Form API Reference

This document provides a programmer's reference to the Drupal Form API. For a brief introduction on how to create forms, see the Form generation guide. For more extensive information about the Form API, see the Form API handbook.

Skip to: Properties | Default Values | Elements

Note that internal properties are not included in the table below, but are included in the Properties list. These include: #built, #children, #error, #id, #input, #printed, #validation_arguments

Form Controls

Legend:
X = attribute can be used with this type
- = attribute is not applicable to this type

#type | checkbox | checkboxes | date | fieldset | file | machine_name | managed_file | password | password_confirm | radio | radios | select | tableselect | text_format | textarea | textfield | vertical_tabs | weight
#access | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #access
#after_build | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #after_build
#ajax | X | X | - | - | - | X | - | - | - | X | X | X | X | X | X | X | - | - | #ajax
#array_parents | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #array_parents
#attached | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #attached
#attributes | X | X | X | X | X | X | X | X | - | X | X | X | X | X | X | X | - | X | #attributes
#autocomplete_path | - | - | - | - | - | X | - | - | - | - | - | - | - | - | - | X | - | - | #autocomplete_path
#collapsed | - | - | - | X | - | - | - | - | - | - | - | - | - | - | - | - | - | - | #collapsed
#collapsible | - | - | - | X | - | - | - | - | - | - | - | - | - | - | - | - | - | - | #collapsible
#cols | - | - | - | - | - | - | - | - | - | - | - | - | - | X | X | - | - | - | #cols
#default_tab | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | X | - | #default_tab
#default_value | X | X | X | - | - | X | - | - | - | X | X | X | X | X | X | X | - | X | #default_value
#delta | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | X | #delta
#description | X | X | X | X | X | X | X | X | X | X | X | X | - | X | X | X | - | X | #description
#disabled | X | X | X | - | X | X | X | X | X | X | X | X | - | X | X | X | - | X | #disabled
#element_validate | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #element_validate
#empty | - | - | - | - | - | - | - | - | - | - | - | - | X | - | - | - | - | - | #empty
#empty_option | - | - | - | - | - | - | - | - | - | - | - | X | - | - | - | - | - | - | #empty_option
#empty_value | - | - | - | - | - | - | - | - | - | - | - | X | - | - | - | - | - | - | #empty_value
#field_prefix | X | - | - | - | - | X | - | X | X | X | - | X | - | - | X | X | - | - | #field_prefix
#field_suffix | X | - | - | - | - | X | - | X | X | X | - | X | - | - | X | X | - | - | #field_suffix
#group | - | - | - | X | - | - | - | - | - | - | - | - | - | - | - | - | - | - | #group
#header | - | - | - | - | - | - | - | - | - | - | - | - | X | - | - | - | - | - | #header
#type | checkbox | checkboxes | date | fieldset | file | machine_name | managed_file | password | password_confirm | radio | radios | select | tableselect | text_format | textarea | textfield | vertical_tabs | weight | #type
#js_select | - | - | - | - | - | - | - | - | - | - | - | - | X | - | - | - | - | - | #js_select
#maxlength | - | - | - | - | - | X | - | X | - | - | - | - | - | - | - | X | - | - | #maxlength
#multiple | - | - | - | - | - | - | - | - | - | - | - | X | X | - | - | - | - | - | #multiple
#options | - | X | - | - | - | - | - | - | - | - | X | X | X | - | - | - | - | - | #options
#parents | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #parents
#post_render | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #post_render
#prefix | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #prefix
#pre_render | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #pre_render
#process | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #process
#required | X | X | X | - | X | X | - | X | X | X | X | X | - | X | X | X | - | X | #required
#resizable | - | - | - | - | - | - | - | - | - | - | - | - | - | X | X | - | - | - | #resizable
#return_value | X | - | - | - | - | - | - | - | - | X | - | - | - | - | - | - | - | - | #return_value
#rows | - | - | - | - | - | - | - | - | - | - | - | - | - | X | X | - | - | - | #rows
#size | - | - | - | - | X | X | - | X | X | - | - | X | - | - | - | X | - | - | #size
#states | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #states
#suffix | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #suffix
#theme | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #theme
#theme_wrappers | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #theme_wrappers
#title | X | X | X | X | X | X | X | X | X | X | X | X | - | X | X | X | - | X | #title
#title_display | X | X | X | X | X | X | X | X | X | X | X | X | - | X | X | X | - | X | #title_display
#tree | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #tree
#value_callback | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #value_callback
#weight | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | #weight

Special Elements

# type | actions | button | container | image_button | submit | form | hidden | token | markup | item | value
#access | X | X | X | X | X | X | X | X | X | X | -
#action | - | - | - | - | - | X | - | - | - | - | -
#after_build | X | X | X | X | X | X | X | X | X | X | -
#ajax | - | X | - | X | X | - | - | - | - | - | -
#attributes | X | X | X | X | X | X | - | - | - | - | -
#button_type | - | X | - | X | X | - | - | - | - | - | -
#default_value | - | - | - | - | - | - | X | X | - | - | -
#description | - | - | - | - | - | - | - | - | - | X | -
#disabled | - | X | - | X | X | - | - | - | - | - | -
#element_validate | - | X | - | X | X | - | X | X | X | X | -
#executes_submit_callback | - | X | - | X | X | - | - | - | - | - | -
#limit_validation_errors | - | X | - | X | X | - | - | - | - | - | -
#markup | - | - | - | - | - | - | - | - | X | X | -
#method | - | - | - | - | - | X | - | - | - | - | -
#name | - | X | - | - | X | - | - | - | - | - | -
#parents | X | X | X | X | X | - | X | X | X | X | -
#post_render | X | X | X | X | X | X | X | X | X | X | -
#prefix | X | X | X | X | X | X | X | X | X | X | -
#pre_render | X | X | X | X | X | X | X | X | X | X | -
#process | X | X | X | X | X | X | X | X | X | X | -
#return_value | - | - | - | X | - | - | - | - | - | - | -
#src | - | - | - | X | - | - | - | - | - | - | -
#submit | - | X | - | X | X | X | - | - | - | - | -
#suffix | X | X | X | X | X | X | X | X | X | X | -
#theme | X | X | X | X | X | X | X | X | X | X | -
#theme_wrappers | X | X | X | X | X | X | X | X | X | X | -
#title | - | - | - | - | - | - | - | - | - | X | -
#title_display | - | - | - | - | - | - | - | - | - | X | -
#tree | X | X | X | X | X | X | X | X | X | X | -
#validate | - | X | - | X | X | X | - | - | - | - | -
#value | - | X | - | X | X | - | X | X | - | - | X
#weight | X | X | X | X | X | - | X | X | X | X | -
# type | actions | button | container | image_button | submit | form | hidden | token | markup | item | value

Default Values

Every element automatically has these default values (see system_element_info()):

  • #description = NULL
  • #attributes = array()
  • #required = FALSE
  • #tree = FALSE
  • #parents = array()

The following is a list of default values which do not need to be set (found in system_element_info):

  • button
    • #name = 'op'
    • #button_type = 'submit'
    • #executes_submit_callback = FALSE
    • #ajax['event'] = 'mousedown'
  • checkbox
    • #return_value = 1
    • #ajax['event'] = 'change'
    • #title_display = 'after'
  • checkboxes
    • #tree = TRUE
  • fieldset
    • #collapsible = FALSE
    • #collapsed = FALSE
  • file
    • #size = 60
  • form
    • #method = 'post'
    • #action = request_uri()
  • image_button
    • #button_type = 'submit'
    • #executes_submit_callback = TRUE
    • #ajax['event'] = 'mousedown'
  • radio
    • #ajax['event'] = 'change'
    • #title_display = 'after'
  • password
    • #size = 60
    • #maxlength = 128
    • #ajax['event'] = 'blur'
  • password_confirm
    • #size = 60
  • submit
    • #name = 'op'
    • #button_type = 'submit'
    • #executes_submit_callback = TRUE
    • #ajax['event'] = 'mousedown'
  • textarea
    • #cols = 60
    • #resizable = TRUE
    • #rows = 5
    • #ajax['event'] = 'blur'
  • textfield
    • #size = 60
    • #maxlength = 128
    • #autocomplete_path = FALSE
    • #ajax['event'] = 'blur'
  • weight
    • #delta = 10

Elements

Note that property names in bold are those that will generally need to be defined when creating this form element. Default values are indicated in parentheses next to property names, if they exist.

actions

Description: A wrapper element to group one or more buttons in a form. Use of the 'actions' element as an array key helps to ensure proper styling in themes and to enable other modules to properly alter a form's actions.

Properties: #access, #after_build, #attributes #children, #id, #parents, #post_render, #pre_render, #prefix, #process, #states, #suffix, #theme, #theme_wrappers, #tree, #type, #weight

Usage example:

<?php
  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  $form['actions']['delete'] = array(
    '#type' => 'button',
    '#value' => t('Delete'),
  );
  $form['actions']['cancel'] = array(
    '#markup' => l(t('Cancel'), 'foo/bar'),
  );
?>

button

Description: Format an action button. When the button is pressed, the form will be submitted to Drupal, where it is validated and rebuilt. The submit handler is not invoked.

Properties: #access, #after_build, #ajax, #attributes, #button_type (default: submit), #disabled, #element_validate, #executes_submit_callback (default: FALSE), #limit_validation_errors, #name (default: op), #parents, #post_render, #prefix, #pre_render, #process, #submit, #states, #suffix, #theme, #theme_wrappers, #tree, #type, #validate, #value, #weight

Usage example (node.module):

<?php
$form['preview'] = array(
  '#type' => 'button',
  '#value' => t('Preview'),
  '#weight' => 19,
);
 ?>

checkbox

Description: Format a checkbox.

Properties: #access, #after_build, #ajax, #attributes, #default_value, #description, #disabled, #element_validate, #field_prefix, #field_suffix, #parents, #post_render, #prefix, #pre_render, #process, #required, #return_value (default: 1), #states, #suffix, #theme, #theme_wrappers, #title, #title_display (default: after), #tree, #type, #weight

Usage example (contact.module):

<?php
$form['copy'] = array(
  '#type' => 'checkbox',
  '#title' => t('Send me a copy.'),
);
?>

checkboxes

Description: Format a set of checkboxes. #options is an associative array, where the key is the #return_value of the checkbox and the value is displayed. The #options array cannot have a 0 key, as it would not be possible to discern checked and unchecked states.

Properties: #access, #after_build, #ajax, #attributes, #default_value, #description, #disabled, #element_validate, #options, #parents, #post_render, #prefix, #pre_render, #process, #required, #states, #suffix, #theme, #theme_wrappers, #title, #title_display, #tree (default: TRUE), #type, #weight

Usage example (form_example_states.inc):

<?php
$form['high_school']['tests_taken'] = array(
  '#type' => 'checkboxes',
  '#options' => drupal_map_assoc(array(t('SAT'), t('ACT'))),
  '#title' => t('What standardized tests did you take?'),
...
),
?>

container

Description: Returns HTML to wrap child elements in a container. Surrounds child elements with a <div> and adds attributes such as classes or an HTML id.

Properties: #access, #after_build, #attributes #children, #id, #parents, #post_render, #pre_render, #prefix, #process, #states, #suffix, #theme, #theme_wrappers, #tree, #type, #weight

Usage example (field.form.inc):

<?php
  if ($elements) {
    // Also aid in theming of field widgets by rendering a classified
    // container.
    $addition[$field_name] = array(
      '#type' => 'container',
      '#attributes' => array(
        'class' => array(
          'field-type-' . drupal_html_class($field['type']),
          'field-name-' . drupal_html_class($field_name),
          'field-widget-' . drupal_html_class($instance['widget']['type']),
        ),
      ),
      '#weight' => $instance['widget']['weight'],
    );
  }
?>

date

Description: Format a date selection box. The #default_value will be today's date if no value is supplied. The format for the #default_value and the #return_value is an array with three elements with the keys: 'year', month', and 'day'. For example, array('year' => 2007, 'month' => 2, 'day' => 15)

Properties: #access, #after_build, #attributes, #default_value, #description, #disabled, #element_validate, #parents, #post_render, #prefix, #pre_render, #process, #required, #states, #suffix, #theme, #theme_wrappers, #title, #title_display, #tree, #type, #weight

Usage example (profile.module):

<?php
$fields[$category][$field->name] = array(
  '#type' => 'date',
  '#title' => check_plain($field->title),
  '#default_value' => $edit[$field->name],
  '#description' => _profile_form_explanation($field),
  '#required' => $field->required
);
?>

fieldset

Description: Format a group of form items.

Properties: #access, #after_build, #attributes, #collapsed (default: FALSE), #collapsible (default: FALSE), #description, #element_validate, #parents, #post_render, #prefix, #pre_render, #process, #states, #suffix, #theme, #theme_wrappers, #title, #title_display, #tree, #type, #weight

Usage example (contact.module):

<?php
$form['contact'] = array(
  '#type' => 'fieldset',
  '#title' => t('Contact settings'),
  '#weight' => 5,
  '#collapsible' => TRUE,
  '#collapsed' => FALSE,
);
?>

file

Description: Format a file upload field.

Note: Drupal will add the code enctype="multipart/form-data", required by browsers to handle files, so it's not necessary to include it yourself.

Properties: #access, #after_build, #array_parents, #attached, #attributes, #description, #disabled, #element_validate, #parents, #post_render, #prefix, #pre_render, #process, #required, #size (default: 60), #states, #suffix, #theme, #theme_wrappers, #title, #title_display, #tree, #type, #weight

Usage example (file.module):

<?php
$element['upload'] = array(
    '#name' => 'files[' . implode('_', $element['#parents']) . ']',
    '#type' => 'file',
    '#title' => t('Choose a file'),
    '#title_display' => 'invisible',
    '#size' => 22,
    '#theme_wrappers' => array(),
    '#weight' => -10,
  );
?>

form

Description: A form containing form elements

Properties: #access, #action (default: request_uri()), #after_build, #attributes, #method (default: 'post'), #post_render, #prefix, #pre_render, #process, #submit, #states, #suffix, #theme, #theme_wrappers, #tree, #validate

Usage example:

N/A

hidden

Description: Store data in a hidden form field.

Properties: #access, #after_build, #default_value, #element_validate, #parents, #post_render, #prefix, #pre_render, #process, #states, #suffix, #theme, #theme_wrappers, #tree, #type, #value, #weight

Usage example (block.module):

<?php
$form['bid'] = array('#type' => 'hidden', '#value' => $bid);
?>

Note that if you plan to use JavaScript to change your hidden element's value, you will need to use the #default_value property rather than #value.

image_button

Description: Format a form submit button with an image.

Properties: #access, #after_build, #ajax, #attributes, #button_type (default: 'submit'), #disabled, #element_validate, #executes_submit_callback (default: TRUE), #limit_validation_errors, #parents, #post_render, #prefix, #pre_render, #process, #return_value (default: TRUE), #src, #submit, #states, #suffix, #theme, #theme_wrappers, #tree, #type, #validate, #value, #weight

item

Description: Generate a display-only form element allowing for an optional title and description.

Note: since this is a read-only field, setting the #required property will do nothing except theme the form element to look as if it were actually required (i.e. by placing a red star next to the #title).

Properties: #access, #after_build, #description, #element_validate, #markup, #parents, #post_render, #prefix, #pre_render, #process, #required, #states, #suffix, #theme, #theme_wrappers, #title, #title_display, #tree, #type, #weight

Usage example (contact.module):

<?php
 $form['from'] = array(
  '#type' => 'item',
  '#title' => t('From'),
  '#markup' => $user->name .' &lt;'. $user->mail .'&gt;',
);
 ?>

machine_name

Description: Format a single-line text field to store a unique machine-readable name.

Provides a form element to enter a machine name, which is validated to ensure that the name is unique and does not contain disallowed characters. All disallowed characters are replaced with a replacement character via JavaScript.

The element validation checks that the submitted value

  • does not contain the replacement character only
  • does not contain disallowed characters
  • is unique; i.e., does not already exist
  • does not exceed the maximum length (via #maxlength)
  • cannot be changed after creation (via #disabled)

Non-standard form element properties:

  • #machine_name: (array)
    • exists: A function name to invoke for checking whether a submitted machine name value already exists. The submitted value is passed as argument. In most cases, an existing API or menu argument function can be re-used. The callback is only invoked, if the submitted value differs from the element's #default_value
    • source: (optional) The #array_parents of the form element containing the human-readable name (i.e., as contained in the $form structure) to use as source for the machine name. Defaults to array('name').
    • label: (optional) A text to display as label for the machine name value after the human-readable name form element. Defaults to "Machine name".
    • replace_pattern: (optional) A regular expression (without delimiters) matching disallowed characters in the machine name. Defaults to '[^a-z0-9_]+'.
    • replace: (optional) A character to replace disallowed characters in the machine name via JavaScript. Defaults to '_' (underscore). When using a different character, 'replace_pattern' needs to be set accordingly.

Properties: #access, #after_build, #ajax, #attributes, #autocomplete_path (default: FALSE), #default_value, #description (default: 'A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'), #disabled, #element_validate, #field_prefix, #field_suffix, #maxlength (default: 64), #parents, #post_render, #prefix, #pre_render, #process, #required (default: TRUE), #size (default: 60), #states, #suffix, #theme (default: 'textfield'), #theme_wrappers (default: 'form_element'), #title (default: 'Machine-readable name'), #title_display #tree, #type, #weight

Usage example (taxonomy.admin.inc):

<?php
$form['machine_name'] = array(
  '#type' => 'machine_name',
  '#default_value' => $vocabulary->machine_name,
  '#maxlength' => 21,
  '#machine_name' => array(
    'exists' => 'menu_edit_menu_name_exists',
  ),
);
?>

Usage example (menu.admin.inc):

<?php
$form['menu_name'] = array(
  '#type' => 'machine_name',
  '#title' => t('Menu name'),
  '#default_value' => $menu['menu_name'],
  '#maxlength' => MENU_MAX_MENU_NAME_LENGTH_UI,
  '#description' => t('A unique name to construct the URL for the menu. It must only contain lowercase letters, numbers and hyphens.'),
  '#machine_name' => array(
    'exists' => 'menu_edit_menu_name_exists',
    'source' => array('title'),
    'label' => t('URL path'),
    'replace_pattern' => '[^a-z0-9-]+',
    'replace' => '-',
  ),
  // A menu's machine name cannot be changed.
  '#disabled' => !empty($menu['old_name']) || isset($system_menus[$menu['menu_name']]),
);
?>

managed_file

Description: Provides a complete ajax/progress aware widget for uploading a file and saving it to the {file_managed} table.

By default a simple upload button is provided for choosing the file to upload. Once a file has been chosen it can be explicitly uploaded via the "Upload" button. The upload is via AJAX and a progress meter is displayed. The form's validate and submit handlers receive a file object ID in $form_state['values'] that represents the ID of the new file in the {file_managed} table.

The #managed_file element is expanded into a set of FAPI elements including two '#submit' buttons one for Upload one for Remove, a '#file' element and a handful of '#hidden' and '#markup' elements to handle progress indication and displaying of already uploaded files.

Note: New files are uploaded with a status of 0 and are treated as temporary files which are removed after 6 hours via cron. Your module is responsible for changing the $file objects status to FILE_STATUS_PERMANENT and saving the new status to the database. Something like the following within your submit handler should do the trick.

<?php
// Load the file via file.fid.
$file = file_load($form_state['values']['my_file_field']);
// Change status to permanent.
$file->status = FILE_STATUS_PERMANENT;
// Save.
file_save($file);
// Record that the module (in this example, user module) is using the file.
file_usage_add($file, 'user', 'user', $account->uid);
?>

(Without the call to file_usage_add, file_managed_file_validate produces an error upon saving the form, saying that the uploaded file may not be referenced.)

Once a file has been uploaded the file object's fid can be used as the #default_value for the form element. This will display an icon, a link to the file, and a remove button.

Clicking the remove button sets the value of the field to 0 and your module is responsible for actually removing the file from the files table and the file system using file_delete().

Non-standard form element properties:

  • #progress_indicator: options are 'none', 'bar', and 'throbber', default is 'throbber'.
  • #progress_message: (string) Progress message to display along with progress meter while a file is being uploaded. Defaults to NULL.
  • #upload_validators: (array) an array of callback functions to perform validation of uploaded files.
  • #upload_location (string) location on server where uploaded files should be stored. e.g.) 'public://files/my_files_director'

Properties: #access, #after_build, #array_parents, #attached, #attributes, #description, #disabled, #element_validate, #parents, #post_render, #prefix, #pre_render, #process, #states, #suffix, #theme, #theme_wrappers, #title, #tree, #weight

Usage example (image_example.pages.inc.):

<?php
// Use the #managed_file FAPI element to upload an image file.
$form['image_example_image_fid'] = array(
  '#title' => t('Image'),
  '#type' => 'managed_file',
  '#description' => t('The uploaded image will be displayed on this page using the image style choosen below.'),
  '#default_value' => variable_get('image_example_image_fid', ''),
  '#upload_location' => 'public://image_example_images/',
);
?>

markup

Description: Generate generic markup for display inside forms. Note that there is no need to declare a form element as #type = 'markup', as this is the default type.

Note: if you use markup, if your content is not wrapped in tags (generally <p> or <div>), your content will fall outside of collapsed fieldsets.

Properties: #access, #after_build, #element_validate, #markup, #parents, #post_render, #prefix, #pre_render, #process, #states, #suffix, #theme, #theme_wrappers, #tree, #type, #weight

Usage example (contact.module):

<?php
$form['contact_information'] = array(
  '#markup' => variable_get('contact_form_information', t('You can leave us a message using the contact form below.')),
);
?>

password

Description: Format a single-line text field that does not display its contents visibly.

Properties: #access, #after_build, #ajax, #attributes, #description, #disabled, #element_validate, #field_prefix, #field_suffix, #maxlength (default: 128), #parents, #post_render, #prefix, #pre_render, #process, #required, #size (default: 60), #states, #suffix, #theme, #theme_wrappers, #title, #title_display, #tree, #type, #weight

Usage example (user.module):

<?php
$form['pass'] = array(
  '#type' => 'password',
  '#title' => t('Password'),
  '#maxlength' => 64,
  '#size' => 15,
);
?>

password_confirm

Description: Format a pair of password fields, which do not validate unless the two entered passwords match.

Properties: #access, #after_build, #description, #disabled, #element_validate, #field_prefix, #field_suffix, #parents, #post_render, #prefix, #pre_render, #process, #required, #size (default: 60), #states, #suffix, #theme, #theme_wrappers, #title, #title_display, #tree, #type, #weight

Usage example (user.module):

<?php
$form['pass'] = array(
  '#type' => 'password_confirm',
  '#title' => t('Password'),
  '#size' => 25,
);
?>

radio

Description: Format a radio button.

Properties: #access, #after_build, #ajax, #attributes, #default_value, #description, #disabled, #element_validate, #field_prefix, #field_suffix, #parents, #post_render, #prefix, #pre_render, #process, #required, #return_value, #states, #suffix, #theme, #theme_wrappers, #title, #title_display (default: after), #tree, #type, #weight

Usage example:

N/A

radios

Description: Format a set of radio buttons.

Properties: #access, #after_build, #ajax, #attributes, #default_value, #description, #disabled, #element_validate, #options, #parents, #post_render, #prefix, #pre_render, #process, #required, #states, #suffix, #theme, #theme_wrappers, #title, #title_display, #tree, #type, #weight

Usage example (poll.module):

<?php
  $active = array(0 => t('Closed'), 1 => t('Active'));
...
  $form['settings']['active'] = array(
    '#type' => 'radios',
    '#title' => t('Poll status'),
    '#default_value' => isset($node->active) ? $node->active : 1,
    '#options' => $active,
    '#description' => t('When a poll is closed, visitors can no longer vote for it.'),
    '#access' => $admin,
  );
?>

select

Description: Format a drop-down menu or scrolling selection box. See #empty_option and #empty_value for an explanation of various settings for a select element, including behavior if #required is TRUE or FALSE.

Properties: #access, #after_build, #ajax, #attributes, #default_value, #description, #disabled, #element_validate, #empty_option, #empty_value, #field_prefix, #field_suffix, #multiple, #options, #parents, #post_render, #prefix, #pre_render, #process, #required, #size, #states, #suffix, #theme, #theme_wrappers, #title, #title_display, #tree, #type, #weight

Usage example (contact.admin.inc):

<?php
  $form['selected'] = array(
    '#type' => 'select',
    '#title' => t('Selected'),
    '#options' => array(
      0 => t('No'),
      1 => t('Yes'),
    ),
    '#default_value' => $category['selected'],
    '#description' => t('Set this to <em>Yes</em> if you would like this category to be selected by default.'),
  );
?>

submit

Description: Format a form submit button.

Properties: #access, #after_build, #ajax, #attributes, #button_type (default: 'submit'), #disabled, #element_validate, #executes_submit_callback (default: TRUE), #limit_validation_errors, #name (default: 'op'), #parents, #post_render, #prefix, #pre_render, #process, #submit, #states, #suffix, #theme, #theme_wrappers, #tree, #type, #validate, #value, #weight

Usage example (locale.module):

<?php
$form['submit'] = array('#type' => 'submit', '#value' => t('Import'));
?>

tableselect

Description: A table created with a far left column of radios or checkboxes. Build the table headings and columns with the #headers property, and the rows with the #options property. See Adding checkboxes to a table for a full explanation.

Other settings:

  • To set accessibility tags for the radios or checkboxes, build one of the cells in the #options property using the 'title' => array( 'data' => array(#title => 'mytitle'))) construction, as in the $options variable in the usage example below. Drupal will create invisible label tags for the left column based on this value.
  • To disable the default "check all" button for the checkboxes, set #js_select property to FALSE. This is FALSE by default for radios.
  • Setting #multiple to TRUE will give you checkboxes instead of radios.

Properties: #access, #after_build, #ajax, #attributes, #default_value, #element_validate, #empty, #header, #js_select, #multiple, #options, #parents, #post_render, #prefix, #pre_render, #process, #states, #suffix, #theme, #theme_wrappers, #tree, #type, #weight

Usage example (node.admin.inc):

<?php
  // Build the sortable table header.
  $header = array(
    'title' => array('data' => t('Title'), 'field' => 'n.title'),
    'type' => array('data' => t('Type'), 'field' => 'n.type'),
    'author' => t('Author'),
    'status' => array('data' => t('Status'), 'field' => 'n.status'),
    'changed' => array('data' => t('Updated'), 'field' => 'n.changed', 'sort' => 'desc')
  );
...
  //Get the node data.
  $nids = $query
    ->fields('n',array('nid'))
    ->limit(50)
    ->orderByHeader($header)
    ->execute()
    ->fetchCol();
  $nodes = node_load_multiple($nids);
...
  //Build the rows.
  $options = array();
  foreach ($nodes as $node) {
...
    $options[$node->nid] = array(
      'title' => array(
        'data' => array(
          '#type' => 'link',
          '#title' => $node->title,
          '#href' => 'node/' . $node->nid,
          '#options' => $l_options,
          '#suffix' => ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))),
        ),
      ),
      'type' => check_plain(node_type_get_name($node)),
      'author' => theme('username', array('account' => $node)),
      'status' => $node->status ? t('published') : t('not published'),
      'changed' => format_date($node->changed, 'short'),
    );
   //For simplicity, this example omits the code to set the operations column.
...
  //Build the tableselect.
  $form['nodes'] = array(
      '#type' => 'tableselect',
      '#header' => $header,
      '#options' => $options,
      '#empty' => t('No content available.'),
    );
?>

text_format

Description: A text-format-enabled version of a textarea.

Properties: #access, #after_build, #ajax, #attributes, #cols (default: 60), #default_value, #description, #disabled, #element_validate, #parents, #post_render, #prefix, #pre_render, #process, #required, #resizable (default: TRUE), #rows (default: 5), #states, #suffix, #theme, #theme_wrappers, #title, #title_display, #tree,#type, #weight

Non-standard Properties:

  • #format: the format to apply. If you want to use the default format, set this property to NULL in your form constructor function, and the filter system will handle the rest.
  • #base_type (optional): defaults to 'textarea'. This makes it possible to also attach the text format selector to other form element types, such as textfields.

Usage example (taxonomy.admin.inc):

<?php
  $form['description'] = array(
    '#type' => 'text_format',
    '#title' => t('Description'),
    '#default_value' => $term->description,
    '#format' => $term->format,
    '#weight' => 0,
  );
?>

textarea

Description: Format a multiple-line text field.

Properties: #access, #after_build, #ajax, #attributes, #cols (default: 60), #default_value, #description, #disabled, #element_validate, #field_prefix, #field_suffix, #parents, #post_render, #prefix, #pre_render, #process, #required, #resizable (default: TRUE), #rows (default: 5), #states, #suffix, #theme, #theme_wrappers, #title, #title_display, #tree, #type, #weight

Usage example (comment.module):

<?php
$form['keywords'] = array(
'#title' => t('Keywords'),
 '#type' => 'textarea',
 '#description' => t ('The comment will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'),
 '#default_value' => isset( $context['keywords']) ? drupal_implode_tags($context['keywords']) : '',
);
 ?>

textfield

Description: Format a single-line text field.

Properties: #access, #after_build, #ajax, #attributes, #autocomplete_path (default: FALSE), #default_value, #description, #disabled, #element_validate, #field_prefix, #field_suffix, #maxlength (default: 128), #parents, #post_render, #prefix, #pre_render, #process, #required, #size (default: 60), #states, #suffix, #text_format, #theme, #theme_wrappers, #title, #title_display, #tree, #type, #weight

Usage example (forum.module):

<?php
$form['title'] = array(
  '#type' => 'textfield',
  '#title' => t('Subject'),
  '#default_value' => $node->title,
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
);
?>

token

Description: Store token data in a hidden form field (generally used to protect against cross-site forgeries). A token element is automatically added to each Drupal form by drupal_prepare_form(), so you don't generally have to add one yourself.

Properties: #access, #after_build, #default_value, #element_validate, #parents, #post_render, #prefix, #pre_render, #process, #states, #suffix, #theme, #theme_wrappers, #tree, #type, #value, #weight

value

Description: A form value that is internal to the form and never displayed to the screen.

Properties: #type, #value

Usage example (node.module):

<?php
$form['vid'] = array('#type' => 'value', '#value' => $node->vid);
?>

Note that as of Drupal 6, you can also simply store arbitrary variables in $form['#foo'] instead, as long as '#foo' does not conflict with any other internal property of the Form API.

vertical_tabs

Description: Formats all child fieldsets and all non-child fieldsets whose #group is assigned this element's name as vertical tabs.

Properties: #access, #after_build, #default_tab, #element_validate, #parents, #post_render, #prefix, #pre_render, #process, #states, #suffix, #theme, #theme_wrappers, #tree, #type, #weight

Functions that use vertical_tabs:
block_admin_configure in block.admin.inc
user_admin_settings in user.admin.inc

weight

Description: Format a weight selection menu.

Properties: #access, #after_build, #attributes, #default_value, #delta (default: 10), #description, #disabled, #element_validate, #parents, #post_render, #prefix, #pre_render, #process, #required, #states, #suffix, #theme, #theme_wrappers, #title, #title_display, #tree, #type, #weight

Usage example (menu.module):

<?php
$form['weight'] = array(
  '#type' => 'weight',
  '#title' => t('Weight'),
  '#default_value' => $edit['weight'],
  '#delta' => 10,
  '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
);
?>

Properties

#access

Used by: All elements and forms

Description: Whether the element is accessible or not; when FALSE, the element is not rendered and the user submitted value is not taken into consideration.

Values: TRUE or FALSE.

#action

Used by: form

Description: The path to which the form will be submitted.

Values: An internal path

Usage example (comment.module):

<?php
$form['#action'] = url('comment/reply/'. $edit['nid']);
 ?>

#after_build

Used by: All elements and forms

Description: An array of function names which will be called after the form or element is built.

Usage example (system.admin.inc):

<?php
  $form['file_public_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Public file system path'),
    '#default_value' => variable_get('file_public_path', conf_path() . '/files'),
    '#maxlength' => 255,
    '#description' => t('A local file system path where public files will be stored. This directory must exist and be writable by Drupal. This directory must be relative to the Drupal installation directory and be accessible over the web.'),
    '#after_build' => array('system_check_directory'),
  );
?>

#ajax

Used by: button, checkbox, checkboxes, image button, password, radio, radios, select, submit, tableselect, textarea, text_format, textfield

An array of elements whose values control the behavior of the element with respect to the Drupal AJAX framework.

AJAX (Asynchronous Javascript and XML) is a term used for dynamic communication between the browser and the server, without page reloads. A purist would insist that the Drupal technique is AHAH (Asychronous HTML and HTTP) because XML is not used. Until Drupal 7, AJAX was known as AHAH. In a nutshell an AJAX request follows these steps:

  1. Drupal builds a form element with a set of #ajax properties. The misc/ajax.js file is included on the page automatically.
  2. ajax.js finds all the form elements on the page that have an #ajax['callback'] or an #ajax['path'] set and adds an event handler for the #ajax['event'] set on that form element.
  3. When the #ajax['event'] occurs on the element (such as 'click'), the AJAX request is made to the Drupal path of the element's #ajax['path']. If an #ajax['callback'] has been specified (the normal case), the Drupal path will be system/ajax.
  4. Form information gets processed, and the function specified in #ajax['callback'] is called. #ajax['callback'] can return either HTML, a renderable array, or an array of AJAX commands.
  5. While the user waits for the callback to execute a throbber or progress bar is shown as determined by #ajax['progress']. The result is returned to the original page containing the form element.
  6. ajax.js gets the result. If it is HTML and #ajax['wrapper'] is set, the HTML replaces the element specified by #ajax['wrapper']. If it is an array of AJAX commands, the commands are executed. and inserts the returned HTML into the #ajax['wrapper'].

Example usages of basic AJAX and AJAX commands are provided in the Examples module.

#ajax['callback']

Description: Specifies the name of a callback function which will be called during an AJAX call. It can return HTML, a renderable array, or an array of AJAX Commands. This callback function is given the $form and $form_state parameters, allowing it to produce a result, which it returns for rendering.

Note: #ajax['callback'] and #ajax['path'] are mutually exclusive. 'callback' is easier to use and requires less code setup, but may not provide the capabilities required for some functions. When you can, use 'callback'.

Values: String containing a function name.

Usage example (poll.module):

<?php
/**
 * Implementation of hook_form().
 */
function poll_form(&$node, $form_state) {
  ...
  $form['choice_wrapper']['poll_more'] = array(
    '#type' => 'submit',
    '#value' => t('More choices'),
    '#description' => t("If the amount of boxes above isn't enough, click here to add more choices."),
    '#weight' => 1,
    '#submit' => array('poll_more_choices_submit'), // If no javascript action.
    '#ajax' => array(
      'callback' => 'poll_choice_js',
      'wrapper' => 'poll-choices',
      'method' => 'replace',
      'effect' => 'fade',
    ),
  );
  ...
}

/**
 * Menu callback for AJAX additions. Render the new poll choices.
 */
function poll_choice_js($form, $form_state) {
  return $form['choice_wrapper']['choice'];
}
?>

#ajax['effect']

Description: Specifies the effect used when adding the content from an AJAX request.

Values: String. Possible values: 'none' (default), 'fade', 'slide'. If the interface elements library is installed, any effect with the name effectToggle may also be used.

#ajax['event']

Description: When this event occurs to this element, Drupal will perform an HTTP request in the background via Javascript.

Values: String. Possible values: Any valid jQuery event, including 'mousedown' (for submit, imagebutton, and button), 'blur' (for textfield and textarea), 'change' (for select). Note that #ajax['event'] does not need to be explicitly specified. Although it can be manually set, usually the default value will be sufficient.

#ajax['keypress']

Description: If set to TRUE, then the element's #ajax['event'] will be triggered if the ENTER key is pressed while the element has focus.

#ajax['method']

Description: Modify the behavior of the returned HTML from an AJAX request when inserting into the #ajax['wrapper']. If not set, the returned HTML will replace the contents of the wrapper element, but it's also possible to use any of the available jQuery operations for DOM manipulation.

Values: String. Possible values: 'replace' (default), 'after', 'append', 'before', 'prepend'.

#ajax['path']

Description: This is the Drupal menu path for a callback function which will generate HTML and return the string of HTML to Drupal. The result will replace the div specified in #ajax['wrapper']. This property is infrequently used in Drupal 7 and higher, because it is set automatically if using the #ajax['callback'] property. When using #ajax['callback'] the path is automatically set to system/ajax, which provides a menu callback that can be used for many situations.

Note: 'path' and 'callback' are mutually exclusive.

Values: String containing a Drupal menu path.

#ajax['prevent']

Description: A JavaScript event to prevent when 'event' is triggered. Defaults to 'click' for #ajax on #type 'submit', 'button', and 'image_button'. Multiple events may be specified separated by spaces. For example, when binding #ajax behaviors to form buttons, pressing the ENTER key within a textfield triggers the 'click' event of the form's first submit button. Triggering Ajax in this situation leads to problems, like breaking autocomplete textfields. Because of that, Ajax behaviors are bound to the 'mousedown' event on form buttons by default. However, binding to 'mousedown' rather than 'click' means that it is possible to trigger a click by pressing the mouse, holding the mouse button down until the Ajax request is complete and the button is re-enabled, and then releasing the mouse button. For this case, 'prevent' can be set to 'click', so an additional event handler is bound to prevent such a click from triggering a non-Ajax form submission. This also prevents a textfield's ENTER press triggering a button's non-Ajax form submission behavior.

Values: String. Possible values: One or more jQuery events, with multiple events separated by space characters.

#ajax['progress']

Description: Choose either a throbber or progress bar that is displayed while awaiting a response from the callback, and add an optional message.

Values: Array.

Possible keys: 'type', 'message', 'url', 'interval'

Possible values:

  • #ajax['progress']['type'] String. Possible values: 'throbber' (default), 'bar'.
  • #ajax['progress']['message'] String. An optional message to the user; should be wrapped with t().
  • #ajax['progress']['url'] String. The optional callback path to use to determine how full the progress bar is (as defined in progress.js). Only useable when 'type' is 'bar'.
  • #ajax['progress']['interval'] String. The interval to be used in updating the progress bar (as defined in progress.js). Ony used if 'url' is defined and 'type' is 'bar'.

Usage example (file.module):

<?php
  $ajax_settings['progress']['type'] ? $ajax_settings['progress']['type'] == 'bar' : 'throbber';
  $ajax_settings['progress']['message'] = NULL;
  $ajax_settings['effect'] = 'none';
  $element['remove_button'] = array(
    '#name' => implode('_', $element['#parents']) . '_remove_button',
    '#type' => 'submit',
    '#value' => t('Remove'),
    '#validate' => array(),
    '#submit' => array('file_managed_file_submit'),
    '#limit_validation_errors' => array($element['#parents']),
    '#ajax' => $ajax_settings,
    '#weight' => -5,
  );
?>

#ajax['trigger_as']

Description: For a non-submit, non-button element, allows selection of the submit element which will be activated when the element is triggered. For example, if a select element is ajax-enabled, and it changes, an element identified by #ajax['trigger_as']['name'] or #ajax['trigger_as']['value'] will be used as the triggering element, especially for button-level validation.

Values: Array.

Possible values

  • array('name' => some_submit_or_button_name)
  • array('value' => some_submit_or_button_value)

Note that if #tree == TRUE, #name encodes the parents of the element in it, as when used with form_set_error(), i.e. "level1][level2][element".

#ajax['wrapper']

Description: This property defines the HTML id attribute of an element on the page which will be replaced by the html returned by the #ajax['path'] or #ajax['callback'] function. Usually, a div element is used as the wrapper, as it provides the most flexibility for placement of elements before, after, or inside of its HTML tags. This property is required for using AJAX requests in on a form element. Note that the entire element with this ID is replaced, not just the contents of the element.

Values: String containg a valid id attribute of an HTML element on the same page. This must not contain the '#' character that a selector would have.

Usage example (upload.module):

    $form['new']['attach'] = array(
      '#type' => 'submit',
      '#value' => t('Attach'),
      '#name' => 'attach',
      '#ajax' => array(
        'path' => 'upload/js',
        'wrapper' => 'attach-wrapper',
        'progress' => array('type' => 'bar', 'message' => t('Please wait...')),
      ),
      '#submit' => array('node_form_submit_build_node'),
    );

#array_parents

Used by: All form elements

Description: (read-only, and mostly internal). The array of names of the element's parents (including itself) in the form. This will always match the structure of $form. It is different from #parents in that #parents lists only the structure used in $form_state['values'], which is flat unless #tree is set to TRUE. Please see the complete comparison between #parents and #array_parents.

#attached

Used by: All form elements

Description: Allows loading of CSS, Javascript, libraries, or custom types when the form is built.

Values: A keyed array of type => value pairs, where the type (most often 'css', 'js', and 'library') determines the loading technique, and the value provides the options presented to the loader function. See the example below and the loader functions drupal_add_css(), drupal_add_js(), drupal_add_library(), etc.

See drupal_process_attached() for additional information.

Usage example (AJAX Example):

$form['#attached']['css'] = array(
drupal_get_path('module', 'ajax_example') . '/ajax_example.css',
);
$form['#attached']['js'] = array(
drupal_get_path('module', 'ajax_example') . '/ajax_example.js',
);

The above javascript #attach could also be written as:

$form['#attached']['js'] = array(
  drupal_get_path('module', 'ajax_example') . '/ajax_example.js' => array(
  'type' => 'file',
  ),
);

and inline javascript can be loaded with the javascript as the key of the array, as described in drupal_add_js().

Adding settings

You add a javascript setting by using the 'data' key (as php keys can't be arrays):

$settings = array('id' => 'mymodule-element-1');
$form['#attached']['js'][] = array(
  'data' => array('mymodule' => $settings),
  'type' => 'setting',
);

Usage example (contact.pages.inc):

<?php
if (!$user->uid) {
$form['#attached']['library'][] = array('system', 'jquery.cookie');
$form['#attributes']['class'][] = 'user-info-from-cookie';
}
?>

#attributes

Used by: actions, button, checkbox, checkboxes, container, date, fieldset, file, form, image_button, password, radio, radios, select, submit, tableselect, textarea, text_format, textfield, weight

Description: Additional HTML attributes, such as 'class' can be set using this mechanism.

Values: Any HTML attribute not covered by other properties, e.g. class (for control types), enctype (for forms).

Usage example (search.module):

Note: If you are altering an existing form via hook_form_alter() or a similar means, be careful with this property! You will probably want to add to the existing array rather than writing over it, so don't follow this usage example exactly.

<?php
$form['#attributes'] = array('class' => array('search-form'));
?>

#autocomplete_path

Used by: textfield

Description: The path the AJAX autocomplete script uses as the source for autocompletion.

Usage example (node.module):

<?php
$form['author']['name'] = array(
  '#type' => 'textfield',
  '#title' => t('Authored by'),
  '#maxlength' => 60,
  '#autocomplete_path' => 'user/autocomplete',
  '#default_value' => $node->name,
  '#weight' => -1,
);
?>

#built

Used by: form

Description: Used to ascertain whether or not a form element has been built yet.

Values: TRUE or FALSE

Usage example: INTERNAL. See the _form_builder function in form.inc.

#button_type

Used by: button, image_button, submit

Description: Adds a CSS class to the button, in the form form-[button_type_value]. Note that this does NOT set the HTML attribute type of the button.

Values: String

Usage example: (system.module):

$types['submit'] = array(
  '#input' => TRUE,
  '#name' => 'op',
  '#button_type' => 'submit',
  '#executes_submit_callback' => TRUE,
  '#limit_validation_errors' => FALSE,
  '#process' => array('ajax_process_form'),
  '#theme_wrappers' => array('button'),
);

#children

Used by: All elements.

Description: Internal. The rendered child elements of an element. Automatically assigned by drupal_render(), unless already set. In rare cases, you may use #children to override the output of rendered child elements, for example in a #theme_wrappers or #post_render callback. Normally, you should not have to use #children, use regular child elements instead. (See actions for an example.)

Values: String representing the rendered child elements of an element.

Usage example theme_container()):
Example in a #theme_wrappers callback.

<?php
function theme_container($variables) {
  $element = $variables['element'];

  // ...

  return '<div' . drupal_attributes($element['#attributes']) . '>' . $element['#children'] . '</div>';
}
?>

#collapsed

Used by: fieldset

Description: Indicates whether or not the fieldset is collapsed by default. See #collapsible property.

Values: TRUE or FALSE

Usage example (block.module) :

<?php
$form['block'] = array(
  '#type' => 'fieldset',
  '#title' => t('Block configuration'),
  '#weight' => 3,
  '#collapsible' => TRUE,
  '#collapsed' => FALSE,
  '#tree' => TRUE,
);
?>

#collapsible

Used by: fieldset

Description: Indicates whether or not the fieldset can be collapsed with JavaScript. See #collapsed property.

Values: TRUE or FALSE

Usage example (block.module):

<?php
$form['block'] = array(
  '#type' => 'fieldset',
  '#title' => t('Block configuration'),
  '#weight' => 3,
  '#collapsible' => TRUE,
  '#collapsed' => FALSE,
  '#tree' => TRUE,
);
?>

#cols

Used by: text_format, textarea

Description: How many columns wide the textarea should be (see also #rows)

Values: A positive number

Usage example (aggregator.module):

<?php
$form['description'] = array(
  '#type' => 'textarea',
  '#title' => t('Description'),
  '#default_value' => $edit['description'],
  '#cols' => 60,
  '#rows' => 5,
);
?>

#default_tab

Used by: vertical_tabs

Description: The default open tab.

Values: String containing the HTML ID of the fieldset element for the default tab. The default value is an empty string, which results in the first tab having the focus. The fieldset's HTML ID typically takes the form of "edit-ARRAY_KEY".

Usage example:

<?php
$form['vertical_tabs'] = array(
'#type' => 'vertical_tabs',
'#default_tab' => 'edit-tab2',
);
$form['tab1'] = array(
'#type' => 'fieldset',
'#title' => t('Tab 1'),
'#collapsible' => TRUE,
'#group' => 'vertical_tabs',
);
$form['tab1']['field1'] = array(
'#title' => t('Field 1'),
'#type' => 'textfield',
);
$form['tab2'] = array(
'#type' => 'fieldset',
'#title' => t('Tab 2'),
'#collapsible' => TRUE,
'#group' => 'vertical_tabs',
);
$form['tab2']['field2'] = array(
'#title' => t('Field 2'),
'#type' => 'textfield',
);
?>

#default_value

Used by: checkbox, checkboxes, date, hidden, radio, radios, select, tableselect, textarea, text_format, textfield, token, weight

Description: The value of the form element that will be displayed or selected initially if the form has not been submitted yet. Should NOT be confused with #value, which is a hard-coded value the user cannot change!

Values: Mixed

Usage example (forum.module):

<?php
$form['body'] = array(
  '#type' => 'textarea',
  '#title' => t('Body'),
  '#default_value' => $node->body,
  '#required' => TRUE,
);
?>

#delta

Used by: weight

Description: Number of weights to have selectable. For example, with $delta => 10, the weight selection box would display numbers from -10 to 10.

Values: A positive number

Usage example (menu.module):

<?php
$form['weight'] = array(
  '#type' => 'weight',
  '#title' => t('Weight'),
  '#default_value' => $edit['weight'],
  '#delta' => 10,
  '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
);
?>

#description

Used by: checkbox, checkboxes, date, fieldset, file, item, password, password_confirm, radio, radios, select, text_format, textarea, textfield, weight

Description: The description of the form element. Make sure to enclose inside the t() function so this property can be translated.

Values: Mixed

Usage example (menu.module):

<?php
$form['weight'] = array(
  '#type' => 'weight',
  '#title' => t('Weight'),
  '#default_value' => $edit['weight'],
  '#delta' => 10,
  '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
);
?>

#disabled

Used by: button, checkbox, checkboxes, date, file, image_button, password, password_confirm, radio, radios, select, submit, text_format, textarea, textfield, weight

Description: Disables (greys out) a form input element. Setting #disabled to TRUE results in user input being ignored, regardless of how the element is themed or whether JavaScript is used to change the control's attributes.

Values: TRUE or FALSE

Usage example (system.module):

<?php
      if (isset($disabled[$name])) {
        $form['theme_settings'][$name]['#disabled'] = TRUE;
      }
?>

#element_validate

Used by: Any element.

Description: A list of custom validation functions. The validation functions must use form_error() or form_set_error() to flag the element as having an error if the validation fails.

Values: An array of function names to be called to validate this element (and/or its children).

A validation function for an element takes $element, $form_state, and $form as parameters, and has the form:

function myelement_validate($element, &$form_state, $form) {
   if (empty($element['#value'])) {
     form_error($element, t('This field is required.'));
   }
}

Usage example (file.field.inc):

Note: If you are altering an existing form element via hook_form_alter() or a similar means, be careful with this property! You will probably want to add to the existing array rather than writing over it, so in that case don't follow this usage example exactly.

You'll notice that the validation function below includes only the first two arguments. $form is the same as $form_state['complete form'], so the third parameter is in fact contained in the second parameter.

<?php
$form['max_filesize'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum upload size'),
    '#default_value' => $settings['max_filesize'],
    '#description' => t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current limit <strong>%limit</strong>).', array('%limit' => format_size(file_upload_max_size()))),
    '#size' => 10,
    '#element_validate' => array('_file_generic_settings_max_filesize'),
    '#weight' => 5,
  );
...
function _file_generic_settings_max_filesize($element, &$form_state) {
  if (!empty($element['#value']) && !is_numeric(parse_size($element['#value']))) {
    form_error($element, t('The "!name" option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).', array('!name' => t($element['title']))));
  }
}
?>

#empty

Used by: tableselect

Description: Text to display if the #options property is empty.

Values: Text, enclosed in the t() translation function.

#empty_option

Used by: select

Description: The label to show for the initial option denoting no selection in a select element. By default, the label is automatically set to "- Select -" for a required field and "- None -" for an optional field.

Values: Text, enclosed in the t() translation function.

Note: Use of this property plays a part in several possible states for a select field:

  • If #required is TRUE and there is no #default_value, an empty option is added to the select control to force the user to make an active choice.
  • If #empty_value or #empty_option is set and #required is FALSE (default), an empty option is added to the select control, allowing the user to choose nothing.
  • If none of #required, #empty_value, #empty_option, and #default_value are set, then no empty option is added to the select control. This leaves the control in a slightly illogical state, since all user agents automatically preselect the first available option.There's no way for the user to select nothing, and the user is also not forced to make an active decision.

#empty_value

Used by: select

Description: The value for the initial option denoting no selection in a select element, which is used to determine whether the user submitted a value or not.

Values: Defaults to empty string. Can be anything except NULL.

Note: Use of this property plays a part in several possible states for a select field:

  • If #required is TRUE and there is no #default_value, an empty option is added to the select control to force the user to make an active choice.
  • If #empty_value or #empty_option is set and #required is FALSE (default), an empty option is added to the select control, allowing the user to choose nothing.
  • If none of #required, #empty_value, #empty_option, and #default_value are set, then no empty option is added to the select control. This leaves the control in a slightly illogical state, since all user agents automatically preselect the first available option. There's no way for the user to select nothing, and the user is also not forced to make an active decision.

#error

INTERNAL. Indicates whether or not a form element has been flagged as having an error.

#executes_submit_callback

Used by: button, image_button, submit

Description: Indicates whether or not button should submit the form.

Values: TRUE or FALSE

#field_prefix

Used by: checkbox, machine_name, password, password_confirm, radio, select, textarea, textfield

Description: Text or code that is placed directly in front of the textfield. This can be used to prefix a textfield with a constant string.

Values: Mixed

Usage example (system.module):

<?php
$form['site_403'] = array(
  '#type' => 'textfield',
  '#title' => t('Default 403 (access denied) page'),
  '#default_value' => variable_get('site_403', ''),
  '#size' => 40,
  '#description' => t('This page is displayed when the requested document is denied to the current user. If unsure, specify nothing.'),
  '#field_prefix' => url(NULL, NULL, NULL, TRUE) . (variable_get('clean_url', 0) ? '' : '?q=')
);
?>

#field_suffix

Used by: checkbox, machine_name, password, password_confirm, radio, select, textarea, textfield

Description: Text or code that is placed directly after a textfield. This can be used to add a unit to a textfield.

Values: Mixed

Usage example (system.module):

<?php
$form['settings_general']['upload_usersize_default'] = array(
  '#type' => 'textfield',
  '#title' => t('Default total file size per user'),
  '#default_value' => $upload_usersize_default,
  '#size' => 5,
  '#maxlength' => 5,
  '#description' => t('The default maximum size of all files a user can have on the site.'),
  '#field_suffix' => t('MB')
);
?>

#group

Used by: fieldset

Description: Specifies a group that can be used to group fieldsets into vertical tabs.

Values: A string where the value is used for the id of a form element with the #type of vertical_tabs.

Usage example (user.admin.inc):

<?php
$form['email'] = array(
  '#type' => 'vertical_tabs',
);
...
 $form['email_admin_created'] = array(
  '#type' => 'fieldset',
  '#title' => t('Welcome (new user created by administrator)'),
  '#collapsible' => TRUE,
  '#collapsed' => (variable_get('user_register', 1) != 0),
  '#description' => t('Edit the welcome e-mail messages sent to new member accounts created by an administrator.'),
  '#group' => 'email'
);
?>

#header

Used by: tableselect

Description: Column headers.

Values: Associative array where the keys are the field names to use for each column, and the values are the translated text to display for each column header.

#id

Description: Internal. Used to populate form elements' id property. In rare cases, you can set this value yourself on a form element, to override the default setting.

Value: HTML id string.

#input

INTERNAL. Indicates whether or not input is possible for this form element.

#js_select

Used by: tableselect

Description: Whether to include a select all checkbox.

Values: TRUE to add a select all box to each row of the table, FALSE to omit the select all box. Only applies if #multiple is also TRUE.

#limit_validation_errors

Used by: button, image_button, submit

Description: Provides an array of sections which are parts of $form_state['values'] which should be validated, implying that sections which are not listed should not be validated. This is normally used in multistep forms in the case of a "back" button, for example, where '#limit_validation_errors' => array() would mean not to validate anything as form values on the current page are to be discarded anyway. #limit_validation_errors does not have any effect if #submit is not set. More discussion is in the form_set_error() documentation.

Values: array indicating sections of the $form_state['values'] which should be validated.

#markup

Used by: item, markup

Description: Used to set HTML that will be output on the form.

Values: Text (valid HTML)

Usage example (contact.module):

<?php
  $form['from'] = array(
    '#type' => 'item',
    '#title' => t('From'),
    '#markup' => check_plain($user->name) . ' &lt;' . check_plain($user->mail) . '&gt;',
  );
?>

#maxlength

Used by: password, textfield

Description: The maximum amount of characters to accept as input.

Values: A positive number.

Usage example (forum.module):

<?php
$form['title'] = array(
  '#type' => 'textfield',
  '#title' => t('Subject'),
  '#default_value' => $node->title,
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
);
?>

#method

Used by: form

Description: The HTTP method with which the form will be submitted.

Values: get or post. Default is post.

Usage example (node.module):

<?php
$form['#method'] = 'post';
?>

#multiple

Used by: select, tableselect

Description: Indicates whether the user may select more than one item.

Values: TRUE or FALSE

Usage example (taxonomy.module):

<?php
 return array(
  '#type' => 'select',
  '#title' => $title,
  '#default_value' => $value,
  '#options' => $options,
  '#description' => $description,
  '#multiple' => $multiple,
  '#size' => $multiple ? min(12, count($options)) : 0,
  '#weight' => -15,
);
?>

#name

Used by: button, submit

Values: String.

#options

Used by: checkboxes, radios, select, tableselect

Description: Selectable options for a form element that allows multiple choices.

Values: An array in the form of array(t('Display value 1'), t('Display value 2')) or array('return_value1' => t('Display Value 1'), 'return_value2' => t('Display Value 2')) if specific return values are required. If returned values are identical to displayed values, you can use drupal_map_assoc() as in the example below. The #options property needs special handling for checkboxes, and works completely differently for tableselect. See the respective element descriptions for details.

Usage example (form_example_states.inc):

<?php
  $form['undergraduate']['school_country'] = array(
    '#type' => 'select',
    '#options' => drupal_map_assoc(array(t('UK'), t('Other'))),
    '#title' => t('In what country is your college or university located?'),
  );
?>

#parents

Used by: All

Description: Identifies parent form elements. See #tree and #parents in the handbook and the complete comparison between #parents and #array_parents.

Values: An array of element names.

Usage example (comment.module):

<?php
$form['admin']['status'] = array(
  '#type' => 'radios',
  '#parents' => array('status'),
  '#title' => t('Status'),
  '#default_value' => $status,
  '#options' => array(t('Published'), t('Not published')),
  '#weight' => -1,
);
?>

#post_render

Used by: All elements and forms

Description: Function(s) to call after rendering in drupal_render() has occured. The named function is called with two arguments, the rendered element and its children. It returns the (potentially) altered) element content.

Values: An array of function names to call.

Usage example:

Note: If you are altering an existing form via hook_form_alter() or a similar means, be careful with this property! You will probably want to add to the existing array rather than writing over it, so don't follow this usage example exactly.

<?php
$form['admin']['#post_render'] = array('admin_form_html_cleanup');
?>

This example would call admin_form_html_cleanup($content, $element) after $element has been rendered to $content via drupal_render(). $content may then be modified and must be returned.

#prefix

Used by: All elements and forms.

Description: Text or markup to include before the form element. Also see #suffix.

Values: Mixed

Usage example (poll.module):

<?php
$form['choice'] = array(
  '#type' => 'fieldset',
  '#title' => t('Choices'),
  '#prefix' => '<div class="poll-form">',
  '#suffix' => '</div>',
  '#tree' => TRUE,
);
?>

#pre_render

Used by: All elements and forms.

Description: Function(s) to call before rendering in drupal_render() has occured. The function(s) provided in #pre_render receive the element as an argument and must return the altered element.

Values: An array of function names to call.

Usage example (filter.module):

Note: If you are altering an existing form via hook_form_alter() or a similar means, be careful with this property! As demonstrated here, you will probably want to add to the existing array rather than writing over it.

// Prepend #pre_render callback to replace field value with user notice
// prior to rendering.
if (!isset($element['value']['#pre_render'])) {
  $element['value']['#pre_render'] = array();
}
array_unshift($element['value']['#pre_render'], 'filter_form_access_denied');

...
function filter_form_access_denied($element) {
  $element['#value'] = t('This field has been disabled because you do not have sufficient permissions to edit it.');
  return $element;
}

This example would call filter_form_access_denied($element) before the $element has been rendered via drupal_render(). $element may then be modified and is returned for rendering.

#printed

INTERNAL. Used to determine whether or not a form element has been printed yet.

#process

Used by: All

Description: An array of functions that are called when an element is processed. Using this callback, modules can "register" further actions. For example, the "radios" form type is expanded to multiple radio buttons using a processing function.

Values: Array of function names (strings)

Usage example (system.module) in system_element_info():

Note: If you are altering an existing form via hook_form_alter() or a similar means, be careful with this property! You will probably want to add to the existing array rather than writing over it, so don't follow this usage example exactly.

<?php
$types['radios'] = array(
'#input' => TRUE,
'#process' => array('form_process_radios'),
'#theme_wrappers' => array('radios'),
'#pre_render' => array('form_pre_render_conditional_form_element'),
);
?>

In this example, the function form_process_radios is called; the entire radios element is passed in as the argument. This function expands a radios element into individual radio buttons.

#processed

INTERNAL. Used to ascertain whether or not a form element has been processed (ie: expanded to multiple elements).

#required

Used by: checkbox, checkboxes, date, file, password, password_confirm, radio, radios, select, text_format, textarea, textfield, weight

Description: Indicates whether or not the element is required. This automatically validates for empty fields, and flags inputs as required. File fields are NOT allowed to be required.

Values: TRUE or FALSE

Usage example (forum.module):

<?php
$form['title'] = array(
  '#type' => 'textfield',
  '#title' => t('Subject'),
  '#default_value' => $node->title,
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
);
?>

#resizable

Used by: text_format, textarea

Description: Whether users should be allowed to resize the text area

Values: TRUE or FALSE

#return_value

Used by: checkbox, image_button, radio

Description: Value element should return when selected

Values: Mixed

Usage example (poll.module):

<?php
$form['morechoices'] = array(
  '#type' => 'checkbox',
  '#title' => t('Need more choices'),
  '#return_value' => 1,
  '#default_value' => 0,
  '#description' => t("If the amount of boxes above isn't enough, check this box and click the Preview button below to add some more."),
);
?>

#rows

Used by: text_format, textarea

Description: How many rows high the textarea should be (see also #cols)

Values: A positive number

Usage example (aggregator.module):

<?php
$form['description'] = array(
  '#type' => 'textarea',
  '#title' => t('Description'),
  '#default_value' => $edit['description'],
  '#cols' => 60,
  '#rows' => 5,
);
?>

#size

Used by: file, password, password_confirm, select, textfield

Description: Width of the textfield (in characters) or size of multiselect box (in lines).

Values: A positive number.

Usage example (comment.module):

<?php
        $form['admin']['homepage'] = array(
          '#type'=> 'textfield',
          '#title'=> t('Homepage'),
          '#maxlength'=> 255,
          '#size'=> 30,
          '#default_value'=> $edit['homepage'],
        );
?>

#src

Used by: image_button

Description: The URL of the image of the button.

Values: A URL.

#states

Used by: any element

Description: Adds JavaScript to the element to allow it to have different active states.

Values: A structured array describing the different JavaScript states that can be applied to the element when certain conditions are met. Please read the extensive description of this feature at drupal_process_states().

Usage example

$form['email_canceled']['settings'] = array(
    '#type' => 'container',
    '#states' => array(
      // Hide the settings when the cancel notify checkbox is disabled.
      'invisible' => array(
       ':input[name="email_canceled_toggle"]' => array('checked' => FALSE),
      ),
    ),
  );

#submit

Used by: button, image_button, submit, form

Description: A list of custom submit functions that will be called when the element is submitted. This is usually to add additional submit functions to a form, or to use an alternate function rather than the default form submission function which is the form ID with _submit appended to it.

Values: An array of function names. Each such function will take $form and $form_state as parameters.

Usage example (node_form()):

if (!empty($node->nid) && node_access('delete', $node)) {
 $form['actions']['delete'] = array(
  '#type' => 'submit',
  '#value' => t('Delete'),
  '#weight' => 15,
  '#submit' => array('node_form_delete_submit'),
 );

#suffix

Used by: All elements and forms.

Description: Text or markup to include after the form element. Also see #prefix.

Values: Mixed

Usage example (poll.module):

<?php
$form['choice'] = array(
  '#type' => 'fieldset',
  '#title' => t('Choices'),
  '#prefix' => '<div class="poll-form">',
  '#suffix' => '</div>',
  '#tree' => TRUE,
);
?>

#theme

Used by: All elements and forms.

Description: Theme function to call for element. It must render this element and all of its child elements.

Values: The name of a theme function, without the initial 'theme_'.

Usage example (node.module):

<?php
$data['actions']['output'][] = array(
        '#theme' => 'menu_local_action',
        '#link' => $item,
      );
?>

#theme_wrappers

Used by: All elements and forms.

Description: Theme function to call for element, after the element and children are rendered, but before the #post_render functions are called.

Values: The name of a theme function, without the initial 'theme_'.

Usage example (system.module from definition of default properties for a form):

<?php
$type['form'] = array('#theme_wrappers' => array('form'));
?>

#title

Used by: checkbox, checkboxes, date, fieldset, file, item, password, password_confirm, radio, radios, select, text_format, textarea, textfield, weight

Description: The title of the form element. Make sure to enclose inside the t() function so this property can be translated.

Values: Mixed

Usage example (aggregator.module):

<?php
$form['description'] = array(
  '#type' => 'textarea',
  '#title' => t('Description'),
  '#default_value' => $edit['description'],
  '#cols' => 60,
  '#rows' => 5,
);
?>

#title_display

Used by: checkbox, checkboxes, date, fieldset, file, item, password, password_confirm, radio, radios, select, text_format, textarea, textfield, weight

Description: Indicates how the label should be rendered. The label includes the #title and the required marker, if #required. If the #title is empty but the field is #required, the label will contain only the required marker.

Values: String.

Possible values:

  • before: The label is output before the element. This is the default for most elements.
  • after: The label is output after the element. For example, this is used for radio and checkbox #type elements as set in system_elements().
  • invisible: #title is rendered as a label element before the form element in the page markup, and is made invisible with the Drupal 7 .element-invisible system CSS class (system.base.css). This makes #title remain available to screen-reader users, but hides it from being displayed visually in the browser.
  • attribute: Set the title attribute on the element to create a tooltip but output no label element. This is supported only for checkboxes and radios in form_pre_render_conditional_form_element(). It is used where a visual label is not needed, such as a table of checkboxes where the row and column provide the context. The tooltip will include the title and required marker.

Usage example (block.module):

<?php
$form['blocks'][$key]['weight'] = array(
 '#type' => 'weight',
 '#default_value' => $block['weight'],
 '#delta' => $weight_delta,
 '#title_display' => 'invisible',
 '#title' => t('Weight for @block block', array('@block' => $block['info'])),
);
?>

#tree

Used by: All

Description: Used to allow collections of form elements. Normally applied to the "parent" element, as the #tree property cascades to sub-elements. Use where you previously used ][ in form_ calls. For more information, see #tree and #parents in the handbook.

Values: TRUE or FALSE

Usage example (system.module):

<?php
$form['status'] = array(
  '#type' => 'checkboxes',
  '#default_value' => $status,
  '#options' => $options,
  '#tree' => TRUE,
);
 $required = array('block', 'filter', 'system', 'user', 'watchdog');
foreach ($required as $require) {
   $form['status'][$require] = array(
    '#type' => 'hidden',
    '#value' => 1,
    '#suffix' => t('required'),
  );
}
?>

#type

Used by: All

Description: Used to determine the type of form element.

Values: button, checkbox, checkboxes, date, fieldset, file, form, hidden, image_button, item, machine_name, markup, password, password_confirm, radio, radios, select, submit, tableselect, textarea, textfield, token, value, vertical_tabs, weight

Usage example (locale.module):

<?php
$form['submit'] = array('#type' => 'submit', '#value' => t('Import'));
?>

#validate

Used by: button, image_button, form, submit

Description: A list of custom validation functions that need to be passed.This is usually used to add additional validation functions to a form, or to use an alternate function rather than the default form validation function which is the form ID with _validate appended to it.

Values: An array of function names. Each such function will take $form and $form_state as parameters and should use form_set_error() if the form values do not pass validation. For example:

function test_form_validate($form, &$form_state) {
  if ($form_state['values']['name'] == '') {
    form_set_error('name', t('You must select a name for this group of settings.'));
  }
}

Usage example (node.module):

Note: If you are altering an existing form via hook_form_alter() or a similar means, be careful with this property! You will probably want to add to the existing array rather than writing over it, so don't follow this usage example exactly.

<?php
    // Node types:
    $types = array_map('check_plain', node_get_types('names'));
    $form['advanced']['type'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Only of the type(s)'),
      '#prefix' => '<div class="criterion">',
      '#suffix' => '</div>',
      '#options' => $types,
    );
    $form['advanced']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Advanced search'),
      '#prefix' => '<div class="action">',
      '#suffix' => '</div>',
    );

    $form['#validate'][] = 'node_search_validate';
?>

#validation_arguments

INTERNAL

#value

Used by: button, hidden, image_button, submit, token, value

Description: Used to set values that cannot be edited by the user. Should NOT be confused with #default_value, which is for form inputs where users can override the default value.

Values: Mixed (text or numbers)

Usage example (locale.module):

<?php
$form['submit'] = array('#type' => 'submit', '#value' => t('Import'));
?>

#value_callback

Used by: All elements.

Description: Specifies the name of a custom value function that implements how user input is mapped to an element's #value property.

Values: A single function name to be called to set the value of this element.

A value function for an element takes $element, $input and $form_state as parameters, and has the form:

<?php
function myelement_value($element, $input = FALSE, $form_state = array()) {
  if ($input === FALSE) {
    return isset($element['#default_value']) ? $element['#default_value'] : 0;
  }
}
?>

Usage example (file.field.inc):

<?php
  // Essentially we use the managed_file type, extended with some enhancements.
  $element_info = element_info('managed_file');
  $element += array(
    '#type' => 'managed_file',
    '#default_value' => isset($items[$delta]) ? $items[$delta] : $defaults,
    '#upload_location' => file_field_widget_uri($field, $instance),
    '#upload_validators' => file_field_widget_upload_validators($field, $instance),
    '#value_callback' => 'file_field_widget_value',
    '#process' => array_merge($element_info['#process'], array('file_field_widget_process')),
    // Allows this field to return an array instead of a single value.
    '#extended' => TRUE,
  );
...
function file_field_widget_value($element, $input = FALSE, $form_state) {
  if ($input) {
    // Checkboxes lose their value when empty.
    // If the display field is present make sure its unchecked value is saved.
    $field = field_widget_field($element, $form_state);
    if (empty($input['display'])) {
      $input['display'] = $field['settings']['display_field'] ? 0 : 1;
    }
  }
?>

#weight

Used by: All elements.

Description: Used to sort the list of form elements before being output; lower numbers appear before higher numbers.

Values: A positive or negative number (integer or decimal).

Usage example (book.module):

<?php
$form['parent'] = array(
   '#type' => 'select',
  '#title' => t('Parent'),
  '#default_value' => ($node->parent ? $node->parent : arg(4)),
  '#options' => book_toc($node->nid),
  '#weight' => -15,
  '#description' => t('The parent that this page belongs in. Note that pages whose parent is &lt;top-level&gt; are regarded as independent, top-level books.'),
);
?>


Drupal 7: Hooks

Drupal 7 7.26
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
Modules | Functions
Hooks

Modules

Callbacks
Field Types API
Field Widget API
Field Formatter API
Field Storage API
Field CRUD API

Functions

module_hook ($module, $hook)
module_implements ($hook, $sort=FALSE, $reset=FALSE)
module_hook_info ()
module_implements_write_cache ()
module_invoke ($module, $hook)
module_invoke_all ($hook)
hook_aggregator_fetch ($feed)
hook_aggregator_fetch_info ()
hook_aggregator_parse ($feed)
hook_aggregator_parse_info ()
hook_aggregator_process ($feed)
hook_aggregator_process_info ()
hook_aggregator_remove ($feed)
hook_block_info ()
hook_block_info_alter (&$blocks, $theme, $code_blocks)
hook_block_configure ($delta= '')
hook_block_save ($delta= '', $edit=array())
hook_block_view ($delta= '')
hook_block_view_alter (&$data, $block)
hook_block_view_MODULE_DELTA_alter (&$data, $block)
hook_block_list_alter (&$blocks)
hook_comment_presave ($comment)
hook_comment_insert ($comment)
hook_comment_update ($comment)
hook_comment_load ($comments)
hook_comment_view ($comment, $view_mode, $langcode)
hook_comment_view_alter (&$build)
hook_comment_publish ($comment)
hook_comment_unpublish ($comment)
hook_comment_delete ($comment)
hook_contextual_links_view_alter (&$element, $items)
hook_dashboard_regions ()
hook_dashboard_regions_alter (&$regions)
hook_field_extra_fields ()
hook_field_extra_fields_alter (&$info)
hook_field_access ($op, $field, $entity_type, $entity, $account)
hook_filter_info ()
hook_filter_info_alter (&$info)
hook_filter_format_insert ($format)
hook_filter_format_update ($format)
hook_filter_format_disable ($format)
hook_help ($path, $arg)
hook_image_effect_info ()
hook_image_effect_info_alter (&$effects)
hook_image_style_save ($style)
hook_image_style_delete ($style)
hook_image_style_flush ($style)
hook_image_styles_alter (&$styles)
hook_image_default_styles ()
hook_locale ($op= 'groups')
hook_multilingual_settings_changed ()
hook_menu_insert ($menu)
hook_menu_update ($menu)
hook_menu_delete ($menu)
hook_node_operations ()
hook_node_type_insert ($info)
hook_node_type_update ($info)
hook_node_type_delete ($info)
hook_openid ($op, $request)
hook_openid_response ($response, $account)
hook_openid_discovery_method_info ()
hook_openid_discovery_method_info_alter (&$methods)
hook_openid_normalization_method_info ()
hook_openid_normalization_method_info_alter (&$methods)
hook_overlay_parent_initialize ()
hook_overlay_child_initialize ()
hook_path_insert ($path)
hook_path_update ($path)
hook_path_delete ($path)
hook_search_page ($results)
hook_shortcut_default_set ($account)
hook_simpletest_alter (&$groups)
hook_test_group_started ()
hook_test_group_finished ()
hook_test_finished ($results)
hook_language_init ()
hook_language_switch_links_alter (array &$links, $type, $path)
hook_language_fallback_candidates_alter (array &$fallback_candidates)
hook_hook_info ()
hook_hook_info_alter (&$hooks)
hook_entity_info ()
hook_entity_info_alter (&$entity_info)
hook_entity_load ($entities, $type)
hook_entity_presave ($entity, $type)
hook_entity_insert ($entity, $type)
hook_entity_update ($entity, $type)
hook_entity_delete ($entity, $type)
hook_entity_query_alter ($query)
hook_entity_view ($entity, $type, $view_mode, $langcode)
hook_entity_view_alter (&$build, $type)
hook_entity_view_mode_alter (&$view_mode, $context)
hook_admin_paths ()
hook_admin_paths_alter (&$paths)
hook_entity_prepare_view ($entities, $type, $langcode)
hook_cron ()
hook_cron_queue_info ()
hook_cron_queue_info_alter (&$queues)
hook_element_info ()
hook_element_info_alter (&$type)
hook_exit ($destination=NULL)
hook_js_alter (&$javascript)
hook_library ()
hook_library_alter (&$libraries, $module)
hook_css_alter (&$css)
hook_ajax_render_alter ($commands)
hook_page_build (&$page)
hook_menu_get_item_alter (&$router_item, $path, $original_map)
hook_menu ()
hook_menu_alter (&$items)
hook_menu_link_alter (&$item)
hook_translated_menu_link_alter (&$item, $map)
hook_menu_link_insert ($link)
hook_menu_link_update ($link)
hook_menu_link_delete ($link)
hook_menu_local_tasks_alter (&$data, $router_item, $root_path)
hook_menu_breadcrumb_alter (&$active_trail, $item)
hook_menu_contextual_links_alter (&$links, $router_item, $root_path)
hook_page_alter (&$page)
hook_form_alter (&$form, &$form_state, $form_id)
hook_form_FORM_ID_alter (&$form, &$form_state, $form_id)
hook_form_BASE_FORM_ID_alter (&$form, &$form_state, $form_id)
hook_forms ($form_id, $args)
hook_boot ()
hook_init ()
hook_image_toolkits ()
hook_mail_alter (&$message)
hook_module_implements_alter (&$implementations, $hook)
hook_system_theme_info ()
hook_system_info_alter (&$info, $file, $type)
hook_permission ()
hook_theme ($existing, $type, $theme, $path)
hook_theme_registry_alter (&$theme_registry)
hook_custom_theme ()
hook_xmlrpc ()
hook_xmlrpc_alter (&$methods)
hook_watchdog (array $log_entry)
hook_mail ($key, &$message, $params)
hook_flush_caches ()
hook_modules_installed ($modules)
hook_modules_enabled ($modules)
hook_modules_disabled ($modules)
hook_modules_uninstalled ($modules)
hook_stream_wrappers ()
hook_stream_wrappers_alter (&$wrappers)
hook_file_load ($files)
hook_file_validate ($file)
hook_file_presave ($file)
hook_file_insert ($file)
hook_file_update ($file)
hook_file_copy ($file, $source)
hook_file_move ($file, $source)
hook_file_delete ($file)
hook_file_download ($uri)
hook_file_url_alter (&$uri)
hook_requirements ($phase)
hook_query_alter (QueryAlterableInterface $query)
hook_query_TAG_alter (QueryAlterableInterface $query)
hook_install ()
hook_update_N (&$sandbox)
hook_update_dependencies ()
hook_update_last_removed ()
hook_uninstall ()
hook_enable ()
hook_disable ()
hook_registry_files_alter (&$files, $modules)
hook_install_tasks (&$install_state)
hook_drupal_goto_alter (&$path, &$options, &$http_response_code)
hook_html_head_alter (&$head_elements)
hook_install_tasks_alter (&$tasks, $install_state)
hook_file_mimetype_mapping_alter (&$mapping)
hook_actions_delete ($aid)
hook_action_info_alter (&$actions)
hook_archiver_info ()
hook_archiver_info_alter (&$info)
hook_date_format_types ()
hook_date_format_types_alter (&$types)
hook_date_formats ()
hook_date_formats_alter (&$formats)
hook_page_delivery_callback_alter (&$callback)
hook_system_themes_page_alter (&$theme_groups)
hook_url_inbound_alter (&$path, $original_path, $path_language)
hook_url_outbound_alter (&$path, &$options, $original_path)
hook_username_alter (&$name, $account)
hook_tokens ($type, $tokens, array $data=array(), array $options=array())
hook_tokens_alter (array &$replacements, array $context)
hook_token_info ()
hook_token_info_alter (&$data)
hook_updater_info ()
hook_updater_info_alter (&$updaters)
hook_countries_alter (&$countries)
hook_menu_site_status_alter (&$menu_site_status, $path)
hook_filetransfer_info ()
hook_filetransfer_info_alter (&$filetransfer_info)
hook_taxonomy_vocabulary_load ($vocabularies)
hook_taxonomy_vocabulary_presave ($vocabulary)
hook_taxonomy_vocabulary_insert ($vocabulary)
hook_taxonomy_vocabulary_update ($vocabulary)
hook_taxonomy_vocabulary_delete ($vocabulary)
hook_taxonomy_term_load ($terms)
hook_taxonomy_term_presave ($term)
hook_taxonomy_term_insert ($term)
hook_taxonomy_term_update ($term)
hook_taxonomy_term_delete ($term)
hook_taxonomy_term_view ($term, $view_mode, $langcode)
hook_taxonomy_term_view_alter (&$build)
hook_trigger_info ()
hook_trigger_info_alter (&$triggers)
hook_update_projects_alter (&$projects)
hook_update_status_alter (&$projects)
hook_user_load ($users)
hook_user_delete ($account)
hook_user_cancel ($edit, $account, $method)
hook_user_cancel_methods_alter (&$methods)
hook_user_operations ()
hook_user_categories ()
hook_user_presave (&$edit, $account, $category)
hook_user_insert (&$edit, $account, $category)
hook_user_update (&$edit, $account, $category)
hook_user_login (&$edit, $account)
hook_user_logout ($account)
hook_user_view ($account, $view_mode, $langcode)
hook_user_view_alter (&$build)
hook_user_role_presave ($role)
hook_user_role_insert ($role)
hook_user_role_update ($role)
hook_user_role_delete ($role)
hook_field_attach_load ($entity_type, $entities, $age, $options)
hook_field_attach_validate ($entity_type, $entity, &$errors)
hook_field_attach_submit ($entity_type, $entity, $form, &$form_state)
hook_field_attach_presave ($entity_type, $entity)
hook_field_attach_insert ($entity_type, $entity)
hook_field_attach_update ($entity_type, $entity)
hook_field_attach_preprocess_alter (&$variables, $context)
hook_field_attach_delete ($entity_type, $entity)
hook_field_attach_delete_revision ($entity_type, $entity)
hook_field_attach_purge ($entity_type, $entity, $field, $instance)
hook_field_attach_view_alter (&$output, $context)
hook_field_attach_prepare_translation_alter (&$entity, $context)
hook_field_language_alter (&$display_language, $context)
hook_field_available_languages_alter (&$languages, $context)
hook_field_attach_create_bundle ($entity_type, $bundle)
hook_field_attach_rename_bundle ($entity_type, $bundle_old, $bundle_new)
hook_field_attach_delete_bundle ($entity_type, $bundle, $instances)

Detailed Description

Allow modules to interact with the Drupal core.

Drupal's module system is based on the concept of "hooks". A hook is a PHP function that is named foo_bar(), where "foo" is the name of the module (whose filename is thus foo.module) and "bar" is the name of the hook. Each hook has a defined set of parameters and a specified result type.

To extend Drupal, a module need simply implement a hook. When Drupal wishes to allow intervention from modules, it determines which modules implement a hook and calls that hook in all enabled modules that implement it.

The available hooks to implement are explained here in the Hooks section of the developer documentation. The string "hook" is used as a placeholder for the module name in the hook definitions. For example, if the module file is called example.module, then hook_help() as implemented by that module would be defined as example_help().

The example functions included are not part of the Drupal core, they are just models that you can modify. Only the hooks implemented within modules are executed when running Drupal.

See Also
Default theme implementations
Callbacks

Function Documentation

hook_action_info_alter ( & $actions )

Alters the actions declared by another module.

Called by actions_list() to allow modules to alter the return values from implementations of hook_action_info().

See Also
trigger_example_action_info_alter()

Definition at line 3961 of file system.api.php.

References t().

hook_actions_delete ( $aid )

Executes code after an action is deleted.

Parameters
$aid The action ID.

Definition at line 3947 of file system.api.php.

References db_delete().

hook_admin_paths ( )

Define administrative paths.

Modules may specify whether or not the paths they define in hook_menu() are to be considered administrative. Other modules may use this information to display those pages differently (e.g. in a modal overlay, or in a different theme).

To change the administrative status of menu items defined in another module's hook_menu(), modules should implement hook_admin_paths_alter().

Returns
An associative array. For each item, the key is the path in question, in a format acceptable to drupal_match_path(). The value for each item should be TRUE (for paths considered administrative) or FALSE (for non- administrative paths).
See Also
hook_menu()
drupal_match_path()
hook_admin_paths_alter()

Definition at line 508 of file system.api.php.

hook_admin_paths_alter ( & $paths )

Redefine administrative paths defined by other modules.

Parameters
$paths An associative array of administrative paths, as defined by implementations of hook_admin_paths().
See Also
hook_admin_paths()

Definition at line 525 of file system.api.php.

hook_aggregator_fetch ( $feed )

Create an alternative fetcher for aggregator.module.

A fetcher downloads feed data to a Drupal site. The fetcher is called at the first of the three aggregation stages: first, data is downloaded by the active fetcher; second, it is converted to a common format by the active parser; and finally, it is passed to all active processors, which manipulate or store the data.

Modules that define this hook can be set as the active fetcher within the configuration page. Only one fetcher can be active at a time.

Parameters
$feed A feed object representing the resource to be downloaded. $feed->url contains the link to the feed. Download the data at the URL and expose it to other modules by attaching it to $feed->source_string.
Returns
TRUE if fetching was successful, FALSE otherwise.
See Also
hook_aggregator_fetch_info()
hook_aggregator_parse()
hook_aggregator_process()

Definition at line 39 of file aggregator.api.php.

hook_aggregator_fetch_info ( )

Specify the title and short description of your fetcher.

The title and the description provided are shown within the configuration page. Use as title the human readable name of the fetcher and as description a brief (40 to 80 characters) explanation of the fetcher's functionality.

This hook is only called if your module implements hook_aggregator_fetch(). If this hook is not implemented aggregator will use your module's file name as title and there will be no description.

Returns
An associative array defining a title and a description string.
See Also
hook_aggregator_fetch()

Definition at line 61 of file aggregator.api.php.

References t().

hook_aggregator_parse ( $feed )

Create an alternative parser for aggregator module.

A parser converts feed item data to a common format. The parser is called at the second of the three aggregation stages: first, data is downloaded by the active fetcher; second, it is converted to a common format by the active parser; and finally, it is passed to all active processors which manipulate or store the data.

Modules that define this hook can be set as the active parser within the configuration page. Only one parser can be active at a time.

Parameters
$feed An object describing the resource to be parsed. $feed->source_string contains the raw feed data. The hook implementation should parse this data and add the following properties to the $feed object:
  • description: The human-readable description of the feed.
  • link: A full URL that directly relates to the feed.
  • image: An image URL used to display an image of the feed.
  • etag: An entity tag from the HTTP header used for cache validation to determine if the content has been changed.
  • modified: The UNIX timestamp when the feed was last modified.
  • items: An array of feed items. The common format for a single feed item is an associative array containing:
    • title: The human-readable title of the feed item.
    • description: The full body text of the item or a summary.
    • timestamp: The UNIX timestamp when the feed item was last published.
    • author: The author of the feed item.
    • guid: The global unique identifier (GUID) string that uniquely identifies the item. If not available, the link is used to identify the item.
    • link: A full URL to the individual feed item.
Returns
TRUE if parsing was successful, FALSE otherwise.
See Also
hook_aggregator_parse_info()
hook_aggregator_fetch()
hook_aggregator_process()

Definition at line 110 of file aggregator.api.php.

hook_aggregator_parse_info ( )

Specify the title and short description of your parser.

The title and the description provided are shown within the configuration page. Use as title the human readable name of the parser and as description a brief (40 to 80 characters) explanation of the parser's functionality.

This hook is only called if your module implements hook_aggregator_parse(). If this hook is not implemented aggregator will use your module's file name as title and there will be no description.

Returns
An associative array defining a title and a description string.
See Also
hook_aggregator_parse()

Definition at line 136 of file aggregator.api.php.

References t().

hook_aggregator_process ( $feed )

Create a processor for aggregator.module.

A processor acts on parsed feed data. Active processors are called at the third and last of the aggregation stages: first, data is downloaded by the active fetcher; second, it is converted to a common format by the active parser; and finally, it is passed to all active processors that manipulate or store the data.

Modules that define this hook can be activated as a processor within the configuration page.

Parameters
$feed A feed object representing the resource to be processed. $feed->items contains an array of feed items downloaded and parsed at the parsing stage. See hook_aggregator_parse() for the basic format of a single item in the $feed->items array. For the exact format refer to the particular parser in use.
See Also
hook_aggregator_process_info()
hook_aggregator_fetch()
hook_aggregator_parse()

Definition at line 168 of file aggregator.api.php.

hook_aggregator_process_info ( )

Specify the title and short description of your processor.

The title and the description provided are shown within the configuration page. Use as title the natural name of the processor and as description a brief (40 to 80 characters) explanation of the functionality.

This hook is only called if your module implements hook_aggregator_process(). If this hook is not implemented aggregator will use your module's file name as title and there will be no description.

Returns
An associative array defining a title and a description string.
See Also
hook_aggregator_process()

Definition at line 192 of file aggregator.api.php.

References t().

hook_aggregator_remove ( $feed )

Remove stored feed data.

Aggregator calls this hook if either a feed is deleted or a user clicks on "remove items".

If your module stores feed items for example on hook_aggregator_process() it is recommended to implement this hook and to remove data related to $feed when called.

Parameters
$feed The $feed object whose items are being removed.

Definition at line 214 of file aggregator.api.php.

hook_ajax_render_alter ( $commands )

Alter the commands that are sent to the user through the Ajax framework.

Parameters
$commands An array of all commands that will be sent to the user.
See Also
ajax_render()

Definition at line 878 of file system.api.php.

References ajax_command_prepend(), and theme().

hook_archiver_info ( )

Declare archivers to the system.

An archiver is a class that is able to package and unpackage one or more files into a single possibly compressed file. Common examples of such files are zip files and tar.gz files. All archiver classes must implement ArchiverInterface.

Each entry should be keyed on a unique value, and specify three additional keys:

  • class: The name of the PHP class for this archiver.
  • extensions: An array of file extensions that this archiver supports.
  • weight: This optional key specifies the weight of this archiver. When mapping file extensions to archivers, the first archiver by weight found that supports the requested extension will be used.
See Also
hook_archiver_info_alter()

Definition at line 3983 of file system.api.php.

hook_archiver_info_alter ( & $info )

Alter archiver information declared by other modules.

See hook_archiver_info() for a description of archivers and the archiver information structure.

Parameters
$info Archiver information to alter (return values from hook_archiver_info()).

Definition at line 4001 of file system.api.php.

References $info.

hook_block_configure ( $delta = '' )

Define a configuration form for a block.

Parameters
$delta Which block is being configured. This is a unique identifier for the block within the module, defined in hook_block_info().
Returns
A configuration form, if one is needed for your block beyond the standard elements that the block module provides (block title, visibility, etc.).

For a detailed usage example, see block_example.module.

See Also
hook_block_info()
hook_block_save()

Definition at line 157 of file block.api.php.

References drupal_map_assoc(), t(), and variable_get().

hook_block_info ( )

Define all blocks provided by the module.

This hook declares to Drupal what blocks are provided by your module and can optionally specify initial block configuration settings.

In hook_block_info(), each block your module provides is given a unique identifier referred to as "delta" (the array key in the return value). Delta values only need to be unique within your module, and they are used in the following ways:

  • Passed into the other block hooks in your module as an argument to identify the block being configured or viewed.
  • Used to construct the default HTML ID of "block-MODULE-DELTA" applied to each block when it is rendered. This ID may then be used for CSS styling or JavaScript programming.
  • Used to define a theming template suggestion of block__MODULE__DELTA, for advanced theming possibilities.
  • Used by other modules to identify your block in hook_block_info_alter() and other alter hooks. The values of delta can be strings or numbers, but because of the uses above it is preferable to use descriptive strings whenever possible, and only use a numeric identifier if you have to (for instance if your module allows users to create several similar blocks that you identify within your module code with numeric IDs). The maximum length for delta values is 32 bytes.
Returns
An associative array whose keys define the delta for each block and whose values contain the block descriptions. Each block description is itself an associative array, with the following key-value pairs:
  • info: (required) The human-readable administrative name of the block. This is used to identify the block on administration screens, and is not displayed to non-administrative users.
  • cache: (optional) A bitmask describing what kind of caching is appropriate for the block. Drupal provides the following bitmask constants for defining cache granularity:
    • DRUPAL_CACHE_PER_ROLE (default): The block can change depending on the roles the user viewing the page belongs to.
    • DRUPAL_CACHE_PER_USER: The block can change depending on the user viewing the page. This setting can be resource-consuming for sites with large number of users, and should only be used when DRUPAL_CACHE_PER_ROLE is not sufficient.
    • DRUPAL_CACHE_PER_PAGE: The block can change depending on the page being viewed.
    • DRUPAL_CACHE_GLOBAL: The block is the same for every user on every page where it is visible.
    • DRUPAL_CACHE_CUSTOM: The module implements its own caching system.
    • DRUPAL_NO_CACHE: The block should not get cached.
  • properties: (optional) Array of additional metadata to add to the block. Common properties include:
    • administrative: Boolean that categorizes this block as usable in an administrative context. This might include blocks that help an administrator approve/deny comments, or view recently created user accounts.
  • weight: (optional) Initial value for the ordering weight of this block. Most modules do not provide an initial value, and any value provided can be modified by a user on the block configuration screen.
  • status: (optional) Initial value for block enabled status. (1 = enabled, 0 = disabled). Most modules do not provide an initial value, and any value provided can be modified by a user on the block configuration screen.
  • region: (optional) Initial value for theme region within which this block is set. Most modules do not provide an initial value, and any value provided can be modified by a user on the block configuration screen. Note: If you set a region that isn't available in the currently enabled theme, the block will be disabled.
  • visibility: (optional) Initial value for the visibility flag, which tells how to interpret the 'pages' value. Possible values are:
    • BLOCK_VISIBILITY_NOTLISTED: Show on all pages except listed pages. 'pages' lists the paths where the block should not be shown.
    • BLOCK_VISIBILITY_LISTED: Show only on listed pages. 'pages' lists the paths where the block should be shown.
    • BLOCK_VISIBILITY_PHP: Use custom PHP code to determine visibility. 'pages' gives the PHP code to use. Most modules do not provide an initial value for 'visibility' or 'pages', and any value provided can be modified by a user on the block configuration screen.
  • pages: (optional) See 'visibility' above. A string that contains one or more page paths separated by '
    ', '', or '
    ' when 'visibility' is set to BLOCK_VISIBILITY_NOTLISTED or BLOCK_VISIBILITY_LISTED, or custom PHP code when 'visibility' is set to BLOCK_VISIBILITY_PHP. Paths may use '*' as a wildcard (matching any number of characters); '<front>' designates the site's front page. For BLOCK_VISIBILITY_PHP, the PHP code's return value should be TRUE if the block is to be made visible or FALSE if the block should not be visible.

For a detailed usage example, see block_example.module.

See Also
hook_block_configure()
hook_block_save()
hook_block_view()
hook_block_info_alter()

Definition at line 105 of file block.api.php.

References DRUPAL_NO_CACHE, and t().

hook_block_info_alter | ( | & | $blocks,
 |  |  | $theme,
 |  |  | $code_blocks
 | ) |  |

Change block definition before saving to the database.

Parameters
$blocks | A multidimensional array of blocks keyed by the defining module and delta; the values are blocks returned by hook_block_info(). This hook is fired after the blocks are collected from hook_block_info() and the database, right before saving back to the database.
$theme | The theme these blocks belong to.
$code_blocks | The blocks as defined in hook_block_info() before being overwritten by the database data.
See Also
hook_block_info()

Definition at line 136 of file block.api.php.

hook_block_list_alter ( & $blocks )

Act on blocks prior to rendering.

This hook allows you to add, remove or modify blocks in the block list. The block list contains the block definitions, not the rendered blocks. The blocks are rendered after the modules have had a chance to manipulate the block list.

You can also set $block->content here, which will override the content of the block and prevent hook_block_view() from running.

Parameters
$blocks An array of $blocks, keyed by the block ID.

Definition at line 333 of file block.api.php.

References db_query().

hook_block_save | ( | $delta = '',
 |  | $edit = array()
 | ) |

Save the configuration options from hook_block_configure().

This hook allows you to save the block-specific configuration settings defined within your hook_block_configure().

Parameters
$delta | Which block is being configured. This is a unique identifier for the block within the module, defined in hook_block_info().
$edit | The submitted form data from the configuration form.

For a detailed usage example, see block_example.module.

See Also
hook_block_configure()
hook_block_info()

Definition at line 188 of file block.api.php.

References variable_set().

hook_block_view ( $delta = '' )

Return a rendered or renderable view of a block.

Parameters
$delta Which block to render. This is a unique identifier for the block within the module, defined in hook_block_info().
Returns
Either an empty array so the block will not be shown or an array containing the following elements:
  • subject: The default localized title of the block. If the block does not have a default title, this should be set to NULL.
  • content: The content of the block's body. This may be a renderable array (preferable) or a string containing rendered HTML content. If the content is empty the block will not be shown.

For a detailed usage example, see block_example.module.

See Also
hook_block_info()
hook_block_view_alter()
hook_block_view_MODULE_DELTA_alter()

Definition at line 217 of file block.api.php.

References node_get_recent(), t(), user_access(), and variable_get().

hook_block_view_alter | ( | & | $data,
 |  |  | $block
 | ) |  |

Perform alterations to the content of a block.

This hook allows you to modify any data returned by hook_block_view().

Note that instead of hook_block_view_alter(), which is called for all blocks, you can also use hook_block_view_MODULE_DELTA_alter() to alter a specific block.

Parameters
$data The data as returned from the hook_block_view() implementation of the module that defined the block. This could be an empty array or NULL value (if the block is empty) or an array containing:
  • subject: The default localized title of the block.
  • content: Either a string or a renderable array representing the content of the block. You should check that the content is an array before trying to modify parts of the renderable structure.
$block The block object, as loaded from the database, having the main properties:
  • module: The name of the module that defined the block.
  • delta: The unique identifier for the block within that module, as defined in hook_block_info().
See Also
hook_block_view_MODULE_DELTA_alter()
hook_block_view()

Definition at line 274 of file block.api.php.

hook_block_view_MODULE_DELTA_alter | ( | & | $data,
 |  |  | $block
 | ) |  |

Perform alterations to a specific block.

Modules can implement hook_block_view_MODULE_DELTA_alter() to modify a specific block, rather than implementing hook_block_view_alter().

Parameters
$data The data as returned from the hook_block_view() implementation of the module that defined the block. This could be an empty array or NULL value (if the block is empty) or an array containing:
  • subject: The localized title of the block.
  • content: Either a string or a renderable array representing the content of the block. You should check that the content is an array before trying to modify parts of the renderable structure.
$block The block object, as loaded from the database, having the main properties:
  • module: The name of the module that defined the block.
  • delta: The unique identifier for the block within that module, as defined in hook_block_info().
See Also
hook_block_view_alter()
hook_block_view()

Definition at line 309 of file block.api.php.

References t().

hook_boot ( )

Perform setup tasks for all page requests.

This hook is run at the beginning of the page request. It is typically used to set up global parameters that are needed later in the request.

Only use this hook if your code must run even for cached page views. This hook is called before the theme, modules, or most include files are loaded into memory. It happens while Drupal is still in bootstrap mode.

See Also
hook_init()

Definition at line 1861 of file system.api.php.

References drupal_load(), and drupal_register_shutdown_function().

hook_comment_delete ( $comment )

The comment is being deleted by the moderator.

Parameters
$comment Passes in the comment the action is being performed on.
Returns
Nothing.

Definition at line 139 of file comment.api.php.

References drupal_set_message(), and t().

hook_comment_insert ( $comment )

The comment is being inserted.

Parameters
$comment The comment object.

Definition at line 32 of file comment.api.php.

References search_touch_node().

hook_comment_load ( $comments )

Comments are being loaded from the database.

Parameters
$comments An array of comment objects indexed by cid.

Definition at line 54 of file comment.api.php.

References db_query().

hook_comment_presave ( $comment )

The comment passed validation and is about to be saved.

Modules may make changes to the comment before it is saved to the database.

Parameters
$comment The comment object.

Definition at line 21 of file comment.api.php.

hook_comment_publish ( $comment )

The comment is being published by the moderator.

Parameters
$comment Passes in the comment the action is being performed on.
Returns
Nothing.

Definition at line 115 of file comment.api.php.

References drupal_set_message(), and t().

hook_comment_unpublish ( $comment )

The comment is being unpublished by the moderator.

Parameters
$comment Passes in the comment the action is being performed on.
Returns
Nothing.

Definition at line 127 of file comment.api.php.

References drupal_set_message(), and t().

hook_comment_update ( $comment )

The comment is being updated.

Parameters
$comment The comment object.

Definition at line 43 of file comment.api.php.

References search_touch_node().

hook_comment_view | ( | $comment,
 |  | $view_mode,
 |  | $langcode
 | ) |

The comment is being viewed. This hook can be used to add additional data to the comment before theming.

Parameters
$comment | Passes in the comment the action is being performed on.
$view_mode | View mode, e.g. 'full', 'teaser'...
$langcode | The language code used for rendering.
See Also
hook_entity_view()

Definition at line 73 of file comment.api.php.

hook_comment_view_alter ( & $build )

The comment was built; the module may modify the structured content.

This hook is called after the content has been assembled in a structured array and may be used for doing processing which requires that the complete comment content structure has been built.

If the module wishes to act on the rendered HTML of the comment rather than the structured content array, it may use this hook to add a #post_render callback. Alternatively, it could also implement hook_preprocess_comment(). See drupal_render() and theme() documentation respectively for details.

Parameters
$build A renderable array representing the comment.
See Also
comment_view()
hook_entity_view_alter()

Definition at line 96 of file comment.api.php.

hook_contextual_links_view_alter | ( | & | $element,
 |  |  | $items
 | ) |  |

Alter a contextual links element before it is rendered.

This hook is invoked by contextual_pre_render_links(). The renderable array of #type 'contextual_links', containing the entire contextual links data that is passed in by reference. Further links may be added or existing links can be altered.

Parameters
$element | A renderable array representing the contextual links.
$items | An associative array containing the original contextual link items, as generated by menu_contextual_links(), which were used to build $element['#links'].
See Also
hook_menu_contextual_links_alter()
contextual_pre_render_links()
contextual_element_info()

Definition at line 32 of file contextual.api.php.

hook_countries_alter ( & $countries )

Alter the default country list.

Parameters
$countries The associative array of countries keyed by ISO 3166-1 country code.
See Also
country_get_list()
_country_get_predefined_list()

Definition at line 4622 of file system.api.php.

hook_cron ( )

Perform periodic actions.

Modules that require some commands to be executed periodically can implement hook_cron(). The engine will then call the hook whenever a cron run happens, as defined by the administrator. Typical tasks managed by hook_cron() are database maintenance, backups, recalculation of settings or parameters, automated mailing, and retrieving remote data.

Short-running or non-resource-intensive tasks can be executed directly in the hook_cron() implementation.

Long-running tasks and tasks that could time out, such as retrieving remote data, sending email, and intensive file tasks, should use the queue API instead of executing the tasks directly. To do this, first define one or more queues via hook_cron_queue_info(). Then, add items that need to be processed to the defined queues.

Definition at line 575 of file system.api.php.

References AGGREGATOR_CLEAR_NEVER, db_delete(), db_query(), DrupalQueue\get(), REQUEST_TIME, variable_get(), and variable_set().

hook_cron_queue_info ( )

Declare queues holding items that need to be run periodically.

While there can be only one hook_cron() process running at the same time, there can be any number of processes defined here running. Because of this, long running tasks are much better suited for this API. Items queued in hook_cron() might be processed in the same cron run if there are not many items in the queue, otherwise it might take several requests, which can be run in parallel.

Returns
An associative array where the key is the queue name and the value is again an associative array. Possible keys are:
  • 'worker callback': The name of the function to call. It will be called with one argument, the item created via DrupalQueue::createItem().
  • 'time': (optional) How much time Drupal should spend on calling this worker in seconds. Defaults to 15.
  • 'skip on cron': (optional) Set to TRUE to avoid being processed during cron runs (for example, if you want to control all queue execution manually).
See Also
hook_cron()
hook_cron_queue_info_alter()

Definition at line 620 of file system.api.php.

hook_cron_queue_info_alter ( & $queues )

Alter cron queue information before cron runs.

Called by drupal_cron_run() to allow modules to alter cron queue settings before any jobs are processesed.

Parameters
array $queues An array of cron queue information.
See Also
hook_cron_queue_info()
drupal_cron_run()

Definition at line 640 of file system.api.php.

hook_css_alter ( & $css )

Alter CSS files before they are output on the page.

Parameters
$css An array of all CSS items (files and inline CSS) being requested on the page.
See Also
drupal_add_css()
drupal_get_css()

Definition at line 865 of file system.api.php.

References drupal_get_path().

hook_custom_theme ( )

Return the machine-readable name of the theme to use for the current page.

This hook can be used to dynamically set the theme for the current page request. It should be used by modules which need to override the theme based on dynamic conditions (for example, a module which allows the theme to be set based on the current user's role). The return value of this hook will be used on all pages except those which have a valid per-page or per-section theme set via a theme callback function in hook_menu(); the themes on those pages can only be overridden using hook_menu_alter().

Note that returning different themes for the same path may not work with page caching. This is most likely to be a problem if an anonymous user on a given path could have different themes returned under different conditions.

Since only one theme can be used at a time, the last (i.e., highest weighted) module which returns a valid theme name from this hook will prevail.

Returns
The machine-readable name of the theme that should be used for the current page request. The value returned from this function will only have an effect if it corresponds to a currently-active theme on the site. Do not return a value if you do not wish to set a custom theme.

Definition at line 2316 of file system.api.php.

hook_dashboard_regions ( )

Add regions to the dashboard.

Returns
An array whose keys are the names of the dashboard regions and whose values are the titles that will be displayed in the blocks administration interface. The keys are also used as theme wrapper functions.

Definition at line 21 of file dashboard.api.php.

hook_dashboard_regions_alter ( & $regions )

Alter dashboard regions provided by modules.

Parameters
$regions An array containing all dashboard regions, in the format provided by hook_dashboard_regions().

Definition at line 35 of file dashboard.api.php.

hook_date_format_types ( )

Define additional date types.

Next to the 'long', 'medium' and 'short' date types defined in core, any module can define additional types that can be used when displaying dates, by implementing this hook. A date type is basically just a name for a date format.

Date types are used in the administration interface: a user can assign date format types defined in hook_date_formats() to date types defined in this hook. Once a format has been assigned by a user, the machine name of a type can be used in the format_date() function to format a date using the chosen formatting.

To define a date type in a module and make sure a format has been assigned to it, without requiring a user to visit the administrative interface, use

variable_set('date_format_' . $type, $format);

where $type is the machine-readable name defined here, and $format is a PHP date format string.

To avoid namespace collisions with date types defined by other modules, it is recommended that each date type starts with the module name. A date type can consist of letters, numbers and underscores.

Returns
An array of date types where the keys are the machine-readable names and the values are the human-readable labels.
See Also
hook_date_formats()
format_date()

Definition at line 4036 of file system.api.php.

References t().

hook_date_format_types_alter ( & $types )

Modify existing date types.

Allows other modules to modify existing date types like 'long'. Called by _system_date_format_types_build(). For instance, A module may use this hook to apply settings across all date types, such as locking all date types so they appear to be provided by the system.

Parameters
$types A list of date types. Each date type is keyed by the machine-readable name and the values are associative arrays containing:
  • is_new: Set to FALSE to override previous settings.
  • module: The name of the module that created the date type.
  • type: The machine-readable date type name.
  • title: The human-readable date type name.
  • locked: Specifies that the date type is system-provided.

Definition at line 4062 of file system.api.php.

References $name.

hook_date_formats ( )

Define additional date formats.

This hook is used to define the PHP date format strings that can be assigned to date types in the administrative interface. A module can provide date format strings for the core-provided date types ('long', 'medium', and 'short'), or for date types defined in hook_date_format_types() by itself or another module.

Since date formats can be locale-specific, you can specify the locales that each date format string applies to. There may be more than one locale for a format. There may also be more than one format for the same locale. For example d/m/Y and Y/m/d work equally well in some locales. You may wish to define some additional date formats that aren't specific to any one locale, for example, "Y m". For these cases, the 'locales' component of the return value should be omitted.

Providing a date format here does not normally assign the format to be used with the associated date type – a user has to choose a format for each date type in the administrative interface. There is one exception: locale initialization chooses a locale-specific format for the three core-provided types (see locale_get_localized_date_format() for details). If your module needs to ensure that a date type it defines has a format associated with it, call

variable_set('date_format_' . $type, $format);

where $type is the machine-readable name defined in hook_date_format_types(), and $format is a PHP date format string.

Returns
A list of date formats to offer as choices in the administrative interface. Each date format is a keyed array consisting of three elements:
  • 'type': The date type name that this format can be used with, as declared in an implementation of hook_date_format_types().
  • 'format': A PHP date format string to use when formatting dates. It can contain any of the formatting options described at http://php.net/manual/function.date.php
  • 'locales': (optional) An array of 2 and 5 character locale codes, defining which locales this format applies to (for example, 'en', 'en-us', etc.). If your date format is not language-specific, leave this array empty.
See Also
hook_date_format_types()

Definition at line 4110 of file system.api.php.

hook_date_formats_alter ( & $formats )

Alter date formats declared by another module.

Called by _system_date_format_types_build() to allow modules to alter the return values from implementations of hook_date_formats().

Definition at line 4136 of file system.api.php.

hook_disable ( )

Perform necessary actions before module is disabled.

The hook is called every time the module is disabled. It should be implemented in the module's .install file. The implementation can rely on the .module file being loaded.

See Also
hook_uninstall()
hook_modules_disabled()

Definition at line 3573 of file system.api.php.

hook_drupal_goto_alter | ( | & | $path,
 |  | & | $options,
 |  | & | $http_response_code
 | ) |  |

Change the page the user is sent to by drupal_goto().

Parameters
$path | A Drupal path or a full URL.
$options | An associative array of additional URL options to pass to url().
$http_response_code | The HTTP status code to use for the redirection. See drupal_goto() for more information.

Definition at line 3802 of file system.api.php.

hook_element_info ( )

Allows modules to declare their own Form API element types and specify their default values.

This hook allows modules to declare their own form element types and to specify their default values. The values returned by this hook will be merged with the elements returned by hook_form() implementations and so can return defaults for any Form APIs keys in addition to those explicitly mentioned below.

Each of the form element types defined by this hook is assumed to have a matching theme function, e.g. theme_elementtype(), which should be registered with hook_theme() as normal.

For more information about custom element types see the explanation at http://drupal.org/node/169815.

Returns
An associative array describing the element types being defined. The array contains a sub-array for each element type, with the machine-readable type name as the key. Each sub-array has a number of possible attributes:
  • "#input": boolean indicating whether or not this element carries a value (even if it's hidden).
  • "#process": array of callback functions taking $element, $form_state, and $complete_form.
  • "#after_build": array of callback functions taking $element and $form_state.
  • "#validate": array of callback functions taking $form and $form_state.
  • "#element_validate": array of callback functions taking $element and $form_state.
  • "#pre_render": array of callback functions taking $element and $form_state.
  • "#post_render": array of callback functions taking $element and $form_state.
  • "#submit": array of callback functions taking $form and $form_state.
  • "#title_display": optional string indicating if and how title should be displayed, see theme_form_element() and theme_form_element_label().
See Also
hook_element_info_alter()
system_element_info()

Definition at line 684 of file system.api.php.

hook_element_info_alter ( & $type )

Alter the element type information returned from modules.

A module may implement this hook in order to alter the element type defaults defined by a module.

Parameters
$type All element type defaults as collected by hook_element_info().
See Also
hook_element_info()

Definition at line 702 of file system.api.php.

hook_enable ( )

Perform necessary actions after module is enabled.

The hook is called every time the module is enabled. It should be implemented in the module's .install file. The implementation can rely on the .module file being loaded.

See Also
module_enable()
hook_install()
hook_modules_enabled()

Definition at line 3559 of file system.api.php.

hook_entity_delete | ( | $entity,
 |  | $type
 | ) |

Act on entities when deleted.

Parameters
$entity | The entity object.
$type | The type of entity being deleted (i.e. node, user, comment).

Definition at line 371 of file system.api.php.

References $info, db_delete(), entity_extract_ids(), and entity_get_info().

hook_entity_info ( )

Inform the base system and the Field API about one or more entity types.

Inform the system about one or more entity types (i.e., object types that can be loaded via entity_load() and, optionally, to which fields can be attached).

Returns
An array whose keys are entity type names and whose values identify properties of those types that the system needs to know about:
  • label: The human-readable name of the type.
  • controller class: The name of the class that is used to load the objects. The class has to implement the DrupalEntityControllerInterface interface. Leave blank to use the DrupalDefaultEntityController implementation.
  • base table: (used by DrupalDefaultEntityController) The name of the entity type's base table.
  • revision table: The name of the entity type's revision table (if any).
  • static cache: (used by DrupalDefaultEntityController) FALSE to disable static caching of entities during a page request. Defaults to TRUE.
  • field cache: (used by Field API loading and saving of field data) FALSE to disable Field API's persistent cache of field data. Only recommended if a higher level persistent cache is available for the entity type. Defaults to TRUE.
  • load hook: The name of the hook which should be invoked by DrupalDefaultEntityController:attachLoad(), for example 'node_load'.
  • uri callback: The name of an implementation of callback_entity_info_uri().
  • label callback: (optional) The name of an implementation of callback_entity_info_label(), which returns the label of the entity. The entity label is the main string associated with an entity; for example, the title of a node or the subject of a comment. If there is an entity object property that defines the label, then using the 'label' element of the 'entity keys' return value component suffices to provide this information (see below). Alternatively, specifying this callback allows more complex logic to determine the label of an entity. See also the entity_label() function, which implements this logic.
  • language callback: (optional) The name of an implementation of callback_entity_info_language(). In most situations, when needing to determine this value, inspecting a property named after the 'language' element of the 'entity keys' should be enough. The language callback is meant to be used primarily for temporary alterations of the property value: entity-defining modules are encouraged to always define a language property, instead of using the callback as main entity language source. In fact not having a language property defined is likely to prevent an entity from being queried by language. Moreover, given that entity_language() is not necessarily used everywhere it would be appropriate, modules implementing the language callback should be aware that this might not be always called.
  • fieldable: Set to TRUE if you want your entity type to accept fields being attached to it.
  • translation: An associative array of modules registered as field translation handlers. Array keys are the module names, array values can be any data structure the module uses to provide field translation. Any empty value disallows the module to appear as a translation handler.
  • entity keys: An array describing how the Field API can extract the information it needs from the objects of the type. Elements:
    • id: The name of the property that contains the primary id of the entity. Every entity object passed to the Field API must have this property and its value must be numeric.
    • revision: The name of the property that contains the revision id of the entity. The Field API assumes that all revision ids are unique across all entities of a type. This entry can be omitted if the entities of this type are not versionable.
    • bundle: The name of the property that contains the bundle name for the entity. The bundle name defines which set of fields are attached to the entity (e.g. what nodes call "content type"). This entry can be omitted if this entity type exposes a single bundle (all entities have the same collection of fields). The name of this single bundle will be the same as the entity type.
    • label: The name of the property that contains the entity label. For example, if the entity's label is located in $entity->subject, then 'subject' should be specified here. If complex logic is required to build the label, a 'label callback' should be defined instead (see the 'label callback' section above for details).
    • language: The name of the property, typically 'language', that contains the language code representing the language the entity has been created in. This value may be changed when editing the entity and represents the language its textual components are supposed to have. If no language property is available, the 'language callback' may be used instead. This entry can be omitted if the entities of this type are not language-aware.
  • bundle keys: An array describing how the Field API can extract the information it needs from the bundle objects for this type. This entry is required if the 'path' provided in the 'bundles'/'admin' section identifies the bundle using a named menu placeholder whose loader callback returns an object (e.g., $vocabulary for taxonomy terms, or $node_type for nodes). If the path does not include the bundle, or the bundle is just a string rather than an automatically loaded object, then this can be omitted. Elements:
    • bundle: The name of the property of the bundle object that contains the name of the bundle object.
  • bundles: An array describing all bundles for this object type. Keys are bundles machine names, as found in the objects' 'bundle' property (defined in the 'entity keys' entry above). This entry can be omitted if this entity type exposes a single bundle (all entities have the same collection of fields). The name of this single bundle will be the same as the entity type. Elements:
    • label: The human-readable name of the bundle.
    • uri callback: Same as the 'uri callback' key documented above for the entity type, but for the bundle only. When determining the URI of an entity, if a 'uri callback' is defined for both the entity type and the bundle, the one for the bundle is used.
    • admin: An array of information that allows Field UI pages to attach themselves to the existing administration pages for the bundle. Elements:
      • path: the path of the bundle's main administration page, as defined in hook_menu(). If the path includes a placeholder for the bundle, the 'bundle argument' and 'real path' keys below are required.
      • bundle argument: The position of the bundle placeholder in 'path', if any.
      • real path: The actual path (no placeholder) of the bundle's main administration page. This will be used to generate links.
      • access callback: As in hook_menu(). 'user_access' will be assumed if no value is provided.
      • access arguments: As in hook_menu().
  • view modes: An array describing the view modes for the entity type. View modes let entities be displayed differently depending on the context. For instance, a node can be displayed differently on its own page ('full' mode), on the home page or taxonomy listings ('teaser' mode), or in an RSS feed ('rss' mode). Modules taking part in the display of the entity (notably the Field API) can adjust their behavior depending on the requested view mode. An additional 'default' view mode is available for all entity types. This view mode is not intended for actual entity display, but holds default display settings. For each available view mode, administrators can configure whether it should use its own set of field display settings, or just replicate the settings of the 'default' view mode, thus reducing the amount of display configurations to keep track of. Keys of the array are view mode names. Each view mode is described by an array with the following key/value pairs:
    • label: The human-readable name of the view mode
    • custom settings: A boolean specifying whether the view mode should by default use its own custom field display settings. If FALSE, entities displayed in this view mode will reuse the 'default' display settings by default (e.g. right after the module exposing the view mode is enabled), but administrators can later use the Field UI to apply custom display settings specific to the view mode.
See Also
entity_load()
hook_entity_info_alter()

Definition at line 202 of file system.api.php.

References $name, module_exists(), node_type_get_names(), and t().

hook_entity_info_alter ( & $entity_info )

Alter the entity info.

Modules may implement this hook to alter the information that defines an entity. All properties that are available in hook_entity_info() can be altered here.

Parameters
$entity_info The entity info array, keyed by entity name.
See Also
hook_entity_info()

Definition at line 285 of file system.api.php.

hook_entity_insert | ( | $entity,
 |  | $type
 | ) |

Act on entities when inserted.

Parameters
$entity | The entity object.
$type | The type of entity being inserted (i.e. node, user, comment).

Definition at line 328 of file system.api.php.

References $info, db_insert(), entity_extract_ids(), entity_get_info(), and REQUEST_TIME.

hook_entity_load | ( | $entities,
 |  | $type
 | ) |

Act on entities when loaded.

This is a generic load hook called for all entity types loaded via the entity API.

Parameters
$entities | The entities keyed by entity ID.
$type | The type of entities being loaded (i.e. node, user, comment).

Definition at line 302 of file system.api.php.

hook_entity_prepare_view | ( | $entities,
 |  | $type,
 |  | $langcode
 | ) |

Act on entities as they are being prepared for view.

Allows you to operate on multiple entities as they are being prepared for view. Only use this if attaching the data during the entity_load() phase is not appropriate, for example when attaching other 'entity' style objects.

Parameters
$entities | The entities keyed by entity ID.
$type | The type of entities being loaded (i.e. node, user, comment).
$langcode | The language to display the entity in.

Definition at line 547 of file system.api.php.

hook_entity_presave | ( | $entity,
 |  | $type
 | ) |

Act on an entity before it is about to be created or updated.

Parameters
$entity | The entity object.
$type | The type of entity being saved (i.e. node, user, comment).

Definition at line 316 of file system.api.php.

References REQUEST_TIME.

hook_entity_query_alter ( $query )

Alter or execute an EntityFieldQuery.

Parameters
EntityFieldQuery $query An EntityFieldQuery. One of the most important properties to be changed is EntityFieldQuery::executeCallback. If this is set to an existing function, this function will get the query as its single argument and its result will be the returned as the result of EntityFieldQuery::execute(). This can be used to change the behavior of EntityFieldQuery entirely. For example, the default implementation can only deal with one field storage engine, but it is possible to write a module that can query across field storage engines. Also, the default implementation presumes entities are stored in SQL, but the execute callback could instead query any other entity storage, local or remote.

Note the $query->altered attribute which is TRUE in case the query has already been altered once. This happens with cloned queries. If there is a pager, then such a cloned query will be executed to count all elements. This query can be detected by checking for ($query->pager && $query->count), allowing the driver to return 0 from the count query and disable the pager.

Definition at line 403 of file system.api.php.

hook_entity_update | ( | $entity,
 |  | $type
 | ) |

Act on entities when updated.

Parameters
$entity | The entity object.
$type | The type of entity being updated (i.e. node, user, comment).

Definition at line 350 of file system.api.php.

References $info, db_update(), entity_extract_ids(), entity_get_info(), and REQUEST_TIME.

hook_entity_view | ( | $entity,
 |  | $type,
 |  | $view_mode,
 |  | $langcode
 | ) |

Act on entities being assembled before rendering.

Parameters
$entity | The entity object.
$type | The type of entity being rendered (i.e. node, user, comment).
$view_mode | The view mode the entity is rendered in.
$langcode | The language code used for rendering.

The module may add elements to $entity->content prior to rendering. The structure of $entity->content is a renderable array as expected by drupal_render().

See Also
hook_entity_view_alter()
hook_comment_view()
hook_node_view()
hook_user_view()

Definition at line 428 of file system.api.php.

hook_entity_view_alter | ( | & | $build,
 |  |  | $type
 | ) |  |

Alter the results of ENTITY_view().

This hook is called after the content has been assembled in a structured array and may be used for doing processing which requires that the complete entity content structure has been built.

If a module wishes to act on the rendered HTML of the entity rather than the structured content array, it may use this hook to add a #post_render callback. Alternatively, it could also implement hook_preprocess_ENTITY(). See drupal_render() and theme() for details.

Parameters
$build | A renderable array representing the entity content.
$type | The type of entity being rendered (i.e. node, user, comment).
See Also
hook_entity_view()
hook_comment_view_alter()
hook_node_view_alter()
hook_taxonomy_term_view_alter()
hook_user_view_alter()

Definition at line 459 of file system.api.php.

hook_entity_view_mode_alter | ( | & | $view_mode,
 |  |  | $context
 | ) |  |

Change the view mode of an entity that is being displayed.

Parameters
string $view_mode The view_mode that is to be used to display the entity.
array $context Array with contextual information, including:
  • entity_type: The type of the entity that is being viewed.
  • entity: The entity object.
  • langcode: The langcode the entity is being viewed in.

Definition at line 480 of file system.api.php.

hook_exit ( $destination = NULL )

Perform cleanup tasks.

This hook is run at the end of most regular page requests. It is often used for page logging and specialized cleanup. This hook MUST NOT print anything because by the time it runs the response is already sent to the browser.

Only use this hook if your code must run even for cached page views. If you have code which must run once on all non-cached pages, use hook_init() instead. That is the usual case. If you implement this hook and see an error like 'Call to undefined function', it is likely that you are depending on the presence of a module which has not been loaded yet. It is not loaded because Drupal is still in bootstrap mode.

Parameters
$destination If this hook is invoked as part of a drupal_goto() call, then this argument will be a fully-qualified URL that is the destination of the redirect.

Definition at line 728 of file system.api.php.

References db_update().

hook_field_access | ( | $op,
 |  | $field,
 |  | $entity_type,
 |  | $entity,
 |  | $account
 | ) |

End of "addtogroup field_crud". Determine whether the user has access to a given field.

This hook is invoked from field_access() to let modules block access to operations on fields. If no module returns FALSE, the operation is allowed.

Parameters
$op | The operation to be performed. Possible values: 'edit', 'view'.
$field | The field on which the operation is to be performed.
$entity_type | The type of $entity; for example, 'node' or 'user'.
$entity | (optional) The entity for the operation.
$account | (optional) The account to check; if not given use currently logged in user.
Returns
TRUE if the operation is allowed, and FALSE if the operation is denied.

Definition at line 2689 of file field.api.php.

References $op, and user_access().

hook_field_attach_create_bundle | ( | $entity_type,
 |  | $bundle
 | ) |

Act on field_attach_create_bundle().

This hook is invoked after the field module has performed the operation.

See field_attach_create_bundle() for details and arguments.

Definition at line 1557 of file field.api.php.

References variable_set().

hook_field_attach_delete | ( | $entity_type,
 |  | $entity
 | ) |

Act on field_attach_delete().

This hook is invoked after the field module has performed the operation.

See field_attach_delete() for details and arguments.

Definition at line 1406 of file field.api.php.

hook_field_attach_delete_bundle | ( | $entity_type,
 |  | $bundle,
 |  | $instances
 | ) |

Act on field_attach_delete_bundle.

This hook is invoked after the field module has performed the operation.

Parameters
$entity_type | The type of entity; for example, 'node' or 'user'.
$bundle | The bundle that was just deleted.
$instances | An array of all instances that existed for the bundle before it was deleted.

Definition at line 1595 of file field.api.php.

References variable_get(), and variable_set().

hook_field_attach_delete_revision | ( | $entity_type,
 |  | $entity
 | ) |

Act on field_attach_delete_revision().

This hook is invoked after the field module has performed the operation.

See field_attach_delete_revision() for details and arguments.

Definition at line 1417 of file field.api.php.

hook_field_attach_insert | ( | $entity_type,
 |  | $entity
 | ) |

Act on field_attach_insert().

This hook is invoked after the field module has performed the operation.

See field_attach_insert() for details and arguments.

Definition at line 1365 of file field.api.php.

hook_field_attach_load | ( | $entity_type,
 |  | $entities,
 |  | $age,
 |  | $options
 | ) |

Act on field_attach_load().

This hook is invoked after the field module has performed the operation.

Unlike other field_attach hooks, this hook accounts for 'multiple loads'. Instead of the usual $entity parameter, it accepts an array of entities, indexed by entity ID. For performance reasons, information for all available entities should be loaded in a single query where possible.

The changes made to the entities' field values get cached by the field cache for subsequent loads.

See field_attach_load() for details and arguments.

Definition at line 1305 of file field.api.php.

hook_field_attach_prepare_translation_alter | ( | & | $entity,
 |  |  | $context
 | ) |  |

Perform alterations on field_attach_prepare_translation().

This hook is invoked after the field module has performed the operation.

Parameters
$entity The entity being prepared for translation.
$context An associative array containing:
  • entity_type: The type of $entity; e.g. 'node' or 'user'.
  • langcode: The language the entity has to be translated in.
  • source_entity: The entity holding the field values to be translated.
  • source_langcode: The source language from which translate.

Definition at line 1500 of file field.api.php.

hook_field_attach_preprocess_alter | ( | & | $variables,
 |  |  | $context
 | ) |  |

Alter field_attach_preprocess() variables.

This hook is invoked while preprocessing the field.tpl.php template file in field_attach_preprocess().

Parameters
$variables The variables array is passed by reference and will be populated with field values.
$context An associative array containing:
  • entity_type: The type of $entity; for example, 'node' or 'user'.
  • entity: The entity with fields to render.
  • element: The structured array containing the values ready for rendering.

Definition at line 1395 of file field.api.php.

hook_field_attach_presave | ( | $entity_type,
 |  | $entity
 | ) |

Act on field_attach_presave().

This hook is invoked after the field module has performed the operation.

See field_attach_presave() for details and arguments.

Definition at line 1354 of file field.api.php.

hook_field_attach_purge | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance
 | ) |

Act on field_purge_data().

This hook is invoked in field_purge_data() and allows modules to act on purging data from a single field pseudo-entity. For example, if a module relates data in the field with its own data, it may purge its own data during this process as well.

Parameters
$entity_type | The type of $entity; for example, 'node' or 'user'.
$entity | The pseudo-entity whose field data is being purged.
$field | The (possibly deleted) field whose data is being purged.
$instance | The deleted field instance whose data is being purged.
See Also
Field API bulk data deletion
field_purge_data()

Definition at line 1441 of file field.api.php.

hook_field_attach_rename_bundle | ( | $entity_type,
 |  | $bundle_old,
 |  | $bundle_new
 | ) |

Act on field_attach_rename_bundle().

This hook is invoked after the field module has performed the operation.

See field_attach_rename_bundle() for details and arguments.

Definition at line 1570 of file field.api.php.

References $info, variable_get(), and variable_set().

hook_field_attach_submit | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Act on field_attach_submit().

This hook is invoked after the field module has performed the operation.

Parameters
$entity_type | The type of $entity; for example, 'node' or 'user'.
$entity | The entity for which an edit form is being submitted. The incoming form values have been extracted as field values of the $entity object.
$form | The form structure where field elements are attached to. This might be a full form structure, or a sub-part of a larger form. The $form['#parents'] property can be used to identify the corresponding part of $form_state['values'].
$form_state | An associative array containing the current state of the form.

Definition at line 1338 of file field.api.php.

References drupal_array_get_nested_value().

hook_field_attach_update | ( | $entity_type,
 |  | $entity
 | ) |

Act on field_attach_update().

This hook is invoked after the field module has performed the operation.

See field_attach_update() for details and arguments.

Definition at line 1376 of file field.api.php.

hook_field_attach_validate | ( |  | $entity_type,
 |  |  | $entity,
 |  | & | $errors
 | ) |  |

Act on field_attach_validate().

This hook is invoked after the field module has performed the operation.

See field_attach_validate() for details and arguments.

Definition at line 1316 of file field.api.php.

hook_field_attach_view_alter | ( | & | $output,
 |  |  | $context
 | ) |  |

Perform alterations on field_attach_view() or field_view_field().

This hook is invoked after the field module has performed the operation.

Parameters
$output The structured content array tree for all of the entity's fields.
$context An associative array containing:
  • entity_type: The type of $entity; for example, 'node' or 'user'.
  • entity: The entity with fields to render.
  • view_mode: View mode; for example, 'full' or 'teaser'.
  • display: Either a view mode string or an array of display settings. If this hook is being invoked from field_attach_view(), the 'display' element is set to the view mode string. If this hook is being invoked from field_view_field(), this element is set to the $display argument and the view_mode element is set to '_custom'. See field_view_field() for more information on what its $display argument contains.
  • language: The language code used for rendering.

Definition at line 1468 of file field.api.php.

References $output, and element_children().

hook_field_available_languages_alter | ( | & | $languages,
 |  |  | $context
 | ) |  |

Alter field_available_languages() values.

This hook is invoked from field_available_languages() to allow modules to alter the array of available languages for the given field.

Parameters
$languages A reference to an array of language codes to be made available.
$context An associative array containing:
  • entity_type: The type of the entity the field is attached to.
  • field: A field data structure.

Definition at line 1541 of file field.api.php.

hook_field_extra_fields ( )

Exposes "pseudo-field" components on fieldable entities.

Field UI's "Manage fields" and "Manage display" pages let users re-order fields, but also non-field components. For nodes, these include the title, poll choices, and other elements exposed by modules through hook_form() or hook_form_alter().

Fieldable entities or modules that want to have their components supported should expose them using this hook. The user-defined settings (weight, visible) are automatically applied on rendered forms and displayed entities in a #pre_render callback added by field_attach_form() and field_attach_view().

See Also
_field_extra_fields_pre_render()
hook_field_extra_fields_alter()
Returns
A nested array of 'pseudo-field' elements. Each list is nested within the following keys: entity type, bundle name, context (either 'form' or 'display'). The keys are the name of the elements as appearing in the renderable array (either the entity form or the displayed entity). The value is an associative array:
  • label: The human readable name of the element.
  • description: A short description of the element contents.
  • weight: The default weight of the element.
  • edit: (optional) String containing markup (normally a link) used as the element's 'edit' operation in the administration interface. Only for 'form' context.
  • delete: (optional) String containing markup (normally a link) used as the element's 'delete' operation in the administration interface. Only for 'form' context.

Definition at line 41 of file field.api.php.

References t().

hook_field_extra_fields_alter ( & $info )

Alter "pseudo-field" components on fieldable entities.

Parameters
$info The associative array of 'pseudo-field' components.
See Also
hook_field_extra_fields()

Definition at line 80 of file field.api.php.

References $info, and node_type_get_types().

hook_field_language_alter | ( | & | $display_language,
 |  |  | $context
 | ) |  |

Perform alterations on field_language() values.

This hook is invoked to alter the array of display languages for the given entity.

Parameters
$display_language A reference to an array of language codes keyed by field name.
$context An associative array containing:
  • entity_type: The type of the entity to be displayed.
  • entity: The entity with fields to render.
  • langcode: The language code $entity has to be displayed in.

Definition at line 1520 of file field.api.php.

References field_has_translation_handler(), locale_field_language_fallback(), and variable_get().

hook_file_copy | ( | $file,
 |  | $source
 | ) |

Respond to a file that has been copied.

Parameters
$file | The newly copied file object.
$source | The original file before the copy.
See Also
file_copy()

Definition at line 2858 of file system.api.php.

References t(), user_load(), and watchdog().

hook_file_delete ( $file )

Respond to a file being deleted.

Parameters
$file The file that has just been deleted.
See Also
file_delete()

Definition at line 2898 of file system.api.php.

References db_delete().

hook_file_download ( $uri )

Control access to private file downloads and specify HTTP headers.

This hook allows modules enforce permissions on file downloads when the private file download method is selected. Modules can also provide headers to specify information like the file's name or MIME type.

Parameters
$uri The URI of the file.
Returns
If the user does not have permission to access the file, return -1. If the user has permission, return an array with the appropriate headers. If the file is not controlled by the current module, the return value should be NULL.
See Also
file_download()

Definition at line 2920 of file system.api.php.

References $info, file_prepare_directory(), file_uri_target(), image_get_info(), user_access(), and variable_get().

hook_file_insert ( $file )

Respond to a file being added.

This hook is called after a file has been added to the database. The hook doesn't distinguish between files created as a result of a copy or those created by an upload.

Parameters
$file The file that has been added.
See Also
file_save()

Definition at line 2818 of file system.api.php.

References file_validate_extensions(), and watchdog().

hook_file_load ( $files )

Load additional information into file objects.

file_load_multiple() calls this hook to allow modules to load additional information into each file.

Parameters
$files An array of file objects, indexed by fid.
See Also
file_load_multiple()
file_load()

Definition at line 2752 of file system.api.php.

References $value, and db_query().

hook_file_mimetype_mapping_alter ( & $mapping )

Alter MIME type mappings used to determine MIME type from a file extension.

This hook is run when file_mimetype_mapping() is called. It is used to allow modules to add to or modify the default mapping from file_default_mimetype_mapping().

Parameters
$mapping An array of mimetypes correlated to the extensions that relate to them. The array has 'mimetypes' and 'extensions' elements, each of which is an array.
See Also
file_default_mimetype_mapping()

Definition at line 3859 of file system.api.php.

hook_file_move | ( | $file,
 |  | $source
 | ) |

Respond to a file that has been moved.

Parameters
$file | The updated file object after the move.
$source | The original file object before the move.
See Also
file_move()

Definition at line 2879 of file system.api.php.

References t(), user_load(), and watchdog().

hook_file_presave ( $file )

Act on a file being inserted or updated.

This hook is called when a file has been added to the database. The hook doesn't distinguish between files created as a result of a copy or those created by an upload.

Parameters
$file The file that has just been created.
See Also
file_save()

Definition at line 2801 of file system.api.php.

hook_file_update ( $file )

Respond to a file being updated.

This hook is called when file_save() is called on an existing file.

Parameters
$file The file that has just been updated.
See Also
file_save()

Definition at line 2836 of file system.api.php.

References t(), user_load(), and watchdog().

hook_file_url_alter ( & $uri )

Alter the URL to a file.

This hook is called from file_create_url(), and is called fairly frequently (10+ times per page), depending on how many files there are in a given page. If CSS and JS aggregation are disabled, this can become very frequently (50+ times per page) so performance is critical.

This function should alter the URI, if it wants to rewrite the file URL.

Parameters
$uri The URI to a file for which we need an external URL, or the path to a shipped file.

Definition at line 2952 of file system.api.php.

References file_stream_wrapper_get_instance_by_scheme(), file_uri_scheme(), and file_uri_target().

hook_file_validate ( $file )

Check that files meet a given criteria.

This hook lets modules perform additional validation on files. They're able to report a failure by returning one or more error messages.

Parameters
$file The file object being validated.
Returns
An array of error messages. If there are no problems with the file return an empty array.
See Also
file_validate()

Definition at line 2776 of file system.api.php.

References t().

hook_filetransfer_info ( )

Register information about FileTransfer classes provided by a module.

The FileTransfer class allows transferring files over a specific type of connection. Core provides classes for FTP and SSH. Contributed modules are free to extend the FileTransfer base class to add other connection types, and if these classes are registered via hook_filetransfer_info(), those connection types will be available to site administrators using the Update manager when they are redirected to the authorize.php script to authorize the file operations.

Returns
array Nested array of information about FileTransfer classes. Each key is a FileTransfer type (not human readable, used for form elements and variable names, etc), and the values are subarrays that define properties of that type. The keys in each subarray are:
  • 'title': Required. The human-readable name of the connection type.
  • 'class': Required. The name of the FileTransfer class. The constructor will always be passed the full path to the root of the site that should be used to restrict where file transfer operations can occur (the $jail) and an array of settings values returned by the settings form.
  • 'file': Required. The include file containing the FileTransfer class. This should be a separate .inc file, not just the .module file, so that the minimum possible code is loaded when authorize.php is running.
  • 'file path': Optional. The directory (relative to the Drupal root) where the include file lives. If not defined, defaults to the base directory of the module implementing the hook.
  • 'weight': Optional. Integer weight used for sorting connection types on the authorize.php form.
See Also
FileTransfer
authorize.php
hook_filetransfer_info_alter()
drupal_get_filetransfer_info()

Definition at line 4687 of file system.api.php.

References $info, and t().

hook_filetransfer_info_alter ( & $filetransfer_info )

Alter the FileTransfer class registry.

Parameters
array $filetransfer_info Reference to a nested array containing information about the FileTransfer class registry.
See Also
hook_filetransfer_info()

Definition at line 4706 of file system.api.php.

References variable_get().

hook_filter_format_disable ( $format )

Perform actions when a text format has been disabled.

Parameters
$format The format object of the format being disabled.
See Also
hook_filter_format_insert()
hook_filter_format_update()

Definition at line 317 of file filter.api.php.

hook_filter_format_insert ( $format )

Perform actions when a new text format has been created.

Parameters
$format The format object of the format being updated.
See Also
hook_filter_format_update()
hook_filter_format_disable()

Definition at line 287 of file filter.api.php.

hook_filter_format_update ( $format )

Perform actions when a text format has been updated.

This hook allows modules to act when a text format has been updated in any way. For example, when filters have been reconfigured, disabled, or re-arranged in the text format.

Parameters
$format The format object of the format being updated.
See Also
hook_filter_format_insert()
hook_filter_format_disable()

Definition at line 304 of file filter.api.php.

hook_filter_info ( )

Define content filters.

User submitted content is passed through a group of filters before it is output in HTML, in order to remove insecure or unwanted parts, correct or enhance the formatting, transform special keywords, etc. A group of filters is referred to as a "text format". Administrators can create as many text formats as needed. Individual filters can be enabled and configured differently for each text format.

This hook is invoked by filter_get_filters() and allows modules to register input filters they provide.

Filtering is a two-step process. First, the content is 'prepared' by calling the 'prepare callback' function for every filter. The purpose of the 'prepare callback' is to escape HTML-like structures. For example, imagine a filter which allows the user to paste entire chunks of programming code without requiring manual escaping of special HTML characters like < or &. If the programming code were left untouched, then other filters could think it was HTML and change it. For many filters, the prepare step is not necessary.

The second step is the actual processing step. The result from passing the text through all the filters' prepare steps gets passed to all the filters again, this time with the 'process callback' function. The process callbacks should then actually change the content: transform URLs into hyperlinks, convert smileys into images, etc.

For performance reasons content is only filtered once; the result is stored in the cache table and retrieved from the cache the next time the same piece of content is displayed. If a filter's output is dynamic, it can override the cache mechanism, but obviously this should be used with caution: having one filter that does not support caching in a particular text format disables caching for the entire format, not just for one filter.

Beware of the filter cache when developing your module: it is advised to set your filter to 'cache' => FALSE while developing, but be sure to remove that setting if it's not needed, when you are no longer in development mode.

Returns
An associative array of filters, whose keys are internal filter names, which should be unique and therefore prefixed with the name of the module. Each value is an associative array describing the filter, with the following elements (all are optional except as noted):
  • title: (required) An administrative summary of what the filter does.
  • description: Additional administrative information about the filter's behavior, if needed for clarification.
  • settings callback: The name of a function that returns configuration form elements for the filter. See callback_filter_settings() for details.
  • default settings: An associative array containing default settings for the filter, to be applied when the filter has not been configured yet.
  • prepare callback: The name of a function that escapes the content before the actual filtering happens. See callback_filter_prepare() for details.
  • process callback: (required) The name the function that performs the actual filtering. See callback_filter_process() for details.
  • cache (default TRUE): Specifies whether the filtered text can be cached. Note that setting this to FALSE makes the entire text format not cacheable, which may have an impact on the site's overall performance. See filter_format_allowcache() for details.
  • tips callback: The name of a function that returns end-user-facing filter usage guidelines for the filter. See callback_filter_tips() for details.
  • weight: A default weight for the filter in new text formats.
See Also
filter_example.module
hook_filter_info_alter()

Definition at line 80 of file filter.api.php.

References t().

hook_filter_info_alter ( & $info )

Perform alterations on filter definitions.

Parameters
$info Array of information on filters exposed by hook_filter_info() implementations.

Definition at line 109 of file filter.api.php.

References $info.

hook_flush_caches ( )

Add a list of cache tables to be cleared.

This hook allows your module to add cache table names to the list of cache tables that will be cleared by the Clear button on the Performance page or whenever drupal_flush_all_caches is invoked.

Returns
An array of cache table names.
See Also
drupal_flush_all_caches()

Definition at line 2568 of file system.api.php.

hook_form_alter | ( | & | $form,
 |  | & | $form_state,
 |  |  | $form_id
 | ) |  |

Perform alterations before a form is rendered.

One popular use of this hook is to add form elements to the node form. When altering a node form, the node object can be accessed at $form['#node'].

In addition to hook_form_alter(), which is called for all forms, there are two more specific form hooks available. The first, hook_form_BASE_FORM_ID_alter(), allows targeting of a form/forms via a base form (if one exists). The second, hook_form_FORM_ID_alter(), can be used to target a specific form directly.

The call order is as follows: all existing form alter functions are called for module A, then all for module B, etc., followed by all for any base theme(s), and finally for the theme itself. The module order is determined by system weight, then by module name.

Within each module, form alter hooks are called in the following order: first, hook_form_alter(); second, hook_form_BASE_FORM_ID_alter(); third, hook_form_FORM_ID_alter(). So, for each module, the more general hooks are called first followed by the more specific.

Parameters
$form | Nested array of form elements that comprise the form.
$form_state | A keyed array containing the current state of the form. The arguments that drupal_get_form() was originally called with are available in the array $form_state['build_info']['args'].
$form_id | String representing the name of the form itself. Typically this is the name of the function that generated the form.
See Also
hook_form_BASE_FORM_ID_alter()
hook_form_FORM_ID_alter()
forms_api_reference.html

Definition at line 1671 of file system.api.php.

References t(), and variable_get().

hook_form_BASE_FORM_ID_alter | ( | & | $form,
 |  | & | $form_state,
 |  |  | $form_id
 | ) |  |

Provide a form-specific alteration for shared ('base') forms.

By default, when drupal_get_form() is called, Drupal looks for a function with the same name as the form ID, and uses that function to build the form. In contrast, base forms allow multiple form IDs to be mapped to a single base (also called 'factory') form function.

Modules can implement hook_form_BASE_FORM_ID_alter() to modify a specific base form, rather than implementing hook_form_alter() and checking for conditions that would identify the shared form constructor.

To identify the base form ID for a particular form (or to determine whether one exists) check the $form_state. The base form ID is stored under $form_state['build_info']['base_form_id'].

See hook_forms() for more information on how to implement base forms in Drupal.

Form alter hooks are called in the following order: hook_form_alter(), hook_form_BASE_FORM_ID_alter(), hook_form_FORM_ID_alter(). See hook_form_alter() for more details.

Parameters
$form | Nested array of form elements that comprise the form.
$form_state | A keyed array containing the current state of the form.
$form_id | String representing the name of the form itself. Typically this is the name of the function that generated the form.
See Also
hook_form_alter()
hook_form_FORM_ID_alter()
drupal_prepare_form()
hook_forms()

Definition at line 1757 of file system.api.php.

References t().

hook_form_FORM_ID_alter | ( | & | $form,
 |  | & | $form_state,
 |  |  | $form_id
 | ) |  |

Provide a form-specific alteration instead of the global hook_form_alter().

Modules can implement hook_form_FORM_ID_alter() to modify a specific form, rather than implementing hook_form_alter() and checking the form ID, or using long switch statements to alter multiple forms.

Form alter hooks are called in the following order: hook_form_alter(), hook_form_BASE_FORM_ID_alter(), hook_form_FORM_ID_alter(). See hook_form_alter() for more details.

Parameters
$form | Nested array of form elements that comprise the form.
$form_state | A keyed array containing the current state of the form. The arguments that drupal_get_form() was originally called with are available in the array $form_state['build_info']['args'].
$form_id | String representing the name of the form itself. Typically this is the name of the function that generated the form.
See Also
hook_form_alter()
hook_form_BASE_FORM_ID_alter()
drupal_prepare_form()
forms_api_reference.html

Definition at line 1708 of file system.api.php.

References t().

hook_forms | ( | $form_id,
 |  | $args
 | ) |

Map form_ids to form builder functions.

By default, when drupal_get_form() is called, the system will look for a function with the same name as the form ID, and use that function to build the form. If no such function is found, Drupal calls this hook. Modules implementing this hook can then provide their own instructions for mapping form IDs to constructor functions. As a result, you can easily map multiple form IDs to a single form constructor (referred to as a 'base' form).

Using a base form can help to avoid code duplication, by allowing many similar forms to use the same code base. Another benefit is that it becomes much easier for other modules to apply a general change to the group of forms; hook_form_BASE_FORM_ID_alter() can be used to easily alter multiple forms at once by directly targeting the shared base form.

Two example use cases where base forms may be useful are given below.

First, you can use this hook to tell the form system to use a different function to build certain forms in your module; this is often used to define a form "factory" function that is used to build several similar forms. In this case, your hook implementation will likely ignore all of the input arguments. See node_forms() for an example of this. Note, node_forms() is the hook_forms() implementation; the base form itself is defined in node_form().

Second, you could use this hook to define how to build a form with a dynamically-generated form ID. In this case, you would need to verify that the $form_id input matched your module's format for dynamically-generated form IDs, and if so, act appropriately.

Parameters
$form_id | The unique string identifying the desired form.
$args | An array containing the original arguments provided to drupal_get_form() or drupal_form_submit(). These are always passed to the form builder and do not have to be specified manually in 'callback arguments'.
Returns
An associative array whose keys define form_ids and whose values are an associative array defining the following keys:
  • callback: The name of the form builder function to invoke. This will be used for the base form ID, for example, to target a base form using hook_form_BASE_FORM_ID_alter().
  • callback arguments: (optional) Additional arguments to pass to the function defined in 'callback', which are prepended to $args.
  • wrapper_callback: (optional) The name of a form builder function to invoke before the form builder defined in 'callback' is invoked. This wrapper callback may prepopulate the $form array with form elements, which will then be already contained in the $form that is passed on to the form builder defined in 'callback'. For example, a wrapper callback could setup wizard-alike form buttons that are the same for a variety of forms that belong to the wizard, which all share the same wrapper callback.

Definition at line 1824 of file system.api.php.

hook_help | ( | $path,
 |  | $arg
 | ) |

Provide online user help.

By implementing hook_help(), a module can make documentation available to the user for the module as a whole, or for specific paths. Help for developers should usually be provided via function header comments in the code, or in special API example files.

For a detailed usage example, see page_example.module.

Parameters
$path | The router menu path, as defined in hook_menu(), for the help that is being requested; e.g., 'admin/people' or 'user/register'. If the router path includes a wildcard, then this will appear in $path as %, even if it is a named autoloader wildcard in the hook_menu() implementation; for example, node pages would have $path equal to 'node/' or 'node/%/view'. To provide a help page for a whole module with a listing on admin/help, your hook implementation should match a path with a special descriptor after a "#" sign: 'admin/help#modulename' The main module help text, displayed on the admin/help/modulename page and linked to from the admin/help page.
$arg | An array that corresponds to the return value of the arg() function, for modules that want to provide help that is specific to certain values of wildcards in $path. For example, you could provide help for the path 'user/1' by looking for the path 'user/' and $arg[1] == '1'. This given array should always be used rather than directly invoking arg(), because your hook implementation may be called for other purposes besides building the current page's help. Note that depending on which module is invoking hook_help, $arg may contain only empty strings. Regardless, $arg[0] to $arg[11] will always be set.
Returns
A localized string containing the help text.

Definition at line 49 of file help.api.php.

References t(), and url().

hook_hook_info ( )

Defines one or more hooks that are exposed by a module.

Normally hooks do not need to be explicitly defined. However, by declaring a hook explicitly, a module may define a "group" for it. Modules that implement a hook may then place their implementation in either $module.module or in $module.$group.inc. If the hook is located in $module.$group.inc, then that file will be automatically loaded when needed. In general, hooks that are rarely invoked and/or are very large should be placed in a separate include file, while hooks that are very short or very frequently called should be left in the main module file so that they are always available.

Returns
An associative array whose keys are hook names and whose values are an associative array containing:
  • group: A string defining the group to which the hook belongs. The module system will determine whether a file with the name $module.$group.inc exists, and automatically load it when required.

See system_hook_info() for all hook groups defined by Drupal core.

See Also
hook_hook_info_alter().

Definition at line 37 of file system.api.php.

hook_hook_info_alter ( & $hooks )

Alter information from hook_hook_info().

Parameters
$hooks Information gathered by module_hook_info() from other modules' implementations of hook_hook_info(). Alter this array directly. See hook_hook_info() for information on what this may contain.

Definition at line 55 of file system.api.php.

hook_html_head_alter ( & $head_elements )

Alter XHTML HEAD tags before they are rendered by drupal_get_html_head().

Elements available to be altered are only those added using drupal_add_html_head_link() or drupal_add_html_head(). CSS and JS files are handled using drupal_add_css() and drupal_add_js(), so the head links for those files will not appear in the $head_elements array.

Parameters
$head_elements An array of renderable elements. Generally the values of the #attributes array will be the most likely target for changes.

Definition at line 3819 of file system.api.php.

hook_image_default_styles ( )

Provide module-based image styles for reuse throughout Drupal.

This hook allows your module to provide image styles. This may be useful if you require images to fit within exact dimensions. Note that you should attempt to re-use the default styles provided by Image module whenever possible, rather than creating image styles that are specific to your module. Image provides the styles "thumbnail", "medium", and "large".

You may use this hook to more easily manage your site's changes by moving existing image styles from the database to a custom module. Note however that moving image styles to code instead storing them in the database has a negligible effect on performance, since custom image styles are loaded from the database all at once. Even if all styles are pulled from modules, Image module will still perform the same queries to check the database for any custom styles.

Returns
An array of image styles, keyed by the style name.
See Also
image_image_default_styles()

Definition at line 176 of file image.api.php.

References $styles.

hook_image_effect_info ( )

Define information about image effects provided by a module.

This hook enables modules to define image manipulation effects for use with an image style.

Returns
An array of image effects. This array is keyed on the machine-readable effect name. Each effect is defined as an associative array containing the following items:
  • "label": The human-readable name of the effect.
  • "effect callback": The function to call to perform this image effect.
  • "dimensions passthrough": (optional) Set this item if the effect doesn't change the dimensions of the image.
  • "dimensions callback": (optional) The function to call to transform dimensions for this effect.
  • "help": (optional) A brief description of the effect that will be shown when adding or configuring this image effect.
  • "form callback": (optional) The name of a function that will return a $form array providing a configuration form for this image effect.
  • "summary theme": (optional) The name of a theme function that will output a summary of this image effect's configuration.
See Also
hook_image_effect_info_alter()

Definition at line 38 of file image.api.php.

References t().

hook_image_effect_info_alter ( & $effects )

Alter the information provided in hook_image_effect_info().

Parameters
$effects The array of image effects, keyed on the machine-readable effect name.
See Also
hook_image_effect_info()

Definition at line 61 of file image.api.php.

hook_image_style_delete ( $style )

Respond to image style deletion.

This hook enables modules to update settings when a image style is being deleted. If a style is deleted, a replacement name may be specified in $style['name'] and the style being deleted will be specified in $style['old_name'].

Parameters
$style The image style array that being deleted.

Definition at line 97 of file image.api.php.

References variable_get(), and variable_set().

hook_image_style_flush ( $style )

Respond to image style flushing.

This hook enables modules to take effect when a style is being flushed (all images are being deleted from the server and regenerated). Any module-specific caches that contain information related to the style should be cleared using this hook. This hook is called whenever a style is updated, deleted, or any effect associated with the style is update or deleted.

Parameters
$style The image style array that is being flushed.

Definition at line 117 of file image.api.php.

References cache_clear_all().

hook_image_style_save ( $style )

Respond to image style updating.

This hook enables modules to update settings that might be affected by changes to an image. For example, updating a module specific variable to reflect a change in the image style's name.

Parameters
$style The image style array that is being updated.

Definition at line 78 of file image.api.php.

References variable_get(), and variable_set().

hook_image_styles_alter ( & $styles )

Modify any image styles provided by other modules or the user.

This hook allows modules to modify, add, or remove image styles. This may be useful to modify default styles provided by other modules or enforce that a specific effect is always enabled on a style. Note that modifications to these styles may negatively affect the user experience, such as if an effect is added to a style through this hook, the user may attempt to remove the effect but it will be immediately be re-added.

The best use of this hook is usually to modify default styles, which are not editable by the user until they are overridden, so such interface contradictions will not occur. This hook can target default (or user) styles by checking the $style['storage'] property.

If your module needs to provide a new style (rather than modify an existing one) use hook_image_default_styles() instead.

See Also
hook_image_default_styles()

Definition at line 142 of file image.api.php.

References $styles, and IMAGE_STORAGE_DEFAULT.

hook_image_toolkits ( )

Define image toolkits provided by this module.

The file which includes each toolkit's functions must be declared as part of the files array in the module .info file so that the registry will find and parse it.

The toolkit's functions must be named image_toolkitname_operation(). where the operation may be:

  • 'load': Required. See image_gd_load() for usage.
  • 'save': Required. See image_gd_save() for usage.
  • 'settings': Optional. See image_gd_settings() for usage.
  • 'resize': Optional. See image_gd_resize() for usage.
  • 'rotate': Optional. See image_gd_rotate() for usage.
  • 'crop': Optional. See image_gd_crop() for usage.
  • 'desaturate': Optional. See image_gd_desaturate() for usage.
Returns
An array with the toolkit name as keys and sub-arrays with these keys:
  • 'title': A string with the toolkit's title.
  • 'available': A Boolean value to indicate that the toolkit is operating properly, e.g. all required libraries exist.
See Also
system_image_toolkits()

Definition at line 1915 of file system.api.php.

References t().

hook_init ( )

Perform setup tasks for non-cached page requests.

This hook is run at the beginning of the page request. It is typically used to set up global parameters that are needed later in the request. When this hook is called, the theme and all modules are already loaded in memory.

This hook is not run on cached pages.

To add CSS or JS that should be present on all pages, modules should not implement this hook, but declare these files in their .info file.

See Also
hook_boot()

Definition at line 1882 of file system.api.php.

References drupal_add_css(), drupal_get_path(), and drupal_is_front_page().

hook_install ( )

Perform setup tasks when the module is installed.

If the module implements hook_schema(), the database tables will be created before this hook is fired.

Implementations of this hook are by convention declared in the module's .install file. The implementation can rely on the .module file being loaded. The hook will only be called the first time a module is enabled or after it is re-enabled after being uninstalled. The module's schema version will be set to the module's greatest numbered update hook. Because of this, any time a hook_update_N() is added to the module, this function needs to be updated to reflect the current version of the database schema.

See the Schema API documentation for details on hook_schema and how database tables are defined.

Note that since this function is called from a full bootstrap, all functions (including those in modules enabled by the current page request) are available when this hook is called. Use cases could be displaying a user message, or calling a module function necessary for initial setup, etc.

Please be sure that anything added or modified in this function that can be removed during uninstall should be removed with hook_uninstall().

See Also
hook_schema()
module_enable()
hook_enable()
hook_disable()
hook_uninstall()
hook_modules_installed()

Definition at line 3310 of file system.api.php.

References db_insert().

hook_install_tasks ( & $install_state )

Return an array of tasks to be performed by an installation profile.

Any tasks you define here will be run, in order, after the installer has finished the site configuration step but before it has moved on to the final import of languages and the end of the installation. You can have any number of custom tasks to perform during this phase.

Each task you define here corresponds to a callback function which you must separately define and which is called when your task is run. This function will receive the global installation state variable, $install_state, as input, and has the opportunity to access or modify any of its settings. See the install_state_defaults() function in the installer for the list of $install_state settings used by Drupal core.

At the end of your task function, you can indicate that you want the installer to pause and display a page to the user by returning any themed output that should be displayed on that page (but see below for tasks that use the form API or batch API; the return values of these task functions are handled differently). You should also use drupal_set_title() within the task callback function to set a custom page title. For some tasks, however, you may want to simply do some processing and pass control to the next task without ending the page request; to indicate this, simply do not send back a return value from your task function at all. This can be used, for example, by installation profiles that need to configure certain site settings in the database without obtaining any input from the user.

The task function is treated specially if it defines a form or requires batch processing; in that case, you should return either the form API definition or batch API array, as appropriate. See below for more information on the 'type' key that you must define in the task definition to inform the installer that your task falls into one of those two categories. It is important to use these APIs directly, since the installer may be run non-interactively (for example, via a command line script), all in one page request; in that case, the installer will automatically take care of submitting forms and processing batches correctly for both types of installations. You can inspect the $install_state['interactive'] boolean to see whether or not the current installation is interactive, if you need access to this information.

Remember that a user installing Drupal interactively will be able to reload an installation page multiple times, so you should use variable_set() and variable_get() if you are collecting any data that you need to store and inspect later. It is important to remove any temporary variables using variable_del() before your last task has completed and control is handed back to the installer.

Parameters
array $install_state An array of information about the current installation state.
Returns
array A keyed array of tasks the profile will perform during the final stage of the installation. Each key represents the name of a function (usually a function defined by this profile, although that is not strictly required) that is called when that task is run. The values are associative arrays containing the following key-value pairs (all of which are optional):
  • display_name: The human-readable name of the task. This will be displayed to the user while the installer is running, along with a list of other tasks that are being run. Leave this unset to prevent the task from appearing in the list.
  • display: This is a boolean which can be used to provide finer-grained control over whether or not the task will display. This is mostly useful for tasks that are intended to display only under certain conditions; for these tasks, you can set 'display_name' to the name that you want to display, but then use this boolean to hide the task only when certain conditions apply.
  • type: A string representing the type of task. This parameter has three possible values:
    • normal: (default) This indicates that the task will be treated as a regular callback function, which does its processing and optionally returns HTML output.
    • batch: This indicates that the task function will return a batch API definition suitable for batch_set(). The installer will then take care of automatically running the task via batch processing.
    • form: This indicates that the task function will return a standard form API definition (and separately define validation and submit handlers, as appropriate). The installer will then take care of automatically directing the user through the form submission process.
  • run: A constant representing the manner in which the task will be run. This parameter has three possible values:
    • INSTALL_TASK_RUN_IF_NOT_COMPLETED: (default) This indicates that the task will run once during the installation of the profile.
    • INSTALL_TASK_SKIP: This indicates that the task will not run during the current installation page request. It can be used to skip running an installation task when certain conditions are met, even though the task may still show on the list of installation tasks presented to the user.
    • INSTALL_TASK_RUN_IF_REACHED: This indicates that the task will run on each installation page request that reaches it. This is rarely necessary for an installation profile to use; it is primarily used by the Drupal installer for bootstrap-related tasks.
  • function: Normally this does not need to be set, but it can be used to force the installer to call a different function when the task is run (rather than the function whose name is given by the array key). This could be used, for example, to allow the same function to be called by two different tasks.
See Also
install_state_defaults()
batch_set()

Definition at line 3730 of file system.api.php.

References INSTALL_TASK_RUN_IF_NOT_COMPLETED, INSTALL_TASK_SKIP, st(), and variable_get().

hook_install_tasks_alter | ( | & | $tasks,
 |  |  | $install_state
 | ) |  |

Alter the full list of installation tasks.

Parameters
$tasks | An array of all available installation tasks, including those provided by Drupal core. You can modify this array to change or replace any part of the Drupal installation process that occurs after the installation profile is selected.
$install_state | An array of information about the current installation state.

Definition at line 3839 of file system.api.php.

hook_js_alter ( & $javascript )

Perform necessary alterations to the JavaScript before it is presented on the page.

Parameters
$javascript An array of all JavaScript being presented on the page.
See Also
drupal_add_js()
drupal_get_js()
drupal_js_defaults()

Definition at line 746 of file system.api.php.

References drupal_get_path().

hook_language_fallback_candidates_alter ( array & $fallback_candidates )

Perform alterations on the language fallback candidates.

Parameters
$fallback_candidates An array of language codes whose order will determine the language fallback order.

Definition at line 180 of file language.api.php.

hook_language_init ( )

Allows modules to act after language initialization has been performed.

This is primarily needed to provide translation for configuration variables in the proper bootstrap phase. Variables are user-defined strings and therefore should not be translated via t(), since the source string can change without notice and any previous translation would be lost. Moreover, since variables can be used in the bootstrap phase, we need a bootstrap hook to provide a translation early enough to avoid misalignments between code using the original values and code using the translated values. However modules implementing hook_boot() should be aware that language initialization did not happen yet and thus they cannot rely on translated variables.

Definition at line 26 of file language.api.php.

References $conf.

hook_language_switch_links_alter | ( | array & | $links,
 |  |  | $type,
 |  |  | $path
 | ) |  |

Perform alterations on language switcher links.

A language switcher link may need to point to a different path or use a translated link text before going through l(), which will just handle the path aliases.

Parameters
$links | Nested array of links keyed by language code.
$type | The language type the links will switch.
$path | The current path.

Definition at line 54 of file language.api.php.

References LANGUAGE_TYPE_CONTENT.

hook_library ( )

Registers JavaScript/CSS libraries associated with a module.

Modules implementing this return an array of arrays. The key to each sub-array is the machine readable name of the library. Each library may contain the following items:

  • 'title': The human readable name of the library.
  • 'website': The URL of the library's web site.
  • 'version': A string specifying the version of the library; intentionally not a float because a version like "1.2.3" is not a valid float. Use PHP's version_compare() to compare different versions.
  • 'js': An array of JavaScript elements; each element's key is used as $data argument, each element's value is used as $options array for drupal_add_js(). To add library-specific (not module-specific) JavaScript settings, the key may be skipped, the value must specify 'type' => 'setting', and the actual settings must be contained in a 'data' element of the value.
  • 'css': Like 'js', an array of CSS elements passed to drupal_add_css().
  • 'dependencies': An array of libraries that are required for a library. Each element is an array listing the module and name of another library. Note that all dependencies for each dependent library will also be added when this library is added.

Registered information for a library should contain re-usable data only. Module- or implementation-specific data and integration logic should be added separately.

Returns
An array defining libraries associated with a module.
See Also
system_library()
drupal_add_library()
drupal_get_library()

Definition at line 786 of file system.api.php.

References drupal_get_path().

hook_library_alter | ( | & | $libraries,
 |  |  | $module
 | ) |  |

Alters the JavaScript/CSS library registry.

Allows certain, contributed modules to update libraries to newer versions while ensuring backwards compatibility. In general, such manipulations should only be done by designated modules, since most modules that integrate with a certain library also depend on the API of a certain library version.

Parameters
$libraries | The JavaScript/CSS libraries provided by $module. Keyed by internal library name and passed by reference.
$module | The name of the module that registered the libraries.
See Also
hook_library()

Definition at line 842 of file system.api.php.

References $module, and drupal_get_path().

hook_locale ( $op = 'groups' )

Allows modules to define their own text groups that can be translated.

Parameters
$op Type of operation. Currently, only supports 'groups'.

Definition at line 19 of file locale.api.php.

References $op, and t().

hook_mail | ( |  | $key,
 |  | & | $message,
 |  |  | $params
 | ) |  |

Prepare a message based on parameters; called from drupal_mail().

Note that hook_mail(), unlike hook_mail_alter(), is only called on the $module argument to drupal_mail(), not all modules.

Parameters
$key | An identifier of the mail.
$message An array to be filled in. Elements in this array include:
  • id: An ID to identify the mail sent. Look at module source code or drupal_mail() for possible id values.
  • to: The address or addresses the message will be sent to. The formatting of this string will be validated with the PHP e-mail validation filter.
  • subject: Subject of the e-mail to be sent. This must not contain any newline characters, or the mail may not be sent properly. drupal_mail() sets this to an empty string when the hook is invoked.
  • body: An array of lines containing the message to be sent. Drupal will format the correct line endings for you. drupal_mail() sets this to an empty array when the hook is invoked.
  • from: The address the message will be marked as being from, which is set by drupal_mail() to either a custom address or the site-wide default email address when the hook is invoked.
  • headers: Associative array containing mail headers, such as From, Sender, MIME-Version, Content-Type, etc. drupal_mail() pre-fills several headers in this array.
$params | An array of parameters supplied by the caller of drupal_mail().

Definition at line 2518 of file system.api.php.

References drupal_html_to_text(), format_username(), node_type_get_name(), taxonomy_vocabulary_load(), url(), and variable_get().

hook_mail_alter ( & $message )

Alter an email message created with the drupal_mail() function.

hook_mail_alter() allows modification of email messages created and sent with drupal_mail(). Usage examples include adding and/or changing message text, message fields, and message headers.

Email messages sent using functions other than drupal_mail() will not invoke hook_mail_alter(). For example, a contributed module directly calling the drupal_mail_system()->mail() or PHP mail() function will not invoke this hook. All core modules use drupal_mail() for messaging, it is best practice but not mandatory in contributed modules.

Parameters
$message An array containing the message data. Keys in this array include:
  • 'id': The drupal_mail() id of the message. Look at module source code or drupal_mail() for possible id values.
  • 'to': The address or addresses the message will be sent to. The formatting of this string will be validated with the PHP e-mail validation filter.
  • 'from': The address the message will be marked as being from, which is either a custom address or the site-wide default email address.
  • 'subject': Subject of the email to be sent. This must not contain any newline characters, or the email may not be sent properly.
  • 'body': An array of strings containing the message text. The message body is created by concatenating the individual array strings into a single text string using "\n\n" as a separator.
  • 'headers': Associative array containing mail headers, such as From, Sender, MIME-Version, Content-Type, etc.
  • 'params': An array of optional parameters supplied by the caller of drupal_mail() that is used to build the message before hook_mail_alter() is invoked.
  • 'language': The language object used to build the message before hook_mail_alter() is invoked.
  • 'send': Set to FALSE to abort sending this email message.
See Also
drupal_mail()

Definition at line 1974 of file system.api.php.

References t(), and variable_get().

hook_menu ( )

Define menu items and page callbacks.

This hook enables modules to register paths in order to define how URL requests are handled. Paths may be registered for URL handling only, or they can register a link to be placed in a menu (usually the Navigation menu). A path and its associated information is commonly called a "menu router item". This hook is rarely called (for example, when modules are enabled), and its results are cached in the database.

hook_menu() implementations return an associative array whose keys define paths and whose values are an associative array of properties for each path. (The complete list of properties is in the return value section below.)

Callback Functions

The definition for each path may include a page callback function, which is invoked when the registered path is requested. If there is no other registered path that fits the requested path better, any further path components are passed to the callback function. For example, your module could register path 'abc/def':

* function mymodule_menu() {
* $items['abc/def'] = array(
* 'page callback' => 'mymodule_abc_view',
* );
* return $items;
* }
*
* function mymodule_abc_view($ghi = 0, $jkl = '') {
* // ...
* }
*

When path 'abc/def' is requested, no further path components are in the request, and no additional arguments are passed to the callback function (so $ghi and $jkl would take the default values as defined in the function signature). When 'abc/def/123/foo' is requested, $ghi will be '123' and $jkl will be 'foo'. Note that this automatic passing of optional path arguments applies only to page and theme callback functions.

Callback Arguments

In addition to optional path arguments, the page callback and other callback functions may specify argument lists as arrays. These argument lists may contain both fixed/hard-coded argument values and integers that correspond to path components. When integers are used and the callback function is called, the corresponding path components will be substituted for the integers. That is, the integer 0 in an argument list will be replaced with the first path component, integer 1 with the second, and so on (path components are numbered starting from zero). To pass an integer without it being replaced with its respective path component, use the string value of the integer (e.g., '1') as the argument value. This substitution feature allows you to re-use a callback function for several different paths. For example:

* function mymodule_menu() {
* $items['abc/def'] = array(
* 'page callback' => 'mymodule_abc_view',
* 'page arguments' => array(1, 'foo'),
* );
* return $items;
* }
*

When path 'abc/def' is requested, the page callback function will get 'def' as the first argument and (always) 'foo' as the second argument.

If a page callback function uses an argument list array, and its path is requested with optional path arguments, then the list array's arguments are passed to the callback function first, followed by the optional path arguments. Using the above example, when path 'abc/def/bar/baz' is requested, mymodule_abc_view() will be called with 'def', 'foo', 'bar' and 'baz' as arguments, in that order.

Special care should be taken for the page callback drupal_get_form(), because your specific form callback function will always receive $form and &$form_state as the first function arguments:

* function mymodule_abc_form($form, &$form_state) {
* // ...
* return $form;
* }
*

See Form API documentation for details.

Wildcards in Paths

Simple Wildcards

Wildcards within paths also work with integer substitution. For example, your module could register path 'my-module/%/edit':

* $items['my-module/%/edit'] = array(
* 'page callback' => 'mymodule_abc_edit',
* 'page arguments' => array(1),
* );
*

When path 'my-module/foo/edit' is requested, integer 1 will be replaced with 'foo' and passed to the callback function. Note that wildcards may not be used as the first component.

Auto-Loader Wildcards

Registered paths may also contain special "auto-loader" wildcard components in the form of 'mymodule_abc', where the '' part means that this path component is a wildcard, and the 'mymodule_abc' part defines the prefix for a load function, which here would be named mymodule_abc_load(). When a matching path is requested, your load function will receive as its first argument the path component in the position of the wildcard; load functions may also be passed additional arguments (see "load arguments" in the return value section below). For example, your module could register path 'my-module/mymodule_abc/edit':

* $items['my-module/%mymodule_abc/edit'] = array(
* 'page callback' => 'mymodule_abc_edit',
* 'page arguments' => array(1),
* );
*

When path 'my-module/123/edit' is requested, your load function mymodule_abc_load() will be invoked with the argument '123', and should load and return an "abc" object with internal id 123:

* function mymodule_abc_load($abc_id) {
* return db_query("SELECT * FROM {mymodule_abc} WHERE abc_id = :abc_id", array(':abc_id' => $abc_id))->fetchObject();
* }
*

This 'abc' object will then be passed into the callback functions defined for the menu item, such as the page callback function mymodule_abc_edit() to replace the integer 1 in the argument array. Note that a load function should return FALSE when it is unable to provide a loadable object. For example, the node_load() function for the 'node/node/edit' menu item will return FALSE for the path 'node/999/edit' if a node with a node ID of 999 does not exist. The menu routing system will return a 404 error in this case.

Argument Wildcards

You can also define a wildcard_to_arg() function (for the example menu entry above this would be 'mymodule_abc_to_arg()'). The _to_arg() function is invoked to retrieve a value that is used in the path in place of the wildcard. A good example is user.module, which defines user_uid_optional_to_arg() (corresponding to the menu entry 'tracker/user_uid_optional'). This function returns the user ID of the current user.

The _to_arg() function will get called with three arguments:

  • $arg: A string representing whatever argument may have been supplied by the caller (this is particularly useful if you want the _to_arg() function only supply a (default) value if no other value is specified, as in the case of user_uid_optional_to_arg().
  • $map: An array of all path fragments (e.g. array('node','123','edit') for 'node/123/edit').
  • index:
    An integer indicating which element of
    map corresponds to $arg.

_load() and _to_arg() functions may seem similar at first glance, but they have different purposes and are called at different times. _load() functions are called when the menu system is collecting arguments to pass to the callback functions defined for the menu item. _to_arg() functions are called when the menu system is generating links to related paths, such as the tabs for a set of MENU_LOCAL_TASK items.

Rendering Menu Items As Tabs

You can also make groups of menu items to be rendered (by default) as tabs on a page. To do that, first create one menu item of type MENU_NORMAL_ITEM, with your chosen path, such as 'foo'. Then duplicate that menu item, using a subdirectory path, such as 'foo/tab1', and changing the type to MENU_DEFAULT_LOCAL_TASK to make it the default tab for the group. Then add the additional tab items, with paths such as "foo/tab2" etc., with type MENU_LOCAL_TASK. Example:

* // Make "Foo settings" appear on the admin Config page
* $items['admin/config/system/foo'] = array(
* 'title' => 'Foo settings',
* 'type' => MENU_NORMAL_ITEM,
* // Page callback, etc. need to be added here.
* );
* // Make "Tab 1" the main tab on the "Foo settings" page
* $items['admin/config/system/foo/tab1'] = array(
* 'title' => 'Tab 1',
* 'type' => MENU_DEFAULT_LOCAL_TASK,
* // Access callback, page callback, and theme callback will be inherited
* // from 'admin/config/system/foo', if not specified here to override.
* );
* // Make an additional tab called "Tab 2" on "Foo settings"
* $items['admin/config/system/foo/tab2'] = array(
* 'title' => 'Tab 2',
* 'type' => MENU_LOCAL_TASK,
* // Page callback and theme callback will be inherited from
* // 'admin/config/system/foo', if not specified here to override.
* // Need to add access callback or access arguments.
* );
*
Returns
An array of menu items. Each menu item has a key corresponding to the Drupal path being registered. The corresponding array value is an associative array that may contain the following key-value pairs:
  • "title": Required. The untranslated title of the menu item.
  • "title callback": Function to generate the title; defaults to t(). If you require only the raw string to be output, set this to FALSE.
  • "title arguments": Arguments to send to t() or your custom callback, with path component substitution as described above.
  • "description": The untranslated description of the menu item.
  • "page callback": The function to call to display a web page when the user visits the path. If omitted, the parent menu item's callback will be used instead.
  • "page arguments": An array of arguments to pass to the page callback function, with path component substitution as described above.
  • "delivery callback": The function to call to package the result of the page callback function and send it to the browser. Defaults to drupal_deliver_html_page() unless a value is inherited from a parent menu item. Note that this function is called even if the access checks fail, so any custom delivery callback function should take that into account. See drupal_deliver_html_page() for an example.
  • "access callback": A function returning TRUE if the user has access rights to this menu item, and FALSE if not. It can also be a boolean constant instead of a function, and you can also use numeric values (will be cast to boolean). Defaults to user_access() unless a value is inherited from the parent menu item; only MENU_DEFAULT_LOCAL_TASK items can inherit access callbacks. To use the user_access() default callback, you must specify the permission to check as 'access arguments' (see below).
  • "access arguments": An array of arguments to pass to the access callback function, with path component substitution as described above. If the access callback is inherited (see above), the access arguments will be inherited with it, unless overridden in the child menu item.
  • "theme callback": (optional) A function returning the machine-readable name of the theme that will be used to render the page. If not provided, the value will be inherited from a parent menu item. If there is no theme callback, or if the function does not return the name of a current active theme on the site, the theme for this page will be determined by either hook_custom_theme() or the default theme instead. As a general rule, the use of theme callback functions should be limited to pages whose functionality is very closely tied to a particular theme, since they can only be overridden by modules which specifically target those pages in hook_menu_alter(). Modules implementing more generic theme switching functionality (for example, a module which allows the theme to be set dynamically based on the current user's role) should use hook_custom_theme() instead.
  • "theme arguments": An array of arguments to pass to the theme callback function, with path component substitution as described above.
  • "file": A file that will be included before the page callback is called; this allows page callback functions to be in separate files. The file should be relative to the implementing module's directory unless otherwise specified by the "file path" option. Does not apply to other callbacks (only page callback).
  • "file path": The path to the directory containing the file specified in "file". This defaults to the path to the module implementing the hook.
  • "load arguments": An array of arguments to be passed to each of the wildcard object loaders in the path, after the path argument itself. For example, if a module registers path node/node/revisions/%/view with load arguments set to array(3), the 'node' in the path indicates that the loader function node_load() will be called with the second path component as the first argument. The 3 in the load arguments indicates that the fourth path component will also be passed to node_load() (numbering of path components starts at zero). So, if path node/12/revisions/29/view is requested, node_load(12, 29) will be called. There are also two "magic" values that can be used in load arguments. "%index" indicates the index of the wildcard path component. "%map" indicates the path components as an array. For example, if a module registers for several paths of the form 'user/user_category/edit/*', all of them can use the same load function user_category_load(), by setting the load arguments to array('map', 'index'). For instance, if the user is editing category 'foo' by requesting path 'user/32/edit/foo', the load function user_category_load() will be called with 32 as its first argument, the array ('user', 32, 'edit', 'foo') as the map argument, and 1 as the index argument (because user_category is the second path component and numbering starts at zero). user_category_load() can then use these values to extract the information that 'foo' is the category being requested.
  • "weight": An integer that determines the relative position of items in the menu; higher-weighted items sink. Defaults to 0. Menu items with the same weight are ordered alphabetically.
  • "menu_name": Optional. Set this to a custom menu if you don't want your item to be placed in Navigation.
  • "expanded": Optional. If set to TRUE, and if a menu link is provided for this menu item (as a result of other properties), then the menu link is always expanded, equivalent to its 'always expanded' checkbox being set in the UI.
  • "context": (optional) Defines the context a tab may appear in. By default, all tabs are only displayed as local tasks when being rendered in a page context. All tabs that should be accessible as contextual links in page region containers outside of the parent menu item's primary page context should be registered using one of the following contexts:
    • MENU_CONTEXT_PAGE: (default) The tab is displayed as local task for the page context only.
    • MENU_CONTEXT_INLINE: The tab is displayed as contextual link outside of the primary page context only. Contexts can be combined. For example, to display a tab both on a page and inline, a menu router item may specify:
      * 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
      *
  • "tab_parent": For local task menu items, the path of the task's parent item; defaults to the same path without the last component (e.g., the default parent for 'admin/people/create' is 'admin/people').
  • "tab_root": For local task menu items, the path of the closest non-tab item; same default as "tab_parent".
  • "position": Position of the block ('left' or 'right') on the system administration page for this item.
  • "type": A bitmask of flags describing properties of the menu item. Many shortcut bitmasks are provided as constants in menu.inc:
    • MENU_NORMAL_ITEM: Normal menu items show up in the menu tree and can be moved/hidden by the administrator.
    • MENU_CALLBACK: Callbacks simply register a path so that the correct information is generated when the path is accessed.
    • MENU_SUGGESTED_ITEM: Modules may "suggest" menu items that the administrator may enable.
    • MENU_LOCAL_ACTION: Local actions are menu items that describe actions on the parent item such as adding a new user or block, and are rendered in the action-links list in your theme.
    • MENU_LOCAL_TASK: Local tasks are menu items that describe different displays of data, and are generally rendered as tabs.
    • MENU_DEFAULT_LOCAL_TASK: Every set of local tasks should provide one "default" task, which should display the same page as the parent item. If the "type" element is omitted, MENU_NORMAL_ITEM is assumed.
  • "options": An array of options to be passed to l() when generating a link from this menu item. Note that the "options" parameter has no effect on MENU_LOCAL_TASK, MENU_DEFAULT_LOCAL_TASK, and MENU_LOCAL_ACTION items.

For a detailed usage example, see page_example.module. For comprehensive documentation on the menu system, see http://drupal.org/node/102338.

Definition at line 1264 of file system.api.php.

References MENU_CALLBACK, and MENU_SUGGESTED_ITEM.

hook_menu_alter ( & $items )

Alter the data being saved to the {menu_router} table after hook_menu is invoked.

This hook is invoked by menu_router_build(). The menu definitions are passed in by reference. Each element of the $items array is one item returned by a module from hook_menu. Additional items may be added, or existing items altered.

Parameters
$items Associative array of menu router definitions returned from hook_menu().

Definition at line 1292 of file system.api.php.

hook_menu_breadcrumb_alter | ( | & | $active_trail,
 |  |  | $item
 | ) |  |

Alter links in the active trail before it is rendered as the breadcrumb.

This hook is invoked by menu_get_active_breadcrumb() and allows alteration of the breadcrumb links for the current page, which may be preferred instead of setting a custom breadcrumb via drupal_set_breadcrumb().

Implementations should take into account that menu_get_active_breadcrumb() subsequently performs the following adjustments to the active trail after this hook has been invoked:

  • The last link in $active_trail is removed, if its 'href' is identical to the 'href' of $item. This happens, because the breadcrumb normally does not contain a link to the current page.
  • The (second to) last link in $active_trail is removed, if the current $item is a MENU_DEFAULT_LOCAL_TASK. This happens in order to do not show a link to the current page, when being on the path for the default local task; e.g. when being on the path node/%/view, the breadcrumb should not contain a link to node/%.

Each link in the active trail must contain:

  • title: The localized title of the link.
  • href: The system path to link to.
  • localized_options: An array of options to pass to url().
Parameters
$active_trail | An array containing breadcrumb links for the current page.
$item | The menu router item of the current page.
See Also
drupal_set_breadcrumb()
menu_get_active_breadcrumb()
menu_get_active_trail()
menu_set_active_trail()

Definition at line 1519 of file system.api.php.

References drupal_is_front_page().

hook_menu_contextual_links_alter | ( | & | $links,
 |  |  | $router_item,
 |  |  | $root_path
 | ) |  |

Alter contextual links before they are rendered.

This hook is invoked by menu_contextual_links(). The system-determined contextual links are passed in by reference. Additional links may be added or existing links can be altered.

Each contextual link must at least contain:

  • title: The localized title of the link.
  • href: The system path to link to.
  • localized_options: An array of options to pass to url().
Parameters
$links | An associative array containing contextual links for the given $root_path, as described above. The array keys are used to build CSS class names for contextual links and must therefore be unique for each set of contextual links.
$router_item | The menu router item belonging to the $root_path being requested.
$root_path | The (parent) path that has been requested to build contextual links for. This is a normalized path, which means that an originally passed path of 'node/123' became 'node/'.
See Also
hook_contextual_links_view_alter()
menu_contextual_links()
hook_menu()
contextual_preprocess()

Definition at line 1561 of file system.api.php.

References $links, and t().

hook_menu_delete ( $menu )

Respond to a custom menu deletion.

This hook is used to notify modules that a custom menu along with all links contained in it (if any) has been deleted. Contributed modules may use the information to perform actions based on the information entered into the menu system.

Parameters
$menu An array representing a custom menu:
  • menu_name: The unique name of the custom menu.
  • title: The human readable menu title.
  • description: The custom menu description.
See Also
hook_menu_insert()
hook_menu_update()

Definition at line 78 of file menu.api.php.

References variable_get(), and variable_set().

hook_menu_get_item_alter | ( | & | $router_item,
 |  |  | $path,
 |  |  | $original_map
 | ) |  |

Alter a menu router item right after it has been retrieved from the database or cache.

This hook is invoked by menu_get_item() and allows for run-time alteration of router information (page_callback, title, and so on) before it is translated and checked for access. The passed-in $router_item is statically cached for the current request, so this hook is only invoked once for any router item that is retrieved via menu_get_item().

Usually, modules will only want to inspect the router item and conditionally perform other actions (such as preparing a state for the current request). Note that this hook is invoked for any router item that is retrieved by menu_get_item(), which may or may not be called on the path itself, so implementations should check the $path parameter if the alteration should fire for the current request only.

Parameters
$router_item | The menu router item for $path.
$path | The originally passed path, for which $router_item is responsible.
$original_map | The path argument map, as contained in $path.
See Also
menu_get_item()

Definition at line 940 of file system.api.php.

hook_menu_insert ( $menu )

Respond to a custom menu creation.

This hook is used to notify modules that a custom menu has been created. Contributed modules may use the information to perform actions based on the information entered into the menu system.

Parameters
$menu An array representing a custom menu:
  • menu_name: The unique name of the custom menu.
  • title: The human readable menu title.
  • description: The custom menu description.
See Also
hook_menu_update()
hook_menu_delete()

Definition at line 29 of file menu.api.php.

References variable_get(), and variable_set().

hook_menu_link_alter ( & $item )

Alter the data being saved to the {menu_links} table by menu_link_save().

Parameters
$item Associative array defining a menu link as passed into menu_link_save().
See Also
hook_translated_menu_link_alter()

Definition at line 1305 of file system.api.php.

hook_menu_link_delete ( $link )

Inform modules that a menu link has been deleted.

This hook is used to notify modules that menu items have been deleted. Contributed modules may use the information to perform actions based on the information entered into the menu system.

Parameters
$link Associative array defining a menu link as passed into menu_link_save().
See Also
hook_menu_link_insert()
hook_menu_link_update()

Definition at line 1411 of file system.api.php.

References db_delete().

hook_menu_link_insert ( $link )

Inform modules that a menu link has been created.

This hook is used to notify modules that menu items have been created. Contributed modules may use the information to perform actions based on the information entered into the menu system.

Parameters
$link Associative array defining a menu link as passed into menu_link_save().
See Also
hook_menu_link_update()
hook_menu_link_delete()

Definition at line 1365 of file system.api.php.

References drupal_write_record().

hook_menu_link_update ( $link )

Inform modules that a menu link has been updated.

This hook is used to notify modules that menu items have been updated. Contributed modules may use the information to perform actions based on the information entered into the menu system.

Parameters
$link Associative array defining a menu link as passed into menu_link_save().
See Also
hook_menu_link_insert()
hook_menu_link_delete()

Definition at line 1387 of file system.api.php.

References db_query(), and db_update().

hook_menu_local_tasks_alter | ( | & | $data,
 |  |  | $router_item,
 |  |  | $root_path
 | ) |  |

Alter tabs and actions displayed on the page before they are rendered.

This hook is invoked by menu_local_tasks(). The system-determined tabs and actions are passed in by reference. Additional tabs or actions may be added, or existing items altered.

Each tab or action is an associative array containing:

  • theme: The theme function to use to render.
  • link: An associative array containing:
    • title: The localized title of the link.
    • href: The system path to link to.
    • localized_options: An array of options to pass to l().
  • #active: Whether the link should be marked as 'active'.
Parameters
$data An associative array containing:
  • actions: An associative array containing:
    • count: The amount of actions determined by the menu system, which can be ignored.
    • output: A list of of actions, each one being an associative array as described above.
  • tabs: An indexed array (list) of tab levels (up to 2 levels), each containing an associative array:
    • count: The amount of tabs determined by the menu system. This value does not need to be altered if there is more than one tab.
    • output: A list of of tabs, each one being an associative array as described above.
$router_item | The menu system router item of the page.
$root_path | The path to the root item for this set of tabs.

Definition at line 1451 of file system.api.php.

References t().

hook_menu_site_status_alter | ( | & | $menu_site_status,
 |  |  | $path
 | ) |  |

Control site status before menu dispatching.

The hook is called after checking whether the site is offline but before the current router item is retrieved and executed by menu_execute_active_handler(). If the site is in offline mode, $menu_site_status is set to MENU_SITE_OFFLINE.

Parameters
$menu_site_status | Supported values are MENU_SITE_OFFLINE, MENU_ACCESS_DENIED, MENU_NOT_FOUND and MENU_SITE_ONLINE. Any other value than MENU_SITE_ONLINE will skip the default menu handling system and be passed for delivery to drupal_deliver_page() with a NULL $default_delivery_callback.
$path | Contains the system path that is going to be loaded. This is read only, use hook_url_inbound_alter() to change the path.

Definition at line 4645 of file system.api.php.

References MENU_SITE_OFFLINE, MENU_SITE_ONLINE, and user_is_anonymous().

hook_menu_update ( $menu )

Respond to a custom menu update.

This hook is used to notify modules that a custom menu has been updated. Contributed modules may use the information to perform actions based on the information entered into the menu system.

Parameters
$menu An array representing a custom menu:
  • menu_name: The unique name of the custom menu.
  • title: The human readable menu title.
  • description: The custom menu description.
  • old_name: The current 'menu_name'. Note that internal menu names cannot be changed after initial creation.
See Also
hook_menu_insert()
hook_menu_delete()

Definition at line 54 of file menu.api.php.

References variable_get(), and variable_set().

hook_module_implements_alter | ( | & | $implementations,
 |  |  | $hook
 | ) |  |

Alter the registry of modules implementing a hook.

This hook is invoked during module_implements(). A module may implement this hook in order to reorder the implementing modules, which are otherwise ordered by the module's system weight.

Note that hooks invoked using drupal_alter() can have multiple variations (such as hook_form_alter() and hook_form_FORM_ID_alter()). drupal_alter() will call all such variants defined by a single module in turn. For the purposes of hook_module_implements_alter(), these variants are treated as a single hook. Thus, to ensure that your implementation of hook_form_FORM_ID_alter() is called at the right time, you will have to change the order of hook_form_alter() implementation in hook_module_implements_alter().

Parameters
$implementations | An array keyed by the module's name. The value of each item corresponds to a $group, which is usually FALSE, unless the implementation is in a file named $module.$group.inc.
$hook | The name of the module hook being implemented.

Definition at line 2009 of file system.api.php.

hook_modules_disabled ( $modules )

Perform necessary actions after modules are disabled.

This function differs from hook_disable() in that it gives all other modules a chance to perform actions when modules are disabled, whereas hook_disable() is only called on the module actually being disabled.

Parameters
$modules An array of the modules that were disabled.
See Also
hook_disable()
hook_modules_uninstalled()

Definition at line 2630 of file system.api.php.

hook_modules_enabled ( $modules )

Perform necessary actions after modules are enabled.

This function differs from hook_enable() in that it gives all other modules a chance to perform actions when modules are enabled, whereas hook_enable() is only called on the module actually being enabled. See module_enable() for a detailed description of the order in which install and enable hooks are invoked.

Parameters
$modules An array of the modules that were enabled.
See Also
hook_enable()
hook_modules_installed()
module_enable()

Definition at line 2610 of file system.api.php.

References drupal_set_message(), and t().

hook_modules_installed ( $modules )

Perform necessary actions after modules are installed.

This function differs from hook_install() in that it gives all other modules a chance to perform actions when a module is installed, whereas hook_install() is only called on the module actually being installed. See module_enable() for a detailed description of the order in which install and enable hooks are invoked.

Parameters
$modules An array of the modules that were installed.
See Also
module_enable()
hook_modules_enabled()
hook_install()

Definition at line 2588 of file system.api.php.

References variable_set().

hook_modules_uninstalled ( $modules )

Perform necessary actions after modules are uninstalled.

This function differs from hook_uninstall() in that it gives all other modules a chance to perform actions when a module is uninstalled, whereas hook_uninstall() is only called on the module actually being uninstalled.

It is recommended that you implement this hook if your module stores data that may have been set by other modules.

Parameters
$modules An array of the modules that were uninstalled.
See Also
hook_uninstall()
hook_modules_disabled()

Definition at line 2652 of file system.api.php.

References $module, and db_delete().

hook_multilingual_settings_changed ( )

Allow modules to react to language settings changes.

Every module needing to act when the number of enabled languages changes should implement this. This is an "internal" hook and should not be invoked elsewhere. The typical implementation would trigger some kind of rebuilding, this way system components could properly react to the change of the enabled languages number.

Definition at line 35 of file locale.api.php.

References field_info_cache_clear().

hook_node_operations ( )

Add mass node operations.

This hook enables modules to inject custom operations into the mass operations dropdown found at admin/content, by associating a callback function with the operation, which is called when the form is submitted. The callback function receives one initial argument, which is an array of the checked nodes.

Returns
An array of operations. Each operation is an associative array that may contain the following key-value pairs:
  • label: (required) The label for the operation, displayed in the dropdown menu.
  • callback: (required) The function to call for the operation.
  • callback arguments: (optional) An array of additional arguments to pass to the callback function.

Definition at line 419 of file node.api.php.

References NODE_NOT_PROMOTED, NODE_NOT_PUBLISHED, NODE_NOT_STICKY, NODE_PROMOTED, NODE_PUBLISHED, NODE_STICKY, and t().

hook_node_type_delete ( $info )

Respond to node type deletion.

This hook is invoked from node_type_delete() after the node type is removed from the database.

Parameters
$info The node type object that is being deleted.

Definition at line 1026 of file node.api.php.

References $info, and variable_del().

hook_node_type_insert ( $info )

Respond to node type creation.

This hook is invoked from node_type_save() after the node type is added to the database.

Parameters
$info The node type object that is being created.

Definition at line 996 of file node.api.php.

References $info, drupal_set_message(), and t().

hook_node_type_update ( $info )

Respond to node type updates.

This hook is invoked from node_type_save() after the node type is updated in the database.

Parameters
$info The node type object that is being updated.

Definition at line 1009 of file node.api.php.

References $info, COMMENT_NODE_OPEN, variable_del(), variable_get(), and variable_set().

hook_openid | ( | $op,
 |  | $request
 | ) |

Allow modules to modify the OpenID request parameters.

Parameters
$op The operation to be performed. Possible values:
  • request: Modify parameters before they are sent to the OpenID provider.
$request An associative array of parameter defaults to which to modify or append.
Returns
An associative array of parameters to be merged with the default list.

Definition at line 26 of file openid.api.php.

References $op.

hook_openid_discovery_method_info ( )

Allow modules to declare OpenID discovery methods.

The discovery function callbacks will be called in turn with an unique parameter, the claimed identifier. They have to return an associative array with array of services and claimed identifier in the same form as returned by openid_discover(). The resulting array must contain following keys:

  • 'services' (required) an array of discovered services (including OpenID version, endpoint URI, etc).
  • 'claimed_id' (optional) new claimed identifer, found by following HTTP redirects during the services discovery.

The first discovery method that succeed (return at least one services) will stop the discovery process.

Returns
An associative array which keys are the name of the discovery methods and values are function callbacks.
See Also
hook_openid_discovery_method_info_alter()

Definition at line 69 of file openid.api.php.

hook_openid_discovery_method_info_alter ( & $methods )

Allow modules to alter discovery methods.

Definition at line 78 of file openid.api.php.

hook_openid_normalization_method_info ( )

Allow modules to declare OpenID normalization methods.

The discovery function callbacks will be called in turn with an unique parameter, the identifier to normalize. They have to return a normalized identifier, or NULL if the identifier is not in a form they can handle.

The first normalization method that succeed (return a value that is not NULL) will stop the normalization process.

Returns
An array with a set of function callbacks, that will be called in turn when normalizing an OpenID identifier. The normalization functions have to return a normalized identifier, or NULL if the identifier is not in a form they can handle.
See Also
hook_openid_normalization_method_info_alter()

Definition at line 100 of file openid.api.php.

hook_openid_normalization_method_info_alter ( & $methods )

Allow modules to alter normalization methods.

Definition at line 109 of file openid.api.php.

hook_openid_response | ( | $response,
 |  | $account
 | ) |

Allow modules to act upon a successful OpenID login.

Parameters
$response | Response values from the OpenID Provider.
$account | The Drupal user account that logged in

Definition at line 42 of file openid.api.php.

hook_overlay_child_initialize ( )

Allow modules to act when an overlay child window is initialized.

The child window is initialized when a page is displayed from within the overlay, so modules can act here if they need to take action to work from within the confines of the overlay.

Definition at line 33 of file overlay.api.php.

References drupal_add_js(), and drupal_get_path().

hook_overlay_parent_initialize ( )

Allow modules to act when an overlay parent window is initialized.

The parent window is initialized when a page is displayed in which the overlay might be required to be displayed, so modules can act here if they need to take action to accommodate the possibility of the overlay appearing within a Drupal page.

Definition at line 21 of file overlay.api.php.

References drupal_add_js(), and drupal_get_path().

hook_page_alter ( & $page )

Perform alterations before a page is rendered.

Use this hook when you want to remove or alter elements at the page level, or add elements at the page level that depend on an other module's elements (this hook runs after hook_page_build().

If you are making changes to entities such as forms, menus, or user profiles, use those objects' native alter hooks instead (hook_form_alter(), for example).

The $page array contains top level elements for each block region:

* $page['page_top']
* $page['header']
* $page['sidebar_first']
* $page['content']
* $page['sidebar_second']
* $page['page_bottom']
*

The 'content' element contains the main content of the current page, and its structure will vary depending on what module is responsible for building the page. Some legacy modules may not return structured content at all: their pre-rendered markup will be located in $page['content']['main']['#markup'].

Pages built by Drupal's core Node and Blog modules use a standard structure:

* // Node body.
* $page['content']['system_main']['nodes'][$nid]['body']
* // Array of links attached to the node (add comments, read more).
* $page['content']['system_main']['nodes'][$nid]['links']
* // The node object itself.
* $page['content']['system_main']['nodes'][$nid]['#node']
* // The results pager.
* $page['content']['system_main']['pager']
*

Blocks may be referenced by their module/delta pair within a region:

* // The login block in the first sidebar region.
* $page['sidebar_first']['user_login']['#block'];
*
Parameters
$page Nested array of renderable elements that make up the page.
See Also
hook_page_build()
drupal_render_page()

Definition at line 1627 of file system.api.php.

References $page, and t().

hook_page_build ( & $page )

Add elements to a page before it is rendered.

Use this hook when you want to add elements at the page level. For your additions to be printed, they have to be placed below a top level array key of the $page array that has the name of a region of the active theme.

By default, valid region keys are 'page_top', 'header', 'sidebar_first', 'content', 'sidebar_second' and 'page_bottom'. To get a list of all regions of the active theme, use system_region_list($theme). Note that $theme is a global variable.

If you want to alter the elements added by other modules or if your module depends on the elements of other modules, use hook_page_alter() instead which runs after this hook.

Parameters
$page Nested array of renderable elements that make up the page.
See Also
hook_page_alter()
drupal_render_page()

Definition at line 905 of file system.api.php.

References $page, menu_get_object(), and t().

hook_page_delivery_callback_alter ( & $callback )

Alters the delivery callback used to send the result of the page callback to the browser.

Called by drupal_deliver_page() to allow modules to alter how the page is delivered to the browser.

This hook is intended for altering the delivery callback based on information unrelated to the path of the page accessed. For example, it can be used to set the delivery callback based on a HTTP request header (as shown in the code sample). To specify a delivery callback based on path information, use hook_menu() or hook_menu_alter().

This hook can also be used as an API function that can be used to explicitly set the delivery callback from some other function. For example, for a module named MODULE:

* function MODULE_page_delivery_callback_alter(&$callback, $set = FALSE) {
* static $stored_callback;
* if ($set) {
* $stored_callback = $callback;
* }
* elseif (isset($stored_callback)) {
* $callback = $stored_callback;
* }
* }
* function SOMEWHERE_ELSE() {
* $desired_delivery_callback = 'foo';
* MODULE_page_delivery_callback_alter($desired_delivery_callback, TRUE);
* }
*
Parameters
$callback The name of a function.
See Also
drupal_deliver_page()

Definition at line 4178 of file system.api.php.

hook_path_delete ( $path )

Respond to a path being deleted.

Parameters
$path An associative array containing the following keys:
  • source: The internal system path.
  • alias: The URL alias.
  • pid: Unique path alias identifier.
  • language: The language of the alias.
See Also
path_delete()

Definition at line 65 of file path.api.php.

References db_delete().

hook_path_insert ( $path )

Respond to a path being inserted.

Parameters
$path An associative array containing the following keys:
  • source: The internal system path.
  • alias: The URL alias.
  • pid: Unique path alias identifier.
  • language: The language of the alias.
See Also
path_save()

Definition at line 25 of file path.api.php.

References db_insert().

hook_path_update ( $path )

Respond to a path being updated.

Parameters
$path An associative array containing the following keys:
  • source: The internal system path.
  • alias: The URL alias.
  • pid: Unique path alias identifier.
  • language: The language of the alias.
See Also
path_save()

Definition at line 46 of file path.api.php.

References db_update().

hook_permission ( )

Define user permissions.

This hook can supply permissions that the module defines, so that they can be selected on the user permissions page and used to grant or restrict access to actions the module performs.

Permissions are checked using user_access().

For a detailed usage example, see page_example.module.

Returns
An array whose keys are permission names and whose corresponding values are arrays containing the following key-value pairs:
  • title: The human-readable name of the permission, to be shown on the permission administration page. This should be wrapped in the t() function so it can be translated.
  • description: (optional) A description of what the permission does. This should be wrapped in the t() function so it can be translated.
  • restrict access: (optional) A boolean which can be set to TRUE to indicate that site administrators should restrict access to this permission to trusted users. This should be used for permissions that have inherent security risks across a variety of potential use cases (for example, the "administer filters" and "bypass node access" permissions provided by Drupal core). When set to TRUE, a standard warning message defined in user_admin_permissions() and output via theme_user_permission_description() will be associated with the permission and displayed with it on the permission administration page. Defaults to FALSE.
  • warning: (optional) A translated warning message to display for this permission on the permission administration page. This warning overrides the automatic warning generated by 'restrict access' being set to TRUE. This should rarely be used, since it is important for all permissions to have a clear, consistent security warning that is the same across the site. Use the 'description' key instead to provide any information that is specific to the permission you are defining.
See Also
theme_user_permission_description()

Definition at line 2103 of file system.api.php.

References t().

hook_query_alter ( QueryAlterableInterface $query )

Perform alterations to a structured query.

Structured (aka dynamic) queries that have tags associated may be altered by any module before the query is executed.

Parameters
$query A Query object describing the composite parts of a SQL query.
See Also
hook_query_TAG_alter()
node_query_node_access_alter()
QueryAlterableInterface
SelectQueryInterface

Definition at line 3228 of file system.api.php.

References QueryAlterableInterface\hasTag().

hook_query_TAG_alter ( QueryAlterableInterface $query )

Perform alterations to a structured query for a given tag.

Parameters
$query An Query object describing the composite parts of a SQL query.
See Also
hook_query_alter()
node_query_node_access_alter()
QueryAlterableInterface
SelectQueryInterface

Definition at line 3245 of file system.api.php.

References $op, db_and(), db_or(), QueryAlterableInterface\getMetaData(), node_access_grants(), node_access_view_all_nodes(), and user_access().

hook_registry_files_alter | ( | & | $files,
 |  |  | $modules
 | ) |  |

Perform necessary alterations to the list of files parsed by the registry.

Modules can manually modify the list of files before the registry parses them. The $modules array provides the .info file information, which includes the list of files registered to each module. Any files in the list can then be added to the list of files that the registry will parse, or modify attributes of a file.

A necessary alteration made by the core SimpleTest module is to force .test files provided by disabled modules into the list of files parsed by the registry.

Parameters
$files List of files to be parsed by the registry. The list will contain files found in each enabled module's info file and the core includes directory. The array is keyed by the file path and contains an array of the related module's name and weight as used internally by _registry_update() and related functions.

For example:

* $files["modules/system/system.module"] = array(
* 'module' => 'system',
* 'weight' => 0,
* );
*
Parameters
$modules An array containing all module information stored in the {system} table. Each element of the array also contains the module's .info file information in the property 'info'. An additional 'dir' property has been added to the module information which provides the path to the directory in which the module resides. The example shows how to take advantage of both properties.
See Also
_registry_update()
simpletest_test_get_all()

Definition at line 3615 of file system.api.php.

References $dir, and $module.

hook_requirements ( $phase )

Check installation requirements and do status reporting.

This hook has three closely related uses, determined by the $phase argument:

  • Checking installation requirements ($phase == 'install').
  • Checking update requirements ($phase == 'update').
  • Status reporting ($phase == 'runtime').

Note that this hook, like all others dealing with installation and updates, must reside in a module_name.install file, or it will not properly abort the installation of the module if a critical requirement is missing.

During the 'install' phase, modules can for example assert that library or server versions are available or sufficient. Note that the installation of a module can happen during installation of Drupal itself (by install.php) with an installation profile or later by hand. As a consequence, install-time requirements must be checked without access to the full Drupal API, because it is not available during install.php. For localization you should for example use $t = get_t() to retrieve the appropriate localization function name (t() or st()). If a requirement has a severity of REQUIREMENT_ERROR, install.php will abort or at least the module will not install. Other severity levels have no effect on the installation. Module dependencies do not belong to these installation requirements, but should be defined in the module's .info file.

The 'runtime' phase is not limited to pure installation requirements but can also be used for more general status information like maintenance tasks and security issues. The returned 'requirements' will be listed on the status report in the administration section, with indication of the severity level. Moreover, any requirement with a severity of REQUIREMENT_ERROR severity will result in a notice on the administration configuration page.

Parameters
$phase The phase in which requirements are checked:
  • install: The module is being installed.
  • update: The module is enabled and update.php is run.
  • runtime: The runtime requirements are being checked and shown on the status report page.
Returns
An associative array where the keys are arbitrary but must be unique (it is suggested to use the module short name as a prefix) and the values are themselves associative arrays with the following elements:
  • title: The name of the requirement.
  • value: The current value (e.g., version, time, level, etc). During install phase, this should only be used for version numbers, do not set it if not applicable.
  • description: The description of the requirement/status.
  • severity: The requirement's result/severity level, one of:
    • REQUIREMENT_INFO: For info only.
    • REQUIREMENT_OK: The requirement is satisfied.
    • REQUIREMENT_WARNING: The requirement failed with a warning.
    • REQUIREMENT_ERROR: The requirement failed with an error.

Definition at line 3053 of file system.api.php.

References DRUPAL_MINIMUM_PHP, format_interval(), get_t(), l(), REQUEST_TIME, REQUIREMENT_ERROR, REQUIREMENT_INFO, url(), variable_get(), and VERSION.

hook_search_page ( $results )

Override the rendering of search results.

A module that implements hook_search_info() to define a type of search may implement this hook in order to override the default theming of its search results, which is otherwise themed using theme('search_results').

Note that by default, theme('search_results') and theme('search_result') work together to create an ordered list (OL). So your hook_search_page() implementation should probably do this as well.

Parameters
$results An array of search results.
Returns
A renderable array, which will render the formatted search results with a pager included.
See Also
search-result.tpl.php
search-results.tpl.php

Definition at line 244 of file search.api.php.

References $output, $results, and theme().

hook_shortcut_default_set ( $account )

Return the name of a default shortcut set for the provided user account.

This hook allows modules to define default shortcut sets for a particular user that differ from the site-wide default (for example, a module may want to define default shortcuts on a per-role basis).

The default shortcut set is used only when the user does not have any other shortcut set explicitly assigned to them.

Note that only one default shortcut set can exist per user, so when multiple modules implement this hook, the last (i.e., highest weighted) module which returns a valid shortcut set name will prevail.

Parameters
$account The user account whose default shortcut set is being requested.
Returns
The name of the shortcut set that this module recommends for that user, if there is one.

Definition at line 33 of file shortcut.api.php.

References variable_get().

hook_simpletest_alter ( & $groups )

Alter the list of tests.

Parameters
$groups A two dimension array, the first key is the test group (as defined in getInfo) the second is the name of the class and the value is the return value of the getInfo method.

Definition at line 21 of file simpletest.api.php.

hook_stream_wrappers ( )

Registers PHP stream wrapper implementations associated with a module.

Provide a facility for managing and querying user-defined stream wrappers in PHP. PHP's internal stream_get_wrappers() doesn't return the class registered to handle a stream, which we need to be able to find the handler for class instantiation.

If a module registers a scheme that is already registered with PHP, it will be unregistered and replaced with the specified class.

Returns
A nested array, keyed first by scheme name ("public" for "public://"), then keyed by the following values:
  • 'name' A short string to name the wrapper.
  • 'class' A string specifying the PHP class that implements the DrupalStreamWrapperInterface interface.
  • 'description' A string with a short description of what the wrapper does.
  • 'type' (Optional) A bitmask of flags indicating what type of streams this wrapper will access - local or remote, readable and/or writeable, etc. Many shortcut constants are defined in stream_wrappers.inc. Defaults to STREAM_WRAPPERS_NORMAL which includes all of these bit flags:
    • STREAM_WRAPPERS_READ
    • STREAM_WRAPPERS_WRITE
    • STREAM_WRAPPERS_VISIBLE
See Also
file_get_stream_wrappers()
hook_stream_wrappers_alter()
system_stream_wrappers()

Definition at line 2691 of file system.api.php.

References STREAM_WRAPPERS_LOCAL_HIDDEN, STREAM_WRAPPERS_LOCAL_NORMAL, STREAM_WRAPPERS_READ_VISIBLE, and t().

hook_stream_wrappers_alter ( & $wrappers )

Alters the list of PHP stream wrapper implementations.

See Also
file_get_stream_wrappers()
hook_stream_wrappers()

Definition at line 2735 of file system.api.php.

References t().

hook_system_info_alter | ( | & | $info,
 |  |  | $file,
 |  |  | $type
 | ) |  |

Alter the information parsed from module and theme .info files

This hook is invoked in _system_rebuild_module_data() and in _system_rebuild_theme_data(). A module may implement this hook in order to add to or alter the data generated by reading the .info file with drupal_parse_info_file().

Parameters
$info | The .info file contents, passed by reference so that it can be altered.
$file | Full information about the module or theme, including $file->name, and $file->filename
$type | Either 'module' or 'theme', depending on the type of .info file that was passed.

Definition at line 2057 of file system.api.php.

References $info.

hook_system_theme_info ( )

Return additional themes provided by modules.

Only use this hook for testing purposes. Use a hidden MYMODULE_test.module to implement this hook. Testing themes should be hidden, too.

This hook is invoked from _system_rebuild_theme_data() and allows modules to register additional themes outside of the regular 'themes' directories of a Drupal installation.

Returns
An associative array. Each key is the system name of a theme and each value is the corresponding path to the theme's .info file.

Definition at line 2035 of file system.api.php.

References drupal_get_path().

hook_system_themes_page_alter ( & $theme_groups )

Alters theme operation links.

Parameters
$theme_groups An associative array containing groups of themes.
See Also
system_themes_page()

Definition at line 4195 of file system.api.php.

References t().

hook_taxonomy_term_delete ( $term )

Respond to the deletion of taxonomy terms.

Modules implementing this hook can respond to the deletion of taxonomy terms from the database.

Parameters
$term A taxonomy term object.

Definition at line 171 of file taxonomy.api.php.

References db_delete().

hook_taxonomy_term_insert ( $term )

Act on taxonomy terms when inserted.

Modules implementing this hook can act on the term object when saved to the database.

Parameters
$term A taxonomy term object.

Definition at line 138 of file taxonomy.api.php.

References db_insert().

hook_taxonomy_term_load ( $terms )

Act on taxonomy terms when loaded.

Modules implementing this hook can act on the term objects returned by taxonomy_term_load_multiple().

For performance reasons, information to be added to term objects should be loaded in a single query for all terms where possible.

Since terms are stored and retrieved from cache during a page request, avoid altering properties provided by the {taxonomy_term_data} table, since this may affect the way results are loaded from cache in subsequent calls.

Parameters
$terms An array of term objects, indexed by tid.

Definition at line 106 of file taxonomy.api.php.

References db_select().

hook_taxonomy_term_presave ( $term )

Act on taxonomy terms before they are saved.

Modules implementing this hook can act on the term object before it is inserted or updated.

Parameters
$term A term object.

Definition at line 125 of file taxonomy.api.php.

hook_taxonomy_term_update ( $term )

Act on taxonomy terms when updated.

Modules implementing this hook can act on the term object when updated.

Parameters
$term A taxonomy term object.

Definition at line 155 of file taxonomy.api.php.

References db_update().

hook_taxonomy_term_view | ( | $term,
 |  | $view_mode,
 |  | $langcode
 | ) |

Act on a taxonomy term that is being assembled before rendering.

The module may add elements to $term->content prior to rendering. The structure of $term->content is a renderable array as expected by drupal_render().

Parameters
$term | The term that is being assembled for rendering.
$view_mode | The $view_mode parameter from taxonomy_term_view().
$langcode | The language code used for rendering.
See Also
hook_entity_view()

Definition at line 193 of file taxonomy.api.php.

hook_taxonomy_term_view_alter ( & $build )

Alter the results of taxonomy_term_view().

This hook is called after the content has been assembled in a structured array and may be used for doing processing which requires that the complete taxonomy term content structure has been built.

If the module wishes to act on the rendered HTML of the term rather than the structured content array, it may use this hook to add a #post_render callback. Alternatively, it could also implement hook_preprocess_taxonomy_term(). See drupal_render() and theme() documentation respectively for details.

Parameters
$build A renderable array representing the node content.
See Also
hook_entity_view_alter()

Definition at line 219 of file taxonomy.api.php.

hook_taxonomy_vocabulary_delete ( $vocabulary )

Respond to the deletion of taxonomy vocabularies.

Modules implementing this hook can respond to the deletion of taxonomy vocabularies from the database.

Parameters
$vocabulary A taxonomy vocabulary object.

Definition at line 84 of file taxonomy.api.php.

References db_delete().

hook_taxonomy_vocabulary_insert ( $vocabulary )

Act on taxonomy vocabularies when inserted.

Modules implementing this hook can act on the vocabulary object when saved to the database.

Parameters
$vocabulary A taxonomy vocabulary object.

Definition at line 54 of file taxonomy.api.php.

hook_taxonomy_vocabulary_load ( $vocabularies )

Act on taxonomy vocabularies when loaded.

Modules implementing this hook can act on the vocabulary objects before they are returned by taxonomy_vocabulary_load_multiple().

Parameters
$vocabulary An array of taxonomy vocabulary objects.

Definition at line 22 of file taxonomy.api.php.

References db_select().

hook_taxonomy_vocabulary_presave ( $vocabulary )

Act on taxonomy vocabularies before they are saved.

Modules implementing this hook can act on the vocabulary object before it is inserted or updated.

Parameters
$vocabulary A taxonomy vocabulary object.

Definition at line 41 of file taxonomy.api.php.

hook_taxonomy_vocabulary_update ( $vocabulary )

Act on taxonomy vocabularies when updated.

Modules implementing this hook can act on the vocabulary object when updated.

Parameters
$vocabulary A taxonomy vocabulary object.

Definition at line 68 of file taxonomy.api.php.

References db_update().

hook_test_finished ( $results )

An individual test has finished.

This hook is called when an individual test has finished.

Parameters
$results The results of the test as gathered by DrupalWebTestCase.
See Also
DrupalWebTestCase->results

Definition at line 54 of file simpletest.api.php.

hook_test_group_finished ( )

A test group has finished.

This hook is called just once at the end of a test group.

Definition at line 41 of file simpletest.api.php.

hook_test_group_started ( )

A test group has started.

This hook is called just once at the beginning of a test group.

Definition at line 33 of file simpletest.api.php.

hook_theme | ( | $existing,
 |  | $type,
 |  | $theme,
 |  | $path
 | ) |

Register a module (or theme's) theme implementations.

The implementations declared by this hook have two purposes: either they specify how a particular render array is to be rendered as HTML (this is usually the case if the theme function is assigned to the render array's theme property), or they return the HTML that should be returned by an invocation of theme(). See Using the theme layer Drupal 7.x for more information on how to implement theme hooks.

The following parameters are all optional.

Parameters
array | $existing | An array of existing implementations that may be used for override purposes. This is primarily useful for themes that may wish to examine existing implementations to extract data (such as arguments) so that it may properly register its own, higher priority implementations.
$type Whether a theme, module, etc. is being processed. This is primarily useful so that themes tell if they are the actual theme being called or a parent theme. May be one of:
  • 'module': A module is being checked for theme implementations.
  • 'base_theme_engine': A theme engine is being checked for a theme that is a parent of the actual theme being used.
  • 'theme_engine': A theme engine is being checked for the actual theme being used.
  • 'base_theme': A base theme is being checked for theme implementations.
  • 'theme': The actual theme in use is being checked.
$theme | The actual name of theme, module, etc. that is being being processed.
$path | The directory path of the theme or module, so that it doesn't need to be looked up.
Returns
array An associative array of theme hook information. The keys on the outer array are the internal names of the hooks, and the values are arrays containing information about the hook. Each information array must contain either a 'variables' element or a 'render element' element, but not both. Use 'render element' if you are theming a single element or element tree composed of elements, such as a form array, a page array, or a single checkbox element. Use 'variables' if your theme implementation is intended to be called directly through theme() and has multiple arguments for the data and style; in this case, the variables not supplied by the calling function will be given default values and passed to the template or theme function. The returned theme information array can contain the following key/value pairs:
  • variables: (see above) Each array key is the name of the variable, and the value given is used as the default value if the function calling theme() does not supply it. Template implementations receive each array key as a variable in the template file (so they must be legal PHP variable names). Function implementations are passed the variables in a single $variables function argument.
  • render element: (see above) The name of the renderable element or element tree to pass to the theme function. This name is used as the name of the variable that holds the renderable element or tree in preprocess and process functions.
  • file: The file the implementation resides in. This file will be included prior to the theme being rendered, to make sure that the function or preprocess function (as needed) is actually loaded; this makes it possible to split theme functions out into separate files quite easily.
  • path: Override the path of the file to be used. Ordinarily the module or theme path will be used, but if the file will not be in the default path, include it here. This path should be relative to the Drupal root directory.
  • template: If specified, this theme implementation is a template, and this is the template file without an extension. Do not put .tpl.php on this file; that extension will be added automatically by the default rendering engine (which is PHPTemplate). If 'path', above, is specified, the template should also be in this path.
  • function: If specified, this will be the function name to invoke for this implementation. If neither 'template' nor 'function' is specified, a default function name will be assumed. For example, if a module registers the 'node' theme hook, 'theme_node' will be assigned to its function. If the chameleon theme registers the node hook, it will be assigned 'chameleon_node' as its function.
  • base hook: A string declaring the base theme hook if this theme implementation is actually implementing a suggestion for another theme hook.
  • pattern: A regular expression pattern to be used to allow this theme implementation to have a dynamic name. The convention is to use __ to differentiate the dynamic portion of the theme. For example, to allow forums to be themed individually, the pattern might be: 'forum__'. Then, when the forum is themed, call:
    * theme(array('forum__' . $tid, 'forum'), $forum)
    *
  • preprocess functions: A list of functions used to preprocess this data. Ordinarily this won't be used; it's automatically filled in. By default, for a module this will be filled in as template_preprocess_HOOK. For a theme this will be filled in as phptemplate_preprocess and phptemplate_preprocess_HOOK as well as themename_preprocess and themename_preprocess_HOOK.
  • override preprocess functions: Set to TRUE when a theme does NOT want the standard preprocess functions to run. This can be used to give a theme FULL control over how variables are set. For example, if a theme wants total control over how certain variables in the page.tpl.php are set, this can be set to true. Please keep in mind that when this is used by a theme, that theme becomes responsible for making sure necessary variables are set.
  • type: (automatically derived) Where the theme hook is defined: 'module', 'theme_engine', or 'theme'.
  • theme path: (automatically derived) The directory path of the theme or module, so that it doesn't need to be looked up.
See Also
hook_theme_registry_alter()

Definition at line 2220 of file system.api.php.

hook_theme_registry_alter ( & $theme_registry )

Alter the theme registry information returned from hook_theme().

The theme registry stores information about all available theme hooks, including which callback functions those hooks will call when triggered, what template files are exposed by these hooks, and so on.

Note that this hook is only executed as the theme cache is re-built. Changes here will not be visible until the next cache clear.

The $theme_registry array is keyed by theme hook name, and contains the information returned from hook_theme(), as well as additional properties added by _theme_process_registry().

For example:

* $theme_registry['user_profile'] = array(
* 'variables' => array(
* 'account' => NULL,
* ),
* 'template' => 'modules/user/user-profile',
* 'file' => 'modules/user/user.pages.inc',
* 'type' => 'module',
* 'theme path' => 'modules/user',
* 'preprocess functions' => array(
* 0 => 'template_preprocess',
* 1 => 'template_preprocess_user_profile',
* ),
* );
*
Parameters
$theme_registry The entire cache of theme registry information, post-processing.
See Also
hook_theme()
_theme_process_registry()

Definition at line 2282 of file system.api.php.

References $value.

hook_token_info ( )

Provide information about available placeholder tokens and token types.

Tokens are placeholders that can be put into text by using the syntax [type:token], where type is the machine-readable name of a token type, and token is the machine-readable name of a token within this group. This hook provides a list of types and tokens to be displayed on text editing screens, so that people editing text can see what their token options are.

The actual token replacement is done by token_replace(), which invokes hook_tokens(). Your module will need to implement that hook in order to generate token replacements from the tokens defined here.

Returns
An associative array of available tokens and token types. The outer array has two components:
  • types: An associative array of token types (groups). Each token type is an associative array with the following components:
    • name: The translated human-readable short name of the token type.
    • description: A translated longer description of the token type.
    • needs-data: The type of data that must be provided to token_replace() in the $data argument (i.e., the key name in $data) in order for tokens of this type to be used in the $text being processed. For instance, if the token needs a node object, 'needs-data' should be 'node', and to use this token in token_replace(), the caller needs to supply a node object as $data['node']. Some token data can also be supplied indirectly; for instance, a node object in $data supplies a user object (the author of the node), allowing user tokens to be used when only a node data object is supplied.
  • tokens: An associative array of tokens. The outer array is keyed by the group name (the same key as in the types array). Within each group of tokens, each token item is keyed by the machine name of the token, and each token item has the following components:
    • name: The translated human-readable short name of the token.
    • description: A translated longer description of the token.
    • type (optional): A 'needs-data' data type supplied by this token, which should match a 'needs-data' value from another token type. For example, the node author token provides a user object, which can then be used for token replacement data in token_replace() without having to supply a separate user object.
See Also
hook_token_info_alter()
hook_tokens()

Definition at line 4460 of file system.api.php.

References t().

hook_token_info_alter ( & $data )

Alter the metadata about available placeholder tokens and token types.

Parameters
$data The associative array of token definitions from hook_token_info().
See Also
hook_token_info()

Definition at line 4507 of file system.api.php.

References t().

hook_tokens | ( |  | $type,
 |  |  | $tokens,
 |  | array | $data = array(),
 |  | array | $options = array()
 | ) |  |

Provide replacement values for placeholder tokens.

This hook is invoked when someone calls token_replace(). That function first scans the text for [type:token] patterns, and splits the needed tokens into groups by type. Then hook_tokens() is invoked on each token-type group, allowing your module to respond by providing replacement text for any of the tokens in the group that your module knows how to process.

A module implementing this hook should also implement hook_token_info() in order to list its available tokens on editing screens.

Parameters
$type | The machine-readable name of the type (group) of token being replaced, such as 'node', 'user', or another type defined by a hook_token_info() implementation.
$tokens | An array of tokens to be replaced. The keys are the machine-readable token names, and the values are the raw [type:token] strings that appeared in the original text.
$data | (optional) An associative array of data objects to be used when generating replacement values, as supplied in the $data parameter to token_replace().
$options | (optional) An associative array of options for token replacement; see token_replace() for possible values.
Returns
An associative array of replacement values, keyed by the raw [type:token] strings from the original text.
See Also
hook_token_info()
hook_tokens_alter()

Definition at line 4320 of file system.api.php.

References $author, $name, check_plain(), filter_xss(), format_date(), t(), token_find_with_prefix(), token_generate(), url(), user_load(), and variable_get().

hook_tokens_alter | ( | array & | $replacements,
 |  | array | $context
 | ) |  |

Alter replacement values for placeholder tokens.

Parameters
$replacements An associative array of replacements returned by hook_tokens().
$context The context in which hook_tokens() was called. An associative array with the following keys, which have the same meaning as the corresponding parameters of hook_tokens():
  • 'type'
  • 'tokens'
  • 'data'
  • 'options'
See Also
hook_tokens()

Definition at line 4392 of file system.api.php.

References $title, drupal_render(), and field_view_field().

hook_translated_menu_link_alter | ( | & | $item,
 |  |  | $map
 | ) |  |

Alter a menu link after it has been translated and before it is rendered.

This hook is invoked from _menu_link_translate() after a menu link has been translated; i.e., after dynamic path argument placeholders (%) have been replaced with actual values, the user access to the link's target page has been checked, and the link has been localized. It is only invoked if $item['options']['alter'] has been set to a non-empty value (e.g., TRUE). This flag should be set using hook_menu_link_alter().

Implementations of this hook are able to alter any property of the menu link. For example, this hook may be used to add a page-specific query string to all menu links, or hide a certain link by setting:

* 'hidden' => 1,
*
Parameters
$item | Associative array defining a menu link after _menu_link_translate()
$map | Associative array containing the menu $map (path parts and/or objects).
See Also
hook_menu_link_alter()

Definition at line 1346 of file system.api.php.

References drupal_get_destination().

hook_trigger_info ( )

Declare triggers (events) for users to assign actions to.

This hook is used by the trigger module to create a list of triggers (events) that users can assign actions to. Your module is responsible for detecting that the events have occurred, calling trigger_get_assigned_actions() to find out which actions the user has associated with your trigger, and then calling actions_do() to fire off the actions.

Returns
A nested associative array.
  • The outermost key is the name of the module that is defining the triggers. This will be used to create a local task (tab) in the trigger module's user interface. A contrib module may supply a trigger for a core module by giving the core module's name as the key. For example, you could use the 'node' key to add a node-related trigger.
    • Within each module, each individual trigger is keyed by a hook name describing the particular trigger (this is not visible to the user, but can be used by your module for identification).
      • Each trigger is described by an associative array. Currently, the only key-value pair is 'label', which contains a translated human-readable description of the triggering event. For example, the trigger set for the 'node' module has 'node' as the outermost key and defines triggers for 'node_insert', 'node_update', 'node_delete' etc. that fire when a node is saved, updated, etc.
See Also
hook_action_info()
hook_trigger_info_alter()

Definition at line 42 of file trigger.api.php.

References t().

hook_trigger_info_alter ( & $triggers )

Alter triggers declared by hook_trigger_info().

Parameters
$triggers Array of trigger information returned by hook_trigger_info() implementations. Modify this array in place. See hook_trigger_info() for information on what this might contain.

Definition at line 72 of file trigger.api.php.

References t().

hook_uninstall ( )

Remove any information that the module sets.

The information that the module should remove includes:

  • variables that the module has set using variable_set() or system_settings_form()
  • modifications to existing tables

The module should not remove its entry from the {system} table. Database tables defined by hook_schema() will be removed automatically.

The uninstall hook must be implemented in the module's .install file. It will fire when the module gets uninstalled but before the module's database tables are removed, allowing your module to query its own tables during this routine.

When hook_uninstall() is called, your module will already be disabled, so its .module file will not be automatically included. If you need to call API functions from your .module file in this hook, use drupal_load() to make them available. (Keep this usage to a minimum, though, especially when calling API functions that invoke hooks, or API functions from modules listed as dependencies, since these may not be available or work as expected when the module is disabled.)

See Also
hook_install()
hook_schema()
hook_disable()
hook_modules_uninstalled()

Definition at line 3544 of file system.api.php.

References variable_del().

hook_update_dependencies ( )

Return an array of information about module update dependencies.

This can be used to indicate update functions from other modules that your module's update functions depend on, or vice versa. It is used by the update system to determine the appropriate order in which updates should be run, as well as to search for missing dependencies.

Implementations of this hook should be placed in a mymodule.install file in the same directory as mymodule.module.

Returns
A multidimensional array containing information about the module update dependencies. The first two levels of keys represent the module and update number (respectively) for which information is being returned, and the value is an array of information about that update's dependencies. Within this array, each key represents a module, and each value represents the number of an update function within that module. In the event that your update function depends on more than one update from a particular module, you should always list the highest numbered one here (since updates within a given module always run in numerical order).
See Also
update_resolve_dependencies()
hook_update_N()

Definition at line 3474 of file system.api.php.

hook_update_last_removed ( )

Return a number which is no longer available as hook_update_N().

If you remove some update functions from your mymodule.install file, you should notify Drupal of those missing functions. This way, Drupal can ensure that no update is accidentally skipped.

Implementations of this hook should be placed in a mymodule.install file in the same directory as mymodule.module.

Returns
An integer, corresponding to hook_update_N() which has been removed from mymodule.install.
See Also
hook_update_N()

Definition at line 3510 of file system.api.php.

hook_update_N ( & $sandbox )

Perform a single update.

For each change that requires one or more actions to be performed when updating a site, add a new hook_update_N(), which will be called by update.php. The documentation block preceding this function is stripped of newlines and used as the description for the update on the pending updates task list. Schema updates should adhere to the Schema API.

Implementations of hook_update_N() are named (module name)_update_(number). The numbers are composed of three parts:

  • 1 digit for Drupal core compatibility.
  • 1 digit for your module's major release version (e.g., is this the 7.x-1.* (1) or 7.x-2.* (2) series of your module?). This digit should be 0 for initial porting of your module to a new Drupal core API.
  • 2 digits for sequential counting, starting with 00.

Examples:

  • mymodule_update_7000(): This is the required update for mymodule to run with Drupal core API 7.x when upgrading from Drupal core API 6.x.
  • mymodule_update_7100(): This is the first update to get the database ready to run mymodule 7.x-1.*.
  • mymodule_update_7200(): This is the first update to get the database ready to run mymodule 7.x-2.*. Users can directly update from 6.x-2.* to 7.x-2.* and they get all 70xx and 72xx updates, but not 71xx updates, because those reside in the 7.x-1.x branch only.

A good rule of thumb is to remove updates older than two major releases of Drupal. See hook_update_last_removed() to notify Drupal about the removals. For further information about releases and release numbers see: Maintaining a drupal.org project with Git

Never renumber update functions.

Implementations of this hook should be placed in a mymodule.install file in the same directory as mymodule.module. Drupal core's updates are implemented using the system module as a name and stored in database/updates.inc.

Not all module functions are available from within a hook_update_N() function. In order to call a function from your mymodule.module or an include file, you need to explicitly load that file first.

During database updates the schema of any module could be out of date. For this reason, caution is needed when using any API function within an update function - particularly CRUD functions, functions that depend on the schema (for example by using drupal_write_record()), and any functions that invoke hooks. See Update versions of API functions for details.

If your update task is potentially time-consuming, you'll need to implement a multipass update to avoid PHP timeouts. Multipass updates use the $sandbox parameter provided by the batch API (normally, $context['sandbox']) to store information between successive calls, and the $sandbox['#finished'] value to provide feedback regarding completion level.

See the batch operations page for more information on how to use the Batch API.

Parameters
$sandbox Stores information for multipass updates. See above for more information.
Exceptions
DrupalUpdateException,PDOException In case of error, update hooks should throw an instance of DrupalUpdateException with a meaningful message for the user. If a database query fails for whatever reason, it will throw a PDOException.
Returns
Optionally, update hooks may return a translated string that will be displayed to the user after the update has completed. If no message is returned, no message will be presented to the user.
See Also
Batch operations
Schema API
Update versions of API functions
hook_update_last_removed()
update_get_update_list()

Definition at line 3402 of file system.api.php.

References db_add_field(), db_query(), db_select(), db_update(), and t().

hook_update_projects_alter ( & $projects )

Alter the list of projects before fetching data and comparing versions.

Most modules will never need to implement this hook. It is for advanced interaction with the Update Manager module. The primary use-case for this hook is to add projects to the list; for example, to provide update status data on disabled modules and themes. A contributed module might want to hide projects from the list; for example, if there is a site-specific module that doesn't have any official releases, that module could remove itself from this list to avoid "No available releases found" warnings on the available updates report. In rare cases, a module might want to alter the data associated with a project already in the list.

Parameters
$projects Reference to an array of the projects installed on the system. This includes all the metadata documented in the comments below for each project (either module or theme) that is currently enabled. The array is initially populated inside update_get_projects() with the help of _update_process_info_list(), so look there for examples of how to populate the array with real values.
See Also
update_get_projects()
_update_process_info_list()

Definition at line 37 of file update.api.php.

hook_update_status_alter ( & $projects )

Alter the information about available updates for projects.

Parameters
$projects Reference to an array of information about available updates to each project installed on the system.
See Also
update_calculate_project_data()

Definition at line 85 of file update.api.php.

References t(), UPDATE_NOT_CHECKED, and variable_get().

hook_updater_info ( )

Provide information on Updaters (classes that can update Drupal).

An Updater is a class that knows how to update various parts of the Drupal file system, for example to update modules that have newer releases, or to install a new theme.

Returns
An associative array of information about the updater(s) being provided. This array is keyed by a unique identifier for each updater, and the values are subarrays that can contain the following keys:
  • class: The name of the PHP class which implements this updater.
  • name: Human-readable name of this updater.
  • weight: Controls what order the Updater classes are consulted to decide which one should handle a given task. When an update task is being run, the system will loop through all the Updater classes defined in this registry in weight order and let each class respond to the task and decide if each Updater wants to handle the task. In general, this doesn't matter, but if you need to override an existing Updater, make sure your Updater has a lighter weight so that it comes first.
See Also
drupal_get_updaters()
hook_updater_info_alter()

Definition at line 4578 of file system.api.php.

References t().

hook_updater_info_alter ( & $updaters )

Alter the Updater information array.

An Updater is a class that knows how to update various parts of the Drupal file system, for example to update modules that have newer releases, or to install a new theme.

Parameters
array $updaters Associative array of updaters as defined through hook_updater_info(). Alter this array directly.
See Also
drupal_get_updaters()
hook_updater_info()

Definition at line 4607 of file system.api.php.

hook_url_inbound_alter | ( | & | $path,
 |  |  | $original_path,
 |  |  | $path_language
 | ) |  |

Alters inbound URL requests.

Parameters
$path | The path being constructed, which, if a path alias, has been resolved to a Drupal path by the database, and which also may have been altered by other modules before this one.
$original_path | The original path, before being checked for path aliases or altered by any modules.
$path_language | The language of the path.
See Also
drupal_get_normal_path()

Definition at line 4223 of file system.api.php.

hook_url_outbound_alter | ( | & | $path,
 |  | & | $options,
 |  |  | $original_path
 | ) |  |

Alters outbound URLs.

Parameters
$path | The outbound path to alter, not adjusted for path aliases yet. It won't be adjusted for path aliases until all modules are finished altering it, thus being consistent with hook_url_inbound_alter(), which adjusts for all path aliases before allowing modules to alter it. This may have been altered by other modules before this one.
$options | A set of URL options for the URL so elements such as a fragment or a query string can be added to the URL.
$original_path | The original path, before being altered by any modules.
See Also
url()

Definition at line 4248 of file system.api.php.

hook_user_cancel | ( | $edit,
 |  | $account,
 |  | $method
 | ) |

Act on user account cancellations.

This hook is invoked from user_cancel() before a user account is canceled. Depending on the account cancellation method, the module should either do nothing, unpublish content, or anonymize content. See user_cancel_methods() for the list of default account cancellation methods provided by User module. Modules may add further methods via hook_user_cancel_methods_alter().

This hook is NOT invoked for the 'user_cancel_delete' account cancellation method. To react on this method, implement hook_user_delete() instead.

Expensive operations should be added to the global account cancellation batch by using batch_set().

Parameters
$edit | The array of form values submitted by the user.
$account | The user object on which the operation is being performed.
$method | The account cancellation method.
See Also
user_cancel_methods()
hook_user_cancel_methods_alter()

Definition at line 78 of file user.api.php.

References db_delete(), db_select(), db_update(), module_load_include(), and node_mass_update().

hook_user_cancel_methods_alter ( & $methods )

Modify account cancellation methods.

By implementing this hook, modules are able to add, customize, or remove account cancellation methods. All defined methods are turned into radio button form elements by user_cancel_methods() after this hook is invoked. The following properties can be defined for each method:

  • title: The radio button's title.
  • description: (optional) A description to display on the confirmation form if the user is not allowed to select the account cancellation method. The description is NOT used for the radio button, but instead should provide additional explanation to the user seeking to cancel their account.
  • access: (optional) A boolean value indicating whether the user can access a method. If #access is defined, the method cannot be configured as default method.
Parameters
$methods An array containing user account cancellation methods, keyed by method id.
See Also
user_cancel_methods()
user_cancel_confirm_form()

Definition at line 135 of file user.api.php.

References t(), and user_access().

hook_user_categories ( )

Retrieve a list of user setting or profile information categories.

Returns
An array of associative arrays. Each inner array has elements:
  • "name": The internal name of the category.
  • "title": The human-readable, localized name of the category.
  • "weight": An integer specifying the category's sort ordering.
  • "access callback": Name of the access callback function to use to determine whether the user can edit the category. Defaults to using user_edit_access(). See hook_menu() for more information on access callbacks.
  • "access arguments": Arguments for the access callback function. Defaults to array(1).

Definition at line 200 of file user.api.php.

References t().

hook_user_delete ( $account )

Respond to user deletion.

This hook is invoked from user_delete_multiple() before field_attach_delete() is called and before users are actually removed from the database.

Modules should additionally implement hook_user_cancel() to process stored user data for other account cancellation methods.

Parameters
$account The account that is being deleted.
See Also
user_delete_multiple()

Definition at line 47 of file user.api.php.

References db_delete().

hook_user_insert | ( | & | $edit,
 |  |  | $account,
 |  |  | $category
 | ) |  |

A user account was created.

The module should save its custom additions to the user object into the database.

Parameters
$edit | The array of form values submitted by the user.
$account | The user object on which the operation is being performed.
$category | The active category of user information being edited.
See Also
hook_user_presave()
hook_user_update()

Definition at line 252 of file user.api.php.

References db_insert().

hook_user_load ( $users )

Act on user objects when loaded from the database.

Due to the static cache in user_load_multiple() you should not use this hook to modify the user properties returned by the {users} table itself since this may result in unreliable results when loading from cache.

Parameters
$users An array of user objects, indexed by uid.
See Also
user_load_multiple()
profile_user_load()

Definition at line 26 of file user.api.php.

References db_query().

hook_user_login | ( | & | $edit,
 |  |  | $account
 | ) |  |

The user just logged in.

Parameters
$edit | The array of form values submitted by the user.
$account | The user object on which the operation was just performed.

Definition at line 294 of file user.api.php.

References drupal_get_destination(), drupal_set_message(), t(), url(), and variable_get().

hook_user_logout ( $account )

The user just logged out.

Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the save operation is entirely completed and user_save() goes out of scope. You should not rely on data in the database at this time as it is not updated yet. You should also note that any write/update database queries executed from this hook are also not committed immediately. Check user_save() and db_transaction() for more info.

Parameters
$account The user object on which the operation was just performed.

Definition at line 315 of file user.api.php.

References db_insert().

hook_user_operations ( )

Add mass user operations.

This hook enables modules to inject custom operations into the mass operations dropdown found at admin/people, by associating a callback function with the operation, which is called when the form is submitted. The callback function receives one initial argument, which is an array of the checked users.

Returns
An array of operations. Each operation is an associative array that may contain the following key-value pairs:
  • "label": Required. The label for the operation, displayed in the dropdown menu.
  • "callback": Required. The function to call for the operation.
  • "callback arguments": Optional. An array of additional arguments to pass to the callback function.

Definition at line 168 of file user.api.php.

References t().

hook_user_presave | ( | & | $edit,
 |  |  | $account,
 |  |  | $category
 | ) |  |

A user account is about to be created or updated.

This hook is primarily intended for modules that want to store properties in the serialized {users}.data column, which is automatically loaded whenever a user account object is loaded, modules may add to $edit['data'] in order to have their data serialized on save.

Parameters
$edit | The array of form values submitted by the user. Assign values to this array to save changes in the database.
$account | The user object on which the operation is performed. Values assigned in this object will not be saved in the database.
$category | The active category of user information being edited.
See Also
hook_user_insert()
hook_user_update()

Definition at line 228 of file user.api.php.

hook_user_role_delete ( $role )

Inform other modules that a user role has been deleted.

This hook allows you act when a user role has been deleted. If your module stores references to roles, it's recommended that you implement this hook and delete existing instances of the deleted role in your module database tables.

Parameters
$role The $role object being deleted.

Definition at line 460 of file user.api.php.

References db_delete().

hook_user_role_insert ( $role )

Inform other modules that a user role has been added.

Modules implementing this hook can act on the user role object when saved to the database. It's recommended that you implement this hook if your module adds additional data to user roles object. The module should save its custom additions to the database.

Parameters
$role A user role object.

Definition at line 418 of file user.api.php.

References db_insert().

hook_user_role_presave ( $role )

Inform other modules that a user role is about to be saved.

Modules implementing this hook can act on the user role object before it has been saved to the database.

Parameters
$role A user role object.
See Also
hook_user_role_insert()
hook_user_role_update()

Definition at line 400 of file user.api.php.

hook_user_role_update ( $role )

Inform other modules that a user role has been updated.

Modules implementing this hook can act on the user role object when updated. It's recommended that you implement this hook if your module adds additional data to user roles object. The module should save its custom additions to the database.

Parameters
$role A user role object.

Definition at line 439 of file user.api.php.

References db_merge().

hook_user_update | ( | & | $edit,
 |  |  | $account,
 |  |  | $category
 | ) |  |

A user account was updated.

Modules may use this hook to update their user data in a custom storage after a user account has been updated.

Parameters
$edit | The array of form values submitted by the user.
$account | The user object on which the operation is performed.
$category | The active category of user information being edited.
See Also
hook_user_presave()
hook_user_insert()

Definition at line 277 of file user.api.php.

References db_insert().

hook_user_view | ( | $account,
 |  | $view_mode,
 |  | $langcode
 | ) |

The user's account information is being displayed.

The module should format its custom additions for display and add them to the $account->content array.

Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the save operation is entirely completed and user_save() goes out of scope. You should not rely on data in the database at this time as it is not updated yet. You should also note that any write/update database queries executed from this hook are also not committed immediately. Check user_save() and db_transaction() for more info.

Parameters
$account | The user object on which the operation is being performed.
$view_mode | View mode, e.g. 'full'.
$langcode | The language code used for rendering.
See Also
hook_user_view_alter()
hook_entity_view()

Definition at line 348 of file user.api.php.

References format_username(), l(), t(), and user_access().

hook_user_view_alter ( & $build )

The user was built; the module may modify the structured content.

This hook is called after the content has been assembled in a structured array and may be used for doing processing which requires that the complete user content structure has been built.

If the module wishes to act on the rendered HTML of the user rather than the structured content array, it may use this hook to add a #post_render callback. Alternatively, it could also implement hook_preprocess_user_profile(). See drupal_render() and theme() documentation respectively for details.

Parameters
$build A renderable array representing the user.
See Also
user_view()
hook_entity_view_alter()

Definition at line 377 of file user.api.php.

hook_username_alter | ( | & | $name,
 |  |  | $account
 | ) |  |

Alter the username that is displayed for a user.

Called by format_username() to allow modules to alter the username that's displayed. Can be used to ensure user privacy in situations where $account->name is too revealing.

Parameters
$name | The string that format_username() will return.
$account | The account object passed to format_username().
See Also
format_username()

Definition at line 4279 of file system.api.php.

References $name, and t().

hook_watchdog ( array $log_entry )

Log an event message.

This hook allows modules to route log events to custom destinations, such as SMS, Email, pager, syslog, ...etc.

Parameters
$log_entry An associative array containing the following keys:
  • type: The type of message for this entry.
  • user: The user object for the user who was logged in when the event happened.
  • uid: The user ID for the user who was logged in when the event happened.
  • request_uri: The request URI for the page the event happened in.
  • referer: The page that referred the user to the page where the event occurred.
  • ip: The IP address where the request for the page came from.
  • timestamp: The UNIX timestamp of the date/time the event occurred.
  • severity: The severity of the message; one of the following values as defined in RFC 3164:
    • WATCHDOG_EMERGENCY: Emergency, system is unusable.
    • WATCHDOG_ALERT: Alert, action must be taken immediately.
    • WATCHDOG_CRITICAL: Critical conditions.
    • WATCHDOG_ERROR: Error conditions.
    • WATCHDOG_WARNING: Warning conditions.
    • WATCHDOG_NOTICE: Normal but significant conditions.
    • WATCHDOG_INFO: Informational messages.
    • WATCHDOG_DEBUG: Debug-level messages.
  • link: An optional link provided by the module that called the watchdog() function.
  • message: The text of the message to be logged. Variables in the message are indicated by using placeholder strings alongside the variables argument to declare the value of the placeholders. See t() for documentation on how the message and variable parameters interact.
  • variables: An array of variables to be inserted into the message on display. Will be NULL or missing if a message is already translated or if the message is not possible to translate.

Definition at line 2438 of file system.api.php.

References $base_url, drupal_mail(), format_date(), name, t(), variable_get(), WATCHDOG_ALERT, WATCHDOG_CRITICAL, WATCHDOG_DEBUG, WATCHDOG_EMERGENCY, WATCHDOG_ERROR, WATCHDOG_INFO, WATCHDOG_NOTICE, and WATCHDOG_WARNING.

hook_xmlrpc ( )

Register XML-RPC callbacks.

This hook lets a module register callback functions to be called when particular XML-RPC methods are invoked by a client.

Returns
An array which maps XML-RPC methods to Drupal functions. Each array element is either a pair of method => function or an array with four entries:
  • The XML-RPC method name (for example, module.function).
  • The Drupal callback function (for example, module_function).
  • The method signature is an array of XML-RPC types. The first element of this array is the type of return value and then you should write a list of the types of the parameters. XML-RPC types are the following (See the types at http://www.xmlrpc.com/spec):
    • "boolean": 0 (false) or 1 (true).
    • "double": a floating point number (for example, -12.214).
    • "int": a integer number (for example, -12).
    • "array": an array without keys (for example, array(1, 2, 3)).
    • "struct": an associative array or an object (for example, array('one' => 1, 'two' => 2)).
    • "date": when you return a date, then you may either return a timestamp (time(), mktime() etc.) or an ISO8601 timestamp. When date is specified as an input parameter, then you get an object, which is described in the function xmlrpc_date
    • "base64": a string containing binary data, automatically encoded/decoded automatically.
    • "string": anything else, typically a string.
  • A descriptive help string, enclosed in a t() function for translation purposes. Both forms are shown in the example.

Definition at line 2356 of file system.api.php.

References t().

hook_xmlrpc_alter ( & $methods )

Alters the definition of XML-RPC methods before they are called.

This hook allows modules to modify the callback definition of declared XML-RPC methods, right before they are invoked by a client. Methods may be added, or existing methods may be altered.

Note that hook_xmlrpc() supports two distinct and incompatible formats to define a callback, so care must be taken when altering other methods.

Parameters
$methods An asssociative array of method callback definitions, as returned from hook_xmlrpc() implementations.
See Also
hook_xmlrpc()
xmlrpc_server()

Definition at line 2384 of file system.api.php.

module_hook | ( | $module,
 |  | $hook
 | ) |

Determines whether a module implements a hook.

Parameters
$module | The name of the module (without the .module extension).
$hook | The name of the hook (e.g. "help" or "menu").
Returns
TRUE if the module is both installed and enabled, and the hook is implemented in that module.

Definition at line 659 of file module.inc.

References $module, module_hook_info(), and module_load_include().

Referenced by drupal_check_module(), field_help(), field_system_info_alter(), help_page(), module_disable(), module_invoke(), node_hook(), and system_get_module_admin_tasks().

module_hook_info ( )

Retrieves a list of hooks that are declared through hook_hook_info().

Returns
An associative array whose keys are hook names and whose values are an associative array containing a group name. The structure of the array is the same as the return value of hook_hook_info().
See Also
hook_hook_info()

Definition at line 787 of file module.inc.

References $module, cache_get(), cache_set(), drupal_bootstrap(), DRUPAL_BOOTSTRAP_FULL, drupal_static(), and module_list().

Referenced by module_hook(), and module_implements().

module_implements | ( | $hook,
 |  | $sort = FALSE,
 |  | $reset = FALSE
 | ) |

Determines which modules are implementing a hook.

Parameters
$hook | The name of the hook (e.g. "help" or "menu").
$sort | By default, modules are ordered by weight and filename, settings this option to TRUE, module list will be ordered by module name.
$reset | For internal use only: Whether to force the stored list of hook implementations to be regenerated (such as after enabling a new module, before processing hook_enable).
Returns
An array with the names of the modules which are implementing this hook.
See Also
module_implements_write_cache()

Definition at line 694 of file module.inc.

References $module, cache_clear_all(), cache_get(), cache_set(), drupal_alter(), drupal_static(), drupal_static_reset(), module_hook_info(), module_list(), and module_load_include().

Referenced by _block_rehash(), _block_render_blocks(), _field_info_collate_types(), _node_query_node_access_alter(), _node_types_build(), _rdf_get_default_mapping(), _registry_update(), _system_update_bootstrap_status(), _theme_build_registry(), aggregator_admin_form(), DrupalDefaultEntityController\attachLoad(), block_form_system_performance_settings_alter(), drupal_alter(), drupal_cron_run(), drupal_get_complete_schema(), drupal_get_filetransfer_info(), drupal_get_normal_path(), drupal_render_page(), field_access(), field_attach_form(), field_attach_insert(), field_attach_load(), field_attach_submit(), field_attach_update(), field_attach_validate(), field_help(), field_purge_data(), field_update_field(), file_download(), file_file_download(), filter_get_filters(), help_links_as_list(), help_menu(), image_effect_definitions(), image_styles(), menu_get_active_help(), menu_router_build(), module_disable(), module_enable(), module_invoke_all(), node_access(), node_access_rebuild(), node_access_view_all_nodes(), node_access_write_grants(), node_form_submit_build_node(), node_modules_enabled(), node_requirements(), node_validate(), rdf_install(), shortcut_set_delete_form(), system_install(), system_modules(), DrupalWebTestCase\tearDown(), user_admin_permissions(), user_filters(), user_module_invoke(), user_permission_get_modules(), and watchdog().

module_implements_write_cache ( )

Writes the hook implementation cache.

See Also
module_implements()

Definition at line 835 of file module.inc.

References cache_set(), and drupal_static().

Referenced by drupal_page_footer().

module_invoke | ( | $module,
 |  | $hook
 | ) |

Invokes a hook in a particular module.

All arguments are passed by value. Use drupal_alter() if you need to pass arguments by reference.

Parameters
$module | The name of the module (without the .module extension).
$hook | The name of the hook to invoke.
... Arguments to pass to the hook implementation.
Returns
The return value of the hook implementation.
See Also
drupal_alter()

Definition at line 861 of file module.inc.

References $module, and module_hook().

Referenced by _block_rehash(), _block_render_blocks(), _field_info_collate_types(), _node_types_build(), _options_get_options(), _rdf_get_default_mapping(), _update_7000_field_create_field(), aggregator_admin_form(), aggregator_form_aggregator_admin_form_alter(), aggregator_refresh(), block_admin_configure(), block_admin_configure_submit(), block_form_user_profile_form_alter(), bootstrap_invoke_all(), dashboard_page_build(), drupal_check_module(), drupal_cron_run(), drupal_get_complete_schema(), drupal_get_library(), drupal_get_schema_unprocessed(), drupal_install_system(), drupal_uninstall_modules(), field_associate_fields(), field_attach_delete(), field_attach_delete_revision(), field_attach_insert(), field_attach_load(), field_attach_update(), field_create_field(), field_delete_field(), field_delete_instance(), field_purge_data(), field_purge_field(), field_purge_instance(), field_read_fields(), field_ui_display_overview_form(), field_ui_field_edit_form(), field_ui_field_settings_form(), field_update_7001(), field_update_field(), file_file_download(), filter_get_filters(), help_links_as_list(), help_page(), hook_search_execute(), image_effect_definitions(), image_styles(), module_disable(), module_enable(), node_filter_form(), node_filters(), node_search_execute(), path_admin_overview(), FieldInfo\prepareField(), search_admin_settings(), system_get_module_admin_tasks(), system_modules(), update_get_update_list(), user_admin_permissions(), user_modules_installed(), user_permission_get_modules(), and watchdog().

module_invoke_all ( $hook )

Invokes a hook in all enabled modules that implement it.

All arguments are passed by value. Use drupal_alter() if you need to pass arguments by reference.

Parameters
$hook The name of the hook to invoke.
... Arguments to pass to the hook.
Returns
An array of return values of the hook implementations. If modules return arrays from their implementations, those are merged into one array.
See Also
drupal_alter()

Definition at line 887 of file module.inc.

References $module, and module_implements().

Referenced by _drupal_bootstrap_full(), _locale_translate_seek(), _menu_delete_item(), _node_index_node(), _node_rankings(), _simpletest_batch_finished(), _simpletest_batch_operation(), _system_rebuild_theme_data(), _trigger_get_all_info(), _user_categories(), actions_delete(), actions_list(), aggregator_remove(), ajax_footer(), archiver_get_info(), DrupalWebTestCase\checkPermissions(), comment_build_content(), comment_delete_multiple(), comment_save(), dashboard_region_descriptions(), EntityExampleBasicController\delete_multiple(), drupal_cron_run(), drupal_exit(), drupal_flush_all_caches(), drupal_get_updaters(), drupal_page_footer(), drupal_retrieve_form(), drupal_uninstall_modules(), element_info(), entity_example_basic_view(), entity_get_info(), entity_prepare_view(), field_attach_create_bundle(), field_attach_delete(), field_attach_delete_bundle(), field_attach_delete_revision(), field_attach_insert(), field_attach_load(), field_attach_presave(), field_attach_rename_bundle(), field_attach_update(), field_create_field(), field_create_instance(), field_delete_field(), field_delete_instance(), field_info_max_weight(), field_purge_field(), field_purge_instance(), field_read_fields(), field_read_instances(), field_update_field(), field_update_instance(), file_copy(), file_delete(), file_get_stream_wrappers(), file_move(), file_save(), file_validate(), filter_format_disable(), filter_format_save(), FieldInfo\getBundleExtraFields(), hook_search_admin(), hook_search_execute(), hook_update_index(), image_file_download(), image_get_available_toolkits(), image_style_delete(), image_style_deliver(), image_style_flush(), image_style_save(), language_negotiation_info(), language_types_info(), locale_add_language(), locale_languages_delete_form_submit(), locale_languages_overview_form_submit(), locale_translate_export_po_form(), locale_translate_export_pot_form(), locale_translate_import_form(), locale_translate_overview_screen(), locale_translation_filters(), menu_delete(), menu_get_custom_theme(), menu_link_save(), menu_save(), module_disable(), module_enable(), node_access(), node_access_acquire_grants(), node_access_grants(), node_admin_nodes(), node_admin_nodes_submit(), node_build_content(), node_delete_multiple(), node_object_prepare(), node_revision_delete(), node_save(), node_search_admin(), node_search_execute(), node_type_delete(), node_type_reset(), node_type_save(), openid_authentication(), openid_authentication_request(), openid_discovery(), openid_normalize(), overlay_set_mode(), path_delete(), path_get_admin_paths(), path_save(), rdf_get_namespaces(), EntityExampleBasicController\save(), shortcut_default_set(), simpletest_run_tests(), standard_install(), system_cron(), system_status(), taxonomy_term_build_content(), taxonomy_term_delete(), taxonomy_term_save(), taxonomy_vocabulary_delete(), taxonomy_vocabulary_save(), theme_disable(), theme_enable(), token_generate(), token_info(), trigger_assign(), update_check_requirements(), update_manager_archive_verify(), user_admin_account(), user_admin_account_submit(), user_build_content(), user_cancel(), user_delete_multiple(), user_logout(), user_role_delete(), user_role_save(), and user_save().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Callbacks

  • Modules
  • Namespaces
  • Classes
  • Files
Functions
Callbacks
Hooks

Functions

callback_filter_settings ($form, &$form_state, $filter, $format, $defaults, $filters)
callback_filter_prepare ($text, $filter, $format, $langcode, $cache, $cache_id)
callback_filter_process ($text, $filter, $format, $langcode, $cache, $cache_id)
callback_filter_tips ($filter, $format, $long)
callback_entity_info_uri ($entity)
callback_entity_info_label ($entity, $entity_type)
callback_entity_info_language ($entity, $entity_type)

Detailed Description

Callback function signatures.

Drupal's API sometimes uses callback functions to allow you to define how some type of processing happens. A callback is a function with a defined signature, which you define in a module. Then you pass the function name as a parameter to a Drupal API function or return it as part of a hook implementation return value, and your function is called at an appropriate time. For instance, when setting up batch processing you might need to provide a callback function for each processing step and/or a callback for when processing is finished; you would do that by defining these functions and passing their names into the batch setup function.

Callback function signatures, like hook definitions, are described by creating and documenting dummy functions in a *.api.php file; normally, the dummy callback function's name should start with "callback_", and you should document the parameters and return value and provide a sample function body. Then your API documentation can refer to this callback function in its documentation. A user of your API can usually name their callback function anything they want, although a standard name would be to replace "callback_" with the module name.

See Also
Hooks
Default theme implementations

End of "addtogroup hooks".

Function Documentation

callback_entity_info_label | ( | $entity,
 |  | $entity_type
 | ) |

Return the label of an entity.

Callback for hook_entity_info().

Parameters
$entity | The entity for which to generate the label.
$entity_type | The entity type; e.g., 'node' or 'user'.
Returns
An unsanitized string with the label of the entity.
See Also
entity_label()

Definition at line 4760 of file system.api.php.

callback_entity_info_language | ( | $entity,
 |  | $entity_type
 | ) |

Return the language code of the entity.

Callback for hook_entity_info().

The language callback is meant to be used primarily for temporary alterations of the property value.

Parameters
$entity | The entity for which to return the language.
$entity_type | The entity type; e.g., 'node' or 'user'.
Returns
The language code for the language of the entity.
See Also
entity_language()

Definition at line 4782 of file system.api.php.

callback_entity_info_uri ( $entity )

Return the URI for an entity.

Callback for hook_entity_info().

Parameters
$entity The entity to return the URI for.
Returns
An associative array with the following elements:
  • 'path': The URL path for the entity.
  • 'options': (optional) An array of options for the url() function. The actual entity URI can be constructed by passing these elements to url().

Definition at line 4739 of file system.api.php.

callback_filter_prepare | ( | $text,
 |  | $filter,
 |  | $format,
 |  | $langcode,
 |  | $cache,
 |  | $cache_id
 | ) |

Provide prepared text with special characters escaped.

Callback for hook_filter_info().

See hook_filter_info() for a description of the filtering process. Filters should not use the 'prepare callback' step for anything other than escaping, because that would short-circuit the control the user has over the order in which filters are applied.

Parameters
$text | The text string to be filtered.
$filter | The filter object containing settings for the given format.
$format | The text format object assigned to the text to be filtered.
$langcode | The language code of the text to be filtered.
$cache | A Boolean indicating whether the filtered text is going to be cached in {cache_filter}.
$cache_id | The ID of the filtered text in {cache_filter}, if $cache is TRUE.
Returns
The prepared, escaped text.

Definition at line 203 of file filter.api.php.

callback_filter_process | ( | $text,
 |  | $filter,
 |  | $format,
 |  | $langcode,
 |  | $cache,
 |  | $cache_id
 | ) |

Provide text filtered to conform to the supplied format.

Callback for hook_filter_info().

See hook_filter_info() for a description of the filtering process. This step is where the filter actually transforms the text.

Parameters
$text | The text string to be filtered.
$filter | The filter object containing settings for the given format.
$format | The text format object assigned to the text to be filtered.
$langcode | The language code of the text to be filtered.
$cache | A Boolean indicating whether the filtered text is going to be cached in {cache_filter}.
$cache_id | The ID of the filtered text in {cache_filter}, if $cache is TRUE.
Returns
The filtered text.

Definition at line 236 of file filter.api.php.

callback_filter_settings | ( |  | $form,
 |  | & | $form_state,
 |  |  | $filter,
 |  |  | $format,
 |  |  | $defaults,
 |  |  | $filters
 | ) |  |

End of "addtogroup hooks". Provide a settings form for filter settings.

Callback for hook_filter_info().

This callback function is used to provide a settings form for filter settings, for filters that need settings on a per-text-format basis. This function should return the form elements for the settings; the filter module will take care of saving the settings in the database.

If the filter's behavior depends on an extensive list and/or external data (e.g. a list of smileys, a list of glossary terms), then the filter module can choose to provide a separate, global configuration page rather than per-text-format settings. In that case, the settings callback function should provide a link to the separate settings page.

Parameters
$form | The prepopulated form array of the filter administration form.
$form_state | The state of the (entire) configuration form.
$filter | The filter object containing the current settings for the given format, in $filter->settings.
$format | The format object being configured.
$defaults | The default settings for the filter, as defined in 'default settings' in hook_filter_info(). These should be combined with $filter->settings to define the form element defaults.
$filters | The complete list of filter objects that are enabled for the given format.
Returns
An array of form elements defining settings for the filter. Array keys should match the array keys in $filter->settings and $defaults.

Definition at line 162 of file filter.api.php.

References t().

callback_filter_tips | ( | $filter,
 |  | $format,
 |  | $long
 | ) |

Return help text for a filter.

Callback for hook_filter_info().

A filter's tips should be informative and to the point. Short tips are preferably one-liners.

Parameters
$filter | An object representing the filter.
$format | An object representing the text format the filter is contained in.
$long | Whether this callback should return a short tip to display in a form (FALSE), or whether a more elaborate filter tips should be returned for theme_filter_tips() (TRUE).
Returns
Translated text to display as a tip.

Definition at line 264 of file filter.api.php.

References t().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Field Types API

  • Files
Functions
Field Types API
Hooks

Functions

hook_field_info ()
hook_field_info_alter (&$info)
hook_field_schema ($field)
hook_field_load ($entity_type, $entities, $field, $instances, $langcode, &$items, $age)
hook_field_prepare_view ($entity_type, $entities, $field, $instances, $langcode, &$items)
hook_field_validate ($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
hook_field_presave ($entity_type, $entity, $field, $instance, $langcode, &$items)
hook_field_insert ($entity_type, $entity, $field, $instance, $langcode, &$items)
hook_field_update ($entity_type, $entity, $field, $instance, $langcode, &$items)
hook_field_storage_update_field ($field, $prior_field, $has_data)
hook_field_delete ($entity_type, $entity, $field, $instance, $langcode, &$items)
hook_field_delete_revision ($entity_type, $entity, $field, $instance, $langcode, &$items)
hook_field_prepare_translation ($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode)
hook_field_is_empty ($item, $field)
hook_field_settings_form ($field, $instance, $has_data)
hook_field_instance_settings_form ($field, $instance)
hook_field_widget_settings_form ($field, $instance)
hook_field_formatter_settings_form ($field, $instance, $view_mode, $form, &$form_state)
hook_field_formatter_settings_summary ($field, $instance, $view_mode)

Detailed Description

Define field types.

In the Field API, each field has a type, which determines what kind of data (integer, string, date, etc.) the field can hold, which settings it provides, and so on. The data type(s) accepted by a field are defined in hook_field_schema(); other basic properties of a field are defined in hook_field_info(). The other hooks below are called by the Field Attach API to perform field-type-specific actions.

The Field Types API also defines two kinds of pluggable handlers: widgets and formatters. Widgets specify how the field appears in edit forms, while formatters specify how the field appears in displayed entities.

A third kind of pluggable handlers, storage backends, is defined by the Field Storage API .

See Field API for information about the other parts of the Field API.

Function Documentation

hook_field_delete | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Define custom delete behavior for this module's field data.

This hook is invoked from field_attach_delete() on the module that defines a field, during the process of deleting an entity object (node, taxonomy term, etc.). It is invoked just before the data for this field on the particular entity object is deleted from field storage. Only field modules that are storing or tracking information outside the standard field storage mechanism need to implement this hook.

Parameters
$entity_type | The type of $entity.
$entity | The entity for the operation.
$field | The field structure for the operation.
$instance | The instance structure for $field on $entity's bundle.
$langcode | The language associated with $items.
$items | $entity->{$field['field_name']}[$langcode], or an empty array if unset.
See Also
hook_field_insert()
hook_field_update()

Definition at line 596 of file field.api.php.

References entity_extract_ids(), and file_field_delete_file().

hook_field_delete_revision | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Define custom revision delete behavior for this module's field types.

This hook is invoked just before the data is deleted from field storage in field_attach_delete_revision(), and will only be called for fieldable types that are versioned.

Parameters
$entity_type | The type of $entity.
$entity | The entity for the operation.
$field | The field structure for the operation.
$instance | The instance structure for $field on $entity's bundle.
$langcode | The language associated with $items.
$items | $entity->{$field['field_name']}[$langcode], or an empty array if unset.

Definition at line 629 of file field.api.php.

References entity_extract_ids(), and file_field_delete_file().

hook_field_formatter_settings_form | ( |  | $field,
 |  |  | $instance,
 |  |  | $view_mode,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Specify the form elements for a formatter's settings.

Parameters
$field | The field structure being configured.
$instance | The instance structure being configured.
$view_mode | The view mode being configured.
$form | The (entire) configuration form array, which will usually have no use here.
$form_state | The form state of the (entire) configuration form.
Returns
The form elements for the formatter settings.

Definition at line 151 of file field_ui.api.php.

References t().

hook_field_formatter_settings_summary | ( | $field,
 |  | $instance,
 |  | $view_mode
 | ) |

Return a short summary for the current formatter settings of an instance.

If an empty result is returned, the formatter is assumed to have no configurable settings, and no UI will be provided to display a settings form.

Parameters
$field | The field structure.
$instance | The instance structure.
$view_mode | The view mode for which a settings summary is requested.
Returns
A string containing a short summary of the formatter settings.

Definition at line 189 of file field_ui.api.php.

References t().

hook_field_info ( )

Define Field API field types.

Along with this hook, you also need to implement other hooks. See Field Types API for more information.

Returns
An array whose keys are field type names and whose values are arrays describing the field type, with the following key/value pairs:
  • label: The human-readable name of the field type.
  • description: A short description for the field type.
  • settings: An array whose keys are the names of the settings available for the field type, and whose values are the default values for those settings.
  • instance_settings: An array whose keys are the names of the settings available for instances of the field type, and whose values are the default values for those settings. Instance-level settings can have different values on each field instance, and thus allow greater flexibility than field-level settings. It is recommended to put settings at the instance level whenever possible. Notable exceptions: settings acting on the schema definition, or settings that Views needs to use across field instances (for example, the list of allowed values).
  • default_widget: The machine name of the default widget to be used by instances of this field type, when no widget is specified in the instance definition. This widget must be available whenever the field type is available (i.e. provided by the field type module, or by a module the field type module depends on).
  • default_formatter: The machine name of the default formatter to be used by instances of this field type, when no formatter is specified in the instance definition. This formatter must be available whenever the field type is available (i.e. provided by the field type module, or by a module the field type module depends on).
  • no_ui: (optional) A boolean specifying that users should not be allowed to create fields and instances of this field type through the UI. Such fields can only be created programmatically with field_create_field() and field_create_instance(). Defaults to FALSE.
See Also
hook_field_info_alter()

Definition at line 152 of file field.api.php.

References t().

hook_field_info_alter ( & $info )

Perform alterations on Field API field types.

Parameters
$info Array of information on field types exposed by hook_field_info() implementations.

Definition at line 188 of file field.api.php.

References $info.

hook_field_insert | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Define custom insert behavior for this module's field data.

This hook is invoked from field_attach_insert() on the module that defines a field, during the process of inserting an entity object (node, taxonomy term, etc.). It is invoked just before the data for this field on the particular entity object is inserted into field storage. Only field modules that are storing or tracking information outside the standard field storage mechanism need to implement this hook.

Parameters
$entity_type | The type of $entity.
$entity | The entity for the operation.
$field | The field structure for the operation.
$instance | The instance structure for $field on $entity's bundle.
$langcode | The language associated with $items.
$items | $entity->{$field['field_name']}[$langcode], or an empty array if unset.
See Also
hook_field_update()
hook_field_delete()

Definition at line 466 of file field.api.php.

References db_insert(), and variable_get().

hook_field_instance_settings_form | ( | $field,
 |  | $instance
 | ) |

Add settings to an instance field settings form.

Invoked from field_ui_field_edit_form() to allow the module defining the field to add settings for a field instance.

Parameters
$field | The field structure being configured.
$instance | The instance structure being configured.
Returns
The form definition for the field instance settings.

Definition at line 65 of file field_ui.api.php.

References t().

hook_field_is_empty | ( | $item,
 |  | $field
 | ) |

Define what constitutes an empty item for a field type.

Parameters
$item | An item that may or may not be empty.
$field | The field to which $item belongs.
Returns
TRUE if $field's type considers $item not to contain any data; FALSE otherwise.

Definition at line 683 of file field.api.php.

hook_field_load | ( |  | $entity_type,
 |  |  | $entities,
 |  |  | $field,
 |  |  | $instances,
 |  |  | $langcode,
 |  | & | $items,
 |  |  | $age
 | ) |  |

Define custom load behavior for this module's field types.

Unlike most other field hooks, this hook operates on multiple entities. The $entities, $instances and $items parameters are arrays keyed by entity ID. For performance reasons, information for all available entity should be loaded in a single query where possible.

Note that the changes made to the field values get cached by the field cache for subsequent loads. You should never use this hook to load fieldable entities, since this is likely to cause infinite recursions when hook_field_load() is run on those as well. Use hook_field_formatter_prepare_view() instead.

Make changes or additions to field values by altering the $items parameter by reference. There is no return value.

Parameters
$entity_type | The type of $entity.
$entities | Array of entities being loaded, keyed by entity ID.
$field | The field structure for the operation.
$instances | Array of instance structures for $field for each entity, keyed by entity ID.
$langcode | The language code associated with $items.
$items | Array of field values already loaded for the entities, keyed by entity ID. Store your changes in this parameter (passed by reference).
$age | FIELD_LOAD_CURRENT to load the most recent revision for all fields, or FIELD_LOAD_REVISION to load the version indicated by each entity.

Definition at line 308 of file field.api.php.

References _text_sanitize(), and filter_format_allowcache().

hook_field_prepare_translation | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items,
 |  |  | $source_entity,
 |  |  | $source_langcode
 | ) |  |

Define custom prepare_translation behavior for this module's field types.

Parameters
$entity_type | The type of $entity.
$entity | The entity for the operation.
$field | The field structure for the operation.
$instance | The instance structure for $field on $entity's bundle.
$langcode | The language associated to $items.
$items | $entity->{$field['field_name']}[$langcode], or an empty array if unset.
$source_entity | The source entity from which field values are being copied.
$source_langcode | The source language from which field values are being copied.

Definition at line 660 of file field.api.php.

References filter_formats().

hook_field_prepare_view | ( |  | $entity_type,
 |  |  | $entities,
 |  |  | $field,
 |  |  | $instances,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Prepare field values prior to display.

This hook is invoked before the field values are handed to formatters for display, and runs before the formatters' own hook_field_formatter_prepare_view().

Unlike most other field hooks, this hook operates on multiple entities. The $entities, $instances and $items parameters are arrays keyed by entity ID. For performance reasons, information for all available entities should be loaded in a single query where possible.

Make changes or additions to field values by altering the $items parameter by reference. There is no return value.

Parameters
$entity_type | The type of $entity.
$entities | Array of entities being displayed, keyed by entity ID.
$field | The field structure for the operation.
$instances | Array of instance structures for $field for each entity, keyed by entity ID.
$langcode | The language associated to $items.
$items | $entity->{$field['field_name']}, or an empty array if unset.

Definition at line 354 of file field.api.php.

References file_load().

hook_field_presave | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Define custom presave behavior for this module's field types.

Make changes or additions to field values by altering the $items parameter by reference. There is no return value.

Parameters
$entity_type | The type of $entity.
$entity | The entity for the operation.
$field | The field structure for the operation.
$instance | The instance structure for $field on $entity's bundle.
$langcode | The language associated with $items.
$items | $entity->{$field['field_name']}[$langcode], or an empty array if unset.

Definition at line 428 of file field.api.php.

hook_field_schema ( $field )

Define the Field API schema for a field structure.

This is invoked when a field is created, in order to obtain the database schema from the module that defines the field's type.

This hook must be defined in the module's .install file for it to be detected during installation and upgrade.

Parameters
$field A field structure.
Returns
An associative array with the following keys:
  • columns: An array of Schema API column specifications, keyed by column name. This specifies what comprises a value for a given field. For example, a value for a number field is simply 'value', while a value for a formatted text field is the combination of 'value' and 'format'. It is recommended to avoid having the column definitions depend on field settings when possible. No assumptions should be made on how storage engines internally use the original column name to structure their storage.
  • indexes: (optional) An array of Schema API indexes definitions. Only columns that appear in the 'columns' array are allowed. Those indexes will be used as default indexes. Callers of field_create_field() can specify additional indexes, or, at their own risk, modify the default indexes specified by the field-type module. Some storage engines might not support indexes.
  • foreign keys: (optional) An array of Schema API foreign keys definitions.

Definition at line 233 of file field.api.php.

hook_field_settings_form | ( | $field,
 |  | $instance,
 |  | $has_data
 | ) |

Add settings to a field settings form.

Invoked from field_ui_field_settings_form() to allow the module defining the field to add global settings (i.e. settings that do not depend on the bundle or instance) to the field settings form. If the field already has data, only include settings that are safe to change.

Parameters
$field | The field structure being configured.
$instance | The instance structure being configured.
$has_data | TRUE if the field already has data, FALSE if not.
Returns
The form definition for the field settings.

Definition at line 38 of file field_ui.api.php.

References t().

hook_field_storage_update_field | ( | $field,
 |  | $prior_field,
 |  | $has_data
 | ) |

Update the storage information for a field.

This is invoked on the field's storage module from field_update_field(), before the new field information is saved to the database. The field storage module should update its storage tables to agree with the new field information. If there is a problem, the field storage module should throw an exception.

Parameters
$field | The updated field structure to be saved.
$prior_field | The previously-saved field structure.
$has_data | TRUE if the field has data in storage currently.

Definition at line 550 of file field.api.php.

References $name, _field_sql_storage_schema(), db_create_table(), db_drop_table(), and drupal_get_schema().

hook_field_update | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Define custom update behavior for this module's field data.

This hook is invoked from field_attach_update() on the module that defines a field, during the process of updating an entity object (node, taxonomy term, etc.). It is invoked just before the data for this field on the particular entity object is updated into field storage. Only field modules that are storing or tracking information outside the standard field storage mechanism need to implement this hook.

Parameters
$entity_type | The type of $entity.
$entity | The entity for the operation.
$field | The field structure for the operation.
$instance | The instance structure for $field on $entity's bundle.
$langcode | The language associated with $items.
$items | $entity->{$field['field_name']}[$langcode], or an empty array if unset.
See Also
hook_field_insert()
hook_field_delete()

Definition at line 507 of file field.api.php.

References db_delete(), db_insert(), drupal_static(), and variable_get().

hook_field_validate | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  | & | $errors
 | ) |  |

Validate this module's field data.

If there are validation problems, add to the $errors array (passed by reference). There is no return value.

Parameters
$entity_type | The type of $entity.
$entity | The entity for the operation.
$field | The field structure for the operation.
$instance | The instance structure for $field on $entity's bundle.
$langcode | The language associated with $items.
$items | $entity->{$field['field_name']}[$langcode], or an empty array if unset.
$errors The array of errors (keyed by field name, language code, and delta) that have already been reported for the entity. The function should add its errors to this array. Each error is an associative array with the following keys and values:
  • error: An error code (should be a string prefixed with the module name).
  • message: The human readable message to be displayed.

Definition at line 396 of file field.api.php.

References drupal_strlen(), and t().

hook_field_widget_settings_form | ( | $field,
 |  | $instance
 | ) |

Add settings to a widget settings form.

Invoked from field_ui_field_edit_form() to allow the module defining the widget to add settings for a widget instance.

Parameters
$field | The field structure being configured.
$instance | The instance structure being configured.
Returns
The form definition for the widget settings.

Definition at line 107 of file field_ui.api.php.

References t().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Field Widget API

Functions
Field Widget API
Hooks

Functions

hook_field_widget_info ()
hook_field_widget_info_alter (&$info)
hook_field_widget_form (&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
hook_field_widget_form_alter (&$element, &$form_state, $context)
hook_field_widget_WIDGET_TYPE_form_alter (&$element, &$form_state, $context)
hook_field_widget_properties_alter (&$widget, $context)
hook_field_widget_error ($element, $error, $form, &$form_state)

Detailed Description

End of "defgroup field_types".

Define Field API widget types.

Field API widgets specify how fields are displayed in edit forms. Fields of a given field type may be edited using more than one widget. In this case, the Field UI module allows the site builder to choose which widget to use. Widget types are defined by implementing hook_field_widget_info().

Widgets are Form API elements with additional processing capabilities. Widget hooks are typically called by the Field Attach API during the creation of the field form structure with field_attach_form().

See Also
Field API
Field Types API
Field Formatter API

Function Documentation

hook_field_widget_error | ( |  | $element,
 |  |  | $error,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Flag a field-level validation error.

Parameters
$element | An array containing the form element for the widget. The error needs to be flagged on the right sub-element, according to the widget's internal structure.
$error An associative array with the following key-value pairs, as returned by hook_field_validate():
  • error: the error code. Complex widgets might need to report different errors to different form elements inside the widget.
  • message: the human readable message to be displayed.
$form | The form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form.
$form_state | An associative array containing the current state of the form.

Definition at line 1004 of file field.api.php.

References form_error().

hook_field_widget_form | ( | & | $form,
 |  | & | $form_state,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  |  | $delta,
 |  |  | $element
 | ) |  |

Return the form for a single field widget.

Field widget form elements should be based on the passed-in $element, which contains the base form element properties derived from the field configuration.

Field API will set the weight, field name and delta values for each form element. If there are multiple values for this field, the Field API will invoke this hook as many times as needed.

Note that, depending on the context in which the widget is being included (regular entity form, field configuration form, advanced search form...), the values for $field and $instance might be different from the "official" definitions returned by field_info_field() and field_info_instance(). Examples: mono-value widget even if the field is multi-valued, non-required widget even if the field is 'required'...

Therefore, the FAPI element callbacks (such as #process, #element_validate, #value_callback...) used by the widget cannot use the field_info_field() or field_info_instance() functions to retrieve the $field or $instance definitions they should operate on. The field_widget_field() and field_widget_instance() functions should be used instead to fetch the current working definitions from $form_state, where Field API stores them.

Alternatively, hook_field_widget_form() can extract the needed specific properties from $field and $instance and set them as ad-hoc $element['#custom'] properties, for later use by its element callbacks.

Other modules may alter the form element provided by this function using hook_field_widget_form_alter().

Parameters
$form | The form structure where widgets are being attached to. This might be a full form structure, or a sub-element of a larger form.
$form_state | An associative array containing the current state of the form.
$field | The field structure.
$instance | The field instance.
$langcode | The language associated with $items.
$items | Array of default values for this field.
$delta | The order of this item in the array of subelements (0, 1, 2, etc).
$element A form element array containing basic properties for the widget:
  • #entity_type: The name of the entity the field is attached to.
  • #bundle: The name of the field bundle the field is contained in.
  • #field_name: The name of the field.
  • language: The language the field is being edited in.
  • #field_parents: The 'parents' space for the field in the form. Most widgets can simply overlook this property. This identifies the location where the field values are placed within $form_state['values'], and is used to access processing information for the field through the field_form_get_state() and field_form_set_state() functions.
  • #columns: A list of field storage columns of the field.
  • title: The sanitized element label for the field instance, ready for output.
  • #description: The sanitized element description for the field instance, ready for output.
  • #required: A Boolean indicating whether the element value is required; for required multiple value fields, only the first widget's values are required.
  • #delta: The order of this item in the array of subelements; see $delta above.
Returns
The form elements for a single widget for this field.
See Also
field_widget_field()
field_widget_instance()
hook_field_widget_form_alter()
hook_field_widget_WIDGET_TYPE_form_alter()

Definition at line 883 of file field.api.php.

hook_field_widget_form_alter | ( | & | $element,
 |  | & | $form_state,
 |  |  | $context
 | ) |  |

Alter forms for field widgets provided by other modules.

Parameters
$element | The field widget form element as constructed by hook_field_widget_form().
$form_state | An associative array containing the current state of the form.
$context An associative array containing the following key-value pairs, matching the arguments received by hook_field_widget_form():
  • form: The form structure to which widgets are being attached. This may be a full form structure, or a sub-element of a larger form.
  • field: The field structure.
  • instance: The field instance structure.
  • langcode: The language associated with $items.
  • items: Array of default values for this field.
  • delta: The order of this item in the array of subelements (0, 1, 2, etc).
See Also
hook_field_widget_form()
hook_field_widget_WIDGET_TYPE_form_alter()

Definition at line 912 of file field.api.php.

hook_field_widget_info ( )

Expose Field API widget types.

Returns
An array describing the widget types implemented by the module. The keys are widget type names. To avoid name clashes, widget type names should be prefixed with the name of the module that exposes them. The values are arrays describing the widget type, with the following key/value pairs:
  • label: The human-readable name of the widget type.
  • description: A short description for the widget type.
  • field types: An array of field types the widget supports.
  • settings: An array whose keys are the names of the settings available for the widget type, and whose values are the default values for those settings.
  • behaviors: (optional) An array describing behaviors of the widget, with the following elements:
    • multiple values: One of the following constants:
      • FIELD_BEHAVIOR_DEFAULT: (default) If the widget allows the input of one single field value (most common case). The widget will be repeated for each value input.
      • FIELD_BEHAVIOR_CUSTOM: If one single copy of the widget can receive several field values. Examples: checkboxes, multiple select, comma-separated textfield.
    • default value: One of the following constants:
      • FIELD_BEHAVIOR_DEFAULT: (default) If the widget accepts default values.
      • FIELD_BEHAVIOR_NONE: if the widget does not support default values.
  • weight: (optional) An integer to determine the weight of this widget relative to other widgets in the Field UI when selecting a widget for a given field instance.
See Also
hook_field_widget_info_alter()
hook_field_widget_form()
hook_field_widget_form_alter()
hook_field_widget_WIDGET_TYPE_form_alter()
hook_field_widget_error()
hook_field_widget_settings_form()

Definition at line 754 of file field.api.php.

References FIELD_BEHAVIOR_DEFAULT, and t().

hook_field_widget_info_alter ( & $info )

Perform alterations on Field API widget types.

Parameters
$info Array of informations on widget types exposed by hook_field_widget_info() implementations.

Definition at line 795 of file field.api.php.

References $info.

hook_field_widget_properties_alter | ( | & | $widget,
 |  |  | $context
 | ) |  |

Alters the widget properties of a field instance before it gets displayed.

Note that instead of hook_field_widget_properties_alter(), which is called for all fields on all entity types, hook_field_widget_properties_ENTITY_TYPE_alter() may be used to alter widget properties for fields on a specific entity type only.

This hook is called once per field per added or edit entity. If the result of the hook involves reading from the database, it is highly recommended to statically cache the information.

Parameters
$widget The instance's widget properties.
$context An associative array containing:
  • entity_type: The entity type; e.g., 'node' or 'user'.
  • entity: The entity object.
  • field: The field that the widget belongs to.
  • instance: The instance of the field.
See Also
hook_field_widget_properties_ENTITY_TYPE_alter()

Definition at line 976 of file field.api.php.

hook_field_widget_WIDGET_TYPE_form_alter | ( | & | $element,
 |  | & | $form_state,
 |  |  | $context
 | ) |  |

Alter widget forms for a specific widget provided by another module.

Modules can implement hook_field_widget_WIDGET_TYPE_form_alter() to modify a specific widget form, rather than using hook_field_widget_form_alter() and checking the widget type.

Parameters
$element | The field widget form element as constructed by hook_field_widget_form().
$form_state | An associative array containing the current state of the form.
$context An associative array containing the following key-value pairs, matching the arguments received by hook_field_widget_form():
  • "form": The form structure where widgets are being attached to. This might be a full form structure, or a sub-element of a larger form.
  • "field": The field structure.
  • "instance": The field instance structure.
  • "langcode": The language associated with $items.
  • "items": Array of default values for this field.
  • "delta": The order of this item in the array of subelements (0, 1, 2, etc).
See Also
hook_field_widget_form()
hook_field_widget_form_alter()

Definition at line 946 of file field.api.php.

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Field Formatter API

Functions
Field Formatter API
Hooks

Functions

hook_field_formatter_info ()
hook_field_formatter_info_alter (&$info)
hook_field_formatter_prepare_view ($entity_type, $entities, $field, $instances, $langcode, &$items, $displays)
hook_field_formatter_view ($entity_type, $entity, $field, $instance, $langcode, $items, $display)

Detailed Description

End of "defgroup field_widget".

Define Field API formatter types.

Field API formatters specify how fields are displayed when the entity to which the field is attached is displayed. Fields of a given field type may be displayed using more than one formatter. In this case, the Field UI module allows the site builder to choose which formatter to use. Field formatters are defined by implementing hook_field_formatter_info().

See Also
Field API
Field Types API
Field Widget API

Function Documentation

hook_field_formatter_info ( )

Expose Field API formatter types.

Formatters handle the display of field values. Formatter hooks are typically called by the Field Attach API field_attach_prepare_view() and field_attach_view() functions.

Returns
An array describing the formatter types implemented by the module. The keys are formatter type names. To avoid name clashes, formatter type names should be prefixed with the name of the module that exposes them. The values are arrays describing the formatter type, with the following key/value pairs:
  • label: The human-readable name of the formatter type.
  • description: A short description for the formatter type.
  • field types: An array of field types the formatter supports.
  • settings: An array whose keys are the names of the settings available for the formatter type, and whose values are the default values for those settings.
See Also
hook_field_formatter_info_alter()
hook_field_formatter_view()
hook_field_formatter_prepare_view()

Definition at line 1055 of file field.api.php.

References t().

hook_field_formatter_info_alter ( & $info )

Perform alterations on Field API formatter types.

Parameters
$info An array of information on formatter types exposed by hook_field_formatter_info() implementations.

Definition at line 1094 of file field.api.php.

References $info.

hook_field_formatter_prepare_view | ( |  | $entity_type,
 |  |  | $entities,
 |  |  | $field,
 |  |  | $instances,
 |  |  | $langcode,
 |  | & | $items,
 |  |  | $displays
 | ) |  |

Allow formatters to load information for field values being displayed.

This should be used when a formatter needs to load additional information from the database in order to render a field, for example a reference field which displays properties of the referenced entities such as name or type.

This hook is called after the field type's own hook_field_prepare_view().

Unlike most other field hooks, this hook operates on multiple entities. The $entities, $instances and $items parameters are arrays keyed by entity ID. For performance reasons, information for all available entities should be loaded in a single query where possible.

Parameters
$entity_type | The type of $entity.
$entities | Array of entities being displayed, keyed by entity ID.
$field | The field structure for the operation.
$instances | Array of instance structures for $field for each entity, keyed by entity ID.
$langcode | The language the field values are to be shown in. If no language is provided the current language is used.
$items | Array of field values for the entities, keyed by entity ID.
$displays | Array of display settings to use for each entity, keyed by entity ID.
Returns
Changes or additions to field values are done by altering the $items parameter by reference.

Definition at line 1139 of file field.api.php.

References taxonomy_term_load_multiple().

hook_field_formatter_view | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance,
 |  | $langcode,
 |  | $items,
 |  | $display
 | ) |

Build a renderable array for a field value.

Parameters
$entity_type | The type of $entity.
$entity | The entity being displayed.
$field | The field structure.
$instance | The field instance.
$langcode | The language associated with $items.
$items | Array of values for this field.
$display The display settings to use, as found in the 'display' entry of instance definitions. The array notably contains the following keys and values;
  • type: The name of the formatter to use.
  • settings: The array of formatter settings.
Returns
A renderable array for the $items, as an array of child elements keyed by numeric indexes starting from 0.

Definition at line 1204 of file field.api.php.

References t().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Field Storage API

Functions | Variables
Field Storage API
Hooks

Functions

hook_field_storage_info ()
hook_field_storage_info_alter (&$info)
hook_field_storage_details ($field)
hook_field_storage_details_alter (&$details, $field)
hook_field_storage_load ($entity_type, $entities, $age, $fields, $options)
hook_field_storage_write ($entity_type, $entity, $op, $fields)
hook_field_storage_delete ($entity_type, $entity, $fields)
hook_field_storage_delete_revision ($entity_type, $entity, $fields)
hook_field_storage_query ($query)
hook_field_storage_create_field ($field)
hook_field_storage_delete_field ($field)
hook_field_storage_delete_instance ($instance)
hook_field_storage_pre_load ($entity_type, $entities, $age, &$skip_fields, $options)
hook_field_storage_pre_insert ($entity_type, $entity, &$skip_fields)
hook_field_storage_pre_update ($entity_type, $entity, &$skip_fields)
hook_field_info_max_weight ($entity_type, $bundle, $context)
hook_field_display_alter (&$display, $context)
hook_field_display_ENTITY_TYPE_alter (&$display, $context)
hook_field_extra_fields_display_alter (&$displays, $context)
hook_field_widget_properties_ENTITY_TYPE_alter (&$widget, $context)

Variables

const | FIELD_STORAGE_UPDATE 'update'
const | FIELD_STORAGE_INSERT 'insert'

Detailed Description

Implement a storage engine for Field API data.

The Field Attach API uses the Field Storage API to perform all "database access". Each Field Storage API hook function defines a primitive database operation such as read, write, or delete. The default field storage module, field_sql_storage.module, uses the local SQL database to implement these operations, but alternative field storage backends can choose to represent the data in SQL differently or use a completely different storage mechanism such as a cloud-based database.

Each field defines which storage backend it uses. The Drupal system variable 'field_storage_default' identifies the storage backend used by default.

See Field API for information about the other parts of the Field API.

End of "defgroup field_attach".

Function Documentation

hook_field_display_alter | ( | & | $display,
 |  |  | $context
 | ) |  |

Alters the display settings of a field before it gets displayed.

Note that instead of hook_field_display_alter(), which is called for all fields on all entity types, hook_field_display_ENTITY_TYPE_alter() may be used to alter display settings for fields on a specific entity type only.

This hook is called once per field per displayed entity. If the result of the hook involves reading from the database, it is highly recommended to statically cache the information.

Parameters
$display The display settings that will be used to display the field values, as found in the 'display' key of $instance definitions.
$context An associative array containing:
  • entity_type: The entity type; e.g., 'node' or 'user'.
  • field: The field being rendered.
  • instance: The instance being rendered.
  • entity: The entity being rendered.
  • view_mode: The view mode, e.g. 'full', 'teaser'...
See Also
hook_field_display_ENTITY_TYPE_alter()

Definition at line 2316 of file field.api.php.

hook_field_display_ENTITY_TYPE_alter | ( | & | $display,
 |  |  | $context
 | ) |  |

Alters the display settings of a field on a given entity type before it gets displayed.

Modules can implement hook_field_display_ENTITY_TYPE_alter() to alter display settings for fields on a specific entity type, rather than implementing hook_field_display_alter().

This hook is called once per field per displayed entity. If the result of the hook involves reading from the database, it is highly recommended to statically cache the information.

Parameters
$display The display settings that will be used to display the field values, as found in the 'display' key of $instance definitions.
$context An associative array containing:
  • entity_type: The entity type; e.g., 'node' or 'user'.
  • field: The field being rendered.
  • instance: The instance being rendered.
  • entity: The entity being rendered.
  • view_mode: The view mode, e.g. 'full', 'teaser'...
See Also
hook_field_display_alter()

Definition at line 2351 of file field.api.php.

hook_field_extra_fields_display_alter | ( | & | $displays,
 |  |  | $context
 | ) |  |

Alters the display settings of pseudo-fields before an entity is displayed.

This hook is called once per displayed entity. If the result of the hook involves reading from the database, it is highly recommended to statically cache the information.

Parameters
$displays An array of display settings for the pseudo-fields in the entity, keyed by pseudo-field names.
$context An associative array containing:
  • entity_type: The entity type; e.g., 'node' or 'user'.
  • bundle: The bundle name.
  • view_mode: The view mode, e.g. 'full', 'teaser'...

Definition at line 2374 of file field.api.php.

hook_field_info_max_weight | ( | $entity_type,
 |  | $bundle,
 |  | $context
 | ) |

Returns the maximum weight for the entity components handled by the module.

Field API takes care of fields and 'extra_fields'. This hook is intended for third-party modules adding other entity components (e.g. field_group).

Parameters
$entity_type | The type of entity; e.g. 'node' or 'user'.
$bundle | The bundle name.
$context | The context for which the maximum weight is requested. Either 'form', or the name of a view mode.
Returns
The maximum weight of the entity's components, or NULL if no components were found.

Definition at line 2282 of file field.api.php.

hook_field_storage_create_field ( $field )

Act on creation of a new field.

This hook is invoked from field_create_field() to ask the field storage module to save field information and prepare for storing field instances. If there is a problem, the field storage module should throw an exception.

Parameters
$field The field structure being created.

Definition at line 2079 of file field.api.php.

References $name, _field_sql_storage_schema(), db_create_table(), and drupal_get_schema().

hook_field_storage_delete | ( | $entity_type,
 |  | $entity,
 |  | $fields
 | ) |

Delete all field data for an entity.

This hook is invoked from field_attach_delete() to ask the field storage module to delete field data.

Parameters
$entity_type | The entity type of entity, such as 'node' or 'user'.
$entity | The entity on which to operate.
$fields | An array listing the fields to delete. The keys and values of the array are field IDs.

Definition at line 1908 of file field.api.php.

References entity_extract_ids(), field_info_field_by_id(), field_info_instances(), and field_sql_storage_field_storage_purge().

hook_field_storage_delete_field ( $field )

Act on deletion of a field.

This hook is invoked from field_delete_field() to ask the field storage module to mark all information stored in the field for deletion.

Parameters
$field The field being deleted.

Definition at line 2096 of file field.api.php.

References _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), db_rename_table(), db_update(), and drupal_get_schema().

hook_field_storage_delete_instance ( $instance )

Act on deletion of a field instance.

This hook is invoked from field_delete_instance() to ask the field storage module to mark all information stored for the field instance for deletion.

Parameters
$instance The instance being deleted.

Definition at line 2123 of file field.api.php.

References _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), db_update(), and field_info_field().

hook_field_storage_delete_revision | ( | $entity_type,
 |  | $entity,
 |  | $fields
 | ) |

Delete a single revision of field data for an entity.

This hook is invoked from field_attach_delete_revision() to ask the field storage module to delete field revision data.

Deleting the current (most recently written) revision is not allowed as has undefined results.

Parameters
$entity_type | The entity type of entity, such as 'node' or 'user'.
$entity | The entity on which to operate. The revision to delete is indicated by the entity's revision ID property, as identified by hook_fieldable_info() for $entity_type.
$fields | An array listing the fields to delete. The keys and values of the array are field IDs.

Definition at line 1938 of file field.api.php.

References _field_sql_storage_revision_tablename(), db_delete(), entity_extract_ids(), and field_info_field_by_id().

hook_field_storage_details ( $field )

Reveal the internal details about the storage for a field.

For example, an SQL storage module might return the Schema API structure for the table. A key/value storage module might return the server name, authentication credentials, and bin name.

Field storage modules are not obligated to implement this hook. Modules that rely on these details must only use them for read operations.

Parameters
$field A field structure.
Returns
An array of details.
  • The first dimension is a store type (sql, solr, etc).
  • The second dimension indicates the age of the values in the store FIELD_LOAD_CURRENT or FIELD_LOAD_REVISION.
  • Other dimensions are specific to the field storage module.
See Also
hook_field_storage_details_alter()

Definition at line 1674 of file field.api.php.

References $attributes, _field_sql_storage_columnname(), _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), FIELD_LOAD_CURRENT, and FIELD_LOAD_REVISION.

hook_field_storage_details_alter | ( | & | $details,
 |  |  | $field
 | ) |  |

Perform alterations on Field API storage details.

Parameters
$details | An array of storage details for fields as exposed by hook_field_storage_details() implementations.
$field | A field structure.
See Also
hook_field_storage_details()

Definition at line 1705 of file field.api.php.

References $attributes, FIELD_LOAD_CURRENT, and FIELD_LOAD_REVISION.

hook_field_storage_info ( )

Expose Field API storage backends.

Returns
An array describing the storage backends implemented by the module. The keys are storage backend names. To avoid name clashes, storage backend names should be prefixed with the name of the module that exposes them. The values are arrays describing the storage backend, with the following key/value pairs:
  • label: The human-readable name of the storage backend.
  • description: A short description for the storage backend.
  • settings: An array whose keys are the names of the settings available for the storage backend, and whose values are the default values for those settings.

Definition at line 1628 of file field.api.php.

References t().

hook_field_storage_info_alter ( & $info )

Perform alterations on Field API storage types.

Parameters
$info Array of informations on storage types exposed by hook_field_field_storage_info() implementations.

Definition at line 1645 of file field.api.php.

References $info.

hook_field_storage_load | ( | $entity_type,
 |  | $entities,
 |  | $age,
 |  | $fields,
 |  | $options
 | ) |

Load field data for a set of entities.

This hook is invoked from field_attach_load() to ask the field storage module to load field data.

Modules implementing this hook should load field values and add them to objects in $entities. Fields with no values should be added as empty arrays.

Parameters
$entity_type | The type of entity, such as 'node' or 'user'.
$entities | The array of entity objects to add fields to, keyed by entity ID.
$age | FIELD_LOAD_CURRENT to load the most recent revision for all fields, or FIELD_LOAD_REVISION to load the version indicated by each entity.
$fields | An array listing the fields to be loaded. The keys of the array are field IDs, and the values of the array are the entity IDs (or revision IDs, depending on the $age parameter) to add each field to.
$options An associative array of additional options, with the following keys:
  • deleted: If TRUE, deleted fields should be loaded as well as non-deleted fields. If unset or FALSE, only non-deleted fields should be loaded.

Definition at line 1749 of file field.api.php.

References $attributes, $results, $row, _field_sql_storage_columnname(), _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), db_select(), field_available_languages(), FIELD_CARDINALITY_UNLIMITED, field_info_field_by_id(), and FIELD_LOAD_CURRENT.

hook_field_storage_pre_insert | ( |  | $entity_type,
 |  |  | $entity,
 |  | & | $skip_fields
 | ) |  |

Act before the storage backends insert field data.

This hook allows modules to store data before the Field Storage API, optionally preventing the field storage module from doing so.

Parameters
$entity_type | The type of $entity; for example, 'node' or 'user'.
$entity | The entity with fields to save.
$skip_fields | An array keyed by field IDs whose data has already been written and therefore should not be written again. The values associated with these keys are not specified.
Returns
Saved field IDs are set set as keys in $skip_fields.

Definition at line 2193 of file field.api.php.

References _forum_node_check_node_type(), and db_insert().

hook_field_storage_pre_load | ( |  | $entity_type,
 |  |  | $entities,
 |  |  | $age,
 |  | & | $skip_fields,
 |  |  | $options
 | ) |  |

Act before the storage backends load field data.

This hook allows modules to load data before the Field Storage API, optionally preventing the field storage module from doing so.

This lets 3rd party modules override, mirror, shard, or otherwise store a subset of fields in a different way than the current storage engine. Possible use cases include per-bundle storage, per-combo-field storage, etc.

Modules implementing this hook should load field values and add them to objects in $entities. Fields with no values should be added as empty arrays. In addition, fields loaded should be added as keys to $skip_fields.

Parameters
$entity_type | The type of entity, such as 'node' or 'user'.
$entities | The array of entity objects to add fields to, keyed by entity ID.
$age | FIELD_LOAD_CURRENT to load the most recent revision for all fields, or FIELD_LOAD_REVISION to load the version indicated by each entity.
$skip_fields | An array keyed by field IDs whose data has already been loaded and therefore should not be loaded again. Add a key to this array to indicate that your module has already loaded a field.
$options An associative array of additional options, with the following keys:
  • field_id: The field ID that should be loaded. If unset, all fields should be loaded.
  • deleted: If TRUE, deleted fields should be loaded as well as non-deleted fields. If unset or FALSE, only non-deleted fields should be loaded.

Definition at line 2172 of file field.api.php.

hook_field_storage_pre_update | ( |  | $entity_type,
 |  |  | $entity,
 |  | & | $skip_fields
 | ) |  |

Act before the storage backends update field data.

This hook allows modules to store data before the Field Storage API, optionally preventing the field storage module from doing so.

Parameters
$entity_type | The type of $entity; for example, 'node' or 'user'.
$entity | The entity with fields to save.
$skip_fields | An array keyed by field IDs whose data has already been written and therefore should not be written again. The values associated with these keys are not specified.
Returns
Saved field IDs are set set as keys in $skip_fields.

Definition at line 2230 of file field.api.php.

References _forum_node_check_node_type(), _forum_update_forum_index(), db_delete(), db_insert(), and drupal_static().

hook_field_storage_query ( $query )

Execute an EntityFieldQuery.

This hook is called to find the entities having certain entity and field conditions and sort them in the given field order. If the field storage engine also handles property sorts and orders, it should unset those properties in the called object to signal that those have been handled.

Parameters
EntityFieldQuery $query An EntityFieldQuery.
Returns
See EntityFieldQuery::execute() for the return values.

Definition at line 1968 of file field.api.php.

References _field_sql_storage_columnname(), _field_sql_storage_query_join_entity(), db_select(), and FIELD_LOAD_CURRENT.

hook_field_storage_write | ( | $entity_type,
 |  | $entity,
 |  | $op,
 |  | $fields
 | ) |

Write field data for an entity.

This hook is invoked from field_attach_insert() and field_attach_update(), to ask the field storage module to save field data.

Parameters
$entity_type | The entity type of entity, such as 'node' or 'user'.
$entity | The entity on which to operate.
$op | FIELD_STORAGE_UPDATE when updating an existing entity, FIELD_STORAGE_INSERT when inserting a new entity.
$fields | An array listing the fields to be written. The keys and values of the array are field IDs.

Definition at line 1814 of file field.api.php.

References $attributes, $op, _field_sql_storage_columnname(), _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), db_delete(), db_insert(), entity_extract_ids(), field_available_languages(), FIELD_CARDINALITY_UNLIMITED, field_info_field_by_id(), and FIELD_STORAGE_UPDATE.

hook_field_widget_properties_ENTITY_TYPE_alter | ( | & | $widget,
 |  |  | $context
 | ) |  |

Alters the widget properties of a field instance on a given entity type before it gets displayed.

Modules can implement hook_field_widget_properties_ENTITY_TYPE_alter() to alter the widget properties for fields on a specific entity type, rather than implementing hook_field_widget_properties_alter().

This hook is called once per field per displayed widget entity. If the result of the hook involves reading from the database, it is highly recommended to statically cache the information.

Parameters
$widget The instance's widget properties.
$context An associative array containing:
  • entity_type: The entity type; e.g., 'node' or 'user'.
  • entity: The entity object.
  • field: The field that the widget belongs to.
  • instance: The instance of the field.
See Also
hook_field_widget_properties_alter()

Definition at line 2403 of file field.api.php.

Variable Documentation

const FIELD_STORAGE_INSERT 'insert'

Argument for an insert operation.

This is used in hook_field_storage_write when inserting a new entity.

Definition at line 65 of file field.attach.inc.

Referenced by field_attach_insert().

const FIELD_STORAGE_UPDATE 'update'

Argument for an update operation.

This is used in hook_field_storage_write when updating an existing entity.

Definition at line 58 of file field.attach.inc.

Referenced by field_attach_update(), field_sql_storage_field_storage_write(), and hook_field_storage_write().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Field CRUD API

Functions
Field CRUD API
Hooks

Functions

hook_field_create_field ($field)
hook_field_create_instance ($instance)
hook_field_update_forbid ($field, $prior_field, $has_data)
hook_field_update_field ($field, $prior_field, $has_data)
hook_field_delete_field ($field)
hook_field_update_instance ($instance, $prior_instance)
hook_field_delete_instance ($instance)
hook_field_read_field ($field)
hook_field_read_instance ($instance)
hook_field_purge_field ($field)
hook_field_purge_instance ($instance)
hook_field_storage_purge_field ($field)
hook_field_storage_purge_field_instance ($instance)
hook_field_storage_purge ($entity_type, $entity, $field, $instance)
field_create_field ($field)
field_update_field ($field)
field_read_field ($field_name, $include_additional=array())
field_read_fields ($params=array(), $include_additional=array())
field_delete_field ($field_name)
field_create_instance ($instance)
field_update_instance ($instance)
_field_write_instance ($instance, $update=FALSE)
field_read_instance ($entity_type, $field_name, $bundle, $include_additional=array())
field_read_instances ($params=array(), $include_additional=array())
field_delete_instance ($instance, $field_cleanup=TRUE)

Detailed Description

Create, update, and delete Field API fields, bundles, and instances.

Modules use this API, often in hook_install(), to create custom data structures. UI modules will use it to create a user interface.

The Field CRUD API uses Field API data structures .

See Field API for information about the other parts of the Field API.

End of "addtogroup field_storage".

Function Documentation

_field_write_instance | ( | $instance,
 |  | $update = FALSE
 | ) |

Stores an instance record in the field configuration database.

Parameters
$instance | An instance structure.
$update | Whether this is a new or existing instance.

Definition at line 586 of file field.crud.inc.

References drupal_write_record(), field_info_field_types(), field_info_formatter_settings(), field_info_formatter_types(), field_info_instance_settings(), field_info_max_weight(), field_info_widget_settings(), field_info_widget_types(), and field_read_field().

Referenced by field_create_instance(), and field_update_instance().

field_create_field ( $field )

Creates a field.

This function does not bind the field to any bundle; use field_create_instance() for that.

Parameters
$field A field definition array. The field_name and type properties are required. Other properties, if omitted, will be given the following default values:
  • cardinality: 1
  • locked: FALSE
  • indexes: the field-type indexes, specified by the field type's hook_field_schema(). The indexes specified in $field are added to those default indexes. It is possible to override the definition of a field-type index by providing an index with the same name, or to remove it by redefining it as an empty array of columns. Overriding field-type indexes should be done carefully, for it might seriously affect the site's performance.
  • settings: each omitted setting is given the default value defined in hook_field_info().
  • storage:
    • type: the storage backend specified in the 'field_storage_default' system variable.
    • settings: each omitted setting is given the default value specified in hook_field_storage_info().
Returns
The $field array with the id property filled in.
Exceptions
FieldException See: Field API data structures .

Definition at line 56 of file field.crud.inc.

References $info, db_delete(), drupal_strlen(), drupal_write_record(), entity_get_info(), field_cache_clear(), field_info_field_settings(), field_info_field_types(), field_info_storage_settings(), field_info_storage_types(), field_read_field(), module_invoke(), module_invoke_all(), module_load_install(), t(), and variable_get().

Referenced by _comment_body_field_create(), field_ui_field_overview_form_submit(), forum_enable(), node_add_body_field(), node_example_node_type_insert(), rdf_example_install(), and standard_install().

field_create_instance ( $instance )

Creates an instance of a field, binding it to a bundle.

Parameters
$instance A field instance definition array. The field_name, entity_type and bundle properties are required. Other properties, if omitted, will be given the following default values:
  • label: the field name
  • description: empty string
  • required: FALSE
  • default_value_function: empty string
  • settings: each omitted setting is given the default value specified in hook_field_info().
  • widget:
    • type: the default widget specified in hook_field_info().
    • settings: each omitted setting is given the default value specified in hook_field_widget_info().
  • display: Settings for the 'default' view mode will be added if not present, and each view mode in the definition will be completed with the following default values:
    • label: 'above'
    • type: the default formatter specified in hook_field_info().
    • settings: each omitted setting is given the default value specified in hook_field_formatter_info(). View modes not present in the definition are left empty, and the field will not be displayed in this mode.
Returns
The $instance array with the id property filled in.
Exceptions
FieldException See: Field API data structures .

Definition at line 473 of file field.crud.inc.

References _field_write_instance(), field_cache_clear(), field_read_field(), field_read_instance(), module_invoke_all(), and t().

Referenced by _comment_body_field_create(), field_ui_field_overview_form_submit(), forum_enable(), node_add_body_field(), node_example_node_type_insert(), rdf_example_install(), and standard_install().

field_delete_field ( $field_name )

Marks a field and its instances and data for deletion.

Parameters
$field_name The field name to delete.

Definition at line 411 of file field.crud.inc.

References db_update(), field_cache_clear(), field_delete_instance(), field_info_field(), field_info_instance(), module_invoke(), and module_invoke_all().

Referenced by comment_uninstall(), field_delete_instance(), forum_uninstall(), and taxonomy_vocabulary_delete().

field_delete_instance | ( | $instance,
 |  | $field_cleanup = TRUE
 | ) |

Marks a field instance and its data for deletion.

Parameters
$instance | An instance structure.
$field_cleanup | If TRUE, the field will be deleted as well if its last instance is being deleted. If FALSE, it is the caller's responsibility to handle the case of fields left without instances. Defaults to TRUE.

Definition at line 768 of file field.crud.inc.

References db_update(), field_cache_clear(), field_delete_field(), field_info_field(), module_invoke(), and module_invoke_all().

Referenced by field_attach_delete_bundle(), field_delete_field(), field_ui_field_delete_form_submit(), and rdf_example_uninstall().

field_read_field | ( | $field_name,
 |  | $include_additional = array()
 | ) |

Reads a single field record directly from the database.

Generally, you should use the field_info_field() instead.

This function will not return deleted fields. Use field_read_fields() instead for this purpose.

Parameters
$field_name | The field name to read.
array | $include_additional | The default behavior of this function is to not return a field that is inactive. Setting $include_additional['include_inactive'] to TRUE will override this behavior.
Returns
A field definition array, or FALSE.

Definition at line 315 of file field.crud.inc.

References field_read_fields().

Referenced by _comment_body_field_create(), _field_write_instance(), field_create_field(), field_create_instance(), field_update_field(), field_update_instance(), FieldInfo\getField(), image_field_delete_instance(), and image_field_update_instance().

field_read_fields | ( | $params = array(),
 |  | $include_additional = array()
 | ) |

Reads in fields that match an array of conditions.

Parameters
array | $params | An array of conditions to match against. Keys are columns from the 'field_config' table, values are conditions to match. Additionally, conditions on the 'entity_type' and 'bundle' columns from the 'field_config_instance' table are supported (select fields having an instance on a given bundle).
array | $include_additional | The default behavior of this function is to not return fields that are inactive or have been deleted. Setting $include_additional['include_inactive'] or $include_additional['include_deleted'] to TRUE will override this behavior.
Returns
An array of fields matching $params. If $include_additional['include_deleted'] is TRUE, the array is keyed by field id, otherwise it is keyed by field name.

Definition at line 340 of file field.crud.inc.

References $results, $value, db_select(), module_invoke(), module_invoke_all(), and module_load_install().

Referenced by _field_ui_field_name_exists(), field_purge_batch(), field_read_field(), field_sql_storage_schema(), field_system_info_alter(), FieldInfo\getBundleInstances(), FieldInfo\getFieldById(), FieldInfo\getFields(), taxonomy_taxonomy_vocabulary_update(), and taxonomy_vocabulary_delete().

field_read_instance | ( | $entity_type,
 |  | $field_name,
 |  | $bundle,
 |  | $include_additional = array()
 | ) |

Reads a single instance record from the database.

Generally, you should use field_info_instance() instead, as it provides caching and allows other modules the opportunity to append additional formatters, widgets, and other information.

Parameters
$entity_type | The type of entity to which the field is bound.
$field_name | The field name to read.
$bundle | The bundle to which the field is bound.
array | $include_additional | The default behavior of this function is to not return an instance that has been deleted, or whose field is inactive. Setting $include_additional['include_inactive'] or $include_additional['include_deleted'] to TRUE will override this behavior.
Returns
An instance structure, or FALSE.

Definition at line 692 of file field.crud.inc.

References field_read_instances().

Referenced by _comment_body_field_create(), field_create_instance(), field_ui_display_overview_form_submit(), field_ui_field_edit_form_submit(), field_ui_field_overview_form_submit(), field_ui_widget_type_form_submit(), and field_update_instance().

field_read_instances | ( | $params = array(),
 |  | $include_additional = array()
 | ) |

Reads in field instances that match an array of conditions.

Parameters
$param | An array of properties to use in selecting a field instance. Valid keys include any column of the field_config_instance table. If NULL, all instances will be returned.
$include_additional | The default behavior of this function is to not return field instances that have been marked deleted, or whose field is inactive. Setting $include_additional['include_inactive'] or $include_additional['include_deleted'] to TRUE will override this behavior.
Returns
An array of instances matching the arguments.

Definition at line 713 of file field.crud.inc.

References $results, $value, db_select(), entity_get_info(), and module_invoke_all().

Referenced by _field_invoke_get_instances(), _field_ui_add_default_view_mode_settings(), field_attach_delete_bundle(), field_purge_batch(), field_purge_field(), field_read_instance(), field_sql_storage_field_attach_rename_bundle(), field_ui_inactive_instances(), FieldInfo\getBundleInstances(), FieldInfo\getInstances(), and image_image_style_save().

field_update_field ( $field )

Updates a field.

Any module may forbid any update for any reason. For example, the field's storage module might forbid an update if it would change the storage schema while data for the field exists. A field type module might forbid an update if it would change existing data's semantics, or if there are external dependencies on field settings that cannot be updated.

Parameters
$field A field structure. $field['field_name'] must provided; it identifies the field that will be updated to match this structure. Any other properties of the field that are not specified in $field will be left unchanged, so it is not necessary to pass in a fully populated $field structure.
Returns
Throws a FieldException if the update cannot be performed.
See Also
field_create_field()

Definition at line 220 of file field.crud.inc.

References $module, drupal_write_record(), field_cache_clear(), field_has_data(), field_info_storage_types(), field_read_field(), module_implements(), module_invoke(), module_invoke_all(), and module_load_install().

Referenced by field_ui_field_edit_form_submit(), field_ui_field_settings_form_submit(), taxonomy_taxonomy_vocabulary_update(), and taxonomy_vocabulary_delete().

field_update_instance ( $instance )

Updates an instance of a field.

Parameters
$instance An associative array representing an instance structure. The following required array elements specify which field instance is being updated:
  • entity_type: The type of the entity the field is attached to.
  • bundle: The bundle this field belongs to.
  • field_name: The name of an existing field. The other array elements represent properties of the instance, and all properties must be specified or their default values will be used (except internal-use properties, which are assigned automatically). To avoid losing the previously stored properties of the instance when making a change, first load the instance with field_info_instance(), then override the values you want to override, and finally save using this function. Example:
    * // Fetch an instance info array.
    * $instance_info = field_info_instance($entity_type, $field_name, $bundle_name);
    * // Change a single property in the instance definition.
    * $instance_info['definition']['required'] = TRUE;
    * // Write the changed definition back.
    * field_update_instance($instance_info['definition']);
    *
Exceptions
FieldException
See Also
field_info_instance()
field_create_instance()

Definition at line 553 of file field.crud.inc.

References _field_write_instance(), field_cache_clear(), field_read_field(), field_read_instance(), module_invoke_all(), and t().

Referenced by _field_ui_add_default_view_mode_settings(), field_ui_display_overview_form_submit(), field_ui_field_edit_form_submit(), field_ui_field_overview_form_submit(), field_ui_widget_type_form_submit(), image_image_style_save(), and node_example_node_type_insert().

hook_field_create_field ( $field )

Act on a field being created.

This hook is invoked from field_create_field() after the field is created, to allow modules to act on field creation.

Parameters
$field The field just created.

Definition at line 2430 of file field.api.php.

hook_field_create_instance ( $instance )

Act on a field instance being created.

This hook is invoked from field_create_instance() after the instance record is saved, so it cannot be used to modify the instance itself.

Parameters
$instance The instance just created.

Definition at line 2443 of file field.api.php.

hook_field_delete_field ( $field )

Act on a field being deleted.

This hook is invoked just after a field is deleted by field_delete_field().

Parameters
$field The field just deleted.

Definition at line 2511 of file field.api.php.

hook_field_delete_instance ( $instance )

Act on a field instance being deleted.

This hook is invoked from field_delete_instance() after the instance is deleted.

Parameters
$instance The instance just deleted.

Definition at line 2539 of file field.api.php.

hook_field_purge_field ( $field )

Acts when a field record is being purged.

In field_purge_field(), after the field configuration has been removed from the database, the field storage module has had a chance to run its hook_field_storage_purge_field(), and the field info cache has been cleared, this hook is invoked on all modules to allow them to respond to the field being purged.

Parameters
$field The field being purged.

Definition at line 2579 of file field.api.php.

References db_delete().

hook_field_purge_instance ( $instance )

Acts when a field instance is being purged.

In field_purge_instance(), after the field instance has been removed from the database, the field storage module has had a chance to run its hook_field_storage_purge_instance(), and the field info cache has been cleared, this hook is invoked on all modules to allow them to respond to the field instance being purged.

Parameters
$instance The instance being purged.

Definition at line 2597 of file field.api.php.

References db_delete().

hook_field_read_field ( $field )

Act on field records being read from the database.

This hook is invoked from field_read_fields() on each field being read.

Parameters
$field The field record just read from the database.

Definition at line 2551 of file field.api.php.

hook_field_read_instance ( $instance )

Act on a field record being read from the database.

This hook is invoked from field_read_instances() on each instance being read.

Parameters
$instance The instance record just read from the database.

Definition at line 2563 of file field.api.php.

hook_field_storage_purge | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance
 | ) |

Remove field storage information when field data is purged.

Called from field_purge_data() to allow the field storage module to delete field data information.

Parameters
$entity_type | The type of $entity; for example, 'node' or 'user'.
$entity | The pseudo-entity whose field data to delete.
$field | The (possibly deleted) field whose data is being purged.
$instance | The deleted field instance whose data is being purged.

Definition at line 2650 of file field.api.php.

References _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), db_delete(), and entity_extract_ids().

hook_field_storage_purge_field ( $field )

Remove field storage information when a field record is purged.

Called from field_purge_field() to allow the field storage module to remove field information when a field is being purged.

Parameters
$field The field being purged.

Definition at line 2612 of file field.api.php.

References _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), and db_drop_table().

hook_field_storage_purge_field_instance ( $instance )

Remove field storage information when a field instance is purged.

Called from field_purge_instance() to allow the field storage module to remove field instance information when a field instance is being purged.

Parameters
$instance The instance being purged.

Definition at line 2629 of file field.api.php.

References db_delete().

hook_field_update_field | ( | $field,
 |  | $prior_field,
 |  | $has_data
 | ) |

Act on a field being updated.

This hook is invoked just after field is updated in field_update_field().

Parameters
$field | The field as it is post-update.
$prior_field | The field as it was pre-update.
$has_data | Whether any data already exists for this field.

Definition at line 2498 of file field.api.php.

References drupal_static_reset().

hook_field_update_forbid | ( | $field,
 |  | $prior_field,
 |  | $has_data
 | ) |

Forbid a field update from occurring.

Any module may forbid any update for any reason. For example, the field's storage module might forbid an update if it would change the storage schema while data for the field exists. A field type module might forbid an update if it would change existing data's semantics, or if there are external dependencies on field settings that cannot be updated.

To forbid the update from occurring, throw a FieldUpdateForbiddenException.

Parameters
$field | The field as it will be post-update.
$prior_field | The field as it is pre-update.
$has_data | Whether any data already exists for this field.

Definition at line 2466 of file field.api.php.

hook_field_update_instance | ( | $instance,
 |  | $prior_instance
 | ) |

Act on a field instance being updated.

This hook is invoked from field_update_instance() after the instance record is saved, so it cannot be used by a module to modify the instance itself.

Parameters
$instance | The instance as it is post-update.
$prior_instance | The instance as it was pre-update.

Definition at line 2526 of file field.api.php.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Field Attach API

Functions
Field Attach API

Functions

_field_invoke ($op, $entity_type, $entity, &$a=NULL, &$b=NULL, $options=array())
_field_invoke_multiple ($op, $entity_type, $entities, &$a=NULL, &$b=NULL, $options=array())
_field_invoke_default ($op, $entity_type, $entity, &$a=NULL, &$b=NULL, $options=array())
_field_invoke_multiple_default ($op, $entity_type, $entities, &$a=NULL, &$b=NULL, $options=array())
_field_invoke_get_instances ($entity_type, $bundle, $options)
field_attach_form ($entity_type, $entity, &$form, &$form_state, $langcode=NULL, $options=array())
field_attach_load ($entity_type, $entities, $age=FIELD_LOAD_CURRENT, $options=array())
field_attach_load_revision ($entity_type, $entities, $options=array())
field_attach_validate ($entity_type, $entity, $options=array())
field_attach_form_validate ($entity_type, $entity, $form, &$form_state, $options=array())
field_attach_submit ($entity_type, $entity, $form, &$form_state, $options=array())
field_attach_presave ($entity_type, $entity)
field_attach_insert ($entity_type, $entity)
field_attach_update ($entity_type, $entity)
field_attach_delete ($entity_type, $entity)
field_attach_delete_revision ($entity_type, $entity)
field_attach_prepare_view ($entity_type, $entities, $view_mode, $langcode=NULL, $options=array())
field_attach_view ($entity_type, $entity, $view_mode, $langcode=NULL, $options=array())
field_attach_preprocess ($entity_type, $entity, $element, &$variables)
field_attach_prepare_translation ($entity_type, $entity, $langcode, $source_entity, $source_langcode)
field_attach_create_bundle ($entity_type, $bundle)
field_attach_rename_bundle ($entity_type, $bundle_old, $bundle_new)
field_attach_delete_bundle ($entity_type, $bundle)
hook_field_attach_form ($entity_type, $entity, &$form, &$form_state, $langcode)
hook_field_attach_load ($entity_type, $entities, $age, $options)
hook_field_attach_validate ($entity_type, $entity, &$errors)
hook_field_attach_submit ($entity_type, $entity, $form, &$form_state)
hook_field_attach_presave ($entity_type, $entity)
hook_field_attach_insert ($entity_type, $entity)
hook_field_attach_update ($entity_type, $entity)
hook_field_attach_preprocess_alter (&$variables, $context)
hook_field_attach_delete ($entity_type, $entity)
hook_field_attach_delete_revision ($entity_type, $entity)
hook_field_attach_purge ($entity_type, $entity, $field, $instance)
hook_field_attach_view_alter (&$output, $context)
hook_field_attach_prepare_translation_alter (&$entity, $context)
hook_field_language_alter (&$display_language, $context)
hook_field_available_languages_alter (&$languages, $context)
hook_field_attach_create_bundle ($entity_type, $bundle)
hook_field_attach_rename_bundle ($entity_type, $bundle_old, $bundle_new)
hook_field_attach_delete_bundle ($entity_type, $bundle, $instances)

Detailed Description

End of "defgroup field_storage".

Operate on Field API data attached to Drupal entities.

Field Attach API functions load, store, display, generate Field API structures, and perform a variety of other functions for field data attached to individual entities.

Field Attach API functions generally take $entity_type and $entity arguments along with additional function-specific arguments. $entity_type is the type of the fieldable entity, such as 'node' or 'user', and $entity is the entity itself.

hook_entity_info() is the central place for entity types to define if and how Field API should operate on their entity objects. Notably, the 'fieldable' property needs to be set to TRUE.

The Field Attach API uses the concept of bundles: the set of fields for a given entity is defined on a per-bundle basis. The collection of bundles for an entity type is defined its hook_entity_info() implementation. For instance, node_entity_info() exposes each node type as its own bundle. This means that the set of fields of a node is determined by the node type. The Field API reads the bundle name for a given entity from a particular property of the entity object, and hook_entity_info() defines which property to use. For instance, node_entity_info() specifies:

$info['entity keys']['bundle'] = 'type'

This indicates that for a particular node object, the bundle name can be found in $node->type. This property can be omitted if the entity type only exposes a single bundle (all entities of this type have the same collection of fields). This is the case for the 'user' entity type.

Most Field Attach API functions define a corresponding hook function that allows any module to act on Field Attach operations for any entity after the operation is complete, and access or modify all the field, form, or display data for that entity and operation. For example, field_attach_view() invokes hook_field_attach_view_alter(). These all-module hooks are distinct from those of the Field Types API, such as hook_field_load(), that are only invoked for the module that defines a specific field type.

field_attach_load(), field_attach_insert(), and field_attach_update() also define pre-operation hooks, e.g. hook_field_attach_pre_load(). These hooks run before the corresponding Field Storage API and Field Type API operations. They allow modules to define additional storage locations (e.g. denormalizing, mirroring) for field data on a per-field basis. They also allow modules to take over field storage completely by instructing other implementations of the same hook and the Field Storage API itself not to operate on specified fields.

The pre-operation hooks do not make the Field Storage API irrelevant. The Field Storage API is essentially the "fallback mechanism" for any fields that aren't being intercepted explicitly by pre-operation hooks.

Field Language API provides information about the structure of field objects.

See Field API for information about the other parts of the Field API.

Function Documentation

_field_invoke | ( |  | $op,
 |  |  | $entity_type,
 |  |  | $entity,
 |  | & | $a = NULL,
 |  | & | $b = NULL,
 |  |  | $options = array()
 | ) |  |

Invoke a field hook.

Parameters
$op Possible operations include:
  • form
  • validate
  • presave
  • insert
  • update
  • delete
  • delete revision
  • view
  • prepare translation
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The fully formed $entity_type entity.
$a
  • The $form in the 'form' operation.
  • The value of $view_mode in the 'view' operation.
  • Otherwise NULL.
$b
  • The $form_state in the 'submit' operation.
  • Otherwise NULL.
$options An associative array of additional options, with the following keys:
  • 'field_name': The name of the field whose operation should be invoked. By default, the operation is invoked on all the fields in the entity's bundle. NOTE: This option is not compatible with the 'deleted' option; the 'field_id' option should be used instead.
  • 'field_id': The id of the field whose operation should be invoked. By default, the operation is invoked on all the fields in the entity's' bundles.
  • 'default': A boolean value, specifying which implementation of the operation should be invoked.
    • if FALSE (default), the field types implementation of the operation will be invoked (hook_field_[op])
    • If TRUE, the default field implementation of the field operation will be invoked (field_default_[op]) Internal use only. Do not explicitely set to TRUE, but use _field_invoke_default() instead.
  • 'deleted': If TRUE, the function will operate on deleted fields as well as non-deleted fields. If unset or FALSE, only non-deleted fields are operated on.
  • 'language': A language code or an array of language codes keyed by field name. It will be used to narrow down to a single value the available languages to act on.

Definition at line 181 of file field.attach.inc.

References $op, _field_invoke_get_instances(), _field_language_suggestion(), entity_extract_ids(), field_available_languages(), and field_info_field_by_id().

Referenced by _field_invoke_default(), field_attach_delete(), field_attach_delete_revision(), field_attach_insert(), field_attach_prepare_translation(), field_attach_presave(), field_attach_update(), field_attach_validate(), and field_purge_data().

_field_invoke_default | ( |  | $op,
 |  |  | $entity_type,
 |  |  | $entity,
 |  | & | $a = NULL,
 |  | & | $b = NULL,
 |  |  | $options = array()
 | ) |  |

Invoke field.module's version of a field hook.

This function invokes the field_default_[op]() function. Use field_invoke() to invoke the field type implementation, hook_field[op]().

See Also
_field_invoke()

Definition at line 383 of file field.attach.inc.

References $op, and _field_invoke().

Referenced by field_attach_form(), field_attach_form_validate(), field_attach_insert(), field_attach_prepare_translation(), field_attach_submit(), field_attach_validate(), field_attach_view(), and field_view_field().

_field_invoke_get_instances | ( | $entity_type,
 |  | $bundle,
 |  | $options
 | ) |

Helper for _field_invoke(): retrieves a list of instances to operate on.

Parameters
$entity_type | The entity type.
$bundle | The bundle name.
$options An associative array of options, as provided to _field_invoke(). Only the following keys are considered :
  • deleted
  • field_name
  • field_id See _field_invoke() for details.
Returns
The array of selected instance definitions.

Definition at line 420 of file field.attach.inc.

References field_info_instance(), field_info_instances(), and field_read_instances().

Referenced by _field_invoke(), _field_invoke_multiple(), and field_attach_load().

_field_invoke_multiple | ( |  | $op,
 |  |  | $entity_type,
 |  |  | $entities,
 |  | & | $a = NULL,
 |  | & | $b = NULL,
 |  |  | $options = array()
 | ) |  |

Invoke a field hook across fields on multiple entities.

Parameters
$op Possible operations include:
  • load
  • prepare_view For all other operations, use _field_invoke() / field_invoke_default() instead.
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entities | An array of entities, keyed by entity id.
$a
  • The $age parameter in the 'load' operation.
  • Otherwise NULL.
$b | Currently always NULL.
$options An associative array of additional options, with the following keys:
  • 'field_name': The name of the field whose operation should be invoked. By default, the operation is invoked on all the fields in the entity's bundle. NOTE: This option is not compatible with the 'deleted' option; the 'field_id' option should be used instead.
  • 'field_id': The id of the field whose operation should be invoked. By default, the operation is invoked on all the fields in the entity's' bundles.
  • 'default': A boolean value, specifying which implementation of the operation should be invoked.
    • if FALSE (default), the field types implementation of the operation will be invoked (hook_field_[op])
    • If TRUE, the default field implementation of the field operation will be invoked (field_default_[op]) Internal use only. Do not explicitely set to TRUE, but use _field_invoke_multiple_default() instead.
  • 'deleted': If TRUE, the function will operate on deleted fields as well as non-deleted fields. If unset or FALSE, only non-deleted fields are operated on.
  • 'language': A language code or an array of arrays of language codes keyed by entity id and field name. It will be used to narrow down to a single value the available languages to act on.
Returns
An array of returned values keyed by entity id.

Definition at line 278 of file field.attach.inc.

References $op, _field_invoke_get_instances(), _field_language_suggestion(), entity_extract_ids(), field_available_languages(), and field_info_field_by_id().

Referenced by _field_invoke_multiple_default(), field_attach_load(), field_attach_prepare_view(), field_view_field(), and node_preview().

_field_invoke_multiple_default | ( |  | $op,
 |  |  | $entity_type,
 |  |  | $entities,
 |  | & | $a = NULL,
 |  | & | $b = NULL,
 |  |  | $options = array()
 | ) |  |

Invoke field.module's version of a field hook on multiple entities.

This function invokes the field_default_[op]() function. Use field_invoke_multiple() to invoke the field type implementation, hook_field[op]().

See Also
_field_invoke_multiple()

Definition at line 397 of file field.attach.inc.

References $op, and _field_invoke_multiple().

Referenced by field_attach_prepare_view(), and field_view_field().

field_attach_create_bundle | ( | $entity_type,
 |  | $bundle
 | ) |

Notify field.module that a new bundle was created.

The default SQL-based storage doesn't need to do anything about it, but others might.

Parameters
$entity_type | The entity type to which the bundle is bound.
$bundle | The name of the newly created bundle.

Definition at line 1342 of file field.attach.inc.

References field_cache_clear(), and module_invoke_all().

Referenced by _comment_body_field_create(), node_type_save(), and taxonomy_vocabulary_save().

field_attach_delete | ( | $entity_type,
 |  | $entity
 | ) |

Delete field data for an existing entity. This deletes all revisions of field data for the entity.

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The entity whose field data to delete.

Definition at line 1045 of file field.attach.inc.

References _field_invoke(), cache_clear_all(), entity_extract_ids(), entity_get_info(), field_info_field_by_id(), field_info_instances(), field_info_storage_types(), module_invoke(), and module_invoke_all().

Referenced by comment_delete_multiple(), EntityExampleBasicController\delete_multiple(), node_delete_multiple(), taxonomy_term_delete(), and user_delete_multiple().

field_attach_delete_bundle | ( | $entity_type,
 |  | $bundle
 | ) |

Notify field.module the a bundle was deleted.

This deletes the data for the field instances as well as the field instances themselves. This function actually just marks the data and field instances and deleted, leaving the garbage collection for a separate process, because it is not always possible to delete this much data in a single page request (particularly since for some field types, the deletion is more than just a simple DELETE query).

Parameters
$entity_type | The entity type to which the bundle is bound.
$bundle | The bundle to delete.

Definition at line 1394 of file field.attach.inc.

References field_cache_clear(), field_delete_instance(), field_read_instances(), module_invoke_all(), and variable_del().

Referenced by comment_node_type_delete(), comment_uninstall(), entity_example_uninstall(), node_type_delete(), taxonomy_uninstall(), and taxonomy_vocabulary_delete().

field_attach_delete_revision | ( | $entity_type,
 |  | $entity
 | ) |

Delete field data for a single revision of an existing entity. The passed entity must have a revision id attribute.

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The entity with fields to save.

Definition at line 1082 of file field.attach.inc.

References _field_invoke(), entity_extract_ids(), field_info_field_by_id(), field_info_instances(), field_info_storage_types(), module_invoke(), and module_invoke_all().

Referenced by node_revision_delete().

field_attach_form | ( |  | $entity_type,
 |  |  | $entity,
 |  | & | $form,
 |  | & | $form_state,
 |  |  | $langcode = NULL,
 |  |  | $options = array()
 | ) |  |

Add form elements for all fields for an entity to a form structure.

The form elements for the entity's fields are added by reference as direct children in the $form parameter. This parameter can be a full form structure (most common case for entity edit forms), or a sub-element of a larger form.

By default, submitted field values appear at the top-level of $form_state['values']. A different location within $form_state['values'] can be specified by setting the '#parents' property on the incoming $form parameter. Because of name clashes, two instances of the same field cannot appear within the same $form element, or within the same '#parents' space.

For each call to field_attach_form(), field values are processed by calling field_attach_form_validate() and field_attach_submit() on the same $form element.

Sample resulting structure in $form:

* '#parents' => The location of field values in $form_state['values'],
* '#entity_type' => The name of the entity type,
* '#bundle' => The name of the bundle,
* // One sub-array per field appearing in the entity, keyed by field name.
* // The structure of the array differs slightly depending on whether the
* // widget is 'single-value' (provides the input for one field value,
* // most common case), and will therefore be repeated as many times as
* // needed, or 'multiple-values' (one single widget allows the input of
* // several values, e.g checkboxes, select box...).
* // The sub-array is nested into a $langcode key where $langcode has the
* // same value of the $langcode parameter above.
* // The '#language' key holds the same value of $langcode and it is used
* // to access the field sub-array when $langcode is unknown.
* 'field_foo' => array(
* '#tree' => TRUE,
* '#field_name' => The name of the field,
* '#language' => $langcode,
* $langcode => array(
* '#field_name' => The name of the field,
* '#language' => $langcode,
* '#field_parents' => The 'parents' space for the field in the form,
* equal to the #parents property of the $form parameter received by
* field_attach_form(),
* '#required' => Whether or not the field is required,
* '#title' => The label of the field instance,
* '#description' => The description text for the field instance,
*
* // Only for 'single' widgets:
* '#theme' => 'field_multiple_value_form',
* '#cardinality' => The field cardinality,
* // One sub-array per copy of the widget, keyed by delta.
* 0 => array(
* '#entity_type' => The name of the entity type,
* '#bundle' => The name of the bundle,
* '#field_name' => The name of the field,
* '#field_parents' => The 'parents' space for the field in the form,
* equal to the #parents property of the $form parameter received by
* field_attach_form(),
* '#title' => The title to be displayed by the widget,
* '#default_value' => The field value for delta 0,
* '#required' => Whether the widget should be marked required,
* '#delta' => 0,
* '#columns' => The array of field columns,
* // The remaining elements in the sub-array depend on the widget.
* '#type' => The type of the widget,
* ...
* ),
* 1 => array(
* ...
* ),
*
* // Only for multiple widgets:
* '#entity_type' => The name of the entity type,
* '#bundle' => $instance['bundle'],
* '#columns' => array_keys($field['columns']),
* // The remaining elements in the sub-array depend on the widget.
* '#type' => The type of the widget,
* ...
* ),
* ...
* ),
* )
*

Additionally, some processing data is placed in $form_state, and can be accessed by field_form_get_state() and field_form_set_state().

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The entity for which to load form elements, used to initialize default form values.
$form | The form structure to fill in. This can be a full form structure, or a sub-element of a larger form. The #parents property can be set to control the location of submitted field values within $form_state['values']. If not specified, $form['#parents'] is set to an empty array, placing field values at the top-level of $form_state['values'].
$form_state | An associative array containing the current state of the form.
$langcode | The language the field values are going to be entered, if no language is provided the default site language will be used.
array | $options | An associative array of additional options. See _field_invoke() for details.
See Also
field_form_get_state()
field_form_set_state()

Definition at line 564 of file field.attach.inc.

References $module, _field_invoke_default(), entity_extract_ids(), field_valid_language(), and module_implements().

Referenced by comment_form(), entity_example_basic_form(), node_form(), taxonomy_form_term(), user_profile_form(), and user_register_form().

field_attach_form_validate | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $form,
 |  | & | $form_state,
 |  |  | $options = array()
 | ) |  |

Perform field validation against form-submitted field values.

There are two levels of validation for fields in forms: widget validation, and field validation.

  • Widget validation steps are specific to a given widget's own form structure and UI metaphors. They are executed through FAPI's #element_validate property during normal form validation.
  • Field validation steps are common to a given field type, independently of the specific widget being used in a given form. They are defined in the field type's implementation of hook_field_validate().

This function performs field validation in the context of a form submission. It converts field validation errors into form errors on the correct form elements. Fieldable entity types should call this function during their own form validation function.

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The entity being submitted. The 'bundle', 'id' and (if applicable) 'revision' keys should be present. The actual field values will be read from $form_state['values'].
$form | The form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form.
$form_state | An associative array containing the current state of the form.
array | $options | An associative array of additional options. See _field_invoke() for details.

Definition at line 837 of file field.attach.inc.

References _field_invoke_default(), field_attach_validate(), field_form_get_state(), and field_form_set_state().

Referenced by entity_example_basic_form_validate(), and entity_form_field_validate().

field_attach_insert | ( | $entity_type,
 |  | $entity
 | ) |

Save field data for a new entity.

The passed-in entity must already contain its id and (if applicable) revision id attributes. Default values (if any) will be saved for fields not present in the $entity.

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The entity with fields to save.
Returns
Default values (if any) will be added to the $entity parameter for fields it leaves unspecified.

Definition at line 936 of file field.attach.inc.

References $module, _field_invoke(), _field_invoke_default(), entity_extract_ids(), entity_get_info(), field_info_field_by_id(), field_info_instances(), field_info_storage_types(), FIELD_STORAGE_INSERT, module_implements(), module_invoke(), and module_invoke_all().

Referenced by comment_save(), EntityExampleBasicController\save(), taxonomy_term_save(), and user_save().

field_attach_load | ( | $entity_type,
 |  | $entities,
 |  | $age = FIELD_LOAD_CURRENT,
 |  | $options = array()
 | ) |

Loads fields for the current revisions of a group of entities.

Loads all fields for each entity object in a group of a single entity type. The loaded field values are added directly to the entity objects.

field_attach_load() is automatically called by the default entity controller class, and thus, in most cases, doesn't need to be explicitly called by the entity type module.

Parameters
$entity_type | The type of $entity; e.g., 'node' or 'user'.
$entities | An array of entities for which to load fields, keyed by entity ID. Each entity needs to have its 'bundle', 'id' and (if applicable) 'revision' keys filled in. The function adds the loaded field data directly in the entity objects of the $entities array.
$age | FIELD_LOAD_CURRENT to load the most recent revision for all fields, or FIELD_LOAD_REVISION to load the version indicated by each entity. Defaults to FIELD_LOAD_CURRENT; use field_attach_load_revision() instead of passing FIELD_LOAD_REVISION.
$options An associative array of additional options, with the following keys:
  • 'field_id': The field ID that should be loaded, instead of loading all fields, for each entity. Note that returned entities may contain data for other fields, for example if they are read from a cache.
  • 'deleted': If TRUE, the function will operate on deleted fields as well as non-deleted fields. If unset or FALSE, only non-deleted fields are operated on.

Definition at line 622 of file field.attach.inc.

References $info, $module, _field_invoke_get_instances(), _field_invoke_multiple(), cache_get_multiple(), cache_set(), entity_extract_ids(), entity_get_info(), field_info_field_by_id(), field_info_instances(), field_info_storage_types(), FIELD_LOAD_CURRENT, module_implements(), module_invoke(), and module_invoke_all().

Referenced by DrupalDefaultEntityController\attachLoad(), comment_reply(), field_attach_load_revision(), field_purge_batch(), and file_field_update().

field_attach_load_revision | ( | $entity_type,
 |  | $entities,
 |  | $options = array()
 | ) |

Load all fields for previous versions of a group of entities.

Loading different versions of the same entities is not supported, and should be done by separate calls to the function.

field_attach_load_revision() is automatically called by the default entity controller class, and thus, in most cases, doesn't need to be explicitly called by the entity type module.

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entities | An array of entities for which to load fields, keyed by entity ID. Each entity needs to have its 'bundle', 'id' and (if applicable) 'revision' keys filled. The function adds the loaded field data directly in the entity objects of the $entities array.
$options | An associative array of additional options. See field_attach_load() for details.

Definition at line 757 of file field.attach.inc.

References field_attach_load(), and FIELD_LOAD_REVISION.

Referenced by DrupalDefaultEntityController\attachLoad().

field_attach_prepare_translation | ( | $entity_type,
 |  | $entity,
 |  | $langcode,
 |  | $source_entity,
 |  | $source_langcode
 | ) |

Prepares an entity for translation.

This function is used to fill-in the form default values for Field API fields while performing entity translation. By default it copies all the source values in the given source language to the new entity and assigns them the target language.

This is used as part of the 'per entity' translation pattern, which is implemented only for nodes by translation.module. Other entity types may be supported through contributed modules.

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The entity to be prepared for translation.
$langcode | The language the entity has to be translated in.
$source_entity | The source entity holding the field values to be translated.
$source_langcode | The source language from which translate.

Definition at line 1315 of file field.attach.inc.

References _field_invoke(), _field_invoke_default(), and drupal_alter().

Referenced by translation_node_prepare().

field_attach_prepare_view | ( | $entity_type,
 |  | $entities,
 |  | $view_mode,
 |  | $langcode = NULL,
 |  | $options = array()
 | ) |

Prepare field data prior to display.

This function lets field types and formatters load additional data needed for display that is not automatically loaded during field_attach_load(). It accepts an array of entities to allow query optimisation when displaying lists of entities.

field_attach_prepare_view() and field_attach_view() are two halves of the same operation. It is safe to call field_attach_prepare_view() multiple times on the same entity before calling field_attach_view() on it, but calling any Field API operation on an entity between passing that entity to these two functions may yield incorrect results.

Parameters
$entity_type | The type of $entities; e.g. 'node' or 'user'.
$entities | An array of entities, keyed by entity id.
$view_mode | View mode, e.g. 'full', 'teaser'...
$langcode | (Optional) The language the field values are to be shown in. If no language is provided the current language is used.
array | $options | An associative array of additional options. See _field_invoke() for details.

Definition at line 1133 of file field.attach.inc.

References _field_invoke_multiple(), _field_invoke_multiple_default(), and field_language().

Referenced by comment_build_content(), comment_view_multiple(), entity_example_basic_view(), node_build_content(), node_preview(), node_view_multiple(), taxonomy_term_build_content(), taxonomy_term_view_multiple(), and user_build_content().

field_attach_preprocess | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $element,
 |  | & | $variables
 | ) |  |

Populate the template variables with the field values available for rendering.

The $variables array will be populated with all the field instance values associated with the given entity type, keyed by field name; in case of translatable fields the language currently chosen for display will be selected.

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The entity with fields to render.
$element | The structured array containing the values ready for rendering.
$variables | The variables array is passed by reference and will be populated with field values.

Definition at line 1272 of file field.attach.inc.

References entity_extract_ids(), and field_info_instances().

Referenced by template_preprocess_comment(), template_preprocess_node(), template_preprocess_taxonomy_term(), and template_preprocess_user_profile().

field_attach_presave | ( | $entity_type,
 |  | $entity
 | ) |

Perform necessary operations just before fields data get saved.

We take no specific action here, we just give other modules the opportunity to act.

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The entity with fields to process.

Definition at line 913 of file field.attach.inc.

References _field_invoke(), and module_invoke_all().

Referenced by comment_save(), node_save(), taxonomy_term_save(), and user_save().

field_attach_rename_bundle | ( | $entity_type,
 |  | $bundle_old,
 |  | $bundle_new
 | ) |

Notify field.module that a bundle was renamed.

Parameters
$entity_type | The entity type to which the bundle is bound.
$bundle_old | The previous name of the bundle.
$bundle_new | The new name of the bundle.

Definition at line 1360 of file field.attach.inc.

References db_update(), field_cache_clear(), module_invoke_all(), variable_del(), variable_get(), and variable_set().

Referenced by comment_node_type_update(), node_type_save(), and taxonomy_vocabulary_save().

field_attach_submit | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $form,
 |  | & | $form_state,
 |  |  | $options = array()
 | ) |  |

Perform necessary operations on field data submitted by a form.

Currently, this accounts for drag-and-drop reordering of field values, and filtering of empty values.

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The entity being submitted. The 'bundle', 'id' and (if applicable) 'revision' keys should be present. The actual field values will be read from $form_state['values'].
$form | The form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form.
$form_state | An associative array containing the current state of the form.
array | $options | An associative array of additional options. See _field_invoke() for details.

Definition at line 884 of file field.attach.inc.

References $module, _field_invoke_default(), and module_implements().

Referenced by entity_example_basic_form_submit(), and entity_form_submit_build_entity().

field_attach_update | ( | $entity_type,
 |  | $entity
 | ) |

Save field data for an existing entity.

When calling this function outside an entity save operation be sure to clear caches for the entity:

* entity_get_controller($entity_type)->resetCache(array($entity_id))
*
Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The entity with fields to save.

Definition at line 990 of file field.attach.inc.

References $module, _field_invoke(), cache_clear_all(), entity_extract_ids(), entity_get_info(), field_info_field_by_id(), field_info_instances(), field_info_storage_types(), FIELD_STORAGE_UPDATE, module_implements(), module_invoke(), and module_invoke_all().

Referenced by comment_save(), EntityExampleBasicController\save(), taxonomy_term_save(), and user_save().

field_attach_validate | ( | $entity_type,
 |  | $entity,
 |  | $options = array()
 | ) |

Perform field validation against the field data in an entity.

This function does not perform field widget validation on form submissions. It is intended to be called during API save operations. Use field_attach_form_validate() to validate form submissions.

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The entity with fields to validate.
Exceptions
FieldValidationException If validation errors are found, a FieldValidationException is thrown. The 'errors' property contains the array of errors, keyed by field name, language and delta.
Parameters
array $options An associative array of additional options. See _field_invoke() for details.

Definition at line 781 of file field.attach.inc.

References $module, _field_invoke(), _field_invoke_default(), and module_implements().

Referenced by field_attach_form_validate().

field_attach_view | ( | $entity_type,
 |  | $entity,
 |  | $view_mode,
 |  | $langcode = NULL,
 |  | $options = array()
 | ) |

Returns a renderable array for the fields on an entity.

Each field is displayed according to the display options specified in the $instance definition for the given $view_mode.

field_attach_prepare_view() and field_attach_view() are two halves of the same operation. It is safe to call field_attach_prepare_view() multiple times on the same entity before calling field_attach_view() on it, but calling any Field API operation on an entity between passing that entity to these two functions may yield incorrect results.

Sample structure:

* array(
* 'field_foo' => array(
* '#theme' => 'field',
* '#title' => the label of the field instance,
* '#label_display' => the label display mode,
* '#object' => the fieldable entity being displayed,
* '#entity_type' => the type of the entity being displayed,
* '#language' => the language of the field values being displayed,
* '#view_mode' => the view mode,
* '#field_name' => the name of the field,
* '#field_type' => the type of the field,
* '#formatter' => the name of the formatter,
* '#items' => the field values being displayed,
* // The element's children are the formatted values returned by
* // hook_field_formatter_view().
* ),
* );
*
Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The entity with fields to render.
$view_mode | View mode, e.g. 'full', 'teaser'...
$langcode | The language the field values are to be shown in. If no language is provided the current language is used.
array | $options | An associative array of additional options. See _field_invoke() for details.
Returns
A renderable array for the field values.

Definition at line 1216 of file field.attach.inc.

References $output, _field_invoke_default(), drupal_alter(), entity_extract_ids(), and field_language().

Referenced by comment_build_content(), entity_example_basic_view(), node_build_content(), taxonomy_term_build_content(), and user_build_content().

hook_field_attach_create_bundle | ( | $entity_type,
 |  | $bundle
 | ) |

Act on field_attach_create_bundle().

This hook is invoked after the field module has performed the operation.

See field_attach_create_bundle() for details and arguments.

Definition at line 1557 of file field.api.php.

References variable_set().

hook_field_attach_delete | ( | $entity_type,
 |  | $entity
 | ) |

Act on field_attach_delete().

This hook is invoked after the field module has performed the operation.

See field_attach_delete() for details and arguments.

Definition at line 1406 of file field.api.php.

hook_field_attach_delete_bundle | ( | $entity_type,
 |  | $bundle,
 |  | $instances
 | ) |

Act on field_attach_delete_bundle.

This hook is invoked after the field module has performed the operation.

Parameters
$entity_type | The type of entity; for example, 'node' or 'user'.
$bundle | The bundle that was just deleted.
$instances | An array of all instances that existed for the bundle before it was deleted.

Definition at line 1595 of file field.api.php.

References variable_get(), and variable_set().

hook_field_attach_delete_revision | ( | $entity_type,
 |  | $entity
 | ) |

Act on field_attach_delete_revision().

This hook is invoked after the field module has performed the operation.

See field_attach_delete_revision() for details and arguments.

Definition at line 1417 of file field.api.php.

hook_field_attach_form | ( |  | $entity_type,
 |  |  | $entity,
 |  | & | $form,
 |  | & | $form_state,
 |  |  | $langcode
 | ) |  |

End of "defgroup field_formatter". Act on field_attach_form().

This hook is invoked after the field module has performed the operation. Implementing modules should alter the $form or $form_state parameters.

Parameters
$entity_type | The type of $entity; for example, 'node' or 'user'.
$entity | The entity for which an edit form is being built.
$form | The form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form. The $form['#parents'] property can be used to identify the corresponding part of $form_state['values']. Hook implementations that need to act on the top-level properties of the global form (like #submit, #validate...) can add a #process callback to the array received in the $form parameter, and act on the $complete_form parameter in the process callback.
$form_state | An associative array containing the current state of the form.
$langcode | The language the field values are going to be entered in. If no language is provided the default site language will be used.

Definition at line 1281 of file field.api.php.

References t().

hook_field_attach_insert | ( | $entity_type,
 |  | $entity
 | ) |

Act on field_attach_insert().

This hook is invoked after the field module has performed the operation.

See field_attach_insert() for details and arguments.

Definition at line 1365 of file field.api.php.

hook_field_attach_load | ( | $entity_type,
 |  | $entities,
 |  | $age,
 |  | $options
 | ) |

Act on field_attach_load().

This hook is invoked after the field module has performed the operation.

Unlike other field_attach hooks, this hook accounts for 'multiple loads'. Instead of the usual $entity parameter, it accepts an array of entities, indexed by entity ID. For performance reasons, information for all available entities should be loaded in a single query where possible.

The changes made to the entities' field values get cached by the field cache for subsequent loads.

See field_attach_load() for details and arguments.

Definition at line 1305 of file field.api.php.

hook_field_attach_prepare_translation_alter | ( | & | $entity,
 |  |  | $context
 | ) |  |

Perform alterations on field_attach_prepare_translation().

This hook is invoked after the field module has performed the operation.

Parameters
$entity The entity being prepared for translation.
$context An associative array containing:
  • entity_type: The type of $entity; e.g. 'node' or 'user'.
  • langcode: The language the entity has to be translated in.
  • source_entity: The entity holding the field values to be translated.
  • source_langcode: The source language from which translate.

Definition at line 1500 of file field.api.php.

hook_field_attach_preprocess_alter | ( | & | $variables,
 |  |  | $context
 | ) |  |

Alter field_attach_preprocess() variables.

This hook is invoked while preprocessing the field.tpl.php template file in field_attach_preprocess().

Parameters
$variables The variables array is passed by reference and will be populated with field values.
$context An associative array containing:
  • entity_type: The type of $entity; for example, 'node' or 'user'.
  • entity: The entity with fields to render.
  • element: The structured array containing the values ready for rendering.

Definition at line 1395 of file field.api.php.

hook_field_attach_presave | ( | $entity_type,
 |  | $entity
 | ) |

Act on field_attach_presave().

This hook is invoked after the field module has performed the operation.

See field_attach_presave() for details and arguments.

Definition at line 1354 of file field.api.php.

hook_field_attach_purge | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance
 | ) |

Act on field_purge_data().

This hook is invoked in field_purge_data() and allows modules to act on purging data from a single field pseudo-entity. For example, if a module relates data in the field with its own data, it may purge its own data during this process as well.

Parameters
$entity_type | The type of $entity; for example, 'node' or 'user'.
$entity | The pseudo-entity whose field data is being purged.
$field | The (possibly deleted) field whose data is being purged.
$instance | The deleted field instance whose data is being purged.
See Also
Field API bulk data deletion
field_purge_data()

Definition at line 1441 of file field.api.php.

hook_field_attach_rename_bundle | ( | $entity_type,
 |  | $bundle_old,
 |  | $bundle_new
 | ) |

Act on field_attach_rename_bundle().

This hook is invoked after the field module has performed the operation.

See field_attach_rename_bundle() for details and arguments.

Definition at line 1570 of file field.api.php.

References $info, variable_get(), and variable_set().

hook_field_attach_submit | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Act on field_attach_submit().

This hook is invoked after the field module has performed the operation.

Parameters
$entity_type | The type of $entity; for example, 'node' or 'user'.
$entity | The entity for which an edit form is being submitted. The incoming form values have been extracted as field values of the $entity object.
$form | The form structure where field elements are attached to. This might be a full form structure, or a sub-part of a larger form. The $form['#parents'] property can be used to identify the corresponding part of $form_state['values'].
$form_state | An associative array containing the current state of the form.

Definition at line 1338 of file field.api.php.

References drupal_array_get_nested_value().

hook_field_attach_update | ( | $entity_type,
 |  | $entity
 | ) |

Act on field_attach_update().

This hook is invoked after the field module has performed the operation.

See field_attach_update() for details and arguments.

Definition at line 1376 of file field.api.php.

hook_field_attach_validate | ( |  | $entity_type,
 |  |  | $entity,
 |  | & | $errors
 | ) |  |

Act on field_attach_validate().

This hook is invoked after the field module has performed the operation.

See field_attach_validate() for details and arguments.

Definition at line 1316 of file field.api.php.

hook_field_attach_view_alter | ( | & | $output,
 |  |  | $context
 | ) |  |

Perform alterations on field_attach_view() or field_view_field().

This hook is invoked after the field module has performed the operation.

Parameters
$output The structured content array tree for all of the entity's fields.
$context An associative array containing:
  • entity_type: The type of $entity; for example, 'node' or 'user'.
  • entity: The entity with fields to render.
  • view_mode: View mode; for example, 'full' or 'teaser'.
  • display: Either a view mode string or an array of display settings. If this hook is being invoked from field_attach_view(), the 'display' element is set to the view mode string. If this hook is being invoked from field_view_field(), this element is set to the $display argument and the view_mode element is set to '_custom'. See field_view_field() for more information on what its $display argument contains.
  • language: The language code used for rendering.

Definition at line 1468 of file field.api.php.

References $output, and element_children().

hook_field_available_languages_alter | ( | & | $languages,
 |  |  | $context
 | ) |  |

Alter field_available_languages() values.

This hook is invoked from field_available_languages() to allow modules to alter the array of available languages for the given field.

Parameters
$languages A reference to an array of language codes to be made available.
$context An associative array containing:
  • entity_type: The type of the entity the field is attached to.
  • field: A field data structure.

Definition at line 1541 of file field.api.php.

hook_field_language_alter | ( | & | $display_language,
 |  |  | $context
 | ) |  |

Perform alterations on field_language() values.

This hook is invoked to alter the array of display languages for the given entity.

Parameters
$display_language A reference to an array of language codes keyed by field name.
$context An associative array containing:
  • entity_type: The type of the entity to be displayed.
  • entity: The entity with fields to render.
  • langcode: The language code $entity has to be displayed in.

Definition at line 1520 of file field.api.php.

References field_has_translation_handler(), locale_field_language_fallback(), and variable_get().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Modules

Modules
Here is a list of all modules:
[detail level 12]
o Examples
| o Example: Action
| o Example: AJAX
| o Example: AJAX Graceful Degradation
| o Example: Batch API
| o Example: Block
| o Example: Cache API
| o Example: Contextual Links
| o Example: Cron
| o Example: Database (DBTNG)
| o Example: Email
| o Example: Entity
| o Example: Field Types API
| o Example: Field Permissions
| o Example: Files
| o Example: Filter
| o Example: Form API
| o Example: Image
| o Example: JavaScript
| o Example: Menu
| o Example: Node Access
| o Example: Node
| o Example: NodeAPI
| o Example: Page
| o Example: Pager
| o Example: Queue
| o Example: RDF
| o Example: Render
| o Example: Simpletest
| o Example: Tabledrag
| o Example: Tablesort
| o Example: Theming
| o Example: Token API
| o Example: Trigger
| o Example: Vertical Tabs
| \ Example: XML-RPC
o Actions
o Ajax framework
o Ajax framework commands
o Logging severity levels
o PHP wrapper functions
o Block Caching
o HTTP handling
o Input validation
o Sanitization functions
o Formatting
o Database abstraction layer
o Schema API
| \ Code registry
o File interface
o Form builder functions
o Form generation
o Batch operations
o Image toolkits
o Language Negotiation API functionality
o Language negotiation options
o Language addition API
o Translation import/export API.
o Translation search API
o List of predefined languages
o Automatic interface translation import
o Locking mechanisms
o Menu system
| o Menu flags
| o Menu item types
| o Menu context types
| o Menu status codes
| \ Menu tree parameters
o Hooks
| o Callbacks
| o Field Types API
| o Field Widget API
| o Field Formatter API
| o Field Storage API
| \ Field CRUD API
o Pager pieces
o Content markers
o Field Attach API
o Field API bulk data deletion
o Field Info API
o Field API
o Field Language API
o File module public API functions
o Standard filters
o Language administration interface
o Translation administration screens
o Translation editing/deletion interface
o Node API Hooks
o Node access rights
o Hook implementations for user-created content types
o RDF Mapping API
o Search interface
o Update versions of API functions
o .x-to-7.x Updates from 6.x to 7.x
o .x-extra Extra updates for 7.x
o Authorized operations
o Queue operations
o Default theme implementations
o Taxonomy indexing
o Update Manager module: update
o Update Manager module: install
o Update Manager module: file management
\ Private update status cache system
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Examples

Modules | Functions
Examples

Modules

Example: Action
Example: AJAX
Example: AJAX Graceful Degradation
Example: Batch API
Example: Block
Example: Cache API
Example: Contextual Links
Example: Cron
Example: Database (DBTNG)
Example: Email
Example: Entity
Example: Field Types API
Example: Field Permissions
Example: Files
Example: Filter
Example: Form API
Example: Image
Example: JavaScript
Example: Menu
Example: Node Access
Example: Node
Example: NodeAPI
Example: Page
Example: Pager
Example: Queue
Example: RDF
Example: Render
Example: Simpletest
Example: Tabledrag
Example: Tablesort
Example: Theming
Example: Token API
Example: Trigger
Example: Vertical Tabs
Example: XML-RPC

Functions

examples_help ($path, $arg)

Detailed Description

Well-documented API examples for a broad range of Drupal 7 core functionality.

Developers can learn how to use a particular API quickly by experimenting with the examples, and adapt them for their own use.

Download the Examples for Developers Project (and participate with submissions, bug reports, patches, and documentation) at http://drupal.org/project/examples

Function Documentation

examples_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 30 of file examples.module.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Action

Functions
Example: Action
Examples

Functions

action_example_action_info ()
action_example_menu ()
_action_example_page ()
action_example_basic_action (&$entity, $context=array())
action_example_unblock_user_action (&$entity, $context=array())
action_example_node_sticky_action_form ($context)
action_example_node_sticky_action_validate ($form, $form_state)
action_example_node_sticky_action_submit ($form, $form_state)
action_example_node_sticky_action ($node, $context)

Detailed Description

Creating actions in Drupal 7

Triggers and actions are a matched pair of Drupal features allowing some Drupal programming without using PHP. Using the appropriate action in a specific event, a site administrator can add new functionality.

Examples are:

  • Send an email after a node is published or edited.
  • Display a message after a user has logged in.
  • Display a message and send an email after a node has been deleted.

A trigger is a special function which can enqueue actions. The trigger module provides the interface allowing us to associate certain actions with certain triggers.

Actions are the functions designed to be run by triggers.

A trigger should build the appropriate context for the action to be fired. Actions are very often grouped by functionality: examples are 'user', 'node', 'taxonomy'. When actions are grouped it is because they expect the same arguments. This way, you can enqueue as many actions understanding the 'user' object as you want.

Not all actions can be used in all triggers because they require different contexts. But some actions are generic enough that they do not require special objects in their contexts, and so can be used on every available trigger. This 'group' type is used by actions to be available for this trigger.

What are good candidates to be triggers? Any function can be a trigger, as long as it has the code to call the enqueued actions, but to make Drupal more extensible, you will find hooks (from Drupal and contributed modules) very good candidates. A trigger should build the arguments, ask for enqueued actions and run them. You may define a function being a trigger, and run it through a button in the front page, or you may prepare a trigger for a hook, and everytime that hook is fired, your trigger will be.

What are good candidates to be actions? any function is a possible action, the only problem is finding a trigger able to run it.

This module describes how to create actions for Drupal. In this example we are providing three actions:

  • A generic action that can be used in any trigger, which is the most basic example of an action.
  • An action which which extends the capabilities of User triggers, even if associated with node or comment events.
  • An action which extends the capabilities of node triggers, but limited to certain events only, and using a customizable option.
See Also
Example: Trigger
hook_action_info()
Writing Actions in Drupal 6
Triggers and Actions in Drupal 6

Function Documentation

_action_example_page ( )

A simple page to explain to the developer what to do.

Definition at line 188 of file action_example.module.

References t(), and url().

action_example_action_info ( )

Implements hook_action_info().

We call hook_action_info when we are defining the actions we provide. Actions are the actions fired by the associated triggers. In this example, we are registering our three new actions, providing the unique name (using Drupal's convention modulename_description_action), an easy to understand description of what the action does, the 'object' expected by this action (default options from core are node, user, comment and system, however other trigger modules may declare new object types), which are the triggers allowed to use these action, and if some customization is available. Please, note that the function name is not required to finish as _action to be declared as a Drupal action, and that only information provided by hook_trigger_info() will be considered for valid actions creation.

These are the actions being provided in hook_action_info()

  • action_example_basic_action: this action is a dummy function which can be used by any trigger. The label describes that the action will do nothing, but is enough for a basic example. Type is set to system, so users will not be confused about the scope of this action (expecting a node, user, or any other object). This action is not configurable, and will appear as available in the list of action under the menu entry: 'admin/config/system/actions.
  • action_example_unblock_user_action: Unblocks a user.
  • action_example_node_sticky_action: This action is a complex action that is only available to Node type triggers, and can only be associated with the events node presave, node insert and node update. The action does not exist by default and it has to be created by user configuration. This makes it an "advanced action" in Drupal, so-called because it requires configuration or customization. In this example action, the action will promote nodes and make them sticky during presave, insert, or update, but only for particular users. As an advanced action, it first needs to be created in the actions management page (admin/config/system/actions). At the bottom of that page a selection list shows a list of advanced actions that will includes the option 'Promote to frontpage and sticky on top any content created by :' Selecting this option and clicking the 'Create' button, a configuration form will ask for an author name. When this action is associated to any of the possible Node trigger events, it will only be effective if the author of the content matches the author configured by the action.
Returns
An associative array of action descriptions. The keys of the array are the names of the action functions, and each corresponding value is an associative array with the following key-value pairs:
  • 'type': The type of object this action acts upon. Core actions have types 'node', 'user', 'comment', and 'system', but additional types can be used, as long as the trigger and action agree on them.
  • 'label': The human-readable name of the action, which should be passed through the t() function for translation.
  • 'configurable': If FALSE, then the action doesn't require any extra configuration. If TRUE, then your module must define a form function with the same name as the action function with '_form' appended (e.g., the form for 'node_assign_owner_action' is 'node_assign_owner_action_form'.) This function takes $context as its only parameter, and is paired with the usual _submit function, and possibly an _validate function.
  • 'triggers': An array of the triggers that can trigger this action. For example: array('node_insert', 'user_update'). You can also declare support for any trigger by returning array('any') for this value.
  • 'behavior': (optional) A machine-readable array of behaviors of this action, used to signal additionally required actions that may need to be triggered. Currently recognized behaviors by Trigger module:
    • 'changes_property': If an action with this behavior is assigned to a trigger other than a "presave" hook, any save actions also assigned to this trigger are moved later in the list. If no save action is present, one will be added. Modules that are processing actions (like Trigger module) should take special care in the "presave" hook, in which case a dependent "save" action should NOT be invoked.
See Also
hook_action_info()

Definition at line 143 of file action_example.module.

References t().

action_example_basic_action | ( | & | $entity,
 |  |  | $context = array()
 | ) |  |

Action function for action_example_basic_action.

This action is not expecting any type of entity object, and can be used with any trigger type or any event.

Parameters
$entity | An optional entity object.
$context | Array with parameters for this action: depends on the trigger.
See Also
action_example_action_info()

Definition at line 205 of file action_example.module.

References drupal_set_message(), t(), and watchdog().

action_example_menu ( )

Implements hook_menu().

Provides a menu entry which explains what the module does.

Definition at line 174 of file action_example.module.

action_example_node_sticky_action | ( | $node,
 |  | $context
 | ) |

Action function for action_example_node_sticky_action.

Promote and set sticky flag. This is the special action that has been customized using the configuration form, validated with the validation function, and submitted with the submit function.

Parameters
$node A node object provided by the associated trigger.
$context Array with the following elements:
  • 'author': username of the author's content this function will promote and set as sticky.

Definition at line 344 of file action_example.module.

References drupal_set_message(), NODE_PROMOTED, NODE_STICKY, node_type_get_name(), t(), user_load_by_name(), and watchdog().

action_example_node_sticky_action_form ( $context )

Form function for action_example_node_sticky_action.

Since we defined action_example_node_sticky_action as 'configurable' => TRUE, this action requires a configuration form to create/configure the action. In this circumstance, Drupal will attempt to call a function named by combining the action name (action_example_node_sticky_action) and _form, in this case yielding action_example_node_sticky_action_form.

In Drupal, actions requiring creation and configuration are called 'advanced actions', because they must be customized to define their functionality.

The 'action_example_node_sticky_action' allows creating rules to promote and set sticky content created by selected users on certain events. A form is used to configure which user is affected by this action, and this form includes the standard _validate and _submit hooks. Generates settings form for action_example_node_sticky_action().

Parameters
$context An array of options of this action (in case it is being edited)
Returns
array $form
See Also
action_example_action_info()

Definition at line 285 of file action_example.module.

References t(), and user_access().

action_example_node_sticky_action_submit | ( | $form,
 |  | $form_state
 | ) |

Submit handler for action_example_node_sticky_action.

Returns an associative array of values which will be available in the $context when an action is executed.

Definition at line 326 of file action_example.module.

action_example_node_sticky_action_validate | ( | $form,
 |  | $form_state
 | ) |

Validates settings form for action_example_node_sticky_action(). Verifies that user exists before continuing.

Definition at line 314 of file action_example.module.

References form_set_error(), t(), and user_load_by_name().

action_example_unblock_user_action | ( | & | $entity,
 |  |  | $context = array()
 | ) |  |

Action function for action_example_unblock_user_action.

This action is expecting an entity object user, node or comment. If none of the above is provided (because it was not called from an user/node/comment trigger event, then the action will be taken on the current logged in user.

Unblock an user. This action can be fired from different trigger types:

  • User trigger: this user will be unblocked.
  • Node/Comment trigger: the author of the node or comment will be unblocked.
  • Other: (including system or custom defined types), current user will be unblocked. (Yes, this seems like an incomprehensible use-case.)
Parameters
$entity | An optional user object (could be a user, or an author if context is node or comment)
$context | Array with parameters for this action: depends on the trigger. The context is not used in this example.

Definition at line 236 of file action_example.module.

References drupal_set_message(), t(), user_load(), user_save(), and watchdog().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: AJAX

Functions
Example: AJAX
Examples

Functions

ajax_example_menu ()
ajax_example_intro ()
ajax_example_simplest ($form, &$form_state)
ajax_example_simplest_callback ($form, $form_state)
ajax_example_autocheckboxes ($form, &$form_state)
ajax_example_autocheckboxes_callback ($form, $form_state)
ajax_example_autotextfields ($form, &$form_state)
ajax_example_autotextfields_callback ($form, $form_state)
ajax_example_submit_driven_ajax ($form, &$form_state)
ajax_example_submit_driven_callback ($form, $form_state)
ajax_example_dependent_dropdown ($form, &$form_state)
ajax_example_dependent_dropdown_callback ($form, $form_state)
_ajax_example_get_first_dropdown_options ()
_ajax_example_get_second_dropdown_options ($key= '')
ajax_example_render_link ()
ajax_link_response ($type= 'ajax')

Detailed Description

These examples show basic AJAX concepts.

General documentation is available at AJAX Framework documentation and at the AJAX Forms handbook page .

The several examples here demonstrate basic AJAX usage.

Function Documentation

_ajax_example_get_first_dropdown_options ( )

Helper function to populate the first dropdown. This would normally be pulling data from the database.

Returns
array of options

Definition at line 586 of file ajax_example.module.

References drupal_map_assoc(), and t().

Referenced by ajax_example_dependent_dropdown(), and ajax_example_dependent_dropdown_degrades().

_ajax_example_get_second_dropdown_options ( $key = '' )

Helper function to populate the second dropdown. This would normally be pulling data from the database.

Parameters
$key This will determine which set of options is returned.
Returns
array of options

Definition at line 600 of file ajax_example.module.

References drupal_map_assoc(), and t().

Referenced by ajax_example_dependent_dropdown(), and ajax_example_dependent_dropdown_degrades().

ajax_example_autocheckboxes | ( |  | $form,
 |  | & | $form_state
 | ) |  |

AJAX-enabled select element causes replacement of a set of checkboxes based on the selection.

Definition at line 340 of file ajax_example.module.

References t().

ajax_example_autocheckboxes_callback | ( | $form,
 |  | $form_state
 | ) |

Callback element needs only select the portion of the form to be updated. Since #ajax['callback'] return can be HTML or a renderable array (or an array of commands), we can just return a piece of the form. See AJAX Advanced Commands for more details on AJAX framework commands. renderable array (the checkboxes fieldset)

Definition at line 402 of file ajax_example.module.

ajax_example_autotextfields | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Show/hide textfields based on AJAX-enabled checkbox clicks.

Definition at line 410 of file ajax_example.module.

References t().

ajax_example_autotextfields_callback | ( | $form,
 |  | $form_state
 | ) |

Selects the piece of the form we want to use as replacement text and returns it as a form (renderable array).

Returns
renderable array (the textfields element)

Definition at line 468 of file ajax_example.module.

ajax_example_dependent_dropdown | ( |  | $form,
 |  | & | $form_state
 | ) |  |

A form with a dropdown whose options are dependent on a choice made in a previous dropdown.

On changing the first dropdown, the options in the second are updated.

Definition at line 521 of file ajax_example.module.

References _ajax_example_get_first_dropdown_options(), _ajax_example_get_second_dropdown_options(), and t().

ajax_example_dependent_dropdown_callback | ( | $form,
 |  | $form_state
 | ) |

Selects just the second dropdown to be returned for re-rendering

Since the controlling logic for populating the form is in the form builder function, all we do here is select the element and return it to be updated.

Returns
renderable array (the second dropdown)

Definition at line 576 of file ajax_example.module.

ajax_example_intro ( )

Definition at line 248 of file ajax_example.module.

References l(), t(), and theme().

ajax_example_menu ( )

Implements hook_menu().

Sets up calls to drupal_get_form() for all our example cases.

See Also
menu_example.module
menu_example_menu()

Definition at line 32 of file ajax_example.module.

References MENU_CALLBACK.

ajax_example_render_link ( )

Demonstrates a clickable AJAX-enabled link using the 'use-ajax' class.

Because of the 'use-ajax' class applied here, the link submission is done without a page refresh.

When using the AJAX framework outside the context of a form or a renderable array of type 'link', you have to include ajax.js explicitly.

Returns

Definition at line 21 of file ajax_example_misc.inc.

References $output, drupal_add_library(), l(), and t().

ajax_example_simplest | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Simple form whose ajax-enabled 'changethis' member causes a text change in the description of the 'replace_textfield' member. See Form API Tutorial

Definition at line 281 of file ajax_example.module.

References t().

ajax_example_simplest_callback | ( | $form,
 |  | $form_state
 | ) |

Callback for ajax_example_simplest.

On an ajax submit, the form builder function is called again, then the $form and $form_state are passed to this callback function so it can select which portion of the form to send on to the client.

Returns
renderable array (the textfield element)

Definition at line 330 of file ajax_example.module.

ajax_example_submit_driven_ajax | ( |  | $form,
 |  | & | $form_state
 | ) |  |

A very basic form which with an AJAX-enabled submit.

On submit, the markup in the #markup element is updated.

Definition at line 478 of file ajax_example.module.

References t().

ajax_example_submit_driven_callback | ( | $form,
 |  | $form_state
 | ) |

Select the 'box' element, change the markup in it, and return it as a renderable array.

Returns
renderable array (the box element)

Definition at line 504 of file ajax_example.module.

ajax_link_response ( $type = 'ajax' )

Callback for link example.

Takes different logic paths based on whether Javascript was enabled. If $type == 'ajax', it tells this function that ajax.js has rewritten the URL and thus we are doing an AJAX and can return an array of commands.

Parameters
$type Either 'ajax' or 'nojs. Type is simply the normal URL argument to this URL.
Returns
If $type == 'ajax', returns an array of AJAX Commands. Otherwise, just returns the content, which will end up being a page.

Definition at line 98 of file ajax_example_misc.inc.

References $output, $page, ajax_command_append(), ajax_deliver(), and t().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: AJAX Graceful Degradation

Functions
Example: AJAX Graceful Degradation
Examples

Functions

ajax_example_dependent_dropdown_degrades ($form, &$form_state, $no_js_use=FALSE)
ajax_example_dependent_dropdown_degrades_submit ($form, &$form_state)
ajax_example_dependent_dropdown_degrades_first_callback ($form, $form_state)
ajax_example_dynamic_sections ($form, &$form_state, $no_js_use=FALSE)
ajax_example_dynamic_sections_validate ($form, &$form_state)
ajax_example_dynamic_sections_submit ($form, &$form_state)
ajax_example_dynamic_sections_select_callback ($form, $form_state)
ajax_example_wizard ($form, &$form_state, $no_js_use=FALSE)
ajax_example_wizard_callback ($form, $form_state)
ajax_example_wizard_submit ($form, &$form_state)
ajax_example_add_more ($form, &$form_state, $no_js_use=FALSE)
ajax_example_add_more_callback ($form, $form_state)
ajax_example_add_more_add_one ($form, &$form_state)
ajax_example_add_more_remove_one ($form, &$form_state)
ajax_example_add_more_submit ($form, &$form_state)

Detailed Description

These examples show AJAX with graceful degradation when Javascript is not available.

In each of these the key idea is that the form is rebuilt different ways depending on form input. In order to accomplish that, the formbuilder function is in charge of almost all logic.

Function Documentation

ajax_example_add_more | ( |  | $form,
 |  | & | $form_state,
 |  |  | $no_js_use = FALSE
 | ) |  |

This example shows a button to "add more" - add another textfield, and the corresponding "remove" button.

It works equivalently with javascript or not, and does the same basic steps either way.

The basic idea is that we build the form based on the setting of $form_state['num_names']. The custom submit functions for the "add-one" and "remove-one" buttons increment and decrement $form_state['num_names'] and then force a rebuild of the form.

The $no_js_use argument is simply for demonstration: When set, it prevents '#ajax' from being set, thus making the example behave as if javascript were disabled in the browser.

Definition at line 511 of file ajax_example_graceful_degradation.inc.

References t(), and url().

ajax_example_add_more_add_one | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for the "add-one-more" button.

Increments the max counter and causes a rebuild.

Definition at line 597 of file ajax_example_graceful_degradation.inc.

ajax_example_add_more_callback | ( | $form,
 |  | $form_state
 | ) |

Callback for both ajax-enabled buttons.

Selects and returns the fieldset with the names in it.

Definition at line 588 of file ajax_example_graceful_degradation.inc.

ajax_example_add_more_remove_one | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for the "remove one" button.

Decrements the max counter and causes a form rebuild.

Definition at line 607 of file ajax_example_graceful_degradation.inc.

ajax_example_add_more_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Final submit handler.

Reports what values were finally set.

Definition at line 619 of file ajax_example_graceful_degradation.inc.

References $output, drupal_set_message(), and t().

ajax_example_dependent_dropdown_degrades | ( |  | $form,
 |  | & | $form_state,
 |  |  | $no_js_use = FALSE
 | ) |  |

A form with a dropdown whose options are dependent on a choice made in a previous dropdown.

On changing the first dropdown, the options in the second are updated. Gracefully degrades if no javascript.

A bit of CSS and javascript is required. The CSS hides the "add more" button if javascript is not enabled. The Javascript snippet is really only used to enable us to present the form in degraded mode without forcing the user to turn off Javascript. Both of these are loaded by using the #attached FAPI property, so it is a good example of how to use that.

The extra argument $no_js_use is here only to allow presentation of this form as if Javascript were not enabled. ajax_example_menu() provides two ways to call this form, one normal ($no_js_use = FALSE) and one simulating Javascript disabled ($no_js_use = TRUE).

Definition at line 38 of file ajax_example_graceful_degradation.inc.

References _ajax_example_get_first_dropdown_options(), _ajax_example_get_second_dropdown_options(), drupal_get_path(), and t().

ajax_example_dependent_dropdown_degrades_first_callback | ( | $form,
 |  | $form_state
 | ) |

Selects just the second dropdown to be returned for re-rendering.

Returns
Renderable array (the second dropdown).

Definition at line 147 of file ajax_example_graceful_degradation.inc.

ajax_example_dependent_dropdown_degrades_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for ajax_example_dependent_dropdown_degrades().

Definition at line 127 of file ajax_example_graceful_degradation.inc.

References drupal_set_message(), and t().

ajax_example_dynamic_sections | ( |  | $form,
 |  | & | $form_state,
 |  |  | $no_js_use = FALSE
 | ) |  |

Example of a form with portions dynamically enabled or disabled, but with graceful degradation in the case of no javascript.

The idea here is that certain parts of the form don't need to be displayed unless a given option is selected, but then they should be displayed and configured.

The third $no_js_use argument is strictly for demonstrating operation without javascript, without making the user/developer turn off javascript.

Definition at line 163 of file ajax_example_graceful_degradation.inc.

References drupal_get_path(), drupal_map_assoc(), t(), and url().

ajax_example_dynamic_sections_select_callback | ( | $form,
 |  | $form_state
 | ) |

Callback for the select element.

This just selects and returns the questions_fieldset.

Definition at line 315 of file ajax_example_graceful_degradation.inc.

ajax_example_dynamic_sections_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for ajax_example_dynamic_sections().

Definition at line 277 of file ajax_example_graceful_degradation.inc.

References drupal_set_message(), and t().

ajax_example_dynamic_sections_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validation function for ajax_example_dynamic_sections().

Definition at line 267 of file ajax_example_graceful_degradation.inc.

References form_set_error(), and t().

ajax_example_wizard | ( |  | $form,
 |  | & | $form_state,
 |  |  | $no_js_use = FALSE
 | ) |  |

This example is a classic wizard, where a different and sequential form is presented on each step of the form.

In the AJAX version, the form is replaced for each wizard section. In the multistep version, it causes a new page load.

Parameters
$form
$form_state
$no_js_use Used for this demonstration only. If true means that the form should be built using a simulated no-javascript approach (ajax.js will not be loaded.)

Definition at line 334 of file ajax_example_graceful_degradation.inc.

References t(), and url().

ajax_example_wizard_callback | ( | $form,
 |  | $form_state
 | ) |

Definition at line 440 of file ajax_example_graceful_degradation.inc.

ajax_example_wizard_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for ajax_example_wizard.

In AJAX this is only submitted when the final submit button is clicked, but in the non-javascript situation, it is submitted with every button click.

Definition at line 451 of file ajax_example_graceful_degradation.inc.

References $value, drupal_set_message(), and t().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Batch API

Functions
Example: Batch API
Examples

Functions

batch_example_update_7100 (&$sandbox)
batch_example_menu ()
batch_example_simple_form ()
batch_example_simple_form_submit ($form, &$form_state)
batch_example_batch_1 ()
batch_example_op_1 ($nid, $operation_details, &$context)
batch_example_batch_2 ()
batch_example_op_2 ($operation_details, &$context)
batch_example_finished ($success, $results, $operations)
batch_example_lowest_nid ()
_batch_example_update_http_requests ()
_batch_example_get_http_requests ()

Detailed Description

Outlines how a module can use the Batch API.

Batches allow heavy processing to be spread out over several page requests, ensuring that the processing does not get interrupted because of a PHP timeout, while allowing the user to receive feedback on the progress of the ongoing operations. It also can prevent out of memory situations.

The .install file also shows how the Batch API can be used to handle long-running hook_update_N() functions.

Two harmless batches are defined:

  • batch 1: Load the node with the lowest nid 100 times.
  • batch 2: Load all nodes, 20 times and uses a progressive op, loading nodes by groups of 5.
    See Also
    Batch operations

Function Documentation

_batch_example_get_http_requests ( )

Definition at line 269 of file batch_example.module.

Referenced by batch_example_finished().

_batch_example_update_http_requests ( )

Utility function to count the HTTP requests in a session variable.

Definition at line 265 of file batch_example.module.

Referenced by batch_example_op_1(), and batch_example_op_2().

batch_example_batch_1 ( )

Batch 1 definition: Load the node with the lowest nid 1000 times. This creates an operations array defining what batch 1 should do, including what it should do when it's finished. In this case, each operation is the same and by chance even has the same $nid to operate on, but we could have a mix of different types of operations in the operations array.

Definition at line 95 of file batch_example.module.

References batch_example_lowest_nid(), drupal_set_message(), and t().

batch_example_batch_2 ( )

Batch 2 : Prepare a batch definition that will load all nodes 20 times.

Definition at line 142 of file batch_example.module.

References db_query(), drupal_set_message(), and t().

batch_example_finished | ( | $success,
 |  | $results,
 |  | $operations
 | ) |

Batch 'finished' callback used by both batch 1 and batch 2.

Definition at line 233 of file batch_example.module.

References $results, _batch_example_get_http_requests(), drupal_set_message(), and t().

batch_example_lowest_nid ( )

Utility function - simply queries and loads the lowest nid.

Returns
A nid or NULL if there are no nodes.

Definition at line 252 of file batch_example.module.

References db_select().

Referenced by batch_example_batch_1(), and batch_example_simple_form().

batch_example_menu ( )

Implements hook_menu().

Definition at line 33 of file batch_example.module.

batch_example_op_1 | ( |  | $nid,
 |  |  | $operation_details,
 |  | & | $context
 | ) |  |

Batch operation for batch 1: load a node. This is the function that is called on each operation in batch 1.

Definition at line 125 of file batch_example.module.

References _batch_example_update_http_requests(), check_plain(), node_load(), and t().

batch_example_op_2 | ( |  | $operation_details,
 |  | & | $context
 | ) |  |

Batch operation for batch 2 : load all nodes, 5 by five After each group of 5 control is returned to the batch API for later continuation.

Definition at line 179 of file batch_example.module.

References $row, _batch_example_update_http_requests(), check_plain(), db_query(), db_select(), and node_load().

batch_example_simple_form ( )

Form builder function to allow choice of which batch to run.

Definition at line 49 of file batch_example.module.

References batch_example_lowest_nid(), drupal_set_message(), and t().

batch_example_simple_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 77 of file batch_example.module.

References batch_set().

batch_example_update_7100 ( & $sandbox )

Example of batch-driven update function.

Because some update functions may require the batch API, the $sandbox provides a place to store state. When $standbox['#finished'] == TRUE, calls to this update function are completed.

The $sandbox param provides a way to store data during multiple invocations. When the $sandbox['#finished'] == 1, execution is complete.

This dummy 'update' function changes no state in the system. It simply loads each node.

To make this update function run again and again, execute the query "update system set schema_version = 0 where name = 'batch_example';" and then run /update.php.

Definition at line 27 of file batch_example.install.

References $row, db_query(), db_select(), and t().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Block

Functions
Example: Block
Examples

Functions

block_example_uninstall ()
block_example_menu ()
block_example_page ()
block_example_block_info ()
block_example_block_configure ($delta= '')
block_example_block_save ($delta= '', $edit=array())
block_example_block_view ($delta= '')
block_example_contents ($which_block)
block_example_block_list_alter (&$blocks)
block_example_block_view_alter (&$data, $block)

Detailed Description

Demonstrates code creation of blocks.

This is an example outlining how a module can define blocks that can be displayed on various pages of a site, or how to alter blocks provided by other modules.

Function Documentation

block_example_block_configure ( $delta = '' )

Implements hook_block_configure().

This hook declares configuration options for blocks provided by this module.

Definition at line 90 of file block_example.module.

References t(), and variable_get().

block_example_block_info ( )

Implements hook_block_info().

This hook declares what blocks are provided by the module.

Definition at line 47 of file block_example.module.

References BLOCK_VISIBILITY_LISTED, DRUPAL_CACHE_PER_ROLE, and t().

block_example_block_list_alter ( & $blocks )

Implements hook_block_list_alter().

This hook allows you to add, remove or modify blocks in the block list. The block list contains the block definitions. This example requires search module and the search block enabled to see how this hook implementation works.

You may also be interested in hook_block_info_alter(), which allows changes to the behavior of blocks.

Definition at line 195 of file block_example.module.

block_example_block_save | ( | $delta = '',
 |  | $edit = array()
 | ) |

Implements hook_block_save().

This hook declares how the configured options for a block provided by this module are saved.

Definition at line 117 of file block_example.module.

References variable_set().

block_example_block_view ( $delta = '' )

Implements hook_block_view().

This hook generates the contents of the blocks themselves.

Definition at line 131 of file block_example.module.

References block_example_contents(), and t().

block_example_block_view_alter | ( | & | $data,
 |  |  | $block
 | ) |  |

Implements hook_block_view_alter().

This hook allows you to modify the output of any block in the system.

In addition, instead of hook_block_view_alter(), which is called for all blocks, you can also use hook_block_view_MODULE_DELTA_alter() to alter a specific block. To change only our block using hook_block_view_MODULE_DELTA_alter, we would use the function: block_example_block_view_block_example_example_configurable_text_alter()

We are going to uppercase the subject (the title of the block as shown to the user) of any block if the string "uppercase" appears in the block title or subject. Default block titles are set programmatically in the subject key; titles created through the UI are saved in the title key. This module creates an example block to demonstrate this effect (default title set programmatically as subject). You can also demonstrate the effect of this hook by creating a new block whose title has the string 'uppercase' in it (set as title through the UI).

Definition at line 230 of file block_example.module.

References drupal_strtoupper().

block_example_contents ( $which_block )

A module-defined block content function.

Definition at line 160 of file block_example.module.

References t(), and variable_get().

Referenced by block_example_block_view().

block_example_menu ( )

Implements hook_menu().

Provides a default page to explain what this module does.

Definition at line 23 of file block_example.module.

block_example_page ( )

Simple page function to explain what the block example is about.

Definition at line 35 of file block_example.module.

References $page, t(), and url().

block_example_uninstall ( )

Implements hook_uninstall().

Definition at line 12 of file block_example.install.

References variable_del().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Cache API

Functions
Example: Cache API
Examples

Functions

cache_example_menu ()
cache_example_page_form ($form, &$form_state)
cache_example_form_expire_files ($form, &$form_state)
cache_example_form_create_expiring_item ($form, &$form_state)
cache_example_form_cache_clearing ($form, &$form_state)

Detailed Description

Outlines how a module can use the Cache API.

Cache API allows us to cache data that is heavy to calculate. As this can significantly speed up the Drupal site, it is recommended to use cache mechanism when it is appropriate.

Cache in Drupal is very easy to use. This example will search entire Drupal folder and display all files. Since this operation includes filesystem it can take a while. This list will not change much on production websites, so we decide to cache it.

See Also
cache_get()
cache_set()
cache_clear_all()

Function Documentation

cache_example_form_cache_clearing | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to demonstrate the various uses of cache_clear_all().

Definition at line 222 of file cache_example.module.

References cache_clear_all(), drupal_set_message(), and t().

cache_example_form_create_expiring_item | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to create a new cache item with specified expiration.

Definition at line 203 of file cache_example.module.

References CACHE_PERMANENT, cache_set(), drupal_set_message(), format_date(), and t().

cache_example_form_expire_files | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler that explicitly clears cache_example_files_count from cache.

Definition at line 186 of file cache_example.module.

References cache_clear_all(), drupal_set_message(), and t().

cache_example_menu ( )

Implements hook_menu().

Definition at line 33 of file cache_example.module.

cache_example_page_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

cache_example page/form callback.

Displays a page/form which outlines how Drupal's cache works.

Definition at line 51 of file cache_example.module.

References cache_get(), cache_set(), file_scan_directory(), request_uri(), t(), and user_access().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Contextual Links

Functions
Example: Contextual Links
Examples

Functions

contextual_links_example_menu ()
contextual_links_example_object_load ($id)
contextual_links_example_block_info ()
contextual_links_example_block_view ($delta= '')
contextual_links_overview_page ()
contextual_links_example_theme ()
template_preprocess_contextual_links_example_object (&$variables)
contextual_links_example_object_page ($object)
contextual_links_example_object_edit_form_submit ($form, &$form_state)
contextual_links_example_node_action_form_submit ($form, &$form_state)

Detailed Description

Example of implementing contextual links.

Function Documentation

contextual_links_example_block_info ( )

Implements hook_block_info().

Definition at line 177 of file contextual_links_example.module.

References t().

contextual_links_example_block_view ( $delta = '' )

Implements hook_block_view().

Definition at line 186 of file contextual_links_example.module.

References contextual_links_example_object_load(), filter_xss(), and t().

contextual_links_example_menu ( )

Implements hook_menu().

Drupal's menu system allows you to indicate that particular menu items should be displayed as contextual links. If you hover over a block or node while logged in as an administrator (and with the Contextual Links module enabled) you'll see a small gear icon appear. Click on this icon, and the list of items that appears in the exposed menu are what Drupal calls "contextual links".

Contextual links allow site administrators to quickly perform actions related to elements on a page, without having to hunt through the administrative interface. As such, you should usually attach them to objects that appear on the main part of a Drupal site and limit them to a few common tasks that are frequently performed (for example, "edit" or "configure"). Do not rely on contextual links being present for your module to work correctly, since they are a convenience feature only. Within Drupal core, the Contextual Links module must be enabled (and the user viewing the page must have the "access contextual links" permission) in order for the contextual links corresponding to actions that the user can perform to actually be injected into the page's HTML.

Three examples of contextual links are provided here. Although none are difficult to implement, they are presented in order of increasing complexity:

  • Attaching contextual links to a node.
  • Attaching contextual links to a block.
  • Attaching contextual links to an arbitrary piece of content defined by your module.
See Also
contextual_links_example_block_info()
contextual_links_example_block_view()
contextual_links_overview_page()

Definition at line 51 of file contextual_links_example.module.

References MENU_CONTEXT_INLINE, MENU_CONTEXT_PAGE, MENU_DEFAULT_LOCAL_TASK, and MENU_LOCAL_TASK.

contextual_links_example_node_action_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for contextual_links_example_node_action_form().

Definition at line 383 of file contextual_links_example.module.

References drupal_set_message(), and t().

contextual_links_example_object_edit_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for contextual_links_example_object_edit_form().

Definition at line 350 of file contextual_links_example.module.

References drupal_set_message(), and t().

contextual_links_example_object_load ( $id )

Menu loader callback for the object defined by this module.

Parameters
$id The ID of the object to load.
Returns
A fully loaded object, or FALSE if the object does not exist.

Definition at line 158 of file contextual_links_example.module.

References t().

Referenced by contextual_links_example_block_view(), and contextual_links_overview_page().

contextual_links_example_object_page ( $object )

Menu callback; displays an object defined by this module on its own page.

See Also
contextual_links_overview_page()

Definition at line 309 of file contextual_links_example.module.

contextual_links_example_theme ( )

Implements hook_theme().

See Also
template_preprocess_contextual_links_example_object()

Definition at line 274 of file contextual_links_example.module.

contextual_links_overview_page ( )

Menu callback; displays a listing of objects defined by this module.

See Also
contextual_links_example_theme()
contextual-links-example-object.tpl.php
contextual_links_example_block_view()

Definition at line 240 of file contextual_links_example.module.

References contextual_links_example_object_load().

template_preprocess_contextual_links_example_object ( & $variables )

Process variables for contextual-links-example-object.tpl.php.

See Also
contextual_links_overview_page()

Definition at line 297 of file contextual_links_example.module.

References filter_xss(), and title.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Cron

Functions
Example: Cron
Examples

Functions

cron_example_menu ()
cron_example_form ($form, &$form_state)
cron_example_form_cron_run_submit ($form, &$form_state)
cron_example_add_jobs_to_queue ($form, &$form_state)
cron_example_cron ()
cron_example_cron_queue_info ()
cron_example_queue_1_worker ($item)
cron_example_queue_2_worker ($item)
cron_example_queue_report_work ($worker, $item)

Detailed Description

Example using Cron API, including hook_cron() and hook_cron_queue_info().

This example is part of the Examples for Developers Project which you can download and experiment with at http://drupal.org/project/examples

Function Documentation

cron_example_add_jobs_to_queue | ( |  | $form,
 |  | & | $form_state
 | ) |  |

#submit function used to add the items to the queue when signaled by the form.

Definition at line 148 of file cron_example.module.

References DrupalQueue::get().

cron_example_cron ( )

Implements hook_cron().

hook_cron() is the traditional (pre-Drupal 7) hook for doing "background" processing. It gets called every time the Drupal cron runs and must decide what it will do.

In this example, it does a watchdog() call after the time named in the variable 'cron_example_next_execution' has arrived, and then it resets that variable to a time in the future.

Definition at line 171 of file cron_example.module.

References date_iso8601(), drupal_set_message(), t(), variable_get(), variable_set(), and watchdog().

cron_example_cron_queue_info ( )

Implements hook_cron_queue_info().

hook_cron_queue_info() and family are new since Drupal 7, and allow any process to add work to the queue to be acted on when cron runs. Queues are described and worker callbacks are provided, and then only the worker callback needs to be implemented.

All the details of queue use are done by the cron_queue implementation, so one doesn't need to know much about DrupalQueue().

See Also
queue_example.module

Definition at line 204 of file cron_example.module.

cron_example_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

The form to provide a link to cron.php.

Definition at line 37 of file cron_example.module.

References date_iso8601(), drupal_map_assoc(), DrupalQueue::get(), system_settings_form(), t(), user_access(), and variable_get().

cron_example_form_cron_run_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Allow user to directly execute cron, optionally forcing it.

Definition at line 128 of file cron_example.module.

References drupal_cron_run(), drupal_set_message(), t(), and variable_set().

cron_example_menu ( )

Implements hook_menu().

Definition at line 22 of file cron_example.module.

cron_example_queue_1_worker ( $item )

Simple workers for the two queues.

Parameters
$item Any object to be worked on.

Definition at line 222 of file cron_example.module.

References cron_example_queue_report_work().

cron_example_queue_2_worker ( $item )

Definition at line 225 of file cron_example.module.

References cron_example_queue_report_work().

cron_example_queue_report_work | ( | $worker,
 |  | $item
 | ) |

Simple reporter for the workers.

Parameters
$worker | (integer) worker number
$item | (object) the $item which was stored in the cron queue.

Definition at line 237 of file cron_example.module.

References date_iso8601(), drupal_set_message(), t(), and watchdog().

Referenced by cron_example_queue_1_worker(), and cron_example_queue_2_worker().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Database (DBTNG)

Functions
Example: Database (DBTNG)
Examples

Functions

dbtng_example_install ()
dbtng_example_uninstall ()
dbtng_example_schema ()
dbtng_example_entry_insert ($entry)
dbtng_example_entry_update ($entry)
dbtng_example_entry_delete ($entry)
dbtng_example_entry_load ($entry=array())
dbtng_example_advanced_list ()
dbtng_example_help ($path)
dbtng_example_menu ()
dbtng_example_list ()
dbtng_example_form_add ($form, &$form_state)
dbtng_example_form_add_submit ($form, &$form_state)
dbtng_example_form_update ($form, &$form_state)
dbtng_example_form_update_callback ($form, $form_state)
dbtng_example_form_update_submit ($form, &$form_state)

Detailed Description

Database examples, including DBTNG.

'DBTNG' means 'Database: The Next Generation.' Yes, Drupallers are nerds.

General documentation is available at database abstraction layer documentation and at Database API .

The several examples here demonstrate basic database usage.

In Drupal 6, the recommended method to save or update an entry in the database was drupal_write_record() or db_query().

In Drupal 7 and forward, the usage of db_query() for INSERT, UPDATE, or DELETE is deprecated, because it is database-dependent. Instead specific functions are provided to perform these operations: db_insert(), db_update(), and db_delete() do the job now. (Note that drupal_write_record() is also deprecated.)

db_insert() example:

* // INSERT INTO {dbtng_example} (name, surname) VALUES('John, 'Doe')
* db_insert('dbtng_example')
* ->fields(array('name' => 'John', 'surname' => 'Doe'))
* ->execute();
*

db_update() example:

* // UPDATE {dbtng_example} SET name = 'Jane' WHERE name = 'John'
* db_update('dbtng_example')
* ->fields(array('name' => 'Jane'))
* ->condition('name', 'John')
* ->execute();
*

db_delete() example:

* // DELETE FROM {dbtng_example} WHERE name = 'Jane'
* db_delete('dbtng_example')
* ->condition('name', 'Jane')
* ->execute();
*

See Database Abstraction Layer

See Also
db_insert()
db_update()
db_delete()
drupal_write_record()

Function Documentation

dbtng_example_advanced_list ( )

Render a filtered list of entries in the database.

DBTNG also helps processing queries that return several rows, providing the found objects in the same query execution call.

This function queries the database using a JOIN between users table and the example entries, to provide the username that created the entry, and creates a table with the results, processing each row.

SELECT e.pid as pid, e.name as name, e.surname as surname, e.age as age u.name as username FROM {dbtng_example} e JOIN users u ON e.uid = u.uid WHERE e.name = 'John' AND e.age > 18

See Also
db_select()
http://drupal.org/node/310075

Definition at line 282 of file dbtng_example.module.

References $header, $output, db_select(), drupal_set_message(), t(), and theme().

dbtng_example_entry_delete ( $entry )

Delete an entry from the database.

The usage of db_query is deprecated except for static queries. Formerly, a deletion might have been accomplished like this:

* db_query("DELETE FROM {dbtng_example} WHERE pid = %d", $entry['pid]);
*
Parameters
$entry An array containing at least the person identifier 'pid' element of the entry to delete.
See Also
db_delete()

Definition at line 161 of file dbtng_example.module.

References db_delete().

dbtng_example_entry_insert ( $entry )

Save an entry in the database.

The underlying DBTNG function is db_insert().

In Drupal 6, this would have been:

* db_query(
* "INSERT INTO {dbtng_example} (name, surname, age)
* VALUES ('%s', '%s', '%d')",
* $entry['name'],
* $entry['surname'],
* $entry['age']
* );
*

Exception handling is shown in this example. It could be simplified without the try/catch blocks, but since an insert will throw an exception and terminate your application if the exception is not handled, it is best to employ try/catch.

Parameters
$entry An array containing all the fields of the database record.
See Also
db_insert()

Definition at line 95 of file dbtng_example.module.

References db_insert(), drupal_set_message(), and t().

Referenced by dbtng_example_form_add_submit().

dbtng_example_entry_load ( $entry = array() )

Read from the database using a filter array.

In Drupal 6, the standard function to perform reads was db_query(), and for static queries, it still is.

db_query() used an SQL query with placeholders and arguments as parameters.

* // Old way
* $query = "SELECT * FROM {dbtng_example} n WHERE n.uid = %d AND name = '%s'";
* $result = db_query($query, $uid, $name);
*

Drupal 7 DBTNG provides an abstracted interface that will work with a wide variety of database engines.

db_query() is deprecated except when doing a static query. The following is perfectly acceptable in Drupal 7. See the handbook page on static queries

* // SELECT * FROM {dbtng_example} WHERE uid = 0 AND name = 'John'
* db_query(
* "SELECT * FROM {dbtng_example} WHERE uid = :uid and name = :name",
* array(':uid' => 0, ':name' => 'John')
* )->execute();
*

But for more dynamic queries, Drupal provides the db_select() API method, so there are several ways to perform the same SQL query. See the handbook page on dynamic queries.

* // SELECT * FROM {dbtng_example} WHERE uid = 0 AND name = 'John'
* db_select('dbtng_example')
* ->fields('dbtng_example')
* ->condition('uid', 0)
* ->condition('name', 'John')
* ->execute();
*

Here is db_select with named placeholders:

* // SELECT * FROM {dbtng_example} WHERE uid = 0 AND name = 'John'
* $arguments = array(':name' => 'John', ':uid' => 0);
* db_select('dbtng_example')
* ->fields('dbtng_example')
* ->where('uid = :uid AND name = :name', $arguments)
* ->execute();
*

Conditions are stacked and evaluated as AND and OR depending on the type of query. For more information, read the conditional queries handbook page at: http://drupal.org/node/310086

The condition argument is an 'equal' evaluation by default, but this can be altered:

* // SELECT * FROM {dbtng_example} WHERE age > 18
* db_select('dbtng_example')
* ->fields('dbtng_example')
* ->condition('age', 18, '>')
* ->execute();
*
Parameters
$entry An array containing all the fields used to search the entries in the table.
Returns
An object containing the loaded entries if found.
See Also
db_select()
db_query()
http://drupal.org/node/310072
http://drupal.org/node/310075

Definition at line 246 of file dbtng_example.module.

References $value, and db_select().

Referenced by dbtng_example_form_update(), and dbtng_example_list().

dbtng_example_entry_update ( $entry )

Update an entry in the database.

The former, deprecated techniques used db_query() or drupal_write_record():

* drupal_write_record('dbtng_example', $entry, $entry['pid']);
*
* db_query(
* "UPDATE {dbtng_example}
* SET name = '%s', surname = '%s', age = '%d'
* WHERE pid = %d",
* $entry['pid']
* );
*
Parameters
$entry An array containing all the fields of the item to be updated.
See Also
db_update()

Definition at line 131 of file dbtng_example.module.

References db_update(), drupal_set_message(), and t().

Referenced by dbtng_example_form_update_submit().

dbtng_example_form_add | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Prepare a simple form to add an entry, with all the interesting fields.

Definition at line 420 of file dbtng_example.module.

References t().

dbtng_example_form_add_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for 'add entry' form.

Definition at line 454 of file dbtng_example.module.

References dbtng_example_entry_insert(), drupal_set_message(), and t().

dbtng_example_form_update | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Sample UI to update a record.

Definition at line 473 of file dbtng_example.module.

References dbtng_example_entry_load(), and t().

dbtng_example_form_update_callback | ( | $form,
 |  | $form_state
 | ) |

AJAX callback handler for the pid select.

When the pid changes, populates the defaults from the database in the form.

Definition at line 540 of file dbtng_example.module.

dbtng_example_form_update_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for 'update entry' form.

Definition at line 554 of file dbtng_example.module.

References dbtng_example_entry_update(), drupal_set_message(), and t().

dbtng_example_help ( $path )

Implements hook_help().

Show some help on each form provided by this module.

Definition at line 330 of file dbtng_example.module.

References $output, and t().

dbtng_example_install ( )

Implements hook_install().

In Drupal 7, there is no need to install schema using this hook, the schema is already installed before this hook is called.

We will create a default entry in the database.

See Also
hook_install()

Definition at line 18 of file dbtng_example.install.

References db_insert().

dbtng_example_list ( )

Render a list of entries in the database.

Definition at line 397 of file dbtng_example.module.

References $header, $output, dbtng_example_entry_load(), drupal_set_message(), t(), and theme().

dbtng_example_menu ( )

Implements hook_menu().

Set up calls to drupal_get_form() for all our example cases.

Definition at line 355 of file dbtng_example.module.

References MENU_DEFAULT_LOCAL_TASK, and MENU_LOCAL_TASK.

dbtng_example_schema ( )

Implements hook_schema().

Defines the database tables used by this module. Remember that the easiest way to create the code for hook_schema is with the schema module

See Also
hook_schema()

Definition at line 70 of file dbtng_example.install.

dbtng_example_uninstall ( )

Implements hook_uninstall().

As in hook_install, there is no need to uninstall schema, Drupal will do it for us.

See Also
hook_uninstall()

Definition at line 55 of file dbtng_example.install.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Email

Functions
Example: Email
Examples

Functions

email_example_mail ($key, &$message, $params)
email_example_mail_send ($form_values)
email_example_mail_alter (&$message)
email_example_menu ()
email_example_form ()
email_example_form_validate ($form, &$form_state)
email_example_form_submit ($form, &$form_state)

Detailed Description

Example of how to use Drupal's mail API.

This example module provides two different examples of the Drupal email API:

  • Defines a simple contact form and shows how to use drupal_mail() to send an e-mail (defined in hook_mail()) when the form is submitted.
  • Shows how modules can alter emails defined by other Drupal modules or Core using hook_mail_alter by attaching a custom signature before they are sent.

Function Documentation

email_example_form ( )

The contact form.

Definition at line 171 of file email_example.module.

References t().

email_example_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission logic for the contact form.

Definition at line 205 of file email_example.module.

References email_example_mail_send().

email_example_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation logic for the contact form.

Definition at line 196 of file email_example.module.

References form_set_error(), t(), and valid_email_address().

email_example_mail | ( |  | $key,
 |  | & | $message,
 |  |  | $params
 | ) |  |

Implement hook_mail().

This hook defines a list of possible e-mail templates that this module can send. Each e-mail is given a unique identifier, or 'key'.

$message comes in with some standard properties already set: 'to' address, 'from' address, and a set of default 'headers' from drupal_mail(). The goal of hook_mail() is to set the message's 'subject' and 'body' properties, as well as make any adjustments to the headers that are necessary.

The $params argument is an array which can hold any additional data required to build the mail subject and body; for example, user-entered form data, or some context information as to where the mail request came from.

Note that hook_mail() is not actually a hook. It is only called for a single module, the module named in the first argument of drupal_mail(). So it's a callback of a type, but not a hook.

Definition at line 40 of file email_example.module.

References check_plain(), language, t(), and variable_get().

email_example_mail_alter ( & $message )

Implement hook_mail_alter().

This function is not required to send an email using Drupal's mail system.

Hook_mail_alter() provides an interface to alter any aspect of email sent by Drupal. You can use this hook to add a common site footer to all outgoing email, add extra header fields, and/or modify the email in anyway. HTML-izing the outgoing email is one possibility.

Definition at line 133 of file email_example.module.

References language, and t().

email_example_mail_send ( $form_values )

Sends an e-mail.

Parameters
$form_values An array of values from the contact form fields that were submitted. There are just two relevant items: $form_values['email'] and $form_values['message'].

Definition at line 76 of file email_example.module.

References $module, drupal_mail(), drupal_set_message(), language_default(), t(), and variable_get().

Referenced by email_example_form_submit().

email_example_menu ( )

Implement hook_menu().

Set up a page with an e-mail contact form on it.

Definition at line 157 of file email_example.module.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Entity

Classes | Functions
Example: Entity
Examples

Classes

interface | EntityExampleBasicControllerInterface
class | EntityExampleBasicController

Functions

entity_example_schema ()
entity_example_entity_info ()
entity_example_basic_load ($basic_id=NULL, $reset=FALSE)
entity_example_basic_load_multiple ($basic_ids=FALSE, $conditions=array(), $reset=FALSE)
entity_example_basic_uri ($basic)
entity_example_menu ()
entity_example_info_page ()
entity_example_permission ()
entity_example_basic_list_entities ()
entity_example_basic_title ($entity)
entity_example_basic_view ($entity, $view_mode= 'tweaky')
entity_example_field_extra_fields ()
entity_example_basic_add ()
entity_example_basic_form ($form, &$form_state, $entity)
entity_example_basic_form_validate ($form, &$form_state)
entity_example_basic_form_submit ($form, &$form_state)
entity_example_basic_edit_delete ($form, &$form_state)
entity_example_basic_save (&$entity)
entity_example_basic_delete ($entity)

Detailed Description

Example creating a core Entity API entity.

Note that this example does not use or demonstrate the contrib Entity API, which you can find here: http://drupal.org/project/entity

Class Documentation

interface EntityExampleBasicControllerInterface

EntityExampleBasicControllerInterface definition.

We create an interface here because anyone could come along and use hook_entity_info_alter() to change our controller class. We want to let them know what methods our class needs in order to function with the rest of the module, so here's a handy list.

See Also
hook_entity_info_alter()

Definition at line 502 of file entity_example.module.

Inheritance diagram for EntityExampleBasicControllerInterface:
DrupalEntityControllerInterface EntityExampleBasicController

Public Member Functions

create ()
save ($entity)
delete ($entity)
- Public Member Functions inherited from DrupalEntityControllerInterface
resetCache (array $ids=NULL)
load ($ids=array(), $conditions=array())

Member Function Documentation

create ( )

Implemented in EntityExampleBasicController.

delete ( $entity )

Implemented in EntityExampleBasicController.

save ( $entity )

Implemented in EntityExampleBasicController.

class EntityExampleBasicController

EntityExampleBasicController extends DrupalDefaultEntityController.

Our subclass of DrupalDefaultEntityController lets us add a few important create, update, and delete methods.

Definition at line 515 of file entity_example.module.

Inheritance diagram for EntityExampleBasicController:
DrupalDefaultEntityController EntityExampleBasicControllerInterface DrupalEntityControllerInterface DrupalEntityControllerInterface

Public Member Functions

create ()
save ($entity)
delete ($entity)
delete_multiple ($entities)
- Public Member Functions inherited from DrupalDefaultEntityController
__construct ($entityType)
resetCache (array $ids=NULL)
load ($ids=array(), $conditions=array())

Additional Inherited Members

- Protected Member Functions inherited from DrupalDefaultEntityController
buildQuery ($ids, $conditions=array(), $revision_id=FALSE)
attachLoad (&$queried_entities, $revision_id=FALSE)
cacheGet ($ids, $conditions=array())
cacheSet ($entities)
- Protected Attributes inherited from DrupalDefaultEntityController
$entityCache
$entityType
$entityInfo
$hookLoadArguments
$idKey
$revisionKey
$revisionTable
$cache

Member Function Documentation

create ( )

Create and return a new entity_example_basic entity.

Implements EntityExampleBasicControllerInterface.

Definition at line 522 of file entity_example.module.

delete ( $entity )

Delete a single entity.

Really a convenience function for delete_multiple().

Implements EntityExampleBasicControllerInterface.

Definition at line 574 of file entity_example.module.

References delete_multiple().

delete_multiple ( $entities )

Delete one or more entity_example_basic entities.

Deletion is unfortunately not supported in the base DrupalDefaultEntityController class.

Parameters
$basic_ids An array of entity IDs or a single numeric ID.

Definition at line 587 of file entity_example.module.

References db_delete(), db_transaction(), field_attach_delete(), module_invoke_all(), and watchdog_exception().

Referenced by delete().

save ( $entity )

Saves the custom fields using drupal_write_record()

Implements EntityExampleBasicControllerInterface.

Definition at line 534 of file entity_example.module.

References drupal_write_record(), field_attach_insert(), field_attach_update(), and module_invoke_all().

Function Documentation

entity_example_basic_add ( )

Provides a wrapper on the edit form to add a new entity.

Definition at line 395 of file entity_example.module.

References drupal_get_form(), and entity_get_controller().

entity_example_basic_delete ( $entity )

Use the controller to delete the entity.

Definition at line 487 of file entity_example.module.

References entity_get_controller().

Referenced by entity_example_basic_edit_delete().

entity_example_basic_edit_delete | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form deletion handler.

Definition at line 468 of file entity_example.module.

References drupal_set_message(), entity_example_basic_delete(), and t().

entity_example_basic_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $entity
 | ) |  |

Form function to create an entity_example_basic entity.

The pattern is:

  • Set up the form for the data that is specific to your entity: the columns of your base table.
  • Call on the Field API to pull in the form elements for fields attached to the entity.

Definition at line 411 of file entity_example.module.

References field_attach_form(), and t().

entity_example_basic_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submit handler: submits basic_add_form information

Definition at line 455 of file entity_example.module.

References entity_example_basic_save(), and field_attach_submit().

entity_example_basic_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validation handler for entity_example_basic_add_form form. We pass things straight through to the Field API to handle validation of the attached fields.

Definition at line 447 of file entity_example.module.

References field_attach_form_validate().

entity_example_basic_list_entities ( )

Returns a render array with all entity_example_basic entities.

In this basic example we know that there won't be many entities, so we'll just load them all for display. See pager_example.module to implement a pager. Most implementations would probably do this with the contrib Entity API module, or a view using views module, but we avoid using non-core features in the Examples project.

See Also
pager_example.module

Definition at line 263 of file entity_example.module.

References $content, entity_example_basic_load_multiple(), l(), and t().

Referenced by entity_example_info_page().

entity_example_basic_load | ( | $basic_id = NULL,
 |  | $reset = FALSE
 | ) |

Fetch a basic object.

This function ends up being a shim between the menu system and entity_example_basic_load_multiple().

This function gets its name from the menu system's wildcard naming conventions. For example, /path/wildcard would end up calling wildcard_load(wildcard value). In our case defining the path: examples/entity_example/basic/entity_example_basic in hook_menu() tells Drupal to call entity_example_basic_load().

Parameters
$basic_id | Integer specifying the basic entity id.
$reset | A boolean indicating that the internal cache should be reset.
Returns
A fully-loaded $basic object or FALSE if it cannot be loaded.
See Also
entity_example_basic_load_multiple()
entity_example_menu()

Definition at line 118 of file entity_example.module.

References entity_example_basic_load_multiple().

entity_example_basic_load_multiple | ( | $basic_ids = FALSE,
 |  | $conditions = array(),
 |  | $reset = FALSE
 | ) |

Loads multiple basic entities.

We only need to pass this request along to entity_load(), which will in turn call the load() method of our entity controller class.

Definition at line 130 of file entity_example.module.

References entity_load().

Referenced by entity_example_basic_list_entities(), and entity_example_basic_load().

entity_example_basic_save ( & $entity )

We save the entity by calling the controller.

Definition at line 480 of file entity_example.module.

References entity_get_controller().

Referenced by entity_example_basic_form_submit().

entity_example_basic_title ( $entity )

Callback for a page title when this entity is displayed.

Definition at line 298 of file entity_example.module.

References t().

entity_example_basic_uri ( $basic )

Implements the uri callback.

Definition at line 137 of file entity_example.module.

entity_example_basic_view | ( | $entity,
 |  | $view_mode = 'tweaky'
 | ) |

Menu callback to display an entity.

As we load the entity for display, we're responsible for invoking a number of hooks in their proper order.

See Also
hook_entity_prepare_view()
hook_entity_view()
hook_entity_view_alter()

Definition at line 312 of file entity_example.module.

References drupal_alter(), entity_prepare_view(), field_attach_prepare_view(), field_attach_view(), format_date(), module_invoke_all(), and t().

entity_example_entity_info ( )

Implements hook_entity_info().

This is the fundamental description of the entity.

It provides a single entity with a single bundle and without revision support.

Definition at line 38 of file entity_example.module.

References $info, and t().

entity_example_field_extra_fields ( )

Implements hook_field_extra_fields().

This exposes the "extra fields" (usually properties that can be configured as if they were fields) of the entity as pseudo-fields so that they get handled by the Entity and Field core functionality. Node titles get treated in a similar manner.

Definition at line 367 of file entity_example.module.

References t().

entity_example_info_page ( )

Basic information for the page.

Definition at line 216 of file entity_example.module.

References $content, entity_example_basic_list_entities(), l(), t(), and user_access().

entity_example_menu ( )

Implements hook_menu().

Definition at line 146 of file entity_example.module.

References MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION, and MENU_LOCAL_TASK.

entity_example_permission ( )

Implements hook_permission().

Definition at line 234 of file entity_example.module.

References t().

entity_example_schema ( )

Implements hook_schema().

Definition at line 15 of file entity_example.install.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Field Types API

Functions
Example: Field Types API
Examples

Functions

field_example_field_schema ($field)
field_example_field_info ()
field_example_field_validate ($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
field_example_field_is_empty ($item, $field)
field_example_field_formatter_info ()
field_example_field_formatter_view ($entity_type, $entity, $field, $instance, $langcode, $items, $display)
field_example_field_widget_info ()
field_example_field_widget_form (&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
field_example_3text_validate ($element, &$form_state)
field_example_field_widget_error ($element, $error, $form, &$form_state)
field_example_menu ()
_field_example_page ()

Detailed Description

Examples using Field Types API.

This is updated from Barry Jaspan's presentation at Drupalcon Paris, Video Presentation

Providing a field requires:

  • Defining a field:
    • hook_field_info()
    • hook_field_schema()
    • hook_field_validate()
    • hook_field_is_empty()
  • Defining a formatter for the field (the portion that outputs the field for display):
    • hook_field_formatter_info()
    • hook_field_formatter_view()
  • Defining a widget for the edit form:
    • hook_field_widget_info()
    • hook_field_widget_form()

Our module defines the field in field_example_field_info(), field_example_field_validate() and field_example_field_is_empty(). field_example_field_schema() is implemented in field_example.install.

Our module sets up a formatter in field_example_field_formatter_info() and field_example_field_formatter_view(). These are the API hooks that present formatted and themed output to the user.

And finally, our module defines the widet in field_example_field_widget_info() and field_example_field_widget_form(). The widget is the form element used to receive input from the user when the field is being populated.

See Also
Field Types API
Field API

Function Documentation

_field_example_page ( )

A simple page to explain to the developer what to do.

Definition at line 383 of file field_example.module.

References t().

field_example_3text_validate | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Validate the individual fields and then convert them into a single HTML RGB value as text.

Definition at line 323 of file field_example.module.

References $value, form_error(), form_set_value(), and t().

field_example_field_formatter_info ( )

Implements hook_field_formatter_info().

We need to tell Drupal that we have two different types of formatters for this field. One will change the text color, and the other will change the background color.

See Also
field_example_field_formatter_view()

Definition at line 116 of file field_example.module.

References t().

field_example_field_formatter_view | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance,
 |  | $langcode,
 |  | $items,
 |  | $display
 | ) |

Implements hook_field_formatter_view().

Two formatters are implemented.

  • field_example_simple_text just outputs markup indicating the color that was entered and uses an inline style to set the text color to that value.
  • field_example_color_background does the same but also changes the background color of div.region-content.
See Also
field_example_field_formatter_info()

Definition at line 142 of file field_example.module.

References t().

field_example_field_info ( )

Implements hook_field_info().

Provides the description of the field.

Definition at line 58 of file field_example.module.

References t().

field_example_field_is_empty | ( | $item,
 |  | $field
 | ) |

Implements hook_field_is_empty().

hook_field_is_emtpy() is where Drupal asks us if this field is empty. Return TRUE if it does not contain data, FALSE if it does. This lets the form API flag an error when required fields are empty.

Definition at line 103 of file field_example.module.

field_example_field_schema ( $field )

Implements hook_field_schema().

Defines the database schema of the field, using the format used by the Schema API.

The data we will store here is just one 7-character element, even though the widget presents the three portions separately.

All implementations of hook_field_schema() must be in the module's .install file.

See Also
http://drupal.org/node/146939
Schema API
hook_field_schema()

Definition at line 24 of file field_example.install.

field_example_field_validate | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  | & | $errors
 | ) |  |

Implements hook_field_validate().

This hook gives us a chance to validate content that's in our field. We're really only interested in the $items parameter, since it holds arrays representing content in the field we've defined. We want to verify that the items only contain RGB hex values like this: #RRGGBB. If the item validates, we do nothing. If it doesn't validate, we add our own error notification to the $errors parameter.

See Also
field_example_field_widget_error()

Definition at line 82 of file field_example.module.

References t().

field_example_field_widget_error | ( |  | $element,
 |  |  | $error,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_field_widget_error().

hook_field_widget_error() lets us figure out what to do with errors we might have generated in hook_field_validate(). Generally, we'll just call form_error().

See Also
field_example_field_validate()
form_error()

Definition at line 357 of file field_example.module.

References form_error().

field_example_field_widget_form | ( | & | $form,
 |  | & | $form_state,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  |  | $delta,
 |  |  | $element
 | ) |  |

Implements hook_field_widget_form().

hook_widget_form() is where Drupal tells us to create form elements for our field's widget.

We provide one of three different forms, depending on the widget type of the Form API item provided.

The 'field_example_colorpicker' and 'field_example_text' are essentially the same, but field_example_colorpicker adds a javascript colorpicker helper.

field_example_3text displays three text fields, one each for red, green, and blue. However, the field type defines a single text column, rgb, which needs an HTML color spec. Define an element validate handler that converts our r, g, and b fields into a simulated single 'rgb' form element.

Definition at line 237 of file field_example.module.

References $title, $value, drupal_get_path(), and t().

field_example_field_widget_info ( )

Implements hook_field_widget_info().

Three widgets are provided.

  • A simple text-only widget where the user enters the '#ffffff'.
  • A 3-textfield widget that gathers the red, green, and blue values separately.
  • A farbtastic colorpicker widget that chooses the value graphically.

These widget types will eventually show up in hook_field_widget_form, where we will have to flesh them out.

See Also
field_example_field_widget_form()

Definition at line 201 of file field_example.module.

References t().

field_example_menu ( )

Implements hook_menu().

Provides a simple user interface that tells the developer where to go.

Definition at line 371 of file field_example.module.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Field Permissions

Functions
Example: Field Permissions
Examples

Functions

field_permission_example_field_schema ($field)
field_permission_example_permission ()
field_permission_example_field_access ($op, $field, $entity_type, $entity, $account)
field_permission_example_field_info ()
field_permission_example_field_is_empty ($item, $field)
field_permission_example_field_formatter_info ()
field_permission_example_field_formatter_view ($entity_type, $entity, $field, $instance, $langcode, $items, $display)
field_permission_example_field_widget_info ()
field_permission_example_field_widget_form (&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
field_permission_example_menu ()
_field_permission_example_page ()

Detailed Description

Example using permissions on a Field API field.

This example is a relatively simple text field you can attach to any fieldable entity.

In this module we demonstrate how to limit access to a field. Drupal's Field API gives you two operations to permit or restrict: view and edit. So you can then decide who gets to see fields, who can edit them, and who can manage them.

Our field is called field_permission_example_fieldnote. It has a simple default widget of a text area, and a default formatter that applies a CSS style to make it look like a sticky note.

In addition to demonstrating how to set up permissions-based access to a field, this module also demonstrates the absolute minimum required to implement a field, since it doesn't have any field settings. The tests also have a generalized field testing class, called FieldTestGeneric, which can be easily subclassed and reused for other fields.

If you wish to use this code as skeleton code for a field without permissions, you can simply remove field_permission_exampe_permission() and field_permission_field_access(). Also field_permission_example_menu() and _field_permission_example_page() are vestigial to the Examples project.

How does it work?

You can install this module and go to path /examples/field_permission_example for an introduction on how to use this field. Or see the same content at _field_permission_example_page().

OK, how does the code work?

As with any permission system, we implement hook_permission() in order to define a few permissions. In our case, users will want to either view or edit fieldnote fields. And, similar to the way node permissions work, we'll also include a context of either their own content or any content. So that gives us 4 permissions which administrators can assign to various roles. See field_permission_example_permission() for the list.

With our permissions defined in hook_permission(), we can now handle requests for access. Those come in through hook_field_access(), which we've implemented as field_permission_example_field_acces(). This function determines whether the user has the ability to view or edit the field in question by calling user_access(). We also give special edit access to users with the 'bypass node access' and 'administer content types' permissions, defined by the node module.

One tricky part is that our field won't always be attached to nodes. It could be attached to any type of entity. This means that there's no general way to figure out if the user 'owns' the entity or not. Since this is a simple example, we'll just check for 'any' access to unknown entity types. We'll also limit our known entity types to node and user, since those are easy to demonstrate.

In a real application, we'd have use-case specific permissions which might be more complex than these. Or perhaps simpler.

You can see a more complex field implementation in field_example.module.

See Also
Example: Field Types API
field_example.module
Field Types API
Field API

Function Documentation

_field_permission_example_page ( )

A simple page to explain to the developer what to do.

See Also
field_permission_example.module

Definition at line 317 of file field_permission_example.module.

References $page, l(), and t().

field_permission_example_field_access | ( | $op,
 |  | $field,
 |  | $entity_type,
 |  | $entity,
 |  | $account
 | ) |

Implements hook_field_access().

We want to make sure that fields aren't being seen or edited by those who shouldn't.

We have to build a permission string similar to those in hook_permission() in order to ask Drupal whether the user has that permission. Permission strings will end up being like 'view any fieldnote' or 'edit own fieldnote'.

The tricky thing here is that a field can be attached to any type of entity, so it's not always trivial to figure out whether $account 'owns' the entity. We'll support access restrictions for user and node entity types, and be permissive with others, since that's easy to demonstrate.

See Also
field_permission_example_permissions()

Definition at line 125 of file field_permission_example.module.

References $op, drupal_set_message(), t(), and user_access().

field_permission_example_field_formatter_info ( )

Implements hook_field_formatter_info().

We need to tell Drupal about our excellent field formatter.

It's some text in a div, styled to look like a sticky note.

See Also
field_permission_example_field_formatter_view()

Definition at line 203 of file field_permission_example.module.

References t().

field_permission_example_field_formatter_view | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance,
 |  | $langcode,
 |  | $items,
 |  | $display
 | ) |

Implements hook_field_formatter_view().

Here we output the field for general consumption.

The field will have a sticky note appearance, thanks to some simple CSS.

Note that all of the permissions and access logic happens in hook_field_access(), and none of it is here.

Definition at line 224 of file field_permission_example.module.

References check_plain(), and drupal_get_path().

field_permission_example_field_info ( )

Implements hook_field_info().

Provides the description of the field.

Definition at line 171 of file field_permission_example.module.

References t().

field_permission_example_field_is_empty | ( | $item,
 |  | $field
 | ) |

Implements hook_field_is_empty().

hook_field_is_emtpy() is where Drupal asks us if this field is empty. Return TRUE if it does not contain data, FALSE if it does. This lets the form API flag an error when required fields are empty.

Definition at line 190 of file field_permission_example.module.

field_permission_example_field_schema ( $field )

Implements hook_field_schema().

Defines the database schema of the field, using the format used by the Schema API.

We only want a simple text field, similar to the body of a node.

Note that this field has only a normal text (which translates to 16k of text in MySQL), and so therefore doesn't have an index. More complex schema would probably have at least one indexed column.

See Also
http://drupal.org/node/146939
Schema API
hook_field_schema()

Definition at line 25 of file field_permission_example.install.

field_permission_example_field_widget_form | ( | & | $form,
 |  | & | $form_state,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  |  | $delta,
 |  |  | $element
 | ) |  |

Implements hook_field_widget_form().

Drupal wants us to create a form for our field. We'll use something very basic like a default textarea.

See Also
field_permission_example_field_widget_info()

Definition at line 275 of file field_permission_example.module.

References $value.

field_permission_example_field_widget_info ( )

Implements hook_field_widget_info().

We're implementing just one widget: A basic textarea.

See Also
field_permission_example_field_widget_form()

Definition at line 258 of file field_permission_example.module.

References t().

field_permission_example_menu ( )

Implements hook_menu().

Provides a simple user interface that gives the developer some clues.

Definition at line 303 of file field_permission_example.module.

field_permission_example_permission ( )

Implements hook_permission().

We want to let site administrators figure out who should be able to view, edit, and administer our field.

Field permission operations can only be view or edit, in the context of one's own content or that of others. Constrast with content types where we also have to worry about who can create or delete content.

Definition at line 94 of file field_permission_example.module.

References t().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Files

Classes | Functions
Example: Files
Examples

Classes

class FileExampleSessionStreamWrapper

Functions

file_example_menu ()
file_example_permission ()
file_example_intro ()
file_example_readwrite ($form, &$form_state)
file_example_managed_write_submit ($form, &$form_state)
file_example_unmanaged_write_submit ($form, &$form_state)
file_example_unmanaged_php_submit ($form, &$form_state)
file_example_read_submit ($form, &$form_state)
file_example_delete_submit ($form, &$form_state)
file_example_file_check_exists_submit ($form, &$form_state)
file_example_create_directory_submit ($form, &$form_state)
file_example_delete_directory_submit ($form, &$form_state)
file_example_check_directory_submit ($form, &$form_state)
file_example_show_session_contents_submit ($form, &$form_state)
file_example_get_managed_file ($uri)
file_example_stream_wrappers ()
file_example_session_contents ()

Detailed Description

Examples demonstrating the Drupal File API (and Stream Wrappers).

The File Example module is a part of the Examples for Developers Project and provides various Drupal File API Examples. You can download and experiment with this code at the Examples for Developers project page.

See Drupal File API for handbook documentation on the File API and File summary on api.drupal.org for the function summary.

Class Documentation

class FileExampleSessionStreamWrapper

Example stream wrapper class to handle session:// streams.

This is just an example, as it could have horrible results if much information were placed in the $_SESSION variable. However, it does demonstrate both the read and write implementation of a stream wrapper.

A "stream" is an important Unix concept for the reading and writing of files and other devices. Reading or writing a "stream" just means that you open some device, file, internet site, or whatever, and you don't have to know at all what it is. All the functions that deal with it are the same. You can read/write more from/to the stream, seek a position in the stream, or anything else without the code that does it even knowing what kind of device it is talking to. This Unix idea is extended into PHP's mindset.

The idea of "stream wrapper" is that this can be extended indefinitely. The classic example is HTTP: With PHP you can do a file_get_contents("http://drupal.org/projects") as if it were a file, because the scheme "http" is supported natively in PHP. So Drupal adds the public:// and private:// schemes, and contrib modules can add any scheme they want to. This example adds the session:// scheme, which allows reading and writing the $_SESSION['file_example'] key as if it were a file.

Note that because this implementation uses simple PHP arrays ($_SESSION) it is limited to string values, so binary files will not work correctly. Only text files can be used.

Definition at line 40 of file file_example_session_streams.inc.

Inheritance diagram for FileExampleSessionStreamWrapper:
DrupalStreamWrapperInterface StreamWrapperInterface

Public Member Functions

__construct ()
setUri ($uri)
getUri ()
getTarget ($uri=NULL)
getDirectoryPath ()
getExternalUrl ()
chmod ($mode)
realpath ()
stream_open ($uri, $mode, $options, &$opened_path)
stream_lock ($operation)
stream_read ($count)
stream_write ($data)
stream_eof ()
stream_seek ($offset, $whence)
stream_flush ()
stream_tell ()
stream_stat ()
stream_close ()
unlink ($uri)
rename ($from_uri, $to_uri)
dirname ($uri=NULL)
mkdir ($uri, $mode, $options)
rmdir ($uri, $options)
url_stat ($uri, $flags)
dir_opendir ($uri, $options)
dir_readdir ()
dir_rewinddir ()
dir_closedir ()

Static Public Member Functions

static getMimeType ($uri, $mapping=NULL)

Public Attributes

$context

Protected Member Functions

getLocalPath ($uri=NULL)
& uri_to_session_key ($uri, $create=TRUE)

Protected Attributes

$uri
$session_content
$directory_pointer
$directory_keys
$stream_pointer

Constructor & Destructor Documentation

__construct ( )

Definition at line 82 of file file_example_session_streams.inc.

Member Function Documentation

chmod ( $mode )

We have no concept of chmod, so just return TRUE.

Implements DrupalStreamWrapperInterface.

Definition at line 174 of file file_example_session_streams.inc.

dir_closedir ( )

Support for closedir().

Returns
TRUE on success.
See Also
http://php.net/manual/en/streamwrapper.dir-closedir.php

Implements StreamWrapperInterface.

Definition at line 686 of file file_example_session_streams.inc.

dir_opendir | ( | $uri,
 |  | $options
 | ) |

Support for opendir().

Parameters
$uri | A string containing the URI to the directory to open.
$options | Unknown (parameter is not documented in PHP Manual).
Returns
TRUE on success.
See Also
http://php.net/manual/en/streamwrapper.dir-opendir.php

Implements StreamWrapperInterface.

Definition at line 634 of file file_example_session_streams.inc.

References $uri, and uri_to_session_key().

dir_readdir ( )

Support for readdir().

Returns
The next filename, or FALSE if there are no more files in the directory.
See Also
http://php.net/manual/en/streamwrapper.dir-readdir.php

Implements StreamWrapperInterface.

Definition at line 657 of file file_example_session_streams.inc.

References $directory_pointer.

dir_rewinddir ( )

Support for rewinddir().

Returns
TRUE on success.
See Also
http://php.net/manual/en/streamwrapper.dir-rewinddir.php

Implements StreamWrapperInterface.

Definition at line 674 of file file_example_session_streams.inc.

dirname ( $uri = NULL )

Gets the name of the directory from a given path.

Parameters
$uri A URI.
Returns
A string containing the directory name.
See Also
drupal_dirname()

Implements DrupalStreamWrapperInterface.

Definition at line 491 of file file_example_session_streams.inc.

References $uri, and getTarget().

getDirectoryPath ( )

Implements getDirectoryPath().

In this case there is no directory string, so return an empty string.

Definition at line 155 of file file_example_session_streams.inc.

getExternalUrl ( )

Overrides getExternalUrl().

We have set up a helper function and menu entry to provide access to this key via HTTP; normally it would be accessible some other way.

Implements DrupalStreamWrapperInterface.

Definition at line 165 of file file_example_session_streams.inc.

References $url, getLocalPath(), and url().

getLocalPath ( $uri = NULL )
protected

Returns the local path. Here we aren't doing anything but stashing the "file" in a key in the $_SESSION variable, so there's not much to do but to create a "path" which is really just a key in the $_SESSION variable. So something like 'session://one/two/three.txt' becomes $_SESSION['file_example']['one']['two']['three.txt'] and the actual path is "one/two/three.txt".

Parameters
$uri Optional URI, supplied when doing a move or rename.

Definition at line 197 of file file_example_session_streams.inc.

References $uri.

Referenced by getExternalUrl(), realpath(), rmdir(), unlink(), and uri_to_session_key().

static getMimeType | ( | $uri,
 |  | $mapping = NULL
 | ) |
static

Implements getMimeType().

Implements DrupalStreamWrapperInterface.

Definition at line 121 of file file_example_session_streams.inc.

References $uri, DRUPAL_ROOT, drupal_strtolower(), and file_mimetype_mapping().

getTarget ( $uri = NULL )

Implements getTarget().

The "target" is the portion of the URI to the right of the scheme. So in session://example/test.txt, the target is 'example/test.txt'.

Definition at line 106 of file file_example_session_streams.inc.

References $uri.

Referenced by dirname().

getUri ( )

Implements getUri().

Implements DrupalStreamWrapperInterface.

Definition at line 96 of file file_example_session_streams.inc.

References $uri.

mkdir | ( | $uri,
 |  | $mode,
 |  | $options
 | ) |

Support for mkdir().

Parameters
$uri | A string containing the URI to the directory to create.
$mode | Permission flags - see mkdir().
$options | A bit mask of STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE.
Returns
TRUE if directory was successfully created.
See Also
http://php.net/manual/en/streamwrapper.mkdir.php

Implements StreamWrapperInterface.

Definition at line 518 of file file_example_session_streams.inc.

References $uri, and uri_to_session_key().

realpath ( )

Implements realpath().

Implements DrupalStreamWrapperInterface.

Definition at line 181 of file file_example_session_streams.inc.

References getLocalPath().

rename | ( | $from_uri,
 |  | $to_uri
 | ) |

Support for rename().

Parameters
$from_uri,The | uri to the file to rename.
$to_uri | The new uri for file.
Returns
TRUE if file was successfully renamed.
See Also
http://php.net/manual/en/streamwrapper.rename.php

Implements StreamWrapperInterface.

Definition at line 469 of file file_example_session_streams.inc.

References uri_to_session_key().

rmdir | ( | $uri,
 |  | $options
 | ) |

Support for rmdir().

Parameters
$uri | A string containing the URI to the directory to delete.
$options | A bit mask of STREAM_REPORT_ERRORS.
Returns
TRUE if directory was successfully removed.
See Also
http://php.net/manual/en/streamwrapper.rmdir.php

Implements StreamWrapperInterface.

Definition at line 546 of file file_example_session_streams.inc.

References $uri, debug(), getLocalPath(), and t().

setUri ( $uri )

Implements setUri().

Implements DrupalStreamWrapperInterface.

Definition at line 89 of file file_example_session_streams.inc.

References $uri.

stream_close ( )

Support for fclose().

Returns
TRUE if stream was successfully closed.
See Also
http://php.net/manual/en/streamwrapper.stream-close.php

Implements StreamWrapperInterface.

Definition at line 424 of file file_example_session_streams.inc.

stream_eof ( )

Support for feof().

Returns
TRUE if end-of-file has been reached.
See Also
http://php.net/manual/en/streamwrapper.stream-eof.php

Implements StreamWrapperInterface.

Definition at line 350 of file file_example_session_streams.inc.

stream_flush ( )

Support for fflush().

Returns
TRUE if data was successfully stored (or there was no data to store). This always returns TRUE, as this example provides and needs no flush support.
See Also
http://php.net/manual/en/streamwrapper.stream-flush.php

Implements StreamWrapperInterface.

Definition at line 385 of file file_example_session_streams.inc.

stream_lock ( $operation )

Support for flock().

The $_SESSION variable has no locking capability, so return TRUE.

Parameters
$operation One of the following:
  • LOCK_SH to acquire a shared lock (reader).
  • LOCK_EX to acquire an exclusive lock (writer).
  • LOCK_UN to release a lock (shared or exclusive).
  • LOCK_NB if you don't want flock() to block while locking (not supported on Windows).
Returns
Always returns TRUE at the present time. (no support)
See Also
http://php.net/manual/en/streamwrapper.stream-lock.php

Implements StreamWrapperInterface.

Definition at line 294 of file file_example_session_streams.inc.

stream_open | ( |  | $uri,
 |  |  | $mode,
 |  |  | $options,
 |  | & | $opened_path
 | ) |  |

Opens a stream, as for fopen(), file_get_contents(), file_put_contents()

Parameters
$uri | A string containing the URI to the file to open.
$mode | The file mode ("r", "wb" etc.).
$options | A bit mask of STREAM_USE_PATH and STREAM_REPORT_ERRORS.
&$opened_path | A string containing the path actually opened.
Returns
Returns TRUE if file was opened successfully. (Always returns TRUE).
See Also
http://php.net/manual/en/streamwrapper.stream-open.php

Implements StreamWrapperInterface.

Definition at line 224 of file file_example_session_streams.inc.

References $uri, and uri_to_session_key().

stream_read ( $count )

Support for fread(), file_get_contents() etc.

Parameters
$count Maximum number of bytes to be read.
Returns
The string that was read, or FALSE in case of an error.
See Also
http://php.net/manual/en/streamwrapper.stream-read.php

Implements StreamWrapperInterface.

Definition at line 309 of file file_example_session_streams.inc.

References $stream_pointer, drupal_strlen(), and drupal_substr().

stream_seek | ( | $offset,
 |  | $whence
 | ) |

Support for fseek().

Parameters
$offset | The byte offset to got to.
$whence | SEEK_SET, SEEK_CUR, or SEEK_END.
Returns
TRUE on success.
See Also
http://php.net/manual/en/streamwrapper.stream-seek.php

Implements StreamWrapperInterface.

Definition at line 367 of file file_example_session_streams.inc.

References drupal_strlen().

stream_stat ( )

Support for fstat().

Returns
An array with file status, or FALSE in case of an error - see fstat() for a description of this array.
See Also
http://php.net/manual/en/streamwrapper.stream-stat.php

Implements StreamWrapperInterface.

Definition at line 410 of file file_example_session_streams.inc.

References drupal_strlen().

stream_tell ( )

Support for ftell().

Returns
The current offset in bytes from the beginning of file.
See Also
http://php.net/manual/en/streamwrapper.stream-tell.php

Implements StreamWrapperInterface.

Definition at line 397 of file file_example_session_streams.inc.

References $stream_pointer.

stream_write ( $data )

Support for fwrite(), file_put_contents() etc.

Parameters
$data The string to be written.
Returns
The number of bytes written (integer).
See Also
http://php.net/manual/en/streamwrapper.stream-write.php

Implements StreamWrapperInterface.

Definition at line 333 of file file_example_session_streams.inc.

References check_plain(), and drupal_strlen().

unlink ( $uri )

Support for unlink().

Parameters
$uri A string containing the uri to the resource to delete.
Returns
TRUE if resource was successfully deleted.
See Also
http://php.net/manual/en/streamwrapper.unlink.php

Implements StreamWrapperInterface.

Definition at line 441 of file file_example_session_streams.inc.

References $uri, getLocalPath(), and t().

& uri_to_session_key | ( | $uri,
 |  | $create = TRUE
 | ) |
protected

Return a reference to the correct $_SESSION key.

Parameters
$uri | The uri: session://something
$create | If TRUE, create the key
Returns
A reference to the array at the end of the key-path, or FALSE if the path doesn't map to a key-path (and $create is FALSE).

Definition at line 249 of file file_example_session_streams.inc.

References $uri, and getLocalPath().

Referenced by dir_opendir(), mkdir(), rename(), stream_open(), and url_stat().

url_stat | ( | $uri,
 |  | $flags
 | ) |

Support for stat().

This important function goes back to the Unix way of doing things. In this example almost the entire stat array is irrelevant, but the mode is very important. It tells PHP whether we have a file or a directory and what the permissions are. All that is packed up in a bitmask. This is not normal PHP fodder.

Parameters
$uri | A string containing the URI to get information about.
$flags | A bit mask of STREAM_URL_STAT_LINK and STREAM_URL_STAT_QUIET.
Returns
An array with file status, or FALSE in case of an error - see fstat() for a description of this array.
See Also
http://php.net/manual/en/streamwrapper.url-stat.php

Implements StreamWrapperInterface.

Definition at line 581 of file file_example_session_streams.inc.

References $uri, drupal_strlen(), and uri_to_session_key().

Member Data Documentation

$context

Definition at line 46 of file file_example_session_streams.inc.

$directory_keys
protected

List of keys in a given directory.

Definition at line 75 of file file_example_session_streams.inc.

$directory_pointer
protected

Pointer to where we are in a directory read.

Definition at line 70 of file file_example_session_streams.inc.

Referenced by dir_readdir().

$session_content
protected

The content of the stream.

Since this trivial example just uses the $_SESSION variable, this is simply a reference to the contents of the related part of $_SESSION['file_example'].

Definition at line 65 of file file_example_session_streams.inc.

$stream_pointer
protected

The pointer to the next read or write within the session variable.

Definition at line 80 of file file_example_session_streams.inc.

Referenced by stream_read(), and stream_tell().

$uri
protected

Definition at line 56 of file file_example_session_streams.inc.

Referenced by dir_opendir(), dirname(), getLocalPath(), getMimeType(), getTarget(), getUri(), mkdir(), rmdir(), setUri(), stream_open(), unlink(), uri_to_session_key(), and url_stat().

Function Documentation

file_example_check_directory_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to test directory existence. This actually just checks to see if the directory is writable

Parameters
$form
$form_state

Definition at line 437 of file file_example.module.

References drupal_set_message(), and t().

file_example_create_directory_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for directory creation. Here we create a directory and set proper permissions on it using file_prepare_directory().

Definition at line 392 of file file_example.module.

References drupal_set_message(), FILE_CREATE_DIRECTORY, FILE_MODIFY_PERMISSIONS, file_prepare_directory(), and t().

file_example_delete_directory_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for directory deletion.

See Also
file_unmanaged_delete_recursive()

Definition at line 417 of file file_example.module.

References drupal_set_message(), file_unmanaged_delete_recursive(), and t().

file_example_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to delete a file.

Definition at line 341 of file file_example.module.

References drupal_set_message(), file_delete(), file_example_get_managed_file(), file_unmanaged_delete(), and t().

file_example_file_check_exists_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to check existence of a file.

Definition at line 377 of file file_example.module.

References drupal_set_message(), and t().

file_example_get_managed_file ( $uri )

Utility function to check for and return a managed file. In this demonstration code we don't necessarily know if a file is managed or not, so often need to check to do the correct behavior. Normal code would not have to do this, as it would be working with either managed or unmanaged files.

Parameters
$uri The URI of the file, like public://test.txt.

Definition at line 471 of file file_example.module.

References db_query(), and file_load().

Referenced by file_example_delete_submit().

file_example_intro ( )

A simple introduction to the workings of this module.

Definition at line 64 of file file_example.module.

References t().

file_example_managed_write_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to write a managed file.

The key functions used here are:

  • file_save_data(), which takes a buffer and saves it to a named file and also creates a tracking record in the database and returns a file object. In this function we use FILE_EXISTS_RENAME (the default) as the argument, which means that if there's an existing file, create a new non-colliding filename and use it.
  • file_create_url(), which converts a URI in the form public://junk.txt or private://something/test.txt into a URL like http://example.com/sites/default/files/junk.txt.

Definition at line 197 of file file_example.module.

References $url, drupal_set_message(), file_create_url(), FILE_EXISTS_RENAME, file_save_data(), l(), and t().

file_example_menu ( )

Implements hook_menu() to set up the URLs (menu entries) for the file examples.

Definition at line 27 of file file_example.module.

References MENU_CALLBACK.

file_example_permission ( )

Implements hook_permission().

Definition at line 53 of file file_example.module.

References t().

file_example_read_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for reading a stream wrapper.

Drupal now has full support for PHP's stream wrappers, which means that instead of the traditional use of all the file functions ($fp = fopen("/tmp/some_file.txt");) far more sophisticated and generalized (and extensible) things can be opened as if they were files. Drupal itself provides the public:// and private:// schemes for handling public and private files. PHP provides file:// (the default) and http://, so that a URL can be read or written (as in a POST) as if it were a file. In addition, new schemes can be provided for custom applications, as will be demonstrated below.

Here we take the stream wrapper provided in the form. We grab the contents with file_get_contents(). Notice that's it's as simple as that: file_get_contents("http://example.com") or file_get_contents("public://somefile.txt") just works. Although it's not necessary, we use file_unmanaged_save_data() to save this file locally and then find a local URL for it by using file_create_url().

Definition at line 308 of file file_example.module.

References $url, drupal_set_message(), file_create_url(), file_munge_filename(), file_unmanaged_save_data(), l(), and t().

file_example_readwrite | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form builder function for the file example readwrite and directory creation example.

A simple form that allows creation of a file, managed or unmanaged. It also allows reading/deleting a file and creation of a directory.

Definition at line 75 of file file_example.module.

References t().

file_example_session_contents ( )

Show the contents of a session file.

This page callback function is called by the Menu API for the path examples/file_example/access_session. Any extra path elements beyond this are considered to be the session path. E.g.: examples/file_example/access_session/foo/bar.txt would be the equivalent of session://foo/bar.txt, which will map into $_SESSION as keys: $_SESSION['foo']['bar.txt']

Parameters
$path-elements The elements of the path will come from Menu API as the function arguments. See explanation above.
Returns
A message containing the contents of the session file.
See Also
file_get_contents()

Definition at line 518 of file file_example.module.

References $content, check_plain(), and t().

file_example_show_session_contents_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Utility submit function to show the contents of $_SESSION.

Definition at line 451 of file file_example.module.

References drupal_set_message(), module_exists(), and t().

file_example_stream_wrappers ( )

Implements hook_stream_wrappers(). hook_stream_wrappers() is Drupal's way of exposing the class that PHP will use to provide a new stream wrapper class. In this case, we'll expose the 'session' scheme, so a file reference like "session://example/example.txt" is readable and writable as a location in the $_SESSION variable.

See Also
FileExampleSessionStreamWrapper

Definition at line 489 of file file_example.module.

References t().

file_example_unmanaged_php_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to write an unmanaged file using plain PHP functions.

The key functions used here are:

  • file_unmanaged_save_data(), which takes a buffer and saves it to a named file, but does not create any kind of tracking record in the database.
  • file_create_url(), which converts a URI in the form public://junk.txt or private://something/test.txt into a URL like http://example.com/sites/default/files/junk.txt.
  • drupal_tempnam() generates a temporary filename for use.

Definition at line 256 of file file_example.module.

References $url, drupal_set_message(), drupal_tempnam(), file_create_url(), l(), and t().

file_example_unmanaged_write_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to write an unmanaged file.

The key functions used here are:

  • file_unmanaged_save_data(), which takes a buffer and saves it to a named file, but does not create any kind of tracking record in the database. This example uses FILE_EXISTS_REPLACE for the third argument, meaning that if there's an existing file at this location, it should be replaced.
  • file_create_url(), which converts a URI in the form public://junk.txt or private://something/test.txt into a URL like http://example.com/sites/default/files/junk.txt.

Definition at line 226 of file file_example.module.

References $url, drupal_set_message(), file_create_url(), FILE_EXISTS_REPLACE, file_unmanaged_save_data(), l(), and t().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Filter

Functions
Example: Filter
Examples

Functions

filter_example_menu ()
filter_example_help ($path, $arg)
_filter_example_information ()
filter_example_filter_info ()
_filter_example_filter_foo_settings ($form, $form_state, $filter, $format, $defaults)
_filter_example_filter_foo_process ($text, $filter, $format)
_filter_example_filter_foo_tips ($filter, $format, $long=FALSE)
_filter_example_filter_time_prepare ($text, $filter)
_filter_example_filter_time_process ($text, $filter)
_filter_example_filter_time_tips ($filter, $format, $long=FALSE)

Detailed Description

Demonstrates the creation of filters.

This is an example outlining how a module can be used to define a filter to be run on user-submitted content before it is output to the browser.

To show all the capabilities of the filter system, we will define two filters in this module. One will substitute the string "foo" with an administratively-defined replacement string. The other will find a custom XML tag, <time>, and replace it by the current time.

Foo filter

Drupal has several content formats (they are not filters), and in our example the foo replacement can be configured for each one of them, allowing an html or php replacement, so the module includes a settings callback, with options to configure that replacements. Also, a Tips callback will help showing the current replacement for the content type being edited.

Time filter.

This filter is a little trickier to implement than the previous one. Since the input involves special HTML characters (< and >) we have to run the filter before HTML is escaped/stripped by other filters. But we want to use HTML in our result as well, and so if we run this filter first our replacement string could be escaped or stripped. The solution is to use the "prepare" operation to escape the special characters, and to later replace our escaped version in the "process" step.

Function Documentation

_filter_example_filter_foo_process | ( | $text,
 |  | $filter,
 |  | $format
 | ) |

Foo filter process callback.

The actual filtering is performed here. The supplied text should be returned, once any necessary substitutions have taken place. The example just replaces foo with our custom defined string in the settings page.

Definition at line 141 of file filter_example.module.

_filter_example_filter_foo_settings | ( | $form,
 |  | $form_state,
 |  | $filter,
 |  | $format,
 |  | $defaults
 | ) |

Settings callback for foo filter

Make use of $format to have different replacements for every input format. Since we allow the administrator to define the string that gets substituted when "foo" is encountered, we need to provide an interface for this kind of customization. The object format is also an argument of the callback.

The settings defined in this form are stored in database by the filter module, and they will be available in the $filter argument.

Definition at line 124 of file filter_example.module.

References t().

_filter_example_filter_foo_tips | ( | $filter,
 |  | $format,
 |  | $long = FALSE
 | ) |

Filter tips callback for foo filter.

The tips callback allows filters to provide help text to users during the content editing process. Short tips are provided on the content editing screen, while long tips are provided on a separate linked page. Short tips are optional, but long tips are highly recommended.

Definition at line 155 of file filter_example.module.

References t().

_filter_example_filter_time_prepare | ( | $text,
 |  | $filter
 | ) |

Time filter prepare callback.

We'll use [filter-example-time] as a replacement for the time tag. Note that in a more complicated filter a closing tag may also be required. For more information, see "Temporary placeholders and delimiters" at http://drupal.org/node/209715.

Definition at line 174 of file filter_example.module.

_filter_example_filter_time_process | ( | $text,
 |  | $filter
 | ) |

Time filter process callback.

Now, in the "process" step, we'll search for our escaped time tags and do the real filtering: replace the xml tag with the date.

Definition at line 184 of file filter_example.module.

References format_date().

_filter_example_filter_time_tips | ( | $filter,
 |  | $format,
 |  | $long = FALSE
 | ) |

Filter tips callback for time filter.

The tips callback allows filters to provide help text to users during the content editing process. Short tips are provided on the content editing screen, while long tips are provided on a separate linked page. Short tips are optional, but long tips are highly recommended.

Definition at line 197 of file filter_example.module.

References t().

_filter_example_information ( )

Simply returns a little bit of information about the example.

Definition at line 65 of file filter_example.module.

References l(), and t().

Referenced by filter_example_help().

filter_example_filter_info ( )

Implements hook_filter_info().

Here we define the different filters provided by the module. For this example, time_filter is a very static and simple replacement, but it requires some preparation of the string because of the special html tags < and >. The foo_filter is more complex, including its own settings and inline tips.

Definition at line 82 of file filter_example.module.

References t().

filter_example_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 55 of file filter_example.module.

References _filter_example_information().

filter_example_menu ( )

Implements hook_menu().

Definition at line 43 of file filter_example.module.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Form API

Functions
Example: Form API
Examples

Functions

form_example_menu ()
form_example_intro ()
form_example_help ($path, $arg)
form_example_element_info ()
form_example_theme ($existing, $type, $theme, $path)
form_example_states_form ($form, &$form_state)
form_example_tutorial ()
form_example_tutorial_1 ($form, &$form_state)
form_example_tutorial_2 ($form, &$form_state)
form_example_tutorial_3 ($form, &$form_state)
form_example_tutorial_4 ($form, &$form_state)
form_example_tutorial_5 ($form, &$form_state)
form_example_tutorial_7 ($form, &$form_state)
form_example_tutorial_8 ($form, &$form_state)
form_example_tutorial_9 ($form, &$form_state)
form_example_tutorial_10 ($form_state)
_form_example_steps ()
form_example_wizard ($form, &$form_state)
form_example_wizard_previous_submit ($form, &$form_state)
form_example_wizard_next_submit ($form, &$form_state)
form_example_wizard_personal_info ($form, &$form_state)
form_example_wizard_location_info ($form, &$form_state)
form_example_wizard_location_info_validate ($form, &$form_state)
form_example_wizard_other_info ($form, &$form_state)
form_example_wizard_submit ($form, &$form_state)

Detailed Description

Examples demonstrating the Drupal Form API.

The Form Example module is a part of the Examples for Developers Project and provides various Drupal Form API Examples. You can download and experiment with this code at the Examples for Developers project page.

Function Documentation

_form_example_steps ( )

Extensible wizard form example.

This is an example of a multistep form using a wizard style. It will include the 'Previous' and 'Next' buttons when required, and a 'Finish' button at the last stage of the form submission.

This example is an extensible skeleton that can include (even programatically) more steps. The demonstration form includes three steps, each step having its own validation functions.

How to extend this example:

  • Steps are defined in the _form_example_steps() function. Include or alter the steps as you require.
  • For each step, implement the corresponding 'form' function (see 'form_example_wizard_personal_info' for the first step in this example.) Each step is a regular form, and the wizard collects all the values of the included forms.
  • Optionally, you may include custom validation functions using the regular validation hook (formname_validate). The wizard uses these validation functions for each step.
  • The most important customization step is to change the submit handler and do whatever you want with the collected information. In this case, the example just shows the collected values in the various steps. Returns the list of steps and their associated forms. This has been separated to clarify and easy the understanding of this example. You should edit this function to include the steps your wizard/multistep form requires.
Returns
$array

Definition at line 44 of file form_example_wizard.inc.

Referenced by form_example_wizard().

form_example_element_info ( )

Implements hook_element_info().

To keep the various pieces of the example together in external files, this just returns _form_example_elements().

Definition at line 197 of file form_example.module.

References _form_example_element_info().

form_example_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 176 of file form_example.module.

References $help, and t().

form_example_intro ( )

Page callback for our general info page.

Definition at line 168 of file form_example.module.

References t().

form_example_menu ( )

Implements hook_menu().

Here we set up the URLs (menu entries) for the form examples. Note that most of the menu items have page callbacks and page arguments set, with page arguments set to be functions in external files.

Definition at line 28 of file form_example.module.

References MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_TASK, and MENU_NORMAL_ITEM.

form_example_states_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

This form shows off the #states system by dynamically showing parts of the form based on the state of other parts.

The basic idea is that you add a #states property to the element which is to be changed based on some action elsewhere on the form. The #states property lists a change which is to be made, and under what conditions that change should be made.

For example, in the 'tests_taken' form element below we have:

* '#states' => array(
* 'visible' => array(
* ':input[name="student_type"]' => array('value' => 'high_school'),
* ),
* ),
*

Meaning that the element is to be made visible when the condition is met. The condition is a combination of a jQuery selector (which selects the element we want to test) and a condition for that element. In this case, the condition is whether the return value of the 'student_type' element is 'high_school'. If it is, this element will be visible.

So the syntax is:

* '#states' => array(
* 'action_to_take_on_this_form_element' => array(
* 'jquery_selector_for_another_element' => array('condition_type' => value),
* ),
* ),
*

If you need an action to take place only when two different conditions are true, then you add both of those conditions to the action. See the 'country_writein' element below for an example.

Note that the easiest way to select a textfield, checkbox, or select is with the ':input' jquery shortcut , which selects any any of those.

There are examples below of changing or hiding an element when a checkbox is checked, when a textarea is filled, when a select has a given value.

See drupal_process_states() for full documentation.

See also –topics–forms_api_reference.html/7#states Form API Reference

Definition at line 58 of file form_example_states.inc.

References drupal_map_assoc(), and t().

form_example_theme | ( | $existing,
 |  | $type,
 |  | $theme,
 |  | $path
 | ) |

Implements hook_theme().

The only theme implementation is by the element example. To keep the various parts of the example together, this actually returns _form_example_element_theme().

Definition at line 209 of file form_example.module.

References _form_example_element_theme().

form_example_tutorial ( )

Main Form tutorial page.

See Also
form_example_tutorial_1()
form_example_tutorial_2()
form_example_tutorial_3()
form_example_tutorial_4()
form_example_tutorial_5()
form_example_tutorial_6()
form_example_tutorial_7()
form_example_tutorial_8()
form_example_tutorial_9()
form_example_tutorial_10()

Definition at line 31 of file form_example_tutorial.inc.

References t().

form_example_tutorial_1 | ( |  | $form,
 |  | & | $form_state
 | ) |  |

This first form function is from the Form Tutorial handbook page

It just creates a very basic form with a textfield.

This function is called the "form constructor function". It builds the form. It takes a two arguments, $form and $form_state, but if drupal_get_form() sends additional arguments, they will be provided after $form_state.

Definition at line 48 of file form_example_tutorial.inc.

References t().

form_example_tutorial_10 ( $form_state )

Example 10: A form with a file upload field.

This example allows the user to upload a file to Drupal which is stored physically and with a reference in the database.

See Also
form_example_tutorial_10_submit()
form_example_tutorial_10_validate()

Definition at line 711 of file form_example_tutorial.inc.

References t().

form_example_tutorial_2 | ( |  | $form,
 |  | & | $form_state
 | ) |  |

This is Example 2, a basic form with a submit button.

See Also
http://drupal.org/node/717726

Definition at line 71 of file form_example_tutorial.inc.

References t().

form_example_tutorial_3 | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Example 3: A basic form with fieldsets.

We establish a fieldset element and then place two text fields within it, one for a first name and one for a last name. This helps us group related content.

Study the code below and you'll notice that we renamed the array of the first and last name fields by placing them under the $form['name'] array. This tells Form API these fields belong to the $form['name'] fieldset.

Definition at line 106 of file form_example_tutorial.inc.

References t().

form_example_tutorial_4 | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Example 4: Basic form with required fields.

Definition at line 141 of file form_example_tutorial.inc.

References t().

form_example_tutorial_5 | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Example 5: Basic form with additional element attributes.

This demonstrates additional attributes of text form fields.

For a more extensive example on element types

See Also
http://drupal.org/node/751826

See the complete form reference

Definition at line 189 of file form_example_tutorial.inc.

References t().

form_example_tutorial_7 | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Example 7: With a submit handler.

From the handbook page: http://drupal.org/node/717740

See Also
form_example_tutorial_7_validate()
form_example_tutorial_7_submit()

Definition at line 310 of file form_example_tutorial.inc.

References t().

form_example_tutorial_8 | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Example 8: A simple multistep form with a Next and a Back button.

Handbook page: http://drupal.org/node/717750.

For more extensive multistep forms, see form_example_wizard.inc

Adds logic to our form builder to give it two pages. The AJAX Example's Wizard Example gives an AJAX version of this same idea.

See Also
form_example_tutorial_8_page_two()
form_example_tutorial_8_page_two_back()
form_example_tutorial_8_page_two_submit()
form_example_tutorial_8_next_submit()
form_example_tutorial.inc

Definition at line 392 of file form_example_tutorial.inc.

References form_example_tutorial_8_page_two(), and t().

form_example_tutorial_9 | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Example 9: A form with a dynamically added new fields.

This example adds default values so that when the form is rebuilt, the form will by default have the previously-entered values.

From handbook page http://drupal.org/node/717746.

See Also
form_example_tutorial_9_add_name()
form_example_tutorial_9_remove_name()
form_example_tutorial_9_submit()
form_example_tutorial_9_validate()

Definition at line 571 of file form_example_tutorial.inc.

References t().

form_example_wizard | ( |  | $form,
 |  | & | $form_state
 | ) |  |

The primary formbuilder function for the wizard form. This is the form that you should call with drupal_get_form() from your code, and it will include the rest of the step forms defined. You are not required to change this function, as this will handle all the step actions for you.

This form has two defined submit handlers to process the different steps:

  • Previous: handles the way to get back one step in the wizard.
  • Next: handles each step form submission,

The third handler, the finish button handler, is the default form _submit handler used to process the information.

You are not required to change the next or previous handlers, but you must change the form_example_wizard_sbumit handler to perform the operations you need on the collected information.

Definition at line 77 of file form_example_wizard.inc.

References _form_example_steps(), drupal_set_title(), and t().

form_example_wizard_location_info | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Returns form elements for the 'location info' page of the wizard. This is the second step of the wizard. This step asks for a textfield value: a City. This step also includes a validation declared later.

Definition at line 233 of file form_example_wizard.inc.

References t().

form_example_wizard_location_info_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Custom validation form for the 'location info' page of the wizard.

This is the validation function for the second step of the wizard. The city cannot be empty or be "San Francisco".

Definition at line 254 of file form_example_wizard.inc.

References form_set_error(), and t().

form_example_wizard_next_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for the 'next' button.

  • Saves away $form_state['values']
  • Increments the step count.
  • Replace $form_state['values'] from the last time we were at this page or with array() if we haven't been here before.
  • Force form rebuild.

You are not required to change this function.

Parameters
$form
$form_state

Definition at line 175 of file form_example_wizard.inc.

form_example_wizard_other_info | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Returns form elements for the 'other info' page of the wizard. This is the thid and last step of the example wizard.

Definition at line 266 of file form_example_wizard.inc.

References t().

form_example_wizard_personal_info | ( |  | $form,
 |  | & | $form_state
 | ) |  |

The previous code was a 'skeleton' of a multistep wizard form. You are not required to change a line on the previous code (apart from defining your own steps in the _form_example_steps() function.

All the code included from here is the content of the wizard, the steps of the form.

First, let's show the defined steps for the wizard example. Returns form elements for the 'personal info' page of the wizard. This is the first step of the wizard, asking for two textfields: first name and last name.

Definition at line 211 of file form_example_wizard.inc.

References t().

form_example_wizard_previous_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for the "previous" button.

  • Stores away $form_state['values']
  • Decrements the step counter
  • Replaces $form_state['values'] with the values from the previous state.
  • Forces form rebuild.

You are not required to change this function.

Definition at line 150 of file form_example_wizard.inc.

form_example_wizard_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Wizard form submit handler.

  • Saves away $form_state['values']
  • Process all the form values.

This demonstration handler just do a drupal_set_message() with the information collected on each different step of the wizard.

Parameters
$form
$form_state

Definition at line 291 of file form_example_wizard.inc.

References $value, drupal_set_message(), and t().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Image

Functions
Example: Image
Examples

Functions

image_example_install ()
image_example_uninstall ()
image_example_enable ()
image_example_disable ()
image_example_menu ()
image_example_help ($path)
image_example_image_default_styles ()
image_example_image_style_save ($style)
image_example_image_style_delete ($style)
image_example_style_flush ($style)
image_example_image_styles_alter (&$styles)
image_example_image_effect_info ()
image_example_colorize_form ($data)
image_example_colorize_effect (&$image, $data)
image_example_theme ()
theme_image_example_colorize_summary ($variables)
image_example_style_form ($form, &$form_state)
image_example_style_form_validate ($form, &$form_state)
image_example_style_form_submit ($form, &$form_state)
theme_image_example_image ($variables)

Detailed Description

Demonstrates the basic use of image API.

This module demonstrates the use of Drupal 7's new image styles and effects including the following topics.

  • Define default image styles in code. Useful for modules that want to ship with predefined image styles and for site developers who want their image style configurations to be in version control. hook_image_default_styles().
  • Define new image effects. Demonstrates how a module can add additional effects to the options available when creating image styles. hook_image_effect_info().
  • Alter existing image styles. Demonstrates the use of hook_image_styles_alter() to modify existing image effects, especially those defined by other modules in hook_image_default_styles() without having to override the styles.
  • Demonstrates the use of hook_image_style_save() and hook_image_style_delete() to update module specific variables when an image style is either re-named or deleted.
  • Generate a form with a field of type #managed_file that allows the user to upload an image and choose a style to use when displaying that image.
  • Demonstrates the use of theme_image_style() to display images using an image style.
See Also
hook_image_default_styles().
hook_image_effect_info().
hook_image_style_save().
hook_image_style_delete().
theme_image_style().

Function Documentation

image_example_colorize_effect | ( | & | $image,
 |  |  | $data
 | ) |  |

Image effect callback; Colorize an image resource.

Parameters
$image An image object returned by image_load().
$data An array of attributes to use when performing the colorize effect with the following items:
  • "color": The web-style hex color to use when colorizing the image.
Returns
TRUE on success. FALSE on failure to colorize image.

Definition at line 305 of file image_example.module.

References watchdog(), and WATCHDOG_ERROR.

image_example_colorize_form ( $data )

Form Builder; Configuration settings for colorize effect.

Create a $form array with the fields necessary for configuring the image_example_colorize effect.

Note that this is not a complete form, it only contains the portion of the form for configuring the colorize options. Therefore it does not not need to include metadata about the effect, nor a submit button.

Parameters
$data The current configuration for this colorize effect.

Definition at line 276 of file image_example.module.

References t().

image_example_disable ( )

Implements hook_disable().

Definition at line 51 of file image_example.install.

References image_example_enable().

image_example_enable ( )

Implements hook_enable().

Definition at line 34 of file image_example.install.

References $styles, image_style_flush(), and image_styles().

Referenced by image_example_disable().

image_example_help ( $path )

Implements hook_help().

Definition at line 63 of file image_example.module.

References $output, l(), and t().

image_example_image_default_styles ( )

Implements hook_image_default_styles().

hook_image_default_styles() declares to Drupal any image styles that are provided by the module. An image style is a collection of image effects that are performed in a specified order, manipulating the image and generating a new derivative image.

This hook can be used to declare image styles that your module depends on or allow you to define image styles in code and gain the benefits of using a version control system.

Definition at line 84 of file image_example.module.

References $styles.

image_example_image_effect_info ( )

Implements hook_image_effect_info().

This hook allows your module to define additional image manipulation effects that can be used with image styles.

Definition at line 231 of file image_example.module.

References t().

image_example_image_style_delete ( $style )

Implements hook_image_style_delete().

This hook allows modules to respond to image styles being deleted.

See Also
image_example_style_save()

Definition at line 157 of file image_example.module.

References variable_get(), and variable_set().

image_example_image_style_save ( $style )

Implements hook_image_style_save().

Allows modules to respond to updates to an image style's settings.

Definition at line 136 of file image_example.module.

References variable_get(), and variable_set().

image_example_image_styles_alter ( & $styles )

Implements hook_image_styles_alter().

Allows your module to modify, add, or remove image styles provided by other modules. The best use of this hook is to modify default styles that have not been overriden by the user. Altering styles that have been overriden by the user could have an adverse affect on the user experience. If you add an effect to a style through this hook and the user attempts to remove the effect it will immediatly be re-applied.

Definition at line 204 of file image_example.module.

References $styles, IMAGE_STORAGE_DEFAULT, and t().

image_example_install ( )

Implements hook_install().

Definition at line 13 of file image_example.install.

References variable_set().

image_example_menu ( )

Implements hook_menu().

Provide a menu item and a page to demonstrate features of this example module.

Definition at line 48 of file image_example.module.

image_example_style_flush ( $style )

Implements hook_image_style_flush().

This hook allows modules to respond when a style is being flushed. Styles are flushed any time a style is updated, an effect associated with the style is updated, a new effect is added to the style, or an existing effect is removed.

Flushing removes all images generated using this style from the host. Once a style has been flushed derivative images will need to be regenerated. New images will be generated automatically as needed but it is worth noting that on a busy site with lots of images this could have an impact on performance.

Note: This function does not currently have any effect as the example module does not use any caches. It is demonstrated here for completeness sake only.

Definition at line 184 of file image_example.module.

References cache_clear_all().

image_example_style_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form for uploading and displaying an image using selected style.

This page provides a form that allows the user to upload an image and choose a style from the list of defined image styles to use when displaying the the image. This serves as an example of integrating image styles with your module and as a way to demonstrate that the styles and effects defined by this module are available via Drupal's image handling system.

See Also
theme_image_style()

Definition at line 21 of file image_example.pages.inc.

References file_load(), image_style_options(), t(), theme(), and variable_get().

image_example_style_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form Builder; Display a form for uploading an image.

Definition at line 79 of file image_example.pages.inc.

References drupal_set_message(), file_delete(), file_load(), file_save(), FILE_STATUS_PERMANENT, file_usage_add(), file_usage_delete(), t(), variable_get(), and variable_set().

image_example_style_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Verifies that the user supplied an image with the form..

Definition at line 68 of file image_example.pages.inc.

References form_set_error(), and t().

image_example_theme ( )

Implements hook_theme().

Definition at line 355 of file image_example.module.

image_example_uninstall ( )

Implements hook_uninstall().

Definition at line 24 of file image_example.install.

References variable_del().

theme_image_example_colorize_summary ( $variables )

Formats a summary of an image colorize effect.

Parameters
$variables An associative array containing:
  • data: The current configuration for this colorize effect.

Definition at line 374 of file image_example.module.

References t().

theme_image_example_image ( $variables )

Theme function displays an image rendered using the specified style.

Definition at line 135 of file image_example.pages.inc.

References $output, t(), and theme().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: JavaScript

Functions
Example: JavaScript
Examples

Functions

js_example_theme ()
js_example_menu ()
js_example_js_weights ()
js_example_accordion ()

Detailed Description

Examples using Drupal 7's built-in JavaScript.

Function Documentation

js_example_accordion ( )

js_example_accordion implementation.

Definition at line 74 of file js_example.module.

References $output, $title, drupal_render(), and t().

js_example_js_weights ( )

js_example_weights implementation.

Definition at line 48 of file js_example.module.

References $output, drupal_add_css(), drupal_add_js(), and drupal_get_path().

js_example_menu ( )

Implements hook_menu().

Definition at line 30 of file js_example.module.

js_example_theme ( )

Implements hook_theme().

Definition at line 18 of file js_example.module.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Menu

Functions
Example: Menu
Examples

Functions

menu_example_menu ()
_menu_example_basic_instructions ($content=NULL)
_menu_example_menu_page ($content=NULL, $arg1=NULL, $arg2=NULL)
menu_example_permission ()
menu_example_custom_access ($role_name)
_menu_example_mappings ($id)
menu_example_id_load ($id)
menu_example_menu_alter (&$items)
_menu_example_simple_title_callback ($base_string)
menu_example_user_page_title ($account)
menu_example_menu_link_alter (&$item, $menu)
menu_example_arg_optional_load ($id)
menu_example_arg_optional_to_arg ($arg)

Detailed Description

Demonstrates uses of the Menu APIs in Drupal.

The Page Example module also talks about the menu system, as well as how to use menu arguments to generate pages.

See Also
hook_menu()
hook_menu_alter()
hook_menu_link_alter()
Example: Page
page_example_menu()

Function Documentation

_menu_example_basic_instructions ( $content = NULL )

Page callback for the simplest introduction menu entry.

Parameters
$content Some content passed in.

Definition at line 324 of file menu_example.module.

References $content, and t().

_menu_example_mappings ( $id )

Utility function to provide mappings from integers to some strings. This would normally be some database lookup to get an object or array from a key.

Parameters
$id
Returns
The string to which the integer key mapped, or NULL if it did not map.

Definition at line 391 of file menu_example.module.

Referenced by menu_example_arg_optional_load(), and menu_example_id_load().

_menu_example_menu_page | ( | $content = NULL,
 |  | $arg1 = NULL,
 |  | $arg2 = NULL
 | ) |

Page callback for use with most of the menu entries. The arguments it receives determine what it outputs.

Parameters
$content | The base content to output.
$arg1 | First additional argument from the path used to access the menu
$arg2 | Second additional argument.

Definition at line 343 of file menu_example.module.

References $content, $output, and t().

_menu_example_simple_title_callback ( $base_string )

Title callback to rewrite the '/user' menu link.

Parameters
$base_string string to be prepended to current user's name.

Definition at line 466 of file menu_example.module.

References t().

menu_example_arg_optional_load ( $id )

Loads an item based on its $id.

In this case we're just creating a more extensive string. In a real example we would load or create some type of object.

Parameters
$id

Definition at line 509 of file menu_example.module.

References _menu_example_mappings(), and t().

menu_example_arg_optional_to_arg ( $arg )

A to_arg() function is used to provide a default for the arg in the wildcard. The purpose is to provide a menu link that will function if no argument is given. For example, in the case of the menu item 'examples/menu_example/default_arg/menu_example_arg_optional' the third argument is required, and the menu system cannot make a menu link using this path since it contains a placeholder. However, when the to_arg() function is provided, the menu system will create a menu link pointing to the path which would be created with the to_arg() function filling in the menu_example_arg_optional.

Parameters
$arg The arg (URL fragment) to be tested.

Definition at line 533 of file menu_example.module.

menu_example_custom_access ( $role_name )

Determine whether the current user has the role specified.

Parameters
$role_name The role required for access
Returns
bool True if the acting user has the role specified.

Definition at line 376 of file menu_example.module.

menu_example_id_load ( $id )

The special _load function to load menu_example.

Given an integer $id, load the string that should be associated with it. Normally this load function would return an array or object with more information.

Parameters
$id The integer to load.
Returns
A string loaded from the integer.

Definition at line 418 of file menu_example.module.

References _menu_example_mappings(), and t().

menu_example_menu ( )

Implements hook_menu().

Definition at line 27 of file menu_example.module.

References MENU_CALLBACK, MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_TASK, t(), and url().

menu_example_menu_alter ( & $items )

Implements hook_menu_alter().

Changes the path 'examples/menu_example/menu_original_path' to 'examples/menu_example/menu_altered_path'. Changes the title callback of the 'user/UID' menu item.

Remember that hook_menu_alter() only runs at menu_rebuild() time, not every time the page is built, so this typically happens only at cache clear time.

Parameters
$items The complete list of menu router items ready to be written to the menu_router table.

Definition at line 443 of file menu_example.module.

menu_example_menu_link_alter | ( | & | $item,
 |  |  | $menu
 | ) |  |

Implements hook_menu_link_alter().

This code will get the chance to alter a menu link when it is being saved in the menu interface at admin/build/menu. Whatever we do here overrides anything the user/administrator might have been trying to do.

Parameters
$item | The menu item being saved.
$menu | The entire menu router table.

Definition at line 493 of file menu_example.module.

menu_example_permission ( )

Implements hook_permission() to provide a demonstration access string.

Definition at line 359 of file menu_example.module.

References t().

menu_example_user_page_title ( $account )

Title callback to rename the title dynamically, based on user_page_title().

Parameters
$account User account related to the visited page.

Definition at line 477 of file menu_example.module.

References format_username(), and t().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Node Access

Functions | Variables
Example: Node Access
Examples

Functions

node_access_example_menu ()
node_access_example_private_node_listing ()
node_access_example_permission ()
node_access_example_node_access ($node, $op, $account)
node_access_example_node_grants ($account, $op)
node_access_example_node_access_records ($node)
node_access_example_form_alter (&$form, $form_state)
node_access_example_node_load ($nodes, $types)
node_access_example_node_delete ($node)
node_access_example_node_insert ($node)
node_access_example_node_update ($node)

Variables

const NODE_ACCESS_EXAMPLE_GRANT_ALL 23

Detailed Description

Demonstrates node access.

This is an example demonstrating how to grant or deny access to nodes using the Drupal core API node access system.

This module will add a 'private' flag for each node, which the node's author can manage. Nodes marked private can only be viewed, edited, or deleted by the author. However, not everything is as private as it seems on the internet, and so we need to implement some ways to allow other users to manage this 'private' content.

We will use the node grant system to specify which users are allowed to view, edit, or delete 'private' content. We will also allow a user named 'foobar' to have edit privileges on private content as well.

In addition, we will provide a page which will show some minimal instructions, and statistics on private nodes on the site.

We use NodeAPI hooks to put a single marker on a node, called 'private'. The marker is implemented by a database table which has one row per node simply indicating that the node is private. If the "private" marker is set, users other than the owner and privileged users are denied access.

Standard permissions are defined which allow users with 'access any private content' or 'edit any private content' to override the 'private' node access restrictions.

A separate access realm grants privileges to each node's author, so that they can always view, edit, and delete their own private nodes.

The only page provided by this module gives a rundown of how many nodes are marked private, and how many of those are accessible to the current user. This demonstrates the use of the 'node_access' tag in node queries, preventing disclosure of information which should not be shown to users who don't have the proper permissions.

Most relevant functions:

  • node_access_example_permission()
  • node_access_example_node_access()
  • node_access_example_node_access_records()
  • node_access_example_node_grants()

Drupal's node access system has three layers.

  • Overall override permissions. User 1 and any user with 'bypass node access' permission are automatically granted access.
  • hook_node_access() gives each module the opportunity to approve or deny access. Any module that returns NODE_ACCESS_DENY from hook_node_access() will result in denial of access. If no module denies access and one or more modules allow access, then access is granted. hook_node_access() was introduced in Drupal 7.
  • If no resolution has yet been reached, then the node_access table is used along with hook_node_grants(). (Drupal updates the node_access table when nodes are saved, by calling hook_node_access_records().)

Note that the hook_node_grants()/hook_node_access_records() layer is a first-grant-wins system, which means a module using it can't deny access to a node. Contributed modules have been developed to overcome this shortcoming, with their own APIs, such as ACL. ACL, in fact, has emerged as the more-or-less standard solution for fine-grained access control, and you really should be reading up on it. Many modules use it, and if your module implements another node access system, there could be chaos.

A list of the many node access modules (and differing APIs) is here: Overview of Node Access Modules. Note that this is Drupal 6 documentation, linked here so the reader can understand the historical reasons for using contributed node access modules such as ACL.

See Also
node_access()
hook_node_access()
hook_node_grants()
hook_node_access_records()

Function Documentation

node_access_example_form_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_alter().

This module adds a simple checkbox to the node form labeled private. If the checkbox is checked, only the node author and users with 'access any private content' privileges may see it.

Definition at line 365 of file node_access_example.module.

References t().

node_access_example_menu ( )

Implements hook_menu().

This path provides a page, with some instructions for the user, and some statistics about node access changes implemented by this module.

See Also
hook_menu()

Definition at line 97 of file node_access_example.module.

node_access_example_node_access | ( | $node,
 |  | $op,
 |  | $account
 | ) |

Implements hook_node_access().

Allows view and edit access to private nodes, when the account requesting access has the username 'foobar'.

hook_node_access() was introduced in Drupal 7. We use it here to demonstrate allowing certain privileges to an arbitrary user.

See Also
hook_node_access()

Definition at line 212 of file node_access_example.module.

References $op, drupal_set_message(), NODE_ACCESS_ALLOW, NODE_ACCESS_IGNORE, and t().

node_access_example_node_access_records ( $node )

Implements hook_node_access_records().

All node access modules must implement this hook. If the module is interested in the privacy of the node passed in, return a list of node access values for each grant ID we offer.

In this example, for each node which is marked 'private,' we define three realms:

The first and second are realms are 'node_access_example_view' and 'node_access_example_edit,' which have a single grant ID, 1. The user is either a member of these realms or not, depending upon the operation and the access permission set.

The third is node_access_example_author. It gives the node author special privileges. node_access_example_author has one grant ID for every UID, and each user is automatically a member of the group where GID == UID. This has the effect of giving each user their own grant ID for nodes they authored, within this realm.

Drupal calls this hook when a node is saved, or when access permissions change in order to rebuild the node access database table(s).

The array you return will define the realm and the grant ID for the given node. This is stored in the {node_access} table for subsequent comparison against the user's realm and grant IDs, which you'll supply in hook_node_grants().

Realm names and grant IDs are arbitrary. Official drupal naming conventions do not cover access realms, but since all realms are stored in the same database table, it's probably a good idea to use descriptive names which follow the module name, such as 'mymodule_realmname'.

See Also
node_access_example_node_grants()

Definition at line 321 of file node_access_example.module.

References NODE_ACCESS_EXAMPLE_GRANT_ALL.

node_access_example_node_delete ( $node )

Implements hook_node_delete().

Delete the node_access_example record when the node is deleted.

See Also
nodeapi_example.module

Definition at line 403 of file node_access_example.module.

References db_delete().

node_access_example_node_grants | ( | $account,
 |  | $op
 | ) |

Implements hook_node_grants().

Tell the node access system what grant IDs the user belongs to for each realm, based on the operation being performed.

When the user tries to perform an operation on the node, Drupal calls hook_node_grants() to determine grant ID and realm for the user. Drupal looks up the grant ID and realm for the node, and compares them to the grant ID and realm provided here. If grant ID and realm match for both user and node, then the operation is allowed.

Grant ID and realm are both determined per node, by your module in hook_node_access_records().

In our example, we've created three access realms: One for authorship, and two that track with the permission system.

We always add node_access_example_author to the list of grants, with a grant ID equal to their user ID. We do this because in our model, authorship always gives you permission to edit or delete your nodes, even if they're marked private.

Then we compare the user's permissions to the operation to determine whether the user falls into the other two realms: node_access_example_view, and/or node_access_example_edit. If the user has the 'access any private content' permission we defined in hook_permission(), they're declared as belonging to the node_access_example_realm. Similarly, if they have the 'edit any private content' permission, we add the node_access_example_edit realm to the list of grants they have.

See Also
node_access_example_permission()
node_access_example_node_access_records()

Definition at line 267 of file node_access_example.module.

References $op, NODE_ACCESS_EXAMPLE_GRANT_ALL, and user_access().

node_access_example_node_insert ( $node )

Implements hook_node_insert().

Insert a new access record when a node is created.

See Also
nodeapi_example.module

Definition at line 413 of file node_access_example.module.

References db_insert(), drupal_set_message(), and t().

Referenced by node_access_example_node_update().

node_access_example_node_load | ( | $nodes,
 |  | $types
 | ) |

Implements hook_node_load().

Gather and add the private setting for the nodes Drupal is loading.

See Also
nodeapi_example.module

Definition at line 390 of file node_access_example.module.

References db_query().

node_access_example_node_update ( $node )

Implements hook_node_update().

If the record in the node_access_example table already exists, we must update it. If it doesn't exist, we create it.

See Also
nodeapi_example.module

Definition at line 427 of file node_access_example.module.

References db_query(), db_update(), drupal_set_message(), node_access_example_node_insert(), and t().

node_access_example_permission ( )

Implements hook_permission().

We create two permissions, which we can use as a base for our grant/deny decision:

  • 'access any private content' allows global access to content marked private by other users.
  • 'edit any private content' allows global edit privileges, basically overriding the node access system.

Note that the 'edit any * content' and 'delete any * content' permissions will allow edit or delete permissions to the holder, regardless of what this module does.

See Also
hook_permissions()

Definition at line 188 of file node_access_example.module.

References t().

node_access_example_private_node_listing ( )

Our hook_menu() page callback function.

Information for the user about what nodes are marked private on the system and which of those the user has access to.

The queries showing what is accessible to the current user demonstrate the use of the 'node_access' tag to make sure that we don't show inappropriate information to unprivileged users.

Returns
Page content.
See Also
Example: Page

Definition at line 120 of file node_access_example.module.

References $content, db_select(), l(), t(), and theme().

Variable Documentation

const NODE_ACCESS_EXAMPLE_GRANT_ALL 23

Here we define a constant for our node access grant ID, for the node_access_example_view and node_access_example_edit realms. This ID could be any integer, but here we choose 23, because it is this author's favorite number.

Definition at line 231 of file node_access_example.module.

Referenced by node_access_example_node_access_records(), and node_access_example_node_grants().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Node

Functions
Example: Node
Examples

Functions

node_example_menu ()
node_example_node_info ()
node_example_node_type_insert ($content_type)
node_example_form ($node, $form_state)
node_example_page ()
node_example_entity_info_alter (&$entity_info)
node_example_field_formatter_info ()
node_example_field_formatter_view ($object_type, $object, $field, $instance, $langcode, $items, $display)
node_example_theme ($existing, $type, $theme, $path)
node_example_help ($path, $arg)
theme_example_node_color ($variables)
_node_example_installed_fields ()
_node_example_installed_instances ()

Detailed Description

Example defining a node type in code.

This is an example outlining how a module can be used to define a new node type. Our example node type will allow users to specify multiple "colors", a "quantity" and an "image" for their nodes; some kind of rudimentary inventory-tracking system, perhaps?

The basic pattern for defining a node type is to tell Drupal about the node's fields and view modes. Drupal will then take over and manage the storage for this node type. This differs from Drupal 6, where we would have to handle all the database storage ourselves in the module.

Remember that most node types do not require any custom code, as one simply creates them using the Drupal user interface. Creating a node like this in code is a special case.

At absolute minimum, in order to provide a content type for node, you have to implement hook_node_info() and hook_form(). Node can take care of the rest, if you want it to.

First and foremost, defining a node type happens in hook_node_info(). Our implementation of this hook gives Drupal an array of information about the content type we want to create.

Next, since we want to add fields to our content type, we implement hook_node_type_insert(), which gives us a chance to modify recently-created content types.

Drupal is able to handle deletion of our content, including dependencies based on re-use of our field instances, so we don't have to manage any of it.

In previous versions of Drupal, "teaser" and "page" were node view modes. In Drupal 7 we can define custom view modes to let the node know how it should return it's data. This module declares a custom view mode called "example_node_list".

Consult the Field API Tutorial and Field API Handbook Page and Field API documentation .

See Also
field_example.module

Function Documentation

_node_example_installed_fields ( )

Define the fields for our content type.

This big array is factored into this function for readability.

Returns
An associative array specifying the fields we wish to add to our new node type.

Definition at line 291 of file node_example.module.

Referenced by node_example_node_type_insert().

_node_example_installed_instances ( )

Define the field instances for our content type.

The instance lets Drupal know which widget to use to allow the user to enter data and how to react in different view modes. We are going to display a page that uses a custom "node_example_list" view mode. We will set a cardinality of three allowing our content type to give the user three color fields.

This big array is factored into this function for readability.

Returns
An associative array specifying the instances we wish to add to our new node type.

Definition at line 329 of file node_example.module.

References t().

Referenced by node_example_node_type_insert().

node_example_entity_info_alter ( & $entity_info )

Implements hook_entity_info_alter().

We need to modify the default node entity info by adding a new view mode to be used in functions like node_view() or node_build_content().

Definition at line 203 of file node_example.module.

References t().

node_example_field_formatter_info ( )

Implements hook_field_formatter_info().

Definition at line 215 of file node_example.module.

References t().

node_example_field_formatter_view | ( | $object_type,
 |  | $object,
 |  | $field,
 |  | $instance,
 |  | $langcode,
 |  | $items,
 |  | $display
 | ) |

Implements hook_field_formatter_view().

Definition at line 230 of file node_example.module.

References theme().

node_example_form | ( | $node,
 |  | $form_state
 | ) |

Implement hook_form().

Drupal needs for us to provide a form that lets the user add content. This is the form that the user will see if they go to node/add/node-example.

You can get fancy with this form, or you can just punt and return the default form that node_content will provide.

Definition at line 154 of file node_example.module.

References node_content_form().

node_example_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 261 of file node_example.module.

References t(), and url().

node_example_menu ( )

Implements hook_menu().

We are providing a default page to illustrate the use of our custom node view mode that will live at http://example.com/?q=examples/node_example

Definition at line 65 of file node_example.module.

node_example_node_info ( )

Implements hook_node_info().

We use hook_node_info() to define our node content type.

Definition at line 79 of file node_example.module.

References t().

node_example_node_type_insert ( $content_type )

Implements hook_node_type_insert().

Much like hook_node_insert() lets us know that a node is being inserted into the database, hook_node_type_insert() lets us know that a new content type has been inserted.

Since Drupal will at some point insert our new content type, this gives us a chance to add the fields we want.

It is called for all inserts to the content type database, so we have to make sure we're only modifying the type we're concerned with.

Definition at line 112 of file node_example.module.

References _node_example_installed_fields(), _node_example_installed_instances(), field_create_field(), field_create_instance(), field_update_instance(), node_add_body_field(), and t().

node_example_page ( )

Callback that builds our content and returns it to the browser.

This callback comes from hook_menu().

Returns
a build array a renderable array showing a list of our nodes.
See Also
node_load()
node_view()
node_example_field_formatter_view()

Definition at line 171 of file node_example.module.

References $row, db_query(), node_load(), node_view(), and t().

node_example_theme | ( | $existing,
 |  | $type,
 |  | $theme,
 |  | $path
 | ) |

Implements hook_theme().

This lets us tell Drupal about our theme functions and their arguments.

Definition at line 250 of file node_example.module.

theme_example_node_color ( $variables )

A custom theme function.

By using this function to format our node-specific information, themes can override this presentation if they wish. This is a simplifed theme function purely for illustrative purposes.

Definition at line 277 of file node_example.module.

References $output.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: NodeAPI

Functions
Example: NodeAPI
Examples

Functions

nodeapi_example_schema ()
nodeapi_example_uninstall ()
nodeapi_example_form_alter (&$form, $form_state, $form_id)
nodeapi_example_node_validate ($node, $form)
nodeapi_example_node_load ($nodes, $types)
nodeapi_example_node_insert ($node)
nodeapi_example_node_delete ($node)
nodeapi_example_node_update ($node)
nodeapi_example_node_view ($node, $build_mode= 'full')
nodeapi_example_theme ()
theme_nodeapi_example_rating ($variables)

Detailed Description

Example using NodeAPI.

This is an example demonstrating how a module can be used to extend existing node types.

hook_nodeapi() has been replaced in Drupal 7 with a set of different hooks providing the same or improved functionality. See the NodeAPI hooks list at api.drupal.org (linked below).

We will add the ability for each node to have a "rating," which will be a number from one to five. The rating will be tracked using the revision system also, so every node revision may have different rating values.

See Also
Node API Hooks

Function Documentation

nodeapi_example_form_alter | ( | & | $form,
 |  |  | $form_state,
 |  |  | $form_id
 | ) |  |

Implements hook_form_alter().

By implementing this hook, we're able to modify any form. We'll only make changes to two types: a node's content type configuration and edit forms.

We need to have a way for administrators to indicate which content types should have our rating field added. This is done by inserting radios in the node's content type configuration page.

Changes made by this hook will be shown when editing the settings of any content type.

Optionally, hook_form_FORM_ID_alter() could be used with the function name nodeapi_example_form_node_type_form_alter

Definition at line 45 of file nodeapi_example.module.

References t(), and variable_get().

nodeapi_example_node_delete ( $node )

Implements hook_node_delete().

When a node is deleted, we need to remove all related records from our table, including all revisions. For the delete operations we use node->nid.

Definition at line 174 of file nodeapi_example.module.

References db_delete().

nodeapi_example_node_insert ( $node )

Implements hook_node_insert().

As a new node is being inserted into the database, we need to do our own database inserts.

Definition at line 155 of file nodeapi_example.module.

References db_insert(), and variable_get().

Referenced by nodeapi_example_node_update().

nodeapi_example_node_load | ( | $nodes,
 |  | $types
 | ) |

Implements hook_node_load().

Loads the rating information if available for any of the nodes in the argument list.

Definition at line 110 of file nodeapi_example.module.

References db_select(), and variable_get().

nodeapi_example_node_update ( $node )

Implements hook_node_update().

As an existing node is being updated in the database, we need to do our own database updates.

This hook is called when an existing node has been changed. We can't simply update, since the node may not have a rating saved, thus no database field. So we first check the database for a rating. If there is one, we update it. Otherwise, we call nodeapi_example_node_insert() to create one.

Definition at line 192 of file nodeapi_example.module.

References db_select(), db_update(), nodeapi_example_node_insert(), and variable_get().

nodeapi_example_node_validate | ( | $node,
 |  | $form
 | ) |

Implements hook_node_validate().

Check that the rating attribute is set in the form submission, since the field is required. If not, send error message.

Definition at line 96 of file nodeapi_example.module.

References form_set_error(), t(), and variable_get().

nodeapi_example_node_view | ( | $node,
 |  | $build_mode = 'full'
 | ) |

Implements hook_node_view().

This is a typical implementation that simply runs the node text through the output filters.

Finally, we need to take care of displaying our rating when the node is viewed. This operation is called after the node has already been prepared into HTML and filtered as necessary, so we know we are dealing with an HTML teaser and body. We will inject our additional information at the front of the node copy.

Using node API 'hook_node_view' is more appropriate than using a filter here, because filters transform user-supplied content, whereas we are extending it with additional information.

Definition at line 232 of file nodeapi_example.module.

References theme(), and variable_get().

nodeapi_example_schema ( )

Implements hook_schema().

Definition at line 13 of file nodeapi_example.install.

nodeapi_example_theme ( )

Implements hook_theme().

This lets us tell Drupal about our theme functions and their arguments.

Definition at line 248 of file nodeapi_example.module.

nodeapi_example_uninstall ( )

Implements hook_uninstall().

We need to clean up our variables data when uninstalling our module.

Our implementation of nodeapi_example_form_alter() automatically creates a nodeapi_example_node_type_<contentType> variable for each node type the user wants to rate.

To delete our variables we call variable_del for our variables' namespace, 'nodeapi_example_node_type_'. Note that an average module would have known variables that it had created, and it could just delete those explicitly. For example, see render_example_uninstall(). It's important not to delete variables that might be owned by other modules, so normally we would just explicitly delete a set of known variables.

hook_uninstall() will only be called when uninstalling a module, not when disabling a module. This allows our data to stay in the database if the user only disables our module without uninstalling it.

Definition at line 70 of file nodeapi_example.install.

References $results, db_select(), and variable_del().

theme_nodeapi_example_rating ( $variables )

A custom theme function.

By using this function to format our rating, themes can override this presentation if they wish; for example, they could provide a star graphic for the rating. We also wrap the default presentation in a CSS class that is prefixed by the module name. This way, style sheets can modify the output without requiring theme code.

Definition at line 265 of file nodeapi_example.module.

References $output, and t().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Page

Functions
Example: Page
Examples

Functions

page_example_help ($path, $arg)
page_example_permission ()
page_example_menu ()
page_example_description ()
page_example_simple ()
page_example_arguments ($first, $second)

Detailed Description

This example demonstrates how a module can display a page at a given URL.

It's important to understand how the menu system works in order to implement your own pages. See the Menu Example module for some insight.

See Also
Example: Menu

Function Documentation

page_example_arguments | ( | $first,
 |  | $second
 | ) |

A more complex page callback that takes arguments.

This callback is mapped to the path 'examples/page_example/arguments/%/'.

The % arguments are passed in from the page URL. In our hook_menu implementation we instructed the menu system to extract the last two parameters of the path and pass them to this function as arguments.

This function also demonstrates a more complex render array in the returned values. Instead of just rendering the HTML with a theme('item_list'), the list is left unrendered, and a theme attached to it so that it can be rendered as late as possible, giving more parts of the system a chance to change it if necessary.

Consult Render Arrays documentation for details.

Definition at line 182 of file page_example.module.

References drupal_access_denied(), and t().

page_example_description ( )

Constructs a descriptive page.

Our menu maps this function to the path 'examples/page_example'.

Definition at line 144 of file page_example.module.

References t(), and url().

page_example_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Through hook_help(), a module can make documentation available to the user for the module as a whole or for specific paths. Where the help appears depends on the $path specified.

In the first example below, the help text will appear on the simple page defined in hook_menu below in the region designated for help text.

In the second example, the text will be available through the module page as a link beside the module or on the admin help page (admin/help) in the list of help topics using the name of the module. To specify help in the admin section use the module name in the path as in the second case below.

See Also
hook_help()

Definition at line 37 of file page_example.module.

References t().

page_example_menu ( )

Implements hook_menu().

Because hook_menu() registers URL paths for items defined by the function, it is necessary for modules that create pages. Each item can also specify a callback function for a given URL. The menu items returned here provide this information to the menu system.

We will define some menus, and their paths will be interpreted as follows:

If the user accesses http://example.com/?q=examples/page_example/simple, the menu system will first look for a menu item with that path. In this case it will find a match, and execute page_example_simple().

If the user accesses http://example.com/?q=examples/page_example/arguments, the menu system will find no explicit match, and will fall back to the closest match, 'examples/page_example', executing page_example_description().

If the user accesses http://example.com/?q=examples/page_example/arguments/1/2, the menu system will first look for examples/page_example/arguments/1/2. Not finding a match, it will look for examples/page_example/arguments/1/%. Again not finding a match, it will look for examples/page_example/arguments/%/2. Yet again not finding a match, it will look for examples/page_example/arguments/%/%. This time it finds a match, and so will execute page_example_arguments(1, 2). Since the parameters are passed to the function after the match, the function can do additional checking or make use of them before executing the callback function.

See Also
hook_menu()
Example: Menu

Definition at line 102 of file page_example.module.

References MENU_CALLBACK.

page_example_permission ( )

Implements hook_permission().

Since the access to our new custom pages will be granted based on special permissions, we need to define what those permissions are here. This ensures that they are available to enable on the user role administration pages.

Definition at line 57 of file page_example.module.

References t().

page_example_simple ( )

Constructs a simple page.

The simple page callback, mapped to the path 'examples/page_example/simple'.

Page callbacks return a renderable array with the content area of the page. The theme system will later render and surround the content in the appropriate blocks, navigation, and styling.

If you do not want to use the theme system (for example for outputting an image or XML), you should print the content yourself and not return anything.

Definition at line 160 of file page_example.module.

References t().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Pager

Functions
Example: Pager
Examples

Functions

pager_example_help ($path, $arg)
pager_example_menu ()
pager_example_page ()

Detailed Description

Example of a results pager.

Function Documentation

pager_example_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 24 of file pager_example.module.

References t().

pager_example_menu ( )

Implements hook_menu().

Definition at line 34 of file pager_example.module.

pager_example_page ( )

Build the pager query

Uses the date_formats table since it is installed with ~35 rows in it and we don't have to create fake data in order to show this example.

Returns
A render array completely set up with a pager.

Definition at line 54 of file pager_example.module.

References $header, $row, db_select(), and t().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Queue

Functions
Example: Queue
Examples

Functions

queue_example_menu ()
queue_example_add_remove_form ($form, &$form_state)
queue_example_add_remove_form_insert ($form, &$form_state)
queue_example_show_queue ($form, &$form_state)
queue_example_add_remove_form_claim ($form, &$form_state)
queue_example_add_remove_form_delete ($form, &$form_state)
queue_example_add_remove_form_run_cron ($form, &$form_state)
queue_example_add_remove_form_clear_queue ($form, &$form_state)
queue_example_retrieve_queue ($queue_name)
theme_queue_items ($variables)
queue_example_theme ()

Detailed Description

Demonstrating the Queue API

The Queue API provides a traditional FIFO (first-in-first-out) queue, but also provides the concepts of:

  • "Creating" a queued item, which means inserting it into a queue.
  • "Claiming" a queued item, which essentially means requesting the next item from the queue and holding a lock on that item for a specified period of time.
  • "Releasing" an item, which means giving up a claim but leaving the item in the queue.
  • "Deleting" an item, which means finally removing it from the queue.

This example demonstrates only basic queue functionality, and will use the default queue implementation, which is SystemQueue, managed using persistent database storage.

See Also
system.queue.inc

Further resources include the limited queue documentation and Batch vs Queue Presentation slides by John VanDyk and session video.

Function Documentation

queue_example_add_remove_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Provides an interface to add items to the queue, to retrieve (claim) an item from the head of the queue, and to claim and delete. Also allows the user to run cron manually, so that claimed items can be released.

Definition at line 56 of file queue_example.module.

References drupal_get_path(), drupal_map_assoc(), queue_example_retrieve_queue(), t(), and theme().

queue_example_add_remove_form_claim | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for the "claim" button. Claims (retrieves) an item from the queue and reports the results.

Definition at line 188 of file queue_example.module.

References drupal_set_message(), DrupalQueue::get(), and t().

queue_example_add_remove_form_clear_queue | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for clearing/deleting the queue.

Definition at line 240 of file queue_example.module.

References drupal_set_message(), DrupalQueue::get(), and t().

queue_example_add_remove_form_delete | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for "Claim and delete" button.

Definition at line 205 of file queue_example.module.

References drupal_set_message(), DrupalQueue::get(), and t().

queue_example_add_remove_form_insert | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for the insert-into-queue button.

Definition at line 147 of file queue_example.module.

References drupal_set_message(), DrupalQueue::get(), and t().

queue_example_add_remove_form_run_cron | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for "run cron" button.

Runs cron (to release expired claims) and reports the results.

Definition at line 228 of file queue_example.module.

References drupal_cron_run(), drupal_set_message(), DrupalQueue::get(), and t().

queue_example_menu ( )

Implements hook_menu().

Definition at line 38 of file queue_example.module.

queue_example_retrieve_queue ( $queue_name )

Retrieves the queue from the database for display purposes only.

It is not recommended to access the database directly, and this is only here so that the user interface can give a good idea of what's going on in the queue.

Parameters
$queue_name The name of the queue from which to fetch items.

Definition at line 256 of file queue_example.module.

References db_query().

Referenced by queue_example_add_remove_form().

queue_example_show_queue | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for the show-queue button.

Definition at line 168 of file queue_example.module.

References DrupalQueue::get().

queue_example_theme ( )

Implements hook_theme().

Definition at line 303 of file queue_example.module.

theme_queue_items ( $variables )

Themes the queue display.

Again, this is not part of the demonstration of the queue API, but is here just to make the user interface more understandable.

Parameters
$variables

Definition at line 275 of file queue_example.module.

References $header, $output, check_plain(), t(), and theme().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: RDF

Functions
Example: RDF
Examples

Functions

rdf_example_install ()
_rdf_example_installed_fields ()
_rdf_example_installed_instances ()
rdf_example_uninstall ()
rdf_example_rdf_mapping ()
rdf_example_rdf_namespaces ()
rdf_example_help ($path, $arg)

Detailed Description

Example RDF Mapping.

Function Documentation

_rdf_example_installed_fields ( )

Return a structured array defining the fields created by this content type.

Definition at line 61 of file rdf_example.install.

References get_t().

Referenced by rdf_example_install().

_rdf_example_installed_instances ( )

Return a structured array defining the instances for this content type.

Definition at line 85 of file rdf_example.install.

References get_t().

Referenced by rdf_example_install().

rdf_example_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 71 of file rdf_example.module.

References t(), and url().

rdf_example_install ( )

Implements hook_install().

  • Create photo, summary fields.
  • Create photo, summary instances.
See Also
node_type_set_defaults()
field_info_instance()
field_update_instance()
field_create_field()
field_create_instance()

Definition at line 24 of file rdf_example.install.

References _rdf_example_installed_fields(), _rdf_example_installed_instances(), field_create_field(), field_create_instance(), get_t(), node_type_save(), and node_type_set_defaults().

rdf_example_rdf_mapping ( )

Implements hook_rdf_mapping().

This hook should only be used to define the RDF mapping for an entity or bundle that has been defined by this module. On installation, this mapping will be saved to the database. To alter anything in this mapping after module installation (or to alter bundles defined in another module), the RDF CRUD functions should be used, as shown below.

Definition at line 25 of file rdf_example.module.

rdf_example_rdf_namespaces ( )

Definition at line 61 of file rdf_example.module.

rdf_example_uninstall ( )

Implements hook_uninstall().

Definition at line 108 of file rdf_example.install.

References $row, db_query(), field_delete_instance(), field_info_instances(), field_purge_batch(), node_delete_multiple(), and node_type_delete().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Render

Functions
Example: Render
Examples

Functions

render_example_menu ()
render_example_info ()
render_example_arrays ()
render_example_cache_pre_render ($element)
render_example_cache_expensive ()
render_example_add_suffix ($element)
render_example_add_prefix ($markup, $element)
theme_render_example_aggregate ($variables)
render_example_demo_form ($form, &$form_state)
render_example_page_alter (&$page)
render_example_embedded_form ($form, &$form_state, $form_items)
render_example_theme ()
theme_render_example_add_div ($variables)
theme_render_example_add_notes ($variables)
theme_render_array ($variables)
render_example_change_to_ol ($element)
render_example_add_hr ($markup, $element)

Detailed Description

Demonstrate how render arrays are arranged and how they can be altered. This alters blocks and the page to show the actual render array that is being used to create each item.

See Also
drupal_render()

Function Documentation

render_example_add_hr | ( | $markup,
 |  | $element
 | ) |

This #post_render function gets to alter the rendered output after all theme functions have acted on it, and it receives the original data, so can make decisions based on that. In this example, no use is made of the passed-in $element.

Parameters
$markup | The already-rendered data
unknown_type | $element | The data element that was rendered
Returns
The altered data.

Definition at line 551 of file render_example.module.

References $output.

render_example_add_prefix | ( | $markup,
 |  | $element
 | ) |

A '#post_render' function to add a little markup onto the end markup.

Parameters
$markup | The rendered element.
$element | The element which was rendered (for reference)
Returns
Markup altered as necessary. In this case we add a little postscript to it.

Definition at line 244 of file render_example.module.

render_example_add_suffix ( $element )

A '#pre_render' function.

Parameters
$element The element which will be rendered.
Returns
The altered element. In this case we add a #prefix to it.

Definition at line 222 of file render_example.module.

References t().

render_example_arrays ( )

Provides a number of render arrays and show what they do.

Each array is keyed by a description; it's returned for rendering at page render time. It's easy to add new examples to this.

The array items in $demos are intended to be raw, normal render arrays that can be experimented with to end up with different outcomes.

Definition at line 64 of file render_example.module.

References DRUPAL_CACHE_PER_PAGE, DRUPAL_CACHE_PER_ROLE, drupal_var_export(), and t().

render_example_cache_expensive ( )

A potentially expensive function.

Returns
Some demo text.

Definition at line 204 of file render_example.module.

References t().

Referenced by render_example_cache_pre_render().

render_example_cache_pre_render ( $element )

A '#pre_render' function.

Parameters
$element The element which will be rendered.
Returns
The altered element. In this case we add the #markup.

Definition at line 187 of file render_example.module.

References render_example_cache_expensive().

render_example_change_to_ol ( $element )

Adds a #type to the element before it gets rendered. In this case, changes from the default 'ul' to 'ol'.

Parameters
$element The element to be altered, in this case a list, ready for theme_item_list.
Returns
The altered list (with '#type')

Definition at line 532 of file render_example.module.

render_example_demo_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Builds the form that offers options of what items to show.

Definition at line 272 of file render_example.module.

References system_settings_form(), t(), and variable_get().

render_example_embedded_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $form_items
 | ) |  |

Utility function to build a named form given a set of form elements.

This is a standard form builder function that takes an additional array, which is itself a form.

Parameters
$form | The standard $form
$form_state | The standard $form_state
$form_items | The form items to be included in this form.

Definition at line 463 of file render_example.module.

render_example_info ( )

Simple basic information about the module; an entry point.

Definition at line 50 of file render_example.module.

References t(), and url().

render_example_menu ( )

Implements hook_menu().

Definition at line 25 of file render_example.module.

render_example_page_alter ( & $page )

Implements hook_page_alter().

Alters the page in several different ways based on how the form has been configured.

Definition at line 329 of file render_example.module.

References $page, drupal_get_form(), element_children(), t(), and variable_get().

render_example_theme ( )

Implements hook_theme().

Definition at line 470 of file render_example.module.

theme_render_array ( $variables )

Themes the render array (from the demonstration page).

Definition at line 515 of file render_example.module.

theme_render_example_add_div ( $variables )

Wraps a div around the already-rendered #children.

Definition at line 491 of file render_example.module.

References $output.

theme_render_example_add_notes ( $variables )

Wraps a div and add a little text after the rendered #children.

Definition at line 502 of file render_example.module.

References $output, and t().

theme_render_example_aggregate ( $variables )

A theme function.

This theme function has the responsibility of consolidating/rendering the children's markup and returning it, where it will be placed in the element's #children property.

Definition at line 256 of file render_example.module.

References $output, and element_children().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Simpletest

Functions
Example: Simpletest
Examples

Functions

simpletest_example_install ()
simpletest_example_update_7001 ()
simpletest_example_node_info ()
simpletest_example_permission ()
simpletest_example_node_access ($node, $op, $account)
simpletest_example_form ($node, $form_state)
simpletest_example_menu ()
_simpletest_example_explanation ()
simpletest_example_empty_mysql_date ($date_string)

Detailed Description

An example of simpletest tests to accompany the tutorial at http://drupal.org/node/890654.

This module creates a new node type called 'SimpleTest Example Node Type,' so that we can test it.

Function Documentation

_simpletest_example_explanation ( )

Returns an explanation of this module.

Definition at line 111 of file simpletest_example.module.

References t().

simpletest_example_empty_mysql_date ( $date_string )

A simple self-contained function used to demonstrate unit tests.

See Also
SimpletestUnitTestExampleTestCase

Definition at line 123 of file simpletest_example.module.

simpletest_example_form | ( | $node,
 |  | $form_state
 | ) |

Implements hook_form().

Form for the node type.

Definition at line 77 of file simpletest_example.module.

References check_plain(), and node_type_get_type().

simpletest_example_install ( )

Implements hook_install().

Definition at line 13 of file simpletest_example.install.

References node_add_body_field(), node_type_get_types(), and node_types_rebuild().

simpletest_example_menu ( )

Implements hook_menu().

Provides an explanation.

Definition at line 98 of file simpletest_example.module.

simpletest_example_node_access | ( | $node,
 |  | $op,
 |  | $account
 | ) |

Implements hook_node_access().

Demonstrates a bug that we'll find in our test.

If this is running on the testbot, we don't want the error to show so will work around it by testing to see if we're in the 'checkout' directory.

Definition at line 52 of file simpletest_example.module.

References $op, NODE_ACCESS_ALLOW, NODE_ACCESS_DENY, NODE_ACCESS_IGNORE, and user_access().

simpletest_example_node_info ( )

Implements hook_node_info().

Definition at line 22 of file simpletest_example.module.

References t().

simpletest_example_permission ( )

Implements hook_permission().

In this case we're adding an addition permission that does the same as the one the node module offers, just to demonstrate this error.

Definition at line 38 of file simpletest_example.module.

References t().

simpletest_example_update_7001 ( )

Adds a body field to the simpletest_example node type.

Definition at line 25 of file simpletest_example.install.

References node_add_body_field(), node_type_get_types(), and node_types_rebuild().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Tabledrag

Functions
Example: Tabledrag
Examples

Functions

tabledrag_example_schema ()
tabledrag_example_install ()
tabledrag_example_uninstall ()
tabledrag_example_help ($path, $arg)
tabledrag_example_menu ()
tabledrag_example_theme ()
tabledrag_example_parent_form ($form_state)
theme_tabledrag_example_parent_form ($variables)
tabledrag_example_parent_form_submit ($form, &$form_state)
tabledrag_example_parent_get_data ()
tabledrag_example_get_tree ($parentitem, &$itemtree=array(), &$depth=0)
tabledrag_example_simple_form ($form_state)
theme_tabledrag_example_simple_form ($variables)
tabledrag_example_simple_form_submit ($form, &$form_state)

Detailed Description

Example of draggable table rows.

Function Documentation

tabledrag_example_get_tree | ( |  | $parentitem,
 |  | & | $itemtree = array(),
 |  | & | $depth = 0
 | ) |  |

Recursively adds to the $itemtree array, ordered by parent/child/weight.

Definition at line 309 of file tabledrag_example_parent_form.inc.

References $children, $depth, and db_query().

Referenced by tabledrag_example_parent_get_data().

tabledrag_example_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Show a bit of information about this module on the example page.

Definition at line 19 of file tabledrag_example.module.

References t().

tabledrag_example_install ( )

Implements hook_install().

This datafills the example item info which will be used in the example.

Definition at line 84 of file tabledrag_example.install.

References $row, db_insert(), db_table_exists(), and get_t().

tabledrag_example_menu ( )

Implements hook_menu().

We'll let drupal_get_form() generate the form page for us, for both of these menu items.

See Also
drupal_get_form()

Definition at line 34 of file tabledrag_example.module.

tabledrag_example_parent_form ( $form_state )

Build the parent-child example form.

Returns
A form array set for theming by theme_tabledrag_example_parent_form()

Definition at line 15 of file tabledrag_example_parent_form.inc.

References t(), and tabledrag_example_parent_get_data().

tabledrag_example_parent_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit callback for the tabledrag_example_parent_form form.

Updates the 'weight' column for each element in our table, taking into account that item's new order after the drag and drop actions have been performed.

Definition at line 263 of file tabledrag_example_parent_form.inc.

References db_query().

tabledrag_example_parent_get_data ( )

Retrives the tree structure from database, and sorts by parent/child/weight.

The sorting should result in children items immediately following their parent items, with items at the same level of the hierarchy sorted by weight.

The approach used here may be considered too database-intensive. Optimization of the approach is left as an exercise for the reader. :)

Definition at line 286 of file tabledrag_example_parent_form.inc.

References $depth, db_query(), and tabledrag_example_get_tree().

Referenced by tabledrag_example_parent_form().

tabledrag_example_schema ( )

Implements hook_schema().

This defines the database table which will hold the example item info.

Definition at line 17 of file tabledrag_example.install.

tabledrag_example_simple_form ( $form_state )

Build the tabledrag_simple_example_form form.

Returns
A form array set for theming by theme_tabledrag_example_simple_form()

Definition at line 15 of file tabledrag_example_simple_form.inc.

References check_plain(), db_query(), and t().

tabledrag_example_simple_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit callback for the tabledrag_example_simple_form form.

Updates the 'weight' column for each element in our table, taking into account that item's new order after the drag and drop actions have been performed.

Definition at line 168 of file tabledrag_example_simple_form.inc.

References db_query().

tabledrag_example_theme ( )

Implements hook_theme().

We need run our forms through custom theme functions in order to build the table structure which is required by tabledrag.js. Before we can use our custom theme functions, we need to implement hook_theme in order to register them with Drupal.

We are defining our theme hooks with the same name as the form generation function so that Drupal automatically calls our theming function when the form is displayed.

Definition at line 68 of file tabledrag_example.module.

tabledrag_example_uninstall ( )

Implements hook_uninstall().

This removes the example data when the module is uninstalled.

Definition at line 149 of file tabledrag_example.install.

References db_drop_table().

theme_tabledrag_example_parent_form ( $variables )

Theme callback for the tabledrag_example_parent_form form.

The theme callback will format the $form data structure into a table and add our tabledrag functionality. (Note that drupal_add_tabledrag should be called from the theme layer, and not from a form declaration. This helps keep template files clean and readable, and prevents tabledrag.js from being added twice accidently.

Definition at line 129 of file tabledrag_example_parent_form.inc.

References $header, $output, drupal_add_tabledrag(), drupal_render(), drupal_render_children(), element_children(), t(), and theme().

theme_tabledrag_example_simple_form ( $variables )

Theme callback for the tabledrag_example_simple_form form.

The theme callback will format the $form data structure into a table and add our tabledrag functionality. (Note that drupal_add_tabledrag should be called from the theme layer, and not from a form declaration. This helps keep template files clean and readable, and prevents tabledrag.js from being added twice accidently.

Returns
The rendered tabledrag form

Definition at line 87 of file tabledrag_example_simple_form.inc.

References $header, $output, drupal_add_tabledrag(), drupal_render(), drupal_render_children(), element_children(), t(), and theme().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Tablesort

Functions
Example: Tablesort
Examples

Functions

tablesort_example_install ()
tablesort_example_uninstall ()
tablesort_example_schema ()
tablesort_example_help ($path, $arg)
tablesort_example_menu ()
tablesort_example_page ()

Detailed Description

Example of a sortable table display.

Function Documentation

tablesort_example_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Show a bit of information about this module on the example page

Definition at line 24 of file tablesort_example.module.

References t().

tablesort_example_install ( )

Implements hook_install().

Definition at line 17 of file tablesort_example.install.

References $row, db_insert(), and db_table_exists().

tablesort_example_menu ( )

Implements hook_menu().

Definition at line 34 of file tablesort_example.module.

tablesort_example_page ( )

Build the table render array.

Returns
A render array set for theming by theme_table().

Definition at line 50 of file tablesort_example.module.

References $header, $row, db_select(), and t().

tablesort_example_schema ( )

Implements hook_schema().

Definition at line 52 of file tablesort_example.install.

tablesort_example_uninstall ( )

Implements hook_uninstall().

It's good to clean up after ourselves

Definition at line 43 of file tablesort_example.install.

References db_drop_table().

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Theming

Functions
Example: Theming
Examples

Functions

theming_example_menu ()
theming_example_theme ()
theming_example_page ()
theming_example_list_page ()
theming_example_select_form ($form, &$form_state)
theming_example_select_form_submit ($form, &$form_state)
theming_example_text_form ($form, &$form_state)
theming_example_text_form_submit ($form, &$form_state)
theme_theming_example_content_array ($variables)
theme_theming_example_list ($variables)
theme_theming_example_select_form ($variables)
template_preprocess_theming_example_text_form (&$variables)

Detailed Description

Example of Drupal theming.

The theming_example module attempts to show how module developers can add theme functions to their projects so that themes can modify output.

Module developers should to strive to avoid hard-wiring any HTML into the output of their code, this should all be done in theme functions.

Starting with the first example, function 'theming_example_page()': the output is put into an array $content which is then fed to a theming function 'theme_theming_example_page()' which loops over the content, wrapping it in html in the process.

In order to get function 'theme_theming_example_page()' recognized it needs to be registered with the module theme register function of the type 'hook_theme'.

function 'theming_example_theme()' does this for this module. for details of what can be done in this hook see the link to api.drupal.org

The functions 'theming_example_list_page()' and theming_example_order_form() work in the same way.

In 'theme_theming_example_list_page()' the content is themed as an ordered list and given a class attribute 'theming_example_mylist' which is defined in theming_example.css

In function 'theme_theming_example_order_form()' the title is loaded into a temporary variable '$title', deleted from the $form array and output wrapped in html. The rest of the form is wrapped in a div using '#prefix' and '#suffix'

The theming functions can be copied to a theme's template.php, renaming appropriately, so if you theme is called 'mytheme' you would copy function 'theme_theming_example_page()' to function 'mytheme_theming_example_page()' in template.php and it will be used instead of the original.

The fourth example shows the use of a template file 'theming_example_text_form.tpl.php' This file can be copied to a theme's folder and it will be used instead.

This example also shows what can be done using Drupal's template_preprocess_HOOK method. In this case it modifies the output so that a themer can output the whole form or gain control over some of its parts in the template file.

Function Documentation

template_preprocess_theming_example_text_form ( & $variables )

Implements template_preprocess() to prepare variables for use inside the theming-example-text-form.tpl.php template file.

In this example, we create a couple new variables, 'text_form' and 'text_form_content', that clean up the form output. Drupal will turn the array keys in the $variables array into variables for use in the template.

So $variables['text_form'] becomes available as $text_form in the template.

See Also
theming-example-text-form.tpl.php

Definition at line 340 of file theming_example.module.

References drupal_render(), and element_children().

theme_theming_example_content_array ( $variables )

Theme a simple content array.

This theme function uses the newer recommended format where a single render array is provided to the theme function.

Definition at line 263 of file theming_example.module.

References $output, and element_children().

theme_theming_example_list ( $variables )

Theming a simple list.

This is just a simple wrapper around theme('item_list') but it's worth showing how a custom theme function can be implemented.

See Also
theme_item_list()

Definition at line 287 of file theming_example.module.

References $output, $title, and theme().

theme_theming_example_select_form ( $variables )

Theming a simple form.

Since our form is named theming_example_select_form(), the default theme function applied to is will be 'theming_example_select_form' if it exists. The form could also have specified a different theme.

Here we collect the title, theme it manually and empty the form title. We also wrap the form in a div.

Definition at line 317 of file theming_example.module.

References $output, $title, and drupal_render_children().

theming_example_list_page ( )

An example page where the output is supplied as an array which is themed into a list and styled with css.

In this case we'll use the core-provided theme_item_list as a #theme_wrapper. Any theme need only override theme_item_list to change the behavior.

Definition at line 169 of file theming_example.module.

References $title, drupal_get_path(), and t().

theming_example_menu ( )

Implements hook_menu().

The Menu Example provides extensive examples for hook_menu().

Definition at line 74 of file theming_example.module.

theming_example_page ( )

Initial landing page explaining the use of the module.

We create a render array and specify the theme to be used through the use of #theme_wrappers. With all output, we aim to leave the content as a render array just as long as possible, so that other modules (or the theme) can alter it.

See Also
render_example.module
form_example_elements.inc

Definition at line 153 of file theming_example.module.

References $content, l(), and t().

theming_example_select_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

A simple form that displays a select box and submit button.

This form will be be themed by the 'theming_example_select_form' theme handler.

Definition at line 211 of file theming_example.module.

References t().

theming_example_select_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 230 of file theming_example.module.

References drupal_set_message(), and t().

theming_example_text_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

A simple form that displays a textfield and submit button.

This form will be rendered by theme('form') (theme_form() by default) because we do not provide a theme function for it here.

Definition at line 240 of file theming_example.module.

References t().

theming_example_text_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 252 of file theming_example.module.

References drupal_set_message(), and t().

theming_example_theme ( )

Implements hook_theme().

Defines the theming capabilities provided by this module.

Definition at line 112 of file theming_example.module.

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Token API

Functions
Example: Token API
Examples

Functions

token_example_menu ()
token_example_entity_info_alter (&$info)
token_example_example_form ($form, &$form_state)
token_example_example_form_submit ($form, &$form_state)
_token_example_get_node ()
_token_example_get_comment ()
_token_example_get_user ()
_token_example_get_taxonomy_term ()
_token_example_get_file ()
token_example_token_info ()
token_example_tokens ($type, $tokens, array $data=array(), array $options=array())

Detailed Description

Examples using the Token API.

The Token module provides an API for providing tokens to other modules. Tokens are small bits of text that can be placed into larger documents via simple placeholders, like site-name or [user].

Drupal 7 documentation on Token can be found here: http://drupal.org/documentation/modules/token

A list of existing tokens can be found here: http://drupal.org/node/390482#drupal7tokenslist

This example is part of the Examples for Developers Project which you can download and experiment with here: http://drupal.org/project/examples

Function Documentation

_token_example_get_comment ( )

Builds a list of available comments.

Definition at line 165 of file token_example.module.

References COMMENT_PUBLISHED, db_select(), module_exists(), NODE_PUBLISHED, and user_access().

_token_example_get_file ( )

Builds a list of available files.

Definition at line 218 of file token_example.module.

References db_select().

_token_example_get_node ( )

Builds a list of available content.

Definition at line 146 of file token_example.module.

References db_select(), NODE_PUBLISHED, and user_access().

_token_example_get_taxonomy_term ( )

Builds a list of available taxonomy terms.

Definition at line 205 of file token_example.module.

References db_select().

_token_example_get_user ( )

Builds a list of available user accounts.

Definition at line 186 of file token_example.module.

References db_select(), and user_access().

token_example_entity_info_alter ( & $info )

Implements hook_entity_info_alter().

Definition at line 52 of file token_example.module.

References $info.

token_example_example_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form builder; display lists of supported token entities and text to tokenize.

Definition at line 64 of file token_example.module.

References $info, entity_get_info(), entity_load(), module_exists(), t(), and token_replace().

token_example_example_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit callback; store the submitted values into storage.

Definition at line 138 of file token_example.module.

token_example_menu ( )

Implements hook_menu().

Definition at line 35 of file token_example.module.

token_example_token_info ( )

Implements hook_token_info().

Definition at line 13 of file token_example.tokens.inc.

References $info, module_exists(), and t().

token_example_tokens | ( |  | $type,
 |  |  | $tokens,
 |  | array | $data = array(),
 |  | array | $options = array()
 | ) |  |

Implements hook_tokens().

Definition at line 62 of file token_example.tokens.inc.

References $name, field_get_items(), filter_default_format(), filter_format_load(), filter_xss(), token_find_with_prefix(), and token_generate().

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Trigger

Functions
Example: Trigger
Examples

Functions

trigger_example_trigger_info ()
trigger_example_triggersomething ($options=array())
trigger_example_user_login (&$edit, $account, $category=NULL)
_trigger_example_first_time_login ($hook, &$edit, $account, $category=NULL)
trigger_example_help ($path, $arg)
trigger_example_menu ()
trigger_example_form ($form_state)
trigger_example_form_submit ($form, $form_state)
trigger_example_trigger_info_alter (&$triggers)

Detailed Description

Trigger definition example module.

Triggers and actions are a pair of special-purpose functions allowing some Drupal programming without using PHP. Using the appropriate action in a specific event, a site administrator can add new functionality. Examples are:

  • Send an email after a node is published or edited.
  • Display a message after a user has logged in.
  • Display a message and send an email after a node has been deleted.

A Trigger is a special function able to enqueue actions. The trigger module provides the interface allowing us to associate certain actions with certain triggers.

Actions are functions intended to be run by triggers.

A trigger should build the appropriate context for the action to be fired. Actions are very often grouped by functionality: examples are 'user', 'node', 'taxonomy'. When some actions are grouped it is because they expect the same arguments. This way, you can enqueue as many actions understanding the 'user' object as you want.

Not all actions can be used in all triggers because they require different contexts. But some actions are generic enough to not require special objects in their contexts, and so can be used on every available trigger. This 'group' type is used by actions to be available for this trigger.

What are good candidates to be triggers? Any function can be a trigger, as long as it has the code to call the enqueued actions, but to make Drupal more extensible, you will find hooks (from Drupal and contributed modules) very good candidates. A trigger should build the arguments, ask for enqueued actions and run them. You may define a function being a trigger, and run it through a button in the front page, or you may prepare a trigger for a hook, and everytime that hook is fired, your trigger will be.

What are good candidates to be actions? any function is a possible action, the only problem is finding a trigger able to run it.

This module describes how to create triggers and actions for Drupal. In this example we are providing two triggers:

  • A custom trigger, in its simplest form. We provide a page with a button. This button does nothing at all, but when you click (and submit the empty form), any actions you have configured will be executed.
  • A trigger which extends the capabilities of User triggers. This creates a new event which fires the first time a user ever logs in. In the module we will create it, and then provide a trigger for the administrator to be able to enqueue actions. They will be executed only the first time the user logs in the system.

See:

Creating Triggers

Writing Actions

Triggers and Actions in Drupal 6

See Also
hook_trigger_info()
hook_trigger_info_alter() Also see the Action Example .

Function Documentation

_trigger_example_first_time_login | ( |  | $hook,
 |  | & | $edit,
 |  |  | $account,
 |  |  | $category = NULL
 | ) |  |

Trigger function for "User first time login"

This trigger is a user-type triggers, so is grouped with other user-type triggers. It needs to provide all the context that user-type triggers provide. For this example, we are going to copy the trigger.module implementation for the 'User has logged in' event.

This function will run all the actions assigned to the 'user_first_time_login' trigger.

For testing you can use an update query like this to reset a user to "never logged in":

* update users set access=created where name='test1';
*
Parameters
string | $hook | The trigger identification.
array | $edit | Modifications for the account object (should be empty).
object | $account | User object that has logged in.
string | $category | Category of the profile.

Definition at line 192 of file trigger_example.module.

References $info, _trigger_normalize_user_context(), actions_do(), and trigger_get_assigned_actions().

Referenced by trigger_example_user_login().

trigger_example_form ( $form_state )

Trigger example test form.

Provides a button to run the triggersomething event.

Definition at line 273 of file trigger_example.module.

References t().

trigger_example_form_submit | ( | $form,
 |  | $form_state
 | ) |

Submit handler for the trigger_example_form().

Definition at line 284 of file trigger_example.module.

References t(), and trigger_example_triggersomething().

trigger_example_help | ( | $path,
 |  | $arg
 | ) |

Helper functions for the module interface to test the triggersomething trigger. Implements hook_help().

Definition at line 227 of file trigger_example.module.

References t(), and url().

trigger_example_menu ( )

Implements hook_menu().

Provides a form that can be used to fire the module's triggers.

Definition at line 257 of file trigger_example.module.

trigger_example_trigger_info ( )

Implements hook_trigger_info().

We call hook_trigger_info when we are defining the triggers we provide. Triggers are the events that make fire any number of assigned actions. In this example, we are registering our three new triggers, providing the group (system, user..), the callback 'hook' (only informative, does not require a real hook) function and the label to be shown in the triggers interface.

Example: In the group (a tab) 'system', for the 'mail' functionality, show: An email is sent by Drupal.

Definition at line 90 of file trigger_example.module.

References t().

trigger_example_trigger_info_alter ( & $triggers )

Optional usage of hook_trigger_info_alter().

This function is not required to write your own triggers, but it may be useful when you want to alter existing triggers. Implements hook_trigger_info_alter().

We call hook_trigger_info_alter when we want to change an existing trigger. As mentioned earlier, this hook is not required to create your own triggers, and should only be used when you need to alter current existing triggers. In this example implementation a little change is done to the existing trigger provided by core: 'cron'

Parameters
$triggers Array of trigger information returned by hook_trigger_info() implementations.
See Also
hook_trigger_info()

Definition at line 314 of file trigger_example.module.

References t().

trigger_example_triggersomething ( $options = array() )

Triggers are used most of the time to do something when an event happens. The most common type of event is a hook invocation, but that is not the only possibility. triggersomething trigger: Run actions associated with an arbitrary event.

Here pressing a button is a trigger. We have defined a custom function as a trigger (trigger_example_triggersomething). It will ask for all actions attached to the 'triggersomething' event, prepare a basic 'context' for them and run all of them. This could have been implemented by a hook implementation, but in this demonstration, it will just be called in a form's submit.

This function is executed during the submission of the example form defined in this module.

Parameters
$options Array of arguments used to call the triggersomething function, if any.

Definition at line 129 of file trigger_example.module.

References actions_do(), and trigger_get_assigned_actions().

Referenced by trigger_example_form_submit().

trigger_example_user_login | ( | & | $edit,
 |  |  | $account,
 |  |  | $category = NULL
 | ) |  |

The next trigger is more complex, we are providing a trigger for a new event: "user first time login". We need to create this event first. Implements hook_user_login().

User first login trigger: Run actions on user first login.

The event "User first time login" does not exist, we should create it before it can be used. We use hook_user_login to be informed when a user logs in and try to find if the user has previously logged in before. If the user has not accessed previously, we make a call to our trigger function.

Definition at line 158 of file trigger_example.module.

References _trigger_example_first_time_login().

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: Vertical Tabs

Functions
Example: Vertical Tabs
Examples

Functions

vertical_tabs_example_menu ()
vertical_tabs_example_form_alter (&$form, $form_state, $form_id)
_vertical_tabs_example_explanation ()

Detailed Description

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 Also
vertical_tabs_example.js

Function Documentation

_vertical_tabs_example_explanation ( )

Simple explanation page.

Definition at line 107 of file vertical_tabs_example.module.

References t(), and url().

vertical_tabs_example_form_alter | ( | & | $form,
 |  |  | $form_state,
 |  |  | $form_id
 | ) |  |

Implement hook_form_alter().

Adds custom fieldset to the node form, and attach ajax behaviour for vertical panels to update the settings description.

See Also
vertical_tabs_example.js

Definition at line 41 of file vertical_tabs_example.module.

References drupal_get_path(), and t().

vertical_tabs_example_menu ( )

Implements hook_menu for a simple explanation page.

Definition at line 23 of file vertical_tabs_example.module.

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: Example: XML-RPC

Functions
Example: XML-RPC
Examples

Functions

xmlrpc_example_menu ()
xmlrpc_example_info ()
xmlrpc_example_xmlrpc ()
_xmlrpc_example_server_add ($num1, $num2)
_xmlrpc_example_server_subtract ($num1, $num2)
xmlrpc_example_server_form ()
xmlrpc_example_client_form ()
xmlrpc_example_client_request_methods_submit ($form, &$form_state)
xmlrpc_example_client_add_submit ($form, &$form_state)
xmlrpc_example_client_subtract_submit ($form, &$form_state)
xmlrpc_example_client_multicall_submit ($form, &$form_state)
xmlrpc_example_xmlrpc_alter (&$methods)
_xmlrpc_example_alter_add ($num1, $num2)
_xmlrpc_example_alter_subtract ($num1, $num2)
xmlrpc_example_alter_form ()

Detailed Description

Demonstration of XML-RPC in Drupal 7.

This is an example of how to implement and XML-RPC server by registering callbacks to specific methods and how to make xmlrpc calls using the built-in xmlrpc() factory provided by Drupal.

For experimentation you may be interested in the XML-RPC Tester module .

Note that the Services module is another common way to do XML-RPC at this time.

See Also
hook_xmlrpc()
xmlrpc()
xmlrpc_errno()
xmlrpc_error_msg()

Function Documentation

_xmlrpc_example_alter_add | ( | $num1,
 |  | $num2
 | ) |

Sum the two arguments without limit checking.

This is the replacement callback for the xmlrpc_example.add xmlrpc method.

Parameters
$num1 | First number
$num2 | Second Number
Returns
The sum of the arguments

Definition at line 660 of file xmlrpc_example.module.

_xmlrpc_example_alter_subtract | ( | $num1,
 |  | $num2
 | ) |

Return the difference of the two arguments without limit checking.

This is the replacement callback for xmlrpc_example.subtract xmlrpc method.

Parameters
$num1 | First number
$num2 | Second Number
Returns
The difference of the two arguments

Definition at line 677 of file xmlrpc_example.module.

_xmlrpc_example_server_add | ( | $num1,
 |  | $num2
 | ) |

This is the callback for the xmlrpc_example.add method.

Sum the two arguments and return value or an error if the result is out of the configured limits.

Parameters
$num1 | The first number to be summed.
$num2 | The second number to be summed.
Returns
The sum of the arguments, or error if it is not in server defined bounds.
See Also
xmlrpc_error()

Definition at line 230 of file xmlrpc_example.module.

References t(), variable_get(), and xmlrpc_error().

_xmlrpc_example_server_subtract | ( | $num1,
 |  | $num2
 | ) |

This is the callback for the xmlrpc_example.subtract xmlrpc method.

Return the difference of the two arguments, or an error if the result is out of the configured limits.

Parameters
$num1 | First number
$num2 | Second number
Returns
The difference of the two arguments, or error if it is not in server defined bounds.
See Also
xmlrpc_error()

Definition at line 263 of file xmlrpc_example.module.

References t(), variable_get(), and xmlrpc_error().

xmlrpc_example_alter_form ( )

Present a form to enable/disable the code implemented in hook_xmlrpc_alter.

Definition at line 689 of file xmlrpc_example.module.

References system_settings_form(), t(), url(), and variable_get().

xmlrpc_example_client_add_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to query xmlrpc_example.add.

Submit: query the XML-RPC endpoint for the method xmlrpc_example.add and report the result as a Drupal message.

Parameters
$form | form array
$form_state | form_state array
See Also
xmlrpc()
xmlrpc_errno()
xmlrpc_error_msg()

Definition at line 459 of file xmlrpc_example.module.

References drupal_set_message(), t(), url(), xmlrpc(), xmlrpc_errno(), and xmlrpc_error_msg().

xmlrpc_example_client_form ( )

Returns a form array to take input for two arguments.

Present a form to get two arguments, and make a call to an XML-RPC server using these arguments as input, showing the result in a message.

Definition at line 343 of file xmlrpc_example.module.

References t(), url(), and variable_get().

xmlrpc_example_client_multicall_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit a multicall request.

Submit a multicall request: query the XML-RPC endpoint for the methods xmlrpc_example.add and xmlrpc_example.subtract and report the result as a Drupal message. Drupal's XML-RPC client builds the system.multicall request automatically when there is more than one method to call.

Parameters
$form | form array
$form_state | form_state array
See Also
xmlrpc()
xmlrpc_errno()
xmlrpc_error_msg()
xmlrpc_example_client_multicall_submit()

Definition at line 548 of file xmlrpc_example.module.

References drupal_set_message(), t(), url(), xmlrpc(), xmlrpc_errno(), and xmlrpc_error_msg().

xmlrpc_example_client_request_methods_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to query system.listMethods.

Submit: query the XML-RPC endpoint for the method system.listMethods and report the result as a Drupal message. The result is a list of the available methods in this XML-RPC server.

Important note: Not all XML-RPC servers implement this method. Drupal's built-in XML-RPC server implements this method by default.

Parameters
$form | form array
$form_state | form_state array
See Also
xmlrpc()
xmlrpc_errno()
xmlrpc_error_msg()

Definition at line 417 of file xmlrpc_example.module.

References drupal_set_message(), t(), url(), xmlrpc(), xmlrpc_errno(), and xmlrpc_error_msg().

xmlrpc_example_client_subtract_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to query xmlrpc_example.subtract.

Submit: query the XML-RPC endpoint for the method xmlrpc_example.subtract and report the result as a Drupal message.

Parameters
$form | form array
$form_state | form_state array
See Also
xmlrpc()
xmlrpc_errno()
xmlrpc_error_msg()
xmlrpc_example_client_add_submit()

Definition at line 505 of file xmlrpc_example.module.

References drupal_set_message(), t(), url(), xmlrpc(), xmlrpc_errno(), and xmlrpc_error_msg().

xmlrpc_example_info ( )

A simple landing-page information function.

Definition at line 85 of file xmlrpc_example.module.

References drupal_set_message(), t(), theme(), url(), xmlrpc(), xmlrpc_errno(), and xmlrpc_error_msg().

xmlrpc_example_menu ( )

Implements hook_menu().

Registers all the demonstration forms.

Definition at line 39 of file xmlrpc_example.module.

xmlrpc_example_server_form ( )

Returns form array to configure the service options.

Present a form to configure the service options. In this case the maximum and minimum values for any of the operations (add or subtraction).

Definition at line 291 of file xmlrpc_example.module.

References system_settings_form(), t(), url(), and variable_get().

xmlrpc_example_xmlrpc ( )

Implements hook_xmlrpc().

Provides Drupal with an array to map XML-RPC callbacks to existing functions. These functions may be defined in other modules. The example implementation defines specific functions for the example services.

Note: Drupal's built-in XML-RPC server already includes several methods by default:

Service dicovery methods:

  • system.listMethods: return a list of the methods the server has, by name.
  • system.methodSignature: return a description of the argument format a
  • system.methodHelp: returns a text description of a particular method. particular method expects.

Other:

  • system.multicall: perform several method calls in a single xmlrpc request.
  • system.getCapabilities: determine if a given capability is supported.

The methods defined by hook_xmlrpc() will be added to those provided by default by Drupal's XML-RPC server.

See Also
hook_xmlrpc()

Definition at line 172 of file xmlrpc_example.module.

References t().

xmlrpc_example_xmlrpc_alter ( & $methods )

Implements hook_xmlrpc_alter().

Check to see if xmlrpc_example.add and xmlrpc_example.subtract methods are defined and replace their callbacks with custom code.

See Also
hook_xmlrpc_alter()

Definition at line 622 of file xmlrpc_example.module.

References variable_get().

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: Actions

Functions
Actions

Functions

actions_do ($action_ids, $object=NULL, $context=NULL, $a1=NULL, $a2=NULL)
comment_publish_action ($comment, $context=array())
comment_unpublish_action ($comment, $context=array())
comment_unpublish_by_keyword_action ($comment, $context)
comment_save_action ($comment)
node_publish_action ($node, $context=array())
node_unpublish_action ($node, $context=array())
node_make_sticky_action ($node, $context=array())
node_make_unsticky_action ($node, $context=array())
node_promote_action ($node, $context=array())
node_unpromote_action ($node, $context=array())
node_save_action ($node)
node_assign_owner_action ($node, $context)
node_unpublish_by_keyword_action ($node, $context)
hook_action_info ()
system_send_email_action ($entity, $context)
system_message_action (&$entity, $context=array())
system_goto_action ($entity, $context)
system_block_ip_action ()
user_block_user_action (&$entity, $context=array())

Detailed Description

Functions that perform an action on a certain system object.

Action functions are declared by modules by implementing hook_action_info(). Modules can cause action functions to run by calling actions_do(), and trigger.module provides a user interface that lets administrators define events that cause action functions to run.

Each action function takes two to four arguments:

  • $entity: The object that the action acts on, such as a node, comment, or user.
  • $context: Array of additional information about what triggered the action.
  • $a1, $a2: Optional additional information, which can be passed into actions_do() and will be passed along to the action function.

Function Documentation

actions_do | ( | $action_ids,
 |  | $object = NULL,
 |  | $context = NULL,
 |  | $a1 = NULL,
 |  | $a2 = NULL
 | ) |

Performs a given list of actions by executing their callback functions.

Given the IDs of actions to perform, this function finds out what the callback functions for the actions are by querying the database. Then it calls each callback using the function call $function($object, $context, $a1, $a2), passing the input arguments of this function (see below) to the action function.

Parameters
$action_ids | The IDs of the actions to perform. Can be a single action ID or an array of IDs. IDs of configurable actions must be given as numeric action IDs; IDs of non-configurable actions may be given as action function names.
$object | The object that the action will act on: a node, user, or comment object.
$context | Associative array containing extra information about what triggered the action call, with $context['hook'] giving the name of the hook that resulted in this call to actions_do().
$a1 | Passed along to the callback.
$a2 | Passed along to the callback.
Returns
An associative array containing the results of the functions that perform the actions, keyed on action ID.

Definition at line 58 of file actions.inc.

References actions_list(), db_query(), db_select(), variable_get(), watchdog(), and WATCHDOG_ERROR.

Referenced by _trigger_comment(), _trigger_example_first_time_login(), _trigger_node(), _trigger_taxonomy(), _trigger_user(), trigger_cron(), and trigger_example_triggersomething().

comment_publish_action | ( | $comment,
 |  | $context = array()
 | ) |

Publishes a comment.

Parameters
$comment An optional comment object.
array $context Array with components:
  • 'cid': Comment ID. Required if $comment is not given.

Definition at line 2560 of file comment.module.

References COMMENT_PUBLISHED, db_query(), db_update(), and watchdog().

comment_save_action ( $comment )

Saves a comment.

Definition at line 2660 of file comment.module.

References cache_clear_all(), comment_save(), and watchdog().

comment_unpublish_action | ( | $comment,
 |  | $context = array()
 | ) |

Unpublishes a comment.

Parameters
$comment An optional comment object.
array $context Array with components:
  • 'cid': Comment ID. Required if $comment is not given.

Definition at line 2587 of file comment.module.

References COMMENT_NOT_PUBLISHED, db_query(), db_update(), and watchdog().

comment_unpublish_by_keyword_action | ( | $comment,
 |  | $context
 | ) |

Unpublishes a comment if it contains certain keywords.

Parameters
$comment Comment object to modify.
array $context Array with components:
  • 'keywords': Keywords to look for. If the comment contains at least one of the keywords, it is unpublished.
See Also
comment_unpublish_by_keyword_action_form()
comment_unpublish_by_keyword_action_submit()

Definition at line 2617 of file comment.module.

References COMMENT_NOT_PUBLISHED, drupal_render(), and watchdog().

hook_action_info ( )

Declares information about actions.

Any module can define actions, and then call actions_do() to make those actions happen in response to events. The trigger module provides a user interface for associating actions with module-defined triggers, and it makes sure the core triggers fire off actions when their events happen.

An action consists of two or three parts:

  • an action definition (returned by this hook)
  • a function which performs the action (which by convention is named MODULE_description-of-function_action)
  • an optional form definition function that defines a configuration form (which has the name of the action function with '_form' appended to it.)

The action function takes two to four arguments, which come from the input arguments to actions_do().

Returns
An associative array of action descriptions. The keys of the array are the names of the action functions, and each corresponding value is an associative array with the following key-value pairs:
  • 'type': The type of object this action acts upon. Core actions have types 'node', 'user', 'comment', and 'system'.
  • 'label': The human-readable name of the action, which should be passed through the t() function for translation.
  • 'configurable': If FALSE, then the action doesn't require any extra configuration. If TRUE, then your module must define a form function with the same name as the action function with '_form' appended (e.g., the form for 'node_assign_owner_action' is 'node_assign_owner_action_form'.) This function takes $context as its only parameter, and is paired with the usual _submit function, and possibly a _validate function.
  • 'triggers': An array of the events (that is, hooks) that can trigger this action. For example: array('node_insert', 'user_update'). You can also declare support for any trigger by returning array('any') for this value.
  • 'behavior': (optional) A machine-readable array of behaviors of this action, used to signal additionally required actions that may need to be triggered. Currently recognized behaviors by Trigger module:
    • 'changes_property': If an action with this behavior is assigned to a trigger other than a "presave" hook, any save actions also assigned to this trigger are moved later in the list. If no save action is present, one will be added. Modules that are processing actions (like Trigger module) should take special care for the "presave" hook, in which case a dependent "save" action should NOT be invoked.

Definition at line 3916 of file system.api.php.

References t().

node_assign_owner_action | ( | $node,
 |  | $context
 | ) |

Assigns ownership of a node to a user.

Parameters
$node A node object to modify.
$context Array with the following elements:
  • 'owner_uid': User ID to assign to the node.
See Also
node_assign_owner_action_form()
node_assign_owner_action_validate()
node_assign_owner_action_submit()

Definition at line 3956 of file node.module.

References db_query(), node_type_get_name(), and watchdog().

node_make_sticky_action | ( | $node,
 |  | $context = array()
 | ) |

Sets the sticky-at-top-of-list property of a node to 1.

Parameters
$node | A node object.
$context | (optional) Array of additional information about what triggered the action. Not used for this action.

Definition at line 3876 of file node.module.

References NODE_STICKY, node_type_get_name(), and watchdog().

node_make_unsticky_action | ( | $node,
 |  | $context = array()
 | ) |

Sets the sticky-at-top-of-list property of a node to 0.

Parameters
$node | A node object.
$context | (optional) Array of additional information about what triggered the action. Not used for this action.

Definition at line 3892 of file node.module.

References NODE_NOT_STICKY, node_type_get_name(), and watchdog().

node_promote_action | ( | $node,
 |  | $context = array()
 | ) |

Sets the promote property of a node to 1.

Parameters
$node | A node object.
$context | (optional) Array of additional information about what triggered the action. Not used for this action.

Definition at line 3908 of file node.module.

References NODE_PROMOTED, node_type_get_name(), and watchdog().

node_publish_action | ( | $node,
 |  | $context = array()
 | ) |

Sets the status of a node to 1 (published).

Parameters
$node | A node object.
$context | (optional) Array of additional information about what triggered the action. Not used for this action.

Definition at line 3844 of file node.module.

References NODE_PUBLISHED, node_type_get_name(), and watchdog().

node_save_action ( $node )

Saves a node.

Parameters
$node The node to be saved.

Definition at line 3937 of file node.module.

References node_save(), node_type_get_name(), and watchdog().

node_unpromote_action | ( | $node,
 |  | $context = array()
 | ) |

Sets the promote property of a node to 0.

Parameters
$node | A node object.
$context | (optional) Array of additional information about what triggered the action. Not used for this action.

Definition at line 3924 of file node.module.

References NODE_NOT_PROMOTED, node_type_get_name(), and watchdog().

node_unpublish_action | ( | $node,
 |  | $context = array()
 | ) |

Sets the status of a node to 0 (unpublished).

Parameters
$node | A node object.
$context | (optional) Array of additional information about what triggered the action. Not used for this action.

Definition at line 3860 of file node.module.

References NODE_NOT_PUBLISHED, node_type_get_name(), and watchdog().

node_unpublish_by_keyword_action | ( | $node,
 |  | $context
 | ) |

Unpublishes a node containing certain keywords.

Parameters
$node A node object to modify.
$context Array with the following elements:
  • 'keywords': Array of keywords. If any keyword is present in the rendered node, the node's status flag is set to unpublished.

Definition at line 4075 of file node.module.

References drupal_render(), NODE_NOT_PUBLISHED, node_type_get_name(), node_view(), and watchdog().

system_block_ip_action ( )

Blocks the current user's IP address.

Definition at line 3321 of file system.module.

References db_insert(), ip_address(), and watchdog().

system_goto_action | ( | $entity,
 |  | $context
 | ) |

Redirects to a different URL.

Parameters
$entity Ignored.
array $context Array with the following elements:
  • 'url': URL to redirect to. This will be passed through token_replace().
  • Other elements will be used as the data for token replacement.

Definition at line 3312 of file system.module.

References drupal_goto(), and token_replace().

system_message_action | ( | & | $entity,
 |  |  | $context = array()
 | ) |  |

Sends a message to the current user's screen.

Parameters
object $entity An optional node object, which will be added as $context['node'] if provided.
array $context Array with the following elements:
  • 'message': The message to send. This will be passed through token_replace().
  • Other elements will be used as the data for token replacement in the message.

Definition at line 3270 of file system.module.

References drupal_set_message(), filter_xss_admin(), and token_replace().

system_send_email_action | ( | $entity,
 |  | $context
 | ) |

Sends an e-mail message.

Parameters
object $entity An optional node object, which will be added as $context['node'] if provided.
array $context Array with the following elements:
  • 'recipient': E-mail message recipient. This will be passed through token_replace().
  • 'subject': The subject of the message. This will be passed through token_replace().
  • 'message': The message to send. This will be passed through token_replace().
  • Other elements will be used as the data for token replacement.

Definition at line 3199 of file system.module.

References drupal_mail(), language_default(), token_replace(), user_load_by_mail(), user_preferred_language(), and watchdog().

user_block_user_action | ( | & | $entity,
 |  |  | $context = array()
 | ) |  |

Blocks a specific user or the current user, if one is not specified.

Parameters
$entity | (optional) An entity object; if it is provided and it has a uid property, the user with that ID is blocked.
$context | (optional) An associative array; if no user ID is found in $entity, the 'uid' element of this array determines the user to block.

Definition at line 3691 of file user.module.

References user_load(), user_save(), and watchdog().

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: Ajax framework

Functions
Ajax framework

Functions

ajax_render ($commands=array())
ajax_get_form ()
ajax_form_callback ()
ajax_base_page_theme ()
ajax_deliver ($page_callback_result)
ajax_prepare_response ($page_callback_result)
ajax_footer ()
ajax_process_form ($element, &$form_state)
ajax_pre_render_element ($element)

Detailed Description

Functions for Drupal's Ajax framework.

Drupal's Ajax framework is used to dynamically update parts of a page's HTML based on data from the server. Upon a specified event, such as a button click, a callback function is triggered which performs server-side logic and may return updated markup, which is then replaced on-the-fly with no page refresh necessary.

This framework creates a PHP macro language that allows the server to instruct JavaScript to perform actions on the client browser. When using forms, it can be used with the #ajax property. The #ajax property can be used to bind events to the Ajax framework. By default, #ajax uses 'system/ajax' as its path for submission and thus calls ajax_form_callback() and a defined #ajax['callback'] function. However, you may optionally specify a different path to request or a different callback function to invoke, which can return updated HTML or can also return a richer set of Ajax framework commands .

Standard form handling is as follows:

  • A form element has a #ajax property that includes #ajax['callback'] and omits #ajax['path']. See below about using #ajax['path'] to implement advanced use-cases that require something other than standard form handling.
  • On the specified element, Ajax processing is triggered by a change to that element.
  • The browser submits an HTTP POST request to the 'system/ajax' Drupal path.
  • The menu page callback for 'system/ajax', ajax_form_callback(), calls drupal_process_form() to process the form submission and rebuild the form if necessary. The form is processed in much the same way as if it were submitted without Ajax, with the same #process functions and validation and submission handlers called in either case, making it easy to create Ajax-enabled forms that degrade gracefully when JavaScript is disabled.
  • After form processing is complete, ajax_form_callback() calls the function named by #ajax['callback'], which returns the form element that has been updated and needs to be returned to the browser, or alternatively, an array of custom Ajax commands.
  • The page delivery callback for 'system/ajax', ajax_deliver(), renders the element returned by #ajax['callback'], and returns the JSON string created by ajax_render() to the browser.
  • The browser unserializes the returned JSON string into an array of command objects and executes each command, resulting in the old page content within and including the HTML element specified by #ajax['wrapper'] being replaced by the new content returned by #ajax['callback'], using a JavaScript animation effect specified by #ajax['effect'].

A simple example of basic Ajax use from the Examples module follows:

* function main_page() {
* return drupal_get_form('ajax_example_simplest');
* }
*
* function ajax_example_simplest($form, &$form_state) {
* $form = array();
* $form['changethis'] = array(
* '#type' => 'select',
* '#options' => array(
* 'one' => 'one',
* 'two' => 'two',
* 'three' => 'three',
* ),
* '#ajax' => array(
* 'callback' => 'ajax_example_simplest_callback',
* 'wrapper' => 'replace_textfield_div',
* ),
* );
* // This entire form element will be replaced with an updated value.
* $form['replace_textfield'] = array(
* '#type' => 'textfield',
* '#title' => t("The default value will be changed"),
* '#description' => t("Say something about why you chose") . "'" .
* (!empty($form_state['values']['changethis'])
* ? $form_state['values']['changethis'] : t("Not changed yet")) . "'",
* '#prefix' => '<div id="replace_textfield_div">',
* '#suffix' => '</div>',
* );
* return $form;
* }
*
* function ajax_example_simplest_callback($form, $form_state) {
* // The form has already been submitted and updated. We can return the replaced
* // item as it is.
* return $form['replace_textfield'];
* }
*

In the above example, the 'changethis' element is Ajax-enabled. The default #ajax['event'] is 'change', so when the 'changethis' element changes, an Ajax call is made. The form is submitted and reprocessed, and then the callback is called. In this case, the form has been automatically built changing $form['replace_textfield']['#description'], so the callback just returns that part of the form.

To implement Ajax handling in a form, add '#ajax' to the form definition of a field. That field will trigger an Ajax event when it is clicked (or changed, depending on the kind of field). #ajax supports the following parameters (either 'path' or 'callback' is required at least):

  • #ajax['callback']: The callback to invoke to handle the server side of the Ajax event, which will receive a $form and $form_state as arguments, and returns a renderable array (most often a form or form fragment), an HTML string, or an array of Ajax commands. If returning a renderable array or a string, the value will replace the original element named in #ajax['wrapper'], and theme_status_messages() will be prepended to that element. (If the status messages are not wanted, return an array of Ajax commands instead.) #ajax['wrapper']. If an array of Ajax commands is returned, it will be executed by the calling code.
  • #ajax['path']: The menu path to use for the request. This is often omitted and the default is used. This path should map to a menu page callback that returns data using ajax_render(). Defaults to 'system/ajax', which invokes ajax_form_callback(), eventually calling the function named in #ajax['callback']. If you use a custom path, you must set up the menu entry and handle the entire callback in your own code.
  • #ajax['wrapper']: The CSS ID of the area to be replaced by the content returned by the #ajax['callback'] function. The content returned from the callback will replace the entire element named by #ajax['wrapper']. The wrapper is usually created using #prefix and #suffix properties in the form. Note that this is the wrapper ID, not a CSS selector. So to replace the element referred to by the CSS selector #some-selector on the page, use #ajax['wrapper'] = 'some-selector', not '#some-selector'.
  • #ajax['effect']: The jQuery effect to use when placing the new HTML. Defaults to no effect. Valid options are 'none', 'slide', or 'fade'.
  • #ajax['speed']: The effect speed to use. Defaults to 'slow'. May be 'slow', 'fast' or a number in milliseconds which represents the length of time the effect should run.
  • #ajax['event']: The JavaScript event to respond to. This is normally selected automatically for the type of form widget being used, and is only needed if you need to override the default behavior.
  • #ajax['prevent']: A JavaScript event to prevent when 'event' is triggered. Defaults to 'click' for #ajax on #type 'submit', 'button', and 'image_button'. Multiple events may be specified separated by spaces. For example, when binding #ajax behaviors to form buttons, pressing the ENTER key within a textfield triggers the 'click' event of the form's first submit button. Triggering Ajax in this situation leads to problems, like breaking autocomplete textfields. Because of that, Ajax behaviors are bound to the 'mousedown' event on form buttons by default. However, binding to 'mousedown' rather than 'click' means that it is possible to trigger a click by pressing the mouse, holding the mouse button down until the Ajax request is complete and the button is re-enabled, and then releasing the mouse button. For this case, 'prevent' can be set to 'click', so an additional event handler is bound to prevent such a click from triggering a non-Ajax form submission. This also prevents a textfield's ENTER press triggering a button's non-Ajax form submission behavior.
  • #ajax['method']: The jQuery method to use to place the new HTML. Defaults to 'replaceWith'. May be: 'replaceWith', 'append', 'prepend', 'before', 'after', or 'html'. See the jQuery manipulators documentation for more information on these methods.
  • #ajax['progress']: Choose either a throbber or progress bar that is displayed while awaiting a response from the callback, and add an optional message. Possible keys: 'type', 'message', 'url', 'interval'. More information is available in the Form API Reference

In addition to using Form API for doing in-form modification, Ajax may be enabled by adding classes to buttons and links. By adding the 'use-ajax' class to a link, the link will be loaded via an Ajax call. When using this method, the href of the link can contain '/nojs/' as part of the path. When the Ajax framework makes the request, it will convert this to '/ajax/'. The server is then able to easily tell if this request was made through an actual Ajax request or in a degraded state, and respond appropriately.

Similarly, submit buttons can be given the class 'use-ajax-submit'. The form will then be submitted via Ajax to the path specified in the #action. Like the ajax-submit class above, this path will have '/nojs/' replaced with '/ajax/' so that the submit handler can tell if the form was submitted in a degraded state or not.

When responding to Ajax requests, the server should do what it needs to do for that request, then create a commands array. This commands array will be converted to a JSON object and returned to the client, which will then iterate over the array and process it like a macro language.

Each command item is an associative array which will be converted to a command object on the JavaScript side. $command_item['command'] is the type of command, e.g. 'alert' or 'replace', and will correspond to a method in the Drupal.ajax[command] space. The command array may contain any other data that the command needs to process, e.g. 'method', 'selector', 'settings', etc.

Commands are usually created with a couple of helper functions, so they look like this:

* $commands = array();
* // Replace the content of '#object-1' on the page with 'some html here'.
* $commands[] = ajax_command_replace('#object-1', 'some html here');
* // Add a visual "changed" marker to the '#object-1' element.
* $commands[] = ajax_command_changed('#object-1');
* // Menu 'page callback' and #ajax['callback'] functions are supposed to
* // return render arrays. If returning an Ajax commands array, it must be
* // encapsulated in a render array structure.
* return array('#type' => 'ajax', '#commands' => $commands);
*

When returning an Ajax command array, it is often useful to have status messages rendered along with other tasks in the command array. In that case the the Ajax commands array may be constructed like this:

* $commands = array();
* $commands[] = ajax_command_replace(NULL, $output);
* $commands[] = ajax_command_prepend(NULL, theme('status_messages'));
* return array('#type' => 'ajax', '#commands' => $commands);
*

See Ajax framework commands

Function Documentation

ajax_base_page_theme ( )

Theme callback for Ajax requests.

Many different pages can invoke an Ajax request to system/ajax or another generic Ajax path. It is almost always desired for an Ajax response to be rendered using the same theme as the base page, because most themes are built with the assumption that they control the entire page, so if the CSS for two themes are both loaded for a given page, they may conflict with each other. For example, Bartik is Drupal's default theme, and Seven is Drupal's default administration theme. Depending on whether the "Use the administration theme when editing or creating content" checkbox is checked, the node edit form may be displayed in either theme, but the Ajax response to the Field module's "Add another item" button should be rendered using the same theme as the rest of the page. Therefore, system_menu() sets the 'theme callback' for 'system/ajax' to this function, and it is recommended that modules implementing other generic Ajax paths do the same.

See Also
system_menu()
file_menu()

Definition at line 406 of file ajax.inc.

References drupal_valid_token(), and variable_get().

ajax_deliver ( $page_callback_result )

Packages and sends the result of a page callback as an Ajax response.

This function is the equivalent of drupal_deliver_html_page(), but for Ajax requests. Like that function, it:

  • Adds needed HTTP headers.
  • Prints rendered output.
  • Performs end-of-request tasks.
Parameters
$page_callback_result The result of a page callback. Can be one of:
  • NULL: to indicate no content.
  • An integer menu status constant: to indicate an error condition.
  • A string of HTML content.
  • A renderable array of content.
See Also
drupal_deliver_html_page()

Definition at line 440 of file ajax.inc.

References ajax_footer(), ajax_prepare_response(), ajax_render(), drupal_add_http_header(), drupal_get_http_header(), and print.

Referenced by ajax_link_response().

ajax_footer ( )

Performs end-of-Ajax-request tasks.

This function is the equivalent of drupal_page_footer(), but for Ajax requests.

See Also
drupal_page_footer()

Definition at line 563 of file ajax.inc.

References DRUPAL_BOOTSTRAP_FULL, drupal_get_bootstrap_phase(), drupal_session_commit(), MAINTENANCE_MODE, and module_invoke_all().

Referenced by ajax_deliver().

ajax_form_callback ( )

Menu callback; handles Ajax requests for the #ajax Form API property.

This rebuilds the form from cache and invokes the defined #ajax['callback'] to return an Ajax command structure for JavaScript. In case no 'callback' has been defined, nothing will happen.

The Form API #ajax property can be set both for buttons and other input elements.

This function is also the canonical example of how to implement #ajax['path']. If processing is required that cannot be accomplished with a callback, re-implement this function and set #ajax['path'] to the enhanced function.

See Also
system_menu()

Definition at line 368 of file ajax.inc.

References ajax_get_form(), and drupal_process_form().

ajax_get_form ( )

Gets a form submitted via #ajax during an Ajax callback.

This will load a form from the form cache used during Ajax operations. It pulls the form info from $_POST.

Returns
An array containing the $form and $form_state. Use the list() function to break these apart:
* list($form, $form_state, $form_id, $form_build_id) = ajax_get_form();
*

Definition at line 317 of file ajax.inc.

References drupal_exit(), form_get_cache(), form_state_defaults(), watchdog(), and WATCHDOG_WARNING.

Referenced by ajax_form_callback(), and file_ajax_upload().

ajax_pre_render_element ( $element )

Adds Ajax information about an element to communicate with JavaScript.

If #ajax['path'] is set on an element, this additional JavaScript is added to the page header to attach the Ajax behaviors. See ajax.js for more information.

Parameters
$element An associative array containing the properties of the element. Properties used:
  • #ajax['event']
  • #ajax['prevent']
  • #ajax['path']
  • #ajax['options']
  • #ajax['wrapper']
  • #ajax['parameters']
  • #ajax['effect']
Returns
The processed element with the necessary JavaScript attached to it.

Definition at line 618 of file ajax.inc.

References url().

Referenced by ajax_process_form(), and drupal_pre_render_link().

ajax_prepare_response ( $page_callback_result )

Converts the return value of a page callback into an Ajax commands array.

Parameters
$page_callback_result The result of a page callback. Can be one of:
  • NULL: to indicate no content.
  • An integer menu status constant: to indicate an error condition.
  • A string of HTML content.
  • A renderable array of content.
Returns
An Ajax commands array that can be passed to ajax_render().

Definition at line 501 of file ajax.inc.

References ajax_command_alert(), ajax_command_insert(), ajax_command_prepend(), drupal_render(), element_info(), filter_xss_admin(), MENU_ACCESS_DENIED, MENU_NOT_FOUND, MENU_SITE_OFFLINE, t(), theme(), and variable_get().

Referenced by ajax_deliver().

ajax_process_form | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Form element processing handler for the #ajax form property.

Parameters
$element An associative array containing the properties of the element.
Returns
The processed element.
See Also
ajax_pre_render_element()

Definition at line 589 of file ajax.inc.

References ajax_pre_render_element().

ajax_render ( $commands = array() )

Renders a commands array into JSON.

Parameters
$commands A list of macro commands generated by the use of ajax_command_*() functions.

Definition at line 232 of file ajax.inc.

References $scripts, $styles, ajax_command_append(), ajax_command_prepend(), ajax_command_settings(), drupal_add_js(), drupal_alter(), drupal_get_css(), drupal_get_js(), and drupal_json_encode().

Referenced by ajax_deliver().

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: Ajax framework commands

Functions
Ajax framework commands

Functions

ajax_command_alert ($text)
ajax_command_insert ($selector, $html, $settings=NULL)
ajax_command_replace ($selector, $html, $settings=NULL)
ajax_command_html ($selector, $html, $settings=NULL)
ajax_command_prepend ($selector, $html, $settings=NULL)
ajax_command_append ($selector, $html, $settings=NULL)
ajax_command_after ($selector, $html, $settings=NULL)
ajax_command_before ($selector, $html, $settings=NULL)
ajax_command_remove ($selector)
ajax_command_changed ($selector, $asterisk= '')
ajax_command_css ($selector, $argument)
ajax_command_settings ($argument, $merge=FALSE)
ajax_command_data ($selector, $name, $value)
ajax_command_invoke ($selector, $method, array $arguments=array())
ajax_command_restripe ($selector)

Detailed Description

End of "defgroup ajax".

Functions to create various Ajax commands.

These functions can be used to create arrays for use with the ajax_render() function.

Function Documentation

ajax_command_after | ( | $selector,
 |  | $html,
 |  | $settings = NULL
 | ) |

Creates a Drupal Ajax 'insert/after' command.

The 'insert/after' command instructs the client to use jQuery's after() method to insert the given HTML content after each element matched by the given selector.

This command is implemented by Drupal.ajax.prototype.commands.insert() defined in misc/ajax.js.

Parameters
$selector | A jQuery selector string. If the command is a response to a request from an #ajax form element then this value can be NULL.
$html | The data to use with the jQuery after() method.
$settings | An optional array of settings that will be used for this command only.
Returns
An array suitable for use with the ajax_render() function.
See Also
http://docs.jquery.com/Manipulation/after#content

Definition at line 974 of file ajax.inc.

Referenced by ajax_example_advanced_commands_after_callback().

ajax_command_alert ( $text )

Creates a Drupal Ajax 'alert' command.

The 'alert' command instructs the client to display a JavaScript alert dialog box.

This command is implemented by Drupal.ajax.prototype.commands.alert() defined in misc/ajax.js.

Parameters
$text The message string to display to the user.
Returns
An array suitable for use with the ajax_render() function.

Definition at line 780 of file ajax.inc.

Referenced by ajax_example_advanced_commands_alert_callback(), and ajax_prepare_response().

ajax_command_append | ( | $selector,
 |  | $html,
 |  | $settings = NULL
 | ) |

Creates a Drupal Ajax 'insert/append' command.

The 'insert/append' command instructs the client to use jQuery's append() method to append the given HTML content to the inside of each element matched by the given selector.

This command is implemented by Drupal.ajax.prototype.commands.insert() defined in misc/ajax.js.

Parameters
$selector | A jQuery selector string. If the command is a response to a request from an #ajax form element then this value can be NULL.
$html | The data to use with the jQuery append() method.
$settings | An optional array of settings that will be used for this command only.
Returns
An array suitable for use with the ajax_render() function.
See Also
http://docs.jquery.com/Manipulation/append#content

Definition at line 941 of file ajax.inc.

Referenced by ajax_example_advanced_commands_append_callback(), ajax_link_response(), and ajax_render().

ajax_command_before | ( | $selector,
 |  | $html,
 |  | $settings = NULL
 | ) |

Creates a Drupal Ajax 'insert/before' command.

The 'insert/before' command instructs the client to use jQuery's before() method to insert the given HTML content before each of elements matched by the given selector.

This command is implemented by Drupal.ajax.prototype.commands.insert() defined in misc/ajax.js.

Parameters
$selector | A jQuery selector string. If the command is a response to a request from an #ajax form element then this value can be NULL.
$html | The data to use with the jQuery before() method.
$settings | An optional array of settings that will be used for this command only.
Returns
An array suitable for use with the ajax_render() function.
See Also
http://docs.jquery.com/Manipulation/before#content

Definition at line 1007 of file ajax.inc.

Referenced by ajax_example_advanced_commands_before_callback().

ajax_command_changed | ( | $selector,
 |  | $asterisk = ''
 | ) |

Creates a Drupal Ajax 'changed' command.

This command instructs the client to mark each of the elements matched by the given selector as 'ajax-changed'.

This command is implemented by Drupal.ajax.prototype.commands.changed() defined in misc/ajax.js.

Parameters
$selector | A jQuery selector string. If the command is a response to a request from an #ajax form element then this value can be NULL.
$asterisk | An optional CSS selector which must be inside $selector. If specified, an asterisk will be appended to the HTML inside the $asterisk selector.
Returns
An array suitable for use with the ajax_render() function.

Definition at line 1062 of file ajax.inc.

Referenced by ajax_example_advanced_commands_changed_callback().

ajax_command_css | ( | $selector,
 |  | $argument
 | ) |

Creates a Drupal Ajax 'css' command.

The 'css' command will instruct the client to use the jQuery css() method to apply the CSS arguments to elements matched by the given selector.

This command is implemented by Drupal.ajax.prototype.commands.css() defined in misc/ajax.js.

Parameters
$selector | A jQuery selector string. If the command is a response to a request from an #ajax form element then this value can be NULL.
$argument | An array of key/value pairs to set in the CSS for the selector.
Returns
An array suitable for use with the ajax_render() function.
See Also
http://docs.jquery.com/CSS/css#properties

Definition at line 1090 of file ajax.inc.

Referenced by ajax_example_advanced_commands_css_callback().

ajax_command_data | ( | $selector,
 |  | $name,
 |  | $value
 | ) |

Creates a Drupal Ajax 'data' command.

The 'data' command instructs the client to attach the name=value pair of data to the selector via jQuery's data cache.

This command is implemented by Drupal.ajax.prototype.commands.data() defined in misc/ajax.js.

Parameters
$selector | A jQuery selector string. If the command is a response to a request from an #ajax form element then this value can be NULL.
$name | The name or key (in the key value pair) of the data attached to this selector.
$value | The value of the data. Not just limited to strings can be any format.
Returns
An array suitable for use with the ajax_render() function.
See Also
http://docs.jquery.com/Core/data#namevalue

Definition at line 1152 of file ajax.inc.

References $name, and $value.

Referenced by ajax_example_advanced_commands_data_callback().

ajax_command_html | ( | $selector,
 |  | $html,
 |  | $settings = NULL
 | ) |

Creates a Drupal Ajax 'insert/html' command.

The 'insert/html' command instructs the client to use jQuery's html() method to set the HTML content of each element matched by the given selector while leaving the outer tags intact.

This command is implemented by Drupal.ajax.prototype.commands.insert() defined in misc/ajax.js.

Parameters
$selector | A jQuery selector string. If the command is a response to a request from an #ajax form element then this value can be NULL.
$html | The data to use with the jQuery html() method.
$settings | An optional array of settings that will be used for this command only.
Returns
An array suitable for use with the ajax_render() function.
See Also
http://docs.jquery.com/Attributes/html#val

Definition at line 875 of file ajax.inc.

Referenced by ajax_example_advanced_commands_html_callback(), and ajax_example_advanced_commands_remove_callback().

ajax_command_insert | ( | $selector,
 |  | $html,
 |  | $settings = NULL
 | ) |

Creates a Drupal Ajax 'insert' command using the method in #ajax['method'].

This command instructs the client to insert the given HTML using whichever jQuery DOM manipulation method has been specified in the #ajax['method'] variable of the element that triggered the request.

This command is implemented by Drupal.ajax.prototype.commands.insert() defined in misc/ajax.js.

Parameters
$selector | A jQuery selector string. If the command is a response to a request from an #ajax form element then this value can be NULL.
$html | The data to use with the jQuery method.
$settings | An optional array of settings that will be used for this command only.
Returns
An array suitable for use with the ajax_render() function.

Definition at line 808 of file ajax.inc.

Referenced by ajax_prepare_response().

ajax_command_invoke | ( |  | $selector,
 |  |  | $method,
 |  | array | $arguments = array()
 | ) |  |

Creates a Drupal Ajax 'invoke' command.

The 'invoke' command will instruct the client to invoke the given jQuery method with the supplied arguments on the elements matched by the given selector. Intended for simple jQuery commands, such as attr(), addClass(), removeClass(), toggleClass(), etc.

This command is implemented by Drupal.ajax.prototype.commands.invoke() defined in misc/ajax.js.

Parameters
$selector | A jQuery selector string. If the command is a response to a request from an #ajax form element then this value can be NULL.
$method | The jQuery method to invoke.
$arguments | (optional) A list of arguments to the jQuery $method, if any.
Returns
An array suitable for use with the ajax_render() function.

Definition at line 1183 of file ajax.inc.

ajax_command_prepend | ( | $selector,
 |  | $html,
 |  | $settings = NULL
 | ) |

Creates a Drupal Ajax 'insert/prepend' command.

The 'insert/prepend' command instructs the client to use jQuery's prepend() method to prepend the given HTML content to the inside each element matched by the given selector.

This command is implemented by Drupal.ajax.prototype.commands.insert() defined in misc/ajax.js.

Parameters
$selector | A jQuery selector string. If the command is a response to a request from an #ajax form element then this value can be NULL.
$html | The data to use with the jQuery prepend() method.
$settings | An optional array of settings that will be used for this command only.
Returns
An array suitable for use with the ajax_render() function.
See Also
http://docs.jquery.com/Manipulation/prepend#content

Definition at line 908 of file ajax.inc.

Referenced by ajax_example_advanced_commands_prepend_callback(), ajax_prepare_response(), ajax_render(), and hook_ajax_render_alter().

ajax_command_remove ( $selector )

Creates a Drupal Ajax 'remove' command.

The 'remove' command instructs the client to use jQuery's remove() method to remove each of elements matched by the given selector, and everything within them.

This command is implemented by Drupal.ajax.prototype.commands.remove() defined in misc/ajax.js.

Parameters
$selector A jQuery selector string. If the command is a response to a request from an #ajax form element then this value can be NULL.
Returns
An array suitable for use with the ajax_render() function.
See Also
http://docs.jquery.com/Manipulation/remove#expr

Definition at line 1036 of file ajax.inc.

Referenced by ajax_example_advanced_commands_remove_callback().

ajax_command_replace | ( | $selector,
 |  | $html,
 |  | $settings = NULL
 | ) |

Creates a Drupal Ajax 'insert/replaceWith' command.

The 'insert/replaceWith' command instructs the client to use jQuery's replaceWith() method to replace each element matched matched by the given selector with the given HTML.

This command is implemented by Drupal.ajax.prototype.commands.insert() defined in misc/ajax.js.

Parameters
$selector | A jQuery selector string. If the command is a response to a request from an #ajax form element then this value can be NULL.
$html | The data to use with the jQuery replaceWith() method.
$settings | An optional array of settings that will be used for this command only.
Returns
An array suitable for use with the ajax_render() function.

See jQuery replaceWith command

Definition at line 842 of file ajax.inc.

Referenced by ajax_example_advanced_commands_after_callback(), ajax_example_advanced_commands_append_callback(), ajax_example_advanced_commands_before_callback(), ajax_example_advanced_commands_changed_callback(), ajax_example_advanced_commands_css_callback(), ajax_example_advanced_commands_data_callback(), ajax_example_advanced_commands_html_callback(), ajax_example_advanced_commands_prepend_callback(), ajax_example_advanced_commands_remove_callback(), ajax_example_advanced_commands_restripe_callback(), and file_ajax_upload().

ajax_command_restripe ( $selector )

Creates a Drupal Ajax 'restripe' command.

The 'restripe' command instructs the client to restripe a table. This is usually used after a table has been modified by a replace or append command.

This command is implemented by Drupal.ajax.prototype.commands.restripe() defined in misc/ajax.js.

Parameters
$selector A jQuery selector string.
Returns
An array suitable for use with the ajax_render() function.

Definition at line 1207 of file ajax.inc.

Referenced by ajax_example_advanced_commands_restripe_callback().

ajax_command_settings | ( | $argument,
 |  | $merge = FALSE
 | ) |

Creates a Drupal Ajax 'settings' command.

The 'settings' command instructs the client either to use the given array as the settings for ajax-loaded content or to extend Drupal.settings with the given array, depending on the value of the $merge parameter.

This command is implemented by Drupal.ajax.prototype.commands.settings() defined in misc/ajax.js.

Parameters
$argument | An array of key/value pairs to add to the settings. This will be utilized for all commands after this if they do not include their own settings array.
$merge | Whether or not the passed settings in $argument should be merged into the global Drupal.settings on the page. By default (FALSE), the settings that are passed to Drupal.attachBehaviors will not include the global Drupal.settings.
Returns
An array suitable for use with the ajax_render() function.

Definition at line 1121 of file ajax.inc.

Referenced by ajax_render().

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: Logging severity levels

Functions | Variables
Logging severity levels

Functions

watchdog_severity_levels ()
drupal_error_levels ()
dblog_overview ()

Variables

const | WATCHDOG_EMERGENCY 0
const | WATCHDOG_ALERT 1
const | WATCHDOG_CRITICAL 2
const | WATCHDOG_ERROR 3
const | WATCHDOG_WARNING 4
const | WATCHDOG_NOTICE 5
const | WATCHDOG_INFO 6
const | WATCHDOG_DEBUG 7

Detailed Description

Logging severity levels as defined in RFC 3164.

The WATCHDOG_* constant definitions correspond to the logging severity levels defined in RFC 3164, section 4.1.1. PHP supplies predefined LOG_* constants for use in the syslog() function, but their values on Windows builds do not correspond to RFC 3164. The associated PHP bug report was closed with the comment, "And it's also not a bug, as Windows just have less log levels," and "So the behavior you're seeing is perfectly normal."

See Also
http://www.faqs.org/rfcs/rfc3164.html
http://bugs.php.net/bug.php?id=18090
http://php.net/manual/function.syslog.php
http://php.net/manual/network.constants.php
watchdog()
watchdog_severity_levels()

Function Documentation

dblog_overview ( )

Page callback: Displays a listing of database log messages.

Messages are truncated at 56 chars. Full-length messages can be viewed on the message details page.

See Also
dblog_clear_log_form()
dblog_event()
dblog_filter_form()
dblog_menu()

Definition at line 21 of file dblog.admin.inc.

References $classes, $header, db_select(), dblog_build_filter_query(), drupal_get_form(), drupal_html_class(), filter_xss(), format_date(), t(), theme(), WATCHDOG_ALERT, WATCHDOG_CRITICAL, WATCHDOG_DEBUG, WATCHDOG_EMERGENCY, WATCHDOG_ERROR, WATCHDOG_INFO, WATCHDOG_NOTICE, and WATCHDOG_WARNING.

drupal_error_levels ( )

Maps PHP error constants to watchdog severity levels.

The error constants are documented at http://php.net/manual/errorfunc.constants.php

Definition at line 16 of file errors.inc.

References WATCHDOG_DEBUG, WATCHDOG_ERROR, WATCHDOG_NOTICE, and WATCHDOG_WARNING.

Referenced by _drupal_error_handler_real().

watchdog_severity_levels ( )

Returns a list of severity levels, as defined in RFC 3164.

Returns
Array of the possible severity levels for log messages.
See Also
http://www.ietf.org/rfc/rfc3164.txt
watchdog()

Definition at line 7389 of file common.inc.

References t(), WATCHDOG_ALERT, WATCHDOG_CRITICAL, WATCHDOG_DEBUG, WATCHDOG_EMERGENCY, WATCHDOG_ERROR, WATCHDOG_INFO, WATCHDOG_NOTICE, and WATCHDOG_WARNING.

Referenced by dblog_event(), and dblog_filters().

Variable Documentation

const WATCHDOG_ALERT 1

Log message severity – Alert: action must be taken immediately.

Definition at line 83 of file bootstrap.inc.

Referenced by check_markup(), dblog_overview(), hook_watchdog(), and watchdog_severity_levels().

const WATCHDOG_CRITICAL 2

Log message severity – Critical conditions.

Definition at line 88 of file bootstrap.inc.

Referenced by dblog_overview(), hook_watchdog(), openid_verify_assertion_nonce(), and watchdog_severity_levels().

const WATCHDOG_DEBUG 7

Log message severity – Debug-level messages.

Definition at line 113 of file bootstrap.inc.

Referenced by dblog_overview(), drupal_error_levels(), hook_watchdog(), and watchdog_severity_levels().

const WATCHDOG_EMERGENCY 0

Log message severity – Emergency: system is unusable.

Definition at line 78 of file bootstrap.inc.

Referenced by dblog_overview(), hook_watchdog(), and watchdog_severity_levels().

const WATCHDOG_ERROR 3

Log message severity – Error conditions.

Definition at line 93 of file bootstrap.inc.

Referenced by _drupal_decode_exception(), _form_validate(), _locale_rebuild_js(), actions_do(), dblog_overview(), drupal_chmod(), drupal_deliver_page(), drupal_error_levels(), drupal_mail(), file_create_htaccess(), file_unmanaged_copy(), file_unmanaged_delete(), hook_watchdog(), image_crop_effect(), image_desaturate_effect(), image_example_colorize_effect(), image_resize_effect(), image_rotate_effect(), image_scale_and_crop_effect(), image_scale_effect(), image_style_create_derivative(), image_toolkit_invoke(), locale_translate_import_form_submit(), system_check_directory(), system_cron(), user_admin_settings(), user_cancel(), and watchdog_severity_levels().

const WATCHDOG_INFO 6

Log message severity – Informational messages.

Definition at line 108 of file bootstrap.inc.

Referenced by actions_synchronize(), dblog_overview(), drupal_uninstall_modules(), hook_watchdog(), module_disable(), module_enable(), system_cron(), and watchdog_severity_levels().

const WATCHDOG_NOTICE 5

Log message severity – Normal but significant conditions.

Definition at line 103 of file bootstrap.inc.

Referenced by _user_cancel(), aggregator_form_category_submit(), aggregator_form_feed_submit(), book_admin_edit_submit(), comment_form_submit(), contact_category_delete_form_submit(), contact_category_edit_form_submit(), dblog_overview(), drupal_cron_run(), drupal_error_levels(), file_unmanaged_delete(), hook_watchdog(), menu_delete_menu_confirm_submit(), menu_item_delete_form_submit(), node_form_submit(), node_type_delete_confirm_submit(), node_type_form_submit(), profile_field_delete_submit(), profile_field_form_submit(), search_view(), taxonomy_form_term_submit(), taxonomy_form_vocabulary_submit(), taxonomy_term_confirm_delete_submit(), taxonomy_vocabulary_confirm_delete_submit(), taxonomy_vocabulary_confirm_reset_alphabetical_submit(), user_cancel_confirm_form_submit(), user_register_submit(), and watchdog_severity_levels().

const WATCHDOG_WARNING 4

Log message severity – Warning conditions.

Definition at line 98 of file bootstrap.inc.

Referenced by _locale_import_po(), _locale_rebuild_js(), _node_query_node_access_alter(), aggregator_aggregator_fetch(), aggregator_parse_feed(), ajax_get_form(), authorize_access_denied_page(), comment_form_submit(), dblog_overview(), drupal_cron_cleanup(), drupal_cron_run(), drupal_deliver_html_page(), drupal_error_levels(), hook_watchdog(), locale_translate_edit_form_validate(), openid_verify_assertion_nonce(), theme(), update_access_denied_page(), user_user_operations(), and watchdog_severity_levels().

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: PHP wrapper functions

Functions
PHP wrapper functions

Functions

& drupal_register_shutdown_function ($callback=NULL)
drupal_http_build_query (array $query, $parent= '')
drupal_parse_url ($url)
drupal_set_time_limit ($time_limit)
drupal_json_encode ($var)
drupal_json_decode ($var)
drupal_move_uploaded_file ($filename, $uri)
drupal_chmod ($uri, $mode=NULL)
drupal_unlink ($uri, $context=NULL)
drupal_realpath ($uri)
drupal_dirname ($uri)
drupal_basename ($uri, $suffix=NULL)
drupal_mkdir ($uri, $mode=NULL, $recursive=FALSE, $context=NULL)
drupal_rmdir ($uri, $context=NULL)
drupal_tempnam ($directory, $prefix)
drupal_session_start ()
drupal_session_regenerate ()
drupal_xml_parser_create (&$data)
drupal_strlen ($text)
drupal_strtoupper ($text)
drupal_strtolower ($text)
drupal_ucfirst ($text)
drupal_substr ($text, $start, $length=NULL)
php_eval ($code)

Detailed Description

Functions that are wrappers or custom implementations of PHP functions.

Certain PHP functions should not be used in Drupal. Instead, Drupal's replacement functions should be used.

For example, for improved or more secure UTF8-handling, or RFC-compliant handling of URLs in Drupal.

For ease of use and memorizing, all these wrapper functions use the same name as the original PHP function, but prefixed with "drupal_". Beware, however, that not all wrapper functions support the same arguments as the original functions.

You should always use these wrapper functions in your code.

Wrong:

* $my_substring = substr($original_string, 0, 5);
*

Correct:

* $my_substring = drupal_substr($original_string, 0, 5);
*

Function Documentation

drupal_basename | ( | $uri,
 |  | $suffix = NULL
 | ) |

Gets the filename from a given path.

PHP's basename() does not properly support streams or filenames beginning with a non-US-ASCII character.

See Also
http://bugs.php.net/bug.php?id=37738
basename()

Definition at line 2317 of file file.inc.

Referenced by _color_html_alter(), _color_render_images(), _locale_batch_import(), color_scheme_form_submit(), FileTransfer\copyDirectoryJailed(), drupal_get_css(), drupal_tempnam(), file_copy(), file_destination(), file_move(), file_save_data(), file_save_upload(), file_unmanaged_copy(), FileTransfer\findChroot(), Updater\findInfoFile(), DrupalLocalStreamWrapper\getLocalPath(), DrupalLocalStreamWrapper\getMimeType(), Updater\getProjectName(), simpletest_result_form(), system_retrieve_file(), update_manager_file_get(), update_verify_update_archive(), and user_update_7012().

drupal_chmod | ( | $uri,
 |  | $mode = NULL
 | ) |

Sets the permissions on a file or directory.

This function will use the 'file_chmod_directory' and 'file_chmod_file' variables for the default modes for directories and uploaded/generated files. By default these will give everyone read access so that users accessing the files with a user account without the webserver group (e.g. via FTP) can read these files, and give group write permissions so webserver group members (e.g. a vhost account) can alter files uploaded and owned by the webserver.

PHP's chmod does not support stream wrappers so we use our wrapper implementation which interfaces with chmod() by default. Contrib wrappers may override this behavior in their implementations as needed.

Parameters
$uri | A string containing a URI file, or directory path.
$mode | Integer value for the permissions. Consult PHP chmod() documentation for more information.
Returns
TRUE for success, FALSE in the event of an error.

Definition at line 2180 of file file.inc.

References file_stream_wrapper_get_instance_by_uri(), variable_get(), watchdog(), and WATCHDOG_ERROR.

Referenced by _color_render_images(), _color_save_stylesheet(), file_create_htaccess(), file_prepare_directory(), file_save_upload(), file_unmanaged_copy(), image_save(), and system_check_directory().

drupal_dirname ( $uri )

Gets the name of the directory from a given path.

PHP's dirname() does not properly pass streams, so this function fills that gap. It is backwards compatible with normal paths and will use PHP's dirname() as a fallback.

Compatibility: normal paths and stream wrappers.

Parameters
$uri A URI or path.
Returns
A string containing the directory name.
See Also
dirname()
http://drupal.org/node/515192

Definition at line 2295 of file file.inc.

References file_stream_wrapper_get_instance_by_scheme(), file_stream_wrapper_valid_scheme(), and file_uri_scheme().

Referenced by file_destination(), file_unmanaged_copy(), and image_style_create_derivative().

drupal_http_build_query | ( | array | $query,
 |  |  | $parent = ''
 | ) |  |

Parses an array into a valid, rawurlencoded query string.

This differs from http_build_query() as we need to rawurlencode() (instead of urlencode()) all query parameters.

Parameters
$query | The query parameter array to be processed, e.g. $_GET.
$parent | Internal use only. Used to build the $query array key for nested items.
Returns
A rawurlencoded string which can be used as or appended to the URL query string.
See Also
drupal_get_query_parameters()

Definition at line 486 of file common.inc.

References $value.

Referenced by drupal_current_script_url(), drupal_get_destination(), image_style_url(), install_redirect_url(), menu_edit_item(), shortcut_preprocess_page(), and url().

drupal_json_decode ( $var )

Converts an HTML-safe JSON string into its PHP equivalent.

See Also
drupal_json_encode()

Definition at line 5028 of file common.inc.

Referenced by DrupalWebTestCase\drupalGetAJAX(), DrupalWebTestCase\drupalPostAJAX(), and DrupalWebTestCase\drupalSetContent().

drupal_json_encode ( $var )

Converts a PHP variable into its JavaScript equivalent.

We use HTML-safe strings, with several characters escaped.

See Also
drupal_json_decode()
drupal_json_encode_helper()

Definition at line 5003 of file common.inc.

References drupal_json_encode_helper(), and DRUPAL_ROOT.

Referenced by _locale_rebuild_js(), ajax_render(), drupal_get_js(), and drupal_json_output().

drupal_mkdir | ( | $uri,
 |  | $mode = NULL,
 |  | $recursive = FALSE,
 |  | $context = NULL
 | ) |

Creates a directory using Drupal's default mode.

PHP's mkdir() does not respect Drupal's default permissions mode. If a mode is not provided, this function will make sure that Drupal's is used.

Compatibility: normal paths and stream wrappers.

Parameters
$uri | A URI or pathname.
$mode | By default the Drupal mode is used.
$recursive | Default to FALSE.
$context | Refer to http://php.net/manual/ref.stream.php
Returns
Boolean TRUE on success, or FALSE on failure.
See Also
mkdir()
http://drupal.org/node/515192

Definition at line 2359 of file file.inc.

References variable_get().

Referenced by Archive_Tar\_dirCheck(), Archive_Tar\_extractList(), drupal_install_mkdir(), file_prepare_directory(), and system_check_directory().

drupal_move_uploaded_file | ( | $filename,
 |  | $uri
 | ) |

Moves an uploaded file to a new location.

PHP's move_uploaded_file() does not properly support streams if safe_mode or open_basedir are enabled, so this function fills that gap.

Compatibility: normal paths and stream wrappers.

Parameters
$filename | The filename of the uploaded file.
$uri | A string containing the destination URI of the file.
Returns
TRUE on success, or FALSE on failure.
See Also
move_uploaded_file()
http://drupal.org/node/515192

Definition at line 1626 of file file.inc.

References drupal_realpath().

Referenced by file_save_upload().

drupal_parse_url ( $url )

Parses a system URL string into an associative array suitable for url().

This function should only be used for URLs that have been generated by the system, such as via url(). It should not be used for URLs that come from external sources, or URLs that link to external resources.

The returned array contains a 'path' that may be passed separately to url(). For example:

* $options = drupal_parse_url($_GET['destination']);
* $my_url = url($options['path'], $options);
* $my_link = l('Example link', $options['path'], $options);
*

This is required, because url() does not support relative URLs containing a query string or fragment in its $path argument. Instead, any query string needs to be parsed into an associative query parameter array in $options['query'] and the fragment into $options['fragment'].

Parameters
$url The URL string to parse, f.e. $_GET['destination'].
Returns
An associative array containing the keys:
  • 'path': The path of the URL. If the given $url is external, this includes the scheme and host.
  • 'query': An array of query parameters of $url, if existent.
  • 'fragment': The fragment of $url, if existent.
See Also
url()
drupal_goto()

Definition at line 580 of file common.inc.

References $url.

Referenced by _locale_parse_js_file(), confirm_form(), drupal_goto(), and field_ui_get_destinations().

drupal_realpath ( $uri )

Resolves the absolute filepath of a local URI or filepath.

The use of drupal_realpath() is discouraged, because it does not work for remote URIs. Except in rare cases, URIs should not be manually resolved.

Only use this function if you know that the stream wrapper in the URI uses the local file system, and you need to pass an absolute path to a function that is incompatible with stream URIs.

Parameters
string $uri A stream wrapper URI or a filepath, possibly including one or more symbolic links.
Returns
string|false The absolute local filepath (with no symbolic links), or FALSE on failure.
See Also
DrupalStreamWrapperInterface::realpath()
http://php.net/manual/function.realpath.php

Definition at line 2259 of file file.inc.

References file_stream_wrapper_get_instance_by_uri().

Referenced by _color_render_images(), _system_theme_settings_validate_path(), archiver_get_archiver(), FileTransfer\checkPath(), drupal_move_uploaded_file(), DrupalWebTestCase\drupalPost(), file_copy(), file_delete(), file_move(), file_unmanaged_copy(), image_gd_save(), system_retrieve_file(), update_manager_file_get(), update_manager_install_form_submit(), and update_manager_update_ready_form_submit().

& drupal_register_shutdown_function ( $callback = NULL )

Registers a function for execution on shutdown.

Wrapper for register_shutdown_function() that catches thrown exceptions to avoid "Exception thrown without a stack frame in Unknown".

Parameters
$callback The shutdown function to register.
... Additional arguments to pass to the shutdown function.
Returns
Array of shutdown functions to be executed.
See Also
register_shutdown_function()

Definition at line 3417 of file bootstrap.inc.

Referenced by _batch_page(), _drupal_session_read(), _drupal_shutdown_function(), _lock_id(), _menu_clear_page_cache(), drupal_cron_run(), hook_boot(), menu_cache_clear(), DrupalWebTestCase\prepareEnvironment(), and DrupalWebTestCase\tearDown().

drupal_rmdir | ( | $uri,
 |  | $context = NULL
 | ) |

Removes a directory.

PHP's rmdir() is broken on Windows, as it can fail to remove a directory when it has a read-only flag set.

Parameters
$uri | A URI or pathname.
$context | Refer to http://php.net/manual/ref.stream.php
Returns
Boolean TRUE on success, or FALSE on failure.
See Also
rmdir()

Definition at line 2389 of file file.inc.

References file_stream_wrapper_valid_scheme(), and file_uri_scheme().

Referenced by color_scheme_form_submit(), file_unmanaged_delete_recursive(), locale_uninstall(), FileTransferLocal\removeDirectoryJailed(), DrupalLocalStreamWrapper\rmdir(), and system_update_7046().

drupal_session_regenerate ( )

Called when an anonymous user becomes authenticated or vice-versa.

Definition at line 350 of file session.inc.

References db_update(), drupal_get_user_timezone(), drupal_random_key(), drupal_save_session(), drupal_session_start(), drupal_session_started(), REQUEST_TIME, and variable_get().

Referenced by _user_cancel_session_regenerate(), user_login_finalize(), and user_save().

drupal_session_start ( )

Starts a session forcefully, preserving already set session data.

Definition at line 281 of file session.inc.

References drupal_is_cli(), and drupal_session_started().

Referenced by drupal_session_commit(), drupal_session_initialize(), and drupal_session_regenerate().

drupal_set_time_limit ( $time_limit )

Attempts to set the PHP maximum execution time.

This function is a wrapper around the PHP function set_time_limit(). When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out.

It also means that it is possible to decrease the total time limit if the sum of the new time limit and the current time spent running the script is inferior to the original time limit. It is inherent to the way set_time_limit() works, it should rather be called with an appropriate value every time you need to allocate a certain amount of time to execute a task than only once at the beginning of the script.

Before calling set_time_limit(), we check if this function is available because it could be disabled by the server administrator. We also hide all the errors that could occur when calling set_time_limit(), because it is not possible to reliably ensure that PHP or a security extension will not issue a warning/error if they prevent the use of this function.

Parameters
$time_limit An integer specifying the new time limit, in seconds. A value of 0 indicates unlimited execution time.

Definition at line 2786 of file common.inc.

Referenced by _locale_import_po(), drupal_cron_run(), node_access_rebuild(), and DrupalWebTestCase\setUp().

drupal_strlen ( $text )

Counts the number of characters in a UTF-8 string.

This is less than or equal to the byte count.

Parameters
$text The string to run the operation on.
Returns
integer The length of the string.

Definition at line 474 of file unicode.inc.

Referenced by _form_validate(), drupal_html_to_text(), field_create_field(), hook_field_validate(), list_allowed_values_setting_validate(), menu_contextual_links(), SearchQuery\parseWord(), FileExampleSessionStreamWrapper\stream_read(), FileExampleSessionStreamWrapper\stream_seek(), FileExampleSessionStreamWrapper\stream_stat(), FileExampleSessionStreamWrapper\stream_write(), template_preprocess_username(), text_field_validate(), text_summary(), theme_image_formatter(), FileExampleSessionStreamWrapper\url_stat(), user_account_form_validate(), and user_validate_name().

drupal_strtolower ( $text )

Lowercase a UTF-8 string.

Parameters
$text The string to run the operation on.
Returns
string The string in lowercase.

Definition at line 521 of file unicode.inc.

Referenced by _color_rewrite_stylesheet(), block_block_list_alter(), book_export(), TaxonomyTermController\cacheGet(), drupal_html_class(), drupal_html_id(), FileExampleSessionStreamWrapper\getMimeType(), DatabaseSchema_pgsql\processField(), system_admin_menu_block(), taxonomy_autocomplete(), and theme_update_report().

drupal_strtoupper ( $text )

Uppercase a UTF-8 string.

Parameters
$text The string to run the operation on.
Returns
string The string in uppercase.

Definition at line 496 of file unicode.inc.

Referenced by block_example_block_view_alter(), TableSort\orderByHeader(), DatabaseSchema_sqlite\processField(), and DatabaseSchema_mysql\processField().

drupal_substr | ( | $text,
 |  | $start,
 |  | $length = NULL
 | ) |

Cuts off a piece of a string based on character indices and counts.

Follows the same behavior as PHP's own substr() function. Note that for cutting off a string at a known character/substring location, the usage of PHP's normal strpos/substr is safe and much faster.

Parameters
$text | The input string.
$start | The position at which to start reading.
$length | The number of characters to read.
Returns
The shortened string.

Definition at line 585 of file unicode.inc.

Referenced by file_create_url(), Updater\findInfoFile(), menu_contextual_links(), FileExampleSessionStreamWrapper\stream_read(), and template_preprocess_username().

drupal_tempnam | ( | $directory,
 |  | $prefix
 | ) |

Creates a file with a unique filename in the specified directory.

PHP's tempnam() does not return a URI like we want. This function will return a URI if given a URI, or it will return a filepath if given a filepath.

Compatibility: normal paths and stream wrappers.

Parameters
$directory | The directory where the temporary filename will be created.
$prefix | The prefix of the generated temporary filename. Note: Windows uses only the first three characters of prefix.
Returns
The new temporary filename, or FALSE on failure.
See Also
tempnam()
http://drupal.org/node/515192

Definition at line 2424 of file file.inc.

References drupal_basename(), file_stream_wrapper_get_instance_by_scheme(), file_stream_wrapper_valid_scheme(), and file_uri_scheme().

Referenced by file_example_unmanaged_php_submit(), file_unmanaged_save_data(), image_gd_save(), and update_manager_local_transfers_allowed().

drupal_ucfirst ( $text )

Capitalizes the first letter of a UTF-8 string.

Parameters
$text The string to convert.
Returns
The string with the first letter as uppercase.

Definition at line 561 of file unicode.inc.

Referenced by drupal_verify_profile(), system_modules(), and taxonomy_help().

drupal_unlink | ( | $uri,
 |  | $context = NULL
 | ) |

Deletes a file.

PHP's unlink() is broken on Windows, as it can fail to remove a file when it has a read-only flag set.

Parameters
$uri | A URI or pathname.
$context | Refer to http://php.net/manual/ref.stream.php
Returns
Boolean TRUE on success, or FALSE on failure.
See Also
unlink()

Definition at line 2225 of file file.inc.

References file_stream_wrapper_valid_scheme(), and file_uri_scheme().

Referenced by Archive_Tar\__destruct(), Archive_Tar\_cleanFile(), Archive_Tar\_close(), Archive_Tar\_extractList(), color_scheme_form_submit(), file_unmanaged_delete(), install_check_requirements(), FileTransferLocal\removeDirectoryJailed(), FileTransferLocal\removeFileJailed(), system_update_7046(), DrupalLocalStreamWrapper\unlink(), and update_manager_local_transfers_allowed().

drupal_xml_parser_create ( & $data )

Prepares a new XML parser.

This is a wrapper around xml_parser_create() which extracts the encoding from the XML data first and sets the output encoding to UTF-8. This function should be used instead of xml_parser_create(), because PHP 4's XML parser doesn't check the input encoding itself. "Starting from PHP 5, the input encoding is automatically detected, so that the encoding parameter specifies only the output encoding."

This is also where unsupported encodings will be converted. Callers should take this into account: $data might have been changed after the call.

Parameters
$data The XML data which will be parsed later.
Returns
An XML parser object or FALSE on error.

Definition at line 184 of file unicode.inc.

Referenced by _aggregator_parse_opml(), and aggregator_parse_feed().

php_eval ( $code )

Evaluates a string of PHP code.

This is a wrapper around PHP's eval(). It uses output buffering to capture both returned and printed text. Unlike eval(), we require code to be surrounded by <?php ?> tags; in other words, we evaluate the code as if it were a stand-alone PHP file.

Using this wrapper also ensures that the PHP code which is evaluated can not overwrite any variables in the calling code, unlike a regular eval() call.

This function is also used as an implementation of callback_filter_process().

Parameters
$code The code to evaluate.
Returns
A string containing the printed output of the code, followed by the returned output of the code.
See Also
php_filter_info()

Definition at line 63 of file php.module.

References $conf, $output, drupal_get_path(), and print.

Referenced by block_block_list_alter().

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: Block Caching

Variables
Block Caching

Variables

const | DRUPAL_NO_CACHE -1
const | DRUPAL_CACHE_CUSTOM -2
const | DRUPAL_CACHE_PER_ROLE 0x0001
const | DRUPAL_CACHE_PER_USER 0x0002
const | DRUPAL_CACHE_PER_PAGE 0x0004
const | DRUPAL_CACHE_GLOBAL 0x0008

Detailed Description

Constants that define each block's caching state.

Modules specify how their blocks can be cached in their hook_block_info() implementations. Caching can be turned off (DRUPAL_NO_CACHE), managed by the module declaring the block (DRUPAL_CACHE_CUSTOM), or managed by the core Block module. If the Block module is managing the cache, you can specify that the block is the same for every page and user (DRUPAL_CACHE_GLOBAL), or that it can change depending on the page (DRUPAL_CACHE_PER_PAGE) or by user (DRUPAL_CACHE_PER_ROLE or DRUPAL_CACHE_PER_USER). Page and user settings can be combined with a bitwise-binary or operator; for example, DRUPAL_CACHE_PER_ROLE | DRUPAL_CACHE_PER_PAGE means that the block can change depending on the user role or page it is on.

The block cache is cleared in cache_clear_all(), and uses the same clearing policy than page cache (node, comment, user, taxonomy added or updated...). Blocks requiring more fine-grained clearing might consider disabling the built-in block cache (DRUPAL_NO_CACHE) and roll their own.

Note that user 1 is excluded from block caching.

Variable Documentation

const DRUPAL_CACHE_CUSTOM -2

The block is handling its own caching in its hook_block_view().

This setting is useful when time based expiration is needed or a site uses a node access which invalidates standard block cache.

Definition at line 135 of file common.inc.

Referenced by _block_get_cache_id(), and forum_block_info().

const DRUPAL_CACHE_GLOBAL 0x0008

The block or element is the same for every user and page that it is visible.

Definition at line 161 of file common.inc.

const DRUPAL_CACHE_PER_PAGE 0x0004

The block or element can change depending on the page being viewed.

Definition at line 156 of file common.inc.

Referenced by book_block_info(), drupal_render_cid_parts(), profile_block_info(), and render_example_arrays().

const DRUPAL_CACHE_PER_ROLE 0x0001

The block or element can change depending on the user's roles.

This is the default setting for blocks, used when the block does not specify anything.

Definition at line 143 of file common.inc.

Referenced by block_example_block_info(), block_update_7004(), book_block_info(), drupal_render_cid_parts(), profile_block_info(), and render_example_arrays().

const DRUPAL_CACHE_PER_USER 0x0002

The block or element can change depending on the user.

This setting can be resource-consuming for sites with large number of users, and thus should only be used when DRUPAL_CACHE_PER_ROLE is not sufficient.

Definition at line 151 of file common.inc.

Referenced by drupal_render_cid_parts().

const DRUPAL_NO_CACHE -1

The block should not get cached.

This setting should be used:

  • For simple blocks (notably those that do not perform any db query), where querying the db cache would be more expensive than directly generating the content.
  • For blocks that change too frequently.

Definition at line 127 of file common.inc.

Referenced by _block_get_cache_id(), block_add_block_form_submit(), block_block_info(), block_update_7004(), hook_block_info(), locale_block_info(), menu_block_info(), node_block_info(), shortcut_block_info(), statistics_block_info(), system_block_info(), and user_block_info().

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: HTTP handling

Functions
HTTP handling

Functions

drupal_get_query_parameters (array $query=NULL, array $exclude=array('q'), $parent= '')
drupal_get_query_array ($query)
drupal_get_destination ()
drupal_encode_path ($path)
drupal_goto ($path= '', array $options=array(), $http_response_code=302)
drupal_site_offline ()
drupal_not_found ()
drupal_access_denied ()
drupal_http_request ($url, array $options=array())
_drupal_http_use_proxy ($host)

Detailed Description

Functions to properly handle HTTP responses.

Function Documentation

_drupal_http_use_proxy ( $host )

Helper function for determining hosts excluded from needing a proxy.

Returns
TRUE if a proxy should be used for this host.

Definition at line 1098 of file common.inc.

References variable_get().

Referenced by drupal_http_request().

drupal_access_denied ( )

Delivers an "access denied" error to the browser.

Page callback functions wanting to report an "access denied" message should return MENU_ACCESS_DENIED instead of calling drupal_access_denied(). However, functions that are invoked in contexts where that return value might not bubble up to menu_execute_active_handler() should call drupal_access_denied().

Definition at line 744 of file common.inc.

References drupal_deliver_page(), and MENU_ACCESS_DENIED.

Referenced by book_export_html(), contact_personal_form(), contact_site_form(), file_download(), page_example_arguments(), system_batch_page(), and user_pass_reset().

drupal_encode_path ( $path )

Encodes a Drupal path for use in a URL.

For aesthetic reasons slashes are not escaped.

Note that url() takes care of calling this function, so a path passed to that function should not be encoded in advance.

Parameters
$path The Drupal path to encode.

Definition at line 639 of file common.inc.

Referenced by file_create_url(), DrupalPublicStreamWrapper\getExternalUrl(), and url().

drupal_get_destination ( )

Prepares a 'destination' URL query parameter for use with drupal_goto().

Used to direct the user back to the referring page after completing a form. By default the current URL is returned. If a destination exists in the previous request, that destination is returned. As such, a destination can persist across multiple pages.

Returns
An associative array containing the key:
  • destination: The path provided via the destination query string or, if not available, the current path.
See Also
current_path()
drupal_goto()

Definition at line 525 of file common.inc.

References drupal_get_query_parameters(), drupal_http_build_query(), and drupal_static().

Referenced by _locale_translate_seek(), _update_no_data(), comment_admin_overview(), contextual_pre_render_links(), field_ui_field_overview_form_submit(), forum_menu_local_tasks_alter(), hook_translated_menu_link_alter(), hook_user_login(), node_admin_nodes(), node_form_delete_submit(), openid_authentication(), overlay_disable_message(), path_admin_form_delete_submit(), path_admin_overview(), shortcut_preprocess_page(), statistics_top_visitors(), system_user_login(), taxonomy_overview_terms(), theme_book_admin_table(), theme_node_recent_block(), theme_system_compact_link(), theme_toolbar_toggle(), theme_update_last_check(), user_admin_account(), user_edit_cancel_submit(), user_login_block(), and user_login_destination().

drupal_get_query_array ( $query )

Splits a URL-encoded query string into an array.

Parameters
$query The query string to split.
Returns
An array of URL decoded couples $param_name => $value.

Definition at line 457 of file common.inc.

Referenced by locale_language_url_rewrite_session(), menu_edit_item_validate(), and system_update_7076().

drupal_get_query_parameters | ( | array | $query = NULL,
 |  | array | $exclude = array('q'),
 |  |  | $parent = ''
 | ) |  |

Processes a URL query parameter array to remove unwanted elements.

Parameters
$query | (optional) An array to be processed. Defaults to $_GET.
$exclude | (optional) A list of $query array keys to remove. Use "parent[child]" to exclude nested items. Defaults to array('q').
$parent | Internal use only. Used to build the $query array key for nested items.
Returns
An array containing query parameters, which can be used for url().

Definition at line 417 of file common.inc.

References $value.

Referenced by drupal_current_script_url(), drupal_get_destination(), drupal_redirect_form(), drupal_validate_form(), overlay_drupal_goto_alter(), overlay_init(), pager_get_query_parameters(), shortcut_preprocess_page(), tablesort_get_query_parameters(), and theme_pager_link().

drupal_goto | ( |  | $path = '',
 |  | array | $options = array(),
 |  |  | $http_response_code = 302
 | ) |  |

Sends the user to a different page.

This issues an on-site HTTP redirect. The function makes sure the redirected URL is formatted correctly.

Usually the redirected URL is constructed from this function's input parameters. However you may override that behavior by setting a destination in either the $_REQUEST-array (i.e. by using the query string of an URI) This is used to direct the user back to the proper page after completing a form. For example, after editing a post on the 'admin/content'-page or after having logged on using the 'user login'-block in a sidebar. The function drupal_get_destination() can be used to help set the destination URL.

Drupal will ensure that messages set by drupal_set_message() and other session data are written to the database before the user is redirected.

This function ends the request; use it instead of a return in your menu callback.

Parameters
$path | (optional) A Drupal path or a full URL, which will be passed to url() to compute the redirect for the URL.
$options | (optional) An associative array of additional URL options to pass to url().
$http_response_code (optional) The HTTP status code to use for the redirection, defaults to
  1. The valid values for 3xx redirection status codes are defined in RFC 2616 and the draft for the new HTTP status codes:
  • 301: Moved Permanently (the recommended value for most redirects).
  • 302: Found (default in Drupal and PHP, sometimes used for spamming search engines).
  • 303: See Other.
  • 304: Not Modified.
  • 305: Use Proxy.
  • 307: Temporary Redirect.
See Also
drupal_get_destination()
url()

Definition at line 686 of file common.inc.

References $url, drupal_alter(), drupal_exit(), drupal_parse_url(), url(), and url_is_external().

Referenced by _batch_page(), aggregator_admin_refresh_feed(), comment_approve(), comment_multiple_delete_confirm(), comment_reply(), drupal_redirect_form(), image_effect_form(), locale_languages_delete_form(), locale_translate_edit_form(), node_add_page(), openid_authentication(), openid_authentication_page(), overlay_init(), overlay_user_dismiss_message(), search_view(), shortcut_link_add_inline(), simpletest_result_form(), system_actions_configure(), system_actions_remove_orphans(), system_admin_compact_page(), system_authorized_run(), system_goto_action(), system_modules_uninstall_validate(), system_run_cron(), system_run_cron_submit(), system_theme_default(), system_theme_disable(), system_theme_enable(), toolbar_toggle_page(), trigger_assign(), trigger_unassign(), trigger_unassign_submit(), update_manager_download_batch_finished(), user_admin_role(), user_cancel_confirm(), user_login(), user_logout(), user_menu_site_status_alter(), user_multiple_cancel_confirm(), user_pass_reset(), and user_register_form().

drupal_http_request | ( |  | $url,
 |  | array | $options = array()
 | ) |  |

Performs an HTTP request.

This is a flexible and powerful HTTP client implementation. Correctly handles GET, POST, PUT or any other HTTP requests. Handles redirects.

Parameters
$url A string containing a fully qualified URI.
array $options (optional) An array that can have one or more of the following elements:
  • headers: An array containing request headers to send as name/value pairs.
  • method: A string containing the request method. Defaults to 'GET'.
  • data: A string containing the request body, formatted as 'param=value&param=value&...'. Defaults to NULL.
  • max_redirects: An integer representing how many times a redirect may be followed. Defaults to 3.
  • timeout: A float representing the maximum number of seconds the function call may take. The default is 30 seconds. If a timeout occurs, the error code is set to the HTTP_REQUEST_TIMEOUT constant.
  • context: A context resource created with stream_context_create().
Returns
object An object that can have one or more of the following components:
  • request: A string containing the request body that was sent.
  • code: An integer containing the response status code, or the error code if an error occurred.
  • protocol: The response protocol (e.g. HTTP/1.1 or HTTP/1.0).
  • status_message: The status message from the response, if a response was received.
  • redirect_code: If redirected, an integer containing the initial response status code.
  • redirect_url: If redirected, a string containing the URL of the redirect target.
  • error: If an error occurred, the error message. Otherwise not set.
  • headers: An array containing the response headers as name/value pairs. HTTP header names are case-insensitive (RFC 2616, section 4.2), so for easy access the array keys are returned in lower case.
  • data: A string containing the response body that was received.

Definition at line 787 of file common.inc.

References $info, $name, $url, $value, _drupal_http_use_proxy(), drupal_generate_test_ua(), HTTP_REQUEST_TIMEOUT, t(), timer_read(), timer_start(), variable_get(), and variable_set().

Referenced by _openid_xrds_discovery(), _update_process_fetch_task(), _xmlrpc(), aggregator_aggregator_fetch(), aggregator_form_opml_submit(), openid_association(), openid_verify_assertion(), system_check_http_request(), and system_clean_url_settings().

drupal_not_found ( )

Delivers a "page not found" error to the browser.

Page callback functions wanting to report a "page not found" message should return MENU_NOT_FOUND instead of calling drupal_not_found(). However, functions that are invoked in contexts where that return value might not bubble up to menu_execute_active_handler() should call drupal_not_found().

Definition at line 731 of file common.inc.

References drupal_deliver_page(), and MENU_NOT_FOUND.

Referenced by book_export(), book_export_html(), contact_site_form(), file_download(), file_transfer(), locale_languages_delete_form(), locale_languages_edit_form(), profile_field_delete(), and profile_field_form().

drupal_site_offline ( )

Delivers a "site is under maintenance" message to the browser.

Page callback functions wanting to report a "site offline" message should return MENU_SITE_OFFLINE instead of calling drupal_site_offline(). However, functions that are invoked in contexts where that return value might not bubble up to menu_execute_active_handler() should call drupal_site_offline().

Definition at line 719 of file common.inc.

References drupal_deliver_page(), and MENU_SITE_OFFLINE.

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: Input validation

Functions
Input validation

Functions

valid_email_address ($mail)
valid_url ($url, $absolute=FALSE)

Detailed Description

Functions to validate user input.

Function Documentation

valid_email_address ( $mail )

Verifies the syntax of the given e-mail address.

This uses the PHP e-mail validation filter.

Parameters
$mail A string containing an e-mail address.
Returns
TRUE if the address is in a valid format.

Definition at line 1186 of file common.inc.

Referenced by _openid_invalid_openid_transition(), comment_form_validate(), contact_category_edit_form_validate(), contact_personal_form_validate(), contact_site_form_validate(), email_example_form_validate(), system_send_email_action_validate(), update_settings_validate(), and user_validate_mail().

valid_url | ( | $url,
 |  | $absolute = FALSE
 | ) |

Verifies the syntax of the given URL.

This function should only be used on actual URLs. It should not be used for Drupal menu paths, which can contain arbitrary characters. Valid values per RFC 3986.

Parameters
$url | The URL to verify.
$absolute | Whether the URL is absolute (beginning with a scheme such as "http:").
Returns
TRUE if the URL is in a valid format.

Definition at line 1204 of file common.inc.

References $url.

Referenced by aggregator_form_feed_validate(), aggregator_form_opml_submit(), aggregator_form_opml_validate(), comment_form_validate(), profile_user_form_validate(), and update_manager_install_form_validate().

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: Sanitization functions

Functions
Sanitization functions

Functions

drupal_strip_dangerous_protocols ($uri)
check_url ($uri)
filter_xss_admin ($string)
filter_xss ($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
_filter_xss_split ($m, $store=FALSE)
_filter_xss_attributes ($attr)
filter_xss_bad_protocol ($string, $decode=TRUE)
drupal_attributes (array $attributes=array())
st ($string, array $args=array(), array $options=array())
check_markup ($text, $format_id=NULL, $langcode= '', $cache=FALSE)

into your string, and t() will

Translates a string to the current language or to a given language.

The t() function serves two purposes. First, at run-time it translates user-visible text into the appropriate language. Second, various mechanisms that figure out what text needs to be translated work off t() – the text inside t() calls is added to the database of strings to be translated. These strings are expected to be in English, so the first argument should always be in English. To enable a fully-translatable site, it is important that all human-readable text that will be displayed on the site or sent to a user is passed through the t() function, or a related function. See the Localization API pages for more information, including recommendations on how to break up or not break up strings for translation.

Translating Variables

You should never use t() to translate variables, such as calling

t($text);

, unless the text that the variable holds has been passed through t() elsewhere (e.g., $text is one of several translated literal strings in an array). It is especially important never to call

t($user_text);

, where $user_text is some text that a user entered - doing that can lead to cross-site scripting and other security problems. However, you can use variable substitution in your string, to put variable text such as user names or link URLs into translated text. Variable substitution looks like this:

* $text = t("@name's blog", array('@name' => format_username($account)));
*

Basically, you can put variables like substitute their sanitized values at translation time. (See the Localization API pages referenced above and the documentation of format_string() for details about how to define variables in your string.) Translators can then rearrange the string as necessary for the language (e.g., in Spanish, it might be "blog de @name").

Use During Installation Phase

During the Drupal installation phase, some resources used by t() wil not be available to code that needs localization. See st() and get_t() for alternatives.

Parameters
$string | A string containing the English string to translate.
$args | An associative array of replacements to make after translation. Based on the first character of the key, the value is escaped and/or themed. See format_string() for details.
$options An associative array of additional options, with the following elements:
  • 'langcode' (defaults to the current language): The language code to translate to a language other than what is used to display the page.
  • 'context' (defaults to the empty context): The context the source string belongs to.
Returns
The translated string.
See Also
st()
get_t()
format_string()
format_string ($string, array $args=array())
check_plain ($text)
get_t ()

Detailed Description

Functions to sanitize values.

See http://drupal.org/writing-secure-code for information on writing secure code.

Function Documentation

_filter_xss_attributes ( $attr )

Processes a string of HTML attributes.

Returns
Cleaned up version of the HTML attributes.

Definition at line 1544 of file common.inc.

References filter_xss_bad_protocol().

Referenced by _filter_xss_split().

_filter_xss_split | ( | $m,
 |  | $store = FALSE
 | ) |

Processes an HTML tag.

Parameters
$m | An array with various meaning depending on the value of $store. If $store is TRUE then the array contains the allowed tags. If $store is FALSE then the array has one element, the HTML tag to process.
$store | Whether to store $m.
Returns
If the element isn't allowed, an empty string. Otherwise, the cleaned up version of the HTML element.

Definition at line 1480 of file common.inc.

References _filter_xss_attributes().

Referenced by filter_xss().

check_markup | ( | $text,
 |  | $format_id = NULL,
 |  | $langcode = '',
 |  | $cache = FALSE
 | ) |

Runs all the enabled filters on a piece of text.

Note: Because filters can inject JavaScript or execute PHP code, security is vital here. When a user supplies a text format, you should validate it using filter_access() before accepting/using it. This is normally done in the validation stage of the Form API. You should for example never make a preview of content in a disallowed format.

Parameters
$text | The text to be filtered.
$format_id | (optional) The format ID of the text to be filtered. If no format is assigned, the fallback format will be used. Defaults to NULL.
$langcode | (optional) The language code of the text to be filtered, e.g. 'en' for English. This allows filters to be language aware so language specific text replacement can be implemented. Defaults to an empty string.
$cache | (optional) A Boolean indicating whether to cache the filtered output in the {cache_filter} table. The caller may set this to FALSE when the output is already cached elsewhere to avoid duplicate cache lookups and storage. Defaults to FALSE.
Returns
The filtered text.

Definition at line 759 of file filter.module.

References $name, cache_get(), cache_set(), filter_fallback_format(), filter_format_load(), filter_get_filters(), filter_list_format(), watchdog(), and WATCHDOG_ALERT.

Referenced by _text_sanitize(), block_block_view(), comment_submit(), hook_node_update_index(), taxonomy_term_build_content(), taxonomy_term_feed(), taxonomy_tokens(), and user_comment_view().

check_plain ( $text )

Encodes special characters in a plain-text string for display as HTML.

Also validates strings as UTF-8 to prevent cross site scripting attacks on Internet Explorer 6.

Parameters
$text The text to be checked or processed.
Returns
An HTML safe version of $text, or an empty string if $text is not valid UTF-8.
See Also
drupal_validate_utf8()

Definition at line 1565 of file bootstrap.inc.

Referenced by _block_render_blocks(), _drupal_decode_exception(), _drupal_render_exception_safe(), _filter_html_escape(), _filter_html_tips(), _filter_url_parse_email_links(), _filter_url_parse_full_links(), _filter_url_parse_partial_links(), _locale_languages_configure_form_language_table(), _locale_translate_seek(), _node_index_node(), _text_sanitize(), aggregator_block_view(), aggregator_categorize_items(), aggregator_form_feed(), ajax_example_node_by_author_node_autocomplete_callback(), ajax_example_simple_user_autocomplete_callback(), ajax_example_unique_node_autocomplete_callback(), DrupalWebTestCase\assertThemeOutput(), batch_example_op_1(), batch_example_op_2(), block_admin_display_form(), block_form_user_profile_form_alter(), block_menu(), check_url(), color_scheme_form(), comment_multiple_delete_confirm(), comment_preview(), comment_submit(), comment_tokens(), contact_category_list(), dblog_event(), debug(), drupal_add_html_head_link(), drupal_attributes(), drupal_block_denied(), drupal_deliver_html_page(), drupal_fast_404(), drupal_get_title(), drupal_placeholder(), drupal_pre_render_styles(), drupal_set_title(), email_example_mail(), field_default_form(), field_multiple_value_form(), field_permission_example_field_formatter_view(), field_ui_display_overview_form(), field_ui_field_overview_form(), file_create_htaccess(), file_example_session_contents(), filter_admin_overview(), filter_xss_bad_protocol(), form_select_options(), format_rss_channel(), format_rss_item(), format_string(), format_xml_elements(), forum_form(), hook_form(), hook_node_update_index(), hook_search_execute(), hook_tokens(), hook_update_index(), image_style_form(), image_style_options(), l(), locale_date_format_form(), locale_language_url_rewrite_session(), locale_languages_edit_form_validate(), locale_languages_overview_form(), locale_translate_edit_form(), menu_block_info(), menu_block_view(), node_admin_nodes(), node_content_form(), node_multiple_delete_confirm(), node_search_execute(), node_tokens(), openid_form_user_register_form_alter(), openid_user_identities(), poll_form(), poll_teaser(), poll_view_voting(), poll_votes(), profile_admin_overview(), profile_admin_settings_autocomplete(), profile_autocomplete(), profile_block_configure(), profile_browse(), profile_form_alter(), profile_user_view(), shortcut_set_admin(), shortcut_set_switch(), shortcut_set_title(), simpletest_example_form(), st(), statistics_access_log(), FileExampleSessionStreamWrapper\stream_write(), system_actions_manage(), system_date_time_settings(), system_file_system_settings(), system_modules(), system_tokens(), system_update_7003(), system_update_7067(), tabledrag_example_simple_form(), taxonomy_admin_vocabulary_title_callback(), taxonomy_autocomplete(), taxonomy_field_formatter_view(), taxonomy_overview_vocabularies(), taxonomy_tokens(), template_preprocess_aggregator_item(), template_preprocess_aggregator_summary_item(), template_preprocess_aggregator_summary_items(), template_preprocess_book_export_html(), template_preprocess_book_navigation(), template_preprocess_book_node_export_html(), template_preprocess_field(), template_preprocess_forum_list(), template_preprocess_forum_topic_list(), template_preprocess_html(), template_preprocess_node(), template_preprocess_poll_bar(), template_preprocess_poll_results(), template_preprocess_poll_vote(), template_preprocess_profile_block(), template_preprocess_search_result(), template_preprocess_search_results(), template_preprocess_taxonomy_term(), template_preprocess_user_profile_category(), template_preprocess_username(), theme_aggregator_block_item(), theme_aggregator_page_opml(), theme_dashboard_disabled_block(), theme_file_icon(), theme_file_link(), theme_file_upload_help(), theme_filter_guidelines(), theme_image_resize_summary(), theme_image_style_preview(), theme_link(), theme_links(), theme_locale_languages_overview_form(), theme_menu_admin_overview(), theme_menu_local_action(), theme_menu_local_task(), theme_node_admin_overview(), theme_pager_link(), theme_profile_admin_overview(), theme_queue_items(), theme_textarea(), theme_trigger_display(), theme_update_report(), theme_user_admin_roles(), toolbar_menu_navigation_links(), tracker_page(), update_do_one(), update_manager_update_form(), user_admin_permissions(), user_autocomplete(), user_multiple_cancel_confirm(), user_tokens(), and xmlrpc_value_get_xml().

check_url ( $uri )

Strips dangerous protocols from a URI and encodes it for output to HTML.

Parameters
$uri A plain-text URI that might contain dangerous protocols.
Returns
A URI stripped of dangerous protocols and encoded for output to an HTML attribute value. Because it is already encoded, it should not be set as a value within a $attributes array passed to drupal_attributes(), because drupal_attributes() expects those values to be plain-text strings. To pass a filtered URI to drupal_attributes(), call drupal_strip_dangerous_protocols() instead.
See Also
drupal_strip_dangerous_protocols()

Definition at line 1387 of file common.inc.

References check_plain(), and drupal_strip_dangerous_protocols().

Referenced by comment_tokens(), format_rss_channel(), format_rss_item(), install_verify_requirements(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_item(), template_preprocess_aggregator_summary_item(), template_preprocess_search_result(), theme_aggregator_block_item(), theme_aggregator_page_opml(), theme_aggregator_page_rss(), update_check_requirements(), and update_info_page().

drupal_attributes ( array $attributes = array() )

Converts an associative array to an XML/HTML tag attribute string.

Each array key and its value will be formatted into an attribute string. If a value is itself an array, then its elements are concatenated to a single space-delimited string (for example, a class attribute with multiple values).

Attribute values are sanitized by running them through check_plain(). Attribute names are not automatically sanitized. When using user-supplied attribute names, it is strongly recommended to allow only white-listed names, since certain attributes carry security risks and can be abused.

Examples of security aspects when using drupal_attributes:

* // By running the value in the following statement through check_plain,
* // the malicious script is neutralized.
* drupal_attributes(array('title' => t('<script>steal_cookie();</script>')));
*
* // The statement below demonstrates dangerous use of drupal_attributes, and
* // will return an onmouseout attribute with JavaScript code that, when used
* // as attribute in a tag, will cause users to be redirected to another site.
* //
* // In this case, the 'onmouseout' attribute should not be whitelisted --
* // you don't want users to have the ability to add this attribute or others
* // that take JavaScript commands.
* drupal_attributes(array('onmouseout' => 'window.location="http://malicious.com/";')));
*
Parameters
$attributes An associative array of key-value pairs to be converted to attributes.
Returns
A string ready for insertion in a tag (starts with a space).

Definition at line 2377 of file common.inc.

References $attributes, and check_plain().

Referenced by _theme_table_cell(), format_xml_elements(), l(), node_feed(), template_preprocess_user_profile_category(), template_preprocess_user_profile_item(), template_process(), template_process_field(), theme_button(), theme_checkbox(), theme_checkboxes(), theme_container(), theme_date(), theme_fieldset(), theme_file(), theme_file_managed_file(), theme_filter_guidelines(), theme_form(), theme_form_element(), theme_form_element_label(), theme_form_example_inline_form_element(), theme_form_required_marker(), theme_hidden(), theme_html_tag(), theme_image(), theme_image_button(), theme_item_list(), theme_link(), theme_links(), theme_menu_link(), theme_pager_link(), theme_password(), theme_radio(), theme_radios(), theme_rdf_metadata(), theme_rdf_template_variable_wrapper(), theme_select(), theme_table(), theme_textarea(), theme_textfield(), and theme_username().

drupal_strip_dangerous_protocols ( $uri )

Strips dangerous protocols (e.g. 'javascript:') from a URI.

This function must be called for all URIs within user-entered input prior to being output to an HTML attribute value. It is often called as part of check_url() or filter_xss(), but those functions return an HTML-encoded string, so this function can be called independently when the output needs to be a plain-text string for passing to t(), l(), drupal_attributes(), or another function that will call check_plain() separately.

Parameters
$uri A plain-text URI that might contain dangerous protocols.
Returns
A plain-text URI stripped of dangerous protocols. As with all plain-text strings, this return value must not be output to an HTML page without check_plain() being called on it. However, it can be passed to functions expecting plain-text strings.
See Also
check_url()

Definition at line 1340 of file common.inc.

References variable_get().

Referenced by check_url(), filter_xss_bad_protocol(), template_preprocess_html(), template_preprocess_maintenance_page(), theme_form(), url(), and url_is_external().

filter_xss | ( | $string,
 |  | $allowed_tags = array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd')
 | ) |

Filters HTML to prevent cross-site-scripting (XSS) vulnerabilities.

Based on kses by Ulf Harnhammar, see http://sourceforge.net/projects/kses. For examples of various XSS attacks, see: http://ha.ckers.org/xss.html.

This code does four things:

  • Removes characters and constructs that can trick browsers.
  • Makes sure all HTML entities are well-formed.
  • Makes sure all HTML tags and attributes are well-formed.
  • Makes sure no HTML tags contain URLs with a disallowed protocol (e.g. javascript:).
Parameters
$string | The string with raw HTML in it. It will be stripped of everything that can cause an XSS attack.
$allowed_tags | An array of allowed tags.
Returns
An XSS safe version of $string, or an empty string if $string is not valid UTF-8.
See Also
drupal_validate_utf8()

Definition at line 1431 of file common.inc.

References _filter_xss_split(), and drupal_validate_utf8().

Referenced by _filter_html(), aggregator_filter_xss(), DrupalWebTestCase\assertTextHelper(), DrupalWebTestCase\assertUniqueTextHelper(), comment_tokens(), contextual_links_example_block_view(), dblog_overview(), drupal_html_to_text(), field_filter_xss(), filter_xss_admin(), hook_tokens(), locale_string_is_safe(), node_revision_overview(), poll_tokens(), taxonomy_tokens(), template_preprocess_contextual_links_example_object(), theme_dblog_message(), and token_example_tokens().

filter_xss_admin ( $string )

Applies a very permissive XSS/HTML filter for admin-only use.

Use only for fields where it is impractical to use the whole filter system, but where some (mainly inline) mark-up is desired (so check_plain() is not acceptable).

Allows all tags that can be used inside an HTML body, save for scripts and styles.

Definition at line 1401 of file common.inc.

References filter_xss().

Referenced by _drupal_error_handler_real(), _locale_languages_configure_form_language_table(), _profile_form_explanation(), ajax_prepare_response(), bartik_process_maintenance_page(), bartik_process_page(), drupal_deliver_html_page(), node_help(), seven_admin_block_content(), seven_node_add_list(), system_message_action(), template_preprocess_forum_list(), template_preprocess_html(), template_preprocess_page(), theme_admin_block_content(), theme_form_element_label(), theme_menu_admin_overview(), theme_node_add_list(), theme_node_admin_overview(), and user_account_form().

filter_xss_bad_protocol | ( | $string,
 |  | $decode = TRUE
 | ) |

Processes an HTML attribute value and strips dangerous protocols from URLs.

Parameters
$string | The string with the attribute value.
$decode | (deprecated) Whether to decode entities in the $string. Set to FALSE if the $string is in plain text, TRUE otherwise. Defaults to TRUE. This parameter is deprecated and will be removed in Drupal 8. To process a plain-text URI, call drupal_strip_dangerous_protocols() or check_url() instead.
Returns
Cleaned up and HTML-escaped version of $string.

Definition at line 1656 of file common.inc.

References check_plain(), decode_entities(), DRUPAL_ROOT, and drupal_strip_dangerous_protocols().

Referenced by _filter_xss_attributes().

format_string | ( |  | $string,
 |  | array | $args = array()
 | ) |  |

Formats a string for HTML display by replacing variable placeholders.

This function replaces variable placeholders in a string with the requested values and escapes the values so they can be safely displayed as HTML. It should be used on any unknown text that is intended to be printed to an HTML page (especially text that may have come from untrusted users, since in that case it prevents cross-site scripting and other security problems).

In most cases, you should use t() rather than calling this function directly, since it will translate the text (on non-English-only sites) in addition to formatting it.

Parameters
$string A string containing placeholders.
$args An associative array of replacements to make. Occurrences in $string of any key in $args are replaced with the corresponding value, after optional sanitization and formatting. The type of sanitization and formatting depends on the first character of the key:
  • : Escaped to HTML using check_plain(). Use this as the default choice for anything displayed on a page on the site.
  • variable: Escaped to HTML and formatted using drupal_placeholder(), which makes it display as emphasized text.
  • !variable: Inserted as is, with no sanitization or formatting. Only use this for text that has already been prepared for HTML display (for example, user-supplied text that has already been run through check_plain() previously, or is expected to contain some limited HTML tags and has already been run through filter_xss() previously).
See Also
t()

Definition at line 1527 of file bootstrap.inc.

References $value, check_plain(), and drupal_placeholder().

Referenced by DrupalWebTestCase\assertThemeOutput(), system_update_7013(), t(), and user_update_7002().

get_t ( )

Returns the name of the proper localization function.

get_t() exists to support localization for code that might run during the installation phase, when some elements of the system might not have loaded.

This would include implementations of hook_install(), which could run during the Drupal installation phase, and might also be run during non-installation time, such as while installing the module from the the module administration page.

Example usage:

* $t = get_t();
* $translated = $t('translate this');
*

Use t() if your code will never run during the Drupal installation phase. Use st() if your code will only run during installation and never any other time. Use get_t() if your code could run in either circumstance.

See Also
t()
st()

Definition at line 2635 of file bootstrap.inc.

References drupal_installation_attempted().

Referenced by _country_get_predefined_list(), _form_validate(), _locale_batch_build(), _locale_import_message(), _rdf_example_installed_fields(), _rdf_example_installed_instances(), _update_7000_field_delete_field(), batch_process(), batch_set(), form_pre_render_conditional_form_element(), hook_requirements(), menu_install(), rdf_example_install(), shortcut_install(), simpletest_requirements(), system_requirements(), tabledrag_example_install(), theme_form_element_label(), and theme_form_required_marker().

st | ( |  | $string,
 |  | array | $args = array(),
 |  | array | $options = array()
 | ) |  |

Translates a string when some systems are not available.

Used during the install process, when database, theme, and localization system is possibly not yet available.

Use t() if your code will never run during the Drupal installation phase. Use st() if your code will only run during installation and never any other time. Use get_t() if your code could run in either circumstance.

See Also
t()
get_t()

Definition at line 1111 of file install.inc.

References $value, _locale_import_one_string(), _locale_import_read_po(), check_plain(), DRUPAL_ROOT, and file_scan_directory().

Referenced by _install_configure_form(), _install_module_batch(), ajax_example_update_7100(), DatabaseTasks_pgsql\checkBinaryOutput(), DatabaseTasks_pgsql\checkEncoding(), DatabaseTasks\checkEngineVersion(), DatabaseTasks_pgsql\checkPHPVersion(), DatabaseTasks\connect(), drupal_rewrite_settings(), drupal_verify_profile(), DatabaseTasks_sqlite\getFormOptions(), DatabaseTasks\getFormOptions(), hook_install_tasks(), DatabaseTasks_pgsql\initializeDatabase(), install_already_done_error(), install_check_requirements(), install_configure_form(), install_database_errors(), install_finished(), install_load_profile(), install_no_profile_error(), install_profile_modules(), install_select_locale(), install_select_locale_form(), install_select_profile(), install_select_profile_form(), install_settings_form(), install_tasks(), install_verify_requirements(), DatabaseTasks_sqlite\name(), DatabaseTasks_mysql\name(), DatabaseTasks_pgsql\name(), DatabaseTasks\runTasks(), DatabaseTasks\runTestQuery(), standard_install(), DatabaseTasks_sqlite\validateDatabaseSettings(), and DatabaseTasks\validateDatabaseSettings().

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: Formatting

Functions
Formatting

Functions

format_rss_channel ($title, $link, $description, $items, $langcode=NULL, $args=array())
format_rss_item ($title, $link, $description, $args=array())
format_xml_elements ($array)
format_plural ($count, $singular, $plural, array $args=array(), array $options=array())
parse_size ($size)
format_size ($size, $langcode=NULL)
format_interval ($interval, $granularity=2, $langcode=NULL)
format_date ($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
date_iso8601 ($date)
_format_date_callback (array $matches=NULL, $new_langcode=NULL)
format_username ($account)

Detailed Description

End of "defgroup sanitization".

Functions to format numbers, strings, dates, etc.

Function Documentation

_format_date_callback | ( | array | $matches = NULL,
 |  |  | $new_langcode = NULL
 | ) |  |

Translates a formatted date string.

Callback for preg_replace_callback() within format_date().

Definition at line 2055 of file common.inc.

References t().

Referenced by format_date().

date_iso8601 ( $date )

Returns an ISO8601 formatted date based on the given date.

Callback for use within hook_rdf_mapping() implementations.

Parameters
$date A UNIX timestamp.
Returns
string An ISO8601 formatted date.

Definition at line 2044 of file common.inc.

Referenced by cron_example_cron(), cron_example_form(), and cron_example_queue_report_work().

format_date | ( | $timestamp,
 |  | $type = 'medium',
 |  | $format = '',
 |  | $timezone = NULL,
 |  | $langcode = NULL
 | ) |

Formats a date, using a date type or a custom date format string.

Parameters
$timestamp | A UNIX timestamp to format.
$type (optional) The format to use, one of:
  • 'short', 'medium', or 'long' (the corresponding built-in date formats).
  • The name of a date type defined by a module in hook_date_format_types(), if it's been assigned a format.
  • The machine name of an administrator-defined date format.
  • 'custom', to use $format. Defaults to 'medium'.
$format | (optional) If $type is 'custom', a PHP date format string suitable for input to date(). Use a backslash to escape ordinary text, so it does not get interpreted as date format characters.
$timezone | (optional) Time zone identifier, as described at http://php.net/manual/timezones.php Defaults to the time zone used to display the page.
$langcode | (optional) Language code to translate to. Defaults to the language used to display the page.
Returns
A translated date string in the requested format.

Definition at line 1962 of file common.inc.

References _format_date_callback(), drupal_static(), and variable_get().

Referenced by _filter_example_filter_time_process(), cache_example_form_create_expiring_item(), comment_admin_overview(), comment_form(), comment_tokens(), dblog_event(), dblog_overview(), DrupalWebTestCase\drupalCreateNode(), entity_example_basic_view(), form_process_date(), hook_tokens(), hook_watchdog(), locale_date_format_form(), node_admin_nodes(), node_form(), node_object_prepare(), node_revision_delete_confirm(), node_revision_delete_confirm_submit(), node_revision_overview(), node_revision_revert_confirm(), node_revision_revert_confirm_submit(), node_show(), node_tokens(), poll_votes(), statistics_access_log(), statistics_node_tracker(), statistics_recent_hits(), statistics_tokens(), statistics_user_tracker(), system_add_date_format_type_form(), system_configure_date_formats_form(), system_date_delete_format_form(), system_date_delete_format_form_submit(), system_date_time_formats(), system_date_time_lookup(), system_date_time_settings(), system_time_zones(), system_token_info(), system_tokens(), template_preprocess_aggregator_item(), template_preprocess_comment(), template_preprocess_node(), template_preprocess_search_result(), theme_update_report(), theme_update_version(), user_pass_reset(), and user_tokens().

format_interval | ( | $interval,
 |  | $granularity = 2,
 |  | $langcode = NULL
 | ) |

Formats a time interval with the requested granularity.

Parameters
$interval | The length of the interval in seconds.
$granularity | How many different units to display in the string.
$langcode | Optional language code to translate to a language other than what is used to display the page.
Returns
A translated string representation of the interval.

Definition at line 1908 of file common.inc.

References $output, $value, format_plural(), and t().

Referenced by _batch_finished(), _batch_process(), aggregator_view(), contact_personal_form(), contact_site_form(), hook_requirements(), poll_tokens(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), system_cron_settings(), system_requirements(), system_token_info(), system_tokens(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_item(), template_preprocess_aggregator_summary_item(), template_preprocess_forum_submitted(), theme_comment_block(), theme_update_last_check(), tracker_page(), user_admin_account(), and user_user_view().

format_plural | ( |  | $count,
 |  |  | $singular,
 |  |  | $plural,
 |  | array | $args = array(),
 |  | array | $options = array()
 | ) |  |

Formats a string containing a count of items.

This function ensures that the string is pluralized correctly. Since t() is called by this function, make sure not to pass already-localized strings to it.

For example:

* $output = format_plural($node->comment_count, '1 comment', '@count comments');
*

Example with additional replacements:

* $output = format_plural($update_count,
* 'Changed the content type of 1 post from %old-type to %new-type.',
* 'Changed the content type of @count posts from %old-type to %new-type.',
* array('%old-type' => $info->old_type, '%new-type' => $info->new_type));
*
Parameters
$count | The item count to display.
$singular | The string for the singular case. Make sure it is clear this is singular, to ease translation (e.g. use "1 new comment" instead of "1 new"). Do not use in the singular string.
$plural | The string for the plural case. Make sure it is clear this is plural, to ease translation. Use in place of the item count, as in "@count new comments".
$args | An associative array of replacements to make after translation. Instances of any key in this array are replaced with the corresponding value. Based on the first character of the key, the value is escaped and/or themed. See format_string(). Note that you do not need to include in this array; this replacement is done automatically for the plural case.
$options | An associative array of additional options. See t() for allowed keys.
Returns
A translated string.
See Also
t()
format_string()

Definition at line 1805 of file common.inc.

References locale_get_plural(), and t().

Referenced by _aggregator_characters(), _aggregator_items(), _locale_batch_language_finished(), _locale_batch_system_finished(), _locale_import_po(), _node_characters(), _node_mass_update_batch_finished(), _simpletest_format_summary_line(), _update_manager_check_backends(), aggregator_view(), comment_multiple_delete_confirm_submit(), comment_node_search_result(), comment_node_view(), SearchQuery\executeFirstPass(), format_interval(), format_size(), hook_node_search_result(), menu_delete_menu_confirm(), node_multiple_delete_confirm(), node_multiple_delete_confirm_submit(), node_node_type_insert(), node_node_type_update(), node_requirements(), node_title_list(), node_type_delete_confirm(), number_field_formatter_view(), poll_page(), search_admin_settings(), shortcut_set_delete_form(), simpletest_clean_database(), simpletest_clean_environment(), simpletest_clean_temporary_directories(), statistics_node_view(), system_modules_confirm_form(), system_themes_page(), DrupalWebTestCase\tearDown(), template_preprocess_forum_list(), template_preprocess_forum_topic_list(), theme_system_modules_uninstall(), tracker_page(), update_fetch_data_finished(), update_script_selection_form(), update_verify_update_archive(), user_block_view(), and user_login_final_validate().

format_rss_channel | ( | $title,
 |  | $link,
 |  | $description,
 |  | $items,
 |  | $langcode = NULL,
 |  | $args = array()
 | ) |

Formats an RSS channel.

Arbitrary elements may be added using the $args associative array.

Definition at line 1685 of file common.inc.

References $output, $title, check_plain(), check_url(), decode_entities(), and format_xml_elements().

Referenced by node_feed(), and theme_aggregator_page_rss().

format_rss_item | ( | $title,
 |  | $link,
 |  | $description,
 |  | $args = array()
 | ) |

Formats a single RSS item.

Arbitrary elements may be added using the $args associative array.

Definition at line 1710 of file common.inc.

References $output, $title, check_plain(), check_url(), and format_xml_elements().

Referenced by node_feed(), and theme_aggregator_page_rss().

format_size | ( | $size,
 |  | $langcode = NULL
 | ) |

Generates a string representation for the given byte count.

Parameters
$size | A size in bytes.
$langcode | Optional language code to translate to a language other than what is used to display the page.
Returns
A translated string representation of the size.

Definition at line 1866 of file common.inc.

References DRUPAL_KILOBYTE, format_plural(), and t().

Referenced by color_scheme_form_submit(), DrupalWebTestCase\curlExec(), file_ajax_progress(), file_ajax_upload(), file_field_instance_settings_form(), file_save_upload(), file_validate_size(), system_tokens(), theme_file_formatter_table(), theme_file_upload_help(), theme_file_widget(), and theme_image_widget().

format_username ( $account )

Format a username.

This is also the label callback implementation of callback_entity_info_label() for user_entity_info().

By default, the passed-in object's 'name' property is used if it exists, or else, the site-defined value for the 'anonymous' variable. However, a module may override this by implementing hook_username_alter(&$name, $account).

See Also
hook_username_alter()
Parameters
$account The account object for the user whose name is to be formatted.
Returns
An unsanitized string with the username to display. The code receiving this result must ensure that check_plain() is called on it before it is printed to the page.

Definition at line 2106 of file common.inc.

References $name, drupal_alter(), t(), and variable_get().

Referenced by blog_feed_user(), blog_node_view(), blog_page_user(), blog_user_view(), blog_view(), contact_mail(), contact_personal_form(), contact_site_form(), hook_mail(), hook_user_view(), menu_example_user_page_title(), node_tokens(), openid_user_identities(), profile_block_view(), statistics_user_tracker(), system_tokens(), template_preprocess_user_picture(), template_preprocess_username(), toolbar_view(), tracker_page(), user_page_title(), user_search_execute(), and user_tokens().

format_xml_elements ( $array )

Formats XML elements.

Parameters
$array An array where each item represents an element and is either a:
  • (key => value) pair (<key>value</key>)
  • Associative array with fields:
    • 'key': element name
    • 'value': element contents
    • 'attributes': associative array of element attributes

In both cases, 'value' can be a simple string, or it can be another array with the same format as $array itself for nesting.

Definition at line 1735 of file common.inc.

References $output, $value, check_plain(), and drupal_attributes().

Referenced by format_rss_channel(), and format_rss_item().

parse_size ( $size )

Parses a given byte count.

Parameters
$size A size expressed as a number of bytes with optional SI or IEC binary unit prefix (e.g. 2, 3K, 5MB, 10G, 6GiB, 8 bytes, 9mbytes).
Returns
An integer representation of the size in bytes.

Definition at line 1842 of file common.inc.

References DRUPAL_KILOBYTE.

Referenced by _file_generic_settings_max_filesize(), color_scheme_form_submit(), drupal_check_memory_limit(), file_field_widget_upload_validators(), and file_upload_max_size().

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: Database abstraction layer

Files | Classes | Functions | Variables
Database abstraction layer

Files

file | query.inc
file | query.inc
file | query.inc

Classes

class | DatabaseConnection
class | Database
class | DatabaseTransactionNoActiveException
class | DatabaseTransactionNameNonUniqueException
class | DatabaseTransactionCommitFailedException
class | DatabaseTransactionExplicitCommitNotAllowedException
class | DatabaseTransactionOutOfOrderException
class | InvalidMergeQueryException
class | FieldsOverlapException
class | NoFieldsException
class | DatabaseConnectionNotDefinedException
class | DatabaseDriverNotSpecifiedException
class | DatabaseTransaction
interface | DatabaseStatementInterface
class | DatabaseStatementBase
class | DatabaseStatementEmpty
class | DatabaseConnection_mysql
class | InsertQuery_mysql
class | TruncateQuery_mysql
class | DatabaseConnection_pgsql
class | SelectQuery_pgsql
class | DatabaseStatementPrefetch
interface | QueryConditionInterface
interface | QueryAlterableInterface
interface | QueryPlaceholderInterface
class | Query
class | InsertQuery
class | DeleteQuery
class | TruncateQuery
class | UpdateQuery
class | MergeQuery
class | DatabaseCondition
interface | QueryExtendableInterface
interface | SelectQueryInterface
class | SelectQueryExtender
class | SelectQuery
class | DatabaseConnection_sqlite
class | DatabaseStatement_sqlite
class | InsertQuery_sqlite
class | UpdateQuery_sqlite
class | DeleteQuery_sqlite
class | TruncateQuery_sqlite
class | SelectQuery_sqlite

Functions

db_query ($query, array $args=array(), array $options=array())
db_query_range ($query, $from, $count, array $args=array(), array $options=array())
db_query_temporary ($query, array $args=array(), array $options=array())
db_insert ($table, array $options=array())
db_merge ($table, array $options=array())
db_update ($table, array $options=array())
db_delete ($table, array $options=array())
db_truncate ($table, array $options=array())
db_select ($table, $alias=NULL, array $options=array())
db_transaction ($name=NULL, array $options=array())
db_set_active ($key= 'default')
db_escape_table ($table)
db_escape_field ($field)
db_like ($string)
db_driver ()
db_close (array $options=array())
db_next_id ($existing_id=0)
db_or ()
db_and ()
db_xor ()
db_condition ($conjunction)

Variables

const POSTGRESQL_NEXTID_LOCK 1000

Detailed Description

Allow the use of different database servers using the same code base.

Drupal provides a database abstraction layer to provide developers with the ability to support multiple database servers easily. The intent of this layer is to preserve the syntax and power of SQL as much as possible, but also allow developers a way to leverage more complex functionality in a unified way. It also provides a structured interface for dynamically constructing queries when appropriate, and enforcing security checks and similar good practices.

The system is built atop PHP's PDO (PHP Data Objects) database API and inherits much of its syntax and semantics.

Most Drupal database SELECT queries are performed by a call to db_query() or db_query_range(). Module authors should also consider using the PagerDefault Extender for queries that return results that need to be presented on multiple pages, and the Tablesort Extender for generating appropriate queries for sortable tables.

For example, one might wish to return a list of the most recent 10 nodes authored by a given user. Instead of directly issuing the SQL query

* SELECT n.nid, n.title, n.created FROM node n WHERE n.uid = $uid LIMIT 0, 10;
*

one would instead call the Drupal functions:

* $result = db_query_range('SELECT n.nid, n.title, n.created
* FROM {node} n WHERE n.uid = :uid', 0, 10, array(':uid' => $uid));
* foreach ($result as $record) {
* // Perform operations on $record->title, etc. here.
* }
*

Curly braces are used around "node" to provide table prefixing via DatabaseConnection::prefixTables(). The explicit use of a user ID is pulled out into an argument passed to db_query() so that SQL injection attacks from user input can be caught and nullified. The LIMIT syntax varies between database servers, so that is abstracted into db_query_range() arguments. Finally, note the PDO-based ability to iterate over the result set using foreach ().

All queries are passed as a prepared statement string. A prepared statement is a "template" of a query that omits literal or variable values in favor of placeholders. The values to place into those placeholders are passed separately, and the database driver handles inserting the values into the query in a secure fashion. That means you should never quote or string-escape a value to be inserted into the query.

There are two formats for placeholders: named and unnamed. Named placeholders are strongly preferred in all cases as they are more flexible and self-documenting. Named placeholders should start with a colon ":" and can be followed by one or more letters, numbers or underscores.

Named placeholders begin with a colon followed by a unique string. Example:

* SELECT nid, title FROM {node} WHERE uid=:uid;
*

":uid" is a placeholder that will be replaced with a literal value when the query is executed. A given placeholder label cannot be repeated in a given query, even if the value should be the same. When using named placeholders, the array of arguments to the query must be an associative array where keys are a placeholder label (e.g., :uid) and the value is the corresponding value to use. The array may be in any order.

Unnamed placeholders are simply a question mark. Example:

* SELECT nid, title FROM {node} WHERE uid=?;
*

In this case, the array of arguments must be an indexed array of values to use in the exact same order as the placeholders in the query.

Note that placeholders should be a "complete" value. For example, when running a LIKE query the SQL wildcard character, %, should be part of the value, not the query itself. Thus, the following is incorrect:

* SELECT nid, title FROM {node} WHERE title LIKE :title%;
*

It should instead read:

* SELECT nid, title FROM {node} WHERE title LIKE :title;
*

and the value for :title should include a % as appropriate. Again, note the lack of quotation marks around :title. Because the value is not inserted into the query as one big string but as an explicitly separate value, the database server knows where the query ends and a value begins. That is considerably more secure against SQL injection than trying to remember which values need quotation marks and string escaping and which don't.

INSERT, UPDATE, and DELETE queries need special care in order to behave consistently across all different databases. Therefore, they use a special object-oriented API for defining a query structurally. For example, rather than:

* INSERT INTO node (nid, title, body) VALUES (1, 'my title', 'my body');
*

one would instead write:

* $fields = array('nid' => 1, 'title' => 'my title', 'body' => 'my body');
* db_insert('node')->fields($fields)->execute();
*

This method allows databases that need special data type handling to do so, while also allowing optimizations such as multi-insert queries. UPDATE and DELETE queries have a similar pattern.

Drupal also supports transactions, including a transparent fallback for databases that do not support transactions. To start a new transaction, simply call $txn = db_transaction(); in your own code. The transaction will remain open for as long as the variable $txn remains in scope. When $txn is destroyed, the transaction will be committed. If your transaction is nested inside of another then Drupal will track each transaction and only commit the outer-most transaction when the last transaction object goes out out of scope, that is, all relevant queries completed successfully.

Example:

* function my_transaction_function() {
* // The transaction opens here.
* $txn = db_transaction();
*
* try {
* $id = db_insert('example')
* ->fields(array(
* 'field1' => 'mystring',
* 'field2' => 5,
* ))
* ->execute();
*
* my_other_function($id);
*
* return $id;
* }
* catch (Exception $e) {
* // Something went wrong somewhere, so roll back now.
* $txn->rollback();
* // Log the exception to watchdog.
* watchdog_exception('type', $e);
* }
*
* // $txn goes out of scope here. Unless the transaction was rolled back, it
* // gets automatically committed here.
* }
*
* function my_other_function($id) {
* // The transaction is still open here.
*
* if ($id % 2 == 0) {
* db_update('example')
* ->condition('id', $id)
* ->fields(array('field2' => 10))
* ->execute();
* }
* }
*
See Also
http://drupal.org/developing/api/database

Class Documentation

class DatabaseConnection

Base Database API class.

This class provides a Drupal-specific extension of the PDO database abstraction class in PHP. Every database driver implementation must provide a concrete implementation of it to support special handling required by that database.

See Also
http://php.net/manual/book.pdo.php

Definition at line 184 of file database.inc.

Inheritance diagram for DatabaseConnection:
DatabaseConnection_mysql DatabaseConnection_pgsql DatabaseConnection_sqlite

Public Member Functions

__construct ($dsn, $username, $password, $driver_options=array())
destroy ()
getConnectionOptions ()
prefixTables ($sql)
tablePrefix ($table= 'default')
prepareQuery ($query)
setTarget ($target=NULL)
getTarget ()
setKey ($key)
getKey ()
setLogger (DatabaseLog $logger)
getLogger ()
makeSequenceName ($table, $field)
makeComment ($comments)
query ($query, array $args=array(), $options=array())
getDriverClass ($class, array $files=array(), $use_autoload=FALSE)
select ($table, $alias=NULL, array $options=array())
insert ($table, array $options=array())
merge ($table, array $options=array())
update ($table, array $options=array())
delete ($table, array $options=array())
truncate ($table, array $options=array())
schema ()
escapeTable ($table)
escapeField ($field)
escapeAlias ($field)
escapeLike ($string)
inTransaction ()
transactionDepth ()
startTransaction ($name= '')
rollback ($savepoint_name= 'drupal_transaction')
pushTransaction ($name)
popTransaction ($name)
queryRange ($query, $from, $count, array $args=array(), array $options=array())
queryTemporary ($query, array $args=array(), array $options=array())
driver ()
version ()
supportsTransactions ()
supportsTransactionalDDL ()
databaseType ()
mapConditionOperator ($operator)
commit ()
nextId ($existing_id=0)

Protected Member Functions

defaultOptions ()
setPrefix ($prefix)
filterComment ($comment= '')
expandArguments (&$query, &$args)
popCommittableTransactions ()
generateTemporaryTableName ()

Protected Attributes

$target = NULL
$key = NULL
$logger = NULL
$transactionLayers = array()
$driverClasses = array()
$statementClass = 'DatabaseStatementBase'
$transactionSupport = TRUE
$transactionalDDLSupport = FALSE
$temporaryNameIndex = 0
$connectionOptions = array()
$schema = NULL
$prefixes = array()
$prefixSearch = array()
$prefixReplace = array()

Constructor & Destructor Documentation

__construct | ( | $dsn,
 |  | $username,
 |  | $password,
 |  | $driver_options = array()
 | ) |

Definition at line 296 of file database.inc.

References setPrefix().

Member Function Documentation

commit ( )

Throws an exception to deny direct access to transaction commits.

We do not want to allow users to commit transactions at any time, only by destroying the transaction object or allowing it to go out of scope. A direct commit bypasses all of the safety checks we've built on top of PDO's transaction routines.

Exceptions
DatabaseTransactionExplicitCommitNotAllowedException
See Also
DatabaseTransaction

Definition at line 1291 of file database.inc.

databaseType ( )
abstract

Returns the name of the PDO driver for this connection.

defaultOptions ( )
protected

Returns the default query options for any given query.

A given query can be customized with a number of option flags in an associative array:

  • target: The database "target" against which to execute a query. Valid values are "default" or "slave". The system will first try to open a connection to a database specified with the user-supplied key. If one is not available, it will silently fall back to the "default" target. If multiple databases connections are specified with the same target, one will be selected at random for the duration of the request.
  • fetch: This element controls how rows from a result set will be returned. Legal values include PDO::FETCH_ASSOC, PDO::FETCH_BOTH, PDO::FETCH_OBJ, PDO::FETCH_NUM, or a string representing the name of a class. If a string is specified, each record will be fetched into a new object of that class. The behavior of all other values is defined by PDO. See http://php.net/manual/pdostatement.fetch.php
  • return: Depending on the type of query, different return values may be meaningful. This directive instructs the system which type of return value is desired. The system will generally set the correct value automatically, so it is extremely rare that a module developer will ever need to specify this value. Setting it incorrectly will likely lead to unpredictable results or fatal errors. Legal values include:
    • Database::RETURN_STATEMENT: Return the prepared statement object for the query. This is usually only meaningful for SELECT queries, where the statement object is how one accesses the result set returned by the query.
    • Database::RETURN_AFFECTED: Return the number of rows affected by an UPDATE or DELETE query. Be aware that means the number of rows actually changed, not the number of rows matched by the WHERE clause.
    • Database::RETURN_INSERT_ID: Return the sequence ID (primary key) created by an INSERT statement on a table that contains a serial column.
    • Database::RETURN_NULL: Do not return anything, as there is no meaningful value to return. That is the case for INSERT queries on tables that do not contain a serial column.
  • throw_exception: By default, the database system will catch any errors on a query as an Exception, log it, and then rethrow it so that code further up the call chain can take an appropriate action. To suppress that behavior and simply return NULL on failure, set this option to FALSE.
Returns
An array of default query options.

Definition at line 373 of file database.inc.

References Database\RETURN_STATEMENT.

Referenced by DatabaseConnection_pgsql\query(), and query().

delete | ( |  | $table,
 |  | array | $options = array()
 | ) |  |

Prepares and returns a DELETE query object.

Parameters
$options An array of options on the query.
Returns
DeleteQuery A new DeleteQuery object.
See Also
DeleteQuery

Definition at line 873 of file database.inc.

References getDriverClass().

destroy ( )

Destroys this Connection object.

PHP does not destruct an object if it is still referenced in other variables. In case of PDO database connection objects, PHP only closes the connection when the PDO object is destructed, so any references to this object may cause the number of maximum allowed connections to be exceeded.

Definition at line 320 of file database.inc.

References schema().

driver ( )
abstract

Returns the type of database driver.

This is not necessarily the same as the type of the database itself. For instance, there could be two MySQL drivers, mysql and mysql_mock. This function would return different values for each, but both would return "mysql" for databaseType().

Referenced by getDriverClass().

escapeAlias ( $field )

Escapes an alias name string.

Force all alias names to be strictly alphanumeric-plus-underscore. In contrast to DatabaseConnection::escapeField() / DatabaseConnection::escapeTable(), this doesn't allow the period (".") because that is not allowed in aliases.

Returns
The sanitized field name string.

Definition at line 951 of file database.inc.

escapeField ( $field )

Escapes a field name string.

Force all field names to be strictly alphanumeric-plus-underscore. For some database drivers, it may also wrap the field name in database-specific escape characters.

Returns
The sanitized field name string.

Definition at line 936 of file database.inc.

Referenced by DatabaseCondition\compile().

escapeLike ( $string )

Escapes characters that work as wildcard characters in a LIKE pattern.

The wildcard characters "%" and "_" as well as backslash are prefixed with a backslash. Use this to do a search for a verbatim string without any wildcard behavior.

For example, the following does a case-insensitive query for all rows whose name starts with $prefix:

* $result = db_query(
* 'SELECT * FROM person WHERE name LIKE :pattern',
* array(':pattern' => db_like($prefix) . '%')
* );
*

Backslash is defined as escape character for LIKE patterns in DatabaseCondition::mapConditionOperator().

Parameters
$string The string to escape.
Returns
The escaped string.

Definition at line 980 of file database.inc.

escapeTable ( $table )

Escapes a table name string.

Force all table names to be strictly alphanumeric-plus-underscore. For some database drivers, it may also wrap the table name in database-specific escape characters.

Returns
The sanitized table name string.

Definition at line 922 of file database.inc.

expandArguments | ( | & | $query,
 |  | & | $args
 | ) |  |
protected

Expands out shorthand placeholders.

Drupal supports an alternate syntax for doing arrays of values. We therefore need to expand them out into a full, executable query string.

Parameters
$query | The query string to modify.
$args | The arguments for the query.
Returns
TRUE if the query was modified, FALSE otherwise.

Definition at line 729 of file database.inc.

References $key, and $value.

Referenced by DatabaseConnection_pgsql\query(), and query().

filterComment ( $comment = '' )
protected

Sanitize a query comment string.

Ensure a query comment does not include strings such as "* /" that might terminate the comment early. This avoids SQL injection attacks via the query comment. The comment strings in this example are separated by a space to avoid PHP parse errors.

For example, the comment:

* db_update('example')
* ->condition('id', $id)
* ->fields(array('field2' => 10))
* ->comment('Exploit * / DROP TABLE node; --')
* ->execute()
*

Would result in the following SQL statement being generated:

* "/ * Exploit * / DROP TABLE node; -- * / UPDATE example SET field2=..."
*

Unless the comment is sanitised first, the SQL server would drop the node table and ignore the rest of the SQL statement.

Parameters
$comment A query comment string.
Returns
A sanitized version of the query comment string.

Definition at line 625 of file database.inc.

Referenced by makeComment().

generateTemporaryTableName ( )
protected

Generates a temporary table name.

Returns
A table name.

Definition at line 1186 of file database.inc.

Referenced by DatabaseConnection_mysql\queryTemporary(), DatabaseConnection_pgsql\queryTemporary(), and DatabaseConnection_sqlite\queryTemporary().

getConnectionOptions ( )

Returns the connection information for this connection object.

Note that Database::getConnectionInfo() is for requesting information about an arbitrary database connection that is defined. This method is for requesting the connection information of this specific open connection object.

Returns
An array of the connection information. The exact list of properties is driver-dependent.

Definition at line 394 of file database.inc.

References $connectionOptions.

getDriverClass | ( |  | $class,
 |  | array | $files = array(),
 |  |  | $use_autoload = FALSE
 | ) |  |

Gets the driver-specific override class if any for the specified class.

Parameters
string | $class | The class for which we want the potentially driver-specific class.
array | $files | The name of the files in which the driver-specific class can be.
$use_autoload | If TRUE, attempt to load classes using PHP's autoload capability as well as the manual approach here.
Returns
string The name of the class that should be used for this driver.

Definition at line 777 of file database.inc.

References driver(), and Database\loadDriverFile().

Referenced by delete(), insert(), merge(), schema(), select(), startTransaction(), truncate(), and update().

getKey ( )

Returns the key this connection is associated with.

Returns
The key of this connection.

Definition at line 529 of file database.inc.

References $key.

getLogger ( )

Gets the current logging object for this connection.

Returns
DatabaseLog The current logging object for this connection. If there isn't one, NULL is returned.

Definition at line 550 of file database.inc.

References $logger.

getTarget ( )

Returns the target this connection is associated with.

Returns
The target string of this connection.

Definition at line 507 of file database.inc.

References $target.

insert | ( |  | $table,
 |  | array | $options = array()
 | ) |  |

Prepares and returns an INSERT query object.

Parameters
$options An array of options on the query.
Returns
InsertQuery A new InsertQuery object.
See Also
InsertQuery

Definition at line 824 of file database.inc.

References getDriverClass().

inTransaction ( )

Determines if there is an active transaction open.

Returns
TRUE if we're currently in a transaction, FALSE otherwise.

Definition at line 990 of file database.inc.

References transactionDepth().

Referenced by DatabaseConnection_sqlite\popTransaction(), DatabaseConnection_sqlite\pushTransaction(), pushTransaction(), DatabaseConnection_sqlite\rollback(), and rollback().

makeComment ( $comments )

Flatten an array of query comments into a single comment string.

The comment string will be sanitized to avoid SQL injection attacks.

Parameters
$comments An array of query comment strings.
Returns
A sanitized comment string.

Definition at line 583 of file database.inc.

References filterComment().

makeSequenceName | ( | $table,
 |  | $field
 | ) |

Creates the appropriate sequence name for a given table and serial field.

This information is exposed to all database drivers, although it is only useful on some of them. This method is table prefix-aware.

Parameters
$table | The table name to use for the sequence.
$field | The field name to use for the sequence.
Returns
A table prefix-parsed string for the sequence name.

Definition at line 568 of file database.inc.

References prefixTables().

Referenced by DatabaseConnection_pgsql\nextId().

mapConditionOperator ( $operator )
abstract

Gets any special processing requirements for the condition operator.

Some condition types require special processing, such as IN, because the value data they pass in is not a simple value. This is a simple overridable lookup function. Database connections should define only those operators they wish to be handled differently than the default.

Parameters
$operator The condition operator, such as "IN", "BETWEEN", etc. Case-sensitive.
Returns
The extra handling directives for the specified operator, or NULL.
See Also
DatabaseCondition::compile()

Referenced by DatabaseCondition\compile().

merge | ( |  | $table,
 |  | array | $options = array()
 | ) |  |

Prepares and returns a MERGE query object.

Parameters
$options An array of options on the query.
Returns
MergeQuery A new MergeQuery object.
See Also
MergeQuery

Definition at line 840 of file database.inc.

References getDriverClass().

nextId ( $existing_id = 0 )
abstract

Retrieves an unique id from a given sequence.

Use this function if for some reason you can't use a serial field. For example, MySQL has no ways of reading of the current value of a sequence and PostgreSQL can not advance the sequence to be larger than a given value. Or sometimes you just need a unique integer.

Parameters
$existing_id After a database import, it might be that the sequences table is behind, so by passing in the maximum existing id, it can be assured that we never issue the same id.
Returns
An integer number larger than any number returned by earlier calls and also larger than the $existing_id if one was passed in.
popCommittableTransactions ( )
protected

Internal function: commit all the transaction layers that can commit.

Definition at line 1134 of file database.inc.

References $name, and query().

Referenced by popTransaction(), and rollback().

popTransaction ( $name )

Decreases the depth of transaction nesting.

If we pop off the last transaction layer, then we either commit or roll back the transaction as necessary. If no transaction is active, we return because the transaction may have manually been rolled back.

Parameters
$name The name of the savepoint
Exceptions
DatabaseTransactionNoActiveException
DatabaseTransactionCommitFailedException
See Also
DatabaseTransaction

Definition at line 1114 of file database.inc.

References $name, popCommittableTransactions(), and supportsTransactions().

prefixTables ( $sql )

Appends a database prefix to all tables in a query.

Queries sent to Drupal should wrap all table names in curly brackets. This function searches for this syntax and adds Drupal's table prefix to all tables, allowing Drupal to coexist with other systems in the same database and/or schema if necessary.

Parameters
$sql A string containing a partial or entire SQL query.
Returns
The properly-prefixed string.

Definition at line 444 of file database.inc.

Referenced by makeSequenceName(), DatabaseConnection_sqlite\prepareQuery(), and prepareQuery().

prepareQuery ( $query )

Prepares a query string and returns the prepared statement.

This method caches prepared statements, reusing them when possible. It also prefixes tables names enclosed in curly-braces.

Parameters
$query The query string as SQL, with curly-braces surrounding the table names.
Returns
DatabaseStatementInterface A PDO prepared statement ready for its execute() method.

Definition at line 476 of file database.inc.

References prefixTables().

Referenced by query().

pushTransaction ( $name )

Increases the depth of transaction nesting.

If no transaction is already active, we begin a new transaction.

Exceptions
DatabaseTransactionNameNonUniqueException
See Also
DatabaseTransaction

Definition at line 1081 of file database.inc.

References $name, inTransaction(), query(), and supportsTransactions().

query | ( |  | $query,
 |  | array | $args = array(),
 |  |  | $options = array()
 | ) |  |

Executes a query string against the database.

This method provides a central handler for the actual execution of every query. All queries executed by Drupal are executed as PDO prepared statements.

Parameters
$query | The query to execute. In most cases this will be a string containing an SQL query with placeholders. An already-prepared instance of DatabaseStatementInterface may also be passed in order to allow calling code to manually bind variables to a query. If a DatabaseStatementInterface is passed, the $args array will be ignored. It is extremely rare that module code will need to pass a statement object to this method. It is used primarily for database drivers for databases that require special LOB field handling.
$args | An array of arguments for the prepared statement. If the prepared statement uses ? placeholders, this array must be an indexed array. If it contains named placeholders, it must be an associative array.
$options | An associative array of options to control how the query is run. See the documentation for DatabaseConnection::defaultOptions() for details.
Returns
DatabaseStatementInterface This method will return one of: the executed statement, the number of rows affected by the query (not the number matched), or the generated insert IT of the last query, depending on the value of $options['return']. Typically that value will be set by default or a query builder and should not be set by a user. If there is an error, this method will return NULL and may throw an exception if $options['throw_exception'] is TRUE.
Exceptions
PDOException

Definition at line 664 of file database.inc.

References defaultOptions(), expandArguments(), prepareQuery(), Database\RETURN_AFFECTED, Database\RETURN_INSERT_ID, Database\RETURN_NULL, and Database\RETURN_STATEMENT.

Referenced by DatabaseConnection_sqlite\__construct(), DatabaseConnection_sqlite\__destruct(), DatabaseConnection_mysql\nextId(), DatabaseConnection_sqlite\nextId(), DatabaseConnection_mysql\nextIdDelete(), DatabaseConnection_mysql\popCommittableTransactions(), popCommittableTransactions(), pushTransaction(), DatabaseConnection_mysql\queryRange(), DatabaseConnection_sqlite\queryRange(), DatabaseConnection_mysql\queryTemporary(), DatabaseConnection_sqlite\queryTemporary(), and rollback().

queryRange | ( |  | $query,
 |  |  | $from,
 |  |  | $count,
 |  | array | $args = array(),
 |  | array | $options = array()
 | ) |  |
abstract

Runs a limited-range query on this database object.

Use this as a substitute for ->query() when a subset of the query is to be returned. User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.

Parameters
$query | A string containing an SQL query.
$args | An array of values to substitute into the query at placeholder markers.
$from | The first result row to return.
$count | The maximum number of result rows to return.
$options | An array of options on the query.
Returns
DatabaseStatementInterface A database query result resource, or NULL if the query was not executed correctly.
queryTemporary | ( |  | $query,
 |  | array | $args = array(),
 |  | array | $options = array()
 | ) |  |
abstract

Runs a SELECT query and stores its results in a temporary table.

Use this as a substitute for ->query() when the results need to stored in a temporary table. Temporary tables exist for the duration of the page request. User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.

Note that if you need to know how many results were returned, you should do a SELECT COUNT(*) on the temporary table afterwards.

Parameters
$query | A string containing a normal SELECT SQL query.
$args | An array of values to substitute into the query at placeholder markers.
$options | An associative array of options to control how the query is run. See the documentation for DatabaseConnection::defaultOptions() for details.
Returns
The name of the temporary table.
rollback ( $savepoint_name = 'drupal_transaction' )

Rolls back the transaction entirely or to a named savepoint.

This method throws an exception if no transaction is active.

Parameters
$savepoint_name The name of the savepoint. The default, 'drupal_transaction', will roll the entire transaction back.
Exceptions
DatabaseTransactionNoActiveException
See Also
DatabaseTransaction::rollback()

Definition at line 1030 of file database.inc.

References inTransaction(), popCommittableTransactions(), query(), and supportsTransactions().

schema ( )

Returns a DatabaseSchema object for manipulating the schema.

This method will lazy-load the appropriate schema library file.

Returns
DatabaseSchema The DatabaseSchema object for this connection.

Definition at line 902 of file database.inc.

References $schema, and getDriverClass().

Referenced by destroy().

select | ( |  | $table,
 |  |  | $alias = NULL,
 |  | array | $options = array()
 | ) |  |

Prepares and returns a SELECT query object.

Parameters
$table | The base table for this query, that is, the first table in the FROM clause. This table will also be used as the "base" table for query_alter hook implementations.
$alias | The alias of the base table of this query.
$options | An array of options on the query.
Returns
SelectQueryInterface An appropriate SelectQuery object for this database connection. Note that it may be a driver-specific subclass of SelectQuery, depending on the driver.
See Also
SelectQuery

Definition at line 808 of file database.inc.

References getDriverClass().

setKey ( $key )

Tells this connection object what its key is.

Parameters
$target The key this connection is for.

Definition at line 517 of file database.inc.

References $key.

setLogger ( DatabaseLog $logger )

Associates a logging object with this connection.

Parameters
$logger The logging object we want to use.

Definition at line 539 of file database.inc.

References $logger.

setPrefix ( $prefix )
protected

Set the list of prefixes used by this database connection.

Parameters
$prefix The prefixes, in any of the multiple forms documented in default.settings.php.

Definition at line 405 of file database.inc.

References $key.

Referenced by DatabaseConnection_sqlite\__construct(), __construct(), and DatabaseConnection_sqlite\queryTemporary().

setTarget ( $target = NULL )

Tells this connection object what its target value is.

This is needed for logging and auditing. It's sloppy to do in the constructor because the constructor for child classes has a different signature. We therefore also ensure that this function is only ever called once.

Parameters
$target The target this connection is for. Set to NULL (default) to disable logging entirely.

Definition at line 495 of file database.inc.

References $target.

startTransaction ( $name = '' )

Returns a new DatabaseTransaction object on this connection.

Parameters
$name Optional name of the savepoint.
Returns
DatabaseTransaction A DatabaseTransaction object.
See Also
DatabaseTransaction

Definition at line 1012 of file database.inc.

References $name, and getDriverClass().

Referenced by DatabaseConnection_sqlite\nextId().

supportsTransactionalDDL ( )

Determines if this driver supports transactional DDL.

DDL queries are those that change the schema, such as ALTER queries.

Returns
TRUE if this connection supports transactions for DDL queries, FALSE otherwise.

Definition at line 1251 of file database.inc.

References $transactionalDDLSupport.

supportsTransactions ( )

Determines if this driver supports transactions.

Returns
TRUE if this connection supports transactions, FALSE otherwise.

Definition at line 1238 of file database.inc.

References $transactionSupport.

Referenced by DatabaseConnection_sqlite\popTransaction(), popTransaction(), DatabaseConnection_sqlite\pushTransaction(), pushTransaction(), DatabaseConnection_sqlite\rollback(), and rollback().

tablePrefix ( $table = 'default' )

Find the prefix for a table.

This function is for when you want to know the prefix of a table. This is not used in prefixTables due to performance reasons.

Definition at line 454 of file database.inc.

transactionDepth ( )

Determines current transaction depth.

Definition at line 997 of file database.inc.

Referenced by DatabaseTransaction\__construct(), and inTransaction().

truncate | ( |  | $table,
 |  | array | $options = array()
 | ) |  |

Prepares and returns a TRUNCATE query object.

Parameters
$options An array of options on the query.
Returns
TruncateQuery A new TruncateQuery object.
See Also
TruncateQuery

Definition at line 889 of file database.inc.

References getDriverClass().

update | ( |  | $table,
 |  | array | $options = array()
 | ) |  |

Prepares and returns an UPDATE query object.

Parameters
$options An array of options on the query.
Returns
UpdateQuery A new UpdateQuery object.
See Also
UpdateQuery

Definition at line 857 of file database.inc.

References getDriverClass().

version ( )

Returns the version of the database server.

Definition at line 1228 of file database.inc.

Member Data Documentation

$connectionOptions = array()
protected

Definition at line 266 of file database.inc.

Referenced by getConnectionOptions().

$driverClasses = array()
protected

Definition at line 229 of file database.inc.

$key = NULL
protected

Definition at line 204 of file database.inc.

Referenced by expandArguments(), getKey(), setKey(), and setPrefix().

$logger = NULL
protected

Definition at line 211 of file database.inc.

Referenced by getLogger(), and setLogger().

$prefixes = array()
protected

Definition at line 280 of file database.inc.

Referenced by DatabaseConnection_sqlite\__construct(), and DatabaseConnection_sqlite\queryTemporary().

$prefixReplace = array()
protected

Definition at line 294 of file database.inc.

$prefixSearch = array()
protected

Definition at line 287 of file database.inc.

$schema = NULL
protected

Definition at line 273 of file database.inc.

Referenced by schema().

$statementClass = 'DatabaseStatementBase'
protected

Definition at line 236 of file database.inc.

$target = NULL
protected

Definition at line 193 of file database.inc.

Referenced by getTarget(), and setTarget().

$temporaryNameIndex = 0
protected

Definition at line 259 of file database.inc.

$transactionalDDLSupport = FALSE
protected

Definition at line 252 of file database.inc.

Referenced by supportsTransactionalDDL().

$transactionLayers = array()
protected

Definition at line 222 of file database.inc.

$transactionSupport = TRUE
protected

Definition at line 243 of file database.inc.

Referenced by DatabaseConnection_pgsql\__construct(), and supportsTransactions().

class Database

Primary front-controller for the database system.

This class is uninstantiatable and un-extendable. It acts to encapsulate all control and shepherding of database connections into a single location without the use of globals.

Definition at line 1322 of file database.inc.

Static Public Member Functions

static | startLog ($logging_key, $key= 'default')
static | getLog ($logging_key, $key= 'default')
static | getConnection ($target= 'default', $key=NULL)
static | isActiveConnection ()
static | setActiveConnection ($key= 'default')
static | parseConnectionInfo ()
static | addConnectionInfo ($key, $target, $info)
static | getConnectionInfo ($key= 'default')
static | renameConnection ($old_key, $new_key)
static | removeConnection ($key)
static | closeConnection ($target=NULL, $key=NULL)
static | ignoreTarget ($key, $target)
static | loadDriverFile ($driver, array $files=array())

Public Attributes

const | RETURN_NULL = 0
const | RETURN_STATEMENT = 1
const | RETURN_AFFECTED = 2
const | RETURN_INSERT_ID = 3

Static Protected Member Functions

static | openConnection ($key, $target)

Static Protected Attributes

static | $connections = array()
static | $databaseInfo = NULL
static | $ignoreTargets = array()
static | $activeKey = 'default'
static | $logs = array()

Member Function Documentation

static addConnectionInfo | ( | $key,
 |  | $target,
 |  | $info
 | ) |
static

Adds database connection information for a given key/target.

This method allows the addition of new connection credentials at runtime. Under normal circumstances the preferred way to specify database credentials is via settings.php. However, this method allows them to be added at arbitrary times, such as during unit tests, when connecting to admin-defined third party databases, etc.

If the given key/target pair already exists, this method will be ignored.

Parameters
$key | The database key.
$target | The database target name.
$info | The database connection information, as it would be defined in settings.php. Note that the structure of this array will depend on the database driver it is connecting to.

Definition at line 1581 of file database.inc.

References $info.

Referenced by DrupalWebTestCase\changeDatabasePrefix(), and DrupalUnitTestCase\setUp().

static closeConnection | ( | $target = NULL,
 |  | $key = NULL
 | ) |
static

Closes a connection to the server specified by the given key and target.

Parameters
$target | The database target name. Defaults to NULL meaning that all target connections will be closed.
$key | The database connection key. Defaults to NULL which means the active key.

Definition at line 1708 of file database.inc.

Referenced by db_close().

static getConnection | ( | $target = 'default',
 |  | $key = NULL
 | ) |
staticfinal

Gets the connection object for the specified database key and target.

Parameters
$target | The database target name.
$key | The database connection key. Defaults to NULL which means the active key.
Returns
DatabaseConnection The corresponding connection object.

Definition at line 1460 of file database.inc.

Referenced by Query\__wakeup(), _db_create_keys_sql(), _registry_check_code(), DrupalTestCase\assert(), DatabaseTasks_pgsql\checkBinaryOutput(), DatabaseTasks\checkEngineVersion(), DatabaseTasks\connect(), db_add_field(), db_add_index(), db_add_primary_key(), db_add_unique_key(), db_change_field(), db_create_table(), db_delete(), db_driver(), db_drop_field(), db_drop_index(), db_drop_primary_key(), db_drop_table(), db_drop_unique_key(), db_escape_field(), db_escape_table(), db_field_exists(), db_field_names(), db_field_set_default(), db_field_set_no_default(), db_find_tables(), db_index_exists(), db_insert(), db_like(), db_merge(), db_next_id(), db_query(), db_query_range(), db_query_temporary(), db_rename_table(), db_select(), db_table_exists(), db_transaction(), db_truncate(), db_update(), dblog_watchdog(), field_sql_storage_field_storage_update_field(), poll_update_7001(), DrupalWebTestCase\preloadRegistry(), DrupalUnitTestCase\setUp(), simpletest_clean_database(), and system_requirements().

static getConnectionInfo ( $key = 'default' )
staticfinal

Gets information on the specified database connection.

Parameters
$connection The connection key for which we want information.

Definition at line 1593 of file database.inc.

Referenced by _registry_update(), DrupalWebTestCase\changeDatabasePrefix(), db_ignore_slave(), DatabaseSchema_mysql\getPrefixInfo(), DrupalUnitTestCase\setUp(), and DrupalWebTestCase\tearDown().

static getLog | ( | $logging_key,
 |  | $key = 'default'
 | ) |
staticfinal

Retrieves the queries logged on for given logging key.

This method also ends logging for the specified key. To get the query log to date without ending the logger request the logging object by starting it again (which does nothing to an open log key) and call methods on it as desired.

Parameters
$logging_key | The logging key to log.
$key | The database connection key for which we want to log.
Returns
array The query log for the specified logging key and connection.
See Also
DatabaseLog

Definition at line 1440 of file database.inc.

static ignoreTarget | ( | $key,
 |  | $target
 | ) |
static

Instructs the system to temporarily ignore a given key/target.

At times we need to temporarily disable slave queries. To do so, call this method with the database key and the target to disable. That database key will then always fall back to 'default' for that key, even if it's defined.

Parameters
$key | The database connection key.
$target | The target of the specified key to ignore.

Definition at line 1747 of file database.inc.

Referenced by system_init().

static isActiveConnection ( )
staticfinal

Determines if there is an active connection.

Note that this method will return FALSE if no connection has been established yet, even if one could be.

Returns
TRUE if there is at least one database connection established, FALSE otherwise.

Definition at line 1491 of file database.inc.

static loadDriverFile | ( |  | $driver,
 |  | array | $files = array()
 | ) |  |
static

Load a file for the database that might hold a class.

Parameters
$driver | The name of the driver.
array | $files | The name of the files the driver specific class can be.

Definition at line 1759 of file database.inc.

Referenced by db_installer_object(), and DatabaseConnection\getDriverClass().

static openConnection | ( | $key,
 |  | $target
 | ) |
staticfinalprotected

Opens a connection to the server specified by the given key and target.

Parameters
$key | The database connection key, as specified in settings.php. The default is "default".
$target | The database target to open.
Exceptions
DatabaseConnectionNotDefinedException
DatabaseDriverNotSpecifiedException

Definition at line 1667 of file database.inc.

References DRUPAL_ROOT.

static parseConnectionInfo ( )
staticfinal

Process the configuration file for database information.

Definition at line 1516 of file database.inc.

References $databases, $info, and $value.

Referenced by install_database_errors().

static removeConnection ( $key )
staticfinal

Remove a connection and its corresponding connection information.

Parameters
$key The connection key.
Returns
TRUE in case of success, FALSE otherwise.

Definition at line 1644 of file database.inc.

Referenced by DrupalUnitTestCase\tearDown(), and DrupalWebTestCase\tearDown().

static renameConnection | ( | $old_key,
 |  | $new_key
 | ) |
staticfinal

Rename a connection and its corresponding connection information.

Parameters
$old_key | The old connection key.
$new_key | The new connection key.
Returns
TRUE in case of success, FALSE otherwise.

Definition at line 1613 of file database.inc.

Referenced by DrupalWebTestCase\changeDatabasePrefix(), DrupalUnitTestCase\setUp(), DrupalUnitTestCase\tearDown(), and DrupalWebTestCase\tearDown().

static setActiveConnection ( $key = 'default' )
staticfinal

Sets the active connection to the specified key.

Returns
The previous database connection key.

Definition at line 1501 of file database.inc.

Referenced by db_set_active().

static startLog | ( | $logging_key,
 |  | $key = 'default'
 | ) |
staticfinal

Starts logging a given logging key on the specified connection.

Parameters
$logging_key | The logging key to log.
$key | The database connection key for which we want to log.
Returns
DatabaseLog The query log object. Note that the log object does support richer methods than the few exposed through the Database class, so in some cases it may be desirable to access it directly.
See Also
DatabaseLog

Definition at line 1405 of file database.inc.

Member Data Documentation

$activeKey = 'default'
staticprotected

Definition at line 1374 of file database.inc.

$connections = array()
staticprotected

Definition at line 1353 of file database.inc.

$databaseInfo = NULL
staticprotected

Definition at line 1360 of file database.inc.

$ignoreTargets = array()
staticprotected

Definition at line 1367 of file database.inc.

$logs = array()
staticprotected

Definition at line 1388 of file database.inc.

const RETURN_AFFECTED = 2

Flag to indicate a query call should return the number of affected rows.

Definition at line 1340 of file database.inc.

Referenced by DeleteQuery\__construct(), TruncateQuery\__construct(), UpdateQuery\__construct(), MergeQuery\__construct(), drupal_write_record(), DatabaseConnection_pgsql\query(), and DatabaseConnection\query().

const RETURN_INSERT_ID = 3

Flag to indicate a query call should return the "last insert id".

Definition at line 1345 of file database.inc.

Referenced by InsertQuery\__construct(), drupal_write_record(), InsertQuery_pgsql\execute(), DatabaseConnection_mysql\nextId(), DatabaseConnection_pgsql\query(), and DatabaseConnection\query().

const RETURN_NULL = 0

Flag to indicate a query call should simply return NULL.

This is used for queries that have no reasonable return value anyway, such as INSERT statements to a table without a serial primary key.

Definition at line 1330 of file database.inc.

Referenced by InsertQuery_pgsql\execute(), DatabaseConnection_pgsql\query(), and DatabaseConnection\query().

const RETURN_STATEMENT = 1

Flag to indicate a query call should return the prepared statement.

Definition at line 1335 of file database.inc.

Referenced by SelectQuery\__construct(), DatabaseConnection\defaultOptions(), DatabaseConnection_pgsql\query(), and DatabaseConnection\query().

class DatabaseTransactionNoActiveException

Exception for when popTransaction() is called with no active transaction.

Definition at line 1784 of file database.inc.

Inheritance diagram for DatabaseTransactionNoActiveException:
Exception
class DatabaseTransactionNameNonUniqueException

Exception thrown when a savepoint or transaction name occurs twice.

Definition at line 1789 of file database.inc.

Inheritance diagram for DatabaseTransactionNameNonUniqueException:
Exception
class DatabaseTransactionCommitFailedException

Exception thrown when a commit() function fails.

Definition at line 1794 of file database.inc.

Inheritance diagram for DatabaseTransactionCommitFailedException:
Exception
class DatabaseTransactionExplicitCommitNotAllowedException

Exception to deny attempts to explicitly manage transactions.

This exception will be thrown when the PDO connection commit() is called. Code should never call this method directly.

Definition at line 1802 of file database.inc.

Inheritance diagram for DatabaseTransactionExplicitCommitNotAllowedException:
Exception
class DatabaseTransactionOutOfOrderException

Exception thrown when a rollback() resulted in other active transactions being rolled-back.

Definition at line 1807 of file database.inc.

Inheritance diagram for DatabaseTransactionOutOfOrderException:
Exception
class InvalidMergeQueryException

Exception thrown for merge queries that do not make semantic sense.

There are many ways that a merge query could be malformed. They should all throw this exception and set an appropriately descriptive message.

Definition at line 1815 of file database.inc.

Inheritance diagram for InvalidMergeQueryException:
Exception
class FieldsOverlapException

Exception thrown if an insert query specifies a field twice.

It is not allowed to specify a field as default and insert field, this exception is thrown if that is the case.

Definition at line 1823 of file database.inc.

Inheritance diagram for FieldsOverlapException:
Exception
class NoFieldsException

Exception thrown if an insert query doesn't specify insert or default fields.

Definition at line 1828 of file database.inc.

Inheritance diagram for NoFieldsException:
Exception
class DatabaseConnectionNotDefinedException

Exception thrown if an undefined database connection is requested.

Definition at line 1833 of file database.inc.

Inheritance diagram for DatabaseConnectionNotDefinedException:
Exception
class DatabaseDriverNotSpecifiedException

Exception thrown if no driver is specified for a database connection.

Definition at line 1838 of file database.inc.

Inheritance diagram for DatabaseDriverNotSpecifiedException:
Exception
class DatabaseTransaction

A wrapper class for creating and managing database transactions.

Not all databases or database configurations support transactions. For example, MySQL MyISAM tables do not. It is also easy to begin a transaction and then forget to commit it, which can lead to connection errors when another transaction is started.

This class acts as a wrapper for transactions. To begin a transaction, simply instantiate it. When the object goes out of scope and is destroyed it will automatically commit. It also will check to see if the specified connection supports transactions. If not, it will simply skip any transaction commands, allowing user-space code to proceed normally. The only difference is that rollbacks won't actually do anything.

In the vast majority of cases, you should not instantiate this class directly. Instead, call ->startTransaction(), from the appropriate connection object.

Definition at line 1860 of file database.inc.

Public Member Functions

__construct (DatabaseConnection $connection, $name=NULL)
__destruct ()
name ()
rollback ()

Protected Attributes

$connection
$rolledBack = FALSE
$name

Constructor & Destructor Documentation

__construct | ( | DatabaseConnection | $connection,
 |  |  | $name = NULL
 | ) |  |

Definition at line 1884 of file database.inc.

References $connection, $depth, $name, name(), and DatabaseConnection\transactionDepth().

__destruct ( )

Definition at line 1902 of file database.inc.

References name().

Member Function Documentation

name ( )

Retrieves the name of the transaction or savepoint.

Definition at line 1912 of file database.inc.

References $name.

Referenced by __construct(), __destruct(), and rollback().

rollback ( )

Rolls back the current transaction.

This is just a wrapper method to rollback whatever transaction stack we are currently in, which is managed by the connection object itself. Note that logging (preferable with watchdog_exception()) needs to happen after a transaction has been rolled back or the log messages will be rolled back too.

See Also
DatabaseConnection::rollback()
watchdog_exception()

Definition at line 1928 of file database.inc.

References name().

Member Data Documentation

$connection
protected

Definition at line 1867 of file database.inc.

Referenced by __construct().

$name
protected

The name of the transaction.

This is used to label the transaction savepoint. It will be overridden to 'drupal_transaction' if there is no transaction depth.

Definition at line 1882 of file database.inc.

Referenced by __construct(), and name().

$rolledBack = FALSE
protected

Definition at line 1874 of file database.inc.

interface DatabaseStatementInterface

Represents a prepared statement.

Some methods in that class are purposefully commented out. Due to a change in how PHP defines PDOStatement, we can't define a signature for those methods that will work the same way between versions older than 5.2.6 and later versions. See http://bugs.php.net/bug.php?id=42452 for more details.

Child implementations should either extend PDOStatement:

* class DatabaseStatement_oracle extends PDOStatement implements DatabaseStatementInterface {}
*

or define their own class. If defining their own class, they will also have to implement either the Iterator or IteratorAggregate interface before DatabaseStatementInterface:

* class DatabaseStatement_oracle implements Iterator, DatabaseStatementInterface {}
*

Definition at line 1953 of file database.inc.

Inheritance diagram for DatabaseStatementInterface:
DatabaseStatement_sqlite DatabaseStatementBase DatabaseStatementEmpty DatabaseStatementPrefetch DatabaseStatement_sqlite

Public Member Functions

execute ($args=array(), $options=array())
getQueryString ()
rowCount ()
fetchField ($index=0)
fetchAssoc ()
fetchCol ($index=0)
fetchAllKeyed ($key_index=0, $value_index=1)
fetchAllAssoc ($key, $fetch=NULL)

Member Function Documentation

execute | ( | $args = array(),
 |  | $options = array()
 | ) |

Executes a prepared statement

Parameters
$args | An array of values with as many elements as there are bound parameters in the SQL statement being executed.
$options | An array of options for this query.
Returns
TRUE on success, or FALSE on failure.

Implemented in DatabaseStatementEmpty, DatabaseStatementBase, DatabaseStatement_sqlite, and DatabaseStatementPrefetch.

fetchAllAssoc | ( | $key,
 |  | $fetch = NULL
 | ) |

Returns the result set as an associative array keyed by the given field.

If the given key appears multiple times, later records will overwrite earlier ones.

Parameters
$key | The name of the field on which to index the array.
$fetch | The fetchmode to use. If set to PDO::FETCH_ASSOC, PDO::FETCH_NUM, or PDO::FETCH_BOTH the returned value with be an array of arrays. For any other value it will be an array of objects. By default, the fetch mode set for the query will be used.
Returns
An associative array, or an empty array if there is no result set.

Implemented in DatabaseStatementEmpty, DatabaseStatementBase, and DatabaseStatementPrefetch.

fetchAllKeyed | ( | $key_index = 0,
 |  | $value_index = 1
 | ) |

Returns the entire result set as a single associative array.

This method is only useful for two-column result sets. It will return an associative array where the key is one column from the result set and the value is another field. In most cases, the default of the first two columns is appropriate.

Note that this method will run the result set to the end.

Parameters
$key_index | The numeric index of the field to use as the array key.
$value_index | The numeric index of the field to use as the array value.
Returns
An associative array, or an empty array if there is no result set.

Implemented in DatabaseStatementEmpty, DatabaseStatementBase, and DatabaseStatementPrefetch.

fetchAssoc ( )

Fetches the next row and returns it as an object.

The object will be of the class specified by DatabaseStatementInterface::setFetchMode() or stdClass if not specified. Fetches the next row and returns it as an associative array.

This method corresponds to PDOStatement::fetchObject(), but for associative arrays. For some reason PDOStatement does not have a corresponding array helper method, so one is added.

Returns
An associative array, or FALSE if there is no next row.

Implemented in DatabaseStatementEmpty, DatabaseStatementBase, and DatabaseStatementPrefetch.

fetchCol ( $index = 0 )

Returns an array containing all of the result set rows.

Parameters
$mode | One of the PDO::FETCH_* constants.
$column_index | If $mode is PDO::FETCH_COLUMN, the index of the column to fetch.
$constructor_arguments | If $mode is PDO::FETCH_CLASS, the arguments to pass to the constructor.
Returns
An array of results. Returns an entire single column of a result set as an indexed array.

Note that this method will run the result set to the end.

Parameters
$index The index of the column number to fetch.
Returns
An indexed array, or an empty array if there is no result set.

Implemented in DatabaseStatementEmpty, DatabaseStatementBase, and DatabaseStatementPrefetch.

fetchField ( $index = 0 )

Sets the default fetch mode for this statement.

See http://php.net/manual/pdo.constants.php for the definition of the constants used.

Parameters
$mode | One of the PDO::FETCH_* constants.
$a1 An option depending of the fetch mode specified by $mode:
  • for PDO::FETCH_COLUMN, the index of the column to fetch
  • for PDO::FETCH_CLASS, the name of the class to create
  • for PDO::FETCH_INTO, the object to add the data to
$a2 | If $mode is PDO::FETCH_CLASS, the optional arguments to pass to the constructor. Fetches the next row from a result set.

See http://php.net/manual/pdo.constants.php for the definition of the constants used.

Parameters
$mode | One of the PDO::FETCH_* constants. Default to what was specified by setFetchMode().
$cursor_orientation | Not implemented in all database drivers, don't use.
$cursor_offset | Not implemented in all database drivers, don't use.
Returns
A result, formatted according to $mode. Returns a single field from the next record of a result set.
Parameters
$index The numeric index of the field to return. Defaults to the first field.
Returns
A single field from the next record, or FALSE if there is no next record.

Implemented in DatabaseStatementEmpty, DatabaseStatementBase, and DatabaseStatementPrefetch.

getQueryString ( )

Gets the query string of this statement.

Returns
The query string, in its form with placeholders.

Implemented in DatabaseStatementEmpty, DatabaseStatementBase, and DatabaseStatementPrefetch.

Referenced by DatabaseLog\log().

rowCount ( )

Returns the number of rows affected by the last SQL statement.

Returns
The number of rows affected by the last DELETE, INSERT, or UPDATE statement executed.

Implemented in DatabaseStatementEmpty, and DatabaseStatementPrefetch.

class DatabaseStatementBase

Default implementation of DatabaseStatementInterface.

PDO allows us to extend the PDOStatement class to provide additional functionality beyond that offered by default. We do need extra functionality. By default, this class is not driver-specific. If a given driver needs to set a custom statement class, it may do so in its constructor.

See Also
http://us.php.net/pdostatement

Definition at line 2134 of file database.inc.

Inheritance diagram for DatabaseStatementBase:
DatabaseStatementInterface

Public Member Functions

execute ($args=array(), $options=array())
getQueryString ()
fetchCol ($index=0)
fetchAllAssoc ($key, $fetch=NULL)
fetchAllKeyed ($key_index=0, $value_index=1)
fetchField ($index=0)
fetchAssoc ()
- Public Member Functions inherited from DatabaseStatementInterface
rowCount ()

Public Attributes

$dbh

Protected Member Functions

__construct ($dbh)

Constructor & Destructor Documentation

__construct ( $dbh )
protected

Definition at line 2145 of file database.inc.

References $dbh.

Member Function Documentation

execute | ( | $args = array(),
 |  | $options = array()
 | ) |

Executes a prepared statement

Parameters
$args | An array of values with as many elements as there are bound parameters in the SQL statement being executed.
$options | An array of options for this query.
Returns
TRUE on success, or FALSE on failure.

Implements DatabaseStatementInterface.

Definition at line 2150 of file database.inc.

fetchAllAssoc | ( | $key,
 |  | $fetch = NULL
 | ) |

Returns the result set as an associative array keyed by the given field.

If the given key appears multiple times, later records will overwrite earlier ones.

Parameters
$key | The name of the field on which to index the array.
$fetch | The fetchmode to use. If set to PDO::FETCH_ASSOC, PDO::FETCH_NUM, or PDO::FETCH_BOTH the returned value with be an array of arrays. For any other value it will be an array of objects. By default, the fetch mode set for the query will be used.
Returns
An associative array, or an empty array if there is no result set.

Implements DatabaseStatementInterface.

Definition at line 2186 of file database.inc.

fetchAllKeyed | ( | $key_index = 0,
 |  | $value_index = 1
 | ) |

Returns the entire result set as a single associative array.

This method is only useful for two-column result sets. It will return an associative array where the key is one column from the result set and the value is another field. In most cases, the default of the first two columns is appropriate.

Note that this method will run the result set to the end.

Parameters
$key_index | The numeric index of the field to use as the array key.
$value_index | The numeric index of the field to use as the array value.
Returns
An associative array, or an empty array if there is no result set.

Implements DatabaseStatementInterface.

Definition at line 2205 of file database.inc.

fetchAssoc ( )

Fetches the next row and returns it as an object.

The object will be of the class specified by DatabaseStatementInterface::setFetchMode() or stdClass if not specified. Fetches the next row and returns it as an associative array.

This method corresponds to PDOStatement::fetchObject(), but for associative arrays. For some reason PDOStatement does not have a corresponding array helper method, so one is added.

Returns
An associative array, or FALSE if there is no next row.

Implements DatabaseStatementInterface.

Definition at line 2219 of file database.inc.

fetchCol ( $index = 0 )

Returns an array containing all of the result set rows.

Parameters
$mode | One of the PDO::FETCH_* constants.
$column_index | If $mode is PDO::FETCH_COLUMN, the index of the column to fetch.
$constructor_arguments | If $mode is PDO::FETCH_CLASS, the arguments to pass to the constructor.
Returns
An array of results. Returns an entire single column of a result set as an indexed array.

Note that this method will run the result set to the end.

Parameters
$index The index of the column number to fetch.
Returns
An indexed array, or an empty array if there is no result set.

Implements DatabaseStatementInterface.

Definition at line 2182 of file database.inc.

fetchField ( $index = 0 )

Sets the default fetch mode for this statement.

See http://php.net/manual/pdo.constants.php for the definition of the constants used.

Parameters
$mode | One of the PDO::FETCH_* constants.
$a1 An option depending of the fetch mode specified by $mode:
  • for PDO::FETCH_COLUMN, the index of the column to fetch
  • for PDO::FETCH_CLASS, the name of the class to create
  • for PDO::FETCH_INTO, the object to add the data to
$a2 | If $mode is PDO::FETCH_CLASS, the optional arguments to pass to the constructor. Fetches the next row from a result set.

See http://php.net/manual/pdo.constants.php for the definition of the constants used.

Parameters
$mode | One of the PDO::FETCH_* constants. Default to what was specified by setFetchMode().
$cursor_orientation | Not implemented in all database drivers, don't use.
$cursor_offset | Not implemented in all database drivers, don't use.
Returns
A result, formatted according to $mode. Returns a single field from the next record of a result set.
Parameters
$index The numeric index of the field to return. Defaults to the first field.
Returns
A single field from the next record, or FALSE if there is no next record.

Implements DatabaseStatementInterface.

Definition at line 2214 of file database.inc.

getQueryString ( )

Gets the query string of this statement.

Returns
The query string, in its form with placeholders.

Implements DatabaseStatementInterface.

Definition at line 2178 of file database.inc.

Member Data Documentation

$dbh

Definition at line 2143 of file database.inc.

Referenced by __construct().

class DatabaseStatementEmpty

Empty implementation of a database statement.

This class satisfies the requirements of being a database statement/result object, but does not actually contain data. It is useful when developers need to safely return an "empty" result set without connecting to an actual database. Calling code can then treat it the same as if it were an actual result set that happens to contain no records.

See Also
SearchQuery

Definition at line 2236 of file database.inc.

Inheritance diagram for DatabaseStatementEmpty:
DatabaseStatementInterface

Public Member Functions

execute ($args=array(), $options=array())
getQueryString ()
rowCount ()
setFetchMode ($mode, $a1=NULL, $a2=array())
fetch ($mode=NULL, $cursor_orientation=NULL, $cursor_offset=NULL)
fetchField ($index=0)
fetchObject ()
fetchAssoc ()
fetchAll ($mode=NULL, $column_index=NULL, array $constructor_arguments=array())
fetchCol ($index=0)
fetchAllKeyed ($key_index=0, $value_index=1)
fetchAllAssoc ($key, $fetch=NULL)
current ()
key ()
rewind ()
next ()
valid ()

Member Function Documentation

current ( )

Definition at line 2288 of file database.inc.

execute | ( | $args = array(),
 |  | $options = array()
 | ) |

Executes a prepared statement

Parameters
$args | An array of values with as many elements as there are bound parameters in the SQL statement being executed.
$options | An array of options for this query.
Returns
TRUE on success, or FALSE on failure.

Implements DatabaseStatementInterface.

Definition at line 2238 of file database.inc.

fetch | ( | $mode = NULL,
 |  | $cursor_orientation = NULL,
 |  | $cursor_offset = NULL
 | ) |

Definition at line 2254 of file database.inc.

fetchAll | ( |  | $mode = NULL,
 |  |  | $column_index = NULL,
 |  | array | $constructor_arguments = array()
 | ) |  |

Definition at line 2270 of file database.inc.

fetchAllAssoc | ( | $key,
 |  | $fetch = NULL
 | ) |

Returns the result set as an associative array keyed by the given field.

If the given key appears multiple times, later records will overwrite earlier ones.

Parameters
$key | The name of the field on which to index the array.
$fetch | The fetchmode to use. If set to PDO::FETCH_ASSOC, PDO::FETCH_NUM, or PDO::FETCH_BOTH the returned value with be an array of arrays. For any other value it will be an array of objects. By default, the fetch mode set for the query will be used.
Returns
An associative array, or an empty array if there is no result set.

Implements DatabaseStatementInterface.

Definition at line 2282 of file database.inc.

fetchAllKeyed | ( | $key_index = 0,
 |  | $value_index = 1
 | ) |

Returns the entire result set as a single associative array.

This method is only useful for two-column result sets. It will return an associative array where the key is one column from the result set and the value is another field. In most cases, the default of the first two columns is appropriate.

Note that this method will run the result set to the end.

Parameters
$key_index | The numeric index of the field to use as the array key.
$value_index | The numeric index of the field to use as the array value.
Returns
An associative array, or an empty array if there is no result set.

Implements DatabaseStatementInterface.

Definition at line 2278 of file database.inc.

fetchAssoc ( )

Fetches the next row and returns it as an object.

The object will be of the class specified by DatabaseStatementInterface::setFetchMode() or stdClass if not specified. Fetches the next row and returns it as an associative array.

This method corresponds to PDOStatement::fetchObject(), but for associative arrays. For some reason PDOStatement does not have a corresponding array helper method, so one is added.

Returns
An associative array, or FALSE if there is no next row.

Implements DatabaseStatementInterface.

Definition at line 2266 of file database.inc.

fetchCol ( $index = 0 )

Returns an array containing all of the result set rows.

Parameters
$mode | One of the PDO::FETCH_* constants.
$column_index | If $mode is PDO::FETCH_COLUMN, the index of the column to fetch.
$constructor_arguments | If $mode is PDO::FETCH_CLASS, the arguments to pass to the constructor.
Returns
An array of results. Returns an entire single column of a result set as an indexed array.

Note that this method will run the result set to the end.

Parameters
$index The index of the column number to fetch.
Returns
An indexed array, or an empty array if there is no result set.

Implements DatabaseStatementInterface.

Definition at line 2274 of file database.inc.

fetchField ( $index = 0 )

Sets the default fetch mode for this statement.

See http://php.net/manual/pdo.constants.php for the definition of the constants used.

Parameters
$mode | One of the PDO::FETCH_* constants.
$a1 An option depending of the fetch mode specified by $mode:
  • for PDO::FETCH_COLUMN, the index of the column to fetch
  • for PDO::FETCH_CLASS, the name of the class to create
  • for PDO::FETCH_INTO, the object to add the data to
$a2 | If $mode is PDO::FETCH_CLASS, the optional arguments to pass to the constructor. Fetches the next row from a result set.

See http://php.net/manual/pdo.constants.php for the definition of the constants used.

Parameters
$mode | One of the PDO::FETCH_* constants. Default to what was specified by setFetchMode().
$cursor_orientation | Not implemented in all database drivers, don't use.
$cursor_offset | Not implemented in all database drivers, don't use.
Returns
A result, formatted according to $mode. Returns a single field from the next record of a result set.
Parameters
$index The numeric index of the field to return. Defaults to the first field.
Returns
A single field from the next record, or FALSE if there is no next record.

Implements DatabaseStatementInterface.

Definition at line 2258 of file database.inc.

fetchObject ( )

Definition at line 2262 of file database.inc.

getQueryString ( )

Gets the query string of this statement.

Returns
The query string, in its form with placeholders.

Implements DatabaseStatementInterface.

Definition at line 2242 of file database.inc.

key ( )

Definition at line 2292 of file database.inc.

next ( )

Definition at line 2300 of file database.inc.

rewind ( )

Definition at line 2296 of file database.inc.

rowCount ( )

Returns the number of rows affected by the last SQL statement.

Returns
The number of rows affected by the last DELETE, INSERT, or UPDATE statement executed.

Implements DatabaseStatementInterface.

Definition at line 2246 of file database.inc.

setFetchMode | ( | $mode,
 |  | $a1 = NULL,
 |  | $a2 = array()
 | ) |

Definition at line 2250 of file database.inc.

valid ( )

Definition at line 2304 of file database.inc.

class DatabaseConnection_mysql

Definition at line 13 of file database.inc.

Inheritance diagram for DatabaseConnection_mysql:
DatabaseConnection

Public Member Functions

__construct (array $connection_options=array())
__destruct ()
queryRange ($query, $from, $count, array $args=array(), array $options=array())
queryTemporary ($query, array $args=array(), array $options=array())
driver ()
databaseType ()
mapConditionOperator ($operator)
nextId ($existing_id=0)
nextIdDelete ()
- Public Member Functions inherited from DatabaseConnection
__construct ($dsn, $username, $password, $driver_options=array())
destroy ()
getConnectionOptions ()
prefixTables ($sql)
tablePrefix ($table= 'default')
prepareQuery ($query)
setTarget ($target=NULL)
getTarget ()
setKey ($key)
getKey ()
setLogger (DatabaseLog $logger)
getLogger ()
makeSequenceName ($table, $field)
makeComment ($comments)
query ($query, array $args=array(), $options=array())
getDriverClass ($class, array $files=array(), $use_autoload=FALSE)
select ($table, $alias=NULL, array $options=array())
insert ($table, array $options=array())
merge ($table, array $options=array())
update ($table, array $options=array())
delete ($table, array $options=array())
truncate ($table, array $options=array())
schema ()
escapeTable ($table)
escapeField ($field)
escapeAlias ($field)
escapeLike ($string)
inTransaction ()
transactionDepth ()
startTransaction ($name= '')
rollback ($savepoint_name= 'drupal_transaction')
pushTransaction ($name)
popTransaction ($name)
queryRange ($query, $from, $count, array $args=array(), array $options=array())
queryTemporary ($query, array $args=array(), array $options=array())
driver ()
version ()
supportsTransactions ()
supportsTransactionalDDL ()
databaseType ()
mapConditionOperator ($operator)
commit ()
nextId ($existing_id=0)

Protected Member Functions

popCommittableTransactions ()
- Protected Member Functions inherited from DatabaseConnection
defaultOptions ()
setPrefix ($prefix)
filterComment ($comment= '')
expandArguments (&$query, &$args)
popCommittableTransactions ()
generateTemporaryTableName ()

Protected Attributes

$needsCleanup = FALSE
- Protected Attributes inherited from DatabaseConnection
$target = NULL
$key = NULL
$logger = NULL
$transactionLayers = array()
$driverClasses = array()
$statementClass = 'DatabaseStatementBase'
$transactionSupport = TRUE
$transactionalDDLSupport = FALSE
$temporaryNameIndex = 0
$connectionOptions = array()
$schema = NULL
$prefixes = array()
$prefixSearch = array()
$prefixReplace = array()

Constructor & Destructor Documentation

__construct ( array $connection_options = array() )

Definition at line 22 of file database.inc.

__destruct ( )

Definition at line 81 of file database.inc.

References nextIdDelete().

Member Function Documentation

databaseType ( )

Definition at line 101 of file database.inc.

driver ( )

Definition at line 97 of file database.inc.

mapConditionOperator ( $operator )

Definition at line 105 of file database.inc.

nextId ( $existing_id = 0 )

Definition at line 110 of file database.inc.

References DatabaseConnection\query(), and Database\RETURN_INSERT_ID.

nextIdDelete ( )

Definition at line 128 of file database.inc.

References DatabaseConnection\query().

Referenced by __destruct().

popCommittableTransactions ( )
protected

Overridden to work around issues to MySQL not supporting transactional DDL.

Definition at line 155 of file database.inc.

References $name, and DatabaseConnection\query().

queryRange | ( |  | $query,
 |  |  | $from,
 |  |  | $count,
 |  | array | $args = array(),
 |  | array | $options = array()
 | ) |  |

Definition at line 87 of file database.inc.

References DatabaseConnection\query().

queryTemporary | ( |  | $query,
 |  | array | $args = array(),
 |  | array | $options = array()
 | ) |  |

Definition at line 91 of file database.inc.

References DatabaseConnection\generateTemporaryTableName(), and DatabaseConnection\query().

Member Data Documentation

$needsCleanup = FALSE
protected

Definition at line 20 of file database.inc.

class InsertQuery_mysql

Definition at line 14 of file query.inc.

Inheritance diagram for InsertQuery_mysql:
InsertQuery Query QueryPlaceholderInterface

Public Member Functions

execute ()
__toString ()
- Public Member Functions inherited from InsertQuery
__construct ($connection, $table, array $options=array())
fields (array $fields, array $values=array())
values (array $values)
useDefaults (array $fields)
from (SelectQueryInterface $query)
execute ()
__toString ()
preExecute ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Additional Inherited Members

- Protected Member Functions inherited from Query
execute ()
- Protected Attributes inherited from InsertQuery
$table
$insertFields = array()
$defaultFields = array()
$insertValues = array()
$fromQuery
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Member Function Documentation

__toString ( )

Definition at line 44 of file query.inc.

References Query\$comments, and InsertQuery\$fromQuery.

execute ( )

Definition at line 16 of file query.inc.

References $value, and InsertQuery\preExecute().

class TruncateQuery_mysql

Definition at line 90 of file query.inc.

Inheritance diagram for TruncateQuery_mysql:
TruncateQuery Query QueryPlaceholderInterface

Additional Inherited Members

- Public Member Functions inherited from TruncateQuery
__construct (DatabaseConnection $connection, $table, array $options=array())
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
execute ()
__toString ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()
- Protected Member Functions inherited from Query
execute ()
- Protected Attributes inherited from TruncateQuery
$table
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()
class DatabaseConnection_pgsql

Definition at line 18 of file database.inc.

Inheritance diagram for DatabaseConnection_pgsql:
DatabaseConnection

Public Member Functions

__construct (array $connection_options=array())
prepareQuery ($query)
query ($query, array $args=array(), $options=array())
queryRange ($query, $from, $count, array $args=array(), array $options=array())
queryTemporary ($query, array $args=array(), array $options=array())
driver ()
databaseType ()
mapConditionOperator ($operator)
nextId ($existing=0)
- Public Member Functions inherited from DatabaseConnection
__construct ($dsn, $username, $password, $driver_options=array())
destroy ()
getConnectionOptions ()
prefixTables ($sql)
tablePrefix ($table= 'default')
prepareQuery ($query)
setTarget ($target=NULL)
getTarget ()
setKey ($key)
getKey ()
setLogger (DatabaseLog $logger)
getLogger ()
makeSequenceName ($table, $field)
makeComment ($comments)
query ($query, array $args=array(), $options=array())
getDriverClass ($class, array $files=array(), $use_autoload=FALSE)
select ($table, $alias=NULL, array $options=array())
insert ($table, array $options=array())
merge ($table, array $options=array())
update ($table, array $options=array())
delete ($table, array $options=array())
truncate ($table, array $options=array())
schema ()
escapeTable ($table)
escapeField ($field)
escapeAlias ($field)
escapeLike ($string)
inTransaction ()
transactionDepth ()
startTransaction ($name= '')
rollback ($savepoint_name= 'drupal_transaction')
pushTransaction ($name)
popTransaction ($name)
queryRange ($query, $from, $count, array $args=array(), array $options=array())
queryTemporary ($query, array $args=array(), array $options=array())
driver ()
version ()
supportsTransactions ()
supportsTransactionalDDL ()
databaseType ()
mapConditionOperator ($operator)
commit ()
nextId ($existing_id=0)

Additional Inherited Members

- Protected Member Functions inherited from DatabaseConnection
defaultOptions ()
setPrefix ($prefix)
filterComment ($comment= '')
expandArguments (&$query, &$args)
popCommittableTransactions ()
generateTemporaryTableName ()
- Protected Attributes inherited from DatabaseConnection
$target = NULL
$key = NULL
$logger = NULL
$transactionLayers = array()
$driverClasses = array()
$statementClass = 'DatabaseStatementBase'
$transactionSupport = TRUE
$transactionalDDLSupport = FALSE
$temporaryNameIndex = 0
$connectionOptions = array()
$schema = NULL
$prefixes = array()
$prefixSearch = array()
$prefixReplace = array()

Constructor & Destructor Documentation

__construct ( array $connection_options = array() )

Definition at line 20 of file database.inc.

References DatabaseConnection\$transactionSupport.

Member Function Documentation

databaseType ( )

Definition at line 157 of file database.inc.

driver ( )

Definition at line 153 of file database.inc.

mapConditionOperator ( $operator )

Definition at line 161 of file database.inc.

nextId ( $existing = 0 )

Retrive a the next id in a sequence.

PostgreSQL has built in sequences. We'll use these instead of inserting and updating a sequences table.

Definition at line 183 of file database.inc.

References DatabaseConnection\makeSequenceName(), POSTGRESQL_NEXTID_LOCK, and query().

prepareQuery ( $query )

Definition at line 77 of file database.inc.

Referenced by query().

query | ( |  | $query,
 |  | array | $args = array(),
 |  |  | $options = array()
 | ) |  |

Definition at line 88 of file database.inc.

References $value, DatabaseConnection\defaultOptions(), DatabaseConnection\expandArguments(), prepareQuery(), Database\RETURN_AFFECTED, Database\RETURN_INSERT_ID, Database\RETURN_NULL, and Database\RETURN_STATEMENT.

Referenced by nextId(), queryRange(), and queryTemporary().

queryRange | ( |  | $query,
 |  |  | $from,
 |  |  | $count,
 |  | array | $args = array(),
 |  | array | $options = array()
 | ) |  |

Definition at line 143 of file database.inc.

References query().

queryTemporary | ( |  | $query,
 |  | array | $args = array(),
 |  | array | $options = array()
 | ) |  |

Definition at line 147 of file database.inc.

References DatabaseConnection\generateTemporaryTableName(), and query().

class SelectQuery_pgsql

Definition at line 13 of file select.inc.

Inheritance diagram for SelectQuery_pgsql:
SelectQuery Query SelectQueryInterface QueryPlaceholderInterface QueryConditionInterface QueryAlterableInterface QueryExtendableInterface QueryPlaceholderInterface

Public Member Functions

orderRandom ()
orderBy ($field, $direction= 'ASC')
- Public Member Functions inherited from SelectQuery
__construct ($table, $alias=NULL, DatabaseConnection $connection, $options=array())
addTag ($tag)
hasTag ($tag)
hasAllTags ()
hasAnyTag ()
addMetaData ($key, $object)
getMetaData ($key)
condition ($field, $value=NULL, $operator=NULL)
& conditions ()
arguments ()
where ($snippet, $args=array())
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
havingCondition ($field, $value=NULL, $operator=NULL)
& havingConditions ()
havingArguments ()
having ($snippet, $args=array())
havingCompile (DatabaseConnection $connection)
extend ($extender_name)
havingIsNull ($field)
havingIsNotNull ($field)
havingExists (SelectQueryInterface $select)
havingNotExists (SelectQueryInterface $select)
forUpdate ($set=TRUE)
& getFields ()
& getExpressions ()
& getOrderBy ()
& getGroupBy ()
& getTables ()
& getUnion ()
getArguments (QueryPlaceholderInterface $queryPlaceholder=NULL)
isPrepared ()
preExecute (SelectQueryInterface $query=NULL)
execute ()
distinct ($distinct=TRUE)
addField ($table_alias, $field, $alias=NULL)
fields ($table_alias, array $fields=array())
addExpression ($expression, $alias=NULL, $arguments=array())
join ($table, $alias=NULL, $condition=NULL, $arguments=array())
innerJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
leftJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
rightJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
addJoin ($type, $table, $alias=NULL, $condition=NULL, $arguments=array())
orderBy ($field, $direction= 'ASC')
orderRandom ()
range ($start=NULL, $length=NULL)
union (SelectQueryInterface $query, $type= '')
groupBy ($field)
countQuery ()
__toString ()
__clone ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Additional Inherited Members

- Protected Member Functions inherited from Query
execute ()
- Protected Attributes inherited from SelectQuery
$fields = array()
$expressions = array()
$tables = array()
$order = array()
$group = array()
$where
$having
$distinct = FALSE
$range
$union = array()
$prepared = FALSE
$forUpdate = FALSE
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Member Function Documentation

orderBy | ( | $field,
 |  | $direction = 'ASC'
 | ) |

Overrides SelectQuery::orderBy().

PostgreSQL adheres strictly to the SQL-92 standard and requires that when using DISTINCT or GROUP BY conditions, fields and expressions that are ordered on also need to be selected. This is a best effort implementation to handle the cases that can be automated by adding the field if it is not yet selected.

* $query = db_select('node', 'n');
* $query->join('node_revision', 'nr', 'n.vid = nr.vid');
* $query
* ->distinct()
* ->fields('n')
* ->orderBy('timestamp');
*

In this query, it is not possible (without relying on the schema) to know whether timestamp belongs to node_revisions and needs to be added or belongs to node and is already selected. Queries like this will need to be corrected in the original query by adding an explicit call to SelectQuery::addField() or SelectQuery::fields().

Since this has a small performance impact, both by the additional processing in this function and in the database that needs to return the additional fields, this is done as an override instead of implementing it directly in SelectQuery::orderBy().

Implements SelectQueryInterface.

Definition at line 50 of file select.inc.

References SelectQuery\addField(), and SelectQuery\fields().

Referenced by orderRandom().

orderRandom ( )

Orders the result set by a random value.

This may be stacked with other orderBy() calls. If so, the query will order by each specified field, including this one, in the order called. Although this method may be called multiple times on the same query, doing so is not particularly useful.

Note: The method used by most drivers may not scale to very large result sets. If you need to work with extremely large data sets, you may create your own database driver by subclassing off of an existing driver and implementing your own randomization mechanism. See

http://jan.kneschke.de/projects/mysql/order-by-rand/

for an example of such an alternate sorting mechanism.

Returns
SelectQueryInterface The called object

Implements SelectQueryInterface.

Definition at line 15 of file select.inc.

References SelectQuery\addExpression(), and orderBy().

class DatabaseStatementPrefetch

An implementation of DatabaseStatementInterface that prefetches all data.

This class behaves very similar to a PDOStatement but as it always fetches every row it is possible to manipulate those results.

Definition at line 22 of file prefetch.inc.

Inheritance diagram for DatabaseStatementPrefetch:
DatabaseStatementInterface DatabaseStatement_sqlite

Public Member Functions

__construct (DatabaseConnection $connection, $query, array $driver_options=array())
execute ($args=array(), $options=array())
getQueryString ()
setFetchMode ($fetchStyle, $a2=NULL, $a3=NULL)
current ()
key ()
rewind ()
next ()
valid ()
rowCount ()
fetch ($fetch_style=NULL, $cursor_orientation=PDO::FETCH_ORI_NEXT, $cursor_offset=NULL)
fetchColumn ($index=0)
fetchField ($index=0)
fetchObject ($class_name=NULL, $constructor_args=array())
fetchAssoc ()
fetchAll ($fetch_style=NULL, $fetch_column=NULL, $constructor_args=NULL)
fetchCol ($index=0)
fetchAllKeyed ($key_index=0, $value_index=1)
fetchAllAssoc ($key, $fetch_style=NULL)

Public Attributes

$dbh

Protected Member Functions

throwPDOException ()
getStatement ($query, &$args=array())

Protected Attributes

$queryString
$driverOptions
$data = array()
$currentRow = NULL
$currentKey = NULL
$columnNames = NULL
$rowCount = NULL
$resultRowCount = 0
$fetchStyle = PDO::FETCH_OBJ
$fetchOptions
$defaultFetchStyle = PDO::FETCH_OBJ
$defaultFetchOptions

Constructor & Destructor Documentation

__construct | ( | DatabaseConnection | $connection,
 |  |  | $query,
 |  | array | $driver_options = array()
 | ) |  |

Definition at line 128 of file prefetch.inc.

Member Function Documentation

current ( )

Return the current row formatted according to the current fetch style.

This is the core method of this class. It grabs the value at the current array position in $this->data and format it according to $this->fetchStyle and $this->fetchMode.

Returns
The current row formatted as requested.

Definition at line 271 of file prefetch.inc.

References $currentRow.

Referenced by fetch(), fetchAll(), fetchAllAssoc(), and fetchObject().

execute | ( | $args = array(),
 |  | $options = array()
 | ) |

Executes a prepared statement.

Parameters
$args | An array of values with as many elements as there are bound parameters in the SQL statement being executed.
$options | An array of options for this query.
Returns
TRUE on success, or FALSE on failure.

Implements DatabaseStatementInterface.

Definition at line 144 of file prefetch.inc.

References getStatement(), next(), rowCount(), setFetchMode(), and throwPDOException().

fetch | ( | $fetch_style = NULL,
 |  | $cursor_orientation = PDO::FETCH_ORI_NEXT,
 |  | $cursor_offset = NULL
 | ) |

Definition at line 352 of file prefetch.inc.

References $defaultFetchOptions, $defaultFetchStyle, current(), and next().

fetchAll | ( | $fetch_style = NULL,
 |  | $fetch_column = NULL,
 |  | $constructor_args = NULL
 | ) |

Definition at line 425 of file prefetch.inc.

References $defaultFetchOptions, $defaultFetchStyle, current(), and next().

fetchAllAssoc | ( | $key,
 |  | $fetch = NULL
 | ) |

Returns the result set as an associative array keyed by the given field.

If the given key appears multiple times, later records will overwrite earlier ones.

Parameters
$key | The name of the field on which to index the array.
$fetch | The fetchmode to use. If set to PDO::FETCH_ASSOC, PDO::FETCH_NUM, or PDO::FETCH_BOTH the returned value with be an array of arrays. For any other value it will be an array of objects. By default, the fetch mode set for the query will be used.
Returns
An associative array, or an empty array if there is no result set.

Implements DatabaseStatementInterface.

Definition at line 481 of file prefetch.inc.

References $currentRow, $defaultFetchOptions, $defaultFetchStyle, $row, current(), and next().

fetchAllKeyed | ( | $key_index = 0,
 |  | $value_index = 1
 | ) |

Returns the entire result set as a single associative array.

This method is only useful for two-column result sets. It will return an associative array where the key is one column from the result set and the value is another field. In most cases, the default of the first two columns is appropriate.

Note that this method will run the result set to the end.

Parameters
$key_index | The numeric index of the field to use as the array key.
$value_index | The numeric index of the field to use as the array value.
Returns
An associative array, or an empty array if there is no result set.

Implements DatabaseStatementInterface.

Definition at line 465 of file prefetch.inc.

References $value, and next().

fetchAssoc ( )

Fetches the next row and returns it as an object.

The object will be of the class specified by DatabaseStatementInterface::setFetchMode() or stdClass if not specified. Fetches the next row and returns it as an associative array.

This method corresponds to PDOStatement::fetchObject(), but for associative arrays. For some reason PDOStatement does not have a corresponding array helper method, so one is added.

Returns
An associative array, or FALSE if there is no next row.

Implements DatabaseStatementInterface.

Definition at line 414 of file prefetch.inc.

References $currentRow, and next().

fetchCol ( $index = 0 )

Returns an array containing all of the result set rows.

Parameters
$mode | One of the PDO::FETCH_* constants.
$column_index | If $mode is PDO::FETCH_COLUMN, the index of the column to fetch.
$constructor_arguments | If $mode is PDO::FETCH_CLASS, the arguments to pass to the constructor.
Returns
An array of results. Returns an entire single column of a result set as an indexed array.

Note that this method will run the result set to the end.

Parameters
$index The index of the column number to fetch.
Returns
An indexed array, or an empty array if there is no result set.

Implements DatabaseStatementInterface.

Definition at line 449 of file prefetch.inc.

References next().

fetchColumn ( $index = 0 )

Definition at line 373 of file prefetch.inc.

References next().

Referenced by fetchField().

fetchField ( $index = 0 )

Sets the default fetch mode for this statement.

See http://php.net/manual/pdo.constants.php for the definition of the constants used.

Parameters
$mode | One of the PDO::FETCH_* constants.
$a1 An option depending of the fetch mode specified by $mode:
  • for PDO::FETCH_COLUMN, the index of the column to fetch
  • for PDO::FETCH_CLASS, the name of the class to create
  • for PDO::FETCH_INTO, the object to add the data to
$a2 | If $mode is PDO::FETCH_CLASS, the optional arguments to pass to the constructor. Fetches the next row from a result set.

See http://php.net/manual/pdo.constants.php for the definition of the constants used.

Parameters
$mode | One of the PDO::FETCH_* constants. Default to what was specified by setFetchMode().
$cursor_orientation | Not implemented in all database drivers, don't use.
$cursor_offset | Not implemented in all database drivers, don't use.
Returns
A result, formatted according to $mode. Returns a single field from the next record of a result set.
Parameters
$index The numeric index of the field to return. Defaults to the first field.
Returns
A single field from the next record, or FALSE if there is no next record.

Implements DatabaseStatementInterface.

Definition at line 385 of file prefetch.inc.

References fetchColumn().

fetchObject | ( | $class_name = NULL,
 |  | $constructor_args = array()
 | ) |

Definition at line 389 of file prefetch.inc.

References $defaultFetchOptions, $defaultFetchStyle, current(), and next().

getQueryString ( )

Return the object's SQL query string.

Implements DatabaseStatementInterface.

Definition at line 232 of file prefetch.inc.

References $queryString.

getStatement | ( |  | $query,
 |  | & | $args = array()
 | ) |  |
protected

Grab a PDOStatement object from a given query and its arguments.

Some drivers (including SQLite) will need to perform some preparation themselves to get the statement right.

Parameters
$query | The query.
array | $args | An array of arguments.
Returns
PDOStatement A PDOStatement object.

Definition at line 225 of file prefetch.inc.

Referenced by execute().

key ( )

Definition at line 323 of file prefetch.inc.

References $currentKey.

Referenced by next().

next ( )

Definition at line 331 of file prefetch.inc.

References key().

Referenced by execute(), fetch(), fetchAll(), fetchAllAssoc(), fetchAllKeyed(), fetchAssoc(), fetchCol(), fetchColumn(), and fetchObject().

rewind ( )

Definition at line 327 of file prefetch.inc.

rowCount ( )

Returns the number of rows affected by the last SQL statement.

Returns
The number of rows affected by the last DELETE, INSERT, or UPDATE statement executed.

Implements DatabaseStatementInterface.

Definition at line 348 of file prefetch.inc.

References $rowCount.

Referenced by execute().

setFetchMode | ( | $fetchStyle,
 |  | $a2 = NULL,
 |  | $a3 = NULL
 | ) |
See Also
PDOStatement::setFetchMode()

Definition at line 239 of file prefetch.inc.

References $defaultFetchOptions, $defaultFetchStyle, and $fetchStyle.

Referenced by execute().

throwPDOException ( )
protected

Throw a PDO Exception based on the last PDO error.

Definition at line 204 of file prefetch.inc.

Referenced by execute().

valid ( )

Definition at line 342 of file prefetch.inc.

Member Data Documentation

$columnNames = NULL
protected

Definition at line 73 of file prefetch.inc.

$currentKey = NULL
protected

Definition at line 66 of file prefetch.inc.

Referenced by key().

$currentRow = NULL
protected

Definition at line 59 of file prefetch.inc.

Referenced by current(), DatabaseStatement_sqlite\execute(), fetchAllAssoc(), and fetchAssoc().

$data = array()
protected

Definition at line 52 of file prefetch.inc.

$dbh

Definition at line 45 of file prefetch.inc.

$defaultFetchOptions
protected
Initial value:
= array(
'class' => 'stdClass',
'constructor_args' => array(),
'object' => NULL,
'column' => 0,
)

Definition at line 121 of file prefetch.inc.

Referenced by fetch(), fetchAll(), fetchAllAssoc(), fetchObject(), and setFetchMode().

$defaultFetchStyle = PDO::FETCH_OBJ
protected

Definition at line 114 of file prefetch.inc.

Referenced by fetch(), fetchAll(), fetchAllAssoc(), fetchObject(), and setFetchMode().

$driverOptions
protected

Definition at line 36 of file prefetch.inc.

$fetchOptions
protected
Initial value:
= array(
'class' => 'stdClass',
'constructor_args' => array(),
'object' => NULL,
'column' => 0,
)

Definition at line 102 of file prefetch.inc.

$fetchStyle = PDO::FETCH_OBJ
protected

Definition at line 95 of file prefetch.inc.

Referenced by setFetchMode().

$queryString
protected

Definition at line 29 of file prefetch.inc.

Referenced by getQueryString().

$resultRowCount = 0
protected

Definition at line 87 of file prefetch.inc.

$rowCount = NULL
protected

Definition at line 80 of file prefetch.inc.

Referenced by rowCount().

interface QueryConditionInterface

Interface for a conditional clause in a query.

Definition at line 16 of file query.inc.

Inheritance diagram for QueryConditionInterface:
DatabaseCondition DeleteQuery MergeQuery SelectQueryInterface UpdateQuery DeleteQuery_sqlite SelectQuery SelectQueryExtender UpdateQuery_pgsql UpdateQuery_sqlite SelectQuery_pgsql SelectQuery_sqlite PagerDefault SearchQuery TableSort

Public Member Functions

condition ($field, $value=NULL, $operator=NULL)
where ($snippet, $args=array())
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
& conditions ()
arguments ()
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()

Member Function Documentation

arguments ( )

Gets a complete list of all values to insert into the prepared statement.

Returns
An associative array of placeholders and values.

Implemented in DatabaseCondition, MergeQuery, UpdateQuery, SelectQuery, DeleteQuery, and SelectQueryExtender.

compile | ( | DatabaseConnection | $connection,
 |  | QueryPlaceholderInterface | $queryPlaceholder
 | ) |  |

Compiles the saved conditions for later retrieval.

This method does not return anything, but simply prepares data to be retrieved via __toString() and arguments().

Parameters
$connection | The database connection for which to compile the conditionals.
$queryPlaceholder | The query this condition belongs to. If not given, the current query is used.

Implemented in DatabaseCondition, MergeQuery, UpdateQuery, SelectQuery, DeleteQuery, and SelectQueryExtender.

compiled ( )

Check whether a condition has been previously compiled.

Returns
TRUE if the condition has been previously compiled.

Implemented in DatabaseCondition, MergeQuery, UpdateQuery, SelectQuery, DeleteQuery, and SelectQueryExtender.

condition | ( | $field,
 |  | $value = NULL,
 |  | $operator = NULL
 | ) |

Helper function: builds the most common conditional clauses.

This method can take a variable number of parameters. If called with two parameters, they are taken as $field and $value with $operator having a value of IN if $value is an array and = otherwise.

Do not use this method to test for NULL values. Instead, use QueryConditionInterface::isNull() or QueryConditionInterface::isNotNull().

Parameters
$field | The name of the field to check. If you would like to add a more complex condition involving operators or functions, use where().
$value | The value to test the field against. In most cases, this is a scalar. For more complex options, it is an array. The meaning of each element in the array is dependent on the $operator.
$operator | The comparison operator, such as =, <, or >=. It also accepts more complex options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array, and = otherwise.
Returns
QueryConditionInterface The called object.
See Also
QueryConditionInterface::isNull()
QueryConditionInterface::isNotNull()

Implemented in DatabaseCondition, MergeQuery, UpdateQuery, SelectQuery, DeleteQuery, and SelectQueryExtender.

Referenced by node_build_filter_query().

& conditions ( )

Gets a complete list of all conditions in this conditional clause.

This method returns by reference. That allows alter hooks to access the data structure directly and manipulate it before it gets compiled.

The data structure that is returned is an indexed array of entries, where each entry looks like the following:

* array(
* 'field' => $field,
* 'value' => $value,
* 'operator' => $operator,
* );
*

In the special case that $operator is NULL, the $field is taken as a raw SQL snippet (possibly containing a function) and $value is an associative array of placeholders for the snippet.

There will also be a single array entry of #conjunction, which is the conjunction that will be applied to the array, such as AND.

Implemented in DatabaseCondition, MergeQuery, UpdateQuery, SelectQuery, DeleteQuery, and SelectQueryExtender.

exists ( SelectQueryInterface $select )

Sets a condition that the specified subquery returns values.

Parameters
SelectQueryInterface $select The subquery that must contain results.
Returns
QueryConditionInterface The called object.

Implemented in DatabaseCondition, MergeQuery, SelectQuery, UpdateQuery, SelectQueryExtender, and DeleteQuery.

isNotNull ( $field )

Sets a condition that the specified field be NOT NULL.

Parameters
$field The name of the field to check.
Returns
QueryConditionInterface The called object.

Implemented in DatabaseCondition, MergeQuery, SelectQuery, UpdateQuery, SelectQueryExtender, and DeleteQuery.

isNull ( $field )

Sets a condition that the specified field be NULL.

Parameters
$field The name of the field to check.
Returns
QueryConditionInterface The called object.

Implemented in DatabaseCondition, MergeQuery, SelectQuery, UpdateQuery, SelectQueryExtender, and DeleteQuery.

notExists ( SelectQueryInterface $select )

Sets a condition that the specified subquery returns no values.

Parameters
SelectQueryInterface $select The subquery that must not contain results.
Returns
QueryConditionInterface The called object.

Implemented in DatabaseCondition, MergeQuery, SelectQuery, UpdateQuery, SelectQueryExtender, and DeleteQuery.

where | ( | $snippet,
 |  | $args = array()
 | ) |

Adds an arbitrary WHERE clause to the query.

Parameters
$snippet | A portion of a WHERE clause as a prepared statement. It must use named placeholders, not ? placeholders.
$args | An associative array of arguments.
Returns
QueryConditionInterface The called object.

Implemented in DatabaseCondition, MergeQuery, UpdateQuery, SelectQuery, DeleteQuery, and SelectQueryExtender.

interface QueryAlterableInterface

Interface for a query that can be manipulated via an alter hook.

Definition at line 166 of file query.inc.

Inheritance diagram for QueryAlterableInterface:
SelectQueryInterface SelectQuery SelectQueryExtender SelectQuery_pgsql SelectQuery_sqlite PagerDefault SearchQuery TableSort

Public Member Functions

addTag ($tag)
hasTag ($tag)
hasAllTags ()
hasAnyTag ()
addMetaData ($key, $object)
getMetaData ($key)

Member Function Documentation

addMetaData | ( | $key,
 |  | $object
 | ) |

Adds additional metadata to the query.

Often, a query may need to provide additional contextual data to alter hooks. Alter hooks may then use that information to decide if and how to take action.

Parameters
$key | The unique identifier for this piece of metadata. Must be a string that follows the same rules as any other PHP identifier.
$object | The additional data to add to the query. May be any valid PHP variable.
Returns
QueryAlterableInterface The called object.

Implemented in SelectQuery, and SelectQueryExtender.

addTag ( $tag )

Adds a tag to a query.

Tags are strings that identify a query. A query may have any number of tags. Tags are used to mark a query so that alter hooks may decide if they wish to take action. Tags should be all lower-case and contain only letters, numbers, and underscore, and start with a letter. That is, they should follow the same rules as PHP identifiers in general.

Parameters
$tag The tag to add.
Returns
QueryAlterableInterface The called object.

Implemented in SelectQuery, and SelectQueryExtender.

getMetaData ( $key )

Retrieves a given piece of metadata.

Parameters
$key The unique identifier for the piece of metadata to retrieve.
Returns
The previously attached metadata object, or NULL if one doesn't exist.

Implemented in SelectQuery, and SelectQueryExtender.

Referenced by hook_query_TAG_alter().

hasAllTags ( )

Determines if a given query has all specified tags.

Parameters
$tags A variable number of arguments, one for each tag to check.
Returns
TRUE if this query has been marked with all specified tags, FALSE otherwise.

Implemented in SelectQuery, and SelectQueryExtender.

hasAnyTag ( )

Determines if a given query has any specified tag.

Parameters
$tags A variable number of arguments, one for each tag to check.
Returns
TRUE if this query has been marked with at least one of the specified tags, FALSE otherwise.

Implemented in SelectQuery, and SelectQueryExtender.

hasTag ( $tag )

Determines if a given query has a given tag.

Parameters
$tag The tag to check.
Returns
TRUE if this query has been marked with this tag, FALSE otherwise.

Implemented in SelectQuery, and SelectQueryExtender.

Referenced by hook_query_alter().

interface QueryPlaceholderInterface

Interface for a query that accepts placeholders.

Definition at line 253 of file query.inc.

Inheritance diagram for QueryPlaceholderInterface:
DatabaseSchema Query SelectQueryInterface DatabaseSchema_mysql DatabaseSchema_pgsql DatabaseSchema_sqlite DeleteQuery InsertQuery MergeQuery SelectQuery TruncateQuery UpdateQuery SelectQuery SelectQueryExtender

Public Member Functions

uniqueIdentifier ()
nextPlaceholder ()

Member Function Documentation

nextPlaceholder ( )

Returns the next placeholder ID for the query.

Returns
The next available placeholder ID as an integer.

Implemented in SelectQueryExtender, Query, and DatabaseSchema.

Referenced by DatabaseCondition\compile().

uniqueIdentifier ( )

Returns a unique identifier for this object.

Implemented in SelectQueryExtender, Query, and DatabaseSchema.

Referenced by DatabaseCondition\compile().

class Query

Base class for query builders.

Note that query builders use PHP's magic __toString() method to compile the query object into a prepared statement.

Definition at line 275 of file query.inc.

Inheritance diagram for Query:
QueryPlaceholderInterface DeleteQuery InsertQuery MergeQuery SelectQuery TruncateQuery UpdateQuery DeleteQuery_sqlite InsertQuery_mysql InsertQuery_pgsql InsertQuery_sqlite SelectQuery_pgsql SelectQuery_sqlite TruncateQuery_mysql TruncateQuery_sqlite UpdateQuery_pgsql UpdateQuery_sqlite

Public Member Functions

__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Protected Member Functions

execute ()

Protected Attributes

$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Constructor & Destructor Documentation

__construct | ( | DatabaseConnection | $connection,
 |  |  | $options
 | ) |  |

Constructs a Query object.

Parameters
DatabaseConnection | $connection | Database connection object.
array | $options | Array of query options.

Definition at line 330 of file query.inc.

References $connection, and uniqueIdentifier().

Member Function Documentation

__clone ( )

Implements the magic __clone function.

Definition at line 359 of file query.inc.

References uniqueIdentifier().

__sleep ( )

Implements the magic __sleep function to disconnect from the database.

Definition at line 343 of file query.inc.

__toString ( )
abstract

Implements PHP magic __toString method to convert the query to a string.

The toString operation is how we compile a query object to a prepared statement.

Returns
A prepared statement query string for this object.
__wakeup ( )

Implements the magic __wakeup function to reconnect to the database.

Definition at line 352 of file query.inc.

References Database\getConnection().

comment ( $comment )

Adds a comment to the query.

By adding a comment to a query, you can more easily find it in your query log or the list of active queries on an SQL server. This allows for easier debugging and allows you to more easily find where a query with a performance problem is being generated.

The comment string will be sanitized to remove * / and other characters that may terminate the string early so as to avoid SQL injection attacks.

Parameters
$comment The comment string to be inserted into the query.
Returns
Query The called object.

Definition at line 413 of file query.inc.

execute ( )
abstractprotected

Runs the query against the database.

& getComments ( )

Returns a reference to the comments array for the query.

Because this method returns by reference, alter hooks may edit the comments array directly to make their changes. If just adding comments, however, the use of comment() is preferred.

Note that this method must be called by reference as well:

* $comments =& $query->getComments();
*
Returns
A reference to the comments array structure.

Definition at line 433 of file query.inc.

References $comments.

nextPlaceholder ( )

Gets the next placeholder value for this query object.

Returns
int Next placeholder value.

Implements QueryPlaceholderInterface.

Definition at line 392 of file query.inc.

uniqueIdentifier ( )

Returns a unique identifier for this object.

Implements QueryPlaceholderInterface.

Definition at line 382 of file query.inc.

References $uniqueIdentifier.

Referenced by __clone(), and __construct().

Member Data Documentation

$comments = array()
protected

Definition at line 320 of file query.inc.

Referenced by InsertQuery_sqlite\__toString(), InsertQuery_mysql\__toString(), InsertQuery_pgsql\__toString(), TruncateQuery_sqlite\__toString(), InsertQuery\__toString(), DeleteQuery\__toString(), TruncateQuery\__toString(), UpdateQuery\__toString(), SelectQuery\__toString(), and getComments().

$connection
protected

Definition at line 282 of file query.inc.

Referenced by __construct(), and InsertQuery\__construct().

$connectionKey
protected

Definition at line 296 of file query.inc.

$connectionTarget
protected

Definition at line 289 of file query.inc.

$nextPlaceholder = 0
protected

The placeholder counter.

Definition at line 313 of file query.inc.

$queryOptions
protected

Definition at line 303 of file query.inc.

Referenced by InsertQuery_pgsql\execute(), UpdateQuery_pgsql\execute(), and InsertQuery\execute().

$uniqueIdentifier
protected

A unique identifier for this query object.

Definition at line 308 of file query.inc.

Referenced by uniqueIdentifier().

class InsertQuery

General class for an abstracted INSERT query.

Definition at line 441 of file query.inc.

Inheritance diagram for InsertQuery:
Query QueryPlaceholderInterface InsertQuery_mysql InsertQuery_pgsql InsertQuery_sqlite

Public Member Functions

__construct ($connection, $table, array $options=array())
fields (array $fields, array $values=array())
values (array $values)
useDefaults (array $fields)
from (SelectQueryInterface $query)
execute ()
__toString ()
preExecute ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Protected Attributes

$table
$insertFields = array()
$defaultFields = array()
$insertValues = array()
$fromQuery
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Additional Inherited Members

- Protected Member Functions inherited from Query
execute ()

Constructor & Destructor Documentation

__construct | ( |  | $connection,
 |  |  | $table,
 |  | array | $options = array()
 | ) |  |

Constructs an InsertQuery object.

Parameters
DatabaseConnection | $connection | A DatabaseConnection object.
string | $table | Name of the table to associate with this query.
array | $options | Array of database options.

Definition at line 498 of file query.inc.

References Query\$connection, $table, and Database\RETURN_INSERT_ID.

Member Function Documentation

__toString ( )

Implements PHP magic __toString method to convert the query to a string.

Returns
string The prepared statement.

Definition at line 668 of file query.inc.

References Query\$comments, and $fromQuery.

execute ( )

Executes the insert query.

Returns
The last insert ID of the query, if one exists. If the query was given multiple sets of values to insert, the return value is undefined. If no fields are specified, this method will do nothing and return NULL. That makes it safe to use in multi-insert loops.

Definition at line 619 of file query.inc.

References Query\$queryOptions, and preExecute().

fields | ( | array | $fields,
 |  | array | $values = array()
 | ) |  |

Adds a set of field->value pairs to be inserted.

This method may only be called once. Calling it a second time will be ignored. To queue up multiple sets of values to be inserted at once, use the values() method.

Parameters
$fields | An array of fields on which to insert. This array may be indexed or associative. If indexed, the array is taken to be the list of fields. If associative, the keys of the array are taken to be the fields and the values are taken to be corresponding values to insert. If a $values argument is provided, $fields must be indexed.
$values | An array of fields to insert into the database. The values must be specified in the same order as the $fields array.
Returns
InsertQuery The called object.

Definition at line 526 of file query.inc.

Referenced by preExecute().

from ( SelectQueryInterface $query )

Sets the fromQuery on this InsertQuery object.

Parameters
SelectQueryInterface $query The query to fetch the rows that should be inserted.
Returns
InsertQuery The called object.

Definition at line 605 of file query.inc.

preExecute ( )

Preprocesses and validates the query.

Returns
TRUE if the validation was successful, FALSE if not.
Exceptions
FieldsOverlapException
NoFieldsException

Definition at line 698 of file query.inc.

References fields().

Referenced by InsertQuery_mysql\execute(), InsertQuery_pgsql\execute(), InsertQuery_sqlite\execute(), and execute().

useDefaults ( array $fields )

Specifies fields for which the database defaults should be used.

If you want to force a given field to use the database-defined default, not NULL or undefined, use this method to instruct the database to use default values explicitly. In most cases this will not be necessary unless you are inserting a row that is all default values, as you cannot specify no values in an INSERT query.

Specifying a field both in fields() and in useDefaults() is an error and will not execute.

Parameters
$fields An array of values for which to use the default values specified in the table definition.
Returns
InsertQuery The called object.

Definition at line 591 of file query.inc.

values ( array $values )

Adds another set of values to the query to be inserted.

If $values is a numeric-keyed array, it will be assumed to be in the same order as the original fields() call. If it is associative, it may be in any order as long as the keys of the array match the names of the fields.

Parameters
$values An array of values to add to the query.
Returns
InsertQuery The called object.

Definition at line 557 of file query.inc.

Member Data Documentation

$defaultFields = array()
protected

Definition at line 462 of file query.inc.

$fromQuery
protected

Definition at line 486 of file query.inc.

Referenced by InsertQuery_sqlite\__toString(), InsertQuery_mysql\__toString(), InsertQuery_pgsql\__toString(), and __toString().

$insertFields = array()
protected

Definition at line 455 of file query.inc.

$insertValues = array()
protected

Definition at line 479 of file query.inc.

$table
protected

Definition at line 448 of file query.inc.

Referenced by __construct().

class DeleteQuery

General class for an abstracted DELETE operation.

Definition at line 733 of file query.inc.

Inheritance diagram for DeleteQuery:
Query QueryConditionInterface QueryPlaceholderInterface DeleteQuery_sqlite

Public Member Functions

__construct (DatabaseConnection $connection, $table, array $options=array())
condition ($field, $value=NULL, $operator=NULL)
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
& conditions ()
arguments ()
where ($snippet, $args=array())
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
execute ()
__toString ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Protected Attributes

$table
$condition
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Additional Inherited Members

- Protected Member Functions inherited from Query
execute ()

Constructor & Destructor Documentation

__construct | ( | DatabaseConnection | $connection,
 |  |  | $table,
 |  | array | $options = array()
 | ) |  |

Constructs a DeleteQuery object.

Parameters
DatabaseConnection | $connection | A DatabaseConnection object.
string | $table | Name of the table to associate with this query.
array | $options | Array of database options.

Definition at line 761 of file query.inc.

References $table, condition(), and Database\RETURN_AFFECTED.

Member Function Documentation

__toString ( )

Implements PHP magic __toString method to convert the query to a string.

Returns
string The prepared statement.

Definition at line 867 of file query.inc.

References Query\$comments, $condition, and condition().

arguments ( )

Implements QueryConditionInterface::arguments().

Implements QueryConditionInterface.

Definition at line 819 of file query.inc.

References condition().

compile | ( | DatabaseConnection | $connection,
 |  | QueryPlaceholderInterface | $queryPlaceholder
 | ) |  |

Implements QueryConditionInterface::compile().

Implements QueryConditionInterface.

Definition at line 834 of file query.inc.

References condition().

compiled ( )

Implements QueryConditionInterface::compiled().

Implements QueryConditionInterface.

Definition at line 841 of file query.inc.

References condition().

condition | ( | $field,
 |  | $value = NULL,
 |  | $operator = NULL
 | ) |

Implements QueryConditionInterface::condition().

Implements QueryConditionInterface.

Definition at line 772 of file query.inc.

References $value.

Referenced by __construct(), __toString(), arguments(), compile(), compiled(), conditions(), DeleteQuery_sqlite\execute(), execute(), exists(), isNotNull(), isNull(), notExists(), and where().

& conditions ( )

Implements QueryConditionInterface::conditions().

Implements QueryConditionInterface.

Definition at line 812 of file query.inc.

References condition().

execute ( )

Executes the DELETE query.

Returns
The return value is dependent on the database connection.

Definition at line 851 of file query.inc.

References condition().

exists ( SelectQueryInterface $select )

Implements QueryConditionInterface::exists().

Implements QueryConditionInterface.

Definition at line 796 of file query.inc.

References condition().

isNotNull ( $field )

Implements QueryConditionInterface::isNotNull().

Implements QueryConditionInterface.

Definition at line 788 of file query.inc.

References condition().

isNull ( $field )

Implements QueryConditionInterface::isNull().

Implements QueryConditionInterface.

Definition at line 780 of file query.inc.

References condition().

notExists ( SelectQueryInterface $select )

Implements QueryConditionInterface::notExists().

Implements QueryConditionInterface.

Definition at line 804 of file query.inc.

References condition().

where | ( | $snippet,
 |  | $args = array()
 | ) |

Implements QueryConditionInterface::where().

Implements QueryConditionInterface.

Definition at line 826 of file query.inc.

References $snippet, and condition().

Member Data Documentation

$condition
protected

Definition at line 749 of file query.inc.

Referenced by __toString().

$table
protected

Definition at line 740 of file query.inc.

Referenced by __construct().

class TruncateQuery

General class for an abstracted TRUNCATE operation.

Definition at line 887 of file query.inc.

Inheritance diagram for TruncateQuery:
Query QueryPlaceholderInterface TruncateQuery_mysql TruncateQuery_sqlite

Public Member Functions

__construct (DatabaseConnection $connection, $table, array $options=array())
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
execute ()
__toString ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Protected Attributes

$table
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Additional Inherited Members

- Protected Member Functions inherited from Query
execute ()

Constructor & Destructor Documentation

__construct | ( | DatabaseConnection | $connection,
 |  |  | $table,
 |  | array | $options = array()
 | ) |  |

Constructs a TruncateQuery object.

Parameters
DatabaseConnection | $connection | A DatabaseConnection object.
string | $table | Name of the table to associate with this query.
array | $options | Array of database options.

Definition at line 906 of file query.inc.

References $table, and Database\RETURN_AFFECTED.

Member Function Documentation

__toString ( )

Implements PHP magic __toString method to convert the query to a string.

Returns
string The prepared statement.

Definition at line 942 of file query.inc.

References Query\$comments.

compile | ( | DatabaseConnection | $connection,
 |  | QueryPlaceholderInterface | $queryPlaceholder
 | ) |  |

Implements QueryConditionInterface::compile().

Definition at line 915 of file query.inc.

compiled ( )

Implements QueryConditionInterface::compiled().

Definition at line 922 of file query.inc.

execute ( )

Executes the TRUNCATE query.

Returns
Return value is dependent on the database type.

Definition at line 932 of file query.inc.

Member Data Documentation

$table
protected

Definition at line 894 of file query.inc.

Referenced by __construct().

class UpdateQuery

General class for an abstracted UPDATE operation.

Definition at line 963 of file query.inc.

Inheritance diagram for UpdateQuery:
Query QueryConditionInterface QueryPlaceholderInterface UpdateQuery_pgsql UpdateQuery_sqlite

Public Member Functions

__construct (DatabaseConnection $connection, $table, array $options=array())
condition ($field, $value=NULL, $operator=NULL)
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
& conditions ()
arguments ()
where ($snippet, $args=array())
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
fields (array $fields)
expression ($field, $expression, array $arguments=NULL)
execute ()
__toString ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Protected Attributes

$table
$fields = array()
$arguments = array()
$condition
$expressionFields = array()
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Additional Inherited Members

- Protected Member Functions inherited from Query
execute ()

Constructor & Destructor Documentation

__construct | ( | DatabaseConnection | $connection,
 |  |  | $table,
 |  | array | $options = array()
 | ) |  |

Constructs an UpdateQuery object.

Parameters
DatabaseConnection | $connection | A DatabaseConnection object.
string | $table | Name of the table to associate with this query.
array | $options | Array of database options.

Definition at line 1020 of file query.inc.

References $table, condition(), and Database\RETURN_AFFECTED.

Member Function Documentation

__toString ( )

Implements PHP magic __toString method to convert the query to a string.

Returns
string The prepared statement.

Definition at line 1186 of file query.inc.

References Query\$comments, $condition, $fields, $value, and condition().

arguments ( )

Implements QueryConditionInterface::arguments().

Implements QueryConditionInterface.

Definition at line 1078 of file query.inc.

References condition().

compile | ( | DatabaseConnection | $connection,
 |  | QueryPlaceholderInterface | $queryPlaceholder
 | ) |  |

Implements QueryConditionInterface::compile().

Implements QueryConditionInterface.

Definition at line 1093 of file query.inc.

References condition().

compiled ( )

Implements QueryConditionInterface::compiled().

Implements QueryConditionInterface.

Definition at line 1100 of file query.inc.

References condition().

condition | ( | $field,
 |  | $value = NULL,
 |  | $operator = NULL
 | ) |

Implements QueryConditionInterface::condition().

Implements QueryConditionInterface.

Definition at line 1031 of file query.inc.

References $value.

Referenced by __construct(), __toString(), arguments(), compile(), compiled(), conditions(), UpdateQuery_sqlite\execute(), UpdateQuery_pgsql\execute(), execute(), exists(), isNotNull(), isNull(), notExists(), and where().

& conditions ( )

Implements QueryConditionInterface::conditions().

Implements QueryConditionInterface.

Definition at line 1071 of file query.inc.

References condition().

execute ( )

Executes the UPDATE query.

Returns
The number of rows affected by the update.

Definition at line 1152 of file query.inc.

References $fields, $value, and condition().

exists ( SelectQueryInterface $select )

Implements QueryConditionInterface::exists().

Implements QueryConditionInterface.

Definition at line 1055 of file query.inc.

References condition().

expression | ( |  | $field,
 |  |  | $expression,
 |  | array | $arguments = NULL
 | ) |  |

Specifies fields to be updated as an expression.

Expression fields are cases such as counter=counter+1. This method takes precedence over fields().

Parameters
$field | The field to set.
$expression | The field will be set to the value of this expression. This parameter may include named placeholders.
$arguments | If specified, this is an array of key/value pairs for named placeholders corresponding to the expression.
Returns
UpdateQuery The called object.

Definition at line 1137 of file query.inc.

References $arguments.

fields ( array $fields )

Adds a set of field->value pairs to be updated.

Parameters
$fields An associative array of fields to write into the database. The array keys are the field names and the values are the values to which to set them.
Returns
UpdateQuery The called object.

Definition at line 1114 of file query.inc.

References $fields.

isNotNull ( $field )

Implements QueryConditionInterface::isNotNull().

Implements QueryConditionInterface.

Definition at line 1047 of file query.inc.

References condition().

isNull ( $field )

Implements QueryConditionInterface::isNull().

Implements QueryConditionInterface.

Definition at line 1039 of file query.inc.

References condition().

notExists ( SelectQueryInterface $select )

Implements QueryConditionInterface::notExists().

Implements QueryConditionInterface.

Definition at line 1063 of file query.inc.

References condition().

where | ( | $snippet,
 |  | $args = array()
 | ) |

Implements QueryConditionInterface::where().

Implements QueryConditionInterface.

Definition at line 1085 of file query.inc.

References $snippet, and condition().

Member Data Documentation

$arguments = array()
protected

Definition at line 984 of file query.inc.

Referenced by UpdateQuery_pgsql\execute(), and expression().

$condition
protected

Definition at line 993 of file query.inc.

Referenced by __toString(), and UpdateQuery_sqlite\execute().

$expressionFields = array()
protected

Definition at line 1008 of file query.inc.

$fields = array()
protected

Definition at line 977 of file query.inc.

Referenced by __toString(), UpdateQuery_sqlite\execute(), UpdateQuery_pgsql\execute(), execute(), and fields().

$table
protected

Definition at line 970 of file query.inc.

Referenced by __construct().

class MergeQuery

General class for an abstracted MERGE query operation.

An ANSI SQL:2003 compatible database would run the following query:

* MERGE INTO table_name_1 USING table_name_2 ON (condition)
* WHEN MATCHED THEN
* UPDATE SET column1 = value1 [, column2 = value2 ...]
* WHEN NOT MATCHED THEN
* INSERT (column1 [, column2 ...]) VALUES (value1 [, value2 ...
*

Other databases (most notably MySQL, PostgreSQL and SQLite) will emulate this statement by running a SELECT and then INSERT or UPDATE.

By default, the two table names are identical and they are passed into the the constructor. table_name_2 can be specified by the MergeQuery::conditionTable() method. It can be either a string or a subquery.

The condition is built exactly like SelectQuery or UpdateQuery conditions, the UPDATE query part is built similarly like an UpdateQuery and finally the INSERT query part is built similarly like an InsertQuery. However, both UpdateQuery and InsertQuery has a fields method so MergeQuery::updateFields() and MergeQuery::insertFields() needs to be called instead. MergeQuery::fields() can also be called which calls both of these methods as the common case is to use the same column-value pairs for both INSERT and UPDATE. However, this is not mandatory. Another convinient wrapper is MergeQuery::key() which adds the same column-value pairs to the condition and the INSERT query part.

Several methods (key(), fields(), insertFields()) can be called to set a key-value pair for the INSERT query part. Subsequent calls for the same fields override the earlier ones. The same is true for UPDATE and key(), fields() and updateFields().

Definition at line 1254 of file query.inc.

Inheritance diagram for MergeQuery:
Query QueryConditionInterface QueryPlaceholderInterface

Public Member Functions

__construct (DatabaseConnection $connection, $table, array $options=array())
updateFields (array $fields)
expression ($field, $expression, array $arguments=NULL)
insertFields (array $fields, array $values=array())
useDefaults (array $fields)
fields (array $fields, array $values=array())
key (array $fields, array $values=array())
condition ($field, $value=NULL, $operator=NULL)
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
& conditions ()
arguments ()
where ($snippet, $args=array())
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
__toString ()
execute ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Public Attributes

const | STATUS_INSERT = 1
const | STATUS_UPDATE = 2

Protected Member Functions

conditionTable ($table)
- Protected Member Functions inherited from Query
execute ()

Protected Attributes

$table
$conditionTable
$insertFields = array()
$defaultFields = array()
$insertValues = array()
$updateFields = array()
$expressionFields = array()
$needsUpdate = FALSE
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Constructor & Destructor Documentation

__construct | ( | DatabaseConnection | $connection,
 |  |  | $table,
 |  | array | $options = array()
 | ) |  |

Constructs a MergeQuery object.

Parameters
DatabaseConnection | $connection | A DatabaseConnection object.
string | $table | Name of the table to associate with this query.
array | $options | Array of database options.

Definition at line 1339 of file query.inc.

References $table, condition(), conditionTable(), and Database\RETURN_AFFECTED.

Member Function Documentation

__toString ( )

Implements PHP magic __toString method to convert the query to a string.

In the degenerate case, there is no string-able query as this operation is potentially two queries.

Returns
string The prepared query statement.

Definition at line 1605 of file query.inc.

arguments ( )

Implements QueryConditionInterface::arguments().

Implements QueryConditionInterface.

Definition at line 1570 of file query.inc.

References condition().

compile | ( | DatabaseConnection | $connection,
 |  | QueryPlaceholderInterface | $queryPlaceholder
 | ) |  |

Implements QueryConditionInterface::compile().

Implements QueryConditionInterface.

Definition at line 1585 of file query.inc.

References condition().

compiled ( )

Implements QueryConditionInterface::compiled().

Implements QueryConditionInterface.

Definition at line 1592 of file query.inc.

References condition().

condition | ( | $field,
 |  | $value = NULL,
 |  | $operator = NULL
 | ) |

Implements QueryConditionInterface::condition().

Implements QueryConditionInterface.

Definition at line 1523 of file query.inc.

References $value.

Referenced by __construct(), arguments(), compile(), compiled(), conditions(), execute(), exists(), isNotNull(), isNull(), key(), notExists(), and where().

& conditions ( )

Implements QueryConditionInterface::conditions().

Implements QueryConditionInterface.

Definition at line 1563 of file query.inc.

References condition().

conditionTable ( $table )
protected

Sets the table or subquery to be used for the condition.

Parameters
$table The table name or the subquery to be used. Use a SelectQuery object to pass in a subquery.
Returns
MergeQuery The called object.

Definition at line 1357 of file query.inc.

References $table.

Referenced by __construct(), and execute().

execute ( )

Definition at line 1608 of file query.inc.

References condition(), conditionTable(), insertFields(), t(), and updateFields().

exists ( SelectQueryInterface $select )

Implements QueryConditionInterface::exists().

Implements QueryConditionInterface.

Definition at line 1547 of file query.inc.

References condition().

expression | ( |  | $field,
 |  |  | $expression,
 |  | array | $arguments = NULL
 | ) |  |

Specifies fields to be updated as an expression.

Expression fields are cases such as counter = counter + 1. This method takes precedence over MergeQuery::updateFields() and it's wrappers, MergeQuery::key() and MergeQuery::fields().

Parameters
$field | The field to set.
$expression | The field will be set to the value of this expression. This parameter may include named placeholders.
$arguments | If specified, this is an array of key/value pairs for named placeholders corresponding to the expression.
Returns
MergeQuery The called object.

Definition at line 1397 of file query.inc.

fields | ( | array | $fields,
 |  | array | $values = array()
 | ) |  |

Sets common field-value pairs in the INSERT and UPDATE query parts.

This method should only be called once. It may be called either with a single associative array or two indexed arrays. If called with an associative array, the keys are taken to be the fields and the values are taken to be the corresponding values to set. If called with two arrays, the first array is taken as the fields and the second array is taken as the corresponding values.

Parameters
$fields | An array of fields to insert, or an associative array of fields and values. The keys of the array are taken to be the fields and the values are taken to be corresponding values to insert.
$values | An array of values to set into the database. The values must be specified in the same order as the $fields array.
Returns
MergeQuery The called object.

Definition at line 1475 of file query.inc.

References $value, insertFields(), and updateFields().

insertFields | ( | array | $fields,
 |  | array | $values = array()
 | ) |  |

Adds a set of field->value pairs to be inserted.

Parameters
$fields | An array of fields on which to insert. This array may be indexed or associative. If indexed, the array is taken to be the list of fields. If associative, the keys of the array are taken to be the fields and the values are taken to be corresponding values to insert. If a $values argument is provided, $fields must be indexed.
$values | An array of fields to insert into the database. The values must be specified in the same order as the $fields array.
Returns
MergeQuery The called object.

Definition at line 1422 of file query.inc.

Referenced by execute(), fields(), and key().

isNotNull ( $field )

Implements QueryConditionInterface::isNotNull().

Implements QueryConditionInterface.

Definition at line 1539 of file query.inc.

References condition().

isNull ( $field )

Implements QueryConditionInterface::isNull().

Implements QueryConditionInterface.

Definition at line 1531 of file query.inc.

References condition().

key | ( | array | $fields,
 |  | array | $values = array()
 | ) |  |

Sets the key field(s) to be used as conditions for this query.

This method should only be called once. It may be called either with a single associative array or two indexed arrays. If called with an associative array, the keys are taken to be the fields and the values are taken to be the corresponding values to set. If called with two arrays, the first array is taken as the fields and the second array is taken as the corresponding values.

The fields are copied to the condition of the query and the INSERT part. If no other method is called, the UPDATE will become a no-op.

Parameters
$fields | An array of fields to set, or an associative array of fields and values.
$values | An array of values to set into the database. The values must be specified in the same order as the $fields array.
Returns
MergeQuery The called object.

Definition at line 1509 of file query.inc.

References $value, condition(), and insertFields().

notExists ( SelectQueryInterface $select )

Implements QueryConditionInterface::notExists().

Implements QueryConditionInterface.

Definition at line 1555 of file query.inc.

References condition().

updateFields ( array $fields )

Adds a set of field->value pairs to be updated.

Parameters
$fields An associative array of fields to write into the database. The array keys are the field names and the values are the values to which to set them.
Returns
MergeQuery The called object.

Definition at line 1372 of file query.inc.

Referenced by execute(), and fields().

useDefaults ( array $fields )

Specifies fields for which the database-defaults should be used.

If you want to force a given field to use the database-defined default, not NULL or undefined, use this method to instruct the database to use default values explicitly. In most cases this will not be necessary unless you are inserting a row that is all default values, as you cannot specify no values in an INSERT query.

Specifying a field both in fields() and in useDefaults() is an error and will not execute.

Parameters
$fields An array of values for which to use the default values specified in the table definition.
Returns
MergeQuery The called object.

Definition at line 1449 of file query.inc.

where | ( | $snippet,
 |  | $args = array()
 | ) |

Implements QueryConditionInterface::where().

Implements QueryConditionInterface.

Definition at line 1577 of file query.inc.

References $snippet, and condition().

Member Data Documentation

$conditionTable
protected

The table or subquery to be used for the condition.

Definition at line 1275 of file query.inc.

$defaultFields = array()
protected

Definition at line 1291 of file query.inc.

$expressionFields = array()
protected

Definition at line 1320 of file query.inc.

$insertFields = array()
protected

Definition at line 1282 of file query.inc.

$insertValues = array()
protected

Definition at line 1298 of file query.inc.

$needsUpdate = FALSE
protected

Definition at line 1327 of file query.inc.

$table
protected

Definition at line 1270 of file query.inc.

Referenced by __construct(), and conditionTable().

$updateFields = array()
protected

Definition at line 1305 of file query.inc.

const STATUS_INSERT = 1

Returned by execute() if an INSERT query has been executed.

Definition at line 1258 of file query.inc.

const STATUS_UPDATE = 2

Returned by execute() if an UPDATE query has been executed.

Definition at line 1263 of file query.inc.

class DatabaseCondition

Generic class for a series of conditions in a query.

Definition at line 1652 of file query.inc.

Inheritance diagram for DatabaseCondition:
QueryConditionInterface

Public Member Functions

__construct ($conjunction)
count ()
condition ($field, $value=NULL, $operator=NULL)
where ($snippet, $args=array())
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
& conditions ()
arguments ()
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
__toString ()
__clone ()

Protected Member Functions

mapConditionOperator ($operator)

Protected Attributes

$conditions = array()
$arguments = array()
$changed = TRUE
$queryPlaceholderIdentifier

Constructor & Destructor Documentation

__construct ( $conjunction )

Constructs a DataBaseCondition object.

Parameters
string $conjunction The operator to use to combine conditions: 'AND' or 'OR'.

Definition at line 1689 of file query.inc.

References conditions().

Member Function Documentation

__clone ( )

PHP magic __clone() method.

Only copies fields that implement QueryConditionInterface. Also sets $this->changed to TRUE.

Definition at line 1897 of file query.inc.

References conditions().

__toString ( )

Implements PHP magic __toString method to convert the conditions to string.

Returns
string A string version of the conditions.

Definition at line 1883 of file query.inc.

arguments ( )

Implements QueryConditionInterface::arguments().

Implements QueryConditionInterface.

Definition at line 1782 of file query.inc.

References $arguments.

Referenced by compile().

compile | ( | DatabaseConnection | $connection,
 |  | QueryPlaceholderInterface | $queryPlaceholder
 | ) |  |

Implements QueryConditionInterface::compile().

Implements QueryConditionInterface.

Definition at line 1793 of file query.inc.

References $arguments, $conditions, $value, arguments(), DatabaseConnection\escapeField(), DatabaseConnection\mapConditionOperator(), mapConditionOperator(), QueryPlaceholderInterface\nextPlaceholder(), and QueryPlaceholderInterface\uniqueIdentifier().

compiled ( )

Implements QueryConditionInterface::compiled().

Implements QueryConditionInterface.

Definition at line 1873 of file query.inc.

References $changed.

condition | ( | $field,
 |  | $value = NULL,
 |  | $operator = NULL
 | ) |

Implements QueryConditionInterface::condition().

Implements QueryConditionInterface.

Definition at line 1707 of file query.inc.

References $value, and conditions().

Referenced by exists(), isNotNull(), isNull(), and notExists().

& conditions ( )

Implements QueryConditionInterface::conditions().

Implements QueryConditionInterface.

Definition at line 1775 of file query.inc.

References $conditions.

Referenced by __clone(), __construct(), condition(), count(), and where().

count ( )

Implements Countable::count().

Returns the size of this conditional. The size of the conditional is the size of its conditional array minus one, because one element is the the conjunction.

Definition at line 1700 of file query.inc.

References conditions().

exists ( SelectQueryInterface $select )

Implements QueryConditionInterface::exists().

Implements QueryConditionInterface.

Definition at line 1761 of file query.inc.

References condition().

isNotNull ( $field )

Implements QueryConditionInterface::isNotNull().

Implements QueryConditionInterface.

Definition at line 1754 of file query.inc.

References condition().

isNull ( $field )

Implements QueryConditionInterface::isNull().

Implements QueryConditionInterface.

Definition at line 1747 of file query.inc.

References condition().

mapConditionOperator ( $operator )
protected

Gets any special processing requirements for the condition operator.

Some condition types require special processing, such as IN, because the value data they pass in is not a simple value. This is a simple overridable lookup function.

Parameters
$operator The condition operator, such as "IN", "BETWEEN", etc. Case-sensitive.
Returns
The extra handling directives for the specified operator, or NULL.

Definition at line 1924 of file query.inc.

Referenced by compile().

notExists ( SelectQueryInterface $select )

Implements QueryConditionInterface::notExists().

Implements QueryConditionInterface.

Definition at line 1768 of file query.inc.

References condition().

where | ( | $snippet,
 |  | $args = array()
 | ) |

Implements QueryConditionInterface::where().

Implements QueryConditionInterface.

Definition at line 1733 of file query.inc.

References $snippet, and conditions().

Member Data Documentation

$arguments = array()
protected

Definition at line 1666 of file query.inc.

Referenced by arguments(), and compile().

$changed = TRUE
protected

Definition at line 1676 of file query.inc.

Referenced by compiled().

$conditions = array()
protected

Definition at line 1659 of file query.inc.

Referenced by compile(), and conditions().

$queryPlaceholderIdentifier
protected

The identifier of the query placeholder this condition has been compiled against.

Definition at line 1681 of file query.inc.

interface QueryExtendableInterface

Interface for extendable query objects.

"Extenders" follow the "Decorator" OOP design pattern. That is, they wrap and "decorate" another object. In our case, they implement the same interface as select queries and wrap a select query, to which they delegate almost all operations. Subclasses of this class may implement additional methods or override existing methods as appropriate. Extenders may also wrap other extender objects, allowing for arbitrarily complex "enhanced" queries.

Definition at line 20 of file select.inc.

Inheritance diagram for QueryExtendableInterface:
SelectQueryInterface SelectQuery SelectQueryExtender SelectQuery_pgsql SelectQuery_sqlite PagerDefault SearchQuery TableSort

Public Member Functions

extend ($extender_name)

Member Function Documentation

extend ( $extender_name )

Enhance this object by wrapping it in an extender object.

Parameters
$extender_name The base name of the extending class. The base name will be checked against the current database connection to allow driver-specific subclasses as well, using the same logic as the query objects themselves. For example, PagerDefault_mysql is the MySQL-specific override for PagerDefault.
Returns
QueryExtendableInterface The extender object, which now contains a reference to this object.

Implemented in SelectQuery, and SelectQueryExtender.

interface SelectQueryInterface

Interface definition for a Select Query object.

Definition at line 39 of file select.inc.

Inheritance diagram for SelectQueryInterface:
QueryConditionInterface QueryAlterableInterface QueryExtendableInterface QueryPlaceholderInterface SelectQuery SelectQueryExtender SelectQuery_pgsql SelectQuery_sqlite PagerDefault SearchQuery TableSort

Public Member Functions

& getFields ()
& getExpressions ()
& getOrderBy ()
& getGroupBy ()
& getTables ()
& getUnion ()
getArguments (QueryPlaceholderInterface $queryPlaceholder=NULL)
distinct ($distinct=TRUE)
addField ($table_alias, $field, $alias=NULL)
fields ($table_alias, array $fields=array())
addExpression ($expression, $alias=NULL, $arguments=array())
join ($table, $alias=NULL, $condition=NULL, $arguments=array())
innerJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
leftJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
rightJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
addJoin ($type, $table, $alias=NULL, $condition=NULL, $arguments=array())
orderBy ($field, $direction= 'ASC')
orderRandom ()
range ($start=NULL, $length=NULL)
union (SelectQueryInterface $query, $type= '')
groupBy ($field)
countQuery ()
isPrepared ()
preExecute (SelectQueryInterface $query=NULL)
havingCondition ($field, $value=NULL, $operator=NULL)
__clone ()
forUpdate ($set=TRUE)
- Public Member Functions inherited from QueryConditionInterface
condition ($field, $value=NULL, $operator=NULL)
where ($snippet, $args=array())
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
& conditions ()
arguments ()
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
- Public Member Functions inherited from QueryAlterableInterface
addTag ($tag)
hasTag ($tag)
hasAllTags ()
hasAnyTag ()
addMetaData ($key, $object)
getMetaData ($key)
- Public Member Functions inherited from QueryExtendableInterface
extend ($extender_name)
- Public Member Functions inherited from QueryPlaceholderInterface
uniqueIdentifier ()
nextPlaceholder ()

Member Function Documentation

__clone ( )

Clone magic method.

Select queries have dependent objects that must be deep-cloned. The connection object itself, however, should not be cloned as that would duplicate the connection itself.

Implemented in SelectQuery, and SelectQueryExtender.

addExpression | ( | $expression,
 |  | $alias = NULL,
 |  | $arguments = array()
 | ) |

Adds an expression to the list of "fields" to be SELECTed.

An expression can be any arbitrary string that is valid SQL. That includes various functions, which may in some cases be database-dependent. This method makes no effort to correct for database-specific functions.

Parameters
$expression | The expression string. May contain placeholders.
$alias | The alias for this expression. If not specified, one will be generated automatically in the form "expression_#". The alias will be checked for uniqueness, so the requested alias may not be the alias that is assigned in all cases.
$arguments | Any placeholder arguments needed for this expression.
Returns
The unique alias that was assigned for this expression.

Implemented in SelectQuery, and SelectQueryExtender.

addField | ( | $table_alias,
 |  | $field,
 |  | $alias = NULL
 | ) |

Adds a field to the list to be SELECTed.

Parameters
$table_alias | The name of the table from which the field comes, as an alias. Generally you will want to use the return value of join() here to ensure that it is valid.
$field | The name of the field.
$alias | The alias for this field. If not specified, one will be generated automatically based on the $table_alias and $field. The alias will be checked for uniqueness, so the requested alias may not be the alias that is assigned in all cases.
Returns
The unique alias that was assigned for this field.

Implemented in SelectQuery, and SelectQueryExtender.

addJoin | ( | $type,
 |  | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Join against another table in the database.

This method does the "hard" work of queuing up a table to be joined against. In some cases, that may include dipping into the Schema API to find the necessary fields on which to join.

Parameters
$type | The type of join. Typically one one of INNER, LEFT OUTER, and RIGHT OUTER.
$table | The table against which to join. May be a string or another SelectQuery object. If a query object is passed, it will be used as a subselect.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table. If omitted, one will be dynamically generated.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implemented in SelectQuery, and SelectQueryExtender.

countQuery ( )

Get the equivalent COUNT query of this query as a new query object.

Returns
SelectQueryInterface A new SelectQuery object with no fields or expressions besides COUNT(*).

Implemented in SelectQuery, SelectQueryExtender, and SearchQuery.

distinct ( $distinct = TRUE )

Sets this query to be DISTINCT.

Parameters
$distinct TRUE to flag this query DISTINCT, FALSE to disable it.
Returns
SelectQueryInterface The called object.

Implemented in SelectQuery, and SelectQueryExtender.

fields | ( |  | $table_alias,
 |  | array | $fields = array()
 | ) |  |

Add multiple fields from the same table to be SELECTed.

This method does not return the aliases set for the passed fields. In the majority of cases that is not a problem, as the alias will be the field name. However, if you do need to know the alias you can call getFields() and examine the result to determine what alias was created. Alternatively, simply use addField() for the few fields you care about and this method for the rest.

Parameters
$table_alias | The name of the table from which the field comes, as an alias. Generally you will want to use the return value of join() here to ensure that it is valid.
$fields | An indexed array of fields present in the specified table that should be included in this query. If not specified, $table_alias.* will be generated without any aliases.
Returns
SelectQueryInterface The called object.

Implemented in SelectQuery, and SelectQueryExtender.

forUpdate ( $set = TRUE )

Add FOR UPDATE to the query.

FOR UPDATE prevents the rows retrieved by the SELECT statement from being modified or deleted by other transactions until the current transaction ends. Other transactions that attempt UPDATE, DELETE, or SELECT FOR UPDATE of these rows will be blocked until the current transaction ends.

Parameters
$set IF TRUE, FOR UPDATE will be added to the query, if FALSE then it won't.
Returns
QueryConditionInterface The called object.

Implemented in SelectQuery, SelectQueryExtender, and SelectQuery_sqlite.

getArguments ( QueryPlaceholderInterface $queryPlaceholder = NULL )

Compiles and returns an associative array of the arguments for this prepared statement.

Parameters
$queryPlaceholder When collecting the arguments of a subquery, the main placeholder object should be passed as this parameter.
Returns
An associative array of all placeholder arguments for this query.

Implemented in SelectQuery, and SelectQueryExtender.

& getExpressions ( )

Returns a reference to the expressions array for this query.

Because this method returns by reference, alter hooks may edit the expressions array directly to make their changes. If just adding expressions, however, the use of addExpression() is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getExpressions();
*
Returns
A reference to the expression array structure.

Implemented in SelectQuery, and SelectQueryExtender.

& getFields ( )

Returns a reference to the fields array for this query.

Because this method returns by reference, alter hooks may edit the fields array directly to make their changes. If just adding fields, however, the use of addField() is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getFields();
*
Returns
A reference to the fields array structure.

Implemented in SelectQuery, and SelectQueryExtender.

& getGroupBy ( )

Returns a reference to the group-by array for this query.

Because this method returns by reference, alter hooks may edit the group-by array directly to make their changes. If just adding additional grouping fields, however, the use of groupBy() is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getGroupBy();
*
Returns
A reference to the group-by array structure.

Implemented in SelectQuery, and SelectQueryExtender.

& getOrderBy ( )

Returns a reference to the order by array for this query.

Because this method returns by reference, alter hooks may edit the order-by array directly to make their changes. If just adding additional ordering fields, however, the use of orderBy() is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getOrderBy();
*
Returns
A reference to the expression array structure.

Implemented in SelectQuery, and SelectQueryExtender.

& getTables ( )

Returns a reference to the tables array for this query.

Because this method returns by reference, alter hooks may edit the tables array directly to make their changes. If just adding tables, however, the use of the join() methods is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getTables();
*
Returns
A reference to the tables array structure.

Implemented in SelectQuery, and SelectQueryExtender.

& getUnion ( )

Returns a reference to the union queries for this query. This include queries for UNION, UNION ALL, and UNION DISTINCT.

Because this method returns by reference, alter hooks may edit the tables array directly to make their changes. If just adding union queries, however, the use of the union() method is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getUnion();
*
Returns
A reference to the union query array structure.

Implemented in SelectQuery, and SelectQueryExtender.

groupBy ( $field )

Groups the result set by the specified field.

Parameters
$field The field on which to group. This should be the field as aliased.
Returns
SelectQueryInterface The called object.

Implemented in SelectQuery, and SelectQueryExtender.

havingCondition | ( | $field,
 |  | $value = NULL,
 |  | $operator = NULL
 | ) |

Helper function to build most common HAVING conditional clauses.

This method can take a variable number of parameters. If called with two parameters, they are taken as $field and $value with $operator having a value of IN if $value is an array and = otherwise.

Parameters
$field | The name of the field to check. If you would like to add a more complex condition involving operators or functions, use having().
$value | The value to test the field against. In most cases, this is a scalar. For more complex options, it is an array. The meaning of each element in the array is dependent on the $operator.
$operator | The comparison operator, such as =, <, or >=. It also accepts more complex options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array = otherwise.
Returns
QueryConditionInterface The called object.

Implemented in SelectQuery, and SelectQueryExtender.

innerJoin | ( | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Inner Join against another table in the database.

Parameters
$table | The table against which to join.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implemented in SelectQuery, and SelectQueryExtender.

isPrepared ( )

Indicates if preExecute() has already been called on that object.

Returns
TRUE is this query has already been prepared, FALSE otherwise.

Implemented in SelectQuery, and SelectQueryExtender.

join | ( | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Default Join against another table in the database.

This method is a convenience method for innerJoin().

Parameters
$table | The table against which to join.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implemented in SelectQuery, and SelectQueryExtender.

leftJoin | ( | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Left Outer Join against another table in the database.

Parameters
$table | The table against which to join.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implemented in SelectQuery, and SelectQueryExtender.

orderBy | ( | $field,
 |  | $direction = 'ASC'
 | ) |

Orders the result set by a given field.

If called multiple times, the query will order by each specified field in the order this method is called.

If the query uses DISTINCT or GROUP BY conditions, fields or expressions that are used for the order must be selected to be compatible with some databases like PostgreSQL. The PostgreSQL driver can handle simple cases automatically but it is suggested to explicitly specify them. Additionally, when ordering on an alias, the alias must be added before orderBy() is called.

Parameters
$field | The field on which to order.
$direction | The direction to sort. Legal values are "ASC" and "DESC".
Returns
SelectQueryInterface The called object.

Implemented in SelectQuery, SelectQueryExtender, and SelectQuery_pgsql.

orderRandom ( )

Orders the result set by a random value.

This may be stacked with other orderBy() calls. If so, the query will order by each specified field, including this one, in the order called. Although this method may be called multiple times on the same query, doing so is not particularly useful.

Note: The method used by most drivers may not scale to very large result sets. If you need to work with extremely large data sets, you may create your own database driver by subclassing off of an existing driver and implementing your own randomization mechanism. See

http://jan.kneschke.de/projects/mysql/order-by-rand/

for an example of such an alternate sorting mechanism.

Returns
SelectQueryInterface The called object

Implemented in SelectQuery, SelectQueryExtender, and SelectQuery_pgsql.

preExecute ( SelectQueryInterface $query = NULL )

Generic preparation and validation for a SELECT query.

Returns
TRUE if the validation was successful, FALSE if not.

Implemented in SelectQuery, and SelectQueryExtender.

range | ( | $start = NULL,
 |  | $length = NULL
 | ) |

Restricts a query to a given range in the result set.

If this method is called with no parameters, will remove any range directives that have been set.

Parameters
$start | The first record from the result set to return. If NULL, removes any range directives that are set.
$length | The number of records to return from the result set.
Returns
SelectQueryInterface The called object.

Implemented in SelectQuery, and SelectQueryExtender.

rightJoin | ( | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Right Outer Join against another table in the database.

Parameters
$table | The table against which to join.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implemented in SelectQuery, and SelectQueryExtender.

union | ( | SelectQueryInterface | $query,
 |  |  | $type = ''
 | ) |  |

Add another Select query to UNION to this one.

Union queries consist of two or more queries whose results are effectively concatenated together. Queries will be UNIONed in the order they are specified, with this object's query coming first. Duplicate columns will be discarded. All forms of UNION are supported, using the second '$type' argument.

Note: All queries UNIONed together must have the same field structure, in the same order. It is up to the caller to ensure that they match properly. If they do not, an SQL syntax error will result.

Parameters
$query | The query to UNION to this query.
$type | The type of UNION to add to the query. Defaults to plain UNION.
Returns
SelectQueryInterface The called object.

Implemented in SelectQuery, and SelectQueryExtender.

class SelectQueryExtender

The base extender class for Select queries.

Definition at line 535 of file select.inc.

Inheritance diagram for SelectQueryExtender:
SelectQueryInterface QueryConditionInterface QueryAlterableInterface QueryExtendableInterface QueryPlaceholderInterface PagerDefault SearchQuery TableSort

Public Member Functions

__construct (SelectQueryInterface $query, DatabaseConnection $connection)
uniqueIdentifier ()
nextPlaceholder ()
addTag ($tag)
hasTag ($tag)
hasAllTags ()
hasAnyTag ()
addMetaData ($key, $object)
getMetaData ($key)
condition ($field, $value=NULL, $operator=NULL)
& conditions ()
arguments ()
where ($snippet, $args=array())
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
havingCondition ($field, $value=NULL, $operator= '=')
& havingConditions ()
havingArguments ()
having ($snippet, $args=array())
havingCompile (DatabaseConnection $connection)
extend ($extender_name)
& getFields ()
& getExpressions ()
& getOrderBy ()
& getGroupBy ()
& getTables ()
& getUnion ()
getArguments (QueryPlaceholderInterface $queryPlaceholder=NULL)
isPrepared ()
preExecute (SelectQueryInterface $query=NULL)
execute ()
distinct ($distinct=TRUE)
addField ($table_alias, $field, $alias=NULL)
fields ($table_alias, array $fields=array())
addExpression ($expression, $alias=NULL, $arguments=array())
join ($table, $alias=NULL, $condition=NULL, $arguments=array())
innerJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
leftJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
rightJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
addJoin ($type, $table, $alias=NULL, $condition=NULL, $arguments=array())
orderBy ($field, $direction= 'ASC')
orderRandom ()
range ($start=NULL, $length=NULL)
union (SelectQueryInterface $query, $type= '')
groupBy ($field)
forUpdate ($set=TRUE)
countQuery ()
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
__toString ()
__clone ()
__call ($method, $args)

Protected Attributes

$query
$connection
$uniqueIdentifier
$placeholder = 0

Constructor & Destructor Documentation

__construct | ( | SelectQueryInterface | $query,
 |  | DatabaseConnection | $connection
 | ) |  |

Definition at line 561 of file select.inc.

References $connection, $query, and uniqueIdentifier().

Member Function Documentation

__call | ( | $method,
 |  | $args
 | ) |

Magic override for undefined methods.

If one extender extends another extender, then methods in the inner extender will not be exposed on the outer extender. That's because we cannot know in advance what those methods will be, so we cannot provide wrapping implementations as we do above. Instead, we use this slower catch-all method to handle any additional methods.

Definition at line 839 of file select.inc.

__clone ( )

Clone magic method.

Select queries have dependent objects that must be deep-cloned. The connection object itself, however, should not be cloned as that would duplicate the connection itself.

Implements SelectQueryInterface.

Definition at line 822 of file select.inc.

References uniqueIdentifier().

__toString ( )

Definition at line 818 of file select.inc.

References $query.

addExpression | ( | $expression,
 |  | $alias = NULL,
 |  | $arguments = array()
 | ) |

Adds an expression to the list of "fields" to be SELECTed.

An expression can be any arbitrary string that is valid SQL. That includes various functions, which may in some cases be database-dependent. This method makes no effort to correct for database-specific functions.

Parameters
$expression | The expression string. May contain placeholders.
$alias | The alias for this expression. If not specified, one will be generated automatically in the form "expression_#". The alias will be checked for uniqueness, so the requested alias may not be the alias that is assigned in all cases.
$arguments | Any placeholder arguments needed for this expression.
Returns
The unique alias that was assigned for this expression.

Implements SelectQueryInterface.

Definition at line 740 of file select.inc.

Referenced by SearchQuery\execute().

addField | ( | $table_alias,
 |  | $field,
 |  | $alias = NULL
 | ) |

Adds a field to the list to be SELECTed.

Parameters
$table_alias | The name of the table from which the field comes, as an alias. Generally you will want to use the return value of join() here to ensure that it is valid.
$field | The name of the field.
$alias | The alias for this field. If not specified, one will be generated automatically based on the $table_alias and $field. The alias will be checked for uniqueness, so the requested alias may not be the alias that is assigned in all cases.
Returns
The unique alias that was assigned for this field.

Implements SelectQueryInterface.

Definition at line 731 of file select.inc.

addJoin | ( | $type,
 |  | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Join against another table in the database.

This method does the "hard" work of queuing up a table to be joined against. In some cases, that may include dipping into the Schema API to find the necessary fields on which to join.

Parameters
$type | The type of join. Typically one one of INNER, LEFT OUTER, and RIGHT OUTER.
$table | The table against which to join. May be a string or another SelectQuery object. If a query object is passed, it will be used as a subselect.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table. If omitted, one will be dynamically generated.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implements SelectQueryInterface.

Definition at line 760 of file select.inc.

Referenced by _node_rankings().

addMetaData | ( | $key,
 |  | $object
 | ) |

Adds additional metadata to the query.

Often, a query may need to provide additional contextual data to alter hooks. Alter hooks may then use that information to decide if and how to take action.

Parameters
$key | The unique identifier for this piece of metadata. Must be a string that follows the same rules as any other PHP identifier.
$object | The additional data to add to the query. May be any valid PHP variable.
Returns
QueryAlterableInterface The called object.

Implements QueryAlterableInterface.

Definition at line 602 of file select.inc.

addTag ( $tag )

Adds a tag to a query.

Tags are strings that identify a query. A query may have any number of tags. Tags are used to mark a query so that alter hooks may decide if they wish to take action. Tags should be all lower-case and contain only letters, numbers, and underscore, and start with a letter. That is, they should follow the same rules as PHP identifiers in general.

Parameters
$tag The tag to add.
Returns
QueryAlterableInterface The called object.

Implements QueryAlterableInterface.

Definition at line 583 of file select.inc.

Referenced by TableSort\__construct(), and PagerDefault\__construct().

arguments ( )

Gets a complete list of all values to insert into the prepared statement.

Returns
An associative array of placeholders and values.

Implements QueryConditionInterface.

Definition at line 622 of file select.inc.

compile | ( | DatabaseConnection | $connection,
 |  | QueryPlaceholderInterface | $queryPlaceholder
 | ) |  |

Compiles the saved conditions for later retrieval.

This method does not return anything, but simply prepares data to be retrieved via __toString() and arguments().

Parameters
$connection | The database connection for which to compile the conditionals.
$queryPlaceholder | The query this condition belongs to. If not given, the current query is used.

Implements QueryConditionInterface.

Definition at line 631 of file select.inc.

compiled ( )

Check whether a condition has been previously compiled.

Returns
TRUE if the condition has been previously compiled.

Implements QueryConditionInterface.

Definition at line 635 of file select.inc.

condition | ( | $field,
 |  | $value = NULL,
 |  | $operator = NULL
 | ) |

Helper function: builds the most common conditional clauses.

This method can take a variable number of parameters. If called with two parameters, they are taken as $field and $value with $operator having a value of IN if $value is an array and = otherwise.

Do not use this method to test for NULL values. Instead, use QueryConditionInterface::isNull() or QueryConditionInterface::isNotNull().

Parameters
$field | The name of the field to check. If you would like to add a more complex condition involving operators or functions, use where().
$value | The value to test the field against. In most cases, this is a scalar. For more complex options, it is an array. The meaning of each element in the array is dependent on the $operator.
$operator | The comparison operator, such as =, <, or >=. It also accepts more complex options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array, and = otherwise.
Returns
QueryConditionInterface The called object.
See Also
QueryConditionInterface::isNull()
QueryConditionInterface::isNotNull()

Implements QueryConditionInterface.

Definition at line 613 of file select.inc.

References $value.

Referenced by SearchQuery\execute(), SearchQuery\executeFirstPass(), and SearchQuery\setOption().

& conditions ( )

Gets a complete list of all conditions in this conditional clause.

This method returns by reference. That allows alter hooks to access the data structure directly and manipulate it before it gets compiled.

The data structure that is returned is an indexed array of entries, where each entry looks like the following:

* array(
* 'field' => $field,
* 'value' => $value,
* 'operator' => $operator,
* );
*

In the special case that $operator is NULL, the $field is taken as a raw SQL snippet (possibly containing a function) and $value is an associative array of placeholders for the snippet.

There will also be a single array entry of #conjunction, which is the conjunction that will be applied to the array, such as AND.

Implements QueryConditionInterface.

Definition at line 618 of file select.inc.

Referenced by SearchQuery\countQuery(), SearchQuery\execute(), SearchQuery\executeFirstPass(), and SearchQuery\parseSearchExpression().

countQuery ( )

Get the equivalent COUNT query of this query as a new query object.

Returns
SelectQueryInterface A new SelectQuery object with no fields or expressions besides COUNT(*).

Implements SelectQueryInterface.

Definition at line 794 of file select.inc.

distinct ( $distinct = TRUE )

Sets this query to be DISTINCT.

Parameters
$distinct TRUE to flag this query DISTINCT, FALSE to disable it.
Returns
SelectQueryInterface The called object.

Implements SelectQueryInterface.

Definition at line 726 of file select.inc.

execute ( )

Definition at line 715 of file select.inc.

References preExecute().

exists ( SelectQueryInterface $select )

Sets a condition that the specified subquery returns values.

Parameters
SelectQueryInterface $select The subquery that must contain results.
Returns
QueryConditionInterface The called object.

Implements QueryConditionInterface.

Definition at line 808 of file select.inc.

extend ( $extender_name )

Enhance this object by wrapping it in an extender object.

Parameters
$extender_name The base name of the extending class. The base name will be checked against the current database connection to allow driver-specific subclasses as well, using the same logic as the query objects themselves. For example, PagerDefault_mysql is the MySQL-specific override for PagerDefault.
Returns
QueryExtendableInterface The extender object, which now contains a reference to this object.

Implements QueryExtendableInterface.

Definition at line 665 of file select.inc.

fields | ( |  | $table_alias,
 |  | array | $fields = array()
 | ) |  |

Add multiple fields from the same table to be SELECTed.

This method does not return the aliases set for the passed fields. In the majority of cases that is not a problem, as the alias will be the field name. However, if you do need to know the alias you can call getFields() and examine the result to determine what alias was created. Alternatively, simply use addField() for the few fields you care about and this method for the rest.

Parameters
$table_alias | The name of the table from which the field comes, as an alias. Generally you will want to use the return value of join() here to ensure that it is valid.
$fields | An indexed array of fields present in the specified table that should be included in this query. If not specified, $table_alias.* will be generated without any aliases.
Returns
SelectQueryInterface The called object.

Implements SelectQueryInterface.

Definition at line 735 of file select.inc.

forUpdate ( $set = TRUE )

Add FOR UPDATE to the query.

FOR UPDATE prevents the rows retrieved by the SELECT statement from being modified or deleted by other transactions until the current transaction ends. Other transactions that attempt UPDATE, DELETE, or SELECT FOR UPDATE of these rows will be blocked until the current transaction ends.

Parameters
$set IF TRUE, FOR UPDATE will be added to the query, if FALSE then it won't.
Returns
QueryConditionInterface The called object.

Implements SelectQueryInterface.

Definition at line 789 of file select.inc.

getArguments ( QueryPlaceholderInterface $queryPlaceholder = NULL )

Compiles and returns an associative array of the arguments for this prepared statement.

Parameters
$queryPlaceholder When collecting the arguments of a subquery, the main placeholder object should be passed as this parameter.
Returns
An associative array of all placeholder arguments for this query.

Implements SelectQueryInterface.

Definition at line 698 of file select.inc.

& getExpressions ( )

Returns a reference to the expressions array for this query.

Because this method returns by reference, alter hooks may edit the expressions array directly to make their changes. If just adding expressions, however, the use of addExpression() is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getExpressions();
*
Returns
A reference to the expression array structure.

Implements SelectQueryInterface.

Definition at line 678 of file select.inc.

& getFields ( )

Returns a reference to the fields array for this query.

Because this method returns by reference, alter hooks may edit the fields array directly to make their changes. If just adding fields, however, the use of addField() is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getFields();
*
Returns
A reference to the fields array structure.

Implements SelectQueryInterface.

Definition at line 674 of file select.inc.

& getGroupBy ( )

Returns a reference to the group-by array for this query.

Because this method returns by reference, alter hooks may edit the group-by array directly to make their changes. If just adding additional grouping fields, however, the use of groupBy() is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getGroupBy();
*
Returns
A reference to the group-by array structure.

Implements SelectQueryInterface.

Definition at line 686 of file select.inc.

getMetaData ( $key )

Retrieves a given piece of metadata.

Parameters
$key The unique identifier for the piece of metadata to retrieve.
Returns
The previously attached metadata object, or NULL if one doesn't exist.

Implements QueryAlterableInterface.

Definition at line 607 of file select.inc.

& getOrderBy ( )

Returns a reference to the order by array for this query.

Because this method returns by reference, alter hooks may edit the order-by array directly to make their changes. If just adding additional ordering fields, however, the use of orderBy() is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getOrderBy();
*
Returns
A reference to the expression array structure.

Implements SelectQueryInterface.

Definition at line 682 of file select.inc.

Referenced by SearchQuery\execute().

& getTables ( )

Returns a reference to the tables array for this query.

Because this method returns by reference, alter hooks may edit the tables array directly to make their changes. If just adding tables, however, the use of the join() methods is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getTables();
*
Returns
A reference to the tables array structure.

Implements SelectQueryInterface.

Definition at line 690 of file select.inc.

Referenced by _node_rankings().

& getUnion ( )

Returns a reference to the union queries for this query. This include queries for UNION, UNION ALL, and UNION DISTINCT.

Because this method returns by reference, alter hooks may edit the tables array directly to make their changes. If just adding union queries, however, the use of the union() method is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getUnion();
*
Returns
A reference to the union query array structure.

Implements SelectQueryInterface.

Definition at line 694 of file select.inc.

groupBy ( $field )

Groups the result set by the specified field.

Parameters
$field The field on which to group. This should be the field as aliased.
Returns
SelectQueryInterface The called object.

Implements SelectQueryInterface.

Definition at line 784 of file select.inc.

hasAllTags ( )

Determines if a given query has all specified tags.

Parameters
$tags A variable number of arguments, one for each tag to check.
Returns
TRUE if this query has been marked with all specified tags, FALSE otherwise.

Implements QueryAlterableInterface.

Definition at line 592 of file select.inc.

hasAnyTag ( )

Determines if a given query has any specified tag.

Parameters
$tags A variable number of arguments, one for each tag to check.
Returns
TRUE if this query has been marked with at least one of the specified tags, FALSE otherwise.

Implements QueryAlterableInterface.

Definition at line 597 of file select.inc.

hasTag ( $tag )

Determines if a given query has a given tag.

Parameters
$tag The tag to check.
Returns
TRUE if this query has been marked with this tag, FALSE otherwise.

Implements QueryAlterableInterface.

Definition at line 588 of file select.inc.

having | ( | $snippet,
 |  | $args = array()
 | ) |

Definition at line 654 of file select.inc.

References $snippet.

havingArguments ( )

Definition at line 650 of file select.inc.

havingCompile ( DatabaseConnection $connection )

Definition at line 659 of file select.inc.

havingCondition | ( | $field,
 |  | $value = NULL,
 |  | $operator = '='
 | ) |

Helper function to build most common HAVING conditional clauses.

This method can take a variable number of parameters. If called with two parameters, they are taken as $field and $value with $operator having a value of IN if $value is an array and = otherwise.

Parameters
$field | The name of the field to check. If you would like to add a more complex condition involving operators or functions, use having().
$value | The value to test the field against. In most cases, this is a scalar. For more complex options, it is an array. The meaning of each element in the array is dependent on the $operator.
$operator | The comparison operator, such as =, <, or >=. It also accepts more complex options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array = otherwise.
Returns
QueryConditionInterface The called object.

Implements SelectQueryInterface.

Definition at line 641 of file select.inc.

References $value.

& havingConditions ( )

Definition at line 646 of file select.inc.

innerJoin | ( | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Inner Join against another table in the database.

Parameters
$table | The table against which to join.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implements SelectQueryInterface.

Definition at line 748 of file select.inc.

isNotNull ( $field )

Sets a condition that the specified field be NOT NULL.

Parameters
$field The name of the field to check.
Returns
QueryConditionInterface The called object.

Implements QueryConditionInterface.

Definition at line 803 of file select.inc.

isNull ( $field )

Sets a condition that the specified field be NULL.

Parameters
$field The name of the field to check.
Returns
QueryConditionInterface The called object.

Implements QueryConditionInterface.

Definition at line 798 of file select.inc.

isPrepared ( )

Indicates if preExecute() has already been called on that object.

Returns
TRUE is this query has already been prepared, FALSE otherwise.

Implements SelectQueryInterface.

Definition at line 702 of file select.inc.

join | ( | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Default Join against another table in the database.

This method is a convenience method for innerJoin().

Parameters
$table | The table against which to join.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implements SelectQueryInterface.

Definition at line 744 of file select.inc.

Referenced by SearchQuery\execute(), and SearchQuery\executeFirstPass().

leftJoin | ( | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Left Outer Join against another table in the database.

Parameters
$table | The table against which to join.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implements SelectQueryInterface.

Definition at line 752 of file select.inc.

nextPlaceholder ( )

Implements QueryPlaceholderInterface::nextPlaceholder().

Implements QueryPlaceholderInterface.

Definition at line 577 of file select.inc.

notExists ( SelectQueryInterface $select )

Sets a condition that the specified subquery returns no values.

Parameters
SelectQueryInterface $select The subquery that must not contain results.
Returns
QueryConditionInterface The called object.

Implements QueryConditionInterface.

Definition at line 813 of file select.inc.

orderBy | ( | $field,
 |  | $direction = 'ASC'
 | ) |

Orders the result set by a given field.

If called multiple times, the query will order by each specified field in the order this method is called.

If the query uses DISTINCT or GROUP BY conditions, fields or expressions that are used for the order must be selected to be compatible with some databases like PostgreSQL. The PostgreSQL driver can handle simple cases automatically but it is suggested to explicitly specify them. Additionally, when ordering on an alias, the alias must be added before orderBy() is called.

Parameters
$field | The field on which to order.
$direction | The direction to sort. Legal values are "ASC" and "DESC".
Returns
SelectQueryInterface The called object.

Implements SelectQueryInterface.

Definition at line 764 of file select.inc.

Referenced by SearchQuery\execute(), and TableSort\orderByHeader().

orderRandom ( )

Orders the result set by a random value.

This may be stacked with other orderBy() calls. If so, the query will order by each specified field, including this one, in the order called. Although this method may be called multiple times on the same query, doing so is not particularly useful.

Note: The method used by most drivers may not scale to very large result sets. If you need to work with extremely large data sets, you may create your own database driver by subclassing off of an existing driver and implementing your own randomization mechanism. See

http://jan.kneschke.de/projects/mysql/order-by-rand/

for an example of such an alternate sorting mechanism.

Returns
SelectQueryInterface The called object

Implements SelectQueryInterface.

Definition at line 769 of file select.inc.

preExecute ( SelectQueryInterface $query = NULL )

Generic preparation and validation for a SELECT query.

Returns
TRUE if the validation was successful, FALSE if not.

Implements SelectQueryInterface.

Definition at line 706 of file select.inc.

References $query.

Referenced by PagerDefault\execute(), and execute().

range | ( | $start = NULL,
 |  | $length = NULL
 | ) |

Restricts a query to a given range in the result set.

If this method is called with no parameters, will remove any range directives that have been set.

Parameters
$start | The first record from the result set to return. If NULL, removes any range directives that are set.
$length | The number of records to return from the result set.
Returns
SelectQueryInterface The called object.

Implements SelectQueryInterface.

Definition at line 774 of file select.inc.

Referenced by PagerDefault\execute().

rightJoin | ( | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Right Outer Join against another table in the database.

Parameters
$table | The table against which to join.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implements SelectQueryInterface.

Definition at line 756 of file select.inc.

union | ( | SelectQueryInterface | $query,
 |  |  | $type = ''
 | ) |  |

Add another Select query to UNION to this one.

Union queries consist of two or more queries whose results are effectively concatenated together. Queries will be UNIONed in the order they are specified, with this object's query coming first. Duplicate columns will be discarded. All forms of UNION are supported, using the second '$type' argument.

Note: All queries UNIONed together must have the same field structure, in the same order. It is up to the caller to ensure that they match properly. If they do not, an SQL syntax error will result.

Parameters
$query | The query to UNION to this query.
$type | The type of UNION to add to the query. Defaults to plain UNION.
Returns
SelectQueryInterface The called object.

Implements SelectQueryInterface.

Definition at line 779 of file select.inc.

References $query.

uniqueIdentifier ( )

Implements QueryPlaceholderInterface::uniqueIdentifier().

Implements QueryPlaceholderInterface.

Definition at line 570 of file select.inc.

References $uniqueIdentifier.

Referenced by __clone(), and __construct().

where | ( | $snippet,
 |  | $args = array()
 | ) |

Adds an arbitrary WHERE clause to the query.

Parameters
$snippet | A portion of a WHERE clause as a prepared statement. It must use named placeholders, not ? placeholders.
$args | An associative array of arguments.
Returns
QueryConditionInterface The called object.

Implements QueryConditionInterface.

Definition at line 626 of file select.inc.

References $snippet.

Member Data Documentation

$connection
protected

Definition at line 549 of file select.inc.

Referenced by __construct().

$placeholder = 0
protected

The placeholder counter.

Definition at line 559 of file select.inc.

$query
protected

Definition at line 542 of file select.inc.

Referenced by __construct(), __toString(), SearchQuery\countQuery(), SearchQuery\executeFirstPass(), preExecute(), PagerDefault\setCountQuery(), and union().

$uniqueIdentifier
protected

A unique identifier for this query object.

Definition at line 554 of file select.inc.

Referenced by uniqueIdentifier().

class SelectQuery

Query builder for SELECT statements.

Definition at line 859 of file select.inc.

Inheritance diagram for SelectQuery:
Query SelectQueryInterface QueryPlaceholderInterface QueryConditionInterface QueryAlterableInterface QueryExtendableInterface QueryPlaceholderInterface SelectQuery_pgsql SelectQuery_sqlite

Public Member Functions

__construct ($table, $alias=NULL, DatabaseConnection $connection, $options=array())
addTag ($tag)
hasTag ($tag)
hasAllTags ()
hasAnyTag ()
addMetaData ($key, $object)
getMetaData ($key)
condition ($field, $value=NULL, $operator=NULL)
& conditions ()
arguments ()
where ($snippet, $args=array())
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
havingCondition ($field, $value=NULL, $operator=NULL)
& havingConditions ()
havingArguments ()
having ($snippet, $args=array())
havingCompile (DatabaseConnection $connection)
extend ($extender_name)
havingIsNull ($field)
havingIsNotNull ($field)
havingExists (SelectQueryInterface $select)
havingNotExists (SelectQueryInterface $select)
forUpdate ($set=TRUE)
& getFields ()
& getExpressions ()
& getOrderBy ()
& getGroupBy ()
& getTables ()
& getUnion ()
getArguments (QueryPlaceholderInterface $queryPlaceholder=NULL)
isPrepared ()
preExecute (SelectQueryInterface $query=NULL)
execute ()
distinct ($distinct=TRUE)
addField ($table_alias, $field, $alias=NULL)
fields ($table_alias, array $fields=array())
addExpression ($expression, $alias=NULL, $arguments=array())
join ($table, $alias=NULL, $condition=NULL, $arguments=array())
innerJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
leftJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
rightJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
addJoin ($type, $table, $alias=NULL, $condition=NULL, $arguments=array())
orderBy ($field, $direction= 'ASC')
orderRandom ()
range ($start=NULL, $length=NULL)
union (SelectQueryInterface $query, $type= '')
groupBy ($field)
countQuery ()
__toString ()
__clone ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Protected Attributes

$fields = array()
$expressions = array()
$tables = array()
$order = array()
$group = array()
$where
$having
$distinct = FALSE
$range
$union = array()
$prepared = FALSE
$forUpdate = FALSE
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Additional Inherited Members

- Protected Member Functions inherited from Query
execute ()

Constructor & Destructor Documentation

__construct | ( |  | $table,
 |  |  | $alias = NULL,
 |  | DatabaseConnection | $connection,
 |  |  | $options = array()
 | ) |  |

Definition at line 966 of file select.inc.

References addJoin(), having(), Database\RETURN_STATEMENT, and where().

Member Function Documentation

__clone ( )

Clone magic method.

Select queries have dependent objects that must be deep-cloned. The connection object itself, however, should not be cloned as that would duplicate the connection itself.

Implements SelectQueryInterface.

Definition at line 1598 of file select.inc.

References having(), and where().

__toString ( )

Definition at line 1483 of file select.inc.

References Query\$comments, $fields, $having, $union, $where, compile(), compiled(), distinct(), fields(), forUpdate(), having(), range(), and where().

addExpression | ( | $expression,
 |  | $alias = NULL,
 |  | $arguments = array()
 | ) |

Adds an expression to the list of "fields" to be SELECTed.

An expression can be any arbitrary string that is valid SQL. That includes various functions, which may in some cases be database-dependent. This method makes no effort to correct for database-specific functions.

Parameters
$expression | The expression string. May contain placeholders.
$alias | The alias for this expression. If not specified, one will be generated automatically in the form "expression_#". The alias will be checked for uniqueness, so the requested alias may not be the alias that is assigned in all cases.
$arguments | Any placeholder arguments needed for this expression.
Returns
The unique alias that was assigned for this expression.

Implements SelectQueryInterface.

Definition at line 1316 of file select.inc.

Referenced by SelectQuery_pgsql\orderRandom(), and orderRandom().

addField | ( | $table_alias,
 |  | $field,
 |  | $alias = NULL
 | ) |

Adds a field to the list to be SELECTed.

Parameters
$table_alias | The name of the table from which the field comes, as an alias. Generally you will want to use the return value of join() here to ensure that it is valid.
$field | The name of the field.
$alias | The alias for this field. If not specified, one will be generated automatically based on the $table_alias and $field. The alias will be checked for uniqueness, so the requested alias may not be the alias that is assigned in all cases.
Returns
The unique alias that was assigned for this field.

Implements SelectQueryInterface.

Definition at line 1272 of file select.inc.

References fields().

Referenced by fields(), and SelectQuery_pgsql\orderBy().

addJoin | ( | $type,
 |  | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Join against another table in the database.

This method does the "hard" work of queuing up a table to be joined against. In some cases, that may include dipping into the Schema API to find the necessary fields on which to join.

Parameters
$type | The type of join. Typically one one of INNER, LEFT OUTER, and RIGHT OUTER.
$table | The table against which to join. May be a string or another SelectQuery object. If a query object is passed, it will be used as a subselect.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table. If omitted, one will be dynamically generated.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implements SelectQueryInterface.

Definition at line 1353 of file select.inc.

Referenced by __construct(), innerJoin(), join(), leftJoin(), and rightJoin().

addMetaData | ( | $key,
 |  | $object
 | ) |

Adds additional metadata to the query.

Often, a query may need to provide additional contextual data to alter hooks. Alter hooks may then use that information to decide if and how to take action.

Parameters
$key | The unique identifier for this piece of metadata. Must be a string that follows the same rules as any other PHP identifier.
$object | The additional data to add to the query. May be any valid PHP variable.
Returns
QueryAlterableInterface The called object.

Implements QueryAlterableInterface.

Definition at line 995 of file select.inc.

addTag ( $tag )

Adds a tag to a query.

Tags are strings that identify a query. A query may have any number of tags. Tags are used to mark a query so that alter hooks may decide if they wish to take action. Tags should be all lower-case and contain only letters, numbers, and underscore, and start with a letter. That is, they should follow the same rules as PHP identifiers in general.

Parameters
$tag The tag to add.
Returns
QueryAlterableInterface The called object.

Implements QueryAlterableInterface.

Definition at line 976 of file select.inc.

arguments ( )

Gets a complete list of all values to insert into the prepared statement.

Returns
An associative array of placeholders and values.

Implements QueryConditionInterface.

Definition at line 1015 of file select.inc.

References $union, compiled(), having(), and where().

Referenced by getArguments().

compile | ( | DatabaseConnection | $connection,
 |  | QueryPlaceholderInterface | $queryPlaceholder
 | ) |  |

Compiles the saved conditions for later retrieval.

This method does not return anything, but simply prepares data to be retrieved via __toString() and arguments().

Parameters
$connection | The database connection for which to compile the conditionals.
$queryPlaceholder | The query this condition belongs to. If not given, the current query is used.

Implements QueryConditionInterface.

Definition at line 1072 of file select.inc.

References $union, having(), and where().

Referenced by __toString(), and getArguments().

compiled ( )

Check whether a condition has been previously compiled.

Returns
TRUE if the condition has been previously compiled.

Implements QueryConditionInterface.

Definition at line 1089 of file select.inc.

References $union, having(), and where().

Referenced by __toString(), and arguments().

condition | ( | $field,
 |  | $value = NULL,
 |  | $operator = NULL
 | ) |

Helper function: builds the most common conditional clauses.

This method can take a variable number of parameters. If called with two parameters, they are taken as $field and $value with $operator having a value of IN if $value is an array and = otherwise.

Do not use this method to test for NULL values. Instead, use QueryConditionInterface::isNull() or QueryConditionInterface::isNotNull().

Parameters
$field | The name of the field to check. If you would like to add a more complex condition involving operators or functions, use where().
$value | The value to test the field against. In most cases, this is a scalar. For more complex options, it is an array. The meaning of each element in the array is dependent on the $operator.
$operator | The comparison operator, such as =, <, or >=. It also accepts more complex options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array, and = otherwise.
Returns
QueryConditionInterface The called object.
See Also
QueryConditionInterface::isNull()
QueryConditionInterface::isNotNull()

Implements QueryConditionInterface.

Definition at line 1006 of file select.inc.

References $value, and where().

Referenced by user_build_filter_query().

& conditions ( )

Gets a complete list of all conditions in this conditional clause.

This method returns by reference. That allows alter hooks to access the data structure directly and manipulate it before it gets compiled.

The data structure that is returned is an indexed array of entries, where each entry looks like the following:

* array(
* 'field' => $field,
* 'value' => $value,
* 'operator' => $operator,
* );
*

In the special case that $operator is NULL, the $field is taken as a raw SQL snippet (possibly containing a function) and $value is an associative array of placeholders for the snippet.

There will also be a single array entry of #conjunction, which is the conjunction that will be applied to the array, such as AND.

Implements QueryConditionInterface.

Definition at line 1011 of file select.inc.

References where().

countQuery ( )

Get the equivalent COUNT query of this query as a new query object.

Returns
SelectQueryInterface A new SelectQuery object with no fields or expressions besides COUNT(*).

Implements SelectQueryInterface.

Definition at line 1429 of file select.inc.

References $expressions, $fields, and $having.

distinct ( $distinct = TRUE )

Sets this query to be DISTINCT.

Parameters
$distinct TRUE to flag this query DISTINCT, FALSE to disable it.
Returns
SelectQueryInterface The called object.

Implements SelectQueryInterface.

Definition at line 1267 of file select.inc.

References $distinct.

Referenced by __toString().

execute ( )

Definition at line 1256 of file select.inc.

References getArguments(), and preExecute().

exists ( SelectQueryInterface $select )

Sets a condition that the specified subquery returns values.

Parameters
SelectQueryInterface $select The subquery that must contain results.
Returns
QueryConditionInterface The called object.

Implements QueryConditionInterface.

Definition at line 1062 of file select.inc.

References where().

extend ( $extender_name )

Enhance this object by wrapping it in an extender object.

Parameters
$extender_name The base name of the extending class. The base name will be checked against the current database connection to allow driver-specific subclasses as well, using the same logic as the query objects themselves. For example, PagerDefault_mysql is the MySQL-specific override for PagerDefault.
Returns
QueryExtendableInterface The extender object, which now contains a reference to this object.

Implements QueryExtendableInterface.

Definition at line 1138 of file select.inc.

fields | ( |  | $table_alias,
 |  | array | $fields = array()
 | ) |  |

Add multiple fields from the same table to be SELECTed.

This method does not return the aliases set for the passed fields. In the majority of cases that is not a problem, as the alias will be the field name. However, if you do need to know the alias you can call getFields() and examine the result to determine what alias was created. Alternatively, simply use addField() for the few fields you care about and this method for the rest.

Parameters
$table_alias | The name of the table from which the field comes, as an alias. Generally you will want to use the return value of join() here to ensure that it is valid.
$fields | An indexed array of fields present in the specified table that should be included in this query. If not specified, $table_alias.* will be generated without any aliases.
Returns
SelectQueryInterface The called object.

Implements SelectQueryInterface.

Definition at line 1300 of file select.inc.

References $fields, and addField().

Referenced by __toString(), addField(), and SelectQuery_pgsql\orderBy().

forUpdate ( $set = TRUE )

Add FOR UPDATE to the query.

FOR UPDATE prevents the rows retrieved by the SELECT statement from being modified or deleted by other transactions until the current transaction ends. Other transactions that attempt UPDATE, DELETE, or SELECT FOR UPDATE of these rows will be blocked until the current transaction ends.

Parameters
$set IF TRUE, FOR UPDATE will be added to the query, if FALSE then it won't.
Returns
QueryConditionInterface The called object.

Implements SelectQueryInterface.

Definition at line 1166 of file select.inc.

Referenced by __toString().

getArguments ( QueryPlaceholderInterface $queryPlaceholder = NULL )

Compiles and returns an associative array of the arguments for this prepared statement.

Parameters
$queryPlaceholder When collecting the arguments of a subquery, the main placeholder object should be passed as this parameter.
Returns
An associative array of all placeholder arguments for this query.

Implements SelectQueryInterface.

Definition at line 1199 of file select.inc.

References arguments(), and compile().

Referenced by execute().

& getExpressions ( )

Returns a reference to the expressions array for this query.

Because this method returns by reference, alter hooks may edit the expressions array directly to make their changes. If just adding expressions, however, the use of addExpression() is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getExpressions();
*
Returns
A reference to the expression array structure.

Implements SelectQueryInterface.

Definition at line 1179 of file select.inc.

References $expressions.

& getFields ( )

Returns a reference to the fields array for this query.

Because this method returns by reference, alter hooks may edit the fields array directly to make their changes. If just adding fields, however, the use of addField() is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getFields();
*
Returns
A reference to the fields array structure.

Implements SelectQueryInterface.

Definition at line 1175 of file select.inc.

References $fields.

& getGroupBy ( )

Returns a reference to the group-by array for this query.

Because this method returns by reference, alter hooks may edit the group-by array directly to make their changes. If just adding additional grouping fields, however, the use of groupBy() is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getGroupBy();
*
Returns
A reference to the group-by array structure.

Implements SelectQueryInterface.

Definition at line 1187 of file select.inc.

References $group.

getMetaData ( $key )

Retrieves a given piece of metadata.

Parameters
$key The unique identifier for the piece of metadata to retrieve.
Returns
The previously attached metadata object, or NULL if one doesn't exist.

Implements QueryAlterableInterface.

Definition at line 1000 of file select.inc.

& getOrderBy ( )

Returns a reference to the order by array for this query.

Because this method returns by reference, alter hooks may edit the order-by array directly to make their changes. If just adding additional ordering fields, however, the use of orderBy() is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getOrderBy();
*
Returns
A reference to the expression array structure.

Implements SelectQueryInterface.

Definition at line 1183 of file select.inc.

References $order.

& getTables ( )

Returns a reference to the tables array for this query.

Because this method returns by reference, alter hooks may edit the tables array directly to make their changes. If just adding tables, however, the use of the join() methods is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getTables();
*
Returns
A reference to the tables array structure.

Implements SelectQueryInterface.

Definition at line 1191 of file select.inc.

References $tables.

& getUnion ( )

Returns a reference to the union queries for this query. This include queries for UNION, UNION ALL, and UNION DISTINCT.

Because this method returns by reference, alter hooks may edit the tables array directly to make their changes. If just adding union queries, however, the use of the union() method is preferred.

Note that this method must be called by reference as well:

* $fields =& $query->getUnion();
*
Returns
A reference to the union query array structure.

Implements SelectQueryInterface.

Definition at line 1195 of file select.inc.

References $union.

groupBy ( $field )

Groups the result set by the specified field.

Parameters
$field The field on which to group. This should be the field as aliased.
Returns
SelectQueryInterface The called object.

Implements SelectQueryInterface.

Definition at line 1424 of file select.inc.

hasAllTags ( )

Determines if a given query has all specified tags.

Parameters
$tags A variable number of arguments, one for each tag to check.
Returns
TRUE if this query has been marked with all specified tags, FALSE otherwise.

Implements QueryAlterableInterface.

Definition at line 985 of file select.inc.

hasAnyTag ( )

Determines if a given query has any specified tag.

Parameters
$tags A variable number of arguments, one for each tag to check.
Returns
TRUE if this query has been marked with at least one of the specified tags, FALSE otherwise.

Implements QueryAlterableInterface.

Definition at line 990 of file select.inc.

hasTag ( $tag )

Determines if a given query has a given tag.

Parameters
$tag The tag to check.
Returns
TRUE if this query has been marked with this tag, FALSE otherwise.

Implements QueryAlterableInterface.

Definition at line 981 of file select.inc.

having | ( | $snippet,
 |  | $args = array()
 | ) |

Definition at line 1127 of file select.inc.

References $snippet.

Referenced by __clone(), __construct(), __toString(), arguments(), compile(), compiled(), havingArguments(), havingCompile(), havingCondition(), havingConditions(), havingExists(), havingIsNotNull(), havingIsNull(), and havingNotExists().

havingArguments ( )

Definition at line 1123 of file select.inc.

References having().

havingCompile ( DatabaseConnection $connection )

Definition at line 1132 of file select.inc.

References having().

havingCondition | ( | $field,
 |  | $value = NULL,
 |  | $operator = NULL
 | ) |

Helper function to build most common HAVING conditional clauses.

This method can take a variable number of parameters. If called with two parameters, they are taken as $field and $value with $operator having a value of IN if $value is an array and = otherwise.

Parameters
$field | The name of the field to check. If you would like to add a more complex condition involving operators or functions, use having().
$value | The value to test the field against. In most cases, this is a scalar. For more complex options, it is an array. The meaning of each element in the array is dependent on the $operator.
$operator | The comparison operator, such as =, <, or >=. It also accepts more complex options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array = otherwise.
Returns
QueryConditionInterface The called object.

Implements SelectQueryInterface.

Definition at line 1114 of file select.inc.

References $value, and having().

& havingConditions ( )

Definition at line 1119 of file select.inc.

References having().

havingExists ( SelectQueryInterface $select )

Definition at line 1156 of file select.inc.

References having().

havingIsNotNull ( $field )

Definition at line 1151 of file select.inc.

References having().

havingIsNull ( $field )

Definition at line 1146 of file select.inc.

References having().

havingNotExists ( SelectQueryInterface $select )

Definition at line 1161 of file select.inc.

References having().

innerJoin | ( | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Inner Join against another table in the database.

Parameters
$table | The table against which to join.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implements SelectQueryInterface.

Definition at line 1341 of file select.inc.

References addJoin().

isNotNull ( $field )

Sets a condition that the specified field be NOT NULL.

Parameters
$field The name of the field to check.
Returns
QueryConditionInterface The called object.

Implements QueryConditionInterface.

Definition at line 1057 of file select.inc.

References where().

isNull ( $field )

Sets a condition that the specified field be NULL.

Parameters
$field The name of the field to check.
Returns
QueryConditionInterface The called object.

Implements QueryConditionInterface.

Definition at line 1052 of file select.inc.

References where().

isPrepared ( )

Indicates if preExecute() has already been called on that object.

Implements SelectQueryInterface.

Definition at line 1210 of file select.inc.

References $prepared.

join | ( | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Default Join against another table in the database.

This method is a convenience method for innerJoin().

Parameters
$table | The table against which to join.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implements SelectQueryInterface.

Definition at line 1337 of file select.inc.

References addJoin().

Referenced by _field_sql_storage_query_join_entity(), and user_build_filter_query().

leftJoin | ( | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Left Outer Join against another table in the database.

Parameters
$table | The table against which to join.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implements SelectQueryInterface.

Definition at line 1345 of file select.inc.

References addJoin().

notExists ( SelectQueryInterface $select )

Sets a condition that the specified subquery returns no values.

Parameters
SelectQueryInterface $select The subquery that must not contain results.
Returns
QueryConditionInterface The called object.

Implements QueryConditionInterface.

Definition at line 1067 of file select.inc.

References where().

orderBy | ( | $field,
 |  | $direction = 'ASC'
 | ) |

Orders the result set by a given field.

If called multiple times, the query will order by each specified field in the order this method is called.

If the query uses DISTINCT or GROUP BY conditions, fields or expressions that are used for the order must be selected to be compatible with some databases like PostgreSQL. The PostgreSQL driver can handle simple cases automatically but it is suggested to explicitly specify them. Additionally, when ordering on an alias, the alias must be added before orderBy() is called.

Parameters
$field | The field on which to order.
$direction | The direction to sort. Legal values are "ASC" and "DESC".
Returns
SelectQueryInterface The called object.

Implements SelectQueryInterface.

Definition at line 1386 of file select.inc.

Referenced by orderRandom().

orderRandom ( )

Orders the result set by a random value.

This may be stacked with other orderBy() calls. If so, the query will order by each specified field, including this one, in the order called. Although this method may be called multiple times on the same query, doing so is not particularly useful.

Note: The method used by most drivers may not scale to very large result sets. If you need to work with extremely large data sets, you may create your own database driver by subclassing off of an existing driver and implementing your own randomization mechanism. See

http://jan.kneschke.de/projects/mysql/order-by-rand/

for an example of such an alternate sorting mechanism.

Returns
SelectQueryInterface The called object

Implements SelectQueryInterface.

Definition at line 1391 of file select.inc.

References addExpression(), and orderBy().

preExecute ( SelectQueryInterface $query = NULL )

Generic preparation and validation for a SELECT query.

Returns
TRUE if the validation was successful, FALSE if not.

Implements SelectQueryInterface.

Definition at line 1220 of file select.inc.

References $prepared, $union, $value, and drupal_alter().

Referenced by execute().

range | ( | $start = NULL,
 |  | $length = NULL
 | ) |

Restricts a query to a given range in the result set.

If this method is called with no parameters, will remove any range directives that have been set.

Parameters
$start | The first record from the result set to return. If NULL, removes any range directives that are set.
$length | The number of records to return from the result set.
Returns
SelectQueryInterface The called object.

Implements SelectQueryInterface.

Definition at line 1397 of file select.inc.

Referenced by __toString().

rightJoin | ( | $table,
 |  | $alias = NULL,
 |  | $condition = NULL,
 |  | $arguments = array()
 | ) |

Right Outer Join against another table in the database.

Parameters
$table | The table against which to join.
$alias | The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table.
$condition | The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.
$arguments | An array of arguments to replace into the $condition of this join.
Returns
The unique alias that was assigned for this table.

Implements SelectQueryInterface.

Definition at line 1349 of file select.inc.

References addJoin().

union | ( | SelectQueryInterface | $query,
 |  |  | $type = ''
 | ) |  |

Add another Select query to UNION to this one.

Union queries consist of two or more queries whose results are effectively concatenated together. Queries will be UNIONed in the order they are specified, with this object's query coming first. Duplicate columns will be discarded. All forms of UNION are supported, using the second '$type' argument.

Note: All queries UNIONed together must have the same field structure, in the same order. It is up to the caller to ensure that they match properly. If they do not, an SQL syntax error will result.

Parameters
$query | The query to UNION to this query.
$type | The type of UNION to add to the query. Defaults to plain UNION.
Returns
SelectQueryInterface The called object.

Implements SelectQueryInterface.

Definition at line 1402 of file select.inc.

where | ( | $snippet,
 |  | $args = array()
 | ) |

Adds an arbitrary WHERE clause to the query.

Parameters
$snippet | A portion of a WHERE clause as a prepared statement. It must use named placeholders, not ? placeholders.
$args | An associative array of arguments.
Returns
QueryConditionInterface The called object.

Implements QueryConditionInterface.

Definition at line 1047 of file select.inc.

References $snippet.

Referenced by __clone(), __construct(), __toString(), _field_sql_storage_query_field_conditions(), arguments(), compile(), compiled(), condition(), conditions(), exists(), isNotNull(), isNull(), and notExists().

Member Data Documentation

$distinct = FALSE
protected

Definition at line 933 of file select.inc.

Referenced by distinct().

$expressions = array()
protected

Definition at line 873 of file select.inc.

Referenced by countQuery(), and getExpressions().

$fields = array()
protected

Definition at line 866 of file select.inc.

Referenced by __toString(), countQuery(), fields(), and getFields().

$forUpdate = FALSE
protected

The FOR UPDATE status

Definition at line 964 of file select.inc.

$group = array()
protected

Definition at line 912 of file select.inc.

Referenced by getGroupBy().

$having
protected

Definition at line 926 of file select.inc.

Referenced by __toString(), and countQuery().

$order = array()
protected

Definition at line 905 of file select.inc.

Referenced by getOrderBy().

$prepared = FALSE
protected

Definition at line 959 of file select.inc.

Referenced by isPrepared(), and preExecute().

$range
protected

Definition at line 940 of file select.inc.

$tables = array()
protected

Definition at line 895 of file select.inc.

Referenced by getTables().

$union = array()
protected

Definition at line 953 of file select.inc.

Referenced by __toString(), arguments(), compile(), compiled(), getUnion(), and preExecute().

$where
protected

Definition at line 919 of file select.inc.

Referenced by __toString().

class DatabaseConnection_sqlite

Specific SQLite implementation of DatabaseConnection.

Definition at line 18 of file database.inc.

Inheritance diagram for DatabaseConnection_sqlite:
DatabaseConnection

Public Member Functions

__construct (array $connection_options=array())
__destruct ()
sqlFunctionIf ($condition, $expr1, $expr2=NULL)
sqlFunctionGreatest ()
sqlFunctionConcat ()
sqlFunctionSubstring ($string, $from, $length)
sqlFunctionSubstringIndex ($string, $delimiter, $count)
sqlFunctionRand ($seed=NULL)
prepare ($query, $options=array())
PDOPrepare ($query, array $options=array())
queryRange ($query, $from, $count, array $args=array(), array $options=array())
queryTemporary ($query, array $args=array(), array $options=array())
driver ()
databaseType ()
mapConditionOperator ($operator)
prepareQuery ($query)
nextId ($existing_id=0)
rollback ($savepoint_name= 'drupal_transaction')
pushTransaction ($name)
popTransaction ($name)
- Public Member Functions inherited from DatabaseConnection
__construct ($dsn, $username, $password, $driver_options=array())
destroy ()
getConnectionOptions ()
prefixTables ($sql)
tablePrefix ($table= 'default')
prepareQuery ($query)
setTarget ($target=NULL)
getTarget ()
setKey ($key)
getKey ()
setLogger (DatabaseLog $logger)
getLogger ()
makeSequenceName ($table, $field)
makeComment ($comments)
query ($query, array $args=array(), $options=array())
getDriverClass ($class, array $files=array(), $use_autoload=FALSE)
select ($table, $alias=NULL, array $options=array())
insert ($table, array $options=array())
merge ($table, array $options=array())
update ($table, array $options=array())
delete ($table, array $options=array())
truncate ($table, array $options=array())
schema ()
escapeTable ($table)
escapeField ($field)
escapeAlias ($field)
escapeLike ($string)
inTransaction ()
transactionDepth ()
startTransaction ($name= '')
rollback ($savepoint_name= 'drupal_transaction')
pushTransaction ($name)
popTransaction ($name)
queryRange ($query, $from, $count, array $args=array(), array $options=array())
queryTemporary ($query, array $args=array(), array $options=array())
driver ()
version ()
supportsTransactions ()
supportsTransactionalDDL ()
databaseType ()
mapConditionOperator ($operator)
commit ()
nextId ($existing_id=0)

Public Attributes

$tableDropped = FALSE

Protected Attributes

$savepointSupport = FALSE
$willRollback
$attachedDatabases = array()
- Protected Attributes inherited from DatabaseConnection
$target = NULL
$key = NULL
$logger = NULL
$transactionLayers = array()
$driverClasses = array()
$statementClass = 'DatabaseStatementBase'
$transactionSupport = TRUE
$transactionalDDLSupport = FALSE
$temporaryNameIndex = 0
$connectionOptions = array()
$schema = NULL
$prefixes = array()
$prefixSearch = array()
$prefixReplace = array()

Additional Inherited Members

- Protected Member Functions inherited from DatabaseConnection
defaultOptions ()
setPrefix ($prefix)
filterComment ($comment= '')
expandArguments (&$query, &$args)
popCommittableTransactions ()
generateTemporaryTableName ()

Constructor & Destructor Documentation

__construct ( array $connection_options = array() )

Definition at line 57 of file database.inc.

References DatabaseConnection\$prefixes, DatabaseConnection\query(), and DatabaseConnection\setPrefix().

__destruct ( )

Destructor for the SQLite connection.

We prune empty databases on destruct, but only if tables have been dropped. This is especially needed when running the test suite, which creates and destroy databases several times in a row.

Definition at line 123 of file database.inc.

References DatabaseConnection\query().

Member Function Documentation

databaseType ( )

Definition at line 261 of file database.inc.

driver ( )

Definition at line 257 of file database.inc.

mapConditionOperator ( $operator )

Definition at line 265 of file database.inc.

nextId ( $existing_id = 0 )

Definition at line 278 of file database.inc.

References DatabaseConnection\query(), and DatabaseConnection\startTransaction().

PDOPrepare | ( |  | $query,
 |  | array | $options = array()
 | ) |  |

NEVER CALL THIS FUNCTION: YOU MIGHT DEADLOCK YOUR PHP PROCESS.

This is a wrapper around the parent PDO::prepare method. However, as the PDO SQLite driver only closes SELECT statements when the PDOStatement destructor is called and SQLite does not allow data change (INSERT, UPDATE etc) on a table which has open SELECT statements, you should never call this function and keep a PDOStatement object alive as that can lead to a deadlock. This really, really should be private, but as DatabaseStatement_sqlite needs to call it, we have no other choice but to expose this function to the world.

Definition at line 237 of file database.inc.

popTransaction ( $name )

Definition at line 349 of file database.inc.

References $name, DatabaseConnection\inTransaction(), and DatabaseConnection\supportsTransactions().

prepare | ( | $query,
 |  | $options = array()
 | ) |

SQLite-specific implementation of DatabaseConnection::prepare().

We don't use prepared statements at all at this stage. We just create a DatabaseStatement_sqlite object, that will create a PDOStatement using the semi-private PDOPrepare() method below.

Definition at line 221 of file database.inc.

Referenced by prepareQuery().

prepareQuery ( $query )

Definition at line 274 of file database.inc.

References DatabaseConnection\prefixTables(), and prepare().

pushTransaction ( $name )

Definition at line 333 of file database.inc.

References $name, DatabaseConnection\inTransaction(), and DatabaseConnection\supportsTransactions().

queryRange | ( |  | $query,
 |  |  | $from,
 |  |  | $count,
 |  | array | $args = array(),
 |  | array | $options = array()
 | ) |  |

Definition at line 241 of file database.inc.

References DatabaseConnection\query().

queryTemporary | ( |  | $query,
 |  | array | $args = array(),
 |  | array | $options = array()
 | ) |  |

Definition at line 245 of file database.inc.

References DatabaseConnection\$prefixes, DatabaseConnection\generateTemporaryTableName(), DatabaseConnection\query(), and DatabaseConnection\setPrefix().

rollback ( $savepoint_name = 'drupal_transaction' )

Definition at line 299 of file database.inc.

References DatabaseConnection\inTransaction(), and DatabaseConnection\supportsTransactions().

sqlFunctionConcat ( )

SQLite compatibility implementation for the CONCAT() SQL function.

Definition at line 174 of file database.inc.

sqlFunctionGreatest ( )

SQLite compatibility implementation for the GREATEST() SQL function.

Definition at line 156 of file database.inc.

sqlFunctionIf | ( | $condition,
 |  | $expr1,
 |  | $expr2 = NULL
 | ) |

SQLite compatibility implementation for the IF() SQL function.

Definition at line 149 of file database.inc.

sqlFunctionRand ( $seed = NULL )

SQLite compatibility implementation for the RAND() SQL function.

Definition at line 207 of file database.inc.

sqlFunctionSubstring | ( | $string,
 |  | $from,
 |  | $length
 | ) |

SQLite compatibility implementation for the SUBSTRING() SQL function.

Definition at line 182 of file database.inc.

sqlFunctionSubstringIndex | ( | $string,
 |  | $delimiter,
 |  | $count
 | ) |

SQLite compatibility implementation for the SUBSTRING_INDEX() SQL function.

Definition at line 189 of file database.inc.

Member Data Documentation

$attachedDatabases = array()
protected

Definition at line 43 of file database.inc.

$savepointSupport = FALSE
protected

Definition at line 28 of file database.inc.

$tableDropped = FALSE

Definition at line 55 of file database.inc.

$willRollback
protected

Definition at line 35 of file database.inc.

class DatabaseStatement_sqlite

Specific SQLite implementation of DatabaseConnection.

See DatabaseConnection_sqlite::PDOPrepare() for reasons why we must prefetch the data instead of using PDOStatement.

See Also
DatabaseConnection_sqlite::PDOPrepare()

Definition at line 391 of file database.inc.

Inheritance diagram for DatabaseStatement_sqlite:
DatabaseStatementPrefetch DatabaseStatementInterface DatabaseStatementInterface

Public Member Functions

execute ($args=array(), $options=array())
- Public Member Functions inherited from DatabaseStatementPrefetch
__construct (DatabaseConnection $connection, $query, array $driver_options=array())
execute ($args=array(), $options=array())
getQueryString ()
setFetchMode ($fetchStyle, $a2=NULL, $a3=NULL)
current ()
key ()
rewind ()
next ()
valid ()
rowCount ()
fetch ($fetch_style=NULL, $cursor_orientation=PDO::FETCH_ORI_NEXT, $cursor_offset=NULL)
fetchColumn ($index=0)
fetchField ($index=0)
fetchObject ($class_name=NULL, $constructor_args=array())
fetchAssoc ()
fetchAll ($fetch_style=NULL, $fetch_column=NULL, $constructor_args=NULL)
fetchCol ($index=0)
fetchAllKeyed ($key_index=0, $value_index=1)
fetchAllAssoc ($key, $fetch_style=NULL)

Protected Member Functions

getStatement ($query, &$args=array())
- Protected Member Functions inherited from DatabaseStatementPrefetch
throwPDOException ()
getStatement ($query, &$args=array())

Additional Inherited Members

- Public Attributes inherited from DatabaseStatementPrefetch
$dbh
- Protected Attributes inherited from DatabaseStatementPrefetch
$queryString
$driverOptions
$data = array()
$currentRow = NULL
$currentKey = NULL
$columnNames = NULL
$rowCount = NULL
$resultRowCount = 0
$fetchStyle = PDO::FETCH_OBJ
$fetchOptions
$defaultFetchStyle = PDO::FETCH_OBJ
$defaultFetchOptions

Member Function Documentation

execute | ( | $args = array(),
 |  | $options = array()
 | ) |

Executes a prepared statement

Parameters
$args | An array of values with as many elements as there are bound parameters in the SQL statement being executed.
$options | An array of options for this query.
Returns
TRUE on success, or FALSE on failure.

Implements DatabaseStatementInterface.

Definition at line 459 of file database.inc.

References DatabaseStatementPrefetch\$currentRow, and $row.

getStatement | ( |  | $query,
 |  | & | $args = array()
 | ) |  |
protected

SQLite specific implementation of getStatement().

The PDO SQLite layer doesn't replace numeric placeholders in queries correctly, and this makes numeric expressions (such as COUNT(*) >= :count) fail. We replace numeric placeholders in the query ourselves to work around this bug.

See http://bugs.php.net/bug.php?id=45259 for more details.

Definition at line 403 of file database.inc.

References $value.

class InsertQuery_sqlite

SQLite specific implementation of InsertQuery.

We ignore all the default fields and use the clever SQLite syntax: INSERT INTO table DEFAULT VALUES for degenerated "default only" queries.

Definition at line 20 of file query.inc.

Inheritance diagram for InsertQuery_sqlite:
InsertQuery Query QueryPlaceholderInterface

Public Member Functions

execute ()
__toString ()
- Public Member Functions inherited from InsertQuery
__construct ($connection, $table, array $options=array())
fields (array $fields, array $values=array())
values (array $values)
useDefaults (array $fields)
from (SelectQueryInterface $query)
execute ()
__toString ()
preExecute ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Additional Inherited Members

- Protected Member Functions inherited from Query
execute ()
- Protected Attributes inherited from InsertQuery
$table
$insertFields = array()
$defaultFields = array()
$insertValues = array()
$fromQuery
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Member Function Documentation

__toString ( )

Definition at line 34 of file query.inc.

References Query\$comments, and InsertQuery\$fromQuery.

execute ( )

Definition at line 22 of file query.inc.

References InsertQuery\preExecute().

class UpdateQuery_sqlite

SQLite specific implementation of UpdateQuery.

SQLite counts all the rows that match the conditions as modified, even if they will not be affected by the query. We workaround this by ensuring that we don't select those rows.

A query like this one: UPDATE test SET col1 = 'newcol1', col2 = 'newcol2' WHERE tid = 1 will become: UPDATE test SET col1 = 'newcol1', col2 = 'newcol2' WHERE tid = 1 AND (col1 <> 'newcol1' OR col2 <> 'newcol2')

Definition at line 65 of file query.inc.

Inheritance diagram for UpdateQuery_sqlite:
UpdateQuery Query QueryConditionInterface QueryPlaceholderInterface

Public Member Functions

execute ()
- Public Member Functions inherited from UpdateQuery
__construct (DatabaseConnection $connection, $table, array $options=array())
condition ($field, $value=NULL, $operator=NULL)
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
& conditions ()
arguments ()
where ($snippet, $args=array())
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
fields (array $fields)
expression ($field, $expression, array $arguments=NULL)
execute ()
__toString ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Additional Inherited Members

- Protected Member Functions inherited from Query
execute ()
- Protected Attributes inherited from UpdateQuery
$table
$fields = array()
$arguments = array()
$condition
$expressionFields = array()
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Member Function Documentation

execute ( )

Definition at line 66 of file query.inc.

References UpdateQuery\$condition, UpdateQuery\$fields, and UpdateQuery\condition().

class DeleteQuery_sqlite

SQLite specific implementation of DeleteQuery.

When the WHERE is omitted from a DELETE statement and the table being deleted has no triggers, SQLite uses an optimization to erase the entire table content without having to visit each row of the table individually.

Prior to SQLite 3.6.5, SQLite does not return the actual number of rows deleted by that optimized "truncate" optimization.

Definition at line 110 of file query.inc.

Inheritance diagram for DeleteQuery_sqlite:
DeleteQuery Query QueryConditionInterface QueryPlaceholderInterface

Public Member Functions

execute ()
- Public Member Functions inherited from DeleteQuery
__construct (DatabaseConnection $connection, $table, array $options=array())
condition ($field, $value=NULL, $operator=NULL)
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
& conditions ()
arguments ()
where ($snippet, $args=array())
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
execute ()
__toString ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Additional Inherited Members

- Protected Member Functions inherited from Query
execute ()
- Protected Attributes inherited from DeleteQuery
$table
$condition
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Member Function Documentation

execute ( )

Definition at line 111 of file query.inc.

References DeleteQuery\condition().

class TruncateQuery_sqlite

SQLite specific implementation of TruncateQuery.

SQLite doesn't support TRUNCATE, but a DELETE query with no condition has exactly the effect (it is implemented by DROPing the table).

Definition at line 129 of file query.inc.

Inheritance diagram for TruncateQuery_sqlite:
TruncateQuery Query QueryPlaceholderInterface

Public Member Functions

__toString ()
- Public Member Functions inherited from TruncateQuery
__construct (DatabaseConnection $connection, $table, array $options=array())
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
execute ()
__toString ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Additional Inherited Members

- Protected Member Functions inherited from Query
execute ()
- Protected Attributes inherited from TruncateQuery
$table
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Member Function Documentation

__toString ( )

Definition at line 130 of file query.inc.

References Query\$comments.

class SelectQuery_sqlite

SQLite specific query builder for SELECT statements.

Definition at line 16 of file select.inc.

Inheritance diagram for SelectQuery_sqlite:
SelectQuery Query SelectQueryInterface QueryPlaceholderInterface QueryConditionInterface QueryAlterableInterface QueryExtendableInterface QueryPlaceholderInterface

Public Member Functions

forUpdate ($set=TRUE)
- Public Member Functions inherited from SelectQuery
__construct ($table, $alias=NULL, DatabaseConnection $connection, $options=array())
addTag ($tag)
hasTag ($tag)
hasAllTags ()
hasAnyTag ()
addMetaData ($key, $object)
getMetaData ($key)
condition ($field, $value=NULL, $operator=NULL)
& conditions ()
arguments ()
where ($snippet, $args=array())
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
havingCondition ($field, $value=NULL, $operator=NULL)
& havingConditions ()
havingArguments ()
having ($snippet, $args=array())
havingCompile (DatabaseConnection $connection)
extend ($extender_name)
havingIsNull ($field)
havingIsNotNull ($field)
havingExists (SelectQueryInterface $select)
havingNotExists (SelectQueryInterface $select)
forUpdate ($set=TRUE)
& getFields ()
& getExpressions ()
& getOrderBy ()
& getGroupBy ()
& getTables ()
& getUnion ()
getArguments (QueryPlaceholderInterface $queryPlaceholder=NULL)
isPrepared ()
preExecute (SelectQueryInterface $query=NULL)
execute ()
distinct ($distinct=TRUE)
addField ($table_alias, $field, $alias=NULL)
fields ($table_alias, array $fields=array())
addExpression ($expression, $alias=NULL, $arguments=array())
join ($table, $alias=NULL, $condition=NULL, $arguments=array())
innerJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
leftJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
rightJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
addJoin ($type, $table, $alias=NULL, $condition=NULL, $arguments=array())
orderBy ($field, $direction= 'ASC')
orderRandom ()
range ($start=NULL, $length=NULL)
union (SelectQueryInterface $query, $type= '')
groupBy ($field)
countQuery ()
__toString ()
__clone ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Additional Inherited Members

- Protected Member Functions inherited from Query
execute ()
- Protected Attributes inherited from SelectQuery
$fields = array()
$expressions = array()
$tables = array()
$order = array()
$group = array()
$where
$having
$distinct = FALSE
$range
$union = array()
$prepared = FALSE
$forUpdate = FALSE
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Member Function Documentation

forUpdate ( $set = TRUE )

Add FOR UPDATE to the query.

FOR UPDATE prevents the rows retrieved by the SELECT statement from being modified or deleted by other transactions until the current transaction ends. Other transactions that attempt UPDATE, DELETE, or SELECT FOR UPDATE of these rows will be blocked until the current transaction ends.

Parameters
$set IF TRUE, FOR UPDATE will be added to the query, if FALSE then it won't.
Returns
QueryConditionInterface The called object.

Implements SelectQueryInterface.

Definition at line 17 of file select.inc.

Function Documentation

db_and ( )

Returns a new DatabaseCondition, set to "AND" all conditions together.

Returns
DatabaseCondition

Definition at line 2671 of file database.inc.

Referenced by _block_rehash(), _locale_translate_seek(), _menu_navigation_links_rebuild(), _node_query_node_access_alter(), hook_query_TAG_alter(), node_access(), node_access_view_all_nodes(), and SearchQuery\parseSearchExpression().

db_close ( array $options = array() )

Closes the active database connection.

Parameters
$options An array of options to control which connection is closed. Only the target key has any meaning in this case.

Definition at line 2631 of file database.inc.

References Database\closeConnection().

Referenced by DatabaseTasks_pgsql\checkBinaryOutput().

db_condition ( $conjunction )

Returns a new DatabaseCondition, set to the specified conjunction.

Internal API function call. The db_and(), db_or(), and db_xor() functions are preferred.

Parameters
$conjunction The conjunction to use for query conditions (AND, OR or XOR).
Returns
DatabaseCondition

Definition at line 2694 of file database.inc.

Referenced by system_update_7003().

db_delete | ( |  | $table,
 |  | array | $options = array()
 | ) |  |

Returns a new DeleteQuery object for the active database.

Parameters
$table | The table from which to delete.
$options | An array of options to control how the query operates.
Returns
DeleteQuery A new DeleteQuery object for this connection.

Definition at line 2477 of file database.inc.

References Database\getConnection().

Referenced by _batch_finished(), _block_rehash(), _drupal_session_destroy(), _drupal_session_garbage_collection(), _locale_import_one_string_db(), _menu_delete_item(), _registry_parse_file(), _registry_update(), _tracker_remove(), _update_7000_field_delete_field(), _update_7000_field_delete_instance(), _update_7000_field_sql_storage_write(), _update_authorize_clear_update_status(), _update_cache_clear(), actions_delete(), aggregator_aggregator_remove(), aggregator_categorize_items_submit(), aggregator_expire(), aggregator_save_category(), aggregator_save_feed(), aggregator_save_item(), ajax_example_node_delete(), block_admin_configure_submit(), block_custom_block_delete_submit(), block_menu_delete(), block_modules_uninstalled(), block_user_role_delete(), book_node_delete(), book_remove_form_submit(), book_uninstall(), DrupalDatabaseCache\clear(), comment_delete_multiple(), comment_node_delete(), contact_category_delete_form_submit(), dblog_clear_log_submit(), dblog_cron(), dbtng_example_entry_delete(), EntityExampleBasicController\delete_multiple(), DrupalTestCase\deleteAssert(), SystemQueue\deleteItem(), SystemQueue\deleteQueue(), drupal_session_destroy_uid(), field_create_field(), field_purge_field(), field_purge_instance(), field_sql_storage_field_storage_delete_revision(), field_sql_storage_field_storage_purge(), field_sql_storage_field_storage_write(), file_delete(), file_usage_delete(), filter_update_7003(), flood_clear_event(), forum_field_storage_pre_update(), forum_node_delete(), forum_node_update(), forum_update_7011(), DrupalDatabaseCache\garbageCollection(), hook_actions_delete(), hook_cron(), hook_delete(), hook_entity_delete(), hook_field_purge_field(), hook_field_purge_instance(), hook_field_storage_delete_revision(), hook_field_storage_pre_update(), hook_field_storage_purge(), hook_field_storage_purge_field_instance(), hook_field_storage_write(), hook_field_update(), hook_file_delete(), hook_menu_link_delete(), hook_modules_uninstalled(), hook_node_delete(), hook_node_revision_delete(), hook_path_delete(), hook_taxonomy_term_delete(), hook_taxonomy_vocabulary_delete(), hook_user_cancel(), hook_user_delete(), hook_user_role_delete(), image_default_style_revert(), image_effect_delete(), image_style_delete(), locale_date_format_reset_form_submit(), locale_languages_delete_form_submit(), locale_translate_delete_form_submit(), locale_translate_edit_form_submit(), locale_update_7004(), lock_may_be_available(), lock_release(), lock_release_all(), menu_delete(), node_access_example_node_delete(), node_access_rebuild(), node_access_write_grants(), node_cron(), node_delete_multiple(), node_form_block_admin_configure_submit(), node_form_block_custom_block_delete_submit(), node_modules_uninstalled(), node_revision_delete(), node_type_delete(), node_user_cancel(), node_user_delete(), nodeapi_example_node_delete(), openid_association(), openid_cron(), openid_user_delete_form_submit(), openid_verify_assertion(), path_delete(), poll_cancel(), poll_delete(), poll_update(), poll_update_7001(), poll_user_delete(), profile_field_delete_submit(), profile_user_cancel(), profile_user_delete(), rdf_mapping_delete(), shortcut_set_delete(), shortcut_set_unassign_user(), simpletest_clean_results_table(), statistics_cron(), statistics_node_delete(), statistics_user_delete(), system_cron(), system_date_format_delete(), system_date_format_type_delete(), system_ip_blocking_delete_submit(), system_update_7003(), system_update_7061(), system_update_7063(), system_update_7065(), system_update_files_database(), taxonomy_delete_node_index(), taxonomy_taxonomy_term_delete(), taxonomy_term_delete(), taxonomy_term_save(), taxonomy_update_7011(), taxonomy_vocabulary_delete(), tracker_cron(), tracker_node_delete(), trigger_actions_delete(), trigger_assign_form_submit(), trigger_unassign_submit(), update_fix_d7_block_deltas(), user_delete_multiple(), user_modules_uninstalled(), user_role_delete(), user_role_revoke_permissions(), user_save(), user_set_authmaps(), and variable_del().

db_driver ( )

Retrieves the name of the currently active database driver.

Returns
The name of the currently active database driver.

Definition at line 2620 of file database.inc.

References Database\getConnection().

Referenced by system_update_7016(), and update_prepare_d7_bootstrap().

db_escape_field ( $field )

Restricts a dynamic column or constraint name to safe characters.

Only keeps alphanumeric and underscores.

Parameters
$field The field name to escape.
Returns
The escaped field name as a string.

Definition at line 2581 of file database.inc.

References Database\getConnection().

db_escape_table ( $table )

Restricts a dynamic table name to safe characters.

Only keeps alphanumeric and underscores.

Parameters
$table The table name to escape.
Returns
The escaped table name as a string.

Definition at line 2566 of file database.inc.

References Database\getConnection().

Referenced by DrupalDatabaseCache\getMultiple().

db_insert | ( |  | $table,
 |  | array | $options = array()
 | ) |  |

Returns a new InsertQuery object for the active database.

Parameters
$table | The table into which to insert.
$options | An array of options to control how the query operates.
Returns
InsertQuery A new InsertQuery object for this connection.

Definition at line 2423 of file database.inc.

References Database\getConnection().

Referenced by _book_update_outline(), _locale_import_one_string_db(), _locale_parse_js_file(), _menu_router_save(), _openid_invalid_openid_transition(), _update_7000_field_create_field(), _update_7000_field_create_instance(), _update_7000_field_sql_storage_write(), _update_create_fetch_task(), actions_synchronize(), aggregator_categorize_items_submit(), aggregator_save_category(), aggregator_save_feed(), aggregator_save_item(), ajax_example_node_insert(), batch_process(), block_add_block_form_submit(), block_admin_configure_submit(), block_update_7004(), comment_enable(), comment_node_insert(), comment_update_7006(), contact_install(), SystemQueue\createItem(), dbtng_example_entry_insert(), dbtng_example_install(), drupal_install_system(), drupal_write_record(), field_sql_storage_field_storage_write(), filter_update_7001(), filter_update_7003(), filter_update_7005(), flood_register_event(), forum_field_storage_pre_insert(), forum_field_storage_pre_update(), forum_node_insert(), forum_node_update(), forum_update_7001(), hook_entity_insert(), hook_field_insert(), hook_field_storage_pre_insert(), hook_field_storage_pre_update(), hook_field_storage_write(), hook_field_update(), hook_insert(), hook_install(), hook_node_insert(), hook_path_insert(), hook_taxonomy_term_insert(), hook_user_insert(), hook_user_logout(), hook_user_role_insert(), hook_user_update(), DrupalTestCase\insertAssert(), locale_add_language(), locale_install(), locale_translate_edit_form_submit(), lock_acquire(), menu_link_save(), minimal_install(), node_access_example_node_insert(), node_access_rebuild(), node_access_write_grants(), node_form_block_admin_configure_submit(), node_install(), node_type_save(), nodeapi_example_node_insert(), openid_association(), openid_user_identities(), openid_verify_assertion_nonce(), poll_insert(), poll_vote(), profile_field_form_submit(), simpletest_run_tests(), standard_install(), statistics_exit(), system_block_ip_action(), system_ip_blocking_form_submit(), system_update_7003(), system_update_7007(), system_update_7011(), system_update_7029(), system_update_7036(), system_update_7053(), system_update_7061(), system_update_files_database(), tabledrag_example_install(), tablesort_example_install(), taxonomy_term_save(), taxonomy_update_7005(), tracker_cron(), trigger_assign_form_submit(), update_fix_d7_install_profile(), update_fix_d7_requirements(), user_install(), and user_save().

db_like ( $string )

Escapes characters that work as wildcard characters in a LIKE pattern.

The wildcard characters "%" and "_" as well as backslash are prefixed with a backslash. Use this to do a search for a verbatim string without any wildcard behavior.

For example, the following does a case-insensitive query for all rows whose name starts with $prefix:

* $result = db_query(
* 'SELECT * FROM person WHERE name LIKE :pattern',
* array(':pattern' => db_like($prefix) . '%')
* );
*

Backslash is defined as escape character for LIKE patterns in DatabaseCondition::mapConditionOperator().

Parameters
$string The string to escape.
Returns
The escaped string.

Definition at line 2610 of file database.inc.

References Database\getConnection().

Referenced by _locale_translate_seek(), _profile_get_fields(), EntityFieldQuery\addCondition(), ajax_example_node_by_author_autocomplete_validate(), ajax_example_node_by_author_node_autocomplete_callback(), ajax_example_simple_user_autocomplete_callback(), ajax_example_unique_autocomplete_validate(), ajax_example_unique_node_autocomplete_callback(), TaxonomyTermController\buildQuery(), DrupalDatabaseCache\clear(), comment_form_validate(), profile_admin_settings_autocomplete(), profile_autocomplete(), profile_browse(), taxonomy_autocomplete(), update_fix_d7_block_deltas(), user_account_form_validate(), user_autocomplete(), user_is_blocked(), user_search_execute(), and user_update_7017().

db_merge | ( |  | $table,
 |  | array | $options = array()
 | ) |  |

Returns a new MergeQuery object for the active database.

Parameters
$table | The table into which to merge.
$options | An array of options to control how the query operates.
Returns
MergeQuery A new MergeQuery object for this connection.

Definition at line 2441 of file database.inc.

References Database\getConnection().

Referenced by _drupal_session_write(), _registry_parse_file(), _registry_parse_files(), _tracker_add(), _update_7000_user_role_grant_permissions(), _update_cache_set(), actions_save(), aggregator_refresh(), aggregator_save_category(), aggregator_save_item(), block_add_block_form_submit(), block_admin_configure_submit(), contact_update_7002(), dashboard_update(), file_usage_add(), filter_format_save(), hook_user_role_update(), locale(), menu_save(), node_tag_new(), poll_update(), profile_save_profile(), rdf_mapping_save(), DrupalDatabaseCache\set(), shortcut_set_assign_user(), statistics_exit(), system_update_7061(), user_role_grant_permissions(), user_set_authmaps(), and variable_set().

db_next_id ( $existing_id = 0 )

Retrieves a unique id.

Use this function if for some reason you can't use a serial field. Using a serial field is preferred, and InsertQuery::execute() returns the value of the last ID inserted.

Parameters
$existing_id After a database import, it might be that the sequences table is behind, so by passing in a minimum ID, it can be assured that we never issue the same ID.
Returns
An integer number larger than any number returned before for this sequence.

Definition at line 2653 of file database.inc.

References Database\getConnection().

Referenced by actions_save(), batch_process(), and user_save().

db_or ( )

Returns a new DatabaseCondition, set to "OR" all conditions together.

Returns
DatabaseCondition

Definition at line 2662 of file database.inc.

Referenced by _block_rehash(), _locale_translate_seek(), _menu_navigation_links_rebuild(), _node_query_node_access_alter(), _update_authorize_clear_update_status(), SearchQuery\executeFirstPass(), hook_query_TAG_alter(), node_access(), node_access_view_all_nodes(), node_admin_nodes(), node_get_recent(), SearchQuery\parseSearchExpression(), SearchQuery\setOption(), statistics_node_tracker(), system_update_7015(), system_update_7053(), system_update_files_database(), and user_search_execute().

db_query | ( |  | $query,
 |  | array | $args = array(),
 |  | array | $options = array()
 | ) |  |

The following utility functions are simply convenience wrappers.

They should never, ever have any database-specific code in them. Executes an arbitrary query string against the active database.

Use this function for SELECT queries if it is just a simple query string. If the caller or other modules need to change the query, use db_select() instead.

Do not use this function for INSERT, UPDATE, or DELETE queries. Those should be handled via db_insert(), db_update() and db_delete() respectively.

Parameters
$query | The prepared statement query to run. Although it will accept both named and unnamed placeholders, named placeholders are strongly preferred as they are more self-documenting.
$args | An array of values to substitute into the query. If the query uses named placeholders, this is an associative array in any order. If the query uses unnamed placeholders (?), this is an indexed array and the order must match the order of placeholders in the query string.
$options | An array of options to control how the query operates.
Returns
DatabaseStatementInterface A prepared statement object, already executed.
See Also
DatabaseConnection::defaultOptions()

Definition at line 2342 of file database.inc.

References Database\getConnection().

Referenced by _book_update_outline(), _comment_update_node_statistics(), _dblog_get_message_types(), _drupal_session_read(), _forum_update_forum_index(), _forum_user_last_visit(), _locale_export_get_strings(), _locale_import_one_string_db(), _locale_import_po(), _locale_parse_js_file(), _locale_rebuild_js(), _menu_delete_item(), _menu_link_find_parent(), _menu_router_build(), _menu_set_expanded_menus(), _node_access_rebuild_batch_operation(), _node_revision_access(), _registry_update(), _simpletest_autoload_psr0(), _tracker_add(), _tracker_calculate_changed(), _tracker_remove(), _update_7000_node_get_types(), _update_7002_taxonomy_get_vocabularies(), _update_cache_get(), actions_do(), actions_function_lookup(), actions_get_all_actions(), actions_load(), actions_synchronize(), aggregator_aggregator_process(), aggregator_aggregator_remove(), aggregator_block_configure(), aggregator_block_info(), aggregator_block_view(), aggregator_categorize_items(), aggregator_category_load(), aggregator_cron(), aggregator_expire(), aggregator_feed_items_load(), aggregator_feed_load(), aggregator_form_category_validate(), aggregator_form_feed(), aggregator_form_feed_validate(), aggregator_form_opml(), aggregator_form_opml_submit(), aggregator_page_categories(), aggregator_page_opml(), aggregator_page_rss(), aggregator_page_sources(), aggregator_save_feed(), aggregator_save_item(), aggregator_view(), ajax_example_node_load(), UserController\attachLoad(), batch_example_batch_2(), batch_example_op_2(), batch_example_update_7100(), batch_load(), block_admin_configure(), block_block_info(), block_block_list_alter(), block_block_view(), block_custom_block_get(), block_flush_caches(), block_form_user_profile_form_alter(), block_load(), block_theme_initialize(), block_update_7004(), block_update_7005(), blocked_ip_load(), book_get_books(), book_link_load(), book_node_delete(), book_node_load(), DatabaseTasks_pgsql\checkBinaryOutput(), DatabaseTasks_pgsql\checkBinaryOutputSuccess(), DatabaseTasks_pgsql\checkEncoding(), color_update_7001(), comment_count_unpublished(), comment_delete_multiple(), comment_form_node_form_alter(), comment_multiple_delete_confirm(), comment_new_page_count(), comment_node_delete(), comment_node_load(), comment_node_search_result(), comment_node_update_index(), comment_num_new(), comment_publish_action(), comment_reply(), comment_save(), comment_unpublish_action(), comment_update_7001(), comment_update_7003(), comment_update_7006(), comment_update_index(), comment_user_delete(), contact_site_form(), dashboard_show_block_content(), dblog_event(), drupal_get_filename(), drupal_get_installed_schema_version(), drupal_is_denied(), drupal_lookup_path(), drupal_path_alias_whitelist_rebuild(), drupal_valid_path(), DrupalWebTestCase\drupalCreateRole(), field_sql_storage_update_7001(), field_update_7001(), file_example_get_managed_file(), filter_admin_format_form_validate(), filter_list_format(), filter_update_7001(), filter_update_7005(), filter_update_7008(), DatabaseSchema_sqlite\findTables(), flood_is_allowed(), forum_node_update(), BatchQueue\getAllItems(), FieldInfo\getFieldMap(), DrupalDatabaseCache\getMultiple(), hook_block_list_alter(), hook_comment_load(), hook_cron(), hook_file_load(), hook_load(), hook_menu_link_update(), hook_node_load(), hook_node_search_result(), hook_node_update_index(), hook_search_status(), hook_update_N(), hook_user_load(), image_update_7005(), DatabaseTasks_pgsql\initializeDatabase(), install_verify_completed_task(), language_list(), list_update_7001(), locale(), locale_batch_by_component(), locale_languages_edit_form(), locale_languages_edit_form_validate(), locale_languages_predefined_form_validate(), locale_translate_delete_page(), locale_translate_edit_form(), locale_translate_edit_form_submit(), locale_translate_overview_screen(), locale_uninstall(), locale_update_7004(), lock_may_be_available(), menu_delete_menu_confirm(), menu_delete_menu_confirm_submit(), menu_edit_menu_submit(), menu_enable(), menu_link_delete(), menu_link_maintain(), menu_link_save(), menu_load_all(), menu_node_delete(), menu_overview_form(), menu_overview_page(), menu_update_7000(), module_enable(), node_access_example_node_load(), node_access_example_node_update(), node_access_rebuild(), node_admin_nodes(), node_assign_owner_action(), node_assign_owner_action_form(), node_assign_owner_action_submit(), node_block_list_alter(), node_example_page(), node_form_block_admin_configure_alter(), node_get_recent(), node_last_changed(), node_last_viewed(), node_multiple_delete_confirm(), node_requirements(), node_revision_delete_confirm_submit(), node_revision_list(), node_search_status(), node_type_delete_confirm(), node_update_7006(), node_user_delete(), SystemQueue\numberOfItems(), openid_association(), openid_user_add_validate(), openid_user_delete_form(), openid_user_identities(), openid_verify_assertion(), openid_verify_assertion_nonce(), path_admin_form_validate(), poll_cron(), poll_load(), profile_admin_overview(), profile_block_configure(), profile_block_view(), profile_browse(), profile_field_delete(), profile_field_form(), profile_user_categories(), profile_user_load(), profile_user_view(), queue_example_retrieve_queue(), rdf_example_uninstall(), registry_get_parsed_files(), DatabaseTasks\runTestQuery(), DrupalWebTestCase\setUp(), shortcut_set_delete_form(), shortcut_set_get_unique_name(), simpletest_clean_results_table(), simpletest_test_get_all(), statistics_access_log(), statistics_get(), statistics_update_index(), system_actions_configure(), system_actions_manage(), system_admin_config_page(), system_admin_menu_block(), system_cron(), system_get_files_database(), system_ip_blocking(), system_ip_blocking_form_validate(), system_list(), system_update_7000(), system_update_7003(), system_update_7007(), system_update_7011(), system_update_7013(), system_update_7016(), system_update_7036(), system_update_7053(), system_update_7060(), system_update_7061(), system_update_7063(), system_update_files_database(), tabledrag_example_get_tree(), tabledrag_example_parent_form_submit(), tabledrag_example_parent_get_data(), tabledrag_example_simple_form(), tabledrag_example_simple_form_submit(), taxonomy_uninstall(), taxonomy_update_7002(), taxonomy_update_7004(), taxonomy_update_7005(), taxonomy_update_7011(), taxonomy_vocabulary_delete(), taxonomy_vocabulary_get_names(), toolbar_get_menu_tree(), tracker_enable(), tracker_page(), tracker_update_7000(), translation_remove_from_set(), trigger_assign_form_submit(), trigger_assign_form_validate(), trigger_get_assigned_actions(), trigger_update_7000(), trigger_update_7002(), update_fix_compatibility(), update_fix_d7_block_deltas(), update_fix_d7_requirements(), update_retrieve_dependencies(), user_admin_account(), user_block_view(), user_external_load(), user_get_authmaps(), user_login_authenticate_validate(), user_multiple_role_edit(), user_node_load(), user_role_permissions(), user_save(), user_update_7000(), user_update_7002(), user_update_7010(), user_update_7012(), user_update_7013(), and variable_initialize().

db_query_range | ( |  | $query,
 |  |  | $from,
 |  |  | $count,
 |  | array | $args = array(),
 |  | array | $options = array()
 | ) |  |

Executes a query against the active database, restricted to a range.

Parameters
$query | The prepared statement query to run. Although it will accept both named and unnamed placeholders, named placeholders are strongly preferred as they are more self-documenting.
$from | The first record from the result set to return.
$count | The number of records to return from the result set.
$args | An array of values to substitute into the query. If the query uses named placeholders, this is an associative array in any order. If the query uses unnamed placeholders (?), this is an indexed array and the order must match the order of placeholders in the query string.
$options | An array of options to control how the query operates.
Returns
DatabaseStatementInterface A prepared statement object, already executed.
See Also
DatabaseConnection::defaultOptions()

Definition at line 2374 of file database.inc.

References Database\getConnection().

Referenced by _aggregator_has_categories(), _comment_update_node_statistics(), _forum_update_forum_index(), _node_access_rebuild_batch_operation(), _tracker_calculate_changed(), _tracker_remove(), aggregator_block_view(), aggregator_page_categories(), aggregator_page_rss(), aggregator_page_sources(), block_add_block_form_validate(), block_admin_configure_validate(), block_theme_initialize(), BatchQueue\claimItem(), SystemQueue\claimItem(), comment_update_7006(), filter_format_exists(), forum_node_presave(), forum_node_validate(), hook_update_index(), locale_date_format_save(), menu_edit_menu_name_exists(), menu_get_item(), menu_node_prepare(), node_admin_nodes(), node_assign_owner_action_validate(), node_type_save(), node_update_index(), path_admin_overview(), php_enable(), profile_autocomplete(), profile_category_access(), shortcut_set_title_exists(), simpletest_last_test_get(), system_date_format_save(), system_update_7060(), system_update_7061(), taxonomy_update_7005(), tracker_cron(), user_block_view(), user_update_7000(), user_update_7002(), user_update_7012(), and user_update_7013().

db_query_temporary | ( |  | $query,
 |  | array | $args = array(),
 |  | array | $options = array()
 | ) |  |

Executes a query string and saves the result set to a temporary table.

The execution of the query string happens against the active database.

Parameters
$query | The prepared statement query to run. Although it will accept both named and unnamed placeholders, named placeholders are strongly preferred as they are more self-documenting.
$args | An array of values to substitute into the query. If the query uses named placeholders, this is an associative array in any order. If the query uses unnamed placeholders (?), this is an indexed array and the order must match the order of placeholders in the query string.
$options | An array of options to control how the query operates.
Returns
The name of the temporary table.
See Also
DatabaseConnection::defaultOptions()

Definition at line 2404 of file database.inc.

References Database\getConnection().

db_select | ( |  | $table,
 |  |  | $alias = NULL,
 |  | array | $options = array()
 | ) |  |

Returns a new SelectQuery object for the active database.

Parameters
$table | The base table for this query. May be a string or another SelectQuery object. If a query object is passed, it will be used as a subselect.
$alias | The alias for the base table of this query.
$options | An array of options to control how the query operates.
Returns
SelectQuery A new SelectQuery object for this connection.

Definition at line 2516 of file database.inc.

References Database\getConnection().

Referenced by _block_load_blocks(), _block_rehash(), _blog_post_exists(), _forum_topics_unread(), _image_update_7002_populate_dimensions(), _locale_translate_seek(), _menu_build_tree(), _menu_find_router_path(), _menu_link_find_parent(), _menu_navigation_links_rebuild(), _menu_update_parental_status(), _node_query_node_access_alter(), _node_types_build(), _profile_get_fields(), _rdf_mapping_load(), _token_example_get_comment(), _token_example_get_file(), _token_example_get_node(), _token_example_get_taxonomy_term(), _token_example_get_user(), _update_7000_field_delete_field(), _update_7000_field_read_fields(), _update_get_cache_multiple(), actions_do(), aggregator_feed_items_load(), ajax_example_node_by_author_autocomplete_validate(), ajax_example_node_by_author_node_autocomplete_callback(), ajax_example_node_update(), ajax_example_simple_user_autocomplete_callback(), ajax_example_unique_autocomplete_validate(), ajax_example_unique_node_autocomplete_callback(), batch_example_lowest_nid(), batch_example_op_2(), batch_example_update_7100(), blog_block_view(), blog_feed_last(), blog_feed_user(), blog_page_last(), blog_page_user(), book_block_view(), book_get_books(), book_menu_subtree_data(), book_update_bid(), DrupalDefaultEntityController\buildQuery(), comment_admin_overview(), comment_enable(), comment_form_validate(), comment_get_display_ordinal(), comment_get_recent(), comment_get_thread(), comment_new_page_count(), comment_update_7006(), contact_category_edit_form_validate(), contact_category_list(), contact_load(), contact_site_form(), SearchQuery\countQuery(), dashboard_disable(), dashboard_page_build(), dblog_cron(), dblog_overview(), dblog_top(), dbtng_example_advanced_list(), dbtng_example_entry_load(), field_read_fields(), field_read_instances(), field_sql_storage_field_storage_load(), field_sql_storage_field_storage_query(), field_sql_storage_update_7001(), field_sql_storage_update_7002(), file_space_used(), file_usage_list(), filter_formats(), filter_update_7003(), forum_block_view(), forum_forum_load(), forum_get_topics(), forum_node_load(), forum_update_7001(), forum_update_7003(), forum_update_7011(), hook_field_storage_load(), hook_field_storage_query(), hook_search_execute(), hook_taxonomy_term_load(), hook_taxonomy_vocabulary_load(), hook_update_N(), hook_user_cancel(), image_effects(), image_styles(), image_update_7002(), DrupalDatabaseCache\isEmpty(), locale_batch_by_language(), menu_contextual_links(), menu_get_names(), menu_link_children_relative_depth(), menu_link_get_preferred(), menu_link_load(), menu_load_links(), menu_local_tasks(), menu_tree_check_access(), menu_tree_page_data(), node_access(), node_access_example_private_node_listing(), node_access_view_all_nodes(), node_admin_nodes(), node_feed(), node_get_recent(), node_page_default(), node_search_execute(), node_update_7000(), node_update_7006(), node_user_cancel(), node_user_delete(), nodeapi_example_node_load(), nodeapi_example_node_update(), nodeapi_example_uninstall(), pager_example_page(), path_admin_overview(), path_form_element_validate(), path_load(), poll_block_view(), poll_load(), poll_page(), poll_votes(), profile_admin_settings_autocomplete(), profile_autocomplete(), profile_browse(), profile_field_form_validate(), EntityFieldQuery\propertyQuery(), shortcut_current_displayed_set(), shortcut_set_load(), shortcut_sets(), simpletest_result_get(), statistics_node_tracker(), statistics_recent_hits(), statistics_title_list(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), statistics_user_tracker(), system_actions_manage(), system_admin_menu_block(), system_get_module_admin_tasks(), system_update_7061(), system_update_7076(), tablesort_example_page(), taxonomy_autocomplete(), taxonomy_get_children(), taxonomy_get_parents(), taxonomy_get_tree(), taxonomy_select_nodes(), taxonomy_tokens(), taxonomy_update_7005(), tracker_cron(), tracker_page(), translation_node_get_translations(), trigger_menu_unassign_access(), update_fix_d7_block_deltas(), update_fix_d7_install_profile(), user_account_form_validate(), user_admin_account(), user_autocomplete(), user_is_blocked(), user_role_load(), user_role_load_by_name(), user_role_save(), user_roles(), user_search_execute(), and user_update_7017().

db_set_active ( $key = 'default' )

Sets a new active database.

Parameters
$key The key in the $databases array to set as the default database.
Returns
The key of the formerly active database.

Definition at line 2551 of file database.inc.

References Database\setActiveConnection().

Referenced by DatabaseTasks\connect().

db_transaction | ( |  | $name = NULL,
 |  | array | $options = array()
 | ) |  |

Returns a new transaction object for the active database.

Parameters
string $name Optional name of the transaction.
array $options An array of options to control how the transaction operates:
  • target: The database target name.
Returns
DatabaseTransaction A new DatabaseTransaction object for this connection.

Definition at line 2535 of file database.inc.

References $name, and Database\getConnection().

Referenced by _registry_update(), block_admin_configure_submit(), block_admin_display_form_submit(), comment_delete_multiple(), comment_save(), EntityExampleBasicController\delete_multiple(), field_sql_storage_field_storage_update_field(), menu_rebuild(), node_delete_multiple(), node_save(), taxonomy_term_delete(), taxonomy_vocabulary_delete(), user_delete_multiple(), and user_save().

db_truncate | ( |  | $table,
 |  | array | $options = array()
 | ) |  |

Returns a new TruncateQuery object for the active database.

Parameters
$table | The table from which to delete.
$options | An array of options to control how the query operates.
Returns
TruncateQuery A new TruncateQuery object for this connection.

Definition at line 2495 of file database.inc.

References Database\getConnection().

Referenced by _menu_router_save(), and DrupalDatabaseCache\clear().

db_update | ( |  | $table,
 |  | array | $options = array()
 | ) |  |

Returns a new UpdateQuery object for the active database.

Parameters
$table | The table to update.
$options | An array of options to control how the query operates.
Returns
UpdateQuery A new UpdateQuery object for this connection.

Definition at line 2459 of file database.inc.

References Database\getConnection().

Referenced by _batch_shutdown(), _comment_update_node_statistics(), _drupal_session_write(), _forum_update_forum_index(), _image_update_7002_populate_dimensions(), _locale_import_one_string(), _locale_import_one_string_db(), _locale_parse_js_file(), _locale_rebuild_js(), _menu_link_move_children(), _menu_navigation_links_rebuild(), _menu_update_parental_status(), _system_update_bootstrap_status(), _tracker_remove(), aggregator_block_save(), aggregator_cron(), aggregator_refresh(), aggregator_remove(), aggregator_save_feed(), ajax_example_node_update(), block_admin_configure_submit(), block_admin_display_form_submit(), block_custom_block_save(), block_install(), block_update_7000(), block_update_7004(), block_update_7005(), book_update_bid(), SystemQueue\claimItem(), comment_publish_action(), comment_unpublish_action(), comment_update_7001(), comment_update_7006(), contact_category_edit_form_submit(), contact_update_7001(), dashboard_disable(), dashboard_enable(), dbtng_example_entry_update(), drupal_session_regenerate(), drupal_set_installed_schema_version(), drupal_write_record(), DrupalWebTestCase\drupalCreateNode(), field_associate_fields(), field_attach_rename_bundle(), field_delete_field(), field_delete_instance(), field_sql_storage_field_attach_rename_bundle(), field_sql_storage_field_storage_delete_field(), field_sql_storage_field_storage_delete_instance(), field_sql_storage_update_7001(), field_sync_field_status(), field_update_7001(), file_usage_delete(), filter_admin_overview_submit(), filter_format_disable(), filter_update_7005(), forum_install(), forum_node_update(), forum_update_7003(), hook_entity_update(), hook_exit(), hook_field_storage_delete_field(), hook_field_storage_delete_instance(), hook_menu_link_update(), hook_node_update(), hook_path_update(), hook_search_reset(), hook_taxonomy_term_update(), hook_taxonomy_vocabulary_update(), hook_update(), hook_update_N(), hook_user_cancel(), image_update_7005(), install_finished(), list_update_7001(), locale(), locale_languages_delete_form_submit(), locale_languages_edit_form_submit(), locale_languages_overview_form_submit(), locale_translate_edit_form_submit(), locale_update_7001(), lock_acquire(), menu_link_save(), menu_update_7001(), module_disable(), module_enable(), node_access_example_node_update(), node_save(), node_search_reset(), node_type_save(), node_type_update_nodes(), node_update_7000(), node_update_7006(), node_update_7009(), node_update_7012(), node_user_cancel(), nodeapi_example_node_update(), poll_cancel(), poll_cron(), poll_update(), poll_update_7001(), poll_user_cancel(), poll_vote(), DrupalWebTestCase\prepareDatabasePrefix(), profile_admin_overview_submit(), profile_field_form_submit(), SystemQueue\releaseItem(), standard_install(), statistics_cron(), statistics_user_cancel(), system_cron(), system_install(), system_status(), system_update_7000(), system_update_7015(), system_update_7021(), system_update_7046(), system_update_7048(), system_update_7053(), system_update_7076(), system_update_files_database(), taxonomy_overview_terms_submit(), taxonomy_update_7002(), taxonomy_vocabulary_confirm_reset_alphabetical_submit(), theme_disable(), theme_enable(), translation_node_insert(), translation_node_update(), translation_remove_from_set(), trigger_update_7000(), trigger_update_7002(), update_fix_compatibility(), update_fix_d7_block_deltas(), user_file_delete(), user_file_move(), user_install(), user_login_finalize(), user_update_7000(), user_update_7002(), user_update_7010(), user_update_7012(), and user_update_7014().

db_xor ( )

Returns a new DatabaseCondition, set to "XOR" all conditions together.

Returns
DatabaseCondition

Definition at line 2680 of file database.inc.

Variable Documentation

const POSTGRESQL_NEXTID_LOCK 1000

The name by which to obtain a lock for retrive the next insert id.

Definition at line 16 of file database.inc.

Referenced by DatabaseConnection_pgsql\nextId().

Generated on Mon Feb 3 2014 12:40:49 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/mysql/query.inc File Reference

  • File List
  • File Members
  • includes
  • database
  • mysql
Classes
query.inc File Reference
Database abstraction layer

Go to the source code of this file.

Classes

class | InsertQuery_mysql
class | TruncateQuery_mysql

Detailed Description

Query code for MySQL embedded database engine.

Definition in file query.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/pgsql/query.inc File Reference

  • includes
  • database
  • pgsql
Classes
query.inc File Reference
Database abstraction layer

Go to the source code of this file.

Classes

class | InsertQuery_pgsql
class | UpdateQuery_pgsql

Detailed Description

Query code for PostgreSQL embedded database engine.

Definition in file query.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/query.inc File Reference

  • includes
  • database
Classes
query.inc File Reference
Database abstraction layer

Go to the source code of this file.

Classes

interface | QueryConditionInterface
interface | QueryAlterableInterface
interface | QueryPlaceholderInterface
class | Query
class | InsertQuery
class | DeleteQuery
class | TruncateQuery
class | UpdateQuery
class | MergeQuery
class | DatabaseCondition

Detailed Description

Non-specific Database query code. Used by all engines.

Definition in file query.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: Schema API

Modules | Classes | Functions | Variables
Schema API

Modules

Code registry

Classes

class | SchemaCache
class | DatabaseSchema_mysql
class | DatabaseSchema_pgsql
class | DatabaseSchema
class | DatabaseSchemaObjectExistsException
class | DatabaseSchemaObjectDoesNotExistException
class | DatabaseSchema_sqlite

Functions

__construct ($cid, $bin)
offsetExists ($offset)
offsetGet ($offset)
offsetSet ($offset, $value)
offsetUnset ($offset)
persist ($offset, $persist=TRUE)
resolveCacheMiss ($offset)
set ($data, $lock=TRUE)
__destruct ()
__construct ()
resolveCacheMiss ($offset)
& drupal_static ($name, $default_value=NULL, $reset=FALSE)
drupal_static_reset ($name=NULL)
drupal_is_cli ()
drupal_placeholder ($text)
_drupal_shutdown_function ()
drupal_check_memory_limit ($required, $memory_limit=NULL)
drupal_install_schema ($module)
drupal_uninstall_schema ($module)
drupal_get_schema_unprocessed ($module, $table=NULL)
_drupal_schema_initialize (&$schema, $module, $remove_descriptions=TRUE)
drupal_schema_fields_sql ($table, $prefix=NULL)
drupal_write_record ($table, &$record, $primary_keys=array())
db_create_table ($name, $table)
db_field_names ($fields)
db_index_exists ($table, $name)
db_table_exists ($table)
db_field_exists ($table, $field)
db_find_tables ($table_expression)
_db_create_keys_sql ($spec)
db_rename_table ($table, $new_name)
db_drop_table ($table)
db_add_field ($table, $field, $spec, $keys_new=array())
db_drop_field ($table, $field)
db_field_set_default ($table, $field, $default)
db_field_set_no_default ($table, $field)
db_add_primary_key ($table, $fields)
db_drop_primary_key ($table)
db_add_unique_key ($table, $name, $fields)
db_drop_unique_key ($table, $name)
db_add_index ($table, $name, $fields)
db_drop_index ($table, $name)
db_change_field ($table, $field, $field_new, $spec, $keys_new=array())
hook_schema ()
hook_schema_alter (&$schema)

Variables

$cid
$bin
$keysToPersist = array()
$storage = array()

into your string, and t() will

Translates a string to the current language or to a given language.

The t() function serves two purposes. First, at run-time it translates user-visible text into the appropriate language. Second, various mechanisms that figure out what text needs to be translated work off t() – the text inside t() calls is added to the database of strings to be translated. These strings are expected to be in English, so the first argument should always be in English. To enable a fully-translatable site, it is important that all human-readable text that will be displayed on the site or sent to a user is passed through the t() function, or a related function. See the Localization API pages for more information, including recommendations on how to break up or not break up strings for translation.

Translating Variables

You should never use t() to translate variables, such as calling

t($text);

, unless the text that the variable holds has been passed through t() elsewhere (e.g., $text is one of several translated literal strings in an array). It is especially important never to call

t($user_text);

, where $user_text is some text that a user entered - doing that can lead to cross-site scripting and other security problems. However, you can use variable substitution in your string, to put variable text such as user names or link URLs into translated text. Variable substitution looks like this:

* $text = t("@name's blog", array('@name' => format_username($account)));
*

Basically, you can put variables like substitute their sanitized values at translation time. (See the Localization API pages referenced above and the documentation of format_string() for details about how to define variables in your string.) Translators can then rearrange the string as necessary for the language (e.g., in Spanish, it might be "blog de @name").

Use During Installation Phase

During the Drupal installation phase, some resources used by t() wil not be available to code that needs localization. See st() and get_t() for alternatives.

Parameters
$string | A string containing the English string to translate.
$args | An associative array of replacements to make after translation. Based on the first character of the key, the value is escaped and/or themed. See format_string() for details.
$options An associative array of additional options, with the following elements:
  • 'langcode' (defaults to the current language): The language code to translate to a language other than what is used to display the page.
  • 'context' (defaults to the empty context): The context the source string belongs to.
Returns
The translated string.
See Also
st()
get_t()
format_string()
drupal_get_schema ($table=NULL, $rebuild=FALSE)
drupal_get_complete_schema ($rebuild=FALSE)

Detailed Description

API to handle database schemas.

A Drupal schema definition is an array structure representing one or more tables and their related keys and indexes. A schema is defined by hook_schema(), which usually lives in a modulename.install file.

By implementing hook_schema() and specifying the tables your module declares, you can easily create and drop these tables on all supported database engines. You don't have to deal with the different SQL dialects for table creation and alteration of the supported database engines.

hook_schema() should return an array with a key for each table that the module defines.

The following keys are defined:

  • 'description': A string in non-markup plain text describing this table and its purpose. References to other tables should be enclosed in curly-brackets. For example, the node_revisions table description field might contain "Stores per-revision title and body data for each {node}."
  • 'fields': An associative array ('fieldname' => specification) that describes the table's database columns. The specification is also an array. The following specification parameters are defined:
    • 'description': A string in non-markup plain text describing this field and its purpose. References to other tables should be enclosed in curly-brackets. For example, the node table vid field description might contain "Always holds the largest (most recent) {node_revision}.vid value for this nid."
    • 'type': The generic datatype: 'char', 'varchar', 'text', 'blob', 'int', 'float', 'numeric', or 'serial'. Most types just map to the according database engine specific datatypes. Use 'serial' for auto incrementing fields. This will expand to 'INT auto_increment' on MySQL.
    • 'mysql_type', 'pgsql_type', 'sqlite_type', etc.: If you need to use a record type not included in the officially supported list of types above, you can specify a type for each database backend. In this case, you can leave out the type parameter, but be advised that your schema will fail to load on backends that do not have a type specified. A possible solution can be to use the "text" type as a fallback.
    • 'serialize': A boolean indicating whether the field will be stored as a serialized string.
    • 'size': The data size: 'tiny', 'small', 'medium', 'normal', 'big'. This is a hint about the largest value the field will store and determines which of the database engine specific datatypes will be used (e.g. on MySQL, TINYINT vs. INT vs. BIGINT). 'normal', the default, selects the base type (e.g. on MySQL, INT, VARCHAR, BLOB, etc.). Not all sizes are available for all data types. See DatabaseSchema::getFieldTypeMap() for possible combinations.
    • 'not null': If true, no NULL values will be allowed in this database column. Defaults to false.
    • 'default': The field's default value. The PHP type of the value matters: '', '0', and 0 are all different. If you specify '0' as the default value for a type 'int' field it will not work because '0' is a string containing the character "zero", not an integer.
    • 'length': The maximal length of a type 'char', 'varchar' or 'text' field. Ignored for other field types.
    • 'unsigned': A boolean indicating whether a type 'int', 'float' and 'numeric' only is signed or unsigned. Defaults to FALSE. Ignored for other field types.
    • 'precision', 'scale': For type 'numeric' fields, indicates the precision (total number of significant digits) and scale (decimal digits right of the decimal point). Both values are mandatory. Ignored for other field types.
    • 'binary': A boolean indicating that MySQL should force 'char', 'varchar' or 'text' fields to use case-sensitive binary collation. This has no effect on other database types for which case sensitivity is already the default behavior. All parameters apart from 'type' are optional except that type 'numeric' columns must specify 'precision' and 'scale', and type 'varchar' must specify the 'length' parameter.

'primary key': An array of one or more key column specifiers (see below) that form the primary key.

  • 'unique keys': An associative array of unique keys ('keyname' => specification). Each specification is an array of one or more key column specifiers (see below) that form a unique key on the table.
  • 'foreign keys': An associative array of relations ('my_relation' => specification). Each specification is an array containing the name of the referenced table ('table'), and an array of column mappings ('columns'). Column mappings are defined by key pairs ('source_column' => 'referenced_column').
  • 'indexes': An associative array of indexes ('indexname' => specification). Each specification is an array of one or more key column specifiers (see below) that form an index on the table.

A key column specifier is either a string naming a column or an array of two elements, column name and length, specifying a prefix of the named column.

As an example, here is a SUBSET of the schema definition for Drupal's 'node' table. It show four fields (nid, vid, type, and title), the primary key on field 'nid', a unique key named 'vid' on field 'vid', and two indexes, one named 'nid' on field 'nid' and one named 'node_title_type' on the field 'title' and the first four bytes of the field 'type':

* $schema['node'] = array(
* 'description' => 'The base table for nodes.',
* 'fields' => array(
* 'nid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
* 'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,'default' => 0),
* 'type' => array('type' => 'varchar','length' => 32,'not null' => TRUE, 'default' => ''),
* 'language' => array('type' => 'varchar','length' => 12,'not null' => TRUE,'default' => ''),
* 'title' => array('type' => 'varchar','length' => 255,'not null' => TRUE, 'default' => ''),
* 'uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
* 'status' => array('type' => 'int', 'not null' => TRUE, 'default' => 1),
* 'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
* 'changed' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
* 'comment' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
* 'promote' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
* 'moderate' => array('type' => 'int', 'not null' => TRUE,'default' => 0),
* 'sticky' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
* 'tnid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
* 'translate' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
* ),
* 'indexes' => array(
* 'node_changed' => array('changed'),
* 'node_created' => array('created'),
* 'node_moderate' => array('moderate'),
* 'node_frontpage' => array('promote', 'status', 'sticky', 'created'),
* 'node_status_type' => array('status', 'type', 'nid'),
* 'node_title_type' => array('title', array('type', 4)),
* 'node_type' => array(array('type', 4)),
* 'uid' => array('uid'),
* 'tnid' => array('tnid'),
* 'translate' => array('translate'),
* ),
* 'unique keys' => array(
* 'vid' => array('vid'),
* ),
* 'foreign keys' => array(
* 'node_revision' => array(
* 'table' => 'node_revision',
* 'columns' => array('vid' => 'vid'),
* ),
* 'node_author' => array(
* 'table' => 'users',
* 'columns' => array('uid' => 'uid'),
* ),
* ),
* 'primary key' => array('nid'),
* );
*
See Also
drupal_install_schema()

End of "defgroup database".

Class Documentation

class SchemaCache

Extends DrupalCacheArray to allow for dynamic building of the schema cache.

Definition at line 2964 of file bootstrap.inc.

Inheritance diagram for SchemaCache:
DrupalCacheArray

Public Member Functions

__construct ()
- Public Member Functions inherited from DrupalCacheArray
__construct ($cid, $bin)
offsetExists ($offset)
offsetGet ($offset)
offsetSet ($offset, $value)
offsetUnset ($offset)
__destruct ()
__construct ($cid, $bin)
initializeRegistry ()
offsetExists ($offset)
offsetGet ($offset)
resolveCacheMiss ($offset)
set ($data, $lock=TRUE)

Protected Member Functions

resolveCacheMiss ($offset)
- Protected Member Functions inherited from DrupalCacheArray
persist ($offset, $persist=TRUE)
resolveCacheMiss ($offset)
set ($data, $lock=TRUE)

Additional Inherited Members

- Protected Attributes inherited from DrupalCacheArray
$cid
$bin
$keysToPersist = array()
$storage = array()
$persistable
$completeRegistry
class DatabaseSchema_mysql

Definition at line 14 of file schema.inc.

Inheritance diagram for DatabaseSchema_mysql:
DatabaseSchema QueryPlaceholderInterface

Public Member Functions

getFieldTypeMap ()
renameTable ($table, $new_name)
dropTable ($table)
addField ($table, $field, $spec, $keys_new=array())
dropField ($table, $field)
fieldSetDefault ($table, $field, $default)
fieldSetNoDefault ($table, $field)
indexExists ($table, $name)
addPrimaryKey ($table, $fields)
dropPrimaryKey ($table)
addUniqueKey ($table, $name, $fields)
dropUniqueKey ($table, $name)
addIndex ($table, $name, $fields)
dropIndex ($table, $name)
changeField ($table, $field, $field_new, $spec, $keys_new=array())
prepareComment ($comment, $length=NULL)
getComment ($table, $column=NULL)
tableExists ($table)
fieldExists ($table, $column)
- Public Member Functions inherited from DatabaseSchema
__construct ($connection)
__clone ()
uniqueIdentifier ()
nextPlaceholder ()
prefixNonTable ($table)
tableExists ($table)
findTables ($table_expression)
fieldExists ($table, $column)
getFieldTypeMap ()
renameTable ($table, $new_name)
dropTable ($table)
addField ($table, $field, $spec, $keys_new=array())
dropField ($table, $field)
fieldSetDefault ($table, $field, $default)
fieldSetNoDefault ($table, $field)
indexExists ($table, $name)
addPrimaryKey ($table, $fields)
dropPrimaryKey ($table)
addUniqueKey ($table, $name, $fields)
dropUniqueKey ($table, $name)
addIndex ($table, $name, $fields)
dropIndex ($table, $name)
changeField ($table, $field, $field_new, $spec, $keys_new=array())
createTable ($name, $table)
fieldNames ($fields)
prepareComment ($comment, $length=NULL)

Public Attributes

const | COMMENT_MAX_TABLE = 60
const | COMMENT_MAX_COLUMN = 255

Protected Member Functions

getPrefixInfo ($table= 'default', $add_prefix=TRUE)
buildTableNameCondition ($table_name, $operator= '=', $add_prefix=TRUE)
createTableSql ($name, $table)
createFieldSql ($name, $spec)
processField ($field)
createKeysSql ($spec)
createKeySql ($fields)
createKeysSqlHelper ($fields)
- Protected Member Functions inherited from DatabaseSchema
getPrefixInfo ($table= 'default', $add_prefix=TRUE)
buildTableNameCondition ($table_name, $operator= '=', $add_prefix=TRUE)

Additional Inherited Members

- Protected Attributes inherited from DatabaseSchema
$connection
$placeholder = 0
$defaultSchema = 'public'
$uniqueIdentifier

Member Function Documentation

addField | ( | $table,
 |  | $field,
 |  | $spec,
 |  | $keys_new = array()
 | ) |

Definition at line 323 of file schema.inc.

References changeField(), createFieldSql(), createKeysSql(), fieldExists(), processField(), t(), and tableExists().

addIndex | ( | $table,
 |  | $name,
 |  | $fields
 | ) |

Definition at line 432 of file schema.inc.

References $name, createKeySql(), indexExists(), t(), and tableExists().

addPrimaryKey | ( | $table,
 |  | $fields
 | ) |

Definition at line 392 of file schema.inc.

References createKeySql(), indexExists(), t(), and tableExists().

addUniqueKey | ( | $table,
 |  | $name,
 |  | $fields
 | ) |

Definition at line 412 of file schema.inc.

References $name, createKeySql(), indexExists(), t(), and tableExists().

buildTableNameCondition | ( | $table_name,
 |  | $operator = '=',
 |  | $add_prefix = TRUE
 | ) |
protected

Build a condition to match a table name against a standard information_schema.

MySQL uses databases like schemas rather than catalogs so when we build a condition to query the information_schema.tables, we set the default database as the schema unless specified otherwise, and exclude table_catalog from the condition criteria.

Definition at line 57 of file schema.inc.

References $info, and getPrefixInfo().

Referenced by getComment().

changeField | ( | $table,
 |  | $field,
 |  | $field_new,
 |  | $spec,
 |  | $keys_new = array()
 | ) |

Definition at line 452 of file schema.inc.

References createFieldSql(), createKeysSql(), fieldExists(), processField(), and t().

Referenced by addField().

createFieldSql | ( | $name,
 |  | $spec
 | ) |
protected

Create an SQL string for a field to be used in table creation or alteration.

Before passing a field out of a schema definition into this function it has to be processed by _db_process_field().

Parameters
$name | Name of the field.
$spec | The field specification, as per the schema data structure format.

Definition at line 131 of file schema.inc.

References $name, and prepareComment().

Referenced by addField(), changeField(), and createTableSql().

createKeySql ( $fields )
protected

Definition at line 276 of file schema.inc.

Referenced by addIndex(), addPrimaryKey(), and addUniqueKey().

createKeysSql ( $spec )
protected

Definition at line 256 of file schema.inc.

References createKeysSqlHelper().

Referenced by addField(), changeField(), and createTableSql().

createKeysSqlHelper ( $fields )
protected

Definition at line 289 of file schema.inc.

Referenced by createKeysSql().

createTableSql | ( | $name,
 |  | $table
 | ) |
protected

Generate SQL to create a new table from a Drupal schema definition.

Parameters
$name | The name of the table to create.
$table | A Schema API table definition array.
Returns
An array of SQL statements to create the table.

Definition at line 78 of file schema.inc.

References $info, $name, createFieldSql(), createKeysSql(), prepareComment(), and processField().

dropField | ( | $table,
 |  | $field
 | ) |

Definition at line 353 of file schema.inc.

References fieldExists().

dropIndex | ( | $table,
 |  | $name
 | ) |

Definition at line 443 of file schema.inc.

References $name, and indexExists().

dropPrimaryKey ( $table )

Definition at line 403 of file schema.inc.

References indexExists().

dropTable ( $table )

Definition at line 314 of file schema.inc.

References tableExists().

dropUniqueKey | ( | $table,
 |  | $name
 | ) |

Definition at line 423 of file schema.inc.

References $name, and indexExists().

fieldExists | ( | $table,
 |  | $column
 | ) |

Definition at line 515 of file schema.inc.

Referenced by addField(), changeField(), dropField(), fieldSetDefault(), and fieldSetNoDefault().

fieldSetDefault | ( | $table,
 |  | $field,
 |  | $default
 | ) |

Definition at line 362 of file schema.inc.

References fieldExists(), and t().

fieldSetNoDefault | ( | $table,
 |  | $field
 | ) |

Definition at line 377 of file schema.inc.

References fieldExists(), and t().

getComment | ( | $table,
 |  | $column = NULL
 | ) |

Retrieve a table or column comment.

Definition at line 483 of file schema.inc.

References buildTableNameCondition().

getFieldTypeMap ( )

Definition at line 215 of file schema.inc.

Referenced by processField().

getPrefixInfo | ( | $table = 'default',
 |  | $add_prefix = TRUE
 | ) |
protected

Get information about the table and database name from the prefix.

Returns
A keyed array with information about the database, table name and prefix.

Definition at line 32 of file schema.inc.

References $info, and Database\getConnectionInfo().

Referenced by buildTableNameCondition(), and renameTable().

indexExists | ( | $table,
 |  | $name
 | ) |

Definition at line 385 of file schema.inc.

References $row.

Referenced by addIndex(), addPrimaryKey(), addUniqueKey(), dropIndex(), dropPrimaryKey(), and dropUniqueKey().

prepareComment | ( | $comment,
 |  | $length = NULL
 | ) |

Definition at line 467 of file schema.inc.

References truncate_utf8().

Referenced by createFieldSql(), and createTableSql().

processField ( $field )
protected

Set database-engine specific properties for a field.

Parameters
$field A field description array, as specified in the schema documentation.

Definition at line 192 of file schema.inc.

References drupal_strtoupper(), and getFieldTypeMap().

Referenced by addField(), changeField(), and createTableSql().

renameTable | ( | $table,
 |  | $new_name
 | ) |

Definition at line 302 of file schema.inc.

References $info, getPrefixInfo(), t(), and tableExists().

tableExists ( $table )

Definition at line 498 of file schema.inc.

Referenced by addField(), addIndex(), addPrimaryKey(), addUniqueKey(), dropTable(), and renameTable().

Member Data Documentation

const COMMENT_MAX_COLUMN = 255

Maximum length of a column comment in MySQL.

Definition at line 24 of file schema.inc.

const COMMENT_MAX_TABLE = 60

Maximum length of a table comment in MySQL.

Definition at line 19 of file schema.inc.

class DatabaseSchema_pgsql

Definition at line 13 of file schema.inc.

Inheritance diagram for DatabaseSchema_pgsql:
DatabaseSchema QueryPlaceholderInterface

Public Member Functions

queryTableInformation ($table)
queryFieldInformation ($table, $field)
getFieldTypeMap ()
renameTable ($table, $new_name)
dropTable ($table)
addField ($table, $field, $spec, $new_keys=array())
dropField ($table, $field)
fieldSetDefault ($table, $field, $default)
fieldSetNoDefault ($table, $field)
indexExists ($table, $name)
addPrimaryKey ($table, $fields)
dropPrimaryKey ($table)
addUniqueKey ($table, $name, $fields)
dropUniqueKey ($table, $name)
addIndex ($table, $name, $fields)
dropIndex ($table, $name)
changeField ($table, $field, $field_new, $spec, $new_keys=array())
getComment ($table, $column=NULL)
- Public Member Functions inherited from DatabaseSchema
__construct ($connection)
__clone ()
uniqueIdentifier ()
nextPlaceholder ()
prefixNonTable ($table)
tableExists ($table)
findTables ($table_expression)
fieldExists ($table, $column)
getFieldTypeMap ()
renameTable ($table, $new_name)
dropTable ($table)
addField ($table, $field, $spec, $keys_new=array())
dropField ($table, $field)
fieldSetDefault ($table, $field, $default)
fieldSetNoDefault ($table, $field)
indexExists ($table, $name)
addPrimaryKey ($table, $fields)
dropPrimaryKey ($table)
addUniqueKey ($table, $name, $fields)
dropUniqueKey ($table, $name)
addIndex ($table, $name, $fields)
dropIndex ($table, $name)
changeField ($table, $field, $field_new, $spec, $keys_new=array())
createTable ($name, $table)
fieldNames ($fields)
prepareComment ($comment, $length=NULL)

Protected Member Functions

createTableSql ($name, $table)
createFieldSql ($name, $spec)
processField ($field)
_createKeySql ($fields)
constraintExists ($table, $name)
_createIndexSql ($table, $name, $fields)
_createKeys ($table, $new_keys)
- Protected Member Functions inherited from DatabaseSchema
getPrefixInfo ($table= 'default', $add_prefix=TRUE)
buildTableNameCondition ($table_name, $operator= '=', $add_prefix=TRUE)

Protected Attributes

$tableInformation = array()
- Protected Attributes inherited from DatabaseSchema
$connection
$placeholder = 0
$defaultSchema = 'public'
$uniqueIdentifier

Member Function Documentation

_createIndexSql | ( | $table,
 |  | $name,
 |  | $fields
 | ) |
protected

Definition at line 582 of file schema.inc.

Referenced by addIndex(), and createTableSql().

_createKeys | ( | $table,
 |  | $new_keys
 | ) |
protected

Definition at line 588 of file schema.inc.

Referenced by addField().

_createKeySql ( $fields )
protected

Definition at line 302 of file schema.inc.

addField | ( | $table,
 |  | $field,
 |  | $spec,
 |  | $new_keys = array()
 | ) |

Definition at line 352 of file schema.inc.

References _createKeys(), createFieldSql(), DatabaseSchema\fieldExists(), DatabaseSchema\prepareComment(), processField(), t(), and DatabaseSchema\tableExists().

addIndex | ( | $table,
 |  | $name,
 |  | $fields
 | ) |

Definition at line 476 of file schema.inc.

References $name, _createIndexSql(), indexExists(), t(), and DatabaseSchema\tableExists().

addPrimaryKey | ( | $table,
 |  | $fields
 | ) |

Definition at line 436 of file schema.inc.

References constraintExists(), t(), and DatabaseSchema\tableExists().

addUniqueKey | ( | $table,
 |  | $name,
 |  | $fields
 | ) |

Definition at line 456 of file schema.inc.

References $name, constraintExists(), DatabaseSchema\prefixNonTable(), t(), and DatabaseSchema\tableExists().

changeField | ( | $table,
 |  | $field,
 |  | $field_new,
 |  | $spec,
 |  | $new_keys = array()
 | ) |

Definition at line 496 of file schema.inc.

References DatabaseSchema\fieldExists(), fieldSetNoDefault(), processField(), queryFieldInformation(), and t().

constraintExists | ( | $table,
 |  | $name
 | ) |
protected

Helper function: check if a constraint (PK, FK, UK) exists.

Parameters
$table | The name of the table.
$name | The name of the constraint (typically 'pkey' or '[constraint]_key').

Definition at line 431 of file schema.inc.

References $name.

Referenced by addPrimaryKey(), addUniqueKey(), dropPrimaryKey(), and dropUniqueKey().

createFieldSql | ( | $name,
 |  | $spec
 | ) |
protected

Create an SQL string for a field to be used in table creation or alteration.

Before passing a field out of a schema definition into this function it has to be processed by _db_process_field().

Parameters
$name | Name of the field.
$spec | The field specification, as per the schema data structure format.

Definition at line 177 of file schema.inc.

References $name.

Referenced by addField(), and createTableSql().

createTableSql | ( | $name,
 |  | $table
 | ) |
protected

Generate SQL to create a new table from a Drupal schema definition.

Parameters
$name | The name of the table to create.
$table | A Schema API table definition array.
Returns
An array of SQL statements to create the table.

Definition at line 119 of file schema.inc.

References $name, _createIndexSql(), createFieldSql(), DatabaseSchema\prefixNonTable(), DatabaseSchema\prepareComment(), and processField().

dropField | ( | $table,
 |  | $field
 | ) |

Definition at line 385 of file schema.inc.

References DatabaseSchema\fieldExists().

dropIndex | ( | $table,
 |  | $name
 | ) |

Definition at line 487 of file schema.inc.

References $name, indexExists(), and DatabaseSchema\prefixNonTable().

dropPrimaryKey ( $table )

Definition at line 447 of file schema.inc.

References constraintExists(), and DatabaseSchema\prefixNonTable().

dropTable ( $table )

Definition at line 343 of file schema.inc.

References DatabaseSchema\tableExists().

dropUniqueKey | ( | $table,
 |  | $name
 | ) |

Definition at line 467 of file schema.inc.

References $name, constraintExists(), and DatabaseSchema\prefixNonTable().

fieldSetDefault | ( | $table,
 |  | $field,
 |  | $default
 | ) |

Definition at line 394 of file schema.inc.

References DatabaseSchema\fieldExists(), and t().

fieldSetNoDefault | ( | $table,
 |  | $field
 | ) |

Definition at line 409 of file schema.inc.

References DatabaseSchema\fieldExists(), and t().

Referenced by changeField().

getComment | ( | $table,
 |  | $column = NULL
 | ) |

Retrieve a table or column comment.

Definition at line 607 of file schema.inc.

getFieldTypeMap ( )

This maps a generic data type in combination with its data size to the engine-specific data type.

Definition at line 261 of file schema.inc.

Referenced by processField().

indexExists | ( | $table,
 |  | $name
 | ) |

Definition at line 417 of file schema.inc.

References $name.

Referenced by addIndex(), and dropIndex().

processField ( $field )
protected

Set database-engine specific properties for a field.

Parameters
$field A field description array, as specified in the schema documentation.

Definition at line 217 of file schema.inc.

References drupal_strtolower(), and getFieldTypeMap().

Referenced by addField(), changeField(), and createTableSql().

queryFieldInformation | ( | $table,
 |  | $field
 | ) |

Fetch the list of CHECK constraints used on a field.

We introspect the database to collect the information required by field alteration.

Parameters
$table | The non-prefixed name of the table.
$field | The name of the field.
Returns
An array of all the checks for the field.

Definition at line 89 of file schema.inc.

References DatabaseSchema\getPrefixInfo().

Referenced by changeField().

queryTableInformation ( $table )

Fetch the list of blobs and sequences used on a table.

We introspect the database to collect the information required by insert and update queries.

Parameters
$table_name The non-prefixed name of the table.
Returns
An object with two member variables:
  • 'blob_fields' that lists all the blob fields in the table.
  • 'sequences' that lists the sequences used in that table.

Definition at line 39 of file schema.inc.

renameTable | ( | $table,
 |  | $new_name
 | ) |

Definition at line 315 of file schema.inc.

References DatabaseSchema\getPrefixInfo(), t(), and DatabaseSchema\tableExists().

Member Data Documentation

$tableInformation = array()
protected

Definition at line 24 of file schema.inc.

class DatabaseSchema

Definition at line 164 of file schema.inc.

Inheritance diagram for DatabaseSchema:
QueryPlaceholderInterface DatabaseSchema_mysql DatabaseSchema_pgsql DatabaseSchema_sqlite

Public Member Functions

__construct ($connection)
__clone ()
uniqueIdentifier ()
nextPlaceholder ()
prefixNonTable ($table)
tableExists ($table)
findTables ($table_expression)
fieldExists ($table, $column)
getFieldTypeMap ()
renameTable ($table, $new_name)
dropTable ($table)
addField ($table, $field, $spec, $keys_new=array())
dropField ($table, $field)
fieldSetDefault ($table, $field, $default)
fieldSetNoDefault ($table, $field)
indexExists ($table, $name)
addPrimaryKey ($table, $fields)
dropPrimaryKey ($table)
addUniqueKey ($table, $name, $fields)
dropUniqueKey ($table, $name)
addIndex ($table, $name, $fields)
dropIndex ($table, $name)
changeField ($table, $field, $field_new, $spec, $keys_new=array())
createTable ($name, $table)
fieldNames ($fields)
prepareComment ($comment, $length=NULL)

Protected Member Functions

getPrefixInfo ($table= 'default', $add_prefix=TRUE)
buildTableNameCondition ($table_name, $operator= '=', $add_prefix=TRUE)

Protected Attributes

$connection
$placeholder = 0
$defaultSchema = 'public'
$uniqueIdentifier

Constructor & Destructor Documentation

__construct ( $connection )

Definition at line 189 of file schema.inc.

References $connection, and uniqueIdentifier().

Member Function Documentation

__clone ( )

Implements the magic __clone function.

Definition at line 197 of file schema.inc.

References uniqueIdentifier().

addField | ( | $table,
 |  | $field,
 |  | $spec,
 |  | $keys_new = array()
 | ) |
abstract

Add a new field to a table.

Parameters
$table | Name of the table to be altered.
$field | Name of the field to be added.
$spec | The field specification array, as taken from a schema definition. The specification may also contain the key 'initial', the newly created field will be set to the value of the key in all rows. This is most useful for creating NOT NULL columns with no default value in existing tables.
$keys_new | Optional keys and indexes specification to be created on the table along with adding the field. The format is the same as a table specification but without the 'fields' element. If you are adding a type 'serial' field, you MUST specify at least one key or index including it in this array. See db_change_field() for more explanation why.
Exceptions
DatabaseSchemaObjectDoesNotExistException | If the specified table doesn't exist.
DatabaseSchemaObjectExistsException | If the specified table already has a field by that name.
addIndex | ( | $table,
 |  | $name,
 |  | $fields
 | ) |
abstract

Add an index.

Parameters
$table | The table to be altered.
$name | The name of the index.
$fields | An array of field names.
Exceptions
DatabaseSchemaObjectDoesNotExistException | If the specified table doesn't exist.
DatabaseSchemaObjectExistsException | If the specified table already has an index by that name.
addPrimaryKey | ( | $table,
 |  | $fields
 | ) |
abstract

Add a primary key.

Parameters
$table | The table to be altered.
$fields | Fields for the primary key.
Exceptions
DatabaseSchemaObjectDoesNotExistException | If the specified table doesn't exist.
DatabaseSchemaObjectExistsException | If the specified table already has a primary key.
addUniqueKey | ( | $table,
 |  | $name,
 |  | $fields
 | ) |
abstract

Add a unique key.

Parameters
$table | The table to be altered.
$name | The name of the key.
$fields | An array of field names.
Exceptions
DatabaseSchemaObjectDoesNotExistException | If the specified table doesn't exist.
DatabaseSchemaObjectExistsException | If the specified table already has a key by that name.
buildTableNameCondition | ( | $table_name,
 |  | $operator = '=',
 |  | $add_prefix = TRUE
 | ) |
protected

Build a condition to match a table name against a standard information_schema.

The information_schema is a SQL standard that provides information about the database server and the databases, schemas, tables, columns and users within it. This makes information_schema a useful tool to use across the drupal database drivers and is used by a few different functions. The function below describes the conditions to be meet when querying information_schema.tables for drupal tables or information associated with drupal tables. Even though this is the standard method, not all databases follow standards and so this method should be overwritten by a database driver if the database provider uses alternate methods. Because information_schema.tables is used in a few different functions, a database driver will only need to override this function to make all the others work. For example see includes/databases/mysql/schema.inc.

Parameters
$table_name | The name of the table in question.
$operator | The operator to apply on the 'table' part of the condition.
$add_prefix | Boolean to indicate whether the table name needs to be prefixed.
Returns
QueryConditionInterface A DatabaseCondition object.

Definition at line 288 of file schema.inc.

References $info, and getPrefixInfo().

Referenced by fieldExists(), findTables(), and tableExists().

changeField | ( | $table,
 |  | $field,
 |  | $field_new,
 |  | $spec,
 |  | $keys_new = array()
 | ) |
abstract

Change a field definition.

IMPORTANT NOTE: To maintain database portability, you have to explicitly recreate all indices and primary keys that are using the changed field.

That means that you have to drop all affected keys and indexes with db_drop_{primary_key,unique_key,index}() before calling db_change_field(). To recreate the keys and indices, pass the key definitions as the optional $keys_new argument directly to db_change_field().

For example, suppose you have:

* $schema['foo'] = array(
* 'fields' => array(
* 'bar' => array('type' => 'int', 'not null' => TRUE)
* ),
* 'primary key' => array('bar')
* );
*

and you want to change foo.bar to be type serial, leaving it as the primary key. The correct sequence is:

* db_drop_primary_key('foo');
* db_change_field('foo', 'bar', 'bar',
* array('type' => 'serial', 'not null' => TRUE),
* array('primary key' => array('bar')));
*

The reasons for this are due to the different database engines:

On PostgreSQL, changing a field definition involves adding a new field and dropping an old one which* causes any indices, primary keys and sequences (from serial-type fields) that use the changed field to be dropped.

On MySQL, all type 'serial' fields must be part of at least one key or index as soon as they are created. You cannot use db_add_{primary_key,unique_key,index}() for this purpose because the ALTER TABLE command will fail to add the column without a key or index specification. The solution is to use the optional $keys_new argument to create the key or index at the same time as field.

You could use db_add_{primary_key,unique_key,index}() in all cases unless you are converting a field to be type serial. You can use the $keys_new argument in all cases.

Parameters
$table | Name of the table.
$field | Name of the field to change.
$field_new | New name for the field (set to the same as $field if you don't want to change the name).
$spec | The field specification for the new field.
$keys_new | Optional keys and indexes specification to be created on the table along with changing the field. The format is the same as a table specification but without the 'fields' element.
Exceptions
DatabaseSchemaObjectDoesNotExistException | If the specified table or source field doesn't exist.
DatabaseSchemaObjectExistsException | If the specified destination field already exists.
createTable | ( | $name,
 |  | $table
 | ) |

Create a new table from a Drupal table definition.

Parameters
$name | The name of the table to create.
$table | A Schema API table definition array.
Exceptions
DatabaseSchemaObjectExistsException If the specified table already exists.

Definition at line 655 of file schema.inc.

References $name, t(), and tableExists().

Referenced by DatabaseSchema_sqlite\alterTable().

dropField | ( | $table,
 |  | $field
 | ) |
abstract

Drop a field.

Parameters
$table | The table to be altered.
$field | The field to be dropped.
Returns
TRUE if the field was successfully dropped, FALSE if there was no field by that name to begin with.
dropIndex | ( | $table,
 |  | $name
 | ) |
abstract

Drop an index.

Parameters
$table | The table to be altered.
$name | The name of the index.
Returns
TRUE if the index was successfully dropped, FALSE if there was no index by that name to begin with.
dropPrimaryKey ( $table )
abstract

Drop the primary key.

Parameters
$table The table to be altered.
Returns
TRUE if the primary key was successfully dropped, FALSE if there was no primary key on this table to begin with.
dropTable ( $table )
abstract

Drop a table.

Parameters
$table The table to be dropped.
Returns
TRUE if the table was successfully dropped, FALSE if there was no table by that name to begin with.
dropUniqueKey | ( | $table,
 |  | $name
 | ) |
abstract

Drop a unique key.

Parameters
$table | The table to be altered.
$name | The name of the key.
Returns
TRUE if the key was successfully dropped, FALSE if there was no key by that name to begin with.
fieldExists | ( | $table,
 |  | $column
 | ) |

Check if a column exists in the given table.

Parameters
$table | The name of the table in drupal (no prefixing).
$name | The name of the column.
Returns
TRUE if the given column exists, otherwise FALSE.

Definition at line 354 of file schema.inc.

References buildTableNameCondition().

Referenced by DatabaseSchema_pgsql\addField(), DatabaseSchema_pgsql\changeField(), DatabaseSchema_pgsql\dropField(), DatabaseSchema_pgsql\fieldSetDefault(), and DatabaseSchema_pgsql\fieldSetNoDefault().

fieldNames ( $fields )

Return an array of field names from an array of key/index column specifiers.

This is usually an identity function but if a key/index uses a column prefix specification, this function extracts just the name.

Parameters
$fields An array of key/index column specifiers.
Returns
An array of field names.

Definition at line 677 of file schema.inc.

fieldSetDefault | ( | $table,
 |  | $field,
 |  | $default
 | ) |
abstract

Set the default value for a field.

Parameters
$table | The table to be altered.
$field | The field to be altered.
$default | Default value to be set. NULL for 'default NULL'.
Exceptions
DatabaseSchemaObjectDoesNotExistException If the specified table or field doesn't exist.
fieldSetNoDefault | ( | $table,
 |  | $field
 | ) |
abstract

Set a field to have no default value.

Parameters
$table | The table to be altered.
$field | The field to be altered.
Exceptions
DatabaseSchemaObjectDoesNotExistException If the specified table or field doesn't exist.
findTables ( $table_expression )

Find all tables that are like the specified base table name.

Parameters
$table_expression An SQL expression, for example "simpletest%" (without the quotes). BEWARE: this is not prefixed, the caller should take care of that.
Returns
Array, both the keys and the values are the matching tables.

Definition at line 331 of file schema.inc.

References buildTableNameCondition().

getFieldTypeMap ( )
abstract

Returns a mapping of Drupal schema field names to DB-native field types.

Because different field types do not map 1:1 between databases, Drupal has its own normalized field type names. This function returns a driver-specific mapping table from Drupal names to the native names for each database.

Returns
array An array of Schema API field types to driver-specific field types.
getPrefixInfo | ( | $table = 'default',
 |  | $add_prefix = TRUE
 | ) |
protected

Get information about the table name and schema from the prefix.

Parameters
Name | of table to look prefix up for. Defaults to 'default' because thats default key for prefix.
$add_prefix | Boolean that indicates whether the given table name should be prefixed.
Returns
A keyed array with information about the schema, table name and prefix.

Definition at line 227 of file schema.inc.

References $info.

Referenced by buildTableNameCondition(), DatabaseSchema_sqlite\createIndexSql(), DatabaseSchema_sqlite\dropIndex(), DatabaseSchema_sqlite\dropUniqueKey(), DatabaseSchema_sqlite\findTables(), DatabaseSchema_sqlite\indexExists(), DatabaseSchema_sqlite\introspectSchema(), prefixNonTable(), DatabaseSchema_pgsql\queryFieldInformation(), DatabaseSchema_sqlite\renameTable(), DatabaseSchema_pgsql\renameTable(), and DatabaseSchema_sqlite\tableExists().

indexExists | ( | $table,
 |  | $name
 | ) |
abstract

Checks if an index exists in the given table.

Parameters
$table | The name of the table in drupal (no prefixing).
$name | The name of the index in drupal (no prefixing).
Returns
TRUE if the given index exists, otherwise FALSE.
nextPlaceholder ( )

Implements QueryPlaceHolderInterface::nextPlaceholder().

Implements QueryPlaceholderInterface.

Definition at line 211 of file schema.inc.

prefixNonTable ( $table )

Create names for indexes, primary keys and constraints.

This prevents using {} around non-table names like indexes and keys.

Definition at line 256 of file schema.inc.

References $info, and getPrefixInfo().

Referenced by DatabaseSchema_pgsql\addUniqueKey(), DatabaseSchema_pgsql\createTableSql(), DatabaseSchema_pgsql\dropIndex(), DatabaseSchema_pgsql\dropPrimaryKey(), and DatabaseSchema_pgsql\dropUniqueKey().

prepareComment | ( | $comment,
 |  | $length = NULL
 | ) |

Prepare a table or column comment for database query.

Parameters
$comment | The comment string to prepare.
$length | Optional upper limit on the returned string length.
Returns
The prepared comment.

Definition at line 701 of file schema.inc.

Referenced by DatabaseSchema_pgsql\addField(), and DatabaseSchema_pgsql\createTableSql().

renameTable | ( | $table,
 |  | $new_name
 | ) |
abstract

Rename a table.

Parameters
$table | The table to be renamed.
$new_name | The new name for the table.
Exceptions
DatabaseSchemaObjectDoesNotExistException | If the specified table doesn't exist.
DatabaseSchemaObjectExistsException | If a table with the specified new name already exists.
tableExists ( $table )

Check if a table exists.

Parameters
$table The name of the table in drupal (no prefixing).
Returns
TRUE if the given table exists, otherwise FALSE.

Definition at line 310 of file schema.inc.

References buildTableNameCondition().

Referenced by DatabaseSchema_pgsql\addField(), DatabaseSchema_pgsql\addIndex(), DatabaseSchema_pgsql\addPrimaryKey(), DatabaseSchema_pgsql\addUniqueKey(), createTable(), DatabaseSchema_pgsql\dropTable(), and DatabaseSchema_pgsql\renameTable().

uniqueIdentifier ( )

Implements QueryPlaceHolderInterface::uniqueIdentifier().

Implements QueryPlaceholderInterface.

Definition at line 204 of file schema.inc.

References $uniqueIdentifier.

Referenced by __clone(), and __construct().

Member Data Documentation

$connection
protected

Definition at line 166 of file schema.inc.

Referenced by __construct().

$defaultSchema = 'public'
protected

Definition of prefixInfo array structure.

Rather than redefining DatabaseSchema::getPrefixInfo() for each driver, by defining the defaultSchema variable only MySQL has to re-write the method.

See Also
DatabaseSchema::getPrefixInfo()

Definition at line 182 of file schema.inc.

$placeholder = 0
protected

The placeholder counter.

Definition at line 171 of file schema.inc.

$uniqueIdentifier
protected

A unique identifier for this query object.

Definition at line 187 of file schema.inc.

Referenced by uniqueIdentifier().

class DatabaseSchemaObjectExistsException

Exception thrown if an object being created already exists.

For example, this exception should be thrown whenever there is an attempt to create a new database table, field, or index that already exists in the database schema.

Definition at line 713 of file schema.inc.

Inheritance diagram for DatabaseSchemaObjectExistsException:
Exception
class DatabaseSchemaObjectDoesNotExistException

Exception thrown if an object being modified doesn't exist yet.

For example, this exception should be thrown whenever there is an attempt to modify a database table, field, or index that does not currently exist in the database schema.

Definition at line 722 of file schema.inc.

Inheritance diagram for DatabaseSchemaObjectDoesNotExistException:
Exception
class DatabaseSchema_sqlite

Definition at line 14 of file schema.inc.

Inheritance diagram for DatabaseSchema_sqlite:
DatabaseSchema QueryPlaceholderInterface

Public Member Functions

tableExists ($table)
fieldExists ($table, $column)
createTableSql ($name, $table)
getFieldTypeMap ()
renameTable ($table, $new_name)
dropTable ($table)
addField ($table, $field, $specification, $keys_new=array())
dropField ($table, $field)
changeField ($table, $field, $field_new, $spec, $keys_new=array())
addIndex ($table, $name, $fields)
indexExists ($table, $name)
dropIndex ($table, $name)
addUniqueKey ($table, $name, $fields)
dropUniqueKey ($table, $name)
addPrimaryKey ($table, $fields)
dropPrimaryKey ($table)
fieldSetDefault ($table, $field, $default)
fieldSetNoDefault ($table, $field)
findTables ($table_expression)
- Public Member Functions inherited from DatabaseSchema
__construct ($connection)
__clone ()
uniqueIdentifier ()
nextPlaceholder ()
prefixNonTable ($table)
tableExists ($table)
findTables ($table_expression)
fieldExists ($table, $column)
getFieldTypeMap ()
renameTable ($table, $new_name)
dropTable ($table)
addField ($table, $field, $spec, $keys_new=array())
dropField ($table, $field)
fieldSetDefault ($table, $field, $default)
fieldSetNoDefault ($table, $field)
indexExists ($table, $name)
addPrimaryKey ($table, $fields)
dropPrimaryKey ($table)
addUniqueKey ($table, $name, $fields)
dropUniqueKey ($table, $name)
addIndex ($table, $name, $fields)
dropIndex ($table, $name)
changeField ($table, $field, $field_new, $spec, $keys_new=array())
createTable ($name, $table)
fieldNames ($fields)
prepareComment ($comment, $length=NULL)

Protected Member Functions

createIndexSql ($tablename, $schema)
createColumsSql ($tablename, $schema)
createKeySql ($fields)
processField ($field)
createFieldSql ($name, $spec)
alterTable ($table, $old_schema, $new_schema, array $mapping=array())
introspectSchema ($table)
mapKeyDefinition (array $key_definition, array $mapping)
- Protected Member Functions inherited from DatabaseSchema
getPrefixInfo ($table= 'default', $add_prefix=TRUE)
buildTableNameCondition ($table_name, $operator= '=', $add_prefix=TRUE)

Protected Attributes

$defaultSchema = 'main'
- Protected Attributes inherited from DatabaseSchema
$connection
$placeholder = 0
$defaultSchema = 'public'
$uniqueIdentifier

Member Function Documentation

addField | ( | $table,
 |  | $field,
 |  | $specification,
 |  | $keys_new = array()
 | ) |

Definition at line 279 of file schema.inc.

References alterTable(), createFieldSql(), fieldExists(), introspectSchema(), processField(), t(), and tableExists().

addIndex | ( | $table,
 |  | $name,
 |  | $fields
 | ) |

Definition at line 560 of file schema.inc.

References $name, createIndexSql(), indexExists(), t(), and tableExists().

addPrimaryKey | ( | $table,
 |  | $fields
 | ) |

Definition at line 618 of file schema.inc.

References alterTable(), introspectSchema(), t(), and tableExists().

addUniqueKey | ( | $table,
 |  | $name,
 |  | $fields
 | ) |

Definition at line 592 of file schema.inc.

References $name, createIndexSql(), indexExists(), t(), and tableExists().

alterTable | ( |  | $table,
 |  |  | $old_schema,
 |  |  | $new_schema,
 |  | array | $mapping = array()
 | ) |  |
protected

Create a table with a new schema containing the old content.

As SQLite does not support ALTER TABLE (with a few exceptions) it is necessary to create a new table and copy over the old content.

Parameters
$table | Name of the table to be altered.
$old_schema | The old schema array for the table.
$new_schema | The new schema array for the table.
$mapping An optional mapping between the fields of the old specification and the fields of the new specification. An associative array, whose keys are the fields of the new table, and values can take two possible forms:
  • a simple string, which is interpreted as the name of a field of the old table,
  • an associative array with two keys 'expression' and 'arguments', that will be used as an expression field.

Definition at line 354 of file schema.inc.

References DatabaseSchema\createTable(), dropTable(), renameTable(), and tableExists().

Referenced by addField(), addPrimaryKey(), changeField(), dropField(), dropPrimaryKey(), fieldSetDefault(), and fieldSetNoDefault().

changeField | ( | $table,
 |  | $field,
 |  | $field_new,
 |  | $spec,
 |  | $keys_new = array()
 | ) |

Definition at line 495 of file schema.inc.

References alterTable(), fieldExists(), introspectSchema(), mapKeyDefinition(), and t().

createColumsSql | ( | $tablename,
 |  | $schema
 | ) |
protected

Build the SQL expression for creating columns.

Definition at line 71 of file schema.inc.

References $name, createFieldSql(), createKeySql(), and processField().

Referenced by createTableSql().

createFieldSql | ( | $name,
 |  | $spec
 | ) |
protected

Create an SQL string for a field to be used in table creation or alteration.

Before passing a field out of a schema definition into this function it has to be processed by db_processField().

Parameters
$name | Name of the field.
$spec | The field specification, as per the schema data structure format.

Definition at line 147 of file schema.inc.

References $name.

Referenced by addField(), and createColumsSql().

createIndexSql | ( | $tablename,
 |  | $schema
 | ) |
protected

Build the SQL expression for indexes.

Definition at line 52 of file schema.inc.

References $info, createKeySql(), and DatabaseSchema\getPrefixInfo().

Referenced by addIndex(), addUniqueKey(), createTableSql(), and renameTable().

createKeySql ( $fields )
protected

Build the SQL expression for keys.

Definition at line 95 of file schema.inc.

Referenced by createColumsSql(), and createIndexSql().

createTableSql | ( | $name,
 |  | $table
 | ) |

Generate SQL to create a new table from a Drupal schema definition.

Parameters
$name | The name of the table to create.
$table | A Schema API table definition array.
Returns
An array of SQL statements to create the table.

Definition at line 43 of file schema.inc.

References $name, createColumsSql(), and createIndexSql().

dropField | ( | $table,
 |  | $field
 | ) |

Definition at line 471 of file schema.inc.

References alterTable(), fieldExists(), and introspectSchema().

dropIndex | ( | $table,
 |  | $name
 | ) |

Definition at line 581 of file schema.inc.

References $info, $name, DatabaseSchema\getPrefixInfo(), and indexExists().

Referenced by renameTable().

dropPrimaryKey ( $table )

Definition at line 634 of file schema.inc.

References alterTable(), and introspectSchema().

dropTable ( $table )

Definition at line 270 of file schema.inc.

References tableExists().

Referenced by alterTable().

dropUniqueKey | ( | $table,
 |  | $name
 | ) |

Definition at line 607 of file schema.inc.

References $info, $name, DatabaseSchema\getPrefixInfo(), and indexExists().

fieldExists | ( | $table,
 |  | $column
 | ) |

Definition at line 28 of file schema.inc.

References introspectSchema().

Referenced by addField(), changeField(), dropField(), fieldSetDefault(), and fieldSetNoDefault().

fieldSetDefault | ( | $table,
 |  | $field,
 |  | $default
 | ) |

Definition at line 647 of file schema.inc.

References alterTable(), fieldExists(), introspectSchema(), and t().

fieldSetNoDefault | ( | $table,
 |  | $field
 | ) |

Definition at line 659 of file schema.inc.

References alterTable(), fieldExists(), introspectSchema(), and t().

findTables ( $table_expression )

Definition at line 671 of file schema.inc.

References $info, db_query(), and DatabaseSchema\getPrefixInfo().

getFieldTypeMap ( )

This maps a generic data type in combination with its data size to the engine-specific data type.

Definition at line 192 of file schema.inc.

Referenced by introspectSchema(), and processField().

indexExists | ( | $table,
 |  | $name
 | ) |

Definition at line 575 of file schema.inc.

References $info, $name, and DatabaseSchema\getPrefixInfo().

Referenced by addIndex(), addUniqueKey(), dropIndex(), and dropUniqueKey().

introspectSchema ( $table )
protected

Find out the schema of a table.

This function uses introspection methods provided by the database to create a schema array. This is useful, for example, during update when the old schema is not available.

Parameters
$table Name of the table.
Returns
An array representing the schema, from drupal_get_schema().
See Also
drupal_get_schema()

Definition at line 410 of file schema.inc.

References $info, $name, $row, getFieldTypeMap(), and DatabaseSchema\getPrefixInfo().

Referenced by addField(), addPrimaryKey(), changeField(), dropField(), dropPrimaryKey(), fieldExists(), fieldSetDefault(), fieldSetNoDefault(), and renameTable().

mapKeyDefinition | ( | array | $key_definition,
 |  | array | $mapping
 | ) |  |
protected

Utility method: rename columns in an index definition according to a new mapping.

Parameters
$key_definition | The key definition.
$mapping | The new mapping.

Definition at line 547 of file schema.inc.

Referenced by changeField().

processField ( $field )
protected

Set database-engine specific properties for a field.

Parameters
$field A field description array, as specified in the schema documentation.

Definition at line 114 of file schema.inc.

References drupal_strtoupper(), and getFieldTypeMap().

Referenced by addField(), and createColumsSql().

renameTable | ( | $table,
 |  | $new_name
 | ) |

Definition at line 233 of file schema.inc.

References $info, createIndexSql(), dropIndex(), DatabaseSchema\getPrefixInfo(), introspectSchema(), t(), and tableExists().

Referenced by alterTable().

tableExists ( $table )

Definition at line 21 of file schema.inc.

References $info, and DatabaseSchema\getPrefixInfo().

Referenced by addField(), addIndex(), addPrimaryKey(), addUniqueKey(), alterTable(), dropTable(), and renameTable().

Member Data Documentation

$defaultSchema = 'main'
protected

Override DatabaseSchema::$defaultSchema

Definition at line 19 of file schema.inc.

Function Documentation

__construct | ( | $cid,
 |  | $bin
 | ) |

Constructs a DrupalCacheArray object.

Parameters
$cid | The cid for the array being cached.
$bin | The bin to cache the array.

Definition at line 336 of file bootstrap.inc.

References DrupalCacheArray\$bin, DrupalCacheArray\$cid, and cache_get().

__construct ( )

Constructs a SchemaCache object.

Definition at line 2969 of file bootstrap.inc.

__destruct ( )

Destructs the DrupalCacheArray object.

Definition at line 438 of file bootstrap.inc.

References DrupalCacheArray\set().

_db_create_keys_sql ( $spec )

Definition at line 2793 of file database.inc.

References Database\getConnection().

_drupal_schema_initialize | ( | & | $schema,
 |  |  | $module,
 |  |  | $remove_descriptions = TRUE
 | ) |  |

Fills in required default values for table definitions from hook_schema().

Parameters
$schema | The schema definition array as it was returned by the module's hook_schema().
$module | The module for which hook_schema() was invoked.
$remove_descriptions | (optional) Whether to additionally remove 'description' keys of all tables and fields to improve performance of serialize() and unserialize(). Defaults to TRUE.

Definition at line 7025 of file common.inc.

References $module, and $name.

Referenced by drupal_get_complete_schema(), drupal_install_schema(), and drupal_uninstall_schema().

_drupal_shutdown_function ( )

Executes registered shutdown functions.

Definition at line 3438 of file bootstrap.inc.

References _drupal_render_exception_safe(), drupal_register_shutdown_function(), DRUPAL_ROOT, error_displayable(), and print.

db_add_field | ( | $table,
 |  | $field,
 |  | $spec,
 |  | $keys_new = array()
 | ) |

Adds a new field to a table.

Parameters
$table | Name of the table to be altered.
$field | Name of the field to be added.
$spec | The field specification array, as taken from a schema definition. The specification may also contain the key 'initial'; the newly-created field will be set to the value of the key in all rows. This is most useful for creating NOT NULL columns with no default value in existing tables.
$keys_new | Optional keys and indexes specification to be created on the table along with adding the field. The format is the same as a table specification, but without the 'fields' element. If you are adding a type 'serial' field, you MUST specify at least one key or index including it in this array. See db_change_field() for more explanation why.
See Also
db_change_field()

Definition at line 2840 of file database.inc.

References Database\getConnection().

Referenced by _image_update_7002_add_columns(), aggregator_update_7000(), aggregator_update_7002(), comment_update_7002(), comment_update_7003(), comment_update_7004(), field_sql_storage_update_7001(), filter_update_7000(), hook_update_N(), image_update_7005(), node_update_7000(), node_update_7005(), poll_update_7001(), poll_update_7002(), system_update_7045(), taxonomy_update_7002(), taxonomy_update_7006(), update_fix_d7_requirements(), user_update_7006(), user_update_7007(), and user_update_7012().

db_add_index | ( | $table,
 |  | $name,
 |  | $fields
 | ) |

Adds an index.

Parameters
$table | The table to be altered.
$name | The name of the index.
$fields | An array of field names.

Definition at line 2940 of file database.inc.

References $name, and Database\getConnection().

Referenced by aggregator_update_7002(), aggregator_update_7003(), comment_update_7002(), comment_update_7003(), comment_update_7004(), comment_update_7007(), comment_update_7008(), dblog_update_7001(), dblog_update_7002(), field_sql_storage_field_storage_update_field(), field_sql_storage_update_7001(), forum_update_7000(), forum_update_7002(), forum_update_7003(), forum_update_7012(), locale_update_7000(), node_update_7002(), node_update_7014(), poll_update_7001(), system_update_7018(), system_update_7032(), system_update_7042(), system_update_7045(), system_update_7062(), system_update_7071(), taxonomy_update_7007(), update_fix_d7_requirements(), user_update_7007(), and user_update_7018().

db_add_primary_key | ( | $table,
 |  | $fields
 | ) |

Adds a primary key to a database table.

Parameters
$table | Name of the table to be altered.
$fields | Array of fields for the primary key.

Definition at line 2890 of file database.inc.

References Database\getConnection().

Referenced by field_sql_storage_update_7001(), field_sql_storage_update_7002(), search_update_7000(), trigger_update_7000(), and update_fix_d7_requirements().

db_add_unique_key | ( | $table,
 |  | $name,
 |  | $fields
 | ) |

Adds a unique key.

Parameters
$table | The table to be altered.
$name | The name of the key.
$fields | An array of field names.

Definition at line 2914 of file database.inc.

References $name, and Database\getConnection().

Referenced by node_update_7013(), system_update_7073(), and taxonomy_update_7002().

db_change_field | ( | $table,
 |  | $field,
 |  | $field_new,
 |  | $spec,
 |  | $keys_new = array()
 | ) |

Changes a field definition.

IMPORTANT NOTE: To maintain database portability, you have to explicitly recreate all indices and primary keys that are using the changed field.

That means that you have to drop all affected keys and indexes with db_drop_{primary_key,unique_key,index}() before calling db_change_field(). To recreate the keys and indices, pass the key definitions as the optional $keys_new argument directly to db_change_field().

For example, suppose you have:

* $schema['foo'] = array(
* 'fields' => array(
* 'bar' => array('type' => 'int', 'not null' => TRUE)
* ),
* 'primary key' => array('bar')
* );
*

and you want to change foo.bar to be type serial, leaving it as the primary key. The correct sequence is:

* db_drop_primary_key('foo');
* db_change_field('foo', 'bar', 'bar',
* array('type' => 'serial', 'not null' => TRUE),
* array('primary key' => array('bar')));
*

The reasons for this are due to the different database engines:

On PostgreSQL, changing a field definition involves adding a new field and dropping an old one which causes any indices, primary keys and sequences (from serial-type fields) that use the changed field to be dropped.

On MySQL, all type 'serial' fields must be part of at least one key or index as soon as they are created. You cannot use db_add_{primary_key,unique_key,index}() for this purpose because the ALTER TABLE command will fail to add the column without a key or index specification. The solution is to use the optional $keys_new argument to create the key or index at the same time as field.

You could use db_add_{primary_key,unique_key,index}() in all cases unless you are converting a field to be type serial. You can use the $keys_new argument in all cases.

Parameters
$table | Name of the table.
$field | Name of the field to change.
$field_new | New name for the field (set to the same as $field if you don't want to change the name).
$spec | The field specification for the new field.
$keys_new | Optional keys and indexes specification to be created on the table along with changing the field. The format is the same as a table specification but without the 'fields' element.

Definition at line 3016 of file database.inc.

References Database\getConnection().

Referenced by aggregator_update_7003(), block_update_7003(), block_update_7005(), block_update_7007(), comment_update_7003(), comment_update_7008(), comment_update_7009(), contact_update_7003(), dblog_update_7001(), filter_update_7010(), forum_update_7003(), image_update_7004(), locale_update_7000(), locale_update_7005(), node_update_7000(), node_update_7011(), node_update_7013(), poll_update_7001(), poll_update_7003(), poll_update_7004(), profile_update_7002(), search_update_7000(), statistics_update_7000(), system_update_7018(), system_update_7032(), system_update_7042(), system_update_7050(), system_update_7051(), system_update_7052(), system_update_7055(), system_update_7057(), system_update_7065(), system_update_7068(), system_update_7071(), system_update_7073(), system_update_7077(), system_update_7078(), system_update_7079(), taxonomy_update_7008(), taxonomy_update_7009(), taxonomy_update_7010(), text_update_7000(), trigger_update_7000(), trigger_update_7001(), update_fix_d7_requirements(), user_update_7000(), user_update_7002(), user_update_7005(), user_update_7009(), user_update_7010(), user_update_7012(), user_update_7015(), and user_update_7016().

db_create_table | ( | $name,
 |  | $table
 | ) |

Creates a new table from a Drupal table definition.

Parameters
$name | The name of the table to create.
$table | A Schema API table definition array.

Definition at line 2716 of file database.inc.

References $name, and Database\getConnection().

Referenced by ajax_example_update_7100(), block_update_7006(), drupal_install_schema(), field_sql_storage_field_storage_create_field(), field_sql_storage_field_storage_update_field(), filter_update_7003(), filter_update_7009(), forum_update_7001(), hook_field_storage_create_field(), hook_field_storage_update_field(), image_update_7000(), node_update_7010(), openid_update_6000(), openid_update_7000(), system_update_7002(), system_update_7034(), system_update_7054(), system_update_7059(), system_update_7061(), taxonomy_update_7004(), taxonomy_update_7005(), tracker_update_7000(), update_fix_d7_requirements(), update_prepare_d7_bootstrap(), and update_update_7001().

db_drop_field | ( | $table,
 |  | $field
 | ) |

Drops a field.

Parameters
$table | The table to be altered.
$field | The field to be dropped.

Definition at line 2852 of file database.inc.

References Database\getConnection().

Referenced by block_update_7008(), comment_update_7006(), field_sql_storage_update_7001(), filter_update_7005(), node_update_7006(), node_update_7007(), node_update_7011(), poll_update_7001(), system_update_7005(), system_update_7042(), system_update_7064(), taxonomy_update_7003(), taxonomy_update_7004(), trigger_update_7000(), user_update_7001(), and user_update_7012().

db_drop_index | ( | $table,
 |  | $name
 | ) |

Drops an index.

Parameters
$table | The table to be altered.
$name | The name of the index.

Definition at line 2952 of file database.inc.

References $name, and Database\getConnection().

Referenced by block_update_7002(), comment_update_7003(), comment_update_7008(), contact_update_7003(), field_sql_storage_field_storage_update_field(), forum_update_7000(), forum_update_7002(), forum_update_7003(), locale_update_7000(), node_update_7002(), node_update_7011(), search_update_7000(), system_update_7018(), system_update_7032(), system_update_7042(), system_update_7062(), system_update_7071(), taxonomy_update_7008(), update_fix_d7_requirements(), and user_update_7005().

db_drop_primary_key ( $table )

Drops the primary key of a database table.

Parameters
$table Name of the table to be altered.

Definition at line 2900 of file database.inc.

References Database\getConnection().

Referenced by field_sql_storage_update_7001(), field_sql_storage_update_7002(), system_update_7065(), trigger_update_7000(), trigger_update_7001(), and update_fix_d7_requirements().

db_drop_table ( $table )

Drops a table.

Parameters
$table The table to be dropped.

Definition at line 2815 of file database.inc.

References Database\getConnection().

Referenced by _update_7000_field_delete_field(), block_update_7006(), drupal_uninstall_schema(), field_sql_storage_field_storage_purge_field(), field_sql_storage_field_storage_update_field(), field_sql_storage_update_7001(), filter_update_7009(), hook_field_storage_purge_field(), hook_field_storage_update_field(), node_update_7003(), openid_update_7000(), simpletest_clean_database(), system_update_7007(), system_update_7044(), system_update_7054(), system_update_7060(), system_update_7061(), tabledrag_example_uninstall(), tablesort_example_uninstall(), taxonomy_update_7005(), DrupalWebTestCase\tearDown(), update_fix_d7_requirements(), and update_update_7001().

db_drop_unique_key | ( | $table,
 |  | $name
 | ) |

Drops a unique key.

Parameters
$table | The table to be altered.
$name | The name of the key.

Definition at line 2926 of file database.inc.

References $name, and Database\getConnection().

Referenced by aggregator_update_7003(), node_update_7013(), search_update_7000(), system_update_7042(), system_update_7073(), and system_update_7078().

db_field_exists | ( | $table,
 |  | $field
 | ) |

Checks if a column exists in the given table.

Parameters
$table | The name of the table in drupal (no prefixing).
$field | The name of the field.
Returns
TRUE if the given column exists, otherwise FALSE.

Definition at line 2775 of file database.inc.

References Database\getConnection().

Referenced by field_sql_storage_update_7001(), user_update_7002(), user_update_7006(), and user_update_7012().

db_field_names ( $fields )

Returns an array of field names from an array of key/index column specifiers.

This is usually an identity function but if a key/index uses a column prefix specification, this function extracts just the name.

Parameters
$fields An array of key/index column specifiers.
Returns
An array of field names.

Definition at line 2732 of file database.inc.

References Database\getConnection().

db_field_set_default | ( | $table,
 |  | $field,
 |  | $default
 | ) |

Sets the default value for a field.

Parameters
$table | The table to be altered.
$field | The field to be altered.
$default | Default value to be set. NULL for 'default NULL'.

Definition at line 2866 of file database.inc.

References Database\getConnection().

db_field_set_no_default | ( | $table,
 |  | $field
 | ) |

Sets a field to have no default value.

Parameters
$table | The table to be altered.
$field | The field to be altered.

Definition at line 2878 of file database.inc.

References Database\getConnection().

db_find_tables ( $table_expression )

Finds all tables that are like the specified base table name.

Parameters
$table_expression An SQL expression, for example "simpletest%" (without the quotes). BEWARE: this is not prefixed, the caller should take care of that.
Returns
Array, both the keys and the values are the matching tables.

Definition at line 2789 of file database.inc.

References Database\getConnection().

Referenced by simpletest_clean_database(), and DrupalWebTestCase\tearDown().

db_index_exists | ( | $table,
 |  | $name
 | ) |

Checks if an index exists in the given table.

Parameters
$table | The name of the table in drupal (no prefixing).
$name | The name of the index in drupal (no prefixing).
Returns
TRUE if the given index exists, otherwise FALSE.

Definition at line 2747 of file database.inc.

References $name, and Database\getConnection().

Referenced by comment_update_7002(), comment_update_7004(), locale_update_7000(), and user_update_7018().

db_rename_table | ( | $table,
 |  | $new_name
 | ) |

Renames a table.

Parameters
$table | The current name of the table to be renamed.
$new_name | The new name for the table.

Definition at line 2805 of file database.inc.

References Database\getConnection().

Referenced by block_update_7002(), comment_update_7002(), field_sql_storage_field_storage_delete_field(), filter_update_7000(), filter_update_7003(), forum_update_7003(), hook_field_storage_delete_field(), image_update_7001(), node_update_7001(), poll_update_7001(), profile_update_7001(), taxonomy_update_7001(), and update_fix_d7_requirements().

db_table_exists ( $table )

Checks if a table exists.

Parameters
$table The name of the table in drupal (no prefixing).
Returns
TRUE if the given table exists, otherwise FALSE.

Definition at line 2760 of file database.inc.

References Database\getConnection().

Referenced by ajax_example_update_7100(), drupal_uninstall_schema(), field_sql_storage_field_storage_update_field(), field_sql_storage_schema(), field_sql_storage_update_7001(), image_update_7000(), image_update_7001(), menu_update_7002(), system_update_7053(), system_update_7060(), system_update_7061(), tabledrag_example_install(), tablesort_example_install(), update_fix_d7_block_deltas(), update_fix_d7_requirements(), update_info_page(), update_prepare_d7_bootstrap(), and user_system_info_alter().

drupal_check_memory_limit | ( | $required,
 |  | $memory_limit = NULL
 | ) |

Compares the memory required for an operation to the available memory.

Parameters
$required | The memory required for the operation, expressed as a number of bytes with optional SI or IEC binary unit prefix (e.g. 2, 3K, 5MB, 10G, 6GiB, 8bytes, 9mbytes).
$memory_limit | (optional) The memory limit for the operation, expressed as a number of bytes with optional SI or IEC binary unit prefix (e.g. 2, 3K, 5MB, 10G, 6GiB, 8bytes, 9mbytes). If no value is passed, the current PHP memory_limit will be used. Defaults to NULL.
Returns
TRUE if there is sufficient memory to allow the operation, or FALSE otherwise.

Definition at line 3477 of file bootstrap.inc.

References parse_size().

Referenced by color_scheme_form_submit(), simpletest_requirements(), and system_requirements().

drupal_get_complete_schema ( $rebuild = FALSE )

Gets the whole database schema.

The returned schema will include any modifications made by any module that implements hook_schema_alter().

Parameters
$rebuild If true, the schema will be rebuilt instead of retrieved from the cache.

Definition at line 2995 of file bootstrap.inc.

References $module, _drupal_schema_initialize(), cache_clear_all(), cache_get(), cache_set(), drupal_alter(), DRUPAL_BOOTSTRAP_FULL, drupal_get_bootstrap_phase(), DRUPAL_ROOT, module_implements(), module_invoke(), module_list(), and module_load_all_includes().

Referenced by drupal_get_schema(), and SchemaCache\resolveCacheMiss().

drupal_get_schema | ( | $table = NULL,
 |  | $rebuild = FALSE
 | ) |

Gets the schema definition of a table, or the whole database schema.

The returned schema will include any modifications made by any module that implements hook_schema_alter().

Parameters
$table | The name of the table. If not given, the schema of all tables is returned.
$rebuild | If true, the schema will be rebuilt instead of retrieved from the cache.

Definition at line 2940 of file bootstrap.inc.

References drupal_get_complete_schema().

Referenced by _node_query_node_access_alter(), drupal_schema_fields_sql(), drupal_write_record(), field_sql_storage_field_storage_create_field(), field_sql_storage_field_storage_delete_field(), field_sql_storage_field_storage_update_field(), hook_field_storage_create_field(), hook_field_storage_delete_field(), hook_field_storage_update_field(), install_configure_form(), install_finished(), DrupalDatabaseCache\isValidBin(), module_enable(), profile_field_form_validate(), EntityFieldQuery\propertyQuery(), DrupalWebTestCase\resetAll(), and user_account_form_validate().

drupal_get_schema_unprocessed | ( | $module,
 |  | $table = NULL
 | ) |

Returns the unprocessed and unaltered version of a module's schema.

Use this function only if you explicitly need the original specification of a schema, as it was defined in a module's hook_schema(). No additional default values will be set, hook_schema_alter() is not invoked and these unprocessed definitions won't be cached.

This function can be used to retrieve a schema specification in hook_schema(), so it allows you to derive your tables from existing specifications.

It is also used by drupal_install_schema() and drupal_uninstall_schema() to ensure that a module's tables are created exactly as specified without any changes introduced by a module that implements hook_schema_alter().

Parameters
$module | The module to which the table belongs.
$table | The name of the table. If not given, the module's complete schema is returned.

Definition at line 6998 of file common.inc.

References $module, module_invoke(), and module_load_install().

Referenced by block_schema(), drupal_install_schema(), drupal_uninstall_schema(), field_schema(), filter_schema(), image_schema(), simpletest_clean_database(), and update_schema().

drupal_install_schema ( $module )

Creates all tables defined in a module's hook_schema().

Note: This function does not pass the module's schema through hook_schema_alter(). The module's tables will be created exactly as the module defines them.

Parameters
$module The module for which the tables will be created.

Definition at line 6939 of file common.inc.

References $module, $name, _drupal_schema_initialize(), db_create_table(), and drupal_get_schema_unprocessed().

Referenced by module_enable(), and system_install().

drupal_is_cli ( )

Detects whether the current script is running in a command-line environment.

Definition at line 3381 of file bootstrap.inc.

Referenced by _drupal_bootstrap_page_header(), _drupal_log_error(), drupal_page_is_cacheable(), and drupal_session_start().

drupal_placeholder ( $text )

Formats text for emphasized display in a placeholder inside a sentence.

Used automatically by format_string().

Parameters
$text The text to format (plain-text).
Returns
The formatted text (html).

Definition at line 3396 of file bootstrap.inc.

References check_plain().

Referenced by filter_admin_overview(), filter_permission(), format_string(), node_revision_overview(), profile_browse(), and theme_update_report().

drupal_schema_fields_sql | ( | $table,
 |  | $prefix = NULL
 | ) |

Retrieves a list of fields from a table schema.

The returned list is suitable for use in an SQL query.

Parameters
$table | The name of the table from which to retrieve fields.
An | optional prefix to to all fields.
Returns
An array of fields.

Definition at line 7055 of file common.inc.

References drupal_get_schema().

Referenced by entity_get_info(), system_admin_menu_block(), and system_get_module_admin_tasks().

& drupal_static | ( | $name,
 |  | $default_value = NULL,
 |  | $reset = FALSE
 | ) |

End of "addtogroup registry". Provides central static variable storage.

All functions requiring a static variable to persist or cache data within a single page request are encouraged to use this function unless it is absolutely certain that the static variable will not need to be reset during the page request. By centralizing static variable storage through this function, other functions can rely on a consistent API for resetting any other function's static variables.

Example:

* function language_list($field = 'language') {
* $languages = &drupal_static(__FUNCTION__);
* if (!isset($languages)) {
* // If this function is being called for the first time after a reset,
* // query the database and execute any other code needed to retrieve
* // information about the supported languages.
* ...
* }
* if (!isset($languages[$field])) {
* // If this function is being called for the first time for a particular
* // index field, then execute code needed to index the information already
* // available in $languages by the desired field.
* ...
* }
* // Subsequent invocations of this function for a particular index field
* // skip the above two code blocks and quickly return the already indexed
* // information.
* return $languages[$field];
* }
* function locale_translate_overview_screen() {
* // When building the content for the translations overview page, make
* // sure to get completely fresh information about the supported languages.
* drupal_static_reset('language_list');
* ...
* }
*

In a few cases, a function can have certainty that there is no legitimate use-case for resetting that function's static variable. This is rare, because when writing a function, it's hard to forecast all the situations in which it will be used. A guideline is that if a function's static variable does not depend on any information outside of the function that might change during a single page request, then it's ok to use the "static" keyword instead of the drupal_static() function.

Example:

* function actions_do(...) {
* // $stack tracks the number of recursive calls.
* static $stack;
* $stack++;
* if ($stack > variable_get('actions_max_stack', 35)) {
* ...
* return;
* }
* ...
* $stack--;
* }
*

In a few cases, a function needs a resettable static variable, but the function is called many times (100+) during a single page request, so every microsecond of execution time that can be removed from the function counts. These functions can use a more cumbersome, but faster variant of calling drupal_static(). It works by storing the reference returned by drupal_static() in the calling function's own static variable, thereby removing the need to call drupal_static() for each iteration of the function. Conceptually, it replaces:

* $foo = &drupal_static(__FUNCTION__);
*

with:

* // Unfortunately, this does not work.
* static $foo = &drupal_static(__FUNCTION__);
*

However, the above line of code does not work, because PHP only allows static variables to be initializied by literal values, and does not allow static variables to be assigned to references.

  • http://php.net/manual/language.variables.scope.php#language.variables.scope.static
  • http://php.net/manual/language.variables.scope.php#language.variables.scope.references The example below shows the syntax needed to work around both limitations. For benchmarks and more information, see http://drupal.org/node/619666.

Example:

* function user_access($string, $account = NULL) {
* // Use the advanced drupal_static() pattern, since this is called very often.
* static $drupal_static_fast;
* if (!isset($drupal_static_fast)) {
* $drupal_static_fast['perm'] = &drupal_static(__FUNCTION__);
* }
* $perm = &$drupal_static_fast['perm'];
* ...
* }
*
Parameters
$name | Globally unique name for the variable. For a function with only one static, variable, the function name (e.g. via the PHP magic FUNCTION constant) is recommended. For a function with multiple static variables add a distinguishing suffix to the function name for each one.
$default_value | Optional default value.
$reset | TRUE to reset a specific named variable, or all variables if $name is NULL. Resetting every variable should only be used, for example, for running unit tests with a clean environment. Should be used only though via function drupal_static_reset() and the return value should not be used in this case.
Returns
Returns a variable by reference.
See Also
drupal_static_reset()

Definition at line 3335 of file bootstrap.inc.

References $name, and $value.

Referenced by _block_compare(), _drupal_build_css_path(), _drupal_session_read(), _drupal_session_write(), _field_info_field_cache(), _field_sql_storage_query_field_conditions(), _form_options_flatten(), _forum_user_last_visit(), _locale_import_one_string(), _locale_translate_seek_query(), _menu_build_tree(), _menu_clear_page_cache(), _menu_overview_tree_form(), _menu_router_cache(), _node_revision_access(), _node_types_build(), _openid_dh_rand(), _rdf_get_default_mapping(), _trigger_get_all_info(), _update_create_fetch_task(), _update_manager_cache_directory(), _update_manager_extract_directory(), _update_manager_unique_identifier(), _update_process_fetch_task(), actions_list(), aggregator_category_load(), aggregator_feed_load(), archiver_get_info(), arg(), block_admin_display_prepare_blocks(), block_list(), book_get_books(), book_get_flat_menu(), book_menu_subtree_data(), DrupalWebTestCase\checkPermissions(), comment_node_update_index(), conf_path(), dashboard_regions(), drupal_add_css(), drupal_add_feed(), drupal_add_html_head(), drupal_add_http_header(), drupal_add_js(), drupal_add_library(), drupal_add_tabledrag(), drupal_alter(), drupal_cache_system_paths(), drupal_get_destination(), drupal_get_filetransfer_info(), drupal_get_http_header(), drupal_get_library(), drupal_get_schema_versions(), drupal_get_updaters(), drupal_html_id(), drupal_is_front_page(), drupal_lookup_path(), drupal_mail_system(), drupal_match_path(), drupal_page_header(), drupal_page_is_cacheable(), drupal_parse_info_file(), drupal_render_collect_attached(), drupal_render_page(), drupal_retrieve_form(), drupal_send_headers(), drupal_set_breadcrumb(), drupal_set_page_content(), drupal_set_title(), drupal_static_reset(), drupal_validate_form(), element_info(), entity_get_controller(), entity_get_info(), field_available_languages(), field_language(), field_ui_field_type_options(), field_ui_formatter_options(), field_ui_widget_type_options(), field_view_mode_settings(), file_get_file_references(), file_get_stream_wrappers(), file_mimetype_mapping(), filter_formats(), filter_get_filters(), filter_list_format(), form_set_error(), format_date(), forum_field_storage_pre_update(), forum_forum_load(), hook_field_storage_pre_update(), hook_field_update(), image_effect_definitions(), image_effects(), image_styles(), install_profile_info(), ip_address(), language_fallback_get_candidates(), language_list(), language_negotiation_info(), language_provider_invoke(), language_types_configurable(), language_types_info(), list_allowed_values(), list_themes(), locale(), locale_get_plural(), locale_language_name(), locale_language_url_rewrite_url(), locale_url_outbound_alter(), map_month(), menu_cache_clear(), menu_contextual_links(), menu_get_custom_theme(), menu_get_item(), menu_get_names(), menu_link_get_preferred(), menu_load_all(), menu_local_tasks(), menu_set_active_menu_names(), menu_set_active_trail(), menu_tree(), menu_tree_all_data(), menu_tree_page_data(), menu_tree_set_path(), module_hook_info(), module_implements(), module_implements_write_cache(), node_access(), node_access_view_all_nodes(), node_last_viewed(), node_mark(), overlay_display_empty_page(), overlay_render_region(), overlay_set_mode(), overlay_set_regions_to_render(), overlay_store_rendered_content(), pager_get_query_parameters(), path_get_admin_paths(), path_is_admin(), shortcut_current_displayed_set(), simpletest_test_get_all(), syslog_watchdog(), system_admin_menu_block(), system_get_module_admin_tasks(), system_list(), system_rebuild_module_data(), taxonomy_get_children(), taxonomy_get_parents(), taxonomy_get_parents_all(), taxonomy_get_tree(), taxonomy_vocabulary_get_names(), template_preprocess(), template_preprocess_block(), theme_comment_post_forbidden(), theme_get_registry(), theme_get_setting(), token_info(), toolbar_in_active_trail(), translation_node_get_translations(), trigger_get_assigned_actions(), update_get_projects(), user_access(), and user_role_permissions().

drupal_static_reset ( $name = NULL )

Resets one or all centrally stored static variable(s).

Parameters
$name Name of the static variable to reset. Omit to reset all variables.

Definition at line 3374 of file bootstrap.inc.

References $name, and drupal_static().

Referenced by _book_update_outline(), _form_validate(), block_page_build(), book_node_delete(), drupal_clear_path_cache(), drupal_process_form(), drupal_rewrite_settings(), drupal_theme_initialize(), drupal_theme_rebuild(), entity_info_cache_clear(), field_info_cache_clear(), field_sql_storage_field_storage_query(), filter_formats_reset(), filter_modules_disabled(), filter_modules_enabled(), form_clear_error(), form_options_flatten(), hook_field_update_field(), image_style_flush(), install_settings_form(), install_verify_settings(), language_negotiation_purge(), language_types_set(), list_field_update_field(), locale_add_language(), locale_languages_overview_form(), locale_reset(), locale_translate_export_screen(), locale_translate_import_form(), locale_translate_import_form_submit(), locale_translate_overview_screen(), locale_translation_filters(), menu_reset_static_cache(), menu_set_active_item(), module_implements(), module_list(), node_type_cache_reset(), DrupalWebTestCase\resetAll(), DrupalUnitTestCase\setUp(), DrupalWebTestCase\setUp(), shortcut_set_assign_user(), system_add_date_format_type_form(), system_date_time_formats(), system_date_time_settings(), system_list_reset(), taxonomy_terms_static_reset(), taxonomy_vocabulary_static_reset(), trigger_actions_delete(), trigger_assign_form_submit(), trigger_unassign_submit(), user_role_delete(), user_role_grant_permissions(), user_role_revoke_permissions(), and user_role_save().

drupal_uninstall_schema ( $module )

Removes all tables defined in a module's hook_schema().

Note: This function does not pass the module's schema through hook_schema_alter(). The module's tables will be created exactly as the module defines them.

Parameters
$module The module for which the tables will be removed.
Returns
An array of arrays with the following key/value pairs:
  • success: a boolean indicating whether the query succeeded.
  • query: the SQL query(s) executed, passed through check_plain().

Definition at line 6963 of file common.inc.

References $module, _drupal_schema_initialize(), db_drop_table(), db_table_exists(), and drupal_get_schema_unprocessed().

Referenced by drupal_uninstall_modules().

drupal_write_record | ( |  | $table,
 |  | & | $record,
 |  |  | $primary_keys = array()
 | ) |  |

Saves (inserts or updates) a record to the database based upon the schema.

Do not use drupal_write_record() within hook_update_N() functions, since the database schema cannot be relied upon when a user is running a series of updates. Instead, use db_insert() or db_update() to save the record.

Parameters
$table | The name of the table; this must be defined by a hook_schema() implementation.
$record | An object or array representing the record to write, passed in by reference. If inserting a new record, values not provided in $record will be populated in $record and in the database with the default values from the schema, as well as a single serial (auto-increment) field (if present). If updating an existing record, only provided values are updated in the database, and $record is not modified.
$primary_keys | To indicate that this is a new record to be inserted, omit this argument. If this is an update, this argument specifies the primary keys' field names. If there is only 1 field in the key, you may pass in a string; if there are multiple fields in the key, pass in an array.
Returns
If the record insert or update failed, returns FALSE. If it succeeded, returns SAVED_NEW or SAVED_UPDATED, depending on the operation performed.

Definition at line 7097 of file common.inc.

References $info, db_insert(), db_update(), drupal_get_schema(), Database\RETURN_AFFECTED, Database\RETURN_INSERT_ID, SAVED_NEW, and SAVED_UPDATED.

Referenced by _block_rehash(), _field_write_instance(), _node_save_revision(), block_theme_initialize(), comment_save(), contact_category_edit_form_submit(), field_create_field(), field_update_field(), file_save(), hook_menu_link_insert(), image_effect_save(), image_style_save(), locale_date_format_save(), node_save(), path_save(), EntityExampleBasicController\save(), shortcut_set_save(), system_date_format_save(), system_date_format_type_save(), taxonomy_term_save(), taxonomy_vocabulary_save(), user_role_save(), and user_save().

hook_schema ( )

Define the current version of the database schema.

A Drupal schema definition is an array structure representing one or more tables and their related keys and indexes. A schema is defined by hook_schema() which must live in your module's .install file.

This hook is called at install and uninstall time, and in the latter case, it cannot rely on the .module file being loaded or hooks being known. If the .module file is needed, it may be loaded with drupal_load().

The tables declared by this hook will be automatically created when the module is first enabled, and removed when the module is uninstalled. This happens before hook_install() is invoked, and after hook_uninstall() is invoked, respectively.

By declaring the tables used by your module via an implementation of hook_schema(), these tables will be available on all supported database engines. You don't have to deal with the different SQL dialects for table creation and alteration of the supported database engines.

See the Schema API Handbook at http://drupal.org/node/146843 for details on schema definition structures.

Returns
array A schema definition structure array. For each element of the array, the key is a table name and the value is a table structure definition.
See Also
hook_schema_alter()

Definition at line 3133 of file system.api.php.

hook_schema_alter ( & $schema )

Perform alterations to existing database schemas.

When a module modifies the database structure of another module (by changing, adding or removing fields, keys or indexes), it should implement hook_schema_alter() to update the default $schema to take its changes into account.

See hook_schema() for details on the schema definition structure.

Parameters
$schema Nested array describing the schemas for all modules.

Definition at line 3204 of file system.api.php.

offsetExists ( $offset )

Implements ArrayAccess::offsetExists().

Definition at line 348 of file bootstrap.inc.

References DrupalCacheArray\offsetGet().

offsetGet ( $offset )

Implements ArrayAccess::offsetGet().

Definition at line 355 of file bootstrap.inc.

References DrupalCacheArray\resolveCacheMiss().

Referenced by DrupalCacheArray\offsetExists().

offsetSet | ( | $offset,
 |  | $value
 | ) |

Implements ArrayAccess::offsetSet().

Definition at line 367 of file bootstrap.inc.

References $value.

offsetUnset ( $offset )

Implements ArrayAccess::offsetUnset().

Definition at line 374 of file bootstrap.inc.

persist | ( | $offset,
 |  | $persist = TRUE
 | ) |
protected

Flags an offset value to be written to the persistent cache.

If a value is assigned to a cache object with offsetSet(), by default it will not be written to the persistent cache unless it is flagged with this method. This allows items to be cached for the duration of a request, without necessarily writing back to the persistent cache at the end.

Parameters
$offset | The array offset that was requested.
$persist | Optional boolean to specify whether the offset should be persisted or not, defaults to TRUE. When called with $persist = FALSE the offset will be unflagged so that it will not be written at the end of the request.

Definition at line 393 of file bootstrap.inc.

Referenced by SchemaCache\resolveCacheMiss().

resolveCacheMiss ( $offset )
abstractprotected

Resolves a cache miss.

When an offset is not found in the object, this is treated as a cache miss. This method allows classes implementing the interface to look up the actual value and allow it to be cached.

Parameters
$offset The offset that was requested.
Returns
The value of the offset, or NULL if no value was found.

Referenced by DrupalCacheArray\offsetGet().

resolveCacheMiss ( $offset )
protected

Overrides DrupalCacheArray::resolveCacheMiss().

Definition at line 2977 of file bootstrap.inc.

References $value, drupal_get_complete_schema(), and DrupalCacheArray\persist().

set | ( | $data,
 |  | $lock = TRUE
 | ) |
protected

Writes a value to the persistent cache immediately.

Parameters
$data | The data to write to the persistent cache.
$lock | Whether to acquire a lock before writing to cache.

Definition at line 420 of file bootstrap.inc.

References DrupalCacheArray\$bin, cache_get(), cache_set(), lock_acquire(), and lock_release().

Referenced by DrupalCacheArray\__destruct().

Variable Documentation

$bin
protected

A bin to pass to cache_set() and cache_get().

Definition at line 316 of file bootstrap.inc.

Referenced by DrupalCacheArray\__construct(), and DrupalCacheArray\set().

$cid
protected

A cid to pass to cache_set() and cache_get().

Definition at line 311 of file bootstrap.inc.

Referenced by DrupalCacheArray\__construct().

$keysToPersist = array()
protected

An array of keys to add to the cache at the end of the request.

Definition at line 321 of file bootstrap.inc.

$storage = array()
protected

Storage for the data itself.

Definition at line 326 of file bootstrap.inc.

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Code registry

Functions
Code registry
Schema API

Functions

drupal_autoload_interface ($interface)
drupal_autoload_class ($class)
_registry_check_code ($type, $name=NULL)
registry_rebuild ()
registry_update ()
_registry_update ()
registry_get_parsed_files ()
_registry_parse_files ($files)
_registry_parse_file ($filename, $contents, $module= '', $weight=0)

Detailed Description

The code registry engine.

Drupal maintains an internal registry of all functions or classes in the system, allowing it to lazy-load code files as needed (reducing the amount of code that must be parsed on each request).

End of "addtogroup schemaapi".

Function Documentation

_registry_check_code | ( | $type,
 |  | $name = NULL
 | ) |

Checks for a resource in the registry.

Parameters
$type | The type of resource we are looking up, or one of the constants REGISTRY_RESET_LOOKUP_CACHE or REGISTRY_WRITE_LOOKUP_CACHE, which signal that we should reset or write the cache, respectively.
$name | The name of the resource, or NULL if either of the REGISTRY_* constants is passed in.
Returns
TRUE if the resource was found, FALSE if not. NULL if either of the REGISTRY_* constants is passed in as $type.

Definition at line 3103 of file bootstrap.inc.

References $name, cache_get(), cache_set(), DRUPAL_ROOT, Database\getConnection(), REGISTRY_RESET_LOOKUP_CACHE, and REGISTRY_WRITE_LOOKUP_CACHE.

Referenced by _registry_update(), drupal_autoload_class(), drupal_autoload_interface(), and drupal_page_footer().

_registry_parse_file | ( | $filename,
 |  | $contents,
 |  | $module = '',
 |  | $weight = 0
 | ) |

Parse a file and save its function and class listings.

Parameters
$filename | Name of the file we are going to parse.
$contents | Contents of the file we are going to parse as a string.
$module | (optional) Name of the module this file belongs to.
$weight | (optional) Weight of the module.

Definition at line 163 of file registry.inc.

References $contents, $module, $name, db_delete(), and db_merge().

Referenced by _registry_parse_files().

_registry_parse_files ( $files )

Parse all files that have changed since the registry was last built, and save their function and class listings.

Parameters
$files The list of files to check and parse.

Definition at line 128 of file registry.inc.

References _registry_parse_file(), and db_merge().

Referenced by _registry_update().

_registry_update ( )

Does the work for registry_update().

Definition at line 21 of file registry.inc.

References $dir, $module, _registry_check_code(), _registry_parse_files(), cache_get(), cache_set(), db_delete(), db_query(), db_transaction(), drupal_alter(), DRUPAL_ROOT, file_scan_directory(), Database\getConnectionInfo(), module_implements(), registry_get_parsed_files(), REGISTRY_RESET_LOOKUP_CACHE, and watchdog_exception().

Referenced by registry_update().

drupal_autoload_class ( $class )

Confirms that a class is available.

This function is rarely called directly. Instead, it is registered as an spl_autoload() handler, and PHP calls it for us when necessary.

Parameters
$class The name of the class to check or load.
Returns
TRUE if the class is currently available, FALSE otherwise.

Definition at line 3084 of file bootstrap.inc.

References _registry_check_code().

drupal_autoload_interface ( $interface )

Confirms that an interface is available.

This function is rarely called directly. Instead, it is registered as an spl_autoload() handler, and PHP calls it for us when necessary.

Parameters
$interface The name of the interface to check or load.
Returns
TRUE if the interface is currently available, FALSE otherwise.

Definition at line 3068 of file bootstrap.inc.

References _registry_check_code().

registry_get_parsed_files ( )

Return the list of files in registry_file

Definition at line 115 of file registry.inc.

References db_query().

Referenced by _registry_update().

registry_rebuild ( )

Rescans all enabled modules and rebuilds the registry.

Rescans all code in modules or includes directories, storing the location of each interface or class in the database.

Definition at line 3175 of file bootstrap.inc.

References registry_update(), and system_rebuild_module_data().

Referenced by drupal_flush_all_caches(), and simpletest_clean_environment().

registry_update ( )

Updates the registry based on the latest files listed in the database.

This function should be used when system_rebuild_module_data() does not need to be called, because it is already known that the list of files in the {system} table matches those in the file system.

Returns
TRUE if the registry was rebuilt, FALSE if another thread was rebuilding in parallel and the current thread just waited for completion.
See Also
registry_rebuild()

Definition at line 3193 of file bootstrap.inc.

References _registry_update(), drupal_installation_attempted(), DRUPAL_ROOT, lock_acquire(), lock_release(), and lock_wait().

Referenced by module_disable(), module_enable(), and registry_rebuild().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: File interface

Functions | Variables
File interface

Functions

file_get_stream_wrappers ($filter=STREAM_WRAPPERS_ALL)
file_stream_wrapper_get_class ($scheme)
file_uri_scheme ($uri)
file_stream_wrapper_valid_scheme ($scheme)
file_uri_target ($uri)
file_default_scheme ()
file_stream_wrapper_uri_normalize ($uri)
file_stream_wrapper_get_instance_by_uri ($uri)
file_stream_wrapper_get_instance_by_scheme ($scheme)
file_create_url ($uri)
file_prepare_directory (&$directory, $options=FILE_MODIFY_PERMISSIONS)
file_ensure_htaccess ()
file_create_htaccess ($directory, $private=TRUE, $force_overwrite=FALSE)
file_htaccess_lines ($private=TRUE)
file_load_multiple ($fids=array(), $conditions=array())
file_load ($fid)
file_save (stdClass $file)
file_usage_list (stdClass $file)
file_usage_add (stdClass $file, $module, $type, $id, $count=1)
file_usage_delete (stdClass $file, $module, $type=NULL, $id=NULL, $count=1)
file_copy (stdClass $source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
file_valid_uri ($uri)
file_unmanaged_copy ($source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
file_build_uri ($path)
file_destination ($destination, $replace)
file_move (stdClass $source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
file_unmanaged_move ($source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
file_munge_filename ($filename, $extensions, $alerts=TRUE)
file_unmunge_filename ($filename)
file_create_filename ($basename, $directory)
file_delete (stdClass $file, $force=FALSE)
file_unmanaged_delete ($path)
file_unmanaged_delete_recursive ($path)
file_space_used ($uid=NULL, $status=FILE_STATUS_PERMANENT)
file_save_upload ($source, $validators=array(), $destination=FALSE, $replace=FILE_EXISTS_RENAME)
file_validate (stdClass &$file, $validators=array())
file_validate_name_length (stdClass $file)
file_validate_extensions (stdClass $file, $extensions)
file_validate_size (stdClass $file, $file_limit=0, $user_limit=0)
file_validate_is_image (stdClass $file)
file_validate_image_resolution (stdClass $file, $maximum_dimensions=0, $minimum_dimensions=0)
file_save_data ($data, $destination=NULL, $replace=FILE_EXISTS_RENAME)
file_unmanaged_save_data ($data, $destination=NULL, $replace=FILE_EXISTS_RENAME)
file_transfer ($uri, $headers)
file_download ()
file_scan_directory ($dir, $mask, $options=array(), $depth=0)
file_upload_max_size ()
file_get_mimetype ($uri, $mapping=NULL)
file_directory_temp ()
file_get_content_headers ($file)

Variables

const | FILE_CREATE_DIRECTORY 1
const | FILE_MODIFY_PERMISSIONS 2
const | FILE_EXISTS_RENAME 0
const | FILE_EXISTS_REPLACE 1
const | FILE_EXISTS_ERROR 2
const | FILE_STATUS_PERMANENT 1

Detailed Description

Manually include stream wrapper code.

Stream wrapper code is included here because there are cases where File API is needed before a bootstrap, or in an alternate order (e.g. maintenance theme).

Common file handling functions.

Fields on the file object:

  • fid: File ID
  • uid: The {users}.uid of the user who is associated with the file.
  • filename: Name of the file with no path components. This may differ from the basename of the filepath if the file is renamed to avoid overwriting an existing file.
  • uri: URI of the file.
  • filemime: The file's MIME type.
  • filesize: The size of the file in bytes.
  • status: A bitmapped field indicating the status of the file. The first 8 bits are reserved for Drupal core. The least significant bit indicates temporary (0) or permanent (1). Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during cron runs.
  • timestamp: UNIX timestamp for the date the file was added to the database.

Function Documentation

file_build_uri ( $path )

Constructs a URI to Drupal's default files location given a relative path.

Definition at line 960 of file file.inc.

References file_default_scheme(), and file_stream_wrapper_uri_normalize().

Referenced by file_unmanaged_copy(), image_style_url(), and system_retrieve_file().

file_copy | ( | stdClass | $source,
 |  |  | $destination = NULL,
 |  |  | $replace = FILE_EXISTS_RENAME
 | ) |  |

Copies a file to a new location and adds a file record to the database.

This function should be used when manipulating files that have records stored in the database. This is a powerful function that in many ways performs like an advanced version of copy().

  • Checks if $source and $destination are valid and readable/writable.
  • If file already exists in $destination either the call will error out, replace the file or rename the file based on the $replace parameter.
  • If the $source and $destination are equal, the behavior depends on the $replace parameter. FILE_EXISTS_REPLACE will error out. FILE_EXISTS_RENAME will rename the file until the $destination is unique.
  • Adds the new file to the files database. If the source file is a temporary file, the resulting file will also be a temporary file. See file_save_upload() for details on temporary files.
Parameters
$source | A file object.
$destination | A string containing the destination that $source should be copied to. This must be a stream wrapper URI.
$replace Replace behavior when the destination file already exists:
  • FILE_EXISTS_REPLACE - Replace the existing file. If a managed file with the destination name exists then its database entry will be updated. If no database entry is found then a new one will be created.
  • FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique.
  • FILE_EXISTS_ERROR - Do nothing and return FALSE.
Returns
File object if the copy is successful, or FALSE in the event of an error.
See Also
file_unmanaged_copy()
hook_file_copy()

Definition at line 786 of file file.inc.

References drupal_basename(), drupal_realpath(), drupal_set_message(), FILE_EXISTS_RENAME, FILE_EXISTS_REPLACE, file_load_multiple(), file_save(), file_unmanaged_copy(), file_valid_uri(), module_invoke_all(), t(), and watchdog().

file_create_filename | ( | $basename,
 |  | $directory
 | ) |

Creates a full file path from a directory and filename.

If a file with the specified name already exists, an alternative will be used.

Parameters
$basename | String filename
$directory | String containing the directory or parent URI.
Returns
File path consisting of $directory and a unique filename based off of $basename.

Definition at line 1206 of file file.inc.

References $name.

Referenced by file_destination().

file_create_htaccess | ( | $directory,
 |  | $private = TRUE,
 |  | $force_overwrite = FALSE
 | ) |

Creates a .htaccess file in the given directory.

Parameters
$directory | The directory.
$private | FALSE indicates that $directory should be an open and public directory. The default is TRUE which indicates a private and protected directory.
$force_overwrite | Set to TRUE to attempt to overwrite the existing .htaccess file if one is already present. Defaults to FALSE.

Definition at line 477 of file file.inc.

References check_plain(), drupal_chmod(), file_htaccess_lines(), file_stream_wrapper_uri_normalize(), file_uri_scheme(), watchdog(), and WATCHDOG_ERROR.

Referenced by file_ensure_htaccess(), and system_check_directory().

file_create_url ( $uri )

Creates a web-accessible URL for a stream to an external or local file.

Compatibility: normal paths and stream wrappers.

There are two kinds of local files:

  • "managed files", i.e. those stored by a Drupal-compatible stream wrapper. These are files that have either been uploaded by users or were generated automatically (for example through CSS aggregation).
  • "shipped files", i.e. those outside of the files directory, which ship as part of Drupal core or contributed modules or themes.
Parameters
$uri The URI to a file for which we need an external URL, or the path to a shipped file.
Returns
A string containing a URL that may be used to access the file. If the provided string already contains a preceding 'http', 'https', or '/', nothing is done and the same string is returned. If a stream wrapper could not be found to generate an external URL, then FALSE is returned.
See Also
http://drupal.org/node/515192

Definition at line 372 of file file.inc.

References drupal_alter(), drupal_encode_path(), drupal_substr(), file_stream_wrapper_get_instance_by_uri(), and file_uri_scheme().

Referenced by _color_page_alter(), drupal_build_css_cache(), drupal_get_js(), drupal_pre_render_styles(), file_example_managed_write_submit(), file_example_read_submit(), file_example_unmanaged_php_submit(), file_example_unmanaged_write_submit(), file_field_formatter_view(), image_field_formatter_view(), image_style_url(), rdf_preprocess_field(), system_tokens(), theme_file_link(), theme_get_setting(), theme_image(), theme_image_button(), theme_image_style_preview(), and DrupalTestCase\verbose().

file_default_scheme ( )

Gets the default file stream implementation.

Returns
'public', 'private' or any other file scheme defined as the default.

Definition at line 256 of file file.inc.

References variable_get().

Referenced by file_build_uri(), file_save_data(), image_install(), image_style_path(), image_uninstall(), system_requirements(), system_update_7060(), system_update_7061(), user_admin_settings(), and user_save().

file_delete | ( | stdClass | $file,
 |  |  | $force = FALSE
 | ) |  |

Deletes a file and its database record.

If the $force parameter is not TRUE, file_usage_list() will be called to determine if the file is being used by any modules. If the file is being used the delete will be canceled.

Parameters
$file | A file object.
$force | Boolean indicating that the file should be deleted even if the file is reported as in use by the file_usage table.
Returns
mixed TRUE for success, FALSE in the event of an error, or an array if the file is being used by any modules.
See Also
file_unmanaged_delete()
file_usage_list()
file_usage_delete()
hook_file_delete()

Definition at line 1268 of file file.inc.

References db_delete(), drupal_realpath(), drupal_set_message(), file_unmanaged_delete(), file_usage_list(), file_valid_uri(), module_invoke_all(), t(), and watchdog().

Referenced by file_example_delete_submit(), file_field_delete_file(), file_managed_file_submit(), file_move(), image_example_style_form_submit(), system_cron(), and user_save().

file_destination | ( | $destination,
 |  | $replace
 | ) |

Determines the destination path for a file.

Parameters
$destination A string specifying the desired final URI or filepath.
$replace Replace behavior when the destination file already exists.
  • FILE_EXISTS_REPLACE - Replace the existing file.
  • FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique.
  • FILE_EXISTS_ERROR - Do nothing and return FALSE.
Returns
The destination filepath, or FALSE if the file already exists and FILE_EXISTS_ERROR is specified.

Definition at line 981 of file file.inc.

References drupal_basename(), drupal_dirname(), file_create_filename(), FILE_EXISTS_ERROR, FILE_EXISTS_RENAME, and FILE_EXISTS_REPLACE.

Referenced by file_save_upload(), and file_unmanaged_copy().

file_directory_temp ( )

Gets the path of system-appropriate temporary directory.

Definition at line 2446 of file file.inc.

References conf_path(), variable_get(), and variable_set().

Referenced by DrupalTemporaryStreamWrapper\getDirectoryPath(), system_file_system_settings(), system_requirements(), and system_update_7066().

file_download ( )

Menu handler for private file transfers.

Call modules that implement hook_file_download() to find out if a file is accessible and what headers it should be transferred with. If one or more modules returned headers the download will start with the returned headers. If a module returns -1 drupal_access_denied() will be returned. If the file exists but no modules responded drupal_access_denied() will be returned. If the file does not exist drupal_not_found() will be returned.

See Also
system_menu()

Definition at line 1989 of file file.inc.

References $module, drupal_access_denied(), drupal_exit(), drupal_not_found(), file_stream_wrapper_valid_scheme(), file_transfer(), and module_implements().

Referenced by image_style_deliver().

file_ensure_htaccess ( )

Creates a .htaccess file in each Drupal files directory if it is missing.

Definition at line 457 of file file.inc.

References file_create_htaccess(), and variable_get().

Referenced by file_unmanaged_copy(), install_system_module(), and system_requirements().

file_get_content_headers ( $file )

Examines a file object and returns appropriate content headers for download.

Parameters
$file A file object.
Returns
An associative array of headers, as expected by file_transfer().

Definition at line 2505 of file file.inc.

References $name, and mime_header_encode().

Referenced by file_file_download().

file_get_mimetype | ( | $uri,
 |  | $mapping = NULL
 | ) |

Determines an Internet Media Type or MIME type from a filename.

Parameters
$uri A string containing the URI, path, or filename.
$mapping An optional map of extensions to their mimetypes, in the form:
  • 'mimetypes': a list of mimetypes, keyed by an identifier,
  • 'extensions': the mapping itself, an associative array in which the key is the extension (lowercase) and the value is the mimetype identifier. If $mapping is NULL file_mimetype_mapping() is called.
Returns
The internet media type registered for the extension or application/octet-stream for unknown extensions.
See Also
file_default_mimetype_mapping()

Definition at line 2143 of file file.inc.

References file_stream_wrapper_get_instance_by_uri(), and DrupalLocalStreamWrapper\getMimeType().

Referenced by file_save_data(), file_save_upload(), system_theme_settings_submit(), and user_update_7012().

file_get_stream_wrappers ( $filter = STREAM_WRAPPERS_ALL )

Provides Drupal stream wrapper registry.

A stream wrapper is an abstraction of a file system that allows Drupal to use the same set of methods to access both local files and remote resources.

Provide a facility for managing and querying user-defined stream wrappers in PHP. PHP's internal stream_get_wrappers() doesn't return the class registered to handle a stream, which we need to be able to find the handler for class instantiation.

If a module registers a scheme that is already registered with PHP, the existing scheme will be unregistered and replaced with the specified class.

A stream is referenced as "scheme://target".

The optional $filter parameter can be used to retrieve only the stream wrappers that are appropriate for particular usage. For example, this returns only stream wrappers that use local file storage:

* $local_stream_wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_LOCAL);
*

The $filter parameter can only filter to types containing a particular flag. In some cases, you may want to filter to types that do not contain a particular flag. For example, you may want to retrieve all stream wrappers that are not writable, or all stream wrappers that are not local. PHP's array_diff_key() function can be used to help with this. For example, this returns only stream wrappers that do not use local file storage:

* $remote_stream_wrappers = array_diff_key(file_get_stream_wrappers(STREAM_WRAPPERS_ALL), file_get_stream_wrappers(STREAM_WRAPPERS_LOCAL));
*
Parameters
$filter (Optional) Filters out all types except those with an on bit for each on bit in $filter. For example, if $filter is STREAM_WRAPPERS_WRITE_VISIBLE, which is equal to (STREAM_WRAPPERS_READ | STREAM_WRAPPERS_WRITE | STREAM_WRAPPERS_VISIBLE), then only stream wrappers with all three of these bits set are returned. Defaults to STREAM_WRAPPERS_ALL, which returns all registered stream wrappers.
Returns
An array keyed by scheme, with values containing an array of information about the stream wrapper, as returned by hook_stream_wrappers(). If $filter is omitted or set to STREAM_WRAPPERS_ALL, the entire Drupal stream wrapper registry is returned. Otherwise only the stream wrappers whose 'type' bitmask has an on bit for each bit specified in $filter are returned.
See Also
hook_stream_wrappers()
hook_stream_wrappers_alter()

Definition at line 123 of file file.inc.

References $info, drupal_alter(), drupal_static(), module_invoke_all(), STREAM_WRAPPERS_ALL, STREAM_WRAPPERS_LOCAL, STREAM_WRAPPERS_NORMAL, and STREAM_WRAPPERS_WRITE_VISIBLE.

Referenced by _drupal_bootstrap_full(), file_field_settings_form(), file_stream_wrapper_get_class(), image_field_settings_form(), image_gd_save(), image_style_flush(), and system_file_system_settings().

file_htaccess_lines ( $private = TRUE )

Returns the standard .htaccess lines that Drupal writes to file directories.

Parameters
$private (Optional) Set to FALSE to return the .htaccess lines for an open and public directory. The default is TRUE, which returns the .htaccess lines for a private and protected directory.
Returns
A string representing the desired contents of the .htaccess file.
See Also
file_create_htaccess()

Definition at line 516 of file file.inc.

Referenced by file_create_htaccess().

file_load ( $fid )

Loads a single file object from the database.

Parameters
$fid A file ID.
Returns
An object representing the file, or FALSE if the file was not found.
See Also
hook_file_load()
file_load_multiple()

Definition at line 580 of file file.inc.

References file_load_multiple().

Referenced by file_example_get_managed_file(), file_field_presave(), file_managed_file_process(), file_managed_file_validate(), file_managed_file_value(), hook_field_prepare_view(), image_example_style_form(), image_example_style_form_submit(), image_field_delete_field(), image_field_delete_instance(), image_field_prepare_view(), image_field_presave(), image_field_update_field(), image_field_update_instance(), system_cron(), and template_preprocess_user_picture().

file_load_multiple | ( | $fids = array(),
 |  | $conditions = array()
 | ) |

Loads file objects from the database.

Parameters
$fids | An array of file IDs.
$conditions | (deprecated) An associative array of conditions on the {file_managed} table, where the keys are the database fields and the values are the values those fields must have. Instead, it is preferable to use EntityFieldQuery to retrieve a list of entity IDs loadable by this function.
Returns
An array of file objects, indexed by fid.
See Also
hook_file_load()
file_load()
entity_load()
EntityFieldQuery

Definition at line 564 of file file.inc.

References entity_load().

Referenced by UserController\attachLoad(), file_copy(), file_field_load(), file_file_download(), file_load(), file_move(), file_save_data(), file_save_upload(), image_file_download(), and user_update_7012().

file_move | ( | stdClass | $source,
 |  |  | $destination = NULL,
 |  |  | $replace = FILE_EXISTS_RENAME
 | ) |  |

Moves a file to a new location and update the file's database entry.

Moving a file is performed by copying the file to the new location and then deleting the original.

  • Checks if $source and $destination are valid and readable/writable.
  • Performs a file move if $source is not equal to $destination.
  • If file already exists in $destination either the call will error out, replace the file or rename the file based on the $replace parameter.
  • Adds the new file to the files database.
Parameters
$source | A file object.
$destination | A string containing the destination that $source should be moved to. This must be a stream wrapper URI.
$replace Replace behavior when the destination file already exists:
  • FILE_EXISTS_REPLACE - Replace the existing file. If a managed file with the destination name exists then its database entry will be updated and file_delete() called on the source file after hook_file_move is called. If no database entry is found then the source files record will be updated.
  • FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique.
  • FILE_EXISTS_ERROR - Do nothing and return FALSE.
Returns
Resulting file object for success, or FALSE in the event of an error.
See Also
file_unmanaged_move()
hook_file_move()

Definition at line 1035 of file file.inc.

References drupal_basename(), drupal_realpath(), drupal_set_message(), file_delete(), FILE_EXISTS_RENAME, FILE_EXISTS_REPLACE, file_load_multiple(), file_save(), file_unmanaged_move(), file_valid_uri(), module_invoke_all(), t(), and watchdog().

Referenced by form_example_tutorial_10_validate(), image_field_update_field(), image_field_update_instance(), and user_save().

file_munge_filename | ( | $filename,
 |  | $extensions,
 |  | $alerts = TRUE
 | ) |

Modifies a filename as needed for security purposes.

Munging a file name prevents unknown file extensions from masking exploit files. When web servers such as Apache decide how to process a URL request, they use the file extension. If the extension is not recognized, Apache skips that extension and uses the previous file extension. For example, if the file being requested is exploit.php.pps, and Apache does not recognize the '.pps' extension, it treats the file as PHP and executes it. To make this file name safe for Apache and prevent it from executing as PHP, the .php extension is "munged" into .php_, making the safe file name exploit.php_.pps.

Specifically, this function adds an underscore to all extensions that are between 2 and 5 characters in length, internal to the file name, and not included in $extensions.

Function behavior is also controlled by the Drupal variable 'allow_insecure_uploads'. If 'allow_insecure_uploads' evaluates to TRUE, no alterations will be made, if it evaluates to FALSE, the filename is 'munged'.

Parameters
$filename | File name to modify.
$extensions | A space-separated list of extensions that should not be altered.
$alerts | If TRUE, drupal_set_message() will be called to display a message if the file name was changed.
Returns
The potentially modified $filename.

Definition at line 1143 of file file.inc.

References drupal_set_message(), t(), and variable_get().

Referenced by file_example_read_submit(), and file_save_upload().

file_prepare_directory | ( | & | $directory,
 |  |  | $options = FILE_MODIFY_PERMISSIONS
 | ) |  |

Checks that the directory exists and is writable.

Directories need to have execute permissions to be considered a directory by FTP servers, etc.

Parameters
$directory | A string reference containing the name of a directory path or URI. A trailing slash will be trimmed from a path.
$options | A bitmask to indicate if the directory should be created if it does not exist (FILE_CREATE_DIRECTORY) or made writable if it is read-only (FILE_MODIFY_PERMISSIONS).
Returns
TRUE if the directory exists (or was created) and is writable. FALSE otherwise.

Definition at line 430 of file file.inc.

References drupal_chmod(), drupal_mkdir(), FILE_CREATE_DIRECTORY, FILE_MODIFY_PERMISSIONS, file_stream_wrapper_valid_scheme(), and file_uri_scheme().

Referenced by _locale_rebuild_js(), color_scheme_form_submit(), drupal_build_css_cache(), drupal_build_js_cache(), file_example_create_directory_submit(), file_managed_file_save_upload(), file_unmanaged_copy(), hook_file_download(), image_field_update_field(), image_field_update_instance(), image_install(), image_style_create_derivative(), DrupalWebTestCase\prepareEnvironment(), DrupalUnitTestCase\setUp(), simpletest_verbose(), system_requirements(), user_admin_settings(), and user_save().

file_save ( stdClass $file )

Saves a file object to the database.

If the $file->fid is not set a new record will be added.

Parameters
$file A file object returned by file_load().
Returns
The updated file object.
See Also
hook_file_insert()
hook_file_update()

Definition at line 599 of file file.inc.

References drupal_write_record(), entity_load_unchanged(), module_invoke_all(), and REQUEST_TIME.

Referenced by file_copy(), file_field_presave(), file_move(), file_save_data(), file_save_upload(), form_example_tutorial_10_submit(), image_example_style_form_submit(), image_field_update_field(), image_field_update_instance(), user_save(), and user_update_7012().

file_save_data | ( | $data,
 |  | $destination = NULL,
 |  | $replace = FILE_EXISTS_RENAME
 | ) |

Saves a file to the specified destination and creates a database entry.

Parameters
$data | A string containing the contents of the file.
$destination | A string containing the destination URI. This must be a stream wrapper URI. If no value is provided, a randomized name will be generated and the file will be saved using Drupal's default files scheme, usually "public://".
$replace Replace behavior when the destination file already exists:
  • FILE_EXISTS_REPLACE - Replace the existing file. If a managed file with the destination name exists then its database entry will be updated. If no database entry is found then a new one will be created.
  • FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique.
  • FILE_EXISTS_ERROR - Do nothing and return FALSE.
Returns
A file object, or FALSE on error.
See Also
file_unmanaged_save_data()

Definition at line 1865 of file file.inc.

References drupal_basename(), drupal_set_message(), file_default_scheme(), FILE_EXISTS_RENAME, FILE_EXISTS_REPLACE, file_get_mimetype(), file_load_multiple(), file_save(), FILE_STATUS_PERMANENT, file_unmanaged_save_data(), file_valid_uri(), t(), and watchdog().

Referenced by file_example_managed_write_submit().

file_save_upload | ( | $source,
 |  | $validators = array(),
 |  | $destination = FALSE,
 |  | $replace = FILE_EXISTS_RENAME
 | ) |

Saves a file upload to a new location.

The file will be added to the {file_managed} table as a temporary file. Temporary files are periodically cleaned. To make the file a permanent file, assign the status and use file_save() to save the changes.

Parameters
$source | A string specifying the filepath or URI of the uploaded file to save.
$validators | An optional, associative array of callback functions used to validate the file. See file_validate() for a full discussion of the array format. If no extension validator is provided it will default to a limited safe list of extensions which is as follows: "jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp". To allow all extensions you must explicitly set the 'file_validate_extensions' validator to an empty array (Beware: this is not safe and should only be allowed for trusted users, if at all).
$destination | A string containing the URI $source should be copied to. This must be a stream wrapper URI. If this value is omitted, Drupal's temporary files scheme will be used ("temporary://").
$replace Replace behavior when the destination file already exists:
  • FILE_EXISTS_REPLACE: Replace the existing file.
  • FILE_EXISTS_RENAME: Append _{incrementing number} until the filename is unique.
  • FILE_EXISTS_ERROR: Do nothing and return FALSE.
Returns
An object containing the file information if the upload succeeded, FALSE in the event of an error, or NULL if no file was uploaded. The documentation for the "File interface" group, which you can find under Related topics, or the header at the top of this file, documents the components of a file object. In addition to the standard components, this function adds:
  • source: Path to the file before it is moved.
  • destination: Path to the file after it is moved (same as 'uri').

Definition at line 1437 of file file.inc.

References drupal_basename(), drupal_chmod(), drupal_move_uploaded_file(), drupal_set_message(), file_destination(), FILE_EXISTS_REPLACE, file_get_mimetype(), file_load_multiple(), file_munge_filename(), file_save(), file_stream_wrapper_valid_scheme(), file_upload_max_size(), file_uri_scheme(), file_validate(), form_set_error(), format_size(), t(), theme(), variable_get(), and watchdog().

Referenced by aggregator_form_opml_submit(), file_managed_file_save_upload(), form_example_tutorial_10_validate(), hook_prepare(), locale_translate_import_form_submit(), system_theme_settings_validate(), update_manager_install_form_submit(), and user_validate_picture().

file_scan_directory | ( | $dir,
 |  | $mask,
 |  | $options = array(),
 |  | $depth = 0
 | ) |

Finds all files that match a given mask in a given directory.

Directories and files beginning with a period are excluded; this prevents hidden files and directories (such as SVN working directories) from being scanned.

Parameters
$dir | The base directory or URI to scan, without trailing slash.
$mask | The preg_match() regular expression of the files to find.
$options An associative array of additional options, with the following elements:
  • 'nomask': The preg_match() regular expression of the files to ignore. Defaults to '/(..?|CVS)$/'.
  • 'callback': The callback function to call for each match. There is no default callback.
  • 'recurse': When TRUE, the directory scan will recurse the entire tree starting at the provided directory. Defaults to TRUE.
  • 'key': The key to be used for the returned associative array of files. Possible values are 'uri', for the file's URI; 'filename', for the basename of the file; and 'name' for the name of the file without the extension. Defaults to 'uri'.
  • 'min_depth': Minimum depth of directories to return files from. Defaults to 0.
$depth | Current depth of recursion. This parameter is only used internally and should not be passed in.
Returns
An associative array (keyed on the chosen key) of objects with 'uri', 'filename', and 'name' members corresponding to the matching files.

Definition at line 2058 of file file.inc.

References $depth, $dir, and file_stream_wrapper_uri_normalize().

Referenced by _registry_update(), cache_example_page_form(), ModuleUpdater\canUpdateDirectory(), ThemeUpdater\canUpdateDirectory(), drupal_clear_css_cache(), drupal_clear_js_cache(), drupal_get_database_types(), drupal_system_listing(), DrupalWebTestCase\drupalGetTestFiles(), Updater\findInfoFile(), install_find_locales(), install_find_profiles(), locale_batch_by_component(), locale_batch_by_language(), locale_uninstall(), simpletest_test_get_all(), st(), update_clear_update_disk_cache(), and update_verify_update_archive().

file_space_used | ( | $uid = NULL,
 |  | $status = FILE_STATUS_PERMANENT
 | ) |

Determines total disk space used by a single user or the whole filesystem.

Parameters
$uid | Optional. A user id, specifying NULL returns the total space used by all non-temporary files.
$status | Optional. The file status to consider. The default is to only consider files in status FILE_STATUS_PERMANENT.
Returns
An integer containing the number of bytes used.

Definition at line 1388 of file file.inc.

References db_select().

Referenced by file_validate_size().

file_stream_wrapper_get_class ( $scheme )

Returns the stream wrapper class name for a given scheme.

Parameters
$scheme Stream scheme.
Returns
Return string if a scheme has a registered handler, or FALSE.

Definition at line 182 of file file.inc.

References file_get_stream_wrappers().

Referenced by file_stream_wrapper_get_instance_by_scheme(), file_stream_wrapper_get_instance_by_uri(), and file_stream_wrapper_valid_scheme().

file_stream_wrapper_get_instance_by_scheme ( $scheme )

Returns a reference to the stream wrapper class responsible for a scheme.

This helper method returns a stream instance using a scheme. That is, the passed string does not contain a "://". For example, "public" is a scheme but "public://" is a URI (stream). This is because the later contains both a scheme and target despite target being empty.

Note: the instance URI will be initialized to "scheme://" so that you can make the customary method calls as if you had retrieved an instance by URI.

Parameters
$scheme If the stream was "public://target", "public" would be the scheme.
Returns
Returns a new stream wrapper object appropriate for the given $scheme. For example, for the public scheme a stream wrapper object (DrupalPublicStreamWrapper). FALSE is returned if no registered handler could be found.

Definition at line 336 of file file.inc.

References file_stream_wrapper_get_class().

Referenced by drupal_dirname(), drupal_tempnam(), Updater\getBackupDir(), hook_file_url_alter(), and image_menu().

file_stream_wrapper_get_instance_by_uri ( $uri )

Returns a reference to the stream wrapper class responsible for a given URI.

The scheme determines the stream wrapper class that should be used by consulting the stream wrapper registry.

Parameters
$uri A stream, referenced as "scheme://target".
Returns
Returns a new stream wrapper object appropriate for the given URI or FALSE if no registered handler could be found. For example, a URI of "private://example.txt" would return a new private stream wrapper object (DrupalPrivateStreamWrapper).

Definition at line 303 of file file.inc.

References file_stream_wrapper_get_class(), and file_uri_scheme().

Referenced by drupal_chmod(), drupal_realpath(), file_create_url(), file_get_mimetype(), and image_style_url().

file_stream_wrapper_uri_normalize ( $uri )

Normalizes a URI by making it syntactically correct.

A stream is referenced as "scheme://target".

The following actions are taken:

  • Remove trailing slashes from target
  • Trim erroneous leading slashes from target. e.g. ":///" becomes "://".
Parameters
$uri String reference containing the URI to normalize.
Returns
The normalized URI.

Definition at line 275 of file file.inc.

References file_stream_wrapper_valid_scheme(), file_uri_scheme(), and file_uri_target().

Referenced by file_build_uri(), file_create_htaccess(), file_scan_directory(), file_unmanaged_copy(), image_style_url(), system_update_7061(), and user_save().

file_stream_wrapper_valid_scheme ( $scheme )

Checks that the scheme of a stream URI is valid.

Confirms that there is a registered stream handler for the provided scheme and that it is callable. This is useful if you want to confirm a valid scheme without creating a new instance of the registered handler.

Parameters
$scheme A URI scheme, a stream is referenced as "scheme://target".
Returns
Returns TRUE if the string is the name of a validated stream, or FALSE if the scheme does not have a registered handler.

Definition at line 218 of file file.inc.

References file_stream_wrapper_get_class().

Referenced by drupal_dirname(), drupal_rmdir(), drupal_tempnam(), drupal_unlink(), file_download(), file_prepare_directory(), file_save_upload(), file_stream_wrapper_uri_normalize(), file_transfer(), file_valid_uri(), image_gd_save(), and image_style_deliver().

file_transfer | ( | $uri,
 |  | $headers
 | ) |

Transfers a file to the client using HTTP.

Pipes a file through Drupal to the client.

Parameters
$uri | String specifying the file URI to transfer.
$headers | An array of HTTP headers to send along with file.

Definition at line 1954 of file file.inc.

References $name, $value, drupal_add_http_header(), drupal_exit(), drupal_not_found(), drupal_send_headers(), file_stream_wrapper_valid_scheme(), file_uri_scheme(), and print.

Referenced by file_download(), and image_style_deliver().

file_unmanaged_copy | ( | $source,
 |  | $destination = NULL,
 |  | $replace = FILE_EXISTS_RENAME
 | ) |

Copies a file to a new location without invoking the file API.

This is a powerful function that in many ways performs like an advanced version of copy().

  • Checks if $source and $destination are valid and readable/writable.
  • If file already exists in $destination either the call will error out, replace the file or rename the file based on the $replace parameter.
  • If the $source and $destination are equal, the behavior depends on the $replace parameter. FILE_EXISTS_REPLACE will error out. FILE_EXISTS_RENAME will rename the file until the $destination is unique.
  • Provides a fallback using realpaths if the move fails using stream wrappers. This can occur because PHP's copy() function does not properly support streams if safe_mode or open_basedir are enabled. See https://bugs.php.net/bug.php?id=60456
Parameters
$source | A string specifying the filepath or URI of the source file.
$destination | A URI containing the destination that $source should be copied to. The URI may be a bare filepath (without a scheme). If this value is omitted, Drupal's default files scheme will be used, usually "public://".
$replace Replace behavior when the destination file already exists:
  • FILE_EXISTS_REPLACE - Replace the existing file.
  • FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique.
  • FILE_EXISTS_ERROR - Do nothing and return FALSE.
Returns
The path to the new file, or FALSE in the event of an error.
See Also
file_copy()

Definition at line 884 of file file.inc.

References drupal_basename(), drupal_chmod(), drupal_dirname(), drupal_realpath(), drupal_set_message(), file_build_uri(), file_destination(), file_ensure_htaccess(), file_prepare_directory(), file_stream_wrapper_uri_normalize(), t(), watchdog(), and WATCHDOG_ERROR.

Referenced by color_scheme_form_submit(), DrupalWebTestCase\drupalGetTestFiles(), file_copy(), file_unmanaged_move(), and system_theme_settings_submit().

file_unmanaged_delete ( $path )

Deletes a file without database changes or hook invocations.

This function should be used when the file to be deleted does not have an entry recorded in the files table.

Parameters
$path A string containing a file path or (streamwrapper) URI.
Returns
TRUE for success or path does not exist, or FALSE in the event of an error.
See Also
file_delete()
file_unmanaged_delete_recursive()

Definition at line 1317 of file file.inc.

References drupal_unlink(), watchdog(), WATCHDOG_ERROR, and WATCHDOG_NOTICE.

Referenced by _locale_rebuild_js(), drupal_delete_file_if_stale(), file_delete(), file_example_delete_submit(), file_unmanaged_delete_recursive(), file_unmanaged_move(), image_path_flush(), and locale_uninstall().

file_unmanaged_delete_recursive ( $path )

Deletes all files and directories in the specified filepath recursively.

If the specified path is a directory then the function will call itself recursively to process the contents. Once the contents have been removed the directory will also be removed.

If the specified path is a file then it will be passed to file_unmanaged_delete().

Note that this only deletes visible files with write permission.

Parameters
$path A string containing either an URI or a file or directory path.
Returns
TRUE for success or if path does not exist, FALSE in the event of an error.
See Also
file_unmanaged_delete()

Definition at line 1358 of file file.inc.

References $dir, dir, drupal_rmdir(), and file_unmanaged_delete().

Referenced by file_example_delete_directory_submit(), image_style_flush(), image_uninstall(), simpletest_clean_temporary_directories(), simpletest_run_tests(), simpletest_uninstall(), DrupalWebTestCase\tearDown(), update_delete_file_if_stale(), and update_manager_archive_extract().

file_unmanaged_move | ( | $source,
 |  | $destination = NULL,
 |  | $replace = FILE_EXISTS_RENAME
 | ) |

Moves a file to a new location without database changes or hook invocation.

Parameters
$source | A string specifying the filepath or URI of the original file.
$destination | A string containing the destination that $source should be moved to. This must be a stream wrapper URI. If this value is omitted, Drupal's default files scheme will be used, usually "public://".
$replace Replace behavior when the destination file already exists:
  • FILE_EXISTS_REPLACE - Replace the existing file.
  • FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique.
  • FILE_EXISTS_ERROR - Do nothing and return FALSE.
Returns
The URI of the moved file, or FALSE in the event of an error.
See Also
file_move()

Definition at line 1103 of file file.inc.

References file_unmanaged_copy(), and file_unmanaged_delete().

Referenced by file_move(), file_unmanaged_save_data(), and image_gd_save().

file_unmanaged_save_data | ( | $data,
 |  | $destination = NULL,
 |  | $replace = FILE_EXISTS_RENAME
 | ) |

Saves a string to the specified destination without invoking file API.

This function is identical to file_save_data() except the file will not be saved to the {file_managed} table and none of the file_* hooks will be called.

Parameters
$data | A string containing the contents of the file.
$destination | A string containing the destination location. This must be a stream wrapper URI. If no value is provided, a randomized name will be generated and the file will be saved using Drupal's default files scheme, usually "public://".
$replace Replace behavior when the destination file already exists:
  • FILE_EXISTS_REPLACE - Replace the existing file.
  • FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique.
  • FILE_EXISTS_ERROR - Do nothing and return FALSE.
Returns
A string with the path of the resulting file, or FALSE on error.
See Also
file_save_data()

Definition at line 1932 of file file.inc.

References drupal_set_message(), drupal_tempnam(), file_unmanaged_move(), and t().

Referenced by _color_save_stylesheet(), _locale_rebuild_js(), drupal_build_css_cache(), drupal_build_js_cache(), file_example_read_submit(), file_example_unmanaged_write_submit(), and file_save_data().

file_unmunge_filename ( $filename )

Undoes the effect of file_munge_filename().

Parameters
$filename String with the filename to be unmunged.
Returns
An unmunged filename string.

Definition at line 1187 of file file.inc.

file_upload_max_size ( )

Determines the maximum file upload size by querying the PHP settings.

Returns
A file size limit in bytes based on the PHP upload_max_filesize and post_max_size

Definition at line 2108 of file file.inc.

References parse_size().

Referenced by file_ajax_upload(), file_field_instance_settings_form(), file_field_widget_upload_validators(), and file_save_upload().

file_uri_scheme ( $uri )

Returns the scheme of a URI (e.g. a stream).

Parameters
$uri A stream, referenced as "scheme://target".
Returns
A string containing the name of the scheme, or FALSE if none. For example, the URI "public://example.txt" would return "public".
See Also
file_uri_target()

Definition at line 199 of file file.inc.

Referenced by _system_theme_settings_validate_path(), drupal_dirname(), drupal_load_stylesheet(), drupal_rmdir(), drupal_tempnam(), drupal_unlink(), file_create_htaccess(), file_create_url(), file_prepare_directory(), file_save_upload(), file_stream_wrapper_get_instance_by_uri(), file_stream_wrapper_uri_normalize(), file_transfer(), file_valid_uri(), hook_file_url_alter(), image_field_update_field(), image_field_update_instance(), image_file_download(), image_gd_save(), image_style_path(), image_style_url(), and system_theme_settings().

file_uri_target ( $uri )

Returns the part of a URI after the schema.

Parameters
$uri A stream, referenced as "scheme://target".
Returns
A string containing the target (path), or FALSE if none. For example, the URI "public://sample/test.txt" would return "sample/test.txt".
See Also
file_uri_scheme()

Definition at line 243 of file file.inc.

Referenced by file_stream_wrapper_uri_normalize(), hook_file_download(), hook_file_url_alter(), image_file_download(), image_style_deliver(), image_style_path(), image_style_url(), system_theme_settings(), and user_file_download().

file_usage_add | ( | stdClass | $file,
 |  |  | $module,
 |  |  | $type,
 |  |  | $id,
 |  |  | $count = 1
 | ) |  |

Records that a module is using a file.

This usage information will be queried during file_delete() to ensure that a file is not in use before it is physically removed from disk.

Examples:

  • A module that associates files with nodes, so $type would be 'node' and $id would be the node's nid. Files for all revisions are stored within a single nid.
  • The User module associates an image with a user, so $type would be 'user' and the $id would be the user's uid.
Parameters
$file | A file object.
$module | The name of the module using the file.
$type | The type of the object that contains the referenced file.
$id | The unique, numeric ID of the object containing the referenced file.
$count | (optional) The number of references to add to the object. Defaults to 1.
See Also
file_usage_list()
file_usage_delete()

Definition at line 682 of file file.inc.

References $module, and db_merge().

Referenced by file_field_insert(), file_field_update(), image_example_style_form_submit(), image_field_update_field(), image_field_update_instance(), system_update_7061(), user_save(), and user_update_7013().

file_usage_delete | ( | stdClass | $file,
 |  |  | $module,
 |  |  | $type = NULL,
 |  |  | $id = NULL,
 |  |  | $count = 1
 | ) |  |

Removes a record to indicate that a module is no longer using a file.

The file_delete() function is typically called after removing a file usage to remove the record from the file_managed table and delete the file itself.

Parameters
$file | A file object.
$module | The name of the module using the file.
$type | (optional) The type of the object that contains the referenced file. May be omitted if all module references to a file are being deleted.
$id | (optional) The unique, numeric ID of the object containing the referenced file. May be omitted if all module references to a file are being deleted.
$count (optional) The number of references to delete from the object. Defaults to
  1. 0 may be specified to delete all references to the file within a specific object.
See Also
file_usage_add()
file_usage_list()
file_delete()

Definition at line 720 of file file.inc.

References $module, db_delete(), and db_update().

Referenced by file_field_delete_file(), image_example_style_form_submit(), image_field_delete_field(), image_field_delete_instance(), image_field_update_field(), image_field_update_instance(), and user_save().

file_usage_list ( stdClass $file )

Determines where a file is used.

Parameters
$file A file object.
Returns
A nested array with usage data. The first level is keyed by module name, the second by object type and the third by the object id. The value of the third level contains the usage count.
See Also
file_usage_add()
file_usage_delete()

Definition at line 642 of file file.inc.

References db_select().

Referenced by file_delete(), file_field_delete_file(), file_managed_file_validate(), and system_cron().

file_valid_uri ( $uri )

Determines whether the URI has a valid scheme for file API operations.

There must be a scheme and it must be a Drupal-provided scheme like 'public', 'private', 'temporary', or an extension provided with hook_stream_wrappers().

Parameters
$uri The URI to be tested.
Returns
TRUE if the URI is allowed.

Definition at line 841 of file file.inc.

References file_stream_wrapper_valid_scheme(), and file_uri_scheme().

Referenced by file_copy(), file_delete(), file_move(), file_save_data(), and template_preprocess_user_picture().

file_validate | ( | stdClass & | $file,
 |  |  | $validators = array()
 | ) |  |

Checks that a file meets the criteria specified by the validators.

After executing the validator callbacks specified hook_file_validate() will also be called to allow other modules to report errors about the file.

Parameters
$file | A Drupal file object.
$validators | An optional, associative array of callback functions used to validate the file. The keys are function names and the values arrays of callback parameters which will be passed in after the file object. The functions should return an array of error messages; an empty array indicates that the file passed validation. The functions will be called in the order specified.
Returns
An array containing validation error messages.
See Also
hook_file_validate()

Definition at line 1664 of file file.inc.

References module_invoke_all().

Referenced by file_save_upload().

file_validate_extensions | ( | stdClass | $file,
 |  |  | $extensions
 | ) |  |

Checks that the filename ends with an allowed extension.

Parameters
$file | A Drupal file object.
$extensions | A string with a space separated list of allowed extensions.
Returns
An array. If the file extension is not allowed, it will contain an error message.
See Also
hook_file_validate()

Definition at line 1713 of file file.inc.

References t().

Referenced by hook_file_insert().

file_validate_image_resolution | ( | stdClass | $file,
 |  |  | $maximum_dimensions = 0,
 |  |  | $minimum_dimensions = 0
 | ) |  |

Verifies that image dimensions are within the specified maximum and minimum.

Non-image files will be ignored. If a image toolkit is available the image will be scaled to fit within the desired maximum dimensions.

Parameters
$file | A Drupal file object. This function may resize the file affecting its size.
$maximum_dimensions | An optional string in the form WIDTHxHEIGHT e.g. '640x480' or '85x85'. If an image toolkit is installed the image will be resized down to these dimensions. A value of 0 indicates no restriction on size, so resizing will be attempted.
$minimum_dimensions | An optional string in the form WIDTHxHEIGHT. This will check that the image meets a minimum size. A value of 0 indicates no restriction.
Returns
An array. If the file is an image and did not meet the requirements, it will contain an error message.
See Also
hook_file_validate()

Definition at line 1808 of file file.inc.

References $info, drupal_set_message(), image_get_info(), image_load(), image_save(), image_scale(), and t().

file_validate_is_image ( stdClass $file )

Checks that the file is recognized by image_get_info() as an image.

Parameters
$file A Drupal file object.
Returns
An array. If the file is not an image, it will contain an error message.
See Also
hook_file_validate()

Definition at line 1773 of file file.inc.

References $info, image_get_info(), and t().

file_validate_name_length ( stdClass $file )

Checks for files with names longer than we can store in the database.

Parameters
$file A Drupal file object.
Returns
An array. If the file name is too long, it will contain an error message.

Definition at line 1687 of file file.inc.

References t().

file_validate_size | ( | stdClass | $file,
 |  |  | $file_limit = 0,
 |  |  | $user_limit = 0
 | ) |  |

Checks that the file's size is below certain limits.

This check is not enforced for the user #1.

Parameters
$file | A Drupal file object.
$file_limit | An integer specifying the maximum file size in bytes. Zero indicates that no limit should be enforced.
$user_limit | An integer specifying the maximum number of bytes the user is allowed. Zero indicates that no limit should be enforced.
Returns
An array. If the file size exceeds limits, it will contain an error message.
See Also
hook_file_validate()

Definition at line 1743 of file file.inc.

References file_space_used(), format_size(), and t().

Variable Documentation

const FILE_CREATE_DIRECTORY 1

Flag used by file_prepare_directory() – create directory if not present.

Definition at line 41 of file file.inc.

Referenced by _locale_rebuild_js(), color_scheme_form_submit(), drupal_build_css_cache(), drupal_build_js_cache(), file_example_create_directory_submit(), file_managed_file_save_upload(), file_prepare_directory(), image_field_update_field(), image_field_update_instance(), image_install(), image_style_create_derivative(), DrupalWebTestCase\prepareEnvironment(), DrupalUnitTestCase\setUp(), simpletest_verbose(), system_requirements(), user_admin_settings(), and user_save().

const FILE_EXISTS_ERROR 2

Flag for dealing with existing files: Do nothing and return FALSE.

Definition at line 61 of file file.inc.

Referenced by file_destination().

const FILE_EXISTS_RENAME 0

Flag for dealing with existing files: Appends number until name is unique.

Definition at line 51 of file file.inc.

Referenced by file_copy(), file_destination(), file_example_managed_write_submit(), file_move(), file_save_data(), and user_save().

const FILE_EXISTS_REPLACE 1

Flag for dealing with existing files: Replace the existing file.

Definition at line 56 of file file.inc.

Referenced by _color_save_stylesheet(), drupal_build_css_cache(), drupal_build_js_cache(), file_copy(), file_destination(), file_example_unmanaged_write_submit(), file_move(), file_save_data(), file_save_upload(), image_gd_save(), update_manager_file_get(), and update_manager_install_form_submit().

const FILE_MODIFY_PERMISSIONS 2

Flag used by file_prepare_directory() – file permissions may be changed.

Definition at line 46 of file file.inc.

Referenced by file_example_create_directory_submit(), file_prepare_directory(), image_install(), image_style_create_derivative(), DrupalWebTestCase\prepareEnvironment(), and DrupalUnitTestCase\setUp().

const FILE_STATUS_PERMANENT 1

Indicates that the file is permanent and should not be deleted.

Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during cron runs, but permanent files will not be removed during the file garbage collection process.

Definition at line 70 of file file.inc.

Referenced by file_field_presave(), file_file_download(), file_managed_file_validate(), file_save_data(), form_example_tutorial_10_submit(), image_example_style_form_submit(), image_field_update_field(), image_field_update_instance(), system_cron(), user_save(), and user_update_7012().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Form builder functions

Functions
Form builder functions

Functions

contextual_links_example_object_edit_form ($form, &$form_state, $object)
contextual_links_example_node_action_form ($form, &$form_state, $node)
authorize_filetransfer_form ($form, &$form_state)
install_settings_form ($form, &$form_state, &$install_state)
install_select_profile_form ($form, &$form_state, $profile_files)
install_select_locale_form ($form, &$form_state, $locales, $profilename)
install_configure_form ($form, &$form_state, &$install_state)
_install_configure_form ($form, &$form_state, &$install_state)
aggregator_form_feed ($form, &$form_state, stdClass $feed=NULL)
aggregator_form_opml ($form, &$form_state)
aggregator_admin_form ($form, $form_state)
aggregator_form_category ($form, &$form_state, $edit=array('title'=> '', 'description'=> '', 'cid'=> NULL))
aggregator_categorize_items ($items, $feed_source= '')
block_admin_display_form ($form, &$form_state, $blocks, $theme, $block_regions=NULL)
block_admin_configure ($form, &$form_state, $module, $delta)
block_add_block_form ($form, &$form_state)
block_custom_block_form ($edit=array())
book_admin_settings ()
book_admin_edit ($form, $form_state, $node)
book_outline_form ($form, &$form_state, $node)
book_remove_form ($form, &$form_state, $node)
color_scheme_form ($complete_form, &$form_state, $theme)
comment_admin_overview ($form, &$form_state, $arg)
comment_multiple_delete_confirm ($form, &$form_state)
comment_confirm_delete ($form, &$form_state, $comment)
comment_form ($form, &$form_state, $comment)
comment_unpublish_by_keyword_action_form ($context)
contact_category_edit_form ($form, &$form_state, array $category=array())
contact_site_form ($form, &$form_state)
contact_personal_form ($form, &$form_state, $recipient)
dblog_filter_form ($form)
dblog_clear_log_form ($form)
field_ui_field_overview_form ($form, &$form_state, $entity_type, $bundle)
field_ui_display_overview_form ($form, &$form_state, $entity_type, $bundle, $view_mode)
field_ui_field_settings_form ($form, &$form_state, $instance)
field_ui_widget_type_form ($form, &$form_state, $instance)
field_ui_field_delete_form ($form, &$form_state, $instance)
field_ui_field_edit_form ($form, &$form_state, $instance)
filter_admin_overview ($form)
filter_admin_format_form ($form, &$form_state, $format)
filter_admin_disable ($form, &$form_state, $format)
forum_form_forum ($form, &$form_state, $edit=array())
forum_form_container ($form, &$form_state, $edit=array())
forum_confirm_delete ($form, &$form_state, $tid)
forum_admin_settings ($form)
forum_overview ($form, &$form_state)
image_style_form ($form, &$form_state, $style)
image_style_add_form ($form, &$form_state)
image_style_delete_form ($form, &$form_state, $style)
image_effect_form ($form, &$form_state, $style, $effect)
image_effect_delete_form ($form, &$form_state, $style, $effect)
locale_translation_filter_form ()
locale_language_selector_form (&$form, &$form_state, $user)
node_type_form ($form, &$form_state, $type=NULL)
node_type_delete_confirm ($form, &$form_state, $type)
node_configure_rebuild_confirm ()
node_filter_form ()
node_admin_content ($form, $form_state)
node_admin_nodes ()
node_multiple_delete_confirm ($form, &$form_state, $nodes)
node_assign_owner_action_form ($context)
node_form ($form, &$form_state, $node)
node_revision_revert_confirm ($form, $form_state, $node_revision)
node_revision_delete_confirm ($form, $form_state, $node_revision)
openid_user_add ()
path_admin_form ($form, &$form_state, $path=array('source'=> '', 'alias'=> '', 'language'=> LANGUAGE_NONE, 'pid'=> NULL))
path_admin_filter_form ($form, &$form_state, $keys= '')
poll_view_voting ($form, &$form_state, $node, $block=FALSE)
poll_cancel_form ($form, &$form_state, $nid)
profile_admin_overview ($form)
profile_field_form ($form, &$form_state, $arg=NULL)
search_admin_settings ($form)
search_box ($form, &$form_state, $form_id)
shortcut_set_switch ($form, &$form_state, $account=NULL)
shortcut_set_add_form ($form, &$form_state)
shortcut_set_customize ($form, &$form_state, $shortcut_set)
shortcut_link_add ($form, &$form_state, $shortcut_set)
shortcut_link_edit ($form, &$form_state, $shortcut_link)
shortcut_set_edit_form ($form, &$form_state, $shortcut_set)
shortcut_set_delete_form ($form, &$form_state, $shortcut_set)
shortcut_link_delete ($form, &$form_state, $shortcut_link)
simpletest_settings_form ($form, &$form_state)
statistics_settings_form ()
system_themes_admin_form ($form, &$form_state, $theme_options)
system_theme_settings ($form, &$form_state, $key= '')
system_modules ($form, $form_state=array())
system_modules_confirm_form ($modules, $storage)
system_modules_uninstall ($form, $form_state=NULL)
system_modules_uninstall_confirm_form ($storage)
system_ip_blocking_form ($form, $form_state, $default_ip)
system_site_information_settings ()
system_cron_settings ()
system_run_cron_submit ($form, &$form_state)
system_logging_settings ()
system_performance_settings ()
system_clear_cache_submit ($form, &$form_state)
system_clear_page_cache_submit ($form, &$form_state)
system_file_system_settings ()
system_image_toolkit_settings ()
system_rss_feeds_settings ()
system_regional_settings ()
system_date_time_settings ()
system_add_date_format_type_form ($form, &$form_state)
system_site_maintenance_mode ()
system_clean_url_settings ($form, &$form_state)
system_actions_manage_form ($form, &$form_state, $options=array())
system_actions_delete_form ($form, &$form_state, $action)
system_settings_form ($form)
taxonomy_overview_vocabularies ($form)
taxonomy_form_vocabulary ($form, &$form_state, $edit=array())
taxonomy_overview_terms ($form, &$form_state, $vocabulary)
taxonomy_form_term ($form, &$form_state, $edit=array(), $vocabulary=NULL)
taxonomy_term_confirm_delete ($form, &$form_state, $tid)
taxonomy_vocabulary_confirm_delete ($form, &$form_state, $vid)
taxonomy_vocabulary_confirm_reset_alphabetical ($form, &$form_state, $vid)
trigger_unassign ($form, $form_state, $module, $hook=NULL, $aid=NULL)
trigger_assign_form ($form, $form_state, $module, $hook, $label)
update_manager_update_form ($form, $form_state=array(), $context)
update_manager_update_ready_form ($form, &$form_state)
update_manager_install_form ($form, &$form_state, $context)
update_settings ($form)
user_filter_form ()
user_admin_account ()
user_admin_settings ()
user_admin_permissions ($form, $form_state, $rid=NULL)
user_admin_roles ($form, $form_state)
user_admin_role ($form, $form_state, $role)
user_login ($form, &$form_state)
user_register_form ($form, &$form_state)
user_pass ()
user_profile_form ($form, &$form_state, $account, $category= 'account')
user_cancel_confirm_form ($form, &$form_state, $account)

Detailed Description

Functions that build an abstract representation of a HTML form.

All modules should declare their form builder functions to be in this group and each builder function should reference its validate and submit functions using @see. Conversely, validate and submit functions should reference the form builder function using @see. For examples, of this see system_modules_uninstall() or user_pass(), the latter of which has the following in its doxygen documentation:

@ingroup forms @see user_pass_validate(). @see user_pass_submit().

Function Documentation

_install_configure_form | ( |  | $form,
 |  | & | $form_state,
 |  | & | $install_state
 | ) |  |

Form constructor for a site configuration form.

Parameters
$install_state An array of information about the current installation state.
See Also
install_configure_form()
install_configure_form_validate()
install_configure_form_submit()

Definition at line 1744 of file install.core.inc.

References country_get_list(), DRUPAL_ROOT, EMAIL_MAX_LENGTH, st(), system_time_zones(), USERNAME_MAX_LENGTH, and variable_get().

Referenced by install_configure_form().

aggregator_admin_form | ( | $form,
 |  | $form_state
 | ) |

Form constructor for the aggregator system settings.

See Also
aggregator_admin_form_submit()

Definition at line 421 of file aggregator.admin.inc.

References $info, $module, aggregator_sanitize_configuration(), module_implements(), module_invoke(), t(), and variable_get().

aggregator_categorize_items | ( | $items,
 |  | $feed_source = ''
 | ) |

Form constructor to build the page list form.

Parameters
$items | An array of the feed items.
$feed_source | (optional) The feed source URL. Defaults to an empty string.
Returns
array An array of FAPI elements.
See Also
aggregator_categorize_items_submit()
theme_aggregator_categorize_items()

Definition at line 205 of file aggregator.pages.inc.

References check_plain(), db_query(), t(), theme(), and variable_get().

Referenced by _aggregator_page_list().

aggregator_form_category | ( |  | $form,
 |  | & | $form_state,
 |  |  | $edit = array('title' => '', 'description' => '', 'cid' => NULL)
 | ) |  |

Form constructor to add/edit/delete aggregator categories.

Parameters
$edit An associative array containing:
  • title: A string to use for the category title.
  • description: A string to use for the category description.
  • cid: The category ID.
See Also
aggregator_form_category_validate()
aggregator_form_category_submit()

Definition at line 549 of file aggregator.admin.inc.

References t().

aggregator_form_feed | ( |  | $form,
 |  | & | $form_state,
 |  | stdClass | $feed = NULL
 | ) |  |

Form constructor for adding and editing feed sources.

Parameters
$feed (optional) If editing a feed, the feed to edit as a PHP stdClass value; if adding a new feed, NULL. Defaults to NULL.
See Also
aggregator_form_feed_validate()
aggregator_form_feed_submit()

Definition at line 66 of file aggregator.admin.inc.

References AGGREGATOR_CLEAR_NEVER, check_plain(), db_query(), drupal_map_assoc(), t(), and url().

aggregator_form_opml | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form constructor for importing feeds from OPML.

See Also
aggregator_form_opml_validate()
aggregator_form_opml_submit()

Definition at line 250 of file aggregator.admin.inc.

References db_query(), drupal_map_assoc(), t(), and url().

authorize_filetransfer_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form constructor for the file transfer authorization form.

Allows the user to choose a FileTransfer type and supply credentials.

See Also
authorize_filetransfer_form_validate()
authorize_filetransfer_form_submit()

Definition at line 17 of file authorize.inc.

References $base_url, $name, _authorize_filetransfer_connection_settings(), drupal_set_message(), t(), and variable_get().

block_add_block_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form constructor for the add block form.

See Also
block_add_block_form_validate()
block_add_block_form_submit()

Definition at line 527 of file block.admin.inc.

References block_admin_configure().

block_admin_configure | ( |  | $form,
 |  | & | $form_state,
 |  |  | $module,
 |  |  | $delta
 | ) |  |

Form constructor for the block configuration form.

Also used by block_add_block_form() for adding a new custom block.

Parameters
$module | Name of the module that implements the block to be configured.
$delta | Unique ID of the block within the context of $module.
See Also
block_admin_configure_validate()
block_admin_configure_submit()

Definition at line 255 of file block.admin.inc.

References $info, $module, $title, BLOCK_CUSTOM_DISABLED, BLOCK_CUSTOM_ENABLED, BLOCK_CUSTOM_FIXED, block_load(), BLOCK_REGION_NONE, BLOCK_VISIBILITY_LISTED, BLOCK_VISIBILITY_NOTLISTED, BLOCK_VISIBILITY_PHP, db_query(), drupal_get_path(), drupal_set_title(), list_themes(), module_exists(), module_invoke(), PASS_THROUGH, REGIONS_VISIBLE, system_region_list(), t(), user_access(), user_roles(), and variable_get().

Referenced by block_add_block_form().

block_admin_display_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $blocks,
 |  |  | $theme,
 |  |  | $block_regions = NULL
 | ) |  |

Form constructor for the main block administration form.

Parameters
$blocks | An array of blocks, as returned by block_admin_display_prepare_blocks().
$theme | A string representing the name of the theme to edit blocks for.
$block_regions | (optional) An array of regions in which the blocks will be allowed to be placed. Defaults to all visible regions for the theme whose blocks are being configured. In all cases, a dummy region for disabled blocks will also be displayed.
Returns
An array representing the form definition.
See Also
block_admin_display_form_submit()

Definition at line 78 of file block.admin.inc.

References BLOCK_REGION_NONE, check_plain(), drupal_get_path(), REGIONS_VISIBLE, system_region_list(), and t().

block_custom_block_form ( $edit = array() )

Form constructor for the custom block form.

Parameters
$edit (optional) An associative array of information retrieved by block_custom_get_block() if an existing block is being edited, or an empty array otherwise. Defaults to array().

Definition at line 515 of file block.module.

References t(), and url().

Referenced by block_block_configure().

book_admin_edit | ( | $form,
 |  | $form_state,
 |  | $node
 | ) |

Form constructor for administering a single book's hierarchy.

See Also
book_admin_edit_submit()
Parameters
$node The node of the top-level page in the book.
See Also
book_admin_edit_validate()
book_admin_edit_submit()

Definition at line 83 of file book.admin.inc.

References _book_admin_table(), drupal_set_title(), and t().

book_admin_settings ( )

Form constructor for the book settings form.

See Also
book_admin_settings_validate()

Definition at line 36 of file book.admin.inc.

References node_type_get_names(), system_settings_form(), t(), and variable_get().

book_outline_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $node
 | ) |  |

Form constructor for the book outline form.

Allows handling of all book outline operations via the outline tab.

Parameters
$node The book node for which to show the outline.
See Also
book_outline_form_submit()
book_remove_button_submit()

Definition at line 132 of file book.pages.inc.

References _book_add_form_elements(), _book_link_defaults(), _book_node_is_removable(), _book_parent_depth_limit(), and t().

book_remove_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $node
 | ) |  |

Form constructor to confirm removal of a node from a book.

Parameters
$node The node to delete.
See Also
book_remove_form_submit()

Definition at line 220 of file book.pages.inc.

References $title, confirm_form(), and t().

color_scheme_form | ( |  | $complete_form,
 |  | & | $form_state,
 |  |  | $theme
 | ) |  |

Form constructor for the color configuration form for a particular theme.

Parameters
$theme The machine name of the theme whose color settings are being configured.
See Also
color_scheme_form_validate()
color_scheme_form_submit()

Definition at line 171 of file color.module.

References $info, $name, $value, check_plain(), color_get_info(), color_get_palette(), drupal_get_path(), t(), and variable_get().

Referenced by color_form_system_theme_settings_alter().

comment_admin_overview | ( |  | $form,
 |  | & | $form_state,
 |  |  | $arg
 | ) |  |

Form builder for the comment overview administration form.

Parameters
$arg Current path's fourth component: the type of overview form ('approval' or 'new').
See Also
comment_admin_overview_validate()
comment_admin_overview_submit()
theme_comment_admin_overview()

Definition at line 34 of file comment.admin.inc.

References $header, $row, comment_load_multiple(), COMMENT_NOT_PUBLISHED, COMMENT_PUBLISHED, db_select(), drupal_get_destination(), field_get_items(), format_date(), t(), theme(), and truncate_utf8().

comment_confirm_delete | ( |  | $form,
 |  | & | $form_state,
 |  |  | $comment
 | ) |  |

Form builder; Builds the confirmation form for deleting a single comment.

See Also
comment_confirm_delete_submit()

Definition at line 257 of file comment.admin.inc.

References confirm_form(), and t().

comment_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $comment
 | ) |  |

Generate the basic commenting form, for appending to a node or display on a separate page.

See Also
comment_form_validate()
comment_form_submit()

Definition at line 1841 of file comment.module.

References $author, $value, COMMENT_ANONYMOUS_MAYNOT_CONTACT, COMMENT_ANONYMOUS_MUST_CONTACT, COMMENT_NOT_PUBLISHED, COMMENT_PUBLISHED, DRUPAL_DISABLED, drupal_html_id(), DRUPAL_OPTIONAL, DRUPAL_REQUIRED, entity_language(), field_attach_form(), format_date(), LANGUAGE_NONE, node_load(), t(), theme(), url(), user_access(), and variable_get().

comment_multiple_delete_confirm | ( |  | $form,
 |  | & | $form_state
 | ) |  |

List the selected comments and verify that the admin wants to delete them.

Parameters
$form_state An associative array containing the current state of the form.
Returns
TRUE if the comments should be deleted, FALSE otherwise.
See Also
comment_multiple_delete_confirm_submit()

Definition at line 195 of file comment.admin.inc.

References $value, check_plain(), comment_load(), confirm_form(), db_query(), drupal_goto(), drupal_set_message(), and t().

comment_unpublish_by_keyword_action_form ( $context )

Form builder; Prepare a form for blacklisted keywords.

See Also
comment_unpublish_by_keyword_action()
comment_unpublish_by_keyword_action_submit()

Definition at line 2635 of file comment.module.

References drupal_implode_tags(), and t().

contact_category_edit_form | ( |  | $form,
 |  | & | $form_state,
 |  | array | $category = array()
 | ) |  |

Form constructor for the category edit form.

Parameters
$category An array describing the category to be edited. May be empty for new categories. Recognized array keys are:
  • category: The name of the category.
  • recipients: A comma-separated list of recipients.
  • reply: (optional) The body of the auto-reply message.
  • weight: The weight of the category.
  • selected: Boolean indicating whether the category should be selected by default.
  • cid: The category ID for which the form is to be displayed.
See Also
contact_category_edit_form_validate()
contact_category_edit_form_submit()

Definition at line 73 of file contact.admin.inc.

References t().

contact_personal_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $recipient
 | ) |  |

Form constructor for the personal contact form.

Path: user/user/contact

See Also
contact_menu()
contact_personal_form_validate()
contact_personal_form_submit()

Definition at line 183 of file contact.pages.inc.

References drupal_access_denied(), drupal_exit(), drupal_set_message(), drupal_set_title(), flood_is_allowed(), format_interval(), format_username(), PASS_THROUGH, t(), theme(), user_access(), and variable_get().

contact_site_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form constructor for the site-wide contact form.

See Also
contact_site_form_validate()
contact_site_form_submit()

Definition at line 15 of file contact.pages.inc.

References db_query(), db_select(), drupal_access_denied(), drupal_exit(), drupal_not_found(), drupal_set_message(), flood_is_allowed(), format_interval(), format_username(), t(), url(), user_access(), and variable_get().

contextual_links_example_node_action_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $node
 | ) |  |

Form callback; display the form for performing an example action on a node.

See Also
contextual_links_example_node_action_form_submit()

Definition at line 360 of file contextual_links_example.module.

References t().

contextual_links_example_object_edit_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $object
 | ) |  |

Form callback; display the form for editing our module's content.

See Also
contextual_links_example_object_edit_form_submit()

Definition at line 327 of file contextual_links_example.module.

References t().

dblog_clear_log_form ( $form )

Form constructor for the form that clears out the log.

See Also
dblog_clear_log_submit()

Definition at line 394 of file dblog.admin.inc.

References t().

dblog_filter_form ( $form )

Form constructor for the database logging filter form.

See Also
dblog_filter_form_validate()
dblog_filter_form_submit()
dblog_overview()

Definition at line 315 of file dblog.admin.inc.

References dblog_filters(), and t().

field_ui_display_overview_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $entity_type,
 |  |  | $bundle,
 |  |  | $view_mode
 | ) |  |

Form constructor for the field display settings for a given view mode.

See Also
field_ui_display_overview_multistep_submit()
field_ui_display_overview_form_submit()

Definition at line 884 of file field_ui.admin.inc.

References $name, _field_ui_bundle_admin_path(), check_plain(), drupal_get_path(), drupal_set_message(), entity_get_info(), field_extract_bundle(), field_info_extra_fields(), field_info_field(), field_info_field_types(), field_info_formatter_settings(), field_info_formatter_types(), field_info_instances(), field_ui_formatter_options(), field_ui_inactive_message(), field_view_mode_settings(), module_invoke(), t(), and url().

field_ui_field_delete_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $instance
 | ) |  |

Form constructor for removing a field instance from a bundle.

See Also
field_ui_field_delete_form_submit()

Definition at line 1730 of file field_ui.admin.inc.

References $output, _field_ui_bundle_admin_path(), confirm_form(), field_info_field(), and t().

field_ui_field_edit_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $instance
 | ) |  |

Form constructor for the field instance settings form.

See Also
field_ui_field_edit_form_validate()
field_ui_field_edit_form_submit()

Definition at line 1801 of file field_ui.admin.inc.

References _field_filter_xss_display_allowed_tags(), drupal_map_assoc(), drupal_set_title(), element_info_property(), FIELD_BEHAVIOR_DEFAULT, field_behaviors_widget(), FIELD_CARDINALITY_UNLIMITED, field_has_data(), field_info_bundles(), field_info_field(), field_info_field_types(), field_info_widget_types(), field_ui_default_value_widget(), module_invoke(), and t().

field_ui_field_overview_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $entity_type,
 |  |  | $bundle
 | ) |  |

Form constructor for the 'Manage fields' form of a bundle.

Allows fields and pseudo-fields to be re-ordered.

See Also
field_ui_field_overview_form_validate()
field_ui_field_overview_form_submit()

Definition at line 288 of file field_ui.admin.inc.

References $info, $name, _field_ui_bundle_admin_path(), check_plain(), drupal_get_path(), field_extract_bundle(), field_info_cache_clear(), field_info_extra_fields(), field_info_field(), field_info_field_types(), field_info_instances(), field_info_max_weight(), field_info_widget_types(), field_ui_existing_field_options(), field_ui_field_type_options(), field_ui_inactive_message(), field_ui_widget_type_options(), t(), and truncate_utf8().

field_ui_field_settings_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $instance
 | ) |  |

Form constructor for the field settings edit page.

See Also
field_ui_field_settings_form_submit()

Definition at line 1564 of file field_ui.admin.inc.

References drupal_set_title(), field_has_data(), field_info_field(), module_invoke(), and t().

field_ui_widget_type_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $instance
 | ) |  |

Form constructor for the widget selection form.

Path: BUNDLE_ADMIN_PATH/fields/field/widget-type, where BUNDLE_ADMIN_PATH is the path stored in the ['admin']['info'] property in the return value of hook_entity_info().

See Also
field_ui_menu()
field_ui_widget_type_form_submit()

Definition at line 1653 of file field_ui.admin.inc.

References drupal_set_title(), field_info_bundles(), field_info_field(), field_info_field_types(), field_info_widget_types(), field_ui_widget_type_options(), and t().

filter_admin_disable | ( |  | $form,
 |  | & | $form_state,
 |  |  | $format
 | ) |  |

Form constructor for the text format deletion confirmation form.

Parameters
$format An object representing a text format.
See Also
filter_menu()
filter_admin_disable_submit()

Definition at line 388 of file filter.admin.inc.

References confirm_form(), and t().

filter_admin_format_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $format
 | ) |  |

Form constructor for the text format add/edit form.

Parameters
$format A format object having the properties:
  • format: A machine-readable name representing the ID of the text format to save. If this corresponds to an existing text format, that format will be updated; otherwise, a new format will be created.
  • name: The title of the text format.
  • cache: An integer indicating whether the text format is cacheable (1) or not (0). Defaults to 1.
  • status: (optional) An integer indicating whether the text format is enabled (1) or not (0). Defaults to 1.
  • weight: (optional) The weight of the text format, which controls its placement in text format lists. If omitted, the weight is set to 0.
See Also
filter_admin_format_form_validate()
filter_admin_format_form_submit()

Definition at line 154 of file filter.admin.inc.

References $name, drupal_get_path(), filter_fallback_format(), filter_get_filters(), filter_get_roles_by_format(), filter_list_format(), t(), user_roles(), and variable_get().

filter_admin_overview ( $form )

Page callback: Form constructor for a form to list and reorder text formats.

See Also
filter_menu()
filter_admin_overview_submit()

Definition at line 15 of file filter.admin.inc.

References check_plain(), drupal_placeholder(), filter_fallback_format(), filter_formats(), filter_get_roles_by_format(), and t().

forum_admin_settings ( $form )

Form constructor for the forum settings page.

See Also
forum_menu()
system_settings_form()

Definition at line 236 of file forum.admin.inc.

References drupal_map_assoc(), system_settings_form(), t(), and variable_get().

forum_confirm_delete | ( |  | $form,
 |  | & | $form_state,
 |  |  | $tid
 | ) |  |

Form constructor for confirming deletion of a forum taxonomy term.

Parameters
$tid ID of the term to be deleted.
See Also
forum_confirm_delete_submit()

Definition at line 208 of file forum.admin.inc.

References confirm_form(), t(), taxonomy_term_load(), and url().

forum_form_container | ( |  | $form,
 |  | & | $form_state,
 |  |  | $edit = array()
 | ) |  |

Form constructor for adding and editing forum containers.

Parameters
$edit (optional) Associative array containing a container term to be added or edited. Defaults to an empty array.
See Also
forum_form_submit()

Definition at line 148 of file forum.admin.inc.

References _forum_parent_select(), t(), and variable_get().

forum_form_forum | ( |  | $form,
 |  | & | $form_state,
 |  |  | $edit = array()
 | ) |  |

Form constructor for adding and editing a forum.

Parameters
$edit (optional) Associative array containing a forum term to be added or edited. Defaults to an empty array.
See Also
forum_form_submit()

Definition at line 47 of file forum.admin.inc.

References _forum_parent_select(), t(), and variable_get().

forum_overview | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form constructor for the forum overview form.

Returns a form for controlling the hierarchy of existing forums and containers.

See Also
forum_menu()

Definition at line 270 of file forum.admin.inc.

References element_children(), module_load_include(), t(), taxonomy_overview_terms(), taxonomy_vocabulary_load(), url(), and variable_get().

image_effect_delete_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $style,
 |  |  | $effect
 | ) |  |

Form builder; Form for deleting an image effect.

Parameters
$style | Name of the image style from which the image effect will be removed.
$effect | Name of the image effect to remove.
See Also
image_effect_delete_form_submit()

Definition at line 456 of file image.admin.inc.

References confirm_form(), and t().

image_effect_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $style,
 |  |  | $effect
 | ) |  |

Form builder; Form for adding and editing image effects.

This form is used universally for editing all image effects. Each effect adds its own custom section to the form by calling the form function specified in hook_image_effects().

Parameters
$form_state | An associative array containing the current state of the form.
$style | An image style array.
$effect | An image effect array.
See Also
hook_image_effects()
image_effects()
image_resize_form()
image_scale_form()
image_rotate_form()
image_crop_form()
image_effect_form_submit()

Definition at line 391 of file image.admin.inc.

References $title, drupal_get_path(), drupal_goto(), drupal_set_title(), PASS_THROUGH, and t().

image_style_add_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form builder; Form for adding a new image style.

See Also
image_style_add_form_submit()

Definition at line 242 of file image.admin.inc.

References t().

image_style_delete_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $style
 | ) |  |

Form builder; Form for deleting an image style.

Parameters
$style An image style array.
See Also
image_style_delete_form_submit()

Definition at line 313 of file image.admin.inc.

References confirm_form(), image_style_options(), PASS_THROUGH, and t().

image_style_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $style
 | ) |  |

Form builder; Edit an image style name and effects order.

Parameters
$form_state | An associative array containing the current state of the form.
$style | An image style array.
See Also
image_style_form_submit()

Definition at line 36 of file image.admin.inc.

References $title, check_plain(), drupal_get_path(), drupal_set_message(), drupal_set_title(), image_effect_definitions(), IMAGE_STORAGE_EDITABLE, PASS_THROUGH, t(), and theme().

install_configure_form | ( |  | $form,
 |  | & | $form_state,
 |  | & | $install_state
 | ) |  |

Form constructor for a form to configure the new site.

Parameters
$install_state An array of information about the current installation state.
See Also
install_configure_form_validate()
install_configure_form_submit()

Definition at line 1483 of file install.core.inc.

References _install_configure_form(), conf_path(), drupal_add_js(), drupal_get_path(), drupal_get_schema(), DRUPAL_ROOT, drupal_set_message(), drupal_set_title(), drupal_verify_install_file(), FILE_EXIST, FILE_NOT_WRITABLE, FILE_READABLE, menu_rebuild(), and st().

install_select_locale_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $locales,
 |  |  | $profilename
 | ) |  |

Form constructor for the language selection form.

Definition at line 1310 of file install.core.inc.

References $name, _locale_get_predefined_list(), DRUPAL_ROOT, and st().

install_select_profile_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $profile_files
 | ) |  |

Form constructor for the profile selection form.

Parameters
$form_state | Array of metadata about state of form processing.
$profile_files | Array of .profile files, as returned from file_scan_directory().

Definition at line 1131 of file install.core.inc.

References $name, DRUPAL_ROOT, install_profile_info(), and st().

install_settings_form | ( |  | $form,
 |  | & | $form_state,
 |  | & | $install_state
 | ) |  |

Form constructor for a form to configure and rewrite settings.php.

Parameters
$install_state An array of information about the current installation state.
See Also
install_settings_form_validate()
install_settings_form_submit()

Definition at line 875 of file install.core.inc.

References $databases, conf_path(), drupal_get_database_types(), drupal_install_profile_distribution_name(), drupal_set_title(), drupal_static_reset(), and st().

locale_language_selector_form | ( | & | $form,
 |  | & | $form_state,
 |  |  | $user
 | ) |  |

Form builder callback to display language selection widget.

See Also
locale_form_alter()

Definition at line 277 of file locale.module.

References $name, language_list(), LANGUAGE_NEGOTIATION_DEFAULT, language_negotiation_get(), LANGUAGE_TYPE_INTERFACE, t(), user_access(), and user_preferred_language().

Referenced by locale_form_alter().

locale_translation_filter_form ( )

Return form for locale translation filters.

Definition at line 843 of file locale.admin.inc.

References locale_translation_filters(), and t().

node_admin_content | ( | $form,
 |  | $form_state
 | ) |

Page callback: Form constructor for the content administration form.

See Also
node_admin_nodes()
node_admin_nodes_submit()
node_admin_nodes_validate()
node_filter_form()
node_filter_form_submit()
node_menu()
node_multiple_delete_confirm()
node_multiple_delete_confirm_submit()

Definition at line 405 of file node.admin.inc.

References node_admin_nodes(), node_filter_form(), and node_multiple_delete_confirm().

node_admin_nodes ( )

Form builder: Builds the node administration overview.

See Also
node_admin_nodes_submit()
node_admin_nodes_validate()
node_filter_form()
node_filter_form_submit()
node_multiple_delete_confirm()
node_multiple_delete_confirm_submit()

Definition at line 428 of file node.admin.inc.

References $header, check_plain(), db_or(), db_query(), db_query_range(), db_select(), drupal_get_destination(), entity_language(), format_date(), language_list(), LANGUAGE_NONE, module_exists(), module_invoke_all(), name, node_access(), node_build_filter_query(), node_load_multiple(), node_mark(), node_type_get_name(), t(), theme(), and user_access().

Referenced by node_admin_content().

node_assign_owner_action_form ( $context )

Generates the settings form for node_assign_owner_action().

Parameters
$context Array of additional information about what triggered the action. Includes the following elements:
  • 'owner_uid': User ID to assign to the node.
See Also
node_assign_owner_action_submit()
node_assign_owner_action_validate()

Definition at line 3975 of file node.module.

References db_query(), and t().

node_configure_rebuild_confirm ( )

Menu callback: confirm rebuilding of permissions.

See Also
node_configure_rebuild_confirm_submit()
node_menu()

Definition at line 15 of file node.admin.inc.

References confirm_form(), and t().

node_filter_form ( )

Returns the node administration filters form array to node_admin_content().

See Also
node_admin_nodes()
node_admin_nodes_submit()
node_admin_nodes_validate()
node_filter_form_submit()
node_multiple_delete_confirm()
node_multiple_delete_confirm_submit()

Definition at line 156 of file node.admin.inc.

References $value, drupal_add_js(), LANGUAGE_NONE, module_invoke(), node_filters(), and t().

Referenced by node_admin_content().

node_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $node
 | ) |  |

Form constructor for the node add/edit form.

See Also
node_form_validate()
node_form_submit()
node_form_build_preview()
node_form_delete_submit()

Definition at line 107 of file node.pages.inc.

References DRUPAL_DISABLED, drupal_get_path(), DRUPAL_OPTIONAL, DRUPAL_REQUIRED, entity_language(), field_attach_form(), form_get_errors(), format_date(), node_access(), node_object_prepare(), node_type_get_base(), t(), user_access(), and variable_get().

node_multiple_delete_confirm | ( |  | $form,
 |  | & | $form_state,
 |  |  | $nodes
 | ) |  |

Multiple node deletion confirmation form for node_admin_content().

See Also
node_admin_nodes()
node_admin_nodes_submit()
node_admin_nodes_validate()
node_filter_form()
node_filter_form_submit()
node_multiple_delete_confirm_submit()

Definition at line 662 of file node.admin.inc.

References $title, $value, check_plain(), confirm_form(), db_query(), format_plural(), and t().

Referenced by node_admin_content().

node_revision_delete_confirm | ( | $form,
 |  | $form_state,
 |  | $node_revision
 | ) |

Form constructor for the revision deletion confirmation form.

This form prevents against CSRF attacks.

Parameters
$node_revision The node revision ID.
Returns
An array as expected by drupal_render().
See Also
node_menu()
node_revision_delete_confirm_submit()

Definition at line 660 of file node.pages.inc.

References confirm_form(), format_date(), and t().

node_revision_revert_confirm | ( | $form,
 |  | $form_state,
 |  | $node_revision
 | ) |

Asks for confirmation of the reversion to prevent against CSRF attacks.

Parameters
int $node_revision The node revision ID.
Returns
array An array as expected by drupal_render().
See Also
node_menu()
node_revision_revert_confirm_submit()

Definition at line 625 of file node.pages.inc.

References confirm_form(), format_date(), and t().

node_type_delete_confirm | ( |  | $form,
 |  | & | $form_state,
 |  |  | $type
 | ) |  |

Menu callback; delete a single content type.

Definition at line 415 of file content_types.inc.

References confirm_form(), db_query(), format_plural(), and t().

node_type_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $type = NULL
 | ) |  |

Form constructor for the node type editing form.

Parameters
$type (optional) An object representing the node type, when editing an existing node type.
See Also
node_type_form_validate()
node_type_form_submit()

Definition at line 88 of file content_types.inc.

References DRUPAL_DISABLED, drupal_get_path(), DRUPAL_OPTIONAL, DRUPAL_REQUIRED, node_type_set_defaults(), t(), and variable_get().

openid_user_add ( )

Form builder; Add an OpenID identity.

See Also
openid_user_add_validate()

Definition at line 71 of file openid.pages.inc.

References t().

path_admin_filter_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $keys = ''
 | ) |  |

Form constructor for the path admin overview filter form.

See Also
path_admin_filter_form_submit_filter()
path_admin_filter_form_submit_reset()

Definition at line 269 of file path.admin.inc.

References t().

path_admin_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $path = array('source' => '', 'alias' => '', 'language' => LANGUAGE_NONE, 'pid' => NULL)
 | ) |  |

Form constructor for the path administration form.

Parameters
$path An array containing the path ID, source, alias, and language code.
See Also
path_admin_form_validate()
path_admin_form_submit()
path_admin_form_delete_submit()

Definition at line 123 of file path.admin.inc.

References t(), url(), and variable_get().

poll_cancel_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $nid
 | ) |  |

Builds the cancel form for a poll.

See Also
poll_cancel()

Definition at line 944 of file poll.module.

References t().

poll_view_voting | ( |  | $form,
 |  | & | $form_state,
 |  |  | $node,
 |  |  | $block = FALSE
 | ) |  |

Generates the voting form for a poll.

See Also
poll_vote()
phptemplate_preprocess_poll_vote()

Definition at line 713 of file poll.module.

References $choice, check_plain(), and t().

profile_admin_overview ( $form )

Form builder to display a listing of all editable profile fields.

See Also
profile_admin_overview_submit()

Definition at line 14 of file profile.admin.inc.

References $value, _profile_field_types(), check_plain(), db_query(), l(), and t().

profile_field_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $arg = NULL
 | ) |  |

Menu callback: Generate a form to add/edit a user profile field.

See Also
profile_field_form_validate()
profile_field_form_submit()

Definition at line 187 of file profile.admin.inc.

References _profile_field_types(), arg(), db_query(), drupal_not_found(), drupal_set_title(), PASS_THROUGH, PROFILE_HIDDEN, PROFILE_PRIVATE, PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS, and t().

search_admin_settings ( $form )

Menu callback: displays the search module settings page.

See Also
search_admin_settings_validate()
search_admin_settings_submit()
search_admin_reindex_submit()

Definition at line 52 of file search.admin.inc.

References $module, $percentage, _search_get_module_names(), drupal_map_assoc(), format_plural(), module_invoke(), system_settings_form(), t(), url(), and variable_get().

search_box | ( |  | $form,
 |  | & | $form_state,
 |  |  | $form_id
 | ) |  |

Form builder; Output a search form for the search block's search box.

See Also
search_box_form_submit()
search-block-form.tpl.php

Definition at line 1007 of file search.module.

shortcut_link_add | ( |  | $form,
 |  | & | $form_state,
 |  |  | $shortcut_set
 | ) |  |

Form callback: builds the form for adding a new shortcut link.

Parameters
$form | An associative array containing the structure of the form.
$form_state | An associative array containing the current state of the form.
$shortcut_set | An object representing the shortcut set to which the link will be added.
Returns
An array representing the form definition.
See Also
shortcut_link_edit_validate()
shortcut_link_add_submit()

Definition at line 419 of file shortcut.admin.inc.

References _shortcut_link_form_elements(), drupal_set_title(), and t().

shortcut_link_delete | ( |  | $form,
 |  | & | $form_state,
 |  |  | $shortcut_link
 | ) |  |

Form callback: builds the confirmation form for deleting a shortcut link.

Parameters
$form | An associative array containing the structure of the form.
$form_state | An associative array containing the current state of the form.
$shortcut_link | An array representing the link that will be deleted.
Returns
An array representing the form definition.
See Also
shortcut_link_delete_submit()

Definition at line 735 of file shortcut.admin.inc.

References confirm_form(), and t().

shortcut_link_edit | ( |  | $form,
 |  | & | $form_state,
 |  |  | $shortcut_link
 | ) |  |

Form callback: builds the form for editing a shortcut link.

Parameters
$form | An associative array containing the structure of the form.
$form_state | An associative array containing the current state of the form.
$shortcut_link | An array representing the link that is being edited.
Returns
An array representing the form definition.
See Also
shortcut_link_edit_validate()
shortcut_link_edit_submit()

Definition at line 446 of file shortcut.admin.inc.

References _shortcut_link_form_elements(), drupal_set_title(), and t().

shortcut_set_add_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form callback: builds the form for adding a shortcut set.

Parameters
$form | An associative array containing the structure of the form.
$form_state | An associative array containing the current state of the form.
Returns
An array representing the form definition.
See Also
shortcut_set_add_form_validate()
shortcut_set_add_form_submit()

Definition at line 208 of file shortcut.admin.inc.

References t().

shortcut_set_customize | ( |  | $form,
 |  | & | $form_state,
 |  |  | $shortcut_set
 | ) |  |

Form callback: builds the form for customizing shortcut sets.

Parameters
$form | An associative array containing the structure of the form.
$form_state | An associative array containing the current state of the form.
$shortcut_set | An object representing the shortcut set which is being edited.
Returns
An array representing the form definition.
See Also
shortcut_set_customize_submit()

Definition at line 266 of file shortcut.admin.inc.

References drupal_get_path(), l(), and t().

shortcut_set_delete_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $shortcut_set
 | ) |  |

Form callback: builds the confirmation form for deleting a shortcut set.

Parameters
$form | An associative array containing the structure of the form.
$form_state | An associative array containing the current state of the form.
object | $shortcut_set | An object representing the shortcut set, as returned from shortcut_set_load().
Returns
An array representing the form definition.
See Also
shortcut_set_delete_form_submit()

Definition at line 673 of file shortcut.admin.inc.

References $info, confirm_form(), db_query(), format_plural(), module_implements(), and t().

shortcut_set_edit_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $shortcut_set
 | ) |  |

Form callback: builds the form for editing the shortcut set name.

Parameters
$form | An associative array containing the structure of the form.
$form_state | An associative array containing the current state of the form.
object | $shortcut_set | An object representing the shortcut set, as returned from shortcut_set_load().
Returns
An array representing the form definition.
See Also
shortcut_set_edit_form_validate()
shortcut_set_edit_form_submit()

Definition at line 611 of file shortcut.admin.inc.

References t().

shortcut_set_switch | ( |  | $form,
 |  | & | $form_state,
 |  |  | $account = NULL
 | ) |  |

Form callback: builds the form for switching shortcut sets.

Parameters
$form | An associative array containing the structure of the form.
$form_state | An associative array containing the current state of the form.
$account | (optional) The user account whose shortcuts will be switched. Defaults to the current logged-in user.
Returns
An array representing the form definition.
See Also
shortcut_set_switch_validate()
shortcut_set_switch_submit()

Definition at line 38 of file shortcut.admin.inc.

References $name, check_plain(), drupal_get_path(), shortcut_current_displayed_set(), shortcut_default_set(), shortcut_sets(), t(), and user_access().

simpletest_settings_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Provides settings form for SimpleTest variables.

See Also
simpletest_settings_form_validate()

Definition at line 438 of file simpletest.pages.inc.

References system_settings_form(), t(), and variable_get().

statistics_settings_form ( )

Form constructor for the statistics administration form.

See Also
system_settings_form()

Definition at line 275 of file statistics.admin.inc.

References drupal_map_assoc(), system_settings_form(), t(), url(), and variable_get().

system_actions_delete_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $action
 | ) |  |

Create the form for confirmation of deleting an action.

See Also
system_actions_delete_form_submit()

Definition at line 3168 of file system.admin.inc.

References confirm_form(), and t().

system_actions_manage_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $options = array()
 | ) |  |

Define the form for the actions overview page.

Parameters
$form_state | An associative array containing the current state of the form; not used.
$options | An array of configurable actions.
Returns
Form definition.
See Also
system_actions_manage_form_submit()

Definition at line 3014 of file system.admin.inc.

References t().

system_add_date_format_type_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Add new date type.

() ()

Definition at line 2104 of file system.admin.inc.

References drupal_static_reset(), format_date(), REQUEST_TIME, system_get_date_formats(), and t().

system_clean_url_settings | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form builder; Configure clean URL settings.

See Also
system_settings_form()

Definition at line 2224 of file system.admin.inc.

References drupal_add_js(), drupal_get_path(), drupal_http_request(), drupal_set_message(), request_uri(), system_settings_form(), t(), url(), and variable_get().

system_clear_cache_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit callback; clear system caches.

Definition at line 1766 of file system.admin.inc.

References drupal_flush_all_caches(), drupal_set_message(), and t().

system_clear_page_cache_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit callback; clear the page cache.

Definition at line 1776 of file system.admin.inc.

References cache_clear_all().

system_cron_settings ( )

Form builder; Cron form.

See Also
system_settings_form()

Definition at line 1596 of file system.admin.inc.

References $base_url, DRUPAL_CRON_DEFAULT_THRESHOLD, drupal_map_assoc(), format_interval(), REQUEST_TIME, system_settings_form(), t(), url(), and variable_get().

system_date_time_settings ( )

Form builder; Configure the site date and time settings.

See Also
system_settings_form()

Definition at line 1994 of file system.admin.inc.

References check_plain(), drupal_static_reset(), format_date(), REQUEST_TIME, system_get_date_formats(), system_get_date_types(), system_settings_form(), t(), url(), and variable_get().

system_file_system_settings ( )

Form builder; Configure the site file handling.

See Also
system_settings_form()

Definition at line 1786 of file system.admin.inc.

References $info, check_plain(), conf_path(), file_directory_temp(), file_get_stream_wrappers(), STREAM_WRAPPERS_WRITE_VISIBLE, system_settings_form(), t(), and variable_get().

system_image_toolkit_settings ( )

Form builder; Configure site image toolkit usage.

See Also
system_settings_form()

Definition at line 1838 of file system.admin.inc.

References image_get_available_toolkits(), image_get_toolkit(), system_settings_form(), t(), url(), variable_del(), variable_get(), and variable_set().

system_ip_blocking_form | ( | $form,
 |  | $form_state,
 |  | $default_ip
 | ) |

Define the form for blocking IP addresses.

See Also
system_ip_blocking_form_validate()
system_ip_blocking_form_submit()

Definition at line 1410 of file system.admin.inc.

References t().

system_logging_settings ( )

Form builder; Configure error reporting settings.

See Also
system_settings_form()

Definition at line 1652 of file system.admin.inc.

References ERROR_REPORTING_DISPLAY_ALL, ERROR_REPORTING_DISPLAY_SOME, ERROR_REPORTING_HIDE, system_settings_form(), t(), and variable_get().

system_modules | ( | $form,
 |  | $form_state = array()
 | ) |

Menu callback; provides module enable/disable interface.

The list of modules gets populated by module.info files, which contain each module's name, description, and information about which modules it requires. See drupal_parse_info_file() for information on module.info descriptors.

Dependency checking is performed to ensure that a module:

  • can not be enabled if there are disabled modules it requires.
  • can not be disabled if there are enabled modules which depend on it.
Parameters
$form_state An associative array containing the current state of the form.
Returns
The form array.
See Also
theme_system_modules()
system_modules_submit()

Definition at line 788 of file system.admin.inc.

References $module, _system_modules_build_row(), check_plain(), drupal_check_incompatibility(), DRUPAL_CORE_COMPATIBILITY, drupal_help_arg(), drupal_install_profile_distribution_name(), DRUPAL_ROOT, drupal_ucfirst(), element_children(), if, menu_get_item(), module_exists(), module_implements(), module_invoke(), system_modules_confirm_form(), system_rebuild_module_data(), t(), url(), and user_access().

system_modules_confirm_form | ( | $modules,
 |  | $storage
 | ) |

Display confirmation form for required modules.

Parameters
$modules | Array of module file objects as returned from system_rebuild_module_data().
$storage | The contents of $form_state['storage']; an array with two elements: the list of required modules and the list of status form field values from the previous screen.

Definition at line 1054 of file system.admin.inc.

References $info, $name, confirm_form(), format_plural(), t(), and theme().

Referenced by system_modules().

system_modules_uninstall | ( | $form,
 |  | $form_state = NULL
 | ) |

Uninstall functions Builds a form of currently disabled modules.

See Also
system_modules_uninstall_validate()
system_modules_uninstall_submit()
Parameters
$form_state['values'] Submitted form values.
Returns
A form array representing the currently disabled modules.

Definition at line 1242 of file system.admin.inc.

References $module, $name, drupal_get_installed_schema_version(), drupal_get_profile(), DRUPAL_ROOT, SCHEMA_UNINSTALLED, system_modules_uninstall_confirm_form(), system_rebuild_module_data(), t(), and url().

system_modules_uninstall_confirm_form ( $storage )

Confirm uninstall of selected modules.

Parameters
$storage An associative array of modules selected to be uninstalled.
Returns
A form array representing modules to confirm.

Definition at line 1310 of file system.admin.inc.

References $info, $module, $value, confirm_form(), drupal_get_path(), drupal_parse_info_file(), t(), and theme().

Referenced by system_modules_uninstall().

system_performance_settings ( )

Form builder; Configure site performance settings.

See Also
system_settings_form()

Definition at line 1674 of file system.admin.inc.

References drupal_add_js(), drupal_get_path(), drupal_map_assoc(), system_settings_form(), t(), url(), and variable_get().

system_regional_settings ( )

Form builder; Configure the site regional settings.

See Also
system_settings_form()
system_regional_settings_submit()

Definition at line 1909 of file system.admin.inc.

References $configurable_timezones, country_get_list(), DRUPAL_ROOT, DRUPAL_USER_TIMEZONE_DEFAULT, DRUPAL_USER_TIMEZONE_EMPTY, DRUPAL_USER_TIMEZONE_SELECT, system_settings_form(), system_time_zones(), t(), and variable_get().

system_rss_feeds_settings ( )

Form builder; Configure how the site handles RSS feeds.

See Also
system_settings_form()

Definition at line 1877 of file system.admin.inc.

References drupal_map_assoc(), system_settings_form(), t(), and variable_get().

system_run_cron_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit callback; run cron.

Definition at line 1634 of file system.admin.inc.

References drupal_cron_run(), drupal_goto(), drupal_set_message(), and t().

system_settings_form ( $form )

Sets up a form to save information automatically.

This function adds a submit handler and a submit button to a form array. The submit function saves all the data in the form, using variable_set(), to variables named the same as the keys in the form array. Note that this means you should normally prefix your form array keys with your module name, so that they are unique when passed into variable_set().

If you need to manipulate the data in a custom manner, you can either put your own submission handler in the form array before calling this function, or just use your own submission handler instead of calling this function.

Parameters
$form An associative array containing the structure of the form.
Returns
The form structure.
See Also
system_settings_form_submit()

Definition at line 2755 of file system.module.

References drupal_set_message(), form_get_errors(), and t().

Referenced by book_admin_settings(), cron_example_form(), forum_admin_settings(), locale_language_providers_session_form(), locale_language_providers_url_form(), menu_configure(), render_example_demo_form(), search_admin_settings(), simpletest_settings_form(), statistics_settings_form(), system_clean_url_settings(), system_cron_settings(), system_date_time_settings(), system_file_system_settings(), system_image_toolkit_settings(), system_logging_settings(), system_performance_settings(), system_regional_settings(), system_rss_feeds_settings(), system_site_information_settings(), system_site_maintenance_mode(), system_theme_settings(), update_settings(), user_admin_settings(), xmlrpc_example_alter_form(), and xmlrpc_example_server_form().

system_site_information_settings ( )

Form builder; The general site information form.

See Also
system_settings_form()

Definition at line 1484 of file system.admin.inc.

References drupal_get_path_alias(), drupal_map_assoc(), system_settings_form(), t(), url(), and variable_get().

system_site_maintenance_mode ( )

Form builder; Configure the site's maintenance status.

See Also
system_settings_form()

Definition at line 2201 of file system.admin.inc.

References system_settings_form(), t(), url(), and variable_get().

system_theme_settings | ( |  | $form,
 |  | & | $form_state,
 |  |  | $key = ''
 | ) |  |

Form builder; display theme configuration for entire site and individual themes.

Parameters
$key A theme name.
Returns
The form structure.
See Also
system_theme_settings_submit()

Definition at line 399 of file system.admin.inc.

References $name, $title, DRUPAL_ROOT, element_children(), file_uri_scheme(), file_uri_target(), list_themes(), module_exists(), system_settings_form(), t(), theme_get_setting(), and variable_get().

system_themes_admin_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $theme_options
 | ) |  |

Form to select the administration theme.

See Also
system_themes_admin_form_submit()

Definition at line 258 of file system.admin.inc.

References t(), and variable_get().

taxonomy_form_term | ( |  | $form,
 |  | & | $form_state,
 |  |  | $edit = array(),
 |  |  | $vocabulary = NULL
 | ) |  |

Form function for the term edit form.

See Also
taxonomy_form_term_submit()

Definition at line 637 of file taxonomy.admin.inc.

References $children, $tree, $value, entity_language(), field_attach_form(), t(), taxonomy_get_parents(), taxonomy_get_tree(), taxonomy_term_confirm_delete(), taxonomy_vocabulary_load(), user_access(), and variable_get().

taxonomy_form_vocabulary | ( |  | $form,
 |  | & | $form_state,
 |  |  | $edit = array()
 | ) |  |

Form builder for the vocabulary editing form.

See Also
taxonomy_form_vocabulary_submit()
taxonomy_form_vocabulary_validate()

Definition at line 108 of file taxonomy.admin.inc.

References $value, t(), and taxonomy_vocabulary_confirm_delete().

taxonomy_overview_terms | ( |  | $form,
 |  | & | $form_state,
 |  |  | $vocabulary
 | ) |  |

Form builder for the taxonomy terms overview.

Display a tree of all the terms in a vocabulary, with options to edit each one. The form is made drag and drop by the theme function.

See Also
taxonomy_overview_terms_submit()
theme_taxonomy_overview_terms()

Definition at line 249 of file taxonomy.admin.inc.

References $page, $tree, drupal_get_destination(), t(), taxonomy_get_tree(), taxonomy_vocabulary_confirm_reset_alphabetical(), url(), and variable_get().

Referenced by forum_overview().

taxonomy_overview_vocabularies ( $form )

Form builder to list and manage vocabularies.

See Also
taxonomy_overview_vocabularies_submit()
theme_taxonomy_overview_vocabularies()

Definition at line 15 of file taxonomy.admin.inc.

References check_plain(), t(), and taxonomy_get_vocabularies().

taxonomy_term_confirm_delete | ( |  | $form,
 |  | & | $form_state,
 |  |  | $tid
 | ) |  |

Form builder for the term delete form.

See Also
taxonomy_term_confirm_delete_submit()

Definition at line 873 of file taxonomy.admin.inc.

References confirm_form(), t(), and taxonomy_term_load().

Referenced by taxonomy_form_term().

taxonomy_vocabulary_confirm_delete | ( |  | $form,
 |  | & | $form_state,
 |  |  | $vid
 | ) |  |

Form builder for the vocabulary delete confirmation form.

See Also
taxonomy_vocabulary_confirm_delete_submit()

Definition at line 914 of file taxonomy.admin.inc.

References confirm_form(), t(), and taxonomy_vocabulary_load().

Referenced by taxonomy_form_vocabulary().

taxonomy_vocabulary_confirm_reset_alphabetical | ( |  | $form,
 |  | & | $form_state,
 |  |  | $vid
 | ) |  |

Form builder to confirm resetting a vocabulary to alphabetical order.

See Also
taxonomy_vocabulary_confirm_reset_alphabetical_submit()

Definition at line 954 of file taxonomy.admin.inc.

References confirm_form(), t(), and taxonomy_vocabulary_load().

Referenced by taxonomy_overview_terms().

trigger_assign_form | ( | $form,
 |  | $form_state,
 |  | $module,
 |  | $hook,
 |  | $label
 | ) |

Returns the form for assigning an action to a trigger.

Parameters
$module | The name of the trigger group, e.g., 'node'.
$hook | The name of the trigger hook, e.g., 'node_insert'.
$label | A plain English description of what this trigger does.
See Also
trigger_assign_form_validate()
trigger_assign_form_submit()

Definition at line 121 of file trigger.admin.inc.

References $info, $module, actions_actions_map(), actions_function_lookup(), actions_get_all_actions(), actions_list(), drupal_hash_base64(), l(), t(), trigger_get_assigned_actions(), and url().

trigger_unassign | ( | $form,
 |  | $form_state,
 |  | $module,
 |  | $hook = NULL,
 |  | $aid = NULL
 | ) |

Form constructor for confirmation page for removal of an assigned action.

Parameters
$module | The tab of triggers the user will be directed to after successful removal of the action, or if the confirmation form is cancelled.
$hook | The name of the trigger hook, e.g., 'node_insert'.
$aid | The action ID.
See Also
trigger_unassign_submit()

Definition at line 55 of file trigger.admin.inc.

References $module, actions_function_lookup(), actions_get_all_actions(), confirm_form(), drupal_goto(), and t().

update_manager_install_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $context
 | ) |  |

Form constructor for the install form of the Update Manager module.

This presents a place to enter a URL or upload an archive file to use to install a new module or theme.

Parameters
$context String representing the context from which we're trying to install. Allowed values are 'module', 'theme', and 'report'.
See Also
update_manager_install_form_validate()
update_manager_install_form_submit()
update_menu()

Definition at line 496 of file update.manager.inc.

References _update_manager_check_backends(), archiver_get_extensions(), and t().

update_manager_update_form | ( | $form,
 |  | $form_state = array(),
 |  | $context
 | ) |

Form constructor for the update form of the Update Manager module.

This presents a table with all projects that have available updates with checkboxes to select which ones to upgrade.

Parameters
$context String representing the context from which we're trying to update. Allowed values are 'module', 'theme', and 'report'.
See Also
update_manager_update_form_validate()
update_manager_update_form_submit()
update_menu()

Definition at line 62 of file update.manager.inc.

References $attributes, $name, _update_manager_check_backends(), check_plain(), drupal_get_path(), l(), module_load_include(), t(), theme(), update_calculate_project_data(), UPDATE_CURRENT, update_get_available(), UPDATE_NOT_CHECKED, UPDATE_NOT_CURRENT, UPDATE_NOT_FETCHED, UPDATE_NOT_SECURE, UPDATE_NOT_SUPPORTED, UPDATE_REVOKED, and UPDATE_UNKNOWN.

update_manager_update_ready_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form constructor for the update ready form.

Build the form when the site is ready to update (after downloading).

This form is an intermediary step in the automated update workflow. It is presented to the site administrator after all the required updates have been downloaded and verified. The point of this page is to encourage the user to backup their site, give them the opportunity to put the site offline, and then ask them to confirm that the update should continue. After this step, the user is redirected to authorize.php to enter their file transfer credentials and attempt to complete the update.

See Also
update_manager_update_ready_form_submit()
update_menu()

Definition at line 382 of file update.manager.inc.

References _update_manager_check_backends(), t(), and url().

update_settings ( $form )

Form constructor for the update settings form.

See Also
update_settings_validate()
update_settings_submit()

Definition at line 15 of file update.settings.inc.

References system_settings_form(), t(), url(), and variable_get().

user_admin_account ( )

Form builder; User administration page.

See Also
user_admin_account_validate()
user_admin_account_submit()

Definition at line 163 of file user.admin.inc.

References $header, db_query(), db_select(), drupal_get_destination(), format_interval(), module_invoke_all(), REQUEST_TIME, t(), theme(), user_build_filter_query(), and user_roles().

user_admin_permissions | ( | $form,
 |  | $form_state,
 |  | $rid = NULL
 | ) |

Menu callback: administer permissions.

See Also
user_admin_permissions_submit()
theme_user_admin_permissions()

Definition at line 672 of file user.admin.inc.

References $module, $name, check_plain(), drupal_get_path(), module_implements(), module_invoke(), system_admin_compact_mode(), system_get_info(), t(), theme(), user_role_permissions(), and user_roles().

user_admin_role | ( | $form,
 |  | $form_state,
 |  | $role
 | ) |

Form to configure a single role.

See Also
user_admin_role_validate()
user_admin_role_submit()

Definition at line 951 of file user.admin.inc.

References DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID, drupal_goto(), and t().

user_admin_roles | ( | $form,
 |  | $form_state
 | ) |

Form to re-order roles or add a new one.

See Also
theme_user_admin_roles()

Definition at line 844 of file user.admin.inc.

References $name, t(), and user_roles().

user_admin_settings ( )

Form builder; Configure user settings for this site.

See Also
system_settings_form()

Definition at line 280 of file user.admin.inc.

References _user_mail_text(), drupal_add_js(), DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID, drupal_get_path(), element_children(), FILE_CREATE_DIRECTORY, file_default_scheme(), file_prepare_directory(), form_set_error(), image_style_options(), module_exists(), module_load_include(), PASS_THROUGH, system_settings_form(), t(), url(), user_cancel_methods(), USER_REGISTER_ADMINISTRATORS_ONLY, USER_REGISTER_VISITORS, USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, user_roles(), variable_get(), watchdog(), and WATCHDOG_ERROR.

user_cancel_confirm_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $account
 | ) |  |

Form builder; confirm form for cancelling user account.

See Also
user_edit_cancel_submit()

Definition at line 353 of file user.pages.inc.

References confirm_form(), element_children(), t(), user_access(), user_cancel_methods(), and variable_get().

user_filter_form ( )

Form builder; Return form for user administration filters.

See Also
user_filter_form_submit()

Definition at line 49 of file user.admin.inc.

References $value, drupal_add_library(), t(), and user_filters().

user_login | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form builder; the main user login form.

Definition at line 2070 of file user.module.

References drupal_goto(), t(), user_login_default_validators(), USERNAME_MAX_LENGTH, and variable_get().

user_pass ( )

Form builder; Request a password reset.

See Also
user_pass_validate()
user_pass_submit()

Definition at line 30 of file user.pages.inc.

References EMAIL_MAX_LENGTH, t(), and USERNAME_MAX_LENGTH.

user_profile_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $account,
 |  |  | $category = 'account'
 | ) |  |

Form builder; edit a user account or one of their profile categories.

See Also
user_account_form()
user_account_form_validate()
user_profile_form_validate()
user_profile_form_submit()
user_cancel_confirm_form_submit()

Definition at line 247 of file user.pages.inc.

References entity_language(), field_attach_form(), t(), user_access(), and user_account_form().

user_register_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form builder; the user registration form.

See Also
user_account_form()
user_account_form_validate()
user_register_submit()

Definition at line 3766 of file user.module.

References drupal_anonymous_user(), drupal_goto(), entity_language(), field_attach_form(), field_info_instances(), t(), user_access(), and user_account_form().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Form generation

Functions
Form generation

Functions

drupal_get_form ($form_id)
drupal_build_form ($form_id, &$form_state)
form_state_defaults ()
drupal_rebuild_form ($form_id, &$form_state, $old_form=NULL)
form_get_cache ($form_build_id, &$form_state)
form_set_cache ($form_build_id, $form, $form_state)
form_state_keys_no_cache ()
form_load_include (&$form_state, $type, $module, $name=NULL)
drupal_form_submit ($form_id, &$form_state)
drupal_retrieve_form ($form_id, &$form_state)
drupal_process_form ($form_id, &$form, &$form_state)
drupal_prepare_form ($form_id, &$form, &$form_state)
drupal_validate_form ($form_id, &$form, &$form_state)
drupal_redirect_form ($form_state)
_form_validate (&$elements, &$form_state, $form_id=NULL)
form_execute_handlers ($type, &$form, &$form_state)
form_set_error ($name=NULL, $message= '', $limit_validation_errors=NULL)
form_clear_error ()
form_get_errors ()
form_get_error ($element)
form_error (&$element, $message= '')
form_builder ($form_id, &$element, &$form_state)
_form_builder_handle_input_element ($form_id, &$element, &$form_state)
_form_element_triggered_scripted_submission ($element, &$form_state)
_form_button_was_clicked ($element, &$form_state)
form_state_values_clean (&$form_state)
form_type_image_button_value ($form, $input, $form_state)
form_type_checkbox_value ($element, $input=FALSE)
form_type_checkboxes_value ($element, $input=FALSE)
form_type_tableselect_value ($element, $input=FALSE)
form_type_radios_value (&$element, $input=FALSE)
form_type_password_confirm_value ($element, $input=FALSE)
form_type_select_value ($element, $input=FALSE)
form_type_textfield_value ($element, $input=FALSE)
form_type_token_value ($element, $input=FALSE)
form_set_value ($element, $value, &$form_state)
form_options_flatten ($array)
_form_options_flatten ($array)
form_process_select ($element)
form_select_options ($element, $choices=NULL)
form_get_options ($element, $key)
form_process_password_confirm ($element)
password_confirm_validate ($element, &$element_state)
form_process_date ($element)
date_validate ($element)
map_month ($month)
weight_value (&$form)
form_process_radios ($element)
form_pre_render_conditional_form_element ($element)
form_process_checkbox ($element, $form_state)
form_process_checkboxes ($element)
form_process_actions ($element, &$form_state)
form_process_container ($element, &$form_state)
form_process_tableselect ($element)
form_process_machine_name ($element, &$form_state)
form_validate_machine_name (&$element, &$form_state)
form_process_fieldset (&$element, &$form_state)
form_pre_render_fieldset ($element)
form_process_vertical_tabs ($element, &$form_state)
form_process_weight ($element)
_form_set_class (&$element, $class=array())
element_validate_integer ($element, &$form_state)
element_validate_integer_positive ($element, &$form_state)
element_validate_number ($element, &$form_state)

Detailed Description

Functions to enable the processing and display of HTML forms.

Drupal uses these functions to achieve consistency in its form processing and presentation, while simplifying code and reducing the amount of HTML that must be explicitly generated by modules.

The primary function used with forms is drupal_get_form(), which is used for forms presented interactively to a user. Forms can also be built and submitted programmatically without any user input using the drupal_form_submit() function.

drupal_get_form() handles retrieving, processing, and displaying a rendered HTML form for modules automatically.

Here is an example of how to use drupal_get_form() and a form builder function:

* $form = drupal_get_form('my_module_example_form');
* ...
* function my_module_example_form($form, &$form_state) {
* $form['submit'] = array(
* '#type' => 'submit',
* '#value' => t('Submit'),
* );
* return $form;
* }
* function my_module_example_form_validate($form, &$form_state) {
* // Validation logic.
* }
* function my_module_example_form_submit($form, &$form_state) {
* // Submission logic.
* }
*

Or with any number of additional arguments:

* $extra = "extra";
* $form = drupal_get_form('my_module_example_form', $extra);
* ...
* function my_module_example_form($form, &$form_state, $extra) {
* $form['submit'] = array(
* '#type' => 'submit',
* '#value' => $extra,
* );
* return $form;
* }
*

The $form argument to form-related functions is a structured array containing the elements and properties of the form. For information on the array components and format, and more detailed explanations of the Form API workflow, see the Form API reference and the Form API documentation section. In addition, there is a set of Form API tutorials in the Form Example Tutorial which provide basics all the way up through multistep forms.

In the form builder, validation, submission, and other form functions, $form_state is the primary influence on the processing of the form and is passed by reference to most functions, so they use it to communicate with the form system and each other.

See drupal_build_form() for documentation of $form_state keys.

Function Documentation

_form_builder_handle_input_element | ( |  | $form_id,
 |  | & | $element,
 |  | & | $form_state
 | ) |  |

Adds the name and value properties of an input element before rendering.

Definition at line 1945 of file form.inc.

References $name, _form_button_was_clicked(), _form_element_triggered_scripted_submission(), drupal_array_get_nested_value(), drupal_array_nested_key_exists(), drupal_array_set_nested_value(), and form_set_value().

Referenced by form_builder().

_form_button_was_clicked | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Determines if a given button triggered the form submission.

This detects button controls that trigger a form submission by being clicked and having the click processed by the browser rather than being captured by JavaScript. Essentially, it detects if the button's name and value are part of the POST data, but with extra code to deal with the convoluted way in which browsers submit data for image button clicks.

This does not detect button clicks processed by Ajax (that is done in _form_element_triggered_scripted_submission()) and it does not detect form submissions from Internet Explorer in response to an ENTER key pressed in a textfield (form_builder() has extra code for that).

Because this function contains only part of the logic needed to determine $form_state['triggering_element'], it should not be called from anywhere other than within the Form API. Form validation and submit handlers needing to know which button was clicked should get that information from $form_state['triggering_element'].

Definition at line 2121 of file form.inc.

Referenced by _form_builder_handle_input_element().

_form_element_triggered_scripted_submission | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Detects if an element triggered the form submission via Ajax.

This detects button or non-button controls that trigger a form submission via Ajax or some other scriptable environment. These environments can set the special input key '_triggering_element_name' to identify the triggering element. If the name alone doesn't identify the element uniquely, the input key '_triggering_element_value' may also be set to require a match on element value. An example where this is needed is if there are several buttons all named 'op', and only differing in their value.

Definition at line 2092 of file form.inc.

Referenced by _form_builder_handle_input_element().

_form_options_flatten ( $array )

Iterates over an array and returns a flat array with duplicate keys removed.

This function also handles cases where objects are passed as array values.

Definition at line 2559 of file form.inc.

References $value, and drupal_static().

Referenced by form_options_flatten().

_form_set_class | ( | & | $element,
 |  |  | $class = array()
 | ) |  |

Sets a form element's class attribute.

Adds 'required' and 'error' classes as needed.

Parameters
$element | The form element.
$name | Array of new class names to be added.

Definition at line 4171 of file form.inc.

References form_get_error().

Referenced by theme_checkbox(), theme_fieldset(), theme_file(), theme_password(), theme_radio(), theme_select(), theme_textarea(), and theme_textfield().

_form_validate | ( | & | $elements,
 |  | & | $form_state,
 |  |  | $form_id = NULL
 | ) |  |

Performs validation on form elements.

First ensures required fields are completed, #maxlength is not exceeded, and selected options were in the list of options given to the user. Then calls user-defined validators.

Parameters
$elements | An associative array containing the structure of the form.
$form_state | A keyed array containing the current state of the form. The current user-submitted data is stored in $form_state['values'], though form validation functions are passed an explicit copy of the values for the sake of simplicity. Validation handlers can also $form_state to pass information on to submit handlers. For example: $form_state['data_for_submission'] = $data; This technique is useful when validation requires file parsing, web service requests, or other expensive requests that should not be repeated in the submission step.
$form_id | A unique string identifying the form for validation, submission, theming, and hook_form_alter functions.

Definition at line 1303 of file form.inc.

References $value, drupal_static_reset(), drupal_strlen(), element_children(), form_error(), form_execute_handlers(), form_options_flatten(), form_set_error(), form_set_value(), get_t(), watchdog(), and WATCHDOG_ERROR.

Referenced by drupal_validate_form().

date_validate ( $element )

Validates the date type to prevent invalid dates (e.g., February 30, 2006).

Definition at line 2987 of file form.inc.

References form_error(), and t().

drupal_build_form | ( |  | $form_id,
 |  | & | $form_state
 | ) |  |

Builds and process a form based on a form id.

The form may also be retrieved from the cache if the form was built in a previous page-load. The form is then passed on for processing, validation and submission if there is proper input.

Parameters
$form_id The unique string identifying the desired form. If a function with that name exists, it is called to build the form array. Modules that need to generate the same form (or very similar forms) using different $form_ids can implement hook_forms(), which maps different $form_id values to the proper form constructor function. Examples may be found in node_forms(), and search_forms().
$form_state An array which stores information about the form. This is passed as a reference so that the caller can use it to examine what in the form changed when the form submission process is complete. Furthermore, it may be used to store information related to the processed data in the form, which will persist across page requests when the 'cache' or 'rebuild' flag is set. The following parameters may be set in $form_state to affect how the form is rendered:
  • build_info: Internal. An associative array of information stored by Form API that is necessary to build and rebuild the form from cache when the original context may no longer be available:
    • args: A list of arguments to pass to the form constructor.
    • files: An optional array defining include files that need to be loaded for building the form. Each array entry may be the path to a file or another array containing values for the parameters 'type', 'module' and 'name' as needed by module_load_include(). The files listed here are automatically loaded by form_get_cache(). By default the current menu router item's 'file' definition is added, if any. Use form_load_include() to add include files from a form constructor.
    • form_id: Identification of the primary form being constructed and processed.
    • base_form_id: Identification for a base form, as declared in a hook_forms() implementation.
  • rebuild_info: Internal. Similar to 'build_info', but pertaining to drupal_rebuild_form().
  • rebuild: Normally, after the entire form processing is completed and submit handlers have run, a form is considered to be done and drupal_redirect_form() will redirect the user to a new page using a GET request (so a browser refresh does not re-submit the form). However, if 'rebuild' has been set to TRUE, then a new copy of the form is immediately built and sent to the browser, instead of a redirect. This is used for multi-step forms, such as wizards and confirmation forms. Normally, $form_state['rebuild'] is set by a submit handler, since it is usually logic within a submit handler that determines whether a form is done or requires another step. However, a validation handler may already set $form_state['rebuild'] to cause the form processing to bypass submit handlers and rebuild the form instead, even if there are no validation errors.
  • redirect: Used to redirect the form on submission. It may either be a string containing the destination URL, or an array of arguments compatible with drupal_goto(). See drupal_redirect_form() for complete information.
  • no_redirect: If set to TRUE the form will NOT perform a drupal_goto(), even if 'redirect' is set.
  • method: The HTTP form method to use for finding the input for this form. May be 'post' or 'get'. Defaults to 'post'. Note that 'get' method forms do not use form ids so are always considered to be submitted, which can have unexpected effects. The 'get' method should only be used on forms that do not change data, as that is exclusively the domain of 'post.'
  • cache: If set to TRUE the original, unprocessed form structure will be cached, which allows the entire form to be rebuilt from cache. A typical form workflow involves two page requests; first, a form is built and rendered for the user to fill in. Then, the user fills the form in and submits it, triggering a second page request in which the form must be built and processed. By default, $form and $form_state are built from scratch during each of these page requests. Often, it is necessary or desired to persist the $form and $form_state variables from the initial page request to the one that processes the submission. 'cache' can be set to TRUE to do this. A prominent example is an Ajax-enabled form, in which ajax_process_form() enables form caching for all forms that include an element with the #ajax property. (The Ajax handler has no way to build the form itself, so must rely on the cached version.) Note that the persistence of $form and $form_state happens automatically for (multi-step) forms having the 'rebuild' flag set, regardless of the value for 'cache'.
  • no_cache: If set to TRUE the form will NOT be cached, even if 'cache' is set.
  • values: An associative array of values submitted to the form. The validation functions and submit functions use this array for nearly all their decision making. (Note that #tree determines whether the values are a flat array or an array whose structure parallels the $form array. See Form API reference for more information.) These are raw and unvalidated, so should not be used without a thorough understanding of security implications. In almost all cases, code should use the data in the 'values' array exclusively. The most common use of this key is for multi-step forms that need to clear some of the user input when setting 'rebuild'. The values correspond to $_POST or $_GET, depending on the 'method' chosen.
  • always_process: If TRUE and the method is GET, a form_id is not necessary. This should only be used on RESTful GET forms that do NOT write data, as this could lead to security issues. It is useful so that searches do not need to have a form_id in their query arguments to trigger the search.
  • must_validate: Ordinarily, a form is only validated once, but there are times when a form is resubmitted internally and should be validated again. Setting this to TRUE will force that to happen. This is most likely to occur during Ajax operations.
  • programmed: If TRUE, the form was submitted programmatically, usually invoked via drupal_form_submit(). Defaults to FALSE.
  • programmed_bypass_access_check: If TRUE, programmatic form submissions are processed without taking #access into account. Set this to FALSE when submitting a form programmatically with values that may have been input by the user executing the current request; this will cause #access to be respected as it would on a normal form submission. Defaults to TRUE.
  • process_input: Boolean flag. TRUE signifies correct form submission. This is always TRUE for programmed forms coming from drupal_form_submit() (see 'programmed' key), or if the form_id coming from the $_POST data is set and matches the current form_id.
  • submitted: If TRUE, the form has been submitted. Defaults to FALSE.
  • executed: If TRUE, the form was submitted and has been processed and executed. Defaults to FALSE.
  • triggering_element: (read-only) The form element that triggered submission. This is the same as the deprecated $form_state['clicked_button']. It is the element that caused submission, which may or may not be a button (in the case of Ajax forms). This key is often used to distinguish between various buttons in a submit handler, and is also used in Ajax handlers.
  • clicked_button: Deprecated. Use triggering_element instead.
  • has_file_element: Internal. If TRUE, there is a file element and Form API will set the appropriate 'enctype' HTML attribute on the form.
  • groups: Internal. An array containing references to fieldsets to render them within vertical tabs.
  • storage: $form_state['storage'] is not a special key, and no specific support is provided for it in the Form API. By tradition it was the location where application-specific data was stored for communication between the submit, validation, and form builder functions, especially in a multi-step-style form. Form implementations may use any key(s) within $form_state (other than the keys listed here and other reserved ones used by Form API internals) for this kind of storage. The recommended way to ensure that the chosen key doesn't conflict with ones used by the Form API or other modules is to use the module name as the key name or a prefix for the key name. For example, the Node module uses $form_state['node'] in node editing forms to store information about the node being edited, and this information stays available across successive clicks of the "Preview" button as well as when the "Save" button is finally clicked.
  • buttons: A list containing copies of all submit and button elements in the form.
  • complete form: A reference to the $form variable containing the complete form structure. #process, #after_build, #element_validate, and other handlers being invoked on a form element may use this reference to access other information in the form the element is contained in.
  • temporary: An array holding temporary data accessible during the current page request only. All $form_state properties that are not reserved keys (see form_state_keys_no_cache()) persist throughout a multistep form sequence. Form API provides this key for modules to communicate information across form-related functions during a single page request. It may be used to temporarily save data that does not need to or should not be cached during the whole form workflow; e.g., data that needs to be accessed during the current form build process only. There is no use-case for this functionality in Drupal core.
  • wrapper_callback: Modules that wish to pre-populate certain forms with common elements, such as back/next/save buttons in multi-step form wizards, may define a form builder function name that returns a form structure, which is passed on to the actual form builder function. Such implementations may either define the 'wrapper_callback' via hook_forms() or have to invoke drupal_build_form() (instead of drupal_get_form()) on their own in a custom menu callback to prepare $form_state accordingly. Information on how certain $form_state properties control redirection behavior after form submission may be found in drupal_redirect_form().
Returns
The rendered form. This function may also perform a redirect and hence may not return at all, depending upon the $form_state flags that were set.
See Also
drupal_redirect_form()

Definition at line 308 of file form.inc.

References drupal_prepare_form(), drupal_process_form(), drupal_rebuild_form(), drupal_retrieve_form(), form_get_cache(), form_state_defaults(), and form_state_keys_no_cache().

Referenced by drupal_get_form(), and install_run_task().

drupal_form_submit | ( |  | $form_id,
 |  | & | $form_state
 | ) |  |

Retrieves, populates, and processes a form.

This function allows you to supply values for form elements and submit a form for processing. Compare to drupal_get_form(), which also builds and processes a form, but does not allow you to supply values.

There is no return value, but you can check to see if there are errors by calling form_get_errors().

Parameters
$form_id | The unique string identifying the desired form. If a function with that name exists, it is called to build the form array. Modules that need to generate the same form (or very similar forms) using different $form_ids can implement hook_forms(), which maps different $form_id values to the proper form constructor function. Examples may be found in node_forms() and search_forms().
$form_state | A keyed array containing the current state of the form. Most important is the $form_state['values'] collection, a tree of data used to simulate the incoming $_POST information from a user's form submission. If a key is not filled in $form_state['values'], then the default value of the respective element is used. To submit an unchecked checkbox or other control that browsers submit by not having a $_POST entry, include the key, but set the value to NULL.
... Any additional arguments are passed on to the functions called by drupal_form_submit(), including the unique form constructor function. For example, the node_edit form requires that a node object be passed in here when it is called. Arguments that need to be passed by reference should not be included here, but rather placed directly in the $form_state build info array so that the reference can be preserved. For example, a form builder function with the following signature:
* function mymodule_form($form, &$form_state, &$object) {
* }
*
would be called via drupal_form_submit() as follows:
* $form_state['values'] = $my_form_values;
* $form_state['build_info']['args'] = array(&$object);
* drupal_form_submit('mymodule_form', $form_state);
*
For example:
* // register a new user
* $form_state = array();
* $form_state['values']['name'] = 'robo-user';
* $form_state['values']['mail'] = 'robouser@example.com';
* $form_state['values']['pass']['pass1'] = 'password';
* $form_state['values']['pass']['pass2'] = 'password';
* $form_state['values']['op'] = t('Create new account');
* drupal_form_submit('user_register_form', $form_state);
*

Definition at line 685 of file form.inc.

References drupal_prepare_form(), drupal_process_form(), drupal_retrieve_form(), form_clear_error(), and form_state_defaults().

Referenced by aggregator_form_opml_submit(), install_run_task(), and openid_authentication().

drupal_get_form ( $form_id )

Returns a renderable form array for a given form ID.

This function should be used instead of drupal_build_form() when $form_state is not needed (i.e., when initially rendering the form) and is often used as a menu callback.

Parameters
$form_id The unique string identifying the desired form. If a function with that name exists, it is called to build the form array. Modules that need to generate the same form (or very similar forms) using different $form_ids can implement hook_forms(), which maps different $form_id values to the proper form constructor function. Examples may be found in node_forms(), and search_forms().
... Any additional arguments are passed on to the functions called by drupal_get_form(), including the unique form constructor function. For example, the node_edit form requires that a node object is passed in here when it is called. These are available to implementations of hook_form_alter() and hook_form_FORM_ID_alter() as the array $form_state['build_info']['args'].
Returns
The form array.
See Also
drupal_build_form()

Definition at line 123 of file form.inc.

References drupal_build_form().

Referenced by block_admin_display(), book_outline(), comment_admin(), comment_confirm_delete_page(), comment_edit_page(), comment_node_page_additions(), comment_reply(), dashboard_admin_blocks(), dblog_overview(), entity_example_basic_add(), filter_admin_format_page(), forum_form_main(), install_select_locale(), install_select_profile(), locale_languages_add_screen(), locale_translate_delete_page(), locale_translate_export_screen(), locale_translate_seek_screen(), menu_delete_menu_page(), menu_item_delete_page(), node_add(), node_page_edit(), openid_redirect(), openid_user_identities(), path_admin_edit(), path_admin_overview(), poll_block_latest_poll_view(), poll_view(), render_example_page_alter(), search_view(), system_actions_manage(), system_ip_blocking(), system_themes_page(), template_preprocess_poll_results(), trigger_assign(), update_selection_page(), user_admin(), user_block_view(), and user_page().

drupal_prepare_form | ( |  | $form_id,
 |  | & | $form,
 |  | & | $form_state
 | ) |  |

Prepares a structured form array.

Adds required elements, executes any hook_form_alter functions, and optionally inserts a validation token to prevent tampering.

Parameters
$form_id | A unique string identifying the form for validation, submission, theming, and hook_form_alter functions.
$form | An associative array containing the structure of the form.
$form_state | A keyed array containing the current state of the form. Passed in here so that hook_form_alter() calls can use it, as well.

Definition at line 969 of file form.inc.

References drupal_alter(), drupal_get_token(), drupal_html_id(), drupal_random_key(), and element_info().

Referenced by drupal_build_form(), drupal_form_submit(), and drupal_rebuild_form().

drupal_process_form | ( |  | $form_id,
 |  | & | $form,
 |  | & | $form_state
 | ) |  |

Processes a form submission.

This function is the heart of form API. The form gets built, validated and in appropriate cases, submitted and rebuilt.

Parameters
$form_id | The unique string identifying the current form.
$form | An associative array containing the structure of the form.
$form_state | A keyed array containing the current state of the form. This includes the current persistent storage data for the form, and any data passed along by earlier steps when displaying a multi-step form. Additional information, like the sanitized $_POST data, is also accumulated here.

Definition at line 829 of file form.inc.

References batch_get(), batch_process(), cache_clear_all(), drupal_get_token(), drupal_rebuild_form(), drupal_redirect_form(), drupal_static_reset(), drupal_validate_form(), form_builder(), form_execute_handlers(), form_get_errors(), form_set_cache(), and variable_get().

Referenced by ajax_form_callback(), drupal_build_form(), drupal_form_submit(), and file_ajax_upload().

drupal_rebuild_form | ( |  | $form_id,
 |  | & | $form_state,
 |  |  | $old_form = NULL
 | ) |  |

Constructs a new $form from the information in $form_state.

This is the key function for making multi-step forms advance from step to step. It is called by drupal_process_form() when all user input processing, including calling validation and submission handlers, for the request is finished. If a validate or submit handler set $form_state['rebuild'] to TRUE, and if other conditions don't preempt a rebuild from happening, then this function is called to generate a new $form, the next step in the form workflow, to be returned for rendering.

Ajax form submissions are almost always multi-step workflows, so that is one common use-case during which form rebuilding occurs. See ajax_form_callback() for more information about creating Ajax-enabled forms.

Parameters
$form_id | The unique string identifying the desired form. If a function with that name exists, it is called to build the form array. Modules that need to generate the same form (or very similar forms) using different $form_ids can implement hook_forms(), which maps different $form_id values to the proper form constructor function. Examples may be found in node_forms() and search_forms().
$form_state | A keyed array containing the current state of the form.
$old_form | (optional) A previously built $form. Used to retain the #build_id and #action properties in Ajax callbacks and similar partial form rebuilds. The only properties copied from $old_form are the ones which both exist in $old_form and for which $form_state['rebuild_info']['copy'][PROPERTY] is TRUE. If $old_form is not passed, the entire $form is rebuilt freshly. 'rebuild_info' needs to be a separate top-level property next to 'build_info', since the contained data must not be cached.
Returns
The newly built form.
See Also
drupal_process_form()
ajax_form_callback()

Definition at line 458 of file form.inc.

References drupal_prepare_form(), drupal_random_key(), drupal_retrieve_form(), form_builder(), and form_set_cache().

Referenced by drupal_build_form(), and drupal_process_form().

drupal_redirect_form ( $form_state )

Redirects the user to a URL after a form has been processed.

After a form is submitted and processed, normally the user should be redirected to a new destination page. This function figures out what that destination should be, based on the $form_state array and the 'destination' query string in the request URL, and redirects the user there.

Usually (for exceptions, see below) $form_state['redirect'] determines where to redirect the user. This can be set either to a string (the path to redirect to), or an array of arguments for drupal_goto(). If $form_state['redirect'] is missing, the user is usually (again, see below for exceptions) redirected back to the page they came from, where they should see a fresh, unpopulated copy of the form.

Here is an example of how to set up a form to redirect to the path 'node':

* $form_state['redirect'] = 'node';
*

And here is an example of how to redirect to 'node/123?foo=bar::baz':

* $form_state['redirect'] = array(
* 'node/123',
* array(
* 'query' => array(
* 'foo' => 'bar',
* ),
* 'fragment' => 'baz',
* ),
* );
*

There are several exceptions to the "usual" behavior described above:

  • If $form_state['programmed'] is TRUE, the form submission was usually invoked via drupal_form_submit(), so any redirection would break the script that invoked drupal_form_submit() and no redirection is done.
  • If $form_state['rebuild'] is TRUE, the form is being rebuilt, and no redirection is done.
  • If $form_state['no_redirect'] is TRUE, redirection is disabled. This is set, for instance, by ajax_get_form() to prevent redirection in Ajax callbacks. $form_state['no_redirect'] should never be set or altered by form builder functions or form validation/submit handlers.
  • If $form_state['redirect'] is set to FALSE, redirection is disabled.
  • If none of the above conditions has prevented redirection, then the redirect is accomplished by calling drupal_goto(), passing in the value of $form_state['redirect'] if it is set, or the current path if it is not. drupal_goto() preferentially uses the value of $_GET['destination'] (the 'destination' URL query string) if it is present, so this will override any values set by $form_state['redirect']. Note that during installation, install_goto() is called in place of drupal_goto().
Parameters
$form_state An associative array containing the current state of the form.
See Also
drupal_process_form()
drupal_build_form()

Definition at line 1249 of file form.inc.

References current_path(), drupal_get_query_parameters(), drupal_goto(), and drupal_installation_attempted().

Referenced by _batch_finished(), and drupal_process_form().

drupal_retrieve_form | ( |  | $form_id,
 |  | & | $form_state
 | ) |  |

Retrieves the structured array that defines a given form.

Parameters
$form_id | The unique string identifying the desired form. If a function with that name exists, it is called to build the form array. Modules that need to generate the same form (or very similar forms) using different $form_ids can implement hook_forms(), which maps different $form_id values to the proper form constructor function.
$form_state | A keyed array containing the current state of the form, including the additional arguments to drupal_get_form() or drupal_form_submit() in the 'args' component of the array.

Definition at line 728 of file form.inc.

References drupal_static(), menu_get_item(), and module_invoke_all().

Referenced by drupal_build_form(), drupal_form_submit(), and drupal_rebuild_form().

drupal_validate_form | ( |  | $form_id,
 |  | & | $form,
 |  | & | $form_state
 | ) |  |

Validates user-submitted form data in the $form_state array.

Parameters
$form_id | A unique string identifying the form for validation, submission, theming, and hook_form_alter functions.
$form | An associative array containing the structure of the form, which is passed by reference. Form validation handlers are able to alter the form structure (like #process and #after_build callbacks during form building) in case of a validation error. If a validation handler alters the form structure, it is responsible for validating the values of changed form elements in $form_state['values'] to prevent form submit handlers from receiving unvalidated values.
$form_state | A keyed array containing the current state of the form. The current user-submitted data is stored in $form_state['values'], though form validation functions are passed an explicit copy of the values for the sake of simplicity. Validation handlers can also use $form_state to pass information on to submit handlers. For example: $form_state['data_for_submission'] = $data; This technique is useful when validation requires file parsing, web service requests, or other expensive requests that should not be repeated in the submission step.

Definition at line 1122 of file form.inc.

References $name, $url, $value, _form_validate(), current_path(), drupal_array_get_nested_value(), drupal_array_nested_key_exists(), drupal_array_set_nested_value(), drupal_get_query_parameters(), drupal_static(), drupal_valid_token(), form_set_error(), t(), and url().

Referenced by drupal_process_form().

element_validate_integer | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Form element validation handler for integer elements.

Definition at line 4192 of file form.inc.

References $value, form_error(), and t().

Referenced by _element_validate_integer().

element_validate_integer_positive | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Form element validation handler for integer elements that must be positive.

Definition at line 4202 of file form.inc.

References $value, form_error(), and t().

Referenced by _element_validate_integer_positive().

element_validate_number | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Form element validation handler for number elements.

Definition at line 4212 of file form.inc.

References $value, form_error(), and t().

Referenced by _element_validate_number().

form_builder | ( |  | $form_id,
 |  | & | $element,
 |  | & | $form_state
 | ) |  |

Builds and processes all elements in the structured form array.

Adds any required properties to each element, maps the incoming input data to the proper elements, and executes any #process handlers attached to a specific element.

This is one of the three primary functions that recursively iterates a form array. This one does it for completing the form building process. The other two are _form_validate() (invoked via drupal_validate_form() and used to invoke validation logic for each element) and drupal_render() (for rendering each element). Each of these three pipelines provides ample opportunity for modules to customize what happens. For example, during this function's life cycle, the following functions get called for each element:

  • $element['#value_callback']: A function that implements how user input is mapped to an element's value property. This defaults to a function named 'form_type_TYPE_value' where TYPE is $element['#type'].
  • $element['#process']: An array of functions called after user input has been mapped to the element's value property. These functions can be used to dynamically add child elements: for example, for the 'date' element type, one of the functions in this array is form_process_date(), which adds the individual 'year', 'month', 'day', etc. child elements. These functions can also be used to set additional properties or implement special logic other than adding child elements: for example, for the 'fieldset' element type, one of the functions in this array is form_process_fieldset(), which adds the attributes and JavaScript needed to make the fieldset collapsible if the #collapsible property is set. The #process functions are called in preorder traversal, meaning they are called for the parent element first, then for the child elements.
  • $element['#after_build']: An array of functions called after form_builder() is done with its processing of the element. These are called in postorder traversal, meaning they are called for the child elements first, then for the parent element. There are similar properties containing callback functions invoked by _form_validate() and drupal_render(), appropriate for those operations.

Developers are strongly encouraged to integrate the functionality needed by their form or module within one of these three pipelines, using the appropriate callback property, rather than implementing their own recursive traversal of a form array. This facilitates proper integration between multiple modules. For example, module developers are familiar with the relative order in which hook_form_alter() implementations and #process functions run. A custom traversal function that affects the building of a form is likely to not integrate with hook_form_alter() and #process in the expected way. Also, deep recursion within PHP is both slow and memory intensive, so it is best to minimize how often it's done.

As stated above, each element's #process functions are executed after its value has been set. This enables those functions to execute conditional logic based on the current value. However, all of form_builder() runs before drupal_validate_form() is called, so during #process function execution, the element's value has not yet been validated, so any code that requires validated values must reside within a submit handler.

As a security measure, user input is used for an element's value only if the element exists within $form, is not disabled (as per the #disabled property), and can be accessed (as per the #access property, except that forms submitted using drupal_form_submit() bypass #access restrictions). When user input is ignored due to #disabled and #access restrictions, the element's default value is used.

Because of the preorder traversal, where #process functions of an element run before user input for its child elements is processed, and because of the Form API security of user input processing with respect to #access and #disabled described above, this generally means that #process functions should not use an element's (unvalidated) value to affect the #disabled or #access of child elements. Use-cases where a developer may be tempted to implement such conditional logic usually fall into one of two categories:

  • Where user input from the current submission must affect the structure of a form, including properties like #access and #disabled that affect how the next submission needs to be processed, a multi-step workflow is needed. This is most commonly implemented with a submit handler setting persistent data within $form_state based on validated values in $form_state['values'] and setting $form_state['rebuild']. The form building functions must then be implemented to use the $form_state data to rebuild the form with the structure appropriate for the new state.
  • Where user input must affect the rendering of the form without affecting its structure, the necessary conditional rendering logic should reside within functions that run during the rendering phase (#pre_render, theme, #theme_wrappers, and #post_render).
Parameters
$form_id | A unique string identifying the form for validation, submission, theming, and hook_form_alter functions.
$element | An associative array containing the structure of the current element.
$form_state | A keyed array containing the current state of the form. In this context, it is used to accumulate information about which button was clicked when the form was submitted, as well as the sanitized $_POST data.

Definition at line 1758 of file form.inc.

References $info, _form_builder_handle_input_element(), drupal_html_id(), element_children(), element_info(), url_is_external(), and variable_get().

Referenced by drupal_process_form(), and drupal_rebuild_form().

form_clear_error ( )

Clears all errors against all form elements made by form_set_error().

Definition at line 1627 of file form.inc.

References drupal_static_reset().

Referenced by drupal_form_submit().

form_error | ( | & | $element,
 |  |  | $message = ''
 | ) |  |

Flags an element as having an error.

Definition at line 1662 of file form.inc.

References form_set_error().

Referenced by _file_generic_settings_extensions(), _file_generic_settings_max_filesize(), _form_validate(), _image_field_resolution_validate(), ajax_example_node_by_author_autocomplete_validate(), ajax_example_unique_autocomplete_validate(), date_validate(), element_validate_integer(), element_validate_integer_positive(), element_validate_number(), field_default_form_errors(), field_example_3text_validate(), field_example_field_widget_error(), file_managed_file_validate(), form_example_phonenumber_combined_validate(), form_example_phonenumber_discrete_validate(), form_validate_machine_name(), hook_field_widget_error(), image_effect_color_validate(), image_effect_integer_validate(), image_effect_scale_validate(), image_style_form_add_validate(), install_configure_form_validate(), list_allowed_values_setting_validate(), number_field_widget_error(), number_field_widget_validate(), options_field_widget_error(), options_field_widget_validate(), password_confirm_validate(), path_form_element_validate(), taxonomy_field_widget_error(), and text_field_widget_error().

form_execute_handlers | ( |  | $type,
 |  | & | $form,
 |  | & | $form_state
 | ) |  |

Executes custom validation and submission handlers for a given form.

Button-specific handlers are checked first. If none exist, the function falls back to form-level handlers.

Parameters
$type | The type of handler to execute. 'validate' or 'submit' are the defaults used by Form API.
$form | An associative array containing the structure of the form.
$form_state | A keyed array containing the current state of the form. If the user submitted the form by clicking a button with custom handler functions defined, those handlers will be stored here.

Definition at line 1452 of file form.inc.

References batch_get().

Referenced by _form_validate(), drupal_process_form(), and node_form_submit_build_node().

form_get_cache | ( |  | $form_build_id,
 |  | & | $form_state
 | ) |  |

Fetches a form from cache.

Definition at line 503 of file form.inc.

References cache_get(), DRUPAL_ROOT, drupal_valid_token(), and module_load_include().

Referenced by ajax_get_form(), and drupal_build_form().

form_get_error ( $element )

Returns the error message filed against the given form element.

Form errors higher up in the form structure override deeper errors as well as errors on the element itself.

Definition at line 1647 of file form.inc.

References form_set_error().

Referenced by _form_set_class().

form_get_errors ( )

Returns an associative array of all errors.

Definition at line 1634 of file form.inc.

References form_set_error().

Referenced by block_admin_configure_submit(), comment_preview(), drupal_process_form(), install_run_task(), node_form(), node_preview(), openid_authentication(), system_settings_form(), and theme_taxonomy_overview_terms().

form_get_options | ( | $element,
 |  | $key
 | ) |

Returns the indexes of a select element's options matching a given key.

This function is useful if you need to modify the options that are already in a form element; for example, to remove choices which are not valid because of additional filters imposed by another module. One example might be altering the choices in a taxonomy selector. To correctly handle the case of a multiple hierarchy taxonomy, #options arrays can now hold an array of objects, instead of a direct mapping of keys to labels, so that multiple choices in the selector can have the same key (and label). This makes it difficult to manipulate directly, which is why this helper function exists.

This function does not support optgroups (when the elements of the #options array are themselves arrays), and will return FALSE if arrays are found. The caller must either flatten/restore or manually do their manipulations in this case, since returning the index is not sufficient, and supporting this would make the "helper" too complicated and cumbersome to be of any help.

As usual with functions that can return array() or FALSE, do not forget to use === and !== if needed.

Parameters
$element | The select element to search.
$key | The key to look for.
Returns
An array of indexes that match the given $key. Array will be empty if no elements were found. FALSE if optgroups were found.

Definition at line 2743 of file form.inc.

References $choice.

form_load_include | ( | & | $form_state,
 |  |  | $type,
 |  |  | $module,
 |  |  | $name = NULL
 | ) |  |

Ensures an include file is loaded whenever the form is processed.

Example:

* // Load node.admin.inc from Node module.
* form_load_include($form_state, 'inc', 'node', 'node.admin');
*

Use this function instead of module_load_include() from inside a form constructor or any form processing logic as it ensures that the include file is loaded whenever the form is processed. In contrast to using module_load_include() directly, form_load_include() makes sure the include file is correctly loaded also if the form is cached.

Parameters
$form_state | The current state of the form.
$type | The include file's type (file extension).
$module | The module to which the include file belongs.
$name | (optional) The base file name (without the $type extension). If omitted, $module is used; i.e., resulting in "$module.$type" by default.
Returns
The filepath of the loaded include file, or FALSE if the include file was not found or has been loaded already.
See Also
module_load_include()

Definition at line 612 of file form.inc.

References $module, $name, and module_load_include().

form_options_flatten ( $array )

Allows PHP array processing of multiple select options with the same value.

Used for form select elements which need to validate HTML option groups and multiple options which may return the same value. Associative PHP arrays cannot handle these structures, since they share a common key.

Parameters
$array The form options array to process.
Returns
An array with all hierarchical elements flattened to a single array.

Definition at line 2548 of file form.inc.

References _form_options_flatten(), and drupal_static_reset().

Referenced by _form_validate(), node_filter_form_submit(), and user_filter_form_submit().

form_pre_render_conditional_form_element ( $element )

Adds form element theming to an element if its title or description is set.

This is used as a pre render function for checkboxes and radios.

Definition at line 3118 of file form.inc.

References get_t().

form_pre_render_fieldset ( $element )

Adds members of this group as actual elements for rendering.

Parameters
$element An associative array containing the properties and children of the fieldset.
Returns
The modified element with all group members.

Definition at line 3629 of file form.inc.

References $children, and element_children().

form_process_actions | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Processes a form actions container element.

Parameters
$element | An associative array containing the properties and children of the form actions container.
$form_state | The $form_state array for the form this element belongs to.
Returns
The processed element.

Definition at line 3213 of file form.inc.

form_process_checkbox | ( | $element,
 |  | $form_state
 | ) |

Sets the #checked property of a checkbox element.

Definition at line 3138 of file form.inc.

References $value.

form_process_checkboxes ( $element )

Processes a checkboxes form element.

Definition at line 3165 of file form.inc.

References $choice, and $value.

form_process_container | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Processes a container element.

Parameters
$element | An associative array containing the properties and children of the container.
$form_state | The $form_state array for the form this element belongs to.
Returns
The processed element.

Definition at line 3230 of file form.inc.

References drupal_html_id().

form_process_date ( $element )

Expands a date element into year, month, and day select elements.

Definition at line 2931 of file form.inc.

References $title, drupal_map_assoc(), format_date(), REQUEST_TIME, t(), and variable_get().

form_process_fieldset | ( | & | $element,
 |  | & | $form_state
 | ) |  |

Arranges fieldsets into groups.

Parameters
$element | An associative array containing the properties and children of the fieldset. Note that $element must be taken by reference here, so processed child elements are taken over into $form_state.
$form_state | The $form_state array for the form this fieldset belongs to.
Returns
The processed element.

Definition at line 3583 of file form.inc.

form_process_machine_name | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Processes a machine-readable name form element.

Parameters
$element The form element to process. Properties used:
  • #machine_name: An associative array containing:
    • exists: A function name to invoke for checking whether a submitted machine name value already exists. The submitted value is passed as argument. In most cases, an existing API or menu argument loader function can be re-used. The callback is only invoked, if the submitted value differs from the element's #default_value.
    • source: (optional) The #array_parents of the form element containing the human-readable name (i.e., as contained in the $form structure) to use as source for the machine name. Defaults to array('name').
    • label: (optional) A text to display as label for the machine name value after the human-readable name form element. Defaults to "Machine name".
    • replace_pattern: (optional) A regular expression (without delimiters) matching disallowed characters in the machine name. Defaults to '[^a-z0-9_]+'.
    • replace: (optional) A character to replace disallowed characters in the machine name via JavaScript. Defaults to '_' (underscore). When using a different character, 'replace_pattern' needs to be set accordingly.
    • error: (optional) A custom form error message string to show, if the machine name contains disallowed characters.
    • standalone: (optional) Whether the live preview should stay in its own form element rather than in the suffix of the source element. Defaults to FALSE.
  • #maxlength: (optional) Should be set to the maximum allowed length of the machine name. Defaults to 64.
  • #disabled: (optional) Should be set to TRUE in case an existing machine name must not be changed after initial creation.

Definition at line 3457 of file form.inc.

References drupal_array_get_nested_value(), drupal_array_set_nested_value(), and t().

form_process_password_confirm ( $element )

Expand a password_confirm field into two text boxes.

Definition at line 2852 of file form.inc.

References t().

form_process_radios ( $element )

Expands a radios element into individual radio elements.

Definition at line 3029 of file form.inc.

References $choice, and drupal_html_id().

form_process_select ( $element )

Processes a select list form element.

This process callback is mandatory for select fields, since all user agents automatically preselect the first available option of single (non-multiple) select lists.

Parameters
$element The form element to process. Properties used:
  • #multiple: (optional) Indicates whether one or more options can be selected. Defaults to FALSE.
  • #default_value: Must be NULL or not set in case there is no value for the element yet, in which case a first default option is inserted by default. Whether this first option is a valid option depends on whether the field is #required or not.
  • #required: (optional) Whether the user needs to select an option (TRUE) or not (FALSE). Defaults to FALSE.
  • #empty_option: (optional) The label to show for the first default option. By default, the label is automatically set to "- Please select -" for a required field and "- None -" for an optional field.
  • #empty_value: (optional) The value for the first default option, which is used to determine whether the user submitted a value or not.
    • If #required is TRUE, this defaults to '' (an empty string).
    • If #required is not TRUE and this value isn't set, then no extra option is added to the select control, leaving the control in a slightly illogical state, because there's no way for the user to select nothing, since all user agents automatically preselect the first available option. But people are used to this being the behavior of select controls.
See Also
_form_validate()

Definition at line 2613 of file form.inc.

References t().

form_process_tableselect ( $element )

Creates checkbox or radio elements to populate a tableselect table.

Parameters
$element An associative array containing the properties and children of the tableselect element.
Returns
The processed element.

Definition at line 3359 of file form.inc.

References $choice, $title, $value, drupal_html_id(), and t().

form_process_vertical_tabs | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Creates a group formatted as vertical tabs.

Parameters
$element | An associative array containing the properties and children of the fieldset.
$form_state | The $form_state array for the form this vertical tab widget belongs to.
Returns
The processed element.

Definition at line 3687 of file form.inc.

References $name.

form_process_weight ( $element )

Expands a weight element into a select element.

Definition at line 3930 of file form.inc.

References DRUPAL_WEIGHT_SELECT_MAX, element_info(), and variable_get().

form_select_options | ( | $element,
 |  | $choices = NULL
 | ) |

Converts a select form element's options array into HTML.

Parameters
$element | An associative array containing the properties of the element.
$choices | Mixed: Either an associative array of items to list as choices, or an object with an 'option' member that is an associative array. This parameter is only used internally and should not be passed.
Returns
An HTML string of options for the select form element.

Definition at line 2679 of file form.inc.

References $choice, and check_plain().

Referenced by theme_select().

form_set_cache | ( | $form_build_id,
 |  | $form,
 |  | $form_state
 | ) |

Stores a form in the cache.

Definition at line 534 of file form.inc.

References cache_set(), drupal_get_token(), form_state_keys_no_cache(), and REQUEST_TIME.

Referenced by drupal_process_form(), and drupal_rebuild_form().

form_set_error | ( | $name = NULL,
 |  | $message = '',
 |  | $limit_validation_errors = NULL
 | ) |

Files an error against a form element.

When a validation error is detected, the validator calls form_set_error() to indicate which element needs to be changed and provide an error message. This causes the Form API to not execute the form submit handlers, and instead to re-display the form to the user with the corresponding elements rendered with an 'error' CSS class (shown as red by default).

The standard form_set_error() behavior can be changed if a button provides the #limit_validation_errors property. Multistep forms not wanting to validate the whole form can set #limit_validation_errors on buttons to limit validation errors to only certain elements. For example, pressing the "Previous" button in a multistep form should not fire validation errors just because the current step has invalid values. If #limit_validation_errors is set on a clicked button, the button must also define a #submit property (may be set to an empty array). Any #submit handlers will be executed even if there is invalid input, so extreme care should be taken with respect to any actions taken by them. This is typically not a problem with buttons like "Previous" or "Add more" that do not invoke persistent storage of the submitted form values. Do not use the #limit_validation_errors property on buttons that trigger saving of form values to the database.

The #limit_validation_errors property is a list of "sections" within $form_state['values'] that must contain valid values. Each "section" is an array with the ordered set of keys needed to reach that part of $form_state'values'.

Example 1: Allow the "Previous" button to function, regardless of whether any user input is valid.

* $form['actions']['previous'] = array(
* '#type' => 'submit',
* '#value' => t('Previous'),
* '#limit_validation_errors' => array(), // No validation.
* '#submit' => array('some_submit_function'), // #submit required.
* );
*

Example 2: Require some, but not all, user input to be valid to process the submission of a "Previous" button.

* $form['actions']['previous'] = array(
* '#type' => 'submit',
* '#value' => t('Previous'),
* '#limit_validation_errors' => array(
* array('step1'), // Validate $form_state['values']['step1'].
* array('foo', 'bar'), // Validate $form_state['values']['foo']['bar'].
* ),
* '#submit' => array('some_submit_function'), // #submit required.
* );
*

This will require $form_state['values']['step1'] and everything within it (for example, $form_state['values']['step1']['choice']) to be valid, so calls to form_set_error('step1', $message) or form_set_error('step1][choice', $message) will prevent the submit handlers from running, and result in the error message being displayed to the user. However, calls to form_set_error('step2', $message) and form_set_error('step2][groupX][choiceY', $message) will be suppressed, resulting in the message not being displayed to the user, and the submit handlers will run despite $form_state['values']['step2'] and $form_state['values']['step2']['groupX']['choiceY'] containing invalid values. Errors for an invalid $form_state['values']['foo'] will be suppressed, but errors flagging invalid values for $form_state['values']['foo']['bar'] and everything within it will be flagged and submission prevented.

Partial form validation is implemented by suppressing errors rather than by skipping the input processing and validation steps entirely, because some forms have button-level submit handlers that call Drupal API functions that assume that certain data exists within $form_state['values'], and while not doing anything with that data that requires it to be valid, PHP errors would be triggered if the input processing and validation steps were fully skipped.

Parameters
$name | The name of the form element. If the #parents property of your form element is array('foo', 'bar', 'baz') then you may set an error on 'foo' or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every element where the #parents array starts with 'foo'.
$message | The error message to present to the user.
$limit_validation_errors | Internal use only. The #limit_validation_errors property of the clicked button, if it exists.
Returns
Return value is for internal use only. To get a list of errors, use form_get_errors() or form_get_error().
See Also
http://drupal.org/node/370537
http://drupal.org/node/763376

Definition at line 1581 of file form.inc.

References $name, drupal_set_message(), and drupal_static().

Referenced by _field_ui_field_overview_form_validate_add_existing(), _field_ui_field_overview_form_validate_add_new(), _form_validate(), action_example_node_sticky_action_validate(), aggregator_form_category_validate(), aggregator_form_feed_validate(), aggregator_form_opml_validate(), ajax_example_dynamic_sections_validate(), authorize_filetransfer_form_validate(), block_add_block_form_validate(), block_admin_configure_validate(), book_admin_edit_validate(), book_admin_settings_validate(), color_scheme_form_validate(), comment_admin_overview_validate(), comment_form_validate(), contact_category_edit_form_validate(), contact_personal_form_validate(), contact_site_form_validate(), dblog_filter_form_validate(), drupal_validate_form(), email_example_form_validate(), SearchQuery\executeFirstPass(), file_managed_file_save_upload(), file_save_upload(), filter_admin_format_form_validate(), form_error(), form_example_tutorial_10_validate(), form_example_tutorial_6_validate(), form_example_tutorial_7_validate(), form_example_tutorial_8_next_validate(), form_example_tutorial_9_validate(), form_example_wizard_location_info_validate(), form_get_error(), form_get_errors(), forum_node_validate(), hook_node_validate(), hook_prepare(), hook_validate(), image_example_style_form_validate(), image_gd_settings(), image_gd_settings_validate(), image_style_name_validate(), install_settings_form_validate(), locale_languages_edit_form_validate(), locale_languages_predefined_form_validate(), locale_translate_edit_form_validate(), locale_translation_filter_form_validate(), menu_edit_item_validate(), node_admin_nodes_validate(), node_assign_owner_action_validate(), node_type_form_validate(), node_validate(), nodeapi_example_node_validate(), openid_begin(), openid_user_add_validate(), path_admin_form_validate(), poll_validate(), poll_view_voting_validate(), profile_field_form_validate(), profile_user_form_validate(), search_admin_settings_validate(), search_form_submit(), shortcut_link_edit_validate(), shortcut_set_add_form_validate(), shortcut_set_edit_form_validate(), shortcut_set_switch_validate(), simpletest_settings_form_validate(), system_add_date_format_type_form_validate(), system_add_date_formats_form_validate(), system_check_directory(), system_ip_blocking_form_validate(), system_send_email_action_validate(), system_site_information_settings_validate(), system_theme_settings_validate(), taxonomy_form_term_validate(), taxonomy_form_vocabulary_validate(), translation_node_validate(), trigger_assign_form_validate(), update_manager_install_form_submit(), update_manager_install_form_validate(), update_manager_update_form_validate(), update_settings_validate(), user_account_form_validate(), user_admin_account_validate(), user_admin_role_validate(), user_admin_settings(), user_login_final_validate(), user_login_name_validate(), user_pass_validate(), user_validate_current_pass(), and user_validate_picture().

form_set_value | ( |  | $element,
 |  |  | $value,
 |  | & | $form_state
 | ) |  |

Changes submitted form values during form validation.

Use this function to change the submitted value of a form element in a form validation function, so that the changed value persists in $form_state through the remaining validation and submission handlers. It does not change the value in $element['value'], only in $form_state['values'], which is where submitted values are always stored.

Note that form validation functions are specified in the '#validate' component of the form array (the value of $form['#validate'] is an array of validation function names). If the form does not originate in your module, you can implement hook_form_FORM_ID_alter() to add a validation function to $form['#validate'].

Parameters
$element | The form element that should have its value updated; in most cases you can just pass in the element from the $form array, although the only component that is actually used is '#parents'. If constructing yourself, set $element['#parents'] to be an array giving the path through the form array's keys to the element whose value you want to update. For instance, if you want to update the value of $form['elem1']['elem2'], which should be stored in $form_state['values']['elem1']['elem2'], you would set $element['#parents'] = array('elem1','elem2').
$value | The new value for the form element.
$form_state | Form state array where the value change should be recorded.

Definition at line 2531 of file form.inc.

References $value, and drupal_array_set_nested_value().

Referenced by _field_ui_field_overview_form_validate_add_new(), _file_generic_settings_extensions(), _file_generic_settings_file_directory_validate(), _form_builder_handle_input_element(), _form_validate(), _image_field_resolution_validate(), field_example_3text_validate(), file_managed_file_submit(), file_managed_file_validate(), filter_admin_format_form_validate(), form_example_phonenumber_combined_validate(), list_allowed_values_setting_validate(), node_search_validate(), number_field_widget_validate(), options_field_widget_validate(), password_confirm_validate(), path_form_element_validate(), search_form_validate(), system_site_information_settings_validate(), taxonomy_autocomplete_validate(), user_account_form_validate(), user_form_field_ui_field_edit_form_submit(), and user_pass_validate().

form_state_defaults ( )

Retrieves default values for the $form_state array.

Definition at line 396 of file form.inc.

Referenced by ajax_get_form(), drupal_build_form(), and drupal_form_submit().

form_state_keys_no_cache ( )

Returns an array of $form_state keys that shouldn't be cached.

Definition at line 555 of file form.inc.

Referenced by drupal_build_form(), and form_set_cache().

form_state_values_clean ( & $form_state )

Removes internal Form API elements and buttons from submitted form values.

This function can be used when a module wants to store all submitted form values, for example, by serializing them into a single database column. In such cases, all internal Form API values and all form button elements should not be contained, and this function allows to remove them before the module proceeds to storage. Next to button elements, the following internal values are removed:

  • form_id
  • form_token
  • form_build_id
  • op
Parameters
$form_state A keyed array containing the current state of the form, including submitted form values; altered by reference.

Definition at line 2159 of file form.inc.

References drupal_array_get_nested_value().

Referenced by filter_admin_format_form_submit(), path_admin_form_submit(), system_settings_form_submit(), system_theme_settings_submit(), user_profile_form_submit(), and user_register_submit().

form_type_checkbox_value | ( | $element,
 |  | $input = FALSE
 | ) |

Determines the value for a checkbox form element.

Parameters
$form | The form element whose value is being populated.
$input | The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
Returns
The data that will appear in the $element_state['values'] collection for this element. Return nothing to use the default.

Definition at line 2257 of file form.inc.

form_type_checkboxes_value | ( | $element,
 |  | $input = FALSE
 | ) |

Determines the value for a checkboxes form element.

Parameters
$element | The form element whose value is being populated.
$input | The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
Returns
The data that will appear in the $element_state['values'] collection for this element. Return nothing to use the default.

Definition at line 2298 of file form.inc.

References $value, and drupal_map_assoc().

form_type_image_button_value | ( | $form,
 |  | $input,
 |  | $form_state
 | ) |

Determines the value for an image button form element.

Parameters
$form | The form element whose value is being populated.
$input | The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
$form_state | A keyed array containing the current state of the form.
Returns
The data that will appear in the $form_state['values'] collection for this element. Return nothing to use the default.

Definition at line 2211 of file form.inc.

form_type_password_confirm_value | ( | $element,
 |  | $input = FALSE
 | ) |

Determines the value for a password_confirm form element.

Parameters
$element | The form element whose value is being populated.
$input | The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
Returns
The data that will appear in the $element_state['values'] collection for this element. Return nothing to use the default.

Definition at line 2414 of file form.inc.

form_type_radios_value | ( | & | $element,
 |  |  | $input = FALSE
 | ) |  |

Form value callback: Determines the value for a #type radios form element.

Parameters
$element | The form element whose value is being populated.
$input | (optional) The incoming input to populate the form element. If FALSE, the element's default value is returned. Defaults to FALSE.
Returns
The data that will appear in the $element_state['values'] collection for this element.

Definition at line 2375 of file form.inc.

References $value.

form_type_select_value | ( | $element,
 |  | $input = FALSE
 | ) |

Determines the value for a select form element.

Parameters
$element | The form element whose value is being populated.
$input | The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
Returns
The data that will appear in the $element_state['values'] collection for this element. Return nothing to use the default.

Definition at line 2434 of file form.inc.

References drupal_map_assoc().

form_type_tableselect_value | ( | $element,
 |  | $input = FALSE
 | ) |

Determines the value for a tableselect form element.

Parameters
$element | The form element whose value is being populated.
$input | The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
Returns
The data that will appear in the $element_state['values'] collection for this element. Return nothing to use the default.

Definition at line 2339 of file form.inc.

References $value, and drupal_map_assoc().

form_type_textfield_value | ( | $element,
 |  | $input = FALSE
 | ) |

Determines the value for a textfield form element.

Parameters
$element | The form element whose value is being populated.
$input | The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
Returns
The data that will appear in the $element_state['values'] collection for this element. Return nothing to use the default.

Definition at line 2475 of file form.inc.

Referenced by color_palette_color_value().

form_type_token_value | ( | $element,
 |  | $input = FALSE
 | ) |

Determines the value for form's token value.

Parameters
$element | The form element whose value is being populated.
$input | The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
Returns
The data that will appear in the $element_state['values'] collection for this element. Return nothing to use the default.

Definition at line 2496 of file form.inc.

form_validate_machine_name | ( | & | $element,
 |  | & | $form_state
 | ) |  |

Form element validation handler for machine_name elements.

Note that #maxlength is validated by _form_validate() already.

Definition at line 3537 of file form.inc.

References form_error(), and t().

map_month ( $month )

Helper function for usage with drupal_map_assoc to display month names.

Definition at line 2996 of file form.inc.

References drupal_static(), and t().

password_confirm_validate | ( |  | $element,
 |  | & | $element_state
 | ) |  |

Validates a password_confirm element.

Definition at line 2880 of file form.inc.

References form_error(), form_set_value(), and t().

weight_value ( & $form )

Sets the value for a weight element, with zero as a default.

Definition at line 3017 of file form.inc.

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Batch operations

Functions
Batch operations

Functions

batch_set ($batch_definition)
batch_process ($redirect=NULL, $url= 'batch', $redirect_callback= 'drupal_goto')
& batch_get ()
_batch_populate_queue (&$batch, $set_id)
_batch_queue ($batch_set)
hook_batch_alter (&$batch)

Detailed Description

End of "defgroup form_api".

Creates and processes batch operations.

Functions allowing forms processing to be spread out over several page requests, thus ensuring that the processing does not get interrupted because of a PHP timeout, while allowing the user to receive feedback on the progress of the ongoing operations.

The API is primarily designed to integrate nicely with the Form API workflow, but can also be used by non-Form API scripts (like update.php) or even simple page callbacks (which should probably be used sparingly).

Example:

* $batch = array(
* 'title' => t('Exporting'),
* 'operations' => array(
* array('my_function_1', array($account->uid, 'story')),
* array('my_function_2', array()),
* ),
* 'finished' => 'my_finished_callback',
* 'file' => 'path_to_file_containing_myfunctions',
* );
* batch_set($batch);
* // Only needed if not inside a form _submit handler.
* // Setting redirect in batch_process.
* batch_process('node/1');
*

Note: if the batch 'title', 'init_message', 'progress_message', or 'error_message' could contain any user input, it is the responsibility of the code calling batch_set() to sanitize them first with a function like check_plain() or filter_xss(). Furthermore, if the batch operation returns any user input in the 'results' or 'message' keys of $context, it must also sanitize them first.

Sample batch operations:

* // Simple and artificial: load a node of a given type for a given user
* function my_function_1($uid, $type, &$context) {
* // The $context array gathers batch context information about the execution (read),
* // as well as 'return values' for the current operation (write)
* // The following keys are provided :
* // 'results' (read / write): The array of results gathered so far by
* // the batch processing, for the current operation to append its own.
* // 'message' (write): A text message displayed in the progress page.
* // The following keys allow for multi-step operations :
* // 'sandbox' (read / write): An array that can be freely used to
* // store persistent data between iterations. It is recommended to
* // use this instead of $_SESSION, which is unsafe if the user
* // continues browsing in a separate window while the batch is processing.
* // 'finished' (write): A float number between 0 and 1 informing
* // the processing engine of the completion level for the operation.
* // 1 (or no value explicitly set) means the operation is finished
* // and the batch processing can continue to the next operation.
*
* $node = node_load(array('uid' => $uid, 'type' => $type));
* $context['results'][] = $node->nid . ' : ' . check_plain($node->title);
* $context['message'] = check_plain($node->title);
* }
*
* // More advanced example: multi-step operation - load all nodes, five by five
* function my_function_2(&$context) {
* if (empty($context['sandbox'])) {
* $context['sandbox']['progress'] = 0;
* $context['sandbox']['current_node'] = 0;
* $context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT nid) FROM {node}')->fetchField();
* }
* $limit = 5;
* $result = db_select('node')
* ->fields('node', array('nid'))
* ->condition('nid', $context['sandbox']['current_node'], '>')
* ->orderBy('nid')
* ->range(0, $limit)
* ->execute();
* foreach ($result as $row) {
* $node = node_load($row->nid, NULL, TRUE);
* $context['results'][] = $node->nid . ' : ' . check_plain($node->title);
* $context['sandbox']['progress']++;
* $context['sandbox']['current_node'] = $node->nid;
* $context['message'] = check_plain($node->title);
* }
* if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
* $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
* }
* }
*

Sample 'finished' callback:

* function batch_test_finished($success, $results, $operations) {
* // The 'success' parameter means no fatal PHP errors were detected. All
* // other error management should be handled using 'results'.
* if ($success) {
* $message = format_plural(count($results), 'One post processed.', '@count posts processed.');
* }
* else {
* $message = t('Finished with an error.');
* }
* drupal_set_message($message);
* // Providing data for the redirected page is done through $_SESSION.
* foreach ($results as $result) {
* $items[] = t('Loaded node %title.', array('%title' => $result));
* }
* $_SESSION['my_batch_results'] = $items;
* }
*

Function Documentation

_batch_populate_queue | ( | & | $batch,
 |  |  | $set_id
 | ) |  |

Populates a job queue with the operations of a batch set.

Depending on whether the batch is progressive or not, the BatchQueue or BatchMemoryQueue handler classes will be used.

Parameters
$batch | The batch array.
$set_id | The id of the set to process.
Returns
The name and class of the queue are added by reference to the batch set.

Definition at line 4563 of file form.inc.

References _batch_queue().

Referenced by batch_process(), and batch_set().

_batch_queue ( $batch_set )

Returns a queue object for a batch set.

Parameters
$batch_set The batch set.
Returns
The queue object.

Definition at line 4593 of file form.inc.

References $name, and DRUPAL_ROOT.

Referenced by _batch_finished(), _batch_populate_queue(), and _batch_process().

& batch_get ( )

Retrieves the current batch.

Definition at line 4538 of file form.inc.

Referenced by _batch_current_set(), _batch_finished(), _batch_next_set(), _batch_page(), _batch_process(), _batch_progress_page_js(), _batch_progress_page_nojs(), _batch_shutdown(), _system_batch_theme(), batch_process(), batch_set(), drupal_process_form(), form_execute_handlers(), and install_run_task().

batch_process | ( | $redirect = NULL,
 |  | $url = 'batch',
 |  | $redirect_callback = 'drupal_goto'
 | ) |

Processes the batch.

Unless the batch has been marked with 'progressive' = FALSE, the function issues a drupal_goto and thus ends page execution.

This function is generally not needed in form submit handlers; Form API takes care of batches that were set during form submission.

Parameters
$redirect | (optional) Path to redirect to when the batch has finished processing.
$url | (optional - should only be used for separate scripts like update.php) URL of the batch processing page.
$redirect_callback | (optional) Specify a function to be called to redirect to the progressive processing page. By default drupal_goto() will be used to redirect to a page which will do the progressive page. Specifying another function will allow the progressive processing to be processed differently.

Definition at line 4459 of file form.inc.

References $url, _batch_populate_queue(), _batch_process(), batch_get(), db_insert(), db_next_id(), drupal_alter(), drupal_get_token(), DRUPAL_ROOT, drupal_theme_initialize(), get_t(), REQUEST_TIME, and url().

Referenced by drupal_process_form(), install_run_task(), system_authorized_batch_process(), update_batch(), update_manual_status(), and user_cancel_confirm().

batch_set ( $batch_definition )

Adds a new batch.

Batch operations are added as new batch sets. Batch sets are used to spread processing (primarily, but not exclusively, forms processing) over several page requests. This helps to ensure that the processing is not interrupted due to PHP timeouts, while users are still able to receive feedback on the progress of the ongoing operations. Combining related operations into distinct batch sets provides clean code independence for each batch set, ensuring that two or more batches, submitted independently, can be processed without mutual interference. Each batch set may specify its own set of operations and results, produce its own UI messages, and trigger its own 'finished' callback. Batch sets are processed sequentially, with the progress bar starting afresh for each new set.

Parameters
$batch_definition An associative array defining the batch, with the following elements (all are optional except as noted):
  • operations: (required) Array of function calls to be performed. Example:
    * array(
    * array('my_function_1', array($arg1)),
    * array('my_function_2', array($arg2_1, $arg2_2)),
    * )
    *
  • title: A safe, translated string to use as the title for the progress page. Defaults to t('Processing').
  • init_message: Message displayed while the processing is initialized. Defaults to t('Initializing.').
  • progress_message: Message displayed while processing the batch. Available placeholders are , , , , and . Defaults to t('Completed of .').
  • error_message: Message displayed if an error occurred while processing the batch. Defaults to t('An error has occurred.').
  • finished: Name of a function to be executed after the batch has completed. This should be used to perform any result massaging that may be needed, and possibly save data in $_SESSION for display after final page redirection.
  • file: Path to the file containing the definitions of the 'operations' and 'finished' functions, for instance if they don't reside in the main .module file. The path should be relative to base_path(), and thus should be built using drupal_get_path().
  • css: Array of paths to CSS files to be used on the progress page.
  • url_options: options passed to url() when constructing redirect URLs for the batch.

Definition at line 4381 of file form.inc.

References _batch_populate_queue(), batch_get(), and get_t().

Referenced by batch_example_simple_form_submit(), install_run_task(), locale_languages_predefined_form_submit(), locale_system_update(), node_access_rebuild(), node_mass_update(), simpletest_run_tests(), update_authorize_run_install(), update_authorize_run_update(), update_batch(), update_manager_update_form_submit(), update_manual_status(), and user_cancel().

hook_batch_alter ( & $batch )

Alter batch information before a batch is processed.

Called by batch_process() to allow modules to alter a batch before it is processed.

Parameters
$batch The associative array of batch information. See batch_set() for details on what this could contain.
See Also
batch_set()
batch_process()

Definition at line 4541 of file system.api.php.

References overlay_get_mode().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Image toolkits

Functions
Image toolkits

Functions

image_get_available_toolkits ()
image_get_toolkit ()
image_toolkit_invoke ($method, stdClass $image, array $params=array())
image_get_info ($filepath, $toolkit=FALSE)
image_scale_and_crop (stdClass $image, $width, $height)
image_dimensions_scale (array &$dimensions, $width=NULL, $height=NULL, $upscale=FALSE)
image_scale (stdClass $image, $width=NULL, $height=NULL, $upscale=FALSE)
image_resize (stdClass $image, $width, $height)
image_rotate (stdClass $image, $degrees, $background=NULL)
image_crop (stdClass $image, $x, $y, $width, $height)
image_desaturate (stdClass $image)
image_load ($file, $toolkit=FALSE)
image_save (stdClass $image, $destination=NULL)
image_gd_settings ()
image_gd_settings_validate ($form, &$form_state)
image_gd_check_settings ()
image_gd_resize (stdClass $image, $width, $height)
image_gd_rotate (stdClass $image, $degrees, $background=NULL)
image_gd_crop (stdClass $image, $x, $y, $width, $height)
image_gd_desaturate (stdClass $image)
image_gd_load (stdClass $image)
image_gd_save (stdClass $image, $destination)
image_gd_create_tmp (stdClass $image, $width, $height)
image_gd_get_info (stdClass $image)

Detailed Description

Functions for image file manipulations.

Drupal's image toolkits provide an abstraction layer for common image file manipulations like scaling, cropping, and rotating. The abstraction frees module authors from the need to support multiple image libraries, and it allows site administrators to choose the library that's best for them.

PHP includes the GD library by default so a GD toolkit is installed with Drupal. Other toolkits like ImageMagick are available from contrib modules. GD works well for small images, but using it with larger files may cause PHP to run out of memory. In contrast the ImageMagick library does not suffer from this problem, but it requires the ISP to have installed additional software.

Image toolkits are discovered based on the associated module's hook_image_toolkits. Additionally the image toolkit include file must be identified in the files array in the module.info file. The toolkit must then be enabled using the admin/config/media/image-toolkit form.

Only one toolkit may be selected at a time. If a module author wishes to call a specific toolkit they can check that it is installed by calling image_get_available_toolkits(), and then calling its functions directly.

Function Documentation

image_crop | ( | stdClass | $image,
 |  |  | $x,
 |  |  | $y,
 |  |  | $width,
 |  |  | $height
 | ) |  |

Crops an image to a rectangle specified by the given dimensions.

Parameters
$image | An image object returned by image_load().
$x | The top left coordinate, in pixels, of the crop area (x axis value).
$y | The top left coordinate, in pixels, of the crop area (y axis value).
$width | The target width, in pixels.
$height | The target height, in pixels.
Returns
TRUE on success, FALSE on failure.
See Also
image_load()
image_scale_and_crop()
image_gd_crop()

Definition at line 331 of file image.inc.

References image_toolkit_invoke().

Referenced by image_crop_effect(), and image_scale_and_crop().

image_desaturate ( stdClass $image )

Converts an image to grayscale.

Parameters
$image An image object returned by image_load().
Returns
TRUE on success, FALSE on failure.
See Also
image_load()
image_gd_desaturate()

Definition at line 354 of file image.inc.

References image_toolkit_invoke().

Referenced by image_desaturate_effect().

image_dimensions_scale | ( | array & | $dimensions,
 |  |  | $width = NULL,
 |  |  | $height = NULL,
 |  |  | $upscale = FALSE
 | ) |  |

Scales image dimensions while maintaining aspect ratio.

The resulting dimensions can be smaller for one or both target dimensions.

Parameters
$dimensions | Dimensions to be modified - an array with components width and height, in pixels.
$width | The target width, in pixels. If this value is NULL then the scaling will be based only on the height value.
$height | The target height, in pixels. If this value is NULL then the scaling will be based only on the width value.
$upscale | Boolean indicating that images smaller than the target dimensions will be scaled up. This generally results in a low quality image.
Returns
TRUE if $dimensions was modified, FALSE otherwise.
See Also
image_scale()

Definition at line 203 of file image.inc.

Referenced by image_scale(), and image_scale_dimensions().

image_gd_check_settings ( )

Verify GD2 settings (that the right version is actually installed).

Returns
A boolean indicating if the GD toolkit is available on this machine.

Definition at line 58 of file image.gd.inc.

Referenced by image_gd_settings(), and system_image_toolkits().

image_gd_create_tmp | ( | stdClass | $image,
 |  |  | $width,
 |  |  | $height
 | ) |  |

Create a truecolor image preserving transparency from a provided image.

Parameters
$image | An image object.
$width | The new width of the new image, in pixels.
$height | The new height of the new image, in pixels.
Returns
A GD image handle.

Definition at line 301 of file image.gd.inc.

Referenced by image_gd_crop(), and image_gd_resize().

image_gd_crop | ( | stdClass | $image,
 |  |  | $x,
 |  |  | $y,
 |  |  | $width,
 |  |  | $height
 | ) |  |

Crop an image using the GD toolkit.

Parameters
$image | An image object. The $image->resource, $image->info['width'], and $image->info['height'] values will be modified by this call.
$x | The starting x offset at which to start the crop, in pixels.
$y | The starting y offset at which to start the crop, in pixels.
$width | The width of the cropped area, in pixels.
$height | The height of the cropped area, in pixels.
Returns
TRUE or FALSE, based on success.
See Also
image_crop()

Definition at line 187 of file image.gd.inc.

References image_gd_create_tmp().

image_gd_desaturate ( stdClass $image )

Convert an image resource to grayscale.

Note that transparent GIFs loose transparency when desaturated.

Parameters
$image An image object. The $image->resource value will be modified by this call.
Returns
TRUE or FALSE, based on success.
See Also
image_desaturate()

Definition at line 214 of file image.gd.inc.

References watchdog().

image_gd_get_info ( stdClass $image )

Get details about an image.

Parameters
$image An image object.
Returns
FALSE, if the file could not be found or is not an image. Otherwise, a keyed array containing information about the image:
  • "width": Width, in pixels.
  • "height": Height, in pixels.
  • "extension": Commonly used file extension for the image.
  • "mime_type": MIME type ('image/jpeg', 'image/gif', 'image/png').
See Also
image_get_info()

Definition at line 347 of file image.gd.inc.

image_gd_load ( stdClass $image )

GD helper function to create an image resource from a file.

Parameters
$image An image object. The $image->resource value will populated by this call.
Returns
TRUE or FALSE, based on success.
See Also
image_load()

Definition at line 234 of file image.gd.inc.

image_gd_resize | ( | stdClass | $image,
 |  |  | $width,
 |  |  | $height
 | ) |  |

Scale an image to the specified size using GD.

Parameters
$image | An image object. The $image->resource, $image->info['width'], and $image->info['height'] values will be modified by this call.
$width | The new width of the resized image, in pixels.
$height | The new height of the resized image, in pixels.
Returns
TRUE or FALSE, based on success.
See Also
image_resize()

Definition at line 83 of file image.gd.inc.

References image_gd_create_tmp().

image_gd_rotate | ( | stdClass | $image,
 |  |  | $degrees,
 |  |  | $background = NULL
 | ) |  |

Rotate an image the given number of degrees.

Parameters
$image | An image object. The $image->resource, $image->info['width'], and $image->info['height'] values will be modified by this call.
$degrees | The number of (clockwise) degrees to rotate the image.
$background | An hexadecimal integer specifying the background color to use for the uncovered area of the image after the rotation. E.g. 0x000000 for black, 0xff00ff for magenta, and 0xffffff for white. For images that support transparency, this will default to transparent. Otherwise it will be white.
Returns
TRUE or FALSE, based on success.
See Also
image_rotate()

Definition at line 117 of file image.gd.inc.

References watchdog().

image_gd_save | ( | stdClass | $image,
 |  |  | $destination
 | ) |  |

GD helper to write an image resource to a destination file.

Parameters
$image | An image object.
$destination | A string file URI or path where the image should be saved.
Returns
TRUE or FALSE, based on success.
See Also
image_save()

Definition at line 252 of file image.gd.inc.

References drupal_realpath(), drupal_tempnam(), FILE_EXISTS_REPLACE, file_get_stream_wrappers(), file_stream_wrapper_valid_scheme(), file_unmanaged_move(), file_uri_scheme(), STREAM_WRAPPERS_LOCAL, and variable_get().

image_gd_settings ( )

Retrieve settings for the GD2 toolkit.

Definition at line 16 of file image.gd.inc.

References form_set_error(), image_gd_check_settings(), t(), and variable_get().

image_gd_settings_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate the submitted GD settings.

Definition at line 44 of file image.gd.inc.

References $value, form_set_error(), and t().

image_get_available_toolkits ( )

Gets a list of available toolkits.

Returns
An array with the toolkit names as keys and the descriptions as values.

Definition at line 42 of file image.inc.

References $info, $name, $output, and module_invoke_all().

Referenced by image_get_toolkit(), and system_image_toolkit_settings().

image_get_info | ( | $filepath,
 |  | $toolkit = FALSE
 | ) |

Gets details about an image.

Drupal supports GIF, JPG and PNG file formats when used with the GD toolkit, and may support others, depending on which toolkits are installed.

Parameters
$filepath | String specifying the path of the image file.
$toolkit | An optional image toolkit name to override the default.
Returns
FALSE, if the file could not be found or is not an image. Otherwise, a keyed array containing information about the image:
  • "width": Width, in pixels.
  • "height": Height, in pixels.
  • "extension": Commonly used file extension for the image.
  • "mime_type": MIME type ('image/jpeg', 'image/gif', 'image/png').
  • "file_size": File size in bytes.

Definition at line 124 of file image.inc.

References image_get_toolkit(), and image_toolkit_invoke().

Referenced by _image_update_7002_populate_dimensions(), file_validate_image_resolution(), file_validate_is_image(), hook_file_download(), hook_prepare(), image_field_presave(), image_field_widget_process(), image_file_download(), image_load(), image_save(), theme_image_style_preview(), user_file_download(), and user_save().

image_get_toolkit ( )

Gets the name of the currently used toolkit.

Returns
String containing the name of the selected toolkit, or FALSE on error.

Definition at line 63 of file image.inc.

References image_get_available_toolkits(), and variable_get().

Referenced by image_get_info(), image_load(), and system_image_toolkit_settings().

image_load | ( | $file,
 |  | $toolkit = FALSE
 | ) |

Loads an image file and returns an image object.

Any changes to the file are not saved until image_save() is called.

Parameters
$file | Path to an image file.
$toolkit | An optional, image toolkit name to override the default.
Returns
An image object or FALSE if there was a problem loading the file. The image object has the following properties:
  • 'source' - The original file path.
  • 'info' - The array of information returned by image_get_info()
  • 'toolkit' - The name of the image toolkit requested when the image was loaded. Image toolkits may add additional properties. The caller is advised not to monkey about with them.
See Also
image_save()
image_get_info()
image_get_available_toolkits()
image_gd_load()

Definition at line 383 of file image.inc.

References image_get_info(), image_get_toolkit(), and image_toolkit_invoke().

Referenced by file_validate_image_resolution(), image_style_create_derivative(), and image_style_deliver().

image_resize | ( | stdClass | $image,
 |  |  | $width,
 |  |  | $height
 | ) |  |

Resizes an image to the given dimensions (ignoring aspect ratio).

Parameters
$image | An image object returned by image_load().
$width | The target width, in pixels.
$height | The target height, in pixels.
Returns
TRUE on success, FALSE on failure.
See Also
image_load()
image_gd_resize()

Definition at line 279 of file image.inc.

References image_toolkit_invoke().

Referenced by image_resize_effect(), image_scale(), and image_scale_and_crop().

image_rotate | ( | stdClass | $image,
 |  |  | $degrees,
 |  |  | $background = NULL
 | ) |  |

Rotates an image by the given number of degrees.

Parameters
$image | An image object returned by image_load().
$degrees | The number of (clockwise) degrees to rotate the image.
$background | An hexadecimal integer specifying the background color to use for the uncovered area of the image after the rotation. E.g. 0x000000 for black, 0xff00ff for magenta, and 0xffffff for white. For images that support transparency, this will default to transparent. Otherwise it will be white.
Returns
TRUE on success, FALSE on failure.
See Also
image_load()
image_gd_rotate()

Definition at line 306 of file image.inc.

References image_toolkit_invoke().

Referenced by image_rotate_effect().

image_save | ( | stdClass | $image,
 |  |  | $destination = NULL
 | ) |  |

Closes the image and saves the changes to a file.

Parameters
$image | An image object returned by image_load(). The object's 'info' property will be updated if the file is saved successfully.
$destination | Destination path where the image should be saved. If it is empty the original image file will be overwritten.
Returns
TRUE on success, FALSE on failure.
See Also
image_load()
image_gd_save()

Definition at line 417 of file image.inc.

References drupal_chmod(), image_get_info(), and image_toolkit_invoke().

Referenced by file_validate_image_resolution(), and image_style_create_derivative().

image_scale | ( | stdClass | $image,
 |  |  | $width = NULL,
 |  |  | $height = NULL,
 |  |  | $upscale = FALSE
 | ) |  |

Scales an image while maintaining aspect ratio.

The resulting image can be smaller for one or both target dimensions.

Parameters
$image | An image object returned by image_load().
$width | The target width, in pixels. If this value is NULL then the scaling will be based only on the height value.
$height | The target height, in pixels. If this value is NULL then the scaling will be based only on the width value.
$upscale | Boolean indicating that files smaller than the dimensions will be scaled up. This generally results in a low quality image.
Returns
TRUE on success, FALSE on failure.
See Also
image_dimensions_scale()
image_load()
image_scale_and_crop()

Definition at line 252 of file image.inc.

References image_dimensions_scale(), and image_resize().

Referenced by file_validate_image_resolution(), and image_scale_effect().

image_scale_and_crop | ( | stdClass | $image,
 |  |  | $width,
 |  |  | $height
 | ) |  |

Scales an image to the exact width and height given.

This function achieves the target aspect ratio by cropping the original image equally on both sides, or equally on the top and bottom. This function is useful to create uniform sized avatars from larger images.

The resulting image always has the exact target dimensions.

Parameters
$image | An image object returned by image_load().
$width | The target width, in pixels.
$height | The target height, in pixels.
Returns
TRUE on success, FALSE on failure.
See Also
image_load()
image_resize()
image_crop()

Definition at line 169 of file image.inc.

References image_crop(), and image_resize().

Referenced by image_scale_and_crop_effect().

image_toolkit_invoke | ( |  | $method,
 |  | stdClass | $image,
 |  | array | $params = array()
 | ) |  |

Invokes the given method using the currently selected toolkit.

Parameters
$method | A string containing the method to invoke.
$image | An image object returned by image_load().
$params | An optional array of parameters to pass to the toolkit method.
Returns
Mixed values (typically Boolean indicating successful operation).

Definition at line 93 of file image.inc.

References watchdog(), and WATCHDOG_ERROR.

Referenced by image_crop(), image_desaturate(), image_get_info(), image_load(), image_resize(), image_rotate(), and image_save().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Language Negotiation API functionality

Functions
Language Negotiation API functionality

Functions

language_types_info ()
language_types_configurable ($stored=TRUE)
language_types_disable ($types)
language_types_set ()
language_negotiation_get ($type, $provider_id=NULL)
language_negotiation_get_any ($provider_id)
language_negotiation_get_switch_links ($type, $path)
language_negotiation_purge ()
language_negotiation_set ($type, $language_providers)
language_negotiation_info ()
language_provider_invoke ($provider_id, $provider=NULL)
language_provider_weight ($provider)
language_initialize ($type)
language_from_default ()
language_url_split_prefix ($path, $languages)
language_fallback_get_candidates ($type=LANGUAGE_TYPE_CONTENT)
hook_language_types_info ()
hook_language_types_info_alter (array &$language_types)
hook_language_negotiation_info ()
hook_language_negotiation_info_alter (array &$language_providers)

Detailed Description

Functions to customize the language types and the negotiation process.

The language negotiation API is based on two major concepts:

  • Language types: types of translatable data (the types of data that a user can view or request).
  • Language negotiation providers: functions for determining which language to use to present a particular piece of data to the user. Both language types and language negotiation providers are customizable.

Drupal defines three built-in language types:

  • Interface language: The page's main language, used to present translated user interface elements such as titles, labels, help text, and messages.
  • Content language: The language used to present content that is available in more than one language (see Field Language API for details).
  • URL language: The language associated with URLs. When generating a URL, this value will be used by url() as a default if no explicit preference is provided. Modules can define additional language types through hook_language_types_info(), and alter existing language type definitions through hook_language_types_info_alter().

Language types may be configurable or fixed. The language negotiation providers associated with a configurable language type can be explicitly set through the user interface. A fixed language type has predetermined (module-defined) language negotiation settings and, thus, does not appear in the configuration page. Here is a code snippet that makes the content language (which by default inherits the interface language's values) configurable:

* function mymodule_language_types_info_alter(&$language_types) {
* unset($language_types[LANGUAGE_TYPE_CONTENT]['fixed']);
* }
*

Every language type can have a different set of language negotiation providers assigned to it. Different language types often share the same language negotiation settings, but they can have independent settings if needed. If two language types are configured the same way, their language switcher configuration will be functionally identical and the same settings will act on both language types.

Drupal defines the following built-in language negotiation providers:

  • URL: Determine the language from the URL (path prefix or domain).
  • Session: Determine the language from a request/session parameter.
  • User: Follow the user's language preference.
  • Browser: Determine the language from the browser's language settings.
  • Default language: Use the default site language. Language negotiation providers are simple callback functions that implement a particular logic to return a language code. For instance, the URL provider searches for a valid path prefix or domain name in the current request URL. If a language negotiation provider does not return a valid language code, the next provider associated to the language type (based on provider weight) is invoked.

Modules can define additional language negotiation providers through hook_language_negotiation_info(), and alter existing providers through hook_language_negotiation_info_alter(). Here is an example snippet that lets path prefixes be ignored for administrative paths:

* function mymodule_language_negotiation_info_alter(&$negotiation_info) {
* // Replace the core function with our own function.
* module_load_include('language', 'inc', 'language.negotiation');
* $negotiation_info[LANGUAGE_NEGOTIATION_URL]['callbacks']['language'] = 'mymodule_from_url';
* $negotiation_info[LANGUAGE_NEGOTIATION_URL]['file'] = drupal_get_path('module', 'mymodule') . '/mymodule.module';
* }
*
* function mymodule_from_url($languages) {
* // Use the core URL language negotiation provider to get a valid language
* // code.
* module_load_include('language', 'inc', 'language.negotiation');
* $langcode = language_from_url($languages);
*
* // If we are on an administrative path, override with the default language.
* if (isset($_GET['q']) && strtok($_GET['q'], '/') == 'admin') {
* return language_default()->langcode;
* }
* return $langcode;
* }
*

For more information, see Language Negotiation API

Function Documentation

hook_language_negotiation_info ( )

Define language negotiation providers.

Returns
An associative array of language negotiation provider definitions. The keys are provider identifiers, and the values are associative arrays defining each provider, with the following elements:
  • types: An array of allowed language types. If a language negotiation provider does not specify which language types it should be used with, it will be available for all the configurable language types.
  • callbacks: An associative array of functions that will be called to perform various tasks. Possible elements are:
    • language: (required) Name of the callback function that determines the language value.
    • switcher: (optional) Name of the callback function that determines links for a language switcher block associated with this provider. See language_switcher_url() for an example.
    • url_rewrite: (optional) Name of the callback function that provides URL rewriting, if needed by this provider.
  • file: The file where callback functions are defined (this file will be included before the callbacks are invoked).
  • weight: The default weight of the provider.
  • name: The translated human-readable name for the provider.
  • description: A translated longer description of the provider.
  • config: An internal path pointing to the provider's configuration page.
  • cache: The value Drupal's page cache should be set to for the current provider to be invoked.
See Also
hook_language_negotiation_info_alter()

Definition at line 140 of file language.api.php.

References drupal_get_path(), and t().

hook_language_negotiation_info_alter ( array & $language_providers )

Perform alterations on language negoiation providers.

Parameters
$language_providers Array of language negotiation provider definitions.
See Also
hook_language_negotiation_info()

Definition at line 167 of file language.api.php.

hook_language_types_info ( )

Define language types.

Returns
An associative array of language type definitions. The keys are the identifiers, which are also used as names for global variables representing the types in the bootstrap phase. The values are associative arrays that may contain the following elements:
  • name: The human-readable language type identifier.
  • description: A description of the language type.
  • fixed: A fixed array of language negotiation provider identifiers to use to initialize this language. Defining this key makes the language type non-configurable, so it will always use the specified providers in the given priority order. Omit to make the language type configurable.
See Also
hook_language_types_info_alter()

Definition at line 82 of file language.api.php.

References t().

hook_language_types_info_alter ( array & $language_types )

Perform alterations on language types.

Parameters
$language_types Array of language type definitions.
See Also
hook_language_types_info()

Definition at line 103 of file language.api.php.

References t().

language_fallback_get_candidates ( $type = LANGUAGE_TYPE_CONTENT )

Returns the possible fallback languages ordered by language weight.

Parameters
(optional) The language type. Defaults to LANGUAGE_TYPE_CONTENT.
Returns
An array of language codes.

Definition at line 554 of file language.inc.

References drupal_alter(), drupal_static(), language_list(), and LANGUAGE_NONE.

language_from_default ( )

Returns the default language negotiation provider.

Returns
The default language code.

Definition at line 509 of file language.inc.

References language_default().

language_initialize ( $type )

Chooses a language based on language negotiation provider settings.

Parameters
$type The language type key to find the language for.
Returns
The negotiated language object.

Definition at line 484 of file language.inc.

References language_default(), LANGUAGE_NEGOTIATION_DEFAULT, language_provider_invoke(), and variable_get().

Referenced by drupal_language_initialize(), and language_negotiation_get_switch_links().

language_negotiation_get | ( | $type,
 |  | $provider_id = NULL
 | ) |

Checks whether a language negotiation provider is enabled for a language type.

This has two possible behaviors:

  • If $provider_id is given return its ID if enabled, FALSE otherwise.
  • If no ID is passed the first enabled language negotiation provider is returned.
Parameters
$type | The language negotiation provider type.
$provider_id | The language negotiation provider ID.
Returns
The provider ID if it is enabled, FALSE otherwise.

Definition at line 230 of file language.inc.

References LANGUAGE_NEGOTIATION_DEFAULT, and variable_get().

Referenced by language_negotiation_get_any(), and locale_language_selector_form().

language_negotiation_get_any ( $provider_id )

Checks if the language negotiation provider is enabled for any language type.

Parameters
$provider_id The language negotiation provider ID.
Returns
TRUE if there is at least one language type for which the given language provider is enabled, FALSE otherwise.

Definition at line 258 of file language.inc.

References language_negotiation_get(), and language_types_configurable().

Referenced by locale_language_from_url(), and locale_language_url_rewrite_session().

language_negotiation_get_switch_links | ( | $type,
 |  | $path
 | ) |

Returns the language switch links for the given language.

Parameters
$type | The language negotiation type.
$path | The internal path the switch links will be relative to.
Returns
A keyed array of links ready to be themed.

Definition at line 279 of file language.inc.

References $links, drupal_alter(), DRUPAL_ROOT, language_initialize(), language_list(), and variable_get().

Referenced by locale_block_view(), translation_node_overview(), and translation_node_view().

language_negotiation_info ( )

Returns all the defined language negotiation providers.

Returns
An array of language negotiation providers.

Definition at line 392 of file language.inc.

References drupal_alter(), drupal_static(), language_default(), LANGUAGE_NEGOTIATION_DEFAULT, module_invoke_all(), and t().

Referenced by language_negotiation_purge(), language_negotiation_set(), language_provider_invoke(), language_types_set(), and locale_languages_configure_form().

language_negotiation_purge ( )

Removes any unused language negotiation providers from the configuration.

Definition at line 318 of file language.inc.

References drupal_static_reset(), language_negotiation_info(), language_negotiation_set(), language_types_info(), and variable_get().

Referenced by locale_modules_enabled().

language_negotiation_set | ( | $type,
 |  | $language_providers
 | ) |

Saves a list of language negotiation providers.

Parameters
$type | The language negotiation type.
$language_providers | An array of language negotiation provider weights keyed by provider ID.
See Also
language_provider_weight()

Definition at line 347 of file language.inc.

References language_negotiation_info(), language_provider_weight(), language_types_configurable(), and variable_set().

Referenced by language_negotiation_purge(), language_types_set(), locale_languages_configure_form_submit(), locale_update_7001(), and locale_update_7002().

language_provider_invoke | ( | $provider_id,
 |  | $provider = NULL
 | ) |

Helper function used to cache the language negotiation providers results.

Parameters
$provider_id | The language negotiation provider's identifier.
$provider | (optional) An associative array of information about the provider to be invoked (see hook_language_negotiation_info() for details). If not passed in, it will be loaded through language_negotiation_info().
Returns
A language object representing the language chosen by the provider.

Definition at line 427 of file language.inc.

References $results, DRUPAL_ROOT, drupal_static(), language_list(), language_negotiation_info(), and variable_get().

Referenced by language_initialize().

language_provider_weight ( $provider )

Returns the passed language negotiation provider weight or a default value.

Parameters
$provider A language negotiation provider data structure.
Returns
A numeric weight.

Definition at line 470 of file language.inc.

Referenced by _locale_languages_configure_form_language_table(), and language_negotiation_set().

language_types_configurable ( $stored = TRUE )

Returns only the configurable language types.

A language type maybe configurable or fixed. A fixed language type is a type whose language negotiation providers are module-defined and not altered through the user interface.

Parameters
$stored Optional. By default retrieves values from the 'language_types' variable to avoid unnecessary hook invocations. If set to FALSE retrieves values from the actual language type definitions. This allows to react to alterations performed on the definitions by modules installed after the 'language_types' variable is set.
Returns
An array of language type names.

Definition at line 139 of file language.inc.

References $info, drupal_language_types(), drupal_static(), language_types_info(), and variable_get().

Referenced by drupal_render_cid_parts(), language_negotiation_get_any(), language_negotiation_set(), locale_block_info(), locale_languages_configure_form(), and locale_url_outbound_alter().

language_types_disable ( $types )

Disables the given language types.

Parameters
$types An array of language types.

Definition at line 166 of file language.inc.

References drupal_language_types(), variable_get(), and variable_set().

language_types_info ( )

Returns all the defined language types.

Returns
An array of language type names. The name will be used as the global variable name the language value will be stored in.

Definition at line 110 of file language.inc.

References drupal_alter(), drupal_static(), and module_invoke_all().

Referenced by language_negotiation_purge(), language_types_configurable(), language_types_set(), locale_block_info(), locale_languages_configure_form(), and locale_update_7002().

language_types_set ( )

Updates the language type configuration.

Definition at line 179 of file language.inc.

References $info, drupal_static_reset(), language_negotiation_info(), language_negotiation_set(), language_types_info(), and variable_set().

Referenced by locale_languages_configure_form_submit(), and locale_modules_enabled().

language_url_split_prefix | ( | $path,
 |  | $languages
 | ) |

Splits the given path into prefix and actual path.

Parse the given path and return the language object identified by the prefix and the actual path.

Parameters
$path | The path to split.
$languages | An array of valid languages.
Returns
An array composed of:
  • A language object corresponding to the identified prefix on success, FALSE otherwise.
  • The path without the prefix on success, the given path otherwise.

Definition at line 530 of file language.inc.

Referenced by locale_language_from_url().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Language negotiation options

Functions
Language negotiation options

Functions

locale_language_from_interface ()
locale_language_from_browser ($languages)
locale_language_from_user ($languages)
locale_language_from_session ($languages)
locale_language_from_url ($languages)
locale_language_url_fallback ($language=NULL, $language_type=LANGUAGE_TYPE_INTERFACE)
locale_language_switcher_url ($type, $path)
locale_language_switcher_session ($type, $path)
locale_language_url_rewrite_url (&$path, &$options)
locale_language_url_rewrite_session (&$path, &$options)

Detailed Description

Functions for language negotiation.

There are functions that provide the ability to identify the language. This behavior can be controlled by various options.

Function Documentation

locale_language_from_browser ( $languages )

Identify language from the Accept-language HTTP header we got.

We perform browser accept-language parsing only if page cache is disabled, otherwise we would cache a user-specific preference.

Parameters
$languages An array of language objects for enabled languages ordered by weight.
Returns
A valid language code on success, FALSE otherwise.

Definition at line 131 of file locale.inc.

locale_language_from_interface ( )

Identifies the language from the current interface language.

Returns
The current interface language code.

Definition at line 114 of file locale.inc.

locale_language_from_session ( $languages )

Identify language from a request/session parameter.

Parameters
$languages An array of valid language objects.
Returns
A valid language code on success, FALSE otherwise.

Definition at line 234 of file locale.inc.

References variable_get().

locale_language_from_url ( $languages )

Identify language via URL prefix or domain.

Parameters
$languages An array of valid language objects.
Returns
A valid language code on success, FALSE otherwise.

Definition at line 264 of file locale.inc.

References language_negotiation_get_any(), language_url_split_prefix(), LOCALE_LANGUAGE_NEGOTIATION_URL, LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN, LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX, and variable_get().

locale_language_from_user ( $languages )

Identify language from the user preferences.

Parameters
$languages An array of valid language objects.
Returns
A valid language code on success, FALSE otherwise.

Definition at line 213 of file locale.inc.

locale_language_switcher_session | ( | $type,
 |  | $path
 | ) |

Return the session language switcher block.

Definition at line 377 of file locale.inc.

References $links, drupal_add_css(), drupal_get_path(), language_list(), and variable_get().

locale_language_switcher_url | ( | $type,
 |  | $path
 | ) |

Return the URL language switcher block. Translation links may be provided by other modules.

Definition at line 358 of file locale.inc.

References $links, and language_list().

locale_language_url_fallback | ( | $language = NULL,
 |  | $language_type = LANGUAGE_TYPE_INTERFACE
 | ) |

Determines the language to be assigned to URLs when none is detected.

The language negotiation process has a fallback chain that ends with the default language provider. Each built-in language type has a separate initialization:

  • Interface language, which is the only configurable one, always gets a valid value. If no request-specific language is detected, the default language will be used.
  • Content language merely inherits the interface language by default.
  • URL language is detected from the requested URL and will be used to rewrite URLs appearing in the page being rendered. If no language can be detected, there are two possibilities:
    • If the default language has no configured path prefix or domain, then the default language is used. This guarantees that (missing) URL prefixes are preserved when navigating through the site.
    • If the default language has a configured path prefix or domain, a requested URL having an empty prefix or domain is an anomaly that must be fixed. This is done by introducing a prefix or domain in the rendered page matching the detected interface language.
Parameters
$languages | (optional) An array of valid language objects. This is passed by language_provider_invoke() to every language provider callback, but it is not actually needed here. Defaults to NULL.
$language_type | (optional) The language type to fall back to. Defaults to the interface language.
Returns
A valid language code.

Definition at line 339 of file locale.inc.

References language_default(), LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX, and variable_get().

locale_language_url_rewrite_session | ( | & | $path,
 |  | & | $options
 | ) |  |

Rewrite URLs for the Session language provider.

Definition at line 475 of file locale.inc.

References check_plain(), drupal_get_query_array(), language_list(), language_negotiation_get_any(), LOCALE_LANGUAGE_NEGOTIATION_SESSION, and variable_get().

locale_language_url_rewrite_url | ( | & | $path,
 |  | & | $options
 | ) |  |

Rewrite URLs for the URL language provider.

Definition at line 411 of file locale.inc.

References drupal_static(), language, language_list(), LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN, LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX, and variable_get().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Language addition API

Functions
Language addition API

Functions

locale_add_language ($langcode, $name=NULL, $native=NULL, $direction=LANGUAGE_LTR, $domain= '', $prefix= '', $enabled=TRUE, $default=FALSE)

Detailed Description

Add a language.

The language addition API is used to create languages and store them.

Function Documentation

locale_add_language | ( | $langcode,
 |  | $name = NULL,
 |  | $native = NULL,
 |  | $direction = LANGUAGE_LTR,
 |  | $domain = '',
 |  | $prefix = '',
 |  | $enabled = TRUE,
 |  | $default = FALSE
 | ) |

API function to add a language.

Parameters
$langcode | Language code.
$name | English name of the language
$native | Native name of the language
$direction | LANGUAGE_LTR or LANGUAGE_RTL
$domain | Optional custom domain name with protocol, without trailing slash (eg. http://de.example.com).
$prefix | Optional path prefix for the language. Defaults to the language code if omitted.
$enabled | Optionally TRUE to enable the language when created or FALSE to disable.
$default | Optionally set this language to be the default.

Definition at line 559 of file locale.inc.

References $name, _locale_get_predefined_list(), _locale_invalidate_js(), db_insert(), DRUPAL_ROOT, drupal_static_reset(), LANGUAGE_LTR, module_invoke_all(), variable_get(), variable_set(), and watchdog().

Referenced by install_import_locales(), locale_languages_predefined_form_submit(), and locale_translate_import_form_submit().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Translation import/export API.

Functions
Translation import/export API.

Functions

_locale_import_po ($file, $langcode, $mode, $group=NULL)
_locale_import_read_po ($op, $file, $mode=NULL, $lang=NULL, $group= 'default')
_locale_import_message ($message, $file, $lineno=NULL)
_locale_import_one_string ($op, $value=NULL, $mode=NULL, $lang=NULL, $file=NULL, $group= 'default')
_locale_import_one_string_db (&$report, $langcode, $context, $source, $translation, $textgroup, $location, $mode, $plid=0, $plural=0)
_locale_import_parse_header ($header)
_locale_import_parse_plural_forms ($pluralforms, $filepath)
_locale_import_parse_arithmetic ($string)
_locale_import_tokenize_formula ($formula)
_locale_import_append_plural ($entry, $key)
_locale_import_shorten_comments ($comment)
_locale_import_parse_quoted ($string)
_locale_export_get_strings ($language=NULL, $group= 'default')
_locale_export_po_generate ($language=NULL, $strings=array(), $header=NULL)
_locale_export_po ($language=NULL, $output=NULL)
_locale_export_string ($str)
_locale_export_wrap ($str, $len)
_locale_export_remove_plural ($entry)

Detailed Description

End of "locale-api-add"

Functions to import and export translations.

These functions provide the ability to import translations from external files and to export translations and translation templates.

Function Documentation

_locale_export_get_strings | ( | $language = NULL,
 |  | $group = 'default'
 | ) |

Generates a structured array of all strings with translations in $language, if given. This array can be used to generate an export of the string in the database.

Parameters
$language | Language object to generate the output for, or NULL if generating translation template.
$group | Text group to export PO file from (eg. 'default' for interface translations).

Definition at line 1613 of file locale.inc.

References db_query().

Referenced by locale_translate_export_po_form_submit().

_locale_export_po | ( | $language = NULL,
 |  | $output = NULL
 | ) |

Write a generated PO or POT file to the output.

Parameters
$language | Language object to generate the output for, or NULL if generating translation template.
$output | The PO(T) file to output as a string. See _locale_export_generate_po() on how it can be generated.

Definition at line 1746 of file locale.inc.

References $output, drupal_exit(), print, and watchdog().

Referenced by locale_translate_export_po_form_submit().

_locale_export_po_generate | ( | $language = NULL,
 |  | $strings = array(),
 |  | $header = NULL
 | ) |

Generates the PO(T) file contents for given strings.

Parameters
$language | Language object to generate the output for, or NULL if generating translation template.
$strings | Array of strings to export. See _locale_export_get_strings() on how it should be formatted.
$header | The header portion to use for the output file. Defaults are provided for PO and POT files.

Definition at line 1654 of file locale.inc.

References $header, $output, _locale_export_remove_plural(), _locale_export_string(), and variable_get().

Referenced by locale_translate_export_po_form_submit().

_locale_export_remove_plural ( $entry )

Removes plural index information from a string

Definition at line 1830 of file locale.inc.

Referenced by _locale_export_po_generate().

_locale_export_string ( $str )

Print out a string on multiple lines

Definition at line 1766 of file locale.inc.

References _locale_export_wrap().

Referenced by _locale_export_po_generate().

_locale_export_wrap | ( | $str,
 |  | $len
 | ) |

Custom word wrapping for Portable Object (Template) files.

Definition at line 1802 of file locale.inc.

Referenced by _locale_export_string().

_locale_import_append_plural | ( | $entry,
 |  | $key
 | ) |

Modify a string to contain proper count indices

This is a callback function used via array_map()

Parameters
$entry | An array element.
$key | Index of the array element.

Definition at line 1413 of file locale.inc.

_locale_import_message | ( | $message,
 |  | $file,
 |  | $lineno = NULL
 | ) |

Sets an error message occurred during locale file parsing.

Parameters
$message | The message to be translated.
$file | Drupal file object corresponding to the PO file to import.
$lineno | An optional line number argument.

Definition at line 948 of file locale.inc.

References drupal_set_message(), and get_t().

Referenced by _locale_import_read_po().

_locale_import_one_string | ( | $op,
 |  | $value = NULL,
 |  | $mode = NULL,
 |  | $lang = NULL,
 |  | $file = NULL,
 |  | $group = 'default'
 | ) |

Imports a string into the database

Parameters
$op | Operation to perform: 'db-store', 'db-report', 'mem-store' or 'mem-report'.
$value | Details of the string stored.
$mode | Should existing translations be replaced LOCALE_IMPORT_KEEP or LOCALE_IMPORT_OVERWRITE.
$lang | Language to store the string in.
$file | Object representation of file being imported, only required when op is 'db-store'.
$group | Text group to import PO file into (eg. 'default' for interface translations).

Definition at line 976 of file locale.inc.

References $header, $op, $value, _locale_import_one_string_db(), _locale_import_parse_header(), _locale_import_parse_plural_forms(), _locale_import_shorten_comments(), db_update(), drupal_static(), language_list(), and LOCALE_IMPORT_KEEP.

Referenced by _locale_import_po(), _locale_import_read_po(), and st().

_locale_import_one_string_db | ( | & | $report,
 |  |  | $langcode,
 |  |  | $context,
 |  |  | $source,
 |  |  | $translation,
 |  |  | $textgroup,
 |  |  | $location,
 |  |  | $mode,
 |  |  | $plid = 0,
 |  |  | $plural = 0
 | ) |  |

Import one string into the database.

Parameters
$report | Report array summarizing the number of changes done in the form: array(inserts, updates, deletes).
$langcode | Language code to import string into.
$context | The context of this string.
$source | Source string.
$translation | Translation to language specified in $langcode.
$textgroup | Name of textgroup to store translation in.
$location | Location value to save with source string.
$mode | Import mode to use, LOCALE_IMPORT_KEEP or LOCALE_IMPORT_OVERWRITE.
$plid | Optional plural ID to use.
$plural | Optional plural value to use.
Returns
The string ID of the existing string modified or the new string added.

Definition at line 1080 of file locale.inc.

References db_delete(), db_insert(), db_query(), db_update(), LOCALE_IMPORT_OVERWRITE, and locale_string_is_safe().

Referenced by _locale_import_one_string().

_locale_import_parse_arithmetic ( $string )

Parses and sanitizes an arithmetic formula into a PHP expression

While parsing, we ensure, that the operators have the right precedence and associativity.

Parameters
$string A string containing the arithmetic formula.
Returns
The PHP version of the formula.

Definition at line 1247 of file locale.inc.

References $op, and _locale_import_tokenize_formula().

Referenced by _locale_import_parse_plural_forms().

_locale_import_parse_header ( $header )

Parses a Gettext Portable Object file header

Parameters
$header A string containing the complete header.
Returns
An associative array of key-value pairs.

Definition at line 1179 of file locale.inc.

References $contents, and $header.

Referenced by _locale_import_one_string().

_locale_import_parse_plural_forms | ( | $pluralforms,
 |  | $filepath
 | ) |

Parses a Plural-Forms entry from a Gettext Portable Object file header

Parameters
$pluralforms | A string containing the Plural-Forms entry.
$filepath | A string containing the filepath.
Returns
An array containing the number of plurals and a formula in PHP for computing the plural form.

Definition at line 1203 of file locale.inc.

References _locale_import_parse_arithmetic(), drupal_set_message(), and t().

Referenced by _locale_import_one_string().

_locale_import_parse_quoted ( $string )

Parses a string in quotes

Parameters
$string A string specified with enclosing quotes.
Returns
The string parsed from inside the quotes.

Definition at line 1456 of file locale.inc.

Referenced by _locale_import_read_po().

_locale_import_po | ( | $file,
 |  | $langcode,
 |  | $mode,
 |  | $group = NULL
 | ) |

Parses Gettext Portable Object file information and inserts into database

Parameters
$file | Drupal file object corresponding to the PO file to import.
$langcode | Language code.
$mode | Should existing translations be replaced LOCALE_IMPORT_KEEP or LOCALE_IMPORT_OVERWRITE.
$group | Text group to import PO file into (eg. 'default' for interface translations).

Definition at line 633 of file locale.inc.

References _locale_import_one_string(), _locale_import_read_po(), _locale_invalidate_js(), cache_clear_all(), db_query(), drupal_set_message(), drupal_set_time_limit(), format_plural(), menu_rebuild(), t(), watchdog(), and WATCHDOG_WARNING.

Referenced by locale_translate_import_form_submit().

_locale_import_read_po | ( | $op,
 |  | $file,
 |  | $mode = NULL,
 |  | $lang = NULL,
 |  | $group = 'default'
 | ) |

Parses Gettext Portable Object file into an array

Parameters
$op | Storage operation type: db-store or mem-store.
$file | Drupal file object corresponding to the PO file to import.
$mode | Should existing translations be replaced LOCALE_IMPORT_KEEP or LOCALE_IMPORT_OVERWRITE.
$lang | Language code.
$group | Text group to import PO file into (eg. 'default' for interface translations).

Definition at line 690 of file locale.inc.

References $op, _locale_import_message(), _locale_import_one_string(), and _locale_import_parse_quoted().

Referenced by _locale_batch_import(), _locale_import_po(), and st().

_locale_import_shorten_comments ( $comment )

Generate a short, one string version of the passed comment array

Parameters
$comment An array of strings containing a comment.
Returns
Short one string version of the comment.

Definition at line 1433 of file locale.inc.

Referenced by _locale_import_one_string().

_locale_import_tokenize_formula ( $formula )

Backward compatible implementation of token_get_all() for formula parsing

Parameters
$string A string containing the arithmetic formula.
Returns
The PHP version of the formula.

Definition at line 1347 of file locale.inc.

Referenced by _locale_import_parse_arithmetic().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Translation search API

Functions
Translation search API

Functions

_locale_translate_seek ()
_locale_translate_seek_query ()
_locale_invalidate_js ($langcode=NULL)
_locale_rebuild_js ($langcode=NULL)
_locale_translate_language_list ($translation, $limit_language)

Detailed Description

End of "locale-api-import-export"

Functions to search in translation files.

These functions provide the functionality to search for specific translations.

Function Documentation

_locale_invalidate_js ( $langcode = NULL )

Force the JavaScript translation file(s) to be refreshed.

This function sets a refresh flag for a specified language, or all languages except English, if none specified. JavaScript translation files are rebuilt (with locale_update_js_files()) the next time a request is served in that language.

Parameters
$langcode The language code for which the file needs to be refreshed.
Returns
New content of the 'javascript_parsed' variable.

Definition at line 1977 of file locale.inc.

References language_list(), variable_get(), and variable_set().

Referenced by _locale_import_po(), locale_add_language(), locale_js_alter(), locale_translate_delete_form_submit(), and locale_translate_edit_form_submit().

_locale_rebuild_js ( $langcode = NULL )

(Re-)Creates the JavaScript translation file for a language.

Parameters
$language The language, the translation file should be (re)created for.

Definition at line 2003 of file locale.inc.

References $dir, db_query(), db_update(), drupal_hash_base64(), drupal_json_encode(), FILE_CREATE_DIRECTORY, file_prepare_directory(), file_unmanaged_delete(), file_unmanaged_save_data(), language_default(), language_list(), t(), variable_get(), variable_set(), watchdog(), WATCHDOG_ERROR, and WATCHDOG_WARNING.

Referenced by locale_js_alter(), and locale_languages_delete_form_submit().

_locale_translate_language_list | ( | $translation,
 |  | $limit_language
 | ) |

List languages in search result table

Definition at line 2129 of file locale.inc.

References $output, drupal_add_css(), drupal_get_path(), and language_list().

Referenced by _locale_translate_seek().

_locale_translate_seek ( )

Perform a string search and display results in a table

Definition at line 1849 of file locale.inc.

References $header, $output, _locale_translate_language_list(), _locale_translate_seek_query(), check_plain(), db_and(), db_like(), db_or(), db_select(), drupal_get_destination(), l(), module_invoke_all(), t(), theme(), and truncate_utf8().

Referenced by locale_translate_seek_screen().

_locale_translate_seek_query ( )

Build array out of search criteria specified in request variables

Definition at line 1949 of file locale.inc.

References drupal_static().

Referenced by _locale_translate_seek().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: List of predefined languages

Functions
List of predefined languages

Functions

_locale_prepare_predefined_list ()
_locale_get_predefined_list ()

Detailed Description

End of "locale-api-seek"

API to provide a list of predefined languages.

Function Documentation

_locale_get_predefined_list ( )

Some of the common languages with their English and native names

Based on ISO 639 and http://people.w3.org/rishida/names/languages.html

Definition at line 291 of file iso.inc.

References LANGUAGE_RTL.

Referenced by _locale_prepare_predefined_list(), install_import_locales(), install_select_locale_form(), locale_add_language(), locale_languages_predefined_form_submit(), locale_languages_predefined_form_validate(), and locale_translate_import_form_submit().

_locale_prepare_predefined_list ( )

Prepares the language code list for a select form item with only the unsupported ones

Definition at line 2157 of file locale.inc.

References $value, _locale_get_predefined_list(), DRUPAL_ROOT, language_list(), and t().

Referenced by locale_languages_predefined_form(), and locale_translate_import_form().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Automatic interface translation import

Functions
Automatic interface translation import

Functions

locale_batch_by_language ($langcode, $finished=NULL, $skip=array())
locale_batch_by_component ($components, $finished= '_locale_batch_system_finished')
_locale_batch_build ($files, $finished=NULL, $components=array())
_locale_batch_import ($filepath, &$context)
_locale_batch_system_finished ($success, $results)
_locale_batch_language_finished ($success, $results)

Detailed Description

End of "locale-api-languages-predefined"

Functions to create batches for importing translations.

These functions can be used to import translations for installed modules.

Function Documentation

_locale_batch_build | ( | $files,
 |  | $finished = NULL,
 |  | $components = array()
 | ) |

Build a locale batch from an array of files.

Parameters
$files | Array of files to import.
$finished | Optional finished callback for the batch.
$components | Optional list of component names the batch covers. Used in the installer.
Returns
A batch structure.

Definition at line 2277 of file locale.inc.

References get_t().

Referenced by locale_batch_by_component(), and locale_batch_by_language().

_locale_batch_import | ( |  | $filepath,
 |  | & | $context
 | ) |  |

Perform interface translation import as a batch step.

Parameters
$filepath | Path to a file to import.
$results | Contains a list of files imported.

Definition at line 2311 of file locale.inc.

References _locale_import_read_po(), drupal_basename(), and LOCALE_IMPORT_KEEP.

_locale_batch_language_finished | ( | $success,
 |  | $results
 | ) |

Finished callback of language addition locale import batch. Inform the user of translation files imported.

Definition at line 2335 of file locale.inc.

References $results, drupal_set_message(), and format_plural().

_locale_batch_system_finished | ( | $success,
 |  | $results
 | ) |

Finished callback of system page locale import batch. Inform the user of translation files imported.

Definition at line 2325 of file locale.inc.

References $results, drupal_set_message(), and format_plural().

locale_batch_by_component | ( | $components,
 |  | $finished = '_locale_batch_system_finished'
 | ) |

Prepare a batch to run when installing modules or enabling themes.

This batch will import translations for the newly added components in all the languages already set up on the site.

Parameters
$components | An array of component (theme and/or module) names to import translations for.
$finished | Optional finished callback for the batch.

Definition at line 2242 of file locale.inc.

References _locale_batch_build(), db_query(), file_scan_directory(), and language_list().

Referenced by locale_system_update().

locale_batch_by_language | ( | $langcode,
 |  | $finished = NULL,
 |  | $skip = array()
 | ) |

Prepare a batch to import translations for all enabled modules in a given language.

Parameters
$langcode | Language code to import translations for.
$finished | Optional finished callback for the batch.
$skip | Array of component names to skip. Used in the installer for the second pass import, when most components are already imported.
Returns
A batch structure or FALSE if no files found.

Definition at line 2207 of file locale.inc.

References _locale_batch_build(), db_select(), and file_scan_directory().

Referenced by install_import_locales(), install_import_locales_remaining(), and locale_languages_predefined_form_submit().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Locking mechanisms

Functions
Locking mechanisms

Functions

lock_initialize ()
_lock_id ()
lock_acquire ($name, $timeout=30.0)
lock_may_be_available ($name)
lock_wait ($name, $delay=30)
lock_release ($name)
lock_release_all ($lock_id=NULL)

Detailed Description

Functions to coordinate long-running operations across requests.

In most environments, multiple Drupal page requests (a.k.a. threads or processes) will execute in parallel. This leads to potential conflicts or race conditions when two requests execute the same code at the same time. A common example of this is a rebuild like menu_rebuild() where we invoke many hook implementations to get and process data from all active modules, and then delete the current data in the database to insert the new afterwards.

This is a cooperative, advisory lock system. Any long-running operation that could potentially be attempted in parallel by multiple requests should try to acquire a lock before proceeding. By obtaining a lock, one request notifies any other requests that a specific operation is in progress which must not be executed in parallel.

To use this API, pick a unique name for the lock. A sensible choice is the name of the function performing the operation. A very simple example use of this API:

* function mymodule_long_operation() {
* if (lock_acquire('mymodule_long_operation')) {
* // Do the long operation here.
* // ...
* lock_release('mymodule_long_operation');
* }
* }
*

If a function acquires a lock it should always release it when the operation is complete by calling lock_release(), as in the example.

A function that has acquired a lock may attempt to renew a lock (extend the duration of the lock) by calling lock_acquire() again during the operation. Failure to renew a lock is indicative that another request has acquired the lock, and that the current operation may need to be aborted.

If a function fails to acquire a lock it may either immediately return, or it may call lock_wait() if the rest of the current page request requires that the operation in question be complete. After lock_wait() returns, the function may again attempt to acquire the lock, or may simply allow the page request to proceed on the assumption that a parallel request completed the operation.

lock_acquire() and lock_wait() will automatically break (delete) a lock whose duration has exceeded the timeout specified when it was acquired.

Alternative implementations of this API (such as APC) may be substituted by setting the 'lock_inc' variable to an alternate include filepath. Since this is an API intended to support alternative implementations, code using this API should never rely upon specific implementation details (for example no code should look for or directly modify a lock in the {semaphore} table).

Function Documentation

_lock_id ( )

Helper function to get this request's unique id.

Definition at line 76 of file lock.inc.

References drupal_register_shutdown_function().

Referenced by lock_acquire(), lock_release(), and lock_release_all().

lock_acquire | ( | $name,
 |  | $timeout = 30.0
 | ) |

Acquire (or renew) a lock, but do not block if it fails.

Parameters
$name | The name of the lock.
$timeout | A number of seconds (float) before the lock expires (minimum of 0.001).
Returns
TRUE if the lock was acquired, FALSE if it failed.

Definition at line 102 of file lock.inc.

References $name, _lock_id(), db_insert(), db_update(), and lock_may_be_available().

Referenced by drupal_cron_run(), image_style_deliver(), locale(), menu_rebuild(), registry_update(), DrupalCacheArray\set(), and variable_initialize().

lock_initialize ( )

Initialize the locking system.

Definition at line 67 of file lock.inc.

Referenced by _drupal_bootstrap_variables().

lock_may_be_available ( $name )

Check if lock acquired by a different process may be available.

If an existing lock has expired, it is removed.

Parameters
$name The name of the lock.
Returns
TRUE if there is no lock or it was removed, FALSE otherwise.

Definition at line 166 of file lock.inc.

References $name, db_delete(), and db_query().

Referenced by lock_acquire(), and lock_wait().

lock_release ( $name )

Release a lock previously acquired by lock_acquire().

This will release the named lock if it is still held by the current request.

Parameters
$name The name of the lock.

Definition at line 247 of file lock.inc.

References $name, _lock_id(), and db_delete().

Referenced by drupal_cron_run(), image_style_deliver(), locale(), menu_rebuild(), registry_update(), DrupalCacheArray\set(), and variable_initialize().

lock_release_all ( $lock_id = NULL )

Release all previously acquired locks.

Definition at line 260 of file lock.inc.

References _lock_id(), and db_delete().

lock_wait | ( | $name,
 |  | $delay = 30
 | ) |

Wait for a lock to be available.

This function may be called in a request that fails to acquire a desired lock. This will block further execution until the lock is available or the specified delay in seconds is reached. This should not be used with locks that are acquired very frequently, since the lock is likely to be acquired again by a different request while waiting.

Parameters
$name | The name of the lock.
$delay | The maximum number of seconds to wait, as an integer.
Returns
TRUE if the lock holds, FALSE if it is available.

Definition at line 203 of file lock.inc.

References $name, and lock_may_be_available().

Referenced by menu_rebuild(), registry_update(), and variable_initialize().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Menu system

Modules | Functions | Variables
Menu system

Modules

Menu flags
Menu item types
Menu context types
Menu status codes
Menu tree parameters

Functions

menu_get_ancestors ($parts)
menu_unserialize ($data, $map)
menu_set_item ($path, $router_item)
menu_get_item ($path=NULL, $router_item=NULL)
menu_execute_active_handler ($path=NULL, $deliver=TRUE)
_menu_load_objects (&$item, &$map)
_menu_check_access (&$item, $map)
_menu_item_localize (&$item, $map, $link_translate=FALSE)
_menu_translate (&$router_item, $map, $to_arg=FALSE)
_menu_link_map_translate (&$map, $to_arg_functions)
menu_tail_to_arg ($arg, $map, $index)
menu_tail_load ($arg, &$map, $index)
_menu_link_translate (&$item, $translate=FALSE)
menu_get_object ($type= 'node', $position=1, $path=NULL)
menu_tree ($menu_name)
menu_tree_output ($tree)
menu_tree_all_data ($menu_name, $link=NULL, $max_depth=NULL)
menu_tree_set_path ($menu_name, $path=NULL)
menu_tree_get_path ($menu_name)
menu_tree_page_data ($menu_name, $max_depth=NULL, $only_active_trail=FALSE)
menu_build_tree ($menu_name, array $parameters=array())
_menu_build_tree ($menu_name, array $parameters=array())
menu_tree_collect_node_links (&$tree, &$node_links)
menu_tree_check_access (&$tree, $node_links=array())
_menu_tree_check_access (&$tree)
menu_tree_data (array $links, array $parents=array(), $depth=1)
_menu_tree_data (&$links, $parents, $depth)
template_preprocess_menu_tree (&$variables)
drupal_help_arg ($arg=array())
menu_get_active_help ()
menu_get_custom_theme ($initialize=FALSE)
menu_set_custom_theme ()
menu_get_names ()
menu_list_system_menus ()
menu_main_menu ()
menu_secondary_menu ()
menu_navigation_links ($menu_name, $level=0)
menu_local_tasks ($level=0)
menu_contextual_links ($module, $parent_path, $args)
menu_primary_local_tasks ()
menu_secondary_local_tasks ()
menu_local_actions ()
menu_tab_root_path ()
menu_local_tabs ()
menu_set_active_menu_names ($menu_names=NULL)
menu_get_active_menu_names ()
menu_set_active_item ($path)
menu_set_active_trail ($new_trail=NULL)
menu_link_get_preferred ($path=NULL, $selected_menu=NULL)
menu_get_active_trail ()
menu_get_active_breadcrumb ()
menu_get_active_title ()
menu_link_load ($mlid)
menu_cache_clear ($menu_name= 'navigation')
menu_cache_clear_all ()
menu_reset_static_cache ()
menu_rebuild ()
menu_router_build ()
_menu_router_cache ($new_menu=NULL)
menu_get_router ()
_menu_link_build ($item)
_menu_navigation_links_rebuild ($menu)
menu_links_clone ($links, $menu_name=NULL)
menu_load_links ($menu_name)
menu_delete_links ($menu_name)
menu_link_delete ($mlid, $path=NULL)
_menu_delete_item ($item, $force=FALSE)
menu_link_save (&$item, $existing_item=array(), $parent_candidates=array())
_menu_link_find_parent ($menu_link, $parent_candidates=array())
_menu_clear_page_cache ()
_menu_set_expanded_menus ()
_menu_find_router_path ($link_path)
menu_link_maintain ($module, $op, $link_path, $link_title)
menu_link_children_relative_depth ($item)
_menu_link_move_children ($item, $existing_item)
_menu_update_parental_status ($item, $exclude=FALSE)
_menu_link_parents_set (&$item, $parent)
_menu_router_build ($callbacks)
_menu_router_save ($menu, $masks)
_menu_site_is_offline ($check_only=FALSE)

Variables

const MENU_PREFERRED_LINK '1cf698d64d1aa4b83907cf6ed55db3a7f8e92c91'

Detailed Description

Define the navigation menus, and route page requests to code based on URLs.

The Drupal menu system drives both the navigation system from a user perspective and the callback system that Drupal uses to respond to URLs passed from the browser. For this reason, a good understanding of the menu system is fundamental to the creation of complex modules. As a note, this is related to, but separate from menu.module, which allows menus (which in this context are hierarchical lists of links) to be customized from the Drupal administrative interface.

Drupal's menu system follows a simple hierarchy defined by paths. Implementations of hook_menu() define menu items and assign them to paths (which should be unique). The menu system aggregates these items and determines the menu hierarchy from the paths. For example, if the paths defined were a, a/b, e, a/b/c/d, f/g, and a/b/h, the menu system would form the structure:

  • a
    • a/b
      • a/b/c/d
      • a/b/h
  • e
  • f/g Note that the number of elements in the path does not necessarily determine the depth of the menu item in the tree.

When responding to a page request, the menu system looks to see if the path requested by the browser is registered as a menu item with a callback. If not, the system searches up the menu tree for the most complete match with a callback it can find. If the path a/b/i is requested in the tree above, the callback for a/b would be used.

The found callback function is called with any arguments specified in the "page arguments" attribute of its menu item. The attribute must be an array. After these arguments, any remaining components of the path are appended as further arguments. In this way, the callback for a/b above could respond to a request for a/b/i differently than a request for a/b/j.

For an illustration of this process, see page_example.module.

Access to the callback functions is also protected by the menu system. The "access callback" with an optional "access arguments" of each menu item is called before the page callback proceeds. If this returns TRUE, then access is granted; if FALSE, then access is denied. Default local task menu items (see next paragraph) may omit this attribute to use the value provided by the parent item.

In the default Drupal interface, you will notice many links rendered as tabs. These are known in the menu system as "local tasks", and they are rendered as tabs by default, though other presentations are possible. Local tasks function just as other menu items in most respects. It is convention that the names of these tasks should be short verbs if possible. In addition, a "default" local task should be provided for each set. When visiting a local task's parent menu item, the default local task will be rendered as if it is selected; this provides for a normal tab user experience. This default task is special in that it links not to its provided path, but to its parent item's path instead. The default task's path is only used to place it appropriately in the menu hierarchy.

Everything described so far is stored in the menu_router table. The menu_links table holds the visible menu links. By default these are derived from the same hook_menu definitions, however you are free to add more with menu_link_save().

Function Documentation

_menu_build_tree | ( |  | $menu_name,
 |  | array | $parameters = array()
 | ) |  |

Builds a menu tree.

This function may be used build the data for a menu tree only, for example to further massage the data manually before further processing happens. menu_tree_check_access() needs to be invoked afterwards.

See Also
menu_build_tree()

Definition at line 1368 of file menu.inc.

References $links, $value, cache_get(), cache_set(), db_select(), drupal_static(), MENU_MAX_DEPTH, menu_tree_collect_node_links(), and menu_tree_data().

Referenced by menu_build_tree().

_menu_check_access | ( | & | $item,
 |  |  | $map
 | ) |  |

Checks access to a menu item using the access callback.

Parameters
$item | A menu router or menu link item
$map | An array of path arguments; for example, array('node', '5').
Returns
$item['access'] becomes TRUE if the item is accessible, FALSE otherwise.

Definition at line 620 of file menu.inc.

References menu_unserialize(), and user_access().

Referenced by _menu_link_translate(), and _menu_translate().

_menu_clear_page_cache ( )

Clears the page and block caches at most twice per page load.

Definition at line 3310 of file menu.inc.

References _menu_set_expanded_menus(), cache_clear_all(), drupal_register_shutdown_function(), and drupal_static().

Referenced by _menu_delete_item(), menu_link_save(), and menu_rebuild().

_menu_delete_item | ( | $item,
 |  | $force = FALSE
 | ) |

Deletes a single menu link.

Parameters
$item | Item to be deleted.
$force | Forces deletion. Internal use only, setting to TRUE is discouraged.
See Also
menu_link_delete()

Definition at line 3018 of file menu.inc.

References _menu_clear_page_cache(), _menu_update_parental_status(), db_delete(), db_query(), menu_cache_clear(), menu_link_load(), menu_link_save(), and module_invoke_all().

Referenced by _menu_navigation_links_rebuild(), menu_delete_links(), and menu_link_delete().

_menu_find_router_path ( $link_path )

Finds the router path which will serve this path.

Parameters
$link_path The path for we are looking up its router path.
Returns
A path from $menu keys or empty if $link_path points to a nonexisting place.

Definition at line 3347 of file menu.inc.

References _menu_router_cache(), db_select(), menu_get_ancestors(), and MENU_MAX_PARTS.

Referenced by _menu_navigation_links_rebuild(), and menu_link_save().

_menu_item_localize | ( | & | $item,
 |  |  | $map,
 |  |  | $link_translate = FALSE
 | ) |  |

Localizes the router item title using t() or another callback.

Translate the title and description to allow storage of English title strings in the database, yet display of them in the language required by the current user.

Parameters
$item | A menu router item or a menu link item.
$map | The path as an array with objects already replaced. E.g., for path node/123 $map would be array('node', $node) where $node is the node object for node 123.
$link_translate | TRUE if we are translating a menu link item; FALSE if we are translating a menu router item.
Returns
No return value. $item['title'] is localized according to $item['title_callback']. If an item's callback is check_plain(), $item['options']['html'] becomes TRUE. $item['description'] is translated using t(). When doing link translation and the $item['options']['attributes']['title'] (link title attribute) matches the description, it is translated as well.

Definition at line 668 of file menu.inc.

References menu_unserialize(), and t().

Referenced by _menu_link_translate(), and _menu_translate().

_menu_link_build ( $item )

Builds a link from a router item.

Definition at line 2795 of file menu.inc.

References MENU_SUGGESTED_ITEM, and MENU_VISIBLE_IN_TREE.

Referenced by _menu_navigation_links_rebuild(), and menu_reset_item().

_menu_link_find_parent | ( | $menu_link,
 |  | $parent_candidates = array()
 | ) |

Finds a possible parent for a given menu link.

Because the parent of a given link might not exist anymore in the database, we apply a set of heuristics to determine a proper parent:

  • use the passed parent link if specified and existing.
  • else, use the first existing link down the previous link hierarchy
  • else, for system menu links (derived from hook_menu()), reparent based on the path hierarchy.
Parameters
$menu_link | A menu link.
$parent_candidates | An array of menu links keyed by mlid.
Returns
A menu link structure of the possible parent or FALSE if no valid parent has been found.

Definition at line 3247 of file menu.inc.

References $depth, db_query(), and db_select().

Referenced by menu_link_save().

_menu_link_map_translate | ( | & | $map,
 |  |  | $to_arg_functions
 | ) |  |

Translates the path elements in the map using any to_arg helper function.

Parameters
$map | An array of path arguments; for example, array('node', '5').
$to_arg_functions | An array of helper functions; for example, array(2 => 'menu_tail_to_arg').
See Also
hook_menu()

Definition at line 810 of file menu.inc.

Referenced by _menu_link_translate(), and _menu_translate().

_menu_link_move_children | ( | $item,
 |  | $existing_item
 | ) |

Updates the children of a menu link that is being moved.

The menu name, parents (p1 - p6), and depth are updated for all children of the link, and the has_children status of the previous parent is updated.

Definition at line 3457 of file menu.inc.

References _menu_update_parental_status(), db_update(), and MENU_MAX_DEPTH.

Referenced by menu_link_save().

_menu_link_parents_set | ( | & | $item,
 |  |  | $parent
 | ) |  |

Sets the p1 through p9 values for a menu link being saved.

Definition at line 3527 of file menu.inc.

References MENU_MAX_DEPTH.

Referenced by menu_link_save().

_menu_link_translate | ( | & | $item,
 |  |  | $translate = FALSE
 | ) |  |

Provides menu link access control, translation, and argument handling.

This function is similar to _menu_translate(), but it also does link-specific preparation (such as always calling to_arg() functions).

Parameters
$item | A menu link.
$translate | (optional) Whether to try to translate a link containing dynamic path argument placeholders (%) based on the menu router item of the current path. Defaults to FALSE. Internally used for breadcrumbs.
Returns
Returns the map of path arguments with objects loaded as defined in the $item['load_functions']. $item['access'] becomes TRUE if the item is accessible, FALSE otherwise. $item['href'] is generated from link_path, possibly by to_arg functions. $item['title'] is generated from link_title, and may be localized. $item['options'] is unserialized; it is also changed within the call here to $item['localized_options'] by _menu_item_localize().

Definition at line 870 of file menu.inc.

References _menu_check_access(), _menu_item_localize(), _menu_link_map_translate(), _menu_load_objects(), drupal_alter(), and menu_get_item().

Referenced by _menu_tree_check_access(), book_link_load(), drupal_valid_path(), menu_link_load(), menu_set_active_trail(), system_admin_config_page(), system_admin_menu_block(), and system_get_module_admin_tasks().

_menu_load_objects | ( | & | $item,
 |  | & | $map
 | ) |  |

Loads objects into the map as defined in the $item['load_functions'].

Parameters
$item | A menu router or menu link item
$map | An array of path arguments; for example, array('node', '5').
Returns
Returns TRUE for success, FALSE if an object cannot be loaded. Names of object loading functions are placed in $item['load_functions']. Loaded objects are placed in $map[]; keys are the same as keys in the $item['load_functions'] array. $item['access'] is set to FALSE if an object cannot be loaded.

Definition at line 554 of file menu.inc.

References $value.

Referenced by _menu_link_translate(), and _menu_translate().

_menu_navigation_links_rebuild ( $menu )

Builds menu links for the items in the menu router.

Definition at line 2820 of file menu.inc.

References _menu_delete_item(), _menu_find_router_path(), _menu_link_build(), db_and(), db_or(), db_select(), db_update(), and menu_link_save().

Referenced by menu_rebuild().

_menu_router_build ( $callbacks )

Builds the router table based on the data from hook_menu().

Definition at line 3545 of file menu.inc.

References db_query(), drupal_get_path(), DRUPAL_PHP_FUNCTION_PATTERN, MENU_CONTEXT_PAGE, MENU_DEFAULT_LOCAL_TASK, MENU_IS_LOCAL_TASK, MENU_MAX_PARTS, MENU_NORMAL_ITEM, and MENU_VISIBLE_IN_BREADCRUMB.

Referenced by menu_router_build().

_menu_router_cache ( $new_menu = NULL )

Stores the menu router if we have it in memory.

Definition at line 2771 of file menu.inc.

References drupal_static().

Referenced by _menu_find_router_path(), menu_get_router(), and menu_router_build().

_menu_router_save | ( | $menu,
 |  | $masks
 | ) |

Saves data from menu_router_build() to the router table.

Definition at line 3772 of file menu.inc.

References db_insert(), db_truncate(), and variable_set().

Referenced by menu_rebuild().

_menu_set_expanded_menus ( )

Updates a list of menus with expanded items.

Definition at line 3332 of file menu.inc.

References db_query(), and variable_set().

Referenced by _menu_clear_page_cache().

_menu_site_is_offline ( $check_only = FALSE )

Checks whether the site is in maintenance mode.

This function will log the current user out and redirect to front page if the current user has no 'access site in maintenance mode' permission.

Parameters
$check_only If this is set to TRUE, the function will perform the access checks and return the site offline status, but not log the user out or display any messages.
Returns
FALSE if the site is not in maintenance mode, the user login page is displayed, or the user has the 'access site in maintenance mode' permission. TRUE for anonymous users not being on the login page when the site is in maintenance mode.

Definition at line 3866 of file menu.inc.

References drupal_set_message(), t(), url(), user_access(), and variable_get().

Referenced by menu_execute_active_handler(), and menu_get_custom_theme().

_menu_translate | ( | & | $router_item,
 |  |  | $map,
 |  |  | $to_arg = FALSE
 | ) |  |

Handles dynamic path translation and menu access control.

When a user arrives on a page such as node/5, this function determines what "5" corresponds to, by inspecting the page's menu path definition, node/node. This will call node_load(5) to load the corresponding node object.

It also works in reverse, to allow the display of tabs and menu items which contain these dynamic arguments, translating node/node to node/5.

Translation of menu item titles and descriptions are done here to allow for storage of English strings in the database, and translation to the language required to generate the current page.

Parameters
$router_item | A menu router item
$map | An array of path arguments; for example, array('node', '5').
$to_arg | Execute $item['to_arg_functions'] or not. Use only if you want to render a path from the menu table, for example tabs.
Returns
Returns the map with objects loaded as defined in the $item['load_functions']. $item['access'] becomes TRUE if the item is accessible, FALSE otherwise. $item['href'] is set according to the map. If an error occurs during calling the load_functions (like trying to load a non-existent node) then this function returns FALSE.

Definition at line 753 of file menu.inc.

References _menu_check_access(), _menu_item_localize(), _menu_link_map_translate(), and _menu_load_objects().

Referenced by menu_contextual_links(), menu_get_item(), menu_link_get_preferred(), and menu_local_tasks().

_menu_tree_check_access ( & $tree )

Sorts the menu tree and recursively checks access for each item.

Definition at line 1508 of file menu.inc.

References $tree, and _menu_link_translate().

Referenced by menu_tree_check_access().

_menu_tree_data | ( | & | $links,
 |  |  | $parents,
 |  |  | $depth
 | ) |  |

Builds the data representing a menu tree.

The function is a bit complex because the rendering of a link depends on the next menu link.

Definition at line 1566 of file menu.inc.

References $depth, and $tree.

Referenced by menu_tree_data().

_menu_update_parental_status | ( | $item,
 |  | $exclude = FALSE
 | ) |

Checks and updates the 'has_children' status for the parent of a link.

Definition at line 3503 of file menu.inc.

References db_select(), and db_update().

Referenced by _menu_delete_item(), _menu_link_move_children(), and menu_link_save().

drupal_help_arg ( $arg = array() )

Generates elements for the $arg array in the help hook.

Definition at line 1700 of file menu.inc.

Referenced by help_links_as_list(), help_page(), menu_get_active_help(), and system_modules().

menu_build_tree | ( |  | $menu_name,
 |  | array | $parameters = array()
 | ) |  |

Builds a menu tree, translates links, and checks access.

Parameters
$menu_name The name of the menu.
$parameters (optional) An associative array of build parameters. Possible keys:
  • expanded: An array of parent link ids to return only menu links that are children of one of the plids in this list. If empty, the whole menu tree is built, unless 'only_active_trail' is TRUE.
  • active_trail: An array of mlids, representing the coordinates of the currently active menu link.
  • only_active_trail: Whether to only return links that are in the active trail. This option is ignored, if 'expanded' is non-empty. Internally used for breadcrumbs.
  • min_depth: The minimum depth of menu links in the resulting tree. Defaults to 1, which is the default to build a whole tree for a menu (excluding menu container itself).
  • max_depth: The maximum depth of menu links in the resulting tree.
  • conditions: An associative array of custom database select query condition key/value pairs; see _menu_build_tree() for the actual query.
Returns
A fully built menu tree.

Definition at line 1351 of file menu.inc.

References _menu_build_tree(), and menu_tree_check_access().

Referenced by menu_tree_all_data(), menu_tree_page_data(), and toolbar_get_menu_tree().

menu_cache_clear ( $menu_name = 'navigation' )

Clears the cached cached data for a single named menu.

Definition at line 2656 of file menu.inc.

References cache_clear_all(), drupal_register_shutdown_function(), drupal_static(), and menu_reset_static_cache().

Referenced by _menu_delete_item(), and menu_link_save().

menu_cache_clear_all ( )

Clears all cached menu data.

This should be called any time broad changes might have been made to the router items or menu links.

Definition at line 2678 of file menu.inc.

References cache_clear_all(), and menu_reset_static_cache().

Referenced by book_uninstall(), menu_delete(), menu_enable(), menu_rebuild(), and menu_save().

menu_contextual_links | ( | $module,
 |  | $parent_path,
 |  | $args
 | ) |

Retrieves contextual links for a path based on registered local tasks.

This leverages the menu system to retrieve the first layer of registered local tasks for a given system path. All local tasks of the tab type MENU_CONTEXT_INLINE are taken into account.

For example, when considering the following registered local tasks:

  • node/node/view (default local task) with no 'context' defined
  • node/node/edit with context: MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE
  • node/node/revisions with context: MENU_CONTEXT_PAGE
  • node/node/report-as-spam with context: MENU_CONTEXT_INLINE

If the path "node/123" is passed to this function, then it will return the links for 'edit' and 'report-as-spam'.

Parameters
$module | The name of the implementing module. This is used to prefix the key for each contextual link, which is transformed into a CSS class during rendering by theme_links(). For example, if $module is 'block' and the retrieved local task path argument is 'edit', then the resulting CSS class will be 'block-edit'.
$parent_path | The static menu router path of the object to retrieve local tasks for, for example 'node' or 'admin/structure/block/manage'.
$args | A list of dynamic path arguments to append to $parent_path to form the fully-qualified menu router path; for example, array(123) for a certain node or array('system', 'navigation') for a certain block.
Returns
A list of menu router items that are local tasks for the passed-in path.
See Also
contextual_links_preprocess()
hook_menu()

Definition at line 2159 of file menu.inc.

References $links, $module, _menu_translate(), db_select(), drupal_alter(), drupal_static(), drupal_strlen(), drupal_substr(), MENU_CONTEXT_NONE, MENU_CONTEXT_PAGE, and menu_get_item().

Referenced by contextual_pre_render_links().

menu_delete_links ( $menu_name )

Deletes all links for a menu.

Parameters
$menu_name The name of the menu whose links will be deleted.

Definition at line 2976 of file menu.inc.

References _menu_delete_item(), and menu_load_links().

Referenced by menu_delete(), shortcut_set_delete(), and shortcut_uninstall().

menu_execute_active_handler | ( | $path = NULL,
 |  | $deliver = TRUE
 | ) |

Execute the page callback associated with the current path.

Parameters
$path | The drupal path whose handler is to be be executed. If set to NULL, then the current path is used.
$deliver | (optional) A boolean to indicate whether the content should be sent to the browser using the appropriate delivery callback (TRUE) or whether to return the result to the caller (FALSE).

Definition at line 500 of file menu.inc.

References _menu_site_is_offline(), drupal_alter(), drupal_deliver_page(), DRUPAL_ROOT, MENU_ACCESS_DENIED, menu_get_item(), MENU_NOT_FOUND, MENU_SITE_OFFLINE, and MENU_SITE_ONLINE.

Referenced by comment_permalink(), drupal_deliver_html_page(), and user_page().

menu_get_active_breadcrumb ( )

Gets the breadcrumb for the current page, as determined by the active trail.

See Also
menu_set_active_trail()

Definition at line 2562 of file menu.inc.

References $breadcrumb, drupal_alter(), drupal_is_front_page(), l(), menu_get_active_trail(), menu_get_item(), and MENU_LINKS_TO_PARENT.

Referenced by drupal_get_breadcrumb(), and menu_edit_item().

menu_get_active_help ( )

Returns the help associated with the active menu item.

Definition at line 1708 of file menu.inc.

References $help, $module, $output, arg(), drupal_help_arg(), menu_tab_root_path(), and module_implements().

Referenced by system_block_view().

menu_get_active_menu_names ( )

Gets the active menu for the current page.

Definition at line 2326 of file menu.inc.

References menu_set_active_menu_names().

Referenced by book_page_alter(), and menu_link_get_preferred().

menu_get_active_title ( )

Gets the title of the current page, as determined by the active trail.

Definition at line 2611 of file menu.inc.

References menu_get_active_trail(), and MENU_IS_LOCAL_TASK.

Referenced by drupal_get_title().

menu_get_active_trail ( )

Gets the active trail (path to root menu root) of the current page.

If a trail is supplied to menu_set_active_trail(), that value is returned. If a trail is not supplied to menu_set_active_trail(), the path to the current page is calculated and returned. The calculated trail is also saved as a static value for use by subsequent calls to menu_get_active_trail().

Returns
Path to menu root of the current page, as an array of menu link items, starting with the site's home page. Each link item is an associative array with the following components:
  • title: Title of the item.
  • href: Drupal path of the item.
  • localized_options: Options for passing into the l() function.
  • type: A menu type constant, such as MENU_DEFAULT_LOCAL_TASK, or 0 to indicate it's not really in the menu (used for the home page item).

Definition at line 2553 of file menu.inc.

References menu_set_active_trail().

Referenced by menu_get_active_breadcrumb(), menu_get_active_title(), and toolbar_in_active_trail().

menu_get_ancestors ( $parts )

Returns the ancestors (and relevant placeholders) for any given path.

For example, the ancestors of node/12345/edit are:

  • node/12345/edit
  • node/12345/%
  • node/%/edit
  • node/%/%
  • node/12345
  • node/%
  • node

To generate these, we will use binary numbers. Each bit represents a part of the path. If the bit is 1, then it represents the original value while 0 means wildcard. If the path is node/12/edit/foo then the 1011 bitstring represents node/%/edit/foo where % means that any argument matches that part. We limit ourselves to using binary numbers that correspond the patterns of wildcards of router items that actually exists. This list of 'masks' is built in menu_rebuild().

Parameters
$parts An array of path parts; for the above example, array('node', '12345', 'edit').
Returns
An array which contains the ancestors and placeholders. Placeholders simply contain as many 's' as the ancestors.

Definition at line 319 of file menu.inc.

References variable_get().

Referenced by _menu_find_router_path(), and menu_get_item().

menu_get_custom_theme ( $initialize = FALSE )

Gets the custom theme for the current page, if there is one.

Parameters
$initialize This parameter should only be used internally; it is set to TRUE in order to force the custom theme to be initialized for the current page request.
Returns
The machine-readable name of the custom theme, if there is one.
See Also
menu_set_custom_theme()

Definition at line 1740 of file menu.inc.

References _menu_site_is_offline(), drupal_static(), drupal_theme_access(), MAINTENANCE_MODE, menu_get_item(), and module_invoke_all().

Referenced by drupal_theme_initialize(), and menu_set_custom_theme().

menu_get_item | ( | $path = NULL,
 |  | $router_item = NULL
 | ) |

Gets a router item.

Parameters
$path | The path; for example, 'node/5'. The function will find the corresponding node/% item and return that.
$router_item | Internal use only.
Returns
The router item or, if an error occurs in _menu_translate(), FALSE. A router item is an associative array corresponding to one row in the menu_router table. The value corresponding to the key 'map' holds the loaded objects. The value corresponding to the key 'access' is TRUE if the current user can access this page. The values corresponding to the keys 'title', 'page_arguments', 'access_arguments', and 'theme_arguments' will be filled in based on the database values and the objects loaded.

Definition at line 447 of file menu.inc.

References _menu_translate(), arg(), db_query_range(), drupal_alter(), drupal_static(), menu_get_ancestors(), MENU_MAX_PARTS, menu_rebuild(), menu_unserialize(), and variable_get().

Referenced by _menu_link_translate(), block_page_build(), blog_menu_local_tasks_alter(), dashboard_is_visible(), drupal_deliver_page(), drupal_retrieve_form(), drupal_valid_path(), menu_contextual_links(), menu_execute_active_handler(), menu_get_active_breadcrumb(), menu_get_custom_theme(), menu_get_object(), menu_link_get_preferred(), menu_local_tasks(), menu_navigation_links(), menu_set_active_trail(), menu_set_item(), menu_tree_output(), menu_tree_page_data(), node_add_page(), node_menu_local_tasks_alter(), shortcut_link_add_inline(), shortcut_preprocess_page(), shortcut_valid_link(), system_admin_menu_block(), system_admin_menu_block_page(), system_get_module_admin_tasks(), system_modules(), and system_settings_overview().

menu_get_names ( )

Build a list of named menus.

Definition at line 1776 of file menu.inc.

References db_select(), and drupal_static().

Referenced by menu_update_7003().

menu_get_object | ( | $type = 'node',
 |  | $position = 1,
 |  | $path = NULL
 | ) |

Gets a loaded object from a router item.

menu_get_object() provides access to objects loaded by the current router item. For example, on the page node/node, the router loads the node object, and calling menu_get_object() will return that. Normally, it is necessary to specify the type of object referenced, however node is the default. The following example tests to see whether the node being displayed is of the "story" content type:

* $node = menu_get_object();
* $story = $node->type == 'story';
*
Parameters
$type | Type of the object. These appear in hook_menu definitions as type. Core provides aggregator_feed, aggregator_category, contact, filter_format, forum_term, menu, menu_link, node, taxonomy_vocabulary, user. See the relevant {$type}_load function for more on each. Defaults to node.
$position | The position of the object in the path, where the first path segment is 0. For node/node, the position of node is 1, but for comment/reply/node, it's 2. Defaults to 1.
$path | See menu_get_item() for more on this. Defaults to the current path.

Definition at line 971 of file menu.inc.

References menu_get_item().

Referenced by book_block_view(), book_page_alter(), hook_page_build(), node_block_list_alter(), node_is_page(), taxonomy_term_is_page(), template_preprocess_html(), and template_preprocess_page().

menu_get_router ( )

Gets the menu router.

Definition at line 2783 of file menu.inc.

References _menu_router_cache(), and menu_router_build().

Referenced by menu_reset_item().

menu_link_children_relative_depth ( $item )

Finds the depth of an item's children relative to its depth.

For example, if the item has a depth of 2, and the maximum of any child in the menu link tree is 5, the relative depth is 3.

Parameters
$item An array representing a menu link item.
Returns
The relative depth, or zero.

Definition at line 3432 of file menu.inc.

References db_select(), and MENU_MAX_DEPTH.

Referenced by _book_parent_depth_limit(), _menu_parent_depth_limit(), and menu_link_save().

menu_link_delete | ( | $mlid,
 |  | $path = NULL
 | ) |

Delete one or several menu links.

Parameters
$mlid | A valid menu link mlid or NULL. If NULL, $path is used.
$path | The path to the menu items to be deleted. $mlid must be NULL.

Definition at line 2996 of file menu.inc.

References _menu_delete_item(), and db_query().

Referenced by book_node_delete(), book_remove_form_submit(), menu_delete_menu_confirm_submit(), menu_item_delete_form_submit(), menu_link_maintain(), menu_node_delete(), menu_node_save(), and shortcut_link_delete_submit().

menu_link_get_preferred | ( | $path = NULL,
 |  | $selected_menu = NULL
 | ) |

Looks up the preferred menu link for a given system path.

Parameters
$path | The path; for example, 'node/5'. The function will find the corresponding menu link ('node/5' if it exists, or fallback to 'node/').
$selected_menu | The name of a menu used to restrict the search for a preferred menu link. If not specified, all the menus returned by menu_get_active_menu_names() will be used.
Returns
A fully translated menu link, or FALSE if no matching menu link was found. The most specific menu link ('node/5' preferred over 'node/') in the most preferred menu (as defined by menu_get_active_menu_names()) is returned.

Definition at line 2454 of file menu.inc.

References _menu_translate(), db_select(), drupal_static(), menu_get_active_menu_names(), menu_get_item(), and MENU_PREFERRED_LINK.

Referenced by menu_set_active_trail(), and menu_tree_page_data().

menu_link_load ( $mlid )

Gets a translated, access-checked menu link that is ready for rendering.

This function should never be called from within node_load() or any other function used as a menu object load function since an infinite recursion may occur.

Parameters
$mlid The mlid of the menu item.
Returns
A menu link, with $item['access'] filled and link translated for rendering.

Definition at line 2635 of file menu.inc.

References _menu_link_translate(), and db_select().

Referenced by _menu_delete_item(), menu_edit_menu_submit(), menu_node_prepare(), shortcut_set_customize_submit(), and system_get_module_admin_tasks().

menu_link_maintain | ( | $module,
 |  | $op,
 |  | $link_path,
 |  | $link_title
 | ) |

Inserts, updates, or deletes an uncustomized menu link related to a module.

Parameters
$module | The name of the module.
$op | Operation to perform: insert, update or delete.
$link_path | The path this link points to.
$link_title | Title of the link to insert or new title to update the link to. Unused for delete.
Returns
The insert op returns the mlid of the new item. Others op return NULL.

Definition at line 3395 of file menu.inc.

References $module, $op, db_query(), menu_link_delete(), and menu_link_save().

Referenced by aggregator_save_category().

menu_link_save | ( | & | $item,
 |  |  | $existing_item = array(),
 |  |  | $parent_candidates = array()
 | ) |  |

Saves a menu link.

After calling this function, rebuild the menu cache using menu_cache_clear_all().

Parameters
$item An associative array representing a menu link item, with elements:
  • link_path: (required) The path of the menu item, which should be normalized first by calling drupal_get_normal_path() on it.
  • link_title: (required) Title to appear in menu for the link.
  • menu_name: (optional) The machine name of the menu for the link. Defaults to 'navigation'.
  • weight: (optional) Integer to determine position in menu. Default is 0.
  • expanded: (optional) Boolean that determines if the item is expanded.
  • options: (optional) An array of options, see l() for more.
  • mlid: (optional) Menu link identifier, the primary integer key for each menu link. Can be set to an existing value, or to 0 or NULL to insert a new link.
  • plid: (optional) The mlid of the parent.
  • router_path: (optional) The path of the relevant router item.
$existing_item | Optional, the current record from the {menu_links} table as an array.
$parent_candidates | Optional array of menu links keyed by mlid. Used by _menu_navigation_links_rebuild() only.
Returns
The mlid of the saved menu link, or FALSE if the menu link could not be saved.

Definition at line 3074 of file menu.inc.

References _menu_clear_page_cache(), _menu_find_router_path(), _menu_link_find_parent(), _menu_link_move_children(), _menu_link_parents_set(), _menu_update_parental_status(), db_insert(), db_query(), db_update(), drupal_alter(), menu_cache_clear(), menu_link_children_relative_depth(), MENU_MAX_DEPTH, MENU_MAX_PARTS, module_invoke_all(), and url_is_external().

Referenced by _book_update_outline(), _menu_delete_item(), _menu_navigation_links_rebuild(), book_admin_edit_submit(), menu_edit_item_submit(), menu_edit_menu_submit(), menu_enable(), menu_link_maintain(), menu_node_save(), menu_overview_form_submit(), menu_reset_item(), shortcut_link_edit_submit(), shortcut_set_customize_submit(), shortcut_set_save(), and standard_install().

menu_links_clone | ( | $links,
 |  | $menu_name = NULL
 | ) |

Clones an array of menu links.

Parameters
$links | An array of menu links to clone.
$menu_name | (optional) The name of a menu that the links will be cloned for. If not set, the cloned links will be in the same menu as the original set of links that were passed in.
Returns
An array of menu links with the same properties as the passed-in array, but with the link identifiers removed so that a new link will be created when any of them is passed in to menu_link_save().
See Also
menu_link_save()

Definition at line 2934 of file menu.inc.

References $links.

Referenced by shortcut_set_add_form_submit(), and shortcut_set_switch_submit().

menu_list_system_menus ( )

Returns an array containing the names of system-defined (default) menus.

Definition at line 1792 of file menu.inc.

Referenced by menu_block_view_alter(), menu_delete_menu_confirm_submit(), menu_delete_menu_page(), menu_edit_menu(), menu_get_menus(), menu_install(), menu_set_active_menu_names(), menu_update_7003(), system_block_info(), system_block_view(), and system_preprocess_block().

menu_load_links ( $menu_name )

Returns an array containing all links for a menu.

Parameters
$menu_name The name of the menu whose links should be returned.
Returns
An array of menu links.

Definition at line 2954 of file menu.inc.

References $links, and db_select().

Referenced by menu_delete_links(), and shortcut_set_load().

menu_local_actions ( )

Returns the rendered local actions at the current level.

Definition at line 2245 of file menu.inc.

References menu_local_tasks().

Referenced by template_preprocess_page().

menu_local_tabs ( )

Returns a renderable element for the primary and secondary tabs.

Definition at line 2261 of file menu.inc.

References menu_primary_local_tasks(), and menu_secondary_local_tasks().

Referenced by template_preprocess_page().

menu_local_tasks ( $level = 0 )

Collects the local tasks (tabs), action links, and the root path.

Parameters
$level The level of tasks you ask for. Primary tasks are 0, secondary are 1.
Returns
An array containing
  • tabs: Local tasks for the requested level:
    • count: The number of local tasks.
    • output: The themed output of local tasks.
  • actions: Action links for the requested level:
    • count: The number of action links.
    • output: The themed output of action links.
  • root_path: The router path for the current page. If the current page is a default local task, then this corresponds to the parent tab.

Definition at line 1899 of file menu.inc.

References $children, $depth, _menu_translate(), cache_get(), cache_set(), db_select(), drupal_alter(), drupal_static(), MENU_CONTEXT_INLINE, menu_get_item(), MENU_IS_LOCAL_ACTION, MENU_IS_LOCAL_TASK, and MENU_LINKS_TO_PARENT.

Referenced by menu_local_actions(), menu_primary_local_tasks(), menu_secondary_local_tasks(), and menu_tab_root_path().

menu_main_menu ( )

Returns an array of links to be rendered as the Main menu.

Definition at line 1804 of file menu.inc.

References menu_navigation_links(), and variable_get().

Referenced by template_preprocess_page().

menu_navigation_links | ( | $menu_name,
 |  | $level = 0
 | ) |

Returns an array of links for a navigation menu.

Parameters
$menu_name | The name of the menu.
$level | Optional, the depth of the menu to be returned.
Returns
An array of links of the specified menu and level.

Definition at line 1834 of file menu.inc.

References $links, $tree, menu_get_item(), and menu_tree_page_data().

Referenced by menu_main_menu(), and menu_secondary_menu().

menu_primary_local_tasks ( )

Returns the rendered local tasks at the top level.

Definition at line 2227 of file menu.inc.

References menu_local_tasks().

Referenced by menu_local_tabs(), and template_preprocess_overlay().

menu_rebuild ( )

Populates the database tables used by various menu functions.

This function will clear and populate the {menu_router} table, add entries to {menu_links} for new router items, and then remove stale items from {menu_links}. If called from update.php or install.php, it will also schedule a call to itself on the first real page load from menu_execute_active_handler(), because the maintenance page environment is different and leaves stale data in the menu tables.

Returns
TRUE if the menu was rebuilt, FALSE if another thread was rebuilding in parallel and the current thread just waited for completion.

Definition at line 2709 of file menu.inc.

References _menu_clear_page_cache(), _menu_navigation_links_rebuild(), _menu_router_save(), db_transaction(), lock_acquire(), lock_release(), lock_wait(), menu_cache_clear_all(), menu_router_build(), variable_del(), variable_set(), and watchdog_exception().

Referenced by _locale_import_po(), drupal_flush_all_caches(), DrupalWebTestCase\drupalCreateContentType(), field_ui_field_attach_rename_bundle(), install_configure_form(), menu_enable(), menu_get_item(), menu_uninstall(), node_type_delete_confirm_submit(), node_type_form_submit(), profile_admin_overview_submit(), profile_field_form_submit(), shortcut_install(), standard_install(), system_theme_default(), theme_disable(), and theme_enable().

menu_reset_static_cache ( )

Resets the menu system static cache.

Definition at line 2686 of file menu.inc.

References drupal_static_reset().

Referenced by menu_cache_clear(), menu_cache_clear_all(), and system_flush_caches().

menu_router_build ( )

Collects and alters the menu definitions.

Definition at line 2747 of file menu.inc.

References $module, _menu_router_build(), _menu_router_cache(), drupal_alter(), and module_implements().

Referenced by menu_get_router(), and menu_rebuild().

menu_secondary_local_tasks ( )

Returns the rendered local tasks at the second level.

Definition at line 2236 of file menu.inc.

References menu_local_tasks().

Referenced by menu_local_tabs().

menu_secondary_menu ( )

Returns an array of links to be rendered as the Secondary links.

Definition at line 1811 of file menu.inc.

References menu_navigation_links(), and variable_get().

Referenced by template_preprocess_page().

menu_set_active_item ( $path )

Sets the active path, which determines which page is loaded.

Note that this may not have the desired effect unless invoked very early in the page load, such as during hook_boot(), or unless you call menu_execute_active_handler() to generate your page output.

Parameters
$path A Drupal path - not a path alias.

Definition at line 2340 of file menu.inc.

References drupal_static_reset().

Referenced by drupal_deliver_html_page(), and user_page().

menu_set_active_menu_names ( $menu_names = NULL )

Sets (or gets) the active menu for the current page.

The active menu for the page determines the active trail.

Returns
An array of menu machine names, in order of preference. The 'menu_default_active_menus' variable may be used to assert a menu order different from the order of creation, or to prevent a particular menu from being used at all in the active trail. E.g., $conf['menu_default_active_menus'] = array('navigation', 'main-menu')

Definition at line 2311 of file menu.inc.

References drupal_static(), menu_list_system_menus(), and variable_get().

Referenced by book_page_alter(), and menu_get_active_menu_names().

menu_set_active_trail ( $new_trail = NULL )

Sets the active trail (path to the menu tree root) of the current page.

Any trail set by this function will only be used for functionality that calls menu_get_active_trail(). Drupal core only uses trails set here for breadcrumbs and the page title and not for menu trees or page content. Additionally, breadcrumbs set by drupal_set_breadcrumb() will override any trail set here.

To affect the trail used by menu trees, use menu_tree_set_path(). To affect the page content, use menu_set_active_item() instead.

Parameters
$new_trail Menu trail to set; the value is saved in a static variable and can be retrieved by menu_get_active_trail(). The format of this array should be the same as the return value of menu_get_active_trail().
Returns
The active trail. See menu_get_active_trail() for details.

Definition at line 2367 of file menu.inc.

References $tree, _menu_link_translate(), drupal_is_front_page(), drupal_static(), menu_get_item(), menu_link_get_preferred(), MENU_LINKS_TO_PARENT, menu_tree_page_data(), and t().

Referenced by menu_get_active_trail().

menu_set_custom_theme ( )

Sets a custom theme for the current page, if there is one.

Definition at line 1769 of file menu.inc.

References menu_get_custom_theme().

Referenced by _drupal_bootstrap_full().

menu_set_item | ( | $path,
 |  | $router_item
 | ) |

Replaces the statically cached item for a given path.

Parameters
$path | The path.
$router_item | The router item. Usually a router entry from menu_get_item() is either modified or set to a different path. This allows the navigation block, the page title, the breadcrumb, and the page help to be modified in one call.

Definition at line 425 of file menu.inc.

References menu_get_item().

menu_tab_root_path ( )

Returns the router path, or the path for a default local task's parent.

Definition at line 2253 of file menu.inc.

References menu_local_tasks().

Referenced by menu_get_active_help().

menu_tail_load | ( |  | $arg,
 |  | & | $map,
 |  |  | $index
 | ) |  |

Loads the path as one string relative to the current index.

To use this load function, you must specify the load arguments in the router item as:

* $item['load arguments'] = array('%map', '%index');
*
See Also
search_menu().

Definition at line 842 of file menu.inc.

menu_tail_to_arg | ( | $arg,
 |  | $map,
 |  | $index
 | ) |

Returns a string containing the path relative to the current index.

Definition at line 827 of file menu.inc.

menu_tree ( $menu_name )

Renders a menu tree based on the current path.

The tree is expanded based on the current path and dynamic paths are also changed according to the defined to_arg functions (for example the 'My account' link is changed from user/% to a link with the current user's uid).

Parameters
$menu_name The name of the menu.
Returns
A structured array representing the specified menu on the current page, to be rendered by drupal_render().

Definition at line 992 of file menu.inc.

References $tree, drupal_static(), menu_tree_output(), and menu_tree_page_data().

Referenced by menu_block_view(), shortcut_renderable_links(), and system_block_view().

menu_tree_all_data | ( | $menu_name,
 |  | $link = NULL,
 |  | $max_depth = NULL
 | ) |

Gets the data structure representing a named menu tree.

Since this can be the full tree including hidden items, the data returned may be used for generating an an admin interface or a select.

Parameters
$menu_name | The named menu links to return
$link | A fully loaded menu link, or NULL. If a link is supplied, only the path to root will be included in the returned tree - as if this link represented the current page in a visible menu.
$max_depth | Optional maximum depth of links to retrieve. Typically useful if only one or two levels of a sub tree are needed in conjunction with a non-NULL $link, in which case $max_depth should be greater than $link['depth'].
Returns
An tree of menu links in an array, in the order they should be rendered.

Definition at line 1105 of file menu.inc.

References $tree, cache_get(), cache_set(), drupal_static(), menu_build_tree(), and MENU_MAX_DEPTH.

Referenced by _menu_get_options(), book_block_view(), book_get_flat_menu(), and book_toc().

menu_tree_check_access | ( | & | $tree,
 |  |  | $node_links = array()
 | ) |  |

Checks access and performs dynamic operations for each link in the tree.

Parameters
$tree | The menu tree you wish to operate on.
$node_links | A collection of node link references generated from $tree by menu_tree_collect_node_links().

Definition at line 1487 of file menu.inc.

References $tree, _menu_tree_check_access(), and db_select().

Referenced by book_menu_subtree_data(), menu_build_tree(), and menu_overview_form().

menu_tree_collect_node_links | ( | & | $tree,
 |  | & | $node_links
 | ) |  |

Collects node links from a given menu tree recursively.

Parameters
$tree | The menu tree you wish to collect node links from.
$node_links | An array in which to store the collected node links.

Definition at line 1463 of file menu.inc.

References $tree.

Referenced by _menu_build_tree(), book_menu_subtree_data(), and menu_overview_form().

menu_tree_data | ( | array | $links,
 |  | array | $parents = array(),
 |  |  | $depth = 1
 | ) |  |

Sorts and returns the built data representing a menu tree.

Parameters
$links | A flat array of menu links that are part of the menu. Each array element is an associative array of information about the menu link, containing the fields from the {menu_links} table, and optionally additional information from the {menu_router} table, if the menu item appears in both tables. This array must be ordered depth-first. See _menu_build_tree() for a sample query.
$parents | An array of the menu link ID values that are in the path from the current page to the root of the menu tree.
$depth | The minimum depth to include in the returned menu tree.
Returns
An array of menu links in the form of a tree. Each item in the tree is an associative array containing:
  • link: The menu link item from $links, with additional element 'in_active_trail' (TRUE if the link ID was in $parents).
  • below: An array containing the sub-tree of this item, where each element is a tree item array with 'link' and 'below' elements. This array will be empty if the menu item has no items in its sub-tree having a depth greater than or equal to $depth.

Definition at line 1554 of file menu.inc.

References $depth, and _menu_tree_data().

Referenced by _menu_build_tree(), book_menu_subtree_data(), and menu_overview_form().

menu_tree_get_path ( $menu_name )

Gets the path for determining the active trail of the specified menu tree.

Parameters
$menu_name The menu name of the requested tree.
Returns
A string containing the path. If no path has been specified with menu_tree_set_path(), NULL is returned.

Definition at line 1188 of file menu.inc.

References menu_tree_set_path().

Referenced by menu_tree_page_data().

menu_tree_output ( $tree )

Returns a rendered menu tree.

The menu item's LI element is given one of the following classes:

  • expanded: The menu item is showing its submenu.
  • collapsed: The menu item has a submenu which is not shown.
  • leaf: The menu item has no submenu.
Parameters
$tree A data structure representing the tree as returned from menu_tree_data.
Returns
A structured array to be rendered by drupal_render().

Definition at line 1016 of file menu.inc.

References $tree, and menu_get_item().

Referenced by book_block_view(), book_children(), and menu_tree().

menu_tree_page_data | ( | $menu_name,
 |  | $max_depth = NULL,
 |  | $only_active_trail = FALSE
 | ) |

Gets the data structure for a named menu tree, based on the current page.

The tree order is maintained by storing each parent in an individual field, see http://drupal.org/node/141866 for more.

Parameters
$menu_name | The named menu links to return.
$max_depth | (optional) The maximum depth of links to retrieve.
$only_active_trail | (optional) Whether to only return the links in the active trail (TRUE) instead of all links on every level of the menu link tree (FALSE). Defaults to FALSE. Internally used for breadcrumbs only.
Returns
An array of menu links, in the order they should be rendered. The array is a list of associative arrays – these have two keys, link and below. link is a menu item, ready for theming as a link. Below represents the submenu below the link if there is one, and it is a subtree that has the same structure described for the top-level array.

Definition at line 1214 of file menu.inc.

References $tree, cache_get(), cache_set(), db_select(), drupal_static(), menu_build_tree(), menu_get_item(), menu_link_get_preferred(), MENU_MAX_DEPTH, menu_tree_get_path(), and variable_get().

Referenced by menu_navigation_links(), menu_set_active_trail(), and menu_tree().

menu_tree_set_path | ( | $menu_name,
 |  | $path = NULL
 | ) |

Sets the path for determining the active trail of the specified menu tree.

This path will also affect the breadcrumbs under some circumstances. Breadcrumbs are built using the preferred link returned by menu_link_get_preferred(). If the preferred link is inside one of the menus specified in calls to menu_tree_set_path(), the preferred link will be overridden by the corresponding path returned by menu_tree_get_path().

Setting this path does not affect the main content; for that use menu_set_active_item() instead.

Parameters
$menu_name | The name of the affected menu tree.
$path | The path to use when finding the active trail.

Definition at line 1170 of file menu.inc.

References drupal_static().

Referenced by menu_tree_get_path().

menu_unserialize | ( | $data,
 |  | $map
 | ) |

Unserializes menu data, using a map to replace path elements.

The menu system stores various path-related information (such as the 'page arguments' and 'access arguments' components of a menu item) in the database using serialized arrays, where integer values in the arrays represent arguments to be replaced by values from the path. This function first unserializes such menu information arrays, and then does the path replacement.

The path replacement acts on each integer-valued element of the unserialized menu data array ($data) using a map array ($map, which is typically an array of path arguments) as a list of replacements. For instance, if there is an element of $data whose value is the number 2, then it is replaced in $data with $map[2]; non-integer values in $data are left alone.

As an example, an unserialized $data array with elements ('node_load', 1) represents instructions for calling the node_load() function. Specifically, this instruction says to use the path component at index 1 as the input parameter to node_load(). If the path is 'node/123', then $map will be the array ('node', 123), and the returned array from this function will have elements ('node_load', 123), since $map[1] is 123. This return value will indicate specifically that node_load(123) is to be called to load the node whose ID is 123 for this menu item.

Parameters
$data | A serialized array of menu data, as read from the database.
$map | A path argument array, used to replace integer values in $data; an integer value N in $data will be replaced by value $map[N]. Typically, the $map array is generated from a call to the arg() function.
Returns
The unserialized $data array, with path arguments replaced.

Definition at line 398 of file menu.inc.

Referenced by _menu_check_access(), _menu_item_localize(), and menu_get_item().

template_preprocess_menu_tree ( & $variables )

Implements template_preprocess_HOOK() for theme_menu_tree().

Definition at line 1598 of file menu.inc.

Variable Documentation

const MENU_PREFERRED_LINK '1cf698d64d1aa4b83907cf6ed55db3a7f8e92c91'

End of "Menu tree parameters". Reserved key to identify the most specific menu link for a given path.

The value of this constant is a hash of the constant name. We use the hash so that the reserved key is over 32 characters in length and will not collide with allowed menu names:

* sha1('MENU_PREFERRED_LINK') = 1cf698d64d1aa4b83907cf6ed55db3a7f8e92c91
*
See Also
menu_link_get_preferred()

Definition at line 289 of file menu.inc.

Referenced by menu_link_get_preferred().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Menu flags

Variables
Menu flags
Menu system

Variables

const | MENU_IS_ROOT 0x0001
const | MENU_VISIBLE_IN_TREE 0x0002
const | MENU_VISIBLE_IN_BREADCRUMB 0x0004
const | MENU_LINKS_TO_PARENT 0x0008
const | MENU_MODIFIED_BY_ADMIN 0x0020
const | MENU_CREATED_BY_ADMIN 0x0040
const | MENU_IS_LOCAL_TASK 0x0080
const | MENU_IS_LOCAL_ACTION 0x0100

Detailed Description

Flags for use in the "type" attribute of menu items.

Variable Documentation

const MENU_CREATED_BY_ADMIN 0x0040

Internal menu flag – menu item was created by administrator.

Definition at line 111 of file menu.inc.

const MENU_IS_LOCAL_ACTION 0x0100

Internal menu flag – menu item is a local action.

Definition at line 121 of file menu.inc.

Referenced by menu_local_tasks().

const MENU_IS_LOCAL_TASK 0x0080

Internal menu flag – menu item is a local task.

Definition at line 116 of file menu.inc.

Referenced by _menu_router_build(), menu_get_active_title(), and menu_local_tasks().

const MENU_IS_ROOT 0x0001

Internal menu flag – menu item is the root of the menu tree.

Definition at line 86 of file menu.inc.

const MENU_LINKS_TO_PARENT 0x0008

Internal menu flag – menu item links back to its parent.

Definition at line 101 of file menu.inc.

Referenced by menu_get_active_breadcrumb(), menu_local_tasks(), and menu_set_active_trail().

const MENU_MODIFIED_BY_ADMIN 0x0020

Internal menu flag – menu item can be modified by administrator.

Definition at line 106 of file menu.inc.

const MENU_VISIBLE_IN_BREADCRUMB 0x0004

Internal menu flag – menu item is visible in the breadcrumb.

Definition at line 96 of file menu.inc.

Referenced by _menu_router_build(), dashboard_menu(), help_menu(), locale_menu(), profile_menu(), system_menu(), and trigger_menu().

const MENU_VISIBLE_IN_TREE 0x0002

Internal menu flag – menu item is visible in the menu tree.

Definition at line 91 of file menu.inc.

Referenced by _menu_link_build().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Menu item types

Variables
Menu item types
Menu system

Variables

const | MENU_NORMAL_ITEM MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB
const | MENU_CALLBACK 0x0000
const | MENU_SUGGESTED_ITEM MENU_VISIBLE_IN_BREADCRUMB | 0x0010
const | MENU_LOCAL_TASK MENU_IS_LOCAL_TASK | MENU_VISIBLE_IN_BREADCRUMB
const | MENU_DEFAULT_LOCAL_TASK MENU_IS_LOCAL_TASK | MENU_LINKS_TO_PARENT | MENU_VISIBLE_IN_BREADCRUMB
const | MENU_LOCAL_ACTION MENU_IS_LOCAL_TASK | MENU_IS_LOCAL_ACTION | MENU_VISIBLE_IN_BREADCRUMB

Detailed Description

End of "Menu flags".

Definitions for various menu item types.

Menu item definitions provide one of these constants, which are shortcuts for combinations of Menu flags .

Variable Documentation

const MENU_CALLBACK 0x0000

Menu type – A hidden, internal callback, typically used for API calls.

Callbacks simply register a path so that the correct function is fired when the URL is accessed. They do not appear in menus or breadcrumbs.

Definition at line 151 of file menu.inc.

Referenced by aggregator_menu(), ajax_example_menu(), block_menu(), blog_menu(), book_menu(), dashboard_menu(), file_example_menu(), file_menu(), hook_menu(), image_menu(), menu_example_menu(), menu_menu(), node_menu(), openid_menu(), overlay_menu(), page_example_menu(), profile_menu(), shortcut_menu(), system_menu(), taxonomy_menu(), toolbar_menu(), update_menu(), and user_menu().

const MENU_DEFAULT_LOCAL_TASK MENU_IS_LOCAL_TASK | MENU_LINKS_TO_PARENT | MENU_VISIBLE_IN_BREADCRUMB

Menu type – The "default" local task, which is initially active.

Every set of local tasks should provide one "default" task, that links to the same path as its parent when clicked.

Definition at line 178 of file menu.inc.

Referenced by _menu_router_build(), aggregator_menu(), block_menu(), book_menu(), comment_menu(), contextual_links_example_menu(), dbtng_example_menu(), entity_example_menu(), field_ui_menu(), filter_menu(), form_example_menu(), forum_menu(), image_menu(), locale_menu(), menu_example_menu(), menu_menu(), node_menu(), path_menu(), shortcut_menu(), simpletest_menu(), system_menu(), taxonomy_menu(), tracker_menu(), update_menu(), and user_menu().

const MENU_LOCAL_ACTION MENU_IS_LOCAL_TASK | MENU_IS_LOCAL_ACTION | MENU_VISIBLE_IN_BREADCRUMB

Menu type – An action specific to the parent, usually rendered as a link.

Local actions are menu items that describe actions on the parent item such as adding a new user, taxonomy term, etc.

Definition at line 186 of file menu.inc.

Referenced by aggregator_menu(), block_menu(), contact_menu(), entity_example_menu(), filter_menu(), forum_menu(), image_menu(), locale_menu(), menu_menu(), node_menu(), path_menu(), shortcut_menu(), system_menu(), taxonomy_menu(), update_menu(), and user_menu().

const MENU_LOCAL_TASK MENU_IS_LOCAL_TASK | MENU_VISIBLE_IN_BREADCRUMB

Menu type – A task specific to the parent item, usually rendered as a tab.

Local tasks are menu items that describe actions to be performed on their parent item. An example is the path "node/52/edit", which performs the "edit" task on "node/52".

Definition at line 170 of file menu.inc.

Referenced by aggregator_menu(), block_menu(), book_menu(), comment_menu(), contact_menu(), contextual_links_example_menu(), dbtng_example_menu(), entity_example_menu(), field_ui_menu(), form_example_menu(), forum_menu(), locale_menu(), menu_example_menu(), menu_menu(), node_menu(), openid_menu(), poll_menu(), shortcut_menu(), simpletest_menu(), statistics_menu(), system_menu(), taxonomy_menu(), tracker_menu(), translation_menu(), trigger_menu(), update_menu(), and user_menu().

const MENU_NORMAL_ITEM MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB

Menu type – A "normal" menu item that's shown in menu and breadcrumbs.

Normal menu items show up in the menu tree and can be moved/hidden by the administrator. Use this for most menu items. It is the default value if no menu item type is specified.

Definition at line 143 of file menu.inc.

Referenced by _menu_router_build(), comment_menu(), field_ui_menu(), and form_example_menu().

const MENU_SUGGESTED_ITEM MENU_VISIBLE_IN_BREADCRUMB | 0x0010

Menu type – A normal menu item, hidden until enabled by an administrator.

Modules may "suggest" menu items that the administrator may enable. They act just as callbacks do until enabled, at which time they act like normal items. Note for the value: 0x0010 was a flag which is no longer used, but this way the values of MENU_CALLBACK and MENU_SUGGESTED_ITEM are separate.

Definition at line 161 of file menu.inc.

Referenced by _menu_link_build(), blog_menu(), book_menu(), contact_menu(), filter_menu(), hook_menu(), poll_menu(), and profile_menu().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Menu context types

Variables
Menu context types
Menu system

Variables

const | MENU_CONTEXT_NONE 0x0000
const | MENU_CONTEXT_PAGE 0x0001
const | MENU_CONTEXT_INLINE 0x0002

Detailed Description

End of "Menu item types".

Flags for use in the "context" attribute of menu router items.

Variable Documentation

const MENU_CONTEXT_INLINE 0x0002

Internal menu flag: Local task should be displayed inline.

Definition at line 214 of file menu.inc.

Referenced by block_menu(), contextual_links_example_menu(), menu_local_tasks(), menu_menu(), and node_menu().

const MENU_CONTEXT_NONE 0x0000

Internal menu flag: Invisible local task.

This flag may be used for local tasks like "Delete", so custom modules and themes can alter the default context and expose the task by altering menu.

Definition at line 204 of file menu.inc.

Referenced by block_menu(), and menu_contextual_links().

const MENU_CONTEXT_PAGE 0x0001

Internal menu flag: Local task should be displayed in page context.

Definition at line 209 of file menu.inc.

Referenced by _menu_router_build(), contextual_links_example_menu(), menu_contextual_links(), menu_menu(), and node_menu().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Menu status codes

Variables
Menu status codes
Menu system

Variables

const | MENU_FOUND 1
const | MENU_NOT_FOUND 2
const | MENU_ACCESS_DENIED 3
const | MENU_SITE_OFFLINE 4
const | MENU_SITE_ONLINE 5

Detailed Description

End of "Menu context types".

Status codes for menu callbacks.

Variable Documentation

const MENU_ACCESS_DENIED 3

Internal menu status code – Menu item access is denied.

Definition at line 239 of file menu.inc.

Referenced by aggregator_admin_refresh_feed(), ajax_prepare_response(), book_export(), comment_approve(), drupal_access_denied(), drupal_deliver_html_page(), image_style_deliver(), menu_delete_menu_page(), menu_execute_active_handler(), menu_item_delete_page(), overlay_user_dismiss_message(), profile_browse(), shortcut_link_add_inline(), system_theme_default(), system_theme_disable(), system_theme_enable(), and user_cancel_confirm().

const MENU_FOUND 1

Internal menu status code – Menu item was found.

Definition at line 229 of file menu.inc.

const MENU_NOT_FOUND 2

Internal menu status code – Menu item was not found.

Definition at line 234 of file menu.inc.

Referenced by ajax_prepare_response(), book_export(), comment_approve(), comment_confirm_delete_page(), comment_permalink(), drupal_deliver_html_page(), drupal_not_found(), locale_translate_delete_page(), menu_execute_active_handler(), profile_browse(), statistics_access_log(), statistics_node_tracker(), statistics_user_tracker(), and user_view_page().

const MENU_SITE_OFFLINE 4

Internal menu status code – Menu item inaccessible because site is offline.

Definition at line 244 of file menu.inc.

Referenced by ajax_prepare_response(), drupal_deliver_html_page(), drupal_site_offline(), hook_menu_site_status_alter(), menu_execute_active_handler(), openid_menu_site_status_alter(), and user_menu_site_status_alter().

const MENU_SITE_ONLINE 5

Internal menu status code – Everything is working fine.

Definition at line 249 of file menu.inc.

Referenced by hook_menu_site_status_alter(), menu_execute_active_handler(), openid_menu_site_status_alter(), and user_menu_site_status_alter().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Menu tree parameters

Variables
Menu tree parameters
Menu system

Variables

const | MENU_MAX_PARTS 9
const | MENU_MAX_DEPTH 9

Detailed Description

End of "Menu status codes".

Parameters for a menu tree.

Variable Documentation

const MENU_MAX_DEPTH 9

The maximum depth of a menu links tree - matches the number of p columns.

Definition at line 270 of file menu.inc.

Referenced by _book_parent_depth_limit(), _book_parent_select(), _menu_build_tree(), _menu_link_move_children(), _menu_link_parents_set(), _menu_parent_depth_limit(), book_menu_subtree_data(), book_node_view_link(), book_update_bid(), menu_edit_item(), menu_link_children_relative_depth(), menu_link_save(), menu_tree_all_data(), menu_tree_page_data(), theme_book_admin_table(), and theme_menu_overview_form().

const MENU_MAX_PARTS 9

The maximum number of path elements for a menu callback

Definition at line 264 of file menu.inc.

Referenced by _menu_find_router_path(), _menu_router_build(), menu_get_item(), and menu_link_save().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Content markers

Variables
Content markers

Variables

const | MARK_READ 0
const | MARK_NEW 1
const | MARK_UPDATED 2

Detailed Description

Markers used by theme_mark() and node_mark() to designate content.

See Also
theme_mark(), node_mark()

Variable Documentation

const MARK_NEW 1

Mark content as being new.

Definition at line 26 of file theme.inc.

Referenced by drupal_common_theme(), node_mark(), and theme_mark().

const MARK_READ 0

Mark content as read.

Definition at line 21 of file theme.inc.

Referenced by comment_prepare_thread(), and node_mark().

const MARK_UPDATED 2

Mark content as being updated.

Definition at line 31 of file theme.inc.

Referenced by node_mark(), and theme_mark().

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: Field API bulk data deletion

Functions
Field API bulk data deletion

Functions

field_purge_batch ($batch_size)
field_purge_data ($entity_type, $entity, $field, $instance)
field_purge_instance ($instance)
field_purge_field ($field)

Detailed Description

End of "defgroup field_crud".

Clean up after Field API bulk deletion operations.

Field API provides functions for deleting data attached to individual entities as well as deleting entire fields or field instances in a single operation.

Deleting field data items for an entity with field_attach_delete() involves three separate operations:

  • Invoking the Field Type API hook_field_delete() for each field on the entity. The hook for each field type receives the entity and the specific field being deleted. A file field module might use this hook to delete uploaded files from the filesystem.
  • Invoking the Field Storage API hook_field_storage_delete() to remove data from the primary field storage. The hook implementation receives the entity being deleted and deletes data for all of the entity's bundle's fields.
  • Invoking the global Field Attach API hook_field_attach_delete() for all modules that implement it. Each hook implementation receives the entity being deleted and can operate on whichever subset of the entity's bundle's fields it chooses to.

These hooks are invoked immediately when field_attach_delete() is called. Similar operations are performed for field_attach_delete_revision().

When a field, bundle, or field instance is deleted, it is not practical to invoke these hooks immediately on every affected entity in a single page request; there could be thousands or millions of them. Instead, the appropriate field data items, instances, and/or fields are marked as deleted so that subsequent load or query operations will not return them. Later, a separate process cleans up, or "purges", the marked-as-deleted data by going through the three-step process described above and, finally, removing deleted field and instance records.

Purging field data is made somewhat tricky by the fact that, while field_attach_delete() has a complete entity to pass to the various deletion hooks, the Field API purge process only has the field data it has previously stored. It cannot reconstruct complete original entities to pass to the deletion hooks. It is even possible that the original entity to which some Field API data was attached has been itself deleted before the field purge operation takes place.

Field API resolves this problem by using "pseudo-entities" during purge operations. A pseudo-entity contains only the information from the original entity that Field API knows about: entity type, id, revision id, and bundle. It also contains the field data for whichever field instance is currently being purged. For example, suppose that the node type 'story' used to contain a field called 'subtitle' but the field was deleted. If node 37 was a story with a subtitle, the pseudo-entity passed to the purge hooks would look something like this:

* $entity = stdClass Object(
* [nid] => 37,
* [vid] => 37,
* [type] => 'story',
* [subtitle] => array(
* [0] => array(
* 'value' => 'subtitle text',
* ),
* ),
* );
*

See Field API for information about the other parts of the Field API.

Function Documentation

field_purge_batch ( $batch_size )

Purges a batch of deleted Field API data, instances, or fields.

This function will purge deleted field data in batches. The batch size is defined as an argument to the function, and once each batch is finished, it continues with the next batch until all have completed. If a deleted field instance with no remaining data records is found, the instance itself will be purged. If a deleted field with no remaining field instances is found, the field itself will be purged.

Parameters
$batch_size The maximum number of field data records to purge before returning.

Definition at line 880 of file field.crud.inc.

References $results, field_attach_load(), field_info_field_by_id(), FIELD_LOAD_CURRENT, field_purge_data(), field_purge_field(), field_purge_instance(), field_read_fields(), and field_read_instances().

Referenced by field_cron(), field_ui_field_delete_form_submit(), forum_uninstall(), and rdf_example_uninstall().

field_purge_data | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance
 | ) |

Purges the field data for a single field on a single pseudo-entity.

This is basically the same as field_attach_delete() except it only applies to a single field. The entity itself is not being deleted, and it is quite possible that other field data will remain attached to it.

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The pseudo-entity whose field data is being purged.
$field | The (possibly deleted) field whose data is being purged.
$instance | The deleted field instance whose data is being purged.

Definition at line 938 of file field.crud.inc.

References $module, _field_invoke(), module_implements(), and module_invoke().

Referenced by field_purge_batch().

field_purge_field ( $field )

Purges a field record from the database.

This function assumes all instances for the field has already been purged, and should only be called by field_purge_batch().

Parameters
$field The field record to purge.

Definition at line 988 of file field.crud.inc.

References db_delete(), field_info_cache_clear(), field_read_instances(), module_invoke(), module_invoke_all(), and t().

Referenced by field_purge_batch().

field_purge_instance ( $instance )

Purges a field instance record from the database.

This function assumes all data for the instance has already been purged, and should only be called by field_purge_batch().

Parameters
$instance The instance record to purge.

Definition at line 963 of file field.crud.inc.

References db_delete(), field_info_cache_clear(), field_info_field_by_id(), module_invoke(), and module_invoke_all().

Referenced by field_purge_batch().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Field Info API

Functions
Field Info API

Functions

field_info_cache_clear ()
_field_info_collate_fields ($reset=FALSE)
_field_info_collate_types ($reset=FALSE)
_field_info_prepare_field ($field)
_field_info_prepare_instance ($instance, $field)
_field_info_prepare_instance_display ($field, $display)
_field_info_prepare_instance_widget ($field, $widget)
_field_info_prepare_extra_fields ($extra_fields, $entity_type, $bundle)
field_behaviors_widget ($op, $instance)
field_info_field_types ($field_type=NULL)
field_info_widget_types ($widget_type=NULL)
field_info_formatter_types ($formatter_type=NULL)
field_info_storage_types ($storage_type=NULL)
field_info_bundles ($entity_type=NULL)
field_info_field_map ()
field_info_fields ()
field_info_field ($field_name)
field_info_field_by_id ($field_id)
field_info_field_by_ids ()
field_info_instances ($entity_type=NULL, $bundle_name=NULL)
field_info_instance ($entity_type, $field_name, $bundle_name)
field_info_extra_fields ($entity_type, $bundle, $context)
field_info_max_weight ($entity_type, $bundle, $context)
field_info_field_settings ($type)
field_info_instance_settings ($type)
field_info_widget_settings ($type)
field_info_formatter_settings ($type)
field_info_storage_settings ($type)

Detailed Description

Obtain information about Field API configuration.

The Field Info API exposes information about field types, fields, instances, bundles, widget types, display formatters, behaviors, and settings defined by or with the Field API.

See Field API for information about the other parts of the Field API.

Function Documentation

_field_info_collate_fields ( $reset = FALSE )

Collates all information on existing fields and instances.

Deprecated. This function is kept to ensure backwards compatibility, but has a serious performance impact, and should be absolutely avoided. See http://drupal.org/node/1915646.

Use the regular field_info_*() API functions to access the information, or field_info_cache_clear() to clear the cached data.

Definition at line 76 of file field.info.inc.

References $info, _field_info_field_cache(), and field_info_bundles().

_field_info_collate_types ( $reset = FALSE )

Collates all information on field types, widget types and related structures.

Parameters
$reset If TRUE, clear the cache. The information will be rebuilt from the database next time it is needed. Defaults to FALSE.
Returns
If $reset is TRUE, nothing. If $reset is FALSE, an array containing the following elements:
  • 'field types': Array of hook_field_info() results, keyed by field_type. Each element has the following components: label, description, settings, instance_settings, default_widget, default_formatter, and behaviors from hook_field_info(), as well as module, giving the module that exposes the field type.
  • 'widget types': Array of hook_field_widget_info() results, keyed by widget_type. Each element has the following components: label, field types, settings, weight, and behaviors from hook_field_widget_info(), as well as module, giving the module that exposes the widget type.
  • 'formatter types': Array of hook_field_formatter_info() results, keyed by formatter_type. Each element has the following components: label, field types, and behaviors from hook_field_formatter_info(), as well as module, giving the module that exposes the formatter type.
  • 'storage types': Array of hook_field_storage_info() results, keyed by storage type names. Each element has the following components: label, description, and settings from hook_field_storage_info(), as well as module, giving the module that exposes the storage type.
  • 'fieldable types': Array of hook_entity_info() results, keyed by entity_type. Each element has the following components: name, id key, revision key, bundle key, cacheable, and bundles from hook_entity_info(), as well as module, giving the module that exposes the entity type.

Definition at line 141 of file field.info.inc.

References $info, $module, $name, cache_clear_all(), cache_get(), cache_set(), drupal_alter(), module_implements(), and module_invoke().

Referenced by field_info_cache_clear(), field_info_field_types(), field_info_formatter_types(), field_info_storage_types(), and field_info_widget_types().

_field_info_prepare_extra_fields | ( | $extra_fields,
 |  | $entity_type,
 |  | $bundle
 | ) |

Prepares 'extra fields' for the current run-time context.

The functionality has moved to the FieldInfo class. This function is kept as a backwards-compatibility layer. See http://drupal.org/node/1915646.

See Also
FieldInfo::prepareExtraFields()

Definition at line 293 of file field.info.inc.

References _field_info_field_cache().

_field_info_prepare_field ( $field )

Prepares a field definition for the current run-time context.

The functionality has moved to the FieldInfo class. This function is kept as a backwards-compatibility layer. See http://drupal.org/node/1915646.

See Also
FieldInfo::prepareField()

Definition at line 241 of file field.info.inc.

References _field_info_field_cache().

_field_info_prepare_instance | ( | $instance,
 |  | $field
 | ) |

Prepares an instance definition for the current run-time context.

The functionality has moved to the FieldInfo class. This function is kept as a backwards-compatibility layer. See http://drupal.org/node/1915646.

See Also
FieldInfo::prepareInstance()

Definition at line 254 of file field.info.inc.

References _field_info_field_cache().

_field_info_prepare_instance_display | ( | $field,
 |  | $display
 | ) |

Adapts display specifications to the current run-time context.

The functionality has moved to the FieldInfo class. This function is kept as a backwards-compatibility layer. See http://drupal.org/node/1915646.

See Also
FieldInfo::prepareInstanceDisplay()

Definition at line 267 of file field.info.inc.

References _field_info_field_cache().

_field_info_prepare_instance_widget | ( | $field,
 |  | $widget
 | ) |

Prepares widget specifications for the current run-time context.

The functionality has moved to the FieldInfo class. This function is kept as a backwards-compatibility layer. See http://drupal.org/node/1915646.

See Also
FieldInfo::prepareInstanceWidget()

Definition at line 280 of file field.info.inc.

References _field_info_field_cache().

field_behaviors_widget | ( | $op,
 |  | $instance
 | ) |

Determines the behavior of a widget with respect to an operation.

Parameters
$op | The name of the operation. Currently supported: 'default value', 'multiple values'.
$instance | The field instance array.
Returns
One of these values:
  • FIELD_BEHAVIOR_NONE: Do nothing for this operation.
  • FIELD_BEHAVIOR_CUSTOM: Use the widget's callback function.
  • FIELD_BEHAVIOR_DEFAULT: Use field.module default behavior.

Definition at line 313 of file field.info.inc.

References $info, $op, FIELD_BEHAVIOR_DEFAULT, and field_info_widget_types().

Referenced by field_default_form(), field_default_form_errors(), field_ui_field_edit_form(), and FieldInfo\prepareInstance().

field_info_bundles ( $entity_type = NULL )

Returns information about existing bundles.

Parameters
$entity_type The type of entity; e.g. 'node' or 'user'.
Returns
An array of bundles for the $entity_type keyed by bundle name, or, if no $entity_type was provided, the array of all existing bundles, keyed by entity type.

Definition at line 428 of file field.info.inc.

References $info, and entity_get_info().

Referenced by _field_info_collate_fields(), _field_ui_bundle_admin_path(), field_ui_field_delete_form_submit(), field_ui_field_edit_form(), field_ui_fields_list(), field_ui_widget_type_form(), and FieldInfo\getInstances().

field_info_cache_clear ( )

Clears the field info cache without clearing the field data cache.

This is useful when deleted fields or instances are purged. We need to remove the purged records, but no actual field data items are affected.

Definition at line 54 of file field.info.inc.

References _field_info_collate_types(), _field_info_field_cache(), drupal_static_reset(), and entity_info_cache_clear().

Referenced by field_bundle_settings(), field_cache_clear(), field_multilingual_settings_changed(), field_purge_field(), field_purge_instance(), field_ui_field_overview_form(), hook_multilingual_settings_changed(), and image_style_flush().

field_info_extra_fields | ( | $entity_type,
 |  | $bundle,
 |  | $context
 | ) |

Returns a list and settings of pseudo-field elements in a given bundle.

If $context is 'form', an array with the following structure:

* array(
* 'name_of_pseudo_field_component' => array(
* 'label' => The human readable name of the component,
* 'description' => A short description of the component content,
* 'weight' => The weight of the component in edit forms,
* ),
* 'name_of_other_pseudo_field_component' => array(
* // ...
* ),
* );
*

If $context is 'display', an array with the following structure:

* array(
* 'name_of_pseudo_field_component' => array(
* 'label' => The human readable name of the component,
* 'description' => A short description of the component content,
* // One entry per view mode, including the 'default' mode:
* 'display' => array(
* 'default' => array(
* 'weight' => The weight of the component in displayed entities in
* this view mode,
* 'visible' => TRUE if the component is visible, FALSE if hidden, in
* displayed entities in this view mode,
* ),
* 'teaser' => array(
* // ...
* ),
* ),
* ),
* 'name_of_other_pseudo_field_component' => array(
* // ...
* ),
* );
*
Parameters
$entity_type | The type of entity; e.g. 'node' or 'user'.
$bundle | The bundle name.
$context | The context for which the list of pseudo-fields is requested. Either 'form' or 'display'.
Returns
The array of pseudo-field elements in the bundle.

Definition at line 684 of file field.info.inc.

References $info, and _field_info_field_cache().

Referenced by _field_extra_fields_pre_render(), field_extra_fields_get_display(), field_info_max_weight(), field_ui_display_overview_form(), and field_ui_field_overview_form().

field_info_field ( $field_name )

Returns data about an individual field, given a field name.

Parameters
$field_name The name of the field to retrieve. $field_name can only refer to a non-deleted, active field. For deleted fields, use field_info_field_by_id(). To retrieve information about inactive fields, use field_read_fields().
Returns
The field array, as returned by field_read_fields(), with an additional element 'bundles', whose value is an array of all the bundles this field belongs to keyed by entity type. NULL if the field was not found.
See Also
field_info_field_by_id()

Definition at line 518 of file field.info.inc.

References _field_info_field_cache().

Referenced by _field_ui_field_overview_form_validate_add_existing(), EntityFieldQuery\addFieldCondition(), comment_submit(), field_delete_field(), field_delete_instance(), field_get_display(), field_sql_storage_field_storage_delete_instance(), field_ui_display_overview_form(), field_ui_existing_field_options(), field_ui_field_delete_form(), field_ui_field_delete_form_submit(), field_ui_field_edit_form(), field_ui_field_edit_form_submit(), field_ui_field_overview_form(), field_ui_field_overview_form_submit(), field_ui_field_settings_form(), field_ui_field_settings_form_submit(), field_ui_fields_list(), field_ui_menu_load(), field_ui_widget_type_form(), field_view_field(), field_view_value(), EntityFieldQuery\fieldOrderBy(), file_file_download(), forum_enable(), forum_menu_local_tasks_alter(), hook_field_storage_delete_instance(), locale_field_entity_form_submit(), node_add_body_field(), taxonomy_autocomplete(), and taxonomy_build_node_index().

field_info_field_by_id ( $field_id )

Returns data about an individual field, given a field ID.

Parameters
$field_id The id of the field to retrieve. $field_id can refer to a deleted field, but not an inactive one.
Returns
The field array, as returned by field_read_fields(), with an additional element 'bundles', whose value is an array of all the bundles this field belongs to.
See Also
field_info_field()

Definition at line 537 of file field.info.inc.

References _field_info_field_cache().

Referenced by _field_invoke(), _field_invoke_multiple(), field_attach_delete(), field_attach_delete_revision(), field_attach_insert(), field_attach_load(), field_attach_update(), field_purge_batch(), field_purge_instance(), field_sql_storage_field_attach_rename_bundle(), field_sql_storage_field_storage_delete(), field_sql_storage_field_storage_delete_revision(), field_sql_storage_field_storage_load(), field_sql_storage_field_storage_write(), hook_field_storage_delete(), hook_field_storage_delete_revision(), hook_field_storage_load(), and hook_field_storage_write().

field_info_field_by_ids ( )

Returns the same data as field_info_field_by_id() for every field.

Use of this function should be avoided when possible, since it loads and statically caches a potentially large array of information.

When iterating over the fields present in a given bundle after a call to field_info_instances($entity_type, $bundle), it is recommended to use field_info_field() on each individual field instead.

Returns
An array, each key is a field ID and the values are field arrays as returned by field_read_fields(), with an additional element 'bundles', whose value is an array of all the bundle this field belongs to.
See Also
field_info_field()
field_info_field_by_id()

Definition at line 560 of file field.info.inc.

References _field_info_field_cache().

field_info_field_map ( )

Returns a lightweight map of fields across bundles.

The function only returns active, non deleted fields.

Returns
An array keyed by field name. Each value is an array with two entries:
  • type: The field type.
  • bundles: The bundles in which the field appears, as an array with entity types as keys and the array of bundle names as values. Example:
    * array(
    * 'body' => array(
    * 'bundles' => array(
    * 'node' => array('page', 'article'),
    * ),
    * 'type' => 'text_with_summary',
    * ),
    * );
    *

Definition at line 464 of file field.info.inc.

References _field_info_field_cache().

field_info_field_settings ( $type )

Returns a field type's default settings.

Parameters
$type A field type name.
Returns
The field type's default settings, as provided by hook_field_info(), or an empty array if type or settings are not defined.

Definition at line 742 of file field.info.inc.

References $info, and field_info_field_types().

Referenced by field_create_field(), file_field_settings_form(), image_field_settings_form(), and FieldInfo\prepareField().

field_info_field_types ( $field_type = NULL )

Returns information about field types from hook_field_info().

Parameters
$field_type (optional) A field type name. If omitted, all field types will be returned.
Returns
Either a field type description, as provided by hook_field_info(), or an array of all existing field types, keyed by field type name.

Definition at line 329 of file field.info.inc.

References $info, and _field_info_collate_types().

Referenced by _field_write_instance(), field_create_field(), field_info_field_settings(), field_info_instance_settings(), field_ui_display_overview_form(), field_ui_existing_field_options(), field_ui_field_edit_form(), field_ui_field_overview_form(), field_ui_field_type_options(), field_ui_fields_list(), field_ui_formatter_options(), field_ui_inactive_message(), field_ui_widget_type_form(), field_ui_widget_type_options(), FieldInfo\prepareInstanceDisplay(), and FieldInfo\prepareInstanceWidget().

field_info_fields ( )

Returns all field definitions.

Use of this function should be avoided when possible, since it loads and statically caches a potentially large array of information. Use field_info_field_map() instead.

When iterating over the fields present in a given bundle after a call to field_info_instances($entity_type, $bundle), it is recommended to use field_info_field() on each individual field instead.

Returns
An array of field definitions, keyed by field name. Each field has an additional property, 'bundles', which is an array of all the bundles to which this field belongs keyed by entity type.
See Also
field_info_field_map()

Definition at line 487 of file field.info.inc.

References $info, and _field_info_field_cache().

Referenced by file_get_file_references().

field_info_formatter_settings ( $type )

Returns a field formatter's default settings.

Parameters
$type A field formatter type name.
Returns
The formatter type's default settings, as provided by hook_field_formatter_info(), or an empty array if type or settings are undefined.

Definition at line 789 of file field.info.inc.

References $info, and field_info_formatter_types().

Referenced by _field_write_instance(), field_ui_display_overview_form(), field_ui_display_overview_form_submit(), and FieldInfo\prepareInstanceDisplay().

field_info_formatter_types ( $formatter_type = NULL )

Returns information about field formatters from hook_field_formatter_info().

Parameters
$formatter_type (optional) A formatter type name. If omitted, all formatter types will be returned.
Returns
Either a single formatter type description, as provided by hook_field_formatter_info(), or an array of all existing formatter types, keyed by formatter type name.

Definition at line 379 of file field.info.inc.

References $info, and _field_info_collate_types().

Referenced by _field_write_instance(), field_info_formatter_settings(), field_ui_display_overview_form(), field_ui_formatter_options(), and FieldInfo\prepareInstanceDisplay().

field_info_instance | ( | $entity_type,
 |  | $field_name,
 |  | $bundle_name
 | ) |

Returns an array of instance data for a specific field and bundle.

The function populates a static cache with all fields and instances used in the bundle, allowing fast retrieval of field_info_field() or field_info_instance() later in the request.

Parameters
$entity_type | The entity type for the instance.
$field_name | The field name for the instance.
$bundle_name | The bundle name for the instance.
Returns
An associative array of instance data for the specific field and bundle; NULL if the instance does not exist.

Definition at line 623 of file field.info.inc.

References $info, and _field_info_field_cache().

Referenced by _field_invoke_get_instances(), _forum_node_check_node_type(), comment_tokens(), field_delete_field(), field_ui_existing_field_options(), field_ui_field_delete_form_submit(), field_ui_field_settings_form_submit(), field_ui_menu_load(), node_add_body_field(), and node_tokens().

field_info_instance_settings ( $type )

Returns a field type's default instance settings.

Parameters
$type A field type name.
Returns
The field type's default instance settings, as provided by hook_field_info(), or an empty array if type or settings are not defined.

Definition at line 757 of file field.info.inc.

References $info, and field_info_field_types().

Referenced by _field_write_instance(), and FieldInfo\prepareInstance().

field_info_instances | ( | $entity_type = NULL,
 |  | $bundle_name = NULL
 | ) |

Retrieves information about field instances.

Use of this function to retrieve instances across separate bundles (i.e. when the $bundle parameter is NULL) should be avoided when possible, since it loads and statically caches a potentially large array of information. Use field_info_field_map() instead.

When retrieving the instances of a specific bundle (i.e. when both $entity_type and $bundle_name are provided), the function also populates a static cache with the corresponding field definitions, allowing fast retrieval of field_info_field() later in the request.

Parameters
$entity_type | (optional) The entity type for which to return instances.
$bundle_name | (optional) The bundle name for which to return instances. If $entity_type is NULL, the $bundle_name parameter is ignored.
Returns
If $entity_type is not set, return all instances keyed by entity type and bundle name. If $entity_type is set, return all instances for that entity type, keyed by bundle name. If $entity_type and $bundle_name are set, return all instances for that bundle.
See Also
field_info_field_map()

Definition at line 592 of file field.info.inc.

References _field_info_field_cache().

Referenced by _field_invoke_get_instances(), entity_form_submit_build_entity(), field_attach_delete(), field_attach_delete_revision(), field_attach_insert(), field_attach_load(), field_attach_preprocess(), field_attach_update(), field_info_max_weight(), field_language(), field_sql_storage_field_storage_delete(), field_ui_display_overview_form(), field_ui_existing_field_options(), field_ui_field_overview_form(), field_ui_fields_list(), field_ui_inactive_instances(), hook_field_storage_delete(), locale_field_entity_form_submit(), rdf_example_uninstall(), taxonomy_build_node_index(), and user_register_form().

field_info_max_weight | ( | $entity_type,
 |  | $bundle,
 |  | $context
 | ) |

Returns the maximum weight of all the components in an entity.

This includes fields, 'extra_fields', and other components added by third-party modules (e.g. field_group).

Parameters
$entity_type | The type of entity; e.g. 'node' or 'user'.
$bundle | The bundle name.
$context | The context for which the maximum weight is requested. Either 'form', or the name of a view mode.
Returns
The maximum weight of the entity's components, or NULL if no components were found.

Definition at line 708 of file field.info.inc.

References field_info_extra_fields(), field_info_instances(), and module_invoke_all().

Referenced by _field_write_instance(), and field_ui_field_overview_form().

field_info_storage_settings ( $type )

Returns a field storage type's default settings.

Parameters
$type A field storage type name.
Returns
The storage type's default settings, as provided by hook_field_storage_info(), or an empty array if type or settings are undefined.

Definition at line 805 of file field.info.inc.

References $info, and field_info_storage_types().

Referenced by field_create_field(), and FieldInfo\prepareField().

field_info_storage_types ( $storage_type = NULL )

Returns information about field storage from hook_field_storage_info().

Parameters
$storage_type (optional) A storage type name. If omitted, all storage types will be returned.
Returns
Either a storage type description, as provided by hook_field_storage_info(), or an array of all existing storage types, keyed by storage type name.

Definition at line 404 of file field.info.inc.

References $info, and _field_info_collate_types().

Referenced by field_attach_delete(), field_attach_delete_revision(), field_attach_insert(), field_attach_load(), field_attach_update(), field_create_field(), field_info_storage_settings(), and field_update_field().

field_info_widget_settings ( $type )

Returns a field widget's default settings.

Parameters
$type A widget type name.
Returns
The widget type's default settings, as provided by hook_field_widget_info(), or an empty array if type or settings are undefined.

Definition at line 773 of file field.info.inc.

References $info, and field_info_widget_types().

Referenced by _field_write_instance(), and FieldInfo\prepareInstanceWidget().

field_info_widget_types ( $widget_type = NULL )

Returns information about field widgets from hook_field_widget_info().

Parameters
$widget_type (optional) A widget type name. If omitted, all widget types will be returned.
Returns
Either a single widget type description, as provided by hook_field_widget_info(), or an array of all existing widget types, keyed by widget type name.

Definition at line 354 of file field.info.inc.

References $info, and _field_info_collate_types().

Referenced by _field_write_instance(), field_behaviors_widget(), field_info_widget_settings(), field_ui_field_edit_form(), field_ui_field_overview_form(), field_ui_inactive_message(), field_ui_widget_type_form(), field_ui_widget_type_form_submit(), field_ui_widget_type_options(), and FieldInfo\prepareInstanceWidget().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Field API

Classes | Functions | Variables
Field API

Classes

class FieldUpdateForbiddenException

Functions

field_help ($path, $arg)
field_theme ()
field_cron ()
field_modules_uninstalled ($modules)
field_system_info_alter (&$info, $file, $type)
field_flush_caches ()
field_modules_enabled ($modules)
field_modules_disabled ($modules)
field_sync_field_status ()
field_associate_fields ($module)
field_get_default_value ($entity_type, $entity, $field, $instance, $langcode=NULL)
_field_filter_items ($field, $items)
_field_sort_items ($field, $items)
_field_sort_items_helper ($a, $b)
_field_sort_items_value_helper ($a, $b)
field_bundle_settings ($entity_type, $bundle, $settings=NULL)
field_view_mode_settings ($entity_type, $bundle)
field_get_display ($instance, $view_mode, $entity)
field_extra_fields_get_display ($entity_type, $bundle, $view_mode)
_field_extra_fields_pre_render ($elements)
field_cache_clear ()
field_filter_xss ($string)
_field_filter_xss_allowed_tags ()
_field_filter_xss_display_allowed_tags ()
field_view_value ($entity_type, $entity, $field_name, $item, $display=array(), $langcode=NULL)
field_view_field ($entity_type, $entity, $field_name, $display=array(), $langcode=NULL)
field_get_items ($entity_type, $entity, $field_name, $langcode=NULL)
field_has_data ($field)
field_access ($op, $field, $entity_type, $entity=NULL, $account=NULL)
field_extract_bundle ($entity_type, $bundle)
template_preprocess_field (&$variables, $hook)
template_process_field (&$variables, $hook)
field_ui_menu_load ($field_name, $entity_type, $bundle_name, $bundle_pos, $map)

Variables

const | FIELD_CARDINALITY_UNLIMITED -1
const | FIELD_BEHAVIOR_NONE 0x0001
const | FIELD_BEHAVIOR_DEFAULT 0x0002
const | FIELD_BEHAVIOR_CUSTOM 0x0004
const | FIELD_LOAD_CURRENT 'FIELD_LOAD_CURRENT'
const | FIELD_LOAD_REVISION 'FIELD_LOAD_REVISION'

Detailed Description

Attach custom data fields to Drupal entities.

The Field API allows custom data fields to be attached to Drupal entities and takes care of storing, loading, editing, and rendering field data. Any entity type (node, user, etc.) can use the Field API to make itself "fieldable" and thus allow fields to be attached to it. Other modules can provide a user interface for managing custom fields via a web browser as well as a wide and flexible variety of data type, form element, and display format capabilities.

The Field API defines two primary data structures, Field and Instance, and the concept of a Bundle. A Field defines a particular type of data that can be attached to entities. A Field Instance is a Field attached to a single Bundle. A Bundle is a set of fields that are treated as a group by the Field Attach API and is related to a single fieldable entity type.

For example, suppose a site administrator wants Article nodes to have a subtitle and photo. Using the Field API or Field UI module, the administrator creates a field named 'subtitle' of type 'text' and a field named 'photo' of type 'image'. The administrator (again, via a UI) creates two Field Instances, one attaching the field 'subtitle' to the 'node' bundle 'article' and one attaching the field 'photo' to the 'node' bundle 'article'. When the node system uses the Field Attach API to load all fields for an Article node, it passes the node's entity type (which is 'node') and content type (which is 'article') as the node's bundle. field_attach_load() then loads the 'subtitle' and 'photo' fields because they are both attached to the 'node' bundle 'article'.

Field definitions are represented as an array of key/value pairs.

array $field:

  • id (integer, read-only): The primary identifier of the field. It is assigned automatically by field_create_field().
  • field_name (string): The name of the field. Each field name is unique within Field API. When a field is attached to an entity, the field's data is stored in $entity->$field_name. Maximum length is 32 characters.
  • type (string): The type of the field, such as 'text' or 'image'. Field types are defined by modules that implement hook_field_info().
  • entity_types (array): The array of entity types that can hold instances of this field. If empty or not specified, the field can have instances in any entity type.
  • cardinality (integer): The number of values the field can hold. Legal values are any positive integer or FIELD_CARDINALITY_UNLIMITED.
  • translatable (integer): Whether the field is translatable.
  • locked (integer): Whether or not the field is available for editing. If TRUE, users can't change field settings or create new instances of the field in the UI. Defaults to FALSE.
  • module (string, read-only): The name of the module that implements the field type.
  • active (integer, read-only): TRUE if the module that implements the field type is currently enabled, FALSE otherwise.
  • deleted (integer, read-only): TRUE if this field has been deleted, FALSE otherwise. Deleted fields are ignored by the Field Attach API. This property exists because fields can be marked for deletion but only actually destroyed by a separate garbage-collection process.
  • columns (array, read-only): An array of the Field API columns used to store each value of this field. The column list may depend on field settings; it is not constant per field type. Field API column specifications are exactly like Schema API column specifications but, depending on the field storage module in use, the name of the column may not represent an actual column in an SQL database.
  • indexes (array): An array of indexes on data columns, using the same definition format as Schema API index specifications. Only columns that appear in the 'columns' setting are allowed. Note that field types can specify default indexes, which can be modified or added to when creating a field.
  • foreign keys: (optional) An associative array of relations, using the same structure as the 'foreign keys' definition of hook_schema(). Note, however, that the field data is not necessarily stored in SQL. Also, the possible usage is limited, as you cannot specify another field as related, only existing SQL tables, such as filter formats.
  • settings (array): A sub-array of key/value pairs of field-type-specific settings. Each field type module defines and documents its own field settings.
  • storage (array): A sub-array of key/value pairs identifying the storage backend to use for the for the field:
    • type (string): The storage backend used by the field. Storage backends are defined by modules that implement hook_field_storage_info().
    • module (string, read-only): The name of the module that implements the storage backend.
    • active (integer, read-only): TRUE if the module that implements the storage backend is currently enabled, FALSE otherwise.
    • settings (array): A sub-array of key/value pairs of settings. Each storage backend defines and documents its own settings.

Field instance definitions are represented as an array of key/value pairs.

array $instance:

  • id (integer, read-only): The primary identifier of this field instance. It is assigned automatically by field_create_instance().
  • field_id (integer, read-only): The foreign key of the field attached to the bundle by this instance. It is populated automatically by field_create_instance().
  • field_name (string): The name of the field attached to the bundle by this instance.
  • entity_type (string): The name of the entity type the instance is attached to.
  • bundle (string): The name of the bundle that the field is attached to.
  • label (string): A human-readable label for the field when used with this bundle. For example, the label will be the title of Form API elements for this instance.
  • description (string): A human-readable description for the field when used with this bundle. For example, the description will be the help text of Form API elements for this instance.
  • required (integer): TRUE if a value for this field is required when used with this bundle, FALSE otherwise. Currently, required-ness is only enforced during Form API operations, not by field_attach_load(), field_attach_insert(), or field_attach_update().
  • default_value_function (string): The name of the function, if any, that will provide a default value.
  • default_value (array): If default_value_function is not set, then fixed values can be provided.
  • deleted (integer, read-only): TRUE if this instance has been deleted, FALSE otherwise. Deleted instances are ignored by the Field Attach API. This property exists because instances can be marked for deletion but only actually destroyed by a separate garbage-collection process.
  • settings (array): A sub-array of key/value pairs of field-type-specific instance settings. Each field type module defines and documents its own instance settings.
  • widget (array): A sub-array of key/value pairs identifying the Form API input widget for the field when used by this bundle:
    • type (string): The type of the widget, such as text_textfield. Widget types are defined by modules that implement hook_field_widget_info().
    • settings (array): A sub-array of key/value pairs of widget-type-specific settings. Each field widget type module defines and documents its own widget settings.
    • weight (float): The weight of the widget relative to the other elements in entity edit forms.
    • module (string, read-only): The name of the module that implements the widget type.
  • display (array): A sub-array of key/value pairs identifying the way field values should be displayed in each of the entity type's view modes, plus the 'default' mode. For each view mode, Field UI lets site administrators define whether they want to use a dedicated set of display options or the 'default' options to reduce the number of displays to maintain as they add new fields. For nodes, on a fresh install, only the 'teaser' view mode is configured to use custom display options, all other view modes defined use the 'default' options by default. When programmatically adding field instances on nodes, it is therefore recommended to at least specify display options for 'default' and 'teaser':
    • default (array): A sub-array of key/value pairs describing the display options to be used when the field is being displayed in view modes that are not configured to use dedicated display options:
      • label (string): Position of the label. 'inline', 'above' and 'hidden' are the values recognized by the default 'field' theme implementation.
      • type (string): The type of the display formatter, or 'hidden' for no display.
      • settings (array): A sub-array of key/value pairs of display options specific to the formatter.
      • weight (float): The weight of the field relative to the other entity components displayed in this view mode.
      • module (string, read-only): The name of the module which implements the display formatter.
    • some_mode: A sub-array of key/value pairs describing the display options to be used when the field is being displayed in the 'some_mode' view mode. Those options will only be actually applied at run time if the view mode is not configured to use default settings for this bundle:
      • ...
    • other_mode:
      • ...

The (default) render arrays produced for field instances are documented at field_attach_view().

Bundles are represented by two strings, an entity type and a bundle name.

  • Field Types API . Defines field types, widget types, and display formatters. Field modules use this API to provide field types like Text and Node Reference along with the associated form elements and display formatters.
  • Field CRUD API . Create, updates, and deletes fields, bundles (a.k.a. "content types"), and instances. Modules use this API, often in hook_install(), to create custom data structures.
  • Field Attach API . Connects entity types to the Field API. Field Attach API functions load, store, generate Form API structures, display, and perform a variety of other functions for field data connected to individual entities. Fieldable entity types like node and user use this API to make themselves fieldable.
  • Field Info API . Exposes information about all fields, instances, widgets, and related information defined by or with the Field API.
  • Field Storage API . Provides a pluggable back-end storage system for actual field data. The default implementation, field_sql_storage.module, stores field data in the local SQL database.
  • Field API bulk data deletion . Cleans up after bulk deletion operations such as field_delete_field() and field_delete_instance().
  • Field language API . Provides native multilingual support for the Field API.

Class Documentation

class FieldUpdateForbiddenException

Exception class thrown by hook_field_update_forbid().

Definition at line 279 of file field.module.

Inheritance diagram for FieldUpdateForbiddenException:
FieldException Exception

Function Documentation

_field_extra_fields_pre_render ( $elements )

Pre-render callback to adjust weights and visibility of non-field elements.

Definition at line 710 of file field.module.

References $name, field_extra_fields_get_display(), and field_info_extra_fields().

_field_filter_items | ( | $field,
 |  | $items
 | ) |

Helper function to filter out empty field values.

Parameters
$field | The field definition.
$items | The field values to filter.
Returns
The array of items without empty field values. The function also renumbers the array keys to ensure sequential deltas.

Definition at line 505 of file field.module.

Referenced by field_default_submit(), and field_default_validate().

_field_filter_xss_allowed_tags ( )

List of tags allowed by field_filter_xss().

Definition at line 759 of file field.module.

Referenced by _field_filter_xss_display_allowed_tags(), and field_filter_xss().

_field_filter_xss_display_allowed_tags ( )

Human-readable list of allowed tags, for display in help texts.

Definition at line 766 of file field.module.

References _field_filter_xss_allowed_tags().

Referenced by field_ui_field_edit_form(), and list_field_settings_form().

_field_sort_items | ( | $field,
 |  | $items
 | ) |

Helper function to sort items in a field according to user drag-n-drop reordering.

Definition at line 520 of file field.module.

References FIELD_CARDINALITY_UNLIMITED.

Referenced by field_default_submit().

_field_sort_items_helper | ( | $a,
 |  | $b
 | ) |

Sort function for items order. (copied form element_sort(), which acts on #weight keys)

Definition at line 536 of file field.module.

_field_sort_items_value_helper | ( | $a,
 |  | $b
 | ) |

Same as above, using ['_weight']['value']

Definition at line 545 of file field.module.

field_access | ( | $op,
 |  | $field,
 |  | $entity_type,
 |  | $entity = NULL,
 |  | $account = NULL
 | ) |

Determine whether the user has access to a given field.

Parameters
$op The operation to be performed. Possible values:
  • 'edit'
  • 'view'
$field | The full field structure array for the field on which the operation is to be performed. See field_info_field().
$entity_type | The type of $entity; e.g., 'node' or 'user'.
$entity | (optional) The entity for the operation.
$account | (optional) The account to check, if not given use currently logged in user.
Returns
TRUE if the operation is allowed; FALSE if the operation is denied.

Definition at line 982 of file field.module.

References $module, $op, and module_implements().

Referenced by field_default_form(), field_default_view(), and file_file_download().

field_associate_fields ( $module )

Allows a module to update the database for fields and columns it controls.

Parameters
$module The name of the module to update on.

Definition at line 446 of file field.module.

References $module, db_update(), and module_invoke().

Referenced by field_sync_field_status(), and forum_enable().

field_bundle_settings | ( | $entity_type,
 |  | $bundle,
 |  | $settings = NULL
 | ) |

Gets or sets administratively defined bundle settings.

Parameters
string | $entity_type | The type of $entity; e.g., 'node' or 'user'.
string | $bundle | The bundle name.
array | null $settings (optional) The settings to store, an associative array with the following elements:
  • view_modes: An associative array keyed by view mode, with the following key/value pairs:
    • custom_settings: Boolean specifying whether the view mode uses a dedicated set of display options (TRUE), or the 'default' options (FALSE). Defaults to FALSE.
  • extra_fields: An associative array containing the form and display settings for extra fields (also known as pseudo-fields):
    • form: An associative array whose keys are the names of extra fields, and whose values are associative arrays with the following elements:
      • weight: The weight of the extra field, determining its position on an entity form.
    • display: An associative array whose keys are the names of extra fields, and whose values are associative arrays keyed by the name of view modes. This array must include an item for the 'default' view mode. Each view mode sub-array contains the following elements:
      • weight: The weight of the extra field, determining its position when an entity is viewed.
      • visible: TRUE if the extra field is visible, FALSE otherwise.
Returns
array|null If no $settings are passed, the current settings are returned.

Definition at line 583 of file field.module.

References field_info_cache_clear(), variable_get(), and variable_set().

Referenced by field_ui_display_overview_form_submit(), field_ui_field_overview_form_submit(), field_view_mode_settings(), and FieldInfo::prepareExtraFields().

field_cache_clear ( )

Clear the field info and field data caches.

Definition at line 740 of file field.module.

References cache_clear_all(), and field_info_cache_clear().

Referenced by field_attach_create_bundle(), field_attach_delete_bundle(), field_attach_rename_bundle(), field_create_field(), field_create_instance(), field_delete_field(), field_delete_instance(), field_update_field(), field_update_instance(), DrupalWebTestCase::tearDown(), text_filter_format_disable(), and text_filter_format_update().

field_cron ( )

Implements hook_cron().

Definition at line 336 of file field.module.

References field_purge_batch(), field_sync_field_status(), and variable_get().

field_extra_fields_get_display | ( | $entity_type,
 |  | $bundle,
 |  | $view_mode
 | ) |

Returns the display settings to use for pseudo-fields in a given view mode.

Parameters
$entity_type | The type of $entity; e.g., 'node' or 'user'.
$bundle | The bundle name.
$view_mode | The view mode.
Returns
The display settings to be used when viewing the bundle's pseudo-fields.

Definition at line 684 of file field.module.

References $name, $value, drupal_alter(), field_info_extra_fields(), and field_view_mode_settings().

Referenced by _field_extra_fields_pre_render(), and taxonomy_term_build_content().

field_extract_bundle | ( | $entity_type,
 |  | $bundle
 | ) |

Helper function to extract the bundle name of from a bundle object.

Parameters
$entity_type | The type of $entity; e.g., 'node' or 'user'.
$bundle | The bundle object (or string if bundles for this entity type do not exist as standalone objects).
Returns
The bundle name.

Definition at line 1010 of file field.module.

References $info, and entity_get_info().

Referenced by _field_ui_view_mode_menu_access(), field_ui_display_overview_form(), field_ui_field_overview_form(), and field_ui_menu_load().

field_filter_xss ( $string )

Like filter_xss_admin(), but with a shorter list of allowed tags.

Used for items entered by administrators, like field descriptions, allowed values, where some (mainly inline) mark-up may be desired (so check_plain() is not acceptable).

Definition at line 752 of file field.module.

References _field_filter_xss_allowed_tags(), and filter_xss().

Referenced by _options_prepare_options(), field_default_form(), field_multiple_value_form(), image_field_widget_form(), list_field_formatter_view(), and number_field_widget_form().

field_flush_caches ( )

Implements hook_flush_caches().

Definition at line 396 of file field.module.

References field_sync_field_status().

field_get_default_value | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance,
 |  | $langcode = NULL
 | ) |

Helper function to get the default value for a field on an entity.

Parameters
$entity_type | The type of $entity; e.g., 'node' or 'user'.
$entity | The entity for the operation.
$field | The field structure.
$instance | The instance structure.
$langcode | The field language to fill-in with the default value.

Definition at line 479 of file field.module.

Referenced by field_default_form().

field_get_display | ( | $instance,
 |  | $view_mode,
 |  | $entity
 | ) |

Returns the display settings to use for an instance in a given view mode.

Parameters
$instance | The field instance being displayed.
$view_mode | The view mode.
$entity | The entity being displayed.
Returns
The display settings to be used when displaying the field values.

Definition at line 651 of file field.module.

References drupal_alter(), field_info_field(), and field_view_mode_settings().

Referenced by field_default_prepare_view(), and field_default_view().

field_get_items | ( | $entity_type,
 |  | $entity,
 |  | $field_name,
 |  | $langcode = NULL
 | ) |

Returns the field items in the language they currently would be displayed.

Parameters
$entity_type | The type of $entity; e.g., 'node' or 'user'.
$entity | The entity containing the data to be displayed.
$field_name | The field to be displayed.
$langcode | (optional) The language code $entity->{$field_name} has to be displayed in. Defaults to the current language.
Returns
An array of field items keyed by delta if available, FALSE otherwise.

Definition at line 935 of file field.module.

References field_language().

Referenced by comment_admin_overview(), comment_preview(), comment_tokens(), file_file_download(), node_tokens(), and token_example_tokens().

field_has_data ( $field )

Determine whether a field has any data.

Parameters
$field A field structure.
Returns
TRUE if the field has data for any entity; FALSE otherwise.

Definition at line 948 of file field.module.

Referenced by field_ui_field_edit_form(), field_ui_field_settings_form(), and field_update_field().

field_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 284 of file field.module.

References $info, $module, $output, l(), module_hook(), module_implements(), system_get_info(), t(), theme(), and url().

field_modules_disabled ( $modules )

Implements hook_modules_disabled().

Definition at line 415 of file field.module.

References field_sync_field_status().

field_modules_enabled ( $modules )

Implements hook_modules_enabled().

Definition at line 407 of file field.module.

References field_sync_field_status().

field_modules_uninstalled ( $modules )

Implements hook_modules_uninstalled().

Definition at line 348 of file field.module.

References $module, and module_load_include().

field_sync_field_status ( )

Refreshes the 'active' and 'storage_active' columns for fields.

Definition at line 423 of file field.module.

References db_update(), field_associate_fields(), and module_list().

Referenced by field_cron(), field_flush_caches(), field_modules_disabled(), and field_modules_enabled().

field_system_info_alter | ( | & | $info,
 |  |  | $file,
 |  |  | $type
 | ) |  |

Implements hook_system_info_alter().

Goes through a list of all modules that provide a field type, and makes them required if there are any active fields of that type.

Definition at line 362 of file field.module.

References $info, field_read_fields(), module_exists(), module_hook(), t(), and url().

field_theme ( )

Implements hook_theme().

Definition at line 322 of file field.module.

field_ui_menu_load | ( | $field_name,
 |  | $entity_type,
 |  | $bundle_name,
 |  | $bundle_pos,
 |  | $map
 | ) |

Menu loader; Load a field instance based on field and bundle name.

Parameters
$field_name | The name of the field, as contained in the path.
$entity_type | The name of the entity.
$bundle_name | The name of the bundle, as contained in the path.
$bundle_pos | The position of $bundle_name in $map.
$map | The translated menu router path argument map.
Returns
The field instance array.

Definition at line 221 of file field_ui.module.

References field_extract_bundle(), field_info_field(), and field_info_instance().

field_view_field | ( | $entity_type,
 |  | $entity,
 |  | $field_name,
 |  | $display = array(),
 |  | $langcode = NULL
 | ) |

Returns a renderable array for the value of a single field in an entity.

The resulting output is a fully themed field with label and multiple values.

This function can be used by third-party modules that need to output an isolated field.

  • Do not use inside node (or any other entity) templates; use render($content[FIELD_NAME]) instead.
  • Do not use to display all fields in an entity; use field_attach_prepare_view() and field_attach_view() instead.
  • The field_view_value() function can be used to output a single formatted field value, without label or wrapping field markup.

The function takes care of invoking the prepare_view steps. It also respects field access permissions.

Parameters
$entity_type | The type of $entity; e.g., 'node' or 'user'.
$entity | The entity containing the field to display. Must at least contain the id key and the field data to display.
$field_name | The name of the field to display.
$display Can be either:
  • The name of a view mode. The field will be displayed according to the display settings specified for this view mode in the $instance definition for the field in the entity's bundle. If no display settings are found for the view mode, the settings for the 'default' view mode will be used.
  • An array of display settings, as found in the 'display' entry of $instance definitions. The following key/value pairs are allowed:
    • label: (string) Position of the label. The default 'field' theme implementation supports the values 'inline', 'above' and 'hidden'. Defaults to 'above'.
    • type: (string) The formatter to use. Defaults to the 'default_formatter' for the field type, specified in hook_field_info(). The default formatter will also be used if the requested formatter is not available.
    • settings: (array) Settings specific to the formatter. Defaults to the formatter's default settings, specified in hook_field_formatter_info().
    • weight: (float) The weight to assign to the renderable element. Defaults to 0.
$langcode | (Optional) The language the field values are to be shown in. The site's current language fallback logic will be applied no values are available for the language. If no language is provided the current language will be used.
Returns
A renderable array for the field value.
See Also
field_view_value()

Definition at line 870 of file field.module.

References $output, _field_info_field_cache(), _field_invoke_default(), _field_invoke_multiple(), _field_invoke_multiple_default(), drupal_alter(), entity_extract_ids(), field_info_field(), and field_language().

Referenced by field_view_value(), and hook_tokens_alter().

field_view_mode_settings | ( | $entity_type,
 |  | $bundle
 | ) |

Returns view mode settings in a given bundle.

Parameters
$entity_type | The type of entity; e.g. 'node' or 'user'.
$bundle | The bundle name to return view mode settings for.
Returns
An array keyed by view mode, with the following key/value pairs:
  • custom_settings: Boolean specifying whether the view mode uses a dedicated set of display options (TRUE), or the 'default' options (FALSE). Defaults to FALSE.

Definition at line 617 of file field.module.

References drupal_static(), entity_get_info(), and field_bundle_settings().

Referenced by _field_ui_view_mode_menu_access(), field_extra_fields_get_display(), field_get_display(), field_ui_display_overview_form(), field_ui_display_overview_form_submit(), FieldInfo::prepareInstance(), and taxonomy_term_build_content().

field_view_value | ( | $entity_type,
 |  | $entity,
 |  | $field_name,
 |  | $item,
 |  | $display = array(),
 |  | $langcode = NULL
 | ) |

Returns a renderable array for a single field value.

Parameters
$entity_type | The type of $entity; e.g., 'node' or 'user'.
$entity | The entity containing the field to display. Must at least contain the id key and the field data to display.
$field_name | The name of the field to display.
$item | The field value to display, as found in $entity->field_name[$langcode][$delta].
$display | Can be either the name of a view mode, or an array of display settings. See field_view_field() for more information.
$langcode | (Optional) The language of the value in $item. If not provided, the current language will be assumed.
Returns
A renderable array for the field value.

Definition at line 792 of file field.module.

References $output, field_info_field(), field_language(), and field_view_field().

template_preprocess_field | ( | & | $variables,
 |  |  | $hook
 | ) |  |

Theme preprocess function for theme_field() and field.tpl.php.

See Also
theme_field()
field.tpl.php

Definition at line 1027 of file field.module.

References check_plain().

template_process_field | ( | & | $variables,
 |  |  | $hook
 | ) |  |

Theme process function for theme_field() and field.tpl.php.

See Also
theme_field()
field.tpl.php

Definition at line 1083 of file field.module.

References drupal_attributes().

Variable Documentation

const FIELD_BEHAVIOR_CUSTOM 0x0004

Value for field API indicating a widget can receive several field values.

See Also
hook_field_widget_info()

Definition at line 262 of file field.module.

Referenced by file_field_widget_info(), image_field_widget_info(), options_field_widget_info(), and taxonomy_field_widget_info().

const FIELD_BEHAVIOR_DEFAULT 0x0002

Value for field API concerning widget default and multiple value settings.

See Also
hook_field_widget_info()

When used in a widget default context, indicates the widget accepts default values. When used in a multiple value context for a widget that allows the input of one single field value, indicates that the widget will be repeated for each value input.

Definition at line 255 of file field.module.

Referenced by field_behaviors_widget(), field_default_form(), field_default_form_errors(), field_ui_field_edit_form(), hook_field_widget_info(), and FieldInfo::prepareInstance().

const FIELD_BEHAVIOR_NONE 0x0001

Value for field API indicating a widget doesn't accept default values.

See Also
hook_field_widget_info()

Definition at line 243 of file field.module.

Referenced by file_field_widget_info(), and image_field_widget_info().

const FIELD_CARDINALITY_UNLIMITED -1

Value for field API indicating a field accepts an unlimited number of values.

Definition at line 236 of file field.module.

Referenced by _field_sort_items(), field_add_more_js(), field_default_validate(), field_multiple_value_form(), field_sql_storage_field_storage_load(), field_sql_storage_field_storage_write(), field_ui_field_edit_form(), file_field_widget_form(), hook_field_storage_load(), hook_field_storage_write(), options_field_widget_form(), standard_install(), system_update_7060(), taxonomy_update_7004(), taxonomy_update_7005(), and theme_field_multiple_value_form().

const FIELD_LOAD_CURRENT 'FIELD_LOAD_CURRENT'

Age argument for loading the most recent version of an entity's field data with field_attach_load().

Definition at line 268 of file field.module.

Referenced by field_attach_load(), field_purge_batch(), field_sql_storage_field_storage_details(), field_sql_storage_field_storage_load(), field_sql_storage_field_storage_query(), file_field_update(), file_file_download(), hook_field_storage_details(), hook_field_storage_details_alter(), hook_field_storage_load(), and hook_field_storage_query().

const FIELD_LOAD_REVISION 'FIELD_LOAD_REVISION'

Age argument for loading the version of an entity's field data specified in the entity with field_attach_load().

Definition at line 274 of file field.module.

Referenced by field_attach_load_revision(), field_sql_storage_field_storage_details(), hook_field_storage_details(), and hook_field_storage_details_alter().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Field Language API

Functions
Field Language API

Functions

field_multilingual_settings_changed ()
field_available_languages ($entity_type, $field)
_field_language_suggestion ($available_languages, $language_suggestion, $field_name)
field_content_languages ()
field_is_translatable ($entity_type, $field)
field_has_translation_handler ($entity_type, $handler=NULL)
field_valid_language ($langcode, $default=TRUE)
field_language ($entity_type, $entity, $field_name=NULL, $langcode=NULL)

Detailed Description

Handling of multilingual fields.

Fields natively implement multilingual support, and all fields use the following structure:

* $entity->{$field_name}[$langcode][$delta][$column_name]
*

Every field can hold a single or multiple value for each language belonging to the available languages set:

  • For untranslatable fields this set only contains LANGUAGE_NONE.
  • For translatable fields this set can contain any language code. By default it is the list returned by field_content_languages(), which contains all installed languages with the addition of LANGUAGE_NONE. This default can be altered by modules implementing hook_field_available_languages_alter().

The available languages for a particular field are returned by field_available_languages(). Whether a field is translatable is determined by calling field_is_translatable(), which checks the $field['translatable'] property returned by field_info_field(), and whether there is at least one translation handler available for the field. A translation handler is a module registering itself via hook_entity_info() to handle field translations.

By default, _field_invoke() and _field_invoke_multiple() are processing a field in all available languages, unless they are given a language suggestion. Based on that suggestion, _field_language_suggestion() determines the languages to act on.

Most field_attach_*() functions act on all available languages, except for the following:

  • field_attach_form() only takes a single language code, specifying which language the field values will be submitted in.
  • field_attach_view() requires the language the entity will be displayed in. Since it is unknown whether a field translation exists for the requested language, the translation handler is responsible for performing one of the following actions:
    • Ignore missing translations, i.e. do not show any field values for the requested language. For example, see locale_field_language_alter().
    • Provide a value in a different language as fallback. By default, the fallback logic is applied separately to each field to ensure that there is a value for each field to display. The field language fallback logic relies on the global language fallback configuration. Therefore, the displayed field values can be in the requested language, but may be different if no values for the requested language are available. The default language fallback rules inspect all the enabled languages ordered by their weight. This behavior can be altered or even disabled by modules implementing hook_field_language_alter(), making it possible to choose the first approach. The display language for each field is returned by field_language().

See Field API for information about the other parts of the Field API.

Function Documentation

_field_language_suggestion | ( | $available_languages,
 |  | $language_suggestion,
 |  | $field_name
 | ) |

Process the given language suggestion based on the available languages.

If a non-empty language suggestion is provided it must appear among the available languages, otherwise it will be ignored.

Parameters
$available_languages | An array of valid language codes.
$language_suggestion | A language code or an array of language codes keyed by field name.
$field_name | The name of the field being processed.
Returns
An array of valid language codes.

Definition at line 131 of file field.multilingual.inc.

Referenced by _field_invoke(), and _field_invoke_multiple().

field_available_languages | ( | $entity_type,
 |  | $field
 | ) |

Collects the available languages for the given entity type and field.

If the given field has language support enabled, an array of available languages will be returned, otherwise only LANGUAGE_NONE will be returned. Since the default value for a 'translatable' entity property is FALSE, we ensure that only entities that are able to handle translations actually get translatable fields.

Parameters
$entity_type | The type of the entity the field is attached to, e.g. 'node' or 'user'.
$field | A field structure.
Returns
An array of valid language codes.

Definition at line 89 of file field.multilingual.inc.

References drupal_alter(), drupal_static(), field_content_languages(), field_is_translatable(), and LANGUAGE_NONE.

Referenced by _field_invoke(), _field_invoke_multiple(), field_sql_storage_field_storage_load(), field_sql_storage_field_storage_write(), hook_field_storage_load(), and hook_field_storage_write().

field_content_languages ( )

Returns available content languages.

The languages that may be associated to fields include LANGUAGE_NONE.

Returns
An array of language codes.

Definition at line 157 of file field.multilingual.inc.

References language_list(), and LANGUAGE_NONE.

Referenced by field_available_languages(), and field_valid_language().

field_has_translation_handler | ( | $entity_type,
 |  | $handler = NULL
 | ) |

Checks if a module is registered as a translation handler for a given entity.

If no handler is passed, simply check if there is any translation handler enabled for the given entity type.

Parameters
$entity_type | The type of the entity whose fields are to be translated.
$handler | (optional) The name of the handler to be checked. Defaults to NULL.
Returns
TRUE, if the given handler is allowed to manage field translations. If no handler is passed, TRUE means there is at least one registered translation handler.

Definition at line 195 of file field.multilingual.inc.

References entity_get_info().

Referenced by field_is_translatable(), field_language(), hook_field_language_alter(), locale_field_entity_form_submit(), and locale_field_language_alter().

field_is_translatable | ( | $entity_type,
 |  | $field
 | ) |

Checks whether a field has language support.

A field has language support enabled if its 'translatable' property is set to TRUE, and its entity type has at least one translation handler registered.

Parameters
$entity_type | The type of the entity the field is attached to.
$field | A field data structure.
Returns
TRUE if the field can be translated.

Definition at line 175 of file field.multilingual.inc.

References field_has_translation_handler().

Referenced by comment_submit(), and field_available_languages().

field_language | ( | $entity_type,
 |  | $entity,
 |  | $field_name = NULL,
 |  | $langcode = NULL
 | ) |

Returns the display language for the fields attached to the given entity.

The actual language for each given field is determined based on the requested language and the actual data available in the fields themselves. If there is no registered translation handler for the given entity type, the display language to be used is just LANGUAGE_NONE, as no other language code is allowed by field_available_languages(). If translation handlers are found, we let modules provide alternative display languages for fields not having the requested language available. Core language fallback rules are provided by locale_field_language_fallback() which is called by locale_field_language_alter().

Parameters
$entity_type | The type of $entity.
$entity | The entity to be displayed.
$field_name | (optional) The name of the field to be displayed. Defaults to NULL. If no value is specified, the display languages for every field attached to the given entity will be returned.
$langcode | (optional) The language code $entity has to be displayed in. Defaults to NULL. If no value is given the current language will be used.
Returns
A language code if a field name is specified, an array of language codes keyed by field name otherwise.

Definition at line 266 of file field.multilingual.inc.

References drupal_alter(), drupal_static(), entity_extract_ids(), field_has_translation_handler(), field_info_instances(), field_valid_language(), and LANGUAGE_NONE.

Referenced by comment_tokens(), field_attach_prepare_view(), field_attach_view(), field_get_items(), field_view_field(), field_view_value(), and node_tokens().

field_multilingual_settings_changed ( )

Implements hook_multilingual_settings_changed().

Definition at line 68 of file field.multilingual.inc.

References field_info_cache_clear().

field_valid_language | ( | $langcode,
 |  | $default = TRUE
 | ) |

Ensures that a given language code is valid.

Checks whether the given language is one of the enabled languages. Otherwise, it returns the current, global language; or the site's default language, if the additional parameter $default is TRUE.

Parameters
$langcode | The language code to validate.
$default | Whether to return the default language code or the current language code in case $langcode is invalid.
Returns
A valid language code.

Definition at line 228 of file field.multilingual.inc.

References field_content_languages(), and language_default().

Referenced by field_attach_form(), and field_language().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: File module public API functions

Functions
File module public API functions

Functions

file_get_file_references ($file, $field=NULL, $age=FIELD_LOAD_REVISION, $field_type= 'file')

Detailed Description

These functions may be used to determine if and where a file is in use.

Function Documentation

file_get_file_references | ( | $file,
 |  | $field = NULL,
 |  | $age = FIELD_LOAD_REVISION,
 |  | $field_type = 'file'
 | ) |

Retrieves a list of references to a file.

Parameters
$file | A file object.
$field | (optional) A field array to be used for this check. If given, limits the reference check to the given field.
$age | (optional) A constant that specifies which references to count. Use FIELD_LOAD_REVISION to retrieve all references within all revisions or FIELD_LOAD_CURRENT to retrieve references only in the current revisions.
$field_type | (optional) The name of a field type. If given, limits the reference check to fields of the given type.
Returns
An integer value.

Definition at line 993 of file file.module.

References drupal_static(), and field_info_fields().

Referenced by file_file_download().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Standard filters

Functions
Standard filters

Functions

filter_filter_info ()
_filter_html_settings ($form, &$form_state, $filter, $format, $defaults)
_filter_html ($text, $filter)
_filter_html_tips ($filter, $format, $long=FALSE)
_filter_url_settings ($form, &$form_state, $filter, $format, $defaults)
_filter_url ($text, $filter)
_filter_url_parse_full_links ($match)
_filter_url_parse_email_links ($match)
_filter_url_parse_partial_links ($match)
_filter_url_escape_comments ($match, $escape=NULL)
_filter_url_trim ($text, $length=NULL)
_filter_url_tips ($filter, $format, $long=FALSE)
_filter_htmlcorrector ($text)
_filter_autop ($text)
_filter_autop_tips ($filter, $format, $long=FALSE)
_filter_html_escape ($text)
_filter_html_escape_tips ($filter, $format, $long=FALSE)

Detailed Description

Filters implemented by the Filter module.

Function Documentation

_filter_autop ( $text )

Implements callback_filter_process().

Converts line breaks into

and
in an intelligent fashion.

Based on: http://photomatt.net/scripts/autop

Definition at line 1686 of file filter.module.

References $output.

_filter_autop_tips | ( | $filter,
 |  | $format,
 |  | $long = FALSE
 | ) |

Implements callback_filter_tips().

Provides help for the auto-paragraph filter.

See Also
filter_filter_info()

Definition at line 1755 of file filter.module.

References t().

_filter_html | ( | $text,
 |  | $filter
 | ) |

Implements callback_filter_process().

Provides filtering of input into accepted HTML.

Definition at line 1291 of file filter.module.

References $links, filter_dom_load(), filter_dom_serialize(), and filter_xss().

_filter_html_escape ( $text )

Implements callback_filter_process().

Escapes all HTML tags, so they will be visible instead of being effective.

Definition at line 1769 of file filter.module.

References check_plain().

_filter_html_escape_tips | ( | $filter,
 |  | $format,
 |  | $long = FALSE
 | ) |

Implements callback_filter_tips().

Provides help for the HTML escaping filter.

See Also
filter_filter_info()

Definition at line 1780 of file filter.module.

References t().

_filter_html_settings | ( |  | $form,
 |  | & | $form_state,
 |  |  | $filter,
 |  |  | $format,
 |  |  | $defaults
 | ) |  |

Implements callback_filter_settings().

Filter settings callback for the HTML content filter.

Definition at line 1263 of file filter.module.

References t().

_filter_html_tips | ( | $filter,
 |  | $format,
 |  | $long = FALSE
 | ) |

Implements callback_filter_tips().

Provides help for the HTML filter.

See Also
filter_filter_info()

Definition at line 1314 of file filter.module.

References $base_url, $header, $output, check_plain(), t(), theme(), and variable_get().

_filter_htmlcorrector ( $text )

Implements callback_filter_process().

Scans the input and makes sure that HTML tags are properly closed.

Definition at line 1675 of file filter.module.

References filter_dom_load(), and filter_dom_serialize().

Referenced by drupal_html_to_text(), and text_summary().

_filter_url | ( | $text,
 |  | $filter
 | ) |

Implements callback_filter_process().

Converts text into hyperlinks automatically.

This filter identifies and makes clickable three types of "links".

  • URLs like http://example.com.
  • E-mail addresses like name@.nosp@m.exam.nosp@m.ple.c.nosp@m.om.
  • Web addresses without the "http://" protocol defined, like www.example.com. Each type must be processed separately, as there is no one regular expression that could possibly match all of the cases in one pass.

Definition at line 1444 of file filter.module.

References _filter_url_escape_comments(), _filter_url_trim(), and variable_get().

_filter_url_escape_comments | ( | $match,
 |  | $escape = NULL
 | ) |

Escapes the contents of HTML comments.

Callback for preg_replace_callback() within _filter_url().

Parameters
$match | An array containing matches to replace from preg_replace_callback(), whereas $match[1] is expected to contain the content to be filtered.
$escape | (optional) A Boolean indicating whether to escape (TRUE) or unescape comments (FALSE). Defaults to NULL, indicating neither. If TRUE, statically cached $comments are reset.

Definition at line 1615 of file filter.module.

References $content.

Referenced by _filter_url().

_filter_url_parse_email_links ( $match )

Makes links out of e-mail addresses.

Callback for preg_replace_callback() within _filter_url().

Definition at line 1577 of file filter.module.

References _filter_url_trim(), check_plain(), and decode_entities().

_filter_url_parse_full_links ( $match )

Makes links out of absolute URLs.

Callback for preg_replace_callback() within _filter_url().

Definition at line 1562 of file filter.module.

References _filter_url_trim(), check_plain(), and decode_entities().

_filter_url_parse_partial_links ( $match )

Makes links out of domain names starting with "www."

Callback for preg_replace_callback() within _filter_url().

Definition at line 1592 of file filter.module.

References _filter_url_trim(), check_plain(), and decode_entities().

_filter_url_settings | ( |  | $form,
 |  | & | $form_state,
 |  |  | $filter,
 |  |  | $format,
 |  |  | $defaults
 | ) |  |

Implements callback_filter_settings().

Provides settings for the URL filter.

See Also
filter_filter_info()

Definition at line 1416 of file filter.module.

References t().

_filter_url_tips | ( | $filter,
 |  | $format,
 |  | $long = FALSE
 | ) |

Implements callback_filter_tips().

Provides help for the URL filter.

See Also
filter_filter_info()

Definition at line 1666 of file filter.module.

References t().

_filter_url_trim | ( | $text,
 |  | $length = NULL
 | ) |

Shortens long URLs to http://www.example.com/long/url...

Definition at line 1645 of file filter.module.

Referenced by _filter_url(), _filter_url_parse_email_links(), _filter_url_parse_full_links(), and _filter_url_parse_partial_links().

filter_filter_info ( )

Implements hook_filter_info().

Definition at line 1217 of file filter.module.

References t().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Language administration interface

Functions
Language administration interface

Functions

locale_languages_overview_form ()
locale_languages_overview_form_submit ($form, &$form_state)
locale_languages_add_screen ()
locale_languages_predefined_form ($form)
locale_languages_custom_form ($form)
locale_languages_edit_form ($form, &$form_state, $langcode)
_locale_languages_common_controls (&$form, $language=NULL)
locale_languages_predefined_form_validate ($form, &$form_state)
locale_languages_predefined_form_submit ($form, &$form_state)
locale_languages_edit_form_validate ($form, &$form_state)
locale_languages_edit_form_submit ($form, &$form_state)
locale_languages_delete_form ($form, &$form_state, $langcode)
locale_languages_delete_form_submit ($form, &$form_state)
locale_languages_configure_form ()
_locale_languages_configure_form_language_table (&$form, $type)
locale_languages_configure_form_submit ($form, &$form_state)
locale_language_providers_url_form ($form, &$form_state)
locale_language_providers_session_form ($form, &$form_state)

Detailed Description

Administration interface for languages.

These functions provide the user interface to show, add, edit and delete languages as well as providing options for language negotiation.

Function Documentation

_locale_languages_common_controls | ( | & | $form,
 |  |  | $language = NULL
 | ) |  |

Common elements of the language addition and editing form.

Parameters
$form | A parent form item (or empty array) to add items below.
$language | Language object to edit.

Definition at line 260 of file locale.admin.inc.

References LANGUAGE_LTR, LANGUAGE_RTL, and t().

Referenced by locale_languages_custom_form(), and locale_languages_edit_form().

_locale_languages_configure_form_language_table | ( | & | $form,
 |  |  | $type
 | ) |  |

Helper function to build a language provider table.

Definition at line 525 of file locale.admin.inc.

References $info, check_plain(), filter_xss_admin(), LANGUAGE_NEGOTIATION_DEFAULT, language_provider_weight(), t(), and variable_get().

Referenced by locale_languages_configure_form().

locale_language_providers_session_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

The URL language provider configuration form.

Definition at line 727 of file locale.admin.inc.

References system_settings_form(), t(), and variable_get().

locale_language_providers_url_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

The URL language provider configuration form.

Definition at line 707 of file locale.admin.inc.

References LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN, LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX, system_settings_form(), t(), and variable_get().

locale_languages_add_screen ( )

User interface for the language addition screen.

Definition at line 181 of file locale.admin.inc.

References drupal_get_form().

locale_languages_configure_form ( )

Setting for language negotiation options

Definition at line 498 of file locale.admin.inc.

References _locale_languages_configure_form_language_table(), DRUPAL_ROOT, language_negotiation_info(), language_types_configurable(), language_types_info(), and t().

locale_languages_configure_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for language negotiation settings.

Definition at line 675 of file locale.admin.inc.

References drupal_set_message(), LANGUAGE_NEGOTIATION_DEFAULT, language_negotiation_set(), language_types_set(), t(), and variable_set().

locale_languages_custom_form ( $form )

Custom language addition form.

Definition at line 210 of file locale.admin.inc.

References _locale_languages_common_controls(), and t().

locale_languages_delete_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $langcode
 | ) |  |

User interface for the language deletion confirmation screen.

Definition at line 432 of file locale.admin.inc.

References confirm_form(), drupal_exit(), drupal_goto(), drupal_not_found(), drupal_set_message(), language_default(), language_list(), name, and t().

locale_languages_delete_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process language deletion submissions.

Definition at line 461 of file locale.admin.inc.

References _locale_rebuild_js(), cache_clear_all(), db_delete(), db_update(), drupal_set_message(), language_list(), module_invoke_all(), name, t(), variable_get(), variable_set(), and watchdog().

locale_languages_edit_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $langcode
 | ) |  |

Editing screen for a particular language.

Parameters
$langcode Language code of the language to edit.

Definition at line 234 of file locale.admin.inc.

References _locale_languages_common_controls(), db_query(), drupal_exit(), drupal_not_found(), and t().

locale_languages_edit_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process the language editing form submission.

Definition at line 404 of file locale.admin.inc.

References db_update(), language_default(), and variable_set().

locale_languages_edit_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate the language editing form. Reused for custom language addition too.

Definition at line 375 of file locale.admin.inc.

References check_plain(), db_query(), form_set_error(), language_default(), and t().

Referenced by locale_languages_predefined_form_validate().

locale_languages_overview_form ( )

User interface for the language overview screen.

Definition at line 20 of file locale.admin.inc.

References check_plain(), drupal_static_reset(), language_default(), language_list(), LANGUAGE_RTL, and t().

locale_languages_overview_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process language overview form submissions, updating existing languages.

Definition at line 120 of file locale.admin.inc.

References cache_clear_all(), db_update(), drupal_set_message(), language_default(), language_list(), LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX, module_invoke_all(), t(), variable_get(), and variable_set().

locale_languages_predefined_form ( $form )

Predefined language setup form.

Definition at line 190 of file locale.admin.inc.

References _locale_prepare_predefined_list(), and t().

locale_languages_predefined_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process the language addition form submission.

Definition at line 348 of file locale.admin.inc.

References _locale_get_predefined_list(), batch_set(), DRUPAL_ROOT, drupal_set_message(), locale_add_language(), locale_batch_by_language(), t(), and url().

locale_languages_predefined_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate the language addition form.

Definition at line 324 of file locale.admin.inc.

References _locale_get_predefined_list(), db_query(), DRUPAL_ROOT, form_set_error(), locale_languages_edit_form_validate(), and t().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Translation administration screens

Functions
Translation administration screens

Functions

locale_translate_overview_screen ()
locale_translate_seek_screen ()
locale_translation_filters ()
locale_translation_filter_form_validate ($form, &$form_state)
locale_translation_filter_form_submit ($form, &$form_state)
locale_translate_import_form ($form)
locale_translate_import_form_submit ($form, &$form_state)
locale_translate_export_screen ()
locale_translate_export_po_form ($form, &$form_state, $names)
locale_translate_export_pot_form ()
locale_translate_export_po_form_submit ($form, &$form_state)

Detailed Description

End of "locale-language-administration"

Screens for translation administration.

These functions provide various screens as administration interface to import, export and view translations.

Function Documentation

locale_translate_export_po_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $names
 | ) |  |

Form to export PO files for the languages provided.

Parameters
$names An associate array with localized language names

Definition at line 1040 of file locale.admin.inc.

References module_invoke_all(), and t().

locale_translate_export_po_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process a translation (or template) export form submission.

Definition at line 1083 of file locale.admin.inc.

References _locale_export_get_strings(), _locale_export_po(), _locale_export_po_generate(), and language_list().

locale_translate_export_pot_form ( )

Translation template export form.

Definition at line 1062 of file locale.admin.inc.

References module_invoke_all(), and t().

locale_translate_export_screen ( )

User interface for the translation export screen.

Definition at line 1018 of file locale.admin.inc.

References $output, drupal_get_form(), drupal_render(), drupal_static_reset(), and locale_language_list().

locale_translate_import_form ( $form )

User interface for the translation import screen.

Definition at line 928 of file locale.admin.inc.

References _locale_prepare_predefined_list(), drupal_static_reset(), LOCALE_IMPORT_KEEP, LOCALE_IMPORT_OVERWRITE, locale_language_list(), module_invoke_all(), and t().

locale_translate_import_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process the locale import form submission.

Definition at line 982 of file locale.admin.inc.

References _locale_get_predefined_list(), _locale_import_po(), DRUPAL_ROOT, drupal_set_message(), drupal_static_reset(), file_save_upload(), language_list(), locale_add_language(), t(), watchdog(), and WATCHDOG_ERROR.

locale_translate_overview_screen ( )

Overview screen for translations.

Definition at line 756 of file locale.admin.inc.

References $name, db_query(), drupal_static_reset(), language_list(), module_invoke_all(), t(), and theme().

locale_translate_seek_screen ( )

String search screen.

Definition at line 793 of file locale.admin.inc.

References $output, _locale_translate_seek(), drupal_add_css(), drupal_get_form(), drupal_get_path(), and drupal_render().

locale_translation_filter_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process result from locale translation filter form.

Definition at line 906 of file locale.admin.inc.

References $name, $op, locale_translation_filters(), and t().

locale_translation_filter_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate result from locale translation filter form.

Definition at line 897 of file locale.admin.inc.

References form_set_error(), and t().

locale_translation_filters ( )

List locale translation filters that can be applied.

Definition at line 806 of file locale.admin.inc.

References drupal_static_reset(), locale_language_list(), module_invoke_all(), and t().

Referenced by locale_translation_filter_form(), and locale_translation_filter_form_submit().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Translation editing/deletion interface

Functions
Translation editing/deletion interface

Functions

locale_translate_edit_form ($form, &$form_state, $lid)
locale_translate_edit_form_validate ($form, &$form_state)
locale_translate_edit_form_submit ($form, &$form_state)
locale_translate_delete_page ($lid)
locale_translate_delete_form ($form, &$form_state, $source)
locale_translate_delete_form_submit ($form, &$form_state)

Detailed Description

End of "locale-translate-administration-screens"

Edit and delete translation strings.

These functions provide the user interface to edit and delete translation strings.

Function Documentation

locale_translate_delete_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $source
 | ) |  |

User interface for the string deletion confirmation screen.

Definition at line 1251 of file locale.admin.inc.

References confirm_form(), and t().

locale_translate_delete_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process string deletion submissions.

Definition at line 1259 of file locale.admin.inc.

References _locale_invalidate_js(), cache_clear_all(), db_delete(), drupal_set_message(), and t().

locale_translate_delete_page ( $lid )

String deletion confirmation page.

Definition at line 1241 of file locale.admin.inc.

References db_query(), drupal_get_form(), and MENU_NOT_FOUND.

locale_translate_edit_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $lid
 | ) |  |

User interface for string editing.

Definition at line 1108 of file locale.admin.inc.

References check_plain(), db_query(), drupal_goto(), drupal_set_message(), language_default(), language_list(), and t().

locale_translate_edit_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process string editing form submissions.

Saves all translations of one string submitted from a form.

Definition at line 1191 of file locale.admin.inc.

References $value, _locale_invalidate_js(), cache_clear_all(), db_delete(), db_insert(), db_query(), db_update(), drupal_set_message(), and t().

locale_translate_edit_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate string editing form submissions.

Definition at line 1175 of file locale.admin.inc.

References $value, form_set_error(), locale_string_is_safe(), t(), watchdog(), and WATCHDOG_WARNING.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Node API Hooks

Functions
Node API Hooks

Functions

hook_node_delete ($node)
hook_node_revision_delete ($node)
hook_node_insert ($node)
hook_node_load ($nodes, $types)
hook_node_prepare ($node)
hook_node_search_result ($node)
hook_node_presave ($node)
hook_node_update ($node)
hook_node_update_index ($node)
hook_node_validate ($node, $form, &$form_state)
hook_node_submit ($node, $form, &$form_state)
hook_node_view ($node, $view_mode, $langcode)
hook_node_view_alter (&$build)
hook_node_info ()
hook_ranking ()
hook_delete ($node)
hook_prepare ($node)
hook_form ($node, &$form_state)
hook_insert ($node)
hook_load ($nodes)
hook_update ($node)
hook_validate ($node, $form, &$form_state)
hook_view ($node, $view_mode)

Detailed Description

Functions to define and modify content types.

Each content type is maintained by a primary module, which is either node.module (for content types created in the user interface) or the module that implements hook_node_info() to define the content type.

During node operations (create, update, view, delete, etc.), there are several sets of hooks that get invoked to allow modules to modify the base node operation:

  • Node-type-specific hooks: These hooks are only invoked on the primary module, using the "base" return component of hook_node_info() as the function prefix. For example, poll.module defines the base for the Poll content type as "poll", so during creation of a poll node, hook_insert() is only invoked by calling poll_insert().
  • All-module hooks: This set of hooks is invoked on all implementing modules, to allow other modules to modify what the primary node module is doing. For example, hook_node_insert() is invoked on all modules when creating a poll node.
  • Field hooks: Hooks related to the fields attached to the node. These are invoked from the field operations functions described below, and can be either field-type-specific or all-module hooks.
  • Entity hooks: Generic hooks for "entity" operations. These are always invoked on all modules.

Here is a list of the node and entity hooks that are invoked, field operations, and other steps that take place during node operations:

  • Creating a new node (calling node_save() on a new node):
    • field_attach_presave()
    • hook_node_presave() (all)
    • hook_entity_presave() (all)
    • Node and revision records are written to the database
    • hook_insert() (node-type-specific)
    • field_attach_insert()
    • hook_node_insert() (all)
    • hook_entity_insert() (all)
    • hook_node_access_records() (all)
    • hook_node_access_records_alter() (all)
  • Updating an existing node (calling node_save() on an existing node):
    • field_attach_presave()
    • hook_node_presave() (all)
    • hook_entity_presave() (all)
    • Node and revision records are written to the database
    • hook_update() (node-type-specific)
    • field_attach_update()
    • hook_node_update() (all)
    • hook_entity_update() (all)
    • hook_node_access_records() (all)
    • hook_node_access_records_alter() (all)
  • Loading a node (calling node_load(), node_load_multiple() or entity_load() with $entity_type of 'node'):
    • Node and revision information is read from database.
    • hook_load() (node-type-specific)
    • field_attach_load_revision() and field_attach_load()
    • hook_entity_load() (all)
    • hook_node_load() (all)
  • Viewing a single node (calling node_view() - note that the input to node_view() is a loaded node, so the Loading steps above are already done):
    • hook_view() (node-type-specific)
    • field_attach_prepare_view()
    • hook_entity_prepare_view() (all)
    • field_attach_view()
    • hook_node_view() (all)
    • hook_entity_view() (all)
    • hook_node_view_alter() (all)
    • hook_entity_view_alter() (all)
  • Viewing multiple nodes (calling node_view_multiple() - note that the input to node_view_multiple() is a set of loaded nodes, so the Loading steps above are already done):
    • field_attach_prepare_view()
    • hook_entity_prepare_view() (all)
    • hook_view() (node-type-specific)
    • field_attach_view()
    • hook_node_view() (all)
    • hook_entity_view() (all)
    • hook_node_view_alter() (all)
    • hook_entity_view_alter() (all)
  • Deleting a node (calling node_delete() or node_delete_multiple()):
    • Node is loaded (see Loading section above)
    • hook_delete() (node-type-specific)
    • hook_node_delete() (all)
    • hook_entity_delete() (all)
    • field_attach_delete()
    • Node and revision information are deleted from database
  • Deleting a node revision (calling node_revision_delete()):
    • Node is loaded (see Loading section above)
    • Revision information is deleted from database
    • hook_node_revision_delete() (all)
    • field_attach_delete_revision()
  • Preparing a node for editing (calling node_form() - note that if it is an existing node, it will already be loaded; see the Loading section above):
    • hook_prepare() (node-type-specific)
    • hook_node_prepare() (all)
    • hook_form() (node-type-specific)
    • field_attach_form()
  • Validating a node during editing form submit (calling node_form_validate()):
    • hook_validate() (node-type-specific)
    • hook_node_validate() (all)
    • field_attach_form_validate()
  • Searching (calling node_search_execute()):
    • hook_ranking() (all)
    • Query is executed to find matching nodes
    • Resulting node is loaded (see Loading section above)
    • Resulting node is prepared for viewing (see Viewing a single node above)
    • comment_node_update_index() is called.
    • hook_node_search_result() (all)
  • Search indexing (calling node_update_index()):
    • Node is loaded (see Loading section above)
    • Node is prepared for viewing (see Viewing a single node above)
    • hook_node_update_index() (all)

Function Documentation

hook_delete ( $node )

Respond to node deletion.

This hook is invoked only on the module that defines the node's content type (use hook_node_delete() to respond to all node deletions).

This hook is invoked from node_delete_multiple() after the node has been removed from the node table in the database, before hook_node_delete() is invoked, and before field_attach_delete() is called.

Parameters
$node The node that is being deleted.

Definition at line 1045 of file node.api.php.

References db_delete().

hook_form | ( |  | $node,
 |  | & | $form_state
 | ) |  |

Display a node editing form.

This hook, implemented by node modules, is called to retrieve the form that is displayed to create or edit a node. This form is displayed at path node/add/[node type] or node/[node ID]/edit.

The submit and preview buttons, administrative and display controls, and sections added by other modules (such as path settings, menu settings, comment settings, and fields managed by the Field UI module) are displayed automatically by the node module. This hook just needs to return the node title and form editing fields specific to the node type.

Parameters
$node | The node being added or edited.
$form_state | The form state array.
Returns
An array containing the title and any custom form elements to be displayed in the node editing form.

Definition at line 1107 of file node.api.php.

References check_plain(), node_type_get_type(), and t().

hook_insert ( $node )

Respond to creation of a new node.

This hook is invoked only on the module that defines the node's content type (use hook_node_insert() to act on all node insertions).

This hook is invoked from node_save() after the node is inserted into the node table in the database, before field_attach_insert() is called, and before hook_node_insert() is invoked.

Parameters
$node The node that is being created.

Definition at line 1153 of file node.api.php.

References db_insert().

hook_load ( $nodes )

Act on nodes being loaded from the database.

This hook is invoked only on the module that defines the node's content type (use hook_node_load() to respond to all node loads).

This hook is invoked during node loading, which is handled by entity_load(), via classes NodeController and DrupalDefaultEntityController. After the node information is read from the database or the entity cache, hook_load() is invoked on the node's content type module, then field_attach_node_revision() or field_attach_load() is called, then hook_entity_load() is invoked on all implementing modules, and finally hook_node_load() is invoked on all implementing modules.

This hook should only be used to add information that is not in the node or node revisions table, not to replace information that is in these tables (which could interfere with the entity cache). For performance reasons, information for all available nodes should be loaded in a single query where possible.

Parameters
$nodes An array of the nodes being loaded, keyed by nid.

For a detailed usage example, see node_example.module.

Definition at line 1189 of file node.api.php.

References db_query().

hook_node_delete ( $node )

Respond to node deletion.

This hook is invoked from node_delete_multiple() after the type-specific hook_delete() has been invoked, but before hook_entity_delete and field_attach_delete() are called, and before the node is removed from the node table in the database.

Parameters
$node The node that is being deleted.

Definition at line 472 of file node.api.php.

References db_delete().

hook_node_info ( )

Define module-provided node types.

This hook allows a module to define one or more of its own node types. For example, the blog module uses it to define a blog node-type named "Blog entry." The name and attributes of each desired node type are specified in an array returned by the hook.

Only module-provided node types should be defined through this hook. User- provided (or 'custom') node types should be defined only in the 'node_type' database table, and should be maintained by using the node_type_save() and node_type_delete() functions.

Returns
An array of information defining the module's node types. The array contains a sub-array for each node type, with the machine-readable type name as the key. Each sub-array has up to 10 attributes. Possible attributes:
  • name: (required) The human-readable name of the node type.
  • base: (required) The base string used to construct callbacks corresponding to this node type (for example, if base is defined as example_foo, then example_foo_insert will be called when inserting a node of that type). This string is usually the name of the module, but not always.
  • description: (required) A brief description of the node type.
  • help: (optional) Help information shown to the user when creating a node of this type.
  • has_title: (optional) A Boolean indicating whether or not this node type has a title field.
  • title_label: (optional) The label for the title field of this content type.
  • locked: (optional) A Boolean indicating whether the administrator can change the machine name of this type. FALSE = changeable (not locked), TRUE = unchangeable (locked).

The machine name of a node type should contain only letters, numbers, and underscores. Underscores will be converted into hyphens for the purpose of constructing URLs.

All attributes of a node type that are defined through this hook (except for 'locked') can be edited by a site administrator. This includes the machine-readable name of a node type, if 'locked' is set to FALSE.

Definition at line 914 of file node.api.php.

References t().

hook_node_insert ( $node )

Respond to creation of a new node.

This hook is invoked from node_save() after the database query that will insert the node into the node table is scheduled for execution, after the type-specific hook_insert() is invoked, and after field_attach_insert() is called.

Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the save operation is entirely completed and node_save() goes out of scope. You should not rely on data in the database at this time as it is not updated yet. You should also note that any write/update database queries executed from this hook are also not committed immediately. Check node_save() and db_transaction() for more info.

Parameters
$node The node that is being created.

Definition at line 517 of file node.api.php.

References db_insert().

hook_node_load | ( | $nodes,
 |  | $types
 | ) |

Act on arbitrary nodes being loaded from the database.

This hook should be used to add information that is not in the node or node revisions table, not to replace information that is in these tables (which could interfere with the entity cache). For performance reasons, information for all available nodes should be loaded in a single query where possible.

This hook is invoked during node loading, which is handled by entity_load(), via classes NodeController and DrupalDefaultEntityController. After the node information is read from the database or the entity cache, hook_load() is invoked on the node's content type module, then field_attach_load_revision() or field_attach_load() is called, then hook_entity_load() is invoked on all implementing modules, and finally hook_node_load() is invoked on all implementing modules.

Parameters
$nodes | An array of the nodes being loaded, keyed by nid.
$types | An array containing the node types present in $nodes. Allows for an early return for modules that only support certain node types. However, if your module defines a content type, you can use hook_load() to respond to loading of just that content type.

For a detailed usage example, see nodeapi_example.module.

Definition at line 554 of file node.api.php.

References db_query().

hook_node_prepare ( $node )

Act on a node object about to be shown on the add/edit form.

This hook is invoked from node_object_prepare() after the type-specific hook_prepare() is invoked.

Parameters
$node The node that is about to be shown on the add/edit form.

Definition at line 642 of file node.api.php.

References COMMENT_NODE_OPEN, and variable_get().

hook_node_presave ( $node )

Act on a node being inserted or updated.

This hook is invoked from node_save() before the node is saved to the database.

Parameters
$node The node that is being inserted or updated.

Definition at line 684 of file node.api.php.

hook_node_revision_delete ( $node )

Respond to deletion of a node revision.

This hook is invoked from node_revision_delete() after the revision has been removed from the node_revision table, and before field_attach_delete_revision() is called.

Parameters
$node The node revision (node object) that is being deleted.

Definition at line 490 of file node.api.php.

References db_delete().

hook_node_search_result ( $node )

Act on a node being displayed as a search result.

This hook is invoked from node_search_execute(), after node_load() and node_view() have been called.

Parameters
$node The node being displayed in a search result.
Returns
array Extra information to be displayed with search result. This information should be presented as an associative array. It will be concatenated with the post information (last updated, author) in the default search result theming.
See Also
template_preprocess_search_result()
search-result.tpl.php

Definition at line 668 of file node.api.php.

References db_query(), and format_plural().

hook_node_submit | ( |  | $node,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Act on a node after validated form values have been copied to it.

This hook is invoked when a node form is submitted with either the "Save" or "Preview" button, after form values have been copied to the form state's node object, but before the node is saved or previewed. It is a chance for modules to adjust the node's properties from what they are simply after a copy from $form_state['values']. This hook is intended for adjusting non-field-related properties. See hook_field_attach_submit() for customizing field-related properties.

Parameters
$node | The node object being updated in response to a form submission.
$form | The form being used to edit the node.
$form_state | The form state array.

Definition at line 796 of file node.api.php.

hook_node_update ( $node )

Respond to updates to a node.

This hook is invoked from node_save() after the database query that will update node in the node table is scheduled for execution, after the type-specific hook_update() is invoked, and after field_attach_update() is called.

Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the save operation is entirely completed and node_save() goes out of scope. You should not rely on data in the database at this time as it is not updated yet. You should also note that any write/update database queries executed from this hook are also not committed immediately. Check node_save() and db_transaction() for more info.

Parameters
$node The node that is being updated.

Definition at line 714 of file node.api.php.

References db_update().

hook_node_update_index ( $node )

Act on a node being indexed for searching.

This hook is invoked during search indexing, after node_load(), and after the result of node_view() is added as $node->rendered to the node object.

Parameters
$node The node being indexed.
Returns
string Additional node information to be indexed.

Definition at line 735 of file node.api.php.

References check_markup(), check_plain(), COMMENT_PUBLISHED, and db_query().

hook_node_validate | ( |  | $node,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Perform node validation before a node is created or updated.

This hook is invoked from node_validate(), after a user has has finished editing the node and is previewing or submitting it. It is invoked at the end of all the standard validation steps, and after the type-specific hook_validate() is invoked.

To indicate a validation error, use form_set_error().

Note: Changes made to the $node object within your hook implementation will have no effect. The preferred method to change a node's content is to use hook_node_presave() instead. If it is really necessary to change the node at the validate stage, you can use form_set_value().

Parameters
$node | The node being validated.
$form | The form being used to edit the node.
$form_state | The form state array.

Definition at line 768 of file node.api.php.

References form_set_error(), and t().

hook_node_view | ( | $node,
 |  | $view_mode,
 |  | $langcode
 | ) |

Act on a node that is being assembled before rendering.

The module may add elements to $node->content prior to rendering. This hook will be called after hook_view(). The structure of $node->content is a renderable array as expected by drupal_render().

When $view_mode is 'rss', modules can also add extra RSS elements and namespaces to $node->rss_elements and $node->rss_namespaces respectively for the RSS item generated for this node. For details on how this is used, see node_feed().

See Also
blog_node_view()
forum_node_view()
comment_node_view()
Parameters
$node | The node that is being assembled for rendering.
$view_mode | The $view_mode parameter from node_view().
$langcode | The language code used for rendering.
See Also
hook_entity_view()

Definition at line 831 of file node.api.php.

hook_node_view_alter ( & $build )

Alter the results of node_view().

This hook is called after the content has been assembled in a structured array and may be used for doing processing which requires that the complete node content structure has been built.

If the module wishes to act on the rendered HTML of the node rather than the structured content array, it may use this hook to add a #post_render callback. Alternatively, it could also implement hook_preprocess_node(). See drupal_render() and theme() documentation respectively for details.

Parameters
$build A renderable array representing the node content.
See Also
node_view()
hook_entity_view_alter()

Definition at line 859 of file node.api.php.

hook_prepare ( $node )

Act on a node object about to be shown on the add/edit form.

This hook is invoked only on the module that defines the node's content type (use hook_node_prepare() to act on all node preparations).

This hook is invoked from node_object_prepare() before the general hook_node_prepare() is invoked.

Parameters
$node The node that is about to be shown on the add/edit form.

Definition at line 1065 of file node.api.php.

References file_save_upload(), form_set_error(), image_get_info(), and t().

hook_ranking ( )

Provide additional methods of scoring for core search results for nodes.

A node's search score is used to rank it among other nodes matched by the search, with the highest-ranked nodes appearing first in the search listing.

For example, a module allowing users to vote on content could expose an option to allow search results' rankings to be influenced by the average voting score of a node.

All scoring mechanisms are provided as options to site administrators, and may be tweaked based on individual sites or disabled altogether if they do not make sense. Individual scoring mechanisms, if enabled, are assigned a weight from 1 to 10. The weight represents the factor of magnification of the ranking mechanism, with higher-weighted ranking mechanisms having more influence. In order for the weight system to work, each scoring mechanism must return a value between 0 and 1 for every node. That value is then multiplied by the administrator-assigned weight for the ranking mechanism, and then the weighted scores from all ranking mechanisms are added, which brings about the same result as a weighted average.

Returns
An associative array of ranking data. The keys should be strings, corresponding to the internal name of the ranking mechanism, such as 'recent', or 'comments'. The values should be arrays themselves, with the following keys available:
  • title: (required) The human readable name of the ranking mechanism.
  • join: (optional) The part of a query string to join to any additional necessary table. This is not necessary if the table required is already joined to by the base query, such as for the {node} table. Other tables should use the full table name as an alias to avoid naming collisions.
  • score: (required) The part of a query string to calculate the score for the ranking mechanism based on values in the database. This does not need to be wrapped in parentheses, as it will be done automatically; it also does not need to take the weighted system into account, as it will be done automatically. It does, however, need to calculate a decimal between 0 and 1; be careful not to cast the entire score to an integer by inadvertently introducing a variable argument.
  • arguments: (optional) If any arguments are required for the score, they can be specified in an array here.

Definition at line 967 of file node.api.php.

References t(), and variable_get().

hook_update ( $node )

Respond to updates to a node.

This hook is invoked only on the module that defines the node's content type (use hook_node_update() to act on all node updates).

This hook is invoked from node_save() after the node is updated in the node table in the database, before field_attach_update() is called, and before hook_node_update() is invoked.

Parameters
$node The node that is being updated.

Definition at line 1211 of file node.api.php.

References db_update().

hook_validate | ( |  | $node,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Perform node validation before a node is created or updated.

This hook is invoked only on the module that defines the node's content type (use hook_node_validate() to act on all node validations).

This hook is invoked from node_validate(), after a user has finished editing the node and is previewing or submitting it. It is invoked at the end of all the standard validation steps, and before hook_node_validate() is invoked.

To indicate a validation error, use form_set_error().

Note: Changes made to the $node object within your hook implementation will have no effect. The preferred method to change a node's content is to use hook_node_presave() instead.

Parameters
$node | The node being validated.
$form | The form being used to edit the node.
$form_state | The form state array.

Definition at line 1244 of file node.api.php.

References form_set_error(), and t().

hook_view | ( | $node,
 |  | $view_mode
 | ) |

Display a node.

This hook is invoked only on the module that defines the node's content type (use hook_node_view() to act on all node views).

This hook is invoked during node viewing after the node is fully loaded, so that the node type module can define a custom method for display, or add to the default display.

Parameters
$node | The node to be displayed, as returned by node_load().
$view_mode | View mode, e.g. 'full', 'teaser', ...
Returns
The passed $node parameter should be modified as necessary and returned so it can be properly presented. Nodes are prepared for display by assembling a structured array, formatted as in the Form API, in $node->content. As with Form API arrays, the #weight property can be used to control the relative positions of added elements. After this hook is invoked, node_view() calls field_attach_view() to add field views to $node->content, and then invokes hook_node_view() and hook_node_view_alter(), so if you want to affect the final view of the node, you might consider implementing one of these hooks instead.

Definition at line 1279 of file node.api.php.

References $breadcrumb, drupal_set_breadcrumb(), l(), node_is_page(), t(), and theme().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Node access rights

Functions
Node access rights

Functions

hook_node_grants ($account, $op)
hook_node_access_records ($node)
hook_node_access_records_alter (&$grants, $node)
hook_node_grants_alter (&$grants, $account, $op)
hook_node_access ($node, $op, $account)
node_access ($op, $node, $account=NULL)
node_node_access ($node, $op, $account)
node_list_permissions ($type)
node_permissions_get_configured_types ()
node_access_grants ($op, $account=NULL)
node_access_view_all_nodes ($account=NULL)
node_query_node_access_alter (QueryAlterableInterface $query)
node_query_entity_field_access_alter (QueryAlterableInterface $query)
_node_query_node_access_alter ($query, $type)
node_access_acquire_grants ($node, $delete=TRUE)
node_access_write_grants ($node, $grants, $realm=NULL, $delete=TRUE)
node_access_needs_rebuild ($rebuild=NULL)
node_access_rebuild ($batch_mode=FALSE)
_node_access_rebuild_batch_operation (&$context)
_node_access_rebuild_batch_finished ($success, $results, $operations)

Detailed Description

The node access system determines who can do what to which nodes.

In determining access rights for a node, node_access() first checks whether the user has the "bypass node access" permission. Such users have unrestricted access to all nodes. user 1 will always pass this check.

Next, all implementations of hook_node_access() will be called. Each implementation may explicitly allow, explicitly deny, or ignore the access request. If at least one module says to deny the request, it will be rejected. If no modules deny the request and at least one says to allow it, the request will be permitted.

If all modules ignore the access request, then the node_access table is used to determine access. All node access modules are queried using hook_node_grants() to assemble a list of "grant IDs" for the user. This list is compared against the table. If any row contains the node ID in question (or 0, which stands for "all nodes"), one of the grant IDs returned, and a value of TRUE for the operation in question, then access is granted. Note that this table is a list of grants; any matching row is sufficient to grant access to the node.

In node listings (lists of nodes generated from a select query, such as the default home page at path 'node', an RSS feed, a recent content block, etc.), the process above is followed except that hook_node_access() is not called on each node for performance reasons and for proper functioning of the pager system. When adding a node listing to your module, be sure to use a dynamic query created by db_select() and add a tag of "node_access". This will allow modules dealing with node access to ensure only nodes to which the user has access are retrieved, through the use of hook_query_TAG_alter().

Note: Even a single module returning NODE_ACCESS_DENY from hook_node_access() will block access to the node. Therefore, implementers should take care to not deny access unless they really intend to. Unless a module wishes to actively deny access it should return NODE_ACCESS_IGNORE (or simply return nothing) to allow other modules or the node_access table to control access.

To see how to write a node access module of your own, see node_access_example.module.

Function Documentation

_node_access_rebuild_batch_finished | ( | $success,
 |  | $results,
 |  | $operations
 | ) |

Performs post-processing for node_access_rebuild().

Parameters
bool | $success | A boolean indicating whether the re-build process has completed.
array | $results | An array of results information.
array | $operations | An array of function calls (not used in this function).

Definition at line 3701 of file node.module.

References cache_clear_all(), drupal_set_message(), node_access_needs_rebuild(), and t().

_node_access_rebuild_batch_operation ( & $context )

Performs batch operation for node_access_rebuild().

This is a multistep operation: we go through all nodes by packs of 20. The batch processing engine interrupts processing and sends progress feedback after 1 second execution time.

Parameters
array $context An array of contextual key/value information for rebuild batch process.

Definition at line 3663 of file node.module.

References db_query(), db_query_range(), node_access_acquire_grants(), and node_load_multiple().

_node_query_node_access_alter | ( | $query,
 |  | $type
 | ) |

Helper for node access functions.

Parameters
$query | The query to add conditions to.
$type | Either 'node' or 'entity' depending on what sort of query it is. See node_query_node_access_alter() and node_query_entity_field_access_alter() for more.

Definition at line 3300 of file node.module.

References $op, db_and(), db_or(), db_select(), drupal_get_schema(), module_implements(), node_access_grants(), node_access_view_all_nodes(), t(), user_access(), watchdog(), and WATCHDOG_WARNING.

Referenced by node_query_entity_field_access_alter(), and node_query_node_access_alter().

hook_node_access | ( | $node,
 |  | $op,
 |  | $account
 | ) |

Control access to a node.

Modules may implement this hook if they want to have a say in whether or not a given user has access to perform a given operation on a node.

The administrative account (user ID #1) always passes any access check, so this hook is not called in that case. Users with the "bypass node access" permission may always view and edit content through the administrative interface.

Note that not all modules will want to influence access on all node types. If your module does not want to actively grant or block access, return NODE_ACCESS_IGNORE or simply return nothing. Blindly returning FALSE will break other node access modules.

Also note that this function isn't called for node listings (e.g., RSS feeds, the default home page at path 'node', a recent content block, etc.) See Node access rights for a full explanation.

Parameters
$node | Either a node object or the machine name of the content type on which to perform the access check.
$op The operation to be performed. Possible values:
  • "create"
  • "delete"
  • "update"
  • "view"
$account | The user object to perform the access check operation on.
Returns
  • NODE_ACCESS_ALLOW: if the operation is to be allowed.
  • NODE_ACCESS_DENY: if the operation is to be denied.
  • NODE_ACCESS_IGNORE: to not affect this operation at all.

Definition at line 605 of file node.api.php.

References $op, NODE_ACCESS_ALLOW, NODE_ACCESS_IGNORE, node_permissions_get_configured_types(), and user_access().

hook_node_access_records ( $node )

Set permissions for a node to be written to the database.

When a node is saved, a module implementing hook_node_access_records() will be asked if it is interested in the access permissions for a node. If it is interested, it must respond with an array of permissions arrays for that node.

Node access grants apply regardless of the published or unpublished status of the node. Implementations must make sure not to grant access to unpublished nodes if they don't want to change the standard access control behavior. Your module may need to create a separate access realm to handle access to unpublished nodes.

Note that the grant values in the return value from your hook must be integers and not boolean TRUE and FALSE.

Each permissions item in the array is an array with the following elements:

  • 'realm': The name of a realm that the module has defined in hook_node_grants().
  • 'gid': A 'grant ID' from hook_node_grants().
  • 'grant_view': If set to 1 a user that has been identified as a member of this gid within this realm can view this node. This should usually be set to $node->status. Failure to do so may expose unpublished content to some users.
  • 'grant_update': If set to 1 a user that has been identified as a member of this gid within this realm can edit this node.
  • 'grant_delete': If set to 1 a user that has been identified as a member of this gid within this realm can delete this node.
  • 'priority': If multiple modules seek to set permissions on a node, the realms that have the highest priority will win out, and realms with a lower priority will not be written. If there is any doubt, it is best to leave this 0.

When an implementation is interested in a node but want to deny access to everyone, it may return a "deny all" grant:

* $grants[] = array(
* 'realm' => 'all',
* 'gid' => 0,
* 'grant_view' => 0,
* 'grant_update' => 0,
* 'grant_delete' => 0,
* 'priority' => 1,
* );
*

Setting the priority should cancel out other grants. In the case of a conflict between modules, it is safer to use hook_node_access_records_alter() to return only the deny grant.

Note: a deny all grant is not written to the database; denies are implicit.

See Also
node_access_write_grants()
Parameters
$node The node that has just been saved.
Returns
An array of grants as defined above.
See Also
hook_node_access_records_alter()

Definition at line 268 of file node.api.php.

hook_node_access_records_alter | ( | & | $grants,
 |  |  | $node
 | ) |  |

Alter permissions for a node before it is written to the database.

Node access modules establish rules for user access to content. Node access records are stored in the {node_access} table and define which permissions are required to access a node. This hook is invoked after node access modules returned their requirements via hook_node_access_records(); doing so allows modules to modify the $grants array by reference before it is stored, so custom or advanced business logic can be applied.

See Also
hook_node_access_records()

Upon viewing, editing or deleting a node, hook_node_grants() builds a permissions array that is compared against the stored access records. The user must have one or more matching permissions in order to complete the requested operation.

A module may deny all access to a node by setting $grants to an empty array.

See Also
hook_node_grants()
hook_node_grants_alter()
Parameters
$grants | The $grants array returned by hook_node_access_records().
$node | The node for which the grants were acquired.

The preferred use of this hook is in a module that bridges multiple node access modules with a configurable behavior, as shown in the example with the 'is_preview' field.

Definition at line 335 of file node.api.php.

hook_node_grants | ( | $account,
 |  | $op
 | ) |

Inform the node access system what permissions the user has.

This hook is for implementation by node access modules. In this hook, the module grants a user different "grant IDs" within one or more "realms". In hook_node_access_records(), the realms and grant IDs are associated with permission to view, edit, and delete individual nodes.

The realms and grant IDs can be arbitrarily defined by your node access module; it is common to use role IDs as grant IDs, but that is not required. Your module could instead maintain its own list of users, where each list has an ID. In that case, the return value of this hook would be an array of the list IDs that this user is a member of.

A node access module may implement as many realms as necessary to properly define the access privileges for the nodes. Note that the system makes no distinction between published and unpublished nodes. It is the module's responsibility to provide appropriate realms to limit access to unpublished content.

Node access records are stored in the {node_access} table and define which grants are required to access a node. There is a special case for the view operation – a record with node ID 0 corresponds to a "view all" grant for the realm and grant ID of that record. If there are no node access modules enabled, the core node module adds a node ID 0 record for realm 'all'. Node access modules can also grant "view all" permission on their custom realms; for example, a module could create a record in {node_access} with:

* $record = array(
* 'nid' => 0,
* 'gid' => 888,
* 'realm' => 'example_realm',
* 'grant_view' => 1,
* 'grant_update' => 0,
* 'grant_delete' => 0,
* );
* drupal_write_record('node_access', $record);
*

And then in its hook_node_grants() implementation, it would need to return:

* if ($op == 'view') {
* $grants['example_realm'] = array(888);
* }
*

If you decide to do this, be aware that the node_access_rebuild() function will erase any node ID 0 entry when it is called, so you will need to make sure to restore your {node_access} record after node_access_rebuild() is called.

See Also
node_access_view_all_nodes()
node_access_rebuild()
Parameters
$account | The user object whose grants are requested.
$op | The node operation to be performed, such as 'view', 'update', or 'delete'.
Returns
An array whose keys are "realms" of grants, and whose values are arrays of the grant IDs within this realm that this user is being granted.

For a detailed example, see node_access_example.module.

Definition at line 194 of file node.api.php.

References user_access().

hook_node_grants_alter | ( | & | $grants,
 |  |  | $account,
 |  |  | $op
 | ) |  |

Alter user access rules when trying to view, edit or delete a node.

Node access modules establish rules for user access to content. hook_node_grants() defines permissions for a user to view, edit or delete nodes by building a $grants array that indicates the permissions assigned to the user by each node access module. This hook is called to allow modules to modify the $grants array by reference, so the interaction of multiple node access modules can be altered or advanced business logic can be applied.

See Also
hook_node_grants()

The resulting grants are then checked against the records stored in the {node_access} table to determine if the operation may be completed.

A module may deny all access to a user by setting $grants to an empty array.

See Also
hook_node_access_records()
hook_node_access_records_alter()
Parameters
$grants | The $grants array returned by hook_node_grants().
$account | The user account requesting access to content.
$op | The operation being performed, 'view', 'update' or 'delete'.

Developers may use this hook to either add additional grants to a user or to remove existing grants. These rules are typically based on either the permissions assigned to a user role, or specific attributes of a user account.

Definition at line 382 of file node.api.php.

References $op, and variable_get().

node_access | ( | $op,
 |  | $node,
 |  | $account = NULL
 | ) |

Determines whether the current user may perform the operation on the node.

Parameters
$op The operation to be performed on the node. Possible values are:
  • "view"
  • "update"
  • "delete"
  • "create"
$node | The node object on which the operation is to be performed, or node type (e.g. 'forum') for "create" operation.
$account | Optional, a user object representing the user for whom the operation is to be performed. Determines access for a user other than the current user.
Returns
TRUE if the operation may be performed, FALSE otherwise.

Definition at line 2981 of file node.module.

References $op, db_and(), db_or(), db_select(), drupal_static(), module_implements(), module_invoke_all(), NODE_ACCESS_ALLOW, NODE_ACCESS_DENY, node_access_grants(), and user_access().

Referenced by _book_outline_access(), _node_add_access(), _node_revision_access(), _translation_tab_access(), book_block_view(), book_export(), book_node_view_link(), comment_file_download_access(), forum_menu_local_tasks_alter(), hook_file_download_access(), node_admin_nodes(), node_file_download_access(), node_form(), node_form_submit(), node_preview(), node_revision_overview(), theme_node_recent_block(), translation_node_overview(), and translation_node_prepare().

node_access_acquire_grants | ( | $node,
 |  | $delete = TRUE
 | ) |

Gets the list of node access grants and writes them to the database.

This function is called when a node is saved, and can also be called by modules if something other than a node save causes node access permissions to change. It collects all node access grants for the node from hook_node_access_records() implementations, allows these grants to be altered via hook_node_access_records_alter() implementations, and saves the collected and altered grants to the database.

Parameters
$node | The $node to acquire grants for.
$delete | Whether to delete existing node access records before inserting new ones. Defaults to TRUE.

Definition at line 3474 of file node.module.

References drupal_alter(), module_invoke_all(), and node_access_write_grants().

Referenced by _node_access_rebuild_batch_operation(), node_access_rebuild(), and node_save().

node_access_grants | ( | $op,
 |  | $account = NULL
 | ) |

Fetches an array of permission IDs granted to the given user ID.

The implementation here provides only the universal "all" grant. A node access module should implement hook_node_grants() to provide a grant list for the user.

After the default grants have been loaded, we allow modules to alter the grants array by reference. This hook allows for complex business logic to be applied when integrating multiple node access modules.

Parameters
$op | The operation that the user is trying to perform.
$account | The user object for the user performing the operation. If omitted, the current user is used.
Returns
An associative array in which the keys are realms, and the values are arrays of grants for those realms.

Definition at line 3187 of file node.module.

References $op, drupal_alter(), and module_invoke_all().

Referenced by _node_query_node_access_alter(), hook_query_TAG_alter(), node_access(), and node_access_view_all_nodes().

node_access_needs_rebuild ( $rebuild = NULL )

Flags or unflags the node access grants for rebuilding.

If the argument isn't specified, the current value of the flag is returned. When the flag is set, a message is displayed to users with 'access administration pages' permission, pointing to the 'rebuild' confirm form. This can be used as an alternative to direct node_access_rebuild calls, allowing administrators to decide when they want to perform the actual (possibly time consuming) rebuild. When unsure if the current user is an administrator, node_access_rebuild() should be used instead.

Parameters
$rebuild (Optional) The boolean value to be written.
Returns
The current value of the flag if no value was provided for $rebuild.
See Also
node_access_rebuild()

Definition at line 3569 of file node.module.

References variable_del(), variable_get(), and variable_set().

Referenced by _node_access_rebuild_batch_finished(), module_disable(), node_access_rebuild(), node_help(), and node_modules_enabled().

node_access_rebuild ( $batch_mode = FALSE )

Rebuilds the node access database.

This is occasionally needed by modules that make system-wide changes to access levels. When the rebuild is required by an admin-triggered action (e.g module settings form), calling node_access_needs_rebuild(TRUE) instead of node_access_rebuild() lets the user perform his changes and actually rebuild only once he is done.

Note: As of Drupal 6, node access modules are not required to (and actually should not) call node_access_rebuild() in hook_enable/disable anymore.

See Also
node_access_needs_rebuild()
Parameters
$batch_mode Set to TRUE to process in 'batch' mode, spawning processing over several HTTP requests (thus avoiding the risk of PHP timeout if the site has a large number of nodes). hook_update_N and any form submit handler are safe contexts to use the 'batch mode'. Less decidable cases (such as calls from hook_user, hook_taxonomy, etc...) might consider using the non-batch mode.

Definition at line 3603 of file node.module.

References batch_set(), cache_clear_all(), db_delete(), db_insert(), db_query(), drupal_set_message(), drupal_set_time_limit(), module_implements(), node_access_acquire_grants(), node_access_needs_rebuild(), node_load(), and t().

Referenced by module_disable(), and node_configure_rebuild_confirm_submit().

node_access_view_all_nodes ( $account = NULL )

Determines whether the user has a global viewing grant for all nodes.

Checks to see whether any module grants global 'view' access to a user account; global 'view' access is encoded in the {node_access} table as a grant with nid=0. If no node access modules are enabled, node.module defines such a global 'view' access grant.

This function is called when a node listing query is tagged with 'node_access'; when this function returns TRUE, no node access joins are added to the query.

Parameters
$account The user object for the user whose access is being checked. If omitted, the current user is used.
Returns
TRUE if 'view' access to all nodes is granted, FALSE otherwise.
See Also
hook_node_grants()
_node_query_node_access_alter()

Definition at line 3223 of file node.module.

References db_and(), db_or(), db_select(), drupal_static(), module_implements(), and node_access_grants().

Referenced by _node_query_node_access_alter(), and hook_query_TAG_alter().

node_access_write_grants | ( | $node,
 |  | $grants,
 |  | $realm = NULL,
 |  | $delete = TRUE
 | ) |

Writes a list of grants to the database, deleting any previously saved ones.

If a realm is provided, it will only delete grants from that realm, but it will always delete a grant from the 'all' realm. Modules that utilize node_access() can use this function when doing mass updates due to widespread permission changes.

Note: Don't call this function directly from a contributed module. Call node_access_acquire_grants() instead.

Parameters
$node | The node whose grants are being written.
$grants | A list of grants to write. Each grant is an array that must contain the following keys: realm, gid, grant_view, grant_update, grant_delete. The realm is specified by a particular module; the gid is as well, and is a module-defined id to define grant privileges. each grant_* field is a boolean value.
$realm | (optional) If provided, read/write grants for that realm only. Defaults to NULL.
$delete | (optional) If false, does not delete records. This is only for optimization purposes, and assumes the caller has already performed a mass delete of some form. Defaults to TRUE.
See Also
node_access_acquire_grants()

Definition at line 3524 of file node.module.

References db_delete(), db_insert(), and module_implements().

Referenced by node_access_acquire_grants().

node_list_permissions ( $type )

Helper function to generate standard node permission list for a given type.

Parameters
$type The machine-readable name of the node type.
Returns
array An array of permission names and descriptions.

Definition at line 3114 of file node.module.

References $info, node_type_get_type(), and t().

Referenced by node_permission().

node_node_access | ( | $node,
 |  | $op,
 |  | $account
 | ) |

Implements hook_node_access().

Definition at line 3081 of file node.module.

References $op, NODE_ACCESS_ALLOW, NODE_ACCESS_IGNORE, node_permissions_get_configured_types(), and user_access().

node_permissions_get_configured_types ( )

Returns an array of node types that should be managed by permissions.

By default, this will include all node types in the system. To exclude a specific node from getting permissions defined for it, set the node_permissions_$type variable to 0. Core does not provide an interface for doing so. However, contrib modules may exclude their own nodes in hook_install(). Alternatively, contrib modules may configure all node types at once, or decide to apply some other hook_node_access() implementation to some or all node types.

Returns
An array of node types managed by this module.

Definition at line 3153 of file node.module.

References $info, node_type_get_types(), and variable_get().

Referenced by hook_node_access(), node_node_access(), and node_permission().

node_query_entity_field_access_alter ( QueryAlterableInterface $query )

Implements hook_query_TAG_alter().

This function implements the same functionality as node_query_node_access_alter() for the SQL field storage engine. Node access conditions are added for field values belonging to nodes only.

Definition at line 3286 of file node.module.

References _node_query_node_access_alter().

node_query_node_access_alter ( QueryAlterableInterface $query )

Implements hook_query_TAG_alter().

This is the hook_query_alter() for queries tagged with 'node_access'. It adds node access checks for the user account given by the 'account' meta-data (or global $user if not provided), for an operation given by the 'op' meta-data (or 'view' if not provided; other possible values are 'update' and 'delete').

Definition at line 3275 of file node.module.

References _node_query_node_access_alter().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Hook implementations for user-created content types

Functions
Hook implementations for user-created content types

Functions

node_content_form ($node, $form_state)

Detailed Description

End of "defgroup node_access".

Functions that implement hooks for user-created content types.

Function Documentation

node_content_form | ( | $node,
 |  | $form_state
 | ) |

Implements hook_form().

Definition at line 3725 of file node.module.

References check_plain(), and node_type_get_type().

Referenced by blog_form(), and node_example_form().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: RDF Mapping API

Functions | Variables
RDF Mapping API

Functions

hook_rdf_mapping ()
hook_rdf_namespaces ()
rdf_rdf_namespaces ()
rdf_get_namespaces ()
rdf_mapping_load ($type, $bundle=RDF_DEFAULT_BUNDLE)
rdf_mapping_save ($mapping)
rdf_mapping_delete ($type, $bundle)
rdf_rdfa_attributes ($mapping, $data=NULL)
theme_rdf_template_variable_wrapper ($variables)
theme_rdf_metadata ($variables)

Variables

const RDF_DEFAULT_BUNDLE ''

Detailed Description

Functions to describe entities and bundles in RDF.

The RDF module introduces RDF and RDFa to Drupal. RDF is a W3C standard to describe structured data. RDF can be serialized as RDFa in XHTML attributes to augment visual data with machine-readable hints.

See Also
http://www.w3.org/RDF/
http://www.w3.org/TR/xhtml-rdfa-primer/

Modules can provide mappings of their bundles' data and metadata to RDF classes and properties. This module takes care of injecting these mappings into variables available to theme functions and templates. All Drupal core themes are coded to be RDFa compatible.

Example mapping from node.module:

* array(
* 'type' => 'node',
* 'bundle' => RDF_DEFAULT_BUNDLE,
* 'mapping' => array(
* 'rdftype' => array('sioc:Item', 'foaf:Document'),
* 'title' => array(
* 'predicates' => array('dc:title'),
* ),
* 'created' => array(
* 'predicates' => array('dc:date', 'dc:created'),
* 'datatype' => 'xsd:dateTime',
* 'callback' => 'date_iso8601',
* ),
* 'body' => array(
* 'predicates' => array('content:encoded'),
* ),
* 'uid' => array(
* 'predicates' => array('sioc:has_creator'),
* ),
* 'name' => array(
* 'predicates' => array('foaf:name'),
* ),
* ),
* );
*

Function Documentation

hook_rdf_mapping ( )

Allow modules to define RDF mappings for field bundles.

Modules defining their own field bundles can specify which RDF semantics should be used to annotate these bundles. These mappings are then used for automatic RDFa output in the HTML code.

Returns
A list of mapping structures, where each mapping is an associative array:
  • type: The name of an entity type (e.g., 'node', 'comment', and so on.)
  • bundle: The name of the bundle (e.g., 'page', 'blog', or RDF_DEFAULT_BUNDLE for default mappings.)
  • mapping: The mapping structure which applies to the entity type and bundle. A mapping structure is an array with keys corresponding to existing field instances in the bundle. Each field is then described in terms of the RDF mapping:
    • predicates: An array of RDF predicates which describe the relation between the bundle (RDF subject) and the value of the field (RDF object). This value is either some text, another bundle, or a URI in general.
    • datatype: Is used along with 'callback' to format data so that it is readable by machines. A typical example is a date which can be written in many different formats but should be translated into a uniform format for machine consumption.
    • callback: A function name to invoke for 'datatype'.
    • type: A string used to determine the type of RDFa markup which will be used in the final HTML output, depending on whether the RDF object is a literal text or another RDF resource.
    • rdftype: A special property used to define the type of the instance. Its value should be an array of RDF classes.

Definition at line 46 of file rdf.api.php.

hook_rdf_namespaces ( )

Allow modules to define namespaces for RDF mappings.

Many common namespace prefixes are defined in rdf_rdf_namespaces(). However, if a module implements hook_rdf_mapping() and uses a prefix that is not defined in rdf_rdf_namespaces(), this hook should be used to define the new namespace prefix.

Returns
An associative array of namespaces where the key is the namespace prefix and the value is the namespace URI.

Definition at line 90 of file rdf.api.php.

rdf_get_namespaces ( )

Returns an array of RDF namespaces defined in modules that implement hook_rdf_namespaces().

Definition at line 97 of file rdf.module.

References $rdf_namespaces, and module_invoke_all().

Referenced by drupal_get_rdf_namespaces().

rdf_mapping_delete | ( | $type,
 |  | $bundle
 | ) |

Deletes the mapping for the given bundle from the database.

Parameters
$type | The entity type the mapping refers to.
$bundle | The bundle the mapping refers to.
Returns
Return boolean TRUE if mapping deleted, FALSE if not.

Definition at line 257 of file rdf.module.

References db_delete().

rdf_mapping_load | ( | $type,
 |  | $bundle = RDF_DEFAULT_BUNDLE
 | ) |

Returns the mapping for attributes of a given entity type/bundle pair.

Parameters
$type | An entity type.
$bundle | (optional) A bundle name.
Returns
The mapping corresponding to the requested entity type/bundle pair or an empty array.

Definition at line 133 of file rdf.module.

References _rdf_get_default_mapping(), and entity_get_info().

Referenced by rdf_entity_load(), rdf_preprocess_field(), rdf_preprocess_username(), and tracker_page().

rdf_mapping_save ( $mapping )

Saves an RDF mapping to the database.

Takes a mapping structure returned by hook_rdf_mapping() implementations and creates or updates a record mapping for each encountered entity type/bundle pair. If available, adds default values for non-existent mapping keys.

Parameters
$mapping The RDF mapping to save, as an array.
Returns
Status flag indicating the outcome of the operation.

Definition at line 225 of file rdf.module.

References _rdf_get_default_mapping(), db_merge(), and entity_info_cache_clear().

Referenced by rdf_modules_installed(), and standard_install().

rdf_rdf_namespaces ( )

Implements hook_rdf_namespaces().

Definition at line 79 of file rdf.module.

rdf_rdfa_attributes | ( | $mapping,
 |  | $data = NULL
 | ) |

Builds an array of RDFa attributes for a given mapping. This array will typically be passed through drupal_attributes() to create the attributes variables that are available to template files. These include $attributes, $title_attributes, $content_attributes and the field-specific $item_attributes variables. For more information, see theme_rdf_template_variable_wrapper().

Parameters
$mapping An array containing a mandatory 'predicates' key and optional 'datatype', 'callback' and 'type' keys. For example:
* array(
* 'predicates' => array('dc:created'),
* 'datatype' => 'xsd:dateTime',
* 'callback' => 'date_iso8601',
* ),
* );
*
$data A value that needs to be converted by the provided callback function.
Returns
An array containing RDFa attributes suitable for drupal_attributes().

Definition at line 291 of file rdf.module.

References $attributes.

Referenced by rdf_comment_load(), rdf_preprocess_field(), rdf_preprocess_node(), and tracker_page().

theme_rdf_metadata ( $variables )

Returns HTML for a series of empty spans for exporting RDF metadata in RDFa.

Sometimes it is useful to export data which is not semantically present in the HTML output. For example, a hierarchy of comments is visible for a human but not for machines because this hiearchy is not present in the DOM tree. We can express it in RDFa via empty tags. These aren't visible and give machines extra information about the content and its structure.

Parameters
$variables An associative array containing:
  • metadata: An array of attribute arrays. Each item in the array corresponds to its own set of attributes, and therefore, needs its own element.
See Also
rdf_process()

Definition at line 864 of file rdf.module.

References $attributes, $output, and drupal_attributes().

theme_rdf_template_variable_wrapper ( $variables )

Returns HTML for a template variable wrapped in an HTML element with the RDF attributes.

This is called by rdf_process() shortly before the theme system renders a template file. It is called once for each template variable for which additional attributes are needed. While template files are responsible for rendering the attributes for the template's primary object (via the $attributes variable), title (via the $title_attributes variable), and content (via the $content_attributes variable), additional template variables that need containing attributes are routed through this function, allowing the template file to receive properly wrapped variables.

Tip for themers: if you're already outputting a wrapper element around a particular template variable in your template file, and if you don't want an extra wrapper element, you can override this function to not wrap that variable and instead print the following inside your template file:

* drupal_attributes($rdf_template_variable_attributes_array[$variable_name])
*
Parameters
$variables An associative array containing:
  • content: A string of content to be wrapped with attributes.
  • attributes: An array of attributes to be placed on the wrapping element.
  • context: An array of context information about the content to be wrapped:
    • hook: The theme hook that will use the wrapped content. This corresponds to the key within the theme registry for this template. For example, if this content is about to be used in node.tpl.php or node-[type].tpl.php, then the 'hook' is 'node'.
    • variable_name: The name of the variable by which the template will refer to this content. Each template file has documentation about the variables it uses. For example, if this function is called in preparing the $author variable for comment.tpl.php, then the 'variable_name' is 'author'.
    • variables: The full array of variables about to be passed to the template.
  • inline: TRUE if the content contains only inline HTML elements and therefore can be validly wrapped by a tag. FALSE if the content might contain block level HTML elements and therefore cannot be validly wrapped by a tag. Modules implementing preprocess functions that set 'rdf_template_variable_attributes_array' for a particular template variable that might contain block level HTML must also implement hook_preprocess_rdf_template_variable_wrapper() and set 'inline' to FALSE for that context. Themes that render normally inline content with block level HTML must similarly implement hook_preprocess_rdf_template_variable_wrapper() and set 'inline' accordingly.
See Also
rdf_process()

Definition at line 836 of file rdf.module.

References $attributes, $output, and drupal_attributes().

Variable Documentation

const RDF_DEFAULT_BUNDLE ''

RDF bundle flag: Default bundle.

Implementations of hook_rdf_mapping() should use this constant for the 'bundle' key when defining a default set of RDF mappings for an entity type. Each bundle will inherit the default mappings defined for the entity type unless the bundle defines its own specific mappings.

Definition at line 74 of file rdf.module.

Referenced by _rdf_get_default_mapping(), comment_rdf_mapping(), node_rdf_mapping(), rdf_modules_installed(), taxonomy_rdf_mapping(), and user_rdf_mapping().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Search interface

Functions
Search interface

Functions

hook_search_info ()
hook_search_access ()
hook_search_reset ()
hook_search_status ()
hook_search_admin ()
hook_search_execute ($keys=NULL, $conditions=NULL)
hook_search_preprocess ($text)
hook_update_index ()
callback_search_conditions ($keys)
search_index ($sid, $module, $text)
search_form ($form, &$form_state, $action= '', $keys= '', $module=NULL, $prompt=NULL)
search_box_form_submit ($form, &$form_state)
template_preprocess_search_block_form (&$variables)
search_data ($keys, $module, $conditions=NULL)
search_excerpt ($keys, $text)

Detailed Description

The Drupal search interface manages a global search mechanism.

Modules may plug into this system to provide searches of different types of data. Most of the system is handled by search.module, so this must be enabled for all of the search features to work.

There are three ways to interact with the search system:

  • Specifically for searching nodes, you can implement hook_node_update_index() and hook_node_search_result(). However, note that the search system already indexes all visible output of a node; i.e., everything displayed normally by hook_view() and hook_node_view(). This is usually sufficient. You should only use this mechanism if you want additional, non-visible data to be indexed.
  • Implement hook_search_info(). This will create a search tab for your module on the /search page with a simple keyword search form. You will also need to implement hook_search_execute() to perform the search.
  • Implement hook_update_index(). This allows your module to use Drupal's HTML indexing mechanism for searching full text efficiently.

If your module needs to provide a more complicated search form, then you need to implement it yourself without hook_search_info(). In that case, you should define it as a local task (tab) under the /search page (e.g. /search/mymodule) so that users can easily find it.

Function Documentation

callback_search_conditions ( $keys )

End of "addtogroup hooks". Provide search query conditions.

Callback for hook_search_info().

This callback is invoked by search_view() to get an array of additional search conditions to pass to search_data(). For example, a search module may get additional keywords, filters, or modifiers for the search from the query string.

This example pulls additional search keywords out of the $_REQUEST variable, (i.e. from the query string of the request). The conditions may also be generated internally - for example based on a module's settings.

Parameters
$keys The search keywords string.
Returns
An array of additional conditions, such as filters.

Definition at line 363 of file search.api.php.

hook_search_access ( )

Define access to a custom search routine.

This hook allows a module to define permissions for a search tab.

Definition at line 56 of file search.api.php.

References user_access().

hook_search_admin ( )

Add elements to the search settings form.

Returns
Form array for the Search settings page at admin/config/search/settings.

Definition at line 104 of file search.api.php.

References drupal_map_assoc(), module_invoke_all(), t(), and variable_get().

hook_search_execute | ( | $keys = NULL,
 |  | $conditions = NULL
 | ) |

Execute a search for a set of key words.

Use database API with the 'PagerDefault' query extension to perform your search.

If your module uses hook_update_index() and search_index() to index its items, use table 'search_index' aliased to 'i' as the main table in your query, with the 'SearchQuery' extension. You can join to your module's table using the 'i.sid' field, which will contain the $sid values you provided to search_index(). Add the main keywords to the query by using method searchExpression(). The functions search_expression_extract() and search_expression_insert() may also be helpful for adding custom search parameters to the search expression.

See node_search_execute() for an example of a module that uses the search index, and user_search_execute() for an example that doesn't use the search index.

Parameters
$keys | The search keywords as entered by the user.
$conditions | An optional array of additional conditions, such as filters.
Returns
An array of search results. To use the default search result display, each item should have the following keys':
  • 'link': Required. The URL of the found item.
  • 'type': The type of item (such as the content type).
  • 'title': Required. The name of the item.
  • 'user': The author of the item.
  • 'date': A timestamp when the item was last modified.
  • 'extra': An array of optional extra information items.
  • 'snippet': An excerpt or preview to show with the result (can be generated with search_excerpt()).
  • 'language': Language code for the item (usually two characters).

Definition at line 167 of file search.api.php.

References $results, _node_rankings(), check_plain(), db_select(), drupal_render(), module_invoke(), module_invoke_all(), node_build_content(), node_load(), node_type_get_name(), search_excerpt(), theme(), and url().

hook_search_info ( )

Define a custom search type.

This hook allows a module to tell search.module that it wishes to perform searches on content it defines (custom node types, users, or comments for example) when a site search is performed.

In order for the search to do anything, your module must also implement hook_search_execute(), which is called when someone requests a search on your module's type of content. If you want to have your content indexed in the standard search index, your module should also implement hook_update_index(). If your search type has settings, you can implement hook_search_admin() to add them to the search settings page. You can use hook_form_FORM_ID_alter(), with FORM_ID set to 'search_form', to add fields to the search form (see node_form_search_form_alter() for an example). You can use hook_search_access() to limit access to searching, and hook_search_page() to override how search results are displayed.

Returns
Array with optional keys:
  • title: Title for the tab on the search page for this module. Defaults to the module name if not given.
  • path: Path component after 'search/' for searching with this module. Defaults to the module name if not given.
  • conditions_callback: An implementation of callback_search_conditions().

Definition at line 41 of file search.api.php.

hook_search_preprocess ( $text )

Preprocess text for search.

This hook is called to preprocess both the text added to the search index and the keywords users have submitted for searching.

Possible uses:

  • Adding spaces between words of Chinese or Japanese text.
  • Stemming words down to their root words to allow matches between, for instance, walk, walked, walking, and walks in searching.
  • Expanding abbreviations and acronymns that occur in text.
Parameters
$text The text to preprocess. This is a single piece of plain text extracted from between two HTML tags or from the search query. It will not contain any HTML entities or HTML tags.
Returns
The text after preprocessing. Note that if your module decides not to alter the text, it should return the original text. Also, after preprocessing, words in the text should be separated by a space.

Definition at line 283 of file search.api.php.

hook_search_reset ( )

Take action when the search index is going to be rebuilt.

Modules that use hook_update_index() should update their indexing bookkeeping so that it starts from scratch the next time hook_update_index() is called.

Definition at line 69 of file search.api.php.

References db_update(), and REQUEST_TIME.

hook_search_status ( )

Report the status of indexing.

The core search module only invokes this hook on active modules. Implementing modules do not need to check whether they are active when calculating their return values.

Returns
An associative array with the key-value pairs:
  • 'remaining': The number of items left to index.
  • 'total': The total number of items to index.

Definition at line 90 of file search.api.php.

References db_query().

hook_update_index ( )

Update the search index for this module.

This hook is called every cron run if search.module is enabled, your module has implemented hook_search_info(), and your module has been set as an active search module on the Search settings page (admin/config/search/settings). It allows your module to add items to the built-in search index using search_index(), or to add them to your module's own indexing mechanism.

When implementing this hook, your module should index content items that were modified or added since the last run. PHP has a time limit for cron, though, so it is advisable to limit how many items you index per run using variable_get('search_cron_limit') (see example below). Also, since the cron run could time out and abort in the middle of your run, you should update your module's internal bookkeeping on when items have last been indexed as you go rather than waiting to the end of indexing.

Definition at line 308 of file search.api.php.

References check_plain(), db_query_range(), drupal_render(), module_invoke_all(), node_build_content(), node_load(), search_index(), variable_get(), and variable_set().

search_box_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process a block search form submission.

Definition at line 1026 of file search.module.

search_data | ( | $keys,
 |  | $module,
 |  | $conditions = NULL
 | ) |

Performs a search by calling hook_search_execute().

Parameters
$keys | Keyword query to search on.
$module | Search module to search.
$conditions | Optional array of additional search conditions.
Returns
Renderable array of search results. No return value if $keys are not supplied or if the given search module is not active.

Definition at line 1096 of file search.module.

Referenced by search_view().

search_excerpt | ( | $keys,
 |  | $text
 | ) |

Returns snippets from a piece of text, with certain keywords highlighted. Used for formatting search results.

Parameters
$keys | A string containing a search query.
$text | The text to extract fragments from.
Returns
A string containing HTML for the excerpt.

Definition at line 1125 of file search.module.

Referenced by hook_search_execute(), and node_search_execute().

search_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $action = '',
 |  |  | $keys = '',
 |  |  | $module = NULL,
 |  |  | $prompt = NULL
 | ) |  |

Builds a search form.

Parameters
$action | Form action. Defaults to "search/$path", where $path is the search path associated with the module in its hook_search_info(). This will be run through url().
$keys | The search string entered by the user, containing keywords for the search.
$module | The search module to render the form for: a module that implements hook_search_info(). If not supplied, the default search module is used.
$prompt | Label for the keywords field. Defaults to t('Enter your keywords') if NULL. Supply '' to omit.
Returns
A Form API array for the search form.

Definition at line 956 of file search.module.

search_index | ( | $sid,
 |  | $module,
 |  | $text
 | ) |

Update the full-text search index for a particular item.

Parameters
$sid | An ID number identifying this particular item (e.g., node ID).
$module | The machine-readable name of the module that this item comes from (a module that implements hook_search_info()).
$text | The content of this item. Must be a piece of HTML or plain text.

Definition at line 552 of file search.module.

Referenced by _node_index_node(), and hook_update_index().

template_preprocess_search_block_form ( & $variables )

Process variables for search-block-form.tpl.php.

The $variables array contains the following arguments:

  • $form
See Also
search-block-form.tpl.php

Definition at line 1063 of file search.module.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Update versions of API functions

Functions
Update versions of API functions

Functions

_update_7000_field_create_field (&$field)
_update_7000_field_delete_field ($field_name)
_update_7000_field_delete_instance ($field_name, $entity_type, $bundle)
_update_7000_field_read_fields (array $conditions=array(), $key= 'id')
_update_7000_field_create_instance ($field, &$instance)
_update_7000_field_sql_storage_write ($entity_type, $bundle, $entity_id, $revision_id, $field_name, $data)
_update_7000_node_get_types ()
_update_7002_taxonomy_get_vocabularies ()
_update_7000_user_role_grant_permissions ($rid, array $permissions, $module)

Detailed Description

End of "addtogroup callbacks".

Functions that are similar to normal API functions, but do not invoke hooks.

These simplified versions of core API functions are provided for use by update functions (hook_update_N() implementations).

During database updates the schema of any module could be out of date. For this reason, caution is needed when using any API function within an update function - particularly CRUD functions, functions that depend on the schema (for example by using drupal_write_record()), and any functions that invoke hooks.

Instead, a simplified utility function should be used. If a utility version of the API function you require does not already exist, then you should create a new function. The new utility function should be named _update_N_mymodule_my_function(). N is the schema version the function acts on (the schema version is the number N from the hook_update_N() implementation where this schema was introduced, or a number following the same numbering scheme), and mymodule_my_function is the name of the original API function including the module's name.

Examples:

  • _update_6000_mymodule_save(): This function performs a save operation without invoking any hooks using the 6.x schema.
  • _update_7000_mymodule_save(): This function performs the same save operation using the 7.x schema.

The utility function should not invoke any hooks, and should perform database operations using functions from the Database abstraction layer, like db_insert(), db_update(), db_delete(), db_query(), and so on.

If a change to the schema necessitates a change to the utility function, a new function should be created with a name based on the version of the schema it acts on. See _update_7000_bar_get_types() and _update_7001_bar_get_types() in the code examples that follow.

For example, foo.install could contain:

* function foo_update_dependencies() {
* // foo_update_7010() needs to run after bar_update_7000().
* $dependencies['foo'][7010] = array(
* 'bar' => 7000,
* );
*
* // foo_update_7036() needs to run after bar_update_7001().
* $dependencies['foo'][7036] = array(
* 'bar' => 7001,
* );
*
* return $dependencies;
* }
*
* function foo_update_7000() {
* // No updates have been run on the {bar_types} table yet, so this needs
* // to work with the 6.x schema.
* foreach (_update_6000_bar_get_types() as $type) {
* // Rename a variable.
* }
* }
*
* function foo_update_7010() {
* // Since foo_update_7010() is going to run after bar_update_7000(), it
* // needs to operate on the new schema, not the old one.
* foreach (_update_7000_bar_get_types() as $type) {
* // Rename a different variable.
* }
* }
*
* function foo_update_7036() {
* // This update will run after bar_update_7001().
* foreach (_update_7001_bar_get_types() as $type) {
* }
* }
*

And bar.install could contain:

* function bar_update_7000() {
* // Type and bundle are confusing, so we renamed the table.
* db_rename_table('bar_types', 'bar_bundles');
* }
*
* function bar_update_7001() {
* // Database table names should be singular when possible.
* db_rename_table('bar_bundles', 'bar_bundle');
* }
*
* function _update_6000_bar_get_types() {
* db_query('SELECT * FROM {bar_types}')->fetchAll();
* }
*
* function _update_7000_bar_get_types() {
* db_query('SELECT * FROM {bar_bundles'})->fetchAll();
* }
*
* function _update_7001_bar_get_types() {
* db_query('SELECT * FROM {bar_bundle}')->fetchAll();
* }
*
See Also
hook_update_N()
hook_update_dependencies()

Function Documentation

_update_7000_field_create_field ( & $field )

Utility function: create a field by writing directly to the database.

This function can be used for databases whose schema is at field module version 7000 or higher.

Definition at line 177 of file field.install.

References db_insert(), field_sql_storage_field_storage_create_field(), module_invoke(), and module_load_install().

Referenced by comment_update_7005(), node_update_7006(), system_update_7060(), and taxonomy_update_7004().

_update_7000_field_create_instance | ( |  | $field,
 |  | & | $instance
 | ) |  |

Utility function: write a field instance directly to the database.

This function can be used for databases whose schema is at field module version 7000 or higher.

Definition at line 363 of file field.install.

References db_insert().

Referenced by comment_update_7005(), node_update_7006(), system_update_7060(), and taxonomy_update_7004().

_update_7000_field_delete_field ( $field_name )

Utility function: delete a field stored in SQL storage directly from the database.

To protect user data, this function can only be used to delete fields once all information it stored is gone. Delete all data from the field_data_$field_name table before calling by either manually issuing delete queries against it or using _update_7000_field_delete_instance().

This function can be used for databases whose schema is at field module version 7000 or higher.

Parameters
$field_name The field name to delete.

Definition at line 258 of file field.install.

References db_delete(), db_drop_table(), db_select(), and get_t().

Referenced by taxonomy_update_7005().

_update_7000_field_delete_instance | ( | $field_name,
 |  | $entity_type,
 |  | $bundle
 | ) |

Utility function: delete an instance and all its data of a field stored in SQL Storage.

BEWARE: this function deletes user data from the field storage tables.

This function is valid for a database schema version 7000.

Definition at line 289 of file field.install.

References db_delete().

Referenced by taxonomy_update_7005().

_update_7000_field_read_fields | ( | array | $conditions = array(),
 |  |  | $key = 'id'
 | ) |  |

Utility function: fetch all the field definitions from the database.

Warning: unlike the field_read_fields() API function, this function returns all fields by default, including deleted and inactive fields, unless specified otherwise in the $conditions parameter.

Parameters
$conditions | An array of conditions to limit the select query to.
$key | The name of the field property the return array is indexed by. Using anything else than 'id' might cause incomplete results if the $conditions do not filter out deleted fields.
Returns
An array of fields matching $conditions, keyed by the property specified by the $key parameter.

Definition at line 328 of file field.install.

References $value, and db_select().

Referenced by field_update_7001(), forum_update_7003(), image_update_7002(), image_update_7004(), list_update_7001(), taxonomy_update_7005(), and text_update_7000().

_update_7000_field_sql_storage_write | ( | $entity_type,
 |  | $bundle,
 |  | $entity_id,
 |  | $revision_id,
 |  | $field_name,
 |  | $data
 | ) |

Utility function: write field data directly to SQL storage.

This function can be used for databases whose schema is at field module version 7000 or higher.

Definition at line 35 of file field_sql_storage.install.

References $value, _field_sql_storage_columnname(), db_delete(), and db_insert().

Referenced by node_update_7006(), and system_update_7061().

_update_7000_node_get_types ( )

Utility function: fetch the node types directly from the database.

This function is valid for a database schema version 7000.

Definition at line 480 of file node.install.

References db_query().

Referenced by comment_update_7000(), comment_update_7005(), comment_update_7006(), menu_update_7000(), menu_update_7001(), node_update_7004(), node_update_7006(), system_update_7017(), system_update_7060(), and taxonomy_update_7004().

_update_7000_user_role_grant_permissions | ( |  | $rid,
 |  | array | $permissions,
 |  |  | $module
 | ) |  |

Utility function: grant a set of permissions to a role during update.

This function is valid for a database schema version 7000.

Parameters
$rid | The role ID.
$permissions | An array of permissions names.
$module | The name of the module defining the permissions.

Definition at line 389 of file user.install.

References $module, $name, and db_merge().

Referenced by filter_update_7005(), filter_update_7008(), node_update_7008(), and system_update_7067().

_update_7002_taxonomy_get_vocabularies ( )

Utility function: get the list of vocabularies directly from the database.

This function is valid for a database schema version 7002.

Definition at line 271 of file taxonomy.install.

References db_query().

Referenced by taxonomy_update_7004().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: .x-to-7.x Updates from 6.x to 7.x

Functions
.x-to-7.x Updates from 6.x to 7.x

Functions

aggregator_update_7000 ()
aggregator_update_7001 ()
aggregator_update_7002 ()
block_update_7000 ()
block_update_7002 ()
block_update_7003 ()
block_update_7004 ()
block_update_7005 ()
block_update_7006 ()
block_update_7007 ()
comment_update_7000 ()
comment_update_7001 ()
comment_update_7002 ()
comment_update_7003 ()
comment_update_7004 ()
comment_update_7005 ()
comment_update_7006 (&$sandbox)
contact_update_7000 ()
contact_update_7001 ()
contact_update_7002 ()
contact_update_7003 ()
dblog_update_7001 ()
field_update_7000 ()
field_update_7001 ()
field_sql_storage_update_7000 ()
field_sql_storage_update_7001 (&$sandbox)
field_sql_storage_update_7002 ()
filter_update_7000 ()
filter_update_7001 ()
filter_update_7003 ()
filter_update_7005 ()
filter_update_7008 ()
filter_update_7009 ()
filter_update_7010 ()
locale_update_7000 ()
locale_update_7001 ()
locale_update_7002 ()
node_update_7000 ()
node_update_7001 ()
node_update_7002 ()
node_update_7003 ()
node_update_7004 ()
node_update_7005 ()
node_update_7006 (&$sandbox)
node_update_7007 ()
node_update_7008 ()
node_update_7009 ()
node_update_7010 ()
openid_update_6000 ()
statistics_update_7000 ()
system_update_7000 ()
system_update_7001 ()
system_update_7002 ()
system_update_7003 ()
system_update_7004 (&$sandbox)
system_update_7005 ()
system_update_7007 ()
system_update_7009 ()
system_update_7011 ()
system_update_7013 ()
system_update_7015 ()
system_update_7016 ()
system_update_7017 ()
system_update_7018 ()
system_update_7020 ()
system_update_7021 ()
system_update_7027 ()
system_update_7029 ()
system_update_7032 ()
system_update_7033 ()
system_update_7034 ()
system_update_7036 ()
system_update_7042 ()
system_update_7044 ()
system_update_7045 ()
system_update_7046 ()
system_update_7047 ()
system_update_7048 ()
system_update_7049 ()
system_update_7050 ()
system_update_7051 ()
system_update_7052 ()
system_update_7053 ()
system_update_7054 ()
system_update_7055 ()
system_update_7057 ()
system_update_7058 ()
system_update_7059 ()
system_update_7060 ()
system_update_7061 (&$sandbox)
system_update_7062 ()
system_update_7063 ()
system_update_7064 ()
system_update_7065 ()
system_update_7066 ()
system_update_7067 ()
system_update_7068 ()
system_update_7069 ()
tracker_update_7000 ()
update_update_7000 ()
update_update_7001 ()
user_update_7000 (&$sandbox)
user_update_7001 ()
user_update_7002 (&$sandbox)
user_update_7003 ()
user_update_7005 (&$sandbox)
user_update_7006 (&$sandbox)
user_update_7007 ()
user_update_7008 ()
user_update_7009 ()
user_update_7010 ()
user_update_7011 ()
user_update_7012 (&$sandbox)
user_update_7013 (&$sandbox)
user_update_7014 ()
user_update_7015 ()

Detailed Description

Update functions from 6.x to 7.x.

Function Documentation

aggregator_update_7000 ( )

Add hash column to aggregator_feed table.

Definition at line 283 of file aggregator.install.

References db_add_field().

aggregator_update_7001 ( )

Add aggregator teaser length to settings from old global default teaser length

Definition at line 290 of file aggregator.install.

References variable_get(), and variable_set().

aggregator_update_7002 ( )

Add queued timestamp.

Definition at line 297 of file aggregator.install.

References db_add_field(), and db_add_index().

block_update_7000 ( )

Set system.weight to a low value for block module.

Block should go first so that other modules can alter its output during hook_page_alter(). Almost everything on the page is a block, so before block module runs, there will not be much to alter.

Definition at line 215 of file block.install.

References db_update().

block_update_7002 ( )

Rename {blocks} table to {block}, {blocks_roles} to {block_role} and {boxes} to {block_custom}.

Definition at line 226 of file block.install.

References db_drop_index(), and db_rename_table().

block_update_7003 ( )

Change the weight column to normal int.

Definition at line 236 of file block.install.

References db_change_field().

block_update_7004 ( )

Add new blocks to new regions, migrate custom variables to blocks.

Definition at line 252 of file block.install.

References BLOCK_VISIBILITY_LISTED, db_insert(), db_query(), db_update(), DRUPAL_CACHE_PER_ROLE, DRUPAL_NO_CACHE, drupal_set_message(), system_rebuild_theme_data(), url(), variable_del(), variable_get(), and variable_set().

block_update_7005 ( )

Update the {block_custom}.format column.

Definition at line 411 of file block.install.

References db_change_field(), db_query(), db_update(), and variable_get().

block_update_7006 ( )

Recreates cache_block table.

Converts fields that hold serialized variables from text to blob. Removes 'headers' column.

Definition at line 440 of file block.install.

References db_create_table(), db_drop_table(), and system_schema_cache_7054().

block_update_7007 ( )

Change {block_custom}.format into varchar.

Definition at line 450 of file block.install.

References db_change_field().

comment_update_7000 ( )

Rename comment display setting variables.

Definition at line 111 of file comment.install.

References _update_7000_node_get_types(), variable_del(), variable_get(), and variable_set().

comment_update_7001 ( )

Change comment status from published being 0 to being 1

Definition at line 144 of file comment.install.

References db_query(), and db_update().

comment_update_7002 ( )

Rename {comments} table to {comment} and upgrade it.

Definition at line 165 of file comment.install.

References db_add_field(), db_add_index(), db_index_exists(), and db_rename_table().

comment_update_7003 ( )

Split {comment}.timestamp into 'created' and 'changed', improve indexing on {comment}.

Definition at line 187 of file comment.install.

References db_add_field(), db_add_index(), db_change_field(), db_drop_index(), and db_query().

comment_update_7004 ( )

Upgrade the {node_comment_statistics} table.

Definition at line 220 of file comment.install.

References db_add_field(), db_add_index(), and db_index_exists().

comment_update_7005 ( )

Create the comment_body field.

Definition at line 239 of file comment.install.

References _update_7000_field_create_field(), _update_7000_field_create_instance(), _update_7000_node_get_types(), and t().

comment_update_7006 ( & $sandbox )

Migrate data from the comment field to field storage.

Definition at line 292 of file comment.install.

References _update_7000_node_get_types(), db_drop_field(), db_insert(), db_query(), db_query_range(), db_select(), db_update(), LANGUAGE_NONE, and variable_get().

contact_update_7000 ( )

Rename the threshold limit variable.

Definition at line 118 of file contact.install.

References variable_del(), variable_get(), and variable_set().

contact_update_7001 ( )

Rename the administer contact forms permission.

Definition at line 126 of file contact.install.

References db_update().

contact_update_7002 ( )

Enable the 'access user contact forms' for registered users by default.

Definition at line 136 of file contact.install.

References db_merge(), and DRUPAL_AUTHENTICATED_RID.

contact_update_7003 ( )

Change the weight column to normal int.

Definition at line 152 of file contact.install.

References db_change_field(), and db_drop_index().

dblog_update_7001 ( )

Update the {watchdog} table.

Definition at line 110 of file dblog.install.

References db_add_index(), and db_change_field().

field_sql_storage_update_7000 ( )

Field SQL storage update version placeholder.

Definition at line 92 of file field_sql_storage.install.

field_sql_storage_update_7001 ( & $sandbox )

Remove the field_config_entity_type table and store 'entity_type' strings.

Definition at line 105 of file field_sql_storage.install.

References $results, db_add_field(), db_add_index(), db_add_primary_key(), db_drop_field(), db_drop_primary_key(), db_drop_table(), db_field_exists(), db_query(), db_select(), db_table_exists(), db_update(), and variable_del().

field_sql_storage_update_7002 ( )

Fix primary keys in field revision data tables.

Definition at line 197 of file field_sql_storage.install.

References $results, db_add_primary_key(), db_drop_primary_key(), and db_select().

field_update_7000 ( )

Field update version placeholder.

Definition at line 398 of file field.install.

field_update_7001 ( )

Fix fields definitions created during the d6 to d7 upgrade path.

Definition at line 410 of file field.install.

References _update_7000_field_read_fields(), db_query(), db_update(), module_invoke(), and module_load_install().

filter_update_7000 ( )

Upgrade the {filter_formats} table and rename it to {filter_format}.

Definition at line 172 of file filter.install.

References db_add_field(), and db_rename_table().

filter_update_7001 ( )

Break out "escape HTML filter" option to its own filter.

Definition at line 199 of file filter.install.

References db_insert(), db_query(), variable_del(), and variable_get().

filter_update_7003 ( )

Upgrade the {filter} table for core filters.

Definition at line 222 of file filter.install.

References $module, db_create_table(), db_delete(), db_insert(), db_rename_table(), db_select(), variable_del(), and variable_get().

filter_update_7005 ( )

Integrate text formats with the user permissions system.

This function converts text format role assignments to use the new text format permissions introduced in Drupal 7, creates a fallback (plain text) format that is available to all users, and explicitly sets the text format in cases that used to rely on a single site-wide default.

Definition at line 352 of file filter.install.

References _update_7000_user_role_grant_permissions(), db_drop_field(), db_insert(), db_query(), db_update(), drupal_set_message(), url(), user_roles(), variable_get(), and variable_set().

filter_update_7008 ( )

Grant usage of all text formats to user roles having the 'administer filters' permission.

Definition at line 447 of file filter.install.

References $name, _update_7000_user_role_grant_permissions(), db_query(), user_roles(), and variable_get().

filter_update_7009 ( )

Converts fields that store serialized variables from text to blob.

Definition at line 468 of file filter.install.

References db_create_table(), db_drop_table(), and system_schema_cache_7054().

filter_update_7010 ( )

Change {filter_format}.format and {filter}.format into varchar.

Definition at line 477 of file filter.install.

References db_change_field().

locale_update_7000 ( )

Add context field index and allow longer location.

Definition at line 37 of file locale.install.

References db_add_index(), db_change_field(), db_drop_index(), and db_index_exists().

locale_update_7001 ( )

Upgrade language negotiation settings.

Definition at line 58 of file locale.install.

References db_update(), DRUPAL_ROOT, language_default(), language_negotiation_set(), LANGUAGE_TYPE_CONTENT, LANGUAGE_TYPE_INTERFACE, LANGUAGE_TYPE_URL, LOCALE_LANGUAGE_NEGOTIATION_BROWSER, locale_language_negotiation_info(), LOCALE_LANGUAGE_NEGOTIATION_INTERFACE, LOCALE_LANGUAGE_NEGOTIATION_URL, LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN, LOCALE_LANGUAGE_NEGOTIATION_USER, variable_del(), variable_get(), and variable_set().

locale_update_7002 ( )

Updates URL language negotiation by adding the URL fallback detection method.

Definition at line 117 of file locale.install.

References $info, DRUPAL_ROOT, language_negotiation_set(), LANGUAGE_TYPE_URL, and language_types_info().

node_update_7000 ( )

Upgrade the node type table and fix node type 'module' attribute to avoid name-space conflicts.

Definition at line 511 of file node.install.

References db_add_field(), db_change_field(), db_select(), and db_update().

node_update_7001 ( )

Rename {node_revisions} table to {node_revision}.

Definition at line 548 of file node.install.

References db_rename_table().

node_update_7002 ( )

Extend the node_promote_status index to include all fields required for the node page query.

Definition at line 555 of file node.install.

References db_add_index(), and db_drop_index().

node_update_7003 ( )

Remove the node_counter if the statistics module is uninstalled.

Definition at line 563 of file node.install.

References db_drop_table(), drupal_get_installed_schema_version(), and SCHEMA_UNINSTALLED.

node_update_7004 ( )

Extend the existing default preview and teaser settings to all node types.

Definition at line 572 of file node.install.

References _update_7000_node_get_types(), node_type_cache_reset(), variable_del(), variable_get(), and variable_set().

node_update_7005 ( )

Add status/comment/promote and sticky columns to the {node_revision} table.

Definition at line 593 of file node.install.

References db_add_field().

node_update_7006 ( & $sandbox )

Convert body and teaser from node properties to fields, and migrate status/comment/promote and sticky columns to the {node_revision} table.

Definition at line 606 of file node.install.

References _update_7000_field_create_field(), _update_7000_field_create_instance(), _update_7000_field_sql_storage_write(), _update_7000_node_get_types(), db_drop_field(), db_query(), db_select(), db_update(), LANGUAGE_NONE, node_type_cache_reset(), text_summary(), variable_del(), and variable_get().

node_update_7007 ( )

Remove column min_word_count.

Definition at line 791 of file node.install.

References db_drop_field().

node_update_7008 ( )

Split the 'administer nodes' permission from 'access content overview'.

Definition at line 798 of file node.install.

References _update_7000_user_role_grant_permissions(), and user_roles().

node_update_7009 ( )

Convert node languages from the empty string to LANGUAGE_NONE.

Definition at line 808 of file node.install.

References db_update(), and LANGUAGE_NONE.

node_update_7010 ( )

Add the {block_node_type} table.

Definition at line 818 of file node.install.

References db_create_table().

openid_update_6000 ( )

Add a table to store nonces.

Definition at line 132 of file openid.install.

References db_create_table().

statistics_update_7000 ( )

Update the {accesslog}.sid column to match the length of {sessions}.sid

Definition at line 147 of file statistics.install.

References db_change_field().

system_update_7000 ( )

Rename blog and forum permissions to be consistent with other content types.

Definition at line 1746 of file system.install.

References db_query(), and db_update().

system_update_7001 ( )

Generate a cron key and save it in the variables table.

Definition at line 1774 of file system.install.

References drupal_random_key(), and variable_set().

system_update_7002 ( )

Add a table to store blocked IP addresses.

Definition at line 1781 of file system.install.

References db_create_table().

system_update_7003 ( )

Update {blocked_ips} with valid IP addresses from {access}.

Definition at line 1811 of file system.install.

References $messages, check_plain(), db_condition(), db_delete(), db_insert(), db_query(), drupal_set_message(), and t().

system_update_7004 ( & $sandbox )

Remove hardcoded numeric deltas from all blocks in core.

Definition at line 1853 of file system.install.

References LANGUAGE_TYPE_INTERFACE, update_fix_d7_block_deltas(), variable_del(), variable_get(), and variable_set().

system_update_7005 ( )

Remove throttle columns and variables.

Definition at line 1904 of file system.install.

References db_drop_field(), and variable_del().

system_update_7007 ( )

Convert to new method of storing permissions.

Definition at line 1916 of file system.install.

References $messages, db_drop_table(), db_insert(), db_query(), and t().

system_update_7009 ( )

Rename the variable for primary links.

Definition at line 1939 of file system.install.

References variable_del(), variable_get(), and variable_set().

system_update_7011 ( )

Split the 'bypass node access' permission from 'administer nodes'.

Definition at line 1950 of file system.install.

References db_insert(), and db_query().

system_update_7013 ( )

Convert default time zone offset to default time zone name.

Definition at line 1971 of file system.install.

References db_query(), drupal_set_message(), format_string(), system_time_zones(), url(), variable_del(), variable_get(), and variable_set().

system_update_7015 ( )

Change the user logout path.

Definition at line 2023 of file system.install.

References db_or(), and db_update().

system_update_7016 ( )

Remove custom datatype *_unsigned in PostgreSQL.

Definition at line 2050 of file system.install.

References $row, db_driver(), and db_query().

system_update_7017 ( )

Change the theme setting 'toggle_node_info' into a per content type variable.

Definition at line 2082 of file system.install.

References $value, _update_7000_node_get_types(), variable_get(), and variable_set().

system_update_7018 ( )

Shorten the {system}.type column and modify indexes.

Definition at line 2108 of file system.install.

References db_add_index(), db_change_field(), and db_drop_index().

system_update_7020 ( )

Enable field and field_ui modules.

Definition at line 2118 of file system.install.

References $module_list, and module_enable().

system_update_7021 ( )

Change the PHP for settings permission.

Definition at line 2126 of file system.install.

References db_update().

system_update_7027 ( )

Enable field type modules.

Definition at line 2136 of file system.install.

References $module_list, and module_enable().

system_update_7029 ( )

Add new 'view own unpublished content' permission for authenticated users. Preserves legacy behavior from Drupal 6.x.

Definition at line 2145 of file system.install.

References db_insert(), and DRUPAL_AUTHENTICATED_RID.

system_update_7032 ( )

Alter field hostname to identifier in the {flood} table.

Definition at line 2157 of file system.install.

References db_add_index(), db_change_field(), and db_drop_index().

system_update_7033 ( )

Move CACHE_AGGRESSIVE to CACHE_NORMAL.

Definition at line 2166 of file system.install.

References t(), variable_get(), and variable_set().

system_update_7034 ( )

Migrate the file path settings and create the new {file_managed} table.

Definition at line 2176 of file system.install.

References db_create_table(), variable_del(), variable_get(), and variable_set().

system_update_7036 ( )

Split the 'access site in maintenance mode' permission from 'administer site configuration'.

Definition at line 2270 of file system.install.

References db_insert(), and db_query().

system_update_7042 ( )

Upgrade the {url_alias} table and create a cache bin for path aliases.

Definition at line 2290 of file system.install.

References db_add_index(), db_change_field(), db_drop_field(), db_drop_index(), db_drop_unique_key(), and drupal_path_alias_whitelist_rebuild().

system_update_7044 ( )

Drop the actions_aid table.

Definition at line 2315 of file system.install.

References db_drop_table().

system_update_7045 ( )

Add expiration field to the {flood} table.

Definition at line 2324 of file system.install.

References db_add_field(), and db_add_index().

system_update_7046 ( )

Switch from the Minnelli theme if it is the default or admin theme.

Definition at line 2332 of file system.install.

References db_update(), drupal_rmdir(), drupal_unlink(), variable_del(), variable_get(), and variable_set().

system_update_7047 ( )

Normalize the front page path variable.

Definition at line 2372 of file system.install.

References drupal_get_normal_path(), variable_get(), and variable_set().

system_update_7048 ( )

Convert path languages from the empty string to LANGUAGE_NONE.

Definition at line 2379 of file system.install.

References db_update(), and LANGUAGE_NONE.

system_update_7049 ( )

Rename 'Default' profile to 'Standard.'

Definition at line 2389 of file system.install.

References variable_get(), and variable_set().

system_update_7050 ( )

Change {batch}.id column from serial to regular int.

Definition at line 2398 of file system.install.

References db_change_field().

system_update_7051 ( )

make the IP field IPv6 compatible

Definition at line 2405 of file system.install.

References db_change_field().

system_update_7052 ( )

Rename file to include_file in {menu_router} table.

Definition at line 2412 of file system.install.

References db_change_field().

system_update_7053 ( )

Upgrade standard blocks and menus.

Definition at line 2419 of file system.install.

References block_flush_caches(), db_insert(), db_or(), db_query(), db_table_exists(), and db_update().

system_update_7054 ( )

Remove {cache_*}.headers columns.

Definition at line 2458 of file system.install.

References db_create_table(), db_drop_table(), and system_schema_cache_7054().

system_update_7055 ( )

Converts fields that store serialized variables from text to blob.

Definition at line 2479 of file system.install.

References db_change_field().

system_update_7057 ( )

Increase the size of session-ids.

Definition at line 2560 of file system.install.

References db_change_field().

system_update_7058 ( )

Remove cron semaphore variable.

Definition at line 2574 of file system.install.

References variable_del().

system_update_7059 ( )

Create the {file_usage} table.

Definition at line 2581 of file system.install.

References db_create_table().

system_update_7060 ( )

Create fields in preparation for migrating upload.module to file.module.

Definition at line 2633 of file system.install.

References $results, $row, _update_7000_field_create_field(), _update_7000_field_create_instance(), _update_7000_node_get_types(), db_drop_table(), db_query(), db_query_range(), db_table_exists(), drupal_set_message(), FIELD_CARDINALITY_UNLIMITED, file_default_scheme(), module_enable(), t(), variable_del(), and variable_get().

system_update_7061 ( & $sandbox )

Migrate upload.module data to the newly created file field.

Definition at line 2762 of file system.install.

References _update_7000_field_sql_storage_write(), conf_path(), db_create_table(), db_delete(), db_drop_table(), db_insert(), db_merge(), db_query(), db_query_range(), db_select(), db_table_exists(), file_default_scheme(), file_stream_wrapper_uri_normalize(), file_usage_add(), LANGUAGE_NONE, t(), and variable_get().

system_update_7062 ( )

Replace 'system_list' index with 'bootstrap' index on {system}.

Definition at line 2915 of file system.install.

References db_add_index(), and db_drop_index().

system_update_7063 ( )

Delete {menu_links} records for 'type' => MENU_CALLBACK which would not appear in a fresh install.

Definition at line 2924 of file system.install.

References db_delete(), and db_query().

system_update_7064 ( )

Remove block_callback field from {menu_router}.

Definition at line 2937 of file system.install.

References db_drop_field().

system_update_7065 ( )

Remove the default value for sid.

Definition at line 2944 of file system.install.

References db_change_field(), db_delete(), and db_drop_primary_key().

system_update_7066 ( )

Migrate the 'file_directory_temp' variable.

Definition at line 2960 of file system.install.

References file_directory_temp(), variable_del(), variable_get(), and variable_set().

system_update_7067 ( )

Grant administrators permission to view the administration theme.

Definition at line 2969 of file system.install.

References _update_7000_user_role_grant_permissions(), check_plain(), drupal_set_message(), url(), user_roles(), and variable_get().

system_update_7068 ( )

Update {url_alias}.language description.

Definition at line 2993 of file system.install.

References db_change_field().

system_update_7069 ( )

Remove the obsolete 'site_offline' variable.

See Also
update_fix_d7_requirements()

Definition at line 3009 of file system.install.

References variable_del().

tracker_update_7000 ( )

Create new tracker_node and tracker_user tables.

Definition at line 128 of file tracker.install.

References $name, db_create_table(), db_query(), and variable_set().

update_update_7000 ( )

Create a queue to store tasks for requests to fetch available update data.

Definition at line 169 of file update.install.

References DrupalQueue::get(), and module_load_include().

update_update_7001 ( )

Recreates cache_update table.

Converts fields that hold serialized variables from text to blob. Removes 'headers' column.

Definition at line 181 of file update.install.

References db_create_table(), db_drop_table(), and system_schema_cache_7054().

user_update_7000 ( & $sandbox )

Increase the length of the password field to accommodate better hashes.

Also re-hashes all current passwords to improve security. This may be a lengthy process, and is performed batch-wise.

Definition at line 415 of file user.install.

References db_change_field(), db_query(), db_query_range(), db_update(), DRUPAL_ROOT, t(), user_hash_password(), and variable_get().

user_update_7001 ( )

Remove the 'threshold', 'mode' and 'sort' columns from the {users} table.

These fields were previously used to store per-user comment settings.

Definition at line 466 of file user.install.

References db_drop_field().

user_update_7002 ( & $sandbox )

Convert user time zones from time zone offsets to time zone names.

Definition at line 475 of file user.install.

References $results, db_change_field(), db_field_exists(), db_query(), db_query_range(), db_update(), drupal_set_message(), format_string(), system_time_zones(), t(), url(), and variable_set().

user_update_7003 ( )

Update user settings for cancelling user accounts.

Prior to 7.x, users were not able to cancel their accounts. When administrators deleted an account, all contents were assigned to uid 0, which is the same as the 'user_cancel_reassign' method now.

Definition at line 552 of file user.install.

References variable_del(), variable_get(), and variable_set().

user_update_7005 ( & $sandbox )

Changes the users table to allow longer e-mail addresses.

Definition at line 574 of file user.install.

References db_change_field(), and db_drop_index().

user_update_7006 ( & $sandbox )

Add module data to {role_permission}.

Definition at line 597 of file user.install.

References db_add_field(), and db_field_exists().

user_update_7007 ( )

Add a weight column to user roles.

Definition at line 616 of file user.install.

References db_add_field(), and db_add_index().

user_update_7008 ( )

If 'user_register' variable was unset in Drupal 6, set it to be the same as the Drupal 6 default setting.

Definition at line 625 of file user.install.

References USER_REGISTER_VISITORS, and variable_set().

user_update_7009 ( )

Converts fields that store serialized variables from text to blob.

Definition at line 635 of file user.install.

References db_change_field().

user_update_7010 ( )

Update the {user}.signature_format column.

Definition at line 649 of file user.install.

References db_change_field(), db_query(), db_update(), and variable_get().

user_update_7011 ( )

Placeholder function.

As a fix for user_update_7011() not updating email templates to use the new tokens, user_update_7017() now targets email templates of Drupal 6 sites and already upgraded sites.

Definition at line 702 of file user.install.

user_update_7012 ( & $sandbox )

Add the user's pictures to the {file_managed} table and make them managed files.

Definition at line 709 of file user.install.

References db_add_field(), db_change_field(), db_drop_field(), db_field_exists(), db_query(), db_query_range(), db_update(), drupal_basename(), file_get_mimetype(), file_load_multiple(), file_save(), and FILE_STATUS_PERMANENT.

user_update_7013 ( & $sandbox )

Add user module file usage entries.

Definition at line 782 of file user.install.

References $row, db_query(), db_query_range(), and file_usage_add().

user_update_7014 ( )

Rename the 'post comments without approval' permission.

In Drupal 7, this permission has been renamed to 'skip comment approval'.

Definition at line 812 of file user.install.

References db_update(), and t().

user_update_7015 ( )

Change {users}.signature_format into varchar.

Definition at line 824 of file user.install.

References db_change_field().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: .x-extra Extra updates for 7.x

Functions
.x-extra Extra updates for 7.x

Functions

aggregator_update_7003 ()
block_update_7008 ()
color_update_7001 ()
comment_update_7007 ()
comment_update_7008 ()
comment_update_7009 ()
dblog_update_7002 ()
field_update_7002 ()
field_update_7003 ()
list_update_7002 ()
forum_update_7002 ()
forum_update_7003 ()
forum_update_7011 ()
forum_update_7012 ()
image_update_7001 ()
_image_update_7002_add_columns ($table, $field_name)
_image_update_7002_populate_dimensions ($table, $field_name, &$last_fid)
image_update_7002 (array &$sandbox)
image_update_7003 ()
image_update_7004 ()
image_update_7005 ()
locale_update_7003 ()
locale_update_7004 ()
locale_update_7005 ()
menu_update_7000 ()
menu_update_7001 ()
menu_update_7002 (&$sandbox)
menu_update_7003 (&$sandbox)
node_update_7011 ()
node_update_7012 ()
node_update_7013 ()
node_update_7014 ()
openid_update_7000 ()
poll_update_7004 ()
system_update_7070 ()
system_update_7071 ()
system_update_7072 ()
system_update_7073 ()
system_update_7074 ()
system_update_7076 ()
system_update_7077 ()
system_update_7078 ()
system_update_7079 ()
taxonomy_update_7011 ()
trigger_update_7001 ()
trigger_update_7002 ()
user_update_7016 ()
user_update_7017 ()
user_update_7018 ()

Detailed Description

End of "defgroup updates-6.x-to-7.x". The next series of updates should start at 8000.

Update functions between 7.x versions.

End of "addtogroup updates-6.x-to-7.x"

End of "addtogroup updates-6.x-to-7.x".

Function Documentation

_image_update_7002_add_columns | ( | $table,
 |  | $field_name
 | ) |

Add width and height columns to a specific table.

Parameters
$table | The name of the database table to be updated.
$columns | Keyed array of columns this table is supposed to have.

Definition at line 288 of file image.install.

References db_add_field().

Referenced by image_update_7002().

_image_update_7002_populate_dimensions | ( |  | $table,
 |  |  | $field_name,
 |  | & | $last_fid
 | ) |  |

Populate image dimensions in a specific table.

Parameters
$table | The name of the database table to be updated.
$columns | Keyed array of columns this table is supposed to have.
$last_fid | The fid of the last image to have been processed.
Returns
The number of images that were processed.

Definition at line 314 of file image.install.

References $info, db_select(), db_update(), and image_get_info().

Referenced by image_update_7002().

aggregator_update_7003 ( )

Increase the length of {aggregator_feed}.url.

Definition at line 319 of file aggregator.install.

References db_add_index(), db_change_field(), and db_drop_unique_key().

block_update_7008 ( )

Update database to match Drupal 7 schema.

Definition at line 471 of file block.install.

References db_drop_field().

color_update_7001 ( )

Warn site administrator if unsafe CSS color codes are found in the database.

Definition at line 52 of file color.install.

References $name, db_query(), drupal_set_message(), url(), and variable_get().

comment_update_7007 ( )

Add an index to the created column.

Definition at line 359 of file comment.install.

References db_add_index().

comment_update_7008 ( )

Update database to match Drupal 7 schema.

Definition at line 366 of file comment.install.

References db_add_index(), db_change_field(), and db_drop_index().

comment_update_7009 ( )

Change the last_comment_timestamp column description.

Definition at line 386 of file comment.install.

References db_change_field().

dblog_update_7002 ( )

Add an index to the severity column in the watchdog database table.

Definition at line 153 of file dblog.install.

References db_add_index().

field_update_7002 ( )

Split the all-inclusive field_bundle_settings variable per bundle.

Definition at line 450 of file field.install.

References variable_del(), variable_get(), and variable_set().

field_update_7003 ( )

Add the FieldInfo class to the class registry.

Definition at line 465 of file field.install.

forum_update_7002 ( )

Add new index to forum_index table.

Definition at line 362 of file forum.install.

References db_add_index(), and db_drop_index().

forum_update_7003 ( )

Rename field to 'taxonomy_forums'.

Definition at line 370 of file forum.install.

References $messages, _update_7000_field_read_fields(), cache_clear_all(), db_add_index(), db_change_field(), db_drop_index(), db_rename_table(), db_select(), db_update(), t(), and variable_get().

forum_update_7011 ( )

Update {forum_index} so that only published nodes are indexed.

Definition at line 447 of file forum.install.

References db_delete(), and db_select().

forum_update_7012 ( )

Add 'created' and 'last_comment_timestamp' indexes.

Definition at line 460 of file forum.install.

References db_add_index().

image_update_7001 ( )

Rename possibly misnamed {image_effect} table to {image_effects}.

Definition at line 271 of file image.install.

References db_rename_table(), and db_table_exists().

image_update_7002 ( array & $sandbox )

Add width and height columns to image field schema and populate.

Definition at line 356 of file image.install.

References _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), _image_update_7002_add_columns(), _image_update_7002_populate_dimensions(), _update_7000_field_read_fields(), and db_select().

image_update_7003 ( )

Remove the variables that set alt and title length since they were not used for database column size and could cause PDO exceptions.

Definition at line 417 of file image.install.

References variable_del().

image_update_7004 ( )

Use a large setting (512 and 1024 characters) for the length of the image alt and title fields.

Definition at line 426 of file image.install.

References _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), _update_7000_field_read_fields(), and db_change_field().

image_update_7005 ( )

Add a column to the 'image_style' table to store administrative labels.

Definition at line 461 of file image.install.

References $styles, db_add_field(), db_query(), and db_update().

list_update_7002 ( )

Re-apply list_update_7001() for deleted fields.

Definition at line 127 of file list.install.

References list_update_7001().

locale_update_7003 ( )

Update "language_count" variable.

Definition at line 140 of file locale.install.

References language_list(), and variable_set().

locale_update_7004 ( )

Remove duplicates in {locales_source}.

Definition at line 148 of file locale.install.

References $url, db_delete(), db_query(), and drupal_set_message().

locale_update_7005 ( )

Increase {locales_languages}.formula column's length.

Definition at line 207 of file locale.install.

References db_change_field().

menu_update_7000 ( )

Migrate the "Default menu for content" setting to individual node types.

Definition at line 80 of file menu.install.

References _update_7000_node_get_types(), db_query(), variable_del(), variable_get(), and variable_set().

menu_update_7001 ( )

Rename "Primary Links" and "Secondary Links" to their Drupal 7 equivalents.

Definition at line 114 of file menu.install.

References _update_7000_node_get_types(), db_update(), variable_del(), variable_get(), and variable_set().

menu_update_7002 ( & $sandbox )

Rename the primary/secondary menu blocks to match previously renamed menus.

Definition at line 168 of file menu.install.

References db_table_exists(), and update_fix_d7_block_deltas().

menu_update_7003 ( & $sandbox )

Add missing custom menus to active menus list.

Definition at line 188 of file menu.install.

References cache_clear_all(), menu_get_names(), menu_list_system_menus(), variable_get(), and variable_set().

node_update_7011 ( )

Update the database from Drupal 6 to match the schema.

Definition at line 862 of file node.install.

References db_change_field(), db_drop_field(), and db_drop_index().

node_update_7012 ( )

Switches body fields to untranslatable while upgrading from D6 and makes them language neutral.

Definition at line 885 of file node.install.

References db_update(), LANGUAGE_NONE, node_type_cache_reset(), and variable_get().

node_update_7013 ( )

Change {node}.vid default value from 0 to NULL to avoid deadlock issues on MySQL.

Definition at line 917 of file node.install.

References db_add_unique_key(), db_change_field(), and db_drop_unique_key().

node_update_7014 ( )

Add an index on {node}.language.

Definition at line 932 of file node.install.

References db_add_index().

openid_update_7000 ( )

Bind associations to their providers.

Definition at line 174 of file openid.install.

References db_create_table(), and db_drop_table().

poll_update_7004 ( )

Update the database to match the schema.

Definition at line 208 of file poll.install.

References db_change_field().

system_update_7070 ( )

Remove the obsolete 'drupal_badge_color' and 'drupal_badge_size' variables.

Definition at line 3027 of file system.install.

References variable_del().

system_update_7071 ( )

Add index missed during upgrade, and fix field default.

Definition at line 3035 of file system.install.

References db_add_index(), db_change_field(), and db_drop_index().

system_update_7072 ( )

Remove the obsolete 'site_offline_message' variable.

See Also
update_fix_d7_requirements()

Definition at line 3050 of file system.install.

References variable_del().

system_update_7073 ( )

Add binary to {file_managed}, in case system_update_7034() was run without it.

Definition at line 3058 of file system.install.

References db_add_unique_key(), db_change_field(), and db_drop_unique_key().

system_update_7074 ( )

This update has been removed and will not run.

Definition at line 3082 of file system.install.

system_update_7076 ( )

Convert menu_links query strings into arrays.

Definition at line 3091 of file system.install.

References db_select(), db_update(), and drupal_get_query_array().

system_update_7077 ( )

Revert {file_managed}.filename changed to a binary column.

Definition at line 3113 of file system.install.

References db_change_field().

system_update_7078 ( )

Add binary to {date_formats}.format.

Definition at line 3127 of file system.install.

References db_change_field(), and db_drop_unique_key().

system_update_7079 ( )

Convert the 'filesize' column in {file_managed} to a bigint.

Definition at line 3141 of file system.install.

References db_change_field().

taxonomy_update_7011 ( )

Drop unpublished nodes from the index.

Definition at line 906 of file taxonomy.install.

References db_delete(), db_query(), and NODE_NOT_PUBLISHED.

trigger_update_7001 ( )

Increase the length of the "hook" field to 78 characters.

This is a separate function for those who ran an older version of trigger_update_7000() that did not do this.

Definition at line 93 of file trigger.install.

References db_change_field(), and db_drop_primary_key().

trigger_update_7002 ( )

Renames nodeapi to node.

Definition at line 101 of file trigger.install.

References db_query(), and db_update().

user_update_7016 ( )

Update the database to match the schema.

Definition at line 845 of file user.install.

References db_change_field().

user_update_7017 ( )

Update email templates to use new tokens.

This function upgrades customized email templates from the old !token format to the new core tokens format. Additionally, in Drupal 7 we no longer e-mail plain text passwords to users, and there is no token for a plain text password in the new token system. Therefore, it also modifies any saved templates using the old '!password' token such that the token is removed, and displays a warning to users that they may need to go and modify the wording of their templates.

Definition at line 866 of file user.install.

References $row, $value, db_like(), db_select(), t(), url(), variable_get(), and variable_set().

user_update_7018 ( )

Ensure there is an index on {users}.picture.

Definition at line 905 of file user.install.

References db_add_index(), and db_index_exists().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Authorized operations

Functions
Authorized operations

Functions

system_authorized_init ($callback, $file, $arguments=array(), $page_title=NULL)
system_authorized_get_url (array $options=array())
system_authorized_batch_processing_url ()
system_authorized_run ($callback, $file, $arguments=array(), $page_title=NULL)
system_authorized_batch_process ()

Detailed Description

Functions to run operations with elevated privileges via authorize.php.

Because of the Update manager functionality included in Drupal core, there is a mechanism for running operations with elevated file system privileges, the top-level authorize.php script. This script runs at a reduced Drupal bootstrap level so that it is not reliant on the entire site being functional. The operations use a FileTransfer class to manipulate code installed on the system as the user that owns the files, not the user that the httpd is running as.

The first setup is to define a callback function that should be authorized to run with the elevated privileges. This callback should take a FileTransfer as its first argument, although you can define an array of other arguments it should be invoked with. The callback should be placed in a separate .inc file that will be included by authorize.php.

To run the operation, certain data must be saved into the SESSION, and then the flow of control should be redirected to the authorize.php script. There are two ways to do this, either to call system_authorized_run() directly, or to call system_authorized_init() and then redirect to authorize.php, using the URL from system_authorized_get_url(). Redirecting yourself is necessary when your authorized operation is being triggered by a form submit handler, since calling drupal_goto() in a submit handler is a bad idea, and you should instead set $form_state['redirect'].

Once the SESSION is setup for the operation and the user is redirected to authorize.php, they will be prompted for their connection credentials (core provides FTP and SSH by default, although other connection classes can be added via contributed modules). With valid credentials, authorize.php will instantiate the appropriate FileTransfer object, and then invoke the desired operation passing in that object. The authorize.php script can act as a Batch API processing page, if the operation requires a batch.

See Also
authorize.php
FileTransfer
hook_filetransfer_info()

Function Documentation

system_authorized_batch_process ( )

Use authorize.php to run batch_process().

See Also
batch_process()

Definition at line 1834 of file system.module.

References batch_process(), system_authorized_batch_processing_url(), and system_authorized_get_url().

Referenced by update_authorize_run_install(), and update_authorize_run_update().

system_authorized_batch_processing_url ( )

Returns the URL for the authorize.php script when it is processing a batch.

Definition at line 1815 of file system.module.

References system_authorized_get_url().

Referenced by overlay_drupal_goto_alter(), and system_authorized_batch_process().

system_authorized_get_url ( array $options = array() )

Return the URL for the authorize.php script.

Parameters
array $options Optional array of options to pass to url().
Returns
The full URL to authorize.php, using HTTPS if available.
See Also
system_authorized_init()

Definition at line 1803 of file system.module.

References $base_url, and url().

Referenced by overlay_drupal_goto_alter(), system_authorized_batch_process(), system_authorized_batch_processing_url(), system_authorized_run(), update_manager_install_form_submit(), and update_manager_update_ready_form_submit().

system_authorized_init | ( | $callback,
 |  | $file,
 |  | $arguments = array(),
 |  | $page_title = NULL
 | ) |

Setup a given callback to run via authorize.php with elevated privileges.

To use authorize.php, certain variables must be stashed into $_SESSION. This function sets up all the necessary $_SESSION variables. The calling function should then redirect to authorize.php, using the full path returned by system_authorized_get_url(). That initiates the workflow that will eventually lead to the callback being invoked. The callback will be invoked at a low bootstrap level, without all modules being invoked, so it needs to be careful not to assume any code exists. Example (system_authorized_run()):

* system_authorized_init($callback, $file, $arguments, $page_title);
* drupal_goto(system_authorized_get_url());
*

Example (update_manager_install_form_submit()):

* system_authorized_init('update_authorize_run_install',
* drupal_get_path('module', 'update') . '/update.authorize.inc',
* $arguments, t('Update manager'));
* $form_state['redirect'] = system_authorized_get_url();
*
Parameters
$callback | The name of the function to invoke once the user authorizes the operation.
$file | The full path to the file where the callback function is implemented.
$arguments | Optional array of arguments to pass into the callback when it is invoked. Note that the first argument to the callback is always the FileTransfer object created by authorize.php when the user authorizes the operation.
$page_title | Optional string to use as the page title once redirected to authorize.php.
Returns
Nothing, this function just initializes variables in the user's session.

Definition at line 1775 of file system.module.

References drupal_get_filetransfer_info().

Referenced by system_authorized_run(), update_manager_install_form_submit(), and update_manager_update_ready_form_submit().

system_authorized_run | ( | $callback,
 |  | $file,
 |  | $arguments = array(),
 |  | $page_title = NULL
 | ) |

Setup and invoke an operation using authorize.php.

See Also
system_authorized_init()

Definition at line 1824 of file system.module.

References drupal_goto(), system_authorized_get_url(), and system_authorized_init().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Queue operations

Classes
Queue operations

Classes

class | DrupalQueue
interface | DrupalQueueInterface
interface | DrupalReliableQueueInterface
class | SystemQueue
class | MemoryQueue

Detailed Description

Queue items to allow later processing.

The queue system allows placing items in a queue and processing them later. The system tries to ensure that only one consumer can process an item.

Before a queue can be used it needs to be created by DrupalQueueInterface::createQueue().

Items can be added to the queue by passing an arbitrary data object to DrupalQueueInterface::createItem().

To process an item, call DrupalQueueInterface::claimItem() and specify how long you want to have a lease for working on that item. When finished processing, the item needs to be deleted by calling DrupalQueueInterface::deleteItem(). If the consumer dies, the item will be made available again by the DrupalQueueInterface implementation once the lease expires. Another consumer will then be able to receive it when calling DrupalQueueInterface::claimItem(). Due to this, the processing code should be aware that an item might be handed over for processing more than once.

The $item object used by the DrupalQueueInterface can contain arbitrary metadata depending on the implementation. Systems using the interface should only rely on the data property which will contain the information passed to DrupalQueueInterface::createItem(). The full queue item returned by DrupalQueueInterface::claimItem() needs to be passed to DrupalQueueInterface::deleteItem() once processing is completed.

There are two kinds of queue backends available: reliable, which preserves the order of messages and guarantees that every item will be executed at least once. The non-reliable kind only does a best effort to preserve order in messages and to execute them at least once but there is a small chance that some items get lost. For example, some distributed back-ends like Amazon SQS will be managing jobs for a large set of producers and consumers where a strict FIFO ordering will likely not be preserved. Another example would be an in-memory queue backend which might lose items if it crashes. However, such a backend would be able to deal with significantly more writes than a reliable queue and for many tasks this is more important. See aggregator_cron() for an example of how to effectively utilize a non-reliable queue. Another example is doing Twitter statistics – the small possibility of losing a few items is insignificant next to power of the queue being able to keep up with writes. As described in the processing section, regardless of the queue being reliable or not, the processing code should be aware that an item might be handed over for processing more than once (because the processing code might time out before it finishes).

Class Documentation

class DrupalQueue

Factory class for interacting with queues.

Definition at line 60 of file system.queue.inc.

Static Public Member Functions

static get ($name, $reliable=FALSE)

Member Function Documentation

static get | ( | $name,
 |  | $reliable = FALSE
 | ) |
static

Returns the queue object for a given name.

The following variables can be set by variable_set or $conf overrides:

  • queue_class_
    name:
    the class to be used for the queue
    name.
  • queue_default_class: the class to use when queue_class_$name is not defined. Defaults to SystemQueue, a reliable backend using SQL.
  • queue_default_reliable_class: the class to use when queue_class_$name is not defined and the queue_default_class is not reliable. Defaults to SystemQueue.
Parameters
$name | Arbitrary string. The name of the queue to work with.
$reliable | TRUE if the ordering of items and guaranteeing every item executes at least once is important, FALSE if scalability is the main concern.
Returns
The queue object for a given name.

Definition at line 81 of file system.queue.inc.

References $name, and variable_get().

Referenced by _update_create_fetch_task(), _update_fetch_data(), aggregator_cron(), cron_example_add_jobs_to_queue(), cron_example_form(), drupal_cron_run(), hook_cron(), queue_example_add_remove_form_claim(), queue_example_add_remove_form_clear_queue(), queue_example_add_remove_form_delete(), queue_example_add_remove_form_insert(), queue_example_add_remove_form_run_cron(), queue_example_show_queue(), update_fetch_data_batch(), update_install(), update_uninstall(), and update_update_7000().

interface DrupalQueueInterface

Definition at line 99 of file system.queue.inc.

Inheritance diagram for DrupalQueueInterface:
DrupalReliableQueueInterface MemoryQueue SystemQueue BatchMemoryQueue BatchQueue

Public Member Functions

createItem ($data)
numberOfItems ()
claimItem ($lease_time=3600)
deleteItem ($item)
releaseItem ($item)
createQueue ()
deleteQueue ()

Member Function Documentation

claimItem ( $lease_time = 3600 )

Claim an item in the queue for processing.

Parameters
$lease_time How long the processing is expected to take in seconds, defaults to an hour. After this lease expires, the item will be reset and another consumer can claim the item. For idempotent tasks (which can be run multiple times without side effects), shorter lease times would result in lower latency in case a consumer fails. For tasks that should not be run more than once (non-idempotent), a larger lease time will make it more rare for a given task to run multiple times in cases of failure, at the cost of higher latency.
Returns
On success we return an item object. If the queue is unable to claim an item it returns false. This implies a best effort to retrieve an item and either the queue is empty or there is some other non-recoverable problem.

Implemented in MemoryQueue, SystemQueue, BatchMemoryQueue, and BatchQueue.

createItem ( $data )

Add a queue item and store it directly to the queue.

Parameters
$data Arbitrary data to be associated with the new task in the queue.
Returns
TRUE if the item was successfully created and was (best effort) added to the queue, otherwise FALSE. We don't guarantee the item was committed to disk etc, but as far as we know, the item is now in the queue.

Implemented in MemoryQueue, and SystemQueue.

createQueue ( )

Create a queue.

Called during installation and should be used to perform any necessary initialization operations. This should not be confused with the constructor for these objects, which is called every time an object is instantiated to operate on a queue. This operation is only needed the first time a given queue is going to be initialized (for example, to make a new database table or directory to hold tasks for the queue – it depends on the queue implementation if this is necessary at all).

Implemented in MemoryQueue, and SystemQueue.

deleteItem ( $item )

Delete a finished item from the queue.

Parameters
$item The item returned by DrupalQueueInterface::claimItem().

Implemented in MemoryQueue, and SystemQueue.

deleteQueue ( )

Delete a queue and every item in the queue.

Implemented in MemoryQueue, and SystemQueue.

numberOfItems ( )

Retrieve the number of items in the queue.

This is intended to provide a "best guess" count of the number of items in the queue. Depending on the implementation and the setup, the accuracy of the results of this function may vary.

e.g. On a busy system with a large number of consumers and items, the result might only be valid for a fraction of a second and not provide an accurate representation.

Returns
An integer estimate of the number of items in the queue.

Implemented in MemoryQueue, and SystemQueue.

releaseItem ( $item )

Release an item that the worker could not process, so another worker can come in and process it before the timeout expires.

Parameters
$item
Returns
boolean

Implemented in MemoryQueue, and SystemQueue.

interface DrupalReliableQueueInterface

Reliable queue interface.

Classes implementing this interface preserve the order of messages and guarantee that every item will be executed at least once.

Definition at line 192 of file system.queue.inc.

Inheritance diagram for DrupalReliableQueueInterface:
DrupalQueueInterface SystemQueue BatchQueue

Additional Inherited Members

- Public Member Functions inherited from DrupalQueueInterface
createItem ($data)
numberOfItems ()
claimItem ($lease_time=3600)
deleteItem ($item)
releaseItem ($item)
createQueue ()
deleteQueue ()
class SystemQueue

Default queue implementation.

Definition at line 198 of file system.queue.inc.

Inheritance diagram for SystemQueue:
DrupalReliableQueueInterface DrupalQueueInterface BatchQueue

Public Member Functions

__construct ($name)
createItem ($data)
numberOfItems ()
claimItem ($lease_time=30)
releaseItem ($item)
deleteItem ($item)
createQueue ()
deleteQueue ()

Protected Attributes

$name

Constructor & Destructor Documentation

__construct ( $name )

Definition at line 206 of file system.queue.inc.

References $name, and name.

Member Function Documentation

claimItem ( $lease_time = 30 )

Claim an item in the queue for processing.

Parameters
$lease_time How long the processing is expected to take in seconds, defaults to an hour. After this lease expires, the item will be reset and another consumer can claim the item. For idempotent tasks (which can be run multiple times without side effects), shorter lease times would result in lower latency in case a consumer fails. For tasks that should not be run more than once (non-idempotent), a larger lease time will make it more rare for a given task to run multiple times in cases of failure, at the cost of higher latency.
Returns
On success we return an item object. If the queue is unable to claim an item it returns false. This implies a best effort to retrieve an item and either the queue is empty or there is some other non-recoverable problem.

Implements DrupalQueueInterface.

Definition at line 228 of file system.queue.inc.

References db_query_range(), db_update(), and name.

createItem ( $data )

Add a queue item and store it directly to the queue.

Parameters
$data Arbitrary data to be associated with the new task in the queue.
Returns
TRUE if the item was successfully created and was (best effort) added to the queue, otherwise FALSE. We don't guarantee the item was committed to disk etc, but as far as we know, the item is now in the queue.

Implements DrupalQueueInterface.

Definition at line 210 of file system.queue.inc.

References db_insert(), and name.

createQueue ( )

Create a queue.

Called during installation and should be used to perform any necessary initialization operations. This should not be confused with the constructor for these objects, which is called every time an object is instantiated to operate on a queue. This operation is only needed the first time a given queue is going to be initialized (for example, to make a new database table or directory to hold tasks for the queue – it depends on the queue implementation if this is necessary at all).

Implements DrupalQueueInterface.

Definition at line 276 of file system.queue.inc.

deleteItem ( $item )

Delete a finished item from the queue.

Parameters
$item The item returned by DrupalQueueInterface::claimItem().

Implements DrupalQueueInterface.

Definition at line 270 of file system.queue.inc.

References db_delete().

deleteQueue ( )

Delete a queue and every item in the queue.

Implements DrupalQueueInterface.

Definition at line 282 of file system.queue.inc.

References db_delete(), and name.

numberOfItems ( )

Retrieve the number of items in the queue.

This is intended to provide a "best guess" count of the number of items in the queue. Depending on the implementation and the setup, the accuracy of the results of this function may vary.

e.g. On a busy system with a large number of consumers and items, the result might only be valid for a fraction of a second and not provide an accurate representation.

Returns
An integer estimate of the number of items in the queue.

Implements DrupalQueueInterface.

Definition at line 224 of file system.queue.inc.

References db_query(), and name.

releaseItem ( $item )

Release an item that the worker could not process, so another worker can come in and process it before the timeout expires.

Parameters
$item
Returns
boolean

Implements DrupalQueueInterface.

Definition at line 261 of file system.queue.inc.

References db_update().

Member Data Documentation

$name
protected

Definition at line 204 of file system.queue.inc.

Referenced by __construct().

class MemoryQueue

Static queue implementation.

This allows "undelayed" variants of processes relying on the Queue interface. The queue data resides in memory. It should only be used for items that will be queued and dequeued within a given page request.

Definition at line 296 of file system.queue.inc.

Inheritance diagram for MemoryQueue:
DrupalQueueInterface BatchMemoryQueue

Public Member Functions

__construct ($name)
createItem ($data)
numberOfItems ()
claimItem ($lease_time=30)
deleteItem ($item)
releaseItem ($item)
createQueue ()
deleteQueue ()

Protected Attributes

$queue
$id_sequence

Constructor & Destructor Documentation

__construct ( $name )

Start working with a queue.

Parameters
$name Arbitrary string. The name of the queue to work with.

Definition at line 317 of file system.queue.inc.

Member Function Documentation

claimItem ( $lease_time = 30 )

Claim an item in the queue for processing.

Parameters
$lease_time How long the processing is expected to take in seconds, defaults to an hour. After this lease expires, the item will be reset and another consumer can claim the item. For idempotent tasks (which can be run multiple times without side effects), shorter lease times would result in lower latency in case a consumer fails. For tasks that should not be run more than once (non-idempotent), a larger lease time will make it more rare for a given task to run multiple times in cases of failure, at the cost of higher latency.
Returns
On success we return an item object. If the queue is unable to claim an item it returns false. This implies a best effort to retrieve an item and either the queue is empty or there is some other non-recoverable problem.

Implements DrupalQueueInterface.

Definition at line 335 of file system.queue.inc.

createItem ( $data )

Add a queue item and store it directly to the queue.

Parameters
$data Arbitrary data to be associated with the new task in the queue.
Returns
TRUE if the item was successfully created and was (best effort) added to the queue, otherwise FALSE. We don't guarantee the item was committed to disk etc, but as far as we know, the item is now in the queue.

Implements DrupalQueueInterface.

Definition at line 322 of file system.queue.inc.

createQueue ( )

Create a queue.

Called during installation and should be used to perform any necessary initialization operations. This should not be confused with the constructor for these objects, which is called every time an object is instantiated to operate on a queue. This operation is only needed the first time a given queue is going to be initialized (for example, to make a new database table or directory to hold tasks for the queue – it depends on the queue implementation if this is necessary at all).

Implements DrupalQueueInterface.

Definition at line 358 of file system.queue.inc.

deleteItem ( $item )

Delete a finished item from the queue.

Parameters
$item The item returned by DrupalQueueInterface::claimItem().

Implements DrupalQueueInterface.

Definition at line 346 of file system.queue.inc.

deleteQueue ( )

Delete a queue and every item in the queue.

Implements DrupalQueueInterface.

Definition at line 362 of file system.queue.inc.

numberOfItems ( )

Retrieve the number of items in the queue.

This is intended to provide a "best guess" count of the number of items in the queue. Depending on the implementation and the setup, the accuracy of the results of this function may vary.

e.g. On a busy system with a large number of consumers and items, the result might only be valid for a fraction of a second and not provide an accurate representation.

Returns
An integer estimate of the number of items in the queue.

Implements DrupalQueueInterface.

Definition at line 331 of file system.queue.inc.

releaseItem ( $item )

Release an item that the worker could not process, so another worker can come in and process it before the timeout expires.

Parameters
$item
Returns
boolean

Implements DrupalQueueInterface.

Definition at line 350 of file system.queue.inc.

Member Data Documentation

$id_sequence
protected

Definition at line 309 of file system.queue.inc.

$queue
protected

Definition at line 302 of file system.queue.inc.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Default theme implementations

Files | Functions
Default theme implementations

Files

file | aggregator-feed-source.tpl.php
file | aggregator-item.tpl.php
file | aggregator-summary-item.tpl.php
file | aggregator-summary-items.tpl.php
file | aggregator-wrapper.tpl.php
file | block-admin-display-form.tpl.php
file | block.tpl.php
file | book-all-books-block.tpl.php
file | book-export-html.tpl.php
file | book-navigation.tpl.php
file | book-node-export-html.tpl.php
file | comment-wrapper.tpl.php
file | comment.tpl.php
file | field.tpl.php
file | forum-icon.tpl.php
file | forum-list.tpl.php
file | forum-submitted.tpl.php
file | forum-topic-list.tpl.php
file | forums.tpl.php
file | node.tpl.php
file | overlay.tpl.php
file | poll-results.tpl.php
file | poll-vote.tpl.php
file | search-result.tpl.php
file | search-results.tpl.php
file | html.tpl.php
file | maintenance-page.tpl.php
file | page.tpl.php
file | region.tpl.php
file | taxonomy-term.tpl.php
file | toolbar.tpl.php
file | user-picture.tpl.php
file | user-profile.tpl.php

Functions

theme_select ($variables)
theme_fieldset ($variables)
theme_radio ($variables)
theme_radios ($variables)
theme_date ($variables)
theme_checkbox ($variables)
theme_checkboxes ($variables)
theme_container ($variables)
theme_tableselect ($variables)
theme_vertical_tabs ($variables)
theme_submit ($variables)
theme_button ($variables)
theme_image_button ($variables)
theme_hidden ($variables)
theme_textfield ($variables)
theme_form ($variables)
theme_textarea ($variables)
theme_password ($variables)
theme_file ($variables)
theme_form_element ($variables)
theme_form_required_marker ($variables)
theme_form_element_label ($variables)
theme_menu_tree ($variables)
theme_menu_link (array $variables)
theme_menu_local_task ($variables)
theme_menu_local_action ($variables)
theme_menu_local_tasks (&$variables)
theme_pager ($variables)
theme_pager_first ($variables)
theme_pager_previous ($variables)
theme_pager_next ($variables)
theme_pager_last ($variables)
theme_pager_link ($variables)
theme_status_messages ($variables)
theme_link ($variables)
theme_links ($variables)
theme_image ($variables)
theme_breadcrumb ($variables)
theme_table ($variables)
theme_tablesort_indicator ($variables)
theme_mark ($variables)
theme_item_list ($variables)
theme_more_help_link ($variables)
theme_feed_icon ($variables)
theme_html_tag ($variables)
theme_more_link ($variables)
theme_username ($variables)
theme_progress_bar ($variables)
theme_indentation ($variables)
theme_task_list ($variables)
theme_authorize_report ($variables)
theme_authorize_message ($variables)
theme_aggregator_block_item ($variables)
theme_aggregator_categorize_items ($variables)
theme_aggregator_page_rss ($variables)
theme_aggregator_page_opml ($variables)
theme_book_admin_table ($variables)
theme_book_title_link ($variables)
theme_color_scheme_form ($variables)
theme_comment_block ()
theme_comment_post_forbidden ($variables)
theme_dashboard ($variables)
theme_dashboard_admin ($variables)
theme_dashboard_region ($variables)
theme_dashboard_disabled_blocks ($variables)
theme_dashboard_disabled_block ($variables)
theme_dblog_message ($variables)
theme_field_multiple_value_form ($variables)
theme_field ($variables)
theme_options_none ($variables)
theme_field_ui_table ($variables)
theme_file_widget ($variables)
theme_file_widget_multiple ($variables)
theme_file_upload_help ($variables)
theme_file_formatter_table ($variables)
theme_file_managed_file ($variables)
theme_file_link ($variables)
theme_file_icon ($variables)
theme_filter_admin_overview ($variables)
theme_filter_admin_format_filter_order ($variables)
theme_text_format_wrapper ($variables)
theme_filter_tips_more_info ()
theme_filter_guidelines ($variables)
theme_filter_tips ($variables)
theme_forum_form ($variables)
theme_image_style_list ($variables)
theme_image_style_effects ($variables)
theme_image_style_preview ($variables)
theme_image_anchor ($variables)
theme_image_resize_summary ($variables)
theme_image_scale_summary ($variables)
theme_image_crop_summary ($variables)
theme_image_rotate_summary ($variables)
theme_image_widget ($variables)
theme_image_formatter ($variables)
theme_image_style ($variables)
theme_locale_languages_overview_form ($variables)
theme_locale_languages_configure_form ($variables)
theme_locale_date_format_form ($variables)
theme_menu_admin_overview ($variables)
theme_menu_overview_form ($variables)
theme_node_admin_overview ($variables)
theme_node_search_admin ($variables)
theme_node_recent_block ($variables)
theme_node_recent_content ($variables)
theme_node_add_list ($variables)
theme_node_preview ($variables)
theme_overlay_disable_message ($variables)
theme_poll_choices ($variables)
theme_profile_admin_overview ($variables)
theme_shortcut_set_customize ($variables)
theme_simpletest_test_table ($variables)
theme_simpletest_result_summary ($variables)
theme_system_date_time_settings ($variables)
theme_admin_block ($variables)
theme_admin_block_content ($variables)
theme_admin_page ($variables)
theme_system_admin_index ($variables)
theme_status_report ($variables)
theme_system_modules_fieldset ($variables)
theme_system_modules_incompatible ($variables)
theme_system_modules_uninstall ($variables)
theme_system_themes_page ($variables)
theme_system_powered_by ()
theme_system_compact_link ()
theme_confirm_form ($variables)
theme_system_settings_form ($variables)
theme_exposed_filters ($variables)
theme_taxonomy_overview_vocabularies ($variables)
theme_taxonomy_overview_terms ($variables)
theme_trigger_display ($variables)
theme_update_manager_update_form ($variables)
theme_update_last_check ($variables)
theme_update_report ($variables)
theme_update_status_label ($variables)
theme_update_version ($variables)
theme_user_admin_permissions ($variables)
theme_user_permission_description ($variables)
theme_user_admin_roles ($variables)
theme_user_list ($variables)
theme_user_signature ($variables)

Detailed Description

Functions and templates for the user interface to be implemented by themes.

Drupal's presentation layer is a pluggable system known as the theme layer. Each theme can take control over most of Drupal's output, and has complete control over the CSS.

Inside Drupal, the theme layer is utilized by the use of the theme() function, which is passed the name of a component (the theme hook) and an array of variables. For example, theme('table', array('header' => $header, 'rows' => $rows)); Additionally, the theme() function can take an array of theme hooks, which can be used to provide 'fallback' implementations to allow for more specific control of output. For example, the function: theme(array('table__foo', 'table'), $variables) would look to see if 'table__foo' is registered anywhere; if it is not, it would 'fall back' to the generic 'table' implementation. This can be used to attach specific theme functions to named objects, allowing the themer more control over specific types of output.

As of Drupal 6, every theme hook is required to be registered by the module that owns it, so that Drupal can tell what to do with it and to make it simple for themes to identify and override the behavior for these calls.

The theme hooks are registered via hook_theme(), which returns an array of arrays with information about the hook. It describes the arguments the function or template will need, and provides defaults for the template in case they are not filled in. If the default implementation is a function, by convention it is named theme_HOOK().

Each module should provide a default implementation for theme_hooks that it registers. This implementation may be either a function or a template; if it is a function it must be specified via hook_theme(). By convention, default implementations of theme hooks are named theme_HOOK. Default template implementations are stored in the module directory.

Drupal's default template renderer is a simple PHP parsing engine that includes the template and stores the output. Drupal's theme engines can provide alternate template engines, such as XTemplate, Smarty and PHPTal. The most common template engine is PHPTemplate (included with Drupal and implemented in phptemplate.engine, which uses Drupal's default template renderer.

In order to create theme-specific implementations of these hooks, themes can implement their own version of theme hooks, either as functions or templates. These implementations will be used instead of the default implementation. If using a pure .theme without an engine, the .theme is required to implement its own version of hook_theme() to tell Drupal what it is implementing; themes utilizing an engine will have their well-named theming functions automatically registered for them. While this can vary based upon the theme engine, the standard set by phptemplate is that theme functions should be named THEMENAME_HOOK. For example, for Drupal's default theme (Bartik) to implement the 'table' hook, the phptemplate.engine would find bartik_table().

The theme system is described and defined in theme.inc.

See Also
theme()
hook_theme()
Hooks
Callbacks

Function Documentation

theme_admin_block ( $variables )

Returns HTML for an administrative block for display.

Parameters
$variables An associative array containing:
  • block: An array containing information about the block:
    • show: A Boolean whether to output the block. Defaults to FALSE.
    • title: The block's title.
    • content: (optional) Formatted content for the block.
    • description: (optional) Description of the block. Only output if 'content' is not set.

Definition at line 2394 of file system.admin.inc.

References $output.

theme_admin_block_content ( $variables )

Returns HTML for the content of an administrative block.

Parameters
$variables An associative array containing:
  • content: An array containing information about the block. Each element of the array represents an administrative menu item, and must at least contain the keys 'title', 'href', and 'localized_options', which are passed to l(). A 'description' key may also be provided.

Definition at line 2430 of file system.admin.inc.

References $content, $output, filter_xss_admin(), l(), and system_admin_compact_mode().

theme_admin_page ( $variables )

Returns HTML for an administrative page.

Parameters
$variables An associative array containing:
  • blocks: An array of blocks to display. Each array should include a 'title', a 'description', a formatted 'content' and a 'position' which will control which container it will be in. This is usually 'left' or 'right'.

Definition at line 2463 of file system.admin.inc.

References $output, and theme().

theme_aggregator_block_item ( $variables )

Returns HTML for an individual feed item for display in the block.

Parameters
$variables An associative array containing:
  • item: The item to be displayed.
  • feed: Not used.

Definition at line 720 of file aggregator.module.

References check_plain(), check_url(), link, and title.

theme_aggregator_categorize_items ( $variables )

Returns HTML for the aggregator page list form for assigning categories.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 282 of file aggregator.pages.inc.

References $output, drupal_render(), drupal_render_children(), element_children(), t(), and theme().

theme_aggregator_page_opml ( $variables )

Prints the OPML page for the feed.

Parameters
$variables An associative array containing:
  • feeds: An array of the feeds to theme.

Definition at line 500 of file aggregator.pages.inc.

References $output, check_plain(), check_url(), drupal_add_http_header(), print, REQUEST_TIME, and variable_get().

theme_aggregator_page_rss ( $variables )

Prints the RSS page for a feed.

Parameters
$variables An associative array containing:
  • feeds: An array of the feeds to theme.
  • category: A common category, if any, for all the feeds.
Returns
void

Definition at line 433 of file aggregator.pages.inc.

References $output, $site_name, $url, check_url(), drupal_add_http_header(), format_rss_channel(), format_rss_item(), print, t(), text_summary(), url(), and variable_get().

theme_authorize_message ( $variables )

Returns HTML for a single log message from the authorize.php batch operation.

Parameters
$variables An associative array containing:
  • message: The log message.
  • success: A boolean indicating failure or success.

Definition at line 201 of file theme.maintenance.inc.

theme_authorize_report ( $variables )

Returns HTML for a results report of an operation run by authorize.php.

Parameters
$variables An associative array containing:
  • messages: An array of result messages.

Definition at line 171 of file theme.maintenance.inc.

References $messages, $output, and theme().

theme_book_admin_table ( $variables )

Returns HTML for a book administration form.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.
See Also
book_admin_table()

Definition at line 252 of file book.admin.inc.

References $header, $row, drupal_add_tabledrag(), drupal_get_destination(), drupal_render(), element_children(), l(), MENU_MAX_DEPTH, t(), theme(), and user_access().

theme_book_title_link ( $variables )

Returns HTML for a link to a book title when used as a block title.

Parameters
$variables An associative array containing:
  • link: An array containing title, href and options for the link.

Definition at line 363 of file book.module.

References l().

theme_breadcrumb ( $variables )

Returns HTML for a breadcrumb trail.

Parameters
$variables An associative array containing:
  • breadcrumb: An array containing the breadcrumb links.

Definition at line 1805 of file theme.inc.

References $breadcrumb, $output, and t().

theme_button ( $variables )

Returns HTML for a button form element.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: #attributes, #button_type, name, value.

Definition at line 3757 of file form.inc.

References drupal_attributes(), and element_set_attributes().

theme_checkbox ( $variables )

Returns HTML for a checkbox form element.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: title, value, #return_value, #description, #required, #attributes, #checked.

Definition at line 3073 of file form.inc.

References _form_set_class(), drupal_attributes(), and element_set_attributes().

theme_checkboxes ( $variables )

Returns HTML for a set of checkbox form elements.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: #children, #attributes.

Definition at line 3097 of file form.inc.

References $attributes, and drupal_attributes().

theme_color_scheme_form ( $variables )

Returns HTML for a theme's color form.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 264 of file color.module.

References $info, $name, $output, drupal_add_css(), drupal_add_js(), drupal_get_path(), drupal_render(), drupal_render_children(), DRUPAL_ROOT, element_children(), and t().

theme_comment_block ( )

Returns HTML for a list of recent comments to be displayed in the comment block.

Definition at line 597 of file comment.module.

References comment_get_recent(), format_interval(), l(), REQUEST_TIME, t(), theme(), and variable_get().

theme_comment_post_forbidden ( $variables )

Returns HTML for a "you can't post comments" notice.

Parameters
$variables An associative array containing:
  • node: The comment node.

Definition at line 2360 of file comment.module.

References COMMENT_FORM_BELOW, COMMENT_FORM_SEPARATE_PAGE, DRUPAL_AUTHENTICATED_RID, drupal_static(), t(), url(), USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, user_roles(), and variable_get().

theme_confirm_form ( $variables )

Returns HTML for a confirmation form.

By default this does not alter the appearance of a form at all, but is provided as a convenience for themers.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 3959 of file system.module.

References drupal_render_children().

theme_container ( $variables )

Returns HTML to wrap child elements in a container.

Used for grouped form items. Can also be used as a #theme_wrapper for any renderable element, to surround it with a

and add attributes such as classes or an HTML id.
Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: #id, #attributes, #children.

Definition at line 3252 of file form.inc.

References drupal_attributes().

theme_dashboard ( $variables )

Returns HTML for the entire dashboard.

Parameters
$variables An associative array containing:
  • element: A render element containing the properties of the dashboard region element, #dashboard_region and #children.

Definition at line 594 of file dashboard.module.

References drupal_add_css(), and drupal_get_path().

theme_dashboard_admin ( $variables )

Returns HTML for the non-customizable part of the dashboard page.

Parameters
$variables An associative array containing:
  • element: A render element containing a #message.

Definition at line 609 of file dashboard.module.

theme_dashboard_disabled_block ( $variables )

Returns HTML for disabled blocks, for use in dashboard customization mode.

Parameters
$variables An associative array containing:
  • block: A block object from _block_rehash().

Definition at line 668 of file dashboard.module.

References $output, and check_plain().

theme_dashboard_disabled_blocks ( $variables )

Returns HTML for disabled blocks, for use in dashboard customization mode.

Parameters
$variables An associative array containing:
  • blocks: An array of block objects from _block_rehash().

Definition at line 646 of file dashboard.module.

References $output, l(), t(), theme(), and url().

theme_dashboard_region ( $variables )

Returns HTML for a generic dashboard region.

Parameters
$variables An associative array containing:
  • element: A render element containing the properties of the dashboard region element, #dashboard_region and #children.

Definition at line 625 of file dashboard.module.

References $output.

theme_date ( $variables )

Returns HTML for a date selection form element.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: title, value, #options, #description, #required, #attributes.

Definition at line 2913 of file form.inc.

References $attributes, drupal_attributes(), and drupal_render_children().

theme_dblog_message ( $variables )

Returns HTML for a log message.

Parameters
array $variables An associative array containing:
  • event: An object with at least the message and variables properties.
  • link: (optional) Format message as link, event->wid is required.

Definition at line 284 of file dblog.admin.inc.

References $output, filter_xss(), l(), t(), and truncate_utf8().

theme_exposed_filters ( $variables )

Returns HTML for an exposed filter form.

Parameters
$variables An associative array containing:
  • form: An associative array containing the structure of the form.
Returns
A string containing an HTML-formatted form.

Definition at line 3991 of file system.module.

References $output, drupal_render(), drupal_render_children(), element_children(), and theme().

theme_feed_icon ( $variables )

Returns HTML for a feed icon.

Parameters
$variables An associative array containing:
  • url: An internal system path or a fully qualified external URL of the feed.
  • title: A descriptive title of the feed.

Definition at line 2159 of file theme.inc.

References l(), t(), and theme().

theme_field ( $variables )

End of "defgroup field". Returns HTML for a field.

This is the default theme implementation to display the value of a field. Theme developers who are comfortable with overriding theme functions may do so in order to customize this markup. This function can be overridden with varying levels of specificity. For example, for a field named 'body' displayed on the 'article' content type, any of the following functions will override this default implementation. The first of these functions that exists is used:

  • THEMENAME_field__body__article()
  • THEMENAME_field__article()
  • THEMENAME_field__body()
  • THEMENAME_field()

Theme developers who prefer to customize templates instead of overriding functions may copy the "field.tpl.php" from the "modules/field/theme" folder of the Drupal installation to somewhere within the theme's folder and customize it, just like customizing other Drupal templates such as page.tpl.php or node.tpl.php. However, it takes longer for the server to process templates than to call a function, so for websites with many fields displayed on a page, this can result in a noticeable slowdown of the website. For these websites, developers are discouraged from placing a field.tpl.php file into the theme's folder, but may customize templates for specific fields. For example, for a field named 'body' displayed on the 'article' content type, any of the following templates will override this default implementation. The first of these templates that exists is used:

  • field–body–article.tpl.php
  • field–article.tpl.php
  • field–body.tpl.php
  • field.tpl.php So, if the body field on the article content type needs customization, a field–body–article.tpl.php file can be added within the theme's folder. Because it's a template, it will result in slightly more time needed to display that field, but it will not impact other fields, and therefore, is unlikely to cause a noticeable change in website performance. A very rough guideline is that if a page is being displayed with more than 100 fields and they are all themed with a template instead of a function, it can add up to 5% to the time it takes to display that page. This is a guideline only and the exact performance impact depends on the server configuration and the details of the website.
Parameters
$variables An associative array containing:
  • label_hidden: A boolean indicating to show or hide the field label.
  • title_attributes: A string containing the attributes for the title.
  • label: The label for the field.
  • content_attributes: A string containing the attributes for the content's div.
  • items: An array of field items.
  • item_attributes: An array of attributes for each item.
  • classes: A string containing the classes for the wrapping div.
  • attributes: A string containing the attributes for the wrapping div.
See Also
template_preprocess_field()
template_process_field()
field.tpl.php

Definition at line 1161 of file field.module.

References $classes, $output, and drupal_render().

theme_field_multiple_value_form ( $variables )

Returns HTML for an individual form element.

Combine multiple values into a table with drag-n-drop reordering. TODO : convert to a template.

Parameters
$variables An associative array containing:
  • element: A render element representing the form element.

Definition at line 301 of file field.form.inc.

References $header, $output, drupal_add_tabledrag(), drupal_html_id(), drupal_render(), element_children(), FIELD_CARDINALITY_UNLIMITED, t(), and theme().

theme_field_ui_table ( $variables )

Returns HTML for Field UI overview tables.

Parameters
$variables An associative array containing:
  • elements: An associative array containing a Form API structure to be rendered as a table.

Definition at line 207 of file field_ui.admin.inc.

References $header, $name, $row, drupal_html_class(), drupal_render(), element_children(), and theme().

theme_fieldset ( $variables )

Returns HTML for a fieldset form element and its children.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: #attributes, #children, #collapsed, #collapsible, #description, #id, title, value.

Definition at line 2772 of file form.inc.

References $output, _form_set_class(), drupal_attributes(), and element_set_attributes().

theme_file ( $variables )

Returns HTML for a file upload form element.

For assistance with handling the uploaded file correctly, see the API provided by file.inc.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: title, name, #size, #description, #required, #attributes.

Definition at line 3969 of file form.inc.

References _form_set_class(), drupal_attributes(), and element_set_attributes().

theme_file_formatter_table ( $variables )

Returns HTML for a file attachments table.

Parameters
$variables An associative array containing:
  • items: An array of file attachments.

Definition at line 1013 of file file.field.inc.

References $header, format_size(), t(), and theme().

theme_file_icon ( $variables )

Returns HTML for an image with an appropriate icon for the given file.

Parameters
$variables An associative array containing:
  • file: A file object for which to make an icon.
  • icon_directory: (optional) A path to a directory of icons to be used for files. Defaults to the value of the "file_icon_directory" variable.

Definition at line 761 of file file.module.

References check_plain(), and file_icon_url().

theme_file_link ( $variables )

Returns HTML for a link to a file.

Parameters
$variables An associative array containing:
  • file: A file object to which the link will be created.
  • icon_directory: (optional) A path to a directory of icons to be used for files. Defaults to the value of the "file_icon_directory" variable.

Definition at line 723 of file file.module.

References $url, check_plain(), file_create_url(), l(), and theme().

theme_file_managed_file ( $variables )

Returns HTML for a managed file element.

Parameters
$variables An associative array containing:
  • element: A render element representing the file.

Definition at line 660 of file file.module.

References $attributes, $output, drupal_attributes(), and drupal_render_children().

theme_file_upload_help ( $variables )

Returns HTML for help text based on file upload validators.

Parameters
$variables An associative array containing:
  • description: The normal description for this field, specified by the user.
  • upload_validators: An array of upload validators as used in $element['#upload_validators'].

Definition at line 933 of file file.field.inc.

References check_plain(), format_size(), and t().

theme_file_widget ( $variables )

Returns HTML for an individual file upload widget.

Parameters
$variables An associative array containing:
  • element: A render element representing the widget.

Definition at line 799 of file file.field.inc.

References $output, drupal_render_children(), and format_size().

theme_file_widget_multiple ( $variables )

Returns HTML for a group of file upload widgets.

Parameters
$variables An associative array containing:
  • element: A render element representing the widgets.

Definition at line 824 of file file.field.inc.

References $output, $row, drupal_add_tabledrag(), drupal_render(), drupal_render_children(), element_children(), hide(), render(), t(), and theme().

theme_filter_admin_format_filter_order ( $variables )

Returns HTML for a text format's filter order form.

Parameters
$variables An associative array containing:
  • element: A render element representing the form.

Definition at line 303 of file filter.admin.inc.

References $name, $output, drupal_add_tabledrag(), drupal_render(), drupal_render_children(), element_children(), and theme().

theme_filter_admin_overview ( $variables )

Returns HTML for the text format administration overview form.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 75 of file filter.admin.inc.

References $header, $output, drupal_add_tabledrag(), drupal_render(), drupal_render_children(), element_children(), t(), and theme().

theme_filter_guidelines ( $variables )

Returns HTML for guidelines for a text format.

Parameters
$variables An associative array containing:
  • format: An object representing a text format.

Definition at line 1197 of file filter.module.

References $attributes, $output, _filter_tips(), check_plain(), drupal_attributes(), and theme().

theme_filter_tips ( $variables )

Returns HTML for a set of filter tips.

Parameters
$variables An associative array containing:
  • tips: An array containing descriptions and a CSS ID in the form of 'module-name/filter-id' (only used when $long is TRUE) for each filter in one or more text formats. Example:
    * array(
    * 'Full HTML' => array(
    * 0 => array(
    * 'tip' => 'Web page addresses and e-mail addresses turn into links automatically.',
    * 'id' => 'filter/2',
    * ),
    * ),
    * );
    *
  • long: (optional) Whether the passed-in filter tips contain extended explanations, i.e. intended to be output on the path 'filter/tips' (TRUE), or are in a short format, i.e. suitable to be displayed below a form element. Defaults to FALSE.
See Also
_filter_tips()

Definition at line 54 of file filter.pages.inc.

References $name, $output, drupal_html_class(), and t().

theme_filter_tips_more_info ( )

Returns HTML for a link to the more extensive filter tips.

Definition at line 1184 of file filter.module.

References l(), and t().

theme_form ( $variables )

Returns HTML for a form.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: #action, #method, #attributes, #children

Definition at line 3862 of file form.inc.

References drupal_attributes(), drupal_strip_dangerous_protocols(), and element_set_attributes().

theme_form_element ( $variables )

Returns HTML for a form element.

Each form element is wrapped in a DIV container having the following CSS classes:

  • form-item: Generic for all form elements.
  • form-type-#type: The internal element #type.
  • form-item-name: The internal form element name (usually derived from the $form structure and set via form_builder()).
  • form-disabled: Only set if the form element is #disabled.

In addition to the element itself, the DIV contains a label for the element based on the optional #title_display property, and an optional #description.

The optional #title_display property can have these values:

  • before: The label is output before the element. This is the default. The label includes the title and the required marker, if #required.
  • after: The label is output after the element. For example, this is used for radio and checkbox #type elements as set in system_element_info(). If the title is empty but the field is #required, the label will contain only the required marker.
  • invisible: Labels are critical for screen readers to enable them to properly navigate through forms but can be visually distracting. This property hides the label for everyone except screen readers.
  • attribute: Set the title attribute on the element to create a tooltip but output no label element. This is supported only for checkboxes and radios in form_pre_render_conditional_form_element(). It is used where a visual label is not needed, such as a table of checkboxes where the row and column provide the context. The tooltip will include the title and required marker.

If the title property is not set, then the label and any required marker will not be output, regardless of the #title_display or #required values. This can be useful in cases such as the password_confirm element, which creates children elements that have their own labels and required markers, but the parent element should have neither. Use this carefully because a field without an associated label can cause accessibility challenges.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: title, #title_display, #description, #id, #required, #children, #type, name.

Definition at line 4024 of file form.inc.

References $attributes, $output, drupal_attributes(), and theme().

theme_form_element_label ( $variables )

Returns HTML for a form element label and required marker.

Form element labels include the title and a #required marker. The label is associated with the element itself by the element #id. Labels may appear before or after elements, depending on theme_form_element() and #title_display.

This function will not be called for elements with no labels, depending on #title_display. For elements that have an empty title and are not required, this function will output no label (''). For required elements that have an empty title, this will output the required marker alone within the label. The label will use the #id to associate the marker with the field that is required. That is especially important for screenreader users to know which field is required.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: #required, title, #id, value, #description.

Definition at line 4128 of file form.inc.

References $attributes, $title, drupal_attributes(), filter_xss_admin(), get_t(), and theme().

theme_form_required_marker ( $variables )

Returns HTML for a marker for required form elements.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element.

Definition at line 4095 of file form.inc.

References $attributes, drupal_attributes(), and get_t().

theme_forum_form ( $variables )

Returns HTML for a forum form.

By default this does not alter the appearance of a form at all, but is provided as a convenience for themers.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 134 of file forum.admin.inc.

References drupal_render_children().

theme_hidden ( $variables )

Returns HTML for a hidden form element.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: name, value, #attributes.

Definition at line 3809 of file form.inc.

References drupal_attributes(), and element_set_attributes().

theme_html_tag ( $variables )

Returns HTML for a generic HTML tag with attributes.

Parameters
$variables An associative array containing:
  • element: An associative array describing the tag:
    • #tag: The tag name to output. Typical tags added to the HTML HEAD:
      • meta: To provide meta information, such as a page refresh.
      • link: To refer to stylesheets and other contextual information.
      • script: To load JavaScript.
    • #attributes: (optional) An array of HTML attributes to apply to the tag.
    • value: (optional) A string containing tag content, such as inline CSS.
    • #value_prefix: (optional) A string to prepend to value, e.g. a CDATA wrapper prefix.
    • #value_suffix: (optional) A string to append to value, e.g. a CDATA wrapper suffix.

Definition at line 2185 of file theme.inc.

References $attributes, $output, and drupal_attributes().

theme_image ( $variables )

Returns HTML for an image.

Parameters
$variables An associative array containing:
  • path: Either the path of the image file (relative to base_path()) or a full URL.
  • width: The width of the image (if known).
  • height: The height of the image (if known).
  • alt: The alternative text for text-based browsers. HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft allows the alt attribute to be omitted in some cases. Therefore, this variable defaults to an empty string, but can be set to NULL for the attribute to be omitted. Usually, neither omission nor an empty string satisfies accessibility requirements, so it is strongly encouraged for code calling theme('image') to pass a meaningful value for this variable.
    • http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.8
    • http://www.w3.org/TR/xhtml1/dtds.html
    • http://dev.w3.org/html5/spec/Overview.html#alt
  • title: The title text is displayed when the image is hovered in some popular browsers.
  • attributes: Associative array of attributes to be placed in the img tag.

Definition at line 1784 of file theme.inc.

References $attributes, drupal_attributes(), and file_create_url().

theme_image_anchor ( $variables )

Returns HTML for a 3x3 grid of checkboxes for image anchors.

Parameters
$variables An associative array containing:
  • element: A render element containing radio buttons.

Definition at line 848 of file image.admin.inc.

References $row, drupal_render(), element_children(), and theme().

theme_image_button ( $variables )

Returns HTML for an image button form element.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: #attributes, #button_type, name, value, title, #src.

Definition at line 3780 of file form.inc.

References drupal_attributes(), element_set_attributes(), and file_create_url().

theme_image_crop_summary ( $variables )

Returns HTML for a summary of an image crop effect.

Parameters
$variables An associative array containing:
  • data: The current configuration for this crop effect.

Definition at line 909 of file image.admin.inc.

References theme().

theme_image_formatter ( $variables )

Returns HTML for an image field formatter.

Parameters
$variables An associative array containing:
  • item: Associative array of image data, which may include "uri", "alt", "width", "height", "title" and "attributes".
  • image_style: An optional image style.
  • path: An array containing the link 'path' and link 'options'.

Definition at line 599 of file image.field.inc.

References $output, drupal_strlen(), l(), and theme().

theme_image_resize_summary ( $variables )

Returns HTML for a summary of an image resize effect.

Parameters
$variables An associative array containing:
  • data: The current configuration for this resize effect.

Definition at line 875 of file image.admin.inc.

References check_plain(), and t().

theme_image_rotate_summary ( $variables )

Returns HTML for a summary of an image rotate effect.

Parameters
$variables An associative array containing:
  • data: The current configuration for this rotate effect.

Definition at line 922 of file image.admin.inc.

References t().

theme_image_scale_summary ( $variables )

Returns HTML for a summary of an image scale effect.

Parameters
$variables An associative array containing:
  • data: The current configuration for this scale effect.

Definition at line 895 of file image.admin.inc.

References t(), and theme().

theme_image_style ( $variables )

Returns HTML for an image using a specific image style.

Parameters
$variables An associative array containing:
  • style_name: The name of the style to be used to alter the original image.
  • path: The path of the image file relative to the Drupal files directory. This function does not work with images outside the files directory nor with remotely hosted images. This should be in a format such as 'images/image.jpg', or using a stream wrapper such as 'public://images/image.jpg'.
  • width: The width of the source image (if known).
  • height: The height of the source image (if known).
  • alt: The alternative text for text-based browsers.
  • title: The title text is displayed when the image is hovered in some popular browsers.
  • attributes: Associative array of attributes to be placed in the img tag.

Definition at line 1346 of file image.module.

References image_style_transform_dimensions(), image_style_url(), and theme().

theme_image_style_effects ( $variables )

Returns HTML for a listing of the effects within a specific image style.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 714 of file image.admin.inc.

References $header, $output, $row, drupal_add_tabledrag(), drupal_render(), element_children(), t(), and theme().

theme_image_style_list ( $variables )

Returns HTML for the page containing the list of image styles.

Parameters
$variables An associative array containing:
  • styles: An array of all the image styles returned by image_get_styles().
See Also
image_get_styles()

Definition at line 664 of file image.admin.inc.

References $header, $row, $styles, IMAGE_STORAGE_NORMAL, IMAGE_STORAGE_OVERRIDE, l(), t(), theme(), and url().

theme_image_style_preview ( $variables )

Returns HTML for a preview of an image style.

Parameters
$variables An associative array containing:
  • style: The image style array being previewed.

Definition at line 771 of file image.admin.inc.

References $output, check_plain(), drupal_get_path(), file_create_url(), image_get_info(), image_style_create_derivative(), image_style_path(), l(), REQUEST_TIME, t(), theme(), and variable_get().

theme_image_widget ( $variables )

Returns HTML for an image field widget.

Parameters
$variables An associative array containing:
  • element: A render element representing the image field widget.

Definition at line 454 of file image.field.inc.

References $output, drupal_render(), drupal_render_children(), and format_size().

theme_indentation ( $variables )

Returns HTML for an indentation div; used for drag and drop tables.

Parameters
$variables An associative array containing:
  • size: Optional. The number of indentations to create.

Definition at line 2278 of file theme.inc.

References $output.

theme_item_list ( $variables )

Returns HTML for a list or nested list of items.

Parameters
$variables An associative array containing:
  • items: An array of items to be displayed in the list. If an item is a string, then it is used as is. If an item is an array, then the "data" element of the array is used as the contents of the list item. If an item is an array with a "children" element, those children are displayed in a nested list. All other elements are treated as attributes of the list item element.
  • title: The title of the list.
  • type: The type of list to return (e.g. "ul", "ol").
  • attributes: The attributes applied to the list element.

Definition at line 2082 of file theme.inc.

References $attributes, $children, $output, $title, $value, and drupal_attributes().

theme_link ( $variables )

Returns HTML for a link.

All Drupal code that outputs a link should call the l() function. That function performs some initial preprocessing, and then, if necessary, calls theme('link') for rendering the anchor tag.

To optimize performance for sites that don't need custom theming of links, the l() function includes an inline copy of this function, and uses that copy if none of the enabled modules or the active theme implement any preprocess or process functions or override this theme implementation.

Parameters
$variables An associative array containing the keys 'text', 'path', and 'options'. See the l() function for information about these variables.
See Also
l()

Definition at line 1645 of file theme.inc.

References check_plain(), drupal_attributes(), and url().

theme_links ( $variables )

Returns HTML for a set of links.

Parameters
$variables An associative array containing:
  • links: An associative array of links to be themed. The key for each link is used as its CSS class. Each link should be itself an array, with the following elements:
    • title: The link text.
    • href: The link URL. If omitted, the 'title' is shown as a plain text item in the links list.
    • html: (optional) Whether or not 'title' is HTML. If set, the title will not be passed through check_plain().
    • attributes: (optional) Attributes for the anchor, or for the tag used in its place if no 'href' is supplied. If element 'class' is included, it must be an array of one or more class names. If the 'href' element is supplied, the entire link array is passed to l() as its $options parameter.
  • attributes: A keyed array of attributes for the UL containing the list of links.
  • heading: (optional) A heading to precede the links. May be an associative array or a string. If it's an array, it can have the following elements:
    • text: The heading text.
    • level: The heading level (e.g. 'h2', 'h3').
    • class: (optional) An array of the CSS classes for the heading. When using a string it will be used as the text of the heading and the level will default to 'h2'. Headings should be used on navigation menus and any list of links that consistently appears on multiple pages. To make the heading invisible use the 'element-invisible' CSS class. Do not use 'display:none', which removes it from screen-readers and assistive technology. Headings allow screen-reader and keyboard only users to navigate to or skip the links. See http://juicystudio.com/article/screen-readers-display-none.php and http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.

Definition at line 1685 of file theme.inc.

References $attributes, $links, $output, check_plain(), drupal_attributes(), drupal_is_front_page(), l(), and language.

theme_locale_date_format_form ( $variables )

End of "locale-translate-edit-delete" Returns HTML for a locale date format form.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 1285 of file locale.admin.inc.

References $header, $output, $row, drupal_render(), drupal_render_children(), element_children(), t(), and theme().

theme_locale_languages_configure_form ( $variables )

Returns HTML for a language configuration form.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 614 of file locale.admin.inc.

References $header, $info, $output, $row, $title, drupal_add_tabledrag(), drupal_render(), drupal_render_children(), element_child(), t(), and theme().

theme_locale_languages_overview_form ( $variables )

Returns HTML for the language overview form.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 73 of file locale.admin.inc.

References $header, $output, $title, check_plain(), drupal_add_tabledrag(), drupal_render(), drupal_render_children(), element_child(), l(), language_default(), t(), and theme().

theme_mark ( $variables )

Returns HTML for a marker for new or updated content.

Parameters
$variables An associative array containing:
  • type: Number representing the marker type to display. See MARK_NEW, MARK_UPDATED, MARK_READ.

Definition at line 2054 of file theme.inc.

References MARK_NEW, MARK_UPDATED, and t().

theme_menu_admin_overview ( $variables )

Returns HTML for a menu title and description for the menu overview page.

Parameters
$variables An associative array containing:
  • title: The menu's title.
  • description: The menu's description.

Definition at line 36 of file menu.admin.inc.

References $output, check_plain(), and filter_xss_admin().

theme_menu_link ( array $variables )

Returns HTML for a menu link and submenu.

Parameters
$variables An associative array containing:
  • element: Structured array data for a menu link.

Definition at line 1625 of file menu.inc.

References $output, drupal_attributes(), drupal_render(), and l().

theme_menu_local_action ( $variables )

Returns HTML for a single local action link.

Parameters
$variables An associative array containing:
  • element: A render element containing:
    • link: A menu link array with 'title', 'href', and 'localized_options' keys.

Definition at line 1679 of file menu.inc.

References $output, check_plain(), and l().

theme_menu_local_task ( $variables )

Returns HTML for a single local task link.

Parameters
$variables An associative array containing:
  • element: A render element containing:
    • link: A menu link array with 'title', 'href', and 'localized_options' keys.
    • #active: A boolean indicating whether the local task is active.

Definition at line 1648 of file menu.inc.

References check_plain(), l(), and t().

theme_menu_local_tasks ( & $variables )

Returns HTML for primary and secondary local tasks.

Parameters
$variables An associative array containing:
  • primary: (optional) An array of local tasks (tabs).
  • secondary: (optional) An array of local tasks (tabs).
See Also
menu_local_tasks()

Definition at line 2280 of file menu.inc.

References $output, drupal_render(), and t().

theme_menu_overview_form ( $variables )

Returns HTML for the menu overview form into a table.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 208 of file menu.admin.inc.

References $header, $op, $output, $row, drupal_add_tabledrag(), drupal_render(), drupal_render_children(), element_children(), MENU_MAX_DEPTH, t(), and theme().

theme_menu_tree ( $variables )

Returns HTML for a wrapper for a menu sub-tree.

Parameters
$variables An associative array containing:
  • tree: An HTML string containing the tree's items.
See Also
template_preprocess_menu_tree()

Definition at line 1612 of file menu.inc.

theme_more_help_link ( $variables )

Returns HTML for a "more help" link.

Parameters
$variables An associative array containing:
  • url: The URL for the link.

Definition at line 2146 of file theme.inc.

References l(), and t().

theme_more_link ( $variables )

Returns HTML for a "more" link, like those used in blocks.

Parameters
$variables An associative array containing:
  • url: The URL of the main page.
  • title: A descriptive verb for the link, like 'Read more'.

Definition at line 2213 of file theme.inc.

References l(), and t().

theme_node_add_list ( $variables )

Returns HTML for a list of available node types for node creation.

Parameters
$variables An associative array containing:
  • content: An array of content types.

Definition at line 44 of file node.pages.inc.

References $content, $output, filter_xss_admin(), l(), t(), and url().

theme_node_admin_overview ( $variables )

Returns HTML for a node type description for the content type admin overview page.

Parameters
$variables An associative array containing:
  • name: The human-readable name of the content type.
  • type: An object containing the 'type' (machine name) and 'description' of the content type.

Definition at line 67 of file content_types.inc.

References $name, $output, check_plain(), filter_xss_admin(), and t().

theme_node_preview ( $variables )

Returns HTML for a node preview for display during node creation and editing.

Parameters
$variables An associative array containing:
  • node: The node object which is being previewed.
See Also
node_preview()

Definition at line 420 of file node.pages.inc.

References $output, drupal_render(), drupal_set_message(), node_view(), and t().

theme_node_recent_block ( $variables )

Returns HTML for a list of recent content.

Parameters
$variables An associative array containing:
  • nodes: An array of recent node objects.

Definition at line 2358 of file node.module.

References $output, $row, drupal_get_destination(), l(), node_access(), t(), theme(), and user_access().

theme_node_recent_content ( $variables )

Returns HTML for a recent node to be displayed in the recent content block.

Parameters
$variables An associative array containing:
  • node: A node object.

Definition at line 2399 of file node.module.

References $output, l(), node_mark(), theme(), and user_load().

theme_node_search_admin ( $variables )

Returns HTML for the content ranking part of the search settings admin page.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.
See Also
node_search_admin()

Definition at line 1868 of file node.module.

References $header, $output, $row, drupal_render(), drupal_render_children(), element_children(), t(), and theme().

theme_options_none ( $variables )

Returns HTML for the label for the empty value for options that are not required.

The default theme will display N/A for a radio list and '- None -' for a select.

Parameters
$variables An associative array containing:
  • instance: An array representing the widget requesting the options.

Definition at line 401 of file options.module.

References $output, and t().

theme_overlay_disable_message ( $variables )

Returns the HTML for the message about how to disable the overlay.

Parameters
$variables An associative array with an 'element' element, which itself is an associative array containing:
  • profile_link: The link to this user's account.
  • dismiss_message_link: The link to dismiss the overlay.

Definition at line 405 of file overlay.module.

References $output, drupal_render(), overlay_get_mode(), and t().

theme_pager ( $variables )

Returns HTML for a query pager.

Menu callbacks that display paged query results should call theme('pager') to retrieve a pager control so that users can view other results. Format a list of nearby pages with additional query results.

Parameters
$variables An associative array containing:
  • tags: An array of labels for the controls in the pager.
  • element: An optional integer to distinguish between multiple pagers on one page.
  • parameters: An associative array of query string parameters to append to the pager links.
  • quantity: The number of pages in the list.

Definition at line 320 of file pager.inc.

References t(), and theme().

theme_pager_first ( $variables )

Returns HTML for the "first page" link in a query pager.

Parameters
$variables An associative array containing:
  • text: The name (or image) of the link.
  • element: An optional integer to distinguish between multiple pagers on one page.
  • parameters: An associative array of query string parameters to append to the pager links.

Definition at line 451 of file pager.inc.

References $output, pager_load_array(), and theme().

theme_pager_last ( $variables )

Returns HTML for the "last page" link in query pager.

Parameters
$variables An associative array containing:
  • text: The name (or image) of the link.
  • element: An optional integer to distinguish between multiple pagers on one page.
  • parameters: An associative array of query string parameters to append to the pager links.

Definition at line 556 of file pager.inc.

References $output, pager_load_array(), and theme().

theme_pager_link ( $variables )

Returns HTML for a link to a specific query result page.

Parameters
$variables An associative array containing:
  • text: The link text. Also used to figure out the title attribute of the link, if it is not provided in $variables['attributes']['title']; in this case, $variables['text'] must be one of the standard pager link text strings that would be generated by the pager theme functions, such as a number or t('« first').
  • page_new: The first result to display on the linked page.
  • element: An optional integer to distinguish between multiple pagers on one page.
  • parameters: An associative array of query string parameters to append to the pager link.
  • attributes: An associative array of HTML attributes to apply to the pager link.
See Also
theme_pager()

Definition at line 594 of file pager.inc.

References $attributes, $page, check_plain(), drupal_attributes(), drupal_get_query_parameters(), pager_get_query_parameters(), pager_load_array(), t(), and url().

theme_pager_next ( $variables )

Returns HTML for the "next page" link in a query pager.

Parameters
$variables An associative array containing:
  • text: The name (or image) of the link.
  • element: An optional integer to distinguish between multiple pagers on one page.
  • interval: The number of pages to move forward when the link is clicked.
  • parameters: An associative array of query string parameters to append to the pager links.

Definition at line 519 of file pager.inc.

References $output, pager_load_array(), and theme().

theme_pager_previous ( $variables )

Returns HTML for the "previous page" link in a query pager.

Parameters
$variables An associative array containing:
  • text: The name (or image) of the link.
  • element: An optional integer to distinguish between multiple pagers on one page.
  • interval: The number of pages to move backward when the link is clicked.
  • parameters: An associative array of query string parameters to append to the pager links.

Definition at line 480 of file pager.inc.

References $output, pager_load_array(), and theme().

theme_password ( $variables )

Returns HTML for a password form element.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: title, value, #description, #size, #maxlength, #required, #attributes.

Definition at line 3918 of file form.inc.

References _form_set_class(), drupal_attributes(), and element_set_attributes().

theme_poll_choices ( $variables )

Returns HTML for an admin poll form for choices.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 851 of file poll.module.

References $output, $row, drupal_add_tabledrag(), drupal_render(), drupal_render_children(), element_children(), t(), theme(), and user_access().

theme_profile_admin_overview ( $variables )

Returns HTML for the profile field overview form into a drag and drop enabled table.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.
See Also
profile_admin_overview()

Definition at line 114 of file profile.admin.inc.

References $header, $output, $row, check_plain(), drupal_add_css(), drupal_add_js(), drupal_add_tabledrag(), drupal_get_path(), drupal_render(), drupal_render_children(), element_children(), t(), and theme().

theme_progress_bar ( $variables )

Returns HTML for a progress bar.

Note that the core Batch API uses this only for non-JavaScript batch jobs.

Parameters
$variables An associative array containing:
  • percent: The percentage of the progress.
  • message: A string containing information to be displayed.

Definition at line 2261 of file theme.inc.

References $output.

theme_radio ( $variables )

Returns HTML for a radio button form element.

Note: The input "name" attribute needs to be sanitized before output, which is currently done by passing all attributes to drupal_attributes().

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: #required, #return_value, value, #attributes, title, #description

Definition at line 2809 of file form.inc.

References _form_set_class(), drupal_attributes(), and element_set_attributes().

theme_radios ( $variables )

Returns HTML for a set of radio button form elements.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: title, value, #options, #description, #required, #attributes, #children.

Definition at line 2833 of file form.inc.

References $attributes, and drupal_attributes().

theme_select ( $variables )

Returns HTML for a select form element.

It is possible to group options together; to do this, change the format of $options to an associative array in which the keys are group labels, and the values are associative arrays in the normal $options format.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: title, value, #options, #description, #extra, #multiple, #required, name, #attributes, #size.

Definition at line 2658 of file form.inc.

References _form_set_class(), drupal_attributes(), element_set_attributes(), and form_select_options().

theme_shortcut_set_customize ( $variables )

Returns HTML for a shortcut set customization form.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.
See Also
shortcut_set_customize()

Definition at line 340 of file shortcut.admin.inc.

References $header, $output, $row, drupal_add_tabledrag(), drupal_render(), drupal_render_children(), element_children(), shortcut_max_slots(), t(), theme(), and url().

theme_simpletest_result_summary ( $variables )

Returns HTML for the summary status of a simpletest result.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 379 of file simpletest.pages.inc.

References _simpletest_format_summary_line().

theme_simpletest_test_table ( $variables )

Returns HTML for a test list generated by simpletest_test_form() into a table.

Parameters
$variables An associative array containing:
  • table: A render element representing the table.

Definition at line 68 of file simpletest.pages.inc.

References $header, $row, $title, drupal_add_css(), drupal_add_js(), drupal_get_path(), drupal_render(), element_children(), t(), and theme().

theme_status_messages ( $variables )

Returns HTML for status and/or error messages, grouped by type.

An invisible heading identifies the messages for assistive technology. Sighted users see a colored box. See http://www.w3.org/TR/WCAG-TECHS/H69.html for info.

Parameters
$variables An associative array containing:
  • display: (optional) Set to 'status' or 'error' to display only messages of that type.

Definition at line 1598 of file theme.inc.

References $messages, $output, drupal_get_messages(), and t().

theme_status_report ( $variables )

Returns HTML for the status report.

Parameters
$variables An associative array containing:
  • requirements: An array of requirements.

Definition at line 2555 of file system.admin.inc.

References $output, REQUIREMENT_ERROR, REQUIREMENT_INFO, REQUIREMENT_OK, REQUIREMENT_WARNING, and t().

theme_submit ( $variables )

Returns HTML for a submit button form element.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: #attributes, #button_type, name, value.

Definition at line 3743 of file form.inc.

References theme().

theme_system_admin_index ( $variables )

Returns HTML for the output of the dashboard page.

Parameters
$variables An associative array containing:
  • menu_items: An array of modules to be displayed.

Definition at line 2503 of file system.admin.inc.

References $module, $output, t(), and theme().

theme_system_compact_link ( )

Returns HTML for a link to show or hide inline help descriptions.

Definition at line 3396 of file system.module.

References $output, drupal_get_destination(), l(), system_admin_compact_mode(), and t().

theme_system_date_time_settings ( $variables )

Returns HTML for the date settings form.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 2072 of file system.admin.inc.

References $header, $output, $row, drupal_render(), drupal_render_children(), element_children(), t(), and theme().

theme_system_modules_fieldset ( $variables )

Returns HTML for the modules form.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 2606 of file system.admin.inc.

References $module, $row, drupal_render(), element_children(), t(), and theme().

theme_system_modules_incompatible ( $variables )

Returns HTML for a message about incompatible modules.

Parameters
$variables An associative array containing:
  • message: The form array representing the currently disabled modules.

Definition at line 2653 of file system.admin.inc.

theme_system_modules_uninstall ( $variables )

Returns HTML for a table of currently disabled modules.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 2666 of file system.admin.inc.

References $header, $module, $output, drupal_render(), drupal_render_children(), element_children(), format_plural(), t(), and theme().

theme_system_powered_by ( )

Returns HTML for the Powered by Drupal text.

Definition at line 3387 of file system.module.

References t().

theme_system_settings_form ( $variables )

Returns HTML for a system settings form.

By default this does not alter the appearance of a form at all, but is provided as a convenience for themers.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 3975 of file system.module.

References drupal_render_children().

theme_system_themes_page ( $variables )

Returns HTML for the Appearance page.

Parameters
$variables An associative array containing:
  • theme_groups: An associative array containing groups of themes.

Definition at line 2715 of file system.admin.inc.

References $output, $title, DRUPAL_CORE_COMPATIBILITY, t(), and theme().

theme_table ( $variables )

Returns HTML for a table.

Parameters
$variables An associative array containing:
  • header: An array containing the table headers. Each element of the array can be either a localized string or an associative array with the following keys:
    • "data": The localized title of the table column.
    • "field": The database field represented in the table column (required if user is to be able to sort on this column).
    • "sort": A default sort order for this column ("asc" or "desc"). Only one column should be given a default sort order because table sorting only applies to one column at a time.
    • Any HTML attributes, such as "colspan", to apply to the column header cell.
  • rows: An array of table rows. Every row is an array of cells, or an associative array with the following keys:
    • "data": an array of cells
    • Any HTML attributes, such as "class", to apply to the table row.
    • "no_striping": a boolean indicating that the row should receive no 'even / odd' styling. Defaults to FALSE. Each cell can be either a string or an associative array with the following keys:
    • "data": The string to display in the table cell.
    • "header": Indicates this cell is a header.
    • Any HTML attributes, such as "colspan", to apply to the table cell. Here's an example for $rows:
      * $rows = array(
      * // Simple row
      * array(
      * 'Cell 1', 'Cell 2', 'Cell 3'
      * ),
      * // Row with attributes on the row and some of its cells.
      * array(
      * 'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 'class' => array('funky')
      * )
      * );
      *
  • attributes: An array of HTML attributes to apply to the table tag.
  • caption: A localized string to use for the tag.
  • colgroups: An array of column groups. Each element of the array can be either:
    • An array of columns, each of which is an associative array of HTML attributes applied to the COL element.
    • An array of attributes applied to the COLGROUP element, which must include a "data" attribute. To add attributes to COL elements, set the "data" attribute with an array of columns, each of which is an associative array of HTML attributes. Here's an example for $colgroup:
      * $colgroup = array(
      * // COLGROUP with one COL element.
      * array(
      * array(
      * 'class' => array('funky'), // Attribute for the COL element.
      * ),
      * ),
      * // Colgroup with attributes and inner COL elements.
      * array(
      * 'data' => array(
      * array(
      * 'class' => array('funky'), // Attribute for the COL element.
      * ),
      * ),
      * 'class' => array('jazzy'), // Attribute for the COLGROUP element.
      * ),
      * );
      *
      These optional tags are used to group and set properties on columns within a table. For example, one may easily group three columns and apply same background style to all.
  • sticky: Use a "sticky" table header.
  • empty: The message to display in an extra row if table does not have any rows.

Definition at line 1895 of file theme.inc.

References $attributes, $header, $output, $row, $value, _theme_table_cell(), drupal_add_js(), drupal_attributes(), tablesort_cell(), tablesort_header(), and tablesort_init().

theme_tableselect ( $variables )

Returns HTML for a table with radio buttons or checkboxes.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties and children of the tableselect element. Properties used: #header, #options, #empty, and #js_select. The #options property is an array of selection options; each array element of #options is an array of properties. These properties can include #attributes, which is added to the table row's HTML attributes; see theme_table(). An example of per-row options:
    * $options = array(
    * array(
    * 'title' => 'How to Learn Drupal',
    * 'content_type' => 'Article',
    * 'status' => 'published',
    * '#attributes' => array('class' => array('article-row')),
    * ),
    * array(
    * 'title' => 'Privacy Policy',
    * 'content_type' => 'Page',
    * 'status' => 'published',
    * '#attributes' => array('class' => array('page-row')),
    * ),
    * );
    * $header = array(
    * 'title' => t('Title'),
    * 'content_type' => t('Content type'),
    * 'status' => t('Status'),
    * );
    * $form['table'] = array(
    * '#type' => 'tableselect',
    * '#header' => $header,
    * '#options' => $options,
    * '#empty' => t('No content available.'),
    * );
    *

Definition at line 3310 of file form.inc.

References $header, $row, $title, drupal_add_js(), drupal_render(), element_children(), and theme().

theme_tablesort_indicator ( $variables )

Returns HTML for a sort icon.

Parameters
$variables An associative array containing:
  • style: Set to either 'asc' or 'desc', this determines which icon to show.

Definition at line 2037 of file theme.inc.

References t(), and theme().

theme_task_list ( $variables )

Returns HTML for a list of maintenance tasks to perform.

Parameters
$variables An associative array containing:
  • items: An associative array of maintenance tasks.
  • active: The key for the currently active maintenance task.

Definition at line 104 of file theme.maintenance.inc.

References $output, and t().

theme_taxonomy_overview_terms ( $variables )

Returns HTML for a terms overview form as a sortable list of terms.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.
See Also
taxonomy_overview_terms()

Definition at line 548 of file taxonomy.admin.inc.

References $header, $output, $row, drupal_add_css(), drupal_add_js(), drupal_add_tabledrag(), drupal_get_path(), drupal_render(), drupal_render_children(), element_children(), form_get_errors(), t(), and theme().

theme_taxonomy_overview_vocabularies ( $variables )

Returns HTML for the vocabulary overview form as a sortable list of vocabularies.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.
See Also
taxonomy_overview_vocabularies()

Definition at line 70 of file taxonomy.admin.inc.

References $header, $row, drupal_add_tabledrag(), drupal_render(), drupal_render_children(), element_children(), t(), theme(), and url().

theme_text_format_wrapper ( $variables )

Returns HTML for a text format-enabled form element.

Parameters
$variables An associative array containing:
  • element: A render element containing #children and #description.

Definition at line 998 of file filter.module.

References $output.

theme_textarea ( $variables )

Returns HTML for a textarea form element.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: title, value, #description, #rows, #cols, #required, #attributes

Definition at line 3886 of file form.inc.

References $output, _form_set_class(), check_plain(), drupal_add_library(), drupal_attributes(), and element_set_attributes().

theme_textfield ( $variables )

Returns HTML for a textfield form element.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties of the element. Properties used: title, value, #description, #size, #maxlength, #required, #attributes, #autocomplete_path.

Definition at line 3827 of file form.inc.

References $attributes, $output, _form_set_class(), drupal_add_library(), drupal_attributes(), drupal_valid_path(), element_set_attributes(), and url().

theme_trigger_display ( $variables )

Returns HTML for the form showing actions assigned to a trigger.

Parameters
$variables An associative array containing:
  • element: The fieldset including all assigned actions.

Definition at line 296 of file trigger.admin.inc.

References $header, $info, $output, check_plain(), drupal_render_children(), t(), and theme().

theme_update_last_check ( $variables )

Returns HTML for the last time we checked for update data.

In addition to properly formatting the given timestamp, this function also provides a "Check manually" link that refreshes the available update and redirects back to the same page.

Parameters
$variables An associative array containing:
  • last: The timestamp when the site last checked for available updates.
See Also
theme_update_report()
theme_update_available_updates_form()

Definition at line 657 of file update.module.

References $output, drupal_get_destination(), format_interval(), l(), REQUEST_TIME, and t().

theme_update_manager_update_form ( $variables )

Returns HTML for the first page in the process of updating projects.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 276 of file update.manager.inc.

References $output, drupal_render_children(), theme(), and variable_get().

theme_update_report ( $variables )

Returns HTML for the project status report.

Parameters
array $variables An associative array containing:
  • data: An array of data about each project's status.

Definition at line 33 of file update.report.inc.

References $header, $name, $output, $row, $value, check_plain(), drupal_add_css(), drupal_get_path(), drupal_placeholder(), drupal_strtolower(), format_date(), l(), t(), theme(), UPDATE_CURRENT, UPDATE_FETCH_PENDING, UPDATE_NOT_CHECKED, UPDATE_NOT_CURRENT, UPDATE_NOT_FETCHED, UPDATE_NOT_SECURE, UPDATE_NOT_SUPPORTED, UPDATE_REVOKED, UPDATE_UNKNOWN, and variable_get().

theme_update_status_label ( $variables )

Returns HTML for a label to display for a project's update status.

Parameters
array $variables An associative array containing:
  • status: The integer code for a project's current update status.
See Also
update_calculate_project_data()

Definition at line 264 of file update.report.inc.

References t(), UPDATE_CURRENT, UPDATE_NOT_CURRENT, UPDATE_NOT_SECURE, UPDATE_NOT_SUPPORTED, and UPDATE_REVOKED.

theme_update_version ( $variables )

Returns HTML for the version display of a project.

Parameters
array $variables An associative array containing:
  • version: An array of data about the latest released version, containing:
    • version: The version number.
    • release_link: The URL for the release notes.
    • date: The date of the release.
    • download_link: The URL for the downloadable file.
  • tag: The title of the project.
  • class: A string containing extra classes for the wrapping table.

Definition at line 299 of file update.report.inc.

References $links, $output, format_date(), l(), t(), and theme().

theme_user_admin_permissions ( $variables )

Returns HTML for the administer permissions page.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 773 of file user.admin.inc.

References $header, $output, $row, drupal_render(), drupal_render_children(), element_children(), t(), theme(), and user_roles().

theme_user_admin_roles ( $variables )

Returns HTML for the role order and new role form.

Parameters
$variables An associative array containing:
  • form: A render element representing the form.

Definition at line 913 of file user.admin.inc.

References $header, $name, $output, $row, check_plain(), drupal_add_tabledrag(), DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID, drupal_render(), drupal_render_children(), element_children(), l(), t(), and theme().

theme_user_list ( $variables )

Returns HTML for a list of users.

Parameters
$variables An associative array containing:
  • users: An array with user objects. Should contain at least the name and uid.
  • title: (optional) Title to pass on to theme_item_list().

Definition at line 1514 of file user.module.

References $title, and theme().

theme_user_permission_description ( $variables )

Returns HTML for an individual permission description.

Parameters
$variables An associative array containing:
  • permission_item: An associative array representing the permission whose description is being themed. Useful keys include:
    • description: The text of the permission description.
    • warning: A security-related warning message about the permission (if there is one).
  • hide: A boolean indicating whether or not the permission description was requested to be hidden rather than shown.

Definition at line 822 of file user.admin.inc.

theme_user_signature ( $variables )

Returns HTML for a user signature.

Parameters
$variables An associative array containing:
  • signature: The user's signature.

Definition at line 3497 of file user.module.

References $output.

theme_username ( $variables )

Returns HTML for a username, potentially linked to the user's page.

Parameters
$variables An associative array containing:
  • account: The user object to format.
  • name: The user's name, sanitized.
  • extra: Additional text to append to the user's name, sanitized.
  • link_path: The path or URL of the user's profile page, home page, or other desired page to link to for more information about the user.
  • link_options: An array of options to pass to the l() function's $options parameter if linking the user's name to the user's page.
  • attributes_array: An array of attributes to pass to the drupal_attributes() function if not linking to the user's page.
See Also
template_preprocess_username()
template_process_username()

Definition at line 2235 of file theme.inc.

References $output, drupal_attributes(), and l().

theme_vertical_tabs ( $variables )

Returns HTML for an element's children fieldsets as vertical tabs.

Parameters
$variables An associative array containing:
  • element: An associative array containing the properties and children of the fieldset. Properties used: #children.

Definition at line 3723 of file form.inc.

References $output, drupal_add_library(), and t().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator-feed-source.tpl.php File Reference

  • modules
  • aggregator
Variables
aggregator-feed-source.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $source_icon
print $source_image
print $source_description
print $source_url
print $last_checked

Detailed Description

Default theme implementation to present the source of the feed.

The contents are rendered above feed listings when browsing source feeds. For example, "example.com/aggregator/sources/1".

Available variables:

  • $source_icon: Feed icon linked to the source. Rendered through theme_feed_icon().
  • $source_image: Image set by the feed source.
  • $source_description: Description set by the feed source.
  • $source_url: URL to the feed source.
  • $last_checked: How long ago the feed was checked locally.
See Also
template_preprocess()
template_preprocess_aggregator_feed_source()

Definition in file aggregator-feed-source.tpl.php.

Variable Documentation

print $last_checked

Definition at line 34 of file aggregator-feed-source.tpl.php.

print $source_description

Definition at line 28 of file aggregator-feed-source.tpl.php.

print $source_icon

Definition at line 25 of file aggregator-feed-source.tpl.php.

print $source_image

Definition at line 26 of file aggregator-feed-source.tpl.php.

print $source_url

Definition at line 31 of file aggregator-feed-source.tpl.php.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator-item.tpl.php File Reference

  • modules
  • aggregator
Variables
aggregator-item.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $feed_url
print $feed_title
if($source_url) print $source_title
endif
print $source_date

Detailed Description

Default theme implementation to format an individual feed item for display on the aggregator page.

Available variables:

  • $feed_url: URL to the originating feed item.
  • $feed_title: Title of the feed item.
  • $source_url: Link to the local source section.
  • $source_title: Title of the remote source.
  • $source_date: Date the feed was posted on the remote source.
  • $content: Feed item content.
  • $categories: Linked categories assigned to the feed.
See Also
template_preprocess()
template_preprocess_aggregator_item()

Definition in file aggregator-item.tpl.php.

Variable Documentation

print $feed_title

Definition at line 25 of file aggregator-item.tpl.php.

print $feed_url

Definition at line 25 of file aggregator-item.tpl.php.

Referenced by aggregator_refresh().

print $source_date

Definition at line 32 of file aggregator-item.tpl.php.

if ($source_url) print $source_title

Definition at line 29 of file aggregator-item.tpl.php.

print $forum num_posts print $forum last_reply endif

Definition at line 31 of file aggregator-item.tpl.php.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator-summary-item.tpl.php File Reference

  • modules
  • aggregator
Variables
aggregator-summary-item.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $feed_url
print $feed_title
print $feed_age
if($source_url)< spanclass="source">
< ahref="<?phpprint$source_url;?>
print 		$source_title
endif

Detailed Description

Default theme implementation to present a linked feed item for summaries.

Available variables:

  • $feed_url: Link to originating feed.
  • $feed_title: Title of feed.
  • $feed_age: Age of remote feed.
  • $source_url: Link to remote source.
  • $source_title: Locally set title for the source.
See Also
template_preprocess()
template_preprocess_aggregator_summary_item()

Definition in file aggregator-summary-item.tpl.php.

Variable Documentation

print $feed_age

Definition at line 21 of file aggregator-summary-item.tpl.php.

print $feed_title

Definition at line 20 of file aggregator-summary-item.tpl.php.

print $feed_url

Definition at line 20 of file aggregator-summary-item.tpl.php.

if ($source_url)<spanclass="source"><ahref="<?phpprint$source_url;?> print $source_title

Definition at line 23 of file aggregator-summary-item.tpl.php.

endif

Definition at line 25 of file aggregator-summary-item.tpl.php.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator-summary-items.tpl.php File Reference

  • modules
  • aggregator
Variables
aggregator-summary-items.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $title
print $summary_list
print $source_url

Detailed Description

Default theme implementation to present feeds as list items.

Each iteration generates a single feed source or category.

Available variables:

  • $title: Title of the feed or category.
  • $summary_list: Unordered list of linked feed items generated through theme_item_list().
  • $source_url: URL to the local source or category.
See Also
template_preprocess()
template_preprocess_aggregator_summary_items()

Definition in file aggregator-summary-items.tpl.php.

Variable Documentation

print $source_url

Definition at line 24 of file aggregator-summary-items.tpl.php.

print $summary_list

Definition at line 22 of file aggregator-summary-items.tpl.php.

print $title

Definition at line 21 of file aggregator-summary-items.tpl.php.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator-wrapper.tpl.php File Reference

  • modules
  • aggregator
Variables
aggregator-wrapper.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $content
print $pager

Detailed Description

Default theme implementation to wrap aggregator content.

Available variables:

  • $content: All aggregator content.
  • $page: Pager links rendered through theme_pager().
See Also
template_preprocess()
template_preprocess_aggregator_wrapper()

Definition in file aggregator-wrapper.tpl.php.

Variable Documentation

print $content

Definition at line 18 of file aggregator-wrapper.tpl.php.

print $pager

Definition at line 19 of file aggregator-wrapper.tpl.php.

Referenced by system_actions_manage(), and taxonomy_select_nodes().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/block/block-admin-display-form.tpl.php File Reference

  • modules
  • block
Variables
block-admin-display-form.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

$row = 0
foreach($block_listing[$region]
as $delta=> $data) print $data
row_class $data 		row_class
print $data | block_title
print $data | region_select
print $data | weight_select
print $data | configure_link
print $data | delete_link
endforeach
print $form_submit

Detailed Description

Default theme implementation to configure blocks.

Available variables:

  • $block_regions: An array of regions. Keyed by name with the title as value.
  • $block_listing: An array of blocks keyed by region and then delta.
  • $form_submit: Form submit button.

Each $block_listing[$region] contains an array of blocks for that region.

Each $data in $block_listing[$region] contains:

  • $data->region_title: Region title for the listed block.
  • $data->block_title: Block title.
  • $data->region_select: Drop-down menu for assigning a region.
  • $data->weight_select: Drop-down menu for setting weights.
  • $data->configure_link: Block configuration link.
  • $data->delete_link: For deleting user added blocks.
See Also
template_preprocess_block_admin_display_form()
theme_block_admin_display()

Definition in file block-admin-display-form.tpl.php.

Variable Documentation

print $form_submit

Definition at line 69 of file block-admin-display-form.tpl.php.

$row = 0

Definition at line 47 of file block-admin-display-form.tpl.php.

Referenced by actions_function_lookup(), batch_example_op_2(), batch_example_update_7100(), book_admin_edit_submit(), comment_admin_overview(), drupal_get_installed_schema_version(), drupal_path_alias_whitelist_rebuild(), DatabaseStatement_sqlite\execute(), DatabaseStatementPrefetch\fetchAllAssoc(), field_sql_storage_field_storage_load(), field_ui_display_overview_row_region(), field_ui_field_overview_row_region(), field_ui_table_pre_render(), FieldInfo\getFieldMap(), hook_field_storage_load(), DatabaseSchema_mysql\indexExists(), DatabaseSchema_sqlite\introspectSchema(), locale_date_format_language_overview_page(), menu_overview_page(), node_example_page(), node_overview_types(), node_revision_overview(), pager_example_page(), path_admin_overview(), DrupalWebTestCase\preloadRegistry(), rdf_example_uninstall(), shortcut_set_admin(), simpletest_result_form(), system_actions_manage(), system_cron(), system_date_time_formats(), system_update_7016(), system_update_7060(), tabledrag_example_install(), tablesort_example_install(), tablesort_example_page(), template_preprocess_forum_list(), template_preprocess_forum_topic_list(), theme_book_admin_table(), theme_field_ui_table(), theme_file_widget_multiple(), theme_image_anchor(), theme_image_style_effects(), theme_image_style_list(), theme_locale_date_format_form(), theme_locale_languages_configure_form(), theme_menu_overview_form(), theme_node_recent_block(), theme_node_search_admin(), theme_poll_choices(), theme_profile_admin_overview(), theme_shortcut_set_customize(), theme_simpletest_test_table(), theme_system_date_time_settings(), theme_system_modules_fieldset(), theme_table(), theme_tableselect(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_update_report(), theme_user_admin_permissions(), theme_user_admin_roles(), tracker_cron(), tracker_page(), update_fix_compatibility(), update_fix_d7_block_deltas(), user_role_permissions(), user_update_7013(), and user_update_7017().

print $data block_title

Definition at line 57 of file block-admin-display-form.tpl.php.

print $data configure_link

Definition at line 60 of file block-admin-display-form.tpl.php.

print $data delete_link

Definition at line 61 of file block-admin-display-form.tpl.php.

endforeach

Definition at line 64 of file block-admin-display-form.tpl.php.

print $data region_select

Definition at line 58 of file block-admin-display-form.tpl.php.

foreach ($block_listing[$region] as $delta=> $data) print $data row_class $data row_class

Definition at line 55 of file block-admin-display-form.tpl.php.

print $data weight_select

Definition at line 59 of file block-admin-display-form.tpl.php.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/block/block.tpl.php File Reference

  • modules
  • block
Variables
block.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $block_html_id
print $classes
print $attributes
if($block->subject) print
$block subject 		endif
print $content_attributes

Detailed Description

Default theme implementation to display a block.

Available variables:

  • $block->subject: Block title.
  • $content: Block content.
  • $block->module: Module that generated the block.
  • $block->delta: An ID for the block, unique within each module.
  • $block->region: The block region embedding the current block.
  • $classes: String of classes that can be used to style contextually through CSS. It can be manipulated through the variable $classes_array from preprocess functions. The default values can be one or more of the following:
    • block: The current template type, i.e., "theming hook".
    • block-[module]: The module generating the block. For example, the user module is responsible for handling the default user navigation block. In that case the class would be 'block-user'.
  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template.

Helper variables:

  • $classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes.
  • $block_zebra: Outputs 'odd' and 'even' dependent on each block region.
  • zebra:
    Same output as
    block_zebra but independent of any block region.
  • $block_id: Counter dependent on each block region.
  • id:
    Same output as
    block_id but independent of any block region.
  • $is_front: Flags true when presented in the front page.
  • $logged_in: Flags true when the current user is a logged-in member.
  • $is_admin: Flags true when the current user is an administrator.
  • $block_html_id: A valid HTML ID and guaranteed unique.
See Also
template_preprocess()
template_preprocess_block()
template_process()

Definition in file block.tpl.php.

Variable Documentation

print $attributes

Definition at line 47 of file block.tpl.php.

Referenced by _field_sql_storage_schema(), _theme_table_cell(), aggregator_element_start(), drupal_add_html_head_link(), drupal_attributes(), drupal_http_header_attributes(), field_sql_storage_field_storage_details(), field_sql_storage_field_storage_load(), field_sql_storage_field_storage_write(), hook_field_storage_details(), hook_field_storage_details_alter(), hook_field_storage_load(), hook_field_storage_write(), hook_process(), rdf_preprocess_username(), rdf_process(), rdf_rdfa_attributes(), template_preprocess_user_picture(), theme_checkboxes(), theme_date(), theme_file_managed_file(), theme_filter_guidelines(), theme_form_element(), theme_form_element_label(), theme_form_example_inline_form_element(), theme_form_required_marker(), theme_html_tag(), theme_image(), theme_item_list(), theme_links(), theme_pager_link(), theme_radios(), theme_rdf_metadata(), theme_rdf_template_variable_wrapper(), theme_table(), theme_textfield(), translation_node_view(), and update_manager_update_form().

print $block_html_id

Definition at line 47 of file block.tpl.php.

print $classes

Definition at line 47 of file block.tpl.php.

print $content_attributes

Definition at line 55 of file block.tpl.php.

if ($block->subject) print $block subject endif

Definition at line 50 of file block.tpl.php.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book-all-books-block.tpl.php File Reference

  • modules
  • book
Variables
book-all-books-block.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

endforeach

Detailed Description

Default theme implementation for rendering book outlines within a block.

This template is used only when the block is configured to "show block on all pages", which presents multiple independent books on all pages.

Available variables:

  • $book_menus: Array of book outlines keyed to the parent book ID. Call render() on each to print it as an unordered list.
See Also
template_preprocess_book_all_books_block()

Definition in file book-all-books-block.tpl.php.

Variable Documentation

endforeach

Definition at line 23 of file book-all-books-block.tpl.php.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book-export-html.tpl.php File Reference

  • modules
  • book
Variables
book-export-html.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $language | language
print $dir
print $title
print $head
print $base_url
if($language_rtl) | $div_close = ''
endfor
print $contents

Detailed Description

Default theme implementation for printed version of book outline.

Available variables:

  • $title: Top level node title.
  • $head: Header tags.
  • $language: Language code. e.g. "en" for english.
  • $language_rtl: TRUE or FALSE depending on right to left language scripts.
  • $base_url: URL to home page.
  • $contents: Nodes within the current outline rendered through book-node-export-html.tpl.php.
See Also
template_preprocess_book_export_html()

Definition in file book-export-html.tpl.php.

Variable Documentation

print $base_url

Definition at line 26 of file book-export-html.tpl.php.

Referenced by _drupal_html_to_mail_urls(), _filter_html_tips(), _php_filter_tips(), _update_process_fetch_task(), authorize_filetransfer_form(), authorize_filetransfer_form_submit(), DrupalWebTestCase\curlInitialize(), drupal_settings_initialize(), DrupalWebTestCase\getAbsoluteUrl(), hook_watchdog(), install_already_done_error(), install_full_redirect_url(), install_goto(), node_feed(), openid_authentication_request(), openid_verify_assertion_return_url(), syslog_watchdog(), system_authorized_get_url(), system_cron_settings(), system_help(), system_requirements(), template_preprocess_book_export_html(), update_get_d6_session_name(), and url().

print $contents

Definition at line 49 of file book-export-html.tpl.php.

Referenced by _locale_import_parse_header(), _registry_parse_file(), book_export_html(), drupal_build_css_cache(), drupal_build_js_cache(), drupal_load_stylesheet(), drupal_load_stylesheet_content(), and system_requirements().

print $dir

Definition at line 22 of file book-export-html.tpl.php.

Referenced by _locale_rebuild_js(), _registry_update(), conf_path(), drupal_detect_baseurl(), drupal_get_filename(), drupal_settings_initialize(), drupal_system_listing(), file_scan_directory(), file_unmanaged_delete_recursive(), hook_registry_files_alter(), locale_js_alter(), and simpletest_registry_files_alter().

print $div_close = ''

The given node is /embedded to its absolute depth in a top level section/. For example, a child node with depth 2 in the hierarchy is contained in (otherwise empty) <div> elements corresponding to depth 0 and depth 1. This is intended to support WYSIWYG output - e.g., level 3 sections always look like level 3 sections, no matter their depth relative to the node selected to be exported as printer-friendly HTML.

Definition at line 43 of file book-export-html.tpl.php.

print $head

Definition at line 25 of file book-export-html.tpl.php.

print $title

Definition at line 24 of file book-export-html.tpl.php.

endfor

Definition at line 48 of file book-export-html.tpl.php.

print $language language

Definition at line 22 of file book-export-html.tpl.php.

Referenced by email_example_mail(), email_example_mail_alter(), l(), locale_form_node_form_alter(), locale_language_url_rewrite_url(), theme_links(), and url().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book-navigation.tpl.php File Reference

  • modules
  • book
Variables
book-navigation.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

if($tree||$has_links) print $tree
endif

Detailed Description

Default theme implementation to navigate books.

Presented under nodes that are a part of book outlines.

Available variables:

  • $tree: The immediate children of the current node rendered as an unordered list.
  • $current_depth: Depth of the current node within the book outline. Provided for context.
  • $prev_url: URL to the previous node.
  • $prev_title: Title of the previous node.
  • $parent_url: URL to the parent node.
  • $parent_title: Title of the parent node. Not printed by default. Provided as an option.
  • $next_url: URL to the next node.
  • $next_title: Title of the next node.
  • $has_links: Flags TRUE whenever the previous, parent or next data has a value.
  • $book_id: The book ID of the current outline being viewed. Same as the node ID containing the entire outline. Provided for context.
  • $book_url: The book/node URL of the current outline being viewed. Provided as an option. Not used by default.
  • $book_title: The book/node title of the current outline being viewed. Provided as an option. Not used by default.
See Also
template_preprocess_book_navigation()

Definition in file book-navigation.tpl.php.

Variable Documentation

if ($tree||$has_links) print $tree

Definition at line 35 of file book-navigation.tpl.php.

Referenced by _book_admin_table(), _book_admin_table_tree(), _book_flatten_menu(), _book_toc_recurse(), _forum_parent_select(), _menu_get_options(), _menu_overview_tree_form(), _menu_parents_recurse(), _menu_tree_check_access(), _menu_tree_data(), book_block_view(), book_export_html(), book_export_traverse(), book_get_flat_menu(), book_menu_subtree_data(), book_prev(), book_toc(), field_ui_table_pre_render(), hook_options_list(), menu_navigation_links(), menu_overview_form(), menu_set_active_trail(), menu_tree(), menu_tree_all_data(), menu_tree_check_access(), menu_tree_collect_node_links(), menu_tree_output(), menu_tree_page_data(), taxonomy_allowed_values(), taxonomy_autocomplete(), taxonomy_autocomplete_validate(), taxonomy_check_vocabulary_hierarchy(), taxonomy_field_settings_form(), taxonomy_form_term(), taxonomy_get_tree(), taxonomy_overview_terms(), taxonomy_overview_terms_submit(), toolbar_get_menu_tree(), and toolbar_menu_navigation_links().

endif

Definition at line 43 of file book-navigation.tpl.php.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book-node-export-html.tpl.php File Reference

  • modules
  • book
Variables
book-node-export-html.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $node nid
print $depth
print $title
print $content
print $children

Detailed Description

Default theme implementation for a single node in a printer-friendly outline.

See Also
book-node-export-html.tpl.php Where it is collected and printed out.

Available variables:

  • $depth: Depth of the current node inside the outline.
  • $title: Node title.
  • $content: Node content.
  • $children: All the child nodes recursively rendered through this file.
See Also
template_preprocess_book_node_export_html()

Definition in file book-node-export-html.tpl.php.

Variable Documentation

print $children

Definition at line 24 of file book-node-export-html.tpl.php.

Referenced by _forum_parent_select(), book_children(), book_export_traverse(), book_node_export(), drupal_render(), drupal_render_collect_attached(), element_children(), field_ui_table_pre_render(), form_pre_render_fieldset(), menu_local_tasks(), tabledrag_example_get_tree(), taxonomy_form_term(), taxonomy_get_children(), taxonomy_get_tree(), taxonomy_term_delete(), and theme_item_list().

print $content

Definition at line 23 of file book-node-export-html.tpl.php.

print $depth

Definition at line 21 of file book-node-export-html.tpl.php.

Referenced by DatabaseTransaction\__construct(), _menu_link_find_parent(), _menu_tree_data(), field_ui_table_pre_render(), file_scan_directory(), menu_local_tasks(), menu_tree_data(), tabledrag_example_get_tree(), tabledrag_example_parent_get_data(), and taxonomy_get_tree().

print $title

Definition at line 22 of file book-node-export-html.tpl.php.

print $node nid

Definition at line 21 of file book-node-export-html.tpl.php.

Referenced by locale_form_node_form_alter(), path_form_node_form_alter(), translation_node_overview(), and translation_node_validate().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment-wrapper.tpl.php File Reference

  • modules
  • comment
Variables
comment-wrapper.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $classes
print $attributes
endif

Detailed Description

Default theme implementation to provide an HTML container for comments.

Available variables:

  • $content: The array of content-related elements for the node. Use render($content) to print them all, or print a subset such as render($content['comment_form']).
  • $classes: String of classes that can be used to style contextually through CSS. It can be manipulated through the variable $classes_array from preprocess functions. The default value has the following:
    • comment-wrapper: The current template type, i.e., "theming hook".
  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template.

The following variables are provided for contextual information.

  • $node: Node object the comments are attached to. The constants below the variables show the possible values and should be used for comparison.
  • $display_mode
    • COMMENT_MODE_FLAT
    • COMMENT_MODE_THREADED

Other variables:

  • $classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes.
See Also
template_preprocess_comment_wrapper()

Definition in file comment-wrapper.tpl.php.

Variable Documentation

print $attributes

Definition at line 39 of file comment-wrapper.tpl.php.

print $classes

Definition at line 39 of file comment-wrapper.tpl.php.

endif

Definition at line 44 of file comment-wrapper.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment.tpl.php File Reference

  • modules
  • comment
Variables
comment.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $classes
print $attributes
print $title_attributes
print $permalink
print $submitted
print $content_attributes

Detailed Description

Default theme implementation for comments.

Available variables:

  • $author: Comment author. Can be link or plain text.
  • content:
    An array of comment items. Use render(
    content) to print them all, or print a subset such as render($content['field_example']). Use hide($content['field_example']) to temporarily suppress the printing of a given element.
  • $created: Formatted date and time for when the comment was created. Preprocess functions can reformat it by calling format_date() with the desired parameters on the $comment->created variable.
  • $changed: Formatted date and time for when the comment was last changed. Preprocess functions can reformat it by calling format_date() with the desired parameters on the $comment->changed variable.
  • $new: New comment marker.
  • $permalink: Comment permalink.
  • submitted:
    Submission information created from
    author and $created during template_preprocess_comment().
  • $picture: Authors picture.
  • $signature: Authors signature.
  • $status: Comment status. Possible values are: comment-unpublished, comment-published or comment-preview.
  • $title: Linked title.
  • $classes: String of classes that can be used to style contextually through CSS. It can be manipulated through the variable $classes_array from preprocess functions. The default values can be one or more of the following:
    • comment: The current template type, i.e., "theming hook".
    • comment-by-anonymous: Comment by an unregistered user.
    • comment-by-node-author: Comment by the author of the parent node.
    • comment-preview: When previewing a new or edited comment. The following applies only to viewers who are registered users:
    • comment-unpublished: An unpublished comment visible only to administrators.
    • comment-by-viewer: Comment by the user currently viewing the page.
    • comment-new: New comment since last the visit.
  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template.

These two variables are provided for context:

  • $comment: Full comment object.
  • $node: Node object the comments are attached to.

Other variables:

  • $classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes.
See Also
template_preprocess()
template_preprocess_comment()
template_process()
theme_comment()

Definition in file comment.tpl.php.

Variable Documentation

print $attributes

Definition at line 62 of file comment.tpl.php.

print $classes

Definition at line 62 of file comment.tpl.php.

print $content_attributes

Definition at line 78 of file comment.tpl.php.

print $permalink

Definition at line 74 of file comment.tpl.php.

print $submitted

Definition at line 75 of file comment.tpl.php.

print $title_attributes

Definition at line 70 of file comment.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/theme/field.tpl.php File Reference

  • modules
  • field
  • theme
Variables
field.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $classes
print $attributes
if(!$label_hidden) print $label endif
print $content_attributes
foreach($items as $delta=>
$item) print 		$item_attributes [$delta]
endforeach

Detailed Description

Default template implementation to display the value of a field.

This file is not used and is here as a starting point for customization only.

See Also
theme_field()

Available variables:

  • $items: An array of field values. Use render() to output them.
  • $label: The item label.
  • $label_hidden: Whether the label display is set to 'hidden'.
  • $classes: String of classes that can be used to style contextually through CSS. It can be manipulated through the variable $classes_array from preprocess functions. The default values can be one or more of the following:
    • field: The current template type, i.e., "theming hook".
    • field-name-[field_name]: The current field name. For example, if the field name is "field_description" it would result in "field-name-field-description".
    • field-type-[field_type]: The current field type. For example, if the field type is "text" it would result in "field-type-text".
    • field-label-[label_display]: The current label position. For example, if the label position is "above" it would result in "field-label-above".

Other variables:

  • $element['#object']: The entity to which the field is attached.
  • $element['#view_mode']: View mode, e.g. 'full', 'teaser'...
  • $element['#field_name']: The field name.
  • $element['#field_type']: The field type.
  • $element['field_language']: The field language.
  • $element['#field_translatable']: Whether the field is translatable or not.
  • $element['#label_display']: Position of label display, inline, above, or hidden.
  • $field_name_css: The css-compatible field name.
  • $field_type_css: The css-compatible field type.
  • $classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes.
See Also
template_preprocess_field()
theme_field()

Definition in file field.tpl.php.

Variable Documentation

print $attributes

Definition at line 53 of file field.tpl.php.

print $classes

Definition at line 53 of file field.tpl.php.

print $content_attributes

Definition at line 57 of file field.tpl.php.

foreach ($items as $delta=> $item) print $item_attributes[$delta]

Definition at line 58 of file field.tpl.php.

endforeach

Definition at line 60 of file field.tpl.php.

if (!$label_hidden) print $label endif

Definition at line 54 of file field.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum-icon.tpl.php File Reference

  • modules
  • forum
forum-icon.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Detailed Description

Displays an appropriate icon for a forum post.

Available variables:

  • $new_posts: Indicates whether or not the topic contains new posts.
  • $icon_class: The icon to display. May be one of 'hot', 'hot-new', 'new', 'default', 'closed', or 'sticky'.
  • $first_new: Indicates whether this is the first topic with new posts.
See Also
template_preprocess_forum_icon()
theme_forum_icon()

Definition in file forum-icon.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum-list.tpl.php File Reference

  • modules
  • forum
Variables
forum-list.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $forum_id
foreach($forums as $child_id=>
$forum) print $forum 		zebra
print $forum | is_container
print $forum | icon_class
print $forum | icon_title
print $forum | link
print $forum | name
if($forum->description) | endif
if(!$forum->is_container)($forum->
new_topics) print $forum 		new_text
endforeach

Detailed Description

Displays a list of forums and containers.

Available variables:

  • $forums: An array of forums and containers to display. It is keyed to the numeric IDs of all child forums and containers. Each $forum in $forums contains:
    • $forum->is_container: TRUE if the forum can contain other forums. FALSE if the forum can contain only topics.
    • $forum->depth: How deep the forum is in the current hierarchy.
    • $forum->zebra: 'even' or 'odd' string used for row class.
    • $forum->icon_class: 'default' or 'new' string used for forum icon class.
    • $forum->icon_title: Text alternative for the forum icon.
    • $forum->name: The name of the forum.
    • $forum->link: The URL to link to this forum.
    • $forum->description: The description of this forum.
    • $forum->new_topics: TRUE if the forum contains unread posts.
    • $forum->new_url: A URL to the forum's unread posts.
    • $forum->new_text: Text for the above URL, which tells how many new posts.
    • $forum->old_topics: A count of posts that have already been read.
    • $forum->num_posts: The total number of posts in the forum.
    • $forum->last_reply: Text representing the last time a forum was posted or commented in.
  • $forum_id: Forum ID for the current forum. Parent to all items within the $forums array.
See Also
template_preprocess_forum_list()
theme_forum_list()

Definition in file forum-list.tpl.php.

Variable Documentation

print $forum_id

Definition at line 36 of file forum-list.tpl.php.

endforeach

Definition at line 75 of file forum-list.tpl.php.

print $forum num_posts print $forum last_reply endif

Definition at line 58 of file forum-list.tpl.php.

print $forum icon_class

Definition at line 54 of file forum-list.tpl.php.

print $forum icon_title

Definition at line 54 of file forum-list.tpl.php.

print $forum is_container

Definition at line 48 of file forum-list.tpl.php.

print $forum link

Definition at line 57 of file forum-list.tpl.php.

Referenced by theme_aggregator_block_item().

print $forum name

Definition at line 57 of file forum-list.tpl.php.

Referenced by Updater\__construct(), SystemQueue\__construct(), BatchQueue\claimItem(), SystemQueue\claimItem(), contact_personal_form_submit(), SystemQueue\createItem(), SystemQueue\deleteQueue(), BatchQueue\getAllItems(), ModuleUpdater\getInstallDirectory(), ThemeUpdater\getInstallDirectory(), hook_watchdog(), Updater\install(), ModuleUpdater\isInstalled(), ThemeUpdater\isInstalled(), locale_date_format_reset_form(), locale_languages_delete_form(), locale_languages_delete_form_submit(), node_add(), node_admin_nodes(), SystemQueue\numberOfItems(), taxonomy_field_formatter_view(), Updater\update(), user_multiple_cancel_confirm(), and xmlrpc_error_get_xml().

if (!$forum->is_container) ($forum->new_topics) print $forum new_text

Definition at line 63 of file forum-list.tpl.php.

foreach ($forums as $child_id=> $forum) print $forum zebra

Definition at line 46 of file forum-list.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum-submitted.tpl.php File Reference

  • modules
  • forum
Variables
forum-submitted.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

else __pad0__
endif

Detailed Description

Formats a forum post submission string.

The submission string indicates when and by whom a topic was submitted.

Available variables:

  • $author: The author of the post.
  • $time: How long ago the post was created.
  • $topic: An object with the raw data of the post. Potentially unsafe. Be sure to clean this data before printing.
See Also
template_preprocess_forum_submitted()
theme_forum_submitted()

Definition in file forum-submitted.tpl.php.

Variable Documentation

else __pad0__

Definition at line 29 of file forum-submitted.tpl.php.

endif

Definition at line 30 of file forum-submitted.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum-topic-list.tpl.php File Reference

  • modules
  • forum
Variables
forum-topic-list.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $topic_id
print $header
foreach($topics as $topic)
print $topic 		icon
print $topic | title
print $topic | created
if($topic->moved) | else
if($topic->new_replies) print
$topic 		new_text
endif
print $topic | last_reply
endforeach
print $pager

Detailed Description

Displays a list of forum topics.

Available variables:

  • $header: The table header. This is pre-generated with click-sorting information. If you need to change this, see template_preprocess_forum_topic_list().
  • $pager: The pager to display beneath the table.
  • topics:
    An array of topics to be displayed. Each
    topic in $topics contains:
    • $topic->icon: The icon to display.
    • $topic->moved: A flag to indicate whether the topic has been moved to another forum.
    • $topic->title: The title of the topic. Safe to output.
    • $topic->message: If the topic has been moved, this contains an explanation and a link.
    • $topic->zebra: 'even' or 'odd' string used for row class.
    • $topic->comment_count: The number of replies on this topic.
    • $topic->new_replies: A flag to indicate whether there are unread comments.
    • $topic->new_url: If there are unread replies, this is a link to them.
    • $topic->new_text: Text containing the translated, properly pluralized count.
    • $topic->created: A string representing when the topic was posted. Safe to output.
    • $topic->last_reply: An outputtable string representing when the topic was last replied to.
    • $topic->timestamp: The raw timestamp this topic was posted.
  • $topic_id: Numeric ID for the current forum topic.
See Also
template_preprocess_forum_topic_list()
theme_forum_topic_list()

Definition in file forum-topic-list.tpl.php.

Variable Documentation

print $header

Definition at line 42 of file forum-topic-list.tpl.php.

Referenced by _filter_html_tips(), _locale_export_po_generate(), _locale_import_one_string(), _locale_import_parse_header(), _locale_translate_seek(), _theme_table_cell(), aggregator_view(), comment_admin_overview(), contact_category_list(), DrupalWebTestCase\curlHeaderCallback(), dblog_overview(), dblog_top(), dbtng_example_advanced_list(), dbtng_example_list(), drupal_add_html_head_link(), DrupalWebTestCase\drupalGetHeader(), DrupalWebTestCase\drupalGetHeaders(), field_ui_fields_list(), locale_date_format_language_overview_page(), menu_overview_page(), node_admin_nodes(), node_overview_types(), node_revision_overview(), openid_user_identities(), pager_example_page(), path_admin_overview(), poll_votes(), shortcut_set_admin(), simpletest_result_form(), statistics_node_tracker(), statistics_recent_hits(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), statistics_user_tracker(), system_actions_manage(), system_date_time_formats(), system_ip_blocking(), EntityFieldQuery\tableSort(), tablesort_cell(), tablesort_example_page(), tablesort_get_order(), tablesort_get_sort(), tablesort_init(), template_preprocess_forum_topic_list(), theme_book_admin_table(), theme_field_multiple_value_form(), theme_field_ui_table(), theme_file_formatter_table(), theme_filter_admin_overview(), theme_image_style_effects(), theme_image_style_list(), theme_locale_date_format_form(), theme_locale_languages_configure_form(), theme_locale_languages_overview_form(), theme_menu_overview_form(), theme_node_search_admin(), theme_profile_admin_overview(), theme_queue_items(), theme_shortcut_set_customize(), theme_simpletest_test_table(), theme_system_date_time_settings(), theme_system_modules_uninstall(), theme_table(), theme_tabledrag_example_parent_form(), theme_tabledrag_example_simple_form(), theme_tableselect(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_trigger_display(), theme_update_report(), theme_user_admin_permissions(), theme_user_admin_roles(), translation_node_overview(), and user_admin_account().

print $pager

Definition at line 72 of file forum-topic-list.tpl.php.

print $topic_id

Definition at line 40 of file forum-topic-list.tpl.php.

print $topic created

Definition at line 53 of file forum-topic-list.tpl.php.

Referenced by template_preprocess_forum_submitted().

if ($topic->moved) else

Definition at line 56 of file forum-topic-list.tpl.php.

endforeach

Definition at line 69 of file forum-topic-list.tpl.php.

endif

Definition at line 64 of file forum-topic-list.tpl.php.

foreach ($topics as $topic) print $topic icon

Definition at line 45 of file forum-topic-list.tpl.php.

print $topic last_reply

Definition at line 66 of file forum-topic-list.tpl.php.

if ($topic->new_replies) print $topic new_text

Definition at line 61 of file forum-topic-list.tpl.php.

print $topic title

Definition at line 50 of file forum-topic-list.tpl.php.

Referenced by Updater\__construct(), book_admin_edit_submit(), rdf_preprocess_node(), shortcut_set_edit_form_validate(), template_preprocess_aggregator_summary_items(), template_preprocess_book_node_export_html(), template_preprocess_contextual_links_example_object(), template_preprocess_poll_vote(), and theme_aggregator_block_item().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forums.tpl.php File Reference

  • modules
  • forum
Variables
forums.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

if($forums_defined) print $topics
endif

Detailed Description

Displays a forum.

May contain forum containers as well as forum topics.

Available variables:

  • $forums: The forums to display (as processed by forum-list.tpl.php).
  • $topics: The topics to display (as processed by forum-topic-list.tpl.php).
  • $forums_defined: A flag to indicate that the forums are configured.
See Also
template_preprocess_forums()

Definition in file forums.tpl.php.

Variable Documentation

if ($forums_defined) print $topics

Definition at line 19 of file forums.tpl.php.

Referenced by forum_get_topics(), and forum_page().

endif

Definition at line 24 of file forums.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/node.tpl.php File Reference

  • modules
  • node
Variables
node.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $node | nid
print $classes
print $attributes
print $user_picture
if(!$page) print | $node_url
print $title
endif
print $content_attributes

Detailed Description

Default theme implementation to display a node.

Available variables:

  • $title: the (sanitized) title of the node.
  • content:
    An array of node items. Use render(
    content) to print them all, or print a subset such as render($content['field_example']). Use hide($content['field_example']) to temporarily suppress the printing of a given element.
  • $user_picture: The node author's picture from user-picture.tpl.php.
  • $date: Formatted creation date. Preprocess functions can reformat it by calling format_date() with the desired parameters on the $created variable.
  • $name: Themed username of node author output from theme_username().
  • $node_url: Direct URL of the current node.
  • $display_submitted: Whether submission information should be displayed.
  • submitted:
    Submission information created from
    name and $date during template_preprocess_node().
  • $classes: String of classes that can be used to style contextually through CSS. It can be manipulated through the variable $classes_array from preprocess functions. The default values can be one or more of the following:
    • node: The current template type; for example, "theming hook".
    • node-[type]: The current node type. For example, if the node is a "Blog entry" it would result in "node-blog". Note that the machine name will often be in a short form of the human readable label.
    • node-teaser: Nodes in teaser form.
    • node-preview: Nodes in preview mode. The following are controlled through the node publishing options.
    • node-promoted: Nodes promoted to the front page.
    • node-sticky: Nodes ordered above other non-sticky nodes in teaser listings.
    • node-unpublished: Unpublished nodes visible only to administrators.
  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template.

Other variables:

  • $node: Full node object. Contains data that may not be safe.
  • $type: Node type; for example, story, page, blog, etc.
  • $comment_count: Number of comments attached to the node.
  • $uid: User ID of the node author.
  • $created: Time the node was published formatted in Unix timestamp.
  • $classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes.
  • $zebra: Outputs either "even" or "odd". Useful for zebra striping in teaser listings.
  • $id: Position of the node. Increments each time it's output.

Node status variables:

  • $view_mode: View mode; for example, "full", "teaser".
  • teaser:
    Flag for the teaser state (shortcut for
    view_mode == 'teaser').
  • $page: Flag for the full page state.
  • $promote: Flag for front page promotion state.
  • $sticky: Flags for sticky post setting.
  • $status: Flag for published status.
  • $comment: State of comment settings for the node.
  • $readmore: Flags true if the teaser content of the node cannot hold the main body content.
  • $is_front: Flags true when presented in the front page.
  • $logged_in: Flags true when the current user is a logged-in member.
  • $is_admin: Flags true when the current user is an administrator.

Field variables: for each field instance attached to the node a corresponding variable is defined; for example, $node->body becomes $body. When needing to access a field's raw values, developers/themers are strongly encouraged to use these variables. Otherwise they will have to explicitly specify the desired field language; for example, $node->body['en'], thus overriding any language negotiation rule that was previously applied.

See Also
template_preprocess()
template_preprocess_node()
template_process()

Definition in file node.tpl.php.

Variable Documentation

print $attributes

Definition at line 83 of file node.tpl.php.

print $classes

Definition at line 83 of file node.tpl.php.

print $content_attributes

Definition at line 99 of file node.tpl.php.

if (!$page) print $node_url

Definition at line 88 of file node.tpl.php.

print $title

Definition at line 89 of file node.tpl.php.

print $user_picture

Definition at line 85 of file node.tpl.php.

if ($display_submitted) endif

Definition at line 90 of file node.tpl.php.

print $node nid

Definition at line 83 of file node.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/overlay/overlay.tpl.php File Reference

  • modules
  • overlay
Variables
overlay.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $attributes
print $title_attributes
print $title
endif
print $content_attributes
print $page

Detailed Description

Default theme implementation to display a page in the overlay.

Available variables:

  • $title: the (sanitized) title of the page.
  • $page: The rendered page content.
  • $tabs (array): Tabs linking to any sub-pages beneath the current page (e.g., the view and edit tabs when displaying a node).

Helper variables:

  • $classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes.
See Also
template_preprocess()
template_preprocess_overlay()
template_process()

Definition in file overlay.tpl.php.

Variable Documentation

print $attributes

Definition at line 26 of file overlay.tpl.php.

print $content_attributes

Definition at line 36 of file overlay.tpl.php.

print $page

Definition at line 37 of file overlay.tpl.php.

Referenced by _field_permission_example_page(), ajax_link_response(), block_example_page(), block_page_build(), comment_form_submit(), comment_permalink(), dashboard_page_build(), drupal_deliver_html_page(), drupal_render_page(), hook_page_alter(), hook_page_build(), image_style_list(), EntityFieldQuery\initializePager(), overlay_page_alter(), overlay_render_region(), pager_default_initialize(), pager_find_page(), render_example_page_alter(), shortcut_page_alter(), statistics_top_pages(), system_batch_page(), taxonomy_overview_terms(), theme_pager_link(), toolbar_page_build(), and tracker_page().

print $title

Definition at line 29 of file overlay.tpl.php.

print $title_attributes

Definition at line 29 of file overlay.tpl.php.

endif

Definition at line 34 of file overlay.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll-results.tpl.php File Reference

  • modules
  • poll
Variables
poll-results.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $results
if(!empty($cancel_form)) endif

Detailed Description

Default theme implementation to display the poll results in a block.

Variables available:

  • $title: The title of the poll.
  • $results: The results of the poll.
  • $votes: The total results in the poll.
  • $links: Links in the poll.
  • $nid: The nid of the poll
  • $cancel_form: A form to cancel the user's vote, if allowed.
  • $raw_links: The raw array of links.
  • $vote: The choice number of the current user's vote.
See Also
template_preprocess_poll_results()

Definition in file poll-results.tpl.php.

Variable Documentation

print $results

Definition at line 23 of file poll-results.tpl.php.

Referenced by _locale_batch_language_finished(), _locale_batch_system_finished(), _node_mass_update_batch_finished(), batch_example_finished(), field_purge_batch(), field_read_fields(), field_read_instances(), field_sql_storage_field_storage_load(), field_sql_storage_update_7001(), field_sql_storage_update_7002(), hook_field_storage_load(), hook_search_execute(), hook_search_page(), language_provider_invoke(), node_search_execute(), nodeapi_example_uninstall(), search_view(), simpletest_result_form(), simpletest_result_get(), system_update_7060(), token_find_with_prefix(), token_scan(), update_authorize_install_batch_finished(), update_authorize_update_batch_finished(), update_fetch_data_finished(), update_finished(), update_fix_d7_install_profile(), update_manager_download_batch_finished(), user_search_execute(), and user_update_7002().

if (!empty($cancel_form)) endif

Definition at line 27 of file poll-results.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll-vote.tpl.php File Reference

  • modules
  • poll
Variables
poll-vote.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

if($block) endif
print $choice
print $vote

Detailed Description

Default theme implementation to display voting form for a poll.

  • $choice: The radio buttons for the choices in the poll.
  • $title: The title of the poll.
  • $block: True if this is being displayed as a block.
  • $vote: The vote button
  • $rest: Anything else in the form that may have been added via form_alter hooks.
See Also
template_preprocess_poll_vote()

Definition in file poll-vote.tpl.php.

Variable Documentation

print $choice

Definition at line 25 of file poll-vote.tpl.php.

Referenced by form_get_options(), form_process_checkboxes(), form_process_radios(), form_process_tableselect(), form_select_options(), poll_form(), poll_insert(), poll_teaser(), poll_tokens(), poll_update(), poll_validate(), poll_view_results(), poll_view_voting(), and poll_vote().

print $vote

Definition at line 27 of file poll-vote.tpl.php.

Referenced by poll_votes().

if ($block) endif

Definition at line 22 of file poll-vote.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search-result.tpl.php File Reference

  • modules
  • search
Variables
search-result.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $classes
print $attributes
print $title_attributes
print $url
print $title
if($snippet) print $snippet
endif

Detailed Description

Default theme implementation for displaying a single search result.

This template renders a single search result and is collected into search-results.tpl.php. This and the parent template are dependent to one another sharing the markup for definition lists.

Available variables:

  • $url: URL of the result.
  • $title: Title of the result.
  • $snippet: A small preview of the result. Does not apply to user searches.
  • $info: String of all the meta information ready for print. Does not apply to user searches.
  • info_split:
    Contains same data as
    info, split into a keyed array.
  • $module: The machine-readable name of the module (tab) being searched, such as "node" or "user".
  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template.

Default keys within $info_split:

  • $info_split['module']: The module that implemented the search query.
  • $info_split['user']: Author of the node linked to users profile. Depends on permission.
  • $info_split['date']: Last update of the node. Short formatted.
  • $info_split['comment']: Number of comments output as "% comments", % being the count. Depends on comment.module.

Other variables:

  • $classes_array: Array of HTML class attribute values. It is flattened into a string within the variable $classes.
  • $title_attributes_array: Array of HTML attributes for the title. It is flattened into a string within the variable $title_attributes.
  • $content_attributes_array: Array of HTML attributes for the content. It is flattened into a string within the variable $content_attributes.

Since $info_split is keyed, a direct print of the item is possible. This array does not apply to user searches so it is recommended to check for its existence before printing. The default keys of 'type', 'user' and 'date' always exist for node searches. Modules may provide other data.

* <?php if (isset($info_split['comment'])): ?>
* <span class="info-comment">
* <?php print $info_split['comment']; ?>
* </span>
* <?php endif; ?>
*

To check for all available data within $info_split, use the code below.

* <?php print '<pre>'. check_plain(print_r($info_split, 1)) .'</pre>'; ?>
*
See Also
template_preprocess()
template_preprocess_search_result()
template_process()

Definition in file search-result.tpl.php.

Variable Documentation

print $attributes

Definition at line 67 of file search-result.tpl.php.

print $classes

Definition at line 67 of file search-result.tpl.php.

if ($snippet) print $snippet

Definition at line 74 of file search-result.tpl.php.

Referenced by SelectQueryExtender\having(), SelectQuery\having(), SelectQueryExtender\where(), DeleteQuery\where(), SelectQuery\where(), UpdateQuery\where(), MergeQuery\where(), and DatabaseCondition\where().

print $title

Definition at line 70 of file search-result.tpl.php.

print $title_attributes

Definition at line 69 of file search-result.tpl.php.

print $url

Definition at line 70 of file search-result.tpl.php.

Referenced by _batch_progress_page_nojs(), _drupal_html_to_mail_urls(), _openid_url_normalize(), _update_build_fetch_url(), _update_process_fetch_task(), _xmlrpc(), batch_process(), drupal_add_feed(), drupal_goto(), drupal_http_request(), drupal_override_server_variables(), drupal_parse_url(), drupal_validate_form(), file_example_managed_write_submit(), file_example_read_submit(), file_example_unmanaged_php_submit(), file_example_unmanaged_write_submit(), FileExampleSessionStreamWrapper\getExternalUrl(), locale_update_7004(), openid_redirect(), openid_redirect_form(), openid_redirect_http(), system_retrieve_file(), theme_aggregator_page_rss(), theme_file_link(), update_batch(), update_manager_batch_project_get(), update_manager_file_get(), update_manager_update_ready_form_submit(), update_parse_db_url(), valid_url(), DrupalTestCase\verbose(), and xmlrpc().

if ($info) endif

Definition at line 76 of file search-result.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search-results.tpl.php File Reference

  • modules
  • search
Variables
search-results.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $module
print $search_results
print $pager
else __pad0__
endif

Detailed Description

Default theme implementation for displaying search results.

This template collects each invocation of theme_search_result(). This and the child template are dependent to one another sharing the markup for definition lists.

Note that modules may implement their own search type and theme function completely bypassing this template.

Available variables:

  • $search_results: All results as it is rendered through search-result.tpl.php
  • $module: The machine-readable name of the module (tab) being searched, such as "node" or "user".
See Also
template_preprocess_search_results()

Definition in file search-results.tpl.php.

Variable Documentation

print $module

Definition at line 28 of file search-results.tpl.php.

Referenced by _block_rehash(), _drupal_schema_initialize(), _field_info_collate_types(), _install_module_batch(), _module_build_dependencies(), _node_types_build(), _rdf_get_default_mapping(), _registry_parse_file(), _registry_update(), _search_get_module_names(), _system_rebuild_module_data(), _system_update_bootstrap_status(), _theme_build_registry(), _update_7000_user_role_grant_permissions(), aggregator_admin_form(), DrupalDefaultEntityController\attachLoad(), block_admin_configure(), block_custom_block_delete(), block_load(), bootstrap_invoke_all(), contextual_pre_render_links(), dashboard_block_info_alter(), dashboard_show_block_content(), drupal_add_library(), drupal_alter(), drupal_check_module(), drupal_check_profile(), drupal_cron_run(), drupal_get_complete_schema(), drupal_get_filetransfer_info(), drupal_get_installed_schema_version(), drupal_get_library(), drupal_get_normal_path(), drupal_get_schema_unprocessed(), drupal_get_schema_versions(), drupal_install_schema(), drupal_load_updates(), drupal_mail(), drupal_mail_system(), drupal_render_page(), drupal_set_installed_schema_version(), drupal_uninstall_modules(), drupal_uninstall_schema(), drupal_verify_profile(), email_example_mail_send(), field_access(), field_associate_fields(), field_attach_form(), field_attach_insert(), field_attach_load(), field_attach_submit(), field_attach_update(), field_attach_validate(), field_default_prepare_view(), field_help(), field_modules_uninstalled(), field_purge_data(), field_update_field(), file_download(), file_file_download(), file_usage_add(), file_usage_delete(), filter_get_filters(), filter_update_7003(), form_load_include(), help_links_as_list(), help_menu(), hook_library_alter(), hook_modules_uninstalled(), hook_registry_files_alter(), image_effect_definitions(), image_styles(), install_profile_modules(), locale_library_alter(), menu_contextual_links(), menu_get_active_help(), menu_link_maintain(), menu_router_build(), module_disable(), module_enable(), module_exists(), module_hook(), module_hook_info(), module_implements(), module_invoke(), module_invoke_all(), module_list(), module_load_all(), module_load_all_includes(), module_load_include(), module_load_install(), node_form_submit_build_node(), node_validate(), rdf_modules_installed(), search_admin_settings(), search_view(), SearchQuery\searchExpression(), DrupalUnitTestCase\setUp(), simpletest_registry_files_alter(), simpletest_test_get_all(), system_add_module_assets(), system_admin_index(), system_get_module_admin_tasks(), system_list(), system_modules(), system_modules_submit(), system_modules_uninstall(), system_modules_uninstall_confirm_form(), system_requirements(), theme_system_admin_index(), theme_system_modules_fieldset(), theme_system_modules_uninstall(), trigger_assign(), trigger_assign_form(), trigger_forms(), trigger_help(), trigger_menu(), trigger_unassign(), update_already_performed(), update_build_dependency_graph(), update_do_one(), update_fix_d7_block_deltas(), update_get_update_function_list(), update_get_update_list(), update_is_missing(), update_resolve_dependencies(), update_results_page(), update_retrieve_dependencies(), update_script_selection_form(), user_admin_permissions(), user_filters(), user_module_invoke(), user_modules_installed(), user_permission_get_modules(), user_set_authmaps(), and watchdog().

print $pager

Definition at line 31 of file search-results.tpl.php.

print $search_results

Definition at line 29 of file search-results.tpl.php.

else __pad0__

Definition at line 33 of file search-results.tpl.php.

endif

Definition at line 35 of file search-results.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/html.tpl.php File Reference

  • modules
  • system
Variables
html.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $language language
print $language dir
print $rdf_namespaces
print $grddl_profile
print $head
print $head_title
print $styles
print $scripts
print $classes
print $attributes
print $page_top
print $page
print $page_bottom

Detailed Description

Default theme implementation to display the basic html structure of a single Drupal page.

Variables:

  • $css: An array of CSS files for the current page.
  • $language: (object) The language the site is being displayed in. $language->language contains its textual representation. $language->dir contains the language direction. It will either be 'ltr' or 'rtl'.
  • $rdf_namespaces: All the RDF namespace prefixes used in the HTML document.
  • $grddl_profile: A GRDDL profile allowing agents to extract the RDF data.
  • $head_title: A modified version of the page title, for use in the TITLE tag.
  • $head_title_array: (array) An associative array containing the string parts that were used to generate the $head_title variable, already prepared to be output as TITLE tag. The key/value pairs may contain one or more of the following, depending on conditions:
    • title: The title of the current page, if any.
    • name: The name of the site.
    • slogan: The slogan of the site, if any, and if there is no title.
  • $head: Markup for the HEAD section (including meta tags, keyword tags, and so on).
  • $styles: Style tags necessary to import all CSS files for the page.
  • $scripts: Script tags necessary to load the JavaScript files and settings for the page.
  • $page_top: Initial markup from any modules that have altered the page. This variable should always be output first, before all other dynamic content.
  • $page: The rendered page content.
  • $page_bottom: Final closing markup from any modules that have altered the page. This variable should always be output last, after all other dynamic content.
  • $classes String of classes that can be used to style contextually through CSS.
See Also
template_preprocess()
template_preprocess_html()
template_process()

Definition in file html.tpl.php.

Variable Documentation

print $attributes

Definition at line 55 of file html.tpl.php.

print $classes

Definition at line 55 of file html.tpl.php.

print $grddl_profile

Definition at line 49 of file html.tpl.php.

print $head

Definition at line 50 of file html.tpl.php.

print $head_title

Definition at line 51 of file html.tpl.php.

Referenced by template_preprocess_html(), and template_preprocess_maintenance_page().

print $page

Definition at line 60 of file html.tpl.php.

print $page_bottom

Definition at line 61 of file html.tpl.php.

print $page_top

Definition at line 59 of file html.tpl.php.

print $rdf_namespaces

Definition at line 47 of file html.tpl.php.

Referenced by rdf_get_namespaces().

print $scripts

Definition at line 53 of file html.tpl.php.

Referenced by ajax_render().

print $styles

Definition at line 52 of file html.tpl.php.

Referenced by ajax_render(), drupal_get_css(), hook_image_default_styles(), hook_image_styles_alter(), image_example_enable(), image_example_image_default_styles(), image_example_image_styles_alter(), image_image_default_styles(), image_path_flush(), image_style_list(), image_style_load(), image_style_name_validate(), image_style_options(), image_styles(), image_update_7005(), and theme_image_style_list().

print $language dir

Definition at line 47 of file html.tpl.php.

Referenced by file_unmanaged_delete_recursive().

print $language language

Definition at line 47 of file html.tpl.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/maintenance-page.tpl.php File Reference

  • modules
  • system
Variables
maintenance-page.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $language language print
$language language print
$language dir print 		$head_title
print $head
print $styles
print $scripts
print $classes
print $logo
endif
print $site_name
print $content

Detailed Description

Default theme implementation to display a single Drupal page while offline.

All the available variables are mirrored in html.tpl.php and page.tpl.php. Some may be blank but they are provided for consistency.

See Also
template_preprocess()
template_preprocess_maintenance_page()

Definition in file maintenance-page.tpl.php.

Variable Documentation

print $classes

Definition at line 26 of file maintenance-page.tpl.php.

print $content

Definition at line 72 of file maintenance-page.tpl.php.

print $head

Definition at line 22 of file maintenance-page.tpl.php.

print $language language print $language language print $language dir print $head_title

Definition at line 21 of file maintenance-page.tpl.php.

print $logo

Definition at line 33 of file maintenance-page.tpl.php.

Referenced by _color_page_alter().

print $scripts

Definition at line 24 of file maintenance-page.tpl.php.

print $site_name

Definition at line 40 of file maintenance-page.tpl.php.

Referenced by system_tokens(), and theme_aggregator_page_rss().

print $styles

Definition at line 23 of file maintenance-page.tpl.php.

if (!empty($footer)) endif

Definition at line 35 of file maintenance-page.tpl.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/page.tpl.php File Reference

  • modules
  • system
Variables
page.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $logo
endif
print $site_name
else __pad0__
print $messages
print $feed_icons

Detailed Description

Default theme implementation to display a single Drupal page.

The doctype, html, head and body tags are not in this template. Instead they can be found in the html.tpl.php template in this directory.

Available variables:

General utility variables:

  • $base_path: The base URL path of the Drupal installation. At the very least, this will always default to /.
  • $directory: The directory the template is located in, e.g. modules/system or themes/bartik.
  • $is_front: TRUE if the current page is the front page.
  • $logged_in: TRUE if the user is registered and signed in.
  • $is_admin: TRUE if the user has permission to access administration pages.

Site identity:

  • front_page:
    The URL of the front page. Use this instead of
    base_path, when linking to the front page. This includes the language domain or prefix.
  • $logo: The path to the logo image, as defined in theme configuration.
  • $site_name: The name of the site, empty when display has been disabled in theme settings.
  • $site_slogan: The slogan of the site, empty when display has been disabled in theme settings.

Navigation:

  • $main_menu (array): An array containing the Main menu links for the site, if they have been configured.
  • $secondary_menu (array): An array containing the Secondary menu links for the site, if they have been configured.
  • $breadcrumb: The breadcrumb trail for the current page.

Page content (in order of occurrence in the default page.tpl.php):

  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • $title: The page title, for use in the actual HTML content.
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template.
  • $messages: HTML for status and error messages. Should be displayed prominently.
  • $tabs (array): Tabs linking to any sub-pages beneath the current page (e.g., the view and edit tabs when displaying a node).
  • $action_links (array): Actions local to the page, such as 'Add menu' on the menu administration interface.
  • $feed_icons: A string of all feed icons for the current page.
  • $node: The node object, if there is an automatically-loaded node associated with the page, and the node ID is the second argument in the page's path (e.g. node/12345 and node/12345/revisions, but not comment/reply/12345).

Regions:

  • $page['help']: Dynamic help text, mostly for admin pages.
  • $page['highlighted']: Items for the highlighted content region.
  • $page['content']: The main content of the current page.
  • $page['sidebar_first']: Items for the first sidebar.
  • $page['sidebar_second']: Items for the second sidebar.
  • $page['header']: Items for the header region.
  • $page['footer']: Items for the footer region.
See Also
template_preprocess()
template_preprocess_page()
template_process()
html.tpl.php

Definition in file page.tpl.php.

Variable Documentation

print $feed_icons

Definition at line 135 of file page.tpl.php.

print $logo

Definition at line 82 of file page.tpl.php.

print $messages

Definition at line 121 of file page.tpl.php.

Referenced by drupal_get_messages(), forum_update_7003(), install_finished(), openid_authentication(), system_update_7003(), system_update_7007(), theme_authorize_report(), theme_status_messages(), update_authorize_install_batch_finished(), update_authorize_update_batch_finished(), and update_results_page().

print $site_name

Definition at line 91 of file page.tpl.php.

else __pad0__

Definition at line 95 of file page.tpl.php.

endif

Definition at line 84 of file page.tpl.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/region.tpl.php File Reference

  • modules
  • system
Variables
region.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

if($content) print $content
endif

Detailed Description

Default theme implementation to display a region.

Available variables:

  • $content: The content for this region, typically blocks.
  • $classes: String of classes that can be used to style contextually through CSS. It can be manipulated through the variable $classes_array from preprocess functions. The default values can be one or more of the following:
    • region: The current template type, i.e., "theming hook".
    • region-[name]: The name of the region with underscores replaced with dashes. For example, the page_top region would have a region-page-top class.
  • $region: The name of the region variable as defined in the theme's .info file.

Helper variables:

  • $classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes.
  • $is_admin: Flags true when the current user is an administrator.
  • $is_front: Flags true when presented in the front page.
  • $logged_in: Flags true when the current user is a logged-in member.
See Also
template_preprocess()
template_preprocess_region()
template_process()

Definition in file region.tpl.php.

Variable Documentation

if ($content) print $content

Definition at line 31 of file region.tpl.php.

endif

Definition at line 35 of file region.tpl.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy/taxonomy-term.tpl.php File Reference

  • modules
  • taxonomy
Variables
taxonomy-term.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $term | tid
print $classes
if(!$page) print | $term_name
endif

Detailed Description

Default theme implementation to display a term.

Available variables:

  • name:
    (deprecated) The unsanitized name of the term. Use
    term_name instead.
  • $content: An array of items for the content of the term (fields and description). Use render($content) to print them all, or print a subset such as render($content['field_example']). Use hide($content['field_example']) to temporarily suppress the printing of a given element.
  • $term_url: Direct URL of the current term.
  • $term_name: Name of the current term.
  • $classes: String of classes that can be used to style contextually through CSS. It can be manipulated through the variable $classes_array from preprocess functions. The default values can be one or more of the following:
    • taxonomy-term: The current template type, i.e., "theming hook".
    • vocabulary-[vocabulary-name]: The vocabulary to which the term belongs to. For example, if the term is a "Tag" it would result in "vocabulary-tag".

Other variables:

  • $term: Full term object. Contains data that may not be safe.
  • $view_mode: View mode, e.g. 'full', 'teaser'...
  • $page: Flag for the full page state.
  • $classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes.
  • $zebra: Outputs either "even" or "odd". Useful for zebra striping in teaser listings.
  • $id: Position of the term. Increments each time it's output.
  • $is_front: Flags true when presented in the front page.
  • $logged_in: Flags true when the current user is a logged-in member.
  • $is_admin: Flags true when the current user is an administrator.
See Also
template_preprocess()
template_preprocess_taxonomy_term()
template_process()

Definition in file taxonomy-term.tpl.php.

Variable Documentation

print $classes

Definition at line 44 of file taxonomy-term.tpl.php.

if (!$page) print $term_name

Definition at line 46 of file taxonomy-term.tpl.php.

endif

Definition at line 48 of file taxonomy-term.tpl.php.

print $term tid

Definition at line 44 of file taxonomy-term.tpl.php.

Referenced by taxonomy_get_parents_all().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/toolbar/toolbar.tpl.php File Reference

  • modules
  • toolbar
Variables
toolbar.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $classes
endif

Detailed Description

Default template for admin toolbar.

Available variables:

  • $classes: String of classes that can be used to style contextually through CSS. It can be manipulated through the variable $classes_array from preprocess functions. The default value has the following:
    • toolbar: The current template type, i.e., "theming hook".
  • $toolbar['toolbar_user']: User account / logout links.
  • $toolbar['toolbar_menu']: Top level management menu links.
  • $toolbar['toolbar_drawer']: A place for extended toolbar content.

Other variables:

  • $classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes.
See Also
template_preprocess()
template_preprocess_toolbar()

Definition in file toolbar.tpl.php.

Variable Documentation

print $classes

Definition at line 26 of file toolbar.tpl.php.

endif

Definition at line 33 of file toolbar.tpl.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user-picture.tpl.php File Reference

  • modules
  • user
Variables
user-picture.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

if($user_picture) endif

Detailed Description

Default theme implementation to present a picture configured for the user's account.

Available variables:

  • $user_picture: Image set by the user or the site's default. Will be linked depending on the viewer's permission to view the user's profile page.
  • $account: Array of account information. Potentially unsafe. Be sure to check_plain() before use.
See Also
template_preprocess_user_picture()

Definition in file user-picture.tpl.php.

Variable Documentation

if ($user_picture) endif

Definition at line 19 of file user-picture.tpl.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user-profile.tpl.php File Reference

  • modules
  • user
Variables
user-profile.tpl.php File Reference
Default theme implementations

Go to the source code of this file.

Variables

print $attributes

Detailed Description

Default theme implementation to present all user profile data.

This template is used when viewing a registered member's profile page, e.g., example.com/user/123. 123 being the users ID.

Use render($user_profile) to print all profile items, or print a subset such as render($user_profile['user_picture']). Always call render($user_profile) at the end in order to print all remaining items. If the item is a category, it will contain all its profile items. By default, $user_profile['summary'] is provided, which contains data on the user's history. Other data can be included by modules. $user_profile['user_picture'] is available for showing the account picture.

Available variables:

  • $user_profile: An array of profile items. Use render() to print them.
  • Field variables: for each field instance attached to the user a corresponding variable is defined; e.g., $account->field_example has a variable $field_example defined. When needing to access a field's raw values, developers/themers are strongly encouraged to use these variables. Otherwise they will have to explicitly specify the desired field language, e.g. $account->field_example['en'], thus overriding any language negotiation rule that was previously applied.
See Also
user-profile-category.tpl.php Where the html is handled for the group.
user-profile-item.tpl.php Where the html is handled for each item in the group.
template_preprocess_user_profile()

Definition in file user-profile.tpl.php.

Variable Documentation

print $attributes

Definition at line 37 of file user-profile.tpl.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: Taxonomy indexing

Functions
Taxonomy indexing

Functions

taxonomy_field_presave ($entity_type, $entity, $field, $instance, $langcode, &$items)
taxonomy_node_insert ($node)
taxonomy_build_node_index ($node)
taxonomy_node_update ($node)
taxonomy_node_delete ($node)
taxonomy_delete_node_index ($node)
taxonomy_taxonomy_term_delete ($term)

Detailed Description

Functions to maintain taxonomy indexing.

Taxonomy uses default field storage to store canonical relationships between terms and fieldable entities. However its most common use case requires listing all content associated with a term or group of terms sorted by creation date. To avoid slow queries due to joining across multiple node and field tables with various conditions and order by criteria, we maintain a denormalized table with all relationships between terms, published nodes and common sort criteria such as sticky and created. This is used as a lookup table by taxonomy_select_nodes(). When using other field storage engines or alternative methods of denormalizing this data you should set the variable 'taxonomy_maintain_index_table' to FALSE to avoid unnecessary writes in SQL.

Function Documentation

taxonomy_build_node_index ( $node )

Builds and inserts taxonomy index entries for a given node.

The index lists all terms that are related to a given node entity, and is therefore maintained at the entity level.

Parameters
$node The node object.

Definition at line 1915 of file taxonomy.module.

References field_info_field(), field_info_instances(), and variable_get().

Referenced by taxonomy_node_insert(), and taxonomy_node_update().

taxonomy_delete_node_index ( $node )

Deletes taxonomy index entries for a given node.

Parameters
$node The node object.

Definition at line 1998 of file taxonomy.module.

References db_delete(), and variable_get().

Referenced by taxonomy_node_delete(), and taxonomy_node_update().

taxonomy_field_presave | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_presave().

Create any new terms defined in a freetagging vocabulary.

Definition at line 1887 of file taxonomy.module.

References taxonomy_term_save().

taxonomy_node_delete ( $node )

Implements hook_node_delete().

Definition at line 1987 of file taxonomy.module.

References taxonomy_delete_node_index().

taxonomy_node_insert ( $node )

Implements hook_node_insert().

Definition at line 1901 of file taxonomy.module.

References taxonomy_build_node_index().

taxonomy_node_update ( $node )

Implements hook_node_update().

Definition at line 1978 of file taxonomy.module.

References taxonomy_build_node_index(), and taxonomy_delete_node_index().

taxonomy_taxonomy_term_delete ( $term )

Implements hook_taxonomy_term_delete().

Definition at line 2007 of file taxonomy.module.

References db_delete(), and variable_get().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Update Manager module: update

Functions
Update Manager module: update

Functions

update_manager_update_form_validate ($form, &$form_state)
update_manager_update_form_submit ($form, &$form_state)
update_manager_download_batch_finished ($success, $results)
update_manager_update_ready_form_submit ($form, &$form_state)

Detailed Description

Update Manager module functionality for updating existing code.

Provides a user interface to update existing code.

Function Documentation

update_manager_download_batch_finished | ( | $success,
 |  | $results
 | ) |

Batch callback: Performs actions when the download batch is completed.

Parameters
$success | TRUE if the batch operation was successful, FALSE if there were errors.
$results | An associative array of results from the batch operation.

Definition at line 345 of file update.manager.inc.

References $results, drupal_goto(), drupal_set_message(), t(), and theme().

update_manager_update_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for update_manager_update_form().

Sets up a batch that downloads, extracts, and verifies the selected releases.

See Also
update_manager_update_form_validate()

Definition at line 310 of file update.manager.inc.

References batch_set(), drupal_get_path(), and t().

update_manager_update_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for update_manager_update_form().

Ensures that at least one project is selected.

See Also
update_manager_update_form_submit()

Definition at line 291 of file update.manager.inc.

References form_set_error(), and t().

update_manager_update_ready_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for update_manager_update_ready_form().

If the site administrator requested that the site is put offline during the update, do so now. Otherwise, pull information about all the required updates out of the SESSION, figure out what Drupal class is needed for each one, generate an array of update operations to perform, and hand it all off to system_authorized_init(), then redirect to authorize.php.

See Also
update_authorize_run_update()
system_authorized_init()
system_authorized_get_url()

Definition at line 421 of file update.manager.inc.

References $url, _update_manager_extract_directory(), conf_path(), drupal_get_path(), drupal_get_updaters(), drupal_realpath(), DRUPAL_ROOT, Updater\factory(), module_load_include(), system_authorized_get_url(), system_authorized_init(), t(), update_authorize_run_update(), variable_get(), and variable_set().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Update Manager module: install

Functions
Update Manager module: install

Functions

_update_manager_check_backends (&$form, $operation)
update_manager_install_form_validate ($form, &$form_state)
update_manager_install_form_submit ($form, &$form_state)

Detailed Description

End of "defgroup update_manager_update".

Update Manager module functionality for installing new code.

Provides a user interface to install new code.

Function Documentation

_update_manager_check_backends | ( | & | $form,
 |  |  | $operation
 | ) |  |

Checks for file transfer backends and prepares a form fragment about them.

Parameters
array | $form | Reference to the form array we're building.
string | $operation | The update manager operation we're in the middle of. Can be either 'update' or 'install'. Use to provide operation-specific interface text.
Returns
TRUE if the update manager should continue to the next step in the workflow, or FALSE if we've hit a fatal configuration and must halt the workflow.

Definition at line 553 of file update.manager.inc.

References drupal_get_filetransfer_info(), format_plural(), t(), and update_manager_local_transfers_allowed().

Referenced by update_manager_install_form(), update_manager_update_form(), and update_manager_update_ready_form().

update_manager_install_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for update_manager_install_form().

Either downloads the file specified in the URL to a temporary cache, or uploads the file attached to the form, then attempts to extract the archive into a temporary location and verify it. Instantiate the appropriate Updater class for this project and make sure it is not already installed in the live webroot. If everything is successful, setup an operation to run via authorize.php which will copy the extracted files from the temporary location into the live site.

See Also
update_manager_install_form_validate()
update_authorize_run_install()
system_authorized_init()
system_authorized_get_url()

Definition at line 639 of file update.manager.inc.

References _update_manager_extract_directory(), archiver_get_extensions(), conf_path(), drupal_get_path(), drupal_get_updaters(), drupal_realpath(), DRUPAL_ROOT, drupal_set_message(), Updater\factory(), FILE_EXISTS_REPLACE, file_save_upload(), form_set_error(), Updater\getProjectTitle(), module_load_include(), system_authorized_get_url(), system_authorized_init(), t(), update_manager_archive_extract(), update_manager_archive_verify(), and update_manager_file_get().

update_manager_install_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for update_manager_install_form().

See Also
update_manager_install_form_submit()

Definition at line 611 of file update.manager.inc.

References form_set_error(), t(), and valid_url().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Update Manager module: file management

Functions
Update Manager module: file management

Functions

hook_verify_update_archive ($project, $archive_file, $directory)
update_manager_archive_extract ($file, $directory)
update_manager_archive_verify ($project, $archive_file, $directory)
update_manager_file_get ($url)
update_manager_batch_project_get ($project, $url, &$context)
update_manager_local_transfers_allowed ()

Detailed Description

End of "defgroup update_manager_install".

Update Manager module file management functions.

These functions are used by the update manager to copy, extract, and verify archive files.

Function Documentation

hook_verify_update_archive | ( | $project,
 |  | $archive_file,
 |  | $directory
 | ) |

Verify an archive after it has been downloaded and extracted.

Parameters
string | $project | The short name of the project that has been downloaded.
string | $archive_file | The filename of the unextracted archive.
string | $directory | The directory that the archive was extracted into.
Returns
If there are any problems, return an array of error messages. If there are no problems, return an empty array.
See Also
update_manager_archive_verify()

Definition at line 122 of file update.api.php.

References t().

update_manager_archive_extract | ( | $file,
 |  | $directory
 | ) |

Unpacks a downloaded archive file.

Parameters
string | $file | The filename of the archive you wish to extract.
string | $directory | The directory you wish to extract the archive into.
Returns
Archiver The Archiver object used to extract the archive.
Exceptions
Exception

Definition at line 773 of file update.manager.inc.

References archiver_get_archiver(), file_unmanaged_delete_recursive(), and t().

Referenced by update_manager_batch_project_get(), and update_manager_install_form_submit().

update_manager_archive_verify | ( | $project,
 |  | $archive_file,
 |  | $directory
 | ) |

Verifies an archive after it has been downloaded and extracted.

This function is responsible for invoking hook_verify_update_archive().

Parameters
string | $project | The short name of the project to download.
string | $archive_file | The filename of the unextracted archive.
string | $directory | The directory that the archive was extracted into.
Returns
array An array of error messages to display if the archive was invalid. If there are no errors, it will be an empty array.

Definition at line 814 of file update.manager.inc.

References module_invoke_all().

Referenced by update_manager_batch_project_get(), and update_manager_install_form_submit().

update_manager_batch_project_get | ( |  | $project,
 |  |  | $url,
 |  | & | $context
 | ) |  |

Batch callback: Downloads, unpacks, and verifies a project.

This function assumes that the provided URL points to a file archive of some sort. The URL can have any scheme that we have a file stream wrapper to support. The file is downloaded to a local cache.

Parameters
string | $project | The short name of the project to download.
string | $url | The URL to download a specific project release archive file.
array | $context | Reference to an array used for Batch API storage.
See Also
update_manager_download_page()

Definition at line 865 of file update.manager.inc.

References $url, _update_manager_extract_directory(), t(), update_manager_archive_extract(), update_manager_archive_verify(), and update_manager_file_get().

update_manager_file_get ( $url )

Copies a file from the specified URL to the temporary directory for updates.

Returns the local path if the file has already been downloaded.

Parameters
$url The URL of the file on the server.
Returns
string Path to local file.

Definition at line 829 of file update.manager.inc.

References $url, _update_manager_cache_directory(), drupal_basename(), drupal_realpath(), FILE_EXISTS_REPLACE, system_retrieve_file(), and update_delete_file_if_stale().

Referenced by update_manager_batch_project_get(), and update_manager_install_form_submit().

update_manager_local_transfers_allowed ( )

Determines if file transfers will be performed locally.

If the server is configured such that webserver-created files have the same owner as the configuration directory (e.g., sites/default) where new code will eventually be installed, the update manager can transfer files entirely locally, without changing their ownership (in other words, without prompting the user for FTP, SSH or other credentials).

This server configuration is an inherent security weakness because it allows a malicious webserver process to append arbitrary PHP code and then execute it. However, it is supported here because it is a common configuration on shared hosting, and there is nothing Drupal can do to prevent it.

Returns
TRUE if local file transfers are allowed on this server, or FALSE if not.
See Also
update_manager_update_ready_form_submit()
update_manager_install_form_submit()
install_check_requirements()

Definition at line 927 of file update.manager.inc.

References conf_path(), drupal_tempnam(), and drupal_unlink().

Referenced by _update_manager_check_backends().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Private update status cache system

Functions
Private update status cache system

Functions

_update_cache_set ($cid, $data, $expire)
_update_cache_get ($cid)
_update_get_cache_multiple ($cid_prefix)
_update_cache_clear ($cid=NULL, $wildcard=FALSE)
update_flush_caches ()

Detailed Description

Functions to manage the update status cache.

We specifically do NOT use the core cache API for saving the fetched data about available updates. It is vitally important that this cache is only cleared when we're populating it after successfully fetching new available update data. Usage of the core cache API results in all sorts of potential problems that would result in attempting to fetch available update data all the time, including if a site has a "minimum cache lifetime" (which is both a minimum and a maximum) defined, or if a site uses memcache or another pluggable cache system that assumes volatile caches.

The Update Manager module still uses the {cache_update} table, but instead of using cache_set(), cache_get(), and cache_clear_all(), there are private helper functions that implement these same basic tasks but ensure that the cache is not prematurely cleared, and that the data is always stored in the database, even if memcache or another cache backend is in use.

Function Documentation

_update_cache_clear | ( | $cid = NULL,
 |  | $wildcard = FALSE
 | ) |

Invalidates cached data relating to update status.

Parameters
$cid | (optional) Cache ID of the record to clear from the private update module cache. If empty, all records will be cleared from the table except fetch tasks. Defaults to NULL.
$wildcard | (optional) If TRUE, cache IDs starting with $cid are deleted in addition to the exact cache ID specified by $cid. Defaults to FALSE.

Definition at line 846 of file update.module.

References db_delete().

Referenced by _update_process_fetch_task(), _update_refresh(), hook_themes_disabled(), update_cache_clear_submit(), update_flush_caches(), update_project_cache(), update_settings_submit(), update_themes_disabled(), and update_themes_enabled().

_update_cache_get ( $cid )

Retrieves data from the private update status cache table.

Parameters
$cid The cache ID to retrieve.
Returns
An array of data for the given cache ID, or NULL if the ID was not found.
See Also
_update_cache_set()

Definition at line 799 of file update.module.

References db_query().

Referenced by _update_process_fetch_task(), and update_project_cache().

_update_cache_set | ( | $cid,
 |  | $data,
 |  | $expire
 | ) |

Stores data in the private update status cache table.

Parameters
$cid | The cache ID to save the data with.
$data | The data to store.
$expire One of the following values:
  • CACHE_PERMANENT: Indicates that the item should never be removed except by explicitly using _update_cache_clear().
  • A Unix timestamp: Indicates that the item should be kept at least until the given time, after which it will be invalidated.
See Also
_update_cache_get()

Definition at line 769 of file update.module.

References db_merge(), and REQUEST_TIME.

Referenced by _update_process_fetch_task(), update_calculate_project_data(), and update_get_projects().

_update_get_cache_multiple ( $cid_prefix )

Returns an array of cache items with a given cache ID prefix.

Parameters
string $cid_prefix The cache ID prefix.
Returns
Associative array of cache items, keyed by cache ID.

Definition at line 818 of file update.module.

References db_select().

Referenced by _update_create_fetch_task(), and _update_get_cached_available_releases().

update_flush_caches ( )

Implements hook_flush_caches().

Called from update.php (among others) to flush the caches. Since we're running update.php, we are likely to install a new version of something, in which case, we want to check for available update data again. However, because we have our own caching system, we need to directly clear the database table ourselves at this point and return nothing, for example, on sites that use memcache where cache_clear_all() won't know how to purge this data.

However, we only want to do this from update.php, since otherwise, we'd lose all the available update data on every cron run. So, we specifically check if the site is in MAINTENANCE_MODE == 'update' (which indicates update.php is running, not update module... alas for overloaded names).

Definition at line 882 of file update.module.

References _update_cache_clear(), and MAINTENANCE_MODE.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Class List
Here are the classes, structs, unions and interfaces with brief descriptions:
o N Archive_Tar
o C Archive_Tar
o C ArchiverInterface
o C ArchiverTar
o C ArchiverZip
o C BatchMemoryQueue
o C BatchQueue
o C CommentController
o C Database
o C DatabaseCondition
o C DatabaseConnection
o C DatabaseConnection_mysql
o C DatabaseConnection_pgsql
o C DatabaseConnection_sqlite
o C DatabaseConnectionNotDefinedException
o C DatabaseDriverNotSpecifiedException
o C DatabaseLog
o C DatabaseSchema
o C DatabaseSchema_mysql
o C DatabaseSchema_pgsql
o C DatabaseSchema_sqlite
o C DatabaseSchemaObjectDoesNotExistException
o C DatabaseSchemaObjectExistsException
o C DatabaseStatement_sqlite
o C DatabaseStatementBase
o C DatabaseStatementEmpty
o C DatabaseStatementInterface
o C DatabaseStatementPrefetch
o C DatabaseTaskException
o C DatabaseTasks
o C DatabaseTasks_mysql
o C DatabaseTasks_pgsql
o C DatabaseTasks_sqlite
o C DatabaseTransaction
o C DatabaseTransactionCommitFailedException
o C DatabaseTransactionExplicitCommitNotAllowedException
o C DatabaseTransactionNameNonUniqueException
o C DatabaseTransactionNoActiveException
o C DatabaseTransactionOutOfOrderException
o C DefaultMailSystem
o C DeleteQuery
o C DeleteQuery_sqlite
o C DrupalCacheArray
o C DrupalCacheInterface
o C DrupalDatabaseCache
o C DrupalDefaultEntityController
o C DrupalEntityControllerInterface
o C DrupalFakeCache
o C DrupalLocalStreamWrapper
o C DrupalPrivateStreamWrapper
o C DrupalPublicStreamWrapper
o C DrupalQueue
o C DrupalQueueInterface
o C DrupalReliableQueueInterface
o C DrupalStreamWrapperInterface
o C DrupalTemporaryStreamWrapper
o C DrupalTestCase
o C DrupalUnitTestCase
o C DrupalUpdateException
o C DrupalUpdaterInterface
o C DrupalWebTestCase
o C EntityExampleBasicController
o C EntityExampleBasicControllerInterface
o C EntityFieldQuery
o C EntityFieldQueryException
o C EntityMalformedException
o C Exception
o C FieldException
o C FieldInfo
o C FieldsOverlapException
o C FieldUpdateForbiddenException
o C FieldValidationException
o C FileExampleSessionStreamWrapper
o C FileTransfer
o C FileTransferChmodInterface
o C FileTransferException
o C FileTransferFTP
o C FileTransferFTPExtension
o C FileTransferLocal
o C FileTransferSSH
o C InsertQuery
o C InsertQuery_mysql
o C InsertQuery_pgsql
o C InsertQuery_sqlite
o C InvalidMergeQueryException
o C MailSystemInterface
o C MemoryQueue
o C MergeQuery
o C ModuleUpdater
o C NodeController
o C NoFieldsException
o C PagerDefault
o C Query
o C QueryAlterableInterface
o C QueryConditionInterface
o C QueryExtendableInterface
o C QueryPlaceholderInterface
o C SchemaCache
o C SearchQuery
o C SelectQuery
o C SelectQuery_pgsql
o C SelectQuery_sqlite
o C SelectQueryExtender
o C SelectQueryInterface
o C SkipDotsRecursiveDirectoryIterator
o C StreamWrapperInterface
o C SystemQueue
o C TableSort
o C TaxonomyTermController
o C TaxonomyVocabularyController
o C TestingMailSystem
o C ThemeUpdater
o C TruncateQuery
o C TruncateQuery_mysql
o C TruncateQuery_sqlite
o C UpdateQuery
o C UpdateQuery_pgsql
o C UpdateQuery_sqlite
o C Updater
o C UpdaterException
o C UpdaterFileTransferException
\ C UserController
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Archive_Tar Namespace Reference

  • Namespace List
Archive_Tar Namespace Reference

Detailed Description

Author
Vincent Blavet vince.nosp@m.nt@p.nosp@m.hpcon.nosp@m.cept.nosp@m..net
Copyright
1997-2008 The Authors http://www.opensource.org/licenses/bsd-license.php New BSD License
Version
CVS: Id: Tar.php,v 1.43 2008/10/30 17:58:42 dufuz Exp Creates a (compressed) Tar archive Vincent Blavet vince.nosp@m.nt@p.nosp@m.hpcon.nosp@m.cept.nosp@m..net Revision: 1.43 http://www.opensource.org/licenses/bsd-license.php New BSD License
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Archive_Tar Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Public Attributes | List of all members
Archive_Tar Class Reference

Public Member Functions

__construct ($p_tarname, $p_compress=null)
loadExtension ($ext)
__destruct ()
create ($p_filelist)
add ($p_filelist)
extract ($p_path='')
listContent ()
createModify ($p_filelist, $p_add_dir, $p_remove_dir='')
addModify ($p_filelist, $p_add_dir, $p_remove_dir='')
addString ($p_filename, $p_string)
extractModify ($p_path, $p_remove_path)
extractInString ($p_filename)
extractList ($p_filelist, $p_path='', $p_remove_path='')
setAttribute ()
_error ($p_message)
_warning ($p_message)
_isArchive ($p_filename=NULL)
_openWrite ()
_openRead ()
_openReadWrite ()
_close ()
_cleanFile ()
_writeBlock ($p_binary_data, $p_len=null)
_readBlock ()
_jumpBlock ($p_len=null)
_writeFooter ()
_addList ($p_list, $p_add_dir, $p_remove_dir)
_addFile ($p_filename, &$p_header, $p_add_dir, $p_remove_dir)
_addString ($p_filename, $p_string)
_writeHeader ($p_filename, $p_stored_filename)
_writeHeaderBlock ($p_filename, $p_size, $p_mtime=0, $p_perms=0, $p_type='', $p_uid=0, $p_gid=0)
_writeLongHeader ($p_filename)
_readHeader ($v_binary_data, &$v_header)
_maliciousFilename ($file)
_readLongHeader (&$v_header)
_extractInString ($p_filename)
_extractList ($p_path, &$p_list_detail, $p_mode, $p_file_list, $p_remove_path)
_openAppend ()
_append ($p_filelist, $p_add_dir='', $p_remove_dir='')
_dirCheck ($p_dir)
_pathReduction ($p_dir)
_translateWinPath ($p_path, $p_remove_disk_letter=true)

Public Attributes

$_tarname =''
$_compress =false
$_compress_type ='none'
$_separator =' '
$_file =0
$_temp_tarname =''

Detailed Description

Definition at line 57 of file system.tar.inc.

Constructor & Destructor Documentation

__construct | ( | $p_tarname,
 |  | $p_compress = null
 | ) |

Archive_Tar Class constructor. This flavour of the constructor only declare a new Archive_Tar object, identifying it by the name of the tar file. If the compress argument is set the tar will be read or created as a gzip or bz2 compressed TAR file.

Parameters
string | $p_tarname | The name of the tar archive to create
string | $p_compress | can be null, 'gz' or 'bz2'. This parameter indicates if gzip or bz2 compression is required. For compatibility reason the boolean value 'true' means 'gz'. public

Definition at line 105 of file system.tar.inc.

References loadExtension().

__destruct ( )

Definition at line 208 of file system.tar.inc.

References _close(), and drupal_unlink().

Member Function Documentation

_addFile | ( |  | $p_filename,
 |  | & | $p_header,
 |  |  | $p_add_dir,
 |  |  | $p_remove_dir
 | ) |  |

Definition at line 963 of file system.tar.inc.

References _error(), _isArchive(), _pathReduction(), _translateWinPath(), _warning(), _writeBlock(), and _writeHeader().

Referenced by _addList().

_addList | ( | $p_list,
 |  | $p_add_dir,
 |  | $p_remove_dir
 | ) |

Definition at line 896 of file system.tar.inc.

References _addFile(), _error(), _translateWinPath(), and _warning().

Referenced by _append(), and createModify().

_addString | ( | $p_filename,
 |  | $p_string
 | ) |

Definition at line 1026 of file system.tar.inc.

References _error(), _translateWinPath(), _writeBlock(), and _writeHeaderBlock().

Referenced by addString().

_append | ( | $p_filelist,
 |  | $p_add_dir = '',
 |  | $p_remove_dir = ''
 | ) |

Definition at line 1774 of file system.tar.inc.

References _addList(), _close(), _openAppend(), and _writeFooter().

Referenced by addModify().

_cleanFile ( )

Definition at line 789 of file system.tar.inc.

References _close(), and drupal_unlink().

Referenced by createModify().

_close ( )

Definition at line 760 of file system.tar.inc.

References _error(), and drupal_unlink().

Referenced by __destruct(), _append(), _cleanFile(), addString(), createModify(), extractInString(), extractList(), extractModify(), and listContent().

_dirCheck ( $p_dir )

Check if a directory exists and create it (including parent dirs) if not.

Parameters
string $p_dir directory to check
Returns
bool TRUE if the directory exists or was created

Definition at line 1798 of file system.tar.inc.

References _error(), and drupal_mkdir().

Referenced by _extractList().

_error ( $p_message )

Definition at line 631 of file system.tar.inc.

Referenced by _addFile(), _addList(), _addString(), _close(), _dirCheck(), _extractInString(), _extractList(), _jumpBlock(), _openRead(), _openReadWrite(), _openWrite(), _readBlock(), _readHeader(), _readLongHeader(), _writeBlock(), addModify(), createModify(), extractList(), and setAttribute().

_extractInString ( $p_filename )

This method extract from the archive one file identified by $p_filename. The return value is a string with the file content, or NULL on error.

Parameters
string $p_filename The path of the file to extract in a string.
Returns
a string with the file content or NULL. private

Definition at line 1415 of file system.tar.inc.

References _error(), _jumpBlock(), _readBlock(), _readHeader(), and _readLongHeader().

Referenced by extractInString().

_extractList | ( |  | $p_path,
 |  | & | $p_list_detail,
 |  |  | $p_mode,
 |  |  | $p_file_list,
 |  |  | $p_remove_path
 | ) |  |

Definition at line 1460 of file system.tar.inc.

References _dirCheck(), _error(), _isArchive(), _readBlock(), _readHeader(), _readLongHeader(), _translateWinPath(), drupal_mkdir(), and drupal_unlink().

Referenced by extractList(), extractModify(), and listContent().

_isArchive ( $p_filename = NULL )

Definition at line 649 of file system.tar.inc.

References $_tarname.

Referenced by _addFile(), _extractList(), addModify(), and addString().

_jumpBlock ( $p_len = null )

Definition at line 859 of file system.tar.inc.

References _error(), and _readBlock().

Referenced by _extractInString().

_maliciousFilename ( $file )

Detect and report a malicious file name

Parameters
string $file
Returns
bool private

Definition at line 1363 of file system.tar.inc.

Referenced by _readHeader(), and _readLongHeader().

_openAppend ( )

Definition at line 1685 of file system.tar.inc.

Referenced by _append(), and addString().

_openRead ( )

Definition at line 683 of file system.tar.inc.

References $_tarname, $_temp_tarname, and _error().

Referenced by extractInString(), extractList(), extractModify(), and listContent().

_openReadWrite ( )

Definition at line 735 of file system.tar.inc.

References _error().

_openWrite ( )

Definition at line 660 of file system.tar.inc.

References _error().

Referenced by addString(), and createModify().

_pathReduction ( $p_dir )

Compress path by changing for example "/dir/foo/../bar" to "/dir/bar", rand emove double slashes.

Parameters
string $p_dir path to reduce
Returns
string reduced path

private

Definition at line 1836 of file system.tar.inc.

Referenced by _addFile(), _writeHeader(), and _writeHeaderBlock().

_readBlock ( )

Definition at line 840 of file system.tar.inc.

References _error().

Referenced by _extractInString(), _extractList(), _jumpBlock(), and _readLongHeader().

_readHeader | ( |  | $v_binary_data,
 |  | & | $v_header
 | ) |  |

Definition at line 1277 of file system.tar.inc.

References _error(), and _maliciousFilename().

Referenced by _extractInString(), _extractList(), and _readLongHeader().

_readLongHeader ( & $v_header )

Definition at line 1376 of file system.tar.inc.

References _error(), _maliciousFilename(), _readBlock(), and _readHeader().

Referenced by _extractInString(), and _extractList().

_translateWinPath | ( | $p_path,
 |  | $p_remove_disk_letter = true
 | ) |

Definition at line 1874 of file system.tar.inc.

Referenced by _addFile(), _addList(), _addString(), and _extractList().

_warning ( $p_message )

Definition at line 640 of file system.tar.inc.

Referenced by _addFile(), and _addList().

_writeBlock | ( | $p_binary_data,
 |  | $p_len = null
 | ) |

Definition at line 809 of file system.tar.inc.

References _error().

Referenced by _addFile(), _addString(), _writeFooter(), _writeHeader(), _writeHeaderBlock(), and _writeLongHeader().

_writeFooter ( )

Definition at line 884 of file system.tar.inc.

References _writeBlock().

Referenced by _append(), addString(), and createModify().

_writeHeader | ( | $p_filename,
 |  | $p_stored_filename
 | ) |

Definition at line 1056 of file system.tar.inc.

References _pathReduction(), _writeBlock(), and _writeLongHeader().

Referenced by _addFile().

_writeHeaderBlock | ( | $p_filename,
 |  | $p_size,
 |  | $p_mtime = 0,
 |  | $p_perms = 0,
 |  | $p_type = '',
 |  | $p_uid = 0,
 |  | $p_gid = 0
 | ) |

Definition at line 1139 of file system.tar.inc.

References _pathReduction(), _writeBlock(), and _writeLongHeader().

Referenced by _addString().

_writeLongHeader ( $p_filename )

Definition at line 1213 of file system.tar.inc.

References _writeBlock().

Referenced by _writeHeader(), and _writeHeaderBlock().

add ( $p_filelist )

This method add the files / directories that are listed in $p_filelist in the archive. If the archive does not exist it is created. The method return false and a PEAR error text. The files and directories listed are only added at the end of the archive, even if a file with the same name is already archived. See also createModify() method for more details.

Parameters
array $p_filelist An array of filenames and directory names, or a single string with names separated by a single blank space.
Returns
true on success, false on error.
See Also
createModify() public

Definition at line 262 of file system.tar.inc.

References addModify().

addModify | ( | $p_filelist,
 |  | $p_add_dir,
 |  | $p_remove_dir = ''
 | ) |

This method add the files / directories listed in $p_filelist at the end of the existing archive. If the archive does not yet exists it is created. The $p_filelist parameter can be an array of string, each string representing a filename or a directory name with their path if needed. It can also be a single string with names separated by a single blank. The path indicated in $p_remove_dir will be removed from the memorized path of each file / directory listed when this path exists. By default nothing is removed (empty path '') The path indicated in $p_add_dir will be added at the beginning of the memorized path of each file / directory listed. However it can be set to empty ''. The adding of a path is done after the removing of path. The path add/remove ability enables the user to prepare an archive for extraction in a different path than the origin files are. If a file/dir is already in the archive it will only be added at the end of the archive. There is no update of the existing archived file/dir. However while extracting the archive, the last file will replace the first one. This results in a none optimization of the archive size. If a file/dir does not exist the file/dir is ignored. However an error text is send to PEAR error. If a file/dir is not readable the file/dir is ignored. However an error text is send to PEAR error.

Parameters
array | $p_filelist | An array of filenames and directory names, or a single string with names separated by a single blank space.
string | $p_add_dir | A string which contains a path to be added to the memorized path of each element in the list.
string | $p_remove_dir | A string which contains a path to be removed from the memorized path of each element in the list, when relevant.
Returns
true on success, false on error. public

Definition at line 400 of file system.tar.inc.

References _append(), _error(), _isArchive(), and createModify().

Referenced by add().

addString | ( | $p_filename,
 |  | $p_string
 | ) |

This method add a single string as a file at the end of the existing archive. If the archive does not yet exists it is created.

Parameters
string | $p_filename | A string which contains the full filename path that will be associated with the string.
string | $p_string | The content of the file added in the archive.
Returns
true on success, false on error. public

Definition at line 438 of file system.tar.inc.

References _addString(), _close(), _isArchive(), _openAppend(), _openWrite(), and _writeFooter().

create ( $p_filelist )

This method creates the archive file and add the files / directories that are listed in $p_filelist. If a file with the same name exist and is writable, it is replaced by the new tar. The method return false and a PEAR error text. The $p_filelist parameter can be an array of string, each string representing a filename or a directory name with their path if needed. It can also be a single string with names separated by a single blank. For each directory added in the archive, the files and sub-directories are also added. See also createModify() method for more details.

Parameters
array $p_filelist An array of filenames and directory names, or a single string with names separated by a single blank space.
Returns
true on success, false on error.
See Also
createModify() public

Definition at line 240 of file system.tar.inc.

References createModify().

createModify | ( | $p_filelist,
 |  | $p_add_dir,
 |  | $p_remove_dir = ''
 | ) |

This method creates the archive file and add the files / directories that are listed in $p_filelist. If the file already exists and is writable, it is replaced by the new tar. It is a create and not an add. If the file exists and is read-only or is a directory it is not replaced. The method return false and a PEAR error text. The $p_filelist parameter can be an array of string, each string representing a filename or a directory name with their path if needed. It can also be a single string with names separated by a single blank. The path indicated in $p_remove_dir will be removed from the memorized path of each file / directory listed when this path exists. By default nothing is removed (empty path '') The path indicated in $p_add_dir will be added at the beginning of the memorized path of each file / directory listed. However it can be set to empty ''. The adding of a path is done after the removing of path. The path add/remove ability enables the user to prepare an archive for extraction in a different path than the origin files are. See also addModify() method for file adding properties.

Parameters
array | $p_filelist | An array of filenames and directory names, or a single string with names separated by a single blank space.
string | $p_add_dir | A string which contains a path to be added to the memorized path of each element in the list.
string | $p_remove_dir | A string which contains a path to be removed from the memorized path of each element in the list, when relevant.
Returns
boolean true on success, false on error. public
See Also
addModify()

Definition at line 328 of file system.tar.inc.

References _addList(), _cleanFile(), _close(), _error(), _openWrite(), and _writeFooter().

Referenced by addModify(), and create().

extract ( $p_path = '' )

Definition at line 269 of file system.tar.inc.

References extractModify().

extractInString ( $p_filename )

This method extract from the archive one file identified by $p_filename. The return value is a string with the file content, or NULL on error.

Parameters
string $p_filename The path of the file to extract in a string.
Returns
a string with the file content or NULL. public

Definition at line 520 of file system.tar.inc.

References _close(), _extractInString(), and _openRead().

extractList | ( | $p_filelist,
 |  | $p_path = '',
 |  | $p_remove_path = ''
 | ) |

This method extract from the archive only the files indicated in the $p_filelist. These files are extracted in the current directory or in the directory indicated by the optional $p_path parameter. If indicated the $p_remove_path can be used in the same way as it is used in extractModify() method.

Parameters
array | $p_filelist | An array of filenames and directory names, or a single string with names separated by a single blank space.
string | $p_path | The path of the directory where the files/dir need to by extracted.
string | $p_remove_path | Part of the memorized path that can be removed if present at the beginning of the file/dir path.
Returns
true on success, false on error. public
See Also
extractModify()

Definition at line 552 of file system.tar.inc.

References _close(), _error(), _extractList(), and _openRead().

extractModify | ( | $p_path,
 |  | $p_remove_path
 | ) |

This method extract all the content of the archive in the directory indicated by $p_path. When relevant the memorized path of the files/dir can be modified by removing the $p_remove_path path at the beginning of the file/dir path. While extracting a file, if the directory path does not exists it is created. While extracting a file, if the file already exists it is replaced without looking for last modification date. While extracting a file, if the file already exists and is write protected, the extraction is aborted. While extracting a file, if a directory with the same name already exists, the extraction is aborted. While extracting a directory, if a file with the same name already exists, the extraction is aborted. While extracting a file/directory if the destination directory exist and is write protected, or does not exist but can not be created, the extraction is aborted. If after extraction an extracted file does not show the correct stored file size, the extraction is aborted. When the extraction is aborted, a PEAR error text is set and false is returned. However the result can be a partial extraction that may need to be manually cleaned.

Parameters
string | $p_path | The path of the directory where the files/dir need to by extracted.
string | $p_remove_path | Part of the memorized path that can be removed if present at the beginning of the file/dir path.
Returns
boolean true on success, false on error. public
See Also
extractList()

Definition at line 497 of file system.tar.inc.

References _close(), _extractList(), and _openRead().

Referenced by extract().

listContent ( )

Definition at line 276 of file system.tar.inc.

References _close(), _extractList(), and _openRead().

loadExtension ( $ext )

OS independent PHP extension load. Remember to take care on the correct extension name for case sensitive OSes. The function is the copy of PEAR::loadExtension().

Parameters
string $ext The extension name
Returns
bool Success or not on the dl() call

Definition at line 179 of file system.tar.inc.

Referenced by __construct().

setAttribute ( )

This method set specific attributes of the archive. It uses a variable list of parameters, in the format attribute code + attribute values : $arch->setAttribute(ARCHIVE_TAR_ATT_SEPARATOR, ',');

Parameters
mixed $argv variable list of attributes and values
Returns
true on success, false on error. public

Definition at line 585 of file system.tar.inc.

References _error(), and ARCHIVE_TAR_ATT_SEPARATOR.

Member Data Documentation

$_compress =false

Definition at line 67 of file system.tar.inc.

$_compress_type ='none'

Definition at line 72 of file system.tar.inc.

$_file =0

Definition at line 82 of file system.tar.inc.

$_separator =' '

Definition at line 77 of file system.tar.inc.

$_tarname =''

Definition at line 62 of file system.tar.inc.

Referenced by _isArchive(), and _openRead().

$_temp_tarname =''

Definition at line 87 of file system.tar.inc.

Referenced by _openRead().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: ArchiverInterface Interface Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
ArchiverInterface Interface Reference
Inheritance diagram for ArchiverInterface:
ArchiverTar ArchiverZip

Public Member Functions

__construct ($file_path)
add ($file_path)
remove ($path)
extract ($path, array $files=array())
listContents ()

Detailed Description

Defines the common interface for all Archiver classes.

Definition at line 11 of file archiver.inc.

Constructor & Destructor Documentation

__construct ( $file_path )

Constructs a new archiver instance.

Parameters
$file_path The full system path of the archive to manipulate. Only local files are supported. If the file does not yet exist, it will be created if appropriate.

Implemented in ArchiverZip, and ArchiverTar.

Member Function Documentation

add ( $file_path )

Adds the specified file or directory to the archive.

Parameters
$file_path The full system path of the file or directory to add. Only local files and directories are supported.
Returns
ArchiverInterface The called object.

Implemented in ArchiverZip, and ArchiverTar.

extract | ( |  | $path,
 |  | array | $files = array()
 | ) |  |

Extracts multiple files in the archive to the specified path.

Parameters
$path | A full system path of the directory to which to extract files.
$files | Optionally specify a list of files to be extracted. Files are relative to the root of the archive. If not specified, all files in the archive will be extracted.
Returns
ArchiverInterface The called object.
listContents ( )

Lists all files in the archive.

Returns
An array of file names relative to the root of the archive.

Implemented in ArchiverZip, and ArchiverTar.

remove ( $path )

Removes the specified file from the archive.

Parameters
$path The file name relative to the root of the archive to remove.
Returns
ArchiverInterface The called object.

Implemented in ArchiverZip, and ArchiverTar.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: ArchiverTar Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Attributes | List of all members
ArchiverTar Class Reference
Inheritance diagram for ArchiverTar:
ArchiverInterface

Public Member Functions

__construct ($file_path)
add ($file_path)
remove ($file_path)
extract ($path, Array $files=array())
listContents ()
getArchive ()
- Public Member Functions inherited from ArchiverInterface
extract ($path, array $files=array())

Protected Attributes

$tar

Detailed Description

Archiver for .tar files.

Definition at line 11 of file system.archiver.inc.

Constructor & Destructor Documentation

__construct ( $file_path )

Constructs a new archiver instance.

Parameters
$file_path The full system path of the archive to manipulate. Only local files are supported. If the file does not yet exist, it will be created if appropriate.

Implements ArchiverInterface.

Definition at line 20 of file system.archiver.inc.

Member Function Documentation

add ( $file_path )

Adds the specified file or directory to the archive.

Parameters
$file_path The full system path of the file or directory to add. Only local files and directories are supported.
Returns
ArchiverInterface The called object.

Implements ArchiverInterface.

Definition at line 24 of file system.archiver.inc.

extract | ( |  | $path,
 |  | Array | $files = array()
 | ) |  |

Definition at line 39 of file system.archiver.inc.

getArchive ( )

Retrieve the tar engine itself.

In some cases it may be necessary to directly access the underlying Archive_Tar object for implementation-specific logic. This is for advanced use only as it is not shared by other implementations of ArchiveInterface.

Returns
The Archive_Tar object used by this object.

Definition at line 68 of file system.archiver.inc.

References $tar.

listContents ( )

Lists all files in the archive.

Returns
An array of file names relative to the root of the archive.

Implements ArchiverInterface.

Definition at line 50 of file system.archiver.inc.

remove ( $path )

Removes the specified file from the archive.

Parameters
$path The file name relative to the root of the archive to remove.
Returns
ArchiverInterface The called object.

Implements ArchiverInterface.

Definition at line 30 of file system.archiver.inc.

Member Data Documentation

$tar
protected

Definition at line 18 of file system.archiver.inc.

Referenced by getArchive().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: ArchiverZip Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Attributes | List of all members
ArchiverZip Class Reference
Inheritance diagram for ArchiverZip:
ArchiverInterface

Public Member Functions

__construct ($file_path)
add ($file_path)
remove ($file_path)
extract ($path, Array $files=array())
listContents ()
getArchive ()
- Public Member Functions inherited from ArchiverInterface
extract ($path, array $files=array())

Protected Attributes

$zip

Detailed Description

Archiver for .zip files.

http://php.net/zip

Definition at line 78 of file system.archiver.inc.

Constructor & Destructor Documentation

__construct ( $file_path )

Constructs a new archiver instance.

Parameters
$file_path The full system path of the archive to manipulate. Only local files are supported. If the file does not yet exist, it will be created if appropriate.

Implements ArchiverInterface.

Definition at line 87 of file system.archiver.inc.

References t().

Member Function Documentation

add ( $file_path )

Adds the specified file or directory to the archive.

Parameters
$file_path The full system path of the file or directory to add. Only local files and directories are supported.
Returns
ArchiverInterface The called object.

Implements ArchiverInterface.

Definition at line 95 of file system.archiver.inc.

extract | ( |  | $path,
 |  | Array | $files = array()
 | ) |  |

Definition at line 107 of file system.archiver.inc.

getArchive ( )

Retrieve the zip engine itself.

In some cases it may be necessary to directly access the underlying ZipArchive object for implementation-specific logic. This is for advanced use only as it is not shared by other implementations of ArchiveInterface.

Returns
The ZipArchive object used by this object.

Definition at line 136 of file system.archiver.inc.

References $zip.

listContents ( )

Lists all files in the archive.

Returns
An array of file names relative to the root of the archive.

Implements ArchiverInterface.

Definition at line 118 of file system.archiver.inc.

remove ( $path )

Removes the specified file from the archive.

Parameters
$path The file name relative to the root of the archive to remove.
Returns
ArchiverInterface The called object.

Implements ArchiverInterface.

Definition at line 101 of file system.archiver.inc.

Member Data Documentation

$zip
protected

Definition at line 85 of file system.archiver.inc.

Referenced by getArchive().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: BatchMemoryQueue Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
BatchMemoryQueue Class Reference
Inheritance diagram for BatchMemoryQueue:
MemoryQueue DrupalQueueInterface

Public Member Functions

claimItem ($lease_time=0)
getAllItems ()
- Public Member Functions inherited from MemoryQueue
__construct ($name)
createItem ($data)
numberOfItems ()
claimItem ($lease_time=30)
deleteItem ($item)
releaseItem ($item)
createQueue ()
deleteQueue ()

Additional Inherited Members

- Protected Attributes inherited from MemoryQueue
$queue
$id_sequence

Detailed Description

Defines a batch queue for non-progressive batches.

Definition at line 55 of file batch.queue.inc.

Member Function Documentation

claimItem ( $lease_time = 0 )

Overrides MemoryQueue::claimItem().

Unlike MemoryQueue::claimItem(), this method provides a default lease time of 0 (no expiration) instead of 30. This allows the item to be claimed repeatedly until it is deleted.

Implements DrupalQueueInterface.

Definition at line 64 of file batch.queue.inc.

getAllItems ( )

Retrieves all remaining items in the queue.

This is specific to Batch API and is not part of the DrupalQueueInterface.

Definition at line 77 of file batch.queue.inc.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: BatchQueue Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
BatchQueue Class Reference
Inheritance diagram for BatchQueue:
SystemQueue DrupalReliableQueueInterface DrupalQueueInterface

Public Member Functions

claimItem ($lease_time=0)
getAllItems ()
- Public Member Functions inherited from SystemQueue
__construct ($name)
createItem ($data)
numberOfItems ()
claimItem ($lease_time=30)
releaseItem ($item)
deleteItem ($item)
createQueue ()
deleteQueue ()

Additional Inherited Members

- Protected Attributes inherited from SystemQueue
$name

Detailed Description

Defines a batch queue.

Stale items from failed batches are cleaned from the {queue} table on cron using the 'created' date.

Definition at line 19 of file batch.queue.inc.

Member Function Documentation

claimItem ( $lease_time = 0 )

Overrides SystemQueue::claimItem().

Unlike SystemQueue::claimItem(), this method provides a default lease time of 0 (no expiration) instead of 30. This allows the item to be claimed repeatedly until it is deleted.

Implements DrupalQueueInterface.

Definition at line 28 of file batch.queue.inc.

References db_query_range(), and name.

getAllItems ( )

Retrieves all remaining items in the queue.

This is specific to Batch API and is not part of the DrupalQueueInterface.

Definition at line 42 of file batch.queue.inc.

References db_query(), and name.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: CommentController Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Protected Member Functions | List of all members
CommentController Class Reference
Inheritance diagram for CommentController:
DrupalDefaultEntityController DrupalEntityControllerInterface

Protected Member Functions

buildQuery ($ids, $conditions=array(), $revision_id=FALSE)
attachLoad (&$comments, $revision_id=FALSE)
- Protected Member Functions inherited from DrupalDefaultEntityController
buildQuery ($ids, $conditions=array(), $revision_id=FALSE)
attachLoad (&$queried_entities, $revision_id=FALSE)
cacheGet ($ids, $conditions=array())
cacheSet ($entities)

Additional Inherited Members

- Public Member Functions inherited from DrupalDefaultEntityController
__construct ($entityType)
resetCache (array $ids=NULL)
load ($ids=array(), $conditions=array())
- Protected Attributes inherited from DrupalDefaultEntityController
$entityCache
$entityType
$entityInfo
$hookLoadArguments
$idKey
$revisionKey
$revisionTable
$cache

Detailed Description

Controller class for comments.

This extends the DrupalDefaultEntityController class, adding required special handling for comment objects.

Definition at line 1694 of file comment.module.

Member Function Documentation

attachLoad | ( | & | $comments,
 |  |  | $revision_id = FALSE
 | ) |  |
protected

Definition at line 1707 of file comment.module.

References node_mark().

buildQuery | ( | $ids,
 |  | $conditions = array(),
 |  | $revision_id = FALSE
 | ) |
protected

Definition at line 1696 of file comment.module.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DatabaseLog Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Attributes | List of all members
DatabaseLog Class Reference

Public Member Functions

__construct ($key= 'default')
start ($logging_key)
get ($logging_key)
clear ($logging_key)
end ($logging_key)
log (DatabaseStatementInterface $statement, $args, $time)
findCaller ()

Protected Attributes

$queryLog = array()
$connectionKey = 'default'

Detailed Description

Database query logger.

We log queries in a separate object rather than in the connection object because we want to be able to see all queries sent to a given database, not database target. If we logged the queries in each connection object we would not be able to track what queries went to which target.

Every connection has one and only one logging object on it for all targets and logging keys.

Definition at line 19 of file log.inc.

Constructor & Destructor Documentation

__construct ( $key = 'default' )

Constructor.

Parameters
$key The database connection key for which to enable logging.

Definition at line 50 of file log.inc.

Member Function Documentation

clear ( $logging_key )

Empty the query log for the specified logging key.

This method does not stop logging, it simply clears the log. To stop logging, use the end() method.

Parameters
$logging_key The logging key to empty.

Definition at line 91 of file log.inc.

Referenced by start().

end ( $logging_key )

Stop logging for the specified logging key.

Parameters
$logging_key The logging key to stop.

Definition at line 101 of file log.inc.

findCaller ( )

Determine the routine that called this query.

We define "the routine that called this query" as the first entry in the call stack that is not inside includes/database and does have a file (which excludes call_user_func_array(), anonymous functions and similar). That makes the climbing logic very simple, and handles the variable stack depth caused by the query builders.

This method returns a stack trace entry similar to that generated by debug_backtrace(). However, it flattens the trace entry and the trace entry before it so that we get the function and args of the function that called into the database system, not the function and args of the database call itself.

Definition at line 144 of file log.inc.

Referenced by log().

get ( $logging_key )

Retrieve the query log for the specified logging key so far.

Parameters
$logging_key The logging key to fetch.
Returns
An indexed array of all query records for this logging key.

Definition at line 78 of file log.inc.

log | ( | DatabaseStatementInterface | $statement,
 |  |  | $args,
 |  |  | $time
 | ) |  |

Log a query to all active logging keys.

Parameters
$statement | The prepared statement object to log.
$args | The arguments passed to the statement object.
$time | The time in milliseconds the query took to execute.

Definition at line 115 of file log.inc.

References findCaller(), and DatabaseStatementInterface\getQueryString().

start ( $logging_key )

Begin logging queries to the specified connection and logging key.

If the specified logging key is already running this method does nothing.

Parameters
$logging_key The identification key for this log request. By specifying different logging keys we are able to start and stop multiple logging runs simultaneously without them colliding.

Definition at line 64 of file log.inc.

References clear().

Member Data Documentation

$connectionKey = 'default'
protected

Definition at line 42 of file log.inc.

$queryLog = array()
protected

Definition at line 35 of file log.inc.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DatabaseTaskException Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DatabaseTaskException Class Reference
Inheritance diagram for DatabaseTaskException:
Exception

Detailed Description

Exception thrown if the database installer fails.

Definition at line 581 of file install.inc.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DatabaseTasks Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DatabaseTasks Class Reference
Inheritance diagram for DatabaseTasks:
DatabaseTasks_mysql DatabaseTasks_pgsql DatabaseTasks_sqlite

Public Member Functions

installable ()
name ()
minimumVersion ()
runTasks ()
getFormOptions ($database)
validateDatabaseSettings ($database)

Protected Member Functions

hasPdoDriver ()
fail ($message)
pass ($message)
connect ()
runTestQuery ($query, $pass, $fail, $fatal=FALSE)
checkEngineVersion ()

Protected Attributes

$tasks
$results = array()

Detailed Description

Database installer structure.

Defines basic Drupal requirements for databases.

Definition at line 290 of file install.inc.

Member Function Documentation

checkEngineVersion ( )
protected

Check the engine version.

Definition at line 463 of file install.inc.

References fail(), Database\getConnection(), minimumVersion(), and st().

connect ( )
protected

Check if we can connect to the database.

Definition at line 431 of file install.inc.

References db_set_active(), fail(), Database\getConnection(), pass(), and st().

Referenced by runTasks().

fail ( $message )
protected

Assert test as failed.

Definition at line 360 of file install.inc.

Referenced by DatabaseTasks_pgsql\checkBinaryOutput(), DatabaseTasks_pgsql\checkEncoding(), checkEngineVersion(), DatabaseTasks_pgsql\checkPHPVersion(), connect(), DatabaseTasks_pgsql\initializeDatabase(), and runTestQuery().

getFormOptions ( $database )

Return driver specific configuration options.

Parameters
$database An array of driver specific configuration options.
Returns
The options form array.

Definition at line 478 of file install.inc.

References drupal_get_profile(), drupal_install_profile_distribution_name(), and st().

hasPdoDriver ( )
protected

Ensure the PDO driver is supported by the version of PHP in use.

Definition at line 353 of file install.inc.

Referenced by installable().

installable ( )

Check whether Drupal is installable on the database.

Definition at line 374 of file install.inc.

References hasPdoDriver().

minimumVersion ( )

Return the minimum required version of the engine.

Returns
A version string. If not NULL, it will be checked against the version reported by the Database engine using version_compare().

Definition at line 390 of file install.inc.

Referenced by checkEngineVersion().

name ( )
abstract

Return the human-readable name of the driver.

Referenced by runTestQuery().

pass ( $message )
protected

Assert test as a pass.

Definition at line 367 of file install.inc.

Referenced by DatabaseTasks_pgsql\checkEncoding(), connect(), DatabaseTasks_pgsql\initializeDatabase(), and runTestQuery().

runTasks ( )

Run database tasks and tests to see if Drupal can run on the database.

Definition at line 397 of file install.inc.

References connect(), and st().

runTestQuery | ( | $query,
 |  | $pass,
 |  | $fail,
 |  | $fatal = FALSE
 | ) |
protected

Run SQL tests to ensure the database can execute commands with the current user.

Definition at line 449 of file install.inc.

References db_query(), fail(), name(), pass(), and st().

validateDatabaseSettings ( $database )

Validates driver specific configuration settings.

Checks to ensure correct basic database settings and that a proper connection to the database can be established.

Parameters
$database An array of driver specific configuration options.
Returns
An array of driver configuration errors, keyed by form element name.

Definition at line 560 of file install.inc.

References st().

Member Data Documentation

$results = array()
protected

Definition at line 348 of file install.inc.

$tasks
protected

Definition at line 300 of file install.inc.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DatabaseTasks_mysql Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Attributes | List of all members
DatabaseTasks_mysql Class Reference
Inheritance diagram for DatabaseTasks_mysql:
DatabaseTasks

Public Member Functions

name ()
minimumVersion ()
- Public Member Functions inherited from DatabaseTasks
installable ()
name ()
minimumVersion ()
runTasks ()
getFormOptions ($database)
validateDatabaseSettings ($database)

Protected Attributes

$pdoDriver = 'mysql'
- Protected Attributes inherited from DatabaseTasks
$tasks
$results = array()

Additional Inherited Members

- Protected Member Functions inherited from DatabaseTasks
hasPdoDriver ()
fail ($message)
pass ($message)
connect ()
runTestQuery ($query, $pass, $fail, $fatal=FALSE)
checkEngineVersion ()

Detailed Description

Specifies installation tasks for MySQL and equivalent databases.

Definition at line 11 of file install.inc.

Member Function Documentation

minimumVersion ( )

Returns the minimum version for MySQL.

Definition at line 29 of file install.inc.

name ( )

Returns a human-readable name string for MySQL and equivalent databases.

Definition at line 22 of file install.inc.

References st().

Member Data Documentation

$pdoDriver = 'mysql'
protected

Definition at line 17 of file install.inc.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DatabaseTasks_pgsql Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DatabaseTasks_pgsql Class Reference
Inheritance diagram for DatabaseTasks_pgsql:
DatabaseTasks

Public Member Functions

__construct ()
name ()
minimumVersion ()
checkPHPVersion ()
checkBinaryOutput ()
initializeDatabase ()
- Public Member Functions inherited from DatabaseTasks
installable ()
name ()
minimumVersion ()
runTasks ()
getFormOptions ($database)
validateDatabaseSettings ($database)

Protected Member Functions

checkEncoding ()
checkBinaryOutputSuccess ()
- Protected Member Functions inherited from DatabaseTasks
hasPdoDriver ()
fail ($message)
pass ($message)
connect ()
runTestQuery ($query, $pass, $fail, $fatal=FALSE)
checkEngineVersion ()

Protected Attributes

$pdoDriver = 'pgsql'
- Protected Attributes inherited from DatabaseTasks
$tasks
$results = array()

Detailed Description

Definition at line 11 of file install.inc.

Constructor & Destructor Documentation

__construct ( )

Definition at line 14 of file install.inc.

Member Function Documentation

checkBinaryOutput ( )

Check Binary Output.

Unserializing does not work on Postgresql 9 when bytea_output is 'hex'.

Definition at line 87 of file install.inc.

References checkBinaryOutputSuccess(), db_close(), db_query(), DatabaseTasks\fail(), Database\getConnection(), and st().

checkBinaryOutputSuccess ( )
protected

Verify that a binary data roundtrip returns the original string.

Definition at line 131 of file install.inc.

References db_query().

Referenced by checkBinaryOutput().

checkEncoding ( )
protected

Check encoding is UTF8.

Definition at line 44 of file install.inc.

References db_query(), DatabaseTasks\fail(), name(), DatabaseTasks\pass(), and st().

checkPHPVersion ( )

Check PHP version.

There are two bugs in PDO_pgsql affecting Drupal:

  • in versions < 5.2.7, PDO_pgsql refuses to insert an empty string into a NOT NULL BLOB column. See: http://bugs.php.net/bug.php?id=46249
  • in versions < 5.2.11 and < 5.3.1 that prevents inserting integer values into numeric columns that exceed the PHP_INT_MAX value. See: http://bugs.php.net/bug.php?id=48924

Definition at line 76 of file install.inc.

References DatabaseTasks\fail(), and st().

initializeDatabase ( )

Make PostgreSQL Drupal friendly.

Definition at line 139 of file install.inc.

References db_query(), DatabaseTasks\fail(), DatabaseTasks\pass(), and st().

minimumVersion ( )

Definition at line 37 of file install.inc.

name ( )

Definition at line 33 of file install.inc.

References st().

Referenced by checkEncoding().

Member Data Documentation

$pdoDriver = 'pgsql'
protected

Definition at line 12 of file install.inc.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DatabaseTasks_sqlite Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Attributes | List of all members
DatabaseTasks_sqlite Class Reference
Inheritance diagram for DatabaseTasks_sqlite:
DatabaseTasks

Public Member Functions

name ()
minimumVersion ()
getFormOptions ($database)
validateDatabaseSettings ($database)
- Public Member Functions inherited from DatabaseTasks
installable ()
name ()
minimumVersion ()
runTasks ()
getFormOptions ($database)
validateDatabaseSettings ($database)

Protected Attributes

$pdoDriver = 'sqlite'
- Protected Attributes inherited from DatabaseTasks
$tasks
$results = array()

Additional Inherited Members

- Protected Member Functions inherited from DatabaseTasks
hasPdoDriver ()
fail ($message)
pass ($message)
connect ()
runTestQuery ($query, $pass, $fail, $fatal=FALSE)
checkEngineVersion ()

Detailed Description

Definition at line 8 of file install.inc.

Member Function Documentation

getFormOptions ( $database )

Definition at line 24 of file install.inc.

References conf_path(), drupal_install_profile_distribution_name(), and st().

minimumVersion ( )

Minimum engine version.

Definition at line 20 of file install.inc.

name ( )

Definition at line 11 of file install.inc.

References st().

validateDatabaseSettings ( $database )

Definition at line 38 of file install.inc.

References st().

Member Data Documentation

$pdoDriver = 'sqlite'
protected

Definition at line 9 of file install.inc.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DefaultMailSystem Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
DefaultMailSystem Class Reference
Inheritance diagram for DefaultMailSystem:
MailSystemInterface TestingMailSystem

Public Member Functions

format (array $message)
mail (array $message)

Detailed Description

The default Drupal mail backend using PHP's mail function.

Definition at line 11 of file system.mail.inc.

Member Function Documentation

format ( array $message )

Concatenate and wrap the e-mail body for plain-text mails.

Parameters
$message A message array, as described in hook_mail_alter().
Returns
The formatted $message.

Implements MailSystemInterface.

Definition at line 21 of file system.mail.inc.

References drupal_html_to_text(), and drupal_wrap_mail().

mail ( array $message )

Send an e-mail message, using Drupal variables and default settings.

See Also
http://php.net/manual/function.mail.php
drupal_mail()
Parameters
$message A message array, as described in hook_mail_alter().
Returns
TRUE if the mail was successfully accepted, otherwise FALSE.

Implements MailSystemInterface.

Definition at line 42 of file system.mail.inc.

References $name, $value, MAIL_LINE_ENDINGS, mime_header_encode(), and variable_get().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalCacheArray Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DrupalCacheArray Class Reference
Inheritance diagram for DrupalCacheArray:
SchemaCache

Public Member Functions

__construct ($cid, $bin)
offsetExists ($offset)
offsetGet ($offset)
offsetSet ($offset, $value)
offsetUnset ($offset)
__destruct ()
__construct ($cid, $bin)
initializeRegistry ()
offsetExists ($offset)
offsetGet ($offset)
resolveCacheMiss ($offset)
set ($data, $lock=TRUE)

Protected Member Functions

persist ($offset, $persist=TRUE)
resolveCacheMiss ($offset)
set ($data, $lock=TRUE)

Protected Attributes

$cid
$bin
$keysToPersist = array()
$storage = array()
$persistable
$completeRegistry

Detailed Description

Provides a caching wrapper to be used in place of large array structures.

This class should be extended by systems that need to cache large amounts of data and have it represented as an array to calling functions. These arrays can become very large, so ArrayAccess is used to allow different strategies to be used for caching internally (lazy loading, building caches over time etc.). This can dramatically reduce the amount of data that needs to be loaded from cache backends on each request, and memory usage from static caches of that same data.

Note that array_* functions do not work with ArrayAccess. Systems using DrupalCacheArray should use this only internally. If providing API functions that return the full array, this can be cached separately or returned directly. However since DrupalCacheArray holds partial content by design, it should be a normal PHP array or otherwise contain the full structure.

Note also that due to limitations in PHP prior to 5.3.4, it is impossible to write directly to the contents of nested arrays contained in this object. Only writes to the top-level array elements are possible. So if you previously had set $object['foo'] = array(1, 2, 'bar' => 'baz'), but later want to change the value of 'bar' from 'baz' to 'foobar', you cannot do so a targeted write like $object['foo']['bar'] = 'foobar'. Instead, you must overwrite the entire top-level 'foo' array with the entire set of new values: $object['foo'] = array(1, 2, 'bar' => 'foobar'). Due to this same limitation, attempts to create references to any contained data, nested or otherwise, will fail silently. So $var = &$object['foo'] will not throw an error, and $var will be populated with the contents of $object['foo'], but that data will be passed by value, not reference. For more information on the PHP limitation, see the note in the official PHP documentation at· http://php.net/manual/arrayaccess.offsetget.php on ArrayAccess::offsetGet().

By default, the class accounts for caches where calling functions might request keys in the array that won't exist even after a cache rebuild. This prevents situations where a cache rebuild would be triggered over and over due to a 'missing' item. These cases are stored internally as a value of NULL. This means that the offsetGet() and offsetExists() methods must be overridden if caching an array where the top level values can legitimately be NULL, and where $object->offsetExists() needs to correctly return (equivalent to array_key_exists() vs. isset()). This should not be necessary in the majority of cases.

Classes extending this class must override at least the resolveCacheMiss() method to have a working implementation.

offsetSet() is not overridden by this class by default. In practice this means that assigning an offset via arrayAccess will only apply while the object is in scope and will not be written back to the persistent cache. This follows a similar pattern to static vs. persistent caching in procedural code. Extending classes may wish to alter this behavior, for example by overriding offsetSet() and adding an automatic call to persist().

See Also
SchemaCache

Builds the run-time theme registry.

Extends DrupalCacheArray to allow the theme registry to be accessed as a complete registry, while internally caching only the parts of the registry that are actually in use on the site. On cache misses the complete theme registry is loaded and used to update the run-time cache.

Definition at line 306 of file bootstrap.inc.

Constructor & Destructor Documentation

__construct | ( | $cid,
 |  | $bin
 | ) |

Definition at line 381 of file theme.inc.

References cache_get(), and module_load_all().

Member Function Documentation

initializeRegistry ( )

Initializes the full theme registry.

Returns
An array with the keys of the full theme registry, but the values initialized to NULL.

Definition at line 410 of file theme.inc.

References theme_get_registry().

offsetExists ( $offset )

Definition at line 416 of file theme.inc.

offsetGet ( $offset )

Definition at line 424 of file theme.inc.

resolveCacheMiss ( $offset )

Definition at line 436 of file theme.inc.

References theme_get_registry().

set | ( | $data,
 |  | $lock = TRUE
 | ) |

Definition at line 447 of file theme.inc.

References cache_get(), cache_set(), lock_acquire(), and lock_release().

Member Data Documentation

$completeRegistry
protected

The complete theme registry array.

Definition at line 379 of file theme.inc.

$persistable
protected

Whether the partial registry can be persisted to the cache.

This is only allowed if all modules and the request method is GET. theme() should be very rarely called on POST requests and this avoids polluting the runtime cache.

Definition at line 374 of file theme.inc.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalCacheInterface Interface Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
DrupalCacheInterface Interface Reference
Inheritance diagram for DrupalCacheInterface:
DrupalDatabaseCache DrupalFakeCache DrupalFakeCache

Public Member Functions

get ($cid)
getMultiple (&$cids)
set ($cid, $data, $expire=CACHE_PERMANENT)
clear ($cid=NULL, $wildcard=FALSE)
isEmpty ()

Detailed Description

Defines an interface for cache implementations.

All cache implementations have to implement this interface. DrupalDatabaseCache provides the default implementation, which can be consulted as an example.

To make Drupal use your implementation for a certain cache bin, you have to set a variable with the name of the cache bin as its key and the name of your class as its value. For example, if your implementation of DrupalCacheInterface was called MyCustomCache, the following line would make Drupal use it for the 'cache_page' bin:

* variable_set('cache_class_cache_page', 'MyCustomCache');
*

Additionally, you can register your cache implementation to be used by default for all cache bins by setting the variable 'cache_default_class' to the name of your implementation of the DrupalCacheInterface, e.g.

* variable_set('cache_default_class', 'MyCustomCache');
*

To implement a completely custom cache bin, use the same variable format:

* variable_set('cache_class_custom_bin', 'MyCustomCache');
*

To access your custom cache bin, specify the name of the bin when storing or retrieving cached data:

* cache_set($cid, $data, 'custom_bin', $expire);
* cache_get($cid, 'custom_bin');
*
See Also
_cache_get_object()
DrupalDatabaseCache

Definition at line 221 of file cache.inc.

Member Function Documentation

clear | ( | $cid = NULL,
 |  | $wildcard = FALSE
 | ) |

Expires data from the cache.

If called without arguments, expirable entries will be cleared from the cache_page and cache_block bins.

Parameters
$cid | If set, the cache ID or an array of cache IDs. Otherwise, all cache entries that can expire are deleted. The $wildcard argument will be ignored if set to NULL.
$wildcard | If TRUE, the $cid argument must contain a string value and cache IDs starting with $cid are deleted in addition to the exact cache ID specified by $cid. If $wildcard is TRUE and $cid is '*', the entire cache is emptied.

Implemented in DrupalDatabaseCache, and DrupalFakeCache.

get ( $cid )

Returns data from the persistent cache.

Data may be stored as either plain text or as serialized data. cache_get() will automatically return unserialized objects and arrays.

Parameters
$cid The cache ID of the data to retrieve.
Returns
The cache or FALSE on failure.

Implemented in DrupalDatabaseCache, and DrupalFakeCache.

getMultiple ( & $cids )

Returns data from the persistent cache when given an array of cache IDs.

Parameters
$cids An array of cache IDs for the data to retrieve. This is passed by reference, and will have the IDs successfully returned from cache removed.
Returns
An array of the items successfully returned from cache indexed by cid.

Implemented in DrupalDatabaseCache, and DrupalFakeCache.

isEmpty ( )

Checks if a cache bin is empty.

A cache bin is considered empty if it does not contain any valid data for any cache ID.

Returns
TRUE if the cache bin specified is empty.

Implemented in DrupalDatabaseCache, and DrupalFakeCache.

set | ( | $cid,
 |  | $data,
 |  | $expire = CACHE_PERMANENT
 | ) |

Stores data in the persistent cache.

Parameters
$cid | The cache ID of the data to store.
$data | The data to store in the cache. Complex data types will be automatically serialized before insertion. Strings will be stored as plain text and not serialized.
$expire One of the following values:
  • CACHE_PERMANENT: Indicates that the item should never be removed unless explicitly told to using cache_clear_all() with a cache ID.
  • CACHE_TEMPORARY: Indicates that the item should be removed at the next general cache wipe.
  • A Unix timestamp: Indicates that the item should be kept at least until the given time, after which it behaves like CACHE_TEMPORARY.

Implemented in DrupalDatabaseCache, and DrupalFakeCache.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalDatabaseCache Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DrupalDatabaseCache Class Reference
Inheritance diagram for DrupalDatabaseCache:
DrupalCacheInterface DrupalFakeCache

Public Member Functions

__construct ($bin)
get ($cid)
getMultiple (&$cids)
set ($cid, $data, $expire=CACHE_PERMANENT)
clear ($cid=NULL, $wildcard=FALSE)
isEmpty ()
isValidBin ()

Protected Member Functions

garbageCollection ()
prepareItem ($cache)

Protected Attributes

$bin

Detailed Description

Defines a default cache implementation.

This is Drupal's default cache implementation. It uses the database to store cached data. Each cache bin corresponds to a database table by the same name.

Definition at line 307 of file cache.inc.

Constructor & Destructor Documentation

__construct ( $bin )

Constructs a DrupalDatabaseCache object.

Parameters
$bin The cache bin for which the object is created.

Definition at line 316 of file cache.inc.

References $bin.

Member Function Documentation

clear | ( | $cid = NULL,
 |  | $wildcard = FALSE
 | ) |

Implements DrupalCacheInterface::clear().

Implements DrupalCacheInterface.

Definition at line 472 of file cache.inc.

References $bin, CACHE_PERMANENT, db_delete(), db_like(), db_truncate(), isValidBin(), REQUEST_TIME, t(), variable_get(), and variable_set().

garbageCollection ( )
protected

Garbage collection for get() and getMultiple().

Parameters
$bin The bin being requested.

Definition at line 368 of file cache.inc.

References $bin, CACHE_PERMANENT, db_delete(), REQUEST_TIME, variable_get(), and variable_set().

Referenced by getMultiple(), and isEmpty().

get ( $cid )

Implements DrupalCacheInterface::get().

Implements DrupalCacheInterface.

Definition at line 323 of file cache.inc.

References getMultiple().

getMultiple ( & $cids )

Implements DrupalCacheInterface::getMultiple().

Implements DrupalCacheInterface.

Definition at line 332 of file cache.inc.

References db_escape_table(), db_query(), garbageCollection(), and prepareItem().

Referenced by get().

isEmpty ( )

Implements DrupalCacheInterface::isEmpty().

Implements DrupalCacheInterface.

Definition at line 545 of file cache.inc.

References db_select(), and garbageCollection().

isValidBin ( )

Checks if $this->bin represents a valid cache table.

This check is required to ensure that non-cache tables are not truncated accidentally when calling cache_clear_all().

Returns
boolean

Definition at line 563 of file cache.inc.

References drupal_get_schema().

Referenced by clear().

prepareItem ( $cache )
protected

Prepares a cached item.

Checks that items are either permanent or did not expire, and unserializes data as appropriate.

Parameters
$cache An item loaded from cache_get() or cache_get_multiple().
Returns
The item with data unserialized as appropriate or FALSE if there is no valid item to load.

Definition at line 417 of file cache.inc.

References CACHE_PERMANENT, and variable_get().

Referenced by getMultiple().

set | ( | $cid,
 |  | $data,
 |  | $expire = CACHE_PERMANENT
 | ) |

Implements DrupalCacheInterface::set().

Implements DrupalCacheInterface.

Definition at line 443 of file cache.inc.

References db_merge(), and REQUEST_TIME.

Member Data Documentation

$bin
protected

Definition at line 308 of file cache.inc.

Referenced by __construct(), clear(), and garbageCollection().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalDefaultEntityController Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DrupalDefaultEntityController Class Reference
Inheritance diagram for DrupalDefaultEntityController:
DrupalEntityControllerInterface CommentController EntityExampleBasicController NodeController TaxonomyTermController TaxonomyVocabularyController UserController

Public Member Functions

__construct ($entityType)
resetCache (array $ids=NULL)
load ($ids=array(), $conditions=array())

Protected Member Functions

buildQuery ($ids, $conditions=array(), $revision_id=FALSE)
attachLoad (&$queried_entities, $revision_id=FALSE)
cacheGet ($ids, $conditions=array())
cacheSet ($entities)

Protected Attributes

$entityCache
$entityType
$entityInfo
$hookLoadArguments
$idKey
$revisionKey
$revisionTable
$cache

Detailed Description

Default implementation of DrupalEntityControllerInterface.

This class can be used as-is by most simple entity types. Entity types requiring special handling can extend the class.

Definition at line 46 of file entity.inc.

Constructor & Destructor Documentation

__construct ( $entityType )

Constructor: sets basic variables.

Parameters
$entityType The entity type for which the instance is created.

Definition at line 118 of file entity.inc.

References $entityType, and entity_get_info().

Member Function Documentation

attachLoad | ( | & | $queried_entities,
 |  |  | $revision_id = FALSE
 | ) |  |
protected

Attaches data to entities upon loading.

This will attach fields, if the entity is fieldable. It calls hook_entity_load() for modules which need to add data to all entities. It also calls hook_TYPE_load() on the loaded entities. For example hook_node_load() or hook_user_load(). If your hook_TYPE_load() expects special parameters apart from the queried entities, you can set $this->hookLoadArguments prior to calling the method. See NodeController::attachLoad() for an example.

Parameters
$queried_entities | Associative array of query results, keyed on the entity ID.
$revision_id | ID of the revision that was loaded, or FALSE if the most current revision was loaded.

Definition at line 309 of file entity.inc.

References $module, field_attach_load(), field_attach_load_revision(), and module_implements().

Referenced by load().

buildQuery | ( | $ids,
 |  | $conditions = array(),
 |  | $revision_id = FALSE
 | ) |
protected

Builds the query to load the entity.

This has full revision support. For entities requiring special queries, the class can be extended, and the default query can be constructed by calling parent::buildQuery(). This is usually necessary when the object being loaded needs to be augmented with additional data from another table, such as loading node type into comments or vocabulary machine name into terms, however it can also support $conditions on different tables. See CommentController::buildQuery() or TaxonomyTermController::buildQuery() for examples.

Parameters
$ids | An array of entity IDs, or FALSE to load all entities.
$conditions | An array of conditions in the form 'field' => $value.
$revision_id | The ID of the revision to load, or FALSE if this query is asking for the most current revision(s).
Returns
SelectQuery A SelectQuery object for loading the entity.

Definition at line 247 of file entity.inc.

References $name, $value, db_select(), and drupal_map_assoc().

Referenced by load().

cacheGet | ( | $ids,
 |  | $conditions = array()
 | ) |
protected

Gets entities from the static cache.

Parameters
$ids | If not empty, return entities that match these IDs.
$conditions | If set, return entities that match all of these conditions.
Returns
Array of entities from the entity cache.

Definition at line 345 of file entity.inc.

Referenced by load().

cacheSet ( $entities )
protected

Stores entities in the static entity cache.

Parameters
$entities Entities to store in the cache.

Definition at line 378 of file entity.inc.

Referenced by load().

load | ( | $ids = array(),
 |  | $conditions = array()
 | ) |

Implements DrupalEntityControllerInterface::load().

Implements DrupalEntityControllerInterface.

Definition at line 155 of file entity.inc.

References $revisionKey, attachLoad(), buildQuery(), cacheGet(), and cacheSet().

resetCache ( array $ids = NULL )

Implements DrupalEntityControllerInterface::resetCache().

Implements DrupalEntityControllerInterface.

Definition at line 141 of file entity.inc.

Member Data Documentation

$cache
protected

Definition at line 110 of file entity.inc.

$entityCache
protected

Definition at line 53 of file entity.inc.

$entityInfo
protected

Definition at line 69 of file entity.inc.

$entityType
protected

Definition at line 60 of file entity.inc.

Referenced by __construct().

$hookLoadArguments
protected

Definition at line 78 of file entity.inc.

$idKey
protected

Definition at line 85 of file entity.inc.

$revisionKey
protected

Definition at line 94 of file entity.inc.

Referenced by load().

$revisionTable
protected

Definition at line 101 of file entity.inc.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalEntityControllerInterface Interface Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
DrupalEntityControllerInterface Interface Reference
Inheritance diagram for DrupalEntityControllerInterface:
DrupalDefaultEntityController EntityExampleBasicControllerInterface CommentController EntityExampleBasicController NodeController TaxonomyTermController TaxonomyVocabularyController UserController EntityExampleBasicController

Public Member Functions

resetCache (array $ids=NULL)
load ($ids=array(), $conditions=array())

Detailed Description

Interface for entity controller classes.

All entity controller classes specified via the 'controller class' key returned by hook_entity_info() or hook_entity_info_alter() have to implement this interface.

Most simple, SQL-based entity controllers will do better by extending DrupalDefaultEntityController instead of implementing this interface directly.

Definition at line 14 of file entity.inc.

Member Function Documentation

load | ( | $ids = array(),
 |  | $conditions = array()
 | ) |

Loads one or more entities.

Parameters
$ids | An array of entity IDs, or FALSE to load all entities.
$conditions | An array of conditions in the form 'field' => $value.
Returns
An array of entity objects indexed by their ids. When no results are found, an empty array is returned.

Implemented in DrupalDefaultEntityController.

resetCache ( array $ids = NULL )

Resets the internal, static entity cache.

Parameters
$ids (optional) If specified, the cache is reset for the entities with the given ids only.

Implemented in DrupalDefaultEntityController.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalFakeCache Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
DrupalFakeCache Class Reference
Inheritance diagram for DrupalFakeCache:
DrupalDatabaseCache DrupalCacheInterface DrupalCacheInterface

Public Member Functions

get ($cid)
getMultiple (&$cids)
set ($cid, $data, $expire=CACHE_PERMANENT)
clear ($cid=NULL, $wildcard=FALSE)
isEmpty ()
- Public Member Functions inherited from DrupalDatabaseCache
__construct ($bin)
get ($cid)
getMultiple (&$cids)
set ($cid, $data, $expire=CACHE_PERMANENT)
clear ($cid=NULL, $wildcard=FALSE)
isEmpty ()
isValidBin ()

Additional Inherited Members

- Protected Member Functions inherited from DrupalDatabaseCache
garbageCollection ()
prepareItem ($cache)
- Protected Attributes inherited from DrupalDatabaseCache
$bin

Detailed Description

Defines a stub cache implementation to be used during installation.

The stub implementation is needed when database access is not yet available. Because Drupal's caching system never requires that cached data be present, these stub functions can short-circuit the process and sidestep the need for any persistent storage. Obviously, using this cache implementation during normal operations would have a negative impact on performance.

Definition at line 17 of file cache-install.inc.

Member Function Documentation

clear | ( | $cid = NULL,
 |  | $wildcard = FALSE
 | ) |

Overrides DrupalDatabaseCache::clear().

Implements DrupalCacheInterface.

Definition at line 42 of file cache-install.inc.

get ( $cid )

Overrides DrupalDatabaseCache::get().

Implements DrupalCacheInterface.

Definition at line 22 of file cache-install.inc.

getMultiple ( & $cids )

Overrides DrupalDatabaseCache::getMultiple().

Implements DrupalCacheInterface.

Definition at line 29 of file cache-install.inc.

isEmpty ( )

Overrides DrupalDatabaseCache::isEmpty().

Implements DrupalCacheInterface.

Definition at line 71 of file cache-install.inc.

set | ( | $cid,
 |  | $data,
 |  | $expire = CACHE_PERMANENT
 | ) |

Overrides DrupalDatabaseCache::set().

Implements DrupalCacheInterface.

Definition at line 36 of file cache-install.inc.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalLocalStreamWrapper Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
DrupalLocalStreamWrapper Class Reference
Inheritance diagram for DrupalLocalStreamWrapper:
DrupalStreamWrapperInterface StreamWrapperInterface DrupalPrivateStreamWrapper DrupalPublicStreamWrapper DrupalTemporaryStreamWrapper

Public Member Functions

getDirectoryPath ()
setUri ($uri)
getUri ()
chmod ($mode)
realpath ()
stream_open ($uri, $mode, $options, &$opened_path)
stream_lock ($operation)
stream_read ($count)
stream_write ($data)
stream_eof ()
stream_seek ($offset, $whence)
stream_flush ()
stream_tell ()
stream_stat ()
stream_close ()
unlink ($uri)
rename ($from_uri, $to_uri)
dirname ($uri=NULL)
mkdir ($uri, $mode, $options)
rmdir ($uri, $options)
url_stat ($uri, $flags)
dir_opendir ($uri, $options)
dir_readdir ()
dir_rewinddir ()
dir_closedir ()
- Public Member Functions inherited from DrupalStreamWrapperInterface
getExternalUrl ()

Static Public Member Functions

static getMimeType ($uri, $mapping=NULL)

Public Attributes

$context
$handle = NULL

Protected Member Functions

getTarget ($uri=NULL)
getLocalPath ($uri=NULL)

Protected Attributes

$uri

Detailed Description

Drupal stream wrapper base class for local files.

This class provides a complete stream wrapper implementation. URIs such as "public://example.txt" are expanded to a normal filesystem path such as "sites/default/files/example.txt" and then PHP filesystem functions are invoked.

DrupalLocalStreamWrapper implementations need to implement at least the getDirectoryPath() and getExternalUrl() methods.

Definition at line 234 of file stream_wrappers.inc.

Member Function Documentation

chmod ( $mode )

Base implementation of chmod().

Implements DrupalStreamWrapperInterface.

Definition at line 343 of file stream_wrappers.inc.

References $output, and getLocalPath().

dir_closedir ( )

Support for closedir().

Returns
TRUE on success.
See Also
http://php.net/manual/streamwrapper.dir-closedir.php

Implements StreamWrapperInterface.

Definition at line 752 of file stream_wrappers.inc.

dir_opendir | ( | $uri,
 |  | $options
 | ) |

Support for opendir().

Parameters
$uri | A string containing the URI to the directory to open.
$options | Unknown (parameter is not documented in PHP Manual).
Returns
TRUE on success.
See Also
http://php.net/manual/streamwrapper.dir-opendir.php

Implements StreamWrapperInterface.

Definition at line 709 of file stream_wrappers.inc.

References $handle, $uri, and getLocalPath().

dir_readdir ( )

Support for readdir().

Returns
The next filename, or FALSE if there are no more files in the directory.
See Also
http://php.net/manual/streamwrapper.dir-readdir.php

Implements StreamWrapperInterface.

Definition at line 724 of file stream_wrappers.inc.

dir_rewinddir ( )

Support for rewinddir().

Returns
TRUE on success.
See Also
http://php.net/manual/streamwrapper.dir-rewinddir.php

Implements StreamWrapperInterface.

Definition at line 736 of file stream_wrappers.inc.

dirname ( $uri = NULL )

Gets the name of the directory from a given path.

This method is usually accessed through drupal_dirname(), which wraps around the PHP dirname() function because it does not support stream wrappers.

Parameters
$uri A URI or path.
Returns
A string containing the directory name.
See Also
drupal_dirname()

Implements DrupalStreamWrapperInterface.

Definition at line 600 of file stream_wrappers.inc.

References $uri, and getTarget().

Referenced by getLocalPath().

getDirectoryPath ( )
abstract

Gets the path that the wrapper is responsible for. : Review this method name in D8 per http://drupal.org/node/701358

Returns
String specifying the path.

Referenced by getLocalPath(), and mkdir().

getLocalPath ( $uri = NULL )
protected

Returns the canonical absolute path of the URI, if possible.

Parameters
string $uri (optional) The stream wrapper URI to be converted to a canonical absolute path. This may point to a directory or another type of file.
Returns
string|false If $uri is not set, returns the canonical absolute path of the URI previously set by the DrupalStreamWrapperInterface::setUri() function. If $uri is set and valid for this class, returns its canonical absolute path, as determined by the realpath() function. If $uri is set but not valid, returns FALSE.

Definition at line 372 of file stream_wrappers.inc.

References $uri, dirname(), drupal_basename(), getDirectoryPath(), getTarget(), and realpath().

Referenced by chmod(), dir_opendir(), mkdir(), realpath(), rename(), rmdir(), stream_open(), unlink(), and url_stat().

static getMimeType | ( | $uri,
 |  | $mapping = NULL
 | ) |
static

Base implementation of getMimeType().

Implements DrupalStreamWrapperInterface.

Definition at line 311 of file stream_wrappers.inc.

References $uri, drupal_basename(), DRUPAL_ROOT, and file_mimetype_mapping().

Referenced by file_get_mimetype().

getTarget ( $uri = NULL )
protected

Returns the local writable target of the resource within the stream.

This function should be used in place of calls to realpath() or similar functions when attempting to determine the location of a file. While functions like realpath() may return the location of a read-only file, this method may return a URI or path suitable for writing that is completely separate from the URI used for reading.

Parameters
$uri Optional URI.
Returns
Returns a string representing a location suitable for writing of a file, or FALSE if unable to write to the file such as with read-only streams.

Definition at line 297 of file stream_wrappers.inc.

References $uri.

Referenced by dirname(), DrupalPublicStreamWrapper\getExternalUrl(), DrupalPrivateStreamWrapper\getExternalUrl(), DrupalTemporaryStreamWrapper\getExternalUrl(), getLocalPath(), and mkdir().

getUri ( )

Base implementation of getUri().

Implements DrupalStreamWrapperInterface.

Definition at line 277 of file stream_wrappers.inc.

References $uri.

mkdir | ( | $uri,
 |  | $mode,
 |  | $options
 | ) |

Support for mkdir().

Parameters
$uri | A string containing the URI to the directory to create.
$mode | Permission flags - see mkdir().
$options | A bit mask of STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE.
Returns
TRUE if directory was successfully created.
See Also
http://php.net/manual/streamwrapper.mkdir.php

Implements StreamWrapperInterface.

Definition at line 627 of file stream_wrappers.inc.

References $uri, getDirectoryPath(), getLocalPath(), and getTarget().

realpath ( )

Base implementation of realpath().

Implements DrupalStreamWrapperInterface.

Definition at line 354 of file stream_wrappers.inc.

References getLocalPath().

Referenced by getLocalPath().

rename | ( | $from_uri,
 |  | $to_uri
 | ) |

Support for rename().

Parameters
$from_uri,The | URI to the file to rename.
$to_uri | The new URI for file.
Returns
TRUE if file was successfully renamed.
See Also
http://php.net/manual/streamwrapper.rename.php

Implements StreamWrapperInterface.

Definition at line 581 of file stream_wrappers.inc.

References getLocalPath().

rmdir | ( | $uri,
 |  | $options
 | ) |

Support for rmdir().

Parameters
$uri | A string containing the URI to the directory to delete.
$options | A bit mask of STREAM_REPORT_ERRORS.
Returns
TRUE if directory was successfully removed.
See Also
http://php.net/manual/streamwrapper.rmdir.php

Implements StreamWrapperInterface.

Definition at line 659 of file stream_wrappers.inc.

References $uri, drupal_rmdir(), and getLocalPath().

setUri ( $uri )

Base implementation of setUri().

Implements DrupalStreamWrapperInterface.

Definition at line 270 of file stream_wrappers.inc.

References $uri.

stream_close ( )

Support for fclose().

Returns
TRUE if stream was successfully closed.
See Also
http://php.net/manual/streamwrapper.stream-close.php

Implements StreamWrapperInterface.

Definition at line 548 of file stream_wrappers.inc.

stream_eof ( )

Support for feof().

Returns
TRUE if end-of-file has been reached.
See Also
http://php.net/manual/streamwrapper.stream-eof.php

Implements StreamWrapperInterface.

Definition at line 480 of file stream_wrappers.inc.

stream_flush ( )

Support for fflush().

Returns
TRUE if data was successfully stored (or there was no data to store).
See Also
http://php.net/manual/streamwrapper.stream-flush.php

Implements StreamWrapperInterface.

Definition at line 511 of file stream_wrappers.inc.

stream_lock ( $operation )

Support for flock().

Parameters
$operation One of the following:
  • LOCK_SH to acquire a shared lock (reader).
  • LOCK_EX to acquire an exclusive lock (writer).
  • LOCK_UN to release a lock (shared or exclusive).
  • LOCK_NB if you don't want flock() to block while locking (not supported on Windows).
Returns
Always returns TRUE at the present time.
See Also
http://php.net/manual/streamwrapper.stream-lock.php

Implements StreamWrapperInterface.

Definition at line 434 of file stream_wrappers.inc.

stream_open | ( |  | $uri,
 |  |  | $mode,
 |  |  | $options,
 |  | & | $opened_path
 | ) |  |

Support for fopen(), file_get_contents(), file_put_contents() etc.

Parameters
$uri | A string containing the URI to the file to open.
$mode | The file mode ("r", "wb" etc.).
$options | A bit mask of STREAM_USE_PATH and STREAM_REPORT_ERRORS.
$opened_path | A string containing the path actually opened.
Returns
Returns TRUE if file was opened successfully.
See Also
http://php.net/manual/streamwrapper.stream-open.php

Implements StreamWrapperInterface.

Definition at line 406 of file stream_wrappers.inc.

References $handle, $uri, and getLocalPath().

stream_read ( $count )

Support for fread(), file_get_contents() etc.

Parameters
$count Maximum number of bytes to be read.
Returns
The string that was read, or FALSE in case of an error.
See Also
http://php.net/manual/streamwrapper.stream-read.php

Implements StreamWrapperInterface.

Definition at line 453 of file stream_wrappers.inc.

stream_seek | ( | $offset,
 |  | $whence
 | ) |

Support for fseek().

Parameters
$offset | The byte offset to got to.
$whence | SEEK_SET, SEEK_CUR, or SEEK_END.
Returns
TRUE on success.
See Also
http://php.net/manual/streamwrapper.stream-seek.php

Implements StreamWrapperInterface.

Definition at line 497 of file stream_wrappers.inc.

stream_stat ( )

Support for fstat().

Returns
An array with file status, or FALSE in case of an error - see fstat() for a description of this array.
See Also
http://php.net/manual/streamwrapper.stream-stat.php

Implements StreamWrapperInterface.

Definition at line 536 of file stream_wrappers.inc.

stream_tell ( )

Support for ftell().

Returns
The current offset in bytes from the beginning of file.
See Also
http://php.net/manual/streamwrapper.stream-tell.php

Implements StreamWrapperInterface.

Definition at line 523 of file stream_wrappers.inc.

stream_write ( $data )

Support for fwrite(), file_put_contents() etc.

Parameters
$data The string to be written.
Returns
The number of bytes written (integer).
See Also
http://php.net/manual/streamwrapper.stream-write.php

Implements StreamWrapperInterface.

Definition at line 468 of file stream_wrappers.inc.

unlink ( $uri )

Support for unlink().

Parameters
$uri A string containing the URI to the resource to delete.
Returns
TRUE if resource was successfully deleted.
See Also
http://php.net/manual/streamwrapper.unlink.php

Implements StreamWrapperInterface.

Definition at line 563 of file stream_wrappers.inc.

References $uri, drupal_unlink(), and getLocalPath().

url_stat | ( | $uri,
 |  | $flags
 | ) |

Support for stat().

Parameters
$uri | A string containing the URI to get information about.
$flags | A bit mask of STREAM_URL_STAT_LINK and STREAM_URL_STAT_QUIET.
Returns
An array with file status, or FALSE in case of an error - see fstat() for a description of this array.
See Also
http://php.net/manual/streamwrapper.url-stat.php

Implements StreamWrapperInterface.

Definition at line 683 of file stream_wrappers.inc.

References $uri, and getLocalPath().

Member Data Documentation

$context

Definition at line 240 of file stream_wrappers.inc.

$handle = NULL

Definition at line 247 of file stream_wrappers.inc.

Referenced by dir_opendir(), and stream_open().

$uri
protected

Definition at line 256 of file stream_wrappers.inc.

Referenced by dir_opendir(), dirname(), getLocalPath(), getMimeType(), getTarget(), getUri(), mkdir(), rmdir(), setUri(), stream_open(), unlink(), and url_stat().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalPrivateStreamWrapper Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
DrupalPrivateStreamWrapper Class Reference
Inheritance diagram for DrupalPrivateStreamWrapper:
DrupalLocalStreamWrapper DrupalStreamWrapperInterface StreamWrapperInterface

Public Member Functions

getDirectoryPath ()
getExternalUrl ()
- Public Member Functions inherited from DrupalLocalStreamWrapper
getDirectoryPath ()
setUri ($uri)
getUri ()
chmod ($mode)
realpath ()
stream_open ($uri, $mode, $options, &$opened_path)
stream_lock ($operation)
stream_read ($count)
stream_write ($data)
stream_eof ()
stream_seek ($offset, $whence)
stream_flush ()
stream_tell ()
stream_stat ()
stream_close ()
unlink ($uri)
rename ($from_uri, $to_uri)
dirname ($uri=NULL)
mkdir ($uri, $mode, $options)
rmdir ($uri, $options)
url_stat ($uri, $flags)
dir_opendir ($uri, $options)
dir_readdir ()
dir_rewinddir ()
dir_closedir ()

Additional Inherited Members

- Static Public Member Functions inherited from DrupalLocalStreamWrapper
static getMimeType ($uri, $mapping=NULL)
- Public Attributes inherited from DrupalLocalStreamWrapper
$context
$handle = NULL
- Protected Member Functions inherited from DrupalLocalStreamWrapper
getTarget ($uri=NULL)
getLocalPath ($uri=NULL)
- Protected Attributes inherited from DrupalLocalStreamWrapper
$uri

Detailed Description

Drupal private (private://) stream wrapper class.

Provides support for storing privately accessible files with the Drupal file interface.

Definition at line 792 of file stream_wrappers.inc.

Member Function Documentation

getDirectoryPath ( )

Implements abstract public function getDirectoryPath()

Definition at line 796 of file stream_wrappers.inc.

References variable_get().

getExternalUrl ( )

Overrides getExternalUrl().

Return the HTML URI of a private file.

Implements DrupalStreamWrapperInterface.

Definition at line 805 of file stream_wrappers.inc.

References DrupalLocalStreamWrapper\getTarget(), and url().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalPublicStreamWrapper Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
DrupalPublicStreamWrapper Class Reference
Inheritance diagram for DrupalPublicStreamWrapper:
DrupalLocalStreamWrapper DrupalStreamWrapperInterface StreamWrapperInterface

Public Member Functions

getDirectoryPath ()
getExternalUrl ()
- Public Member Functions inherited from DrupalLocalStreamWrapper
getDirectoryPath ()
setUri ($uri)
getUri ()
chmod ($mode)
realpath ()
stream_open ($uri, $mode, $options, &$opened_path)
stream_lock ($operation)
stream_read ($count)
stream_write ($data)
stream_eof ()
stream_seek ($offset, $whence)
stream_flush ()
stream_tell ()
stream_stat ()
stream_close ()
unlink ($uri)
rename ($from_uri, $to_uri)
dirname ($uri=NULL)
mkdir ($uri, $mode, $options)
rmdir ($uri, $options)
url_stat ($uri, $flags)
dir_opendir ($uri, $options)
dir_readdir ()
dir_rewinddir ()
dir_closedir ()

Additional Inherited Members

- Static Public Member Functions inherited from DrupalLocalStreamWrapper
static getMimeType ($uri, $mapping=NULL)
- Public Attributes inherited from DrupalLocalStreamWrapper
$context
$handle = NULL
- Protected Member Functions inherited from DrupalLocalStreamWrapper
getTarget ($uri=NULL)
getLocalPath ($uri=NULL)
- Protected Attributes inherited from DrupalLocalStreamWrapper
$uri

Detailed Description

Drupal public (public://) stream wrapper class.

Provides support for storing publicly accessible files with the Drupal file interface.

Definition at line 766 of file stream_wrappers.inc.

Member Function Documentation

getDirectoryPath ( )

Implements abstract public function getDirectoryPath()

Definition at line 770 of file stream_wrappers.inc.

References conf_path(), and variable_get().

getExternalUrl ( )

Overrides getExternalUrl().

Return the HTML URI of a public file.

Implements DrupalStreamWrapperInterface.

Definition at line 779 of file stream_wrappers.inc.

References drupal_encode_path(), and DrupalLocalStreamWrapper\getTarget().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalStreamWrapperInterface Interface Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Static Public Member Functions | List of all members
DrupalStreamWrapperInterface Interface Reference
Inheritance diagram for DrupalStreamWrapperInterface:
StreamWrapperInterface DrupalLocalStreamWrapper FileExampleSessionStreamWrapper DrupalPrivateStreamWrapper DrupalPublicStreamWrapper DrupalTemporaryStreamWrapper

Public Member Functions

setUri ($uri)
getUri ()
getExternalUrl ()
chmod ($mode)
realpath ()
dirname ($uri=NULL)
- Public Member Functions inherited from StreamWrapperInterface
stream_open ($uri, $mode, $options, &$opened_url)
stream_close ()
stream_lock ($operation)
stream_read ($count)
stream_write ($data)
stream_eof ()
stream_seek ($offset, $whence)
stream_flush ()
stream_tell ()
stream_stat ()
unlink ($uri)
rename ($from_uri, $to_uri)
mkdir ($uri, $mode, $options)
rmdir ($uri, $options)
url_stat ($uri, $flags)
dir_opendir ($uri, $options)
dir_readdir ()
dir_rewinddir ()
dir_closedir ()

Static Public Member Functions

static getMimeType ($uri, $mapping=NULL)

Detailed Description

Drupal stream wrapper extension.

Extend the StreamWrapperInterface with methods expected by Drupal stream wrapper classes.

Definition at line 126 of file stream_wrappers.inc.

Member Function Documentation

chmod ( $mode )

Changes permissions of the resource.

PHP lacks this functionality and it is not part of the official stream wrapper interface. This is a custom implementation for Drupal.

Parameters
$mode Integer value for the permissions. Consult PHP chmod() documentation for more information.
Returns
Returns TRUE on success or FALSE on failure.

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

dirname ( $uri = NULL )

Gets the name of the directory from a given path.

This method is usually accessed through drupal_dirname(), which wraps around the normal PHP dirname() function, which does not support stream wrappers.

Parameters
$uri An optional URI.
Returns
A string containing the directory name, or FALSE if not applicable.
See Also
drupal_dirname()

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

getExternalUrl ( )

Returns a web accessible URL for the resource.

This function should return a URL that can be embedded in a web page and accessed from a browser. For example, the external URL of "youtube://xIpLd0WQKCY" might be "http://www.youtube.com/watch?v=xIpLd0WQKCY".

Returns
Returns a string containing a web accessible URL for the resource.

Implemented in DrupalTemporaryStreamWrapper, DrupalPrivateStreamWrapper, DrupalPublicStreamWrapper, and FileExampleSessionStreamWrapper.

static getMimeType | ( | $uri,
 |  | $mapping = NULL
 | ) |
static

Returns the MIME type of the resource.

Parameters
$uri The URI, path, or filename.
$mapping An optional map of extensions to their mimetypes, in the form:
  • 'mimetypes': a list of mimetypes, keyed by an identifier,
  • 'extensions': the mapping itself, an associative array in which the key is the extension and the value is the mimetype identifier.
Returns
Returns a string containing the MIME type of the resource.

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

getUri ( )

Returns the stream resource URI.

Returns
Returns the current URI of the instance.

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

realpath ( )

Returns canonical, absolute path of the resource.

Implementation placeholder. PHP's realpath() does not support stream wrappers. We provide this as a default so that individual wrappers may implement their own solutions.

Returns
Returns a string with absolute pathname on success (implemented by core wrappers), or FALSE on failure or if the registered wrapper does not provide an implementation.

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

setUri ( $uri )

Set the absolute stream resource URI.

This allows you to set the URI. Generally is only called by the factory method.

Parameters
$uri A string containing the URI that should be used for this instance.

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalTemporaryStreamWrapper Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
DrupalTemporaryStreamWrapper Class Reference
Inheritance diagram for DrupalTemporaryStreamWrapper:
DrupalLocalStreamWrapper DrupalStreamWrapperInterface StreamWrapperInterface

Public Member Functions

getDirectoryPath ()
getExternalUrl ()
- Public Member Functions inherited from DrupalLocalStreamWrapper
getDirectoryPath ()
setUri ($uri)
getUri ()
chmod ($mode)
realpath ()
stream_open ($uri, $mode, $options, &$opened_path)
stream_lock ($operation)
stream_read ($count)
stream_write ($data)
stream_eof ()
stream_seek ($offset, $whence)
stream_flush ()
stream_tell ()
stream_stat ()
stream_close ()
unlink ($uri)
rename ($from_uri, $to_uri)
dirname ($uri=NULL)
mkdir ($uri, $mode, $options)
rmdir ($uri, $options)
url_stat ($uri, $flags)
dir_opendir ($uri, $options)
dir_readdir ()
dir_rewinddir ()
dir_closedir ()

Additional Inherited Members

- Static Public Member Functions inherited from DrupalLocalStreamWrapper
static getMimeType ($uri, $mapping=NULL)
- Public Attributes inherited from DrupalLocalStreamWrapper
$context
$handle = NULL
- Protected Member Functions inherited from DrupalLocalStreamWrapper
getTarget ($uri=NULL)
getLocalPath ($uri=NULL)
- Protected Attributes inherited from DrupalLocalStreamWrapper
$uri

Detailed Description

Drupal temporary (temporary://) stream wrapper class.

Provides support for storing temporarily accessible files with the Drupal file interface.

Extends DrupalPublicStreamWrapper.

Definition at line 819 of file stream_wrappers.inc.

Member Function Documentation

getDirectoryPath ( )

Implements abstract public function getDirectoryPath()

Definition at line 823 of file stream_wrappers.inc.

References file_directory_temp(), and variable_get().

getExternalUrl ( )

Overrides getExternalUrl().

Implements DrupalStreamWrapperInterface.

Definition at line 830 of file stream_wrappers.inc.

References DrupalLocalStreamWrapper\getTarget(), and url().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalTestCase Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
DrupalTestCase Class Reference
Inheritance diagram for DrupalTestCase:
DrupalUnitTestCase DrupalWebTestCase

Public Member Functions

__construct ($test_id=NULL)
run (array $methods=array())
errorHandler ($severity, $message, $file=NULL, $line=NULL)

Static Public Member Functions

static | insertAssert ($test_id, $test_class, $status, $message= '', $group= 'Other', array $caller=array())
static | deleteAssert ($message_id)
static | randomString ($length=8)
static | randomName ($length=8)
static | generatePermutations ($parameters)

Public Attributes

$results

Protected Member Functions

assert ($status, $message= '', $group= 'Other', array $caller=NULL)
getAssertionCall ()
assertTrue ($value, $message= '', $group= 'Other')
assertFalse ($value, $message= '', $group= 'Other')
assertNull ($value, $message= '', $group= 'Other')
assertNotNull ($value, $message= '', $group= 'Other')
assertEqual ($first, $second, $message= '', $group= 'Other')
assertNotEqual ($first, $second, $message= '', $group= 'Other')
assertIdentical ($first, $second, $message= '', $group= 'Other')
assertNotIdentical ($first, $second, $message= '', $group= 'Other')
pass ($message=NULL, $group= 'Other')
fail ($message=NULL, $group= 'Other')
error ($message= '', $group= 'Other', array $caller=NULL)
verbose ($message)
exceptionHandler ($exception)

Protected Attributes

$testId
$databasePrefix = NULL
$originalFileDirectory = NULL
$timeLimit = 500
$assertions = array()
$skipClasses = array(__CLASS__ => TRUE)
$setup = FALSE
$setupDatabasePrefix = FALSE
$setupEnvironment = FALSE

Detailed Description

Base class for Drupal tests.

Do not extend this class, use one of the subclasses in this file.

Definition at line 20 of file drupal_web_test_case.php.

Constructor & Destructor Documentation

__construct ( $test_id = NULL )

Constructor for DrupalTestCase.

Parameters
$test_id Tests with the same id are reported together.

Definition at line 98 of file drupal_web_test_case.php.

Member Function Documentation

assert | ( |  | $status,
 |  |  | $message = '',
 |  |  | $group = 'Other',
 |  | array | $caller = NULL
 | ) |  |
protected

Internal helper: stores the assert.

Parameters
$status | Can be 'pass', 'fail', 'exception'. TRUE is a synonym for 'pass', FALSE for 'fail'.
$message | The message string.
$group | Which group this assert belongs to.
$caller | By default, the assert comes from a function whose name starts with 'test'. Instead, you can specify where this assert originates from by passing in an associative array as $caller. Key 'file' is the name of the source file, 'line' is the line number and 'function' is the caller function itself.

Definition at line 119 of file drupal_web_test_case.php.

References getAssertionCall(), and Database\getConnection().

Referenced by assertEqual(), assertFalse(), assertIdentical(), DrupalWebTestCase\assertLink(), DrupalWebTestCase\assertLinkByHref(), DrupalWebTestCase\assertNoDuplicateIds(), DrupalWebTestCase\assertNoLink(), DrupalWebTestCase\assertNoLinkByHref(), DrupalWebTestCase\assertNoPattern(), DrupalWebTestCase\assertNoRaw(), assertNotEqual(), assertNotIdentical(), assertNotNull(), assertNull(), DrupalWebTestCase\assertPattern(), DrupalWebTestCase\assertRaw(), DrupalWebTestCase\assertTextHelper(), assertTrue(), DrupalWebTestCase\assertUniqueTextHelper(), error(), fail(), and pass().

assertEqual | ( | $first,
 |  | $second,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Check to see if two values are equal.

Parameters
$first | The first value to check.
$second | The second value to check.
$message | The message to display along with the assertion.
$group | The type of assertion - examples are "Browser", "PHP".
Returns
TRUE if the assertion succeeded, FALSE otherwise.

Definition at line 329 of file drupal_web_test_case.php.

References assert(), and t().

Referenced by DrupalWebTestCase\assertTitle(), DrupalWebTestCase\assertUrl(), and DrupalWebTestCase\drupalCreateContentType().

assertFalse | ( | $value,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Check to see if a value is false (an empty string, 0, NULL, or FALSE).

Parameters
$value | The value on which the assertion is to be done.
$message | The message to display along with the assertion.
$group | The type of assertion - examples are "Browser", "PHP".
Returns
TRUE if the assertion succeeded, FALSE otherwise.

Definition at line 279 of file drupal_web_test_case.php.

References $value, assert(), and t().

Referenced by DrupalWebTestCase\assertNoFieldByXPath(), and DrupalWebTestCase\assertNoResponse().

assertIdentical | ( | $first,
 |  | $second,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Check to see if two values are identical.

Parameters
$first | The first value to check.
$second | The second value to check.
$message | The message to display along with the assertion.
$group | The type of assertion - examples are "Browser", "PHP".
Returns
TRUE if the assertion succeeded, FALSE otherwise.

Definition at line 365 of file drupal_web_test_case.php.

References assert(), and t().

Referenced by DrupalWebTestCase\assertThemeOutput().

assertNotEqual | ( | $first,
 |  | $second,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Check to see if two values are not equal.

Parameters
$first | The first value to check.
$second | The second value to check.
$message | The message to display along with the assertion.
$group | The type of assertion - examples are "Browser", "PHP".
Returns
TRUE if the assertion succeeded, FALSE otherwise.

Definition at line 347 of file drupal_web_test_case.php.

References assert(), and t().

Referenced by DrupalWebTestCase\assertNoTitle().

assertNotIdentical | ( | $first,
 |  | $second,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Check to see if two values are not identical.

Parameters
$first | The first value to check.
$second | The second value to check.
$message | The message to display along with the assertion.
$group | The type of assertion - examples are "Browser", "PHP".
Returns
TRUE if the assertion succeeded, FALSE otherwise.

Definition at line 383 of file drupal_web_test_case.php.

References assert(), and t().

assertNotNull | ( | $value,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Check to see if a value is not NULL.

Parameters
$value | The value on which the assertion is to be done.
$message | The message to display along with the assertion.
$group | The type of assertion - examples are "Browser", "PHP".
Returns
TRUE if the assertion succeeded, FALSE otherwise.

Definition at line 311 of file drupal_web_test_case.php.

References $value, assert(), and t().

assertNull | ( | $value,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Check to see if a value is NULL.

Parameters
$value | The value on which the assertion is to be done.
$message | The message to display along with the assertion.
$group | The type of assertion - examples are "Browser", "PHP".
Returns
TRUE if the assertion succeeded, FALSE otherwise.

Definition at line 295 of file drupal_web_test_case.php.

References $value, assert(), and t().

assertTrue | ( | $value,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Check to see if a value is not false (not an empty string, 0, NULL, or FALSE).

Parameters
$value | The value on which the assertion is to be done.
$message | The message to display along with the assertion.
$group | The type of assertion - examples are "Browser", "PHP".
Returns
TRUE if the assertion succeeded, FALSE otherwise.

Definition at line 263 of file drupal_web_test_case.php.

References $value, assert(), and t().

Referenced by DrupalWebTestCase\assertFieldByXPath(), DrupalWebTestCase\assertFieldChecked(), DrupalWebTestCase\assertMail(), DrupalWebTestCase\assertMailPattern(), DrupalWebTestCase\assertMailString(), DrupalWebTestCase\assertNoFieldChecked(), DrupalWebTestCase\assertNoOptionSelected(), DrupalWebTestCase\assertOptionSelected(), DrupalWebTestCase\assertResponse(), DrupalWebTestCase\clickLink(), DrupalWebTestCase\curlExec(), DrupalWebTestCase\drupalCreateRole(), DrupalWebTestCase\drupalCreateUser(), DrupalWebTestCase\drupalPost(), and DrupalWebTestCase\setUp().

static deleteAssert ( $message_id )
static

Delete an assertion record by message ID.

Parameters
$message_id Message ID of the assertion to delete.
Returns
TRUE if the assertion was deleted, FALSE otherwise.
See Also
DrupalTestCase::insertAssert()

Definition at line 223 of file drupal_web_test_case.php.

References db_delete().

Referenced by run().

error | ( |  | $message = '',
 |  |  | $group = 'Other',
 |  | array | $caller = NULL
 | ) |  |
protected

Fire an error assertion.

Parameters
$message | The message to display along with the assertion.
$group | The type of assertion - examples are "Browser", "PHP".
$caller | The caller of the error.
Returns
FALSE.

Definition at line 427 of file drupal_web_test_case.php.

References assert().

Referenced by errorHandler(), exceptionHandler(), and verbose().

errorHandler | ( | $severity,
 |  | $message,
 |  | $file = NULL,
 |  | $line = NULL
 | ) |

Handle errors during test runs.

Because this is registered in set_error_handler(), it has to be public.

See Also
set_error_handler

Definition at line 530 of file drupal_web_test_case.php.

References _drupal_get_last_caller(), and error().

exceptionHandler ( $exception )
protected

Handle exceptions.

See Also
set_exception_handler

Definition at line 564 of file drupal_web_test_case.php.

References _drupal_decode_exception(), _drupal_get_last_caller(), DRUPAL_ROOT, error(), and t().

Referenced by run().

fail | ( | $message = NULL,
 |  | $group = 'Other'
 | ) |
protected

Fire an assertion that is always negative.

Parameters
$message | The message to display along with the assertion.
$group | The type of assertion - examples are "Browser", "PHP".
Returns
FALSE.

Definition at line 411 of file drupal_web_test_case.php.

References assert().

Referenced by DrupalWebTestCase\assertNoDuplicateIds(), DrupalWebTestCase\checkPermissions(), DrupalWebTestCase\drupalPost(), DrupalWebTestCase\parse(), run(), and DrupalWebTestCase\tearDown().

static generatePermutations ( $parameters )
static

Converts a list of possible parameters into a stack of permutations.

Takes a list of parameters containing possible values, and converts all of them into a list of items containing every possible permutation.

Example:

* $parameters = array(
* 'one' => array(0, 1),
* 'two' => array(2, 3),
* );
* $permutations = DrupalTestCase::generatePermutations($parameters)
* // Result:
* $permutations == array(
* array('one' => 0, 'two' => 2),
* array('one' => 1, 'two' => 2),
* array('one' => 0, 'two' => 3),
* array('one' => 1, 'two' => 3),
* )
*
Parameters
$parameters An associative array of parameters, keyed by parameter name, and whose values are arrays of parameter values.
Returns
A list of permutations, which is an array of arrays. Each inner array contains the full list of parameters that have been passed, but with a single value only.

Definition at line 664 of file drupal_web_test_case.php.

References $value.

getAssertionCall ( )
protected

Cycles through backtrace until the first non-assertion method is found.

Returns
Array representing the true caller.

Definition at line 235 of file drupal_web_test_case.php.

References _drupal_get_last_caller().

Referenced by assert().

static insertAssert | ( |  | $test_id,
 |  |  | $test_class,
 |  |  | $status,
 |  |  | $message = '',
 |  |  | $group = 'Other',
 |  | array | $caller = array()
 | ) |  |
static

Store an assertion from outside the testing context.

This is useful for inserting assertions that can only be recorded after the test case has been destroyed, such as PHP fatal errors. The caller information is not automatically gathered since the caller is most likely inserting the assertion on behalf of other code. In all other respects the method behaves just like DrupalTestCase::assert() in terms of storing the assertion.

Returns
Message ID of the stored assertion.
See Also
DrupalTestCase::assert()
DrupalTestCase::deleteAssert()

Definition at line 185 of file drupal_web_test_case.php.

References db_insert(), and t().

Referenced by run(), and simpletest_log_read().

pass | ( | $message = NULL,
 |  | $group = 'Other'
 | ) |
protected

Fire an assertion that is always positive.

Parameters
$message | The message to display along with the assertion.
$group | The type of assertion - examples are "Browser", "PHP".
Returns
TRUE.

Definition at line 397 of file drupal_web_test_case.php.

References assert().

Referenced by DrupalWebTestCase\parse(), and DrupalWebTestCase\tearDown().

static randomName ( $length = 8 )
static

Generates a random string containing letters and numbers.

The string will always start with a letter. The letters may be upper or lower case. This method is better for restricted inputs that do not accept certain characters. For example, when testing input fields that require machine readable values (i.e. without spaces and non-standard characters) this method is best.

Do not use this method when testing unvalidated user input. Instead, use DrupalWebTestCase::randomString().

Parameters
$length Length of random string to generate.
Returns
Randomly generated string.
See Also
DrupalWebTestCase::randomString()

Definition at line 623 of file drupal_web_test_case.php.

Referenced by DrupalWebTestCase\drupalCreateContentType(), DrupalWebTestCase\drupalCreateNode(), DrupalWebTestCase\drupalCreateRole(), and DrupalWebTestCase\drupalCreateUser().

static randomString ( $length = 8 )
static

Generates a random string of ASCII characters of codes 32 to 126.

The generated string includes alpha-numeric characters and common miscellaneous characters. Use this method when testing general input where the content is not restricted.

Do not use this method when special characters are not possible (e.g., in machine or file names that have already been validated); instead, use DrupalWebTestCase::randomName().

Parameters
$length Length of random string to generate.
Returns
Randomly generated string.
See Also
DrupalWebTestCase::randomName()

Definition at line 595 of file drupal_web_test_case.php.

run ( array $methods = array() )

Run all tests in this class.

Regardless of whether $methods are passed or not, only method names starting with "test" are executed.

Parameters
$methods (optional) A list of method names in the test case class to run; e.g., array('testFoo', 'testBar'). By default, all methods of the class are taken into account, but it can be useful to only run a few selected test methods during debugging.

Definition at line 468 of file drupal_web_test_case.php.

References conf_path(), deleteAssert(), drupal_get_messages(), exceptionHandler(), fail(), insertAssert(), simpletest_verbose(), t(), and variable_get().

verbose ( $message )
protected

Logs verbose message in a text file.

The a link to the vebose message will be placed in the test results via as a passing assertion with the text '[verbose message]'.

Parameters
$message The verbose message to be stored.
See Also
simpletest_verbose()

Definition at line 448 of file drupal_web_test_case.php.

References $url, error(), file_create_url(), l(), simpletest_verbose(), and t().

Referenced by DrupalWebTestCase\assertThemeOutput(), DrupalWebTestCase\drupalGet(), DrupalWebTestCase\drupalPost(), and DrupalWebTestCase\verboseEmail().

Member Data Documentation

$assertions = array()
protected

Definition at line 64 of file drupal_web_test_case.php.

$databasePrefix = NULL
protected

Definition at line 33 of file drupal_web_test_case.php.

Referenced by DrupalWebTestCase\prepareEnvironment(), and DrupalUnitTestCase\setUp().

$originalFileDirectory = NULL
protected

Definition at line 40 of file drupal_web_test_case.php.

Referenced by DrupalUnitTestCase\tearDown(), and DrupalWebTestCase\tearDown().

$results
Initial value:
= array(
'#pass' => 0,
'#fail' => 0,
'#exception' => 0,
'#debug' => 0,
)

Definition at line 52 of file drupal_web_test_case.php.

$setup = FALSE
protected

Flag to indicate whether the test has been set up.

The setUp() method isolates the test from the parent Drupal site by creating a random prefix for the database and setting up a clean file storage directory. The tearDown() method then cleans up this test environment. We must ensure that setUp() has been run. Otherwise, tearDown() will act on the parent Drupal site rather than the test environment, destroying live data.

Definition at line 86 of file drupal_web_test_case.php.

$setupDatabasePrefix = FALSE
protected

Definition at line 88 of file drupal_web_test_case.php.

$setupEnvironment = FALSE
protected

Definition at line 90 of file drupal_web_test_case.php.

$skipClasses = array(__CLASS__ => TRUE)
protected

This class is skipped when looking for the source of an assertion.

When displaying which function an assert comes from, it's not too useful to see "drupalWebTestCase->drupalLogin()', we would like to see the test that called it. So we need to skip the classes defining these helper methods.

Definition at line 74 of file drupal_web_test_case.php.

$testId
protected

Definition at line 26 of file drupal_web_test_case.php.

$timeLimit = 500
protected

Time limit for the test.

Definition at line 45 of file drupal_web_test_case.php.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalUnitTestCase Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Member Functions | List of all members
DrupalUnitTestCase Class Reference
Inheritance diagram for DrupalUnitTestCase:
DrupalTestCase

Public Member Functions

__construct ($test_id=NULL)
- Public Member Functions inherited from DrupalTestCase
__construct ($test_id=NULL)
run (array $methods=array())
errorHandler ($severity, $message, $file=NULL, $line=NULL)

Protected Member Functions

setUp ()
tearDown ()
- Protected Member Functions inherited from DrupalTestCase
assert ($status, $message= '', $group= 'Other', array $caller=NULL)
getAssertionCall ()
assertTrue ($value, $message= '', $group= 'Other')
assertFalse ($value, $message= '', $group= 'Other')
assertNull ($value, $message= '', $group= 'Other')
assertNotNull ($value, $message= '', $group= 'Other')
assertEqual ($first, $second, $message= '', $group= 'Other')
assertNotEqual ($first, $second, $message= '', $group= 'Other')
assertIdentical ($first, $second, $message= '', $group= 'Other')
assertNotIdentical ($first, $second, $message= '', $group= 'Other')
pass ($message=NULL, $group= 'Other')
fail ($message=NULL, $group= 'Other')
error ($message= '', $group= 'Other', array $caller=NULL)
verbose ($message)
exceptionHandler ($exception)

Additional Inherited Members

- Static Public Member Functions inherited from DrupalTestCase
static | insertAssert ($test_id, $test_class, $status, $message= '', $group= 'Other', array $caller=array())
static | deleteAssert ($message_id)
static | randomString ($length=8)
static | randomName ($length=8)
static | generatePermutations ($parameters)
- Public Attributes inherited from DrupalTestCase
$results
- Protected Attributes inherited from DrupalTestCase
$testId
$databasePrefix = NULL
$originalFileDirectory = NULL
$timeLimit = 500
$assertions = array()
$skipClasses = array(__CLASS__ => TRUE)
$setup = FALSE
$setupDatabasePrefix = FALSE
$setupEnvironment = FALSE

Detailed Description

Test case for Drupal unit tests.

These tests can not access the database nor files. Calling any Drupal function that needs the database will throw exceptions. These include watchdog(), module_implements(), module_invoke_all() etc.

Definition at line 690 of file drupal_web_test_case.php.

Constructor & Destructor Documentation

__construct ( $test_id = NULL )

Constructor for DrupalUnitTestCase.

Definition at line 695 of file drupal_web_test_case.php.

Member Function Documentation

setUp ( )
protected

Sets up unit test environment.

Unlike DrupalWebTestCase::setUp(), DrupalUnitTestCase::setUp() does not install modules because tests are performed without accessing the database. Any required files must be explicitly included by the child class setUp() method.

Definition at line 708 of file drupal_web_test_case.php.

References $conf, DrupalTestCase\$databasePrefix, $module, $module_list, $value, Database\addConnectionInfo(), conf_path(), drupal_get_filename(), drupal_static_reset(), FILE_CREATE_DIRECTORY, FILE_MODIFY_PERMISSIONS, file_prepare_directory(), Database\getConnection(), Database\getConnectionInfo(), module_list(), Database\renameConnection(), and variable_get().

tearDown ( )
protected

Definition at line 753 of file drupal_web_test_case.php.

References $conf, DrupalTestCase\$originalFileDirectory, module_list(), Database\removeConnection(), and Database\renameConnection().

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalUpdateException Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalUpdateException Class Reference
Inheritance diagram for DrupalUpdateException:
Exception

Detailed Description

Definition at line 1008 of file update.inc.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalUpdaterInterface Interface Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Static Public Member Functions | List of all members
DrupalUpdaterInterface Interface Reference
Inheritance diagram for DrupalUpdaterInterface:
ModuleUpdater ThemeUpdater

Public Member Functions

isInstalled ()
getInstallDirectory ()
postInstall ()
postUpdate ()

Static Public Member Functions

static | getProjectName ($directory)
static | canUpdateDirectory ($directory)

Detailed Description

Interface for a class which can update a Drupal project.

An Updater currently serves the following purposes:

  • It can take a given directory, and determine if it can operate on it.
  • It can move the contents of that directory into the appropriate place on the system using FileTransfer classes.
  • It can return a list of "next steps" after an update or install.
  • In the future, it will most likely perform some of those steps as well.

Definition at line 21 of file updater.inc.

Member Function Documentation

static canUpdateDirectory ( $directory )
static

Determine if the Updater can handle the project provided in $directory.

Parameters
string $directory
Returns
bool TRUE if the project is installed, FALSE if not.

Implemented in ThemeUpdater, and ModuleUpdater.

getInstallDirectory ( )
Returns
string An absolute path to the default install location.

Implemented in ThemeUpdater, and ModuleUpdater.

static getProjectName ( $directory )
static

Returns the system name of the project.

Parameters
string $directory A directory containing a project.
isInstalled ( )

Checks if the project is installed.

Returns
bool

Implemented in ThemeUpdater, and ModuleUpdater.

postInstall ( )

Actions to run after an install has occurred.

Implemented in ThemeUpdater.

postUpdate ( )

Actions to run after an update has occurred.

Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: DrupalWebTestCase Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DrupalWebTestCase Class Reference
Inheritance diagram for DrupalWebTestCase:
DrupalTestCase

Public Member Functions

__construct ($test_id=NULL)
drupalGetNodeByTitle ($title, $reset=FALSE)
- Public Member Functions inherited from DrupalTestCase
__construct ($test_id=NULL)
run (array $methods=array())
errorHandler ($severity, $message, $file=NULL, $line=NULL)

Protected Member Functions

drupalCreateNode ($settings=array())
drupalCreateContentType ($settings=array())
drupalGetTestFiles ($type, $size=NULL)
drupalCompareFiles ($file1, $file2)
drupalCreateUser (array $permissions=array())
drupalCreateRole (array $permissions, $name=NULL)
checkPermissions (array $permissions, $reset=FALSE)
drupalLogin (stdClass $account)
drupalGetToken ($value= '')
drupalLogout ()
prepareDatabasePrefix ()
changeDatabasePrefix ()
prepareEnvironment ()
setUp ()
preloadRegistry ()
resetAll ()
refreshVariables ()
tearDown ()
curlInitialize ()
curlExec ($curl_options, $redirect=FALSE)
curlHeaderCallback ($curlHandler, $header)
curlClose ()
parse ()
drupalGet ($path, array $options=array(), array $headers=array())
drupalGetAJAX ($path, array $options=array(), array $headers=array())
drupalPost ($path, $edit, $submit, array $options=array(), array $headers=array(), $form_html_id=NULL, $extra_post=NULL)
drupalPostAJAX ($path, $edit, $triggering_element, $ajax_path=NULL, array $options=array(), array $headers=array(), $form_html_id=NULL, $ajax_settings=NULL)
cronRun ()
checkForMetaRefresh ()
drupalHead ($path, array $options=array(), array $headers=array())
handleForm (&$post, &$edit, &$upload, $submit, $form)
buildXPathQuery ($xpath, array $args=array())
xpath ($xpath, array $arguments=array())
getAllOptions (SimpleXMLElement $element)
assertLink ($label, $index=0, $message= '', $group= 'Other')
assertNoLink ($label, $message= '', $group= 'Other')
assertLinkByHref ($href, $index=0, $message= '', $group= 'Other')
assertNoLinkByHref ($href, $message= '', $group= 'Other')
clickLink ($label, $index=0)
getAbsoluteUrl ($path)
getUrl ()
drupalGetHeaders ($all_requests=FALSE)
drupalGetHeader ($name, $all_requests=FALSE)
drupalGetContent ()
drupalGetSettings ()
drupalGetMails ($filter=array())
drupalSetContent ($content, $url= 'internal:')
drupalSetSettings ($settings)
assertUrl ($path, array $options=array(), $message= '', $group= 'Other')
assertRaw ($raw, $message= '', $group= 'Other')
assertNoRaw ($raw, $message= '', $group= 'Other')
assertText ($text, $message= '', $group= 'Other')
assertNoText ($text, $message= '', $group= 'Other')
assertTextHelper ($text, $message= '', $group, $not_exists)
assertUniqueText ($text, $message= '', $group= 'Other')
assertNoUniqueText ($text, $message= '', $group= 'Other')
assertUniqueTextHelper ($text, $message= '', $group, $be_unique)
assertPattern ($pattern, $message= '', $group= 'Other')
assertNoPattern ($pattern, $message= '', $group= 'Other')
assertTitle ($title, $message= '', $group= 'Other')
assertNoTitle ($title, $message= '', $group= 'Other')
assertThemeOutput ($callback, array $variables=array(), $expected, $message= '', $group= 'Other')
assertFieldByXPath ($xpath, $value=NULL, $message= '', $group= 'Other')
getSelectedItem (SimpleXMLElement $element)
assertNoFieldByXPath ($xpath, $value=NULL, $message= '', $group= 'Other')
assertFieldByName ($name, $value=NULL, $message=NULL)
assertNoFieldByName ($name, $value= '', $message= '')
assertFieldById ($id, $value= '', $message= '')
assertNoFieldById ($id, $value= '', $message= '')
assertFieldChecked ($id, $message= '')
assertNoFieldChecked ($id, $message= '')
assertOptionSelected ($id, $option, $message= '')
assertNoOptionSelected ($id, $option, $message= '')
assertField ($field, $message= '', $group= 'Other')
assertNoField ($field, $message= '', $group= 'Other')
assertNoDuplicateIds ($message= '', $group= 'Other', $ids_to_skip=array())
constructFieldXpath ($attribute, $value)
assertResponse ($code, $message= '')
assertNoResponse ($code, $message= '')
assertMail ($name, $value= '', $message= '')
assertMailString ($field_name, $string, $email_depth)
assertMailPattern ($field_name, $regex, $message)
verboseEmail ($count=1)
- Protected Member Functions inherited from DrupalTestCase
assert ($status, $message= '', $group= 'Other', array $caller=NULL)
getAssertionCall ()
assertTrue ($value, $message= '', $group= 'Other')
assertFalse ($value, $message= '', $group= 'Other')
assertNull ($value, $message= '', $group= 'Other')
assertNotNull ($value, $message= '', $group= 'Other')
assertEqual ($first, $second, $message= '', $group= 'Other')
assertNotEqual ($first, $second, $message= '', $group= 'Other')
assertIdentical ($first, $second, $message= '', $group= 'Other')
assertNotIdentical ($first, $second, $message= '', $group= 'Other')
pass ($message=NULL, $group= 'Other')
fail ($message=NULL, $group= 'Other')
error ($message= '', $group= 'Other', array $caller=NULL)
verbose ($message)
exceptionHandler ($exception)

Protected Attributes

$profile = 'standard'
$url
$curlHandle
$headers
$content
$plainTextContent
$drupalSettings
$elements = NULL
$loggedInUser = FALSE
$cookieFile = NULL
$additionalCurlOptions = array()
$originalUser = NULL
$originalShutdownCallbacks = array()
$httpauth_method = CURLAUTH_BASIC
$httpauth_credentials = NULL
$session_name = NULL
$session_id = NULL
$generatedTestFiles = FALSE
$redirect_count
- Protected Attributes inherited from DrupalTestCase
$testId
$databasePrefix = NULL
$originalFileDirectory = NULL
$timeLimit = 500
$assertions = array()
$skipClasses = array(__CLASS__ => TRUE)
$setup = FALSE
$setupDatabasePrefix = FALSE
$setupEnvironment = FALSE

Additional Inherited Members

- Static Public Member Functions inherited from DrupalTestCase
static | insertAssert ($test_id, $test_class, $status, $message= '', $group= 'Other', array $caller=array())
static | deleteAssert ($message_id)
static | randomString ($length=8)
static | randomName ($length=8)
static | generatePermutations ($parameters)
- Public Attributes inherited from DrupalTestCase
$results

Detailed Description

Test case for typical Drupal tests.

Definition at line 771 of file drupal_web_test_case.php.

Constructor & Destructor Documentation

__construct ( $test_id = NULL )

Constructor for DrupalWebTestCase.

Definition at line 897 of file drupal_web_test_case.php.

Member Function Documentation

assertField | ( | $field,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Asserts that a field exists with the given name or id.

Parameters
$field | Name or id of field to assert.
$message | Message to display.
$group | The group this message belongs to.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3476 of file drupal_web_test_case.php.

References assertFieldByXPath(), and constructFieldXpath().

Referenced by drupalLogout().

assertFieldById | ( | $id,
 |  | $value = '',
 |  | $message = ''
 | ) |
protected

Asserts that a field exists in the current page with the given id and value.

Parameters
$id | Id of field to assert.
$value | Value of the field to assert.
$message | Message to display.
$group | The group this message belongs to.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3376 of file drupal_web_test_case.php.

References $value, assertFieldByXPath(), constructFieldXpath(), and t().

assertFieldByName | ( | $name,
 |  | $value = NULL,
 |  | $message = NULL
 | ) |
protected

Asserts that a field exists in the current page with the given name and value.

Parameters
$name | Name of field to assert.
$value | Value of the field to assert.
$message | Message to display.
$group | The group this message belongs to.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3327 of file drupal_web_test_case.php.

References $name, $value, assertFieldByXPath(), constructFieldXpath(), and t().

assertFieldByXPath | ( | $xpath,
 |  | $value = NULL,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Asserts that a field exists in the current page by the given XPath.

Parameters
$xpath | XPath used to find the field.
$value | (optional) Value of the field to assert.
$message | (optional) Message to display.
$group | (optional) The group this message belongs to.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3222 of file drupal_web_test_case.php.

References $value, DrupalTestCase\assertTrue(), getAllOptions(), getSelectedItem(), and xpath().

Referenced by assertField(), assertFieldById(), and assertFieldByName().

assertFieldChecked | ( | $id,
 |  | $message = ''
 | ) |
protected

Asserts that a checkbox field in the current page is checked.

Parameters
$id | Id of field to assert.
$message | Message to display.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3408 of file drupal_web_test_case.php.

References $elements, DrupalTestCase\assertTrue(), t(), and xpath().

assertLink | ( | $label,
 |  | $index = 0,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Pass if a link with the specified label is found, and optional with the specified index.

Parameters
$label | Text between the anchor tags.
$index | Link position counting from zero.
$message | Message to display.
$group | The group this message belongs to, defaults to 'Other'.
Returns
TRUE if the assertion succeeded, FALSE otherwise.

Definition at line 2601 of file drupal_web_test_case.php.

References $links, DrupalTestCase\assert(), t(), and xpath().

Referenced by drupalLogin().

assertLinkByHref | ( | $href,
 |  | $index = 0,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Pass if a link containing a given href (part) is found.

Parameters
$href | The full or partial value of the 'href' attribute of the anchor tag.
$index | Link position counting from zero.
$message | Message to display.
$group | The group this message belongs to, defaults to 'Other'.
Returns
TRUE if the assertion succeeded, FALSE otherwise.

Definition at line 2642 of file drupal_web_test_case.php.

References $links, DrupalTestCase\assert(), t(), and xpath().

assertMail | ( | $name,
 |  | $value = '',
 |  | $message = ''
 | ) |
protected

Asserts that the most recently sent e-mail message has the given value.

The field in $name must have the content described in $value.

Parameters
$name | Name of field or message property to assert. Examples: subject, body, id, ...
$value | Value of the field to assert.
$message | Message to display.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3591 of file drupal_web_test_case.php.

References $name, $value, DrupalTestCase\assertTrue(), t(), and variable_get().

assertMailPattern | ( | $field_name,
 |  | $regex,
 |  | $message
 | ) |
protected

Asserts that the most recently sent e-mail message has the pattern in it.

Parameters
$field_name | Name of field or message property to assert: subject, body, id, ...
$regex | Pattern to search for.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3638 of file drupal_web_test_case.php.

References DrupalTestCase\assertTrue(), drupalGetMails(), and t().

assertMailString | ( | $field_name,
 |  | $string,
 |  | $email_depth
 | ) |
protected

Asserts that the most recently sent e-mail message has the string in it.

Parameters
$field_name | Name of field or message property to assert: subject, body, id, ...
$string | String to search for.
$email_depth | Number of emails to search for string, starting with most recent.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3610 of file drupal_web_test_case.php.

References DrupalTestCase\assertTrue(), drupalGetMails(), and t().

assertNoDuplicateIds | ( | $message = '',
 |  | $group = 'Other',
 |  | $ids_to_skip = array()
 | ) |
protected

Asserts that each HTML ID is used for just a single element.

Parameters
$message | Message to display.
$group | The group this message belongs to.
$ids_to_skip | An optional array of ids to skip when checking for duplicates. It is always a bug to have duplicate HTML IDs, so this parameter is to enable incremental fixing of core code. Whenever a test passes this parameter, it should add a "todo" comment above the call to this function explaining the legacy bug that the test wishes to ignore and including a link to an issue that is working to fix that legacy bug.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3513 of file drupal_web_test_case.php.

References DrupalTestCase\assert(), DrupalTestCase\fail(), t(), and xpath().

assertNoField | ( | $field,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Asserts that a field does not exist with the given name or id.

Parameters
$field | Name or id of field to assert.
$message | Message to display.
$group | The group this message belongs to.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3492 of file drupal_web_test_case.php.

References assertNoFieldByXPath(), and constructFieldXpath().

assertNoFieldById | ( | $id,
 |  | $value = '',
 |  | $message = ''
 | ) |
protected

Asserts that a field does not exist with the given id and value.

Parameters
$id | Id of field to assert.
$value | Value of the field to assert.
$message | Message to display.
$group | The group this message belongs to.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3394 of file drupal_web_test_case.php.

References $value, assertNoFieldByXPath(), constructFieldXpath(), and t().

assertNoFieldByName | ( | $name,
 |  | $value = '',
 |  | $message = ''
 | ) |
protected

Asserts that a field does not exist with the given name and value.

Parameters
$name | Name of field to assert.
$value | Value of the field to assert.
$message | Message to display.
$group | The group this message belongs to.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3358 of file drupal_web_test_case.php.

References $name, $value, assertNoFieldByXPath(), constructFieldXpath(), and t().

assertNoFieldByXPath | ( | $xpath,
 |  | $value = NULL,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Asserts that a field does not exist in the current page by the given XPath.

Parameters
$xpath | XPath used to find the field.
$value | (optional) Value of the field to assert.
$message | (optional) Message to display.
$group | (optional) The group this message belongs to.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3295 of file drupal_web_test_case.php.

References $value, DrupalTestCase\assertFalse(), and xpath().

Referenced by assertNoField(), assertNoFieldById(), and assertNoFieldByName().

assertNoFieldChecked | ( | $id,
 |  | $message = ''
 | ) |
protected

Asserts that a checkbox field in the current page is not checked.

Parameters
$id | Id of field to assert.
$message | Message to display.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3423 of file drupal_web_test_case.php.

References $elements, DrupalTestCase\assertTrue(), t(), and xpath().

assertNoLink | ( | $label,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Pass if a link with the specified label is not found.

Parameters
$label | Text between the anchor tags.
$index | Link position counting from zero.
$message | Message to display.
$group | The group this message belongs to, defaults to 'Other'.
Returns
TRUE if the assertion succeeded, FALSE otherwise.

Definition at line 2621 of file drupal_web_test_case.php.

References $links, DrupalTestCase\assert(), t(), and xpath().

assertNoLinkByHref | ( | $href,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Pass if a link containing a given href (part) is not found.

Parameters
$href | The full or partial value of the 'href' attribute of the anchor tag.
$message | Message to display.
$group | The group this message belongs to, defaults to 'Other'.
Returns
TRUE if the assertion succeeded, FALSE otherwise.

Definition at line 2661 of file drupal_web_test_case.php.

References $links, DrupalTestCase\assert(), t(), and xpath().

assertNoOptionSelected | ( | $id,
 |  | $option,
 |  | $message = ''
 | ) |
protected

Asserts that a select option in the current page is not checked.

Parameters
$id | Id of select field to assert.
$option | Option to assert.
$message | Message to display.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3459 of file drupal_web_test_case.php.

References $elements, DrupalTestCase\assertTrue(), t(), and xpath().

assertNoPattern | ( | $pattern,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Will trigger a pass if the perl regex pattern is not present in raw content.

Parameters
$pattern | Perl regex to look for including the regex delimiters.
$message | Message to display.
$group | The group this message belongs to.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3118 of file drupal_web_test_case.php.

References DrupalTestCase\assert(), drupalGetContent(), and t().

assertNoRaw | ( | $raw,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Pass if the raw text is NOT found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.

Parameters
$raw | Raw (HTML) string to look for.
$message | Message to display.
$group | The group this message belongs to, defaults to 'Other'.
Returns
TRUE on pass, FALSE on fail.

Definition at line 2946 of file drupal_web_test_case.php.

References DrupalTestCase\assert(), drupalGetContent(), and t().

assertNoResponse | ( | $code,
 |  | $message = ''
 | ) |
protected

Asserts the page did not return the specified response code.

Parameters
$code | Response code. For example 200 is a successful page request. For a list of all codes see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
$message | Message to display.
Returns
Assertion result.

Definition at line 3570 of file drupal_web_test_case.php.

References DrupalTestCase\assertFalse(), and t().

assertNoText | ( | $text,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Pass if the text is NOT found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.

Parameters
$text | Plain text to look for.
$message | Message to display.
$group | The group this message belongs to, defaults to 'Other'.
Returns
TRUE on pass, FALSE on fail.

Definition at line 2985 of file drupal_web_test_case.php.

References assertTextHelper().

assertNoTitle | ( | $title,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Pass if the page title is not the given string.

Parameters
$title | The string the title should not be.
$message | Message to display.
$group | The group this message belongs to.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3160 of file drupal_web_test_case.php.

References $title, DrupalTestCase\assertNotEqual(), t(), and xpath().

assertNoUniqueText | ( | $text,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Pass if the text is found MORE THAN ONCE on the text version of the page.

The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.

Parameters
$text | Plain text to look for.
$message | Message to display.
$group | The group this message belongs to, defaults to 'Other'.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3051 of file drupal_web_test_case.php.

References assertUniqueTextHelper().

assertOptionSelected | ( | $id,
 |  | $option,
 |  | $message = ''
 | ) |
protected

Asserts that a select option in the current page is checked.

Parameters
$id | Id of select field to assert.
$option | Option to assert.
$message | Message to display.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3442 of file drupal_web_test_case.php.

References $elements, DrupalTestCase\assertTrue(), t(), and xpath().

assertPattern | ( | $pattern,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Will trigger a pass if the Perl regex pattern is found in the raw content.

Parameters
$pattern | Perl regex to look for including the regex delimiters.
$message | Message to display.
$group | The group this message belongs to.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3099 of file drupal_web_test_case.php.

References DrupalTestCase\assert(), drupalGetContent(), and t().

assertRaw | ( | $raw,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Pass if the raw text IS found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.

Parameters
$raw | Raw (HTML) string to look for.
$message | Message to display.
$group | The group this message belongs to, defaults to 'Other'.
Returns
TRUE on pass, FALSE on fail.

Definition at line 2926 of file drupal_web_test_case.php.

References DrupalTestCase\assert(), drupalGetContent(), and t().

assertResponse | ( | $code,
 |  | $message = ''
 | ) |
protected

Asserts the page responds with the specified response code.

Parameters
$code | Response code. For example 200 is a successful page request. For a list of all codes see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
$message | Message to display.
Returns
Assertion result.

Definition at line 3552 of file drupal_web_test_case.php.

References DrupalTestCase\assertTrue(), and t().

assertText | ( | $text,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Pass if the text IS found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.

Parameters
$text | Plain text to look for.
$message | Message to display.
$group | The group this message belongs to, defaults to 'Other'.
Returns
TRUE on pass, FALSE on fail.

Definition at line 2967 of file drupal_web_test_case.php.

References assertTextHelper().

assertTextHelper | ( | $text,
 |  | $message = '',
 |  | $group,
 |  | $not_exists
 | ) |
protected

Helper for assertText and assertNoText.

It is not recommended to call this function directly.

Parameters
$text | Plain text to look for.
$message | Message to display.
$group | The group this message belongs to.
$not_exists | TRUE if this text should not exist, FALSE if it should.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3005 of file drupal_web_test_case.php.

References DrupalTestCase\assert(), drupalGetContent(), filter_xss(), and t().

Referenced by assertNoText(), and assertText().

assertThemeOutput | ( |  | $callback,
 |  | array | $variables = array(),
 |  |  | $expected,
 |  |  | $message = '',
 |  |  | $group = 'Other'
 | ) |  |
protected

Asserts themed output.

Parameters
$callback | The name of the theme function to invoke; e.g. 'links' for theme_links().
$variables | An array of variables to pass to the theme function.
$expected | The expected themed output string.
$message | (optional) A message to display with the assertion. Do not translate messages: use format_string() to embed variables in the message text, not t(). If left blank, a default message will be displayed.
$group | (optional) The group this message is in, which is displayed in a column in test output. Use 'Debug' to indicate this is debugging output. Do not translate this string. Defaults to 'Other'; most tests do not override this default.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3193 of file drupal_web_test_case.php.

References $output, DrupalTestCase\assertIdentical(), check_plain(), format_string(), theme(), and DrupalTestCase\verbose().

assertTitle | ( | $title,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Pass if the page title is the given string.

Parameters
$title | The string the title should be.
$message | Message to display.
$group | The group this message belongs to.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3137 of file drupal_web_test_case.php.

References $title, DrupalTestCase\assertEqual(), t(), and xpath().

assertUniqueText | ( | $text,
 |  | $message = '',
 |  | $group = 'Other'
 | ) |
protected

Pass if the text is found ONLY ONCE on the text version of the page.

The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.

Parameters
$text | Plain text to look for.
$message | Message to display.
$group | The group this message belongs to, defaults to 'Other'.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3031 of file drupal_web_test_case.php.

References assertUniqueTextHelper().

assertUniqueTextHelper | ( | $text,
 |  | $message = '',
 |  | $group,
 |  | $be_unique
 | ) |
protected

Helper for assertUniqueText and assertNoUniqueText.

It is not recommended to call this function directly.

Parameters
$text | Plain text to look for.
$message | Message to display.
$group | The group this message belongs to.
$be_unique | TRUE if this text should be found only once, FALSE if it should be found more than once.
Returns
TRUE on pass, FALSE on fail.

Definition at line 3071 of file drupal_web_test_case.php.

References DrupalTestCase\assert(), drupalGetContent(), and filter_xss().

Referenced by assertNoUniqueText(), and assertUniqueText().

assertUrl | ( |  | $path,
 |  | array | $options = array(),
 |  |  | $message = '',
 |  |  | $group = 'Other'
 | ) |  |
protected

Pass if the internal browser's URL matches the given path.

Parameters
$path | The expected system path.
$options | (optional) Any additional options to pass for $path to url().
$message | Message to display.
$group | The group this message belongs to, defaults to 'Other'.
Returns
TRUE on pass, FALSE on fail.

Definition at line 2903 of file drupal_web_test_case.php.

References DrupalTestCase\assertEqual(), getUrl(), t(), and url().

buildXPathQuery | ( |  | $xpath,
 |  | array | $args = array()
 | ) |  |
protected

Builds an XPath query.

Builds an XPath query by replacing placeholders in the query by the value of the arguments.

XPath 1.0 (the version supported by libxml2, the underlying XML library used by PHP) doesn't support any form of quotation. This function simplifies the building of XPath expression.

Parameters
$xpath | An XPath query, possibly with placeholders in the form ':name'.
$args | An array of arguments with keys in the form ':name' matching the placeholders in the query. The values may be either strings or numeric values.
Returns
An XPath query with arguments replaced.

Definition at line 2514 of file drupal_web_test_case.php.

References $value.

Referenced by constructFieldXpath(), and xpath().

changeDatabasePrefix ( )
protected

Changes the database connection to the prefixed one.

See Also
DrupalWebTestCase::setUp()

Definition at line 1315 of file drupal_web_test_case.php.

References $value, Database\addConnectionInfo(), Database\getConnectionInfo(), prepareDatabasePrefix(), and Database\renameConnection().

Referenced by setUp().

checkForMetaRefresh ( )
protected

Check for meta refresh tag and if found call drupalGet() recursively. This function looks for the http-equiv attribute to be set to "Refresh" and is case-sensitive.

Returns
Either the new page content or FALSE.

Definition at line 2308 of file drupal_web_test_case.php.

References decode_entities(), drupalGet(), drupalGetContent(), getAbsoluteUrl(), parse(), and xpath().

Referenced by drupalGet(), and drupalPost().

checkPermissions | ( | array | $permissions,
 |  |  | $reset = FALSE
 | ) |  |
protected

Check to make sure that the array of permissions are valid.

Parameters
$permissions | Permissions to check.
$reset | Reset cached available permissions.
Returns
TRUE or FALSE depending on whether the permissions are valid.

Definition at line 1195 of file drupal_web_test_case.php.

References drupal_static(), DrupalTestCase\fail(), module_invoke_all(), and t().

Referenced by drupalCreateContentType(), drupalCreateRole(), and resetAll().

clickLink | ( | $label,
 |  | $index = 0
 | ) |
protected

Follows a link by name.

Will click the first link found with this link text by default, or a later one if an index is given. Match is case sensitive with normalized space. The label is translated label. There is an assert for successful click.

Parameters
$label | Text between the anchor tags.
$index | Link position counting from zero.
Returns
Page on success, or FALSE on failure.

Definition at line 2681 of file drupal_web_test_case.php.

References DrupalTestCase\assertTrue(), drupalGet(), getAbsoluteUrl(), getUrl(), t(), and xpath().

constructFieldXpath | ( | $attribute,
 |  | $value
 | ) |
protected

Helper function: construct an XPath for the given set of attributes and value.

Parameters
$attribute | Field attributes.
$value | Value of field.
Returns
XPath for specified values.

Definition at line 3536 of file drupal_web_test_case.php.

References $value, and buildXPathQuery().

Referenced by assertField(), assertFieldById(), assertFieldByName(), assertNoField(), assertNoFieldById(), and assertNoFieldByName().

cronRun ( )
protected

Runs cron in the Drupal installed by Simpletest.

Definition at line 2296 of file drupal_web_test_case.php.

References drupalGet(), and variable_get().

curlClose ( )
protected

Close the cURL handler and unset the handler.

Definition at line 1871 of file drupal_web_test_case.php.

Referenced by tearDown().

curlExec | ( | $curl_options,
 |  | $redirect = FALSE
 | ) |
protected

Initializes and executes a cURL request.

Parameters
$curl_options | An associative array of cURL options to set, where the keys are constants defined by the cURL library. For a list of valid options, see http://www.php.net/manual/function.curl-setopt.php
$redirect | FALSE if this is an initial request, TRUE if this request is the result of a redirect.
Returns
The content returned from the call to curl_exec().
See Also
curlInitialize()

Definition at line 1756 of file drupal_web_test_case.php.

References $content, $url, DrupalTestCase\assertTrue(), curlInitialize(), drupalGetContent(), drupalGetHeader(), drupalSetContent(), format_size(), t(), and variable_get().

Referenced by drupalGet(), drupalHead(), and drupalPost().

curlHeaderCallback | ( | $curlHandler,
 |  | $header
 | ) |
protected

Reads headers and registers errors received from the tested site.

See Also
_drupal_log_error().
Parameters
$curlHandler | The cURL handler.
$header | An header.

Definition at line 1828 of file drupal_web_test_case.php.

References $header, $name, and $value.

curlInitialize ( )
protected

Initializes the cURL connection.

If the simpletest_httpauth_credentials variable is set, this function will add HTTP authentication headers. This is necessary for testing sites that are protected by login credentials from public access. See the description of $curl_options for other options.

Definition at line 1697 of file drupal_web_test_case.php.

References $base_url, $httpauth_credentials, $httpauth_method, and drupal_generate_test_ua().

Referenced by curlExec().

drupalCompareFiles | ( | $file1,
 |  | $file2
 | ) |
protected

Compare two files based on size and file name.

Definition at line 1092 of file drupal_web_test_case.php.

drupalCreateContentType ( $settings = array() )
protected

Creates a custom content type based on default settings.

Parameters
$settings An array of settings to change from the defaults. Example: 'type' => 'foo'.
Returns
Created content type.

Definition at line 991 of file drupal_web_test_case.php.

References $name, DrupalTestCase\assertEqual(), checkPermissions(), menu_rebuild(), node_add_body_field(), node_type_get_type(), node_type_save(), node_types_rebuild(), DrupalTestCase\randomName(), SAVED_NEW, and t().

drupalCreateNode ( $settings = array() )
protected

Creates a node based on default settings.

Parameters
$settings An associative array of settings to change from the defaults, keys are node properties, for example 'title' => 'Hello, world!'.
Returns
Created node object.

Definition at line 929 of file drupal_web_test_case.php.

References db_update(), filter_default_format(), format_date(), LANGUAGE_NONE, node_save(), DrupalTestCase\randomName(), and REQUEST_TIME.

drupalCreateRole | ( | array | $permissions,
 |  |  | $name = NULL
 | ) |  |
protected

Internal helper function; Create a role with specified permissions.

Parameters
$permissions | Array of permission names to assign to role.
$name | (optional) String for the name of the role. Defaults to a random string.
Returns
Role ID of newly created role, or FALSE if role creation failed.

Definition at line 1157 of file drupal_web_test_case.php.

References $name, DrupalTestCase\assertTrue(), checkPermissions(), db_query(), DrupalTestCase\randomName(), t(), user_role_grant_permissions(), and user_role_save().

Referenced by drupalCreateUser().

drupalCreateUser ( array $permissions = array() )
protected

Create a user with a given set of permissions.

Parameters
array $permissions Array of permission names to assign to user. Note that the user always has the default permissions derived from the "authenticated users" role.
Returns
object|false A fully loaded user object with pass_raw property, or FALSE if account creation fails.

Definition at line 1115 of file drupal_web_test_case.php.

References DrupalTestCase\assertTrue(), drupal_anonymous_user(), drupalCreateRole(), DrupalTestCase\randomName(), t(), user_password(), and user_save().

drupalGet | ( |  | $path,
 |  | array | $options = array(),
 |  | array | $headers = array()
 | ) |  |
protected

Retrieves a Drupal path or an absolute path.

Parameters
$path | Drupal path or URL to load into internal browser
$options | Options to be forwarded to url().
$headers | An array containing additional HTTP request headers, each formatted as "name: value".
Returns
The retrieved HTML string, also available as $this->drupalGetContent()

Definition at line 1917 of file drupal_web_test_case.php.

References $headers, checkForMetaRefresh(), curlExec(), getUrl(), refreshVariables(), url(), and DrupalTestCase\verbose().

Referenced by checkForMetaRefresh(), clickLink(), cronRun(), drupalGetAJAX(), drupalLogout(), drupalPost(), and drupalPostAJAX().

drupalGetAJAX | ( |  | $path,
 |  | array | $options = array(),
 |  | array | $headers = array()
 | ) |  |
protected

Retrieve a Drupal path or an absolute path and JSON decode the result.

Definition at line 1939 of file drupal_web_test_case.php.

References $headers, drupal_json_decode(), and drupalGet().

drupalGetContent ( )
protected

Gets the current raw HTML of requested page.

Definition at line 2826 of file drupal_web_test_case.php.

References $content.

Referenced by assertNoPattern(), assertNoRaw(), assertPattern(), assertRaw(), assertTextHelper(), assertUniqueTextHelper(), checkForMetaRefresh(), curlExec(), and parse().

drupalGetHeader | ( | $name,
 |  | $all_requests = FALSE
 | ) |
protected

Gets the value of an HTTP response header. If multiple requests were required to retrieve the page, only the headers from the last request will be checked by default. However, if TRUE is passed as the second argument, all requests will be processed from last to first until the header is found.

Parameters
$name | The name of the header to retrieve. Names are case-insensitive (see RFC 2616 section 4.2).
$all_requests | Boolean value specifying whether to check all requests if the header is not found in the last request. Defaults to FALSE.
Returns
The HTTP header value or FALSE if not found.

Definition at line 2803 of file drupal_web_test_case.php.

References $header, $headers, $name, and drupalGetHeaders().

Referenced by curlExec().

drupalGetHeaders ( $all_requests = FALSE )
protected

Gets the HTTP response headers of the requested page. Normally we are only interested in the headers returned by the last request. However, if a page is redirected or HTTP authentication is in use, multiple requests will be required to retrieve the page. Headers from all requests may be requested by passing TRUE to this function.

Parameters
$all_requests Boolean value specifying whether to return headers from all requests instead of just the last request. Defaults to FALSE.
Returns
A name/value array if headers from only the last request are requested. If headers from all requests are requested, an array of name/value arrays, one for each request.

The pseudonym ":status" is used for the HTTP status line.

Values for duplicate headers are stored as a single comma-separated list.

Definition at line 2756 of file drupal_web_test_case.php.

References $header, $headers, $name, and $value.

Referenced by drupalGetHeader().

drupalGetMails ( $filter = array() )
protected

Gets an array containing all e-mails sent during this test case.

Parameters
$filter An array containing key/value pairs used to filter the e-mails that are returned.
Returns
An array containing e-mail messages captured during the current test.

Definition at line 2845 of file drupal_web_test_case.php.

References $value, and variable_get().

Referenced by assertMailPattern(), assertMailString(), and verboseEmail().

drupalGetNodeByTitle | ( | $title,
 |  | $reset = FALSE
 | ) |

Get a node from the database based on its title.

Parameters
$title | A node title, usually generated by $this->randomName().
$reset | (optional) Whether to reset the internal node_load() cache.
Returns
A node object matching $title.

Definition at line 913 of file drupal_web_test_case.php.

References $title, and node_load_multiple().

drupalGetSettings ( )
protected

Gets the value of the Drupal.settings JavaScript variable for the currently loaded page.

Definition at line 2833 of file drupal_web_test_case.php.

References $drupalSettings.

drupalGetTestFiles | ( | $type,
 |  | $size = NULL
 | ) |
protected

Get a list files that can be used in tests.

Parameters
$type | File type, possible values: 'binary', 'html', 'image', 'javascript', 'php', 'sql', 'text'.
$size | File size in bytes to match. Please check the tests/files folder.
Returns
List of files that match filter.

Definition at line 1044 of file drupal_web_test_case.php.

References conf_path(), drupal_get_path(), file_scan_directory(), file_unmanaged_copy(), simpletest_generate_file(), and variable_get().

drupalGetToken ( $value = '' )
protected

Generate a token for the currently logged in user.

Definition at line 1262 of file drupal_web_test_case.php.

References $value, drupal_get_private_key(), and drupal_hmac_base64().

drupalHead | ( |  | $path,
 |  | array | $options = array(),
 |  | array | $headers = array()
 | ) |  |
protected

Retrieves only the headers for a Drupal path or an absolute path.

Parameters
$path | Drupal path or URL to load into internal browser
$options | Options to be forwarded to url().
$headers | An array containing additional HTTP request headers, each formatted as "name: value".
Returns
The retrieved headers, also available as $this->drupalGetContent()

Definition at line 2335 of file drupal_web_test_case.php.

References $headers, curlExec(), refreshVariables(), and url().

drupalLogin ( stdClass $account )
protected

Log in a user with the internal browser.

If a user is already logged in, then the current user is logged out before logging in the specified user.

Please note that neither the global $user nor the passed-in user object is populated with data of the logged in user. If you need full access to the user object after logging in, it must be updated manually. If you also need access to the plain-text password of the user (set by drupalCreateUser()), e.g. to log in the same user again, then it must be re-assigned manually. For example:

* // Create a user.
* $account = $this->drupalCreateUser(array());
* $this->drupalLogin($account);
* // Load real user object.
* $pass_raw = $account->pass_raw;
* $account = user_load($account->uid);
* $account->pass_raw = $pass_raw;
*
Parameters
$account User object representing the user to log in.
See Also
drupalCreateUser()

Definition at line 1239 of file drupal_web_test_case.php.

References assertLink(), drupalLogout(), drupalPost(), and t().

drupalLogout ( )
protected

Definition at line 1270 of file drupal_web_test_case.php.

References assertField(), drupalGet(), and t().

Referenced by drupalLogin().

drupalPost | ( |  | $path,
 |  |  | $edit,
 |  |  | $submit,
 |  | array | $options = array(),
 |  | array | $headers = array(),
 |  |  | $form_html_id = NULL,
 |  |  | $extra_post = NULL
 | ) |  |
protected

Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser.

Parameters
$path Location of the post form. Either a Drupal path or an absolute path or NULL to post to the current page. For multi-stage forms you can set the path to NULL and have it post to the last received page. Example:
* // First step in form.
* $edit = array(...);
* $this->drupalPost('some_url', $edit, t('Save'));
*
* // Second step in form.
* $edit = array(...);
* $this->drupalPost(NULL, $edit, t('Save'));
*
Parameters
$edit Field data in an associative array. Changes the current input fields (where possible) to the values indicated. A checkbox can be set to TRUE to be checked and FALSE to be unchecked. Note that when a form contains file upload fields, other fields cannot start with the '@' character.

Multiple select fields can be set using name[] and setting each of the possible values. Example:

* $edit = array();
* $edit['name[]'] = array('value1', 'value2');
*
Parameters
$submit Value of the submit button whose click is to be emulated. For example, t('Save'). The processing of the request depends on this value. For example, a form may have one button with the value t('Save') and another button with the value t('Delete'), and execute different code depending on which one is clicked.

This function can also be called to emulate an Ajax submission. In this case, this value needs to be an array with the following keys:

  • path: A path to submit the form values to for Ajax-specific processing, which is likely different than the $path parameter used for retrieving the initial form. Defaults to 'system/ajax'.
  • triggering_element: If the value for the 'path' key is 'system/ajax' or another generic Ajax processing path, this needs to be set to the name of the element. If the name doesn't identify the element uniquely, then this should instead be an array with a single key/value pair, corresponding to the element name and value. The callback for the generic Ajax processing path uses this to find the #ajax information for the element, including which specific callback to use for processing the request.

This can also be set to NULL in order to emulate an Internet Explorer submission of a form with a single text field, and pressing ENTER in that textfield: under these conditions, no button information is added to the POST data.

Parameters
$options | Options to be forwarded to url().
$headers | An array containing additional HTTP request headers, each formatted as "name: value".
$form_html_id | (optional) HTML ID of the form to be submitted. On some pages there are many identical forms, so just using the value of the submit button is not enough. For example: 'trigger-node-presave-assign-form'. Note that this is not the Drupal $form_id, but rather the HTML ID of the form, which is typically the same thing but with hyphens replacing the underscores.
$extra_post | (optional) A string of additional data to append to the POST submission. This can be used to add POST data for which there are no HTML fields, as is done by drupalPostAJAX(). This string is literally appended to the POST data, so it must already be urlencoded and contain a leading "&" (e.g., "&extra_var1=hello+world&extra_var2=you%26me").

Definition at line 2018 of file drupal_web_test_case.php.

References $headers, $name, $value, DrupalTestCase\assertTrue(), checkForMetaRefresh(), curlExec(), drupal_realpath(), drupalGet(), DrupalTestCase\fail(), getAbsoluteUrl(), getUrl(), handleForm(), parse(), refreshVariables(), t(), DrupalTestCase\verbose(), and xpath().

Referenced by drupalLogin(), and drupalPostAJAX().

drupalPostAJAX | ( |  | $path,
 |  |  | $edit,
 |  |  | $triggering_element,
 |  |  | $ajax_path = NULL,
 |  | array | $options = array(),
 |  | array | $headers = array(),
 |  |  | $form_html_id = NULL,
 |  |  | $ajax_settings = NULL
 | ) |  |
protected

Execute an Ajax submission.

This executes a POST as ajax.js does. It uses the returned JSON data, an array of commands, to update $this->content using equivalent DOM manipulation as is used by ajax.js. It also returns the array of commands.

Parameters
$path | Location of the form containing the Ajax enabled element to test. Can be either a Drupal path or an absolute path or NULL to use the current page.
$edit | Field data in an associative array. Changes the current input fields (where possible) to the values indicated.
$triggering_element | The name of the form element that is responsible for triggering the Ajax functionality to test. May be a string or, if the triggering element is a button, an associative array where the key is the name of the button and the value is the button label. i.e.) array('op' => t('Refresh')).
$ajax_path | (optional) Override the path set by the Ajax settings of the triggering element. In the absence of both the triggering element's Ajax path and $ajax_path 'system/ajax' will be used.
$options | (optional) Options to be forwarded to url().
$headers | (optional) An array containing additional HTTP request headers, each formatted as "name: value". Forwarded to drupalPost().
$form_html_id | (optional) HTML ID of the form to be submitted, use when there is more than one identical form on the same page and the value of the triggering element is not enough to identify the form. Note this is not the Drupal ID of the form but rather the HTML ID of the form.
$ajax_settings | (optional) An array of Ajax settings which if specified will be used in place of the Ajax settings of the triggering element.
Returns
An array of Ajax commands.
See Also
drupalPost()
ajax.js

Definition at line 2146 of file drupal_web_test_case.php.

References $content, $drupalSettings, $headers, $value, drupal_array_merge_deep(), drupal_json_decode(), drupalGet(), drupalPost(), drupalSetContent(), drupalSetSettings(), and xpath().

drupalSetContent | ( | $content,
 |  | $url = 'internal:'
 | ) |
protected

Sets the raw HTML content. This can be useful when a page has been fetched outside of the internal browser and assertions need to be made on the returned page.

A good example would be when testing drupal_http_request(). After fetching the page the content can be set and page elements can be checked to ensure that the function worked properly.

Definition at line 2870 of file drupal_web_test_case.php.

References $content, $url, drupal_json_decode(), and url().

Referenced by curlExec(), and drupalPostAJAX().

drupalSetSettings ( $settings )
protected

Sets the value of the Drupal.settings JavaScript variable for the currently loaded page.

Definition at line 2884 of file drupal_web_test_case.php.

Referenced by drupalPostAJAX().

getAbsoluteUrl ( $path )
protected

Takes a path and returns an absolute path.

Parameters
$path A path from the internal browser content.
Returns
The $path with $base_url prepended, if necessary.

Definition at line 2705 of file drupal_web_test_case.php.

References $base_url.

Referenced by checkForMetaRefresh(), clickLink(), and drupalPost().

getAllOptions ( SimpleXMLElement $element )
protected

Get all option elements, including nested options, in a select.

Parameters
$element The element for which to get the options.
Returns
Option elements in select.

Definition at line 2570 of file drupal_web_test_case.php.

Referenced by assertFieldByXPath(), and handleForm().

getSelectedItem ( SimpleXMLElement $element )
protected

Get the selected value from a select field.

Parameters
$element SimpleXMLElement select element.
Returns
The selected value or FALSE.

Definition at line 3266 of file drupal_web_test_case.php.

References $value.

Referenced by assertFieldByXPath().

getUrl ( )
protected

Get the current URL from the cURL handler.

Returns
The current URL.

Definition at line 2733 of file drupal_web_test_case.php.

References $url.

Referenced by assertUrl(), clickLink(), drupalGet(), drupalPost(), and parse().

handleForm | ( | & | $post,
 |  | & | $edit,
 |  | & | $upload,
 |  |  | $submit,
 |  |  | $form
 | ) |  |
protected

Handle form input related to drupalPost(). Ensure that the specified fields exist and attempt to create POST data in the correct manner for the particular field type.

Parameters
$post | Reference to array of post values.
$edit | Reference to array of edit values to be checked against the form.
$submit | Form submit button value.
$form | Array of form elements.
Returns
Submit value matches a valid submit input in the form.

Definition at line 2358 of file drupal_web_test_case.php.

References $elements, $name, $value, and getAllOptions().

Referenced by drupalPost().

parse ( )
protected

Parse content returned from curlExec using DOM and SimpleXML.

Returns
A SimpleXMLElement or FALSE on failure.

Definition at line 1884 of file drupal_web_test_case.php.

References $elements, drupalGetContent(), DrupalTestCase\fail(), getUrl(), DrupalTestCase\pass(), and t().

Referenced by checkForMetaRefresh(), drupalPost(), and xpath().

preloadRegistry ( )
protected

Preload the registry from the testing site.

This method is called by DrupalWebTestCase::setUp(), and preloads the registry from the testing site to cut down on the time it takes to set up a clean environment for the current test run.

Definition at line 1538 of file drupal_web_test_case.php.

References $row, and Database\getConnection().

Referenced by setUp().

prepareDatabasePrefix ( )
protected

Generates a database prefix for running tests.

The generated database table prefix is used for the Drupal installation being performed for the test. It is also used as user agent HTTP header value by the cURL-based browser of DrupalWebTestCase, which is sent to the Drupal installation of the test. During early Drupal bootstrap, the user agent HTTP header is parsed, and if it matches, all database queries use the database table prefix that has been generated here.

See Also
DrupalWebTestCase::curlInitialize()
drupal_valid_test_ua()
DrupalWebTestCase::setUp()

Definition at line 1298 of file drupal_web_test_case.php.

References db_update().

Referenced by changeDatabasePrefix(), and setUp().

prepareEnvironment ( )
protected

Prepares the current environment for running the test.

Backups various current environment variables and resets them, so they do not interfere with the Drupal site installation in which tests are executed and can be restored in tearDown().

Also sets up new resources for the testing environment, such as the public filesystem and configuration directories.

See Also
DrupalWebTestCase::setUp()
DrupalWebTestCase::tearDown()

Definition at line 1353 of file drupal_web_test_case.php.

References $conf, DrupalTestCase\$databasePrefix, conf_path(), drupal_get_profile(), drupal_register_shutdown_function(), FILE_CREATE_DIRECTORY, FILE_MODIFY_PERMISSIONS, file_prepare_directory(), and variable_get().

Referenced by setUp().

refreshVariables ( )
protected

Refresh the in-memory set of variables. Useful after a page request is made that changes a variable in a different thread.

In other words calling a settings page with $this->drupalPost() with a changed value would update a variable to reflect that change, but in the thread that made the call (thread running the test) the changed variable would not be picked up.

This method clears the variables cache and loads a fresh copy from the database to ensure that the most up-to-date set of variables is loaded.

Definition at line 1605 of file drupal_web_test_case.php.

References $conf, cache_clear_all(), and variable_initialize().

Referenced by drupalGet(), drupalHead(), drupalPost(), resetAll(), and tearDown().

resetAll ( )
protected

Reset all data structures after having enabled new modules.

This method is called by DrupalWebTestCase::setUp() after enabling the requested modules. It must be called again when additional modules are enabled later.

Definition at line 1574 of file drupal_web_test_case.php.

References checkPermissions(), drupal_flush_all_caches(), drupal_get_schema(), drupal_static_reset(), module_list(), and refreshVariables().

Referenced by setUp().

setUp ( )
protected

Sets up a Drupal site for running functional and integration tests.

Generates a random database prefix and installs Drupal with the specified installation profile in DrupalWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Parameters
... List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.
See Also
DrupalWebTestCase::prepareDatabasePrefix()
DrupalWebTestCase::changeDatabasePrefix()
DrupalWebTestCase::prepareEnvironment()

Definition at line 1424 of file drupal_web_test_case.php.

References $conf, $profile, DrupalTestCase\assertTrue(), changeDatabasePrefix(), db_query(), drupal_cron_run(), drupal_install_system(), DRUPAL_ROOT, drupal_save_session(), drupal_set_time_limit(), drupal_static_reset(), install_profile_info(), language_default(), module_enable(), preloadRegistry(), prepareDatabasePrefix(), prepareEnvironment(), resetAll(), t(), user_load(), and variable_set().

tearDown ( )
protected

Delete created files and temporary files directory, delete the tables created by setUp(), and reset the database prefix.

Definition at line 1615 of file drupal_web_test_case.php.

References DrupalTestCase\$originalFileDirectory, $originalShutdownCallbacks, $originalUser, curlClose(), db_drop_table(), db_find_tables(), drupal_register_shutdown_function(), drupal_save_session(), DrupalTestCase\fail(), field_cache_clear(), file_unmanaged_delete_recursive(), format_plural(), Database\getConnectionInfo(), module_implements(), module_list(), DrupalTestCase\pass(), refreshVariables(), Database\removeConnection(), Database\renameConnection(), simpletest_log_read(), t(), and variable_get().

verboseEmail ( $count = 1 )
protected

Outputs to verbose the most recent $count emails sent.

Parameters
$count Optional number of emails to output.

Definition at line 3651 of file drupal_web_test_case.php.

References drupalGetMails(), t(), and DrupalTestCase\verbose().

xpath | ( |  | $xpath,
 |  | array | $arguments = array()
 | ) |  |
protected

Perform an xpath search on the contents of the internal browser. The search is relative to the root element (HTML tag normally) of the page.

Parameters
$xpath The xpath string to use in the search.
Returns
The return value of the xpath search. For details on the xpath string format and return values see the SimpleXML documentation, http://us.php.net/manual/function.simplexml-element-xpath.php.

Definition at line 2548 of file drupal_web_test_case.php.

References buildXPathQuery(), and parse().

Referenced by assertFieldByXPath(), assertFieldChecked(), assertLink(), assertLinkByHref(), assertNoDuplicateIds(), assertNoFieldByXPath(), assertNoFieldChecked(), assertNoLink(), assertNoLinkByHref(), assertNoOptionSelected(), assertNoTitle(), assertOptionSelected(), assertTitle(), checkForMetaRefresh(), clickLink(), drupalPost(), and drupalPostAJAX().

Member Data Documentation

$additionalCurlOptions = array()
protected

Additional cURL options.

DrupalWebTestCase itself never sets this but always obeys what is set.

Definition at line 848 of file drupal_web_test_case.php.

$content
protected

Definition at line 805 of file drupal_web_test_case.php.

Referenced by curlExec(), drupalGetContent(), drupalPostAJAX(), and drupalSetContent().

$cookieFile = NULL
protected

The current cookie file used by cURL.

We do not reuse the cookies in further runs, so we do not need a file but we still need cookie handling, so we set the jar to NULL.

Definition at line 841 of file drupal_web_test_case.php.

$curlHandle
protected

Definition at line 791 of file drupal_web_test_case.php.

$drupalSettings
protected

Definition at line 819 of file drupal_web_test_case.php.

Referenced by drupalGetSettings(), and drupalPostAJAX().

$elements = NULL
protected

Definition at line 826 of file drupal_web_test_case.php.

Referenced by assertFieldChecked(), assertNoFieldChecked(), assertNoOptionSelected(), assertOptionSelected(), handleForm(), and parse().

$generatedTestFiles = FALSE
protected

Whether the files were copied to the test files directory.

Definition at line 887 of file drupal_web_test_case.php.

$headers
protected

Definition at line 798 of file drupal_web_test_case.php.

Referenced by drupalGet(), drupalGetAJAX(), drupalGetHeader(), drupalGetHeaders(), drupalHead(), drupalPost(), and drupalPostAJAX().

$httpauth_credentials = NULL
protected

HTTP authentication credentials (<username>:<password>).

Definition at line 872 of file drupal_web_test_case.php.

Referenced by curlInitialize().

$httpauth_method = CURLAUTH_BASIC
protected

HTTP authentication method

Definition at line 867 of file drupal_web_test_case.php.

Referenced by curlInitialize().

$loggedInUser = FALSE
protected

Definition at line 833 of file drupal_web_test_case.php.

$originalShutdownCallbacks = array()
protected

Definition at line 862 of file drupal_web_test_case.php.

Referenced by tearDown().

$originalUser = NULL
protected

Definition at line 855 of file drupal_web_test_case.php.

Referenced by tearDown().

$plainTextContent
protected

Definition at line 812 of file drupal_web_test_case.php.

$profile = 'standard'
protected

Definition at line 777 of file drupal_web_test_case.php.

Referenced by setUp().

$redirect_count
protected

The number of redirects followed during the handling of a request.

Definition at line 892 of file drupal_web_test_case.php.

$session_id = NULL
protected

The current session ID, if available.

Definition at line 882 of file drupal_web_test_case.php.

$session_name = NULL
protected

The current session name, if available.

Definition at line 877 of file drupal_web_test_case.php.

$url
protected

Definition at line 784 of file drupal_web_test_case.php.

Referenced by curlExec(), drupalSetContent(), and getUrl().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: EntityFieldQuery Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
EntityFieldQuery Class Reference

Public Member Functions

entityCondition ($name, $value, $operator=NULL)
fieldCondition ($field, $column=NULL, $value=NULL, $operator=NULL, $delta_group=NULL, $language_group=NULL)
fieldLanguageCondition ($field, $value=NULL, $operator=NULL, $delta_group=NULL, $language_group=NULL)
fieldDeltaCondition ($field, $value=NULL, $operator=NULL, $delta_group=NULL, $language_group=NULL)
propertyCondition ($column, $value, $operator=NULL)
entityOrderBy ($name, $direction= 'ASC')
fieldOrderBy ($field, $column, $direction= 'ASC')
propertyOrderBy ($column, $direction= 'ASC')
count ()
range ($start=NULL, $length=NULL)
pager ($limit=10, $element=NULL)
tableSort (&$headers)
deleted ($deleted=TRUE)
age ($age)
addTag ($tag)
addMetaData ($key, $object)
execute ()
queryCallback ()
initializePager ()
finishQuery ($select_query, $id_key= 'entity_id')
addCondition (SelectQuery $select_query, $sql_field, $condition, $having=FALSE)

Public Attributes

const RETURN_ALL = NULL
$altered = FALSE
$entityConditions = array()
$fieldConditions = array()
$fieldMetaConditions = array()
$propertyConditions = array()
$order = array()
$range = array()
$pager = array()
$deleted = FALSE
$fields = array()
$count = FALSE
$age = FIELD_LOAD_CURRENT
$tags = array()
$metaData = array()
$orderedResults = array()
$executeCallback = ''

Protected Member Functions

addFieldCondition (&$conditions, $field, $column=NULL, $value=NULL, $operator=NULL, $delta_group=NULL, $language_group=NULL)
propertyQuery ()

Detailed Description

Retrieves entities matching a given set of conditions.

This class allows finding entities based on entity properties (for example, node->changed), field values, and generic entity meta data (bundle, entity type, entity id, and revision ID). It is not possible to query across multiple entity types. For example, there is no facility to find published nodes written by users created in the last hour, as this would require querying both node->status and user->created.

Normally we would not want to have public properties on the object, as that allows the object's state to become inconsistent too easily. However, this class's standard use case involves primarily code that does need to have direct access to the collected properties in order to handle alternate execution routines. We therefore use public properties for simplicity. Note that code that is simply creating and running a field query should still use the appropriate methods to add conditions on the query.

Storage engines are not required to support every type of query. By default, an EntityFieldQueryException will be raised if an unsupported condition is specified or if the query has field conditions or sorts that are stored in different field storage engines. However, this logic can be overridden in hook_entity_query_alter().

Also note that this query does not automatically respect entity access restrictions. Node access control is performed by the SQL storage engine but other storage engines might not do this.

Definition at line 420 of file entity.inc.

Member Function Documentation

addCondition | ( | SelectQuery | $select_query,
 |  |  | $sql_field,
 |  |  | $condition,
 |  |  | $having = FALSE
 | ) |  |

Adds a condition to an already built SelectQuery (internal function).

This is a helper for hook_entity_query() and hook_field_storage_query().

Parameters
SelectQuery | $select_query | A SelectQuery object.
$sql_field | The name of the field.
$condition | A condition as described in EntityFieldQuery::fieldCondition() and EntityFieldQuery::entityCondition().
$having | HAVING or WHERE. This is necessary because SQL can't handle WHERE conditions on aliased columns.

Definition at line 1341 of file entity.inc.

References db_like().

Referenced by _field_sql_storage_query_field_conditions(), field_sql_storage_field_storage_query(), and propertyQuery().

addFieldCondition | ( | & | $conditions,
 |  |  | $field,
 |  |  | $column = NULL,
 |  |  | $value = NULL,
 |  |  | $operator = NULL,
 |  |  | $delta_group = NULL,
 |  |  | $language_group = NULL
 | ) |  |
protected

Adds the given condition to the proper condition array.

Parameters
$conditions | A reference to an array of conditions.
$field | Either a field name or a field array.
$column | A column defined in the hook_field_schema() of this field. If this is omitted then the query will find only entities that have data in this field, using the entity and property conditions if there are any.
$value | The value to test the column value against. In most cases, this is a scalar. For more complex options, it is an array. The meaning of each element in the array is dependent on $operator.
$operator Possible values:
  • '=', '<>', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These operators expect $value to be a literal of the same type as the column.
  • 'IN', 'NOT IN': These operators expect $value to be an array of literals of the same type as the column.
  • 'BETWEEN': This operator expects $value to be an array of two literals of the same type as the column. The operator can be omitted, and will default to 'IN' if the value is an array, or to '=' otherwise.
$delta_group | An arbitrary identifier: conditions in the same group must have the same $delta_group. For example, let's presume a multivalue field which has two columns, 'color' and 'shape', and for entity id 1, there are two values: red/square and blue/circle. Entity ID 1 does not have values corresponding to 'red circle', however if you pass 'red' and 'circle' as conditions, it will appear in the results - by default queries will run against any combination of deltas. By passing the conditions with the same $delta_group it will ensure that only values attached to the same delta are matched, and entity 1 would then be excluded from the results.
$language_group | An arbitrary identifier: conditions in the same group must have the same $language_group.
Returns
EntityFieldQuery The called object.

Definition at line 756 of file entity.inc.

References $value, count(), field_info_field(), and t().

Referenced by fieldCondition(), fieldDeltaCondition(), and fieldLanguageCondition().

addMetaData | ( | $key,
 |  | $object
 | ) |

Adds additional metadata to the query.

Sometimes a query may need to provide additional contextual data for the alter hook. The alter hook implementations may then use that information to decide if and how to take action.

Parameters
$key | The unique identifier for this piece of metadata. Must be a string that follows the same rules as any other PHP identifier.
$object | The additional data to add to the query. May be any valid PHP variable.
Returns
EntityFieldQuery The called object.

Definition at line 1095 of file entity.inc.

addTag ( $tag )

Adds a tag to the query.

Tags are strings that mark a query so that hook_query_alter() and hook_query_TAG_alter() implementations may decide if they wish to alter the query. A query may have any number of tags, and they must be valid PHP identifiers (composed of letters, numbers, and underscores). For example, queries involving nodes that will be displayed for a user need to add the tag 'node_access', so that the node module can add access restrictions to the query.

If an entity field query has tags, it must also have an entity type specified, because the alter hook will need the entity base table.

Parameters
string $tag The tag to add.
Returns
EntityFieldQuery The called object.

Definition at line 1074 of file entity.inc.

age ( $age )

Queries the current or every revision.

Note that this only affects field conditions. Property conditions always apply to the current revision. : Once revision tables have been cleaned up, revisit this.

Parameters
$age
  • FIELD_LOAD_CURRENT (default): Query the most recent revisions for all entities. The results will be keyed by entity type and entity ID.
  • FIELD_LOAD_REVISION: Query all revisions. The results will be keyed by entity type and entity revision ID.
Returns
EntityFieldQuery The called object.

Definition at line 1049 of file entity.inc.

References $age.

Referenced by field_sql_storage_field_storage_query().

count ( )

Sets the query to be a count query only.

Returns
EntityFieldQuery The called object.

Definition at line 930 of file entity.inc.

Referenced by addFieldCondition(), fieldOrderBy(), finishQuery(), and initializePager().

deleted ( $deleted = TRUE )

Filters on the data being deleted.

Parameters
$deleted TRUE to only return deleted data, FALSE to return non-deleted data, EntityFieldQuery::RETURN_ALL to return everything. Defaults to FALSE.
Returns
EntityFieldQuery The called object.

Definition at line 1028 of file entity.inc.

References $deleted.

Referenced by field_sql_storage_field_storage_query().

entityCondition | ( | $name,
 |  | $value,
 |  | $operator = NULL
 | ) |

Adds a condition on entity-generic metadata.

If the overall query contains only entity conditions or ordering, or if there are property conditions, then specifying the entity type is mandatory. If there are field conditions or ordering but no property conditions or ordering, then specifying an entity type is optional. While the field storage engine might support field conditions on more than one entity type, there is no way to query across multiple entity base tables by default. To specify the entity type, pass in 'entity_type' for $name, the type as a string for $value, and no $operator (it's disregarded).

'bundle', 'revision_id' and 'entity_id' have no such restrictions.

Note: The "comment" entity type does not support bundle conditions.

Parameters
$name | 'entity_type', 'bundle', 'revision_id' or 'entity_id'.
$value | The value for $name. In most cases, this is a scalar. For more complex options, it is an array. The meaning of each element in the array is dependent on $operator.
$operator Possible values:
  • '=', '<>', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These operators expect $value to be a literal of the same type as the column.
  • 'IN', 'NOT IN': These operators expect $value to be an array of literals of the same type as the column.
  • 'BETWEEN': This operator expects $value to be an array of two literals of the same type as the column. The operator can be omitted, and will default to 'IN' if the value is an array, or to '=' otherwise.
Returns
EntityFieldQuery The called object.

Definition at line 617 of file entity.inc.

References $name, and $value.

entityOrderBy | ( | $name,
 |  | $direction = 'ASC'
 | ) |

Orders the result set by entity-generic metadata.

If called multiple times, the query will order by each specified column in the order this method is called.

Note: The "comment" and "taxonomy_term" entity types don't support ordering by bundle. For "taxonomy_term", propertyOrderBy('vid') can be used instead.

Parameters
$name | 'entity_type', 'bundle', 'revision_id' or 'entity_id'.
$direction | The direction to sort. Legal values are "ASC" and "DESC".
Returns
EntityFieldQuery The called object.

Definition at line 846 of file entity.inc.

References $name.

execute ( )

Executes the query.

After executing the query, $this->orderedResults will contain a list of the same stub entities in the order returned by the query. This is only relevant if there are multiple entity types in the returned value and a field ordering was requested. In every other case, the returned value contains everything necessary for processing.

Returns
Either a number if count() was called or an array of associative arrays of stub entities. The outer array keys are entity types, and the inner array keys are the relevant ID. (In most cases this will be the entity ID. The only exception is when age=FIELD_LOAD_REVISION is used and field conditions or sorts are present – in this case, the key will be the revision ID.) The entity type will only exist in the outer array if results were found. The inner array values are always stub entities, as returned by entity_create_stub_entity(). To traverse the returned array:
* foreach ($query->execute() as $entity_type => $entities) {
* foreach ($entities as $entity_id => $entity) {
*
Note if the entity type is known, then the following snippet will load the entities found:
* $result = $query->execute();
* if (!empty($result[$my_type])) {
* $entities = entity_load($my_type, array_keys($result[$my_type]));
* }
*

Definition at line 1131 of file entity.inc.

References drupal_alter(), initializePager(), and queryCallback().

fieldCondition | ( | $field,
 |  | $column = NULL,
 |  | $value = NULL,
 |  | $operator = NULL,
 |  | $delta_group = NULL,
 |  | $language_group = NULL
 | ) |

Adds a condition on field values.

Note that entities with empty field values will be excluded from the EntityFieldQuery results when using this method.

Parameters
$field | Either a field name or a field array.
$column | The column that should hold the value to be matched.
$value | The value to test the column value against.
$operator | The operator to be used to test the given value.
$delta_group | An arbitrary identifier: conditions in the same group must have the same $delta_group.
$language_group | An arbitrary identifier: conditions in the same group must have the same $language_group.
Returns
EntityFieldQuery The called object.
See Also
EntityFieldQuery::addFieldCondition
EntityFieldQuery::deleted

Definition at line 657 of file entity.inc.

References $value, and addFieldCondition().

fieldDeltaCondition | ( | $field,
 |  | $value = NULL,
 |  | $operator = NULL,
 |  | $delta_group = NULL,
 |  | $language_group = NULL
 | ) |

Adds a condition on the field delta column.

Parameters
$field | Either a field name or a field array.
$value | The value to test the column value against.
$operator | The operator to be used to test the given value.
$delta_group | An arbitrary identifier: conditions in the same group must have the same $delta_group.
$language_group | An arbitrary identifier: conditions in the same group must have the same $language_group.
Returns
EntityFieldQuery The called object.
See Also
EntityFieldQuery::addFieldCondition
EntityFieldQuery::deleted

Definition at line 709 of file entity.inc.

References $value, and addFieldCondition().

fieldLanguageCondition | ( | $field,
 |  | $value = NULL,
 |  | $operator = NULL,
 |  | $delta_group = NULL,
 |  | $language_group = NULL
 | ) |

Adds a condition on the field language column.

Parameters
$field | Either a field name or a field array.
$value | The value to test the column value against.
$operator | The operator to be used to test the given value.
$delta_group | An arbitrary identifier: conditions in the same group must have the same $delta_group.
$language_group | An arbitrary identifier: conditions in the same group must have the same $language_group.
Returns
EntityFieldQuery The called object.
See Also
EntityFieldQuery::addFieldCondition
EntityFieldQuery::deleted

Definition at line 683 of file entity.inc.

References $value, and addFieldCondition().

fieldOrderBy | ( | $field,
 |  | $column,
 |  | $direction = 'ASC'
 | ) |

Orders the result set by a given field column.

If called multiple times, the query will order by each specified column in the order this method is called. Note that entities with empty field values will be excluded from the EntityFieldQuery results when using this method.

Parameters
$field | Either a field name or a field array.
$column | A column defined in the hook_field_schema() of this field. entity_id and bundle can also be used.
$direction | The direction to sort. Legal values are "ASC" and "DESC".
Returns
EntityFieldQuery The called object.

Definition at line 874 of file entity.inc.

References count(), field_info_field(), and t().

Referenced by tableSort().

finishQuery | ( | $select_query,
 |  | $id_key = 'entity_id'
 | ) |

Finishes the query.

Adds tags, metaData, range and returns the requested list or count.

Parameters
SelectQuery | $select_query | A SelectQuery which has entity_type, entity_id, revision_id and bundle fields added.
$id_key | Which field's values to use as the returned array keys.
Returns
See EntityFieldQuery::execute().

Definition at line 1301 of file entity.inc.

References count(), entity_create_stub_entity(), and range().

Referenced by field_sql_storage_field_storage_query(), and propertyQuery().

initializePager ( )

Gets the total number of results and initializes a pager for the query.

The pager can be disabled by either setting the pager limit to 0, or by setting this query to be a count query.

Definition at line 1276 of file entity.inc.

References $page, count(), pager(), pager_default_initialize(), pager_find_page(), and range().

Referenced by execute().

pager | ( | $limit = 10,
 |  | $element = NULL
 | ) |

Enables a pager for the query.

Parameters
$limit | An integer specifying the number of elements per page. If passed a false value (FALSE, 0, NULL), the pager is disabled.
$element | An optional integer to distinguish between multiple pagers on one page. If not provided, one is automatically calculated.
Returns
EntityFieldQuery The called object.

Definition at line 968 of file entity.inc.

References PagerDefault\$maxElement.

Referenced by initializePager().

propertyCondition | ( | $column,
 |  | $value,
 |  | $operator = NULL
 | ) |

Adds a condition on an entity-specific property.

An $entity_type must be specified by calling EntityFieldCondition::entityCondition('entity_type', $entity_type) before executing the query. Also, by default only entities stored in SQL are supported; however, EntityFieldQuery::executeCallback can be set to handle different entity storage.

Parameters
$column | A column defined in the hook_schema() of the base table of the entity.
$value | The value to test the field against. In most cases, this is a scalar. For more complex options, it is an array. The meaning of each element in the array is dependent on $operator.
$operator Possible values:
  • '=', '<>', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These operators expect $value to be a literal of the same type as the column.
  • 'IN', 'NOT IN': These operators expect $value to be an array of literals of the same type as the column.
  • 'BETWEEN': This operator expects $value to be an array of two literals of the same type as the column. The operator can be omitted, and will default to 'IN' if the value is an array, or to '=' otherwise.
Returns
EntityFieldQuery The called object.

Definition at line 815 of file entity.inc.

References $value.

propertyOrderBy | ( | $column,
 |  | $direction = 'ASC'
 | ) |

Orders the result set by an entity-specific property.

An $entity_type must be specified by calling EntityFieldCondition::entityCondition('entity_type', $entity_type) before executing the query.

If called multiple times, the query will order by each specified column in the order this method is called.

Parameters
$column | The column on which to order.
$direction | The direction to sort. Legal values are "ASC" and "DESC".
Returns
EntityFieldQuery The called object.

Definition at line 915 of file entity.inc.

propertyQuery ( )
protected

Queries entity tables in SQL for property conditions and sorts.

This method is only used if there are no field conditions and sorts.

Returns
See EntityFieldQuery::execute().

Definition at line 1188 of file entity.inc.

References $order, addCondition(), db_select(), drupal_get_schema(), entity_get_info(), finishQuery(), and t().

queryCallback ( )

Determines the query callback to use for this entity query.

Returns
A callback that can be used with call_user_func().

Definition at line 1151 of file entity.inc.

References $executeCallback, and t().

Referenced by execute().

range | ( | $start = NULL,
 |  | $length = NULL
 | ) |

Restricts a query to a given range in the result set.

Parameters
$start | The first entity from the result set to return. If NULL, removes any range directives that are set.
$length | The number of entities to return from the result set.
Returns
EntityFieldQuery The called object.

Definition at line 947 of file entity.inc.

Referenced by finishQuery(), and initializePager().

tableSort ( & $headers )

Enables sortable tables for this query.

Parameters
$headers An EFQ Header array based on which the order clause is added to the query.
Returns
EntityFieldQuery The called object.

Definition at line 993 of file entity.inc.

References $header, $order, fieldOrderBy(), tablesort_get_order(), and tablesort_get_sort().

Member Data Documentation

$age = FIELD_LOAD_CURRENT

Definition at line 542 of file entity.inc.

Referenced by age().

$altered = FALSE

Definition at line 437 of file entity.inc.

$count = FALSE

Definition at line 533 of file entity.inc.

$deleted = FALSE

Query behavior for deleted data.

TRUE to return only deleted data, FALSE to return only non-deleted data, EntityFieldQuery::RETURN_ALL to return everything.

See Also
EntityFieldQuery::deleted()

Definition at line 514 of file entity.inc.

Referenced by deleted().

$entityConditions = array()

Definition at line 446 of file entity.inc.

$executeCallback = ''

Definition at line 578 of file entity.inc.

Referenced by queryCallback().

$fieldConditions = array()

Definition at line 455 of file entity.inc.

$fieldMetaConditions = array()

Definition at line 470 of file entity.inc.

$fields = array()

Definition at line 526 of file entity.inc.

$metaData = array()

Definition at line 560 of file entity.inc.

$order = array()

Definition at line 486 of file entity.inc.

Referenced by propertyQuery(), and tableSort().

$orderedResults = array()

Definition at line 569 of file entity.inc.

$pager = array()

Definition at line 504 of file entity.inc.

$propertyConditions = array()

Definition at line 479 of file entity.inc.

$range = array()

Definition at line 495 of file entity.inc.

$tags = array()

Definition at line 551 of file entity.inc.

const RETURN_ALL = NULL

Indicates that both deleted and non-deleted fields should be returned.

See Also
EntityFieldQuery::deleted()

Definition at line 427 of file entity.inc.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: EntityFieldQueryException Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
EntityFieldQueryException Class Reference
Inheritance diagram for EntityFieldQueryException:
Exception

Detailed Description

Exception thrown by EntityFieldQuery() on unsupported query syntax.

Some storage modules might not support the full range of the syntax for conditions, and will raise an EntityFieldQueryException when an unsupported condition was specified.

Definition at line 390 of file entity.inc.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: EntityMalformedException Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
EntityMalformedException Class Reference
Inheritance diagram for EntityMalformedException:
Exception

Detailed Description

Defines an exception thrown when a malformed entity is passed.

Definition at line 1360 of file entity.inc.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Exception Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Exception Class Reference
Inheritance diagram for Exception:
DatabaseConnectionNotDefinedException DatabaseDriverNotSpecifiedException DatabaseSchemaObjectDoesNotExistException DatabaseSchemaObjectExistsException DatabaseTaskException DatabaseTransactionCommitFailedException DatabaseTransactionExplicitCommitNotAllowedException DatabaseTransactionNameNonUniqueException DatabaseTransactionNoActiveException DatabaseTransactionOutOfOrderException DrupalUpdateException EntityFieldQueryException EntityMalformedException FieldException FieldsOverlapException FileTransferException InvalidMergeQueryException NoFieldsException UpdaterException

Detailed Description

to throw error if a module update fails.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: FieldException Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
FieldException Class Reference
Inheritance diagram for FieldException:
Exception FieldUpdateForbiddenException FieldValidationException

Detailed Description

Base class for all exceptions thrown by Field API functions.

This class has no functionality of its own other than allowing all Field API exceptions to be caught by a single catch block.

Definition at line 13 of file field.module.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: FieldInfo Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Attributes | List of all members
FieldInfo Class Reference

Public Member Functions

flush ()
getFieldMap ()
getFields ()
getInstances ($entity_type=NULL)
getField ($field_name)
getFieldById ($field_id)
getBundleInstances ($entity_type, $bundle)
getBundleExtraFields ($entity_type, $bundle)
prepareField ($field)
prepareInstance ($instance, $field_type)
prepareInstanceWidget ($widget, $field_type)
prepareInstanceDisplay ($display, $field_type)
prepareExtraFields ($extra_fields, $entity_type, $bundle)

Protected Attributes

$fieldMap
$fieldsById = array()
$fieldIdsByName = array()
$loadedAllFields = FALSE
$unknownFields = array()
$bundleInstances = array()
$loadedAllInstances = FALSE
$emptyBundles = array()
$bundleExtraFields = array()

Detailed Description

Provides field and instance definitions for the current runtime environment.

A FieldInfo object is created and statically persisted through the request by the _field_info_field_cache() function. The object properties act as a "static cache" of fields and instances definitions.

The preferred way to access definitions is through the getBundleInstances() method, which keeps cache entries per bundle, storing both fields and instances for a given bundle. Fields used in multiple bundles are duplicated in several cache entries, and are merged into a single list in the memory cache. Cache entries are loaded for bundles as a whole, optimizing memory and CPU usage for the most common pattern of iterating over all instances of a bundle rather than accessing a single instance.

The getFields() and getInstances() methods, which return all existing field and instance definitions, are kept mainly for backwards compatibility, and should be avoided when possible, since they load and persist in memory a potentially large array of information. In many cases, the lightweight getFieldMap() method should be preferred.

Definition at line 29 of file field.info.class.inc.

Member Function Documentation

flush ( )

Clears the "static" and persistent caches.

Definition at line 97 of file field.info.class.inc.

References cache_clear_all().

getBundleExtraFields | ( | $entity_type,
 |  | $bundle
 | ) |

Retrieves the "extra fields" for a bundle.

Parameters
$entity_type | The entity type.
$bundle | The bundle name.
Returns
The array of extra fields.

Definition at line 438 of file field.info.class.inc.

References $info, cache_get(), cache_set(), drupal_alter(), module_invoke_all(), and prepareExtraFields().

getBundleInstances | ( | $entity_type,
 |  | $bundle
 | ) |

Retrieves the instances for a bundle.

The function also populates the corresponding field definitions in the "static" cache.

Parameters
$entity_type | The entity type.
$bundle | The bundle name.
Returns
The array of instance definitions, keyed by field name.

Definition at line 341 of file field.info.class.inc.

References $info, cache_get(), cache_set(), field_read_fields(), field_read_instances(), prepareField(), and prepareInstance().

getField ( $field_name )

Returns a field definition from a field name.

This method only retrieves active, non-deleted fields.

Parameters
$field_name The field name.
Returns
The field definition, or NULL if no field was found.

Definition at line 259 of file field.info.class.inc.

References field_read_field(), and prepareField().

Referenced by getInstances().

getFieldById ( $field_id )

Returns a field definition from a field ID.

This method only retrieves active fields, deleted or not.

Parameters
$field_id The field ID.
Returns
The field definition, or NULL if no field was found.

Definition at line 297 of file field.info.class.inc.

References field_read_fields(), and prepareField().

getFieldMap ( )

Collects a lightweight map of fields across bundles.

Returns
An array keyed by field name. Each value is an array with two entries:
  • type: The field type.
  • bundles: The bundles in which the field appears, as an array with entity types as keys and the array of bundle names as values.

Definition at line 123 of file field.info.class.inc.

References $fieldMap, $row, cache_get(), cache_set(), and db_query().

Referenced by prepareField().

getFields ( )

Returns all active fields, including deleted ones.

Returns
An array of field definitions, keyed by field ID.

Definition at line 160 of file field.info.class.inc.

References $fieldsById, cache_get(), cache_set(), field_read_fields(), and prepareField().

Referenced by getInstances().

getInstances ( $entity_type = NULL )

Retrieves all active, non-deleted instances definitions.

Parameters
$entity_type (optional) The entity type.
Returns
If $entity_type is not set, all instances keyed by entity type and bundle name. If $entity_type is set, all instances for that entity type, keyed by bundle name.

Definition at line 203 of file field.info.class.inc.

References $bundleInstances, cache_get(), cache_set(), field_info_bundles(), field_read_instances(), getField(), getFields(), and prepareInstance().

prepareExtraFields | ( | $extra_fields,
 |  | $entity_type,
 |  | $bundle
 | ) |

Prepares 'extra fields' for the current run-time context.

Parameters
$extra_fields | The array of extra fields, as collected in hook_field_extra_fields().
$entity_type | The entity type.
$bundle | The bundle name.
Returns
The list of extra fields completed for the current runtime context.

Definition at line 631 of file field.info.class.inc.

References $name, entity_get_info(), and field_bundle_settings().

Referenced by getBundleExtraFields().

prepareField ( $field )

Prepares a field definition for the current run-time context.

Parameters
$field The raw field structure as read from the database.
Returns
The field definition completed for the current runtime context.

Definition at line 477 of file field.info.class.inc.

References drupal_alter(), field_info_field_settings(), field_info_storage_settings(), getFieldMap(), and module_invoke().

Referenced by getBundleInstances(), getField(), getFieldById(), and getFields().

prepareInstance | ( | $instance,
 |  | $field_type
 | ) |

Prepares an instance definition for the current run-time context.

Parameters
$instance | The raw instance structure as read from the database.
$field_type | The field type.
Returns
The field instance array completed for the current runtime context.

Definition at line 510 of file field.info.class.inc.

References entity_get_info(), FIELD_BEHAVIOR_DEFAULT, field_behaviors_widget(), field_info_instance_settings(), field_view_mode_settings(), prepareInstanceDisplay(), and prepareInstanceWidget().

Referenced by getBundleInstances(), and getInstances().

prepareInstanceDisplay | ( | $display,
 |  | $field_type
 | ) |

Adapts display specifications to the current run-time context.

Parameters
$display | Display specifications as found in $instance['display']['a_view_mode'].
$field_type | The field type.
Returns
The display properties completed for the current runtime context.

Definition at line 593 of file field.info.class.inc.

References field_info_field_types(), field_info_formatter_settings(), and field_info_formatter_types().

Referenced by prepareInstance().

prepareInstanceWidget | ( | $widget,
 |  | $field_type
 | ) |

Prepares widget properties for the current run-time context.

Parameters
$widget | Widget specifications as found in $instance['widget'].
$field_type | The field type.
Returns
The widget properties completed for the current runtime context.

Definition at line 559 of file field.info.class.inc.

References field_info_field_types(), field_info_widget_settings(), and field_info_widget_types().

Referenced by prepareInstance().

Member Data Documentation

$bundleExtraFields = array()
protected

Definition at line 92 of file field.info.class.inc.

$bundleInstances = array()
protected

Definition at line 71 of file field.info.class.inc.

Referenced by getInstances().

$emptyBundles = array()
protected

Definition at line 85 of file field.info.class.inc.

$fieldIdsByName = array()
protected

Definition at line 50 of file field.info.class.inc.

$fieldMap
protected

Definition at line 36 of file field.info.class.inc.

Referenced by getFieldMap().

$fieldsById = array()
protected

Definition at line 43 of file field.info.class.inc.

Referenced by getFields().

$loadedAllFields = FALSE
protected

Definition at line 57 of file field.info.class.inc.

$loadedAllInstances = FALSE
protected

Definition at line 78 of file field.info.class.inc.

$unknownFields = array()
protected

Definition at line 64 of file field.info.class.inc.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: FieldValidationException Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Public Attributes | List of all members
FieldValidationException Class Reference
Inheritance diagram for FieldValidationException:
FieldException Exception

Public Member Functions

__construct ($errors)

Public Attributes

$errors

Detailed Description

Exception thrown by field_attach_validate() on field validation errors.

Definition at line 11 of file field.attach.inc.

Constructor & Destructor Documentation

__construct ( $errors )

Constructor for FieldValidationException.

Parameters
$errors An array of field validation errors, keyed by field name and delta that contains two keys:
  • 'error': A machine-readable error code string, prefixed by the field module name. A field widget may use this code to decide how to report the error.
  • 'message': A human-readable error message such as to be passed to form_error() for the appropriate form element.

Definition at line 26 of file field.attach.inc.

References $errors, and t().

Member Data Documentation

$errors

Definition at line 12 of file field.attach.inc.

Referenced by __construct().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: FileTransfer Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
FileTransfer Class Reference
Inheritance diagram for FileTransfer:
FileTransferFTP FileTransferLocal FileTransferSSH FileTransferFTPExtension

Public Member Functions

__construct ($jail)
__get ($name)
copyDirectory ($source, $destination)
chmod ($path, $mode, $recursive=FALSE)
createDirectory ($directory)
removeDirectory ($directory)
copyFile ($source, $destination)
removeFile ($destination)
sanitizePath ($path)
isDirectory ($path)
isFile ($path)
findChroot ()
setChroot ()
getSettingsForm ()

Static Public Member Functions

static factory ($jail, $settings)

Protected Member Functions

connect ()
checkPath ($path)
fixRemotePath ($path, $strip_chroot=TRUE)
copyDirectoryJailed ($source, $destination)
createDirectoryJailed ($directory)
removeDirectoryJailed ($directory)
copyFileJailed ($source, $destination)
removeFileJailed ($destination)

Protected Attributes

$username
$password
$hostname = 'localhost'
$port

Detailed Description

Definition at line 12 of file filetransfer.inc.

Constructor & Destructor Documentation

__construct ( $jail )

The constructor for the UpdateConnection class. This method is also called from the classes that extend this class and override this method.

Definition at line 22 of file filetransfer.inc.

Member Function Documentation

__get ( $name )

Implementation of the magic __get() method.

If the connection isn't set to anything, this will call the connect() method and set it to and return the result; afterwards, the connection will be returned directly without using this method.

Definition at line 51 of file filetransfer.inc.

References $name, connect(), and setChroot().

checkPath ( $path )
finalprotected

Checks that the path is inside the jail and throws an exception if not.

Parameters
$path A path to check against the jail.

Definition at line 157 of file filetransfer.inc.

References drupal_realpath(), and fixRemotePath().

Referenced by chmod(), copyDirectory(), copyFile(), createDirectory(), removeDirectory(), and removeFile().

chmod | ( | $path,
 |  | $mode,
 |  | $recursive = FALSE
 | ) |
final
See Also
http://php.net/chmod
Parameters
string | $path
long | $mode
bool | $recursive

Definition at line 90 of file filetransfer.inc.

References checkPath(), fixRemotePath(), and sanitizePath().

Referenced by FileTransferLocal\chmodJailed().

connect ( )
abstractprotected

Connect to the server.

Referenced by __get().

copyDirectory | ( | $source,
 |  | $destination
 | ) |
final

Copies a directory.

Parameters
$source | The source path.
$destination | The destination path.

Definition at line 76 of file filetransfer.inc.

References checkPath(), copyDirectoryJailed(), fixRemotePath(), and sanitizePath().

copyDirectoryJailed | ( | $source,
 |  | $destination
 | ) |
protected

Copies a directory.

We need a separate method to make the $destination is in the jail.

Parameters
$source | The source path.
$destination | The destination path.

Definition at line 212 of file filetransfer.inc.

References copyFile(), createDirectory(), drupal_basename(), and isDirectory().

Referenced by copyDirectory().

copyFile | ( | $source,
 |  | $destination
 | ) |
final

Copies a file.

Parameters
$source | The source file.
$destination | The destination file.

Definition at line 132 of file filetransfer.inc.

References checkPath(), copyFileJailed(), fixRemotePath(), and sanitizePath().

Referenced by copyDirectoryJailed().

copyFileJailed | ( | $source,
 |  | $destination
 | ) |
abstractprotected

Copies a file.

Parameters
$source | The source file.
$destination | The destination file.

Referenced by copyFile().

createDirectory ( $directory )
final

Creates a directory.

Parameters
$directory The directory to be created.

Definition at line 106 of file filetransfer.inc.

References checkPath(), createDirectoryJailed(), and fixRemotePath().

Referenced by copyDirectoryJailed().

createDirectoryJailed ( $directory )
abstractprotected

Creates a directory.

Parameters
$directory The directory to be created.

Referenced by createDirectory().

static factory | ( | $jail,
 |  | $settings
 | ) |
static

Classes that extend this class must override the factory() static method.

Parameters
string | $jail | The full path where all file operations performed by this object will be restricted to. This prevents the FileTransfer classes from being able to touch other parts of the filesystem.
array | $settings | An array of connection settings for the FileTransfer subclass. If the getSettingsForm() method uses any nested settings, the same structure will be assumed here.
Returns
object New instance of the appropriate FileTransfer subclass.

Definition at line 40 of file filetransfer.inc.

findChroot ( )

Return the chroot property for this connection.

It does this by moving up the tree until it finds itself. If successful, it will return the chroot, otherwise FALSE.

Returns
The chroot path for this connection or FALSE.

Definition at line 291 of file filetransfer.inc.

References drupal_basename(), fixRemotePath(), and isFile().

Referenced by setChroot().

fixRemotePath | ( | $path,
 |  | $strip_chroot = TRUE
 | ) |
finalprotected

Returns a modified path suitable for passing to the server. If a path is a windows path, makes it POSIX compliant by removing the drive letter. If $this->chroot has a value, it is stripped from the path to allow for chroot'd filetransfer systems.

Parameters
$path
$strip_chroot
Returns
string

Definition at line 177 of file filetransfer.inc.

References sanitizePath().

Referenced by checkPath(), chmod(), copyDirectory(), copyFile(), createDirectory(), findChroot(), removeDirectory(), removeFile(), and setChroot().

getSettingsForm ( )

Returns a form to collect connection settings credentials.

Implementing classes can either extend this form with fields collecting the specific information they need, or override it entirely.

Definition at line 329 of file filetransfer.inc.

References t().

isDirectory ( $path )
abstract

Checks if a particular path is a directory

Parameters
$path The path to check
Returns
boolean

Referenced by copyDirectoryJailed().

isFile ( $path )
abstract

Checks if a particular path is a file (not a directory).

Parameters
$path The path to check
Returns
boolean

Referenced by findChroot().

removeDirectory ( $directory )
final

Removes a directory.

Parameters
$directory The directory to be removed.

Definition at line 118 of file filetransfer.inc.

References checkPath(), fixRemotePath(), and removeDirectoryJailed().

Referenced by FileTransferFTPExtension\removeDirectoryJailed().

removeDirectoryJailed ( $directory )
abstractprotected

Removes a directory.

Parameters
$directory The directory to be removed.

Referenced by removeDirectory().

removeFile ( $destination )
final

Removes a file.

Parameters
$destination The destination file to be removed.

Definition at line 145 of file filetransfer.inc.

References checkPath(), fixRemotePath(), and removeFileJailed().

Referenced by FileTransferFTPExtension\removeDirectoryJailed().

removeFileJailed ( $destination )
abstractprotected

Removes a file.

Parameters
$destination The destination file to be removed.

Referenced by removeFile().

sanitizePath ( $path )

Changes backslashes to slashes, also removes a trailing slash.

Parameters
string $path
Returns
string

Definition at line 194 of file filetransfer.inc.

Referenced by chmod(), copyDirectory(), copyFile(), and fixRemotePath().

setChroot ( )

Sets the chroot and changes the jail to match the correct path scheme

Definition at line 318 of file filetransfer.inc.

References findChroot(), and fixRemotePath().

Referenced by __get().

Member Data Documentation

$hostname = 'localhost'
protected

Definition at line 15 of file filetransfer.inc.

Referenced by FileTransferFTP\__construct(), FileTransferSSH\__construct(), FileTransferFTP\factory(), and FileTransferSSH\factory().

$password
protected

Definition at line 14 of file filetransfer.inc.

Referenced by FileTransferFTP\__construct(), FileTransferSSH\__construct(), FileTransferFTP\factory(), and FileTransferSSH\factory().

$port
protected

Definition at line 16 of file filetransfer.inc.

Referenced by FileTransferFTP\__construct(), FileTransferSSH\__construct(), FileTransferFTP\factory(), and FileTransferSSH\factory().

$username
protected

Definition at line 13 of file filetransfer.inc.

Referenced by FileTransferFTP\__construct(), FileTransferSSH\__construct(), FileTransferFTP\factory(), and FileTransferSSH\factory().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: FileTransferChmodInterface Interface Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
FileTransferChmodInterface Interface Reference
Inheritance diagram for FileTransferChmodInterface:
FileTransferFTPExtension FileTransferLocal FileTransferSSH

Public Member Functions

chmodJailed ($path, $mode, $recursive)

Detailed Description

A FileTransfer Class implementing this interface can be used to chmod files.

Definition at line 376 of file filetransfer.inc.

Member Function Documentation

chmodJailed | ( | $path,
 |  | $mode,
 |  | $recursive
 | ) |

Changes the permissions of the file / directory specified in $path

Parameters
string | $path | Path to change permissions of.
long | $mode | The new file permission mode to be passed to chmod().
boolean | $recursive | Pass TRUE to recursively chmod the entire directory specified in $path.

Implemented in FileTransferFTPExtension, FileTransferSSH, and FileTransferLocal.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: FileTransferException Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Public Attributes | List of all members
FileTransferException Class Reference
Inheritance diagram for FileTransferException:
Exception

Public Member Functions

__construct ($message, $code=0, $arguments=array())

Public Attributes

$arguments

Detailed Description

FileTransferException class.

Definition at line 363 of file filetransfer.inc.

Constructor & Destructor Documentation

__construct | ( | $message,
 |  | $code = 0,
 |  | $arguments = array()
 | ) |

Definition at line 366 of file filetransfer.inc.

References $arguments.

Member Data Documentation

$arguments

Definition at line 364 of file filetransfer.inc.

Referenced by __construct().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: FileTransferFTP Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Static Public Member Functions | List of all members
FileTransferFTP Class Reference
Inheritance diagram for FileTransferFTP:
FileTransfer FileTransferFTPExtension

Public Member Functions

__construct ($jail, $username, $password, $hostname, $port)
getSettingsForm ()
- Public Member Functions inherited from FileTransfer
__construct ($jail)
__get ($name)
copyDirectory ($source, $destination)
chmod ($path, $mode, $recursive=FALSE)
createDirectory ($directory)
removeDirectory ($directory)
copyFile ($source, $destination)
removeFile ($destination)
sanitizePath ($path)
isDirectory ($path)
isFile ($path)
findChroot ()
setChroot ()
getSettingsForm ()

Static Public Member Functions

static | factory ($jail, $settings)
- Static Public Member Functions inherited from FileTransfer
static | factory ($jail, $settings)

Additional Inherited Members

- Protected Member Functions inherited from FileTransfer
connect ()
checkPath ($path)
fixRemotePath ($path, $strip_chroot=TRUE)
copyDirectoryJailed ($source, $destination)
createDirectoryJailed ($directory)
removeDirectoryJailed ($directory)
copyFileJailed ($source, $destination)
removeFileJailed ($destination)
- Protected Attributes inherited from FileTransfer
$username
$password
$hostname = 'localhost'
$port

Detailed Description

Base class for FTP implementations.

Definition at line 6 of file ftp.inc.

Constructor & Destructor Documentation

__construct | ( | $jail,
 |  | $username,
 |  | $password,
 |  | $hostname,
 |  | $port
 | ) |

Definition at line 8 of file ftp.inc.

References FileTransfer\$hostname, FileTransfer\$password, FileTransfer\$port, and FileTransfer\$username.

Member Function Documentation

static factory | ( | $jail,
 |  | $settings
 | ) |
static

Return an object which can implement the FTP protocol.

Parameters
string | $jail
array | $settings
Returns
FileTransferFTP The appropriate FileTransferFTP subclass based on the available options. If the FTP PHP extension is available, use it.

Definition at line 25 of file ftp.inc.

References FileTransfer\$hostname, FileTransfer\$password, FileTransfer\$port, and FileTransfer\$username.

getSettingsForm ( )

Returns the form to configure the FileTransfer class for FTP.

Definition at line 44 of file ftp.inc.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: FileTransferFTPExtension Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Member Functions | List of all members
FileTransferFTPExtension Class Reference
Inheritance diagram for FileTransferFTPExtension:
FileTransferFTP FileTransferChmodInterface FileTransfer

Public Member Functions

connect ()
isDirectory ($path)
isFile ($path)
chmodJailed ($path, $mode, $recursive)
- Public Member Functions inherited from FileTransferFTP
__construct ($jail, $username, $password, $hostname, $port)
getSettingsForm ()
- Public Member Functions inherited from FileTransfer
__construct ($jail)
__get ($name)
copyDirectory ($source, $destination)
chmod ($path, $mode, $recursive=FALSE)
createDirectory ($directory)
removeDirectory ($directory)
copyFile ($source, $destination)
removeFile ($destination)
sanitizePath ($path)
isDirectory ($path)
isFile ($path)
findChroot ()
setChroot ()
getSettingsForm ()

Protected Member Functions

copyFileJailed ($source, $destination)
createDirectoryJailed ($directory)
removeDirectoryJailed ($directory)
removeFileJailed ($destination)
- Protected Member Functions inherited from FileTransfer
connect ()
checkPath ($path)
fixRemotePath ($path, $strip_chroot=TRUE)
copyDirectoryJailed ($source, $destination)
createDirectoryJailed ($directory)
removeDirectoryJailed ($directory)
copyFileJailed ($source, $destination)
removeFileJailed ($destination)

Additional Inherited Members

- Static Public Member Functions inherited from FileTransferFTP
static | factory ($jail, $settings)
- Static Public Member Functions inherited from FileTransfer
static | factory ($jail, $settings)
- Protected Attributes inherited from FileTransfer
$username
$password
$hostname = 'localhost'
$port

Detailed Description

Definition at line 51 of file ftp.inc.

Member Function Documentation

chmodJailed | ( | $path,
 |  | $mode,
 |  | $recursive
 | ) |

Changes the permissions of the file / directory specified in $path

Parameters
string | $path | Path to change permissions of.
long | $mode | The new file permission mode to be passed to chmod().
boolean | $recursive | Pass TRUE to recursively chmod the entire directory specified in $path.

Implements FileTransferChmodInterface.

Definition at line 123 of file ftp.inc.

References isDirectory().

connect ( )

Definition at line 53 of file ftp.inc.

copyFileJailed | ( | $source,
 |  | $destination
 | ) |
protected

Definition at line 64 of file ftp.inc.

createDirectoryJailed ( $directory )
protected

Definition at line 70 of file ftp.inc.

isDirectory ( $path )

Definition at line 109 of file ftp.inc.

Referenced by chmodJailed().

isFile ( $path )

Definition at line 119 of file ftp.inc.

removeDirectoryJailed ( $directory )
protected

Definition at line 76 of file ftp.inc.

References FileTransfer\removeDirectory(), and FileTransfer\removeFile().

removeFileJailed ( $destination )
protected

Definition at line 103 of file ftp.inc.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: FileTransferLocal Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
FileTransferLocal Class Reference
Inheritance diagram for FileTransferLocal:
FileTransfer FileTransferChmodInterface

Public Member Functions

connect ()
isDirectory ($path)
isFile ($path)
chmodJailed ($path, $mode, $recursive)
- Public Member Functions inherited from FileTransfer
__construct ($jail)
__get ($name)
copyDirectory ($source, $destination)
chmod ($path, $mode, $recursive=FALSE)
createDirectory ($directory)
removeDirectory ($directory)
copyFile ($source, $destination)
removeFile ($destination)
sanitizePath ($path)
isDirectory ($path)
isFile ($path)
findChroot ()
setChroot ()
getSettingsForm ()

Static Public Member Functions

static | factory ($jail, $settings)
- Static Public Member Functions inherited from FileTransfer
static | factory ($jail, $settings)

Protected Member Functions

copyFileJailed ($source, $destination)
createDirectoryJailed ($directory)
removeDirectoryJailed ($directory)
removeFileJailed ($file)
- Protected Member Functions inherited from FileTransfer
connect ()
checkPath ($path)
fixRemotePath ($path, $strip_chroot=TRUE)
copyDirectoryJailed ($source, $destination)
createDirectoryJailed ($directory)
removeDirectoryJailed ($directory)
copyFileJailed ($source, $destination)
removeFileJailed ($destination)

Additional Inherited Members

- Protected Attributes inherited from FileTransfer
$username
$password
$hostname = 'localhost'
$port

Detailed Description

The local connection class for copying files as the httpd user.

Definition at line 6 of file local.inc.

Member Function Documentation

chmodJailed | ( | $path,
 |  | $mode,
 |  | $recursive
 | ) |

Changes the permissions of the file / directory specified in $path

Parameters
string | $path | Path to change permissions of.
long | $mode | The new file permission mode to be passed to chmod().
boolean | $recursive | Pass TRUE to recursively chmod the entire directory specified in $path.

Implements FileTransferChmodInterface.

Definition at line 64 of file local.inc.

References FileTransfer\chmod().

connect ( )

Definition at line 8 of file local.inc.

copyFileJailed | ( | $source,
 |  | $destination
 | ) |
protected

Definition at line 16 of file local.inc.

createDirectoryJailed ( $directory )
protected

Definition at line 22 of file local.inc.

static factory | ( | $jail,
 |  | $settings
 | ) |
static

Definition at line 12 of file local.inc.

isDirectory ( $path )

Definition at line 56 of file local.inc.

isFile ( $path )

Definition at line 60 of file local.inc.

removeDirectoryJailed ( $directory )
protected

Definition at line 28 of file local.inc.

References drupal_rmdir(), and drupal_unlink().

removeFileJailed ( $file )
protected

Definition at line 50 of file local.inc.

References drupal_unlink().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: FileTransferSSH Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
FileTransferSSH Class Reference
Inheritance diagram for FileTransferSSH:
FileTransfer FileTransferChmodInterface

Public Member Functions

__construct ($jail, $username, $password, $hostname="localhost", $port=22)
connect ()
isDirectory ($path)
isFile ($path)
chmodJailed ($path, $mode, $recursive)
getSettingsForm ()
- Public Member Functions inherited from FileTransfer
__construct ($jail)
__get ($name)
copyDirectory ($source, $destination)
chmod ($path, $mode, $recursive=FALSE)
createDirectory ($directory)
removeDirectory ($directory)
copyFile ($source, $destination)
removeFile ($destination)
sanitizePath ($path)
isDirectory ($path)
isFile ($path)
findChroot ()
setChroot ()
getSettingsForm ()

Static Public Member Functions

static | factory ($jail, $settings)
- Static Public Member Functions inherited from FileTransfer
static | factory ($jail, $settings)

Protected Member Functions

copyFileJailed ($source, $destination)
copyDirectoryJailed ($source, $destination)
createDirectoryJailed ($directory)
removeDirectoryJailed ($directory)
removeFileJailed ($destination)
- Protected Member Functions inherited from FileTransfer
connect ()
checkPath ($path)
fixRemotePath ($path, $strip_chroot=TRUE)
copyDirectoryJailed ($source, $destination)
createDirectoryJailed ($directory)
removeDirectoryJailed ($directory)
copyFileJailed ($source, $destination)
removeFileJailed ($destination)

Additional Inherited Members

- Protected Attributes inherited from FileTransfer
$username
$password
$hostname = 'localhost'
$port

Detailed Description

The SSH connection class for the update module.

Definition at line 6 of file ssh.inc.

Constructor & Destructor Documentation

__construct | ( | $jail,
 |  | $username,
 |  | $password,
 |  | $hostname = "localhost",
 |  | $port = 22
 | ) |

Definition at line 8 of file ssh.inc.

References FileTransfer\$hostname, FileTransfer\$password, FileTransfer\$port, and FileTransfer\$username.

Member Function Documentation

chmodJailed | ( | $path,
 |  | $mode,
 |  | $recursive
 | ) |

Changes the permissions of the file / directory specified in $path

Parameters
string | $path | Path to change permissions of.
long | $mode | The new file permission mode to be passed to chmod().
boolean | $recursive | Pass TRUE to recursively chmod the entire directory specified in $path.

Implements FileTransferChmodInterface.

Definition at line 93 of file ssh.inc.

connect ( )

Definition at line 16 of file ssh.inc.

copyDirectoryJailed | ( | $source,
 |  | $destination
 | ) |
protected

Definition at line 40 of file ssh.inc.

copyFileJailed | ( | $source,
 |  | $destination
 | ) |
protected

Definition at line 34 of file ssh.inc.

createDirectoryJailed ( $directory )
protected

Definition at line 46 of file ssh.inc.

static factory | ( | $jail,
 |  | $settings
 | ) |
static

Definition at line 26 of file ssh.inc.

References FileTransfer\$hostname, FileTransfer\$password, FileTransfer\$port, and FileTransfer\$username.

getSettingsForm ( )

Returns the form to configure the FileTransfer class for SSH.

Definition at line 103 of file ssh.inc.

isDirectory ( $path )

WARNING: This is untested. It is not currently used, but should do the trick.

Definition at line 67 of file ssh.inc.

References $output.

isFile ( $path )

Definition at line 80 of file ssh.inc.

References $output.

removeDirectoryJailed ( $directory )
protected

Definition at line 52 of file ssh.inc.

removeFileJailed ( $destination )
protected

Definition at line 58 of file ssh.inc.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: InsertQuery_pgsql Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
InsertQuery_pgsql Class Reference
Inheritance diagram for InsertQuery_pgsql:
InsertQuery Query QueryPlaceholderInterface

Public Member Functions

execute ()
__toString ()
- Public Member Functions inherited from InsertQuery
__construct ($connection, $table, array $options=array())
fields (array $fields, array $values=array())
values (array $values)
useDefaults (array $fields)
from (SelectQueryInterface $query)
execute ()
__toString ()
preExecute ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Additional Inherited Members

- Protected Member Functions inherited from Query
execute ()
- Protected Attributes inherited from InsertQuery
$table
$insertFields = array()
$defaultFields = array()
$insertValues = array()
$fromQuery
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Detailed Description

Definition at line 14 of file query.inc.

Member Function Documentation

__toString ( )

Definition at line 105 of file query.inc.

References Query\$comments, and InsertQuery\$fromQuery.

execute ( )

Definition at line 16 of file query.inc.

References Query\$queryOptions, $value, InsertQuery\preExecute(), Database\RETURN_INSERT_ID, and Database\RETURN_NULL.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: MailSystemInterface Interface Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
MailSystemInterface Interface Reference
Inheritance diagram for MailSystemInterface:
DefaultMailSystem TestingMailSystem TestingMailSystem

Public Member Functions

format (array $message)
mail (array $message)

Detailed Description

An interface for pluggable mail back-ends.

Definition at line 292 of file mail.inc.

Member Function Documentation

format ( array $message )

Format a message composed by drupal_mail() prior sending.

Parameters
$message A message array, as described in hook_mail_alter().
Returns
The formatted $message.

Implemented in DefaultMailSystem.

mail ( array $message )

Send a message composed by drupal_mail().

Parameters
$message Message array with at least the following elements:
  • id: A unique identifier of the e-mail type. Examples: 'contact_user_copy', 'user_password_reset'.
  • to: The mail address or addresses where the message will be sent to. The formatting of this string will be validated with the PHP e-mail validation filter. Some examples are:
    • user@.nosp@m.exam.nosp@m.ple.c.nosp@m.om
    • user@.nosp@m.exam.nosp@m.ple.c.nosp@m.om, anoth.nosp@m.erus.nosp@m.er@ex.nosp@m.ampl.nosp@m.e.com
    • User user@.nosp@m.exam.nosp@m.ple.c.nosp@m.om
    • User user@.nosp@m.exam.nosp@m.ple.c.nosp@m.om, Another User anoth.nosp@m.erus.nosp@m.er@ex.nosp@m.ampl.nosp@m.e.com
  • subject: Subject of the e-mail to be sent. This must not contain any newline characters, or the mail may not be sent properly.
  • body: Message to be sent. Accepts both CRLF and LF line-endings. E-mail bodies must be wrapped. You can use drupal_wrap_mail() for smart plain text wrapping.
  • headers: Associative array containing all additional mail headers not defined by one of the other parameters. PHP's mail() looks for Cc and Bcc headers and sends the mail to addresses in these headers too.
Returns
TRUE if the mail was successfully accepted for delivery, otherwise FALSE.

Implemented in TestingMailSystem, and DefaultMailSystem.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: ModuleUpdater Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Static Public Member Functions | List of all members
ModuleUpdater Class Reference
Inheritance diagram for ModuleUpdater:
Updater DrupalUpdaterInterface

Public Member Functions

getInstallDirectory ()
isInstalled ()
getSchemaUpdates ()
postInstallTasks ()
postUpdateTasks ()
- Public Member Functions inherited from Updater
__construct ($source)
update (&$filetransfer, $overrides=array())
install (&$filetransfer, $overrides=array())
prepareInstallDirectory (&$filetransfer, $directory)
makeWorldReadable (&$filetransfer, $path, $recursive=TRUE)
makeBackup (&$filetransfer, $from, $to)
getBackupDir ()
postUpdate ()
postInstall ()
postInstallTasks ()
postUpdateTasks ()
- Public Member Functions inherited from DrupalUpdaterInterface
postInstall ()
postUpdate ()

Static Public Member Functions

static | canUpdateDirectory ($directory)
static | canUpdate ($project_name)
- Static Public Member Functions inherited from Updater
static | factory ($source)
static | getUpdaterFromDirectory ($directory)
static | findInfoFile ($directory)
static | getProjectName ($directory)
static | getProjectTitle ($directory)
- Static Public Member Functions inherited from DrupalUpdaterInterface
static | getProjectName ($directory)

Additional Inherited Members

- Public Attributes inherited from Updater
$source
- Protected Member Functions inherited from Updater
getInstallArgs ($overrides=array())

Detailed Description

Class for updating modules using FileTransfer classes via authorize.php.

Definition at line 12 of file system.updater.inc.

Member Function Documentation

static canUpdate ( $project_name )
static

Definition at line 47 of file system.updater.inc.

References drupal_get_path().

static canUpdateDirectory ( $directory )
static

Determine if the Updater can handle the project provided in $directory.

Parameters
string $directory
Returns
bool TRUE if the project is installed, FALSE if not.

Implements DrupalUpdaterInterface.

Definition at line 40 of file system.updater.inc.

References file_scan_directory().

getInstallDirectory ( )

Return the directory where a module should be installed.

If the module is already installed, drupal_get_path() will return a valid path and we should install it there (although we need to use an absolute path, so we prepend DRUPAL_ROOT). If we're installing a new module, we always want it to go into sites/all/modules, since that's where all the documentation recommends users install their modules, and there's no way that can conflict on a multi-site installation, since the Update manager won't let you install a new module if it's already found on your system, and if there was a copy in sites/all, we'd see it.

Implements DrupalUpdaterInterface.

Definition at line 26 of file system.updater.inc.

References drupal_get_path(), DRUPAL_ROOT, and name.

getSchemaUpdates ( )

Return available database schema updates one a new version is installed.

Definition at line 54 of file system.updater.inc.

References drupal_get_schema_versions(), DRUPAL_ROOT, module_load_include(), and update_get_update_list().

isInstalled ( )

Checks if the project is installed.

Returns
bool

Implements DrupalUpdaterInterface.

Definition at line 36 of file system.updater.inc.

References drupal_get_path(), and name.

postInstallTasks ( )

Returns a list of post install actions.

Definition at line 79 of file system.updater.inc.

References l(), and t().

postUpdateTasks ( )

Definition at line 87 of file system.updater.inc.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: NodeController Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Protected Member Functions | List of all members
NodeController Class Reference
Inheritance diagram for NodeController:
DrupalDefaultEntityController DrupalEntityControllerInterface

Protected Member Functions

attachLoad (&$nodes, $revision_id=FALSE)
buildQuery ($ids, $conditions=array(), $revision_id=FALSE)
- Protected Member Functions inherited from DrupalDefaultEntityController
buildQuery ($ids, $conditions=array(), $revision_id=FALSE)
attachLoad (&$queried_entities, $revision_id=FALSE)
cacheGet ($ids, $conditions=array())
cacheSet ($entities)

Additional Inherited Members

- Public Member Functions inherited from DrupalDefaultEntityController
__construct ($entityType)
resetCache (array $ids=NULL)
load ($ids=array(), $conditions=array())
- Protected Attributes inherited from DrupalDefaultEntityController
$entityCache
$entityType
$entityInfo
$hookLoadArguments
$idKey
$revisionKey
$revisionTable
$cache

Detailed Description

Controller class for nodes.

This extends the DrupalDefaultEntityController class, adding required special handling for node objects.

Definition at line 4130 of file node.module.

Member Function Documentation

attachLoad | ( | & | $nodes,
 |  |  | $revision_id = FALSE
 | ) |  |
protected

Definition at line 4132 of file node.module.

References node_hook(), and node_type_get_base().

buildQuery | ( | $ids,
 |  | $conditions = array(),
 |  | $revision_id = FALSE
 | ) |
protected

Definition at line 4154 of file node.module.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: PagerDefault Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
PagerDefault Class Reference
Inheritance diagram for PagerDefault:
SelectQueryExtender SelectQueryInterface QueryConditionInterface QueryAlterableInterface QueryExtendableInterface QueryPlaceholderInterface

Public Member Functions

__construct (SelectQueryInterface $query, DatabaseConnection $connection)
execute ()
setCountQuery (SelectQueryInterface $query)
getCountQuery ()
limit ($limit=10)
element ($element)
- Public Member Functions inherited from SelectQueryExtender
__construct (SelectQueryInterface $query, DatabaseConnection $connection)
uniqueIdentifier ()
nextPlaceholder ()
addTag ($tag)
hasTag ($tag)
hasAllTags ()
hasAnyTag ()
addMetaData ($key, $object)
getMetaData ($key)
condition ($field, $value=NULL, $operator=NULL)
& conditions ()
arguments ()
where ($snippet, $args=array())
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
havingCondition ($field, $value=NULL, $operator= '=')
& havingConditions ()
havingArguments ()
having ($snippet, $args=array())
havingCompile (DatabaseConnection $connection)
extend ($extender_name)
& getFields ()
& getExpressions ()
& getOrderBy ()
& getGroupBy ()
& getTables ()
& getUnion ()
getArguments (QueryPlaceholderInterface $queryPlaceholder=NULL)
isPrepared ()
preExecute (SelectQueryInterface $query=NULL)
execute ()
distinct ($distinct=TRUE)
addField ($table_alias, $field, $alias=NULL)
fields ($table_alias, array $fields=array())
addExpression ($expression, $alias=NULL, $arguments=array())
join ($table, $alias=NULL, $condition=NULL, $arguments=array())
innerJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
leftJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
rightJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
addJoin ($type, $table, $alias=NULL, $condition=NULL, $arguments=array())
orderBy ($field, $direction= 'ASC')
orderRandom ()
range ($start=NULL, $length=NULL)
union (SelectQueryInterface $query, $type= '')
groupBy ($field)
forUpdate ($set=TRUE)
countQuery ()
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
__toString ()
__clone ()
__call ($method, $args)

Static Public Attributes

static $maxElement = 0

Protected Member Functions

ensureElement ()

Protected Attributes

$limit = 10
$element = NULL
$customCountQuery = FALSE
- Protected Attributes inherited from SelectQueryExtender
$query
$connection
$uniqueIdentifier
$placeholder = 0

Detailed Description

Query extender for pager queries.

This is the "default" pager mechanism. It creates a paged query with a fixed number of entries per page.

Definition at line 15 of file pager.inc.

Constructor & Destructor Documentation

__construct | ( | SelectQueryInterface | $query,
 |  | DatabaseConnection | $connection
 | ) |  |

Definition at line 45 of file pager.inc.

References SelectQueryExtender\addTag().

Member Function Documentation

element ( $element )

Specify the element ID for this pager query.

The element is used to differentiate different pager queries on the same page so that they may be operated independently. If you do not specify an element, every pager query on the page will get a unique element. If for whatever reason you want to explicitly define an element for a given query, you may do so here.

Setting the element here also increments the static $maxElement counter, which is used for determining the $element when there's none specified.

Note that no collision detection is done when setting an element ID explicitly, so it is possible for two pagers to end up using the same ID if both are set explicitly.

Parameters
$element

Definition at line 160 of file pager.inc.

References $element.

Referenced by ensureElement(), and execute().

ensureElement ( )
protected

Ensure that there is an element associated with this query. If an element was not specified previously, then the value of the $maxElement counter is taken, after which the counter is incremented.

After running this method, access $this->element to get the element for this query.

Definition at line 90 of file pager.inc.

References element().

Referenced by execute().

execute ( )

Override the execute method.

Before we run the query, we need to add pager-based range() instructions to it.

Definition at line 59 of file pager.inc.

References element(), ensureElement(), getCountQuery(), limit(), pager_default_initialize(), SelectQueryExtender\preExecute(), and SelectQueryExtender\range().

getCountQuery ( )

Retrieve the count query for this pager.

The count query may be specified manually or, by default, taken from the query we are extending.

Returns
SelectQueryInterface A count query object.

Definition at line 119 of file pager.inc.

References $customCountQuery.

Referenced by execute().

limit ( $limit = 10 )

Specify the maximum number of elements per page for this query.

The default if not specified is 10 items per page.

Parameters
$limit An integer specifying the number of elements per page. If passed a false value (FALSE, 0, NULL), the pager is disabled.

Definition at line 137 of file pager.inc.

References $limit.

Referenced by execute().

setCountQuery ( SelectQueryInterface $query )

Specify the count query object to use for this pager.

You will rarely need to specify a count query directly. If not specified, one is generated off of the pager query itself.

Parameters
SelectQueryInterface $query The count query object. It must return a single row with a single column, which is the total number of records.

Definition at line 106 of file pager.inc.

References SelectQueryExtender\$query.

Member Data Documentation

$customCountQuery = FALSE
protected

Definition at line 43 of file pager.inc.

Referenced by getCountQuery().

$element = NULL
protected

Definition at line 36 of file pager.inc.

Referenced by element().

$limit = 10
protected

Definition at line 29 of file pager.inc.

Referenced by limit().

$maxElement = 0
static

Definition at line 22 of file pager.inc.

Referenced by EntityFieldQuery\pager().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: SearchQuery Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SearchQuery Class Reference
Inheritance diagram for SearchQuery:
SelectQueryExtender SelectQueryInterface QueryConditionInterface QueryAlterableInterface QueryExtendableInterface QueryPlaceholderInterface

Public Member Functions

searchExpression ($expression, $module)
setOption ($option, $column)
executeFirstPass ()
addScore ($score, $arguments=array(), $multiply=FALSE)
execute ()
countQuery ()
- Public Member Functions inherited from SelectQueryExtender
__construct (SelectQueryInterface $query, DatabaseConnection $connection)
uniqueIdentifier ()
nextPlaceholder ()
addTag ($tag)
hasTag ($tag)
hasAllTags ()
hasAnyTag ()
addMetaData ($key, $object)
getMetaData ($key)
condition ($field, $value=NULL, $operator=NULL)
& conditions ()
arguments ()
where ($snippet, $args=array())
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
havingCondition ($field, $value=NULL, $operator= '=')
& havingConditions ()
havingArguments ()
having ($snippet, $args=array())
havingCompile (DatabaseConnection $connection)
extend ($extender_name)
& getFields ()
& getExpressions ()
& getOrderBy ()
& getGroupBy ()
& getTables ()
& getUnion ()
getArguments (QueryPlaceholderInterface $queryPlaceholder=NULL)
isPrepared ()
preExecute (SelectQueryInterface $query=NULL)
execute ()
distinct ($distinct=TRUE)
addField ($table_alias, $field, $alias=NULL)
fields ($table_alias, array $fields=array())
addExpression ($expression, $alias=NULL, $arguments=array())
join ($table, $alias=NULL, $condition=NULL, $arguments=array())
innerJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
leftJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
rightJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
addJoin ($type, $table, $alias=NULL, $condition=NULL, $arguments=array())
orderBy ($field, $direction= 'ASC')
orderRandom ()
range ($start=NULL, $length=NULL)
union (SelectQueryInterface $query, $type= '')
groupBy ($field)
forUpdate ($set=TRUE)
countQuery ()
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
__toString ()
__clone ()
__call ($method, $args)

Protected Member Functions

parseSearchExpression ()
parseWord ($word)

Protected Attributes

$searchExpression
$type
$keys = array('positive' => array(), 'negative' => array())
$simple = TRUE
$conditions
$matches = 0
$words = array()
$normalize
$executedFirstPass = FALSE
$scores = array()
$scoresArguments = array()
$multiply = array()
$expressionsIgnored = FALSE
- Protected Attributes inherited from SelectQueryExtender
$query
$connection
$uniqueIdentifier
$placeholder = 0

Detailed Description

Do a query on the full-text search index for a word or words.

This function is normally only called by each module that supports the indexed search (and thus, implements hook_update_index()).

Results are retrieved in two logical passes. However, the two passes are joined together into a single query. And in the case of most simple queries the second pass is not even used.

The first pass selects a set of all possible matches, which has the benefit of also providing the exact result set for simple "AND" or "OR" searches.

The second portion of the query further refines this set by verifying advanced text conditions (such as negative or phrase matches).

The used query object has the tag 'search_$module' and can be further extended with hook_query_alter().

Definition at line 27 of file search.extender.inc.

Member Function Documentation

addScore | ( | $score,
 |  | $arguments = array(),
 |  | $multiply = FALSE
 | ) |

Adds a custom score expression to the search query.

Score expressions are used to order search results. If no calls to addScore() have taken place, a default keyword relevance score will be used. However, if at least one call to addScore() has taken place, the keyword relevance score is not automatically added.

Also note that if you call orderBy() directly on the query, search scores will not automatically be used to order search results. Your orderBy() expression can reference 'calculated_score', which will be the total calculated score value.

Parameters
$score | The score expression, which should evaluate to a number between 0 and 1. The string 'i.relevance' in a score expression will be replaced by a measure of keyword relevance between 0 and 1.
$arguments | Query arguments needed to provide values to the score expression.
$multiply | If set, the score is multiplied with this value. However, all scores with multipliers are then divided by the total of all multipliers, so that overall, the normalization is maintained.
Returns
object The updated query object.

Definition at line 420 of file search.extender.inc.

References $multiply.

Referenced by execute().

countQuery ( )

Builds the default count query for SearchQuery.

Since SearchQuery always uses GROUP BY, we can default to a subquery. We also add the same conditions as execute() because countQuery() is called first.

Implements SelectQueryInterface.

Definition at line 513 of file search.extender.inc.

References SelectQueryExtender\$query, SelectQueryExtender\conditions(), and db_select().

execute ( )

Executes the search.

If not already done, this executes the first pass query. Then the complex conditions are applied to the query including score expressions and ordering.

Returns
FALSE if the first pass query returned no results, and a database result set if there were results.

Definition at line 450 of file search.extender.inc.

References SelectQueryExtender\addExpression(), addScore(), SelectQueryExtender\condition(), SelectQueryExtender\conditions(), executeFirstPass(), SelectQueryExtender\getOrderBy(), SelectQueryExtender\join(), and SelectQueryExtender\orderBy().

executeFirstPass ( )

Executes the first pass query.

This can either be done explicitly, so that additional scores and conditions can be applied to the second pass query, or implicitly by addScore() or execute().

Returns
TRUE if search items exist, FALSE if not.

Definition at line 343 of file search.extender.inc.

References SelectQueryExtender\$query, SelectQueryExtender\condition(), SelectQueryExtender\conditions(), db_or(), drupal_set_message(), form_set_error(), format_plural(), SelectQueryExtender\join(), parseSearchExpression(), t(), and variable_get().

Referenced by execute().

parseSearchExpression ( )
protected

Parses the search query into SQL conditions.

We build two queries that match the dataset bodies.

Definition at line 186 of file search.extender.inc.

References $words, SelectQueryExtender\conditions(), db_and(), db_or(), drupal_set_message(), parseWord(), search_simplify(), searchExpression(), t(), and variable_get().

Referenced by executeFirstPass().

parseWord ( $word )
protected

Helper function for parseQuery().

Definition at line 314 of file search.extender.inc.

References drupal_strlen(), and variable_get().

Referenced by parseSearchExpression().

searchExpression | ( | $expression,
 |  | $module
 | ) |

Sets up the search query expression.

Parameters
$query | A search query string, which can contain options.
$module | The search module. This maps to {search_index}.type in the database.
Returns
The SearchQuery object.

Definition at line 148 of file search.extender.inc.

References $module.

Referenced by parseSearchExpression(), and setOption().

setOption | ( | $option,
 |  | $column
 | ) |

Applies a search option and removes it from the search query string.

These options are in the form option:value,value2,value3.

Parameters
$option | Name of the option.
$column | Name of the database column to which the value should be applied.
Returns
TRUE if a value for that option was found, FALSE if not.

Definition at line 168 of file search.extender.inc.

References $value, SelectQueryExtender\condition(), db_or(), search_expression_extract(), search_expression_insert(), and searchExpression().

Member Data Documentation

$conditions
protected

Definition at line 68 of file search.extender.inc.

$executedFirstPass = FALSE
protected

Definition at line 102 of file search.extender.inc.

$expressionsIgnored = FALSE
protected

Definition at line 135 of file search.extender.inc.

$keys = array('positive' => array(), 'negative' => array())
protected

Definition at line 51 of file search.extender.inc.

$matches = 0
protected

Definition at line 75 of file search.extender.inc.

$multiply = array()
protected

Definition at line 125 of file search.extender.inc.

Referenced by addScore().

$normalize
protected

Definition at line 95 of file search.extender.inc.

$scores = array()
protected

Definition at line 111 of file search.extender.inc.

$scoresArguments = array()
protected

Definition at line 118 of file search.extender.inc.

$searchExpression
protected

Definition at line 33 of file search.extender.inc.

$simple = TRUE
protected

Definition at line 58 of file search.extender.inc.

$type
protected

Definition at line 44 of file search.extender.inc.

$words = array()
protected

Definition at line 84 of file search.extender.inc.

Referenced by parseSearchExpression().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: SkipDotsRecursiveDirectoryIterator Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Member Functions | List of all members
SkipDotsRecursiveDirectoryIterator Class Reference
Inheritance diagram for SkipDotsRecursiveDirectoryIterator:

Public Member Functions

__construct ($path)
rewind ()
next ()

Protected Member Functions

skipdots ()

Detailed Description

Provides an interface for iterating recursively over filesystem directories.

Manually skips '.' and '..' directories, since no existing method is available in PHP 5.2.

Definition at line 400 of file filetransfer.inc.

Constructor & Destructor Documentation

__construct ( $path )

Constructs a SkipDotsRecursiveDirectoryIterator

Parameters
$path The path of the directory to be iterated over.

Definition at line 407 of file filetransfer.inc.

References skipdots().

Member Function Documentation

next ( )

Definition at line 417 of file filetransfer.inc.

References skipdots().

rewind ( )

Definition at line 412 of file filetransfer.inc.

References skipdots().

skipdots ( )
protected

Definition at line 422 of file filetransfer.inc.

Referenced by __construct(), next(), and rewind().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: StreamWrapperInterface Interface Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
StreamWrapperInterface Interface Reference
Inheritance diagram for StreamWrapperInterface:
DrupalStreamWrapperInterface DrupalLocalStreamWrapper FileExampleSessionStreamWrapper DrupalPrivateStreamWrapper DrupalPublicStreamWrapper DrupalTemporaryStreamWrapper

Public Member Functions

stream_open ($uri, $mode, $options, &$opened_url)
stream_close ()
stream_lock ($operation)
stream_read ($count)
stream_write ($data)
stream_eof ()
stream_seek ($offset, $whence)
stream_flush ()
stream_tell ()
stream_stat ()
unlink ($uri)
rename ($from_uri, $to_uri)
mkdir ($uri, $mode, $options)
rmdir ($uri, $options)
url_stat ($uri, $flags)
dir_opendir ($uri, $options)
dir_readdir ()
dir_rewinddir ()
dir_closedir ()

Detailed Description

Generic PHP stream wrapper interface.

See Also
http://www.php.net/manual/class.streamwrapper.php

Definition at line 98 of file stream_wrappers.inc.

Member Function Documentation

dir_closedir ( )

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

dir_opendir | ( | $uri,
 |  | $options
 | ) |

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

dir_readdir ( )

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

dir_rewinddir ( )

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

mkdir | ( | $uri,
 |  | $mode,
 |  | $options
 | ) |

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

rename | ( | $from_uri,
 |  | $to_uri
 | ) |

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

rmdir | ( | $uri,
 |  | $options
 | ) |

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

stream_close ( )

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

stream_eof ( )

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

stream_flush ( )

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

stream_lock ( $operation )

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

stream_open | ( |  | $uri,
 |  |  | $mode,
 |  |  | $options,
 |  | & | $opened_url
 | ) |  |

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

stream_read ( $count )

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

stream_seek | ( | $offset,
 |  | $whence
 | ) |

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

stream_stat ( )

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

stream_tell ( )

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

stream_write ( $data )

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

unlink ( $uri )

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

url_stat | ( | $uri,
 |  | $flags
 | ) |

Implemented in DrupalLocalStreamWrapper, and FileExampleSessionStreamWrapper.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: TableSort Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TableSort Class Reference
Inheritance diagram for TableSort:
SelectQueryExtender SelectQueryInterface QueryConditionInterface QueryAlterableInterface QueryExtendableInterface QueryPlaceholderInterface

Public Member Functions

__construct (SelectQueryInterface $query, DatabaseConnection $connection)
orderByHeader (Array $header)
- Public Member Functions inherited from SelectQueryExtender
__construct (SelectQueryInterface $query, DatabaseConnection $connection)
uniqueIdentifier ()
nextPlaceholder ()
addTag ($tag)
hasTag ($tag)
hasAllTags ()
hasAnyTag ()
addMetaData ($key, $object)
getMetaData ($key)
condition ($field, $value=NULL, $operator=NULL)
& conditions ()
arguments ()
where ($snippet, $args=array())
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
havingCondition ($field, $value=NULL, $operator= '=')
& havingConditions ()
havingArguments ()
having ($snippet, $args=array())
havingCompile (DatabaseConnection $connection)
extend ($extender_name)
& getFields ()
& getExpressions ()
& getOrderBy ()
& getGroupBy ()
& getTables ()
& getUnion ()
getArguments (QueryPlaceholderInterface $queryPlaceholder=NULL)
isPrepared ()
preExecute (SelectQueryInterface $query=NULL)
execute ()
distinct ($distinct=TRUE)
addField ($table_alias, $field, $alias=NULL)
fields ($table_alias, array $fields=array())
addExpression ($expression, $alias=NULL, $arguments=array())
join ($table, $alias=NULL, $condition=NULL, $arguments=array())
innerJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
leftJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
rightJoin ($table, $alias=NULL, $condition=NULL, $arguments=array())
addJoin ($type, $table, $alias=NULL, $condition=NULL, $arguments=array())
orderBy ($field, $direction= 'ASC')
orderRandom ()
range ($start=NULL, $length=NULL)
union (SelectQueryInterface $query, $type= '')
groupBy ($field)
forUpdate ($set=TRUE)
countQuery ()
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
__toString ()
__clone ()
__call ($method, $args)

Protected Member Functions

init ()
getSort ()
getQueryParameters ()
order ()

Protected Attributes

$header = array()
- Protected Attributes inherited from SelectQueryExtender
$query
$connection
$uniqueIdentifier
$placeholder = 0

Detailed Description

Query extender class for tablesort queries.

Definition at line 15 of file tablesort.inc.

Constructor & Destructor Documentation

__construct | ( | SelectQueryInterface | $query,
 |  | DatabaseConnection | $connection
 | ) |  |

Definition at line 24 of file tablesort.inc.

References SelectQueryExtender\addTag().

Member Function Documentation

getQueryParameters ( )
protected

Compose a URL query parameter array to append to table sorting requests.

Returns
A URL query parameter array that consists of all components of the current page request except for those pertaining to table sorting.
See Also
tablesort_get_query_parameters()

Definition at line 88 of file tablesort.inc.

References tablesort_get_query_parameters().

Referenced by init().

getSort ( )
protected

Determine the current sort direction.

Parameters
$headers An array of column headers in the format described in theme_table().
Returns
The current sort direction ("asc" or "desc").

Definition at line 75 of file tablesort.inc.

References tablesort_get_sort().

Referenced by init().

init ( )
protected

Initializes the table sort context.

Definition at line 60 of file tablesort.inc.

References getQueryParameters(), getSort(), and order().

Referenced by orderByHeader().

order ( )
protected

Determine the current sort criterion.

Parameters
$headers An array of column headers in the format described in theme_table().
Returns
An associative array describing the criterion, containing the keys:
  • "name": The localized title of the table column.
  • "sql": The name of the database field to sort on.

Definition at line 102 of file tablesort.inc.

References tablesort_get_order().

Referenced by init().

orderByHeader ( Array $header )

Order the query based on a header array.

See Also
theme_table()
Parameters
$header Table header array.
Returns
SelectQueryInterface The called object.

Definition at line 42 of file tablesort.inc.

References $header, drupal_strtoupper(), init(), and SelectQueryExtender\orderBy().

Member Data Documentation

$header = array()
protected

Definition at line 22 of file tablesort.inc.

Referenced by orderByHeader().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: TaxonomyTermController Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Protected Member Functions | List of all members
TaxonomyTermController Class Reference
Inheritance diagram for TaxonomyTermController:
DrupalDefaultEntityController DrupalEntityControllerInterface

Protected Member Functions

buildQuery ($ids, $conditions=array(), $revision_id=FALSE)
cacheGet ($ids, $conditions=array())
- Protected Member Functions inherited from DrupalDefaultEntityController
buildQuery ($ids, $conditions=array(), $revision_id=FALSE)
attachLoad (&$queried_entities, $revision_id=FALSE)
cacheGet ($ids, $conditions=array())
cacheSet ($entities)

Additional Inherited Members

- Public Member Functions inherited from DrupalDefaultEntityController
__construct ($entityType)
resetCache (array $ids=NULL)
load ($ids=array(), $conditions=array())
- Protected Attributes inherited from DrupalDefaultEntityController
$entityCache
$entityType
$entityInfo
$hookLoadArguments
$idKey
$revisionKey
$revisionTable
$cache

Detailed Description

Controller class for taxonomy terms.

This extends the DrupalDefaultEntityController class. Only alteration is that we match the condition on term name case-independently.

Definition at line 1236 of file taxonomy.module.

Member Function Documentation

buildQuery | ( | $ids,
 |  | $conditions = array(),
 |  | $revision_id = FALSE
 | ) |
protected

Definition at line 1238 of file taxonomy.module.

References db_like().

cacheGet | ( | $ids,
 |  | $conditions = array()
 | ) |
protected

Definition at line 1258 of file taxonomy.module.

References drupal_strtolower().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: TaxonomyVocabularyController Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Protected Member Functions | List of all members
TaxonomyVocabularyController Class Reference
Inheritance diagram for TaxonomyVocabularyController:
DrupalDefaultEntityController DrupalEntityControllerInterface

Protected Member Functions

buildQuery ($ids, $conditions=array(), $revision_id=FALSE)
- Protected Member Functions inherited from DrupalDefaultEntityController
buildQuery ($ids, $conditions=array(), $revision_id=FALSE)
attachLoad (&$queried_entities, $revision_id=FALSE)
cacheGet ($ids, $conditions=array())
cacheSet ($entities)

Additional Inherited Members

- Public Member Functions inherited from DrupalDefaultEntityController
__construct ($entityType)
resetCache (array $ids=NULL)
load ($ids=array(), $conditions=array())
- Protected Attributes inherited from DrupalDefaultEntityController
$entityCache
$entityType
$entityInfo
$hookLoadArguments
$idKey
$revisionKey
$revisionTable
$cache

Detailed Description

Controller class for taxonomy vocabularies.

This extends the DrupalDefaultEntityController class, adding required special handling for taxonomy vocabulary objects.

Definition at line 1278 of file taxonomy.module.

Member Function Documentation

buildQuery | ( | $ids,
 |  | $conditions = array(),
 |  | $revision_id = FALSE
 | ) |
protected

Definition at line 1280 of file taxonomy.module.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: TestingMailSystem Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
TestingMailSystem Class Reference
Inheritance diagram for TestingMailSystem:
DefaultMailSystem MailSystemInterface MailSystemInterface

Public Member Functions

mail (array $message)
- Public Member Functions inherited from DefaultMailSystem
format (array $message)
mail (array $message)

Detailed Description

A mail sending implementation that captures sent messages to a variable.

This class is for running tests or for development.

Definition at line 119 of file system.mail.inc.

Member Function Documentation

mail ( array $message )

Accept an e-mail message and store it in a variable.

Parameters
$message An e-mail message.

Implements MailSystemInterface.

Definition at line 126 of file system.mail.inc.

References variable_get(), and variable_set().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: ThemeUpdater Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Static Public Member Functions | List of all members
ThemeUpdater Class Reference
Inheritance diagram for ThemeUpdater:
Updater DrupalUpdaterInterface

Public Member Functions

getInstallDirectory ()
isInstalled ()
postInstall ()
postInstallTasks ()
- Public Member Functions inherited from Updater
__construct ($source)
update (&$filetransfer, $overrides=array())
install (&$filetransfer, $overrides=array())
prepareInstallDirectory (&$filetransfer, $directory)
makeWorldReadable (&$filetransfer, $path, $recursive=TRUE)
makeBackup (&$filetransfer, $from, $to)
getBackupDir ()
postUpdate ()
postInstall ()
postInstallTasks ()
postUpdateTasks ()
- Public Member Functions inherited from DrupalUpdaterInterface
postUpdate ()

Static Public Member Functions

static | canUpdateDirectory ($directory)
static | canUpdate ($project_name)
- Static Public Member Functions inherited from Updater
static | factory ($source)
static | getUpdaterFromDirectory ($directory)
static | findInfoFile ($directory)
static | getProjectName ($directory)
static | getProjectTitle ($directory)
- Static Public Member Functions inherited from DrupalUpdaterInterface
static | getProjectName ($directory)

Additional Inherited Members

- Public Attributes inherited from Updater
$source
- Protected Member Functions inherited from Updater
getInstallArgs ($overrides=array())

Detailed Description

Class for updating themes using FileTransfer classes via authorize.php.

Definition at line 97 of file system.updater.inc.

Member Function Documentation

static canUpdate ( $project_name )
static

Definition at line 133 of file system.updater.inc.

References drupal_get_path().

static canUpdateDirectory ( $directory )
static

Determine if the Updater can handle the project provided in $directory.

Parameters
string $directory
Returns
bool TRUE if the project is installed, FALSE if not.

Implements DrupalUpdaterInterface.

Definition at line 125 of file system.updater.inc.

References file_scan_directory().

getInstallDirectory ( )

Return the directory where a theme should be installed.

If the theme is already installed, drupal_get_path() will return a valid path and we should install it there (although we need to use an absolute path, so we prepend DRUPAL_ROOT). If we're installing a new theme, we always want it to go into sites/all/themes, since that's where all the documentation recommends users install their themes, and there's no way that can conflict on a multi-site installation, since the Update manager won't let you install a new theme if it's already found on your system, and if there was a copy in sites/all, we'd see it.

Implements DrupalUpdaterInterface.

Definition at line 111 of file system.updater.inc.

References drupal_get_path(), DRUPAL_ROOT, and name.

isInstalled ( )

Checks if the project is installed.

Returns
bool

Implements DrupalUpdaterInterface.

Definition at line 121 of file system.updater.inc.

References drupal_get_path(), and name.

postInstall ( )

Actions to run after an install has occurred.

Implements DrupalUpdaterInterface.

Definition at line 137 of file system.updater.inc.

References system_rebuild_theme_data().

postInstallTasks ( )

Definition at line 144 of file system.updater.inc.

References l(), and t().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: UpdateQuery_pgsql Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
UpdateQuery_pgsql Class Reference
Inheritance diagram for UpdateQuery_pgsql:
UpdateQuery Query QueryConditionInterface QueryPlaceholderInterface

Public Member Functions

execute ()
- Public Member Functions inherited from UpdateQuery
__construct (DatabaseConnection $connection, $table, array $options=array())
condition ($field, $value=NULL, $operator=NULL)
isNull ($field)
isNotNull ($field)
exists (SelectQueryInterface $select)
notExists (SelectQueryInterface $select)
& conditions ()
arguments ()
where ($snippet, $args=array())
compile (DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
compiled ()
fields (array $fields)
expression ($field, $expression, array $arguments=NULL)
execute ()
__toString ()
- Public Member Functions inherited from Query
__construct (DatabaseConnection $connection, $options)
__sleep ()
__wakeup ()
__clone ()
__toString ()
uniqueIdentifier ()
nextPlaceholder ()
comment ($comment)
& getComments ()

Additional Inherited Members

- Protected Member Functions inherited from Query
execute ()
- Protected Attributes inherited from UpdateQuery
$table
$fields = array()
$arguments = array()
$condition
$expressionFields = array()
- Protected Attributes inherited from Query
$connection
$connectionTarget
$connectionKey
$queryOptions
$uniqueIdentifier
$nextPlaceholder = 0
$comments = array()

Detailed Description

Definition at line 151 of file query.inc.

Member Function Documentation

execute ( )

Definition at line 152 of file query.inc.

References UpdateQuery\$arguments, UpdateQuery\$fields, Query\$queryOptions, $value, and UpdateQuery\condition().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Updater Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Updater Class Reference
Inheritance diagram for Updater:
ModuleUpdater ThemeUpdater

Public Member Functions

__construct ($source)
update (&$filetransfer, $overrides=array())
install (&$filetransfer, $overrides=array())
prepareInstallDirectory (&$filetransfer, $directory)
makeWorldReadable (&$filetransfer, $path, $recursive=TRUE)
makeBackup (&$filetransfer, $from, $to)
getBackupDir ()
postUpdate ()
postInstall ()
postInstallTasks ()
postUpdateTasks ()

Static Public Member Functions

static | factory ($source)
static | getUpdaterFromDirectory ($directory)
static | findInfoFile ($directory)
static | getProjectName ($directory)
static | getProjectTitle ($directory)

Public Attributes

$source

Protected Member Functions

getInstallArgs ($overrides=array())

Detailed Description

Base class for Updaters used in Drupal.

Definition at line 70 of file updater.inc.

Constructor & Destructor Documentation

__construct ( $source )

Definition at line 77 of file updater.inc.

References $source, name, and title.

Member Function Documentation

static factory ( $source )
static

Return an Updater of the appropriate type depending on the source.

If a directory is provided which contains a module, will return a ModuleUpdater.

Parameters
string $source Directory of a Drupal project.
Returns
Updater

Definition at line 94 of file updater.inc.

References $source, and t().

Referenced by update_manager_install_form_submit(), and update_manager_update_ready_form_submit().

static findInfoFile ( $directory )
static

Figure out what the most important (or only) info file is in a directory.

Since there is no enforcement of which info file is the project's "main" info file, this will get one with the same name as the directory, or the first one it finds. Not ideal, but needs a larger solution.

Parameters
string $directory Directory to search in.
Returns
string Path to the info file.

Definition at line 138 of file updater.inc.

References drupal_basename(), drupal_substr(), and file_scan_directory().

getBackupDir ( )

Return the full path to a directory where backups should be written.

Definition at line 372 of file updater.inc.

References file_stream_wrapper_get_instance_by_scheme().

Referenced by getInstallArgs().

getInstallArgs ( $overrides = array() )
protected

Store the default parameters for the Updater.

Parameters
array $overrides An array of overrides for the default parameters.
Returns
array An array of configuration parameters for an update or install operation.

Definition at line 199 of file updater.inc.

References getBackupDir().

Referenced by install(), and update().

static getProjectName ( $directory )
static

Get the name of the project directory (basename).

Parameters
string $directory
Returns
string The name of the project.

Definition at line 165 of file updater.inc.

References drupal_basename().

static getProjectTitle ( $directory )
static

Return the project name from a Drupal info file.

Parameters
string $directory Directory to search for the info file.
Returns
string The title of the project.

Definition at line 178 of file updater.inc.

References $info, drupal_parse_info_file(), and t().

Referenced by update_manager_install_form_submit().

static getUpdaterFromDirectory ( $directory )
static

Determine which Updater class can operate on the given directory.

Parameters
string $directory Extracted Drupal project.
Returns
string The class name which can work with this project type.

Definition at line 113 of file updater.inc.

References drupal_get_updaters(), and t().

install | ( | & | $filetransfer,
 |  |  | $overrides = array()
 | ) |  |

Installs a Drupal project, returns a list of next actions.

Parameters
FileTransfer | $filetransfer | Object that is a child of FileTransfer.
array | $overrides | An array of settings to override defaults; see self::getInstallArgs().
Returns
array An array of links which the user may need to complete the install.

Definition at line 275 of file updater.inc.

References getInstallArgs(), makeWorldReadable(), name, postInstall(), postInstallTasks(), prepareInstallDirectory(), and t().

makeBackup | ( | & | $filetransfer,
 |  |  | $from,
 |  |  | $to
 | ) |  |

Perform a backup.

Definition at line 366 of file updater.inc.

Referenced by update().

makeWorldReadable | ( | & | $filetransfer,
 |  |  | $path,
 |  |  | $recursive = TRUE
 | ) |  |

Ensure that a given directory is world readable.

Parameters
FileTransfer | $filetransfer | Object which is a child of FileTransfer.
string | $path | The file path to make world readable.
bool | $recursive | If the chmod should be applied recursively.

Definition at line 353 of file updater.inc.

Referenced by install(), prepareInstallDirectory(), and update().

postInstall ( )

Perform actions after installation.

Definition at line 385 of file updater.inc.

Referenced by install().

postInstallTasks ( )

Return an array of links to pages that should be visited post operation.

Returns
array Links which provide actions to take after the install is finished.

Definition at line 394 of file updater.inc.

Referenced by install().

postUpdate ( )

Perform actions after new code is updated.

Definition at line 379 of file updater.inc.

Referenced by update().

postUpdateTasks ( )

Return an array of links to pages that should be visited post operation.

Returns
array Links which provide actions to take after the update is finished.

Definition at line 404 of file updater.inc.

Referenced by update().

prepareInstallDirectory | ( | & | $filetransfer,
 |  |  | $directory
 | ) |  |

Make sure the installation parent directory exists and is writable.

Parameters
FileTransfer | $filetransfer | Object which is a child of FileTransfer.
string | $directory | The installation directory to prepare.

Definition at line 308 of file updater.inc.

References makeWorldReadable(), and t().

Referenced by install(), and update().

update | ( | & | $filetransfer,
 |  |  | $overrides = array()
 | ) |  |

Updates a Drupal project, returns a list of next actions.

Parameters
FileTransfer | $filetransfer | Object that is a child of FileTransfer. Used for moving files to the server.
array | $overrides | An array of settings to override defaults; see self::getInstallArgs().
Returns
array An array of links which the user may need to complete the update

Definition at line 220 of file updater.inc.

References getInstallArgs(), makeBackup(), makeWorldReadable(), name, postUpdate(), postUpdateTasks(), prepareInstallDirectory(), and t().

Member Data Documentation

$source

Definition at line 75 of file updater.inc.

Referenced by __construct(), and factory().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: UpdaterException Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
UpdaterException Class Reference
Inheritance diagram for UpdaterException:
Exception UpdaterFileTransferException

Detailed Description

Exception class for the Updater class hierarchy.

This is identical to the base Exception class, we just give it a more specific name so that call sites that want to tell the difference can specifically catch these exceptions and treat them differently.

Definition at line 416 of file updater.inc.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: UpdaterFileTransferException Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
UpdaterFileTransferException Class Reference
Inheritance diagram for UpdaterFileTransferException:
UpdaterException Exception

Detailed Description

Child class of UpdaterException that indicates a FileTransfer exception.

We have to catch FileTransfer exceptions and wrap those in t(), since FileTransfer is so low-level that it doesn't use any Drupal APIs and none of the strings are translated.

Definition at line 426 of file updater.inc.

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: UserController Class Reference

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Public Member Functions | List of all members
UserController Class Reference
Inheritance diagram for UserController:
DrupalDefaultEntityController DrupalEntityControllerInterface

Public Member Functions

attachLoad (&$queried_users, $revision_id=FALSE)
- Public Member Functions inherited from DrupalDefaultEntityController
__construct ($entityType)
resetCache (array $ids=NULL)
load ($ids=array(), $conditions=array())

Additional Inherited Members

- Protected Member Functions inherited from DrupalDefaultEntityController
buildQuery ($ids, $conditions=array(), $revision_id=FALSE)
attachLoad (&$queried_entities, $revision_id=FALSE)
cacheGet ($ids, $conditions=array())
cacheSet ($entities)
- Protected Attributes inherited from DrupalDefaultEntityController
$entityCache
$entityType
$entityInfo
$hookLoadArguments
$idKey
$revisionKey
$revisionTable
$cache

Detailed Description

Controller class for users.

This extends the DrupalDefaultEntityController class, adding required special handling for user objects.

Definition at line 300 of file user.module.

Member Function Documentation

attachLoad | ( | & | $queried_users,
 |  |  | $revision_id = FALSE
 | ) |  |

Definition at line 302 of file user.module.

References db_query(), DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID, file_load_multiple(), and variable_get().

Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Index

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Class Index
A | B | C | D | E | F | I | M | N | P | Q | S | T | U
A
DatabaseStatement_sqlite DrupalReliableQueueInterface FileTransferSSH SearchQuery
DatabaseStatementBase DrupalStreamWrapperInterface
I
SelectQuery
Archive_Tar DatabaseStatementEmpty DrupalTemporaryStreamWrapper SelectQuery_pgsql
ArchiverInterface DatabaseStatementInterface DrupalTestCase InsertQuery SelectQuery_sqlite
ArchiverTar DatabaseStatementPrefetch DrupalUnitTestCase InsertQuery_mysql SelectQueryExtender
ArchiverZip DatabaseTaskException DrupalUpdateException InsertQuery_pgsql SelectQueryInterface
B
DatabaseTasks DrupalUpdaterInterface InsertQuery_sqlite SkipDotsRecursiveDirectoryIterator
DatabaseTasks_mysql DrupalWebTestCase InvalidMergeQueryException StreamWrapperInterface
BatchMemoryQueue DatabaseTasks_pgsql
E
M
SystemQueue
BatchQueue DatabaseTasks_sqlite
T
C
DatabaseTransaction EntityExampleBasicController MailSystemInterface
DatabaseTransactionCommitFailedException EntityExampleBasicControllerInterface MemoryQueue TableSort
CommentController DatabaseTransactionExplicitCommitNotAllowedException EntityFieldQuery MergeQuery TaxonomyTermController
D
DatabaseTransactionNameNonUniqueException EntityFieldQueryException ModuleUpdater TaxonomyVocabularyController
DatabaseTransactionNoActiveException EntityMalformedException
N
TestingMailSystem
Database DatabaseTransactionOutOfOrderException Exception ThemeUpdater
DatabaseCondition DefaultMailSystem
F
NodeController TruncateQuery
DatabaseConnection DeleteQuery NoFieldsException TruncateQuery_mysql
DatabaseConnection_mysql DeleteQuery_sqlite FieldException
P
TruncateQuery_sqlite
DatabaseConnection_pgsql DrupalCacheArray FieldInfo
U
DatabaseConnection_sqlite DrupalCacheInterface FieldsOverlapException PagerDefault
DatabaseConnectionNotDefinedException DrupalDatabaseCache FieldUpdateForbiddenException
Q
UpdateQuery
DatabaseDriverNotSpecifiedException DrupalDefaultEntityController FieldValidationException UpdateQuery_pgsql
DatabaseLog DrupalEntityControllerInterface FileExampleSessionStreamWrapper Query UpdateQuery_sqlite
DatabaseSchema DrupalFakeCache FileTransfer QueryAlterableInterface Updater
DatabaseSchema_mysql DrupalLocalStreamWrapper FileTransferChmodInterface QueryConditionInterface UpdaterException
DatabaseSchema_pgsql DrupalPrivateStreamWrapper FileTransferException QueryExtendableInterface UpdaterFileTransferException
DatabaseSchema_sqlite DrupalPublicStreamWrapper FileTransferFTP QueryPlaceholderInterface UserController
DatabaseSchemaObjectDoesNotExistException DrupalQueue FileTransferFTPExtension
S
DatabaseSchemaObjectExistsException DrupalQueueInterface FileTransferLocal
SchemaCache
A | B | C | D | E | F | I | M | N | P | Q | S | T | U
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Hierarchy

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Class Hierarchy
This inheritance list is sorted roughly, but not completely, alphabetically:
[detail level 1234]
o C Archive_Tar
o C ArchiverInterface
| o C ArchiverTar
| \ C ArchiverZip
o C ArrayAccess
| \ C DrupalCacheArray
|   \ C SchemaCache
o C Countable
| \ C DatabaseCondition
o C Database
o C DatabaseLog
o C DatabaseTasks
| o C DatabaseTasks_mysql
| o C DatabaseTasks_pgsql
| \ C DatabaseTasks_sqlite
o C DatabaseTransaction
o C DrupalCacheInterface
| o C DrupalDatabaseCache
| | \ C DrupalFakeCache
| \ C DrupalFakeCache
o C DrupalEntityControllerInterface
| o C DrupalDefaultEntityController
| | o C CommentController
| | o C EntityExampleBasicController
| | o C NodeController
| | o C TaxonomyTermController
| | o C TaxonomyVocabularyController
| | \ C UserController
| \ C EntityExampleBasicControllerInterface
|   \ C EntityExampleBasicController
o C DrupalQueue
o C DrupalQueueInterface
| o C DrupalReliableQueueInterface
| | \ C SystemQueue
| |   \ C BatchQueue
| \ C MemoryQueue
|   \ C BatchMemoryQueue
o C DrupalTestCase
| o C DrupalUnitTestCase
| \ C DrupalWebTestCase
o C DrupalUpdaterInterface
| o C ModuleUpdater
| \ C ThemeUpdater
o C EntityFieldQuery
o C Exception
| o C DatabaseConnectionNotDefinedException
| o C DatabaseDriverNotSpecifiedException
| o C DatabaseSchemaObjectDoesNotExistException
| o C DatabaseSchemaObjectExistsException
| o C DatabaseTaskException
| o C DatabaseTransactionCommitFailedException
| o C DatabaseTransactionExplicitCommitNotAllowedException
| o C DatabaseTransactionNameNonUniqueException
| o C DatabaseTransactionNoActiveException
| o C DatabaseTransactionOutOfOrderException
| o C DrupalUpdateException
| o C EntityFieldQueryException
| o C EntityMalformedException
| o C FieldException
| | o C FieldUpdateForbiddenException
| | \ C FieldValidationException
| o C FieldsOverlapException
| o C FileTransferException
| o C InvalidMergeQueryException
| o C NoFieldsException
| \ C UpdaterException
|   \ C UpdaterFileTransferException
o C FieldInfo
o C FileTransfer
| o C FileTransferFTP
| | \ C FileTransferFTPExtension
| o C FileTransferLocal
| \ C FileTransferSSH
o C FileTransferChmodInterface
| o C FileTransferFTPExtension
| o C FileTransferLocal
| \ C FileTransferSSH
o C Iterator
| o C DatabaseStatement_sqlite
| o C DatabaseStatementEmpty
| \ C DatabaseStatementPrefetch
|   \ C DatabaseStatement_sqlite
o C MailSystemInterface
| o C DefaultMailSystem
| | \ C TestingMailSystem
| \ C TestingMailSystem
o C PDO
| \ C DatabaseConnection
|   o C DatabaseConnection_mysql
|   o C DatabaseConnection_pgsql
|   \ C DatabaseConnection_sqlite
o C PDOStatement
| \ C DatabaseStatementBase
o C QueryAlterableInterface
| \ C SelectQueryInterface
|   o C SelectQuery
|   | o C SelectQuery_pgsql
|   | \ C SelectQuery_sqlite
|   \ C SelectQueryExtender
|     o C PagerDefault
|     o C SearchQuery
|     \ C TableSort
o C QueryConditionInterface
| o C DatabaseCondition
| o C DeleteQuery
| | \ C DeleteQuery_sqlite
| o C MergeQuery
| o C SelectQueryInterface
| \ C UpdateQuery
|   o C UpdateQuery_pgsql
|   \ C UpdateQuery_sqlite
o C QueryExtendableInterface
| \ C SelectQueryInterface
o C QueryPlaceholderInterface
| o C DatabaseSchema
| | o C DatabaseSchema_mysql
| | o C DatabaseSchema_pgsql
| | \ C DatabaseSchema_sqlite
| o C Query
| | o C DeleteQuery
| | o C InsertQuery
| | | o C InsertQuery_mysql
| | | o C InsertQuery_pgsql
| | | \ C InsertQuery_sqlite
| | o C MergeQuery
| | o C SelectQuery
| | o C TruncateQuery
| | | o C TruncateQuery_mysql
| | | \ C TruncateQuery_sqlite
| | \ C UpdateQuery
| \ C SelectQueryInterface
o C RecursiveDirectoryIterator
| \ C SkipDotsRecursiveDirectoryIterator
o C StreamWrapperInterface
| \ C DrupalStreamWrapperInterface
|   o C DrupalLocalStreamWrapper
|   | o C DrupalPrivateStreamWrapper
|   | o C DrupalPublicStreamWrapper
|   | \ C DrupalTemporaryStreamWrapper
|   \ C FileExampleSessionStreamWrapper
o C Traversable
| \ C DatabaseStatementInterface
|   o C DatabaseStatement_sqlite
|   o C DatabaseStatementBase
|   o C DatabaseStatementEmpty
|   \ C DatabaseStatementPrefetch
\ C Updater
  o C ModuleUpdater
  \ C ThemeUpdater
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- $ -

  • $_compress : Archive_Tar
  • $_compress_type : Archive_Tar
  • $_file : Archive_Tar
  • $_separator : Archive_Tar
  • $_tarname : Archive_Tar
  • $_temp_tarname : Archive_Tar
  • $activeKey : Database
  • $additionalCurlOptions : DrupalWebTestCase
  • $age : EntityFieldQuery
  • $altered : EntityFieldQuery
  • $arguments : UpdateQuery , DatabaseCondition , FileTransferException
  • $assertions : DrupalTestCase
  • $attachedDatabases : DatabaseConnection_sqlite
  • $bin : DrupalCacheArray , DrupalDatabaseCache
  • $bundleExtraFields : FieldInfo
  • $bundleInstances : FieldInfo
  • $cache : DrupalDefaultEntityController
  • $changed : DatabaseCondition
  • $cid : DrupalCacheArray
  • $columnNames : DatabaseStatementPrefetch
  • $comments : Query
  • $completeRegistry : DrupalCacheArray
  • $condition : DeleteQuery , UpdateQuery
  • $conditions : DatabaseCondition , SearchQuery
  • $conditionTable : MergeQuery
  • $connection : Query , DatabaseSchema , SelectQueryExtender , DatabaseTransaction
  • $connectionKey : DatabaseLog , Query
  • $connectionOptions : DatabaseConnection
  • $connections : Database
  • $connectionTarget : Query
  • $content : DrupalWebTestCase
  • $context : FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper
  • $cookieFile : DrupalWebTestCase
  • $count : EntityFieldQuery
  • $curlHandle : DrupalWebTestCase
  • $currentKey : DatabaseStatementPrefetch
  • $currentRow : DatabaseStatementPrefetch
  • $customCountQuery : PagerDefault
  • $data : DatabaseStatementPrefetch
  • $databaseInfo : Database
  • $databasePrefix : DrupalTestCase
  • $dbh : DatabaseStatementBase , DatabaseStatementPrefetch
  • $defaultFetchOptions : DatabaseStatementPrefetch
  • $defaultFetchStyle : DatabaseStatementPrefetch
  • $defaultFields : InsertQuery , MergeQuery
  • $defaultSchema : DatabaseSchema , DatabaseSchema_sqlite
  • $deleted : EntityFieldQuery
  • $directory_keys : FileExampleSessionStreamWrapper
  • $directory_pointer : FileExampleSessionStreamWrapper
  • $distinct : SelectQuery
  • $driverClasses : DatabaseConnection
  • $driverOptions : DatabaseStatementPrefetch
  • $drupalSettings : DrupalWebTestCase
  • $element : PagerDefault
  • $elements : DrupalWebTestCase
  • $emptyBundles : FieldInfo
  • $entityCache : DrupalDefaultEntityController
  • $entityConditions : EntityFieldQuery
  • $entityInfo : DrupalDefaultEntityController
  • $entityType : DrupalDefaultEntityController
  • $errors : FieldValidationException
  • $executeCallback : EntityFieldQuery
  • $executedFirstPass : SearchQuery
  • $expressionFields : UpdateQuery , MergeQuery
  • $expressions : SelectQuery
  • $expressionsIgnored : SearchQuery
  • $fetchOptions : DatabaseStatementPrefetch
  • $fetchStyle : DatabaseStatementPrefetch
  • $fieldConditions : EntityFieldQuery
  • $fieldIdsByName : FieldInfo
  • $fieldMap : FieldInfo
  • $fieldMetaConditions : EntityFieldQuery
  • $fields : UpdateQuery , SelectQuery , EntityFieldQuery
  • $fieldsById : FieldInfo
  • $forUpdate : SelectQuery
  • $fromQuery : InsertQuery
  • $generatedTestFiles : DrupalWebTestCase
  • $group : SelectQuery
  • $handle : DrupalLocalStreamWrapper
  • $having : SelectQuery
  • $header : TableSort
  • $headers : DrupalWebTestCase
  • $hookLoadArguments : DrupalDefaultEntityController
  • $hostname : FileTransfer
  • $httpauth_credentials : DrupalWebTestCase
  • $httpauth_method : DrupalWebTestCase
  • $id_sequence : MemoryQueue
  • $idKey : DrupalDefaultEntityController
  • $ignoreTargets : Database
  • $insertFields : InsertQuery , MergeQuery
  • $insertValues : InsertQuery , MergeQuery
  • $key : DatabaseConnection
  • $keys : SearchQuery
  • $keysToPersist : DrupalCacheArray
  • $limit : PagerDefault
  • $loadedAllFields : FieldInfo
  • $loadedAllInstances : FieldInfo
  • $loggedInUser : DrupalWebTestCase
  • $logger : DatabaseConnection
  • $logs : Database
  • $matches : SearchQuery
  • $maxElement : PagerDefault
  • $metaData : EntityFieldQuery
  • $multiply : SearchQuery
  • $name : DatabaseTransaction , SystemQueue
  • $needsCleanup : DatabaseConnection_mysql
  • $needsUpdate : MergeQuery
  • $nextPlaceholder : Query
  • $normalize : SearchQuery
  • $order : SelectQuery , EntityFieldQuery
  • $orderedResults : EntityFieldQuery
  • $originalFileDirectory : DrupalTestCase
  • $originalShutdownCallbacks : DrupalWebTestCase
  • $originalUser : DrupalWebTestCase
  • $pager : EntityFieldQuery
  • $password : FileTransfer
  • $pdoDriver : DatabaseTasks_mysql , DatabaseTasks_pgsql , DatabaseTasks_sqlite
  • $persistable : DrupalCacheArray
  • $placeholder : DatabaseSchema , SelectQueryExtender
  • $plainTextContent : DrupalWebTestCase
  • $port : FileTransfer
  • $prefixes : DatabaseConnection
  • $prefixReplace : DatabaseConnection
  • $prefixSearch : DatabaseConnection
  • $prepared : SelectQuery
  • $profile : DrupalWebTestCase
  • $propertyConditions : EntityFieldQuery
  • $query : SelectQueryExtender
  • $queryLog : DatabaseLog
  • $queryOptions : Query
  • $queryPlaceholderIdentifier : DatabaseCondition
  • $queryString : DatabaseStatementPrefetch
  • $queue : MemoryQueue
  • $range : EntityFieldQuery , SelectQuery
  • $redirect_count : DrupalWebTestCase
  • $resultRowCount : DatabaseStatementPrefetch
  • $results : DrupalTestCase , DatabaseTasks
  • $revisionKey : DrupalDefaultEntityController
  • $revisionTable : DrupalDefaultEntityController
  • $rolledBack : DatabaseTransaction
  • $rowCount : DatabaseStatementPrefetch
  • $savepointSupport : DatabaseConnection_sqlite
  • $schema : DatabaseConnection
  • $scores : SearchQuery
  • $scoresArguments : SearchQuery
  • $searchExpression : SearchQuery
  • $session_content : FileExampleSessionStreamWrapper
  • $session_id : DrupalWebTestCase
  • $session_name : DrupalWebTestCase
  • $setup : DrupalTestCase
  • $setupDatabasePrefix : DrupalTestCase
  • $setupEnvironment : DrupalTestCase
  • $simple : SearchQuery
  • $skipClasses : DrupalTestCase
  • $source : Updater
  • $statementClass : DatabaseConnection
  • $storage : DrupalCacheArray
  • $stream_pointer : FileExampleSessionStreamWrapper
  • $table : UpdateQuery , DeleteQuery , InsertQuery , MergeQuery , TruncateQuery
  • $tableDropped : DatabaseConnection_sqlite
  • $tableInformation : DatabaseSchema_pgsql
  • $tables : SelectQuery
  • $tags : EntityFieldQuery
  • $tar : ArchiverTar
  • $target : DatabaseConnection
  • $tasks : DatabaseTasks
  • $temporaryNameIndex : DatabaseConnection
  • $testId : DrupalTestCase
  • $timeLimit : DrupalTestCase
  • $transactionalDDLSupport : DatabaseConnection
  • $transactionLayers : DatabaseConnection
  • $transactionSupport : DatabaseConnection
  • $type : SearchQuery
  • $union : SelectQuery
  • $uniqueIdentifier : Query , SelectQueryExtender , DatabaseSchema
  • $unknownFields : FieldInfo
  • $updateFields : MergeQuery
  • $uri : FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper
  • $url : DrupalWebTestCase
  • $username : FileTransfer
  • $where : SelectQuery
  • $willRollback : DatabaseConnection_sqlite
  • $words : SearchQuery
  • $zip : ArchiverZip
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- _ -

  • __call() : SelectQueryExtender
  • __clone() : Query , DatabaseSchema , SelectQueryInterface , DatabaseCondition , SelectQueryExtender , SelectQuery
  • __construct() : FileExampleSessionStreamWrapper , DatabaseLog , DrupalDefaultEntityController , FileTransfer , DatabaseConnection_mysql , FileTransferException , SkipDotsRecursiveDirectoryIterator , ArchiverInterface , DatabaseConnection_pgsql , FileTransferFTP , FileTransferSSH , DatabaseTasks_pgsql , PagerDefault , TableSort , DrupalCacheArray , DatabaseStatementPrefetch , DrupalCacheArray , Updater , Query , FieldValidationException , DrupalTestCase , SchemaCache , InsertQuery , DrupalUnitTestCase , DrupalWebTestCase , DeleteQuery , ArchiverTar , ArchiverZip , DrupalDatabaseCache , TruncateQuery , SystemQueue , MemoryQueue , UpdateQuery , Archive_Tar , DatabaseConnection , MergeQuery , DatabaseCondition , DatabaseTransaction , DatabaseSchema , SelectQueryExtender , DatabaseStatementBase , SelectQuery , DatabaseConnection_sqlite
  • __destruct() : DrupalCacheArray , DatabaseTransaction , DatabaseConnection_mysql , DatabaseConnection_sqlite , Archive_Tar
  • __get() : FileTransfer
  • __sleep() : Query
  • __toString() : UpdateQuery , MergeQuery , DatabaseCondition , SelectQueryExtender , SelectQuery , InsertQuery_sqlite , TruncateQuery_sqlite , InsertQuery , TruncateQuery , DeleteQuery , Query , InsertQuery_mysql , InsertQuery_pgsql
  • __wakeup() : Query
  • _addFile() : Archive_Tar
  • _addList() : Archive_Tar
  • _addString() : Archive_Tar
  • _append() : Archive_Tar
  • _cleanFile() : Archive_Tar
  • _close() : Archive_Tar
  • _createIndexSql() : DatabaseSchema_pgsql
  • _createKeys() : DatabaseSchema_pgsql
  • _createKeySql() : DatabaseSchema_pgsql
  • _dirCheck() : Archive_Tar
  • _error() : Archive_Tar
  • _extractInString() : Archive_Tar
  • _extractList() : Archive_Tar
  • _isArchive() : Archive_Tar
  • _jumpBlock() : Archive_Tar
  • _maliciousFilename() : Archive_Tar
  • _openAppend() : Archive_Tar
  • _openRead() : Archive_Tar
  • _openReadWrite() : Archive_Tar
  • _openWrite() : Archive_Tar
  • _pathReduction() : Archive_Tar
  • _readBlock() : Archive_Tar
  • _readHeader() : Archive_Tar
  • _readLongHeader() : Archive_Tar
  • _translateWinPath() : Archive_Tar
  • _warning() : Archive_Tar
  • _writeBlock() : Archive_Tar
  • _writeFooter() : Archive_Tar
  • _writeHeader() : Archive_Tar
  • _writeHeaderBlock() : Archive_Tar
  • _writeLongHeader() : Archive_Tar
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- a -

  • add() : ArchiverInterface , ArchiverTar , Archive_Tar , ArchiverZip
  • addCondition() : EntityFieldQuery
  • addConnectionInfo() : Database
  • addExpression() : SelectQueryExtender , SelectQuery , SelectQueryInterface
  • addField() : DatabaseSchema_sqlite , DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema , SelectQueryInterface , SelectQueryExtender , SelectQuery
  • addFieldCondition() : EntityFieldQuery
  • addIndex() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema , DatabaseSchema_sqlite
  • addJoin() : SelectQueryInterface , SelectQueryExtender , SelectQuery
  • addMetaData() : QueryAlterableInterface , SelectQueryExtender , SelectQuery , EntityFieldQuery
  • addModify() : Archive_Tar
  • addPrimaryKey() : DatabaseSchema , DatabaseSchema_sqlite , DatabaseSchema_mysql , DatabaseSchema_pgsql
  • addScore() : SearchQuery
  • addString() : Archive_Tar
  • addTag() : QueryAlterableInterface , SelectQueryExtender , SelectQuery , EntityFieldQuery
  • addUniqueKey() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema , DatabaseSchema_sqlite
  • age() : EntityFieldQuery
  • alterTable() : DatabaseSchema_sqlite
  • arguments() : QueryConditionInterface , DeleteQuery , UpdateQuery , MergeQuery , DatabaseCondition , SelectQueryExtender , SelectQuery
  • assert() : DrupalTestCase
  • assertEqual() : DrupalTestCase
  • assertFalse() : DrupalTestCase
  • assertField() : DrupalWebTestCase
  • assertFieldById() : DrupalWebTestCase
  • assertFieldByName() : DrupalWebTestCase
  • assertFieldByXPath() : DrupalWebTestCase
  • assertFieldChecked() : DrupalWebTestCase
  • assertIdentical() : DrupalTestCase
  • assertLink() : DrupalWebTestCase
  • assertLinkByHref() : DrupalWebTestCase
  • assertMail() : DrupalWebTestCase
  • assertMailPattern() : DrupalWebTestCase
  • assertMailString() : DrupalWebTestCase
  • assertNoDuplicateIds() : DrupalWebTestCase
  • assertNoField() : DrupalWebTestCase
  • assertNoFieldById() : DrupalWebTestCase
  • assertNoFieldByName() : DrupalWebTestCase
  • assertNoFieldByXPath() : DrupalWebTestCase
  • assertNoFieldChecked() : DrupalWebTestCase
  • assertNoLink() : DrupalWebTestCase
  • assertNoLinkByHref() : DrupalWebTestCase
  • assertNoOptionSelected() : DrupalWebTestCase
  • assertNoPattern() : DrupalWebTestCase
  • assertNoRaw() : DrupalWebTestCase
  • assertNoResponse() : DrupalWebTestCase
  • assertNotEqual() : DrupalTestCase
  • assertNoText() : DrupalWebTestCase
  • assertNotIdentical() : DrupalTestCase
  • assertNoTitle() : DrupalWebTestCase
  • assertNotNull() : DrupalTestCase
  • assertNoUniqueText() : DrupalWebTestCase
  • assertNull() : DrupalTestCase
  • assertOptionSelected() : DrupalWebTestCase
  • assertPattern() : DrupalWebTestCase
  • assertRaw() : DrupalWebTestCase
  • assertResponse() : DrupalWebTestCase
  • assertText() : DrupalWebTestCase
  • assertTextHelper() : DrupalWebTestCase
  • assertThemeOutput() : DrupalWebTestCase
  • assertTitle() : DrupalWebTestCase
  • assertTrue() : DrupalTestCase
  • assertUniqueText() : DrupalWebTestCase
  • assertUniqueTextHelper() : DrupalWebTestCase
  • assertUrl() : DrupalWebTestCase
  • attachLoad() : NodeController , CommentController , UserController , DrupalDefaultEntityController
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- b -

  • buildQuery() : DrupalDefaultEntityController , CommentController , TaxonomyTermController , TaxonomyVocabularyController , NodeController
  • buildTableNameCondition() : DatabaseSchema_mysql , DatabaseSchema
  • buildXPathQuery() : DrupalWebTestCase
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- c -

  • cacheGet() : DrupalDefaultEntityController , TaxonomyTermController
  • cacheSet() : DrupalDefaultEntityController
  • canUpdate() : ModuleUpdater , ThemeUpdater
  • canUpdateDirectory() : ThemeUpdater , DrupalUpdaterInterface , ModuleUpdater
  • changeDatabasePrefix() : DrupalWebTestCase
  • changeField() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema , DatabaseSchema_sqlite
  • checkBinaryOutput() : DatabaseTasks_pgsql
  • checkBinaryOutputSuccess() : DatabaseTasks_pgsql
  • checkEncoding() : DatabaseTasks_pgsql
  • checkEngineVersion() : DatabaseTasks
  • checkForMetaRefresh() : DrupalWebTestCase
  • checkPath() : FileTransfer
  • checkPermissions() : DrupalWebTestCase
  • checkPHPVersion() : DatabaseTasks_pgsql
  • chmod() : FileExampleSessionStreamWrapper , FileTransfer , DrupalStreamWrapperInterface , DrupalLocalStreamWrapper
  • chmodJailed() : FileTransferChmodInterface , FileTransferFTPExtension , FileTransferLocal , FileTransferSSH
  • claimItem() : DrupalQueueInterface , SystemQueue , MemoryQueue , BatchQueue , BatchMemoryQueue
  • clear() : DrupalFakeCache , DrupalCacheInterface , DrupalDatabaseCache , DatabaseLog
  • clickLink() : DrupalWebTestCase
  • closeConnection() : Database
  • comment() : Query
  • COMMENT_MAX_COLUMN : DatabaseSchema_mysql
  • COMMENT_MAX_TABLE : DatabaseSchema_mysql
  • commit() : DatabaseConnection
  • compile() : QueryConditionInterface , DeleteQuery , TruncateQuery , UpdateQuery , MergeQuery , DatabaseCondition , SelectQueryExtender , SelectQuery
  • compiled() : QueryConditionInterface , DeleteQuery , TruncateQuery , UpdateQuery , MergeQuery , DatabaseCondition , SelectQueryExtender , SelectQuery
  • condition() : MergeQuery , DatabaseCondition , SelectQueryExtender , SelectQuery , QueryConditionInterface , DeleteQuery , UpdateQuery
  • conditions() : MergeQuery , QueryConditionInterface , DeleteQuery , UpdateQuery , DatabaseCondition , SelectQueryExtender , SelectQuery
  • conditionTable() : MergeQuery
  • connect() : FileTransfer , FileTransferFTPExtension , FileTransferLocal , DatabaseTasks , FileTransferSSH
  • constraintExists() : DatabaseSchema_pgsql
  • constructFieldXpath() : DrupalWebTestCase
  • copyDirectory() : FileTransfer
  • copyDirectoryJailed() : FileTransfer , FileTransferSSH
  • copyFile() : FileTransfer
  • copyFileJailed() : FileTransferFTPExtension , FileTransferLocal , FileTransferSSH , FileTransfer
  • count() : EntityFieldQuery , DatabaseCondition
  • countQuery() : SelectQueryExtender , SelectQuery , SearchQuery , SelectQueryInterface
  • create() : EntityExampleBasicController , EntityExampleBasicControllerInterface , Archive_Tar
  • createColumsSql() : DatabaseSchema_sqlite
  • createDirectory() : FileTransfer
  • createDirectoryJailed() : FileTransfer , FileTransferFTPExtension , FileTransferLocal , FileTransferSSH
  • createFieldSql() : DatabaseSchema_mysql , DatabaseSchema_sqlite , DatabaseSchema_pgsql
  • createIndexSql() : DatabaseSchema_sqlite
  • createItem() : MemoryQueue , SystemQueue , DrupalQueueInterface
  • createKeySql() : DatabaseSchema_sqlite , DatabaseSchema_mysql
  • createKeysSql() : DatabaseSchema_mysql
  • createKeysSqlHelper() : DatabaseSchema_mysql
  • createModify() : Archive_Tar
  • createQueue() : SystemQueue , DrupalQueueInterface , MemoryQueue
  • createTable() : DatabaseSchema
  • createTableSql() : DatabaseSchema_sqlite , DatabaseSchema_mysql , DatabaseSchema_pgsql
  • cronRun() : DrupalWebTestCase
  • curlClose() : DrupalWebTestCase
  • curlExec() : DrupalWebTestCase
  • curlHeaderCallback() : DrupalWebTestCase
  • curlInitialize() : DrupalWebTestCase
  • current() : DatabaseStatementPrefetch , DatabaseStatementEmpty
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- d -

  • databaseType() : DatabaseConnection , DatabaseConnection_mysql , DatabaseConnection_sqlite , DatabaseConnection_pgsql
  • defaultOptions() : DatabaseConnection
  • delete() : DatabaseConnection , EntityExampleBasicControllerInterface , EntityExampleBasicController
  • delete_multiple() : EntityExampleBasicController
  • deleteAssert() : DrupalTestCase
  • deleted() : EntityFieldQuery
  • deleteItem() : DrupalQueueInterface , SystemQueue , MemoryQueue
  • deleteQueue() : SystemQueue , MemoryQueue , DrupalQueueInterface
  • destroy() : DatabaseConnection
  • dir_closedir() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • dir_opendir() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • dir_readdir() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • dir_rewinddir() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • dirname() : DrupalStreamWrapperInterface , DrupalLocalStreamWrapper , FileExampleSessionStreamWrapper
  • distinct() : SelectQueryInterface , SelectQueryExtender , SelectQuery
  • driver() : DatabaseConnection , DatabaseConnection_mysql , DatabaseConnection_pgsql , DatabaseConnection_sqlite
  • dropField() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema , DatabaseSchema_sqlite
  • dropIndex() : DatabaseSchema , DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema_sqlite
  • dropPrimaryKey() : DatabaseSchema , DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema_sqlite
  • dropTable() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema_sqlite , DatabaseSchema
  • dropUniqueKey() : DatabaseSchema , DatabaseSchema_pgsql , DatabaseSchema_mysql , DatabaseSchema_sqlite
  • drupalCompareFiles() : DrupalWebTestCase
  • drupalCreateContentType() : DrupalWebTestCase
  • drupalCreateNode() : DrupalWebTestCase
  • drupalCreateRole() : DrupalWebTestCase
  • drupalCreateUser() : DrupalWebTestCase
  • drupalGet() : DrupalWebTestCase
  • drupalGetAJAX() : DrupalWebTestCase
  • drupalGetContent() : DrupalWebTestCase
  • drupalGetHeader() : DrupalWebTestCase
  • drupalGetHeaders() : DrupalWebTestCase
  • drupalGetMails() : DrupalWebTestCase
  • drupalGetNodeByTitle() : DrupalWebTestCase
  • drupalGetSettings() : DrupalWebTestCase
  • drupalGetTestFiles() : DrupalWebTestCase
  • drupalGetToken() : DrupalWebTestCase
  • drupalHead() : DrupalWebTestCase
  • drupalLogin() : DrupalWebTestCase
  • drupalLogout() : DrupalWebTestCase
  • drupalPost() : DrupalWebTestCase
  • drupalPostAJAX() : DrupalWebTestCase
  • drupalSetContent() : DrupalWebTestCase
  • drupalSetSettings() : DrupalWebTestCase
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- e -

  • element() : PagerDefault
  • end() : DatabaseLog
  • ensureElement() : PagerDefault
  • entityCondition() : EntityFieldQuery
  • entityOrderBy() : EntityFieldQuery
  • error() : DrupalTestCase
  • errorHandler() : DrupalTestCase
  • escapeAlias() : DatabaseConnection
  • escapeField() : DatabaseConnection
  • escapeLike() : DatabaseConnection
  • escapeTable() : DatabaseConnection
  • exceptionHandler() : DrupalTestCase
  • execute() : InsertQuery_mysql , EntityFieldQuery , PagerDefault , InsertQuery_pgsql , SearchQuery , UpdateQuery_pgsql , DatabaseStatementPrefetch , Query , InsertQuery , DeleteQuery , TruncateQuery , UpdateQuery , MergeQuery , DeleteQuery_sqlite , UpdateQuery_sqlite , InsertQuery_sqlite , DatabaseStatementInterface , SelectQueryExtender , SelectQuery , DatabaseStatementBase , DatabaseStatement_sqlite , DatabaseStatementEmpty
  • executeFirstPass() : SearchQuery
  • exists() : SelectQuery , MergeQuery , QueryConditionInterface , DeleteQuery , SelectQueryExtender , UpdateQuery , DatabaseCondition
  • expandArguments() : DatabaseConnection
  • expression() : UpdateQuery , MergeQuery
  • extend() : QueryExtendableInterface , SelectQueryExtender , SelectQuery
  • extract() : ArchiverTar , ArchiverZip , Archive_Tar , ArchiverInterface
  • extractInString() : Archive_Tar
  • extractList() : Archive_Tar
  • extractModify() : Archive_Tar
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- f -

  • factory() : FileTransfer , FileTransferFTP , FileTransferSSH , Updater , FileTransferLocal
  • fail() : DatabaseTasks , DrupalTestCase
  • fetch() : DatabaseStatementEmpty , DatabaseStatementPrefetch
  • fetchAll() : DatabaseStatementEmpty , DatabaseStatementPrefetch
  • fetchAllAssoc() : DatabaseStatementInterface , DatabaseStatementBase , DatabaseStatementEmpty , DatabaseStatementPrefetch
  • fetchAllKeyed() : DatabaseStatementInterface , DatabaseStatementBase , DatabaseStatementEmpty , DatabaseStatementPrefetch
  • fetchAssoc() : DatabaseStatementInterface , DatabaseStatementBase , DatabaseStatementEmpty , DatabaseStatementPrefetch
  • fetchCol() : DatabaseStatementInterface , DatabaseStatementBase , DatabaseStatementEmpty , DatabaseStatementPrefetch
  • fetchColumn() : DatabaseStatementPrefetch
  • fetchField() : DatabaseStatementPrefetch , DatabaseStatementInterface , DatabaseStatementBase , DatabaseStatementEmpty
  • fetchObject() : DatabaseStatementEmpty , DatabaseStatementPrefetch
  • fieldCondition() : EntityFieldQuery
  • fieldDeltaCondition() : EntityFieldQuery
  • fieldExists() : DatabaseSchema_sqlite , DatabaseSchema_mysql , DatabaseSchema
  • fieldLanguageCondition() : EntityFieldQuery
  • fieldNames() : DatabaseSchema
  • fieldOrderBy() : EntityFieldQuery
  • fields() : UpdateQuery , MergeQuery , SelectQueryInterface , SelectQuery , InsertQuery , SelectQueryExtender
  • fieldSetDefault() : DatabaseSchema , DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema_sqlite
  • fieldSetNoDefault() : DatabaseSchema_mysql , DatabaseSchema , DatabaseSchema_sqlite , DatabaseSchema_pgsql
  • filterComment() : DatabaseConnection
  • findCaller() : DatabaseLog
  • findChroot() : FileTransfer
  • findInfoFile() : Updater
  • findTables() : DatabaseSchema , DatabaseSchema_sqlite
  • finishQuery() : EntityFieldQuery
  • fixRemotePath() : FileTransfer
  • flush() : FieldInfo
  • format() : MailSystemInterface , DefaultMailSystem
  • forUpdate() : SelectQuery_sqlite , SelectQueryInterface , SelectQuery , SelectQueryExtender
  • from() : InsertQuery
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- g -

  • garbageCollection() : DrupalDatabaseCache
  • generatePermutations() : DrupalTestCase
  • generateTemporaryTableName() : DatabaseConnection
  • get() : DrupalFakeCache , DrupalQueue , DrupalCacheInterface , DrupalDatabaseCache , DatabaseLog
  • getAbsoluteUrl() : DrupalWebTestCase
  • getAllItems() : BatchQueue , BatchMemoryQueue
  • getAllOptions() : DrupalWebTestCase
  • getArchive() : ArchiverTar , ArchiverZip
  • getArguments() : SelectQueryExtender , SelectQuery , SelectQueryInterface
  • getAssertionCall() : DrupalTestCase
  • getBackupDir() : Updater
  • getBundleExtraFields() : FieldInfo
  • getBundleInstances() : FieldInfo
  • getComment() : DatabaseSchema_mysql , DatabaseSchema_pgsql
  • getComments() : Query
  • getConnection() : Database
  • getConnectionInfo() : Database
  • getConnectionOptions() : DatabaseConnection
  • getCountQuery() : PagerDefault
  • getDirectoryPath() : DrupalPrivateStreamWrapper , DrupalTemporaryStreamWrapper , FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper , DrupalPublicStreamWrapper
  • getDriverClass() : DatabaseConnection
  • getExpressions() : SelectQueryInterface , SelectQueryExtender , SelectQuery
  • getExternalUrl() : FileExampleSessionStreamWrapper , DrupalStreamWrapperInterface , DrupalPublicStreamWrapper , DrupalPrivateStreamWrapper , DrupalTemporaryStreamWrapper
  • getField() : FieldInfo
  • getFieldById() : FieldInfo
  • getFieldMap() : FieldInfo
  • getFields() : SelectQueryInterface , SelectQueryExtender , SelectQuery , FieldInfo
  • getFieldTypeMap() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema , DatabaseSchema_sqlite
  • getFormOptions() : DatabaseTasks_sqlite , DatabaseTasks
  • getGroupBy() : SelectQueryInterface , SelectQueryExtender , SelectQuery
  • getInstallArgs() : Updater
  • getInstallDirectory() : DrupalUpdaterInterface , ModuleUpdater , ThemeUpdater
  • getInstances() : FieldInfo
  • getKey() : DatabaseConnection
  • getLocalPath() : FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper
  • getLog() : Database
  • getLogger() : DatabaseConnection
  • getMetaData() : QueryAlterableInterface , SelectQueryExtender , SelectQuery
  • getMimeType() : FileExampleSessionStreamWrapper , DrupalStreamWrapperInterface , DrupalLocalStreamWrapper
  • getMultiple() : DrupalCacheInterface , DrupalDatabaseCache , DrupalFakeCache
  • getOrderBy() : SelectQueryExtender , SelectQueryInterface , SelectQuery
  • getPrefixInfo() : DatabaseSchema , DatabaseSchema_mysql
  • getProjectName() : DrupalUpdaterInterface , Updater
  • getProjectTitle() : Updater
  • getQueryParameters() : TableSort
  • getQueryString() : DatabaseStatementInterface , DatabaseStatementBase , DatabaseStatementPrefetch , DatabaseStatementEmpty
  • getSchemaUpdates() : ModuleUpdater
  • getSelectedItem() : DrupalWebTestCase
  • getSettingsForm() : FileTransferSSH , FileTransfer , FileTransferFTP
  • getSort() : TableSort
  • getStatement() : DatabaseStatement_sqlite , DatabaseStatementPrefetch
  • getTables() : SelectQueryExtender , SelectQuery , SelectQueryInterface
  • getTarget() : DrupalLocalStreamWrapper , FileExampleSessionStreamWrapper , DatabaseConnection
  • getUnion() : SelectQueryInterface , SelectQuery , SelectQueryExtender
  • getUpdaterFromDirectory() : Updater
  • getUri() : FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper , DrupalStreamWrapperInterface
  • getUrl() : DrupalWebTestCase
  • groupBy() : SelectQueryExtender , SelectQuery , SelectQueryInterface
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- h -

  • handleForm() : DrupalWebTestCase
  • hasAllTags() : QueryAlterableInterface , SelectQuery , SelectQueryExtender
  • hasAnyTag() : QueryAlterableInterface , SelectQueryExtender , SelectQuery
  • hasPdoDriver() : DatabaseTasks
  • hasTag() : QueryAlterableInterface , SelectQueryExtender , SelectQuery
  • having() : SelectQueryExtender , SelectQuery
  • havingArguments() : SelectQuery , SelectQueryExtender
  • havingCompile() : SelectQueryExtender , SelectQuery
  • havingCondition() : SelectQueryExtender , SelectQueryInterface , SelectQuery
  • havingConditions() : SelectQuery , SelectQueryExtender
  • havingExists() : SelectQuery
  • havingIsNotNull() : SelectQuery
  • havingIsNull() : SelectQuery
  • havingNotExists() : SelectQuery
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- i -

  • ignoreTarget() : Database
  • indexExists() : DatabaseSchema_mysql , DatabaseSchema , DatabaseSchema_sqlite , DatabaseSchema_pgsql
  • init() : TableSort
  • initializeDatabase() : DatabaseTasks_pgsql
  • initializePager() : EntityFieldQuery
  • initializeRegistry() : DrupalCacheArray
  • innerJoin() : SelectQueryInterface , SelectQueryExtender , SelectQuery
  • insert() : DatabaseConnection
  • insertAssert() : DrupalTestCase
  • insertFields() : MergeQuery
  • install() : Updater
  • installable() : DatabaseTasks
  • inTransaction() : DatabaseConnection
  • introspectSchema() : DatabaseSchema_sqlite
  • isActiveConnection() : Database
  • isDirectory() : FileTransfer , FileTransferFTPExtension , FileTransferLocal , FileTransferSSH
  • isEmpty() : DrupalFakeCache , DrupalCacheInterface , DrupalDatabaseCache
  • isFile() : FileTransferSSH , FileTransfer , FileTransferFTPExtension , FileTransferLocal
  • isInstalled() : DrupalUpdaterInterface , ModuleUpdater , ThemeUpdater
  • isNotNull() : UpdateQuery , DeleteQuery , MergeQuery , QueryConditionInterface , SelectQueryExtender , DatabaseCondition , SelectQuery
  • isNull() : DeleteQuery , SelectQueryExtender , UpdateQuery , MergeQuery , DatabaseCondition , QueryConditionInterface , SelectQuery
  • isPrepared() : SelectQuery , SelectQueryExtender , SelectQueryInterface
  • isValidBin() : DrupalDatabaseCache
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- j -

  • join() : SelectQueryInterface , SelectQuery , SelectQueryExtender
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- k -

  • key() : DatabaseStatementEmpty , MergeQuery , DatabaseStatementPrefetch
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- l -

  • leftJoin() : SelectQueryInterface , SelectQueryExtender , SelectQuery
  • limit() : PagerDefault
  • listContent() : Archive_Tar
  • listContents() : ArchiverZip , ArchiverInterface , ArchiverTar
  • load() : DrupalEntityControllerInterface , DrupalDefaultEntityController
  • loadDriverFile() : Database
  • loadExtension() : Archive_Tar
  • log() : DatabaseLog
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- m -

  • mail() : MailSystemInterface , DefaultMailSystem , TestingMailSystem
  • makeBackup() : Updater
  • makeComment() : DatabaseConnection
  • makeSequenceName() : DatabaseConnection
  • makeWorldReadable() : Updater
  • mapConditionOperator() : DatabaseConnection , DatabaseConnection_mysql , DatabaseConnection_pgsql , DatabaseCondition , DatabaseConnection_sqlite
  • mapKeyDefinition() : DatabaseSchema_sqlite
  • merge() : DatabaseConnection
  • minimumVersion() : DatabaseTasks_mysql , DatabaseTasks_pgsql , DatabaseTasks_sqlite , DatabaseTasks
  • mkdir() : StreamWrapperInterface , FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- n -

  • name() : DatabaseTransaction , DatabaseTasks_mysql , DatabaseTasks_sqlite , DatabaseTasks , DatabaseTasks_pgsql
  • next() : SkipDotsRecursiveDirectoryIterator , DatabaseStatementEmpty , DatabaseStatementPrefetch
  • nextId() : DatabaseConnection , DatabaseConnection_mysql , DatabaseConnection_pgsql , DatabaseConnection_sqlite
  • nextIdDelete() : DatabaseConnection_mysql
  • nextPlaceholder() : DatabaseSchema , SelectQueryExtender , QueryPlaceholderInterface , Query
  • notExists() : DatabaseCondition , UpdateQuery , SelectQueryExtender , QueryConditionInterface , MergeQuery , DeleteQuery , SelectQuery
  • numberOfItems() : SystemQueue , MemoryQueue , DrupalQueueInterface
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- o -

  • offsetExists() : DrupalCacheArray
  • offsetGet() : DrupalCacheArray
  • offsetSet() : DrupalCacheArray
  • offsetUnset() : DrupalCacheArray
  • openConnection() : Database
  • order() : TableSort
  • orderBy() : SelectQueryExtender , SelectQuery_pgsql , SelectQueryInterface , SelectQuery
  • orderByHeader() : TableSort
  • orderRandom() : SelectQuery_pgsql , SelectQueryExtender , SelectQueryInterface , SelectQuery
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- p -

  • pager() : EntityFieldQuery
  • parse() : DrupalWebTestCase
  • parseConnectionInfo() : Database
  • parseSearchExpression() : SearchQuery
  • parseWord() : SearchQuery
  • pass() : DatabaseTasks , DrupalTestCase
  • PDOPrepare() : DatabaseConnection_sqlite
  • persist() : DrupalCacheArray
  • popCommittableTransactions() : DatabaseConnection , DatabaseConnection_mysql
  • popTransaction() : DatabaseConnection , DatabaseConnection_sqlite
  • postInstall() : ThemeUpdater , DrupalUpdaterInterface , Updater
  • postInstallTasks() : Updater , ModuleUpdater , ThemeUpdater
  • postUpdate() : DrupalUpdaterInterface , Updater
  • postUpdateTasks() : Updater , ModuleUpdater
  • preExecute() : InsertQuery , SelectQueryInterface , SelectQueryExtender , SelectQuery
  • prefixNonTable() : DatabaseSchema
  • prefixTables() : DatabaseConnection
  • preloadRegistry() : DrupalWebTestCase
  • prepare() : DatabaseConnection_sqlite
  • prepareComment() : DatabaseSchema_mysql , DatabaseSchema
  • prepareDatabasePrefix() : DrupalWebTestCase
  • prepareEnvironment() : DrupalWebTestCase
  • prepareExtraFields() : FieldInfo
  • prepareField() : FieldInfo
  • prepareInstallDirectory() : Updater
  • prepareInstance() : FieldInfo
  • prepareInstanceDisplay() : FieldInfo
  • prepareInstanceWidget() : FieldInfo
  • prepareItem() : DrupalDatabaseCache
  • prepareQuery() : DatabaseConnection_pgsql , DatabaseConnection , DatabaseConnection_sqlite
  • processField() : DatabaseSchema_mysql , DatabaseSchema_sqlite , DatabaseSchema_pgsql
  • propertyCondition() : EntityFieldQuery
  • propertyOrderBy() : EntityFieldQuery
  • propertyQuery() : EntityFieldQuery
  • pushTransaction() : DatabaseConnection , DatabaseConnection_sqlite
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- q -

  • query() : DatabaseConnection , DatabaseConnection_pgsql
  • queryCallback() : EntityFieldQuery
  • queryFieldInformation() : DatabaseSchema_pgsql
  • queryRange() : DatabaseConnection_sqlite , DatabaseConnection , DatabaseConnection_mysql , DatabaseConnection_pgsql
  • queryTableInformation() : DatabaseSchema_pgsql
  • queryTemporary() : DatabaseConnection , DatabaseConnection_mysql , DatabaseConnection_sqlite , DatabaseConnection_pgsql
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- r -

  • randomName() : DrupalTestCase
  • randomString() : DrupalTestCase
  • range() : SelectQueryExtender , SelectQuery , SelectQueryInterface , EntityFieldQuery
  • realpath() : DrupalStreamWrapperInterface , DrupalLocalStreamWrapper , FileExampleSessionStreamWrapper
  • refreshVariables() : DrupalWebTestCase
  • releaseItem() : DrupalQueueInterface , SystemQueue , MemoryQueue
  • remove() : ArchiverZip , ArchiverInterface , ArchiverTar
  • removeConnection() : Database
  • removeDirectory() : FileTransfer
  • removeDirectoryJailed() : FileTransfer , FileTransferFTPExtension , FileTransferLocal , FileTransferSSH
  • removeFile() : FileTransfer
  • removeFileJailed() : FileTransfer , FileTransferFTPExtension , FileTransferLocal , FileTransferSSH
  • rename() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • renameConnection() : Database
  • renameTable() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema , DatabaseSchema_sqlite
  • resetAll() : DrupalWebTestCase
  • resetCache() : DrupalEntityControllerInterface , DrupalDefaultEntityController
  • resolveCacheMiss() : SchemaCache , DrupalCacheArray
  • RETURN_AFFECTED : Database
  • RETURN_ALL : EntityFieldQuery
  • RETURN_INSERT_ID : Database
  • RETURN_NULL : Database
  • RETURN_STATEMENT : Database
  • rewind() : DatabaseStatementEmpty , DatabaseStatementPrefetch , SkipDotsRecursiveDirectoryIterator
  • rightJoin() : SelectQuery , SelectQueryInterface , SelectQueryExtender
  • rmdir() : DrupalLocalStreamWrapper , FileExampleSessionStreamWrapper , StreamWrapperInterface
  • rollback() : DatabaseTransaction , DatabaseConnection , DatabaseConnection_sqlite
  • rowCount() : DatabaseStatementPrefetch , DatabaseStatementEmpty , DatabaseStatementInterface
  • run() : DrupalTestCase
  • runTasks() : DatabaseTasks
  • runTestQuery() : DatabaseTasks
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- s -

  • sanitizePath() : FileTransfer
  • save() : EntityExampleBasicControllerInterface , EntityExampleBasicController
  • schema() : DatabaseConnection
  • searchExpression() : SearchQuery
  • select() : DatabaseConnection
  • set() : DrupalFakeCache , DrupalCacheInterface , DrupalDatabaseCache , DrupalCacheArray
  • setActiveConnection() : Database
  • setAttribute() : Archive_Tar
  • setChroot() : FileTransfer
  • setCountQuery() : PagerDefault
  • setFetchMode() : DatabaseStatementEmpty , DatabaseStatementPrefetch
  • setKey() : DatabaseConnection
  • setLogger() : DatabaseConnection
  • setOption() : SearchQuery
  • setPrefix() : DatabaseConnection
  • setTarget() : DatabaseConnection
  • setUp() : DrupalUnitTestCase , DrupalWebTestCase
  • setUri() : FileExampleSessionStreamWrapper , DrupalStreamWrapperInterface , DrupalLocalStreamWrapper
  • skipdots() : SkipDotsRecursiveDirectoryIterator
  • sqlFunctionConcat() : DatabaseConnection_sqlite
  • sqlFunctionGreatest() : DatabaseConnection_sqlite
  • sqlFunctionIf() : DatabaseConnection_sqlite
  • sqlFunctionRand() : DatabaseConnection_sqlite
  • sqlFunctionSubstring() : DatabaseConnection_sqlite
  • sqlFunctionSubstringIndex() : DatabaseConnection_sqlite
  • start() : DatabaseLog
  • startLog() : Database
  • startTransaction() : DatabaseConnection
  • STATUS_INSERT : MergeQuery
  • STATUS_UPDATE : MergeQuery
  • stream_close() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • stream_eof() : StreamWrapperInterface , DrupalLocalStreamWrapper , FileExampleSessionStreamWrapper
  • stream_flush() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • stream_lock() : DrupalLocalStreamWrapper , FileExampleSessionStreamWrapper , StreamWrapperInterface
  • stream_open() : DrupalLocalStreamWrapper , FileExampleSessionStreamWrapper , StreamWrapperInterface
  • stream_read() : FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper , StreamWrapperInterface
  • stream_seek() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • stream_stat() : DrupalLocalStreamWrapper , FileExampleSessionStreamWrapper , StreamWrapperInterface
  • stream_tell() : DrupalLocalStreamWrapper , StreamWrapperInterface , FileExampleSessionStreamWrapper
  • stream_write() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • supportsTransactionalDDL() : DatabaseConnection
  • supportsTransactions() : DatabaseConnection
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- t -

  • tableExists() : DatabaseSchema_mysql , DatabaseSchema , DatabaseSchema_sqlite
  • tablePrefix() : DatabaseConnection
  • tableSort() : EntityFieldQuery
  • tearDown() : DrupalWebTestCase , DrupalUnitTestCase
  • throwPDOException() : DatabaseStatementPrefetch
  • transactionDepth() : DatabaseConnection
  • truncate() : DatabaseConnection
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- u -

  • union() : SelectQueryInterface , SelectQueryExtender , SelectQuery
  • uniqueIdentifier() : QueryPlaceholderInterface , Query , DatabaseSchema , SelectQueryExtender
  • unlink() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • update() : DatabaseConnection , Updater
  • updateFields() : MergeQuery
  • uri_to_session_key() : FileExampleSessionStreamWrapper
  • url_stat() : FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper , StreamWrapperInterface
  • useDefaults() : InsertQuery , MergeQuery
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- v -

  • valid() : DatabaseStatementEmpty , DatabaseStatementPrefetch
  • validateDatabaseSettings() : DatabaseTasks , DatabaseTasks_sqlite
  • values() : InsertQuery
  • verbose() : DrupalTestCase
  • verboseEmail() : DrupalWebTestCase
  • version() : DatabaseConnection
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- w -

  • where() : QueryConditionInterface , SelectQuery , SelectQueryExtender , DatabaseCondition , MergeQuery , UpdateQuery , DeleteQuery
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
Here is a list of all class members with links to the classes they belong to:

- x -

  • xpath() : DrupalWebTestCase
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- _ -

  • __call() : SelectQueryExtender
  • __clone() : Query , DatabaseSchema , SelectQueryInterface , DatabaseCondition , SelectQueryExtender , SelectQuery
  • __construct() : FileExampleSessionStreamWrapper , DatabaseLog , DrupalDefaultEntityController , FileTransfer , DatabaseConnection_mysql , FileTransferException , SkipDotsRecursiveDirectoryIterator , ArchiverInterface , DatabaseConnection_pgsql , FileTransferFTP , FileTransferSSH , DatabaseTasks_pgsql , PagerDefault , TableSort , DrupalCacheArray , DatabaseStatementPrefetch , DrupalCacheArray , Updater , Query , FieldValidationException , DrupalTestCase , SchemaCache , InsertQuery , DrupalUnitTestCase , DrupalWebTestCase , DeleteQuery , ArchiverTar , ArchiverZip , DrupalDatabaseCache , TruncateQuery , SystemQueue , MemoryQueue , UpdateQuery , Archive_Tar , DatabaseConnection , MergeQuery , DatabaseCondition , DatabaseTransaction , DatabaseSchema , SelectQueryExtender , DatabaseStatementBase , SelectQuery , DatabaseConnection_sqlite
  • __destruct() : DrupalCacheArray , DatabaseTransaction , DatabaseConnection_mysql , DatabaseConnection_sqlite , Archive_Tar
  • __get() : FileTransfer
  • __sleep() : Query
  • __toString() : UpdateQuery , MergeQuery , DatabaseCondition , SelectQueryExtender , SelectQuery , InsertQuery_sqlite , TruncateQuery_sqlite , InsertQuery , TruncateQuery , DeleteQuery , Query , InsertQuery_mysql , InsertQuery_pgsql
  • __wakeup() : Query
  • _addFile() : Archive_Tar
  • _addList() : Archive_Tar
  • _addString() : Archive_Tar
  • _append() : Archive_Tar
  • _cleanFile() : Archive_Tar
  • _close() : Archive_Tar
  • _createIndexSql() : DatabaseSchema_pgsql
  • _createKeys() : DatabaseSchema_pgsql
  • _createKeySql() : DatabaseSchema_pgsql
  • _dirCheck() : Archive_Tar
  • _error() : Archive_Tar
  • _extractInString() : Archive_Tar
  • _extractList() : Archive_Tar
  • _isArchive() : Archive_Tar
  • _jumpBlock() : Archive_Tar
  • _maliciousFilename() : Archive_Tar
  • _openAppend() : Archive_Tar
  • _openRead() : Archive_Tar
  • _openReadWrite() : Archive_Tar
  • _openWrite() : Archive_Tar
  • _pathReduction() : Archive_Tar
  • _readBlock() : Archive_Tar
  • _readHeader() : Archive_Tar
  • _readLongHeader() : Archive_Tar
  • _translateWinPath() : Archive_Tar
  • _warning() : Archive_Tar
  • _writeBlock() : Archive_Tar
  • _writeFooter() : Archive_Tar
  • _writeHeader() : Archive_Tar
  • _writeHeaderBlock() : Archive_Tar
  • _writeLongHeader() : Archive_Tar
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- a -

  • add() : ArchiverInterface , ArchiverTar , Archive_Tar , ArchiverZip
  • addCondition() : EntityFieldQuery
  • addConnectionInfo() : Database
  • addExpression() : SelectQueryExtender , SelectQuery , SelectQueryInterface
  • addField() : DatabaseSchema_sqlite , DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema , SelectQueryInterface , SelectQueryExtender , SelectQuery
  • addFieldCondition() : EntityFieldQuery
  • addIndex() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema , DatabaseSchema_sqlite
  • addJoin() : SelectQueryInterface , SelectQueryExtender , SelectQuery
  • addMetaData() : QueryAlterableInterface , SelectQueryExtender , SelectQuery , EntityFieldQuery
  • addModify() : Archive_Tar
  • addPrimaryKey() : DatabaseSchema , DatabaseSchema_sqlite , DatabaseSchema_mysql , DatabaseSchema_pgsql
  • addScore() : SearchQuery
  • addString() : Archive_Tar
  • addTag() : QueryAlterableInterface , SelectQueryExtender , SelectQuery , EntityFieldQuery
  • addUniqueKey() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema , DatabaseSchema_sqlite
  • age() : EntityFieldQuery
  • alterTable() : DatabaseSchema_sqlite
  • arguments() : QueryConditionInterface , DeleteQuery , UpdateQuery , MergeQuery , DatabaseCondition , SelectQueryExtender , SelectQuery
  • assert() : DrupalTestCase
  • assertEqual() : DrupalTestCase
  • assertFalse() : DrupalTestCase
  • assertField() : DrupalWebTestCase
  • assertFieldById() : DrupalWebTestCase
  • assertFieldByName() : DrupalWebTestCase
  • assertFieldByXPath() : DrupalWebTestCase
  • assertFieldChecked() : DrupalWebTestCase
  • assertIdentical() : DrupalTestCase
  • assertLink() : DrupalWebTestCase
  • assertLinkByHref() : DrupalWebTestCase
  • assertMail() : DrupalWebTestCase
  • assertMailPattern() : DrupalWebTestCase
  • assertMailString() : DrupalWebTestCase
  • assertNoDuplicateIds() : DrupalWebTestCase
  • assertNoField() : DrupalWebTestCase
  • assertNoFieldById() : DrupalWebTestCase
  • assertNoFieldByName() : DrupalWebTestCase
  • assertNoFieldByXPath() : DrupalWebTestCase
  • assertNoFieldChecked() : DrupalWebTestCase
  • assertNoLink() : DrupalWebTestCase
  • assertNoLinkByHref() : DrupalWebTestCase
  • assertNoOptionSelected() : DrupalWebTestCase
  • assertNoPattern() : DrupalWebTestCase
  • assertNoRaw() : DrupalWebTestCase
  • assertNoResponse() : DrupalWebTestCase
  • assertNotEqual() : DrupalTestCase
  • assertNoText() : DrupalWebTestCase
  • assertNotIdentical() : DrupalTestCase
  • assertNoTitle() : DrupalWebTestCase
  • assertNotNull() : DrupalTestCase
  • assertNoUniqueText() : DrupalWebTestCase
  • assertNull() : DrupalTestCase
  • assertOptionSelected() : DrupalWebTestCase
  • assertPattern() : DrupalWebTestCase
  • assertRaw() : DrupalWebTestCase
  • assertResponse() : DrupalWebTestCase
  • assertText() : DrupalWebTestCase
  • assertTextHelper() : DrupalWebTestCase
  • assertThemeOutput() : DrupalWebTestCase
  • assertTitle() : DrupalWebTestCase
  • assertTrue() : DrupalTestCase
  • assertUniqueText() : DrupalWebTestCase
  • assertUniqueTextHelper() : DrupalWebTestCase
  • assertUrl() : DrupalWebTestCase
  • attachLoad() : NodeController , CommentController , UserController , DrupalDefaultEntityController
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- b -

  • buildQuery() : DrupalDefaultEntityController , CommentController , TaxonomyTermController , TaxonomyVocabularyController , NodeController
  • buildTableNameCondition() : DatabaseSchema_mysql , DatabaseSchema
  • buildXPathQuery() : DrupalWebTestCase
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- c -

  • cacheGet() : DrupalDefaultEntityController , TaxonomyTermController
  • cacheSet() : DrupalDefaultEntityController
  • canUpdate() : ModuleUpdater , ThemeUpdater
  • canUpdateDirectory() : ThemeUpdater , DrupalUpdaterInterface , ModuleUpdater
  • changeDatabasePrefix() : DrupalWebTestCase
  • changeField() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema , DatabaseSchema_sqlite
  • checkBinaryOutput() : DatabaseTasks_pgsql
  • checkBinaryOutputSuccess() : DatabaseTasks_pgsql
  • checkEncoding() : DatabaseTasks_pgsql
  • checkEngineVersion() : DatabaseTasks
  • checkForMetaRefresh() : DrupalWebTestCase
  • checkPath() : FileTransfer
  • checkPermissions() : DrupalWebTestCase
  • checkPHPVersion() : DatabaseTasks_pgsql
  • chmod() : FileExampleSessionStreamWrapper , FileTransfer , DrupalStreamWrapperInterface , DrupalLocalStreamWrapper
  • chmodJailed() : FileTransferChmodInterface , FileTransferFTPExtension , FileTransferLocal , FileTransferSSH
  • claimItem() : DrupalQueueInterface , SystemQueue , MemoryQueue , BatchQueue , BatchMemoryQueue
  • clear() : DrupalFakeCache , DrupalCacheInterface , DrupalDatabaseCache , DatabaseLog
  • clickLink() : DrupalWebTestCase
  • closeConnection() : Database
  • comment() : Query
  • commit() : DatabaseConnection
  • compile() : QueryConditionInterface , DeleteQuery , TruncateQuery , UpdateQuery , MergeQuery , DatabaseCondition , SelectQueryExtender , SelectQuery
  • compiled() : QueryConditionInterface , DeleteQuery , TruncateQuery , UpdateQuery , MergeQuery , DatabaseCondition , SelectQueryExtender , SelectQuery
  • condition() : SelectQueryExtender , SelectQuery , QueryConditionInterface , DeleteQuery , UpdateQuery , MergeQuery , DatabaseCondition
  • conditions() : SelectQueryExtender , QueryConditionInterface , DeleteQuery , UpdateQuery , MergeQuery , DatabaseCondition , SelectQuery
  • conditionTable() : MergeQuery
  • connect() : FileTransfer , FileTransferLocal , FileTransferSSH , DatabaseTasks , FileTransferFTPExtension
  • constraintExists() : DatabaseSchema_pgsql
  • constructFieldXpath() : DrupalWebTestCase
  • copyDirectory() : FileTransfer
  • copyDirectoryJailed() : FileTransfer , FileTransferSSH
  • copyFile() : FileTransfer
  • copyFileJailed() : FileTransfer , FileTransferFTPExtension , FileTransferSSH , FileTransferLocal
  • count() : EntityFieldQuery , DatabaseCondition
  • countQuery() : SelectQuery , SearchQuery , SelectQueryExtender , SelectQueryInterface
  • create() : EntityExampleBasicController , Archive_Tar , EntityExampleBasicControllerInterface
  • createColumsSql() : DatabaseSchema_sqlite
  • createDirectory() : FileTransfer
  • createDirectoryJailed() : FileTransferSSH , FileTransfer , FileTransferLocal , FileTransferFTPExtension
  • createFieldSql() : DatabaseSchema_pgsql , DatabaseSchema_sqlite , DatabaseSchema_mysql
  • createIndexSql() : DatabaseSchema_sqlite
  • createItem() : DrupalQueueInterface , MemoryQueue , SystemQueue
  • createKeySql() : DatabaseSchema_mysql , DatabaseSchema_sqlite
  • createKeysSql() : DatabaseSchema_mysql
  • createKeysSqlHelper() : DatabaseSchema_mysql
  • createModify() : Archive_Tar
  • createQueue() : SystemQueue , DrupalQueueInterface , MemoryQueue
  • createTable() : DatabaseSchema
  • createTableSql() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema_sqlite
  • cronRun() : DrupalWebTestCase
  • curlClose() : DrupalWebTestCase
  • curlExec() : DrupalWebTestCase
  • curlHeaderCallback() : DrupalWebTestCase
  • curlInitialize() : DrupalWebTestCase
  • current() : DatabaseStatementPrefetch , DatabaseStatementEmpty
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- d -

  • databaseType() : DatabaseConnection , DatabaseConnection_mysql , DatabaseConnection_sqlite , DatabaseConnection_pgsql
  • defaultOptions() : DatabaseConnection
  • delete() : DatabaseConnection , EntityExampleBasicControllerInterface , EntityExampleBasicController
  • delete_multiple() : EntityExampleBasicController
  • deleteAssert() : DrupalTestCase
  • deleted() : EntityFieldQuery
  • deleteItem() : DrupalQueueInterface , SystemQueue , MemoryQueue
  • deleteQueue() : SystemQueue , MemoryQueue , DrupalQueueInterface
  • destroy() : DatabaseConnection
  • dir_closedir() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • dir_opendir() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • dir_readdir() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • dir_rewinddir() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • dirname() : DrupalStreamWrapperInterface , DrupalLocalStreamWrapper , FileExampleSessionStreamWrapper
  • distinct() : SelectQueryInterface , SelectQueryExtender , SelectQuery
  • driver() : DatabaseConnection , DatabaseConnection_mysql , DatabaseConnection_pgsql , DatabaseConnection_sqlite
  • dropField() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema , DatabaseSchema_sqlite
  • dropIndex() : DatabaseSchema , DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema_sqlite
  • dropPrimaryKey() : DatabaseSchema , DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema_sqlite
  • dropTable() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema_sqlite , DatabaseSchema
  • dropUniqueKey() : DatabaseSchema , DatabaseSchema_pgsql , DatabaseSchema_mysql , DatabaseSchema_sqlite
  • drupalCompareFiles() : DrupalWebTestCase
  • drupalCreateContentType() : DrupalWebTestCase
  • drupalCreateNode() : DrupalWebTestCase
  • drupalCreateRole() : DrupalWebTestCase
  • drupalCreateUser() : DrupalWebTestCase
  • drupalGet() : DrupalWebTestCase
  • drupalGetAJAX() : DrupalWebTestCase
  • drupalGetContent() : DrupalWebTestCase
  • drupalGetHeader() : DrupalWebTestCase
  • drupalGetHeaders() : DrupalWebTestCase
  • drupalGetMails() : DrupalWebTestCase
  • drupalGetNodeByTitle() : DrupalWebTestCase
  • drupalGetSettings() : DrupalWebTestCase
  • drupalGetTestFiles() : DrupalWebTestCase
  • drupalGetToken() : DrupalWebTestCase
  • drupalHead() : DrupalWebTestCase
  • drupalLogin() : DrupalWebTestCase
  • drupalLogout() : DrupalWebTestCase
  • drupalPost() : DrupalWebTestCase
  • drupalPostAJAX() : DrupalWebTestCase
  • drupalSetContent() : DrupalWebTestCase
  • drupalSetSettings() : DrupalWebTestCase
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- e -

  • element() : PagerDefault
  • end() : DatabaseLog
  • ensureElement() : PagerDefault
  • entityCondition() : EntityFieldQuery
  • entityOrderBy() : EntityFieldQuery
  • error() : DrupalTestCase
  • errorHandler() : DrupalTestCase
  • escapeAlias() : DatabaseConnection
  • escapeField() : DatabaseConnection
  • escapeLike() : DatabaseConnection
  • escapeTable() : DatabaseConnection
  • exceptionHandler() : DrupalTestCase
  • execute() : InsertQuery_mysql , EntityFieldQuery , PagerDefault , InsertQuery_pgsql , SearchQuery , UpdateQuery_pgsql , DatabaseStatementPrefetch , Query , InsertQuery , DeleteQuery , TruncateQuery , UpdateQuery , MergeQuery , DeleteQuery_sqlite , UpdateQuery_sqlite , InsertQuery_sqlite , DatabaseStatementInterface , SelectQueryExtender , SelectQuery , DatabaseStatementBase , DatabaseStatement_sqlite , DatabaseStatementEmpty
  • executeFirstPass() : SearchQuery
  • exists() : SelectQuery , MergeQuery , QueryConditionInterface , DeleteQuery , SelectQueryExtender , UpdateQuery , DatabaseCondition
  • expandArguments() : DatabaseConnection
  • expression() : UpdateQuery , MergeQuery
  • extend() : QueryExtendableInterface , SelectQueryExtender , SelectQuery
  • extract() : ArchiverTar , ArchiverZip , Archive_Tar , ArchiverInterface
  • extractInString() : Archive_Tar
  • extractList() : Archive_Tar
  • extractModify() : Archive_Tar
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- f -

  • factory() : FileTransfer , FileTransferFTP , FileTransferSSH , Updater , FileTransferLocal
  • fail() : DatabaseTasks , DrupalTestCase
  • fetch() : DatabaseStatementEmpty , DatabaseStatementPrefetch
  • fetchAll() : DatabaseStatementEmpty , DatabaseStatementPrefetch
  • fetchAllAssoc() : DatabaseStatementInterface , DatabaseStatementBase , DatabaseStatementEmpty , DatabaseStatementPrefetch
  • fetchAllKeyed() : DatabaseStatementInterface , DatabaseStatementBase , DatabaseStatementEmpty , DatabaseStatementPrefetch
  • fetchAssoc() : DatabaseStatementInterface , DatabaseStatementBase , DatabaseStatementEmpty , DatabaseStatementPrefetch
  • fetchCol() : DatabaseStatementInterface , DatabaseStatementBase , DatabaseStatementEmpty , DatabaseStatementPrefetch
  • fetchColumn() : DatabaseStatementPrefetch
  • fetchField() : DatabaseStatementPrefetch , DatabaseStatementInterface , DatabaseStatementBase , DatabaseStatementEmpty
  • fetchObject() : DatabaseStatementEmpty , DatabaseStatementPrefetch
  • fieldCondition() : EntityFieldQuery
  • fieldDeltaCondition() : EntityFieldQuery
  • fieldExists() : DatabaseSchema_sqlite , DatabaseSchema_mysql , DatabaseSchema
  • fieldLanguageCondition() : EntityFieldQuery
  • fieldNames() : DatabaseSchema
  • fieldOrderBy() : EntityFieldQuery
  • fields() : UpdateQuery , MergeQuery , SelectQueryInterface , SelectQuery , InsertQuery , SelectQueryExtender
  • fieldSetDefault() : DatabaseSchema , DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema_sqlite
  • fieldSetNoDefault() : DatabaseSchema_mysql , DatabaseSchema , DatabaseSchema_sqlite , DatabaseSchema_pgsql
  • filterComment() : DatabaseConnection
  • findCaller() : DatabaseLog
  • findChroot() : FileTransfer
  • findInfoFile() : Updater
  • findTables() : DatabaseSchema , DatabaseSchema_sqlite
  • finishQuery() : EntityFieldQuery
  • fixRemotePath() : FileTransfer
  • flush() : FieldInfo
  • format() : MailSystemInterface , DefaultMailSystem
  • forUpdate() : SelectQuery_sqlite , SelectQueryInterface , SelectQuery , SelectQueryExtender
  • from() : InsertQuery
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- g -

  • garbageCollection() : DrupalDatabaseCache
  • generatePermutations() : DrupalTestCase
  • generateTemporaryTableName() : DatabaseConnection
  • get() : DrupalFakeCache , DrupalQueue , DrupalCacheInterface , DrupalDatabaseCache , DatabaseLog
  • getAbsoluteUrl() : DrupalWebTestCase
  • getAllItems() : BatchQueue , BatchMemoryQueue
  • getAllOptions() : DrupalWebTestCase
  • getArchive() : ArchiverTar , ArchiverZip
  • getArguments() : SelectQueryExtender , SelectQuery , SelectQueryInterface
  • getAssertionCall() : DrupalTestCase
  • getBackupDir() : Updater
  • getBundleExtraFields() : FieldInfo
  • getBundleInstances() : FieldInfo
  • getComment() : DatabaseSchema_mysql , DatabaseSchema_pgsql
  • getComments() : Query
  • getConnection() : Database
  • getConnectionInfo() : Database
  • getConnectionOptions() : DatabaseConnection
  • getCountQuery() : PagerDefault
  • getDirectoryPath() : DrupalPrivateStreamWrapper , DrupalTemporaryStreamWrapper , FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper , DrupalPublicStreamWrapper
  • getDriverClass() : DatabaseConnection
  • getExpressions() : SelectQueryInterface , SelectQueryExtender , SelectQuery
  • getExternalUrl() : FileExampleSessionStreamWrapper , DrupalStreamWrapperInterface , DrupalPublicStreamWrapper , DrupalPrivateStreamWrapper , DrupalTemporaryStreamWrapper
  • getField() : FieldInfo
  • getFieldById() : FieldInfo
  • getFieldMap() : FieldInfo
  • getFields() : SelectQueryInterface , SelectQueryExtender , SelectQuery , FieldInfo
  • getFieldTypeMap() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema , DatabaseSchema_sqlite
  • getFormOptions() : DatabaseTasks_sqlite , DatabaseTasks
  • getGroupBy() : SelectQueryInterface , SelectQueryExtender , SelectQuery
  • getInstallArgs() : Updater
  • getInstallDirectory() : DrupalUpdaterInterface , ModuleUpdater , ThemeUpdater
  • getInstances() : FieldInfo
  • getKey() : DatabaseConnection
  • getLocalPath() : FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper
  • getLog() : Database
  • getLogger() : DatabaseConnection
  • getMetaData() : QueryAlterableInterface , SelectQueryExtender , SelectQuery
  • getMimeType() : FileExampleSessionStreamWrapper , DrupalStreamWrapperInterface , DrupalLocalStreamWrapper
  • getMultiple() : DrupalCacheInterface , DrupalDatabaseCache , DrupalFakeCache
  • getOrderBy() : SelectQueryExtender , SelectQueryInterface , SelectQuery
  • getPrefixInfo() : DatabaseSchema , DatabaseSchema_mysql
  • getProjectName() : DrupalUpdaterInterface , Updater
  • getProjectTitle() : Updater
  • getQueryParameters() : TableSort
  • getQueryString() : DatabaseStatementInterface , DatabaseStatementBase , DatabaseStatementPrefetch , DatabaseStatementEmpty
  • getSchemaUpdates() : ModuleUpdater
  • getSelectedItem() : DrupalWebTestCase
  • getSettingsForm() : FileTransferSSH , FileTransfer , FileTransferFTP
  • getSort() : TableSort
  • getStatement() : DatabaseStatement_sqlite , DatabaseStatementPrefetch
  • getTables() : SelectQueryExtender , SelectQuery , SelectQueryInterface
  • getTarget() : DrupalLocalStreamWrapper , FileExampleSessionStreamWrapper , DatabaseConnection
  • getUnion() : SelectQueryInterface , SelectQuery , SelectQueryExtender
  • getUpdaterFromDirectory() : Updater
  • getUri() : FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper , DrupalStreamWrapperInterface
  • getUrl() : DrupalWebTestCase
  • groupBy() : SelectQueryExtender , SelectQuery , SelectQueryInterface
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- h -

  • handleForm() : DrupalWebTestCase
  • hasAllTags() : QueryAlterableInterface , SelectQuery , SelectQueryExtender
  • hasAnyTag() : QueryAlterableInterface , SelectQueryExtender , SelectQuery
  • hasPdoDriver() : DatabaseTasks
  • hasTag() : QueryAlterableInterface , SelectQueryExtender , SelectQuery
  • having() : SelectQueryExtender , SelectQuery
  • havingArguments() : SelectQuery , SelectQueryExtender
  • havingCompile() : SelectQueryExtender , SelectQuery
  • havingCondition() : SelectQueryExtender , SelectQueryInterface , SelectQuery
  • havingConditions() : SelectQuery , SelectQueryExtender
  • havingExists() : SelectQuery
  • havingIsNotNull() : SelectQuery
  • havingIsNull() : SelectQuery
  • havingNotExists() : SelectQuery
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- i -

  • ignoreTarget() : Database
  • indexExists() : DatabaseSchema_mysql , DatabaseSchema , DatabaseSchema_sqlite , DatabaseSchema_pgsql
  • init() : TableSort
  • initializeDatabase() : DatabaseTasks_pgsql
  • initializePager() : EntityFieldQuery
  • initializeRegistry() : DrupalCacheArray
  • innerJoin() : SelectQueryInterface , SelectQueryExtender , SelectQuery
  • insert() : DatabaseConnection
  • insertAssert() : DrupalTestCase
  • insertFields() : MergeQuery
  • install() : Updater
  • installable() : DatabaseTasks
  • inTransaction() : DatabaseConnection
  • introspectSchema() : DatabaseSchema_sqlite
  • isActiveConnection() : Database
  • isDirectory() : FileTransfer , FileTransferFTPExtension , FileTransferLocal , FileTransferSSH
  • isEmpty() : DrupalFakeCache , DrupalCacheInterface , DrupalDatabaseCache
  • isFile() : FileTransferSSH , FileTransfer , FileTransferFTPExtension , FileTransferLocal
  • isInstalled() : DrupalUpdaterInterface , ModuleUpdater , ThemeUpdater
  • isNotNull() : UpdateQuery , DeleteQuery , MergeQuery , QueryConditionInterface , SelectQueryExtender , DatabaseCondition , SelectQuery
  • isNull() : DeleteQuery , SelectQueryExtender , UpdateQuery , MergeQuery , DatabaseCondition , QueryConditionInterface , SelectQuery
  • isPrepared() : SelectQuery , SelectQueryExtender , SelectQueryInterface
  • isValidBin() : DrupalDatabaseCache
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- j -

  • join() : SelectQueryInterface , SelectQuery , SelectQueryExtender
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- k -

  • key() : DatabaseStatementEmpty , MergeQuery , DatabaseStatementPrefetch
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- l -

  • leftJoin() : SelectQueryInterface , SelectQueryExtender , SelectQuery
  • limit() : PagerDefault
  • listContent() : Archive_Tar
  • listContents() : ArchiverZip , ArchiverInterface , ArchiverTar
  • load() : DrupalEntityControllerInterface , DrupalDefaultEntityController
  • loadDriverFile() : Database
  • loadExtension() : Archive_Tar
  • log() : DatabaseLog
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- m -

  • mail() : MailSystemInterface , DefaultMailSystem , TestingMailSystem
  • makeBackup() : Updater
  • makeComment() : DatabaseConnection
  • makeSequenceName() : DatabaseConnection
  • makeWorldReadable() : Updater
  • mapConditionOperator() : DatabaseConnection , DatabaseConnection_mysql , DatabaseConnection_pgsql , DatabaseCondition , DatabaseConnection_sqlite
  • mapKeyDefinition() : DatabaseSchema_sqlite
  • merge() : DatabaseConnection
  • minimumVersion() : DatabaseTasks_mysql , DatabaseTasks_pgsql , DatabaseTasks_sqlite , DatabaseTasks
  • mkdir() : StreamWrapperInterface , FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- n -

  • name() : DatabaseTransaction , DatabaseTasks_mysql , DatabaseTasks_sqlite , DatabaseTasks , DatabaseTasks_pgsql
  • next() : SkipDotsRecursiveDirectoryIterator , DatabaseStatementEmpty , DatabaseStatementPrefetch
  • nextId() : DatabaseConnection , DatabaseConnection_mysql , DatabaseConnection_pgsql , DatabaseConnection_sqlite
  • nextIdDelete() : DatabaseConnection_mysql
  • nextPlaceholder() : DatabaseSchema , SelectQueryExtender , QueryPlaceholderInterface , Query
  • notExists() : DatabaseCondition , UpdateQuery , SelectQueryExtender , QueryConditionInterface , MergeQuery , DeleteQuery , SelectQuery
  • numberOfItems() : SystemQueue , MemoryQueue , DrupalQueueInterface
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- o -

  • offsetExists() : DrupalCacheArray
  • offsetGet() : DrupalCacheArray
  • offsetSet() : DrupalCacheArray
  • offsetUnset() : DrupalCacheArray
  • openConnection() : Database
  • order() : TableSort
  • orderBy() : SelectQueryExtender , SelectQuery_pgsql , SelectQueryInterface , SelectQuery
  • orderByHeader() : TableSort
  • orderRandom() : SelectQuery_pgsql , SelectQueryExtender , SelectQueryInterface , SelectQuery
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- p -

  • pager() : EntityFieldQuery
  • parse() : DrupalWebTestCase
  • parseConnectionInfo() : Database
  • parseSearchExpression() : SearchQuery
  • parseWord() : SearchQuery
  • pass() : DatabaseTasks , DrupalTestCase
  • PDOPrepare() : DatabaseConnection_sqlite
  • persist() : DrupalCacheArray
  • popCommittableTransactions() : DatabaseConnection , DatabaseConnection_mysql
  • popTransaction() : DatabaseConnection , DatabaseConnection_sqlite
  • postInstall() : ThemeUpdater , DrupalUpdaterInterface , Updater
  • postInstallTasks() : Updater , ModuleUpdater , ThemeUpdater
  • postUpdate() : DrupalUpdaterInterface , Updater
  • postUpdateTasks() : Updater , ModuleUpdater
  • preExecute() : InsertQuery , SelectQueryInterface , SelectQueryExtender , SelectQuery
  • prefixNonTable() : DatabaseSchema
  • prefixTables() : DatabaseConnection
  • preloadRegistry() : DrupalWebTestCase
  • prepare() : DatabaseConnection_sqlite
  • prepareComment() : DatabaseSchema_mysql , DatabaseSchema
  • prepareDatabasePrefix() : DrupalWebTestCase
  • prepareEnvironment() : DrupalWebTestCase
  • prepareExtraFields() : FieldInfo
  • prepareField() : FieldInfo
  • prepareInstallDirectory() : Updater
  • prepareInstance() : FieldInfo
  • prepareInstanceDisplay() : FieldInfo
  • prepareInstanceWidget() : FieldInfo
  • prepareItem() : DrupalDatabaseCache
  • prepareQuery() : DatabaseConnection_pgsql , DatabaseConnection , DatabaseConnection_sqlite
  • processField() : DatabaseSchema_mysql , DatabaseSchema_sqlite , DatabaseSchema_pgsql
  • propertyCondition() : EntityFieldQuery
  • propertyOrderBy() : EntityFieldQuery
  • propertyQuery() : EntityFieldQuery
  • pushTransaction() : DatabaseConnection , DatabaseConnection_sqlite
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- q -

  • query() : DatabaseConnection , DatabaseConnection_pgsql
  • queryCallback() : EntityFieldQuery
  • queryFieldInformation() : DatabaseSchema_pgsql
  • queryRange() : DatabaseConnection_sqlite , DatabaseConnection , DatabaseConnection_mysql , DatabaseConnection_pgsql
  • queryTableInformation() : DatabaseSchema_pgsql
  • queryTemporary() : DatabaseConnection , DatabaseConnection_mysql , DatabaseConnection_sqlite , DatabaseConnection_pgsql
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- r -

  • randomName() : DrupalTestCase
  • randomString() : DrupalTestCase
  • range() : SelectQueryExtender , SelectQuery , SelectQueryInterface , EntityFieldQuery
  • realpath() : DrupalStreamWrapperInterface , DrupalLocalStreamWrapper , FileExampleSessionStreamWrapper
  • refreshVariables() : DrupalWebTestCase
  • releaseItem() : DrupalQueueInterface , SystemQueue , MemoryQueue
  • remove() : ArchiverZip , ArchiverInterface , ArchiverTar
  • removeConnection() : Database
  • removeDirectory() : FileTransfer
  • removeDirectoryJailed() : FileTransfer , FileTransferFTPExtension , FileTransferLocal , FileTransferSSH
  • removeFile() : FileTransfer
  • removeFileJailed() : FileTransfer , FileTransferFTPExtension , FileTransferLocal , FileTransferSSH
  • rename() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • renameConnection() : Database
  • renameTable() : DatabaseSchema_mysql , DatabaseSchema_pgsql , DatabaseSchema , DatabaseSchema_sqlite
  • resetAll() : DrupalWebTestCase
  • resetCache() : DrupalEntityControllerInterface , DrupalDefaultEntityController
  • resolveCacheMiss() : DrupalCacheArray , SchemaCache , DrupalCacheArray
  • rewind() : DatabaseStatementPrefetch , DatabaseStatementEmpty , SkipDotsRecursiveDirectoryIterator
  • rightJoin() : SelectQuery , SelectQueryInterface , SelectQueryExtender
  • rmdir() : StreamWrapperInterface , FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper
  • rollback() : DatabaseConnection_sqlite , DatabaseConnection , DatabaseTransaction
  • rowCount() : DatabaseStatementInterface , DatabaseStatementEmpty , DatabaseStatementPrefetch
  • run() : DrupalTestCase
  • runTasks() : DatabaseTasks
  • runTestQuery() : DatabaseTasks
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- s -

  • sanitizePath() : FileTransfer
  • save() : EntityExampleBasicControllerInterface , EntityExampleBasicController
  • schema() : DatabaseConnection
  • searchExpression() : SearchQuery
  • select() : DatabaseConnection
  • set() : DrupalFakeCache , DrupalCacheInterface , DrupalDatabaseCache , DrupalCacheArray
  • setActiveConnection() : Database
  • setAttribute() : Archive_Tar
  • setChroot() : FileTransfer
  • setCountQuery() : PagerDefault
  • setFetchMode() : DatabaseStatementEmpty , DatabaseStatementPrefetch
  • setKey() : DatabaseConnection
  • setLogger() : DatabaseConnection
  • setOption() : SearchQuery
  • setPrefix() : DatabaseConnection
  • setTarget() : DatabaseConnection
  • setUp() : DrupalUnitTestCase , DrupalWebTestCase
  • setUri() : FileExampleSessionStreamWrapper , DrupalStreamWrapperInterface , DrupalLocalStreamWrapper
  • skipdots() : SkipDotsRecursiveDirectoryIterator
  • sqlFunctionConcat() : DatabaseConnection_sqlite
  • sqlFunctionGreatest() : DatabaseConnection_sqlite
  • sqlFunctionIf() : DatabaseConnection_sqlite
  • sqlFunctionRand() : DatabaseConnection_sqlite
  • sqlFunctionSubstring() : DatabaseConnection_sqlite
  • sqlFunctionSubstringIndex() : DatabaseConnection_sqlite
  • start() : DatabaseLog
  • startLog() : Database
  • startTransaction() : DatabaseConnection
  • stream_close() : StreamWrapperInterface , FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper
  • stream_eof() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • stream_flush() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • stream_lock() : StreamWrapperInterface , DrupalLocalStreamWrapper , FileExampleSessionStreamWrapper
  • stream_open() : DrupalLocalStreamWrapper , StreamWrapperInterface , FileExampleSessionStreamWrapper
  • stream_read() : FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper , StreamWrapperInterface
  • stream_seek() : DrupalLocalStreamWrapper , FileExampleSessionStreamWrapper , StreamWrapperInterface
  • stream_stat() : DrupalLocalStreamWrapper , StreamWrapperInterface , FileExampleSessionStreamWrapper
  • stream_tell() : StreamWrapperInterface , FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper
  • stream_write() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • supportsTransactionalDDL() : DatabaseConnection
  • supportsTransactions() : DatabaseConnection
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- t -

  • tableExists() : DatabaseSchema_mysql , DatabaseSchema , DatabaseSchema_sqlite
  • tablePrefix() : DatabaseConnection
  • tableSort() : EntityFieldQuery
  • tearDown() : DrupalWebTestCase , DrupalUnitTestCase
  • throwPDOException() : DatabaseStatementPrefetch
  • transactionDepth() : DatabaseConnection
  • truncate() : DatabaseConnection
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- u -

  • union() : SelectQueryInterface , SelectQueryExtender , SelectQuery
  • uniqueIdentifier() : QueryPlaceholderInterface , Query , DatabaseSchema , SelectQueryExtender
  • unlink() : FileExampleSessionStreamWrapper , StreamWrapperInterface , DrupalLocalStreamWrapper
  • update() : DatabaseConnection , Updater
  • updateFields() : MergeQuery
  • uri_to_session_key() : FileExampleSessionStreamWrapper
  • url_stat() : FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper , StreamWrapperInterface
  • useDefaults() : InsertQuery , MergeQuery
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- v -

  • valid() : DatabaseStatementEmpty , DatabaseStatementPrefetch
  • validateDatabaseSettings() : DatabaseTasks , DatabaseTasks_sqlite
  • values() : InsertQuery
  • verbose() : DrupalTestCase
  • verboseEmail() : DrupalWebTestCase
  • version() : DatabaseConnection
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- w -

  • where() : QueryConditionInterface , SelectQuery , SelectQueryExtender , DatabaseCondition , MergeQuery , UpdateQuery , DeleteQuery
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Functions

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- x -

  • xpath() : DrupalWebTestCase
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Variables

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • c
  • r
  • s

- $ -

  • $_compress : Archive_Tar
  • $_compress_type : Archive_Tar
  • $_file : Archive_Tar
  • $_separator : Archive_Tar
  • $_tarname : Archive_Tar
  • $_temp_tarname : Archive_Tar
  • $activeKey : Database
  • $additionalCurlOptions : DrupalWebTestCase
  • $age : EntityFieldQuery
  • $altered : EntityFieldQuery
  • $arguments : UpdateQuery , DatabaseCondition , FileTransferException
  • $assertions : DrupalTestCase
  • $attachedDatabases : DatabaseConnection_sqlite
  • $bin : DrupalCacheArray , DrupalDatabaseCache
  • $bundleExtraFields : FieldInfo
  • $bundleInstances : FieldInfo
  • $cache : DrupalDefaultEntityController
  • $changed : DatabaseCondition
  • $cid : DrupalCacheArray
  • $columnNames : DatabaseStatementPrefetch
  • $comments : Query
  • $completeRegistry : DrupalCacheArray
  • $condition : DeleteQuery , UpdateQuery
  • $conditions : DatabaseCondition , SearchQuery
  • $conditionTable : MergeQuery
  • $connection : Query , DatabaseSchema , SelectQueryExtender , DatabaseTransaction
  • $connectionKey : DatabaseLog , Query
  • $connectionOptions : DatabaseConnection
  • $connections : Database
  • $connectionTarget : Query
  • $content : DrupalWebTestCase
  • $context : FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper
  • $cookieFile : DrupalWebTestCase
  • $count : EntityFieldQuery
  • $curlHandle : DrupalWebTestCase
  • $currentKey : DatabaseStatementPrefetch
  • $currentRow : DatabaseStatementPrefetch
  • $customCountQuery : PagerDefault
  • $data : DatabaseStatementPrefetch
  • $databaseInfo : Database
  • $databasePrefix : DrupalTestCase
  • $dbh : DatabaseStatementBase , DatabaseStatementPrefetch
  • $defaultFetchOptions : DatabaseStatementPrefetch
  • $defaultFetchStyle : DatabaseStatementPrefetch
  • $defaultFields : InsertQuery , MergeQuery
  • $defaultSchema : DatabaseSchema , DatabaseSchema_sqlite
  • $deleted : EntityFieldQuery
  • $directory_keys : FileExampleSessionStreamWrapper
  • $directory_pointer : FileExampleSessionStreamWrapper
  • $distinct : SelectQuery
  • $driverClasses : DatabaseConnection
  • $driverOptions : DatabaseStatementPrefetch
  • $drupalSettings : DrupalWebTestCase
  • $element : PagerDefault
  • $elements : DrupalWebTestCase
  • $emptyBundles : FieldInfo
  • $entityCache : DrupalDefaultEntityController
  • $entityConditions : EntityFieldQuery
  • $entityInfo : DrupalDefaultEntityController
  • $entityType : DrupalDefaultEntityController
  • $errors : FieldValidationException
  • $executeCallback : EntityFieldQuery
  • $executedFirstPass : SearchQuery
  • $expressionFields : UpdateQuery , MergeQuery
  • $expressions : SelectQuery
  • $expressionsIgnored : SearchQuery
  • $fetchOptions : DatabaseStatementPrefetch
  • $fetchStyle : DatabaseStatementPrefetch
  • $fieldConditions : EntityFieldQuery
  • $fieldIdsByName : FieldInfo
  • $fieldMap : FieldInfo
  • $fieldMetaConditions : EntityFieldQuery
  • $fields : UpdateQuery , SelectQuery , EntityFieldQuery
  • $fieldsById : FieldInfo
  • $forUpdate : SelectQuery
  • $fromQuery : InsertQuery
  • $generatedTestFiles : DrupalWebTestCase
  • $group : SelectQuery
  • $handle : DrupalLocalStreamWrapper
  • $having : SelectQuery
  • $header : TableSort
  • $headers : DrupalWebTestCase
  • $hookLoadArguments : DrupalDefaultEntityController
  • $hostname : FileTransfer
  • $httpauth_credentials : DrupalWebTestCase
  • $httpauth_method : DrupalWebTestCase
  • $id_sequence : MemoryQueue
  • $idKey : DrupalDefaultEntityController
  • $ignoreTargets : Database
  • $insertFields : InsertQuery , MergeQuery
  • $insertValues : InsertQuery , MergeQuery
  • $key : DatabaseConnection
  • $keys : SearchQuery
  • $keysToPersist : DrupalCacheArray
  • $limit : PagerDefault
  • $loadedAllFields : FieldInfo
  • $loadedAllInstances : FieldInfo
  • $loggedInUser : DrupalWebTestCase
  • $logger : DatabaseConnection
  • $logs : Database
  • $matches : SearchQuery
  • $maxElement : PagerDefault
  • $metaData : EntityFieldQuery
  • $multiply : SearchQuery
  • $name : DatabaseTransaction , SystemQueue
  • $needsCleanup : DatabaseConnection_mysql
  • $needsUpdate : MergeQuery
  • $nextPlaceholder : Query
  • $normalize : SearchQuery
  • $order : SelectQuery , EntityFieldQuery
  • $orderedResults : EntityFieldQuery
  • $originalFileDirectory : DrupalTestCase
  • $originalShutdownCallbacks : DrupalWebTestCase
  • $originalUser : DrupalWebTestCase
  • $pager : EntityFieldQuery
  • $password : FileTransfer
  • $pdoDriver : DatabaseTasks_mysql , DatabaseTasks_pgsql , DatabaseTasks_sqlite
  • $persistable : DrupalCacheArray
  • $placeholder : DatabaseSchema , SelectQueryExtender
  • $plainTextContent : DrupalWebTestCase
  • $port : FileTransfer
  • $prefixes : DatabaseConnection
  • $prefixReplace : DatabaseConnection
  • $prefixSearch : DatabaseConnection
  • $prepared : SelectQuery
  • $profile : DrupalWebTestCase
  • $propertyConditions : EntityFieldQuery
  • $query : SelectQueryExtender
  • $queryLog : DatabaseLog
  • $queryOptions : Query
  • $queryPlaceholderIdentifier : DatabaseCondition
  • $queryString : DatabaseStatementPrefetch
  • $queue : MemoryQueue
  • $range : EntityFieldQuery , SelectQuery
  • $redirect_count : DrupalWebTestCase
  • $resultRowCount : DatabaseStatementPrefetch
  • $results : DrupalTestCase , DatabaseTasks
  • $revisionKey : DrupalDefaultEntityController
  • $revisionTable : DrupalDefaultEntityController
  • $rolledBack : DatabaseTransaction
  • $rowCount : DatabaseStatementPrefetch
  • $savepointSupport : DatabaseConnection_sqlite
  • $schema : DatabaseConnection
  • $scores : SearchQuery
  • $scoresArguments : SearchQuery
  • $searchExpression : SearchQuery
  • $session_content : FileExampleSessionStreamWrapper
  • $session_id : DrupalWebTestCase
  • $session_name : DrupalWebTestCase
  • $setup : DrupalTestCase
  • $setupDatabasePrefix : DrupalTestCase
  • $setupEnvironment : DrupalTestCase
  • $simple : SearchQuery
  • $skipClasses : DrupalTestCase
  • $source : Updater
  • $statementClass : DatabaseConnection
  • $storage : DrupalCacheArray
  • $stream_pointer : FileExampleSessionStreamWrapper
  • $table : UpdateQuery , DeleteQuery , InsertQuery , MergeQuery , TruncateQuery
  • $tableDropped : DatabaseConnection_sqlite
  • $tableInformation : DatabaseSchema_pgsql
  • $tables : SelectQuery
  • $tags : EntityFieldQuery
  • $tar : ArchiverTar
  • $target : DatabaseConnection
  • $tasks : DatabaseTasks
  • $temporaryNameIndex : DatabaseConnection
  • $testId : DrupalTestCase
  • $timeLimit : DrupalTestCase
  • $transactionalDDLSupport : DatabaseConnection
  • $transactionLayers : DatabaseConnection
  • $transactionSupport : DatabaseConnection
  • $type : SearchQuery
  • $union : SelectQuery
  • $uniqueIdentifier : Query , SelectQueryExtender , DatabaseSchema
  • $unknownFields : FieldInfo
  • $updateFields : MergeQuery
  • $uri : FileExampleSessionStreamWrapper , DrupalLocalStreamWrapper
  • $url : DrupalWebTestCase
  • $username : FileTransfer
  • $where : SelectQuery
  • $willRollback : DatabaseConnection_sqlite
  • $words : SearchQuery
  • $zip : ArchiverZip
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Variables

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • c
  • r
  • s

- c -

  • COMMENT_MAX_COLUMN : DatabaseSchema_mysql
  • COMMENT_MAX_TABLE : DatabaseSchema_mysql
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Variables

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • c
  • r
  • s

- r -

  • RETURN_AFFECTED : Database
  • RETURN_ALL : EntityFieldQuery
  • RETURN_INSERT_ID : Database
  • RETURN_NULL : Database
  • RETURN_STATEMENT : Database
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Class Members - Variables

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • All
  • Functions
  • Variables
  • $
  • c
  • r
  • s

- s -

  • STATUS_INSERT : MergeQuery
  • STATUS_UPDATE : MergeQuery
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File List

File List
Here is a list of all files with brief descriptions:
[detail level 12345]
o + examples
| o + action_example
| | \ * action_example.module
| o + ajax_example
| | o * ajax_example.install
| | o * ajax_example.module
| | o * ajax_example_advanced.inc
| | o * ajax_example_autocomplete.inc
| | o * ajax_example_graceful_degradation.inc
| | o * ajax_example_misc.inc
| | \ * ajax_example_node_form_alter.inc
| o + batch_example
| | o * batch_example.install
| | \ * batch_example.module
| o + block_example
| | o * block_example.install
| | \ * block_example.module
| o + cache_example
| | \ * cache_example.module
| o + contextual_links_example
| | o * contextual-links-example-object.tpl.php
| | \ * contextual_links_example.module
| o + cron_example
| | \ * cron_example.module
| o + dbtng_example
| | o * dbtng_example.install
| | \ * dbtng_example.module
| o + email_example
| | \ * email_example.module
| o + entity_example
| | o * entity_example.install
| | \ * entity_example.module
| o + field_example
| | o * field_example.install
| | \ * field_example.module
| o + field_permission_example
| | o * field_permission_example.install
| | \ * field_permission_example.module
| o + file_example
| | o * file_example.module
| | \ * file_example_session_streams.inc
| o + filter_example
| | \ * filter_example.module
| o + form_example
| | o * form_example.module
| | o * form_example_elements.inc
| | o * form_example_states.inc
| | o * form_example_tutorial.inc
| | \ * form_example_wizard.inc
| o + image_example
| | o * image_example.install
| | o * image_example.module
| | \ * image_example.pages.inc
| o + js_example
| | o * accordion.tpl.php
| | \ * js_example.module
| o + menu_example
| | \ * menu_example.module
| o + node_access_example
| | o * node_access_example.install
| | \ * node_access_example.module
| o + node_example
| | \ * node_example.module
| o + nodeapi_example
| | o * nodeapi_example.install
| | \ * nodeapi_example.module
| o + page_example
| | \ * page_example.module
| o + pager_example
| | \ * pager_example.module
| o + queue_example
| | \ * queue_example.module
| o + rdf_example
| | o * rdf_example.install
| | \ * rdf_example.module
| o + render_example
| | o * render_example.install
| | \ * render_example.module
| o + simpletest_example
| | o * simpletest_example.install
| | \ * simpletest_example.module
| o + tabledrag_example
| | o * tabledrag_example.install
| | o * tabledrag_example.module
| | o * tabledrag_example_parent_form.inc
| | \ * tabledrag_example_simple_form.inc
| o + tablesort_example
| | o * tablesort_example.install
| | \ * tablesort_example.module
| o + theming_example
| | o * theming-example-text-form.tpl.php
| | \ * theming_example.module
| o + token_example
| | o * token_example.module
| | \ * token_example.tokens.inc
| o + trigger_example
| | \ * trigger_example.module
| o + vertical_tabs_example
| | \ * vertical_tabs_example.module
| o + xmlrpc_example
| | \ * xmlrpc_example.module
| o * examples.index.php
| \ * examples.module
o + includes
| o + database
| | o + mysql
| | | o * database.inc
| | | o * install.inc
| | | o * query.inc
| | | \ * schema.inc
| | o + pgsql
| | | o * database.inc
| | | o * install.inc
| | | o * query.inc
| | | o * schema.inc
| | | \ * select.inc
| | o + sqlite
| | | o * database.inc
| | | o * install.inc
| | | o * query.inc
| | | o * schema.inc
| | | \ * select.inc
| | o * database.inc
| | o * log.inc
| | o * prefetch.inc
| | o * query.inc
| | o * schema.inc
| | \ * select.inc
| o + filetransfer
| | o * filetransfer.inc
| | o * ftp.inc
| | o * local.inc
| | \ * ssh.inc
| o * actions.inc
| o * ajax.inc
| o * archiver.inc
| o * authorize.inc
| o * batch.inc
| o * batch.queue.inc
| o * bootstrap.inc
| o * cache-install.inc
| o * cache.inc
| o * common.inc
| o * date.inc
| o * entity.inc
| o * errors.inc
| o * file.inc
| o * file.mimetypes.inc
| o * form.inc
| o * graph.inc
| o * image.inc
| o * install.core.inc
| o * install.inc
| o * iso.inc
| o * json-encode.inc
| o * language.inc
| o * locale.inc
| o * lock.inc
| o * mail.inc
| o * menu.inc
| o * module.inc
| o * pager.inc
| o * password.inc
| o * path.inc
| o * registry.inc
| o * session.inc
| o * stream_wrappers.inc
| o * tablesort.inc
| o * theme.inc
| o * theme.maintenance.inc
| o * token.inc
| o * unicode.entities.inc
| o * unicode.inc
| o * update.inc
| o * updater.inc
| o * utility.inc
| o * xmlrpc.inc
| \ * xmlrpcs.inc
o + modules
| o + aggregator
| | o * aggregator-feed-source.tpl.php
| | o * aggregator-item.tpl.php
| | o * aggregator-summary-item.tpl.php
| | o * aggregator-summary-items.tpl.php
| | o * aggregator-wrapper.tpl.php
| | o * aggregator.admin.inc
| | o * aggregator.api.php
| | o * aggregator.fetcher.inc
| | o * aggregator.install
| | o * aggregator.module
| | o * aggregator.pages.inc
| | o * aggregator.parser.inc
| | \ * aggregator.processor.inc
| o + block
| | o * block-admin-display-form.tpl.php
| | o * block.admin.inc
| | o * block.api.php
| | o * block.install
| | o * block.module
| | \ * block.tpl.php
| o + blog
| | o * blog.install
| | o * blog.module
| | \ * blog.pages.inc
| o + book
| | o * book-all-books-block.tpl.php
| | o * book-export-html.tpl.php
| | o * book-navigation.tpl.php
| | o * book-node-export-html.tpl.php
| | o * book.admin.inc
| | o * book.install
| | o * book.module
| | \ * book.pages.inc
| o + color
| | o * color.install
| | \ * color.module
| o + comment
| | o * comment-wrapper.tpl.php
| | o * comment.admin.inc
| | o * comment.api.php
| | o * comment.install
| | o * comment.module
| | o * comment.pages.inc
| | o * comment.tokens.inc
| | \ * comment.tpl.php
| o + contact
| | o * contact.admin.inc
| | o * contact.install
| | o * contact.module
| | \ * contact.pages.inc
| o + contextual
| | o * contextual.api.php
| | \ * contextual.module
| o + dashboard
| | o * dashboard.api.php
| | o * dashboard.install
| | \ * dashboard.module
| o + dblog
| | o * dblog.admin.inc
| | o * dblog.install
| | \ * dblog.module
| o + field
| | o + modules
| | | o + field_sql_storage
| | | | o * field_sql_storage.install
| | | | \ * field_sql_storage.module
| | | o + list
| | | | o * list.install
| | | | \ * list.module
| | | o + number
| | | | o * number.install
| | | | \ * number.module
| | | o + options
| | | | o * options.api.php
| | | | \ * options.module
| | | \ + text
| | |   o * text.install
| | |   \ * text.module
| | o + theme
| | | \ * field.tpl.php
| | o * field.api.php
| | o * field.attach.inc
| | o * field.crud.inc
| | o * field.default.inc
| | o * field.form.inc
| | o * field.info.class.inc
| | o * field.info.inc
| | o * field.install
| | o * field.module
| | \ * field.multilingual.inc
| o + field_ui
| | o * field_ui.admin.inc
| | o * field_ui.api.php
| | \ * field_ui.module
| o + file
| | o * file.api.php
| | o * file.field.inc
| | o * file.install
| | \ * file.module
| o + filter
| | o * filter.admin.inc
| | o * filter.api.php
| | o * filter.install
| | o * filter.module
| | \ * filter.pages.inc
| o + forum
| | o * forum-icon.tpl.php
| | o * forum-list.tpl.php
| | o * forum-submitted.tpl.php
| | o * forum-topic-list.tpl.php
| | o * forum.admin.inc
| | o * forum.install
| | o * forum.module
| | o * forum.pages.inc
| | \ * forums.tpl.php
| o + help
| | o * help.admin.inc
| | o * help.api.php
| | \ * help.module
| o + image
| | o * image.admin.inc
| | o * image.api.php
| | o * image.effects.inc
| | o * image.field.inc
| | o * image.install
| | \ * image.module
| o + locale
| | o * locale.admin.inc
| | o * locale.api.php
| | o * locale.install
| | \ * locale.module
| o + menu
| | o * menu.admin.inc
| | o * menu.api.php
| | o * menu.install
| | \ * menu.module
| o + node
| | o * content_types.inc
| | o * node.admin.inc
| | o * node.api.php
| | o * node.install
| | o * node.module
| | o * node.pages.inc
| | o * node.tokens.inc
| | \ * node.tpl.php
| o + openid
| | o * openid.api.php
| | o * openid.inc
| | o * openid.install
| | o * openid.module
| | \ * openid.pages.inc
| o + overlay
| | o * overlay.api.php
| | o * overlay.install
| | o * overlay.module
| | \ * overlay.tpl.php
| o + path
| | o * path.admin.inc
| | o * path.api.php
| | \ * path.module
| o + php
| | o * php.install
| | \ * php.module
| o + poll
| | o * poll-bar--block.tpl.php
| | o * poll-bar.tpl.php
| | o * poll-results--block.tpl.php
| | o * poll-results.tpl.php
| | o * poll-vote.tpl.php
| | o * poll.install
| | o * poll.module
| | o * poll.pages.inc
| | \ * poll.tokens.inc
| o + profile
| | o * profile-block.tpl.php
| | o * profile-listing.tpl.php
| | o * profile-wrapper.tpl.php
| | o * profile.admin.inc
| | o * profile.install
| | o * profile.module
| | \ * profile.pages.inc
| o + rdf
| | o * rdf.api.php
| | o * rdf.install
| | \ * rdf.module
| o + search
| | o * search-block-form.tpl.php
| | o * search-result.tpl.php
| | o * search-results.tpl.php
| | o * search.admin.inc
| | o * search.api.php
| | o * search.extender.inc
| | o * search.install
| | o * search.module
| | \ * search.pages.inc
| o + shortcut
| | o * shortcut.admin.inc
| | o * shortcut.api.php
| | o * shortcut.install
| | \ * shortcut.module
| o + simpletest
| | o + files
| | | \ * php-2.php
| | o * drupal_web_test_case.php
| | o * simpletest.api.php
| | o * simpletest.install
| | o * simpletest.module
| | \ * simpletest.pages.inc
| o + statistics
| | o * statistics.admin.inc
| | o * statistics.install
| | o * statistics.module
| | o * statistics.pages.inc
| | o * statistics.php
| | \ * statistics.tokens.inc
| o + syslog
| | o * syslog.install
| | \ * syslog.module
| o + system
| | o * html.tpl.php
| | o * image.gd.inc
| | o * language.api.php
| | o * maintenance-page.tpl.php
| | o * page.tpl.php
| | o * region.tpl.php
| | o * system.admin.inc
| | o * system.api.php
| | o * system.archiver.inc
| | o * system.install
| | o * system.mail.inc
| | o * system.module
| | o * system.queue.inc
| | o * system.tar.inc
| | o * system.tokens.inc
| | o * system.updater.inc
| | \ * theme.api.php
| o + taxonomy
| | o * taxonomy-term.tpl.php
| | o * taxonomy.admin.inc
| | o * taxonomy.api.php
| | o * taxonomy.install
| | o * taxonomy.module
| | o * taxonomy.pages.inc
| | \ * taxonomy.tokens.inc
| o + toolbar
| | o * toolbar.module
| | \ * toolbar.tpl.php
| o + tracker
| | o * tracker.install
| | o * tracker.module
| | \ * tracker.pages.inc
| o + translation
| | o * translation.module
| | \ * translation.pages.inc
| o + trigger
| | o * trigger.admin.inc
| | o * trigger.api.php
| | o * trigger.install
| | \ * trigger.module
| o + update
| | o * update.api.php
| | o * update.authorize.inc
| | o * update.compare.inc
| | o * update.fetch.inc
| | o * update.install
| | o * update.manager.inc
| | o * update.module
| | o * update.report.inc
| | \ * update.settings.inc
| \ + user
|   o * user-picture.tpl.php
|   o * user-profile-category.tpl.php
|   o * user-profile-item.tpl.php
|   o * user-profile.tpl.php
|   o * user.admin.inc
|   o * user.api.php
|   o * user.install
|   o * user.module
|   o * user.pages.inc
|   \ * user.tokens.inc
o + profiles
| o + minimal
| | o * minimal.install
| | \ * minimal.profile
| o + standard
| | o * standard.install
| | \ * standard.profile
| \ + testing
|   o + modules
|   | o + drupal_system_listing_compatible_test
|   | | \ * drupal_system_listing_compatible_test.module
|   | \ + drupal_system_listing_incompatible_test
|   |   \ * drupal_system_listing_incompatible_test.module
|   o * testing.install
|   \ * testing.profile
o + sites
| o + default
| | \ * default.settings.php
| \ * example.sites.php
o + themes
| o + bartik
| | o + color
| | | \ * color.inc
| | o + templates
| | | o * comment-wrapper.tpl.php
| | | o * comment.tpl.php
| | | o * maintenance-page.tpl.php
| | | o * node.tpl.php
| | | \ * page.tpl.php
| | \ * template.php
| o + engines
| | \ + phptemplate
| |   \ * phptemplate.engine
| o + garland
| | o + color
| | | \ * color.inc
| | o * comment.tpl.php
| | o * maintenance-page.tpl.php
| | o * node.tpl.php
| | o * page.tpl.php
| | o * template.php
| | \ * theme-settings.php
| \ + seven
|   o * maintenance-page.tpl.php
|   o * page.tpl.php
|   \ * template.php
o * authorize.php
o * cron.php
o * index.php
o * install.php
o * update.php
\ * xmlrpc.php
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples Directory Reference

  • examples
examples Directory Reference

Directories

directory | action_example
directory | ajax_example
directory | batch_example
directory | block_example
directory | cache_example
directory | contextual_links_example
directory | cron_example
directory | dbtng_example
directory | email_example
directory | entity_example
directory | field_example
directory | field_permission_example
directory | file_example
directory | filter_example
directory | form_example
directory | image_example
directory | js_example
directory | menu_example
directory | node_access_example
directory | node_example
directory | nodeapi_example
directory | page_example
directory | pager_example
directory | queue_example
directory | rdf_example
directory | render_example
directory | simpletest_example
directory | tabledrag_example
directory | tablesort_example
directory | theming_example
directory | token_example
directory | trigger_example
directory | vertical_tabs_example
directory | xmlrpc_example

Files

file | examples.index.php [code]
file | examples.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/action_example Directory Reference

  • examples
  • action_example
action_example Directory Reference

Files

file action_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/action_example/action_example.module File Reference

  • examples
  • action_example
Functions
action_example.module File Reference

Go to the source code of this file.

Functions

action_example_action_info ()
action_example_menu ()
_action_example_page ()
action_example_basic_action (&$entity, $context=array())
action_example_unblock_user_action (&$entity, $context=array())
action_example_node_sticky_action_form ($context)
action_example_node_sticky_action_validate ($form, $form_state)
action_example_node_sticky_action_submit ($form, $form_state)
action_example_node_sticky_action ($node, $context)

Detailed Description

Action definition example module.

Definition in file action_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example Directory Reference

  • examples
  • ajax_example
ajax_example Directory Reference

Files

file | ajax_example.install [code]
file | ajax_example.module [code]
file | ajax_example_advanced.inc [code]
file | ajax_example_autocomplete.inc [code]
file | ajax_example_graceful_degradation.inc [code]
file | ajax_example_misc.inc [code]
file | ajax_example_node_form_alter.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example/ajax_example.install File Reference

  • examples
  • ajax_example
Functions
ajax_example.install File Reference

Go to the source code of this file.

Functions

ajax_example_schema ()
ajax_example_update_7100 ()

Detailed Description

AJAX Examples install file schema for ajax_example_form_node_form_alter()

Definition in file ajax_example.install.

Function Documentation

ajax_example_schema ( )

Implements hook_schema().

Definition at line 11 of file ajax_example.install.

Referenced by ajax_example_update_7100().

ajax_example_update_7100 ( )

Add the new ajax_example_node_form_alter table.

Definition at line 50 of file ajax_example.install.

References ajax_example_schema(), db_create_table(), db_table_exists(), and st().

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example/ajax_example.module File Reference

  • examples
  • ajax_example
Functions
ajax_example.module File Reference

Go to the source code of this file.

Functions

ajax_example_menu ()
ajax_example_intro ()
ajax_example_simplest ($form, &$form_state)
ajax_example_simplest_callback ($form, $form_state)
ajax_example_autocheckboxes ($form, &$form_state)
ajax_example_autocheckboxes_callback ($form, $form_state)
ajax_example_autotextfields ($form, &$form_state)
ajax_example_autotextfields_callback ($form, $form_state)
ajax_example_submit_driven_ajax ($form, &$form_state)
ajax_example_submit_driven_callback ($form, $form_state)
ajax_example_dependent_dropdown ($form, &$form_state)
ajax_example_dependent_dropdown_callback ($form, $form_state)
_ajax_example_get_first_dropdown_options ()
_ajax_example_get_second_dropdown_options ($key= '')

Detailed Description

AJAX Examples module file with basic examples.

Definition in file ajax_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example/ajax_example_advanced.inc File Reference

  • examples
  • ajax_example
Functions
ajax_example_advanced.inc File Reference

Go to the source code of this file.

Functions

ajax_example_advanced_commands ($form, &$form_state)
ajax_example_advanced_commands_after_callback ($form, $form_state)
ajax_example_advanced_commands_alert_callback ($form, $form_state)
ajax_example_advanced_commands_append_callback ($form, $form_state)
ajax_example_advanced_commands_before_callback ($form, $form_state)
ajax_example_advanced_commands_changed_callback ($form, $form_state)
ajax_example_advanced_commands_css_callback ($form, $form_state)
ajax_example_advanced_commands_data_callback ($form, $form_state)
ajax_example_advanced_commands_html_callback ($form, $form_state)
ajax_example_advanced_commands_prepend_callback ($form, $form_state)
ajax_example_advanced_commands_remove_callback ($form, $form_state)
ajax_example_advanced_commands_restripe_num_rows ($form, $form_state)
ajax_example_advanced_commands_restripe_callback ($form, $form_state)

Detailed Description

AJAX Commands examples.

This demonstrates each of the new AJAX commands. This is consolidated into a dense page because it's advanced material and because it would spread itself all over creation otherwise.

Definition in file ajax_example_advanced.inc.

Function Documentation

ajax_example_advanced_commands | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form to display the AJAX Commands.

Definition at line 16 of file ajax_example_advanced.inc.

References drupal_map_assoc(), and t().

ajax_example_advanced_commands_after_callback | ( | $form,
 |  | $form_state
 | ) |

'after' callback.

See Also
ajax_command_after()

Definition at line 233 of file ajax_example_advanced.inc.

References ajax_command_after(), and ajax_command_replace().

ajax_example_advanced_commands_alert_callback | ( | $form,
 |  | $form_state
 | ) |

'alert' callback.

See Also
ajax_command_alert()

Definition at line 247 of file ajax_example_advanced.inc.

References ajax_command_alert().

ajax_example_advanced_commands_append_callback | ( | $form,
 |  | $form_state
 | ) |

'append' callback.

See Also
ajax_command_append()

Definition at line 258 of file ajax_example_advanced.inc.

References ajax_command_append(), and ajax_command_replace().

ajax_example_advanced_commands_before_callback | ( | $form,
 |  | $form_state
 | ) |

'before' callback.

See Also
ajax_command_before()

Definition at line 272 of file ajax_example_advanced.inc.

References ajax_command_before(), and ajax_command_replace().

ajax_example_advanced_commands_changed_callback | ( | $form,
 |  | $form_state
 | ) |

'changed' callback.

See Also
ajax_command_changed()

Definition at line 286 of file ajax_example_advanced.inc.

References ajax_command_changed(), and ajax_command_replace().

ajax_example_advanced_commands_css_callback | ( | $form,
 |  | $form_state
 | ) |

'css' callback.

See Also
ajax_command_css()

Definition at line 305 of file ajax_example_advanced.inc.

References ajax_command_css(), and ajax_command_replace().

ajax_example_advanced_commands_data_callback | ( | $form,
 |  | $form_state
 | ) |

'data' callback.

See Also
ajax_command_data()

Definition at line 320 of file ajax_example_advanced.inc.

References $value, ajax_command_data(), and ajax_command_replace().

ajax_example_advanced_commands_html_callback | ( | $form,
 |  | $form_state
 | ) |

'html' callback.

See Also
ajax_command_html()

Definition at line 336 of file ajax_example_advanced.inc.

References ajax_command_html(), and ajax_command_replace().

ajax_example_advanced_commands_prepend_callback | ( | $form,
 |  | $form_state
 | ) |

'prepend' callback.

See Also
ajax_command_prepend()

Definition at line 350 of file ajax_example_advanced.inc.

References ajax_command_prepend(), and ajax_command_replace().

ajax_example_advanced_commands_remove_callback | ( | $form,
 |  | $form_state
 | ) |

'remove' callback.

See Also
ajax_command_remove()

Definition at line 362 of file ajax_example_advanced.inc.

References ajax_command_html(), ajax_command_remove(), and ajax_command_replace().

ajax_example_advanced_commands_restripe_callback | ( | $form,
 |  | $form_state
 | ) |

'restripe' callback.

See Also
ajax_command_restripe()

Definition at line 396 of file ajax_example_advanced.inc.

References ajax_command_replace(), and ajax_command_restripe().

ajax_example_advanced_commands_restripe_num_rows | ( | $form,
 |  | $form_state
 | ) |

'restripe' rows callback.

Rebuilds the table with the selected number of rows.

Definition at line 381 of file ajax_example_advanced.inc.

References $output.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example/ajax_example_autocomplete.inc File Reference

  • examples
  • ajax_example
Functions
ajax_example_autocomplete.inc File Reference

Go to the source code of this file.

Functions

ajax_example_simple_autocomplete ($form, &$form_state)
ajax_example_simple_user_autocomplete_callback ($string="")
ajax_example_unique_autocomplete ($form, &$form_state)
ajax_example_unique_autocomplete_validate ($form, &$form_state)
ajax_example_unique_autocomplete_submit ($form, &$form_state)
ajax_example_unique_node_autocomplete_callback ($string="")
ajax_example_node_by_author_autocomplete ($form, &$form_state)
ajax_example_node_by_author_ajax_callback ($form, $form_state)
ajax_example_node_by_author_autocomplete_validate ($form, &$form_state)
ajax_example_node_by_author_autocomplete_submit ($form, &$form_state)
ajax_example_node_by_author_node_autocomplete_callback ($author_uid, $string="")

Detailed Description

ajax_example_autocomplete.inc

Demonstrates usage of the Form API's autocomplete features.

This file provides three examples in increasing complexity:

  • A simple username autocomplete (usernames are unique, so little effort is required)
  • A node title autocomplete (titles are not unique, so we have to find the nid and stash it in the field)
  • A username autocomplete that updates a node title autocomplete with a changed #autocomplete_path so that the #autocomplete_path can have context (the username to use in the search).

Definition in file ajax_example_autocomplete.inc.

Function Documentation

ajax_example_node_by_author_ajax_callback | ( | $form,
 |  | $form_state
 | ) |

AJAX callback for author form element.

Parameters
$form
$form_state
Returns
array

Definition at line 284 of file ajax_example_autocomplete.inc.

ajax_example_node_by_author_autocomplete | ( |  | $form,
 |  | & | $form_state
 | ) |  |

In this example, we'll look up nodes by title, but we want only nodes that have been authored by a particular user. That means that we'll have to make an autocomplete function which takes a username as an argument, and use #ajax to change the #autocomplete_path based on the selected user.

Although the implementation of the validate handler may look complex, it's just ambitious. The idea here is:

  1. Autcomplete to get a valid username.
  2. Use #ajax to update the node element with a #autocomplete_callback that gives the context for the username.
  3. Do an autcomplete on the node field that is limited by the username.
Parameters
$form
$form_state
Returns
array

Definition at line 224 of file ajax_example_autocomplete.inc.

References $author, t(), and user_load_by_name().

ajax_example_node_by_author_autocomplete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for node lookup unique autocomplete example.

Here the nid has already been placed in $form_state['values']['node'] by the validation handler.

Parameters
$form
$form_state

Definition at line 358 of file ajax_example_autocomplete.inc.

References drupal_set_message(), l(), node_load(), t(), theme(), and user_load().

ajax_example_node_by_author_autocomplete_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate handler to convert our string like "Some node title [3325]" into a nid.

In case the user did not actually use the autocomplete or have a valid string there, we'll try to look up a result anyway giving it our best guess.

Since the user chose a unique node, we must now use the same one in our submit handler, which means we need to look in the string for the nid.

This handler looks complex because it's ambitious (and tries to punt and find a node if they've entered a valid username and part of a title), but you could just do a form_error() if nothing were found, forcing people to use the autocomplete to look up the relevant items.

Parameters
$form
$form_state

Definition at line 304 of file ajax_example_autocomplete.inc.

References $author, $title, db_like(), db_select(), form_error(), node_load(), t(), and user_load_by_name().

ajax_example_node_by_author_node_autocomplete_callback | ( | $author_uid,
 |  | $string = ""
 | ) |

Autocomplete callback for nodes by title but limited by author.

Searches for a node by title given the passed-in author username.

The returned $matches array has

  • key: The title, with the identifying nid in brackets, like "Some node title [3325]"
  • value: the title which will is displayed in the autocomplete pulldown.

Note that we must use a key style that can be parsed successfully and unambiguously. For example, if we might have node titles that could have [3325] in them, then we'd have to use a more restrictive token.

Parameters
$author_uid | The author username to limit the search.
$string | The string that will be searched.

Definition at line 382 of file ajax_example_autocomplete.inc.

References check_plain(), db_like(), db_select(), and drupal_json_output().

ajax_example_simple_autocomplete | ( |  | $form,
 |  | & | $form_state
 | ) |  |

A simple autocomplete form which just looks up usernames in the user table.

Parameters
$form
$form_state
Returns
array

Definition at line 22 of file ajax_example_autocomplete.inc.

References t().

ajax_example_simple_user_autocomplete_callback ( $string = "" )

This is just a copy of user_autocomplete().

It works simply by searching usernames (and of course in Drupal usernames are unique, so can be used for identifying a record.)

The returned $matches array has

  • key: string which will be displayed once the autocomplete is selected
  • value: the value which will is displayed in the autocomplete pulldown.

In the simplest cases (see user_autocomplete()) these are the same, and nothing needs to be done. However, more more complicated autocompletes require more work. Here we demonstrate the difference by displaying the UID along with the username in the dropdown.

In the end, though, we'll be doing something with the value that ends up in the textfield, so it needs to uniquely identify the record we want to access. This is demonstrated in ajax_example_unique_autocomplete().

Parameters
$string The string that will be searched.

Definition at line 58 of file ajax_example_autocomplete.inc.

References check_plain(), db_like(), db_select(), and drupal_json_output().

ajax_example_unique_autocomplete | ( |  | $form,
 |  | & | $form_state
 | ) |  |

A unique autocomplete form which looks up nodes by title in the node table, but must keep track of the nid, because titles are certainly not guaranteed to be unique.

Parameters
$form
$form_state
Returns
array

Definition at line 87 of file ajax_example_autocomplete.inc.

References t().

ajax_example_unique_autocomplete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for node lookup unique autocomplete example.

Here the nid has already been placed in $form_state['values']['node'] by the validation handler.

Parameters
$form
$form_state

Definition at line 170 of file ajax_example_autocomplete.inc.

References drupal_set_message(), node_load(), and t().

ajax_example_unique_autocomplete_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate handler to convert our string like "Some node title [3325]" into a nid.

In case the user did not actually use the autocomplete or have a valid string there, we'll try to look up a result anyway giving it our best guess.

Since the user chose a unique node, we must now use the same one in our submit handler, which means we need to look in the string for the nid.

Parameters
$form
$form_state

Definition at line 124 of file ajax_example_autocomplete.inc.

References $title, db_like(), db_select(), form_error(), node_load(), and t().

ajax_example_unique_node_autocomplete_callback ( $string = "" )

Autocomplete callback for nodes by title.

Searches for a node by title, but then identifies it by nid, so the actual returned value can be used later by the form.

The returned $matches array has

  • key: The title, with the identifying nid in brackets, like "Some node title [3325]"
  • value: the title which will is displayed in the autocomplete pulldown.

Note that we must use a key style that can be parsed successfully and unambiguously. For example, if we might have node titles that could have [3325] in them, then we'd have to use a more restrictive token.

Parameters
$string The string that will be searched.

Definition at line 191 of file ajax_example_autocomplete.inc.

References check_plain(), db_like(), db_select(), and drupal_json_output().

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example/ajax_example_graceful_degradation.inc File Reference

  • examples
  • ajax_example
Functions
ajax_example_graceful_degradation.inc File Reference

Go to the source code of this file.

Functions

ajax_example_dependent_dropdown_degrades ($form, &$form_state, $no_js_use=FALSE)
ajax_example_dependent_dropdown_degrades_submit ($form, &$form_state)
ajax_example_dependent_dropdown_degrades_first_callback ($form, $form_state)
ajax_example_dynamic_sections ($form, &$form_state, $no_js_use=FALSE)
ajax_example_dynamic_sections_validate ($form, &$form_state)
ajax_example_dynamic_sections_submit ($form, &$form_state)
ajax_example_dynamic_sections_select_callback ($form, $form_state)
ajax_example_wizard ($form, &$form_state, $no_js_use=FALSE)
ajax_example_wizard_callback ($form, $form_state)
ajax_example_wizard_submit ($form, &$form_state)
ajax_example_add_more ($form, &$form_state, $no_js_use=FALSE)
ajax_example_add_more_callback ($form, $form_state)
ajax_example_add_more_add_one ($form, &$form_state)
ajax_example_add_more_remove_one ($form, &$form_state)
ajax_example_add_more_submit ($form, &$form_state)

Detailed Description

Demonstrations of AJAX with graceful degradation.

Definition in file ajax_example_graceful_degradation.inc.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example/ajax_example_misc.inc File Reference

  • examples
  • ajax_example
Functions
ajax_example_misc.inc File Reference

Go to the source code of this file.

Functions

ajax_example_render_link ()
ajax_example_render_link_ra ()
ajax_link_response ($type= 'ajax')

Detailed Description

AJAX Miscellaneous Topics.

Definition in file ajax_example_misc.inc.

Function Documentation

ajax_example_render_link_ra ( )

Demonstrates a clickable AJAX-enabled link using a renderable array with the #ajax property.

A link that is constructed as a renderable array can have the #ajax property, which ensures that the link submission is done without a page refresh. The href of the link is used as the ajax callback, but it degrades gracefully without JavaScript because if the 'nojs' portion of the href is not stripped out by js, the callback will return content as required for a full page reload.

The necessary JavaScript file, ajax.js, will be included on the page automatically.

Returns

Definition at line 57 of file ajax_example_misc.inc.

References t().

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example/ajax_example_node_form_alter.inc File Reference

  • examples
  • ajax_example
Functions
ajax_example_node_form_alter.inc File Reference

Go to the source code of this file.

Functions

ajax_example_form_node_form_alter (&$form, &$form_state, $form_id)
ajax_example_form_node_callback ($form, $form_state)
ajax_example_node_submit ($node, $form, &$form_state)
ajax_example_node_prepare ($node)
ajax_example_node_load ($nodes, $types)
ajax_example_node_insert ($node)
ajax_example_node_update ($node)
ajax_example_node_delete ($node)

Detailed Description

This example shows how to use AJAX when altering a node form.

It maintains a table parallel to the node table containing attributes 'example_1' and 'example_2' which are displayed on the node form. 'example_2' is displayed dynamically when example_1 is checked.

Definition in file ajax_example_node_form_alter.inc.

Function Documentation

ajax_example_form_node_callback | ( | $form,
 |  | $form_state
 | ) |

Returns changed part of the form.

Returns
renderable array
See Also
ajax_example_form_node_form_alter()

Definition at line 58 of file ajax_example_node_form_alter.inc.

ajax_example_form_node_form_alter | ( | & | $form,
 |  | & | $form_state,
 |  |  | $form_id
 | ) |  |

Implements hook_form_FORM_ID_alter() for the node form.

Adds two fields to the node form, second only appears after first is enabled.

Definition at line 16 of file ajax_example_node_form_alter.inc.

References t().

ajax_example_node_delete ( $node )

Implements hook_node_delete().

See Also
ajax_example_form_node_form_alter()

Definition at line 146 of file ajax_example_node_form_alter.inc.

References db_delete().

ajax_example_node_insert ( $node )

Implements hook_node_insert().

See Also
ajax_example_form_node_form_alter()

Definition at line 110 of file ajax_example_node_form_alter.inc.

References db_insert().

Referenced by ajax_example_node_update().

ajax_example_node_load | ( | $nodes,
 |  | $types
 | ) |

Implements hook_node_load().

See Also
ajax_example_form_node_form_alter()

Definition at line 92 of file ajax_example_node_form_alter.inc.

References db_query().

ajax_example_node_prepare ( $node )

Implements hook_node_prepare().

See Also
ajax_example_form_node_form_alter()

Definition at line 79 of file ajax_example_node_form_alter.inc.

ajax_example_node_submit | ( |  | $node,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_node_submit().

See Also
ajax_example_form_node_form_alter()

Definition at line 66 of file ajax_example_node_form_alter.inc.

ajax_example_node_update ( $node )

Implements hook_node_update().

See Also
ajax_example_form_node_form_alter()

Definition at line 126 of file ajax_example_node_form_alter.inc.

References ajax_example_node_insert(), db_select(), and db_update().

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/batch_example Directory Reference

  • examples
  • batch_example
batch_example Directory Reference

Files

file | batch_example.install [code]
file | batch_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/batch_example/batch_example.install File Reference

  • examples
  • batch_example
Functions
batch_example.install File Reference

Go to the source code of this file.

Functions

batch_example_update_7100 (&$sandbox)

Detailed Description

Install, update, and uninstall functions for the batch_example module.

Definition in file batch_example.install.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/batch_example/batch_example.module File Reference

  • examples
  • batch_example
Functions
batch_example.module File Reference

Go to the source code of this file.

Functions

batch_example_menu ()
batch_example_simple_form ()
batch_example_simple_form_submit ($form, &$form_state)
batch_example_batch_1 ()
batch_example_op_1 ($nid, $operation_details, &$context)
batch_example_batch_2 ()
batch_example_op_2 ($operation_details, &$context)
batch_example_finished ($success, $results, $operations)
batch_example_lowest_nid ()
_batch_example_update_http_requests ()
_batch_example_get_http_requests ()

Detailed Description

Outlines how a module can use the Batch API.

Definition in file batch_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/block_example Directory Reference

  • examples
  • block_example
block_example Directory Reference

Files

file | block_example.install [code]
file | block_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/block_example/block_example.install File Reference

  • examples
  • block_example
Functions
block_example.install File Reference

Go to the source code of this file.

Functions

block_example_uninstall ()

Detailed Description

Install, update and uninstall functions for the block_example module.

Definition in file block_example.install.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/block_example/block_example.module File Reference

  • examples
  • block_example
Functions
block_example.module File Reference

Go to the source code of this file.

Functions

block_example_menu ()
block_example_page ()
block_example_block_info ()
block_example_block_configure ($delta= '')
block_example_block_save ($delta= '', $edit=array())
block_example_block_view ($delta= '')
block_example_contents ($which_block)
block_example_block_list_alter (&$blocks)
block_example_block_view_alter (&$data, $block)

Detailed Description

Module file for block_example.

Definition in file block_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/cache_example Directory Reference

  • examples
  • cache_example
cache_example Directory Reference

Files

file cache_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/cache_example/cache_example.module File Reference

  • examples
  • cache_example
Functions
cache_example.module File Reference

Go to the source code of this file.

Functions

cache_example_menu ()
cache_example_page_form ($form, &$form_state)
cache_example_form_expire_files ($form, &$form_state)
cache_example_form_create_expiring_item ($form, &$form_state)
cache_example_form_cache_clearing ($form, &$form_state)

Detailed Description

Outlines how a module can use the Cache API.

Definition in file cache_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/contextual_links_example Directory Reference

  • examples
  • contextual_links_example
contextual_links_example Directory Reference

Files

file | contextual-links-example-object.tpl.php [code]
file | contextual_links_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/contextual_links_example/contextual-links-example-object.tpl.php File Reference

  • examples
  • contextual_links_example
Variables
contextual-links-example-object.tpl.php File Reference

Go to the source code of this file.

Variables

print $classes
print $title
print $content

Detailed Description

Default theme implementation to display a sample object with contextual links.

Available variables:

  • $title: The sanitized title of the object.
  • $content: The sanitized content of the object. These are defined in template_preprocess_contextual_links_example_object() and represent whichever variables you might actually use to display the main content of your module's object.

Standard variables (required for contextual links):

  • $classes: String of classes that can be used to style contextually through CSS.
  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template. The above variables are a subset of those which Drupal provides to all templates, and they must be printed in your template file in order for contextual links to be properly attached. For example, the core Contextual Links module adds the renderable contextual links themselves inside $title_suffix, so they will appear immediately after the object's title in the HTML. (This placement is for accessibility reasons, among others.)

Definition in file contextual-links-example-object.tpl.php.

Variable Documentation

print $classes

Definition at line 31 of file contextual-links-example-object.tpl.php.

Referenced by dblog_overview(), drupal_html_class(), simpletest_result_form_submit(), simpletest_test_get_all(), and theme_field().

print $content

Definition at line 35 of file contextual-links-example-object.tpl.php.

Referenced by _filter_url_escape_comments(), _menu_example_basic_instructions(), _menu_example_menu_page(), _openid_meta_httpequiv(), drupal_add_region_content(), drupal_get_region_content(), drupal_load_stylesheet(), drupal_set_page_content(), entity_example_basic_list_entities(), entity_example_info_page(), file_example_session_contents(), node_access_example_private_node_listing(), node_add_page(), overlay_store_rendered_content(), profile_browse(), seven_admin_block_content(), seven_node_add_list(), statistics_block_view(), system_admin_menu_block(), system_admin_menu_block_page(), system_settings_overview(), theme_admin_block_content(), theme_node_add_list(), and theming_example_page().

print $title

Definition at line 33 of file contextual-links-example-object.tpl.php.

Referenced by _forum_parent_select(), _menu_get_options(), _menu_overview_tree_form(), _menu_parents_recurse(), _statistics_format_item(), _statistics_link(), aggregator_form_category_submit(), aggregator_form_feed_submit(), ajax_example_node_by_author_autocomplete_validate(), ajax_example_unique_autocomplete_validate(), DrupalWebTestCase\assertNoTitle(), DrupalWebTestCase\assertTitle(), block_admin_configure(), blog_page_user(), book_block_view(), book_remove_form(), comment_tokens(), drupal_add_feed(), drupal_get_title(), drupal_set_title(), DrupalWebTestCase\drupalGetNodeByTitle(), field_example_field_widget_form(), field_multiple_value_form(), form_process_date(), form_process_tableselect(), format_rss_channel(), format_rss_item(), forum_block_view(), hook_tokens_alter(), image_effect_form(), image_style_form(), js_example_accordion(), menu_block_info(), menu_install(), node_multiple_delete_confirm(), node_title_list(), profile_browse(), profile_field_form_validate(), profile_user_view(), shortcut_link_add_inline(), shortcut_set_title_exists(), system_block_info(), system_theme_settings(), tablesort_header(), template_preprocess_forums(), theme_form_element_label(), theme_item_list(), theme_locale_languages_configure_form(), theme_locale_languages_overview_form(), theme_simpletest_test_table(), theme_system_themes_page(), theme_tableselect(), theme_theming_example_list(), theme_theming_example_select_form(), theme_user_list(), theming_example_list_page(), and translation_node_overview().

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/contextual_links_example/contextual_links_example.module File Reference

  • examples
  • contextual_links_example
Functions
contextual_links_example.module File Reference

Go to the source code of this file.

Functions

contextual_links_example_menu ()
contextual_links_example_object_load ($id)
contextual_links_example_block_info ()
contextual_links_example_block_view ($delta= '')
contextual_links_overview_page ()
contextual_links_example_theme ()
template_preprocess_contextual_links_example_object (&$variables)
contextual_links_example_object_page ($object)
contextual_links_example_object_edit_form ($form, &$form_state, $object)
contextual_links_example_object_edit_form_submit ($form, &$form_state)
contextual_links_example_node_action_form ($form, &$form_state, $node)
contextual_links_example_node_action_form_submit ($form, &$form_state)

Detailed Description

Shows how to use Drupal's contextual links functionality.

See Also
http://drupal.org/node/1089922

Definition in file contextual_links_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/cron_example Directory Reference

  • examples
  • cron_example
cron_example Directory Reference

Files

file cron_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/cron_example/cron_example.module File Reference

  • examples
  • cron_example
Functions
cron_example.module File Reference

Go to the source code of this file.

Functions

cron_example_menu ()
cron_example_form ($form, &$form_state)
cron_example_form_cron_run_submit ($form, &$form_state)
cron_example_add_jobs_to_queue ($form, &$form_state)
cron_example_cron ()
cron_example_cron_queue_info ()
cron_example_queue_1_worker ($item)
cron_example_queue_2_worker ($item)
cron_example_queue_report_work ($worker, $item)

Detailed Description

Demonstrates use of the Cron API in Drupal - hook_cron()

Definition in file cron_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/dbtng_example Directory Reference

  • examples
  • dbtng_example
dbtng_example Directory Reference

Files

file | dbtng_example.install [code]
file | dbtng_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/dbtng_example/dbtng_example.install File Reference

  • examples
  • dbtng_example
Functions
dbtng_example.install File Reference

Go to the source code of this file.

Functions

dbtng_example_install ()
dbtng_example_uninstall ()
dbtng_example_schema ()

Detailed Description

Install, update and uninstall functions for the dbtng_example module.

Definition in file dbtng_example.install.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/dbtng_example/dbtng_example.module File Reference

  • examples
  • dbtng_example
Functions
dbtng_example.module File Reference

Go to the source code of this file.

Functions

dbtng_example_entry_insert ($entry)
dbtng_example_entry_update ($entry)
dbtng_example_entry_delete ($entry)
dbtng_example_entry_load ($entry=array())
dbtng_example_advanced_list ()
dbtng_example_help ($path)
dbtng_example_menu ()
dbtng_example_list ()
dbtng_example_form_add ($form, &$form_state)
dbtng_example_form_add_submit ($form, &$form_state)
dbtng_example_form_update ($form, &$form_state)
dbtng_example_form_update_callback ($form, $form_state)
dbtng_example_form_update_submit ($form, &$form_state)

Detailed Description

This is an example outlining how a module can make use of the new DBTNG database API in Drupal 7.

General documentation is available at Database abstraction layer documentation and at http://drupal.org/node/310069.

Definition in file dbtng_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/email_example Directory Reference

  • examples
  • email_example
email_example Directory Reference

Files

file email_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/email_example/email_example.module File Reference

  • examples
  • email_example
Functions
email_example.module File Reference

Go to the source code of this file.

Functions

email_example_mail ($key, &$message, $params)
email_example_mail_send ($form_values)
email_example_mail_alter (&$message)
email_example_menu ()
email_example_form ()
email_example_form_validate ($form, &$form_state)
email_example_form_submit ($form, &$form_state)

Detailed Description

Example of how to use Drupal's mail API.

Definition in file email_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/entity_example Directory Reference

  • examples
  • entity_example
entity_example Directory Reference

Files

file | entity_example.install [code]
file | entity_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/entity_example/entity_example.install File Reference

  • examples
  • entity_example
Functions
entity_example.install File Reference

Go to the source code of this file.

Functions

entity_example_schema ()
entity_example_uninstall ()

Detailed Description

Install for a basic entity - need to create the base table for our entity. This table can have as many columns as you need to keep track of entity-specific data that will not be added via attached fields. The minimum information for the entity to work is an id and an entity name.

Definition in file entity_example.install.

Function Documentation

entity_example_uninstall ( )

Definition at line 69 of file entity_example.install.

References field_attach_delete_bundle().

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/entity_example/entity_example.module File Reference

  • examples
  • entity_example
Classes | Functions
entity_example.module File Reference

Go to the source code of this file.

Classes

interface | EntityExampleBasicControllerInterface
class | EntityExampleBasicController

Functions

entity_example_entity_info ()
entity_example_basic_load ($basic_id=NULL, $reset=FALSE)
entity_example_basic_load_multiple ($basic_ids=FALSE, $conditions=array(), $reset=FALSE)
entity_example_basic_uri ($basic)
entity_example_menu ()
entity_example_info_page ()
entity_example_permission ()
entity_example_basic_list_entities ()
entity_example_basic_title ($entity)
entity_example_basic_view ($entity, $view_mode= 'tweaky')
entity_example_field_extra_fields ()
entity_example_basic_add ()
entity_example_basic_form ($form, &$form_state, $entity)
entity_example_basic_form_validate ($form, &$form_state)
entity_example_basic_form_submit ($form, &$form_state)
entity_example_basic_edit_delete ($form, &$form_state)
entity_example_basic_save (&$entity)
entity_example_basic_delete ($entity)

Detailed Description

Implements the basic functionality required to create and display an entity.

This example does not use the Entity API module , which is used by many entity implementations and is recommended by many.

An example of use of creating and managing entities using the Entity API module is provided in the Model Entity module .

Definition in file entity_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/field_example Directory Reference

  • examples
  • field_example
field_example Directory Reference

Files

file | field_example.install [code]
file | field_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/field_example/field_example.install File Reference

  • examples
  • field_example
Functions
field_example.install File Reference

Go to the source code of this file.

Functions

field_example_field_schema ($field)

Detailed Description

Install, update, and uninstall functions for the field_example module.

Definition in file field_example.install.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/field_example/field_example.module File Reference

  • examples
  • field_example
Functions
field_example.module File Reference

Go to the source code of this file.

Functions

field_example_field_info ()
field_example_field_validate ($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
field_example_field_is_empty ($item, $field)
field_example_field_formatter_info ()
field_example_field_formatter_view ($entity_type, $entity, $field, $instance, $langcode, $items, $display)
field_example_field_widget_info ()
field_example_field_widget_form (&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
field_example_3text_validate ($element, &$form_state)
field_example_field_widget_error ($element, $error, $form, &$form_state)
field_example_menu ()
_field_example_page ()

Detailed Description

An example field using the Field Types API.

Definition in file field_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/field_permission_example Directory Reference

  • examples
  • field_permission_example
field_permission_example Directory Reference

Files

file | field_permission_example.install [code]
file | field_permission_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/field_permission_example/field_permission_example.install File Reference

  • examples
  • field_permission_example
Functions
field_permission_example.install File Reference

Go to the source code of this file.

Functions

field_permission_example_field_schema ($field)

Detailed Description

Install function for the field_permission_example module.

Definition in file field_permission_example.install.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/field_permission_example/field_permission_example.module File Reference

  • examples
  • field_permission_example
Functions
field_permission_example.module File Reference

Go to the source code of this file.

Functions

field_permission_example_permission ()
field_permission_example_field_access ($op, $field, $entity_type, $entity, $account)
field_permission_example_field_info ()
field_permission_example_field_is_empty ($item, $field)
field_permission_example_field_formatter_info ()
field_permission_example_field_formatter_view ($entity_type, $entity, $field, $instance, $langcode, $items, $display)
field_permission_example_field_widget_info ()
field_permission_example_field_widget_form (&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
field_permission_example_menu ()
_field_permission_example_page ()

Detailed Description

An example field using the Field Types API.

Definition in file field_permission_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/file_example Directory Reference

  • examples
  • file_example
file_example Directory Reference

Files

file | file_example.module [code]
file | file_example_session_streams.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/file_example/file_example.module File Reference

  • examples
  • file_example
Functions
file_example.module File Reference

Go to the source code of this file.

Functions

file_example_menu ()
file_example_permission ()
file_example_intro ()
file_example_readwrite ($form, &$form_state)
file_example_managed_write_submit ($form, &$form_state)
file_example_unmanaged_write_submit ($form, &$form_state)
file_example_unmanaged_php_submit ($form, &$form_state)
file_example_read_submit ($form, &$form_state)
file_example_delete_submit ($form, &$form_state)
file_example_file_check_exists_submit ($form, &$form_state)
file_example_create_directory_submit ($form, &$form_state)
file_example_delete_directory_submit ($form, &$form_state)
file_example_check_directory_submit ($form, &$form_state)
file_example_show_session_contents_submit ($form, &$form_state)
file_example_get_managed_file ($uri)
file_example_stream_wrappers ()
file_example_session_contents ()

Detailed Description

Examples demonstrating the Drupal File API (and Stream Wrappers).

Definition in file file_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/file_example/file_example_session_streams.inc File Reference

  • examples
  • file_example
Classes
file_example_session_streams.inc File Reference

Go to the source code of this file.

Classes

class FileExampleSessionStreamWrapper

Detailed Description

Provides a demonstration session:// streamwrapper.

This example is nearly fully functional, but has no known practical use. It's an example and demonstration only.

Definition in file file_example_session_streams.inc.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/filter_example Directory Reference

  • examples
  • filter_example
filter_example Directory Reference

Files

file filter_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/filter_example/filter_example.module File Reference

  • examples
  • filter_example
Functions
filter_example.module File Reference

Go to the source code of this file.

Functions

filter_example_menu ()
filter_example_help ($path, $arg)
_filter_example_information ()
filter_example_filter_info ()
_filter_example_filter_foo_settings ($form, $form_state, $filter, $format, $defaults)
_filter_example_filter_foo_process ($text, $filter, $format)
_filter_example_filter_foo_tips ($filter, $format, $long=FALSE)
_filter_example_filter_time_prepare ($text, $filter)
_filter_example_filter_time_process ($text, $filter)
_filter_example_filter_time_tips ($filter, $format, $long=FALSE)

Detailed Description

Module file for filter_example.

Definition in file filter_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/form_example Directory Reference

  • examples
  • form_example
form_example Directory Reference

Files

file | form_example.module [code]
file | form_example_elements.inc [code]
file | form_example_states.inc [code]
file | form_example_tutorial.inc [code]
file | form_example_wizard.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/form_example/form_example.module File Reference

  • examples
  • form_example
Functions
form_example.module File Reference

Go to the source code of this file.

Functions

form_example_menu ()
form_example_intro ()
form_example_help ($path, $arg)
form_example_element_info ()
form_example_theme ($existing, $type, $theme, $path)

Detailed Description

Examples demonstrating the Drupal Form API.

Definition in file form_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/form_example/form_example_elements.inc File Reference

  • examples
  • form_example
Functions
form_example_elements.inc File Reference

Go to the source code of this file.

Functions

_form_example_element_info ()
form_example_phonenumber_combined_value (&$element, $input=FALSE, $form_state=NULL)
form_type_form_example_checkbox_value ($element, $input=FALSE)
form_example_phonenumber_discrete_process ($element, &$form_state, $complete_form)
form_example_phonenumber_discrete_validate ($element, &$form_state)
form_example_phonenumber_combined_process ($element, &$form_state, $complete_form)
form_example_phonenumber_combined_validate ($element, &$form_state)
_form_example_element_theme ()
theme_form_example_checkbox ($variables)
theme_form_example_inline_form_element ($variables)
form_example_element_demo_form ($form, &$form_state)
form_example_element_demo_form_submit ($form, &$form_state)

Detailed Description

This is an example demonstrating how a module can define custom form and render elements.

Form elements are already familiar to anyone who uses Form API. They share history with render elements, which are explained in the Render Example . Examples of core form elements are 'textfield', 'checkbox' and 'fieldset'. Drupal utilizes hook_elements() to define these FAPI types, and this occurs in the core function system_elements().

Each form element has a #type value that determines how it is treated by the Form API and how it is ultimately rendered into HTML. hook_element_info() allows modules to define new element types, and tells the Form API what default values they should automatically be populated with.

By implementing hook_element_info() in your own module, you can create custom form (or render) elements with their own properties, validation and theming.

In this example, we define a series of elements that range from trivial (a renamed textfield) to more advanced (a telephone number field with each portion separately validated).

Since each element can use arbitrary properties (like #process or #dropthis) it can be quite complicated to figure out what all the properties actually mean. This example won't undertake the exhaustive task of explaining them all, as that would probably be impossible.

Definition in file form_example_elements.inc.

Function Documentation

_form_example_element_info ( )

Utility function providing data for form_example_element_info().

This defines several new form element types.

  • form_example_textfield: This is actually just a textfield, but provides the new type. If more were to be done with it a theme function could be provided.
  • form_example_checkbox: Nothing more than a regular checkbox, but uses an alternate theme function provided by this module.
  • form_example_phonenumber_discrete: Provides a North-American style three-part phonenumber where the value of the phonenumber is managed as an array of three parts.
  • form_example_phonenumber_combined: Provides a North-American style three-part phonenumber where the actual value is managed as a 10-digit string and only broken up into three parts for the user interface.

form_builder() has significant discussion of #process and #value_callback. See also hook_element_info().

system_element_info() contains the Drupal default element types, which can also be used as examples.

Definition at line 77 of file form_example_elements.inc.

Referenced by form_example_element_info().

_form_example_element_theme ( )

Called by form_example_theme() to provide hook_theme().

This is kept in this file so it can be with the theme functions it presents. Otherwise it would get lonely.

Definition at line 361 of file form_example_elements.inc.

Referenced by form_example_theme().

form_example_element_demo_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Simple form to demonstrate how to use the various new FAPI elements we've defined.

Definition at line 448 of file form_example_elements.inc.

References t(), and variable_get().

form_example_element_demo_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for form_example_element_demo_form().

Definition at line 488 of file form_example_elements.inc.

References $value, drupal_set_message(), t(), and variable_set().

form_example_phonenumber_combined_process | ( |  | $element,
 |  | & | $form_state,
 |  |  | $complete_form
 | ) |  |

Process callback for the combined version of the phonenumber element.

Definition at line 281 of file form_example_elements.inc.

form_example_phonenumber_combined_validate | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Phone number validation function for the combined phonenumber.

Uses regular expressions to check that:

  • the area code is a three digit number
  • the prefix is numeric 3-digit number
  • the extension is a numeric 4-digit number

Any problems are shown on the form element using form_error().

The combined value is then updated in the element.

Definition at line 336 of file form_example_elements.inc.

References $value, form_error(), form_set_value(), and t().

form_example_phonenumber_combined_value | ( | & | $element,
 |  |  | $input = FALSE,
 |  |  | $form_state = NULL
 | ) |  |

Builds the current combined value of the phone number only when the form builder is not processing the input.

Parameters
$element
$input
$form_state
Returns
array

Definition at line 178 of file form_example_elements.inc.

form_example_phonenumber_discrete_process | ( |  | $element,
 |  | & | $form_state,
 |  |  | $complete_form
 | ) |  |

Process callback for the discrete version of phonenumber.

Definition at line 212 of file form_example_elements.inc.

form_example_phonenumber_discrete_validate | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Validation handler for the discrete version of the phone number.

Uses regular expressions to check that:

  • the area code is a three digit number.
  • the prefix is numeric 3-digit number.
  • the extension is a numeric 4-digit number.

Any problems are shown on the form element using form_error().

Definition at line 259 of file form_example_elements.inc.

References form_error(), and t().

form_type_form_example_checkbox_value | ( | $element,
 |  | $input = FALSE
 | ) |

Value callback for form_example_checkbox element type. Copied from form_type_checkbox_value().

Parameters
$element | The form element whose value is being populated.
$input | The incoming input to populate the form element. If this is FALSE, meaning there is no input, the element's default value should be returned.

Definition at line 200 of file form_example_elements.inc.

theme_form_example_checkbox ( $variables )

Themes a custom checkbox.

This doesn't actually do anything, but is here to show that theming can be done here.

Definition at line 380 of file form_example_elements.inc.

References theme().

theme_form_example_inline_form_element ( $variables )

Formats child form elements as inline elements.

Definition at line 388 of file form_example_elements.inc.

References $attributes, $output, drupal_attributes(), and theme().

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/form_example/form_example_states.inc File Reference

  • examples
  • form_example
Functions
form_example_states.inc File Reference

Go to the source code of this file.

Functions

form_example_states_form ($form, &$form_state)
form_example_states_form_submit ($form, &$form_state)

Detailed Description

An example of how to use the new #states Form API element, allowing dynamic form behavior with very simple setup.

Definition in file form_example_states.inc.

Function Documentation

form_example_states_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for form_example_states_form().

Definition at line 285 of file form_example_states.inc.

References drupal_set_message(), and t().

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/form_example/form_example_tutorial.inc File Reference

  • examples
  • form_example
Functions
form_example_tutorial.inc File Reference

Go to the source code of this file.

Functions

form_example_tutorial ()
form_example_tutorial_1 ($form, &$form_state)
form_example_tutorial_2 ($form, &$form_state)
form_example_tutorial_3 ($form, &$form_state)
form_example_tutorial_4 ($form, &$form_state)
form_example_tutorial_5 ($form, &$form_state)
form_example_tutorial_6 ($form, &$form_state)
form_example_tutorial_6_validate ($form, &$form_state)
form_example_tutorial_7 ($form, &$form_state)
form_example_tutorial_7_validate ($form, &$form_state)
form_example_tutorial_7_submit ($form, &$form_state)
form_example_tutorial_8 ($form, &$form_state)
form_example_tutorial_8_page_two ($form, &$form_state)
form_example_tutorial_8_next_validate ($form, &$form_state)
form_example_tutorial_8_next_submit ($form, &$form_state)
form_example_tutorial_8_page_two_back ($form, &$form_state)
form_example_tutorial_8_page_two_submit ($form, &$form_state)
form_example_tutorial_9 ($form, &$form_state)
form_example_tutorial_9_add_name ($form, &$form_state)
form_example_tutorial_9_remove_name ($form, &$form_state)
form_example_tutorial_9_validate ($form, &$form_state)
form_example_tutorial_9_submit ($form, &$form_state)
form_example_tutorial_10 ($form_state)
form_example_tutorial_10_validate ($form, &$form_state)
form_example_tutorial_10_submit ($form, &$form_state)

Detailed Description

This is the Form API Tutorial from the handbook.

It goes through 10 form examples of increasing complexity to demonstrate Drupal 7 Form API.

Links are provided inline for the related handbook pages.

See Also
http://drupal.org/node/262422

Definition in file form_example_tutorial.inc.

Function Documentation

form_example_tutorial_10_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for form_example_tutorial_10().

Definition at line 757 of file form_example_tutorial.inc.

References drupal_set_message(), file_save(), FILE_STATUS_PERMANENT, and t().

form_example_tutorial_10_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate handler for form_example_tutorial_10().

Definition at line 733 of file form_example_tutorial.inc.

References file_move(), file_save_upload(), form_set_error(), and t().

form_example_tutorial_6 | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Example 6: A basic form with a validate handler.

From http://drupal.org/node/717736

See Also
form_example_tutorial_6_validate()

Definition at line 232 of file form_example_tutorial.inc.

References t().

form_example_tutorial_6_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Now we add a handler/function to validate the data entered into the "year of birth" field to make sure it's between the values of 1900 and 2000. If not, it displays an error. The value report is $form_state'values'.

Notice the name of the function. It is simply the name of the form followed by '_validate'. This is always the name of the default validation function. An alternate list of validation functions could have been provided in $form['#validate'].

See Also
form_example_tutorial_6()

Definition at line 290 of file form_example_tutorial.inc.

References form_set_error(), and t().

form_example_tutorial_7_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for form_example_tutorial_7().

Adds a submit handler/function to our form to send a successful completion message to the screen.

Definition at line 364 of file form_example_tutorial.inc.

References drupal_set_message(), and t().

form_example_tutorial_7_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validation function for form_example_tutorial_7().

Definition at line 351 of file form_example_tutorial.inc.

References form_set_error(), and t().

form_example_tutorial_8_next_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for form_example_tutorial_8() next button.

Capture the values from page one and store them away so they can be used at final submit time.

Definition at line 484 of file form_example_tutorial.inc.

form_example_tutorial_8_next_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate handler for the next button on first page.

Definition at line 471 of file form_example_tutorial.inc.

References form_set_error(), and t().

form_example_tutorial_8_page_two | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Returns the form for the second page of form_example_tutorial_8().

Definition at line 439 of file form_example_tutorial.inc.

References t().

Referenced by form_example_tutorial_8().

form_example_tutorial_8_page_two_back | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Back button handler submit handler.

Since #limit_validation_errors = array() is set, values from page 2 will be discarded. We load the page 1 values instead.

Definition at line 506 of file form_example_tutorial.inc.

form_example_tutorial_8_page_two_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

The page 2 submit handler.

This is the final submit handler. Gather all the data together and output it in a drupal_set_message().

Definition at line 518 of file form_example_tutorial.inc.

References drupal_set_message(), and t().

form_example_tutorial_9_add_name | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for "Add another name" button on form_example_tutorial_9().

$form_state['num_names'] tells the form builder function how many name fieldsets to build, so here we increment it.

All elements of $form_state are persisted, so there's no need to use a particular key, like the old $form_state['storage']. We can just use $form_state['num_names'].

Definition at line 651 of file form_example_tutorial.inc.

form_example_tutorial_9_remove_name | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 661 of file form_example_tutorial.inc.

form_example_tutorial_9_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for form_example_tutorial_9().

Definition at line 690 of file form_example_tutorial.inc.

References $output, drupal_set_message(), and t().

form_example_tutorial_9_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate function for form_example_tutorial_9().

Adds logic to validate the form to check the validity of the new fields, if they exist.

Definition at line 676 of file form_example_tutorial.inc.

References form_set_error(), and t().

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/form_example/form_example_wizard.inc File Reference

  • examples
  • form_example
Functions
form_example_wizard.inc File Reference

Go to the source code of this file.

Functions

_form_example_steps ()
form_example_wizard ($form, &$form_state)
form_example_wizard_previous_submit ($form, &$form_state)
form_example_wizard_next_submit ($form, &$form_state)
form_example_wizard_personal_info ($form, &$form_state)
form_example_wizard_location_info ($form, &$form_state)
form_example_wizard_location_info_validate ($form, &$form_state)
form_example_wizard_other_info ($form, &$form_state)
form_example_wizard_submit ($form, &$form_state)

Detailed Description

Extensible wizard form example.

Definition in file form_example_wizard.inc.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/image_example Directory Reference

  • examples
  • image_example
image_example Directory Reference

Files

file | image_example.install [code]
file | image_example.module [code]
file | image_example.pages.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/image_example/image_example.install File Reference

  • examples
  • image_example
Functions
image_example.install File Reference

Go to the source code of this file.

Functions

image_example_install ()
image_example_uninstall ()
image_example_enable ()
image_example_disable ()

Detailed Description

Install, update, and uninstall functions for the image_example module.

Definition in file image_example.install.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/image_example/image_example.module File Reference

  • examples
  • image_example
Functions
image_example.module File Reference

Go to the source code of this file.

Functions

image_example_menu ()
image_example_help ($path)
image_example_image_default_styles ()
image_example_image_style_save ($style)
image_example_image_style_delete ($style)
image_example_style_flush ($style)
image_example_image_styles_alter (&$styles)
image_example_image_effect_info ()
image_example_colorize_form ($data)
image_example_colorize_effect (&$image, $data)
image_example_theme ()
theme_image_example_colorize_summary ($variables)

Detailed Description

Module file for image_example

Definition in file image_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/image_example/image_example.pages.inc File Reference

  • examples
  • image_example
Functions
image_example.pages.inc File Reference

Go to the source code of this file.

Functions

image_example_style_form ($form, &$form_state)
image_example_style_form_validate ($form, &$form_state)
image_example_style_form_submit ($form, &$form_state)
theme_image_example_image ($variables)

Detailed Description

Page/form showing image styles in use.

Definition in file image_example.pages.inc.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/js_example Directory Reference

  • examples
  • js_example
js_example Directory Reference

Files

file | accordion.tpl.php [code]
file | js_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/js_example/accordion.tpl.php File Reference

  • examples
  • js_example
Variables
accordion.tpl.php File Reference

Go to the source code of this file.

Variables

print $title

Detailed Description

Template file for js_example module.

Definition in file accordion.tpl.php.

Variable Documentation

print $title

Definition at line 9 of file accordion.tpl.php.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/js_example/js_example.module File Reference

  • examples
  • js_example
Functions
js_example.module File Reference

Go to the source code of this file.

Functions

js_example_theme ()
js_example_menu ()
js_example_js_weights ()
js_example_accordion ()

Detailed Description

Examples showing how to use some of the new JavaScript features in Drupal 7.

Definition in file js_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/menu_example Directory Reference

  • examples
  • menu_example
menu_example Directory Reference

Files

file menu_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/menu_example/menu_example.module File Reference

  • examples
  • menu_example
Functions
menu_example.module File Reference

Go to the source code of this file.

Functions

menu_example_menu ()
_menu_example_basic_instructions ($content=NULL)
_menu_example_menu_page ($content=NULL, $arg1=NULL, $arg2=NULL)
menu_example_permission ()
menu_example_custom_access ($role_name)
_menu_example_mappings ($id)
menu_example_id_load ($id)
menu_example_menu_alter (&$items)
_menu_example_simple_title_callback ($base_string)
menu_example_user_page_title ($account)
menu_example_menu_link_alter (&$item, $menu)
menu_example_arg_optional_load ($id)
menu_example_arg_optional_to_arg ($arg)

Detailed Description

Module file for menu_example.

Definition in file menu_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/node_access_example Directory Reference

  • examples
  • node_access_example
node_access_example Directory Reference

Files

file | node_access_example.install [code]
file | node_access_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/node_access_example/node_access_example.install File Reference

  • examples
  • node_access_example
Functions
node_access_example.install File Reference

Go to the source code of this file.

Functions

node_access_example_schema ()

Detailed Description

Install, update, and uninstall functions for the node_access_example module.

Definition in file node_access_example.install.

Function Documentation

node_access_example_schema ( )

Implements hook_schema().

Definition at line 11 of file node_access_example.install.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/node_access_example/node_access_example.module File Reference

  • examples
  • node_access_example
Functions | Variables
node_access_example.module File Reference

Go to the source code of this file.

Functions

node_access_example_menu ()
node_access_example_private_node_listing ()
node_access_example_permission ()
node_access_example_node_access ($node, $op, $account)
node_access_example_node_grants ($account, $op)
node_access_example_node_access_records ($node)
node_access_example_form_alter (&$form, $form_state)
node_access_example_node_load ($nodes, $types)
node_access_example_node_delete ($node)
node_access_example_node_insert ($node)
node_access_example_node_update ($node)

Variables

const NODE_ACCESS_EXAMPLE_GRANT_ALL 23

Detailed Description

Module file illustrating API-based node access.

Definition in file node_access_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/node_example Directory Reference

  • examples
  • node_example
node_example Directory Reference

Files

file node_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/node_example/node_example.module File Reference

  • examples
  • node_example
Functions
node_example.module File Reference

Go to the source code of this file.

Functions

node_example_menu ()
node_example_node_info ()
node_example_node_type_insert ($content_type)
node_example_form ($node, $form_state)
node_example_page ()
node_example_entity_info_alter (&$entity_info)
node_example_field_formatter_info ()
node_example_field_formatter_view ($object_type, $object, $field, $instance, $langcode, $items, $display)
node_example_theme ($existing, $type, $theme, $path)
node_example_help ($path, $arg)
theme_example_node_color ($variables)
_node_example_installed_fields ()
_node_example_installed_instances ()

Detailed Description

Module file for Node Example module.

Part of the Examples for Developers project.

Definition in file node_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/nodeapi_example Directory Reference

  • examples
  • nodeapi_example
nodeapi_example Directory Reference

Files

file | nodeapi_example.install [code]
file | nodeapi_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/nodeapi_example/nodeapi_example.install File Reference

  • examples
  • nodeapi_example
Functions
nodeapi_example.install File Reference

Go to the source code of this file.

Functions

nodeapi_example_schema ()
nodeapi_example_uninstall ()

Detailed Description

Install, update and uninstall functions for the nodeapi_example module.

Definition in file nodeapi_example.install.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/nodeapi_example/nodeapi_example.module File Reference

  • examples
  • nodeapi_example
Functions
nodeapi_example.module File Reference

Go to the source code of this file.

Functions

nodeapi_example_form_alter (&$form, $form_state, $form_id)
nodeapi_example_node_validate ($node, $form)
nodeapi_example_node_load ($nodes, $types)
nodeapi_example_node_insert ($node)
nodeapi_example_node_delete ($node)
nodeapi_example_node_update ($node)
nodeapi_example_node_view ($node, $build_mode= 'full')
nodeapi_example_theme ()
theme_nodeapi_example_rating ($variables)

Detailed Description

Module implementation for nodeapi_example module.

Definition in file nodeapi_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/page_example Directory Reference

  • examples
  • page_example
page_example Directory Reference

Files

file page_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/page_example/page_example.module File Reference

  • examples
  • page_example
Functions
page_example.module File Reference

Go to the source code of this file.

Functions

page_example_help ($path, $arg)
page_example_permission ()
page_example_menu ()
page_example_description ()
page_example_simple ()
page_example_arguments ($first, $second)

Detailed Description

Module file for page_example_module.

Definition in file page_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/pager_example Directory Reference

  • examples
  • pager_example
pager_example Directory Reference

Files

file pager_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/pager_example/pager_example.module File Reference

  • examples
  • pager_example
Functions
pager_example.module File Reference

Go to the source code of this file.

Functions

pager_example_help ($path, $arg)
pager_example_menu ()
pager_example_page ()

Detailed Description

This is an example describing how a module can implement a pager in order to reduce the number of output rows to the screen and allow a user to scroll through multiple screens of output.

See: Database API Extenders

Definition in file pager_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/queue_example Directory Reference

  • examples
  • queue_example
queue_example Directory Reference

Files

file queue_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/queue_example/queue_example.module File Reference

  • examples
  • queue_example
Functions
queue_example.module File Reference

Go to the source code of this file.

Functions

queue_example_menu ()
queue_example_add_remove_form ($form, &$form_state)
queue_example_add_remove_form_insert ($form, &$form_state)
queue_example_show_queue ($form, &$form_state)
queue_example_add_remove_form_claim ($form, &$form_state)
queue_example_add_remove_form_delete ($form, &$form_state)
queue_example_add_remove_form_run_cron ($form, &$form_state)
queue_example_add_remove_form_clear_queue ($form, &$form_state)
queue_example_retrieve_queue ($queue_name)
theme_queue_items ($variables)
queue_example_theme ()

Detailed Description

Examples demonstrating the Drupal Queue API.

Definition in file queue_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/rdf_example Directory Reference

  • examples
  • rdf_example
rdf_example Directory Reference

Files

file | rdf_example.install [code]
file | rdf_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/rdf_example/rdf_example.install File Reference

  • examples
  • rdf_example
Functions
rdf_example.install File Reference

Go to the source code of this file.

Functions

rdf_example_install ()
_rdf_example_installed_fields ()
_rdf_example_installed_instances ()
rdf_example_uninstall ()

Detailed Description

Install file for RDF Example module.

To demonstrate hook_rdf_mapping, this module creates it's own node type. For more information on creating node types, see Node Example.

Definition in file rdf_example.install.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/rdf_example/rdf_example.module File Reference

  • examples
  • rdf_example
Functions
rdf_example.module File Reference

Go to the source code of this file.

Functions

rdf_example_rdf_mapping ()
rdf_example_rdf_namespaces ()
rdf_example_help ($path, $arg)

Detailed Description

This is an example outlining how a module can be used to define RDF mappings. We define mappings for a node type defined in this module. We also customize mappings for a node type that is defined in another module, node_example.

Definition in file rdf_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/render_example Directory Reference

  • examples
  • render_example
render_example Directory Reference

Files

file | render_example.install [code]
file | render_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/render_example/render_example.install File Reference

  • examples
  • render_example
Functions
render_example.install File Reference

Go to the source code of this file.

Functions

render_example_uninstall ()

Detailed Description

Install, update and uninstall functions for the render_example module.

Definition in file render_example.install.

Function Documentation

render_example_uninstall ( )

Implements hook_uninstall().

Definition at line 11 of file render_example.install.

References variable_del().

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/render_example/render_example.module File Reference

  • examples
  • render_example
Functions
render_example.module File Reference

Go to the source code of this file.

Functions

render_example_menu ()
render_example_info ()
render_example_arrays ()
render_example_cache_pre_render ($element)
render_example_cache_expensive ()
render_example_add_suffix ($element)
render_example_add_prefix ($markup, $element)
theme_render_example_aggregate ($variables)
render_example_demo_form ($form, &$form_state)
render_example_page_alter (&$page)
render_example_embedded_form ($form, &$form_state, $form_items)
render_example_theme ()
theme_render_example_add_div ($variables)
theme_render_example_add_notes ($variables)
theme_render_array ($variables)
render_example_change_to_ol ($element)
render_example_add_hr ($markup, $element)

Detailed Description

Demonstrates render arrays.

Definition in file render_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/simpletest_example Directory Reference

  • examples
  • simpletest_example
simpletest_example Directory Reference

Files

file | simpletest_example.install [code]
file | simpletest_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/simpletest_example/simpletest_example.install File Reference

  • examples
  • simpletest_example
Functions
simpletest_example.install File Reference

Go to the source code of this file.

Functions

simpletest_example_install ()
simpletest_example_update_7001 ()

Detailed Description

Install, update and uninstall functions for the simpletest_example module.

Definition in file simpletest_example.install.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/simpletest_example/simpletest_example.module File Reference

  • examples
  • simpletest_example
Functions
simpletest_example.module File Reference

Go to the source code of this file.

Functions

simpletest_example_node_info ()
simpletest_example_permission ()
simpletest_example_node_access ($node, $op, $account)
simpletest_example_form ($node, $form_state)
simpletest_example_menu ()
_simpletest_example_explanation ()
simpletest_example_empty_mysql_date ($date_string)

Detailed Description

Module file for simpletest_example

Definition in file simpletest_example.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/tabledrag_example Directory Reference

  • examples
  • tabledrag_example
tabledrag_example Directory Reference

Files

file | tabledrag_example.install [code]
file | tabledrag_example.module [code]
file | tabledrag_example_parent_form.inc [code]
file | tabledrag_example_simple_form.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/tabledrag_example/tabledrag_example.install File Reference

  • examples
  • tabledrag_example
Functions
tabledrag_example.install File Reference

Go to the source code of this file.

Functions

tabledrag_example_schema ()
tabledrag_example_install ()
tabledrag_example_uninstall ()

Detailed Description

Install and uninstall functions for the tabledrag example module.

This file contains the functions required to perform install and uninstall operations.

Definition in file tabledrag_example.install.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/tabledrag_example/tabledrag_example.module File Reference

  • examples
  • tabledrag_example
Functions
tabledrag_example.module File Reference

Go to the source code of this file.

Functions

tabledrag_example_help ($path, $arg)
tabledrag_example_menu ()
tabledrag_example_theme ()

Detailed Description

An example of how to build a sortable form using tabledrag.

Definition in file tabledrag_example.module.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/tabledrag_example/tabledrag_example_parent_form.inc File Reference

  • examples
  • tabledrag_example
Functions
tabledrag_example_parent_form.inc File Reference

Go to the source code of this file.

Functions

tabledrag_example_parent_form ($form_state)
theme_tabledrag_example_parent_form ($variables)
tabledrag_example_parent_form_submit ($form, &$form_state)
tabledrag_example_parent_get_data ()
tabledrag_example_get_tree ($parentitem, &$itemtree=array(), &$depth=0)

Detailed Description

Example demonstrating a parent/child tabledrag form

Definition in file tabledrag_example_parent_form.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/tabledrag_example/tabledrag_example_simple_form.inc File Reference

  • examples
  • tabledrag_example
Functions
tabledrag_example_simple_form.inc File Reference

Go to the source code of this file.

Functions

tabledrag_example_simple_form ($form_state)
theme_tabledrag_example_simple_form ($variables)
tabledrag_example_simple_form_submit ($form, &$form_state)

Detailed Description

Example demonstrating a simple (i.e. 'sort' only) tabledrag form

Definition in file tabledrag_example_simple_form.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/tablesort_example Directory Reference

  • examples
  • tablesort_example
tablesort_example Directory Reference

Files

file | tablesort_example.install [code]
file | tablesort_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/tablesort_example/tablesort_example.install File Reference

  • examples
  • tablesort_example
Functions
tablesort_example.install File Reference

Go to the source code of this file.

Functions

tablesort_example_install ()
tablesort_example_uninstall ()
tablesort_example_schema ()

Detailed Description

Install and uninstall functions for the tablesort example module.

This file contains the functions required to perform install and uninstall operations.

Definition in file tablesort_example.install.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/tablesort_example/tablesort_example.module File Reference

  • examples
  • tablesort_example
Functions
tablesort_example.module File Reference

Go to the source code of this file.

Functions

tablesort_example_help ($path, $arg)
tablesort_example_menu ()
tablesort_example_page ()

Detailed Description

This is an example describing how a module can display data in a sortable table

See: Extenders Database API

Definition in file tablesort_example.module.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/theming_example Directory Reference

  • examples
  • theming_example
theming_example Directory Reference

Files

file | theming-example-text-form.tpl.php [code]
file | theming_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/theming_example/theming-example-text-form.tpl.php File Reference

  • examples
  • theming_example
Variables
theming-example-text-form.tpl.php File Reference

Go to the source code of this file.

Variables

print $text_form

Detailed Description

Template file for the theming example text form.

Available custom variables:

  • $text_form: A string containing the pre-rendered form.
  • $text_form_content: An array of form elements keyed by the element name.

The default example below renders the entire form and its form elements in a default order provided by Drupal.

Alternatively, you may print each form element in the order you desire, adding any extra html markup you wish to decorate the form like this:

<?php print $text_form_content['element_name']; ?>

The following snippet will print the contents of the $text_form_content array, hidden in the source of the page, for you to discover the individual element names.

<?php print ''; ?>

Definition in file theming-example-text-form.tpl.php.

Variable Documentation

print $text_form

Definition at line 28 of file theming-example-text-form.tpl.php.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/theming_example/theming_example.module File Reference

  • examples
  • theming_example
Functions
theming_example.module File Reference

Go to the source code of this file.

Functions

theming_example_menu ()
theming_example_theme ()
theming_example_page ()
theming_example_list_page ()
theming_example_select_form ($form, &$form_state)
theming_example_select_form_submit ($form, &$form_state)
theming_example_text_form ($form, &$form_state)
theming_example_text_form_submit ($form, &$form_state)
theme_theming_example_content_array ($variables)
theme_theming_example_list ($variables)
theme_theming_example_select_form ($variables)
template_preprocess_theming_example_text_form (&$variables)

Detailed Description

Explains how a module declares theme functions, preprocess functions, and templates.

The underlying approach is that a module should allow themes to do all rendering, but provide default implementations where appropriate.

Modules are also expected to leave data as render arrays as long as possible, leaving rendering to theme functions and templates.

Definition in file theming_example.module.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/token_example Directory Reference

  • examples
  • token_example
token_example Directory Reference

Files

file | token_example.module [code]
file | token_example.tokens.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/token_example/token_example.module File Reference

  • examples
  • token_example
Functions
token_example.module File Reference

Go to the source code of this file.

Functions

token_example_menu ()
token_example_entity_info_alter (&$info)
token_example_example_form ($form, &$form_state)
token_example_example_form_submit ($form, &$form_state)
_token_example_get_node ()
_token_example_get_comment ()
_token_example_get_user ()
_token_example_get_taxonomy_term ()
_token_example_get_file ()

Detailed Description

An example module showing how to define and use tokens.

The Token module provides an API for providing tokens to other modules. Tokens are small bits of text that can be placed into larger documents via simple placeholders, like site-name or [user].

Definition in file token_example.module.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/token_example/token_example.tokens.inc File Reference

  • examples
  • token_example
Functions
token_example.tokens.inc File Reference

Go to the source code of this file.

Functions

token_example_token_info ()
token_example_tokens ($type, $tokens, array $data=array(), array $options=array())

Detailed Description

Token callbacks for the token_example module.

Definition in file token_example.tokens.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/trigger_example Directory Reference

  • examples
  • trigger_example
trigger_example Directory Reference

Files

file trigger_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/trigger_example/trigger_example.module File Reference

  • examples
  • trigger_example
Functions
trigger_example.module File Reference

Go to the source code of this file.

Functions

trigger_example_trigger_info ()
trigger_example_triggersomething ($options=array())
trigger_example_user_login (&$edit, $account, $category=NULL)
_trigger_example_first_time_login ($hook, &$edit, $account, $category=NULL)
trigger_example_help ($path, $arg)
trigger_example_menu ()
trigger_example_form ($form_state)
trigger_example_form_submit ($form, $form_state)
trigger_example_trigger_info_alter (&$triggers)

Detailed Description

Trigger definition example module.

Definition in file trigger_example.module.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/vertical_tabs_example Directory Reference

  • examples
  • vertical_tabs_example
vertical_tabs_example Directory Reference

Files

file vertical_tabs_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/vertical_tabs_example/vertical_tabs_example.module File Reference

  • examples
  • vertical_tabs_example
Functions
vertical_tabs_example.module File Reference

Go to the source code of this file.

Functions

vertical_tabs_example_menu ()
vertical_tabs_example_form_alter (&$form, $form_state, $form_id)
_vertical_tabs_example_explanation ()

Detailed Description

Module file for vertical_tabs_example module.

Definition in file vertical_tabs_example.module.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/xmlrpc_example Directory Reference

  • examples
  • xmlrpc_example
xmlrpc_example Directory Reference

Files

file xmlrpc_example.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/xmlrpc_example/xmlrpc_example.module File Reference

  • examples
  • xmlrpc_example
Functions
xmlrpc_example.module File Reference

Go to the source code of this file.

Functions

xmlrpc_example_menu ()
xmlrpc_example_info ()
xmlrpc_example_xmlrpc ()
_xmlrpc_example_server_add ($num1, $num2)
_xmlrpc_example_server_subtract ($num1, $num2)
xmlrpc_example_server_form ()
xmlrpc_example_client_form ()
xmlrpc_example_client_request_methods_submit ($form, &$form_state)
xmlrpc_example_client_add_submit ($form, &$form_state)
xmlrpc_example_client_subtract_submit ($form, &$form_state)
xmlrpc_example_client_multicall_submit ($form, &$form_state)
xmlrpc_example_xmlrpc_alter (&$methods)
_xmlrpc_example_alter_add ($num1, $num2)
_xmlrpc_example_alter_subtract ($num1, $num2)
xmlrpc_example_alter_form ()

Detailed Description

Module file for xmlrpc_example module.

Definition in file xmlrpc_example.module.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/examples.index.php File Reference

  • examples
examples.index.php File Reference

Go to the source code of this file.

Detailed Description

Example modules

  • Creating actions
  • Using AJAX forms
  • Using the batch API
  • Defining blocks
  • Demonstrate Drupal caching
  • Defining contextual links
  • Using hook_cron() and hook_cron_queue_info()
  • Database examples (DBTNG)
  • Sending e-mail
  • Creating and managing a custom entity
  • Defining fields in the field API
  • Demonstrates file handling
  • Defining an input filter
  • Form API examples, including multistep forms
  • Demonstrates image handling with styles and effects
  • Javascript examples
  • Menu API examples
  • Node API demonstrations showing how a separate module can change the behavior of a node
  • Define custom node access fules using node access hooks
  • Creating custom node types, with fields
  • Creating a custom page
  • Using a table with a pager
  • Using the Queue API
  • Implementing RDF in Drupal
  • Demonstrates the render API
  • Writing tests for Drupal
  • Use a render array to present a table with automatic sorting
  • Demonstrates tabledrag forms
  • Demonstrate how modules shoule use theme functions and provide tpl.php files
  • Using tokens
  • Implementing triggers and actions
  • Using vertical tabs
  • XML-RPC example

Definition in file examples.index.php.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/examples.module File Reference

  • examples
Functions
examples.module File Reference

Go to the source code of this file.

Functions

examples_help ($path, $arg)

Detailed Description

This file serves as a stub file for the many Examples modules in the Examples for Developers Project which you can download and experiment with.

One might say that examples.module is an example of documentation. However, note that the example submodules define many doxygen groups, which may or may not be a good strategy for other modules.

Definition in file examples.module.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes Directory Reference

  • includes
includes Directory Reference

Directories

directory | database
directory | filetransfer

Files

file | actions.inc [code]
file | ajax.inc [code]
file | archiver.inc [code]
file | authorize.inc [code]
file | batch.inc [code]
file | batch.queue.inc [code]
file | bootstrap.inc [code]
file | cache-install.inc [code]
file | cache.inc [code]
file | common.inc [code]
file | date.inc [code]
file | entity.inc [code]
file | errors.inc [code]
file | file.inc [code]
file | file.mimetypes.inc [code]
file | form.inc [code]
file | graph.inc [code]
file | image.inc [code]
file | install.core.inc [code]
file | install.inc [code]
file | iso.inc [code]
file | json-encode.inc [code]
file | language.inc [code]
file | locale.inc [code]
file | lock.inc [code]
file | mail.inc [code]
file | menu.inc [code]
file | module.inc [code]
file | pager.inc [code]
file | password.inc [code]
file | path.inc [code]
file | registry.inc [code]
file | session.inc [code]
file | stream_wrappers.inc [code]
file | tablesort.inc [code]
file | theme.inc [code]
file | theme.maintenance.inc [code]
file | token.inc [code]
file | unicode.entities.inc [code]
file | unicode.inc [code]
file | update.inc [code]
file | updater.inc [code]
file | utility.inc [code]
file | xmlrpc.inc [code]
file | xmlrpcs.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database Directory Reference

  • includes
  • database
database Directory Reference

Directories

directory | mysql
directory | pgsql
directory | sqlite

Files

file | database.inc [code]
file | log.inc [code]
file | prefetch.inc [code]
file | query.inc [code]
file | schema.inc [code]
file | select.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/mysql Directory Reference

  • includes
  • database
  • mysql
mysql Directory Reference

Files

file | database.inc [code]
file | install.inc [code]
file | query.inc [code]
file | schema.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/mysql/database.inc File Reference

  • includes
  • database
  • mysql
Classes
database.inc File Reference

Go to the source code of this file.

Classes

class DatabaseConnection_mysql

Detailed Description

Database interface code for MySQL database servers.

Definition in file database.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/mysql/install.inc File Reference

  • includes
  • database
  • mysql
Classes
install.inc File Reference

Go to the source code of this file.

Classes

class DatabaseTasks_mysql

Detailed Description

Installation code for MySQL embedded database engine.

Definition in file install.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/mysql/schema.inc File Reference

  • includes
  • database
  • mysql
Classes
schema.inc File Reference

Go to the source code of this file.

Classes

class DatabaseSchema_mysql

Detailed Description

Database schema code for MySQL database servers.

Definition in file schema.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/pgsql Directory Reference

  • includes
  • database
  • pgsql
pgsql Directory Reference

Files

file | database.inc [code]
file | install.inc [code]
file | query.inc [code]
file | schema.inc [code]
file | select.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/pgsql/database.inc File Reference

  • includes
  • database
  • pgsql
Classes | Variables
database.inc File Reference

Go to the source code of this file.

Classes

class DatabaseConnection_pgsql

Variables

const POSTGRESQL_NEXTID_LOCK 1000

Detailed Description

Database interface code for PostgreSQL database servers.

Definition in file database.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/pgsql/install.inc File Reference

  • includes
  • database
  • pgsql
Classes
install.inc File Reference

Go to the source code of this file.

Classes

class DatabaseTasks_pgsql

Detailed Description

Install functions for PostgreSQL embedded database engine.

Definition in file install.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/pgsql/schema.inc File Reference

  • includes
  • database
  • pgsql
Classes
schema.inc File Reference

Go to the source code of this file.

Classes

class DatabaseSchema_pgsql

Detailed Description

Database schema code for PostgreSQL database servers.

Definition in file schema.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/pgsql/select.inc File Reference

  • includes
  • database
  • pgsql
Classes
select.inc File Reference

Go to the source code of this file.

Classes

class SelectQuery_pgsql

Detailed Description

Select builder for PostgreSQL database engine.

Definition in file select.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/sqlite Directory Reference

  • includes
  • database
  • sqlite
sqlite Directory Reference

Files

file | database.inc [code]
file | install.inc [code]
file | query.inc [code]
file | schema.inc [code]
file | select.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/sqlite/database.inc File Reference

  • includes
  • database
  • sqlite
Classes
database.inc File Reference

Go to the source code of this file.

Classes

class | DatabaseConnection_sqlite
class | DatabaseStatement_sqlite

Detailed Description

Database interface code for SQLite embedded database engine.

Definition in file database.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/sqlite/install.inc File Reference

  • includes
  • database
  • sqlite
Classes
install.inc File Reference

Go to the source code of this file.

Classes

class DatabaseTasks_sqlite

Detailed Description

SQLite specific install functions

Definition in file install.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/sqlite/query.inc File Reference

  • includes
  • database
  • sqlite
Classes
query.inc File Reference

Go to the source code of this file.

Classes

class | InsertQuery_sqlite
class | UpdateQuery_sqlite
class | DeleteQuery_sqlite
class | TruncateQuery_sqlite

Detailed Description

Query code for SQLite embedded database engine.

Definition in file query.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/sqlite/schema.inc File Reference

  • includes
  • database
  • sqlite
Classes
schema.inc File Reference

Go to the source code of this file.

Classes

class DatabaseSchema_sqlite

Detailed Description

Database schema code for SQLite databases.

Definition in file schema.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/sqlite/select.inc File Reference

  • includes
  • database
  • sqlite
Classes
select.inc File Reference

Go to the source code of this file.

Classes

class SelectQuery_sqlite

Detailed Description

Select builder for SQLite embedded database engine.

Definition in file select.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/database.inc File Reference

  • includes
  • database
Classes | Functions
database.inc File Reference

Go to the source code of this file.

Classes

class | DatabaseConnection
class | Database
class | DatabaseTransactionNoActiveException
class | DatabaseTransactionNameNonUniqueException
class | DatabaseTransactionCommitFailedException
class | DatabaseTransactionExplicitCommitNotAllowedException
class | DatabaseTransactionOutOfOrderException
class | InvalidMergeQueryException
class | FieldsOverlapException
class | NoFieldsException
class | DatabaseConnectionNotDefinedException
class | DatabaseDriverNotSpecifiedException
class | DatabaseTransaction
interface | DatabaseStatementInterface
class | DatabaseStatementBase
class | DatabaseStatementEmpty

Functions

db_query ($query, array $args=array(), array $options=array())
db_query_range ($query, $from, $count, array $args=array(), array $options=array())
db_query_temporary ($query, array $args=array(), array $options=array())
db_insert ($table, array $options=array())
db_merge ($table, array $options=array())
db_update ($table, array $options=array())
db_delete ($table, array $options=array())
db_truncate ($table, array $options=array())
db_select ($table, $alias=NULL, array $options=array())
db_transaction ($name=NULL, array $options=array())
db_set_active ($key= 'default')
db_escape_table ($table)
db_escape_field ($field)
db_like ($string)
db_driver ()
db_close (array $options=array())
db_next_id ($existing_id=0)
db_or ()
db_and ()
db_xor ()
db_condition ($conjunction)
db_create_table ($name, $table)
db_field_names ($fields)
db_index_exists ($table, $name)
db_table_exists ($table)
db_field_exists ($table, $field)
db_find_tables ($table_expression)
_db_create_keys_sql ($spec)
db_rename_table ($table, $new_name)
db_drop_table ($table)
db_add_field ($table, $field, $spec, $keys_new=array())
db_drop_field ($table, $field)
db_field_set_default ($table, $field, $default)
db_field_set_no_default ($table, $field)
db_add_primary_key ($table, $fields)
db_drop_primary_key ($table)
db_add_unique_key ($table, $name, $fields)
db_drop_unique_key ($table, $name)
db_add_index ($table, $name, $fields)
db_drop_index ($table, $name)
db_change_field ($table, $field, $field_new, $spec, $keys_new=array())
db_ignore_slave ()

Detailed Description

Core systems for the database layer.

Classes required for basic functioning of the database system should be placed in this file. All utility functions should also be placed in this file only, as they cannot auto-load the way classes can.

Definition in file database.inc.

Function Documentation

db_ignore_slave ( )

End of "addtogroup schemaapi". Sets a session variable specifying the lag time for ignoring a slave server.

Definition at line 3027 of file database.inc.

References Database\getConnectionInfo(), REQUEST_TIME, and variable_get().

Referenced by comment_save(), and node_save().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/log.inc File Reference

  • includes
  • database
Classes
log.inc File Reference

Go to the source code of this file.

Classes

class DatabaseLog

Detailed Description

Logging classes for the database layer.

Definition in file log.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/prefetch.inc File Reference

  • includes
  • database
Classes
prefetch.inc File Reference

Go to the source code of this file.

Classes

class DatabaseStatementPrefetch

Detailed Description

Database interface code for engines that need complete control over their result sets. For example, SQLite will prefix some column names by the name of the table. We post-process the data, by renaming the column names using the same convention as MySQL and PostgreSQL.

Definition in file prefetch.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/schema.inc File Reference

  • includes
  • database
Classes
schema.inc File Reference

Go to the source code of this file.

Classes

class | DatabaseSchema
class | DatabaseSchemaObjectExistsException
class | DatabaseSchemaObjectDoesNotExistException

Detailed Description

Generic Database schema code.

Definition in file schema.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/select.inc File Reference

  • includes
  • database
Classes
select.inc File Reference

Go to the source code of this file.

Classes

interface | QueryExtendableInterface
interface | SelectQueryInterface
class | SelectQueryExtender
class | SelectQuery
Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/filetransfer Directory Reference

  • includes
  • filetransfer
filetransfer Directory Reference

Files

file | filetransfer.inc [code]
file | ftp.inc [code]
file | local.inc [code]
file | ssh.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/filetransfer/filetransfer.inc File Reference

  • includes
  • filetransfer
Classes
filetransfer.inc File Reference

Go to the source code of this file.

Classes

class | FileTransfer
class | FileTransferException
interface | FileTransferChmodInterface
class | SkipDotsRecursiveDirectoryIterator
Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/filetransfer/ftp.inc File Reference

  • includes
  • filetransfer
Classes
ftp.inc File Reference

Go to the source code of this file.

Classes

class | FileTransferFTP
class | FileTransferFTPExtension
Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/filetransfer/local.inc File Reference

  • includes
  • filetransfer
Classes
local.inc File Reference

Go to the source code of this file.

Classes

class FileTransferLocal
Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/filetransfer/ssh.inc File Reference

  • includes
  • filetransfer
Classes
ssh.inc File Reference

Go to the source code of this file.

Classes

class FileTransferSSH
Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/actions.inc File Reference

  • includes
Functions
actions.inc File Reference

Go to the source code of this file.

Functions

actions_do ($action_ids, $object=NULL, $context=NULL, $a1=NULL, $a2=NULL)
actions_list ($reset=FALSE)
actions_get_all_actions ()
actions_actions_map ($actions)
actions_function_lookup ($hash)
actions_synchronize ($delete_orphans=FALSE)
actions_save ($function, $type, $params, $label, $aid=NULL)
actions_load ($aid)
actions_delete ($aid)

Detailed Description

This is the actions engine for executing stored actions.

Definition in file actions.inc.

Function Documentation

actions_actions_map ( $actions )

Creates an associative array keyed by hashes of function names or IDs.

Hashes are used to prevent actual function names from going out into HTML forms and coming back.

Parameters
$actions An associative array with function names or action IDs as keys and associative arrays with keys 'label', 'type', etc. as values. This is usually the output of actions_list() or actions_get_all_actions().
Returns
An associative array whose keys are hashes of the input array keys, and whose corresponding values are associative arrays with components 'callback', 'label', 'type', and 'configurable' from the input array.

Definition at line 216 of file actions.inc.

References drupal_hash_base64().

Referenced by system_actions_configure(), system_actions_manage(), and trigger_assign_form().

actions_delete ( $aid )

Deletes a single action from the database.

Parameters
$aid The ID of the action to delete.

Definition at line 383 of file actions.inc.

References db_delete(), and module_invoke_all().

Referenced by actions_synchronize(), and system_actions_delete_form_submit().

actions_function_lookup ( $hash )

Returns an action array key (function or ID), given its hash.

Faster than actions_actions_map() when you only need the function name or ID.

Parameters
$hash Hash of a function name or action ID array key. The array key is a key into the return value of actions_list() (array key is the action function name) or actions_get_all_actions() (array key is the action ID).
Returns
The corresponding array key, or FALSE if no match is found.

Definition at line 241 of file actions.inc.

References $row, actions_list(), db_query(), and drupal_hash_base64().

Referenced by system_actions_configure_submit(), system_actions_configure_validate(), trigger_assign_form(), trigger_assign_form_submit(), trigger_assign_form_validate(), trigger_unassign(), and trigger_unassign_submit().

actions_get_all_actions ( )

Retrieves all action instances from the database.

This function differs from the actions_list() function, which gathers actions by invoking hook_action_info(). The actions returned by this function and the actions returned by actions_list() are partially synchronized. Non-configurable actions from hook_action_info() implementations are put into the database when actions_synchronize() is called, which happens when admin/config/system/actions is visited. Configurable actions are not added to the database until they are configured in the user interface, in which case a database row is created for each configuration of each action.

Returns
Associative array keyed by numeric action ID. Each value is an associative array with keys 'callback', 'label', 'type' and 'configurable'.

Definition at line 190 of file actions.inc.

References db_query().

Referenced by trigger_assign_form(), trigger_unassign(), and trigger_unassign_submit().

actions_list ( $reset = FALSE )

Discovers all available actions by invoking hook_action_info().

This function contrasts with actions_get_all_actions(); see the documentation of actions_get_all_actions() for an explanation.

Parameters
$reset Reset the action info static cache.
Returns
An associative array keyed on action function name, with the same format as the return value of hook_action_info(), containing all modules' hook_action_info() return values as modified by any hook_action_info_alter() implementations.
See Also
hook_action_info()

Definition at line 162 of file actions.inc.

References drupal_alter(), drupal_static(), and module_invoke_all().

Referenced by actions_do(), actions_function_lookup(), actions_synchronize(), system_actions_configure(), system_actions_manage(), trigger_assign_form(), and trigger_assign_form_submit().

actions_load ( $aid )

Retrieves a single action from the database.

Parameters
$aid The ID of the action to retrieve.
Returns
The appropriate action row from the database as an object.

Definition at line 373 of file actions.inc.

References db_query().

Referenced by system_actions_delete_form_submit().

actions_save | ( | $function,
 |  | $type,
 |  | $params,
 |  | $label,
 |  | $aid = NULL
 | ) |

Saves an action and its user-supplied parameter values to the database.

Parameters
$function | The name of the function to be called when this action is performed.
$type | The type of action, to describe grouping and/or context, e.g., 'node', 'user', 'comment', or 'system'.
$params | An associative array with parameter names as keys and parameter values as values.
$label | A user-supplied label of this particular action, e.g., 'Send e-mail to Jim'.
$aid | The ID of this action. If omitted, a new action is created.
Returns
The ID of the action.

Definition at line 343 of file actions.inc.

References db_merge(), db_next_id(), and watchdog().

Referenced by system_actions_configure_submit().

actions_synchronize ( $delete_orphans = FALSE )

Synchronizes actions that are provided by modules in hook_action_info().

Actions provided by modules in hook_action_info() implementations are synchronized with actions that are stored in the actions database table. This is necessary so that actions that do not require configuration can receive action IDs.

Parameters
$delete_orphans If TRUE, any actions that exist in the database but are no longer found in the code (for example, because the module that provides them has been disabled) will be deleted.

Definition at line 274 of file actions.inc.

References actions_delete(), actions_list(), db_insert(), db_query(), l(), t(), watchdog(), and WATCHDOG_INFO.

Referenced by drupal_flush_all_caches(), system_actions_manage(), system_actions_remove_orphans(), and trigger_install().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/ajax.inc File Reference

  • includes
Functions
ajax.inc File Reference

Go to the source code of this file.

Functions

ajax_render ($commands=array())
ajax_get_form ()
ajax_form_callback ()
ajax_base_page_theme ()
ajax_deliver ($page_callback_result)
ajax_prepare_response ($page_callback_result)
ajax_footer ()
ajax_process_form ($element, &$form_state)
ajax_pre_render_element ($element)
ajax_command_alert ($text)
ajax_command_insert ($selector, $html, $settings=NULL)
ajax_command_replace ($selector, $html, $settings=NULL)
ajax_command_html ($selector, $html, $settings=NULL)
ajax_command_prepend ($selector, $html, $settings=NULL)
ajax_command_append ($selector, $html, $settings=NULL)
ajax_command_after ($selector, $html, $settings=NULL)
ajax_command_before ($selector, $html, $settings=NULL)
ajax_command_remove ($selector)
ajax_command_changed ($selector, $asterisk= '')
ajax_command_css ($selector, $argument)
ajax_command_settings ($argument, $merge=FALSE)
ajax_command_data ($selector, $name, $value)
ajax_command_invoke ($selector, $method, array $arguments=array())
ajax_command_restripe ($selector)

Detailed Description

Functions for use with Drupal's Ajax framework.

Definition in file ajax.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/archiver.inc File Reference

  • includes
Classes
archiver.inc File Reference

Go to the source code of this file.

Classes

interface ArchiverInterface

Detailed Description

Shared classes and interfaces for the archiver system.

Definition in file archiver.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/authorize.inc File Reference

  • includes
Functions
authorize.inc File Reference

Go to the source code of this file.

Functions

authorize_filetransfer_form ($form, &$form_state)
_authorize_filetransfer_connection_settings ($backend)
_authorize_filetransfer_connection_settings_set_defaults (&$element, $key, array $defaults)
authorize_filetransfer_form_validate ($form, &$form_state)
authorize_filetransfer_form_submit ($form, &$form_state)
authorize_run_operation ($filetransfer)
authorize_get_filetransfer ($backend, $settings=array())

Detailed Description

Helper functions and form handlers used for the authorize.php script.

Definition in file authorize.inc.

Function Documentation

_authorize_filetransfer_connection_settings ( $backend )

Generates the Form API array for a given connection backend's settings.

Parameters
$backend The name of the backend (e.g. 'ftp', 'ssh', etc).
Returns
Form API array of connection settings for the given backend.
See Also
hook_filetransfer_backends()

Definition at line 146 of file authorize.inc.

References _authorize_filetransfer_connection_settings_set_defaults(), authorize_get_filetransfer(), and variable_get().

Referenced by authorize_filetransfer_form().

_authorize_filetransfer_connection_settings_set_defaults | ( | & | $element,
 |  |  | $key,
 |  | array | $defaults
 | ) |  |

Sets the default settings on a file transfer connection form recursively.

The default settings for the file transfer connection forms are saved in the database. The settings are stored as a nested array in the case of a settings form that has fieldsets or otherwise uses a nested structure. Therefore, to properly add defaults, we need to walk through all the children form elements and process those defaults recursively.

Parameters
$element | Reference to the Form API form element we're operating on.
$key | The key for our current form element, if any.
array | $defaults | The default settings for the file transfer backend we're operating on.

Definition at line 176 of file authorize.inc.

References element_children().

Referenced by _authorize_filetransfer_connection_settings().

authorize_filetransfer_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for authorize_filetransfer_form().

See Also
authorize_filetransfer_form()
authorize_filetransfer_validate()

Definition at line 232 of file authorize.inc.

References $base_url, $value, authorize_get_filetransfer(), authorize_run_operation(), and variable_set().

authorize_filetransfer_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for authorize_filetransfer_form().

See Also
authorize_filetransfer_form()
authorize_filetransfer_submit()

Definition at line 199 of file authorize.inc.

References authorize_get_filetransfer(), form_set_error(), and t().

authorize_get_filetransfer | ( | $backend,
 |  | $settings = array()
 | ) |

Gets a FileTransfer class for a specific transfer method and settings.

Parameters
$backend | The FileTransfer backend to get the class for.
$settings | Array of settings for the FileTransfer.
Returns
An instantiated FileTransfer object for the requested method and settings, or FALSE if there was an error finding or instantiating it.

Definition at line 319 of file authorize.inc.

References DRUPAL_ROOT.

Referenced by _authorize_filetransfer_connection_settings(), authorize_filetransfer_form_submit(), and authorize_filetransfer_form_validate().

authorize_run_operation ( $filetransfer )

Runs the operation specified in $_SESSION['authorize_operation'].

Parameters
$filetransfer The FileTransfer object to use for running the operation.

Definition at line 295 of file authorize.inc.

References DRUPAL_ROOT, and drupal_set_title().

Referenced by authorize_filetransfer_form_submit().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/batch.inc File Reference

  • includes
Functions
batch.inc File Reference

Go to the source code of this file.

Functions

batch_load ($id)
_batch_page ()
_batch_start ()
_batch_progress_page_js ()
_batch_do ()
_batch_progress_page_nojs ()
_batch_process ()
_batch_api_percentage ($total, $current)
& _batch_current_set ()
_batch_next_set ()
_batch_finished ()
_batch_shutdown ()

Detailed Description

Batch processing API for processes to run in multiple HTTP requests.

Note that batches are usually invoked by form submissions, which is why the core interaction functions of the batch processing API live in form.inc.

See Also
form.inc
batch_set()
batch_process()
batch_get()

Definition in file batch.inc.

Function Documentation

_batch_api_percentage | ( | $total,
 |  | $current
 | ) |

Formats the percent completion for a batch set.

Parameters
$total | The total number of operations.
$current | The number of the current operation. This may be a floating point number rather than an integer in the case of a multi-step operation that is not yet complete; in that case, the fractional part of $current represents the fraction of the operation that has been completed.
Returns
The properly formatted percentage, as a string. We output percentages using the correct number of decimal places so that we never print "100%" until we are finished, but we also never print more decimal places than are meaningful.
See Also
_batch_process()

Definition at line 391 of file batch.inc.

References $percentage.

Referenced by _batch_process().

& _batch_current_set ( )

Returns the batch set being currently processed.

Definition at line 418 of file batch.inc.

References batch_get().

Referenced by _batch_next_set(), _batch_process(), _batch_progress_page_js(), and _batch_progress_page_nojs().

_batch_do ( )

Does one execution pass with JavaScript and returns progress to the browser.

See Also
_batch_progress_page_js()
_batch_process()

Definition at line 152 of file batch.inc.

References $percentage, _batch_process(), drupal_json_output(), drupal_set_message(), drupal_set_title(), and t().

Referenced by _batch_page().

_batch_finished ( )

Ends the batch processing.

Call the 'finished' callback of each batch set to allow custom handling of the results and resolve page redirection.

Definition at line 453 of file batch.inc.

References _batch_queue(), batch_get(), db_delete(), drupal_redirect_form(), DRUPAL_ROOT, and format_interval().

Referenced by _batch_page(), and _batch_process().

_batch_next_set ( )

Retrieves the next set in a batch.

If there is a subsequent set in this batch, assign it as the new set to process and execute its form submit handler (if defined), which may add further sets to this batch.

Returns
TRUE if a subsequent set was found in the batch.

Definition at line 433 of file batch.inc.

References _batch_current_set(), and batch_get().

Referenced by _batch_process().

_batch_page ( )

Renders the batch processing page based on the current state of the batch.

See Also
_batch_shutdown()

Definition at line 43 of file batch.inc.

References $op, $output, _batch_do(), _batch_finished(), _batch_progress_page_nojs(), _batch_start(), batch_get(), batch_load(), drupal_add_css(), drupal_goto(), drupal_register_shutdown_function(), drupal_set_message(), and t().

Referenced by install_run_task(), and system_batch_page().

_batch_process ( )

Processes sets in a batch.

If the batch was marked for progressive execution (default), this executes as many operations in batch sets until an execution time of 1 second has been exceeded. It will continue with the next operation of the same batch set in the next request.

Returns
An array containing a completion value (in percent) and a status message.

Definition at line 241 of file batch.inc.

References $percentage, _batch_api_percentage(), _batch_current_set(), _batch_finished(), _batch_next_set(), _batch_queue(), batch_get(), DRUPAL_ROOT, format_interval(), timer_read(), and timer_start().

Referenced by _batch_do(), _batch_progress_page_nojs(), and batch_process().

_batch_progress_page_js ( )

Outputs a batch processing page with JavaScript support.

This initializes the batch and error messages. Note that in JavaScript-based processing, the batch processing page is displayed only once and updated via AHAH requests, so only the first batch set gets to define the page title. Titles specified by subsequent batch sets are not displayed.

See Also
batch_set()
_batch_do()

Definition at line 123 of file batch.inc.

References _batch_current_set(), batch_get(), drupal_add_js(), drupal_add_library(), drupal_set_title(), PASS_THROUGH, and url().

Referenced by _batch_start().

_batch_progress_page_nojs ( )

Outputs a batch processing page without JavaScript support.

See Also
_batch_process()

Definition at line 171 of file batch.inc.

References $percentage, $url, _batch_current_set(), _batch_process(), batch_get(), drupal_add_html_head(), drupal_set_title(), PASS_THROUGH, print, theme(), and url().

Referenced by _batch_page(), and _batch_start().

_batch_shutdown ( )

Shutdown function: Stores the current batch data for the next request.

See Also
_batch_page()
drupal_register_shutdown_function()

Definition at line 532 of file batch.inc.

References batch_get(), and db_update().

_batch_start ( )

Initializes the batch processing.

JavaScript-enabled clients are identified by the 'has_js' cookie set in drupal.js. If no JavaScript-enabled page has been visited during the current user's browser session, the non-JavaScript version is returned.

Definition at line 103 of file batch.inc.

References _batch_progress_page_js(), and _batch_progress_page_nojs().

Referenced by _batch_page().

batch_load ( $id )

Loads a batch from the database.

Parameters
$id The ID of the batch to load. When a progressive batch is being processed, the relevant ID is found in $_REQUEST['id'].
Returns
An array representing the batch, or FALSE if no batch was found.

Definition at line 27 of file batch.inc.

References db_query(), and drupal_get_token().

Referenced by _batch_page(), and _system_batch_theme().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/batch.queue.inc File Reference

  • includes
Classes
batch.queue.inc File Reference

Go to the source code of this file.

Classes

class | BatchQueue
class | BatchMemoryQueue

Detailed Description

Queue handlers used by the Batch API.

These implementations:

  • Ensure FIFO ordering.
  • Allow an item to be repeatedly claimed until it is actually deleted (no notion of lease time or 'expire' date), to allow multipass operations.

Definition in file batch.queue.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/bootstrap.inc File Reference

  • includes
Classes | Functions | Variables
bootstrap.inc File Reference

Go to the source code of this file.

Classes

class | DrupalCacheArray
class | SchemaCache

Functions

timer_start ($name)
timer_read ($name)
timer_stop ($name)
conf_path ($require_settings=TRUE, $reset=FALSE)
drupal_override_server_variables ($variables=array())
drupal_environment_initialize ()
drupal_valid_http_host ($host)
drupal_settings_initialize ()
drupal_get_filename ($type, $name, $filename=NULL)
variable_initialize ($conf=array())
variable_get ($name, $default=NULL)
variable_set ($name, $value)
variable_del ($name)
drupal_page_get_cache ($check_only=FALSE)
drupal_page_is_cacheable ($allow_caching=NULL)
bootstrap_invoke_all ($hook)
drupal_load ($type, $name)
drupal_add_http_header ($name, $value, $append=FALSE)
drupal_get_http_header ($name=NULL)
_drupal_set_preferred_header_name ($name=NULL)
drupal_send_headers ($default_headers=array(), $only_default=FALSE)
drupal_page_header ()
drupal_serve_page_from_cache (stdClass $cache)
bootstrap_hooks ()
drupal_unpack ($obj, $field= 'data')
drupal_autoload_interface ($interface)
drupal_autoload_class ($class)
_registry_check_code ($type, $name=NULL)
registry_rebuild ()
registry_update ()
& drupal_static ($name, $default_value=NULL, $reset=FALSE)
drupal_static_reset ($name=NULL)
drupal_is_cli ()
drupal_placeholder ($text)
& drupal_register_shutdown_function ($callback=NULL)
_drupal_shutdown_function ()
drupal_check_memory_limit ($required, $memory_limit=NULL)
into your string, and t() will

Translates a string to the current language or to a given language.

The t() function serves two purposes. First, at run-time it translates user-visible text into the appropriate language. Second, various mechanisms that figure out what text needs to be translated work off t() – the text inside t() calls is added to the database of strings to be translated. These strings are expected to be in English, so the first argument should always be in English. To enable a fully-translatable site, it is important that all human-readable text that will be displayed on the site or sent to a user is passed through the t() function, or a related function. See the Localization API pages for more information, including recommendations on how to break up or not break up strings for translation.

Translating Variables

You should never use t() to translate variables, such as calling

t($text);

, unless the text that the variable holds has been passed through t() elsewhere (e.g., $text is one of several translated literal strings in an array). It is especially important never to call

t($user_text);

, where $user_text is some text that a user entered - doing that can lead to cross-site scripting and other security problems. However, you can use variable substitution in your string, to put variable text such as user names or link URLs into translated text. Variable substitution looks like this:

* $text = t("@name's blog", array('@name' => format_username($account)));
*

Basically, you can put variables like substitute their sanitized values at translation time. (See the Localization API pages referenced above and the documentation of format_string() for details about how to define variables in your string.) Translators can then rearrange the string as necessary for the language (e.g., in Spanish, it might be "blog de @name").

Use During Installation Phase

During the Drupal installation phase, some resources used by t() wil not be available to code that needs localization. See st() and get_t() for alternatives.

Parameters
$string | A string containing the English string to translate.
$args | An associative array of replacements to make after translation. Based on the first character of the key, the value is escaped and/or themed. See format_string() for details.
$options An associative array of additional options, with the following elements:
  • 'langcode' (defaults to the current language): The language code to translate to a language other than what is used to display the page.
  • 'context' (defaults to the empty context): The context the source string belongs to.
Returns
The translated string.
See Also
st()
get_t()
format_string()
t ($string, array $args=array(), array $options=array())
format_string ($string, array $args=array())
check_plain ($text)
drupal_validate_utf8 ($text)
request_uri ()
watchdog_exception ($type, Exception $exception, $message=NULL, $variables=array(), $severity=WATCHDOG_ERROR, $link=NULL)
watchdog ($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
drupal_set_message ($message=NULL, $type= 'status', $repeat=TRUE)
drupal_get_messages ($type=NULL, $clear_queue=TRUE)
drupal_get_title ()
drupal_set_title ($title=NULL, $output=CHECK_PLAIN)
drupal_is_denied ($ip)
drupal_block_denied ($ip)
drupal_random_key ($byte_count=32)
drupal_base64_encode ($string)
drupal_random_bytes ($count)
drupal_hmac_base64 ($data, $key)
drupal_hash_base64 ($data)
drupal_array_merge_deep ()
drupal_array_merge_deep_array ($arrays)
drupal_anonymous_user ()
drupal_bootstrap ($phase=NULL, $new_phase=TRUE)
drupal_get_user_timezone ()
drupal_get_hash_salt ()
_drupal_error_handler ($error_level, $message, $filename, $line, $context)
_drupal_exception_handler ($exception)
_drupal_bootstrap_configuration ()
_drupal_bootstrap_page_cache ()
_drupal_bootstrap_database ()
_drupal_bootstrap_variables ()
_drupal_bootstrap_page_header ()
drupal_get_bootstrap_phase ()
drupal_valid_test_ua ()
drupal_generate_test_ua ($prefix)
drupal_maintenance_theme ()
drupal_fast_404 ()
drupal_installation_attempted ()
get_t ()
drupal_language_initialize ()
drupal_language_types ()
drupal_multilingual ()
language_types ()
language_list ($field= 'language')
language_default ($property=NULL)
request_path ()
arg ($index=NULL, $path=NULL)
ip_address ()
drupal_get_schema ($table=NULL, $rebuild=FALSE)
drupal_get_complete_schema ($rebuild=FALSE)

Variables

const | VERSION '7.26'
const | DRUPAL_CORE_COMPATIBILITY '7.x'
const | DRUPAL_MINIMUM_PHP '5.2.4'
const | DRUPAL_MINIMUM_PHP_MEMORY_LIMIT '32M'
const | ERROR_REPORTING_HIDE 0
const | ERROR_REPORTING_DISPLAY_SOME 1
const | ERROR_REPORTING_DISPLAY_ALL 2
const | CACHE_PERMANENT 0
const | CACHE_TEMPORARY -1
const | WATCHDOG_EMERGENCY 0
const | WATCHDOG_ALERT 1
const | WATCHDOG_CRITICAL 2
const | WATCHDOG_ERROR 3
const | WATCHDOG_WARNING 4
const | WATCHDOG_NOTICE 5
const | WATCHDOG_INFO 6
const | WATCHDOG_DEBUG 7
const | DRUPAL_BOOTSTRAP_CONFIGURATION 0
const | DRUPAL_BOOTSTRAP_PAGE_CACHE 1
const | DRUPAL_BOOTSTRAP_DATABASE 2
const | DRUPAL_BOOTSTRAP_VARIABLES 3
const | DRUPAL_BOOTSTRAP_SESSION 4
const | DRUPAL_BOOTSTRAP_PAGE_HEADER 5
const | DRUPAL_BOOTSTRAP_LANGUAGE 6
const | DRUPAL_BOOTSTRAP_FULL 7
const | DRUPAL_ANONYMOUS_RID 1
const | DRUPAL_AUTHENTICATED_RID 2
const | DRUPAL_KILOBYTE 1024
const | LANGUAGE_NONE 'und'
const | LANGUAGE_TYPE_CONTENT 'language_content'
const | LANGUAGE_TYPE_INTERFACE 'language'
const | LANGUAGE_TYPE_URL 'language_url'
const | LANGUAGE_LTR 0
const | LANGUAGE_RTL 1
const | REQUEST_TIME (int) $_SERVER['REQUEST_TIME']
const | CHECK_PLAIN 0
const | PASS_THROUGH -1
const | REGISTRY_RESET_LOOKUP_CACHE 1
const | REGISTRY_WRITE_LOOKUP_CACHE 2
const | DRUPAL_PHP_FUNCTION_PATTERN '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'

Detailed Description

Functions that need to be loaded on every Drupal request.

Definition in file bootstrap.inc.

Function Documentation

_drupal_bootstrap_configuration ( )

Sets up the script environment and loads settings.php.

Definition at line 2347 of file bootstrap.inc.

References drupal_environment_initialize(), drupal_settings_initialize(), and timer_start().

Referenced by drupal_bootstrap().

_drupal_bootstrap_database ( )

Initializes the database system and registers autoload functions.

Definition at line 2418 of file bootstrap.inc.

References $value, drupal_installation_attempted(), DRUPAL_ROOT, drupal_valid_test_ua(), and install_goto().

Referenced by drupal_bootstrap().

_drupal_bootstrap_page_cache ( )

Attempts to serve a page from the cache.

Definition at line 2362 of file bootstrap.inc.

References bootstrap_invoke_all(), drupal_anonymous_user(), drupal_block_denied(), drupal_bootstrap(), DRUPAL_BOOTSTRAP_VARIABLES, drupal_get_user_timezone(), drupal_page_get_cache(), DRUPAL_ROOT, drupal_serve_page_from_cache(), drupal_set_title(), ip_address(), PASS_THROUGH, and variable_get().

Referenced by drupal_bootstrap().

_drupal_bootstrap_page_header ( )

Invokes hook_boot(), initializes locking system, and sends HTTP headers.

Definition at line 2487 of file bootstrap.inc.

References bootstrap_invoke_all(), drupal_is_cli(), and drupal_page_header().

Referenced by drupal_bootstrap().

_drupal_bootstrap_variables ( )

Loads system variables and all enabled bootstrap modules.

Definition at line 2470 of file bootstrap.inc.

References $conf, DRUPAL_ROOT, lock_initialize(), module_load_all(), variable_get(), and variable_initialize().

Referenced by drupal_bootstrap().

_drupal_error_handler | ( | $error_level,
 |  | $message,
 |  | $filename,
 |  | $line,
 |  | $context
 | ) |

Provides custom PHP error handling.

Parameters
$error_level | The level of the error raised.
$message | The error message.
$filename | The filename that the error was raised in.
$line | The line number the error was raised at.
$context | An array that points to the active symbol table at the point the error occurred.

Definition at line 2311 of file bootstrap.inc.

References _drupal_error_handler_real(), and DRUPAL_ROOT.

_drupal_exception_handler ( $exception )

Provides custom PHP exception handling.

Uncaught exceptions are those not enclosed in a try/catch block. They are always fatal: the execution of the script will stop as soon as the exception handler exits.

Parameters
$exception The exception object that was thrown.

Definition at line 2326 of file bootstrap.inc.

References _drupal_decode_exception(), _drupal_log_error(), _drupal_render_exception_safe(), DRUPAL_ROOT, error_displayable(), and print.

_drupal_set_preferred_header_name ( $name = NULL )

Sets the preferred name for the HTTP header.

Header names are case-insensitive, but for maximum compatibility they should follow "common form" (see RFC 2617, section 4.2).

Definition at line 1178 of file bootstrap.inc.

References $name.

Referenced by drupal_add_http_header(), drupal_page_set_cache(), and drupal_send_headers().

arg | ( | $index = NULL,
 |  | $path = NULL
 | ) |

Returns a component of the current Drupal path.

When viewing a page at the path "admin/structure/types", for example, arg(0) returns "admin", arg(1) returns "structure", and arg(2) returns "types".

Avoid use of this function where possible, as resulting code is hard to read. In menu callback functions, attempt to use named arguments. See the explanation in menu.inc for how to construct callbacks that take arguments. When attempting to use this function to load an element from the current path, e.g. loading the node on a node page, use menu_get_object() instead.

Parameters
$index | The index of the component, where each component is separated by a '/' (forward-slash), and where the first component has an index of 0 (zero).
$path | A path to break into components. Defaults to the path of the current page.
Returns
The component specified by $index, or NULL if the specified component was not found. If called without arguments, it returns an array containing all the components of the current path.

Definition at line 2852 of file bootstrap.inc.

References drupal_static().

Referenced by _trigger_normalize_user_context(), aggregator_form_category_submit(), aggregator_form_feed_submit(), aggregator_page_category(), aggregator_page_last(), aggregator_page_rss(), aggregator_page_source(), blog_node_view(), dblog_init(), filter_tips_long(), forum_form_node_form_alter(), menu_get_active_help(), menu_get_item(), node_block_list_alter(), openid_user_add_submit(), profile_block_view(), profile_field_form(), statistics_exit(), statistics_node_tracker(), statistics_user_tracker(), template_preprocess_html(), template_preprocess_page(), template_preprocess_profile_wrapper(), update_init(), and user_block_view().

bootstrap_hooks ( )

Defines the critical hooks that force modules to always be loaded.

Definition at line 1375 of file bootstrap.inc.

Referenced by _system_update_bootstrap_status().

bootstrap_invoke_all ( $hook )

Invokes a bootstrap hook in all bootstrap modules that implement it.

Parameters
$hook The name of the bootstrap hook to invoke.
See Also
bootstrap_hooks()

Definition at line 1066 of file bootstrap.inc.

References $module, drupal_load(), module_invoke(), and module_list().

Referenced by _drupal_bootstrap_page_cache(), _drupal_bootstrap_page_header(), and drupal_language_initialize().

conf_path | ( | $require_settings = TRUE,
 |  | $reset = FALSE
 | ) |

Returns the appropriate configuration directory.

Returns the configuration path based on the site's hostname, port, and pathname. Uses find_conf_path() to find the current configuration directory. See default.settings.php for examples on how the URL is converted to a directory.

Parameters
bool | $require_settings | Only configuration directories with an existing settings.php file will be recognized. Defaults to TRUE. During initial installation, this is set to FALSE so that Drupal can detect a matching directory, then create a new settings.php file in it.
bool | $reset | Force a full search for matching directories even if one had been found previously. Defaults to FALSE.
Returns
The path of the matching directory.
See Also
default.settings.php

Definition at line 541 of file bootstrap.inc.

References $conf, $dir, DRUPAL_ROOT, and drupal_static().

Referenced by drupal_rewrite_settings(), drupal_settings_initialize(), drupal_system_listing(), DrupalWebTestCase\drupalGetTestFiles(), file_directory_temp(), DrupalPublicStreamWrapper\getDirectoryPath(), DatabaseTasks_sqlite\getFormOptions(), install_check_requirements(), install_configure_form(), install_settings_form(), install_verify_settings(), DrupalWebTestCase\prepareEnvironment(), DrupalTestCase\run(), DrupalUnitTestCase\setUp(), system_file_system_settings(), system_requirements(), system_update_7061(), update_fix_d7_requirements(), update_manager_install_form_submit(), update_manager_local_transfers_allowed(), update_manager_update_ready_form_submit(), and update_prepare_d7_bootstrap().

drupal_add_http_header | ( | $name,
 |  | $value,
 |  | $append = FALSE
 | ) |

Sets an HTTP response header for the current page.

Note: When sending a Content-Type header, always include a 'charset' type, too. This is necessary to avoid security bugs (e.g. UTF-7 XSS).

Parameters
$name | The HTTP header name, or the special 'Status' header name.
$value | The HTTP header value; if equal to FALSE, the specified header is unset. If $name is 'Status', this is expected to be a status code followed by a reason phrase, e.g. "404 Not Found".
$append | Whether to append the value to an existing header or to replace it.

Definition at line 1129 of file bootstrap.inc.

References $name, $value, _drupal_set_preferred_header_name(), drupal_send_headers(), and drupal_static().

Referenced by _drupal_log_error(), ajax_deliver(), authorize_access_denied_page(), drupal_deliver_html_page(), drupal_fast_404(), drupal_json_output(), drupal_serve_page_from_cache(), file_transfer(), image_style_deliver(), node_feed(), theme_aggregator_page_opml(), theme_aggregator_page_rss(), theme_install_page(), theme_update_page(), update_access_denied_page(), and xmlrpc_server_output().

drupal_anonymous_user ( )

Generates a default anonymous $user object.

Returns
Object - the user object.

Definition at line 2152 of file bootstrap.inc.

References DRUPAL_ANONYMOUS_RID, ip_address(), and variable_get().

Referenced by _drupal_bootstrap_page_cache(), _drupal_session_destroy(), _drupal_session_read(), _user_cancel(), comment_form_node_type_form_alter(), drupal_cron_run(), drupal_session_initialize(), DrupalWebTestCase\drupalCreateUser(), user_external_login_register(), and user_register_form().

drupal_array_merge_deep ( )

Merges multiple arrays, recursively, and returns the merged array.

This function is similar to PHP's array_merge_recursive() function, but it handles non-array values differently. When merging values that are not both arrays, the latter value replaces the former rather than merging with it.

Example:

* $link_options_1 = array('fragment' => 'x', 'attributes' => array('title' => t('X'), 'class' => array('a', 'b')));
* $link_options_2 = array('fragment' => 'y', 'attributes' => array('title' => t('Y'), 'class' => array('c', 'd')));
*
* // This results in array('fragment' => array('x', 'y'), 'attributes' => array('title' => array(t('X'), t('Y')), 'class' => array('a', 'b', 'c', 'd'))).
* $incorrect = array_merge_recursive($link_options_1, $link_options_2);
*
* // This results in array('fragment' => 'y', 'attributes' => array('title' => t('Y'), 'class' => array('a', 'b', 'c', 'd'))).
* $correct = drupal_array_merge_deep($link_options_1, $link_options_2);
*
Parameters
... Arrays to merge.
Returns
The merged array.
See Also
drupal_array_merge_deep_array()

Definition at line 2100 of file bootstrap.inc.

References drupal_array_merge_deep_array().

Referenced by DrupalWebTestCase\drupalPostAJAX().

drupal_array_merge_deep_array ( $arrays )

Merges multiple arrays, recursively, and returns the merged array.

This function is equivalent to drupal_array_merge_deep(), except the input arrays are passed as a single array parameter rather than a variable parameter list.

The following are equivalent:

  • drupal_array_merge_deep($a, $b);
  • drupal_array_merge_deep_array(array($a, $b));

The following are also equivalent:

  • call_user_func_array('drupal_array_merge_deep', $arrays_to_merge);
  • drupal_array_merge_deep_array($arrays_to_merge);
See Also
drupal_array_merge_deep()

Definition at line 2122 of file bootstrap.inc.

References $value.

Referenced by drupal_array_merge_deep(), and drupal_get_js().

drupal_base64_encode ( $string )

Returns a URL-safe, base64 encoded version of the supplied string.

Parameters
$string The string to convert to base64.
Returns
string

Definition at line 1957 of file bootstrap.inc.

Referenced by drupal_random_key().

drupal_block_denied ( $ip )

Handles denied users.

Parameters
$ip IP address to check. Prints a message and exits if access is denied.

Definition at line 1927 of file bootstrap.inc.

References check_plain(), drupal_is_denied(), ip_address(), and print.

Referenced by _drupal_bootstrap_page_cache().

drupal_bootstrap | ( | $phase = NULL,
 |  | $new_phase = TRUE
 | ) |

Ensures Drupal is bootstrapped to the specified phase.

In order to bootstrap Drupal from another PHP script, you can use this code:

* define('DRUPAL_ROOT', '/path/to/drupal');
* require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
* drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
*
Parameters
$phase A constant telling which phase to bootstrap to. When you bootstrap to a particular phase, all earlier phases are run automatically. Possible values:
  • DRUPAL_BOOTSTRAP_CONFIGURATION: Initializes configuration.
  • DRUPAL_BOOTSTRAP_PAGE_CACHE: Tries to serve a cached page.
  • DRUPAL_BOOTSTRAP_DATABASE: Initializes the database layer.
  • DRUPAL_BOOTSTRAP_VARIABLES: Initializes the variable system.
  • DRUPAL_BOOTSTRAP_SESSION: Initializes session handling.
  • DRUPAL_BOOTSTRAP_PAGE_HEADER: Sets up the page header.
  • DRUPAL_BOOTSTRAP_LANGUAGE: Finds out the language of the page.
  • DRUPAL_BOOTSTRAP_FULL: Fully loads Drupal. Validates and fixes input data.
$new_phase A boolean, set to FALSE if calling drupal_bootstrap from inside a function called from drupal_bootstrap (recursion).
Returns
The most recently completed phase.

Definition at line 2192 of file bootstrap.inc.

References _drupal_bootstrap_configuration(), _drupal_bootstrap_database(), _drupal_bootstrap_full(), _drupal_bootstrap_page_cache(), _drupal_bootstrap_page_header(), _drupal_bootstrap_variables(), DRUPAL_BOOTSTRAP_CONFIGURATION, DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_FULL, DRUPAL_BOOTSTRAP_LANGUAGE, DRUPAL_BOOTSTRAP_PAGE_CACHE, DRUPAL_BOOTSTRAP_PAGE_HEADER, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_VARIABLES, drupal_language_initialize(), DRUPAL_ROOT, drupal_session_initialize(), and variable_get().

Referenced by _drupal_bootstrap_page_cache(), drupal_get_bootstrap_phase(), drupal_theme_initialize(), install_begin_request(), install_bootstrap_full(), module_hook_info(), statistics_exit(), and update_prepare_d7_bootstrap().

drupal_environment_initialize ( )

Initializes the PHP environment.

Definition at line 639 of file bootstrap.inc.

References drupal_valid_http_host(), and request_path().

Referenced by _drupal_bootstrap_configuration().

drupal_fast_404 ( )

Returns a simple 404 Not Found page.

If fast 404 pages are enabled, and this is a matching page then print a simple 404 page and exit.

This function is called from drupal_deliver_html_page() at the time when a a normal 404 page is generated, but it can also optionally be called directly from settings.php to prevent a Drupal bootstrap on these pages. See documentation in settings.php for the benefits and drawbacks of using this.

Paths to dynamically-generated content, such as image styles, should also be accounted for in this function.

Definition at line 2588 of file bootstrap.inc.

References check_plain(), drupal_add_http_header(), print, request_uri(), and variable_get().

Referenced by drupal_deliver_html_page().

drupal_generate_test_ua ( $prefix )

Generates a user agent string with a HMAC and timestamp for simpletest.

Definition at line 2546 of file bootstrap.inc.

References drupal_get_hash_salt(), and drupal_hmac_base64().

Referenced by DrupalWebTestCase\curlInitialize(), and drupal_http_request().

drupal_get_bootstrap_phase ( )

Returns the current bootstrap phase for this Drupal process.

The current phase is the one most recently completed by drupal_bootstrap().

See Also
drupal_bootstrap()

Definition at line 2503 of file bootstrap.inc.

References drupal_bootstrap().

Referenced by _drupal_log_error(), ajax_footer(), drupal_exit(), and drupal_get_complete_schema().

drupal_get_filename | ( | $type,
 |  | $name,
 |  | $filename = NULL
 | ) |

Returns and optionally sets the filename for a system resource.

The filename, whether provided, cached, or retrieved from the database, is only returned if the file exists.

This function plays a key role in allowing Drupal's resources (modules and themes) to be located in different places depending on a site's configuration. For example, a module 'foo' may legally be located in any of these three places:

modules/foo/foo.module sites/all/modules/foo/foo.module sites/example.com/modules/foo/foo.module

Calling drupal_get_filename('module', 'foo') will give you one of the above, depending on where the module is located.

Parameters
$type | The type of the item (theme, theme_engine, module, profile).
$name | The name of the item for which the filename is requested.
$filename | The filename of the item if it is to be set explicitly rather than by consulting the database.
Returns
The filename of the requested item or NULL if the item is not found.

Definition at line 820 of file bootstrap.inc.

References $dir, $name, db_query(), DRUPAL_PHP_FUNCTION_PATTERN, DRUPAL_ROOT, and drupal_system_listing().

Referenced by drupal_get_path(), drupal_load(), module_list(), DrupalUnitTestCase\setUp(), simpletest_test_get_all(), and system_list().

drupal_get_hash_salt ( )

Gets a salt useful for hardening against SQL injection.

Returns
A salt based on information in settings.php, not in the database.

Definition at line 2289 of file bootstrap.inc.

References $databases, and $drupal_hash_salt.

Referenced by _update_manager_unique_identifier(), drupal_generate_test_ua(), drupal_get_token(), drupal_valid_test_ua(), image_style_path_token(), and user_pass_rehash().

drupal_get_http_header ( $name = NULL )

Gets the HTTP response headers for the current page.

Parameters
$name An HTTP header name. If omitted, all headers are returned as name/value pairs. If an array value is FALSE, the header has been unset.
Returns
A string containing the header value, or FALSE if the header has been set, or NULL if the header has not been set.

Definition at line 1161 of file bootstrap.inc.

References $name, and drupal_static().

Referenced by ajax_deliver(), drupal_deliver_html_page(), drupal_page_set_cache(), drupal_send_headers(), and drupal_serve_page_from_cache().

drupal_get_messages | ( | $type = NULL,
 |  | $clear_queue = TRUE
 | ) |

Returns all messages that have been set with drupal_set_message().

Parameters
string $type (optional) Limit the messages returned by type. Defaults to NULL, meaning all types. These values are supported:
  • NULL
  • 'status'
  • 'warning'
  • 'error'
bool $clear_queue (optional) If this is TRUE, the queue will be cleared of messages of the type specified in the $type parameter. Otherwise the queue will be left intact. Defaults to TRUE.
Returns
array A multidimensional array with keys corresponding to the set message types. The indexed array values of each contain the set messages for that type. The messages returned are limited to the type specified in the $type parameter. If there are no messages of the specified type, an empty array is returned.
See Also
drupal_set_message()
theme_status_messages()

Definition at line 1820 of file bootstrap.inc.

References $messages, and drupal_set_message().

Referenced by openid_authentication(), DrupalTestCase\run(), and theme_status_messages().

drupal_get_title ( )

Gets the title of the current page.

The title is displayed on the page and in the title bar.

Returns
The current page's title.

Definition at line 1848 of file bootstrap.inc.

References $title, check_plain(), drupal_set_title(), and menu_get_active_title().

Referenced by drupal_page_set_cache(), shortcut_preprocess_page(), statistics_exit(), template_preprocess_html(), template_preprocess_maintenance_page(), template_preprocess_overlay(), and template_process_page().

drupal_get_user_timezone ( )

Returns the time zone of the current user.

Definition at line 2271 of file bootstrap.inc.

References variable_get().

Referenced by _drupal_bootstrap_page_cache(), drupal_session_initialize(), and drupal_session_regenerate().

drupal_hash_base64 ( $data )

Calculates a base-64 encoded, URL-safe sha-256 hash.

Parameters
$data String to be hashed.
Returns
A base-64 encoded sha-256 hash, with + replaced with -, / with _ and any = padding characters removed.

Definition at line 2067 of file bootstrap.inc.

Referenced by _book_admin_table(), _locale_rebuild_js(), actions_actions_map(), actions_function_lookup(), drupal_build_css_cache(), drupal_build_js_cache(), image_style_deliver(), system_actions_configure(), trigger_assign_form(), and update_fix_d7_requirements().

drupal_hmac_base64 | ( | $data,
 |  | $key
 | ) |

Calculates a base-64 encoded, URL-safe sha-256 hmac.

Parameters
string | $data | String to be validated with the hmac.
string | $key | A secret string key.
Returns
string A base-64 encoded sha-256 hmac, with + replaced with -, / with _ and any = padding characters removed.

Definition at line 2047 of file bootstrap.inc.

Referenced by _update_process_fetch_task(), drupal_generate_test_ua(), drupal_get_token(), drupal_valid_test_ua(), DrupalWebTestCase\drupalGetToken(), image_style_path_token(), and user_pass_rehash().

drupal_installation_attempted ( )

Returns TRUE if a Drupal installation is currently being attempted.

Definition at line 2605 of file bootstrap.inc.

References MAINTENANCE_MODE.

Referenced by _drupal_bootstrap_database(), drupal_install_profile_distribution_name(), drupal_redirect_form(), get_t(), registry_update(), and shortcut_install().

drupal_is_denied ( $ip )

Checks to see if an IP address has been blocked.

Blocked IP addresses are stored in the database by default. However for performance reasons we allow an override in settings.php. This allows us to avoid querying the database at this critical stage of the bootstrap if an administrative interface for IP address blocking is not required.

Parameters
$ip IP address to check.
Returns
bool TRUE if access is denied, FALSE if access is allowed.

Definition at line 1900 of file bootstrap.inc.

References db_query(), and variable_get().

Referenced by drupal_block_denied().

drupal_language_initialize ( )

Initializes all the defined language types.

Definition at line 2648 of file bootstrap.inc.

References bootstrap_invoke_all(), drupal_multilingual(), DRUPAL_ROOT, language_default(), language_initialize(), and language_types().

Referenced by drupal_bootstrap(), install_begin_request(), and locale_uninstall().

drupal_language_types ( )

Returns a list of the built-in language types.

Returns
An array of key-values pairs where the key is the language type and the value is its configurability.

Definition at line 2677 of file bootstrap.inc.

References LANGUAGE_TYPE_CONTENT, LANGUAGE_TYPE_INTERFACE, and LANGUAGE_TYPE_URL.

Referenced by language_types(), language_types_configurable(), and language_types_disable().

drupal_load | ( | $type,
 |  | $name
 | ) |

Includes a file with the provided type and name.

This prevents including a theme, engine, module, etc., more than once.

Parameters
$type | The type of item to load (i.e. theme, theme_engine, module).
$name | The name of the item to load.
Returns
TRUE if the item is loaded or has already been loaded.

Definition at line 1093 of file bootstrap.inc.

References $name, drupal_get_filename(), and DRUPAL_ROOT.

Referenced by _drupal_maintenance_theme(), bootstrap_invoke_all(), field_sql_storage_schema(), forum_uninstall(), hook_boot(), install_begin_request(), module_enable(), module_load_all(), shortcut_uninstall(), and simpletest_uninstall().

drupal_maintenance_theme ( )

Enables use of the theme system without requiring database access.

Loads and initializes the theme system for site installs, updates and when the site is in maintenance mode. This also applies when the database fails.

See Also
_drupal_maintenance_theme()

Definition at line 2569 of file bootstrap.inc.

References _drupal_maintenance_theme(), and DRUPAL_ROOT.

Referenced by _drupal_log_error(), drupal_deliver_html_page(), and install_begin_request().

drupal_multilingual ( )

Returns TRUE if there is more than one language enabled.

Returns
TRUE if more than one language is enabled.

Definition at line 2691 of file bootstrap.inc.

References variable_get().

Referenced by drupal_language_initialize(), drupal_render_cid_parts(), language_list(), locale_block_view(), locale_form_alter(), locale_url_outbound_alter(), and translation_node_view().

drupal_override_server_variables ( $variables = array() )

Sets appropriate server variables needed for command line scripts to work.

This function can be called by command line scripts before bootstrapping Drupal, to ensure that the page loads with the desired server parameters. This is because many parts of Drupal assume that they are running in a web browser and therefore use information from the global PHP $_SERVER variable that does not get set when Drupal is run from the command line.

In many cases, the default way in which this function populates the $_SERVER variable is sufficient, and it can therefore be called without passing in any input. However, command line scripts running on a multisite installation (or on any installation that has settings.php stored somewhere other than the sites/default folder) need to pass in the URL of the site to allow Drupal to detect the correct location of the settings.php file. Passing in the 'url' parameter is also required for functions like request_uri() to return the expected values.

Most other parameters do not need to be passed in, but may be necessary in some cases; for example, if Drupal's ip_address() function needs to return anything but the standard localhost value ('127.0.0.1'), the command line script should pass in the desired value via the 'REMOTE_ADDR' key.

Parameters
$variables (optional) An associative array of variables within $_SERVER that should be replaced. If the special element 'url' is provided in this array, it will be used to populate some of the server defaults; it should be set to the URL of the current page request, excluding any $_GET request but including the script name (e.g., http://www.example.com/mysite/index.php).
See Also
conf_path()
request_uri()
ip_address()

Definition at line 608 of file bootstrap.inc.

References $url.

Referenced by install_begin_request().

drupal_page_get_cache ( $check_only = FALSE )

Retrieves the current page from the cache.

Note: we do not serve cached pages to authenticated users, or to anonymous users when $_SESSION is non-empty. $_SESSION may contain status messages from a form submission, the contents of a shopping cart, or other user- specific content that should not be cached and displayed to other users.

Parameters
$check_only (optional) Set to TRUE to only return whether a previous call found a cache entry.
Returns
The cache object, if the page was found in the cache, NULL otherwise.

Definition at line 1022 of file bootstrap.inc.

References cache_get(), drupal_page_is_cacheable(), and request_uri().

Referenced by _drupal_bootstrap_page_cache().

drupal_page_header ( )

Sets HTTP headers in preparation for a page response.

Authenticated users are always given a 'no-cache' header, and will fetch a fresh page on every request. This prevents authenticated users from seeing locally cached pages.

Also give each page a unique ETag. This will force clients to include both an If-Modified-Since header and an If-None-Match header when doing conditional requests for the page (required by RFC 2616, section 13.3.4), making the validation more robust. This is a workaround for a bug in Mozilla Firefox that is triggered when Drupal's caching is enabled and the user accesses Drupal via an HTTP proxy (see https://bugzilla.mozilla.org/show_bug.cgi?id=269303): When an authenticated user requests a page, and then logs out and requests the same page again, Firefox may send a conditional request based on the page that was cached locally when the user was logged in. If this page did not have an ETag header, the request only contains an If-Modified-Since header. The date will be recent, because with authenticated users the Last-Modified header always refers to the time of the request. If the user accesses Drupal via a proxy server, and the proxy already has a cached copy of the anonymous page with an older Last-Modified date, the proxy may respond with 304 Not Modified, making the client think that the anonymous and authenticated pageviews are identical.

See Also
drupal_page_set_cache()

Definition at line 1253 of file bootstrap.inc.

References drupal_send_headers(), drupal_static(), and REQUEST_TIME.

Referenced by _drupal_bootstrap_page_header(), and install_display_output().

drupal_page_is_cacheable ( $allow_caching = NULL )

Determines the cacheability of the current page.

Parameters
$allow_caching Set to FALSE if you want to prevent this page to get cached.
Returns
TRUE if the current page can be cached, FALSE otherwise.

Definition at line 1048 of file bootstrap.inc.

References drupal_is_cli(), and drupal_static().

Referenced by drupal_page_get_cache(), drupal_page_set_cache(), drupal_session_initialize(), and drupal_set_message().

drupal_random_bytes ( $count )

Returns a string of highly randomized bytes (over the full 8-bit range).

This function is better than simply calling mt_rand() or any other built-in PHP function because it can return a long string of bytes (compared to < 4 bytes normally from mt_rand()) and uses the best available pseudo-random source.

Parameters
$count The number of characters (bytes) to return in the string.

Definition at line 1974 of file bootstrap.inc.

References $output.

Referenced by _drupal_bootstrap_full(), _openid_dh_rand(), _openid_get_bytes(), _password_generate_salt(), drupal_random_key(), update_fix_d7_requirements(), and user_password().

drupal_random_key ( $byte_count = 32 )

Returns a URL-safe, base64 encoded string of highly randomized bytes (over the full 8-bit range).

Parameters
$byte_count The number of random bytes to fetch and base64 encode.
Returns
string The base64 encoded result will have a length of up to 4 * $byte_count.

Definition at line 1945 of file bootstrap.inc.

References drupal_base64_encode(), and drupal_random_bytes().

Referenced by drupal_get_private_key(), drupal_prepare_form(), drupal_rebuild_form(), drupal_session_initialize(), drupal_session_regenerate(), install_settings_form_submit(), system_install(), system_update_7001(), and user_pass_reset().

drupal_send_headers | ( | $default_headers = array(),
 |  | $only_default = FALSE
 | ) |

Sends the HTTP response headers that were previously set, adding defaults.

Headers are set in drupal_add_http_header(). Default headers are not set if they have been replaced or unset using drupal_add_http_header().

Parameters
array | $default_headers | (optional) An array of headers as name/value pairs.
bool | $only_default | (optional) If TRUE and headers have already been sent, send only the specified headers.

Definition at line 1199 of file bootstrap.inc.

References $name, $value, _drupal_set_preferred_header_name(), drupal_get_http_header(), and drupal_static().

Referenced by drupal_add_http_header(), drupal_page_header(), drupal_serve_page_from_cache(), and file_transfer().

drupal_serve_page_from_cache ( stdClass $cache )

Sets HTTP headers in preparation for a cached page response.

The headers allow as much as possible in proxies and browsers without any particular knowledge about the pages. Modules can override these headers using drupal_add_http_header().

If the request is conditional (using If-Modified-Since and If-None-Match), and the conditions match those currently in the cache, a 304 Not Modified response is sent.

Definition at line 1280 of file bootstrap.inc.

References $name, $value, drupal_add_http_header(), drupal_get_http_header(), drupal_send_headers(), print, and variable_get().

Referenced by _drupal_bootstrap_page_cache(), and drupal_page_footer().

drupal_set_message | ( | $message = NULL,
 |  | $type = 'status',
 |  | $repeat = TRUE
 | ) |

Sets a message to display to the user.

Messages are stored in a session variable and displayed in page.tpl.php via the $messages theme variable.

Example usage:

* drupal_set_message(t('An error occurred and processing did not complete.'), 'error');
*
Parameters
string | $message | (optional) The translated message to be displayed to the user. For consistency with other messages, it should begin with a capital letter and end with a period.
string $type (optional) The message's type. Defaults to 'status'. These values are supported:
  • 'status'
  • 'warning'
  • 'error'
bool | $repeat | (optional) If this is FALSE and the message is already set, then the message won't be repeated. Defaults to TRUE.
Returns
array|null A multidimensional array with keys corresponding to the set message types. The indexed array values of each contain the set messages for that type. Or, if there are no messages set, the function returns NULL.
See Also
drupal_get_messages()
theme_status_messages()

Definition at line 1777 of file bootstrap.inc.

References drupal_page_is_cacheable().

Referenced by _batch_do(), _batch_page(), _block_rehash(), _drupal_log_error(), _locale_batch_language_finished(), _locale_batch_system_finished(), _locale_import_message(), _locale_import_parse_plural_forms(), _locale_import_po(), _menu_site_is_offline(), _node_access_rebuild_batch_finished(), _node_mass_update_batch_finished(), _openid_invalid_openid_transition(), _simpletest_batch_finished(), _user_cancel(), action_example_basic_action(), action_example_node_sticky_action(), action_example_unblock_user_action(), aggregator_aggregator_fetch(), aggregator_aggregator_remove(), aggregator_categorize_items_submit(), aggregator_form_category_submit(), aggregator_form_feed_submit(), aggregator_form_opml_submit(), aggregator_parse_feed(), aggregator_refresh(), ajax_example_add_more_submit(), ajax_example_dependent_dropdown_degrades_submit(), ajax_example_dynamic_sections_submit(), ajax_example_node_by_author_autocomplete_submit(), ajax_example_unique_autocomplete_submit(), ajax_example_wizard_submit(), authorize_filetransfer_form(), batch_example_batch_1(), batch_example_batch_2(), batch_example_finished(), batch_example_simple_form(), block_add_block_form_submit(), block_admin_configure_submit(), block_admin_display_form_submit(), block_custom_block_delete_submit(), block_update_7004(), blog_page_last(), blog_page_user(), book_admin_edit_submit(), book_export(), book_outline_form_submit(), book_remove_form_submit(), cache_example_form_cache_clearing(), cache_example_form_create_expiring_item(), cache_example_form_expire_files(), color_scheme_form_submit(), color_update_7001(), comment_admin_overview_submit(), comment_approve(), comment_confirm_delete_submit(), comment_form_submit(), comment_multiple_delete_confirm(), comment_multiple_delete_confirm_submit(), comment_reply(), contact_category_delete_form_submit(), contact_category_edit_form_submit(), contact_personal_form(), contact_personal_form_submit(), contact_site_form(), contact_site_form_submit(), contextual_links_example_node_action_form_submit(), contextual_links_example_object_edit_form_submit(), cron_example_cron(), cron_example_form_cron_run_submit(), cron_example_queue_report_work(), dashboard_update(), dblog_clear_log_submit(), dbtng_example_advanced_list(), dbtng_example_entry_insert(), dbtng_example_entry_update(), dbtng_example_form_add_submit(), dbtng_example_form_update_submit(), dbtng_example_list(), drupal_check_module(), drupal_get_messages(), drupal_mail(), email_example_mail_send(), entity_example_basic_edit_delete(), SearchQuery\executeFirstPass(), field_permission_example_field_access(), field_ui_display_overview_form(), field_ui_display_overview_form_submit(), field_ui_field_delete_form_submit(), field_ui_field_edit_form_submit(), field_ui_field_overview_form_submit(), field_ui_field_settings_form_submit(), field_ui_inactive_message(), field_ui_widget_type_form_submit(), file_ajax_upload(), file_copy(), file_delete(), file_example_check_directory_submit(), file_example_create_directory_submit(), file_example_delete_directory_submit(), file_example_delete_submit(), file_example_file_check_exists_submit(), file_example_managed_write_submit(), file_example_read_submit(), file_example_show_session_contents_submit(), file_example_unmanaged_php_submit(), file_example_unmanaged_write_submit(), file_move(), file_munge_filename(), file_save_data(), file_save_upload(), file_unmanaged_copy(), file_unmanaged_save_data(), file_validate_image_resolution(), filter_admin_disable_submit(), filter_admin_format_form_submit(), filter_admin_overview_submit(), filter_update_7005(), form_example_element_demo_form_submit(), form_example_states_form_submit(), form_example_tutorial_10_submit(), form_example_tutorial_7_submit(), form_example_tutorial_8_page_two_submit(), form_example_tutorial_9_submit(), form_example_wizard_submit(), form_set_error(), forum_confirm_delete_submit(), forum_form_submit(), hook_comment_delete(), hook_comment_publish(), hook_comment_unpublish(), hook_modules_enabled(), hook_node_type_insert(), hook_user_login(), image_effect_delete_form_submit(), image_effect_form_submit(), image_example_style_form_submit(), image_style_add_form_submit(), image_style_delete_form_submit(), image_style_form(), image_style_form_add_submit(), image_style_form_override_submit(), image_style_form_submit(), image_style_revert_form_submit(), install_configure_form(), install_finished(), locale_date_format_form_submit(), locale_languages_configure_form_submit(), locale_languages_delete_form(), locale_languages_delete_form_submit(), locale_languages_overview_form_submit(), locale_languages_predefined_form_submit(), locale_translate_delete_form_submit(), locale_translate_edit_form(), locale_translate_edit_form_submit(), locale_translate_import_form_submit(), locale_update_7004(), menu_delete_menu_confirm_submit(), menu_edit_item_submit(), menu_edit_item_validate(), menu_edit_menu_submit(), menu_item_delete_form_submit(), menu_node_save(), menu_overview_form_submit(), menu_reset_item_confirm_submit(), node_access_example_node_access(), node_access_example_node_insert(), node_access_example_node_update(), node_access_rebuild(), node_delete_confirm_submit(), node_form_submit(), node_help(), node_mass_update(), node_multiple_delete_confirm_submit(), node_node_type_insert(), node_node_type_update(), node_revision_delete_confirm_submit(), node_revision_revert_confirm_submit(), node_type_delete_confirm_submit(), node_type_form_submit(), openid_authentication(), openid_authentication_page(), openid_user_delete_form_submit(), openid_user_identities(), openid_user_insert(), overlay_user_dismiss_message(), SearchQuery\parseSearchExpression(), path_admin_form_submit(), php_disable(), php_enable(), poll_cancel(), poll_vote(), profile_admin_overview_submit(), profile_field_delete_submit(), profile_field_form_submit(), queue_example_add_remove_form_claim(), queue_example_add_remove_form_clear_queue(), queue_example_add_remove_form_delete(), queue_example_add_remove_form_insert(), queue_example_add_remove_form_run_cron(), search_admin_settings_submit(), search_reindex_confirm_submit(), shortcut_link_add_inline(), shortcut_link_add_submit(), shortcut_link_delete_submit(), shortcut_link_edit_submit(), shortcut_set_add_form_submit(), shortcut_set_customize_submit(), shortcut_set_delete_form_submit(), shortcut_set_edit_form_submit(), shortcut_set_switch_submit(), simpletest_clean_database(), simpletest_clean_environment(), simpletest_clean_temporary_directories(), simpletest_result_form(), simpletest_test_form_submit(), system_action_delete_orphans_post(), system_actions_configure_submit(), system_actions_delete_form_submit(), system_add_date_format_type_form_submit(), system_add_date_formats_form_submit(), system_admin_config_page(), system_clean_url_settings(), system_clear_cache_submit(), system_date_delete_format_form_submit(), system_delete_date_format_type_form_submit(), system_ip_blocking_delete_submit(), system_ip_blocking_form_submit(), system_message_action(), system_modules_submit(), system_modules_uninstall_submit(), system_modules_uninstall_validate(), system_run_cron(), system_run_cron_submit(), system_settings_form(), system_settings_form_submit(), system_theme_default(), system_theme_disable(), system_theme_enable(), system_theme_settings_submit(), system_themes_admin_form_submit(), system_update_7003(), system_update_7013(), system_update_7060(), system_update_7067(), system_user_login(), taxonomy_form_term_submit(), taxonomy_form_vocabulary_submit(), taxonomy_overview_terms_submit(), taxonomy_overview_vocabularies_submit(), taxonomy_term_confirm_delete_submit(), taxonomy_vocabulary_confirm_delete_submit(), taxonomy_vocabulary_confirm_reset_alphabetical_submit(), theme_node_preview(), theming_example_select_form_submit(), theming_example_text_form_submit(), translation_node_prepare(), trigger_assign_form_submit(), trigger_unassign_submit(), update_fetch_data_finished(), update_init(), update_manager_download_batch_finished(), update_manager_install_form_submit(), update_script_selection_form(), user_admin_account_submit(), user_admin_permissions_submit(), user_admin_role_delete_confirm_submit(), user_admin_role_submit(), user_admin_roles_order_submit(), user_cancel(), user_cancel_confirm(), user_cancel_confirm_form_submit(), user_external_login_register(), user_multiple_cancel_confirm(), user_pass_reset(), user_pass_submit(), user_profile_form_submit(), user_register_submit(), user_update_7002(), xmlrpc_example_client_add_submit(), xmlrpc_example_client_multicall_submit(), xmlrpc_example_client_request_methods_submit(), xmlrpc_example_client_subtract_submit(), and xmlrpc_example_info().

drupal_set_title | ( | $title = NULL,
 |  | $output = CHECK_PLAIN
 | ) |

Sets the title of the current page.

The title is displayed on the page and in the title bar.

Parameters
$title | Optional string value to assign to the page title; or if set to NULL (default), leaves the current title unchanged.
$output | Optional flag - normally should be left as CHECK_PLAIN. Only set to PASS_THROUGH if you have already removed any possibly dangerous code from $title using a function like check_plain() or filter_xss(). With this flag the string will be passed through unchanged.
Returns
The updated title of the current page.

Definition at line 1876 of file bootstrap.inc.

References $output, $title, check_plain(), drupal_static(), and PASS_THROUGH.

Referenced by _batch_do(), _batch_progress_page_js(), _batch_progress_page_nojs(), _drupal_bootstrap_page_cache(), _drupal_log_error(), aggregator_page_source(), authorize_access_denied_page(), authorize_run_operation(), block_admin_configure(), blog_page_user(), book_admin_edit(), book_outline(), comment_edit_page(), comment_preview(), confirm_form(), contact_personal_form(), drupal_deliver_html_page(), drupal_get_title(), field_ui_field_edit_form(), field_ui_field_settings_form(), field_ui_widget_type_form(), filter_admin_format_page(), form_example_wizard(), help_page(), image_effect_form(), image_style_form(), install_already_done_error(), install_configure_form(), install_finished(), install_no_profile_error(), install_select_locale(), install_select_profile(), install_settings_form(), install_verify_requirements(), node_add(), node_page_default(), node_page_edit(), node_page_view(), node_preview(), node_revision_overview(), node_show(), openid_user_identities(), path_admin_edit(), poll_results(), poll_votes(), profile_browse(), profile_field_form(), shortcut_link_add(), shortcut_link_edit(), statistics_node_tracker(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), statistics_user_tracker(), taxonomy_term_page(), template_preprocess_forums(), tracker_page(), translation_node_overview(), update_access_denied_page(), update_check_requirements(), update_info_page(), update_results_page(), and update_selection_page().

drupal_settings_initialize ( )

Sets the base URL, cookie domain, and session name from configuration.

Definition at line 709 of file bootstrap.inc.

References $base_url, $conf, $databases, $dir, $drupal_hash_salt, $update_free_access, conf_path(), and DRUPAL_ROOT.

Referenced by _drupal_bootstrap_configuration().

drupal_unpack | ( | $obj,
 |  | $field = 'data'
 | ) |

Unserializes and appends elements from a serialized string.

Parameters
$obj | The object to which the elements are appended.
$field | The attribute of $obj whose value should be unserialized.

Definition at line 1387 of file bootstrap.inc.

References $value.

drupal_valid_http_host ( $host )

Validates that a hostname (for example $_SERVER['HTTP_HOST']) is safe.

Returns
TRUE if only containing valid characters, or FALSE otherwise.

Definition at line 702 of file bootstrap.inc.

Referenced by drupal_environment_initialize().

drupal_valid_test_ua ( )

Returns the test prefix if this is an internal request from SimpleTest.

Returns
Either the simpletest prefix (the string "simpletest" followed by any number of digits) or FALSE if the user agent does not contain a valid HMAC and timestamp.

Definition at line 2515 of file bootstrap.inc.

References drupal_get_hash_salt(), drupal_hmac_base64(), and REQUEST_TIME.

Referenced by _drupal_bootstrap_database(), and drupal_system_listing().

drupal_validate_utf8 ( $text )

Checks whether a string is valid UTF-8.

All functions designed to filter input should use drupal_validate_utf8 to ensure they operate on valid UTF-8 strings to prevent bypass of the filter.

When text containing an invalid UTF-8 lead byte (0xC0 - 0xFF) is presented as UTF-8 to Internet Explorer 6, the program may misinterpret subsequent bytes. When these subsequent bytes are HTML control characters such as quotes or angle brackets, parts of the text that were deemed safe by filters end up in locations that are potentially unsafe; An onerror attribute that is outside of a tag, and thus deemed safe by a filter, can be interpreted by the browser as if it were inside the tag.

The function does not return FALSE for strings containing character codes above U+10FFFF, even though these are prohibited by RFC 3629.

Parameters
$text The text to check.
Returns
TRUE if the text is valid UTF-8, FALSE if not.

Definition at line 1593 of file bootstrap.inc.

Referenced by filter_xss().

ip_address ( )

Returns the IP address of the client machine.

If Drupal is behind a reverse proxy, we use the X-Forwarded-For header instead of $_SERVER['REMOTE_ADDR'], which would be the IP address of the proxy server, and not the client's. The actual header name can be configured by the reverse_proxy_header variable.

Returns
IP address of client machine, adjusted for reverse proxy and/or cluster environments.

Definition at line 2890 of file bootstrap.inc.

References drupal_static(), and variable_get().

Referenced by _drupal_bootstrap_page_cache(), _drupal_session_write(), comment_save(), drupal_anonymous_user(), drupal_block_denied(), flood_clear_event(), flood_is_allowed(), flood_register_event(), openid_verify_assertion_nonce(), poll_cancel(), poll_load(), poll_vote(), statistics_exit(), system_block_ip_action(), system_ip_blocking_form_validate(), user_login_authenticate_validate(), and watchdog().

language_default ( $property = NULL )

Returns the default language used on the site

Parameters
$property Optional property of the language object to return

Definition at line 2765 of file bootstrap.inc.

References variable_get().

Referenced by _locale_rebuild_js(), _update_cron_notify(), _user_mail_notify(), contact_site_form_submit(), drupal_language_initialize(), email_example_mail_send(), field_valid_language(), language_from_default(), language_initialize(), language_list(), language_negotiation_info(), locale_form_node_form_alter(), locale_language_url_fallback(), locale_languages_delete_form(), locale_languages_edit_form_submit(), locale_languages_edit_form_validate(), locale_languages_overview_form(), locale_languages_overview_form_submit(), locale_translate_edit_form(), locale_update_7001(), DrupalWebTestCase\setUp(), system_send_email_action(), template_preprocess_maintenance_page(), theme_locale_languages_overview_form(), and user_preferred_language().

language_list ( $field = 'language' )

Returns a list of installed languages, indexed by the specified key.

Parameters
$field (optional) The field to index the list with.
Returns
An associative array, keyed on the values of $field.
  • If $field is 'weight' or 'enabled', the array is nested, with the outer array's values each being associative arrays with language codes as keys and language objects as values.
  • For all other values of $field, the array is only one level deep, and the array's values are language objects.

Definition at line 2723 of file bootstrap.inc.

References db_query(), drupal_multilingual(), drupal_static(), language_default(), module_exists(), and variable_get().

Referenced by _locale_import_one_string(), _locale_invalidate_js(), _locale_prepare_predefined_list(), _locale_rebuild_js(), _locale_translate_language_list(), field_content_languages(), language_fallback_get_candidates(), language_negotiation_get_switch_links(), language_provider_invoke(), locale_batch_by_component(), locale_date_format_reset_form(), locale_get_plural(), locale_language_list(), locale_language_selector_form(), locale_language_switcher_session(), locale_language_switcher_url(), locale_language_url_rewrite_session(), locale_language_url_rewrite_url(), locale_languages_delete_form(), locale_languages_delete_form_submit(), locale_languages_overview_form(), locale_languages_overview_form_submit(), locale_translate_edit_form(), locale_translate_export_po_form_submit(), locale_translate_import_form_submit(), locale_translate_overview_screen(), locale_update_7003(), node_admin_nodes(), node_form_search_form_alter(), overlay_overlay_parent_initialize(), system_date_format_save(), translation_form_node_form_alter(), translation_node_overview(), translation_node_prepare(), translation_node_view(), and user_preferred_language().

language_types ( )

Returns an array of the available language types.

Returns
An array of all language types where the keys of each are the language type name and its value is its configurability (TRUE/FALSE).

Definition at line 2705 of file bootstrap.inc.

References drupal_language_types(), and variable_get().

Referenced by drupal_language_initialize(), and locale_uninstall().

request_path ( )

Returns the requested URL path of the page being viewed.

Examples:

  • http://example.com/node/306 returns "node/306".
  • http://example.com/drupalfolder/node/306 returns "node/306" while base_path() returns "/drupalfolder/".
  • http://example.com/path/alias (which is a path alias for node/306) returns "path/alias" as opposed to the internal path.
  • http://example.com/index.php returns an empty string (meaning: front page).
  • http://example.com/index.php?page=1 returns an empty string.
Returns
The requested Drupal URL path.
See Also
current_path()

Definition at line 2787 of file bootstrap.inc.

Referenced by drupal_environment_initialize().

request_uri ( )

Returns the equivalent of Apache's $_SERVER['REQUEST_URI'] variable.

Because $_SERVER['REQUEST_URI'] is only available on Apache, we generate an equivalent using other environment variables.

Definition at line 1609 of file bootstrap.inc.

Referenced by cache_example_page_form(), drupal_deliver_html_page(), drupal_fast_404(), drupal_page_get_cache(), drupal_page_set_cache(), drupal_render_cid_parts(), locale(), openid_verify_assertion_return_url(), system_clean_url_settings(), system_element_info(), and watchdog().

t | ( |  | $string,
 |  | array | $args = array(),
 |  | array | $options = array()
 | ) |  |

Definition at line 1459 of file bootstrap.inc.

References format_string(), locale(), and variable_get().

Referenced by FieldValidationException\__construct(), ArchiverZip\__construct(), _action_example_page(), _aggregator_characters(), _ajax_example_get_first_dropdown_options(), _ajax_example_get_second_dropdown_options(), _batch_do(), _batch_page(), _block_rehash(), _book_add_form_elements(), _book_admin_table_tree(), _book_install_type_create(), _book_parent_select(), _comment_get_modes(), _drupal_log_error(), _field_example_page(), _field_permission_example_page(), _field_ui_field_overview_form_validate_add_existing(), _field_ui_field_overview_form_validate_add_new(), _file_generic_settings_extensions(), _file_generic_settings_max_filesize(), _filter_autop_tips(), _filter_example_filter_foo_settings(), _filter_example_filter_foo_tips(), _filter_example_filter_time_tips(), _filter_example_information(), _filter_html_escape_tips(), _filter_html_settings(), _filter_html_tips(), _filter_url_settings(), _filter_url_tips(), _format_date_callback(), _forum_parent_select(), _image_field_resolution_validate(), _locale_import_parse_plural_forms(), _locale_import_po(), _locale_languages_common_controls(), _locale_languages_configure_form_language_table(), _locale_prepare_predefined_list(), _locale_rebuild_js(), _locale_translate_seek(), _menu_example_basic_instructions(), _menu_example_menu_page(), _menu_example_simple_title_callback(), _menu_item_localize(), _menu_overview_tree_form(), _menu_parents_recurse(), _menu_site_is_offline(), _node_access_rebuild_batch_finished(), _node_characters(), _node_example_installed_instances(), _node_mass_update_batch_finished(), _node_query_node_access_alter(), _openid_invalid_openid_transition(), _openid_user_login_form_alter(), _php_filter_tips(), _poll_choice_form(), _profile_field_types(), _profile_form_explanation(), _shortcut_link_form_elements(), _simpletest_batch_finished(), _simpletest_batch_operation(), _simpletest_example_explanation(), _simpletest_format_summary_line(), _system_modules_build_row(), _update_manager_check_backends(), _update_message_text(), _update_no_data(), _update_requirement_check(), _user_cancel(), _user_mail_text(), _vertical_tabs_example_explanation(), _xmlrpc(), _xmlrpc_example_server_add(), _xmlrpc_example_server_subtract(), action_example_action_info(), action_example_basic_action(), action_example_node_sticky_action(), action_example_node_sticky_action_form(), action_example_node_sticky_action_validate(), action_example_unblock_user_action(), actions_synchronize(), DatabaseSchema_sqlite\addField(), DatabaseSchema_mysql\addField(), DatabaseSchema_pgsql\addField(), EntityFieldQuery\addFieldCondition(), DatabaseSchema_mysql\addIndex(), DatabaseSchema_pgsql\addIndex(), DatabaseSchema_sqlite\addIndex(), DatabaseSchema_mysql\addPrimaryKey(), DatabaseSchema_pgsql\addPrimaryKey(), DatabaseSchema_sqlite\addPrimaryKey(), DatabaseSchema_mysql\addUniqueKey(), DatabaseSchema_pgsql\addUniqueKey(), DatabaseSchema_sqlite\addUniqueKey(), aggregator_admin_form(), aggregator_admin_remove_feed(), aggregator_aggregator_fetch(), aggregator_aggregator_fetch_info(), aggregator_aggregator_parse_info(), aggregator_aggregator_process_info(), aggregator_aggregator_remove(), aggregator_block_configure(), aggregator_block_info(), aggregator_block_view(), aggregator_categorize_items(), aggregator_categorize_items_submit(), aggregator_form_aggregator_admin_form_alter(), aggregator_form_category(), aggregator_form_category_submit(), aggregator_form_category_validate(), aggregator_form_feed(), aggregator_form_feed_submit(), aggregator_form_feed_validate(), aggregator_form_opml(), aggregator_form_opml_submit(), aggregator_form_opml_validate(), aggregator_help(), aggregator_page_category(), aggregator_page_last(), aggregator_page_sources(), aggregator_parse_feed(), aggregator_permission(), aggregator_refresh(), aggregator_view(), ajax_example_add_more(), ajax_example_add_more_submit(), ajax_example_advanced_commands(), ajax_example_autocheckboxes(), ajax_example_autotextfields(), ajax_example_dependent_dropdown(), ajax_example_dependent_dropdown_degrades(), ajax_example_dependent_dropdown_degrades_submit(), ajax_example_dynamic_sections(), ajax_example_dynamic_sections_submit(), ajax_example_dynamic_sections_validate(), ajax_example_form_node_form_alter(), ajax_example_intro(), ajax_example_node_by_author_autocomplete(), ajax_example_node_by_author_autocomplete_submit(), ajax_example_node_by_author_autocomplete_validate(), ajax_example_render_link(), ajax_example_render_link_ra(), ajax_example_simple_autocomplete(), ajax_example_simplest(), ajax_example_submit_driven_ajax(), ajax_example_unique_autocomplete(), ajax_example_unique_autocomplete_submit(), ajax_example_unique_autocomplete_validate(), ajax_example_wizard(), ajax_example_wizard_submit(), ajax_link_response(), ajax_prepare_response(), archiver_get_archiver(), DrupalTestCase\assertEqual(), DrupalTestCase\assertFalse(), DrupalWebTestCase\assertFieldById(), DrupalWebTestCase\assertFieldByName(), DrupalWebTestCase\assertFieldChecked(), DrupalTestCase\assertIdentical(), DrupalWebTestCase\assertLink(), DrupalWebTestCase\assertLinkByHref(), DrupalWebTestCase\assertMail(), DrupalWebTestCase\assertMailPattern(), DrupalWebTestCase\assertMailString(), DrupalWebTestCase\assertNoDuplicateIds(), DrupalWebTestCase\assertNoFieldById(), DrupalWebTestCase\assertNoFieldByName(), DrupalWebTestCase\assertNoFieldChecked(), DrupalWebTestCase\assertNoLink(), DrupalWebTestCase\assertNoLinkByHref(), DrupalWebTestCase\assertNoOptionSelected(), DrupalWebTestCase\assertNoPattern(), DrupalWebTestCase\assertNoRaw(), DrupalWebTestCase\assertNoResponse(), DrupalTestCase\assertNotEqual(), DrupalTestCase\assertNotIdentical(), DrupalWebTestCase\assertNoTitle(), DrupalTestCase\assertNotNull(), DrupalTestCase\assertNull(), DrupalWebTestCase\assertOptionSelected(), DrupalWebTestCase\assertPattern(), DrupalWebTestCase\assertRaw(), DrupalWebTestCase\assertResponse(), DrupalWebTestCase\assertTextHelper(), DrupalWebTestCase\assertTitle(), DrupalTestCase\assertTrue(), DrupalWebTestCase\assertUrl(), authorize_access_denied_page(), authorize_filetransfer_form(), authorize_filetransfer_form_validate(), batch_example_batch_1(), batch_example_batch_2(), batch_example_finished(), batch_example_op_1(), batch_example_simple_form(), batch_example_update_7100(), block_add_block_form_submit(), block_add_block_form_validate(), block_admin_configure(), block_admin_configure_submit(), block_admin_configure_validate(), block_admin_display_form(), block_admin_display_form_submit(), block_custom_block_delete(), block_custom_block_delete_submit(), block_custom_block_form(), block_example_block_configure(), block_example_block_info(), block_example_block_view(), block_example_contents(), block_example_page(), block_form_system_performance_settings_alter(), block_form_user_profile_form_alter(), block_help(), block_page_build(), block_permission(), blog_block_configure(), blog_block_info(), blog_block_view(), blog_feed_last(), blog_feed_user(), blog_help(), blog_menu_local_tasks_alter(), blog_node_info(), blog_node_view(), blog_page_last(), blog_page_user(), blog_user_view(), blog_view(), book_admin_edit(), book_admin_edit_submit(), book_admin_edit_validate(), book_admin_overview(), book_admin_settings(), book_admin_settings_validate(), book_block_configure(), book_block_info(), book_block_view(), book_entity_info_alter(), book_export(), book_form_node_delete_confirm_alter(), book_form_node_form_alter(), book_help(), book_node_view_link(), book_outline_form(), book_outline_form_submit(), book_permission(), book_remove_form(), book_remove_form_submit(), cache_example_form_cache_clearing(), cache_example_form_create_expiring_item(), cache_example_form_expire_files(), cache_example_page_form(), callback_filter_settings(), callback_filter_tips(), DatabaseSchema_mysql\changeField(), DatabaseSchema_sqlite\changeField(), DatabaseSchema_pgsql\changeField(), DrupalWebTestCase\checkPermissions(), DrupalDatabaseCache\clear(), DrupalWebTestCase\clickLink(), color_form_system_theme_settings_alter(), color_help(), color_requirements(), color_scheme_form(), color_scheme_form_submit(), color_scheme_form_validate(), comment_action_info(), comment_admin_overview(), comment_admin_overview_submit(), comment_admin_overview_validate(), comment_approve(), comment_block_configure(), comment_block_info(), comment_block_view(), comment_confirm_delete(), comment_confirm_delete_submit(), comment_count_unpublished(), comment_edit_page(), comment_entity_info(), comment_field_extra_fields(), comment_form(), comment_form_node_form_alter(), comment_form_node_type_form_alter(), comment_form_submit(), comment_form_validate(), comment_help(), comment_links(), comment_multiple_delete_confirm(), comment_node_view(), comment_permission(), comment_preview(), comment_ranking(), comment_reply(), comment_submit(), comment_token_info(), comment_tokens(), comment_unpublish_by_keyword_action_form(), comment_update_7005(), confirm_form(), contact_category_delete_form(), contact_category_delete_form_submit(), contact_category_edit_form(), contact_category_edit_form_submit(), contact_category_edit_form_validate(), contact_category_list(), contact_form_user_admin_settings_alter(), contact_form_user_profile_form_alter(), contact_help(), contact_mail(), contact_permission(), contact_personal_form(), contact_personal_form_submit(), contact_personal_form_validate(), contact_site_form(), contact_site_form_submit(), contact_site_form_validate(), contextual_help(), contextual_links_example_block_info(), contextual_links_example_block_view(), contextual_links_example_node_action_form(), contextual_links_example_node_action_form_submit(), contextual_links_example_object_edit_form(), contextual_links_example_object_edit_form_submit(), contextual_links_example_object_load(), contextual_permission(), DatabaseSchema\createTable(), cron_example_cron(), cron_example_form(), cron_example_form_cron_run_submit(), cron_example_queue_report_work(), DrupalWebTestCase\curlExec(), dashboard_admin(), dashboard_help(), dashboard_page_build(), dashboard_permission(), dashboard_update(), date_validate(), dblog_clear_log_form(), dblog_clear_log_submit(), dblog_event(), dblog_filter_form(), dblog_filter_form_submit(), dblog_filter_form_validate(), dblog_filters(), dblog_form_system_logging_settings_alter(), dblog_help(), dblog_overview(), dblog_top(), dbtng_example_advanced_list(), dbtng_example_entry_insert(), dbtng_example_entry_update(), dbtng_example_form_add(), dbtng_example_form_add_submit(), dbtng_example_form_update(), dbtng_example_form_update_submit(), dbtng_example_help(), dbtng_example_list(), drupal_check_module(), drupal_deliver_html_page(), drupal_http_request(), drupal_mail(), drupal_mail_system(), drupal_validate_form(), DrupalWebTestCase\drupalCreateContentType(), DrupalWebTestCase\drupalCreateRole(), DrupalWebTestCase\drupalCreateUser(), DrupalWebTestCase\drupalLogin(), DrupalWebTestCase\drupalLogout(), DrupalWebTestCase\drupalPost(), element_validate_integer(), element_validate_integer_positive(), element_validate_number(), email_example_form(), email_example_form_validate(), email_example_mail(), email_example_mail_alter(), email_example_mail_send(), entity_example_basic_edit_delete(), entity_example_basic_form(), entity_example_basic_list_entities(), entity_example_basic_title(), entity_example_basic_view(), entity_example_entity_info(), entity_example_field_extra_fields(), entity_example_info_page(), entity_example_permission(), DrupalTestCase\exceptionHandler(), MergeQuery\execute(), SearchQuery\executeFirstPass(), Updater\factory(), field_create_field(), field_create_instance(), field_default_validate(), field_example_3text_validate(), field_example_field_formatter_info(), field_example_field_formatter_view(), field_example_field_info(), field_example_field_validate(), field_example_field_widget_form(), field_example_field_widget_info(), field_help(), field_multiple_value_form(), field_permission_example_field_access(), field_permission_example_field_formatter_info(), field_permission_example_field_info(), field_permission_example_field_widget_info(), field_permission_example_permission(), field_purge_field(), field_sql_storage_field_storage_info(), field_sql_storage_help(), field_system_info_alter(), field_ui_default_value_widget(), field_ui_display_overview_form(), field_ui_display_overview_form_submit(), field_ui_field_delete_form(), field_ui_field_delete_form_submit(), field_ui_field_edit_form(), field_ui_field_edit_form_submit(), field_ui_field_overview_form(), field_ui_field_overview_form_submit(), field_ui_field_settings_form(), field_ui_field_settings_form_submit(), field_ui_fields_list(), field_ui_form_node_type_form_alter(), field_ui_help(), field_ui_inactive_message(), field_ui_menu(), field_ui_widget_type_form(), field_ui_widget_type_form_submit(), field_update_instance(), EntityFieldQuery\fieldOrderBy(), DatabaseSchema_mysql\fieldSetDefault(), DatabaseSchema_pgsql\fieldSetDefault(), DatabaseSchema_sqlite\fieldSetDefault(), DatabaseSchema_mysql\fieldSetNoDefault(), DatabaseSchema_pgsql\fieldSetNoDefault(), DatabaseSchema_sqlite\fieldSetNoDefault(), file_ajax_progress(), file_ajax_upload(), file_copy(), file_delete(), file_example_check_directory_submit(), file_example_create_directory_submit(), file_example_delete_directory_submit(), file_example_delete_submit(), file_example_file_check_exists_submit(), file_example_intro(), file_example_managed_write_submit(), file_example_permission(), file_example_read_submit(), file_example_readwrite(), file_example_session_contents(), file_example_show_session_contents_submit(), file_example_stream_wrappers(), file_example_unmanaged_php_submit(), file_example_unmanaged_write_submit(), file_field_formatter_info(), file_field_info(), file_field_instance_settings_form(), file_field_settings_form(), file_field_widget_form(), file_field_widget_info(), file_field_widget_process(), file_field_widget_process_multiple(), file_field_widget_settings_form(), file_help(), file_managed_file_process(), file_managed_file_save_upload(), file_managed_file_validate(), file_move(), file_munge_filename(), file_requirements(), file_save_data(), file_save_upload(), file_unmanaged_copy(), file_unmanaged_save_data(), file_validate_extensions(), file_validate_image_resolution(), file_validate_is_image(), file_validate_name_length(), file_validate_size(), filter_admin_disable(), filter_admin_disable_submit(), filter_admin_format_form(), filter_admin_format_form_submit(), filter_admin_format_form_validate(), filter_admin_format_page(), filter_admin_overview(), filter_admin_overview_submit(), filter_example_filter_info(), filter_filter_info(), filter_form_access_denied(), filter_help(), filter_permission(), filter_process_format(), form_example_element_demo_form(), form_example_element_demo_form_submit(), form_example_help(), form_example_intro(), form_example_phonenumber_combined_validate(), form_example_phonenumber_discrete_validate(), form_example_states_form(), form_example_states_form_submit(), form_example_tutorial(), form_example_tutorial_1(), form_example_tutorial_10(), form_example_tutorial_10_submit(), form_example_tutorial_10_validate(), form_example_tutorial_2(), form_example_tutorial_3(), form_example_tutorial_4(), form_example_tutorial_5(), form_example_tutorial_6(), form_example_tutorial_6_validate(), form_example_tutorial_7(), form_example_tutorial_7_submit(), form_example_tutorial_7_validate(), form_example_tutorial_8(), form_example_tutorial_8_next_validate(), form_example_tutorial_8_page_two(), form_example_tutorial_8_page_two_submit(), form_example_tutorial_9(), form_example_tutorial_9_submit(), form_example_tutorial_9_validate(), form_example_wizard(), form_example_wizard_location_info(), form_example_wizard_location_info_validate(), form_example_wizard_other_info(), form_example_wizard_personal_info(), form_example_wizard_submit(), form_process_date(), form_process_machine_name(), form_process_password_confirm(), form_process_select(), form_process_tableselect(), form_validate_machine_name(), format_interval(), format_plural(), format_size(), format_username(), forum_admin_settings(), forum_block_configure(), forum_block_info(), forum_block_view(), forum_block_view_pre_render(), forum_confirm_delete(), forum_confirm_delete_submit(), forum_enable(), forum_form(), forum_form_container(), forum_form_forum(), forum_form_main(), forum_form_submit(), forum_form_taxonomy_form_vocabulary_alter(), forum_get_topics(), forum_help(), forum_menu_local_tasks_alter(), forum_node_info(), forum_node_validate(), forum_node_view(), forum_overview(), forum_permission(), forum_update_7003(), garland_breadcrumb(), garland_form_system_theme_settings_alter(), garland_preprocess_page(), Updater\getProjectTitle(), FileTransfer\getSettingsForm(), Updater\getUpdaterFromDirectory(), help_help(), help_main(), help_page(), hook_action_info(), hook_action_info_alter(), hook_aggregator_fetch_info(), hook_aggregator_parse_info(), hook_aggregator_process_info(), hook_block_configure(), hook_block_info(), hook_block_view(), hook_block_view_MODULE_DELTA_alter(), hook_comment_delete(), hook_comment_publish(), hook_comment_unpublish(), hook_date_format_types(), hook_entity_info(), hook_field_attach_form(), hook_field_extra_fields(), hook_field_formatter_info(), hook_field_formatter_settings_form(), hook_field_formatter_settings_summary(), hook_field_formatter_view(), hook_field_info(), hook_field_instance_settings_form(), hook_field_settings_form(), hook_field_storage_info(), hook_field_validate(), hook_field_widget_info(), hook_field_widget_settings_form(), hook_file_copy(), hook_file_move(), hook_file_update(), hook_file_validate(), hook_filetransfer_info(), hook_filter_info(), hook_form(), hook_form_alter(), hook_form_BASE_FORM_ID_alter(), hook_form_FORM_ID_alter(), hook_form_system_theme_settings_alter(), hook_help(), hook_image_effect_info(), hook_image_toolkits(), hook_language_negotiation_info(), hook_language_types_info(), hook_language_types_info_alter(), hook_locale(), hook_mail_alter(), hook_menu_contextual_links_alter(), hook_menu_local_tasks_alter(), hook_modules_enabled(), hook_node_info(), hook_node_operations(), hook_node_type_insert(), hook_node_validate(), hook_options_list(), hook_page_alter(), hook_page_build(), hook_permission(), hook_prepare(), hook_ranking(), hook_search_admin(), hook_stream_wrappers(), hook_stream_wrappers_alter(), hook_system_themes_page_alter(), hook_token_info(), hook_token_info_alter(), hook_tokens(), hook_trigger_info(), hook_trigger_info_alter(), hook_update_N(), hook_update_status_alter(), hook_updater_info(), hook_user_cancel_methods_alter(), hook_user_categories(), hook_user_login(), hook_user_operations(), hook_user_view(), hook_username_alter(), hook_validate(), hook_verify_update_archive(), hook_view(), hook_watchdog(), hook_xmlrpc(), image_crop_form(), image_effect_color_validate(), image_effect_delete_form(), image_effect_delete_form_submit(), image_effect_form(), image_effect_form_submit(), image_effect_integer_validate(), image_effect_scale_validate(), image_example_colorize_form(), image_example_help(), image_example_image_effect_info(), image_example_image_styles_alter(), image_example_style_form(), image_example_style_form_submit(), image_example_style_form_validate(), image_field_formatter_info(), image_field_formatter_settings_form(), image_field_formatter_settings_summary(), image_field_info(), image_field_instance_settings_form(), image_field_settings_form(), image_field_widget_info(), image_field_widget_process(), image_field_widget_settings_form(), image_gd_settings(), image_gd_settings_validate(), image_help(), image_image_effect_info(), image_permission(), image_requirements(), image_resize_form(), image_rotate_form(), image_scale_form(), image_style_add_form(), image_style_add_form_submit(), image_style_delete_form(), image_style_delete_form_submit(), image_style_deliver(), image_style_form(), image_style_form_add_submit(), image_style_form_add_validate(), image_style_form_override_submit(), image_style_form_submit(), image_style_name_validate(), image_style_options(), image_style_revert_form(), image_style_revert_form_submit(), DrupalTestCase\insertAssert(), Updater\install(), js_example_accordion(), language_negotiation_info(), list_allowed_values_setting_validate(), list_field_formatter_info(), list_field_info(), list_field_settings_form(), list_field_update_forbid(), list_field_validate(), list_help(), locale_block_info(), locale_block_view(), locale_date_format_form(), locale_date_format_form_submit(), locale_date_format_language_overview_page(), locale_date_format_reset_form(), locale_form_node_form_alter(), locale_form_node_type_form_alter(), locale_form_path_admin_form_alter(), locale_help(), locale_language_list(), locale_language_name(), locale_language_negotiation_info(), locale_language_providers_session_form(), locale_language_providers_url_form(), locale_language_selector_form(), locale_language_types_info(), locale_languages_configure_form(), locale_languages_configure_form_submit(), locale_languages_custom_form(), locale_languages_delete_form(), locale_languages_delete_form_submit(), locale_languages_edit_form(), locale_languages_edit_form_validate(), locale_languages_overview_form(), locale_languages_overview_form_submit(), locale_languages_predefined_form(), locale_languages_predefined_form_submit(), locale_languages_predefined_form_validate(), locale_locale(), locale_permission(), locale_translate_delete_form(), locale_translate_delete_form_submit(), locale_translate_edit_form(), locale_translate_edit_form_submit(), locale_translate_edit_form_validate(), locale_translate_export_po_form(), locale_translate_export_pot_form(), locale_translate_import_form(), locale_translate_import_form_submit(), locale_translate_overview_screen(), locale_translation_filter_form(), locale_translation_filter_form_submit(), locale_translation_filter_form_validate(), locale_translation_filters(), map_month(), menu_configure(), menu_delete_menu_confirm(), menu_delete_menu_confirm_submit(), menu_edit_item(), menu_edit_item_submit(), menu_edit_item_validate(), menu_edit_menu(), menu_edit_menu_submit(), menu_example_arg_optional_load(), menu_example_id_load(), menu_example_menu(), menu_example_permission(), menu_example_user_page_title(), menu_form_node_form_alter(), menu_form_node_type_form_alter(), menu_get_menus(), menu_help(), menu_item_delete_form(), menu_item_delete_form_submit(), menu_node_save(), menu_overview_form(), menu_overview_form_submit(), menu_overview_page(), menu_permission(), menu_reset_item_confirm(), menu_reset_item_confirm_submit(), menu_set_active_trail(), node_access_example_form_alter(), node_access_example_node_access(), node_access_example_node_insert(), node_access_example_node_update(), node_access_example_permission(), node_access_example_private_node_listing(), node_access_rebuild(), node_action_info(), node_add(), node_admin_nodes(), node_admin_nodes_validate(), node_assign_owner_action_form(), node_assign_owner_action_validate(), node_block_configure(), node_block_info(), node_block_view(), node_build_content(), node_configure_rebuild_confirm(), node_delete_confirm(), node_delete_confirm_submit(), node_entity_info(), node_example_entity_info_alter(), node_example_field_formatter_info(), node_example_help(), node_example_node_info(), node_example_node_type_insert(), node_example_page(), node_field_extra_fields(), node_filter_form(), node_filter_form_submit(), node_filters(), node_form(), node_form_block_admin_configure_alter(), node_form_search_form_alter(), node_form_submit(), node_help(), node_list_permissions(), node_mass_update(), node_multiple_delete_confirm(), node_node_operations(), node_overview_types(), node_page_default(), node_page_edit(), node_permission(), node_preview(), node_ranking(), node_requirements(), node_revision_delete_confirm(), node_revision_delete_confirm_submit(), node_revision_overview(), node_revision_revert_confirm(), node_revision_revert_confirm_submit(), node_search_admin(), node_show(), node_token_info(), node_type_delete_confirm(), node_type_delete_confirm_submit(), node_type_form(), node_type_form_submit(), node_type_form_validate(), node_unpublish_by_keyword_action_form(), node_validate(), nodeapi_example_form_alter(), nodeapi_example_node_validate(), number_field_formatter_info(), number_field_formatter_settings_form(), number_field_formatter_settings_summary(), number_field_info(), number_field_instance_settings_form(), number_field_settings_form(), number_field_validate(), number_field_widget_info(), number_field_widget_validate(), number_help(), openid_authentication(), openid_authentication_page(), openid_begin(), openid_form_user_register_form_alter(), openid_help(), openid_redirect(), openid_redirect_form(), openid_requirements(), openid_user_add(), openid_user_add_validate(), openid_user_delete_form(), openid_user_delete_form_submit(), openid_user_identities(), openid_user_insert(), options_field_widget_info(), options_field_widget_settings_form(), options_field_widget_validate(), options_help(), overlay_disable_message(), overlay_form_user_profile_form_alter(), overlay_help(), overlay_permission(), overlay_user_dismiss_message(), page_example_arguments(), page_example_description(), page_example_help(), page_example_permission(), page_example_simple(), pager_example_help(), pager_example_page(), DrupalWebTestCase\parse(), SearchQuery\parseSearchExpression(), password_confirm_validate(), path_admin_delete_confirm(), path_admin_filter_form(), path_admin_form(), path_admin_form_submit(), path_admin_form_validate(), path_admin_overview(), path_form_element_validate(), path_form_node_form_alter(), path_form_taxonomy_form_term_alter(), path_help(), path_permission(), php_disable(), php_enable(), php_filter_info(), php_help(), php_permission(), poll_block_info(), poll_block_latest_poll_view(), poll_block_view(), poll_cancel(), poll_cancel_form(), poll_field_extra_fields(), poll_form(), poll_help(), poll_node_info(), poll_page(), poll_permission(), poll_token_info(), poll_validate(), poll_view_voting(), poll_view_voting_validate(), poll_vote(), poll_votes(), ModuleUpdater\postInstallTasks(), ThemeUpdater\postInstallTasks(), Updater\prepareInstallDirectory(), profile_admin_overview(), profile_admin_overview_submit(), profile_block_configure(), profile_block_info(), profile_block_view(), profile_browse(), profile_field_delete(), profile_field_delete_submit(), profile_field_form(), profile_field_form_submit(), profile_field_form_validate(), profile_help(), profile_user_form_validate(), EntityFieldQuery\propertyQuery(), EntityFieldQuery\queryCallback(), queue_example_add_remove_form(), queue_example_add_remove_form_claim(), queue_example_add_remove_form_clear_queue(), queue_example_add_remove_form_delete(), queue_example_add_remove_form_insert(), queue_example_add_remove_form_run_cron(), rdf_example_help(), rdf_help(), DatabaseSchema_sqlite\renameTable(), DatabaseSchema_mysql\renameTable(), DatabaseSchema_pgsql\renameTable(), render_example_add_suffix(), render_example_arrays(), render_example_cache_expensive(), render_example_demo_form(), render_example_info(), render_example_page_alter(), FileExampleSessionStreamWrapper\rmdir(), DrupalTestCase\run(), search_admin_settings(), search_admin_settings_submit(), search_admin_settings_validate(), search_form_submit(), search_reindex_confirm(), search_reindex_confirm_submit(), search_view(), DrupalWebTestCase\setUp(), seven_node_add_list(), seven_tablesort_indicator(), shortcut_block_info(), shortcut_block_view(), shortcut_help(), shortcut_link_add(), shortcut_link_add_inline(), shortcut_link_add_submit(), shortcut_link_delete(), shortcut_link_delete_submit(), shortcut_link_edit(), shortcut_link_edit_submit(), shortcut_link_edit_validate(), shortcut_permission(), shortcut_preprocess_page(), shortcut_set_add_form(), shortcut_set_add_form_submit(), shortcut_set_add_form_validate(), shortcut_set_admin(), shortcut_set_customize(), shortcut_set_customize_submit(), shortcut_set_delete_form(), shortcut_set_delete_form_submit(), shortcut_set_edit_form(), shortcut_set_edit_form_submit(), shortcut_set_edit_form_validate(), shortcut_set_switch(), shortcut_set_switch_submit(), shortcut_set_switch_validate(), shortcut_toolbar_pre_render(), simpletest_clean_database(), simpletest_clean_environment(), simpletest_clean_temporary_directories(), simpletest_example_node_info(), simpletest_example_permission(), simpletest_help(), simpletest_permission(), simpletest_result_form(), simpletest_result_status_image(), simpletest_run_tests(), simpletest_settings_form(), simpletest_settings_form_validate(), simpletest_test_form(), simpletest_test_form_submit(), statistics_access_log(), statistics_block_configure(), statistics_block_info(), statistics_block_view(), statistics_help(), statistics_node_tracker(), statistics_permission(), statistics_ranking(), statistics_recent_hits(), statistics_settings_form(), statistics_token_info(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), statistics_user_tracker(), syslog_form_system_logging_settings_alter(), syslog_help(), system_action_delete_orphans_post(), system_action_info(), system_actions_configure(), system_actions_configure_submit(), system_actions_delete_form(), system_actions_delete_form_submit(), system_actions_manage(), system_actions_manage_form(), system_add_date_format_type_form(), system_add_date_format_type_form_submit(), system_add_date_format_type_form_validate(), system_add_date_formats_form_submit(), system_add_date_formats_form_validate(), system_admin_config_page(), system_admin_menu_block_page(), system_block_info(), system_block_view(), system_check_directory(), system_clean_url_settings(), system_clear_cache_submit(), system_configure_date_formats_form(), system_cron_settings(), system_date_delete_format_form(), system_date_delete_format_form_submit(), system_date_time_formats(), system_date_time_settings(), system_delete_date_format_type_form(), system_delete_date_format_type_form_submit(), system_entity_info(), system_file_system_settings(), system_filetransfer_info(), system_get_module_admin_tasks(), system_goto_action_form(), system_help(), system_image_toolkit_settings(), system_image_toolkits(), system_ip_blocking(), system_ip_blocking_delete(), system_ip_blocking_delete_submit(), system_ip_blocking_form(), system_ip_blocking_form_submit(), system_ip_blocking_form_validate(), system_logging_settings(), system_message_action_form(), system_modules(), system_modules_confirm_form(), system_modules_submit(), system_modules_uninstall(), system_modules_uninstall_confirm_form(), system_modules_uninstall_submit(), system_modules_uninstall_validate(), system_performance_settings(), system_permission(), system_region_list(), system_regional_settings(), system_requirements(), system_rss_feeds_settings(), system_run_cron(), system_run_cron_submit(), system_send_email_action_form(), system_send_email_action_validate(), system_settings_form(), system_settings_form_submit(), system_site_information_settings(), system_site_information_settings_validate(), system_site_maintenance_mode(), system_stream_wrappers(), system_theme_default(), system_theme_disable(), system_theme_enable(), system_theme_settings(), system_theme_settings_submit(), system_theme_settings_validate(), system_themes_admin_form(), system_themes_admin_form_submit(), system_themes_page(), system_time_zones(), system_token_info(), system_update_7003(), system_update_7007(), system_update_7033(), system_update_7060(), system_update_7061(), system_updater_info(), system_user_login(), system_user_timezone(), tabledrag_example_help(), tabledrag_example_parent_form(), tabledrag_example_simple_form(), tablesort_example_help(), tablesort_example_page(), tablesort_header(), taxonomy_autocomplete(), taxonomy_entity_info(), taxonomy_field_extra_fields(), taxonomy_field_formatter_info(), taxonomy_field_info(), taxonomy_field_settings_form(), taxonomy_field_validate(), taxonomy_field_widget_info(), taxonomy_form_term(), taxonomy_form_term_submit(), taxonomy_form_term_validate(), taxonomy_form_vocabulary(), taxonomy_form_vocabulary_submit(), taxonomy_form_vocabulary_validate(), taxonomy_help(), taxonomy_overview_terms(), taxonomy_overview_terms_submit(), taxonomy_overview_vocabularies(), taxonomy_overview_vocabularies_submit(), taxonomy_permission(), taxonomy_term_confirm_delete(), taxonomy_term_confirm_delete_submit(), taxonomy_term_page(), taxonomy_token_info(), taxonomy_vocabulary_confirm_delete(), taxonomy_vocabulary_confirm_delete_submit(), taxonomy_vocabulary_confirm_reset_alphabetical(), taxonomy_vocabulary_confirm_reset_alphabetical_submit(), DrupalWebTestCase\tearDown(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_item(), template_preprocess_aggregator_summary_item(), template_preprocess_block_admin_display_form(), template_preprocess_comment(), template_preprocess_dashboard_admin_display_form(), template_preprocess_forum_icon(), template_preprocess_forum_list(), template_preprocess_forum_topic_list(), template_preprocess_forums(), template_preprocess_node(), template_preprocess_user_picture(), template_preprocess_username(), text_field_formatter_info(), text_field_formatter_settings_form(), text_field_formatter_settings_summary(), text_field_info(), text_field_instance_settings_form(), text_field_settings_form(), text_field_validate(), text_field_widget_form(), text_field_widget_info(), text_field_widget_settings_form(), text_help(), theme(), theme_aggregator_categorize_items(), theme_aggregator_page_rss(), theme_book_admin_table(), theme_breadcrumb(), theme_color_scheme_form(), theme_comment_block(), theme_comment_post_forbidden(), theme_dashboard_disabled_blocks(), theme_dblog_message(), theme_feed_icon(), theme_field_multiple_value_form(), theme_file_formatter_table(), theme_file_upload_help(), theme_file_widget_multiple(), theme_filter_admin_overview(), theme_filter_tips(), theme_filter_tips_more_info(), theme_image_example_colorize_summary(), theme_image_example_image(), theme_image_resize_summary(), theme_image_rotate_summary(), theme_image_scale_summary(), theme_image_style_effects(), theme_image_style_list(), theme_image_style_preview(), theme_locale_date_format_form(), theme_locale_languages_configure_form(), theme_locale_languages_overview_form(), theme_mark(), theme_menu_local_task(), theme_menu_local_tasks(), theme_menu_overview_form(), theme_more_help_link(), theme_more_link(), theme_node_add_list(), theme_node_admin_overview(), theme_node_preview(), theme_node_recent_block(), theme_node_search_admin(), theme_nodeapi_example_rating(), theme_options_none(), theme_overlay_disable_message(), theme_pager(), theme_pager_link(), theme_poll_choices(), theme_profile_admin_overview(), theme_queue_items(), theme_render_example_add_notes(), theme_shortcut_set_customize(), theme_simpletest_test_table(), theme_status_messages(), theme_status_report(), theme_system_admin_index(), theme_system_compact_link(), theme_system_date_time_settings(), theme_system_modules_fieldset(), theme_system_modules_uninstall(), theme_system_powered_by(), theme_system_themes_page(), theme_tabledrag_example_parent_form(), theme_tabledrag_example_simple_form(), theme_tablesort_indicator(), theme_task_list(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_toolbar_toggle(), theme_trigger_display(), theme_update_last_check(), theme_update_report(), theme_update_status_label(), theme_update_version(), theme_user_admin_permissions(), theme_user_admin_roles(), theme_vertical_tabs(), theming_example_list_page(), theming_example_page(), theming_example_select_form(), theming_example_select_form_submit(), theming_example_text_form(), theming_example_text_form_submit(), token_example_example_form(), token_example_token_info(), toolbar_help(), toolbar_permission(), toolbar_view(), tracker_help(), tracker_page(), translation_form_node_form_alter(), translation_form_node_type_form_alter(), translation_help(), translation_node_overview(), translation_node_prepare(), translation_node_validate(), translation_permission(), trigger_assign_form(), trigger_assign_form_submit(), trigger_assign_form_validate(), trigger_example_form(), trigger_example_form_submit(), trigger_example_help(), trigger_example_trigger_info(), trigger_example_trigger_info_alter(), trigger_help(), trigger_trigger_info(), trigger_unassign(), trigger_unassign_submit(), FileExampleSessionStreamWrapper\unlink(), Updater\update(), update_authorize_batch_copy_project(), update_authorize_install_batch_finished(), update_authorize_run_install(), update_authorize_run_update(), update_authorize_update_batch_finished(), update_calculate_project_data(), update_calculate_project_update_status(), update_do_one(), update_fetch_data_batch(), update_fetch_data_finished(), update_help(), update_mail(), update_manager_archive_extract(), update_manager_batch_project_get(), update_manager_download_batch_finished(), update_manager_install_form(), update_manager_install_form_submit(), update_manager_install_form_validate(), update_manager_update_form(), update_manager_update_form_submit(), update_manager_update_form_validate(), update_manager_update_ready_form(), update_manager_update_ready_form_submit(), update_manual_status(), update_process_project_info(), update_requirements(), update_script_selection_form(), update_settings(), update_settings_validate(), update_verify_update_archive(), user_account_form(), user_account_form_validate(), user_action_info(), user_admin(), user_admin_account(), user_admin_account_submit(), user_admin_account_validate(), user_admin_permissions(), user_admin_permissions_submit(), user_admin_role(), user_admin_role_delete_confirm(), user_admin_role_delete_confirm_submit(), user_admin_role_submit(), user_admin_role_validate(), user_admin_roles(), user_admin_roles_order_submit(), user_admin_settings(), user_block_configure(), user_block_info(), user_block_view(), user_cancel(), user_cancel_confirm(), user_cancel_confirm_form(), user_cancel_confirm_form_submit(), user_cancel_methods(), user_entity_info(), user_external_login_register(), user_field_extra_fields(), user_filter_form(), user_filter_form_submit(), user_filters(), user_form_field_ui_field_edit_form_alter(), user_form_process_password_confirm(), user_help(), user_login(), user_login_block(), user_login_final_validate(), user_login_name_validate(), user_menu_title(), user_multiple_cancel_confirm(), user_pass(), user_pass_reset(), user_pass_submit(), user_pass_validate(), user_permission(), user_profile_form(), user_profile_form_submit(), user_register_form(), user_register_submit(), user_roles(), user_token_info(), user_tokens(), user_update_7000(), user_update_7002(), user_update_7014(), user_update_7017(), user_user_categories(), user_user_operations(), user_user_view(), user_validate_current_pass(), user_validate_mail(), user_validate_name(), user_validate_picture(), DrupalTestCase\verbose(), DrupalWebTestCase\verboseEmail(), vertical_tabs_example_form_alter(), watchdog_severity_levels(), xmlrpc_example_alter_form(), xmlrpc_example_client_add_submit(), xmlrpc_example_client_form(), xmlrpc_example_client_multicall_submit(), xmlrpc_example_client_request_methods_submit(), xmlrpc_example_client_subtract_submit(), xmlrpc_example_info(), xmlrpc_example_server_form(), xmlrpc_example_xmlrpc(), xmlrpc_server(), xmlrpc_server_call(), xmlrpc_server_method_signature(), and xmlrpc_server_multicall().

timer_read ( $name )

Reads the current timer value without stopping the timer.

Parameters
$name The name of the timer.
Returns
The current timer value in ms.

Definition at line 476 of file bootstrap.inc.

References $name.

Referenced by _batch_process(), drupal_http_request(), and statistics_exit().

timer_start ( $name )

Starts the timer with the specified name.

If you start and stop the same timer multiple times, the measured intervals will be accumulated.

Parameters
$name The name of the timer.

Definition at line 460 of file bootstrap.inc.

References $name.

Referenced by _batch_process(), _drupal_bootstrap_configuration(), and drupal_http_request().

timer_stop ( $name )

Stops the timer with the specified name.

Parameters
$name The name of the timer.
Returns
A timer array. The array contains the number of times the timer has been started and stopped (count) and the accumulated timer value in ms (time).

Definition at line 501 of file bootstrap.inc.

References $name.

variable_del ( $name )

Unsets a persistent variable.

Case-sensitivity of the variable_* functions depends on the database collation used. To avoid problems, always use lower case for persistent variable names.

Parameters
$name The name of the variable to undefine.
See Also
variable_get()
variable_set()

Definition at line 996 of file bootstrap.inc.

References $conf, $name, cache_clear_all(), and db_delete().

Referenced by aggregator_sanitize_configuration(), aggregator_uninstall(), block_example_uninstall(), block_update_7004(), blog_uninstall(), book_uninstall(), color_scheme_form_submit(), comment_node_type_delete(), comment_uninstall(), comment_update_7000(), contact_uninstall(), contact_update_7000(), dashboard_enable(), dashboard_uninstall(), dblog_uninstall(), drupal_clear_css_cache(), drupal_clear_js_cache(), drupal_cron_cleanup(), field_attach_delete_bundle(), field_attach_rename_bundle(), field_sql_storage_update_7001(), field_update_7002(), filter_update_7001(), filter_update_7003(), forum_uninstall(), hook_node_type_delete(), hook_node_type_update(), hook_uninstall(), image_example_uninstall(), image_update_7003(), install_import_locales_remaining(), install_profile_modules(), install_run_task(), locale_uninstall(), locale_update_7001(), menu_rebuild(), menu_update_7000(), menu_update_7001(), node_access_needs_rebuild(), node_type_delete_confirm_submit(), node_type_form_submit(), node_update_7004(), node_update_7006(), nodeapi_example_uninstall(), profile_uninstall(), render_example_uninstall(), search_uninstall(), simpletest_uninstall(), statistics_uninstall(), syslog_uninstall(), system_image_toolkit_settings(), system_update_7004(), system_update_7005(), system_update_7009(), system_update_7013(), system_update_7034(), system_update_7046(), system_update_7058(), system_update_7060(), system_update_7066(), system_update_7069(), system_update_7070(), system_update_7072(), taxonomy_uninstall(), tracker_uninstall(), update_finished(), update_settings_submit(), update_uninstall(), and user_update_7003().

variable_get | ( | $name,
 |  | $default = NULL
 | ) |

Returns a persistent variable.

Case-sensitivity of the variable_* functions depends on the database collation used. To avoid problems, always use lower case for persistent variable names.

Parameters
$name | The name of the variable to return.
$default | The default value to use if this variable has never been set.
Returns
The value of the variable. Unserialization is taken care of as necessary.
See Also
variable_del()
variable_set()

Definition at line 951 of file bootstrap.inc.

References $conf, and $name.

Referenced by _aggregator_get_variables(), _authorize_filetransfer_connection_settings(), _block_get_cache_id(), _book_parent_select(), _cache_get_object(), _color_html_alter(), _color_page_alter(), _color_theme_select_form_alter(), _comment_update_node_statistics(), _drupal_bootstrap_full(), _drupal_bootstrap_page_cache(), _drupal_bootstrap_variables(), _drupal_http_use_proxy(), _drupal_maintenance_theme(), _drupal_session_destroy(), _drupal_session_write(), _drupal_theme_access(), _filter_html_tips(), _filter_url(), _forum_parent_select(), _install_configure_form(), _locale_export_po_generate(), _locale_invalidate_js(), _locale_languages_configure_form_language_table(), _locale_rebuild_js(), _menu_site_is_offline(), _node_rankings(), _openid_xri_discovery(), _shortcut_link_form_elements(), _update_cron_notify(), _update_fetch_data(), _update_get_fetch_url_base(), _update_process_fetch_task(), _user_mail_notify(), _user_mail_text(), _xmlrpc_example_server_add(), _xmlrpc_example_server_subtract(), actions_do(), aggregator_admin_form(), aggregator_categorize_items(), aggregator_expire(), aggregator_filter_xss(), aggregator_form_aggregator_admin_form_alter(), aggregator_page_categories(), aggregator_page_category(), aggregator_page_last(), aggregator_page_rss(), aggregator_page_sources(), aggregator_update_7001(), ajax_base_page_theme(), ajax_prepare_response(), DrupalWebTestCase\assertMail(), UserController\attachLoad(), authorize_access_allowed(), authorize_filetransfer_form(), bartik_process_maintenance_page(), bartik_process_page(), block_admin_configure(), block_example_block_configure(), block_example_contents(), block_form_system_performance_settings_alter(), block_help(), block_menu(), block_page_build(), block_theme_initialize(), block_update_7004(), block_update_7005(), blog_block_configure(), blog_block_view(), blog_feed_last(), blog_feed_user(), blog_page_last(), blog_page_user(), book_admin_paths(), book_admin_settings(), book_block_configure(), book_block_view(), book_node_type_update(), book_node_view_link(), book_type_is_allowed(), DrupalDatabaseCache\clear(), color_get_palette(), color_scheme_form(), color_scheme_form_submit(), color_update_7001(), comment_block_configure(), comment_field_extra_fields(), comment_form(), comment_form_node_type_form_alter(), comment_get_display_ordinal(), comment_get_display_page(), comment_new_page_count(), comment_node_insert(), comment_node_page_additions(), comment_node_prepare(), comment_node_update_index(), comment_node_view(), comment_preview(), comment_ranking(), comment_submit(), comment_tokens(), comment_update_7000(), comment_update_7006(), comment_view(), contact_form_user_admin_settings_alter(), contact_install(), contact_mail(), contact_personal_form(), contact_personal_form_submit(), contact_site_form(), contact_site_form_submit(), contact_update_7000(), contact_user_presave(), cron_example_cron(), cron_example_form(), DrupalWebTestCase\cronRun(), DrupalWebTestCase\curlExec(), dashboard_block_info_alter(), dashboard_enable(), db_ignore_slave(), dblog_cron(), dblog_form_system_logging_settings_alter(), drupal_aggregate_css(), drupal_anonymous_user(), drupal_bootstrap(), drupal_build_css_cache(), drupal_build_js_cache(), drupal_chmod(), drupal_cron_cleanup(), drupal_delete_file_if_stale(), drupal_deliver_html_page(), drupal_fast_404(), drupal_get_js(), drupal_get_private_key(), drupal_get_profile(), drupal_get_user_timezone(), drupal_http_request(), drupal_is_denied(), drupal_is_front_page(), drupal_lookup_path(), drupal_mail(), drupal_mail_system(), drupal_match_path(), drupal_mkdir(), drupal_multilingual(), drupal_page_footer(), drupal_page_set_cache(), drupal_path_alias_whitelist_rebuild(), drupal_path_initialize(), drupal_pre_render_styles(), drupal_process_form(), drupal_serve_page_from_cache(), drupal_session_commit(), drupal_session_initialize(), drupal_session_regenerate(), drupal_strip_dangerous_protocols(), drupal_system_listing(), drupal_theme_initialize(), DrupalWebTestCase\drupalGetMails(), DrupalWebTestCase\drupalGetTestFiles(), email_example_mail(), email_example_mail_send(), error_displayable(), SearchQuery\executeFirstPass(), field_attach_rename_bundle(), field_bundle_settings(), field_create_field(), field_cron(), field_update_7002(), file_default_scheme(), file_directory_temp(), file_ensure_htaccess(), file_field_info(), file_field_widget_process(), file_icon_path(), file_munge_filename(), file_save_upload(), filter_admin_format_form(), filter_fallback_format(), filter_update_7001(), filter_update_7003(), filter_update_7005(), filter_update_7008(), form_builder(), form_example_element_demo_form(), form_process_date(), form_process_weight(), format_date(), format_username(), forum_admin_settings(), forum_block_configure(), forum_block_view(), forum_enable(), forum_entity_info_alter(), forum_form_container(), forum_form_forum(), forum_form_submit(), forum_form_taxonomy_form_term_alter(), forum_form_taxonomy_form_vocabulary_alter(), forum_forum_load(), forum_node_validate(), forum_node_view(), forum_overview(), forum_page(), forum_taxonomy_term_delete(), forum_update_7003(), DrupalDatabaseCache\garbageCollection(), DrupalQueue\get(), DrupalPublicStreamWrapper\getDirectoryPath(), DrupalPrivateStreamWrapper\getDirectoryPath(), DrupalTemporaryStreamWrapper\getDirectoryPath(), hook_block_configure(), hook_block_view(), hook_cron(), hook_field_attach_delete_bundle(), hook_field_attach_rename_bundle(), hook_field_insert(), hook_field_language_alter(), hook_field_update(), hook_file_download(), hook_filetransfer_info_alter(), hook_form_alter(), hook_image_style_delete(), hook_image_style_save(), hook_install_tasks(), hook_mail(), hook_mail_alter(), hook_menu_delete(), hook_menu_insert(), hook_menu_update(), hook_node_grants_alter(), hook_node_prepare(), hook_node_type_update(), hook_ranking(), hook_requirements(), hook_search_admin(), hook_shortcut_default_set(), hook_tokens(), hook_update_index(), hook_update_status_alter(), hook_user_login(), hook_watchdog(), image_example_image_style_delete(), image_example_image_style_save(), image_example_style_form(), image_example_style_form_submit(), image_field_info(), image_gd_save(), image_gd_settings(), image_get_toolkit(), image_style_deliver(), image_style_url(), install_begin_request(), install_import_locales_remaining(), install_profile_modules(), install_run_task(), ip_address(), l(), language_default(), language_initialize(), language_list(), language_negotiation_get(), language_negotiation_get_switch_links(), language_negotiation_purge(), language_provider_invoke(), language_types(), language_types_configurable(), language_types_disable(), locale(), locale_add_language(), locale_date_format_form(), locale_field_language_alter(), locale_form_node_type_form_alter(), locale_get_localized_date_format(), locale_js_alter(), locale_language_from_session(), locale_language_from_url(), locale_language_providers_session_form(), locale_language_providers_url_form(), locale_language_switcher_session(), locale_language_url_fallback(), locale_language_url_rewrite_session(), locale_language_url_rewrite_url(), locale_languages_delete_form_submit(), locale_languages_overview_form_submit(), locale_library_alter(), locale_multilingual_node_type(), locale_uninstall(), locale_update_7001(), locale_url_outbound_alter(), DefaultMailSystem\mail(), TestingMailSystem\mail(), menu_configure(), menu_delete(), menu_form_node_form_alter(), menu_form_node_type_form_alter(), menu_get_ancestors(), menu_get_item(), menu_main_menu(), menu_node_prepare(), menu_parent_options(), menu_save(), menu_secondary_menu(), menu_set_active_menu_names(), menu_tree_page_data(), menu_update_7000(), menu_update_7001(), menu_update_7003(), minimal_install(), node_access_needs_rebuild(), node_admin_paths(), node_block_configure(), node_block_view(), node_feed(), node_form(), node_object_prepare(), node_page_default(), node_permissions_get_configured_types(), node_ranking(), node_search_admin(), node_type_form(), node_update_7004(), node_update_7006(), node_update_7012(), node_update_index(), nodeapi_example_form_alter(), nodeapi_example_node_insert(), nodeapi_example_node_load(), nodeapi_example_node_update(), nodeapi_example_node_validate(), nodeapi_example_node_view(), openid_authentication(), openid_form_user_register_form_alter(), openid_user_insert(), overlay_overlay_parent_initialize(), SearchQuery\parseSearchExpression(), SearchQuery\parseWord(), path_admin_form(), DrupalWebTestCase\prepareEnvironment(), DrupalDatabaseCache\prepareItem(), profile_block_configure(), profile_block_view(), render_example_demo_form(), render_example_page_alter(), DrupalTestCase\run(), search_admin_settings(), search_admin_settings_submit(), DrupalUnitTestCase\setUp(), shortcut_max_slots(), simpletest_clean_environment(), simpletest_clean_results_table(), simpletest_settings_form(), simpletest_settings_form_validate(), simpletest_verbose(), standard_install(), statistics_block_configure(), statistics_block_info(), statistics_block_view(), statistics_cron(), statistics_exit(), statistics_node_view(), statistics_ranking(), statistics_settings_form(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), syslog_form_system_logging_settings_alter(), syslog_watchdog(), system_admin_compact_mode(), system_clean_url_settings(), system_cron_settings(), system_custom_theme(), system_date_time_settings(), system_file_system_settings(), system_form_user_profile_form_alter(), system_form_user_register_form_alter(), system_image_toolkit_settings(), system_logging_settings(), system_performance_settings(), system_permission(), system_regional_settings(), system_requirements(), system_rss_feeds_settings(), system_site_information_settings(), system_site_maintenance_mode(), system_stream_wrappers(), system_theme_default(), system_theme_disable(), system_theme_settings(), system_themes_admin_form(), system_themes_page(), system_time_zones(), system_tokens(), system_update_7004(), system_update_7009(), system_update_7013(), system_update_7017(), system_update_7033(), system_update_7034(), system_update_7046(), system_update_7047(), system_update_7049(), system_update_7060(), system_update_7061(), system_update_7066(), system_update_7067(), system_user_login(), system_user_timezone(), t(), taxonomy_build_node_index(), taxonomy_delete_node_index(), taxonomy_form_term(), taxonomy_overview_terms(), taxonomy_select_nodes(), taxonomy_taxonomy_term_delete(), taxonomy_term_feed(), taxonomy_term_page(), DrupalWebTestCase\tearDown(), template_preprocess_aggregator_item(), template_preprocess_comment_wrapper(), template_preprocess_forum_icon(), template_preprocess_forums(), template_preprocess_html(), template_preprocess_maintenance_page(), template_preprocess_node(), template_preprocess_page(), template_preprocess_user_picture(), text_summary(), theme_aggregator_page_opml(), theme_aggregator_page_rss(), theme_comment_block(), theme_comment_post_forbidden(), theme_disable(), theme_get_setting(), theme_image_style_preview(), theme_update_manager_update_form(), theme_update_report(), tracker_cron(), translation_admin_paths(), translation_language_switch_links_alter(), translation_node_overview(), translation_node_view(), translation_supported_type(), update_authorize_install_batch_finished(), update_authorize_update_batch_finished(), update_batch(), update_cron(), update_fix_d7_requirements(), update_get_projects(), update_mail(), update_manager_access(), update_manager_update_ready_form_submit(), update_prepare_d7_bootstrap(), update_settings(), update_settings_submit(), url(), user_account_form(), user_admin_settings(), user_authenticate(), user_block_configure(), user_block_view(), user_cancel_confirm(), user_cancel_confirm_form(), user_cancel_methods(), user_comment_view(), user_file_download(), user_hash_password(), user_image_style_save(), user_login(), user_login_authenticate_validate(), user_login_block(), user_login_final_validate(), user_modules_installed(), user_multiple_cancel_confirm(), user_needs_new_hash(), user_pass_reset(), user_permission(), user_register_access(), user_register_submit(), user_save(), user_update_7000(), user_update_7003(), user_update_7010(), user_update_7017(), user_validate_current_pass(), user_validate_picture(), xmlrpc_example_alter_form(), xmlrpc_example_client_form(), xmlrpc_example_server_form(), and xmlrpc_example_xmlrpc_alter().

variable_initialize ( $conf = array() )

Loads the persistent variable table.

The variable table is composed of values that have been saved in the table with variable_set() as well as those explicitly specified in the configuration file.

Definition at line 903 of file bootstrap.inc.

References $conf, $name, $value, cache_get(), cache_set(), db_query(), lock_acquire(), lock_release(), and lock_wait().

Referenced by _drupal_bootstrap_variables(), and DrupalWebTestCase\refreshVariables().

variable_set | ( | $name,
 |  | $value
 | ) |

Sets a persistent variable.

Case-sensitivity of the variable_* functions depends on the database collation used. To avoid problems, always use lower case for persistent variable names.

Parameters
$name | The name of the variable to set.
$value | The value to set. This can be any PHP data type; these functions take care of serialization as necessary.
See Also
variable_del()
variable_get()

Definition at line 973 of file bootstrap.inc.

References $conf, $name, $value, cache_clear_all(), and db_merge().

Referenced by _book_install_type_create(), _color_render_images(), _drupal_flush_css_js(), _locale_invalidate_js(), _locale_rebuild_js(), _menu_router_save(), _menu_set_expanded_menus(), _node_index_node(), _update_cron_notify(), _update_process_fetch_task(), aggregator_update_7001(), authorize_filetransfer_form_submit(), block_example_block_save(), block_update_7004(), blog_block_save(), book_block_save(), book_node_type_update(), DrupalDatabaseCache\clear(), color_scheme_form_submit(), comment_block_save(), comment_update_7000(), comment_update_index(), contact_update_7000(), cron_example_cron(), cron_example_form_cron_run_submit(), dashboard_disable(), drupal_build_css_cache(), drupal_build_js_cache(), drupal_cron_run(), drupal_get_private_key(), drupal_http_request(), drupal_path_alias_whitelist_rebuild(), field_attach_rename_bundle(), field_bundle_settings(), field_ui_field_attach_create_bundle(), field_update_7002(), file_directory_temp(), filter_install(), filter_update_7005(), form_example_element_demo_form_submit(), forum_block_save(), forum_enable(), forum_form_submit(), forum_install(), forum_taxonomy_term_delete(), DrupalDatabaseCache\garbageCollection(), hook_block_save(), hook_cron(), hook_field_attach_create_bundle(), hook_field_attach_delete_bundle(), hook_field_attach_rename_bundle(), hook_image_style_delete(), hook_image_style_save(), hook_menu_delete(), hook_menu_insert(), hook_menu_update(), hook_modules_installed(), hook_node_type_update(), hook_update_index(), image_example_image_style_delete(), image_example_image_style_save(), image_example_install(), image_example_style_form_submit(), image_system_file_system_settings_submit(), install_configure_form_submit(), install_finished(), install_import_locales(), install_run_task(), install_run_tasks(), install_system_module(), language_negotiation_set(), language_types_disable(), language_types_set(), locale_add_language(), locale_js_alter(), locale_languages_configure_form_submit(), locale_languages_delete_form_submit(), locale_languages_edit_form_submit(), locale_languages_overview_form_submit(), locale_update_7001(), locale_update_7003(), TestingMailSystem\mail(), menu_delete(), menu_rebuild(), menu_save(), menu_update_7000(), menu_update_7001(), menu_update_7003(), minimal_install(), node_access_needs_rebuild(), node_block_save(), node_type_form_submit(), node_update_7004(), profile_block_save(), search_admin_settings_submit(), DrupalWebTestCase\setUp(), standard_install(), statistics_block_save(), statistics_cron(), statistics_update_index(), system_add_date_format_type_form_submit(), system_check_http_request(), system_image_toolkit_settings(), system_install(), system_settings_form_submit(), system_theme_default(), system_theme_settings_submit(), system_themes_admin_form_submit(), system_update_7001(), system_update_7004(), system_update_7009(), system_update_7013(), system_update_7017(), system_update_7033(), system_update_7034(), system_update_7046(), system_update_7047(), system_update_7049(), system_update_7066(), testing_install(), tracker_cron(), tracker_enable(), tracker_update_7000(), update_authorize_install_batch_finished(), update_authorize_update_batch_finished(), update_batch(), update_finished(), update_fix_d7_requirements(), update_manager_update_ready_form_submit(), update_prepare_d7_bootstrap(), update_settings_submit(), user_block_save(), user_image_style_save(), user_update_7002(), user_update_7003(), user_update_7008(), and user_update_7017().

watchdog | ( | $type,
 |  | $message,
 |  | $variables = array(),
 |  | $severity = WATCHDOG_NOTICE,
 |  | $link = NULL
 | ) |

Logs a system message.

Parameters
$type | The category to which this message belongs. Can be any string, but the general practice is to use the name of the module calling watchdog().
$message | The message to store in the log. Keep $message translatable by not concatenating dynamic values into it! Variables in the message should be added by using placeholder strings alongside the variables argument to declare the value of the placeholders. See t() for documentation on how $message and $variables interact.
$variables | Array of variables to replace in the message on display or NULL if message is already translated or not possible to translate.
$severity The severity of the message; one of the following values as defined in RFC 3164:
  • WATCHDOG_EMERGENCY: Emergency, system is unusable.
  • WATCHDOG_ALERT: Alert, action must be taken immediately.
  • WATCHDOG_CRITICAL: Critical conditions.
  • WATCHDOG_ERROR: Error conditions.
  • WATCHDOG_WARNING: Warning conditions.
  • WATCHDOG_NOTICE: (default) Normal but significant conditions.
  • WATCHDOG_INFO: Informational messages.
  • WATCHDOG_DEBUG: Debug-level messages.
$link | A link to associate with the message.
See Also
watchdog_severity_levels()
hook_watchdog()

Definition at line 1704 of file bootstrap.inc.

References $module, ip_address(), module_implements(), module_invoke(), and request_uri().

Referenced by _drupal_log_error(), _form_validate(), _locale_export_po(), _locale_import_po(), _locale_rebuild_js(), _node_query_node_access_alter(), _user_cancel(), action_example_basic_action(), action_example_node_sticky_action(), action_example_unblock_user_action(), actions_do(), actions_save(), actions_synchronize(), aggregator_aggregator_fetch(), aggregator_form_category_submit(), aggregator_form_feed_submit(), aggregator_parse_feed(), aggregator_refresh(), ajax_get_form(), authorize_access_denied_page(), book_admin_edit_submit(), check_markup(), comment_confirm_delete_submit(), comment_form_submit(), comment_multiple_delete_confirm_submit(), comment_publish_action(), comment_save_action(), comment_unpublish_action(), comment_unpublish_by_keyword_action(), contact_category_delete_form_submit(), contact_category_edit_form_submit(), contact_personal_form_submit(), contact_site_form_submit(), cron_example_cron(), cron_example_queue_report_work(), drupal_chmod(), drupal_cron_cleanup(), drupal_cron_run(), drupal_deliver_html_page(), drupal_deliver_page(), drupal_mail(), drupal_uninstall_modules(), file_copy(), file_create_htaccess(), file_delete(), file_managed_file_save_upload(), file_move(), file_save_data(), file_save_upload(), file_unmanaged_copy(), file_unmanaged_delete(), forum_confirm_delete_submit(), hook_file_copy(), hook_file_insert(), hook_file_move(), hook_file_update(), image_crop_effect(), image_desaturate_effect(), image_example_colorize_effect(), image_gd_desaturate(), image_gd_rotate(), image_resize_effect(), image_rotate_effect(), image_scale_and_crop_effect(), image_scale_effect(), image_style_create_derivative(), image_style_deliver(), image_toolkit_invoke(), locale_add_language(), locale_languages_delete_form_submit(), locale_translate_edit_form_validate(), locale_translate_import_form_submit(), menu_delete_menu_confirm_submit(), menu_item_delete_form_submit(), module_disable(), module_enable(), node_assign_owner_action(), node_delete_confirm_submit(), node_form_submit(), node_make_sticky_action(), node_make_unsticky_action(), node_multiple_delete_confirm_submit(), node_promote_action(), node_publish_action(), node_revision_delete_confirm_submit(), node_revision_revert_confirm_submit(), node_save_action(), node_type_delete_confirm_submit(), node_type_form_submit(), node_unpromote_action(), node_unpublish_action(), node_unpublish_by_keyword_action(), openid_verify_assertion_nonce(), profile_field_delete_submit(), profile_field_form_submit(), search_view(), system_actions_delete_form_submit(), system_block_ip_action(), system_check_directory(), system_cron(), system_ip_blocking_delete_submit(), system_send_email_action(), taxonomy_form_term_submit(), taxonomy_form_vocabulary_submit(), taxonomy_term_confirm_delete_submit(), taxonomy_vocabulary_confirm_delete_submit(), taxonomy_vocabulary_confirm_reset_alphabetical_submit(), theme(), tracker_cron(), trigger_unassign_submit(), update_access_denied_page(), user_admin_settings(), user_block_user_action(), user_cancel(), user_cancel_confirm_form_submit(), user_login_final_validate(), user_login_finalize(), user_logout(), user_pass_reset(), user_pass_submit(), user_register_submit(), user_user_operations(), and watchdog_exception().

watchdog_exception | ( |  | $type,
 |  | Exception | $exception,
 |  |  | $message = NULL,
 |  |  | $variables = array(),
 |  |  | $severity = WATCHDOG_ERROR,
 |  |  | $link = NULL
 | ) |  |

Logs an exception.

This is a wrapper function for watchdog() which automatically decodes an exception.

Parameters
$type | The category to which this message belongs.
$exception | The exception that is going to be logged.
$message | The message to store in the log. If empty, a text that contains all useful information about the passed-in exception is used.
$variables | Array of variables to replace in the message on display. Defaults to the return value of drupal_decode_exception().
$severity | The severity of the message, as per RFC 3164.
$link | A link to associate with the message.
See Also
watchdog()
drupal_decode_exception()

Definition at line 1654 of file bootstrap.inc.

References _drupal_decode_exception(), DRUPAL_ROOT, and watchdog().

Referenced by _registry_update(), block_admin_configure_submit(), block_admin_display_form_submit(), comment_delete_multiple(), comment_save(), EntityExampleBasicController\delete_multiple(), drupal_cron_run(), menu_rebuild(), node_delete_multiple(), node_save(), taxonomy_term_delete(), taxonomy_vocabulary_delete(), update_do_one(), user_delete_multiple(), and user_save().

Variable Documentation

const CACHE_PERMANENT 0

Indicates that the item should never be removed unless explicitly selected.

The item may be removed using cache_clear_all() with a cache ID.

Definition at line 48 of file bootstrap.inc.

Referenced by cache_example_form_create_expiring_item(), DrupalDatabaseCache\clear(), drupal_render_cache_set(), DrupalDatabaseCache\garbageCollection(), and DrupalDatabaseCache\prepareItem().

const CACHE_TEMPORARY -1

Indicates that the item should be removed at the next general cache wipe.

Definition at line 53 of file bootstrap.inc.

Referenced by _block_render_blocks(), and drupal_page_set_cache().

const CHECK_PLAIN 0

Flag used to indicate that text is not sanitized, so run check_plain().

See Also
drupal_set_title()

Definition at line 225 of file bootstrap.inc.

const DRUPAL_ANONYMOUS_RID 1

Role ID for anonymous users; should match what's in the "role" table.

Definition at line 162 of file bootstrap.inc.

Referenced by UserController\attachLoad(), drupal_anonymous_user(), minimal_install(), standard_install(), testing_install(), theme_user_admin_roles(), user_admin_role(), user_admin_settings(), user_install(), user_role_edit_access(), user_roles(), and user_save().

const DRUPAL_AUTHENTICATED_RID 2

Role ID for authenticated users; should match what's in the "role" table.

Definition at line 167 of file bootstrap.inc.

Referenced by _drupal_session_read(), UserController\attachLoad(), comment_node_update_index(), contact_update_7002(), minimal_install(), standard_install(), system_update_7029(), testing_install(), theme_comment_post_forbidden(), theme_user_admin_roles(), user_account_form(), user_admin_role(), user_admin_settings(), user_build_filter_query(), user_filters(), user_install(), user_role_edit_access(), user_roles(), user_save(), and user_user_operations().

const DRUPAL_BOOTSTRAP_CONFIGURATION 0

End of "defgroup logging_severity_levels". First bootstrap phase: initialize configuration.

Definition at line 122 of file bootstrap.inc.

Referenced by drupal_bootstrap(), install_begin_request(), and update_prepare_d7_bootstrap().

const DRUPAL_BOOTSTRAP_DATABASE 2

Third bootstrap phase: initialize database layer.

Definition at line 132 of file bootstrap.inc.

Referenced by drupal_bootstrap(), drupal_theme_initialize(), and update_prepare_d7_bootstrap().

const DRUPAL_BOOTSTRAP_FULL 7

Final bootstrap phase: Drupal is fully loaded; validate and fix input data.

Definition at line 157 of file bootstrap.inc.

Referenced by _drupal_log_error(), ajax_footer(), drupal_bootstrap(), drupal_exit(), drupal_get_complete_schema(), install_bootstrap_full(), and module_hook_info().

const DRUPAL_BOOTSTRAP_LANGUAGE 6

Seventh bootstrap phase: find out language of the page.

Definition at line 152 of file bootstrap.inc.

Referenced by drupal_bootstrap().

const DRUPAL_BOOTSTRAP_PAGE_CACHE 1

Second bootstrap phase: try to serve a cached page.

Definition at line 127 of file bootstrap.inc.

Referenced by drupal_bootstrap().

const DRUPAL_BOOTSTRAP_PAGE_HEADER 5

Sixth bootstrap phase: set up the page header.

Definition at line 147 of file bootstrap.inc.

Referenced by drupal_bootstrap().

const DRUPAL_BOOTSTRAP_SESSION 4

Fifth bootstrap phase: initialize session handling.

Definition at line 142 of file bootstrap.inc.

Referenced by drupal_bootstrap(), and statistics_exit().

const DRUPAL_BOOTSTRAP_VARIABLES 3

Fourth bootstrap phase: initialize the variable system.

Definition at line 137 of file bootstrap.inc.

Referenced by _drupal_bootstrap_page_cache(), drupal_bootstrap(), statistics_exit(), and update_prepare_d7_bootstrap().

const DRUPAL_CORE_COMPATIBILITY '7.x'

Core API compatibility.

Definition at line 16 of file bootstrap.inc.

Referenced by _system_modules_build_row(), _update_build_fetch_url(), drupal_parse_dependency(), drupal_system_listing(), system_modules(), system_requirements(), system_themes_page(), theme_system_themes_page(), update_check_incompatibility(), and update_verify_update_archive().

const DRUPAL_KILOBYTE 1024

The number of bytes in a kilobyte.

For more information, visit http://en.wikipedia.org/wiki/Kilobyte.

Definition at line 174 of file bootstrap.inc.

Referenced by format_size(), and parse_size().

const DRUPAL_MINIMUM_PHP '5.2.4'

Minimum supported version of PHP.

Definition at line 21 of file bootstrap.inc.

Referenced by _system_rebuild_module_data(), _system_rebuild_theme_data(), hook_requirements(), install_profile_info(), system_requirements(), update_fix_d7_install_profile(), and update_prepare_d7_bootstrap().

const DRUPAL_MINIMUM_PHP_MEMORY_LIMIT '32M'

Minimum recommended value of PHP memory_limit.

Definition at line 26 of file bootstrap.inc.

Referenced by system_requirements().

const DRUPAL_PHP_FUNCTION_PATTERN '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'

Regular expression to match PHP function names.

See Also
http://php.net/manual/language.functions.php

Definition at line 249 of file bootstrap.inc.

Referenced by _menu_router_build(), _system_rebuild_module_data(), _system_rebuild_theme_data(), drupal_get_filename(), drupal_required_modules(), drupal_verify_profile(), and update_verify_update_archive().

const ERROR_REPORTING_DISPLAY_ALL 2

Error reporting level: display all messages.

Definition at line 41 of file bootstrap.inc.

Referenced by error_displayable(), and system_logging_settings().

const ERROR_REPORTING_DISPLAY_SOME 1

Error reporting level: display errors and warnings.

Definition at line 36 of file bootstrap.inc.

Referenced by error_displayable(), and system_logging_settings().

const ERROR_REPORTING_HIDE 0

Error reporting level: display no errors.

Definition at line 31 of file bootstrap.inc.

Referenced by system_logging_settings().

const LANGUAGE_LTR 0

Language written left to right. Possible value of $language->direction.

Definition at line 201 of file bootstrap.inc.

Referenced by _locale_languages_common_controls(), install_import_locales(), and locale_add_language().

const LANGUAGE_NONE 'und'

The language code used when no language is explicitly assigned.

Defined by ISO639-2 for "Undetermined".

Definition at line 181 of file bootstrap.inc.

Referenced by _translation_tab_access(), book_admin_edit_submit(), comment_form(), comment_submit(), comment_update_7006(), drupal_lookup_path(), DrupalWebTestCase\drupalCreateNode(), field_available_languages(), field_content_languages(), field_default_prepare_translation(), field_language(), field_ui_default_value_widget(), field_ui_field_edit_form_submit(), field_ui_field_edit_form_validate(), language_fallback_get_candidates(), locale_form_comment_form_alter(), locale_form_node_form_alter(), locale_form_path_admin_form_alter(), node_add(), node_admin_nodes(), node_filter_form(), node_filters(), node_update_7006(), node_update_7009(), node_update_7012(), path_admin_form_validate(), path_admin_overview(), path_form_node_form_alter(), path_form_taxonomy_form_term_alter(), path_node_insert(), path_save(), path_taxonomy_term_insert(), path_taxonomy_term_update(), system_update_7048(), system_update_7061(), taxonomy_update_7005(), template_preprocess_search_result(), translation_form_node_form_alter(), and translation_language_switch_links_alter().

const LANGUAGE_RTL 1

Language written right to left. Possible value of $language->direction.

Definition at line 206 of file bootstrap.inc.

Referenced by _locale_get_predefined_list(), _locale_languages_common_controls(), locale_css_alter(), locale_languages_overview_form(), locale_library_alter(), and template_preprocess_book_export_html().

const LANGUAGE_TYPE_CONTENT 'language_content'

The type of language used to define the content language.

Definition at line 186 of file bootstrap.inc.

Referenced by drupal_language_types(), hook_language_switch_links_alter(), locale_language_negotiation_info(), locale_language_types_info(), and locale_update_7001().

const LANGUAGE_TYPE_INTERFACE 'language'

The type of language used to select the user interface.

Definition at line 191 of file bootstrap.inc.

Referenced by drupal_language_types(), locale_language_negotiation_info(), locale_language_selector_form(), locale_language_types_info(), locale_update_7001(), system_update_7004(), translation_language_switch_links_alter(), translation_node_overview(), and translation_node_view().

const LANGUAGE_TYPE_URL 'language_url'

The type of language used for URLs.

Definition at line 196 of file bootstrap.inc.

Referenced by drupal_language_types(), locale_language_negotiation_info(), locale_language_types_info(), locale_update_7001(), and locale_update_7002().

const PASS_THROUGH -1

Flag used to indicate that text has already been sanitized.

See Also
drupal_set_title()

Definition at line 232 of file bootstrap.inc.

Referenced by _batch_progress_page_js(), _batch_progress_page_nojs(), _drupal_bootstrap_page_cache(), block_admin_configure(), blog_page_user(), comment_edit_page(), comment_preview(), confirm_form(), contact_personal_form(), drupal_set_title(), image_effect_form(), image_field_formatter_settings_form(), image_field_formatter_settings_summary(), image_field_widget_settings_form(), image_style_delete_form(), image_style_form(), image_style_options(), install_finished(), node_add(), node_page_default(), node_page_edit(), node_preview(), node_revision_overview(), node_show(), profile_browse(), profile_field_form(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), translation_node_overview(), and user_admin_settings().

const REGISTRY_RESET_LOOKUP_CACHE 1

Signals that the registry lookup cache should be reset.

Definition at line 237 of file bootstrap.inc.

Referenced by _registry_check_code(), and _registry_update().

const REGISTRY_WRITE_LOOKUP_CACHE 2

Signals that the registry lookup cache should be written to storage.

Definition at line 242 of file bootstrap.inc.

Referenced by _registry_check_code(), and drupal_page_footer().

const REQUEST_TIME (int) $_SERVER['REQUEST_TIME']

Time of the current request in seconds elapsed since the Unix Epoch.

This differs from $_SERVER['REQUEST_TIME'], which is stored as a float since PHP 5.4.0. Float timestamps confuse most PHP functions (including date_create()).

See Also
http://php.net/manual/reserved.variables.server.php
http://php.net/manual/function.time.php

Definition at line 218 of file bootstrap.inc.

Referenced by _drupal_flush_css_js(), _drupal_session_delete_cookie(), _drupal_session_garbage_collection(), _drupal_session_write(), _update_cache_set(), _update_create_fetch_task(), _update_cron_notify(), _update_get_cached_available_releases(), aggregator_aggregator_process(), aggregator_cron(), aggregator_expire(), aggregator_refresh(), aggregator_view(), batch_process(), DrupalDatabaseCache\clear(), comment_preview(), comment_save(), comment_submit(), db_ignore_slave(), drupal_cache_system_paths(), drupal_cron_run(), drupal_delete_file_if_stale(), drupal_get_js(), drupal_page_header(), drupal_page_set_cache(), drupal_session_commit(), drupal_session_regenerate(), drupal_valid_test_ua(), DrupalWebTestCase\drupalCreateNode(), file_save(), flood_is_allowed(), flood_register_event(), form_process_date(), form_set_cache(), DrupalDatabaseCache\garbageCollection(), hook_cron(), hook_entity_insert(), hook_entity_presave(), hook_entity_update(), hook_requirements(), hook_search_reset(), locale_date_format_form(), node_object_prepare(), node_preview(), node_save(), node_search_reset(), node_submit(), node_tag_new(), openid_association(), openid_cron(), poll_cron(), poll_vote(), DrupalDatabaseCache\set(), statistics_cron(), statistics_exit(), statistics_top_referrers(), system_add_date_format_type_form(), system_configure_date_formats_form(), system_cron(), system_cron_settings(), system_date_delete_format_form(), system_date_delete_format_form_submit(), system_date_time_formats(), system_date_time_lookup(), system_date_time_settings(), system_init(), system_requirements(), system_time_zones(), system_token_info(), system_tokens(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_item(), template_preprocess_aggregator_summary_item(), template_preprocess_forum_submitted(), theme_aggregator_page_opml(), theme_comment_block(), theme_image_style_preview(), theme_update_last_check(), tracker_page(), update_calculate_project_data(), update_cron(), update_delete_file_if_stale(), update_get_projects(), update_project_cache(), user_admin_account(), user_block_view(), user_cancel_confirm(), user_cancel_url(), user_cookie_delete(), user_cookie_save(), user_external_login_register(), user_install(), user_login_finalize(), user_pass_reset(), user_pass_reset_url(), user_save(), and user_user_view().

const VERSION '7.26'

The current system version.

Definition at line 11 of file bootstrap.inc.

Referenced by _drupal_default_html_head(), hook_requirements(), locale(), system_library(), and system_requirements().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/cache-install.inc File Reference

  • includes
Classes
cache-install.inc File Reference

Go to the source code of this file.

Classes

class DrupalFakeCache

Detailed Description

Provides a stub cache implementation to be used during installation.

Definition in file cache-install.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/cache.inc File Reference

  • includes
Classes | Functions
cache.inc File Reference

Go to the source code of this file.

Classes

interface | DrupalCacheInterface
class | DrupalDatabaseCache

Functions

_cache_get_object ($bin)
cache_get ($cid, $bin= 'cache')
cache_get_multiple (array &$cids, $bin= 'cache')
cache_set ($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
cache_clear_all ($cid=NULL, $bin=NULL, $wildcard=FALSE)
cache_is_empty ($bin)

Detailed Description

Functions and interfaces for cache handling.

Definition in file cache.inc.

Function Documentation

_cache_get_object ( $bin )

Gets the cache object for a cache bin.

By default, this returns an instance of the DrupalDatabaseCache class. Classes implementing DrupalCacheInterface can register themselves both as a default implementation and for specific bins.

Parameters
$bin The cache bin for which the cache object should be returned.
Returns
DrupalCacheInterface The cache object associated with the specified bin.
See Also
DrupalCacheInterface

Definition at line 22 of file cache.inc.

References variable_get().

Referenced by cache_clear_all(), cache_get(), cache_get_multiple(), cache_is_empty(), and cache_set().

cache_clear_all | ( | $cid = NULL,
 |  | $bin = NULL,
 |  | $wildcard = FALSE
 | ) |

Expires data from the cache.

If called with the arguments $cid and $bin set to NULL or omitted, then expirable entries will be cleared from the cache_page and cache_block bins, and the $wildcard argument is ignored.

Parameters
$cid | If set, the cache ID or an array of cache IDs. Otherwise, all cache entries that can expire are deleted. The $wildcard argument will be ignored if set to NULL.
$bin | If set, the cache bin to delete from. Mandatory argument if $cid is set.
$wildcard | If TRUE, the $cid argument must contain a string value and cache IDs starting with $cid are deleted in addition to the exact cache ID specified by $cid. If $wildcard is TRUE and $cid is '*', the entire cache is emptied.

Definition at line 155 of file cache.inc.

References _cache_get_object(), and module_exists().

Referenced by _field_info_collate_types(), _locale_import_po(), _menu_clear_page_cache(), _node_access_rebuild_batch_finished(), _user_cancel(), aggregator_aggregator_parse(), block_add_block_form_submit(), block_admin_configure_submit(), block_admin_display_form_submit(), block_custom_block_delete_submit(), cache_example_form_cache_clearing(), cache_example_form_expire_files(), comment_admin_overview_submit(), comment_confirm_delete_submit(), comment_form_submit(), comment_multiple_delete_confirm_submit(), comment_save_action(), drupal_flush_all_caches(), drupal_get_complete_schema(), drupal_process_form(), drupal_theme_rebuild(), entity_info_cache_clear(), field_attach_delete(), field_attach_update(), field_cache_clear(), filter_format_disable(), filter_format_save(), filter_formats_reset(), FieldInfo\flush(), forum_form_submit(), forum_update_7003(), hook_image_style_flush(), image_example_style_flush(), image_style_flush(), locale(), locale_languages_delete_form_submit(), locale_languages_overview_form_submit(), locale_translate_delete_form_submit(), locale_translate_edit_form_submit(), menu_cache_clear(), menu_cache_clear_all(), menu_update_7003(), module_implements(), node_access_rebuild(), node_admin_nodes_submit(), node_delete_confirm_submit(), node_form_submit(), node_multiple_delete_confirm_submit(), node_type_cache_reset(), poll_vote(), profile_admin_overview_submit(), profile_field_delete_submit(), profile_field_form_submit(), DrupalWebTestCase\refreshVariables(), simpletest_clean_environment(), system_clear_page_cache_submit(), system_cron(), system_list_reset(), system_theme_settings_submit(), taxonomy_form_term_submit(), taxonomy_term_confirm_delete_submit(), taxonomy_vocabulary_confirm_delete_submit(), taxonomy_vocabulary_delete(), taxonomy_vocabulary_save(), update_info_page(), user_admin_permissions_submit(), user_profile_form_submit(), variable_del(), and variable_set().

cache_get | ( | $cid,
 |  | $bin = 'cache'
 | ) |

Returns data from the persistent cache.

Data may be stored as either plain text or as serialized data. cache_get will automatically return unserialized objects and arrays.

Parameters
$cid | The cache ID of the data to retrieve.
$bin | The cache bin to store the data in. Valid core values are 'cache_block', 'cache_bootstrap', 'cache_field', 'cache_filter', 'cache_form', 'cache_menu', 'cache_page', 'cache_path', 'cache_update' or 'cache' for the default cache.
Returns
The cache or FALSE on failure.
See Also
cache_set()

Definition at line 55 of file cache.inc.

References _cache_get_object().

Referenced by DrupalCacheArray\__construct(), _field_info_collate_types(), _menu_build_tree(), _node_types_build(), _registry_check_code(), _registry_update(), _theme_build_registry(), _theme_load_registry(), archiver_get_info(), book_menu_subtree_data(), cache_example_page_form(), check_markup(), drupal_get_complete_schema(), drupal_lookup_path(), drupal_page_get_cache(), drupal_render_cache_get(), entity_get_info(), filter_formats(), filter_list_format(), form_get_cache(), FieldInfo\getBundleExtraFields(), FieldInfo\getBundleInstances(), FieldInfo\getFieldMap(), FieldInfo\getFields(), FieldInfo\getInstances(), image_effect_definitions(), image_styles(), locale(), menu_load_all(), menu_local_tasks(), menu_tree_all_data(), menu_tree_page_data(), module_hook_info(), module_implements(), DrupalCacheArray\set(), simpletest_test_get_all(), system_list(), and variable_initialize().

cache_get_multiple | ( | array & | $cids,
 |  |  | $bin = 'cache'
 | ) |  |

Returns data from the persistent cache when given an array of cache IDs.

Parameters
$cids | An array of cache IDs for the data to retrieve. This is passed by reference, and will have the IDs successfully returned from cache removed.
$bin | The cache bin where the data is stored.
Returns
An array of the items successfully returned from cache indexed by cid.

Definition at line 71 of file cache.inc.

References _cache_get_object().

Referenced by _block_render_blocks(), and field_attach_load().

cache_is_empty ( $bin )

Checks if a cache bin is empty.

A cache bin is considered empty if it does not contain any valid data for any cache ID.

Parameters
$bin The cache bin to check.
Returns
TRUE if the cache bin specified is empty.

Definition at line 180 of file cache.inc.

References _cache_get_object().

cache_set | ( | $cid,
 |  | $data,
 |  | $bin = 'cache',
 |  | $expire = CACHE_PERMANENT
 | ) |

Stores data in the persistent cache.

The persistent cache is split up into several cache bins. In the default cache implementation, each cache bin corresponds to a database table by the same name. Other implementations might want to store several bins in data structures that get flushed together. While it is not a problem for most cache bins if the entries in them are flushed before their expire time, some might break functionality or are extremely expensive to recalculate. The other bins are expired automatically by core. Contributed modules can add additional bins and get them expired automatically by implementing hook_flush_caches().

The reasons for having several bins are as follows:

  • Smaller bins mean smaller database tables and allow for faster selects and inserts.
  • We try to put fast changing cache items and rather static ones into different bins. The effect is that only the fast changing bins will need a lot of writes to disk. The more static bins will also be better cacheable with MySQL's query cache.
Parameters
$cid | The cache ID of the data to store.
$data | The data to store in the cache. Complex data types will be automatically serialized before insertion. Strings will be stored as plain text and are not serialized.
$bin The cache bin to store the data in. Valid core values are:
  • cache: (default) Generic cache storage bin (used for theme registry, locale date, list of simpletest tests, etc.).
  • cache_block: Stores the content of various blocks.
  • cache_bootstrap: Stores the class registry, the system list of modules, the list of which modules implement which hooks, and the Drupal variable list.
  • cache_field: Stores the field data belonging to a given object.
  • cache_filter: Stores filtered pieces of content.
  • cache_form: Stores multistep forms. Flushing this bin means that some forms displayed to users lose their state and the data already submitted to them. This bin should not be flushed before its expired time.
  • cache_menu: Stores the structure of visible navigation menus per page.
  • cache_page: Stores generated pages for anonymous users. It is flushed very often, whenever a page changes, at least for every node and comment submission. This is the only bin affected by the page cache setting on the administrator panel.
  • cache_path: Stores the system paths that have an alias.
$expire One of the following values:
  • CACHE_PERMANENT: Indicates that the item should never be removed unless explicitly told to using cache_clear_all() with a cache ID.
  • CACHE_TEMPORARY: Indicates that the item should be removed at the next general cache wipe.
  • A Unix timestamp: Indicates that the item should be kept at least until the given time, after which it behaves like CACHE_TEMPORARY.
See Also
_update_cache_set()
cache_get()

Definition at line 133 of file cache.inc.

References _cache_get_object().

Referenced by _block_render_blocks(), _field_info_collate_types(), _menu_build_tree(), _node_types_build(), _registry_check_code(), _registry_update(), _theme_build_registry(), _theme_save_registry(), archiver_get_info(), book_menu_subtree_data(), cache_example_form_create_expiring_item(), cache_example_page_form(), check_markup(), drupal_cache_system_paths(), drupal_get_complete_schema(), drupal_page_set_cache(), drupal_render_cache_set(), entity_get_info(), field_attach_load(), filter_formats(), filter_list_format(), form_set_cache(), FieldInfo\getBundleExtraFields(), FieldInfo\getBundleInstances(), FieldInfo\getFieldMap(), FieldInfo\getFields(), FieldInfo\getInstances(), image_effect_definitions(), image_styles(), locale(), menu_load_all(), menu_local_tasks(), menu_tree_all_data(), menu_tree_page_data(), module_hook_info(), module_implements(), module_implements_write_cache(), DrupalCacheArray\set(), simpletest_test_get_all(), system_list(), and variable_initialize().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/common.inc File Reference

  • includes
Functions | Variables
common.inc File Reference

Go to the source code of this file.

Functions

drupal_add_region_content ($region=NULL, $data=NULL)
drupal_get_region_content ($region=NULL, $delimiter= ' ')
drupal_get_profile ()
drupal_set_breadcrumb ($breadcrumb=NULL)
drupal_get_breadcrumb ()
drupal_get_rdf_namespaces ()
drupal_add_html_head ($data=NULL, $key=NULL)
_drupal_default_html_head ()
drupal_get_html_head ()
drupal_add_feed ($url=NULL, $title= '')
drupal_get_feeds ($delimiter="\n")
drupal_get_query_parameters (array $query=NULL, array $exclude=array('q'), $parent= '')
drupal_get_query_array ($query)
drupal_http_build_query (array $query, $parent= '')
drupal_get_destination ()
drupal_parse_url ($url)
drupal_encode_path ($path)
drupal_goto ($path= '', array $options=array(), $http_response_code=302)
drupal_site_offline ()
drupal_not_found ()
drupal_access_denied ()
drupal_http_request ($url, array $options=array())
_drupal_http_use_proxy ($host)
_fix_gpc_magic (&$item)
_fix_gpc_magic_files (&$item, $key)
fix_gpc_magic ()
valid_email_address ($mail)
valid_url ($url, $absolute=FALSE)
flood_register_event ($name, $window=3600, $identifier=NULL)
flood_clear_event ($name, $identifier=NULL)
flood_is_allowed ($name, $threshold, $window=3600, $identifier=NULL)
drupal_strip_dangerous_protocols ($uri)
check_url ($uri)
filter_xss_admin ($string)
filter_xss ($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
_filter_xss_split ($m, $store=FALSE)
_filter_xss_attributes ($attr)
filter_xss_bad_protocol ($string, $decode=TRUE)
format_rss_channel ($title, $link, $description, $items, $langcode=NULL, $args=array())
format_rss_item ($title, $link, $description, $args=array())
format_xml_elements ($array)
format_plural ($count, $singular, $plural, array $args=array(), array $options=array())
parse_size ($size)
format_size ($size, $langcode=NULL)
format_interval ($interval, $granularity=2, $langcode=NULL)
format_date ($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
date_iso8601 ($date)
_format_date_callback (array $matches=NULL, $new_langcode=NULL)
format_username ($account)
url ($path=NULL, array $options=array())
url_is_external ($path)
drupal_http_header_attributes (array $attributes=array())
drupal_attributes (array $attributes=array())
l ($text, $path, array $options=array())
drupal_deliver_page ($page_callback_result, $default_delivery_callback=NULL)
drupal_deliver_html_page ($page_callback_result)
drupal_page_footer ()
drupal_exit ($destination=NULL)
drupal_map_assoc ($array, $function=NULL)
drupal_set_time_limit ($time_limit)
drupal_get_path ($type, $name)
base_path ()
drupal_add_html_head_link ($attributes, $header=FALSE)
drupal_add_css ($data=NULL, $options=NULL)
drupal_get_css ($css=NULL, $skip_alter=FALSE)
drupal_sort_css_js ($a, $b)
drupal_group_css ($css)
drupal_aggregate_css (&$css_groups)
drupal_pre_render_styles ($elements)
drupal_build_css_cache ($css)
_drupal_build_css_path ($matches, $base=NULL)
drupal_load_stylesheet ($file, $optimize=NULL, $reset_basepath=TRUE)
drupal_load_stylesheet_content ($contents, $optimize=FALSE)
_drupal_load_stylesheet ($matches)
drupal_clear_css_cache ()
drupal_delete_file_if_stale ($uri)
drupal_clean_css_identifier ($identifier, $filter=array(' '=> '-', '_'=> '-', '/'=> '-', '['=> '-', ']'=> ''))
drupal_html_class ($class)
drupal_html_id ($id)
drupal_region_class ($region)
drupal_add_js ($data=NULL, $options=NULL)
drupal_js_defaults ($data=NULL)
drupal_get_js ($scope= 'header', $javascript=NULL, $skip_alter=FALSE)
drupal_process_attached ($elements, $group=JS_DEFAULT, $dependency_check=FALSE, $every_page=NULL)
drupal_process_states (&$elements)
drupal_add_library ($module, $name, $every_page=NULL)
drupal_get_library ($module, $name=NULL)
drupal_add_tabledrag ($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
drupal_build_js_cache ($files)
drupal_clear_js_cache ()
drupal_json_encode ($var)
drupal_json_decode ($var)
drupal_json_output ($var=NULL)
drupal_get_private_key ()
drupal_get_token ($value= '')
drupal_valid_token ($token, $value= '', $skip_anonymous=FALSE)
_drupal_bootstrap_full ()
drupal_page_set_cache ()
drupal_cron_run ()
drupal_cron_cleanup ()
drupal_system_listing ($mask, $directory, $key= 'name', $min_depth=1)
drupal_set_page_content ($content=NULL)
drupal_pre_render_conditional_comments ($elements)
drupal_pre_render_link ($element)
drupal_pre_render_links ($element)
drupal_pre_render_markup ($elements)
drupal_render_page ($page)
drupal_render (&$elements)
drupal_render_children (&$element, $children_keys=NULL)
render (&$element)
hide (&$element)
show (&$element)
drupal_render_cache_get ($elements)
drupal_render_cache_set (&$markup, $elements)
drupal_render_collect_attached ($elements, $return=FALSE)
drupal_render_cache_by_query ($query, $function, $expire=CACHE_TEMPORARY, $granularity=NULL)
drupal_render_cid_parts ($granularity=NULL)
drupal_render_cid_create ($elements)
element_sort ($a, $b)
element_sort_by_title ($a, $b)
element_info ($type)
element_info_property ($type, $property_name, $default=NULL)
drupal_sort_weight ($a, $b)
drupal_sort_title ($a, $b)
element_property ($key)
element_properties ($element)
element_child ($key)
element_children (&$elements, $sort=FALSE)
element_get_visible_children (array $elements)
element_set_attributes (array &$element, array $map)
drupal_array_diff_assoc_recursive ($array1, $array2)
drupal_array_set_nested_value (array &$array, array $parents, $value, $force=FALSE)
& drupal_array_get_nested_value (array &$array, array $parents, &$key_exists=NULL)
drupal_array_nested_key_exists (array $array, array $parents)
drupal_common_theme ()
drupal_install_schema ($module)
drupal_uninstall_schema ($module)
drupal_get_schema_unprocessed ($module, $table=NULL)
_drupal_schema_initialize (&$schema, $module, $remove_descriptions=TRUE)
drupal_schema_fields_sql ($table, $prefix=NULL)
drupal_write_record ($table, &$record, $primary_keys=array())
drupal_parse_info_file ($filename)
drupal_parse_info_format ($data)
watchdog_severity_levels ()
drupal_explode_tags ($tags)
drupal_implode_tags ($tags)
drupal_flush_all_caches ()
_drupal_flush_css_js ()
debug ($data, $label=NULL, $print_r=FALSE)
drupal_parse_dependency ($dependency)
drupal_check_incompatibility ($v, $current_version)
entity_get_info ($entity_type=NULL)
entity_info_cache_clear ()
entity_extract_ids ($entity_type, $entity)
entity_create_stub_entity ($entity_type, $ids)
entity_load ($entity_type, $ids=FALSE, $conditions=array(), $reset=FALSE)
entity_load_unchanged ($entity_type, $id)
entity_get_controller ($entity_type)
entity_prepare_view ($entity_type, $entities, $langcode=NULL)
entity_uri ($entity_type, $entity)
entity_label ($entity_type, $entity)
entity_language ($entity_type, $entity)
entity_form_field_validate ($entity_type, $form, &$form_state)
entity_form_submit_build_entity ($entity_type, $entity, $form, &$form_state)
xmlrpc ($url, $args, $options=array())
archiver_get_info ()
archiver_get_extensions ()
archiver_get_archiver ($file)
drupal_get_updaters ()
drupal_get_filetransfer_info ()

Variables

const | SAVED_NEW 1
const | SAVED_UPDATED 2
const | SAVED_DELETED 3
const | CSS_SYSTEM -100
const | CSS_DEFAULT 0
const | CSS_THEME 100
const | JS_LIBRARY -100
const | JS_DEFAULT 0
const | JS_THEME 100
const | HTTP_REQUEST_TIMEOUT -1
const | DRUPAL_NO_CACHE -1
const | DRUPAL_CACHE_CUSTOM -2
const | DRUPAL_CACHE_PER_ROLE 0x0001
const | DRUPAL_CACHE_PER_USER 0x0002
const | DRUPAL_CACHE_PER_PAGE 0x0004
const | DRUPAL_CACHE_GLOBAL 0x0008

Detailed Description

Common functions that many Drupal modules will need to reference.

The functions that are critical and need to be available even when serving a cached page are instead located in bootstrap.inc.

Definition in file common.inc.

Function Documentation

_drupal_bootstrap_full ( )

Definition at line 5100 of file common.inc.

References drupal_path_initialize(), drupal_random_bytes(), DRUPAL_ROOT, drupal_theme_initialize(), file_get_stream_wrappers(), fix_gpc_magic(), MAINTENANCE_MODE, menu_set_custom_theme(), module_invoke_all(), module_load_all(), unicode_check(), and variable_get().

Referenced by drupal_bootstrap().

_drupal_build_css_path | ( | $matches,
 |  | $base = NULL
 | ) |

Prefixes all paths within a CSS file for drupal_build_css_cache().

Definition at line 3621 of file common.inc.

References drupal_static().

Referenced by color_scheme_form_submit(), and drupal_build_css_cache().

_drupal_default_html_head ( )

Returns elements that are always displayed in the HEAD tag of the HTML page.

Definition at line 319 of file common.inc.

References VERSION.

Referenced by drupal_add_html_head().

_drupal_flush_css_js ( )

Changes the dummy query string added to all CSS and JavaScript files.

Changing the dummy query string appended to CSS and JavaScript files forces all browsers to reload fresh files.

Definition at line 7495 of file common.inc.

References REQUEST_TIME, and variable_set().

Referenced by drupal_flush_all_caches(), and update_info_page().

_drupal_load_stylesheet ( $matches )

Loads stylesheets recursively and returns contents with corrected paths.

This function is used for recursive loading of stylesheets and returns the stylesheet content with all url() paths corrected.

Definition at line 3763 of file common.inc.

References drupal_load_stylesheet().

_fix_gpc_magic ( & $item )

End of "HTTP handling". Strips slashes from a string or array of strings.

Callback for array_walk() within fix_gpx_magic().

Parameters
$item An individual string or array of strings from superglobals.

Definition at line 1115 of file common.inc.

_fix_gpc_magic_files | ( | & | $item,
 |  |  | $key
 | ) |  |

Strips slashes from $_FILES items.

Callback for array_walk() within fix_gpc_magic().

The tmp_name key is skipped keys since PHP generates single backslashes for file paths on Windows systems.

Parameters
$item | An item from $_FILES.
$key | The key for the item within $_FILES.
See Also
http://php.net/manual/features.file-upload.php#42280

Definition at line 1139 of file common.inc.

archiver_get_archiver ( $file )

Creates the appropriate archiver for the specified file.

Parameters
$file The full path of the archive file. Note that stream wrapper paths are supported, but not remote ones.
Returns
A newly created instance of the archiver class appropriate for the specified file, already bound to that file. If no appropriate archiver class was found, will return FALSE.

Definition at line 8145 of file common.inc.

References archiver_get_info(), drupal_realpath(), and t().

Referenced by update_manager_archive_extract().

archiver_get_extensions ( )

Returns a string of supported archive extensions.

Returns
A space-separated string of extensions suitable for use by the file validation system.

Definition at line 8119 of file common.inc.

References archiver_get_info().

Referenced by update_manager_install_form(), and update_manager_install_form_submit().

archiver_get_info ( )

Retrieves a list of all available archivers.

See Also
hook_archiver_info()
hook_archiver_info_alter()

Definition at line 8092 of file common.inc.

References cache_get(), cache_set(), drupal_alter(), drupal_static(), and module_invoke_all().

Referenced by archiver_get_archiver(), and archiver_get_extensions().

base_path ( )

Returns the base URL path (i.e., directory) of the Drupal installation.

base_path() adds a "/" to the beginning and end of the returned path if the path is not empty. At the very least, this will return "/".

Examples:

  • http://example.com returns "/" because the path is empty.
  • http://example.com/drupal/folder returns "/drupal/folder/".

Definition at line 2817 of file common.inc.

Referenced by _color_rewrite_stylesheet(), color_scheme_form_submit(), drupal_add_js(), file_icon_url(), install_check_requirements(), system_requirements(), template_preprocess_maintenance_page(), template_preprocess_page(), update_authorize_update_batch_finished(), update_helpful_links(), update_info_page(), update_results_page(), and url().

debug | ( | $data,
 |  | $label = NULL,
 |  | $print_r = FALSE
 | ) |

Outputs debug information.

The debug information is passed on to trigger_error() after being converted to a string using _drupal_debug_message().

Parameters
$data | Data to be output.
$label | Label to prefix the data.
$print_r | Flag to switch between print_r() and var_export() for data conversion to string. Set $print_r to TRUE when dealing with a recursive data structure as var_export() will generate an error.

Definition at line 7515 of file common.inc.

References check_plain().

Referenced by FileExampleSessionStreamWrapper\rmdir().

drupal_add_css | ( | $data = NULL,
 |  | $options = NULL
 | ) |

Adds a cascading stylesheet to the stylesheet queue.

Calling drupal_static_reset('drupal_add_css') will clear all cascading stylesheets added so far.

If CSS aggregation/compression is enabled, all cascading style sheets added with $options['preprocess'] set to TRUE will be merged into one aggregate file and compressed by removing all extraneous white space. Preprocessed inline stylesheets will not be aggregated into this single file; instead, they are just compressed upon output on the page. Externally hosted stylesheets are never aggregated or compressed.

The reason for aggregating the files is outlined quite thoroughly here: http://www.die.net/musings/page_load_time/ "Load fewer external objects. Due to request overhead, one bigger file just loads faster than two smaller ones half its size."

$options['preprocess'] should be only set to TRUE when a file is required for all typical visitors and most pages of a site. It is critical that all preprocessed files are added unconditionally on every page, even if the files do not happen to be needed on a page. This is normally done by calling drupal_add_css() in a hook_init() implementation.

Non-preprocessed files should only be added to the page when they are actually needed.

Parameters
$data (optional) The stylesheet data to be added, depending on what is passed through to the $options['type'] parameter:
  • 'file': The path to the CSS file relative to the base_path(), or a stream wrapper URI. For example: "modules/devel/devel.css" or "public://generated_css/stylesheet_1.css". Note that Modules should always prefix the names of their CSS files with the module name; for example, system-menus.css rather than simply menus.css. Themes can override module-supplied CSS files based on their filenames, and this prefixing helps prevent confusing name collisions for theme developers. See drupal_get_css() where the overrides are performed. Also, if the direction of the current language is right-to-left (Hebrew, Arabic, etc.), the function will also look for an RTL CSS file and append it to the list. The name of this file should have an '-rtl.css' suffix. For example, a CSS file called 'mymodule-name.css' will have a 'mymodule-name-rtl.css' file added to the list, if exists in the same directory. This CSS file should contain overrides for properties which should be reversed or otherwise different in a right-to-left display.
  • 'inline': A string of CSS that should be placed in the given scope. Note that it is better practice to use 'file' stylesheets, rather than 'inline', as the CSS would then be aggregated and cached.
  • 'external': The absolute path to an external CSS file that is not hosted on the local server. These files will not be aggregated if CSS aggregation is enabled.
$options (optional) A string defining the 'type' of CSS that is being added in the $data parameter ('file', 'inline', or 'external'), or an array which can have any or all of the following keys:
  • 'type': The type of stylesheet being added. Available options are 'file', 'inline' or 'external'. Defaults to 'file'.
  • 'basename': Force a basename for the file being added. Modules are expected to use stylesheets with unique filenames, but integration of external libraries may make this impossible. The basename of 'modules/node/node.css' is 'node.css'. If the external library "node.js" ships with a 'node.css', then a different, unique basename would be 'node.js.css'.
  • 'group': A number identifying the group in which to add the stylesheet. Available constants are:
    • CSS_SYSTEM: Any system-layer CSS.
    • CSS_DEFAULT: (default) Any module-layer CSS.
    • CSS_THEME: Any theme-layer CSS. The group number serves as a weight: the markup for loading a stylesheet within a lower weight group is output to the page before the markup for loading a stylesheet within a higher weight group, so CSS within higher weight groups take precendence over CSS within lower weight groups.
  • 'every_page': For optimal front-end performance when aggregation is enabled, this should be set to TRUE if the stylesheet is present on every page of the website for users for whom it is present at all. This defaults to FALSE. It is set to TRUE for stylesheets added via module and theme .info files. Modules that add stylesheets within hook_init() implementations, or from other code that ensures that the stylesheet is added to all website pages, should also set this flag to TRUE. All stylesheets within the same group that have the 'every_page' flag set to TRUE and do not have 'preprocess' set to FALSE are aggregated together into a single aggregate file, and that aggregate file can be reused across a user's entire site visit, leading to faster navigation between pages. However, stylesheets that are only needed on pages less frequently visited, can be added by code that only runs for those particular pages, and that code should not set the 'every_page' flag. This minimizes the size of the aggregate file that the user needs to download when first visiting the website. Stylesheets without the 'every_page' flag are aggregated into a separate aggregate file. This other aggregate file is likely to change from page to page, and each new aggregate file needs to be downloaded when first encountered, so it should be kept relatively small by ensuring that most commonly needed stylesheets are added to every page.
  • 'weight': The weight of the stylesheet specifies the order in which the CSS will appear relative to other stylesheets with the same group and 'every_page' flag. The exact ordering of stylesheets is as follows:
    • First by group.
    • Then by the 'every_page' flag, with TRUE coming before FALSE.
    • Then by weight.
    • Then by the order in which the CSS was added. For example, all else being the same, a stylesheet added by a call to drupal_add_css() that happened later in the page request gets added to the page after one for which drupal_add_css() happened earlier in the page request.
  • 'media': The media type for the stylesheet, e.g., all, print, screen. Defaults to 'all'.
  • 'preprocess': If TRUE and CSS aggregation/compression is enabled, the styles will be aggregated and compressed. Defaults to TRUE.
  • 'browsers': An array containing information specifying which browsers should load the CSS item. See drupal_pre_render_conditional_comments() for details.
Returns
An array of queued cascading stylesheets.
See Also
drupal_get_css()

Definition at line 2967 of file common.inc.

References CSS_DEFAULT, and drupal_static().

Referenced by _batch_page(), _drupal_maintenance_theme(), _drupal_theme_initialize(), _locale_translate_language_list(), bartik_preprocess_html(), bartik_preprocess_maintenance_page(), block_admin_demo(), dblog_init(), drupal_get_css(), garland_preprocess_html(), help_main(), hook_init(), js_example_js_weights(), locale_block_view(), locale_language_switcher_session(), locale_translate_seek_screen(), openid_user_identities(), overlay_render_region(), seven_preprocess_html(), simpletest_result_form(), system_add_module_assets(), system_init(), template_process_html(), template_process_maintenance_page(), theme_color_scheme_form(), theme_dashboard(), theme_profile_admin_overview(), theme_simpletest_test_table(), theme_taxonomy_overview_terms(), and theme_update_report().

drupal_add_feed | ( | $url = NULL,
 |  | $title = ''
 | ) |

Adds a feed URL for the current page.

This function can be called as long the HTML header hasn't been sent.

Parameters
$url | An internal system path or a fully qualified external URL of the feed.
$title | The title of the feed.

Definition at line 368 of file common.inc.

References $title, $url, drupal_add_html_head_link(), drupal_static(), theme(), and url().

Referenced by aggregator_page_category(), aggregator_page_last(), blog_page_last(), blog_page_user(), drupal_get_feeds(), node_page_default(), taxonomy_term_page(), and template_preprocess_forums().

drupal_add_html_head | ( | $data = NULL,
 |  | $key = NULL
 | ) |

Adds output to the HEAD tag of the HTML page.

This function can be called as long as the headers aren't sent. Pass no arguments (or NULL for both) to retrieve the currently stored elements.

Parameters
$data | A renderable array. If the '#type' key is not set then 'html_tag' will be added as the default '#type'.
$key | A unique string key to allow implementations of hook_html_head_alter() to identify the element in $data. Required if $data is not NULL.
Returns
An array of all stored HEAD elements.
See Also
theme_html_tag()

Definition at line 299 of file common.inc.

References _drupal_default_html_head(), and drupal_static().

Referenced by _batch_progress_page_nojs(), drupal_add_html_head_link(), drupal_get_html_head(), install_display_output(), rdf_preprocess_node(), rdf_preprocess_taxonomy_term(), and rdf_preprocess_user_profile().

drupal_add_html_head_link | ( | $attributes,
 |  | $header = FALSE
 | ) |

Adds a LINK tag with a distinct 'rel' attribute to the page's HEAD.

This function can be called as long the HTML header hasn't been sent, which on normal pages is up through the preprocess step of theme('html'). Adding a link will overwrite a prior link with the exact same 'rel' and 'href' attributes.

Parameters
$attributes | Associative array of element attributes including 'href' and 'rel'.
$header | Optional flag to determine if a HTTP 'Link:' header should be sent.

Definition at line 2834 of file common.inc.

References $attributes, $header, check_plain(), drupal_add_html_head(), and drupal_http_header_attributes().

Referenced by drupal_add_feed(), node_page_view(), taxonomy_term_page(), template_preprocess_book_navigation(), template_preprocess_html(), and template_preprocess_maintenance_page().

drupal_add_js | ( | $data = NULL,
 |  | $options = NULL
 | ) |

Adds a JavaScript file, setting, or inline code to the page.

The behavior of this function depends on the parameters it is called with. Generally, it handles the addition of JavaScript to the page, either as reference to an existing file or as inline code. The following actions can be performed using this function:

  • Add a file ('file'): Adds a reference to a JavaScript file to the page.
  • Add inline JavaScript code ('inline'): Executes a piece of JavaScript code on the current page by placing the code directly in the page (for example, to tell the user that a new message arrived, by opening a pop up, alert box, etc.). This should only be used for JavaScript that cannot be executed from a file. When adding inline code, make sure that you are not relying on $() being the jQuery function. Wrap your code in
    (function ($) {... })(jQuery);
    or use jQuery() instead of $().
  • Add external JavaScript ('external'): Allows the inclusion of external JavaScript files that are not hosted on the local server. Note that these external JavaScript references do not get aggregated when preprocessing is on.
  • Add settings ('setting'): Adds settings to Drupal's global storage of JavaScript settings. Per-page settings are required by some modules to function properly. All settings will be accessible at Drupal.settings.

Examples:

* drupal_add_js('misc/collapse.js');
* drupal_add_js('misc/collapse.js', 'file');
* drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');
* drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });',
* array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
* );
* drupal_add_js('http://example.com/example.js', 'external');
* drupal_add_js(array('myModule' => array('key' => 'value')), 'setting');
*

Calling drupal_static_reset('drupal_add_js') will clear all JavaScript added so far.

If JavaScript aggregation is enabled, all JavaScript files added with $options['preprocess'] set to TRUE will be merged into one aggregate file. Preprocessed inline JavaScript will not be aggregated into this single file. Externally hosted JavaScripts are never aggregated.

The reason for aggregating the files is outlined quite thoroughly here: http://www.die.net/musings/page_load_time/ "Load fewer external objects. Due to request overhead, one bigger file just loads faster than two smaller ones half its size."

$options['preprocess'] should be only set to TRUE when a file is required for all typical visitors and most pages of a site. It is critical that all preprocessed files are added unconditionally on every page, even if the files are not needed on a page. This is normally done by calling drupal_add_js() in a hook_init() implementation.

Non-preprocessed files should only be added to the page when they are actually needed.

Parameters
$data (optional) If given, the value depends on the $options parameter, or $options['type'] if $options is passed as an associative array:
  • 'file': Path to the file relative to base_path().
  • 'inline': The JavaScript code that should be placed in the given scope.
  • 'external': The absolute path to an external JavaScript file that is not hosted on the local server. These files will not be aggregated if JavaScript aggregation is enabled.
  • 'setting': An associative array with configuration options. The array is merged directly into Drupal.settings. All modules should wrap their actual configuration settings in another variable to prevent conflicts in the Drupal.settings namespace. Items added with a string key will replace existing settings with that key; items with numeric array keys will be added to the existing settings array.
$options (optional) A string defining the type of JavaScript that is being added in the $data parameter ('file'/'setting'/'inline'/'external'), or an associative array. JavaScript settings should always pass the string 'setting' only. Other types can have the following elements in the array:
  • type: The type of JavaScript that is to be added to the page. Allowed values are 'file', 'inline', 'external' or 'setting'. Defaults to 'file'.
  • scope: The location in which you want to place the script. Possible values are 'header' or 'footer'. If your theme implements different regions, you can also use these. Defaults to 'header'.
  • group: A number identifying the group in which to add the JavaScript. Available constants are:
    • JS_LIBRARY: Any libraries, settings, or jQuery plugins.
    • JS_DEFAULT: Any module-layer JavaScript.
    • JS_THEME: Any theme-layer JavaScript. The group number serves as a weight: JavaScript within a lower weight group is presented on the page before JavaScript within a higher weight group.
  • every_page: For optimal front-end performance when aggregation is enabled, this should be set to TRUE if the JavaScript is present on every page of the website for users for whom it is present at all. This defaults to FALSE. It is set to TRUE for JavaScript files that are added via module and theme .info files. Modules that add JavaScript within hook_init() implementations, or from other code that ensures that the JavaScript is added to all website pages, should also set this flag to TRUE. All JavaScript files within the same group and that have the 'every_page' flag set to TRUE and do not have 'preprocess' set to FALSE are aggregated together into a single aggregate file, and that aggregate file can be reused across a user's entire site visit, leading to faster navigation between pages. However, JavaScript that is only needed on pages less frequently visited, can be added by code that only runs for those particular pages, and that code should not set the 'every_page' flag. This minimizes the size of the aggregate file that the user needs to download when first visiting the website. JavaScript without the 'every_page' flag is aggregated into a separate aggregate file. This other aggregate file is likely to change from page to page, and each new aggregate file needs to be downloaded when first encountered, so it should be kept relatively small by ensuring that most commonly needed JavaScript is added to every page.
  • weight: A number defining the order in which the JavaScript is added to the page relative to other JavaScript with the same 'scope', 'group', and 'every_page' value. In some cases, the order in which the JavaScript is presented on the page is very important. jQuery, for example, must be added to the page before any jQuery code is run, so jquery.js uses the JS_LIBRARY group and a weight of -20, jquery.once.js (a library drupal.js depends on) uses the JS_LIBRARY group and a weight of -19, drupal.js uses the JS_LIBRARY group and a weight of -1, other libraries use the JS_LIBRARY group and a weight of 0 or higher, and all other scripts use one of the other group constants. The exact ordering of JavaScript is as follows:
    • First by scope, with 'header' first, 'footer' last, and any other scopes provided by a custom theme coming in between, as determined by the theme.
    • Then by group.
    • Then by the 'every_page' flag, with TRUE coming before FALSE.
    • Then by weight.
    • Then by the order in which the JavaScript was added. For example, all else being the same, JavaScript added by a call to drupal_add_js() that happened later in the page request gets added to the page after one for which drupal_add_js() happened earlier in the page request.
  • defer: If set to TRUE, the defer attribute is set on the <script> tag. Defaults to FALSE.
  • cache: If set to FALSE, the JavaScript file is loaded anew on every page call; in other words, it is not cached. Used only when 'type' references a JavaScript file. Defaults to TRUE.
  • preprocess: If TRUE and JavaScript aggregation is enabled, the script file will be aggregated. Defaults to TRUE.
Returns
The current array of JavaScript files, settings, and in-line code, including Drupal defaults, anything previously added with calls to drupal_add_js(), and this function call's additions.
See Also
drupal_get_js()

Definition at line 4128 of file common.inc.

References base_path(), drupal_add_library(), drupal_js_defaults(), drupal_static(), JS_LIBRARY, and url().

Referenced by _batch_progress_page_js(), _drupal_theme_initialize(), ajax_render(), drupal_add_tabledrag(), drupal_get_js(), drupal_theme_initialize(), file_ajax_upload(), hook_overlay_child_initialize(), hook_overlay_parent_initialize(), install_configure_form(), js_example_js_weights(), menu_form_node_type_form_alter(), node_filter_form(), overlay_close_dialog(), overlay_overlay_parent_initialize(), overlay_render_region(), overlay_trigger_refresh(), system_add_module_assets(), system_clean_url_settings(), system_performance_settings(), system_user_timezone(), theme_color_scheme_form(), theme_profile_admin_overview(), theme_simpletest_test_table(), theme_table(), theme_tableselect(), theme_taxonomy_overview_terms(), and user_admin_settings().

drupal_add_library | ( | $module,
 |  | $name,
 |  | $every_page = NULL
 | ) |

Adds multiple JavaScript or CSS files at the same time.

A library defines a set of JavaScript and/or CSS files, optionally using settings, and optionally requiring another library. For example, a library can be a jQuery plugin, a JavaScript framework, or a CSS framework. This function allows modules to load a library defined/shipped by itself or a depending module, without having to add all files of the library separately. Each library is only loaded once.

Parameters
$module | The name of the module that registered the library.
$name | The name of the library to add.
$every_page | Set to TRUE if this library is added to every page on the site. Only items with the every_page flag set to TRUE can participate in aggregation.
Returns
TRUE if the library was successfully added; FALSE if the library or one of its dependencies could not be added.
See Also
drupal_get_library()
hook_library()
hook_library_alter()

Definition at line 4694 of file common.inc.

References $module, $name, drupal_get_library(), drupal_process_attached(), drupal_static(), and JS_LIBRARY.

Referenced by _batch_progress_page_js(), ajax_example_render_link(), drupal_add_js(), drupal_add_tabledrag(), drupal_process_attached(), overlay_set_mode(), theme_textarea(), theme_textfield(), theme_vertical_tabs(), and user_filter_form().

drupal_add_region_content | ( | $region = NULL,
 |  | $data = NULL
 | ) |

End of "defgroup block_caching". Adds content to a specified region.

Parameters
$region | Page region the content is added to.
$data | Content to be added.

Definition at line 175 of file common.inc.

References $content.

Referenced by drupal_get_region_content(), install_display_output(), and update_task_list().

drupal_add_tabledrag | ( | $table_id,
 |  | $action,
 |  | $relationship,
 |  | $group,
 |  | $subgroup = NULL,
 |  | $source = NULL,
 |  | $hidden = TRUE,
 |  | $limit = 0
 | ) |

Assists in adding the tableDrag JavaScript behavior to a themed table.

Draggable tables should be used wherever an outline or list of sortable items needs to be arranged by an end-user. Draggable tables are very flexible and can manipulate the value of form elements placed within individual columns.

To set up a table to use drag and drop in place of weight select-lists or in place of a form that contains parent relationships, the form must be themed into a table. The table must have an ID attribute set. If using theme_table(), the ID may be set as follows:

* $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'my-module-table')));
* return $output;
*

In the theme function for the form, a special class must be added to each form element within the same column, "grouping" them together.

In a situation where a single weight column is being sorted in the table, the classes could be added like this (in the theme function):

* $form['my_elements'][$delta]['weight']['#attributes']['class'] = array('my-elements-weight');
*

Each row of the table must also have a class of "draggable" in order to enable the drag handles:

* $row = array(...);
* $rows[] = array(
* 'data' => $row,
* 'class' => array('draggable'),
* );
*

When tree relationships are present, the two additional classes 'tabledrag-leaf' and 'tabledrag-root' can be used to refine the behavior:

  • Rows with the 'tabledrag-leaf' class cannot have child rows.
  • Rows with the 'tabledrag-root' class cannot be nested under a parent row.

Calling drupal_add_tabledrag() would then be written as such:

* drupal_add_tabledrag('my-module-table', 'order', 'sibling', 'my-elements-weight');
*

In a more complex case where there are several groups in one column (such as the block regions on the admin/structure/block page), a separate subgroup class must also be added to differentiate the groups.

* $form['my_elements'][$region][$delta]['weight']['#attributes']['class'] = array('my-elements-weight', 'my-elements-weight-' . $region);
*

$group is still 'my-element-weight', and the additional $subgroup variable will be passed in as 'my-elements-weight-' . $region. This also means that you'll need to call drupal_add_tabledrag() once for every region added.

* foreach ($regions as $region) {
* drupal_add_tabledrag('my-module-table', 'order', 'sibling', 'my-elements-weight', 'my-elements-weight-' . $region);
* }
*

In a situation where tree relationships are present, adding multiple subgroups is not necessary, because the table will contain indentations that provide enough information about the sibling and parent relationships. See theme_menu_overview_form() for an example creating a table containing parent relationships.

Note that this function should be called from the theme layer, such as in a .tpl.php file, theme_ function, or in a template_preprocess function, not in a form declaration. Though the same JavaScript could be added to the page using drupal_add_js() directly, this function helps keep template files clean and readable. It also prevents tabledrag.js from being added twice accidentally.

Parameters
$table_id String containing the target table's id attribute. If the table does not have an id, one will need to be set, such as
$action | String describing the action to be done on the form item. Either 'match' 'depth', or 'order'. Match is typically used for parent relationships. Order is typically used to set weights on other form elements with the same group. Depth updates the target element with the current indentation.
$relationship | String describing where the $action variable should be performed. Either 'parent', 'sibling', 'group', or 'self'. Parent will only look for fields up the tree. Sibling will look for fields in the same group in rows above and below it. Self affects the dragged row itself. Group affects the dragged row, plus any children below it (the entire dragged group).
$group | A class name applied on all related form elements for this action.
$subgroup | (optional) If the group has several subgroups within it, this string should contain the class name identifying fields in the same subgroup.
$source | (optional) If the $action is 'match', this string should contain the class name identifying what field will be used as the source value when matching the value in $subgroup.
$hidden | (optional) The column containing the field elements may be entirely hidden from view dynamically when the JavaScript is loaded. Set to FALSE if the column should not be hidden.
$limit | (optional) Limit the maximum amount of parenting in this table.
See Also
block-admin-display-form.tpl.php
theme_menu_overview_form()

Definition at line 4887 of file common.inc.

References drupal_add_js(), drupal_add_library(), and drupal_static().

Referenced by theme_book_admin_table(), theme_field_multiple_value_form(), theme_file_widget_multiple(), theme_filter_admin_format_filter_order(), theme_filter_admin_overview(), theme_image_style_effects(), theme_locale_languages_configure_form(), theme_locale_languages_overview_form(), theme_menu_overview_form(), theme_poll_choices(), theme_profile_admin_overview(), theme_shortcut_set_customize(), theme_tabledrag_example_parent_form(), theme_tabledrag_example_simple_form(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), and theme_user_admin_roles().

drupal_aggregate_css ( & $css_groups )

Default callback to aggregate CSS files and inline content.

Having the browser load fewer CSS files results in much faster page loads than when it loads many small files. This function aggregates files within the same group into a single file unless the site-wide setting to do so is disabled (commonly the case during site development). To optimize download, it also compresses the aggregate files by removing comments, whitespace, and other unnecessary content. Additionally, this functions aggregates inline content together, regardless of the site-wide aggregation setting.

Parameters
$css_groups An array of CSS groups as returned by drupal_group_css(). This function modifies the group's 'data' property for each group that is aggregated.
See Also
drupal_group_css()
drupal_pre_render_styles()
system_element_info()

Definition at line 3274 of file common.inc.

References drupal_build_css_cache(), drupal_load_stylesheet_content(), MAINTENANCE_MODE, and variable_get().

drupal_array_diff_assoc_recursive | ( | $array1,
 |  | $array2
 | ) |

Recursively computes the difference of arrays with additional index check.

This is a version of array_diff_assoc() that supports multidimensional arrays.

Parameters
array | $array1 | The array to compare from.
array | $array2 | The array to compare to.
Returns
array Returns an array containing all the values from array1 that are not present in array2.

Definition at line 6515 of file common.inc.

References $value.

& drupal_array_get_nested_value | ( | array & | $array,
 |  | array | $parents,
 |  | & | $key_exists = NULL
 | ) |  |

Retrieves a value from a nested array with variable depth.

This helper function should be used when the depth of the array element being retrieved may vary (that is, the number of parent keys is variable). It is primarily used for form structures and renderable arrays.

Without this helper function the only way to get a nested array value with variable depth in one line would be using eval(), which should be avoided:

* // Do not do this! Avoid eval().
* // May also throw a PHP notice, if the variable array keys do not exist.
* eval('$value = $array[\'' . implode("']['", $parents) . "'];");
*

Instead, use this helper function:

* $value = drupal_array_get_nested_value($form, $parents);
*

The return value will be NULL, regardless of whether the actual value is NULL or whether the requested key does not exist. If it is required to know whether the nested array key actually exists, pass a third argument that is altered by reference:

* $key_exists = NULL;
* $value = drupal_array_get_nested_value($form, $parents, $key_exists);
* if ($key_exists) {
* // ... do something with $value ...
* }
*

However if the number of array parent keys is static, the value should always be retrieved directly rather than calling this function. For instance:

* $value = $form['signature_settings']['signature'];
*
Parameters
$array | The array from which to get the value.
$parents | An array of parent keys of the value, starting with the outermost key.
$key_exists | (optional) If given, an already defined variable that is altered by reference.
Returns
The requested nested value. Possibly NULL if the value is NULL or not all nested parent keys exist. $key_exists is altered by reference and is a Boolean that indicates whether all nested parent keys exist (TRUE) or not (FALSE). This allows to distinguish between the two possibilities when NULL is returned.
See Also
drupal_array_set_nested_value()

Definition at line 6666 of file common.inc.

Referenced by _form_builder_handle_input_element(), drupal_array_nested_key_exists(), drupal_validate_form(), field_add_more_js(), field_add_more_submit(), field_default_extract_form_values(), field_default_form_errors(), field_form_get_state(), file_field_widget_process(), file_field_widget_submit(), file_managed_file_submit(), form_process_machine_name(), form_state_values_clean(), hook_field_attach_submit(), and list_boolean_allowed_values_callback().

drupal_array_nested_key_exists | ( | array | $array,
 |  | array | $parents
 | ) |  |

Determines whether a nested array contains the requested keys.

This helper function should be used when the depth of the array element to be checked may vary (that is, the number of parent keys is variable). See drupal_array_set_nested_value() for details. It is primarily used for form structures and renderable arrays.

If it is required to also get the value of the checked nested key, use drupal_array_get_nested_value() instead.

If the number of array parent keys is static, this helper function is unnecessary and the following code can be used instead:

* $value_exists = isset($form['signature_settings']['signature']);
* $key_exists = array_key_exists('signature', $form['signature_settings']);
*
Parameters
$array | The array with the value to check for.
$parents | An array of parent keys of the value, starting with the outermost key.
Returns
TRUE if all the parent keys exist, FALSE otherwise.
See Also
drupal_array_get_nested_value()

Definition at line 6710 of file common.inc.

References drupal_array_get_nested_value().

Referenced by _form_builder_handle_input_element(), and drupal_validate_form().

drupal_array_set_nested_value | ( | array & | $array,
 |  | array | $parents,
 |  |  | $value,
 |  |  | $force = FALSE
 | ) |  |

Sets a value in a nested array with variable depth.

This helper function should be used when the depth of the array element you are changing may vary (that is, the number of parent keys is variable). It is primarily used for form structures and renderable arrays.

Example:

* // Assume you have a 'signature' element somewhere in a form. It might be:
* $form['signature_settings']['signature'] = array(
* '#type' => 'text_format',
* '#title' => t('Signature'),
* );
* // Or, it might be further nested:
* $form['signature_settings']['user']['signature'] = array(
* '#type' => 'text_format',
* '#title' => t('Signature'),
* );
*

To deal with the situation, the code needs to figure out the route to the element, given an array of parents that is either

array('signature_settings', 'signature')

in the first case or

array('signature_settings', 'user', 'signature')

in the second case.

Without this helper function the only way to set the signature element in one line would be using eval(), which should be avoided:

* // Do not do this! Avoid eval().
* eval('$form[\'' . implode("']['", $parents) . '\'] = $element;');
*

Instead, use this helper function:

* drupal_array_set_nested_value($form, $parents, $element);
*

However if the number of array parent keys is static, the value should always be set directly rather than calling this function. For instance, for the first example we could just do:

* $form['signature_settings']['signature'] = $element;
*
Parameters
$array | A reference to the array to modify.
$parents | An array of parent keys, starting with the outermost key.
$value | The value to set.
$force | (Optional) If TRUE, the value is forced into the structure even if it requires the deletion of an already existing non-array parent value. If FALSE, PHP throws an error if trying to add into a value that is not an array. Defaults to FALSE.
See Also
drupal_array_get_nested_value()

Definition at line 6598 of file common.inc.

References $value.

Referenced by _form_builder_handle_input_element(), drupal_validate_form(), field_form_set_state(), file_field_widget_submit(), file_managed_file_submit(), form_process_machine_name(), and form_set_value().

drupal_build_css_cache ( $css )

Aggregates and optimizes CSS files into a cache file in the files directory.

The file name for the CSS cache file is generated from the hash of the aggregated contents of the files in $css. This forces proxies and browsers to download new CSS when the CSS changes.

The cache file name is retrieved on a page load via a lookup variable that contains an associative array. The array key is the hash of the file names in $css while the value is the cache file name. The cache file is generated in two cases. First, if there is no file name value for the key, which will happen if a new file name has been added to $css or after the lookup variable is emptied to force a rebuild of the cache. Second, the cache file is generated if it is missing on disk. Old cache files are not deleted immediately when the lookup variable is emptied, but are deleted after a set period by drupal_delete_file_if_stale(). This ensures that files referenced by a cached page will still be available.

Parameters
$css An array of CSS files to aggregate and compress into one file.
Returns
The URI of the CSS cache file, or FALSE if the file could not be saved.

Definition at line 3546 of file common.inc.

References $contents, _drupal_build_css_path(), drupal_hash_base64(), drupal_load_stylesheet(), FILE_CREATE_DIRECTORY, file_create_url(), FILE_EXISTS_REPLACE, file_prepare_directory(), file_unmanaged_save_data(), variable_get(), and variable_set().

Referenced by drupal_aggregate_css().

drupal_build_js_cache ( $files )

Aggregates JavaScript files into a cache file in the files directory.

The file name for the JavaScript cache file is generated from the hash of the aggregated contents of the files in $files. This forces proxies and browsers to download new JavaScript when the JavaScript changes.

The cache file name is retrieved on a page load via a lookup variable that contains an associative array. The array key is the hash of the names in $files while the value is the cache file name. The cache file is generated in two cases. First, if there is no file name value for the key, which will happen if a new file name has been added to $files or after the lookup variable is emptied to force a rebuild of the cache. Second, the cache file is generated if it is missing on disk. Old cache files are not deleted immediately when the lookup variable is emptied, but are deleted after a set period by drupal_delete_file_if_stale(). This ensures that files referenced by a cached page will still be available.

Parameters
$files An array of JavaScript files to aggregate and compress into one file.
Returns
The URI of the cache file, or FALSE if the file could not be saved.

Definition at line 4936 of file common.inc.

References $contents, $info, drupal_hash_base64(), FILE_CREATE_DIRECTORY, FILE_EXISTS_REPLACE, file_prepare_directory(), file_unmanaged_save_data(), variable_get(), and variable_set().

Referenced by drupal_get_js().

drupal_check_incompatibility | ( | $v,
 |  | $current_version
 | ) |

Checks whether a version is compatible with a given dependency.

Parameters
$v | The parsed dependency structure from drupal_parse_dependency().
$current_version | The version to check against (like 4.2).
Returns
NULL if compatible, otherwise the original dependency version string that caused the incompatibility.
See Also
drupal_parse_dependency()

Definition at line 7597 of file common.inc.

Referenced by system_modules(), and system_requirements().

drupal_clean_css_identifier | ( | $identifier,
 |  | $filter = array(' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => '')
 | ) |

Prepares a string for use as a CSS identifier (element, class, or ID name).

http://www.w3.org/TR/CSS21/syndata.html#characters shows the syntax for valid CSS identifiers (including element names, classes, and IDs in selectors.)

Parameters
$identifier | The identifier to clean.
$filter | An array of string replacements to use on the identifier.
Returns
The cleaned identifier.

Definition at line 3812 of file common.inc.

Referenced by drupal_html_class().

drupal_clear_css_cache ( )

Deletes old cached CSS files.

Definition at line 3783 of file common.inc.

References file_scan_directory(), and variable_del().

Referenced by drupal_flush_all_caches(), theme_disable(), and theme_enable().

drupal_clear_js_cache ( )

Deletes old cached JavaScript files and variables.

Definition at line 4988 of file common.inc.

References file_scan_directory(), and variable_del().

Referenced by drupal_flush_all_caches().

drupal_common_theme ( )

Provides theme registration for themes across .inc files.

Definition at line 6721 of file common.inc.

References MARK_NEW.

Referenced by system_theme().

drupal_cron_cleanup ( )

Shutdown function: Performs cron cleanup.

See Also
drupal_cron_run()
drupal_register_shutdown_function()

Definition at line 5310 of file common.inc.

References variable_del(), variable_get(), watchdog(), and WATCHDOG_WARNING.

drupal_cron_run ( )

Executes a cron run when called.

Do not call this function from a test. Use $this->cronRun() instead.

Returns
TRUE if cron ran successfully.

Definition at line 5227 of file common.inc.

References $info, $module, drupal_alter(), drupal_anonymous_user(), drupal_register_shutdown_function(), drupal_save_session(), drupal_set_time_limit(), DrupalQueue\get(), lock_acquire(), lock_release(), module_implements(), module_invoke(), module_invoke_all(), REQUEST_TIME, variable_set(), watchdog(), watchdog_exception(), WATCHDOG_NOTICE, and WATCHDOG_WARNING.

Referenced by cron_example_form_cron_run_submit(), install_finished(), queue_example_add_remove_form_run_cron(), DrupalWebTestCase\setUp(), system_run_cron(), and system_run_cron_submit().

drupal_delete_file_if_stale ( $uri )

Callback to delete files modified more than a set time ago.

Definition at line 3791 of file common.inc.

References file_unmanaged_delete(), REQUEST_TIME, and variable_get().

drupal_deliver_html_page ( $page_callback_result )

Packages and sends the result of a page callback to the browser as HTML.

Parameters
$page_callback_result The result of a page callback. Can be one of:
  • NULL: to indicate no content.
  • An integer menu status constant: to indicate an error condition.
  • A string of HTML content.
  • A renderable array of content.
See Also
drupal_deliver_page()

Definition at line 2585 of file common.inc.

References $page, check_plain(), drupal_add_http_header(), drupal_fast_404(), drupal_get_http_header(), drupal_get_normal_path(), drupal_maintenance_theme(), drupal_page_footer(), drupal_render_page(), drupal_set_page_content(), drupal_set_title(), element_info(), filter_xss_admin(), MENU_ACCESS_DENIED, menu_execute_active_handler(), MENU_NOT_FOUND, menu_set_active_item(), MENU_SITE_OFFLINE, print, request_uri(), t(), theme(), variable_get(), watchdog(), and WATCHDOG_WARNING.

drupal_deliver_page | ( | $page_callback_result,
 |  | $default_delivery_callback = NULL
 | ) |

Delivers a page callback result to the browser in the appropriate format.

This function is most commonly called by menu_execute_active_handler(), but can also be called by error conditions such as drupal_not_found(), drupal_access_denied(), and drupal_site_offline().

When a user requests a page, index.php calls menu_execute_active_handler(), which calls the 'page callback' function registered in hook_menu(). The page callback function can return one of:

  • NULL: to indicate no content.
  • An integer menu status constant: to indicate an error condition.
  • A string of HTML content.
  • A renderable array of content. Returning a renderable array rather than a string of HTML is preferred, because that provides modules with more flexibility in customizing the final result.

When the page callback returns its constructed content to menu_execute_active_handler(), this function gets called. The purpose of this function is to determine the most appropriate 'delivery callback' function to route the content to. The delivery callback function then sends the content to the browser in the needed format. The default delivery callback is drupal_deliver_html_page(), which delivers the content as an HTML page, complete with blocks in addition to the content. This default can be overridden on a per menu router item basis by setting 'delivery callback' in hook_menu() or hook_menu_alter(), and can also be overridden on a per request basis in hook_page_delivery_callback_alter().

For example, the same page callback function can be used for an HTML version of the page and an Ajax version of the page. The page callback function just needs to decide what content is to be returned and the delivery callback function will send it as an HTML page or an Ajax response, as appropriate.

In order for page callbacks to be reusable in different delivery formats, they should not issue any "print" or "echo" statements, but instead just return content.

Also note that this function does not perform access checks. The delivery callback function specified in hook_menu(), hook_menu_alter(), or hook_page_delivery_callback_alter() will be called even if the router item access checks fail. This is intentional (it is needed for JSON and other purposes), but it has security implications. Do not call this function directly unless you understand the security implications, and be careful in writing delivery callbacks, so that they do not violate security. See drupal_deliver_html_page() for an example of a delivery callback that respects security.

Parameters
$page_callback_result The result of a page callback. Can be one of:
  • NULL: to indicate no content.
  • An integer menu status constant: to indicate an error condition.
  • A string of HTML content.
  • A renderable array of content.
$default_delivery_callback (Optional) If given, it is the name of a delivery function most likely to be appropriate for the page request as determined by the calling function (e.g., menu_execute_active_handler()). If not given, it is determined from the menu router information of the current page.
See Also
menu_execute_active_handler()
hook_menu()
hook_menu_alter()
hook_page_delivery_callback_alter()

Definition at line 2554 of file common.inc.

References drupal_alter(), menu_get_item(), watchdog(), and WATCHDOG_ERROR.

Referenced by drupal_access_denied(), drupal_not_found(), drupal_site_offline(), and menu_execute_active_handler().

drupal_exit ( $destination = NULL )

Performs end-of-request tasks.

In some cases page requests need to end without calling drupal_page_footer(). In these cases, call drupal_exit() instead. There should rarely be a reason to call exit instead of drupal_exit();

Parameters
$destination If this function is called from drupal_goto(), then this argument will be a fully-qualified URL that is the destination of the redirect. This should be passed along to hook_exit() implementations.

Definition at line 2721 of file common.inc.

References DRUPAL_BOOTSTRAP_FULL, drupal_get_bootstrap_phase(), drupal_session_commit(), MAINTENANCE_MODE, and module_invoke_all().

Referenced by _locale_export_po(), ajax_get_form(), contact_personal_form(), contact_site_form(), dashboard_show_block_content(), dashboard_show_disabled(), dashboard_update(), drupal_goto(), file_download(), file_transfer(), image_style_deliver(), install_goto(), locale_languages_delete_form(), locale_languages_edit_form(), openid_redirect(), openid_redirect_http(), overlay_deliver_empty_page(), system_php(), user_pass_reset(), xmlrpc_server(), and xmlrpc_server_output().

drupal_explode_tags ( $tags )

Explodes a string of tags into an array.

See Also
drupal_implode_tags()

Definition at line 7408 of file common.inc.

Referenced by comment_unpublish_by_keyword_action_submit(), node_unpublish_by_keyword_action_submit(), taxonomy_autocomplete(), and taxonomy_autocomplete_validate().

drupal_flush_all_caches ( )

Flushes all cached data on the site.

Empties cache tables, rebuilds the menu cache and theme registries, and invokes a hook so that other modules' cache data can be cleared as well.

Definition at line 7453 of file common.inc.

References _drupal_flush_css_js(), _system_update_bootstrap_status(), actions_synchronize(), cache_clear_all(), drupal_clear_css_cache(), drupal_clear_js_cache(), drupal_theme_rebuild(), entity_info_cache_clear(), menu_rebuild(), module_invoke_all(), node_types_rebuild(), registry_rebuild(), and system_rebuild_theme_data().

Referenced by _install_profile_modules_finished(), install_finished(), DrupalWebTestCase\resetAll(), system_clear_cache_submit(), system_modules_submit(), update_finished(), and update_script_selection_form().

drupal_get_breadcrumb ( )

Gets the breadcrumb trail for the current page.

Definition at line 255 of file common.inc.

References $breadcrumb, drupal_set_breadcrumb(), and menu_get_active_breadcrumb().

Referenced by template_process_page().

drupal_get_css | ( | $css = NULL,
 |  | $skip_alter = FALSE
 | ) |

Returns a themed representation of all stylesheets to attach to the page.

It loads the CSS in order, with 'module' first, then 'theme' afterwards. This ensures proper cascading of styles so themes can easily override module styles through CSS selectors.

Themes may replace module-defined CSS files by adding a stylesheet with the same filename. For example, themes/bartik/system-menus.css would replace modules/system/system-menus.css. This allows themes to override complete CSS files, rather than specific selectors, when necessary.

If the original CSS file is being overridden by a theme, the theme is responsible for supplying an accompanying RTL CSS file to replace the module's.

Parameters
$css | (optional) An array of CSS files. If no array is provided, the default stylesheets array is used instead.
$skip_alter | (optional) If set to TRUE, this function skips calling drupal_alter() on $css, useful when the calling function passes a $css array that has already been altered.
Returns
A string of XHTML CSS tags.
See Also
drupal_add_css()

Definition at line 3052 of file common.inc.

References $styles, drupal_add_css(), drupal_alter(), drupal_basename(), and drupal_render().

Referenced by _color_html_alter(), ajax_render(), overlay_deliver_empty_page(), template_process_html(), and template_process_maintenance_page().

drupal_get_feeds ( $delimiter = "\n" )

Gets the feed URLs for the current page.

Parameters
$delimiter A delimiter to split feeds by.

Definition at line 392 of file common.inc.

References drupal_add_feed().

Referenced by template_preprocess_page().

drupal_get_filetransfer_info ( )

Assembles the Drupal FileTransfer registry.

Returns
The Drupal FileTransfer class registry.
See Also
FileTransfer
hook_filetransfer_info()
hook_filetransfer_info_alter()

Definition at line 8200 of file common.inc.

References $info, $module, drupal_alter(), drupal_get_path(), drupal_static(), and module_implements().

Referenced by _update_manager_check_backends(), and system_authorized_init().

drupal_get_html_head ( )

Retrieves output to be displayed in the HEAD tag of the HTML page.

Definition at line 352 of file common.inc.

References drupal_add_html_head(), drupal_alter(), and drupal_render().

Referenced by template_preprocess_book_export_html(), template_process_html(), and template_process_maintenance_page().

drupal_get_js | ( | $scope = 'header',
 |  | $javascript = NULL,
 |  | $skip_alter = FALSE
 | ) |

Returns a themed presentation of all JavaScript code for the current page.

References to JavaScript files are placed in a certain order: first, all 'core' files, then all 'module' and finally all 'theme' JavaScript files are added to the page. Then, all settings are output, followed by 'inline' JavaScript code. If running update.php, all preprocessing is disabled.

Note that hook_js_alter(&$javascript) is called during this function call to allow alterations of the JavaScript during its presentation. Calls to drupal_add_js() from hook_js_alter() will not be added to the output presentation. The correct way to add JavaScript during hook_js_alter() is to add another element to the $javascript array, deriving from drupal_js_defaults(). See locale_js_alter() for an example of this.

Parameters
$scope | (optional) The scope for which the JavaScript rules should be returned. Defaults to 'header'.
$javascript | (optional) An array with all JavaScript code. Defaults to the default JavaScript array for the given scope.
$skip_alter | (optional) If set to TRUE, this function skips calling drupal_alter() on $javascript, useful when the calling function passes a $javascript array that has already been altered.
Returns
All JavaScript code segments and includes for the scope as HTML tags.
See Also
drupal_add_js()
locale_js_alter()
drupal_js_defaults()

Definition at line 4263 of file common.inc.

References $output, drupal_add_js(), drupal_alter(), drupal_array_merge_deep_array(), drupal_build_js_cache(), drupal_json_encode(), file_create_url(), MAINTENANCE_MODE, REQUEST_TIME, theme(), and variable_get().

Referenced by ajax_render(), overlay_deliver_empty_page(), template_process_html(), and template_process_maintenance_page().

drupal_get_library | ( | $module,
 |  | $name = NULL
 | ) |

Retrieves information for a JavaScript/CSS library.

Library information is statically cached. Libraries are keyed by module for several reasons:

  • Libraries are not unique. Multiple modules might ship with the same library in a different version or variant. This registry cannot (and does not attempt to) prevent library conflicts.
  • Modules implementing and thereby depending on a library that is registered by another module can only rely on that module's library.
  • Two (or more) modules can still register the same library and use it without conflicts in case the libraries are loaded on certain pages only.
Parameters
$module | The name of a module that registered a library.
$name | (optional) The name of a registered library to retrieve. By default, all libraries registered by $module are returned.
Returns
The definition of the requested library, if $name was passed and it exists, or FALSE if it does not exist. If no $name was passed, an associative array of libraries registered by $module is returned (which may be empty).
See Also
drupal_add_library()
hook_library()
hook_library_alter()

Definition at line 4748 of file common.inc.

References $module, $name, drupal_alter(), drupal_static(), and module_invoke().

Referenced by drupal_add_library().

drupal_get_path | ( | $type,
 |  | $name
 | ) |

Returns the path to a system item (module, theme, etc.).

Parameters
$type | The type of the item (i.e. theme, theme_engine, module, profile).
$name | The name of the item for which the path is requested.
Returns
The path to the requested item or an empty string if the item is not found.

Definition at line 2803 of file common.inc.

References $name, and drupal_get_filename().

Referenced by _aggregator_get_variables(), _book_add_form_elements(), _drupal_maintenance_theme(), _locale_translate_language_list(), _menu_router_build(), _openid_user_login_form_alter(), _theme_build_registry(), ajax_example_dependent_dropdown_degrades(), ajax_example_dynamic_sections(), bartik_preprocess_maintenance_page(), block_admin_configure(), block_admin_demo(), block_admin_display_form(), ModuleUpdater\canUpdate(), ThemeUpdater\canUpdate(), color_get_info(), color_scheme_form(), color_scheme_form_submit(), comment_form_node_form_alter(), comment_form_node_type_form_alter(), contextual_library(), dashboard_admin(), dashboard_theme(), dblog_init(), drupal_get_filetransfer_info(), drupal_install_system(), DrupalWebTestCase\drupalGetTestFiles(), field_example_field_widget_form(), field_permission_example_field_formatter_view(), field_ui_display_overview_form(), field_ui_field_overview_form(), file_element_info(), file_field_settings_form(), file_icon_path(), filter_admin_format_form(), filter_process_format(), ModuleUpdater\getInstallDirectory(), ThemeUpdater\getInstallDirectory(), help_main(), hook_css_alter(), hook_init(), hook_js_alter(), hook_language_negotiation_info(), hook_library(), hook_library_alter(), hook_overlay_child_initialize(), hook_overlay_parent_initialize(), hook_system_theme_info(), image_effect_form(), image_field_widget_process(), image_style_form(), image_style_list(), install_configure_form(), ModuleUpdater\isInstalled(), ThemeUpdater\isInstalled(), js_example_js_weights(), locale_block_view(), locale_language_switcher_session(), locale_library_alter(), locale_translate_seek_screen(), menu_form_node_form_alter(), menu_form_node_type_form_alter(), menu_overview_form(), module_load_include(), node_form(), node_mass_update(), node_type_form(), openid_user_identities(), overlay_library(), path_form_node_form_alter(), php_eval(), queue_example_add_remove_form(), seven_css_alter(), seven_tablesort_indicator(), shortcut_preprocess_page(), shortcut_set_customize(), shortcut_set_switch(), shortcut_toolbar_pre_render(), simpletest_js_alter(), simpletest_result_form(), simpletest_run_tests(), statistics_node_view(), system_clean_url_settings(), system_configure_date_formats_form(), system_image_toolkits(), system_init(), system_modules_uninstall_confirm_form(), system_performance_settings(), taxonomy_term_view(), text_field_widget_form(), theme_color_scheme_form(), theme_dashboard(), theme_image_style_preview(), theme_profile_admin_overview(), theme_simpletest_test_table(), theme_taxonomy_overview_terms(), theme_update_report(), theming_example_list_page(), toolbar_theme(), toolbar_view(), tracker_page(), update_access_allowed(), update_authorize_run_install(), update_authorize_run_update(), update_manager_install_form_submit(), update_manager_update_form(), update_manager_update_form_submit(), update_manager_update_ready_form_submit(), update_manual_status(), user_admin_permissions(), user_admin_settings(), user_form_field_ui_field_edit_form_alter(), user_form_process_password_confirm(), user_menu(), and vertical_tabs_example_form_alter().

drupal_get_private_key ( )

Ensures the private key variable used to generate tokens is set.

Returns
The private key.

Definition at line 5056 of file common.inc.

References drupal_random_key(), variable_get(), and variable_set().

Referenced by _update_process_fetch_task(), drupal_get_token(), DrupalWebTestCase\drupalGetToken(), and image_style_path_token().

drupal_get_profile ( )

Gets the name of the currently active installation profile.

When this function is called during Drupal's initial installation process, the name of the profile that's about to be installed is stored in the global installation state. At all other times, the standard Drupal systems variable table contains the name of the current profile, and we can call variable_get() to determine what one is active.

Returns
$profile The name of the installation profile.

Definition at line 222 of file common.inc.

References variable_get().

Referenced by _system_rebuild_module_data(), drupal_install_profile_distribution_name(), drupal_required_modules(), drupal_system_listing(), drupal_uninstall_modules(), drupal_verify_profile(), DatabaseTasks\getFormOptions(), install_finished(), install_system_module(), module_disable(), DrupalWebTestCase\prepareEnvironment(), system_modules_uninstall(), system_requirements(), and update_fix_d7_install_profile().

drupal_get_rdf_namespaces ( )

Returns a string containing RDF namespace declarations for use in XML and XHTML output.

Definition at line 269 of file common.inc.

References rdf_get_namespaces().

Referenced by template_preprocess_html().

drupal_get_region_content | ( | $region = NULL,
 |  | $delimiter = ' '
 | ) |

Gets assigned content for a given region.

Parameters
$region | A specified region to fetch content for. If NULL, all regions will be returned.
$delimiter | Content to be inserted between imploded array elements.

Definition at line 193 of file common.inc.

References $content, and drupal_add_region_content().

Referenced by template_preprocess_maintenance_page().

drupal_get_token ( $value = '' )

Generates a token based on $value, the user session, and the private key.

Parameters
$value An additional value to base the token on.
Returns
string A 43-character URL-safe token for validation, based on the user session ID, the hash salt provided from drupal_get_hash_salt(), and the 'drupal_private_key' configuration variable.
See Also
drupal_get_hash_salt()

Definition at line 5077 of file common.inc.

References $value, drupal_get_hash_salt(), drupal_get_private_key(), and drupal_hmac_base64().

Referenced by aggregator_view(), batch_load(), batch_process(), comment_links(), dashboard_admin(), drupal_prepare_form(), drupal_process_form(), drupal_theme_initialize(), drupal_valid_token(), form_set_cache(), overlay_disable_message(), shortcut_preprocess_page(), system_themes_page(), and update_info_page().

drupal_get_updaters ( )

Assembles the Drupal Updater registry.

An Updater is a class that knows how to update various parts of the Drupal file system, for example to update modules that have newer releases, or to install a new theme.

Returns
The Drupal Updater class registry.
See Also
hook_updater_info()
hook_updater_info_alter()

Definition at line 8180 of file common.inc.

References drupal_alter(), drupal_static(), and module_invoke_all().

Referenced by Updater\getUpdaterFromDirectory(), update_manager_install_form_submit(), and update_manager_update_ready_form_submit().

drupal_group_css ( $css )

Default callback to group CSS items.

This function arranges the CSS items that are in the #items property of the styles element into groups. Arranging the CSS items into groups serves two purposes. When aggregation is enabled, files within a group are aggregated into a single file, significantly improving page loading performance by minimizing network traffic overhead. When aggregation is disabled, grouping allows multiple files to be loaded from a single STYLE tag, enabling sites with many modules enabled or a complex theme being used to stay within IE's 31 CSS inclusion tag limit: http://drupal.org/node/228818.

This function puts multiple items into the same group if they are groupable and if they are for the same 'media' and 'browsers'. Items of the 'file' type are groupable if their 'preprocess' flag is TRUE, items of the 'inline' type are always groupable, and items of the 'external' type are never groupable. This function also ensures that the process of grouping items does not change their relative order. This requirement may result in multiple groups for the same type, media, and browsers, if needed to accommodate other items in between.

Parameters
$css An array of CSS items, as returned by drupal_add_css(), but after alteration performed by drupal_get_css().
Returns
An array of CSS groups. Each group contains the same keys (e.g., 'media', 'data', etc.) as a CSS item from the $css parameter, with the value of each key applying to the group as a whole. Each group also contains an 'items' key, which is the subset of items from $css that are in the group.
See Also
drupal_pre_render_styles()
system_element_info()

Definition at line 3191 of file common.inc.

drupal_html_class ( $class )

Prepares a string for use as a valid class name.

Do not pass one string containing multiple classes as they will be incorrectly concatenated with dashes, i.e. "one two" will become "one-two".

Parameters
$class The class name to clean.
Returns
The cleaned class name.

Definition at line 3841 of file common.inc.

References $classes, drupal_clean_css_identifier(), and drupal_strtolower().

Referenced by contextual_pre_render_links(), dblog_overview(), drupal_region_class(), field_default_form(), field_ui_table_pre_render(), template_preprocess(), template_preprocess_block(), template_preprocess_html(), template_preprocess_node(), theme_field_ui_table(), and theme_filter_tips().

drupal_html_id ( $id )

Prepares a string for use as a valid HTML ID and guarantees uniqueness.

This function ensures that each passed HTML ID value only exists once on the page. By tracking the already returned ids, this function enables forms, blocks, and other content to be output multiple times on the same page, without breaking (X)HTML validation.

For already existing IDs, a counter is appended to the ID string. Therefore, JavaScript and CSS code should not rely on any value that was generated by this function and instead should rely on manually added CSS classes or similarly reliable constructs.

Two consecutive hyphens separate the counter from the original ID. To manage uniqueness across multiple Ajax requests on the same page, Ajax requests POST an array of all IDs currently present on the page, which are used to prime this function's cache upon first invocation.

To allow reverse-parsing of IDs submitted via Ajax, any multiple consecutive hyphens in the originally passed $id are replaced with a single hyphen.

Parameters
$id The ID to clean.
Returns
The cleaned ID.

Definition at line 3879 of file common.inc.

References drupal_static(), and drupal_strtolower().

Referenced by comment_form(), drupal_pre_render_link(), drupal_prepare_form(), field_multiple_value_form(), form_builder(), form_process_container(), form_process_radios(), form_process_tableselect(), template_preprocess_block(), and theme_field_multiple_value_form().

drupal_http_header_attributes ( array $attributes = array() )

Formats an attribute string for an HTTP header.

Parameters
$attributes An associative array of attributes such as 'rel'.
Returns
A ; separated string ready for insertion in a HTTP header. No escaping is performed for HTML entities, so this string is not safe to be printed.
See Also
drupal_add_http_header()

Definition at line 2331 of file common.inc.

References $attributes.

Referenced by drupal_add_html_head_link().

drupal_implode_tags ( $tags )

Implodes an array of tags into a string.

See Also
drupal_explode_tags()

Definition at line 7434 of file common.inc.

Referenced by comment_unpublish_by_keyword_action_form(), node_unpublish_by_keyword_action_form(), and taxonomy_autocomplete().

drupal_js_defaults ( $data = NULL )

Constructs an array of the defaults that are used for JavaScript items.

Parameters
$data (optional) The default data parameter for the JavaScript item array.
See Also
drupal_get_js()
drupal_add_js()

Definition at line 4215 of file common.inc.

References JS_DEFAULT.

Referenced by drupal_add_js(), and locale_js_alter().

drupal_json_output ( $var = NULL )

Returns data in JSON format.

This function should be used for JavaScript callback functions returning data in JSON format. It sets the header for JavaScript output.

Parameters
$var (optional) If set, the variable will be converted to JSON and output.

Definition at line 5041 of file common.inc.

References drupal_add_http_header(), and drupal_json_encode().

Referenced by _batch_do(), ajax_example_node_by_author_node_autocomplete_callback(), ajax_example_simple_user_autocomplete_callback(), ajax_example_unique_node_autocomplete_callback(), file_ajax_progress(), menu_parent_options_js(), profile_admin_settings_autocomplete(), profile_autocomplete(), system_date_time_lookup(), system_timezone(), taxonomy_autocomplete(), and user_autocomplete().

drupal_load_stylesheet | ( | $file,
 |  | $optimize = NULL,
 |  | $reset_basepath = TRUE
 | ) |

Loads the stylesheet and resolves all commands.

Loads a stylesheet and replaces commands with the contents of the imported file. Use this instead of file_get_contents when processing stylesheets.

The returned contents are compressed removing white space and comments only when CSS aggregation is enabled. This optimization will not apply for color.module enabled themes with CSS aggregation turned off.

Parameters
$file | Name of the stylesheet to be processed.
$optimize | Defines if CSS contents should be compressed or not.
$reset_basepath | Used internally to facilitate recursive resolution of commands.
Returns
Contents of the stylesheet, including any resolved commands.

Definition at line 3659 of file common.inc.

References $content, $contents, drupal_load_stylesheet_content(), and file_uri_scheme().

Referenced by _drupal_load_stylesheet(), color_scheme_form_submit(), and drupal_build_css_cache().

drupal_load_stylesheet_content | ( | $contents,
 |  | $optimize = FALSE
 | ) |

Processes the contents of a stylesheet for aggregation.

Parameters
$contents | The contents of the stylesheet.
$optimize | (optional) Boolean whether CSS contents should be minified. Defaults to FALSE.
Returns
Contents of the stylesheet including the imported stylesheets.

Definition at line 3707 of file common.inc.

References $contents.

Referenced by drupal_aggregate_css(), and drupal_load_stylesheet().

drupal_map_assoc | ( | $array,
 |  | $function = NULL
 | ) |

Forms an associative array from a linear array.

This function walks through the provided array and constructs an associative array out of it. The keys of the resulting array will be the values of the input array. The values will be the same as the keys unless a function is specified, in which case the output of the function is used for the values instead.

Parameters
$array | A linear array.
$function | A name of a function to apply to all values before output.
Returns
An associative array.

Definition at line 2748 of file common.inc.

Referenced by _ajax_example_get_first_dropdown_options(), _ajax_example_get_second_dropdown_options(), _comment_per_page(), aggregator_block_configure(), aggregator_form_aggregator_admin_form_alter(), aggregator_form_feed(), aggregator_form_opml(), ajax_example_advanced_commands(), ajax_example_dynamic_sections(), blog_block_configure(), DrupalDefaultEntityController\buildQuery(), comment_block_configure(), cron_example_form(), dblog_form_system_logging_settings_alter(), field_ui_field_edit_form(), field_ui_menu(), field_ui_table_pre_render(), form_example_states_form(), form_process_date(), form_type_checkboxes_value(), form_type_select_value(), form_type_tableselect_value(), forum_admin_settings(), forum_block_configure(), hook_block_configure(), hook_search_admin(), node_block_configure(), node_search_admin(), number_field_formatter_settings_form(), number_field_settings_form(), poll_form(), queue_example_add_remove_form(), search_admin_settings(), statistics_block_configure(), statistics_settings_form(), system_cron_settings(), system_performance_settings(), system_rss_feeds_settings(), system_site_information_settings(), update_filter_project_info(), update_get_update_list(), and user_block_configure().

drupal_page_footer ( )

Performs end-of-request tasks.

This function sets the page cache if appropriate, and allows modules to react to the closing of the page by calling hook_exit().

Definition at line 2688 of file common.inc.

References _registry_check_code(), drupal_cache_system_paths(), drupal_page_set_cache(), drupal_serve_page_from_cache(), drupal_session_commit(), module_implements_write_cache(), module_invoke_all(), REGISTRY_WRITE_LOOKUP_CACHE, system_run_automated_cron(), and variable_get().

Referenced by drupal_deliver_html_page().

drupal_page_set_cache ( )

Stores the current page in the cache.

If page_compression is enabled, a gzipped version of the page is stored in the cache to avoid compressing the output on each request. The cache entry is unzipped in the relatively rare event that the page is requested by a client without gzip support.

Page compression requires the PHP zlib extension (http://php.net/manual/ref.zlib.php).

See Also
drupal_page_header()

Definition at line 5175 of file common.inc.

References $value, _drupal_set_preferred_header_name(), cache_set(), CACHE_TEMPORARY, drupal_get_http_header(), drupal_get_title(), drupal_page_is_cacheable(), REQUEST_TIME, request_uri(), and variable_get().

Referenced by drupal_page_footer().

drupal_parse_dependency ( $dependency )

Parses a dependency for comparison by drupal_check_incompatibility().

Parameters
$dependency A dependency string, for example 'foo (>=7.x-4.5-beta5, 3.x)'.
Returns
An associative array with three keys:
  • 'name' includes the name of the thing to depend on (e.g. 'foo').
  • 'original_version' contains the original version string (which can be used in the UI for reporting incompatibilities).
  • 'versions' is a list of associative arrays, each containing the keys 'op' and 'version'. 'op' can be one of: '=', '==', '!=', '<>', '<', '<=', '>', or '>='. 'version' is one piece like '4.5-beta3'. Callers should pass this structure to drupal_check_incompatibility().
See Also
drupal_check_incompatibility()

Definition at line 7543 of file common.inc.

References $op, $value, and DRUPAL_CORE_COMPATIBILITY.

Referenced by _module_build_dependencies().

drupal_parse_info_file ( $filename )

End of "addtogroup schemaapi". Parses Drupal module and theme .info files.

Info files are NOT for placing arbitrary theme and module-specific settings. Use variable_get() and variable_set() for that.

Information stored in a module .info file:

  • name: The real name of the module for display purposes.
  • description: A brief description of the module.
  • dependencies: An array of shortnames of other modules this module requires.
  • package: The name of the package of modules this module belongs to.

See forum.info for an example of a module .info file.

Information stored in a theme .info file:

  • name: The real name of the theme for display purposes.
  • description: Brief description.
  • screenshot: Path to screenshot relative to the theme's .info file.
  • engine: Theme engine; typically phptemplate.
  • base: Name of a base theme, if applicable; e.g., base = zen.
  • regions: Listed regions; e.g., region[left] = Left sidebar.
  • features: Features available; e.g., features[] = logo.
  • stylesheets: Theme stylesheets; e.g., stylesheets[all][] = my-style.css.
  • scripts: Theme scripts; e.g., scripts[] = my-script.js.

See bartik.info for an example of a theme .info file.

Parameters
$filename The file we are parsing. Accepts file with relative or absolute path.
Returns
The info array.
See Also
drupal_parse_info_format()

Definition at line 7270 of file common.inc.

References $info, drupal_parse_info_format(), and drupal_static().

Referenced by _system_rebuild_module_data(), _system_rebuild_theme_data(), drupal_required_modules(), drupal_system_listing(), Updater\getProjectTitle(), install_profile_info(), system_modules_uninstall_confirm_form(), update_fix_d7_install_profile(), and update_verify_update_archive().

drupal_parse_info_format ( $data )

Parses data in Drupal's .info format.

Data should be in an .ini-like format to specify values. White-space generally doesn't matter, except inside values:

* key = value
* key = "value"
* key = 'value'
* key = "multi-line
* value"
* key = 'multi-line
* value'
* key
* =
* 'value'
*

Arrays are created using a HTTP GET alike syntax:

* key[] = "numeric array"
* key[index] = "associative array"
* key[index][] = "nested numeric array"
* key[index][index] = "nested associative array"
*

PHP constants are substituted in, but only when used as the entire value. Comments should start with a semi-colon at the beginning of a line.

Parameters
$data A string to parse.
Returns
The info array.
See Also
drupal_parse_info_file()

Definition at line 7322 of file common.inc.

References $info, and $value.

Referenced by drupal_parse_info_file().

drupal_pre_render_conditional_comments ( $elements )

#pre_render callback to render #browsers into #prefix and #suffix.

Parameters
$elements A render array with a '#browsers' property. The '#browsers' property can contain any or all of the following keys:
  • 'IE': If FALSE, the element is not rendered by Internet Explorer. If TRUE, the element is rendered by Internet Explorer. Can also be a string containing an expression for Internet Explorer to evaluate as part of a conditional comment. For example, this can be set to 'lt IE 7' for the element to be rendered in Internet Explorer 6, but not in Internet Explorer 7 or higher. Defaults to TRUE.
  • '!IE': If FALSE, the element is not rendered by browsers other than Internet Explorer. If TRUE, the element is rendered by those browsers. Defaults to TRUE. Examples:
  • To render an element in all browsers, '#browsers' can be left out or set to array('IE' => TRUE, '!IE' => TRUE).
  • To render an element in Internet Explorer only, '#browsers' can be set to array('!IE' => FALSE).
  • To render an element in Internet Explorer 6 only, '#browsers' can be set to array('IE' => 'lt IE 7', '!IE' => FALSE).
  • To render an element in Internet Explorer 8 and higher and in all other browsers, '#browsers' can be set to array('IE' => 'gte IE 8').
Returns
The passed-in element with markup for conditional comments potentially added to '#prefix' and '#suffix'.

Definition at line 5500 of file common.inc.

drupal_pre_render_link ( $element )

#pre_render callback to render a link into #markup.

Doing so during pre_render gives modules a chance to alter the link parts.

Parameters
$elements A structured array whose keys form the arguments to l():
  • title: The link text to pass as argument to l().
  • #href: The URL path component to pass as argument to l().
  • #options: (optional) An array of options to pass to l().
Returns
The passed-in elements containing a rendered link in '#markup'.

Definition at line 5561 of file common.inc.

References ajax_pre_render_element(), drupal_html_id(), and l().

drupal_pre_render_links ( $element )

#pre_render callback that collects child links into a single array.

This function can be added as a pre_render callback for a renderable array, usually one which will be themed by theme_links(). It iterates through all unrendered children of the element, collects any #links properties it finds, merges them into the parent element's #links array, and prevents those children from being rendered separately.

The purpose of this is to allow links to be logically grouped into related categories, so that each child group can be rendered as its own list of links if drupal_render() is called on it, but calling drupal_render() on the parent element will still produce a single list containing all the remaining links, regardless of what group they were in.

A typical example comes from node links, which are stored in a renderable array similar to this:

* $node->content['links'] = array(
* '#theme' => 'links__node',
* '#pre_render' => array('drupal_pre_render_links'),
* 'comment' => array(
* '#theme' => 'links__node__comment',
* '#links' => array(
* // An array of links associated with node comments, suitable for
* // passing in to theme_links().
* ),
* ),
* 'statistics' => array(
* '#theme' => 'links__node__statistics',
* '#links' => array(
* // An array of links associated with node statistics, suitable for
* // passing in to theme_links().
* ),
* ),
* 'translation' => array(
* '#theme' => 'links__node__translation',
* '#links' => array(
* // An array of links associated with node translation, suitable for
* // passing in to theme_links().
* ),
* ),
* );
*

In this example, the links are grouped by functionality, which can be helpful to themers who want to display certain kinds of links independently. For example, adding this code to node.tpl.php will result in the comment links being rendered as a single list:

* print render($content['links']['comment']);
*

(where $node->content has been transformed into $content before handing control to the node.tpl.php template).

The pre_render function defined here allows the above flexibility, but also allows the following code to be used to render all remaining links into a single list, regardless of their group:

* print render($content['links']);
*

In the above example, this will result in the statistics and translation links being rendered together in a single list (but not the comment links, which were rendered previously on their own).

Because of the way this function works, the individual properties of each group (for example, a group-specific theme property such as 'links__node__comment' in the example above, or any other property such as #attributes or #pre_render that is attached to it) are only used when that group is rendered on its own. When the group is rendered together with other children, these child-specific properties are ignored, and only the overall properties of the parent are used.

Definition at line 5676 of file common.inc.

References element_children().

drupal_pre_render_markup ( $elements )

#pre_render callback to append contents in #markup to #children.

This needs to be a #pre_render callback, because eventually assigned #theme_wrappers will expect the element's rendered content in #children. Note that if also a theme is defined for the element, then the result of the theme callback will override #children.

Parameters
$elements A structured array using the #markup key.
Returns
The passed-in elements, but #markup appended to #children.
See Also
drupal_render()

Definition at line 5708 of file common.inc.

drupal_pre_render_styles ( $elements )

#pre_render callback to add the elements needed for CSS tags to be rendered.

For production websites, LINK tags are preferable to STYLE tags with statements, because:

  • They are the standard tag intended for linking to a resource.
  • On Firefox 2 and perhaps other browsers, CSS files included with statements don't get saved when saving the complete web page for offline use: http://drupal.org/node/145218.
  • On IE, if only LINK tags and no statements are used, all the CSS files are downloaded in parallel, resulting in faster page load, but if statements are used and span across multiple STYLE tags, all the ones from one STYLE tag must be downloaded before downloading begins for the next STYLE tag. Furthermore, IE7 does not support media declaration on the statement, so multiple STYLE tags must be used when different files are for different media types. Non-IE browsers always download in parallel, so this is an IE-specific performance quirk: http://www.stevesouders.com/blog/2009/04/09/dont-use-import/.

However, IE has an annoying limit of 31 total CSS inclusion tags (http://drupal.org/node/228818) and LINK tags are limited to one file per tag, whereas STYLE tags can contain multiple statements allowing multiple files to be loaded per tag. When CSS aggregation is disabled, a Drupal site can easily have more than 31 CSS files that need to be loaded, so using LINK tags exclusively would result in a site that would display incorrectly in IE. Depending on different needs, different strategies can be employed to decide when to use LINK tags and when to use STYLE tags.

The strategy employed by this function is to use LINK tags for all aggregate files and for all files that cannot be aggregated (e.g., if 'preprocess' is set to FALSE or the type is 'external'), and to use STYLE tags for groups of files that could be aggregated together but aren't (e.g., if the site-wide aggregation setting is disabled). This results in all LINK tags when aggregation is enabled, a guarantee that as many or only slightly more tags are used with aggregation disabled than enabled (so that if the limit were to be crossed with aggregation enabled, the site developer would also notice the problem while aggregation is disabled), and an easy way for a developer to view HTML source while aggregation is disabled and know what files will be aggregated together when aggregation becomes enabled.

This function evaluates the aggregation enabled/disabled condition on a group by group basis by testing whether an aggregate file has been made for the group rather than by testing the site-wide aggregation setting. This allows this function to work correctly even if modules have implemented custom logic for grouping and aggregating files.

Parameters
$element A render array containing:
  • '#items': The CSS items as returned by drupal_add_css() and altered by drupal_get_css().
  • '#group_callback': A function to call to group #items to enable the use of fewer tags by aggregating files and/or using multiple statements within a single tag.
  • '#aggregate_callback': A function to call to aggregate the items within the groups arranged by the #group_callback function.
Returns
A render array that will render to a string of XHTML CSS tags.
See Also
drupal_get_css()

Definition at line 3359 of file common.inc.

References check_plain(), file_create_url(), and variable_get().

drupal_process_attached | ( | $elements,
 |  | $group = JS_DEFAULT,
 |  | $dependency_check = FALSE,
 |  | $every_page = NULL
 | ) |

Adds attachments to a render() structure.

Libraries, JavaScript, CSS and other types of custom structures are attached to elements using the #attached property. The #attached property is an associative array, where the keys are the the attachment types and the values are the attached data. For example:

* $build['#attached'] = array(
* 'js' => array(drupal_get_path('module', 'taxonomy') . '/taxonomy.js'),
* 'css' => array(drupal_get_path('module', 'taxonomy') . '/taxonomy.css'),
* );
*

'js', 'css', and 'library' are types that get special handling. For any other kind of attached data, the array key must be the full name of the callback function and each value an array of arguments. For example:

* $build['#attached']['drupal_add_http_header'] = array(
* array('Content-Type', 'application/rss+xml; charset=utf-8'),
* );
*

External 'js' and 'css' files can also be loaded. For example:

* $build['#attached']['js'] = array(
* 'http://code.jquery.com/jquery-1.4.2.min.js' => array(
* 'type' => 'external',
* ),
* );
*
Parameters
$elements | The structured array describing the data being rendered.
$group | The default group of JavaScript and CSS being added. This is only applied to the stylesheets and JavaScript items that don't have an explicit group assigned to them.
$dependency_check | When TRUE, will exit if a given library's dependencies are missing. When set to FALSE, will continue to add the libraries, even though one or more dependencies are missing. Defaults to FALSE.
$every_page | Set to TRUE to indicate that the attachments are added to every page on the site. Only attachments with the every_page flag set to TRUE can participate in JavaScript/CSS aggregation.
Returns
FALSE if there were any missing library dependencies; TRUE if all library dependencies were met.
See Also
drupal_add_library()
drupal_add_js()
drupal_add_css()
drupal_render()

Definition at line 4472 of file common.inc.

References drupal_add_library().

Referenced by drupal_add_library(), drupal_render(), and drupal_render_cache_get().

drupal_process_states ( & $elements )

Adds JavaScript to change the state of an element based on another element.

A "state" means a certain property on a DOM element, such as "visible" or "checked". A state can be applied to an element, depending on the state of another element on the page. In general, states depend on HTML attributes and DOM element properties, which change due to user interaction.

Since states are driven by JavaScript only, it is important to understand that all states are applied on presentation only, none of the states force any server-side logic, and that they will not be applied for site visitors without JavaScript support. All modules implementing states have to make sure that the intended logic also works without JavaScript being enabled.

#states is an associative array in the form of:

* array(
* STATE1 => CONDITIONS_ARRAY1,
* STATE2 => CONDITIONS_ARRAY2,
* ...
* )
*

Each key is the name of a state to apply to the element, such as 'visible'. Each value is a list of conditions that denote when the state should be applied.

Multiple different states may be specified to act on complex conditions:

* array(
* 'visible' => CONDITIONS,
* 'checked' => OTHER_CONDITIONS,
* )
*

Every condition is a key/value pair, whose key is a jQuery selector that denotes another element on the page, and whose value is an array of conditions, which must bet met on that element:

* array(
* 'visible' => array(
* JQUERY_SELECTOR => REMOTE_CONDITIONS,
* JQUERY_SELECTOR => REMOTE_CONDITIONS,
* ...
* ),
* )
*

All conditions must be met for the state to be applied.

Each remote condition is a key/value pair specifying conditions on the other element that need to be met to apply the state to the element:

* array(
* 'visible' => array(
* ':input[name="remote_checkbox"]' => array('checked' => TRUE),
* ),
* )
*

For example, to show a textfield only when a checkbox is checked:

* $form['toggle_me'] = array(
* '#type' => 'checkbox',
* '#title' => t('Tick this box to type'),
* );
* $form['settings'] = array(
* '#type' => 'textfield',
* '#states' => array(
* // Only show this field when the 'toggle_me' checkbox is enabled.
* 'visible' => array(
* ':input[name="toggle_me"]' => array('checked' => TRUE),
* ),
* ),
* );
*

The following states may be applied to an element:

  • enabled
  • disabled
  • required
  • optional
  • visible
  • invisible
  • checked
  • unchecked
  • expanded
  • collapsed

The following states may be used in remote conditions:

  • empty
  • filled
  • checked
  • unchecked
  • expanded
  • collapsed
  • value

The following states exist for both elements and remote conditions, but are not fully implemented and may not change anything on the element:

  • relevant
  • irrelevant
  • valid
  • invalid
  • touched
  • untouched
  • readwrite
  • readonly

When referencing select lists and radio buttons in remote conditions, a 'value' condition must be used:

* '#states' => array(
* // Show the settings if 'bar' has been selected for 'foo'.
* 'visible' => array(
* ':input[name="foo"]' => array('value' => 'bar'),
* ),
* ),
*
Parameters
$elements A renderable array element having a #states property as described above.
See Also
form_example_states_form()

Definition at line 4660 of file common.inc.

Referenced by drupal_render().

drupal_region_class ( $region )

Provides a standard HTML class name that identifies a page region.

It is recommended that template preprocess functions apply this class to any page region that is output by the theme (Drupal core already handles this in the standard template preprocess implementation). Standardizing the class names in this way allows modules to implement certain features, such as drag-and-drop or dynamic Ajax loading, in a theme-independent way.

Parameters
$region The name of the page region (for example, 'page_top' or 'content').
Returns
An HTML class that identifies the region (for example, 'region-page-top' or 'region-content').
See Also
template_preprocess_region()

Definition at line 3976 of file common.inc.

References drupal_html_class().

Referenced by overlay_request_refresh(), and template_preprocess_region().

drupal_render ( & $elements )

Renders HTML given a structured array tree.

Recursively iterates over each of the array elements, generating HTML code.

Renderable arrays have two kinds of key/value pairs: properties and children. Properties have keys starting with '#' and their values influence how the array will be rendered. Children are all elements whose keys do not start with a '#'. Their values should be renderable arrays themselves, which will be rendered during the rendering of the parent array. The markup provided by the children is typically inserted into the markup generated by the parent array.

HTML generation for a renderable array, and the treatment of any children, is controlled by two properties containing theme functions, theme and #theme_wrappers.

theme is the theme function called first. If it is set and the element has any children, it is the responsibility of the theme function to render these children. For elements that are not allowed to have any children, e.g. buttons or textfields, the theme function can be used to render the element itself. If theme is not present and the element has children, each child is itself rendered by a call to drupal_render(), and the results are concatenated.

The #theme_wrappers property contains an array of theme functions which will be called, in order, after theme has run. These can be used to add further markup around the rendered children; e.g., fieldsets add the required markup for a fieldset around their rendered child elements. All wrapper theme functions have to include the element's #children property in their output, as it contains the output of the previous theme functions and the rendered children.

For example, for the form element type, by default only the #theme_wrappers property is set, which adds the form markup around the rendered child elements of the form. This allows you to set the theme property on a specific form to a custom theme function, giving you complete control over the placement of the form's children while not at all having to deal with the form markup itself.

drupal_render() can optionally cache the rendered output of elements to improve performance. To use drupal_render() caching, set the element's #cache property to an associative array with one or several of the following keys:

  • 'keys': An array of one or more keys that identify the element. If 'keys' is set, the cache ID is created automatically from these keys. See drupal_render_cid_create().
  • 'granularity' (optional): Define the cache granularity using binary combinations of the cache granularity constants, e.g. DRUPAL_CACHE_PER_USER to cache for each user separately or DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE to cache separately for each page and role. If not specified the element is cached globally for each theme and language.
  • 'cid': Specify the cache ID directly. Either 'keys' or 'cid' is required. If 'cid' is set, 'keys' and 'granularity' are ignored. Use only if you have special requirements.
  • 'expire': Set to one of the cache lifetime constants.
  • 'bin': Specify a cache bin to cache the element in. Defaults to 'cache'.

This function is usually called from within another function, like drupal_get_form() or a theme function. Elements are sorted internally using uasort(). Since this is expensive, when passing already sorted elements to drupal_render(), for example from a database query, set $elements['#sorted'] = TRUE to avoid sorting them a second time.

drupal_render() flags each element with a '#printed' status to indicate that the element has been rendered, which allows individual elements of a given array to be rendered independently and prevents them from being rendered more than once on subsequent calls to drupal_render() (e.g., as part of a larger array). If the same array or array element is passed more than once to drupal_render(), it simply returns an empty string.

Parameters
array $elements The structured array describing the data to be rendered.
Returns
string The rendered HTML.

Definition at line 5834 of file common.inc.

References $children, $output, drupal_process_attached(), drupal_process_states(), drupal_render_cache_get(), drupal_render_cache_set(), element_children(), element_info(), and theme().

Referenced by _node_index_node(), _theme_table_cell(), ajax_prepare_response(), bartik_field__taxonomy_term_reference(), book_children(), book_node_export(), comment_node_update_index(), comment_unpublish_by_keyword_action(), dashboard_show_block_content(), drupal_get_css(), drupal_get_html_head(), drupal_render_children(), drupal_render_page(), file_ajax_upload(), hook_search_execute(), hook_tokens_alter(), hook_update_index(), install_run_task(), install_select_locale(), install_select_profile(), js_example_accordion(), locale_translate_export_screen(), locale_translate_seek_screen(), node_feed(), node_search_execute(), node_unpublish_by_keyword_action(), openid_redirect(), render(), system_themes_page(), template_preprocess_block_admin_display_form(), template_preprocess_poll_results(), template_preprocess_poll_vote(), template_preprocess_theming_example_text_form(), template_process_html(), theme_aggregator_categorize_items(), theme_book_admin_table(), theme_color_scheme_form(), theme_exposed_filters(), theme_field(), theme_field_multiple_value_form(), theme_field_ui_table(), theme_file_widget_multiple(), theme_filter_admin_format_filter_order(), theme_filter_admin_overview(), theme_image_anchor(), theme_image_style_effects(), theme_image_widget(), theme_locale_date_format_form(), theme_locale_languages_configure_form(), theme_locale_languages_overview_form(), theme_menu_link(), theme_menu_local_tasks(), theme_menu_overview_form(), theme_node_preview(), theme_node_search_admin(), theme_overlay_disable_message(), theme_poll_choices(), theme_profile_admin_overview(), theme_shortcut_set_customize(), theme_simpletest_test_table(), theme_system_date_time_settings(), theme_system_modules_fieldset(), theme_system_modules_uninstall(), theme_tabledrag_example_parent_form(), theme_tabledrag_example_simple_form(), theme_tableselect(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_user_admin_permissions(), theme_user_admin_roles(), and update_selection_page().

drupal_render_cache_by_query | ( | $query,
 |  | $function,
 |  | $expire = CACHE_TEMPORARY,
 |  | $granularity = NULL
 | ) |

Prepares an element for caching based on a query.

This smart caching strategy saves Drupal from querying and rendering to HTML when the underlying query is unchanged.

Expensive queries should use the query builder to create the query and then call this function. Executing the query and formatting results should happen in a #pre_render callback.

Parameters
$query | A select query object as returned by db_select().
$function | The name of the function doing this caching. A _pre_render suffix will be added to this string and is also part of the cache key in drupal_render_cache_set() and drupal_render_cache_get().
$expire | The cache expire time, passed eventually to cache_set().
$granularity | One or more granularity constants passed to drupal_render_cid_parts().
Returns
A renderable array with the following keys and values:
  • #query: The passed-in $query.
  • #pre_render: $function with a _pre_render suffix.
  • #cache: An associative array prepared for drupal_render_cache_set().

Definition at line 6192 of file common.inc.

References drupal_render_cid_parts().

Referenced by forum_block_view().

drupal_render_cache_get ( $elements )

Gets the rendered output of a renderable element from the cache.

Parameters
$elements A renderable array.
Returns
A markup string containing the rendered content of the element, or FALSE if no cached copy of the element is available.
See Also
drupal_render()
drupal_render_cache_set()

Definition at line 6068 of file common.inc.

References cache_get(), drupal_process_attached(), and drupal_render_cid_create().

Referenced by drupal_render().

drupal_render_cache_set | ( | & | $markup,
 |  |  | $elements
 | ) |  |

Caches the rendered output of a renderable element.

This is called by drupal_render() if the #cache property is set on an element.

Parameters
$markup | The rendered output string of $elements.
$elements | A renderable array.
See Also
drupal_render_cache_get()

Definition at line 6099 of file common.inc.

References CACHE_PERMANENT, cache_set(), drupal_render_cid_create(), and drupal_render_collect_attached().

Referenced by drupal_render().

drupal_render_children | ( | & | $element,
 |  |  | $children_keys = NULL
 | ) |  |

Renders children of an element and concatenates them.

This renders all children of an element using drupal_render() and then joins them together into a single string.

Parameters
$element | The structured array whose children shall be rendered.
$children_keys | If the keys of the element's children are already known, they can be passed in to save another run of element_children().

Definition at line 5958 of file common.inc.

References $output, drupal_render(), and element_children().

Referenced by template_preprocess_block_admin_display_form(), template_preprocess_poll_vote(), theme_aggregator_categorize_items(), theme_color_scheme_form(), theme_confirm_form(), theme_date(), theme_exposed_filters(), theme_file_managed_file(), theme_file_widget(), theme_file_widget_multiple(), theme_filter_admin_format_filter_order(), theme_filter_admin_overview(), theme_forum_form(), theme_image_widget(), theme_locale_date_format_form(), theme_locale_languages_configure_form(), theme_locale_languages_overview_form(), theme_menu_overview_form(), theme_node_search_admin(), theme_poll_choices(), theme_profile_admin_overview(), theme_shortcut_set_customize(), theme_system_date_time_settings(), theme_system_modules_uninstall(), theme_system_settings_form(), theme_tabledrag_example_parent_form(), theme_tabledrag_example_simple_form(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_theming_example_select_form(), theme_trigger_display(), theme_update_manager_update_form(), theme_user_admin_permissions(), and theme_user_admin_roles().

drupal_render_cid_create ( $elements )

Creates the cache ID for a renderable element.

This creates the cache ID string, either by returning the #cache['cid'] property if present or by building the cache ID out of the #cache['keys'] and, optionally, the #cache['granularity'] properties.

Parameters
$elements A renderable array.
Returns
The cache ID string, or FALSE if the element may not be cached.

Definition at line 6266 of file common.inc.

References drupal_render_cid_parts().

Referenced by drupal_render_cache_get(), and drupal_render_cache_set().

drupal_render_cid_parts ( $granularity = NULL )

Returns cache ID parts for building a cache ID.

Parameters
$granularity One or more cache granularity constants. For example, to cache separately for each user, use DRUPAL_CACHE_PER_USER. To cache separately for each page and role, use the expression:
* DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE
*
Returns
An array of cache ID parts, always containing the active theme. If the locale module is enabled it also contains the active language. If $granularity was passed in, more parts are added.

Definition at line 6222 of file common.inc.

References DRUPAL_CACHE_PER_PAGE, DRUPAL_CACHE_PER_ROLE, DRUPAL_CACHE_PER_USER, drupal_multilingual(), language_types_configurable(), and request_uri().

Referenced by _block_get_cache_id(), drupal_render_cache_by_query(), and drupal_render_cid_create().

drupal_render_collect_attached | ( | $elements,
 |  | $return = FALSE
 | ) |

Collects #attached for an element and its children into a single array.

When caching elements, it is necessary to collect all libraries, JavaScript and CSS into a single array, from both the element itself and all child elements. This allows drupal_render() to add these back to the page when the element is returned from cache.

Parameters
$elements | The element to collect #attached from.
$return | Whether to return the attached elements and reset the internal static.
Returns
The #attached array for this element and its descendants.

Definition at line 6138 of file common.inc.

References $children, $value, drupal_static(), and element_children().

Referenced by drupal_render_cache_set().

drupal_render_page ( $page )

Renders the page, including all theming.

Parameters
$page A string or array representing the content of a page. The array consists of the following keys:
  • #type: Value is always 'page'. This pushes the theming through page.tpl.php (required).
  • #show_messages: Suppress drupal_get_message() items. Used by Batch API (optional).
See Also
hook_page_alter()
element_info()

Definition at line 5727 of file common.inc.

References $module, $page, drupal_alter(), drupal_render(), drupal_set_page_content(), drupal_static(), element_info(), and module_implements().

Referenced by drupal_deliver_html_page(), and overlay_render_region().

drupal_set_breadcrumb ( $breadcrumb = NULL )

Sets the breadcrumb trail for the current page.

Parameters
$breadcrumb Array of links, starting with "home" and proceeding up to but not including the current page.

Definition at line 243 of file common.inc.

References $breadcrumb, and drupal_static().

Referenced by blog_view(), comment_reply(), drupal_get_breadcrumb(), forum_node_view(), hook_view(), menu_edit_item(), taxonomy_term_page(), and template_preprocess_forums().

drupal_set_page_content ( $content = NULL )

Sets the main page content value for later use.

Given the nature of the Drupal page handling, this will be called once with a string or array. We store that and return it later as the block is being displayed.

Parameters
$content A string or renderable array representing the body of the page.
Returns
If called without $content, a renderable array representing the body of the page.

Definition at line 5454 of file common.inc.

References $content, and drupal_static().

Referenced by drupal_deliver_html_page(), drupal_render_page(), system_batch_page(), and system_block_view().

drupal_sort_css_js | ( | $a,
 |  | $b
 | ) |

Sorts CSS and JavaScript resources.

Callback for uasort() within:

  • drupal_get_css()
  • drupal_get_js()

This sort order helps optimize front-end performance while providing modules and themes with the necessary control for ordering the CSS and JavaScript appearing on a page.

Parameters
$a | First item for comparison. The compared items should be associative arrays of member items from drupal_add_css() or drupal_add_js().
$b | Second item for comparison.
See Also
drupal_add_css()
drupal_add_js()

Definition at line 3124 of file common.inc.

drupal_sort_title | ( | $a,
 |  | $b
 | ) |

Array sorting callback; sorts elements by 'title' key.

Definition at line 6368 of file common.inc.

drupal_sort_weight | ( | $a,
 |  | $b
 | ) |

Sorts a structured array by the 'weight' element.

Note that the sorting is by the 'weight' array element, not by the render element property '#weight'.

Callback for uasort() used in various functions.

Parameters
$a | First item for comparison. The compared items should be associative arrays that optionally include a 'weight' element. For items without a 'weight' element, a default value of 0 will be used.
$b | Second item for comparison.

Definition at line 6356 of file common.inc.

drupal_system_listing | ( | $mask,
 |  | $directory,
 |  | $key = 'name',
 |  | $min_depth = 1
 | ) |

Returns information about system object files (modules, themes, etc.).

This function is used to find all or some system object files (module files, theme files, etc.) that exist on the site. It searches in several locations, depending on what type of object you are looking for. For instance, if you are looking for modules and call:

* drupal_system_listing("/\.module$/", "modules", 'name', 0);
*

this function will search the site-wide modules directory (i.e., /modules/), your installation profile's directory (i.e., /profiles/your_site_profile/modules/), the all-sites directory (i.e., /sites/all/modules/), and your site-specific directory (i.e., /sites/your_site_dir/modules/), in that order, and return information about all of the files ending in .module in those directories.

The information is returned in an associative array, which can be keyed on the file name ($key = 'filename'), the file name without the extension ($key = 'name'), or the full file stream URI ($key = 'uri'). If you use a key of 'filename' or 'name', files found later in the search will take precedence over files found earlier (unless they belong to a module or theme not compatible with Drupal core); if you choose a key of 'uri', you will get all files found.

Parameters
string | $mask | The preg_match() regular expression for the files to find.
string | $directory | The subdirectory name in which the files are found. For example, 'modules' will search in sub-directories of the top-level /modules directory, sub-directories of /sites/all/modules/, etc.
string | $key | The key to be used for the associative array returned. Possible values are 'uri', for the file's URI; 'filename', for the basename of the file; and 'name' for the name of the file without the extension. If you choose 'name' or 'filename', only the highest-precedence file will be returned.
int | $min_depth | Minimum depth of directories to return files from, relative to each directory searched. For instance, a minimum depth of 2 would find modules inside /modules/node/tests, but not modules directly in /modules/node.
Returns
array An associative array of file objects, keyed on the chosen key. Each element in the array is an object containing file information, with properties:
  • 'uri': Full URI of the file.
  • 'filename': File name.
  • 'name': Name of file without the extension.

Definition at line 5368 of file common.inc.

References $dir, $info, conf_path(), DRUPAL_CORE_COMPATIBILITY, drupal_get_profile(), drupal_parse_info_file(), DRUPAL_ROOT, drupal_valid_test_ua(), file_scan_directory(), and variable_get().

Referenced by _system_rebuild_module_data(), _system_rebuild_theme_data(), drupal_find_theme_templates(), drupal_get_filename(), drupal_required_modules(), and drupal_verify_profile().

drupal_valid_token | ( | $token,
 |  | $value = '',
 |  | $skip_anonymous = FALSE
 | ) |

Validates a token based on $value, the user session, and the private key.

Parameters
$token | The token to be validated.
$value | An additional value to base the token on.
$skip_anonymous | Set to true to skip token validation for anonymous users.
Returns
True for a valid token, false for an invalid token. When $skip_anonymous is true, the return value will always be true for anonymous users.

Definition at line 5095 of file common.inc.

References $value, and drupal_get_token().

Referenced by aggregator_admin_refresh_feed(), ajax_base_page_theme(), color_palette_color_value(), comment_approve(), dashboard_update(), drupal_validate_form(), form_get_cache(), overlay_user_dismiss_message(), shortcut_link_add_inline(), system_theme_default(), system_theme_disable(), and system_theme_enable().

element_child ( $key )

Checks if the key is a child.

Definition at line 6395 of file common.inc.

Referenced by theme_locale_languages_configure_form(), and theme_locale_languages_overview_form().

element_children | ( | & | $elements,
 |  |  | $sort = FALSE
 | ) |  |

Identifies the children of an element array, optionally sorted by weight.

The children of a element array are those key/value pairs whose key does not start with a '#'. See drupal_render() for details.

Parameters
$elements | The element array whose children are to be identified.
$sort | Boolean to indicate whether the children should be sorted by weight.
Returns
The array keys of the element's children.

Definition at line 6413 of file common.inc.

References $children, and $value.

Referenced by _authorize_filetransfer_connection_settings_set_defaults(), _color_theme_select_form_alter(), _form_validate(), _simpletest_batch_operation(), book_admin_edit_submit(), dashboard_form_block_admin_configure_alter(), dashboard_form_block_admin_display_form_alter(), drupal_pre_render_links(), drupal_render(), drupal_render_children(), drupal_render_collect_attached(), element_get_visible_children(), field_ui_field_edit_instance_pre_render(), field_ui_table_pre_render(), file_field_widget_process(), file_field_widget_process_multiple(), filter_process_format(), form_builder(), form_pre_render_fieldset(), forum_overview(), hook_field_attach_view_alter(), image_field_widget_form(), menu_overview_form(), menu_overview_form_submit(), overlay_page_alter(), profile_admin_overview_submit(), rdf_field_attach_view_alter(), render_example_page_alter(), system_modules(), system_theme_settings(), template_preprocess_block_admin_display_form(), template_preprocess_book_all_books_block(), template_preprocess_comment(), template_preprocess_node(), template_preprocess_taxonomy_term(), template_preprocess_theming_example_text_form(), template_preprocess_user_profile(), theme_aggregator_categorize_items(), theme_book_admin_table(), theme_color_scheme_form(), theme_exposed_filters(), theme_field_multiple_value_form(), theme_field_ui_table(), theme_file_widget_multiple(), theme_filter_admin_format_filter_order(), theme_filter_admin_overview(), theme_image_anchor(), theme_image_style_effects(), theme_locale_date_format_form(), theme_menu_overview_form(), theme_node_search_admin(), theme_poll_choices(), theme_profile_admin_overview(), theme_render_example_aggregate(), theme_shortcut_set_customize(), theme_simpletest_test_table(), theme_system_date_time_settings(), theme_system_modules_fieldset(), theme_system_modules_uninstall(), theme_tabledrag_example_parent_form(), theme_tabledrag_example_simple_form(), theme_tableselect(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_theming_example_content_array(), theme_user_admin_permissions(), theme_user_admin_roles(), user_admin_settings(), user_cancel_confirm_form(), and user_multiple_cancel_confirm().

element_get_visible_children ( array $elements )

Returns the visible children of an element.

Parameters
$elements The parent element.
Returns
The array keys of the element's visible children.

Definition at line 6453 of file common.inc.

References element_children().

element_info ( $type )

Retrieves the default properties for the defined element type.

Parameters
$type An element type as defined by hook_element_info().

Definition at line 6306 of file common.inc.

References $info, drupal_alter(), drupal_static(), and module_invoke_all().

Referenced by ajax_prepare_response(), drupal_deliver_html_page(), drupal_prepare_form(), drupal_render(), drupal_render_page(), element_info_property(), file_field_widget_form(), filter_process_format(), form_builder(), form_process_weight(), and system_batch_page().

element_info_property | ( | $type,
 |  | $property_name,
 |  | $default = NULL
 | ) |

Retrieves a single property for the defined element type.

Parameters
$type | An element type as defined by hook_element_info().
$property_name | The property within the element type that should be returned.
$default | (Optional) The value to return if the element type does not specify a value for the property. Defaults to NULL.

Definition at line 6337 of file common.inc.

References $info, and element_info().

Referenced by field_ui_field_edit_form().

element_properties ( $element )

Gets properties of a structured array element (keys beginning with '#').

Definition at line 6388 of file common.inc.

Referenced by filter_process_format().

element_property ( $key )

Checks if the key is a property.

Definition at line 6381 of file common.inc.

element_set_attributes | ( | array & | $element,
 |  | array | $map
 | ) |  |

Sets HTML attributes based on element properties.

Parameters
$element | The renderable element to process.
$map | An associative array whose keys are element property names and whose values are the HTML attribute names to set for corresponding the property; e.g., array('#propertyname' => 'attributename'). If both names are identical except for the leading '#', then an attribute name value is sufficient and no property name needs to be specified.

Definition at line 6487 of file common.inc.

Referenced by theme_button(), theme_checkbox(), theme_fieldset(), theme_file(), theme_form(), theme_hidden(), theme_image_button(), theme_password(), theme_radio(), theme_select(), theme_textarea(), and theme_textfield().

element_sort | ( | $a,
 |  | $b
 | ) |

Function used by uasort to sort structured arrays by weight.

Definition at line 6282 of file common.inc.

element_sort_by_title | ( | $a,
 |  | $b
 | ) |

Array sorting callback; sorts elements by title.

Definition at line 6294 of file common.inc.

entity_create_stub_entity | ( | $entity_type,
 |  | $ids
 | ) |

Helper function to assemble an object structure with initial ids.

This function can be seen as reciprocal to entity_extract_ids().

Parameters
$entity_type | The entity type; e.g. 'node' or 'user'.
$ids | A numerically indexed array, as returned by entity_extract_ids().
Returns
An entity structure, initialized with the ids provided.
See Also
entity_extract_ids()

Definition at line 7749 of file common.inc.

References $info, and entity_get_info().

Referenced by file_field_update(), and EntityFieldQuery\finishQuery().

entity_extract_ids | ( | $entity_type,
 |  | $entity
 | ) |

Helper function to extract id, vid, and bundle name from an entity.

Parameters
$entity_type | The entity type; e.g. 'node' or 'user'.
$entity | The entity from which to extract values.
Returns
A numerically indexed array (not a hash table) containing these elements:
  • 0: Primary ID of the entity.
  • 1: Revision ID of the entity, or NULL if $entity_type is not versioned.
  • 2: Bundle name of the entity, or NULL if $entity_type has no bundles.

Definition at line 7711 of file common.inc.

References $info, and entity_get_info().

Referenced by _field_invoke(), _field_invoke_multiple(), entity_form_submit_build_entity(), entity_uri(), field_attach_delete(), field_attach_delete_revision(), field_attach_form(), field_attach_insert(), field_attach_load(), field_attach_preprocess(), field_attach_update(), field_attach_view(), field_default_form(), field_default_view(), field_language(), field_sql_storage_field_storage_delete(), field_sql_storage_field_storage_delete_revision(), field_sql_storage_field_storage_purge(), field_sql_storage_field_storage_write(), field_view_field(), file_field_delete(), file_field_delete_revision(), file_field_insert(), file_field_update(), hook_entity_delete(), hook_entity_insert(), hook_entity_update(), hook_field_delete(), hook_field_delete_revision(), hook_field_storage_delete(), hook_field_storage_delete_revision(), hook_field_storage_purge(), hook_field_storage_write(), locale_field_entity_form_submit(), rdf_entity_load(), and taxonomy_term_build_content().

entity_form_field_validate | ( |  | $entity_type,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Attaches field API validation to entity forms.

Definition at line 7997 of file common.inc.

References field_attach_form_validate().

Referenced by comment_form_validate(), node_form_validate(), taxonomy_form_term_validate(), user_profile_form_validate(), and user_register_validate().

entity_form_submit_build_entity | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Copies submitted values to entity properties for simple entity forms.

During the submission handling of an entity form's "Save", "Preview", and possibly other buttons, the form state's entity needs to be updated with the submitted form values. Each entity form implements its own builder function for doing this, appropriate for the particular entity and form, whereas modules may specify additional builder functions in $form['#entity_builders'] for copying the form values of added form elements to entity properties. Many of the main entity builder functions can call this helper function to re-use its logic of copying $form_state['values'][PROPERTY] values to $entity->PROPERTY for all entries in $form_state['values'] that are not field data, and calling field_attach_submit() to copy field data. Apart from that this helper invokes any additional builder functions that have been specified in $form['#entity_builders'].

For some entity forms (e.g., forms with complex non-field data and forms that simultaneously edit multiple entities), this behavior may be inappropriate, so the builder function for such forms needs to implement the required functionality instead of calling this function.

Definition at line 8028 of file common.inc.

References $info, $value, entity_extract_ids(), entity_get_info(), field_attach_submit(), and field_info_instances().

Referenced by comment_form_submit_build_comment(), node_form_submit_build_node(), taxonomy_form_term_submit_build_taxonomy_term(), taxonomy_form_vocabulary_submit(), user_profile_form_submit(), and user_register_submit().

entity_get_controller ( $entity_type )

Get the entity controller class for an entity type.

Definition at line 7832 of file common.inc.

References drupal_static(), and entity_get_info().

Referenced by entity_example_basic_add(), entity_example_basic_delete(), entity_example_basic_save(), entity_load(), entity_load_unchanged(), node_delete_multiple(), node_save(), taxonomy_terms_static_reset(), taxonomy_vocabulary_static_reset(), user_delete_multiple(), and user_save().

entity_get_info ( $entity_type = NULL )

Get the entity info array of an entity type.

Parameters
$entity_type The entity type, e.g. node, for which the info shall be returned, or NULL to return an array with info about all types.
See Also
hook_entity_info()
hook_entity_info_alter()

Definition at line 7617 of file common.inc.

References $name, cache_get(), cache_set(), drupal_alter(), drupal_schema_fields_sql(), drupal_static(), and module_invoke_all().

Referenced by DrupalDefaultEntityController\__construct(), _field_sql_storage_query_join_entity(), entity_create_stub_entity(), entity_extract_ids(), entity_form_submit_build_entity(), entity_get_controller(), entity_label(), entity_language(), entity_uri(), field_attach_delete(), field_attach_insert(), field_attach_load(), field_attach_update(), field_create_field(), field_extract_bundle(), field_has_translation_handler(), field_info_bundles(), field_read_instances(), field_ui_display_overview_form(), field_ui_display_overview_form_submit(), field_ui_menu(), field_view_mode_settings(), hook_entity_delete(), hook_entity_insert(), hook_entity_update(), FieldInfo\prepareExtraFields(), FieldInfo\prepareInstance(), EntityFieldQuery\propertyQuery(), rdf_mapping_load(), taxonomy_field_extra_fields(), and token_example_example_form().

entity_info_cache_clear ( )

Resets the cached information about entity types.

Definition at line 7690 of file common.inc.

References cache_clear_all(), and drupal_static_reset().

Referenced by drupal_flush_all_caches(), field_info_cache_clear(), field_ui_field_attach_rename_bundle(), module_disable(), module_enable(), and rdf_mapping_save().

entity_label | ( | $entity_type,
 |  | $entity
 | ) |

Returns the label of an entity.

See the 'label callback' component of the hook_entity_info() return value for more information.

Parameters
$entity_type | The entity type; e.g., 'node' or 'user'.
$entity | The entity for which to generate the label.
Returns
The entity label, or FALSE if not found.

Definition at line 7943 of file common.inc.

References $info, and entity_get_info().

entity_language | ( | $entity_type,
 |  | $entity
 | ) |

Returns the language of an entity.

Parameters
$entity_type | The entity type; e.g., 'node' or 'user'.
$entity | The entity for which to get the language.
Returns
A valid language code or NULL if the entity has no language support.

Definition at line 7967 of file common.inc.

References $info, and entity_get_info().

Referenced by _translation_tab_access(), comment_form(), comment_submit(), locale_field_entity_form_submit(), node_admin_nodes(), node_form(), node_search_execute(), node_tokens(), path_form_node_form_alter(), path_form_taxonomy_form_term_alter(), path_node_insert(), path_taxonomy_term_insert(), path_taxonomy_term_update(), taxonomy_form_term(), translation_language_switch_links_alter(), translation_node_get_translations(), translation_node_overview(), translation_node_update(), translation_node_validate(), translation_node_view(), user_profile_form(), and user_register_form().

entity_load | ( | $entity_type,
 |  | $ids = FALSE,
 |  | $conditions = array(),
 |  | $reset = FALSE
 | ) |

Load entities from the database.

The entities are stored in a static memory cache, and will not require database access if loaded again during the same page request.

The actual loading is done through a class that has to implement the DrupalEntityControllerInterface interface. By default, DrupalDefaultEntityController is used. Entity types can specify that a different class should be used by setting the 'controller class' key in hook_entity_info(). These classes can either implement the DrupalEntityControllerInterface interface, or, most commonly, extend the DrupalDefaultEntityController class. See node_entity_info() and the NodeController in node.module as an example.

Parameters
$entity_type | The entity type to load, e.g. node or user.
$ids | An array of entity IDs, or FALSE to load all entities.
$conditions | (deprecated) An associative array of conditions on the base table, where the keys are the database fields and the values are the values those fields must have. Instead, it is preferable to use EntityFieldQuery to retrieve a list of entity IDs loadable by this function.
$reset | Whether to reset the internal cache for the requested entity type.
Returns
An array of entity objects indexed by their ids. When no results are found, an empty array is returned.
See Also
hook_entity_info()
DrupalEntityControllerInterface
DrupalDefaultEntityController
EntityFieldQuery

Definition at line 7800 of file common.inc.

References entity_get_controller().

Referenced by comment_load_multiple(), entity_example_basic_load_multiple(), file_file_download(), file_load_multiple(), node_load_multiple(), taxonomy_term_load_multiple(), taxonomy_vocabulary_load_multiple(), token_example_example_form(), and user_load_multiple().

entity_load_unchanged | ( | $entity_type,
 |  | $id
 | ) |

Loads the unchanged, i.e. not modified, entity from the database.

Unlike entity_load() this function ensures the entity is directly loaded from the database, thus bypassing any static cache. In particular, this function is useful to determine changes by comparing the entity being saved to the stored entity.

Parameters
$entity_type | The entity type to load, e.g. node or user.
$id | The ID of the entity to load.
Returns
The unchanged entity, or FALSE if the entity cannot be loaded.

Definition at line 7823 of file common.inc.

References entity_get_controller().

Referenced by comment_save(), file_save(), node_save(), taxonomy_term_save(), taxonomy_vocabulary_save(), and user_save().

entity_prepare_view | ( | $entity_type,
 |  | $entities,
 |  | $langcode = NULL
 | ) |

Invoke hook_entity_prepare_view().

If adding a new entity similar to nodes, comments or users, you should invoke this function during the ENTITY_build_content() or ENTITY_view_multiple() phases of rendering to allow other modules to alter the objects during this phase. This is needed for situations where information needs to be loaded outside of ENTITY_load() - particularly when loading entities into one another - i.e. a user object into a node, due to the potential for unwanted side-effects such as caching and infinite recursion. By convention, entity_prepare_view() is called after field_attach_prepare_view() to allow entity level hooks to act on content loaded by field API.

Parameters
$entity_type | The type of entity, i.e. 'node', 'user'.
$entities | The entity objects which are being prepared for view, keyed by object ID.
$langcode | (optional) A language code to be used for rendering. Defaults to the global content language of the current request.
See Also
hook_entity_prepare_view()

Definition at line 7866 of file common.inc.

References module_invoke_all().

Referenced by comment_build_content(), comment_view_multiple(), entity_example_basic_view(), node_build_content(), node_view_multiple(), taxonomy_term_build_content(), taxonomy_term_view_multiple(), and user_build_content().

entity_uri | ( | $entity_type,
 |  | $entity
 | ) |

Returns the URI elements of an entity.

Parameters
$entity_type | The entity type; e.g. 'node' or 'user'.
$entity | The entity for which to generate a path.
Returns
An array containing the 'path' and 'options' keys used to build the URI of the entity, and matching the signature of url(). NULL if the entity has no URI of its own.

Definition at line 7902 of file common.inc.

References $info, entity_extract_ids(), and entity_get_info().

Referenced by image_field_formatter_view(), node_page_view(), node_search_execute(), rdf_preprocess_comment(), rdf_preprocess_user_profile(), taxonomy_field_formatter_view(), taxonomy_term_page(), taxonomy_tokens(), template_preprocess_comment(), template_preprocess_node(), template_preprocess_taxonomy_term(), and user_register_submit().

fix_gpc_magic ( )

Fixes double-escaping caused by "magic quotes" in some PHP installations.

See Also
_fix_gpc_magic()
_fix_gpc_magic_files()

Definition at line 1156 of file common.inc.

Referenced by _drupal_bootstrap_full().

flood_clear_event | ( | $name,
 |  | $identifier = NULL
 | ) |

Makes the flood control mechanism forget an event for the current visitor.

Parameters
$name | The name of an event.
$identifier | Optional identifier (defaults to the current user's IP address).

Definition at line 1267 of file common.inc.

References $name, db_delete(), and ip_address().

Referenced by user_login_final_validate().

flood_is_allowed | ( | $name,
 |  | $threshold,
 |  | $window = 3600,
 |  | $identifier = NULL
 | ) |

Checks whether a user is allowed to proceed with the specified event.

Events can have thresholds saying that each user can only do that event a certain number of times in a time window. This function verifies that the current user has not exceeded this threshold.

Parameters
$name | The unique name of the event.
$threshold | The maximum number of times each user can do this event per time window.
$window | Number of seconds in the time window for this event (default is 3600 seconds, or 1 hour).
$identifier | Unique identifier of the current user. Defaults to their IP address.
Returns
TRUE if the user is allowed to proceed. FALSE if they have exceeded the threshold and should not be allowed to proceed.

Definition at line 1298 of file common.inc.

References $name, db_query(), ip_address(), and REQUEST_TIME.

Referenced by contact_personal_form(), contact_site_form(), and user_login_authenticate_validate().

flood_register_event | ( | $name,
 |  | $window = 3600,
 |  | $identifier = NULL
 | ) |

End of "defgroup validation". Registers an event for the current visitor to the flood control mechanism.

Parameters
$name | The name of an event.
$window | Optional number of seconds before this event expires. Defaults to 3600 (1 hour). Typically uses the same value as the flood_is_allowed() $window parameter. Expired events are purged on cron run to prevent the flood table from growing indefinitely.
$identifier | Optional identifier (defaults to the current user's IP address).

Definition at line 1245 of file common.inc.

References $name, db_insert(), ip_address(), and REQUEST_TIME.

Referenced by contact_personal_form_submit(), contact_site_form_submit(), and user_login_final_validate().

hide ( & $element )

Hides an element from later rendering.

The first time render() or drupal_render() is called on an element tree, as each element in the tree is rendered, it is marked with a #printed flag and the rendered children of the element are cached. Subsequent calls to render() or drupal_render() will not traverse the child tree of this element again: they will just use the cached children. So if you want to hide an element, be sure to call hide() on the element before its parent tree is rendered for the first time, as it will have no effect on subsequent renderings of the parent tree.

Parameters
$element The element to be hidden.
Returns
The element.
See Also
render()
show()

Definition at line 6021 of file common.inc.

Referenced by theme_file_widget_multiple().

l | ( |  | $text,
 |  |  | $path,
 |  | array | $options = array()
 | ) |  |

Formats an internal or external URL link as an HTML anchor tag.

This function correctly handles aliased paths and adds an 'active' class attribute to links that point to the current page (for theming), so all internal links output by modules should be generated by this function if possible.

However, for links enclosed in translatable text you should use t() and embed the HTML anchor tag directly in the translated string. For example:

* t('Visit the <a href="@url">settings</a> page', array('@url' => url('admin')));
*

This keeps the context of the link title ('settings' in the example) for translators.

Parameters
string | $text | The translated link text for the anchor tag.
string | $path | The internal path or external URL being linked to, such as "node/34" or "http://example.com/foo". After the url() function is called to construct the URL from $path and $options, the resulting URL is passed through check_plain() before it is inserted into the HTML anchor tag, to ensure well-formed HTML. See url() for more information and notes.
array $options An associative array of additional options. Defaults to an empty array. It may contain the following elements.
  • 'attributes': An associative array of HTML attributes to apply to the anchor tag. If element 'class' is included, it must be an array; 'title' must be a string; other elements are more flexible, as they just need to work in a call to drupal_attributes($options['attributes']).
  • 'html' (default FALSE): Whether $text is HTML or just plain-text. For example, to make an image tag into a link, this must be set to TRUE, or you will see the escaped HTML image tag. $text is not sanitized if 'html' is TRUE. The calling function must ensure that $text is already safe.
  • 'language': An optional language object. If the path being linked to is internal to the site, $options['language'] is used to determine whether the link is "active", or pointing to the current page (the language as well as the path must match). This element is also used by url().
  • Additional $options elements used by the url() function.
Returns
string An HTML string containing a link to the given path.
See Also
url()

Definition at line 2432 of file common.inc.

References check_plain(), drupal_attributes(), drupal_is_front_page(), drupal_theme_initialize(), language, theme(), theme_get_registry(), url(), and variable_get().

Referenced by _field_permission_example_page(), _filter_example_information(), _locale_translate_seek(), _menu_overview_tree_form(), _node_mass_update_batch_process(), _openid_user_login_form_alter(), _statistics_link(), _update_requirement_check(), actions_synchronize(), aggregator_form_category_submit(), aggregator_form_feed_submit(), aggregator_view(), ajax_example_intro(), ajax_example_node_by_author_autocomplete_submit(), ajax_example_render_link(), block_help(), blog_user_view(), blog_view(), book_admin_edit_submit(), book_admin_overview(), book_render(), comment_form_submit(), comment_reply(), contact_category_edit_form_submit(), contact_category_list(), dashboard_permission(), dblog_event(), drupal_pre_render_link(), entity_example_basic_list_entities(), entity_example_info_page(), field_help(), field_ui_fields_list(), file_example_managed_write_submit(), file_example_read_submit(), file_example_unmanaged_php_submit(), file_example_unmanaged_write_submit(), filter_permission(), forum_node_view(), help_links_as_list(), help_page(), hook_requirements(), hook_user_view(), hook_view(), image_example_help(), locale_date_format_language_overview_page(), menu_edit_item(), menu_get_active_breadcrumb(), menu_overview_page(), node_access_example_private_node_listing(), node_form_submit(), node_overview_types(), node_page_default(), node_requirements(), node_revision_overview(), node_title_list(), node_type_form_submit(), openid_user_identities(), path_admin_overview(), poll_page(), ModuleUpdater\postInstallTasks(), ThemeUpdater\postInstallTasks(), profile_admin_overview(), profile_block_view(), profile_field_delete_submit(), profile_field_form_submit(), search_view(), seven_admin_block_content(), seven_node_add_list(), shortcut_set_admin(), shortcut_set_customize(), statistics_access_log(), statistics_node_tracker(), statistics_recent_hits(), statistics_top_visitors(), statistics_user_tracker(), syslog_form_system_logging_settings_alter(), system_actions_manage(), system_date_time_formats(), system_ip_blocking(), system_requirements(), system_token_info(), tablesort_header(), taxonomy_form_term_submit(), taxonomy_form_vocabulary_submit(), taxonomy_term_page(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_item(), template_preprocess_comment(), template_preprocess_forum_topic_list(), template_preprocess_forums(), template_preprocess_user_picture(), theme_admin_block_content(), theme_book_admin_table(), theme_book_title_link(), theme_comment_block(), theme_dashboard_disabled_blocks(), theme_dblog_message(), theme_feed_icon(), theme_file_link(), theme_filter_tips_more_info(), theme_image_formatter(), theme_image_style_list(), theme_image_style_preview(), theme_links(), theme_locale_languages_overview_form(), theme_menu_link(), theme_menu_local_action(), theme_menu_local_task(), theme_more_help_link(), theme_more_link(), theme_node_add_list(), theme_node_recent_block(), theme_node_recent_content(), theme_system_compact_link(), theme_toolbar_toggle(), theme_update_last_check(), theme_update_report(), theme_update_version(), theme_user_admin_roles(), theme_username(), theming_example_page(), tracker_page(), translation_node_overview(), trigger_assign_form(), update_manager_update_form(), user_account_form(), user_login_block(), user_register_submit(), and DrupalTestCase\verbose().

render ( & $element )

Renders an element.

This function renders an element using drupal_render(). The top level element is shown with show() before rendering, so it will always be rendered even if hide() had been previously used on it.

Parameters
$element The element to be rendered.
Returns
The rendered element.
See Also
drupal_render()
show()
hide()

Definition at line 5988 of file common.inc.

References drupal_render(), and show().

Referenced by theme_file_widget_multiple().

show ( & $element )

Shows a hidden element for later rendering.

You can also use render($element), which shows the element while rendering it.

The first time render() or drupal_render() is called on an element tree, as each element in the tree is rendered, it is marked with a #printed flag and the rendered children of the element are cached. Subsequent calls to render() or drupal_render() will not traverse the child tree of this element again: they will just use the cached children. So if you want to show an element, be sure to call show() on the element before its parent tree is rendered for the first time, as it will have no effect on subsequent renderings of the parent tree.

Parameters
$element The element to be shown.
Returns
The element.
See Also
render()
hide()

Definition at line 6050 of file common.inc.

Referenced by render().

url | ( |  | $path = NULL,
 |  | array | $options = array()
 | ) |  |

End of "defgroup format". Generates an internal or external URL.

When creating links in modules, consider whether l() could be a better alternative than url().

Parameters
$path (optional) The internal path or external URL being linked to, such as "node/34" or "http://example.com/foo". The default value is equivalent to passing in '<front>'. A few notes:
  • If you provide a full URL, it will be considered an external URL.
  • If you provide only the path (e.g. "node/34"), it will be considered an internal link. In this case, it should be a system URL, and it will be replaced with the alias, if one exists. Additional query arguments for internal paths must be supplied in $options['query'], not included in $path.
  • If you provide an internal path and $options['alias'] is set to TRUE, the path is assumed already to be the correct path alias, and the alias is not looked up.
  • The special string '<front>' generates a link to the site's base URL.
  • If your external URL contains a query (e.g. http://example.com/foo?a=b), then you can either URL encode the query keys and values yourself and include them in $path, or use $options['query'] to let this function URL encode them.
$options (optional) An associative array of additional options, with the following elements:
  • 'query': An array of query key/value-pairs (without any URL-encoding) to append to the URL.
  • 'fragment': A fragment identifier (named anchor) to append to the URL. Do not include the leading '#' character.
  • 'absolute': Defaults to FALSE. Whether to force the output to be an absolute link (beginning with http:). Useful for links that will be displayed outside the site, such as in an RSS feed.
  • 'alias': Defaults to FALSE. Whether the given path is a URL alias already.
  • 'external': Whether the given path is an external URL.
  • 'language': An optional language object. If the path being linked to is internal to the site, $options['language'] is used to look up the alias for the URL. If $options['language'] is omitted, the global $language_url will be used.
  • 'https': Whether this URL should point to a secure location. If not defined, the current scheme is used, so the user stays on HTTP or HTTPS respectively. TRUE enforces HTTPS and FALSE enforces HTTP, but HTTPS can only be enforced when the variable 'https' is set to TRUE.
  • 'base_url': Only used internally, to modify the base URL when a language dependent URL requires so.
  • 'prefix': Only used internally, to modify the path when a language dependent URL requires so.
  • 'script': The script filename in Drupal's root directory to use when clean URLs are disabled, such as 'index.php'. Defaults to an empty string, as most modern web servers automatically find 'index.php'. If clean URLs are disabled, the value of $path is appended as query parameter 'q' to $options['script'] in the returned URL. When deploying Drupal on a web server that cannot be configured to automatically find index.php, then hook_url_outbound_alter() can be implemented to force this value to 'index.php'.
  • 'entity_type': The entity type of the object that called url(). Only set if url() is invoked by entity_uri().
  • 'entity': The entity object (such as a node) for which the URL is being generated. Only set if url() is invoked by entity_uri().
Returns
A string containing a URL to the given path.

Definition at line 2181 of file common.inc.

References $base_url, base_path(), drupal_alter(), drupal_encode_path(), drupal_get_path_alias(), drupal_http_build_query(), drupal_strip_dangerous_protocols(), language, and variable_get().

Referenced by _action_example_page(), _batch_progress_page_js(), _batch_progress_page_nojs(), _menu_site_is_offline(), _openid_user_login_form_alter(), _php_filter_tips(), _shortcut_link_form_elements(), _update_message_text(), _update_no_data(), _vertical_tabs_example_explanation(), aggregator_form_aggregator_admin_form_alter(), aggregator_form_feed(), aggregator_form_opml(), aggregator_help(), aggregator_page_categories(), aggregator_page_sources(), aggregator_view(), ajax_example_add_more(), ajax_example_dynamic_sections(), ajax_example_wizard(), ajax_pre_render_element(), DrupalWebTestCase\assertUrl(), batch_process(), block_custom_block_form(), block_example_page(), block_help(), block_update_7004(), blog_feed_last(), blog_feed_user(), blog_help(), book_help(), color_help(), color_update_7001(), comment_form(), comment_help(), comment_node_view(), comment_tokens(), contact_form_user_profile_form_alter(), contact_help(), contact_mail(), contact_site_form(), dashboard_admin(), dashboard_help(), dblog_form_system_logging_settings_alter(), dblog_help(), drupal_add_feed(), drupal_add_js(), drupal_goto(), drupal_validate_form(), DrupalWebTestCase\drupalGet(), DrupalWebTestCase\drupalHead(), DrupalWebTestCase\drupalSetContent(), field_help(), field_sql_storage_help(), field_system_info_alter(), field_ui_display_overview_form(), field_ui_display_overview_form_submit(), field_ui_help(), file_help(), filter_help(), filter_update_7005(), forum_confirm_delete(), forum_help(), forum_menu_local_tasks_alter(), forum_overview(), FileExampleSessionStreamWrapper\getExternalUrl(), DrupalPrivateStreamWrapper\getExternalUrl(), DrupalTemporaryStreamWrapper\getExternalUrl(), help_help(), hook_help(), hook_mail(), hook_requirements(), hook_search_execute(), hook_tokens(), hook_user_login(), image_help(), image_style_url(), install_finished(), l(), list_help(), locale_form_node_type_form_alter(), locale_help(), locale_languages_predefined_form_submit(), menu_configure(), menu_example_menu(), menu_help(), menu_overview_form(), node_example_help(), node_feed(), node_help(), node_overview_types(), node_page_view(), node_permission(), node_search_execute(), node_tokens(), number_help(), openid_authentication(), openid_login_validate(), openid_user_add_submit(), options_help(), overlay_close_dialog(), page_example_description(), path_admin_form(), path_admin_overview(), path_help(), php_enable(), php_help(), poll_help(), profile_block_configure(), profile_field_delete(), profile_help(), rdf_comment_load(), rdf_example_help(), rdf_preprocess_comment(), rdf_preprocess_taxonomy_term(), rdf_preprocess_user_profile(), rdf_preprocess_username(), render_example_info(), search_admin_settings(), seven_node_add_list(), shortcut_help(), shortcut_set_switch_submit(), simpletest_help(), simpletest_requirements(), simpletest_result_form(), statistics_access_log(), statistics_help(), statistics_node_view(), statistics_settings_form(), system_admin_config_page(), system_authorized_get_url(), system_check_http_request(), system_clean_url_settings(), system_configure_date_formats_form(), system_cron_settings(), system_date_time_formats(), system_date_time_settings(), system_help(), system_image_toolkit_settings(), system_modules(), system_modules_uninstall(), system_performance_settings(), system_permission(), system_requirements(), system_site_information_settings(), system_site_maintenance_mode(), system_tokens(), system_update_7013(), system_update_7067(), system_user_login(), taxonomy_field_formatter_view(), taxonomy_help(), taxonomy_overview_terms(), taxonomy_term_feed(), taxonomy_term_page(), taxonomy_tokens(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_item(), template_preprocess_book_navigation(), template_preprocess_forum_list(), template_preprocess_forum_topic_list(), template_preprocess_maintenance_page(), template_preprocess_node(), template_preprocess_page(), template_preprocess_taxonomy_term(), text_help(), theme_aggregator_page_rss(), theme_comment_post_forbidden(), theme_dashboard_disabled_blocks(), theme_image_style_list(), theme_link(), theme_node_add_list(), theme_pager_link(), theme_shortcut_set_customize(), theme_taxonomy_overview_vocabularies(), theme_textfield(), toolbar_help(), tracker_help(), tracker_page(), translation_form_node_type_form_alter(), translation_help(), trigger_assign_form(), trigger_example_help(), trigger_help(), update_help(), update_mail(), update_manager_update_ready_form(), update_settings(), user_account_form_validate(), user_admin_settings(), user_cancel_url(), user_help(), user_login_block(), user_login_final_validate(), user_pass_reset(), user_pass_reset_url(), user_permission(), user_register_submit(), user_search_execute(), user_tokens(), user_update_7002(), user_update_7017(), xmlrpc_example_alter_form(), xmlrpc_example_client_add_submit(), xmlrpc_example_client_form(), xmlrpc_example_client_multicall_submit(), xmlrpc_example_client_request_methods_submit(), xmlrpc_example_client_subtract_submit(), xmlrpc_example_info(), and xmlrpc_example_server_form().

url_is_external ( $path )

Returns TRUE if a path is external to Drupal (e.g. http://example.com).

If a path cannot be assessed by Drupal's menu handler, then we must treat it as potentially insecure.

Parameters
$path The internal path or external URL being linked to, such as "node/34" or "http://example.com/foo".
Returns
Boolean TRUE or FALSE, where TRUE indicates an external path.

Definition at line 2311 of file common.inc.

References drupal_strip_dangerous_protocols().

Referenced by drupal_goto(), drupal_valid_path(), form_builder(), menu_edit_item_validate(), menu_link_save(), overlay_init(), and shortcut_valid_link().

xmlrpc | ( | $url,
 |  | $args,
 |  | $options = array()
 | ) |

Performs one or more XML-RPC request(s).

Usage example:

* $result = xmlrpc('http://example.com/xmlrpc.php', array(
* 'service.methodName' => array($parameter, $second, $third),
* ));
*
Parameters
$url | An absolute URL of the XML-RPC endpoint.
$args | An associative array whose keys are the methods to call and whose values are the arguments to pass to the respective method. If multiple methods are specified, a system.multicall is performed.
$options | (optional) An array of options to pass along to drupal_http_request().
Returns
For one request: Either the return value of the method on success, or FALSE. If FALSE is returned, see xmlrpc_errno() and xmlrpc_error_msg(). For multiple requests: An array of results. Each result will either be the result returned by the method called, or an xmlrpc_error object if the call failed. See xmlrpc_error().

Definition at line 8081 of file common.inc.

References $url, _xmlrpc(), and DRUPAL_ROOT.

Referenced by xmlrpc_example_client_add_submit(), xmlrpc_example_client_multicall_submit(), xmlrpc_example_client_request_methods_submit(), xmlrpc_example_client_subtract_submit(), and xmlrpc_example_info().

Variable Documentation

const CSS_DEFAULT 0

The default group for module CSS files added to the page.

Definition at line 65 of file common.inc.

Referenced by drupal_add_css().

const CSS_SYSTEM -100

The default group for system CSS files added to the page.

Definition at line 60 of file common.inc.

Referenced by system_init().

const CSS_THEME 100

The default group for theme CSS files added to the page.

Definition at line 70 of file common.inc.

Referenced by _drupal_theme_initialize(), bartik_preprocess_html(), garland_preprocess_html(), and seven_preprocess_html().

const HTTP_REQUEST_TIMEOUT -1

Error code indicating that the request exceeded the specified timeout.

See Also
drupal_http_request()

Definition at line 92 of file common.inc.

Referenced by drupal_http_request().

const JS_DEFAULT 0

The default group for module JavaScript code added to the page.

Definition at line 80 of file common.inc.

Referenced by drupal_js_defaults(), and system_library().

const JS_LIBRARY -100

The default group for JavaScript and jQuery libraries added to the page.

Definition at line 75 of file common.inc.

Referenced by drupal_add_js(), drupal_add_library(), and system_library().

const JS_THEME 100

The default group for theme JavaScript code added to the page.

Definition at line 85 of file common.inc.

Referenced by _drupal_theme_initialize().

const SAVED_DELETED 3

Return status for saving which deleted an existing item.

Definition at line 55 of file common.inc.

Referenced by taxonomy_term_delete(), and taxonomy_vocabulary_delete().

const SAVED_NEW 1

Return status for saving which involved creating a new item.

Definition at line 45 of file common.inc.

Referenced by drupal_write_record(), DrupalWebTestCase\drupalCreateContentType(), filter_admin_format_form_submit(), filter_format_save(), forum_form_submit(), menu_save(), node_type_form_submit(), node_type_save(), taxonomy_form_term_submit(), and taxonomy_form_vocabulary_submit().

const SAVED_UPDATED 2

Return status for saving which involved an update to an existing item.

Definition at line 50 of file common.inc.

Referenced by drupal_write_record(), filter_admin_format_form_submit(), filter_format_save(), forum_form_submit(), menu_save(), node_type_form_submit(), node_type_save(), shortcut_set_save(), taxonomy_form_term_submit(), and taxonomy_form_vocabulary_submit().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/date.inc File Reference

  • includes
Functions
date.inc File Reference

Go to the source code of this file.

Functions

system_default_date_formats ()

Detailed Description

Initializes the list of date formats and their locales.

Definition in file date.inc.

Function Documentation

system_default_date_formats ( )

Provides a default system list of date formats for system_date_formats().

Definition at line 11 of file date.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/entity.inc File Reference

  • includes
Classes
entity.inc File Reference

Go to the source code of this file.

Classes

interface | DrupalEntityControllerInterface
class | DrupalDefaultEntityController
class | EntityFieldQueryException
class | EntityFieldQuery
class | EntityMalformedException
Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/errors.inc File Reference

  • includes
Functions
errors.inc File Reference

Go to the source code of this file.

Functions

drupal_error_levels ()
_drupal_error_handler_real ($error_level, $message, $filename, $line, $context)
_drupal_decode_exception ($exception)
_drupal_render_exception_safe ($exception)
error_displayable ($error=NULL)
_drupal_log_error ($error, $fatal=FALSE)
_drupal_get_last_caller ($backtrace)

Detailed Description

Functions for error handling.

Definition in file errors.inc.

Function Documentation

_drupal_decode_exception ( $exception )

Decodes an exception and retrieves the correct caller.

Parameters
$exception The exception object that was thrown.
Returns
An error in the format expected by _drupal_log_error().

Definition at line 88 of file errors.inc.

References _drupal_get_last_caller(), check_plain(), and WATCHDOG_ERROR.

Referenced by _drupal_exception_handler(), _drupal_render_exception_safe(), DrupalTestCase\exceptionHandler(), update_do_one(), and watchdog_exception().

_drupal_error_handler_real | ( | $error_level,
 |  | $message,
 |  | $filename,
 |  | $line,
 |  | $context
 | ) |

Provides custom PHP error handling.

Parameters
$error_level | The level of the error raised.
$message | The error message.
$filename | The filename that the error was raised in.
$line | The line number the error was raised at.
$context | An array that points to the active symbol table at the point the error occurred.

Definition at line 55 of file errors.inc.

References _drupal_get_last_caller(), _drupal_log_error(), drupal_error_levels(), DRUPAL_ROOT, and filter_xss_admin().

Referenced by _drupal_error_handler().

_drupal_get_last_caller ( $backtrace )

Gets the last caller from a backtrace.

Parameters
$backtrace A standard PHP backtrace.
Returns
An associative array with keys 'file', 'line' and 'function'.

Definition at line 260 of file errors.inc.

Referenced by _drupal_decode_exception(), _drupal_error_handler_real(), DrupalTestCase\errorHandler(), DrupalTestCase\exceptionHandler(), and DrupalTestCase\getAssertionCall().

_drupal_log_error | ( | $error,
 |  | $fatal = FALSE
 | ) |

Logs a PHP error or exception and displays an error page in fatal cases.

Parameters
$error | An array with the following keys: type, !message, function, file, line and severity_level. All the parameters are plain-text, with the exception of !message, which needs to be a safe HTML string.
$fatal | TRUE if the error is fatal.

Definition at line 171 of file errors.inc.

References drupal_add_http_header(), DRUPAL_BOOTSTRAP_FULL, drupal_get_bootstrap_phase(), drupal_is_cli(), drupal_maintenance_theme(), drupal_set_message(), drupal_set_title(), error_displayable(), print, t(), theme(), and watchdog().

Referenced by _drupal_error_handler_real(), and _drupal_exception_handler().

_drupal_render_exception_safe ( $exception )

Renders an exception error message without further exceptions.

Parameters
$exception The exception object that was thrown.
Returns
An error message.

Definition at line 134 of file errors.inc.

References _drupal_decode_exception(), and check_plain().

Referenced by _drupal_exception_handler(), _drupal_session_write(), and _drupal_shutdown_function().

error_displayable ( $error = NULL )

Determines whether an error should be displayed.

When in maintenance mode or when error_level is ERROR_REPORTING_DISPLAY_ALL, all errors should be displayed. For ERROR_REPORTING_DISPLAY_SOME, $error will be examined to determine if it should be displayed.

Parameters
$error Optional error to examine for ERROR_REPORTING_DISPLAY_SOME.
Returns
TRUE if an error should be displayed.

Definition at line 151 of file errors.inc.

References ERROR_REPORTING_DISPLAY_ALL, ERROR_REPORTING_DISPLAY_SOME, MAINTENANCE_MODE, and variable_get().

Referenced by _drupal_exception_handler(), _drupal_log_error(), _drupal_session_write(), and _drupal_shutdown_function().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/file.inc File Reference

  • includes
Functions | Variables
file.inc File Reference

Go to the source code of this file.

Functions

file_get_stream_wrappers ($filter=STREAM_WRAPPERS_ALL)
file_stream_wrapper_get_class ($scheme)
file_uri_scheme ($uri)
file_stream_wrapper_valid_scheme ($scheme)
file_uri_target ($uri)
file_default_scheme ()
file_stream_wrapper_uri_normalize ($uri)
file_stream_wrapper_get_instance_by_uri ($uri)
file_stream_wrapper_get_instance_by_scheme ($scheme)
file_create_url ($uri)
file_prepare_directory (&$directory, $options=FILE_MODIFY_PERMISSIONS)
file_ensure_htaccess ()
file_create_htaccess ($directory, $private=TRUE, $force_overwrite=FALSE)
file_htaccess_lines ($private=TRUE)
file_load_multiple ($fids=array(), $conditions=array())
file_load ($fid)
file_save (stdClass $file)
file_usage_list (stdClass $file)
file_usage_add (stdClass $file, $module, $type, $id, $count=1)
file_usage_delete (stdClass $file, $module, $type=NULL, $id=NULL, $count=1)
file_copy (stdClass $source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
file_valid_uri ($uri)
file_unmanaged_copy ($source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
file_build_uri ($path)
file_destination ($destination, $replace)
file_move (stdClass $source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
file_unmanaged_move ($source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
file_munge_filename ($filename, $extensions, $alerts=TRUE)
file_unmunge_filename ($filename)
file_create_filename ($basename, $directory)
file_delete (stdClass $file, $force=FALSE)
file_unmanaged_delete ($path)
file_unmanaged_delete_recursive ($path)
file_space_used ($uid=NULL, $status=FILE_STATUS_PERMANENT)
file_save_upload ($source, $validators=array(), $destination=FALSE, $replace=FILE_EXISTS_RENAME)
drupal_move_uploaded_file ($filename, $uri)
file_validate (stdClass &$file, $validators=array())
file_validate_name_length (stdClass $file)
file_validate_extensions (stdClass $file, $extensions)
file_validate_size (stdClass $file, $file_limit=0, $user_limit=0)
file_validate_is_image (stdClass $file)
file_validate_image_resolution (stdClass $file, $maximum_dimensions=0, $minimum_dimensions=0)
file_save_data ($data, $destination=NULL, $replace=FILE_EXISTS_RENAME)
file_unmanaged_save_data ($data, $destination=NULL, $replace=FILE_EXISTS_RENAME)
file_transfer ($uri, $headers)
file_download ()
file_scan_directory ($dir, $mask, $options=array(), $depth=0)
file_upload_max_size ()
file_get_mimetype ($uri, $mapping=NULL)
drupal_chmod ($uri, $mode=NULL)
drupal_unlink ($uri, $context=NULL)
drupal_realpath ($uri)
drupal_dirname ($uri)
drupal_basename ($uri, $suffix=NULL)
drupal_mkdir ($uri, $mode=NULL, $recursive=FALSE, $context=NULL)
drupal_rmdir ($uri, $context=NULL)
drupal_tempnam ($directory, $prefix)
file_directory_temp ()
file_get_content_headers ($file)

Variables

const | FILE_CREATE_DIRECTORY 1
const | FILE_MODIFY_PERMISSIONS 2
const | FILE_EXISTS_RENAME 0
const | FILE_EXISTS_REPLACE 1
const | FILE_EXISTS_ERROR 2
const | FILE_STATUS_PERMANENT 1

Detailed Description

API for handling file uploads and server file management.

Definition in file file.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/file.mimetypes.inc File Reference

  • includes
Functions
file.mimetypes.inc File Reference

Go to the source code of this file.

Functions

file_mimetype_mapping ()
file_default_mimetype_mapping ()

Detailed Description

Provides mimetype mappings.

Definition in file file.mimetypes.inc.

Function Documentation

file_default_mimetype_mapping ( )

Default MIME extension mapping.

Returns
Array of mimetypes correlated to the extensions that relate to them.
See Also
file_get_mimetype()

Definition at line 36 of file file.mimetypes.inc.

Referenced by file_mimetype_mapping().

file_mimetype_mapping ( )

Return an array of MIME extension mappings.

Returns the mapping after modules have altered the default mapping.

Returns
Array of mimetypes correlated to the extensions that relate to them.
See Also
file_get_mimetype()

Definition at line 18 of file file.mimetypes.inc.

References drupal_alter(), drupal_static(), and file_default_mimetype_mapping().

Referenced by FileExampleSessionStreamWrapper\getMimeType(), and DrupalLocalStreamWrapper\getMimeType().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/form.inc File Reference

  • includes
Functions
form.inc File Reference

Go to the source code of this file.

Functions

drupal_get_form ($form_id)
drupal_build_form ($form_id, &$form_state)
form_state_defaults ()
drupal_rebuild_form ($form_id, &$form_state, $old_form=NULL)
form_get_cache ($form_build_id, &$form_state)
form_set_cache ($form_build_id, $form, $form_state)
form_state_keys_no_cache ()
form_load_include (&$form_state, $type, $module, $name=NULL)
drupal_form_submit ($form_id, &$form_state)
drupal_retrieve_form ($form_id, &$form_state)
drupal_process_form ($form_id, &$form, &$form_state)
drupal_prepare_form ($form_id, &$form, &$form_state)
drupal_validate_form ($form_id, &$form, &$form_state)
drupal_redirect_form ($form_state)
_form_validate (&$elements, &$form_state, $form_id=NULL)
form_execute_handlers ($type, &$form, &$form_state)
form_set_error ($name=NULL, $message= '', $limit_validation_errors=NULL)
form_clear_error ()
form_get_errors ()
form_get_error ($element)
form_error (&$element, $message= '')
form_builder ($form_id, &$element, &$form_state)
_form_builder_handle_input_element ($form_id, &$element, &$form_state)
_form_element_triggered_scripted_submission ($element, &$form_state)
_form_button_was_clicked ($element, &$form_state)
form_state_values_clean (&$form_state)
form_type_image_button_value ($form, $input, $form_state)
form_type_checkbox_value ($element, $input=FALSE)
form_type_checkboxes_value ($element, $input=FALSE)
form_type_tableselect_value ($element, $input=FALSE)
form_type_radios_value (&$element, $input=FALSE)
form_type_password_confirm_value ($element, $input=FALSE)
form_type_select_value ($element, $input=FALSE)
form_type_textfield_value ($element, $input=FALSE)
form_type_token_value ($element, $input=FALSE)
form_set_value ($element, $value, &$form_state)
form_options_flatten ($array)
_form_options_flatten ($array)
form_process_select ($element)
theme_select ($variables)
form_select_options ($element, $choices=NULL)
form_get_options ($element, $key)
theme_fieldset ($variables)
theme_radio ($variables)
theme_radios ($variables)
form_process_password_confirm ($element)
password_confirm_validate ($element, &$element_state)
theme_date ($variables)
form_process_date ($element)
date_validate ($element)
map_month ($month)
weight_value (&$form)
form_process_radios ($element)
theme_checkbox ($variables)
theme_checkboxes ($variables)
form_pre_render_conditional_form_element ($element)
form_process_checkbox ($element, $form_state)
form_process_checkboxes ($element)
form_process_actions ($element, &$form_state)
form_process_container ($element, &$form_state)
theme_container ($variables)
theme_tableselect ($variables)
form_process_tableselect ($element)
form_process_machine_name ($element, &$form_state)
form_validate_machine_name (&$element, &$form_state)
form_process_fieldset (&$element, &$form_state)
form_pre_render_fieldset ($element)
form_process_vertical_tabs ($element, &$form_state)
theme_vertical_tabs ($variables)
theme_submit ($variables)
theme_button ($variables)
theme_image_button ($variables)
theme_hidden ($variables)
theme_textfield ($variables)
theme_form ($variables)
theme_textarea ($variables)
theme_password ($variables)
form_process_weight ($element)
theme_file ($variables)
theme_form_element ($variables)
theme_form_required_marker ($variables)
theme_form_element_label ($variables)
_form_set_class (&$element, $class=array())
element_validate_integer ($element, &$form_state)
element_validate_integer_positive ($element, &$form_state)
element_validate_number ($element, &$form_state)
batch_set ($batch_definition)
batch_process ($redirect=NULL, $url= 'batch', $redirect_callback= 'drupal_goto')
& batch_get ()
_batch_populate_queue (&$batch, $set_id)
_batch_queue ($batch_set)

Detailed Description

Functions for form and batch generation and processing.

Definition in file form.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/graph.inc File Reference

  • includes
Functions
graph.inc File Reference

Go to the source code of this file.

Functions

drupal_depth_first_search (&$graph)
_drupal_depth_first_search (&$graph, &$state, $start, &$component=NULL)

Detailed Description

Directed acyclic graph manipulation.

Definition in file graph.inc.

Function Documentation

_drupal_depth_first_search | ( | & | $graph,
 |  | & | $state,
 |  |  | $start,
 |  | & | $component = NULL
 | ) |  |

Performs a depth-first search on a graph.

Parameters
$graph | A three dimensional associated graph array.
$state | An associative array. The key 'last_visit_order' stores a list of the vertices visited. The key components stores list of vertices belonging to the same the component.
$start | An arbitrary vertex where we started traversing the graph.
$component | The component of the last vertex.
See Also
drupal_depth_first_search()

Definition at line 90 of file graph.inc.

Referenced by drupal_depth_first_search().

drupal_depth_first_search ( & $graph )

Performs a depth-first search and sort on a directed acyclic graph.

Parameters
$graph A three dimensional associated array, with the first keys being the names of the vertices, these can be strings or numbers. The second key is 'edges' and the third one are again vertices, each such key representing an edge. Values of array elements are copied over.

Example:

* $graph[1]['edges'][2] = 1;
* $graph[2]['edges'][3] = 1;
* $graph[2]['edges'][4] = 1;
* $graph[3]['edges'][4] = 1;
*

On return you will also have:

* $graph[1]['paths'][2] = 1;
* $graph[1]['paths'][3] = 1;
* $graph[2]['reverse_paths'][1] = 1;
* $graph[3]['reverse_paths'][1] = 1;
*
Returns
The passed-in $graph with more secondary keys filled in:
  • 'paths': Contains a list of vertices than can be reached on a path from this vertex.
  • 'reverse_paths': Contains a list of vertices that has a path from them to this vertex.
  • 'weight': If there is a path from a vertex to another then the weight of the latter is higher.
  • 'component': Vertices in the same component have the same component identifier.
See Also
_drupal_depth_first_search()

Definition at line 47 of file graph.inc.

References _drupal_depth_first_search().

Referenced by _module_build_dependencies(), and update_resolve_dependencies().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/image.inc File Reference

  • includes
Functions
image.inc File Reference

Go to the source code of this file.

Functions

image_get_available_toolkits ()
image_get_toolkit ()
image_toolkit_invoke ($method, stdClass $image, array $params=array())
image_get_info ($filepath, $toolkit=FALSE)
image_scale_and_crop (stdClass $image, $width, $height)
image_dimensions_scale (array &$dimensions, $width=NULL, $height=NULL, $upscale=FALSE)
image_scale (stdClass $image, $width=NULL, $height=NULL, $upscale=FALSE)
image_resize (stdClass $image, $width, $height)
image_rotate (stdClass $image, $degrees, $background=NULL)
image_crop (stdClass $image, $x, $y, $width, $height)
image_desaturate (stdClass $image)
image_load ($file, $toolkit=FALSE)
image_save (stdClass $image, $destination=NULL)

Detailed Description

API for manipulating images.

Definition in file image.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/install.core.inc File Reference

  • includes
Functions | Variables
install.core.inc File Reference

Go to the source code of this file.

Functions

install_drupal ($settings=array())
install_state_defaults ()
install_begin_request (&$install_state)
install_run_tasks (&$install_state)
install_run_task ($task, &$install_state)
install_tasks_to_perform ($install_state)
install_tasks ($install_state)
install_tasks_to_display ($install_state)
install_redirect_url ($install_state)
install_full_redirect_url ($install_state)
install_display_output ($output, $install_state)
install_verify_requirements (&$install_state)
install_system_module (&$install_state)
install_verify_completed_task ()
install_verify_settings ()
install_verify_pdo ()
install_settings_form ($form, &$form_state, &$install_state)
install_settings_form_validate ($form, &$form_state)
install_database_errors ($database, $settings_file)
install_settings_form_submit ($form, &$form_state)
install_find_profiles ()
install_select_profile (&$install_state)
_install_select_profile ($profiles)
install_select_profile_form ($form, &$form_state, $profile_files)
install_find_locales ($profilename)
install_select_locale (&$install_state)
install_select_locale_form ($form, &$form_state, $locales, $profilename)
install_no_profile_error ()
install_already_done_error ()
install_load_profile (&$install_state)
install_bootstrap_full (&$install_state)
install_profile_modules (&$install_state)
install_import_locales (&$install_state)
install_configure_form ($form, &$form_state, &$install_state)
install_import_locales_remaining (&$install_state)
install_finished (&$install_state)
_install_module_batch ($module, $module_name, &$context)
_install_profile_modules_finished ($success, $results, $operations)
install_check_requirements ($install_state)
_install_configure_form ($form, &$form_state, &$install_state)
install_configure_form_validate ($form, &$form_state)
install_configure_form_submit ($form, &$form_state)

Variables

const | INSTALL_TASK_SKIP 1
const | INSTALL_TASK_RUN_IF_REACHED 2
const | INSTALL_TASK_RUN_IF_NOT_COMPLETED 3

Detailed Description

API functions for installing Drupal.

Definition in file install.core.inc.

Function Documentation

_install_module_batch | ( |  | $module,
 |  |  | $module_name,
 |  | & | $context
 | ) |  |

Batch callback for batch installation of modules.

Definition at line 1590 of file install.core.inc.

References $module, module_enable(), and st().

_install_profile_modules_finished | ( | $success,
 |  | $results,
 |  | $operations
 | ) |

'Finished' callback for module installation batch.

Definition at line 1603 of file install.core.inc.

References drupal_flush_all_caches().

_install_select_profile ( $profiles )

Selects an installation profile.

A profile will be selected if:

  • Only one profile is available,
  • A profile was submitted through $_POST,
  • Exactly one of the profiles is marked as "exclusive". If multiple profiles are marked as "exclusive" then no profile will be selected.
Parameters
array $profiles An associative array of profiles with the machine-readable names as keys.
Returns
The machine-readable name of the selected profile or NULL if no profile was selected.

Definition at line 1084 of file install.core.inc.

References DRUPAL_ROOT, install_no_profile_error(), and install_profile_info().

Referenced by install_select_profile().

install_already_done_error ( )

Indicates that Drupal has already been installed.

Definition at line 1350 of file install.core.inc.

References $base_url, drupal_set_title(), and st().

Referenced by install_begin_request(), and install_verify_completed_task().

install_begin_request ( & $install_state )

Begins an installation request, modifying the installation state as needed.

This function performs commands that must run at the beginning of every page request. It throws an exception if the installation should not proceed.

Parameters
$install_state An array of information about the current installation state. This is modified with information gleaned from the beginning of the page request.

Definition at line 210 of file install.core.inc.

References $conf, $module_list, drupal_bootstrap(), DRUPAL_BOOTSTRAP_CONFIGURATION, drupal_language_initialize(), drupal_load(), drupal_maintenance_theme(), drupal_override_server_variables(), DRUPAL_ROOT, install_already_done_error(), install_verify_completed_task(), install_verify_settings(), module_list(), and variable_get().

Referenced by install_drupal().

install_bootstrap_full ( & $install_state )

Performs a full bootstrap of Drupal during installation.

Parameters
$install_state An array of information about the current installation state.

Definition at line 1382 of file install.core.inc.

References drupal_bootstrap(), and DRUPAL_BOOTSTRAP_FULL.

install_check_requirements ( $install_state )

Checks installation requirements and reports any errors.

Definition at line 1612 of file install.core.inc.

References base_path(), conf_path(), drupal_check_profile(), drupal_install_profile_distribution_name(), drupal_unlink(), drupal_verify_install_file(), FILE_EXIST, FILE_READABLE, FILE_WRITABLE, REQUIREMENT_ERROR, and st().

Referenced by install_verify_requirements().

install_configure_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for install_configure_form().

See Also
install_configure_form_validate()

Definition at line 1876 of file install.core.inc.

References module_enable(), user_load(), user_login_finalize(), user_save(), and variable_set().

install_configure_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for install_configure_form().

See Also
install_configure_form_submit()

Definition at line 1859 of file install.core.inc.

References form_error(), user_validate_mail(), and user_validate_name().

install_database_errors | ( | $database,
 |  | $settings_file
 | ) |

Checks a database connection and returns any errors.

Definition at line 960 of file install.core.inc.

References $databases, db_run_tasks(), drupal_get_database_types(), drupal_install_profile_distribution_name(), Database\parseConnectionInfo(), and st().

Referenced by install_settings_form_validate(), and install_verify_settings().

install_display_output | ( | $output,
 |  | $install_state
 | ) |

Displays themed installer output and ends the page request.

Installation tasks should use drupal_set_title() to set the desired page title, but otherwise this function takes care of theming the overall page output during every step of the installation.

Parameters
$output | The content to display on the main part of the page.
$install_state | An array of information about the current installation state.

Definition at line 693 of file install.core.inc.

References $output, drupal_add_html_head(), drupal_add_region_content(), drupal_page_header(), install_tasks_to_display(), print, and theme().

Referenced by install_drupal().

install_drupal ( $settings = array() )

Installs Drupal either interactively or via an array of passed-in settings.

The Drupal installation happens in a series of steps, which may be spread out over multiple page requests. Each request begins by trying to determine the last completed installation step (also known as a "task"), if one is available from a previous request. Control is then passed to the task handler, which processes the remaining tasks that need to be run until (a) an error is thrown, (b) a new page needs to be displayed, or (c) the installation finishes (whichever happens first).

Parameters
$settings An optional array of installation settings. Leave this empty for a normal, interactive, browser-based installation intended to occur over multiple page requests. Alternatively, if an array of settings is passed in, the installer will attempt to use it to perform the installation in a single page request (optimized for the command line) and not send any output intended for the web browser. See install_state_defaults() for a list of elements that are allowed to appear in this array.
See Also
install_state_defaults()

Definition at line 64 of file install.core.inc.

References $output, install_begin_request(), install_display_output(), install_goto(), install_redirect_url(), install_run_tasks(), and install_state_defaults().

install_find_locales ( $profilename )

Find all .po files for the current profile.

Definition at line 1191 of file install.core.inc.

References file_scan_directory().

Referenced by install_select_locale().

install_find_profiles ( )

Finds all .profile files.

Definition at line 1023 of file install.core.inc.

References file_scan_directory().

Referenced by install_select_profile().

install_finished ( & $install_state )

Finishes importing files at end of installation.

Parameters
$install_state An array of information about the current installation state.
Returns
A message informing the user that the installation is complete.

Definition at line 1555 of file install.core.inc.

References $messages, $output, db_update(), drupal_cron_run(), drupal_flush_all_caches(), drupal_get_profile(), drupal_get_schema(), drupal_install_profile_distribution_name(), drupal_set_message(), drupal_set_title(), PASS_THROUGH, st(), url(), and variable_set().

install_full_redirect_url ( $install_state )

Returns the complete URL redirected to during an installation request.

Parameters
$install_state An array of information about the current installation state.
Returns
The complete URL to redirect to.
See Also
install_redirect_url()

Definition at line 676 of file install.core.inc.

References $base_url, and install_redirect_url().

Referenced by install_run_task().

install_import_locales ( & $install_state )

Imports languages via a batch process during installation.

Parameters
$install_state An array of information about the current installation state.
Returns
The batch definition, if there are language files to import.

Definition at line 1448 of file install.core.inc.

References _locale_get_predefined_list(), DRUPAL_ROOT, LANGUAGE_LTR, locale_add_language(), locale_batch_by_language(), and variable_set().

install_import_locales_remaining ( & $install_state )

Installation task; import remaining languages via a batch process.

Parameters
$install_state An array of information about the current installation state.
Returns
The batch definition, if there are language files to import.

Definition at line 1535 of file install.core.inc.

References DRUPAL_ROOT, locale_batch_by_language(), variable_del(), and variable_get().

install_load_profile ( & $install_state )

Loads information about the chosen profile during installation.

Parameters
$install_state An array of information about the current installation state. The loaded profile information will be added here, or an exception will be thrown if the profile cannot be loaded.

Definition at line 1365 of file install.core.inc.

References DRUPAL_ROOT, install_profile_info(), and st().

install_no_profile_error ( )

Indicates that there are no profiles available.

Definition at line 1342 of file install.core.inc.

References drupal_set_title(), and st().

Referenced by _install_select_profile(), drupal_check_profile(), drupal_verify_profile(), and install_select_profile().

install_profile_modules ( & $install_state )

Installs required modules via a batch process.

Parameters
$install_state An array of information about the current installation state.
Returns
The batch definition.

Definition at line 1395 of file install.core.inc.

References $module, drupal_install_profile_distribution_name(), st(), system_rebuild_module_data(), variable_del(), and variable_get().

install_redirect_url ( $install_state )

Returns the URL that should be redirected to during an installation request.

The output of this function is suitable for sending to install_goto().

Parameters
$install_state An array of information about the current installation state.
Returns
The URL to redirect to.
See Also
install_full_redirect_url()

Definition at line 661 of file install.core.inc.

References drupal_http_build_query().

Referenced by install_drupal(), install_full_redirect_url(), and install_run_task().

install_run_task | ( |  | $task,
 |  | & | $install_state
 | ) |  |

Runs an individual installation task.

Parameters
$task | An array of information about the task to be run.
$install_state | An array of information about the current installation state. This is passed in by reference so that it can be modified by the task.
Returns
The output of the task function, if there is any.

Definition at line 373 of file install.core.inc.

References $output, _batch_page(), batch_get(), batch_process(), batch_set(), drupal_build_form(), drupal_form_submit(), drupal_render(), DRUPAL_ROOT, form_get_errors(), install_full_redirect_url(), install_redirect_url(), variable_del(), variable_get(), and variable_set().

Referenced by install_run_tasks().

install_run_tasks ( & $install_state )

Runs all tasks for the current installation request.

In the case of an interactive installation, all tasks will be attempted until one is reached that has output which needs to be displayed to the user, or until a page redirect is required. Otherwise, tasks will be attempted until the installation is finished.

Parameters
$install_state An array of information about the current installation state. This is passed along to each task, so it can be modified if necessary.
Returns
HTML output from the last completed task.

Definition at line 325 of file install.core.inc.

References $output, install_run_task(), INSTALL_TASK_RUN_IF_NOT_COMPLETED, install_tasks_to_perform(), and variable_set().

Referenced by install_drupal().

install_select_locale ( & $install_state )

Installation task; select which locale to use for the current profile.

Parameters
$install_state An array of information about the current installation state. The chosen locale will be added here, if it was not already selected previously, as will a list of all available locales.
Returns
For interactive installations, a form or other page output allowing the locale to be selected or providing information about locale selection, if a locale has not been chosen. Otherwise, an exception is thrown if a locale cannot be chosen automatically.

Definition at line 1220 of file install.core.inc.

References $output, drupal_get_form(), drupal_render(), DRUPAL_ROOT, drupal_set_title(), install_find_locales(), and st().

install_select_profile ( & $install_state )

Selects which profile to install.

Parameters
$install_state An array of information about the current installation state. The chosen profile will be added here, if it was not already selected previously, as will a list of all available profiles.
Returns
For interactive installations, a form allowing the profile to be selected, if the user has a choice that needs to be made. Otherwise, an exception is thrown if a profile cannot be chosen automatically.

Definition at line 1040 of file install.core.inc.

References _install_select_profile(), drupal_get_form(), drupal_render(), DRUPAL_ROOT, drupal_set_title(), install_find_profiles(), install_no_profile_error(), and st().

install_settings_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for install_settings_form().

See Also
install_settings_form_validate()

Definition at line 999 of file install.core.inc.

References drupal_random_key(), drupal_rewrite_settings(), and install_verify_completed_task().

install_settings_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for install_settings_form().

See Also
install_settings_form_submit()

Definition at line 940 of file install.core.inc.

References $name, form_set_error(), and install_database_errors().

install_state_defaults ( )

Returns an array of default settings for the global installation state.

The installation state is initialized with these settings at the beginning of each page request. They may evolve during the page request, but they are initialized again once the next request begins.

Non-interactive Drupal installations can override some of these default settings by passing in an array to the installation script, most notably 'parameters' (which contains one-time parameters such as 'profile' and 'locale' that are normally passed in via the URL) and 'forms' (which can be used to programmatically submit forms during the installation; the keys of each element indicate the name of the installation task that the form submission is for, and the values are used as the $form_state['values'] array that is passed on to the form submission via drupal_form_submit()).

See Also
drupal_form_submit()

Definition at line 124 of file install.core.inc.

Referenced by install_drupal().

install_system_module ( & $install_state )

Installation task; install the Drupal system module.

Parameters
$install_state An array of information about the current installation state.

Definition at line 780 of file install.core.inc.

References drupal_get_profile(), drupal_install_system(), file_ensure_htaccess(), module_enable(), and variable_set().

install_tasks ( $install_state )

Returns a list of all tasks the installer currently knows about.

This function will return tasks regardless of whether or not they are intended to run on the current page request. However, the list can change based on the installation state (for example, if an installation profile hasn't been selected yet, we don't yet know which profile tasks will be available).

Parameters
$install_state An array of information about the current installation state.
Returns
A list of tasks, with associated metadata.

Definition at line 520 of file install.core.inc.

References DRUPAL_ROOT, INSTALL_TASK_RUN_IF_NOT_COMPLETED, INSTALL_TASK_RUN_IF_REACHED, INSTALL_TASK_SKIP, and st().

Referenced by install_tasks_to_display(), and install_tasks_to_perform().

install_tasks_to_display ( $install_state )

Returns a list of tasks that should be displayed to the end user.

The output of this function is a list suitable for sending to theme_task_list().

Parameters
$install_state An array of information about the current installation state.
Returns
A list of tasks, with keys equal to the machine-readable task name and values equal to the name that should be displayed.
See Also
theme_task_list()

Definition at line 638 of file install.core.inc.

References $name, and install_tasks().

Referenced by install_display_output().

install_tasks_to_perform ( $install_state )

Returns a list of tasks to perform during the current installation request.

Note that the list of tasks can change based on the installation state as the page request evolves (for example, if an installation profile hasn't been selected yet, we don't yet know which profile tasks need to be run).

Parameters
$install_state An array of information about the current installation state.
Returns
A list of tasks to be performed, with associated metadata.

Definition at line 487 of file install.core.inc.

References $name, INSTALL_TASK_RUN_IF_REACHED, INSTALL_TASK_SKIP, and install_tasks().

Referenced by install_run_tasks().

install_verify_completed_task ( )

Verifies and returns the last installation task that was completed.

Returns
The last completed task, if there is one. An exception is thrown if Drupal is already installed.

Definition at line 816 of file install.core.inc.

References db_query(), and install_already_done_error().

Referenced by install_begin_request(), and install_settings_form_submit().

install_verify_pdo ( )

Verifies the PDO library.

Definition at line 856 of file install.core.inc.

Referenced by install_verify_settings().

install_verify_requirements ( & $install_state )

Verifies the requirements for installing Drupal.

Parameters
$install_state An array of information about the current installation state.
Returns
A themed status report, or an exception if there are requirement errors. If there are only requirement warnings, a themed status report is shown initially, but the user is allowed to bypass it by providing 'continue=1' in the URL. Otherwise, no output is returned, so that the next task can be run in the same page request.

Definition at line 736 of file install.core.inc.

References check_url(), drupal_requirements_severity(), drupal_requirements_url(), drupal_set_title(), drupal_verify_profile(), install_check_requirements(), REQUIREMENT_ERROR, REQUIREMENT_WARNING, st(), and theme().

install_verify_settings ( )

Verifies the existing settings in settings.php.

Definition at line 837 of file install.core.inc.

References $databases, conf_path(), drupal_static_reset(), install_database_errors(), and install_verify_pdo().

Referenced by install_begin_request().

Variable Documentation

const INSTALL_TASK_RUN_IF_NOT_COMPLETED 3

Global flag to indicate that a task should be run on each installation request that reaches it, until the database is set up and we are able to record the fact that it already ran.

This is the default method for running tasks and should be used for most tasks that occur after the database is set up; these tasks will then run once and be marked complete once they are successfully finished. For example, the Drupal installer uses this flag for the batch installation of modules on the new site, and also for the configuration form that collects basic site information and sets up the site maintenance account.

Definition at line 40 of file install.core.inc.

Referenced by hook_install_tasks(), install_run_tasks(), and install_tasks().

const INSTALL_TASK_RUN_IF_REACHED 2

Run the task on each installation request until the database is set up.

This is primarily used by the Drupal installer for bootstrap-related tasks.

Definition at line 26 of file install.core.inc.

Referenced by install_tasks(), and install_tasks_to_perform().

const INSTALL_TASK_SKIP 1

Do not run the task during the current installation request.

This can be used to skip running an installation task when certain conditions are met, even though the task may still show on the list of installation tasks presented to the user. For example, the Drupal installer uses this flag to skip over the database configuration form when valid database connection information is already available from settings.php. It also uses this flag to skip language import tasks when the installation is being performed in English.

Definition at line 19 of file install.core.inc.

Referenced by hook_install_tasks(), install_tasks(), and install_tasks_to_perform().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/install.inc File Reference

  • includes
Classes | Functions | Variables
install.inc File Reference

Go to the source code of this file.

Classes

class | DatabaseTasks
class | DatabaseTaskException

Functions

drupal_load_updates ()
drupal_get_schema_versions ($module)
drupal_get_installed_schema_version ($module, $reset=FALSE, $array=FALSE)
drupal_set_installed_schema_version ($module, $version)
drupal_install_profile_distribution_name ()
drupal_detect_baseurl ($file= 'install.php')
drupal_detect_database_types ()
drupal_get_database_types ()
drupal_rewrite_settings ($settings=array(), $prefix= '')
drupal_verify_profile ($install_state)
drupal_install_system ()
drupal_uninstall_modules ($module_list=array(), $uninstall_dependents=TRUE)
drupal_verify_install_file ($file, $mask=NULL, $type= 'file')
drupal_install_mkdir ($file, $mask, $message=TRUE)
drupal_install_fix_file ($file, $mask, $message=TRUE)
install_goto ($path)
drupal_current_script_url ($query=array())
drupal_requirements_url ($severity)
st ($string, array $args=array(), array $options=array())
drupal_check_profile ($profile)
drupal_requirements_severity (&$requirements)
drupal_check_module ($module)
install_profile_info ($profile, $locale= 'en')
db_run_tasks ($driver)
db_installer_object ($driver)

Variables

const | SCHEMA_UNINSTALLED -1
const | SCHEMA_INSTALLED 0
const | REQUIREMENT_INFO -1
const | REQUIREMENT_OK 0
const | REQUIREMENT_WARNING 1
const | REQUIREMENT_ERROR 2
const | FILE_EXIST 1
const | FILE_READABLE 2
const | FILE_WRITABLE 4
const | FILE_EXECUTABLE 8
const | FILE_NOT_EXIST 16
const | FILE_NOT_READABLE 32
const | FILE_NOT_WRITABLE 64
const | FILE_NOT_EXECUTABLE 128

Detailed Description

API functions for installing modules and themes.

Definition in file install.inc.

Function Documentation

db_installer_object ( $driver )

Returns a database installer object.

Parameters
$driver The name of the driver.

Definition at line 1328 of file install.inc.

References Database\loadDriverFile().

Referenced by db_run_tasks(), and drupal_get_database_types().

db_run_tasks ( $driver )

Ensures the environment for a Drupal database on a predefined connection.

This will run tasks that check that Drupal can perform all of the functions on a database, that Drupal needs. Tasks include simple checks like CREATE TABLE to database specific functions like stored procedures and client encoding.

Definition at line 1317 of file install.inc.

References db_installer_object().

Referenced by install_database_errors(), and update_prepare_d7_bootstrap().

drupal_check_module ( $module )

Checks a module's requirements.

Parameters
$module Machine name of module to check.
Returns
TRUE or FALSE, depending on whether the requirements are met.

Definition at line 1216 of file install.inc.

References $module, drupal_requirements_severity(), drupal_set_message(), module_hook(), module_invoke(), module_load_install(), REQUIREMENT_ERROR, and t().

Referenced by system_modules_submit().

drupal_check_profile ( $profile )

Checks an installation profile's requirements.

Parameters
$profile Name of installation profile to check.
Returns
Array of the installation profile's requirements.

Definition at line 1164 of file install.inc.

References $info, $module, DRUPAL_ROOT, install_no_profile_error(), install_profile_info(), and module_load_install().

Referenced by install_check_requirements().

drupal_current_script_url ( $query = array() )

Returns the URL of the current script, with modified query parameters.

This function can be called by low-level scripts (such as install.php and update.php) and returns the URL of the current script. Existing query parameters are preserved by default, but new ones can optionally be merged in.

This function is used when the script must maintain certain query parameters over multiple page requests in order to work correctly. In such cases (for example, update.php, which requires the 'continue=1' parameter to remain in the URL throughout the update process if there are any requirement warnings that need to be bypassed), using this function to generate the URL for links to the next steps of the script ensures that the links will work correctly.

Parameters
$query (optional) An array of query parameters to merge in to the existing ones.
Returns
The URL of the current script, with query parameters modified by the passed-in $query. The URL is not sanitized, so it still needs to be run through check_url() if it will be used as an HTML attribute value.
See Also
drupal_requirements_url()

Definition at line 1060 of file install.inc.

References drupal_get_query_parameters(), and drupal_http_build_query().

Referenced by drupal_requirements_url(), and update_info_page().

drupal_detect_baseurl ( $file = 'install.php' )

Detects the base URL using the PHP $_SERVER variables.

Parameters
$file The name of the file calling this function so we can strip it out of the URI when generating the base_url.
Returns
The auto-detected $base_url that should be configured in settings.php

Definition at line 221 of file install.inc.

References $dir.

drupal_detect_database_types ( )

Detects all supported databases that are compiled into PHP.

Returns
An array of database types compiled into PHP.

Definition at line 237 of file install.inc.

References $databases, and drupal_get_database_types().

Referenced by system_requirements().

drupal_get_database_types ( )

Returns all supported database installer objects that are compiled into PHP.

Returns
An array of database installer objects compiled into PHP.

Definition at line 253 of file install.inc.

References $databases, db_installer_object(), DRUPAL_ROOT, and file_scan_directory().

Referenced by drupal_detect_database_types(), install_database_errors(), and install_settings_form().

drupal_get_installed_schema_version | ( | $module,
 |  | $reset = FALSE,
 |  | $array = FALSE
 | ) |

Returns the currently installed schema version for a module.

Parameters
$module | A module name.
$reset | Set to TRUE after modifying the system table.
$array | Set to TRUE if you want to get information about all modules in the system.
Returns
The currently installed schema version, or SCHEMA_UNINSTALLED if the module is not installed.

Definition at line 146 of file install.inc.

References $module, $row, db_query(), and SCHEMA_UNINSTALLED.

Referenced by drupal_load_updates(), drupal_set_installed_schema_version(), drupal_uninstall_modules(), module_enable(), node_update_7003(), system_modules_submit(), system_modules_uninstall(), system_requirements(), update_already_performed(), update_fix_d7_install_profile(), update_fix_d7_requirements(), update_get_update_list(), and update_prepare_d7_bootstrap().

drupal_get_schema_versions ( $module )

Returns an array of available schema versions for a module.

Parameters
$module A module name.
Returns
If the module has updates, an array of available updates sorted by version. Otherwise, FALSE.

Definition at line 98 of file install.inc.

References $module, drupal_static(), and module_list().

Referenced by drupal_install_system(), ModuleUpdater\getSchemaUpdates(), module_enable(), system_install(), system_requirements(), update_get_update_function_list(), and update_get_update_list().

drupal_install_fix_file | ( | $file,
 |  | $mask,
 |  | $message = TRUE
 | ) |

Attempts to fix file permissions.

The general approach here is that, because we do not know the security setup of the webserver, we apply our permission changes to all three digits of the file permission (i.e. user, group and all).

To ensure that the values behave as expected (and numbers don't carry from one digit to the next) we do the calculation on the octal value using bitwise operations. This lets us remove, for example, 0222 from 0700 and get the correct value of 0500.

Parameters
$file | The name of the file with permissions to fix.
$mask | The desired permissions for the file.
$message | (optional) Whether to output messages. Defaults to TRUE.
Returns
TRUE/FALSE whether or not we were able to fix the file's permissions.

Definition at line 958 of file install.inc.

References FILE_EXECUTABLE, FILE_NOT_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_READABLE, and FILE_WRITABLE.

Referenced by drupal_verify_install_file().

drupal_install_mkdir | ( | $file,
 |  | $mask,
 |  | $message = TRUE
 | ) |

Creates a directory with the specified permissions.

Parameters
$file | The name of the directory to create;
$mask | The permissions of the directory to create.
$message | (optional) Whether to output messages. Defaults to TRUE.
Returns
TRUE/FALSE whether or not the directory was successfully created.

Definition at line 909 of file install.inc.

References drupal_mkdir(), FILE_EXECUTABLE, FILE_NOT_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_READABLE, and FILE_WRITABLE.

Referenced by drupal_verify_install_file().

drupal_install_profile_distribution_name ( )

Loads the installation profile, extracting its defined distribution name.

Returns
The distribution name defined in the profile's .info file. Defaults to "Drupal" if none is explicitly provided by the installation profile.
See Also
install_profile_info()

Definition at line 196 of file install.inc.

References $info, drupal_get_profile(), drupal_installation_attempted(), and system_get_info().

Referenced by DatabaseTasks_sqlite\getFormOptions(), DatabaseTasks\getFormOptions(), install_check_requirements(), install_database_errors(), install_finished(), install_profile_modules(), install_settings_form(), and system_modules().

drupal_install_system ( )

Installs the system module.

Separated from the installation of other modules so core system functions can be made available while other modules are installed.

Definition at line 721 of file install.inc.

References db_insert(), drupal_get_path(), drupal_get_schema_versions(), DRUPAL_ROOT, module_invoke(), SCHEMA_INSTALLED, and system_rebuild_module_data().

Referenced by install_system_module(), and DrupalWebTestCase\setUp().

drupal_load_updates ( )

Loads .install files for installed modules to initialize the update system.

Definition at line 81 of file install.inc.

References $module, drupal_get_installed_schema_version(), and module_load_install().

Referenced by system_status(), and update_fix_d7_install_profile().

drupal_requirements_severity ( & $requirements )

Extracts the highest severity from the requirements array.

Parameters
$requirements An array of requirements, in the same format as is returned by hook_requirements().
Returns
The highest severity in the array.

Definition at line 1197 of file install.inc.

References REQUIREMENT_OK.

Referenced by drupal_check_module(), install_verify_requirements(), system_status(), and update_check_requirements().

drupal_requirements_url ( $severity )

Returns a URL for proceeding to the next page after a requirements problem.

This function can be called by low-level scripts (such as install.php and update.php) and returns a URL that can be used to attempt to proceed to the next step of the script.

Parameters
$severity The severity of the requirements problem, as returned by drupal_requirements_severity().
Returns
A URL for attempting to proceed to the next step of the script. The URL is not sanitized, so it still needs to be run through check_url() if it will be used as an HTML attribute value.
See Also
drupal_current_script_url()

Definition at line 1087 of file install.inc.

References drupal_current_script_url(), and REQUIREMENT_WARNING.

Referenced by install_verify_requirements(), and update_check_requirements().

drupal_rewrite_settings | ( | $settings = array(),
 |  | $prefix = ''
 | ) |

Replaces values in settings.php with values in the submitted array.

Parameters
$settings An array of settings that need to be updated.

Definition at line 590 of file install.inc.

References conf_path(), DRUPAL_ROOT, drupal_static_reset(), and st().

Referenced by install_settings_form_submit().

drupal_set_installed_schema_version | ( | $module,
 |  | $version
 | ) |

Update the installed version information for a module.

Parameters
$module | A module name.
$version | The new schema version.

Definition at line 177 of file install.inc.

References $module, db_update(), and drupal_get_installed_schema_version().

Referenced by drupal_uninstall_modules(), module_enable(), system_install(), update_batch(), and update_do_one().

drupal_uninstall_modules | ( | $module_list = array(),
 |  | $uninstall_dependents = TRUE
 | ) |

Uninstalls a given list of disabled modules.

Parameters
array | $module_list | The modules to uninstall. It is the caller's responsibility to ensure that all modules in this list have already been disabled before this function is called.
bool | $uninstall_dependents | (optional) If TRUE, the function will check that all modules which depend on the passed-in module list either are already uninstalled or contained in the list, and it will ensure that the modules are uninstalled in the correct order. This incurs a significant performance cost, so use FALSE if you know $module_list is already complete and in the correct order. Defaults to TRUE.
Returns
bool Returns TRUE if the operation succeeds or FALSE if it aborts due to an unsafe condition, namely, $uninstall_dependents is TRUE and a module in $module_list has dependents which are not already uninstalled and not also included in $module_list).
See Also
module_disable()

Definition at line 766 of file install.inc.

References $module, $module_list, drupal_get_installed_schema_version(), drupal_get_profile(), drupal_set_installed_schema_version(), drupal_uninstall_schema(), module_invoke(), module_invoke_all(), module_load_install(), SCHEMA_UNINSTALLED, system_rebuild_module_data(), watchdog(), and WATCHDOG_INFO.

Referenced by system_modules_uninstall_submit().

drupal_verify_install_file | ( | $file,
 |  | $mask = NULL,
 |  | $type = 'file'
 | ) |

Verifies the state of the specified file.

Parameters
$file | The file to check for.
$mask | An optional bitmask created from various FILE_* constants.
$type | The type of file. Can be file (default), dir, or link.
Returns
TRUE on success or FALSE on failure. A message is set for the latter.

Definition at line 829 of file install.inc.

References drupal_install_fix_file(), drupal_install_mkdir(), FILE_EXECUTABLE, FILE_EXIST, FILE_NOT_EXECUTABLE, FILE_NOT_EXIST, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_READABLE, and FILE_WRITABLE.

Referenced by install_check_requirements(), install_configure_form(), system_requirements(), and update_prepare_d7_bootstrap().

drupal_verify_profile ( $install_state )

Verifies an installation profile for installation.

Parameters
$install_state An array of information about the current installation state.
Returns
The list of modules to install.

Definition at line 671 of file install.inc.

References $info, $module, drupal_get_profile(), DRUPAL_PHP_FUNCTION_PATTERN, DRUPAL_ROOT, drupal_system_listing(), drupal_ucfirst(), install_no_profile_error(), REQUIREMENT_ERROR, and st().

Referenced by install_verify_requirements().

install_goto ( $path )

Sends the user to a different installer page.

This issues an on-site HTTP redirect. Messages (and errors) are erased.

Parameters
$path An installer path.

Definition at line 1027 of file install.inc.

References $base_url, drupal_exit(), and DRUPAL_ROOT.

Referenced by _drupal_bootstrap_database(), and install_drupal().

install_profile_info | ( | $profile,
 |  | $locale = 'en'
 | ) |

Retrieves information about an installation profile from its .info file.

The information stored in a profile .info file is similar to that stored in a normal Drupal module .info file. For example:

  • name: The real name of the installation profile for display purposes.
  • description: A brief description of the profile.
  • dependencies: An array of shortnames of other modules that this install profile requires.

Additional, less commonly-used information that can appear in a profile.info file but not in a normal Drupal module .info file includes:

  • distribution_name: The name of the Drupal distribution that is being installed, to be shown throughout the installation process. Defaults to 'Drupal'.
  • exclusive: If the install profile is intended to be the only eligible choice in a distribution, setting exclusive = TRUE will auto-select it during installation, and the install profile selection screen will be skipped. If more than one profile is found where exclusive = TRUE then this property will have no effect and the profile selection screen will be shown as normal with all available profiles shown.

Note that this function does an expensive file system scan to get info file information for dependencies. If you only need information from the info file itself, use system_get_info().

Example of .info file:

* name = Minimal
* description = Start fresh, with only a few modules enabled.
* dependencies[] = block
* dependencies[] = dblog
*
Parameters
$profile | Name of profile.
$locale | Name of locale used (if any).
Returns
The info array.

Definition at line 1280 of file install.inc.

References $info, DRUPAL_MINIMUM_PHP, drupal_parse_info_file(), drupal_required_modules(), and drupal_static().

Referenced by _install_select_profile(), drupal_check_profile(), install_load_profile(), install_select_profile_form(), and DrupalWebTestCase\setUp().

Variable Documentation

const FILE_EXECUTABLE 8

File permission check – File is executable.

Definition at line 56 of file install.inc.

Referenced by drupal_install_fix_file(), drupal_install_mkdir(), and drupal_verify_install_file().

const FILE_EXIST 1

File permission check – File exists.

Definition at line 41 of file install.inc.

Referenced by drupal_verify_install_file(), install_check_requirements(), install_configure_form(), system_requirements(), and update_prepare_d7_bootstrap().

const FILE_NOT_EXECUTABLE 128

File permission check – File is not executable.

Definition at line 76 of file install.inc.

Referenced by drupal_install_fix_file(), drupal_install_mkdir(), and drupal_verify_install_file().

const FILE_NOT_EXIST 16

File permission check – File does not exist.

Definition at line 61 of file install.inc.

Referenced by drupal_verify_install_file().

const FILE_NOT_READABLE 32

File permission check – File is not readable.

Definition at line 66 of file install.inc.

Referenced by drupal_install_fix_file(), drupal_install_mkdir(), and drupal_verify_install_file().

const FILE_NOT_WRITABLE 64

File permission check – File is not writable.

Definition at line 71 of file install.inc.

Referenced by drupal_install_fix_file(), drupal_install_mkdir(), drupal_verify_install_file(), install_configure_form(), and system_requirements().

const FILE_READABLE 2

File permission check – File is readable.

Definition at line 46 of file install.inc.

Referenced by drupal_install_fix_file(), drupal_install_mkdir(), drupal_verify_install_file(), install_check_requirements(), install_configure_form(), system_requirements(), and update_prepare_d7_bootstrap().

const FILE_WRITABLE 4

File permission check – File is writable.

Definition at line 51 of file install.inc.

Referenced by drupal_install_fix_file(), drupal_install_mkdir(), drupal_verify_install_file(), install_check_requirements(), and update_prepare_d7_bootstrap().

const REQUIREMENT_ERROR 2

Requirement severity – Error condition; abort installation.

Definition at line 36 of file install.inc.

Referenced by _update_cron_notify(), _update_requirement_check(), color_requirements(), drupal_check_module(), drupal_verify_profile(), hook_requirements(), image_requirements(), install_check_requirements(), install_verify_requirements(), openid_requirements(), simpletest_requirements(), system_requirements(), system_status(), theme_status_report(), update_check_requirements(), update_init(), and update_prepare_d7_bootstrap().

const REQUIREMENT_INFO -1

Requirement severity – Informational message only.

Definition at line 21 of file install.inc.

Referenced by file_requirements(), hook_requirements(), system_requirements(), and theme_status_report().

const REQUIREMENT_OK 0

Requirement severity – Requirement successfully met.

Definition at line 26 of file install.inc.

Referenced by color_requirements(), drupal_requirements_severity(), file_requirements(), image_requirements(), openid_requirements(), system_requirements(), theme_status_report(), and update_prepare_d7_bootstrap().

const REQUIREMENT_WARNING 1

Requirement severity – Warning condition; proceed but flag warning.

Definition at line 31 of file install.inc.

Referenced by _update_requirement_check(), color_requirements(), drupal_requirements_url(), image_requirements(), install_verify_requirements(), openid_requirements(), system_requirements(), theme_status_report(), update_check_requirements(), update_init(), and update_requirements().

const SCHEMA_INSTALLED 0

Indicates that a module has been installed.

Definition at line 16 of file install.inc.

Referenced by drupal_install_system(), module_enable(), and system_install().

const SCHEMA_UNINSTALLED -1

Indicates that a module has not been installed yet.

Definition at line 11 of file install.inc.

Referenced by drupal_get_installed_schema_version(), drupal_uninstall_modules(), module_enable(), node_update_7003(), system_modules_submit(), system_modules_uninstall(), update_get_update_list(), and update_retrieve_dependencies().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/iso.inc File Reference

  • includes
Functions
iso.inc File Reference

Go to the source code of this file.

Functions

_country_get_predefined_list ()
_locale_get_predefined_list ()

Detailed Description

Provides a list of countries and languages based on ISO standards.

Definition in file iso.inc.

Function Documentation

_country_get_predefined_list ( )

Get an array of all country code => country name pairs.

Get an array of all country code => country name pairs as laid out in ISO 3166-1 alpha-2. Grabbed from location project (http://drupal.org/project/location).

Returns
An array of all country code => country name pairs.

Definition at line 17 of file iso.inc.

References get_t().

Referenced by country_get_list().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/json-encode.inc File Reference

  • includes
Functions
json-encode.inc File Reference

Go to the source code of this file.

Functions

drupal_json_encode_helper ($var)

Detailed Description

Provides a helper to properly encode HTML-safe JSON prior to PHP 5.3.0.

Definition in file json-encode.inc.

Function Documentation

drupal_json_encode_helper ( $var )

Encodes a PHP variable to HTML-safe JSON for PHP versions below 5.3.0.

See Also
drupal_json_encode()

Definition at line 13 of file json-encode.inc.

References $output.

Referenced by drupal_json_encode().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/language.inc File Reference

  • includes
Functions | Variables
language.inc File Reference

Go to the source code of this file.

Functions

language_types_info ()
language_types_configurable ($stored=TRUE)
language_types_disable ($types)
language_types_set ()
language_negotiation_get ($type, $provider_id=NULL)
language_negotiation_get_any ($provider_id)
language_negotiation_get_switch_links ($type, $path)
language_negotiation_purge ()
language_negotiation_set ($type, $language_providers)
language_negotiation_info ()
language_provider_invoke ($provider_id, $provider=NULL)
language_provider_weight ($provider)
language_initialize ($type)
language_from_default ()
language_url_split_prefix ($path, $languages)
language_fallback_get_candidates ($type=LANGUAGE_TYPE_CONTENT)

Variables

const LANGUAGE_NEGOTIATION_DEFAULT 'language-default'

Detailed Description

Language Negotiation API.

See Also
http://drupal.org/node/1497272

Definition in file language.inc.

Variable Documentation

const LANGUAGE_NEGOTIATION_DEFAULT 'language-default'

No language negotiation. The default language is used.

Definition at line 13 of file language.inc.

Referenced by _locale_languages_configure_form_language_table(), language_initialize(), language_negotiation_get(), language_negotiation_info(), locale_language_selector_form(), and locale_languages_configure_form_submit().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/locale.inc File Reference

  • includes
Functions | Variables
locale.inc File Reference

Go to the source code of this file.

Functions

locale_language_from_interface ()
locale_language_from_browser ($languages)
locale_language_from_user ($languages)
locale_language_from_session ($languages)
locale_language_from_url ($languages)
locale_language_url_fallback ($language=NULL, $language_type=LANGUAGE_TYPE_INTERFACE)
locale_language_switcher_url ($type, $path)
locale_language_switcher_session ($type, $path)
locale_language_url_rewrite_url (&$path, &$options)
locale_language_url_rewrite_session (&$path, &$options)
locale_string_is_safe ($string)
locale_add_language ($langcode, $name=NULL, $native=NULL, $direction=LANGUAGE_LTR, $domain= '', $prefix= '', $enabled=TRUE, $default=FALSE)
_locale_import_po ($file, $langcode, $mode, $group=NULL)
_locale_import_read_po ($op, $file, $mode=NULL, $lang=NULL, $group= 'default')
_locale_import_message ($message, $file, $lineno=NULL)
_locale_import_one_string ($op, $value=NULL, $mode=NULL, $lang=NULL, $file=NULL, $group= 'default')
_locale_import_one_string_db (&$report, $langcode, $context, $source, $translation, $textgroup, $location, $mode, $plid=0, $plural=0)
_locale_import_parse_header ($header)
_locale_import_parse_plural_forms ($pluralforms, $filepath)
_locale_import_parse_arithmetic ($string)
_locale_import_tokenize_formula ($formula)
_locale_import_append_plural ($entry, $key)
_locale_import_shorten_comments ($comment)
_locale_import_parse_quoted ($string)
_locale_parse_js_file ($filepath)
_locale_export_get_strings ($language=NULL, $group= 'default')
_locale_export_po_generate ($language=NULL, $strings=array(), $header=NULL)
_locale_export_po ($language=NULL, $output=NULL)
_locale_export_string ($str)
_locale_export_wrap ($str, $len)
_locale_export_remove_plural ($entry)
_locale_translate_seek ()
_locale_translate_seek_query ()
_locale_invalidate_js ($langcode=NULL)
_locale_rebuild_js ($langcode=NULL)
_locale_translate_language_list ($translation, $limit_language)
_locale_prepare_predefined_list ()
locale_batch_by_language ($langcode, $finished=NULL, $skip=array())
locale_batch_by_component ($components, $finished= '_locale_batch_system_finished')
_locale_batch_build ($files, $finished=NULL, $components=array())
_locale_batch_import ($filepath, &$context)
_locale_batch_system_finished ($success, $results)
_locale_batch_language_finished ($success, $results)
country_get_list ()
locale_date_format_save ($langcode, $type, $format)
locale_get_localized_date_format ($languages)

Variables

const | LOCALE_LANGUAGE_NEGOTIATION_URL 'locale-url'
const | LOCALE_LANGUAGE_NEGOTIATION_BROWSER 'locale-browser'
const | LOCALE_LANGUAGE_NEGOTIATION_INTERFACE 'locale-interface'
const | LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK 'locale-url-fallback'
const | LOCALE_LANGUAGE_NEGOTIATION_USER 'locale-user'
const | LOCALE_LANGUAGE_NEGOTIATION_SESSION 'locale-session'
const | LOCALE_JS_STRING '(?:(?:\'(?:\\\\\'|[^\'])*\'|"(?:\\\\"|[^"])*")(?:\s*\+\s*)?)+'
const | LOCALE_JS_OBJECT '\{.*?\}'
const | LOCALE_JS_OBJECT_CONTEXT ' \{ # match object literal start .*? # match anything, non-greedy (?: # match a form of "context" \'context\' | "context" | context ) \s*:\s* # match key-value separator ":" (' . LOCALE_JS_STRING . ') # match context string .*? # match anything, non-greedy \} # match end of object literal '
const | LOCALE_IMPORT_OVERWRITE 0
const | LOCALE_IMPORT_KEEP 1
const | LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX 0
const | LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN 1

Detailed Description

Administration functions for locale.module.

Definition in file locale.inc.

Function Documentation

_locale_parse_js_file ( $filepath )

End of "locale-api-import-export" Parses a JavaScript file, extracts strings wrapped in Drupal.t() and Drupal.formatPlural() and inserts them into the database.

Definition at line 1480 of file locale.inc.

References db_insert(), db_query(), db_update(), drupal_parse_url(), LOCALE_JS_OBJECT, LOCALE_JS_OBJECT_CONTEXT, and LOCALE_JS_STRING.

Referenced by locale_js_alter().

country_get_list ( )

End of "locale-autoimport" Get list of all predefined and custom countries.

Returns
An array of all country code => country name pairs.

Definition at line 2351 of file locale.inc.

References _country_get_predefined_list(), drupal_alter(), and DRUPAL_ROOT.

Referenced by _install_configure_form(), and system_regional_settings().

locale_date_format_save | ( | $langcode,
 |  | $type,
 |  | $format
 | ) |

Save locale specific date formats to the database.

Parameters
$langcode | Language code, can be 2 characters, e.g. 'en' or 5 characters, e.g. 'en-CA'.
$type | Date format type, e.g. 'short', 'medium'.
$format | The date format string.

Definition at line 2370 of file locale.inc.

References db_query_range(), and drupal_write_record().

Referenced by locale_date_format_form_submit().

locale_get_localized_date_format ( $languages )

Select locale date format details from database.

Parameters
$languages An array of language codes.
Returns
An array of date formats.

Definition at line 2395 of file locale.inc.

References system_date_format_locale(), system_get_date_types(), and variable_get().

Referenced by locale_init().

locale_string_is_safe ( $string )

End of "locale-languages-negotiation" Check that a string is safe to be added or imported as a translation.

This test can be used to detect possibly bad translation strings. It should not have any false positives. But it is only a test, not a transformation, as it destroys valid HTML. We cannot reliably filter translation strings on import because some strings are irreversibly corrupted. For example, a & in the translation would get encoded to &amp; by filter_xss() before being put in the database, and thus would be displayed incorrectly.

The allowed tag list is like filter_xss_admin(), but omitting div and img as not needed for translation and likely to cause layout issues (div) or a possible attack vector (img).

Definition at line 525 of file locale.inc.

References decode_entities(), and filter_xss().

Referenced by _locale_import_one_string_db(), and locale_translate_edit_form_validate().

Variable Documentation

const LOCALE_IMPORT_KEEP 1

Translation import mode keeping existing translations and only inserting new strings.

Definition at line 85 of file locale.inc.

Referenced by _locale_batch_import(), _locale_import_one_string(), and locale_translate_import_form().

const LOCALE_IMPORT_OVERWRITE 0

Translation import mode overwriting all existing translations if new translated version available.

Definition at line 79 of file locale.inc.

Referenced by _locale_import_one_string_db(), and locale_translate_import_form().

const LOCALE_JS_OBJECT '\{.*?\}'

Regular expression pattern used to match simple JS object literal.

This pattern matches a basic JS object, but will fail on an object with nested objects. Used in JS file parsing for string arg processing.

Definition at line 51 of file locale.inc.

Referenced by _locale_parse_js_file().

const LOCALE_JS_OBJECT_CONTEXT ' \{ # match object literal start .*? # match anything, non-greedy (?: # match a form of "context" \'context\' | "context" | context ) \s*:\s* # match key-value separator ":" (' . LOCALE_JS_STRING . ') # match context string .*? # match anything, non-greedy \} # match end of object literal '

Regular expression to match an object containing a key 'context'.

Pattern to match a JS object containing a 'context key' with a string value, which is captured. Will fail if there are nested objects.

Definition at line 59 of file locale.inc.

Referenced by _locale_parse_js_file().

const LOCALE_JS_STRING '(?:(?:\'(?:\\\\\'|[^\'])*\'|"(?:\\\\"|[^"])*")(?:\s*\+\s*)?)+'

Regular expression pattern used to localize JavaScript strings.

Definition at line 43 of file locale.inc.

Referenced by _locale_parse_js_file().

const LOCALE_LANGUAGE_NEGOTIATION_BROWSER 'locale-browser'

The language is set based on the browser language settings.

Definition at line 17 of file locale.inc.

Referenced by locale_language_negotiation_info(), and locale_update_7001().

const LOCALE_LANGUAGE_NEGOTIATION_INTERFACE 'locale-interface'

The language is determined using the current interface language.

Definition at line 22 of file locale.inc.

Referenced by locale_language_negotiation_info(), locale_language_types_info(), and locale_update_7001().

const LOCALE_LANGUAGE_NEGOTIATION_SESSION 'locale-session'

The language is set based on the request/session parameters.

Definition at line 38 of file locale.inc.

Referenced by locale_language_negotiation_info(), and locale_language_url_rewrite_session().

const LOCALE_LANGUAGE_NEGOTIATION_URL 'locale-url'

The language is determined using a URL language indicator: path prefix or domain according to the configuration.

Definition at line 12 of file locale.inc.

Referenced by locale_language_from_url(), locale_language_negotiation_info(), locale_language_types_info(), and locale_update_7001().

const LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN 1

URL language negotiation: use the domain as URL language indicator.

Definition at line 97 of file locale.inc.

Referenced by locale_language_from_url(), locale_language_providers_url_form(), locale_language_url_rewrite_url(), and locale_update_7001().

const LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK 'locale-url-fallback'

If no URL language is available language is determined using an already detected one.

Definition at line 28 of file locale.inc.

Referenced by locale_language_negotiation_info(), and locale_language_types_info().

const LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX 0

URL language negotiation: use the path prefix as URL language indicator.

Definition at line 91 of file locale.inc.

Referenced by locale_language_from_url(), locale_language_providers_url_form(), locale_language_url_fallback(), locale_language_url_rewrite_url(), locale_languages_overview_form_submit(), and overlay_overlay_parent_initialize().

const LOCALE_LANGUAGE_NEGOTIATION_USER 'locale-user'

The language is set based on the user language settings.

Definition at line 33 of file locale.inc.

Referenced by locale_language_negotiation_info(), and locale_update_7001().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/lock.inc File Reference

  • includes
Functions
lock.inc File Reference

Go to the source code of this file.

Functions

lock_initialize ()
_lock_id ()
lock_acquire ($name, $timeout=30.0)
lock_may_be_available ($name)
lock_wait ($name, $delay=30)
lock_release ($name)
lock_release_all ($lock_id=NULL)

Detailed Description

A database-mediated implementation of a locking mechanism.

Definition in file lock.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/mail.inc File Reference

  • includes
Classes | Functions | Variables
mail.inc File Reference

Go to the source code of this file.

Classes

interface MailSystemInterface

Functions

drupal_mail ($module, $key, $to, $language, $params=array(), $from=NULL, $send=TRUE)
drupal_mail_system ($module, $key)
drupal_wrap_mail ($text, $indent= '')
drupal_html_to_text ($string, $allowed_tags=NULL)
_drupal_wrap_mail_line (&$line, $key, $values)
_drupal_html_to_mail_urls ($match=NULL, $reset=FALSE)
_drupal_html_to_text_clean ($indent)
_drupal_html_to_text_pad ($text, $pad, $prefix= '')

Variables

const MAIL_LINE_ENDINGS isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER_SOFTWARE'], 'Win32') !== FALSE ? "\r\n" : "\n"

Detailed Description

API functions for processing and sending e-mail.

Definition in file mail.inc.

Function Documentation

_drupal_html_to_mail_urls | ( | $match = NULL,
 |  | $reset = FALSE
 | ) |

Keeps track of URLs and replaces them with placeholder tokens.

Callback for preg_replace_callback() within drupal_html_to_text().

Definition at line 577 of file mail.inc.

References $base_url, and $url.

Referenced by drupal_html_to_text().

_drupal_html_to_text_clean ( $indent )

Replaces non-quotation markers from a given piece of indentation with spaces.

Callback for array_map() within drupal_html_to_text().

Definition at line 604 of file mail.inc.

Referenced by drupal_wrap_mail().

_drupal_html_to_text_pad | ( | $text,
 |  | $pad,
 |  | $prefix = ''
 | ) |

Pads the last line with the given character.

See Also
drupal_html_to_text()

Definition at line 613 of file mail.inc.

Referenced by drupal_html_to_text().

_drupal_wrap_mail_line | ( | & | $line,
 |  |  | $key,
 |  |  | $values
 | ) |  |

Wraps words on a single line.

Callback for array_walk() winthin drupal_wrap_mail().

Definition at line 565 of file mail.inc.

Referenced by drupal_wrap_mail().

drupal_html_to_text | ( | $string,
 |  | $allowed_tags = NULL
 | ) |

Transforms an HTML string into plain text, preserving its structure.

The output will be suitable for use as 'format=flowed; delsp=yes' text (RFC 3676) and can be passed directly to drupal_mail() for sending.

We deliberately use LF rather than CRLF, see drupal_mail().

This function provides suitable alternatives for the following tags:

  1. $string The string to be transformed. $allowed_tags (optional) If supplied, a list of tags that will be transformed. If omitted, all all supported tags are transformed. The transformed string.

Definition at line 402 of file mail.inc.

References $output, $value, _drupal_html_to_mail_urls(), _drupal_html_to_text_pad(), _filter_htmlcorrector(), decode_entities(), drupal_strlen(), drupal_wrap_mail(), filter_xss(), and MAIL_LINE_ENDINGS.

Referenced by DefaultMailSystem\format(), and hook_mail().

drupal_mail | ( | $module,
 |  | $key,
 |  | $to,
 |  | $language,
 |  | $params = array(),
 |  | $from = NULL,
 |  | $send = TRUE
 | ) |

Composes and optionally sends an e-mail message.

Sending an e-mail works with defining an e-mail template (subject, text and possibly e-mail headers) and the replacement values to use in the appropriate places in the template. Processed e-mail templates are requested from hook_mail() from the module sending the e-mail. Any module can modify the composed e-mail message array using hook_mail_alter(). Finally drupal_mail_system()->mail() sends the e-mail, which can be reused if the exact same composed e-mail is to be sent to multiple recipients.

Finding out what language to send the e-mail with needs some consideration. If you send e-mail to a user, her preferred language should be fine, so use user_preferred_language(). If you send email based on form values filled on the page, there are two additional choices if you are not sending the e-mail to a user on the site. You can either use the language used to generate the page ($language global variable) or the site default language. See language_default(). The former is good if sending e-mail to the person filling the form, the later is good if you send e-mail to an address previously set up (like contact addresses in a contact form).

Taking care of always using the proper language is even more important when sending e-mails in a row to multiple users. Hook_mail() abstracts whether the mail text comes from an administrator setting or is static in the source code. It should also deal with common mail tokens, only receiving $params which are unique to the actual e-mail at hand.

An example:

* function example_notify($accounts) {
* foreach ($accounts as $account) {
* $params['account'] = $account;
* // example_mail() will be called based on the first drupal_mail() parameter.
* drupal_mail('example', 'notice', $account->mail, user_preferred_language($account), $params);
* }
* }
*
* function example_mail($key, &$message, $params) {
* $data['user'] = $params['account'];
* $options['language'] = $message['language'];
* user_mail_tokens($variables, $data, $options);
* switch($key) {
* case 'notice':
* // If the recipient can receive such notices by instant-message, do
* // not send by email.
* if (example_im_send($key, $message, $params)) {
* $message['send'] = FALSE;
* break;
* }
* $langcode = $message['language']->language;
* $message['subject'] = t('Notification from !site', $variables, array('langcode' => $langcode));
* $message['body'][] = t("Dear !username\n\nThere is new content available on the site.", $variables, array('langcode' => $langcode));
* break;
* }
* }
*

Another example, which uses drupal_mail() to format a message for sending later:

* $params = array('current_conditions' => $data);
* $to = 'user@example.com';
* $message = drupal_mail('example', 'notice', $to, $language, $params, FALSE);
* // Only add to the spool if sending was not canceled.
* if ($message['send']) {
* example_spool_message($message);
* }
*
Parameters
$module | A module name to invoke hook_mail() on. The {$module}_mail() hook will be called to complete the $message structure which will already contain common defaults.
$key | A key to identify the e-mail sent. The final e-mail id for e-mail altering will be {$module}_{$key}.
$to The e-mail address or addresses where the message will be sent to. The formatting of this string will be validated with the PHP e-mail validation filter. Some examples are:
  • user@.nosp@m.exam.nosp@m.ple.c.nosp@m.om
  • user@.nosp@m.exam.nosp@m.ple.c.nosp@m.om, anoth.nosp@m.erus.nosp@m.er@ex.nosp@m.ampl.nosp@m.e.com
  • User user@.nosp@m.exam.nosp@m.ple.c.nosp@m.om
  • User user@.nosp@m.exam.nosp@m.ple.c.nosp@m.om, Another User anoth.nosp@m.erus.nosp@m.er@ex.nosp@m.ampl.nosp@m.e.com
$language | Language object to use to compose the e-mail.
$params | Optional parameters to build the e-mail.
$from | Sets From to this value, if given.
$send | If TRUE, drupal_mail() will call drupal_mail_system()->mail() to deliver the message, and store the result in $message['result']. Modules implementing hook_mail_alter() may cancel sending by setting $message['send'] to FALSE.
Returns
The $message array structure containing all details of the message. If already sent ($send = TRUE), then the 'result' element will contain the success indicator of the e-mail, failure being already written to the watchdog. (Success means nothing more than the message being accepted at php-level, which still doesn't guarantee it to be delivered.)

Definition at line 122 of file mail.inc.

References $module, drupal_alter(), drupal_mail_system(), drupal_set_message(), t(), variable_get(), watchdog(), and WATCHDOG_ERROR.

Referenced by _update_cron_notify(), _user_mail_notify(), contact_personal_form_submit(), contact_site_form_submit(), email_example_mail_send(), hook_watchdog(), and system_send_email_action().

drupal_mail_system | ( | $module,
 |  | $key
 | ) |

Returns an object that implements the MailSystemInterface interface.

Allows for one or more custom mail backends to format and send mail messages composed using drupal_mail().

An implementation needs to implement the following methods:

  • format: Allows to preprocess, format, and postprocess a mail message before it is passed to the sending system. By default, all messages may contain HTML and are converted to plain-text by the DefaultMailSystem implementation. For example, an alternative implementation could override the default implementation and additionally sanitize the HTML for usage in a MIME-encoded e-mail, but still invoking the DefaultMailSystem implementation to generate an alternate plain-text version for sending.
  • mail: Sends a message through a custom mail sending engine. By default, all messages are sent via PHP's mail() function by the DefaultMailSystem implementation.

The selection of a particular implementation is controlled via the variable 'mail_system', which is a keyed array. The default implementation is the class whose name is the value of 'default-system' key. A more specific match first to key and then to module will be used in preference to the default. To specify a different class for all mail sent by one module, set the class name as the value for the key corresponding to the module name. To specify a class for a particular message sent by one module, set the class name as the value for the array key that is the message id, which is "${module}_${key}".

For example to debug all mail sent by the user module by logging it to a file, you might set the variable as something like:

* array(
* 'default-system' => 'DefaultMailSystem',
* 'user' => 'DevelMailLog',
* );
*

Finally, a different system can be specified for a specific e-mail ID (see the $key param), such as one of the keys used by the contact module:

* array(
* 'default-system' => 'DefaultMailSystem',
* 'user' => 'DevelMailLog',
* 'contact_page_autoreply' => 'DrupalDevNullMailSend',
* );
*

Other possible uses for system include a mail-sending class that actually sends (or duplicates) each message to SMS, Twitter, instant message, etc, or a class that queues up a large number of messages for more efficient bulk sending or for sending via a remote gateway so as to reduce the load on the local server.

Parameters
$module | The module name which was used by drupal_mail() to invoke hook_mail().
$key | A key to identify the e-mail sent. The final e-mail ID for the e-mail alter hook in drupal_mail() would have been {$module}_{$key}.
Returns
MailSystemInterface

Definition at line 258 of file mail.inc.

References $module, drupal_static(), t(), and variable_get().

Referenced by drupal_mail().

drupal_wrap_mail | ( | $text,
 |  | $indent = ''
 | ) |

Performs format=flowed soft wrapping for mail (RFC 3676).

We use delsp=yes wrapping, but only break non-spaced languages when absolutely necessary to avoid compatibility issues.

We deliberately use LF rather than CRLF, see drupal_mail().

Parameters
string | $text | The plain text to process.
string | $indent | (optional) A string to indent the text with. Only '>' characters are repeated on subsequent wrapped lines. Others are replaced by spaces.
Returns
string The content of the email as a string with formatting applied.

Definition at line 351 of file mail.inc.

References _drupal_html_to_text_clean(), and _drupal_wrap_mail_line().

Referenced by drupal_html_to_text(), and DefaultMailSystem\format().

Variable Documentation

const MAIL_LINE_ENDINGS isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER_SOFTWARE'], 'Win32') !== FALSE ? "\r\n" : "\n"

Auto-detect appropriate line endings for e-mails.

$conf['mail_line_endings'] will override this setting.

Definition at line 13 of file mail.inc.

Referenced by drupal_html_to_text(), and DefaultMailSystem\mail().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/menu.inc File Reference

  • includes
Functions | Variables
menu.inc File Reference

Go to the source code of this file.

Functions

menu_get_ancestors ($parts)
menu_unserialize ($data, $map)
menu_set_item ($path, $router_item)
menu_get_item ($path=NULL, $router_item=NULL)
menu_execute_active_handler ($path=NULL, $deliver=TRUE)
_menu_load_objects (&$item, &$map)
_menu_check_access (&$item, $map)
_menu_item_localize (&$item, $map, $link_translate=FALSE)
_menu_translate (&$router_item, $map, $to_arg=FALSE)
_menu_link_map_translate (&$map, $to_arg_functions)
menu_tail_to_arg ($arg, $map, $index)
menu_tail_load ($arg, &$map, $index)
_menu_link_translate (&$item, $translate=FALSE)
menu_get_object ($type= 'node', $position=1, $path=NULL)
menu_tree ($menu_name)
menu_tree_output ($tree)
menu_tree_all_data ($menu_name, $link=NULL, $max_depth=NULL)
menu_tree_set_path ($menu_name, $path=NULL)
menu_tree_get_path ($menu_name)
menu_tree_page_data ($menu_name, $max_depth=NULL, $only_active_trail=FALSE)
menu_build_tree ($menu_name, array $parameters=array())
_menu_build_tree ($menu_name, array $parameters=array())
menu_tree_collect_node_links (&$tree, &$node_links)
menu_tree_check_access (&$tree, $node_links=array())
_menu_tree_check_access (&$tree)
menu_tree_data (array $links, array $parents=array(), $depth=1)
_menu_tree_data (&$links, $parents, $depth)
template_preprocess_menu_tree (&$variables)
theme_menu_tree ($variables)
theme_menu_link (array $variables)
theme_menu_local_task ($variables)
theme_menu_local_action ($variables)
drupal_help_arg ($arg=array())
menu_get_active_help ()
menu_get_custom_theme ($initialize=FALSE)
menu_set_custom_theme ()
menu_get_names ()
menu_list_system_menus ()
menu_main_menu ()
menu_secondary_menu ()
menu_navigation_links ($menu_name, $level=0)
menu_local_tasks ($level=0)
menu_contextual_links ($module, $parent_path, $args)
menu_primary_local_tasks ()
menu_secondary_local_tasks ()
menu_local_actions ()
menu_tab_root_path ()
menu_local_tabs ()
theme_menu_local_tasks (&$variables)
menu_set_active_menu_names ($menu_names=NULL)
menu_get_active_menu_names ()
menu_set_active_item ($path)
menu_set_active_trail ($new_trail=NULL)
menu_link_get_preferred ($path=NULL, $selected_menu=NULL)
menu_get_active_trail ()
menu_get_active_breadcrumb ()
menu_get_active_title ()
menu_link_load ($mlid)
menu_cache_clear ($menu_name= 'navigation')
menu_cache_clear_all ()
menu_reset_static_cache ()
menu_rebuild ()
menu_router_build ()
_menu_router_cache ($new_menu=NULL)
menu_get_router ()
_menu_link_build ($item)
_menu_navigation_links_rebuild ($menu)
menu_links_clone ($links, $menu_name=NULL)
menu_load_links ($menu_name)
menu_delete_links ($menu_name)
menu_link_delete ($mlid, $path=NULL)
_menu_delete_item ($item, $force=FALSE)
menu_link_save (&$item, $existing_item=array(), $parent_candidates=array())
_menu_link_find_parent ($menu_link, $parent_candidates=array())
_menu_clear_page_cache ()
_menu_set_expanded_menus ()
_menu_find_router_path ($link_path)
menu_link_maintain ($module, $op, $link_path, $link_title)
menu_link_children_relative_depth ($item)
_menu_link_move_children ($item, $existing_item)
_menu_update_parental_status ($item, $exclude=FALSE)
_menu_link_parents_set (&$item, $parent)
_menu_router_build ($callbacks)
_menu_router_save ($menu, $masks)
_menu_site_is_offline ($check_only=FALSE)

Variables

const | MENU_IS_ROOT 0x0001
const | MENU_VISIBLE_IN_TREE 0x0002
const | MENU_VISIBLE_IN_BREADCRUMB 0x0004
const | MENU_LINKS_TO_PARENT 0x0008
const | MENU_MODIFIED_BY_ADMIN 0x0020
const | MENU_CREATED_BY_ADMIN 0x0040
const | MENU_IS_LOCAL_TASK 0x0080
const | MENU_IS_LOCAL_ACTION 0x0100
const | MENU_NORMAL_ITEM MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB
const | MENU_CALLBACK 0x0000
const | MENU_SUGGESTED_ITEM MENU_VISIBLE_IN_BREADCRUMB | 0x0010
const | MENU_LOCAL_TASK MENU_IS_LOCAL_TASK | MENU_VISIBLE_IN_BREADCRUMB
const | MENU_DEFAULT_LOCAL_TASK MENU_IS_LOCAL_TASK | MENU_LINKS_TO_PARENT | MENU_VISIBLE_IN_BREADCRUMB
const | MENU_LOCAL_ACTION MENU_IS_LOCAL_TASK | MENU_IS_LOCAL_ACTION | MENU_VISIBLE_IN_BREADCRUMB
const | MENU_CONTEXT_NONE 0x0000
const | MENU_CONTEXT_PAGE 0x0001
const | MENU_CONTEXT_INLINE 0x0002
const | MENU_FOUND 1
const | MENU_NOT_FOUND 2
const | MENU_ACCESS_DENIED 3
const | MENU_SITE_OFFLINE 4
const | MENU_SITE_ONLINE 5
const | MENU_MAX_PARTS 9
const | MENU_MAX_DEPTH 9
const | MENU_PREFERRED_LINK '1cf698d64d1aa4b83907cf6ed55db3a7f8e92c91'

Detailed Description

API for the Drupal menu system.

Definition in file menu.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/module.inc File Reference

  • includes
Functions
module.inc File Reference

Go to the source code of this file.

Functions

module_load_all ($bootstrap=FALSE)
module_list ($refresh=FALSE, $bootstrap_refresh=FALSE, $sort=FALSE, $fixed_list=NULL)
system_list ($type)
system_list_reset ()
_module_build_dependencies ($files)
module_exists ($module)
module_load_install ($module)
module_load_include ($type, $module, $name=NULL)
module_load_all_includes ($type, $name=NULL)
module_enable ($module_list, $enable_dependencies=TRUE)
module_disable ($module_list, $disable_dependents=TRUE)
module_hook ($module, $hook)
module_implements ($hook, $sort=FALSE, $reset=FALSE)
module_hook_info ()
module_implements_write_cache ()
module_invoke ($module, $hook)
module_invoke_all ($hook)
drupal_required_modules ()
drupal_alter ($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)

Detailed Description

API for loading and interacting with Drupal modules.

Definition in file module.inc.

Function Documentation

_module_build_dependencies ( $files )

Determines which modules require and are required by each module.

Parameters
$files The array of filesystem objects used to rebuild the cache.
Returns
The same array with the new keys for each module:
  • requires: An array with the keys being the modules that this module requires.
  • required_by: An array with the keys being the modules that will not work without this module.

Definition at line 245 of file module.inc.

References $module, drupal_depth_first_search(), drupal_parse_dependency(), and DRUPAL_ROOT.

Referenced by system_rebuild_module_data().

drupal_alter | ( |  | $type,
 |  | & | $data,
 |  | & | $context1 = NULL,
 |  | & | $context2 = NULL,
 |  | & | $context3 = NULL
 | ) |  |

Passes alterable variables to specific hook_TYPE_alter() implementations.

This dispatch function hands off the passed-in variables to type-specific hook_TYPE_alter() implementations in modules. It ensures a consistent interface for all altering operations.

A maximum of 2 alterable arguments is supported (a third is supported for legacy reasons, but should not be used in new code). In case more arguments need to be passed and alterable, modules provide additional variables assigned by reference in the last $context argument:

* $context = array(
* 'alterable' => &$alterable,
* 'unalterable' => $unalterable,
* 'foo' => 'bar',
* );
* drupal_alter('mymodule_data', $alterable1, $alterable2, $context);
*

Note that objects are always passed by reference in PHP5. If it is absolutely required that no implementation alters a passed object in $context, then an object needs to be cloned:

* $context = array(
* 'unalterable_object' => clone $object,
* );
* drupal_alter('mymodule_data', $data, $context);
*
Parameters
$type | A string describing the type of the alterable $data. 'form', 'links', 'node_content', and so on are several examples. Alternatively can be an array, in which case hook_TYPE_alter() is invoked for each value in the array, ordered first by module, and then for each module, in the order of values in $type. For example, when Form API is using drupal_alter() to execute both hook_form_alter() and hook_form_FORM_ID_alter() implementations, it passes array('form', 'form_' . $form_id) for $type.
$data | The variable that will be passed to hook_TYPE_alter() implementations to be altered. The type of this variable depends on the value of the $type argument. For example, when altering a 'form', $data will be a structured array. When altering a 'profile', $data will be an object.
$context1 | (optional) An additional variable that is passed by reference.
$context2 | (optional) An additional variable that is passed by reference. If more context needs to be provided to implementations, then this should be an associative array as described above.
$context3 | (optional) An additional variable that is passed by reference. This parameter is deprecated and will not exist in Drupal 8; consequently, it should not be used for new Drupal 7 code either. It is here only for backwards compatibility with older code that passed additional arguments to drupal_alter().

Definition at line 988 of file module.inc.

References $module, drupal_static(), module_implements(), and module_list().

Referenced by _block_load_blocks(), _block_rehash(), _block_render_blocks(), _field_info_collate_types(), _menu_link_translate(), _registry_update(), _system_rebuild_module_data(), _system_rebuild_theme_data(), _theme_build_registry(), _trigger_get_all_info(), actions_list(), ajax_render(), archiver_get_info(), batch_process(), comment_build_content(), comment_view(), contextual_pre_render_links(), country_get_list(), dashboard_region_descriptions(), drupal_cron_run(), drupal_deliver_page(), drupal_get_complete_schema(), drupal_get_css(), drupal_get_filetransfer_info(), drupal_get_html_head(), drupal_get_js(), drupal_get_library(), drupal_get_updaters(), drupal_goto(), drupal_mail(), drupal_prepare_form(), drupal_render_page(), element_info(), entity_example_basic_view(), entity_get_info(), EntityFieldQuery\execute(), field_attach_prepare_translation(), field_attach_view(), field_available_languages(), field_default_form(), field_extra_fields_get_display(), field_get_display(), field_language(), field_multiple_value_form(), field_view_field(), file_create_url(), file_file_download(), file_get_stream_wrappers(), file_mimetype_mapping(), filter_get_filters(), format_username(), FieldInfo\getBundleExtraFields(), image_effect_definitions(), image_styles(), language_fallback_get_candidates(), language_negotiation_get_switch_links(), language_negotiation_info(), language_types_info(), menu_contextual_links(), menu_execute_active_handler(), menu_get_active_breadcrumb(), menu_get_item(), menu_link_save(), menu_local_tasks(), menu_router_build(), module_implements(), node_access_acquire_grants(), node_access_grants(), node_build_content(), node_view(), openid_discovery(), openid_normalize(), path_get_admin_paths(), SelectQuery\preExecute(), FieldInfo\prepareField(), simpletest_test_get_all(), system_themes_page(), taxonomy_term_build_content(), taxonomy_term_view(), token_generate(), token_info(), trigger_assign(), update_calculate_project_data(), update_get_projects(), url(), user_build_content(), user_cancel_methods(), user_view(), and xmlrpc_server().

drupal_required_modules ( )

End of "defgroup hooks". Returns an array of modules required by core.

Definition at line 915 of file module.inc.

References $info, $name, drupal_get_profile(), drupal_parse_info_file(), DRUPAL_PHP_FUNCTION_PATTERN, and drupal_system_listing().

Referenced by install_profile_info().

module_disable | ( | $module_list,
 |  | $disable_dependents = TRUE
 | ) |

Disables a given set of modules.

Parameters
$module_list | An array of module names.
$disable_dependents | If TRUE, dependent modules will automatically be added and disabled in the correct order. This incurs a significant performance cost, so use FALSE if you know $module_list is already complete and in the correct order.

Definition at line 515 of file module.inc.

References $module, $module_list, _system_update_bootstrap_status(), db_update(), drupal_get_profile(), drupal_theme_rebuild(), entity_info_cache_clear(), module_exists(), module_hook(), module_implements(), module_invoke(), module_invoke_all(), module_list(), module_load_install(), node_access_needs_rebuild(), node_access_rebuild(), registry_update(), system_list_reset(), system_rebuild_module_data(), watchdog(), and WATCHDOG_INFO.

Referenced by system_modules_submit().

module_enable | ( | $module_list,
 |  | $enable_dependencies = TRUE
 | ) |

Enables or installs a given list of modules.

Definitions:

  • "Enabling" is the process of activating a module for use by Drupal.
  • "Disabling" is the process of deactivating a module.
  • "Installing" is the process of enabling it for the first time or after it has been uninstalled.
  • "Uninstalling" is the process of removing all traces of a module.

Order of events:

  • Gather and add module dependencies to $module_list (if applicable).
  • For each module that is being enabled:
    • Install module schema and update system registries and caches.
    • If the module is being enabled for the first time or had been uninstalled, invoke hook_install() and add it to the list of installed modules.
    • Invoke hook_enable().
  • Invoke hook_modules_installed().
  • Invoke hook_modules_enabled().
Parameters
$module_list | An array of module names.
$enable_dependencies | If TRUE, dependencies will automatically be added and enabled in the correct order. This incurs a significant performance cost, so use FALSE if you know $module_list is already complete and in the correct order.
Returns
FALSE if one or more dependencies are missing, TRUE otherwise.
See Also
hook_install()
hook_enable()
hook_modules_installed()
hook_modules_enabled()

Definition at line 383 of file module.inc.

References $module, $module_list, _system_update_bootstrap_status(), db_query(), db_update(), drupal_get_installed_schema_version(), drupal_get_schema(), drupal_get_schema_versions(), drupal_install_schema(), drupal_load(), DRUPAL_ROOT, drupal_set_installed_schema_version(), drupal_theme_rebuild(), entity_info_cache_clear(), module_implements(), module_invoke(), module_invoke_all(), module_list(), module_load_install(), registry_update(), SCHEMA_INSTALLED, SCHEMA_UNINSTALLED, system_list_reset(), system_rebuild_module_data(), watchdog(), and WATCHDOG_INFO.

Referenced by _install_module_batch(), install_configure_form_submit(), install_system_module(), DrupalWebTestCase\setUp(), system_modules_submit(), system_update_7020(), system_update_7027(), and system_update_7060().

module_exists ( $module )

Determines whether a given module exists.

Parameters
$module The name of the module (without the .module extension).
Returns
TRUE if the module is both installed and enabled.

Definition at line 274 of file module.inc.

References $module, and module_list().

Referenced by _token_example_get_comment(), aggregator_sanitize_configuration(), aggregator_save_category(), aggregator_save_feed(), bartik_process_html(), bartik_process_page(), block_admin_configure(), block_block_list_alter(), cache_clear_all(), dblog_menu(), field_system_info_alter(), file_example_show_session_contents_submit(), garland_process_html(), garland_process_page(), hook_entity_info(), image_style_flush(), language_list(), menu_help(), module_disable(), node_admin_nodes(), node_delete_multiple(), node_entity_info(), node_filters(), node_overview_types(), overlay_overlay_parent_initialize(), path_admin_overview(), syslog_form_system_logging_settings_alter(), system_help(), system_modules(), system_modules_submit(), system_requirements(), system_theme_settings(), template_preprocess_user_picture(), token_example_example_form(), token_example_token_info(), update_results_page(), and user_admin_settings().

module_list | ( | $refresh = FALSE,
 |  | $bootstrap_refresh = FALSE,
 |  | $sort = FALSE,
 |  | $fixed_list = NULL
 | ) |

Returns a list of currently active modules.

Usually, this returns a list of all enabled modules. When called early on in the bootstrap, it will return a list of vital modules only (those needed to generate cached pages).

All parameters to this function are optional and should generally not be changed from their defaults.

Parameters
$refresh | (optional) Whether to force the module list to be regenerated (such as after the administrator has changed the system settings). Defaults to FALSE.
$bootstrap_refresh | (optional) When $refresh is TRUE, setting $bootstrap_refresh to TRUE forces the module list to be regenerated using the reduced set of modules loaded in "bootstrap mode" for cached pages. Otherwise, setting $refresh to TRUE generates the complete list of enabled modules.
$sort | (optional) By default, modules are ordered by weight and module name. Set this option to TRUE to return a module list ordered only by module name.
$fixed_list | (optional) If an array of module names is provided, this will override the module list with the given set of modules. This will persist until the next call with $refresh set to TRUE or with a new $fixed_list passed in. This parameter is primarily intended for internal use (e.g., in install.php and update.php).
Returns
An associative array whose keys and values are the names of the modules in the list.

Definition at line 66 of file module.inc.

References $module, $name, drupal_get_filename(), drupal_static_reset(), and system_list().

Referenced by _drupal_maintenance_theme(), _theme_process_registry(), bootstrap_invoke_all(), drupal_alter(), drupal_get_complete_schema(), drupal_get_schema_versions(), field_sync_field_status(), install_begin_request(), module_disable(), module_enable(), module_exists(), module_hook_info(), module_implements(), module_load_all(), module_load_all_includes(), DrupalWebTestCase\resetAll(), DrupalUnitTestCase\setUp(), system_install(), system_modules_submit(), system_requirements(), DrupalUnitTestCase\tearDown(), and DrupalWebTestCase\tearDown().

module_load_all ( $bootstrap = FALSE )

Loads all the modules that have been enabled in the system table.

Parameters
$bootstrap Whether to load only the reduced set of modules loaded in "bootstrap mode" for cached pages. See bootstrap.inc.
Returns
If $bootstrap is NULL, return a boolean indicating whether all modules have been loaded.

Definition at line 19 of file module.inc.

References $module, drupal_load(), and module_list().

Referenced by DrupalCacheArray\__construct(), _drupal_bootstrap_full(), _drupal_bootstrap_variables(), _theme_build_registry(), _theme_load_registry(), and theme().

module_load_all_includes | ( | $type,
 |  | $name = NULL
 | ) |

Loads an include file for each module enabled in the {system} table.

Definition at line 340 of file module.inc.

References $module, $name, module_list(), and module_load_include().

Referenced by drupal_get_complete_schema().

module_load_include | ( | $type,
 |  | $module,
 |  | $name = NULL
 | ) |

Loads a module include file.

Examples:

* // Load node.admin.inc from the node module.
* module_load_include('inc', 'node', 'node.admin');
* // Load content_types.inc from the node module.
* module_load_include('inc', 'node', 'content_types');
*

Do not use this function to load an install file, use module_load_install() instead. Do not use this function in a global context since it requires Drupal to be fully bootstrapped, use require_once DRUPAL_ROOT . '/path/file' instead.

Parameters
$type | The include file's type (file extension).
$module | The module to which the include file belongs.
$name | (optional) The base file name (without the $type extension). If omitted, $module is used; i.e., resulting in "$module.$type" by default.
Returns
The name of the included file, if successful; FALSE otherwise.

Definition at line 322 of file module.inc.

References $module, $name, drupal_get_path(), and DRUPAL_ROOT.

Referenced by _update_refresh(), dashboard_admin_blocks(), field_modules_uninstalled(), form_get_cache(), form_load_include(), forum_overview(), ModuleUpdater\getSchemaUpdates(), hook_user_cancel(), image_effect_apply(), image_style_transform_dimensions(), module_hook(), module_implements(), module_load_all_includes(), module_load_install(), node_user_cancel(), openid_association(), openid_association_request(), openid_authentication(), openid_authentication_request(), openid_begin(), openid_complete(), openid_discovery(), openid_form_user_register_form_alter(), openid_verify_assertion(), update_create_fetch_task(), update_cron(), update_fetch_data(), update_get_available(), update_manager_install_form_submit(), update_manager_update_form(), update_manager_update_ready_form_submit(), update_refresh(), update_requirements(), update_status(), update_update_7000(), user_admin_settings(), user_menu_site_status_alter(), and user_multiple_cancel_confirm().

module_load_install ( $module )

Loads a module's installation hooks.

Parameters
$module The name of the module (without the .module extension).
Returns
The name of the module's install file, if successful; FALSE otherwise.

Definition at line 288 of file module.inc.

References $module, DRUPAL_ROOT, and module_load_include().

Referenced by _update_7000_field_create_field(), _update_cron_notify(), drupal_check_module(), drupal_check_profile(), drupal_get_schema_unprocessed(), drupal_load_updates(), drupal_uninstall_modules(), field_create_field(), field_read_fields(), field_update_7001(), field_update_field(), module_disable(), module_enable(), and update_init().

system_list ( $type )

Builds a list of bootstrap modules and enabled modules and themes.

Parameters
$type The type of list to return:
  • module_enabled: All enabled modules.
  • bootstrap: All enabled modules required for bootstrap.
  • theme: All themes.
Returns
An associative array of modules or themes, keyed by name. For $type 'bootstrap', the array values equal the keys. For $type 'module_enabled' or 'theme', the array values are objects representing the respective database row, with the 'info' property already unserialized.
See Also
module_list()
list_themes()

Definition at line 122 of file module.inc.

References $module, cache_get(), cache_set(), db_query(), drupal_find_base_themes(), drupal_get_filename(), DRUPAL_ROOT, and drupal_static().

Referenced by list_themes(), module_list(), and system_get_info().

system_list_reset ( )

Resets all system_list() caches.

Definition at line 224 of file module.inc.

References cache_clear_all(), and drupal_static_reset().

Referenced by _system_update_bootstrap_status(), list_themes(), module_disable(), module_enable(), and system_update_files_database().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/pager.inc File Reference

  • includes
Classes | Functions
pager.inc File Reference

Go to the source code of this file.

Classes

class PagerDefault

Functions

pager_find_page ($element=0)
pager_default_initialize ($total, $limit, $element=0)
pager_get_query_parameters ()
theme_pager ($variables)
theme_pager_first ($variables)
theme_pager_previous ($variables)
theme_pager_next ($variables)
theme_pager_last ($variables)
theme_pager_link ($variables)
pager_load_array ($value, $element, $old_array)

Detailed Description

Functions to aid in presenting database results as a set of pages.

Definition in file pager.inc.

Function Documentation

pager_default_initialize | ( | $total,
 |  | $limit,
 |  | $element = 0
 | ) |

Initializes a pager for theme('pager').

This function sets up the necessary global variables so that future calls to theme('pager') will render a pager that correctly corresponds to the items being displayed.

If the items being displayed result from a database query performed using Drupal's database API, and if you have control over the construction of the database query, you do not need to call this function directly; instead, you can simply extend the query object with the 'PagerDefault' extender before executing it. For example:

* $query = db_select('some_table')->extend('PagerDefault');
*

However, if you are using a different method for generating the items to be paged through, then you should call this function in preparation.

The following example shows how this function can be used in a page callback that invokes an external datastore with an SQL-like syntax:

* // First find the total number of items and initialize the pager.
* $where = "status = 1";
* $total = mymodule_select("SELECT COUNT(*) FROM data " . $where)->result();
* $num_per_page = variable_get('mymodule_num_per_page', 10);
* $page = pager_default_initialize($total, $num_per_page);
*
* // Next, retrieve and display the items for the current page.
* $offset = $num_per_page * $page;
* $result = mymodule_select("SELECT * FROM data " . $where . " LIMIT %d, %d", $offset, $num_per_page)->fetchAll();
* $output = theme('mymodule_results', array('result' => $result));
*
* // Finally, display the pager controls, and return.
* $output .= theme('pager');
* return $output;
*

A second example involves a page callback that invokes an external search service where the total number of matching results is provided as part of the returned set (so that we do not need a separate query in order to obtain this information). Here, we call pager_find_page() to calculate the desired offset before the search is invoked:

* // Perform the query, using the requested offset from pager_find_page().
* // This comes from a URL parameter, so here we are assuming that the URL
* // parameter corresponds to an actual page of results that will exist
* // within the set.
* $page = pager_find_page();
* $num_per_page = variable_get('mymodule_num_per_page', 10);
* $offset = $num_per_page * $page;
* $result = mymodule_remote_search($keywords, $offset, $num_per_page);
*
* // Now that we have the total number of results, initialize the pager.
* pager_default_initialize($result->total, $num_per_page);
*
* // Display the search results.
* $output = theme('search_results', array('results' => $result->data, 'type' => 'remote'));
*
* // Finally, display the pager controls, and return.
* $output .= theme('pager');
* return $output;
*
Parameters
$total | The total number of items to be paged.
$limit | The number of items the calling code will display per page.
$element | An optional integer to distinguish between multiple pagers on one page.
Returns
The number of the current page, within the pager represented by $element. This is determined from the URL query parameter $_GET['page'], or 0 by default. However, if a page that does not correspond to the actual range of the result set was requested, this function will return the closest page actually within the result set.

Definition at line 274 of file pager.inc.

References $page, and pager_find_page().

Referenced by PagerDefault\execute(), and EntityFieldQuery\initializePager().

pager_find_page ( $element = 0 )

Returns the current page being requested for display within a pager.

Parameters
$element An optional integer to distinguish between multiple pagers on one page.
Returns
The number of the current requested page, within the pager represented by $element. This is determined from the URL query parameter $_GET['page'], or 0 by default. Note that this number may differ from the actual page being displayed. For example, if a search for "example text" brings up three pages of results, but a users visits search/node/example+text?page=10, this function will return 10, even though the default pager implementation adjusts for this and still displays the third page of search results at that URL.
See Also
pager_default_initialize()

Definition at line 187 of file pager.inc.

References $page.

Referenced by EntityFieldQuery\initializePager(), and pager_default_initialize().

pager_get_query_parameters ( )

Compose a URL query parameter array for pager links.

Returns
A URL query parameter array that consists of all components of the current page request except for those pertaining to paging.

Definition at line 294 of file pager.inc.

References drupal_get_query_parameters(), and drupal_static().

Referenced by theme_pager_link().

pager_load_array | ( | $value,
 |  | $element,
 |  | $old_array
 | ) |

End of "Pager pieces". Helper function

Copies $old_array to $new_array and sets $new_array[$element] = $value Fills in $new_array[0 .. $element - 1] = 0

Definition at line 652 of file pager.inc.

References $value.

Referenced by theme_pager_first(), theme_pager_last(), theme_pager_link(), theme_pager_next(), and theme_pager_previous().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/password.inc File Reference

  • includes
Functions | Variables
password.inc File Reference

Go to the source code of this file.

Functions

_password_itoa64 ()
_password_base64_encode ($input, $count)
_password_generate_salt ($count_log2)
_password_enforce_log2_boundaries ($count_log2)
_password_crypt ($algo, $password, $setting)
_password_get_count_log2 ($setting)
user_hash_password ($password, $count_log2=0)
user_check_password ($password, $account)
user_needs_new_hash ($account)

Variables

const | DRUPAL_HASH_COUNT 15
const | DRUPAL_MIN_HASH_COUNT 7
const | DRUPAL_MAX_HASH_COUNT 30
const | DRUPAL_HASH_LENGTH 55

Detailed Description

Secure password hashing functions for user authentication.

Based on the Portable PHP password hashing framework.

See Also
http://www.openwall.com/phpass/

An alternative or custom version of this password hashing API may be used by setting the variable password_inc to the name of the PHP file containing replacement user_hash_password(), user_check_password(), and user_needs_new_hash() functions.

Definition in file password.inc.

Function Documentation

_password_base64_encode | ( | $input,
 |  | $count
 | ) |

Encodes bytes into printable base 64 using the *nix standard from crypt().

Parameters
$input | The string containing bytes to encode.
$count | The number of characters (bytes) to encode.
Returns
Encoded string

Definition at line 56 of file password.inc.

References $output, $value, and _password_itoa64().

Referenced by _password_crypt(), and _password_generate_salt().

_password_crypt | ( | $algo,
 |  | $password,
 |  | $setting
 | ) |

Hash a password using a secure stretched hash.

By using a salt and repeated hashing the password is "stretched". Its security is increased because it becomes much more computationally costly for an attacker to try to break the hash by brute-force computation of the hashes of a large number of plain-text words or strings to find a match.

Parameters
$algo | The string name of a hashing algorithm usable by hash(), like 'sha256'.
$password | The plain-text password to hash.
$setting | An existing hash or the output of _password_generate_salt(). Must be at least 12 characters (the settings and salt).
Returns
A string containing the hashed password (and salt) or FALSE on failure. The return string will be truncated at DRUPAL_HASH_LENGTH characters max.

Definition at line 152 of file password.inc.

References $output, _password_base64_encode(), _password_get_count_log2(), DRUPAL_HASH_LENGTH, and DRUPAL_MAX_HASH_COUNT.

Referenced by user_check_password(), and user_hash_password().

_password_enforce_log2_boundaries ( $count_log2 )

Ensures that $count_log2 is within set bounds.

Parameters
$count_log2 Integer that determines the number of iterations used in the hashing process. A larger value is more secure, but takes more time to complete.
Returns
Integer within set bounds that is closest to $count_log2.

Definition at line 121 of file password.inc.

References DRUPAL_MAX_HASH_COUNT, and DRUPAL_MIN_HASH_COUNT.

Referenced by _password_generate_salt(), and user_needs_new_hash().

_password_generate_salt ( $count_log2 )

Generates a random base 64-encoded salt prefixed with settings for the hash.

Proper use of salts may defeat a number of attacks, including:

  • The ability to try candidate passwords against multiple hashes at once.
  • The ability to use pre-hashed lists of candidate passwords.
  • The ability to determine whether two users have the same (or different) password without actually having to guess one of the passwords.
Parameters
$count_log2 Integer that determines the number of iterations used in the hashing process. A larger value is more secure, but takes more time to complete.
Returns
A 12 character string containing the iteration count and a random salt.

Definition at line 99 of file password.inc.

References $output, _password_base64_encode(), _password_enforce_log2_boundaries(), _password_itoa64(), and drupal_random_bytes().

Referenced by user_hash_password().

_password_get_count_log2 ( $setting )

Parse the log2 iteration count from a stored hash or setting string.

Definition at line 190 of file password.inc.

References _password_itoa64().

Referenced by _password_crypt(), and user_needs_new_hash().

_password_itoa64 ( )

Returns a string for mapping an int to the corresponding base 64 character.

Definition at line 41 of file password.inc.

Referenced by _password_base64_encode(), _password_generate_salt(), and _password_get_count_log2().

user_check_password | ( | $password,
 |  | $account
 | ) |

Check whether a plain text password matches a stored hashed password.

Alternative implementations of this function may use other data in the $account object, for example the uid to look up the hash in a custom table or remote database.

Parameters
$password | A plain-text password
$account | A user object with at least the fields from the {users} table.
Returns
TRUE or FALSE.

Definition at line 230 of file password.inc.

References _password_crypt().

Referenced by user_authenticate(), and user_validate_current_pass().

user_hash_password | ( | $password,
 |  | $count_log2 = 0
 | ) |

Hash a password using a secure hash.

Parameters
$password | A plain-text password.
$count_log2 | Optional integer to specify the iteration count. Generally used only during mass operations where a value less than the default is needed for speed.
Returns
A string containing the hashed password (and a salt), or FALSE on failure.

Definition at line 207 of file password.inc.

References _password_crypt(), _password_generate_salt(), DRUPAL_HASH_COUNT, and variable_get().

Referenced by user_save(), and user_update_7000().

user_needs_new_hash ( $account )

Check whether a user's hashed password needs to be replaced with a new hash.

This is typically called during the login process when the plain text password is available. A new hash is needed when the desired iteration count has changed through a change in the variable password_count_log2 or DRUPAL_HASH_COUNT or if the user's password hash was generated in an update like user_update_7000().

Alternative implementations of this function might use other criteria based on the fields in $account.

Parameters
$account A user object with at least the fields from the {users} table.
Returns
TRUE or FALSE.

Definition at line 278 of file password.inc.

References _password_enforce_log2_boundaries(), _password_get_count_log2(), DRUPAL_HASH_COUNT, DRUPAL_HASH_LENGTH, and variable_get().

Referenced by user_authenticate().

Variable Documentation

const DRUPAL_HASH_COUNT 15

The standard log2 number of iterations for password stretching. This should increase by 1 every Drupal version in order to counteract increases in the speed and power of computers available to crack the hashes.

Definition at line 21 of file password.inc.

Referenced by user_hash_password(), and user_needs_new_hash().

const DRUPAL_HASH_LENGTH 55

The expected (and maximum) number of characters in a hashed password.

Definition at line 36 of file password.inc.

Referenced by _password_crypt(), and user_needs_new_hash().

const DRUPAL_MAX_HASH_COUNT 30

The maximum allowed log2 number of iterations for password stretching.

Definition at line 31 of file password.inc.

Referenced by _password_crypt(), and _password_enforce_log2_boundaries().

const DRUPAL_MIN_HASH_COUNT 7

The minimum allowed log2 number of iterations for password stretching.

Definition at line 26 of file password.inc.

Referenced by _password_enforce_log2_boundaries().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/path.inc File Reference

  • includes
Functions
path.inc File Reference

Go to the source code of this file.

Functions

drupal_path_initialize ()
drupal_lookup_path ($action, $path= '', $path_language=NULL)
drupal_cache_system_paths ()
drupal_get_path_alias ($path=NULL, $path_language=NULL)
drupal_get_normal_path ($path, $path_language=NULL)
drupal_is_front_page ()
drupal_match_path ($path, $patterns)
current_path ()
drupal_path_alias_whitelist_rebuild ($source=NULL)
path_load ($conditions)
path_save (&$path)
path_delete ($criteria)
path_is_admin ($path)
path_get_admin_paths ()
drupal_valid_path ($path, $dynamic_allowed=FALSE)
drupal_clear_path_cache ($source=NULL)

Detailed Description

Functions to handle paths in Drupal, including path aliasing.

These functions are not loaded for cached pages, but modules that need to use them in hook_boot() or hook exit() can make them available, by executing "drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);".

Definition in file path.inc.

Function Documentation

current_path ( )

Return the current URL path of the page being viewed.

Examples:

  • http://example.com/node/306 returns "node/306".
  • http://example.com/drupalfolder/node/306 returns "node/306" while base_path() returns "/drupalfolder/".
  • http://example.com/path/alias (which is a path alias for node/306) returns "node/306" as opposed to the path alias.

This function is not available in hook_boot() so use $_GET['q'] instead. However, be careful when doing that because in the case of Example #3 $_GET['q'] will contain "path/alias". If "node/306" is needed, calling drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL) makes this function available.

Returns
The current Drupal URL path.
See Also
request_path()

Definition at line 354 of file path.inc.

Referenced by drupal_cache_system_paths(), drupal_lookup_path(), drupal_redirect_form(), drupal_validate_form(), overlay_drupal_goto_alter(), overlay_enable(), overlay_init(), shortcut_set_switch_submit(), system_custom_theme(), system_init(), and user_login_block().

drupal_cache_system_paths ( )

Cache system paths for a page.

Cache an array of the system paths available on each page. We assume that aliases will be needed for the majority of these paths during subsequent requests, and load them in a single query during drupal_lookup_path().

Definition at line 203 of file path.inc.

References cache_set(), current_path(), drupal_static(), and REQUEST_TIME.

Referenced by drupal_page_footer().

drupal_clear_path_cache ( $source = NULL )

Clear the path cache.

Parameters
$source An optional system path for which an alias is being changed.

Definition at line 583 of file path.inc.

References drupal_path_alias_whitelist_rebuild(), and drupal_static_reset().

Referenced by path_delete(), and path_save().

drupal_get_normal_path | ( | $path,
 |  | $path_language = NULL
 | ) |

Given a path alias, return the internal path it represents.

Parameters
$path | A Drupal path alias.
$path_language | An optional language code to look up the path in.
Returns
The internal path represented by the alias, or the original alias if no internal path was found.

Definition at line 259 of file path.inc.

References $module, drupal_lookup_path(), and module_implements().

Referenced by drupal_deliver_html_page(), drupal_path_initialize(), menu_edit_item_validate(), path_admin_form_validate(), shortcut_admin_add_link(), shortcut_link_edit_submit(), shortcut_valid_link(), system_site_information_settings_validate(), and system_update_7047().

drupal_get_path_alias | ( | $path = NULL,
 |  | $path_language = NULL
 | ) |

Given an internal Drupal path, return the alias set by the administrator.

If no path is provided, the function will return the alias of the current page.

Parameters
$path | An internal Drupal path.
$path_language | An optional language code to look up the path in.
Returns
An aliased path if one was found, or the original path if no alias was found.

Definition at line 235 of file path.inc.

References drupal_lookup_path().

Referenced by _shortcut_link_form_elements(), _statistics_link(), block_block_list_alter(), path_admin_overview(), system_site_information_settings(), and url().

drupal_is_front_page ( )

Check if the current page is the front page.

Returns
Boolean value: TRUE if the current page is the front page; FALSE if otherwise.

Definition at line 284 of file path.inc.

References drupal_static(), and variable_get().

Referenced by _template_preprocess_default_variables(), hook_init(), hook_menu_breadcrumb_alter(), l(), locale_block_view(), menu_get_active_breadcrumb(), menu_set_active_trail(), theme_get_suggestions(), and theme_links().

drupal_lookup_path | ( | $action,
 |  | $path = '',
 |  | $path_language = NULL
 | ) |

Given an alias, return its Drupal system URL if one exists. Given a Drupal system URL return one of its aliases if such a one exists. Otherwise, return FALSE.

Parameters
$action One of the following values:
  • wipe: delete the alias cache.
  • alias: return an alias for a given Drupal system path (if one exists).
  • source: return the Drupal system URL for a path alias (if one exists).
$path | The path to investigate for corresponding aliases or system URLs.
$path_language | Optional language code to search the path with. Defaults to the page language. If there's no path defined for that language it will search paths without language.
Returns
Either a Drupal system path, an aliased path, or FALSE if no path was found.

Definition at line 45 of file path.inc.

References cache_get(), current_path(), db_query(), drupal_path_alias_whitelist_rebuild(), drupal_static(), LANGUAGE_NONE, and variable_get().

Referenced by drupal_get_normal_path(), and drupal_get_path_alias().

drupal_match_path | ( | $path,
 |  | $patterns
 | ) |

Check if a path matches any pattern in a set of patterns.

Parameters
$path The path to match.
$patterns String containing a set of patterns separated by
, or
.
Returns
Boolean value: TRUE if the path matches a pattern, FALSE otherwise.

Definition at line 312 of file path.inc.

References drupal_static(), and variable_get().

Referenced by block_block_list_alter(), and path_is_admin().

drupal_path_alias_whitelist_rebuild ( $source = NULL )

Rebuild the path alias white list.

Parameters
$source An optional system path for which an alias is being inserted.
Returns
An array containing a white list of path aliases.

Definition at line 367 of file path.inc.

References $row, db_query(), variable_get(), and variable_set().

Referenced by drupal_clear_path_cache(), drupal_lookup_path(), and system_update_7042().

drupal_path_initialize ( )

Initialize the $_GET['q'] variable to the proper normal path.

Definition at line 15 of file path.inc.

References drupal_get_normal_path(), and variable_get().

Referenced by _drupal_bootstrap_full().

drupal_valid_path | ( | $path,
 |  | $dynamic_allowed = FALSE
 | ) |

Checks a path exists and the current user has access to it.

Parameters
$path | The path to check.
$dynamic_allowed | Whether paths with menu wildcards (like user/%) should be allowed.
Returns
TRUE if it is a valid path AND the current user has access permission, FALSE otherwise.

Definition at line 553 of file path.inc.

References _menu_link_translate(), db_query(), menu_get_item(), and url_is_external().

Referenced by menu_edit_item_validate(), path_admin_form_validate(), system_site_information_settings_validate(), and theme_textfield().

path_delete ( $criteria )

Delete a URL alias.

Parameters
$criteria A number representing the pid or an array of criteria.

Definition at line 463 of file path.inc.

References $value, db_delete(), drupal_clear_path_cache(), module_invoke_all(), and path_load().

Referenced by path_admin_delete_confirm_submit(), path_node_delete(), path_node_update(), path_taxonomy_term_delete(), and path_taxonomy_term_update().

path_get_admin_paths ( )

Gets a list of administrative and non-administrative paths.

Returns
array An associative array containing the following keys: 'admin': An array of administrative paths and regular expressions in a format suitable for drupal_match_path(). 'non_admin': An array of non-administrative paths and regular expressions.
See Also
hook_admin_paths()
hook_admin_paths_alter()

Definition at line 517 of file path.inc.

References drupal_alter(), drupal_static(), and module_invoke_all().

Referenced by overlay_overlay_parent_initialize(), and path_is_admin().

path_is_admin ( $path )

Determines whether a path is in the administrative section of the site.

By default, paths are considered to be non-administrative. If a path does not match any of the patterns in path_get_admin_paths(), or if it matches both administrative and non-administrative patterns, it is considered non-administrative.

Parameters
$path A Drupal path.
Returns
TRUE if the path is administrative, FALSE otherwise.
See Also
path_get_admin_paths()
hook_admin_paths()
hook_admin_paths_alter()

Definition at line 495 of file path.inc.

References drupal_match_path(), drupal_static(), and path_get_admin_paths().

Referenced by overlay_init(), system_custom_theme(), and system_init().

path_load ( $conditions )

Fetches a specific URL alias from the database.

Parameters
$conditions A string representing the source, a number representing the pid, or an array of query conditions.
Returns
FALSE if no alias was found or an associative array containing the following keys:
  • source: The internal system path.
  • alias: The URL alias.
  • pid: Unique path alias identifier.
  • language: The language of the alias.

Definition at line 403 of file path.inc.

References $value, and db_select().

Referenced by path_delete(), path_form_node_form_alter(), path_form_taxonomy_form_term_alter(), and path_save().

path_save ( & $path )

Save a path alias to the database.

Parameters
$path An associative array containing the following keys:
  • source: The internal system path.
  • alias: The URL alias.
  • pid: (optional) Unique path alias identifier.
  • language: (optional) The language of the alias.

Definition at line 433 of file path.inc.

References drupal_clear_path_cache(), drupal_write_record(), LANGUAGE_NONE, module_invoke_all(), and path_load().

Referenced by path_admin_form_submit(), path_node_insert(), path_taxonomy_term_insert(), and path_taxonomy_term_update().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/registry.inc File Reference

  • includes
Functions
registry.inc File Reference

Go to the source code of this file.

Functions

_registry_update ()
registry_get_parsed_files ()
_registry_parse_files ($files)
_registry_parse_file ($filename, $contents, $module= '', $weight=0)

Detailed Description

This file contains the code registry parser engine.

Definition in file registry.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/session.inc File Reference

  • includes
Functions
session.inc File Reference

Go to the source code of this file.

Functions

_drupal_session_open ()
_drupal_session_close ()
_drupal_session_read ($sid)
_drupal_session_write ($sid, $value)
drupal_session_initialize ()
drupal_session_start ()
drupal_session_commit ()
drupal_session_started ($set=NULL)
drupal_session_regenerate ()
_drupal_session_destroy ($sid)
_drupal_session_delete_cookie ($name, $secure=NULL)
drupal_session_destroy_uid ($uid)
_drupal_session_garbage_collection ($lifetime)
drupal_save_session ($status=NULL)

Detailed Description

User session handling functions.

The user-level session storage handlers:

  • _drupal_session_open()
  • _drupal_session_close()
  • _drupal_session_read()
  • _drupal_session_write()
  • _drupal_session_destroy()
  • _drupal_session_garbage_collection() are assigned by session_set_save_handler() in bootstrap.inc and are called automatically by PHP. These functions should not be called directly. Session data should instead be accessed via the $_SESSION superglobal.

Definition in file session.inc.

Function Documentation

_drupal_session_close ( )

Session handler assigned by session_set_save_handler().

This function is used to close the current session. Because Drupal stores session data in the database immediately on write, this function does not need to do anything.

This function should not be called directly.

Returns
This function will always return TRUE.

Definition at line 47 of file session.inc.

_drupal_session_delete_cookie | ( | $name,
 |  | $secure = NULL
 | ) |

Deletes the session cookie.

Parameters
$name | Name of session cookie to delete.
boolean | $secure | Force the secure value of the cookie.

Definition at line 459 of file session.inc.

References $name, and REQUEST_TIME.

Referenced by _drupal_session_destroy().

_drupal_session_destroy ( $sid )

Session handler assigned by session_set_save_handler().

Cleans up a specific session.

Parameters
$sid Session ID.

Definition at line 423 of file session.inc.

References _drupal_session_delete_cookie(), db_delete(), drupal_anonymous_user(), drupal_save_session(), and variable_get().

_drupal_session_garbage_collection ( $lifetime )

Session handler assigned by session_set_save_handler().

Cleans up stalled sessions.

Parameters
$lifetime The value of session.gc_maxlifetime, passed by PHP. Sessions not updated for more than $lifetime seconds will be removed.

Definition at line 497 of file session.inc.

References db_delete(), and REQUEST_TIME.

_drupal_session_open ( )

Session handler assigned by session_set_save_handler().

This function is used to handle any initialization, such as file paths or database connections, that is needed before accessing session data. Drupal does not need to initialize anything in this function.

This function should not be called directly.

Returns
This function will always return TRUE.

Definition at line 31 of file session.inc.

_drupal_session_read ( $sid )

Reads an entire session from the database (internal use only).

Also initializes the $user object for the user associated with the session. This function is registered with session_set_save_handler() to support database-backed sessions. It is called on every page load when PHP sets up the $_SESSION superglobal.

This function is an internal function and must not be called directly. Doing so may result in logging out the current user, corrupting session data or other unexpected behavior. Session data must always be accessed via the $_SESSION superglobal.

Parameters
$sid The session ID of the session to retrieve.
Returns
The user's session, or an empty string if no session exists.

Definition at line 70 of file session.inc.

References db_query(), drupal_anonymous_user(), DRUPAL_AUTHENTICATED_RID, drupal_register_shutdown_function(), and drupal_static().

_drupal_session_write | ( | $sid,
 |  | $value
 | ) |

Writes an entire session to the database (internal use only).

This function is registered with session_set_save_handler() to support database-backed sessions.

This function is an internal function and must not be called directly. Doing so may result in corrupted session data or other unexpected behavior. Session data must always be accessed via the $_SESSION superglobal.

Parameters
$sid | The session ID of the session to write to.
$value | Session data to write as a serialized string.
Returns
Always returns TRUE.

Definition at line 158 of file session.inc.

References $value, _drupal_render_exception_safe(), db_merge(), db_update(), DRUPAL_ROOT, drupal_save_session(), drupal_static(), error_displayable(), ip_address(), print, REQUEST_TIME, and variable_get().

drupal_save_session ( $status = NULL )

Determines whether to save session data of the current request.

This function allows the caller to temporarily disable writing of session data, should the request end while performing potentially dangerous operations, such as manipulating the global $user object. See http://drupal.org/node/218104 for usage.

Parameters
$status Disables writing of session data when FALSE, (re-)enables writing when TRUE.
Returns
FALSE if writing session data has been disabled. Otherwise, TRUE.

Definition at line 524 of file session.inc.

Referenced by _drupal_session_destroy(), _drupal_session_write(), drupal_cron_run(), drupal_session_commit(), drupal_session_destroy_uid(), drupal_session_regenerate(), DrupalWebTestCase\setUp(), and DrupalWebTestCase\tearDown().

drupal_session_commit ( )

Commits the current session, if necessary.

If an anonymous user already have an empty session, destroy it.

Definition at line 302 of file session.inc.

References drupal_save_session(), drupal_session_start(), drupal_session_started(), REQUEST_TIME, and variable_get().

Referenced by ajax_footer(), drupal_exit(), and drupal_page_footer().

drupal_session_destroy_uid ( $uid )

Ends a specific user's session(s).

Parameters
$uid User ID.

Definition at line 477 of file session.inc.

References db_delete(), and drupal_save_session().

Referenced by user_delete_multiple(), and user_save().

drupal_session_initialize ( )

Initializes the session handler, starting a session if needed.

Definition at line 239 of file session.inc.

References drupal_anonymous_user(), drupal_get_user_timezone(), drupal_page_is_cacheable(), drupal_random_key(), drupal_session_start(), and variable_get().

Referenced by drupal_bootstrap().

drupal_session_started ( $set = NULL )

Returns whether a session has been started.

Definition at line 337 of file session.inc.

Referenced by drupal_session_commit(), drupal_session_regenerate(), and drupal_session_start().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/stream_wrappers.inc File Reference

  • includes
Classes | Variables
stream_wrappers.inc File Reference

Go to the source code of this file.

Classes

interface | StreamWrapperInterface
interface | DrupalStreamWrapperInterface
class | DrupalLocalStreamWrapper
class | DrupalPublicStreamWrapper
class | DrupalPrivateStreamWrapper
class | DrupalTemporaryStreamWrapper

Variables

const | STREAM_WRAPPERS_ALL 0x0000
const | STREAM_WRAPPERS_LOCAL 0x0001
const | STREAM_WRAPPERS_READ 0x0004
const | STREAM_WRAPPERS_WRITE 0x0008
const | STREAM_WRAPPERS_VISIBLE 0x0010
const | STREAM_WRAPPERS_HIDDEN STREAM_WRAPPERS_READ | STREAM_WRAPPERS_WRITE
const | STREAM_WRAPPERS_LOCAL_HIDDEN STREAM_WRAPPERS_LOCAL | STREAM_WRAPPERS_HIDDEN
const | STREAM_WRAPPERS_WRITE_VISIBLE STREAM_WRAPPERS_READ | STREAM_WRAPPERS_WRITE | STREAM_WRAPPERS_VISIBLE
const | STREAM_WRAPPERS_READ_VISIBLE STREAM_WRAPPERS_READ | STREAM_WRAPPERS_VISIBLE
const | STREAM_WRAPPERS_NORMAL STREAM_WRAPPERS_WRITE_VISIBLE
const | STREAM_WRAPPERS_LOCAL_NORMAL STREAM_WRAPPERS_LOCAL | STREAM_WRAPPERS_NORMAL

Detailed Description

Drupal stream wrapper interface.

Provides a Drupal interface and classes to implement PHP stream wrappers for public, private, and temporary files.

A stream wrapper is an abstraction of a file system that allows Drupal to use the same set of methods to access both local files and remote resources.

Note that PHP 5.2 fopen() only supports URIs of the form "scheme://target" despite the fact that according to RFC 3986 a URI's scheme component delimiter is in general just ":", not "://". Because of this PHP limitation and for consistency Drupal will only accept URIs of form "scheme://target".

See Also
http://www.faqs.org/rfcs/rfc3986.html
http://bugs.php.net/bug.php?id=47070

Definition in file stream_wrappers.inc.

Variable Documentation

const STREAM_WRAPPERS_ALL 0x0000

Stream wrapper bit flags that are the basis for composite types.

Note that 0x0002 is skipped, because it was the value of a constant that has since been removed. Stream wrapper bit flag – a filter that matches all wrappers.

Definition at line 32 of file stream_wrappers.inc.

Referenced by file_get_stream_wrappers().

const STREAM_WRAPPERS_HIDDEN STREAM_WRAPPERS_READ | STREAM_WRAPPERS_WRITE

Composite stream wrapper bit flags that are usually used as the types. Stream wrapper type flag – not visible in the UI or accessible via web, but readable and writable. E.g. the temporary directory for uploads.

Definition at line 62 of file stream_wrappers.inc.

const STREAM_WRAPPERS_LOCAL 0x0001

Stream wrapper bit flag – refers to a local file system location.

Definition at line 37 of file stream_wrappers.inc.

Referenced by file_get_stream_wrappers(), and image_gd_save().

const STREAM_WRAPPERS_LOCAL_HIDDEN STREAM_WRAPPERS_LOCAL | STREAM_WRAPPERS_HIDDEN

Stream wrapper type flag – hidden, readable and writeable using local files.

Definition at line 67 of file stream_wrappers.inc.

Referenced by hook_stream_wrappers(), and system_stream_wrappers().

const STREAM_WRAPPERS_LOCAL_NORMAL STREAM_WRAPPERS_LOCAL | STREAM_WRAPPERS_NORMAL

Stream wrapper type flag – visible, readable and writeable using local files.

Definition at line 91 of file stream_wrappers.inc.

Referenced by hook_stream_wrappers(), and system_stream_wrappers().

const STREAM_WRAPPERS_NORMAL STREAM_WRAPPERS_WRITE_VISIBLE

Stream wrapper type flag – the default when 'type' is omitted from hook_stream_wrappers(). This does not include STREAM_WRAPPERS_LOCAL, because PHP grants a greater trust level to local files (for example, they can be used in an "include" statement, regardless of the "allow_url_include" setting), so stream wrappers need to explicitly opt-in to this.

Definition at line 86 of file stream_wrappers.inc.

Referenced by file_get_stream_wrappers().

const STREAM_WRAPPERS_READ 0x0004

Stream wrapper bit flag – wrapper is readable (almost always true).

Definition at line 42 of file stream_wrappers.inc.

const STREAM_WRAPPERS_READ_VISIBLE STREAM_WRAPPERS_READ | STREAM_WRAPPERS_VISIBLE

Stream wrapper type flag – visible and read-only.

Definition at line 77 of file stream_wrappers.inc.

Referenced by hook_stream_wrappers().

const STREAM_WRAPPERS_VISIBLE 0x0010

Stream wrapper bit flag – exposed in the UI and potentially web accessible.

Definition at line 52 of file stream_wrappers.inc.

const STREAM_WRAPPERS_WRITE 0x0008

Stream wrapper bit flag – wrapper is writeable.

Definition at line 47 of file stream_wrappers.inc.

const STREAM_WRAPPERS_WRITE_VISIBLE STREAM_WRAPPERS_READ | STREAM_WRAPPERS_WRITE | STREAM_WRAPPERS_VISIBLE

Stream wrapper type flag – visible, readable and writeable.

Definition at line 72 of file stream_wrappers.inc.

Referenced by file_field_settings_form(), file_get_stream_wrappers(), image_field_settings_form(), image_style_flush(), and system_file_system_settings().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/tablesort.inc File Reference

  • includes
Classes | Functions
tablesort.inc File Reference

Go to the source code of this file.

Classes

class TableSort

Functions

tablesort_init ($header)
tablesort_header ($cell, $header, $ts)
tablesort_cell ($cell, $header, $ts, $i)
tablesort_get_query_parameters ()
tablesort_get_order ($headers)
tablesort_get_sort ($headers)

Detailed Description

Functions to aid in the creation of sortable tables.

All tables created with a call to theme('table') have the option of having column headers that the user can click on to sort the table by that column.

Definition in file tablesort.inc.

Function Documentation

tablesort_cell | ( | $cell,
 |  | $header,
 |  | $ts,
 |  | $i
 | ) |

Formats a table cell.

Adds a class attribute to all cells in the currently active column.

Parameters
$cell | The cell to format.
$header | An array of column headers in the format described in theme_table().
$ts | The current table sort context as returned from tablesort_init().
$i | The index of the cell's table column.
Returns
A properly formatted cell, ready for _theme_table_cell().

Definition at line 171 of file tablesort.inc.

References $header.

Referenced by theme_table().

tablesort_get_order ( $headers )

Determines the current sort criterion.

Parameters
$headers An array of column headers in the format described in theme_table().
Returns
An associative array describing the criterion, containing the keys:
  • "name": The localized title of the table column.
  • "sql": The name of the database field to sort on.

Definition at line 205 of file tablesort.inc.

References $header.

Referenced by TableSort\order(), EntityFieldQuery\tableSort(), tablesort_get_sort(), and tablesort_init().

tablesort_get_query_parameters ( )

Composes a URL query parameter array for table sorting links.

Returns
A URL query parameter array that consists of all components of the current page request except for those pertaining to table sorting.

Definition at line 190 of file tablesort.inc.

References drupal_get_query_parameters().

Referenced by TableSort\getQueryParameters(), and tablesort_init().

tablesort_get_sort ( $headers )

Determines the current sort direction.

Parameters
$headers An array of column headers in the format described in theme_table().
Returns
The current sort direction ("asc" or "desc").

Definition at line 240 of file tablesort.inc.

References $header, and tablesort_get_order().

Referenced by TableSort\getSort(), EntityFieldQuery\tableSort(), and tablesort_init().

tablesort_header | ( | $cell,
 |  | $header,
 |  | $ts
 | ) |

Formats a column header.

If the cell in question is the column header for the current sort criterion, it gets special formatting. All possible sort criteria become links.

Parameters
$cell | The cell to format.
$header | An array of column headers in the format described in theme_table().
$ts | The current table sort context as returned from tablesort_init().
Returns
A properly formatted cell, ready for _theme_table_cell().

Definition at line 133 of file tablesort.inc.

References $title, l(), t(), and theme().

Referenced by template_preprocess_forum_topic_list(), and theme_table().

tablesort_init ( $header )

Initialize the table sort context.

Definition at line 110 of file tablesort.inc.

References $header, tablesort_get_order(), tablesort_get_query_parameters(), and tablesort_get_sort().

Referenced by template_preprocess_forum_topic_list(), and theme_table().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/theme.inc File Reference

  • includes
Classes | Functions | Variables
theme.inc File Reference

Go to the source code of this file.

Classes

class DrupalCacheArray

Functions

drupal_theme_access ($theme)
_drupal_theme_access ($theme)
drupal_theme_initialize ()
_drupal_theme_initialize ($theme, $base_theme=array(), $registry_callback= '_theme_load_registry')
theme_get_registry ($complete=TRUE)
_theme_registry_callback ($callback=NULL, array $arguments=array())
_theme_load_registry ($theme, $base_theme=NULL, $theme_engine=NULL, $complete=TRUE)
_theme_save_registry ($theme, $registry)
drupal_theme_rebuild ()
_theme_process_registry (&$cache, $name, $type, $theme, $path)
_theme_build_registry ($theme, $base_theme, $theme_engine)
list_themes ($refresh=FALSE)
drupal_find_base_themes ($themes, $key, $used_keys=array())
theme ($hook, $variables=array())
path_to_theme ()
drupal_find_theme_functions ($cache, $prefixes)
drupal_find_theme_templates ($cache, $extension, $path)
theme_get_setting ($setting_name, $theme=NULL)
theme_render_template ($template_file, $variables)
theme_enable ($theme_list)
theme_disable ($theme_list)
theme_status_messages ($variables)
theme_link ($variables)
theme_links ($variables)
theme_image ($variables)
theme_breadcrumb ($variables)
theme_table ($variables)
theme_tablesort_indicator ($variables)
theme_mark ($variables)
theme_item_list ($variables)
theme_more_help_link ($variables)
theme_feed_icon ($variables)
theme_html_tag ($variables)
theme_more_link ($variables)
theme_username ($variables)
theme_progress_bar ($variables)
theme_indentation ($variables)
_theme_table_cell ($cell, $header=FALSE)
template_preprocess (&$variables, $hook)
_template_preprocess_default_variables ()
template_process (&$variables, $hook)
template_preprocess_html (&$variables)
template_preprocess_page (&$variables)
template_process_page (&$variables)
template_process_html (&$variables)
theme_get_suggestions ($args, $base, $delimiter= '__')
template_preprocess_maintenance_page (&$variables)
template_process_maintenance_page (&$variables)
template_preprocess_region (&$variables)
template_preprocess_username (&$variables)
template_process_username (&$variables)

Variables

const | MARK_READ 0
const | MARK_NEW 1
const | MARK_UPDATED 2

Detailed Description

The theme system, which controls the output of Drupal.

The theme system allows for nearly all output of the Drupal system to be customized by user themes.

Definition in file theme.inc.

Function Documentation

_drupal_theme_access ( $theme )

Helper function for determining access to a theme.

See Also
drupal_theme_access()

Definition at line 62 of file theme.inc.

References variable_get().

Referenced by drupal_theme_access().

_drupal_theme_initialize | ( | $theme,
 |  | $base_theme = array(),
 |  | $registry_callback = '_theme_load_registry'
 | ) |

Initializes the theme system given already loaded information.

This function is useful to initialize a theme when no database is present.

Parameters
$theme | An object with the following information: filename The .info file for this theme. The 'path' to the theme will be in this file's directory. (Required) owner The path to the .theme file or the .engine file to load for the theme. (Required) stylesheet The primary stylesheet for the theme. (Optional) engine The name of theme engine to use. (Optional)
$base_theme | An optional array of objects that represent the 'base theme' if the theme is meant to be derivative of another theme. It requires the same information as the $theme object. It should be in 'oldest first' order, meaning the top level of the chain will be first.
$registry_callback | The callback to invoke to set the theme registry.

Definition at line 141 of file theme.inc.

References $name, _theme_registry_callback(), CSS_THEME, drupal_add_css(), drupal_add_js(), DRUPAL_ROOT, and JS_THEME.

Referenced by _drupal_maintenance_theme(), and drupal_theme_initialize().

_template_preprocess_default_variables ( )

Returns hook-independent variables to template_preprocess().

Definition at line 2380 of file theme.inc.

References drupal_is_front_page(), and user_access().

Referenced by template_preprocess().

_theme_build_registry | ( | $theme,
 |  | $base_theme,
 |  | $theme_engine
 | ) |

Builds the theme registry cache.

Parameters
$theme | The loaded $theme object as returned by list_themes().
$base_theme | An array of loaded $theme objects representing the ancestor themes in oldest first order.
$theme_engine | The name of the theme engine.

Definition at line 678 of file theme.inc.

References $info, $module, _theme_process_registry(), cache_get(), cache_set(), drupal_alter(), drupal_get_path(), module_implements(), and module_load_all().

Referenced by _theme_load_offline_registry(), and _theme_load_registry().

_theme_load_registry | ( | $theme,
 |  | $base_theme = NULL,
 |  | $theme_engine = NULL,
 |  | $complete = TRUE
 | ) |

Gets the theme_registry cache; if it doesn't exist, builds it.

Parameters
$theme | The loaded $theme object as returned by list_themes().
$base_theme | An array of loaded $theme objects representing the ancestor themes in oldest first order.
$theme_engine | The name of the theme engine.
$complete | Whether to load the complete theme registry or an instance of the ThemeRegistry class.
Returns
The theme registry array, or an instance of the ThemeRegistry class.

Definition at line 316 of file theme.inc.

References _theme_build_registry(), _theme_save_registry(), cache_get(), and module_load_all().

_theme_process_registry | ( | & | $cache,
 |  |  | $name,
 |  |  | $type,
 |  |  | $theme,
 |  |  | $path
 | ) |  |

Process a single implementation of hook_theme().

Parameters
$cache The theme registry that will eventually be cached; It is an associative array keyed by theme hooks, whose values are associative arrays describing the hook:
  • 'type': The passed-in $type.
  • 'theme path': The passed-in $path.
  • 'function': The name of the function generating output for this theme hook. Either defined explicitly in hook_theme() or, if neither 'function' nor 'template' is defined, then the default theme function name is used. The default theme function name is the theme hook prefixed by either 'theme_' for modules or '$name_' for everything else. If 'function' is defined, 'template' is not used.
  • 'template': The filename of the template generating output for this theme hook. The template is in the directory defined by the 'path' key of hook_theme() or defaults to $path.
  • 'variables': The variables for this theme hook as defined in hook_theme(). If there is more than one implementation and 'variables' is not specified in a later one, then the previous definition is kept.
  • 'render element': The renderable element for this theme hook as defined in hook_theme(). If there is more than one implementation and 'render element' is not specified in a later one, then the previous definition is kept.
  • 'preprocess functions': See theme() for detailed documentation.
  • 'process functions': See theme() for detailed documentation.
$name | The name of the module, theme engine, base theme engine, theme or base theme implementing hook_theme().
$type | One of 'module', 'theme_engine', 'base_theme_engine', 'theme', or 'base_theme'. Unlike regular hooks that can only be implemented by modules, each of these can implement hook_theme(). _theme_process_registry() is called in aforementioned order and new entries override older ones. For example, if a theme hook is both defined by a module and a theme, then the definition in the theme will be used.
$theme | The loaded $theme object as returned from list_themes().
$path | The directory where $name is. For example, modules/system or themes/bartik.
See Also
theme()
_theme_build_registry()
hook_theme()
list_themes()

Definition at line 515 of file theme.inc.

References $info, $name, DRUPAL_ROOT, and module_list().

Referenced by _theme_build_registry().

_theme_registry_callback | ( |  | $callback = NULL,
 |  | array | $arguments = array()
 | ) |  |

Sets the callback that will be used by theme_get_registry().

Parameters
$callback | The name of the callback function.
$arguments | The arguments to pass to the function.

Definition at line 291 of file theme.inc.

Referenced by _drupal_theme_initialize(), and theme_get_registry().

_theme_save_registry | ( | $theme,
 |  | $registry
 | ) |

Writes the theme_registry cache into the database.

Definition at line 342 of file theme.inc.

References cache_set().

Referenced by _theme_load_registry().

_theme_table_cell | ( | $cell,
 |  | $header = FALSE
 | ) |

End of "addtogroup themeable". Returns HTML output for a single table cell for theme_table().

Parameters
$cell | Array of cell information, or string to display in cell.
bool | $header | TRUE if this cell is a table header cell, FALSE if it is an ordinary table cell. If $cell is an array with element 'header' set to TRUE, that will override the $header parameter.
Returns
HTML for the cell.

Definition at line 2303 of file theme.inc.

References $attributes, $header, $output, drupal_attributes(), and drupal_render().

Referenced by template_preprocess_forum_topic_list(), and theme_table().

drupal_find_base_themes | ( | $themes,
 |  | $key,
 |  | $used_keys = array()
 | ) |

Find all the base themes for the specified theme.

Themes can inherit templates and function implementations from earlier themes.

Parameters
$themes | An array of available themes.
$key | The name of the theme whose base we are looking for.
$used_keys | A recursion parameter preventing endless loops.
Returns
Returns an array of all of the theme's ancestors; the first element's value will be NULL if an error occurred.

Definition at line 843 of file theme.inc.

Referenced by _system_rebuild_theme_data(), system_find_base_themes(), and system_list().

drupal_find_theme_functions | ( | $cache,
 |  | $prefixes
 | ) |

Allows themes and/or theme engines to discover overridden theme functions.

Parameters
$cache | The existing cache of theme hooks to test against.
$prefixes | An array of prefixes to test, in reverse order of importance.
Returns
$implementations The functions found, suitable for returning from hook_theme;

Definition at line 1240 of file theme.inc.

References $info.

Referenced by phptemplate_theme().

drupal_find_theme_templates | ( | $cache,
 |  | $extension,
 |  | $path
 | ) |

Allows themes and/or theme engines to easily discover overridden templates.

Parameters
$cache | The existing cache of theme hooks to test against.
$extension | The extension that these templates will have.
$path | The path to search.

Definition at line 1296 of file theme.inc.

References $info, drupal_system_listing(), and list_themes().

Referenced by phptemplate_theme().

drupal_theme_access ( $theme )

End of "Content markers". Determines if a theme is available to use.

Parameters
$theme Either the name of a theme or a full theme object.
Returns
Boolean TRUE if the theme is enabled or is the site administration theme; FALSE otherwise.

Definition at line 47 of file theme.inc.

References _drupal_theme_access(), and list_themes().

Referenced by _block_themes_access(), _system_themes_access(), drupal_theme_initialize(), menu_get_custom_theme(), and system_themes_page().

drupal_theme_initialize ( )

Initializes the theme system by loading the theme.

Definition at line 70 of file theme.inc.

References _drupal_theme_initialize(), drupal_add_js(), drupal_bootstrap(), DRUPAL_BOOTSTRAP_DATABASE, drupal_get_token(), drupal_static_reset(), drupal_theme_access(), list_themes(), menu_get_custom_theme(), and variable_get().

Referenced by _block_rehash(), _drupal_bootstrap_full(), _overlay_region_list(), batch_process(), block_admin_display(), block_page_build(), dashboard_admin_blocks(), dashboard_enable(), dashboard_form_block_admin_configure_alter(), dashboard_show_block_content(), dashboard_update(), l(), path_to_theme(), and theme_get_registry().

drupal_theme_rebuild ( )

Forces the system to rebuild the theme registry.

This function should be called when modules are added to the system, or when a dynamic system needs to add more theme hooks.

Definition at line 352 of file theme.inc.

References cache_clear_all(), and drupal_static_reset().

Referenced by drupal_flush_all_caches(), image_style_flush(), module_disable(), module_enable(), theme_disable(), and theme_enable().

list_themes ( $refresh = FALSE )

Returns a list of all currently available themes.

Retrieved from the database, if available and the site is not in maintenance mode; otherwise compiled freshly from the filesystem.

Parameters
$refresh Whether to reload the list of themes from the database. Defaults to FALSE.
Returns
An associative array of the currently available themes. The keys are the themes' machine names and the values are objects having the following properties:
  • filename: The filepath and name of the .info file.
  • name: The machine name of the theme.
  • status: 1 for enabled, 0 for disabled themes.
  • info: The contents of the .info file.
  • stylesheets: A two dimensional array, using the first key for the media attribute (e.g. 'all'), the second for the name of the file (e.g. style.css). The value is a complete filepath (e.g. themes/bartik/style.css). Not set if no stylesheets are defined in the .info file.
  • scripts: An associative array of JavaScripts, using the filename as key and the complete filepath as value. Not set if no scripts are defined in the .info file.
  • prefix: The base theme engine prefix.
  • engine: The machine name of the theme engine.
  • base_theme: If this is a sub-theme, the machine name of the base theme defined in the .info file. Otherwise, the element is not set.
  • base_themes: If this is a sub-theme, an associative array of the base-theme ancestors of this theme, starting with this theme's base theme, then the base theme's own base theme, etc. Each entry has an array key equal to the theme's machine name, and a value equal to the human-readable theme name; if a theme with matching machine name does not exist in the system, the value will instead be NULL (and since the system would not know whether that theme itself has a base theme, that will end the array of base themes). This is not set if the theme is not a sub-theme.
  • sub_themes: An associative array of themes on the system that are either direct sub-themes (that is, they declare this theme to be their base theme), direct sub-themes of sub-themes, etc. The keys are the themes' machine names, and the values are the themes' human-readable names. This element is not set if there are no themes on the system that declare this theme as their base theme.

Definition at line 774 of file theme.inc.

References _system_rebuild_theme_data(), drupal_static(), system_list(), and system_list_reset().

Referenced by _color_html_alter(), _color_rewrite_stylesheet(), _color_theme_select_form_alter(), _drupal_maintenance_theme(), _overlay_region_list(), block_add_block_form_submit(), block_admin_configure(), block_help(), block_menu(), drupal_find_theme_templates(), drupal_theme_access(), drupal_theme_initialize(), system_help(), system_menu(), system_region_list(), system_theme_default(), system_theme_disable(), system_theme_enable(), system_theme_settings(), template_preprocess_maintenance_page(), theme_disable(), theme_enable(), and theme_get_setting().

path_to_theme ( )

Returns the path to the current themed element.

It can point to the active theme or the module handling a themed implementation. For example, when invoked within the scope of a theming call it will depend on where the theming function is handled. If implemented from a module, it will point to the module. If implemented from the active theme, it will point to the active theme. When called outside the scope of a theming call, it will always point to the active theme.

Definition at line 1219 of file theme.inc.

References drupal_theme_initialize().

Referenced by bartik_preprocess_html(), garland_preprocess_html(), seven_preprocess_html(), and template_preprocess().

template_preprocess | ( | & | $variables,
 |  |  | $hook
 | ) |  |

Adds a default set of helper variables for variable processors and templates.

This function is called for theme hooks implemented as templates only, not for theme hooks implemented as functions. This preprocess function is the first in the sequence of preprocessing and processing functions that is called when preparing variables for a template. See theme() for more details about the full sequence.

See Also
theme()
template_process()

Definition at line 2343 of file theme.inc.

References _template_preprocess_default_variables(), drupal_html_class(), drupal_static(), and path_to_theme().

Referenced by theme().

template_preprocess_html ( & $variables )

Preprocess variables for html.tpl.php

See Also
system_elements()
html.tpl.php

Definition at line 2452 of file theme.inc.

References $head_title, arg(), check_plain(), drupal_add_html_head_link(), drupal_get_rdf_namespaces(), drupal_get_title(), drupal_html_class(), drupal_strip_dangerous_protocols(), filter_xss_admin(), menu_get_object(), theme_get_setting(), theme_get_suggestions(), and variable_get().

template_preprocess_maintenance_page ( & $variables )

Process variables for maintenance-page.tpl.php.

The variables array generated here is a mirror of template_preprocess_page(). This preprocessor will run its course when theme_maintenance_page() is invoked. An alternate template file of maintenance-page–offline.tpl.php can be used when the database is offline to hide errors and completely replace the content.

The $variables array contains the following arguments:

  • $content
See Also
maintenance-page.tpl.php

Definition at line 2722 of file theme.inc.

References $head_title, base_path(), drupal_add_html_head_link(), drupal_get_region_content(), drupal_get_title(), drupal_strip_dangerous_protocols(), language_default(), list_themes(), theme(), theme_get_setting(), url(), and variable_get().

template_preprocess_page ( & $variables )

Preprocess variables for page.tpl.php

Most themes utilize their own copy of page.tpl.php. The default is located inside "modules/system/page.tpl.php". Look in there for the full list of variables.

Uses the arg() function to generate a series of page template suggestions based on the current path.

Any changes to variables in this preprocessor should also be changed inside template_preprocess_maintenance_page() to keep all of them consistent.

See Also
drupal_render_page()
template_process_page()
page.tpl.php

Definition at line 2545 of file theme.inc.

References arg(), base_path(), drupal_get_feeds(), filter_xss_admin(), menu_get_object(), menu_local_actions(), menu_local_tabs(), menu_main_menu(), menu_secondary_menu(), system_region_list(), theme_get_setting(), theme_get_suggestions(), url(), and variable_get().

template_preprocess_region ( & $variables )

Preprocess variables for region.tpl.php

Prepares the values passed to the theme_region function to be passed into a pluggable template engine. Uses the region name to generate a template file suggestions. If none are found, the default region.tpl.php is used.

See Also
drupal_region_class()
region.tpl.php

Definition at line 2834 of file theme.inc.

References drupal_region_class().

template_preprocess_username ( & $variables )

Preprocesses variables for theme_username().

Modules that make any changes to variables like 'name' or 'extra' must insure that the final string is safe to include directly in the output by using check_plain() or filter_xss().

See Also
template_process_username()

Definition at line 2852 of file theme.inc.

References $name, check_plain(), drupal_strlen(), drupal_substr(), format_username(), t(), theme_get_setting(), and user_access().

template_process | ( | & | $variables,
 |  |  | $hook
 | ) |  |

Adds helper variables derived from variables defined during preprocessing.

When preparing variables for a theme hook implementation, all 'preprocess' functions run first, then all 'process' functions (see theme() for details about the full sequence).

This function serializes array variables manipulated during the preprocessing phase into strings for convenient use by templates. As with template_preprocess(), this function does not get called for theme hooks implemented as functions.

See Also
theme()
template_preprocess()

Definition at line 2433 of file theme.inc.

References drupal_attributes().

template_process_html ( & $variables )

Process variables for html.tpl.php

Perform final addition and modification of variables before passing into the template. To customize these variables, call drupal_render() on elements in $variables['page'] during THEME_preprocess_page().

See Also
template_preprocess_html()
html.tpl.php

Definition at line 2625 of file theme.inc.

References drupal_add_css(), drupal_get_css(), drupal_get_html_head(), drupal_get_js(), and drupal_render().

template_process_maintenance_page ( & $variables )

Theme process function for theme_maintenance_field().

The variables array generated here is a mirror of template_process_html(). This processor will run its course when theme_maintenance_page() is invoked.

See Also
maintenance-page.tpl.php
template_process_html()

Definition at line 2817 of file theme.inc.

References drupal_add_css(), drupal_get_css(), drupal_get_html_head(), and drupal_get_js().

template_process_page ( & $variables )

Process variables for page.tpl.php

Perform final addition of variables before passing them into the template. To customize these variables, simply set them in an earlier step.

See Also
template_preprocess_page()
page.tpl.php

Definition at line 2596 of file theme.inc.

References drupal_get_breadcrumb(), drupal_get_title(), and theme().

template_process_username ( & $variables )

Processes variables for theme_username().

See Also
template_preprocess_username()

Definition at line 2904 of file theme.inc.

theme | ( | $hook,
 |  | $variables = array()
 | ) |

Generates themed output.

All requests for themed output must go through this function (however, calling the theme() function directly is strongly discouraged - see next paragraph). It examines the request and routes it to the appropriate theme function or template , by checking the theme registry.

Avoid calling this function directly. It is preferable to replace direct calls to the theme() function with calls to drupal_render() by passing a render array with a theme key to drupal_render(), which in turn calls theme().

Theme Hooks

Most commonly, the first argument to this function is the name of the theme hook. For instance, to theme a taxonomy term, the theme hook name is 'taxonomy_term'. Modules register theme hooks within a hook_theme() implementation and provide a default implementation via a function named theme_HOOK() (e.g., theme_taxonomy_term()) or via a template file named according to the value of the 'template' key registered with the theme hook (see hook_theme() for details). Default templates are implemented with the PHPTemplate rendering engine and are named the same as the theme hook, with underscores changed to hyphens, so for the 'taxonomy_term' theme hook, the default template is 'taxonomy-term.tpl.php'.

Overriding Theme Hooks

Themes may also register new theme hooks within a hook_theme() implementation, but it is more common for themes to override default implementations provided by modules than to register entirely new theme hooks. Themes can override a default implementation by implementing a function named THEME_HOOK() (for example, the 'bartik' theme overrides the default implementation of the 'menu_tree' theme hook by implementing a bartik_menu_tree() function), or by adding a template file within its folder structure that follows the template naming structure used by the theme's rendering engine (for example, since the Bartik theme uses the PHPTemplate rendering engine, it overrides the default implementation of the 'page' theme hook by containing a 'page.tpl.php' file within its folder structure).

Preprocessing for Template Files

If the implementation is a template file, several functions are called before the template file is invoked, to modify the $variables array. These fall into the "preprocessing" phase and the "processing" phase, and are executed (if they exist), in the following order (note that in the following list, HOOK indicates the theme hook name, MODULE indicates a module name, THEME indicates a theme name, and ENGINE indicates a theme engine name):

  • template_preprocess(&$variables, $hook): Creates a default set of variables for all theme hooks with template implementations.
  • template_preprocess_HOOK(&$variables): Should be implemented by the module that registers the theme hook, to set up default variables.
  • MODULE_preprocess(&$variables, $hook): hook_preprocess() is invoked on all implementing modules.
  • MODULE_preprocess_HOOK(&$variables): hook_preprocess_HOOK() is invoked on all implementing modules, so that modules that didn't define the theme hook can alter the variables.
  • ENGINE_engine_preprocess(&$variables, $hook): Allows the theme engine to set necessary variables for all theme hooks with template implementations.
  • ENGINE_engine_preprocess_HOOK(&$variables): Allows the theme engine to set necessary variables for the particular theme hook.
  • THEME_preprocess(&$variables, $hook): Allows the theme to set necessary variables for all theme hooks with template implementations.
  • THEME_preprocess_HOOK(&$variables): Allows the theme to set necessary variables specific to the particular theme hook.
  • template_process(&$variables, $hook): Creates an additional set of default variables for all theme hooks with template implementations. The variables created in this function are derived from ones created by template_preprocess(), but potentially altered by the other preprocess functions listed above. For example, any preprocess function can add to or modify the $variables['attributes_array'] variable, and after all of them have finished executing, template_process() flattens it into a $variables['attributes'] string for convenient use by templates.
  • template_process_HOOK(&$variables): Should be implemented by the module that registers the theme hook, if it needs to perform additional variable processing after all preprocess functions have finished.
  • MODULE_process(&$variables, $hook): hook_process() is invoked on all implementing modules.
  • MODULE_process_HOOK(&$variables): hook_process_HOOK() is invoked on on all implementing modules, so that modules that didn't define the theme hook can alter the variables.
  • ENGINE_engine_process(&$variables, $hook): Allows the theme engine to process variables for all theme hooks with template implementations.
  • ENGINE_engine_process_HOOK(&$variables): Allows the theme engine to process the variables specific to the theme hook.
  • THEME_process(&$variables, $hook): Allows the theme to process the variables for all theme hooks with template implementations.
  • THEME_process_HOOK(&$variables): Allows the theme to process the variables specific to the theme hook.

Preprocessing for Theme Functions

If the implementation is a function, only the theme-hook-specific preprocess and process functions (the ones ending in _HOOK) are called from the list above. This is because theme hooks with function implementations need to be fast, and calling the non-theme-hook-specific preprocess and process functions for them would incur a noticeable performance penalty.

Suggesting Alternate Hooks

There are two special variables that these preprocess and process functions can set: 'theme_hook_suggestion' and 'theme_hook_suggestions'. These will be merged together to form a list of 'suggested' alternate theme hooks to use, in reverse order of priority. theme_hook_suggestion will always be a higher priority than items in theme_hook_suggestions. theme() will use the highest priority implementation that exists. If none exists, theme() will use the implementation for the theme hook it was called with. These suggestions are similar to and are used for similar reasons as calling theme() with an array as the $hook parameter (see below). The difference is whether the suggestions are determined by the code that calls theme() or by a preprocess or process function.

Parameters
$hook The name of the theme hook to call. If the name contains a double-underscore ('__') and there isn't an implementation for the full name, the part before the '__' is checked. This allows a fallback to a more generic implementation. For example, if theme('links__node', ...) is called, but there is no implementation of that theme hook, then the 'links' implementation is used. This process is iterative, so if theme('links__contextual__node', ...) is called, theme() checks for the following implementations, and uses the first one that exists:
  • links__contextual__node
  • links__contextual
  • links This allows themes to create specific theme implementations for named objects and contexts of otherwise generic theme hooks. The $hook parameter may also be an array, in which case the first theme hook that has an implementation is used. This allows for the code that calls theme() to explicitly specify the fallback order in a situation where using the '__' convention is not desired or is insufficient.
$variables An associative array of variables to merge with defaults from the theme registry, pass to preprocess and process functions for modification, and finally, pass to the function or template implementing the theme hook. Alternatively, this can be a renderable array, in which case, its properties are mapped to variables expected by the theme hook implementations.
Returns
An HTML string representing the themed output.
See Also
drupal_render()
Default theme implementations
hook_theme()
template_preprocess()
template_process()

Definition at line 1012 of file theme.inc.

References $info, $name, $output, DRUPAL_ROOT, module_load_all(), t(), template_preprocess(), theme_get_registry(), watchdog(), and WATCHDOG_WARNING.

Referenced by _aggregator_page_list(), _batch_progress_page_nojs(), _color_theme_select_form_alter(), _drupal_log_error(), _filter_html_tips(), _locale_translate_seek(), _node_mass_update_batch_finished(), _options_get_options(), _simpletest_batch_operation(), _system_modules_build_row(), aggregator_block_view(), aggregator_categorize_items(), aggregator_page_categories(), aggregator_page_opml(), aggregator_page_rss(), aggregator_page_source(), aggregator_page_sources(), aggregator_view(), ajax_example_intro(), ajax_example_node_by_author_autocomplete_submit(), ajax_prepare_response(), DrupalWebTestCase\assertThemeOutput(), blog_page_user(), book_admin_overview(), book_block_view(), book_export_html(), book_node_export(), book_node_view(), book_render(), comment_admin_overview(), comment_block_view(), comment_form(), comment_links(), comment_node_view(), contact_personal_form(), dashboard_show_disabled(), dblog_event(), dblog_overview(), dblog_top(), dbtng_example_advanced_list(), dbtng_example_list(), drupal_add_feed(), drupal_deliver_html_page(), drupal_get_js(), drupal_render(), field_help(), field_ui_fields_list(), field_ui_inactive_message(), field_ui_table_pre_render(), file_ajax_upload(), file_field_widget_form(), file_managed_file_process(), file_save_upload(), filter_tips_long(), forum_help(), forum_page(), garland_preprocess_page(), help_page(), hook_ajax_render_alter(), hook_process(), hook_search_execute(), hook_search_page(), hook_view(), image_example_style_form(), image_field_widget_form(), image_field_widget_process(), image_style_form(), image_style_list(), install_display_output(), install_verify_requirements(), l(), locale_block_view(), locale_date_format_language_overview_page(), locale_translate_overview_screen(), menu_overview_page(), node_access_example_private_node_listing(), node_add_page(), node_admin_nodes(), node_block_view(), node_example_field_formatter_view(), node_overview_types(), node_page_default(), node_preview(), node_revision_overview(), node_search_execute(), nodeapi_example_node_view(), poll_page(), poll_view_results(), poll_votes(), profile_block_view(), profile_browse(), queue_example_add_remove_form(), rdf_process(), seven_tablesort_indicator(), shortcut_set_admin(), simpletest_result_status_image(), statistics_access_log(), statistics_node_tracker(), statistics_recent_hits(), statistics_top_visitors(), system_actions_manage(), system_admin_config_page(), system_admin_index(), system_admin_menu_block_page(), system_block_view(), system_modules_confirm_form(), system_modules_uninstall_confirm_form(), system_requirements(), system_settings_overview(), system_status(), system_themes_page(), tablesort_header(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_summary_items(), template_preprocess_aggregator_wrapper(), template_preprocess_comment(), template_preprocess_forum_list(), template_preprocess_forum_submitted(), template_preprocess_forum_topic_list(), template_preprocess_forums(), template_preprocess_maintenance_page(), template_preprocess_node(), template_preprocess_poll_results(), template_preprocess_profile_block(), template_preprocess_profile_listing(), template_preprocess_search_results(), template_preprocess_user_picture(), template_process_page(), theme_admin_page(), theme_aggregator_categorize_items(), theme_authorize_report(), theme_book_admin_table(), theme_comment_block(), theme_dashboard_disabled_blocks(), theme_exposed_filters(), theme_feed_icon(), theme_field_multiple_value_form(), theme_field_ui_table(), theme_file_formatter_table(), theme_file_link(), theme_file_widget_multiple(), theme_filter_admin_format_filter_order(), theme_filter_admin_overview(), theme_filter_guidelines(), theme_form_element(), theme_form_element_label(), theme_form_example_checkbox(), theme_form_example_inline_form_element(), theme_image_anchor(), theme_image_crop_summary(), theme_image_example_image(), theme_image_formatter(), theme_image_scale_summary(), theme_image_style(), theme_image_style_effects(), theme_image_style_list(), theme_image_style_preview(), theme_install_page(), theme_locale_date_format_form(), theme_locale_languages_configure_form(), theme_locale_languages_overview_form(), theme_menu_overview_form(), theme_node_recent_block(), theme_node_recent_content(), theme_node_search_admin(), theme_pager(), theme_pager_first(), theme_pager_last(), theme_pager_next(), theme_pager_previous(), theme_poll_choices(), theme_profile_admin_overview(), theme_queue_items(), theme_shortcut_set_customize(), theme_simpletest_test_table(), theme_submit(), theme_system_admin_index(), theme_system_date_time_settings(), theme_system_modules_fieldset(), theme_system_modules_uninstall(), theme_system_themes_page(), theme_tabledrag_example_parent_form(), theme_tabledrag_example_simple_form(), theme_tableselect(), theme_tablesort_indicator(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_theming_example_list(), theme_trigger_display(), theme_update_manager_update_form(), theme_update_page(), theme_update_report(), theme_update_version(), theme_user_admin_permissions(), theme_user_admin_roles(), theme_user_list(), tracker_page(), update_check_requirements(), update_manager_download_batch_finished(), update_manager_update_form(), update_results_page(), update_script_selection_form(), update_status(), update_task_list(), user_account_form(), user_admin_account(), user_admin_permissions(), user_block_view(), user_login_block(), user_user_view(), and xmlrpc_example_info().

theme_disable ( $theme_list )

Disables a given list of themes.

Parameters
$theme_list An array of theme names.

Definition at line 1554 of file theme.inc.

References db_update(), drupal_clear_css_cache(), drupal_theme_rebuild(), list_themes(), menu_rebuild(), module_invoke_all(), and variable_get().

Referenced by system_theme_disable().

theme_enable ( $theme_list )

Enables a given list of themes.

Parameters
$theme_list An array of theme names.

Definition at line 1529 of file theme.inc.

References db_update(), drupal_clear_css_cache(), drupal_theme_rebuild(), list_themes(), menu_rebuild(), and module_invoke_all().

Referenced by system_theme_default(), and system_theme_enable().

theme_get_registry ( $complete = TRUE )

Gets the theme registry.

Parameters
$complete Optional boolean to indicate whether to return the complete theme registry array or an instance of the ThemeRegistry class. If TRUE, the complete theme registry array will be returned. This is useful if you want to foreach over the whole registry, use array_* functions or inspect it in a debugger. If FALSE, an instance of the ThemeRegistry class will be returned, this provides an ArrayObject which allows it to be accessed with array syntax and isset(), and should be more lightweight than the full registry. Defaults to TRUE.
Returns
The complete theme registry array, or an instance of the ThemeRegistry class.

Definition at line 255 of file theme.inc.

References _theme_registry_callback(), drupal_static(), and drupal_theme_initialize().

Referenced by contextual_preprocess(), hook_preprocess(), DrupalCacheArray\initializeRegistry(), l(), DrupalCacheArray\resolveCacheMiss(), and theme().

theme_get_setting | ( | $setting_name,
 |  | $theme = NULL
 | ) |

Retrieves a setting for the current theme or for a given theme.

The final setting is obtained from the last value found in the following sources:

  • the default global settings specified in this function
  • the default theme-specific settings defined in any base theme's .info file
  • the default theme-specific settings defined in the theme's .info file
  • the saved values from the global theme settings form
  • the saved values from the theme's settings form To only retrieve the default global theme setting, an empty string should be given for $theme.
Parameters
$setting_name | The name of the setting to be retrieved.
$theme | The name of a given theme; defaults to the current theme.
Returns
The value of the requested setting, NULL if the setting does not exist.

Definition at line 1401 of file theme.inc.

References _system_default_theme_features(), drupal_static(), file_create_url(), list_themes(), and variable_get().

Referenced by bartik_process_maintenance_page(), bartik_process_page(), garland_form_system_theme_settings_alter(), garland_preprocess_html(), hook_form_system_theme_settings_alter(), shortcut_preprocess_page(), system_theme_settings(), template_preprocess_comment(), template_preprocess_html(), template_preprocess_maintenance_page(), template_preprocess_node(), template_preprocess_page(), and template_preprocess_username().

theme_get_suggestions | ( | $args,
 |  | $base,
 |  | $delimiter = '__'
 | ) |

Generate an array of suggestions from path arguments.

This is typically called for adding to the 'theme_hook_suggestions' or 'classes_array' variables from within preprocess functions, when wanting to base the additional suggestions on the path of the current page.

Parameters
$args | An array of path arguments, such as from function arg().
$base | A string identifying the base 'thing' from which more specific suggestions are derived. For example, 'page' or 'html'.
$delimiter | The string used to delimit increasingly specific information. The default of '__' is appropriate for theme hook suggestions. '-' is appropriate for extra classes.
Returns
An array of suggestions, suitable for adding to $variables['theme_hook_suggestions'] within a preprocess function or to $variables['classes_array'] if the suggestions represent extra CSS classes.

Definition at line 2661 of file theme.inc.

References drupal_is_front_page().

Referenced by template_preprocess_html(), and template_preprocess_page().

theme_render_template | ( | $template_file,
 |  | $variables
 | ) |

Renders a system default template, which is essentially a PHP template.

Parameters
$template_file | The filename of the template to render.
$variables | A keyed array of variables that will appear in the output.
Returns
The output generated by the template.

Definition at line 1509 of file theme.inc.

References DRUPAL_ROOT.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/theme.maintenance.inc File Reference

  • includes
Functions
theme.maintenance.inc File Reference

Go to the source code of this file.

Functions

_drupal_maintenance_theme ()
_theme_load_offline_registry ($theme, $base_theme=NULL, $theme_engine=NULL)
theme_task_list ($variables)
theme_install_page ($variables)
theme_update_page ($variables)
theme_authorize_report ($variables)
theme_authorize_message ($variables)

Detailed Description

Theming for maintenance pages.

Definition in file theme.maintenance.inc.

Function Documentation

_drupal_maintenance_theme ( )

Sets up the theming system for maintenance page.

Used for site installs, updates and when the site is in maintenance mode. It also applies when the database is unavailable or bootstrap was not complete. Seven is always used for the initial install and update operations. In other cases, Bartik is used, but this can be overridden by setting a "maintenance_theme" key in the $conf variable in settings.php.

Definition at line 17 of file theme.maintenance.inc.

References $conf, $module_list, _drupal_theme_initialize(), drupal_add_css(), drupal_get_path(), drupal_load(), DRUPAL_ROOT, list_themes(), MAINTENANCE_MODE, module_list(), unicode_check(), and variable_get().

Referenced by drupal_maintenance_theme().

_theme_load_offline_registry | ( | $theme,
 |  | $base_theme = NULL,
 |  | $theme_engine = NULL
 | ) |

Builds the registry when the site needs to bypass any database calls.

Definition at line 90 of file theme.maintenance.inc.

References _theme_build_registry().

theme_install_page ( $variables )

Returns HTML for the installation page.

Note: this function is not themeable.

Parameters
$variables An associative array containing:
  • content: The page content to show.

Definition at line 141 of file theme.maintenance.inc.

References drupal_add_http_header(), and theme().

theme_update_page ( $variables )

Returns HTML for the update page.

Note: this function is not themeable.

Parameters
$variables An associative array containing:
  • content: The page content to show.
  • show_messages: Whether to output status and error messages. FALSE can be useful to postpone the messages to a subsequent page.

Definition at line 157 of file theme.maintenance.inc.

References drupal_add_http_header(), and theme().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/token.inc File Reference

  • includes
Functions
token.inc File Reference

Go to the source code of this file.

Functions

token_replace ($text, array $data=array(), array $options=array())
token_scan ($text)
token_generate ($type, array $tokens, array $data=array(), array $options=array())
token_find_with_prefix (array $tokens, $prefix, $delimiter= ':')
token_info ()

Detailed Description

Drupal placeholder/token replacement system.

API functions for replacing placeholders in text with meaningful values.

For example: When configuring automated emails, an administrator enters standard text for the email. Variables like the title of a node and the date the email was sent can be entered as placeholders like [node:title] and [date:short]. When a Drupal module prepares to send the email, it can call the token_replace() function, passing in the text. The token system will scan the text for placeholder tokens, give other modules an opportunity to replace them with meaningful text, then return the final product to the original module.

Tokens follow the form: [$type:$name], where $type is a general class of tokens like 'node', 'user', or 'comment' and $name is the name of a given placeholder. For example, [node:title] or [node:created:since].

In addition to raw text containing placeholders, modules may pass in an array of objects to be used when performing the replacement. The objects should be keyed by the token type they correspond to. For example:

* // Load a node and a user, then replace tokens in the text.
* $text = 'On [date:short], [user:name] read [node:title].';
* $node = node_load(1);
* $user = user_load(1);
*
* // [date:...] tokens use the current date automatically.
* $data = array('node' => $node, 'user' => $user);
* return token_replace($text, $data);
*

Some tokens may be chained in the form of [$type:$pointer:$name], where $type is a normal token type, $pointer is a reference to another token type, and $name is the name of a given placeholder. For example, [node:author:mail]. In that example, 'author' is a pointer to the 'user' account that created the node, and 'mail' is a placeholder available for any 'user'.

See Also
token_replace()
hook_tokens()
hook_token_info()

Definition in file token.inc.

Function Documentation

token_find_with_prefix | ( | array | $tokens,
 |  |  | $prefix,
 |  |  | $delimiter = ':'
 | ) |  |

Returns a list of tokens that begin with a specific prefix.

Used to extract a group of 'chained' tokens (such as [node:author:name]) from the full list of tokens found in text. For example:

* $data = array(
* 'author:name' => '[node:author:name]',
* 'title' => '[node:title]',
* 'created' => '[node:created]',
* );
* $results = token_find_with_prefix($data, 'author');
* $results == array('name' => '[node:author:name]');
*
Parameters
$tokens | A keyed array of tokens, and their original raw form in the source text.
$prefix | A textual string to be matched at the beginning of the token.
$delimiter | An optional string containing the character that separates the prefix from the rest of the token. Defaults to ':'.
Returns
An associative array of discovered tokens, with the prefix and delimiter stripped from the key.

Definition at line 219 of file token.inc.

References $results.

Referenced by comment_tokens(), hook_tokens(), node_tokens(), statistics_tokens(), system_tokens(), taxonomy_tokens(), token_example_tokens(), and user_tokens().

token_generate | ( |  | $type,
 |  | array | $tokens,
 |  | array | $data = array(),
 |  | array | $options = array()
 | ) |  |

Generates replacement values for a list of tokens.

Parameters
$type | The type of token being replaced. 'node', 'user', and 'date' are common.
$tokens | An array of tokens to be replaced, keyed by the literal text of the token as it appeared in the source text.
$data | (optional) An array of keyed objects. For simple replacement scenarios 'node', 'user', and others are common keys, with an accompanying node or user object being the value. Some token types, like 'site', do not require any explicit information from $data and can be replaced even if it is empty.
$options (optional) A keyed array of settings and flags to control the token replacement process. Supported options are:
  • language: A language object to be used when generating locale-sensitive tokens.
  • callback: A callback function that will be used to post-process the array of token replacements after they are generated. Can be used when modules require special formatting of token text, for example URL encoding or truncation to a specific length.
  • sanitize: A boolean flag indicating that tokens should be sanitized for display to a web browser. Developers who set this option to FALSE assume responsibility for running filter_xss(), check_plain() or other appropriate scrubbing functions before displaying data to users.
Returns
An associative array of replacement values, keyed by the original 'raw' tokens that were found in the source text. For example: $results['[node:title]'] = 'My new node';
See Also
hook_tokens()
hook_tokens_alter()

Definition at line 176 of file token.inc.

References drupal_alter(), and module_invoke_all().

Referenced by comment_tokens(), hook_tokens(), node_tokens(), statistics_tokens(), system_tokens(), taxonomy_tokens(), token_example_tokens(), token_replace(), and user_tokens().

token_info ( )

Returns metadata describing supported tokens.

The metadata array contains token type, name, and description data as well as an optional pointer indicating that the token chains to another set of tokens.

For example:

* $data['types']['node'] = array(
* 'name' => t('Nodes'),
* 'description' => t('Tokens related to node objects.'),
* );
* $data['tokens']['node']['title'] = array(
* 'name' => t('Title'),
* 'description' => t('The title of the current node.'),
* );
* $data['tokens']['node']['author'] = array(
* 'name' => t('Author'),
* 'description' => t('The author of the current node.'),
* 'type' => 'user',
* );
*
Returns
An associative array of token information, grouped by token type.

Definition at line 257 of file token.inc.

References drupal_alter(), drupal_static(), and module_invoke_all().

token_replace | ( |  | $text,
 |  | array | $data = array(),
 |  | array | $options = array()
 | ) |  |

Replaces all tokens in a given string with appropriate values.

Parameters
$text | A string potentially containing replaceable tokens.
$data | (optional) An array of keyed objects. For simple replacement scenarios 'node', 'user', and others are common keys, with an accompanying node or user object being the value. Some token types, like 'site', do not require any explicit information from $data and can be replaced even if it is empty.
$options (optional) A keyed array of settings and flags to control the token replacement process. Supported options are:
  • language: A language object to be used when generating locale-sensitive tokens.
  • callback: A callback function that will be used to post-process the array of token replacements after they are generated. For example, a module using tokens in a text-only email might provide a callback to strip HTML entities from token values before they are inserted into the final text.
  • clear: A boolean flag indicating that tokens should be removed from the final text if no replacement value can be generated.
  • sanitize: A boolean flag indicating that tokens should be sanitized for display to a web browser. Defaults to TRUE. Developers who set this option to FALSE assume responsibility for running filter_xss(), check_plain() or other appropriate scrubbing functions before displaying data to users.
Returns
Text with tokens replaced.

Definition at line 79 of file token.inc.

References token_generate(), and token_scan().

Referenced by _user_mail_text(), file_field_widget_uri(), system_goto_action(), system_mail(), system_message_action(), system_send_email_action(), and token_example_example_form().

token_scan ( $text )

Builds a list of all token-like patterns that appear in the text.

Parameters
$text The text to be scanned for possible tokens.
Returns
An associative array of discovered tokens, grouped by type.

Definition at line 114 of file token.inc.

References $results.

Referenced by token_replace().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/unicode.entities.inc File Reference

  • includes
Variables
unicode.entities.inc File Reference

Go to the source code of this file.

Variables

$html_entities

Detailed Description

(X)HTML entities, as defined in HTML 4.01.

See Also
http://www.w3.org/TR/html401/sgml/entities.html

Definition in file unicode.entities.inc.

Variable Documentation

$html_entities

Definition at line 10 of file unicode.entities.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/unicode.inc File Reference

  • includes
Functions | Variables
unicode.inc File Reference

Go to the source code of this file.

Functions

unicode_check ()
_unicode_check ()
unicode_requirements ()
drupal_xml_parser_create (&$data)
drupal_convert_to_utf8 ($data, $encoding)
drupal_truncate_bytes ($string, $len)
truncate_utf8 ($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
mime_header_encode ($string)
mime_header_decode ($header)
_mime_header_decode ($matches)
decode_entities ($text)
drupal_strlen ($text)
drupal_strtoupper ($text)
drupal_strtolower ($text)
_unicode_caseflip ($matches)
drupal_ucfirst ($text)
drupal_substr ($text, $start, $length=NULL)

Variables

const | UNICODE_ERROR -1
const | UNICODE_SINGLEBYTE 0
const | UNICODE_MULTIBYTE 1
const | PREG_CLASS_UNICODE_WORD_BOUNDARY '\x{0}-\x{2F}\x{3A}-\x{40}\x{5B}-\x{60}\x{7B}-\x{A9}\x{AB}-\x{B1}\x{B4}' . '\x{B6}-\x{B8}\x{BB}\x{BF}\x{D7}\x{F7}\x{2C2}-\x{2C5}\x{2D2}-\x{2DF}' . '\x{2E5}-\x{2EB}\x{2ED}\x{2EF}-\x{2FF}\x{375}\x{37E}-\x{385}\x{387}\x{3F6}' . '\x{482}\x{55A}-\x{55F}\x{589}-\x{58A}\x{5BE}\x{5C0}\x{5C3}\x{5C6}' . '\x{5F3}-\x{60F}\x{61B}-\x{61F}\x{66A}-\x{66D}\x{6D4}\x{6DD}\x{6E9}' . '\x{6FD}-\x{6FE}\x{700}-\x{70F}\x{7F6}-\x{7F9}\x{830}-\x{83E}' . '\x{964}-\x{965}\x{970}\x{9F2}-\x{9F3}\x{9FA}-\x{9FB}\x{AF1}\x{B70}' . '\x{BF3}-\x{BFA}\x{C7F}\x{CF1}-\x{CF2}\x{D79}\x{DF4}\x{E3F}\x{E4F}' . '\x{E5A}-\x{E5B}\x{F01}-\x{F17}\x{F1A}-\x{F1F}\x{F34}\x{F36}\x{F38}' . '\x{F3A}-\x{F3D}\x{F85}\x{FBE}-\x{FC5}\x{FC7}-\x{FD8}\x{104A}-\x{104F}' . '\x{109E}-\x{109F}\x{10FB}\x{1360}-\x{1368}\x{1390}-\x{1399}\x{1400}' . '\x{166D}-\x{166E}\x{1680}\x{169B}-\x{169C}\x{16EB}-\x{16ED}' . '\x{1735}-\x{1736}\x{17B4}-\x{17B5}\x{17D4}-\x{17D6}\x{17D8}-\x{17DB}' . '\x{1800}-\x{180A}\x{180E}\x{1940}-\x{1945}\x{19DE}-\x{19FF}' . '\x{1A1E}-\x{1A1F}\x{1AA0}-\x{1AA6}\x{1AA8}-\x{1AAD}\x{1B5A}-\x{1B6A}' . '\x{1B74}-\x{1B7C}\x{1C3B}-\x{1C3F}\x{1C7E}-\x{1C7F}\x{1CD3}\x{1FBD}' . '\x{1FBF}-\x{1FC1}\x{1FCD}-\x{1FCF}\x{1FDD}-\x{1FDF}\x{1FED}-\x{1FEF}' . '\x{1FFD}-\x{206F}\x{207A}-\x{207E}\x{208A}-\x{208E}\x{20A0}-\x{20B8}' . '\x{2100}-\x{2101}\x{2103}-\x{2106}\x{2108}-\x{2109}\x{2114}' . '\x{2116}-\x{2118}\x{211E}-\x{2123}\x{2125}\x{2127}\x{2129}\x{212E}' . '\x{213A}-\x{213B}\x{2140}-\x{2144}\x{214A}-\x{214D}\x{214F}' . '\x{2190}-\x{244A}\x{249C}-\x{24E9}\x{2500}-\x{2775}\x{2794}-\x{2B59}' . '\x{2CE5}-\x{2CEA}\x{2CF9}-\x{2CFC}\x{2CFE}-\x{2CFF}\x{2E00}-\x{2E2E}' . '\x{2E30}-\x{3004}\x{3008}-\x{3020}\x{3030}\x{3036}-\x{3037}' . '\x{303D}-\x{303F}\x{309B}-\x{309C}\x{30A0}\x{30FB}\x{3190}-\x{3191}' . '\x{3196}-\x{319F}\x{31C0}-\x{31E3}\x{3200}-\x{321E}\x{322A}-\x{3250}' . '\x{3260}-\x{327F}\x{328A}-\x{32B0}\x{32C0}-\x{33FF}\x{4DC0}-\x{4DFF}' . '\x{A490}-\x{A4C6}\x{A4FE}-\x{A4FF}\x{A60D}-\x{A60F}\x{A673}\x{A67E}' . '\x{A6F2}-\x{A716}\x{A720}-\x{A721}\x{A789}-\x{A78A}\x{A828}-\x{A82B}' . '\x{A836}-\x{A839}\x{A874}-\x{A877}\x{A8CE}-\x{A8CF}\x{A8F8}-\x{A8FA}' . '\x{A92E}-\x{A92F}\x{A95F}\x{A9C1}-\x{A9CD}\x{A9DE}-\x{A9DF}' . '\x{AA5C}-\x{AA5F}\x{AA77}-\x{AA79}\x{AADE}-\x{AADF}\x{ABEB}' . '\x{E000}-\x{F8FF}\x{FB29}\x{FD3E}-\x{FD3F}\x{FDFC}-\x{FDFD}' . '\x{FE10}-\x{FE19}\x{FE30}-\x{FE6B}\x{FEFF}-\x{FF0F}\x{FF1A}-\x{FF20}' . '\x{FF3B}-\x{FF40}\x{FF5B}-\x{FF65}\x{FFE0}-\x{FFFD}'

Detailed Description

Provides Unicode-related conversions and operations.

Definition in file unicode.inc.

Function Documentation

_mime_header_decode ( $matches )

Decodes encoded header data passed from mime_header_decode().

Callback for preg_replace_callback() within mime_header_decode().

Parameters
$matches The array of matches from preg_replace_callback().
Returns
string The mime-decoded string.
See Also
mime_header_decode()

Definition at line 432 of file unicode.inc.

_unicode_caseflip ( $matches )

Flips U+C0-U+DE to U+E0-U+FD and back.

Parameters
$matches An array of matches.
Returns
array The Latin-1 version of the array of matches.
See Also
drupal_strtolower()

Definition at line 546 of file unicode.inc.

_unicode_check ( )

Perform checks about Unicode support in PHP, and set the right settings if needed.

Because Drupal needs to be able to handle text in various encodings, we do not support mbstring function overloading. HTTP input/output conversion must be disabled for similar reasons.

Parameters
$errors Whether to report any fatal errors with form_set_error().

Definition at line 102 of file unicode.inc.

decode_entities ( $text )

Decodes all HTML entities (including numerical ones) to regular UTF-8 bytes.

Double-escaped entities will only be decoded once ("&amp;lt;" becomes "&lt;" , not "<"). Be careful when using this function, as decode_entities can revert previous sanitization efforts (<script> will become <script>).

Parameters
$text The text to decode entities in.
Returns
The input $text, with all HTML entities decoded once.

Definition at line 457 of file unicode.inc.

Referenced by _filter_url_parse_email_links(), _filter_url_parse_full_links(), _filter_url_parse_partial_links(), DrupalWebTestCase\checkForMetaRefresh(), comment_submit(), drupal_html_to_text(), filter_xss_bad_protocol(), format_rss_channel(), and locale_string_is_safe().

drupal_convert_to_utf8 | ( | $data,
 |  | $encoding
 | ) |

Converts data to UTF-8.

Requires the iconv, GNU recode or mbstring PHP extension.

Parameters
$data | The data to be converted.
$encoding | The encoding that the data is in.
Returns
Converted data or FALSE.

Definition at line 232 of file unicode.inc.

drupal_truncate_bytes | ( | $string,
 |  | $len
 | ) |

Truncates a UTF-8-encoded string safely to a number of bytes.

If the end position is in the middle of a UTF-8 sequence, it scans backwards until the beginning of the byte sequence.

Use this function whenever you want to chop off a string at an unsure location. On the other hand, if you're sure that you're splitting on a character boundary (e.g. after using strpos() or similar), you can safely use substr() instead.

Parameters
$string | The string to truncate.
$len | An upper limit on the returned string length.
Returns
The truncated string.

Definition at line 269 of file unicode.inc.

mime_header_decode ( $header )

Decodes MIME/HTTP encoded header values.

Parameters
$header The header to decode.
Returns
string The mime-decoded header.
See Also
mime_header_encode()

Definition at line 412 of file unicode.inc.

mime_header_encode ( $string )

Encodes MIME/HTTP header values that contain incorrectly encoded characters.

For example, mime_header_encode('tést.txt') returns "=?UTF-8?B?dMOpc3QudHh0?=".

See http://www.rfc-editor.org/rfc/rfc2047.txt for more information.

Notes:

  • Only encode strings that contain non-ASCII characters.
  • We progressively cut-off a chunk with truncate_utf8(). This is to ensure each chunk starts and ends on a character boundary.
  • Using
    as the chunk separator may cause problems on some systems and may have to be changed to
    or .
Parameters
$string The header to encode.
Returns
string The mime-encoded header.
See Also
mime_header_decode()

Definition at line 384 of file unicode.inc.

Referenced by file_get_content_headers(), and DefaultMailSystem\mail().

truncate_utf8 | ( | $string,
 |  | $max_length,
 |  | $wordsafe = FALSE,
 |  | $add_ellipsis = FALSE,
 |  | $min_wordsafe_length = 1
 | ) |

Truncates a UTF-8-encoded string safely to a number of characters.

Parameters
$string | The string to truncate.
$max_length | An upper limit on the returned string length, including trailing ellipsis if $add_ellipsis is TRUE.
$wordsafe | If TRUE, attempt to truncate on a word boundary. Word boundaries are spaces, punctuation, and Unicode characters used as word boundaries in non-Latin languages; see PREG_CLASS_UNICODE_WORD_BOUNDARY for more information. If a word boundary cannot be found that would make the length of the returned string fall within length guidelines (see parameters $max_length and $min_wordsafe_length), word boundaries are ignored.
$add_ellipsis | If TRUE, add t('...') to the end of the truncated string (defaults to FALSE). The string length will still fall within $max_length.
$min_wordsafe_length | If $wordsafe is TRUE, the minimum acceptable length for truncation (before adding an ellipsis, if $add_ellipsis is TRUE). Has no effect if $wordsafe is FALSE. This can be used to prevent having a very short resulting string that will not be understandable. For instance, if you are truncating the string "See myverylongurlexample.com for more information" to a word-safe return length of 20, the only available word boundary within 20 characters is after the word "See", which wouldn't leave a very informative string. If you had set $min_wordsafe_length to 10, though, the function would realise that "See" alone is too short, and would then just truncate ignoring word boundaries, giving you "See myverylongurl..." (assuming you had set $add_ellipses to TRUE).
Returns
string The truncated string.

Definition at line 316 of file unicode.inc.

Referenced by _book_toc_recurse(), _locale_translate_seek(), _menu_parents_recurse(), _statistics_link(), aggregator_aggregator_process(), aggregator_parse_feed(), comment_admin_overview(), comment_submit(), field_ui_field_overview_form(), DatabaseSchema_mysql\prepareComment(), statistics_exit(), text_summary(), and theme_dblog_message().

unicode_check ( )

Wrapper around _unicode_check().

Definition at line 87 of file unicode.inc.

Referenced by _drupal_bootstrap_full(), and _drupal_maintenance_theme().

unicode_requirements ( )

Returns Unicode library status and errors.

Definition at line 134 of file unicode.inc.

Referenced by system_requirements().

Variable Documentation

const PREG_CLASS_UNICODE_WORD_BOUNDARY '\x{0}-\x{2F}\x{3A}-\x{40}\x{5B}-\x{60}\x{7B}-\x{A9}\x{AB}-\x{B1}\x{B4}' . '\x{B6}-\x{B8}\x{BB}\x{BF}\x{D7}\x{F7}\x{2C2}-\x{2C5}\x{2D2}-\x{2DF}' . '\x{2E5}-\x{2EB}\x{2ED}\x{2EF}-\x{2FF}\x{375}\x{37E}-\x{385}\x{387}\x{3F6}' . '\x{482}\x{55A}-\x{55F}\x{589}-\x{58A}\x{5BE}\x{5C0}\x{5C3}\x{5C6}' . '\x{5F3}-\x{60F}\x{61B}-\x{61F}\x{66A}-\x{66D}\x{6D4}\x{6DD}\x{6E9}' . '\x{6FD}-\x{6FE}\x{700}-\x{70F}\x{7F6}-\x{7F9}\x{830}-\x{83E}' . '\x{964}-\x{965}\x{970}\x{9F2}-\x{9F3}\x{9FA}-\x{9FB}\x{AF1}\x{B70}' . '\x{BF3}-\x{BFA}\x{C7F}\x{CF1}-\x{CF2}\x{D79}\x{DF4}\x{E3F}\x{E4F}' . '\x{E5A}-\x{E5B}\x{F01}-\x{F17}\x{F1A}-\x{F1F}\x{F34}\x{F36}\x{F38}' . '\x{F3A}-\x{F3D}\x{F85}\x{FBE}-\x{FC5}\x{FC7}-\x{FD8}\x{104A}-\x{104F}' . '\x{109E}-\x{109F}\x{10FB}\x{1360}-\x{1368}\x{1390}-\x{1399}\x{1400}' . '\x{166D}-\x{166E}\x{1680}\x{169B}-\x{169C}\x{16EB}-\x{16ED}' . '\x{1735}-\x{1736}\x{17B4}-\x{17B5}\x{17D4}-\x{17D6}\x{17D8}-\x{17DB}' . '\x{1800}-\x{180A}\x{180E}\x{1940}-\x{1945}\x{19DE}-\x{19FF}' . '\x{1A1E}-\x{1A1F}\x{1AA0}-\x{1AA6}\x{1AA8}-\x{1AAD}\x{1B5A}-\x{1B6A}' . '\x{1B74}-\x{1B7C}\x{1C3B}-\x{1C3F}\x{1C7E}-\x{1C7F}\x{1CD3}\x{1FBD}' . '\x{1FBF}-\x{1FC1}\x{1FCD}-\x{1FCF}\x{1FDD}-\x{1FDF}\x{1FED}-\x{1FEF}' . '\x{1FFD}-\x{206F}\x{207A}-\x{207E}\x{208A}-\x{208E}\x{20A0}-\x{20B8}' . '\x{2100}-\x{2101}\x{2103}-\x{2106}\x{2108}-\x{2109}\x{2114}' . '\x{2116}-\x{2118}\x{211E}-\x{2123}\x{2125}\x{2127}\x{2129}\x{212E}' . '\x{213A}-\x{213B}\x{2140}-\x{2144}\x{214A}-\x{214D}\x{214F}' . '\x{2190}-\x{244A}\x{249C}-\x{24E9}\x{2500}-\x{2775}\x{2794}-\x{2B59}' . '\x{2CE5}-\x{2CEA}\x{2CF9}-\x{2CFC}\x{2CFE}-\x{2CFF}\x{2E00}-\x{2E2E}' . '\x{2E30}-\x{3004}\x{3008}-\x{3020}\x{3030}\x{3036}-\x{3037}' . '\x{303D}-\x{303F}\x{309B}-\x{309C}\x{30A0}\x{30FB}\x{3190}-\x{3191}' . '\x{3196}-\x{319F}\x{31C0}-\x{31E3}\x{3200}-\x{321E}\x{322A}-\x{3250}' . '\x{3260}-\x{327F}\x{328A}-\x{32B0}\x{32C0}-\x{33FF}\x{4DC0}-\x{4DFF}' . '\x{A490}-\x{A4C6}\x{A4FE}-\x{A4FF}\x{A60D}-\x{A60F}\x{A673}\x{A67E}' . '\x{A6F2}-\x{A716}\x{A720}-\x{A721}\x{A789}-\x{A78A}\x{A828}-\x{A82B}' . '\x{A836}-\x{A839}\x{A874}-\x{A877}\x{A8CE}-\x{A8CF}\x{A8F8}-\x{A8FA}' . '\x{A92E}-\x{A92F}\x{A95F}\x{A9C1}-\x{A9CD}\x{A9DE}-\x{A9DF}' . '\x{AA5C}-\x{AA5F}\x{AA77}-\x{AA79}\x{AADE}-\x{AADF}\x{ABEB}' . '\x{E000}-\x{F8FF}\x{FB29}\x{FD3E}-\x{FD3F}\x{FDFC}-\x{FDFD}' . '\x{FE10}-\x{FE19}\x{FE30}-\x{FE6B}\x{FEFF}-\x{FF0F}\x{FF1A}-\x{FF20}' . '\x{FF3B}-\x{FF40}\x{FF5B}-\x{FF65}\x{FFE0}-\x{FFFD}'

Matches Unicode characters that are word boundaries.

Characters with the following General_category (gc) property values are used as word boundaries. While this does not fully conform to the Word Boundaries algorithm described in http://unicode.org/reports/tr29, as PCRE does not contain the Word_Break property table, this simpler algorithm has to do.

  • Cc, Cf, Cn, Co, Cs: Other.
  • Pc, Pd, Pe, Pf, Pi, Po, Ps: Punctuation.
  • Sc, Sk, Sm, So: Symbols.
  • Zl, Zp, Zs: Separators.

Non-boundary characters include the following General_category (gc) property values:

  • Ll, Lm, Lo, Lt, Lu: Letters.
  • Mc, Me, Mn: Combining Marks.
  • Nd, Nl, No: Numbers.

Note that the PCRE property matcher is not used because we wanted to be compatible with Unicode 5.2.0 regardless of the PCRE version used (and any bugs in PCRE property tables).

See Also
http://unicode.org/glossary

Definition at line 48 of file unicode.inc.

const UNICODE_ERROR -1

Indicates an error during check for PHP unicode support.

Definition at line 11 of file unicode.inc.

const UNICODE_MULTIBYTE 1

Indicates that full unicode support with the PHP mbstring extension is being used.

Definition at line 22 of file unicode.inc.

const UNICODE_SINGLEBYTE 0

Indicates that standard PHP (emulated) unicode support is being used.

Definition at line 16 of file unicode.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/update.inc File Reference

  • includes
Classes | Functions | Variables
update.inc File Reference

Go to the source code of this file.

Classes

class DrupalUpdateException

Functions

update_fix_compatibility ()
update_check_incompatibility ($name, $type= 'module')
update_prepare_d7_bootstrap ()
update_fix_d7_block_deltas (&$sandbox, $renamed_deltas, $moved_deltas)
update_fix_d7_requirements ()
update_fix_d7_install_profile ()
update_parse_db_url ($db_url, $db_prefix)
update_get_d6_session_name ()
update_do_one ($module, $number, $dependency_map, &$context)
update_batch ($start, $redirect=NULL, $url=NULL, $batch=array(), $redirect_callback= 'drupal_goto')
update_finished ($success, $results, $operations)
update_get_update_list ()
update_resolve_dependencies ($starting_updates)
update_get_update_function_list ($starting_updates)
update_build_dependency_graph ($update_functions)
update_is_missing ($module, $number, $update_functions)
update_already_performed ($module, $number)
update_retrieve_dependencies ()

Variables

const REQUIRED_D6_SCHEMA_VERSION '6055'

Detailed Description

Drupal database update API.

This file contains functions to perform database updates for a Drupal installation. It is included and used extensively by update.php.

Definition in file update.inc.

Function Documentation

update_already_performed | ( | $module,
 |  | $number
 | ) |

Determines if a module update has already been performed.

Parameters
$module | The name of the module.
$number | The number of the update within that module.
Returns
TRUE if the database schema indicates that the update has already been performed; FALSE otherwise.

Definition at line 1407 of file update.inc.

References $module, and drupal_get_installed_schema_version().

Referenced by update_resolve_dependencies().

update_batch | ( | $start,
 |  | $redirect = NULL,
 |  | $url = NULL,
 |  | $batch = array(),
 |  | $redirect_callback = 'drupal_goto'
 | ) |

Starts the database update batch process.

Parameters
$start | An array whose keys contain the names of modules to be updated during the current batch process, and whose values contain the number of the first requested update for that module. The actual updates that are run (and the order they are run in) will depend on the results of passing this data through the update dependency system.
$redirect | Path to redirect to when the batch has finished processing.
$url | URL of the batch processing page (should only be used for separate scripts like update.php).
$batch | Optional parameters to pass into the batch API.
$redirect_callback | (optional) Specify a function to be called to redirect to the progressive processing page.
See Also
update_resolve_dependencies()

Definition at line 1032 of file update.inc.

References $url, batch_process(), batch_set(), drupal_set_installed_schema_version(), update_resolve_dependencies(), variable_get(), and variable_set().

update_build_dependency_graph ( $update_functions )

Constructs a graph which encodes the dependencies between module updates.

This function returns an associative array which contains a "directed graph" representation of the dependencies between a provided list of update functions, as well as any outside update functions that they directly depend on but that were not in the provided list. The vertices of the graph represent the update functions themselves, and each edge represents a requirement that the first update function needs to run before the second. For example, consider this graph:

system_update_7000 —> system_update_7001 —> system_update_7002

Visually, this indicates that system_update_7000() must run before system_update_7001(), which in turn must run before system_update_7002().

The function takes into account standard dependencies within each module, as shown above (i.e., the fact that each module's updates must run in numerical order), but also finds any cross-module dependencies that are defined by modules which implement hook_update_dependencies(), and builds them into the graph as well.

Parameters
$update_functions An organized array of update functions, in the format returned by update_get_update_function_list().
Returns
A multidimensional array representing the dependency graph, suitable for passing in to drupal_depth_first_search(), but with extra information about each update function also included. Each array key contains the name of an update function, including all update functions from the provided list as well as any outside update functions which they directly depend on. Each value is an associative array containing the following keys:
  • 'edges': A representation of any other update functions that immediately depend on this one. See drupal_depth_first_search() for more details on the format.
  • 'module': The name of the module that this update function belongs to.
  • 'number': The number of this update function within that module.
See Also
drupal_depth_first_search()
update_resolve_dependencies()

Definition at line 1336 of file update.inc.

References $module, and update_retrieve_dependencies().

Referenced by update_resolve_dependencies().

update_check_incompatibility | ( | $name,
 |  | $type = 'module'
 | ) |

Tests the compatibility of a module or theme.

Definition at line 43 of file update.inc.

References $name, DRUPAL_CORE_COMPATIBILITY, system_rebuild_module_data(), and system_rebuild_theme_data().

Referenced by update_fix_compatibility(), and update_get_update_list().

update_do_one | ( |  | $module,
 |  |  | $number,
 |  |  | $dependency_map,
 |  | & | $context
 | ) |  |

Performs one update and stores the results for display on the results page.

If an update function completes successfully, it should return a message as a string indicating success, for example:

* return t('New index added successfully.');
*

Alternatively, it may return nothing. In that case, no message will be displayed at all.

If it fails for whatever reason, it should throw an instance of DrupalUpdateException with an appropriate error message, for example:

* throw new DrupalUpdateException(t('Description of what went wrong'));
*

If an exception is thrown, the current update and all updates that depend on it will be aborted. The schema version will not be updated in this case, and all the aborted updates will continue to appear on update.php as updates that have not yet been run.

If an update function needs to be re-run as part of a batch process, it should accept the $sandbox array by reference as its first parameter and set the #finished property to the percentage completed that it is, as a fraction of 1.

Parameters
$module | The module whose update will be run.
$number | The update number to run.
$dependency_map | An array whose keys are the names of all update functions that will be performed during this batch process, and whose values are arrays of other update functions that each one depends on.
$context | The batch context array.
See Also
update_resolve_dependencies()

Definition at line 951 of file update.inc.

References $module, _drupal_decode_exception(), check_plain(), DRUPAL_ROOT, drupal_set_installed_schema_version(), t(), and watchdog_exception().

update_finished | ( | $success,
 |  | $results,
 |  | $operations
 | ) |

Finishes the update process and stores the results for eventual display.

After the updates run, all caches are flushed. The update results are stored into the session (for example, to be displayed on the update results page in update.php). Additionally, if the site was off-line, now that the update process is completed, the site is set back online.

Parameters
$success | Indicate that the batch API tasks were all completed successfully.
$results | An array of all the results that were updated in update_do_one().
$operations | A list of all the operations that had not been completed by the batch API.
See Also
update_batch()

Definition at line 1097 of file update.inc.

References $results, drupal_flush_all_caches(), variable_del(), and variable_set().

update_fix_compatibility ( )

Disable any items in the {system} table that are not core compatible.

Definition at line 24 of file update.inc.

References $row, db_query(), db_update(), and update_check_incompatibility().

update_fix_d7_block_deltas | ( | & | $sandbox,
 |  |  | $renamed_deltas,
 |  |  | $moved_deltas
 | ) |  |

A helper function that modules can use to assist with the transformation from numeric block deltas to string block deltas during the 6.x -> 7.x upgrade.

Parameters
$sandbox An array holding data for the batch process.
$renamed_deltas An associative array. Keys are module names, values an associative array mapping the old block deltas to the new block deltas for the module. Example:
* $renamed_deltas = array(
* 'mymodule' =>
* array(
* 0 => 'mymodule-block-1',
* 1 => 'mymodule-block-2',
* ),
* );
*
$moved_deltas An associative array. Keys are source module names, values an associative array mapping the (possibly renamed) block name to the new module name. Example:
* $moved_deltas = array(
* 'user' =>
* array(
* 'navigation' => 'system',
* ),
* );
*

Definition at line 355 of file update.inc.

References $module, $row, db_delete(), db_like(), db_query(), db_select(), db_table_exists(), and db_update().

Referenced by menu_update_7002(), and system_update_7004().

update_fix_d7_install_profile ( )

Register the currently installed profile in the system table.

Installation profiles are now treated as modules by Drupal, and have an upgrade path based on their schema version in the system table.

The installation profile will be set to schema_version 0, as it has already been installed. Any other hook_update_N functions provided by the installation profile will be run by update.php.

Definition at line 795 of file update.inc.

References $info, $results, db_insert(), db_select(), drupal_get_installed_schema_version(), drupal_get_profile(), drupal_load_updates(), DRUPAL_MINIMUM_PHP, and drupal_parse_info_file().

Referenced by update_fix_d7_requirements().

update_fix_d7_requirements ( )

Perform Drupal 6.x to 7.x updates that are required for update.php to function properly.

This function runs when update.php is run the first time for 7.x, even before updates are selected or performed. It is important that if updates are not ultimately performed that no changes are made which make it impossible to continue using the prior version.

Definition at line 478 of file update.inc.

References $conf, $databases, conf_path(), db_add_field(), db_add_index(), db_add_primary_key(), db_change_field(), db_create_table(), db_drop_index(), db_drop_primary_key(), db_drop_table(), db_insert(), db_query(), db_rename_table(), db_table_exists(), drupal_get_installed_schema_version(), drupal_hash_base64(), drupal_random_bytes(), system_schema_cache_7054(), update_fix_d7_install_profile(), update_parse_db_url(), variable_get(), and variable_set().

update_get_d6_session_name ( )

Constructs a session name compatible with a D6 environment.

Returns
D6-compatible session name string.
See Also
drupal_settings_initialize()

Definition at line 887 of file update.inc.

References $base_url.

Referenced by update_prepare_d7_bootstrap().

update_get_update_function_list ( $starting_updates )

Returns an organized list of update functions for a set of modules.

Parameters
$starting_updates An array whose keys contain the names of modules and whose values contain the number of the first requested update for that module.
Returns
An array containing all the update functions that should be run for each module, including the provided starting update and all subsequent updates that are available. The keys of the array contain the module names, and each value is an ordered array of update functions, keyed by the update number.
See Also
update_resolve_dependencies()

Definition at line 1273 of file update.inc.

References $module, and drupal_get_schema_versions().

Referenced by update_resolve_dependencies().

update_get_update_list ( )

Returns a list of all the pending database updates.

Returns
An associative array keyed by module name which contains all information about database updates that need to be run, and any updates that are not going to proceed due to missing requirements. The system module will always be listed first.

The subarray for each module can contain the following keys:

  • start: The starting update that is to be processed. If this does not exist then do not process any updates for this module as there are other requirements that need to be resolved.
  • warning: Any warnings about why this module can not be updated.
  • pending: An array of all the pending updates for the module including the update number and the description from source code comment for each update function. This array is keyed by the update number.

Definition at line 1135 of file update.inc.

References $module, drupal_get_installed_schema_version(), drupal_get_schema_versions(), drupal_map_assoc(), module_invoke(), SCHEMA_UNINSTALLED, and update_check_incompatibility().

Referenced by ModuleUpdater\getSchemaUpdates(), and update_script_selection_form().

update_is_missing | ( | $module,
 |  | $number,
 |  | $update_functions
 | ) |

Determines if a module update is missing or unavailable.

Parameters
$module | The name of the module.
$number | The number of the update within that module.
$update_functions | An organized array of update functions, in the format returned by update_get_update_function_list(). This should represent all module updates that are requested to run at the time this function is called.
Returns
TRUE if the provided module update is not installed or is not in the provided list of updates to run; FALSE otherwise.

Definition at line 1391 of file update.inc.

References $module.

Referenced by update_resolve_dependencies().

update_parse_db_url | ( | $db_url,
 |  | $db_prefix
 | ) |

Parse pre-Drupal 7 database connection URLs and return D7 compatible array.

Returns
Drupal 7 DBTNG compatible array of database connection information.

Definition at line 855 of file update.inc.

References $databases, and $url.

Referenced by update_fix_d7_requirements(), and update_prepare_d7_bootstrap().

update_prepare_d7_bootstrap ( )

Performs extra steps required to bootstrap when using a Drupal 6 database.

Users who still have a Drupal 6 database (and are in the process of updating to Drupal 7) need extra help before a full bootstrap can be achieved. This function does the necessary preliminary work that allows the bootstrap to be successful.

No access check has been performed when this function is called, so no irreversible changes to the database are made here.

Definition at line 81 of file update.inc.

References $databases, conf_path(), db_create_table(), db_driver(), db_run_tasks(), db_table_exists(), drupal_bootstrap(), DRUPAL_BOOTSTRAP_CONFIGURATION, DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_VARIABLES, drupal_get_installed_schema_version(), DRUPAL_MINIMUM_PHP, DRUPAL_ROOT, drupal_verify_install_file(), FILE_EXIST, FILE_READABLE, FILE_WRITABLE, print, REQUIRED_D6_SCHEMA_VERSION, REQUIREMENT_ERROR, REQUIREMENT_OK, update_extra_requirements(), update_get_d6_session_name(), update_parse_db_url(), variable_get(), and variable_set().

update_resolve_dependencies ( $starting_updates )

Resolves dependencies in a set of module updates, and orders them correctly.

This function receives a list of requested module updates and determines an appropriate order to run them in such that all update dependencies are met. Any updates whose dependencies cannot be met are included in the returned array but have the key 'allowed' set to FALSE; the calling function should take responsibility for ensuring that these updates are ultimately not performed.

In addition, the returned array also includes detailed information about the dependency chain for each update, as provided by the depth-first search algorithm in drupal_depth_first_search().

Parameters
$starting_updates An array whose keys contain the names of modules with updates to be run and whose values contain the number of the first requested update for that module.
Returns
An array whose keys are the names of all update functions within the provided modules that would need to be run in order to fulfill the request, arranged in the order in which the update functions should be run. (This includes the provided starting update for each module and all subsequent updates that are available.) The values are themselves arrays containing all the keys provided by the drupal_depth_first_search() algorithm, which encode detailed information about the dependency chain for this update function (for example: 'paths', 'reverse_paths', 'weight', and 'component'), as well as the following additional keys:
  • 'allowed': A boolean which is TRUE when the update function's dependencies are met, and FALSE otherwise. Calling functions should inspect this value before running the update.
  • 'missing_dependencies': An array containing the names of any other update functions that are required by this one but that are unavailable to be run. This array will be empty when 'allowed' is TRUE.
  • 'module': The name of the module that this update function belongs to.
  • 'number': The number of this update function within that module.
See Also
drupal_depth_first_search()

Definition at line 1220 of file update.inc.

References $module, drupal_depth_first_search(), DRUPAL_ROOT, update_already_performed(), update_build_dependency_graph(), update_get_update_function_list(), and update_is_missing().

Referenced by update_batch(), and update_script_selection_form().

update_retrieve_dependencies ( )

Invokes hook_update_dependencies() in all installed modules.

This function is similar to module_invoke_all(), with the main difference that it does not require that a module be enabled to invoke its hook, only that it be installed. This allows the update system to properly perform updates even on modules that are currently disabled.

Returns
An array of return values obtained by merging the results of the hook_update_dependencies() implementations in all installed modules.
See Also
module_invoke_all()
hook_update_dependencies()

Definition at line 1426 of file update.inc.

References $module, db_query(), and SCHEMA_UNINSTALLED.

Referenced by update_build_dependency_graph().

Variable Documentation

const REQUIRED_D6_SCHEMA_VERSION '6055'

Minimum schema version of Drupal 6 required for upgrade to Drupal 7.

Upgrades from Drupal 6 to Drupal 7 require that Drupal 6 be running the most recent version, or the upgrade could fail. We can't easily check the Drupal 6 version once the update process has begun, so instead we check the schema version of system.module in the system table.

Definition at line 19 of file update.inc.

Referenced by update_prepare_d7_bootstrap().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/updater.inc File Reference

  • includes
Classes
updater.inc File Reference

Go to the source code of this file.

Classes

interface | DrupalUpdaterInterface
class | Updater
class | UpdaterException
class | UpdaterFileTransferException

Detailed Description

Classes used for updating various files in the Drupal webroot. These classes use a FileTransfer object to actually perform the operations. Normally, the FileTransfer is provided when the site owner is redirected to authorize.php as part of a multistep process.

Definition in file updater.inc.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/utility.inc File Reference

  • includes
Functions
utility.inc File Reference

Go to the source code of this file.

Functions

drupal_var_export ($var, $prefix= '')

Detailed Description

Miscellaneous functions.

Definition in file utility.inc.

Function Documentation

drupal_var_export | ( | $var,
 |  | $prefix = ''
 | ) |

Drupal-friendly var_export().

Parameters
$var | The variable to export.
$prefix | A prefix that will be added at the beginning of every lines of the output.
Returns
The variable exported in a way compatible to Drupal's coding standards.

Definition at line 19 of file utility.inc.

References $output, and $value.

Referenced by render_example_arrays().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/xmlrpc.inc File Reference

  • includes
Functions
xmlrpc.inc File Reference

Go to the source code of this file.

Functions

xmlrpc_value ($data, $type=FALSE)
xmlrpc_value_calculate_type ($xmlrpc_value)
xmlrpc_value_get_xml ($xmlrpc_value)
xmlrpc_message ($message)
xmlrpc_message_parse ($xmlrpc_message)
xmlrpc_message_set ($value=NULL)
xmlrpc_message_get ()
xmlrpc_message_tag_open ($parser, $tag, $attr)
xmlrpc_message_cdata ($parser, $cdata)
xmlrpc_message_tag_close ($parser, $tag)
xmlrpc_request ($method, $args)
xmlrpc_error ($code=NULL, $message=NULL, $reset=FALSE)
xmlrpc_error_get_xml ($xmlrpc_error)
xmlrpc_date ($time)
xmlrpc_date_get_xml ($xmlrpc_date)
xmlrpc_base64 ($data)
xmlrpc_base64_get_xml ($xmlrpc_base64)
_xmlrpc ($url, $args, $options=array())
xmlrpc_errno ()
xmlrpc_error_msg ()
xmlrpc_clear_error ()

Detailed Description

Drupal XML-RPC library.

Based on the IXR - The Incutio XML-RPC Library - (c) Incutio Ltd 2002-2005 Version 1.7 (beta) - Simon Willison, 23rd May 2005 Site: http://scripts.incutio.com/xmlrpc/ Manual: http://scripts.incutio.com/xmlrpc/manual.php This version is made available under the GNU GPL License

Definition in file xmlrpc.inc.

Function Documentation

_xmlrpc | ( | $url,
 |  | $args,
 |  | $options = array()
 | ) |

Performs one or more XML-RPC requests.

Parameters
$url | An absolute URL of the XML-RPC endpoint, e.g., http://example.com/xmlrpc.php
$args | An associative array whose keys are the methods to call and whose values are the arguments to pass to the respective method. If multiple methods are specified, a system.multicall is performed.
$options | (optional) An array of options to pass along to drupal_http_request().
Returns
A single response (single request) or an array of responses (multicall request). Each response is the return value of the method, just as if it has been a local function call, on success, or FALSE on failure. If FALSE is returned, see xmlrpc_errno() and xmlrpc_error_msg() to get more information.

Definition at line 546 of file xmlrpc.inc.

References $url, drupal_http_request(), t(), xmlrpc_clear_error(), xmlrpc_error(), xmlrpc_message(), xmlrpc_message_parse(), and xmlrpc_request().

Referenced by xmlrpc().

xmlrpc_base64 ( $data )

Returns an XML-RPC base 64 object.

Parameters
$data Base 64 data to store in returned object.
Returns
object An XML-RPC base 64 object.

Definition at line 506 of file xmlrpc.inc.

xmlrpc_base64_get_xml ( $xmlrpc_base64 )

Converts an XML-RPC base 64 object into XML.

Parameters
$xmlrpc_base64 The XML-RPC base 64 object.
Returns
string An XML representation of the base 64 data as XML.

Definition at line 522 of file xmlrpc.inc.

Referenced by xmlrpc_value_get_xml().

xmlrpc_clear_error ( )

Clears any previously-saved errors.

See Also
xmlrpc_error()

Definition at line 622 of file xmlrpc.inc.

References xmlrpc_error().

Referenced by _xmlrpc().

xmlrpc_date ( $time )

Converts a PHP or ISO date/time to an XML-RPC object.

Parameters
$time A PHP timestamp or an ISO date-time string.
Returns
object An XML-RPC time/date object.

Definition at line 458 of file xmlrpc.inc.

Referenced by xmlrpc_message_tag_close().

xmlrpc_date_get_xml ( $xmlrpc_date )

Converts an XML-RPC date-time object into XML.

Parameters
$xmlrpc_date The XML-RPC date-time object.
Returns
string An XML representation of the date/time as XML.

Definition at line 493 of file xmlrpc.inc.

Referenced by xmlrpc_value_get_xml().

xmlrpc_errno ( )

Returns the last XML-RPC client error number.

Definition at line 604 of file xmlrpc.inc.

References xmlrpc_error().

Referenced by xmlrpc_example_client_add_submit(), xmlrpc_example_client_multicall_submit(), xmlrpc_example_client_request_methods_submit(), xmlrpc_example_client_subtract_submit(), and xmlrpc_example_info().

xmlrpc_error | ( | $code = NULL,
 |  | $message = NULL,
 |  | $reset = FALSE
 | ) |

Generates, temporarily saves, and returns an XML-RPC error object.

Parameters
$code | The error code.
$message | The error message.
$reset | TRUE to empty the temporary error storage. Ignored if $code is supplied.
Returns
object An XML-RPC error object representing $code and $message, or the most recently stored error object if omitted.

Definition at line 404 of file xmlrpc.inc.

Referenced by _xmlrpc(), _xmlrpc_example_server_add(), _xmlrpc_example_server_subtract(), xmlrpc_clear_error(), xmlrpc_errno(), xmlrpc_error_msg(), xmlrpc_server_call(), xmlrpc_server_error(), xmlrpc_server_method_signature(), and xmlrpc_server_multicall().

xmlrpc_error_get_xml ( $xmlrpc_error )

Converts an XML-RPC error object into XML.

Parameters
$xmlrpc_error The XML-RPC error object.
Returns
string An XML representation of the error as an XML methodResponse.

Definition at line 427 of file xmlrpc.inc.

References name, and value.

Referenced by xmlrpc_server_error().

xmlrpc_error_msg ( )

Returns the last XML-RPC client error message.

Definition at line 612 of file xmlrpc.inc.

References xmlrpc_error().

Referenced by xmlrpc_example_client_add_submit(), xmlrpc_example_client_multicall_submit(), xmlrpc_example_client_request_methods_submit(), xmlrpc_example_client_subtract_submit(), and xmlrpc_example_info().

xmlrpc_message ( $message )

Constructs an object representing an XML-RPC message.

Parameters
$message A string containing an XML message.
Returns
object An XML-RPC object containing the message.
See Also
http://www.xmlrpc.com/spec

Definition at line 149 of file xmlrpc.inc.

Referenced by _xmlrpc(), and xmlrpc_server().

xmlrpc_message_cdata | ( | $parser,
 |  | $cdata
 | ) |

Handles character data for XML parsing in xmlrpc_message_parse().

Definition at line 260 of file xmlrpc.inc.

References xmlrpc_message_get(), and xmlrpc_message_set().

xmlrpc_message_get ( )

Returns the most recently stored XML-RPC message object.

Returns
object The most recently stored message.
See Also
xmlrpc_message_set()

Definition at line 225 of file xmlrpc.inc.

References xmlrpc_message_set().

Referenced by xmlrpc_message_cdata(), xmlrpc_message_parse(), xmlrpc_message_tag_close(), and xmlrpc_message_tag_open().

xmlrpc_message_parse ( $xmlrpc_message )

Parses an XML-RPC message.

If parsing fails, the faultCode and faultString will be added to the message object.

Parameters
$xmlrpc_message An object generated by xmlrpc_message().
Returns
TRUE if parsing succeeded; FALSE otherwise.

Definition at line 173 of file xmlrpc.inc.

References xmlrpc_message_get(), and xmlrpc_message_set().

Referenced by _xmlrpc(), and xmlrpc_server().

xmlrpc_message_set ( $value = NULL )

Stores a copy of the most recent XML-RPC message object temporarily.

Parameters
$value An XML-RPC message to store, or NULL to keep the last message.
Returns
object The most recently stored message.
See Also
xmlrpc_message_get()

Definition at line 209 of file xmlrpc.inc.

References $value.

Referenced by xmlrpc_message_cdata(), xmlrpc_message_get(), xmlrpc_message_parse(), xmlrpc_message_tag_close(), and xmlrpc_message_tag_open().

xmlrpc_message_tag_close | ( | $parser,
 |  | $tag
 | ) |

Handles closing tags for XML parsing in xmlrpc_message_parse().

Definition at line 269 of file xmlrpc.inc.

References $value, xmlrpc_date(), xmlrpc_message_get(), and xmlrpc_message_set().

xmlrpc_message_tag_open | ( | $parser,
 |  | $tag,
 |  | $attr
 | ) |

Handles opening tags for XML parsing in xmlrpc_message_parse().

Definition at line 232 of file xmlrpc.inc.

References xmlrpc_message_get(), and xmlrpc_message_set().

xmlrpc_request | ( | $method,
 |  | $args
 | ) |

Constructs an object representing an XML-RPC request.

Parameters
$method | The name of the method to be called.
$args | An array of parameters to send with the method.
Returns
object An XML-RPC object representing the request.

Definition at line 369 of file xmlrpc.inc.

References xmlrpc_value(), and xmlrpc_value_get_xml().

Referenced by _xmlrpc().

xmlrpc_value | ( | $data,
 |  | $type = FALSE
 | ) |

Turns a data structure into objects with 'data' and 'type' attributes.

Parameters
$data | The data structure.
$type | Optional type to assign to $data.
Returns
object An XML-RPC data object containing the input $data.

Definition at line 25 of file xmlrpc.inc.

References $value, and xmlrpc_value_calculate_type().

Referenced by xmlrpc_request(), and xmlrpc_server().

xmlrpc_value_calculate_type ( $xmlrpc_value )

Maps a PHP type to an XML-RPC type.

Parameters
$xmlrpc_value Variable whose type should be mapped.
Returns
string The corresponding XML-RPC type.
See Also
http://www.xmlrpc.com/spec#scalars

Definition at line 57 of file xmlrpc.inc.

Referenced by xmlrpc_value().

xmlrpc_value_get_xml ( $xmlrpc_value )

Generates XML representing the given value.

Parameters
$xmlrpc_value A value to be represented in XML.
Returns
XML representation of $xmlrpc_value.

Definition at line 96 of file xmlrpc.inc.

References $name, $value, check_plain(), xmlrpc_base64_get_xml(), and xmlrpc_date_get_xml().

Referenced by xmlrpc_request(), and xmlrpc_server().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/xmlrpcs.inc File Reference

  • includes
Functions
xmlrpcs.inc File Reference

Go to the source code of this file.

Functions

xmlrpc_server ($callbacks)
xmlrpc_server_error ($error, $message=FALSE)
xmlrpc_server_output ($xml)
xmlrpc_server_set ($xmlrpc_server=NULL)
xmlrpc_server_get ()
xmlrpc_server_call ($xmlrpc_server, $methodname, $args)
xmlrpc_server_multicall ($methodcalls)
xmlrpc_server_list_methods ()
xmlrpc_server_get_capabilities ()
xmlrpc_server_method_signature ($methodname)
xmlrpc_server_method_help ($method)

Detailed Description

Provides API for defining and handling XML-RPC requests.

Definition in file xmlrpcs.inc.

Function Documentation

xmlrpc_server ( $callbacks )

Invokes XML-RPC methods on this server.

Parameters
array $callbacks Array of external XML-RPC method names with the callbacks they map to.

Definition at line 14 of file xmlrpcs.inc.

References drupal_alter(), drupal_exit(), print, t(), xmlrpc_message(), xmlrpc_message_parse(), xmlrpc_server_call(), xmlrpc_server_error(), xmlrpc_server_output(), xmlrpc_server_set(), xmlrpc_value(), and xmlrpc_value_get_xml().

xmlrpc_server_call | ( | $xmlrpc_server,
 |  | $methodname,
 |  | $args
 | ) |

Dispatches an XML-RPC request and any parameters to the appropriate handler.

Parameters
object | $xmlrpc_server | Object containing information about this XML-RPC server, the methods it provides, their signatures, etc.
string | $methodname | The external XML-RPC method name; e.g., 'system.methodHelp'.
array | $args | Array containing any parameters that are to be sent along with the request.
Returns
The results of the call.

Definition at line 178 of file xmlrpcs.inc.

References t(), and xmlrpc_error().

Referenced by xmlrpc_server(), and xmlrpc_server_multicall().

xmlrpc_server_error | ( | $error,
 |  | $message = FALSE
 | ) |

Throws an XML-RPC error.

Parameters
$error | An error object or integer error code.
$message | (optional) The description of the error. Used only if an integer error code was passed in.

Definition at line 111 of file xmlrpcs.inc.

References xmlrpc_error(), xmlrpc_error_get_xml(), and xmlrpc_server_output().

Referenced by xmlrpc_server().

xmlrpc_server_get ( )

Retrieves the latest stored XML-RPC request.

Returns
object The stored request.
See Also
xmlrpc_server_set()

Definition at line 160 of file xmlrpcs.inc.

References xmlrpc_server_set().

Referenced by xmlrpc_server_list_methods(), xmlrpc_server_method_help(), xmlrpc_server_method_signature(), and xmlrpc_server_multicall().

xmlrpc_server_get_capabilities ( )

Returns a list of the capabilities of this server.

XML-RPC method system.getCapabilities maps to this function.

Returns
array Array of server capabilities.
See Also
http://groups.yahoo.com/group/xml-rpc/message/2897

Definition at line 317 of file xmlrpcs.inc.

xmlrpc_server_list_methods ( )

Lists the methods available on this XML-RPC server.

XML-RPC method system.listMethods maps to this function.

Returns
array Array of the names of methods available on this server.

Definition at line 302 of file xmlrpcs.inc.

References xmlrpc_server_get().

xmlrpc_server_method_help ( $method )

Returns the help for an XML-RPC method.

XML-RPC method system.methodHelp maps to this function.

Parameters
string $method Name of method for which we return a help string.
Returns
string Help text for $method.

Definition at line 381 of file xmlrpcs.inc.

References xmlrpc_server_get().

xmlrpc_server_method_signature ( $methodname )

Returns one method signature for a function.

This is the function mapped to the XML-RPC method system.methodSignature.

A method signature is an array of the input and output types of a method. For instance, the method signature of this function is array('array', 'string'), because it takes an array and returns a string.

Parameters
string $methodname Name of method to return a method signature for.
Returns
array An array of arrays of types, each of the arrays representing one method signature of the function that $methodname maps to.

Definition at line 354 of file xmlrpcs.inc.

References t(), xmlrpc_error(), and xmlrpc_server_get().

xmlrpc_server_multicall ( $methodcalls )

Dispatches multiple XML-RPC requests.

Parameters
array $methodcalls An array of XML-RPC requests to make. Each request is an array with the following elements:
  • methodName: Name of the method to invoke.
  • params: Parameters to pass to the method.
Returns
An array of the results of each request.
See Also
xmlrpc_server_call()

Definition at line 263 of file xmlrpcs.inc.

References t(), xmlrpc_error(), xmlrpc_server_call(), and xmlrpc_server_get().

xmlrpc_server_output ( $xml )

Sends XML-RPC output to the browser.

Parameters
string $xml XML to send to the browser.

Definition at line 124 of file xmlrpcs.inc.

References drupal_add_http_header(), and drupal_exit().

Referenced by xmlrpc_server(), and xmlrpc_server_error().

xmlrpc_server_set ( $xmlrpc_server = NULL )

Stores a copy of an XML-RPC request temporarily.

Parameters
object $xmlrpc_server (optional) Request object created by xmlrpc_server(). Omit to leave the previous server object saved.
Returns
The latest stored request.
See Also
xmlrpc_server_get()

Definition at line 144 of file xmlrpcs.inc.

Referenced by xmlrpc_server(), and xmlrpc_server_get().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules Directory Reference

  • modules
modules Directory Reference

Directories

directory | aggregator
directory | block
directory | blog
directory | book
directory | color
directory | comment
directory | contact
directory | contextual
directory | dashboard
directory | dblog
directory | field
directory | field_ui
directory | file
directory | filter
directory | forum
directory | help
directory | image
directory | locale
directory | menu
directory | node
directory | openid
directory | overlay
directory | path
directory | php
directory | poll
directory | profile
directory | rdf
directory | search
directory | shortcut
directory | simpletest
directory | statistics
directory | syslog
directory | system
directory | taxonomy
directory | toolbar
directory | tracker
directory | translation
directory | trigger
directory | update
directory | user
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator Directory Reference

  • modules
  • aggregator
aggregator Directory Reference

Files

file | aggregator-feed-source.tpl.php [code]
file | aggregator-item.tpl.php [code]
file | aggregator-summary-item.tpl.php [code]
file | aggregator-summary-items.tpl.php [code]
file | aggregator-wrapper.tpl.php [code]
file | aggregator.admin.inc [code]
file | aggregator.api.php [code]
file | aggregator.fetcher.inc [code]
file | aggregator.install [code]
file | aggregator.module [code]
file | aggregator.pages.inc [code]
file | aggregator.parser.inc [code]
file | aggregator.processor.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.admin.inc File Reference

  • modules
  • aggregator
Functions
aggregator.admin.inc File Reference

Go to the source code of this file.

Functions

aggregator_admin_overview ()
aggregator_view ()
aggregator_form_feed ($form, &$form_state, stdClass $feed=NULL)
aggregator_form_feed_validate ($form, &$form_state)
aggregator_form_feed_submit ($form, &$form_state)
aggregator_admin_remove_feed ($form, $form_state, $feed)
aggregator_admin_remove_feed_submit ($form, &$form_state)
aggregator_form_opml ($form, &$form_state)
aggregator_form_opml_validate ($form, &$form_state)
aggregator_form_opml_submit ($form, &$form_state)
_aggregator_parse_opml ($opml)
aggregator_admin_refresh_feed ($feed)
aggregator_admin_form ($form, $form_state)
aggregator_admin_form_submit ($form, &$form_state)
aggregator_form_category ($form, &$form_state, $edit=array('title'=> '', 'description'=> '', 'cid'=> NULL))
aggregator_form_category_validate ($form, &$form_state)
aggregator_form_category_submit ($form, &$form_state)

Detailed Description

Administration page callbacks for the Aggregator module.

Definition in file aggregator.admin.inc.

Function Documentation

_aggregator_parse_opml ( $opml )

Parses an OPML file.

Feeds are recognized as <outline> elements with the attributes "text" and "xmlurl" set.

Parameters
$opml The complete contents of an OPML document.
Returns
An array of feeds, each an associative array with a "title" and a "url" element, or NULL if the OPML document failed to be parsed. An empty array will be returned if the document is valid but contains no feeds, as some OPML documents do.

Definition at line 383 of file aggregator.admin.inc.

References drupal_xml_parser_create().

Referenced by aggregator_form_opml_submit().

aggregator_admin_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for aggregator_admin_form().

Definition at line 529 of file aggregator.admin.inc.

References system_settings_form_submit().

aggregator_admin_overview ( )

Page callback: Displays the Aggregator module administration page.

Definition at line 11 of file aggregator.admin.inc.

References aggregator_view().

aggregator_admin_refresh_feed ( $feed )

Page callback: Refreshes a feed, then redirects to the overview page.

Parameters
$feed An object describing the feed to be refreshed.

Definition at line 407 of file aggregator.admin.inc.

References aggregator_refresh(), drupal_goto(), drupal_valid_token(), and MENU_ACCESS_DENIED.

aggregator_admin_remove_feed | ( | $form,
 |  | $form_state,
 |  | $feed
 | ) |

Deletes a feed.

Parameters
$feed An associative array describing the feed to be cleared.
See Also
aggregator_admin_remove_feed_submit()

Definition at line 217 of file aggregator.admin.inc.

References confirm_form(), and t().

aggregator_admin_remove_feed_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for aggregator_admin_remove_feed().

Removes all items from a feed and redirects to the overview page.

Definition at line 238 of file aggregator.admin.inc.

References aggregator_remove().

aggregator_form_category_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for aggregator_form_category().

See Also
aggregator_form_category_validate()

Definition at line 597 of file aggregator.admin.inc.

References $title, aggregator_save_category(), arg(), drupal_set_message(), l(), t(), watchdog(), and WATCHDOG_NOTICE.

aggregator_form_category_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for aggregator_form_category().

See Also
aggregator_form_category_submit()

Definition at line 575 of file aggregator.admin.inc.

References db_query(), form_set_error(), and t().

aggregator_form_feed_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for aggregator_form_feed().

See Also
aggregator_form_feed_validate()

Definition at line 171 of file aggregator.admin.inc.

References $title, aggregator_save_feed(), arg(), drupal_set_message(), l(), t(), watchdog(), and WATCHDOG_NOTICE.

aggregator_form_feed_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for aggregator_form_feed().

See Also
aggregator_form_feed_submit()

Definition at line 140 of file aggregator.admin.inc.

References db_query(), form_set_error(), t(), and valid_url().

aggregator_form_opml_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for aggregator_form_opml().

See Also
aggregator_form_opml_validate()

Definition at line 319 of file aggregator.admin.inc.

References _aggregator_parse_opml(), db_query(), drupal_form_submit(), drupal_http_request(), drupal_set_message(), file_save_upload(), t(), and valid_url().

aggregator_form_opml_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for aggregator_form_opml().

See Also
aggregator_form_opml_submit()

Definition at line 302 of file aggregator.admin.inc.

References form_set_error(), t(), and valid_url().

aggregator_view ( )

Displays the aggregator administration page.

Returns
A HTML-formatted string with administration page content.

Definition at line 21 of file aggregator.admin.inc.

References $header, $output, db_query(), drupal_get_token(), format_interval(), format_plural(), l(), REQUEST_TIME, t(), theme(), and url().

Referenced by aggregator_admin_overview().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.api.php File Reference

  • modules
  • aggregator
Functions
aggregator.api.php File Reference

Go to the source code of this file.

Functions

hook_aggregator_fetch ($feed)
hook_aggregator_fetch_info ()
hook_aggregator_parse ($feed)
hook_aggregator_parse_info ()
hook_aggregator_process ($feed)
hook_aggregator_process_info ()
hook_aggregator_remove ($feed)

Detailed Description

Documentation for aggregator API.

Definition in file aggregator.api.php.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.fetcher.inc File Reference

  • modules
  • aggregator
Functions
aggregator.fetcher.inc File Reference

Go to the source code of this file.

Functions

aggregator_aggregator_fetch_info ()
aggregator_aggregator_fetch ($feed)

Detailed Description

Fetcher functions for the aggregator module.

Definition in file aggregator.fetcher.inc.

Function Documentation

aggregator_aggregator_fetch ( $feed )

Implements hook_aggregator_fetch().

Definition at line 21 of file aggregator.fetcher.inc.

References drupal_http_request(), drupal_set_message(), t(), watchdog(), and WATCHDOG_WARNING.

aggregator_aggregator_fetch_info ( )

Implements hook_aggregator_fetch_info().

Definition at line 11 of file aggregator.fetcher.inc.

References t().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.install File Reference

  • modules
  • aggregator
Functions
aggregator.install File Reference

Go to the source code of this file.

Functions

aggregator_uninstall ()
aggregator_schema ()
aggregator_update_7000 ()
aggregator_update_7001 ()
aggregator_update_7002 ()
aggregator_update_7003 ()

Detailed Description

Install, update and uninstall functions for the aggregator module.

Definition in file aggregator.install.

Function Documentation

aggregator_schema ( )

Implements hook_schema().

Definition at line 25 of file aggregator.install.

aggregator_uninstall ( )

Implements hook_uninstall().

Definition at line 11 of file aggregator.install.

References variable_del().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.module File Reference

  • modules
  • aggregator
Functions | Variables
aggregator.module File Reference

Go to the source code of this file.

Functions

aggregator_help ($path, $arg)
aggregator_theme ()
aggregator_menu ()
_aggregator_category_title ($category)
_aggregator_has_categories ()
aggregator_permission ()
aggregator_cron ()
aggregator_cron_queue_info ()
aggregator_block_info ()
aggregator_block_configure ($delta= '')
aggregator_block_save ($delta= '', $edit=array())
aggregator_block_view ($delta= '')
aggregator_save_category ($edit)
aggregator_save_feed ($edit)
aggregator_remove ($feed)
_aggregator_get_variables ()
aggregator_refresh ($feed)
aggregator_feed_load ($fid)
aggregator_category_load ($cid)
theme_aggregator_block_item ($variables)
aggregator_filter_xss ($value)
aggregator_sanitize_configuration ()
_aggregator_items ($count)

Variables

const AGGREGATOR_CLEAR_NEVER 0

Detailed Description

Used to aggregate syndicated content (RSS, RDF, and Atom).

Definition in file aggregator.module.

Function Documentation

_aggregator_category_title ( $category )

Title callback: Returns a title for aggregator category pages.

Parameters
$category An aggregator category.
Returns
A string with the aggregator category title.

Definition at line 277 of file aggregator.module.

_aggregator_get_variables ( )

Gets the fetcher, parser, and processors.

Returns
An array containing the fetcher, parser, and processors.

Definition at line 589 of file aggregator.module.

References drupal_get_path(), DRUPAL_ROOT, and variable_get().

Referenced by aggregator_refresh(), aggregator_remove(), and aggregator_sanitize_configuration().

_aggregator_has_categories ( )

Determines whether there are any aggregator categories.

Returns
TRUE if there is at least one category and the user has access to them; FALSE otherwise.

Definition at line 288 of file aggregator.module.

References db_query_range(), and user_access().

_aggregator_items ( $count )

Helper function for drupal_map_assoc.

Parameters
$count Items count.
Returns
A string that is plural-formatted as "@count items".

Definition at line 780 of file aggregator.module.

References format_plural().

aggregator_block_configure ( $delta = '' )

Implements hook_block_configure().

Definition at line 364 of file aggregator.module.

References $value, db_query(), drupal_map_assoc(), and t().

aggregator_block_info ( )

Implements hook_block_info().

Definition at line 348 of file aggregator.module.

References db_query(), and t().

aggregator_block_save | ( | $delta = '',
 |  | $edit = array()
 | ) |

Implements hook_block_save().

Definition at line 381 of file aggregator.module.

References db_update().

aggregator_block_view ( $delta = '' )

Implements hook_block_view().

Generates blocks for the latest news items in each category and feed.

Definition at line 396 of file aggregator.module.

References check_plain(), db_query(), db_query_range(), t(), theme(), and user_access().

aggregator_category_load ( $cid )

Loads an aggregator category.

Parameters
$cid The category id.
Returns
An associative array describing the category.

Definition at line 701 of file aggregator.module.

References db_query(), and drupal_static().

aggregator_cron ( )

Implements hook_cron().

Queues news feeds for updates once their refresh interval has elapsed.

Definition at line 311 of file aggregator.module.

References AGGREGATOR_CLEAR_NEVER, db_query(), db_update(), DrupalQueue::get(), and REQUEST_TIME.

aggregator_cron_queue_info ( )

Implements hook_cron_queue_info().

Definition at line 337 of file aggregator.module.

aggregator_feed_load ( $fid )

Loads an aggregator feed.

Parameters
$fid The feed id.
Returns
An object describing the feed.

Definition at line 683 of file aggregator.module.

References db_query(), and drupal_static().

aggregator_filter_xss ( $value )

Renders the HTML content safely, as allowed.

Parameters
$value The content to be filtered.
Returns
The filtered content.

Definition at line 734 of file aggregator.module.

References $value, filter_xss(), and variable_get().

Referenced by template_preprocess_aggregator_feed_source(), and template_preprocess_aggregator_item().

aggregator_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 16 of file aggregator.module.

References $output, t(), and url().

aggregator_menu ( )

Implements hook_menu().

Definition at line 98 of file aggregator.module.

References MENU_CALLBACK, MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION, and MENU_LOCAL_TASK.

aggregator_permission ( )

Implements hook_permission().

Definition at line 295 of file aggregator.module.

References t().

aggregator_refresh ( $feed )

Checks a news feed for new items.

Parameters
$feed An object describing the feed to be refreshed.

Definition at line 612 of file aggregator.module.

References $feed_url, _aggregator_get_variables(), aggregator_expire(), db_merge(), db_update(), drupal_set_message(), module_invoke(), REQUEST_TIME, t(), and watchdog().

Referenced by aggregator_admin_refresh_feed().

aggregator_remove ( $feed )

Removes all items from a feed.

Parameters
$feed An object describing the feed to be cleared.

Definition at line 567 of file aggregator.module.

References _aggregator_get_variables(), db_update(), and module_invoke_all().

Referenced by aggregator_admin_remove_feed_submit().

aggregator_sanitize_configuration ( )

Checks and sanitizes the aggregator configuration.

Goes through all fetchers, parsers and processors and checks whether they are available. If one is missing, resets to standard configuration.

Returns
TRUE if this function resets the configuration; FALSE if not.

Definition at line 747 of file aggregator.module.

References _aggregator_get_variables(), module_exists(), and variable_del().

Referenced by aggregator_admin_form().

aggregator_save_category ( $edit )

Adds/edits/deletes aggregator categories.

Parameters
$edit An associative array describing the category to be added/edited/deleted.

Definition at line 440 of file aggregator.module.

References $op, db_delete(), db_insert(), db_merge(), menu_link_maintain(), and module_exists().

Referenced by aggregator_form_category_submit().

aggregator_save_feed ( $edit )

Add/edit/delete an aggregator feed.

Parameters
$edit An associative array describing the feed to be added/edited/deleted.

Definition at line 491 of file aggregator.module.

References $value, db_delete(), db_insert(), db_query(), db_update(), and module_exists().

Referenced by aggregator_form_feed_submit().

aggregator_theme ( )

Implements hook_theme().

Definition at line 50 of file aggregator.module.

Variable Documentation

const AGGREGATOR_CLEAR_NEVER 0

Denotes that a feed's items should never expire.

Definition at line 11 of file aggregator.module.

Referenced by aggregator_cron(), aggregator_expire(), aggregator_form_aggregator_admin_form_alter(), aggregator_form_feed(), and hook_cron().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.pages.inc File Reference

  • modules
  • aggregator
Functions
aggregator.pages.inc File Reference

Go to the source code of this file.

Functions

aggregator_page_last ()
aggregator_page_source ($feed)
aggregator_page_source_form ($form, $form_state, $feed)
aggregator_page_category ($category)
aggregator_page_category_form ($form, $form_state, $category)
aggregator_feed_items_load ($type, $data=NULL)
_aggregator_page_list ($items, $op, $feed_source= '')
aggregator_categorize_items ($items, $feed_source= '')
aggregator_categorize_items_submit ($form, &$form_state)
theme_aggregator_categorize_items ($variables)
template_preprocess_aggregator_wrapper (&$variables)
template_preprocess_aggregator_item (&$variables)
aggregator_page_sources ()
aggregator_page_categories ()
aggregator_page_rss ()
theme_aggregator_page_rss ($variables)
aggregator_page_opml ($cid=NULL)
theme_aggregator_page_opml ($variables)
template_preprocess_aggregator_summary_items (&$variables)
template_preprocess_aggregator_summary_item (&$variables)
template_preprocess_aggregator_feed_source (&$variables)

Detailed Description

User page callbacks for the Aggregator module.

Definition in file aggregator.pages.inc.

Function Documentation

_aggregator_page_list | ( | $items,
 |  | $op,
 |  | $feed_source = ''
 | ) |

Prints an aggregator page listing a number of feed items.

Various menu callbacks use this function to print their feeds.

Parameters
$items | The items to be listed.
$op | Which form should be added to the items. Only 'categorize' is now recognized.
$feed_source | The feed source URL.
Returns
The rendered list of items for the feed.

Definition at line 173 of file aggregator.pages.inc.

References $op, $output, aggregator_categorize_items(), theme(), and user_access().

Referenced by aggregator_page_category(), aggregator_page_last(), and aggregator_page_source().

aggregator_categorize_items_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for aggregator_categorize_items().

Definition at line 248 of file aggregator.pages.inc.

References db_delete(), db_insert(), drupal_set_message(), and t().

aggregator_feed_items_load | ( | $type,
 |  | $data = NULL
 | ) |

Loads and optionally filters feed items.

Parameters
$type The type of filter for the items. Possible values are:
  • sum: No filtering.
  • source: Filter the feed items, limiting the result to items from a single source.
  • category: Filter the feed items by category.
$data Feed or category data used for filtering. The type and value of $data depends on $type:
  • source: $data is an object with $data->fid identifying the feed used to as filter.
  • category: $data is an array with $data['cid'] being the category id to filter on. The $data parameter is not used when $type is 'sum'.
Returns
An array of the feed items.

Definition at line 114 of file aggregator.pages.inc.

References db_query(), and db_select().

Referenced by aggregator_page_category(), aggregator_page_last(), and aggregator_page_source().

aggregator_page_categories ( )

Page callback: Displays all the categories used by the Aggregator module.

Returns
string An HTML formatted string.
See Also
aggregator_menu()

Definition at line 379 of file aggregator.pages.inc.

References $output, db_query(), db_query_range(), theme(), url(), and variable_get().

aggregator_page_category ( $category )

Page callback: Displays all the items aggregated in a particular category.

Parameters
$category The category for which to list all of the aggregated items.
Returns
The rendered list of items for the feed.

Definition at line 68 of file aggregator.pages.inc.

References _aggregator_page_list(), aggregator_feed_items_load(), arg(), drupal_add_feed(), t(), and variable_get().

Referenced by aggregator_page_category_form().

aggregator_page_category_form | ( | $form,
 |  | $form_state,
 |  | $category
 | ) |

Page callback: Displays a form containing items aggregated in a category.

Parameters
$category The category for which to list all of the aggregated items.
Returns
The rendered list of items for the feed.
See Also
aggregator_page_category()

Definition at line 89 of file aggregator.pages.inc.

References aggregator_page_category().

aggregator_page_last ( )

Page callback: Displays the most recent items gathered from any feed.

Returns
The rendered list of items for the feed.

Definition at line 14 of file aggregator.pages.inc.

References _aggregator_page_list(), aggregator_feed_items_load(), arg(), drupal_add_feed(), t(), and variable_get().

aggregator_page_opml ( $cid = NULL )

Page callback: Generates an OPML representation of all feeds.

Parameters
$cid (optional) If set, feeds are exported only from a category with this ID. Otherwise, all feeds are exported. Defaults to NULL.
Returns
An OPML formatted string.

Definition at line 479 of file aggregator.pages.inc.

References db_query(), and theme().

aggregator_page_rss ( )

Page callback: Generates an RSS 0.92 feed of aggregator items or categories.

Returns
string An HTML formatted string.

Definition at line 404 of file aggregator.pages.inc.

References arg(), db_query(), db_query_range(), theme(), and variable_get().

aggregator_page_source ( $feed )

Page callback: Displays all the items captured from the particular feed.

Parameters
$feed The feed for which to display all items.
Returns
The rendered list of items for a feed.
See Also
aggregator_menu()

Definition at line 33 of file aggregator.pages.inc.

References _aggregator_page_list(), aggregator_feed_items_load(), arg(), drupal_set_title(), and theme().

Referenced by aggregator_page_source_form().

aggregator_page_source_form | ( | $form,
 |  | $form_state,
 |  | $feed
 | ) |

Page callback: Displays a form with all items captured from a feed.

Parameters
$feed The feed for which to list all of the aggregated items.
Returns
The rendered list of items for the feed.
See Also
aggregator_page_source()

Definition at line 55 of file aggregator.pages.inc.

References aggregator_page_source().

aggregator_page_sources ( )

Page callback: Displays all the feeds used by the aggregator.

Returns
An HTML-formatted string.
See Also
aggregator_menu()

Definition at line 350 of file aggregator.pages.inc.

References $output, db_query(), db_query_range(), t(), theme(), url(), and variable_get().

template_preprocess_aggregator_feed_source ( & $variables )

Processes variables for aggregator-feed-source.tpl.php.

See Also
aggregator-feed-source.tpl.php

Definition at line 557 of file aggregator.pages.inc.

References aggregator_filter_xss(), check_url(), format_interval(), l(), REQUEST_TIME, t(), theme(), url(), and user_access().

template_preprocess_aggregator_item ( & $variables )

Processes variables for aggregator-item.tpl.php.

See Also
aggregator-item.tpl.php

Definition at line 316 of file aggregator.pages.inc.

References aggregator_filter_xss(), check_plain(), check_url(), format_date(), format_interval(), l(), REQUEST_TIME, t(), url(), and variable_get().

template_preprocess_aggregator_summary_item ( & $variables )

Processes variables for aggregator-summary-item.tpl.php.

See Also
aggregator-summary-item.tpl.php

Definition at line 537 of file aggregator.pages.inc.

References check_plain(), check_url(), format_interval(), REQUEST_TIME, and t().

template_preprocess_aggregator_summary_items ( & $variables )

Processes variables for aggregator-summary-items.tpl.php.

See Also
aggregator-summary-items.tpl.php

Definition at line 526 of file aggregator.pages.inc.

References check_plain(), theme(), and title.

template_preprocess_aggregator_wrapper ( & $variables )

Processes variables for aggregator-wrapper.tpl.php.

See Also
aggregator-wrapper.tpl.php

Definition at line 307 of file aggregator.pages.inc.

References theme().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.parser.inc File Reference

  • modules
  • aggregator
Functions
aggregator.parser.inc File Reference

Go to the source code of this file.

Functions

aggregator_aggregator_parse_info ()
aggregator_aggregator_parse ($feed)
aggregator_parse_feed (&$data, $feed)
aggregator_element_start ($parser, $name, $attributes)
aggregator_element_end ($parser, $name)
aggregator_element_data ($parser, $data)
aggregator_parse_w3cdtf ($date_str)

Detailed Description

Parser functions for the aggregator module.

Definition in file aggregator.parser.inc.

Function Documentation

aggregator_aggregator_parse ( $feed )

Implements hook_aggregator_parse().

Definition at line 21 of file aggregator.parser.inc.

References $value, aggregator_parse_feed(), and cache_clear_all().

aggregator_aggregator_parse_info ( )

Implements hook_aggregator_parse_info().

Definition at line 11 of file aggregator.parser.inc.

References t().

aggregator_element_data | ( | $parser,
 |  | $data
 | ) |

Performs an action when data is encountered.

Callback function used by xml_parse() within aggregator_parse_feed().

Definition at line 246 of file aggregator.parser.inc.

aggregator_element_end | ( | $parser,
 |  | $name
 | ) |

Performs an action when a closing tag is encountered.

Callback function used by xml_parse() within aggregator_parse_feed().

Definition at line 222 of file aggregator.parser.inc.

References $name.

aggregator_element_start | ( | $parser,
 |  | $name,
 |  | $attributes
 | ) |

Performs an action when an opening tag is encountered.

Callback function used by xml_parse() within aggregator_parse_feed().

Definition at line 172 of file aggregator.parser.inc.

References $attributes, and $name.

aggregator_parse_feed | ( | & | $data,
 |  |  | $feed
 | ) |  |

Parses a feed and stores its items.

Parameters
$data | The feed data.
$feed | An object describing the feed to be parsed.
Returns
FALSE on error, TRUE otherwise.

Definition at line 67 of file aggregator.parser.inc.

References $value, aggregator_parse_w3cdtf(), drupal_set_message(), drupal_xml_parser_create(), t(), truncate_utf8(), watchdog(), and WATCHDOG_WARNING.

Referenced by aggregator_aggregator_parse().

aggregator_parse_w3cdtf ( $date_str )

Parses the W3C date/time format, a subset of ISO 8601.

PHP date parsing functions do not handle this format. See http://www.w3.org/TR/NOTE-datetime for more information. Originally from MagpieRSS (http://magpierss.sourceforge.net/).

Parameters
$date_str A string with a potentially W3C DTF date.
Returns
A timestamp if parsed successfully or FALSE if not.

Definition at line 303 of file aggregator.parser.inc.

Referenced by aggregator_parse_feed().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.processor.inc File Reference

  • modules
  • aggregator
Functions
aggregator.processor.inc File Reference

Go to the source code of this file.

Functions

aggregator_aggregator_process_info ()
aggregator_aggregator_process ($feed)
aggregator_aggregator_remove ($feed)
aggregator_form_aggregator_admin_form_alter (&$form, $form_state)
_aggregator_characters ($length)
aggregator_save_item ($edit)
aggregator_expire ($feed)

Detailed Description

Processor functions for the aggregator module.

Definition in file aggregator.processor.inc.

Function Documentation

_aggregator_characters ( $length )

Creates display text for teaser length option values.

Callback for drupal_map_assoc() within aggregator_form_aggregator_admin_form_alter().

Parameters
$length The desired length of teaser text, in bytes.
Returns
A translated string explaining the teaser string length.

Definition at line 141 of file aggregator.processor.inc.

References format_plural(), and t().

aggregator_aggregator_process ( $feed )

Implements hook_aggregator_process().

Definition at line 21 of file aggregator.processor.inc.

References aggregator_save_item(), db_query(), REQUEST_TIME, and truncate_utf8().

aggregator_aggregator_process_info ( )

Implements hook_aggregator_process_info().

Definition at line 11 of file aggregator.processor.inc.

References t().

aggregator_aggregator_remove ( $feed )

Implements hook_aggregator_remove().

Definition at line 53 of file aggregator.processor.inc.

References db_delete(), db_query(), drupal_set_message(), and t().

aggregator_expire ( $feed )

Expires items from a feed depending on expiration settings.

Parameters
$feed Object describing feed.

Definition at line 193 of file aggregator.processor.inc.

References AGGREGATOR_CLEAR_NEVER, db_delete(), db_query(), REQUEST_TIME, and variable_get().

Referenced by aggregator_refresh().

aggregator_form_aggregator_admin_form_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_aggregator_admin_form_alter().

Form alter aggregator module's own form to keep processor functionality separate from aggregator API functionality.

Definition at line 73 of file aggregator.processor.inc.

References $info, AGGREGATOR_CLEAR_NEVER, drupal_map_assoc(), module_invoke(), t(), url(), and variable_get().

aggregator_save_item ( $edit )

Adds/edits/deletes an aggregator item.

Parameters
$edit An associative array describing the item to be added/edited/deleted.

Definition at line 151 of file aggregator.processor.inc.

References db_delete(), db_insert(), db_merge(), and db_query().

Referenced by aggregator_aggregator_process().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/block Directory Reference

  • modules
  • block
block Directory Reference

Files

file | block-admin-display-form.tpl.php [code]
file | block.admin.inc [code]
file | block.api.php [code]
file | block.install [code]
file | block.module [code]
file | block.tpl.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/block/block.admin.inc File Reference

  • modules
  • block
Functions
block.admin.inc File Reference

Go to the source code of this file.

Functions

block_admin_demo ($theme=NULL)
block_admin_display ($theme=NULL)
block_admin_display_prepare_blocks ($theme)
block_admin_display_form ($form, &$form_state, $blocks, $theme, $block_regions=NULL)
block_admin_display_form_submit ($form, &$form_state)
_block_compare ($a, $b)
block_admin_configure ($form, &$form_state, $module, $delta)
block_admin_configure_validate ($form, &$form_state)
block_admin_configure_submit ($form, &$form_state)
block_add_block_form ($form, &$form_state)
block_add_block_form_validate ($form, &$form_state)
block_add_block_form_submit ($form, &$form_state)
block_custom_block_delete ($form, &$form_state, $module, $delta)
block_custom_block_delete_submit ($form, &$form_state)
template_preprocess_block_admin_display_form (&$variables)

Detailed Description

Admin page callbacks for the block module.

Definition in file block.admin.inc.

Function Documentation

_block_compare | ( | $a,
 |  | $b
 | ) |

Sorts active blocks by region, then by weight; sorts inactive blocks by name.

Callback for usort() in block_admin_display_prepare_blocks().

Definition at line 204 of file block.admin.inc.

References BLOCK_REGION_NONE, drupal_static(), and system_region_list().

block_add_block_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for block_add_block_form().

Saves the new custom block.

See Also
block_add_block_form()
block_add_block_form_validate()

Definition at line 553 of file block.admin.inc.

References BLOCK_REGION_NONE, cache_clear_all(), db_insert(), db_merge(), DRUPAL_NO_CACHE, drupal_set_message(), list_themes(), and t().

block_add_block_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for block_add_block_form().

See Also
block_add_block_form()
block_add_block_form_submit()

Definition at line 537 of file block.admin.inc.

References db_query_range(), form_set_error(), and t().

block_admin_configure_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for block_admin_configure().

See Also
block_admin_configure()
block_admin_configure_validate()

Definition at line 466 of file block.admin.inc.

References BLOCK_REGION_NONE, cache_clear_all(), db_delete(), db_insert(), db_merge(), db_transaction(), db_update(), drupal_set_message(), form_get_errors(), module_invoke(), t(), and watchdog_exception().

block_admin_configure_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for block_admin_configure().

See Also
block_admin_configure()
block_admin_configure_submit()

Definition at line 448 of file block.admin.inc.

References db_query_range(), form_set_error(), and t().

block_admin_demo ( $theme = NULL )

Menu callback for admin/structure/block/demo.

Definition at line 11 of file block.admin.inc.

References drupal_add_css(), and drupal_get_path().

block_admin_display ( $theme = NULL )

Menu callback for admin/structure/block.

Parameters
$theme The theme to display the administration page for. If not provided, defaults to the currently used theme.

Definition at line 23 of file block.admin.inc.

References block_admin_display_prepare_blocks(), drupal_get_form(), and drupal_theme_initialize().

block_admin_display_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for block_admin_display_form().

See Also
block_admin_display_form()

Definition at line 172 of file block.admin.inc.

References BLOCK_REGION_NONE, cache_clear_all(), db_transaction(), db_update(), drupal_set_message(), t(), and watchdog_exception().

block_admin_display_prepare_blocks ( $theme )

Prepares a list of blocks for display on the blocks administration page.

Parameters
$theme The machine-readable name of the theme whose blocks should be returned.
Returns
An array of blocks, as returned by _block_rehash(), sorted by region in preparation for display on the blocks administration page.
See Also
block_admin_display_form()

Definition at line 51 of file block.admin.inc.

References _block_rehash(), and drupal_static().

Referenced by block_admin_display(), and dashboard_admin_blocks().

block_custom_block_delete | ( |  | $form,
 |  | & | $form_state,
 |  |  | $module,
 |  |  | $delta
 | ) |  |

Form constructor for the custom block deletion form.

Parameters
$module | The name of the module that implements the block to be deleted. This should always equal 'block' since it only allows custom blocks to be deleted.
$delta | The unique ID of the block within the context of $module.
See Also
block_custom_block_delete_submit()

Definition at line 621 of file block.admin.inc.

References $module, block_custom_block_get(), block_load(), confirm_form(), and t().

block_custom_block_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for block_custom_block_delete().

See Also
block_custom_block_delete()

Definition at line 635 of file block.admin.inc.

References cache_clear_all(), db_delete(), drupal_set_message(), and t().

template_preprocess_block_admin_display_form ( & $variables )

Processes variables for block-admin-display-form.tpl.php.

The $variables array contains the following arguments:

  • $form
See Also
block-admin-display.tpl.php
theme_block_admin_display()

Definition at line 662 of file block.admin.inc.

References $value, BLOCK_REGION_NONE, drupal_render(), drupal_render_children(), element_children(), and t().

Referenced by template_preprocess_dashboard_admin_display_form().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/block/block.api.php File Reference

  • modules
  • block
Functions
block.api.php File Reference

Go to the source code of this file.

Functions

hook_block_info ()
hook_block_info_alter (&$blocks, $theme, $code_blocks)
hook_block_configure ($delta= '')
hook_block_save ($delta= '', $edit=array())
hook_block_view ($delta= '')
hook_block_view_alter (&$data, $block)
hook_block_view_MODULE_DELTA_alter (&$data, $block)
hook_block_list_alter (&$blocks)

Detailed Description

Hooks provided by the Block module.

Definition in file block.api.php.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/block/block.install File Reference

  • modules
  • block
Functions
block.install File Reference

Go to the source code of this file.

Functions

block_schema ()
block_install ()
block_update_dependencies ()
block_update_7000 ()
block_update_7002 ()
block_update_7003 ()
block_update_7004 ()
block_update_7005 ()
block_update_7006 ()
block_update_7007 ()
block_update_7008 ()

Detailed Description

Install, update and uninstall functions for the block module.

Definition in file block.install.

Function Documentation

block_install ( )

Implements hook_install().

Definition at line 178 of file block.install.

References db_update().

block_schema ( )

Implements hook_schema().

Definition at line 11 of file block.install.

References drupal_get_schema_unprocessed().

block_update_dependencies ( )

Implements hook_update_dependencies().

Definition at line 192 of file block.install.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/block/block.module File Reference

  • modules
  • block
Functions | Variables
block.module File Reference

Go to the source code of this file.

Functions

block_help ($path, $arg)
block_theme ()
block_permission ()
block_menu ()
_block_themes_access ($theme)
_block_custom_theme ($theme=NULL)
block_block_info ()
block_block_configure ($delta=0)
block_block_save ($delta=0, $edit=array())
block_block_view ($delta= '')
block_page_build (&$page)
block_get_blocks_by_region ($region)
_block_get_renderable_array ($list=array())
_block_rehash ($theme=NULL)
block_custom_block_get ($bid)
block_custom_block_form ($edit=array())
block_custom_block_save ($edit, $delta)
block_form_user_profile_form_alter (&$form, &$form_state)
block_user_presave (&$edit, $account, $category)
block_themes_enabled ($theme_list)
block_theme_initialize ($theme)
block_list ($region)
block_load ($module, $delta)
_block_load_blocks ()
block_block_list_alter (&$blocks)
_block_render_blocks ($region_blocks)
_block_get_cache_id ($block)
block_flush_caches ()
template_preprocess_block (&$variables)
block_user_role_delete ($role)
block_menu_delete ($menu)
block_form_system_performance_settings_alter (&$form, &$form_state)
block_admin_paths ()
block_modules_uninstalled ($modules)

Variables

const | BLOCK_REGION_NONE -1
const | BLOCK_CUSTOM_FIXED 0
const | BLOCK_CUSTOM_ENABLED 1
const | BLOCK_CUSTOM_DISABLED 2
const | BLOCK_VISIBILITY_NOTLISTED 0
const | BLOCK_VISIBILITY_LISTED 1
const | BLOCK_VISIBILITY_PHP 2

Detailed Description

Controls the visual building blocks a page is constructed with.

Definition in file block.module.

Function Documentation

_block_custom_theme ( $theme = NULL )

Theme callback for the block configuration pages.

Parameters
$theme The theme whose blocks are being configured. If not set, the default theme is assumed.
Returns
The theme that should be used for the block configuration page, or NULL to indicate that the default theme should be used.

Definition at line 196 of file block.module.

_block_get_cache_id ( $block )

Assemble the cache_id to use for a given block.

The cache_id string reflects the viewing context for the current block instance, obtained by concatenating the relevant context information (user, page, ...) according to the block's cache settings (BLOCK_CACHE_* constants). Two block instances can use the same cached content when they share the same cache_id.

Theme and language contexts are automatically differentiated.

Parameters
$block
Returns
The string used as cache_id for the block.

Definition at line 947 of file block.module.

References DRUPAL_CACHE_CUSTOM, DRUPAL_NO_CACHE, drupal_render_cid_parts(), and variable_get().

Referenced by _block_render_blocks().

_block_get_renderable_array ( $list = array() )

Gets an array of blocks suitable for drupal_render().

Parameters
$list A list of blocks such as that returned by block_list().
Returns
A renderable array.

Definition at line 333 of file block.module.

Referenced by block_get_blocks_by_region(), dashboard_page_build(), and dashboard_show_block_content().

_block_load_blocks ( )

Loads blocks' information from the database.

Returns
An array of blocks grouped by region.

Definition at line 726 of file block.module.

References db_select(), and drupal_alter().

Referenced by block_list().

_block_rehash ( $theme = NULL )

Updates the 'block' DB table with the blocks currently exported by modules.

Parameters
$theme The theme to rehash blocks for. If not provided, defaults to the currently used theme.
Returns
Blocks currently exported by modules.

Definition at line 369 of file block.module.

References $module, BLOCK_REGION_NONE, db_and(), db_delete(), db_or(), db_select(), drupal_alter(), drupal_set_message(), drupal_theme_initialize(), drupal_write_record(), module_implements(), module_invoke(), system_region_list(), and t().

Referenced by block_admin_display_prepare_blocks(), block_flush_caches(), and dashboard_show_disabled().

_block_render_blocks ( $region_blocks )

Render the content and subject for a set of blocks.

Parameters
$region_blocks An array of block objects such as returned for one region by _block_load_blocks().
Returns
An array of visible blocks as expected by drupal_render().

Definition at line 850 of file block.module.

References _block_get_cache_id(), cache_get_multiple(), cache_set(), CACHE_TEMPORARY, check_plain(), drupal_alter(), module_implements(), and module_invoke().

Referenced by block_list(), and dashboard_show_block_content().

_block_themes_access ( $theme )

Menu item access callback - only admin or enabled themes can be accessed.

Definition at line 182 of file block.module.

References drupal_theme_access(), and user_access().

block_admin_paths ( )

Implements hook_admin_paths().

Definition at line 1071 of file block.module.

block_block_configure ( $delta = 0 )

Implements hook_block_configure().

Definition at line 220 of file block.module.

References block_custom_block_form(), and block_custom_block_get().

block_block_info ( )

Implements hook_block_info().

Definition at line 205 of file block.module.

References db_query(), and DRUPAL_NO_CACHE.

block_block_list_alter ( & $blocks )

Implements hook_block_list_alter().

Checks the page, user role, and user-specific visibility settings. Removes the block if the visibility conditions are not met.

Definition at line 758 of file block.module.

References BLOCK_CUSTOM_ENABLED, BLOCK_CUSTOM_FIXED, BLOCK_VISIBILITY_LISTED, BLOCK_VISIBILITY_PHP, db_query(), drupal_get_path_alias(), drupal_match_path(), drupal_strtolower(), module_exists(), and php_eval().

block_block_save | ( | $delta = 0,
 |  | $edit = array()
 | ) |

Implements hook_block_save().

Definition at line 233 of file block.module.

References block_custom_block_save().

block_block_view ( $delta = '' )

Implements hook_block_view().

Generates the administrator-defined blocks for display.

Definition at line 242 of file block.module.

References check_markup(), and db_query().

block_custom_block_get ( $bid )

Returns information from database about a user-created (custom) block.

Parameters
$bid ID of the block to get information for.
Returns
Associative array of information stored in the database for this block. Array keys:
  • bid: Block ID.
  • info: Block description.
  • body: Block contents.
  • format: Filter ID of the filter format for the body.

Definition at line 501 of file block.module.

References db_query().

Referenced by block_block_configure(), and block_custom_block_delete().

block_custom_block_save | ( | $edit,
 |  | $delta
 | ) |

Saves a user-created block in the database.

Parameters
$edit Associative array of fields to save. Array keys:
  • info: Block description.
  • body: Associative array of body value and format. Array keys:
    • value: Block contents.
    • format: Filter ID of the filter format for the body.
$delta Block ID of the block to save.
Returns
Always returns TRUE.

Definition at line 559 of file block.module.

References db_update().

Referenced by block_block_save().

block_flush_caches ( )

Implements hook_flush_caches().

Definition at line 967 of file block.module.

References _block_rehash(), and db_query().

Referenced by system_update_7053().

block_form_system_performance_settings_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 1056 of file block.module.

References module_implements(), t(), and variable_get().

block_form_user_profile_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter() for user_profile_form().

Definition at line 574 of file block.module.

References check_plain(), db_query(), module_invoke(), and t().

block_get_blocks_by_region ( $region )

Gets a renderable array of a region containing all enabled blocks.

Parameters
$region The requested region.
Returns
A renderable array of a region containing all enabled blocks.

Definition at line 316 of file block.module.

References _block_get_renderable_array(), and block_list().

Referenced by block_page_build().

block_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 46 of file block.module.

References $output, l(), list_themes(), t(), url(), and variable_get().

block_list ( $region )

Returns all blocks in the specified region for the current user.

Parameters
$region The name of a region.
Returns
An array of block objects, indexed with the module name and block delta concatenated with an underscore, thus: MODULE_DELTA. If you are displaying your blocks in one or two sidebars, you may check whether this array is empty to see how many columns are going to be displayed.

Definition at line 674 of file block.module.

References _block_load_blocks(), _block_render_blocks(), and drupal_static().

Referenced by block_get_blocks_by_region().

block_load | ( | $module,
 |  | $delta
 | ) |

Loads a block object from the database.

Parameters
$module | Name of the module that implements the block to load.
$delta | Unique ID of the block within the context of $module. Pass NULL to return an empty block object for $module.
Returns
A block object.

Definition at line 704 of file block.module.

References $module, and db_query().

Referenced by block_admin_configure(), and block_custom_block_delete().

block_menu ( )

Implements hook_menu().

Definition at line 105 of file block.module.

References check_plain(), list_themes(), MENU_CALLBACK, MENU_CONTEXT_INLINE, MENU_CONTEXT_NONE, MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION, MENU_LOCAL_TASK, and variable_get().

block_menu_delete ( $menu )

Implements hook_menu_delete().

Definition at line 1042 of file block.module.

References db_delete().

block_modules_uninstalled ( $modules )

Implements hook_modules_uninstalled().

Cleans up {block} and {block_role} tables from modules' blocks.

Definition at line 1085 of file block.module.

References db_delete().

block_page_build ( & $page )

Implements hook_page_build().

Renders blocks into their regions.

Definition at line 254 of file block.module.

References $page, block_get_blocks_by_region(), drupal_static_reset(), drupal_theme_initialize(), menu_get_item(), REGIONS_VISIBLE, system_region_list(), t(), and variable_get().

block_permission ( )

Implements hook_permission().

Definition at line 94 of file block.module.

References t().

block_theme ( )

Implements hook_theme().

Definition at line 77 of file block.module.

block_theme_initialize ( $theme )

Assigns an initial, default set of blocks for a theme.

This function is called the first time a new theme is enabled. The new theme gets a copy of the default theme's blocks, with the difference that if a particular region isn't available in the new theme, the block is assigned to the new theme's default region.

Parameters
$theme The name of a theme.

Definition at line 638 of file block.module.

References db_query(), db_query_range(), drupal_write_record(), REGIONS_VISIBLE, system_default_region(), system_region_list(), and variable_get().

Referenced by block_themes_enabled(), and hook_themes_enabled().

block_themes_enabled ( $theme_list )

Initializes blocks for enabled themes.

Parameters
$theme_list An array of theme names.

Definition at line 621 of file block.module.

References block_theme_initialize().

block_user_presave | ( | & | $edit,
 |  |  | $account,
 |  |  | $category
 | ) |  |

Implements hook_user_presave().

Definition at line 609 of file block.module.

block_user_role_delete ( $role )

Implements hook_user_role_delete().

Removes deleted role from blocks that use it.

Definition at line 1033 of file block.module.

References db_delete().

template_preprocess_block ( & $variables )

Processes variables for block.tpl.php.

Prepares the values passed to the theme_block function to be passed into a pluggable template engine. Uses block properties to generate a series of template file suggestions. If none are found, the default block.tpl.php is used.

Most themes utilize their own copy of block.tpl.php. The default is located inside "modules/block/block.tpl.php". Look in there for the full list of variables.

The $variables array contains the following arguments:

  • $block
See Also
block.tpl.php

Definition at line 996 of file block.module.

References drupal_html_class(), drupal_html_id(), and drupal_static().

Variable Documentation

const BLOCK_CUSTOM_DISABLED 2

Hides this block by default but lets individual users show it.

Definition at line 26 of file block.module.

Referenced by block_admin_configure().

const BLOCK_CUSTOM_ENABLED 1

Shows this block by default, but lets individual users hide it.

Definition at line 21 of file block.module.

Referenced by block_admin_configure(), and block_block_list_alter().

const BLOCK_CUSTOM_FIXED 0

Users cannot control whether or not they see this block.

Definition at line 16 of file block.module.

Referenced by block_admin_configure(), and block_block_list_alter().

const BLOCK_REGION_NONE -1

Denotes that a block is not enabled in any region and should not be shown.

Definition at line 11 of file block.module.

Referenced by _block_compare(), _block_rehash(), block_add_block_form_submit(), block_admin_configure(), block_admin_configure_submit(), block_admin_display_form(), block_admin_display_form_submit(), dashboard_block_info_alter(), dashboard_disable(), template_preprocess_block_admin_display_form(), and template_preprocess_dashboard_admin_display_form().

const BLOCK_VISIBILITY_LISTED 1

Shows this block on only the listed pages.

Definition at line 36 of file block.module.

Referenced by block_admin_configure(), block_block_list_alter(), block_example_block_info(), and block_update_7004().

const BLOCK_VISIBILITY_NOTLISTED 0

Shows this block on every page except the listed pages.

Definition at line 31 of file block.module.

Referenced by block_admin_configure().

const BLOCK_VISIBILITY_PHP 2

Shows this block if the associated PHP code returns TRUE.

Definition at line 41 of file block.module.

Referenced by block_admin_configure(), and block_block_list_alter().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/blog Directory Reference

  • modules
  • blog
blog Directory Reference

Files

file | blog.install [code]
file | blog.module [code]
file | blog.pages.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/blog/blog.install File Reference

  • modules
  • blog
Functions
blog.install File Reference

Go to the source code of this file.

Functions

blog_install ()
blog_uninstall ()

Detailed Description

Install, update and uninstall functions for the blog module.

Definition in file blog.install.

Function Documentation

blog_install ( )

Implements hook_install().

Definition at line 11 of file blog.install.

References node_add_body_field(), node_type_get_types(), and node_types_rebuild().

blog_uninstall ( )

Implements hook_uninstall().

Definition at line 21 of file blog.install.

References variable_del().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/blog/blog.module File Reference

  • modules
  • blog
Functions
blog.module File Reference

Go to the source code of this file.

Functions

blog_node_info ()
blog_user_view ($account)
blog_help ($path, $arg)
blog_form ($node, $form_state)
blog_view ($node, $view_mode)
blog_node_view ($node, $view_mode)
blog_menu ()
blog_menu_local_tasks_alter (&$data, $router_item, $root_path)
blog_page_user_access ($account)
_blog_post_exists ($account)
blog_block_info ()
blog_block_configure ($delta= '')
blog_block_save ($delta= '', $edit=array())
blog_block_view ($delta= '')
blog_rdf_mapping ()

Detailed Description

Enables multi-user blogs.

Definition in file blog.module.

Function Documentation

_blog_post_exists ( $account )

Helper function to determine if a user has blog posts already.

Definition at line 182 of file blog.module.

References db_select().

Referenced by blog_page_user_access().

blog_block_configure ( $delta = '' )

Implements hook_block_configure().

Definition at line 206 of file blog.module.

References drupal_map_assoc(), t(), and variable_get().

blog_block_info ( )

Implements hook_block_info().

Definition at line 197 of file blog.module.

References t().

blog_block_save | ( | $delta = '',
 |  | $edit = array()
 | ) |

Implements hook_block_save().

Definition at line 221 of file blog.module.

References variable_set().

blog_block_view ( $delta = '' )

Implements hook_block_view().

Displays the most recent 10 blog titles.

Definition at line 232 of file blog.module.

References db_select(), node_title_list(), t(), user_access(), and variable_get().

blog_form | ( | $node,
 |  | $form_state
 | ) |

Implements hook_form().

Definition at line 62 of file blog.module.

References node_content_form().

blog_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 39 of file blog.module.

References $output, t(), and url().

blog_menu ( )

Implements hook_menu().

Definition at line 101 of file blog.module.

References MENU_CALLBACK, and MENU_SUGGESTED_ITEM.

blog_menu_local_tasks_alter | ( | & | $data,
 |  |  | $router_item,
 |  |  | $root_path
 | ) |  |

Implements hook_menu_local_tasks_alter().

Definition at line 140 of file blog.module.

References menu_get_item(), t(), and user_access().

blog_node_info ( )

Implements hook_node_info().

Definition at line 11 of file blog.module.

References t().

blog_node_view | ( | $node,
 |  | $view_mode
 | ) |

Implements hook_node_view().

Definition at line 80 of file blog.module.

References $links, arg(), format_username(), and t().

blog_page_user_access ( $account )

Access callback for user blog pages.

Definition at line 172 of file blog.module.

References _blog_post_exists(), and user_access().

blog_rdf_mapping ( )

Implements hook_rdf_mapping().

Definition at line 262 of file blog.module.

blog_user_view ( $account )

Implements hook_user_view().

Definition at line 24 of file blog.module.

References format_username(), l(), t(), and user_access().

blog_view | ( | $node,
 |  | $view_mode
 | ) |

Implements hook_view().

Definition at line 69 of file blog.module.

References drupal_set_breadcrumb(), format_username(), l(), node_is_page(), and t().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/blog/blog.pages.inc File Reference

  • modules
  • blog
Functions
blog.pages.inc File Reference

Go to the source code of this file.

Functions

blog_page_user ($account)
blog_page_last ()
blog_feed_user ($account)
blog_feed_last ()

Detailed Description

Page callback file for the blog module.

Definition in file blog.pages.inc.

Function Documentation

blog_feed_last ( )

Menu callback; displays an RSS feed containing recent blog entries of all users.

Definition at line 112 of file blog.pages.inc.

References db_select(), node_feed(), t(), url(), and variable_get().

blog_feed_user ( $account )

Menu callback; displays an RSS feed containing recent blog entries of a given user.

Definition at line 90 of file blog.pages.inc.

References db_select(), format_username(), node_feed(), t(), url(), and variable_get().

blog_page_last ( )

Menu callback; displays a Drupal page containing recent blog entries of all users.

Definition at line 55 of file blog.pages.inc.

References db_select(), drupal_add_feed(), drupal_set_message(), node_load_multiple(), node_view_multiple(), t(), and variable_get().

blog_page_user ( $account )

Menu callback; displays a Drupal page containing recent blog entries of a given user.

Definition at line 11 of file blog.pages.inc.

References $title, db_select(), drupal_add_feed(), drupal_set_message(), drupal_set_title(), format_username(), node_load_multiple(), node_view_multiple(), PASS_THROUGH, t(), theme(), and variable_get().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book Directory Reference

  • modules
  • book
book Directory Reference

Files

file | book-all-books-block.tpl.php [code]
file | book-export-html.tpl.php [code]
file | book-navigation.tpl.php [code]
file | book-node-export-html.tpl.php [code]
file | book.admin.inc [code]
file | book.install [code]
file | book.module [code]
file | book.pages.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book.admin.inc File Reference

  • modules
  • book
Functions
book.admin.inc File Reference

Go to the source code of this file.

Functions

book_admin_overview ()
book_admin_settings ()
book_admin_settings_validate ($form, &$form_state)
book_admin_edit ($form, $form_state, $node)
book_admin_edit_validate ($form, &$form_state)
book_admin_edit_submit ($form, &$form_state)
_book_admin_table ($node, &$form)
_book_admin_table_tree ($tree, &$form)
theme_book_admin_table ($variables)

Detailed Description

Administration page callbacks for the Book module.

Definition in file book.admin.inc.

Function Documentation

_book_admin_table | ( |  | $node,
 |  | & | $form
 | ) |  |

Builds the table portion of the form for the book administration page.

Parameters
$node | The node of the top-level page in the book.
$form | The form that is being modified, passed by reference.
See Also
book_admin_edit()

Definition at line 163 of file book.admin.inc.

References $tree, _book_admin_table_tree(), book_menu_subtree_data(), and drupal_hash_base64().

Referenced by book_admin_edit().

_book_admin_table_tree | ( |  | $tree,
 |  | & | $form
 | ) |  |

Helps build the main table in the book administration page form.

Parameters
$tree | A subtree of the book menu hierarchy.
$form | The form that is being modified, passed by reference.
Returns
The modified form array.
See Also
book_admin_edit()

Definition at line 201 of file book.admin.inc.

References $tree, and t().

Referenced by _book_admin_table().

book_admin_edit_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for book_admin_edit().

This function takes care to save parent menu items before their children. Saving menu items in the incorrect order can break the menu tree.

See Also
book_admin_edit_validate()
menu_overview_form_submit()

Definition at line 117 of file book.admin.inc.

References $row, drupal_set_message(), element_children(), l(), LANGUAGE_NONE, menu_link_save(), node_load(), node_save(), t(), title, watchdog(), and WATCHDOG_NOTICE.

book_admin_edit_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for book_admin_edit().

Checks that the book has not been changed while using the form.

See Also
book_admin_edit_submit()

Definition at line 102 of file book.admin.inc.

References form_set_error(), and t().

book_admin_overview ( )

Returns an administrative overview of all books.

Returns
string A HTML-formatted string with the administrative page content.
See Also
book_menu()

Definition at line 16 of file book.admin.inc.

References book_get_books(), l(), t(), and theme().

book_admin_settings_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for book_admin_settings().

See Also
book_admin_settings_submit()

Definition at line 64 of file book.admin.inc.

References form_set_error(), and t().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book.install File Reference

  • modules
  • book
Functions
book.install File Reference

Go to the source code of this file.

Functions

book_install ()
book_uninstall ()
_book_install_type_create ()
book_schema ()

Detailed Description

Install, update and uninstall functions for the book module.

Definition in file book.install.

Function Documentation

_book_install_type_create ( )

Creates the book content type.

Definition at line 34 of file book.install.

References node_add_body_field(), node_type_save(), node_type_set_defaults(), t(), and variable_set().

Referenced by book_install().

book_install ( )

Implements hook_install().

Definition at line 11 of file book.install.

References _book_install_type_create().

book_schema ( )

Implements hook_schema().

Definition at line 59 of file book.install.

book_uninstall ( )

Implements hook_uninstall().

Definition at line 19 of file book.install.

References db_delete(), menu_cache_clear_all(), and variable_del().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book.module File Reference

  • modules
  • book
Functions
book.module File Reference

Go to the source code of this file.

Functions

book_help ($path, $arg)
book_theme ()
book_permission ()
book_node_view_link ($node, $view_mode)
book_menu ()
_book_outline_access ($node)
_book_outline_remove_access ($node)
_book_node_is_removable ($node)
book_admin_paths ()
book_entity_info_alter (&$info)
book_block_info ()
book_block_view ($delta= '')
book_block_configure ($delta= '')
book_block_save ($delta= '', $edit=array())
theme_book_title_link ($variables)
book_get_books ()
book_form_node_form_alter (&$form, &$form_state, $form_id)
book_pick_book_nojs_submit ($form, &$form_state)
_book_parent_select ($book_link)
_book_add_form_elements (&$form, &$form_state, $node)
book_form_update ($form, $form_state)
_book_update_outline ($node)
book_update_bid ($book_link)
book_get_flat_menu ($book_link)
_book_flatten_menu ($tree, &$flat)
book_prev ($book_link)
book_next ($book_link)
book_children ($book_link)
book_menu_name ($bid)
book_node_load ($nodes, $types)
book_node_view ($node, $view_mode)
book_page_alter (&$page)
book_node_presave ($node)
book_node_insert ($node)
book_node_update ($node)
book_node_delete ($node)
book_node_prepare ($node)
_book_parent_depth_limit ($book_link)
book_form_node_delete_confirm_alter (&$form, $form_state)
_book_link_defaults ($nid)
template_preprocess_book_all_books_block (&$variables)
template_preprocess_book_navigation (&$variables)
_book_toc_recurse ($tree, $indent, &$toc, $exclude, $depth_limit)
book_toc ($bid, $depth_limit, $exclude=array())
template_preprocess_book_export_html (&$variables)
book_export_traverse ($tree, $visit_func)
book_node_export ($node, $children= '')
template_preprocess_book_node_export_html (&$variables)
book_type_is_allowed ($type)
book_node_type_update ($type)
book_link_load ($mlid)
book_menu_subtree_data ($link)

Detailed Description

Allows users to create and organize related content in an outline.

Definition in file book.module.

Function Documentation

_book_add_form_elements | ( | & | $form,
 |  | & | $form_state,
 |  |  | $node
 | ) |  |

Builds the common elements of the book form for the node and outline forms.

Parameters
$node The node whose form is being viewed.

Definition at line 519 of file book.module.

References _book_parent_select(), book_get_books(), drupal_get_path(), t(), and user_access().

Referenced by book_form_node_form_alter(), and book_outline_form().

_book_flatten_menu | ( |  | $tree,
 |  | & | $flat
 | ) |  |

Recursively converts a tree of menu links to a flat array.

Parameters
$tree | A tree of menu links in an array.
$flat | A flat array of the menu links from $tree, passed by reference.
See Also
book_get_flat_menu().

Definition at line 744 of file book.module.

References $tree.

Referenced by book_get_flat_menu().

_book_link_defaults ( $nid )

Returns an array with default values for a book page's menu link.

Parameters
$nid The ID of the node whose menu link is being created.
Returns
The default values for the menu link.

Definition at line 1057 of file book.module.

Referenced by book_node_prepare(), and book_outline_form().

_book_node_is_removable ( $node )

Determines if a node can be removed from the book.

A node can be removed from a book if it is actually in a book and it either is not a top-level page or is a top-level page with no children.

Parameters
$node The node to remove from the outline.

Definition at line 228 of file book.module.

Referenced by _book_outline_remove_access(), book_outline_form(), and book_remove_form_submit().

_book_outline_access ( $node )

Access callback: Determines if the outline tab is accessible.

Parameters
$node The node whose outline tab is to be viewed.

Definition at line 203 of file book.module.

References node_access(), and user_access().

Referenced by _book_outline_remove_access().

_book_outline_remove_access ( $node )

Access callback: Determines if the user can remove nodes from the outline.

Parameters
$node The node to remove from the outline.
See Also
book_menu()

Definition at line 215 of file book.module.

References _book_node_is_removable(), and _book_outline_access().

_book_parent_depth_limit ( $book_link )

Finds the depth limit for items in the parent select.

Parameters
$book_link A fully loaded menu link that is part of the book hierarchy.
Returns
The depth limit for items in the parent select.

Definition at line 1026 of file book.module.

References menu_link_children_relative_depth(), and MENU_MAX_DEPTH.

Referenced by book_node_prepare(), and book_outline_form().

_book_parent_select ( $book_link )

Builds the parent selection form element for the node form or outline tab.

This function is also called when generating a new set of options during the Ajax callback, so an array is returned that can be used to replace an existing form element.

Parameters
$book_link A fully loaded menu link that is part of the book hierarchy.
Returns
A parent selection form element.

Definition at line 473 of file book.module.

References book_toc(), MENU_MAX_DEPTH, t(), and variable_get().

Referenced by _book_add_form_elements().

_book_toc_recurse | ( |  | $tree,
 |  |  | $indent,
 |  | & | $toc,
 |  |  | $exclude,
 |  |  | $depth_limit
 | ) |  |

Recursively processes and formats menu items for book_toc().

This helper function recursively modifies the table of contents array for each item in the menu tree, ignoring items in the exclude array or at a depth greater than the limit. Truncates titles over thirty characters and appends an indentation string incremented by depth.

Parameters
$tree | The data structure of the book's menu tree. Includes hidden links.
$indent | A string appended to each menu item title. Increments by '–' per depth level.
$toc | Reference to the table of contents array. This is modified in place, so the function does not have a return value.
$exclude | (optional) An array of menu link ID values. Any link whose menu link ID is in this array will be excluded (along with its children). Defaults to an empty array.
$depth_limit | Any link deeper than this value will be excluded (along with its children).

Definition at line 1165 of file book.module.

References $tree, and truncate_utf8().

Referenced by book_toc().

_book_update_outline ( $node )

Handles additions and updates to the book outline.

This common helper function performs all additions and updates to the book outline through node addition, node editing, node deletion, or the outline tab.

Parameters
$node The node that is being saved, added, deleted, or moved.
Returns
TRUE if the menu link was saved; FALSE otherwise.

Definition at line 626 of file book.module.

References book_menu_name(), book_update_bid(), db_insert(), db_query(), drupal_static_reset(), and menu_link_save().

Referenced by book_node_delete(), book_node_insert(), book_node_update(), and book_outline_form_submit().

book_admin_paths ( )

Implements hook_admin_paths().

Definition at line 235 of file book.module.

References variable_get().

book_block_configure ( $delta = '' )

Implements hook_block_configure().

Definition at line 329 of file book.module.

References t(), and variable_get().

book_block_info ( )

Implements hook_block_info().

Definition at line 261 of file book.module.

References DRUPAL_CACHE_PER_PAGE, DRUPAL_CACHE_PER_ROLE, and t().

book_block_save | ( | $delta = '',
 |  | $edit = array()
 | ) |

Implements hook_block_save().

Definition at line 349 of file book.module.

References variable_set().

book_block_view ( $delta = '' )

Implements hook_block_view().

Displays the book table of contents in a block when the current page is a single-node view of a book node.

Definition at line 275 of file book.module.

References $title, $tree, book_get_books(), db_select(), menu_get_object(), menu_tree_all_data(), menu_tree_output(), node_access(), node_load(), t(), theme(), and variable_get().

book_children ( $book_link )

Formats the menu links for the child pages of the current page.

Parameters
$book_link A fully loaded menu link that is part of the book hierarchy.
Returns
HTML for the links to the child pages of the current page.

Definition at line 829 of file book.module.

References $children, book_get_flat_menu(), drupal_render(), and menu_tree_output().

Referenced by template_preprocess_book_navigation().

book_entity_info_alter ( & $info )

Implements hook_entity_info_alter().

Definition at line 248 of file book.module.

References $info, and t().

book_export_traverse | ( | $tree,
 |  | $visit_func
 | ) |

Traverses the book tree to build printable or exportable output.

During the traversal, the $visit_func() callback is applied to each node and is called recursively for each child of the node (in weight, title order).

Parameters
$tree | A subtree of the book menu hierarchy, rooted at the current page.
$visit_func | A function callback to be called upon visiting a node in the tree.
Returns
The output generated in visiting each node.

Definition at line 1240 of file book.module.

References $children, $output, $tree, book_node_export(), and node_load().

Referenced by book_export_html().

book_form_node_delete_confirm_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter() for node_delete_confirm().

Alters the confirm form for a single node deletion.

See Also
node_delete_confirm()

Definition at line 1037 of file book.module.

References node_load(), and t().

book_form_node_form_alter | ( | & | $form,
 |  | & | $form_state,
 |  |  | $form_id
 | ) |  |

Implements hook_form_BASE_FORM_ID_alter() for node_form().

Adds the book fieldset to the node form.

See Also
book_pick_book_nojs_submit()

Definition at line 419 of file book.module.

References _book_add_form_elements(), book_type_is_allowed(), t(), and user_access().

book_form_update | ( | $form,
 |  | $form_state
 | ) |

Renders a new parent page select element when the book selection changes.

This function is called via Ajax when the selected book is changed on a node or book outline form.

Returns
The rendered parent page select element.

Definition at line 609 of file book.module.

book_get_books ( )

Returns an array of all books.

This list may be used for generating a list of all the books, or for building the options for a form select.

Returns
An array of all books.

Definition at line 380 of file book.module.

References db_query(), db_select(), and drupal_static().

Referenced by _book_add_form_elements(), book_admin_overview(), book_block_view(), and book_render().

book_get_flat_menu ( $book_link )

Gets the book menu tree for a page and returns it as a linear array.

Parameters
$book_link A fully loaded menu link that is part of the book hierarchy.
Returns
A linear array of menu links in the order that the links are shown in the menu, so the previous and next pages are the elements before and after the element corresponding to the current node. The children of the current node (if any) will come immediately after it in the array, and links will only be fetched as deep as one level deeper than $book_link.

Definition at line 721 of file book.module.

References $tree, _book_flatten_menu(), drupal_static(), and menu_tree_all_data().

Referenced by book_children(), book_next(), and book_prev().

book_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file book.module.

References $output, t(), and url().

book_link_load ( $mlid )

Gets a book menu link by its menu link ID.

Like menu_link_load(), but adds additional data from the {book} table.

Do not call when loading a node, since this function may call node_load().

Parameters
$mlid The menu link ID of the menu item.
Returns
A menu link, with the link translated for rendering and data added from the {book} table. FALSE if there is an error.

Definition at line 1356 of file book.module.

References _menu_link_translate(), and db_query().

Referenced by book_node_prepare(), and template_preprocess_book_navigation().

book_menu ( )

Implements hook_menu().

Definition at line 130 of file book.module.

References MENU_CALLBACK, MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_TASK, and MENU_SUGGESTED_ITEM.

book_menu_name ( $bid )

Generates the corresponding menu name from a book ID.

Parameters
$bid The book ID for which to make a menu name.
Returns
The menu name.

Definition at line 864 of file book.module.

Referenced by _book_update_outline(), book_node_insert(), book_node_update(), book_outline_form_submit(), and book_toc().

book_menu_subtree_data ( $link )

Gets the data representing a subtree of the book hierarchy.

The root of the subtree will be the link passed as a parameter, so the returned tree will contain this item and all its descendents in the menu tree.

Parameters
$link A fully loaded menu link.
Returns
A subtree of menu links in an array, in the order they should be rendered.

Definition at line 1380 of file book.module.

References $links, $tree, cache_get(), cache_set(), db_select(), drupal_static(), MENU_MAX_DEPTH, menu_tree_check_access(), menu_tree_collect_node_links(), and menu_tree_data().

Referenced by _book_admin_table(), book_export_html(), and book_prev().

book_next ( $book_link )

Fetches the menu link for the next page of the book.

Parameters
$book_link A fully loaded menu link that is part of the book hierarchy.
Returns
A fully loaded menu link for the page after the one represented in $book_link.

Definition at line 807 of file book.module.

References book_get_flat_menu().

Referenced by template_preprocess_book_navigation().

book_node_delete ( $node )

Implements hook_node_delete().

Definition at line 964 of file book.module.

References _book_update_outline(), db_delete(), db_query(), drupal_static_reset(), menu_link_delete(), and node_load().

book_node_export | ( | $node,
 |  | $children = ''
 | ) |

Generates printer-friendly HTML for a node.

Parameters
$node | The node that will be output.
$children | (optional) All the rendered child nodes within the current node. Defaults to an empty string.
Returns
The HTML generated for the given node.
See Also
book_export_traverse()

Definition at line 1279 of file book.module.

References $children, drupal_render(), node_view(), and theme().

Referenced by book_export_traverse().

book_node_insert ( $node )

Implements hook_node_insert().

Definition at line 934 of file book.module.

References _book_update_outline(), and book_menu_name().

book_node_load | ( | $nodes,
 |  | $types
 | ) |

Implements hook_node_load().

Definition at line 871 of file book.module.

References db_query().

book_node_prepare ( $node )

Implements hook_node_prepare().

Definition at line 988 of file book.module.

References _book_link_defaults(), _book_parent_depth_limit(), book_link_load(), and user_access().

book_node_presave ( $node )

Implements hook_node_presave().

Definition at line 916 of file book.module.

References user_access().

book_node_type_update ( $type )

Implements hook_node_type_update().

Updates the Book module's persistent variables if the machine-readable name of a node type is changed.

Definition at line 1323 of file book.module.

References variable_get(), and variable_set().

book_node_update ( $node )

Implements hook_node_update().

Definition at line 949 of file book.module.

References _book_update_outline(), and book_menu_name().

book_node_view | ( | $node,
 |  | $view_mode
 | ) |

Implements hook_node_view().

Definition at line 884 of file book.module.

References book_node_view_link(), and theme().

book_node_view_link | ( | $node,
 |  | $view_mode
 | ) |

Adds relevant book links to the node's links.

Parameters
$node | The book page node to add links to.
$view_mode | The view mode of the node.

Definition at line 94 of file book.module.

References $links, MENU_MAX_DEPTH, node_access(), node_is_page(), t(), user_access(), and variable_get().

Referenced by book_node_view().

book_page_alter ( & $page )

Implements hook_page_alter().

Adds the book menu to the list of menus used to build the active trail when viewing a book page.

Definition at line 905 of file book.module.

References menu_get_active_menu_names(), menu_get_object(), and menu_set_active_menu_names().

book_permission ( )

Implements hook_permission().

Definition at line 68 of file book.module.

References t().

book_pick_book_nojs_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for node_form().

This handler is run when JavaScript is disabled. It triggers the form to rebuild so that the "Parent item" options are changed to reflect the newly selected book. When JavaScript is enabled, the submit button that triggers this handler is hidden, and the "Book" dropdown directly triggers the book_form_update() Ajax callback instead.

See Also
book_form_update()
book_form_node_form_alter()

Definition at line 455 of file book.module.

book_prev ( $book_link )

Fetches the menu link for the previous page of the book.

Parameters
$book_link A fully loaded menu link that is part of the book hierarchy.
Returns
A fully loaded menu link for the page before the one represented in $book_link.

Definition at line 765 of file book.module.

References $tree, book_get_flat_menu(), and book_menu_subtree_data().

Referenced by template_preprocess_book_navigation().

book_theme ( )

Implements hook_theme().

Definition at line 38 of file book.module.

book_toc | ( | $bid,
 |  | $depth_limit,
 |  | $exclude = array()
 | ) |

Returns an array of book pages in table of contents order.

Parameters
$bid | The ID of the book whose pages are to be listed.
$depth_limit | Any link deeper than this value will be excluded (along with its children).
$exclude | Optional array of menu link ID values. Any link whose menu link ID is in this array will be excluded (along with its children).
Returns
An array of (menu link ID, title) pairs for use as options for selecting a book page.

Definition at line 1196 of file book.module.

References $tree, _book_toc_recurse(), book_menu_name(), and menu_tree_all_data().

Referenced by _book_parent_select().

book_type_is_allowed ( $type )

Determine if a given node type is in the list of types allowed for books.

Parameters
$type A node type.
Returns
A Boolean TRUE if the node type can be included in books; otherwise, FALSE.

Definition at line 1313 of file book.module.

References variable_get().

Referenced by book_form_node_form_alter().

book_update_bid ( $book_link )

Updates the book ID of a page and its children when it moves to a new book.

Parameters
$book_link A fully loaded menu link that is part of the book hierarchy.

Definition at line 692 of file book.module.

References db_select(), db_update(), and MENU_MAX_DEPTH.

Referenced by _book_update_outline().

template_preprocess_book_all_books_block ( & $variables )

Processes variables for book-all-books-block.tpl.php.

All non-renderable elements are removed so that the template has full access to the structured data but can also simply iterate over all elements and render them (as in the default template).

Parameters
$variables An associative array containing the following key:
  • book_menus
See Also
book-all-books-block.tpl.php

Definition at line 1074 of file book.module.

References element_children().

template_preprocess_book_export_html ( & $variables )

Processes variables for book-export-html.tpl.php.

Parameters
$variables An associative array containing the following keys:
  • title
  • contents
  • depth
See Also
book-export-html.tpl.php

Definition at line 1215 of file book.module.

References $base_url, check_plain(), drupal_get_html_head(), and LANGUAGE_RTL.

template_preprocess_book_navigation ( & $variables )

Processes variables for book-navigation.tpl.php.

Parameters
$variables An associative array containing the following key:
  • book_link
See Also
book-navigation.tpl.php

Definition at line 1092 of file book.module.

References $links, book_children(), book_link_load(), book_next(), book_prev(), check_plain(), drupal_add_html_head_link(), and url().

template_preprocess_book_node_export_html ( & $variables )

Processes variables for book-node-export-html.tpl.php.

Parameters
$variables An associative array containing the following keys:
  • node
  • children
See Also
book-node-export-html.tpl.php

Definition at line 1298 of file book.module.

References check_plain(), and title.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book.pages.inc File Reference

  • modules
  • book
Functions
book.pages.inc File Reference

Go to the source code of this file.

Functions

book_render ()
book_export ($type, $nid)
book_export_html ($nid)
book_outline ($node)
book_outline_form ($form, &$form_state, $node)
book_remove_button_submit ($form, &$form_state)
book_outline_form_submit ($form, &$form_state)
book_remove_form ($form, &$form_state, $node)
book_remove_form_submit ($form, &$form_state)

Detailed Description

User page callbacks for the book module.

Definition in file book.pages.inc.

Function Documentation

book_export | ( | $type,
 |  | $nid
 | ) |

Menu callback; Generates representations of a book page and its children.

The function delegates the generation of output to helper functions. The function name is derived by prepending 'book_export_' to the given output type. So, e.g., a type of 'html' results in a call to the function book_export_html().

Parameters
$type A string encoding the type of output requested. The following types are currently supported in book module:
  • html: Printer-friendly HTML. Other types may be supported in contributed modules.
$nid An integer representing the node id (nid) of the node to export
Returns
A string representing the node and its children in the book hierarchy in a format determined by the $type parameter.
See Also
book_menu()

Definition at line 47 of file book.pages.inc.

References drupal_not_found(), drupal_set_message(), drupal_strtolower(), MENU_ACCESS_DENIED, MENU_NOT_FOUND, node_access(), node_load(), print, and t().

book_export_html ( $nid )

Generates HTML for export when invoked by book_export().

The given node is embedded to its absolute depth in a top level section. For example, a child node with depth 2 in the hierarchy is contained in (otherwise empty)

elements corresponding to depth 0 and depth 1. This is intended to support WYSIWYG output - e.g., level 3 sections always look like level 3 sections, no matter their depth relative to the node selected to be exported as printer-friendly HTML.
Parameters
$nid An integer representing the node id (nid) of the node to export.
Returns
A string containing HTML representing the node and its children in the book hierarchy.

Definition at line 87 of file book.pages.inc.

References $contents, $tree, book_export_traverse(), book_menu_subtree_data(), drupal_access_denied(), drupal_not_found(), node_load(), theme(), and user_access().

book_outline ( $node )

Menu callback: Shows the outline form for a single node.

Parameters
$node The book node for which to show the outline.
Returns
string A HTML-formatted string with the outline form for a single node.
See Also
book_menu()

Definition at line 115 of file book.pages.inc.

References drupal_get_form(), and drupal_set_title().

book_outline_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for book_outline_form().

See Also
book_remove_button_submit()

Definition at line 184 of file book.pages.inc.

References _book_update_outline(), book_menu_name(), drupal_set_message(), and t().

book_remove_button_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for book_outline_form().

Redirects to removal confirmation form.

See Also
book_outline_form_submit()

Definition at line 175 of file book.pages.inc.

book_remove_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for book_remove_form().

Definition at line 237 of file book.pages.inc.

References _book_node_is_removable(), db_delete(), drupal_set_message(), menu_link_delete(), and t().

book_render ( )

Menu callback: Prints a listing of all books.

Returns
string A HTML-formatted string with the listing of all books content.
See Also
book_menu()

Definition at line 16 of file book.pages.inc.

References book_get_books(), l(), and theme().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/color Directory Reference

  • modules
  • color
color Directory Reference

Files

file | color.install [code]
file | color.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/color/color.install File Reference

  • modules
  • color
Functions
color.install File Reference

Go to the source code of this file.

Functions

color_requirements ($phase)
color_update_7001 ()

Detailed Description

Install, update and uninstall functions for the color module.

Definition in file color.install.

Function Documentation

color_requirements ( $phase )

Implements hook_requirements().

Definition at line 11 of file color.install.

References $info, REQUIREMENT_ERROR, REQUIREMENT_OK, REQUIREMENT_WARNING, and t().

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/color/color.module File Reference

  • modules
  • color
Functions
color.module File Reference

Go to the source code of this file.

Functions

color_help ($path, $arg)
color_theme ()
color_form_system_theme_settings_alter (&$form, &$form_state)
color_form_system_themes_alter (&$form, &$form_state)
_color_theme_select_form_alter (&$form, &$form_state)
_color_html_alter (&$vars)
_color_page_alter (&$vars)
color_get_info ($theme)
color_get_palette ($theme, $default=FALSE)
color_scheme_form ($complete_form, &$form_state, $theme)
theme_color_scheme_form ($variables)
color_palette_color_value ($element, $input=FALSE, $form_state=array())
color_valid_hexadecimal_string ($color)
color_scheme_form_validate ($form, &$form_state)
color_scheme_form_submit ($form, &$form_state)
_color_rewrite_stylesheet ($theme, &$info, &$paths, $palette, $style)
_color_save_stylesheet ($file, $style, &$paths)
_color_render_images ($theme, &$info, &$paths, $palette)
_color_shift ($given, $ref1, $ref2, $target)
_color_gd ($img, $hex)
_color_blend ($img, $hex1, $hex2, $alpha)
_color_unpack ($hex, $normalize=FALSE)
_color_pack ($rgb, $normalize=FALSE)
_color_hsl2rgb ($hsl)
_color_hue2rgb ($m1, $m2, $h)
_color_rgb2hsl ($rgb)

Detailed Description

Allows users to change the color scheme of themes.

Definition in file color.module.

Function Documentation

_color_blend | ( | $img,
 |  | $hex1,
 |  | $hex2,
 |  | $alpha
 | ) |

Blends two hex colors and returns the GD color.

Definition at line 722 of file color.module.

References _color_unpack().

Referenced by _color_render_images().

_color_gd | ( | $img,
 |  | $hex
 | ) |

Converts a hex triplet into a GD color.

Definition at line 714 of file color.module.

References _color_unpack().

Referenced by _color_render_images().

_color_hsl2rgb ( $hsl )

Converts an HSL triplet into RGB.

Definition at line 763 of file color.module.

References _color_hue2rgb().

Referenced by _color_shift().

_color_html_alter ( & $vars )

Replaces style sheets with color-altered style sheets.

A theme that supports the color module should call this function from its THEME_process_html() function, so that the correct style sheets are included when html.tpl.php is rendered.

See Also
theme()

Definition at line 85 of file color.module.

References drupal_basename(), drupal_get_css(), list_themes(), and variable_get().

Referenced by bartik_process_html(), and garland_process_html().

_color_hue2rgb | ( | $m1,
 |  | $m2,
 |  | $h
 | ) |

Helper function for _color_hsl2rgb().

Definition at line 780 of file color.module.

Referenced by _color_hsl2rgb().

_color_pack | ( | $rgb,
 |  | $normalize = FALSE
 | ) |

Converts an RGB triplet to a hex color.

Definition at line 751 of file color.module.

Referenced by _color_shift().

_color_page_alter ( & $vars )

Replaces the logo with a color-altered logo.

A theme that supports the color module should call this function from its THEME_process_page() function, so that the correct logo is included when page.tpl.php is rendered.

See Also
theme()

Definition at line 120 of file color.module.

References $logo, file_create_url(), and variable_get().

Referenced by bartik_process_page(), and garland_process_page().

_color_render_images | ( |  | $theme,
 |  | & | $info,
 |  | & | $paths,
 |  |  | $palette
 | ) |  |

Renders images that match a given palette.

Definition at line 578 of file color.module.

References $info, _color_blend(), _color_gd(), drupal_basename(), drupal_chmod(), drupal_realpath(), and variable_set().

Referenced by color_scheme_form_submit().

_color_rewrite_stylesheet | ( |  | $theme,
 |  | & | $info,
 |  | & | $paths,
 |  |  | $palette,
 |  |  | $style
 | ) |  |

Rewrites the stylesheet to match the colors in the palette.

Definition at line 496 of file color.module.

References $info, $output, _color_shift(), base_path(), color_get_palette(), drupal_strtolower(), and list_themes().

Referenced by color_scheme_form_submit().

_color_rgb2hsl ( $rgb )

Converts an RGB triplet to HSL.

Definition at line 792 of file color.module.

Referenced by _color_shift().

_color_save_stylesheet | ( |  | $file,
 |  |  | $style,
 |  | & | $paths
 | ) |  |

Saves the rewritten stylesheet to disk.

Definition at line 567 of file color.module.

References drupal_chmod(), FILE_EXISTS_REPLACE, and file_unmanaged_save_data().

Referenced by color_scheme_form_submit().

_color_shift | ( | $given,
 |  | $ref1,
 |  | $ref2,
 |  | $target
 | ) |

Shifts a given color, using a reference pair and a target blend color.

Note: this function is significantly different from the JS version, as it is written to match the blended images perfectly.

Constraint: if (ref2 == target + (ref1 - target) * delta) for some fraction delta then (return == target + (given - target) * delta).

Loose constraint: Preserve relative positions in saturation and luminance space.

Definition at line 664 of file color.module.

References _color_hsl2rgb(), _color_pack(), _color_rgb2hsl(), and _color_unpack().

Referenced by _color_rewrite_stylesheet().

_color_theme_select_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Helper for hook_form_FORM_ID_alter() implementations.

Definition at line 64 of file color.module.

References element_children(), list_themes(), theme(), and variable_get().

Referenced by color_form_system_themes_alter().

_color_unpack | ( | $hex,
 |  | $normalize = FALSE
 | ) |

Converts a hex color into an RGB triplet.

Definition at line 736 of file color.module.

Referenced by _color_blend(), _color_gd(), and _color_shift().

color_form_system_theme_settings_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 39 of file color.module.

References color_get_info(), color_scheme_form(), and t().

color_form_system_themes_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 57 of file color.module.

References _color_theme_select_form_alter().

color_get_info ( $theme )

Retrieves the Color module information for a particular theme.

Definition at line 133 of file color.module.

References $info, drupal_get_path(), and DRUPAL_ROOT.

Referenced by color_form_system_theme_settings_alter(), color_get_palette(), and color_scheme_form().

color_get_palette | ( | $theme,
 |  | $default = FALSE
 | ) |

Retrieves the color palette for a particular theme.

Definition at line 152 of file color.module.

References $info, color_get_info(), and variable_get().

Referenced by _color_rewrite_stylesheet(), color_scheme_form(), and color_scheme_form_submit().

color_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 10 of file color.module.

References $output, t(), and url().

color_palette_color_value | ( | $element,
 |  | $input = FALSE,
 |  | $form_state = array()
 | ) |

Determines the value for a palette color field.

Parameters
$element | The form element whose value is being populated.
$input | The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
$form_state | A keyed array containing the current state of the form.
Returns
The data that will appear in the $form_state['values'] collection for this element. Return nothing to use the default.

Definition at line 313 of file color.module.

References $value, color_valid_hexadecimal_string(), drupal_valid_token(), and form_type_textfield_value().

color_scheme_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for color_scheme_form().

See Also
color_scheme_form_validate()

Definition at line 363 of file color.module.

References $info, _color_render_images(), _color_rewrite_stylesheet(), _color_save_stylesheet(), _drupal_build_css_path(), base_path(), color_get_palette(), drupal_basename(), drupal_check_memory_limit(), drupal_get_path(), drupal_load_stylesheet(), drupal_rmdir(), drupal_set_message(), drupal_unlink(), FILE_CREATE_DIRECTORY, file_prepare_directory(), file_unmanaged_copy(), format_size(), parse_size(), t(), variable_del(), variable_get(), and variable_set().

color_scheme_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for color_scheme_form().

See Also
color_scheme_form_submit()

Definition at line 349 of file color.module.

References color_valid_hexadecimal_string(), form_set_error(), and t().

color_theme ( )

Implements hook_theme().

Definition at line 28 of file color.module.

color_valid_hexadecimal_string ( $color )

Determines if a hexadecimal CSS color string is valid.

Parameters
$color The string to check.
Returns
TRUE if the string is a valid hexadecimal CSS color string, or FALSE if it isn't.

Definition at line 340 of file color.module.

Referenced by color_palette_color_value(), and color_scheme_form_validate().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment Directory Reference

  • modules
  • comment
comment Directory Reference

Files

file | comment-wrapper.tpl.php [code]
file | comment.admin.inc [code]
file | comment.api.php [code]
file | comment.install [code]
file | comment.module [code]
file | comment.pages.inc [code]
file | comment.tokens.inc [code]
file | comment.tpl.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment.admin.inc File Reference

  • modules
  • comment
Functions
comment.admin.inc File Reference

Go to the source code of this file.

Functions

comment_admin ($type= 'new')
comment_admin_overview ($form, &$form_state, $arg)
comment_admin_overview_validate ($form, &$form_state)
comment_admin_overview_submit ($form, &$form_state)
comment_multiple_delete_confirm ($form, &$form_state)
comment_multiple_delete_confirm_submit ($form, &$form_state)
comment_confirm_delete_page ($cid)
comment_confirm_delete ($form, &$form_state, $comment)
comment_confirm_delete_submit ($form, &$form_state)

Detailed Description

Admin page callbacks for the comment module.

Definition in file comment.admin.inc.

Function Documentation

comment_admin ( $type = 'new' )

Menu callback; present an administrative comment listing.

Definition at line 11 of file comment.admin.inc.

References drupal_get_form().

comment_admin_overview_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process comment_admin_overview form submissions.

Execute the chosen 'Update option' on the selected comments, such as publishing, unpublishing or deleting.

Definition at line 160 of file comment.admin.inc.

References $value, cache_clear_all(), comment_delete_multiple(), comment_load(), COMMENT_NOT_PUBLISHED, COMMENT_PUBLISHED, comment_save(), drupal_set_message(), and t().

comment_admin_overview_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate comment_admin_overview form submissions.

Definition at line 146 of file comment.admin.inc.

References form_set_error(), and t().

comment_confirm_delete_page ( $cid )

Page callback for comment deletions.

Definition at line 244 of file comment.admin.inc.

References comment_load(), drupal_get_form(), and MENU_NOT_FOUND.

comment_confirm_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process comment_confirm_delete form submissions.

Definition at line 274 of file comment.admin.inc.

References cache_clear_all(), comment_delete(), drupal_set_message(), t(), and watchdog().

comment_multiple_delete_confirm_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process comment_multiple_delete_confirm form submissions.

Definition at line 230 of file comment.admin.inc.

References cache_clear_all(), comment_delete_multiple(), drupal_set_message(), format_plural(), and watchdog().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment.api.php File Reference

  • modules
  • comment
Functions
comment.api.php File Reference

Go to the source code of this file.

Functions

hook_comment_presave ($comment)
hook_comment_insert ($comment)
hook_comment_update ($comment)
hook_comment_load ($comments)
hook_comment_view ($comment, $view_mode, $langcode)
hook_comment_view_alter (&$build)
hook_comment_publish ($comment)
hook_comment_unpublish ($comment)
hook_comment_delete ($comment)

Detailed Description

Hooks provided by the Comment module.

Definition in file comment.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment.install File Reference

  • modules
  • comment
Functions
comment.install File Reference

Go to the source code of this file.

Functions

comment_uninstall ()
comment_enable ()
comment_modules_enabled ($modules)
comment_update_dependencies ()
comment_update_7000 ()
comment_update_7001 ()
comment_update_7002 ()
comment_update_7003 ()
comment_update_7004 ()
comment_update_7005 ()
comment_update_7006 (&$sandbox)
comment_update_7007 ()
comment_update_7008 ()
comment_update_7009 ()
comment_schema ()

Detailed Description

Install, update and uninstall functions for the comment module.

Definition in file comment.install.

Function Documentation

comment_enable ( )

Implements hook_enable().

Definition at line 35 of file comment.install.

References db_insert(), and db_select().

comment_modules_enabled ( $modules )

Implements hook_modules_enabled().

Creates comment body fields for node types existing before the comment module is enabled. We use hook_modules_enabled() rather than hook_enable() so we can react to node types of existing modules, and those of modules being enabled both before and after comment module in the loop of module_enable().

There is a separate comment bundle for each node type to allow for per-node-type customization of comment fields. Each one of these bundles needs a comment body field instance. A comment bundle is needed even for node types whose comments are disabled by default, because individual nodes may override that default.

See Also
comment_node_type_insert()

Definition at line 67 of file comment.install.

References $info, _comment_body_field_create(), node_type_get_types(), and node_types_rebuild().

comment_schema ( )

End of "addtogroup updates-7.x-extra". Implements hook_schema().

Definition at line 402 of file comment.install.

comment_uninstall ( )

Implements hook_uninstall().

Definition at line 11 of file comment.install.

References field_attach_delete_bundle(), field_delete_field(), node_type_get_types(), and variable_del().

comment_update_dependencies ( )

Implements hook_update_dependencies().

Definition at line 85 of file comment.install.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment.module File Reference

  • modules
  • comment
Classes | Functions | Variables
comment.module File Reference

Go to the source code of this file.

Classes

class CommentController

Functions

comment_help ($path, $arg)
comment_entity_info ()
comment_node_type_load ($name)
comment_uri ($comment)
comment_field_extra_fields ()
comment_theme ()
comment_menu ()
comment_menu_alter (&$items)
comment_count_unpublished ()
comment_node_type_insert ($info)
comment_node_type_update ($info)
comment_node_type_delete ($info)
_comment_body_field_create ($info)
comment_permission ()
comment_block_info ()
comment_block_configure ($delta= '')
comment_block_save ($delta= '', $edit=array())
comment_block_view ($delta= '')
comment_permalink ($cid)
comment_get_recent ($number=10)
comment_new_page_count ($num_comments, $new_replies, $node)
theme_comment_block ()
comment_node_view ($node, $view_mode)
comment_node_page_additions ($node)
comment_get_thread ($node, $mode, $comments_per_page)
comment_prepare_thread (&$comments)
comment_view ($comment, $node, $view_mode= 'full', $langcode=NULL)
comment_build_content ($comment, $node, $view_mode= 'full', $langcode=NULL)
comment_links ($comment, $node)
comment_view_multiple ($comments, $node, $view_mode= 'full', $weight=0, $langcode=NULL)
comment_form_node_type_form_alter (&$form, $form_state)
comment_form_node_form_alter (&$form, $form_state)
comment_node_load ($nodes, $types)
comment_node_prepare ($node)
comment_node_insert ($node)
comment_node_delete ($node)
comment_node_update_index ($node)
comment_update_index ()
comment_node_search_result ($node)
comment_user_cancel ($edit, $account, $method)
comment_user_delete ($account)
comment_access ($op, $comment)
comment_save ($comment)
comment_delete ($cid)
comment_delete_multiple ($cids)
comment_load_multiple ($cids=array(), $conditions=array(), $reset=FALSE)
comment_load ($cid, $reset=FALSE)
comment_num_new ($nid, $timestamp=0)
comment_get_display_ordinal ($cid, $node_type)
comment_get_display_page ($cid, $node_type)
comment_edit_page ($comment)
comment_forms ()
comment_form ($form, &$form_state, $comment)
comment_form_build_preview ($form, &$form_state)
comment_preview ($comment)
comment_form_validate ($form, &$form_state)
comment_submit ($comment)
comment_form_submit_build_comment ($form, &$form_state)
comment_form_submit ($form, &$form_state)
template_preprocess_comment (&$variables)
theme_comment_post_forbidden ($variables)
template_preprocess_comment_wrapper (&$variables)
_comment_get_modes ()
_comment_per_page ()
_comment_update_node_statistics ($nid)
int2vancode ($i=0)
vancode2int ($c= '00')
comment_action_info ()
comment_publish_action ($comment, $context=array())
comment_unpublish_action ($comment, $context=array())
comment_unpublish_by_keyword_action ($comment, $context)
comment_unpublish_by_keyword_action_form ($context)
comment_unpublish_by_keyword_action_submit ($form, $form_state)
comment_save_action ($comment)
comment_ranking ()
comment_rdf_mapping ()
comment_file_download_access ($field, $entity_type, $entity)

Variables

const | COMMENT_NOT_PUBLISHED 0
const | COMMENT_PUBLISHED 1
const | COMMENT_MODE_FLAT 0
const | COMMENT_MODE_THREADED 1
const | COMMENT_ANONYMOUS_MAYNOT_CONTACT 0
const | COMMENT_ANONYMOUS_MAY_CONTACT 1
const | COMMENT_ANONYMOUS_MUST_CONTACT 2
const | COMMENT_FORM_SEPARATE_PAGE 0
const | COMMENT_FORM_BELOW 1
const | COMMENT_NODE_HIDDEN 0
const | COMMENT_NODE_CLOSED 1
const | COMMENT_NODE_OPEN 2

Detailed Description

Enables users to comment on published content.

When enabled, the Drupal comment module creates a discussion board for each Drupal node. Users can post comments to discuss a forum topic, weblog post, story, collaborative book page, etc.

Definition in file comment.module.

Function Documentation

_comment_body_field_create ( $info )

Creates a comment_body field instance for a given node type.

Definition at line 362 of file comment.module.

References $info, field_attach_create_bundle(), field_create_field(), field_create_instance(), field_read_field(), and field_read_instance().

Referenced by comment_modules_enabled(), and comment_node_type_insert().

_comment_get_modes ( )

Return an array of viewing modes for comment listings.

We can't use a global variable array because the locale system is not initialized yet when the comment module is loaded.

Definition at line 2417 of file comment.module.

References COMMENT_MODE_FLAT, COMMENT_MODE_THREADED, and t().

_comment_per_page ( )

Return an array of "comments per page" settings from which the user can choose.

Definition at line 2428 of file comment.module.

References drupal_map_assoc().

Referenced by comment_form_node_type_form_alter().

_comment_update_node_statistics ( $nid )

Updates the comment statistics for a given node. This should be called any time a comment is added, deleted, or updated.

The following fields are contained in the node_comment_statistics table.

  • last_comment_timestamp: the timestamp of the last comment for this node or the node create stamp if no comments exist for the node.
  • last_comment_name: the name of the anonymous poster for the last comment
  • last_comment_uid: the uid of the poster for the last comment for this node or the node authors uid if no comments exists for the node.
  • comment_count: the total number of approved/published comments on this node.

Definition at line 2442 of file comment.module.

References COMMENT_PUBLISHED, db_query(), db_query_range(), db_update(), and variable_get().

Referenced by comment_delete_multiple(), and comment_save().

comment_access | ( | $op,
 |  | $comment
 | ) |

Determines whether the current user has access to a particular comment.

Authenticated users can edit their comments as long they have not been replied to. This prevents people from changing or revising their statements based on the replies to their posts.

Parameters
$op | The operation that is to be performed on the comment. Only 'edit' is recognized now.
$comment | The comment object.
Returns
TRUE if the current user has acces to the comment, FALSE otherwise.

Definition at line 1439 of file comment.module.

References $op, COMMENT_PUBLISHED, and user_access().

Referenced by comment_links().

comment_action_info ( )

Implements hook_action_info().

Definition at line 2517 of file comment.module.

References t().

comment_block_configure ( $delta = '' )

Implements hook_block_configure().

Definition at line 431 of file comment.module.

References drupal_map_assoc(), t(), and variable_get().

comment_block_info ( )

Implements hook_block_info().

Definition at line 421 of file comment.module.

References t().

comment_block_save | ( | $delta = '',
 |  | $edit = array()
 | ) |

Implements hook_block_save().

Definition at line 445 of file comment.module.

References variable_set().

comment_block_view ( $delta = '' )

Implements hook_block_view().

Generates a block with the most recent comments.

Definition at line 454 of file comment.module.

References t(), theme(), and user_access().

comment_build_content | ( | $comment,
 |  | $node,
 |  | $view_mode = 'full',
 |  | $langcode = NULL
 | ) |

Builds a structured array representing the comment's content.

The content built for the comment (field values, comments, file attachments or other comment components) will vary depending on the $view_mode parameter.

Parameters
$comment | A comment object.
$node | The node the comment is attached to.
$view_mode | View mode, e.g. 'full', 'teaser'...
$langcode | (optional) A language code to use for rendering. Defaults to the global content language of the current request.

Definition at line 987 of file comment.module.

References comment_links(), drupal_alter(), entity_prepare_view(), field_attach_prepare_view(), field_attach_view(), and module_invoke_all().

Referenced by comment_view().

comment_count_unpublished ( )

Returns a menu title which includes the number of unapproved comments.

Definition at line 311 of file comment.module.

References COMMENT_NOT_PUBLISHED, db_query(), and t().

comment_delete ( $cid )

Delete a comment and all its replies.

Parameters
$cid The comment to delete.

Definition at line 1606 of file comment.module.

References comment_delete_multiple().

Referenced by comment_confirm_delete_submit().

comment_delete_multiple ( $cids )

Delete comments and all their replies.

Parameters
$cids The comment to delete.

Definition at line 1616 of file comment.module.

References _comment_update_node_statistics(), comment_load_multiple(), db_delete(), db_query(), db_transaction(), field_attach_delete(), module_invoke_all(), and watchdog_exception().

Referenced by comment_admin_overview_submit(), comment_delete(), comment_multiple_delete_confirm_submit(), comment_node_delete(), and comment_user_delete().

comment_edit_page ( $comment )

Page callback for comment editing.

Definition at line 1816 of file comment.module.

References drupal_get_form(), drupal_set_title(), node_load(), PASS_THROUGH, and t().

comment_entity_info ( )

Implements hook_entity_info().

Definition at line 94 of file comment.module.

References $name, node_type_get_names(), and t().

comment_field_extra_fields ( )

Implements hook_field_extra_fields().

Definition at line 167 of file comment.module.

References node_type_get_types(), t(), and variable_get().

comment_file_download_access | ( | $field,
 |  | $entity_type,
 |  | $entity
 | ) |

Implements hook_file_download_access().

Definition at line 2731 of file comment.module.

References COMMENT_PUBLISHED, node_access(), node_load(), and user_access().

comment_form_build_preview | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Build a preview from submitted form values.

Definition at line 2053 of file comment.module.

References comment_form_submit_build_comment(), and comment_preview().

comment_form_node_form_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_BASE_FORM_ID_alter().

Definition at line 1205 of file comment.module.

References COMMENT_NODE_CLOSED, COMMENT_NODE_HIDDEN, COMMENT_NODE_OPEN, db_query(), drupal_get_path(), t(), and user_access().

comment_form_node_type_form_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 1128 of file comment.module.

References _comment_per_page(), COMMENT_ANONYMOUS_MAY_CONTACT, COMMENT_ANONYMOUS_MAYNOT_CONTACT, COMMENT_ANONYMOUS_MUST_CONTACT, COMMENT_FORM_BELOW, COMMENT_MODE_THREADED, COMMENT_NODE_CLOSED, COMMENT_NODE_HIDDEN, COMMENT_NODE_OPEN, drupal_anonymous_user(), DRUPAL_DISABLED, drupal_get_path(), DRUPAL_OPTIONAL, DRUPAL_REQUIRED, t(), user_access(), and variable_get().

comment_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process comment form submissions; prepare the comment, store it, and set a redirection target.

Definition at line 2235 of file comment.module.

References $page, cache_clear_all(), comment_form_submit_build_comment(), comment_get_display_page(), COMMENT_NODE_OPEN, COMMENT_NOT_PUBLISHED, comment_save(), drupal_set_message(), l(), node_load(), t(), user_access(), user_cookie_save(), user_is_anonymous(), watchdog(), WATCHDOG_NOTICE, and WATCHDOG_WARNING.

comment_form_submit_build_comment | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Updates the form state's comment entity by processing this submission's values.

This is the default builder function for the comment form. It is called during the "Save" and "Preview" submit handlers to retrieve the entity to save or preview. This function can also be called by a "Next" button of a wizard to update the form state's entity with the current step's values before proceeding to the next step.

See Also
comment_form()

Definition at line 2225 of file comment.module.

References comment_submit(), and entity_form_submit_build_entity().

Referenced by comment_form_build_preview(), and comment_form_submit().

comment_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate comment form submissions.

Definition at line 2120 of file comment.module.

References db_like(), db_select(), entity_form_field_validate(), form_set_error(), t(), user_load_by_name(), valid_email_address(), and valid_url().

comment_forms ( )

Implements hook_forms().

Definition at line 1825 of file comment.module.

References node_type_get_types().

comment_get_display_ordinal | ( | $cid,
 |  | $node_type
 | ) |

Get the display ordinal for a comment, starting from 0.

Count the number of comments which appear before the comment we want to display, taking into account display settings and threading.

Parameters
$cid | The comment ID.
$node_type | The node type of the comment's parent.
Returns
The display ordinal for the comment.
See Also
comment_get_display_page()

Definition at line 1766 of file comment.module.

References COMMENT_MODE_FLAT, COMMENT_MODE_THREADED, COMMENT_PUBLISHED, db_select(), user_access(), and variable_get().

Referenced by comment_get_display_page().

comment_get_display_page | ( | $cid,
 |  | $node_type
 | ) |

Return the page number for a comment.

Finds the correct page number for a comment taking into account display and paging settings.

Parameters
$cid | The comment ID.
$node_type | The node type the comment is attached to.
Returns
The page number.

Definition at line 1807 of file comment.module.

References comment_get_display_ordinal(), and variable_get().

Referenced by comment_form_submit(), and comment_permalink().

comment_get_recent ( $number = 10 )

Find the most recent comments that are available to the current user.

Parameters
integer $number (optional) The maximum number of comments to find. Defaults to 10.
Returns
An array of comment objects or an empty array if there are no recent comments visible to the current user.

Definition at line 506 of file comment.module.

References COMMENT_PUBLISHED, db_select(), and NODE_PUBLISHED.

Referenced by theme_comment_block().

comment_get_thread | ( | $node,
 |  | $mode,
 |  | $comments_per_page
 | ) |

Retrieve comments for a thread.

Parameters
$node | The node whose comment(s) needs rendering.
$mode | The comment display mode; COMMENT_MODE_FLAT or COMMENT_MODE_THREADED.
$comments_per_page | The amount of comments to display per page.

To display threaded comments in the correct order we keep a 'thread' field and order by that value. This field keeps this data in a way which is easy to update and convenient to use.

A "thread" value starts at "1". If we add a child (A) to this comment, we assign it a "thread" = "1.1". A child of (A) will have "1.1.1". Next brother of (A) will get "1.2". Next brother of the parent of (A) will get "2" and so on.

First of all note that the thread field stores the depth of the comment: depth 0 will be "X", depth 1 "X.X", depth 2 "X.X.X", etc.

Now to get the ordering right, consider this example:

1 1.1 1.1.1 1.2 2

If we "ORDER BY thread ASC" we get the above result, and this is the natural order sorted by time. However, if we "ORDER BY thread DESC" we get:

2 1.2 1.1.1 1.1 1

Clearly, this is not a natural way to see a thread, and users will get confused. The natural order to show a thread by time desc would be:

2 1 1.2 1.1 1.1.1

which is what we already did before the standard pager patch. To achieve this we simply add a "/" at the end of each "thread" value. This way, the thread fields will look like this:

1/ 1.1/ 1.1.1/ 1.2/ 2/

we add "/" since this char is, in ASCII, higher than every number, so if now we "ORDER BY thread DESC" we get the correct order. However this would spoil the reverse ordering, "ORDER BY thread ASC" – here, we do not need to consider the trailing "/" so we use a substring only.

Definition at line 822 of file comment.module.

References COMMENT_MODE_FLAT, COMMENT_PUBLISHED, db_select(), and user_access().

Referenced by comment_node_page_additions(), and comment_node_update_index().

comment_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 75 of file comment.module.

References $output, t(), and url().

comment_links | ( | $comment,
 |  | $node
 | ) |

Helper function, build links for an individual comment.

Adds reply, edit, delete etc. depending on the current user permissions.

Parameters
$comment | The comment object.
$node | The node the comment is attached to.
Returns
A structured array of links.

Definition at line 1042 of file comment.module.

References $links, comment_access(), COMMENT_NODE_OPEN, COMMENT_NOT_PUBLISHED, drupal_get_token(), t(), theme(), and user_access().

Referenced by comment_build_content().

comment_load | ( | $cid,
 |  | $reset = FALSE
 | ) |

Load the entire comment by cid.

Parameters
$cid | The identifying comment id.
$reset | Whether to reset the internal static entity cache. Note that the static cache is disabled in comment_entity_info() by default.
Returns
The comment object.

Definition at line 1683 of file comment.module.

References comment_load_multiple().

Referenced by comment_admin_overview_submit(), comment_approve(), comment_confirm_delete_page(), comment_multiple_delete_confirm(), comment_permalink(), comment_save(), and comment_tokens().

comment_load_multiple | ( | $cids = array(),
 |  | $conditions = array(),
 |  | $reset = FALSE
 | ) |

Load comments from the database.

Parameters
$cids | An array of comment IDs.
$conditions | (deprecated) An associative array of conditions on the {comments} table, where the keys are the database fields and the values are the values those fields must have. Instead, it is preferable to use EntityFieldQuery to retrieve a list of entity IDs loadable by this function.
$reset | Whether to reset the internal static entity cache. Note that the static cache is disabled in comment_entity_info() by default.
Returns
An array of comment objects, indexed by comment ID.
See Also
entity_load()
EntityFieldQuery

Definition at line 1667 of file comment.module.

References entity_load().

Referenced by comment_admin_overview(), comment_delete_multiple(), comment_load(), comment_node_page_additions(), comment_node_update_index(), comment_preview(), and comment_user_cancel().

comment_menu ( )

Implements hook_menu().

Definition at line 220 of file comment.module.

References MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_TASK, and MENU_NORMAL_ITEM.

comment_menu_alter ( & $items )

Implements hook_menu_alter().

Definition at line 296 of file comment.module.

comment_new_page_count | ( | $num_comments,
 |  | $new_replies,
 |  | $node
 | ) |

Calculate page number for first new comment.

Parameters
$num_comments | Number of comments.
$new_replies | Number of new replies.
$node | The first new comment node.
Returns
"page=X" if the page number is greater than zero; empty string otherwise.

Definition at line 537 of file comment.module.

References COMMENT_MODE_FLAT, COMMENT_MODE_THREADED, COMMENT_PUBLISHED, db_query(), db_select(), and variable_get().

Referenced by comment_node_view(), and template_preprocess_forum_topic_list().

comment_node_delete ( $node )

Implements hook_node_delete().

Definition at line 1321 of file comment.module.

References comment_delete_multiple(), db_delete(), and db_query().

comment_node_insert ( $node )

Implements hook_node_insert().

Definition at line 1301 of file comment.module.

References db_insert(), and variable_get().

comment_node_load | ( | $nodes,
 |  | $types
 | ) |

Implements hook_node_load().

Definition at line 1257 of file comment.module.

References COMMENT_NODE_HIDDEN, and db_query().

comment_node_page_additions ( $node )

Build the comment-related elements for node detail pages.

Parameters
$node A node object.

Definition at line 722 of file comment.module.

References COMMENT_FORM_BELOW, comment_get_thread(), comment_load_multiple(), COMMENT_MODE_THREADED, COMMENT_NODE_OPEN, comment_prepare_thread(), comment_view_multiple(), drupal_get_form(), user_access(), and variable_get().

Referenced by comment_node_view().

comment_node_prepare ( $node )

Implements hook_node_prepare().

Definition at line 1292 of file comment.module.

References COMMENT_NODE_OPEN, and variable_get().

comment_node_search_result ( $node )

Implements hook_node_search_result().

Formats a comment count string and returns it, for display with search results.

Definition at line 1381 of file comment.module.

References COMMENT_NODE_CLOSED, COMMENT_NODE_HIDDEN, db_query(), format_plural(), and user_access().

comment_node_type_delete ( $info )

Implements hook_node_type_delete().

Definition at line 343 of file comment.module.

References $info, field_attach_delete_bundle(), and variable_del().

comment_node_type_insert ( $info )

Implements hook_node_type_insert().

Creates a comment body field for a node type created while the comment module is enabled. For node types created before the comment module is enabled, hook_modules_enabled() serves to create the body fields.

See Also
comment_modules_enabled()

Definition at line 327 of file comment.module.

References $info, and _comment_body_field_create().

comment_node_type_load ( $name )

Menu loader callback for Field UI paths.

Return a comment bundle name from a node type in the URL.

Definition at line 148 of file comment.module.

References $name, and node_type_get_type().

comment_node_type_update ( $info )

Implements hook_node_type_update().

Definition at line 334 of file comment.module.

References $info, and field_attach_rename_bundle().

comment_node_update_index ( $node )

Implements hook_node_update_index().

Definition at line 1332 of file comment.module.

References comment_get_thread(), comment_load_multiple(), COMMENT_MODE_THREADED, comment_prepare_thread(), comment_view_multiple(), db_query(), DRUPAL_AUTHENTICATED_RID, drupal_render(), drupal_static(), and variable_get().

comment_node_view | ( | $node,
 |  | $view_mode
 | ) |

Implements hook_node_view().

Definition at line 615 of file comment.module.

References $links, COMMENT_FORM_BELOW, COMMENT_FORM_SEPARATE_PAGE, comment_new_page_count(), COMMENT_NODE_HIDDEN, COMMENT_NODE_OPEN, comment_node_page_additions(), comment_num_new(), format_plural(), node_is_page(), t(), theme(), url(), user_access(), and variable_get().

comment_num_new | ( | $nid,
 |  | $timestamp = 0
 | ) |

Get number of new comments for current user and specified node.

Parameters
$nid | Node-id to count comments for.
$timestamp | Time to count from (defaults to time of last user access to node).
Returns
The result or FALSE on error.

Definition at line 1729 of file comment.module.

References COMMENT_PUBLISHED, db_query(), node_last_viewed(), and NODE_NEW_LIMIT.

Referenced by comment_node_view(), comment_tokens(), forum_get_topics(), and tracker_page().

comment_permalink ( $cid )

Redirects comment links to the correct page depending on comment settings.

Since comments are paged there is no way to guarantee which page a comment appears on. Comment paging and threading settings may be changed at any time. With threaded comments, an individual comment may move between pages as comments can be added either before or after it in the overall discussion. Therefore we use a central routing function for comment links, which calculates the page number based on current comment settings and returns the full comment view with the pager set dynamically.

Parameters
$cid A comment identifier.
Returns
The comment listing set to the page on which the comment appears.

Definition at line 479 of file comment.module.

References $page, comment_get_display_page(), comment_load(), menu_execute_active_handler(), MENU_NOT_FOUND, and node_load().

comment_permission ( )

Implements hook_permission().

Definition at line 398 of file comment.module.

References t().

comment_prepare_thread ( & $comments )

Loop over comment thread, noting indentation level.

Parameters
array $comments An array of comment objects, keyed by cid.
Returns
The $comments argument is altered by reference with indentation information.

Definition at line 869 of file comment.module.

References MARK_READ.

Referenced by comment_node_page_additions(), and comment_node_update_index().

comment_preview ( $comment )

Generate a comment preview.

Definition at line 2062 of file comment.module.

References check_plain(), comment_load_multiple(), COMMENT_PUBLISHED, comment_view(), drupal_set_title(), field_get_items(), form_get_errors(), node_load(), node_view(), PASS_THROUGH, REQUEST_TIME, t(), user_load_by_name(), and variable_get().

Referenced by comment_form_build_preview().

comment_ranking ( )

Implements hook_ranking().

Definition at line 2669 of file comment.module.

References t(), and variable_get().

comment_rdf_mapping ( )

Implements hook_rdf_mapping().

Definition at line 2689 of file comment.module.

References RDF_DEFAULT_BUNDLE.

comment_save ( $comment )

Accepts a submission of new or changed comment content.

Parameters
$comment A comment object.

Definition at line 1453 of file comment.module.

References _comment_update_node_statistics(), comment_load(), COMMENT_NOT_PUBLISHED, COMMENT_PUBLISHED, db_ignore_slave(), db_query(), db_transaction(), drupal_write_record(), entity_load_unchanged(), field_attach_insert(), field_attach_presave(), field_attach_update(), int2vancode(), ip_address(), module_invoke_all(), node_load(), REQUEST_TIME, user_access(), vancode2int(), and watchdog_exception().

Referenced by comment_admin_overview_submit(), comment_approve(), comment_form_submit(), comment_save_action(), and comment_user_cancel().

comment_submit ( $comment )

Prepare a comment for submission.

Definition at line 2165 of file comment.module.

References check_markup(), check_plain(), decode_entities(), entity_language(), field_info_field(), field_is_translatable(), LANGUAGE_NONE, REQUEST_TIME, t(), truncate_utf8(), user_load_by_name(), and variable_get().

Referenced by comment_form_submit_build_comment().

comment_theme ( )

Implements hook_theme().

Definition at line 195 of file comment.module.

comment_unpublish_by_keyword_action_submit | ( | $form,
 |  | $form_state
 | ) |

Process comment_unpublish_by_keyword_action_form form submissions.

See Also
comment_unpublish_by_keyword_action()

Definition at line 2651 of file comment.module.

References drupal_explode_tags().

comment_update_index ( )

Implements hook_update_index().

Definition at line 1370 of file comment.module.

References db_query(), and variable_set().

comment_uri ( $comment )

Implements callback_entity_info_uri().

Definition at line 157 of file comment.module.

comment_user_cancel | ( | $edit,
 |  | $account,
 |  | $method
 | ) |

Implements hook_user_cancel().

Definition at line 1396 of file comment.module.

References comment_load_multiple(), and comment_save().

comment_user_delete ( $account )

Implements hook_user_delete().

Definition at line 1419 of file comment.module.

References comment_delete_multiple(), and db_query().

comment_view | ( | $comment,
 |  | $node,
 |  | $view_mode = 'full',
 |  | $langcode = NULL
 | ) |

Generate an array for rendering the given comment.

Parameters
$comment | A comment object.
$node | The node the comment is attached to.
$view_mode | View mode, e.g. 'full', 'teaser'...
$langcode | (optional) A language code to use for rendering. Defaults to the global content language of the current request.
Returns
An array as expected by drupal_render().

Definition at line 920 of file comment.module.

References comment_build_content(), COMMENT_MODE_THREADED, drupal_alter(), and variable_get().

Referenced by comment_preview(), comment_reply(), and comment_view_multiple().

comment_view_multiple | ( | $comments,
 |  | $node,
 |  | $view_mode = 'full',
 |  | $weight = 0,
 |  | $langcode = NULL
 | ) |

Construct a drupal_render() style array from an array of loaded comments.

Parameters
$comments | An array of comments as returned by comment_load_multiple().
$node | The node the comments are attached to.
$view_mode | View mode, e.g. 'full', 'teaser'...
$weight | An integer representing the weight of the first comment in the list.
$langcode | A string indicating the language field values are to be shown in. If no language is provided the current content language is used.
Returns
An array in the format expected by drupal_render().

Definition at line 1110 of file comment.module.

References comment_view(), entity_prepare_view(), and field_attach_prepare_view().

Referenced by comment_node_page_additions(), and comment_node_update_index().

int2vancode ( $i = 0 )

Generate vancode.

Consists of a leading character indicating length, followed by N digits with a numerical value in base 36. Vancodes can be sorted as strings without messing up numerical order.

It goes: 00, 01, 02, ..., 0y, 0z, 110, 111, ... , 1zy, 1zz, 2100, 2101, ..., 2zzy, 2zzz, 31000, 31001, ...

Definition at line 2500 of file comment.module.

Referenced by comment_save().

template_preprocess_comment ( & $variables )

Process variables for comment.tpl.php.

See Also
comment.tpl.php

Definition at line 2285 of file comment.module.

References COMMENT_NOT_PUBLISHED, element_children(), entity_uri(), field_attach_preprocess(), format_date(), l(), t(), theme(), and theme_get_setting().

template_preprocess_comment_wrapper ( & $variables )

Process variables for comment-wrapper.tpl.php.

See Also
comment-wrapper.tpl.php

Definition at line 2403 of file comment.module.

References COMMENT_MODE_THREADED, and variable_get().

vancode2int ( $c = '00' )

Decode vancode back to an integer.

Definition at line 2510 of file comment.module.

Referenced by comment_save().

Variable Documentation

const COMMENT_ANONYMOUS_MAY_CONTACT 1

Anonymous posters may leave their contact information.

Definition at line 40 of file comment.module.

Referenced by comment_form_node_type_form_alter().

const COMMENT_ANONYMOUS_MAYNOT_CONTACT 0

Anonymous posters cannot enter their contact information.

Definition at line 35 of file comment.module.

Referenced by comment_form(), and comment_form_node_type_form_alter().

const COMMENT_ANONYMOUS_MUST_CONTACT 2

Anonymous posters are required to leave their contact information.

Definition at line 45 of file comment.module.

Referenced by comment_form(), and comment_form_node_type_form_alter().

const COMMENT_FORM_BELOW 1

Comment form should be shown below post or list of comments.

Definition at line 55 of file comment.module.

Referenced by comment_form_node_type_form_alter(), comment_node_page_additions(), comment_node_view(), and theme_comment_post_forbidden().

const COMMENT_FORM_SEPARATE_PAGE 0

Comment form should be displayed on a separate page.

Definition at line 50 of file comment.module.

Referenced by comment_node_view(), and theme_comment_post_forbidden().

const COMMENT_MODE_FLAT 0

Comments are displayed in a flat list - expanded.

Definition at line 25 of file comment.module.

Referenced by _comment_get_modes(), comment_get_display_ordinal(), comment_get_thread(), and comment_new_page_count().

const COMMENT_MODE_THREADED 1

Comments are displayed as a threaded list - expanded.

Definition at line 30 of file comment.module.

Referenced by _comment_get_modes(), comment_form_node_type_form_alter(), comment_get_display_ordinal(), comment_new_page_count(), comment_node_page_additions(), comment_node_update_index(), comment_view(), and template_preprocess_comment_wrapper().

const COMMENT_NODE_CLOSED 1

Comments for this node are closed.

Definition at line 65 of file comment.module.

Referenced by comment_form_node_form_alter(), comment_form_node_type_form_alter(), comment_node_search_result(), and template_preprocess_forum_icon().

const COMMENT_NODE_HIDDEN 0

Comments for this node are hidden.

Definition at line 60 of file comment.module.

Referenced by comment_form_node_form_alter(), comment_form_node_type_form_alter(), comment_node_load(), comment_node_search_result(), comment_node_view(), standard_install(), and template_preprocess_forum_icon().

const COMMENT_NODE_OPEN 2

Comments for this node are open.

Definition at line 70 of file comment.module.

Referenced by comment_form_node_form_alter(), comment_form_node_type_form_alter(), comment_form_submit(), comment_links(), comment_node_page_additions(), comment_node_prepare(), comment_node_view(), comment_reply(), hook_node_prepare(), and hook_node_type_update().

const COMMENT_NOT_PUBLISHED 0

Comment is awaiting approval.

Definition at line 15 of file comment.module.

Referenced by comment_admin_overview(), comment_admin_overview_submit(), comment_count_unpublished(), comment_form(), comment_form_submit(), comment_links(), comment_save(), comment_unpublish_action(), comment_unpublish_by_keyword_action(), and template_preprocess_comment().

const COMMENT_PUBLISHED 1

Comment is published.

Definition at line 20 of file comment.module.

Referenced by _comment_update_node_statistics(), _forum_update_forum_index(), _token_example_get_comment(), _tracker_calculate_changed(), _tracker_remove(), comment_access(), comment_admin_overview(), comment_admin_overview_submit(), comment_approve(), comment_file_download_access(), comment_form(), comment_get_display_ordinal(), comment_get_recent(), comment_get_thread(), comment_new_page_count(), comment_num_new(), comment_preview(), comment_publish_action(), comment_reply(), comment_save(), hook_node_update_index(), tracker_comment_update(), and tracker_cron().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment.pages.inc File Reference

  • modules
  • comment
Functions
comment.pages.inc File Reference

Go to the source code of this file.

Functions

comment_reply ($node, $pid=NULL)
comment_approve ($cid)

Detailed Description

User page callbacks for the comment module.

Definition in file comment.pages.inc.

Function Documentation

comment_approve ( $cid )

Menu callback; publish specified comment.

Parameters
$cid A comment identifier.

Definition at line 111 of file comment.pages.inc.

References comment_load(), COMMENT_PUBLISHED, comment_save(), drupal_goto(), drupal_set_message(), drupal_valid_token(), MENU_ACCESS_DENIED, MENU_NOT_FOUND, and t().

comment_reply | ( | $node,
 |  | $pid = NULL
 | ) |

This function is responsible for generating a comment reply form. There are several cases that have to be handled, including:

  • replies to comments
  • replies to nodes
  • attempts to reply to nodes that can no longer accept comments
  • respecting access permissions ('access comments', 'post comments', etc.)

The node or comment that is being replied to must appear above the comment form to provide the user context while authoring the comment.

Parameters
$node | Every comment belongs to a node. This is that node.
$pid | Some comments are replies to other comments. In those cases, $pid is the parent comment's cid.
Returns
array An associative array containing:
  • An array for rendering the node or parent comment.
    • comment_node: If the comment is a reply to the node.
    • comment_parent: If the comment is a reply to another comment.
  • comment_form: The comment form as a renderable array.

Definition at line 33 of file comment.pages.inc.

References $op, COMMENT_NODE_OPEN, COMMENT_PUBLISHED, comment_view(), db_query(), drupal_get_form(), drupal_goto(), drupal_set_breadcrumb(), drupal_set_message(), field_attach_load(), l(), node_view(), t(), and user_access().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment.tokens.inc File Reference

  • modules
  • comment
Functions
comment.tokens.inc File Reference

Go to the source code of this file.

Functions

comment_token_info ()
comment_tokens ($type, $tokens, array $data=array(), array $options=array())

Detailed Description

Builds placeholder replacement tokens for comment-related data.

Definition in file comment.tokens.inc.

Function Documentation

comment_token_info ( )

Implements hook_token_info().

Definition at line 11 of file comment.tokens.inc.

References t().

comment_tokens | ( |  | $type,
 |  |  | $tokens,
 |  | array | $data = array(),
 |  | array | $options = array()
 | ) |  |

Implements hook_tokens().

Definition at line 105 of file comment.tokens.inc.

References $name, $title, _text_sanitize(), check_plain(), check_url(), comment_load(), comment_num_new(), field_get_items(), field_info_instance(), field_language(), filter_xss(), format_date(), node_load(), t(), token_find_with_prefix(), token_generate(), url(), user_load(), and variable_get().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/contact Directory Reference

  • modules
  • contact
contact Directory Reference

Files

file | contact.admin.inc [code]
file | contact.install [code]
file | contact.module [code]
file | contact.pages.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/contact/contact.admin.inc File Reference

  • modules
  • contact
Functions
contact.admin.inc File Reference

Go to the source code of this file.

Functions

contact_category_list ()
contact_category_edit_form ($form, &$form_state, array $category=array())
contact_category_edit_form_validate ($form, &$form_state)
contact_category_edit_form_submit ($form, &$form_state)
contact_category_delete_form ($form, &$form_state, array $contact)
contact_category_delete_form_submit ($form, &$form_state)

Detailed Description

Admin page callbacks for the Contact module.

Definition in file contact.admin.inc.

Function Documentation

contact_category_delete_form | ( |  | $form,
 |  | & | $form_state,
 |  | array | $contact
 | ) |  |

Form constructor for the contact category deletion form.

Parameters
$contact Array describing the contact category to be deleted. See the documentation of contact_category_edit_form() for the recognized keys.
See Also
contact_menu()
contact_category_delete_form_submit()

Definition at line 198 of file contact.admin.inc.

References confirm_form(), and t().

contact_category_delete_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for contact_category_delete_form().

Definition at line 217 of file contact.admin.inc.

References db_delete(), drupal_set_message(), t(), watchdog(), and WATCHDOG_NOTICE.

contact_category_edit_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for contact_category_edit_form().

See Also
contact_category_edit_form_validate()

Definition at line 168 of file contact.admin.inc.

References db_update(), drupal_set_message(), drupal_write_record(), l(), t(), watchdog(), and WATCHDOG_NOTICE.

contact_category_edit_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for contact_category_edit_form().

See Also
contact_category_edit_form_submit()

Definition at line 139 of file contact.admin.inc.

References db_select(), form_set_error(), t(), and valid_email_address().

contact_category_list ( )

Categories/list tab.

Definition at line 11 of file contact.admin.inc.

References $header, check_plain(), db_select(), l(), and t().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/contact/contact.install File Reference

  • modules
  • contact
Functions
contact.install File Reference

Go to the source code of this file.

Functions

contact_schema ()
contact_install ()
contact_uninstall ()
contact_update_dependencies ()
contact_update_7000 ()
contact_update_7001 ()
contact_update_7002 ()
contact_update_7003 ()

Detailed Description

Install, update and uninstall functions for the contact module.

Definition in file contact.install.

Function Documentation

contact_install ( )

Implements hook_install().

Definition at line 70 of file contact.install.

References db_insert(), and variable_get().

contact_schema ( )

Implements hook_schema().

Definition at line 11 of file contact.install.

contact_uninstall ( )

Implements hook_uninstall().

Definition at line 85 of file contact.install.

References variable_del().

contact_update_dependencies ( )

Implements hook_update_dependencies().

Definition at line 94 of file contact.install.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/contact/contact.module File Reference

  • modules
  • contact
Functions
contact.module File Reference

Go to the source code of this file.

Functions

contact_help ($path, $arg)
contact_permission ()
contact_menu ()
_contact_personal_tab_access ($account)
contact_load ($cid)
contact_mail ($key, &$message, $params)
contact_form_user_profile_form_alter (&$form, &$form_state)
contact_user_presave (&$edit, $account, $category)
contact_form_user_admin_settings_alter (&$form, &$form_state)

Detailed Description

Enables the use of personal and site-wide contact forms.

Definition in file contact.module.

Function Documentation

_contact_personal_tab_access ( $account )

Menu access callback for a user's personal contact form.

Parameters
$account The user object of the user whose contact form is being requested.

Definition at line 115 of file contact.module.

References user_access().

contact_form_user_admin_settings_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Add the default personal contact setting on the user settings page.

See Also
user_admin_settings()

Definition at line 247 of file contact.module.

References t(), and variable_get().

contact_form_user_profile_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Add the enable personal contact form to an individual user's account page.

See Also
user_profile_form()

Definition at line 215 of file contact.module.

References t(), and url().

contact_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file contact.module.

References $output, t(), and url().

contact_load ( $cid )

Loads a contact category.

Parameters
$cid The contact category ID.
Returns
An array with the contact category's data.

Definition at line 156 of file contact.module.

References db_select().

Referenced by contact_site_form_submit().

contact_mail | ( |  | $key,
 |  | & | $message,
 |  |  | $params
 | ) |  |

Implements hook_mail().

Definition at line 168 of file contact.module.

References format_username(), t(), url(), and variable_get().

contact_menu ( )

Implements hook_menu().

Definition at line 57 of file contact.module.

References MENU_LOCAL_ACTION, MENU_LOCAL_TASK, and MENU_SUGGESTED_ITEM.

contact_permission ( )

Implements hook_permission().

Definition at line 40 of file contact.module.

References t().

contact_user_presave | ( | & | $edit,
 |  |  | $account,
 |  |  | $category
 | ) |  |

Implements hook_user_presave().

Definition at line 236 of file contact.module.

References variable_get().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/contact/contact.pages.inc File Reference

  • modules
  • contact
Functions
contact.pages.inc File Reference

Go to the source code of this file.

Functions

contact_site_form ($form, &$form_state)
contact_site_form_validate ($form, &$form_state)
contact_site_form_submit ($form, &$form_state)
contact_personal_form ($form, &$form_state, $recipient)
contact_personal_form_validate ($form, &$form_state)
contact_personal_form_submit ($form, &$form_state)

Detailed Description

Page callbacks for the Contact module.

Definition in file contact.pages.inc.

Function Documentation

contact_personal_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for contact_personal_form().

See Also
contact_personal_form_validate()

Definition at line 269 of file contact.pages.inc.

References drupal_mail(), drupal_set_message(), flood_register_event(), name, t(), user_access(), user_cookie_save(), user_preferred_language(), variable_get(), and watchdog().

contact_personal_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for contact_personal_form().

See Also
contact_personal_form_submit()

Definition at line 258 of file contact.pages.inc.

References form_set_error(), t(), and valid_email_address().

contact_site_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for contact_site_form().

See Also
contact_site_form_validate()

Definition at line 133 of file contact.pages.inc.

References contact_load(), drupal_mail(), drupal_set_message(), flood_register_event(), language_default(), t(), user_cookie_save(), variable_get(), and watchdog().

contact_site_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for contact_site_form().

See Also
contact_site_form_submit()

Definition at line 119 of file contact.pages.inc.

References form_set_error(), t(), and valid_email_address().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/contextual Directory Reference

  • modules
  • contextual
contextual Directory Reference

Files

file | contextual.api.php [code]
file | contextual.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/contextual/contextual.api.php File Reference

  • modules
  • contextual
Functions
contextual.api.php File Reference

Go to the source code of this file.

Functions

hook_contextual_links_view_alter (&$element, $items)

Detailed Description

Hooks provided by Contextual module.

Definition in file contextual.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/contextual/contextual.module File Reference

  • modules
  • contextual
Functions
contextual.module File Reference

Go to the source code of this file.

Functions

contextual_help ($path, $arg)
contextual_permission ()
contextual_library ()
contextual_element_info ()
contextual_preprocess (&$variables, $hook)
contextual_pre_render_links ($element)

Detailed Description

Adds contextual links to perform actions related to elements on a page.

Definition in file contextual.module.

Function Documentation

contextual_element_info ( )

Implements hook_element_info().

Definition at line 60 of file contextual.module.

contextual_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file contextual.module.

References $output, and t().

contextual_library ( )

Implements hook_library().

Definition at line 41 of file contextual.module.

References drupal_get_path().

contextual_permission ( )

Implements hook_permission().

Definition at line 29 of file contextual.module.

References t().

contextual_pre_render_links ( $element )

Build a renderable array for contextual links.

Parameters
$element A renderable array containing a #contextual_links property, which is a keyed array. Each key is the name of the implementing module, and each value is an array that forms the function arguments for menu_contextual_links(). For example:
* array('#contextual_links' => array(
* 'block' => array('admin/structure/block/manage', array('system', 'navigation')),
* 'menu' => array('admin/structure/menu/manage', array('navigation')),
* ))
*
Returns
A renderable array representing contextual links.
See Also
menu_contextual_links()
contextual_element_info()

Definition at line 137 of file contextual.module.

References $links, $module, drupal_alter(), drupal_get_destination(), drupal_html_class(), and menu_contextual_links().

contextual_preprocess | ( | & | $variables,
 |  |  | $hook
 | ) |  |

Implements hook_preprocess().

See Also
contextual_pre_render_links()

Definition at line 84 of file contextual.module.

References theme_get_registry(), and user_access().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/dashboard Directory Reference

  • modules
  • dashboard
dashboard Directory Reference

Files

file | dashboard.api.php [code]
file | dashboard.install [code]
file | dashboard.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/dashboard/dashboard.api.php File Reference

  • modules
  • dashboard
Functions
dashboard.api.php File Reference

Go to the source code of this file.

Functions

hook_dashboard_regions ()
hook_dashboard_regions_alter (&$regions)

Detailed Description

Hooks provided by the Dashboard module.

Definition in file dashboard.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/dashboard/dashboard.install File Reference

  • modules
  • dashboard
Functions
dashboard.install File Reference

Go to the source code of this file.

Functions

dashboard_disable ()
dashboard_enable ()
dashboard_uninstall ()

Detailed Description

Install, update and uninstall functions for the dashboard module.

Definition in file dashboard.install.

Function Documentation

dashboard_disable ( )

Implements hook_disable().

Stash a list of blocks enabled on the dashboard, so they can be re-enabled if the dashboard is re-enabled. Then disable those blocks, since the dashboard regions will no longer be defined.

Definition at line 15 of file dashboard.install.

References BLOCK_REGION_NONE, dashboard_regions(), db_select(), db_update(), and variable_set().

dashboard_enable ( )

Implements hook_enable().

Restores blocks to the dashboard that were there when the dashboard module was disabled.

Definition at line 49 of file dashboard.install.

References db_update(), drupal_theme_initialize(), variable_del(), and variable_get().

dashboard_uninstall ( )

Implements hook_uninstall().

Definition at line 76 of file dashboard.install.

References variable_del().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/dashboard/dashboard.module File Reference

  • modules
  • dashboard
Functions
dashboard.module File Reference

Go to the source code of this file.

Functions

dashboard_help ($path, $arg)
dashboard_menu ()
dashboard_permission ()
dashboard_block_info_alter (&$blocks, $theme, $code_blocks)
dashboard_block_list_alter (&$blocks)
dashboard_page_build (&$page)
dashboard_system_info_alter (&$info, $file, $type)
dashboard_theme ()
dashboard_forms ()
dashboard_admin ($launch_customize=FALSE)
dashboard_admin_blocks ()
dashboard_form_block_admin_display_form_alter (&$form, &$form_state, $form_id)
dashboard_form_dashboard_admin_display_form_alter (&$form, &$form_state)
dashboard_form_block_admin_configure_alter (&$form, &$form_state)
dashboard_form_block_add_block_form_alter (&$form, &$form_state)
template_preprocess_dashboard_admin_display_form (&$variables)
dashboard_is_visible ()
dashboard_region_descriptions ()
dashboard_regions ()
dashboard_dashboard_regions ()
dashboard_show_disabled ()
dashboard_show_block_content ($module, $delta)
dashboard_update ()
theme_dashboard ($variables)
theme_dashboard_admin ($variables)
theme_dashboard_region ($variables)
theme_dashboard_disabled_blocks ($variables)
theme_dashboard_disabled_block ($variables)

Detailed Description

Provides a dashboard page in the administrative interface.

Definition in file dashboard.module.

Function Documentation

dashboard_admin ( $launch_customize = FALSE )

Page callback: Displays the dashboard.

Parameters
$launch_customize Whether to launch in customization mode right away. TRUE or FALSE.

Definition at line 275 of file dashboard.module.

References drupal_get_path(), drupal_get_token(), t(), url(), and user_access().

dashboard_admin_blocks ( )

Page callback: Builds the page for administering dashboard blocks.

This page reuses the Block module's administration form but limits editing to blocks that are available to appear on the dashboard.

See Also
block_admin_display()
block_admin_display_form()
dashboard_form_dashboard_admin_display_form_alter()
template_preprocess_dashboard_admin_display_form()

Definition at line 315 of file dashboard.module.

References block_admin_display_prepare_blocks(), dashboard_region_descriptions(), drupal_get_form(), drupal_theme_initialize(), module_load_include(), REGIONS_VISIBLE, and system_region_list().

dashboard_block_info_alter | ( | & | $blocks,
 |  |  | $theme,
 |  |  | $code_blocks
 | ) |  |

Implements hook_block_info_alter().

Definition at line 101 of file dashboard.module.

References $module, BLOCK_REGION_NONE, and variable_get().

dashboard_block_list_alter ( & $blocks )

Implements hook_block_list_alter().

Skip rendering dashboard blocks when not on the dashboard page itself. This prevents expensive dashboard blocks from causing performance issues on pages where they will never be displayed.

Definition at line 124 of file dashboard.module.

References dashboard_is_visible(), and dashboard_regions().

dashboard_dashboard_regions ( )

Implements hook_dashboard_regions().

Definition at line 483 of file dashboard.module.

dashboard_form_block_add_block_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 412 of file dashboard.module.

References dashboard_form_block_admin_configure_alter().

dashboard_form_block_admin_configure_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 392 of file dashboard.module.

References dashboard_region_descriptions(), drupal_theme_initialize(), and element_children().

Referenced by dashboard_form_block_add_block_form_alter().

dashboard_form_block_admin_display_form_alter | ( | & | $form,
 |  | & | $form_state,
 |  |  | $form_id
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 341 of file dashboard.module.

References dashboard_region_descriptions(), and element_children().

dashboard_form_dashboard_admin_display_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 376 of file dashboard.module.

dashboard_forms ( )

Implements hook_forms().

Definition at line 259 of file dashboard.module.

dashboard_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 10 of file dashboard.module.

References $output, t(), and url().

dashboard_is_visible ( )

Determines if the dashboard should be displayed on the current page.

This function checks if the user is currently viewing the dashboard and has access to see it. It is used by other functions in the dashboard module to decide whether or not the dashboard content should be displayed to the current user.

Although the menu system normally handles the above tasks, it only does so for the main page content. However, the dashboard is not part of the main page content, but rather is displayed in special regions of the page (so it can interface with the Block module's method of managing page regions). We therefore need to maintain this separate function to check the menu item for us.

Returns
TRUE if the dashboard should be visible on the current page, FALSE otherwise.
See Also
dashboard_block_list_alter()
dashboard_page_build()

Definition at line 448 of file dashboard.module.

References menu_get_item().

Referenced by dashboard_block_list_alter(), and dashboard_page_build().

dashboard_menu ( )

Implements hook_menu().

Definition at line 36 of file dashboard.module.

References MENU_CALLBACK, and MENU_VISIBLE_IN_BREADCRUMB.

dashboard_page_build ( & $page )

Implements hook_page_build().

Display dashboard blocks in the main content region.

Definition at line 139 of file dashboard.module.

References $page, _block_get_renderable_array(), dashboard_is_visible(), dashboard_regions(), db_select(), module_invoke(), and t().

dashboard_permission ( )

Implements hook_permission().

Definition at line 84 of file dashboard.module.

References l(), and t().

dashboard_region_descriptions ( )

Returns an array of dashboard region descriptions, keyed by region name.

Definition at line 463 of file dashboard.module.

References drupal_alter(), and module_invoke_all().

Referenced by dashboard_admin_blocks(), dashboard_form_block_admin_configure_alter(), dashboard_form_block_admin_display_form_alter(), dashboard_regions(), and dashboard_system_info_alter().

dashboard_regions ( )

Returns an array of dashboard region names.

Definition at line 472 of file dashboard.module.

References dashboard_region_descriptions(), and drupal_static().

Referenced by dashboard_block_list_alter(), dashboard_disable(), dashboard_page_build(), and dashboard_system_info_alter().

dashboard_show_block_content | ( | $module,
 |  | $delta
 | ) |

Ajax callback: Displays the rendered contents of a specific block.

Parameters
$module | The block's module name.
$delta | The block's delta.

Definition at line 520 of file dashboard.module.

References $module, _block_get_renderable_array(), _block_render_blocks(), db_query(), drupal_exit(), drupal_render(), drupal_theme_initialize(), and print.

dashboard_show_disabled ( )

Ajax callback: Shows disabled blocks in the dashboard customization mode.

Definition at line 494 of file dashboard.module.

References _block_rehash(), drupal_exit(), print, and theme().

dashboard_system_info_alter | ( | & | $info,
 |  |  | $file,
 |  |  | $type
 | ) |  |

Implements hook_system_info_alter().

Add regions to each theme to store the dashboard blocks.

Definition at line 207 of file dashboard.module.

References $info, dashboard_region_descriptions(), and dashboard_regions().

dashboard_theme ( )

Implements hook_theme().

Definition at line 228 of file dashboard.module.

References drupal_get_path().

dashboard_update ( )

Sets the new weight of each region according to the drag-and-drop order.

Definition at line 543 of file dashboard.module.

References db_merge(), drupal_exit(), drupal_set_message(), drupal_theme_initialize(), drupal_valid_token(), and t().

template_preprocess_dashboard_admin_display_form ( & $variables )

Preprocesses variables for block-admin-display-form.tpl.php.

Definition at line 419 of file dashboard.module.

References BLOCK_REGION_NONE, t(), and template_preprocess_block_admin_display_form().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/dblog Directory Reference

  • modules
  • dblog
dblog Directory Reference

Files

file | dblog.admin.inc [code]
file | dblog.install [code]
file | dblog.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/dblog/dblog.admin.inc File Reference

  • modules
  • dblog
Functions
dblog.admin.inc File Reference

Go to the source code of this file.

Functions

dblog_overview ()
dblog_top ($type)
dblog_event ($id)
dblog_build_filter_query ()
dblog_filters ()
theme_dblog_message ($variables)
dblog_filter_form ($form)
dblog_filter_form_validate ($form, &$form_state)
dblog_filter_form_submit ($form, &$form_state)
dblog_clear_log_form ($form)
dblog_clear_log_submit ()

Detailed Description

Administrative page callbacks for the Database Logging module.

Definition in file dblog.admin.inc.

Function Documentation

dblog_build_filter_query ( )

Builds a query for database log administration filters based on session.

Returns
array An associative array with keys 'where' and 'args'.

Definition at line 212 of file dblog.admin.inc.

References $value, and dblog_filters().

Referenced by dblog_overview().

dblog_clear_log_submit ( )

Form submission handler for dblog_clear_log_form().

Definition at line 414 of file dblog.admin.inc.

References db_delete(), drupal_set_message(), and t().

dblog_event ( $id )

Page callback: Displays details about a specific database log message.

Parameters
int $id Unique ID of the database log message.
Returns
array|string If the ID is located in the Database Logging table, a build array in the format expected by drupal_render(); otherwise, an empty string.
See Also
dblog_menu()

Definition at line 152 of file dblog.admin.inc.

References check_plain(), db_query(), format_date(), l(), t(), theme(), and watchdog_severity_levels().

dblog_filter_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for dblog_filter_form().

See Also
dblog_filter_form_validate()

Definition at line 370 of file dblog.admin.inc.

References $name, $op, dblog_filters(), and t().

dblog_filter_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for dblog_filter_form().

See Also
dblog_filter_form_submit()

Definition at line 359 of file dblog.admin.inc.

References form_set_error(), and t().

dblog_filters ( )

Creates a list of database log administration filters that can be applied.

Returns
array Associative array of filters. The top-level keys are used as the form element names for the filters, and the values are arrays with the following elements:
  • title: Title of the filter.
  • where: The filter condition.
  • options: Array of options for the select list for the filter.

Definition at line 250 of file dblog.admin.inc.

References _dblog_get_message_types(), t(), and watchdog_severity_levels().

Referenced by dblog_build_filter_query(), dblog_filter_form(), and dblog_filter_form_submit().

dblog_top ( $type )

Page callback: Shows the most frequent log messages of a given event type.

Messages are not truncated on this page because events detailed herein do not have links to a detailed view.

Parameters
string $type Type of database log events to display (e.g., 'search').
Returns
array A build array in the format expected by drupal_render().
See Also
dblog_menu()

Definition at line 102 of file dblog.admin.inc.

References $header, db_select(), t(), and theme().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/dblog/dblog.install File Reference

  • modules
  • dblog
Functions
dblog.install File Reference

Go to the source code of this file.

Functions

dblog_schema ()
dblog_uninstall ()
dblog_update_7001 ()
dblog_update_7002 ()

Detailed Description

Install, update and uninstall functions for the dblog module.

Definition in file dblog.install.

Function Documentation

dblog_schema ( )

Implements hook_schema().

Definition at line 11 of file dblog.install.

dblog_uninstall ( )

Implements hook_uninstall().

Definition at line 98 of file dblog.install.

References variable_del().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/dblog/dblog.module File Reference

  • modules
  • dblog
Functions
dblog.module File Reference

Go to the source code of this file.

Functions

dblog_help ($path, $arg)
dblog_menu ()
dblog_init ()
dblog_cron ()
_dblog_get_message_types ()
dblog_watchdog (array $log_entry)
dblog_form_system_logging_settings_alter (&$form, $form_state)
dblog_theme ()

Detailed Description

System monitoring and logging for administrators.

The Database Logging module monitors your site and keeps a list of recorded events containing usage and performance data, errors, warnings, and similar operational information.

See Also
watchdog()

Definition in file dblog.module.

Function Documentation

_dblog_get_message_types ( )

Gathers a list of uniquely defined database log message types.

Returns
array List of uniquely defined database log message types.

Definition at line 130 of file dblog.module.

References db_query().

Referenced by dblog_filters().

dblog_cron ( )

Implements hook_cron().

Controls the size of the log table, paring it to 'dblog_row_limit' messages.

Definition at line 101 of file dblog.module.

References db_delete(), db_select(), and variable_get().

dblog_form_system_logging_settings_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter() for system_logging_settings().

Definition at line 166 of file dblog.module.

References drupal_map_assoc(), t(), url(), and variable_get().

dblog_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 17 of file dblog.module.

References $output, t(), and url().

dblog_init ( )

Implements hook_init().

Definition at line 89 of file dblog.module.

References arg(), drupal_add_css(), and drupal_get_path().

dblog_menu ( )

Implements hook_menu().

Definition at line 39 of file dblog.module.

References module_exists().

dblog_theme ( )

Implements hook_theme().

Definition at line 180 of file dblog.module.

dblog_watchdog ( array $log_entry )

Implements hook_watchdog().

Note: Some values may be truncated to meet database column size restrictions.

Definition at line 146 of file dblog.module.

References Database::getConnection().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field Directory Reference

  • modules
  • field
field Directory Reference

Directories

directory | modules
directory | theme

Files

file | field.api.php [code]
file | field.attach.inc [code]
file | field.crud.inc [code]
file | field.default.inc [code]
file | field.form.inc [code]
file | field.info.class.inc [code]
file | field.info.inc [code]
file | field.install [code]
file | field.module [code]
file | field.multilingual.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules Directory Reference

  • modules
  • field
  • modules
modules Directory Reference

Directories

directory | field_sql_storage
directory | list
directory | number
directory | options
directory | text
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/field_sql_storage Directory Reference

  • modules
  • field
  • modules
  • field_sql_storage
field_sql_storage Directory Reference

Files

file | field_sql_storage.install [code]
file | field_sql_storage.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/field_sql_storage/field_sql_storage.install File Reference

  • modules
  • field
  • modules
  • field_sql_storage
Functions
field_sql_storage.install File Reference

Go to the source code of this file.

Functions

field_sql_storage_schema ()
_update_7000_field_sql_storage_write ($entity_type, $bundle, $entity_id, $revision_id, $field_name, $data)
field_sql_storage_update_7000 ()
field_sql_storage_update_7001 (&$sandbox)
field_sql_storage_update_7002 ()

Detailed Description

Install, update and uninstall functions for the field_sql_storage module.

Definition in file field_sql_storage.install.

Function Documentation

field_sql_storage_schema ( )

Implements hook_schema().

Definition at line 11 of file field_sql_storage.install.

References _field_sql_storage_schema(), db_table_exists(), drupal_load(), and field_read_fields().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/field_sql_storage/field_sql_storage.module File Reference

  • modules
  • field
  • modules
  • field_sql_storage
Functions
field_sql_storage.module File Reference

Go to the source code of this file.

Functions

field_sql_storage_help ($path, $arg)
field_sql_storage_field_storage_info ()
_field_sql_storage_tablename ($field)
_field_sql_storage_revision_tablename ($field)
_field_sql_storage_columnname ($name, $column)
_field_sql_storage_indexname ($name, $index)
_field_sql_storage_schema ($field)
field_sql_storage_field_storage_create_field ($field)
field_sql_storage_field_update_forbid ($field, $prior_field, $has_data)
field_sql_storage_field_storage_update_field ($field, $prior_field, $has_data)
field_sql_storage_field_storage_delete_field ($field)
field_sql_storage_field_storage_load ($entity_type, $entities, $age, $fields, $options)
field_sql_storage_field_storage_write ($entity_type, $entity, $op, $fields)
field_sql_storage_field_storage_delete ($entity_type, $entity, $fields)
field_sql_storage_field_storage_purge ($entity_type, $entity, $field, $instance)
field_sql_storage_field_storage_query (EntityFieldQuery $query)
_field_sql_storage_query_join_entity (SelectQuery $select_query, $entity_type, $field_base_table)
_field_sql_storage_query_field_conditions (EntityFieldQuery $query, SelectQuery $select_query, $conditions, $table_aliases, $column_callback)
_field_sql_storage_query_columnname ($field_name, $column)
field_sql_storage_field_storage_delete_revision ($entity_type, $entity, $fields)
field_sql_storage_field_storage_delete_instance ($instance)
field_sql_storage_field_attach_rename_bundle ($entity_type, $bundle_old, $bundle_new)
field_sql_storage_field_storage_purge_field ($field)
field_sql_storage_field_storage_details ($field)

Detailed Description

Default implementation of the field storage API.

Definition in file field_sql_storage.module.

Function Documentation

_field_sql_storage_columnname | ( | $name,
 |  | $column
 | ) |

Generate a column name for a field data table.

Parameters
$name | The name of the field
$column | The name of the column
Returns
A string containing a generated column name for a field data table that is unique among all other fields.

Definition at line 78 of file field_sql_storage.module.

References $name.

Referenced by _field_sql_storage_schema(), _update_7000_field_sql_storage_write(), field_sql_storage_field_storage_details(), field_sql_storage_field_storage_load(), field_sql_storage_field_storage_query(), field_sql_storage_field_storage_update_field(), field_sql_storage_field_storage_write(), hook_field_storage_details(), hook_field_storage_load(), hook_field_storage_query(), and hook_field_storage_write().

_field_sql_storage_indexname | ( | $name,
 |  | $index
 | ) |

Generate an index name for a field data table.

Parameters
$name | The name of the field
$column | The name of the index
Returns
A string containing a generated index name for a field data table that is unique among all other fields.

Definition at line 93 of file field_sql_storage.module.

References $name.

Referenced by _field_sql_storage_schema(), and field_sql_storage_field_storage_update_field().

_field_sql_storage_query_columnname | ( | $field_name,
 |  | $column
 | ) |

Field meta condition column callback.

Definition at line 652 of file field_sql_storage.module.

_field_sql_storage_query_field_conditions | ( | EntityFieldQuery | $query,
 |  | SelectQuery | $select_query,
 |  |  | $conditions,
 |  |  | $table_aliases,
 |  |  | $column_callback
 | ) |  |

Adds field (meta) conditions to the given query objects respecting groupings.

Parameters
EntityFieldQuery | $query | The field query object to be processed.
SelectQuery | $select_query | The SelectQuery that should get grouping conditions.
condtions | The conditions to be added.
$table_aliases | An associative array of table aliases keyed by field index.
$column_callback | A callback that should return the column name to be used for the field conditions. Accepts a field name and a field column name as parameters.

Definition at line 626 of file field_sql_storage.module.

References EntityFieldQuery::addCondition(), drupal_static(), and SelectQuery::where().

Referenced by field_sql_storage_field_storage_query().

_field_sql_storage_query_join_entity | ( | SelectQuery | $select_query,
 |  |  | $entity_type,
 |  |  | $field_base_table
 | ) |  |

Adds the base entity table to a field query object.

Parameters
SelectQuery | $select_query | A SelectQuery containing at least one table as specified by _field_sql_storage_tablename().
$entity_type | The entity type for which the base table should be joined.
$field_base_table | Name of a table in $select_query. As only INNER JOINs are used, it does not matter which.
Returns
The name of the entity base table joined in.

Definition at line 603 of file field_sql_storage.module.

References entity_get_info(), and SelectQuery::join().

Referenced by field_sql_storage_field_storage_query(), and hook_field_storage_query().

_field_sql_storage_revision_tablename ( $field )

Generate a table name for a field revision archive table.

Parameters
$name The field structure.
Returns
A string containing the generated name for the database table

Definition at line 58 of file field_sql_storage.module.

Referenced by _field_sql_storage_schema(), field_sql_storage_field_attach_rename_bundle(), field_sql_storage_field_storage_delete_field(), field_sql_storage_field_storage_delete_instance(), field_sql_storage_field_storage_delete_revision(), field_sql_storage_field_storage_details(), field_sql_storage_field_storage_load(), field_sql_storage_field_storage_purge(), field_sql_storage_field_storage_purge_field(), field_sql_storage_field_storage_update_field(), field_sql_storage_field_storage_write(), hook_field_storage_delete_field(), hook_field_storage_delete_instance(), hook_field_storage_delete_revision(), hook_field_storage_details(), hook_field_storage_load(), hook_field_storage_purge(), hook_field_storage_purge_field(), hook_field_storage_write(), image_update_7002(), and image_update_7004().

_field_sql_storage_schema ( $field )

Return the database schema for a field. This may contain one or more tables. Each table will contain the columns relevant for the specified field. Leave the $field's 'columns' and 'indexes' keys empty to get only the base schema.

Parameters
$field The field structure for which to generate a database schema.
Returns
One or more tables representing the schema for the field.

Definition at line 108 of file field_sql_storage.module.

References $attributes, _field_sql_storage_columnname(), _field_sql_storage_indexname(), _field_sql_storage_revision_tablename(), and _field_sql_storage_tablename().

Referenced by field_sql_storage_field_storage_create_field(), field_sql_storage_field_storage_update_field(), field_sql_storage_schema(), hook_field_storage_create_field(), and hook_field_storage_update_field().

_field_sql_storage_tablename ( $field )

Generate a table name for a field data table.

Parameters
$field The field structure.
Returns
A string containing the generated name for the database table

Definition at line 41 of file field_sql_storage.module.

Referenced by _field_sql_storage_schema(), field_sql_storage_field_attach_rename_bundle(), field_sql_storage_field_storage_delete_field(), field_sql_storage_field_storage_delete_instance(), field_sql_storage_field_storage_details(), field_sql_storage_field_storage_load(), field_sql_storage_field_storage_purge(), field_sql_storage_field_storage_purge_field(), field_sql_storage_field_storage_update_field(), field_sql_storage_field_storage_write(), hook_field_storage_delete_field(), hook_field_storage_delete_instance(), hook_field_storage_details(), hook_field_storage_load(), hook_field_storage_purge(), hook_field_storage_purge_field(), hook_field_storage_write(), image_update_7002(), and image_update_7004().

field_sql_storage_field_attach_rename_bundle | ( | $entity_type,
 |  | $bundle_old,
 |  | $bundle_new
 | ) |

Implements hook_field_attach_rename_bundle().

Definition at line 701 of file field_sql_storage.module.

References _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), db_update(), field_info_field_by_id(), and field_read_instances().

field_sql_storage_field_storage_create_field ( $field )

Implements hook_field_storage_create_field().

Definition at line 213 of file field_sql_storage.module.

References $name, _field_sql_storage_schema(), db_create_table(), and drupal_get_schema().

Referenced by _update_7000_field_create_field().

field_sql_storage_field_storage_delete | ( | $entity_type,
 |  | $entity,
 |  | $fields
 | ) |

Implements hook_field_storage_delete().

This function deletes data for all fields for an entity from the database.

Definition at line 462 of file field_sql_storage.module.

References entity_extract_ids(), field_info_field_by_id(), field_info_instances(), and field_sql_storage_field_storage_purge().

field_sql_storage_field_storage_delete_field ( $field )

Implements hook_field_storage_delete_field().

Definition at line 305 of file field_sql_storage.module.

References _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), db_rename_table(), db_update(), and drupal_get_schema().

field_sql_storage_field_storage_delete_instance ( $instance )

Implements hook_field_storage_delete_instance().

This function simply marks for deletion all data associated with the field.

Definition at line 682 of file field_sql_storage.module.

References _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), db_update(), and field_info_field().

field_sql_storage_field_storage_delete_revision | ( | $entity_type,
 |  | $entity,
 |  | $fields
 | ) |

Implements hook_field_storage_delete_revision().

This function actually deletes the data from the database.

Definition at line 661 of file field_sql_storage.module.

References _field_sql_storage_revision_tablename(), db_delete(), entity_extract_ids(), and field_info_field_by_id().

field_sql_storage_field_storage_details ( $field )

Implements hook_field_storage_details().

Definition at line 739 of file field_sql_storage.module.

References $attributes, _field_sql_storage_columnname(), _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), FIELD_LOAD_CURRENT, and FIELD_LOAD_REVISION.

field_sql_storage_field_storage_info ( )

Implements hook_field_storage_info().

Definition at line 24 of file field_sql_storage.module.

References t().

field_sql_storage_field_storage_load | ( | $entity_type,
 |  | $entities,
 |  | $age,
 |  | $fields,
 |  | $options
 | ) |

Implements hook_field_storage_load().

Definition at line 326 of file field_sql_storage.module.

References $attributes, $results, $row, _field_sql_storage_columnname(), _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), db_select(), field_available_languages(), FIELD_CARDINALITY_UNLIMITED, field_info_field_by_id(), and FIELD_LOAD_CURRENT.

field_sql_storage_field_storage_purge | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance
 | ) |

Implements hook_field_storage_purge().

This function deletes data from the database for a single field on an entity.

Definition at line 479 of file field_sql_storage.module.

References _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), db_delete(), and entity_extract_ids().

Referenced by field_sql_storage_field_storage_delete(), and hook_field_storage_delete().

field_sql_storage_field_storage_purge_field ( $field )

Implements hook_field_storage_purge_field().

All field data items and instances have already been purged, so all that is left is to delete the table.

Definition at line 729 of file field_sql_storage.module.

References _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), and db_drop_table().

field_sql_storage_field_storage_query ( EntityFieldQuery $query )

Implements hook_field_storage_query().

Definition at line 497 of file field_sql_storage.module.

References _field_sql_storage_columnname(), _field_sql_storage_query_field_conditions(), _field_sql_storage_query_join_entity(), EntityFieldQuery::addCondition(), EntityFieldQuery::age(), db_select(), EntityFieldQuery::deleted(), drupal_static_reset(), FIELD_LOAD_CURRENT, and EntityFieldQuery::finishQuery().

field_sql_storage_field_storage_update_field | ( | $field,
 |  | $prior_field,
 |  | $has_data
 | ) |

Implements hook_field_storage_update_field().

Definition at line 236 of file field_sql_storage.module.

References $name, _field_sql_storage_columnname(), _field_sql_storage_indexname(), _field_sql_storage_revision_tablename(), _field_sql_storage_schema(), _field_sql_storage_tablename(), db_add_index(), db_create_table(), db_drop_index(), db_drop_table(), db_table_exists(), db_transaction(), drupal_get_schema(), and Database::getConnection().

field_sql_storage_field_storage_write | ( | $entity_type,
 |  | $entity,
 |  | $op,
 |  | $fields
 | ) |

Implements hook_field_storage_write().

Definition at line 377 of file field_sql_storage.module.

References $attributes, $op, _field_sql_storage_columnname(), _field_sql_storage_revision_tablename(), _field_sql_storage_tablename(), db_delete(), db_insert(), entity_extract_ids(), field_available_languages(), FIELD_CARDINALITY_UNLIMITED, field_info_field_by_id(), and FIELD_STORAGE_UPDATE.

field_sql_storage_field_update_forbid | ( | $field,
 |  | $prior_field,
 |  | $has_data
 | ) |

Implements hook_field_update_forbid().

Forbid any field update that changes column definitions if there is any data.

Definition at line 227 of file field_sql_storage.module.

field_sql_storage_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file field_sql_storage.module.

References $output, t(), and url().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/list Directory Reference

  • modules
  • field
  • modules
  • list
list Directory Reference

Files

file | list.install [code]
file | list.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/list/list.install File Reference

  • modules
  • field
  • modules
  • list
Functions
list.install File Reference

Go to the source code of this file.

Functions

list_field_schema ($field)
list_update_7001 ()
_list_update_7001_extract_allowed_values ($string, $position_keys)
list_update_7002 ()

Detailed Description

Install, update and uninstall functions for the list module.

Definition in file list.install.

Function Documentation

_list_update_7001_extract_allowed_values | ( | $string,
 |  | $position_keys
 | ) |

Helper function for list_update_7001: extract allowed values from a string.

This reproduces the parsing logic in use before D7 RC2.

Definition at line 96 of file list.install.

References $value.

Referenced by list_update_7001().

list_field_schema ( $field )

Implements hook_field_schema().

Definition at line 11 of file list.install.

list_update_7001 ( )

Rename the list field types and change 'allowed_values' format.

Definition at line 51 of file list.install.

References _list_update_7001_extract_allowed_values(), _update_7000_field_read_fields(), db_query(), and db_update().

Referenced by list_update_7002().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/list/list.module File Reference

  • modules
  • field
  • modules
  • list
Functions
list.module File Reference

Go to the source code of this file.

Functions

list_help ($path, $arg)
list_field_info ()
list_field_settings_form ($field, $instance, $has_data)
list_allowed_values_setting_validate ($element, &$form_state)
list_boolean_allowed_values_callback ($element, $input, $form_state)
list_field_update_field ($field, $prior_field, $has_data)
list_allowed_values ($field, $instance=NULL, $entity_type=NULL, $entity=NULL)
list_extract_allowed_values ($string, $field_type, $generate_keys)
list_allowed_values_string ($values)
list_field_update_forbid ($field, $prior_field, $has_data)
_list_values_in_use ($field, $values)
list_field_validate ($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
list_field_is_empty ($item, $field)
list_field_widget_info_alter (&$info)
list_options_list ($field, $instance, $entity_type, $entity)
list_field_formatter_info ()
list_field_formatter_view ($entity_type, $entity, $field, $instance, $langcode, $items, $display)

Detailed Description

Defines list field types that can be used with the Options module.

Definition in file list.module.

Function Documentation

_list_values_in_use | ( | $field,
 |  | $values
 | ) |

Checks if a list of values are being used in actual field values.

Definition at line 371 of file list.module.

Referenced by list_allowed_values_setting_validate(), and list_field_update_forbid().

list_allowed_values | ( | $field,
 |  | $instance = NULL,
 |  | $entity_type = NULL,
 |  | $entity = NULL
 | ) |

Returns the array of allowed values for a list field.

The strings are not safe for output. Keys and values of the array should be sanitized through field_filter_xss() before being displayed.

Parameters
$field | The field definition.
$instance | (optional) A field instance array. Defaults to NULL.
$entity_type | (optional) The type of entity; e.g. 'node' or 'user'. Defaults to NULL.
$entity | (optional) The entity object. Defaults to NULL.
Returns
The array of allowed values. Keys of the array are the raw stored values (number or text), values of the array are the display labels.

Definition at line 235 of file list.module.

References drupal_static().

Referenced by list_field_formatter_view(), list_field_validate(), and list_options_list().

list_allowed_values_setting_validate | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Element validate callback; check that the entered values are valid.

Definition at line 160 of file list.module.

References $value, _list_values_in_use(), drupal_strlen(), form_error(), form_set_value(), list_extract_allowed_values(), and t().

list_allowed_values_string ( $values )

Generates a string representation of an array of 'allowed values'.

This string format is suitable for edition in a textarea.

Parameters
$values An array of values, where array keys are values and array values are labels.
Returns
The string representation of the $values array:
  • Values are separated by a carriage return.
  • Each value is in the format "value|label" or "value".

Definition at line 347 of file list.module.

References $value.

Referenced by list_field_settings_form().

list_boolean_allowed_values_callback | ( | $element,
 |  | $input,
 |  | $form_state
 | ) |

Form element #value_callback: assembles the allowed values for 'boolean' fields.

Definition at line 203 of file list.module.

References drupal_array_get_nested_value().

list_extract_allowed_values | ( | $string,
 |  | $field_type,
 |  | $generate_keys
 | ) |

Parses a string of 'allowed values' into an array.

Parameters
$string | The list of allowed values in string format described in list_allowed_values_string().
$field_type | The field type. Either 'list_number' or 'list_text'.
$generate_keys | Boolean value indicating whether to generate keys based on the position of the value if a key is not manually specified, and if the value cannot be used as a key. This should only be TRUE for fields of type 'list_number'.
Returns
The array of extracted key/value pairs, or NULL if the string is invalid.
See Also
list_allowed_values_string()

Definition at line 280 of file list.module.

References $value.

Referenced by list_allowed_values_setting_validate().

list_field_formatter_info ( )

Implements hook_field_formatter_info().

Definition at line 444 of file list.module.

References t().

list_field_formatter_view | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance,
 |  | $langcode,
 |  | $items,
 |  | $display
 | ) |

Implements hook_field_formatter_view().

Definition at line 460 of file list.module.

References $output, field_filter_xss(), and list_allowed_values().

list_field_info ( )

Implements hook_field_info().

Definition at line 24 of file list.module.

References t().

list_field_is_empty | ( | $item,
 |  | $field
 | ) |

Implements hook_field_is_empty().

Definition at line 407 of file list.module.

list_field_settings_form | ( | $field,
 |  | $instance,
 |  | $has_data
 | ) |

Implements hook_field_settings_form().

Definition at line 60 of file list.module.

References _field_filter_xss_display_allowed_tags(), list_allowed_values_string(), and t().

list_field_update_field | ( | $field,
 |  | $prior_field,
 |  | $has_data
 | ) |

Implements hook_field_update_field().

Definition at line 212 of file list.module.

References drupal_static_reset().

list_field_update_forbid | ( | $field,
 |  | $prior_field,
 |  | $has_data
 | ) |

Implements hook_field_update_forbid().

Definition at line 358 of file list.module.

References _list_values_in_use(), and t().

list_field_validate | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  | & | $errors
 | ) |  |

Implements hook_field_validate().

Possible error codes:

  • 'list_illegal_value': The value is not part of the list of allowed values.

Definition at line 390 of file list.module.

References list_allowed_values(), and t().

list_field_widget_info_alter ( & $info )

Implements hook_field_widget_info_alter().

The List module does not implement widgets of its own, but reuses the widgets defined in options.module.

See Also
list_options_list()

Definition at line 422 of file list.module.

References $info.

list_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file list.module.

References $output, t(), and url().

list_options_list | ( | $field,
 |  | $instance,
 |  | $entity_type,
 |  | $entity
 | ) |

Implements hook_options_list().

Definition at line 437 of file list.module.

References list_allowed_values().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/number Directory Reference

  • modules
  • field
  • modules
  • number
number Directory Reference

Files

file | number.install [code]
file | number.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/number/number.install File Reference

  • modules
  • field
  • modules
  • number
Functions
number.install File Reference

Go to the source code of this file.

Functions

number_field_schema ($field)

Detailed Description

Install, update and uninstall functions for the number module.

Definition in file number.install.

Function Documentation

number_field_schema ( $field )

Implements hook_field_schema().

Definition at line 11 of file number.install.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/number/number.module File Reference

  • modules
  • field
  • modules
  • number
Functions
number.module File Reference

Go to the source code of this file.

Functions

number_help ($path, $arg)
number_field_info ()
number_field_settings_form ($field, $instance, $has_data)
number_field_instance_settings_form ($field, $instance)
number_field_validate ($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
number_field_presave ($entity_type, $entity, $field, $instance, $langcode, &$items)
number_field_is_empty ($item, $field)
number_field_formatter_info ()
number_field_formatter_settings_form ($field, $instance, $view_mode, $form, &$form_state)
number_field_formatter_settings_summary ($field, $instance, $view_mode)
number_field_formatter_view ($entity_type, $entity, $field, $instance, $langcode, $items, $display)
number_field_widget_info ()
number_field_widget_form (&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
number_field_widget_validate ($element, &$form_state)
number_field_widget_error ($element, $error, $form, &$form_state)

Detailed Description

Defines numeric field types.

Definition in file number.module.

Function Documentation

number_field_formatter_info ( )

Implements hook_field_formatter_info().

Definition at line 182 of file number.module.

References t().

number_field_formatter_settings_form | ( |  | $field,
 |  |  | $instance,
 |  |  | $view_mode,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_field_formatter_settings_form().

Definition at line 221 of file number.module.

References drupal_map_assoc(), and t().

number_field_formatter_settings_summary | ( | $field,
 |  | $instance,
 |  | $view_mode
 | ) |

Implements hook_field_formatter_settings_summary().

Definition at line 268 of file number.module.

References t().

number_field_formatter_view | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance,
 |  | $langcode,
 |  | $items,
 |  | $display
 | ) |

Implements hook_field_formatter_view().

Definition at line 286 of file number.module.

References $output, and format_plural().

number_field_info ( )

Implements hook_field_info().

Definition at line 24 of file number.module.

References t().

number_field_instance_settings_form | ( | $field,
 |  | $instance
 | ) |

Implements hook_field_instance_settings_form().

Definition at line 93 of file number.module.

References t().

number_field_is_empty | ( | $item,
 |  | $field
 | ) |

Implements hook_field_is_empty().

Definition at line 172 of file number.module.

number_field_presave | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_presave().

Definition at line 157 of file number.module.

number_field_settings_form | ( | $field,
 |  | $instance,
 |  | $has_data
 | ) |

Implements hook_field_settings_form().

Definition at line 55 of file number.module.

References drupal_map_assoc(), and t().

number_field_validate | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  | & | $errors
 | ) |  |

Implements hook_field_validate().

Possible error codes:

  • 'number_min': The value is less than the allowed minimum value.
  • 'number_max': The value is greater than the allowed maximum value.

Definition at line 135 of file number.module.

References t().

number_field_widget_error | ( |  | $element,
 |  |  | $error,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_field_widget_error().

Definition at line 417 of file number.module.

References form_error().

number_field_widget_form | ( | & | $form,
 |  | & | $form_state,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  |  | $delta,
 |  |  | $element
 | ) |  |

Implements hook_field_widget_form().

Definition at line 331 of file number.module.

References $value, and field_filter_xss().

number_field_widget_info ( )

Implements hook_field_widget_info().

Definition at line 319 of file number.module.

References t().

number_field_widget_validate | ( |  | $element,
 |  | & | $form_state
 | ) |  |

FAPI validation of an individual number element.

Definition at line 368 of file number.module.

References $value, field_widget_field(), field_widget_instance(), form_error(), form_set_value(), and t().

number_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file number.module.

References $output, t(), and url().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/options Directory Reference

  • modules
  • field
  • modules
  • options
options Directory Reference

Files

file | options.api.php [code]
file | options.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/options/options.api.php File Reference

  • modules
  • field
  • modules
  • options
Functions
options.api.php File Reference

Go to the source code of this file.

Functions

hook_options_list ($field, $instance, $entity_type, $entity)

Detailed Description

Hooks provided by the Options module.

Definition in file options.api.php.

Function Documentation

hook_options_list | ( | $field,
 |  | $instance,
 |  | $entity_type,
 |  | $entity
 | ) |

Returns the list of options to be displayed for a field.

Field types willing to enable one or several of the widgets defined in options.module (select, radios/checkboxes, on/off checkbox) need to implement this hook to specify the list of options to display in the widgets.

Parameters
$field | The field definition.
$instance | (optional) The instance definition. The hook might be called without an $instance parameter in contexts where no specific instance can be targeted. It is recommended to only use instance level properties to filter out values from a list defined by field level properties.
$entity_type | The entity type the field is attached to.
$entity | The entity object the field is attached to, or NULL if no entity exists (e.g. in field settings page).
Returns
The array of options for the field. Array keys are the values to be stored, and should be of the data type (string, number...) expected by the first 'column' for the field type. Array values are the labels to display within the widgets. The labels should NOT be sanitized, options.module takes care of sanitation according to the needs of each widget. The HTML tags defined in _field_filter_xss_allowed_tags() are allowed, other tags will be filtered.

Definition at line 38 of file options.api.php.

References $tree, t(), and taxonomy_get_tree().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/options/options.module File Reference

  • modules
  • field
  • modules
  • options
Functions
options.module File Reference

Go to the source code of this file.

Functions

options_help ($path, $arg)
options_theme ()
options_field_widget_info ()
options_field_widget_form (&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
options_field_widget_settings_form ($field, $instance)
options_field_widget_validate ($element, &$form_state)
_options_properties ($type, $multiple, $required, $has_value)
_options_get_options ($field, $instance, $properties, $entity_type, $entity)
_options_prepare_options (&$options, $properties)
_options_storage_to_form ($items, $options, $column, $properties)
_options_form_to_storage ($element)
options_array_transpose ($array)
options_array_flatten ($array)
options_field_widget_error ($element, $error, $form, &$form_state)
theme_options_none ($variables)

Detailed Description

Defines selection, check box and radio button widgets for text and numeric fields.

Definition in file options.module.

Function Documentation

_options_form_to_storage ( $element )

Transforms submitted form values into field storage format.

Definition at line 303 of file options.module.

References options_array_transpose().

Referenced by options_field_widget_validate().

_options_get_options | ( | $field,
 |  | $instance,
 |  | $properties,
 |  | $entity_type,
 |  | $entity
 | ) |

Collects the options for a field.

Definition at line 243 of file options.module.

References _options_prepare_options(), module_invoke(), options_array_flatten(), and theme().

Referenced by options_field_widget_form().

_options_prepare_options | ( | & | $options,
 |  |  | $properties
 | ) |  |

Sanitizes the options.

The function is recursive to support optgroups.

Definition at line 267 of file options.module.

References $value, and field_filter_xss().

Referenced by _options_get_options().

_options_properties | ( | $type,
 |  | $multiple,
 |  | $required,
 |  | $has_value
 | ) |

Describes the preparation steps required by each widget.

Definition at line 184 of file options.module.

Referenced by options_field_widget_form().

_options_storage_to_form | ( | $items,
 |  | $options,
 |  | $column,
 |  | $properties
 | ) |

Transforms stored field values into the format the widgets need.

Definition at line 287 of file options.module.

References options_array_flatten(), and options_array_transpose().

Referenced by options_field_widget_form().

options_array_flatten ( $array )

Flattens an array of allowed values.

Parameters
$array A single or multidimensional array.
Returns
A flattened array.

Definition at line 368 of file options.module.

References $value.

Referenced by _options_get_options(), and _options_storage_to_form().

options_array_transpose ( $array )

Manipulates a 2D array to reverse rows and columns.

The default data storage for fields is delta first, column names second. This is sometimes inconvenient for field modules, so this function can be used to present the data in an alternate format.

Parameters
$array The array to be transposed. It must be at least two-dimensional, and the subarrays must all have the same keys or behavior is undefined.
Returns
The transposed array.

Definition at line 343 of file options.module.

Referenced by _options_form_to_storage(), and _options_storage_to_form().

options_field_widget_error | ( |  | $element,
 |  |  | $error,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_field_widget_error().

Definition at line 386 of file options.module.

References form_error().

options_field_widget_form | ( | & | $form,
 |  | & | $form_state,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  |  | $delta,
 |  |  | $element
 | ) |  |

Implements hook_field_widget_form().

Definition at line 71 of file options.module.

References _options_get_options(), _options_properties(), _options_storage_to_form(), and FIELD_CARDINALITY_UNLIMITED.

options_field_widget_info ( )

Implements hook_field_widget_info().

Field type modules willing to use those widgets should:

  • Use hook_field_widget_info_alter() to append their field own types to the list of types supported by the widgets,
  • Implement hook_options_list() to provide the list of options. See list.module.

Definition at line 41 of file options.module.

References FIELD_BEHAVIOR_CUSTOM, and t().

options_field_widget_settings_form | ( | $field,
 |  | $instance
 | ) |

Implements hook_field_widget_settings_form().

Definition at line 155 of file options.module.

References t().

options_field_widget_validate | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Form element validation handler for options element.

Definition at line 171 of file options.module.

References _options_form_to_storage(), form_error(), form_set_value(), and t().

options_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file options.module.

References $output, t(), and url().

options_theme ( )

Implements hook_theme().

Definition at line 24 of file options.module.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/text Directory Reference

  • modules
  • field
  • modules
  • text
text Directory Reference

Files

file | text.install [code]
file | text.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/text/text.install File Reference

  • modules
  • field
  • modules
  • text
Functions
text.install File Reference

Go to the source code of this file.

Functions

text_field_schema ($field)
text_update_7000 ()

Detailed Description

Install, update and uninstall functions for the text module.

Definition in file text.install.

Function Documentation

text_field_schema ( $field )

Implements hook_field_schema().

Definition at line 11 of file text.install.

text_update_7000 ( )

Change text field 'format' columns into varchar.

Definition at line 72 of file text.install.

References _update_7000_field_read_fields(), and db_change_field().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/text/text.module File Reference

  • modules
  • field
  • modules
  • text
Functions
text.module File Reference

Go to the source code of this file.

Functions

text_help ($path, $arg)
text_field_info ()
text_field_settings_form ($field, $instance, $has_data)
text_field_instance_settings_form ($field, $instance)
text_field_validate ($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
text_field_load ($entity_type, $entities, $field, $instances, $langcode, &$items)
text_field_is_empty ($item, $field)
text_field_formatter_info ()
text_field_formatter_settings_form ($field, $instance, $view_mode, $form, &$form_state)
text_field_formatter_settings_summary ($field, $instance, $view_mode)
text_field_formatter_view ($entity_type, $entity, $field, $instance, $langcode, $items, $display)
_text_sanitize ($instance, $langcode, $item, $column)
text_summary ($text, $format=NULL, $size=NULL)
text_field_widget_info ()
text_field_widget_settings_form ($field, $instance)
text_field_widget_form (&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
text_field_widget_error ($element, $error, $form, &$form_state)
text_field_prepare_translation ($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode)
text_filter_format_update ($format)
text_filter_format_disable ($format)

Detailed Description

Defines simple text field types.

Definition in file text.module.

Function Documentation

_text_sanitize | ( | $instance,
 |  | $langcode,
 |  | $item,
 |  | $column
 | ) |

Sanitizes the 'value' or 'summary' data of a text value.

Depending on whether the field instance uses text processing, data is run through check_plain() or check_markup().

Parameters
$instance | The instance definition.
$langcode | The language associated to $item.
$item | The field value to sanitize.
$column | The column to sanitize (either 'value' or 'summary').
Returns
The sanitized string.

Definition at line 313 of file text.module.

References check_markup(), and check_plain().

Referenced by comment_tokens(), hook_field_load(), node_tokens(), text_field_formatter_view(), and text_field_load().

text_field_formatter_info ( )

Implements hook_field_formatter_info().

Definition at line 181 of file text.module.

References t().

text_field_formatter_settings_form | ( |  | $field,
 |  |  | $instance,
 |  |  | $view_mode,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_field_formatter_settings_form().

Definition at line 218 of file text.module.

References t().

text_field_formatter_settings_summary | ( | $field,
 |  | $instance,
 |  | $view_mode
 | ) |

Implements hook_field_formatter_settings_summary().

Definition at line 241 of file text.module.

References t().

text_field_formatter_view | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance,
 |  | $langcode,
 |  | $items,
 |  | $display
 | ) |

Implements hook_field_formatter_view().

Definition at line 257 of file text.module.

References $output, _text_sanitize(), and text_summary().

text_field_info ( )

Implements hook_field_info().

Field settings:

  • max_length: the maximum length for a varchar field. Instance settings:
  • text_processing: whether text input filters should be used.
  • display_summary: whether the summary field should be displayed. When empty and not displayed the summary will take its value from the trimmed value of the main text field.

Definition at line 32 of file text.module.

References t().

text_field_instance_settings_form | ( | $field,
 |  | $instance
 | ) |

Implements hook_field_instance_settings_form().

Definition at line 87 of file text.module.

References t().

text_field_is_empty | ( | $item,
 |  | $field
 | ) |

Implements hook_field_is_empty().

Definition at line 171 of file text.module.

text_field_load | ( |  | $entity_type,
 |  |  | $entities,
 |  |  | $field,
 |  |  | $instances,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_load().

Where possible, generate the sanitized version of each field early so that it is cached in the field cache. This avoids looking up from the filter cache separately.

See Also
text_field_formatter_view()

Definition at line 153 of file text.module.

References _text_sanitize(), and filter_format_allowcache().

text_field_prepare_translation | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items,
 |  |  | $source_entity,
 |  |  | $source_langcode
 | ) |  |

Implements hook_field_prepare_translation().

Definition at line 584 of file text.module.

text_field_settings_form | ( | $field,
 |  | $instance,
 |  | $has_data
 | ) |

Implements hook_field_settings_form().

Definition at line 62 of file text.module.

References t().

text_field_validate | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  | & | $errors
 | ) |  |

Implements hook_field_validate().

Possible error codes:

  • 'text_value_max_length': The value exceeds the maximum length.
  • 'text_summary_max_length': The summary exceeds the maximum length.

Definition at line 118 of file text.module.

References drupal_strlen(), and t().

text_field_widget_error | ( |  | $element,
 |  |  | $error,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_field_widget_error().

Definition at line 567 of file text.module.

References form_error().

text_field_widget_form | ( | & | $form,
 |  | & | $form_state,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  |  | $delta,
 |  |  | $element
 | ) |  |

Implements hook_field_widget_form().

Definition at line 502 of file text.module.

References drupal_get_path(), and t().

text_field_widget_info ( )

Implements hook_field_widget_info().

Definition at line 450 of file text.module.

References t().

text_field_widget_settings_form | ( | $field,
 |  | $instance
 | ) |

Implements hook_field_widget_settings_form().

Definition at line 473 of file text.module.

References t().

text_filter_format_disable ( $format )

Implements hook_filter_format_disable().

Definition at line 609 of file text.module.

References field_cache_clear().

text_filter_format_update ( $format )

Implements hook_filter_format_update().

Definition at line 602 of file text.module.

References field_cache_clear().

text_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file text.module.

References $output, t(), and url().

text_summary | ( | $text,
 |  | $format = NULL,
 |  | $size = NULL
 | ) |

Generate a trimmed, formatted version of a text field value.

If the end of the summary is not indicated using the delimiter then we generate the summary automatically, trying to end it at a sensible place such as the end of a paragraph, a line break, or the end of a sentence (in that order of preference).

Parameters
$text | The content for which a summary will be generated.
$format | The format of the content. If the PHP filter is present and $text contains PHP code, we do not split it up to prevent parse errors. If the line break filter is present then we treat newlines embedded in $text as line breaks. If the htmlcorrector filter is present, it will be run on the generated summary (if different from the incoming $text).
$size | The desired character length of the summary. If omitted, the default value will be used. Ignored if the special delimiter is present in $text.
Returns
The generated summary.

Definition at line 347 of file text.module.

References _filter_htmlcorrector(), drupal_strlen(), filter_list_format(), truncate_utf8(), and variable_get().

Referenced by node_update_7006(), text_field_formatter_view(), and theme_aggregator_page_rss().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/theme Directory Reference

  • modules
  • field
  • theme
theme Directory Reference

Files

file field.tpl.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.api.php File Reference

  • modules
  • field
Functions
field.api.php File Reference

Go to the source code of this file.

Functions

hook_field_extra_fields ()
hook_field_extra_fields_alter (&$info)
hook_field_info ()
hook_field_info_alter (&$info)
hook_field_schema ($field)
hook_field_load ($entity_type, $entities, $field, $instances, $langcode, &$items, $age)
hook_field_prepare_view ($entity_type, $entities, $field, $instances, $langcode, &$items)
hook_field_validate ($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
hook_field_presave ($entity_type, $entity, $field, $instance, $langcode, &$items)
hook_field_insert ($entity_type, $entity, $field, $instance, $langcode, &$items)
hook_field_update ($entity_type, $entity, $field, $instance, $langcode, &$items)
hook_field_storage_update_field ($field, $prior_field, $has_data)
hook_field_delete ($entity_type, $entity, $field, $instance, $langcode, &$items)
hook_field_delete_revision ($entity_type, $entity, $field, $instance, $langcode, &$items)
hook_field_prepare_translation ($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode)
hook_field_is_empty ($item, $field)
hook_field_widget_info ()
hook_field_widget_info_alter (&$info)
hook_field_widget_form (&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
hook_field_widget_form_alter (&$element, &$form_state, $context)
hook_field_widget_WIDGET_TYPE_form_alter (&$element, &$form_state, $context)
hook_field_widget_properties_alter (&$widget, $context)
hook_field_widget_error ($element, $error, $form, &$form_state)
hook_field_formatter_info ()
hook_field_formatter_info_alter (&$info)
hook_field_formatter_prepare_view ($entity_type, $entities, $field, $instances, $langcode, &$items, $displays)
hook_field_formatter_view ($entity_type, $entity, $field, $instance, $langcode, $items, $display)
hook_field_storage_info ()
hook_field_storage_info_alter (&$info)
hook_field_storage_details ($field)
hook_field_storage_details_alter (&$details, $field)
hook_field_storage_load ($entity_type, $entities, $age, $fields, $options)
hook_field_storage_write ($entity_type, $entity, $op, $fields)
hook_field_storage_delete ($entity_type, $entity, $fields)
hook_field_storage_delete_revision ($entity_type, $entity, $fields)
hook_field_storage_query ($query)
hook_field_storage_create_field ($field)
hook_field_storage_delete_field ($field)
hook_field_storage_delete_instance ($instance)
hook_field_storage_pre_load ($entity_type, $entities, $age, &$skip_fields, $options)
hook_field_storage_pre_insert ($entity_type, $entity, &$skip_fields)
hook_field_storage_pre_update ($entity_type, $entity, &$skip_fields)
hook_field_info_max_weight ($entity_type, $bundle, $context)
hook_field_display_alter (&$display, $context)
hook_field_display_ENTITY_TYPE_alter (&$display, $context)
hook_field_extra_fields_display_alter (&$displays, $context)
hook_field_widget_properties_ENTITY_TYPE_alter (&$widget, $context)
hook_field_create_field ($field)
hook_field_create_instance ($instance)
hook_field_update_forbid ($field, $prior_field, $has_data)
hook_field_update_field ($field, $prior_field, $has_data)
hook_field_delete_field ($field)
hook_field_update_instance ($instance, $prior_instance)
hook_field_delete_instance ($instance)
hook_field_read_field ($field)
hook_field_read_instance ($instance)
hook_field_purge_field ($field)
hook_field_purge_instance ($instance)
hook_field_storage_purge_field ($field)
hook_field_storage_purge_field_instance ($instance)
hook_field_storage_purge ($entity_type, $entity, $field, $instance)
hook_field_access ($op, $field, $entity_type, $entity, $account)
hook_field_attach_form ($entity_type, $entity, &$form, &$form_state, $langcode)
hook_field_attach_load ($entity_type, $entities, $age, $options)
hook_field_attach_validate ($entity_type, $entity, &$errors)
hook_field_attach_submit ($entity_type, $entity, $form, &$form_state)
hook_field_attach_presave ($entity_type, $entity)
hook_field_attach_insert ($entity_type, $entity)
hook_field_attach_update ($entity_type, $entity)
hook_field_attach_preprocess_alter (&$variables, $context)
hook_field_attach_delete ($entity_type, $entity)
hook_field_attach_delete_revision ($entity_type, $entity)
hook_field_attach_purge ($entity_type, $entity, $field, $instance)
hook_field_attach_view_alter (&$output, $context)
hook_field_attach_prepare_translation_alter (&$entity, $context)
hook_field_language_alter (&$display_language, $context)
hook_field_available_languages_alter (&$languages, $context)
hook_field_attach_create_bundle ($entity_type, $bundle)
hook_field_attach_rename_bundle ($entity_type, $bundle_old, $bundle_new)
hook_field_attach_delete_bundle ($entity_type, $bundle, $instances)
Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.attach.inc File Reference

  • modules
  • field
Classes | Functions | Variables
field.attach.inc File Reference

Go to the source code of this file.

Classes

class FieldValidationException

Functions

_field_invoke ($op, $entity_type, $entity, &$a=NULL, &$b=NULL, $options=array())
_field_invoke_multiple ($op, $entity_type, $entities, &$a=NULL, &$b=NULL, $options=array())
_field_invoke_default ($op, $entity_type, $entity, &$a=NULL, &$b=NULL, $options=array())
_field_invoke_multiple_default ($op, $entity_type, $entities, &$a=NULL, &$b=NULL, $options=array())
_field_invoke_get_instances ($entity_type, $bundle, $options)
field_attach_form ($entity_type, $entity, &$form, &$form_state, $langcode=NULL, $options=array())
field_attach_load ($entity_type, $entities, $age=FIELD_LOAD_CURRENT, $options=array())
field_attach_load_revision ($entity_type, $entities, $options=array())
field_attach_validate ($entity_type, $entity, $options=array())
field_attach_form_validate ($entity_type, $entity, $form, &$form_state, $options=array())
field_attach_submit ($entity_type, $entity, $form, &$form_state, $options=array())
field_attach_presave ($entity_type, $entity)
field_attach_insert ($entity_type, $entity)
field_attach_update ($entity_type, $entity)
field_attach_delete ($entity_type, $entity)
field_attach_delete_revision ($entity_type, $entity)
field_attach_prepare_view ($entity_type, $entities, $view_mode, $langcode=NULL, $options=array())
field_attach_view ($entity_type, $entity, $view_mode, $langcode=NULL, $options=array())
field_attach_preprocess ($entity_type, $entity, $element, &$variables)
field_attach_prepare_translation ($entity_type, $entity, $langcode, $source_entity, $source_langcode)
field_attach_create_bundle ($entity_type, $bundle)
field_attach_rename_bundle ($entity_type, $bundle_old, $bundle_new)
field_attach_delete_bundle ($entity_type, $bundle)

Variables

const | FIELD_STORAGE_UPDATE 'update'
const | FIELD_STORAGE_INSERT 'insert'

Detailed Description

Field attach API, allowing entities (nodes, users, ...) to be 'fieldable'.

Definition in file field.attach.inc.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.crud.inc File Reference

  • modules
  • field
Functions
field.crud.inc File Reference

Go to the source code of this file.

Functions

field_create_field ($field)
field_update_field ($field)
field_read_field ($field_name, $include_additional=array())
field_read_fields ($params=array(), $include_additional=array())
field_delete_field ($field_name)
field_create_instance ($instance)
field_update_instance ($instance)
_field_write_instance ($instance, $update=FALSE)
field_read_instance ($entity_type, $field_name, $bundle, $include_additional=array())
field_read_instances ($params=array(), $include_additional=array())
field_delete_instance ($instance, $field_cleanup=TRUE)
field_purge_batch ($batch_size)
field_purge_data ($entity_type, $entity, $field, $instance)
field_purge_instance ($instance)
field_purge_field ($field)

Detailed Description

Field CRUD API, handling field and field instance creation and deletion.

Definition in file field.crud.inc.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.default.inc File Reference

  • modules
  • field
Functions
field.default.inc File Reference

Go to the source code of this file.

Functions

field_default_extract_form_values ($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state)
field_default_validate ($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
field_default_submit ($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state)
field_default_insert ($entity_type, $entity, $field, $instance, $langcode, &$items)
field_default_prepare_view ($entity_type, $entities, $field, $instances, $langcode, &$items, $display)
field_default_view ($entity_type, $entity, $field, $instance, $langcode, $items, $display)
field_default_prepare_translation ($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode)

Detailed Description

Default 'implementations' of hook_field_*(): common field housekeeping.

Those implementations are special, as field.module does not define any field types. Those functions take care of default stuff common to all field types. They are called through the field_invoke_default() iterator, generally in the corresponding field_attach[operation]() function.

Definition in file field.default.inc.

Function Documentation

field_default_extract_form_values | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Extracts field values from submitted form values.

Parameters
$entity_type | The type of $entity.
$entity | The entity for the operation.
$field | The field structure for the operation.
$instance | The instance structure for $field on $entity's bundle.
$langcode | The language associated to $items.
$items | The field values. This parameter is altered by reference to receive the incoming form values.
$form | The form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form.
$form_state | The form state.

Definition at line 35 of file field.default.inc.

References drupal_array_get_nested_value().

Referenced by field_ui_field_edit_form_submit(), and field_ui_field_edit_form_validate().

field_default_insert | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Default field 'insert' operation.

Insert default value if no $entity->$field_name entry was provided. This can happen with programmatic saves, or on form-based creation where the current user doesn't have 'edit' permission for the field.

Definition at line 103 of file field.default.inc.

field_default_prepare_translation | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items,
 |  |  | $source_entity,
 |  |  | $source_langcode
 | ) |  |

Copies source field values into the entity to be prepared.

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | The entity to be prepared for translation.
$field | The field structure for the operation.
$instance | The instance structure for $field on $entity's bundle.
$langcode | The language the entity has to be translated in.
$items | $entity->{$field['field_name']}[$langcode], or an empty array if unset.
$source_entity | The source entity holding the field values to be translated.
$source_langcode | The source language from which translate.

Definition at line 259 of file field.default.inc.

References LANGUAGE_NONE.

field_default_prepare_view | ( |  | $entity_type,
 |  |  | $entities,
 |  |  | $field,
 |  |  | $instances,
 |  |  | $langcode,
 |  | & | $items,
 |  |  | $display
 | ) |  |

Invokes hook_field_formatter_prepare_view() on the relevant formatters.

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entities | An array of entities being displayed, keyed by entity id.
$field | The field structure for the operation.
$instances | Array of instance structures for $field for each entity, keyed by entity id.
$langcode | The language associated to $items.
$items | Array of field values already loaded for the entities, keyed by entity id.
$display Can be either:
  • the name of a view mode
  • or an array of display settings to use for display, as found in the 'display' entry of $instance definitions.

Definition at line 138 of file field.default.inc.

References $module, and field_get_display().

field_default_submit | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 89 of file field.default.inc.

References _field_filter_items(), and _field_sort_items().

Referenced by field_ui_field_edit_form_submit().

field_default_validate | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  | & | $errors
 | ) |  |

Generic field validation handler.

Possible error codes:

  • 'field_cardinality': The number of values exceeds the field cardinality.
See Also
_hook_field_validate()
Parameters
$entity_type | The type of $entity.
$entity | The entity for the operation.
$field | The field structure for the operation.
$instance | The instance structure for $field on $entity's bundle.
$langcode | The language associated to $items.
$items | $entity->{$field['field_name']}[$langcode], or an empty array if unset.
$errors The array of errors, keyed by field name and by value delta, that have already been reported for the entity. The function should add its errors to this array. Each error is an associative array, with the following keys and values:
  • 'error': an error code (should be a string, prefixed with the module name)
  • 'message': the human readable message to be displayed.

Definition at line 74 of file field.default.inc.

References _field_filter_items(), FIELD_CARDINALITY_UNLIMITED, and t().

field_default_view | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance,
 |  | $langcode,
 |  | $items,
 |  | $display
 | ) |

Builds a renderable array for one field on one entity instance.

Parameters
$entity_type | The type of $entity; e.g. 'node' or 'user'.
$entity | A single object of type $entity_type.
$field | The field structure for the operation.
$instance | An array containing each field on $entity's bundle.
$langcode | The language associated to $items.
$items | Array of field values already loaded for the entities, keyed by entity id.
$display Can be either:
  • the name of a view mode;
  • or an array of custom display settings, as found in the 'display' entry of $instance definitions.

Definition at line 191 of file field.default.inc.

References $info, entity_extract_ids(), field_access(), and field_get_display().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.form.inc File Reference

  • modules
  • field
Functions
field.form.inc File Reference

Go to the source code of this file.

Functions

field_default_form ($entity_type, $entity, $field, $instance, $langcode, $items, &$form, &$form_state, $get_delta=NULL)
field_multiple_value_form ($field, $instance, $langcode, $items, &$form, &$form_state)
theme_field_multiple_value_form ($variables)
field_form_element_after_build ($element, &$form_state)
field_default_form_errors ($entity_type, $entity, $field, $instance, $langcode, $items, $form, &$form_state)
field_add_more_submit ($form, &$form_state)
field_add_more_js ($form, $form_state)
field_form_get_state ($parents, $field_name, $langcode, &$form_state)
field_form_set_state ($parents, $field_name, $langcode, &$form_state, $field_state)
_field_form_state_parents ($parents, $field_name, $langcode)
field_widget_field ($element, $form_state)
field_widget_instance ($element, $form_state)

Detailed Description

Field forms management.

Definition in file field.form.inc.

Function Documentation

_field_form_state_parents | ( | $parents,
 |  | $field_name,
 |  | $langcode
 | ) |

Returns the location of processing information within $form_state.

Definition at line 535 of file field.form.inc.

Referenced by field_form_get_state(), and field_form_set_state().

field_add_more_js | ( | $form,
 |  | $form_state
 | ) |

Ajax callback in response to a new empty widget being added to the form.

This returns the new page content to replace the page content made obsolete by the form submission.

See Also
field_add_more_submit()

Definition at line 457 of file field.form.inc.

References drupal_array_get_nested_value(), FIELD_CARDINALITY_UNLIMITED, and field_form_get_state().

field_add_more_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for the "Add another item" button of a field form.

This handler is run regardless of whether JS is enabled or not. It makes changes to the form state. If the button was clicked with JS disabled, then the page is reloaded with the complete rebuilt form. If the button was clicked with JS enabled, then ajax_form_callback() calls field_add_more_js() to return just the changed part of the form.

Definition at line 432 of file field.form.inc.

References drupal_array_get_nested_value(), field_form_get_state(), and field_form_set_state().

field_default_form | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  | & | $form,
 |  | & | $form_state,
 |  |  | $get_delta = NULL
 | ) |  |

Creates a form element for a field and can populate it with a default value.

If the form element is not associated with an entity (i.e., $entity is NULL) field_get_default_value will be called to supply the default value for the field. Also allows other modules to alter the form element by implementing their own hooks.

Parameters
$entity_type | The type of entity (for example 'node' or 'user') that the field belongs to.
$entity | The entity object that the field belongs to. This may be NULL if creating a form element with a default value.
$field | An array representing the field whose editing element is being created.
$instance | An array representing the structure for $field in its current context.
$langcode | The language associated with the field.
$items | An array of the field values. When creating a new entity this may be NULL or an empty array to use default values.
$form | An array representing the form that the editing element will be attached to.
$form_state | An array containing the current state of the form.
$get_delta | Used to get only a specific delta value of a multiple value field.
Returns
The form element array created for this field.

Definition at line 42 of file field.form.inc.

References check_plain(), drupal_alter(), drupal_html_class(), entity_extract_ids(), field_access(), FIELD_BEHAVIOR_DEFAULT, field_behaviors_widget(), field_filter_xss(), field_form_get_state(), field_form_set_state(), field_get_default_value(), and field_multiple_value_form().

Referenced by field_ui_default_value_widget().

field_default_form_errors | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Transfer field-level validation errors to widgets.

Definition at line 389 of file field.form.inc.

References drupal_array_get_nested_value(), FIELD_BEHAVIOR_DEFAULT, field_behaviors_widget(), field_form_get_state(), field_form_set_state(), and form_error().

Referenced by field_ui_field_edit_form_validate().

field_form_element_after_build | ( |  | $element,
 |  | & | $form_state
 | ) |  |

#after_build callback for field elements in a form.

This stores the final location of the field within the form structure so that field_default_form_errors() can assign validation errors to the right form element.

See Also
field_default_form_errors()

Definition at line 374 of file field.form.inc.

References field_form_get_state(), and field_form_set_state().

field_form_get_state | ( |  | $parents,
 |  |  | $field_name,
 |  |  | $langcode,
 |  | & | $form_state
 | ) |  |

Retrieves processing information about a field from $form_state.

Parameters
$parents | The array of #parents where the field lives in the form.
$field_name | The field name.
$langcode | The language in which the field values are entered.
$form_state | The form state.
Returns
An array with the following key/data pairs:
  • field: the field definition array,
  • instance: the field instance definition array,
  • items_count: the number of widgets to display for the field,
  • array_parents: the location of the field's widgets within the $form structure. This entry is populated at '#after_build' time.
  • errors: the array of field validation errors reported on the field. This entry is populated at field_attach_form_validate() time.
See Also
field_form_set_state()

Definition at line 505 of file field.form.inc.

References _field_form_state_parents(), and drupal_array_get_nested_value().

Referenced by field_add_more_js(), field_add_more_submit(), field_attach_form_validate(), field_default_form(), field_default_form_errors(), field_form_element_after_build(), field_multiple_value_form(), field_ui_field_edit_form_validate(), field_widget_field(), field_widget_instance(), file_field_widget_form(), and file_field_widget_submit().

field_form_set_state | ( |  | $parents,
 |  |  | $field_name,
 |  |  | $langcode,
 |  | & | $form_state,
 |  |  | $field_state
 | ) |  |

Stores processing information about a field in $form_state.

Parameters
$parents | The array of #parents where the field lives in the form.
$field_name | The field name.
$langcode | The language in which the field values are entered.
$form_state | The form state.
$field_state | The array of data to store. See field_form_get_state() for the structure and content of the array.
See Also
field_form_get_state()

Definition at line 527 of file field.form.inc.

References _field_form_state_parents(), and drupal_array_set_nested_value().

Referenced by field_add_more_submit(), field_attach_form_validate(), field_default_form(), field_default_form_errors(), field_form_element_after_build(), field_ui_field_edit_form_validate(), and file_field_widget_submit().

field_multiple_value_form | ( |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  | & | $form,
 |  | & | $form_state
 | ) |  |

Special handling to create form elements for multiple values.

Handles generic features for multiple fields:

  • number of widgets
  • AHAH-'add more' button
  • drag-n-drop value reordering

Definition at line 180 of file field.form.inc.

References $title, check_plain(), drupal_alter(), drupal_html_id(), FIELD_CARDINALITY_UNLIMITED, field_filter_xss(), field_form_get_state(), and t().

Referenced by field_default_form().

field_widget_field | ( | $element,
 |  | $form_state
 | ) |

Retrieves the field definition for a widget's helper callbacks.

Widgets helper element callbacks (such as #process, #element_validate, #value_callback, ...) should use field_widget_field() and field_widget_instance() instead of field_info_field() and field_info_instance() when they need to access field or instance properties. See hook_field_widget_form() for more details.

Parameters
$element | The structured array for the widget.
$form_state | The form state.
Returns
The $field definition array for the current widget.
See Also
field_widget_instance()
hook_field_widget_form()

Definition at line 576 of file field.form.inc.

References field_form_get_state().

Referenced by file_field_widget_process(), file_field_widget_value(), number_field_widget_validate(), and taxonomy_autocomplete_validate().

field_widget_instance | ( | $element,
 |  | $form_state
 | ) |

Retrieves the instance definition array for a widget's helper callbacks.

Widgets helper element callbacks (such as #process, #element_validate, #value_callback, ...) should use field_widget_field() and field_widget_instance() instead of field_info_field() and field_info_instance() when they need to access field or instance properties. See hook_field_widget_form() for more details.

Parameters
$element | The structured array for the widget.
$form_state | The form state.
Returns
The $instance definition array for the current widget.
See Also
field_widget_field()
hook_field_widget_form()

Definition at line 601 of file field.form.inc.

References field_form_get_state().

Referenced by file_field_widget_process(), image_field_widget_process(), and number_field_widget_validate().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.info.class.inc File Reference

  • modules
  • field
Classes
field.info.class.inc File Reference

Go to the source code of this file.

Classes

class FieldInfo
Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.info.inc File Reference

  • modules
  • field
Functions
field.info.inc File Reference

Go to the source code of this file.

Functions

_field_info_field_cache ()
field_info_cache_clear ()
_field_info_collate_fields ($reset=FALSE)
_field_info_collate_types ($reset=FALSE)
_field_info_prepare_field ($field)
_field_info_prepare_instance ($instance, $field)
_field_info_prepare_instance_display ($field, $display)
_field_info_prepare_instance_widget ($field, $widget)
_field_info_prepare_extra_fields ($extra_fields, $entity_type, $bundle)
field_behaviors_widget ($op, $instance)
field_info_field_types ($field_type=NULL)
field_info_widget_types ($widget_type=NULL)
field_info_formatter_types ($formatter_type=NULL)
field_info_storage_types ($storage_type=NULL)
field_info_bundles ($entity_type=NULL)
field_info_field_map ()
field_info_fields ()
field_info_field ($field_name)
field_info_field_by_id ($field_id)
field_info_field_by_ids ()
field_info_instances ($entity_type=NULL, $bundle_name=NULL)
field_info_instance ($entity_type, $field_name, $bundle_name)
field_info_extra_fields ($entity_type, $bundle, $context)
field_info_max_weight ($entity_type, $bundle, $context)
field_info_field_settings ($type)
field_info_instance_settings ($type)
field_info_widget_settings ($type)
field_info_formatter_settings ($type)
field_info_storage_settings ($type)

Detailed Description

Field Info API, providing information about available fields and field types.

Definition in file field.info.inc.

Function Documentation

_field_info_field_cache ( )

Retrieves the FieldInfo object for the current request.

Returns
FieldInfo An instance of the FieldInfo class.

Definition at line 14 of file field.info.inc.

References drupal_static().

Referenced by _field_info_collate_fields(), _field_info_prepare_extra_fields(), _field_info_prepare_field(), _field_info_prepare_instance(), _field_info_prepare_instance_display(), _field_info_prepare_instance_widget(), field_info_cache_clear(), field_info_extra_fields(), field_info_field(), field_info_field_by_id(), field_info_field_by_ids(), field_info_field_map(), field_info_fields(), field_info_instance(), field_info_instances(), and field_view_field().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.install File Reference

  • modules
  • field
Functions
field.install File Reference

Go to the source code of this file.

Functions

field_schema ()
_update_7000_field_create_field (&$field)
_update_7000_field_delete_field ($field_name)
_update_7000_field_delete_instance ($field_name, $entity_type, $bundle)
_update_7000_field_read_fields (array $conditions=array(), $key= 'id')
_update_7000_field_create_instance ($field, &$instance)
field_update_7000 ()
field_update_7001 ()
field_update_7002 ()
field_update_7003 ()

Detailed Description

Install, update and uninstall functions for the field module.

Definition in file field.install.

Function Documentation

field_schema ( )

Implements hook_schema().

Definition at line 11 of file field.install.

References drupal_get_schema_unprocessed().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.module File Reference

  • modules
  • field
Classes | Functions | Variables
field.module File Reference

Go to the source code of this file.

Classes

class | FieldException
class | FieldUpdateForbiddenException

Functions

field_help ($path, $arg)
field_theme ()
field_cron ()
field_modules_uninstalled ($modules)
field_system_info_alter (&$info, $file, $type)
field_flush_caches ()
field_modules_enabled ($modules)
field_modules_disabled ($modules)
field_sync_field_status ()
field_associate_fields ($module)
field_get_default_value ($entity_type, $entity, $field, $instance, $langcode=NULL)
_field_filter_items ($field, $items)
_field_sort_items ($field, $items)
_field_sort_items_helper ($a, $b)
_field_sort_items_value_helper ($a, $b)
field_bundle_settings ($entity_type, $bundle, $settings=NULL)
field_view_mode_settings ($entity_type, $bundle)
field_get_display ($instance, $view_mode, $entity)
field_extra_fields_get_display ($entity_type, $bundle, $view_mode)
_field_extra_fields_pre_render ($elements)
field_cache_clear ()
field_filter_xss ($string)
_field_filter_xss_allowed_tags ()
_field_filter_xss_display_allowed_tags ()
field_view_value ($entity_type, $entity, $field_name, $item, $display=array(), $langcode=NULL)
field_view_field ($entity_type, $entity, $field_name, $display=array(), $langcode=NULL)
field_get_items ($entity_type, $entity, $field_name, $langcode=NULL)
field_has_data ($field)
field_access ($op, $field, $entity_type, $entity=NULL, $account=NULL)
field_extract_bundle ($entity_type, $bundle)
template_preprocess_field (&$variables, $hook)
template_process_field (&$variables, $hook)
theme_field ($variables)
_element_validate_integer ($element, &$form_state)
_element_validate_integer_positive ($element, &$form_state)
_element_validate_number ($element, &$form_state)

Variables

const | FIELD_CARDINALITY_UNLIMITED -1
const | FIELD_BEHAVIOR_NONE 0x0001
const | FIELD_BEHAVIOR_DEFAULT 0x0002
const | FIELD_BEHAVIOR_CUSTOM 0x0004
const | FIELD_LOAD_CURRENT 'FIELD_LOAD_CURRENT'
const | FIELD_LOAD_REVISION 'FIELD_LOAD_REVISION'

Detailed Description

Attach custom data fields to Drupal entities.

Definition in file field.module.

Function Documentation

_element_validate_integer | ( |  | $element,
 |  | & | $form_state
 | ) |  |

DEPRECATED: Helper form element validator: integer.

Use element_validate_integer() instead.

Deprecated:
See Also
element_validate_integer()

Definition at line 1191 of file field.module.

References element_validate_integer().

_element_validate_integer_positive | ( |  | $element,
 |  | & | $form_state
 | ) |  |

DEPRECATED: Helper form element validator: integer > 0.

Use element_validate_integer_positive() instead.

Deprecated:
See Also
element_validate_integer_positive()

Definition at line 1203 of file field.module.

References element_validate_integer_positive().

_element_validate_number | ( |  | $element,
 |  | & | $form_state
 | ) |  |

DEPRECATED: Helper form element validator: number.

Use element_validate_number() instead.

Deprecated:
See Also
element_validate_number()

Definition at line 1215 of file field.module.

References element_validate_number().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.multilingual.inc File Reference

  • modules
  • field
Functions
field.multilingual.inc File Reference

Go to the source code of this file.

Functions

field_multilingual_settings_changed ()
field_available_languages ($entity_type, $field)
_field_language_suggestion ($available_languages, $language_suggestion, $field_name)
field_content_languages ()
field_is_translatable ($entity_type, $field)
field_has_translation_handler ($entity_type, $handler=NULL)
field_valid_language ($langcode, $default=TRUE)
field_language ($entity_type, $entity, $field_name=NULL, $langcode=NULL)

Detailed Description

Functions implementing Field API multilingual support.

Definition in file field.multilingual.inc.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field_ui Directory Reference

  • modules
  • field_ui
field_ui Directory Reference

Files

file | field_ui.admin.inc [code]
file | field_ui.api.php [code]
file | field_ui.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field_ui/field_ui.admin.inc File Reference

  • modules
  • field_ui
Functions
field_ui.admin.inc File Reference

Go to the source code of this file.

Functions

field_ui_fields_list ()
field_ui_inactive_message ($entity_type, $bundle)
_field_ui_reduce_order ($array, $a)
field_ui_field_overview_row_region ($row)
field_ui_display_overview_row_region ($row)
field_ui_table_pre_render ($elements)
theme_field_ui_table ($variables)
field_ui_field_overview_form ($form, &$form_state, $entity_type, $bundle)
field_ui_field_overview_form_validate ($form, &$form_state)
_field_ui_field_overview_form_validate_add_new ($form, &$form_state)
_field_ui_field_name_exists ($value)
_field_ui_field_overview_form_validate_add_existing ($form, &$form_state)
field_ui_field_overview_form_submit ($form, &$form_state)
field_ui_display_overview_form ($form, &$form_state, $entity_type, $bundle, $view_mode)
field_ui_display_overview_multistep_submit ($form, &$form_state)
field_ui_display_overview_multistep_js ($form, &$form_state)
field_ui_display_overview_form_submit ($form, &$form_state)
_field_ui_add_default_view_mode_settings ($entity_type, $bundle, $view_mode, &$settings)
field_ui_field_type_options ()
field_ui_widget_type_options ($field_type=NULL, $by_label=FALSE)
field_ui_formatter_options ($field_type=NULL)
field_ui_existing_field_options ($entity_type, $bundle)
field_ui_field_settings_form ($form, &$form_state, $instance)
field_ui_field_settings_form_submit ($form, &$form_state)
field_ui_widget_type_form ($form, &$form_state, $instance)
field_ui_widget_type_form_submit ($form, &$form_state)
field_ui_field_delete_form ($form, &$form_state, $instance)
field_ui_field_delete_form_submit ($form, &$form_state)
field_ui_field_edit_form ($form, &$form_state, $instance)
field_ui_field_edit_instance_pre_render ($element)
field_ui_default_value_widget ($field, $instance, &$form, &$form_state)
field_ui_field_edit_form_validate ($form, &$form_state)
field_ui_field_edit_form_submit ($form, &$form_state)
field_ui_get_destinations ($destinations)
field_ui_next_destination ($entity_type, $bundle)

Detailed Description

Administrative interface for custom field type creation.

Definition in file field_ui.admin.inc.

Function Documentation

_field_ui_add_default_view_mode_settings | ( |  | $entity_type,
 |  |  | $bundle,
 |  |  | $view_mode,
 |  | & | $settings
 | ) |  |

Populates display settings for a new view mode from the default view mode.

When an administrator decides to use custom display settings for a view mode, that view mode needs to be initialized with the display settings for the 'default' view mode, which it was previously using. This helper function adds the new custom display settings to this bundle's instances, and saves them. It also modifies the passed-in $settings array, which the caller can then save using field_bundle_settings().

Parameters
$entity_type | The bundle's entity type.
$bundle | The bundle whose view mode is being customized.
$view_mode | The view mode that the administrator has set to use custom settings.
$settings | An associative array of bundle settings, as expected by field_bundle_settings().
See Also
field_ui_display_overview_form_submit().
field_bundle_settings()

Definition at line 1412 of file field_ui.admin.inc.

References $name, field_read_instances(), and field_update_instance().

Referenced by field_ui_display_overview_form_submit().

_field_ui_field_name_exists ( $value )

Render API callback: Checks if a field machine name is taken.

Parameters
$value The machine name, not prefixed with 'field_'.
Returns
Whether or not the field machine name is taken.

Definition at line 722 of file field_ui.admin.inc.

References $value, and field_read_fields().

_field_ui_field_overview_form_validate_add_existing | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validates the 'add existing field' row of field_ui_field_overview_form().

See Also
field_ui_field_overview_form_validate()

Definition at line 736 of file field_ui.admin.inc.

References field_info_field(), field_ui_widget_type_options(), form_set_error(), and t().

Referenced by field_ui_field_overview_form_validate().

_field_ui_field_overview_form_validate_add_new | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validates the 'add new field' row of field_ui_field_overview_form().

See Also
field_ui_field_overview_form_validate()

Definition at line 671 of file field_ui.admin.inc.

References field_ui_widget_type_options(), form_set_error(), form_set_value(), and t().

Referenced by field_ui_field_overview_form_validate().

_field_ui_reduce_order | ( | $array,
 |  | $a
 | ) |

Determines the rendering order of an array representing a tree.

Callback for array_reduce() within field_ui_table_pre_render().

Definition at line 79 of file field_ui.admin.inc.

field_ui_default_value_widget | ( |  | $field,
 |  |  | $instance,
 |  | & | $form,
 |  | & | $form_state
 | ) |  |

Builds the default value fieldset for a given field instance.

Definition at line 1982 of file field_ui.admin.inc.

References field_default_form(), LANGUAGE_NONE, and t().

Referenced by field_ui_field_edit_form().

field_ui_display_overview_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for field_ui_display_overview_form().

Definition at line 1314 of file field_ui.admin.inc.

References $name, $value, _field_ui_add_default_view_mode_settings(), _field_ui_bundle_admin_path(), drupal_set_message(), entity_get_info(), field_bundle_settings(), field_info_formatter_settings(), field_read_instance(), field_update_instance(), field_view_mode_settings(), t(), and url().

field_ui_display_overview_multistep_js | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Ajax handler for multistep buttons on the 'Manage display' screen.

Definition at line 1276 of file field_ui.admin.inc.

References $name, and $op.

field_ui_display_overview_multistep_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for buttons in field_ui_display_overview_form().

Definition at line 1236 of file field_ui.admin.inc.

References $op.

field_ui_display_overview_row_region ( $row )

Returns the region to which a row in the 'Manage display' screen belongs.

This function is used as a #region_callback in field_ui_field_overview_form(), and is called during field_ui_table_pre_render().

Definition at line 117 of file field_ui.admin.inc.

References $row.

field_ui_existing_field_options | ( | $entity_type,
 |  | $bundle
 | ) |

Returns an array of existing fields to be added to a bundle.

Definition at line 1523 of file field_ui.admin.inc.

References $info, field_info_field(), field_info_field_types(), field_info_instance(), and field_info_instances().

Referenced by field_ui_field_overview_form().

field_ui_field_delete_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for field_ui_field_delete_form().

Removes a field instance from a bundle. If the field has no more instances, it will be marked as deleted too.

Definition at line 1763 of file field_ui.admin.inc.

References _field_ui_bundle_admin_path(), drupal_set_message(), field_delete_instance(), field_info_bundles(), field_info_field(), field_info_instance(), field_purge_batch(), field_ui_get_destinations(), and t().

field_ui_field_edit_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for field_ui_field_edit_form().

See Also
field_ui_field_edit_form_validate().

Definition at line 2050 of file field_ui.admin.inc.

References drupal_set_message(), field_default_extract_form_values(), field_default_submit(), field_info_field(), field_read_instance(), field_ui_next_destination(), field_update_field(), field_update_instance(), LANGUAGE_NONE, and t().

field_ui_field_edit_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for field_ui_field_edit_form().

See Also
field_ui_field_edit_form_submit().

Definition at line 2013 of file field_ui.admin.inc.

References field_default_extract_form_values(), field_default_form_errors(), field_form_get_state(), field_form_set_state(), and LANGUAGE_NONE.

field_ui_field_edit_instance_pre_render ( $element )

Pre-render function for field instance settings.

Combines the instance, widget, and other settings into a single fieldset so that elements within each group can be shown at different weights as if they all had the same parent.

Definition at line 1959 of file field_ui.admin.inc.

References element_children().

field_ui_field_overview_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for field_ui_field_overview_form().

See Also
field_ui_field_overview_form_validate()

Definition at line 774 of file field_ui.admin.inc.

References _field_ui_bundle_admin_path(), drupal_get_destination(), drupal_set_message(), field_bundle_settings(), field_create_field(), field_create_instance(), field_info_field(), field_read_instance(), field_ui_get_destinations(), field_update_instance(), and t().

field_ui_field_overview_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for field_ui_field_overview_form().

See Also
field_ui_field_overview_form_submit()

Definition at line 661 of file field_ui.admin.inc.

References _field_ui_field_overview_form_validate_add_existing(), and _field_ui_field_overview_form_validate_add_new().

field_ui_field_overview_row_region ( $row )

Returns the region to which a row in the 'Manage fields' screen belongs.

This function is used as a #region_callback in field_ui_field_overview_form(). It is called during field_ui_table_pre_render().

Definition at line 98 of file field_ui.admin.inc.

References $row.

field_ui_field_settings_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for field_ui_field_settings_form().

Definition at line 1618 of file field_ui.admin.inc.

References drupal_set_message(), field_info_field(), field_info_instance(), field_ui_next_destination(), field_update_field(), and t().

field_ui_field_type_options ( )

Returns an array of field_type options.

Definition at line 1437 of file field_ui.admin.inc.

References $name, drupal_static(), field_info_field_types(), and field_ui_widget_type_options().

Referenced by field_ui_field_overview_form().

field_ui_fields_list ( )

Menu callback; lists all defined fields for quick reference.

Definition at line 11 of file field_ui.admin.inc.

References $header, $output, _field_ui_bundle_admin_path(), field_info_bundles(), field_info_field(), field_info_field_types(), field_info_instances(), l(), system_rebuild_module_data(), t(), and theme().

field_ui_formatter_options ( $field_type = NULL )

Returns an array of formatter options for a field type.

If no field type is provided, returns a nested array of all formatters, keyed by field type.

Definition at line 1498 of file field_ui.admin.inc.

References $name, drupal_static(), field_info_field_types(), and field_info_formatter_types().

Referenced by field_ui_display_overview_form().

field_ui_get_destinations ( $destinations )

Extracts next redirect path from an array of multiple destinations.

See Also
field_ui_next_destination()

Definition at line 2092 of file field_ui.admin.inc.

References drupal_parse_url().

Referenced by field_ui_field_delete_form_submit(), field_ui_field_overview_form_submit(), and field_ui_next_destination().

field_ui_inactive_message | ( | $entity_type,
 |  | $bundle
 | ) |

Displays a message listing the inactive fields of a given bundle.

Definition at line 56 of file field_ui.admin.inc.

References drupal_set_message(), field_info_field_types(), field_info_widget_types(), field_ui_inactive_instances(), t(), and theme().

Referenced by field_ui_display_overview_form(), and field_ui_field_overview_form().

field_ui_next_destination | ( | $entity_type,
 |  | $bundle
 | ) |

Returns the next redirect path in a multipage sequence.

Definition at line 2104 of file field_ui.admin.inc.

References _field_ui_bundle_admin_path(), and field_ui_get_destinations().

Referenced by field_ui_field_edit_form_submit(), field_ui_field_settings_form_submit(), and field_ui_widget_type_form_submit().

field_ui_table_pre_render ( $elements )

Pre-render callback for field_ui_table elements.

Definition at line 128 of file field_ui.admin.inc.

References $children, $depth, $name, $row, $tree, drupal_html_class(), drupal_map_assoc(), element_children(), and theme().

field_ui_widget_type_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for field_ui_widget_type_form().

Definition at line 1697 of file field_ui.admin.inc.

References drupal_set_message(), field_info_widget_types(), field_read_instance(), field_ui_next_destination(), field_update_instance(), and t().

field_ui_widget_type_options | ( | $field_type = NULL,
 |  | $by_label = FALSE
 | ) |

Returns an array of widget type options for a field type.

If no field type is provided, returns a nested array of all widget types, keyed by field type human name.

Definition at line 1462 of file field_ui.admin.inc.

References $name, drupal_static(), field_info_field_types(), and field_info_widget_types().

Referenced by _field_ui_field_overview_form_validate_add_existing(), _field_ui_field_overview_form_validate_add_new(), field_ui_field_overview_form(), field_ui_field_type_options(), and field_ui_widget_type_form().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field_ui/field_ui.api.php File Reference

  • modules
  • field_ui
Functions
field_ui.api.php File Reference

Go to the source code of this file.

Functions

hook_field_settings_form ($field, $instance, $has_data)
hook_field_instance_settings_form ($field, $instance)
hook_field_widget_settings_form ($field, $instance)
hook_field_formatter_settings_form ($field, $instance, $view_mode, $form, &$form_state)
hook_field_formatter_settings_summary ($field, $instance, $view_mode)

Detailed Description

Hooks provided by the Field UI module.

Definition in file field_ui.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field_ui/field_ui.module File Reference

  • modules
  • field_ui
Functions
field_ui.module File Reference

Go to the source code of this file.

Functions

field_ui_help ($path, $arg)
field_ui_field_attach_rename_bundle ($entity_type, $bundle_old, $bundle_new)
field_ui_menu ()
field_ui_menu_load ($field_name, $entity_type, $bundle_name, $bundle_pos, $map)
field_ui_menu_title ($instance)
_field_ui_view_mode_menu_access ($entity_type, $bundle, $view_mode, $access_callback)
field_ui_theme ()
field_ui_element_info ()
field_ui_field_attach_create_bundle ($entity_type, $bundle)
_field_ui_bundle_admin_path ($entity_type, $bundle_name)
field_ui_inactive_instances ($entity_type, $bundle_name=NULL)
field_ui_form_node_type_form_alter (&$form, $form_state)
field_ui_form_node_type_form_submit ($form, &$form_state)

Detailed Description

Allows administrators to attach custom fields to fieldable types.

Definition in file field_ui.module.

Function Documentation

_field_ui_bundle_admin_path | ( | $entity_type,
 |  | $bundle_name
 | ) |

Determines the administration path for a bundle.

Definition at line 323 of file field_ui.module.

References field_info_bundles().

Referenced by field_ui_display_overview_form(), field_ui_display_overview_form_submit(), field_ui_field_delete_form(), field_ui_field_delete_form_submit(), field_ui_field_overview_form(), field_ui_field_overview_form_submit(), field_ui_fields_list(), field_ui_form_node_type_form_submit(), and field_ui_next_destination().

_field_ui_view_mode_menu_access | ( | $entity_type,
 |  | $bundle,
 |  | $view_mode,
 |  | $access_callback
 | ) |

Menu access callback for the 'view mode display settings' pages.

Definition at line 257 of file field_ui.module.

References field_extract_bundle(), field_view_mode_settings(), and user_access().

field_ui_element_info ( )

Implements hook_element_info().

Definition at line 301 of file field_ui.module.

field_ui_field_attach_create_bundle | ( | $entity_type,
 |  | $bundle
 | ) |

Implements hook_field_attach_create_bundle().

Definition at line 314 of file field_ui.module.

References variable_set().

field_ui_field_attach_rename_bundle | ( | $entity_type,
 |  | $bundle_old,
 |  | $bundle_new
 | ) |

Implements hook_field_attach_rename_bundle().

Definition at line 52 of file field_ui.module.

References entity_info_cache_clear(), and menu_rebuild().

field_ui_form_node_type_form_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Adds a button 'Save and add fields' to the 'Create content type' form.

See Also
node_type_form()
field_ui_form_node_type_form_submit()

Definition at line 373 of file field_ui.module.

References t().

field_ui_form_node_type_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for the 'Save and add fields' button.

See Also
field_ui_form_node_type_form_alter()

Definition at line 390 of file field_ui.module.

References _field_ui_bundle_admin_path().

field_ui_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 10 of file field_ui.module.

References $output, t(), and url().

field_ui_inactive_instances | ( | $entity_type,
 |  | $bundle_name = NULL
 | ) |

Identifies inactive fields within a bundle.

Definition at line 334 of file field_ui.module.

References field_info_instances(), and field_read_instances().

Referenced by field_ui_inactive_message().

field_ui_menu ( )

Implements hook_menu().

Definition at line 63 of file field_ui.module.

References drupal_map_assoc(), entity_get_info(), MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_TASK, MENU_NORMAL_ITEM, and t().

field_ui_menu_title ( $instance )

Menu title callback.

Definition at line 250 of file field_ui.module.

field_ui_theme ( )

Implements hook_theme().

Definition at line 290 of file field_ui.module.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/file Directory Reference

  • modules
  • file
file Directory Reference

Files

file | file.api.php [code]
file | file.field.inc [code]
file | file.install [code]
file | file.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/file/file.api.php File Reference

  • modules
  • file
Functions
file.api.php File Reference

Go to the source code of this file.

Functions

hook_file_download_access ($file_item, $entity_type, $entity)
hook_file_download_access_alter (&$grants, $file_item, $entity_type, $entity)

Detailed Description

Hooks for file module.

Definition in file file.api.php.

Function Documentation

hook_file_download_access | ( | $file_item,
 |  | $entity_type,
 |  | $entity
 | ) |

Control download access to files.

The hook is typically implemented to limit access based on the entity the file is referenced, e.g., only users with access to a node should be allowed to download files attached to that node.

Parameters
array | $file_item | The array of information about the file to check access for.
$entity_type | The type of $entity; for example, 'node' or 'user'.
$entity | The $entity to which $file is referenced.
Returns
TRUE is access should be allowed by this entity or FALSE if denied. Note that denial may be overridden by another entity controller, making this grant permissive rather than restrictive.
See Also
hook_field_access().

Definition at line 29 of file file.api.php.

References node_access().

hook_file_download_access_alter | ( | & | $grants,
 |  |  | $file_item,
 |  |  | $entity_type,
 |  |  | $entity
 | ) |  |

Alter the access rules applied to a file download.

Entities that implement file management set the access rules for their individual files. Module may use this hook to create custom access rules for file downloads.

See Also
hook_file_download_access().
Parameters
$grants | An array of grants gathered by hook_file_download_access(). The array is keyed by the module that defines the entity type's access control; the values are Boolean grant responses for each module.
array | $file_item | The array of information about the file to alter access for.
$entity_type | The type of $entity; for example, 'node' or 'user'.
$entity | The $entity to which $file is referenced.

Definition at line 55 of file file.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/file/file.field.inc File Reference

  • modules
  • file
Functions
file.field.inc File Reference

Go to the source code of this file.

Functions

file_field_info ()
file_field_settings_form ($field, $instance, $has_data)
file_field_instance_settings_form ($field, $instance)
_file_generic_settings_max_filesize ($element, &$form_state)
_file_generic_settings_extensions ($element, &$form_state)
_file_generic_settings_file_directory_validate ($element, &$form_state)
file_field_load ($entity_type, $entities, $field, $instances, $langcode, &$items, $age)
file_field_prepare_view ($entity_type, $entities, $field, $instances, $langcode, &$items)
file_field_presave ($entity_type, $entity, $field, $instance, $langcode, &$items)
file_field_insert ($entity_type, $entity, $field, $instance, $langcode, &$items)
file_field_update ($entity_type, $entity, $field, $instance, $langcode, &$items)
file_field_delete ($entity_type, $entity, $field, $instance, $langcode, &$items)
file_field_delete_revision ($entity_type, $entity, $field, $instance, $langcode, &$items)
file_field_delete_file ($item, $field, $entity_type, $id, $count=1)
file_field_is_empty ($item, $field)
file_field_displayed ($item, $field)
file_field_formatter_info ()
file_field_widget_info ()
file_field_widget_settings_form ($field, $instance)
file_field_widget_form (&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
file_field_widget_upload_validators ($field, $instance)
file_field_widget_uri ($field, $instance, $data=array())
file_field_widget_value ($element, $input=FALSE, $form_state)
file_field_widget_process ($element, &$form_state, $form)
file_field_widget_process_multiple ($element, &$form_state, $form)
_file_field_get_description_from_element ($element)
file_field_widget_submit ($form, &$form_state)
theme_file_widget ($variables)
theme_file_widget_multiple ($variables)
theme_file_upload_help ($variables)
file_field_formatter_view ($entity_type, $entity, $field, $instance, $langcode, $items, $display)
theme_file_formatter_table ($variables)

Detailed Description

Field module functionality for the File module.

Definition in file file.field.inc.

Function Documentation

_file_field_get_description_from_element ( $element )

Retrieves the file description from a field field element.

This helper function is used by file_field_widget_process_multiple().

Parameters
$element The element being processed.
Returns
A description of the file suitable for use in the administrative interface.

Definition at line 732 of file file.field.inc.

Referenced by file_field_widget_process_multiple().

_file_generic_settings_extensions | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Element validate callback for the allowed file extensions field.

This doubles as a convenience clean-up function and a validation routine. Commas are allowed by the end-user, but ultimately the value will be stored as a space-separated list for compatibility with file_validate_extensions().

Definition at line 140 of file file.field.inc.

References form_error(), form_set_value(), and t().

_file_generic_settings_file_directory_validate | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Element validate callback for the file destination field.

Remove slashes from the beginning and end of the destination value and ensure that the file directory path is not included at the beginning of the value.

Definition at line 160 of file file.field.inc.

References $value, and form_set_value().

_file_generic_settings_max_filesize | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Element validate callback for the maximum upload size field.

Ensure a size that can be parsed by parse_size() has been entered.

Definition at line 127 of file file.field.inc.

References form_error(), parse_size(), and t().

file_field_delete | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_delete().

Definition at line 305 of file file.field.inc.

References entity_extract_ids(), and file_field_delete_file().

Referenced by image_field_delete().

file_field_delete_file | ( | $item,
 |  | $field,
 |  | $entity_type,
 |  | $id,
 |  | $count = 1
 | ) |

Decrements the usage count for a file and attempts to delete it.

This function only has an effect if the file being deleted is used only by File module.

Parameters
$item | The field item that contains a file array.
$field | The field structure for the operation.
$entity_type | The type of $entity.
$id | The entity ID which contains the file being deleted.
$count | (optional) The number of references to decrement from the object containing the file. Defaults to 1.
Returns
Boolean TRUE if the file was deleted, or an array of remaining references if the file is still in use by other modules. Boolean FALSE if an error was encountered.

Definition at line 350 of file file.field.inc.

References file_delete(), file_usage_delete(), and file_usage_list().

Referenced by file_field_delete(), file_field_delete_revision(), hook_field_delete(), and hook_field_delete_revision().

file_field_delete_revision | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_delete_revision().

Definition at line 317 of file file.field.inc.

References entity_extract_ids(), and file_field_delete_file().

Referenced by image_field_delete_revision().

file_field_displayed | ( | $item,
 |  | $field
 | ) |

Determines whether a file should be displayed when outputting field content.

Parameters
$item | A field item array.
$field | A field array.
Returns
Boolean TRUE if the file will be displayed, FALSE if the file is hidden.

Definition at line 384 of file file.field.inc.

Referenced by file_field_prepare_view().

file_field_formatter_info ( )

Implements hook_field_formatter_info().

Definition at line 394 of file file.field.inc.

References t().

file_field_formatter_view | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance,
 |  | $langcode,
 |  | $items,
 |  | $display
 | ) |

Implements hook_field_formatter_view().

Definition at line 971 of file file.field.inc.

References file_create_url().

file_field_info ( )

Implements hook_field_info().

Definition at line 11 of file file.field.inc.

References t(), and variable_get().

file_field_insert | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_insert().

Definition at line 238 of file file.field.inc.

References entity_extract_ids(), and file_usage_add().

Referenced by image_field_insert().

file_field_instance_settings_form | ( | $field,
 |  | $instance
 | ) |

Implements hook_field_instance_settings_form().

Definition at line 74 of file file.field.inc.

References file_upload_max_size(), format_size(), and t().

Referenced by image_field_instance_settings_form().

file_field_is_empty | ( | $item,
 |  | $field
 | ) |

Implements hook_field_is_empty().

Definition at line 369 of file file.field.inc.

Referenced by image_field_is_empty().

file_field_load | ( |  | $entity_type,
 |  |  | $entities,
 |  |  | $field,
 |  |  | $instances,
 |  |  | $langcode,
 |  | & | $items,
 |  |  | $age
 | ) |  |

Implements hook_field_load().

Definition at line 169 of file file.field.inc.

References file_load_multiple().

Referenced by image_field_load().

file_field_prepare_view | ( |  | $entity_type,
 |  |  | $entities,
 |  |  | $field,
 |  |  | $instances,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_prepare_view().

Definition at line 198 of file file.field.inc.

References file_field_displayed().

file_field_presave | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_presave().

Definition at line 214 of file file.field.inc.

References file_load(), file_save(), and FILE_STATUS_PERMANENT.

Referenced by image_field_presave().

file_field_settings_form | ( | $field,
 |  | $instance,
 |  | $has_data
 | ) |

Implements hook_field_settings_form().

Definition at line 36 of file file.field.inc.

References drupal_get_path(), field_info_field_settings(), file_get_stream_wrappers(), STREAM_WRAPPERS_WRITE_VISIBLE, and t().

file_field_update | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_update().

Checks for files that have been removed from the object.

Definition at line 253 of file file.field.inc.

References entity_create_stub_entity(), entity_extract_ids(), field_attach_load(), FIELD_LOAD_CURRENT, and file_usage_add().

Referenced by image_field_update().

file_field_widget_form | ( | & | $form,
 |  | & | $form_state,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  |  | $delta,
 |  |  | $element
 | ) |  |

Implements hook_field_widget_form().

Definition at line 456 of file file.field.inc.

References element_info(), FIELD_CARDINALITY_UNLIMITED, field_form_get_state(), file_field_widget_upload_validators(), file_field_widget_uri(), t(), and theme().

Referenced by image_field_widget_form().

file_field_widget_info ( )

Implements hook_field_widget_info().

Definition at line 414 of file file.field.inc.

References FIELD_BEHAVIOR_CUSTOM, FIELD_BEHAVIOR_NONE, and t().

file_field_widget_process | ( |  | $element,
 |  | & | $form_state,
 |  |  | $form
 | ) |  |

An element #process callback for the file_generic field type.

Expands the file_generic type to include the description and display fields.

Definition at line 617 of file file.field.inc.

References drupal_array_get_nested_value(), element_children(), field_widget_field(), field_widget_instance(), t(), and variable_get().

file_field_widget_process_multiple | ( |  | $element,
 |  | & | $form_state,
 |  |  | $form
 | ) |  |

An element #process callback for a group of file_generic fields.

Adds the weight field to each row so it can be ordered and adds a new Ajax wrapper around the entire group so it can be replaced all at once.

Definition at line 688 of file file.field.inc.

References _file_field_get_description_from_element(), element_children(), and t().

file_field_widget_settings_form | ( | $field,
 |  | $instance
 | ) |

Implements hook_field_widget_settings_form().

Definition at line 433 of file file.field.inc.

References file_progress_implementation(), and t().

Referenced by image_field_widget_settings_form().

file_field_widget_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for upload/remove button of file_field_widget_form().

This runs in addition to and after file_managed_file_submit().

See Also
file_managed_file_submit()
file_field_widget_form()
file_field_widget_process()

Definition at line 754 of file file.field.inc.

References drupal_array_get_nested_value(), drupal_array_set_nested_value(), field_form_get_state(), and field_form_set_state().

file_field_widget_upload_validators | ( | $field,
 |  | $instance
 | ) |

Retrieves the upload validators for a file field.

Parameters
$field A field array.
Returns
An array suitable for passing to file_save_upload() or the file field element's '#upload_validators' property.

Definition at line 542 of file file.field.inc.

References file_upload_max_size(), and parse_size().

Referenced by file_field_widget_form().

file_field_widget_uri | ( | $field,
 |  | $instance,
 |  | $data = array()
 | ) |

Determines the URI for a file field instance.

Parameters
$field | A field array.
$instance | A field instance array.
$data | An array of token objects to pass to token_replace().
Returns
A file directory URI with tokens replaced.
See Also
token_replace()

Definition at line 577 of file file.field.inc.

References token_replace().

Referenced by file_field_widget_form().

file_field_widget_value | ( | $element,
 |  | $input = FALSE,
 |  | $form_state
 | ) |

The #value_callback for the file_generic field element.

Definition at line 589 of file file.field.inc.

References field_widget_field(), and file_managed_file_value().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/file/file.install File Reference

  • modules
  • file
Functions
file.install File Reference

Go to the source code of this file.

Functions

file_field_schema ($field)
file_requirements ($phase)

Detailed Description

Install, update and uninstall functions for File module.

Definition in file file.install.

Function Documentation

file_field_schema ( $field )

Implements hook_field_schema().

Definition at line 11 of file file.install.

file_requirements ( $phase )

Implements hook_requirements().

Display information about getting upload progress bars working.

Definition at line 51 of file file.install.

References $value, file_progress_implementation(), REQUIREMENT_INFO, REQUIREMENT_OK, and t().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/file/file.module File Reference

  • modules
  • file
Functions
file.module File Reference

Go to the source code of this file.

Functions

file_help ($path, $arg)
file_menu ()
file_element_info ()
file_theme ()
file_file_download ($uri, $field_type= 'file')
file_ajax_upload ()
file_ajax_progress ($key)
file_progress_implementation ()
file_file_delete ($file)
file_managed_file_process ($element, &$form_state, $form)
file_managed_file_value (&$element, $input=FALSE, $form_state=NULL)
file_managed_file_validate (&$element, &$form_state)
file_managed_file_submit ($form, &$form_state)
file_managed_file_save_upload ($element)
theme_file_managed_file ($variables)
file_managed_file_pre_render ($element)
theme_file_link ($variables)
theme_file_icon ($variables)
file_icon_url ($file, $icon_directory=NULL)
file_icon_path ($file, $icon_directory=NULL)
file_icon_map ($file)
file_get_file_references ($file, $field=NULL, $age=FIELD_LOAD_REVISION, $field_type= 'file')

Detailed Description

Defines a "managed_file" Form API field and a "file" field for Field module.

Definition in file file.module.

Function Documentation

file_ajax_progress ( $key )

Menu callback for upload progress.

Parameters
$key The unique key for this upload process.

Definition at line 298 of file file.module.

References drupal_json_output(), file_progress_implementation(), format_size(), and t().

file_ajax_upload ( )

Menu callback; Shared Ajax callback for file uploads and deletions.

This rebuilds the form element for a particular field item. As long as the form processing is properly encapsulated in the widget element the form should rebuild correctly using FAPI without the need for additional callbacks or processing.

Definition at line 237 of file file.module.

References $output, ajax_command_replace(), ajax_get_form(), drupal_add_js(), drupal_process_form(), drupal_render(), drupal_set_message(), file_upload_max_size(), format_size(), t(), and theme().

file_element_info ( )

Implements hook_element_info().

The managed file element may be used anywhere in Drupal.

Definition at line 61 of file file.module.

References drupal_get_path().

file_file_delete ( $file )

Implements hook_file_delete().

Definition at line 350 of file file.module.

file_file_download | ( | $uri,
 |  | $field_type = 'file'
 | ) |

Implements hook_file_download().

This function takes an extra parameter $field_type so that it may be re-used by other File-like modules, such as Image.

Definition at line 123 of file file.module.

References $module, drupal_alter(), entity_load(), field_access(), field_get_items(), field_info_field(), FIELD_LOAD_CURRENT, file_get_content_headers(), file_get_file_references(), file_load_multiple(), FILE_STATUS_PERMANENT, module_implements(), and module_invoke().

Referenced by image_file_download().

file_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 14 of file file.module.

References $output, t(), and url().

file_icon_map ( $file )

Determines the generic icon MIME package based on a file's MIME type.

Parameters
$file A file object.
Returns
The generic icon MIME package expected for this file.

Definition at line 851 of file file.module.

Referenced by file_icon_path().

file_icon_path | ( | $file,
 |  | $icon_directory = NULL
 | ) |

Creates a path to the icon for a file object.

Parameters
$file | A file object.
$icon_directory | (optional) A path to a directory of icons to be used for files. Defaults to the value of the "file_icon_directory" variable.
Returns
A string to the icon as a local path, or FALSE if an appropriate icon could not be found.

Definition at line 802 of file file.module.

References drupal_get_path(), file_icon_map(), and variable_get().

Referenced by file_icon_url().

file_icon_url | ( | $file,
 |  | $icon_directory = NULL
 | ) |

Creates a URL to the icon for a file object.

Parameters
$file | A file object.
$icon_directory | (optional) A path to a directory of icons to be used for files. Defaults to the value of the "file_icon_directory" variable.
Returns
A URL string to the icon, or FALSE if an appropriate icon cannot be found.

Definition at line 782 of file file.module.

References base_path(), and file_icon_path().

Referenced by theme_file_icon().

file_managed_file_pre_render ( $element )

#pre_render callback to hide display of the upload or remove controls.

Upload controls are hidden when a file is already uploaded. Remove controls are hidden when there is no file attached. Controls are hidden here instead of in file_managed_file_process(), because #access for these buttons depends on the managed_file element's value. See the documentation of form_builder() for more detailed information about the relationship between #process, value, and #access.

Because #access is set here, it affects display only and does not prevent JavaScript or other untrusted code from submitting the form as though access were enabled. The form processing functions for these elements should not assume that the buttons can't be "clicked" just because they are not displayed.

See Also
file_managed_file_process()
form_builder()

Definition at line 699 of file file.module.

file_managed_file_process | ( |  | $element,
 |  | & | $form_state,
 |  |  | $form
 | ) |  |

Process function to expand the managed_file element type.

Expands the file type to include Upload and Remove buttons, as well as support for a default value.

Definition at line 360 of file file.module.

References file_load(), file_progress_implementation(), t(), and theme().

file_managed_file_save_upload ( $element )

Saves any files that have been uploaded into a managed_file element.

Parameters
$element The FAPI element whose values are being saved.
Returns
The file object representing the file that was saved, or FALSE if no file was saved.

Definition at line 629 of file file.module.

References FILE_CREATE_DIRECTORY, file_prepare_directory(), file_save_upload(), form_set_error(), t(), and watchdog().

Referenced by file_managed_file_value().

file_managed_file_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for upload / remove buttons of managed_file elements.

See Also
file_managed_file_process()

Definition at line 581 of file file.module.

References drupal_array_get_nested_value(), drupal_array_set_nested_value(), file_delete(), and form_set_value().

file_managed_file_validate | ( | & | $element,
 |  | & | $form_state
 | ) |  |

An #element_validate callback for the managed_file element.

Definition at line 546 of file file.module.

References file_load(), FILE_STATUS_PERMANENT, file_usage_list(), form_error(), form_set_value(), and t().

file_managed_file_value | ( | & | $element,
 |  |  | $input = FALSE,
 |  |  | $form_state = NULL
 | ) |  |

The #value_callback for a managed_file type element.

Definition at line 480 of file file.module.

References file_load(), and file_managed_file_save_upload().

Referenced by file_field_widget_value().

file_menu ( )

Implements hook_menu().

Definition at line 36 of file file.module.

References MENU_CALLBACK.

file_progress_implementation ( )

Determines the preferred upload progress implementation.

Returns
A string indicating which upload progress system is available. Either "apc" or "uploadprogress". If neither are available, returns FALSE.

Definition at line 330 of file file.module.

Referenced by file_ajax_progress(), file_field_widget_settings_form(), file_managed_file_process(), and file_requirements().

file_theme ( )

Implements hook_theme().

Definition at line 88 of file file.module.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/filter Directory Reference

  • modules
  • filter
filter Directory Reference

Files

file | filter.admin.inc [code]
file | filter.api.php [code]
file | filter.install [code]
file | filter.module [code]
file | filter.pages.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/filter/filter.admin.inc File Reference

  • modules
  • filter
Functions
filter.admin.inc File Reference

Go to the source code of this file.

Functions

filter_admin_overview ($form)
filter_admin_overview_submit ($form, &$form_state)
theme_filter_admin_overview ($variables)
filter_admin_format_page ($format=NULL)
filter_admin_format_form ($form, &$form_state, $format)
theme_filter_admin_format_filter_order ($variables)
filter_admin_format_form_validate ($form, &$form_state)
filter_admin_format_form_submit ($form, &$form_state)
filter_admin_disable ($form, &$form_state, $format)
filter_admin_disable_submit ($form, &$form_state)

Detailed Description

Administrative page callbacks for the Filter module.

Definition in file filter.admin.inc.

Function Documentation

filter_admin_disable_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for filter_admin_disable().

Definition at line 402 of file filter.admin.inc.

References drupal_set_message(), filter_format_disable(), and t().

filter_admin_format_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for filter_admin_format_form().

See Also
filter_admin_format_form_validate()

Definition at line 349 of file filter.admin.inc.

References $value, drupal_set_message(), filter_format_save(), filter_permission_name(), form_state_values_clean(), SAVED_NEW, SAVED_UPDATED, t(), and user_role_change_permissions().

filter_admin_format_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for filter_admin_format_form().

See Also
filter_admin_format_form_submit()

Definition at line 330 of file filter.admin.inc.

References db_query(), form_set_error(), form_set_value(), and t().

filter_admin_format_page ( $format = NULL )

Page callback: Displays the text format add/edit form.

Parameters
object | null $format (optional) An object representing a format, with the following properties:
  • format: A machine-readable name representing the ID of the text format to save. If this corresponds to an existing text format, that format will be updated; otherwise, a new format will be created.
  • name: The title of the text format.
  • cache: (optional) An integer indicating whether the text format is cacheable (1) or not (0). Defaults to 1.
  • status: (optional) An integer indicating whether the text format is enabled (1) or not (0). Defaults to 1.
  • weight: (optional) The weight of the text format, which controls its placement in text format lists. If omitted, the weight is set to 0. Defaults to NULL.
Returns
A form array.
See Also
filter_menu()

Definition at line 123 of file filter.admin.inc.

References drupal_get_form(), drupal_set_title(), and t().

filter_admin_overview_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for filter_admin_overview().

Definition at line 52 of file filter.admin.inc.

References db_update(), drupal_set_message(), filter_formats_reset(), and t().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/filter/filter.api.php File Reference

  • modules
  • filter
Functions
filter.api.php File Reference

Go to the source code of this file.

Functions

hook_filter_info ()
hook_filter_info_alter (&$info)
callback_filter_settings ($form, &$form_state, $filter, $format, $defaults, $filters)
callback_filter_prepare ($text, $filter, $format, $langcode, $cache, $cache_id)
callback_filter_process ($text, $filter, $format, $langcode, $cache, $cache_id)
callback_filter_tips ($filter, $format, $long)
hook_filter_format_insert ($format)
hook_filter_format_update ($format)
hook_filter_format_disable ($format)

Detailed Description

Hooks provided by the Filter module.

Definition in file filter.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/filter/filter.install File Reference

  • modules
  • filter
Functions
filter.install File Reference

Go to the source code of this file.

Functions

filter_schema ()
filter_install ()
filter_update_dependencies ()
filter_update_7000 ()
filter_update_7001 ()
filter_update_7003 ()
filter_update_7005 ()
filter_update_7008 ()
filter_update_7009 ()
filter_update_7010 ()

Detailed Description

Install, update, and uninstall functions for the Filter module.

Definition in file filter.install.

Function Documentation

filter_install ( )

Implements hook_install().

Definition at line 117 of file filter.install.

References filter_format_save(), and variable_set().

filter_schema ( )

Implements hook_schema().

Definition at line 11 of file filter.install.

References drupal_get_schema_unprocessed().

filter_update_dependencies ( )

Implements hook_update_dependencies().

Definition at line 154 of file filter.install.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/filter/filter.module File Reference

  • modules
  • filter
Functions
filter.module File Reference

Go to the source code of this file.

Functions

filter_help ($path, $arg)
filter_theme ()
filter_element_info ()
filter_menu ()
_filter_disable_format_access ($format)
filter_format_load ($format_id)
filter_format_save ($format)
filter_format_disable ($format)
filter_format_exists ($format_id)
filter_admin_format_title ($format)
filter_permission ()
filter_permission_name ($format)
filter_modules_enabled ($modules)
filter_modules_disabled ($modules)
filter_formats ($account=NULL)
filter_formats_reset ()
filter_get_roles_by_format ($format)
filter_get_formats_by_role ($rid)
filter_default_format ($account=NULL)
filter_fallback_format ()
filter_fallback_format_title ()
filter_get_filters ()
_filter_list_cmp ($a, $b)
filter_format_allowcache ($format_id)
_filter_format_is_cacheable ($format)
filter_list_format ($format_id)
check_markup ($text, $format_id=NULL, $langcode= '', $cache=FALSE)
filter_process_format ($element)
filter_form_access_denied ($element)
theme_text_format_wrapper ($variables)
filter_access ($format, $account=NULL)
_filter_tips ($format_id, $long=FALSE)
filter_dom_load ($text)
filter_dom_serialize ($dom_document)
filter_dom_serialize_escape_cdata_element ($dom_document, $dom_element, $comment_start= '//', $comment_end= '')
theme_filter_tips_more_info ()
theme_filter_guidelines ($variables)
filter_filter_info ()
_filter_html_settings ($form, &$form_state, $filter, $format, $defaults)
_filter_html ($text, $filter)
_filter_html_tips ($filter, $format, $long=FALSE)
_filter_url_settings ($form, &$form_state, $filter, $format, $defaults)
_filter_url ($text, $filter)
_filter_url_parse_full_links ($match)
_filter_url_parse_email_links ($match)
_filter_url_parse_partial_links ($match)
_filter_url_escape_comments ($match, $escape=NULL)
_filter_url_trim ($text, $length=NULL)
_filter_url_tips ($filter, $format, $long=FALSE)
_filter_htmlcorrector ($text)
_filter_autop ($text)
_filter_autop_tips ($filter, $format, $long=FALSE)
_filter_html_escape ($text)
_filter_html_escape_tips ($filter, $format, $long=FALSE)

Detailed Description

Framework for handling the filtering of content.

Definition in file filter.module.

Function Documentation

_filter_disable_format_access ( $format )

Access callback: Checks access for disabling text formats.

Parameters
$format A text format object.
Returns
TRUE if the text format can be disabled by the current user, FALSE otherwise.
See Also
filter_menu()

Definition at line 147 of file filter.module.

References filter_fallback_format(), and user_access().

_filter_format_is_cacheable ( $format )

Helper function to determine whether the output of a given text format can be cached.

The output of a given text format can be cached when all enabled filters in the text format allow caching.

Parameters
$format The text format object to check.
Returns
TRUE if all the filters enabled in the given text format allow caching, FALSE otherwise.
See Also
filter_format_save()

Definition at line 662 of file filter.module.

References $name, and filter_get_filters().

Referenced by filter_format_save().

_filter_list_cmp | ( | $a,
 |  | $b
 | ) |

Sorts an array of filters by filter name.

Callback for uasort() within filter_get_filters().

Definition at line 625 of file filter.module.

_filter_tips | ( | $format_id,
 |  | $long = FALSE
 | ) |

Retrieves the filter tips.

Parameters
$format_id | The ID of the text format for which to retrieve tips, or -1 to return tips for all formats accessible to the current user.
$long | (optional) Boolean indicating whether the long form of tips should be returned. Defaults to FALSE.
Returns
An associative array of filtering tips, keyed by filter name. Each filtering tip is an associative array with elements:
  • tip: Tip text.
  • id: Filter ID.

Definition at line 1054 of file filter.module.

References $name, filter_formats(), filter_get_filters(), and filter_list_format().

Referenced by filter_tips_long(), and theme_filter_guidelines().

filter_access | ( | $format,
 |  | $account = NULL
 | ) |

Checks if a user has access to a particular text format.

Parameters
$format | An object representing the text format.
$account | (optional) The user account to check access for; if omitted, the currently logged-in user is used. Defaults to NULL.
Returns
Boolean TRUE if the user is allowed to access the given format.

Definition at line 1022 of file filter.module.

References filter_fallback_format(), filter_permission_name(), and user_access().

Referenced by filter_formats().

filter_admin_format_title ( $format )

Displays a text format form title.

Parameters
object $format A format object.
Returns
string The name of the format.
See Also
filter_menu()

Definition at line 333 of file filter.module.

Referenced by filter_fallback_format_title().

filter_default_format ( $account = NULL )

Returns the ID of the default text format for a particular user.

The default text format is the first available format that the user is allowed to access, when the formats are ordered by weight. It should generally be used as a default choice when presenting the user with a list of possible text formats (for example, in a node creation form).

Conversely, when existing content that does not have an assigned text format needs to be filtered for display, the default text format is the wrong choice, because it is not guaranteed to be consistent from user to user, and some trusted users may have an unsafe text format set by default, which should not be used on text of unknown origin. Instead, the fallback format returned by filter_fallback_format() should be used, since that is intended to be a safe, consistent format that is always available to all users.

Parameters
$account (optional) The user account to check. Defaults to the currently logged-in user. Defaults to NULL.
Returns
The ID of the user's default text format.
See Also
filter_fallback_format()

Definition at line 524 of file filter.module.

References filter_formats().

Referenced by DrupalWebTestCase::drupalCreateNode(), filter_process_format(), and token_example_tokens().

filter_dom_load ( $text )

Parses an HTML snippet and returns it as a DOM object.

This function loads the body part of a partial (X)HTML document and returns a full DOMDocument object that represents this document. You can use filter_dom_serialize() to serialize this DOMDocument back to a XHTML snippet.

Parameters
$text The partial (X)HTML snippet to load. Invalid mark-up will be corrected on import.
Returns
A DOMDocument that represents the loaded (X)HTML snippet.

Definition at line 1097 of file filter.module.

Referenced by _filter_html(), and _filter_htmlcorrector().

filter_dom_serialize ( $dom_document )

Converts a DOM object back to an HTML snippet.

The function serializes the body part of a DOMDocument back to an XHTML snippet. The resulting XHTML snippet will be properly formatted to be compatible with HTML user agents.

Parameters
$dom_document A DOMDocument object to serialize, only the tags below the first <body> node will be converted.
Returns
A valid (X)HTML snippet, as a string.

Definition at line 1119 of file filter.module.

References filter_dom_serialize_escape_cdata_element().

Referenced by _filter_html(), and _filter_htmlcorrector().

filter_dom_serialize_escape_cdata_element | ( | $dom_document,
 |  | $dom_element,
 |  | $comment_start = '//',
 |  | $comment_end = ''
 | ) |

Adds comments around the <!CDATA section in a dom element.

DOMDocument::loadHTML in filter_dom_load() makes CDATA sections from the contents of inline script and style tags. This can cause HTML 4 browsers to throw exceptions.

This function attempts to solve the problem by creating a DocumentFragment and imitating the behavior in drupal_get_js(), commenting the CDATA tag.

Parameters
$dom_document | The DOMDocument containing the $dom_element.
$dom_element | The element potentially containing a CDATA node.
$comment_start | (optional) A string to use as a comment start marker to escape the CDATA declaration. Defaults to '//'.
$comment_end | (optional) A string to use as a comment end marker to escape the CDATA declaration. Defaults to an empty string.

Definition at line 1158 of file filter.module.

Referenced by filter_dom_serialize().

filter_element_info ( )

Implements hook_element_info().

See Also
filter_process_format()
text_format_wrapper()

Definition at line 76 of file filter.module.

filter_fallback_format ( )

Returns the ID of the fallback text format that all users have access to.

The fallback text format is a regular text format in every respect, except it does not participate in the filter permission system and cannot be disabled. It needs to exist because any user who has permission to create formatted content must always have at least one text format they can use.

Because the fallback format is available to all users, it should always be configured securely. For example, when the Filter module is installed, this format is initialized to output plain text. Installation profiles and site administrators have the freedom to configure it further.

Note that the fallback format is completely distinct from the default format, which differs per user and is simply the first format which that user has access to. The default and fallback formats are only guaranteed to be the same for users who do not have access to any other format; otherwise, the fallback format's weight determines its placement with respect to the user's other formats.

Any modules implementing a format deletion functionality must not delete this format.

Returns
The ID of the fallback text format.
See Also
hook_filter_format_disable()
filter_default_format()

Definition at line 565 of file filter.module.

References variable_get().

Referenced by _filter_disable_format_access(), check_markup(), filter_access(), filter_admin_format_form(), filter_admin_overview(), filter_fallback_format_title(), filter_get_roles_by_format(), and filter_permission_name().

filter_fallback_format_title ( )

Returns the title of the fallback text format.

Returns
string The title of the fallback text format.

Definition at line 581 of file filter.module.

References filter_admin_format_title(), filter_fallback_format(), and filter_format_load().

filter_form_access_denied ( $element )

Render API callback: Hides the field value of 'text_format' elements.

To not break form processing and previews if a user does not have access to a stored text format, the expanded form elements in filter_process_format() are forced to take over the stored #default_values for 'value' and 'format'. However, to prevent the unfiltered, original value from being displayed to the user, we replace it with a friendly notice here.

See Also
filter_process_format()

Definition at line 984 of file filter.module.

References t().

filter_format_allowcache ( $format_id )

Checks if the text in a certain text format is allowed to be cached.

This function can be used to check whether the result of the filtering process can be cached. A text format may allow caching depending on the filters enabled.

Parameters
$format_id The text format ID to check.
Returns
TRUE if the given text format allows caching, FALSE otherwise.

Definition at line 642 of file filter.module.

References filter_format_load().

Referenced by hook_field_load(), and text_field_load().

filter_format_disable ( $format )

Disables a text format.

There is no core facility to re-enable a disabled format. It is not deleted to keep information for contrib and to make sure the format ID is never reused. As there might be content using the disabled format, this would lead to data corruption.

Parameters
$format The text format object to be disabled.

Definition at line 291 of file filter.module.

References cache_clear_all(), db_update(), filter_formats_reset(), and module_invoke_all().

Referenced by filter_admin_disable_submit().

filter_format_exists ( $format_id )

Determines if a text format exists.

Parameters
$format_id The ID of the text format to check.
Returns
TRUE if the text format exists, FALSE otherwise. Note that for disabled formats filter_format_exists() will return TRUE while filter_format_load() will return FALSE.
See Also
filter_format_load()

Definition at line 318 of file filter.module.

References db_query_range().

filter_format_load ( $format_id )

Loads a text format object from the database.

Parameters
$format_id The format ID.
Returns
A fully-populated text format object, if the requested format exists and is enabled. If the format does not exist, or exists in the database but has been marked as disabled, FALSE is returned.
See Also
filter_format_exists()

Definition at line 165 of file filter.module.

References filter_formats().

Referenced by check_markup(), filter_fallback_format_title(), filter_format_allowcache(), and token_example_tokens().

filter_format_save ( $format )

Saves a text format object to the database.

Parameters
$format A format object having the properties:
  • format: A machine-readable name representing the ID of the text format to save. If this corresponds to an existing text format, that format will be updated; otherwise, a new format will be created.
  • name: The title of the text format.
  • status: (optional) An integer indicating whether the text format is enabled (1) or not (0). Defaults to 1.
  • weight: (optional) The weight of the text format, which controls its placement in text format lists. If omitted, the weight is set to 0.
  • filters: (optional) An associative, multi-dimensional array of filters assigned to the text format, keyed by the name of each filter and using the properties:
    • weight: (optional) The weight of the filter in the text format. If omitted, either the currently stored weight is retained (if there is one), or the filter is assigned a weight of 10, which will usually put it at the bottom of the list.
    • status: (optional) A boolean indicating whether the filter is enabled in the text format. If omitted, the filter will be disabled.
    • settings: (optional) An array of configured settings for the filter. See hook_filter_info() for details.
Returns
SAVED_NEW or SAVED_UPDATED.

Definition at line 198 of file filter.module.

References $name, _filter_format_is_cacheable(), cache_clear_all(), db_merge(), filter_formats_reset(), filter_get_filters(), module_invoke_all(), SAVED_NEW, and SAVED_UPDATED.

Referenced by filter_admin_format_form_submit(), filter_install(), php_enable(), and standard_install().

filter_formats ( $account = NULL )

Retrieves a list of text formats, ordered by weight.

Parameters
$account (optional) If provided, only those formats that are allowed for this user account will be returned. All formats will be returned otherwise. Defaults to NULL.
Returns
An array of text format objects, keyed by the format ID and ordered by weight.
See Also
filter_formats_reset()

Definition at line 412 of file filter.module.

References cache_get(), cache_set(), db_select(), drupal_static(), and filter_access().

Referenced by _filter_tips(), filter_admin_overview(), filter_default_format(), filter_format_load(), filter_get_formats_by_role(), filter_permission(), filter_process_format(), and hook_field_prepare_translation().

filter_formats_reset ( )

Resets the text format caches.

See Also
filter_formats()

Definition at line 452 of file filter.module.

References cache_clear_all(), and drupal_static_reset().

Referenced by filter_admin_overview_submit(), filter_format_disable(), and filter_format_save().

filter_get_filters ( )

Returns a list of all filters provided by modules.

Returns
array An array of filter formats.

Definition at line 592 of file filter.module.

References $info, $module, $name, drupal_alter(), drupal_static(), module_implements(), and module_invoke().

Referenced by _filter_format_is_cacheable(), _filter_tips(), check_markup(), filter_admin_format_form(), filter_format_save(), and filter_list_format().

filter_get_formats_by_role ( $rid )

Retrieves a list of text formats that are allowed for a given role.

Parameters
$rid The user role ID to retrieve text formats for.
Returns
An array of text format objects that are allowed for the role, keyed by the text format ID and ordered by weight.

Definition at line 488 of file filter.module.

References filter_formats(), and filter_get_roles_by_format().

filter_get_roles_by_format ( $format )

Retrieves a list of roles that are allowed to use a given text format.

Parameters
$format An object representing the text format.
Returns
An array of role names, keyed by role ID.

Definition at line 468 of file filter.module.

References filter_fallback_format(), filter_permission_name(), and user_roles().

Referenced by filter_admin_format_form(), filter_admin_overview(), and filter_get_formats_by_role().

filter_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file filter.module.

References $output, t(), and url().

filter_list_format ( $format_id )

Retrieves a list of filters for a given text format.

Note that this function returns all associated filters regardless of whether they are enabled or disabled. All functions working with the filter information outside of filter administration should test for $filter->status before performing actions with the filter.

Parameters
$format_id The format ID to retrieve filters for.
Returns
An array of filter objects associated to the given text format, keyed by filter name.

Definition at line 691 of file filter.module.

References $name, cache_get(), cache_set(), db_query(), drupal_static(), and filter_get_filters().

Referenced by _filter_tips(), check_markup(), filter_admin_format_form(), and text_summary().

filter_menu ( )

Implements hook_menu().

Definition at line 88 of file filter.module.

References MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION, and MENU_SUGGESTED_ITEM.

filter_modules_disabled ( $modules )

Implements hook_modules_disabled().

Definition at line 392 of file filter.module.

References drupal_static_reset().

filter_modules_enabled ( $modules )

Implements hook_modules_enabled().

Definition at line 383 of file filter.module.

References drupal_static_reset().

filter_permission ( )

Implements hook_permission().

Definition at line 340 of file filter.module.

References drupal_placeholder(), filter_formats(), filter_permission_name(), l(), t(), and user_access().

filter_permission_name ( $format )

Returns the machine-readable permission name for a provided text format.

Parameters
$format An object representing a text format.
Returns
The machine-readable permission name, or FALSE if the provided text format is malformed or is the fallback format (which is available to all users).

Definition at line 373 of file filter.module.

References filter_fallback_format().

Referenced by filter_access(), filter_admin_format_form_submit(), filter_get_roles_by_format(), filter_permission(), and standard_install().

filter_process_format ( $element )

Expands an element into a base element with text format selector attached.

The form element will be expanded into two separate form elements, one holding the original element, and the other holding the text format selector:

  • value: Holds the original element, having its #type changed to the value of #base_type or 'textarea' by default.
  • format: Holds the text format fieldset and the text format selection, using the text format id specified in #format or the user's default format by default, if NULL.

The resulting value for the element will be an array holding the value and the format. For example, the value for the body element will be:

* $form_state['values']['body']['value'] = 'foo';
* $form_state['values']['body']['format'] = 'foo';
*
Parameters
$element The form element to process. Properties used:
  • #base_type: The form element #type to use for the 'value' element. 'textarea' by default.
  • #format: (optional) The text format ID to preselect. If NULL or not set, the default format for the current user will be used.
Returns
The expanded element.

Definition at line 842 of file filter.module.

References drupal_get_path(), element_children(), element_info(), element_properties(), filter_default_format(), filter_formats(), t(), and user_access().

filter_theme ( )

Implements hook_theme().

Definition at line 44 of file filter.module.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/filter/filter.pages.inc File Reference

  • modules
  • filter
Functions
filter.pages.inc File Reference

Go to the source code of this file.

Functions

filter_tips_long ()
theme_filter_tips ($variables)

Detailed Description

User page callbacks for the Filter module.

Definition in file filter.pages.inc.

Function Documentation

filter_tips_long ( )

Page callback: Displays a page with long filter tips.

Returns
string An HTML-formatted string.
See Also
filter_menu()
theme_filter_tips()

Definition at line 17 of file filter.pages.inc.

References $output, _filter_tips(), arg(), and theme().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum Directory Reference

  • modules
  • forum
forum Directory Reference

Files

file | forum-icon.tpl.php [code]
file | forum-list.tpl.php [code]
file | forum-submitted.tpl.php [code]
file | forum-topic-list.tpl.php [code]
file | forum.admin.inc [code]
file | forum.install [code]
file | forum.module [code]
file | forum.pages.inc [code]
file | forums.tpl.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum.admin.inc File Reference

  • modules
  • forum
Functions
forum.admin.inc File Reference

Go to the source code of this file.

Functions

forum_form_main ($type, $edit=array())
forum_form_forum ($form, &$form_state, $edit=array())
forum_form_submit ($form, &$form_state)
theme_forum_form ($variables)
forum_form_container ($form, &$form_state, $edit=array())
forum_confirm_delete ($form, &$form_state, $tid)
forum_confirm_delete_submit ($form, &$form_state)
forum_admin_settings ($form)
forum_overview ($form, &$form_state)
_forum_parent_select ($tid, $title, $child_type)

Detailed Description

Administrative page callbacks for the Forum module.

Definition in file forum.admin.inc.

Function Documentation

_forum_parent_select | ( | $tid,
 |  | $title,
 |  | $child_type
 | ) |

Returns a select box for available parent terms.

Parameters
$tid | ID of the term that is being added or edited.
$title | Title for the select box.
$child_type | Whether the child is a forum or a container.
Returns
A select form element.

Definition at line 315 of file forum.admin.inc.

References $children, $title, $tree, t(), taxonomy_get_parents(), taxonomy_get_tree(), and variable_get().

Referenced by forum_form_container(), and forum_form_forum().

forum_confirm_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for forum_confirm_delete().

Definition at line 220 of file forum.admin.inc.

References drupal_set_message(), t(), taxonomy_term_delete(), and watchdog().

forum_form_main | ( | $type,
 |  | $edit = array()
 | ) |

Page callback: Returns a form for creating a new forum or container.

Parameters
$type | What is being added. Possible values are 'forum' and 'container'.
$edit | (optional) Associative array containing a forum term to be edited. Defaults to an empty array.
Returns
A form for creating a new forum or container.
See Also
forum_menu()

Definition at line 22 of file forum.admin.inc.

References drupal_get_form(), and t().

forum_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for forum_form_forum() and forum_form_container().

Definition at line 90 of file forum.admin.inc.

References cache_clear_all(), drupal_set_message(), SAVED_NEW, SAVED_UPDATED, t(), taxonomy_term_save(), variable_get(), and variable_set().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum.install File Reference

  • modules
  • forum
Functions
forum.install File Reference

Go to the source code of this file.

Functions

forum_install ()
forum_enable ()
forum_uninstall ()
forum_schema ()
forum_update_dependencies ()
forum_update_7000 ()
forum_update_7001 ()
forum_update_7002 ()
forum_update_7003 ()
forum_update_7011 ()
forum_update_7012 ()

Detailed Description

Install, update, and uninstall functions for the Forum module.

Definition in file forum.install.

Function Documentation

forum_enable ( )

Implements hook_enable().

Definition at line 25 of file forum.install.

References field_associate_fields(), field_create_field(), field_create_instance(), field_info_field(), node_add_body_field(), node_type_get_types(), node_types_rebuild(), t(), taxonomy_term_save(), taxonomy_vocabulary_load(), taxonomy_vocabulary_save(), variable_get(), and variable_set().

forum_install ( )

Implements hook_install().

Definition at line 11 of file forum.install.

References db_update(), and variable_set().

forum_schema ( )

Implements hook_schema().

Definition at line 126 of file forum.install.

forum_uninstall ( )

Implements hook_uninstall().

Definition at line 105 of file forum.install.

References drupal_load(), field_delete_field(), field_purge_batch(), and variable_del().

forum_update_7000 ( )

Add new index to forum table.

Definition at line 261 of file forum.install.

References db_add_index(), and db_drop_index().

forum_update_7001 ( )

Create new {forum_index} table.

Definition at line 269 of file forum.install.

References db_create_table(), db_insert(), and db_select().

forum_update_dependencies ( )

Implements hook_update_dependencies().

Definition at line 246 of file forum.install.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum.module File Reference

  • modules
  • forum
Functions
forum.module File Reference

Go to the source code of this file.

Functions

forum_help ($path, $arg)
forum_theme ()
forum_menu ()
forum_menu_local_tasks_alter (&$data, $router_item, $root_path)
forum_entity_info_alter (&$info)
forum_uri ($forum)
_forum_node_check_node_type ($node)
forum_node_view ($node, $view_mode)
forum_node_validate ($node, $form)
forum_node_presave ($node)
forum_node_update ($node)
forum_node_insert ($node)
forum_node_delete ($node)
forum_node_load ($nodes)
forum_node_info ()
forum_permission ()
forum_taxonomy_term_delete ($term)
forum_comment_publish ($comment)
forum_comment_update ($comment)
forum_comment_unpublish ($comment)
forum_comment_delete ($comment)
forum_field_storage_pre_insert ($entity_type, $entity, &$skip_fields)
forum_field_storage_pre_update ($entity_type, $entity, &$skip_fields)
forum_form_taxonomy_form_vocabulary_alter (&$form, &$form_state, $form_id)
forum_form_taxonomy_form_term_alter (&$form, &$form_state, $form_id)
forum_form_node_form_alter (&$form, &$form_state, $form_id)
forum_block_info ()
forum_block_configure ($delta= '')
forum_block_save ($delta= '', $edit=array())
forum_block_view ($delta= '')
forum_block_view_pre_render ($elements)
forum_form ($node, $form_state)
forum_forum_load ($tid=NULL)
_forum_topics_unread ($term, $uid)
forum_get_topics ($tid, $sortby, $forum_per_page)
template_preprocess_forums (&$variables)
template_preprocess_forum_list (&$variables)
template_preprocess_forum_topic_list (&$variables)
template_preprocess_forum_icon (&$variables)
template_preprocess_forum_submitted (&$variables)
_forum_user_last_visit ($nid)
_forum_get_topic_order ($sortby)
_forum_update_forum_index ($nid)
forum_rdf_mapping ()

Detailed Description

Provides discussion forums.

Definition in file forum.module.

Function Documentation

_forum_get_topic_order ( $sortby )

Gets topic sorting information based on an integer code.

Parameters
$sortby One of the following integers indicating the sort criteria:
  • 1: Date - newest first.
  • 2: Date - oldest first.
  • 3: Posts with the most comments first.
  • 4: Posts with the least comments first.
Returns
An array with the following values:
  • field: A field for an SQL query.
  • sort: 'asc' or 'desc'.

Definition at line 1316 of file forum.module.

Referenced by forum_get_topics().

_forum_node_check_node_type ( $node )

Checks whether a node can be used in a forum, based on its content type.

Parameters
$node A node object.
Returns
Boolean indicating if the node can be assigned to a forum.

Definition at line 255 of file forum.module.

References field_info_instance().

Referenced by forum_field_storage_pre_insert(), forum_field_storage_pre_update(), forum_node_delete(), forum_node_insert(), forum_node_load(), forum_node_presave(), forum_node_update(), forum_node_validate(), forum_node_view(), hook_field_storage_pre_insert(), and hook_field_storage_pre_update().

_forum_topics_unread | ( | $term,
 |  | $uid
 | ) |

Calculates the number of new posts in a forum that the user has not yet read.

Nodes are new if they are newer than NODE_NEW_LIMIT.

Parameters
$term | The term ID of the forum.
$uid | The user ID.
Returns
The number of new posts in the forum that have not been read by the user.

Definition at line 883 of file forum.module.

References db_select(), and NODE_NEW_LIMIT.

Referenced by template_preprocess_forum_list().

_forum_update_forum_index ( $nid )

Updates the taxonomy index for a given node.

Parameters
$nid The ID of the node to update.

Definition at line 1339 of file forum.module.

References COMMENT_PUBLISHED, db_query(), db_query_range(), and db_update().

Referenced by forum_comment_delete(), forum_comment_publish(), forum_comment_unpublish(), forum_comment_update(), forum_field_storage_pre_update(), and hook_field_storage_pre_update().

_forum_user_last_visit ( $nid )

Gets the last time the user viewed a node.

Parameters
$nid The node ID.
Returns
The timestamp when the user last viewed this node, if the user has previously viewed the node; otherwise NODE_NEW_LIMIT.

Definition at line 1288 of file forum.module.

References db_query(), drupal_static(), and NODE_NEW_LIMIT.

Referenced by forum_get_topics().

forum_block_configure ( $delta = '' )

Implements hook_block_configure().

Definition at line 662 of file forum.module.

References drupal_map_assoc(), t(), and variable_get().

forum_block_info ( )

Implements hook_block_info().

Definition at line 645 of file forum.module.

References DRUPAL_CACHE_CUSTOM, and t().

forum_block_save | ( | $delta = '',
 |  | $edit = array()
 | ) |

Implements hook_block_save().

Definition at line 675 of file forum.module.

References variable_set().

forum_block_view ( $delta = '' )

Implements hook_block_view().

Generates a block containing the currently active forum topics and the most recently added forum topics.

Definition at line 685 of file forum.module.

References $title, db_select(), drupal_render_cache_by_query(), t(), user_access(), and variable_get().

forum_block_view_pre_render ( $elements )

Render API callback: Lists nodes based on the element's #query property.

This function can be used as a #pre_render callback.

See Also
forum_block_view()

Definition at line 719 of file forum.module.

References node_title_list(), and t().

forum_comment_delete ( $comment )

Implements hook_comment_delete().

Definition at line 520 of file forum.module.

References _forum_update_forum_index().

forum_comment_publish ( $comment )

Implements hook_comment_publish().

This actually handles the insertion and update of published nodes since comment_save() calls hook_comment_publish() for all published comments.

Definition at line 492 of file forum.module.

References _forum_update_forum_index().

forum_comment_unpublish ( $comment )

Implements hook_comment_unpublish().

Definition at line 513 of file forum.module.

References _forum_update_forum_index().

forum_comment_update ( $comment )

Implements hook_comment_update().

The Comment module doesn't call hook_comment_unpublish() when saving individual comments, so we need to check for those here.

Definition at line 502 of file forum.module.

References _forum_update_forum_index().

forum_entity_info_alter ( & $info )

Implements hook_entity_info_alter().

Definition at line 217 of file forum.module.

References $info, taxonomy_vocabulary_get_names(), and variable_get().

forum_field_storage_pre_insert | ( |  | $entity_type,
 |  |  | $entity,
 |  | & | $skip_fields
 | ) |  |

Implements hook_field_storage_pre_insert().

Definition at line 527 of file forum.module.

References _forum_node_check_node_type(), and db_insert().

forum_field_storage_pre_update | ( |  | $entity_type,
 |  |  | $entity,
 |  | & | $skip_fields
 | ) |  |

Implements hook_field_storage_pre_update().

Definition at line 550 of file forum.module.

References _forum_node_check_node_type(), _forum_update_forum_index(), db_delete(), db_insert(), and drupal_static().

forum_form | ( | $node,
 |  | $form_state
 | ) |

Implements hook_form().

Definition at line 731 of file forum.module.

References check_plain(), node_type_get_type(), and t().

forum_form_node_form_alter | ( | & | $form,
 |  | & | $form_state,
 |  |  | $form_id
 | ) |  |

Implements hook_form_BASE_FORM_ID_alter() for node_form().

Definition at line 626 of file forum.module.

References arg().

forum_form_taxonomy_form_term_alter | ( | & | $form,
 |  | & | $form_state,
 |  |  | $form_id
 | ) |  |

Implements hook_form_FORM_ID_alter() for taxonomy_form_term().

Definition at line 615 of file forum.module.

References variable_get().

forum_form_taxonomy_form_vocabulary_alter | ( | & | $form,
 |  | & | $form_state,
 |  |  | $form_id
 | ) |  |

Implements hook_form_FORM_ID_alter() for taxonomy_form_vocabulary().

Definition at line 596 of file forum.module.

References t(), and variable_get().

forum_forum_load ( $tid = NULL )

Returns a tree of all forums for a given taxonomy term ID.

Parameters
$tid (optional) Taxonomy term ID of the forum. If not given all forums will be returned.
Returns
A tree of taxonomy objects, with the following additional properties:
  • num_topics: Number of topics in the forum.
  • num_posts: Total number of posts in all topics.
  • last_post: Most recent post for the forum.
  • forums: An array of child forums.

Definition at line 765 of file forum.module.

References db_select(), drupal_static(), taxonomy_get_parents_all(), taxonomy_get_tree(), taxonomy_term_load(), and variable_get().

Referenced by forum_menu_local_tasks_alter(), and forum_page().

forum_get_topics | ( | $tid,
 |  | $sortby,
 |  | $forum_per_page
 | ) |

Gets all the topics in a forum.

Parameters
$tid | The term ID of the forum.
$sortby One of the following integers indicating the sort criteria:
  • 1: Date - newest first.
  • 2: Date - oldest first.
  • 3: Posts with the most comments first.
  • 4: Posts with the least comments first.
$forum_per_page | The maximum number of topics to display per page.
Returns
A list of all the topics in a forum.

Definition at line 914 of file forum.module.

References $topics, _forum_get_topic_order(), _forum_user_last_visit(), comment_num_new(), db_select(), and t().

Referenced by forum_page().

forum_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file forum.module.

References $output, t(), theme(), and url().

forum_menu ( )

Implements hook_menu().

Definition at line 89 of file forum.module.

References MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION, and MENU_LOCAL_TASK.

forum_menu_local_tasks_alter | ( | & | $data,
 |  |  | $router_item,
 |  |  | $root_path
 | ) |  |

Implements hook_menu_local_tasks_alter().

Definition at line 164 of file forum.module.

References $links, drupal_get_destination(), field_info_field(), forum_forum_load(), node_access(), node_type_get_name(), t(), and url().

forum_node_delete ( $node )

Implements hook_node_delete().

Definition at line 414 of file forum.module.

References _forum_node_check_node_type(), and db_delete().

forum_node_info ( )

Implements hook_node_info().

Definition at line 450 of file forum.module.

References t().

forum_node_insert ( $node )

Implements hook_node_insert().

Definition at line 397 of file forum.module.

References _forum_node_check_node_type(), and db_insert().

forum_node_load ( $nodes )

Implements hook_node_load().

Definition at line 428 of file forum.module.

References _forum_node_check_node_type(), and db_select().

forum_node_presave ( $node )

Implements hook_node_presave().

Assigns the forum taxonomy when adding a topic from within a forum.

Definition at line 327 of file forum.module.

References _forum_node_check_node_type(), and db_query_range().

forum_node_update ( $node )

Implements hook_node_update().

Definition at line 349 of file forum.module.

References _forum_node_check_node_type(), db_delete(), db_insert(), db_query(), and db_update().

forum_node_validate | ( | $node,
 |  | $form
 | ) |

Implements hook_node_validate().

Checks in particular that the node is assigned only a "leaf" term in the forum taxonomy.

Definition at line 291 of file forum.module.

References _forum_node_check_node_type(), db_query_range(), form_set_error(), t(), taxonomy_term_load(), and variable_get().

forum_node_view | ( | $node,
 |  | $view_mode
 | ) |

Implements hook_node_view().

Definition at line 265 of file forum.module.

References $breadcrumb, _forum_node_check_node_type(), drupal_set_breadcrumb(), l(), node_is_page(), t(), taxonomy_get_parents_all(), taxonomy_vocabulary_load(), and variable_get().

forum_permission ( )

Implements hook_permission().

Definition at line 464 of file forum.module.

References t().

forum_rdf_mapping ( )

Implements hook_rdf_mapping().

Definition at line 1375 of file forum.module.

forum_taxonomy_term_delete ( $term )

Implements hook_taxonomy_term_delete().

Definition at line 476 of file forum.module.

References variable_get(), and variable_set().

forum_theme ( )

Implements hook_theme().

Definition at line 57 of file forum.module.

forum_uri ( $forum )

Implements callback_entity_info_uri().

Entity URI callback used in forum_entity_info_alter().

Definition at line 240 of file forum.module.

template_preprocess_forum_icon ( & $variables )

Preprocesses variables for forum-icon.tpl.php.

Parameters
$variables An array containing the following elements:
  • new_posts: Indicates whether or not the topic contains new posts.
  • num_posts: The total number of posts in all topics.
  • comment_mode: An integer indicating whether comments are open, closed, or hidden.
  • sticky: Indicates whether the topic is sticky.
  • first_new: Indicates whether this is the first topic with new posts.
See Also
forum-icon.tpl.php
theme_forum_icon()

Definition at line 1238 of file forum.module.

References COMMENT_NODE_CLOSED, COMMENT_NODE_HIDDEN, t(), and variable_get().

template_preprocess_forum_list ( & $variables )

Preprocesses variables for forum-list.tpl.php.

Parameters
$variables An array containing the following elements:
  • forums: An array of all forum objects to display for the given taxonomy term ID. If tid = 0 then all the top-level forums are displayed.
  • parents: An array of taxonomy term objects that are ancestors of the current term ID.
  • tid: Taxonomy term ID of the current forum.
See Also
forum-list.tpl.php
theme_forum_list()

Definition at line 1121 of file forum.module.

References $row, _forum_topics_unread(), check_plain(), filter_xss_admin(), format_plural(), t(), theme(), and url().

template_preprocess_forum_submitted ( & $variables )

Preprocesses variables for forum-submitted.tpl.php.

The submission information will be displayed in the forum list and topic list.

Parameters
$variables An array containing the following elements:
  • topic: The topic object.
See Also
forum-submitted.tpl.php
theme_forum_submitted()

Definition at line 1273 of file forum.module.

References created, format_interval(), REQUEST_TIME, and theme().

template_preprocess_forum_topic_list ( & $variables )

Preprocesses variables for forum-topic-list.tpl.php.

Parameters
$variables An array containing the following elements:
  • tid: Taxonomy term ID of the current forum.
  • topics: An array of all the topics in the current forum.
  • forum_per_page: The maximum number of topics to display per page.
See Also
forum-topic-list.tpl.php
theme_forum_topic_list()

Definition at line 1168 of file forum.module.

References $header, $row, _theme_table_cell(), check_plain(), comment_new_page_count(), format_plural(), l(), t(), tablesort_header(), tablesort_init(), theme(), and url().

template_preprocess_forums ( & $variables )

Preprocesses variables for forums.tpl.php.

Parameters
$variables An array containing the following elements:
  • forums: An array of all forum objects to display for the given taxonomy term ID. If tid = 0 then all the top-level forums are displayed.
  • topics: An array of all the topics in the current forum.
  • parents: An array of taxonomy term objects that are ancestors of the current term ID.
  • tid: Taxonomy term ID of the current forum.
  • sortby: One of the following integers indicating the sort criteria:
    • 1: Date - newest first.
    • 2: Date - oldest first.
    • 3: Posts with the most comments first.
    • 4: Posts with the least comments first.
  • forum_per_page: The maximum number of topics to display per page.
See Also
forums.tpl.php

Definition at line 1041 of file forum.module.

References $breadcrumb, $title, drupal_add_feed(), drupal_set_breadcrumb(), drupal_set_title(), l(), t(), taxonomy_vocabulary_load(), theme(), and variable_get().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum.pages.inc File Reference

  • modules
  • forum
Functions
forum.pages.inc File Reference

Go to the source code of this file.

Functions

forum_page ($forum_term=NULL)

Detailed Description

User page callbacks for the Forum module.

Definition in file forum.pages.inc.

Function Documentation

forum_page ( $forum_term = NULL )

Page callback: Prints a forum listing.

Parameters
$forum_term A tree of all forums for a given taxonomy term ID. Defaults to NULL. See the return object of forum_forum_load() for a complete definition.
Returns
A string containing HTML representing the themed forum listing.
See Also
forum_menu()

Definition at line 20 of file forum.pages.inc.

References $topics, forum_forum_load(), forum_get_topics(), theme(), and variable_get().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/help Directory Reference

  • modules
  • help
help Directory Reference

Files

file | help.admin.inc [code]
file | help.api.php [code]
file | help.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/help/help.admin.inc File Reference

  • modules
  • help
Functions
help.admin.inc File Reference

Go to the source code of this file.

Functions

help_main ()
help_page ($name)
help_links_as_list ()

Detailed Description

Admin page callbacks for the help module.

Definition in file help.admin.inc.

Function Documentation

help_links_as_list ( )

Provides a formatted list of available help topics.

Returns
A string containing the formatted list.

Definition at line 58 of file help.admin.inc.

References $module, $name, $output, drupal_help_arg(), l(), module_implements(), module_invoke(), and system_rebuild_module_data().

Referenced by help_main().

help_main ( )

Menu callback; prints a page listing a glossary of Drupal terminology.

Definition at line 11 of file help.admin.inc.

References $output, drupal_add_css(), drupal_get_path(), help_links_as_list(), and t().

help_page ( $name )

Menu callback; prints a page listing general help for a module.

Parameters
$name A module name to display a help page for.

Definition at line 24 of file help.admin.inc.

References $info, $links, $name, $output, drupal_help_arg(), drupal_set_title(), l(), module_hook(), module_invoke(), system_get_info(), system_get_module_admin_tasks(), t(), and theme().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/help/help.api.php File Reference

  • modules
  • help
Functions
help.api.php File Reference

Go to the source code of this file.

Functions

hook_help ($path, $arg)

Detailed Description

Hooks provided by the Help module.

Definition in file help.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/help/help.module File Reference

  • modules
  • help
Functions
help.module File Reference

Go to the source code of this file.

Functions

help_menu ()
help_help ($path, $arg)

Detailed Description

Manages displaying online help.

Definition in file help.module.

Function Documentation

help_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 38 of file help.module.

References $output, t(), and url().

help_menu ( )

Implements hook_menu().

Definition at line 11 of file help.module.

References $module, MENU_VISIBLE_IN_BREADCRUMB, and module_implements().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/image Directory Reference

  • modules
  • image
image Directory Reference

Files

file | image.admin.inc [code]
file | image.api.php [code]
file | image.effects.inc [code]
file | image.field.inc [code]
file | image.install [code]
file | image.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/image/image.admin.inc File Reference

  • modules
  • image
Functions
image.admin.inc File Reference

Go to the source code of this file.

Functions

image_style_list ()
image_style_form ($form, &$form_state, $style)
image_style_form_add_validate ($form, &$form_state)
image_style_form_add_submit ($form, &$form_state)
image_style_form_override_submit ($form, &$form_state)
image_style_form_submit ($form, &$form_state)
image_style_add_form ($form, &$form_state)
image_style_add_form_submit ($form, &$form_state)
image_style_name_validate ($element, $form_state)
image_style_delete_form ($form, &$form_state, $style)
image_style_delete_form_submit ($form, &$form_state)
image_style_revert_form ($form, &$form_state, $style)
image_style_revert_form_submit ($form, &$form_state)
image_effect_form ($form, &$form_state, $style, $effect)
image_effect_form_submit ($form, &$form_state)
image_effect_delete_form ($form, &$form_state, $style, $effect)
image_effect_delete_form_submit ($form, &$form_state)
image_effect_integer_validate ($element, &$form_state)
image_effect_color_validate ($element, &$form_state)
image_effect_scale_validate ($element, &$form_state)
image_resize_form ($data)
image_scale_form ($data)
image_crop_form ($data)
image_rotate_form ($data)
theme_image_style_list ($variables)
theme_image_style_effects ($variables)
theme_image_style_preview ($variables)
theme_image_anchor ($variables)
theme_image_resize_summary ($variables)
theme_image_scale_summary ($variables)
theme_image_crop_summary ($variables)
theme_image_rotate_summary ($variables)

Detailed Description

Administration pages for image settings.

Definition in file image.admin.inc.

Function Documentation

image_crop_form ( $data )

Form structure for the image crop form.

Note that this is not a complete form, it only contains the portion of the form for configuring the crop options. Therefore it does not not need to include metadata about the effect, nor a submit button.

Parameters
$data The current configuration for this crop effect.

Definition at line 583 of file image.admin.inc.

References image_resize_form(), and t().

image_effect_color_validate | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Element validate handler to ensure a hexadecimal color value.

Definition at line 496 of file image.admin.inc.

References form_error(), and t().

image_effect_delete_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to delete an image effect.

Definition at line 467 of file image.admin.inc.

References drupal_set_message(), image_effect_delete(), and t().

image_effect_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for updating an image effect.

Definition at line 437 of file image.admin.inc.

References drupal_set_message(), image_effect_save(), and t().

image_effect_integer_validate | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Element validate handler to ensure an integer pixel value.

The property #allow_negative = TRUE may be set to allow negative integers.

Definition at line 481 of file image.admin.inc.

References $value, form_error(), and t().

image_effect_scale_validate | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Element validate handler to ensure that either a height or a width is specified.

Definition at line 509 of file image.admin.inc.

References form_error(), and t().

image_resize_form ( $data )

Form structure for the image resize form.

Note that this is not a complete form, it only contains the portion of the form for configuring the resize options. Therefore it does not not need to include metadata about the effect, nor a submit button.

Parameters
$data The current configuration for this resize effect.

Definition at line 525 of file image.admin.inc.

References t().

Referenced by image_crop_form(), and image_scale_form().

image_rotate_form ( $data )

Form structure for the image rotate form.

Note that this is not a complete form, it only contains the portion of the form for configuring the rotate options. Therefore it does not not need to include metadata about the effect, nor a submit button.

Parameters
$data The current configuration for this rotate effect.

Definition at line 623 of file image.admin.inc.

References t().

image_scale_form ( $data )

Form structure for the image scale form.

Note that this is not a complete form, it only contains the portion of the form for configuring the scale options. Therefore it does not not need to include metadata about the effect, nor a submit button.

Parameters
$data The current configuration for this scale effect.

Definition at line 559 of file image.admin.inc.

References image_resize_form(), and t().

image_style_add_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for adding a new image style.

Definition at line 273 of file image.admin.inc.

References drupal_set_message(), image_style_save(), and t().

image_style_delete_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to delete an image style.

Definition at line 336 of file image.admin.inc.

References drupal_set_message(), image_style_delete(), and t().

image_style_form_add_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for adding a new image effect to an image style.

Definition at line 182 of file image.admin.inc.

References drupal_set_message(), image_effect_definition_load(), image_effect_save(), and t().

image_style_form_add_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate handler for adding a new image effect to an image style.

Definition at line 173 of file image.admin.inc.

References form_error(), and t().

image_style_form_override_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for overriding a module-defined style.

Definition at line 204 of file image.admin.inc.

References drupal_set_message(), image_default_style_save(), and t().

image_style_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for saving an image style.

Definition at line 212 of file image.admin.inc.

References drupal_set_message(), image_effect_save(), image_style_save(), and t().

image_style_list ( )

Menu callback; Listing of all current image styles.

Definition at line 11 of file image.admin.inc.

References $page, $styles, drupal_get_path(), image_styles(), and theme().

image_style_name_validate | ( | $element,
 |  | $form_state
 | ) |

Element validate function to ensure unique, URL safe style names.

This function is no longer used in Drupal core since image style names are now validated using #machine_name functionality. It is kept for backwards compatibility (since non-core modules may be using it) and will be removed in Drupal 8.

Definition at line 291 of file image.admin.inc.

References $styles, form_set_error(), image_styles(), and t().

image_style_revert_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $style
 | ) |  |

Confirmation form to revert a database style to its default.

Definition at line 347 of file image.admin.inc.

References confirm_form(), and t().

image_style_revert_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to convert an overridden style to its default.

Definition at line 362 of file image.admin.inc.

References drupal_set_message(), image_default_style_revert(), and t().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/image/image.api.php File Reference

  • modules
  • image
Functions
image.api.php File Reference

Go to the source code of this file.

Functions

hook_image_effect_info ()
hook_image_effect_info_alter (&$effects)
hook_image_style_save ($style)
hook_image_style_delete ($style)
hook_image_style_flush ($style)
hook_image_styles_alter (&$styles)
hook_image_default_styles ()

Detailed Description

Hooks related to image styles and effects.

Definition in file image.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/image/image.effects.inc File Reference

  • modules
  • image
Functions
image.effects.inc File Reference

Go to the source code of this file.

Functions

image_image_effect_info ()
image_resize_effect (&$image, $data)
image_resize_dimensions (array &$dimensions, array $data)
image_scale_effect (&$image, $data)
image_scale_dimensions (array &$dimensions, array $data)
image_crop_effect (&$image, $data)
image_scale_and_crop_effect (&$image, $data)
image_desaturate_effect (&$image, $data)
image_rotate_effect (&$image, $data)
image_rotate_dimensions (array &$dimensions, array $data)

Detailed Description

Functions needed to execute image effects provided by Image module.

Definition in file image.effects.inc.

Function Documentation

image_crop_effect | ( | & | $image,
 |  |  | $data
 | ) |  |

Image effect callback; Crop an image resource.

Parameters
$image An image object returned by image_load().
$data An array of attributes to use when performing the crop effect with the following items:
  • "width": An integer representing the desired width in pixels.
  • "height": An integer representing the desired height in pixels.
  • "anchor": A string describing where the crop should originate in the form of "XOFFSET-YOFFSET". XOFFSET is either a number of pixels or "left", "center", "right" and YOFFSET is either a number of pixels or "top", "center", "bottom".
Returns
TRUE on success. FALSE on failure to crop image.
See Also
image_crop()

Definition at line 177 of file image.effects.inc.

References image_crop(), image_filter_keyword(), watchdog(), and WATCHDOG_ERROR.

image_desaturate_effect | ( | & | $image,
 |  |  | $data
 | ) |  |

Image effect callback; Desaturate (grayscale) an image resource.

Parameters
$image | An image object returned by image_load().
$data | An array of attributes to use when performing the desaturate effect.
Returns
TRUE on success. FALSE on failure to desaturate image.
See Also
image_desaturate()

Definition at line 226 of file image.effects.inc.

References image_desaturate(), watchdog(), and WATCHDOG_ERROR.

image_image_effect_info ( )

Implements hook_image_effect_info().

Definition at line 11 of file image.effects.inc.

References t().

image_resize_dimensions | ( | array & | $dimensions,
 |  | array | $data
 | ) |  |

Image dimensions callback; Resize.

Parameters
$dimensions Dimensions to be modified - an array with components width and height, in pixels.
$data An array of attributes to use when performing the resize effect with the following items:
  • "width": An integer representing the desired width in pixels.
  • "height": An integer representing the desired height in pixels.

Definition at line 100 of file image.effects.inc.

image_resize_effect | ( | & | $image,
 |  |  | $data
 | ) |  |

Image effect callback; Resize an image resource.

Parameters
$image An image object returned by image_load().
$data An array of attributes to use when performing the resize effect with the following items:
  • "width": An integer representing the desired width in pixels.
  • "height": An integer representing the desired height in pixels.
Returns
TRUE on success. FALSE on failure to resize image.
See Also
image_resize()

Definition at line 80 of file image.effects.inc.

References image_resize(), watchdog(), and WATCHDOG_ERROR.

image_rotate_dimensions | ( | array & | $dimensions,
 |  | array | $data
 | ) |  |

Image dimensions callback; Rotate.

Parameters
$dimensions Dimensions to be modified - an array with components width and height, in pixels.
$data An array of attributes to use when performing the rotate effect containing the following items:
  • "degrees": The number of (clockwise) degrees to rotate the image.
  • "random": A boolean indicating that a random rotation angle should be used for this image. The angle specified in "degrees" is used as a positive and negative maximum.

Definition at line 301 of file image.effects.inc.

image_rotate_effect | ( | & | $image,
 |  |  | $data
 | ) |  |

Image effect callback; Rotate an image resource.

Parameters
$image An image object returned by image_load().
$data An array of attributes to use when performing the rotate effect containing the following items:
  • "degrees": The number of (clockwise) degrees to rotate the image.
  • "random": A boolean indicating that a random rotation angle should be used for this image. The angle specified in "degrees" is used as a positive and negative maximum.
  • "bgcolor": The background color to use for exposed areas of the image. Use web-style hex colors (#FFFFFF for white, #000000 for black). Leave blank for transparency on image types that support it.
Returns
TRUE on success. FALSE on failure to rotate image.
See Also
image_rotate().

Definition at line 253 of file image.effects.inc.

References image_rotate(), watchdog(), and WATCHDOG_ERROR.

image_scale_and_crop_effect | ( | & | $image,
 |  |  | $data
 | ) |  |

Image effect callback; Scale and crop an image resource.

Parameters
$image An image object returned by image_load().
$data An array of attributes to use when performing the scale and crop effect with the following items:
  • "width": An integer representing the desired width in pixels.
  • "height": An integer representing the desired height in pixels.
Returns
TRUE on success. FALSE on failure to scale and crop image.
See Also
image_scale_and_crop()

Definition at line 207 of file image.effects.inc.

References image_scale_and_crop(), watchdog(), and WATCHDOG_ERROR.

image_scale_dimensions | ( | array & | $dimensions,
 |  | array | $data
 | ) |  |

Image dimensions callback; Scale.

Parameters
$dimensions Dimensions to be modified - an array with components width and height, in pixels.
$data An array of attributes to use when performing the scale effect with the following items:
  • "width": An integer representing the desired width in pixels.
  • "height": An integer representing the desired height in pixels.
  • "upscale": A boolean indicating that the image should be upscaled if the dimensions are larger than the original image.

Definition at line 153 of file image.effects.inc.

References image_dimensions_scale().

image_scale_effect | ( | & | $image,
 |  |  | $data
 | ) |  |

Image effect callback; Scale an image resource.

Parameters
$image An image object returned by image_load().
$data An array of attributes to use when performing the scale effect with the following items:
  • "width": An integer representing the desired width in pixels.
  • "height": An integer representing the desired height in pixels.
  • "upscale": A boolean indicating that the image should be upscaled if the dimensions are larger than the original image.
Returns
TRUE on success. FALSE on failure to scale image.
See Also
image_scale()

Definition at line 124 of file image.effects.inc.

References image_scale(), watchdog(), and WATCHDOG_ERROR.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/image/image.field.inc File Reference

  • modules
  • image
Functions
image.field.inc File Reference

Go to the source code of this file.

Functions

image_field_info ()
image_field_settings_form ($field, $instance)
image_field_instance_settings_form ($field, $instance)
_image_field_resolution_validate ($element, &$form_state)
image_field_load ($entity_type, $entities, $field, $instances, $langcode, &$items, $age)
image_field_prepare_view ($entity_type, $entities, $field, $instances, $langcode, &$items)
image_field_presave ($entity_type, $entity, $field, $instance, $langcode, &$items)
image_field_insert ($entity_type, $entity, $field, $instance, $langcode, &$items)
image_field_update ($entity_type, $entity, $field, $instance, $langcode, &$items)
image_field_delete ($entity_type, $entity, $field, $instance, $langcode, &$items)
image_field_delete_revision ($entity_type, $entity, $field, $instance, $langcode, &$items)
image_field_is_empty ($item, $field)
image_field_widget_info ()
image_field_widget_settings_form ($field, $instance)
image_field_widget_form (&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
image_field_widget_process ($element, &$form_state, $form)
theme_image_widget ($variables)
image_field_formatter_info ()
image_field_formatter_settings_form ($field, $instance, $view_mode, $form, &$form_state)
image_field_formatter_settings_summary ($field, $instance, $view_mode)
image_field_formatter_view ($entity_type, $entity, $field, $instance, $langcode, $items, $display)
theme_image_formatter ($variables)

Detailed Description

Implement an image field, based on the file module's file field.

Definition in file image.field.inc.

Function Documentation

_image_field_resolution_validate | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Element validate function for resolution fields.

Definition at line 171 of file image.field.inc.

References $value, form_error(), form_set_value(), and t().

image_field_delete | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_delete().

Definition at line 263 of file image.field.inc.

References file_field_delete().

image_field_delete_revision | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_delete_revision().

Definition at line 270 of file image.field.inc.

References file_field_delete_revision().

image_field_formatter_info ( )

Implements hook_field_formatter_info().

Definition at line 479 of file image.field.inc.

References t().

image_field_formatter_settings_form | ( |  | $field,
 |  |  | $instance,
 |  |  | $view_mode,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_field_formatter_settings_form().

Definition at line 494 of file image.field.inc.

References image_style_options(), PASS_THROUGH, and t().

image_field_formatter_settings_summary | ( | $field,
 |  | $instance,
 |  | $view_mode
 | ) |

Implements hook_field_formatter_settings_summary().

Definition at line 525 of file image.field.inc.

References image_style_options(), PASS_THROUGH, and t().

image_field_formatter_view | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance,
 |  | $langcode,
 |  | $items,
 |  | $display
 | ) |

Implements hook_field_formatter_view().

Definition at line 558 of file image.field.inc.

References entity_uri(), and file_create_url().

image_field_info ( )

Implements hook_field_info().

Definition at line 11 of file image.field.inc.

References t(), and variable_get().

image_field_insert | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_insert().

Definition at line 249 of file image.field.inc.

References file_field_insert().

image_field_instance_settings_form | ( | $field,
 |  | $instance
 | ) |

Implements hook_field_instance_settings_form().

Definition at line 72 of file image.field.inc.

References file_field_instance_settings_form(), and t().

image_field_is_empty | ( | $item,
 |  | $field
 | ) |

Implements hook_field_is_empty().

Definition at line 277 of file image.field.inc.

References file_field_is_empty().

image_field_load | ( |  | $entity_type,
 |  |  | $entities,
 |  |  | $field,
 |  |  | $instances,
 |  |  | $langcode,
 |  | & | $items,
 |  |  | $age
 | ) |  |

Implements hook_field_load().

Definition at line 194 of file image.field.inc.

References file_field_load().

image_field_prepare_view | ( |  | $entity_type,
 |  |  | $entities,
 |  |  | $field,
 |  |  | $instances,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_prepare_view().

Definition at line 201 of file image.field.inc.

References file_load().

image_field_presave | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_presave().

Definition at line 230 of file image.field.inc.

References $info, file_field_presave(), file_load(), and image_get_info().

image_field_settings_form | ( | $field,
 |  | $instance
 | ) |

Implements hook_field_settings_form().

Definition at line 39 of file image.field.inc.

References field_info_field_settings(), file_get_stream_wrappers(), STREAM_WRAPPERS_WRITE_VISIBLE, and t().

image_field_update | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  | & | $items
 | ) |  |

Implements hook_field_update().

Definition at line 256 of file image.field.inc.

References file_field_update().

image_field_widget_form | ( | & | $form,
 |  | & | $form_state,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  |  | $delta,
 |  |  | $element
 | ) |  |

Implements hook_field_widget_form().

Definition at line 327 of file image.field.inc.

References element_children(), field_filter_xss(), file_field_widget_form(), and theme().

image_field_widget_info ( )

Implements hook_field_widget_info().

Definition at line 284 of file image.field.inc.

References FIELD_BEHAVIOR_CUSTOM, FIELD_BEHAVIOR_NONE, and t().

image_field_widget_process | ( |  | $element,
 |  | & | $form_state,
 |  |  | $form
 | ) |  |

An element #process callback for the image_image field type.

Expands the image_image type to include the alt and title fields.

Definition at line 368 of file image.field.inc.

References $info, drupal_get_path(), field_widget_instance(), image_get_info(), t(), and theme().

image_field_widget_settings_form | ( | $field,
 |  | $instance
 | ) |

Implements hook_field_widget_settings_form().

Definition at line 304 of file image.field.inc.

References file_field_widget_settings_form(), image_style_options(), PASS_THROUGH, and t().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/image/image.install File Reference

  • modules
  • image
Functions
image.install File Reference

Go to the source code of this file.

Functions

image_install ()
image_uninstall ()
image_schema ()
image_field_schema ($field)
image_update_dependencies ()
image_update_7000 ()
image_update_7001 ()
_image_update_7002_add_columns ($table, $field_name)
_image_update_7002_populate_dimensions ($table, $field_name, &$last_fid)
image_update_7002 (array &$sandbox)
image_update_7003 ()
image_update_7004 ()
image_update_7005 ()
image_requirements ($phase)

Detailed Description

Install, update and uninstall functions for the image module.

Definition in file image.install.

Function Documentation

image_field_schema ( $field )

Implements hook_field_schema().

Definition at line 119 of file image.install.

image_install ( )

Implements hook_install().

Definition at line 11 of file image.install.

References FILE_CREATE_DIRECTORY, file_default_scheme(), FILE_MODIFY_PERMISSIONS, and file_prepare_directory().

image_requirements ( $phase )

End of "addtogroup updates-7.x-extra". Implements hook_requirements() to check the PHP GD Library.

Parameters
$phase

Definition at line 491 of file image.install.

References $info, REQUIREMENT_ERROR, REQUIREMENT_OK, REQUIREMENT_WARNING, and t().

image_schema ( )

Implements hook_schema().

Definition at line 28 of file image.install.

References drupal_get_schema_unprocessed().

image_uninstall ( )

Implements hook_uninstall().

Definition at line 20 of file image.install.

References file_default_scheme(), and file_unmanaged_delete_recursive().

image_update_7000 ( )

Install the schema for users upgrading from the contributed module.

Definition at line 178 of file image.install.

References db_create_table(), db_table_exists(), and system_schema_cache_7054().

image_update_dependencies ( )

Implements hook_update_dependencies().

Definition at line 166 of file image.install.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/image/image.module File Reference

  • modules
  • image
Functions | Variables
image.module File Reference

Go to the source code of this file.

Functions

image_help ($path, $arg)
image_menu ()
image_theme ()
image_permission ()
image_form_system_file_system_settings_alter (&$form, &$form_state)
image_system_file_system_settings_submit ($form, &$form_state)
image_flush_caches ()
image_file_download ($uri)
image_file_move ($file, $source)
image_file_delete ($file)
image_image_default_styles ()
image_image_style_save ($style)
image_image_style_delete ($style)
image_field_delete_field ($field)
image_field_update_field ($field, $prior_field, $has_data)
image_field_delete_instance ($instance)
image_field_update_instance ($instance, $prior_instance)
image_path_flush ($path)
image_styles ()
image_style_load ($name=NULL, $isid=NULL, $include=NULL)
image_style_save ($style)
image_style_delete ($style, $replacement_style_name= '')
image_style_effects ($style)
image_style_options ($include_empty=TRUE, $output=CHECK_PLAIN)
image_style_deliver ($style, $scheme)
image_style_create_derivative ($style, $source, $destination)
image_style_transform_dimensions ($style_name, array &$dimensions)
image_style_flush ($style)
image_style_url ($style_name, $path)
image_style_path_token ($style_name, $uri)
image_style_path ($style_name, $uri)
image_default_style_save ($style)
image_default_style_revert ($style)
image_effect_definitions ()
image_effect_definition_load ($effect, $style_name=NULL)
image_effects ()
image_effect_load ($ieid, $style_name, $include=NULL)
image_effect_save ($effect)
image_effect_delete ($effect)
image_effect_apply ($image, $effect)
theme_image_style ($variables)
image_filter_keyword ($value, $current_pixels, $new_pixels)
_image_effect_definitions_sort ($a, $b)

Variables

const | IMAGE_STORAGE_NORMAL 1
const | IMAGE_STORAGE_OVERRIDE 2
const | IMAGE_STORAGE_DEFAULT 4
const | IMAGE_STORAGE_EDITABLE IMAGE_STORAGE_NORMAL | IMAGE_STORAGE_OVERRIDE
const | IMAGE_STORAGE_MODULE IMAGE_STORAGE_OVERRIDE | IMAGE_STORAGE_DEFAULT
const | IMAGE_DERIVATIVE_TOKEN 'itok'

Detailed Description

Exposes global functionality for creating image styles.

Definition in file image.module.

Function Documentation

_image_effect_definitions_sort | ( | $a,
 |  | $b
 | ) |

Internal function for sorting image effect definitions through uasort().

See Also
image_effect_definitions()

Definition at line 1391 of file image.module.

image_default_style_revert ( $style )

Reverts the changes made by users to a default image style.

Parameters
style An image style array.
Returns
Boolean TRUE if the operation succeeded.

Definition at line 1116 of file image.module.

References db_delete(), and image_style_flush().

Referenced by image_style_revert_form_submit().

image_default_style_save ( $style )

Saves a default image style to the database.

Parameters
style An image style array provided by a module.
Returns
An image style array. The returned style array will include the new 'isid' assigned to the style.

Definition at line 1096 of file image.module.

References image_effect_save(), and image_style_save().

Referenced by image_style_form_override_submit().

image_effect_apply | ( | $image,
 |  | $effect
 | ) |

Applies an image effect to the image object.

Parameters
$image | An image object returned by image_load().
$effect | An image effect array.
Returns
TRUE on success. FALSE if unable to perform the image effect on the image.

Definition at line 1317 of file image.module.

References module_load_include().

Referenced by image_style_create_derivative().

image_effect_definition_load | ( | $effect,
 |  | $style_name = NULL
 | ) |

Loads the definition for an image effect.

The effect definition is a set of core properties for an image effect, not containing any user-settings. The definition defines various functions to call when configuring or executing an image effect. This loader is mostly for internal use within image.module. Use image_effect_load() or image_style_load() to get image effects that contain configuration.

Parameters
$effect | The name of the effect definition to load.
$style | An image style array to which this effect will be added.
Returns
An array containing the image effect definition with the following keys:
  • "effect": The unique name for the effect being performed. Usually prefixed with the name of the module providing the effect.
  • "module": The module providing the effect.
  • "help": A description of the effect.
  • "function": The name of the function that will execute the effect.
  • "form": (optional) The name of a function to configure the effect.
  • "summary": (optional) The name of a theme function that will display a one-line summary of the effect. Does not include the "theme_" prefix.

Definition at line 1195 of file image.module.

References image_effect_definitions(), IMAGE_STORAGE_DEFAULT, and image_style_load().

Referenced by image_effects(), image_help(), image_style_form_add_submit(), and image_styles().

image_effect_definitions ( )

Returns a set of image effects.

These image effects are exposed by modules implementing hook_image_effect_info().

Returns
An array of image effects to be used when transforming images.
See Also
hook_image_effect_info()
image_effect_definition_load()

Definition at line 1136 of file image.module.

References $module, $name, cache_get(), cache_set(), drupal_alter(), DRUPAL_ROOT, drupal_static(), module_implements(), and module_invoke().

Referenced by image_effect_definition_load(), and image_style_form().

image_effect_delete ( $effect )

Deletes an image effect.

Parameters
$effect An image effect array.

Definition at line 1300 of file image.module.

References db_delete(), image_style_flush(), and image_style_load().

Referenced by image_effect_delete_form_submit().

image_effect_load | ( | $ieid,
 |  | $style_name,
 |  | $include = NULL
 | ) |

Loads a single image effect.

Parameters
$ieid | The image effect ID.
$style_name | The image style name.
$include | If set, this loader will restrict to a specific type of image style, may be one of the defined Image style storage constants.
Returns
An image effect array, consisting of the following keys:
  • "ieid": The unique image effect ID.
  • "isid": The unique image style ID that contains this image effect.
  • "weight": The weight of this image effect within the image style.
  • "name": The name of the effect definition that powers this image effect.
  • "data": An array of configuration options for this image effect. Besides these keys, the entirety of the image definition is merged into the image effect array. Returns FALSE if the specified effect cannot be found.
See Also
image_style_load()
image_effect_definition_load()

Definition at line 1266 of file image.module.

References image_style_load().

Referenced by image_help().

image_effect_save ( $effect )

Saves an image effect.

Parameters
$effect An image effect array.
Returns
An image effect array. In the case of a new effect, 'ieid' will be set.

Definition at line 1282 of file image.module.

References drupal_write_record(), image_style_flush(), and image_style_load().

Referenced by image_default_style_save(), image_effect_form_submit(), image_style_form_add_submit(), and image_style_form_submit().

image_effects ( )

Loads all image effects from the database.

Returns
An array of all image effects.
See Also
image_effect_load()

Definition at line 1217 of file image.module.

References db_select(), drupal_static(), and image_effect_definition_load().

Referenced by image_style_effects().

image_field_delete_field ( $field )

Implements hook_field_delete_field().

Definition at line 426 of file image.module.

References file_load(), and file_usage_delete().

image_field_delete_instance ( $instance )

Implements hook_field_delete_instance().

Definition at line 478 of file image.module.

References field_read_field(), file_load(), and file_usage_delete().

image_field_update_field | ( | $field,
 |  | $prior_field,
 |  | $has_data
 | ) |

Implements hook_field_update_field().

Definition at line 441 of file image.module.

References FILE_CREATE_DIRECTORY, file_load(), file_move(), file_prepare_directory(), file_save(), FILE_STATUS_PERMANENT, file_uri_scheme(), file_usage_add(), and file_usage_delete().

image_field_update_instance | ( | $instance,
 |  | $prior_instance
 | ) |

Implements hook_field_update_instance().

Definition at line 501 of file image.module.

References field_read_field(), FILE_CREATE_DIRECTORY, file_load(), file_move(), file_prepare_directory(), file_save(), FILE_STATUS_PERMANENT, file_uri_scheme(), file_usage_add(), and file_usage_delete().

image_file_delete ( $file )

Implements hook_file_delete().

Definition at line 338 of file image.module.

References image_path_flush().

image_file_download ( $uri )

Implements hook_file_download().

Control the access to files underneath the styles directory.

Definition at line 280 of file image.module.

References $info, file_file_download(), file_load_multiple(), file_uri_scheme(), file_uri_target(), image_get_info(), and module_invoke_all().

image_file_move | ( | $file,
 |  | $source
 | ) |

Implements hook_file_move().

Definition at line 330 of file image.module.

References image_path_flush().

image_filter_keyword | ( | $value,
 |  | $current_pixels,
 |  | $new_pixels
 | ) |

Accepts a keyword (center, top, left, etc) and returns it as a pixel offset.

Parameters
$value
$current_pixels
$new_pixels

Definition at line 1370 of file image.module.

References $value.

Referenced by image_crop_effect().

image_flush_caches ( )

Implements hook_flush_caches().

Definition at line 271 of file image.module.

image_form_system_file_system_settings_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 252 of file image.module.

image_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 44 of file image.module.

References $output, image_effect_definition_load(), image_effect_load(), t(), and url().

image_image_default_styles ( )

Implements hook_image_default_styles().

Definition at line 346 of file image.module.

References $styles.

image_image_style_delete ( $style )

Implements hook_image_style_delete().

Definition at line 419 of file image.module.

References image_image_style_save().

image_image_style_save ( $style )

Implements hook_image_style_save().

Definition at line 388 of file image.module.

References field_read_instances(), and field_update_instance().

Referenced by image_image_style_delete().

image_menu ( )

Implements hook_menu().

Definition at line 75 of file image.module.

References file_stream_wrapper_get_instance_by_scheme(), IMAGE_STORAGE_EDITABLE, IMAGE_STORAGE_NORMAL, IMAGE_STORAGE_OVERRIDE, MENU_CALLBACK, MENU_DEFAULT_LOCAL_TASK, and MENU_LOCAL_ACTION.

image_path_flush ( $path )

Clears cached versions of a specific file in all styles.

Parameters
$path The Drupal file path to the original image.

Definition at line 548 of file image.module.

References $styles, file_unmanaged_delete(), image_style_path(), and image_styles().

Referenced by image_file_delete(), and image_file_move().

image_permission ( )

Implements hook_permission().

Definition at line 240 of file image.module.

References t().

image_style_create_derivative | ( | $style,
 |  | $source,
 |  | $destination
 | ) |

Creates a new image derivative based on an image style.

Generates an image derivative by creating the destination folder (if it does not already exist), applying all image effects defined in $style['effects'], and saving a cached version of the resulting image.

Parameters
$style | An image style array.
$source | Path of the source file.
$destination | Path or URI of the destination file.
Returns
TRUE if an image derivative was generated, or FALSE if the image derivative could not be generated.
See Also
image_style_load()

Definition at line 903 of file image.module.

References drupal_dirname(), FILE_CREATE_DIRECTORY, FILE_MODIFY_PERMISSIONS, file_prepare_directory(), image_effect_apply(), image_load(), image_save(), watchdog(), and WATCHDOG_ERROR.

Referenced by image_style_deliver(), and theme_image_style_preview().

image_style_delete | ( | $style,
 |  | $replacement_style_name = ''
 | ) |

Deletes an image style.

Parameters
$style | An image style array.
$replacement_style_name | (optional) When deleting a style, specify a replacement style name so that existing settings (if any) may be converted to a new style.
Returns
TRUE on success.

Definition at line 725 of file image.module.

References db_delete(), image_style_flush(), and module_invoke_all().

Referenced by image_style_delete_form_submit().

image_style_deliver | ( | $style,
 |  | $scheme
 | ) |

Page callback: Generates a derivative, given a style and image path.

After generating an image, transfer it to the requesting agent.

Parameters
$style The image style

Definition at line 805 of file image.module.

References $name, $value, drupal_add_http_header(), drupal_exit(), drupal_hash_base64(), file_download(), file_stream_wrapper_valid_scheme(), file_transfer(), file_uri_target(), IMAGE_DERIVATIVE_TOKEN, image_load(), image_style_create_derivative(), image_style_path(), image_style_path_token(), lock_acquire(), lock_release(), MENU_ACCESS_DENIED, module_invoke_all(), print, t(), variable_get(), and watchdog().

image_style_effects ( $style )

Loads all the effects for an image style.

Parameters
array $style An image style array containing:
  • isid: The unique image style ID that contains this image effect.
Returns
array An array of image effects associated with specified image style in the format array('isid' => array()), or an empty array if the specified style has no effects.
See Also
image_effects()

Definition at line 752 of file image.module.

References image_effects().

Referenced by image_styles().

image_style_flush ( $style )

Flushes cached media for a style.

Parameters
$style An image style array.

Definition at line 971 of file image.module.

References cache_clear_all(), drupal_static_reset(), drupal_theme_rebuild(), field_info_cache_clear(), file_get_stream_wrappers(), file_unmanaged_delete_recursive(), module_exists(), module_invoke_all(), and STREAM_WRAPPERS_WRITE_VISIBLE.

Referenced by image_default_style_revert(), image_effect_delete(), image_effect_save(), image_example_enable(), image_style_delete(), and image_style_save().

image_style_load | ( | $name = NULL,
 |  | $isid = NULL,
 |  | $include = NULL
 | ) |

Loads a style by style name or ID.

May be used as a loader for menu items.

Parameters
$name | The name of the style.
$isid | Optional. The numeric id of a style if the name is not known.
$include | If set, this loader will restrict to a specific type of image style, may be one of the defined Image style storage constants.
Returns
An image style array containing the following keys:
  • "isid": The unique image style ID.
  • "name": The unique image style name.
  • "effects": An array of image effects within this image style. If the image style name or ID is not valid, an empty array is returned.
See Also
image_effect_load()

Definition at line 641 of file image.module.

References $name, $styles, and image_styles().

Referenced by image_effect_definition_load(), image_effect_delete(), image_effect_load(), image_effect_save(), image_style_save(), and image_style_transform_dimensions().

image_style_options | ( | $include_empty = TRUE,
 |  | $output = CHECK_PLAIN
 | ) |

Gets an array of image styles suitable for using as select list options.

Parameters
$include_empty | If TRUE a <none> option will be inserted in the options array.
$output | Optional flag determining how the options will be sanitized on output. Leave this at the default (CHECK_PLAIN) if you are using the output of this function directly in an HTML context, such as for checkbox or radio button labels, and do not plan to sanitize it on your own. If using the output of this function as select list options (its primary use case), you should instead set this flag to PASS_THROUGH to avoid double-escaping of the output (the form API sanitizes select list options by default).
Returns
Array of image styles with the machine name as key and the label as value.

Definition at line 781 of file image.module.

References $name, $output, $styles, check_plain(), image_styles(), PASS_THROUGH, and t().

Referenced by image_example_style_form(), image_field_formatter_settings_form(), image_field_formatter_settings_summary(), image_field_widget_settings_form(), image_style_delete_form(), and user_admin_settings().

image_style_path | ( | $style_name,
 |  | $uri
 | ) |

Returns the URI of an image when using a style.

The path returned by this function may not exist. The default generation method only creates images when they are requested by a user's browser.

Parameters
$style_name | The name of the style to be used with this image.
$uri | The URI or path to the image.
Returns
The URI to an image style image.
See Also
image_style_url()

Definition at line 1074 of file image.module.

References file_default_scheme(), file_uri_scheme(), and file_uri_target().

Referenced by image_path_flush(), image_style_deliver(), image_style_url(), and theme_image_style_preview().

image_style_path_token | ( | $style_name,
 |  | $uri
 | ) |

Generates a token to protect an image style derivative.

This prevents unauthorized generation of an image style derivative, which can be costly both in CPU time and disk space.

Parameters
$style_name | The name of the image style.
$uri | The URI of the image for this style, for example as returned by image_style_path().
Returns
An eight-character token which can be used to protect image style derivatives against denial-of-service attacks.

Definition at line 1054 of file image.module.

References drupal_get_hash_salt(), drupal_get_private_key(), and drupal_hmac_base64().

Referenced by image_style_deliver(), and image_style_url().

image_style_save ( $style )

Saves an image style.

Parameters
array $style An image style array containing:
  • name: A unique name for the style.
  • isid: (optional) An image style ID.
Returns
array An image style array containing:
  • name: An unique name for the style.
  • old_name: The original name for the style.
  • isid: An image style ID.
  • is_new: TRUE if this is a new style, and FALSE if it is an existing style.

Definition at line 685 of file image.module.

References drupal_write_record(), image_style_flush(), image_style_load(), and module_invoke_all().

Referenced by image_default_style_save(), image_style_add_form_submit(), and image_style_form_submit().

image_style_transform_dimensions | ( |  | $style_name,
 |  | array & | $dimensions
 | ) |  |

Determines the dimensions of the styled image.

Applies all of an image style's effects to $dimensions.

Parameters
$style_name | The name of the style to be applied.
$dimensions | Dimensions to be modified - an array with components width and height, in pixels.

Definition at line 943 of file image.module.

References image_style_load(), and module_load_include().

Referenced by theme_image_style().

image_style_url | ( | $style_name,
 |  | $path
 | ) |

Returns the URL for an image derivative given a style and image path.

Parameters
$style_name | The name of the style to be used with this image.
$path | The path to the image.
Returns
The absolute URL where a style image can be downloaded, suitable for use in an tag. Requesting the URL will cause the image to be created.
See Also
image_style_deliver()

Definition at line 1013 of file image.module.

References drupal_http_build_query(), file_build_uri(), file_create_url(), file_stream_wrapper_get_instance_by_uri(), file_stream_wrapper_uri_normalize(), file_uri_scheme(), file_uri_target(), IMAGE_DERIVATIVE_TOKEN, image_style_path(), image_style_path_token(), url(), and variable_get().

Referenced by rdf_preprocess_field(), and theme_image_style().

image_styles ( )

Gets an array of all styles and their settings.

Returns
An array of styles keyed by the image style ID (isid).
See Also
image_style_load()

Definition at line 565 of file image.module.

References $module, $styles, cache_get(), cache_set(), db_select(), drupal_alter(), drupal_static(), image_effect_definition_load(), IMAGE_STORAGE_DEFAULT, IMAGE_STORAGE_NORMAL, IMAGE_STORAGE_OVERRIDE, image_style_effects(), module_implements(), and module_invoke().

Referenced by image_example_enable(), image_path_flush(), image_style_list(), image_style_load(), image_style_name_validate(), and image_style_options().

image_system_file_system_settings_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for system_file_system_settings().

Adds a menu rebuild after the public file path has been changed, so that the menu router item depending on that file path will be regenerated.

Definition at line 262 of file image.module.

References variable_set().

image_theme ( )

Implements hook_theme().

Definition at line 186 of file image.module.

Variable Documentation

const IMAGE_DERIVATIVE_TOKEN 'itok'

The name of the query parameter for image derivative tokens.

Definition at line 36 of file image.module.

Referenced by image_style_deliver(), and image_style_url().

const IMAGE_STORAGE_DEFAULT 4

Image style constant for module-defined presets in code.

Definition at line 21 of file image.module.

Referenced by hook_image_styles_alter(), image_effect_definition_load(), image_example_image_styles_alter(), and image_styles().

const IMAGE_STORAGE_EDITABLE IMAGE_STORAGE_NORMAL | IMAGE_STORAGE_OVERRIDE

Image style constant to represent an editable preset.

Definition at line 26 of file image.module.

Referenced by image_menu(), and image_style_form().

const IMAGE_STORAGE_MODULE IMAGE_STORAGE_OVERRIDE | IMAGE_STORAGE_DEFAULT

Image style constant to represent any module-based preset.

Definition at line 31 of file image.module.

const IMAGE_STORAGE_NORMAL 1

Image style constant for user presets in the database.

Definition at line 11 of file image.module.

Referenced by image_menu(), image_styles(), and theme_image_style_list().

const IMAGE_STORAGE_OVERRIDE 2

Image style constant for user presets that override module-defined presets.

Definition at line 16 of file image.module.

Referenced by image_menu(), image_styles(), and theme_image_style_list().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/locale Directory Reference

  • modules
  • locale
locale Directory Reference

Files

file | locale.admin.inc [code]
file | locale.api.php [code]
file | locale.install [code]
file | locale.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/locale/locale.admin.inc File Reference

  • modules
  • locale
Functions
locale.admin.inc File Reference

Go to the source code of this file.

Functions

locale_languages_overview_form ()
theme_locale_languages_overview_form ($variables)
locale_languages_overview_form_submit ($form, &$form_state)
locale_languages_add_screen ()
locale_languages_predefined_form ($form)
locale_languages_custom_form ($form)
locale_languages_edit_form ($form, &$form_state, $langcode)
_locale_languages_common_controls (&$form, $language=NULL)
locale_languages_predefined_form_validate ($form, &$form_state)
locale_languages_predefined_form_submit ($form, &$form_state)
locale_languages_edit_form_validate ($form, &$form_state)
locale_languages_edit_form_submit ($form, &$form_state)
locale_languages_delete_form ($form, &$form_state, $langcode)
locale_languages_delete_form_submit ($form, &$form_state)
locale_languages_configure_form ()
_locale_languages_configure_form_language_table (&$form, $type)
theme_locale_languages_configure_form ($variables)
locale_languages_configure_form_submit ($form, &$form_state)
locale_language_providers_url_form ($form, &$form_state)
locale_language_providers_session_form ($form, &$form_state)
locale_translate_overview_screen ()
locale_translate_seek_screen ()
locale_translation_filters ()
locale_translation_filter_form ()
locale_translation_filter_form_validate ($form, &$form_state)
locale_translation_filter_form_submit ($form, &$form_state)
locale_translate_import_form ($form)
locale_translate_import_form_submit ($form, &$form_state)
locale_translate_export_screen ()
locale_translate_export_po_form ($form, &$form_state, $names)
locale_translate_export_pot_form ()
locale_translate_export_po_form_submit ($form, &$form_state)
locale_translate_edit_form ($form, &$form_state, $lid)
locale_translate_edit_form_validate ($form, &$form_state)
locale_translate_edit_form_submit ($form, &$form_state)
locale_translate_delete_page ($lid)
locale_translate_delete_form ($form, &$form_state, $source)
locale_translate_delete_form_submit ($form, &$form_state)
theme_locale_date_format_form ($variables)
locale_date_format_language_overview_page ()
locale_date_format_form ($form, &$form_state, $langcode)
locale_date_format_form_submit ($form, &$form_state)
locale_date_format_reset_form ($form, &$form_state, $langcode)
locale_date_format_reset_form_submit ($form, &$form_state)

Detailed Description

Administration functions for locale.module.

Definition in file locale.admin.inc.

Function Documentation

locale_date_format_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $langcode
 | ) |  |

Provide date localization configuration options to users.

Definition at line 1333 of file locale.admin.inc.

References check_plain(), format_date(), locale_language_list(), REQUEST_TIME, system_date_format_locale(), system_get_date_formats(), system_get_date_types(), t(), and variable_get().

locale_date_format_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for configuring localized date formats on the locale_date_format_form.

Definition at line 1395 of file locale.admin.inc.

References DRUPAL_ROOT, drupal_set_message(), locale_date_format_save(), system_get_date_types(), and t().

locale_date_format_language_overview_page ( )

Display edit date format links for each language.

Definition at line 1310 of file locale.admin.inc.

References $header, $info, $row, l(), locale_language_list(), t(), and theme().

locale_date_format_reset_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $langcode
 | ) |  |

Reset locale specific date formats to the global defaults.

Parameters
$langcode Language code, e.g. 'en'.

Definition at line 1418 of file locale.admin.inc.

References confirm_form(), language_list(), name, and t().

locale_date_format_reset_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Reset date formats for a specific language to global defaults.

Definition at line 1431 of file locale.admin.inc.

References db_delete().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/locale/locale.api.php File Reference

  • modules
  • locale
Functions
locale.api.php File Reference

Go to the source code of this file.

Functions

hook_locale ($op= 'groups')
hook_multilingual_settings_changed ()

Detailed Description

Hooks provided by the Locale module.

Definition in file locale.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/locale/locale.install File Reference

  • modules
  • locale
Functions
locale.install File Reference

Go to the source code of this file.

Functions

locale_install ()
locale_update_7000 ()
locale_update_7001 ()
locale_update_7002 ()
locale_update_7003 ()
locale_update_7004 ()
locale_update_7005 ()
locale_uninstall ()
locale_schema ()

Detailed Description

Install, update and uninstall functions for the locale module.

Definition in file locale.install.

Function Documentation

locale_install ( )

Implements hook_install().

Definition at line 11 of file locale.install.

References db_insert().

locale_schema ( )

Implements hook_schema().

Definition at line 274 of file locale.install.

locale_uninstall ( )

End of "addtogroup updates-7.x-extra". Implements hook_uninstall().

Definition at line 224 of file locale.install.

References db_query(), drupal_language_initialize(), drupal_rmdir(), file_scan_directory(), file_unmanaged_delete(), language_types(), node_type_get_types(), variable_del(), and variable_get().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/locale/locale.module File Reference

  • modules
  • locale
Functions
locale.module File Reference

Go to the source code of this file.

Functions

locale_help ($path, $arg)
locale_menu ()
locale_init ()
locale_permission ()
locale_locale ($op= 'groups')
locale_language_selector_form (&$form, &$form_state, $user)
locale_form_path_admin_form_alter (&$form, &$form_state)
locale_form_node_type_form_alter (&$form, &$form_state)
locale_multilingual_node_type ($type_name)
locale_form_alter (&$form, &$form_state, $form_id)
locale_form_node_form_alter (&$form, &$form_state)
locale_field_node_form_submit ($form, &$form_state)
locale_form_comment_form_alter (&$form, &$form_state, $form_id)
locale_field_comment_form_submit ($form, &$form_state)
locale_field_entity_form_submit ($entity_type, $form, &$form_state)
locale_theme ()
locale_field_language_alter (&$display_language, $context)
locale_field_language_fallback (&$display_language, $entity, $langcode)
locale_entity_info_alter (&$entity_info)
locale_language_types_info ()
locale_language_negotiation_info ()
locale_modules_enabled ($modules)
locale_modules_disabled ($modules)
locale ($string=NULL, $context=NULL, $langcode=NULL)
locale_reset ()
locale_get_plural ($count, $langcode=NULL)
locale_language_name ($lang)
locale_language_list ($field= 'name', $all=FALSE)
locale_modules_installed ($modules)
locale_themes_enabled ($themes)
locale_system_update ($components)
locale_js_alter (&$javascript)
locale_css_alter (&$css)
locale_library_alter (&$libraries, $module)
locale_block_info ()
locale_block_view ($type)
locale_url_outbound_alter (&$path, &$options, $original_path)

Detailed Description

Add language handling functionality and enables the translation of the user interface to languages other than English.

When enabled, multiple languages can be set up. The site interface can be displayed in different languages, as well as nodes can have languages assigned. The setup of languages and translations is completely web based. Gettext portable object files are supported.

Definition in file locale.module.

Function Documentation

locale | ( | $string = NULL,
 |  | $context = NULL,
 |  | $langcode = NULL
 | ) |

Provides interface translation services.

This function is called from t() to translate a string if needed.

Parameters
$string | A string to look up translation for. If omitted, all the cached strings will be returned in all languages already used on the page.
$context | The context of this string.
$langcode | Language code to use for the lookup.

Definition at line 668 of file locale.module.

References cache_clear_all(), cache_get(), cache_set(), db_merge(), db_query(), db_update(), drupal_static(), lock_acquire(), lock_release(), request_uri(), variable_get(), and VERSION.

Referenced by t().

locale_block_info ( )

Implements hook_block_info().

Definition at line 1018 of file locale.module.

References $info, DRUPAL_NO_CACHE, DRUPAL_ROOT, language_types_configurable(), language_types_info(), and t().

locale_block_view ( $type )

Implements hook_block_view().

Displays a language switcher. Only show if we have at least two languages.

Definition at line 1037 of file locale.module.

References $links, drupal_add_css(), drupal_get_path(), drupal_is_front_page(), drupal_multilingual(), language_negotiation_get_switch_links(), t(), and theme().

locale_css_alter ( & $css )

Implements hook_css_alter().

This function checks all CSS files currently added via drupal_add_css() and and checks to see if a related right to left CSS file should be included.

Definition at line 962 of file locale.module.

References LANGUAGE_RTL.

locale_entity_info_alter ( & $entity_info )

Implements hook_entity_info_alter().

Definition at line 525 of file locale.module.

locale_field_comment_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submit handler for comment_form().

This submit handler needs to run before entity_form_submit_build_entity() is invoked by comment_form_submit_build_comment(), because it alters the values of attached fields.

Definition at line 419 of file locale.module.

References locale_field_entity_form_submit().

locale_field_entity_form_submit | ( |  | $entity_type,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Handles field language on submit for the given entity type.

Checks if Locale is registered as a translation handler and handle possible language changes.

Definition at line 429 of file locale.module.

References entity_extract_ids(), entity_language(), field_has_translation_handler(), field_info_field(), and field_info_instances().

Referenced by locale_field_comment_form_submit(), and locale_field_node_form_submit().

locale_field_language_alter | ( | & | $display_language,
 |  |  | $context
 | ) |  |

Implements hook_field_language_alter().

Definition at line 470 of file locale.module.

References field_has_translation_handler(), locale_field_language_fallback(), and variable_get().

locale_field_language_fallback | ( | & | $display_language,
 |  |  | $entity,
 |  |  | $langcode
 | ) |  |

Applies language fallback rules to the fields attached to the given entity.

Core language fallback rules simply check if fields have a field translation for the requested language code. If so the requested language is returned, otherwise all the fallback candidates are inspected to see if there is a field translation available in another language. By default this is called by locale_field_language_alter(), but this behavior can be disabled by setting the 'locale_field_language_fallback' variable to FALSE.

Parameters
$display_language | A reference to an array of language codes keyed by field name.
$entity | The entity to be displayed.
$langcode | The language code $entity has to be displayed in.

Definition at line 496 of file locale.module.

Referenced by hook_field_language_alter(), and locale_field_language_alter().

locale_field_node_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submit handler for node_form().

This submit handler needs to run before entity_form_submit_build_entity() is invoked by node_form_submit_build_node(), because it alters the values of attached fields. Therefore, it cannot be a hook_node_submit() implementation.

Definition at line 393 of file locale.module.

References locale_field_entity_form_submit().

locale_form_alter | ( | & | $form,
 |  | & | $form_state,
 |  |  | $form_id
 | ) |  |

Implements hook_form_alter().

Adds language fields to user forms.

Definition at line 352 of file locale.module.

References drupal_multilingual(), and locale_language_selector_form().

locale_form_comment_form_alter | ( | & | $form,
 |  | & | $form_state,
 |  |  | $form_id
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 400 of file locale.module.

References LANGUAGE_NONE, and locale_multilingual_node_type().

locale_form_node_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_BASE_FORM_ID_alter().

Definition at line 366 of file locale.module.

References language, language_default(), LANGUAGE_NONE, locale_language_list(), locale_multilingual_node_type(), nid, and t().

locale_form_node_type_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 325 of file locale.module.

References t(), url(), and variable_get().

locale_form_path_admin_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 311 of file locale.module.

References LANGUAGE_NONE, locale_language_list(), and t().

locale_get_plural | ( | $count,
 |  | $langcode = NULL
 | ) |

Returns plural form index for a specific number.

The index is computed from the formula of this language.

Parameters
$count | Number to return plural for.
$langcode | Optional language code to translate to a language other than what is used to display the page.
Returns
The numeric index of the plural variant to use for this $langcode and $count combination or -1 if the language was not found or does not have a plural formula.

Definition at line 782 of file locale.module.

References drupal_static(), and language_list().

Referenced by format_plural().

locale_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 20 of file locale.module.

References $output, t(), and url().

locale_init ( )

Implements hook_init().

Initialize date formats according to the user's current locale.

Definition at line 226 of file locale.module.

References $conf, DRUPAL_ROOT, and locale_get_localized_date_format().

locale_js_alter ( & $javascript )

Implements hook_js_alter().

This function checks all JavaScript files currently added via drupal_add_js() and invokes parsing if they have not yet been parsed for Drupal.t() and Drupal.formatPlural() calls. Also refreshes the JavaScript translation file if necessary, and adds it to the page.

Definition at line 900 of file locale.module.

References $dir, _locale_invalidate_js(), _locale_parse_js_file(), _locale_rebuild_js(), drupal_js_defaults(), DRUPAL_ROOT, variable_get(), and variable_set().

locale_language_list | ( | $field = 'name',
 |  | $all = FALSE
 | ) |

Returns array of language names

Parameters
$field | 'name' => names in current language, localized 'native' => native names
$all | Boolean to return all languages or only enabled ones

Definition at line 843 of file locale.module.

References language_list(), and t().

Referenced by locale_date_format_form(), locale_date_format_language_overview_page(), locale_form_node_form_alter(), locale_form_path_admin_form_alter(), locale_language_name(), locale_translate_export_screen(), locale_translate_import_form(), locale_translation_filters(), and translation_form_node_form_alter().

locale_language_name ( $lang )

Returns a language name

Definition at line 826 of file locale.module.

References drupal_static(), locale_language_list(), and t().

locale_language_negotiation_info ( )

Implements hook_language_negotiation_info().

Definition at line 566 of file locale.module.

References LANGUAGE_TYPE_CONTENT, LANGUAGE_TYPE_INTERFACE, LANGUAGE_TYPE_URL, LOCALE_LANGUAGE_NEGOTIATION_BROWSER, LOCALE_LANGUAGE_NEGOTIATION_INTERFACE, LOCALE_LANGUAGE_NEGOTIATION_SESSION, LOCALE_LANGUAGE_NEGOTIATION_URL, LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK, LOCALE_LANGUAGE_NEGOTIATION_USER, and t().

Referenced by locale_update_7001().

locale_language_types_info ( )

Implements hook_language_types_info().

Defines the three core language types:

  • Interface language is the only configurable language type in core. It is used by t() as the default language if none is specified.
  • Content language is by default non-configurable and inherits the interface language negotiated value. It is used by the Field API to determine the display language for fields if no explicit value is specified.
  • URL language is by default non-configurable and is determined through the URL language provider or the URL fallback provider if no language can be detected. It is used by l() as the default language if none is specified.

Definition at line 545 of file locale.module.

References DRUPAL_ROOT, LANGUAGE_TYPE_CONTENT, LANGUAGE_TYPE_INTERFACE, LANGUAGE_TYPE_URL, LOCALE_LANGUAGE_NEGOTIATION_INTERFACE, LOCALE_LANGUAGE_NEGOTIATION_URL, LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK, and t().

locale_library_alter | ( | & | $libraries,
 |  |  | $module
 | ) |  |

Implement hook_library_alter().

Provides the language support for the jQuery UI Date Picker.

Definition at line 988 of file locale.module.

References $module, drupal_get_path(), LANGUAGE_RTL, and variable_get().

locale_locale ( $op = 'groups' )

Implements hook_locale().

Definition at line 264 of file locale.module.

References $op, and t().

locale_menu ( )

Implements hook_menu().

Definition at line 73 of file locale.module.

References MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION, MENU_LOCAL_TASK, and MENU_VISIBLE_IN_BREADCRUMB.

locale_modules_disabled ( $modules )

Implements hook_modules_disabled().

Definition at line 647 of file locale.module.

References locale_modules_enabled().

locale_modules_enabled ( $modules )

Implements hook_modules_enabled().

Definition at line 638 of file locale.module.

References DRUPAL_ROOT, language_negotiation_purge(), and language_types_set().

Referenced by locale_modules_disabled().

locale_modules_installed ( $modules )

Implements hook_modules_installed().

Definition at line 861 of file locale.module.

References locale_system_update().

locale_multilingual_node_type ( $type_name )

Return whether the given content type has multilingual support.

Returns
True if multilingual support is enabled.

Definition at line 343 of file locale.module.

References variable_get().

Referenced by locale_form_comment_form_alter(), and locale_form_node_form_alter().

locale_permission ( )

Implements hook_permission().

Definition at line 249 of file locale.module.

References t().

locale_reset ( )

Reset static variables used by locale().

Definition at line 762 of file locale.module.

References drupal_static_reset().

locale_system_update ( $components )

Imports translations when new modules or themes are installed.

This function will either import translation for the component change right away, or start a batch if more files need to be imported.

Parameters
$components An array of component (theme and/or module) names to import translations for.

Definition at line 885 of file locale.module.

References batch_set(), DRUPAL_ROOT, and locale_batch_by_component().

Referenced by locale_modules_installed(), and locale_themes_enabled().

locale_theme ( )

Implements hook_theme().

Definition at line 453 of file locale.module.

locale_themes_enabled ( $themes )

Implements hook_themes_enabled().

Definition at line 871 of file locale.module.

References locale_system_update().

locale_url_outbound_alter | ( | & | $path,
 |  | & | $options,
 |  |  | $original_path
 | ) |  |

Implements hook_url_outbound_alter().

Rewrite outbound URLs with language based prefixes.

Definition at line 1058 of file locale.module.

References drupal_multilingual(), DRUPAL_ROOT, drupal_static(), language_types_configurable(), and variable_get().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/menu Directory Reference

  • modules
  • menu
menu Directory Reference

Files

file | menu.admin.inc [code]
file | menu.api.php [code]
file | menu.install [code]
file | menu.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/menu/menu.admin.inc File Reference

  • modules
  • menu
Functions
menu.admin.inc File Reference

Go to the source code of this file.

Functions

menu_overview_page ()
theme_menu_admin_overview ($variables)
menu_overview_form ($form, &$form_state, $menu)
_menu_overview_tree_form ($tree)
menu_overview_form_submit ($form, &$form_state)
theme_menu_overview_form ($variables)
menu_edit_item ($form, &$form_state, $type, $item, $menu)
menu_edit_item_validate ($form, &$form_state)
menu_item_delete_submit ($form, &$form_state)
menu_edit_item_submit ($form, &$form_state)
menu_edit_menu ($form, &$form_state, $type, $menu=array())
menu_custom_delete_submit ($form, &$form_state)
menu_delete_menu_page ($menu)
menu_delete_menu_confirm ($form, &$form_state, $menu)
menu_delete_menu_confirm_submit ($form, &$form_state)
menu_edit_menu_name_exists ($value)
menu_edit_menu_submit ($form, &$form_state)
menu_item_delete_page ($item)
menu_item_delete_form ($form, &$form_state, $item)
menu_item_delete_form_submit ($form, &$form_state)
menu_reset_item_confirm ($form, &$form_state, $item)
menu_reset_item_confirm_submit ($form, &$form_state)
menu_configure ()

Detailed Description

Administrative page callbacks for menu module.

Definition in file menu.admin.inc.

Function Documentation

_menu_overview_tree_form ( $tree )

Recursive helper function for menu_overview_form().

Parameters
$tree The menu_tree retrieved by menu_tree_data.

Definition at line 92 of file menu.admin.inc.

References $title, $tree, drupal_static(), l(), and t().

Referenced by menu_overview_form().

menu_configure ( )

Menu callback; Build the form presenting menu configuration options.

Definition at line 670 of file menu.admin.inc.

References menu_get_menus(), system_settings_form(), t(), url(), and variable_get().

menu_custom_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for the 'Delete' button on the menu editing form.

Definition at line 504 of file menu.admin.inc.

menu_delete_menu_confirm | ( |  | $form,
 |  | & | $form_state,
 |  |  | $menu
 | ) |  |

Build a confirm form for deletion of a custom menu.

Definition at line 523 of file menu.admin.inc.

References confirm_form(), db_query(), format_plural(), and t().

menu_delete_menu_confirm_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Delete a custom menu and all links in it.

Definition at line 537 of file menu.admin.inc.

References db_query(), drupal_set_message(), menu_delete(), menu_link_delete(), menu_list_system_menus(), menu_reset_item(), t(), watchdog(), and WATCHDOG_NOTICE.

menu_delete_menu_page ( $menu )

Menu callback; check access and get a confirm form for deletion of a custom menu.

Definition at line 511 of file menu.admin.inc.

References drupal_get_form(), MENU_ACCESS_DENIED, and menu_list_system_menus().

menu_edit_item | ( |  | $form,
 |  | & | $form_state,
 |  |  | $type,
 |  |  | $item,
 |  |  | $menu
 | ) |  |

Menu callback; Build the menu link editing form.

Definition at line 265 of file menu.admin.inc.

References $breadcrumb, drupal_http_build_query(), drupal_set_breadcrumb(), l(), menu_get_active_breadcrumb(), menu_get_menus(), MENU_MAX_DEPTH, menu_parent_options(), and t().

menu_edit_item_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process menu and menu item add/edit form submissions.

Definition at line 417 of file menu.admin.inc.

References drupal_set_message(), menu_link_save(), and t().

menu_edit_item_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate form values for a menu link being added or edited.

Definition at line 375 of file menu.admin.inc.

References drupal_get_normal_path(), drupal_get_query_array(), drupal_set_message(), drupal_valid_path(), form_set_error(), t(), and url_is_external().

menu_edit_menu | ( |  | $form,
 |  | & | $form_state,
 |  |  | $type,
 |  |  | $menu = array()
 | ) |  |

Menu callback; Build the form that handles the adding/editing of a custom menu.

Definition at line 439 of file menu.admin.inc.

References menu_list_system_menus(), MENU_MAX_MENU_NAME_LENGTH_UI, and t().

menu_edit_menu_name_exists ( $value )

Returns whether a menu name already exists.

See Also
menu_edit_menu()
form_validate_machine_name()

Definition at line 573 of file menu.admin.inc.

References $value, and db_query_range().

menu_edit_menu_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for adding or editing a custom menu.

Definition at line 585 of file menu.admin.inc.

References db_query(), drupal_set_message(), menu_link_load(), menu_link_save(), menu_save(), and t().

menu_item_delete_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $item
 | ) |  |

Build a confirm form for deletion of a single menu link.

Definition at line 632 of file menu.admin.inc.

References confirm_form(), and t().

menu_item_delete_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process menu delete form submissions.

Definition at line 640 of file menu.admin.inc.

References drupal_set_message(), menu_link_delete(), t(), watchdog(), and WATCHDOG_NOTICE.

menu_item_delete_page ( $item )

Menu callback; Check access and present a confirm form for deleting a menu link.

Definition at line 620 of file menu.admin.inc.

References drupal_get_form(), and MENU_ACCESS_DENIED.

menu_item_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for the delete button on the menu item editing form.

Definition at line 410 of file menu.admin.inc.

menu_overview_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $menu
 | ) |  |

Form for editing an entire menu tree at once.

Shows for one menu the menu links accessible to the current user and relevant operations.

Definition at line 49 of file menu.admin.inc.

References $links, $tree, _menu_overview_tree_form(), db_query(), drupal_get_path(), element_children(), menu_tree_check_access(), menu_tree_collect_node_links(), menu_tree_data(), t(), and url().

menu_overview_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for the menu overview form.

This function takes great care in saving parent items first, then items underneath them. Saving items in the incorrect order can break the menu tree.

See Also
menu_overview_form()

Definition at line 160 of file menu.admin.inc.

References drupal_set_message(), element_children(), menu_link_save(), and t().

menu_overview_page ( )

Menu callback which shows an overview page of all the custom menus and their descriptions.

Definition at line 11 of file menu.admin.inc.

References $header, $row, db_query(), l(), t(), and theme().

menu_reset_item_confirm | ( |  | $form,
 |  | & | $form_state,
 |  |  | $item
 | ) |  |

Menu callback; reset a single modified menu link.

Definition at line 652 of file menu.admin.inc.

References confirm_form(), and t().

menu_reset_item_confirm_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process menu reset item form submissions.

Definition at line 660 of file menu.admin.inc.

References drupal_set_message(), menu_reset_item(), and t().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/menu/menu.api.php File Reference

  • modules
  • menu
Functions
menu.api.php File Reference

Go to the source code of this file.

Functions

hook_menu_insert ($menu)
hook_menu_update ($menu)
hook_menu_delete ($menu)

Detailed Description

Hooks provided by the Menu module.

Definition in file menu.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/menu/menu.install File Reference

  • modules
  • menu
Functions
menu.install File Reference

Go to the source code of this file.

Functions

menu_schema ()
menu_install ()
menu_uninstall ()
menu_update_7000 ()
menu_update_7001 ()
menu_update_7002 (&$sandbox)
menu_update_7003 (&$sandbox)

Detailed Description

Install, update and uninstall functions for the menu module.

Definition in file menu.install.

Function Documentation

menu_install ( )

Implements hook_install().

Definition at line 46 of file menu.install.

References $title, get_t(), menu_list_system_menus(), and menu_save().

menu_schema ( )

Implements hook_schema().

Definition at line 11 of file menu.install.

menu_uninstall ( )

Implements hook_uninstall().

Definition at line 68 of file menu.install.

References menu_rebuild().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/menu/menu.module File Reference

  • modules
  • menu
Functions | Variables
menu.module File Reference

Go to the source code of this file.

Functions

menu_help ($path, $arg)
menu_permission ()
menu_menu ()
menu_theme ()
menu_enable ()
menu_overview_title ($menu)
menu_load ($menu_name)
menu_load_all ()
menu_save ($menu)
menu_delete ($menu)
menu_parent_options ($menus, $item, $type= '')
menu_parent_options_js ()
_menu_get_options ($menus, $available_menus, $item)
_menu_parents_recurse ($tree, $menu_name, $indent, &$options, $exclude, $depth_limit)
menu_reset_item ($link)
menu_block_info ()
menu_block_view ($delta= '')
menu_block_view_alter (&$data, $block)
menu_node_insert ($node)
menu_node_update ($node)
menu_node_save ($node)
menu_node_delete ($node)
menu_node_prepare ($node)
_menu_parent_depth_limit ($item)
menu_form_node_form_alter (&$form, $form_state)
menu_node_submit ($node, $form, $form_state)
menu_form_node_type_form_alter (&$form, $form_state)
menu_get_menus ($all=TRUE)

Variables

const MENU_MAX_MENU_NAME_LENGTH_UI 27

Detailed Description

Allows administrators to customize the site's navigation menus.

A menu (in this context) is a hierarchical collection of links, generally used for navigation. This is not to be confused with the Menu system of menu.inc and hook_menu(), which defines page routing requests for Drupal, and also allows the defined page routing URLs to be added to the main site navigation menu.

Definition in file menu.module.

Function Documentation

_menu_get_options | ( | $menus,
 |  | $available_menus,
 |  | $item
 | ) |

Helper function to get the items of the given menu.

Definition at line 403 of file menu.module.

References $title, $tree, _menu_parent_depth_limit(), _menu_parents_recurse(), and menu_tree_all_data().

Referenced by menu_parent_options(), and menu_parent_options_js().

_menu_parent_depth_limit ( $item )

Find the depth limit for items in the parent select.

Definition at line 615 of file menu.module.

References menu_link_children_relative_depth(), and MENU_MAX_DEPTH.

Referenced by _menu_get_options(), and menu_node_prepare().

_menu_parents_recurse | ( |  | $tree,
 |  |  | $menu_name,
 |  |  | $indent,
 |  | & | $options,
 |  |  | $exclude,
 |  |  | $depth_limit
 | ) |  |

Recursive helper function for menu_parent_options().

Definition at line 426 of file menu.module.

References $title, $tree, t(), and truncate_utf8().

Referenced by _menu_get_options().

menu_block_info ( )

Implements hook_block_info().

Definition at line 468 of file menu.module.

References $name, $title, check_plain(), DRUPAL_NO_CACHE, and menu_get_menus().

menu_block_view ( $delta = '' )

Implements hook_block_view().

Definition at line 484 of file menu.module.

References check_plain(), menu_get_menus(), and menu_tree().

menu_block_view_alter | ( | & | $data,
 |  |  | $block
 | ) |  |

Implements hook_block_view_alter().

Definition at line 498 of file menu.module.

References menu_list_system_menus().

menu_delete ( $menu )

Delete a custom menu and all contained links.

Note that this function deletes all menu links in a custom menu. While menu links derived from router paths may be restored by rebuilding the menu, all customized and custom links will be irreversibly gone. Therefore, this function should usually be called from a user interface (form submit) handler only, which allows the user to confirm the action.

Parameters
$menu An array representing a custom menu:
  • menu_name: The unique name of the custom menu.
  • title: The human readable menu title.
  • description: The custom menu description.

Modules should always pass a fully populated $menu when deleting a custom menu, so other modules are able to output proper status or watchdog messages.

See Also
menu_load()

menu_delete_links() will take care of clearing the page cache. Other modules should take care of their menu-related data by implementing hook_menu_delete().

Definition at line 313 of file menu.module.

References db_delete(), menu_cache_clear_all(), menu_delete_links(), menu_get_menus(), module_invoke_all(), variable_get(), and variable_set().

Referenced by menu_delete_menu_confirm_submit().

menu_enable ( )

Implements hook_enable().

Add a link for each custom menu.

Definition at line 180 of file menu.module.

References db_query(), menu_cache_clear_all(), menu_link_save(), and menu_rebuild().

menu_form_node_form_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_BASE_FORM_ID_alter().

Adds menu item fields to the node form.

See Also
menu_node_submit()

Definition at line 626 of file menu.module.

References drupal_get_path(), menu_get_menus(), menu_parent_options(), t(), user_access(), and variable_get().

menu_form_node_type_form_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Adds menu options to the node type form.

Definition at line 731 of file menu.module.

References drupal_add_js(), drupal_get_path(), menu_get_menus(), menu_parent_options(), t(), and variable_get().

menu_get_menus ( $all = TRUE )

Return an associative array of the custom menus names.

Parameters
$all If FALSE return only user-added menus, or if TRUE also include the menus defined by the system.
Returns
An array with the machine-readable names as the keys, and human-readable titles as the values.

Definition at line 783 of file menu.module.

References menu_list_system_menus(), menu_load_all(), and t().

Referenced by menu_block_info(), menu_block_view(), menu_configure(), menu_delete(), menu_edit_item(), menu_form_node_form_alter(), menu_form_node_type_form_alter(), menu_parent_options_js(), and menu_save().

menu_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 23 of file menu.module.

References $output, module_exists(), t(), and url().

menu_load ( $menu_name )

Load the data for a single custom menu.

Parameters
$menu_name The unique name of a custom menu to load.
Returns
Array defining the custom menu, or FALSE if the menu doesn't exist.

Definition at line 219 of file menu.module.

References menu_load_all().

menu_load_all ( )

Load all custom menu data.

Returns
Array of custom menu data.

Definition at line 230 of file menu.module.

References cache_get(), cache_set(), db_query(), and drupal_static().

Referenced by menu_get_menus(), and menu_load().

menu_menu ( )

Implements hook_menu().

Definition at line 59 of file menu.module.

References MENU_CALLBACK, MENU_CONTEXT_INLINE, MENU_CONTEXT_PAGE, MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION, and MENU_LOCAL_TASK.

menu_node_delete ( $node )

Implements hook_node_delete().

Definition at line 554 of file menu.module.

References db_query(), and menu_link_delete().

menu_node_insert ( $node )

Implements hook_node_insert().

Definition at line 511 of file menu.module.

References menu_node_save().

menu_node_prepare ( $node )

Implements hook_node_prepare().

Definition at line 565 of file menu.module.

References _menu_parent_depth_limit(), db_query_range(), menu_link_load(), and variable_get().

menu_node_save ( $node )

Helper for hook_node_insert() and hook_node_update().

Definition at line 525 of file menu.module.

References drupal_set_message(), menu_link_delete(), menu_link_save(), and t().

Referenced by menu_node_insert(), and menu_node_update().

menu_node_submit | ( | $node,
 |  | $form,
 |  | $form_state
 | ) |

Implements hook_node_submit().

See Also
menu_form_node_form_alter()

Definition at line 718 of file menu.module.

menu_node_update ( $node )

Implements hook_node_update().

Definition at line 518 of file menu.module.

References menu_node_save().

menu_overview_title ( $menu )

Title callback for the menu overview page and links.

Definition at line 207 of file menu.module.

menu_parent_options | ( | $menus,
 |  | $item,
 |  | $type = ''
 | ) |

Return a list of menu items that are valid possible parents for the given menu item.

Parameters
$menus | An array of menu names and titles, such as from menu_get_menus().
$item | The menu item or the node type for which to generate a list of parents. If $item['mlid'] == 0 then the complete tree is returned.
$type | The node type for which to generate a list of parents. If $item itself is a node type then $type is ignored.
Returns
An array of menu link titles keyed on the a string containing the menu name and mlid. The list excludes the given item and its children.

Definition at line 353 of file menu.module.

References _menu_get_options(), and variable_get().

Referenced by menu_edit_item(), menu_form_node_form_alter(), and menu_form_node_type_form_alter().

menu_parent_options_js ( )

Page callback. Get all the available menus and menu items as a JavaScript array.

Definition at line 388 of file menu.module.

References _menu_get_options(), drupal_json_output(), and menu_get_menus().

menu_permission ( )

Implements hook_permission().

Definition at line 48 of file menu.module.

References t().

menu_reset_item ( $link )

Reset a system-defined menu link.

Definition at line 448 of file menu.module.

References _menu_link_build(), menu_get_router(), and menu_link_save().

Referenced by menu_delete_menu_confirm_submit(), and menu_reset_item_confirm_submit().

menu_save ( $menu )

Save a custom menu.

Parameters
$menu An array representing a custom menu:
  • menu_name: The unique name of the custom menu (composed of lowercase letters, numbers, and hyphens).
  • title: The human readable menu title.
  • description: The custom menu description.

Modules should always pass a fully populated $menu when saving a custom menu, so other modules are able to output proper status or watchdog messages.

See Also
menu_load()

Definition at line 259 of file menu.module.

References db_merge(), menu_cache_clear_all(), menu_get_menus(), module_invoke_all(), SAVED_NEW, SAVED_UPDATED, variable_get(), and variable_set().

Referenced by menu_edit_menu_submit(), and menu_install().

menu_theme ( )

Implements hook_theme().

Definition at line 162 of file menu.module.

Variable Documentation

const MENU_MAX_MENU_NAME_LENGTH_UI 27

Maximum length of menu name as entered by the user. Database length is 32 and we add a menu- prefix.

Definition at line 18 of file menu.module.

Referenced by menu_edit_menu().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node Directory Reference

  • modules
  • node
node Directory Reference

Files

file | content_types.inc [code]
file | node.admin.inc [code]
file | node.api.php [code]
file | node.install [code]
file | node.module [code]
file | node.pages.inc [code]
file | node.tokens.inc [code]
file | node.tpl.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/content_types.inc File Reference

  • modules
  • node
Functions
content_types.inc File Reference

Go to the source code of this file.

Functions

node_overview_types ()
theme_node_admin_overview ($variables)
node_type_form ($form, &$form_state, $type=NULL)
_node_characters ($length)
node_type_form_validate ($form, &$form_state)
node_type_form_submit ($form, &$form_state)
node_node_type_insert ($info)
node_node_type_update ($info)
node_type_reset ($type)
node_type_delete_confirm ($form, &$form_state, $type)
node_type_delete_confirm_submit ($form, &$form_state)

Detailed Description

Content type editing user interface.

Definition in file content_types.inc.

Function Documentation

_node_characters ( $length )

Helper function for teaser length choices.

Definition at line 247 of file content_types.inc.

References format_plural(), and t().

node_node_type_insert ( $info )

Implements hook_node_type_insert().

Definition at line 367 of file content_types.inc.

References $info, drupal_set_message(), format_plural(), and node_type_update_nodes().

node_node_type_update ( $info )

Implements hook_node_type_update().

Definition at line 380 of file content_types.inc.

References $info, drupal_set_message(), format_plural(), and node_type_update_nodes().

node_overview_types ( )

Displays the content type admin overview page.

Definition at line 11 of file content_types.inc.

References $header, $name, $row, l(), module_exists(), node_hook(), node_type_get_names(), node_type_get_types(), t(), theme(), and url().

node_type_delete_confirm_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process content type delete confirm submissions.

See Also
node_type_delete_confirm()

Definition at line 437 of file content_types.inc.

References drupal_set_message(), menu_rebuild(), node_type_delete(), node_types_rebuild(), t(), variable_del(), watchdog(), and WATCHDOG_NOTICE.

node_type_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for node_type_form().

See Also
node_type_form_validate()

Definition at line 286 of file content_types.inc.

References $op, $value, drupal_set_message(), l(), menu_rebuild(), node_add_body_field(), node_type_save(), node_type_set_defaults(), node_types_rebuild(), SAVED_NEW, SAVED_UPDATED, t(), variable_del(), variable_set(), watchdog(), and WATCHDOG_NOTICE.

node_type_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for node_type_form().

See Also
node_type_form_submit()

Definition at line 256 of file content_types.inc.

References form_set_error(), node_type_get_names(), and t().

node_type_reset ( $type )

Resets relevant fields of a module-defined node type to their default values.

Parameters
$type The node type to reset. The node type is passed back by reference with its resetted values. If there is no module-defined info for this node type, then nothing happens.

Definition at line 398 of file content_types.inc.

References $info, $value, module_invoke_all(), and node_type_set_defaults().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/node.admin.inc File Reference

  • modules
  • node
Functions
node.admin.inc File Reference

Go to the source code of this file.

Functions

node_configure_rebuild_confirm ()
node_configure_rebuild_confirm_submit ($form, &$form_state)
node_node_operations ()
node_filters ()
node_build_filter_query (SelectQueryInterface $query)
node_filter_form ()
node_filter_form_submit ($form, &$form_state)
node_mass_update ($nodes, $updates)
_node_mass_update_helper ($nid, $updates)
_node_mass_update_batch_process ($nodes, $updates, &$context)
_node_mass_update_batch_finished ($success, $results, $operations)
node_admin_content ($form, $form_state)
node_admin_nodes ()
node_admin_nodes_validate ($form, &$form_state)
node_admin_nodes_submit ($form, &$form_state)
node_multiple_delete_confirm ($form, &$form_state, $nodes)
node_multiple_delete_confirm_submit ($form, &$form_state)

Detailed Description

Content administration and module settings UI.

Definition in file node.admin.inc.

Function Documentation

_node_mass_update_batch_finished | ( | $success,
 |  | $results,
 |  | $operations
 | ) |

Menu callback: Reports the status of batch operation for node_mass_update().

Parameters
bool | $success | A boolean indicating whether the batch mass update operation successfully concluded.
int | $results | The number of nodes updated via the batch mode process.
array | $operations | An array of function calls (not used in this function).

Definition at line 380 of file node.admin.inc.

References $results, drupal_set_message(), format_plural(), t(), and theme().

_node_mass_update_batch_process | ( |  | $nodes,
 |  |  | $updates,
 |  | & | $context
 | ) |  |

Executes a batch operation for node_mass_update().

Parameters
array | $nodes | An array of node IDs.
array | $updates | Associative array of updates.
array | $context | An array of contextual key/values.

Definition at line 341 of file node.admin.inc.

References _node_mass_update_helper(), and l().

_node_mass_update_helper | ( | $nid,
 |  | $updates
 | ) |

Updates individual nodes when fewer than 10 are queued.

Parameters
$nid | ID of node to update.
$updates | Associative array of updates.
Returns
object An updated node object.
See Also
node_mass_update()

Definition at line 320 of file node.admin.inc.

References $name, $value, node_load(), and node_save().

Referenced by _node_mass_update_batch_process(), and node_mass_update().

node_admin_nodes_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process node_admin_nodes form submissions.

Executes the chosen 'Update option' on the selected nodes.

See Also
node_admin_nodes()
node_admin_nodes_validate()
node_filter_form()
node_filter_form_submit()
node_multiple_delete_confirm()
node_multiple_delete_confirm_submit()

Definition at line 627 of file node.admin.inc.

References cache_clear_all(), and module_invoke_all().

node_admin_nodes_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate node_admin_nodes form submissions.

Checks whether any nodes have been selected to perform the chosen 'Update option' on.

See Also
node_admin_nodes()
node_admin_nodes_submit()
node_filter_form()
node_filter_form_submit()
node_multiple_delete_confirm()
node_multiple_delete_confirm_submit()

Definition at line 608 of file node.admin.inc.

References form_set_error(), and t().

node_build_filter_query ( SelectQueryInterface $query )

Applies filters for node administration filters based on session.

Parameters
$query A SelectQuery to which the filters should be applied.

Definition at line 127 of file node.admin.inc.

References $value, and QueryConditionInterface\condition().

Referenced by node_admin_nodes().

node_configure_rebuild_confirm_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Handler for wipe confirmation

See Also
node_configure_rebuild_confirm()

Definition at line 25 of file node.admin.inc.

References node_access_rebuild().

node_filter_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for node_filter_form().

See Also
node_admin_content()
node_admin_nodes()
node_admin_nodes_submit()
node_admin_nodes_validate()
node_filter_form()
node_multiple_delete_confirm()
node_multiple_delete_confirm_submit()

Definition at line 239 of file node.admin.inc.

References form_options_flatten(), node_filters(), and t().

node_filters ( )

List node administration filters that can be applied.

Returns
An associative array of filters.

Definition at line 79 of file node.admin.inc.

References LANGUAGE_NONE, module_exists(), module_invoke(), node_type_get_names(), and t().

Referenced by node_filter_form(), and node_filter_form_submit().

node_mass_update | ( | $nodes,
 |  | $updates
 | ) |

Make mass update of nodes, changing all nodes in the $nodes array to update them with the field values in $updates.

IMPORTANT NOTE: This function is intended to work when called from a form submission handler. Calling it outside of the form submission process may not work correctly.

Parameters
array | $nodes | Array of node nids to update.
array | $updates | Array of key/value pairs with node field names and the value to update that field to.

Definition at line 279 of file node.admin.inc.

References _node_mass_update_helper(), batch_set(), drupal_get_path(), drupal_set_message(), and t().

Referenced by hook_user_cancel(), and node_user_cancel().

node_multiple_delete_confirm_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for node_multiple_delete_confirm().

See Also
node_admin_nodes()
node_admin_nodes_submit()
node_admin_nodes_validate()
node_filter_form()
node_filter_form_submit()
node_multiple_delete_confirm()

Definition at line 695 of file node.admin.inc.

References cache_clear_all(), drupal_set_message(), format_plural(), node_delete_multiple(), and watchdog().

node_node_operations ( )

Implements hook_node_operations().

Definition at line 33 of file node.admin.inc.

References NODE_NOT_PROMOTED, NODE_NOT_PUBLISHED, NODE_NOT_STICKY, NODE_PROMOTED, NODE_PUBLISHED, NODE_STICKY, and t().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/node.api.php File Reference

  • modules
  • node
Functions
node.api.php File Reference

Go to the source code of this file.

Functions

hook_node_grants ($account, $op)
hook_node_access_records ($node)
hook_node_access_records_alter (&$grants, $node)
hook_node_grants_alter (&$grants, $account, $op)
hook_node_operations ()
hook_node_delete ($node)
hook_node_revision_delete ($node)
hook_node_insert ($node)
hook_node_load ($nodes, $types)
hook_node_access ($node, $op, $account)
hook_node_prepare ($node)
hook_node_search_result ($node)
hook_node_presave ($node)
hook_node_update ($node)
hook_node_update_index ($node)
hook_node_validate ($node, $form, &$form_state)
hook_node_submit ($node, $form, &$form_state)
hook_node_view ($node, $view_mode, $langcode)
hook_node_view_alter (&$build)
hook_node_info ()
hook_ranking ()
hook_node_type_insert ($info)
hook_node_type_update ($info)
hook_node_type_delete ($info)
hook_delete ($node)
hook_prepare ($node)
hook_form ($node, &$form_state)
hook_insert ($node)
hook_load ($nodes)
hook_update ($node)
hook_validate ($node, $form, &$form_state)
hook_view ($node, $view_mode)

Detailed Description

Hooks provided by the Node module.

Definition in file node.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/node.install File Reference

  • modules
  • node
Functions
node.install File Reference

Go to the source code of this file.

Functions

node_schema ()
node_install ()
node_update_dependencies ()
_update_7000_node_get_types ()
node_update_7000 ()
node_update_7001 ()
node_update_7002 ()
node_update_7003 ()
node_update_7004 ()
node_update_7005 ()
node_update_7006 (&$sandbox)
node_update_7007 ()
node_update_7008 ()
node_update_7009 ()
node_update_7010 ()
node_update_7011 ()
node_update_7012 ()
node_update_7013 ()
node_update_7014 ()

Detailed Description

Install, update and uninstall functions for the node module.

Definition in file node.install.

Function Documentation

node_install ( )

Implements hook_install().

Definition at line 435 of file node.install.

References db_insert().

node_schema ( )

Implements hook_schema().

Definition at line 11 of file node.install.

node_update_dependencies ( )

Implements hook_update_dependencies().

Definition at line 452 of file node.install.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/node.module File Reference

  • modules
  • node
Classes | Functions | Variables
node.module File Reference

Go to the source code of this file.

Classes

class NodeController

Functions

node_help ($path, $arg)
node_theme ()
node_cron ()
node_entity_info ()
node_field_display_node_alter (&$display, $context)
node_uri ($node)
node_admin_paths ()
node_title_list ($result, $title=NULL)
node_tag_new ($node)
node_last_viewed ($nid)
node_mark ($nid, $timestamp)
_node_extract_type ($node)
node_type_get_types ()
node_type_get_type ($node)
node_type_get_base ($node)
node_type_get_names ()
node_type_get_name ($node)
node_types_rebuild ()
node_type_load ($name)
node_type_save ($info)
node_add_body_field ($type, $label= 'Body')
node_field_extra_fields ()
node_type_delete ($type)
node_type_update_nodes ($old_type, $type)
_node_types_build ($rebuild=FALSE)
node_type_cache_reset ()
node_type_set_defaults ($info=array())
node_rdf_mapping ()
node_hook ($node, $hook)
node_invoke ($node, $hook, $a2=NULL, $a3=NULL, $a4=NULL)
node_load_multiple ($nids=array(), $conditions=array(), $reset=FALSE)
node_load ($nid=NULL, $vid=NULL, $reset=FALSE)
node_object_prepare ($node)
node_validate ($node, $form, &$form_state)
node_submit ($node)
node_save ($node)
_node_save_revision ($node, $uid, $update=NULL)
node_delete ($nid)
node_delete_multiple ($nids)
node_revision_delete ($revision_id)
node_view ($node, $view_mode= 'full', $langcode=NULL)
node_build_content ($node, $view_mode= 'full', $langcode=NULL)
node_show ($node, $message=FALSE)
node_is_page ($node)
template_preprocess_node (&$variables)
node_permission ()
_node_rankings (SelectQueryExtender $query)
node_search_info ()
node_search_access ()
node_search_reset ()
node_search_status ()
node_search_admin ()
node_search_execute ($keys=NULL, $conditions=NULL)
node_ranking ()
node_user_cancel ($edit, $account, $method)
node_user_delete ($account)
theme_node_search_admin ($variables)
_node_revision_access ($node, $op= 'view', $account=NULL)
_node_add_access ()
node_menu ()
node_menu_local_tasks_alter (&$data, $router_item, $root_path)
node_type_page_title ($type)
node_page_title ($node)
node_last_changed ($nid)
node_revision_list ($node)
node_block_info ()
node_block_view ($delta= '')
node_block_configure ($delta= '')
node_block_save ($delta= '', $edit=array())
node_get_recent ($number=10)
theme_node_recent_block ($variables)
theme_node_recent_content ($variables)
node_form_block_add_block_form_alter (&$form, &$form_state)
node_form_block_admin_configure_alter (&$form, &$form_state)
node_form_block_admin_configure_submit ($form, &$form_state)
node_form_block_custom_block_delete_alter (&$form, &$form_state)
node_form_block_custom_block_delete_submit ($form, &$form_state)
node_modules_uninstalled ($modules)
node_block_list_alter (&$blocks)
node_feed ($nids=FALSE, $channel=array())
node_view_multiple ($nodes, $view_mode= 'teaser', $weight=0, $langcode=NULL)
node_page_default ()
node_page_view ($node)
node_update_index ()
_node_index_node ($node)
node_form_search_form_alter (&$form, $form_state)
node_search_validate ($form, &$form_state)
node_access ($op, $node, $account=NULL)
node_node_access ($node, $op, $account)
node_list_permissions ($type)
node_permissions_get_configured_types ()
node_access_grants ($op, $account=NULL)
node_access_view_all_nodes ($account=NULL)
node_query_node_access_alter (QueryAlterableInterface $query)
node_query_entity_field_access_alter (QueryAlterableInterface $query)
_node_query_node_access_alter ($query, $type)
node_access_acquire_grants ($node, $delete=TRUE)
node_access_write_grants ($node, $grants, $realm=NULL, $delete=TRUE)
node_access_needs_rebuild ($rebuild=NULL)
node_access_rebuild ($batch_mode=FALSE)
_node_access_rebuild_batch_operation (&$context)
_node_access_rebuild_batch_finished ($success, $results, $operations)
node_content_form ($node, $form_state)
node_forms ()
node_action_info ()
node_publish_action ($node, $context=array())
node_unpublish_action ($node, $context=array())
node_make_sticky_action ($node, $context=array())
node_make_unsticky_action ($node, $context=array())
node_promote_action ($node, $context=array())
node_unpromote_action ($node, $context=array())
node_save_action ($node)
node_assign_owner_action ($node, $context)
node_assign_owner_action_form ($context)
node_assign_owner_action_validate ($form, $form_state)
node_assign_owner_action_submit ($form, $form_state)
node_unpublish_by_keyword_action_form ($context)
node_unpublish_by_keyword_action_submit ($form, $form_state)
node_unpublish_by_keyword_action ($node, $context)
node_requirements ($phase)
node_modules_enabled ($modules)
node_file_download_access ($field, $entity_type, $entity)

Variables

const | NODE_NOT_PUBLISHED 0
const | NODE_PUBLISHED 1
const | NODE_NOT_PROMOTED 0
const | NODE_PROMOTED 1
const | NODE_NOT_STICKY 0
const | NODE_STICKY 1
const | NODE_NEW_LIMIT REQUEST_TIME - 30 * 24 * 60 * 60
const | NODE_ACCESS_ALLOW 'allow'
const | NODE_ACCESS_DENY 'deny'
const | NODE_ACCESS_IGNORE NULL

Detailed Description

The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

Definition in file node.module.

Function Documentation

_node_add_access ( )

Access callback: Checks whether the user has permission to add a node.

Returns
TRUE if the user has add permission, otherwise FALSE.
See Also
node_menu()

Definition at line 1963 of file node.module.

References node_access(), node_hook(), node_type_get_types(), and user_access().

Referenced by node_page_default().

_node_extract_type ( $node )

Extracts the type name.

Parameters
$node Either a string or object, containing the node type information.
Returns
Node type of the passed-in data.

Definition at line 378 of file node.module.

Referenced by node_type_get_base(), node_type_get_name(), and node_type_get_type().

_node_index_node ( $node )

Indexes a single node.

Parameters
$node The node to index.

Definition at line 2777 of file node.module.

References check_plain(), drupal_render(), module_invoke_all(), node_load(), node_view(), search_index(), and variable_set().

Referenced by node_update_index().

_node_rankings ( SelectQueryExtender $query )

Gathers the rankings from the the hook_ranking() implementations.

Parameters
$query A query object that has been extended with the Search DB Extender.

Definition at line 1623 of file node.module.

References SelectQueryExtender::addJoin(), SelectQueryExtender::getTables(), module_invoke_all(), and variable_get().

Referenced by hook_search_execute(), and node_search_execute().

_node_revision_access | ( | $node,
 |  | $op = 'view',
 |  | $account = NULL
 | ) |

Access callback: Checks node revision access.

Parameters
$node | The node to check.
$op | (optional) The specific operation being checked. Defaults to 'view.'
object | $account | (optional) A user object representing the user for whom the operation is to be performed. Determines access for a user other than the current user.
Returns
TRUE if the operation may be performed, FALSE otherwise.
See Also
node_menu()

Definition at line 1903 of file node.module.

References $op, db_query(), drupal_static(), node_access(), node_load(), and user_access().

_node_save_revision | ( | $node,
 |  | $uid,
 |  | $update = NULL
 | ) |

Helper function to save a revision with the uid of the current user.

The resulting revision ID is available afterward in $node->vid.

Parameters
$node | A node object.
$uid | The current user's UID.
$update | (optional) An array of primary keys' field names to update.

Definition at line 1214 of file node.module.

References drupal_write_record().

Referenced by node_save().

_node_types_build ( $rebuild = FALSE )

Builds and returns the list of available node types.

The list of types is built by invoking hook_node_info() on all modules and comparing this information with the node types in the {node_type} table. These two information sources are not synchronized during module installation until node_types_rebuild() is called.

Parameters
$rebuild TRUE to rebuild node types. Equivalent to calling node_types_rebuild().
Returns
An object with two properties:
  • names: Associative array of the names of node types, keyed by the type.
  • types: Associative array of node type objects, keyed by the type. Both of these arrays will include new types that have been defined by hook_node_info() implementations but not yet saved in the {node_type} table. These are indicated in the type object by $type->is_new being set to the value 1. These arrays will also include obsolete types: types that were previously defined by modules that have now been disabled, or for whatever reason are no longer being defined in hook_node_info() implementations, but are still in the database. These are indicated in the type object by $type->disabled being set to TRUE.

Definition at line 705 of file node.module.

References $info, $module, cache_get(), cache_set(), db_select(), drupal_static(), module_implements(), module_invoke(), node_type_save(), and node_type_set_defaults().

Referenced by node_type_get_base(), node_type_get_name(), node_type_get_names(), node_type_get_type(), node_type_get_types(), and node_types_rebuild().

node_action_info ( )

Implements hook_action_info().

Definition at line 3767 of file node.module.

References t().

node_add_body_field | ( | $type,
 |  | $label = 'Body'
 | ) |

Adds default body field to a node type.

Parameters
$type | A node type object.
$label | The label for the body instance.
Returns
Body field instance.

Definition at line 586 of file node.module.

References field_create_field(), field_create_instance(), field_info_field(), and field_info_instance().

Referenced by _book_install_type_create(), blog_install(), DrupalWebTestCase::drupalCreateContentType(), forum_enable(), node_example_node_type_insert(), node_type_form_submit(), simpletest_example_install(), simpletest_example_update_7001(), and standard_install().

node_admin_paths ( )

Implements hook_admin_paths().

Definition at line 258 of file node.module.

References variable_get().

node_assign_owner_action_submit | ( | $form,
 |  | $form_state
 | ) |

Saves settings form for node_assign_owner_action().

See Also
node_assign_owner_action_validate()

Definition at line 4029 of file node.module.

References db_query().

node_assign_owner_action_validate | ( | $form,
 |  | $form_state
 | ) |

Validates settings form for node_assign_owner_action().

See Also
node_assign_owner_action_submit()

Definition at line 4017 of file node.module.

References db_query_range(), form_set_error(), and t().

node_block_configure ( $delta = '' )

Implements hook_block_configure().

Definition at line 2286 of file node.module.

References drupal_map_assoc(), t(), and variable_get().

node_block_info ( )

Implements hook_block_info().

Definition at line 2244 of file node.module.

References DRUPAL_NO_CACHE, and t().

node_block_list_alter ( & $blocks )

Implements hook_block_list_alter().

Check the content type specific visibilty settings. Remove the block if the visibility conditions are not met.

Definition at line 2514 of file node.module.

References arg(), db_query(), menu_get_object(), and node_type_get_types().

node_block_save | ( | $delta = '',
 |  | $edit = array()
 | ) |

Implements hook_block_save().

Definition at line 2302 of file node.module.

References variable_set().

node_block_view ( $delta = '' )

Implements hook_block_view().

Definition at line 2258 of file node.module.

References node_get_recent(), t(), theme(), user_access(), and variable_get().

node_build_content | ( | $node,
 |  | $view_mode = 'full',
 |  | $langcode = NULL
 | ) |

Builds a structured array representing the node's content.

The content built for the node (field values, comments, file attachments or other node components) will vary depending on the $view_mode parameter.

Drupal core defines the following view modes for nodes, with the following default use cases:

  • full (default): node is being displayed on its own page (node/123)
  • teaser: node is being displayed on the default home page listing, on taxonomy listing pages, or on blog listing pages.
  • rss: node displayed in an RSS feed. If search.module is enabled:
  • search_index: node is being indexed for search.
  • search_result: node is being displayed as a search result. If book.module is enabled:
  • print: node is being displayed in print-friendly mode. Contributed modules might define additional view modes, or use existing view modes in additional contexts.
Parameters
$node | A node object.
$view_mode | View mode, e.g. 'full', 'teaser'...
$langcode | (optional) A language code to use for rendering. Defaults to the global content language of the current request.

Definition at line 1391 of file node.module.

References $links, drupal_alter(), entity_prepare_view(), field_attach_prepare_view(), field_attach_view(), module_invoke_all(), node_hook(), node_invoke(), and t().

Referenced by hook_search_execute(), hook_update_index(), and node_view().

node_cron ( )

Implements hook_cron().

Definition at line 158 of file node.module.

References db_delete(), and NODE_NEW_LIMIT.

node_delete ( $nid )

Deletes a node.

Parameters
$nid A node ID.

Definition at line 1233 of file node.module.

References node_delete_multiple().

Referenced by node_delete_confirm_submit().

node_delete_multiple ( $nids )

Deletes multiple nodes.

Parameters
$nids An array of node IDs.

Definition at line 1243 of file node.module.

References db_delete(), db_transaction(), entity_get_controller(), field_attach_delete(), module_exists(), module_invoke_all(), node_invoke(), node_load_multiple(), search_reindex(), and watchdog_exception().

Referenced by node_delete(), node_multiple_delete_confirm_submit(), node_user_delete(), and rdf_example_uninstall().

node_entity_info ( )

Implements hook_entity_info().

Definition at line 167 of file node.module.

References $name, module_exists(), node_type_get_names(), and t().

node_feed | ( | $nids = FALSE,
 |  | $channel = array()
 | ) |

Generates and prints an RSS feed.

Generates an RSS feed from an array of node IDs, and prints it with an HTTP header, with Content Type set to RSS/XML.

Parameters
$nids | An array of node IDs (nid). Defaults to FALSE so empty feeds can be generated with passing an empty array, if no items are to be added to the feed.
$channel | An associative array containing title, link, description and other keys, to be parsed by format_rss_channel() and format_xml_elements(). A list of channel elements can be found at the RSS 2.0 Specification. The link should be an absolute URL.

Definition at line 2581 of file node.module.

References $base_url, $output, db_select(), drupal_add_http_header(), drupal_attributes(), drupal_render(), format_rss_channel(), format_rss_item(), node_load_multiple(), node_view(), print, url(), and variable_get().

Referenced by blog_feed_last(), blog_feed_user(), and taxonomy_term_feed().

node_field_display_node_alter | ( | & | $display,
 |  |  | $context
 | ) |  |

Implements hook_field_display_ENTITY_TYPE_alter().

Definition at line 239 of file node.module.

node_field_extra_fields ( )

Implements hook_field_extra_fields().

Definition at line 625 of file node.module.

References node_type_get_types(), and t().

node_file_download_access | ( | $field,
 |  | $entity_type,
 |  | $entity
 | ) |

Implements hook_file_download_access().

Definition at line 4170 of file node.module.

References node_access().

node_form_block_add_block_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORMID_alter().

Adds node-type specific visibility options to add block form.

See Also
block_add_block_form()

Definition at line 2419 of file node.module.

References node_form_block_admin_configure_alter().

node_form_block_admin_configure_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORMID_alter().

Adds node-type specific visibility options to block configuration form.

See Also
block_admin_configure()

Definition at line 2430 of file node.module.

References db_query(), node_type_get_names(), and t().

Referenced by node_form_block_add_block_form_alter().

node_form_block_admin_configure_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for node_form_block_admin_configure_alter().

See Also
node_form_block_admin_configure_alter()

Definition at line 2458 of file node.module.

References db_delete(), and db_insert().

node_form_block_custom_block_delete_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORMID_alter().

Adds node specific submit handler to delete custom block form.

See Also
block_custom_block_delete()

Definition at line 2481 of file node.module.

node_form_block_custom_block_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for node_form_block_custom_block_delete_alter().

See Also
node_form_block_custom_block_delete_alter()

Definition at line 2490 of file node.module.

References db_delete().

node_form_search_form_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 2804 of file node.module.

References language_list(), node_type_get_names(), t(), and user_access().

node_forms ( )

End of "defgroup node_content". Implements hook_forms().

All node forms share the same form handler.

Definition at line 3754 of file node.module.

References node_type_get_types().

node_get_recent ( $number = 10 )

Finds the most recently changed nodes that are available to the current user.

Parameters
$number (optional) The maximum number of nodes to find. Defaults to 10.
Returns
An array of node entities or an empty array if there are no recent nodes visible to the current user.

Definition at line 2318 of file node.module.

References db_or(), db_query(), db_select(), node_load_multiple(), NODE_NOT_PUBLISHED, NODE_PUBLISHED, and user_access().

Referenced by hook_block_view(), and node_block_view().

node_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 65 of file node.module.

References $output, drupal_set_message(), filter_xss_admin(), node_access_needs_rebuild(), node_load(), node_type_get_name(), node_type_get_type(), t(), url(), and user_access().

node_hook | ( | $node,
 |  | $hook
 | ) |

Determines whether a node hook exists.

Parameters
$node | A node object or a string containing the node type.
$hook | A string containing the name of the hook.
Returns
TRUE if the $hook exists in the node type of $node.

Definition at line 893 of file node.module.

References module_hook(), and node_type_get_base().

Referenced by _node_add_access(), NodeController::attachLoad(), node_build_content(), node_invoke(), and node_overview_types().

node_invoke | ( | $node,
 |  | $hook,
 |  | $a2 = NULL,
 |  | $a3 = NULL,
 |  | $a4 = NULL
 | ) |

Invokes a node hook.

Parameters
$node | A node object or a string containing the node type.
$hook | A string containing the name of the hook.
$a2,$a3,$a4 | Arguments to pass on to the hook, after the $node argument.
Returns
The returned value of the invoked hook.

Definition at line 911 of file node.module.

References node_hook(), and node_type_get_base().

Referenced by node_build_content(), node_delete_multiple(), node_object_prepare(), and node_save().

node_is_page ( $node )

Returns whether the current page is the full page view of the passed-in node.

Parameters
$node A node object.
Returns
The ID of the node if this is a full page view, otherwise FALSE.

Definition at line 1487 of file node.module.

References menu_get_object().

Referenced by bartik_preprocess_node(), blog_view(), book_node_view_link(), comment_node_view(), forum_node_view(), hook_view(), node_view(), statistics_node_view(), and template_preprocess_node().

node_last_changed ( $nid )

Finds the last time a node was changed.

Parameters
$nid The ID of a node.
Returns
A unix timestamp indicating the last time the node was changed.

Definition at line 2218 of file node.module.

References db_query().

Referenced by node_validate().

node_last_viewed ( $nid )

Retrieves the timestamp for the current user's last view of a specified node.

Parameters
$nid A node ID.
Returns
If a node has been previously viewed by the user, the timestamp in seconds of when the last view occurred; otherwise, zero.

Definition at line 328 of file node.module.

References db_query(), and drupal_static().

Referenced by comment_num_new(), and node_mark().

node_load | ( | $nid = NULL,
 |  | $vid = NULL,
 |  | $reset = FALSE
 | ) |

Loads a node object from the database.

Parameters
$nid | The node ID.
$vid | The revision ID.
$reset | Whether to reset the node_load_multiple cache.
Returns
A fully-populated node object, or FALSE if the node is not found.

Definition at line 962 of file node.module.

References node_load_multiple().

Referenced by _node_index_node(), _node_mass_update_helper(), _node_revision_access(), _trigger_normalize_comment_context(), _trigger_normalize_user_context(), ajax_example_node_by_author_autocomplete_submit(), ajax_example_node_by_author_autocomplete_validate(), ajax_example_unique_autocomplete_submit(), ajax_example_unique_autocomplete_validate(), batch_example_op_1(), batch_example_op_2(), book_admin_edit_submit(), book_block_view(), book_export(), book_export_html(), book_export_traverse(), book_form_node_delete_confirm_alter(), book_node_delete(), comment_edit_page(), comment_file_download_access(), comment_form(), comment_form_submit(), comment_permalink(), comment_preview(), comment_save(), comment_tokens(), hook_search_execute(), hook_update_index(), node_access_rebuild(), node_delete_confirm_submit(), node_example_page(), node_help(), node_revision_delete(), node_search_execute(), poll_block_view(), poll_cancel(), profile_block_view(), statistics_node_tracker(), translation_language_switch_links_alter(), translation_node_overview(), translation_node_prepare(), and translation_path_get_translations().

node_load_multiple | ( | $nids = array(),
 |  | $conditions = array(),
 |  | $reset = FALSE
 | ) |

Loads node entities from the database.

This function should be used whenever you need to load more than one node from the database. Nodes are loaded into memory and will not require database access if loaded again during the same page request.

See Also
entity_load()
EntityFieldQuery
Parameters
$nids | An array of node IDs.
$conditions | (deprecated) An associative array of conditions on the {node} table, where the keys are the database fields and the values are the values those fields must have. Instead, it is preferable to use EntityFieldQuery to retrieve a list of entity IDs loadable by this function.
$reset | Whether to reset the internal node_load cache.
Returns
An array of node objects indexed by nid.

Definition at line 945 of file node.module.

References entity_load().

Referenced by _node_access_rebuild_batch_operation(), blog_page_last(), blog_page_user(), DrupalWebTestCase::drupalGetNodeByTitle(), node_admin_nodes(), node_delete_multiple(), node_feed(), node_get_recent(), node_load(), node_page_default(), and taxonomy_term_page().

node_mark | ( | $nid,
 |  | $timestamp
 | ) |

Determines the type of marker to be displayed for a given node.

Parameters
$nid | Node ID whose history supplies the "last viewed" timestamp.
$timestamp | Time which is compared against node's "last viewed" timestamp.
Returns
One of the MARK constants.

Definition at line 350 of file node.module.

References drupal_static(), MARK_NEW, MARK_READ, MARK_UPDATED, node_last_viewed(), and NODE_NEW_LIMIT.

Referenced by CommentController::attachLoad(), node_admin_nodes(), theme_node_recent_content(), and tracker_page().

node_menu ( )

Implements hook_menu().

Definition at line 1982 of file node.module.

References MENU_CALLBACK, MENU_CONTEXT_INLINE, MENU_CONTEXT_PAGE, MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION, MENU_LOCAL_TASK, node_type_cache_reset(), and node_type_get_types().

node_menu_local_tasks_alter | ( | & | $data,
 |  |  | $router_item,
 |  |  | $root_path
 | ) |  |

Implements hook_menu_local_tasks_alter().

Definition at line 2166 of file node.module.

References menu_get_item().

node_modules_enabled ( $modules )

Implements hook_modules_enabled().

Definition at line 4116 of file node.module.

References module_implements(), and node_access_needs_rebuild().

node_modules_uninstalled ( $modules )

Implements hook_modules_uninstalled().

Cleanup {block_node_type} table from modules' blocks.

Definition at line 2502 of file node.module.

References db_delete().

node_object_prepare ( $node )

Prepares a node object for editing.

Fills in a few default values, and then invokes hook_prepare() on the node type module, and hook_node_prepare() on all modules.

Parameters
$node A node object.

Definition at line 978 of file node.module.

References format_date(), module_invoke_all(), node_invoke(), REQUEST_TIME, and variable_get().

Referenced by node_form().

node_page_default ( )

Menu callback: Generates a listing of promoted nodes.

Returns
array An array in the format expected by drupal_render().
See Also
node_menu()

Definition at line 2687 of file node.module.

References _node_add_access(), db_select(), drupal_add_feed(), drupal_set_title(), l(), node_load_multiple(), node_view_multiple(), PASS_THROUGH, t(), theme(), and variable_get().

node_page_title ( $node )

Title callback: Returns the title of the node.

Parameters
$node The node object.
Returns
An unsanitized string that is the title of the node.
See Also
node_menu()

Definition at line 2205 of file node.module.

node_page_view ( $node )

Menu callback: Displays a single node.

Parameters
$node The node object.
Returns
A page array suitable for use by drupal_render().
See Also
node_menu()

Definition at line 2745 of file node.module.

References drupal_add_html_head_link(), drupal_set_title(), entity_uri(), node_show(), and url().

node_permission ( )

Implements hook_permission().

Definition at line 1571 of file node.module.

References node_list_permissions(), node_permissions_get_configured_types(), t(), url(), and user_access().

node_ranking ( )

Implements hook_ranking().

Definition at line 1765 of file node.module.

References t(), and variable_get().

node_rdf_mapping ( )

Implements hook_rdf_mapping().

Definition at line 838 of file node.module.

References RDF_DEFAULT_BUNDLE.

node_requirements ( $phase )

Implements hook_requirements().

Definition at line 4089 of file node.module.

References $value, db_query(), format_plural(), l(), module_implements(), and t().

node_revision_delete ( $revision_id )

Deletes a node revision.

Parameters
$revision_id The revision ID to delete.

Definition at line 1296 of file node.module.

References db_delete(), field_attach_delete_revision(), module_invoke_all(), and node_load().

Referenced by node_revision_delete_confirm_submit(), and node_user_delete().

node_revision_list ( $node )

Returns a list of all the existing revision numbers.

Parameters
$node The node object.
Returns
An associative array keyed by node revision number.

Definition at line 2231 of file node.module.

References db_query().

Referenced by node_revision_overview().

node_save ( $node )

Saves changes to a node or adds a new node.

Parameters
$node The $node object to be saved. If $node->nid is omitted (or $node->is_new is TRUE), a new node will be added.

Definition at line 1076 of file node.module.

References $op, _node_save_revision(), db_ignore_slave(), db_transaction(), db_update(), drupal_write_record(), entity_get_controller(), entity_load_unchanged(), field_attach_presave(), module_invoke_all(), node_access_acquire_grants(), node_invoke(), REQUEST_TIME, and watchdog_exception().

Referenced by _node_mass_update_helper(), book_admin_edit_submit(), DrupalWebTestCase::drupalCreateNode(), node_form_submit(), node_revision_revert_confirm_submit(), and node_save_action().

node_search_access ( )

Implements hook_search_access().

Definition at line 1652 of file node.module.

References user_access().

node_search_admin ( )

Implements hook_search_admin().

Definition at line 1678 of file node.module.

References drupal_map_assoc(), module_invoke_all(), t(), and variable_get().

node_search_execute | ( | $keys = NULL,
 |  | $conditions = NULL
 | ) |

Implements hook_search_execute().

Definition at line 1705 of file node.module.

References $results, _node_rankings(), check_plain(), db_select(), drupal_render(), entity_language(), entity_uri(), module_invoke(), module_invoke_all(), node_load(), node_type_get_name(), node_view(), search_excerpt(), theme(), and url().

node_search_info ( )

Implements hook_search_info().

Definition at line 1642 of file node.module.

node_search_reset ( )

Implements hook_search_reset().

Definition at line 1659 of file node.module.

References db_update(), and REQUEST_TIME.

node_search_status ( )

Implements hook_search_status().

Definition at line 1669 of file node.module.

References db_query().

node_search_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for node_form_alter().

Definition at line 2878 of file node.module.

References form_set_value(), and search_expression_insert().

node_show | ( | $node,
 |  | $message = FALSE
 | ) |

Generates an array which displays a node detail page.

Parameters
$node | A node object.
$message | A flag which sets a page title relevant to the revision being viewed.
Returns
A $page element suitable for use by drupal_render().

Definition at line 1464 of file node.module.

References drupal_set_title(), format_date(), node_tag_new(), node_view_multiple(), PASS_THROUGH, and t().

Referenced by node_page_view(), and poll_results().

node_submit ( $node )

Prepares node for saving by populating author and creation date.

Parameters
$node A node object.
Returns
An updated node object.

Definition at line 1051 of file node.module.

References REQUEST_TIME, and user_load_by_name().

Referenced by node_form_submit_build_node().

node_tag_new ( $node )

Updates the 'last viewed' timestamp of the specified node for current user.

Parameters
$node A node object.

Definition at line 305 of file node.module.

References db_merge(), and REQUEST_TIME.

Referenced by node_show().

node_theme ( )

Implements hook_theme().

Definition at line 125 of file node.module.

node_title_list | ( | $result,
 |  | $title = NULL
 | ) |

Gathers a listing of links to nodes.

Parameters
$result | A database result object from a query to fetch node entities. If your query joins the {node_comment_statistics} table so that the comment_count field is available, a title attribute will be added to show the number of comments.
$title | A heading for the resulting list.
Returns
A renderable array containing a list of linked node titles fetched from $result, or FALSE if there are no rows in $result.

Definition at line 288 of file node.module.

References $title, format_plural(), and l().

Referenced by blog_block_view(), forum_block_view_pre_render(), and statistics_block_view().

node_type_cache_reset ( )

Clears the node type cache.

Definition at line 783 of file node.module.

References cache_clear_all(), and drupal_static_reset().

Referenced by node_menu(), node_type_delete(), node_type_save(), node_update_7004(), node_update_7006(), and node_update_7012().

node_type_delete ( $type )

Deletes a node type from the database.

Parameters
$type The machine-readable name of the node type to be deleted.

Definition at line 651 of file node.module.

References $info, db_delete(), field_attach_delete_bundle(), module_invoke_all(), node_type_cache_reset(), and node_type_get_type().

Referenced by node_type_delete_confirm_submit(), and rdf_example_uninstall().

node_type_get_base ( $node )

Returns the node type base of the passed node or node type string.

The base indicates which module implements this node type and is used to execute node-type-specific hooks. For types defined in the user interface and managed by node.module, the base is 'node_content'.

Parameters
$node A node object or string that indicates the node type to return.
Returns
The node type base or FALSE if the node type is not found.
See Also
node_invoke()

Definition at line 431 of file node.module.

References _node_extract_type(), and _node_types_build().

Referenced by NodeController::attachLoad(), node_form(), node_hook(), node_invoke(), and node_validate().

node_type_get_name ( $node )

Returns the node type name of the passed node or node type string.

Parameters
$node A node object or string that indicates the node type to return.
Returns
The node type name or FALSE if the node type is not found.

Definition at line 459 of file node.module.

References _node_extract_type(), and _node_types_build().

Referenced by action_example_node_sticky_action(), forum_menu_local_tasks_alter(), hook_mail(), hook_search_execute(), node_admin_nodes(), node_assign_owner_action(), node_delete_confirm_submit(), node_form_submit(), node_help(), node_make_sticky_action(), node_make_unsticky_action(), node_page_edit(), node_promote_action(), node_publish_action(), node_revision_delete_confirm_submit(), node_revision_revert_confirm_submit(), node_save_action(), node_search_execute(), node_tokens(), node_unpromote_action(), node_unpublish_action(), node_unpublish_by_keyword_action(), and tracker_page().

node_type_get_names ( )

Returns a list of available node type names.

This list can include types that are queued for addition or deletion. See _node_types_build() for details.

Returns
An array of node type names, keyed by the type.

Definition at line 446 of file node.module.

References _node_types_build().

Referenced by book_admin_settings(), comment_entity_info(), hook_entity_info(), node_entity_info(), node_filters(), node_form_block_admin_configure_alter(), node_form_search_form_alter(), node_overview_types(), and node_type_form_validate().

node_type_get_type ( $node )

Returns the node type of the passed node or node type string.

Parameters
$node A node object or string that indicates the node type to return.
Returns
A single node type, as an object, or FALSE if the node type is not found. The node type is an object containing fields from hook_node_info() return values, as well as the field 'type' (the machine-readable type) and other fields used internally and defined in _node_types_build(), hook_node_info(), and node_type_set_defaults().

Definition at line 410 of file node.module.

References _node_extract_type(), and _node_types_build().

Referenced by comment_node_type_load(), DrupalWebTestCase::drupalCreateContentType(), forum_form(), hook_form(), node_content_form(), node_help(), node_list_permissions(), node_type_delete(), node_type_load(), poll_form(), and simpletest_example_form().

node_type_get_types ( )

Returns a list of all the available node types.

This list can include types that are queued for addition or deletion. See _node_types_build() for details.

Returns
An array of node types, as objects, keyed by the type.
See Also
node_type_get_type()

Definition at line 393 of file node.module.

References _node_types_build().

Referenced by _node_add_access(), blog_install(), comment_field_extra_fields(), comment_forms(), comment_modules_enabled(), comment_uninstall(), forum_enable(), hook_field_extra_fields_alter(), locale_uninstall(), node_add(), node_block_list_alter(), node_field_extra_fields(), node_forms(), node_menu(), node_overview_types(), node_permissions_get_configured_types(), simpletest_example_install(), and simpletest_example_update_7001().

node_type_load ( $name )

Menu argument loader: loads a node type by string.

Parameters
$name The machine-readable name of a node type to load, where '_' is replaced with '-'.
Returns
A node type object or FALSE if $name does not exist.

Definition at line 489 of file node.module.

References $name, and node_type_get_type().

node_type_page_title ( $type )

Title callback: Returns the unsanitized title of the node type edit form.

Parameters
$type The node type object.
Returns
string An unsanitized string that is the title of the node type edit form.
See Also
node_menu()

Definition at line 2190 of file node.module.

node_type_save ( $info )

Saves a node type to the database.

Parameters
object $info The node type to save; an object with the following properties:
  • type: A string giving the machine name of the node type.
  • name: A string giving the human-readable name of the node type.
  • base: A string that indicates the base string for hook functions. For example, 'node_content' is the value used by the UI when creating a new node type.
  • description: A string that describes the node type.
  • help: A string giving the help information shown to the user when creating a node of this type.
  • custom: TRUE or FALSE indicating whether this type is defined by a module (FALSE) or by a user (TRUE) via Add Content Type.
  • modified: TRUE or FALSE indicating whether this type has been modified by an administrator. Currently not used in any way.
  • locked: TRUE or FALSE indicating whether the administrator can change the machine name of this type.
  • disabled: TRUE or FALSE indicating whether this type has been disabled.
  • has_title: TRUE or FALSE indicating whether this type uses the node title field.
  • title_label: A string containing the label for the title.
  • module: A string giving the module defining this type of node.
  • orig_type: A string giving the original machine-readable name of this node type. This may be different from the current type name if the 'locked' key is FALSE.
Returns
int A status flag indicating the outcome of the operation, either SAVED_NEW or SAVED_UPDATED.

Definition at line 525 of file node.module.

References $info, db_insert(), db_query_range(), db_update(), field_attach_create_bundle(), field_attach_rename_bundle(), module_invoke_all(), node_type_cache_reset(), node_type_set_defaults(), SAVED_NEW, and SAVED_UPDATED.

Referenced by _book_install_type_create(), _node_types_build(), DrupalWebTestCase::drupalCreateContentType(), node_type_form_submit(), rdf_example_install(), and standard_install().

node_type_set_defaults ( $info = array() )

Sets the default values for a node type.

The defaults are appropriate for a type defined through hook_node_info(), since 'custom' is TRUE for types defined in the user interface, and FALSE for types defined by modules. (The 'custom' flag prevents types from being deleted through the user interface.) Also, the default for 'locked' is TRUE, which prevents users from changing the machine name of the type.

Parameters
$info (optional) An object or array containing values to override the defaults. See hook_node_info() for details on what the array elements mean. Defaults to an empty array.
Returns
A node type object, with missing values in $info set to their defaults.

Definition at line 805 of file node.module.

References $info.

Referenced by _book_install_type_create(), _node_types_build(), node_type_form(), node_type_form_submit(), node_type_reset(), node_type_save(), rdf_example_install(), and standard_install().

node_type_update_nodes | ( | $old_type,
 |  | $type
 | ) |

Updates all nodes of one type to be of another type.

Parameters
$old_type | The current node type of the nodes.
$type | The new node type of the nodes.
Returns
The number of nodes whose node type field was modified.

Definition at line 674 of file node.module.

References db_update().

Referenced by node_node_type_insert(), and node_node_type_update().

node_types_rebuild ( )

Updates the database cache of node types.

All new module-defined node types are saved to the database via a call to node_type_save(), and obsolete ones are deleted via a call to node_type_delete(). See _node_types_build() for an explanation of the new and obsolete types.

See Also
_node_types_build()

Definition at line 475 of file node.module.

References _node_types_build().

Referenced by blog_install(), comment_modules_enabled(), drupal_flush_all_caches(), DrupalWebTestCase::drupalCreateContentType(), forum_enable(), node_type_delete_confirm_submit(), node_type_form_submit(), simpletest_example_install(), and simpletest_example_update_7001().

node_unpublish_by_keyword_action_form ( $context )

Generates settings form for node_unpublish_by_keyword_action().

Parameters
array $context Array of additional information about what triggered this action.
Returns
array A form array.
See Also
node_unpublish_by_keyword_action_submit()

Definition at line 4046 of file node.module.

References drupal_implode_tags(), and t().

node_unpublish_by_keyword_action_submit | ( | $form,
 |  | $form_state
 | ) |

Saves settings form for node_unpublish_by_keyword_action().

Definition at line 4059 of file node.module.

References drupal_explode_tags().

node_update_index ( )

Implements hook_update_index().

Definition at line 2761 of file node.module.

References _node_index_node(), db_query_range(), and variable_get().

node_uri ( $node )

Implements callback_entity_info_uri().

Definition at line 249 of file node.module.

node_user_cancel | ( | $edit,
 |  | $account,
 |  | $method
 | ) |

Implements hook_user_cancel().

Definition at line 1800 of file node.module.

References db_delete(), db_select(), db_update(), module_load_include(), and node_mass_update().

node_user_delete ( $account )

Implements hook_user_delete().

Definition at line 1838 of file node.module.

References db_delete(), db_query(), db_select(), node_delete_multiple(), and node_revision_delete().

node_validate | ( |  | $node,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_validate().

Performs validation checks on the given node.

Definition at line 1010 of file node.module.

References $module, form_set_error(), module_implements(), node_last_changed(), node_type_get_base(), t(), and user_load_by_name().

Referenced by node_form_validate().

node_view | ( | $node,
 |  | $view_mode = 'full',
 |  | $langcode = NULL
 | ) |

Generates an array for rendering the given node.

Parameters
$node | A node object.
$view_mode | View mode, e.g. 'full', 'teaser'...
$langcode | (optional) A language code to use for rendering. Defaults to the global content language of the current request.
Returns
An array as expected by drupal_render().

Definition at line 1329 of file node.module.

References drupal_alter(), node_build_content(), and node_is_page().

Referenced by _node_index_node(), book_node_export(), comment_preview(), comment_reply(), node_example_page(), node_feed(), node_search_execute(), node_unpublish_by_keyword_action(), node_view_multiple(), and theme_node_preview().

node_view_multiple | ( | $nodes,
 |  | $view_mode = 'teaser',
 |  | $weight = 0,
 |  | $langcode = NULL
 | ) |

Constructs a drupal_render() style array from an array of loaded nodes.

Parameters
$nodes | An array of nodes as returned by node_load_multiple().
$view_mode | View mode, e.g. 'full', 'teaser'...
$weight | An integer representing the weight of the first node in the list.
$langcode | (optional) A language code to use for rendering. Defaults to NULL which is the global content language of the current request.
Returns
An array in the format expected by drupal_render().

Definition at line 2666 of file node.module.

References entity_prepare_view(), field_attach_prepare_view(), and node_view().

Referenced by blog_page_last(), blog_page_user(), node_page_default(), node_show(), and taxonomy_term_page().

template_preprocess_node ( & $variables )

Processes variables for node.tpl.php

Most themes utilize their own copy of node.tpl.php. The default is located inside "modules/node/node.tpl.php". Look in there for the full list of variables.

The $variables array contains the following arguments:

  • $node
  • $view_mode
  • $page
See Also
node.tpl.php

Definition at line 1506 of file node.module.

References check_plain(), drupal_html_class(), element_children(), entity_uri(), field_attach_preprocess(), format_date(), node_is_page(), t(), theme(), theme_get_setting(), url(), and variable_get().

Variable Documentation

const NODE_ACCESS_ALLOW 'allow'

Modules should return this value from hook_node_access() to allow access to a node.

Definition at line 50 of file node.module.

Referenced by hook_node_access(), node_access(), node_access_example_node_access(), node_node_access(), and simpletest_example_node_access().

const NODE_ACCESS_DENY 'deny'

Modules should return this value from hook_node_access() to deny access to a node.

Definition at line 55 of file node.module.

Referenced by node_access(), and simpletest_example_node_access().

const NODE_ACCESS_IGNORE NULL

Modules should return this value from hook_node_access() to not affect node access.

Definition at line 60 of file node.module.

Referenced by hook_node_access(), node_access_example_node_access(), node_node_access(), and simpletest_example_node_access().

const NODE_NEW_LIMIT REQUEST_TIME - 30 * 24 * 60 * 60

Nodes changed before this time are always marked as read.

Nodes changed after this time may be marked new, updated, or read, depending on their state for the current user. Defaults to 30 days ago.

Definition at line 45 of file node.module.

Referenced by _forum_topics_unread(), _forum_user_last_visit(), comment_num_new(), node_cron(), and node_mark().

const NODE_NOT_PROMOTED 0

Node is not promoted to front page.

Definition at line 22 of file node.module.

Referenced by hook_node_operations(), node_node_operations(), and node_unpromote_action().

const NODE_NOT_PUBLISHED 0

Node is not published.

Definition at line 12 of file node.module.

Referenced by hook_node_operations(), node_get_recent(), node_node_operations(), node_unpublish_action(), node_unpublish_by_keyword_action(), and taxonomy_update_7011().

const NODE_NOT_STICKY 0

Node is not sticky at top of the page.

Definition at line 32 of file node.module.

Referenced by hook_node_operations(), node_make_unsticky_action(), and node_node_operations().

const NODE_PROMOTED 1

Node is promoted to front page.

Definition at line 27 of file node.module.

Referenced by action_example_node_sticky_action(), hook_node_operations(), node_node_operations(), and node_promote_action().

const NODE_PUBLISHED 1

Node is published.

Definition at line 17 of file node.module.

Referenced by _token_example_get_comment(), _token_example_get_node(), comment_get_recent(), hook_node_operations(), node_get_recent(), node_node_operations(), and node_publish_action().

const NODE_STICKY 1

Node is sticky at top of the page.

Definition at line 37 of file node.module.

Referenced by action_example_node_sticky_action(), hook_node_operations(), node_make_sticky_action(), and node_node_operations().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/node.pages.inc File Reference

  • modules
  • node
Functions
node.pages.inc File Reference

Go to the source code of this file.

Functions

node_page_edit ($node)
node_add_page ()
theme_node_add_list ($variables)
node_add ($type)
node_form_validate ($form, &$form_state)
node_form ($form, &$form_state, $node)
node_form_delete_submit ($form, &$form_state)
node_form_build_preview ($form, &$form_state)
node_preview ($node)
theme_node_preview ($variables)
node_form_submit ($form, &$form_state)
node_form_submit_build_node ($form, &$form_state)
node_delete_confirm ($form, &$form_state, $node)
node_delete_confirm_submit ($form, &$form_state)
node_revision_overview ($node)
node_revision_revert_confirm ($form, $form_state, $node_revision)
node_revision_revert_confirm_submit ($form, &$form_state)
node_revision_delete_confirm ($form, $form_state, $node_revision)
node_revision_delete_confirm_submit ($form, &$form_state)

Detailed Description

Page callbacks for adding, editing, deleting, and revisions management for content.

Definition in file node.pages.inc.

Function Documentation

node_add ( $type )

Returns a node submission form.

Parameters
$type The node type for the submitted node.
Returns
The themed form.

Definition at line 72 of file node.pages.inc.

References $output, drupal_get_form(), drupal_set_title(), LANGUAGE_NONE, name, node_type_get_types(), PASS_THROUGH, and t().

node_add_page ( )

Page callback: Displays add content links for available content types.

Redirects to node/add/[type] if only one content type is available.

See Also
node_menu()

Definition at line 24 of file node.pages.inc.

References $content, drupal_goto(), menu_get_item(), system_admin_menu_block(), and theme().

node_delete_confirm | ( |  | $form,
 |  | & | $form_state,
 |  |  | $node
 | ) |  |

Form constructor for the node deletion confirmation form.

See Also
node_delete_confirm_submit()

Definition at line 523 of file node.pages.inc.

References confirm_form(), and t().

node_delete_confirm_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Executes node deletion.

See Also
node_delete_confirm()

Definition at line 541 of file node.pages.inc.

References cache_clear_all(), drupal_set_message(), node_delete(), node_load(), node_type_get_name(), t(), and watchdog().

node_form_build_preview | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for node_form().

Handles the 'Preview' button on the node form.

See Also
node_form()
node_form_validate()

Definition at line 356 of file node.pages.inc.

References node_form_submit_build_node(), and node_preview().

node_form_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for node_form().

Handles the 'Delete' button on the node form.

See Also
node_form()
node_form_validate()

Definition at line 338 of file node.pages.inc.

References drupal_get_destination().

node_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for node_form().

See Also
node_form()
node_form_validate()

Definition at line 454 of file node.pages.inc.

References cache_clear_all(), drupal_set_message(), l(), node_access(), node_form_submit_build_node(), node_save(), node_type_get_name(), t(), watchdog(), and WATCHDOG_NOTICE.

node_form_submit_build_node | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Updates the form state's node entity by processing this submission's values.

This is the default builder function for the node form. It is called during the "Save" and "Preview" submit handlers to retrieve the entity to save or preview. This function can also be called by a "Next" button of a wizard to update the form state's entity with the current step's values before proceeding to the next step.

See Also
node_form()

Definition at line 496 of file node.pages.inc.

References $module, entity_form_submit_build_entity(), form_execute_handlers(), module_implements(), and node_submit().

Referenced by node_form_build_preview(), and node_form_submit().

node_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for node_form().

See Also
node_form()
node_form_submit()

Definition at line 89 of file node.pages.inc.

References entity_form_field_validate(), and node_validate().

node_page_edit ( $node )

Menu callback; presents the node editing form.

Definition at line 11 of file node.pages.inc.

References drupal_get_form(), drupal_set_title(), node_type_get_name(), PASS_THROUGH, and t().

node_preview ( $node )

Generates a node preview.

Parameters
$node The node to preview.
Returns
An HTML-formatted string of a node preview.
See Also
node_form_build_preview()

Definition at line 373 of file node.pages.inc.

References $output, _field_invoke_multiple(), drupal_set_title(), field_attach_prepare_view(), form_get_errors(), node_access(), PASS_THROUGH, REQUEST_TIME, t(), theme(), user_load(), and user_load_by_name().

Referenced by node_form_build_preview().

node_revision_delete_confirm_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for node_revision_delete_confirm().

Definition at line 668 of file node.pages.inc.

References db_query(), drupal_set_message(), format_date(), node_revision_delete(), node_type_get_name(), t(), and watchdog().

node_revision_overview ( $node )

Generates an overview table of older revisions of a node.

Parameters
$node A node object.
Returns
array An array as expected by drupal_render().
See Also
node_menu()

Definition at line 564 of file node.pages.inc.

References $header, $row, drupal_placeholder(), drupal_set_title(), filter_xss(), format_date(), l(), node_access(), node_revision_list(), PASS_THROUGH, t(), theme(), and user_access().

node_revision_revert_confirm_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for node_revision_revert_confirm().

Definition at line 633 of file node.pages.inc.

References drupal_set_message(), format_date(), node_save(), node_type_get_name(), t(), and watchdog().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/node.tokens.inc File Reference

  • modules
  • node
Functions
node.tokens.inc File Reference

Go to the source code of this file.

Functions

node_token_info ()
node_tokens ($type, $tokens, array $data=array(), array $options=array())

Detailed Description

Builds placeholder replacement tokens for node-related data.

Definition in file node.tokens.inc.

Function Documentation

node_token_info ( )

Implements hook_token_info().

Definition at line 13 of file node.tokens.inc.

References t().

node_tokens | ( |  | $type,
 |  |  | $tokens,
 |  | array | $data = array(),
 |  | array | $options = array()
 | ) |  |

Implements hook_tokens().

Definition at line 92 of file node.tokens.inc.

References $author, $name, _text_sanitize(), check_plain(), entity_language(), field_get_items(), field_info_instance(), field_language(), format_date(), format_username(), node_type_get_name(), token_find_with_prefix(), token_generate(), url(), and user_load().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/openid Directory Reference

  • modules
  • openid
openid Directory Reference

Files

file | openid.api.php [code]
file | openid.inc [code]
file | openid.install [code]
file | openid.module [code]
file | openid.pages.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/openid/openid.api.php File Reference

  • modules
  • openid
Functions
openid.api.php File Reference

Go to the source code of this file.

Functions

hook_openid ($op, $request)
hook_openid_response ($response, $account)
hook_openid_discovery_method_info ()
hook_openid_discovery_method_info_alter (&$methods)
hook_openid_normalization_method_info ()
hook_openid_normalization_method_info_alter (&$methods)

Detailed Description

Hooks provided by the OpenID module.

Definition in file openid.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/openid/openid.inc File Reference

  • modules
  • openid
Functions | Variables
openid.inc File Reference

Go to the source code of this file.

Functions

openid_redirect_http ($url, $message)
openid_redirect ($url, $message)
openid_redirect_form ($form, &$form_state, $url, $message)
_openid_xrds_parse ($raw_xml)
_openid_select_service (array $services)
_openid_is_xri ($identifier)
openid_normalize ($identifier)
_openid_xri_normalize ($identifier)
_openid_url_normalize ($url)
_openid_create_message ($data)
_openid_encode_message ($message)
_openid_parse_message ($message)
_openid_nonce ()
_openid_link_href ($rel, $html)
_openid_meta_httpequiv ($equiv, $html)
_openid_signature ($association, $message_array, $keys_to_sign)
_openid_hmac ($key, $text)
_openid_dh_base64_to_long ($str)
_openid_dh_long_to_base64 ($str)
_openid_dh_binary_to_long ($str)
_openid_dh_long_to_binary ($long)
_openid_dh_xorsecret ($shared, $secret)
_openid_dh_rand ($stop)
_openid_get_bytes ($num_bytes)
_openid_response ($str=NULL)
_openid_get_params ($str)
openid_extract_namespace ($response, $extension_namespace, $fallback_prefix=NULL, $only_signed=FALSE)
openid_extract_ax_values ($values, $uris)
_openid_get_math_library ()
_openid_math_add ($x, $y)
_openid_math_mul ($x, $y)
_openid_math_div ($x, $y)
_openid_math_cmp ($x, $y)
_openid_math_mod ($x, $y)
_openid_math_pow ($x, $y)
_openid_math_powmod ($x, $y, $z)
_openid_invalid_openid_transition ($identity, $response)

Variables

const | OPENID_DH_DEFAULT_MOD '155172898181473697471232257763715539915724801' . '966915404479707795314057629378541917580651227423698188993727816152646631' . '438561595825688188889951272158842675419950341258706556549803580104870537' . '681476726513255747040765857479291291572334510643245094715007229621094194' . '349783925984760375594985848253359305585439638443'
const | OPENID_DH_DEFAULT_GEN '2'
const | OPENID_SHA1_BLOCKSIZE 64
const | OPENID_RAND_SOURCE '/dev/urandom'
const | OPENID_NS_2_0 'http://specs.openid.net/auth/2.0'
const | OPENID_NS_1_1 'http://openid.net/signon/1.1'
const | OPENID_NS_1_0 'http://openid.net/signon/1.0'
const | OPENID_NS_OPENID 'http://openid.net/xmlns/1.0'
const | OPENID_NS_SREG 'http://openid.net/extensions/sreg/1.1'
const | OPENID_NS_AX 'http://openid.net/srv/ax/1.0'
const | OPENID_NS_XRD 'xri://$xrd*($v*2.0)'

Detailed Description

OpenID utility functions.

Definition in file openid.inc.

Function Documentation

_openid_create_message ( $data )

Create a serialized message packet as per spec: $key:$value
.

Definition at line 329 of file openid.inc.

References $value.

Referenced by _openid_signature(), openid_association(), and openid_verify_assertion().

_openid_dh_base64_to_long ( $str )

Definition at line 462 of file openid.inc.

References _openid_dh_binary_to_long().

Referenced by openid_association().

_openid_dh_binary_to_long ( $str )

Definition at line 472 of file openid.inc.

References _openid_math_add(), and _openid_math_mul().

Referenced by _openid_dh_base64_to_long(), and _openid_dh_rand().

_openid_dh_long_to_base64 ( $str )

Definition at line 468 of file openid.inc.

References _openid_dh_long_to_binary().

Referenced by openid_association_request().

_openid_dh_long_to_binary ( $long )

Definition at line 484 of file openid.inc.

References _openid_math_cmp(), _openid_math_div(), and _openid_math_mod().

Referenced by _openid_dh_long_to_base64(), _openid_dh_rand(), and _openid_dh_xorsecret().

_openid_dh_rand ( $stop )

Definition at line 524 of file openid.inc.

References _openid_dh_binary_to_long(), _openid_dh_long_to_binary(), _openid_math_cmp(), _openid_math_mod(), _openid_math_pow(), drupal_random_bytes(), and drupal_static().

Referenced by openid_association().

_openid_dh_xorsecret | ( | $shared,
 |  | $secret
 | ) |

Definition at line 513 of file openid.inc.

References _openid_dh_long_to_binary().

Referenced by openid_association().

_openid_encode_message ( $message )

Encode a message from _openid_create_message for HTTP Post

Definition at line 344 of file openid.inc.

Referenced by openid_association(), and openid_verify_assertion().

_openid_get_bytes ( $num_bytes )

Definition at line 563 of file openid.inc.

References drupal_random_bytes().

_openid_get_math_library ( )

Determine the available math library GMP vs. BCMath, favouring GMP for performance.

Definition at line 714 of file openid.inc.

Referenced by _openid_math_add(), _openid_math_cmp(), _openid_math_div(), _openid_math_mod(), _openid_math_mul(), _openid_math_pow(), _openid_math_powmod(), and openid_begin().

_openid_get_params ( $str )

Definition at line 588 of file openid.inc.

Referenced by _openid_response().

_openid_hmac | ( | $key,
 |  | $text
 | ) |

Definition at line 448 of file openid.inc.

References OPENID_SHA1_BLOCKSIZE.

Referenced by _openid_signature().

_openid_invalid_openid_transition | ( | $identity,
 |  | $response
 | ) |

Provides transition for accounts with possibly invalid OpenID identifiers in authmap.

This function provides a less safe but more unobtrusive procedure for users who cannot login with their OpenID identifiers. OpenID identifiers in the authmap could be incomplete due to invalid OpenID implementation in previous versions of Drupal (e.g. fragment part of the identifier could be missing). For more information see http://drupal.org/node/1120290.

Parameters
string $identity The user's claimed OpenID identifier.
Returns
A fully-loaded user object if the user is found or FALSE if not found.

Definition at line 837 of file openid.inc.

References db_insert(), drupal_set_message(), openid_extract_ax_values(), openid_extract_namespace(), openid_normalize(), OPENID_NS_AX, OPENID_NS_SREG, t(), user_external_load(), and valid_email_address().

Referenced by openid_authentication().

_openid_is_xri ( $identifier )

Determine if the given identifier is an XRI ID.

Definition at line 257 of file openid.inc.

Referenced by _openid_xri_discovery(), and _openid_xri_normalize().

_openid_link_href | ( | $rel,
 |  | $html
 | ) |

Pull the href attribute out of an html link element.

Definition at line 399 of file openid.inc.

Referenced by _openid_xrds_discovery().

_openid_math_add | ( | $x,
 |  | $y
 | ) |

Calls the add function from the available math library for OpenID.

Definition at line 734 of file openid.inc.

References _openid_get_math_library().

Referenced by _openid_dh_binary_to_long(), and openid_association().

_openid_math_cmp | ( | $x,
 |  | $y
 | ) |

Calls the cmp function from the available math library for OpenID.

Definition at line 773 of file openid.inc.

References _openid_get_math_library().

Referenced by _openid_dh_long_to_binary(), and _openid_dh_rand().

_openid_math_div | ( | $x,
 |  | $y
 | ) |

Calls the div function from the available math library for OpenID.

Definition at line 760 of file openid.inc.

References _openid_get_math_library().

Referenced by _openid_dh_long_to_binary().

_openid_math_mod | ( | $x,
 |  | $y
 | ) |

Calls the mod function from the available math library for OpenID.

Definition at line 786 of file openid.inc.

References _openid_get_math_library().

Referenced by _openid_dh_long_to_binary(), and _openid_dh_rand().

_openid_math_mul | ( | $x,
 |  | $y
 | ) |

Calls the mul function from the available math library for OpenID.

Definition at line 747 of file openid.inc.

References _openid_get_math_library().

Referenced by _openid_dh_binary_to_long().

_openid_math_pow | ( | $x,
 |  | $y
 | ) |

Calls the pow function from the available math library for OpenID.

Definition at line 799 of file openid.inc.

References _openid_get_math_library().

Referenced by _openid_dh_rand().

_openid_math_powmod | ( | $x,
 |  | $y,
 |  | $z
 | ) |

Calls the mul function from the available math library for OpenID.

Definition at line 812 of file openid.inc.

References _openid_get_math_library().

Referenced by openid_association().

_openid_meta_httpequiv | ( | $equiv,
 |  | $html
 | ) |

Pull the http-equiv attribute out of an html meta element

Definition at line 412 of file openid.inc.

References $content.

Referenced by _openid_xrds_discovery().

_openid_nonce ( )

Return a nonce value - formatted per OpenID spec.

NOTE: This nonce is not cryptographically secure and only suitable for use by the test framework.

Definition at line 387 of file openid.inc.

_openid_parse_message ( $message )

Convert a direct communication message into an associative array.

Definition at line 366 of file openid.inc.

Referenced by openid_association(), and openid_verify_assertion().

_openid_response ( $str = NULL )

Definition at line 567 of file openid.inc.

References _openid_get_params().

Referenced by openid_complete().

_openid_select_service ( array $services )

Select a service element.

The procedure is described in OpenID Authentication 2.0, section 7.3.2.

A new entry is added to the returned array with the key 'version' and the value 1 or 2 specifying the protocol version used by the service.

Parameters
$services An array of service arrays as returned by openid_discovery().
Returns
The selected service array, or NULL if no valid services were found.

Definition at line 210 of file openid.inc.

References OPENID_NS_1_0, and OPENID_NS_1_1.

Referenced by openid_begin().

_openid_signature | ( | $association,
 |  | $message_array,
 |  | $keys_to_sign
 | ) |

Sign certain keys in a message

Parameters
$association - object loaded from openid_association or openid_server_association table
  • important fields are ->assoc_type and ->mac_key
$message_array | - array of entire message about to be sent
$keys_to_sign | - keys in the message to include in signature (without 'openid.' appended)

Definition at line 431 of file openid.inc.

References _openid_create_message(), and _openid_hmac().

Referenced by openid_verify_assertion_signature().

_openid_url_normalize ( $url )

OpenID normalization method: normalize URL identifiers.

Definition at line 309 of file openid.inc.

References $url.

_openid_xrds_parse ( $raw_xml )

Parse an XRDS document.

Parameters
$raw_xml A string containing the XRDS document.
Returns
An array of service entries.

Definition at line 139 of file openid.inc.

References OPENID_NS_OPENID, and OPENID_NS_XRD.

Referenced by _openid_xrds_discovery().

_openid_xri_normalize ( $identifier )

OpenID normalization method: normalize XRI identifiers.

Definition at line 297 of file openid.inc.

References _openid_is_xri().

openid_extract_ax_values | ( | $values,
 |  | $uris
 | ) |

Extracts values from an OpenID AX Response.

The values can be returned in two forms:

  • only openid.ax.value.<alias> (for single-valued answers)
  • both openid.ax.count.<alias> and openid.ax.value.<alias>.<count> (for both single and multiple-valued answers)
Parameters
$values | An array as returned by openid_extract_namespace(..., OPENID_NS_AX).
$uris | An array of identifier URIs.
Returns
An array of values.
See Also
http://openid.net/specs/openid-attribute-exchange-1_0.html#fetch_response

Definition at line 692 of file openid.inc.

References $output, and $value.

Referenced by _openid_invalid_openid_transition(), and openid_form_user_register_form_alter().

openid_extract_namespace | ( | $response,
 |  | $extension_namespace,
 |  | $fallback_prefix = NULL,
 |  | $only_signed = FALSE
 | ) |

Extract all the parameters belonging to an extension in a response message.

OpenID 2.0 defines a simple extension mechanism, based on a namespace prefix.

Each request or response can define a prefix using:

* openid.ns.[prefix] = [extension_namespace]
* openid.[prefix].[key1] = [value1]
* openid.[prefix].[key2] = [value2]
* ...
*

This function extracts all the keys belonging to an extension namespace in a response, optionally using a fallback prefix if none is provided in the response.

Note that you cannot assume that a given extension namespace will use the same prefix on the response and the request: each party may use a different prefix to refer to the same namespace.

Parameters
$response | The response array.
$extension_namespace | The namespace of the extension.
$fallback_prefix | An optional prefix that will be used in case no prefix is found for the target extension namespace.
$only_signed | Return only keys that are included in the message signature in openid.sig. Unsigned fields may have been modified or added by other parties than the OpenID Provider.
Returns
An associative array containing all the parameters in the response message that belong to the extension. The keys are stripped from their namespace prefix.
See Also
http://openid.net/specs/openid-authentication-2_0.html#extensions

Definition at line 642 of file openid.inc.

References $output, and $value.

Referenced by _openid_invalid_openid_transition(), and openid_form_user_register_form_alter().

openid_normalize ( $identifier )

Normalize the given identifier.

The procedure is described in OpenID Authentication 2.0, section 7.2.

Definition at line 277 of file openid.inc.

References drupal_alter(), and module_invoke_all().

Referenced by _openid_invalid_openid_transition(), _openid_xrds_discovery(), _openid_xri_discovery(), openid_begin(), openid_complete(), and openid_user_add_validate().

openid_redirect | ( | $url,
 |  | $message
 | ) |

Creates a js auto-submit redirect for (for the 2.x protocol)

Definition at line 90 of file openid.inc.

References $output, $url, drupal_exit(), drupal_get_form(), drupal_render(), print, and t().

Referenced by openid_begin().

openid_redirect_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $url,
 |  |  | $message
 | ) |  |

Definition at line 110 of file openid.inc.

References $url, $value, and t().

openid_redirect_http | ( | $url,
 |  | $message
 | ) |

Performs an HTTP 302 redirect (for the 1.x protocol).

Definition at line 75 of file openid.inc.

References $url, and drupal_exit().

Referenced by openid_begin().

Variable Documentation

const OPENID_DH_DEFAULT_GEN '2'

Diffie-Hellman generator; used for Diffie-Hellman key exchange computations.

Definition at line 25 of file openid.inc.

Referenced by openid_association().

const OPENID_DH_DEFAULT_MOD '155172898181473697471232257763715539915724801' . '966915404479707795314057629378541917580651227423698188993727816152646631' . '438561595825688188889951272158842675419950341258706556549803580104870537' . '681476726513255747040765857479291291572334510643245094715007229621094194' . '349783925984760375594985848253359305585439638443'

Diffie-Hellman Key Exchange Default Value.

This is used to establish an association between the Relying Party and the OpenID Provider.

See RFC 2631: http://www.ietf.org/rfc/rfc2631.txt

Definition at line 16 of file openid.inc.

Referenced by openid_association().

const OPENID_NS_1_0 'http://openid.net/signon/1.0'

OpenID Authentication 1.0 namespace URL; used for backwards-compatibility.

Definition at line 50 of file openid.inc.

Referenced by _openid_select_service().

const OPENID_NS_1_1 'http://openid.net/signon/1.1'

OpenID Authentication 1.1 namespace URL; used for backwards-compatibility.

Definition at line 45 of file openid.inc.

Referenced by _openid_select_service().

const OPENID_NS_2_0 'http://specs.openid.net/auth/2.0'

OpenID Authentication 2.0 namespace URL.

Definition at line 40 of file openid.inc.

Referenced by openid_association_request(), and openid_authentication_request().

const OPENID_NS_AX 'http://openid.net/srv/ax/1.0'

OpenID Attribute Exchange extension.

Definition at line 65 of file openid.inc.

Referenced by _openid_invalid_openid_transition(), openid_authentication_request(), and openid_form_user_register_form_alter().

const OPENID_NS_OPENID 'http://openid.net/xmlns/1.0'

OpenID namespace used in Yadis documents.

Definition at line 55 of file openid.inc.

Referenced by _openid_xrds_parse().

const OPENID_NS_SREG 'http://openid.net/extensions/sreg/1.1'

OpenID Simple Registration extension.

Definition at line 60 of file openid.inc.

Referenced by _openid_invalid_openid_transition(), openid_authentication_request(), and openid_form_user_register_form_alter().

const OPENID_NS_XRD 'xri://$xrd*($v*2.0)'

Extensible Resource Descriptor documents.

Definition at line 70 of file openid.inc.

Referenced by _openid_xrds_parse(), and _openid_xri_discovery().

const OPENID_RAND_SOURCE '/dev/urandom'

Random number generator; used for Diffie-Hellman key exchange computations.

Definition at line 35 of file openid.inc.

const OPENID_SHA1_BLOCKSIZE 64

SHA-1 hash block size; used for Diffie-Hellman key exchange computations.

Definition at line 30 of file openid.inc.

Referenced by _openid_hmac().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/openid/openid.install File Reference

  • modules
  • openid
Functions
openid.install File Reference

Go to the source code of this file.

Functions

openid_schema ()
openid_requirements ($phase)
openid_update_6000 ()
openid_update_7000 ()

Detailed Description

Install, update and uninstall functions for the openid module.

Definition in file openid.install.

Function Documentation

openid_requirements ( $phase )

Implements hook_requirements().

Definition at line 93 of file openid.install.

References REQUIREMENT_ERROR, REQUIREMENT_OK, REQUIREMENT_WARNING, and t().

openid_schema ( )

Implements hook_schema().

Definition at line 11 of file openid.install.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/openid/openid.module File Reference

  • modules
  • openid
Functions
openid.module File Reference

Go to the source code of this file.

Functions

openid_menu ()
openid_menu_site_status_alter (&$menu_site_status, $path)
openid_admin_paths ()
openid_help ($path, $arg)
openid_user_insert (&$edit, $account, $category)
openid_user_login (&$edit, $account)
openid_user_logout ($account)
openid_form_user_login_block_alter (&$form, &$form_state)
openid_form_user_login_alter (&$form, &$form_state)
_openid_user_login_form_alter (&$form, &$form_state)
openid_form_user_register_form_alter (&$form, &$form_state)
openid_login_validate ($form, &$form_state)
openid_begin ($claimed_id, $return_to= '', $form_values=array())
openid_complete ($response=array())
openid_discovery ($claimed_id)
openid_openid_discovery_method_info ()
_openid_xri_discovery ($claimed_id)
_openid_xrds_discovery ($claimed_id)
openid_openid_normalization_method_info ()
openid_association ($op_endpoint)
openid_authentication ($response)
openid_association_request ($public)
openid_authentication_request ($claimed_id, $identity, $return_to= '', $assoc_handle= '', $service)
openid_verify_assertion ($service, $response)
openid_verify_assertion_signature ($service, $association, $response)
openid_verify_assertion_nonce ($service, $response)
openid_verify_assertion_return_url ($service, $response)
openid_cron ()

Detailed Description

Implement OpenID Relying Party support for Drupal

Definition in file openid.module.

Function Documentation

_openid_user_login_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 136 of file openid.module.

References drupal_get_path(), l(), t(), url(), and user_login_destination().

Referenced by openid_form_user_login_alter(), and openid_form_user_login_block_alter().

_openid_xrds_discovery ( $claimed_id )

OpenID discovery method: perform a XRDS discovery.

See Also
http://openid.net/specs/openid-authentication-2_0.html#discovery
hook_openid_discovery_method_info()
openid_discovery()
Returns
An array of discovered services and claimed identifier or NULL. See openid_discovery() for more specific information.

Definition at line 492 of file openid.module.

References _openid_link_href(), _openid_meta_httpequiv(), _openid_xrds_parse(), drupal_http_request(), and openid_normalize().

Referenced by _openid_xri_discovery().

_openid_xri_discovery ( $claimed_id )

OpenID discovery method: perform an XRI discovery.

See Also
http://openid.net/specs/openid-authentication-2_0.html#discovery
hook_openid_discovery_method_info()
openid_discovery()
Returns
An array of discovered services and claimed identifier or NULL. See openid_discovery() for more specific information.

Definition at line 457 of file openid.module.

References _openid_is_xri(), _openid_xrds_discovery(), openid_normalize(), OPENID_NS_XRD, and variable_get().

openid_admin_paths ( )

Implements hook_admin_paths().

Definition at line 52 of file openid.module.

openid_association ( $op_endpoint )

Attempt to create a shared secret with the OpenID Provider.

Parameters
$op_endpoint URL of the OpenID Provider endpoint.
Returns
$assoc_handle The association handle.

Definition at line 590 of file openid.module.

References _openid_create_message(), _openid_dh_base64_to_long(), _openid_dh_rand(), _openid_dh_xorsecret(), _openid_encode_message(), _openid_math_add(), _openid_math_powmod(), _openid_parse_message(), db_delete(), db_insert(), db_query(), drupal_http_request(), module_load_include(), openid_association_request(), OPENID_DH_DEFAULT_GEN, OPENID_DH_DEFAULT_MOD, and REQUEST_TIME.

Referenced by openid_begin().

openid_association_request ( $public )

Definition at line 722 of file openid.module.

References _openid_dh_long_to_base64(), module_load_include(), and OPENID_NS_2_0.

Referenced by openid_association().

openid_authentication ( $response )

Authenticate a user or attempt registration.

Parameters
$response Response values from the OpenID Provider.

Definition at line 652 of file openid.module.

References $messages, _openid_invalid_openid_transition(), drupal_form_submit(), drupal_get_destination(), drupal_get_messages(), drupal_goto(), drupal_set_message(), form_get_errors(), module_invoke_all(), module_load_include(), t(), url(), user_external_load(), user_login_name_validate(), user_login_submit(), USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, and variable_get().

Referenced by openid_authentication_page().

openid_authentication_request | ( | $claimed_id,
 |  | $identity,
 |  | $return_to = '',
 |  | $assoc_handle = '',
 |  | $service
 | ) |

Definition at line 740 of file openid.module.

References $base_url, $value, module_invoke_all(), module_load_include(), OPENID_NS_2_0, OPENID_NS_AX, and OPENID_NS_SREG.

Referenced by openid_begin().

openid_begin | ( | $claimed_id,
 |  | $return_to = '',
 |  | $form_values = array()
 | ) |

The initial step of OpenID authentication responsible for the following:

  • Perform discovery on the claimed OpenID.
  • If possible, create an association with the Provider's endpoint.
  • Create the authentication request.
  • Perform the appropriate redirect.
Parameters
$claimed_id | The OpenID to authenticate
$return_to | The endpoint to return to from the OpenID Provider

Definition at line 261 of file openid.module.

References _openid_get_math_library(), _openid_select_service(), form_set_error(), module_load_include(), openid_association(), openid_authentication_request(), openid_discovery(), openid_normalize(), openid_redirect(), openid_redirect_http(), and t().

Referenced by openid_login_validate(), and openid_user_add_submit().

openid_complete ( $response = array() )

Completes OpenID authentication by validating returned data from the OpenID Provider.

Parameters
$response Array of returned values from the OpenID Provider.
Returns
$response Response values for further processing with $response['status'] set to one of 'success', 'failed' or 'cancel'.

Definition at line 328 of file openid.module.

References _openid_response(), module_load_include(), openid_discovery(), openid_normalize(), and openid_verify_assertion().

Referenced by openid_authentication_page(), and openid_user_identities().

openid_cron ( )

Remove expired nonces from the database.

Implements hook_cron().

Definition at line 1030 of file openid.module.

References db_delete(), and REQUEST_TIME.

openid_discovery ( $claimed_id )

Perform discovery on a claimed ID to determine the OpenID provider endpoint.

Discovery methods are provided by the hook_openid_discovery_method_info and could be further altered using the hook_openid_discovery_method_info_alter.

Parameters
$claimed_id The OpenID URL to perform discovery on.
Returns
The resulting discovery array from the first successful discovery method, which must contain following keys:
  • 'services' (required) an array of discovered services (including OpenID version, endpoint URI, etc).
  • 'claimed_id' (optional) new claimed identifer, found by following HTTP redirects during the services discovery. If all the discovery method fails or if no appropriate discovery method is found, FALSE is returned.

Definition at line 413 of file openid.module.

References drupal_alter(), module_invoke_all(), and module_load_include().

Referenced by openid_begin(), and openid_complete().

openid_form_user_login_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 132 of file openid.module.

References _openid_user_login_form_alter().

openid_form_user_login_block_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 125 of file openid.module.

References _openid_user_login_form_alter().

openid_form_user_register_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Prefills the login form with values acquired via OpenID.

Definition at line 182 of file openid.module.

References check_plain(), module_load_include(), openid_extract_ax_values(), openid_extract_namespace(), OPENID_NS_AX, OPENID_NS_SREG, t(), user_password(), and variable_get().

openid_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 63 of file openid.module.

References $output, and t().

openid_login_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Login form _validate hook

Definition at line 242 of file openid.module.

References openid_begin(), and url().

openid_menu ( )

Implements hook_menu().

Definition at line 11 of file openid.module.

References MENU_CALLBACK, and MENU_LOCAL_TASK.

openid_menu_site_status_alter | ( | & | $menu_site_status,
 |  |  | $path
 | ) |  |

Implements hook_menu_site_status_alter().

Definition at line 42 of file openid.module.

References MENU_SITE_OFFLINE, MENU_SITE_ONLINE, and user_is_anonymous().

openid_openid_discovery_method_info ( )

Implements hook_openid_discovery_method_info().

Define standard discovery methods.

Definition at line 435 of file openid.module.

openid_openid_normalization_method_info ( )

Implements hook_openid_normalization_method_info().

Define standard normalization methods.

Definition at line 573 of file openid.module.

openid_user_insert | ( | & | $edit,
 |  |  | $account,
 |  |  | $category
 | ) |  |

Implements hook_user_insert().

Definition at line 86 of file openid.module.

References drupal_set_message(), t(), user_set_authmaps(), and variable_get().

openid_user_login | ( | & | $edit,
 |  |  | $account
 | ) |  |

Implements hook_user_login().

Save openid_identifier to visitor cookie.

Definition at line 103 of file openid.module.

References user_cookie_save().

openid_user_logout ( $account )

Implements hook_user_logout().

Delete any openid_identifier in visitor cookie.

Definition at line 116 of file openid.module.

References user_cookie_delete().

openid_verify_assertion | ( | $service,
 |  | $response
 | ) |

Attempt to verify the response received from the OpenID Provider.

Parameters
$service | Array describing the OpenID provider.
$response | Array of response values from the provider.
Returns
boolean
See Also
http://openid.net/specs/openid-authentication-2_0.html#rfc.section.11.4

Definition at line 818 of file openid.module.

References _openid_create_message(), _openid_encode_message(), _openid_parse_message(), db_delete(), db_query(), drupal_http_request(), module_load_include(), openid_verify_assertion_nonce(), openid_verify_assertion_return_url(), and openid_verify_assertion_signature().

Referenced by openid_complete().

openid_verify_assertion_nonce | ( | $service,
 |  | $response
 | ) |

Verify that the nonce has not been used in earlier assertions from the same OpenID provider.

Parameters
$service | Array describing the OpenID provider.
$response | Array of response values from the provider.
Returns
TRUE if the nonce has not expired and has not been used earlier.

Definition at line 939 of file openid.module.

References db_insert(), db_query(), ip_address(), watchdog(), WATCHDOG_CRITICAL, and WATCHDOG_WARNING.

Referenced by openid_verify_assertion().

openid_verify_assertion_return_url | ( | $service,
 |  | $response
 | ) |

Verify that openid.return_to matches the current URL.

See OpenID Authentication 2.0, section 11.1. While OpenID Authentication 1.1, section 4.3 does not mandate return_to verification, the received return_to should still match these constraints.

Parameters
$service | Array describing the OpenID provider.
$response | Array of response values from the provider.
Returns
TRUE if return_to is valid, FALSE otherwise.

Definition at line 1002 of file openid.module.

References $base_url, $name, $value, and request_uri().

Referenced by openid_verify_assertion().

openid_verify_assertion_signature | ( | $service,
 |  | $association,
 |  | $response
 | ) |

Verify the signature of the response received from the OpenID provider.

Parameters
$service | Array describing the OpenID provider.
$association | Information on the association with the OpenID provider.
$response | Array of response values from the provider.
Returns
TRUE if the signature is valid and covers all fields required to be signed.
See Also
http://openid.net/specs/openid-authentication-2_0.html#rfc.section.11.4

Definition at line 902 of file openid.module.

References _openid_signature().

Referenced by openid_verify_assertion().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/openid/openid.pages.inc File Reference

  • modules
  • openid
Functions
openid.pages.inc File Reference

Go to the source code of this file.

Functions

openid_authentication_page ()
openid_user_identities ($account)
openid_user_add ()
openid_user_add_validate ($form, &$form_state)
openid_user_add_submit ($form, &$form_state)
openid_user_delete_form ($form, $form_state, $account, $aid=0)
openid_user_delete_form_submit ($form, &$form_state)

Detailed Description

User page callbacks for the openid module.

Definition in file openid.pages.inc.

Function Documentation

openid_authentication_page ( )

Menu callback; Process an OpenID authentication.

Definition at line 11 of file openid.pages.inc.

References drupal_goto(), drupal_set_message(), openid_authentication(), openid_complete(), and t().

openid_user_add_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 89 of file openid.pages.inc.

References arg(), openid_begin(), and url().

openid_user_add_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 81 of file openid.pages.inc.

References db_query(), form_set_error(), openid_normalize(), and t().

openid_user_delete_form | ( | $form,
 |  | $form_state,
 |  | $account,
 |  | $aid = 0
 | ) |

Menu callback; Delete the specified OpenID identity from the system.

Definition at line 97 of file openid.pages.inc.

References confirm_form(), db_query(), and t().

openid_user_delete_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 106 of file openid.pages.inc.

References db_delete(), drupal_set_message(), and t().

openid_user_identities ( $account )

Menu callback; Manage OpenID identities for the specified user.

Definition at line 29 of file openid.pages.inc.

References $header, check_plain(), db_insert(), db_query(), drupal_add_css(), drupal_get_form(), drupal_get_path(), drupal_set_message(), drupal_set_title(), format_username(), l(), openid_complete(), and t().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/overlay Directory Reference

  • modules
  • overlay
overlay Directory Reference

Files

file | overlay.api.php [code]
file | overlay.install [code]
file | overlay.module [code]
file | overlay.tpl.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/overlay/overlay.api.php File Reference

  • modules
  • overlay
Functions
overlay.api.php File Reference

Go to the source code of this file.

Functions

hook_overlay_parent_initialize ()
hook_overlay_child_initialize ()

Detailed Description

Hooks provided by Overlay module.

Definition in file overlay.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/overlay/overlay.install File Reference

  • modules
  • overlay
Functions
overlay.install File Reference

Go to the source code of this file.

Functions

overlay_enable ()

Detailed Description

Install, update, and uninstall functions for the Overlay module.

Definition in file overlay.install.

Function Documentation

overlay_enable ( )

Implements hook_enable().

If the module is being enabled through the admin UI, and not from an installation profile, reopen the modules page in an overlay.

Definition at line 14 of file overlay.install.

References current_path().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/overlay/overlay.module File Reference

  • modules
  • overlay
Functions
overlay.module File Reference

Go to the source code of this file.

Functions

overlay_help ($path, $arg)
overlay_menu ()
overlay_admin_paths ()
overlay_permission ()
overlay_theme ()
overlay_form_user_profile_form_alter (&$form, &$form_state)
overlay_user_presave (&$edit, $account, $category)
overlay_init ()
overlay_exit ()
overlay_library ()
overlay_drupal_goto_alter (&$path, &$options, &$http_response_code)
overlay_batch_alter (&$batch)
overlay_page_alter (&$page)
overlay_user_dismiss_message ()
overlay_disable_message ()
theme_overlay_disable_message ($variables)
overlay_block_list_alter (&$blocks)
overlay_system_info_alter (&$info, $file, $type)
overlay_preprocess_html (&$variables)
overlay_preprocess_maintenance_page (&$variables)
template_preprocess_overlay (&$variables)
template_process_overlay (&$variables)
overlay_preprocess_page (&$variables)
overlay_display_empty_page ($value=NULL)
overlay_page_delivery_callback_alter (&$callback)
overlay_deliver_empty_page ()
overlay_get_mode ()
overlay_set_mode ($mode=NULL)
overlay_overlay_parent_initialize ()
overlay_overlay_child_initialize ()
overlay_close_dialog ($redirect=NULL, $redirect_options=array())
overlay_regions ()
overlay_supplemental_regions ()
_overlay_region_list ($type)
overlay_get_regions_to_render ()
overlay_set_regions_to_render ($regions=NULL)
overlay_render_region ($region)
overlay_get_rendered_content ()
overlay_store_rendered_content ($id=NULL, $content=NULL)
overlay_request_refresh ($region)
overlay_request_page_refresh ()
overlay_trigger_refresh ()
overlay_ajax_render_region ($region)

Detailed Description

Displays the Drupal administration interface in an overlay.

Definition in file overlay.module.

Function Documentation

_overlay_region_list ( $type )

Returns a list of page regions related to the overlay.

Parameters
$type The type of regions to return. This can either be 'overlay_regions' or 'overlay_supplemental_regions'.
Returns
An array of region names of the given type, within the theme that is being used to display the current page.
See Also
overlay_regions()
overlay_supplemental_regions()

Definition at line 794 of file overlay.module.

References drupal_theme_initialize(), and list_themes().

Referenced by overlay_regions(), and overlay_supplemental_regions().

overlay_admin_paths ( )

Implements hook_admin_paths().

Definition at line 44 of file overlay.module.

overlay_ajax_render_region ( $region )

Prints the markup obtained by rendering a single region of the page.

This function is intended to be called via Ajax.

Parameters
$region The name of the page region to render.
See Also
Drupal.overlay.refreshRegions()

Definition at line 1008 of file overlay.module.

References overlay_render_region(), and print.

overlay_batch_alter ( & $batch )

Implements hook_batch_alter().

If the current page request is inside the overlay, add ?render=overlay to the success callback URL, so that it appears correctly within the overlay.

See Also
overlay_get_mode()

Definition at line 274 of file overlay.module.

References overlay_get_mode().

overlay_block_list_alter ( & $blocks )

Implements hook_block_list_alter().

Definition at line 435 of file overlay.module.

References overlay_get_regions_to_render().

overlay_close_dialog | ( | $redirect = NULL,
 |  | $redirect_options = array()
 | ) |

Requests that the overlay closes when the page is displayed.

Parameters
$redirect | (optional) The path that should open in the parent window after the overlay closes. If not set, no redirect will be performed on the parent window.
$redirect_options | (optional) An associative array of options to use when generating the redirect URL.

Definition at line 722 of file overlay.module.

References drupal_add_js(), overlay_display_empty_page(), and url().

Referenced by overlay_init().

overlay_deliver_empty_page ( )

Prints an empty page.

This function is used to print out a bare minimum empty page which still has the scripts and styles necessary in order to trigger the overlay to close.

Definition at line 578 of file overlay.module.

References drupal_exit(), drupal_get_css(), drupal_get_js(), and print.

overlay_disable_message ( )

Returns a renderable array representing a message for disabling the overlay.

If the current user can access the overlay and has not previously indicated that this message should be dismissed, this function returns a message containing a link to disable the overlay. Nothing is returned for anonymous users, because the links control per-user settings. Because some screen readers are unable to properly read overlay contents, site builders are discouraged from granting the "access overlay" permission to the anonymous role.

See Also
http://drupal.org/node/890284

Definition at line 344 of file overlay.module.

References drupal_get_destination(), drupal_get_token(), overlay_get_mode(), t(), and user_access().

Referenced by overlay_page_alter(), and template_preprocess_overlay().

overlay_display_empty_page ( $value = NULL )

Stores and returns whether an empty page override is needed.

This is used to prevent a page request which closes the overlay (for example, a form submission) from being fully re-rendered before the overlay is closed. Instead, we store a variable which will cause the page to be rendered by a delivery callback function that does not actually print visible HTML (but rather only the bare minimum scripts and styles necessary to trigger the overlay to close), thereby allowing the dialog to be closed faster and with less interruption, and also allowing the display of messages to be deferred to the parent window (rather than displaying them in the child window, which will close before the user has had a chance to read them).

Parameters
$value By default, an empty page will not be displayed. Set to TRUE to request an empty page display, or FALSE to disable the empty page display (if it was previously enabled on this page request).
Returns
TRUE if the current behavior is to display an empty page, or FALSE if not.
See Also
overlay_page_delivery_callback_alter()

Definition at line 555 of file overlay.module.

References $value, and drupal_static().

Referenced by overlay_close_dialog(), and overlay_page_delivery_callback_alter().

overlay_drupal_goto_alter | ( | & | $path,
 |  | & | $options,
 |  | & | $http_response_code
 | ) |  |

Implements hook_drupal_goto_alter().

Definition at line 241 of file overlay.module.

References current_path(), drupal_get_query_parameters(), overlay_get_mode(), system_authorized_batch_processing_url(), and system_authorized_get_url().

overlay_exit ( )

Implements hook_exit().

When viewing an overlay child page, check if we need to trigger a refresh of the supplemental regions of the overlay on the next page request.

Definition at line 176 of file overlay.module.

References overlay_get_mode(), overlay_get_rendered_content(), overlay_render_region(), overlay_request_refresh(), and overlay_supplemental_regions().

overlay_form_user_profile_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 84 of file overlay.module.

References t(), and user_access().

overlay_get_mode ( )

Gets the current overlay mode.

See Also
overlay_set_mode()

Definition at line 589 of file overlay.module.

References overlay_set_mode().

Referenced by hook_batch_alter(), overlay_batch_alter(), overlay_disable_message(), overlay_drupal_goto_alter(), overlay_exit(), overlay_init(), overlay_page_alter(), overlay_preprocess_html(), overlay_preprocess_page(), and theme_overlay_disable_message().

overlay_get_regions_to_render ( )

Returns a list of page regions that rendering should be limited to.

Returns
An array containing the names of the regions that will be rendered when drupal_render_page() is called. If empty, then no limits will be imposed, and all regions of the page will be rendered.
See Also
overlay_page_alter()
overlay_block_list_alter()
overlay_set_regions_to_render()

Definition at line 817 of file overlay.module.

References overlay_set_regions_to_render().

Referenced by overlay_block_list_alter(), and overlay_page_alter().

overlay_get_rendered_content ( )

Returns any rendered content that was stored earlier in the page request.

Returns
An array of all rendered HTML that was stored earlier in the page request, keyed by the identifier with which it was stored. If no content was stored, an empty array is returned.
See Also
overlay_store_rendered_content()

Definition at line 914 of file overlay.module.

References overlay_store_rendered_content().

Referenced by overlay_exit().

overlay_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file overlay.module.

References $output, and t().

overlay_init ( )

Implements hook_init().

Determine whether the current page request is destined to appear in the parent window or in the overlay window, and format the page accordingly.

See Also
overlay_set_mode()

Definition at line 122 of file overlay.module.

References current_path(), drupal_get_query_parameters(), drupal_goto(), overlay_close_dialog(), overlay_get_mode(), overlay_set_mode(), path_is_admin(), url_is_external(), and user_access().

overlay_library ( )

Implements hook_library().

Definition at line 203 of file overlay.module.

References drupal_get_path().

overlay_menu ( )

Implements hook_menu().

Definition at line 24 of file overlay.module.

References MENU_CALLBACK.

overlay_overlay_child_initialize ( )

Implements hook_overlay_child_initialize().

Definition at line 685 of file overlay.module.

References overlay_regions(), overlay_render_region(), overlay_request_page_refresh(), overlay_set_regions_to_render(), overlay_store_rendered_content(), overlay_supplemental_regions(), and overlay_trigger_refresh().

overlay_overlay_parent_initialize ( )

Implements hook_overlay_parent_initialize().

Definition at line 657 of file overlay.module.

References drupal_add_js(), language_list(), LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX, module_exists(), path_get_admin_paths(), and variable_get().

overlay_page_alter ( & $page )

Implements hook_page_alter().

Definition at line 288 of file overlay.module.

References $page, element_children(), overlay_disable_message(), overlay_get_mode(), and overlay_get_regions_to_render().

overlay_page_delivery_callback_alter ( & $callback )

Implements hook_page_delivery_callback_alter().

Definition at line 566 of file overlay.module.

References overlay_display_empty_page().

overlay_permission ( )

Implements hook_permission().

Definition at line 57 of file overlay.module.

References t().

overlay_preprocess_html ( & $variables )

Implements hook_preprocess_html().

If the current page request is inside the overlay, add appropriate classes to the <body> element, and simplify the page title.

See Also
overlay_get_mode()

Definition at line 471 of file overlay.module.

References overlay_get_mode().

Referenced by overlay_preprocess_maintenance_page().

overlay_preprocess_maintenance_page ( & $variables )

Implements hook_preprocess_maintenance_page().

If the current page request is inside the overlay, add appropriate classes to the <body> element, and simplify the page title.

See Also
overlay_preprocess_maintenance_page()

Definition at line 486 of file overlay.module.

References overlay_preprocess_html().

overlay_preprocess_page ( & $variables )

Implements hook_preprocess_page().

If the current page request is inside the overlay, hide the tabs.

See Also
overlay_get_mode()

Definition at line 525 of file overlay.module.

References overlay_get_mode().

overlay_regions ( )

Returns a list of page regions that appear in the overlay.

Overlay regions correspond to the entire contents of the overlay child window and are refreshed each time a new page request is made within the overlay.

Returns
An array of region names that correspond to those which appear in the overlay, within the theme that is being used to display the current page.
See Also
overlay_supplemental_regions()

Definition at line 754 of file overlay.module.

References _overlay_region_list().

Referenced by overlay_overlay_child_initialize().

overlay_render_region ( $region )

Renders an individual page region.

This function is primarily intended to be used for checking the content of supplemental overlay regions (e.g., a region containing a toolbar). Passing in a region that is intended to display the main page content is not supported; the region will be rendered by this function, but the main page content will not appear in it. In addition, although this function returns the rendered HTML for the provided region, it does not place it on the final page, nor add any of its associated JavaScript or CSS to the page.

Parameters
$region The name of the page region that should be rendered.
Returns
The rendered HTML of the provided region.

Definition at line 864 of file overlay.module.

References $page, drupal_add_css(), drupal_add_js(), drupal_render_page(), drupal_static(), and overlay_set_regions_to_render().

Referenced by overlay_ajax_render_region(), overlay_exit(), and overlay_overlay_child_initialize().

overlay_request_page_refresh ( )

Requests that the entire parent window is reloaded when the overlay closes.

See Also
overlay_trigger_refresh()

Definition at line 966 of file overlay.module.

Referenced by overlay_overlay_child_initialize().

overlay_request_refresh ( $region )

Requests that the parent window refreshes a particular page region.

Parameters
$region The name of the page region to refresh. The parent window will trigger a refresh of this region on the next page load.
See Also
overlay_trigger_refresh()
Drupal.overlay.refreshRegions()

Definition at line 956 of file overlay.module.

References drupal_region_class().

Referenced by overlay_exit().

overlay_set_mode ( $mode = NULL )

Sets the overlay mode and adds proper JavaScript and styles to the page.

Note that since setting the overlay mode triggers a variety of behaviors (including hooks being invoked), it can only be done once per page request. Therefore, the first call to this function which passes along a value of the $mode parameter controls the overlay mode that will be used.

Parameters
$mode To set the mode, pass in one of the following values:
  • 'parent': This is used in the context of a parent window (a regular browser window). If set, JavaScript is added so that administrative links in the parent window will open in an overlay.
  • 'child': This is used in the context of the child overlay window (the page actually appearing within the overlay iframe). If set, JavaScript and CSS are added so that Drupal behaves nicely from within the overlay.
  • 'none': This is used to avoid adding any overlay-related code to the page at all. Modules can set this to explicitly prevent the overlay from being used. For example, since the overlay module itself sets the mode to 'parent' or 'child' in overlay_init() when certain conditions are met, other modules which want to override that behavior can do so by setting the mode to 'none' earlier in the page request - e.g., in their own hook_init() implementations, if they have a lower weight. This parameter is optional, and if omitted, the current mode will be returned with no action taken.
Returns
The current mode, if any has been set, or NULL if no mode has been set.
See Also
overlay_init()

Definition at line 625 of file overlay.module.

References drupal_add_library(), drupal_static(), and module_invoke_all().

Referenced by overlay_get_mode(), and overlay_init().

overlay_set_regions_to_render ( $regions = NULL )

Sets the regions of the page that rendering will be limited to.

Parameters
$regions (Optional) An array containing the names of the regions that should be rendered when drupal_render_page() is called. Pass in an empty array to remove all limits and cause drupal_render_page() to render all page regions (the default behavior). If this parameter is omitted, no change will be made to the current list of regions to render.
Returns
The current list of regions to render, or an empty array if the regions are not being limited.
See Also
overlay_page_alter()
overlay_block_list_alter()
overlay_get_regions_to_render()

Definition at line 839 of file overlay.module.

References drupal_static().

Referenced by overlay_get_regions_to_render(), overlay_overlay_child_initialize(), and overlay_render_region().

overlay_store_rendered_content | ( | $id = NULL,
 |  | $content = NULL
 | ) |

Stores strings representing rendered HTML content.

This function is used to keep a static cache of rendered content that can be referred to later in the page request.

Parameters
$id | (Optional) An identifier for the content which is being stored, which will be used as an array key in the returned array. If omitted, no change will be made to the current stored data.
$content | (Optional) A string representing the rendered data to store. This only has an effect if $id is also provided.
Returns
An array representing all data that is currently being stored, or an empty array if there is none.
See Also
overlay_get_rendered_content()

Definition at line 938 of file overlay.module.

References $content, and drupal_static().

Referenced by overlay_get_rendered_content(), and overlay_overlay_child_initialize().

overlay_supplemental_regions ( )

Returns a list of supplemental page regions for the overlay.

Supplemental overlay regions are those which are technically part of the parent window, but appear to the user as being related to the overlay (usually because they are displayed next to, rather than underneath, the main overlay regions) and therefore need to be dynamically refreshed if any administrative actions taken within the overlay change their contents.

An example of a typical overlay supplemental region would be the 'page_top' region, in the case where a toolbar is being displayed there.

Returns
An array of region names that correspond to supplemental overlay regions, within the theme that is being used to display the current page.
See Also
overlay_regions()

Definition at line 776 of file overlay.module.

References _overlay_region_list().

Referenced by overlay_exit(), and overlay_overlay_child_initialize().

overlay_system_info_alter | ( | & | $info,
 |  |  | $file,
 |  |  | $type
 | ) |  |

Implements hook_system_info_alter().

Add default regions for the overlay.

Definition at line 456 of file overlay.module.

References $info.

overlay_theme ( )

Implements hook_theme().

Definition at line 69 of file overlay.module.

overlay_trigger_refresh ( )

Checks if the parent window needs to be refreshed on this page load.

If the previous page load requested that any page regions be refreshed, or if it requested that the entire page be refreshed when the overlay closes, pass that request via JavaScript to the child window, so it can in turn pass the request to the parent window.

See Also
overlay_request_refresh()
overlay_request_page_refresh()
Drupal.overlay.refreshRegions()

Definition at line 982 of file overlay.module.

References drupal_add_js().

Referenced by overlay_overlay_child_initialize().

overlay_user_dismiss_message ( )

Page callback: Dismisses the overlay accessibility message for this user.

Returns
A render array for a page containing a list of content.

Definition at line 314 of file overlay.module.

References drupal_goto(), drupal_set_message(), drupal_valid_token(), MENU_ACCESS_DENIED, t(), user_load(), and user_save().

overlay_user_presave | ( | & | $edit,
 |  |  | $account,
 |  |  | $category
 | ) |  |

Implements hook_user_presave().

Definition at line 108 of file overlay.module.

template_preprocess_overlay ( & $variables )

Implements template_preprocess_HOOK() for overlay.tpl.php

If the current page request is inside the overlay, add appropriate classes to the <body> element, and simplify the page title.

See Also
template_process_overlay()
overlay.tpl.php

Definition at line 499 of file overlay.module.

References drupal_get_title(), menu_primary_local_tasks(), and overlay_disable_message().

template_process_overlay ( & $variables )

Implements template_process_HOOK() for overlay.tpl.php

Places the rendered HTML for the page body into a top level variable.

See Also
template_preprocess_overlay()
overlay.tpl.php

Definition at line 514 of file overlay.module.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/path Directory Reference

  • modules
  • path
path Directory Reference

Files

file | path.admin.inc [code]
file | path.api.php [code]
file | path.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/path/path.admin.inc File Reference

  • modules
  • path
Functions
path.admin.inc File Reference

Go to the source code of this file.

Functions

path_admin_overview ($keys=NULL)
path_admin_edit ($path=array())
path_admin_form ($form, &$form_state, $path=array('source'=> '', 'alias'=> '', 'language'=> LANGUAGE_NONE, 'pid'=> NULL))
path_admin_form_delete_submit ($form, &$form_state)
path_admin_form_validate ($form, &$form_state)
path_admin_form_submit ($form, &$form_state)
path_admin_delete_confirm ($form, &$form_state, $path)
path_admin_delete_confirm_submit ($form, &$form_state)
path_admin_filter_form ($form, &$form_state, $keys= '')
path_admin_filter_form_submit_filter ($form, &$form_state)
path_admin_filter_form_submit_reset ($form, &$form_state)

Detailed Description

Administrative page callbacks for the path module.

Definition in file path.admin.inc.

Function Documentation

path_admin_delete_confirm | ( |  | $form,
 |  | & | $form_state,
 |  |  | $path
 | ) |  |

Form constructor for the path deletion form.

Parameters
$path The path alias that will be deleted.
See Also
path_admin_delete_confirm_submit()

Definition at line 239 of file path.admin.inc.

References confirm_form(), t(), and user_access().

path_admin_delete_confirm_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for path_admin_delete_confirm().

Definition at line 255 of file path.admin.inc.

References path_delete().

path_admin_edit ( $path = array() )

Page callback: Returns a form creating or editing a path alias.

Parameters
$path An array containing the path ID, source, alias, and language code.
Returns
A form for adding or editing a URL alias.
See Also
path_menu()

Definition at line 100 of file path.admin.inc.

References $output, drupal_get_form(), and drupal_set_title().

path_admin_filter_form_submit_filter | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for the path_admin_filter_form() Filter button.

See Also
path_admin_filter_form_submit_reset()

Definition at line 303 of file path.admin.inc.

path_admin_filter_form_submit_reset | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for the path_admin_filter_form() Reset button.

See Also
path_admin_filter_form_submit_filter()

Definition at line 312 of file path.admin.inc.

path_admin_form_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for the 'Delete' button on path_admin_form().

See Also
path_admin_form_validate()
path_admin_form_submit()

Definition at line 177 of file path.admin.inc.

References drupal_get_destination().

path_admin_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for path_admin_form().

See Also
path_admin_form_validate()
path_admin_form_delete_submit()

Definition at line 221 of file path.admin.inc.

References drupal_set_message(), form_state_values_clean(), path_save(), and t().

path_admin_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for path_admin_form().

See Also
path_admin_form_submit()
path_admin_form_delete_submit()

Definition at line 192 of file path.admin.inc.

References db_query(), drupal_get_normal_path(), drupal_valid_path(), form_set_error(), LANGUAGE_NONE, and t().

path_admin_overview ( $keys = NULL )

Returns a listing of all defined URL aliases.

When filter key passed, perform a standard search on the given key, and return the list of matching URL aliases.

Definition at line 14 of file path.admin.inc.

References $header, $row, db_query_range(), db_select(), drupal_get_destination(), drupal_get_form(), drupal_get_path_alias(), l(), LANGUAGE_NONE, module_exists(), module_invoke(), t(), and url().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/path/path.api.php File Reference

  • modules
  • path
Functions
path.api.php File Reference

Go to the source code of this file.

Functions

hook_path_insert ($path)
hook_path_update ($path)
hook_path_delete ($path)

Detailed Description

Hooks provided by the Path module.

Definition in file path.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/path/path.module File Reference

  • modules
  • path
Functions
path.module File Reference

Go to the source code of this file.

Functions

path_help ($path, $arg)
path_permission ()
path_menu ()
path_form_node_form_alter (&$form, $form_state)
path_form_element_validate ($element, &$form_state, $complete_form)
path_node_insert ($node)
path_node_update ($node)
path_node_delete ($node)
path_form_taxonomy_form_term_alter (&$form, $form_state)
path_taxonomy_term_insert ($term)
path_taxonomy_term_update ($term)
path_taxonomy_term_delete ($term)

Detailed Description

Enables users to rename URLs.

Definition in file path.module.

Function Documentation

path_form_element_validate | ( |  | $element,
 |  | & | $form_state,
 |  |  | $complete_form
 | ) |  |

Form element validation handler for URL alias form element.

See Also
path_form_node_form_alter()

Definition at line 152 of file path.module.

References db_select(), form_error(), form_set_value(), and t().

path_form_node_form_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_BASE_FORM_ID_alter() for node_form().

See Also
path_form_element_validate()

Definition at line 98 of file path.module.

References drupal_get_path(), entity_language(), LANGUAGE_NONE, nid, path_load(), t(), and user_access().

path_form_taxonomy_form_term_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter() for taxonomy_form_term().

Definition at line 228 of file path.module.

References entity_language(), LANGUAGE_NONE, path_load(), t(), and user_access().

path_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file path.module.

References $output, t(), and url().

path_menu ( )

Implements hook_menu().

Definition at line 54 of file path.module.

References MENU_DEFAULT_LOCAL_TASK, and MENU_LOCAL_ACTION.

path_node_delete ( $node )

Implements hook_node_delete().

Definition at line 220 of file path.module.

References path_delete().

path_node_insert ( $node )

Implements hook_node_insert().

Definition at line 187 of file path.module.

References entity_language(), LANGUAGE_NONE, and path_save().

Referenced by path_node_update().

path_node_update ( $node )

Implements hook_node_update().

Definition at line 205 of file path.module.

References path_delete(), and path_node_insert().

path_permission ( )

Implements hook_permission().

Definition at line 40 of file path.module.

References t().

path_taxonomy_term_delete ( $term )

Implements hook_taxonomy_term_delete().

Definition at line 310 of file path.module.

References path_delete().

path_taxonomy_term_insert ( $term )

Implements hook_taxonomy_term_insert().

Definition at line 266 of file path.module.

References entity_language(), LANGUAGE_NONE, and path_save().

path_taxonomy_term_update ( $term )

Implements hook_taxonomy_term_update().

Definition at line 286 of file path.module.

References entity_language(), LANGUAGE_NONE, path_delete(), and path_save().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/php Directory Reference

  • modules
  • php
php Directory Reference

Files

file | php.install [code]
file | php.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/php/php.install File Reference

  • modules
  • php
Functions
php.install File Reference

Go to the source code of this file.

Functions

php_enable ()
php_disable ()

Detailed Description

Install, update and uninstall functions for the php module.

Definition in file php.install.

Function Documentation

php_disable ( )

Implements hook_disable().

Definition at line 43 of file php.install.

References drupal_set_message(), and t().

php_enable ( )

Implements hook_enable().

Definition at line 11 of file php.install.

References db_query_range(), drupal_set_message(), filter_format_save(), t(), and url().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/php/php.module File Reference

  • modules
  • php
Functions
php.module File Reference

Go to the source code of this file.

Functions

php_help ($path, $arg)
php_permission ()
php_eval ($code)
_php_filter_tips ($filter, $format, $long=FALSE)
php_filter_info ()

Detailed Description

Additional filter for PHP input.

Definition in file php.module.

Function Documentation

_php_filter_tips | ( | $filter,
 |  | $format,
 |  | $long = FALSE
 | ) |

Implements callback_filter_tips().

See Also
php_filter_info()

Definition at line 95 of file php.module.

References $base_url, $output, t(), and url().

php_filter_info ( )

Implements hook_filter_info().

Provide PHP code filter. Use with care.

Definition at line 138 of file php.module.

References t().

php_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file php.module.

References $output, t(), and url().

php_permission ( )

Implements hook_permission().

Definition at line 29 of file php.module.

References t().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll Directory Reference

  • modules
  • poll
poll Directory Reference

Files

file | poll-bar--block.tpl.php [code]
file | poll-bar.tpl.php [code]
file | poll-results--block.tpl.php [code]
file | poll-results.tpl.php [code]
file | poll-vote.tpl.php [code]
file | poll.install [code]
file | poll.module [code]
file | poll.pages.inc [code]
file | poll.tokens.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll-bar--block.tpl.php File Reference

  • modules
  • poll
Variables
poll-bar--block.tpl.php File Reference

Go to the source code of this file.

Variables

print $title
print $percentage

Detailed Description

Default theme implementation to display the bar for a single choice in a poll.

Variables available:

  • $title: The title of the poll.
  • $votes: The number of votes for this choice
  • $total_votes: The number of votes for this choice
  • $percentage: The percentage of votes for this choice.
  • $vote: The choice number of the current user's vote.
  • $voted: Set to TRUE if the user voted for this choice.
See Also
template_preprocess_poll_bar()

Definition in file poll-bar--block.tpl.php.

Variable Documentation

print $percentage

Definition at line 22 of file poll-bar--block.tpl.php.

Referenced by _batch_api_percentage(), _batch_do(), _batch_process(), _batch_progress_page_nojs(), and search_admin_settings().

print $title

Definition at line 20 of file poll-bar--block.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll-bar.tpl.php File Reference

  • modules
  • poll
Variables
poll-bar.tpl.php File Reference

Go to the source code of this file.

Variables

print $title
print $percentage

Detailed Description

Default theme implementation to display the bar for a single choice in a poll.

Variables available:

  • $title: The title of the poll.
  • $votes: The number of votes for this choice
  • $total_votes: The number of votes for this choice
  • $percentage: The percentage of votes for this choice.
  • $vote: The choice number of the current user's vote.
  • $voted: Set to TRUE if the user voted for this choice.
See Also
template_preprocess_poll_bar()

Definition in file poll-bar.tpl.php.

Variable Documentation

print $percentage

Definition at line 22 of file poll-bar.tpl.php.

print $title

Definition at line 20 of file poll-bar.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll-results--block.tpl.php File Reference

  • modules
  • poll
Variables
poll-results--block.tpl.php File Reference

Go to the source code of this file.

Variables

print $links

Detailed Description

Default theme implementation to display the poll results in a block.

Variables available:

  • $title: The title of the poll.
  • $results: The results of the poll.
  • $votes: The total results in the poll.
  • $links: Links in the poll.
  • $nid: The nid of the poll
  • $cancel_form: A form to cancel the user's vote, if allowed.
  • $raw_links: The raw array of links. Should be run through theme('links') if used.
  • $vote: The choice number of the current user's vote.
See Also
template_preprocess_poll_results()

Definition in file poll-results--block.tpl.php.

Variable Documentation

print $links

Definition at line 28 of file poll-results--block.tpl.php.

Referenced by _filter_html(), _menu_build_tree(), DrupalWebTestCase\assertLink(), DrupalWebTestCase\assertLinkByHref(), DrupalWebTestCase\assertNoLink(), DrupalWebTestCase\assertNoLinkByHref(), blog_node_view(), book_menu_subtree_data(), book_node_view_link(), comment_links(), comment_node_view(), contextual_pre_render_links(), forum_menu_local_tasks_alter(), help_page(), hook_menu_contextual_links_alter(), language_negotiation_get_switch_links(), locale_block_view(), locale_language_switcher_session(), locale_language_switcher_url(), menu_contextual_links(), menu_links_clone(), menu_load_links(), menu_navigation_links(), menu_overview_form(), node_build_content(), poll_block_latest_poll_view(), shortcut_set_customize_submit(), shortcut_toolbar_pre_render(), statistics_node_view(), system_get_module_admin_tasks(), template_preprocess_book_navigation(), theme_links(), theme_update_version(), toolbar_menu_navigation_links(), toolbar_view(), translation_node_overview(), translation_node_view(), update_helpful_links(), and update_results_page().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll.install File Reference

  • modules
  • poll
Functions
poll.install File Reference

Go to the source code of this file.

Functions

poll_schema ()
poll_update_7001 ()
poll_update_7002 ()
poll_update_7003 ()
poll_update_7004 ()

Detailed Description

Install, update and uninstall functions for the poll module.

Definition in file poll.install.

Function Documentation

poll_schema ( )

Implements hook_schema().

Definition at line 11 of file poll.install.

poll_update_7001 ( )

Use the poll_choice primary key to record votes in poll_votes rather than the choice order. Rename chorder to weight.

Rename {poll_choices} table to {poll_choice} and {poll_votes} to {poll_vote}.

Definition at line 157 of file poll.install.

References db_add_field(), db_add_index(), db_change_field(), db_delete(), db_drop_field(), db_rename_table(), db_update(), and Database::getConnection().

poll_update_7002 ( )

Add timestamp field to {poll_vote}.

Definition at line 179 of file poll.install.

References db_add_field().

poll_update_7003 ( )

Change the weight column to normal int.

Definition at line 191 of file poll.install.

References db_change_field().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll.module File Reference

  • modules
  • poll
Functions
poll.module File Reference

Go to the source code of this file.

Functions

poll_help ($path, $arg)
poll_theme ()
poll_permission ()
poll_menu ()
_poll_menu_access ($node, $perm, $inspect_allowvotes)
poll_block_info ()
poll_block_view ($delta= '')
poll_cron ()
poll_node_info ()
poll_field_extra_fields ()
poll_form ($node, &$form_state)
poll_more_choices_submit ($form, &$form_state)
_poll_choice_form ($key, $chid=NULL, $value= '', $votes=0, $weight=0, $size=10)
poll_choice_js ($form, $form_state)
poll_node_form_submit (&$form, &$form_state)
poll_validate ($node, $form)
poll_field_attach_prepare_translation_alter (&$entity, $context)
poll_load ($nodes)
poll_insert ($node)
poll_update ($node)
poll_delete ($node)
poll_block_latest_poll_view ($node)
poll_view ($node, $view_mode)
poll_teaser ($node)
poll_view_voting ($form, &$form_state, $node, $block=FALSE)
poll_view_voting_validate ($form, &$form_state)
poll_vote ($form, &$form_state)
template_preprocess_poll_vote (&$variables)
poll_view_results ($node, $view_mode, $block=FALSE)
theme_poll_choices ($variables)
template_preprocess_poll_results (&$variables)
template_preprocess_poll_bar (&$variables)
poll_cancel_form ($form, &$form_state, $nid)
poll_cancel ($form, &$form_state)
poll_user_cancel ($edit, $account, $method)
poll_user_delete ($account)
poll_rdf_mapping ()

Detailed Description

Enables your site to capture votes on different topics in the form of multiple choice questions.

Definition in file poll.module.

Function Documentation

_poll_choice_form | ( | $key,
 |  | $chid = NULL,
 |  | $value = '',
 |  | $votes = 0,
 |  | $weight = 0,
 |  | $size = 10
 | ) |

Definition at line 381 of file poll.module.

References $value, t(), and user_access().

Referenced by poll_form().

_poll_menu_access | ( | $node,
 |  | $perm,
 |  | $inspect_allowvotes
 | ) |

Callback function to see if a node is acceptable for poll menu items.

Definition at line 126 of file poll.module.

References user_access().

poll_block_info ( )

Implements hook_block_info().

Definition at line 133 of file poll.module.

References t().

poll_block_latest_poll_view ( $node )

Return content for 'latest poll' block.

Parameters
$node The node object to load.

Definition at line 633 of file poll.module.

References $links, $output, drupal_get_form(), poll_view_results(), and t().

Referenced by poll_block_view().

poll_block_view ( $delta = '' )

Implements hook_block_view().

Generates a block containing the latest poll.

Definition at line 144 of file poll.module.

References db_select(), node_load(), poll_block_latest_poll_view(), t(), and user_access().

poll_cancel | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit callback for poll_cancel_form().

Definition at line 963 of file poll.module.

References db_delete(), db_update(), drupal_set_message(), ip_address(), node_load(), and t().

poll_choice_js | ( | $form,
 |  | $form_state
 | ) |

Ajax callback in response to new choices being added to the form.

This returns the new page content to replace the page content made obsolete by the form submission.

See Also
poll_more_choices_submit()

Definition at line 435 of file poll.module.

poll_cron ( )

Implements hook_cron().

Closes polls that have exceeded their allowed runtime.

Definition at line 174 of file poll.module.

References db_query(), db_update(), and REQUEST_TIME.

poll_delete ( $node )

Implements hook_delete().

Definition at line 615 of file poll.module.

References db_delete().

poll_field_attach_prepare_translation_alter | ( | & | $entity,
 |  |  | $context
 | ) |  |

Implements hook_field_attach_prepare_translation_alter().

Definition at line 476 of file poll.module.

poll_field_extra_fields ( )

Implements hook_field_extra_fields().

Definition at line 202 of file poll.module.

References t().

poll_form | ( |  | $node,
 |  | & | $form_state
 | ) |  |

Implements hook_form().

Definition at line 236 of file poll.module.

References $choice, _poll_choice_form(), check_plain(), drupal_map_assoc(), node_type_get_type(), t(), and user_access().

poll_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 12 of file poll.module.

References $output, t(), and url().

poll_insert ( $node )

Implements hook_insert().

Definition at line 536 of file poll.module.

References $choice, db_insert(), and user_access().

poll_load ( $nodes )

Implements hook_load().

Definition at line 488 of file poll.module.

References $value, db_query(), db_select(), ip_address(), and user_access().

poll_menu ( )

Implements hook_menu().

Definition at line 89 of file poll.module.

References MENU_LOCAL_TASK, and MENU_SUGGESTED_ITEM.

poll_more_choices_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to add more choices to a poll form.

This handler is run regardless of whether JS is enabled or not. It makes changes to the form state. If the button was clicked with JS disabled, then the page is reloaded with the complete rebuilt form. If the button was clicked with JS enabled, then ajax_form_callback() calls poll_choice_js() to return just the changed part of the form.

Definition at line 366 of file poll.module.

poll_node_form_submit | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Form submit handler for node_form().

Upon preview and final submission, we need to renumber poll choices and create a teaser output.

Definition at line 445 of file poll.module.

References poll_teaser().

poll_node_info ( )

Implements hook_node_info().

Definition at line 187 of file poll.module.

References t().

poll_permission ( )

Implements hook_permission().

Definition at line 70 of file poll.module.

References t().

poll_rdf_mapping ( )

Implements hook_rdf_mapping().

Definition at line 1009 of file poll.module.

poll_teaser ( $node )

Creates a simple teaser that lists all the choices.

This is primarily used for RSS.

Definition at line 694 of file poll.module.

References $choice, and check_plain().

Referenced by poll_node_form_submit().

poll_theme ( )

Implements hook_theme().

Definition at line 32 of file poll.module.

poll_update ( $node )

Implements hook_update().

Definition at line 570 of file poll.module.

References $choice, db_delete(), db_merge(), and db_update().

poll_user_cancel | ( | $edit,
 |  | $account,
 |  | $method
 | ) |

Implements hook_user_cancel().

Definition at line 986 of file poll.module.

References db_update().

poll_user_delete ( $account )

Implements hook_user_delete().

Definition at line 1000 of file poll.module.

References db_delete().

poll_validate | ( | $node,
 |  | $form
 | ) |

Implements hook_validate().

Definition at line 454 of file poll.module.

References $choice, form_set_error(), and t().

poll_view | ( | $node,
 |  | $view_mode
 | ) |

Implements hook_view().

Definition at line 676 of file poll.module.

References $output, drupal_get_form(), and poll_view_results().

poll_view_results | ( | $node,
 |  | $view_mode,
 |  | $block = FALSE
 | ) |

Generates a graphical representation of the results of a poll.

Definition at line 816 of file poll.module.

References $choice, and theme().

Referenced by poll_block_latest_poll_view(), and poll_view().

poll_view_voting_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validation function for processing votes

Definition at line 750 of file poll.module.

References form_set_error(), and t().

poll_vote | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for processing a vote.

Definition at line 759 of file poll.module.

References $choice, cache_clear_all(), db_insert(), db_update(), drupal_set_message(), ip_address(), REQUEST_TIME, and t().

template_preprocess_poll_bar ( & $variables )

Preprocess the poll_bar theme hook.

Inputs: $title, $votes, $total_votes, $voted, $block

See Also
poll-bar.tpl.php
poll-bar–block.tpl.php
theme_poll_bar()

Definition at line 930 of file poll.module.

References check_plain().

template_preprocess_poll_results ( & $variables )

Preprocess the poll_results theme hook.

Inputs: $raw_title, $results, $votes, $raw_links, $block, $nid, $vote. The $raw_* inputs to this are naturally unsafe; often safe versions are made to simply overwrite the raw version, but in this case it seems likely that the title and the links may be overridden by the theme layer, so they are left in with a different name for that purpose.

See Also
poll-results.tpl.php
poll-results–block.tpl.php

Definition at line 908 of file poll.module.

References check_plain(), drupal_get_form(), drupal_render(), theme(), and user_access().

template_preprocess_poll_vote ( & $variables )

Themes the voting form for a poll.

Inputs: $form

Definition at line 801 of file poll.module.

References check_plain(), drupal_render(), drupal_render_children(), and title.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll.pages.inc File Reference

  • modules
  • poll
Functions
poll.pages.inc File Reference

Go to the source code of this file.

Functions

poll_page ()
poll_votes ($node)
poll_results ($node)

Detailed Description

User page callbacks for the poll module.

Definition in file poll.pages.inc.

Function Documentation

poll_page ( )

Menu callback to provide a simple list of all polls available.

Definition at line 11 of file poll.pages.inc.

References $output, db_select(), format_plural(), l(), t(), and theme().

poll_results ( $node )

Callback for the 'results' tab for polls you can vote on

Definition at line 93 of file poll.pages.inc.

References drupal_set_title(), and node_show().

poll_votes ( $node )

Callback for the 'votes' tab for polls you can see other votes on

Definition at line 51 of file poll.pages.inc.

References $header, $vote, check_plain(), db_select(), drupal_set_title(), format_date(), t(), and theme().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll.tokens.inc File Reference

  • modules
  • poll
Functions
poll.tokens.inc File Reference

Go to the source code of this file.

Functions

poll_token_info ()
poll_tokens ($type, $tokens, array $data=array(), array $options=array())

Detailed Description

Builds placeholder replacement tokens for values specific to Poll nodes.

Definition in file poll.tokens.inc.

Function Documentation

poll_token_info ( )

Implements hook_token_info().

Definition at line 11 of file poll.tokens.inc.

References t().

poll_tokens | ( |  | $type,
 |  |  | $tokens,
 |  | array | $data = array(),
 |  | array | $options = array()
 | ) |  |

Implements hook_tokens().

Definition at line 41 of file poll.tokens.inc.

References $choice, $name, filter_xss(), and format_interval().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile Directory Reference

  • modules
  • profile
profile Directory Reference

Files

file | profile-block.tpl.php [code]
file | profile-listing.tpl.php [code]
file | profile-wrapper.tpl.php [code]
file | profile.admin.inc [code]
file | profile.install [code]
file | profile.module [code]
file | profile.pages.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile/profile-block.tpl.php File Reference

  • modules
  • profile
Variables
profile-block.tpl.php File Reference

Go to the source code of this file.

Variables

print $user_picture
foreach($profile as $field)($field->
type!= 'checkbox') 		endif
print $field value
endforeach

Detailed Description

Default theme implementation for displaying a users profile within a block. It only shows in relation to a node displayed as a full page.

Available variables:

  • $user_picture: Image configured for the account linking to the users page.
  • $profile: Keyed array of all profile fields that have a value.

Each $field in $profile contains:

  • $field->title: Title of the profile field.
  • $field->value: Value of the profile field.
  • $field->type: Type of the profile field, i.e., checkbox, textfield, textarea, selection, list, url or date.

Since $profile is keyed, a direct print of the field is possible. Not all accounts may have a value for a profile so do a check first. If a field of "last_name" was set for the site, the following can be used.

<?php if (isset($profile['last_name'])): ?>

<?php print $profile['last_name']->title; ?>:
<?php print $profile['last_name']->value; ?>

<?php endif; ?>

See Also
template_preprocess_profile_block()

Definition in file profile-block.tpl.php.

Variable Documentation

print $user_picture

Definition at line 32 of file profile-block.tpl.php.

endforeach

Definition at line 41 of file profile-block.tpl.php.

foreach ($profile as $field) ($field->type!= 'checkbox') endif

Definition at line 34 of file profile-block.tpl.php.

print $field value

Definition at line 39 of file profile-block.tpl.php.

Referenced by xmlrpc_error_get_xml().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile/profile-listing.tpl.php File Reference

  • modules
  • profile
Variables
profile-listing.tpl.php File Reference

Go to the source code of this file.

Variables

print $user_picture
print $name
foreach($profile as $field) endforeach

Detailed Description

Default theme implementation for displaying a user and their profile data for member listing pages.

See Also
profile-wrapper.tpl.php where all the data is collected and printed out.

Available variables:

  • $account: User's account object.
  • $user_picture: Image configured for the account linking to the users page.
  • $name: User's account name linking to the users page.
  • $profile: Keyed array of all profile fields that are set as visible in member list pages (configured by site administrators). It also needs to have a value in order to be present.

Each $field in $profile contains:

  • $field->title: Title of the profile field.
  • $field->value: Value of the profile field.
  • $field->type: Type of the profile field, i.e., checkbox, textfield, textarea, selection, list, url or date.

Since $profile is keyed, a direct print of the field is possible. Not all accounts may have a value for a profile so do a check first. If a field of "last_name" was set for the site, the following can be used.

<?php if (isset($profile['last_name'])): ?>

<?php print $profile['last_name']->title; ?>:
<?php print $profile['last_name']->value; ?>

<?php endif; ?>

See Also
template_preprocess_profile_listing()

Definition in file profile-listing.tpl.php.

Variable Documentation

print $name

Definition at line 43 of file profile-listing.tpl.php.

Referenced by FileTransfer\__get(), _batch_queue(), _drupal_schema_initialize(), _drupal_session_delete_cookie(), _drupal_set_preferred_header_name(), _drupal_theme_initialize(), _field_extra_fields_pre_render(), _field_info_collate_types(), _field_sql_storage_columnname(), _field_sql_storage_indexname(), _field_ui_add_default_view_mode_settings(), _filter_format_is_cacheable(), _filter_tips(), _form_builder_handle_input_element(), _node_mass_update_helper(), _registry_check_code(), _registry_parse_file(), _system_rebuild_theme_data(), _theme_process_registry(), _trigger_tab_information(), _update_7000_user_role_grant_permissions(), _update_build_fetch_url(), _update_process_info_list(), DatabaseSchema_mysql\addIndex(), DatabaseSchema_pgsql\addIndex(), DatabaseSchema_sqlite\addIndex(), DatabaseSchema_mysql\addUniqueKey(), DatabaseSchema_pgsql\addUniqueKey(), DatabaseSchema_sqlite\addUniqueKey(), aggregator_element_end(), aggregator_element_start(), ajax_command_data(), DrupalWebTestCase\assertFieldByName(), DrupalWebTestCase\assertMail(), DrupalWebTestCase\assertNoFieldByName(), authorize_filetransfer_form(), DrupalDefaultEntityController\buildQuery(), check_markup(), color_scheme_form(), color_update_7001(), comment_entity_info(), comment_node_type_load(), comment_tokens(), confirm_form(), DatabaseSchema_pgsql\constraintExists(), DatabaseSchema_sqlite\createColumsSql(), DatabaseSchema_mysql\createFieldSql(), DatabaseSchema_sqlite\createFieldSql(), DatabaseSchema_pgsql\createFieldSql(), DatabaseSchema\createTable(), DatabaseSchema_sqlite\createTableSql(), DatabaseSchema_mysql\createTableSql(), DatabaseSchema_pgsql\createTableSql(), DrupalWebTestCase\curlHeaderCallback(), db_add_index(), db_add_unique_key(), db_create_table(), db_drop_index(), db_drop_unique_key(), db_index_exists(), db_transaction(), dblog_filter_form_submit(), DatabaseSchema_mysql\dropIndex(), DatabaseSchema_pgsql\dropIndex(), DatabaseSchema_sqlite\dropIndex(), DatabaseSchema_mysql\dropUniqueKey(), DatabaseSchema_pgsql\dropUniqueKey(), DatabaseSchema_sqlite\dropUniqueKey(), drupal_add_http_header(), drupal_add_library(), drupal_get_filename(), drupal_get_http_header(), drupal_get_library(), drupal_get_path(), drupal_http_request(), drupal_install_schema(), drupal_load(), drupal_required_modules(), drupal_send_headers(), drupal_serve_page_from_cache(), drupal_static(), drupal_static_reset(), drupal_validate_form(), DrupalWebTestCase\drupalCreateContentType(), DrupalWebTestCase\drupalCreateRole(), DrupalWebTestCase\drupalGetHeader(), DrupalWebTestCase\drupalGetHeaders(), DrupalWebTestCase\drupalPost(), entity_get_info(), EntityFieldQuery\entityCondition(), EntityFieldQuery\entityOrderBy(), field_extra_fields_get_display(), field_sql_storage_field_storage_create_field(), field_sql_storage_field_storage_update_field(), field_ui_display_overview_form(), field_ui_display_overview_form_submit(), field_ui_display_overview_multistep_js(), field_ui_field_overview_form(), field_ui_field_type_options(), field_ui_formatter_options(), field_ui_table_pre_render(), field_ui_widget_type_options(), file_create_filename(), file_get_content_headers(), file_transfer(), filter_admin_format_form(), filter_format_save(), filter_get_filters(), filter_list_format(), filter_update_7008(), flood_clear_event(), flood_is_allowed(), flood_register_event(), form_load_include(), form_process_vertical_tabs(), form_set_error(), format_username(), DrupalQueue\get(), DrupalWebTestCase\handleForm(), help_links_as_list(), help_page(), hook_date_format_types_alter(), hook_entity_info(), hook_field_storage_create_field(), hook_field_storage_update_field(), hook_tokens(), hook_username_alter(), image_effect_definitions(), image_get_available_toolkits(), image_style_deliver(), image_style_load(), image_style_options(), DatabaseSchema_pgsql\indexExists(), DatabaseSchema_sqlite\indexExists(), install_select_locale_form(), install_select_profile_form(), install_settings_form_validate(), install_tasks_to_display(), install_tasks_to_perform(), DatabaseSchema_sqlite\introspectSchema(), locale_add_language(), locale_language_selector_form(), locale_translate_overview_screen(), locale_translation_filter_form_submit(), lock_acquire(), lock_may_be_available(), lock_release(), lock_wait(), DefaultMailSystem\mail(), menu_block_info(), module_list(), module_load_all_includes(), module_load_include(), node_entity_info(), node_overview_types(), node_tokens(), node_type_load(), openid_verify_assertion_return_url(), poll_tokens(), DatabaseConnection_mysql\popCommittableTransactions(), DatabaseConnection\popCommittableTransactions(), DatabaseConnection_sqlite\popTransaction(), DatabaseConnection\popTransaction(), FieldInfo\prepareExtraFields(), profile_browse(), profile_field_form_validate(), DatabaseConnection_sqlite\pushTransaction(), DatabaseConnection\pushTransaction(), shortcut_default_set(), shortcut_set_get_unique_name(), shortcut_set_switch(), simpletest_test_get_all(), DatabaseConnection\startTransaction(), statistics_tokens(), system_actions_configure(), system_get_info(), system_modules_confirm_form(), system_modules_submit(), system_modules_uninstall(), system_region_list(), system_requirements(), system_theme_settings(), system_tokens(), taxonomy_autocomplete(), taxonomy_field_formatter_view(), taxonomy_get_term_by_name(), taxonomy_select_nodes(), taxonomy_tokens(), taxonomy_vocabulary_machine_name_load(), template_preprocess_username(), theme(), theme_color_scheme_form(), theme_field_ui_table(), theme_filter_admin_format_filter_order(), theme_filter_tips(), theme_node_admin_overview(), theme_update_report(), theme_user_admin_roles(), timer_read(), timer_start(), timer_stop(), token_example_tokens(), tracker_update_7000(), update_check_incompatibility(), update_manager_update_form(), user_admin_permissions(), user_admin_permissions_submit(), user_admin_roles(), user_authenticate(), user_cancel_methods(), user_external_login_register(), user_is_blocked(), user_load_by_name(), user_pass_validate(), user_role_grant_permissions(), user_role_permissions(), user_tokens(), user_validate_current_pass(), user_validate_name(), variable_del(), variable_get(), variable_initialize(), variable_set(), and xmlrpc_value_get_xml().

print $user_picture

Definition at line 40 of file profile-listing.tpl.php.

foreach ($profile as $field) endforeach

Definition at line 46 of file profile-listing.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile/profile-wrapper.tpl.php File Reference

  • modules
  • profile
Variables
profile-wrapper.tpl.php File Reference

Go to the source code of this file.

Variables

print $content

Detailed Description

Default theme implementation for wrapping member listings and their profiles.

This template is used when viewing a list of users. It can be a general list for viewing all users with the URL of "example.com/profile" or when viewing a set of users who share a specific value for a profile such as "example.com/profile/country/belgium".

Available variables:

  • $content: User account profiles iterated through profile-listing.tpl.php.
  • $current_field: The named field being browsed. Provided here for context. The above example would result in "last_name". An alternate template name is also based on this, e.g., "profile-wrapper-last_name.tpl.php".
See Also
template_preprocess_profile_wrapper()

Definition in file profile-wrapper.tpl.php.

Variable Documentation

print $content

Definition at line 23 of file profile-wrapper.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile/profile.admin.inc File Reference

  • modules
  • profile
Functions
profile.admin.inc File Reference

Go to the source code of this file.

Functions

profile_admin_overview ($form)
profile_admin_overview_submit ($form, &$form_state)
theme_profile_admin_overview ($variables)
profile_field_form ($form, &$form_state, $arg=NULL)
profile_field_form_validate ($form, &$form_state)
profile_field_form_submit ($form, &$form_state)
profile_field_delete ($form, &$form_state, $fid)
profile_field_delete_submit ($form, &$form_state)
profile_admin_settings_autocomplete ($string)

Detailed Description

Administrative page callbacks for the profile module.

Definition in file profile.admin.inc.

Function Documentation

profile_admin_overview_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to update changed profile field weights and categories.

See Also
profile_admin_overview()

Definition at line 82 of file profile.admin.inc.

References cache_clear_all(), db_update(), drupal_set_message(), element_children(), menu_rebuild(), and t().

profile_admin_settings_autocomplete ( $string )

Retrieve a pipe delimited string of autocomplete suggestions for profile categories

Definition at line 434 of file profile.admin.inc.

References check_plain(), db_like(), db_select(), and drupal_json_output().

profile_field_delete | ( |  | $form,
 |  | & | $form_state,
 |  |  | $fid
 | ) |  |

Menu callback; deletes a field from all user profiles.

Definition at line 396 of file profile.admin.inc.

References confirm_form(), db_query(), drupal_not_found(), t(), and url().

profile_field_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process a field delete form submission.

Definition at line 414 of file profile.admin.inc.

References cache_clear_all(), db_delete(), drupal_set_message(), l(), t(), watchdog(), and WATCHDOG_NOTICE.

profile_field_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process profile_field_form submissions.

Definition at line 363 of file profile.admin.inc.

References cache_clear_all(), db_insert(), db_update(), drupal_set_message(), l(), menu_rebuild(), t(), watchdog(), and WATCHDOG_NOTICE.

profile_field_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate profile_field_form submissions.

Definition at line 310 of file profile.admin.inc.

References $name, $title, db_select(), drupal_get_schema(), form_set_error(), PROFILE_HIDDEN, and t().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile/profile.install File Reference

  • modules
  • profile
Functions
profile.install File Reference

Go to the source code of this file.

Functions

profile_uninstall ()
profile_schema ()
profile_update_7001 ()
profile_update_7002 ()

Detailed Description

Install, update and uninstall functions for the profile module.

Definition in file profile.install.

Function Documentation

profile_schema ( )

Implements hook_schema().

Definition at line 18 of file profile.install.

profile_uninstall ( )

Implements hook_uninstall().

Definition at line 11 of file profile.install.

References variable_del().

profile_update_7001 ( )

Rename {profile_fields} table to {profile_field} and {profile_values} to {profile_value}.

Definition at line 157 of file profile.install.

References db_rename_table().

profile_update_7002 ( )

Change the weight column to normal int.

Definition at line 165 of file profile.install.

References db_change_field().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile/profile.module File Reference

  • modules
  • profile
Functions | Variables
profile.module File Reference

Go to the source code of this file.

Functions

profile_help ($path, $arg)
profile_theme ()
profile_menu ()
profile_block_info ()
profile_block_configure ($delta= '')
profile_block_save ($delta= '', $edit=array())
profile_block_view ($delta= '')
profile_user_presave (&$edit, $account, $category)
profile_user_insert (&$edit, $account, $category)
profile_user_cancel ($edit, $account, $method)
profile_user_delete ($account)
profile_user_load ($users)
profile_save_profile (&$edit, $account, $category, $register=FALSE)
profile_view_field ($account, $field)
profile_user_view ($account)
_profile_form_explanation ($field)
profile_form_alter (&$form, &$form_state, $form_id)
_profile_update_user_fields ($fields, $account)
profile_user_form_validate ($form, &$form_state)
profile_user_categories ()
profile_category_access ($account, $category)
template_preprocess_profile_block (&$variables)
template_preprocess_profile_listing (&$variables)
template_preprocess_profile_wrapper (&$variables)
_profile_field_types ($type=NULL)
_profile_field_serialize ($type=NULL)
_profile_get_fields ($category, $register=FALSE)

Variables

const | PROFILE_PRIVATE 1
const | PROFILE_PUBLIC 2
const | PROFILE_PUBLIC_LISTINGS 3
const | PROFILE_HIDDEN 4

Detailed Description

Support for configurable user profiles.

Definition in file profile.module.

Function Documentation

_profile_field_serialize ( $type = NULL )

Definition at line 610 of file profile.module.

Referenced by profile_save_profile(), and profile_user_load().

_profile_field_types ( $type = NULL )

Definition at line 599 of file profile.module.

References t().

Referenced by profile_admin_overview(), and profile_field_form().

_profile_form_explanation ( $field )

Definition at line 361 of file profile.module.

References $output, filter_xss_admin(), PROFILE_PRIVATE, and t().

Referenced by profile_form_alter().

_profile_get_fields | ( | $category,
 |  | $register = FALSE
 | ) |

Definition at line 614 of file profile.module.

References db_like(), db_select(), PROFILE_HIDDEN, and user_access().

Referenced by profile_form_alter(), profile_save_profile(), and profile_user_form_validate().

_profile_update_user_fields | ( | $fields,
 |  | $account
 | ) |

Helper function: update an array of user fields by calling profile_view_field

Definition at line 472 of file profile.module.

References profile_view_field().

Referenced by profile_block_view(), and profile_browse().

profile_block_configure ( $delta = '' )

Implements hook_block_configure().

Definition at line 148 of file profile.module.

References check_plain(), db_query(), PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS, t(), url(), and variable_get().

profile_block_info ( )

Implements hook_block_info().

Definition at line 139 of file profile.module.

References DRUPAL_CACHE_PER_PAGE, DRUPAL_CACHE_PER_ROLE, and t().

profile_block_save | ( | $delta = '',
 |  | $edit = array()
 | ) |

Implements hook_block_save().

Definition at line 169 of file profile.module.

References variable_set().

profile_block_view ( $delta = '' )

Implements hook_block_view().

Definition at line 176 of file profile.module.

References $output, _profile_update_user_fields(), arg(), db_query(), format_username(), l(), node_load(), PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS, t(), theme(), user_access(), user_load(), and variable_get().

profile_category_access | ( | $account,
 |  | $category
 | ) |

Menu item access callback - check if a user has access to a profile category.

Definition at line 519 of file profile.module.

References db_query_range(), PROFILE_HIDDEN, user_access(), and user_edit_access().

profile_form_alter | ( | & | $form,
 |  | & | $form_state,
 |  |  | $form_id
 | ) |  |

Implements hook_form_alter().

Definition at line 378 of file profile.module.

References _profile_form_explanation(), _profile_get_fields(), and check_plain().

profile_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 31 of file profile.module.

References $output, t(), and url().

profile_menu ( )

Implements hook_menu().

Definition at line 79 of file profile.module.

References MENU_CALLBACK, MENU_SUGGESTED_ITEM, and MENU_VISIBLE_IN_BREADCRUMB.

profile_save_profile | ( | & | $edit,
 |  |  | $account,
 |  |  | $category,
 |  |  | $register = FALSE
 | ) |  |

Definition at line 262 of file profile.module.

References _profile_field_serialize(), _profile_get_fields(), and db_merge().

Referenced by profile_user_insert(), and profile_user_presave().

profile_theme ( )

Implements hook_theme().

Definition at line 55 of file profile.module.

profile_user_cancel | ( | $edit,
 |  | $account,
 |  | $method
 | ) |

Implements hook_user_cancel().

Definition at line 232 of file profile.module.

References db_delete().

profile_user_categories ( )

Implements hook_user_categories().

Definition at line 501 of file profile.module.

References db_query().

profile_user_delete ( $account )

Implements hook_user_delete().

Definition at line 244 of file profile.module.

References db_delete().

profile_user_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for the user register/profile form.

See Also
profile_form_alter()

Definition at line 484 of file profile.module.

References _profile_get_fields(), form_set_error(), t(), user_access(), and valid_url().

profile_user_insert | ( | & | $edit,
 |  |  | $account,
 |  |  | $category
 | ) |  |

Implements hook_user_insert().

Definition at line 225 of file profile.module.

References profile_save_profile().

profile_user_load ( $users )

Implements hook_user_load().

Definition at line 253 of file profile.module.

References _profile_field_serialize(), and db_query().

profile_user_presave | ( | & | $edit,
 |  |  | $account,
 |  |  | $category
 | ) |  |

Implements hook_user_presave().

Definition at line 216 of file profile.module.

References profile_save_profile().

profile_user_view ( $account )

Implements hook_user_view().

Definition at line 328 of file profile.module.

References $title, check_plain(), db_query(), PROFILE_HIDDEN, PROFILE_PRIVATE, profile_view_field(), and user_access().

profile_view_field | ( | $account,
 |  | $field
 | ) |

Definition at line 278 of file profile.module.

References PROFILE_PRIVATE, and user_access().

Referenced by _profile_update_user_fields(), and profile_user_view().

template_preprocess_profile_block ( & $variables )

Process variables for profile-block.tpl.php.

The $variables array contains the following arguments:

  • $account
  • $fields
See Also
profile-block.tpl.php

Definition at line 541 of file profile.module.

References check_plain(), and theme().

template_preprocess_profile_listing ( & $variables )

Process variables for profile-listing.tpl.php.

The $variables array contains the following arguments:

  • $account
  • $fields
See Also
profile-listing.tpl.php

Definition at line 566 of file profile.module.

References theme().

template_preprocess_profile_wrapper ( & $variables )

Process variables for profile-wrapper.tpl.php.

The $variables array contains the following arguments:

  • $content
See Also
profile-wrapper.tpl.php

Definition at line 591 of file profile.module.

References arg().

Variable Documentation

const PROFILE_HIDDEN 4

Hidden profile field, only accessible by administrators, modules and themes.

Definition at line 26 of file profile.module.

Referenced by _profile_get_fields(), profile_browse(), profile_category_access(), profile_field_form(), profile_field_form_validate(), and profile_user_view().

const PROFILE_PRIVATE 1

Private field, content only available to privileged users.

Definition at line 11 of file profile.module.

Referenced by _profile_form_explanation(), profile_browse(), profile_field_form(), profile_user_view(), and profile_view_field().

const PROFILE_PUBLIC 2

Public field, content shown on profile page but not used on member list pages.

Definition at line 16 of file profile.module.

Referenced by profile_block_configure(), profile_block_view(), and profile_field_form().

const PROFILE_PUBLIC_LISTINGS 3

Public field, content shown on profile page and on member list pages.

Definition at line 21 of file profile.module.

Referenced by profile_block_configure(), profile_block_view(), profile_browse(), and profile_field_form().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile/profile.pages.inc File Reference

  • modules
  • profile
Functions
profile.pages.inc File Reference

Go to the source code of this file.

Functions

profile_browse ()
profile_autocomplete ($field, $string)

Detailed Description

User page callbacks for the profile module.

Definition in file profile.pages.inc.

Function Documentation

profile_autocomplete | ( | $field,
 |  | $string
 | ) |

Callback to allow autocomplete of profile text fields.

Definition at line 118 of file profile.pages.inc.

References $value, check_plain(), db_like(), db_query_range(), db_select(), and drupal_json_output().

profile_browse ( )

Menu callback; display a list of user information.

Definition at line 11 of file profile.pages.inc.

References $content, $name, $output, $title, $value, _profile_update_user_fields(), check_plain(), db_like(), db_query(), db_select(), drupal_placeholder(), drupal_set_title(), MENU_ACCESS_DENIED, MENU_NOT_FOUND, PASS_THROUGH, PROFILE_HIDDEN, PROFILE_PRIVATE, PROFILE_PUBLIC_LISTINGS, t(), theme(), user_access(), and user_load_multiple().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/rdf Directory Reference

  • modules
  • rdf
rdf Directory Reference

Files

file | rdf.api.php [code]
file | rdf.install [code]
file | rdf.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/rdf/rdf.api.php File Reference

  • modules
  • rdf
Functions
rdf.api.php File Reference

Go to the source code of this file.

Functions

hook_rdf_mapping ()
hook_rdf_namespaces ()

Detailed Description

Hooks provided by the RDF module.

Definition in file rdf.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/rdf/rdf.install File Reference

  • modules
  • rdf
Functions
rdf.install File Reference

Go to the source code of this file.

Functions

rdf_schema ()
rdf_install ()

Detailed Description

Install, update and uninstall functions for the rdf module.

Definition in file rdf.install.

Function Documentation

rdf_install ( )

Implements hook_install().

Definition at line 44 of file rdf.install.

References module_implements(), and rdf_modules_installed().

rdf_schema ( )

Implements hook_schema().

Definition at line 11 of file rdf.install.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/rdf/rdf.module File Reference

  • modules
  • rdf
Functions | Variables
rdf.module File Reference

Go to the source code of this file.

Functions

rdf_help ($path, $arg)
rdf_rdf_namespaces ()
rdf_get_namespaces ()
rdf_mapping_load ($type, $bundle=RDF_DEFAULT_BUNDLE)
_rdf_get_default_mapping ($type)
_rdf_mapping_load ($type, $bundle)
rdf_mapping_save ($mapping)
rdf_mapping_delete ($type, $bundle)
rdf_rdfa_attributes ($mapping, $data=NULL)
rdf_modules_installed ($modules)
rdf_modules_uninstalled ($modules)
rdf_entity_info_alter (&$entity_info)
rdf_entity_load ($entities, $type)
rdf_comment_load ($comments)
rdf_theme ()
rdf_process (&$variables, $hook)
rdf_preprocess_node (&$variables)
rdf_preprocess_field (&$variables)
rdf_preprocess_user_profile (&$variables)
rdf_preprocess_username (&$variables)
rdf_preprocess_comment (&$variables)
rdf_preprocess_taxonomy_term (&$variables)
rdf_field_attach_view_alter (&$output, $context)
rdf_preprocess_image (&$variables)
theme_rdf_template_variable_wrapper ($variables)
theme_rdf_metadata ($variables)

Variables

const RDF_DEFAULT_BUNDLE ''

Detailed Description

Enables semantically enriched output for Drupal sites in the form of RDFa.

Definition in file rdf.module.

Function Documentation

_rdf_get_default_mapping ( $type )

End of "defgroup rdf". Helper function to get the default RDF mapping for a given entity type.

Parameters
$type An entity type, e.g. 'node' or 'comment'.
Returns
The RDF mapping or an empty array if no mapping is defined for this entity type.

Definition at line 160 of file rdf.module.

References $module, drupal_static(), module_implements(), module_invoke(), and RDF_DEFAULT_BUNDLE.

Referenced by rdf_entity_info_alter(), rdf_mapping_load(), and rdf_mapping_save().

_rdf_mapping_load | ( | $type,
 |  | $bundle
 | ) |

Helper function to retrieve an RDF mapping from the database.

Parameters
$type | The entity type the mapping refers to.
$bundle | The bundle the mapping refers to.
Returns
An RDF mapping structure or an empty array if no record was found.

Definition at line 192 of file rdf.module.

References db_select().

Referenced by rdf_entity_info_alter().

rdf_comment_load ( $comments )

Implements hook_comment_load().

Definition at line 400 of file rdf.module.

References rdf_rdfa_attributes(), and url().

rdf_entity_info_alter ( & $entity_info )

Implements hook_entity_info_alter().

Adds the proper RDF mapping to each entity type/bundle pair.

Definition at line 368 of file rdf.module.

References _rdf_get_default_mapping(), and _rdf_mapping_load().

rdf_entity_load | ( | $entities,
 |  | $type
 | ) |

Implements hook_entity_load().

Definition at line 389 of file rdf.module.

References entity_extract_ids(), and rdf_mapping_load().

rdf_field_attach_view_alter | ( | & | $output,
 |  |  | $context
 | ) |  |

Implements hook_field_attach_view_alter().

Definition at line 747 of file rdf.module.

References $output, and element_children().

rdf_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file rdf.module.

References $output, and t().

rdf_modules_installed ( $modules )

End of "addtogroup rdf". Implements hook_modules_installed().

Checks if the installed modules have any RDF mapping definitions to declare and stores them in the rdf_mapping table.

While both default entity mappings and specific bundle mappings can be defined in hook_rdf_mapping(), default entity mappings are not stored in the database. Only overridden mappings are stored in the database. The default entity mappings can be overriden by specific bundle mappings which are stored in the database and can be altered via the RDF CRUD mapping API.

Definition at line 336 of file rdf.module.

References $module, RDF_DEFAULT_BUNDLE, and rdf_mapping_save().

Referenced by rdf_install().

rdf_modules_uninstalled ( $modules )

Implements hook_modules_uninstalled().

Definition at line 353 of file rdf.module.

rdf_preprocess_comment ( & $variables )

Implements MODULE_preprocess_HOOK().

Definition at line 671 of file rdf.module.

References entity_uri(), and url().

rdf_preprocess_field ( & $variables )

Implements MODULE_preprocess_HOOK().

Definition at line 549 of file rdf.module.

References file_create_url(), image_style_url(), rdf_mapping_load(), and rdf_rdfa_attributes().

rdf_preprocess_image ( & $variables )

Implements MODULE_preprocess_HOOK().

Definition at line 776 of file rdf.module.

rdf_preprocess_node ( & $variables )

Implements MODULE_preprocess_HOOK().

Definition at line 466 of file rdf.module.

References drupal_add_html_head(), rdf_rdfa_attributes(), title, and user_access().

rdf_preprocess_taxonomy_term ( & $variables )

Implements MODULE_preprocess_HOOK().

Definition at line 729 of file rdf.module.

References drupal_add_html_head(), and url().

rdf_preprocess_user_profile ( & $variables )

Implements MODULE_preprocess_HOOK().

Definition at line 577 of file rdf.module.

References drupal_add_html_head(), entity_uri(), and url().

rdf_preprocess_username ( & $variables )

Implements MODULE_preprocess_HOOK().

Definition at line 614 of file rdf.module.

References $attributes, rdf_mapping_load(), and url().

rdf_process | ( | & | $variables,
 |  |  | $hook
 | ) |  |

Template process function for adding extra tags to hold RDFa attributes.

Since template files already have built-in support for $attributes, $title_attributes, and $content_attributes, and field templates have support for $item_attributes, we try to leverage those as much as possible. However, in some cases additional attributes are needed not covered by these. We deal with those here.

Definition at line 436 of file rdf.module.

References $attributes, and theme().

rdf_theme ( )

Implements hook_theme().

Definition at line 416 of file rdf.module.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search Directory Reference

  • modules
  • search
search Directory Reference

Files

file | search-block-form.tpl.php [code]
file | search-result.tpl.php [code]
file | search-results.tpl.php [code]
file | search.admin.inc [code]
file | search.api.php [code]
file | search.extender.inc [code]
file | search.install [code]
file | search.module [code]
file | search.pages.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search-block-form.tpl.php File Reference

  • modules
  • search
Variables
search-block-form.tpl.php File Reference

Go to the source code of this file.

Variables

endif
print $search_form

Detailed Description

Displays the search form block.

Available variables:

  • $search_form: The complete search form ready for print.
  • $search: Associative array of search elements. Can be used to print each form element separately.

Default elements within $search:

  • $search['search_block_form']: Text input area wrapped in a div.
  • $search['actions']: Rendered form buttons.
  • $search['hidden']: Hidden form elements. Used to validate forms when submitted.

Modules can add to the search form, so it is recommended to check for their existence before printing. The default keys will always exist. To check for a module-provided field, use code like this:

* <?php if (isset($search['extra_field'])): ?>
* <div class="extra-field">
* <?php print $search['extra_field']; ?>
* </div>
* <?php endif; ?>
*
See Also
template_preprocess_search_block_form()

Definition in file search-block-form.tpl.php.

Variable Documentation

print $search_form

Definition at line 36 of file search-block-form.tpl.php.

endif

Definition at line 35 of file search-block-form.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search.admin.inc File Reference

  • modules
  • search
Functions
search.admin.inc File Reference

Go to the source code of this file.

Functions

search_reindex_confirm ()
search_reindex_confirm_submit (&$form, &$form_state)
_search_get_module_names ()
search_admin_settings ($form)
search_admin_settings_validate ($form, &$form_state)
search_admin_settings_submit ($form, &$form_state)
search_admin_reindex_submit ($form, &$form_state)

Detailed Description

Admin page callbacks for the search module.

Definition in file search.admin.inc.

Function Documentation

_search_get_module_names ( )

Helper function to get real module names.

Definition at line 31 of file search.admin.inc.

References $info, $module, search_get_info(), and system_get_info().

Referenced by search_admin_settings().

search_admin_reindex_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for reindex button on search_admin_settings_form().

Definition at line 183 of file search.admin.inc.

search_admin_settings_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for search_admin_settings().

Definition at line 159 of file search.admin.inc.

References drupal_set_message(), search_reindex(), t(), variable_get(), and variable_set().

search_admin_settings_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for search_admin_settings().

Definition at line 145 of file search.admin.inc.

References form_set_error(), and t().

search_reindex_confirm ( )

Menu callback: confirm wiping of the index.

Definition at line 11 of file search.admin.inc.

References confirm_form(), and t().

search_reindex_confirm_submit | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Handler for wipe confirmation

Definition at line 19 of file search.admin.inc.

References drupal_set_message(), search_reindex(), and t().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search.api.php File Reference

  • modules
  • search
Functions
search.api.php File Reference

Go to the source code of this file.

Functions

hook_search_info ()
hook_search_access ()
hook_search_reset ()
hook_search_status ()
hook_search_admin ()
hook_search_execute ($keys=NULL, $conditions=NULL)
hook_search_page ($results)
hook_search_preprocess ($text)
hook_update_index ()
callback_search_conditions ($keys)

Detailed Description

Hooks provided by the Search module.

Definition in file search.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search.extender.inc File Reference

  • modules
  • search
Classes
search.extender.inc File Reference

Go to the source code of this file.

Classes

class SearchQuery

Detailed Description

Search query extender and helper functions.

Definition in file search.extender.inc.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search.install File Reference

  • modules
  • search
Functions
search.install File Reference

Go to the source code of this file.

Functions

search_uninstall ()
search_schema ()
search_update_7000 ()

Detailed Description

Install, update and uninstall functions for the search module.

Definition in file search.install.

Function Documentation

search_schema ( )

Implements hook_schema().

Definition at line 20 of file search.install.

search_uninstall ( )

Implements hook_uninstall().

Definition at line 11 of file search.install.

References variable_del().

search_update_7000 ( )

Replace unique keys in 'search_dataset' and 'search_index' by primary keys.

Definition at line 160 of file search.install.

References db_add_primary_key(), db_change_field(), db_drop_index(), and db_drop_unique_key().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search.module File Reference

  • modules
  • search
Functions | Variables
search.module File Reference

Go to the source code of this file.

Functions

search_help ($path, $arg)
search_theme ()
search_permission ()
search_block_info ()
search_block_view ($delta= '')
search_menu ()
search_is_active ()
search_get_info ($all=FALSE)
search_get_default_module_info ()
_search_menu_access ($name)
search_reindex ($sid=NULL, $module=NULL, $reindex=FALSE)
search_dirty ($word=NULL)
search_cron ()
search_update_totals ()
search_simplify ($text)
search_expand_cjk ($matches)
search_index_split ($text)
_search_index_truncate (&$text)
search_invoke_preprocess (&$text)
search_index ($sid, $module, $text)
search_touch_node ($nid)
search_node_update_index ($node)
search_node_update ($node)
search_comment_insert ($comment)
search_comment_update ($comment)
search_comment_delete ($comment)
search_comment_publish ($comment)
search_comment_unpublish ($comment)
search_expression_extract ($expression, $option)
search_expression_insert ($expression, $option, $value=NULL)
search_form ($form, &$form_state, $action= '', $keys= '', $module=NULL, $prompt=NULL)
search_box ($form, &$form_state, $form_id)
search_box_form_submit ($form, &$form_state)
template_preprocess_search_block_form (&$variables)
search_data ($keys, $module, $conditions=NULL)
search_excerpt ($keys, $text)
_search_excerpt_replace (&$text)
search_simplify_excerpt_match ($key, $text, $offset, $boundary)
_search_excerpt_match_filter ($var)
search_forms ()

Variables

const | PREG_CLASS_NUMBERS '\x{30}-\x{39}\x{b2}\x{b3}\x{b9}\x{bc}-\x{be}\x{660}-\x{669}\x{6f0}-\x{6f9}' . '\x{966}-\x{96f}\x{9e6}-\x{9ef}\x{9f4}-\x{9f9}\x{a66}-\x{a6f}\x{ae6}-\x{aef}' . '\x{b66}-\x{b6f}\x{be7}-\x{bf2}\x{c66}-\x{c6f}\x{ce6}-\x{cef}\x{d66}-\x{d6f}' . '\x{e50}-\x{e59}\x{ed0}-\x{ed9}\x{f20}-\x{f33}\x{1040}-\x{1049}\x{1369}-' . '\x{137c}\x{16ee}-\x{16f0}\x{17e0}-\x{17e9}\x{17f0}-\x{17f9}\x{1810}-\x{1819}' . '\x{1946}-\x{194f}\x{2070}\x{2074}-\x{2079}\x{2080}-\x{2089}\x{2153}-\x{2183}' . '\x{2460}-\x{249b}\x{24ea}-\x{24ff}\x{2776}-\x{2793}\x{3007}\x{3021}-\x{3029}' . '\x{3038}-\x{303a}\x{3192}-\x{3195}\x{3220}-\x{3229}\x{3251}-\x{325f}\x{3280}-' . '\x{3289}\x{32b1}-\x{32bf}\x{ff10}-\x{ff19}'
const | PREG_CLASS_PUNCTUATION '\x{21}-\x{23}\x{25}-\x{2a}\x{2c}-\x{2f}\x{3a}\x{3b}\x{3f}\x{40}\x{5b}-\x{5d}' . '\x{5f}\x{7b}\x{7d}\x{a1}\x{ab}\x{b7}\x{bb}\x{bf}\x{37e}\x{387}\x{55a}-\x{55f}' . '\x{589}\x{58a}\x{5be}\x{5c0}\x{5c3}\x{5f3}\x{5f4}\x{60c}\x{60d}\x{61b}\x{61f}' . '\x{66a}-\x{66d}\x{6d4}\x{700}-\x{70d}\x{964}\x{965}\x{970}\x{df4}\x{e4f}' . '\x{e5a}\x{e5b}\x{f04}-\x{f12}\x{f3a}-\x{f3d}\x{f85}\x{104a}-\x{104f}\x{10fb}' . '\x{1361}-\x{1368}\x{166d}\x{166e}\x{169b}\x{169c}\x{16eb}-\x{16ed}\x{1735}' . '\x{1736}\x{17d4}-\x{17d6}\x{17d8}-\x{17da}\x{1800}-\x{180a}\x{1944}\x{1945}' . '\x{2010}-\x{2027}\x{2030}-\x{2043}\x{2045}-\x{2051}\x{2053}\x{2054}\x{2057}' . '\x{207d}\x{207e}\x{208d}\x{208e}\x{2329}\x{232a}\x{23b4}-\x{23b6}\x{2768}-' . '\x{2775}\x{27e6}-\x{27eb}\x{2983}-\x{2998}\x{29d8}-\x{29db}\x{29fc}\x{29fd}' . '\x{3001}-\x{3003}\x{3008}-\x{3011}\x{3014}-\x{301f}\x{3030}\x{303d}\x{30a0}' . '\x{30fb}\x{fd3e}\x{fd3f}\x{fe30}-\x{fe52}\x{fe54}-\x{fe61}\x{fe63}\x{fe68}' . '\x{fe6a}\x{fe6b}\x{ff01}-\x{ff03}\x{ff05}-\x{ff0a}\x{ff0c}-\x{ff0f}\x{ff1a}' . '\x{ff1b}\x{ff1f}\x{ff20}\x{ff3b}-\x{ff3d}\x{ff3f}\x{ff5b}\x{ff5d}\x{ff5f}-' . '\x{ff65}'
const | PREG_CLASS_CJK '\x{1100}-\x{11FF}\x{3040}-\x{309F}\x{30A1}-\x{318E}' . '\x{31A0}-\x{31B7}\x{31F0}-\x{31FF}\x{3400}-\x{4DBF}\x{4E00}-\x{9FCF}' . '\x{A000}-\x{A48F}\x{A4D0}-\x{A4FD}\x{A960}-\x{A97F}\x{AC00}-\x{D7FF}' . '\x{F900}-\x{FAFF}\x{FF21}-\x{FF3A}\x{FF41}-\x{FF5A}\x{FF66}-\x{FFDC}' . '\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}'

Detailed Description

Enables site-wide keyword searching.

Definition in file search.module.

Function Documentation

_search_excerpt_match_filter ( $var )

Helper function for array_filter() in search_search_excerpt_match().

Definition at line 1340 of file search.module.

_search_excerpt_replace ( & $text )

End of "defgroup search". Helper function for array_walk() in search_excerpt().

Definition at line 1265 of file search.module.

_search_index_truncate ( & $text )

Helper function for array_walk in search_index_split.

Definition at line 523 of file search.module.

_search_menu_access ( $name )

Access callback for search tabs.

Definition at line 293 of file search.module.

search_block_info ( )

Implements hook_block_info().

Definition at line 139 of file search.module.

search_block_view ( $delta = '' )

Implements hook_block_view().

Definition at line 150 of file search.module.

search_comment_delete ( $comment )

Implements hook_comment_delete().

Definition at line 832 of file search.module.

search_comment_insert ( $comment )

Implements hook_comment_insert().

Definition at line 816 of file search.module.

search_comment_publish ( $comment )

Implements hook_comment_publish().

Definition at line 840 of file search.module.

search_comment_unpublish ( $comment )

Implements hook_comment_unpublish().

Definition at line 848 of file search.module.

search_comment_update ( $comment )

Implements hook_comment_update().

Definition at line 824 of file search.module.

search_cron ( )

Implements hook_cron().

Fires hook_update_index() in all modules and cleans up dirty words.

See Also
search_dirty()

Definition at line 354 of file search.module.

search_dirty ( $word = NULL )

Marks a word as "dirty" (changed), or retrieves the list of dirty words.

This is used during indexing (cron). Words that are dirty have outdated total counts in the search_total table, and need to be recounted.

Definition at line 337 of file search.module.

search_expand_cjk ( $matches )

Splits CJK (Chinese, Japanese, Korean) text into tokens.

The Search module matches exact words, where a word is defined to be a sequence of characters delimited by spaces or punctuation. CJK languages are written in long strings of characters, though, not split up into words. So in order to allow search matching, we split up CJK text into tokens consisting of consecutive, overlapping sequences of characters whose length is equal to the 'minimum_word_size' variable. This tokenizing is only done if the 'overlap_cjk' variable is TRUE.

Parameters
$matches This function is a callback for preg_replace_callback(), which is called from search_simplify(). So, $matches is an array of regular expression matches, which means that $matches[0] contains the matched text – a string of CJK characters to tokenize.
Returns
Tokenized text, starting and ending with a space character.

Definition at line 473 of file search.module.

search_expression_extract | ( | $expression,
 |  | $option
 | ) |

Extracts a module-specific search option from a search expression.

Search options are added using search_expression_insert(), and retrieved using search_expression_extract(). They take the form option:value, and are added to the ordinary keywords in the search expression.

Parameters
$expression | The search expression to extract from.
$option | The name of the option to retrieve from the search expression.
Returns
The value previously stored in the search expression for option $option, if any. Trailing spaces in values will not be included.

Definition at line 869 of file search.module.

Referenced by SearchQuery::setOption().

search_expression_insert | ( | $expression,
 |  | $option,
 |  | $value = NULL
 | ) |

Adds a module-specific search option to a search expression.

Search options are added using search_expression_insert(), and retrieved using search_expression_extract(). They take the form option:value, and are added to the ordinary keywords in the search expression.

Parameters
$expression | The search expression to add to.
$option | The name of the option to add to the search expression.
$value | The value to add for the option. If present, it will replace any previous value added for the option. Cannot contain any spaces or | characters, as these are used as delimiters. If you want to add a blank value $option: to the search expression, pass in an empty string or a string that is composed of only spaces. To clear a previously-stored option without adding a replacement, pass in NULL for $value or omit.
Returns
$expression, with any previous value for this option removed, and a new $option:$value pair added if $value was provided.

Definition at line 898 of file search.module.

Referenced by node_search_validate(), and SearchQuery::setOption().

search_forms ( )

Implements hook_forms().

Definition at line 1347 of file search.module.

search_get_default_module_info ( )

Returns information about the default search module.

Returns
The search_get_info() array element for the default search module, if any.

Definition at line 279 of file search.module.

Referenced by search_view().

search_get_info ( $all = FALSE )

Returns information about available search modules.

Parameters
$all If TRUE, information about all enabled modules implementing hook_search_info() will be returned. If FALSE (default), only modules that have been set to active on the search settings page will be returned.
Returns
Array of hook_search_info() return values, keyed by module name. The 'title' and 'path' array elements will be set to defaults for each module if not supplied by hook_search_info(), and an additional array element of 'module' will be added (set to the module name).

Definition at line 252 of file search.module.

Referenced by _search_get_module_names(), and search_view().

search_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 64 of file search.module.

search_index_split ( $text )

Simplifies and splits a string into tokens for indexing.

Definition at line 502 of file search.module.

search_invoke_preprocess ( & $text )

Invokes hook_search_preprocess() in modules.

Definition at line 533 of file search.module.

search_is_active ( )

Determines access for the ?q=search path.

Definition at line 233 of file search.module.

search_menu ( )

Implements hook_menu().

Definition at line 160 of file search.module.

search_node_update ( $node )

Implements hook_node_update().

Definition at line 807 of file search.module.

search_node_update_index ( $node )

Implements hook_node_update_index().

Definition at line 792 of file search.module.

search_permission ( )

Implements hook_permission().

Definition at line 122 of file search.module.

search_reindex | ( | $sid = NULL,
 |  | $module = NULL,
 |  | $reindex = FALSE
 | ) |

Clears a part of or the entire search index.

Parameters
$sid | (optional) The ID of the item to remove from the search index. If specified, $module must also be given. Omit both $sid and $module to clear the entire search index.
$module | (optional) The machine-readable name of the module for the item to remove from the search index.

Definition at line 308 of file search.module.

Referenced by node_delete_multiple(), search_admin_settings_submit(), and search_reindex_confirm_submit().

search_simplify ( $text )

Simplifies a string according to indexing rules.

Parameters
$text Text to simplify.
Returns
Simplified text.
See Also
hook_search_preprocess()

Definition at line 409 of file search.module.

Referenced by SearchQuery::parseSearchExpression().

search_simplify_excerpt_match | ( | $key,
 |  | $text,
 |  | $offset,
 |  | $boundary
 | ) |

Find words in the original text that matched via search_simplify().

This is called in search_excerpt() if an exact match is not found in the text, so that we can find the derived form that matches.

Parameters
$key | The keyword to find.
$text | The text to search for the keyword.
$offset | Offset position in $text to start searching at.
$boundary | Text to include in a regular expression that will match a word boundary.
Returns
FALSE if no match is found. If a match is found, return an associative array with element 'where' giving the position of the match, and element 'keyword' giving the actual word found in the text at that position.

Definition at line 1289 of file search.module.

search_theme ( )

Implements hook_theme().

Definition at line 100 of file search.module.

search_touch_node ( $nid )

Changes a node's changed timestamp to 'now' to force reindexing.

Parameters
$nid The node ID of the node that needs reindexing.

Definition at line 781 of file search.module.

Referenced by hook_comment_insert(), and hook_comment_update().

search_update_totals ( )

Updates the {search_total} database table.

This function is called on shutdown to ensure that {search_total} is always up to date (even if cron times out or otherwise fails).

Definition at line 371 of file search.module.

Variable Documentation

const PREG_CLASS_CJK '\x{1100}-\x{11FF}\x{3040}-\x{309F}\x{30A1}-\x{318E}' . '\x{31A0}-\x{31B7}\x{31F0}-\x{31FF}\x{3400}-\x{4DBF}\x{4E00}-\x{9FCF}' . '\x{A000}-\x{A48F}\x{A4D0}-\x{A4FD}\x{A960}-\x{A97F}\x{AC00}-\x{D7FF}' . '\x{F900}-\x{FAFF}\x{FF21}-\x{FF3A}\x{FF41}-\x{FF5A}\x{FF66}-\x{FFDC}' . '\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}'

Matches CJK (Chinese, Japanese, Korean) letter-like characters.

This list is derived from the "East Asian Scripts" section of http://www.unicode.org/charts/index.html, as well as a comment on http://unicode.org/reports/tr11/tr11-11.html listing some character ranges that are reserved for additional CJK ideographs.

The character ranges do not include numbers, punctuation, or symbols, since these are handled separately in search. Note that radicals and strokes are considered symbols. (See http://www.unicode.org/Public/UNIDATA/extracted/DerivedGeneralCategory.txt)

See Also
search_expand_cjk()

Definition at line 55 of file search.module.

const PREG_CLASS_NUMBERS '\x{30}-\x{39}\x{b2}\x{b3}\x{b9}\x{bc}-\x{be}\x{660}-\x{669}\x{6f0}-\x{6f9}' . '\x{966}-\x{96f}\x{9e6}-\x{9ef}\x{9f4}-\x{9f9}\x{a66}-\x{a6f}\x{ae6}-\x{aef}' . '\x{b66}-\x{b6f}\x{be7}-\x{bf2}\x{c66}-\x{c6f}\x{ce6}-\x{cef}\x{d66}-\x{d6f}' . '\x{e50}-\x{e59}\x{ed0}-\x{ed9}\x{f20}-\x{f33}\x{1040}-\x{1049}\x{1369}-' . '\x{137c}\x{16ee}-\x{16f0}\x{17e0}-\x{17e9}\x{17f0}-\x{17f9}\x{1810}-\x{1819}' . '\x{1946}-\x{194f}\x{2070}\x{2074}-\x{2079}\x{2080}-\x{2089}\x{2153}-\x{2183}' . '\x{2460}-\x{249b}\x{24ea}-\x{24ff}\x{2776}-\x{2793}\x{3007}\x{3021}-\x{3029}' . '\x{3038}-\x{303a}\x{3192}-\x{3195}\x{3220}-\x{3229}\x{3251}-\x{325f}\x{3280}-' . '\x{3289}\x{32b1}-\x{32bf}\x{ff10}-\x{ff19}'

Matches all 'N' Unicode character classes (numbers)

Definition at line 11 of file search.module.

const PREG_CLASS_PUNCTUATION '\x{21}-\x{23}\x{25}-\x{2a}\x{2c}-\x{2f}\x{3a}\x{3b}\x{3f}\x{40}\x{5b}-\x{5d}' . '\x{5f}\x{7b}\x{7d}\x{a1}\x{ab}\x{b7}\x{bb}\x{bf}\x{37e}\x{387}\x{55a}-\x{55f}' . '\x{589}\x{58a}\x{5be}\x{5c0}\x{5c3}\x{5f3}\x{5f4}\x{60c}\x{60d}\x{61b}\x{61f}' . '\x{66a}-\x{66d}\x{6d4}\x{700}-\x{70d}\x{964}\x{965}\x{970}\x{df4}\x{e4f}' . '\x{e5a}\x{e5b}\x{f04}-\x{f12}\x{f3a}-\x{f3d}\x{f85}\x{104a}-\x{104f}\x{10fb}' . '\x{1361}-\x{1368}\x{166d}\x{166e}\x{169b}\x{169c}\x{16eb}-\x{16ed}\x{1735}' . '\x{1736}\x{17d4}-\x{17d6}\x{17d8}-\x{17da}\x{1800}-\x{180a}\x{1944}\x{1945}' . '\x{2010}-\x{2027}\x{2030}-\x{2043}\x{2045}-\x{2051}\x{2053}\x{2054}\x{2057}' . '\x{207d}\x{207e}\x{208d}\x{208e}\x{2329}\x{232a}\x{23b4}-\x{23b6}\x{2768}-' . '\x{2775}\x{27e6}-\x{27eb}\x{2983}-\x{2998}\x{29d8}-\x{29db}\x{29fc}\x{29fd}' . '\x{3001}-\x{3003}\x{3008}-\x{3011}\x{3014}-\x{301f}\x{3030}\x{303d}\x{30a0}' . '\x{30fb}\x{fd3e}\x{fd3f}\x{fe30}-\x{fe52}\x{fe54}-\x{fe61}\x{fe63}\x{fe68}' . '\x{fe6a}\x{fe6b}\x{ff01}-\x{ff03}\x{ff05}-\x{ff0a}\x{ff0c}-\x{ff0f}\x{ff1a}' . '\x{ff1b}\x{ff1f}\x{ff20}\x{ff3b}-\x{ff3d}\x{ff3f}\x{ff5b}\x{ff5d}\x{ff5f}-' . '\x{ff65}'

Matches all 'P' Unicode character classes (punctuation)

Definition at line 24 of file search.module.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search.pages.inc File Reference

  • modules
  • search
Functions
search.pages.inc File Reference

Go to the source code of this file.

Functions

search_view ($module=NULL, $keys= '')
template_preprocess_search_results (&$variables)
template_preprocess_search_result (&$variables)
search_form_validate ($form, &$form_state)
search_form_submit ($form, &$form_state)

Detailed Description

User page callbacks for the search module.

Definition in file search.pages.inc.

Function Documentation

search_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process a search form submission.

Definition at line 150 of file search.pages.inc.

References form_set_error(), and t().

search_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

As the search form collates keys from other modules hooked in via hook_form_alter, the validation takes place in _submit. search_form_validate() is used solely to set the 'processed_keys' form value for the basic search form.

Definition at line 143 of file search.pages.inc.

References form_set_value().

search_view | ( | $module = NULL,
 |  | $keys = ''
 | ) |

Menu callback; presents the search form and/or search results.

Parameters
$module | Search module to use for the search.
$keys | Keywords to use for the search.

Definition at line 16 of file search.pages.inc.

References $info, $module, $results, drupal_get_form(), drupal_goto(), l(), search_data(), search_get_default_module_info(), search_get_info(), t(), watchdog(), and WATCHDOG_NOTICE.

template_preprocess_search_result ( & $variables )

Process variables for search-result.tpl.php.

The $variables array contains the following arguments:

  • $result
  • $module
See Also
search-result.tpl.php

Definition at line 105 of file search.pages.inc.

References $info, check_plain(), check_url(), format_date(), and LANGUAGE_NONE.

template_preprocess_search_results ( & $variables )

Process variables for search-results.tpl.php.

The $variables array contains the following arguments:

  • $results: Search results array.
  • $module: Module the search results came from (module implementing hook_search_info()).
See Also
search-results.tpl.php

Definition at line 84 of file search.pages.inc.

References check_plain(), and theme().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/shortcut Directory Reference

  • modules
  • shortcut
shortcut Directory Reference

Files

file | shortcut.admin.inc [code]
file | shortcut.api.php [code]
file | shortcut.install [code]
file | shortcut.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/shortcut/shortcut.admin.inc File Reference

  • modules
  • shortcut
Functions
shortcut.admin.inc File Reference

Go to the source code of this file.

Functions

shortcut_max_slots ()
shortcut_set_switch ($form, &$form_state, $account=NULL)
shortcut_set_switch_validate ($form, &$form_state)
shortcut_set_switch_submit ($form, &$form_state)
shortcut_set_admin ()
shortcut_set_add_form ($form, &$form_state)
shortcut_set_add_form_validate ($form, &$form_state)
shortcut_set_add_form_submit ($form, &$form_state)
shortcut_set_customize ($form, &$form_state, $shortcut_set)
shortcut_set_customize_submit ($form, &$form_state)
theme_shortcut_set_customize ($variables)
shortcut_link_add ($form, &$form_state, $shortcut_set)
shortcut_link_edit ($form, &$form_state, $shortcut_link)
_shortcut_link_form_elements ($shortcut_link=NULL)
shortcut_link_edit_validate ($form, &$form_state)
shortcut_link_edit_submit ($form, &$form_state)
shortcut_link_add_submit ($form, &$form_state)
shortcut_admin_add_link ($shortcut_link, &$shortcut_set, $limit=NULL)
shortcut_set_edit_form ($form, &$form_state, $shortcut_set)
shortcut_set_edit_form_validate ($form, &$form_state)
shortcut_set_edit_form_submit ($form, &$form_state)
shortcut_set_delete_form ($form, &$form_state, $shortcut_set)
shortcut_set_delete_form_submit ($form, &$form_state)
shortcut_link_delete ($form, &$form_state, $shortcut_link)
shortcut_link_delete_submit ($form, &$form_state)
shortcut_link_add_inline ($shortcut_set)

Detailed Description

Administrative page callbacks for the shortcut module.

Definition in file shortcut.admin.inc.

Function Documentation

_shortcut_link_form_elements ( $shortcut_link = NULL )

Helper function for building a form for adding or editing shortcut links.

Parameters
$shortcut_link (optional) An array representing the shortcut link that will be edited. If not provided, a new link will be created.
Returns
An array of form elements.

Definition at line 466 of file shortcut.admin.inc.

References drupal_get_path_alias(), t(), url(), and variable_get().

Referenced by shortcut_link_add(), and shortcut_link_edit().

shortcut_admin_add_link | ( |  | $shortcut_link,
 |  | & | $shortcut_set,
 |  |  | $limit = NULL
 | ) |  |

Adds a link to the end of a shortcut set, keeping within a prescribed limit.

Parameters
$link | An array representing a shortcut link.
$shortcut_set | An object representing the shortcut set which the link will be added to. The links in the shortcut set will be re-weighted so that the new link is at the end, and some existing links may be disabled (if the $limit parameter is provided).
$limit | (optional) The maximum number of links that are allowed to be enabled for this shortcut set. If provided, existing links at the end of the list that exceed the limit will be automatically disabled. If not provided, no limit will be enforced.

Definition at line 566 of file shortcut.admin.inc.

References drupal_get_normal_path(), and shortcut_set_reset_link_weights().

Referenced by shortcut_link_add_inline(), and shortcut_link_add_submit().

shortcut_link_add_inline ( $shortcut_set )

Menu page callback: creates a new link in the provided shortcut set.

After completion, redirects the user back to where they came from.

Parameters
$shortcut_set Returned from shortcut_set_load().

Definition at line 769 of file shortcut.admin.inc.

References $title, drupal_goto(), drupal_set_message(), drupal_valid_token(), MENU_ACCESS_DENIED, menu_get_item(), shortcut_admin_add_link(), shortcut_max_slots(), shortcut_set_save(), shortcut_valid_link(), and t().

shortcut_link_add_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for shortcut_link_add().

Definition at line 539 of file shortcut.admin.inc.

References drupal_set_message(), shortcut_admin_add_link(), shortcut_max_slots(), shortcut_set_save(), and t().

shortcut_link_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for shortcut_link_delete_submit().

Definition at line 754 of file shortcut.admin.inc.

References drupal_set_message(), menu_link_delete(), and t().

shortcut_link_edit_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for shortcut_link_edit().

Definition at line 521 of file shortcut.admin.inc.

References drupal_get_normal_path(), drupal_set_message(), menu_link_save(), and t().

shortcut_link_edit_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validation handler for the shortcut link add and edit forms.

Definition at line 512 of file shortcut.admin.inc.

References form_set_error(), shortcut_valid_link(), and t().

shortcut_max_slots ( )

Returns the maximum number of shortcut "slots" available per shortcut set.

This is used as a limitation in the user interface only.

Returns
The maximum number of shortcuts allowed to be added to a shortcut set.

Definition at line 16 of file shortcut.admin.inc.

References variable_get().

Referenced by shortcut_link_add_inline(), shortcut_link_add_submit(), and theme_shortcut_set_customize().

shortcut_set_add_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for shortcut_set_add_form().

Definition at line 238 of file shortcut.admin.inc.

References drupal_set_message(), menu_links_clone(), shortcut_default_set(), shortcut_set_save(), and t().

shortcut_set_add_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validation handler for shortcut_set_add_form().

Definition at line 228 of file shortcut.admin.inc.

References form_set_error(), shortcut_set_title_exists(), and t().

shortcut_set_admin ( )

Menu page callback: builds the page for administering shortcut sets.

Definition at line 169 of file shortcut.admin.inc.

References $header, $row, check_plain(), l(), shortcut_set_delete_access(), shortcut_sets(), t(), and theme().

shortcut_set_customize_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for shortcut_set_customize().

Definition at line 318 of file shortcut.admin.inc.

References $links, drupal_set_message(), menu_link_load(), menu_link_save(), and t().

shortcut_set_delete_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for shortcut_set_delete_form().

Definition at line 712 of file shortcut.admin.inc.

References drupal_set_message(), shortcut_set_delete(), shortcut_set_load(), and t().

shortcut_set_edit_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for shortcut_set_edit_form().

Definition at line 648 of file shortcut.admin.inc.

References drupal_set_message(), shortcut_set_save(), and t().

shortcut_set_edit_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validation handler for shortcut_set_edit_form().

Definition at line 637 of file shortcut.admin.inc.

References form_set_error(), shortcut_set_title_exists(), t(), and title.

shortcut_set_switch_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for shortcut_set_switch().

Definition at line 125 of file shortcut.admin.inc.

References current_path(), drupal_set_message(), menu_links_clone(), shortcut_default_set(), shortcut_set_assign_user(), shortcut_set_load(), shortcut_set_save(), t(), and url().

shortcut_set_switch_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validation handler for shortcut_set_switch().

Definition at line 109 of file shortcut.admin.inc.

References form_set_error(), shortcut_set_title_exists(), and t().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/shortcut/shortcut.api.php File Reference

  • modules
  • shortcut
Functions
shortcut.api.php File Reference

Go to the source code of this file.

Functions

hook_shortcut_default_set ($account)

Detailed Description

Hooks provided by the Shortcut module.

Definition in file shortcut.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/shortcut/shortcut.install File Reference

  • modules
  • shortcut
Functions
shortcut.install File Reference

Go to the source code of this file.

Functions

shortcut_install ()
shortcut_uninstall ()
shortcut_schema ()

Detailed Description

Install, update and uninstall functions for the shortcut module.

Definition in file shortcut.install.

Function Documentation

shortcut_install ( )

Implements hook_install().

Definition at line 11 of file shortcut.install.

References drupal_installation_attempted(), get_t(), menu_rebuild(), and shortcut_set_save().

shortcut_schema ( )

Implements hook_schema().

Definition at line 52 of file shortcut.install.

shortcut_uninstall ( )

Implements hook_uninstall().

Definition at line 41 of file shortcut.install.

References drupal_load(), menu_delete_links(), and shortcut_sets().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/shortcut/shortcut.module File Reference

  • modules
  • shortcut
Functions | Variables
shortcut.module File Reference

Go to the source code of this file.

Functions

shortcut_help ($path, $arg)
shortcut_permission ()
shortcut_menu ()
shortcut_admin_paths ()
shortcut_theme ()
shortcut_block_info ()
shortcut_block_view ($delta= '')
shortcut_set_edit_access ($shortcut_set=NULL)
shortcut_set_delete_access ($shortcut_set)
shortcut_set_switch_access ($account=NULL)
shortcut_link_access ($menu_link)
shortcut_set_load ($set_name)
shortcut_set_save (&$shortcut_set)
shortcut_set_delete ($shortcut_set)
shortcut_set_reset_link_weights (&$shortcut_set)
shortcut_set_assign_user ($shortcut_set, $account)
shortcut_set_unassign_user ($account)
shortcut_current_displayed_set ($account=NULL)
shortcut_default_set ($account=NULL)
shortcut_set_get_unique_name ()
shortcut_set_name ($number)
shortcut_sets ()
shortcut_set_title_exists ($title)
shortcut_valid_link ($path)
shortcut_renderable_links ($shortcut_set=NULL)
shortcut_preprocess_page (&$variables)
shortcut_page_alter (&$page)
shortcut_toolbar_pre_render ($toolbar)
shortcut_set_title ($shortcut_set)
shortcut_set_title_callback ($shortcut_set)

Variables

const SHORTCUT_DEFAULT_SET_NAME 'shortcut-set-1'

Detailed Description

Allows users to manage customizable lists of shortcut links.

Definition in file shortcut.module.

Function Documentation

shortcut_admin_paths ( )

Implements hook_admin_paths().

Definition at line 167 of file shortcut.module.

shortcut_block_info ( )

Implements hook_block_info().

Definition at line 189 of file shortcut.module.

References DRUPAL_NO_CACHE, and t().

shortcut_block_view ( $delta = '' )

Implements hook_block_view().

Definition at line 200 of file shortcut.module.

References shortcut_current_displayed_set(), shortcut_renderable_links(), and t().

shortcut_current_displayed_set ( $account = NULL )

Returns the current displayed shortcut set for the provided user account.

Parameters
$account (optional) The user account whose shortcuts will be returned. Defaults to the currently logged-in user.
Returns
An object representing the shortcut set that should be displayed to the current user. If the user does not have an explicit shortcut set defined, the default set is returned.

Definition at line 481 of file shortcut.module.

References db_select(), drupal_static(), shortcut_default_set(), and shortcut_set_load().

Referenced by shortcut_block_view(), shortcut_preprocess_page(), shortcut_renderable_links(), shortcut_set_edit_access(), shortcut_set_switch(), and shortcut_toolbar_pre_render().

shortcut_default_set ( $account = NULL )

Returns the default shortcut set for a given user account.

Parameters
object $account (optional) The user account whose default shortcut set will be returned. If not provided, the function will return the currently logged-in user's default shortcut set.
Returns
An object representing the default shortcut set.

Definition at line 521 of file shortcut.module.

References $name, module_invoke_all(), SHORTCUT_DEFAULT_SET_NAME, and shortcut_set_load().

Referenced by shortcut_current_displayed_set(), shortcut_set_add_form_submit(), shortcut_set_switch(), and shortcut_set_switch_submit().

shortcut_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 19 of file shortcut.module.

References $output, t(), url(), and user_access().

shortcut_link_access ( $menu_link )

Access callback for editing a link in a shortcut set.

Definition at line 293 of file shortcut.module.

References shortcut_set_edit_access(), and shortcut_set_load().

shortcut_menu ( )

Implements hook_menu().

Definition at line 69 of file shortcut.module.

References MENU_CALLBACK, MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION, and MENU_LOCAL_TASK.

shortcut_page_alter ( & $page )

Implements hook_page_alter().

Definition at line 701 of file shortcut.module.

References $page.

shortcut_permission ( )

Implements hook_permission().

Definition at line 50 of file shortcut.module.

References t().

shortcut_preprocess_page ( & $variables )

Implements hook_preprocess_page().

Definition at line 645 of file shortcut.module.

References drupal_get_destination(), drupal_get_path(), drupal_get_query_parameters(), drupal_get_title(), drupal_get_token(), drupal_http_build_query(), menu_get_item(), shortcut_current_displayed_set(), shortcut_set_edit_access(), shortcut_set_switch_access(), t(), and theme_get_setting().

shortcut_renderable_links ( $shortcut_set = NULL )

Returns an array of shortcut links, suitable for rendering.

Parameters
$shortcut_set (optional) An object representing the set whose links will be displayed. If not provided, the user's current set will be displayed.
Returns
An array of shortcut links, in the format returned by the menu system.
See Also
menu_tree()

Definition at line 635 of file shortcut.module.

References menu_tree(), and shortcut_current_displayed_set().

Referenced by shortcut_block_view(), and shortcut_toolbar_pre_render().

shortcut_set_assign_user | ( | $shortcut_set,
 |  | $account
 | ) |

Assigns a user to a particular shortcut set.

Parameters
$shortcut_set | An object representing the shortcut set.
$account | A user account that will be assigned to use the set.

Definition at line 441 of file shortcut.module.

References db_merge(), and drupal_static_reset().

Referenced by shortcut_set_switch_submit().

shortcut_set_delete ( $shortcut_set )

Deletes a shortcut set.

Note that the default set cannot be deleted.

Parameters
$shortcut_set An object representing the shortcut set to delete.
Returns
TRUE if the set was deleted, FALSE otherwise.

Definition at line 391 of file shortcut.module.

References db_delete(), menu_delete_links(), and SHORTCUT_DEFAULT_SET_NAME.

Referenced by shortcut_set_delete_form_submit().

shortcut_set_delete_access ( $shortcut_set )

Access callback for deleting a shortcut set.

Parameters
$shortcut_set The shortcut set to be deleted.
Returns
TRUE if the current user has access to delete shortcut sets and this is not the site-wide default set; FALSE otherwise.

Definition at line 242 of file shortcut.module.

References SHORTCUT_DEFAULT_SET_NAME, and user_access().

Referenced by shortcut_set_admin().

shortcut_set_edit_access ( $shortcut_set = NULL )

Access callback for editing a shortcut set.

Parameters
object $shortcut_set (optional) The shortcut set to be edited. If not set, the current user's shortcut set will be used.
Returns
TRUE if the current user has access to edit the shortcut set, FALSE otherwise.

Definition at line 220 of file shortcut.module.

References shortcut_current_displayed_set(), and user_access().

Referenced by shortcut_link_access(), shortcut_preprocess_page(), and shortcut_toolbar_pre_render().

shortcut_set_get_unique_name ( )

Returns a unique, machine-readable shortcut set name.

Definition at line 545 of file shortcut.module.

References $name, db_query(), shortcut_set_load(), and shortcut_set_name().

Referenced by shortcut_set_save().

shortcut_set_load ( $set_name )

Loads the data for a shortcut set.

Parameters
$set_name The name of the shortcut set to load.
Returns
object If the shortcut set exists, an object containing the following properties:
  • 'set_name': The internal name of the shortcut set.
  • 'title': The title of the shortcut set.
  • 'links': An array of links associated with this shortcut set. If the shortcut set does not exist, the function returns FALSE.

Definition at line 315 of file shortcut.module.

References db_select(), and menu_load_links().

Referenced by shortcut_current_displayed_set(), shortcut_default_set(), shortcut_link_access(), shortcut_set_delete_form_submit(), shortcut_set_get_unique_name(), and shortcut_set_switch_submit().

shortcut_set_name ( $number )

Returns the name of a shortcut set, based on a provided number.

All shortcut sets have names like "shortcut-set-N" so that they can be matched with a properly-namespaced entry in the {menu_links} table.

Parameters
$number A number representing the shortcut set whose name should be retrieved.
Returns
A string representing the expected shortcut name.

Definition at line 571 of file shortcut.module.

Referenced by shortcut_set_get_unique_name().

shortcut_set_reset_link_weights ( & $shortcut_set )

Resets the link weights in a shortcut set to match their current order.

This function can be used, for example, when a new shortcut link is added to the set. If the link is added to the end of the array and this function is called, it will force that link to display at the end of the list.

Parameters
object $shortcut_set An object representing a shortcut set. The link weights of the passed-in object will be reset as described above.

Definition at line 425 of file shortcut.module.

Referenced by shortcut_admin_add_link().

shortcut_set_save ( & $shortcut_set )

Saves a shortcut set.

Parameters
$shortcut_set An object containing the following properties:
  • 'title': The title of the shortcut set.
  • 'set_name': (optional) The internal name of the shortcut set. If omitted, a new shortcut set will be created, and the 'set_name' property will be added to the passed-in object.
  • 'links': (optional) An array of menu links to save for the shortcut set. Each link is an array containing at least the following keys (which will be expanded to fill in other default values after the shortcut set is saved):
    • 'link_path': The Drupal path or external path that the link points to.
    • 'link_title': The title of the link. Any other keys accepted by menu_link_save() may also be provided.
Returns
A constant which is either SAVED_NEW or SAVED_UPDATED depending on whether a new set was created or an existing one was updated.
See Also
menu_link_save()

Definition at line 351 of file shortcut.module.

References drupal_write_record(), menu_link_save(), SAVED_UPDATED, and shortcut_set_get_unique_name().

Referenced by shortcut_install(), shortcut_link_add_inline(), shortcut_link_add_submit(), shortcut_set_add_form_submit(), shortcut_set_edit_form_submit(), and shortcut_set_switch_submit().

shortcut_set_switch_access ( $account = NULL )

Access callback for switching the shortcut set assigned to a user account.

Parameters
object $account (optional) The user account whose shortcuts will be switched. If not set, permissions will be checked for switching the logged-in user's own shortcut set.
Returns
TRUE if the current user has access to switch the shortcut set of the provided account, FALSE otherwise.

Definition at line 268 of file shortcut.module.

References user_access().

Referenced by shortcut_preprocess_page().

shortcut_set_title ( $shortcut_set )

Returns the sanitized title of a shortcut set.

Deprecated. This function was previously used as a menu item title callback but has been replaced by shortcut_set_title_callback() (which does not sanitize the title, since the menu system does that automatically). In Drupal 7, use that function for title callbacks, and call check_plain() directly if you need a sanitized title. In Drupal 8, this function will be restored as a title callback and therefore will no longer sanitize its output.

Parameters
$shortcut_set An object representing the shortcut set, as returned by shortcut_set_load().

Definition at line 752 of file shortcut.module.

References check_plain().

shortcut_set_title_callback ( $shortcut_set )

Returns the title of a shortcut set.

Title callback for the editing pages for shortcut sets.

Parameters
$shortcut_set An object representing the shortcut set, as returned by shortcut_set_load().

Definition at line 765 of file shortcut.module.

shortcut_set_title_exists ( $title )

Check to see if a shortcut set with the given title already exists.

Parameters
$title Human-readable name of the shortcut set to check.
Returns
TRUE if a shortcut set with that title exists; FALSE otherwise.

Definition at line 599 of file shortcut.module.

References $title, and db_query_range().

Referenced by shortcut_set_add_form_validate(), shortcut_set_edit_form_validate(), and shortcut_set_switch_validate().

shortcut_set_unassign_user ( $account )

Unassigns a user from any shortcut set they may have been assigned to.

The user will go back to using whatever default set applies.

Parameters
$account A user account that will be removed from the shortcut set assignment.
Returns
TRUE if the user was previously assigned to a shortcut set and has been successfully removed from it. FALSE if the user was already not assigned to any set.

Definition at line 462 of file shortcut.module.

References db_delete().

shortcut_sets ( )

Returns an array of all shortcut sets, keyed by the set name.

Returns
An array of shortcut sets. Note that only the basic shortcut set properties (name and title) are returned by this function, not the list of menu links that belong to the set.

Definition at line 583 of file shortcut.module.

References db_select().

Referenced by shortcut_set_admin(), shortcut_set_switch(), and shortcut_uninstall().

shortcut_theme ( )

Implements hook_theme().

Definition at line 177 of file shortcut.module.

shortcut_toolbar_pre_render ( $toolbar )

Pre-render function for adding shortcuts to the toolbar drawer.

Definition at line 712 of file shortcut.module.

References $links, drupal_get_path(), shortcut_current_displayed_set(), shortcut_renderable_links(), shortcut_set_edit_access(), and t().

shortcut_valid_link ( $path )

Determines if a path corresponds to a valid shortcut link.

Parameters
$path The path to the link.
Returns
TRUE if the shortcut link is valid, FALSE otherwise. Valid links are ones that correspond to actual paths on the site.
See Also
menu_edit_item_validate()

Definition at line 614 of file shortcut.module.

References drupal_get_normal_path(), menu_get_item(), and url_is_external().

Referenced by shortcut_link_add_inline(), and shortcut_link_edit_validate().

Variable Documentation

const SHORTCUT_DEFAULT_SET_NAME 'shortcut-set-1'

The name of the default shortcut set.

This set will be displayed to any user that does not have another set assigned, unless overridden by a hook_shortcut_default_set() implementation.

Definition at line 14 of file shortcut.module.

Referenced by shortcut_default_set(), shortcut_set_delete(), and shortcut_set_delete_access().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/simpletest Directory Reference

  • modules
  • simpletest
simpletest Directory Reference

Directories

directory files

Files

file | drupal_web_test_case.php [code]
file | simpletest.api.php [code]
file | simpletest.install [code]
file | simpletest.module [code]
file | simpletest.pages.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/simpletest/files Directory Reference

  • modules
  • simpletest
  • files
files Directory Reference

Files

file php-2.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/simpletest/files/php-2.php File Reference

  • modules
  • simpletest
  • files
Variables
php-2.php File Reference

Go to the source code of this file.

Variables

print

Variable Documentation

print

Definition at line 2 of file php-2.php.

Referenced by _batch_progress_page_nojs(), _drupal_exception_handler(), _drupal_log_error(), _drupal_session_write(), _drupal_shutdown_function(), _locale_export_po(), ajax_deliver(), book_export(), dashboard_show_block_content(), dashboard_show_disabled(), drupal_block_denied(), drupal_deliver_html_page(), drupal_fast_404(), drupal_serve_page_from_cache(), file_transfer(), image_style_deliver(), install_display_output(), node_feed(), openid_redirect(), overlay_ajax_render_region(), overlay_deliver_empty_page(), php_eval(), taxonomy_autocomplete(), theme_aggregator_page_opml(), theme_aggregator_page_rss(), update_check_requirements(), update_prepare_d7_bootstrap(), and xmlrpc_server().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/simpletest/drupal_web_test_case.php File Reference

  • modules
  • simpletest
Classes | Functions | Variables
drupal_web_test_case.php File Reference

Go to the source code of this file.

Classes

class | DrupalTestCase
class | DrupalUnitTestCase
class | DrupalWebTestCase

Functions

simpletest_verbose ($message, $original_file_directory=NULL, $test_class=NULL)

Variables

global $drupal_test_info

Function Documentation

simpletest_verbose | ( | $message,
 |  | $original_file_directory = NULL,
 |  | $test_class = NULL
 | ) |

Logs verbose message in a text file.

If verbose mode is enabled then page requests will be dumped to a file and presented on the test result screen. The messages will be placed in a file located in the simpletest directory in the original file system.

Parameters
$message | The verbose message to be stored.
$original_file_directory | The original file directory, before it was changed for testing purposes.
$test_class | The active test case class.
Returns
The ID of the message to be placed in related assertion messages.
See Also
DrupalTestCase->originalFileDirectory
DrupalWebTestCase->verbose()

Definition at line 3680 of file drupal_web_test_case.php.

References FILE_CREATE_DIRECTORY, file_prepare_directory(), and variable_get().

Referenced by DrupalTestCase\run(), and DrupalTestCase\verbose().

Variable Documentation

global $drupal_test_info

Definition at line 13 of file drupal_web_test_case.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/simpletest/simpletest.api.php File Reference

  • modules
  • simpletest
Functions
simpletest.api.php File Reference

Go to the source code of this file.

Functions

hook_simpletest_alter (&$groups)
hook_test_group_started ()
hook_test_group_finished ()
hook_test_finished ($results)

Detailed Description

Hooks provided by the SimpleTest module.

Definition in file simpletest.api.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/simpletest/simpletest.install File Reference

  • modules
  • simpletest
Functions | Variables
simpletest.install File Reference

Go to the source code of this file.

Functions

simpletest_requirements ($phase)
simpletest_schema ()
simpletest_uninstall ()

Variables

const SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT '64M'

Detailed Description

Install, update and uninstall functions for the simpletest module.

Definition in file simpletest.install.

Function Documentation

simpletest_requirements ( $phase )

Implements hook_requirements().

Definition at line 16 of file simpletest.install.

References drupal_check_memory_limit(), get_t(), REQUIREMENT_ERROR, SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT, and url().

simpletest_schema ( )

Implements hook_schema().

Definition at line 77 of file simpletest.install.

simpletest_uninstall ( )

Implements hook_uninstall().

Definition at line 169 of file simpletest.install.

References drupal_load(), file_unmanaged_delete_recursive(), simpletest_clean_database(), and variable_del().

Variable Documentation

const SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT '64M'

Minimum value of PHP memory_limit for SimpleTest.

Definition at line 11 of file simpletest.install.

Referenced by simpletest_requirements().

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/simpletest/simpletest.module File Reference

  • modules
  • simpletest
Functions
simpletest.module File Reference

Go to the source code of this file.

Functions

simpletest_help ($path, $arg)
simpletest_menu ()
simpletest_permission ()
simpletest_theme ()
simpletest_js_alter (&$javascript)
_simpletest_format_summary_line ($summary)
simpletest_run_tests ($test_list, $reporter= 'drupal')
_simpletest_batch_operation ($test_list_init, $test_id, &$context)
_simpletest_batch_finished ($success, $results, $operations, $elapsed)
simpletest_last_test_get ($test_id)
simpletest_log_read ($test_id, $prefix, $test_class, $during_test=FALSE)
simpletest_test_get_all ()
simpletest_classloader_register ()
_simpletest_autoload_psr0 ($class)
simpletest_registry_files_alter (&$files, $modules)
simpletest_generate_file ($filename, $width, $lines, $type= 'binary-text')
simpletest_clean_environment ()
simpletest_clean_database ()
simpletest_clean_temporary_directories ()
simpletest_clean_results_table ($test_id=NULL)
simpletest_mail_alter (&$message)

Detailed Description

Provides testing functionality.

Definition in file simpletest.module.

Function Documentation

_simpletest_autoload_psr0 ( $class )

Autoload callback to find PSR-0 test classes.

This will only work on classes where the namespace is of the pattern "Drupal\$extension\Tests\.."

Definition at line 419 of file simpletest.module.

References db_query().

_simpletest_batch_finished | ( | $success,
 |  | $results,
 |  | $operations,
 |  | $elapsed
 | ) |

Definition at line 208 of file simpletest.module.

References drupal_set_message(), module_invoke_all(), simpletest_last_test_get(), simpletest_log_read(), and t().

_simpletest_batch_operation | ( |  | $test_list_init,
 |  |  | $test_id,
 |  | & | $context
 | ) |  |

Batch operation callback.

Definition at line 159 of file simpletest.module.

References $info, $value, _simpletest_format_summary_line(), element_children(), module_invoke_all(), simpletest_classloader_register(), t(), and theme().

_simpletest_format_summary_line ( $summary )

Definition at line 103 of file simpletest.module.

References format_plural(), and t().

Referenced by _simpletest_batch_operation(), and theme_simpletest_result_summary().

simpletest_classloader_register ( )

Definition at line 398 of file simpletest.module.

Referenced by _simpletest_batch_operation(), simpletest_result_form(), simpletest_test_form_submit(), and simpletest_test_get_all().

simpletest_clean_database ( )

Removed prefixed tables from the database that are left over from crashed tests.

Definition at line 537 of file simpletest.module.

References db_drop_table(), db_find_tables(), drupal_get_schema_unprocessed(), drupal_set_message(), format_plural(), Database::getConnection(), and t().

Referenced by simpletest_clean_environment(), and simpletest_uninstall().

simpletest_clean_environment ( )

Remove all temporary database tables and directories.

Definition at line 518 of file simpletest.module.

References cache_clear_all(), drupal_set_message(), format_plural(), registry_rebuild(), simpletest_clean_database(), simpletest_clean_results_table(), simpletest_clean_temporary_directories(), t(), and variable_get().

simpletest_clean_results_table ( $test_id = NULL )

Clear the test result tables.

Parameters
$test_id Test ID to remove results for, or NULL to remove all results.
Returns
The number of results removed.

Definition at line 590 of file simpletest.module.

References db_delete(), db_query(), and variable_get().

Referenced by simpletest_clean_environment(), and simpletest_result_form().

simpletest_clean_temporary_directories ( )

Find all leftover temporary directories and remove them.

Definition at line 561 of file simpletest.module.

References drupal_set_message(), file_unmanaged_delete_recursive(), format_plural(), and t().

Referenced by simpletest_clean_environment().

simpletest_generate_file | ( | $filename,
 |  | $width,
 |  | $lines,
 |  | $type = 'binary-text'
 | ) |

Generate test file.

Definition at line 489 of file simpletest.module.

Referenced by DrupalWebTestCase::drupalGetTestFiles().

simpletest_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file simpletest.module.

References $output, t(), and url().

simpletest_js_alter ( & $javascript )

Implements hook_js_alter().

Definition at line 94 of file simpletest.module.

References drupal_get_path().

simpletest_last_test_get ( $test_id )

Get information about the last test that ran given a test ID.

Parameters
$test_id The test ID to get the last test from.
Returns
Array containing the last database prefix used and the last test class that ran.

Definition at line 237 of file simpletest.module.

References db_query_range().

Referenced by _simpletest_batch_finished().

simpletest_log_read | ( | $test_id,
 |  | $prefix,
 |  | $test_class,
 |  | $during_test = FALSE
 | ) |

Read the error log and report any errors as assertion failures.

The errors in the log should only be fatal errors since any other errors will have been recorded by the error handler.

Parameters
$test_id | The test ID to which the log relates.
$prefix | The database prefix to which the log relates.
$test_class | The test class to which the log relates.
$during_test | Indicates that the current file directory path is a temporary file file directory used during testing.
Returns
Found any entries in log.

Definition at line 261 of file simpletest.module.

References DrupalTestCase::insertAssert().

Referenced by _simpletest_batch_finished(), and DrupalWebTestCase::tearDown().

simpletest_mail_alter ( & $message )

Implements hook_mail_alter().

Aborts sending of messages with ID 'simpletest_cancel_test'.

See Also
MailTestCase::testCancelMessage()

Definition at line 622 of file simpletest.module.

simpletest_menu ( )

Implements hook_menu().

Definition at line 30 of file simpletest.module.

References MENU_DEFAULT_LOCAL_TASK, and MENU_LOCAL_TASK.

simpletest_permission ( )

Implements hook_permission().

Definition at line 66 of file simpletest.module.

References t().

simpletest_registry_files_alter | ( | & | $files,
 |  |  | $modules
 | ) |  |

Implements hook_registry_files_alter().

Add the test files for disabled modules so that we get a list containing all the avialable tests.

Definition at line 469 of file simpletest.module.

References $dir, and $module.

simpletest_run_tests | ( | $test_list,
 |  | $reporter = 'drupal'
 | ) |

Actually runs tests.

Parameters
$test_list | List of tests to run.
$reporter | Which reporter to use. Allowed values are: text, xml, html and drupal, drupal being the default.

Definition at line 125 of file simpletest.module.

References $info, batch_set(), db_insert(), drupal_get_path(), file_unmanaged_delete_recursive(), module_invoke_all(), and t().

Referenced by simpletest_test_form_submit().

simpletest_test_get_all ( )

Get a list of all of the tests provided by the system.

The list of test classes is loaded from the registry where it looks for files ending in ".test". Once loaded the test list is cached and stored in a static variable. In order to list tests provided by disabled modules hook_registry_files_alter() is used to forcefully add them to the registry.

PSR-0 classes are found by searching the designated directory for each module for files matching the PSR-0 standard.

Returns
An array of tests keyed with the groups specified in each of the tests getInfo() method and then keyed by the test class. An example of the array structure is provided below.
* $groups['Blog'] => array(
* 'BlogTestCase' => array(
* 'name' => 'Blog functionality',
* 'description' => 'Create, view, edit, delete, ...',
* 'group' => 'Blog',
* ),
* );
*
See Also
simpletest_registry_files_alter()

Definition at line 312 of file simpletest.module.

References $classes, $info, $module, $name, cache_get(), cache_set(), db_query(), drupal_alter(), drupal_get_filename(), DRUPAL_ROOT, drupal_static(), file_scan_directory(), and simpletest_classloader_register().

Referenced by simpletest_test_form().

simpletest_theme ( )

Implements hook_theme().

Definition at line 78 of file simpletest.module.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/simpletest/simpletest.pages.inc File Reference

  • modules
  • simpletest
Functions
simpletest.pages.inc File Reference

Go to the source code of this file.

Functions

simpletest_test_form ($form)
theme_simpletest_test_table ($variables)
simpletest_test_form_submit ($form, &$form_state)
simpletest_result_form ($form, &$form_state, $test_id)
simpletest_result_form_submit ($form, &$form_state)
theme_simpletest_result_summary ($variables)
simpletest_result_get ($test_id)
simpletest_result_status_image ($status)
simpletest_settings_form ($form, &$form_state)
simpletest_settings_form_validate ($form, &$form_state)

Detailed Description

Page callbacks for simpletest module.

Definition in file simpletest.pages.inc.

Function Documentation

simpletest_result_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $test_id
 | ) |  |

Test results form for $test_id.

Definition at line 206 of file simpletest.pages.inc.

References $header, $info, $results, $row, drupal_add_css(), drupal_basename(), drupal_get_path(), drupal_goto(), drupal_set_message(), simpletest_classloader_register(), simpletest_clean_results_table(), simpletest_result_get(), simpletest_result_status_image(), t(), and url().

simpletest_result_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Re-run the tests that match the filter.

Definition at line 342 of file simpletest.pages.inc.

References $classes, and simpletest_test_form_submit().

simpletest_result_get ( $test_id )

Get test results for $test_id.

Parameters
$test_id The test_id to retrieve results of.
Returns
Array of results grouped by test_class.

Definition at line 390 of file simpletest.pages.inc.

References $results, and db_select().

Referenced by simpletest_result_form().

simpletest_result_status_image ( $status )

Get the appropriate image for the status.

Parameters
$status Status string, either: pass, fail, exception.
Returns
HTML image or false.

Definition at line 414 of file simpletest.pages.inc.

References t(), and theme().

Referenced by simpletest_result_form().

simpletest_settings_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validation handler for simpletest_settings_form().

Definition at line 500 of file simpletest.pages.inc.

References form_set_error(), t(), and variable_get().

simpletest_test_form ( $form )

List tests arranged in groups that can be selected and run.

Definition at line 11 of file simpletest.pages.inc.

References $info, simpletest_test_get_all(), and t().

simpletest_test_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Run selected tests.

Definition at line 183 of file simpletest.pages.inc.

References $value, drupal_set_message(), simpletest_classloader_register(), simpletest_run_tests(), and t().

Referenced by simpletest_result_form_submit().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/statistics Directory Reference

  • modules
  • statistics
statistics Directory Reference

Files

file | statistics.admin.inc [code]
file | statistics.install [code]
file | statistics.module [code]
file | statistics.pages.inc [code]
file | statistics.php [code]
file | statistics.tokens.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/statistics/statistics.admin.inc File Reference

  • modules
  • statistics
Functions
statistics.admin.inc File Reference

Go to the source code of this file.

Functions

statistics_recent_hits ()
statistics_top_pages ()
statistics_top_visitors ()
statistics_top_referrers ()
statistics_access_log ($aid)
statistics_settings_form ()

Detailed Description

Admin page callbacks for the Statistics module.

Definition in file statistics.admin.inc.

Function Documentation

statistics_access_log ( $aid )

Page callback: Gathers page access statistics suitable for rendering.

Parameters
$aid The unique accesslog ID.
Returns
A render array containing page access statistics. If information for the page was not found, drupal_not_found() is called.

Definition at line 230 of file statistics.admin.inc.

References check_plain(), db_query(), format_date(), l(), MENU_NOT_FOUND, t(), theme(), and url().

statistics_recent_hits ( )

Page callback: Displays the "recent hits" page.

This displays the pages with recent hits in a given time interval that haven't been flushed yet. The flush interval is set on the statistics settings form, but is dependent on cron running.

Returns
A render array containing information about the most recent hits.

Definition at line 18 of file statistics.admin.inc.

References $header, _statistics_format_item(), db_select(), format_date(), l(), t(), and theme().

statistics_top_pages ( )

Page callback: Displays statistics for the "top pages" (most accesses).

This displays the pages with the most hits (the "top pages") within a given time period that haven't been flushed yet. The flush interval is set on the statistics settings form, but is dependent on cron running.

Returns
A render array containing information about the the top pages.

Definition at line 64 of file statistics.admin.inc.

References $header, $page, _statistics_format_item(), db_select(), drupal_set_title(), format_interval(), PASS_THROUGH, t(), and variable_get().

statistics_top_referrers ( )

Page callback: Displays the "top referrers" in the access logs.

This displays the pages with the top referrers in a given time interval that haven't been flushed yet. The flush interval is set on the statistics settings form, but is dependent on cron running.

Returns
A render array containing the top referrers information.

Definition at line 177 of file statistics.admin.inc.

References $header, _statistics_link(), db_select(), drupal_set_title(), format_interval(), PASS_THROUGH, REQUEST_TIME, t(), and variable_get().

statistics_top_visitors ( )

Page callback: Displays the "top visitors" page.

This displays the pages with the top number of visitors in a given time interval that haven't been flushed yet. The flush interval is set on the statistics settings form, but is dependent on cron running.

Returns
A render array containing the top visitors information.

Definition at line 117 of file statistics.admin.inc.

References $header, db_select(), drupal_get_destination(), drupal_set_title(), format_interval(), l(), PASS_THROUGH, t(), theme(), user_access(), and variable_get().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/statistics/statistics.install File Reference

  • modules
  • statistics
Functions
statistics.install File Reference

Go to the source code of this file.

Functions

statistics_uninstall ()
statistics_schema ()
statistics_update_7000 ()

Detailed Description

Install, update, and uninstall functions for the Statistics module.

Definition in file statistics.install.

Function Documentation

statistics_schema ( )

Implements hook_schema().

Definition at line 26 of file statistics.install.

statistics_uninstall ( )

Implements hook_uninstall().

Definition at line 11 of file statistics.install.

References variable_del().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/statistics/statistics.module File Reference

  • modules
  • statistics
Functions
statistics.module File Reference

Go to the source code of this file.

Functions

statistics_help ($path, $arg)
statistics_exit ()
statistics_permission ()
statistics_node_view ($node, $view_mode)
statistics_menu ()
statistics_user_cancel ($edit, $account, $method)
statistics_user_delete ($account)
statistics_cron ()
statistics_title_list ($dbfield, $dbrows)
statistics_get ($nid)
statistics_block_info ()
statistics_block_configure ($delta= '')
statistics_block_save ($delta= '', $edit=array())
statistics_block_view ($delta= '')
_statistics_link ($path, $width=35)
_statistics_format_item ($title, $path)
statistics_node_delete ($node)
statistics_ranking ()
statistics_update_index ()

Detailed Description

Logs and displays access statistics for a site.

Definition in file statistics.module.

Function Documentation

_statistics_format_item | ( | $title,
 |  | $path
 | ) |

Formats an item for display, including both the item title and the link.

Parameters
$title | The text to link to a path; will be truncated to a maximum width of 35.
$path | The path to link to; will default to '/'.
Returns
An HTML string with $title linked to the $path.

Definition at line 421 of file statistics.module.

References $output, $title, and _statistics_link().

Referenced by statistics_recent_hits(), statistics_top_pages(), and statistics_user_tracker().

_statistics_link | ( | $path,
 |  | $width = 35
 | ) |

Generates a link to a path, truncating the displayed text to a given width.

Parameters
$path | The path to generate the link for.
$width | The width to set the displayed text of the path.
Returns
A string as a link, truncated to the width, linked to the given $path.

Definition at line 404 of file statistics.module.

References $title, drupal_get_path_alias(), l(), and truncate_utf8().

Referenced by _statistics_format_item(), statistics_node_tracker(), and statistics_top_referrers().

statistics_block_configure ( $delta = '' )

Implements hook_block_configure().

Definition at line 342 of file statistics.module.

References drupal_map_assoc(), t(), and variable_get().

statistics_block_info ( )

Implements hook_block_info().

Definition at line 328 of file statistics.module.

References DRUPAL_NO_CACHE, t(), and variable_get().

statistics_block_save | ( | $delta = '',
 |  | $edit = array()
 | ) |

Implements hook_block_save().

Definition at line 354 of file statistics.module.

References variable_set().

statistics_block_view ( $delta = '' )

Implements hook_block_view().

Definition at line 363 of file statistics.module.

References $content, node_title_list(), statistics_title_list(), t(), user_access(), and variable_get().

statistics_cron ( )

Implements hook_cron().

Definition at line 248 of file statistics.module.

References db_delete(), db_update(), REQUEST_TIME, variable_get(), and variable_set().

statistics_exit ( )

Implements hook_exit().

Gathers statistics for page accesses.

Definition at line 50 of file statistics.module.

References arg(), db_insert(), db_merge(), drupal_bootstrap(), DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_VARIABLES, drupal_get_title(), DRUPAL_ROOT, ip_address(), REQUEST_TIME, timer_read(), truncate_utf8(), and variable_get().

statistics_get ( $nid )

Retrieves a node's "view statistics".

Parameters
$nid The node ID.
Returns
An associative array containing:
  • totalcount: Integer for the total number of times the node has been viewed.
  • daycount: Integer for the total number of times the node has been viewed "today". For the daycount to be reset, cron must be enabled.
  • timestamp: Integer for the timestamp of when the node was last viewed.

Definition at line 317 of file statistics.module.

References db_query().

Referenced by statistics_node_view(), and statistics_tokens().

statistics_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file statistics.module.

References $output, t(), and url().

statistics_menu ( )

Implements hook_menu().

Definition at line 152 of file statistics.module.

References MENU_LOCAL_TASK.

statistics_node_delete ( $node )

Implements hook_node_delete().

Definition at line 431 of file statistics.module.

References db_delete().

statistics_node_view | ( | $node,
 |  | $view_mode
 | ) |

Implements hook_node_view().

Definition at line 117 of file statistics.module.

References $links, drupal_get_path(), format_plural(), node_is_page(), statistics_get(), url(), user_access(), and variable_get().

statistics_permission ( )

Implements hook_permission().

Definition at line 100 of file statistics.module.

References t().

statistics_ranking ( )

Implements hook_ranking().

Definition at line 441 of file statistics.module.

References t(), and variable_get().

statistics_title_list | ( | $dbfield,
 |  | $dbrows
 | ) |

Returns the most viewed content of all time, today, or the last-viewed node.

Parameters
$dbfield The database field to use, one of:
  • 'totalcount': Integer that shows the top viewed content of all time.
  • 'daycount': Integer that shows the top viewed content for today.
  • 'timestamp': Integer that shows only the last viewed node.
$dbrows The number of rows to be returned.
Returns
SelectQuery|FALSE A query result containing the node ID, title, user ID that owns the node, and the username for the selected node(s), or FALSE if the query could not be executed correctly.

Definition at line 283 of file statistics.module.

References db_select().

Referenced by statistics_block_view().

statistics_update_index ( )

Implements hook_update_index().

Definition at line 463 of file statistics.module.

References db_query(), and variable_set().

statistics_user_cancel | ( | $edit,
 |  | $account,
 |  | $method
 | ) |

Implements hook_user_cancel().

Definition at line 225 of file statistics.module.

References db_update().

statistics_user_delete ( $account )

Implements hook_user_delete().

Definition at line 239 of file statistics.module.

References db_delete().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/statistics/statistics.pages.inc File Reference

  • modules
  • statistics
Functions
statistics.pages.inc File Reference

Go to the source code of this file.

Functions

statistics_node_tracker ()
statistics_user_tracker ()

Detailed Description

User page callbacks for the Statistics module.

Definition in file statistics.pages.inc.

Function Documentation

statistics_node_tracker ( )

Page callback: Displays statistics for a node.

Returns
A render array containing node statistics. If information for the node was not found, this will deliver a page not found error via drupal_not_found().

Definition at line 15 of file statistics.pages.inc.

References $header, _statistics_link(), arg(), db_or(), db_select(), drupal_set_title(), format_date(), l(), MENU_NOT_FOUND, node_load(), t(), and theme().

statistics_user_tracker ( )

Page callback: Displays statistics for a user.

Returns
array A render array containing user statistics. If information for the user was not found, this will deliver a page not found error via drupal_not_found().

Definition at line 67 of file statistics.pages.inc.

References $header, _statistics_format_item(), arg(), db_select(), drupal_set_title(), format_date(), format_username(), l(), MENU_NOT_FOUND, t(), and user_load().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/statistics/statistics.php File Reference

  • modules
  • statistics
Variables
statistics.php File Reference

Go to the source code of this file.

Variables

const DRUPAL_ROOT substr($_SERVER['SCRIPT_FILENAME'], 0, strpos($_SERVER['SCRIPT_FILENAME'], '/modules/statistics/statistics.php'))

Detailed Description

Handles counts of node views via Ajax with minimal bootstrap.

Definition in file statistics.php.

Variable Documentation

const DRUPAL_ROOT substr($_SERVER['SCRIPT_FILENAME'], 0, strpos($_SERVER['SCRIPT_FILENAME'], '/modules/statistics/statistics.php'))

Root directory of Drupal installation.

Definition at line 11 of file statistics.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/statistics/statistics.tokens.inc File Reference

  • modules
  • statistics
Functions
statistics.tokens.inc File Reference

Go to the source code of this file.

Functions

statistics_token_info ()
statistics_tokens ($type, $tokens, array $data=array(), array $options=array())

Detailed Description

Builds placeholder replacement tokens for node visitor statistics.

Definition in file statistics.tokens.inc.

Function Documentation

statistics_token_info ( )

Implements hook_token_info().

Definition at line 11 of file statistics.tokens.inc.

References t().

statistics_tokens | ( |  | $type,
 |  |  | $tokens,
 |  | array | $data = array(),
 |  | array | $options = array()
 | ) |  |

Implements hook_tokens().

Definition at line 34 of file statistics.tokens.inc.

References $name, format_date(), statistics_get(), token_find_with_prefix(), and token_generate().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/syslog Directory Reference

  • modules
  • syslog
syslog Directory Reference

Files

file | syslog.install [code]
file | syslog.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/syslog/syslog.install File Reference

  • modules
  • syslog
Functions
syslog.install File Reference

Go to the source code of this file.

Functions

syslog_uninstall ()

Detailed Description

Install, update and uninstall functions for the syslog module.

Definition in file syslog.install.

Function Documentation

syslog_uninstall ( )

Implements hook_uninstall().

Definition at line 11 of file syslog.install.

References variable_del().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/syslog/syslog.module File Reference

  • modules
  • syslog
Functions | Variables
syslog.module File Reference

Go to the source code of this file.

Functions

syslog_help ($path, $arg)
syslog_form_system_logging_settings_alter (&$form, &$form_state)
syslog_facility_list ()
syslog_watchdog (array $log_entry)

Variables

if(defined('LOG_LOCAL0')) else

Detailed Description

Redirects logging messages to syslog.

Definition in file syslog.module.

Function Documentation

syslog_facility_list ( )

Lists all possible syslog facilities for UNIX/Linux.

Returns
array An array of syslog facilities for UNIX/Linux.

Definition at line 79 of file syslog.module.

Referenced by syslog_form_system_logging_settings_alter().

syslog_form_system_logging_settings_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 47 of file syslog.module.

References $help, l(), module_exists(), syslog_facility_list(), t(), and variable_get().

syslog_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 27 of file syslog.module.

References $output, and t().

syslog_watchdog ( array $log_entry )

Implements hook_watchdog().

Definition at line 95 of file syslog.module.

References $base_url, drupal_static(), and variable_get().

Variable Documentation

if (defined('LOG_LOCAL0')) else
Initial value:
{
define('DEFAULT_SYSLOG_FACILITY', LOG_USER)

Definition at line 20 of file syslog.module.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system Directory Reference

  • modules
  • system
system Directory Reference

Files

file | html.tpl.php [code]
file | image.gd.inc [code]
file | language.api.php [code]
file | maintenance-page.tpl.php [code]
file | page.tpl.php [code]
file | region.tpl.php [code]
file | system.admin.inc [code]
file | system.api.php [code]
file | system.archiver.inc [code]
file | system.install [code]
file | system.mail.inc [code]
file | system.module [code]
file | system.queue.inc [code]
file | system.tar.inc [code]
file | system.tokens.inc [code]
file | system.updater.inc [code]
file | theme.api.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/image.gd.inc File Reference

  • modules
  • system
Functions
image.gd.inc File Reference

Go to the source code of this file.

Functions

image_gd_settings ()
image_gd_settings_validate ($form, &$form_state)
image_gd_check_settings ()
image_gd_resize (stdClass $image, $width, $height)
image_gd_rotate (stdClass $image, $degrees, $background=NULL)
image_gd_crop (stdClass $image, $x, $y, $width, $height)
image_gd_desaturate (stdClass $image)
image_gd_load (stdClass $image)
image_gd_save (stdClass $image, $destination)
image_gd_create_tmp (stdClass $image, $width, $height)
image_gd_get_info (stdClass $image)

Detailed Description

GD2 toolkit for image manipulation within Drupal.

Definition in file image.gd.inc.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/language.api.php File Reference

  • modules
  • system
Functions
language.api.php File Reference

Go to the source code of this file.

Functions

hook_language_init ()
hook_language_switch_links_alter (array &$links, $type, $path)
hook_language_types_info ()
hook_language_types_info_alter (array &$language_types)
hook_language_negotiation_info ()
hook_language_negotiation_info_alter (array &$language_providers)
hook_language_fallback_candidates_alter (array &$fallback_candidates)

Detailed Description

Hooks provided by the base system for language support.

Definition in file language.api.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.admin.inc File Reference

  • modules
  • system
Functions
system.admin.inc File Reference

Go to the source code of this file.

Functions

system_admin_config_page ()
system_admin_menu_block_page ()
system_admin_index ()
system_settings_overview ()
system_themes_page ()
system_themes_admin_form ($form, &$form_state, $theme_options)
system_themes_admin_form_submit ($form, &$form_state)
system_theme_enable ()
system_theme_disable ()
system_theme_default ()
system_theme_settings ($form, &$form_state, $key= '')
system_theme_settings_validate ($form, &$form_state)
_system_theme_settings_validate_path ($path)
system_theme_settings_submit ($form, &$form_state)
_system_is_incompatible (&$incompatible, $files, $file)
system_modules ($form, $form_state=array())
system_sort_modules_by_info_name ($a, $b)
system_sort_themes ($a, $b)
_system_modules_build_row ($info, $extra)
system_modules_confirm_form ($modules, $storage)
system_modules_submit ($form, &$form_state)
system_modules_uninstall ($form, $form_state=NULL)
system_modules_uninstall_confirm_form ($storage)
system_modules_uninstall_validate ($form, &$form_state)
system_modules_uninstall_submit ($form, &$form_state)
system_ip_blocking ($default_ip= '')
system_ip_blocking_form ($form, $form_state, $default_ip)
system_ip_blocking_form_validate ($form, &$form_state)
system_ip_blocking_form_submit ($form, &$form_state)
system_ip_blocking_delete ($form, &$form_state, $iid)
system_ip_blocking_delete_submit ($form, &$form_state)
system_site_information_settings ()
system_site_information_settings_validate ($form, &$form_state)
system_cron_settings ()
system_run_cron_submit ($form, &$form_state)
system_logging_settings ()
system_performance_settings ()
system_clear_cache_submit ($form, &$form_state)
system_clear_page_cache_submit ($form, &$form_state)
system_file_system_settings ()
system_image_toolkit_settings ()
system_rss_feeds_settings ()
system_regional_settings ()
system_date_time_settings ()
theme_system_date_time_settings ($variables)
system_add_date_format_type_form ($form, &$form_state)
system_add_date_format_type_form_validate ($form, &$form_state)
system_add_date_format_type_form_submit ($form, &$form_state)
system_date_time_lookup ()
system_site_maintenance_mode ()
system_clean_url_settings ($form, &$form_state)
system_status ($check=FALSE)
system_run_cron ()
system_php ()
system_batch_page ()
theme_admin_block ($variables)
theme_admin_block_content ($variables)
theme_admin_page ($variables)
theme_system_admin_index ($variables)
theme_status_report ($variables)
theme_system_modules_fieldset ($variables)
theme_system_modules_incompatible ($variables)
theme_system_modules_uninstall ($variables)
theme_system_themes_page ($variables)
system_date_delete_format_form ($form, &$form_state, $dfid)
system_date_delete_format_form_submit ($form, &$form_state)
system_delete_date_format_type_form ($form, &$form_state, $format_type)
system_delete_date_format_type_form_submit ($form, &$form_state)
system_date_time_formats ()
system_configure_date_formats_form ($form, &$form_state, $dfid=0)
system_add_date_formats_form_validate ($form, &$form_state)
system_add_date_formats_form_submit ($form, &$form_state)
system_actions_manage ()
system_actions_manage_form ($form, &$form_state, $options=array())
system_actions_manage_form_submit ($form, &$form_state)
system_actions_configure ($form, &$form_state, $action=NULL)
system_actions_configure_validate ($form, &$form_state)
system_actions_configure_submit ($form, &$form_state)
system_actions_delete_form ($form, &$form_state, $action)
system_actions_delete_form_submit ($form, &$form_state)
system_action_delete_orphans_post ($orphaned)
system_actions_remove_orphans ()

Detailed Description

Admin page callbacks for the system module.

Definition in file system.admin.inc.

Function Documentation

_system_is_incompatible | ( | & | $incompatible,
 |  |  | $files,
 |  |  | $file
 | ) |  |

Recursively check compatibility.

Parameters
$incompatible | An associative array which at the end of the check contains all incompatible files as the keys, their values being TRUE.
$files | The set of files that will be tested.
$file | The file at which the check starts.
Returns
Returns TRUE if an incompatible file is found, NULL (no return value) otherwise.

Definition at line 754 of file system.admin.inc.

_system_modules_build_row | ( | $info,
 |  | $extra
 | ) |

Build a table row for the system modules page.

Definition at line 968 of file system.admin.inc.

References $info, DRUPAL_CORE_COMPATIBILITY, t(), and theme().

Referenced by system_modules().

_system_theme_settings_validate_path ( $path )

Helper function for the system_theme_settings form.

Attempts to validate normal system paths, paths relative to the public files directory, or stream wrapper URIs. If the given path is any of the above, returns a valid path or URI that the theme system can display.

Parameters
$path A path relative to the Drupal root or to the public files directory, or a stream wrapper URI.
Returns
mixed A valid path that can be displayed through the theme system, or FALSE if the path could not be validated.

Definition at line 671 of file system.admin.inc.

References drupal_realpath(), and file_uri_scheme().

Referenced by system_theme_settings_submit(), and system_theme_settings_validate().

system_action_delete_orphans_post ( $orphaned )

Post-deletion operations for deleting action orphans.

Parameters
$orphaned An array of orphaned actions.

Definition at line 3202 of file system.admin.inc.

References drupal_set_message(), and t().

system_actions_configure | ( |  | $form,
 |  | & | $form_state,
 |  |  | $action = NULL
 | ) |  |

Menu callback; Creates the form for configuration of a single action.

We provide the "Description" field. The rest of the form is provided by the action. We then provide the Save button. Because we are combining unknown form elements with the action configuration form, we use an 'actions_' prefix on our elements.

Parameters
$action Hash of an action ID or an integer. If it is a hash, we are creating a new instance. If it is an integer, we are editing an existing instance.
Returns
A form definition.
See Also
system_actions_configure_validate()
system_actions_configure_submit()

Definition at line 3064 of file system.admin.inc.

References $name, actions_actions_map(), actions_list(), db_query(), drupal_goto(), drupal_hash_base64(), and t().

system_actions_configure_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process system_actions_configure() form submissions.

Definition at line 3148 of file system.admin.inc.

References actions_function_lookup(), actions_save(), drupal_set_message(), and t().

system_actions_configure_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate system_actions_configure() form submissions.

Definition at line 3137 of file system.admin.inc.

References actions_function_lookup().

system_actions_delete_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process system_actions_delete form submissions.

Post-deletion operations for action deletion.

Definition at line 3187 of file system.admin.inc.

References actions_delete(), actions_load(), drupal_set_message(), t(), and watchdog().

system_actions_manage ( )

Menu callback; Displays an overview of available and configured actions.

Definition at line 2946 of file system.admin.inc.

References $header, $pager, $row, actions_actions_map(), actions_list(), actions_synchronize(), check_plain(), db_query(), db_select(), drupal_get_form(), l(), t(), and theme().

system_actions_manage_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process system_actions_manage form submissions.

See Also
system_actions_manage_form()

Definition at line 3040 of file system.admin.inc.

system_actions_remove_orphans ( )

Remove actions that are in the database but not supported by any enabled module.

Definition at line 3211 of file system.admin.inc.

References actions_synchronize(), and drupal_goto().

system_add_date_format_type_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process system_add_date_format_type form submissions.

Definition at line 2172 of file system.admin.inc.

References drupal_set_message(), system_date_format_type_save(), t(), and variable_set().

system_add_date_format_type_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate system_add_date_format_type form submissions.

Definition at line 2157 of file system.admin.inc.

References form_set_error(), system_get_date_types(), and t().

system_add_date_formats_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process new date format string submission.

Definition at line 2925 of file system.admin.inc.

References drupal_set_message(), system_date_format_save(), and t().

system_add_date_formats_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validate new date format string submission.

Definition at line 2914 of file system.admin.inc.

References form_set_error(), system_get_date_formats(), and t().

system_admin_config_page ( )

Menu callback; Provide the administration overview page.

Definition at line 11 of file system.admin.inc.

References _menu_link_translate(), db_query(), drupal_set_message(), system_admin_menu_block(), system_status(), t(), theme(), url(), and user_access().

system_admin_index ( )

Menu callback; prints a listing of admin tasks, organized by module.

Definition at line 80 of file system.admin.inc.

References $info, $module, system_get_info(), system_get_module_admin_tasks(), and theme().

system_admin_menu_block_page ( )

Provide a single block from the administration menu as a page.

This function is often a destination for these blocks. For example, 'admin/structure/types' needs to have a destination to be valid in the Drupal menu system, but too much information there might be hidden, so we supply the contents of the block.

Returns
The output HTML.

Definition at line 66 of file system.admin.inc.

References $content, $output, menu_get_item(), system_admin_menu_block(), t(), and theme().

system_batch_page ( )

Default page callback for batches.

Definition at line 2363 of file system.admin.inc.

References $output, $page, _batch_page(), drupal_access_denied(), DRUPAL_ROOT, drupal_set_page_content(), and element_info().

system_configure_date_formats_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $dfid = 0
 | ) |  |

Allow users to add additional date formats.

Definition at line 2863 of file system.admin.inc.

References drupal_get_path(), format_date(), REQUEST_TIME, system_get_date_format(), t(), and url().

system_date_delete_format_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $dfid
 | ) |  |

Menu callback; present a form for deleting a date format.

Definition at line 2767 of file system.admin.inc.

References $output, confirm_form(), format_date(), REQUEST_TIME, system_get_date_format(), and t().

system_date_delete_format_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Delete a configured date format.

Definition at line 2788 of file system.admin.inc.

References drupal_set_message(), format_date(), REQUEST_TIME, system_date_format_delete(), system_get_date_format(), and t().

system_date_time_formats ( )

Displays the date format strings overview page.

Definition at line 2834 of file system.admin.inc.

References $header, $row, drupal_static_reset(), format_date(), l(), REQUEST_TIME, system_get_date_formats(), t(), and url().

system_date_time_lookup ( )

Return the date for a given format string via Ajax.

Definition at line 2190 of file system.admin.inc.

References drupal_json_output(), format_date(), and REQUEST_TIME.

system_delete_date_format_type_form | ( |  | $form,
 |  | & | $form_state,
 |  |  | $format_type
 | ) |  |

Menu callback; present a form for deleting a date type.

Definition at line 2800 of file system.admin.inc.

References $output, confirm_form(), system_get_date_types(), and t().

system_delete_date_format_type_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Delete a configured date type.

Definition at line 2821 of file system.admin.inc.

References drupal_set_message(), system_date_format_type_delete(), system_get_date_types(), and t().

system_ip_blocking ( $default_ip = '' )

Menu callback. Display blocked IP addresses.

Parameters
$default_ip Optional IP address to be passed on to drupal_get_form() for use as the default value of the IP address form field.

Definition at line 1380 of file system.admin.inc.

References $header, db_query(), drupal_get_form(), l(), and t().

system_ip_blocking_delete | ( |  | $form,
 |  | & | $form_state,
 |  |  | $iid
 | ) |  |

IP deletion confirm page.

See Also
system_ip_blocking_delete_submit()

Definition at line 1457 of file system.admin.inc.

References confirm_form(), and t().

system_ip_blocking_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process system_ip_blocking_delete form submissions.

Definition at line 1468 of file system.admin.inc.

References db_delete(), drupal_set_message(), t(), and watchdog().

system_ip_blocking_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 1442 of file system.admin.inc.

References db_insert(), drupal_set_message(), and t().

system_ip_blocking_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 1429 of file system.admin.inc.

References db_query(), form_set_error(), ip_address(), and t().

system_modules_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit callback; handles modules form submission.

Definition at line 1094 of file system.admin.inc.

References $module, $name, drupal_check_module(), drupal_flush_all_caches(), drupal_get_installed_schema_version(), DRUPAL_ROOT, drupal_set_message(), module_disable(), module_enable(), module_exists(), module_list(), SCHEMA_UNINSTALLED, system_rebuild_module_data(), and t().

system_modules_uninstall_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Processes the submitted uninstall form.

Definition at line 1355 of file system.admin.inc.

References DRUPAL_ROOT, drupal_set_message(), drupal_uninstall_modules(), and t().

system_modules_uninstall_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validates the submitted uninstall form.

Definition at line 1344 of file system.admin.inc.

References drupal_goto(), drupal_set_message(), and t().

system_php ( )

Menu callback: return information about PHP.

Definition at line 2355 of file system.admin.inc.

References drupal_exit().

system_run_cron ( )

Menu callback: run cron manually.

Definition at line 2340 of file system.admin.inc.

References drupal_cron_run(), drupal_goto(), drupal_set_message(), and t().

system_settings_overview ( )

Displays the configuration overview page.

This menu callback implementation is a legacy function that used to display the configuration overview page at admin/config. It is currently unused and will be removed in Drupal 8. The page at admin/config is now generated by system_admin_config_page().

Deprecated:
See Also
system_admin_config_page()

Definition at line 119 of file system.admin.inc.

References $content, $output, menu_get_item(), system_admin_menu_block(), and theme().

system_site_information_settings_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validates the submitted site-information form.

Definition at line 1555 of file system.admin.inc.

References drupal_get_normal_path(), drupal_valid_path(), form_set_error(), form_set_value(), t(), and user_validate_mail().

system_sort_modules_by_info_name | ( | $a,
 |  | $b
 | ) |

Array sorting callback; sorts modules or themes by their name.

Definition at line 948 of file system.admin.inc.

system_sort_themes | ( | $a,
 |  | $b
 | ) |

Array sorting callback; sorts modules or themes by their name.

Definition at line 955 of file system.admin.inc.

system_status ( $check = FALSE )

Menu callback: displays the site status report. Can also be used as a pure check.

Parameters
$check If true, only returns a boolean whether there are system status errors.

Definition at line 2314 of file system.admin.inc.

References db_update(), drupal_load_updates(), drupal_requirements_severity(), DRUPAL_ROOT, module_invoke_all(), REQUIREMENT_ERROR, and theme().

Referenced by system_admin_config_page().

system_theme_default ( )

Menu callback; Set the default theme.

Definition at line 346 of file system.admin.inc.

References drupal_goto(), drupal_set_message(), drupal_valid_token(), list_themes(), MENU_ACCESS_DENIED, menu_rebuild(), t(), theme_enable(), variable_get(), and variable_set().

system_theme_disable ( )

Menu callback; Disables a theme.

Definition at line 318 of file system.admin.inc.

References drupal_goto(), drupal_set_message(), drupal_valid_token(), list_themes(), MENU_ACCESS_DENIED, t(), theme_disable(), and variable_get().

system_theme_enable ( )

Menu callback; Enables a theme.

Definition at line 296 of file system.admin.inc.

References drupal_goto(), drupal_set_message(), drupal_valid_token(), list_themes(), MENU_ACCESS_DENIED, t(), and theme_enable().

system_theme_settings_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process system_theme_settings form submissions.

Definition at line 693 of file system.admin.inc.

References _system_theme_settings_validate_path(), cache_clear_all(), drupal_set_message(), file_get_mimetype(), file_unmanaged_copy(), form_state_values_clean(), t(), and variable_set().

system_theme_settings_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validator for the system_theme_settings() form.

Definition at line 607 of file system.admin.inc.

References _system_theme_settings_validate_path(), file_save_upload(), form_set_error(), and t().

system_themes_admin_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process system_themes_admin_form form submissions.

Definition at line 287 of file system.admin.inc.

References drupal_set_message(), t(), and variable_set().

system_themes_page ( )

Menu callback; displays a listing of all themes.

Definition at line 136 of file system.admin.inc.

References drupal_alter(), DRUPAL_CORE_COMPATIBILITY, drupal_get_form(), drupal_get_token(), drupal_render(), drupal_theme_access(), format_plural(), system_rebuild_theme_data(), t(), theme(), and variable_get().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.api.php File Reference

  • modules
  • system
Functions
system.api.php File Reference

Go to the source code of this file.

Functions

hook_hook_info ()
hook_hook_info_alter (&$hooks)
hook_entity_info ()
hook_entity_info_alter (&$entity_info)
hook_entity_load ($entities, $type)
hook_entity_presave ($entity, $type)
hook_entity_insert ($entity, $type)
hook_entity_update ($entity, $type)
hook_entity_delete ($entity, $type)
hook_entity_query_alter ($query)
hook_entity_view ($entity, $type, $view_mode, $langcode)
hook_entity_view_alter (&$build, $type)
hook_entity_view_mode_alter (&$view_mode, $context)
hook_admin_paths ()
hook_admin_paths_alter (&$paths)
hook_entity_prepare_view ($entities, $type, $langcode)
hook_cron ()
hook_cron_queue_info ()
hook_cron_queue_info_alter (&$queues)
hook_element_info ()
hook_element_info_alter (&$type)
hook_exit ($destination=NULL)
hook_js_alter (&$javascript)
hook_library ()
hook_library_alter (&$libraries, $module)
hook_css_alter (&$css)
hook_ajax_render_alter ($commands)
hook_page_build (&$page)
hook_menu_get_item_alter (&$router_item, $path, $original_map)
hook_menu ()
hook_menu_alter (&$items)
hook_menu_link_alter (&$item)
hook_translated_menu_link_alter (&$item, $map)
hook_menu_link_insert ($link)
hook_menu_link_update ($link)
hook_menu_link_delete ($link)
hook_menu_local_tasks_alter (&$data, $router_item, $root_path)
hook_menu_breadcrumb_alter (&$active_trail, $item)
hook_menu_contextual_links_alter (&$links, $router_item, $root_path)
hook_page_alter (&$page)
hook_form_alter (&$form, &$form_state, $form_id)
hook_form_FORM_ID_alter (&$form, &$form_state, $form_id)
hook_form_BASE_FORM_ID_alter (&$form, &$form_state, $form_id)
hook_forms ($form_id, $args)
hook_boot ()
hook_init ()
hook_image_toolkits ()
hook_mail_alter (&$message)
hook_module_implements_alter (&$implementations, $hook)
hook_system_theme_info ()
hook_system_info_alter (&$info, $file, $type)
hook_permission ()
hook_theme ($existing, $type, $theme, $path)
hook_theme_registry_alter (&$theme_registry)
hook_custom_theme ()
hook_xmlrpc ()
hook_xmlrpc_alter (&$methods)
hook_watchdog (array $log_entry)
hook_mail ($key, &$message, $params)
hook_flush_caches ()
hook_modules_installed ($modules)
hook_modules_enabled ($modules)
hook_modules_disabled ($modules)
hook_modules_uninstalled ($modules)
hook_stream_wrappers ()
hook_stream_wrappers_alter (&$wrappers)
hook_file_load ($files)
hook_file_validate ($file)
hook_file_presave ($file)
hook_file_insert ($file)
hook_file_update ($file)
hook_file_copy ($file, $source)
hook_file_move ($file, $source)
hook_file_delete ($file)
hook_file_download ($uri)
hook_file_url_alter (&$uri)
hook_requirements ($phase)
hook_schema ()
hook_schema_alter (&$schema)
hook_query_alter (QueryAlterableInterface $query)
hook_query_TAG_alter (QueryAlterableInterface $query)
hook_install ()
hook_update_N (&$sandbox)
hook_update_dependencies ()
hook_update_last_removed ()
hook_uninstall ()
hook_enable ()
hook_disable ()
hook_registry_files_alter (&$files, $modules)
hook_install_tasks (&$install_state)
hook_drupal_goto_alter (&$path, &$options, &$http_response_code)
hook_html_head_alter (&$head_elements)
hook_install_tasks_alter (&$tasks, $install_state)
hook_file_mimetype_mapping_alter (&$mapping)
hook_action_info ()
hook_actions_delete ($aid)
hook_action_info_alter (&$actions)
hook_archiver_info ()
hook_archiver_info_alter (&$info)
hook_date_format_types ()
hook_date_format_types_alter (&$types)
hook_date_formats ()
hook_date_formats_alter (&$formats)
hook_page_delivery_callback_alter (&$callback)
hook_system_themes_page_alter (&$theme_groups)
hook_url_inbound_alter (&$path, $original_path, $path_language)
hook_url_outbound_alter (&$path, &$options, $original_path)
hook_username_alter (&$name, $account)
hook_tokens ($type, $tokens, array $data=array(), array $options=array())
hook_tokens_alter (array &$replacements, array $context)
hook_token_info ()
hook_token_info_alter (&$data)
hook_batch_alter (&$batch)
hook_updater_info ()
hook_updater_info_alter (&$updaters)
hook_countries_alter (&$countries)
hook_menu_site_status_alter (&$menu_site_status, $path)
hook_filetransfer_info ()
hook_filetransfer_info_alter (&$filetransfer_info)
callback_entity_info_uri ($entity)
callback_entity_info_label ($entity, $entity_type)
callback_entity_info_language ($entity, $entity_type)

Detailed Description

Hooks provided by Drupal core and the System module.

Definition in file system.api.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.archiver.inc File Reference

  • modules
  • system
Classes
system.archiver.inc File Reference

Go to the source code of this file.

Classes

class | ArchiverTar
class | ArchiverZip

Detailed Description

Archiver implementations provided by the system module.

Definition in file system.archiver.inc.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.install File Reference

  • modules
  • system
Functions
system.install File Reference

Go to the source code of this file.

Functions

system_requirements ($phase)
system_install ()
system_schema ()
system_schema_cache_7054 ()
system_update_last_removed ()
system_update_dependencies ()
system_update_7000 ()
system_update_7001 ()
system_update_7002 ()
system_update_7003 ()
system_update_7004 (&$sandbox)
system_update_7005 ()
system_update_7007 ()
system_update_7009 ()
system_update_7011 ()
system_update_7013 ()
system_update_7015 ()
system_update_7016 ()
system_update_7017 ()
system_update_7018 ()
system_update_7020 ()
system_update_7021 ()
system_update_7027 ()
system_update_7029 ()
system_update_7032 ()
system_update_7033 ()
system_update_7034 ()
system_update_7036 ()
system_update_7042 ()
system_update_7044 ()
system_update_7045 ()
system_update_7046 ()
system_update_7047 ()
system_update_7048 ()
system_update_7049 ()
system_update_7050 ()
system_update_7051 ()
system_update_7052 ()
system_update_7053 ()
system_update_7054 ()
system_update_7055 ()
system_update_7057 ()
system_update_7058 ()
system_update_7059 ()
system_update_7060 ()
system_update_7061 (&$sandbox)
system_update_7062 ()
system_update_7063 ()
system_update_7064 ()
system_update_7065 ()
system_update_7066 ()
system_update_7067 ()
system_update_7068 ()
system_update_7069 ()
system_update_7070 ()
system_update_7071 ()
system_update_7072 ()
system_update_7073 ()
system_update_7074 ()
system_update_7076 ()
system_update_7077 ()
system_update_7078 ()
system_update_7079 ()

Detailed Description

Install, update and uninstall functions for the system module.

Definition in file system.install.

Function Documentation

system_install ( )

Implements hook_install().

Definition at line 523 of file system.install.

References db_update(), drupal_get_schema_versions(), drupal_install_schema(), drupal_random_key(), drupal_set_installed_schema_version(), module_implements(), module_list(), SCHEMA_INSTALLED, system_rebuild_theme_data(), and variable_set().

system_requirements ( $phase )

Implements hook_requirements().

Definition at line 11 of file system.install.

References $base_url, $contents, $help, $info, $module, $name, base_path(), conf_path(), drupal_check_incompatibility(), drupal_check_memory_limit(), DRUPAL_CORE_COMPATIBILITY, drupal_detect_database_types(), drupal_get_installed_schema_version(), drupal_get_profile(), drupal_get_schema_versions(), DRUPAL_MINIMUM_PHP, DRUPAL_MINIMUM_PHP_MEMORY_LIMIT, DRUPAL_ROOT, drupal_verify_install_file(), FILE_CREATE_DIRECTORY, file_default_scheme(), file_directory_temp(), file_ensure_htaccess(), FILE_EXIST, FILE_NOT_WRITABLE, file_prepare_directory(), FILE_READABLE, format_interval(), get_t(), Database::getConnection(), l(), module_exists(), module_list(), REQUEST_TIME, REQUIREMENT_ERROR, REQUIREMENT_INFO, REQUIREMENT_OK, REQUIREMENT_WARNING, system_check_http_request(), system_get_info(), system_rebuild_module_data(), t(), theme(), unicode_requirements(), url(), variable_get(), and VERSION.

system_schema ( )

Implements hook_schema().

Definition at line 554 of file system.install.

system_schema_cache_7054 ( )

The cache schema corresponding to system_update_7054.

Drupal 7 adds several new cache tables. Since they all have identical schema this helper function allows them to re-use the same definition, without relying on system_schema(), which may change with future updates.

Definition at line 1660 of file system.install.

Referenced by block_update_7006(), filter_update_7009(), image_update_7000(), system_update_7054(), update_fix_d7_requirements(), and update_update_7001().

system_update_dependencies ( )

Implements hook_update_dependencies().

Definition at line 1714 of file system.install.

system_update_last_removed ( )

Definition at line 1707 of file system.install.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.mail.inc File Reference

  • modules
  • system
Classes
system.mail.inc File Reference

Go to the source code of this file.

Classes

class | DefaultMailSystem
class | TestingMailSystem

Detailed Description

Drupal core implementations of MailSystemInterface.

Definition in file system.mail.inc.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.module File Reference

  • modules
  • system
Functions | Variables
system.module File Reference

Go to the source code of this file.

Functions

system_help ($path, $arg)
system_theme ()
system_permission ()
system_hook_info ()
system_entity_info ()
system_element_info ()
system_menu ()
_system_batch_theme ()
system_library ()
system_stream_wrappers ()
blocked_ip_load ($iid)
_system_themes_access ($theme)
system_authorized_init ($callback, $file, $arguments=array(), $page_title=NULL)
system_authorized_get_url (array $options=array())
system_authorized_batch_processing_url ()
system_authorized_run ($callback, $file, $arguments=array(), $page_title=NULL)
system_authorized_batch_process ()
system_updater_info ()
system_filetransfer_info ()
system_init ()
system_add_module_assets ()
system_custom_theme ()
system_form_user_profile_form_alter (&$form, &$form_state)
system_form_user_register_form_alter (&$form, &$form_state)
system_user_login (&$edit, $account)
system_user_timezone (&$form, &$form_state)
system_block_info ()
system_block_view ($delta= '')
system_preprocess_block (&$variables)
system_admin_menu_block ($item)
system_check_directory ($form_element)
system_get_files_database (&$files, $type)
system_update_files_database (&$files, $type)
system_get_info ($type, $name=NULL)
_system_rebuild_module_data ()
system_rebuild_module_data ()
_system_update_bootstrap_status ()
_system_rebuild_theme_data ()
system_rebuild_theme_data ()
_system_info_add_path ($info, $path)
_system_default_theme_features ()
system_find_base_themes ($themes, $key, $used_keys=array())
system_region_list ($theme_key, $show=REGIONS_ALL)
system_system_info_alter (&$info, $file, $type)
system_default_region ($theme)
system_settings_form ($form)
system_settings_form_submit ($form, &$form_state)
_system_sort_requirements ($a, $b)
confirm_form ($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
system_admin_compact_mode ()
system_admin_compact_page ($mode= 'off')
system_get_module_admin_tasks ($module, $info)
system_cron ()
system_flush_caches ()
system_action_info ()
system_send_email_action_form ($context)
system_send_email_action_validate ($form, $form_state)
system_send_email_action_submit ($form, $form_state)
system_send_email_action ($entity, $context)
system_mail ($key, &$message, $params)
system_message_action_form ($context)
system_message_action_submit ($form, $form_state)
system_message_action (&$entity, $context=array())
system_goto_action_form ($context)
system_goto_action_submit ($form, $form_state)
system_goto_action ($entity, $context)
system_block_ip_action ()
system_time_zones ($blank=NULL)
system_check_http_request ()
system_timezone ($abbreviation= '', $offset=-1, $is_daylight_saving_time=NULL)
theme_system_powered_by ()
theme_system_compact_link ()
system_image_toolkits ()
system_retrieve_file ($url, $destination=NULL, $managed=FALSE, $replace=FILE_EXISTS_RENAME)
system_page_alter (&$page)
system_run_automated_cron ()
system_get_date_types ($type=NULL)
system_date_format_types ()
system_date_formats ()
system_get_date_formats ($type=NULL)
system_get_date_format ($dfid)
system_date_formats_rebuild ()
system_date_format_locale ($langcode=NULL, $type=NULL)
_system_date_format_types_build ()
_system_date_formats_build ()
system_date_format_type_save ($type)
system_date_format_type_delete ($type)
system_date_format_save ($date_format, $dfid=0)
system_date_format_delete ($dfid)
system_archiver_info ()
theme_confirm_form ($variables)
theme_system_settings_form ($variables)
theme_exposed_filters ($variables)
system_admin_paths ()

Variables

const | DRUPAL_MAXIMUM_TEMP_FILE_AGE 21600
const | DRUPAL_CRON_DEFAULT_THRESHOLD 10800
const | DRUPAL_USER_TIMEZONE_DEFAULT 0
const | DRUPAL_USER_TIMEZONE_EMPTY 1
const | DRUPAL_USER_TIMEZONE_SELECT 2
const | DRUPAL_DISABLED 0
const | DRUPAL_OPTIONAL 1
const | DRUPAL_REQUIRED 2
const | DRUPAL_WEIGHT_SELECT_MAX 100
const | REGIONS_VISIBLE 'visible'
const | REGIONS_ALL 'all'

Detailed Description

Configuration system that lets administrators modify the workings of the site.

Definition in file system.module.

Function Documentation

_system_batch_theme ( )

Theme callback for the default batch page.

Definition at line 1071 of file system.module.

References batch_get(), batch_load(), and DRUPAL_ROOT.

_system_date_format_types_build ( )

Builds and returns information about available date types.

Returns
An associative array of date type information keyed by name. Each date type information array has the following elements:
  • type: The machine-readable name of the date type.
  • title: The human-readable name of the date type.
  • locked: A boolean indicating whether or not this date type should be configurable from the user interface.
  • module: The name of the module that defined this format in its hook_date_format_types(). An empty string if the format was user-defined.
  • is_new: A boolean indicating whether or not this date type is as of yet unsaved in the database.

Definition at line 3684 of file system.module.

_system_date_formats_build ( )

Builds and returns information about available date formats.

Returns
An associative array of date formats. The top-level keys are the names of the date types that the date formats belong to. The values are in turn associative arrays keyed by format with the following keys:
  • dfid: The date format ID.
  • format: The PHP date format string.
  • type: The machine-readable name of the date type the format belongs to.
  • locales: An array of language codes. This can include both 2 character language codes like 'en and 'fr' and 5 character language codes like 'en-gb' and 'en-us'.
  • locked: A boolean indicating whether or not this date type should be configurable from the user interface.
  • module: The name of the module that defined this format in its hook_date_formats(). An empty string if the format was user-defined.
  • is_new: A boolean indicating whether or not this date type is as of yet unsaved in the database.

Definition at line 3749 of file system.module.

_system_default_theme_features ( )

Returns an array of default theme features.

Definition at line 2655 of file system.module.

Referenced by _system_rebuild_theme_data(), and theme_get_setting().

_system_info_add_path | ( | $info,
 |  | $path
 | ) |

Prefixes all values in an .info file array with a given path.

This helper function is mainly used to prefix all array values of an .info file property with a single given path (to the module or theme); e.g., to prefix all values of the 'stylesheets' or 'scripts' properties with the file path to the defining module/theme.

Parameters
$info | A nested array of data of an .info file to be processed.
$path | A file path to prepend to each value in $info.
Returns
The $info array with prefixed values.
See Also
_system_rebuild_module_data()
_system_rebuild_theme_data()

Definition at line 2636 of file system.module.

References $info, and $value.

Referenced by _system_rebuild_module_data(), and _system_rebuild_theme_data().

_system_rebuild_module_data ( )

Helper function to scan and collect module .info data.

Returns
An associative array of module information.

Definition at line 2361 of file system.module.

References $module, _system_info_add_path(), drupal_alter(), drupal_get_profile(), DRUPAL_MINIMUM_PHP, drupal_parse_info_file(), DRUPAL_PHP_FUNCTION_PATTERN, and drupal_system_listing().

Referenced by system_rebuild_module_data().

_system_rebuild_theme_data ( )

Helper function to scan and collect theme .info data and their engines.

Returns
An associative array of themes information.

Definition at line 2493 of file system.module.

References $name, _system_default_theme_features(), _system_info_add_path(), drupal_alter(), drupal_find_base_themes(), DRUPAL_MINIMUM_PHP, drupal_parse_info_file(), DRUPAL_PHP_FUNCTION_PATTERN, drupal_system_listing(), and module_invoke_all().

Referenced by list_themes(), and system_rebuild_theme_data().

_system_sort_requirements | ( | $a,
 |  | $b
 | ) |

Helper function to sort requirements.

Definition at line 2793 of file system.module.

_system_themes_access ( $theme )

Menu item access callback - only admin or enabled themes can be accessed.

Definition at line 1695 of file system.module.

References drupal_theme_access(), and user_access().

_system_update_bootstrap_status ( )

Refresh bootstrap column in the system table.

This is called internally by module_enable/disable() to flag modules that implement hooks used during bootstrap, such as hook_boot(). These modules are loaded earlier to invoke the hooks.

Definition at line 2467 of file system.module.

References $module, bootstrap_hooks(), db_update(), module_implements(), and system_list_reset().

Referenced by drupal_flush_all_caches(), module_disable(), and module_enable().

blocked_ip_load ( $iid )

Retrieve a blocked IP address from the database.

Parameters
$iid integer The ID of the blocked IP address to retrieve.
Returns
The blocked IP address from the database as an array.

Definition at line 1688 of file system.module.

References db_query().

confirm_form | ( | $form,
 |  | $question,
 |  | $path,
 |  | $description = NULL,
 |  | $yes = NULL,
 |  | $no = NULL,
 |  | $name = 'confirm'
 | ) |

Generates a form array for a confirmation form.

This function returns a complete form array for confirming an action. The form contains a confirm button as well as a cancellation link that allows a user to abort the action.

If the submit handler for a form that implements confirm_form() is invoked, the user successfully confirmed the action. You should never directly inspect $_POST to see if an action was confirmed.

Note - if the parameters $question, $description, $yes, or $no could contain any user input (such as node titles or taxonomy terms), it is the responsibility of the code calling confirm_form() to sanitize them first with a function like check_plain() or filter_xss().

Parameters
$form | Additional elements to add to the form. These can be regular form elements, value elements, etc., and their values will be available to the submit handler.
$question | The question to ask the user (e.g. "Are you sure you want to delete the block <em>foo</em>?"). The page title will be set to this value.
$path The page to go to if the user cancels the action. This can be either:
  • A string containing a Drupal path.
  • An associative array with a 'path' key. Additional array values are passed as the $options parameter to l(). If the 'destination' query parameter is set in the URL when viewing a confirmation form, that value will be used instead of $path.
$description | Additional text to display. Defaults to t('This action cannot be undone.').
$yes | A caption for the button that confirms the action (e.g. "Delete", "Replace", ...). Defaults to t('Confirm').
$no | A caption for the link which cancels the action (e.g. "Cancel"). Defaults to t('Cancel').
$name | The internal name used to refer to the confirmation item.
Returns
The form array.

Definition at line 2847 of file system.module.

References $name, drupal_parse_url(), drupal_set_title(), PASS_THROUGH, and t().

Referenced by aggregator_admin_remove_feed(), block_custom_block_delete(), book_remove_form(), comment_confirm_delete(), comment_multiple_delete_confirm(), contact_category_delete_form(), field_ui_field_delete_form(), filter_admin_disable(), forum_confirm_delete(), image_effect_delete_form(), image_style_delete_form(), image_style_revert_form(), locale_date_format_reset_form(), locale_languages_delete_form(), locale_translate_delete_form(), menu_delete_menu_confirm(), menu_item_delete_form(), menu_reset_item_confirm(), node_configure_rebuild_confirm(), node_delete_confirm(), node_multiple_delete_confirm(), node_revision_delete_confirm(), node_revision_revert_confirm(), node_type_delete_confirm(), openid_user_delete_form(), path_admin_delete_confirm(), profile_field_delete(), search_reindex_confirm(), shortcut_link_delete(), shortcut_set_delete_form(), system_actions_delete_form(), system_date_delete_format_form(), system_delete_date_format_type_form(), system_ip_blocking_delete(), system_modules_confirm_form(), system_modules_uninstall_confirm_form(), taxonomy_term_confirm_delete(), taxonomy_vocabulary_confirm_delete(), taxonomy_vocabulary_confirm_reset_alphabetical(), trigger_unassign(), user_admin_role_delete_confirm(), user_cancel_confirm_form(), and user_multiple_cancel_confirm().

system_action_info ( )

Implements hook_action_info().

Definition at line 3076 of file system.module.

References t().

system_add_module_assets ( )

Adds CSS and JavaScript files declared in module .info files.

Definition at line 1938 of file system.module.

References $info, $module, drupal_add_css(), drupal_add_js(), and system_get_info().

Referenced by system_init().

system_admin_compact_mode ( )

Determines whether the current user is in compact mode.

Compact mode shows certain administration pages with less description text, such as the configuration page and the permissions page.

Whether the user is in compact mode is determined by a cookie, which is set for the user by system_admin_compact_page().

If the user does not have the cookie, the default value is given by the system variable 'admin_compact_mode', which itself defaults to FALSE. This does not have a user interface to set it: it is a hidden variable which can be set in the settings.php file.

Returns
TRUE when in compact mode, FALSE when in expanded mode.

Definition at line 2902 of file system.module.

References variable_get().

Referenced by seven_admin_block_content(), theme_admin_block_content(), theme_system_compact_link(), and user_admin_permissions().

system_admin_compact_page ( $mode = 'off' )

Menu callback; Sets whether the admin menu is in compact mode or not.

Parameters
$mode Valid values are 'on' and 'off'.

Definition at line 2914 of file system.module.

References drupal_goto(), and user_cookie_save().

system_admin_menu_block ( $item )

Provide a single block on the administration overview page.

Parameters
$item The menu item to be displayed.

Definition at line 2117 of file system.module.

References $content, _menu_link_translate(), db_query(), db_select(), drupal_schema_fields_sql(), drupal_static(), drupal_strtolower(), and menu_get_item().

Referenced by node_add_page(), system_admin_config_page(), system_admin_menu_block_page(), and system_settings_overview().

system_admin_paths ( )

Implements hook_admin_paths().

Definition at line 4011 of file system.module.

system_archiver_info ( )

Implements hook_archiver_info().

Definition at line 3933 of file system.module.

system_block_info ( )

Implements hook_block_info().

Definition at line 2035 of file system.module.

References $title, DRUPAL_NO_CACHE, menu_list_system_menus(), and t().

system_block_view ( $delta = '' )

Implements hook_block_view().

Generate a block with a promotional link to Drupal.org and all system menu blocks.

Definition at line 2074 of file system.module.

References drupal_set_page_content(), menu_get_active_help(), menu_list_system_menus(), menu_tree(), t(), and theme().

system_check_directory ( $form_element )

Checks the existence of the directory specified in $form_element.

This function is called from the system_settings form to check all core file directories (file_public_path, file_private_path, file_temporary_path).

Parameters
$form_element The form element containing the name of the directory to check.

Definition at line 2175 of file system.module.

References drupal_chmod(), drupal_mkdir(), file_create_htaccess(), form_set_error(), t(), watchdog(), and WATCHDOG_ERROR.

system_check_http_request ( )

Checks whether the server is capable of issuing HTTP requests.

The function sets the drupal_http_request_fail system variable to TRUE if drupal_http_request() does not work and then the system status report page will contain an error.

Returns
TRUE if this installation can issue HTTP requests.

Definition at line 3361 of file system.module.

References drupal_http_request(), url(), and variable_set().

Referenced by system_requirements().

system_cron ( )

Implements hook_cron().

Remove older rows from flood and batch table. Remove old temporary files.

Definition at line 3010 of file system.module.

References $row, cache_clear_all(), db_delete(), db_query(), db_update(), DRUPAL_MAXIMUM_TEMP_FILE_AGE, file_delete(), file_load(), FILE_STATUS_PERMANENT, file_usage_list(), module_invoke_all(), REQUEST_TIME, watchdog(), WATCHDOG_ERROR, and WATCHDOG_INFO.

system_custom_theme ( )

Implements hook_custom_theme().

Definition at line 1958 of file system.module.

References current_path(), path_is_admin(), user_access(), and variable_get().

system_date_format_delete ( $dfid )

Deletes a date format from the database.

Parameters
$dfid The date format ID.

Definition at line 3924 of file system.module.

References db_delete().

Referenced by system_date_delete_format_form_submit().

system_date_format_locale | ( | $langcode = NULL,
 |  | $type = NULL
 | ) |

Gets the appropriate date format string for a date type and locale.

Parameters
$langcode | (optional) Language code for the current locale. This can be a 2 character language code like 'en' and 'fr' or a 5 character language code like 'en-gb' and 'en-us'.
$type | (optional) The date type name.
Returns
If $type and $langcode are specified, returns the corresponding date format string. If only $langcode is specified, returns an array of all date format strings for that locale, keyed by the date type. If neither is specified, or if no matching formats are found, returns FALSE.

Definition at line 3645 of file system.module.

Referenced by locale_date_format_form(), and locale_get_localized_date_format().

system_date_format_save | ( | $date_format,
 |  | $dfid = 0
 | ) |

Saves a date format to the database.

Parameters
$date_format A date format array containing the following keys:
  • type: The name of the date type this format is associated with.
  • format: The PHP date format string.
  • locked: A boolean indicating whether or not this format should be configurable from the user interface.
$dfid If set, replace the existing date format having this ID with the information specified in $date_format.
See Also
system_get_date_types()
http://php.net/date

Definition at line 3877 of file system.module.

References $info, db_query_range(), drupal_write_record(), and language_list().

Referenced by system_add_date_formats_form_submit().

system_date_format_type_delete ( $type )

Deletes a date type from the database.

Parameters
$type The machine-readable name of the date type.

Definition at line 3849 of file system.module.

References db_delete().

Referenced by system_delete_date_format_type_form_submit().

system_date_format_type_save ( $type )

Saves a date type to the database.

Parameters
$type A date type array containing the following keys:
  • type: The machine-readable name of the date type.
  • title: The human-readable name of the date type.
  • locked: A boolean indicating whether or not this date type should be configurable from the user interface.
  • is_new: A boolean indicating whether or not this date type is as of yet unsaved in the database.

Definition at line 3828 of file system.module.

References $info, and drupal_write_record().

Referenced by system_add_date_format_type_form_submit().

system_date_format_types ( )

Implements hook_date_format_types().

Definition at line 3541 of file system.module.

system_date_formats ( )

Implements hook_date_formats().

Definition at line 3552 of file system.module.

system_date_formats_rebuild ( )

Resets the database cache of date formats and saves all new date formats.

Definition at line 3612 of file system.module.

Referenced by system_flush_caches().

system_default_region ( $theme )

Get the name of the default region for a given theme.

Parameters
$theme The name of a theme.
Returns
A string that is the region name.

Definition at line 2727 of file system.module.

References REGIONS_VISIBLE, and system_region_list().

Referenced by block_theme_initialize().

system_element_info ( )

Implements hook_element_info().

Definition at line 292 of file system.module.

References request_uri().

system_entity_info ( )

Implements hook_entity_info().

Definition at line 275 of file system.module.

References t().

system_filetransfer_info ( )

Implements hook_filetransfer_info().

Definition at line 1865 of file system.module.

References t().

system_find_base_themes | ( | $themes,
 |  | $key,
 |  | $used_keys = array()
 | ) |

Find all the base themes for the specified theme.

This function has been deprecated in favor of drupal_find_base_themes().

Definition at line 2674 of file system.module.

References drupal_find_base_themes().

system_flush_caches ( )

Implements hook_flush_caches().

Definition at line 3066 of file system.module.

References menu_reset_static_cache(), and system_date_formats_rebuild().

system_form_user_profile_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 1967 of file system.module.

References system_user_timezone(), and variable_get().

system_form_user_register_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Definition at line 1979 of file system.module.

References DRUPAL_USER_TIMEZONE_DEFAULT, DRUPAL_USER_TIMEZONE_SELECT, system_user_timezone(), and variable_get().

system_get_date_format ( $dfid )

Gets the format details for a particular format ID.

Parameters
$dfid A date format ID.
Returns
A date format object with the following properties:
  • dfid: The date format ID.
  • format: The date format string.
  • type: The name of the date type.
  • locked: Whether the date format can be changed or not.

Definition at line 3605 of file system.module.

Referenced by system_configure_date_formats_form(), system_date_delete_format_form(), and system_date_delete_format_form_submit().

system_get_date_formats ( $type = NULL )

Gets the list of defined date formats and attributes.

Parameters
$type (optional) The date type name.
Returns
An associative array of date formats. The top-level keys are the names of the date types that the date formats belong to. The values are in turn associative arrays keyed by the format string, with the following keys:
  • dfid: The date format ID.
  • format: The format string.
  • type: The machine-readable name of the date type.
  • locales: An array of language codes. This can include both 2 character language codes like 'en and 'fr' and 5 character language codes like 'en-gb' and 'en-us'.
  • locked: A boolean indicating whether or not this date type should be configurable from the user interface.
  • module: The name of the module that defined this date format in its hook_date_formats(). An empty string if the format was user-defined.
  • is_new: A boolean indicating whether or not this date type is as of yet unsaved in the database. If $type was defined, only the date formats associated with the given date type are returned, in a single associative array keyed by format string.

Definition at line 3582 of file system.module.

Referenced by locale_date_format_form(), system_add_date_format_type_form(), system_add_date_formats_form_validate(), system_date_time_formats(), and system_date_time_settings().

system_get_date_types ( $type = NULL )

Gets the list of available date types and attributes.

Parameters
$type (optional) The date type name.
Returns
An associative array of date type information keyed by the date type name. Each date type information array has the following elements:
  • type: The machine-readable name of the date type.
  • title: The human-readable name of the date type.
  • locked: A boolean indicating whether or not this date type should be configurable from the user interface.
  • module: The name of the module that defined this date type in its hook_date_format_types(). An empty string if the date type was user-defined.
  • is_new: A boolean indicating whether or not this date type is as of yet unsaved in the database. If $type was defined, only a single associative array with the above elements is returned.

Definition at line 3528 of file system.module.

Referenced by locale_date_format_form(), locale_date_format_form_submit(), locale_get_localized_date_format(), system_add_date_format_type_form_validate(), system_date_time_settings(), system_delete_date_format_type_form(), and system_delete_date_format_type_form_submit().

system_get_files_database | ( | & | $files,
 |  |  | $type
 | ) |  |

Retrieves the current status of an array of files in the system table.

Parameters
$files | An array of files to check.
$type | The type of the files.

Definition at line 2214 of file system.module.

References $value, and db_query().

Referenced by system_rebuild_module_data(), and system_rebuild_theme_data().

system_get_info | ( | $type,
 |  | $name = NULL
 | ) |

Returns an array of information about enabled modules or themes.

This function returns the information from the {system} table corresponding to the cached contents of the .info file for each active module or theme.

Parameters
$type | Either 'module' or 'theme'.
$name | (optional) The name of a module or theme whose information shall be returned. If omitted, all records for the provided $type will be returned. If $name does not exist in the provided $type or is not enabled, an empty array will be returned.
Returns
An associative array of module or theme information keyed by name, or only information for $name, if given. If no records are available, an empty array is returned.
See Also
system_rebuild_module_data()
system_rebuild_theme_data()

Definition at line 2338 of file system.module.

References $info, $name, and system_list().

Referenced by _search_get_module_names(), _trigger_tab_information(), drupal_install_profile_distribution_name(), field_help(), help_page(), system_add_module_assets(), system_admin_index(), system_requirements(), and user_admin_permissions().

system_get_module_admin_tasks | ( | $module,
 |  | $info
 | ) |

Generate a list of tasks offered by a specified module.

Parameters
$module | Module name.
$info | The module's information, as provided by system_get_info().
Returns
An array of task links.

Definition at line 2930 of file system.module.

References $info, $links, $module, _menu_link_translate(), db_select(), drupal_schema_fields_sql(), drupal_static(), menu_get_item(), menu_link_load(), module_hook(), module_invoke(), and t().

Referenced by help_page(), and system_admin_index().

system_goto_action_form ( $context )

Settings form for system_goto_action().

Definition at line 3282 of file system.module.

References t().

system_goto_action_submit | ( | $form,
 |  | $form_state
 | ) |

Definition at line 3293 of file system.module.

system_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 72 of file system.module.

References $base_url, $output, list_themes(), module_exists(), t(), update_manager_access(), and url().

system_hook_info ( )

Implements hook_hook_info().

Definition at line 255 of file system.module.

system_image_toolkits ( )

Implements hook_image_toolkits().

Definition at line 3412 of file system.module.

References drupal_get_path(), DRUPAL_ROOT, image_gd_check_settings(), and t().

system_init ( )

Implements hook_init().

Definition at line 1896 of file system.module.

References CSS_SYSTEM, current_path(), drupal_add_css(), drupal_get_path(), Database::ignoreTarget(), path_is_admin(), REQUEST_TIME, and system_add_module_assets().

system_library ( )

Implements hook_library().

Definition at line 1087 of file system.module.

References JS_DEFAULT, JS_LIBRARY, and VERSION.

system_mail | ( |  | $key,
 |  | & | $message,
 |  |  | $params
 | ) |  |

Implements hook_mail().

Definition at line 3229 of file system.module.

References token_replace().

system_menu ( )

Implements hook_menu().

Definition at line 519 of file system.module.

References list_themes(), MENU_CALLBACK, MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION, MENU_LOCAL_TASK, and MENU_VISIBLE_IN_BREADCRUMB.

system_message_action_form ( $context )

Definition at line 3239 of file system.module.

References t().

system_message_action_submit | ( | $form,
 |  | $form_state
 | ) |

Definition at line 3251 of file system.module.

system_page_alter ( & $page )

Implements hook_page_alter().

Definition at line 3480 of file system.module.

system_permission ( )

Implements hook_permission().

Definition at line 214 of file system.module.

References t(), url(), and variable_get().

system_preprocess_block ( & $variables )

Implements hook_preprocess_block().

Definition at line 2104 of file system.module.

References menu_list_system_menus().

system_rebuild_module_data ( )

Rebuild, save, and return data about all currently available modules.

Returns
Array of all available modules and their data.

Definition at line 2444 of file system.module.

References _module_build_dependencies(), _system_rebuild_module_data(), drupal_static(), system_get_files_database(), and system_update_files_database().

Referenced by drupal_install_system(), drupal_uninstall_modules(), field_ui_fields_list(), help_links_as_list(), install_profile_modules(), module_disable(), module_enable(), registry_rebuild(), system_modules(), system_modules_submit(), system_modules_uninstall(), system_requirements(), update_check_incompatibility(), and update_get_projects().

system_rebuild_theme_data ( )

Rebuild, save, and return data about all currently available themes.

Returns
Array of all available themes and their data.

Definition at line 2609 of file system.module.

References _system_rebuild_theme_data(), system_get_files_database(), and system_update_files_database().

Referenced by block_update_7004(), drupal_flush_all_caches(), ThemeUpdater::postInstall(), system_install(), system_themes_page(), update_check_incompatibility(), and update_get_projects().

system_region_list | ( | $theme_key,
 |  | $show = REGIONS_ALL
 | ) |

Get a list of available regions from a specified theme.

Parameters
$theme_key | The name of a theme.
$show | Possible values: REGIONS_ALL or REGIONS_VISIBLE. Visible excludes hidden regions.
Returns
An array of regions in the form $region['name'] = 'description'.

Definition at line 2689 of file system.module.

References $info, $name, list_themes(), REGIONS_ALL, and t().

Referenced by _block_compare(), _block_rehash(), block_admin_configure(), block_admin_display_form(), block_page_build(), block_theme_initialize(), dashboard_admin_blocks(), system_default_region(), and template_preprocess_page().

system_retrieve_file | ( | $url,
 |  | $destination = NULL,
 |  | $managed = FALSE,
 |  | $replace = FILE_EXISTS_RENAME
 | ) |

Attempts to get a file using drupal_http_request and to store it locally.

Parameters
$url | The URL of the file to grab.
$destination | Stream wrapper URI specifying where the file should be placed. If a directory path is provided, the file is saved into that directory under its original name. If the path contains a filename as well, that one will be used instead. If this value is omitted, the site's default files scheme will be used, usually "public://".
$managed | boolean If this is set to TRUE, the file API hooks will be invoked and the file is registered in the database.
$replace boolean Replace behavior when the destination file already exists:
  • FILE_EXISTS_REPLACE: Replace the existing file.
  • FILE_EXISTS_RENAME: Append _{incrementing number} until the filename is unique.
  • FILE_EXISTS_ERROR: Do nothing and return FALSE.
Returns
On success the location the file was saved to, FALSE on failure.

Definition at line 3450 of file system.module.

References $url, drupal_basename(), drupal_realpath(), and file_build_uri().

Referenced by update_manager_file_get().

system_run_automated_cron ( )

Run the automated cron if enabled.

Definition at line 3495 of file system.module.

Referenced by drupal_page_footer().

system_send_email_action_form ( $context )

Return a form definition so the Send email action can be configured.

Parameters
$context Default values (if we are editing an existing action instance).
Returns
Form definition.
See Also
system_send_email_action_validate()
system_send_email_action_submit()

Definition at line 3117 of file system.module.

References t().

system_send_email_action_submit | ( | $form,
 |  | $form_state
 | ) |

Process system_send_email_action form submissions.

Definition at line 3169 of file system.module.

system_send_email_action_validate | ( | $form,
 |  | $form_state
 | ) |

Validate system_send_email_action form submissions.

Definition at line 3157 of file system.module.

References form_set_error(), t(), and valid_email_address().

system_settings_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for system_settings_form().

If you want node type configure style handling of your checkboxes, add an array_filter value to your form.

Definition at line 2776 of file system.module.

References $value, drupal_set_message(), form_state_values_clean(), t(), and variable_set().

Referenced by aggregator_admin_form_submit(), and update_settings_submit().

system_stream_wrappers ( )

Implements hook_stream_wrappers().

Definition at line 1650 of file system.module.

References STREAM_WRAPPERS_LOCAL_HIDDEN, STREAM_WRAPPERS_LOCAL_NORMAL, t(), and variable_get().

system_system_info_alter | ( | & | $info,
 |  |  | $file,
 |  |  | $type
 | ) |  |

Implements hook_system_info_alter().

Definition at line 2710 of file system.module.

References $info.

system_theme ( )

Implements hook_theme().

Definition at line 154 of file system.module.

References drupal_common_theme().

system_time_zones ( $blank = NULL )

Generate an array of time zones and their local time&date.

Parameters
$blank If evaluates true, prepend an empty time zone option to the array.

Definition at line 3335 of file system.module.

References format_date(), REQUEST_TIME, t(), and variable_get().

Referenced by _install_configure_form(), system_regional_settings(), system_update_7013(), system_user_timezone(), and user_update_7002().

system_timezone | ( | $abbreviation = '',
 |  | $offset = -1,
 |  | $is_daylight_saving_time = NULL
 | ) |

Menu callback; Retrieve a JSON object containing a suggested time zone name.

Definition at line 3374 of file system.module.

References drupal_json_output().

system_update_files_database | ( | & | $files,
 |  |  | $type
 | ) |  |

Updates the records in the system table based on the files array.

Parameters
$files | An array of files.
$type | The type of the files.

Definition at line 2237 of file system.module.

References $value, db_delete(), db_insert(), db_or(), db_query(), db_update(), and system_list_reset().

Referenced by system_rebuild_module_data(), and system_rebuild_theme_data().

system_updater_info ( )

End of "defgroup authorize". Implements hook_updater_info().

Definition at line 1847 of file system.module.

References t().

system_user_login | ( | & | $edit,
 |  |  | $account
 | ) |  |

Implements hook_user_login().

Definition at line 1997 of file system.module.

References drupal_get_destination(), drupal_set_message(), t(), url(), and variable_get().

system_user_timezone | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Add the time zone field to the user edit and register forms.

Definition at line 2007 of file system.module.

References drupal_add_js(), system_time_zones(), t(), and variable_get().

Referenced by system_form_user_profile_form_alter(), and system_form_user_register_form_alter().

Variable Documentation

const DRUPAL_CRON_DEFAULT_THRESHOLD 10800

Default interval for automatic cron executions in seconds.

Definition at line 16 of file system.module.

Referenced by system_cron_settings().

const DRUPAL_DISABLED 0

Disabled option on forms and settings

Definition at line 36 of file system.module.

Referenced by comment_form(), comment_form_node_type_form_alter(), node_form(), and node_type_form().

const DRUPAL_MAXIMUM_TEMP_FILE_AGE 21600

Maximum age of temporary files in seconds.

Definition at line 11 of file system.module.

Referenced by system_cron(), and update_delete_file_if_stale().

const DRUPAL_OPTIONAL 1

Optional option on forms and settings

Definition at line 41 of file system.module.

Referenced by comment_form(), comment_form_node_type_form_alter(), node_form(), and node_type_form().

const DRUPAL_REQUIRED 2

Required option on forms and settings

Definition at line 46 of file system.module.

Referenced by comment_form(), comment_form_node_type_form_alter(), node_form(), and node_type_form().

const DRUPAL_USER_TIMEZONE_DEFAULT 0

New users will be set to the default time zone at registration.

Definition at line 21 of file system.module.

Referenced by system_form_user_register_form_alter(), and system_regional_settings().

const DRUPAL_USER_TIMEZONE_EMPTY 1

New users will get an empty time zone at registration.

Definition at line 26 of file system.module.

Referenced by system_regional_settings().

const DRUPAL_USER_TIMEZONE_SELECT 2

New users will select their own timezone at registration.

Definition at line 31 of file system.module.

Referenced by system_form_user_register_form_alter(), and system_regional_settings().

const DRUPAL_WEIGHT_SELECT_MAX 100

Maximum number of values in a weight select element.

If the number of values is over the maximum, a text field is used instead.

Definition at line 53 of file system.module.

Referenced by form_process_weight().

const REGIONS_ALL 'all'

Return all regions.

See Also
system_region_list()

Definition at line 67 of file system.module.

Referenced by system_region_list().

const REGIONS_VISIBLE 'visible'

Return only visible regions.

See Also
system_region_list()

Definition at line 60 of file system.module.

Referenced by block_admin_configure(), block_admin_display_form(), block_page_build(), block_theme_initialize(), dashboard_admin_blocks(), and system_default_region().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.queue.inc File Reference

  • modules
  • system
Classes
system.queue.inc File Reference

Go to the source code of this file.

Classes

class | DrupalQueue
interface | DrupalQueueInterface
interface | DrupalReliableQueueInterface
class | SystemQueue
class | MemoryQueue

Detailed Description

Queue functionality.

Definition in file system.queue.inc.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.tar.inc File Reference

  • modules
  • system
Classes | Namespaces | Variables
system.tar.inc File Reference

Go to the source code of this file.

Classes

class Archive_Tar

Namespaces

Archive_Tar

Variables

const | ARCHIVE_TAR_ATT_SEPARATOR 90001
const | ARCHIVE_TAR_END_BLOCK pack("a512", '')

Variable Documentation

const ARCHIVE_TAR_ATT_SEPARATOR 90001

Definition at line 46 of file system.tar.inc.

Referenced by Archive_Tar\setAttribute().

const ARCHIVE_TAR_END_BLOCK pack("a512", '')

Definition at line 47 of file system.tar.inc.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.tokens.inc File Reference

  • modules
  • system
Functions
system.tokens.inc File Reference

Go to the source code of this file.

Functions

system_token_info ()
system_tokens ($type, $tokens, array $data=array(), array $options=array())

Detailed Description

Builds placeholder replacement tokens system-wide data.

This file handles tokens for the global 'site' token type, as well as 'date' and 'file' tokens.

Definition in file system.tokens.inc.

Function Documentation

system_token_info ( )

Implements hook_token_info().

Definition at line 14 of file system.tokens.inc.

References format_date(), format_interval(), l(), REQUEST_TIME, and t().

system_tokens | ( |  | $type,
 |  |  | $tokens,
 |  | array | $data = array(),
 |  | array | $options = array()
 | ) |  |

Implements hook_tokens().

Definition at line 131 of file system.tokens.inc.

References $name, $site_name, check_plain(), file_create_url(), format_date(), format_interval(), format_size(), format_username(), REQUEST_TIME, token_find_with_prefix(), token_generate(), url(), user_load(), and variable_get().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.updater.inc File Reference

  • modules
  • system
Classes
system.updater.inc File Reference

Go to the source code of this file.

Classes

class | ModuleUpdater
class | ThemeUpdater

Detailed Description

Subclasses of the Updater class to update Drupal core knows how to update. At this time, only modules and themes are supported.

Definition in file system.updater.inc.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/theme.api.php File Reference

  • modules
  • system
Functions
theme.api.php File Reference

Go to the source code of this file.

Functions

hook_form_system_theme_settings_alter (&$form, &$form_state)
hook_preprocess (&$variables, $hook)
hook_preprocess_HOOK (&$variables)
hook_process (&$variables, $hook)
hook_process_HOOK (&$variables)
hook_themes_enabled ($theme_list)
hook_themes_disabled ($theme_list)

Function Documentation

hook_form_system_theme_settings_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

End of "defgroup themeable". Allow themes to alter the theme-specific settings form.

With this hook, themes can alter the theme-specific settings form in any way allowable by Drupal's Form API, such as adding form elements, changing default values and removing form elements. See the Form API documentation on api.drupal.org for detailed information.

Note that the base theme's form alterations will be run before any sub-theme alterations.

Parameters
$form | Nested array of form elements that comprise the form.
$form_state | A keyed array containing the current state of the form.

Definition at line 87 of file theme.api.php.

References t(), and theme_get_setting().

hook_preprocess | ( | & | $variables,
 |  |  | $hook
 | ) |  |

Preprocess theme variables for templates.

This hook allows modules to preprocess theme variables for theme templates. It is called for all theme hooks implemented as templates, but not for theme hooks implemented as functions. hook_preprocess_HOOK() can be used to preprocess variables for a specific theme hook, whether implemented as a template or function.

For more detailed information, see theme().

Parameters
$variables | The variables array (modify in place).
$hook | The name of the theme hook.

Definition at line 113 of file theme.api.php.

References theme_get_registry(), and user_access().

hook_preprocess_HOOK ( & $variables )

Preprocess theme variables for a specific theme hook.

This hook allows modules to preprocess theme variables for a specific theme hook. It should only be used if a module needs to override or add to the theme preprocessing for a theme hook it didn't define.

For more detailed information, see theme().

Parameters
$variables The variables array (modify in place).

Definition at line 159 of file theme.api.php.

hook_process | ( | & | $variables,
 |  |  | $hook
 | ) |  |

Process theme variables for templates.

This hook allows modules to process theme variables for theme templates. It is called for all theme hooks implemented as templates, but not for theme hooks implemented as functions. hook_process_HOOK() can be used to process variables for a specific theme hook, whether implemented as a template or function.

For more detailed information, see theme().

Parameters
$variables | The variables array (modify in place).
$hook | The name of the theme hook.

Definition at line 181 of file theme.api.php.

References $attributes, and theme().

hook_process_HOOK ( & $variables )

Process theme variables for a specific theme hook.

This hook allows modules to process theme variables for a specific theme hook. It should only be used if a module needs to override or add to the theme processing for a theme hook it didn't define.

For more detailed information, see theme().

Parameters
$variables The variables array (modify in place).

Definition at line 207 of file theme.api.php.

hook_themes_disabled ( $theme_list )

Respond to themes being disabled.

Parameters
array $theme_list Array containing the names of the themes being disabled.
See Also
theme_disable()

Definition at line 237 of file theme.api.php.

References _update_cache_clear().

hook_themes_enabled ( $theme_list )

Respond to themes being enabled.

Parameters
array $theme_list Array containing the names of the themes being enabled.
See Also
theme_enable()

Definition at line 223 of file theme.api.php.

References block_theme_initialize().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy Directory Reference

  • modules
  • taxonomy
taxonomy Directory Reference

Files

file | taxonomy-term.tpl.php [code]
file | taxonomy.admin.inc [code]
file | taxonomy.api.php [code]
file | taxonomy.install [code]
file | taxonomy.module [code]
file | taxonomy.pages.inc [code]
file | taxonomy.tokens.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy/taxonomy.admin.inc File Reference

  • modules
  • taxonomy
Functions
taxonomy.admin.inc File Reference

Go to the source code of this file.

Functions

taxonomy_overview_vocabularies ($form)
taxonomy_overview_vocabularies_submit ($form, &$form_state)
theme_taxonomy_overview_vocabularies ($variables)
taxonomy_form_vocabulary ($form, &$form_state, $edit=array())
taxonomy_form_vocabulary_validate ($form, &$form_state)
taxonomy_form_vocabulary_submit ($form, &$form_state)
taxonomy_overview_terms ($form, &$form_state, $vocabulary)
taxonomy_overview_terms_submit ($form, &$form_state)
theme_taxonomy_overview_terms ($variables)
taxonomy_form_term ($form, &$form_state, $edit=array(), $vocabulary=NULL)
taxonomy_form_term_validate ($form, &$form_state)
taxonomy_form_term_submit ($form, &$form_state)
taxonomy_form_term_submit_build_taxonomy_term ($form, &$form_state)
taxonomy_term_confirm_delete ($form, &$form_state, $tid)
taxonomy_term_confirm_delete_submit ($form, &$form_state)
taxonomy_vocabulary_confirm_delete ($form, &$form_state, $vid)
taxonomy_vocabulary_confirm_delete_submit ($form, &$form_state)
taxonomy_vocabulary_confirm_reset_alphabetical ($form, &$form_state, $vid)
taxonomy_vocabulary_confirm_reset_alphabetical_submit ($form, &$form_state)

Detailed Description

Administrative page callbacks for the taxonomy module.

Definition in file taxonomy.admin.inc.

Function Documentation

taxonomy_form_term_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to insert or update a term.

See Also
taxonomy_form_term()

Definition at line 801 of file taxonomy.admin.inc.

References cache_clear_all(), drupal_set_message(), l(), SAVED_NEW, SAVED_UPDATED, t(), taxonomy_check_vocabulary_hierarchy(), taxonomy_form_term_submit_build_taxonomy_term(), taxonomy_term_confirm_delete_submit(), taxonomy_term_save(), taxonomy_vocabulary_save(), watchdog(), and WATCHDOG_NOTICE.

taxonomy_form_term_submit_build_taxonomy_term | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Updates the form state's term entity by processing this submission's values.

Definition at line 856 of file taxonomy.admin.inc.

References entity_form_submit_build_entity().

Referenced by taxonomy_form_term_submit().

taxonomy_form_term_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validation handler for the term form.

See Also
taxonomy_form_term()

Definition at line 787 of file taxonomy.admin.inc.

References entity_form_field_validate(), form_set_error(), and t().

taxonomy_form_vocabulary_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for taxonomy_form_vocabulary().

See Also
taxonomy_form_vocabulary()
taxonomy_form_vocabulary_validate()

Definition at line 211 of file taxonomy.admin.inc.

References drupal_set_message(), entity_form_submit_build_entity(), l(), SAVED_NEW, SAVED_UPDATED, t(), taxonomy_vocabulary_save(), watchdog(), and WATCHDOG_NOTICE.

taxonomy_form_vocabulary_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for taxonomy_form_vocabulary().

Makes sure that the machine name of the vocabulary is not in the disallowed list (names that conflict with menu items, such as 'list' and 'add').

See Also
taxonomy_form_vocabulary()
taxonomy_form_vocabulary_submit()

Definition at line 193 of file taxonomy.admin.inc.

References form_set_error(), and t().

taxonomy_overview_terms_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for terms overview form.

Rather than using a textfield or weight field, this form depends entirely upon the order of form elements on the page to determine new weights.

Because there might be hundreds or thousands of taxonomy terms that need to be ordered, terms are weighted from 0 to the number of terms in the vocabulary, rather than the standard -10 to 10 scale. Numbers are sorted lowest to highest, but are not necessarily sequential. Numbers may be skipped when a term has children so that reordering is minimal when a child is added or removed from a term.

See Also
taxonomy_overview_terms()

Definition at line 436 of file taxonomy.admin.inc.

References $tree, db_update(), drupal_set_message(), t(), taxonomy_get_tree(), taxonomy_vocabulary_confirm_reset_alphabetical_submit(), and taxonomy_vocabulary_save().

taxonomy_overview_vocabularies_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for vocabularies overview. Updates changed vocabulary weights.

See Also
taxonomy_overview_vocabularies()

Definition at line 50 of file taxonomy.admin.inc.

References drupal_set_message(), t(), and taxonomy_vocabulary_save().

taxonomy_term_confirm_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to delete a term after confirmation.

See Also
taxonomy_term_confirm_delete()

Definition at line 898 of file taxonomy.admin.inc.

References cache_clear_all(), drupal_set_message(), t(), taxonomy_check_vocabulary_hierarchy(), taxonomy_term_delete(), watchdog(), and WATCHDOG_NOTICE.

Referenced by taxonomy_form_term_submit().

taxonomy_vocabulary_confirm_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to delete a vocabulary after confirmation.

See Also
taxonomy_vocabulary_confirm_delete()

Definition at line 939 of file taxonomy.admin.inc.

References cache_clear_all(), drupal_set_message(), t(), taxonomy_vocabulary_delete(), watchdog(), and WATCHDOG_NOTICE.

taxonomy_vocabulary_confirm_reset_alphabetical_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler to reset a vocabulary to alphabetical order after confirmation.

See Also
taxonomy_vocabulary_confirm_reset_alphabetical()

Definition at line 976 of file taxonomy.admin.inc.

References db_update(), drupal_set_message(), t(), watchdog(), and WATCHDOG_NOTICE.

Referenced by taxonomy_overview_terms_submit().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy/taxonomy.api.php File Reference

  • modules
  • taxonomy
Functions
taxonomy.api.php File Reference

Go to the source code of this file.

Functions

hook_taxonomy_vocabulary_load ($vocabularies)
hook_taxonomy_vocabulary_presave ($vocabulary)
hook_taxonomy_vocabulary_insert ($vocabulary)
hook_taxonomy_vocabulary_update ($vocabulary)
hook_taxonomy_vocabulary_delete ($vocabulary)
hook_taxonomy_term_load ($terms)
hook_taxonomy_term_presave ($term)
hook_taxonomy_term_insert ($term)
hook_taxonomy_term_update ($term)
hook_taxonomy_term_delete ($term)
hook_taxonomy_term_view ($term, $view_mode, $langcode)
hook_taxonomy_term_view_alter (&$build)

Detailed Description

Hooks provided by the Taxonomy module.

Definition in file taxonomy.api.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy/taxonomy.install File Reference

  • modules
  • taxonomy
Functions
taxonomy.install File Reference

Go to the source code of this file.

Functions

taxonomy_uninstall ()
taxonomy_schema ()
taxonomy_field_schema ($field)
taxonomy_update_dependencies ()
_update_7002_taxonomy_get_vocabularies ()
taxonomy_update_7001 ()
taxonomy_update_7002 ()
taxonomy_update_7003 ()
taxonomy_update_7004 ()
taxonomy_update_7005 (&$sandbox)
taxonomy_update_7006 ()
taxonomy_update_7007 ()
taxonomy_update_7008 ()
taxonomy_update_7009 ()
taxonomy_update_7010 ()
taxonomy_update_7011 ()

Detailed Description

Install, update and uninstall functions for the taxonomy module.

Definition in file taxonomy.install.

Function Documentation

taxonomy_field_schema ( $field )

Implements hook_field_schema().

Definition at line 229 of file taxonomy.install.

taxonomy_schema ( )

Implements hook_schema().

Definition at line 25 of file taxonomy.install.

taxonomy_uninstall ( )

Implements hook_uninstall().

Definition at line 11 of file taxonomy.install.

References db_query(), field_attach_delete_bundle(), and variable_del().

taxonomy_update_7001 ( )

Rename taxonomy tables.

Definition at line 278 of file taxonomy.install.

References db_rename_table().

taxonomy_update_7002 ( )

Add {vocabulary}.machine_name column.

Definition at line 291 of file taxonomy.install.

References db_add_field(), db_add_unique_key(), db_query(), and db_update().

taxonomy_update_7003 ( )

Remove the related terms setting from vocabularies.

This setting has not been used since Drupal 6. The {taxonomy_relations} table itself is retained to allow for data to be upgraded.

Definition at line 324 of file taxonomy.install.

References db_drop_field().

taxonomy_update_7004 ( )

Move taxonomy vocabulary associations for nodes to fields and field instances.

Definition at line 331 of file taxonomy.install.

References _update_7000_field_create_field(), _update_7000_field_create_instance(), _update_7000_node_get_types(), _update_7002_taxonomy_get_vocabularies(), db_create_table(), db_drop_field(), db_query(), and FIELD_CARDINALITY_UNLIMITED.

taxonomy_update_7005 ( & $sandbox )

Migrate {taxonomy_term_node} table to field storage.

Definition at line 526 of file taxonomy.install.

References _update_7000_field_delete_field(), _update_7000_field_delete_instance(), _update_7000_field_read_fields(), db_create_table(), db_drop_table(), db_insert(), db_query(), db_query_range(), db_select(), FIELD_CARDINALITY_UNLIMITED, and LANGUAGE_NONE.

taxonomy_update_7006 ( )

Add {taxonomy_term_data}.format column.

Definition at line 828 of file taxonomy.install.

References db_add_field().

taxonomy_update_7007 ( )

Add index on {taxonomy_term_data}.name column to speed up taxonomy_get_term_by_name().

Definition at line 840 of file taxonomy.install.

References db_add_index().

taxonomy_update_7008 ( )

Change the weight columns to normal int.

Definition at line 847 of file taxonomy.install.

References db_change_field(), and db_drop_index().

taxonomy_update_7009 ( )

Change {taxonomy_term_data}.format into varchar.

Definition at line 876 of file taxonomy.install.

References db_change_field().

taxonomy_update_7010 ( )

Change {taxonomy_index}.created to support signed int.

Definition at line 888 of file taxonomy.install.

References db_change_field().

taxonomy_update_dependencies ( )

Implements hook_update_dependencies().

Definition at line 253 of file taxonomy.install.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy/taxonomy.module File Reference

  • modules
  • taxonomy
Classes | Functions
taxonomy.module File Reference

Go to the source code of this file.

Classes

class | TaxonomyTermController
class | TaxonomyVocabularyController

Functions

taxonomy_help ($path, $arg)
taxonomy_permission ()
taxonomy_entity_info ()
taxonomy_term_uri ($term)
taxonomy_field_extra_fields ()
taxonomy_select_nodes ($tid, $pager=TRUE, $limit=FALSE, $order=array('t.sticky'=> 'DESC', 't.created'=> 'DESC'))
taxonomy_theme ()
taxonomy_menu ()
taxonomy_admin_paths ()
taxonomy_term_edit_access ($term)
taxonomy_admin_vocabulary_title_callback ($vocabulary)
taxonomy_vocabulary_save ($vocabulary)
taxonomy_vocabulary_delete ($vid)
taxonomy_taxonomy_vocabulary_update ($vocabulary)
taxonomy_check_vocabulary_hierarchy ($vocabulary, $changed_term)
taxonomy_term_save ($term)
taxonomy_term_delete ($tid)
taxonomy_term_show ($term)
taxonomy_term_view_multiple ($terms, $view_mode= 'teaser', $weight=0, $langcode=NULL)
taxonomy_term_build_content ($term, $view_mode= 'full', $langcode=NULL)
taxonomy_term_view ($term, $view_mode= 'full', $langcode=NULL)
template_preprocess_taxonomy_term (&$variables)
taxonomy_term_is_page ($term)
taxonomy_terms_static_reset ()
taxonomy_vocabulary_static_reset ($ids=NULL)
taxonomy_get_vocabularies ()
taxonomy_vocabulary_get_names ()
taxonomy_get_parents ($tid)
taxonomy_get_parents_all ($tid)
taxonomy_get_children ($tid, $vid=0)
taxonomy_get_tree ($vid, $parent=0, $max_depth=NULL, $load_entities=FALSE)
taxonomy_get_term_by_name ($name, $vocabulary=NULL)
taxonomy_term_load_multiple ($tids=array(), $conditions=array())
taxonomy_vocabulary_load_multiple ($vids=array(), $conditions=array())
taxonomy_vocabulary_load ($vid)
taxonomy_vocabulary_machine_name_load ($name)
taxonomy_term_load ($tid)
_taxonomy_get_tid_from_term ($term)
taxonomy_implode_tags ($tags, $vid=NULL)
taxonomy_field_info ()
taxonomy_field_widget_info ()
taxonomy_field_widget_info_alter (&$info)
taxonomy_options_list ($field, $instance, $entity_type, $entity)
taxonomy_field_validate ($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
taxonomy_field_is_empty ($item, $field)
taxonomy_field_formatter_info ()
taxonomy_field_formatter_view ($entity_type, $entity, $field, $instance, $langcode, $items, $display)
taxonomy_allowed_values ($field)
taxonomy_field_formatter_prepare_view ($entity_type, $entities, $field, $instances, $langcode, &$items, $displays)
taxonomy_term_title ($term)
taxonomy_field_widget_form (&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
taxonomy_autocomplete_validate ($element, &$form_state)
taxonomy_field_widget_error ($element, $error, $form, &$form_state)
taxonomy_field_settings_form ($field, $instance, $has_data)
taxonomy_rdf_mapping ()
taxonomy_field_presave ($entity_type, $entity, $field, $instance, $langcode, &$items)
taxonomy_node_insert ($node)
taxonomy_build_node_index ($node)
taxonomy_node_update ($node)
taxonomy_node_delete ($node)
taxonomy_delete_node_index ($node)
taxonomy_taxonomy_term_delete ($term)
taxonomy_entity_query_alter ($query)

Detailed Description

Enables the organization of content into categories.

Definition in file taxonomy.module.

Function Documentation

_taxonomy_get_tid_from_term ( $term )

Helper function for array_map purposes.

Definition at line 1394 of file taxonomy.module.

taxonomy_admin_paths ( )

Implements hook_admin_paths().

Definition at line 363 of file taxonomy.module.

taxonomy_admin_vocabulary_title_callback ( $vocabulary )

Returns the sanitized name of a vocabulary.

Deprecated. This function was previously used as a menu item title callback but has been replaced by using entity_label() (which does not sanitize the title, since the menu system does that automatically). In Drupal 7, use that function for title callbacks, and call check_plain() directly if you need a sanitized title.

Definition at line 386 of file taxonomy.module.

References check_plain().

taxonomy_allowed_values ( $field )

Returns the set of valid terms for a taxonomy field.

Parameters
$field The field definition.
Returns
The array of valid terms for this field, keyed by term id.

Definition at line 1641 of file taxonomy.module.

References $tree, taxonomy_get_tree(), and taxonomy_vocabulary_machine_name_load().

taxonomy_autocomplete_validate | ( |  | $element,
 |  | & | $form_state
 | ) |  |

Form element validate handler for taxonomy term autocomplete element.

Definition at line 1742 of file taxonomy.module.

References $tree, $value, drupal_explode_tags(), field_widget_field(), form_set_value(), taxonomy_term_load_multiple(), and taxonomy_vocabulary_machine_name_load().

taxonomy_check_vocabulary_hierarchy | ( | $vocabulary,
 |  | $changed_term
 | ) |

Checks and updates the hierarchy flag of a vocabulary.

Checks the current parents of all terms in a vocabulary and updates the vocabulary's hierarchy setting to the lowest possible level. If no term has parent terms then the vocabulary will be given a hierarchy of 0. If any term has a single parent then the vocabulary will be given a hierarchy of 1. If any term has multiple parents then the vocabulary will be given a hierarchy of 2.

Parameters
$vocabulary | A vocabulary object.
$changed_term | An array of the term structure that was updated.
Returns
An integer that represents the level of the vocabulary's hierarchy.

Definition at line 564 of file taxonomy.module.

References $tree, taxonomy_get_tree(), and taxonomy_vocabulary_save().

Referenced by taxonomy_form_term_submit(), and taxonomy_term_confirm_delete_submit().

taxonomy_entity_info ( )

Implements hook_entity_info().

Definition at line 91 of file taxonomy.module.

References t(), and taxonomy_vocabulary_get_names().

taxonomy_entity_query_alter ( $query )

End of "defgroup taxonomy_index". Implements hook_entity_query_alter().

Converts EntityFieldQuery instances on taxonomy terms that have an entity condition on term bundles (vocabulary machine names). Since the vocabulary machine name is not present in the {taxonomy_term_data} table itself, we have to convert the bundle condition into a property condition of vocabulary IDs to match against {taxonomy_term_data}.vid.

Definition at line 2027 of file taxonomy.module.

References taxonomy_vocabulary_get_names().

taxonomy_field_extra_fields ( )

Implements hook_field_extra_fields().

Definition at line 154 of file taxonomy.module.

References $info, entity_get_info(), and t().

taxonomy_field_formatter_info ( )

Implements hook_field_formatter_info().

Definition at line 1560 of file taxonomy.module.

References t().

taxonomy_field_formatter_prepare_view | ( |  | $entity_type,
 |  |  | $entities,
 |  |  | $field,
 |  |  | $instances,
 |  |  | $langcode,
 |  | & | $items,
 |  |  | $displays
 | ) |  |

Implements hook_field_formatter_prepare_view().

This preloads all taxonomy terms for multiple loaded objects at once and unsets values for invalid terms that do not exist.

Definition at line 1661 of file taxonomy.module.

References taxonomy_term_load_multiple().

taxonomy_field_formatter_view | ( | $entity_type,
 |  | $entity,
 |  | $field,
 |  | $instance,
 |  | $langcode,
 |  | $items,
 |  | $display
 | ) |

Implements hook_field_formatter_view().

Definition at line 1580 of file taxonomy.module.

References $name, check_plain(), entity_uri(), name, and url().

taxonomy_field_info ( )

Implements hook_field_info().

Field settings:

  • allowed_values: a list array of one or more vocabulary trees:
    • vocabulary: a vocabulary machine name.
    • parent: a term ID of a term whose children are allowed. This should be '0' if all terms in a vocabulary are allowed. The allowed values do not include the parent term.

Definition at line 1434 of file taxonomy.module.

References t().

taxonomy_field_is_empty | ( | $item,
 |  | $field
 | ) |

Implements hook_field_is_empty().

Definition at line 1550 of file taxonomy.module.

taxonomy_field_settings_form | ( | $field,
 |  | $instance,
 |  | $has_data
 | ) |

Implements hook_field_settings_form().

Definition at line 1789 of file taxonomy.module.

References $tree, t(), and taxonomy_get_vocabularies().

taxonomy_field_validate | ( |  | $entity_type,
 |  |  | $entity,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  | & | $errors
 | ) |  |

Implements hook_field_validate().

Taxonomy field settings allow for either a single vocabulary ID, multiple vocabulary IDs, or sub-trees of a vocabulary to be specified as allowed values, although only the first of these is supported via the field UI. Confirm that terms entered as values meet at least one of these conditions.

Possible error codes:

  • 'taxonomy_term_illegal_value': The value is not part of the list of allowed values.

Definition at line 1499 of file taxonomy.module.

References t(), taxonomy_get_parents_all(), and taxonomy_term_load_multiple().

taxonomy_field_widget_error | ( |  | $element,
 |  |  | $error,
 |  |  | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_field_widget_error().

Definition at line 1783 of file taxonomy.module.

References form_error().

taxonomy_field_widget_form | ( | & | $form,
 |  | & | $form_state,
 |  |  | $field,
 |  |  | $instance,
 |  |  | $langcode,
 |  |  | $items,
 |  |  | $delta,
 |  |  | $element
 | ) |  |

Implements hook_field_widget_form().

Definition at line 1721 of file taxonomy.module.

References taxonomy_implode_tags(), and taxonomy_term_load().

taxonomy_field_widget_info ( )

Implements hook_field_widget_info().

Definition at line 1456 of file taxonomy.module.

References FIELD_BEHAVIOR_CUSTOM, and t().

taxonomy_field_widget_info_alter ( & $info )

Implements hook_field_widget_info_alter().

Definition at line 1475 of file taxonomy.module.

References $info.

taxonomy_get_children | ( | $tid,
 |  | $vid = 0
 | ) |

Finds all children of a term ID.

Parameters
$tid | A taxonomy term ID.
$vid | An optional vocabulary ID to restrict the child search.
Returns
An array of term objects that are the children of the term $tid, or an empty array when no children exist.

Definition at line 1062 of file taxonomy.module.

References $children, db_select(), drupal_static(), and taxonomy_term_load_multiple().

Referenced by taxonomy_term_delete().

taxonomy_get_parents ( $tid )

Finds all parents of a given term ID.

Parameters
$tid A taxonomy term ID.
Returns
An array of term objects which are the parents of the term $tid, or an empty array if parents are not found.

Definition at line 1007 of file taxonomy.module.

References db_select(), drupal_static(), and taxonomy_term_load_multiple().

Referenced by _forum_parent_select(), taxonomy_form_term(), taxonomy_get_parents_all(), taxonomy_term_delete(), taxonomy_term_page(), and taxonomy_tokens().

taxonomy_get_parents_all ( $tid )

Find all ancestors of a given term ID.

Definition at line 1028 of file taxonomy.module.

References drupal_static(), taxonomy_get_parents(), taxonomy_term_load(), and tid.

Referenced by forum_forum_load(), forum_node_view(), and taxonomy_field_validate().

taxonomy_get_term_by_name | ( | $name,
 |  | $vocabulary = NULL
 | ) |

Try to map a string to an existing term, as for glossary use.

Provides a case-insensitive and trimmed mapping, to maximize the likelihood of a successful match.

Parameters
$name | Name of the term to search for.
$vocabulary | (optional) Vocabulary machine name to limit the search. Defaults to NULL.
Returns
An array of matching term objects.

Definition at line 1215 of file taxonomy.module.

References $name, taxonomy_term_load_multiple(), and taxonomy_vocabulary_get_names().

taxonomy_get_tree | ( | $vid,
 |  | $parent = 0,
 |  | $max_depth = NULL,
 |  | $load_entities = FALSE
 | ) |

Create a hierarchical representation of a vocabulary.

Parameters
$vid | Which vocabulary to generate the tree for.
$parent | The term ID under which to generate the tree. If 0, generate the tree for the entire vocabulary.
$max_depth | The number of levels of the tree to return. Leave NULL to return all levels.
$load_entities | If TRUE, a full entity load will occur on the term objects. Otherwise they are partial objects queried directly from the {taxonomy_term_data} table to save execution time and memory consumption when listing large numbers of terms. Defaults to FALSE.
Returns
An array of all term objects in the tree. Each term object is extended to have "depth" and "parents" attributes in addition to its normal ones. Results are statically cached. Term objects will be partial or complete depending on the $load_entities parameter.

Definition at line 1105 of file taxonomy.module.

References $children, $depth, $tree, db_select(), drupal_static(), and taxonomy_term_load_multiple().

Referenced by _forum_parent_select(), forum_forum_load(), hook_options_list(), taxonomy_allowed_values(), taxonomy_check_vocabulary_hierarchy(), taxonomy_form_term(), taxonomy_overview_terms(), and taxonomy_overview_terms_submit().

taxonomy_get_vocabularies ( )

Return an array of all vocabulary objects.

Returns
An array of all vocabulary objects, indexed by vid.

Definition at line 973 of file taxonomy.module.

References taxonomy_vocabulary_load_multiple().

Referenced by taxonomy_field_settings_form(), taxonomy_overview_vocabularies(), and taxonomy_permission().

taxonomy_help | ( | $path,
 |  | $arg
 | ) |

Users can create new terms in a free-tagging vocabulary when submitting a taxonomy_autocomplete_widget. We store a term object whose tid is 'autocreate' as a field data item during widget validation and then actually create the term if/when that field data item makes it to taxonomy_field_insert/update(). Implements hook_help().

Definition at line 19 of file taxonomy.module.

References $output, drupal_ucfirst(), t(), taxonomy_vocabulary_machine_name_load(), and url().

taxonomy_implode_tags | ( | $tags,
 |  | $vid = NULL
 | ) |

Implodes a list of tags of a certain vocabulary into a string.

See Also
drupal_explode_tags()

Definition at line 1403 of file taxonomy.module.

Referenced by taxonomy_field_widget_form().

taxonomy_menu ( )

Implements hook_menu().

Definition at line 259 of file taxonomy.module.

References MENU_CALLBACK, MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION, and MENU_LOCAL_TASK.

taxonomy_options_list | ( | $field,
 |  | $instance,
 |  | $entity_type,
 |  | $entity
 | ) |

Implements hook_options_list().

Definition at line 1483 of file taxonomy.module.

taxonomy_permission ( )

Implements hook_permission().

Definition at line 67 of file taxonomy.module.

References t(), and taxonomy_get_vocabularies().

taxonomy_rdf_mapping ( )

Implements hook_rdf_mapping().

Returns
array The rdf mapping for vocabularies and terms.

Definition at line 1825 of file taxonomy.module.

References RDF_DEFAULT_BUNDLE.

taxonomy_select_nodes | ( | $tid,
 |  | $pager = TRUE,
 |  | $limit = FALSE,
 |  | $order = array('t.sticky' => 'DESC', 't.created' => 'DESC')
 | ) |

Return nodes attached to a term across all field instances.

This function requires taxonomy module to be maintaining its own tables, and will return an empty array if it is not. If using other field storage methods alternatives methods for listing terms will need to be used.

Parameters
$tid | The term ID.
$pager | Boolean to indicate whether a pager should be used.
$limit | Integer. The maximum number of nodes to find. Set to FALSE for no limit.
$order | An array of fields and directions.
Returns
An array of nids matching the query.

Definition at line 204 of file taxonomy.module.

References $name, $pager, db_select(), and variable_get().

Referenced by taxonomy_term_feed(), and taxonomy_term_page().

taxonomy_taxonomy_vocabulary_update ( $vocabulary )

Implements hook_taxonomy_vocabulary_update().

Definition at line 524 of file taxonomy.module.

References $value, field_read_fields(), and field_update_field().

taxonomy_term_build_content | ( | $term,
 |  | $view_mode = 'full',
 |  | $langcode = NULL
 | ) |

Builds a structured array representing the term's content.

The content built for the taxonomy term (field values, file attachments or other term components) will vary depending on the $view_mode parameter.

Drupal core defines the following view modes for terms, with the following default use cases:

  • full (default): term is displayed on its own page (taxonomy/term/123) Contributed modules might define additional view modes, or use existing view modes in additional contexts.
Parameters
$term | A taxonomy term object.
$view_mode | View mode, e.g. 'full', 'teaser'...
$langcode | (optional) A language code to use for rendering. Defaults to the global content language of the current request.

Definition at line 806 of file taxonomy.module.

References check_markup(), drupal_alter(), entity_extract_ids(), entity_prepare_view(), field_attach_prepare_view(), field_attach_view(), field_extra_fields_get_display(), field_view_mode_settings(), and module_invoke_all().

Referenced by taxonomy_term_view().

taxonomy_term_delete ( $tid )

Delete a term.

Parameters
$tid The term ID.
Returns
Status constant indicating deletion.

Definition at line 701 of file taxonomy.module.

References $children, db_delete(), db_transaction(), field_attach_delete(), module_invoke_all(), SAVED_DELETED, taxonomy_get_children(), taxonomy_get_parents(), taxonomy_term_load(), taxonomy_terms_static_reset(), and watchdog_exception().

Referenced by forum_confirm_delete_submit(), taxonomy_term_confirm_delete_submit(), and taxonomy_vocabulary_delete().

taxonomy_term_edit_access ( $term )

Return edit access for a given term.

Definition at line 373 of file taxonomy.module.

References user_access().

taxonomy_term_is_page ( $term )

Returns whether the current page is the page of the passed-in term.

Parameters
$term A term object.

Definition at line 937 of file taxonomy.module.

References menu_get_object().

Referenced by template_preprocess_taxonomy_term().

taxonomy_term_load ( $tid )

Return the term object matching a term ID.

Parameters
$tid A term's ID
Returns
A taxonomy term object, or FALSE if the term was not found. Results are statically cached.

Definition at line 1383 of file taxonomy.module.

References taxonomy_term_load_multiple().

Referenced by forum_confirm_delete(), forum_forum_load(), forum_node_validate(), taxonomy_field_widget_form(), taxonomy_get_parents_all(), taxonomy_term_confirm_delete(), and taxonomy_term_delete().

taxonomy_term_load_multiple | ( | $tids = array(),
 |  | $conditions = array()
 | ) |

Load multiple taxonomy terms based on certain conditions.

This function should be used whenever you need to load more than one term from the database. Terms are loaded into memory and will not require database access if loaded again during the same page request.

See Also
entity_load()
EntityFieldQuery
Parameters
$tids | An array of taxonomy term IDs.
$conditions | (deprecated) An associative array of conditions on the {taxonomy_term} table, where the keys are the database fields and the values are the values those fields must have. Instead, it is preferable to use EntityFieldQuery to retrieve a list of entity IDs loadable by this function.
Returns
An array of term objects, indexed by tid. When no results are found, an empty array is returned.

Definition at line 1314 of file taxonomy.module.

References entity_load().

Referenced by hook_field_formatter_prepare_view(), taxonomy_autocomplete_validate(), taxonomy_field_formatter_prepare_view(), taxonomy_field_validate(), taxonomy_get_children(), taxonomy_get_parents(), taxonomy_get_term_by_name(), taxonomy_get_tree(), and taxonomy_term_load().

taxonomy_term_save ( $term )

Saves a term object to the database.

Parameters
$term The taxonomy term object with the following properties:
  • vid: The ID of the vocabulary the term is assigned to.
  • name: The name of the term.
  • tid: (optional) The unique ID for the term being saved. If $term->tid is empty or omitted, a new term will be inserted.
  • description: (optional) The term's description.
  • format: (optional) The text format for the term's description.
  • weight: (optional) The weight of this term in relation to other terms within the same vocabulary.
  • parent: (optional) The parent term(s) for this term. This can be a single term ID or an array of term IDs. A value of 0 means this term does not have any parents. When omitting this variable during an update, the existing hierarchy for the term remains unchanged.
  • vocabulary_machine_name: (optional) The machine name of the vocabulary the term is assigned to. If not given, this value will be set automatically by loading the vocabulary based on $term->vid.
  • original: (optional) The original taxonomy term object before any changes were applied. When omitted, the unchanged taxonomy term object is loaded from the database and stored in this property. Since a taxonomy term is an entity, any fields contained in the term object are saved alongside the term object.
Returns
Status constant indicating whether term was inserted (SAVED_NEW) or updated (SAVED_UPDATED). When inserting a new term, $term->tid will contain the term ID of the newly created term.

Definition at line 621 of file taxonomy.module.

References $op, db_delete(), db_insert(), drupal_write_record(), entity_load_unchanged(), field_attach_insert(), field_attach_presave(), field_attach_update(), module_invoke_all(), taxonomy_terms_static_reset(), and taxonomy_vocabulary_load().

Referenced by forum_enable(), forum_form_submit(), taxonomy_field_presave(), and taxonomy_form_term_submit().

taxonomy_term_show ( $term )

Generates an array which displays a term detail page.

Parameters
term A taxonomy term object.
Returns
A $page element suitable for use by drupal_page_render().

Definition at line 753 of file taxonomy.module.

References taxonomy_term_view_multiple().

taxonomy_term_title ( $term )

Title callback for term pages.

Parameters
$term A term object.
Returns
The term name to be used as the page title.

Definition at line 1714 of file taxonomy.module.

taxonomy_term_uri ( $term )

Implements callback_entity_info_uri().

Definition at line 145 of file taxonomy.module.

taxonomy_term_view | ( | $term,
 |  | $view_mode = 'full',
 |  | $langcode = NULL
 | ) |

Generate an array for rendering the given term.

Parameters
$term | A term object.
$view_mode | View mode, e.g. 'full', 'teaser'...
$langcode | (optional) A language code to use for rendering. Defaults to the global content language of the current request.
Returns
An array as expected by drupal_render().

Definition at line 867 of file taxonomy.module.

References drupal_alter(), drupal_get_path(), and taxonomy_term_build_content().

Referenced by taxonomy_term_page(), and taxonomy_term_view_multiple().

taxonomy_term_view_multiple | ( | $terms,
 |  | $view_mode = 'teaser',
 |  | $weight = 0,
 |  | $langcode = NULL
 | ) |

Constructs a drupal_render() style array from an array of loaded terms.

Parameters
$terms | An array of taxonomy terms as returned by taxonomy_term_load_multiple().
$view_mode | View mode, e.g. 'full', 'teaser'...
$weight | An integer representing the weight of the first taxonomy term in the list.
$langcode | (optional) A language code to use for rendering. Defaults to the global content language of the current request.
Returns
An array in the format expected by drupal_render().

Definition at line 773 of file taxonomy.module.

References entity_prepare_view(), field_attach_prepare_view(), and taxonomy_term_view().

Referenced by taxonomy_term_show().

taxonomy_terms_static_reset ( )

Clear all static cache variables for terms.

Definition at line 945 of file taxonomy.module.

References drupal_static_reset(), and entity_get_controller().

Referenced by taxonomy_term_delete(), and taxonomy_term_save().

taxonomy_theme ( )

Implements hook_theme().

Definition at line 241 of file taxonomy.module.

taxonomy_vocabulary_delete ( $vid )

Delete a vocabulary.

Parameters
$vid A vocabulary ID.
Returns
Constant indicating items were deleted.

Definition at line 467 of file taxonomy.module.

References cache_clear_all(), db_delete(), db_query(), db_transaction(), field_attach_delete_bundle(), field_delete_field(), field_read_fields(), field_update_field(), module_invoke_all(), SAVED_DELETED, taxonomy_term_delete(), taxonomy_vocabulary_load(), taxonomy_vocabulary_static_reset(), and watchdog_exception().

Referenced by taxonomy_vocabulary_confirm_delete_submit().

taxonomy_vocabulary_get_names ( )

Get names for all taxonomy vocabularies.

Returns
An associative array of objects keyed by vocabulary machine name with information about taxonomy vocabularies. Each object has properties:
  • name: The vocabulary name.
  • machine_name: The machine name.
  • vid: The vocabulary ID.

Definition at line 987 of file taxonomy.module.

References db_query(), and drupal_static().

Referenced by forum_entity_info_alter(), taxonomy_autocomplete(), taxonomy_entity_info(), taxonomy_entity_query_alter(), and taxonomy_get_term_by_name().

taxonomy_vocabulary_load ( $vid )

Return the vocabulary object matching a vocabulary ID.

Parameters
$vid The vocabulary's ID.
Returns
The vocabulary object with all of its metadata, if exists, FALSE otherwise. Results are statically cached.
See Also
taxonomy_vocabulary_machine_name_load()

Definition at line 1351 of file taxonomy.module.

References taxonomy_vocabulary_load_multiple().

Referenced by forum_enable(), forum_node_view(), forum_overview(), hook_mail(), taxonomy_form_term(), taxonomy_term_save(), taxonomy_tokens(), taxonomy_vocabulary_confirm_delete(), taxonomy_vocabulary_confirm_reset_alphabetical(), taxonomy_vocabulary_delete(), and template_preprocess_forums().

taxonomy_vocabulary_load_multiple | ( | $vids = array(),
 |  | $conditions = array()
 | ) |

Load multiple taxonomy vocabularies based on certain conditions.

This function should be used whenever you need to load more than one vocabulary from the database. Terms are loaded into memory and will not require database access if loaded again during the same page request.

See Also
entity_load()
Parameters
$vids | An array of taxonomy vocabulary IDs, or FALSE to load all vocabularies.
$conditions | An array of conditions to add to the query.
Returns
An array of vocabulary objects, indexed by vid.

Definition at line 1335 of file taxonomy.module.

References entity_load().

Referenced by taxonomy_get_vocabularies(), taxonomy_vocabulary_load(), and taxonomy_vocabulary_machine_name_load().

taxonomy_vocabulary_machine_name_load ( $name )

Return the vocabulary object matching a vocabulary machine name.

Parameters
$name The vocabulary's machine name.
Returns
The vocabulary object with all of its metadata, if exists, FALSE otherwise. Results are statically cached.
See Also
taxonomy_vocabulary_load()

Definition at line 1368 of file taxonomy.module.

References $name, and taxonomy_vocabulary_load_multiple().

Referenced by taxonomy_allowed_values(), taxonomy_autocomplete_validate(), and taxonomy_help().

taxonomy_vocabulary_save ( $vocabulary )

Saves a vocabulary.

Parameters
$vocabulary A vocabulary object with the following properties:
  • vid: (optional) The ID of the vocabulary (omit if creating a new vocabulary; only use to update an existing vocabulary).
  • name: The human-readable name of the vocabulary.
  • machine_name: The machine name of the vocabulary.
  • description: (optional) The vocabulary's description.
  • hierarchy: The hierarchy level of the vocabulary.
  • module: (optional) The module altering the vocabulary.
  • weight: (optional) The weight of this vocabulary in relation to other vocabularies.
  • original: (optional) The original vocabulary object before any changes are applied.
  • old_machine_name: (optional) The original machine name of the vocabulary.
Returns
Status constant indicating whether the vocabulary was inserted (SAVED_NEW) or updated (SAVED_UPDATED).

Definition at line 413 of file taxonomy.module.

References cache_clear_all(), drupal_write_record(), entity_load_unchanged(), field_attach_create_bundle(), field_attach_rename_bundle(), module_invoke_all(), and taxonomy_vocabulary_static_reset().

Referenced by forum_enable(), standard_install(), taxonomy_check_vocabulary_hierarchy(), taxonomy_form_term_submit(), taxonomy_form_vocabulary_submit(), taxonomy_overview_terms_submit(), and taxonomy_overview_vocabularies_submit().

taxonomy_vocabulary_static_reset ( $ids = NULL )

Clear all static cache variables for vocabularies.

Parameters
$ids An array of ids to reset in entity controller cache.

Definition at line 962 of file taxonomy.module.

References drupal_static_reset(), and entity_get_controller().

Referenced by taxonomy_vocabulary_delete(), and taxonomy_vocabulary_save().

template_preprocess_taxonomy_term ( & $variables )

Process variables for taxonomy-term.tpl.php.

Definition at line 898 of file taxonomy.module.

References check_plain(), element_children(), entity_uri(), field_attach_preprocess(), taxonomy_term_is_page(), and url().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy/taxonomy.pages.inc File Reference

  • modules
  • taxonomy
Functions
taxonomy.pages.inc File Reference

Go to the source code of this file.

Functions

taxonomy_term_page ($term)
taxonomy_term_feed ($term)
taxonomy_autocomplete ($field_name= '', $tags_typed= '')

Detailed Description

Page callbacks for the taxonomy module.

Definition in file taxonomy.pages.inc.

Function Documentation

taxonomy_autocomplete | ( | $field_name = '',
 |  | $tags_typed = ''
 | ) |

Page callback: Outputs JSON for taxonomy autocomplete suggestions.

Path: taxonomy/autocomplete

This callback outputs term name suggestions in response to Ajax requests made by the taxonomy autocomplete widget for taxonomy term reference fields. The output is a JSON object of plain-text term suggestions, keyed by the user-entered value with the completed term name appended. Term names containing commas are wrapped in quotes.

For example, suppose the user has entered the string 'red fish, blue' in the field, and there are two taxonomy terms, 'blue fish' and 'blue moon'. The JSON output would have the following structure:

* {
* "red fish, blue fish": "blue fish",
* "red fish, blue moon": "blue moon",
* };
*
Parameters
$field_name | The name of the term reference field.
$tags_typed | (optional) A comma-separated list of term names entered in the autocomplete form element. Only the last term is used for autocompletion. Defaults to '' (an empty string).
See Also
taxonomy_menu()
taxonomy_field_widget_info()

Definition at line 121 of file taxonomy.pages.inc.

References $name, $tree, check_plain(), db_like(), db_select(), drupal_explode_tags(), drupal_implode_tags(), drupal_json_output(), drupal_strtolower(), field_info_field(), print, t(), and taxonomy_vocabulary_get_names().

taxonomy_term_feed ( $term )

Generate the content feed for a taxonomy term.

Parameters
$term The taxonomy term.

Definition at line 79 of file taxonomy.pages.inc.

References check_markup(), node_feed(), taxonomy_select_nodes(), url(), and variable_get().

taxonomy_term_page ( $term )

Menu callback; displays all nodes associated with a term.

Parameters
$term The taxonomy term.
Returns
The page content.

Definition at line 16 of file taxonomy.pages.inc.

References $breadcrumb, drupal_add_feed(), drupal_add_html_head_link(), drupal_set_breadcrumb(), drupal_set_title(), entity_uri(), l(), node_load_multiple(), node_view_multiple(), t(), taxonomy_get_parents(), taxonomy_select_nodes(), taxonomy_term_view(), url(), and variable_get().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy/taxonomy.tokens.inc File Reference

  • modules
  • taxonomy
Functions
taxonomy.tokens.inc File Reference

Go to the source code of this file.

Functions

taxonomy_token_info ()
taxonomy_tokens ($type, $tokens, array $data=array(), array $options=array())

Detailed Description

Builds placeholder replacement tokens for taxonomy terms and vocabularies.

Definition in file taxonomy.tokens.inc.

Function Documentation

taxonomy_token_info ( )

Implements hook_token_info().

Definition at line 11 of file taxonomy.tokens.inc.

References t().

taxonomy_tokens | ( |  | $type,
 |  |  | $tokens,
 |  | array | $data = array(),
 |  | array | $options = array()
 | ) |  |

Implements hook_tokens().

Definition at line 91 of file taxonomy.tokens.inc.

References $name, check_markup(), check_plain(), db_select(), entity_uri(), filter_xss(), taxonomy_get_parents(), taxonomy_vocabulary_load(), token_find_with_prefix(), token_generate(), and url().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/toolbar Directory Reference

  • modules
  • toolbar
toolbar Directory Reference

Files

file | toolbar.module [code]
file | toolbar.tpl.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/toolbar/toolbar.module File Reference

  • modules
  • toolbar
Functions
toolbar.module File Reference

Go to the source code of this file.

Functions

toolbar_help ($path, $arg)
toolbar_permission ()
toolbar_theme ($existing, $type, $theme, $path)
toolbar_menu ()
toolbar_toggle_page ()
theme_toolbar_toggle ($variables)
_toolbar_is_collapsed ()
toolbar_page_build (&$page)
toolbar_pre_render ($toolbar)
toolbar_preprocess_html (&$vars)
toolbar_preprocess_toolbar (&$variables)
toolbar_system_info_alter (&$info, $file, $type)
toolbar_view ()
toolbar_get_menu_tree ()
toolbar_menu_navigation_links ($tree)
toolbar_in_active_trail ($path)

Detailed Description

Administration toolbar for quick access to top level administration items.

Definition in file toolbar.module.

Function Documentation

_toolbar_is_collapsed ( )

Determines the current state of the toolbar drawer's visibility.

Returns
TRUE when drawer is collapsed, FALSE when it is expanded.

Definition at line 108 of file toolbar.module.

Referenced by toolbar_preprocess_html(), toolbar_toggle_page(), and toolbar_view().

theme_toolbar_toggle ( $variables )

Formats an element used to toggle the toolbar drawer's visibility.

Parameters
$variables An associative array containing:
  • collapsed: A boolean value representing the toolbar drawer's visibility.
  • attributes: An associative array of HTML attributes.
Returns
An HTML string representing the element for toggling.

Definition at line 91 of file toolbar.module.

References drupal_get_destination(), l(), and t().

toolbar_get_menu_tree ( )

Gets only the top level items below the 'admin' path.

Returns
An array containing a menu tree of top level items below the 'admin' path.

Definition at line 284 of file toolbar.module.

References $tree, db_query(), and menu_build_tree().

Referenced by toolbar_view().

toolbar_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file toolbar.module.

References $output, t(), and url().

toolbar_in_active_trail ( $path )

Checks whether an item is in the active trail.

Useful when using a menu generated by menu_tree_all_data() which does not set the 'in_active_trail' flag on items.

Returns
TRUE when path is in the active trail, FALSE if not.

Definition at line 349 of file toolbar.module.

References drupal_static(), and menu_get_active_trail().

Referenced by toolbar_menu_navigation_links().

toolbar_menu ( )

Implements hook_menu().

Definition at line 57 of file toolbar.module.

References MENU_CALLBACK.

toolbar_menu_navigation_links ( $tree )

Generates a links array from a menu tree array.

Based on menu_navigation_links(). Adds path based IDs and icon placeholders to the links.

Returns
An array of links as defined above.

Definition at line 307 of file toolbar.module.

References $links, $tree, check_plain(), and toolbar_in_active_trail().

Referenced by toolbar_view().

toolbar_page_build ( & $page )

Implements hook_page_build().

Add admin toolbar to the page_top region automatically.

Definition at line 119 of file toolbar.module.

References $page, and user_access().

toolbar_permission ( )

Implements hook_permission().

Definition at line 28 of file toolbar.module.

References t().

toolbar_pre_render ( $toolbar )

Prerender function for the toolbar.

Since building the toolbar takes some time, it is done just prior to rendering to ensure that it is built only if it will be displayed.

Definition at line 133 of file toolbar.module.

References toolbar_view().

toolbar_preprocess_html ( & $vars )

Implements hook_preprocess_html().

Add some page classes, so global page theming can adjust to the toolbar.

Definition at line 143 of file toolbar.module.

References _toolbar_is_collapsed(), and user_access().

toolbar_preprocess_toolbar ( & $variables )

Implements hook_preprocess_toolbar().

Adding the 'overlay-displace-top' class to the toolbar pushes the overlay down, so it appears below the toolbar.

Definition at line 158 of file toolbar.module.

toolbar_system_info_alter | ( | & | $info,
 |  |  | $file,
 |  |  | $type
 | ) |  |

Implements hook_system_info_alter().

Indicate that the 'page_top' region (in which the toolbar will be displayed) is an overlay supplemental region that should be refreshed whenever its content is updated.

This information is provided for any module that might need to use it, not just the core Overlay module.

Definition at line 172 of file toolbar.module.

References $info.

toolbar_theme | ( | $existing,
 |  | $type,
 |  | $theme,
 |  | $path
 | ) |

Implements hook_theme().

Definition at line 39 of file toolbar.module.

References drupal_get_path().

toolbar_toggle_page ( )

Menu callback; toggles the visibility of the toolbar drawer.

Definition at line 70 of file toolbar.module.

References _toolbar_is_collapsed(), and drupal_goto().

toolbar_view ( )

Builds the admin menu as a structured array ready for drupal_render().

Returns
Array of links and settings relating to the admin menu.

Definition at line 184 of file toolbar.module.

References $links, _toolbar_is_collapsed(), drupal_get_path(), format_username(), t(), toolbar_get_menu_tree(), and toolbar_menu_navigation_links().

Referenced by toolbar_pre_render().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/tracker Directory Reference

  • modules
  • tracker
tracker Directory Reference

Files

file | tracker.install [code]
file | tracker.module [code]
file | tracker.pages.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/tracker/tracker.install File Reference

  • modules
  • tracker
Functions
tracker.install File Reference

Go to the source code of this file.

Functions

tracker_uninstall ()
tracker_enable ()
tracker_schema ()
tracker_update_7000 ()

Detailed Description

Install, update, and uninstall functions for tracker.module.

Definition in file tracker.install.

Function Documentation

tracker_enable ( )

Implements hook_enable().

Definition at line 19 of file tracker.install.

References db_query(), tracker_cron(), and variable_set().

tracker_schema ( )

Implements hook_schema().

Definition at line 32 of file tracker.install.

tracker_uninstall ( )

Implements hook_uninstall().

Definition at line 11 of file tracker.install.

References variable_del().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/tracker/tracker.module File Reference

  • modules
  • tracker
Functions
tracker.module File Reference

Go to the source code of this file.

Functions

tracker_help ($path, $arg)
tracker_menu ()
tracker_cron ()
_tracker_myrecent_access ($account)
_tracker_user_access ($account)
tracker_node_insert ($node, $arg=0)
tracker_node_update ($node, $arg=0)
tracker_node_delete ($node, $arg=0)
tracker_comment_update ($comment)
tracker_comment_publish ($comment)
tracker_comment_unpublish ($comment)
tracker_comment_delete ($comment)
_tracker_add ($nid, $uid, $changed)
_tracker_calculate_changed ($nid)
_tracker_remove ($nid, $uid=NULL, $changed=NULL)

Detailed Description

Tracks recent content posted by a user or users.

Definition in file tracker.module.

Function Documentation

_tracker_add | ( | $nid,
 |  | $uid,
 |  | $changed
 | ) |

Updates indexing tables when a node is added, updated, or commented on.

Parameters
$nid | A node ID.
$uid | The node or comment author.
$changed | The node updated timestamp or comment timestamp.

Definition at line 250 of file tracker.module.

References db_merge(), and db_query().

Referenced by tracker_comment_publish(), tracker_node_insert(), and tracker_node_update().

_tracker_calculate_changed ( $nid )

Determines the max timestamp between $node->changed and the last comment.

Parameters
$nid A node ID.
Returns
The $node->changed timestamp, or most recent comment timestamp, whichever is the greatest.

Definition at line 289 of file tracker.module.

References COMMENT_PUBLISHED, db_query(), and db_query_range().

Referenced by _tracker_remove(), and tracker_cron().

_tracker_myrecent_access ( $account )

Access callback for tracker/user_uid_optional.

Definition at line 158 of file tracker.module.

References user_access().

_tracker_remove | ( | $nid,
 |  | $uid = NULL,
 |  | $changed = NULL
 | ) |

Cleans up indexed data when nodes or comments are removed.

Parameters
$nid | The node ID.
$uid | The author of the node or comment.
$changed | The last changed timestamp of the node.

Definition at line 311 of file tracker.module.

References _tracker_calculate_changed(), COMMENT_PUBLISHED, db_delete(), db_query(), db_query_range(), and db_update().

Referenced by tracker_comment_delete(), tracker_comment_unpublish(), and tracker_comment_update().

_tracker_user_access ( $account )

Access callback for user/user/track.

Definition at line 166 of file tracker.module.

References user_access(), and user_view_access().

tracker_comment_delete ( $comment )

Implements hook_comment_delete().

Definition at line 236 of file tracker.module.

References _tracker_remove().

tracker_comment_publish ( $comment )

Implements hook_comment_publish().

This actually handles the insert and update of published nodes since comment_save() calls hook_comment_publish() for all published comments.

Definition at line 222 of file tracker.module.

References _tracker_add().

tracker_comment_unpublish ( $comment )

Implements hook_comment_unpublish().

Definition at line 229 of file tracker.module.

References _tracker_remove().

tracker_comment_update ( $comment )

Implements hook_comment_update().

Comment module doesn't call hook_comment_unpublish() when saving individual comments so we need to check for those here.

Definition at line 208 of file tracker.module.

References _tracker_remove(), and COMMENT_PUBLISHED.

tracker_cron ( )

Implements hook_cron().

Updates tracking information for any items still to be tracked. The variable 'tracker_index_nid' is set to ((the last node ID that was indexed) - 1) and used to select the nodes to be processed. If there are no remaining nodes to process, 'tracker_index_nid' will be 0.

Definition at line 79 of file tracker.module.

References $row, _tracker_calculate_changed(), COMMENT_PUBLISHED, db_delete(), db_insert(), db_query_range(), db_select(), variable_get(), variable_set(), and watchdog().

Referenced by tracker_enable().

tracker_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file tracker.module.

References $output, t(), and url().

tracker_menu ( )

Implements hook_menu().

Definition at line 32 of file tracker.module.

References MENU_DEFAULT_LOCAL_TASK, and MENU_LOCAL_TASK.

tracker_node_delete | ( | $node,
 |  | $arg = 0
 | ) |

Implements hook_node_delete().

Deletes tracking information for a node.

Definition at line 193 of file tracker.module.

References db_delete().

tracker_node_insert | ( | $node,
 |  | $arg = 0
 | ) |

Implements hook_node_insert().

Adds new tracking information for this node since it's new.

Definition at line 175 of file tracker.module.

References _tracker_add().

tracker_node_update | ( | $node,
 |  | $arg = 0
 | ) |

Implements hook_node_update().

Adds tracking information for this node since it's been updated.

Definition at line 184 of file tracker.module.

References _tracker_add().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/tracker/tracker.pages.inc File Reference

  • modules
  • tracker
Functions
tracker.pages.inc File Reference

Go to the source code of this file.

Functions

tracker_page ($account=NULL, $set_title=FALSE)

Detailed Description

User page callbacks for tracker.module.

Definition in file tracker.pages.inc.

Function Documentation

tracker_page | ( | $account = NULL,
 |  | $set_title = FALSE
 | ) |

Page callback: prints a listing of active nodes on the site.

Queries the database for info, adds RDFa info if applicable, and generates the render array that will be used to render the page.

Definition at line 15 of file tracker.pages.inc.

References $page, $row, check_plain(), comment_num_new(), db_query(), db_select(), drupal_get_path(), drupal_set_title(), format_interval(), format_plural(), format_username(), l(), node_mark(), node_type_get_name(), rdf_mapping_load(), rdf_rdfa_attributes(), REQUEST_TIME, t(), theme(), and url().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/translation Directory Reference

  • modules
  • translation
translation Directory Reference

Files

file | translation.module [code]
file | translation.pages.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/translation/translation.module File Reference

  • modules
  • translation
Functions | Variables
translation.module File Reference

Go to the source code of this file.

Functions

translation_help ($path, $arg)
translation_menu ()
_translation_tab_access ($node)
translation_admin_paths ()
translation_permission ()
translation_form_node_type_form_alter (&$form, &$form_state)
translation_form_node_form_alter (&$form, &$form_state)
translation_node_view ($node, $view_mode)
translation_node_prepare ($node)
translation_node_insert ($node)
translation_node_update ($node)
translation_node_validate ($node, $form)
translation_node_delete ($node)
translation_remove_from_set ($node)
translation_node_get_translations ($tnid)
translation_supported_type ($type)
translation_path_get_translations ($path)
translation_language_switch_links_alter (array &$links, $type, $path)

Variables

const TRANSLATION_ENABLED 2

Detailed Description

Manages content translations.

Translations are managed in sets of posts, which represent the same information in different languages. Only content types for which the administrator has explicitly enabled translations could have translations associated. Translations are managed in sets with exactly one source post per set. The source post is used to translate to different languages, so if the source post is significantly updated, the editor can decide to mark all translations outdated.

The node table stores the values used by this module:

  • tnid: Integer for the translation set ID, which equals the node ID of the source post.
  • translate: Integer flag, either indicating that the translation is up to date (0) or needs to be updated (1).

Definition in file translation.module.

Function Documentation

_translation_tab_access ( $node )

Access callback: Checks that the user has permission to 'translate content'.

Only displays the translation tab for nodes that are not language-neutral of types that have translation enabled.

Parameters
$node A node object.
Returns
TRUE if the translation tab should be displayed, FALSE otherwise.
See Also
translation_menu()

Definition at line 86 of file translation.module.

References entity_language(), LANGUAGE_NONE, node_access(), translation_supported_type(), and user_access().

translation_admin_paths ( )

Implements hook_admin_paths().

Definition at line 96 of file translation.module.

References variable_get().

translation_form_node_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_BASE_FORM_ID_alter() for node_form().

Alters language fields on node edit forms when a translation is about to be created.

See Also
node_form()

Definition at line 134 of file translation.module.

References language_list(), LANGUAGE_NONE, locale_language_list(), t(), translation_node_get_translations(), translation_supported_type(), and user_access().

translation_form_node_type_form_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter() for node_type_form().

Definition at line 119 of file translation.module.

References t(), TRANSLATION_ENABLED, and url().

translation_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 30 of file translation.module.

References $output, t(), and url().

translation_language_switch_links_alter | ( | array & | $links,
 |  |  | $type,
 |  |  | $path
 | ) |  |

Implements hook_language_switch_links_alter().

Replaces links with pointers to translated versions of the content.

Definition at line 518 of file translation.module.

References entity_language(), LANGUAGE_NONE, LANGUAGE_TYPE_INTERFACE, node_load(), translation_node_get_translations(), translation_supported_type(), and variable_get().

translation_menu ( )

Implements hook_menu().

Definition at line 57 of file translation.module.

References MENU_LOCAL_TASK.

translation_node_delete ( $node )

Implements hook_node_delete().

Definition at line 403 of file translation.module.

References translation_remove_from_set(), and translation_supported_type().

translation_node_get_translations ( $tnid )

Gets all nodes in a given translation set.

Parameters
$tnid The translation source nid of the translation set, the identifier of the node used to derive all translations in the set.
Returns
Array of partial node objects (nid, title, language) representing all nodes in the translation set, in effect all translations of node $tnid, including node $tnid itself. Because these are partial nodes, you need to node_load() the full node, if you need more properties. The array is indexed by language code.

Definition at line 461 of file translation.module.

References db_select(), drupal_static(), and entity_language().

Referenced by translation_form_node_form_alter(), translation_language_switch_links_alter(), translation_node_overview(), translation_node_prepare(), translation_node_validate(), translation_node_view(), and translation_path_get_translations().

translation_node_insert ( $node )

Implements hook_node_insert().

Definition at line 323 of file translation.module.

References db_update(), and translation_supported_type().

translation_node_prepare ( $node )

Implements hook_node_prepare().

Definition at line 273 of file translation.module.

References drupal_set_message(), field_attach_prepare_translation(), language_list(), node_access(), node_load(), t(), translation_node_get_translations(), translation_supported_type(), and user_access().

translation_node_update ( $node )

Implements hook_node_update().

Definition at line 358 of file translation.module.

References db_update(), entity_language(), and translation_supported_type().

translation_node_validate | ( | $node,
 |  | $form
 | ) |

Implements hook_node_validate().

Ensures that duplicate translations can't be created for the same source.

Definition at line 388 of file translation.module.

References entity_language(), form_set_error(), nid, t(), translation_node_get_translations(), and translation_supported_type().

translation_node_view | ( | $node,
 |  | $view_mode
 | ) |

Implements hook_node_view().

Displays translation links with language names if this node is part of a translation set. If no language provider is enabled, "fall back" to simple links built through the result of translation_node_get_translations().

Definition at line 216 of file translation.module.

References $attributes, $links, drupal_multilingual(), entity_language(), language_list(), language_negotiation_get_switch_links(), LANGUAGE_TYPE_INTERFACE, translation_node_get_translations(), and variable_get().

translation_path_get_translations ( $path )

Returns the paths of all translations of a node, based on its Drupal path.

Parameters
$path A Drupal path, for example node/432.
Returns
An array of paths of translations of the node accessible to the current user, keyed with language codes.

Definition at line 502 of file translation.module.

References node_load(), and translation_node_get_translations().

translation_permission ( )

Implements hook_permission().

Definition at line 108 of file translation.module.

References t().

translation_remove_from_set ( $node )

Removes a node from its translation set and updates accordingly.

Parameters
$node A node object.

Definition at line 416 of file translation.module.

References db_query(), and db_update().

Referenced by translation_node_delete().

translation_supported_type ( $type )

Returns whether the given content type has support for translations.

Returns
TRUE if translation is supported, and FALSE if not.

Definition at line 488 of file translation.module.

References TRANSLATION_ENABLED, and variable_get().

Referenced by _translation_tab_access(), translation_form_node_form_alter(), translation_language_switch_links_alter(), translation_node_delete(), translation_node_insert(), translation_node_prepare(), translation_node_update(), and translation_node_validate().

Variable Documentation

const TRANSLATION_ENABLED 2

Identifies a content type which has translation support enabled.

Definition at line 25 of file translation.module.

Referenced by translation_form_node_type_form_alter(), and translation_supported_type().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/translation/translation.pages.inc File Reference

  • modules
  • translation
Functions
translation.pages.inc File Reference

Go to the source code of this file.

Functions

translation_node_overview ($node)

Detailed Description

User page callbacks for the Translation module.

Definition in file translation.pages.inc.

Function Documentation

translation_node_overview ( $node )

Page callback: Displays a list of a node's translations.

Parameters
$node A node object.
Returns
A render array for a page containing a list of content.
See Also
translation_menu()

Definition at line 19 of file translation.pages.inc.

References $header, $links, $title, DRUPAL_ROOT, drupal_set_title(), entity_language(), l(), language_list(), language_negotiation_get_switch_links(), LANGUAGE_TYPE_INTERFACE, nid, node_access(), node_load(), PASS_THROUGH, t(), translation_node_get_translations(), and variable_get().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/trigger Directory Reference

  • modules
  • trigger
trigger Directory Reference

Files

file | trigger.admin.inc [code]
file | trigger.api.php [code]
file | trigger.install [code]
file | trigger.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/trigger/trigger.admin.inc File Reference

  • modules
  • trigger
Functions
trigger.admin.inc File Reference

Go to the source code of this file.

Functions

trigger_assign ($module_to_display=NULL)
trigger_unassign ($form, $form_state, $module, $hook=NULL, $aid=NULL)
trigger_unassign_submit ($form, &$form_state)
trigger_assign_form ($form, $form_state, $module, $hook, $label)
trigger_assign_form_validate ($form, $form_state)
trigger_assign_form_submit ($form, &$form_state)
theme_trigger_display ($variables)

Detailed Description

Admin page callbacks for the trigger module.

Definition in file trigger.admin.inc.

Function Documentation

trigger_assign ( $module_to_display = NULL )

Builds a form that allows users to assign actions to triggers.

Parameters
$module_to_display Which tab of triggers to display. E.g., 'node' for all node-related triggers.
Returns
HTML form.
See Also
trigger_menu()

Definition at line 20 of file trigger.admin.inc.

References $module, drupal_alter(), drupal_get_form(), drupal_goto(), and module_invoke_all().

trigger_assign_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for trigger_assign_form().

See Also
trigger_assign_form_validate()

Definition at line 231 of file trigger.admin.inc.

References actions_function_lookup(), actions_list(), db_delete(), db_insert(), db_query(), drupal_set_message(), drupal_static_reset(), and t().

trigger_assign_form_validate | ( | $form,
 |  | $form_state
 | ) |

Form validation handler for trigger_assign_form().

Makes sure that the user is not re-assigning an action to an event.

See Also
trigger_assign_form_submit()

Definition at line 212 of file trigger.admin.inc.

References actions_function_lookup(), db_query(), form_set_error(), and t().

trigger_unassign_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for trigger_unassign().

Definition at line 89 of file trigger.admin.inc.

References actions_function_lookup(), actions_get_all_actions(), db_delete(), drupal_goto(), drupal_set_message(), drupal_static_reset(), t(), and watchdog().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/trigger/trigger.api.php File Reference

  • modules
  • trigger
Functions
trigger.api.php File Reference

Go to the source code of this file.

Functions

hook_trigger_info ()
hook_trigger_info_alter (&$triggers)

Detailed Description

Hooks provided by the Trigger module.

Definition in file trigger.api.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/trigger/trigger.install File Reference

  • modules
  • trigger
Functions
trigger.install File Reference

Go to the source code of this file.

Functions

trigger_schema ()
trigger_install ()
trigger_update_7000 ()
trigger_update_7001 ()
trigger_update_7002 ()

Detailed Description

Install, update and uninstall functions for the trigger module.

Definition in file trigger.install.

Function Documentation

trigger_install ( )

Implements hook_install().

Definition at line 52 of file trigger.install.

References actions_synchronize().

trigger_schema ( )

Implements hook_schema().

Definition at line 11 of file trigger.install.

trigger_update_7000 ( )

Alter the "hook" field and drop the "op field" of {trigger_assignments}.

Increase the length of the "hook" field to 78 characters and adds operation names to the hook names, and drops the "op" field.

Definition at line 63 of file trigger.install.

References db_add_primary_key(), db_change_field(), db_drop_field(), db_drop_primary_key(), db_query(), and db_update().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/trigger/trigger.module File Reference

  • modules
  • trigger
Functions
trigger.module File Reference

Go to the source code of this file.

Functions

trigger_help ($path, $arg)
trigger_menu ()
trigger_menu_unassign_access ()
trigger_trigger_info ()
trigger_get_assigned_actions ($hook)
trigger_theme ()
trigger_forms ()
_trigger_normalize_node_context ($type, $node)
_trigger_node ($node, $hook, $a3=NULL, $a4=NULL)
trigger_node_view ($node, $view_mode)
trigger_node_update ($node)
trigger_node_presave ($node)
trigger_node_insert ($node)
trigger_node_delete ($node)
_trigger_normalize_comment_context ($type, $comment)
trigger_comment_presave ($comment)
trigger_comment_insert ($comment)
trigger_comment_update ($comment)
trigger_comment_delete ($comment)
trigger_comment_view ($comment)
_trigger_comment ($a1, $hook)
trigger_cron ()
_trigger_normalize_user_context ($type, $account)
trigger_user_login (&$edit, $account, $category)
trigger_user_logout ($account)
trigger_user_insert (&$edit, $account, $category)
trigger_user_update (&$edit, $account, $category)
trigger_user_cancel ($edit, $account, $method)
trigger_user_delete ($account)
trigger_user_view ($account)
_trigger_user ($hook, &$edit, $account, $category=NULL)
_trigger_taxonomy ($hook, $array)
trigger_taxonomy_term_insert ($term)
trigger_taxonomy_term_update ($term)
trigger_taxonomy_term_delete ($term)
trigger_actions_delete ($aid)
_trigger_get_all_info ()
_trigger_tab_information ()

Detailed Description

Enables functions to be stored and executed at a later time.

Definition in file trigger.module.

Function Documentation

_trigger_comment | ( | $a1,
 |  | $hook
 | ) |

Calls action functions for comment triggers.

Parameters
$a1 | Comment object or array of form values.
$hook | Hook to trigger.

Definition at line 416 of file trigger.module.

References $info, _trigger_normalize_comment_context(), actions_do(), and trigger_get_assigned_actions().

Referenced by trigger_comment_delete(), trigger_comment_insert(), trigger_comment_presave(), trigger_comment_update(), and trigger_comment_view().

_trigger_get_all_info ( )

Retrieves and caches information from hook_trigger_info() implementations.

Returns
Array of all triggers.

Definition at line 640 of file trigger.module.

References drupal_alter(), drupal_static(), and module_invoke_all().

Referenced by _trigger_tab_information(), and trigger_forms().

_trigger_node | ( | $node,
 |  | $hook,
 |  | $a3 = NULL,
 |  | $a4 = NULL
 | ) |

Calls action functions for node triggers.

Parameters
$node | Node object.
$hook | Hook to trigger.
$a3 | Additional argument to action function.
$a4 | Additional argument to action function.

Definition at line 267 of file trigger.module.

References $info, _trigger_normalize_node_context(), actions_do(), and trigger_get_assigned_actions().

Referenced by trigger_node_delete(), trigger_node_insert(), trigger_node_presave(), trigger_node_update(), and trigger_node_view().

_trigger_normalize_comment_context | ( | $type,
 |  | $comment
 | ) |

Loads associated objects for comment triggers.

When an action is called in a context that does not match its type, the object that the action expects must be retrieved. For example, when an action that works on nodes is called during the comment hook, the node object is not available since the comment hook doesn't pass it. So here we load the object the action expects.

Parameters
$type | The type of action that is about to be called.
$comment | The comment that was passed via the comment hook.
Returns
The object expected by the action that is about to be called.

Definition at line 361 of file trigger.module.

References node_load(), and user_load().

Referenced by _trigger_comment().

_trigger_normalize_node_context | ( | $type,
 |  | $node
 | ) |

Loads associated objects for node triggers.

When an action is called in a context that does not match its type, the object that the action expects must be retrieved. For example, when an action that works on users is called during a node hook implementation, the user object is not available since the node hook call doesn't pass it. So here we load the object the action expects.

Parameters
$type | The type of action that is about to be called.
$node | The node that was passed via the node hook.
Returns
The object expected by the action that is about to be called.

Definition at line 244 of file trigger.module.

References user_load().

Referenced by _trigger_node().

_trigger_normalize_user_context | ( | $type,
 |  | $account
 | ) |

Loads associated objects for user triggers.

When an action is called in a context that does not match its type, the object that the action expects must be retrieved. For example, when an action that works on nodes is called during the user hook, the node object is not available since the user hook doesn't pass it. So here we load the object the action expects.

Parameters
$type | The type of action that is about to be called.
$account | The account object that was passed via the user hook.
Returns
The object expected by the action that is about to be called.

Definition at line 475 of file trigger.module.

References arg(), and node_load().

Referenced by _trigger_example_first_time_login(), and _trigger_user().

_trigger_tab_information ( )

Gathers information about tabs on the triggers administration screen.

Returns
Array of modules that have triggers, with the keys being the machine-readable name of the module, and the values being the human-readable name of the module.

Definition at line 659 of file trigger.module.

References $info, $name, _trigger_get_all_info(), and system_get_info().

Referenced by trigger_help(), and trigger_menu().

_trigger_taxonomy | ( | $hook,
 |  | $array
 | ) |

Calls action functions for taxonomy triggers.

Parameters
$hook | Hook to trigger actions for taxonomy_term_insert(), taxonomy_term_update(), and taxonomy_term_delete().
$array | Item on which operation is being performed, either a term or form values.

Definition at line 592 of file trigger.module.

References actions_do(), and trigger_get_assigned_actions().

Referenced by trigger_taxonomy_term_delete(), trigger_taxonomy_term_insert(), and trigger_taxonomy_term_update().

_trigger_user | ( |  | $hook,
 |  | & | $edit,
 |  |  | $account,
 |  |  | $category = NULL
 | ) |  |

Calls action functions for user triggers.

Parameters
$hook | The hook that called this function.
$edit | Edit variable passed in to the hook or empty array if not needed.
$account | Account variable passed in to the hook.
$method | Method variable passed in to the hook or NULL if not needed.

Definition at line 558 of file trigger.module.

References $info, _trigger_normalize_user_context(), actions_do(), and trigger_get_assigned_actions().

Referenced by trigger_user_cancel(), trigger_user_delete(), trigger_user_insert(), trigger_user_login(), trigger_user_logout(), trigger_user_update(), and trigger_user_view().

trigger_actions_delete ( $aid )

Implements hook_actions_delete().

Removes all trigger entries for the given action, when an action is deleted.

Definition at line 627 of file trigger.module.

References db_delete(), and drupal_static_reset().

trigger_comment_delete ( $comment )

Implements hook_comment_delete().

Definition at line 397 of file trigger.module.

References _trigger_comment().

trigger_comment_insert ( $comment )

Implements hook_comment_insert().

Definition at line 383 of file trigger.module.

References _trigger_comment().

trigger_comment_presave ( $comment )

Implements hook_comment_presave().

Definition at line 376 of file trigger.module.

References _trigger_comment().

trigger_comment_update ( $comment )

Implements hook_comment_update().

Definition at line 390 of file trigger.module.

References _trigger_comment().

trigger_comment_view ( $comment )

Implements hook_comment_view().

Definition at line 404 of file trigger.module.

References _trigger_comment().

trigger_cron ( )

Implements hook_cron().

Definition at line 447 of file trigger.module.

References actions_do(), and trigger_get_assigned_actions().

trigger_forms ( )

Implements hook_forms().

We re-use code by using the same assignment form definition for each hook.

Definition at line 215 of file trigger.module.

References $module, and _trigger_get_all_info().

trigger_get_assigned_actions ( $hook )

Gets the action IDs of actions to be executed for a hook.

Parameters
$hook The name of the hook being fired.
Returns
An array whose keys are action IDs that the user has associated with this trigger, and whose values are arrays containing the action type and label.

Definition at line 188 of file trigger.module.

References db_query(), and drupal_static().

Referenced by _trigger_comment(), _trigger_example_first_time_login(), _trigger_node(), _trigger_taxonomy(), _trigger_user(), trigger_assign_form(), trigger_cron(), and trigger_example_triggersomething().

trigger_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 11 of file trigger.module.

References $module, $output, _trigger_tab_information(), t(), and url().

trigger_menu ( )

Implements hook_menu().

Definition at line 42 of file trigger.module.

References $module, _trigger_tab_information(), MENU_LOCAL_TASK, and MENU_VISIBLE_IN_BREADCRUMB.

trigger_menu_unassign_access ( )

Access callback: Determines if triggers can be unassigned.

Returns
bool TRUE if there are triggers that the user can unassign, FALSE otherwise.
See Also
trigger_menu()

Definition at line 86 of file trigger.module.

References db_select(), and user_access().

trigger_node_delete ( $node )

Implements hook_node_delete().

Definition at line 340 of file trigger.module.

References _trigger_node().

trigger_node_insert ( $node )

Implements hook_node_insert().

Definition at line 333 of file trigger.module.

References _trigger_node().

trigger_node_presave ( $node )

Implements hook_node_presave().

Definition at line 326 of file trigger.module.

References _trigger_node().

trigger_node_update ( $node )

Implements hook_node_update().

Definition at line 319 of file trigger.module.

References _trigger_node().

trigger_node_view | ( | $node,
 |  | $view_mode
 | ) |

Implements hook_node_view().

Definition at line 312 of file trigger.module.

References _trigger_node().

trigger_taxonomy_term_delete ( $term )

Implements hook_taxonomy_term_delete().

Definition at line 618 of file trigger.module.

References _trigger_taxonomy().

trigger_taxonomy_term_insert ( $term )

Implements hook_taxonomy_term_insert().

Definition at line 604 of file trigger.module.

References _trigger_taxonomy().

trigger_taxonomy_term_update ( $term )

Implements hook_taxonomy_term_update().

Definition at line 611 of file trigger.module.

References _trigger_taxonomy().

trigger_theme ( )

Implements hook_theme().

Definition at line 201 of file trigger.module.

trigger_trigger_info ( )

Implements hook_trigger_info().

Defines all the triggers that this module implements triggers for.

Definition at line 102 of file trigger.module.

References t().

trigger_user_cancel | ( | $edit,
 |  | $account,
 |  | $method
 | ) |

Implements hook_user_cancel().

Definition at line 522 of file trigger.module.

References _trigger_user().

trigger_user_delete ( $account )

Implements hook_user_delete().

Definition at line 533 of file trigger.module.

References _trigger_user().

trigger_user_insert | ( | & | $edit,
 |  |  | $account,
 |  |  | $category
 | ) |  |

Implements hook_user_insert().

Definition at line 508 of file trigger.module.

References _trigger_user().

trigger_user_login | ( | & | $edit,
 |  |  | $account,
 |  |  | $category
 | ) |  |

Implements hook_user_login().

Definition at line 493 of file trigger.module.

References _trigger_user().

trigger_user_logout ( $account )

Implements hook_user_logout().

Definition at line 500 of file trigger.module.

References _trigger_user().

trigger_user_update | ( | & | $edit,
 |  |  | $account,
 |  |  | $category
 | ) |  |

Implements hook_user_update().

Definition at line 515 of file trigger.module.

References _trigger_user().

trigger_user_view ( $account )

Implements hook_user_view().

Definition at line 541 of file trigger.module.

References _trigger_user().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update Directory Reference

  • modules
  • update
update Directory Reference

Files

file | update.api.php [code]
file | update.authorize.inc [code]
file | update.compare.inc [code]
file | update.fetch.inc [code]
file | update.install [code]
file | update.manager.inc [code]
file | update.module [code]
file | update.report.inc [code]
file | update.settings.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.api.php File Reference

  • modules
  • update
Functions
update.api.php File Reference

Go to the source code of this file.

Functions

hook_update_projects_alter (&$projects)
hook_update_status_alter (&$projects)
hook_verify_update_archive ($project, $archive_file, $directory)

Detailed Description

Hooks provided by the Update Manager module.

Definition in file update.api.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.authorize.inc File Reference

  • modules
  • update
Functions
update.authorize.inc File Reference

Go to the source code of this file.

Functions

update_authorize_run_update ($filetransfer, $projects)
update_authorize_run_install ($filetransfer, $project, $updater_name, $local_url)
update_authorize_batch_copy_project ($project, $updater_name, $local_url, $filetransfer, &$context)
update_authorize_update_batch_finished ($success, $results)
update_authorize_install_batch_finished ($success, $results)
_update_batch_create_message (&$project_results, $message, $success=TRUE)
_update_authorize_clear_update_status ()

Detailed Description

Callbacks and related functions invoked by authorize.php to update projects.

We use the Batch API to actually update each individual project on the site. All of the code in this file is run at a low bootstrap level (modules are not loaded), so these functions cannot assume access to the rest of the code of the Update Manager module.

Definition in file update.authorize.inc.

Function Documentation

_update_authorize_clear_update_status ( )

Clears cached available update status data.

Since this function is run at such a low bootstrap level, the Update Manager module is not loaded. So, we can't just call _update_cache_clear(). However, the database is bootstrapped, so we can do a query ourselves to clear out what we want to clear.

Note that we do not want to just truncate the table, since that would remove items related to currently pending fetch attempts.

See Also
update_authorize_update_batch_finished()
_update_cache_clear()

Definition at line 325 of file update.authorize.inc.

References db_delete(), and db_or().

Referenced by update_authorize_update_batch_finished().

_update_batch_create_message | ( | & | $project_results,
 |  |  | $message,
 |  |  | $success = TRUE
 | ) |  |

Creates a structure of log messages.

Parameters
array | $project_results | An associative array of results from the batch operation.
string | $message | A string containing a log message.
bool | $success | (optional) TRUE if the operation the message is about was a success, FALSE if there were errors. Defaults to TRUE.

Definition at line 307 of file update.authorize.inc.

Referenced by update_authorize_batch_copy_project().

update_authorize_batch_copy_project | ( |  | $project,
 |  |  | $updater_name,
 |  |  | $local_url,
 |  |  | $filetransfer,
 |  | & | $context
 | ) |  |

Batch callback: Copies project to its proper place when authorized to do so.

Parameters
string | $project | The canonical short name of the project being installed.
string | $updater_name | The name of the Updater class to use for installing this project.
string | $local_url | The URL to the locally installed temp directory where the project has already been downloaded and extracted into.
FileTransfer | $filetransfer | The FileTransfer object to use for performing this operation.
array | $context | Reference to an array used for Batch API storage.

Definition at line 114 of file update.authorize.inc.

References _update_batch_create_message(), and t().

update_authorize_install_batch_finished | ( | $success,
 |  | $results
 | ) |

Batch callback: Performs actions when the authorized install batch is done.

This processes the results and stashes them into SESSION such that authorize.php will render a report. Also responsible for putting the site back online after a successful install if necessary.

Parameters
$success | TRUE if the batch operation was a success; FALSE if there were errors.
$results | An associative array of results from the batch operation.

Definition at line 249 of file update.authorize.inc.

References $messages, $results, t(), variable_get(), and variable_set().

update_authorize_run_install | ( | $filetransfer,
 |  | $project,
 |  | $updater_name,
 |  | $local_url
 | ) |

Installs a new project when invoked by authorize.php.

Callback for system_authorized_init() in update_manager_install_form_submit().

Parameters
FileTransfer | $filetransfer | The FileTransfer object created by authorize.php for use during this operation.
string | $project | The canonical project short name (e.g., {system}.name).
string | $updater_name | The name of the Updater class to use for installing this project.
string | $local_url | The URL to the locally installed temp directory where the project has already been downloaded and extracted into.

Definition at line 73 of file update.authorize.inc.

References batch_set(), drupal_get_path(), system_authorized_batch_process(), and t().

update_authorize_run_update | ( | $filetransfer,
 |  | $projects
 | ) |

Updates existing projects when invoked by authorize.php.

Callback for system_authorized_init() in update_manager_update_ready_form_submit().

Parameters
$filetransfer The FileTransfer object created by authorize.php for use during this operation.
$projects A nested array of projects to install into the live webroot, keyed by project name. Each subarray contains the following keys:
  • project: The canonical project short name.
  • updater_name: The name of the Updater class to use for this project.
  • local_url: The locally installed location of new code to update with.

Definition at line 29 of file update.authorize.inc.

References batch_set(), drupal_get_path(), system_authorized_batch_process(), and t().

Referenced by update_manager_update_ready_form_submit().

update_authorize_update_batch_finished | ( | $success,
 |  | $results
 | ) |

Batch callback: Performs actions when the authorized update batch is done.

This processes the results and stashes them into SESSION such that authorize.php will render a report. Also responsible for putting the site back online and clearing the update status cache after a successful update.

Parameters
$success | TRUE if the batch operation was successful; FALSE if there were errors.
$results | An associative array of results from the batch operation.

Definition at line 182 of file update.authorize.inc.

References $messages, $results, _update_authorize_clear_update_status(), base_path(), t(), variable_get(), and variable_set().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.compare.inc File Reference

  • modules
  • update
Functions
update.compare.inc File Reference

Go to the source code of this file.

Functions

update_get_projects ()
_update_process_info_list (&$projects, $list, $project_type, $status)
update_get_project_name ($file)
update_process_project_info (&$projects)
update_calculate_project_data ($available)
update_calculate_project_update_status ($project, &$project_data, $available)
update_project_cache ($cid)
update_filter_project_info ($info)

Detailed Description

Code required only when comparing available updates to existing data.

Definition in file update.compare.inc.

Function Documentation

_update_process_info_list | ( | & | $projects,
 |  |  | $list,
 |  |  | $project_type,
 |  |  | $status
 | ) |  |

Populates an array of project data.

This iterates over a list of the installed modules or themes and groups them by project and status. A few parts of this function assume that enabled modules and themes are always processed first, and if disabled modules or themes are being processed (there is a setting to control if disabled code should be included or not in the 'Available updates' report), those are only processed after $projects has been populated with information about the enabled code. Modules and themes set as hidden are always ignored. This function also records the latest change time on the .info files for each module or theme, which is important data which is used when deciding if the cached available update data should be invalidated.

Parameters
$projects | Reference to the array of project data of what's installed on this site.
$list | Array of data to process to add the relevant info to the $projects array.
$project_type | The kind of data in the list. Can be 'module' or 'theme'.
$status | Boolean that controls what status (enabled or disabled) to process out of the $list and add to the $projects array.
See Also
update_get_projects()

Definition at line 106 of file update.compare.inc.

References $name, update_filter_project_info(), and update_get_project_name().

Referenced by update_get_projects().

update_calculate_project_data ( $available )

Calculates the current update status of all projects on the site.

The results of this function are expensive to compute, especially on sites with lots of modules or themes, since it involves a lot of comparisons and other operations. Therefore, we cache the results into the {cache_update} table using the 'update_project_data' cache ID. However, since this is not the data about available updates fetched from the network, it is ok to invalidate it somewhat quickly. If we keep this data for very long, site administrators are more likely to see incorrect results if they upgrade to a newer version of a module or theme but do not visit certain pages that automatically clear this cache.

Parameters
array $available Data about available project releases.
Returns
An array of installed projects with current update status information.
See Also
update_get_available()
update_get_projects()
update_process_project_info()
update_project_cache()

Definition at line 335 of file update.compare.inc.

References _update_cache_set(), drupal_alter(), REQUEST_TIME, t(), update_calculate_project_update_status(), update_get_projects(), update_process_project_info(), update_project_cache(), and UPDATE_UNKNOWN.

Referenced by update_manager_update_form(), update_requirements(), and update_status().

update_calculate_project_update_status | ( |  | $project,
 |  | & | $project_data,
 |  |  | $available
 | ) |  |

Calculates the current update status of a specific project.

This function is the heart of the update status feature. For each project it is invoked with, it first checks if the project has been flagged with a special status like "unsupported" or "insecure", or if the project node itself has been unpublished. In any of those cases, the project is marked with an error and the next project is considered.

If the project itself is valid, the function decides what major release series to consider. The project defines what the currently supported major versions are for each version of core, so the first step is to make sure the current version is still supported. If so, that's the target version. If the current version is unsupported, the project maintainer's recommended major version is used. There's also a check to make sure that this function never recommends an earlier release than the currently installed major version.

Given a target major version, the available releases are scanned looking for the specific release to recommend (avoiding beta releases and development snapshots if possible). For the target major version, the highest patch level is found. If there is a release at that patch level with no extra ("beta", etc.), then the release at that patch level with the most recent release date is recommended. If every release at that patch level has extra (only betas), then the latest release from the previous patch level is recommended. For example:

  • 1.6-bugfix <– recommended version because 1.6 already exists.
  • 1.6

or

  • 1.6-beta
  • 1.5 <– recommended version because no 1.6 exists.
  • 1.4

Also, the latest release from the same major version is looked for, even beta releases, to display to the user as the "Latest version" option. Additionally, the latest official release from any higher major versions that have been released is searched for to provide a set of "Also available" options.

Finally, and most importantly, the release history continues to be scanned until the currently installed release is reached, searching for anything marked as a security update. If any security updates have been found between the recommended release and the installed version, all of the releases that included a security fix are recorded so that the site administrator can be warned their site is insecure, and links pointing to the release notes for each security update can be included (which, in turn, will link to the official security announcements for each vulnerability).

This function relies on the fact that the .xml release history data comes sorted based on major version and patch level, then finally by release date if there are multiple releases such as betas from the same major.patch version (e.g., 5.x-1.5-beta1, 5.x-1.5-beta2, and 5.x-1.5). Development snapshots for a given major version are always listed last.

Parameters
$project | An array containing information about a specific project.
$project_data | An array containing information about a specific project.
$available | Data about available project releases of a specific project.

Definition at line 427 of file update.compare.inc.

References t(), UPDATE_CURRENT, UPDATE_FETCH_PENDING, UPDATE_NOT_CHECKED, UPDATE_NOT_CURRENT, UPDATE_NOT_FETCHED, UPDATE_NOT_SECURE, UPDATE_NOT_SUPPORTED, UPDATE_REVOKED, and UPDATE_UNKNOWN.

Referenced by update_calculate_project_data().

update_filter_project_info ( $info )

Filters the project .info data to only save attributes we need.

Parameters
array $info Array of .info file data as returned by drupal_parse_info_file().
Returns
Array of .info file data we need for the update manager.
See Also
_update_process_info_list()

Definition at line 819 of file update.compare.inc.

References $info, and drupal_map_assoc().

Referenced by _update_process_info_list().

update_get_project_name ( $file )

Determines what project a given file object belongs to.

Parameters
$file A file object as returned by system_get_files_database().
Returns
The canonical project short name.
See Also
system_get_files_database()

Definition at line 249 of file update.compare.inc.

Referenced by _update_process_info_list().

update_get_projects ( )

Fetches an array of installed and enabled projects.

This is only responsible for generating an array of projects (taking into account projects that include more than one module or theme). Other information like the specific version and install type (official release, dev snapshot, etc) is handled later in update_process_project_info() since that logic is only required when preparing the status report, not for fetching the available release data.

This array is fairly expensive to construct, since it involves a lot of disk I/O, so we cache the results into the {cache_update} table using the 'update_project_projects' cache ID. However, since this is not the data about available updates fetched from the network, it is acceptable to invalidate it somewhat quickly. If we keep this data for very long, site administrators are more likely to see incorrect results if they upgrade to a newer version of a module or theme but do not visit certain pages that automatically clear this cache.

Returns
An associative array of currently enabled projects keyed by the machine-readable project short name. Each project contains:
  • name: The machine-readable project short name.
  • info: An array with values from the main .info file for this project.
    • name: The human-readable name of the project.
    • package: The package that the project is grouped under.
    • version: The version of the project.
    • project: The Drupal.org project name.
    • datestamp: The date stamp of the project's main .info file.
    • _info_file_ctime: The maximum file change time for all of the .info files included in this project.
  • datestamp: The date stamp when the project was released, if known.
  • includes: An associative array containing all projects included with this project, keyed by the machine-readable short name with the human-readable name as value.
  • project_type: The type of project. Allowed values are 'module' and 'theme'.
  • project_status: This indicates if the project is enabled and will always be TRUE, as the function only returns enabled projects.
  • sub_themes: If the project is a theme it contains an associative array of all sub-themes.
  • base_themes: If the project is a theme it contains an associative array of all base-themes.
See Also
update_process_project_info()
update_calculate_project_data()
update_project_cache()

Definition at line 56 of file update.compare.inc.

References _update_cache_set(), _update_process_info_list(), drupal_alter(), drupal_static(), REQUEST_TIME, system_rebuild_module_data(), system_rebuild_theme_data(), update_project_cache(), and variable_get().

Referenced by _update_refresh(), update_calculate_project_data(), and update_get_available().

update_process_project_info ( & $projects )

Determines version and type information for currently installed projects.

Processes the list of projects on the system to figure out the currently installed versions, and other information that is required before we can compare against the available releases to produce the status report.

Parameters
$projects Array of project information from update_get_projects().

Definition at line 270 of file update.compare.inc.

References $info, and t().

Referenced by update_calculate_project_data().

update_project_cache ( $cid )

Retrieves data from {cache_update} or empties the cache when necessary.

Two very expensive arrays computed by this module are the list of all installed modules and themes (and .info data, project associations, etc), and the current status of the site relative to the currently available releases. These two arrays are cached in the {cache_update} table and used whenever possible. The cache is cleared whenever the administrator visits the status report, available updates report, or the module or theme administration pages, since we should always recompute the most current values on any of those pages.

Note: while both of these arrays are expensive to compute (in terms of disk I/O and some fairly heavy CPU processing), neither of these is the actual data about available updates that we have to fetch over the network from updates.drupal.org. That information is stored with the 'update_available_releases' cache ID – it needs to persist longer than 1 hour and never get invalidated just by visiting a page on the site.

Parameters
$cid The cache ID of data to return from the cache. Valid options are 'update_project_data' and 'update_project_projects'.
Returns
The cached value of the $projects array generated by update_calculate_project_data() or update_get_projects(), or an empty array when the cache is cleared.

Definition at line 779 of file update.compare.inc.

References _update_cache_clear(), _update_cache_get(), and REQUEST_TIME.

Referenced by update_calculate_project_data(), and update_get_projects().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.fetch.inc File Reference

  • modules
  • update
Functions
update.fetch.inc File Reference

Go to the source code of this file.

Functions

update_manual_status ()
update_fetch_data_batch (&$context)
update_fetch_data_finished ($success, $results)
_update_fetch_data ()
_update_process_fetch_task ($project)
_update_refresh ()
_update_create_fetch_task ($project)
_update_build_fetch_url ($project, $site_key= '')
_update_get_fetch_url_base ($project)
_update_cron_notify ()
update_parse_xml ($raw_xml)

Detailed Description

Code required only when fetching information about available updates.

Definition in file update.fetch.inc.

Function Documentation

_update_build_fetch_url | ( | $project,
 |  | $site_key = ''
 | ) |

Generates the URL to fetch information about project updates.

This figures out the right URL to use, based on the project's .info file and the global defaults. Appends optional query arguments when the site is configured to report usage stats.

Parameters
$project | The array of project information from update_get_projects().
$site_key | (optional) The anonymous site key hash. Defaults to an empty string.
Returns
The URL for fetching information about updates to the specified project.
See Also
update_fetch_data()
_update_process_fetch_task()
update_get_projects()

Definition at line 287 of file update.fetch.inc.

References $name, $url, _update_get_fetch_url_base(), and DRUPAL_CORE_COMPATIBILITY.

Referenced by _update_process_fetch_task().

_update_create_fetch_task ( $project )

Adds a task to the queue for fetching release history data for a project.

We only create a new fetch task if there's no task already in the queue for this particular project (based on 'fetch_task::' entries in the {cache_update} table).

Parameters
$project Associative array of information about a project as created by update_get_projects(), including keys such as 'name' (short name), and the 'info' array with data from a .info file for the project.
See Also
update_get_projects()
update_get_available()
update_refresh()
update_fetch_data()
_update_process_fetch_task()

Definition at line 239 of file update.fetch.inc.

References _update_get_cache_multiple(), db_insert(), drupal_static(), DrupalQueue\get(), and REQUEST_TIME.

Referenced by update_create_fetch_task().

_update_cron_notify ( )

Performs any notifications that should be done once cron fetches new data.

This method checks the status of the site using the new data and, depending on the configuration of the site, notifies administrators via e-mail if there are new releases or missing security updates.

See Also
update_requirements()

Definition at line 340 of file update.fetch.inc.

References drupal_mail(), language_default(), module_load_install(), REQUEST_TIME, REQUIREMENT_ERROR, UPDATE_NOT_CURRENT, update_requirements(), user_load_by_mail(), user_preferred_language(), variable_get(), and variable_set().

Referenced by update_cron().

_update_fetch_data ( )

Attempts to drain the queue of tasks for release history data to fetch.

Definition at line 108 of file update.fetch.inc.

References _update_process_fetch_task(), DrupalQueue\get(), UPDATE_MAX_FETCH_TIME, and variable_get().

Referenced by update_fetch_data().

_update_get_fetch_url_base ( $project )

Returns the base of the URL to fetch available update data for a project.

Parameters
$project The array of project information from update_get_projects().
Returns
The base of the URL used for fetching available update data. This does not include the path elements to specify a particular project, version, site_key, etc.
See Also
_update_build_fetch_url()

Definition at line 327 of file update.fetch.inc.

References UPDATE_DEFAULT_URL, and variable_get().

Referenced by _update_build_fetch_url(), and _update_process_fetch_task().

_update_process_fetch_task ( $project )

Processes a task to fetch available update data for a single project.

Once the release history XML data is downloaded, it is parsed and saved into the {cache_update} table in an entry just for that project.

Parameters
$project Associative array of information about the project to fetch data for.
Returns
TRUE if we fetched parsable XML, otherwise FALSE.

Definition at line 129 of file update.fetch.inc.

References $base_url, $url, _update_build_fetch_url(), _update_cache_clear(), _update_cache_get(), _update_cache_set(), _update_get_fetch_url_base(), drupal_get_private_key(), drupal_hmac_base64(), drupal_http_request(), drupal_static(), UPDATE_MAX_FETCH_ATTEMPTS, update_parse_xml(), variable_get(), and variable_set().

Referenced by _update_fetch_data(), and update_fetch_data_batch().

_update_refresh ( )

Clears out all the cached available update data and initiates re-fetching.

Definition at line 197 of file update.fetch.inc.

References _update_cache_clear(), module_load_include(), update_create_fetch_task(), and update_get_projects().

Referenced by update_manual_status(), and update_refresh().

update_fetch_data_batch ( & $context )

Batch callback: Processes a step in batch for fetching available update data.

Parameters
$context Reference to an array used for Batch API storage.

Definition at line 37 of file update.fetch.inc.

References _update_process_fetch_task(), DrupalQueue\get(), and t().

update_fetch_data_finished | ( | $success,
 |  | $results
 | ) |

Batch callback: Performs actions when all fetch tasks have been completed.

Parameters
$success | TRUE if the batch operation was successful; FALSE if there were errors.
$results | An associative array of results from the batch operation, including the key 'updated' which holds the total number of projects we fetched available update data for.

Definition at line 89 of file update.fetch.inc.

References $results, drupal_set_message(), format_plural(), and t().

update_manual_status ( )

Page callback: Checks for updates and displays the update status report.

Manually checks the update status without the use of cron.

See Also
update_menu()

Definition at line 15 of file update.fetch.inc.

References _update_refresh(), batch_process(), batch_set(), drupal_get_path(), and t().

update_parse_xml ( $raw_xml )

Parses the XML of the Drupal release history info files.

Parameters
$raw_xml A raw XML string of available release data for a given project.
Returns
Array of parsed data about releases for a given project, or NULL if there was an error parsing the string.

Definition at line 384 of file update.fetch.inc.

Referenced by _update_process_fetch_task().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.install File Reference

  • modules
  • update
Functions
update.install File Reference

Go to the source code of this file.

Functions

update_requirements ($phase)
update_schema ()
update_install ()
update_uninstall ()
_update_requirement_check ($project, $type)
update_update_7000 ()
update_update_7001 ()

Detailed Description

Install, update, and uninstall functions for the Update Manager module.

Definition in file update.install.

Function Documentation

_update_requirement_check | ( | $project,
 |  | $type
 | ) |

Fills in the requirements array.

This is shared for both core and contrib to generate the right elements in the array for hook_requirements().

Parameters
$project | Array of information about the project we're testing as returned by update_calculate_project_data().
$type | What kind of project this is ('core' or 'contrib').
Returns
An array to be included in the nested $requirements array.
See Also
hook_requirements()
update_requirements()
update_calculate_project_data()

Definition at line 117 of file update.install.

References _update_message_text(), l(), REQUIREMENT_ERROR, REQUIREMENT_WARNING, t(), UPDATE_CURRENT, update_manager_access(), UPDATE_NOT_CHECKED, UPDATE_NOT_CURRENT, UPDATE_NOT_FETCHED, UPDATE_NOT_SECURE, UPDATE_NOT_SUPPORTED, UPDATE_REVOKED, and UPDATE_UNKNOWN.

Referenced by update_requirements().

update_install ( )

Implements hook_install().

Definition at line 71 of file update.install.

References DrupalQueue::get().

update_requirements ( $phase )

Implements hook_requirements().

Returns
An array describing the status of the site regarding available updates. If there is no update data, only one record will be returned, indicating that the status of core can't be determined. If data is available, there will be two records: one for core, and another for all of contrib (assuming there are any contributed modules or themes enabled on the site). In addition to the fields expected by hook_requirements ('value', 'severity', and optionally 'description'), this array will contain a 'reason' attribute, which is an integer constant to indicate why the given status is being returned (UPDATE_NOT_SECURE, UPDATE_NOT_CURRENT, or UPDATE_UNKNOWN). This is used for generating the appropriate e-mail notification messages during update_cron(), and might be useful for other modules that invoke update_requirements() to find out if the site is up to date or not.
See Also
_update_message_text()
_update_cron_notify()

Definition at line 28 of file update.install.

References _update_no_data(), _update_requirement_check(), module_load_include(), REQUIREMENT_WARNING, t(), update_calculate_project_data(), update_get_available(), and UPDATE_UNKNOWN.

Referenced by _update_cron_notify(), and update_init().

update_schema ( )

Implements hook_schema().

Definition at line 62 of file update.install.

References drupal_get_schema_unprocessed().

update_uninstall ( )

Implements hook_uninstall().

Definition at line 79 of file update.install.

References DrupalQueue::get(), and variable_del().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.manager.inc File Reference

  • modules
  • update
Functions
update.manager.inc File Reference

Go to the source code of this file.

Functions

update_manager_update_form ($form, $form_state=array(), $context)
theme_update_manager_update_form ($variables)
update_manager_update_form_validate ($form, &$form_state)
update_manager_update_form_submit ($form, &$form_state)
update_manager_download_batch_finished ($success, $results)
update_manager_update_ready_form ($form, &$form_state)
update_manager_update_ready_form_submit ($form, &$form_state)
update_manager_install_form ($form, &$form_state, $context)
_update_manager_check_backends (&$form, $operation)
update_manager_install_form_validate ($form, &$form_state)
update_manager_install_form_submit ($form, &$form_state)
update_manager_archive_extract ($file, $directory)
update_manager_archive_verify ($project, $archive_file, $directory)
update_manager_file_get ($url)
update_manager_batch_project_get ($project, $url, &$context)
update_manager_local_transfers_allowed ()

Detailed Description

Administrative screens and processing functions of the Update Manager module.

This allows site administrators with the 'administer software updates' permission to either upgrade existing projects, or download and install new ones, so long as the killswitch setting ('allow_authorize_operations') is still TRUE.

To install new code, the administrator is prompted for either the URL of an archive file, or to directly upload the archive file. The archive is loaded into a temporary location, extracted, and verified. If everything is successful, the user is redirected to authorize.php to type in file transfer credentials and authorize the installation to proceed with elevated privileges, such that the extracted files can be copied out of the temporary location and into the live web root.

Updating existing code is a more elaborate process. The first step is a selection form where the user is presented with a table of installed projects that are missing newer releases. The user selects which projects they wish to update, and presses the "Download updates" button to continue. This sets up a batch to fetch all the selected releases, and redirects to admin/update/download to display the batch progress bar as it runs. Each batch operation is responsible for downloading a single file, extracting the archive, and verifying the contents. If there are any errors, the user is redirected back to the first page with the error messages. If all downloads were extacted and verified, the user is instead redirected to admin/update/ready, a landing page which reminds them to backup their database and asks if they want to put the site offline during the update. Once the user presses the "Install updates" button, they are redirected to authorize.php to supply their web root file access credentials. The authorized operation (which lives in update.authorize.inc) sets up a batch to copy each extracted update from the temporary location into the live web root.

Definition in file update.manager.inc.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.module File Reference

  • modules
  • update
Functions | Variables
update.module File Reference

Go to the source code of this file.

Functions

update_help ($path, $arg)
update_init ()
update_menu ()
update_manager_access ()
update_theme ()
update_cron ()
update_themes_enabled ($themes)
update_themes_disabled ($themes)
update_form_system_modules_alter (&$form, $form_state)
update_cache_clear_submit ($form, &$form_state)
_update_no_data ()
update_get_available ($refresh=FALSE)
update_create_fetch_task ($project)
update_refresh ()
update_fetch_data ()
_update_get_cached_available_releases ()
update_mail ($key, &$message, $params)
_update_message_text ($msg_type, $msg_reason, $report_link=FALSE, $language=NULL)
_update_project_status_sort ($a, $b)
theme_update_last_check ($variables)
update_verify_update_archive ($project, $archive_file, $directory)
_update_cache_set ($cid, $data, $expire)
_update_cache_get ($cid)
_update_get_cache_multiple ($cid_prefix)
_update_cache_clear ($cid=NULL, $wildcard=FALSE)
update_flush_caches ()
_update_manager_unique_identifier ()
_update_manager_extract_directory ($create=TRUE)
_update_manager_cache_directory ($create=TRUE)
update_clear_update_disk_cache ()
update_delete_file_if_stale ($path)

Variables

const | UPDATE_DEFAULT_URL 'http://updates.drupal.org/release-history'
const | UPDATE_NOT_SECURE 1
const | UPDATE_REVOKED 2
const | UPDATE_NOT_SUPPORTED 3
const | UPDATE_NOT_CURRENT 4
const | UPDATE_CURRENT 5
const | UPDATE_NOT_CHECKED -1
const | UPDATE_UNKNOWN -2
const | UPDATE_NOT_FETCHED -3
const | UPDATE_FETCH_PENDING -4
const | UPDATE_MAX_FETCH_ATTEMPTS 2
const | UPDATE_MAX_FETCH_TIME 5

Detailed Description

Handles updates of Drupal core and contributed projects.

The module checks for available updates of Drupal core and any installed contributed modules and themes. It warns site administrators if newer releases are available via the system status report (admin/reports/status), the module and theme pages, and optionally via e-mail. It also provides the ability to install contributed modules and themes via an user interface.

Definition in file update.module.

Function Documentation

_update_get_cached_available_releases ( )

Returns all currently cached data about available releases for all projects.

Returns
Array of data about available releases, keyed by project shortname.

Definition at line 485 of file update.module.

References _update_get_cache_multiple(), REQUEST_TIME, and UPDATE_FETCH_PENDING.

Referenced by update_get_available().

_update_manager_cache_directory ( $create = TRUE )

Returns the directory where update archive files should be cached.

Parameters
$create (optional) Whether to attempt to create the directory if it does not already exist. Defaults to TRUE.
Returns
The full path to the temporary directory where update file archives should be cached.

Definition at line 940 of file update.module.

References _update_manager_unique_identifier(), and drupal_static().

Referenced by update_clear_update_disk_cache(), and update_manager_file_get().

_update_manager_extract_directory ( $create = TRUE )

Returns the directory where update archive files should be extracted.

Parameters
$create (optional) Whether to attempt to create the directory if it does not already exist. Defaults to TRUE.
Returns
The full path to the temporary directory where update file archives should be extracted.

Definition at line 918 of file update.module.

References _update_manager_unique_identifier(), and drupal_static().

Referenced by update_clear_update_disk_cache(), update_manager_batch_project_get(), update_manager_install_form_submit(), and update_manager_update_ready_form_submit().

_update_manager_unique_identifier ( )

End of "defgroup update_status_cache". Returns a short unique identifier for this Drupal installation.

Returns
An eight character string uniquely identifying this Drupal installation.

Definition at line 899 of file update.module.

References drupal_get_hash_salt(), and drupal_static().

Referenced by _update_manager_cache_directory(), and _update_manager_extract_directory().

_update_message_text | ( | $msg_type,
 |  | $msg_reason,
 |  | $report_link = FALSE,
 |  | $language = NULL
 | ) |

Returns the appropriate message text when site is out of date or not secure.

These error messages are shared by both update_requirements() for the site-wide status report at admin/reports/status and in the body of the notification e-mail messages generated by update_cron().

Parameters
$msg_type | String to indicate what kind of message to generate. Can be either 'core' or 'contrib'.
$msg_reason | Integer constant specifying why message is generated.
$report_link | (optional) Boolean that controls if a link to the updates report should be added. Defaults to FALSE.
$language | (optional) A language object to use. Defaults to NULL.
Returns
The properly translated error message for the given key.

Definition at line 562 of file update.module.

References t(), UPDATE_FETCH_PENDING, update_manager_access(), UPDATE_NOT_CHECKED, UPDATE_NOT_CURRENT, UPDATE_NOT_FETCHED, UPDATE_NOT_SECURE, UPDATE_NOT_SUPPORTED, UPDATE_REVOKED, UPDATE_UNKNOWN, and url().

Referenced by _update_requirement_check(), and update_mail().

_update_no_data ( )

Returns a warning message when there is no data about available updates.

Definition at line 365 of file update.module.

References drupal_get_destination(), t(), and url().

Referenced by update_requirements(), and update_status().

_update_project_status_sort | ( | $a,
 |  | $b
 | ) |

Orders projects based on their status.

Callback for uasort() within update_requirements().

Definition at line 632 of file update.module.

update_cache_clear_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submission handler for system_modules().

See Also
update_form_system_modules_alter()

Definition at line 357 of file update.module.

References _update_cache_clear().

update_clear_update_disk_cache ( )

Clears the temporary files and directories based on file age from disk.

Definition at line 954 of file update.module.

References _update_manager_cache_directory(), _update_manager_extract_directory(), and file_scan_directory().

Referenced by update_cron().

update_create_fetch_task ( $project )

Creates a new fetch task after loading the necessary include file.

Parameters
$project Associative array of information about a project. See update_get_projects() for the keys used.
See Also
_update_create_fetch_task()

Definition at line 454 of file update.module.

References _update_create_fetch_task(), and module_load_include().

Referenced by _update_refresh(), and update_get_available().

update_cron ( )

Implements hook_cron().

Definition at line 294 of file update.module.

References _update_cron_notify(), module_load_include(), REQUEST_TIME, update_clear_update_disk_cache(), update_fetch_data(), update_get_available(), update_refresh(), and variable_get().

update_delete_file_if_stale ( $path )

Deletes stale files and directories from the update manager disk cache.

Files and directories older than 6 hours and development snapshots older than 5 minutes are considered stale. We only cache development snapshots for 5 minutes since otherwise updated snapshots might not be downloaded as expected.

When checking file ages, we need to use the ctime, not the mtime (modification time) since many (all?) tar implementations go out of their way to set the mtime on the files they create to the timestamps recorded in the tarball. We want to see the last time the file was changed on disk, which is left alone by tar and correctly set to the time the archive file was unpacked.

Parameters
$path A string containing a file path or (streamwrapper) URI.

Definition at line 986 of file update.module.

References DRUPAL_MAXIMUM_TEMP_FILE_AGE, file_unmanaged_delete_recursive(), and REQUEST_TIME.

Referenced by update_manager_file_get().

update_fetch_data ( )

Attempts to fetch update data after loading the necessary include file.

See Also
_update_fetch_data()

Definition at line 474 of file update.module.

References _update_fetch_data(), and module_load_include().

Referenced by update_cron(), and update_get_available().

update_form_system_modules_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter() for system_modules().

Adds a form submission handler to the system modules form, so that if a site admin saves the form, we invalidate the cache of available updates.

See Also
_update_cache_clear()

Definition at line 348 of file update.module.

update_get_available ( $refresh = FALSE )

Tries to get update information from cache and refreshes it when necessary.

In addition to checking the cache lifetime, this function also ensures that there are no .info files for enabled modules or themes that have a newer modification timestamp than the last time we checked for available update data. If any .info file was modified, it almost certainly means a new version of something was installed. Without fresh available update data, the logic in update_calculate_project_data() will be wrong and produce confusing, bogus results.

Parameters
$refresh (optional) Boolean to indicate if this method should refresh the cache automatically if there's no data. Defaults to FALSE.
Returns
Array of data about available releases, keyed by project shortname.
See Also
update_refresh()
update_get_projects()

Definition at line 394 of file update.module.

References _update_get_cached_available_releases(), module_load_include(), update_create_fetch_task(), update_fetch_data(), UPDATE_FETCH_PENDING, and update_get_projects().

Referenced by update_cron(), update_manager_update_form(), update_requirements(), and update_status().

update_help | ( | $path,
 |  | $arg
 | ) |

Implements hook_help().

Definition at line 79 of file update.module.

References $output, t(), update_manager_access(), and url().

update_init ( )

Implements hook_init().

Definition at line 111 of file update.module.

References arg(), drupal_set_message(), module_load_install(), REQUIREMENT_ERROR, REQUIREMENT_WARNING, UPDATE_NOT_SECURE, update_requirements(), and user_access().

update_mail | ( |  | $key,
 |  | & | $message,
 |  |  | $params
 | ) |  |

Implements hook_mail().

Constructs the e-mail notification message when the site is out of date.

Parameters
$key | Unique key to indicate what message to build, always 'status_notify'.
$message | Reference to the message array being built.
$params | Array of parameters to indicate what kind of text to include in the message body. This is a keyed array of message type ('core' or 'contrib') as the keys, and the status reason constant (UPDATE_NOT_SECURE, etc) for the values.
See Also
drupal_mail()
_update_cron_notify()
_update_message_text()

Definition at line 521 of file update.module.

References _update_message_text(), t(), update_manager_access(), url(), and variable_get().

update_manager_access ( )

Access callback: Resolves if the current user can access updater menu items.

It both enforces the 'administer software updates' permission and the global kill switch for the authorize.php script.

Returns
TRUE if the current user can access the updater menu items; FALSE otherwise.
See Also
update_menu()

Definition at line 263 of file update.module.

References user_access(), and variable_get().

Referenced by _update_message_text(), _update_requirement_check(), system_help(), update_help(), and update_mail().

update_menu ( )

Implements hook_menu().

Definition at line 165 of file update.module.

References MENU_CALLBACK, MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION, and MENU_LOCAL_TASK.

update_refresh ( )

Refreshes the release data after loading the necessary include file.

See Also
_update_refresh()

Definition at line 464 of file update.module.

References _update_refresh(), and module_load_include().

Referenced by update_cron().

update_theme ( )

Implements hook_theme().

Definition at line 270 of file update.module.

update_themes_disabled ( $themes )

Implements hook_themes_disabled().

If themes are disabled, we invalidate the cache of available updates.

Definition at line 335 of file update.module.

References _update_cache_clear().

update_themes_enabled ( $themes )

Implements hook_themes_enabled().

If themes are enabled, we invalidate the cache of available updates.

Definition at line 325 of file update.module.

References _update_cache_clear().

update_verify_update_archive | ( | $project,
 |  | $archive_file,
 |  | $directory
 | ) |

Implements hook_verify_update_archive().

First, we ensure that the archive isn't a copy of Drupal core, which the update manager does not yet support. See http://drupal.org/node/606592

Then, we make sure that at least one module included in the archive file has an .info file which claims that the code is compatible with the current version of Drupal core.

See Also
drupal_system_listing()
_system_rebuild_module_data()

Definition at line 679 of file update.module.

References $info, drupal_basename(), DRUPAL_CORE_COMPATIBILITY, drupal_parse_info_file(), DRUPAL_PHP_FUNCTION_PATTERN, file_scan_directory(), format_plural(), and t().

Variable Documentation

const UPDATE_CURRENT 5

Project is up to date.

Definition at line 44 of file update.module.

Referenced by _update_requirement_check(), theme_update_report(), theme_update_status_label(), update_calculate_project_update_status(), and update_manager_update_form().

const UPDATE_DEFAULT_URL 'http://updates.drupal.org/release-history'

URL to check for updates, if a given project doesn't define its own.

Definition at line 17 of file update.module.

Referenced by _update_get_fetch_url_base().

const UPDATE_FETCH_PENDING -4

We need to (re)fetch available update data for this project.

Definition at line 64 of file update.module.

Referenced by _update_get_cached_available_releases(), _update_message_text(), theme_update_report(), update_calculate_project_update_status(), and update_get_available().

const UPDATE_MAX_FETCH_ATTEMPTS 2

Maximum number of attempts to fetch available update data from a given host.

Definition at line 69 of file update.module.

Referenced by _update_process_fetch_task().

const UPDATE_MAX_FETCH_TIME 5

Maximum number of seconds to try fetching available update data at a time.

Definition at line 74 of file update.module.

Referenced by _update_fetch_data().

const UPDATE_NOT_CHECKED -1

Project's status cannot be checked.

Definition at line 49 of file update.module.

Referenced by _update_message_text(), _update_requirement_check(), hook_update_status_alter(), theme_update_report(), update_calculate_project_update_status(), and update_manager_update_form().

const UPDATE_NOT_CURRENT 4

Project has a new release available, but it is not a security release.

Definition at line 39 of file update.module.

Referenced by _update_cron_notify(), _update_message_text(), _update_requirement_check(), theme_update_report(), theme_update_status_label(), update_calculate_project_update_status(), and update_manager_update_form().

const UPDATE_NOT_FETCHED -3

There was a failure fetching available update data for this project.

Definition at line 59 of file update.module.

Referenced by _update_message_text(), _update_requirement_check(), theme_update_report(), update_calculate_project_update_status(), and update_manager_update_form().

const UPDATE_NOT_SECURE 1

Project is missing security update(s).

Definition at line 24 of file update.module.

Referenced by _update_message_text(), _update_requirement_check(), theme_update_report(), theme_update_status_label(), update_calculate_project_update_status(), update_init(), and update_manager_update_form().

const UPDATE_NOT_SUPPORTED 3

Current release is no longer supported by the project maintainer.

Definition at line 34 of file update.module.

Referenced by _update_message_text(), _update_requirement_check(), theme_update_report(), theme_update_status_label(), update_calculate_project_update_status(), and update_manager_update_form().

const UPDATE_REVOKED 2

Current release has been unpublished and is no longer available.

Definition at line 29 of file update.module.

Referenced by _update_message_text(), _update_requirement_check(), theme_update_report(), theme_update_status_label(), update_calculate_project_update_status(), and update_manager_update_form().

const UPDATE_UNKNOWN -2

No available update data was found for project.

Definition at line 54 of file update.module.

Referenced by _update_message_text(), _update_requirement_check(), theme_update_report(), update_calculate_project_data(), update_calculate_project_update_status(), update_manager_update_form(), and update_requirements().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.report.inc File Reference

  • modules
  • update
Functions
update.report.inc File Reference

Go to the source code of this file.

Functions

update_status ()
theme_update_report ($variables)
theme_update_status_label ($variables)
theme_update_version ($variables)

Detailed Description

Code required only when rendering the available updates report.

Definition in file update.report.inc.

Function Documentation

update_status ( )

Page callback: Generates a page about the update status of projects.

See Also
update_menu()

Definition at line 13 of file update.report.inc.

References _update_no_data(), module_load_include(), theme(), update_calculate_project_data(), and update_get_available().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.settings.inc File Reference

  • modules
  • update
Functions
update.settings.inc File Reference

Go to the source code of this file.

Functions

update_settings ($form)
update_settings_validate ($form, &$form_state)
update_settings_submit ($form, $form_state)

Detailed Description

Code required only for the update status settings form.

Definition in file update.settings.inc.

Function Documentation

update_settings_submit | ( | $form,
 |  | $form_state
 | ) |

Form submission handler for update_settings().

Also invalidates the cache of available updates if the "Check for updates of disabled modules and themes" setting is being changed. The available updates report needs to refetch available update data after this setting changes or it would show misleading things (e.g., listing the disabled projects on the site with the "No available releases found" warning).

See Also
update_settings_validate()

Definition at line 108 of file update.settings.inc.

References $op, _update_cache_clear(), system_settings_form_submit(), variable_del(), variable_get(), and variable_set().

update_settings_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for update_settings().

Validates the e-mail addresses and ensures the field is formatted correctly.

See Also
update_settings_submit()

Definition at line 70 of file update.settings.inc.

References form_set_error(), t(), and valid_email_address().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user Directory Reference

  • modules
  • user
user Directory Reference

Files

file | user-picture.tpl.php [code]
file | user-profile-category.tpl.php [code]
file | user-profile-item.tpl.php [code]
file | user-profile.tpl.php [code]
file | user.admin.inc [code]
file | user.api.php [code]
file | user.install [code]
file | user.module [code]
file | user.pages.inc [code]
file | user.tokens.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user-profile-category.tpl.php File Reference

  • modules
  • user
Variables
user-profile-category.tpl.php File Reference

Go to the source code of this file.

Variables

if($title) endif
print $attributes
print $profile_items

Detailed Description

Default theme implementation to present profile categories (groups of profile items).

Categories are defined when configuring user profile fields for the site. It can also be defined by modules. All profile items for a category will be output through the $profile_items variable.

See Also
user-profile-item.tpl.php where each profile item is rendered. It is implemented as a definition list by default.
user-profile.tpl.php where all items and categories are collected and printed out.

Available variables:

  • $title: Category title for the group of items.
  • $profile_items: All the items for the group rendered through user-profile-item.tpl.php.
  • $attributes: HTML attributes. Usually renders classes.
See Also
template_preprocess_user_profile_category()

Definition in file user-profile-category.tpl.php.

Variable Documentation

print $attributes

Definition at line 31 of file user-profile-category.tpl.php.

print $profile_items

Definition at line 32 of file user-profile-category.tpl.php.

if ($title) endif

Definition at line 27 of file user-profile-category.tpl.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user-profile-item.tpl.php File Reference

  • modules
  • user
Variables
user-profile-item.tpl.php File Reference

Go to the source code of this file.

Variables

print $attributes
print $title
print $value

Detailed Description

Default theme implementation to present profile items (values from user account profile fields or modules).

This template is used to loop through and render each field configured for the user's account. It can also be the data from modules. The output is grouped by categories.

See Also
user-profile-category.tpl.php for the parent markup. Implemented as a definition list by default.
user-profile.tpl.php where all items and categories are collected and printed out.

Available variables:

  • $title: Field title for the profile item.
  • $value: User defined value for the profile item or data from a module.
  • $attributes: HTML attributes. Usually renders classes.
See Also
template_preprocess_user_profile_item()

Definition in file user-profile-item.tpl.php.

Variable Documentation

print $attributes

Definition at line 25 of file user-profile-item.tpl.php.

print $title

Definition at line 25 of file user-profile-item.tpl.php.

print $value

Definition at line 26 of file user-profile-item.tpl.php.

Referenced by UpdateQuery\__toString(), _drupal_bootstrap_database(), _drupal_session_write(), _field_ui_field_name_exists(), _file_generic_settings_file_directory_validate(), _form_options_flatten(), _form_validate(), _image_field_resolution_validate(), _list_update_7001_extract_allowed_values(), _locale_import_one_string(), _locale_prepare_predefined_list(), _menu_build_tree(), _menu_load_objects(), _node_mass_update_helper(), _openid_create_message(), _options_prepare_options(), _password_base64_encode(), _poll_choice_form(), _simpletest_batch_operation(), _system_info_add_path(), _update_7000_field_read_fields(), _update_7000_field_sql_storage_write(), EntityFieldQuery\addFieldCondition(), aggregator_aggregator_parse(), aggregator_block_configure(), aggregator_filter_xss(), aggregator_parse_feed(), aggregator_save_feed(), ajax_command_data(), ajax_example_advanced_commands_data_callback(), ajax_example_wizard_submit(), DrupalTestCase\assertFalse(), DrupalWebTestCase\assertFieldById(), DrupalWebTestCase\assertFieldByName(), DrupalWebTestCase\assertFieldByXPath(), DrupalWebTestCase\assertMail(), DrupalWebTestCase\assertNoFieldById(), DrupalWebTestCase\assertNoFieldByName(), DrupalWebTestCase\assertNoFieldByXPath(), DrupalTestCase\assertNotNull(), DrupalTestCase\assertNull(), DrupalTestCase\assertTrue(), authorize_filetransfer_form_submit(), DrupalDefaultEntityController\buildQuery(), DrupalWebTestCase\buildXPathQuery(), DrupalWebTestCase\changeDatabasePrefix(), color_palette_color_value(), color_scheme_form(), comment_admin_overview_submit(), comment_form(), comment_multiple_delete_confirm(), DatabaseCondition\compile(), SelectQueryExtender\condition(), DeleteQuery\condition(), SelectQuery\condition(), UpdateQuery\condition(), MergeQuery\condition(), DatabaseCondition\condition(), DrupalWebTestCase\constructFieldXpath(), DrupalWebTestCase\curlHeaderCallback(), dblog_build_filter_query(), dbtng_example_entry_load(), drupal_add_http_header(), drupal_array_diff_assoc_recursive(), drupal_array_merge_deep_array(), drupal_array_set_nested_value(), drupal_get_query_parameters(), drupal_get_token(), drupal_html_to_text(), drupal_http_build_query(), drupal_http_request(), drupal_page_set_cache(), drupal_parse_dependency(), drupal_parse_info_format(), drupal_render_collect_attached(), drupal_send_headers(), drupal_serve_page_from_cache(), drupal_static(), drupal_unpack(), drupal_valid_token(), drupal_validate_form(), drupal_var_export(), DrupalWebTestCase\drupalGetHeaders(), DrupalWebTestCase\drupalGetMails(), DrupalWebTestCase\drupalGetToken(), DrupalWebTestCase\drupalPost(), DrupalWebTestCase\drupalPostAJAX(), element_children(), element_validate_integer(), element_validate_integer_positive(), element_validate_number(), entity_form_submit_build_entity(), EntityFieldQuery\entityCondition(), InsertQuery_mysql\execute(), InsertQuery_pgsql\execute(), UpdateQuery_pgsql\execute(), UpdateQuery\execute(), DatabaseConnection\expandArguments(), DatabaseStatementPrefetch\fetchAllKeyed(), field_example_3text_validate(), field_example_field_widget_form(), field_extra_fields_get_display(), field_permission_example_field_widget_form(), field_read_fields(), field_read_instances(), field_ui_display_overview_form_submit(), EntityFieldQuery\fieldCondition(), EntityFieldQuery\fieldDeltaCondition(), EntityFieldQuery\fieldLanguageCondition(), MergeQuery\fields(), file_requirements(), file_transfer(), filter_admin_format_form_submit(), form_example_element_demo_form_submit(), form_example_phonenumber_combined_validate(), form_example_wizard_submit(), form_process_checkbox(), form_process_checkboxes(), form_process_tableselect(), form_set_value(), form_type_checkboxes_value(), form_type_radios_value(), form_type_tableselect_value(), format_interval(), format_string(), format_xml_elements(), DrupalTestCase\generatePermutations(), DrupalWebTestCase\getSelectedItem(), DatabaseStatement_sqlite\getStatement(), DrupalWebTestCase\handleForm(), SelectQueryExtender\havingCondition(), SelectQuery\havingCondition(), hook_file_load(), hook_theme_registry_alter(), image_effect_integer_validate(), image_filter_keyword(), image_gd_settings_validate(), image_style_deliver(), MergeQuery\key(), list_allowed_values_setting_validate(), list_allowed_values_string(), list_extract_allowed_values(), locale_translate_edit_form_submit(), locale_translate_edit_form_validate(), DefaultMailSystem\mail(), menu_edit_menu_name_exists(), node_build_filter_query(), node_filter_form(), node_multiple_delete_confirm(), node_requirements(), node_type_form_submit(), node_type_reset(), number_field_widget_form(), number_field_widget_validate(), DrupalCacheArray\offsetSet(), openid_authentication_request(), openid_extract_ax_values(), openid_extract_namespace(), openid_redirect_form(), openid_verify_assertion_return_url(), options_array_flatten(), overlay_display_empty_page(), pager_load_array(), Database\parseConnectionInfo(), path_delete(), path_load(), poll_load(), SelectQuery\preExecute(), profile_admin_overview(), profile_autocomplete(), profile_browse(), EntityFieldQuery\propertyCondition(), DatabaseConnection_pgsql\query(), SchemaCache\resolveCacheMiss(), SearchQuery\setOption(), DrupalUnitTestCase\setUp(), simpletest_test_form_submit(), st(), system_get_files_database(), system_modules_uninstall_confirm_form(), system_settings_form_submit(), system_update_7017(), system_update_files_database(), taxonomy_autocomplete_validate(), taxonomy_form_term(), taxonomy_form_vocabulary(), taxonomy_taxonomy_vocabulary_update(), template_preprocess_block_admin_display_form(), theme_item_list(), theme_table(), theme_update_report(), user_build_filter_query(), user_cookie_save(), user_filter_form(), user_multiple_cancel_confirm_submit(), user_permission_get_modules(), user_save(), user_set_authmaps(), user_update_7017(), user_user_operations(), variable_initialize(), variable_set(), xmlrpc_message_set(), xmlrpc_message_tag_close(), xmlrpc_value(), and xmlrpc_value_get_xml().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user.admin.inc File Reference

  • modules
  • user
Functions
user.admin.inc File Reference

Go to the source code of this file.

Functions

user_admin ($callback_arg= '')
user_filter_form ()
user_filter_form_submit ($form, &$form_state)
user_admin_account ()
user_admin_account_submit ($form, &$form_state)
user_admin_account_validate ($form, &$form_state)
user_admin_settings ()
user_admin_permissions ($form, $form_state, $rid=NULL)
user_admin_permissions_submit ($form, &$form_state)
theme_user_admin_permissions ($variables)
theme_user_permission_description ($variables)
user_admin_roles ($form, $form_state)
user_admin_roles_order_submit ($form, &$form_state)
theme_user_admin_roles ($variables)
user_admin_role ($form, $form_state, $role)
user_admin_role_validate ($form, &$form_state)
user_admin_role_submit ($form, &$form_state)
user_admin_role_delete_submit ($form, &$form_state)
user_admin_role_delete_confirm ($form, &$form_state, $role)
user_admin_role_delete_confirm_submit ($form, &$form_state)

Detailed Description

Admin page callback file for the user module.

Definition in file user.admin.inc.

Function Documentation

user_admin ( $callback_arg = '' )

Page callback: Generates the appropriate user administration form.

This function generates the user registration, multiple user cancellation, or filtered user list admin form, depending on the argument and the POST form values.

Parameters
string $callback_arg (optional) Indicates which form to build. Defaults to '', which will trigger the user filter form. If the POST value 'op' is present, this function uses that value as the callback argument.
Returns
string A renderable form array for the respective request.

Definition at line 23 of file user.admin.inc.

References $op, drupal_get_form(), and t().

user_admin_account_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit the user administration update form.

Definition at line 248 of file user.admin.inc.

References drupal_set_message(), module_invoke_all(), and t().

user_admin_account_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 267 of file user.admin.inc.

References form_set_error(), and t().

user_admin_permissions_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Save permissions selected on the administer permissions page.

See Also
user_admin_permissions()

Definition at line 753 of file user.admin.inc.

References $name, cache_clear_all(), drupal_set_message(), t(), and user_role_change_permissions().

user_admin_role_delete_confirm | ( |  | $form,
 |  | & | $form_state,
 |  |  | $role
 | ) |  |

Form to confirm role delete operation.

Definition at line 1037 of file user.admin.inc.

References confirm_form(), and t().

user_admin_role_delete_confirm_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submit handler for user_admin_role_delete_confirm().

Definition at line 1048 of file user.admin.inc.

References drupal_set_message(), t(), and user_role_delete().

user_admin_role_delete_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submit handler for the user_admin_role() form.

Definition at line 1030 of file user.admin.inc.

user_admin_role_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submit handler for the user_admin_role() form.

Definition at line 1013 of file user.admin.inc.

References drupal_set_message(), t(), and user_role_save().

user_admin_role_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for the user_admin_role() form.

Definition at line 991 of file user.admin.inc.

References form_set_error(), t(), and user_role_load_by_name().

user_admin_roles_order_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form submit function. Update the role weights.

Definition at line 895 of file user.admin.inc.

References drupal_set_message(), t(), and user_role_save().

user_filter_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Process result from user administration filter form.

Definition at line 124 of file user.admin.inc.

References $op, form_options_flatten(), t(), and user_filters().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user.api.php File Reference

  • modules
  • user
Functions
user.api.php File Reference

Go to the source code of this file.

Functions

hook_user_load ($users)
hook_user_delete ($account)
hook_user_cancel ($edit, $account, $method)
hook_user_cancel_methods_alter (&$methods)
hook_user_operations ()
hook_user_categories ()
hook_user_presave (&$edit, $account, $category)
hook_user_insert (&$edit, $account, $category)
hook_user_update (&$edit, $account, $category)
hook_user_login (&$edit, $account)
hook_user_logout ($account)
hook_user_view ($account, $view_mode, $langcode)
hook_user_view_alter (&$build)
hook_user_role_presave ($role)
hook_user_role_insert ($role)
hook_user_role_update ($role)
hook_user_role_delete ($role)

Detailed Description

Hooks provided by the User module.

Definition in file user.api.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user.install File Reference

  • modules
  • user
Functions
user.install File Reference

Go to the source code of this file.

Functions

user_schema ()
user_install ()
user_update_dependencies ()
_update_7000_user_role_grant_permissions ($rid, array $permissions, $module)
user_update_7000 (&$sandbox)
user_update_7001 ()
user_update_7002 (&$sandbox)
user_update_7003 ()
user_update_7005 (&$sandbox)
user_update_7006 (&$sandbox)
user_update_7007 ()
user_update_7008 ()
user_update_7009 ()
user_update_7010 ()
user_update_7011 ()
user_update_7012 (&$sandbox)
user_update_7013 (&$sandbox)
user_update_7014 ()
user_update_7015 ()
user_update_7016 ()
user_update_7017 ()
user_update_7018 ()

Detailed Description

Install, update and uninstall functions for the user module.

Definition in file user.install.

Function Documentation

user_install ( )

Implements hook_install().

Definition at line 293 of file user.install.

References db_insert(), db_update(), DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID, and REQUEST_TIME.

user_schema ( )

Implements hook_schema().

Definition at line 11 of file user.install.

user_update_dependencies ( )

Implements hook_update_dependencies().

Definition at line 345 of file user.install.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user.module File Reference

  • modules
  • user
Classes | Functions | Variables
user.module File Reference

Go to the source code of this file.

Classes

class UserController

Functions

user_help ($path, $arg)
user_module_invoke ($type, &$edit, $account, $category=NULL)
user_theme ()
user_entity_info ()
user_uri ($user)
user_field_info_alter (&$info)
user_field_extra_fields ()
user_external_load ($authname)
user_load_multiple ($uids=array(), $conditions=array(), $reset=FALSE)
user_load ($uid, $reset=FALSE)
user_load_by_mail ($mail)
user_load_by_name ($name)
user_save ($account, $edit=array(), $category= 'account')
user_validate_name ($name)
user_validate_mail ($mail)
user_validate_picture (&$form, &$form_state)
user_password ($length=10)
user_role_permissions ($roles=array())
user_access ($string, $account=NULL)
user_is_blocked ($name)
user_permission ()
user_file_download ($uri)
user_file_move ($file, $source)
user_file_delete ($file)
user_search_info ()
user_search_access ()
user_search_execute ($keys=NULL, $conditions=NULL)
user_element_info ()
user_user_view ($account)
user_account_form (&$form, &$form_state)
user_validate_current_pass (&$form, &$form_state)
user_account_form_validate ($form, &$form_state)
user_user_presave (&$edit, $account, $category)
user_user_categories ()
user_login_block ($form)
user_block_info ()
user_block_configure ($delta= '')
user_block_save ($delta= '', $edit=array())
user_block_view ($delta= '')
template_preprocess_user_picture (&$variables)
theme_user_list ($variables)
user_is_anonymous ()
user_is_logged_in ()
user_register_access ()
user_view_access ($account)
user_edit_access ($account)
user_cancel_access ($account)
user_menu ()
user_menu_site_status_alter (&$menu_site_status, $path)
user_menu_link_alter (&$link)
user_translated_menu_link_alter (&$link)
user_admin_paths ()
user_uid_only_optional_to_arg ($arg)
user_uid_optional_load ($uid=NULL)
user_category_load ($uid, &$map, $index)
user_uid_optional_to_arg ($arg)
user_menu_title ()
user_page_title ($account)
user_get_authmaps ($authname=NULL)
user_set_authmaps ($account, $authmaps)
user_login ($form, &$form_state)
user_login_default_validators ()
user_login_name_validate ($form, &$form_state)
user_login_authenticate_validate ($form, &$form_state)
user_login_final_validate ($form, &$form_state)
user_authenticate ($name, $password)
user_login_finalize (&$edit=array())
user_login_submit ($form, &$form_state)
user_external_login_register ($name, $module)
user_pass_reset_url ($account)
user_cancel_url ($account)
user_pass_rehash ($password, $timestamp, $login)
user_cancel ($edit, $uid, $method)
_user_cancel ($edit, $account, $method)
_user_cancel_session_regenerate ()
user_delete ($uid)
user_delete_multiple (array $uids)
user_view_page ($account)
user_view ($account, $view_mode= 'full', $langcode=NULL)
user_build_content ($account, $view_mode= 'full', $langcode=NULL)
user_mail ($key, &$message, $params)
_user_mail_text ($key, $language=NULL, $variables=array(), $replace=TRUE)
user_mail_tokens (&$replacements, $data, $options)
user_roles ($membersonly=FALSE, $permission=NULL)
user_role_load ($rid)
user_role_load_by_name ($role_name)
user_role_save ($role)
user_role_delete ($role)
user_role_edit_access ($role)
user_permission_get_modules ()
user_role_change_permissions ($rid, array $permissions=array())
user_role_grant_permissions ($rid, array $permissions=array())
user_role_revoke_permissions ($rid, array $permissions=array())
user_user_operations ($form=array(), $form_state=array())
user_user_operations_unblock ($accounts)
user_user_operations_block ($accounts)
user_multiple_role_edit ($accounts, $operation, $rid)
user_multiple_cancel_confirm ($form, &$form_state)
user_multiple_cancel_confirm_submit ($form, &$form_state)
_user_categories ()
_user_sort ($a, $b)
user_filters ()
user_build_filter_query (SelectQuery $query)
user_comment_view ($comment)
theme_user_signature ($variables)
user_preferred_language ($account, $default=NULL)
_user_mail_notify ($op, $account, $language=NULL)
user_form_process_password_confirm ($element)
user_node_load ($nodes, $types)
user_image_style_delete ($style)
user_image_style_save ($style)
user_action_info ()
user_block_user_action (&$entity, $context=array())
user_form_field_ui_field_edit_form_alter (&$form, &$form_state, $form_id)
user_form_field_ui_field_edit_form_submit ($form, &$form_state)
user_register_form ($form, &$form_state)
user_register_validate ($form, &$form_state)
user_register_submit ($form, &$form_state)
user_modules_installed ($modules)
user_modules_uninstalled ($modules)
user_login_destination ()
user_cookie_save (array $values)
user_cookie_delete ($cookie_name)
user_rdf_mapping ()
user_file_download_access ($field, $entity_type, $entity)
user_system_info_alter (&$info, $file, $type)

Variables

const | USERNAME_MAX_LENGTH 60
const | EMAIL_MAX_LENGTH 254
const | USER_REGISTER_ADMINISTRATORS_ONLY 0
const | USER_REGISTER_VISITORS 1
const | USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL 2

Detailed Description

Enables the user registration and login system.

Definition in file user.module.

Function Documentation

_user_cancel | ( | $edit,
 |  | $account,
 |  | $method
 | ) |

Last batch processing step for cancelling a user account.

Since batch and session API require a valid user account, the actual cancellation of a user account needs to happen last.

See Also
user_cancel()

Definition at line 2451 of file user.module.

References _user_mail_notify(), cache_clear_all(), drupal_anonymous_user(), drupal_set_message(), t(), user_delete(), user_save(), watchdog(), and WATCHDOG_NOTICE.

_user_cancel_session_regenerate ( )

Finished batch processing callback for cancelling a user account.

See Also
user_cancel()

Definition at line 2496 of file user.module.

References drupal_session_regenerate().

_user_categories ( )

Retrieve a list of all user setting/information categories and sort them by weight.

Definition at line 3376 of file user.module.

References module_invoke_all().

Referenced by user_category_load(), and user_menu().

_user_mail_notify | ( | $op,
 |  | $account,
 |  | $language = NULL
 | ) |

Conditionally create and send a notification email when a certain operation happens on the given user account.

See Also
user_mail_tokens()
drupal_mail()
Parameters
$op The operation being performed on the account. Possible values:
  • 'register_admin_created': Welcome message for user created by the admin.
  • 'register_no_approval_required': Welcome message when user self-registers.
  • 'register_pending_approval': Welcome message, user pending admin approval.
  • 'password_reset': Password recovery request.
  • 'status_activated': Account activated.
  • 'status_blocked': Account blocked.
  • 'cancel_confirm': Account cancellation request.
  • 'status_canceled': Account canceled.
$account | The user object of the account being notified. Must contain at least the fields 'uid', 'name', and 'mail'.
$language | Optional language to use for the notification, overriding account language.
Returns
The return value from drupal_mail_system()->mail(), if ends up being called.

Definition at line 3564 of file user.module.

References $op, drupal_mail(), language_default(), user_preferred_language(), and variable_get().

Referenced by _user_cancel(), user_cancel_confirm_form_submit(), user_pass_submit(), user_register_submit(), and user_save().

_user_mail_text | ( | $key,
 |  | $language = NULL,
 |  | $variables = array(),
 |  | $replace = TRUE
 | ) |

Returns a mail string for a variable name.

Used by user_mail() and the settings forms to retrieve strings.

Definition at line 2671 of file user.module.

References t(), token_replace(), and variable_get().

Referenced by user_admin_settings(), and user_mail().

_user_sort | ( | $a,
 |  | $b
 | ) |

Definition at line 3383 of file user.module.

template_preprocess_user_picture ( & $variables )

Process variables for user-picture.tpl.php.

The $variables array contains the following arguments:

  • $account: A user, node or comment object with 'name', 'uid' and 'picture' fields.
See Also
user-picture.tpl.php

Definition at line 1463 of file user.module.

References $attributes, file_load(), file_valid_uri(), format_username(), l(), module_exists(), t(), theme(), user_access(), and variable_get().

user_access | ( | $string,
 |  | $account = NULL
 | ) |

Determine whether the user has a given privilege.

Parameters
$string | The permission, such as "administer nodes", being checked for.
$account | (optional) The account to check, if not given use currently logged in user.
Returns
Boolean TRUE if the current user has the requested permission.

All permission checks in Drupal should go through this function. This way, we guarantee consistent behavior, and ensure that the superuser can perform all actions.

Definition at line 794 of file user.module.

References drupal_static(), and user_role_permissions().

Referenced by _aggregator_has_categories(), _aggregator_page_list(), _block_themes_access(), _book_add_form_elements(), _book_outline_access(), _contact_personal_tab_access(), _field_ui_view_mode_menu_access(), _filter_disable_format_access(), _menu_check_access(), _menu_site_is_offline(), _node_add_access(), _node_query_node_access_alter(), _node_revision_access(), _poll_choice_form(), _poll_menu_access(), _profile_get_fields(), _system_themes_access(), _template_preprocess_default_variables(), _token_example_get_comment(), _token_example_get_node(), _token_example_get_user(), _tracker_myrecent_access(), _tracker_user_access(), _translation_tab_access(), action_example_node_sticky_action_form(), aggregator_block_view(), authorize_access_allowed(), block_admin_configure(), blog_block_view(), blog_menu_local_tasks_alter(), blog_page_user_access(), blog_user_view(), book_export_html(), book_form_node_form_alter(), book_node_prepare(), book_node_presave(), book_node_view_link(), cache_example_page_form(), comment_access(), comment_block_view(), comment_file_download_access(), comment_form(), comment_form_node_form_alter(), comment_form_node_type_form_alter(), comment_form_submit(), comment_get_display_ordinal(), comment_get_thread(), comment_links(), comment_node_page_additions(), comment_node_search_result(), comment_node_view(), comment_reply(), comment_save(), contact_personal_form(), contact_personal_form_submit(), contact_site_form(), contextual_preprocess(), cron_example_form(), dashboard_admin(), entity_example_info_page(), field_permission_example_field_access(), filter_access(), filter_permission(), filter_process_format(), forum_block_view(), hook_block_view(), hook_field_access(), hook_file_download(), hook_node_access(), hook_node_grants(), hook_preprocess(), hook_query_TAG_alter(), hook_search_access(), hook_user_cancel_methods_alter(), hook_user_view(), locale_language_selector_form(), menu_form_node_form_alter(), node_access(), node_access_example_node_grants(), node_admin_nodes(), node_block_view(), node_form(), node_form_search_form_alter(), node_get_recent(), node_help(), node_node_access(), node_permission(), node_revision_overview(), node_search_access(), overlay_disable_message(), overlay_form_user_profile_form_alter(), overlay_init(), path_admin_delete_confirm(), path_form_node_form_alter(), path_form_taxonomy_form_term_alter(), poll_block_view(), poll_form(), poll_insert(), poll_load(), profile_block_view(), profile_browse(), profile_category_access(), profile_user_form_validate(), profile_user_view(), profile_view_field(), rdf_preprocess_node(), shortcut_help(), shortcut_set_delete_access(), shortcut_set_edit_access(), shortcut_set_switch(), shortcut_set_switch_access(), simpletest_example_node_access(), statistics_block_view(), statistics_node_view(), statistics_top_visitors(), system_admin_config_page(), system_custom_theme(), system_modules(), taxonomy_form_term(), taxonomy_term_edit_access(), template_preprocess_aggregator_feed_source(), template_preprocess_poll_results(), template_preprocess_user_picture(), template_preprocess_username(), theme_book_admin_table(), theme_node_recent_block(), theme_poll_choices(), toolbar_page_build(), toolbar_preprocess_html(), translation_form_node_form_alter(), translation_node_prepare(), trigger_menu_unassign_access(), update_access_allowed(), update_helpful_links(), update_init(), update_manager_access(), update_results_page(), user_account_form(), user_block_view(), user_build_filter_query(), user_cancel_access(), user_cancel_confirm_form(), user_cancel_confirm_form_submit(), user_cancel_methods(), user_edit_access(), user_menu_site_status_alter(), user_profile_form(), user_register_form(), user_role_edit_access(), user_search_access(), user_search_execute(), user_user_operations(), and user_view_access().

user_account_form | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Helper function to add default user account fields to user registration and edit form.

See Also
user_account_form_validate()
user_validate_current_pass()
user_validate_picture()
user_validate_mail()

Definition at line 1019 of file user.module.

References DRUPAL_AUTHENTICATED_RID, EMAIL_MAX_LENGTH, filter_xss_admin(), l(), t(), theme(), user_access(), USER_REGISTER_VISITORS, USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, user_roles(), USERNAME_MAX_LENGTH, and variable_get().

Referenced by user_profile_form(), and user_register_form().

user_account_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for user_account_form().

See Also
user_account_form()

Definition at line 1223 of file user.module.

References db_like(), db_select(), drupal_get_schema(), drupal_strlen(), form_set_error(), form_set_value(), t(), url(), user_validate_mail(), and user_validate_name().

user_action_info ( )

Implements hook_action_info().

Definition at line 3668 of file user.module.

References t().

user_admin_paths ( )

Implements hook_admin_paths().

Definition at line 1912 of file user.module.

user_authenticate | ( | $name,
 |  | $password
 | ) |

Try to validate the user's login credentials locally.

Parameters
$name | User name to authenticate.
$password | A plain-text password, such as trimmed text from form values.
Returns
The user's uid on success, or FALSE on failure to authenticate.

Definition at line 2223 of file user.module.

References $name, DRUPAL_ROOT, user_check_password(), user_load_by_name(), user_needs_new_hash(), user_save(), and variable_get().

Referenced by user_login_authenticate_validate().

user_block_configure ( $delta = '' )

Implements hook_block_configure().

Definition at line 1361 of file user.module.

References drupal_map_assoc(), t(), and variable_get().

user_block_info ( )

Implements hook_block_info().

Definition at line 1340 of file user.module.

References DRUPAL_NO_CACHE, and t().

user_block_save | ( | $delta = '',
 |  | $edit = array()
 | ) |

Implements hook_block_save().

Definition at line 1385 of file user.module.

References variable_set().

user_block_view ( $delta = '' )

Implements hook_block_view().

Definition at line 1403 of file user.module.

References $output, arg(), db_query(), db_query_range(), drupal_get_form(), format_plural(), REQUEST_TIME, t(), theme(), user_access(), and variable_get().

user_build_content | ( | $account,
 |  | $view_mode = 'full',
 |  | $langcode = NULL
 | ) |

Builds a structured array representing the profile content.

Parameters
$account | A user object.
$view_mode | View mode, e.g. 'full'.
$langcode | (optional) A language code to use for rendering. Defaults to the global content language of the current request.

Definition at line 2626 of file user.module.

References drupal_alter(), entity_prepare_view(), field_attach_prepare_view(), field_attach_view(), and module_invoke_all().

Referenced by user_view().

user_build_filter_query ( SelectQuery $query )

Extends a query object for user administration filters based on session.

Parameters
$query Query object that should be filtered.

Definition at line 3443 of file user.module.

References $value, SelectQuery::condition(), DRUPAL_AUTHENTICATED_RID, SelectQuery::join(), user_access(), and user_filters().

Referenced by user_admin_account().

user_cancel | ( | $edit,
 |  | $uid,
 |  | $method
 | ) |

Cancel a user account.

Since the user cancellation process needs to be run in a batch, either Form API will invoke it, or batch_process() needs to be invoked after calling this function and should define the path to redirect to.

Parameters
$edit | An array of submitted form values.
$uid | The user ID of the user account to cancel.
$method | The account cancellation method to use.
See Also
_user_cancel()

Definition at line 2398 of file user.module.

References batch_set(), drupal_set_message(), module_invoke_all(), t(), user_load(), watchdog(), and WATCHDOG_ERROR.

Referenced by user_cancel_confirm(), user_cancel_confirm_form_submit(), and user_multiple_cancel_confirm_submit().

user_cancel_access ( $account )

Menu access callback; limit access to account cancellation pages.

Limit access to users with the 'cancel account' permission or administrative users, and prevent the anonymous user from cancelling the account.

Definition at line 1597 of file user.module.

References user_access().

user_cancel_url ( $account )

Generates a URL to confirm an account cancellation request.

Parameters
object $account The user account object, which must contain at least the following properties:
  • uid: The user ID number.
  • pass: The hashed user password string.
  • login: The UNIX timestamp of the user's last login.
Returns
A unique URL that may be used to confirm the cancellation of the user account.
See Also
user_mail_tokens()
user_cancel_confirm()

Definition at line 2352 of file user.module.

References REQUEST_TIME, url(), and user_pass_rehash().

Referenced by user_mail_tokens().

user_category_load | ( |  | $uid,
 |  | & | $map,
 |  |  | $index
 | ) |  |

Return a user object after checking if any profile category in the path exists.

Definition at line 1955 of file user.module.

References _user_categories(), and user_load().

user_comment_view ( $comment )

Implements hook_comment_view().

Definition at line 3475 of file user.module.

References check_markup(), and variable_get().

user_cookie_delete ( $cookie_name )

Delete a visitor information cookie.

Parameters
$cookie_name A cookie name such as 'homepage'.

Definition at line 3971 of file user.module.

References REQUEST_TIME.

Referenced by openid_user_logout().

user_cookie_save ( array $values )

Saves visitor information as a cookie so it can be reused.

Parameters
$values An array of key/value pairs to be saved into a cookie.

Definition at line 3958 of file user.module.

References $value, and REQUEST_TIME.

Referenced by comment_form_submit(), contact_personal_form_submit(), contact_site_form_submit(), openid_user_login(), and system_admin_compact_page().

user_delete ( $uid )

Delete a user.

Parameters
$uid A user ID.

Definition at line 2508 of file user.module.

References user_delete_multiple().

Referenced by _user_cancel().

user_delete_multiple ( array $uids )

Delete multiple user accounts.

Parameters
$uids An array of user IDs.

Definition at line 2518 of file user.module.

References db_delete(), db_transaction(), drupal_session_destroy_uid(), entity_get_controller(), field_attach_delete(), module_invoke_all(), user_load_multiple(), and watchdog_exception().

Referenced by user_delete().

user_edit_access ( $account )

Access callback for user account editing.

Definition at line 1587 of file user.module.

References user_access().

Referenced by profile_category_access().

user_element_info ( )

Implements hook_element_info().

Definition at line 977 of file user.module.

user_entity_info ( )

Implements hook_entity_info().

Definition at line 153 of file user.module.

References t().

user_external_load ( $authname )

Fetches a user object based on an external authentication source.

Parameters
string $authname The external authentication username.
Returns
A fully-loaded user object if the user is found or FALSE if not found.

Definition at line 249 of file user.module.

References db_query(), and user_load().

Referenced by _openid_invalid_openid_transition(), openid_authentication(), and user_external_login_register().

user_external_login_register | ( | $name,
 |  | $module
 | ) |

Helper function for authentication modules. Either logs in or registers the current user, based on username. Either way, the global $user object is populated and login tasks are performed.

Definition at line 2292 of file user.module.

References $name, drupal_anonymous_user(), drupal_set_message(), REQUEST_TIME, t(), user_external_load(), user_login_submit(), user_password(), user_save(), and user_set_authmaps().

user_field_extra_fields ( )

Implements hook_field_extra_fields().

Definition at line 214 of file user.module.

References t().

user_field_info_alter ( & $info )

Implements hook_field_info_alter().

Definition at line 201 of file user.module.

References $info.

user_file_delete ( $file )

Implements hook_file_delete().

Definition at line 906 of file user.module.

References db_update().

user_file_download ( $uri )

Implements hook_file_download().

Ensure that user pictures (avatars) are always downloadable.

Definition at line 880 of file user.module.

References $info, file_uri_target(), image_get_info(), and variable_get().

user_file_download_access | ( | $field,
 |  | $entity_type,
 |  | $entity
 | ) |

Implements hook_file_download_access().

Definition at line 4000 of file user.module.

References user_view_access().

user_file_move | ( | $file,
 |  | $source
 | ) |

Implements hook_file_move().

Definition at line 890 of file user.module.

References db_update().

user_filters ( )

List user administration filters that can be applied.

Definition at line 3392 of file user.module.

References $module, DRUPAL_AUTHENTICATED_RID, module_implements(), t(), and user_roles().

Referenced by user_build_filter_query(), user_filter_form(), and user_filter_form_submit().

user_form_field_ui_field_edit_form_alter | ( | & | $form,
 |  | & | $form_state,
 |  |  | $form_id
 | ) |  |

Implements hook_form_FORM_ID_alter().

Add a checkbox for the 'user_register_form' instance settings on the 'Edit field instance' form.

Definition at line 3715 of file user.module.

References drupal_get_path(), and t().

user_form_field_ui_field_edit_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Additional submit handler for the 'Edit field instance' form.

Make sure the 'user_register_form' setting is set for required fields.

Definition at line 3750 of file user.module.

References form_set_value().

user_form_process_password_confirm ( $element )

Form element process handler for client-side password validation.

This #process handler is automatically invoked for 'password_confirm' form elements to add the JavaScript and string translations for dynamic password validation.

See Also
system_element_info()

Definition at line 3590 of file user.module.

References drupal_get_path(), and t().

user_get_authmaps ( $authname = NULL )

Discover which external authentication module(s) authenticated a username.

Parameters
$authname A username used by an external authentication module.
Returns
An associative array with module as key and username as value.

Definition at line 2027 of file user.module.

References db_query().

user_help | ( | $path,
 |  | $arg
 | ) |

Implement hook_help().

Definition at line 37 of file user.module.

References $output, t(), and url().

user_image_style_delete ( $style )

Implements hook_image_style_delete().

Definition at line 3649 of file user.module.

References user_image_style_save().

user_image_style_save ( $style )

Implements hook_image_style_save().

Definition at line 3658 of file user.module.

References variable_get(), and variable_set().

Referenced by user_image_style_delete().

user_is_anonymous ( )

Determines if the current user is anonymous.

Returns
bool TRUE if the user is anonymous, FALSE if the user is authenticated.

Definition at line 1533 of file user.module.

Referenced by comment_form_submit(), hook_menu_site_status_alter(), openid_menu_site_status_alter(), user_menu_site_status_alter(), and user_register_access().

user_is_blocked ( $name )

Checks for usernames blocked by user administration.

Parameters
$name A string containing a name of the user.
Returns
Object with property 'name' (the user name), if the user is blocked; FALSE if the user is not blocked.

Definition at line 837 of file user.module.

References $name, db_like(), and db_select().

Referenced by user_login_name_validate().

user_is_logged_in ( )

Determines if the current user is logged in.

Returns
bool TRUE if the user is logged in, FALSE if the user is anonymous.

Definition at line 1544 of file user.module.

Referenced by user_menu_site_status_alter(), and user_menu_title().

user_load | ( | $uid,
 |  | $reset = FALSE
 | ) |

Loads a user object.

Drupal has a global $user object, which represents the currently-logged-in user. So to avoid confusion and to avoid clobbering the global $user object, it is a good idea to assign the result of this function to a different local variable, generally $account. If you actually do want to act as the user you are loading, it is essential to call drupal_save_session(FALSE); first. See Safely impersonating another user for more information.

Parameters
$uid | Integer specifying the user ID to load.
$reset | TRUE to reset the internal cache and load from the database; FALSE (default) to load from the internal cache, if set.
Returns
A fully-loaded user object upon successful user load, or FALSE if the user cannot be loaded.
See Also
user_load_multiple()

Definition at line 365 of file user.module.

References user_load_multiple().

Referenced by _trigger_normalize_comment_context(), _trigger_normalize_node_context(), action_example_unblock_user_action(), ajax_example_node_by_author_autocomplete_submit(), comment_tokens(), hook_file_copy(), hook_file_move(), hook_file_update(), hook_tokens(), install_configure_form_submit(), node_preview(), node_tokens(), overlay_user_dismiss_message(), profile_block_view(), DrupalWebTestCase::setUp(), statistics_user_tracker(), system_tokens(), theme_node_recent_content(), user_block_user_action(), user_cancel(), user_category_load(), user_external_load(), user_login_submit(), user_pass_reset(), user_tokens(), user_uid_optional_load(), and user_view_access().

user_load_by_mail ( $mail )

Fetch a user object by email address.

Parameters
$mail String with the account's e-mail address.
Returns
A fully-loaded $user object upon successful user load or FALSE if user cannot be loaded.
See Also
user_load_multiple()

Definition at line 381 of file user.module.

References user_load_multiple().

Referenced by _update_cron_notify(), and system_send_email_action().

user_load_by_name ( $name )

Fetch a user object by account name.

Parameters
$name String with the account's user name.
Returns
A fully-loaded $user object upon successful user load or FALSE if user cannot be loaded.
See Also
user_load_multiple()

Definition at line 397 of file user.module.

References $name, and user_load_multiple().

Referenced by action_example_node_sticky_action(), action_example_node_sticky_action_validate(), ajax_example_node_by_author_autocomplete(), ajax_example_node_by_author_autocomplete_validate(), comment_form_validate(), comment_preview(), comment_submit(), node_preview(), node_submit(), node_validate(), and user_authenticate().

user_load_multiple | ( | $uids = array(),
 |  | $conditions = array(),
 |  | $reset = FALSE
 | ) |

Load multiple users based on certain conditions.

This function should be used whenever you need to load more than one user from the database. Users are loaded into memory and will not require database access if loaded again during the same page request.

Parameters
$uids | An array of user IDs.
$conditions | (deprecated) An associative array of conditions on the {users} table, where the keys are the database fields and the values are the values those fields must have. Instead, it is preferable to use EntityFieldQuery to retrieve a list of entity IDs loadable by this function.
$reset | A boolean indicating that the internal cache should be reset. Use this if loading a user object which has been altered during the page request.
Returns
An array of user objects, indexed by uid.
See Also
entity_load()
user_load()
user_load_by_mail()
user_load_by_name()
EntityFieldQuery

Definition at line 290 of file user.module.

References entity_load().

Referenced by profile_browse(), user_delete_multiple(), user_load(), user_load_by_mail(), user_load_by_name(), user_multiple_cancel_confirm(), user_multiple_role_edit(), user_pass_reset(), user_pass_validate(), user_search_execute(), user_user_operations_block(), and user_user_operations_unblock().

user_login_authenticate_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

A validate handler on the login form. Check supplied username/password against local users table. If successful, $form_state['uid'] is set to the matching user ID.

Definition at line 2136 of file user.module.

References db_query(), flood_is_allowed(), ip_address(), user_authenticate(), and variable_get().

user_login_block ( $form )

Definition at line 1308 of file user.module.

References current_path(), drupal_get_destination(), l(), t(), theme(), url(), user_login_default_validators(), USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, USERNAME_MAX_LENGTH, and variable_get().

user_login_default_validators ( )

Set up a series for validators which check for blocked users, then authenticate against local database, then return an error if authentication fails. Distributed authentication modules are welcome to use hook_form_alter() to change this series in order to authenticate against their user database instead of the local users table. If a distributed authentication module is successful, it should set $form_state['uid'] to a user ID.

We use three validators instead of one since external authentication modules usually only need to alter the second validator.

See Also
user_login_name_validate()
user_login_authenticate_validate()
user_login_final_validate()
Returns
array A simple list of validate functions.

Definition at line 2117 of file user.module.

Referenced by user_login(), and user_login_block().

user_login_destination ( )

Helper function to rewrite the destination to avoid redirecting to login page after login.

Third-party authentication modules may use this function to determine the proper destination after a user has been properly logged in.

Definition at line 3944 of file user.module.

References drupal_get_destination().

Referenced by _openid_user_login_form_alter().

user_login_final_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

The final validation handler on the login form.

Sets a form error if user has not been authenticated, or if too many logins have been attempted. This validation function should always be the last one.

Definition at line 2183 of file user.module.

References flood_clear_event(), flood_register_event(), form_set_error(), format_plural(), t(), url(), variable_get(), and watchdog().

user_login_finalize ( & $edit = array() )

Finalize the login process. Must be called when logging in a user.

The function records a watchdog message about the new session, saves the login timestamp, calls hook_user_login(), and generates a new session.

Parameters
array $edit The array of form values submitted by the user.
See Also
hook_user_login()

Definition at line 2255 of file user.module.

References db_update(), drupal_session_regenerate(), REQUEST_TIME, user_module_invoke(), and watchdog().

Referenced by install_configure_form_submit(), user_login_submit(), and user_pass_reset().

user_login_name_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

A FAPI validate handler. Sets an error if supplied username has been blocked.

Definition at line 2124 of file user.module.

References form_set_error(), t(), and user_is_blocked().

Referenced by openid_authentication().

user_login_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for the login form. Load $user object and perform standard login tasks. The user is then redirected to the My Account page. Setting the destination in the query string overrides the redirect.

Definition at line 2279 of file user.module.

References user_load(), and user_login_finalize().

Referenced by openid_authentication(), user_external_login_register(), and user_register_submit().

user_mail | ( |  | $key,
 |  | & | $message,
 |  |  | $params
 | ) |  |

Implements hook_mail().

Definition at line 2659 of file user.module.

References _user_mail_text().

user_mail_tokens | ( | & | $replacements,
 |  |  | $data,
 |  |  | $options
 | ) |  |

Token callback to add unsafe tokens for user mails.

This function is used by the token_replace() call at the end of _user_mail_text() to set up some additional tokens that can be used in email messages generated by user_mail().

Parameters
$replacements | An associative array variable containing mappings from token names to values (for use with strtr()).
$data An associative array of token replacement values. If the 'user' element exists, it must contain a user account object with the following properties:
  • login: The UNIX timestamp of the user's last login.
  • pass: The hashed account login password.
$options | Unused parameter required by the token_replace() function.

Definition at line 2849 of file user.module.

References user_cancel_url(), and user_pass_reset_url().

user_menu ( )

Implements hook_menu().

Definition at line 1604 of file user.module.

References _user_categories(), drupal_get_path(), MENU_CALLBACK, MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION, and MENU_LOCAL_TASK.

user_menu_link_alter ( & $link )

Implements hook_menu_link_alter().

Definition at line 1883 of file user.module.

user_menu_site_status_alter | ( | & | $menu_site_status,
 |  |  | $path
 | ) |  |

Implements hook_menu_site_status_alter().

Definition at line 1841 of file user.module.

References drupal_goto(), MENU_SITE_OFFLINE, MENU_SITE_ONLINE, module_load_include(), user_access(), user_is_anonymous(), user_is_logged_in(), and user_logout().

user_menu_title ( )

Menu item title callback for the 'user' path.

Anonymous users should see "User account", but authenticated users are expected to see "My account".

Definition at line 2008 of file user.module.

References t(), and user_is_logged_in().

user_module_invoke | ( |  | $type,
 |  | & | $edit,
 |  |  | $account,
 |  |  | $category = NULL
 | ) |  |

Invokes a user hook in every module.

We cannot use module_invoke() for this, because the arguments need to be passed by reference.

Parameters
$type A text string that controls which user hook to invoke. Valid choices are:
  • cancel: Invokes hook_user_cancel().
  • insert: Invokes hook_user_insert().
  • login: Invokes hook_user_login().
  • presave: Invokes hook_user_presave().
  • update: Invokes hook_user_update().
$edit | An associative array variable containing form values to be passed as the first parameter of the hook function.
$account | The user account object to be passed as the second parameter of the hook function.
$category | The category of user information being acted upon.

Definition at line 98 of file user.module.

References $module, and module_implements().

Referenced by user_login_finalize(), and user_save().

user_modules_installed ( $modules )

Implements hook_modules_installed().

Definition at line 3913 of file user.module.

References $module, module_invoke(), user_role_grant_permissions(), and variable_get().

user_modules_uninstalled ( $modules )

Implements hook_modules_uninstalled().

Definition at line 3932 of file user.module.

References db_delete().

user_multiple_cancel_confirm | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 3279 of file user.module.

References check_plain(), confirm_form(), drupal_goto(), drupal_set_message(), element_children(), module_load_include(), name, t(), user_cancel_methods(), user_load_multiple(), and variable_get().

user_multiple_cancel_confirm_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for mass-account cancellation form.

See Also
user_multiple_cancel_confirm()
user_cancel_confirm_form_submit()

Definition at line 3349 of file user.module.

References $value, user_cancel(), and user_cancel_confirm_form_submit().

user_multiple_role_edit | ( | $accounts,
 |  | $operation,
 |  | $rid
 | ) |

Callback function for admin mass adding/deleting a user role.

Definition at line 3244 of file user.module.

References db_query(), user_load_multiple(), and user_save().

user_node_load | ( | $nodes,
 |  | $types
 | ) |

Implements hook_node_load().

Definition at line 3628 of file user.module.

References db_query().

user_page_title ( $account )

Menu item title callback - use the user name.

Definition at line 2015 of file user.module.

References format_username().

user_pass_rehash | ( | $password,
 |  | $timestamp,
 |  | $login
 | ) |

Creates a unique hash value for use in time-dependent per-user URLs.

This hash is normally used to build a unique and secure URL that is sent to the user by email for purposes such as resetting the user's password. In order to validate the URL, the same hash can be generated again, from the same information, and compared to the hash value from the URL. The URL normally contains both the time stamp and the numeric user ID. The login timestamp and hashed password are retrieved from the database as necessary. For a usage example, see user_cancel_url() and user_cancel_confirm().

Parameters
string | $password | The hashed user account password value.
int | $timestamp | A UNIX timestamp, typically REQUEST_TIME.
int | $login | The UNIX timestamp of the user's last login.
Returns
A string that is safe for use in URLs and SQL statements.

Definition at line 2378 of file user.module.

References drupal_get_hash_salt(), and drupal_hmac_base64().

Referenced by user_cancel_confirm(), user_cancel_url(), user_pass_reset(), and user_pass_reset_url().

user_pass_reset_url ( $account )

Generates a unique URL for a user to login and reset their password.

Parameters
object $account An object containing the user account, which must contain at least the following properties:
  • uid: The user ID number.
  • login: The UNIX timestamp of the user's last login.
Returns
A unique URL that provides a one-time log in for the user, from which they can change their password.

Definition at line 2330 of file user.module.

References REQUEST_TIME, url(), and user_pass_rehash().

Referenced by user_mail_tokens().

user_password ( $length = 10 )

Generate a random alphanumeric password.

Definition at line 705 of file user.module.

References drupal_random_bytes().

Referenced by DrupalWebTestCase::drupalCreateUser(), openid_form_user_register_form_alter(), user_external_login_register(), and user_register_submit().

user_permission ( )

Implements hook_permission().

Definition at line 848 of file user.module.

References t(), url(), and variable_get().

user_permission_get_modules ( )

Determine the modules that permissions belong to.

Returns
An associative array in the format $permission => $module.

Definition at line 3036 of file user.module.

References $module, $value, module_implements(), and module_invoke().

Referenced by user_role_grant_permissions().

user_preferred_language | ( | $account,
 |  | $default = NULL
 | ) |

Get the language object preferred by the user. This user preference can be set on the user account editing page, and is only available if there are more than one languages enabled on the site. If the user did not choose a preferred language, or is the anonymous user, the $default value, or if it is not set, the site default language will be returned.

Parameters
$account | User account to look up language for.
$default | Optional default language object to return if the account has no valid language.

Definition at line 3524 of file user.module.

References language_default(), and language_list().

Referenced by _update_cron_notify(), _user_mail_notify(), contact_personal_form_submit(), locale_language_selector_form(), and system_send_email_action().

user_rdf_mapping ( )

Implements hook_rdf_mapping().

Definition at line 3978 of file user.module.

References RDF_DEFAULT_BUNDLE.

user_register_access ( )

Determines if the current user has access to the user registration page.

Returns
bool TRUE if the user is not already logged in and can register for an account.

Definition at line 1554 of file user.module.

References user_is_anonymous(), USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, and variable_get().

user_register_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for the user registration form.

This function is shared by the installation form and the normal registration form, which is why it can't be in the user.pages.inc file.

See Also
user_register_form()

Definition at line 3837 of file user.module.

References $op, _user_mail_notify(), drupal_set_message(), entity_form_submit_build_entity(), entity_uri(), form_state_values_clean(), l(), t(), url(), user_login_submit(), user_password(), user_save(), variable_get(), watchdog(), and WATCHDOG_NOTICE.

user_register_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validation function for the user registration form.

Definition at line 3825 of file user.module.

References entity_form_field_validate().

user_role_change_permissions | ( |  | $rid,
 |  | array | $permissions = array()
 | ) |  |

Change permissions for a user role.

This function may be used to grant and revoke multiple permissions at once. For example, when a form exposes checkboxes to configure permissions for a role, the form submit handler may directly pass the submitted values for the checkboxes form element to this function.

Parameters
$rid The ID of a user role to alter.
$permissions An associative array, where the key holds the permission name and the value determines whether to grant or revoke that permission. Any value that evaluates to TRUE will cause the permission to be granted. Any value that evaluates to FALSE will cause the permission to be revoked.
* array(
* 'administer nodes' => 0, // Revoke 'administer nodes'
* 'administer blocks' => FALSE, // Revoke 'administer blocks'
* 'access user profiles' => 1, // Grant 'access user profiles'
* 'access content' => TRUE, // Grant 'access content'
* 'access comments' => 'access comments', // Grant 'access comments'
* )
*
Existing permissions are not changed, unless specified in $permissions.
See Also
user_role_grant_permissions()
user_role_revoke_permissions()

Definition at line 3076 of file user.module.

References user_role_grant_permissions(), and user_role_revoke_permissions().

Referenced by filter_admin_format_form_submit(), and user_admin_permissions_submit().

user_role_delete ( $role )

Delete a user role from database.

Parameters
$role A string with the role name, or an integer with the role ID.

Definition at line 2992 of file user.module.

References db_delete(), drupal_static_reset(), module_invoke_all(), user_role_load(), and user_role_load_by_name().

Referenced by user_admin_role_delete_confirm_submit().

user_role_edit_access ( $role )

Menu access callback for user role editing.

Definition at line 3021 of file user.module.

References DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID, and user_access().

user_role_grant_permissions | ( |  | $rid,
 |  | array | $permissions = array()
 | ) |  |

Grant permissions to a user role.

Parameters
$rid | The ID of a user role to alter.
$permissions | A list of permission names to grant.
See Also
user_role_change_permissions()
user_role_revoke_permissions()

Definition at line 3100 of file user.module.

References $name, db_merge(), drupal_static_reset(), and user_permission_get_modules().

Referenced by DrupalWebTestCase::drupalCreateRole(), minimal_install(), standard_install(), testing_install(), user_modules_installed(), and user_role_change_permissions().

user_role_load ( $rid )

Fetches a user role by role ID.

Parameters
$rid An integer representing the role ID.
Returns
A fully-loaded role object if a role with the given ID exists, or FALSE otherwise.
See Also
user_role_load_by_name()

Definition at line 2915 of file user.module.

References db_select().

Referenced by user_role_delete().

user_role_load_by_name ( $role_name )

Fetches a user role by role name.

Parameters
$role_name A string representing the role name.
Returns
A fully-loaded role object if a role with the given name exists, or FALSE otherwise.
See Also
user_role_load()

Definition at line 2935 of file user.module.

References db_select().

Referenced by user_admin_role_validate(), and user_role_delete().

user_role_permissions ( $roles = array() )

Determine the permissions for one or more roles.

Parameters
$roles An array whose keys are the role IDs of interest, such as $user->roles.
Returns
An array indexed by role ID. Each value is an array whose keys are the permission strings for the given role ID.

Definition at line 743 of file user.module.

References $name, $row, db_query(), and drupal_static().

Referenced by user_access(), and user_admin_permissions().

user_role_revoke_permissions | ( |  | $rid,
 |  | array | $permissions = array()
 | ) |  |

Revoke permissions from a user role.

Parameters
$rid | The ID of a user role to alter.
$permissions | A list of permission names to revoke.
See Also
user_role_change_permissions()
user_role_grant_permissions()

Definition at line 3131 of file user.module.

References db_delete(), and drupal_static_reset().

Referenced by user_role_change_permissions().

user_role_save ( $role )

Save a user role to the database.

Parameters
$role A role object to modify or add. If $role->rid is not specified, a new role will be created.
Returns
Status constant indicating if role was created or updated. Failure to write the user role record will return FALSE. Otherwise. SAVED_NEW or SAVED_UPDATED is returned depending on the operation performed.

Definition at line 2955 of file user.module.

References db_select(), drupal_static_reset(), drupal_write_record(), and module_invoke_all().

Referenced by DrupalWebTestCase::drupalCreateRole(), standard_install(), user_admin_role_submit(), and user_admin_roles_order_submit().

user_roles | ( | $membersonly = FALSE,
 |  | $permission = NULL
 | ) |

Retrieve an array of roles matching specified conditions.

Parameters
$membersonly | Set this to TRUE to exclude the 'anonymous' role.
$permission | A string containing a permission. If set, only roles containing that permission are returned.
Returns
An associative array with the role id as the key and the role name as value.

Definition at line 2871 of file user.module.

References db_select(), DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID, and t().

Referenced by block_admin_configure(), filter_admin_format_form(), filter_get_roles_by_format(), filter_update_7005(), filter_update_7008(), node_update_7008(), system_update_7067(), theme_comment_post_forbidden(), theme_user_admin_permissions(), user_account_form(), user_admin_account(), user_admin_permissions(), user_admin_roles(), user_admin_settings(), user_filters(), and user_user_operations().

user_save | ( | $account,
 |  | $edit = array(),
 |  | $category = 'account'
 | ) |

Save changes to a user account or add a new user.

Parameters
$account | (optional) The user object to modify or add. If you want to modify an existing user account, you will need to ensure that (a) $account is an object, and (b) you have set $account->uid to the numeric user ID of the user account you wish to modify. If you want to create a new user account, you can set $account->is_new to TRUE or omit the $account->uid field.
$edit | An array of fields and values to save. For example array('name' => 'My name'). Key / value pairs added to the $edit['data'] will be serialized and saved in the {users.data} column.
$category | (optional) The category for storing profile information in.
Returns
A fully-loaded $user object upon successful save or FALSE if the save failed.

Definition at line 424 of file user.module.

References $info, $op, $picture, $value, _user_mail_notify(), db_delete(), db_insert(), db_next_id(), db_query(), db_transaction(), DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID, DRUPAL_ROOT, drupal_session_destroy_uid(), drupal_session_regenerate(), drupal_write_record(), entity_get_controller(), entity_load_unchanged(), field_attach_insert(), field_attach_presave(), field_attach_update(), FILE_CREATE_DIRECTORY, file_default_scheme(), file_delete(), FILE_EXISTS_RENAME, file_move(), file_prepare_directory(), file_save(), FILE_STATUS_PERMANENT, file_stream_wrapper_uri_normalize(), file_usage_add(), file_usage_delete(), image_get_info(), module_invoke_all(), REQUEST_TIME, user_hash_password(), user_module_invoke(), variable_get(), and watchdog_exception().

Referenced by _user_cancel(), action_example_unblock_user_action(), DrupalWebTestCase::drupalCreateUser(), install_configure_form_submit(), overlay_user_dismiss_message(), user_authenticate(), user_block_user_action(), user_cancel_confirm_form_submit(), user_external_login_register(), user_multiple_role_edit(), user_profile_form_submit(), user_register_submit(), user_user_operations_block(), and user_user_operations_unblock().

user_search_access ( )

Implements hook_search_access().

Definition at line 926 of file user.module.

References user_access().

user_search_execute | ( | $keys = NULL,
 |  | $conditions = NULL
 | ) |

Implements hook_search_execute().

Definition at line 933 of file user.module.

References $results, db_like(), db_or(), db_select(), format_username(), url(), user_access(), and user_load_multiple().

user_search_info ( )

Implements hook_search_info().

Definition at line 917 of file user.module.

user_set_authmaps | ( | $account,
 |  | $authmaps
 | ) |

Save mappings of which external authentication module(s) authenticated a user. Maps external usernames to user ids in the users table.

Parameters
$account | A user object.
$authmaps | An associative array with a compound key and the username as the value. The key is made up of 'authname_' plus the name of the external authentication module.
See Also
user_external_login_register()

Definition at line 2044 of file user.module.

References $module, $value, db_delete(), and db_merge().

Referenced by openid_user_insert(), and user_external_login_register().

user_system_info_alter | ( | & | $info,
 |  |  | $file,
 |  |  | $type
 | ) |  |

Implements hook_system_info_alter().

Drupal 7 ships with two methods to add additional fields to users: Profile module, a legacy module dating back from 2002, and Field API integration with users. While Field API support for users currently provides less end user features, the inefficient data storage mechanism of Profile module, as well as its lack of consistency with the rest of the entity / field based systems in Drupal 7, make this a sub-optimal solution to those who were not using it in previous releases of Drupal.

To prevent new Drupal 7 sites from installing Profile module, and unwittingly ending up with two completely different and incompatible methods of extending users, only make the Profile module available if the profile_* tables are present.

Definition at line 4024 of file user.module.

References $info, and db_table_exists().

user_theme ( )

Implements hook_theme().

Definition at line 108 of file user.module.

user_translated_menu_link_alter ( & $link )

Implements hook_translated_menu_link_alter().

Definition at line 1902 of file user.module.

user_uid_only_optional_to_arg ( $arg )

Returns $arg or the user ID of the current user if $arg is '' or empty.

Deprecated. Use user_uid_optional instead.

Definition at line 1928 of file user.module.

References user_uid_optional_to_arg().

user_uid_optional_load ( $uid = NULL )

Load either a specified or the current user account.

Parameters
$uid An optional user ID of the user to load. If not provided, the current user's ID will be used.
Returns
A fully-loaded $user object upon successful user load, FALSE if user cannot be loaded.
See Also
user_load()

Definition at line 1945 of file user.module.

References user_load().

user_uid_optional_to_arg ( $arg )

Returns $arg or the user ID of the current user if $arg is '' or empty.

Definition at line 1995 of file user.module.

Referenced by user_uid_only_optional_to_arg().

user_uri ( $user )

Implements callback_entity_info_uri().

Definition at line 192 of file user.module.

user_user_categories ( )

Implements hook_user_categories().

Definition at line 1300 of file user.module.

References t().

user_user_operations | ( | $form = array(),
 |  | $form_state = array()
 | ) |

Implements hook_user_operations().

Definition at line 3146 of file user.module.

References $value, DRUPAL_AUTHENTICATED_RID, t(), user_access(), user_roles(), watchdog(), and WATCHDOG_WARNING.

user_user_operations_block ( $accounts )

Callback function for admin mass blocking users.

Definition at line 3228 of file user.module.

References user_load_multiple(), and user_save().

user_user_operations_unblock ( $accounts )

Callback function for admin mass unblocking users.

Definition at line 3215 of file user.module.

References user_load_multiple(), and user_save().

user_user_presave | ( | & | $edit,
 |  |  | $account,
 |  |  | $category
 | ) |  |

Implements hook_user_presave().

Definition at line 1274 of file user.module.

user_user_view ( $account )

Implements hook_user_view().

Definition at line 990 of file user.module.

References format_interval(), REQUEST_TIME, t(), and theme().

user_validate_current_pass | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Form validation handler for the current password on the user_account_form().

See Also
user_account_form()

Definition at line 1199 of file user.module.

References $name, DRUPAL_ROOT, form_set_error(), t(), user_check_password(), and variable_get().

user_validate_mail ( $mail )

Validates a user's email address.

Checks that a user's email address exists and follows all standard validation rules. Returns error messages when the address is invalid.

Parameters
$mail A user's email address.
Returns
If the address is invalid, a human-readable error message is returned. If the address is valid, nothing is returned.

Definition at line 670 of file user.module.

References t(), and valid_email_address().

Referenced by install_configure_form_validate(), system_site_information_settings_validate(), and user_account_form_validate().

user_validate_name ( $name )

Verify the syntax of the given name.

Definition at line 624 of file user.module.

References $name, drupal_strlen(), t(), and USERNAME_MAX_LENGTH.

Referenced by install_configure_form_validate(), and user_account_form_validate().

user_validate_picture | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Validates an image uploaded by a user.

See Also
user_account_form()

Definition at line 684 of file user.module.

References file_save_upload(), form_set_error(), t(), and variable_get().

user_view | ( | $account,
 |  | $view_mode = 'full',
 |  | $langcode = NULL
 | ) |

Generate an array for rendering the given user.

When viewing a user profile, the $page array contains:

  • $page['content']['Profile Category']: Profile categories keyed by their human-readable names.
  • $page['content']['Profile Category']['profile_machine_name']: Profile fields keyed by their machine-readable names.
  • $page['content']['user_picture']: User's rendered picture.
  • $page['content']['summary']: Contains the default "History" profile data for a user.
  • $page['content']['#account']: The user account of the profile being viewed.

To theme user profiles, copy modules/user/user-profile.tpl.php to your theme directory, and edit it as instructed in that file's comments.

Parameters
$account | A user object.
$view_mode | View mode, e.g. 'full'.
$langcode | (optional) A language code to use for rendering. Defaults to the global content language of the current request.
Returns
An array as expected by drupal_render().

Definition at line 2589 of file user.module.

References drupal_alter(), and user_build_content().

Referenced by user_view_page().

user_view_access ( $account )

User view access callback.

Parameters
$account Can either be a full user object or a $uid.

Definition at line 1564 of file user.module.

References user_access(), and user_load().

Referenced by _tracker_user_access(), and user_file_download_access().

user_view_page ( $account )

Page callback wrapper for user_view().

Definition at line 2553 of file user.module.

References MENU_NOT_FOUND, and user_view().

Variable Documentation

const EMAIL_MAX_LENGTH 254

Maximum length of user e-mail text field.

Definition at line 16 of file user.module.

Referenced by _install_configure_form(), user_account_form(), and user_pass().

const USER_REGISTER_ADMINISTRATORS_ONLY 0

Only administrators can create user accounts.

Definition at line 21 of file user.module.

Referenced by user_admin_settings().

const USER_REGISTER_VISITORS 1

Visitors can create their own accounts.

Definition at line 26 of file user.module.

Referenced by user_account_form(), user_admin_settings(), and user_update_7008().

const USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL 2

Visitors can create accounts, but they don't become active without administrative approval.

Definition at line 32 of file user.module.

Referenced by minimal_install(), openid_authentication(), standard_install(), testing_install(), theme_comment_post_forbidden(), user_account_form(), user_admin_settings(), user_login_block(), and user_register_access().

const USERNAME_MAX_LENGTH 60

Maximum length of username text field.

Definition at line 11 of file user.module.

Referenced by _install_configure_form(), user_account_form(), user_login(), user_login_block(), user_pass(), and user_validate_name().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user.pages.inc File Reference

  • modules
  • user
Functions
user.pages.inc File Reference

Go to the source code of this file.

Functions

user_autocomplete ($string= '')
user_pass ()
user_pass_validate ($form, &$form_state)
user_pass_submit ($form, &$form_state)
user_pass_reset ($form, &$form_state, $uid, $timestamp, $hashed_pass, $action=NULL)
user_logout ()
template_preprocess_user_profile (&$variables)
template_preprocess_user_profile_item (&$variables)
template_preprocess_user_profile_category (&$variables)
user_profile_form ($form, &$form_state, $account, $category= 'account')
user_profile_form_validate ($form, &$form_state)
user_profile_form_submit ($form, &$form_state)
user_edit_cancel_submit ($form, &$form_state)
user_cancel_confirm_form ($form, &$form_state, $account)
user_cancel_confirm_form_submit ($form, &$form_state)
user_cancel_methods ()
user_cancel_confirm ($account, $timestamp=0, $hashed_pass= '')
user_page ()

Detailed Description

User page callback file for the user module.

Definition in file user.pages.inc.

Function Documentation

template_preprocess_user_profile ( & $variables )

Process variables for user-profile.tpl.php.

The $variables array contains the following arguments:

  • $account
See Also
user-profile.tpl.php

Definition at line 191 of file user.pages.inc.

References element_children(), and field_attach_preprocess().

template_preprocess_user_profile_category ( & $variables )

Process variables for user-profile-category.tpl.php.

The $variables array contains the following arguments:

  • $element
See Also
user-profile-category.tpl.php

Definition at line 228 of file user.pages.inc.

References check_plain(), and drupal_attributes().

template_preprocess_user_profile_item ( & $variables )

Process variables for user-profile-item.tpl.php.

The $variables array contains the following arguments:

  • $element
See Also
user-profile-item.tpl.php

Definition at line 211 of file user.pages.inc.

References drupal_attributes().

user_autocomplete ( $string = '' )

Menu callback; Retrieve a JSON object containing autocomplete suggestions for existing users.

Definition at line 11 of file user.pages.inc.

References check_plain(), db_like(), db_select(), and drupal_json_output().

user_cancel_confirm | ( | $account,
 |  | $timestamp = 0,
 |  | $hashed_pass = ''
 | ) |

Menu callback; Cancel a user account via e-mail confirmation link.

See Also
user_cancel_confirm_form()
user_cancel_url()

Definition at line 515 of file user.pages.inc.

References batch_process(), drupal_goto(), drupal_set_message(), MENU_ACCESS_DENIED, REQUEST_TIME, t(), user_cancel(), user_pass_rehash(), and variable_get().

user_cancel_confirm_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit handler for the account cancellation confirm form.

See Also
user_cancel_confirm_form()
user_multiple_cancel_confirm_submit()

Definition at line 430 of file user.pages.inc.

References _user_mail_notify(), drupal_set_message(), t(), user_access(), user_cancel(), user_save(), watchdog(), and WATCHDOG_NOTICE.

Referenced by user_multiple_cancel_confirm_submit().

user_cancel_methods ( )

Helper function to return available account cancellation methods.

See documentation of hook_user_cancel_methods_alter().

Returns
An array containing all account cancellation methods as form elements.
See Also
hook_user_cancel_methods_alter()
user_admin_settings()
user_cancel_confirm_form()
user_multiple_cancel_confirm()

Definition at line 471 of file user.pages.inc.

References $name, drupal_alter(), t(), user_access(), and variable_get().

Referenced by user_admin_settings(), user_cancel_confirm_form(), and user_multiple_cancel_confirm().

user_edit_cancel_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for the 'Cancel account' button on the user edit form.

Definition at line 337 of file user.pages.inc.

References drupal_get_destination().

user_logout ( )

Menu callback; logs the current user out, and redirects to the home page.

Definition at line 170 of file user.pages.inc.

References drupal_goto(), module_invoke_all(), and watchdog().

Referenced by user_menu_site_status_alter().

user_page ( )

Page callback: Displays the user page.

Displays user profile if user is logged in, or login form for anonymous users.

Returns
A render array for either a user profile or a login form.
See Also
user_view_page()
user_login()

Definition at line 553 of file user.pages.inc.

References drupal_get_form(), menu_execute_active_handler(), and menu_set_active_item().

user_pass_reset | ( |  | $form,
 |  | & | $form_state,
 |  |  | $uid,
 |  |  | $timestamp,
 |  |  | $hashed_pass,
 |  |  | $action = NULL
 | ) |  |

Menu callback; process one time login link and redirects to the user page on success.

Definition at line 93 of file user.pages.inc.

References drupal_access_denied(), drupal_exit(), drupal_goto(), drupal_random_key(), drupal_set_message(), format_date(), REQUEST_TIME, t(), url(), user_load(), user_load_multiple(), user_login_finalize(), user_pass_rehash(), variable_get(), and watchdog().

user_pass_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 75 of file user.pages.inc.

References _user_mail_notify(), drupal_set_message(), t(), and watchdog().

user_pass_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Definition at line 57 of file user.pages.inc.

References $name, form_set_error(), form_set_value(), t(), and user_load_multiple().

user_profile_form_submit | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Submit function for the user account and profile editing form.

Definition at line 303 of file user.pages.inc.

References cache_clear_all(), drupal_set_message(), entity_form_submit_build_entity(), form_state_values_clean(), t(), and user_save().

user_profile_form_validate | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Validation function for the user account and profile editing form.

Definition at line 296 of file user.pages.inc.

References entity_form_field_validate().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user.tokens.inc File Reference

  • modules
  • user
Functions
user.tokens.inc File Reference

Go to the source code of this file.

Functions

user_token_info ()
user_tokens ($type, $tokens, array $data=array(), array $options=array())

Detailed Description

Builds placeholder replacement tokens for user-related data.

Definition in file user.tokens.inc.

Function Documentation

user_token_info ( )

Implements hook_token_info().

Definition at line 11 of file user.tokens.inc.

References t().

user_tokens | ( |  | $type,
 |  |  | $tokens,
 |  | array | $data = array(),
 |  | array | $options = array()
 | ) |  |

Implements hook_tokens().

Definition at line 64 of file user.tokens.inc.

References $name, check_plain(), format_date(), format_username(), t(), token_find_with_prefix(), token_generate(), url(), and user_load().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles Directory Reference

  • profiles
profiles Directory Reference

Directories

directory | minimal
directory | standard
directory | testing
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/minimal Directory Reference

  • profiles
  • minimal
minimal Directory Reference

Files

file | minimal.install [code]
file | minimal.profile [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/minimal/minimal.install File Reference

  • profiles
  • minimal
Functions
minimal.install File Reference

Go to the source code of this file.

Functions

minimal_install ()

Detailed Description

Install, update and uninstall functions for the minimal installation profile.

Definition in file minimal.install.

Function Documentation

minimal_install ( )

Implements hook_install().

Performs actions to set up the site for this profile.

See Also
system_install()

Definition at line 14 of file minimal.install.

References db_insert(), DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID, USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, user_role_grant_permissions(), variable_get(), and variable_set().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/minimal/minimal.profile File Reference

  • profiles
  • minimal
Functions
minimal.profile File Reference

Go to the source code of this file.

Functions

minimal_form_install_configure_form_alter (&$form, $form_state)

Detailed Description

Enables modules and site configuration for a minimal site installation.

Definition in file minimal.profile.

Function Documentation

minimal_form_install_configure_form_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter() for install_configure_form().

Allows the profile to alter the site configuration form.

Definition at line 12 of file minimal.profile.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/standard Directory Reference

  • profiles
  • standard
standard Directory Reference

Files

file | standard.install [code]
file | standard.profile [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/standard/standard.install File Reference

  • profiles
  • standard
Functions
standard.install File Reference

Go to the source code of this file.

Functions

standard_install ()

Detailed Description

Install, update and uninstall functions for the standard installation profile.

Definition in file standard.install.

Function Documentation

standard_install ( )

Implements hook_install().

Perform actions to set up the site for this profile.

See Also
system_install()

Definition at line 14 of file standard.install.

References $help, COMMENT_NODE_HIDDEN, db_insert(), db_update(), DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID, FIELD_CARDINALITY_UNLIMITED, field_create_field(), field_create_instance(), filter_format_save(), filter_permission_name(), menu_link_save(), menu_rebuild(), module_invoke_all(), node_add_body_field(), node_type_save(), node_type_set_defaults(), rdf_mapping_save(), st(), taxonomy_vocabulary_save(), USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, user_role_grant_permissions(), user_role_save(), variable_get(), and variable_set().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/standard/standard.profile File Reference

  • profiles
  • standard
Functions
standard.profile File Reference

Go to the source code of this file.

Functions

standard_form_install_configure_form_alter (&$form, $form_state)

Detailed Description

Enables modules and site configuration for a standard site installation.

Definition in file standard.profile.

Function Documentation

standard_form_install_configure_form_alter | ( | & | $form,
 |  |  | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter() for install_configure_form().

Allows the profile to alter the site configuration form.

Definition at line 12 of file standard.profile.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/testing Directory Reference

  • profiles
  • testing
testing Directory Reference

Directories

directory modules

Files

file | testing.install [code]
file | testing.profile [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/testing/modules Directory Reference

  • profiles
  • testing
  • modules
modules Directory Reference

Directories

directory | drupal_system_listing_compatible_test
directory | drupal_system_listing_incompatible_test
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/testing/modules/drupal_system_listing_compatible_test Directory Reference

  • profiles
  • testing
  • modules
  • drupal_system_listing_compatible_test
drupal_system_listing_compatible_test Directory Reference

Files

file drupal_system_listing_compatible_test.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module File Reference

  • profiles
  • testing
  • modules
  • drupal_system_listing_compatible_test
drupal_system_listing_compatible_test.module File Reference

Go to the source code of this file.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/testing/modules/drupal_system_listing_incompatible_test Directory Reference

  • profiles
  • testing
  • modules
  • drupal_system_listing_incompatible_test
drupal_system_listing_incompatible_test Directory Reference

Files

file drupal_system_listing_incompatible_test.module [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module File Reference

  • profiles
  • testing
  • modules
  • drupal_system_listing_incompatible_test
drupal_system_listing_incompatible_test.module File Reference

Go to the source code of this file.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/testing/testing.install File Reference

  • profiles
  • testing
Functions
testing.install File Reference

Go to the source code of this file.

Functions

testing_install ()

Detailed Description

Install, update and uninstall functions for the testing profile.

Definition in file testing.install.

Function Documentation

testing_install ( )

Implements hook_install().

Perform actions to set up the site for this profile.

See Also
system_install()

Definition at line 14 of file testing.install.

References DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID, USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, user_role_grant_permissions(), and variable_set().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/testing/testing.profile File Reference

  • profiles
  • testing
testing.profile File Reference

Go to the source code of this file.

Detailed Description

Installation profile for tests.

Definition in file testing.profile.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: sites Directory Reference

  • sites
sites Directory Reference

Directories

directory default

Files

file example.sites.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: sites/default Directory Reference

  • sites
  • default
default Directory Reference

Files

file default.settings.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: sites/default/default.settings.php File Reference

  • sites
  • default
Variables
default.settings.php File Reference

Go to the source code of this file.

Variables

$databases = array()
$update_free_access = FALSE
$drupal_hash_salt = ''
$conf ['404_fast_paths_exclude'] = '/\/(?:styles)\//'
$conf ['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'
$conf ['404_fast_html'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>'

Detailed Description

Drupal site-specific configuration file.

IMPORTANT NOTE: This file may have been set to read-only by the Drupal installation program. If you make changes to this file, be sure to protect it again after making your modifications. Failure to remove write permissions to this file is a security risk.

The configuration file to be loaded is based upon the rules below. However if the multisite aliasing file named sites/sites.php is present, it will be loaded, and the aliases in the array $sites will override the default directory rules below. See sites/example.sites.php for more information about aliases.

The configuration directory will be discovered by stripping the website's hostname from left to right and pathname from right to left. The first configuration file found will be used and any others will be ignored. If no other configuration file is found then the default configuration file at 'sites/default' will be used.

For example, for a fictitious site installed at http://www.drupal.org:8080/mysite/test/, the 'settings.php' file is searched for in the following directories:

  • sites/8080.www.drupal.org.mysite.test
  • sites/www.drupal.org.mysite.test
  • sites/drupal.org.mysite.test
  • sites/org.mysite.test
  • sites/8080.www.drupal.org.mysite
  • sites/www.drupal.org.mysite
  • sites/drupal.org.mysite
  • sites/org.mysite
  • sites/8080.www.drupal.org
  • sites/www.drupal.org
  • sites/drupal.org
  • sites/org
  • sites/default

Note that if you are installing on a non-standard port number, prefix the hostname with that number. For example, http://www.drupal.org:8080/mysite/test/ could be loaded from sites/8080.www.drupal.org.mysite.test/.

See Also
example.sites.php
conf_path()

Definition in file default.settings.php.

Variable Documentation

$conf['404_fast_paths_exclude'] = '/\/(?:styles)\//'

If you encounter a situation where users post a large amount of text, and the result is stripped out upon viewing but can still be edited, Drupal's output filter may not have sufficient memory to process it. If you experience this issue, you may wish to uncomment the following two lines and increase the limits of these variables. For more information, see http://php.net/manual/pcre.configuration.php. Drupal automatically generates a unique session cookie name for each site based on its full domain name. If you have multiple domains pointing at the same Drupal site, you can either redirect them all to a single domain (see comment in .htaccess), or uncomment the line below and specify their shared base domain. Doing so assures that users remain logged in as they cross between your various domains. Make sure to always start the $cookie_domain with a leading dot, as per RFC 2109. Variable overrides:

To override specific entries in the 'variable' table for this site, set them here. You usually don't need to use this feature. This is useful in a configuration file for a vhost or directory, rather than the default settings.php. Any configuration setting from the 'variable' table can be given a new value. Note that any values you provide in these variable overrides will not be modifiable from the Drupal administration interface.

The following overrides are examples:

  • site_name: Defines the site's name.
  • theme_default: Defines the default theme for this site.
  • anonymous: Defines the human-readable name of anonymous users. Remove the leading hash signs to enable. A custom theme can be set for the offline page. This applies when the site is explicitly set to maintenance mode through the administration page or when the database is inactive due to an error. It can be set through the 'maintenance_theme' key. The template file should also be copied into the theme. It is located inside 'modules/system/maintenance-page.tpl.php'. Note: This setting does not apply to installation and update pages. Reverse Proxy Configuration:

Reverse proxy servers are often used to enhance the performance of heavily visited sites and may also provide other site caching, security, or encryption benefits. In an environment where Drupal is behind a reverse proxy, the real IP address of the client should be determined such that the correct client IP address is available to Drupal's logging, statistics, and access management systems. In the most simple scenario, the proxy server will add an X-Forwarded-For header to the request that contains the client IP address. However, HTTP headers are vulnerable to spoofing, where a malicious client could bypass restrictions by setting the X-Forwarded-For header directly. Therefore, Drupal's proxy configuration requires the IP addresses of all remote proxies to be specified in $conf['reverse_proxy_addresses'] to work correctly.

Enable this setting to get Drupal to determine the client IP from the X-Forwarded-For header (or $conf['reverse_proxy_header'] if set). If you are unsure about this setting, do not have a reverse proxy, or Drupal operates in a shared hosting environment, this setting should remain commented out.

In order for this setting to be used you must specify every possible reverse proxy IP address in $conf['reverse_proxy_addresses']. If a complete list of reverse proxies is not available in your environment (for example, if you use a CDN) you may set the $_SERVER['REMOTE_ADDR'] variable directly in settings.php. Be aware, however, that it is likely that this would allow IP address spoofing unless more advanced precautions are taken. Specify every reverse proxy IP address in your environment. This setting is required if $conf['reverse_proxy'] is TRUE. Set this value if your proxy server sends the client IP in a header other than X-Forwarded-For. Page caching:

By default, Drupal sends a "Vary: Cookie" HTTP header for anonymous page views. This tells a HTTP proxy that it may return a page from its local cache without contacting the web server, if the user sends the same Cookie header as the user who originally requested the cached page. Without "Vary: Cookie", authenticated users would also be served the anonymous page from the cache. If the site has mostly anonymous users except a few known editors/administrators, the Vary header can be omitted. This allows for better caching in HTTP proxies (including reverse proxies), i.e. even if clients send different cookies, they still get content served from the cache. However, authenticated users should access the site directly (i.e. not use an HTTP proxy, and bypass the reverse proxy if one is used) in order to avoid getting cached pages from the proxy. CSS/JS aggregated file gzip compression:

By default, when CSS or JS aggregation and clean URLs are enabled Drupal will store a gzip compressed (.gz) copy of the aggregated files. If this file is available then rewrite rules in the default .htaccess file will serve these files to browsers that accept gzip encoded content. This allows pages to load faster for these users and has minimal impact on server load. If you are using a webserver other than Apache httpd, or a caching reverse proxy that is configured to cache and compress these files itself you may want to uncomment one or both of the below lines, which will prevent gzip files being stored. String overrides:

To override specific strings on your site with or without enabling the Locale module, add an entry to this list. This functionality allows you to change a small number of your site's default English language interface strings.

Remove the leading hash signs to enable.

IP blocking:

To bypass database queries for denied IP addresses, use this setting. Drupal queries the {blocked_ips} table by default on every page request for both authenticated and anonymous users. This allows the system to block IP addresses from within the administrative interface and before any modules are loaded. However on high traffic websites you may want to avoid this query, allowing you to bypass database access altogether for anonymous users under certain caching configurations.

If using this setting, you will need to add back any IP addresses which you may have blocked via the administrative interface. Each element of this array represents a blocked IP address. Uncommenting the array and leaving it empty will have the effect of disabling IP blocking on your site.

Remove the leading hash signs to enable. Fast 404 pages:

Drupal can generate fully themed 404 pages. However, some of these responses are for images or other resource files that are not displayed to the user. This can waste bandwidth, and also generate server load.

The options below return a simple, fast 404 page for URLs matching a specific pattern:

  • 404_fast_paths_exclude: A regular expression to match paths to exclude, such as images generated by image styles, or dynamically-resized images. If you need to add more paths, you can add '|path' to the expression.
  • 404_fast_paths: A regular expression to match paths that should return a simple 404 page, rather than the fully themed 404 page. If you don't have any aliases ending in htm or html you can add '|s?html?' to the expression.
  • 404_fast_html: The html to return for simple 404 pages.

Add leading hash signs if you would like to disable this functionality.

Definition at line 491 of file default.settings.php.

$conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'

Definition at line 492 of file default.settings.php.

$conf['404_fast_html'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>'

Definition at line 493 of file default.settings.php.

$databases = array()

Database settings:

The $databases array specifies the database connection or connections that Drupal may use. Drupal is able to connect to multiple databases, including multiple types of databases, during the same request.

Each database connection is specified as an array of settings, similar to the following:

* array(
* 'driver' => 'mysql',
* 'database' => 'databasename',
* 'username' => 'username',
* 'password' => 'password',
* 'host' => 'localhost',
* 'port' => 3306,
* 'prefix' => 'myprefix_',
* 'collation' => 'utf8_general_ci',
* );
*

The "driver" property indicates what Drupal database driver the connection should use. This is usually the same as the name of the database type, such as mysql or sqlite, but not always. The other properties will vary depending on the driver. For SQLite, you must specify a database file name in a directory that is writable by the webserver. For most other drivers, you must specify a username, password, host, and database name.

Some database engines support transactions. In order to enable transaction support for a given database, set the 'transactions' key to TRUE. To disable it, set it to FALSE. Note that the default value varies by driver. For MySQL, the default is FALSE since MyISAM tables do not support transactions.

For each database, you may optionally specify multiple "target" databases. A target database allows Drupal to try to send certain queries to a different database if it can but fall back to the default connection if not. That is useful for master/slave replication, as Drupal may try to connect to a slave server when appropriate and if one is not available will simply fall back to the single master server.

The general format for the $databases array is as follows:

* $databases['default']['default'] = $info_array;
* $databases['default']['slave'][] = $info_array;
* $databases['default']['slave'][] = $info_array;
* $databases['extra']['default'] = $info_array;
*

In the above example, $info_array is an array of settings described above. The first line sets a "default" database that has one master database (the second level default). The second and third lines create an array of potential slave databases. Drupal will select one at random for a given request as needed. The fourth line creates a new database with a name of "extra".

For a single database configuration, the following is sufficient:

* $databases['default']['default'] = array(
* 'driver' => 'mysql',
* 'database' => 'databasename',
* 'username' => 'username',
* 'password' => 'password',
* 'host' => 'localhost',
* 'prefix' => 'main_',
* 'collation' => 'utf8_general_ci',
* );
*

You can optionally set prefixes for some or all database table names by using the 'prefix' setting. If a prefix is specified, the table name will be prepended with its value. Be sure to use valid database characters only, usually alphanumeric and underscore. If no prefixes are desired, leave it as an empty string ''.

To have all database names prefixed, set 'prefix' as a string:

* 'prefix' => 'main_',
*

To provide prefixes for specific tables, set 'prefix' as an array. The array's keys are the table names and the values are the prefixes. The 'default' element is mandatory and holds the prefix for any tables not specified elsewhere in the array. Example:

* 'prefix' => array(
* 'default' => 'main_',
* 'users' => 'shared_',
* 'sessions' => 'shared_',
* 'role' => 'shared_',
* 'authmap' => 'shared_',
* ),
*

You can also use a reference to a schema/database as a prefix. This may be useful if your Drupal installation exists in a schema that is not the default or you want to access several databases from the same code base at the same time. Example:

* 'prefix' => array(
* 'default' => 'main.',
* 'users' => 'shared.',
* 'sessions' => 'shared.',
* 'role' => 'shared.',
* 'authmap' => 'shared.',
* );
*

NOTE: MySQL and SQLite's definition of a schema is a database.

Advanced users can add or override initial commands to execute when connecting to the database server, as well as PDO connection settings. For example, to enable MySQL SELECT queries to exceed the max_join_size system variable, and to reduce the database connection timeout to 5 seconds:

* $databases['default']['default'] = array(
* 'init_commands' => array(
* 'big_selects' => 'SET SQL_BIG_SELECTS=1',
* ),
* 'pdo' => array(
* PDO::ATTR_TIMEOUT => 5,
* ),
* );
*

WARNING: These defaults are designed for database portability. Changing them may cause unexpected behavior, including potential data loss.

See Also
DatabaseConnection_mysql::__construct
DatabaseConnection_pgsql::__construct
DatabaseConnection_sqlite::__construct

Database configuration format:

* $databases['default']['default'] = array(
* 'driver' => 'mysql',
* 'database' => 'databasename',
* 'username' => 'username',
* 'password' => 'password',
* 'host' => 'localhost',
* 'prefix' => '',
* );
* $databases['default']['default'] = array(
* 'driver' => 'pgsql',
* 'database' => 'databasename',
* 'username' => 'username',
* 'password' => 'password',
* 'host' => 'localhost',
* 'prefix' => '',
* );
* $databases['default']['default'] = array(
* 'driver' => 'sqlite',
* 'database' => '/path/to/databasefilename',
* );
*

Definition at line 213 of file default.settings.php.

Referenced by drupal_detect_database_types(), drupal_get_database_types(), drupal_get_hash_salt(), drupal_settings_initialize(), install_database_errors(), install_settings_form(), install_verify_settings(), Database\parseConnectionInfo(), update_fix_d7_requirements(), update_parse_db_url(), and update_prepare_d7_bootstrap().

$drupal_hash_salt = ''

Salt for one-time login links and cancel links, form tokens, etc.

This variable will be set to a random value by the installer. All one-time login links will be invalidated if the value is changed. Note that if your site is deployed on a cluster of web servers, you must ensure that this variable has the same value on each server. If this variable is empty, a hash of the serialized database credentials will be used as a fallback salt.

For enhanced security, you may set this variable to a value using the contents of a file outside your docroot that is never saved together with any backups of your Drupal files and database.

Example: $drupal_hash_salt = file_get_contents('/home/example/salt.txt');

Definition at line 245 of file default.settings.php.

Referenced by drupal_get_hash_salt(), and drupal_settings_initialize().

$update_free_access = FALSE

Access control for update.php script.

If you are updating your Drupal installation using the update.php script but are not logged in using either an account with the "Administer software updates" permission or the site maintenance account (the account that was created during installation), you will need to modify the access check statement below. Change the FALSE to a TRUE to disable the access check. After finishing the upgrade, be sure to open this file again and change the TRUE back to a FALSE!

Definition at line 226 of file default.settings.php.

Referenced by drupal_settings_initialize(), and update_access_allowed().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: sites/example.sites.php File Reference

  • sites
example.sites.php File Reference

Go to the source code of this file.

Detailed Description

Configuration file for Drupal's multi-site directory aliasing feature.

This file allows you to define a set of aliases that map hostnames, ports, and pathnames to configuration directories in the sites directory. These aliases are loaded prior to scanning for directories, and they are exempt from the normal discovery rules. See default.settings.php to view how Drupal discovers the configuration directory when no alias is found.

Aliases are useful on development servers, where the domain name may not be the same as the domain of the live server. Since Drupal stores file paths in the database (files, system table, etc.) this will ensure the paths are correct when the site is deployed to a live server.

To use this file, copy and rename it such that its path plus filename is 'sites/sites.php'. If you don't need to use multi-site directory aliasing, then you can safely ignore this file, and Drupal will ignore it too.

Aliases are defined in an associative array named $sites. The array is written in the format: '<port>.<domain>.<path>' => 'directory'. As an example, to map http://www.drupal.org:8080/mysite/test to the configuration directory sites/example.com, the array should be defined as:

* $sites = array(
* '8080.www.drupal.org.mysite.test' => 'example.com',
* );
*

The URL, http://www.drupal.org:8080/mysite/test/, could be a symbolic link or an Apache Alias directive that points to the Drupal root containing index.php. An alias could also be created for a subdomain. See the online Drupal installation guide for more information on setting up domains, subdomains, and subdirectories.

The following examples look for a site configuration in sites/example.com:

* URL: http://dev.drupal.org
* $sites['dev.drupal.org'] = 'example.com';
*
* URL: http://localhost/example
* $sites['localhost.example'] = 'example.com';
*
* URL: http://localhost:8080/example
* $sites['8080.localhost.example'] = 'example.com';
*
* URL: http://www.drupal.org:8080/mysite/test/
* $sites['8080.www.drupal.org.mysite.test'] = 'example.com';
*
See Also
default.settings.php
conf_path()
http://drupal.org/documentation/install/multi-site

Definition in file example.sites.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes Directory Reference

  • themes
themes Directory Reference

Directories

directory | bartik
directory | engines
directory | garland
directory | seven
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik Directory Reference

  • themes
  • bartik
bartik Directory Reference

Directories

directory | color
directory | templates

Files

file template.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/color Directory Reference

  • themes
  • bartik
  • color
color Directory Reference

Files

file color.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/color/color.inc File Reference

  • themes
  • bartik
  • color
Variables
color.inc File Reference

Go to the source code of this file.

Variables

$info

Variable Documentation

$info

Definition at line 6 of file color.inc.

Referenced by _color_render_images(), _color_rewrite_stylesheet(), _comment_body_field_create(), _field_info_collate_fields(), _field_info_collate_types(), _image_update_7002_populate_dimensions(), _locale_languages_configure_form_language_table(), _node_types_build(), _search_get_module_names(), _simpletest_batch_operation(), _system_info_add_path(), _system_modules_build_row(), _theme_build_registry(), _theme_process_registry(), _trigger_comment(), _trigger_example_first_time_login(), _trigger_node(), _trigger_tab_information(), _trigger_user(), Database\addConnectionInfo(), aggregator_admin_form(), aggregator_form_aggregator_admin_form_alter(), block_admin_configure(), book_entity_info_alter(), DatabaseSchema_mysql\buildTableNameCondition(), DatabaseSchema\buildTableNameCondition(), color_get_info(), color_get_palette(), color_requirements(), color_scheme_form(), color_scheme_form_submit(), comment_modules_enabled(), comment_node_type_delete(), comment_node_type_insert(), comment_node_type_update(), DatabaseSchema_sqlite\createIndexSql(), DatabaseSchema_mysql\createTableSql(), dashboard_system_info_alter(), DatabaseSchema_sqlite\dropIndex(), DatabaseSchema_sqlite\dropUniqueKey(), drupal_build_js_cache(), drupal_check_profile(), drupal_cron_run(), drupal_find_theme_functions(), drupal_find_theme_templates(), drupal_get_filetransfer_info(), drupal_http_request(), drupal_install_profile_distribution_name(), drupal_parse_info_file(), drupal_parse_info_format(), drupal_required_modules(), drupal_system_listing(), drupal_verify_profile(), drupal_write_record(), element_info(), element_info_property(), entity_create_stub_entity(), entity_example_entity_info(), entity_extract_ids(), entity_form_submit_build_entity(), entity_label(), entity_language(), entity_uri(), field_attach_load(), field_behaviors_widget(), field_create_field(), field_default_view(), field_extract_bundle(), field_help(), field_info_bundles(), field_info_extra_fields(), field_info_field_settings(), field_info_field_types(), field_info_fields(), field_info_formatter_settings(), field_info_formatter_types(), field_info_instance(), field_info_instance_settings(), field_info_storage_settings(), field_info_storage_types(), field_info_widget_settings(), field_info_widget_types(), field_system_info_alter(), field_ui_existing_field_options(), field_ui_field_overview_form(), file_get_stream_wrappers(), file_validate_image_resolution(), file_validate_is_image(), filter_get_filters(), DatabaseSchema_sqlite\findTables(), form_builder(), forum_entity_info_alter(), FieldInfo\getBundleExtraFields(), FieldInfo\getBundleInstances(), DatabaseSchema_mysql\getPrefixInfo(), DatabaseSchema\getPrefixInfo(), Updater\getProjectTitle(), help_page(), hook_archiver_info_alter(), hook_entity_delete(), hook_entity_insert(), hook_entity_update(), hook_field_attach_rename_bundle(), hook_field_extra_fields_alter(), hook_field_formatter_info_alter(), hook_field_info_alter(), hook_field_storage_info_alter(), hook_field_widget_info_alter(), hook_file_download(), hook_filetransfer_info(), hook_filter_info_alter(), hook_node_type_delete(), hook_node_type_insert(), hook_node_type_update(), hook_system_info_alter(), image_field_presave(), image_field_widget_process(), image_file_download(), image_get_available_toolkits(), image_requirements(), DatabaseSchema_sqlite\indexExists(), install_profile_info(), DatabaseSchema_sqlite\introspectSchema(), language_types_configurable(), language_types_set(), list_field_widget_info_alter(), locale_block_info(), locale_date_format_language_overview_page(), locale_update_7002(), node_list_permissions(), node_node_type_insert(), node_node_type_update(), node_permissions_get_configured_types(), node_type_delete(), node_type_reset(), node_type_save(), node_type_set_defaults(), overlay_system_info_alter(), Database\parseConnectionInfo(), DatabaseSchema\prefixNonTable(), DatabaseSchema_sqlite\renameTable(), DatabaseSchema_mysql\renameTable(), search_view(), shortcut_set_delete_form(), simpletest_result_form(), simpletest_run_tests(), simpletest_test_form(), simpletest_test_get_all(), system_add_module_assets(), system_admin_index(), system_date_format_save(), system_date_format_type_save(), system_file_system_settings(), system_get_info(), system_get_module_admin_tasks(), system_modules_confirm_form(), system_modules_uninstall_confirm_form(), system_region_list(), system_requirements(), system_system_info_alter(), DatabaseSchema_sqlite\tableExists(), taxonomy_field_extra_fields(), taxonomy_field_widget_info_alter(), template_preprocess_search_result(), theme(), theme_color_scheme_form(), theme_locale_languages_configure_form(), theme_trigger_display(), token_example_entity_info_alter(), token_example_example_form(), token_example_token_info(), toolbar_system_info_alter(), trigger_assign_form(), update_filter_project_info(), update_fix_d7_install_profile(), update_process_project_info(), update_verify_update_archive(), user_field_info_alter(), user_file_download(), user_save(), and user_system_info_alter().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/templates Directory Reference

  • themes
  • bartik
  • templates
templates Directory Reference

Files

file | comment-wrapper.tpl.php [code]
file | comment.tpl.php [code]
file | maintenance-page.tpl.php [code]
file | node.tpl.php [code]
file | page.tpl.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/templates/comment-wrapper.tpl.php File Reference

  • themes
  • bartik
  • templates
Variables
comment-wrapper.tpl.php File Reference

Go to the source code of this file.

Variables

print $classes
print $attributes
endif

Detailed Description

Bartik's theme implementation to provide an HTML container for comments.

Available variables:

  • $content: The array of content-related elements for the node. Use render($content) to print them all, or print a subset such as render($content['comment_form']).
  • $classes: String of classes that can be used to style contextually through CSS. It can be manipulated through the variable $classes_array from preprocess functions. The default value has the following:
    • comment-wrapper: The current template type, i.e., "theming hook".
  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template.

The following variables are provided for contextual information.

  • $node: Node object the comments are attached to. The constants below the variables show the possible values and should be used for comparison.
  • $display_mode
    • COMMENT_MODE_FLAT
    • COMMENT_MODE_THREADED

Other variables:

  • $classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes.
See Also
template_preprocess_comment_wrapper()

Definition in file comment-wrapper.tpl.php.

Variable Documentation

print $attributes

Definition at line 37 of file comment-wrapper.tpl.php.

print $classes

Definition at line 37 of file comment-wrapper.tpl.php.

endif

Definition at line 42 of file comment-wrapper.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/templates/comment.tpl.php File Reference

  • themes
  • bartik
  • templates
Variables
comment.tpl.php File Reference

Go to the source code of this file.

Variables

print $classes
print $attributes
print $picture
print $author
print $created
print $permalink
if($new) endif
print $title_attributes
print $title
print $content_attributes

Detailed Description

Bartik's theme implementation for comments.

Available variables:

  • $author: Comment author. Can be link or plain text.
  • content:
    An array of comment items. Use render(
    content) to print them all, or print a subset such as render($content['field_example']). Use hide($content['field_example']) to temporarily suppress the printing of a given element.
  • $created: Formatted date and time for when the comment was created. Preprocess functions can reformat it by calling format_date() with the desired parameters on the $comment->created variable.
  • $changed: Formatted date and time for when the comment was last changed. Preprocess functions can reformat it by calling format_date() with the desired parameters on the $comment->changed variable.
  • $new: New comment marker.
  • $permalink: Comment permalink.
  • submitted:
    Submission information created from
    author and $created during template_preprocess_comment().
  • $picture: Authors picture.
  • $signature: Authors signature.
  • $status: Comment status. Possible values are: comment-unpublished, comment-published or comment-preview.
  • $title: Linked title.
  • $classes: String of classes that can be used to style contextually through CSS. It can be manipulated through the variable $classes_array from preprocess functions. The default values can be one or more of the following:
    • comment: The current template type, i.e., "theming hook".
    • comment-by-anonymous: Comment by an unregistered user.
    • comment-by-node-author: Comment by the author of the parent node.
    • comment-preview: When previewing a new or edited comment. The following applies only to viewers who are registered users:
    • comment-unpublished: An unpublished comment visible only to administrators.
    • comment-by-viewer: Comment by the user currently viewing the page.
    • comment-new: New comment since last the visit.
  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template.

These two variables are provided for context:

  • $comment: Full comment object.
  • $node: Node object the comments are attached to.

Other variables:

  • $classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes.
See Also
template_preprocess()
template_preprocess_comment()
template_process()
theme_comment()

Definition in file comment.tpl.php.

Variable Documentation

print $attributes

Definition at line 60 of file comment.tpl.php.

print $author

Definition at line 68 of file comment.tpl.php.

Referenced by ajax_example_node_by_author_autocomplete(), ajax_example_node_by_author_autocomplete_validate(), comment_form(), hook_tokens(), and node_tokens().

print $classes

Definition at line 60 of file comment.tpl.php.

print $content_attributes

Definition at line 90 of file comment.tpl.php.

print $created

Definition at line 71 of file comment.tpl.php.

print $permalink

Definition at line 74 of file comment.tpl.php.

print $picture

Definition at line 64 of file comment.tpl.php.

Referenced by user_save().

print $title

Definition at line 87 of file comment.tpl.php.

print $title_attributes

Definition at line 87 of file comment.tpl.php.

if ($signature) endif

Definition at line 82 of file comment.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/templates/maintenance-page.tpl.php File Reference

  • themes
  • bartik
  • templates
Variables
maintenance-page.tpl.php File Reference

Go to the source code of this file.

Variables

print $language language
print $language dir
print $head
print $head_title
print $styles
print $scripts
print $classes
print $attributes
if($site_name||$site_slogan)($hide_site_name
&&$hide_site_slogan) if($site_name)($hide_site_name)
print 		$front_page
print $site_name
endif
if($site_slogan)($hide_site_slogan)
print 		$site_slogan
print $content

Detailed Description

Implementation to display a single Drupal page while offline.

All the available variables are mirrored in page.tpl.php.

See Also
template_preprocess()
template_preprocess_maintenance_page()
bartik_process_maintenance_page()

Definition in file maintenance-page.tpl.php.

Variable Documentation

print $attributes

Definition at line 23 of file maintenance-page.tpl.php.

print $classes

Definition at line 23 of file maintenance-page.tpl.php.

print $content

Definition at line 54 of file maintenance-page.tpl.php.

print $front_page

Definition at line 34 of file maintenance-page.tpl.php.

print $head

Definition at line 18 of file maintenance-page.tpl.php.

print $head_title

Definition at line 19 of file maintenance-page.tpl.php.

print $scripts

Definition at line 21 of file maintenance-page.tpl.php.

print $site_name

Definition at line 37 of file maintenance-page.tpl.php.

if ($site_slogan) ($hide_site_slogan) print $site_slogan

Definition at line 41 of file maintenance-page.tpl.php.

print $styles

Definition at line 20 of file maintenance-page.tpl.php.

print $language dir

Definition at line 16 of file maintenance-page.tpl.php.

if ($messages) endif

Definition at line 40 of file maintenance-page.tpl.php.

print $language language

Definition at line 16 of file maintenance-page.tpl.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/templates/node.tpl.php File Reference

  • themes
  • bartik
  • templates
Variables
node.tpl.php File Reference

Go to the source code of this file.

Variables

print $node | nid
print $classes
print $attributes
if(!$page) print | $node_url
print $title
endif
if($display_submitted) print | $submitted
print $content_attributes
if($teaser||!empty($content['comments']['comment_form'])) | $links = render($content['links'])

Detailed Description

Bartik's theme implementation to display a node.

Available variables:

  • $title: the (sanitized) title of the node.
  • content:
    An array of node items. Use render(
    content) to print them all, or print a subset such as render($content['field_example']). Use hide($content['field_example']) to temporarily suppress the printing of a given element.
  • $user_picture: The node author's picture from user-picture.tpl.php.
  • $date: Formatted creation date. Preprocess functions can reformat it by calling format_date() with the desired parameters on the $created variable.
  • $name: Themed username of node author output from theme_username().
  • $node_url: Direct URL of the current node.
  • $display_submitted: Whether submission information should be displayed.
  • submitted:
    Submission information created from
    name and $date during template_preprocess_node().
  • $classes: String of classes that can be used to style contextually through CSS. It can be manipulated through the variable $classes_array from preprocess functions. The default values can be one or more of the following:
    • node: The current template type; for example, "theming hook".
    • node-[type]: The current node type. For example, if the node is a "Blog entry" it would result in "node-blog". Note that the machine name will often be in a short form of the human readable label.
    • node-teaser: Nodes in teaser form.
    • node-preview: Nodes in preview mode. The following are controlled through the node publishing options.
    • node-promoted: Nodes promoted to the front page.
    • node-sticky: Nodes ordered above other non-sticky nodes in teaser listings.
    • node-unpublished: Unpublished nodes visible only to administrators.
  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template.

Other variables:

  • $node: Full node object. Contains data that may not be safe.
  • $type: Node type; for example, story, page, blog, etc.
  • $comment_count: Number of comments attached to the node.
  • $uid: User ID of the node author.
  • $created: Time the node was published formatted in Unix timestamp.
  • $classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes.
  • $zebra: Outputs either "even" or "odd". Useful for zebra striping in teaser listings.
  • $id: Position of the node. Increments each time it's output.

Node status variables:

  • $view_mode: View mode; for example, "full", "teaser".
  • teaser:
    Flag for the teaser state (shortcut for
    view_mode == 'teaser').
  • $page: Flag for the full page state.
  • $promote: Flag for front page promotion state.
  • $sticky: Flags for sticky post setting.
  • $status: Flag for published status.
  • $comment: State of comment settings for the node.
  • $readmore: Flags true if the teaser content of the node cannot hold the main body content.
  • $is_front: Flags true when presented in the front page.
  • $logged_in: Flags true when the current user is a logged-in member.
  • $is_admin: Flags true when the current user is an administrator.

Field variables: for each field instance attached to the node a corresponding variable is defined; for example, $node->body becomes $body. When needing to access a field's raw values, developers/themers are strongly encouraged to use these variables. Otherwise they will have to explicitly specify the desired field language; for example, $node->body['en'], thus overriding any language negotiation rule that was previously applied.

See Also
template_preprocess()
template_preprocess_node()
template_process()

Definition in file node.tpl.php.

Variable Documentation

print $attributes

Definition at line 81 of file node.tpl.php.

print $classes

Definition at line 81 of file node.tpl.php.

print $content_attributes

Definition at line 98 of file node.tpl.php.

if ($teaser||!empty($content['comments']['comment_form'])) $links = render($content['links'])

Definition at line 114 of file node.tpl.php.

if (!$page) print $node_url

Definition at line 84 of file node.tpl.php.

if ($display_submitted) print $submitted

Definition at line 91 of file node.tpl.php.

print $title

Definition at line 86 of file node.tpl.php.

if ($links) endif

Definition at line 88 of file node.tpl.php.

print $node nid

Definition at line 81 of file node.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/templates/page.tpl.php File Reference

  • themes
  • bartik
  • templates
Variables
page.tpl.php File Reference

Go to the source code of this file.

Variables

print $secondary_menu
print $logo
endif
if($site_name||$site_slogan)($hide_site_name
&&$hide_site_slogan) if($site_name)($title)($hide_site_name)
print 		$front_page
print $site_name
else __pad0__
if($site_slogan)($hide_site_slogan)
print 		$site_slogan
print $feed_icons

Detailed Description

Bartik's theme implementation to display a single Drupal page.

The doctype, html, head and body tags are not in this template. Instead they can be found in the html.tpl.php template normally located in the modules/system directory.

Available variables:

General utility variables:

  • $base_path: The base URL path of the Drupal installation. At the very least, this will always default to /.
  • $directory: The directory the template is located in, e.g. modules/system or themes/bartik.
  • $is_front: TRUE if the current page is the front page.
  • $logged_in: TRUE if the user is registered and signed in.
  • $is_admin: TRUE if the user has permission to access administration pages.

Site identity:

  • front_page:
    The URL of the front page. Use this instead of
    base_path, when linking to the front page. This includes the language domain or prefix.
  • $logo: The path to the logo image, as defined in theme configuration.
  • $site_name: The name of the site, empty when display has been disabled in theme settings.
  • $site_slogan: The slogan of the site, empty when display has been disabled in theme settings.
  • $hide_site_name: TRUE if the site name has been toggled off on the theme settings page. If hidden, the "element-invisible" class is added to make the site name visually hidden, but still accessible.
  • $hide_site_slogan: TRUE if the site slogan has been toggled off on the theme settings page. If hidden, the "element-invisible" class is added to make the site slogan visually hidden, but still accessible.

Navigation:

  • $main_menu (array): An array containing the Main menu links for the site, if they have been configured.
  • $secondary_menu (array): An array containing the Secondary menu links for the site, if they have been configured.
  • $breadcrumb: The breadcrumb trail for the current page.

Page content (in order of occurrence in the default page.tpl.php):

  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • $title: The page title, for use in the actual HTML content.
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template.
  • $messages: HTML for status and error messages. Should be displayed prominently.
  • $tabs (array): Tabs linking to any sub-pages beneath the current page (e.g., the view and edit tabs when displaying a node).
  • $action_links (array): Actions local to the page, such as 'Add menu' on the menu administration interface.
  • $feed_icons: A string of all feed icons for the current page.
  • $node: The node object, if there is an automatically-loaded node associated with the page, and the node ID is the second argument in the page's path (e.g. node/12345 and node/12345/revisions, but not comment/reply/12345).

Regions:

  • $page['header']: Items for the header region.
  • $page['featured']: Items for the featured region.
  • $page['highlighted']: Items for the highlighted content region.
  • $page['help']: Dynamic help text, mostly for admin pages.
  • $page['content']: The main content of the current page.
  • $page['sidebar_first']: Items for the first sidebar.
  • $page['triptych_first']: Items for the first triptych.
  • $page['triptych_middle']: Items for the middle triptych.
  • $page['triptych_last']: Items for the last triptych.
  • $page['footer_firstcolumn']: Items for the first footer column.
  • $page['footer_secondcolumn']: Items for the second footer column.
  • $page['footer_thirdcolumn']: Items for the third footer column.
  • $page['footer_fourthcolumn']: Items for the fourth footer column.
  • $page['footer']: Items for the footer region.
See Also
template_preprocess()
template_preprocess_page()
template_process()
bartik_process_page()
html.tpl.php

Definition in file page.tpl.php.

Variable Documentation

print $feed_icons

Definition at line 208 of file page.tpl.php.

print $front_page

Definition at line 101 of file page.tpl.php.

print $logo

Definition at line 94 of file page.tpl.php.

print $secondary_menu

Definition at line 90 of file page.tpl.php.

print $site_name

Definition at line 105 of file page.tpl.php.

if ($site_slogan) ($hide_site_slogan) print $site_slogan

Definition at line 115 of file page.tpl.php.

else __pad0__

Definition at line 109 of file page.tpl.php.

endif

Definition at line 96 of file page.tpl.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/template.php File Reference

  • themes
  • bartik
Functions
template.php File Reference

Go to the source code of this file.

Functions

bartik_preprocess_html (&$variables)
bartik_process_html (&$variables)
bartik_process_page (&$variables)
bartik_preprocess_maintenance_page (&$variables)
bartik_process_maintenance_page (&$variables)
bartik_preprocess_node (&$variables)
bartik_preprocess_block (&$variables)
bartik_menu_tree ($variables)
bartik_field__taxonomy_term_reference ($variables)

Function Documentation

bartik_field__taxonomy_term_reference ( $variables )

Implements theme_field__field_type().

Definition at line 137 of file template.php.

References $output, and drupal_render().

bartik_menu_tree ( $variables )

Implements theme_menu_tree().

Definition at line 130 of file template.php.

bartik_preprocess_block ( & $variables )

Override or insert variables into the block template.

Definition at line 120 of file template.php.

bartik_preprocess_html ( & $variables )

Add body classes if certain regions have content.

Definition at line 6 of file template.php.

References CSS_THEME, drupal_add_css(), and path_to_theme().

bartik_preprocess_maintenance_page ( & $variables )

Implements hook_preprocess_maintenance_page().

Definition at line 79 of file template.php.

References drupal_add_css(), and drupal_get_path().

bartik_preprocess_node ( & $variables )

Override or insert variables into the node template.

Definition at line 111 of file template.php.

References node_is_page().

bartik_process_html ( & $variables )

Override or insert variables into the page template for HTML output.

Definition at line 32 of file template.php.

References _color_html_alter(), and module_exists().

bartik_process_maintenance_page ( & $variables )

Override or insert variables into the maintenance page template.

Definition at line 93 of file template.php.

References filter_xss_admin(), theme_get_setting(), and variable_get().

bartik_process_page ( & $variables )

Override or insert variables into the page template.

Definition at line 42 of file template.php.

References _color_page_alter(), filter_xss_admin(), module_exists(), theme_get_setting(), and variable_get().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/engines Directory Reference

  • themes
  • engines
engines Directory Reference

Directories

directory phptemplate
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/engines/phptemplate Directory Reference

  • themes
  • engines
  • phptemplate
phptemplate Directory Reference

Files

file phptemplate.engine [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/engines/phptemplate/phptemplate.engine File Reference

  • themes
  • engines
  • phptemplate
Functions
phptemplate.engine File Reference

Go to the source code of this file.

Functions

phptemplate_init ($template)
phptemplate_theme ($existing, $type, $theme, $path)

Detailed Description

Handles integration of PHP templates with the Drupal theme system.

Definition in file phptemplate.engine.

Function Documentation

phptemplate_init ( $template )

Implements hook_init().

Definition at line 11 of file phptemplate.engine.

References DRUPAL_ROOT.

phptemplate_theme | ( | $existing,
 |  | $type,
 |  | $theme,
 |  | $path
 | ) |

Implements hook_theme().

Definition at line 21 of file phptemplate.engine.

References drupal_find_theme_functions(), and drupal_find_theme_templates().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland Directory Reference

  • themes
  • garland
garland Directory Reference

Directories

directory color

Files

file | comment.tpl.php [code]
file | maintenance-page.tpl.php [code]
file | node.tpl.php [code]
file | page.tpl.php [code]
file | template.php [code]
file | theme-settings.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/color Directory Reference

  • themes
  • garland
  • color
color Directory Reference

Files

file color.inc [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/color/color.inc File Reference

  • themes
  • garland
  • color
Variables
color.inc File Reference

Go to the source code of this file.

Variables

$info

Variable Documentation

$info

Definition at line 3 of file color.inc.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/comment.tpl.php File Reference

  • themes
  • garland
Variables
comment.tpl.php File Reference

Go to the source code of this file.

Variables

print $classes $zebra
print $attributes
print $title_attributes
print $content_attributes

Variable Documentation

print $attributes

Definition at line 3 of file comment.tpl.php.

print $content_attributes

Definition at line 19 of file comment.tpl.php.

print $title_attributes

Definition at line 16 of file comment.tpl.php.

print $classes $zebra

Definition at line 3 of file comment.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/maintenance-page.tpl.php File Reference

  • themes
  • garland
Variables
maintenance-page.tpl.php File Reference

Go to the source code of this file.

Variables

print $language language print
$language language print
$language dir print
$head_title print $head print
$styles print $scripts print
$classes print 		$header
$site_fields = array()
if($site_name) if($site_slogan) | $site_title = implode(' ', $site_fields)
if($site_fields) | $site_html = implode(' ', $site_fields)
if($logo||$site_title) if($sidebar_first)
if($title) print 		$messages
print $help

Detailed Description

Override of the default maintenance page.

This is an override of the default maintenance page. Used for Garland and Minnelli, this file should not be moved or modified since the installation and update pages depend on this file.

This mirrors closely page.tpl.php for Garland in order to share the same styles.

Definition in file maintenance-page.tpl.php.

Variable Documentation

print $language language print $language language print $language dir print $head_title print $head print $styles print $scripts print $classes print $header

Definition at line 26 of file maintenance-page.tpl.php.

print $help

Definition at line 69 of file maintenance-page.tpl.php.

Referenced by form_example_help(), menu_get_active_help(), standard_install(), syslog_form_system_logging_settings_alter(), and system_requirements().

if ($logo||$site_title) if ($sidebar_first) if ($title) print $messages

Definition at line 67 of file maintenance-page.tpl.php.

$site_fields = array()

Definition at line 35 of file maintenance-page.tpl.php.

Referenced by garland_preprocess_page().

if ($site_fields) $site_html = implode(' ', $site_fields)

Definition at line 46 of file maintenance-page.tpl.php.

if ($site_name) if ($site_slogan) $site_title = implode(' ', $site_fields)

Definition at line 42 of file maintenance-page.tpl.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/node.tpl.php File Reference

  • themes
  • garland
Variables
node.tpl.php File Reference

Go to the source code of this file.

Variables

print $node | nid
print $classes
print $attributes
print $user_picture
if(!$page) print | $node_url
print $title
endif
if($display_submitted) print | $content_attributes

Variable Documentation

print $attributes

Definition at line 3 of file node.tpl.php.

print $classes

Definition at line 3 of file node.tpl.php.

if ($display_submitted) print $content_attributes

Definition at line 13 of file node.tpl.php.

if (!$page) print $node_url

Definition at line 8 of file node.tpl.php.

print $title

Definition at line 9 of file node.tpl.php.

print $user_picture

Definition at line 5 of file node.tpl.php.

endif

Definition at line 10 of file node.tpl.php.

print $node nid

Definition at line 3 of file node.tpl.php.

Generated on Mon Feb 3 2014 12:40:47 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/page.tpl.php File Reference

  • themes
  • garland
Variables
page.tpl.php File Reference

Go to the source code of this file.

Variables

if($logo||$site_title)($title)($logo)
print $site_html 		else
print $site_html endif
print $breadcrumb
print $messages

Variable Documentation

print $breadcrumb

Definition at line 40 of file page.tpl.php.

Referenced by drupal_get_breadcrumb(), drupal_set_breadcrumb(), forum_node_view(), garland_breadcrumb(), hook_view(), menu_edit_item(), menu_get_active_breadcrumb(), taxonomy_term_page(), template_preprocess_forums(), and theme_breadcrumb().

print $messages

Definition at line 51 of file page.tpl.php.

if($logo || $site_title) ($title) ($logo) print $site_html else

Definition at line 10 of file page.tpl.php.

endif

Definition at line 25 of file page.tpl.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/template.php File Reference

  • themes
  • garland
Functions
template.php File Reference

Go to the source code of this file.

Functions

garland_breadcrumb ($variables)
garland_preprocess_maintenance_page (&$vars)
garland_preprocess_html (&$vars)
garland_process_html (&$vars)
garland_preprocess_page (&$vars)
garland_preprocess_node (&$vars)
garland_preprocess_comment (&$vars)
garland_preprocess_block (&$vars)
garland_process_page (&$vars)
garland_preprocess_region (&$vars)

Function Documentation

garland_breadcrumb ( $variables )

Override of theme_breadcrumb().

Definition at line 6 of file template.php.

References $breadcrumb, $output, and t().

garland_preprocess_block ( & $vars )

Override or insert variables into the block template.

Definition at line 134 of file template.php.

garland_preprocess_comment ( & $vars )

Override or insert variables into the comment template.

Definition at line 127 of file template.php.

garland_preprocess_html ( & $vars )

Override or insert variables into the html template.

Definition at line 34 of file template.php.

References CSS_THEME, drupal_add_css(), path_to_theme(), and theme_get_setting().

Referenced by garland_preprocess_maintenance_page().

garland_preprocess_maintenance_page ( & $vars )

Override or insert variables into the maintenance page template.

Definition at line 22 of file template.php.

References garland_preprocess_html().

garland_preprocess_node ( & $vars )

Override or insert variables into the node template.

Definition at line 120 of file template.php.

garland_preprocess_page ( & $vars )

Override or insert variables into the page template.

Definition at line 56 of file template.php.

References $site_fields, t(), and theme().

garland_preprocess_region ( & $vars )

Override or insert variables into the region template.

Definition at line 152 of file template.php.

garland_process_html ( & $vars )

Override or insert variables into the html template.

Definition at line 46 of file template.php.

References _color_html_alter(), and module_exists().

garland_process_page ( & $vars )

Override or insert variables into the page template.

Definition at line 142 of file template.php.

References _color_page_alter(), and module_exists().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/theme-settings.php File Reference

  • themes
  • garland
Functions
theme-settings.php File Reference

Go to the source code of this file.

Functions

garland_form_system_theme_settings_alter (&$form, &$form_state)

Detailed Description

Theme setting callbacks for the garland theme.

Definition in file theme-settings.php.

Function Documentation

garland_form_system_theme_settings_alter | ( | & | $form,
 |  | & | $form_state
 | ) |  |

Implements hook_form_FORM_ID_alter().

Parameters
$form | The form.
$form_state | The form state.

Definition at line 16 of file theme-settings.php.

References t(), and theme_get_setting().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/seven Directory Reference

  • themes
  • seven
seven Directory Reference

Files

file | maintenance-page.tpl.php [code]
file | page.tpl.php [code]
file | template.php [code]
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/seven/maintenance-page.tpl.php File Reference

  • themes
  • seven
Variables
maintenance-page.tpl.php File Reference

Go to the source code of this file.

Variables

print $language language print
$language language print
$language dir print 		$head_title
print $head
print $styles
print $scripts
print $classes
print $page_top
if($title) endif
print $content
print $page_bottom

Variable Documentation

print $classes

Definition at line 10 of file maintenance-page.tpl.php.

print $content

Definition at line 38 of file maintenance-page.tpl.php.

print $head

Definition at line 6 of file maintenance-page.tpl.php.

print $language language print $language language print $language dir print $head_title

Definition at line 5 of file maintenance-page.tpl.php.

print $page_bottom

Definition at line 43 of file maintenance-page.tpl.php.

print $page_top

Definition at line 12 of file maintenance-page.tpl.php.

print $scripts

Definition at line 8 of file maintenance-page.tpl.php.

print $styles

Definition at line 7 of file maintenance-page.tpl.php.

if ($help) endif

Definition at line 15 of file maintenance-page.tpl.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/seven/page.tpl.php File Reference

  • themes
  • seven
Variables
page.tpl.php File Reference

Go to the source code of this file.

Variables

print $breadcrumb
if($title) endif
print $feed_icons

Variable Documentation

print $breadcrumb

Definition at line 3 of file page.tpl.php.

print $feed_icons

Definition at line 32 of file page.tpl.php.

endif

Definition at line 5 of file page.tpl.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/seven/template.php File Reference

  • themes
  • seven
Functions
template.php File Reference

Go to the source code of this file.

Functions

seven_preprocess_maintenance_page (&$vars)
seven_preprocess_html (&$vars)
seven_preprocess_page (&$vars)
seven_node_add_list ($variables)
seven_admin_block_content ($variables)
seven_tablesort_indicator ($variables)
seven_css_alter (&$css)

Function Documentation

seven_admin_block_content ( $variables )

Overrides theme_admin_block_content().

Use unordered list markup in both compact and extended mode.

Definition at line 66 of file template.php.

References $content, $output, filter_xss_admin(), l(), and system_admin_compact_mode().

seven_css_alter ( & $css )

Implements hook_css_alter().

Definition at line 103 of file template.php.

References drupal_get_path().

seven_node_add_list ( $variables )

Display the list of available node types for node creation.

Definition at line 42 of file template.php.

References $content, $output, filter_xss_admin(), l(), t(), and url().

seven_preprocess_html ( & $vars )

Override or insert variables into the html template.

Definition at line 18 of file template.php.

References CSS_THEME, drupal_add_css(), and path_to_theme().

Referenced by seven_preprocess_maintenance_page().

seven_preprocess_maintenance_page ( & $vars )

Override or insert variables into the maintenance page template.

Definition at line 6 of file template.php.

References seven_preprocess_html().

seven_preprocess_page ( & $vars )

Override or insert variables into the page template.

Definition at line 30 of file template.php.

seven_tablesort_indicator ( $variables )

Override of theme_tablesort_indicator().

Use our own image versions, so they show up as black and not gray on gray.

Definition at line 89 of file template.php.

References drupal_get_path(), t(), and theme().

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: authorize.php File Reference

Functions | Variables
authorize.php File Reference

Go to the source code of this file.

Functions

authorize_access_denied_page ()
authorize_access_allowed ()

Variables

const | DRUPAL_ROOT getcwd()
const | MAINTENANCE_MODE 'update'
global | $conf
$module_list ['system']['filename'] = 'modules/system/system.module'
$module_list ['user']['filename'] = 'modules/user/user.module'
$output = ''
$show_messages = TRUE
if(authorize_access_allowed()) else

Detailed Description

Administrative script for running authorized file operations.

Using this script, the site owner (the user actually owning the files on the webserver) can authorize certain file-related operations to proceed with elevated privileges, for example to deploy and upgrade modules or themes. Users should not visit this page directly, but instead use an administrative user interface which knows how to redirect the user to this script as part of a multistep process. This script actually performs the selected operations without loading all of Drupal, to be able to more gracefully recover from errors. Access to the script is controlled by a global killswitch in settings.php ('allow_authorize_operations') and via the 'administer software updates' permission.

There are helper functions for setting up an operation to run via this system in modules/system/system.module. For more information, see: Authorized operation helper functions

Definition in file authorize.php.

Function Documentation

authorize_access_allowed ( )

Determines if the current user is allowed to run authorize.php.

The killswitch in settings.php overrides all else, otherwise, the user must have access to the 'administer software updates' permission.

Returns
TRUE if the current user can run authorize.php, and FALSE if not.

Definition at line 57 of file authorize.php.

References user_access(), and variable_get().

authorize_access_denied_page ( )

Renders a 403 access denied page for authorize.php.

Definition at line 41 of file authorize.php.

References drupal_add_http_header(), drupal_set_title(), t(), watchdog(), and WATCHDOG_WARNING.

Variable Documentation

global $conf

Definition at line 74 of file authorize.php.

Referenced by _drupal_bootstrap_variables(), _drupal_maintenance_theme(), conf_path(), drupal_settings_initialize(), hook_language_init(), install_begin_request(), locale_init(), php_eval(), DrupalWebTestCase\prepareEnvironment(), DrupalWebTestCase\refreshVariables(), DrupalUnitTestCase\setUp(), DrupalWebTestCase\setUp(), DrupalUnitTestCase\tearDown(), update_fix_d7_requirements(), variable_del(), variable_get(), variable_initialize(), and variable_set().

$module_list['system']['filename'] = 'modules/system/system.module'

Definition at line 78 of file authorize.php.

Referenced by _drupal_maintenance_theme(), drupal_uninstall_modules(), install_begin_request(), module_disable(), module_enable(), DrupalUnitTestCase\setUp(), system_update_7020(), and system_update_7027().

$module_list['user']['filename'] = 'modules/user/user.module'

Definition at line 79 of file authorize.php.

$output = ''

Definition at line 93 of file authorize.php.

Referenced by _aggregator_page_list(), _batch_page(), _color_rewrite_stylesheet(), _filter_autop(), _filter_html_tips(), _locale_export_po(), _locale_export_po_generate(), _locale_translate_language_list(), _locale_translate_seek(), _menu_example_menu_page(), _password_base64_encode(), _password_crypt(), _password_generate_salt(), _php_filter_tips(), _profile_form_explanation(), _statistics_format_item(), _theme_table_cell(), aggregator_help(), aggregator_page_categories(), aggregator_page_sources(), aggregator_view(), ajax_example_add_more_submit(), ajax_example_advanced_commands_restripe_num_rows(), ajax_example_render_link(), ajax_link_response(), DrupalWebTestCase\assertThemeOutput(), bartik_field__taxonomy_term_reference(), block_help(), blog_help(), book_export_traverse(), book_help(), DrupalLocalStreamWrapper\chmod(), color_help(), comment_help(), contact_help(), contextual_help(), dashboard_help(), dblog_help(), dbtng_example_advanced_list(), dbtng_example_help(), dbtng_example_list(), drupal_get_js(), drupal_html_to_text(), drupal_json_encode_helper(), drupal_random_bytes(), drupal_render(), drupal_render_children(), drupal_set_title(), drupal_var_export(), field_attach_view(), field_help(), field_sql_storage_help(), field_ui_field_delete_form(), field_ui_fields_list(), field_ui_help(), field_view_field(), field_view_value(), file_ajax_upload(), file_help(), filter_help(), filter_tips_long(), form_example_tutorial_9_submit(), format_interval(), format_rss_channel(), format_rss_item(), format_xml_elements(), forum_help(), garland_breadcrumb(), help_help(), help_links_as_list(), help_main(), help_page(), hook_field_attach_view_alter(), hook_search_page(), image_example_help(), image_get_available_toolkits(), image_help(), image_style_options(), install_display_output(), install_drupal(), install_finished(), install_run_task(), install_run_tasks(), install_select_locale(), FileTransferSSH\isDirectory(), FileTransferSSH\isFile(), js_example_accordion(), js_example_js_weights(), list_field_formatter_view(), list_help(), locale_help(), locale_translate_export_screen(), locale_translate_seek_screen(), menu_get_active_help(), menu_help(), node_add(), node_feed(), node_help(), node_preview(), number_field_formatter_view(), number_help(), openid_extract_ax_values(), openid_extract_namespace(), openid_help(), openid_redirect(), options_help(), overlay_help(), path_admin_edit(), path_help(), php_eval(), php_help(), poll_block_latest_poll_view(), poll_help(), poll_page(), poll_view(), profile_block_view(), profile_browse(), profile_help(), rdf_field_attach_view_alter(), rdf_help(), render_example_add_hr(), seven_admin_block_content(), seven_node_add_list(), shortcut_help(), simpletest_help(), statistics_help(), syslog_help(), system_admin_menu_block_page(), system_batch_page(), system_date_delete_format_form(), system_delete_date_format_type_form(), system_help(), system_settings_overview(), taxonomy_help(), text_field_formatter_view(), text_help(), theme(), theme_admin_block(), theme_admin_block_content(), theme_admin_page(), theme_aggregator_categorize_items(), theme_aggregator_page_opml(), theme_aggregator_page_rss(), theme_authorize_report(), theme_breadcrumb(), theme_color_scheme_form(), theme_dashboard_disabled_block(), theme_dashboard_disabled_blocks(), theme_dashboard_region(), theme_dblog_message(), theme_example_node_color(), theme_exposed_filters(), theme_field(), theme_field_multiple_value_form(), theme_fieldset(), theme_file_managed_file(), theme_file_widget(), theme_file_widget_multiple(), theme_filter_admin_format_filter_order(), theme_filter_admin_overview(), theme_filter_guidelines(), theme_filter_tips(), theme_form_element(), theme_form_example_inline_form_element(), theme_html_tag(), theme_image_example_image(), theme_image_formatter(), theme_image_style_effects(), theme_image_style_preview(), theme_image_widget(), theme_indentation(), theme_item_list(), theme_links(), theme_locale_date_format_form(), theme_locale_languages_configure_form(), theme_locale_languages_overview_form(), theme_menu_admin_overview(), theme_menu_link(), theme_menu_local_action(), theme_menu_local_tasks(), theme_menu_overview_form(), theme_node_add_list(), theme_node_admin_overview(), theme_node_preview(), theme_node_recent_block(), theme_node_recent_content(), theme_node_search_admin(), theme_nodeapi_example_rating(), theme_options_none(), theme_overlay_disable_message(), theme_pager_first(), theme_pager_last(), theme_pager_next(), theme_pager_previous(), theme_poll_choices(), theme_profile_admin_overview(), theme_progress_bar(), theme_queue_items(), theme_rdf_metadata(), theme_rdf_template_variable_wrapper(), theme_render_example_add_div(), theme_render_example_add_notes(), theme_render_example_aggregate(), theme_shortcut_set_customize(), theme_status_messages(), theme_status_report(), theme_system_admin_index(), theme_system_compact_link(), theme_system_date_time_settings(), theme_system_modules_uninstall(), theme_system_themes_page(), theme_table(), theme_tabledrag_example_parent_form(), theme_tabledrag_example_simple_form(), theme_task_list(), theme_taxonomy_overview_terms(), theme_text_format_wrapper(), theme_textarea(), theme_textfield(), theme_theming_example_content_array(), theme_theming_example_list(), theme_theming_example_select_form(), theme_trigger_display(), theme_update_last_check(), theme_update_manager_update_form(), theme_update_report(), theme_update_version(), theme_user_admin_permissions(), theme_user_admin_roles(), theme_user_signature(), theme_username(), theme_vertical_tabs(), toolbar_help(), tracker_help(), translation_help(), trigger_help(), update_help(), update_info_page(), update_results_page(), update_selection_page(), user_block_view(), and user_help().

$show_messages = TRUE

Definition at line 94 of file authorize.php.

const DRUPAL_ROOT getcwd()

Defines the root directory of the Drupal installation.

Definition at line 26 of file authorize.php.

Referenced by _aggregator_get_variables(), _batch_finished(), _batch_process(), _batch_queue(), _drupal_bootstrap_database(), _drupal_bootstrap_full(), _drupal_bootstrap_page_cache(), _drupal_bootstrap_variables(), _drupal_error_handler(), _drupal_error_handler_real(), _drupal_exception_handler(), _drupal_maintenance_theme(), _drupal_session_write(), _drupal_shutdown_function(), _drupal_theme_initialize(), _install_configure_form(), _install_select_profile(), _locale_prepare_predefined_list(), _module_build_dependencies(), _registry_check_code(), _registry_update(), _system_batch_theme(), _theme_process_registry(), authorize_get_filetransfer(), authorize_run_operation(), batch_process(), color_get_info(), conf_path(), country_get_list(), drupal_bootstrap(), drupal_check_profile(), drupal_get_complete_schema(), drupal_get_database_types(), drupal_get_filename(), drupal_install_system(), drupal_json_encode(), drupal_language_initialize(), drupal_load(), drupal_maintenance_theme(), drupal_rewrite_settings(), drupal_settings_initialize(), drupal_system_listing(), drupal_verify_profile(), DrupalTestCase\exceptionHandler(), filter_xss_bad_protocol(), form_get_cache(), ModuleUpdater\getInstallDirectory(), ThemeUpdater\getInstallDirectory(), FileExampleSessionStreamWrapper\getMimeType(), DrupalLocalStreamWrapper\getMimeType(), ModuleUpdater\getSchemaUpdates(), image_effect_definitions(), install_begin_request(), install_configure_form(), install_goto(), install_import_locales(), install_import_locales_remaining(), install_load_profile(), install_run_task(), install_select_locale(), install_select_locale_form(), install_select_profile(), install_select_profile_form(), install_tasks(), language_negotiation_get_switch_links(), language_provider_invoke(), locale_add_language(), locale_block_info(), locale_date_format_form_submit(), locale_init(), locale_js_alter(), locale_language_types_info(), locale_languages_configure_form(), locale_languages_predefined_form_submit(), locale_languages_predefined_form_validate(), locale_modules_enabled(), locale_system_update(), locale_translate_import_form_submit(), locale_update_7001(), locale_update_7002(), locale_url_outbound_alter(), menu_execute_active_handler(), module_enable(), module_load_include(), module_load_install(), Database\openConnection(), phptemplate_init(), registry_update(), DrupalWebTestCase\setUp(), simpletest_test_get_all(), st(), statistics_exit(), system_batch_page(), system_image_toolkits(), system_list(), system_modules(), system_modules_submit(), system_modules_uninstall(), system_modules_uninstall_submit(), system_regional_settings(), system_requirements(), system_status(), system_theme_settings(), theme(), theme_color_scheme_form(), theme_render_template(), translation_node_overview(), update_access_allowed(), update_do_one(), update_manager_install_form_submit(), update_manager_update_ready_form_submit(), update_prepare_d7_bootstrap(), update_resolve_dependencies(), user_authenticate(), user_save(), user_update_7000(), user_validate_current_pass(), watchdog_exception(), and xmlrpc().

if (authorize_access_allowed()) else
Initial value:
{
$output = authorize_access_denied_page()
$output
$output
Definition: authorize.php:93
authorize_access_denied_page
authorize_access_denied_page()
Definition: authorize.php:41

Definition at line 168 of file authorize.php.

const MAINTENANCE_MODE 'update'

Global flag to identify update.php and authorize.php runs.

Identifies update.php and authorize.php runs, avoiding unwanted operations such as hook_init() and hook_exit() invokes, css/js preprocessing and translation, and solves some theming issues. The flag is checked in other places in Drupal code (not just authorize.php).

Definition at line 36 of file authorize.php.

Referenced by _drupal_bootstrap_full(), _drupal_maintenance_theme(), ajax_footer(), drupal_aggregate_css(), drupal_exit(), drupal_get_js(), drupal_installation_attempted(), error_displayable(), menu_get_custom_theme(), and update_flush_caches().

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: cron.php File Reference

Variables
cron.php File Reference

Go to the source code of this file.

Variables

const DRUPAL_ROOT getcwd()
if(!isset($_GET['cron_key'])||variable_get('cron_key',
'drupal')!=$_GET['cron_key'])
elseif(variable_get('maintenance_mode', 0)) 		else

Detailed Description

Handles incoming requests to fire off regularly-scheduled tasks (cron jobs).

Definition in file cron.php.

Variable Documentation

const DRUPAL_ROOT getcwd()

Root directory of Drupal installation.

Definition at line 11 of file cron.php.

if (!isset($_GET['cron_key'])||variable_get('cron_key', 'drupal')!=$_GET['cron_key']) elseif (variable_get('maintenance_mode', 0)) else
Initial value:
{
drupal_cron_run()
drupal_cron_run
drupal_cron_run()
Definition: common.inc:5227

Definition at line 24 of file cron.php.

Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: index.php File Reference

Variables
index.php File Reference

Go to the source code of this file.

Variables

const DRUPAL_ROOT getcwd()

Detailed Description

The PHP page that serves all page requests on a Drupal installation.

The routines here dispatch control to the appropriate handler, which then prints the appropriate page.

All Drupal code is released under the GNU General Public License. See COPYRIGHT.txt and LICENSE.txt.

Definition in file index.php.

Variable Documentation

const DRUPAL_ROOT getcwd()

Root directory of Drupal installation.

Definition at line 17 of file index.php.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: install.php File Reference

Variables
install.php File Reference

Go to the source code of this file.

Variables

const | DRUPAL_ROOT getcwd()
const | MAINTENANCE_MODE 'install'
if (version_compare(PHP_VERSION, '5.2.4')< 0)

Detailed Description

Initiates a browser-based installation of Drupal.

Definition in file install.php.

Variable Documentation

const DRUPAL_ROOT getcwd()

Defines the root directory of the Drupal installation.

Definition at line 11 of file install.php.

if ( )

Definition at line 19 of file install.php.

Referenced by system_modules().

const MAINTENANCE_MODE 'install'

Global flag to indicate the site is in installation mode.

Definition at line 16 of file install.php.

Generated on Mon Feb 3 2014 12:40:46 for Drupal 7 by doxygen 1.8.5


Drupal 7: update.php File Reference

Functions | Variables
update.php File Reference

Go to the source code of this file.

Functions

update_selection_page ()
update_script_selection_form ($form, &$form_state)
update_helpful_links ()
update_results_page ()
update_info_page ()
update_access_denied_page ()
update_access_allowed ()
update_task_list ($active=NULL)
update_extra_requirements ($requirements=NULL)
update_check_requirements ($skip_warnings=FALSE)

Variables

const | DRUPAL_ROOT getcwd()
const | MAINTENANCE_MODE 'update'
$configurable_timezones = variable_get('configurable_timezones', 1)
$conf ['configurable_timezones'] = 0
$op = isset($_REQUEST['op']) ? $_REQUEST['op'] : ''
if(update_access_allowed()) else

Detailed Description

Administrative page for handling updates from one Drupal version to another.

Point your browser to "http://www.example.com/update.php" and follow the instructions.

If you are not logged in using either the site maintenance account or an account with the "Administer software updates" permission, you will need to modify the access check statement inside your settings.php file. After finishing the upgrade, be sure to open settings.php again, and change it back to its original state!

Definition in file update.php.

Function Documentation

update_access_allowed ( )

Determines if the current user is allowed to run update.php.

Returns
TRUE if the current user should be granted access, or FALSE otherwise.

Definition at line 304 of file update.php.

References $update_free_access, drupal_get_path(), DRUPAL_ROOT, and user_access().

update_access_denied_page ( )

Renders a 403 access denied page for update.php.

Returns
Rendered HTML warning with 403 status.

Definition at line 285 of file update.php.

References drupal_add_http_header(), drupal_set_title(), watchdog(), and WATCHDOG_WARNING.

update_check_requirements ( $skip_warnings = FALSE )

Checks update requirements and reports errors and (optionally) warnings.

Parameters
$skip_warnings (optional) If set to TRUE, requirement warnings will be ignored, and a report will only be issued if there are requirement errors. Defaults to FALSE.

Definition at line 357 of file update.php.

References check_url(), drupal_requirements_severity(), drupal_requirements_url(), drupal_set_title(), module_invoke_all(), print, REQUIREMENT_ERROR, REQUIREMENT_WARNING, theme(), update_extra_requirements(), and update_task_list().

update_extra_requirements ( $requirements = NULL )

Returns and stores extra requirements that apply during the update process.

Definition at line 341 of file update.php.

Referenced by update_check_requirements(), and update_prepare_d7_bootstrap().

update_helpful_links ( )

Provides links to the homepage and administration pages.

Definition at line 153 of file update.php.

References $links, base_path(), and user_access().

Referenced by update_results_page(), and update_script_selection_form().

update_info_page ( )

Provides an overview of the Drupal database update.

This page provides cautionary suggestions that should happen before proceeding with the update to ensure data integrity.

Returns
Rendered HTML form.

Definition at line 254 of file update.php.

References $output, _drupal_flush_css_js(), base_path(), cache_clear_all(), check_url(), db_table_exists(), drupal_current_script_url(), drupal_get_token(), drupal_set_title(), and update_task_list().

update_results_page ( )

Displays results of the update script with any accompanying errors.

Definition at line 164 of file update.php.

References $links, $messages, $module, $output, base_path(), drupal_set_title(), module_exists(), theme(), update_helpful_links(), update_task_list(), and user_access().

update_script_selection_form | ( |  | $form,
 |  | & | $form_state
 | ) |  |

Form constructor for the list of available database module updates.

Definition at line 46 of file update.php.

References $module, drupal_flush_all_caches(), drupal_set_message(), format_plural(), t(), theme(), update_get_update_list(), update_helpful_links(), and update_resolve_dependencies().

update_selection_page ( )

Renders a form with a list of available database updates.

Definition at line 33 of file update.php.

References $output, drupal_get_form(), drupal_render(), drupal_set_title(), and update_task_list().

update_task_list ( $active = NULL )

Adds the update task list to the current page.

Definition at line 325 of file update.php.

References drupal_add_region_content(), and theme().

Referenced by update_check_requirements(), update_info_page(), update_results_page(), and update_selection_page().

Variable Documentation

$conf['configurable_timezones'] = 0

Definition at line 393 of file update.php.

$configurable_timezones = variable_get('configurable_timezones', 1)

Definition at line 392 of file update.php.

Referenced by system_regional_settings().

$op = isset($_REQUEST['op']) ? $_REQUEST['op'] : ''

Definition at line 404 of file update.php.

Referenced by _aggregator_page_list(), _batch_page(), _field_invoke(), _field_invoke_default(), _field_invoke_multiple(), _field_invoke_multiple_default(), _locale_import_one_string(), _locale_import_parse_arithmetic(), _locale_import_read_po(), _node_query_node_access_alter(), _node_revision_access(), _user_mail_notify(), aggregator_save_category(), comment_access(), comment_reply(), dblog_filter_form_submit(), drupal_parse_dependency(), field_access(), field_behaviors_widget(), field_permission_example_field_access(), field_sql_storage_field_storage_write(), field_ui_display_overview_multistep_js(), field_ui_display_overview_multistep_submit(), hook_field_access(), hook_field_storage_write(), hook_locale(), hook_node_access(), hook_node_grants_alter(), hook_openid(), hook_query_TAG_alter(), locale_locale(), locale_translation_filter_form_submit(), menu_link_maintain(), node_access(), node_access_example_node_access(), node_access_example_node_grants(), node_access_grants(), node_node_access(), node_save(), node_type_form_submit(), simpletest_example_node_access(), taxonomy_term_save(), theme_menu_overview_form(), update_settings_submit(), user_admin(), user_filter_form_submit(), user_register_submit(), and user_save().

const DRUPAL_ROOT getcwd()

Defines the root directory of the Drupal installation.

Definition at line 6 of file update.php.

if (update_access_allowed()) else
Initial value:
{
$output = update_access_denied_page()
$output
$output
Definition: authorize.php:93
update_access_denied_page
update_access_denied_page()
Definition: update.php:285

Definition at line 502 of file update.php.

const MAINTENANCE_MODE 'update'

Global flag indicating that update.php is being run.

When this flag is set, various operations do not take place, such as invoking hook_init() and hook_exit(), css/js preprocessing, and translation.

Definition at line 28 of file update.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: xmlrpc.php File Reference

Variables
xmlrpc.php File Reference

Go to the source code of this file.

Variables

const DRUPAL_ROOT getcwd()

Detailed Description

PHP page for handling incoming XML-RPC requests from clients.

Definition in file xmlrpc.php.

Variable Documentation

const DRUPAL_ROOT getcwd()

Root directory of Drupal installation.

Definition at line 11 of file xmlrpc.php.

Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- $ -

  • $attributes : block.tpl.php , comment-wrapper.tpl.php , field.tpl.php , html.tpl.php , comment.tpl.php , node.tpl.php , user-profile-category.tpl.php , node.tpl.php , user-profile-item.tpl.php , user-profile.tpl.php , comment.tpl.php , overlay.tpl.php , comment-wrapper.tpl.php , comment.tpl.php , search-result.tpl.php , maintenance-page.tpl.php , node.tpl.php
  • $author : comment.tpl.php
  • $base_url : book-export-html.tpl.php
  • $block_html_id : block.tpl.php
  • $breadcrumb : page.tpl.php
  • $children : book-node-export-html.tpl.php
  • $choice : poll-vote.tpl.php
  • $classes : html.tpl.php , maintenance-page.tpl.php , taxonomy-term.tpl.php , toolbar.tpl.php , comment-wrapper.tpl.php , comment.tpl.php , maintenance-page.tpl.php , node.tpl.php , maintenance-page.tpl.php , contextual-links-example-object.tpl.php , block.tpl.php , comment-wrapper.tpl.php , comment.tpl.php , field.tpl.php , node.tpl.php , search-result.tpl.php
  • $conf : authorize.php , default.settings.php , update.php
  • $configurable_timezones : update.php
  • $content : contextual-links-example-object.tpl.php , aggregator-wrapper.tpl.php , book-node-export-html.tpl.php , profile-wrapper.tpl.php , maintenance-page.tpl.php , region.tpl.php , maintenance-page.tpl.php
  • $content_attributes : node.tpl.php , block.tpl.php , comment.tpl.php , field.tpl.php , node.tpl.php , overlay.tpl.php , comment.tpl.php , node.tpl.php , comment.tpl.php
  • $contents : book-export-html.tpl.php
  • $created : comment.tpl.php
  • $databases : default.settings.php
  • $depth : book-node-export-html.tpl.php
  • $dir : book-export-html.tpl.php
  • $div_close : book-export-html.tpl.php
  • $drupal_hash_salt : default.settings.php
  • $drupal_test_info : drupal_web_test_case.php
  • $feed_age : aggregator-summary-item.tpl.php
  • $feed_icons : page.tpl.php
  • $feed_title : aggregator-item.tpl.php , aggregator-summary-item.tpl.php
  • $feed_url : aggregator-item.tpl.php , aggregator-summary-item.tpl.php
  • $form_submit : block-admin-display-form.tpl.php
  • $forum_id : forum-list.tpl.php
  • $front_page : maintenance-page.tpl.php , page.tpl.php
  • $grddl_profile : html.tpl.php
  • $head : book-export-html.tpl.php , html.tpl.php , maintenance-page.tpl.php
  • $head_title : html.tpl.php , maintenance-page.tpl.php
  • $header : forum-topic-list.tpl.php , maintenance-page.tpl.php
  • $help : maintenance-page.tpl.php
  • $html_entities : unicode.entities.inc
  • $info : color.inc
  • $item_attributes : field.tpl.php
  • $last_checked : aggregator-feed-source.tpl.php
  • $links : poll-results--block.tpl.php , node.tpl.php
  • $logo : page.tpl.php , maintenance-page.tpl.php , page.tpl.php
  • $messages : page.tpl.php , maintenance-page.tpl.php , page.tpl.php
  • $module : search-results.tpl.php
  • $module_list : authorize.php
  • $name : profile-listing.tpl.php
  • $node_url : node.tpl.php
  • $op : update.php
  • $output : authorize.php
  • $page : overlay.tpl.php , html.tpl.php
  • $page_bottom : maintenance-page.tpl.php , html.tpl.php
  • $page_top : html.tpl.php , maintenance-page.tpl.php
  • $pager : forum-topic-list.tpl.php , search-results.tpl.php , aggregator-wrapper.tpl.php
  • $percentage : poll-bar--block.tpl.php , poll-bar.tpl.php
  • $permalink : comment.tpl.php
  • $picture : comment.tpl.php
  • $profile_items : user-profile-category.tpl.php
  • $rdf_namespaces : html.tpl.php
  • $results : poll-results.tpl.php
  • $row : block-admin-display-form.tpl.php
  • $scripts : maintenance-page.tpl.php , html.tpl.php , maintenance-page.tpl.php
  • $search_form : search-block-form.tpl.php
  • $search_results : search-results.tpl.php
  • $secondary_menu : page.tpl.php
  • $show_messages : authorize.php
  • $site_fields : maintenance-page.tpl.php
  • $site_html : maintenance-page.tpl.php
  • $site_name : page.tpl.php , maintenance-page.tpl.php , page.tpl.php
  • $site_slogan : maintenance-page.tpl.php , page.tpl.php
  • $site_title : maintenance-page.tpl.php
  • $snippet : search-result.tpl.php
  • $source_date : aggregator-item.tpl.php
  • $source_description : aggregator-feed-source.tpl.php
  • $source_icon : aggregator-feed-source.tpl.php
  • $source_image : aggregator-feed-source.tpl.php
  • $source_title : aggregator-item.tpl.php , aggregator-summary-item.tpl.php
  • $source_url : aggregator-summary-items.tpl.php , aggregator-feed-source.tpl.php
  • $styles : html.tpl.php , maintenance-page.tpl.php
  • $submitted : comment.tpl.php , node.tpl.php
  • $summary_list : aggregator-summary-items.tpl.php
  • $term_name : taxonomy-term.tpl.php
  • $text_form : theming-example-text-form.tpl.php
  • $title : node.tpl.php , book-export-html.tpl.php , accordion.tpl.php , search-result.tpl.php , user-profile-item.tpl.php , comment.tpl.php , contextual-links-example-object.tpl.php , poll-bar.tpl.php , poll-bar--block.tpl.php , aggregator-summary-items.tpl.php , overlay.tpl.php , book-node-export-html.tpl.php , node.tpl.php
  • $title_attributes : overlay.tpl.php , comment.tpl.php , search-result.tpl.php
  • $topic_id : forum-topic-list.tpl.php
  • $topics : forums.tpl.php
  • $tree : book-navigation.tpl.php
  • $update_free_access : default.settings.php
  • $url : search-result.tpl.php
  • $user_picture : profile-listing.tpl.php , node.tpl.php , profile-block.tpl.php
  • $value : user-profile-item.tpl.php
  • $vote : poll-vote.tpl.php
  • $zebra : comment.tpl.php
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- _ -

  • __pad0__ : forum-submitted.tpl.php , search-results.tpl.php , page.tpl.php
  • _action_example_page() : action_example.module
  • _aggregator_category_title() : aggregator.module
  • _aggregator_characters() : aggregator.processor.inc
  • _aggregator_get_variables() : aggregator.module
  • _aggregator_has_categories() : aggregator.module
  • _aggregator_items() : aggregator.module
  • _aggregator_page_list() : aggregator.pages.inc
  • _aggregator_parse_opml() : aggregator.admin.inc
  • _ajax_example_get_first_dropdown_options() : ajax_example.module
  • _ajax_example_get_second_dropdown_options() : ajax_example.module
  • _authorize_filetransfer_connection_settings() : authorize.inc
  • _authorize_filetransfer_connection_settings_set_defaults() : authorize.inc
  • _batch_api_percentage() : batch.inc
  • _batch_current_set() : batch.inc
  • _batch_do() : batch.inc
  • _batch_example_get_http_requests() : batch_example.module
  • _batch_example_update_http_requests() : batch_example.module
  • _batch_finished() : batch.inc
  • _batch_next_set() : batch.inc
  • _batch_page() : batch.inc
  • _batch_populate_queue() : form.inc
  • _batch_process() : batch.inc
  • _batch_progress_page_js() : batch.inc
  • _batch_progress_page_nojs() : batch.inc
  • _batch_queue() : form.inc
  • _batch_shutdown() : batch.inc
  • _batch_start() : batch.inc
  • _block_compare() : block.admin.inc
  • _block_custom_theme() : block.module
  • _block_get_cache_id() : block.module
  • _block_get_renderable_array() : block.module
  • _block_load_blocks() : block.module
  • _block_rehash() : block.module
  • _block_render_blocks() : block.module
  • _block_themes_access() : block.module
  • _blog_post_exists() : blog.module
  • _book_add_form_elements() : book.module
  • _book_admin_table() : book.admin.inc
  • _book_admin_table_tree() : book.admin.inc
  • _book_flatten_menu() : book.module
  • _book_install_type_create() : book.install
  • _book_link_defaults() : book.module
  • _book_node_is_removable() : book.module
  • _book_outline_access() : book.module
  • _book_outline_remove_access() : book.module
  • _book_parent_depth_limit() : book.module
  • _book_parent_select() : book.module
  • _book_toc_recurse() : book.module
  • _book_update_outline() : book.module
  • _cache_get_object() : cache.inc
  • _color_blend() : color.module
  • _color_gd() : color.module
  • _color_hsl2rgb() : color.module
  • _color_html_alter() : color.module
  • _color_hue2rgb() : color.module
  • _color_pack() : color.module
  • _color_page_alter() : color.module
  • _color_render_images() : color.module
  • _color_rewrite_stylesheet() : color.module
  • _color_rgb2hsl() : color.module
  • _color_save_stylesheet() : color.module
  • _color_shift() : color.module
  • _color_theme_select_form_alter() : color.module
  • _color_unpack() : color.module
  • _comment_body_field_create() : comment.module
  • _comment_get_modes() : comment.module
  • _comment_per_page() : comment.module
  • _comment_update_node_statistics() : comment.module
  • _contact_personal_tab_access() : contact.module
  • _country_get_predefined_list() : iso.inc
  • _db_create_keys_sql() : database.inc
  • _dblog_get_message_types() : dblog.module
  • _drupal_bootstrap_configuration() : bootstrap.inc
  • _drupal_bootstrap_database() : bootstrap.inc
  • _drupal_bootstrap_full() : common.inc
  • _drupal_bootstrap_page_cache() : bootstrap.inc
  • _drupal_bootstrap_page_header() : bootstrap.inc
  • _drupal_bootstrap_variables() : bootstrap.inc
  • _drupal_build_css_path() : common.inc
  • _drupal_decode_exception() : errors.inc
  • _drupal_default_html_head() : common.inc
  • _drupal_depth_first_search() : graph.inc
  • _drupal_error_handler() : bootstrap.inc
  • _drupal_error_handler_real() : errors.inc
  • _drupal_exception_handler() : bootstrap.inc
  • _drupal_flush_css_js() : common.inc
  • _drupal_get_last_caller() : errors.inc
  • _drupal_html_to_mail_urls() : mail.inc
  • _drupal_html_to_text_clean() : mail.inc
  • _drupal_html_to_text_pad() : mail.inc
  • _drupal_http_use_proxy() : common.inc
  • _drupal_load_stylesheet() : common.inc
  • _drupal_log_error() : errors.inc
  • _drupal_maintenance_theme() : theme.maintenance.inc
  • _drupal_render_exception_safe() : errors.inc
  • _drupal_schema_initialize() : common.inc
  • _drupal_session_close() : session.inc
  • _drupal_session_delete_cookie() : session.inc
  • _drupal_session_destroy() : session.inc
  • _drupal_session_garbage_collection() : session.inc
  • _drupal_session_open() : session.inc
  • _drupal_session_read() : session.inc
  • _drupal_session_write() : session.inc
  • _drupal_set_preferred_header_name() : bootstrap.inc
  • _drupal_shutdown_function() : bootstrap.inc
  • _drupal_theme_access() : theme.inc
  • _drupal_theme_initialize() : theme.inc
  • _drupal_wrap_mail_line() : mail.inc
  • _element_validate_integer() : field.module
  • _element_validate_integer_positive() : field.module
  • _element_validate_number() : field.module
  • _field_example_page() : field_example.module
  • _field_extra_fields_pre_render() : field.module
  • _field_filter_items() : field.module
  • _field_filter_xss_allowed_tags() : field.module
  • _field_filter_xss_display_allowed_tags() : field.module
  • _field_form_state_parents() : field.form.inc
  • _field_info_collate_fields() : field.info.inc
  • _field_info_collate_types() : field.info.inc
  • _field_info_field_cache() : field.info.inc
  • _field_info_prepare_extra_fields() : field.info.inc
  • _field_info_prepare_field() : field.info.inc
  • _field_info_prepare_instance() : field.info.inc
  • _field_info_prepare_instance_display() : field.info.inc
  • _field_info_prepare_instance_widget() : field.info.inc
  • _field_invoke() : field.attach.inc
  • _field_invoke_default() : field.attach.inc
  • _field_invoke_get_instances() : field.attach.inc
  • _field_invoke_multiple() : field.attach.inc
  • _field_invoke_multiple_default() : field.attach.inc
  • _field_language_suggestion() : field.multilingual.inc
  • _field_permission_example_page() : field_permission_example.module
  • _field_sort_items() : field.module
  • _field_sort_items_helper() : field.module
  • _field_sort_items_value_helper() : field.module
  • _field_sql_storage_columnname() : field_sql_storage.module
  • _field_sql_storage_indexname() : field_sql_storage.module
  • _field_sql_storage_query_columnname() : field_sql_storage.module
  • _field_sql_storage_query_field_conditions() : field_sql_storage.module
  • _field_sql_storage_query_join_entity() : field_sql_storage.module
  • _field_sql_storage_revision_tablename() : field_sql_storage.module
  • _field_sql_storage_schema() : field_sql_storage.module
  • _field_sql_storage_tablename() : field_sql_storage.module
  • _field_ui_add_default_view_mode_settings() : field_ui.admin.inc
  • _field_ui_bundle_admin_path() : field_ui.module
  • _field_ui_field_name_exists() : field_ui.admin.inc
  • _field_ui_field_overview_form_validate_add_existing() : field_ui.admin.inc
  • _field_ui_field_overview_form_validate_add_new() : field_ui.admin.inc
  • _field_ui_reduce_order() : field_ui.admin.inc
  • _field_ui_view_mode_menu_access() : field_ui.module
  • _field_write_instance() : field.crud.inc
  • _file_field_get_description_from_element() : file.field.inc
  • _file_generic_settings_extensions() : file.field.inc
  • _file_generic_settings_file_directory_validate() : file.field.inc
  • _file_generic_settings_max_filesize() : file.field.inc
  • _filter_autop() : filter.module
  • _filter_autop_tips() : filter.module
  • _filter_disable_format_access() : filter.module
  • _filter_example_filter_foo_process() : filter_example.module
  • _filter_example_filter_foo_settings() : filter_example.module
  • _filter_example_filter_foo_tips() : filter_example.module
  • _filter_example_filter_time_prepare() : filter_example.module
  • _filter_example_filter_time_process() : filter_example.module
  • _filter_example_filter_time_tips() : filter_example.module
  • _filter_example_information() : filter_example.module
  • _filter_format_is_cacheable() : filter.module
  • _filter_html() : filter.module
  • _filter_html_escape() : filter.module
  • _filter_html_escape_tips() : filter.module
  • _filter_html_settings() : filter.module
  • _filter_html_tips() : filter.module
  • _filter_htmlcorrector() : filter.module
  • _filter_list_cmp() : filter.module
  • _filter_tips() : filter.module
  • _filter_url() : filter.module
  • _filter_url_escape_comments() : filter.module
  • _filter_url_parse_email_links() : filter.module
  • _filter_url_parse_full_links() : filter.module
  • _filter_url_parse_partial_links() : filter.module
  • _filter_url_settings() : filter.module
  • _filter_url_tips() : filter.module
  • _filter_url_trim() : filter.module
  • _filter_xss_attributes() : common.inc
  • _filter_xss_split() : common.inc
  • _fix_gpc_magic() : common.inc
  • _fix_gpc_magic_files() : common.inc
  • _form_builder_handle_input_element() : form.inc
  • _form_button_was_clicked() : form.inc
  • _form_element_triggered_scripted_submission() : form.inc
  • _form_example_element_info() : form_example_elements.inc
  • _form_example_element_theme() : form_example_elements.inc
  • _form_example_steps() : form_example_wizard.inc
  • _form_options_flatten() : form.inc
  • _form_set_class() : form.inc
  • _form_validate() : form.inc
  • _format_date_callback() : common.inc
  • _forum_get_topic_order() : forum.module
  • _forum_node_check_node_type() : forum.module
  • _forum_parent_select() : forum.admin.inc
  • _forum_topics_unread() : forum.module
  • _forum_update_forum_index() : forum.module
  • _forum_user_last_visit() : forum.module
  • _image_effect_definitions_sort() : image.module
  • _image_field_resolution_validate() : image.field.inc
  • _image_update_7002_add_columns() : image.install
  • _image_update_7002_populate_dimensions() : image.install
  • _install_configure_form() : install.core.inc
  • _install_module_batch() : install.core.inc
  • _install_profile_modules_finished() : install.core.inc
  • _install_select_profile() : install.core.inc
  • _list_update_7001_extract_allowed_values() : list.install
  • _list_values_in_use() : list.module
  • _locale_batch_build() : locale.inc
  • _locale_batch_import() : locale.inc
  • _locale_batch_language_finished() : locale.inc
  • _locale_batch_system_finished() : locale.inc
  • _locale_export_get_strings() : locale.inc
  • _locale_export_po() : locale.inc
  • _locale_export_po_generate() : locale.inc
  • _locale_export_remove_plural() : locale.inc
  • _locale_export_string() : locale.inc
  • _locale_export_wrap() : locale.inc
  • _locale_get_predefined_list() : iso.inc
  • _locale_import_append_plural() : locale.inc
  • _locale_import_message() : locale.inc
  • _locale_import_one_string() : locale.inc
  • _locale_import_one_string_db() : locale.inc
  • _locale_import_parse_arithmetic() : locale.inc
  • _locale_import_parse_header() : locale.inc
  • _locale_import_parse_plural_forms() : locale.inc
  • _locale_import_parse_quoted() : locale.inc
  • _locale_import_po() : locale.inc
  • _locale_import_read_po() : locale.inc
  • _locale_import_shorten_comments() : locale.inc
  • _locale_import_tokenize_formula() : locale.inc
  • _locale_invalidate_js() : locale.inc
  • _locale_languages_common_controls() : locale.admin.inc
  • _locale_languages_configure_form_language_table() : locale.admin.inc
  • _locale_parse_js_file() : locale.inc
  • _locale_prepare_predefined_list() : locale.inc
  • _locale_rebuild_js() : locale.inc
  • _locale_translate_language_list() : locale.inc
  • _locale_translate_seek() : locale.inc
  • _locale_translate_seek_query() : locale.inc
  • _lock_id() : lock.inc
  • _menu_build_tree() : menu.inc
  • _menu_check_access() : menu.inc
  • _menu_clear_page_cache() : menu.inc
  • _menu_delete_item() : menu.inc
  • _menu_example_basic_instructions() : menu_example.module
  • _menu_example_mappings() : menu_example.module
  • _menu_example_menu_page() : menu_example.module
  • _menu_example_simple_title_callback() : menu_example.module
  • _menu_find_router_path() : menu.inc
  • _menu_get_options() : menu.module
  • _menu_item_localize() : menu.inc
  • _menu_link_build() : menu.inc
  • _menu_link_find_parent() : menu.inc
  • _menu_link_map_translate() : menu.inc
  • _menu_link_move_children() : menu.inc
  • _menu_link_parents_set() : menu.inc
  • _menu_link_translate() : menu.inc
  • _menu_load_objects() : menu.inc
  • _menu_navigation_links_rebuild() : menu.inc
  • _menu_overview_tree_form() : menu.admin.inc
  • _menu_parent_depth_limit() : menu.module
  • _menu_parents_recurse() : menu.module
  • _menu_router_build() : menu.inc
  • _menu_router_cache() : menu.inc
  • _menu_router_save() : menu.inc
  • _menu_set_expanded_menus() : menu.inc
  • _menu_site_is_offline() : menu.inc
  • _menu_translate() : menu.inc
  • _menu_tree_check_access() : menu.inc
  • _menu_tree_data() : menu.inc
  • _menu_update_parental_status() : menu.inc
  • _mime_header_decode() : unicode.inc
  • _module_build_dependencies() : module.inc
  • _node_access_rebuild_batch_finished() : node.module
  • _node_access_rebuild_batch_operation() : node.module
  • _node_add_access() : node.module
  • _node_characters() : content_types.inc
  • _node_example_installed_fields() : node_example.module
  • _node_example_installed_instances() : node_example.module
  • _node_extract_type() : node.module
  • _node_index_node() : node.module
  • _node_mass_update_batch_finished() : node.admin.inc
  • _node_mass_update_batch_process() : node.admin.inc
  • _node_mass_update_helper() : node.admin.inc
  • _node_query_node_access_alter() : node.module
  • _node_rankings() : node.module
  • _node_revision_access() : node.module
  • _node_save_revision() : node.module
  • _node_types_build() : node.module
  • _openid_create_message() : openid.inc
  • _openid_dh_base64_to_long() : openid.inc
  • _openid_dh_binary_to_long() : openid.inc
  • _openid_dh_long_to_base64() : openid.inc
  • _openid_dh_long_to_binary() : openid.inc
  • _openid_dh_rand() : openid.inc
  • _openid_dh_xorsecret() : openid.inc
  • _openid_encode_message() : openid.inc
  • _openid_get_bytes() : openid.inc
  • _openid_get_math_library() : openid.inc
  • _openid_get_params() : openid.inc
  • _openid_hmac() : openid.inc
  • _openid_invalid_openid_transition() : openid.inc
  • _openid_is_xri() : openid.inc
  • _openid_link_href() : openid.inc
  • _openid_math_add() : openid.inc
  • _openid_math_cmp() : openid.inc
  • _openid_math_div() : openid.inc
  • _openid_math_mod() : openid.inc
  • _openid_math_mul() : openid.inc
  • _openid_math_pow() : openid.inc
  • _openid_math_powmod() : openid.inc
  • _openid_meta_httpequiv() : openid.inc
  • _openid_nonce() : openid.inc
  • _openid_parse_message() : openid.inc
  • _openid_response() : openid.inc
  • _openid_select_service() : openid.inc
  • _openid_signature() : openid.inc
  • _openid_url_normalize() : openid.inc
  • _openid_user_login_form_alter() : openid.module
  • _openid_xrds_discovery() : openid.module
  • _openid_xrds_parse() : openid.inc
  • _openid_xri_discovery() : openid.module
  • _openid_xri_normalize() : openid.inc
  • _options_form_to_storage() : options.module
  • _options_get_options() : options.module
  • _options_prepare_options() : options.module
  • _options_properties() : options.module
  • _options_storage_to_form() : options.module
  • _overlay_region_list() : overlay.module
  • _password_base64_encode() : password.inc
  • _password_crypt() : password.inc
  • _password_enforce_log2_boundaries() : password.inc
  • _password_generate_salt() : password.inc
  • _password_get_count_log2() : password.inc
  • _password_itoa64() : password.inc
  • _php_filter_tips() : php.module
  • _poll_choice_form() : poll.module
  • _poll_menu_access() : poll.module
  • _profile_field_serialize() : profile.module
  • _profile_field_types() : profile.module
  • _profile_form_explanation() : profile.module
  • _profile_get_fields() : profile.module
  • _profile_update_user_fields() : profile.module
  • _rdf_example_installed_fields() : rdf_example.install
  • _rdf_example_installed_instances() : rdf_example.install
  • _rdf_get_default_mapping() : rdf.module
  • _rdf_mapping_load() : rdf.module
  • _registry_check_code() : bootstrap.inc
  • _registry_parse_file() : registry.inc
  • _registry_parse_files() : registry.inc
  • _registry_update() : registry.inc
  • _search_excerpt_match_filter() : search.module
  • _search_excerpt_replace() : search.module
  • _search_get_module_names() : search.admin.inc
  • _search_index_truncate() : search.module
  • _search_menu_access() : search.module
  • _shortcut_link_form_elements() : shortcut.admin.inc
  • _simpletest_autoload_psr0() : simpletest.module
  • _simpletest_batch_finished() : simpletest.module
  • _simpletest_batch_operation() : simpletest.module
  • _simpletest_example_explanation() : simpletest_example.module
  • _simpletest_format_summary_line() : simpletest.module
  • _statistics_format_item() : statistics.module
  • _statistics_link() : statistics.module
  • _system_batch_theme() : system.module
  • _system_date_format_types_build() : system.module
  • _system_date_formats_build() : system.module
  • _system_default_theme_features() : system.module
  • _system_info_add_path() : system.module
  • _system_is_incompatible() : system.admin.inc
  • _system_modules_build_row() : system.admin.inc
  • _system_rebuild_module_data() : system.module
  • _system_rebuild_theme_data() : system.module
  • _system_sort_requirements() : system.module
  • _system_theme_settings_validate_path() : system.admin.inc
  • _system_themes_access() : system.module
  • _system_update_bootstrap_status() : system.module
  • _taxonomy_get_tid_from_term() : taxonomy.module
  • _template_preprocess_default_variables() : theme.inc
  • _text_sanitize() : text.module
  • _theme_build_registry() : theme.inc
  • _theme_load_offline_registry() : theme.maintenance.inc
  • _theme_load_registry() : theme.inc
  • _theme_process_registry() : theme.inc
  • _theme_registry_callback() : theme.inc
  • _theme_save_registry() : theme.inc
  • _theme_table_cell() : theme.inc
  • _token_example_get_comment() : token_example.module
  • _token_example_get_file() : token_example.module
  • _token_example_get_node() : token_example.module
  • _token_example_get_taxonomy_term() : token_example.module
  • _token_example_get_user() : token_example.module
  • _toolbar_is_collapsed() : toolbar.module
  • _tracker_add() : tracker.module
  • _tracker_calculate_changed() : tracker.module
  • _tracker_myrecent_access() : tracker.module
  • _tracker_remove() : tracker.module
  • _tracker_user_access() : tracker.module
  • _translation_tab_access() : translation.module
  • _trigger_comment() : trigger.module
  • _trigger_example_first_time_login() : trigger_example.module
  • _trigger_get_all_info() : trigger.module
  • _trigger_node() : trigger.module
  • _trigger_normalize_comment_context() : trigger.module
  • _trigger_normalize_node_context() : trigger.module
  • _trigger_normalize_user_context() : trigger.module
  • _trigger_tab_information() : trigger.module
  • _trigger_taxonomy() : trigger.module
  • _trigger_user() : trigger.module
  • _unicode_caseflip() : unicode.inc
  • _unicode_check() : unicode.inc
  • _update_7000_field_create_field() : field.install
  • _update_7000_field_create_instance() : field.install
  • _update_7000_field_delete_field() : field.install
  • _update_7000_field_delete_instance() : field.install
  • _update_7000_field_read_fields() : field.install
  • _update_7000_field_sql_storage_write() : field_sql_storage.install
  • _update_7000_node_get_types() : node.install
  • _update_7000_user_role_grant_permissions() : user.install
  • _update_7002_taxonomy_get_vocabularies() : taxonomy.install
  • _update_authorize_clear_update_status() : update.authorize.inc
  • _update_batch_create_message() : update.authorize.inc
  • _update_build_fetch_url() : update.fetch.inc
  • _update_cache_clear() : update.module
  • _update_cache_get() : update.module
  • _update_cache_set() : update.module
  • _update_create_fetch_task() : update.fetch.inc
  • _update_cron_notify() : update.fetch.inc
  • _update_fetch_data() : update.fetch.inc
  • _update_get_cache_multiple() : update.module
  • _update_get_cached_available_releases() : update.module
  • _update_get_fetch_url_base() : update.fetch.inc
  • _update_manager_cache_directory() : update.module
  • _update_manager_check_backends() : update.manager.inc
  • _update_manager_extract_directory() : update.module
  • _update_manager_unique_identifier() : update.module
  • _update_message_text() : update.module
  • _update_no_data() : update.module
  • _update_process_fetch_task() : update.fetch.inc
  • _update_process_info_list() : update.compare.inc
  • _update_project_status_sort() : update.module
  • _update_refresh() : update.fetch.inc
  • _update_requirement_check() : update.install
  • _user_cancel() : user.module
  • _user_cancel_session_regenerate() : user.module
  • _user_categories() : user.module
  • _user_mail_notify() : user.module
  • _user_mail_text() : user.module
  • _user_sort() : user.module
  • _vertical_tabs_example_explanation() : vertical_tabs_example.module
  • _xmlrpc() : xmlrpc.inc
  • _xmlrpc_example_alter_add() : xmlrpc_example.module
  • _xmlrpc_example_alter_subtract() : xmlrpc_example.module
  • _xmlrpc_example_server_add() : xmlrpc_example.module
  • _xmlrpc_example_server_subtract() : xmlrpc_example.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- a -

  • action_example_action_info() : action_example.module
  • action_example_basic_action() : action_example.module
  • action_example_menu() : action_example.module
  • action_example_node_sticky_action() : action_example.module
  • action_example_node_sticky_action_form() : action_example.module
  • action_example_node_sticky_action_submit() : action_example.module
  • action_example_node_sticky_action_validate() : action_example.module
  • action_example_unblock_user_action() : action_example.module
  • actions_actions_map() : actions.inc
  • actions_delete() : actions.inc
  • actions_do() : actions.inc
  • actions_function_lookup() : actions.inc
  • actions_get_all_actions() : actions.inc
  • actions_list() : actions.inc
  • actions_load() : actions.inc
  • actions_save() : actions.inc
  • actions_synchronize() : actions.inc
  • aggregator_admin_form() : aggregator.admin.inc
  • aggregator_admin_form_submit() : aggregator.admin.inc
  • aggregator_admin_overview() : aggregator.admin.inc
  • aggregator_admin_refresh_feed() : aggregator.admin.inc
  • aggregator_admin_remove_feed() : aggregator.admin.inc
  • aggregator_admin_remove_feed_submit() : aggregator.admin.inc
  • aggregator_aggregator_fetch() : aggregator.fetcher.inc
  • aggregator_aggregator_fetch_info() : aggregator.fetcher.inc
  • aggregator_aggregator_parse() : aggregator.parser.inc
  • aggregator_aggregator_parse_info() : aggregator.parser.inc
  • aggregator_aggregator_process() : aggregator.processor.inc
  • aggregator_aggregator_process_info() : aggregator.processor.inc
  • aggregator_aggregator_remove() : aggregator.processor.inc
  • aggregator_block_configure() : aggregator.module
  • aggregator_block_info() : aggregator.module
  • aggregator_block_save() : aggregator.module
  • aggregator_block_view() : aggregator.module
  • aggregator_categorize_items() : aggregator.pages.inc
  • aggregator_categorize_items_submit() : aggregator.pages.inc
  • aggregator_category_load() : aggregator.module
  • AGGREGATOR_CLEAR_NEVER : aggregator.module
  • aggregator_cron() : aggregator.module
  • aggregator_cron_queue_info() : aggregator.module
  • aggregator_element_data() : aggregator.parser.inc
  • aggregator_element_end() : aggregator.parser.inc
  • aggregator_element_start() : aggregator.parser.inc
  • aggregator_expire() : aggregator.processor.inc
  • aggregator_feed_items_load() : aggregator.pages.inc
  • aggregator_feed_load() : aggregator.module
  • aggregator_filter_xss() : aggregator.module
  • aggregator_form_aggregator_admin_form_alter() : aggregator.processor.inc
  • aggregator_form_category() : aggregator.admin.inc
  • aggregator_form_category_submit() : aggregator.admin.inc
  • aggregator_form_category_validate() : aggregator.admin.inc
  • aggregator_form_feed() : aggregator.admin.inc
  • aggregator_form_feed_submit() : aggregator.admin.inc
  • aggregator_form_feed_validate() : aggregator.admin.inc
  • aggregator_form_opml() : aggregator.admin.inc
  • aggregator_form_opml_submit() : aggregator.admin.inc
  • aggregator_form_opml_validate() : aggregator.admin.inc
  • aggregator_help() : aggregator.module
  • aggregator_menu() : aggregator.module
  • aggregator_page_categories() : aggregator.pages.inc
  • aggregator_page_category() : aggregator.pages.inc
  • aggregator_page_category_form() : aggregator.pages.inc
  • aggregator_page_last() : aggregator.pages.inc
  • aggregator_page_opml() : aggregator.pages.inc
  • aggregator_page_rss() : aggregator.pages.inc
  • aggregator_page_source() : aggregator.pages.inc
  • aggregator_page_source_form() : aggregator.pages.inc
  • aggregator_page_sources() : aggregator.pages.inc
  • aggregator_parse_feed() : aggregator.parser.inc
  • aggregator_parse_w3cdtf() : aggregator.parser.inc
  • aggregator_permission() : aggregator.module
  • aggregator_refresh() : aggregator.module
  • aggregator_remove() : aggregator.module
  • aggregator_sanitize_configuration() : aggregator.module
  • aggregator_save_category() : aggregator.module
  • aggregator_save_feed() : aggregator.module
  • aggregator_save_item() : aggregator.processor.inc
  • aggregator_schema() : aggregator.install
  • aggregator_theme() : aggregator.module
  • aggregator_uninstall() : aggregator.install
  • aggregator_update_7000() : aggregator.install
  • aggregator_update_7001() : aggregator.install
  • aggregator_update_7002() : aggregator.install
  • aggregator_update_7003() : aggregator.install
  • aggregator_view() : aggregator.admin.inc
  • ajax_base_page_theme() : ajax.inc
  • ajax_command_after() : ajax.inc
  • ajax_command_alert() : ajax.inc
  • ajax_command_append() : ajax.inc
  • ajax_command_before() : ajax.inc
  • ajax_command_changed() : ajax.inc
  • ajax_command_css() : ajax.inc
  • ajax_command_data() : ajax.inc
  • ajax_command_html() : ajax.inc
  • ajax_command_insert() : ajax.inc
  • ajax_command_invoke() : ajax.inc
  • ajax_command_prepend() : ajax.inc
  • ajax_command_remove() : ajax.inc
  • ajax_command_replace() : ajax.inc
  • ajax_command_restripe() : ajax.inc
  • ajax_command_settings() : ajax.inc
  • ajax_deliver() : ajax.inc
  • ajax_example_add_more() : ajax_example_graceful_degradation.inc
  • ajax_example_add_more_add_one() : ajax_example_graceful_degradation.inc
  • ajax_example_add_more_callback() : ajax_example_graceful_degradation.inc
  • ajax_example_add_more_remove_one() : ajax_example_graceful_degradation.inc
  • ajax_example_add_more_submit() : ajax_example_graceful_degradation.inc
  • ajax_example_advanced_commands() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_after_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_alert_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_append_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_before_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_changed_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_css_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_data_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_html_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_prepend_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_remove_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_restripe_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_restripe_num_rows() : ajax_example_advanced.inc
  • ajax_example_autocheckboxes() : ajax_example.module
  • ajax_example_autocheckboxes_callback() : ajax_example.module
  • ajax_example_autotextfields() : ajax_example.module
  • ajax_example_autotextfields_callback() : ajax_example.module
  • ajax_example_dependent_dropdown() : ajax_example.module
  • ajax_example_dependent_dropdown_callback() : ajax_example.module
  • ajax_example_dependent_dropdown_degrades() : ajax_example_graceful_degradation.inc
  • ajax_example_dependent_dropdown_degrades_first_callback() : ajax_example_graceful_degradation.inc
  • ajax_example_dependent_dropdown_degrades_submit() : ajax_example_graceful_degradation.inc
  • ajax_example_dynamic_sections() : ajax_example_graceful_degradation.inc
  • ajax_example_dynamic_sections_select_callback() : ajax_example_graceful_degradation.inc
  • ajax_example_dynamic_sections_submit() : ajax_example_graceful_degradation.inc
  • ajax_example_dynamic_sections_validate() : ajax_example_graceful_degradation.inc
  • ajax_example_form_node_callback() : ajax_example_node_form_alter.inc
  • ajax_example_form_node_form_alter() : ajax_example_node_form_alter.inc
  • ajax_example_intro() : ajax_example.module
  • ajax_example_menu() : ajax_example.module
  • ajax_example_node_by_author_ajax_callback() : ajax_example_autocomplete.inc
  • ajax_example_node_by_author_autocomplete() : ajax_example_autocomplete.inc
  • ajax_example_node_by_author_autocomplete_submit() : ajax_example_autocomplete.inc
  • ajax_example_node_by_author_autocomplete_validate() : ajax_example_autocomplete.inc
  • ajax_example_node_by_author_node_autocomplete_callback() : ajax_example_autocomplete.inc
  • ajax_example_node_delete() : ajax_example_node_form_alter.inc
  • ajax_example_node_insert() : ajax_example_node_form_alter.inc
  • ajax_example_node_load() : ajax_example_node_form_alter.inc
  • ajax_example_node_prepare() : ajax_example_node_form_alter.inc
  • ajax_example_node_submit() : ajax_example_node_form_alter.inc
  • ajax_example_node_update() : ajax_example_node_form_alter.inc
  • ajax_example_render_link() : ajax_example_misc.inc
  • ajax_example_render_link_ra() : ajax_example_misc.inc
  • ajax_example_schema() : ajax_example.install
  • ajax_example_simple_autocomplete() : ajax_example_autocomplete.inc
  • ajax_example_simple_user_autocomplete_callback() : ajax_example_autocomplete.inc
  • ajax_example_simplest() : ajax_example.module
  • ajax_example_simplest_callback() : ajax_example.module
  • ajax_example_submit_driven_ajax() : ajax_example.module
  • ajax_example_submit_driven_callback() : ajax_example.module
  • ajax_example_unique_autocomplete() : ajax_example_autocomplete.inc
  • ajax_example_unique_autocomplete_submit() : ajax_example_autocomplete.inc
  • ajax_example_unique_autocomplete_validate() : ajax_example_autocomplete.inc
  • ajax_example_unique_node_autocomplete_callback() : ajax_example_autocomplete.inc
  • ajax_example_update_7100() : ajax_example.install
  • ajax_example_wizard() : ajax_example_graceful_degradation.inc
  • ajax_example_wizard_callback() : ajax_example_graceful_degradation.inc
  • ajax_example_wizard_submit() : ajax_example_graceful_degradation.inc
  • ajax_footer() : ajax.inc
  • ajax_form_callback() : ajax.inc
  • ajax_get_form() : ajax.inc
  • ajax_link_response() : ajax_example_misc.inc
  • ajax_pre_render_element() : ajax.inc
  • ajax_prepare_response() : ajax.inc
  • ajax_process_form() : ajax.inc
  • ajax_render() : ajax.inc
  • ARCHIVE_TAR_ATT_SEPARATOR : system.tar.inc
  • ARCHIVE_TAR_END_BLOCK : system.tar.inc
  • archiver_get_archiver() : common.inc
  • archiver_get_extensions() : common.inc
  • archiver_get_info() : common.inc
  • arg() : bootstrap.inc
  • authorize_access_allowed() : authorize.php
  • authorize_access_denied_page() : authorize.php
  • authorize_filetransfer_form() : authorize.inc
  • authorize_filetransfer_form_submit() : authorize.inc
  • authorize_filetransfer_form_validate() : authorize.inc
  • authorize_get_filetransfer() : authorize.inc
  • authorize_run_operation() : authorize.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- b -

  • bartik_field__taxonomy_term_reference() : template.php
  • bartik_menu_tree() : template.php
  • bartik_preprocess_block() : template.php
  • bartik_preprocess_html() : template.php
  • bartik_preprocess_maintenance_page() : template.php
  • bartik_preprocess_node() : template.php
  • bartik_process_html() : template.php
  • bartik_process_maintenance_page() : template.php
  • bartik_process_page() : template.php
  • base_path() : common.inc
  • batch_example_batch_1() : batch_example.module
  • batch_example_batch_2() : batch_example.module
  • batch_example_finished() : batch_example.module
  • batch_example_lowest_nid() : batch_example.module
  • batch_example_menu() : batch_example.module
  • batch_example_op_1() : batch_example.module
  • batch_example_op_2() : batch_example.module
  • batch_example_simple_form() : batch_example.module
  • batch_example_simple_form_submit() : batch_example.module
  • batch_example_update_7100() : batch_example.install
  • batch_get() : form.inc
  • batch_load() : batch.inc
  • batch_process() : form.inc
  • batch_set() : form.inc
  • block_add_block_form() : block.admin.inc
  • block_add_block_form_submit() : block.admin.inc
  • block_add_block_form_validate() : block.admin.inc
  • block_admin_configure() : block.admin.inc
  • block_admin_configure_submit() : block.admin.inc
  • block_admin_configure_validate() : block.admin.inc
  • block_admin_demo() : block.admin.inc
  • block_admin_display() : block.admin.inc
  • block_admin_display_form() : block.admin.inc
  • block_admin_display_form_submit() : block.admin.inc
  • block_admin_display_prepare_blocks() : block.admin.inc
  • block_admin_paths() : block.module
  • block_block_configure() : block.module
  • block_block_info() : block.module
  • block_block_list_alter() : block.module
  • block_block_save() : block.module
  • block_block_view() : block.module
  • block_custom_block_delete() : block.admin.inc
  • block_custom_block_delete_submit() : block.admin.inc
  • block_custom_block_form() : block.module
  • block_custom_block_get() : block.module
  • block_custom_block_save() : block.module
  • BLOCK_CUSTOM_DISABLED : block.module
  • BLOCK_CUSTOM_ENABLED : block.module
  • BLOCK_CUSTOM_FIXED : block.module
  • block_example_block_configure() : block_example.module
  • block_example_block_info() : block_example.module
  • block_example_block_list_alter() : block_example.module
  • block_example_block_save() : block_example.module
  • block_example_block_view() : block_example.module
  • block_example_block_view_alter() : block_example.module
  • block_example_contents() : block_example.module
  • block_example_menu() : block_example.module
  • block_example_page() : block_example.module
  • block_example_uninstall() : block_example.install
  • block_flush_caches() : block.module
  • block_form_system_performance_settings_alter() : block.module
  • block_form_user_profile_form_alter() : block.module
  • block_get_blocks_by_region() : block.module
  • block_help() : block.module
  • block_install() : block.install
  • block_list() : block.module
  • block_load() : block.module
  • block_menu() : block.module
  • block_menu_delete() : block.module
  • block_modules_uninstalled() : block.module
  • block_page_build() : block.module
  • block_permission() : block.module
  • BLOCK_REGION_NONE : block.module
  • block_schema() : block.install
  • block_theme() : block.module
  • block_theme_initialize() : block.module
  • block_themes_enabled() : block.module
  • block_title : block-admin-display-form.tpl.php
  • block_update_7000() : block.install
  • block_update_7002() : block.install
  • block_update_7003() : block.install
  • block_update_7004() : block.install
  • block_update_7005() : block.install
  • block_update_7006() : block.install
  • block_update_7007() : block.install
  • block_update_7008() : block.install
  • block_update_dependencies() : block.install
  • block_user_presave() : block.module
  • block_user_role_delete() : block.module
  • BLOCK_VISIBILITY_LISTED : block.module
  • BLOCK_VISIBILITY_NOTLISTED : block.module
  • BLOCK_VISIBILITY_PHP : block.module
  • blocked_ip_load() : system.module
  • blog_block_configure() : blog.module
  • blog_block_info() : blog.module
  • blog_block_save() : blog.module
  • blog_block_view() : blog.module
  • blog_feed_last() : blog.pages.inc
  • blog_feed_user() : blog.pages.inc
  • blog_form() : blog.module
  • blog_help() : blog.module
  • blog_install() : blog.install
  • blog_menu() : blog.module
  • blog_menu_local_tasks_alter() : blog.module
  • blog_node_info() : blog.module
  • blog_node_view() : blog.module
  • blog_page_last() : blog.pages.inc
  • blog_page_user() : blog.pages.inc
  • blog_page_user_access() : blog.module
  • blog_rdf_mapping() : blog.module
  • blog_uninstall() : blog.install
  • blog_user_view() : blog.module
  • blog_view() : blog.module
  • book_admin_edit() : book.admin.inc
  • book_admin_edit_submit() : book.admin.inc
  • book_admin_edit_validate() : book.admin.inc
  • book_admin_overview() : book.admin.inc
  • book_admin_paths() : book.module
  • book_admin_settings() : book.admin.inc
  • book_admin_settings_validate() : book.admin.inc
  • book_block_configure() : book.module
  • book_block_info() : book.module
  • book_block_save() : book.module
  • book_block_view() : book.module
  • book_children() : book.module
  • book_entity_info_alter() : book.module
  • book_export() : book.pages.inc
  • book_export_html() : book.pages.inc
  • book_export_traverse() : book.module
  • book_form_node_delete_confirm_alter() : book.module
  • book_form_node_form_alter() : book.module
  • book_form_update() : book.module
  • book_get_books() : book.module
  • book_get_flat_menu() : book.module
  • book_help() : book.module
  • book_install() : book.install
  • book_link_load() : book.module
  • book_menu() : book.module
  • book_menu_name() : book.module
  • book_menu_subtree_data() : book.module
  • book_next() : book.module
  • book_node_delete() : book.module
  • book_node_export() : book.module
  • book_node_insert() : book.module
  • book_node_load() : book.module
  • book_node_prepare() : book.module
  • book_node_presave() : book.module
  • book_node_type_update() : book.module
  • book_node_update() : book.module
  • book_node_view() : book.module
  • book_node_view_link() : book.module
  • book_outline() : book.pages.inc
  • book_outline_form() : book.pages.inc
  • book_outline_form_submit() : book.pages.inc
  • book_page_alter() : book.module
  • book_permission() : book.module
  • book_pick_book_nojs_submit() : book.module
  • book_prev() : book.module
  • book_remove_button_submit() : book.pages.inc
  • book_remove_form() : book.pages.inc
  • book_remove_form_submit() : book.pages.inc
  • book_render() : book.pages.inc
  • book_schema() : book.install
  • book_theme() : book.module
  • book_toc() : book.module
  • book_type_is_allowed() : book.module
  • book_uninstall() : book.install
  • book_update_bid() : book.module
  • bootstrap_hooks() : bootstrap.inc
  • bootstrap_invoke_all() : bootstrap.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- c -

  • cache_clear_all() : cache.inc
  • cache_example_form_cache_clearing() : cache_example.module
  • cache_example_form_create_expiring_item() : cache_example.module
  • cache_example_form_expire_files() : cache_example.module
  • cache_example_menu() : cache_example.module
  • cache_example_page_form() : cache_example.module
  • cache_get() : cache.inc
  • cache_get_multiple() : cache.inc
  • cache_is_empty() : cache.inc
  • CACHE_PERMANENT : bootstrap.inc
  • cache_set() : cache.inc
  • CACHE_TEMPORARY : bootstrap.inc
  • callback_entity_info_label() : system.api.php
  • callback_entity_info_language() : system.api.php
  • callback_entity_info_uri() : system.api.php
  • callback_filter_prepare() : filter.api.php
  • callback_filter_process() : filter.api.php
  • callback_filter_settings() : filter.api.php
  • callback_filter_tips() : filter.api.php
  • callback_search_conditions() : search.api.php
  • check_markup() : filter.module
  • CHECK_PLAIN : bootstrap.inc
  • check_plain() : bootstrap.inc
  • check_url() : common.inc
  • color_form_system_theme_settings_alter() : color.module
  • color_form_system_themes_alter() : color.module
  • color_get_info() : color.module
  • color_get_palette() : color.module
  • color_help() : color.module
  • color_palette_color_value() : color.module
  • color_requirements() : color.install
  • color_scheme_form() : color.module
  • color_scheme_form_submit() : color.module
  • color_scheme_form_validate() : color.module
  • color_theme() : color.module
  • color_update_7001() : color.install
  • color_valid_hexadecimal_string() : color.module
  • comment_access() : comment.module
  • comment_action_info() : comment.module
  • comment_admin() : comment.admin.inc
  • comment_admin_overview() : comment.admin.inc
  • comment_admin_overview_submit() : comment.admin.inc
  • comment_admin_overview_validate() : comment.admin.inc
  • COMMENT_ANONYMOUS_MAY_CONTACT : comment.module
  • COMMENT_ANONYMOUS_MAYNOT_CONTACT : comment.module
  • COMMENT_ANONYMOUS_MUST_CONTACT : comment.module
  • comment_approve() : comment.pages.inc
  • comment_block_configure() : comment.module
  • comment_block_info() : comment.module
  • comment_block_save() : comment.module
  • comment_block_view() : comment.module
  • comment_build_content() : comment.module
  • comment_confirm_delete() : comment.admin.inc
  • comment_confirm_delete_page() : comment.admin.inc
  • comment_confirm_delete_submit() : comment.admin.inc
  • comment_count_unpublished() : comment.module
  • comment_delete() : comment.module
  • comment_delete_multiple() : comment.module
  • comment_edit_page() : comment.module
  • comment_enable() : comment.install
  • comment_entity_info() : comment.module
  • comment_field_extra_fields() : comment.module
  • comment_file_download_access() : comment.module
  • comment_form() : comment.module
  • COMMENT_FORM_BELOW : comment.module
  • comment_form_build_preview() : comment.module
  • comment_form_node_form_alter() : comment.module
  • comment_form_node_type_form_alter() : comment.module
  • COMMENT_FORM_SEPARATE_PAGE : comment.module
  • comment_form_submit() : comment.module
  • comment_form_submit_build_comment() : comment.module
  • comment_form_validate() : comment.module
  • comment_forms() : comment.module
  • comment_get_display_ordinal() : comment.module
  • comment_get_display_page() : comment.module
  • comment_get_recent() : comment.module
  • comment_get_thread() : comment.module
  • comment_help() : comment.module
  • comment_links() : comment.module
  • comment_load() : comment.module
  • comment_load_multiple() : comment.module
  • comment_menu() : comment.module
  • comment_menu_alter() : comment.module
  • COMMENT_MODE_FLAT : comment.module
  • COMMENT_MODE_THREADED : comment.module
  • comment_modules_enabled() : comment.install
  • comment_multiple_delete_confirm() : comment.admin.inc
  • comment_multiple_delete_confirm_submit() : comment.admin.inc
  • comment_new_page_count() : comment.module
  • COMMENT_NODE_CLOSED : comment.module
  • comment_node_delete() : comment.module
  • COMMENT_NODE_HIDDEN : comment.module
  • comment_node_insert() : comment.module
  • comment_node_load() : comment.module
  • COMMENT_NODE_OPEN : comment.module
  • comment_node_page_additions() : comment.module
  • comment_node_prepare() : comment.module
  • comment_node_search_result() : comment.module
  • comment_node_type_delete() : comment.module
  • comment_node_type_insert() : comment.module
  • comment_node_type_load() : comment.module
  • comment_node_type_update() : comment.module
  • comment_node_update_index() : comment.module
  • comment_node_view() : comment.module
  • COMMENT_NOT_PUBLISHED : comment.module
  • comment_num_new() : comment.module
  • comment_permalink() : comment.module
  • comment_permission() : comment.module
  • comment_prepare_thread() : comment.module
  • comment_preview() : comment.module
  • comment_publish_action() : comment.module
  • COMMENT_PUBLISHED : comment.module
  • comment_ranking() : comment.module
  • comment_rdf_mapping() : comment.module
  • comment_reply() : comment.pages.inc
  • comment_save() : comment.module
  • comment_save_action() : comment.module
  • comment_schema() : comment.install
  • comment_submit() : comment.module
  • comment_theme() : comment.module
  • comment_token_info() : comment.tokens.inc
  • comment_tokens() : comment.tokens.inc
  • comment_uninstall() : comment.install
  • comment_unpublish_action() : comment.module
  • comment_unpublish_by_keyword_action() : comment.module
  • comment_unpublish_by_keyword_action_form() : comment.module
  • comment_unpublish_by_keyword_action_submit() : comment.module
  • comment_update_7000() : comment.install
  • comment_update_7001() : comment.install
  • comment_update_7002() : comment.install
  • comment_update_7003() : comment.install
  • comment_update_7004() : comment.install
  • comment_update_7005() : comment.install
  • comment_update_7006() : comment.install
  • comment_update_7007() : comment.install
  • comment_update_7008() : comment.install
  • comment_update_7009() : comment.install
  • comment_update_dependencies() : comment.install
  • comment_update_index() : comment.module
  • comment_uri() : comment.module
  • comment_user_cancel() : comment.module
  • comment_user_delete() : comment.module
  • comment_view() : comment.module
  • comment_view_multiple() : comment.module
  • conf_path() : bootstrap.inc
  • configure_link : block-admin-display-form.tpl.php
  • confirm_form() : system.module
  • contact_category_delete_form() : contact.admin.inc
  • contact_category_delete_form_submit() : contact.admin.inc
  • contact_category_edit_form() : contact.admin.inc
  • contact_category_edit_form_submit() : contact.admin.inc
  • contact_category_edit_form_validate() : contact.admin.inc
  • contact_category_list() : contact.admin.inc
  • contact_form_user_admin_settings_alter() : contact.module
  • contact_form_user_profile_form_alter() : contact.module
  • contact_help() : contact.module
  • contact_install() : contact.install
  • contact_load() : contact.module
  • contact_mail() : contact.module
  • contact_menu() : contact.module
  • contact_permission() : contact.module
  • contact_personal_form() : contact.pages.inc
  • contact_personal_form_submit() : contact.pages.inc
  • contact_personal_form_validate() : contact.pages.inc
  • contact_schema() : contact.install
  • contact_site_form() : contact.pages.inc
  • contact_site_form_submit() : contact.pages.inc
  • contact_site_form_validate() : contact.pages.inc
  • contact_uninstall() : contact.install
  • contact_update_7000() : contact.install
  • contact_update_7001() : contact.install
  • contact_update_7002() : contact.install
  • contact_update_7003() : contact.install
  • contact_update_dependencies() : contact.install
  • contact_user_presave() : contact.module
  • contextual_element_info() : contextual.module
  • contextual_help() : contextual.module
  • contextual_library() : contextual.module
  • contextual_links_example_block_info() : contextual_links_example.module
  • contextual_links_example_block_view() : contextual_links_example.module
  • contextual_links_example_menu() : contextual_links_example.module
  • contextual_links_example_node_action_form() : contextual_links_example.module
  • contextual_links_example_node_action_form_submit() : contextual_links_example.module
  • contextual_links_example_object_edit_form() : contextual_links_example.module
  • contextual_links_example_object_edit_form_submit() : contextual_links_example.module
  • contextual_links_example_object_load() : contextual_links_example.module
  • contextual_links_example_object_page() : contextual_links_example.module
  • contextual_links_example_theme() : contextual_links_example.module
  • contextual_links_overview_page() : contextual_links_example.module
  • contextual_permission() : contextual.module
  • contextual_pre_render_links() : contextual.module
  • contextual_preprocess() : contextual.module
  • country_get_list() : locale.inc
  • created : forum-topic-list.tpl.php
  • cron_example_add_jobs_to_queue() : cron_example.module
  • cron_example_cron() : cron_example.module
  • cron_example_cron_queue_info() : cron_example.module
  • cron_example_form() : cron_example.module
  • cron_example_form_cron_run_submit() : cron_example.module
  • cron_example_menu() : cron_example.module
  • cron_example_queue_1_worker() : cron_example.module
  • cron_example_queue_2_worker() : cron_example.module
  • cron_example_queue_report_work() : cron_example.module
  • CSS_DEFAULT : common.inc
  • CSS_SYSTEM : common.inc
  • CSS_THEME : common.inc
  • current_path() : path.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- d -

  • dashboard_admin() : dashboard.module
  • dashboard_admin_blocks() : dashboard.module
  • dashboard_block_info_alter() : dashboard.module
  • dashboard_block_list_alter() : dashboard.module
  • dashboard_dashboard_regions() : dashboard.module
  • dashboard_disable() : dashboard.install
  • dashboard_enable() : dashboard.install
  • dashboard_form_block_add_block_form_alter() : dashboard.module
  • dashboard_form_block_admin_configure_alter() : dashboard.module
  • dashboard_form_block_admin_display_form_alter() : dashboard.module
  • dashboard_form_dashboard_admin_display_form_alter() : dashboard.module
  • dashboard_forms() : dashboard.module
  • dashboard_help() : dashboard.module
  • dashboard_is_visible() : dashboard.module
  • dashboard_menu() : dashboard.module
  • dashboard_page_build() : dashboard.module
  • dashboard_permission() : dashboard.module
  • dashboard_region_descriptions() : dashboard.module
  • dashboard_regions() : dashboard.module
  • dashboard_show_block_content() : dashboard.module
  • dashboard_show_disabled() : dashboard.module
  • dashboard_system_info_alter() : dashboard.module
  • dashboard_theme() : dashboard.module
  • dashboard_uninstall() : dashboard.install
  • dashboard_update() : dashboard.module
  • date_iso8601() : common.inc
  • date_validate() : form.inc
  • db_add_field() : database.inc
  • db_add_index() : database.inc
  • db_add_primary_key() : database.inc
  • db_add_unique_key() : database.inc
  • db_and() : database.inc
  • db_change_field() : database.inc
  • db_close() : database.inc
  • db_condition() : database.inc
  • db_create_table() : database.inc
  • db_delete() : database.inc
  • db_driver() : database.inc
  • db_drop_field() : database.inc
  • db_drop_index() : database.inc
  • db_drop_primary_key() : database.inc
  • db_drop_table() : database.inc
  • db_drop_unique_key() : database.inc
  • db_escape_field() : database.inc
  • db_escape_table() : database.inc
  • db_field_exists() : database.inc
  • db_field_names() : database.inc
  • db_field_set_default() : database.inc
  • db_field_set_no_default() : database.inc
  • db_find_tables() : database.inc
  • db_ignore_slave() : database.inc
  • db_index_exists() : database.inc
  • db_insert() : database.inc
  • db_installer_object() : install.inc
  • db_like() : database.inc
  • db_merge() : database.inc
  • db_next_id() : database.inc
  • db_or() : database.inc
  • db_query() : database.inc
  • db_query_range() : database.inc
  • db_query_temporary() : database.inc
  • db_rename_table() : database.inc
  • db_run_tasks() : install.inc
  • db_select() : database.inc
  • db_set_active() : database.inc
  • db_table_exists() : database.inc
  • db_transaction() : database.inc
  • db_truncate() : database.inc
  • db_update() : database.inc
  • db_xor() : database.inc
  • dblog_build_filter_query() : dblog.admin.inc
  • dblog_clear_log_form() : dblog.admin.inc
  • dblog_clear_log_submit() : dblog.admin.inc
  • dblog_cron() : dblog.module
  • dblog_event() : dblog.admin.inc
  • dblog_filter_form() : dblog.admin.inc
  • dblog_filter_form_submit() : dblog.admin.inc
  • dblog_filter_form_validate() : dblog.admin.inc
  • dblog_filters() : dblog.admin.inc
  • dblog_form_system_logging_settings_alter() : dblog.module
  • dblog_help() : dblog.module
  • dblog_init() : dblog.module
  • dblog_menu() : dblog.module
  • dblog_overview() : dblog.admin.inc
  • dblog_schema() : dblog.install
  • dblog_theme() : dblog.module
  • dblog_top() : dblog.admin.inc
  • dblog_uninstall() : dblog.install
  • dblog_update_7001() : dblog.install
  • dblog_update_7002() : dblog.install
  • dblog_watchdog() : dblog.module
  • dbtng_example_advanced_list() : dbtng_example.module
  • dbtng_example_entry_delete() : dbtng_example.module
  • dbtng_example_entry_insert() : dbtng_example.module
  • dbtng_example_entry_load() : dbtng_example.module
  • dbtng_example_entry_update() : dbtng_example.module
  • dbtng_example_form_add() : dbtng_example.module
  • dbtng_example_form_add_submit() : dbtng_example.module
  • dbtng_example_form_update() : dbtng_example.module
  • dbtng_example_form_update_callback() : dbtng_example.module
  • dbtng_example_form_update_submit() : dbtng_example.module
  • dbtng_example_help() : dbtng_example.module
  • dbtng_example_install() : dbtng_example.install
  • dbtng_example_list() : dbtng_example.module
  • dbtng_example_menu() : dbtng_example.module
  • dbtng_example_schema() : dbtng_example.install
  • dbtng_example_uninstall() : dbtng_example.install
  • debug() : common.inc
  • decode_entities() : unicode.inc
  • delete_link : block-admin-display-form.tpl.php
  • dir : html.tpl.php , maintenance-page.tpl.php
  • drupal_access_denied() : common.inc
  • drupal_add_css() : common.inc
  • drupal_add_feed() : common.inc
  • drupal_add_html_head() : common.inc
  • drupal_add_html_head_link() : common.inc
  • drupal_add_http_header() : bootstrap.inc
  • drupal_add_js() : common.inc
  • drupal_add_library() : common.inc
  • drupal_add_region_content() : common.inc
  • drupal_add_tabledrag() : common.inc
  • drupal_aggregate_css() : common.inc
  • drupal_alter() : module.inc
  • DRUPAL_ANONYMOUS_RID : bootstrap.inc
  • drupal_anonymous_user() : bootstrap.inc
  • drupal_array_diff_assoc_recursive() : common.inc
  • drupal_array_get_nested_value() : common.inc
  • drupal_array_merge_deep() : bootstrap.inc
  • drupal_array_merge_deep_array() : bootstrap.inc
  • drupal_array_nested_key_exists() : common.inc
  • drupal_array_set_nested_value() : common.inc
  • drupal_attributes() : common.inc
  • DRUPAL_AUTHENTICATED_RID : bootstrap.inc
  • drupal_autoload_class() : bootstrap.inc
  • drupal_autoload_interface() : bootstrap.inc
  • drupal_base64_encode() : bootstrap.inc
  • drupal_basename() : file.inc
  • drupal_block_denied() : bootstrap.inc
  • drupal_bootstrap() : bootstrap.inc
  • DRUPAL_BOOTSTRAP_CONFIGURATION : bootstrap.inc
  • DRUPAL_BOOTSTRAP_DATABASE : bootstrap.inc
  • DRUPAL_BOOTSTRAP_FULL : bootstrap.inc
  • DRUPAL_BOOTSTRAP_LANGUAGE : bootstrap.inc
  • DRUPAL_BOOTSTRAP_PAGE_CACHE : bootstrap.inc
  • DRUPAL_BOOTSTRAP_PAGE_HEADER : bootstrap.inc
  • DRUPAL_BOOTSTRAP_SESSION : bootstrap.inc
  • DRUPAL_BOOTSTRAP_VARIABLES : bootstrap.inc
  • drupal_build_css_cache() : common.inc
  • drupal_build_form() : form.inc
  • drupal_build_js_cache() : common.inc
  • DRUPAL_CACHE_CUSTOM : common.inc
  • DRUPAL_CACHE_GLOBAL : common.inc
  • DRUPAL_CACHE_PER_PAGE : common.inc
  • DRUPAL_CACHE_PER_ROLE : common.inc
  • DRUPAL_CACHE_PER_USER : common.inc
  • drupal_cache_system_paths() : path.inc
  • drupal_check_incompatibility() : common.inc
  • drupal_check_memory_limit() : bootstrap.inc
  • drupal_check_module() : install.inc
  • drupal_check_profile() : install.inc
  • drupal_chmod() : file.inc
  • drupal_clean_css_identifier() : common.inc
  • drupal_clear_css_cache() : common.inc
  • drupal_clear_js_cache() : common.inc
  • drupal_clear_path_cache() : path.inc
  • drupal_common_theme() : common.inc
  • drupal_convert_to_utf8() : unicode.inc
  • DRUPAL_CORE_COMPATIBILITY : bootstrap.inc
  • drupal_cron_cleanup() : common.inc
  • DRUPAL_CRON_DEFAULT_THRESHOLD : system.module
  • drupal_cron_run() : common.inc
  • drupal_current_script_url() : install.inc
  • drupal_delete_file_if_stale() : common.inc
  • drupal_deliver_html_page() : common.inc
  • drupal_deliver_page() : common.inc
  • drupal_depth_first_search() : graph.inc
  • drupal_detect_baseurl() : install.inc
  • drupal_detect_database_types() : install.inc
  • drupal_dirname() : file.inc
  • DRUPAL_DISABLED : system.module
  • drupal_encode_path() : common.inc
  • drupal_environment_initialize() : bootstrap.inc
  • drupal_error_levels() : errors.inc
  • drupal_exit() : common.inc
  • drupal_explode_tags() : common.inc
  • drupal_fast_404() : bootstrap.inc
  • drupal_find_base_themes() : theme.inc
  • drupal_find_theme_functions() : theme.inc
  • drupal_find_theme_templates() : theme.inc
  • drupal_flush_all_caches() : common.inc
  • drupal_form_submit() : form.inc
  • drupal_generate_test_ua() : bootstrap.inc
  • drupal_get_bootstrap_phase() : bootstrap.inc
  • drupal_get_breadcrumb() : common.inc
  • drupal_get_complete_schema() : bootstrap.inc
  • drupal_get_css() : common.inc
  • drupal_get_database_types() : install.inc
  • drupal_get_destination() : common.inc
  • drupal_get_feeds() : common.inc
  • drupal_get_filename() : bootstrap.inc
  • drupal_get_filetransfer_info() : common.inc
  • drupal_get_form() : form.inc
  • drupal_get_hash_salt() : bootstrap.inc
  • drupal_get_html_head() : common.inc
  • drupal_get_http_header() : bootstrap.inc
  • drupal_get_installed_schema_version() : install.inc
  • drupal_get_js() : common.inc
  • drupal_get_library() : common.inc
  • drupal_get_messages() : bootstrap.inc
  • drupal_get_normal_path() : path.inc
  • drupal_get_path() : common.inc
  • drupal_get_path_alias() : path.inc
  • drupal_get_private_key() : common.inc
  • drupal_get_profile() : common.inc
  • drupal_get_query_array() : common.inc
  • drupal_get_query_parameters() : common.inc
  • drupal_get_rdf_namespaces() : common.inc
  • drupal_get_region_content() : common.inc
  • drupal_get_schema() : bootstrap.inc
  • drupal_get_schema_unprocessed() : common.inc
  • drupal_get_schema_versions() : install.inc
  • drupal_get_title() : bootstrap.inc
  • drupal_get_token() : common.inc
  • drupal_get_updaters() : common.inc
  • drupal_get_user_timezone() : bootstrap.inc
  • drupal_goto() : common.inc
  • drupal_group_css() : common.inc
  • drupal_hash_base64() : bootstrap.inc
  • DRUPAL_HASH_COUNT : password.inc
  • DRUPAL_HASH_LENGTH : password.inc
  • drupal_help_arg() : menu.inc
  • drupal_hmac_base64() : bootstrap.inc
  • drupal_html_class() : common.inc
  • drupal_html_id() : common.inc
  • drupal_html_to_text() : mail.inc
  • drupal_http_build_query() : common.inc
  • drupal_http_header_attributes() : common.inc
  • drupal_http_request() : common.inc
  • drupal_implode_tags() : common.inc
  • drupal_install_fix_file() : install.inc
  • drupal_install_mkdir() : install.inc
  • drupal_install_profile_distribution_name() : install.inc
  • drupal_install_schema() : common.inc
  • drupal_install_system() : install.inc
  • drupal_installation_attempted() : bootstrap.inc
  • drupal_is_cli() : bootstrap.inc
  • drupal_is_denied() : bootstrap.inc
  • drupal_is_front_page() : path.inc
  • drupal_js_defaults() : common.inc
  • drupal_json_decode() : common.inc
  • drupal_json_encode() : common.inc
  • drupal_json_encode_helper() : json-encode.inc
  • drupal_json_output() : common.inc
  • DRUPAL_KILOBYTE : bootstrap.inc
  • drupal_language_initialize() : bootstrap.inc
  • drupal_language_types() : bootstrap.inc
  • drupal_load() : bootstrap.inc
  • drupal_load_stylesheet() : common.inc
  • drupal_load_stylesheet_content() : common.inc
  • drupal_load_updates() : install.inc
  • drupal_lookup_path() : path.inc
  • drupal_mail() : mail.inc
  • drupal_mail_system() : mail.inc
  • drupal_maintenance_theme() : bootstrap.inc
  • drupal_map_assoc() : common.inc
  • drupal_match_path() : path.inc
  • DRUPAL_MAX_HASH_COUNT : password.inc
  • DRUPAL_MAXIMUM_TEMP_FILE_AGE : system.module
  • DRUPAL_MIN_HASH_COUNT : password.inc
  • DRUPAL_MINIMUM_PHP : bootstrap.inc
  • DRUPAL_MINIMUM_PHP_MEMORY_LIMIT : bootstrap.inc
  • drupal_mkdir() : file.inc
  • drupal_move_uploaded_file() : file.inc
  • drupal_multilingual() : bootstrap.inc
  • DRUPAL_NO_CACHE : common.inc
  • drupal_not_found() : common.inc
  • DRUPAL_OPTIONAL : system.module
  • drupal_override_server_variables() : bootstrap.inc
  • drupal_page_footer() : common.inc
  • drupal_page_get_cache() : bootstrap.inc
  • drupal_page_header() : bootstrap.inc
  • drupal_page_is_cacheable() : bootstrap.inc
  • drupal_page_set_cache() : common.inc
  • drupal_parse_dependency() : common.inc
  • drupal_parse_info_file() : common.inc
  • drupal_parse_info_format() : common.inc
  • drupal_parse_url() : common.inc
  • drupal_path_alias_whitelist_rebuild() : path.inc
  • drupal_path_initialize() : path.inc
  • DRUPAL_PHP_FUNCTION_PATTERN : bootstrap.inc
  • drupal_placeholder() : bootstrap.inc
  • drupal_pre_render_conditional_comments() : common.inc
  • drupal_pre_render_link() : common.inc
  • drupal_pre_render_links() : common.inc
  • drupal_pre_render_markup() : common.inc
  • drupal_pre_render_styles() : common.inc
  • drupal_prepare_form() : form.inc
  • drupal_process_attached() : common.inc
  • drupal_process_form() : form.inc
  • drupal_process_states() : common.inc
  • drupal_random_bytes() : bootstrap.inc
  • drupal_random_key() : bootstrap.inc
  • drupal_realpath() : file.inc
  • drupal_rebuild_form() : form.inc
  • drupal_redirect_form() : form.inc
  • drupal_region_class() : common.inc
  • drupal_register_shutdown_function() : bootstrap.inc
  • drupal_render() : common.inc
  • drupal_render_cache_by_query() : common.inc
  • drupal_render_cache_get() : common.inc
  • drupal_render_cache_set() : common.inc
  • drupal_render_children() : common.inc
  • drupal_render_cid_create() : common.inc
  • drupal_render_cid_parts() : common.inc
  • drupal_render_collect_attached() : common.inc
  • drupal_render_page() : common.inc
  • DRUPAL_REQUIRED : system.module
  • drupal_required_modules() : module.inc
  • drupal_requirements_severity() : install.inc
  • drupal_requirements_url() : install.inc
  • drupal_retrieve_form() : form.inc
  • drupal_rewrite_settings() : install.inc
  • drupal_rmdir() : file.inc
  • DRUPAL_ROOT : install.php , xmlrpc.php , authorize.php , update.php , cron.php , index.php , statistics.php
  • drupal_save_session() : session.inc
  • drupal_schema_fields_sql() : common.inc
  • drupal_send_headers() : bootstrap.inc
  • drupal_serve_page_from_cache() : bootstrap.inc
  • drupal_session_commit() : session.inc
  • drupal_session_destroy_uid() : session.inc
  • drupal_session_initialize() : session.inc
  • drupal_session_regenerate() : session.inc
  • drupal_session_start() : session.inc
  • drupal_session_started() : session.inc
  • drupal_set_breadcrumb() : common.inc
  • drupal_set_installed_schema_version() : install.inc
  • drupal_set_message() : bootstrap.inc
  • drupal_set_page_content() : common.inc
  • drupal_set_time_limit() : common.inc
  • drupal_set_title() : bootstrap.inc
  • drupal_settings_initialize() : bootstrap.inc
  • drupal_site_offline() : common.inc
  • drupal_sort_css_js() : common.inc
  • drupal_sort_title() : common.inc
  • drupal_sort_weight() : common.inc
  • drupal_static() : bootstrap.inc
  • drupal_static_reset() : bootstrap.inc
  • drupal_strip_dangerous_protocols() : common.inc
  • drupal_strlen() : unicode.inc
  • drupal_strtolower() : unicode.inc
  • drupal_strtoupper() : unicode.inc
  • drupal_substr() : unicode.inc
  • drupal_system_listing() : common.inc
  • drupal_tempnam() : file.inc
  • drupal_theme_access() : theme.inc
  • drupal_theme_initialize() : theme.inc
  • drupal_theme_rebuild() : theme.inc
  • drupal_truncate_bytes() : unicode.inc
  • drupal_ucfirst() : unicode.inc
  • drupal_uninstall_modules() : install.inc
  • drupal_uninstall_schema() : common.inc
  • drupal_unlink() : file.inc
  • drupal_unpack() : bootstrap.inc
  • DRUPAL_USER_TIMEZONE_DEFAULT : system.module
  • DRUPAL_USER_TIMEZONE_EMPTY : system.module
  • DRUPAL_USER_TIMEZONE_SELECT : system.module
  • drupal_valid_http_host() : bootstrap.inc
  • drupal_valid_path() : path.inc
  • drupal_valid_test_ua() : bootstrap.inc
  • drupal_valid_token() : common.inc
  • drupal_validate_form() : form.inc
  • drupal_validate_utf8() : bootstrap.inc
  • drupal_var_export() : utility.inc
  • drupal_verify_install_file() : install.inc
  • drupal_verify_profile() : install.inc
  • DRUPAL_WEIGHT_SELECT_MAX : system.module
  • drupal_wrap_mail() : mail.inc
  • drupal_write_record() : common.inc
  • drupal_xml_parser_create() : unicode.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- e -

  • element_child() : common.inc
  • element_children() : common.inc
  • element_get_visible_children() : common.inc
  • element_info() : common.inc
  • element_info_property() : common.inc
  • element_properties() : common.inc
  • element_property() : common.inc
  • element_set_attributes() : common.inc
  • element_sort() : common.inc
  • element_sort_by_title() : common.inc
  • element_validate_integer() : form.inc
  • element_validate_integer_positive() : form.inc
  • element_validate_number() : form.inc
  • else : forum-topic-list.tpl.php , syslog.module , page.tpl.php , update.php , authorize.php , cron.php
  • email_example_form() : email_example.module
  • email_example_form_submit() : email_example.module
  • email_example_form_validate() : email_example.module
  • email_example_mail() : email_example.module
  • email_example_mail_alter() : email_example.module
  • email_example_mail_send() : email_example.module
  • email_example_menu() : email_example.module
  • EMAIL_MAX_LENGTH : user.module
  • endfor : book-export-html.tpl.php
  • endforeach : forum-list.tpl.php , forum-topic-list.tpl.php , profile-block.tpl.php , profile-listing.tpl.php , block-admin-display-form.tpl.php , book-all-books-block.tpl.php , field.tpl.php
  • endif : node.tpl.php , page.tpl.php , node.tpl.php , page.tpl.php , maintenance-page.tpl.php , page.tpl.php , aggregator-item.tpl.php , aggregator-summary-item.tpl.php , block.tpl.php , book-navigation.tpl.php , maintenance-page.tpl.php , comment-wrapper.tpl.php , field.tpl.php , forum-list.tpl.php , user-picture.tpl.php , forum-submitted.tpl.php , forum-topic-list.tpl.php , forums.tpl.php , page.tpl.php , node.tpl.php , overlay.tpl.php , poll-results.tpl.php , poll-vote.tpl.php , profile-block.tpl.php , search-block-form.tpl.php , search-result.tpl.php , search-results.tpl.php , maintenance-page.tpl.php , region.tpl.php , taxonomy-term.tpl.php , toolbar.tpl.php , user-profile-category.tpl.php , comment-wrapper.tpl.php , comment.tpl.php
  • entity_create_stub_entity() : common.inc
  • entity_example_basic_add() : entity_example.module
  • entity_example_basic_delete() : entity_example.module
  • entity_example_basic_edit_delete() : entity_example.module
  • entity_example_basic_form() : entity_example.module
  • entity_example_basic_form_submit() : entity_example.module
  • entity_example_basic_form_validate() : entity_example.module
  • entity_example_basic_list_entities() : entity_example.module
  • entity_example_basic_load() : entity_example.module
  • entity_example_basic_load_multiple() : entity_example.module
  • entity_example_basic_save() : entity_example.module
  • entity_example_basic_title() : entity_example.module
  • entity_example_basic_uri() : entity_example.module
  • entity_example_basic_view() : entity_example.module
  • entity_example_entity_info() : entity_example.module
  • entity_example_field_extra_fields() : entity_example.module
  • entity_example_info_page() : entity_example.module
  • entity_example_menu() : entity_example.module
  • entity_example_permission() : entity_example.module
  • entity_example_schema() : entity_example.install
  • entity_example_uninstall() : entity_example.install
  • entity_extract_ids() : common.inc
  • entity_form_field_validate() : common.inc
  • entity_form_submit_build_entity() : common.inc
  • entity_get_controller() : common.inc
  • entity_get_info() : common.inc
  • entity_info_cache_clear() : common.inc
  • entity_label() : common.inc
  • entity_language() : common.inc
  • entity_load() : common.inc
  • entity_load_unchanged() : common.inc
  • entity_prepare_view() : common.inc
  • entity_uri() : common.inc
  • error_displayable() : errors.inc
  • ERROR_REPORTING_DISPLAY_ALL : bootstrap.inc
  • ERROR_REPORTING_DISPLAY_SOME : bootstrap.inc
  • ERROR_REPORTING_HIDE : bootstrap.inc
  • examples_help() : examples.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- f -

  • field_access() : field.module
  • field_add_more_js() : field.form.inc
  • field_add_more_submit() : field.form.inc
  • field_associate_fields() : field.module
  • field_attach_create_bundle() : field.attach.inc
  • field_attach_delete() : field.attach.inc
  • field_attach_delete_bundle() : field.attach.inc
  • field_attach_delete_revision() : field.attach.inc
  • field_attach_form() : field.attach.inc
  • field_attach_form_validate() : field.attach.inc
  • field_attach_insert() : field.attach.inc
  • field_attach_load() : field.attach.inc
  • field_attach_load_revision() : field.attach.inc
  • field_attach_prepare_translation() : field.attach.inc
  • field_attach_prepare_view() : field.attach.inc
  • field_attach_preprocess() : field.attach.inc
  • field_attach_presave() : field.attach.inc
  • field_attach_rename_bundle() : field.attach.inc
  • field_attach_submit() : field.attach.inc
  • field_attach_update() : field.attach.inc
  • field_attach_validate() : field.attach.inc
  • field_attach_view() : field.attach.inc
  • field_available_languages() : field.multilingual.inc
  • FIELD_BEHAVIOR_CUSTOM : field.module
  • FIELD_BEHAVIOR_DEFAULT : field.module
  • FIELD_BEHAVIOR_NONE : field.module
  • field_behaviors_widget() : field.info.inc
  • field_bundle_settings() : field.module
  • field_cache_clear() : field.module
  • FIELD_CARDINALITY_UNLIMITED : field.module
  • field_content_languages() : field.multilingual.inc
  • field_create_field() : field.crud.inc
  • field_create_instance() : field.crud.inc
  • field_cron() : field.module
  • field_default_extract_form_values() : field.default.inc
  • field_default_form() : field.form.inc
  • field_default_form_errors() : field.form.inc
  • field_default_insert() : field.default.inc
  • field_default_prepare_translation() : field.default.inc
  • field_default_prepare_view() : field.default.inc
  • field_default_submit() : field.default.inc
  • field_default_validate() : field.default.inc
  • field_default_view() : field.default.inc
  • field_delete_field() : field.crud.inc
  • field_delete_instance() : field.crud.inc
  • field_example_3text_validate() : field_example.module
  • field_example_field_formatter_info() : field_example.module
  • field_example_field_formatter_view() : field_example.module
  • field_example_field_info() : field_example.module
  • field_example_field_is_empty() : field_example.module
  • field_example_field_schema() : field_example.install
  • field_example_field_validate() : field_example.module
  • field_example_field_widget_error() : field_example.module
  • field_example_field_widget_form() : field_example.module
  • field_example_field_widget_info() : field_example.module
  • field_example_menu() : field_example.module
  • field_extra_fields_get_display() : field.module
  • field_extract_bundle() : field.module
  • field_filter_xss() : field.module
  • field_flush_caches() : field.module
  • field_form_element_after_build() : field.form.inc
  • field_form_get_state() : field.form.inc
  • field_form_set_state() : field.form.inc
  • field_get_default_value() : field.module
  • field_get_display() : field.module
  • field_get_items() : field.module
  • field_has_data() : field.module
  • field_has_translation_handler() : field.multilingual.inc
  • field_help() : field.module
  • field_info_bundles() : field.info.inc
  • field_info_cache_clear() : field.info.inc
  • field_info_extra_fields() : field.info.inc
  • field_info_field() : field.info.inc
  • field_info_field_by_id() : field.info.inc
  • field_info_field_by_ids() : field.info.inc
  • field_info_field_map() : field.info.inc
  • field_info_field_settings() : field.info.inc
  • field_info_field_types() : field.info.inc
  • field_info_fields() : field.info.inc
  • field_info_formatter_settings() : field.info.inc
  • field_info_formatter_types() : field.info.inc
  • field_info_instance() : field.info.inc
  • field_info_instance_settings() : field.info.inc
  • field_info_instances() : field.info.inc
  • field_info_max_weight() : field.info.inc
  • field_info_storage_settings() : field.info.inc
  • field_info_storage_types() : field.info.inc
  • field_info_widget_settings() : field.info.inc
  • field_info_widget_types() : field.info.inc
  • field_is_translatable() : field.multilingual.inc
  • field_language() : field.multilingual.inc
  • FIELD_LOAD_CURRENT : field.module
  • FIELD_LOAD_REVISION : field.module
  • field_modules_disabled() : field.module
  • field_modules_enabled() : field.module
  • field_modules_uninstalled() : field.module
  • field_multilingual_settings_changed() : field.multilingual.inc
  • field_multiple_value_form() : field.form.inc
  • field_permission_example_field_access() : field_permission_example.module
  • field_permission_example_field_formatter_info() : field_permission_example.module
  • field_permission_example_field_formatter_view() : field_permission_example.module
  • field_permission_example_field_info() : field_permission_example.module
  • field_permission_example_field_is_empty() : field_permission_example.module
  • field_permission_example_field_schema() : field_permission_example.install
  • field_permission_example_field_widget_form() : field_permission_example.module
  • field_permission_example_field_widget_info() : field_permission_example.module
  • field_permission_example_menu() : field_permission_example.module
  • field_permission_example_permission() : field_permission_example.module
  • field_purge_batch() : field.crud.inc
  • field_purge_data() : field.crud.inc
  • field_purge_field() : field.crud.inc
  • field_purge_instance() : field.crud.inc
  • field_read_field() : field.crud.inc
  • field_read_fields() : field.crud.inc
  • field_read_instance() : field.crud.inc
  • field_read_instances() : field.crud.inc
  • field_schema() : field.install
  • field_sql_storage_field_attach_rename_bundle() : field_sql_storage.module
  • field_sql_storage_field_storage_create_field() : field_sql_storage.module
  • field_sql_storage_field_storage_delete() : field_sql_storage.module
  • field_sql_storage_field_storage_delete_field() : field_sql_storage.module
  • field_sql_storage_field_storage_delete_instance() : field_sql_storage.module
  • field_sql_storage_field_storage_delete_revision() : field_sql_storage.module
  • field_sql_storage_field_storage_details() : field_sql_storage.module
  • field_sql_storage_field_storage_info() : field_sql_storage.module
  • field_sql_storage_field_storage_load() : field_sql_storage.module
  • field_sql_storage_field_storage_purge() : field_sql_storage.module
  • field_sql_storage_field_storage_purge_field() : field_sql_storage.module
  • field_sql_storage_field_storage_query() : field_sql_storage.module
  • field_sql_storage_field_storage_update_field() : field_sql_storage.module
  • field_sql_storage_field_storage_write() : field_sql_storage.module
  • field_sql_storage_field_update_forbid() : field_sql_storage.module
  • field_sql_storage_help() : field_sql_storage.module
  • field_sql_storage_schema() : field_sql_storage.install
  • field_sql_storage_update_7000() : field_sql_storage.install
  • field_sql_storage_update_7001() : field_sql_storage.install
  • field_sql_storage_update_7002() : field_sql_storage.install
  • FIELD_STORAGE_INSERT : field.attach.inc
  • FIELD_STORAGE_UPDATE : field.attach.inc
  • field_sync_field_status() : field.module
  • field_system_info_alter() : field.module
  • field_theme() : field.module
  • field_ui_default_value_widget() : field_ui.admin.inc
  • field_ui_display_overview_form() : field_ui.admin.inc
  • field_ui_display_overview_form_submit() : field_ui.admin.inc
  • field_ui_display_overview_multistep_js() : field_ui.admin.inc
  • field_ui_display_overview_multistep_submit() : field_ui.admin.inc
  • field_ui_display_overview_row_region() : field_ui.admin.inc
  • field_ui_element_info() : field_ui.module
  • field_ui_existing_field_options() : field_ui.admin.inc
  • field_ui_field_attach_create_bundle() : field_ui.module
  • field_ui_field_attach_rename_bundle() : field_ui.module
  • field_ui_field_delete_form() : field_ui.admin.inc
  • field_ui_field_delete_form_submit() : field_ui.admin.inc
  • field_ui_field_edit_form() : field_ui.admin.inc
  • field_ui_field_edit_form_submit() : field_ui.admin.inc
  • field_ui_field_edit_form_validate() : field_ui.admin.inc
  • field_ui_field_edit_instance_pre_render() : field_ui.admin.inc
  • field_ui_field_overview_form() : field_ui.admin.inc
  • field_ui_field_overview_form_submit() : field_ui.admin.inc
  • field_ui_field_overview_form_validate() : field_ui.admin.inc
  • field_ui_field_overview_row_region() : field_ui.admin.inc
  • field_ui_field_settings_form() : field_ui.admin.inc
  • field_ui_field_settings_form_submit() : field_ui.admin.inc
  • field_ui_field_type_options() : field_ui.admin.inc
  • field_ui_fields_list() : field_ui.admin.inc
  • field_ui_form_node_type_form_alter() : field_ui.module
  • field_ui_form_node_type_form_submit() : field_ui.module
  • field_ui_formatter_options() : field_ui.admin.inc
  • field_ui_get_destinations() : field_ui.admin.inc
  • field_ui_help() : field_ui.module
  • field_ui_inactive_instances() : field_ui.module
  • field_ui_inactive_message() : field_ui.admin.inc
  • field_ui_menu() : field_ui.module
  • field_ui_menu_load() : field_ui.module
  • field_ui_menu_title() : field_ui.module
  • field_ui_next_destination() : field_ui.admin.inc
  • field_ui_table_pre_render() : field_ui.admin.inc
  • field_ui_theme() : field_ui.module
  • field_ui_widget_type_form() : field_ui.admin.inc
  • field_ui_widget_type_form_submit() : field_ui.admin.inc
  • field_ui_widget_type_options() : field_ui.admin.inc
  • field_update_7000() : field.install
  • field_update_7001() : field.install
  • field_update_7002() : field.install
  • field_update_7003() : field.install
  • field_update_field() : field.crud.inc
  • field_update_instance() : field.crud.inc
  • field_valid_language() : field.multilingual.inc
  • field_view_field() : field.module
  • field_view_mode_settings() : field.module
  • field_view_value() : field.module
  • field_widget_field() : field.form.inc
  • field_widget_instance() : field.form.inc
  • file_ajax_progress() : file.module
  • file_ajax_upload() : file.module
  • file_build_uri() : file.inc
  • file_copy() : file.inc
  • FILE_CREATE_DIRECTORY : file.inc
  • file_create_filename() : file.inc
  • file_create_htaccess() : file.inc
  • file_create_url() : file.inc
  • file_default_mimetype_mapping() : file.mimetypes.inc
  • file_default_scheme() : file.inc
  • file_delete() : file.inc
  • file_destination() : file.inc
  • file_directory_temp() : file.inc
  • file_download() : file.inc
  • file_element_info() : file.module
  • file_ensure_htaccess() : file.inc
  • file_example_check_directory_submit() : file_example.module
  • file_example_create_directory_submit() : file_example.module
  • file_example_delete_directory_submit() : file_example.module
  • file_example_delete_submit() : file_example.module
  • file_example_file_check_exists_submit() : file_example.module
  • file_example_get_managed_file() : file_example.module
  • file_example_intro() : file_example.module
  • file_example_managed_write_submit() : file_example.module
  • file_example_menu() : file_example.module
  • file_example_permission() : file_example.module
  • file_example_read_submit() : file_example.module
  • file_example_readwrite() : file_example.module
  • file_example_session_contents() : file_example.module
  • file_example_show_session_contents_submit() : file_example.module
  • file_example_stream_wrappers() : file_example.module
  • file_example_unmanaged_php_submit() : file_example.module
  • file_example_unmanaged_write_submit() : file_example.module
  • FILE_EXECUTABLE : install.inc
  • FILE_EXIST : install.inc
  • FILE_EXISTS_ERROR : file.inc
  • FILE_EXISTS_RENAME : file.inc
  • FILE_EXISTS_REPLACE : file.inc
  • file_field_delete() : file.field.inc
  • file_field_delete_file() : file.field.inc
  • file_field_delete_revision() : file.field.inc
  • file_field_displayed() : file.field.inc
  • file_field_formatter_info() : file.field.inc
  • file_field_formatter_view() : file.field.inc
  • file_field_info() : file.field.inc
  • file_field_insert() : file.field.inc
  • file_field_instance_settings_form() : file.field.inc
  • file_field_is_empty() : file.field.inc
  • file_field_load() : file.field.inc
  • file_field_prepare_view() : file.field.inc
  • file_field_presave() : file.field.inc
  • file_field_schema() : file.install
  • file_field_settings_form() : file.field.inc
  • file_field_update() : file.field.inc
  • file_field_widget_form() : file.field.inc
  • file_field_widget_info() : file.field.inc
  • file_field_widget_process() : file.field.inc
  • file_field_widget_process_multiple() : file.field.inc
  • file_field_widget_settings_form() : file.field.inc
  • file_field_widget_submit() : file.field.inc
  • file_field_widget_upload_validators() : file.field.inc
  • file_field_widget_uri() : file.field.inc
  • file_field_widget_value() : file.field.inc
  • file_file_delete() : file.module
  • file_file_download() : file.module
  • file_get_content_headers() : file.inc
  • file_get_file_references() : file.module
  • file_get_mimetype() : file.inc
  • file_get_stream_wrappers() : file.inc
  • file_help() : file.module
  • file_htaccess_lines() : file.inc
  • file_icon_map() : file.module
  • file_icon_path() : file.module
  • file_icon_url() : file.module
  • file_load() : file.inc
  • file_load_multiple() : file.inc
  • file_managed_file_pre_render() : file.module
  • file_managed_file_process() : file.module
  • file_managed_file_save_upload() : file.module
  • file_managed_file_submit() : file.module
  • file_managed_file_validate() : file.module
  • file_managed_file_value() : file.module
  • file_menu() : file.module
  • file_mimetype_mapping() : file.mimetypes.inc
  • FILE_MODIFY_PERMISSIONS : file.inc
  • file_move() : file.inc
  • file_munge_filename() : file.inc
  • FILE_NOT_EXECUTABLE : install.inc
  • FILE_NOT_EXIST : install.inc
  • FILE_NOT_READABLE : install.inc
  • FILE_NOT_WRITABLE : install.inc
  • file_prepare_directory() : file.inc
  • file_progress_implementation() : file.module
  • FILE_READABLE : install.inc
  • file_requirements() : file.install
  • file_save() : file.inc
  • file_save_data() : file.inc
  • file_save_upload() : file.inc
  • file_scan_directory() : file.inc
  • file_space_used() : file.inc
  • FILE_STATUS_PERMANENT : file.inc
  • file_stream_wrapper_get_class() : file.inc
  • file_stream_wrapper_get_instance_by_scheme() : file.inc
  • file_stream_wrapper_get_instance_by_uri() : file.inc
  • file_stream_wrapper_uri_normalize() : file.inc
  • file_stream_wrapper_valid_scheme() : file.inc
  • file_theme() : file.module
  • file_transfer() : file.inc
  • file_unmanaged_copy() : file.inc
  • file_unmanaged_delete() : file.inc
  • file_unmanaged_delete_recursive() : file.inc
  • file_unmanaged_move() : file.inc
  • file_unmanaged_save_data() : file.inc
  • file_unmunge_filename() : file.inc
  • file_upload_max_size() : file.inc
  • file_uri_scheme() : file.inc
  • file_uri_target() : file.inc
  • file_usage_add() : file.inc
  • file_usage_delete() : file.inc
  • file_usage_list() : file.inc
  • file_valid_uri() : file.inc
  • file_validate() : file.inc
  • file_validate_extensions() : file.inc
  • file_validate_image_resolution() : file.inc
  • file_validate_is_image() : file.inc
  • file_validate_name_length() : file.inc
  • file_validate_size() : file.inc
  • FILE_WRITABLE : install.inc
  • filter_access() : filter.module
  • filter_admin_disable() : filter.admin.inc
  • filter_admin_disable_submit() : filter.admin.inc
  • filter_admin_format_form() : filter.admin.inc
  • filter_admin_format_form_submit() : filter.admin.inc
  • filter_admin_format_form_validate() : filter.admin.inc
  • filter_admin_format_page() : filter.admin.inc
  • filter_admin_format_title() : filter.module
  • filter_admin_overview() : filter.admin.inc
  • filter_admin_overview_submit() : filter.admin.inc
  • filter_default_format() : filter.module
  • filter_dom_load() : filter.module
  • filter_dom_serialize() : filter.module
  • filter_dom_serialize_escape_cdata_element() : filter.module
  • filter_element_info() : filter.module
  • filter_example_filter_info() : filter_example.module
  • filter_example_help() : filter_example.module
  • filter_example_menu() : filter_example.module
  • filter_fallback_format() : filter.module
  • filter_fallback_format_title() : filter.module
  • filter_filter_info() : filter.module
  • filter_form_access_denied() : filter.module
  • filter_format_allowcache() : filter.module
  • filter_format_disable() : filter.module
  • filter_format_exists() : filter.module
  • filter_format_load() : filter.module
  • filter_format_save() : filter.module
  • filter_formats() : filter.module
  • filter_formats_reset() : filter.module
  • filter_get_filters() : filter.module
  • filter_get_formats_by_role() : filter.module
  • filter_get_roles_by_format() : filter.module
  • filter_help() : filter.module
  • filter_install() : filter.install
  • filter_list_format() : filter.module
  • filter_menu() : filter.module
  • filter_modules_disabled() : filter.module
  • filter_modules_enabled() : filter.module
  • filter_permission() : filter.module
  • filter_permission_name() : filter.module
  • filter_process_format() : filter.module
  • filter_schema() : filter.install
  • filter_theme() : filter.module
  • filter_tips_long() : filter.pages.inc
  • filter_update_7000() : filter.install
  • filter_update_7001() : filter.install
  • filter_update_7003() : filter.install
  • filter_update_7005() : filter.install
  • filter_update_7008() : filter.install
  • filter_update_7009() : filter.install
  • filter_update_7010() : filter.install
  • filter_update_dependencies() : filter.install
  • filter_xss() : common.inc
  • filter_xss_admin() : common.inc
  • filter_xss_bad_protocol() : common.inc
  • fix_gpc_magic() : common.inc
  • flood_clear_event() : common.inc
  • flood_is_allowed() : common.inc
  • flood_register_event() : common.inc
  • form_builder() : form.inc
  • form_clear_error() : form.inc
  • form_error() : form.inc
  • form_example_element_demo_form() : form_example_elements.inc
  • form_example_element_demo_form_submit() : form_example_elements.inc
  • form_example_element_info() : form_example.module
  • form_example_help() : form_example.module
  • form_example_intro() : form_example.module
  • form_example_menu() : form_example.module
  • form_example_phonenumber_combined_process() : form_example_elements.inc
  • form_example_phonenumber_combined_validate() : form_example_elements.inc
  • form_example_phonenumber_combined_value() : form_example_elements.inc
  • form_example_phonenumber_discrete_process() : form_example_elements.inc
  • form_example_phonenumber_discrete_validate() : form_example_elements.inc
  • form_example_states_form() : form_example_states.inc
  • form_example_states_form_submit() : form_example_states.inc
  • form_example_theme() : form_example.module
  • form_example_tutorial() : form_example_tutorial.inc
  • form_example_tutorial_1() : form_example_tutorial.inc
  • form_example_tutorial_10() : form_example_tutorial.inc
  • form_example_tutorial_10_submit() : form_example_tutorial.inc
  • form_example_tutorial_10_validate() : form_example_tutorial.inc
  • form_example_tutorial_2() : form_example_tutorial.inc
  • form_example_tutorial_3() : form_example_tutorial.inc
  • form_example_tutorial_4() : form_example_tutorial.inc
  • form_example_tutorial_5() : form_example_tutorial.inc
  • form_example_tutorial_6() : form_example_tutorial.inc
  • form_example_tutorial_6_validate() : form_example_tutorial.inc
  • form_example_tutorial_7() : form_example_tutorial.inc
  • form_example_tutorial_7_submit() : form_example_tutorial.inc
  • form_example_tutorial_7_validate() : form_example_tutorial.inc
  • form_example_tutorial_8() : form_example_tutorial.inc
  • form_example_tutorial_8_next_submit() : form_example_tutorial.inc
  • form_example_tutorial_8_next_validate() : form_example_tutorial.inc
  • form_example_tutorial_8_page_two() : form_example_tutorial.inc
  • form_example_tutorial_8_page_two_back() : form_example_tutorial.inc
  • form_example_tutorial_8_page_two_submit() : form_example_tutorial.inc
  • form_example_tutorial_9() : form_example_tutorial.inc
  • form_example_tutorial_9_add_name() : form_example_tutorial.inc
  • form_example_tutorial_9_remove_name() : form_example_tutorial.inc
  • form_example_tutorial_9_submit() : form_example_tutorial.inc
  • form_example_tutorial_9_validate() : form_example_tutorial.inc
  • form_example_wizard() : form_example_wizard.inc
  • form_example_wizard_location_info() : form_example_wizard.inc
  • form_example_wizard_location_info_validate() : form_example_wizard.inc
  • form_example_wizard_next_submit() : form_example_wizard.inc
  • form_example_wizard_other_info() : form_example_wizard.inc
  • form_example_wizard_personal_info() : form_example_wizard.inc
  • form_example_wizard_previous_submit() : form_example_wizard.inc
  • form_example_wizard_submit() : form_example_wizard.inc
  • form_execute_handlers() : form.inc
  • form_get_cache() : form.inc
  • form_get_error() : form.inc
  • form_get_errors() : form.inc
  • form_get_options() : form.inc
  • form_load_include() : form.inc
  • form_options_flatten() : form.inc
  • form_pre_render_conditional_form_element() : form.inc
  • form_pre_render_fieldset() : form.inc
  • form_process_actions() : form.inc
  • form_process_checkbox() : form.inc
  • form_process_checkboxes() : form.inc
  • form_process_container() : form.inc
  • form_process_date() : form.inc
  • form_process_fieldset() : form.inc
  • form_process_machine_name() : form.inc
  • form_process_password_confirm() : form.inc
  • form_process_radios() : form.inc
  • form_process_select() : form.inc
  • form_process_tableselect() : form.inc
  • form_process_vertical_tabs() : form.inc
  • form_process_weight() : form.inc
  • form_select_options() : form.inc
  • form_set_cache() : form.inc
  • form_set_error() : form.inc
  • form_set_value() : form.inc
  • form_state_defaults() : form.inc
  • form_state_keys_no_cache() : form.inc
  • form_state_values_clean() : form.inc
  • form_type_checkbox_value() : form.inc
  • form_type_checkboxes_value() : form.inc
  • form_type_form_example_checkbox_value() : form_example_elements.inc
  • form_type_image_button_value() : form.inc
  • form_type_password_confirm_value() : form.inc
  • form_type_radios_value() : form.inc
  • form_type_select_value() : form.inc
  • form_type_tableselect_value() : form.inc
  • form_type_textfield_value() : form.inc
  • form_type_token_value() : form.inc
  • form_validate_machine_name() : form.inc
  • format_date() : common.inc
  • format_interval() : common.inc
  • format_plural() : common.inc
  • format_rss_channel() : common.inc
  • format_rss_item() : common.inc
  • format_size() : common.inc
  • format_string() : bootstrap.inc
  • format_username() : common.inc
  • format_xml_elements() : common.inc
  • forum_admin_settings() : forum.admin.inc
  • forum_block_configure() : forum.module
  • forum_block_info() : forum.module
  • forum_block_save() : forum.module
  • forum_block_view() : forum.module
  • forum_block_view_pre_render() : forum.module
  • forum_comment_delete() : forum.module
  • forum_comment_publish() : forum.module
  • forum_comment_unpublish() : forum.module
  • forum_comment_update() : forum.module
  • forum_confirm_delete() : forum.admin.inc
  • forum_confirm_delete_submit() : forum.admin.inc
  • forum_enable() : forum.install
  • forum_entity_info_alter() : forum.module
  • forum_field_storage_pre_insert() : forum.module
  • forum_field_storage_pre_update() : forum.module
  • forum_form() : forum.module
  • forum_form_container() : forum.admin.inc
  • forum_form_forum() : forum.admin.inc
  • forum_form_main() : forum.admin.inc
  • forum_form_node_form_alter() : forum.module
  • forum_form_submit() : forum.admin.inc
  • forum_form_taxonomy_form_term_alter() : forum.module
  • forum_form_taxonomy_form_vocabulary_alter() : forum.module
  • forum_forum_load() : forum.module
  • forum_get_topics() : forum.module
  • forum_help() : forum.module
  • forum_install() : forum.install
  • forum_menu() : forum.module
  • forum_menu_local_tasks_alter() : forum.module
  • forum_node_delete() : forum.module
  • forum_node_info() : forum.module
  • forum_node_insert() : forum.module
  • forum_node_load() : forum.module
  • forum_node_presave() : forum.module
  • forum_node_update() : forum.module
  • forum_node_validate() : forum.module
  • forum_node_view() : forum.module
  • forum_overview() : forum.admin.inc
  • forum_page() : forum.pages.inc
  • forum_permission() : forum.module
  • forum_rdf_mapping() : forum.module
  • forum_schema() : forum.install
  • forum_taxonomy_term_delete() : forum.module
  • forum_theme() : forum.module
  • forum_uninstall() : forum.install
  • forum_update_7000() : forum.install
  • forum_update_7001() : forum.install
  • forum_update_7002() : forum.install
  • forum_update_7003() : forum.install
  • forum_update_7011() : forum.install
  • forum_update_7012() : forum.install
  • forum_update_dependencies() : forum.install
  • forum_uri() : forum.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- g -

  • garland_breadcrumb() : template.php
  • garland_form_system_theme_settings_alter() : theme-settings.php
  • garland_preprocess_block() : template.php
  • garland_preprocess_comment() : template.php
  • garland_preprocess_html() : template.php
  • garland_preprocess_maintenance_page() : template.php
  • garland_preprocess_node() : template.php
  • garland_preprocess_page() : template.php
  • garland_preprocess_region() : template.php
  • garland_process_html() : template.php
  • garland_process_page() : template.php
  • get_t() : bootstrap.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- h -

  • help_help() : help.module
  • help_links_as_list() : help.admin.inc
  • help_main() : help.admin.inc
  • help_menu() : help.module
  • help_page() : help.admin.inc
  • hide() : common.inc
  • hook_action_info() : system.api.php
  • hook_action_info_alter() : system.api.php
  • hook_actions_delete() : system.api.php
  • hook_admin_paths() : system.api.php
  • hook_admin_paths_alter() : system.api.php
  • hook_aggregator_fetch() : aggregator.api.php
  • hook_aggregator_fetch_info() : aggregator.api.php
  • hook_aggregator_parse() : aggregator.api.php
  • hook_aggregator_parse_info() : aggregator.api.php
  • hook_aggregator_process() : aggregator.api.php
  • hook_aggregator_process_info() : aggregator.api.php
  • hook_aggregator_remove() : aggregator.api.php
  • hook_ajax_render_alter() : system.api.php
  • hook_archiver_info() : system.api.php
  • hook_archiver_info_alter() : system.api.php
  • hook_batch_alter() : system.api.php
  • hook_block_configure() : block.api.php
  • hook_block_info() : block.api.php
  • hook_block_info_alter() : block.api.php
  • hook_block_list_alter() : block.api.php
  • hook_block_save() : block.api.php
  • hook_block_view() : block.api.php
  • hook_block_view_alter() : block.api.php
  • hook_block_view_MODULE_DELTA_alter() : block.api.php
  • hook_boot() : system.api.php
  • hook_comment_delete() : comment.api.php
  • hook_comment_insert() : comment.api.php
  • hook_comment_load() : comment.api.php
  • hook_comment_presave() : comment.api.php
  • hook_comment_publish() : comment.api.php
  • hook_comment_unpublish() : comment.api.php
  • hook_comment_update() : comment.api.php
  • hook_comment_view() : comment.api.php
  • hook_comment_view_alter() : comment.api.php
  • hook_contextual_links_view_alter() : contextual.api.php
  • hook_countries_alter() : system.api.php
  • hook_cron() : system.api.php
  • hook_cron_queue_info() : system.api.php
  • hook_cron_queue_info_alter() : system.api.php
  • hook_css_alter() : system.api.php
  • hook_custom_theme() : system.api.php
  • hook_dashboard_regions() : dashboard.api.php
  • hook_dashboard_regions_alter() : dashboard.api.php
  • hook_date_format_types() : system.api.php
  • hook_date_format_types_alter() : system.api.php
  • hook_date_formats() : system.api.php
  • hook_date_formats_alter() : system.api.php
  • hook_delete() : node.api.php
  • hook_disable() : system.api.php
  • hook_drupal_goto_alter() : system.api.php
  • hook_element_info() : system.api.php
  • hook_element_info_alter() : system.api.php
  • hook_enable() : system.api.php
  • hook_entity_delete() : system.api.php
  • hook_entity_info() : system.api.php
  • hook_entity_info_alter() : system.api.php
  • hook_entity_insert() : system.api.php
  • hook_entity_load() : system.api.php
  • hook_entity_prepare_view() : system.api.php
  • hook_entity_presave() : system.api.php
  • hook_entity_query_alter() : system.api.php
  • hook_entity_update() : system.api.php
  • hook_entity_view() : system.api.php
  • hook_entity_view_alter() : system.api.php
  • hook_entity_view_mode_alter() : system.api.php
  • hook_exit() : system.api.php
  • hook_field_access() : field.api.php
  • hook_field_attach_create_bundle() : field.api.php
  • hook_field_attach_delete() : field.api.php
  • hook_field_attach_delete_bundle() : field.api.php
  • hook_field_attach_delete_revision() : field.api.php
  • hook_field_attach_form() : field.api.php
  • hook_field_attach_insert() : field.api.php
  • hook_field_attach_load() : field.api.php
  • hook_field_attach_prepare_translation_alter() : field.api.php
  • hook_field_attach_preprocess_alter() : field.api.php
  • hook_field_attach_presave() : field.api.php
  • hook_field_attach_purge() : field.api.php
  • hook_field_attach_rename_bundle() : field.api.php
  • hook_field_attach_submit() : field.api.php
  • hook_field_attach_update() : field.api.php
  • hook_field_attach_validate() : field.api.php
  • hook_field_attach_view_alter() : field.api.php
  • hook_field_available_languages_alter() : field.api.php
  • hook_field_create_field() : field.api.php
  • hook_field_create_instance() : field.api.php
  • hook_field_delete() : field.api.php
  • hook_field_delete_field() : field.api.php
  • hook_field_delete_instance() : field.api.php
  • hook_field_delete_revision() : field.api.php
  • hook_field_display_alter() : field.api.php
  • hook_field_display_ENTITY_TYPE_alter() : field.api.php
  • hook_field_extra_fields() : field.api.php
  • hook_field_extra_fields_alter() : field.api.php
  • hook_field_extra_fields_display_alter() : field.api.php
  • hook_field_formatter_info() : field.api.php
  • hook_field_formatter_info_alter() : field.api.php
  • hook_field_formatter_prepare_view() : field.api.php
  • hook_field_formatter_settings_form() : field_ui.api.php
  • hook_field_formatter_settings_summary() : field_ui.api.php
  • hook_field_formatter_view() : field.api.php
  • hook_field_info() : field.api.php
  • hook_field_info_alter() : field.api.php
  • hook_field_info_max_weight() : field.api.php
  • hook_field_insert() : field.api.php
  • hook_field_instance_settings_form() : field_ui.api.php
  • hook_field_is_empty() : field.api.php
  • hook_field_language_alter() : field.api.php
  • hook_field_load() : field.api.php
  • hook_field_prepare_translation() : field.api.php
  • hook_field_prepare_view() : field.api.php
  • hook_field_presave() : field.api.php
  • hook_field_purge_field() : field.api.php
  • hook_field_purge_instance() : field.api.php
  • hook_field_read_field() : field.api.php
  • hook_field_read_instance() : field.api.php
  • hook_field_schema() : field.api.php
  • hook_field_settings_form() : field_ui.api.php
  • hook_field_storage_create_field() : field.api.php
  • hook_field_storage_delete() : field.api.php
  • hook_field_storage_delete_field() : field.api.php
  • hook_field_storage_delete_instance() : field.api.php
  • hook_field_storage_delete_revision() : field.api.php
  • hook_field_storage_details() : field.api.php
  • hook_field_storage_details_alter() : field.api.php
  • hook_field_storage_info() : field.api.php
  • hook_field_storage_info_alter() : field.api.php
  • hook_field_storage_load() : field.api.php
  • hook_field_storage_pre_insert() : field.api.php
  • hook_field_storage_pre_load() : field.api.php
  • hook_field_storage_pre_update() : field.api.php
  • hook_field_storage_purge() : field.api.php
  • hook_field_storage_purge_field() : field.api.php
  • hook_field_storage_purge_field_instance() : field.api.php
  • hook_field_storage_query() : field.api.php
  • hook_field_storage_update_field() : field.api.php
  • hook_field_storage_write() : field.api.php
  • hook_field_update() : field.api.php
  • hook_field_update_field() : field.api.php
  • hook_field_update_forbid() : field.api.php
  • hook_field_update_instance() : field.api.php
  • hook_field_validate() : field.api.php
  • hook_field_widget_error() : field.api.php
  • hook_field_widget_form() : field.api.php
  • hook_field_widget_form_alter() : field.api.php
  • hook_field_widget_info() : field.api.php
  • hook_field_widget_info_alter() : field.api.php
  • hook_field_widget_properties_alter() : field.api.php
  • hook_field_widget_properties_ENTITY_TYPE_alter() : field.api.php
  • hook_field_widget_settings_form() : field_ui.api.php
  • hook_field_widget_WIDGET_TYPE_form_alter() : field.api.php
  • hook_file_copy() : system.api.php
  • hook_file_delete() : system.api.php
  • hook_file_download() : system.api.php
  • hook_file_download_access() : file.api.php
  • hook_file_download_access_alter() : file.api.php
  • hook_file_insert() : system.api.php
  • hook_file_load() : system.api.php
  • hook_file_mimetype_mapping_alter() : system.api.php
  • hook_file_move() : system.api.php
  • hook_file_presave() : system.api.php
  • hook_file_update() : system.api.php
  • hook_file_url_alter() : system.api.php
  • hook_file_validate() : system.api.php
  • hook_filetransfer_info() : system.api.php
  • hook_filetransfer_info_alter() : system.api.php
  • hook_filter_format_disable() : filter.api.php
  • hook_filter_format_insert() : filter.api.php
  • hook_filter_format_update() : filter.api.php
  • hook_filter_info() : filter.api.php
  • hook_filter_info_alter() : filter.api.php
  • hook_flush_caches() : system.api.php
  • hook_form() : node.api.php
  • hook_form_alter() : system.api.php
  • hook_form_BASE_FORM_ID_alter() : system.api.php
  • hook_form_FORM_ID_alter() : system.api.php
  • hook_form_system_theme_settings_alter() : theme.api.php
  • hook_forms() : system.api.php
  • hook_help() : help.api.php
  • hook_hook_info() : system.api.php
  • hook_hook_info_alter() : system.api.php
  • hook_html_head_alter() : system.api.php
  • hook_image_default_styles() : image.api.php
  • hook_image_effect_info() : image.api.php
  • hook_image_effect_info_alter() : image.api.php
  • hook_image_style_delete() : image.api.php
  • hook_image_style_flush() : image.api.php
  • hook_image_style_save() : image.api.php
  • hook_image_styles_alter() : image.api.php
  • hook_image_toolkits() : system.api.php
  • hook_init() : system.api.php
  • hook_insert() : node.api.php
  • hook_install() : system.api.php
  • hook_install_tasks() : system.api.php
  • hook_install_tasks_alter() : system.api.php
  • hook_js_alter() : system.api.php
  • hook_language_fallback_candidates_alter() : language.api.php
  • hook_language_init() : language.api.php
  • hook_language_negotiation_info() : language.api.php
  • hook_language_negotiation_info_alter() : language.api.php
  • hook_language_switch_links_alter() : language.api.php
  • hook_language_types_info() : language.api.php
  • hook_language_types_info_alter() : language.api.php
  • hook_library() : system.api.php
  • hook_library_alter() : system.api.php
  • hook_load() : node.api.php
  • hook_locale() : locale.api.php
  • hook_mail() : system.api.php
  • hook_mail_alter() : system.api.php
  • hook_menu() : system.api.php
  • hook_menu_alter() : system.api.php
  • hook_menu_breadcrumb_alter() : system.api.php
  • hook_menu_contextual_links_alter() : system.api.php
  • hook_menu_delete() : menu.api.php
  • hook_menu_get_item_alter() : system.api.php
  • hook_menu_insert() : menu.api.php
  • hook_menu_link_alter() : system.api.php
  • hook_menu_link_delete() : system.api.php
  • hook_menu_link_insert() : system.api.php
  • hook_menu_link_update() : system.api.php
  • hook_menu_local_tasks_alter() : system.api.php
  • hook_menu_site_status_alter() : system.api.php
  • hook_menu_update() : menu.api.php
  • hook_module_implements_alter() : system.api.php
  • hook_modules_disabled() : system.api.php
  • hook_modules_enabled() : system.api.php
  • hook_modules_installed() : system.api.php
  • hook_modules_uninstalled() : system.api.php
  • hook_multilingual_settings_changed() : locale.api.php
  • hook_node_access() : node.api.php
  • hook_node_access_records() : node.api.php
  • hook_node_access_records_alter() : node.api.php
  • hook_node_delete() : node.api.php
  • hook_node_grants() : node.api.php
  • hook_node_grants_alter() : node.api.php
  • hook_node_info() : node.api.php
  • hook_node_insert() : node.api.php
  • hook_node_load() : node.api.php
  • hook_node_operations() : node.api.php
  • hook_node_prepare() : node.api.php
  • hook_node_presave() : node.api.php
  • hook_node_revision_delete() : node.api.php
  • hook_node_search_result() : node.api.php
  • hook_node_submit() : node.api.php
  • hook_node_type_delete() : node.api.php
  • hook_node_type_insert() : node.api.php
  • hook_node_type_update() : node.api.php
  • hook_node_update() : node.api.php
  • hook_node_update_index() : node.api.php
  • hook_node_validate() : node.api.php
  • hook_node_view() : node.api.php
  • hook_node_view_alter() : node.api.php
  • hook_openid() : openid.api.php
  • hook_openid_discovery_method_info() : openid.api.php
  • hook_openid_discovery_method_info_alter() : openid.api.php
  • hook_openid_normalization_method_info() : openid.api.php
  • hook_openid_normalization_method_info_alter() : openid.api.php
  • hook_openid_response() : openid.api.php
  • hook_options_list() : options.api.php
  • hook_overlay_child_initialize() : overlay.api.php
  • hook_overlay_parent_initialize() : overlay.api.php
  • hook_page_alter() : system.api.php
  • hook_page_build() : system.api.php
  • hook_page_delivery_callback_alter() : system.api.php
  • hook_path_delete() : path.api.php
  • hook_path_insert() : path.api.php
  • hook_path_update() : path.api.php
  • hook_permission() : system.api.php
  • hook_prepare() : node.api.php
  • hook_preprocess() : theme.api.php
  • hook_preprocess_HOOK() : theme.api.php
  • hook_process() : theme.api.php
  • hook_process_HOOK() : theme.api.php
  • hook_query_alter() : system.api.php
  • hook_query_TAG_alter() : system.api.php
  • hook_ranking() : node.api.php
  • hook_rdf_mapping() : rdf.api.php
  • hook_rdf_namespaces() : rdf.api.php
  • hook_registry_files_alter() : system.api.php
  • hook_requirements() : system.api.php
  • hook_schema() : system.api.php
  • hook_schema_alter() : system.api.php
  • hook_search_access() : search.api.php
  • hook_search_admin() : search.api.php
  • hook_search_execute() : search.api.php
  • hook_search_info() : search.api.php
  • hook_search_page() : search.api.php
  • hook_search_preprocess() : search.api.php
  • hook_search_reset() : search.api.php
  • hook_search_status() : search.api.php
  • hook_shortcut_default_set() : shortcut.api.php
  • hook_simpletest_alter() : simpletest.api.php
  • hook_stream_wrappers() : system.api.php
  • hook_stream_wrappers_alter() : system.api.php
  • hook_system_info_alter() : system.api.php
  • hook_system_theme_info() : system.api.php
  • hook_system_themes_page_alter() : system.api.php
  • hook_taxonomy_term_delete() : taxonomy.api.php
  • hook_taxonomy_term_insert() : taxonomy.api.php
  • hook_taxonomy_term_load() : taxonomy.api.php
  • hook_taxonomy_term_presave() : taxonomy.api.php
  • hook_taxonomy_term_update() : taxonomy.api.php
  • hook_taxonomy_term_view() : taxonomy.api.php
  • hook_taxonomy_term_view_alter() : taxonomy.api.php
  • hook_taxonomy_vocabulary_delete() : taxonomy.api.php
  • hook_taxonomy_vocabulary_insert() : taxonomy.api.php
  • hook_taxonomy_vocabulary_load() : taxonomy.api.php
  • hook_taxonomy_vocabulary_presave() : taxonomy.api.php
  • hook_taxonomy_vocabulary_update() : taxonomy.api.php
  • hook_test_finished() : simpletest.api.php
  • hook_test_group_finished() : simpletest.api.php
  • hook_test_group_started() : simpletest.api.php
  • hook_theme() : system.api.php
  • hook_theme_registry_alter() : system.api.php
  • hook_themes_disabled() : theme.api.php
  • hook_themes_enabled() : theme.api.php
  • hook_token_info() : system.api.php
  • hook_token_info_alter() : system.api.php
  • hook_tokens() : system.api.php
  • hook_tokens_alter() : system.api.php
  • hook_translated_menu_link_alter() : system.api.php
  • hook_trigger_info() : trigger.api.php
  • hook_trigger_info_alter() : trigger.api.php
  • hook_uninstall() : system.api.php
  • hook_update() : node.api.php
  • hook_update_dependencies() : system.api.php
  • hook_update_index() : search.api.php
  • hook_update_last_removed() : system.api.php
  • hook_update_N() : system.api.php
  • hook_update_projects_alter() : update.api.php
  • hook_update_status_alter() : update.api.php
  • hook_updater_info() : system.api.php
  • hook_updater_info_alter() : system.api.php
  • hook_url_inbound_alter() : system.api.php
  • hook_url_outbound_alter() : system.api.php
  • hook_user_cancel() : user.api.php
  • hook_user_cancel_methods_alter() : user.api.php
  • hook_user_categories() : user.api.php
  • hook_user_delete() : user.api.php
  • hook_user_insert() : user.api.php
  • hook_user_load() : user.api.php
  • hook_user_login() : user.api.php
  • hook_user_logout() : user.api.php
  • hook_user_operations() : user.api.php
  • hook_user_presave() : user.api.php
  • hook_user_role_delete() : user.api.php
  • hook_user_role_insert() : user.api.php
  • hook_user_role_presave() : user.api.php
  • hook_user_role_update() : user.api.php
  • hook_user_update() : user.api.php
  • hook_user_view() : user.api.php
  • hook_user_view_alter() : user.api.php
  • hook_username_alter() : system.api.php
  • hook_validate() : node.api.php
  • hook_verify_update_archive() : update.api.php
  • hook_view() : node.api.php
  • hook_watchdog() : system.api.php
  • hook_xmlrpc() : system.api.php
  • hook_xmlrpc_alter() : system.api.php
  • HTTP_REQUEST_TIMEOUT : common.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- i -

  • icon : forum-topic-list.tpl.php
  • icon_class : forum-list.tpl.php
  • icon_title : forum-list.tpl.php
  • if : install.php
  • image_crop() : image.inc
  • image_crop_effect() : image.effects.inc
  • image_crop_form() : image.admin.inc
  • image_default_style_revert() : image.module
  • image_default_style_save() : image.module
  • IMAGE_DERIVATIVE_TOKEN : image.module
  • image_desaturate() : image.inc
  • image_desaturate_effect() : image.effects.inc
  • image_dimensions_scale() : image.inc
  • image_effect_apply() : image.module
  • image_effect_color_validate() : image.admin.inc
  • image_effect_definition_load() : image.module
  • image_effect_definitions() : image.module
  • image_effect_delete() : image.module
  • image_effect_delete_form() : image.admin.inc
  • image_effect_delete_form_submit() : image.admin.inc
  • image_effect_form() : image.admin.inc
  • image_effect_form_submit() : image.admin.inc
  • image_effect_integer_validate() : image.admin.inc
  • image_effect_load() : image.module
  • image_effect_save() : image.module
  • image_effect_scale_validate() : image.admin.inc
  • image_effects() : image.module
  • image_example_colorize_effect() : image_example.module
  • image_example_colorize_form() : image_example.module
  • image_example_disable() : image_example.install
  • image_example_enable() : image_example.install
  • image_example_help() : image_example.module
  • image_example_image_default_styles() : image_example.module
  • image_example_image_effect_info() : image_example.module
  • image_example_image_style_delete() : image_example.module
  • image_example_image_style_save() : image_example.module
  • image_example_image_styles_alter() : image_example.module
  • image_example_install() : image_example.install
  • image_example_menu() : image_example.module
  • image_example_style_flush() : image_example.module
  • image_example_style_form() : image_example.pages.inc
  • image_example_style_form_submit() : image_example.pages.inc
  • image_example_style_form_validate() : image_example.pages.inc
  • image_example_theme() : image_example.module
  • image_example_uninstall() : image_example.install
  • image_field_delete() : image.field.inc
  • image_field_delete_field() : image.module
  • image_field_delete_instance() : image.module
  • image_field_delete_revision() : image.field.inc
  • image_field_formatter_info() : image.field.inc
  • image_field_formatter_settings_form() : image.field.inc
  • image_field_formatter_settings_summary() : image.field.inc
  • image_field_formatter_view() : image.field.inc
  • image_field_info() : image.field.inc
  • image_field_insert() : image.field.inc
  • image_field_instance_settings_form() : image.field.inc
  • image_field_is_empty() : image.field.inc
  • image_field_load() : image.field.inc
  • image_field_prepare_view() : image.field.inc
  • image_field_presave() : image.field.inc
  • image_field_schema() : image.install
  • image_field_settings_form() : image.field.inc
  • image_field_update() : image.field.inc
  • image_field_update_field() : image.module
  • image_field_update_instance() : image.module
  • image_field_widget_form() : image.field.inc
  • image_field_widget_info() : image.field.inc
  • image_field_widget_process() : image.field.inc
  • image_field_widget_settings_form() : image.field.inc
  • image_file_delete() : image.module
  • image_file_download() : image.module
  • image_file_move() : image.module
  • image_filter_keyword() : image.module
  • image_flush_caches() : image.module
  • image_form_system_file_system_settings_alter() : image.module
  • image_gd_check_settings() : image.gd.inc
  • image_gd_create_tmp() : image.gd.inc
  • image_gd_crop() : image.gd.inc
  • image_gd_desaturate() : image.gd.inc
  • image_gd_get_info() : image.gd.inc
  • image_gd_load() : image.gd.inc
  • image_gd_resize() : image.gd.inc
  • image_gd_rotate() : image.gd.inc
  • image_gd_save() : image.gd.inc
  • image_gd_settings() : image.gd.inc
  • image_gd_settings_validate() : image.gd.inc
  • image_get_available_toolkits() : image.inc
  • image_get_info() : image.inc
  • image_get_toolkit() : image.inc
  • image_help() : image.module
  • image_image_default_styles() : image.module
  • image_image_effect_info() : image.effects.inc
  • image_image_style_delete() : image.module
  • image_image_style_save() : image.module
  • image_install() : image.install
  • image_load() : image.inc
  • image_menu() : image.module
  • image_path_flush() : image.module
  • image_permission() : image.module
  • image_requirements() : image.install
  • image_resize() : image.inc
  • image_resize_dimensions() : image.effects.inc
  • image_resize_effect() : image.effects.inc
  • image_resize_form() : image.admin.inc
  • image_rotate() : image.inc
  • image_rotate_dimensions() : image.effects.inc
  • image_rotate_effect() : image.effects.inc
  • image_rotate_form() : image.admin.inc
  • image_save() : image.inc
  • image_scale() : image.inc
  • image_scale_and_crop() : image.inc
  • image_scale_and_crop_effect() : image.effects.inc
  • image_scale_dimensions() : image.effects.inc
  • image_scale_effect() : image.effects.inc
  • image_scale_form() : image.admin.inc
  • image_schema() : image.install
  • IMAGE_STORAGE_DEFAULT : image.module
  • IMAGE_STORAGE_EDITABLE : image.module
  • IMAGE_STORAGE_MODULE : image.module
  • IMAGE_STORAGE_NORMAL : image.module
  • IMAGE_STORAGE_OVERRIDE : image.module
  • image_style_add_form() : image.admin.inc
  • image_style_add_form_submit() : image.admin.inc
  • image_style_create_derivative() : image.module
  • image_style_delete() : image.module
  • image_style_delete_form() : image.admin.inc
  • image_style_delete_form_submit() : image.admin.inc
  • image_style_deliver() : image.module
  • image_style_effects() : image.module
  • image_style_flush() : image.module
  • image_style_form() : image.admin.inc
  • image_style_form_add_submit() : image.admin.inc
  • image_style_form_add_validate() : image.admin.inc
  • image_style_form_override_submit() : image.admin.inc
  • image_style_form_submit() : image.admin.inc
  • image_style_list() : image.admin.inc
  • image_style_load() : image.module
  • image_style_name_validate() : image.admin.inc
  • image_style_options() : image.module
  • image_style_path() : image.module
  • image_style_path_token() : image.module
  • image_style_revert_form() : image.admin.inc
  • image_style_revert_form_submit() : image.admin.inc
  • image_style_save() : image.module
  • image_style_transform_dimensions() : image.module
  • image_style_url() : image.module
  • image_styles() : image.module
  • image_system_file_system_settings_submit() : image.module
  • image_theme() : image.module
  • image_toolkit_invoke() : image.inc
  • image_uninstall() : image.install
  • image_update_7000() : image.install
  • image_update_7001() : image.install
  • image_update_7002() : image.install
  • image_update_7003() : image.install
  • image_update_7004() : image.install
  • image_update_7005() : image.install
  • image_update_dependencies() : image.install
  • install_already_done_error() : install.core.inc
  • install_begin_request() : install.core.inc
  • install_bootstrap_full() : install.core.inc
  • install_check_requirements() : install.core.inc
  • install_configure_form() : install.core.inc
  • install_configure_form_submit() : install.core.inc
  • install_configure_form_validate() : install.core.inc
  • install_database_errors() : install.core.inc
  • install_display_output() : install.core.inc
  • install_drupal() : install.core.inc
  • install_find_locales() : install.core.inc
  • install_find_profiles() : install.core.inc
  • install_finished() : install.core.inc
  • install_full_redirect_url() : install.core.inc
  • install_goto() : install.inc
  • install_import_locales() : install.core.inc
  • install_import_locales_remaining() : install.core.inc
  • install_load_profile() : install.core.inc
  • install_no_profile_error() : install.core.inc
  • install_profile_info() : install.inc
  • install_profile_modules() : install.core.inc
  • install_redirect_url() : install.core.inc
  • install_run_task() : install.core.inc
  • install_run_tasks() : install.core.inc
  • install_select_locale() : install.core.inc
  • install_select_locale_form() : install.core.inc
  • install_select_profile() : install.core.inc
  • install_select_profile_form() : install.core.inc
  • install_settings_form() : install.core.inc
  • install_settings_form_submit() : install.core.inc
  • install_settings_form_validate() : install.core.inc
  • install_state_defaults() : install.core.inc
  • install_system_module() : install.core.inc
  • INSTALL_TASK_RUN_IF_NOT_COMPLETED : install.core.inc
  • INSTALL_TASK_RUN_IF_REACHED : install.core.inc
  • INSTALL_TASK_SKIP : install.core.inc
  • install_tasks() : install.core.inc
  • install_tasks_to_display() : install.core.inc
  • install_tasks_to_perform() : install.core.inc
  • install_verify_completed_task() : install.core.inc
  • install_verify_pdo() : install.core.inc
  • install_verify_requirements() : install.core.inc
  • install_verify_settings() : install.core.inc
  • int2vancode() : comment.module
  • ip_address() : bootstrap.inc
  • is_container : forum-list.tpl.php
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- j -

  • JS_DEFAULT : common.inc
  • js_example_accordion() : js_example.module
  • js_example_js_weights() : js_example.module
  • js_example_menu() : js_example.module
  • js_example_theme() : js_example.module
  • JS_LIBRARY : common.inc
  • JS_THEME : common.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- l -

  • l() : common.inc
  • language : book-export-html.tpl.php , maintenance-page.tpl.php , html.tpl.php
  • language_default() : bootstrap.inc
  • language_fallback_get_candidates() : language.inc
  • language_from_default() : language.inc
  • language_initialize() : language.inc
  • language_list() : bootstrap.inc
  • LANGUAGE_LTR : bootstrap.inc
  • LANGUAGE_NEGOTIATION_DEFAULT : language.inc
  • language_negotiation_get() : language.inc
  • language_negotiation_get_any() : language.inc
  • language_negotiation_get_switch_links() : language.inc
  • language_negotiation_info() : language.inc
  • language_negotiation_purge() : language.inc
  • language_negotiation_set() : language.inc
  • LANGUAGE_NONE : bootstrap.inc
  • language_provider_invoke() : language.inc
  • language_provider_weight() : language.inc
  • LANGUAGE_RTL : bootstrap.inc
  • LANGUAGE_TYPE_CONTENT : bootstrap.inc
  • LANGUAGE_TYPE_INTERFACE : bootstrap.inc
  • LANGUAGE_TYPE_URL : bootstrap.inc
  • language_types() : bootstrap.inc
  • language_types_configurable() : language.inc
  • language_types_disable() : language.inc
  • language_types_info() : language.inc
  • language_types_set() : language.inc
  • language_url_split_prefix() : language.inc
  • last_reply : forum-topic-list.tpl.php
  • link : forum-list.tpl.php
  • list_allowed_values() : list.module
  • list_allowed_values_setting_validate() : list.module
  • list_allowed_values_string() : list.module
  • list_boolean_allowed_values_callback() : list.module
  • list_extract_allowed_values() : list.module
  • list_field_formatter_info() : list.module
  • list_field_formatter_view() : list.module
  • list_field_info() : list.module
  • list_field_is_empty() : list.module
  • list_field_schema() : list.install
  • list_field_settings_form() : list.module
  • list_field_update_field() : list.module
  • list_field_update_forbid() : list.module
  • list_field_validate() : list.module
  • list_field_widget_info_alter() : list.module
  • list_help() : list.module
  • list_options_list() : list.module
  • list_themes() : theme.inc
  • list_update_7001() : list.install
  • list_update_7002() : list.install
  • locale() : locale.module
  • locale_add_language() : locale.inc
  • locale_batch_by_component() : locale.inc
  • locale_batch_by_language() : locale.inc
  • locale_block_info() : locale.module
  • locale_block_view() : locale.module
  • locale_css_alter() : locale.module
  • locale_date_format_form() : locale.admin.inc
  • locale_date_format_form_submit() : locale.admin.inc
  • locale_date_format_language_overview_page() : locale.admin.inc
  • locale_date_format_reset_form() : locale.admin.inc
  • locale_date_format_reset_form_submit() : locale.admin.inc
  • locale_date_format_save() : locale.inc
  • locale_entity_info_alter() : locale.module
  • locale_field_comment_form_submit() : locale.module
  • locale_field_entity_form_submit() : locale.module
  • locale_field_language_alter() : locale.module
  • locale_field_language_fallback() : locale.module
  • locale_field_node_form_submit() : locale.module
  • locale_form_alter() : locale.module
  • locale_form_comment_form_alter() : locale.module
  • locale_form_node_form_alter() : locale.module
  • locale_form_node_type_form_alter() : locale.module
  • locale_form_path_admin_form_alter() : locale.module
  • locale_get_localized_date_format() : locale.inc
  • locale_get_plural() : locale.module
  • locale_help() : locale.module
  • LOCALE_IMPORT_KEEP : locale.inc
  • LOCALE_IMPORT_OVERWRITE : locale.inc
  • locale_init() : locale.module
  • locale_install() : locale.install
  • locale_js_alter() : locale.module
  • LOCALE_JS_OBJECT : locale.inc
  • LOCALE_JS_OBJECT_CONTEXT : locale.inc
  • LOCALE_JS_STRING : locale.inc
  • locale_language_from_browser() : locale.inc
  • locale_language_from_interface() : locale.inc
  • locale_language_from_session() : locale.inc
  • locale_language_from_url() : locale.inc
  • locale_language_from_user() : locale.inc
  • locale_language_list() : locale.module
  • locale_language_name() : locale.module
  • LOCALE_LANGUAGE_NEGOTIATION_BROWSER : locale.inc
  • locale_language_negotiation_info() : locale.module
  • LOCALE_LANGUAGE_NEGOTIATION_INTERFACE : locale.inc
  • LOCALE_LANGUAGE_NEGOTIATION_SESSION : locale.inc
  • LOCALE_LANGUAGE_NEGOTIATION_URL : locale.inc
  • LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN : locale.inc
  • LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK : locale.inc
  • LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX : locale.inc
  • LOCALE_LANGUAGE_NEGOTIATION_USER : locale.inc
  • locale_language_providers_session_form() : locale.admin.inc
  • locale_language_providers_url_form() : locale.admin.inc
  • locale_language_selector_form() : locale.module
  • locale_language_switcher_session() : locale.inc
  • locale_language_switcher_url() : locale.inc
  • locale_language_types_info() : locale.module
  • locale_language_url_fallback() : locale.inc
  • locale_language_url_rewrite_session() : locale.inc
  • locale_language_url_rewrite_url() : locale.inc
  • locale_languages_add_screen() : locale.admin.inc
  • locale_languages_configure_form() : locale.admin.inc
  • locale_languages_configure_form_submit() : locale.admin.inc
  • locale_languages_custom_form() : locale.admin.inc
  • locale_languages_delete_form() : locale.admin.inc
  • locale_languages_delete_form_submit() : locale.admin.inc
  • locale_languages_edit_form() : locale.admin.inc
  • locale_languages_edit_form_submit() : locale.admin.inc
  • locale_languages_edit_form_validate() : locale.admin.inc
  • locale_languages_overview_form() : locale.admin.inc
  • locale_languages_overview_form_submit() : locale.admin.inc
  • locale_languages_predefined_form() : locale.admin.inc
  • locale_languages_predefined_form_submit() : locale.admin.inc
  • locale_languages_predefined_form_validate() : locale.admin.inc
  • locale_library_alter() : locale.module
  • locale_locale() : locale.module
  • locale_menu() : locale.module
  • locale_modules_disabled() : locale.module
  • locale_modules_enabled() : locale.module
  • locale_modules_installed() : locale.module
  • locale_multilingual_node_type() : locale.module
  • locale_permission() : locale.module
  • locale_reset() : locale.module
  • locale_schema() : locale.install
  • locale_string_is_safe() : locale.inc
  • locale_system_update() : locale.module
  • locale_theme() : locale.module
  • locale_themes_enabled() : locale.module
  • locale_translate_delete_form() : locale.admin.inc
  • locale_translate_delete_form_submit() : locale.admin.inc
  • locale_translate_delete_page() : locale.admin.inc
  • locale_translate_edit_form() : locale.admin.inc
  • locale_translate_edit_form_submit() : locale.admin.inc
  • locale_translate_edit_form_validate() : locale.admin.inc
  • locale_translate_export_po_form() : locale.admin.inc
  • locale_translate_export_po_form_submit() : locale.admin.inc
  • locale_translate_export_pot_form() : locale.admin.inc
  • locale_translate_export_screen() : locale.admin.inc
  • locale_translate_import_form() : locale.admin.inc
  • locale_translate_import_form_submit() : locale.admin.inc
  • locale_translate_overview_screen() : locale.admin.inc
  • locale_translate_seek_screen() : locale.admin.inc
  • locale_translation_filter_form() : locale.admin.inc
  • locale_translation_filter_form_submit() : locale.admin.inc
  • locale_translation_filter_form_validate() : locale.admin.inc
  • locale_translation_filters() : locale.admin.inc
  • locale_uninstall() : locale.install
  • locale_update_7000() : locale.install
  • locale_update_7001() : locale.install
  • locale_update_7002() : locale.install
  • locale_update_7003() : locale.install
  • locale_update_7004() : locale.install
  • locale_update_7005() : locale.install
  • locale_url_outbound_alter() : locale.module
  • lock_acquire() : lock.inc
  • lock_initialize() : lock.inc
  • lock_may_be_available() : lock.inc
  • lock_release() : lock.inc
  • lock_release_all() : lock.inc
  • lock_wait() : lock.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- m -

  • MAIL_LINE_ENDINGS : mail.inc
  • MAINTENANCE_MODE : authorize.php , update.php , install.php
  • map_month() : form.inc
  • MARK_NEW : theme.inc
  • MARK_READ : theme.inc
  • MARK_UPDATED : theme.inc
  • MENU_ACCESS_DENIED : menu.inc
  • menu_block_info() : menu.module
  • menu_block_view() : menu.module
  • menu_block_view_alter() : menu.module
  • menu_build_tree() : menu.inc
  • menu_cache_clear() : menu.inc
  • menu_cache_clear_all() : menu.inc
  • MENU_CALLBACK : menu.inc
  • menu_configure() : menu.admin.inc
  • MENU_CONTEXT_INLINE : menu.inc
  • MENU_CONTEXT_NONE : menu.inc
  • MENU_CONTEXT_PAGE : menu.inc
  • menu_contextual_links() : menu.inc
  • MENU_CREATED_BY_ADMIN : menu.inc
  • menu_custom_delete_submit() : menu.admin.inc
  • MENU_DEFAULT_LOCAL_TASK : menu.inc
  • menu_delete() : menu.module
  • menu_delete_links() : menu.inc
  • menu_delete_menu_confirm() : menu.admin.inc
  • menu_delete_menu_confirm_submit() : menu.admin.inc
  • menu_delete_menu_page() : menu.admin.inc
  • menu_edit_item() : menu.admin.inc
  • menu_edit_item_submit() : menu.admin.inc
  • menu_edit_item_validate() : menu.admin.inc
  • menu_edit_menu() : menu.admin.inc
  • menu_edit_menu_name_exists() : menu.admin.inc
  • menu_edit_menu_submit() : menu.admin.inc
  • menu_enable() : menu.module
  • menu_example_arg_optional_load() : menu_example.module
  • menu_example_arg_optional_to_arg() : menu_example.module
  • menu_example_custom_access() : menu_example.module
  • menu_example_id_load() : menu_example.module
  • menu_example_menu() : menu_example.module
  • menu_example_menu_alter() : menu_example.module
  • menu_example_menu_link_alter() : menu_example.module
  • menu_example_permission() : menu_example.module
  • menu_example_user_page_title() : menu_example.module
  • menu_execute_active_handler() : menu.inc
  • menu_form_node_form_alter() : menu.module
  • menu_form_node_type_form_alter() : menu.module
  • MENU_FOUND : menu.inc
  • menu_get_active_breadcrumb() : menu.inc
  • menu_get_active_help() : menu.inc
  • menu_get_active_menu_names() : menu.inc
  • menu_get_active_title() : menu.inc
  • menu_get_active_trail() : menu.inc
  • menu_get_ancestors() : menu.inc
  • menu_get_custom_theme() : menu.inc
  • menu_get_item() : menu.inc
  • menu_get_menus() : menu.module
  • menu_get_names() : menu.inc
  • menu_get_object() : menu.inc
  • menu_get_router() : menu.inc
  • menu_help() : menu.module
  • menu_install() : menu.install
  • MENU_IS_LOCAL_ACTION : menu.inc
  • MENU_IS_LOCAL_TASK : menu.inc
  • MENU_IS_ROOT : menu.inc
  • menu_item_delete_form() : menu.admin.inc
  • menu_item_delete_form_submit() : menu.admin.inc
  • menu_item_delete_page() : menu.admin.inc
  • menu_item_delete_submit() : menu.admin.inc
  • menu_link_children_relative_depth() : menu.inc
  • menu_link_delete() : menu.inc
  • menu_link_get_preferred() : menu.inc
  • menu_link_load() : menu.inc
  • menu_link_maintain() : menu.inc
  • menu_link_save() : menu.inc
  • menu_links_clone() : menu.inc
  • MENU_LINKS_TO_PARENT : menu.inc
  • menu_list_system_menus() : menu.inc
  • menu_load() : menu.module
  • menu_load_all() : menu.module
  • menu_load_links() : menu.inc
  • MENU_LOCAL_ACTION : menu.inc
  • menu_local_actions() : menu.inc
  • menu_local_tabs() : menu.inc
  • MENU_LOCAL_TASK : menu.inc
  • menu_local_tasks() : menu.inc
  • menu_main_menu() : menu.inc
  • MENU_MAX_DEPTH : menu.inc
  • MENU_MAX_MENU_NAME_LENGTH_UI : menu.module
  • MENU_MAX_PARTS : menu.inc
  • menu_menu() : menu.module
  • MENU_MODIFIED_BY_ADMIN : menu.inc
  • menu_navigation_links() : menu.inc
  • menu_node_delete() : menu.module
  • menu_node_insert() : menu.module
  • menu_node_prepare() : menu.module
  • menu_node_save() : menu.module
  • menu_node_submit() : menu.module
  • menu_node_update() : menu.module
  • MENU_NORMAL_ITEM : menu.inc
  • MENU_NOT_FOUND : menu.inc
  • menu_overview_form() : menu.admin.inc
  • menu_overview_form_submit() : menu.admin.inc
  • menu_overview_page() : menu.admin.inc
  • menu_overview_title() : menu.module
  • menu_parent_options() : menu.module
  • menu_parent_options_js() : menu.module
  • menu_permission() : menu.module
  • MENU_PREFERRED_LINK : menu.inc
  • menu_primary_local_tasks() : menu.inc
  • menu_rebuild() : menu.inc
  • menu_reset_item() : menu.module
  • menu_reset_item_confirm() : menu.admin.inc
  • menu_reset_item_confirm_submit() : menu.admin.inc
  • menu_reset_static_cache() : menu.inc
  • menu_router_build() : menu.inc
  • menu_save() : menu.module
  • menu_schema() : menu.install
  • menu_secondary_local_tasks() : menu.inc
  • menu_secondary_menu() : menu.inc
  • menu_set_active_item() : menu.inc
  • menu_set_active_menu_names() : menu.inc
  • menu_set_active_trail() : menu.inc
  • menu_set_custom_theme() : menu.inc
  • menu_set_item() : menu.inc
  • MENU_SITE_OFFLINE : menu.inc
  • MENU_SITE_ONLINE : menu.inc
  • MENU_SUGGESTED_ITEM : menu.inc
  • menu_tab_root_path() : menu.inc
  • menu_tail_load() : menu.inc
  • menu_tail_to_arg() : menu.inc
  • menu_theme() : menu.module
  • menu_tree() : menu.inc
  • menu_tree_all_data() : menu.inc
  • menu_tree_check_access() : menu.inc
  • menu_tree_collect_node_links() : menu.inc
  • menu_tree_data() : menu.inc
  • menu_tree_get_path() : menu.inc
  • menu_tree_output() : menu.inc
  • menu_tree_page_data() : menu.inc
  • menu_tree_set_path() : menu.inc
  • menu_uninstall() : menu.install
  • menu_unserialize() : menu.inc
  • menu_update_7000() : menu.install
  • menu_update_7001() : menu.install
  • menu_update_7002() : menu.install
  • menu_update_7003() : menu.install
  • MENU_VISIBLE_IN_BREADCRUMB : menu.inc
  • MENU_VISIBLE_IN_TREE : menu.inc
  • mime_header_decode() : unicode.inc
  • mime_header_encode() : unicode.inc
  • minimal_form_install_configure_form_alter() : minimal.profile
  • minimal_install() : minimal.install
  • module_disable() : module.inc
  • module_enable() : module.inc
  • module_exists() : module.inc
  • module_hook() : module.inc
  • module_hook_info() : module.inc
  • module_implements() : module.inc
  • module_implements_write_cache() : module.inc
  • module_invoke() : module.inc
  • module_invoke_all() : module.inc
  • module_list() : module.inc
  • module_load_all() : module.inc
  • module_load_all_includes() : module.inc
  • module_load_include() : module.inc
  • module_load_install() : module.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- n -

  • name : forum-list.tpl.php
  • new_text : forum-list.tpl.php , forum-topic-list.tpl.php
  • nid : book-node-export-html.tpl.php , node.tpl.php
  • node_access() : node.module
  • node_access_acquire_grants() : node.module
  • NODE_ACCESS_ALLOW : node.module
  • NODE_ACCESS_DENY : node.module
  • node_access_example_form_alter() : node_access_example.module
  • NODE_ACCESS_EXAMPLE_GRANT_ALL : node_access_example.module
  • node_access_example_menu() : node_access_example.module
  • node_access_example_node_access() : node_access_example.module
  • node_access_example_node_access_records() : node_access_example.module
  • node_access_example_node_delete() : node_access_example.module
  • node_access_example_node_grants() : node_access_example.module
  • node_access_example_node_insert() : node_access_example.module
  • node_access_example_node_load() : node_access_example.module
  • node_access_example_node_update() : node_access_example.module
  • node_access_example_permission() : node_access_example.module
  • node_access_example_private_node_listing() : node_access_example.module
  • node_access_example_schema() : node_access_example.install
  • node_access_grants() : node.module
  • NODE_ACCESS_IGNORE : node.module
  • node_access_needs_rebuild() : node.module
  • node_access_rebuild() : node.module
  • node_access_view_all_nodes() : node.module
  • node_access_write_grants() : node.module
  • node_action_info() : node.module
  • node_add() : node.pages.inc
  • node_add_body_field() : node.module
  • node_add_page() : node.pages.inc
  • node_admin_content() : node.admin.inc
  • node_admin_nodes() : node.admin.inc
  • node_admin_nodes_submit() : node.admin.inc
  • node_admin_nodes_validate() : node.admin.inc
  • node_admin_paths() : node.module
  • node_assign_owner_action() : node.module
  • node_assign_owner_action_form() : node.module
  • node_assign_owner_action_submit() : node.module
  • node_assign_owner_action_validate() : node.module
  • node_block_configure() : node.module
  • node_block_info() : node.module
  • node_block_list_alter() : node.module
  • node_block_save() : node.module
  • node_block_view() : node.module
  • node_build_content() : node.module
  • node_build_filter_query() : node.admin.inc
  • node_configure_rebuild_confirm() : node.admin.inc
  • node_configure_rebuild_confirm_submit() : node.admin.inc
  • node_content_form() : node.module
  • node_cron() : node.module
  • node_delete() : node.module
  • node_delete_confirm() : node.pages.inc
  • node_delete_confirm_submit() : node.pages.inc
  • node_delete_multiple() : node.module
  • node_entity_info() : node.module
  • node_example_entity_info_alter() : node_example.module
  • node_example_field_formatter_info() : node_example.module
  • node_example_field_formatter_view() : node_example.module
  • node_example_form() : node_example.module
  • node_example_help() : node_example.module
  • node_example_menu() : node_example.module
  • node_example_node_info() : node_example.module
  • node_example_node_type_insert() : node_example.module
  • node_example_page() : node_example.module
  • node_example_theme() : node_example.module
  • node_feed() : node.module
  • node_field_display_node_alter() : node.module
  • node_field_extra_fields() : node.module
  • node_file_download_access() : node.module
  • node_filter_form() : node.admin.inc
  • node_filter_form_submit() : node.admin.inc
  • node_filters() : node.admin.inc
  • node_form() : node.pages.inc
  • node_form_block_add_block_form_alter() : node.module
  • node_form_block_admin_configure_alter() : node.module
  • node_form_block_admin_configure_submit() : node.module
  • node_form_block_custom_block_delete_alter() : node.module
  • node_form_block_custom_block_delete_submit() : node.module
  • node_form_build_preview() : node.pages.inc
  • node_form_delete_submit() : node.pages.inc
  • node_form_search_form_alter() : node.module
  • node_form_submit() : node.pages.inc
  • node_form_submit_build_node() : node.pages.inc
  • node_form_validate() : node.pages.inc
  • node_forms() : node.module
  • node_get_recent() : node.module
  • node_help() : node.module
  • node_hook() : node.module
  • node_install() : node.install
  • node_invoke() : node.module
  • node_is_page() : node.module
  • node_last_changed() : node.module
  • node_last_viewed() : node.module
  • node_list_permissions() : node.module
  • node_load() : node.module
  • node_load_multiple() : node.module
  • node_make_sticky_action() : node.module
  • node_make_unsticky_action() : node.module
  • node_mark() : node.module
  • node_mass_update() : node.admin.inc
  • node_menu() : node.module
  • node_menu_local_tasks_alter() : node.module
  • node_modules_enabled() : node.module
  • node_modules_uninstalled() : node.module
  • node_multiple_delete_confirm() : node.admin.inc
  • node_multiple_delete_confirm_submit() : node.admin.inc
  • NODE_NEW_LIMIT : node.module
  • node_node_access() : node.module
  • node_node_operations() : node.admin.inc
  • node_node_type_insert() : content_types.inc
  • node_node_type_update() : content_types.inc
  • NODE_NOT_PROMOTED : node.module
  • NODE_NOT_PUBLISHED : node.module
  • NODE_NOT_STICKY : node.module
  • node_object_prepare() : node.module
  • node_overview_types() : content_types.inc
  • node_page_default() : node.module
  • node_page_edit() : node.pages.inc
  • node_page_title() : node.module
  • node_page_view() : node.module
  • node_permission() : node.module
  • node_permissions_get_configured_types() : node.module
  • node_preview() : node.pages.inc
  • node_promote_action() : node.module
  • NODE_PROMOTED : node.module
  • node_publish_action() : node.module
  • NODE_PUBLISHED : node.module
  • node_query_entity_field_access_alter() : node.module
  • node_query_node_access_alter() : node.module
  • node_ranking() : node.module
  • node_rdf_mapping() : node.module
  • node_requirements() : node.module
  • node_revision_delete() : node.module
  • node_revision_delete_confirm() : node.pages.inc
  • node_revision_delete_confirm_submit() : node.pages.inc
  • node_revision_list() : node.module
  • node_revision_overview() : node.pages.inc
  • node_revision_revert_confirm() : node.pages.inc
  • node_revision_revert_confirm_submit() : node.pages.inc
  • node_save() : node.module
  • node_save_action() : node.module
  • node_schema() : node.install
  • node_search_access() : node.module
  • node_search_admin() : node.module
  • node_search_execute() : node.module
  • node_search_info() : node.module
  • node_search_reset() : node.module
  • node_search_status() : node.module
  • node_search_validate() : node.module
  • node_show() : node.module
  • NODE_STICKY : node.module
  • node_submit() : node.module
  • node_tag_new() : node.module
  • node_theme() : node.module
  • node_title_list() : node.module
  • node_token_info() : node.tokens.inc
  • node_tokens() : node.tokens.inc
  • node_type_cache_reset() : node.module
  • node_type_delete() : node.module
  • node_type_delete_confirm() : content_types.inc
  • node_type_delete_confirm_submit() : content_types.inc
  • node_type_form() : content_types.inc
  • node_type_form_submit() : content_types.inc
  • node_type_form_validate() : content_types.inc
  • node_type_get_base() : node.module
  • node_type_get_name() : node.module
  • node_type_get_names() : node.module
  • node_type_get_type() : node.module
  • node_type_get_types() : node.module
  • node_type_load() : node.module
  • node_type_page_title() : node.module
  • node_type_reset() : content_types.inc
  • node_type_save() : node.module
  • node_type_set_defaults() : node.module
  • node_type_update_nodes() : node.module
  • node_types_rebuild() : node.module
  • node_unpromote_action() : node.module
  • node_unpublish_action() : node.module
  • node_unpublish_by_keyword_action() : node.module
  • node_unpublish_by_keyword_action_form() : node.module
  • node_unpublish_by_keyword_action_submit() : node.module
  • node_update_7000() : node.install
  • node_update_7001() : node.install
  • node_update_7002() : node.install
  • node_update_7003() : node.install
  • node_update_7004() : node.install
  • node_update_7005() : node.install
  • node_update_7006() : node.install
  • node_update_7007() : node.install
  • node_update_7008() : node.install
  • node_update_7009() : node.install
  • node_update_7010() : node.install
  • node_update_7011() : node.install
  • node_update_7012() : node.install
  • node_update_7013() : node.install
  • node_update_7014() : node.install
  • node_update_dependencies() : node.install
  • node_update_index() : node.module
  • node_uri() : node.module
  • node_user_cancel() : node.module
  • node_user_delete() : node.module
  • node_validate() : node.module
  • node_view() : node.module
  • node_view_multiple() : node.module
  • nodeapi_example_form_alter() : nodeapi_example.module
  • nodeapi_example_node_delete() : nodeapi_example.module
  • nodeapi_example_node_insert() : nodeapi_example.module
  • nodeapi_example_node_load() : nodeapi_example.module
  • nodeapi_example_node_update() : nodeapi_example.module
  • nodeapi_example_node_validate() : nodeapi_example.module
  • nodeapi_example_node_view() : nodeapi_example.module
  • nodeapi_example_schema() : nodeapi_example.install
  • nodeapi_example_theme() : nodeapi_example.module
  • nodeapi_example_uninstall() : nodeapi_example.install
  • number_field_formatter_info() : number.module
  • number_field_formatter_settings_form() : number.module
  • number_field_formatter_settings_summary() : number.module
  • number_field_formatter_view() : number.module
  • number_field_info() : number.module
  • number_field_instance_settings_form() : number.module
  • number_field_is_empty() : number.module
  • number_field_presave() : number.module
  • number_field_schema() : number.install
  • number_field_settings_form() : number.module
  • number_field_validate() : number.module
  • number_field_widget_error() : number.module
  • number_field_widget_form() : number.module
  • number_field_widget_info() : number.module
  • number_field_widget_validate() : number.module
  • number_help() : number.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- o -

  • openid_admin_paths() : openid.module
  • openid_association() : openid.module
  • openid_association_request() : openid.module
  • openid_authentication() : openid.module
  • openid_authentication_page() : openid.pages.inc
  • openid_authentication_request() : openid.module
  • openid_begin() : openid.module
  • openid_complete() : openid.module
  • openid_cron() : openid.module
  • OPENID_DH_DEFAULT_GEN : openid.inc
  • OPENID_DH_DEFAULT_MOD : openid.inc
  • openid_discovery() : openid.module
  • openid_extract_ax_values() : openid.inc
  • openid_extract_namespace() : openid.inc
  • openid_form_user_login_alter() : openid.module
  • openid_form_user_login_block_alter() : openid.module
  • openid_form_user_register_form_alter() : openid.module
  • openid_help() : openid.module
  • openid_login_validate() : openid.module
  • openid_menu() : openid.module
  • openid_menu_site_status_alter() : openid.module
  • openid_normalize() : openid.inc
  • OPENID_NS_1_0 : openid.inc
  • OPENID_NS_1_1 : openid.inc
  • OPENID_NS_2_0 : openid.inc
  • OPENID_NS_AX : openid.inc
  • OPENID_NS_OPENID : openid.inc
  • OPENID_NS_SREG : openid.inc
  • OPENID_NS_XRD : openid.inc
  • openid_openid_discovery_method_info() : openid.module
  • openid_openid_normalization_method_info() : openid.module
  • OPENID_RAND_SOURCE : openid.inc
  • openid_redirect() : openid.inc
  • openid_redirect_form() : openid.inc
  • openid_redirect_http() : openid.inc
  • openid_requirements() : openid.install
  • openid_schema() : openid.install
  • OPENID_SHA1_BLOCKSIZE : openid.inc
  • openid_update_6000() : openid.install
  • openid_update_7000() : openid.install
  • openid_user_add() : openid.pages.inc
  • openid_user_add_submit() : openid.pages.inc
  • openid_user_add_validate() : openid.pages.inc
  • openid_user_delete_form() : openid.pages.inc
  • openid_user_delete_form_submit() : openid.pages.inc
  • openid_user_identities() : openid.pages.inc
  • openid_user_insert() : openid.module
  • openid_user_login() : openid.module
  • openid_user_logout() : openid.module
  • openid_verify_assertion() : openid.module
  • openid_verify_assertion_nonce() : openid.module
  • openid_verify_assertion_return_url() : openid.module
  • openid_verify_assertion_signature() : openid.module
  • options_array_flatten() : options.module
  • options_array_transpose() : options.module
  • options_field_widget_error() : options.module
  • options_field_widget_form() : options.module
  • options_field_widget_info() : options.module
  • options_field_widget_settings_form() : options.module
  • options_field_widget_validate() : options.module
  • options_help() : options.module
  • options_theme() : options.module
  • overlay_admin_paths() : overlay.module
  • overlay_ajax_render_region() : overlay.module
  • overlay_batch_alter() : overlay.module
  • overlay_block_list_alter() : overlay.module
  • overlay_close_dialog() : overlay.module
  • overlay_deliver_empty_page() : overlay.module
  • overlay_disable_message() : overlay.module
  • overlay_display_empty_page() : overlay.module
  • overlay_drupal_goto_alter() : overlay.module
  • overlay_enable() : overlay.install
  • overlay_exit() : overlay.module
  • overlay_form_user_profile_form_alter() : overlay.module
  • overlay_get_mode() : overlay.module
  • overlay_get_regions_to_render() : overlay.module
  • overlay_get_rendered_content() : overlay.module
  • overlay_help() : overlay.module
  • overlay_init() : overlay.module
  • overlay_library() : overlay.module
  • overlay_menu() : overlay.module
  • overlay_overlay_child_initialize() : overlay.module
  • overlay_overlay_parent_initialize() : overlay.module
  • overlay_page_alter() : overlay.module
  • overlay_page_delivery_callback_alter() : overlay.module
  • overlay_permission() : overlay.module
  • overlay_preprocess_html() : overlay.module
  • overlay_preprocess_maintenance_page() : overlay.module
  • overlay_preprocess_page() : overlay.module
  • overlay_regions() : overlay.module
  • overlay_render_region() : overlay.module
  • overlay_request_page_refresh() : overlay.module
  • overlay_request_refresh() : overlay.module
  • overlay_set_mode() : overlay.module
  • overlay_set_regions_to_render() : overlay.module
  • overlay_store_rendered_content() : overlay.module
  • overlay_supplemental_regions() : overlay.module
  • overlay_system_info_alter() : overlay.module
  • overlay_theme() : overlay.module
  • overlay_trigger_refresh() : overlay.module
  • overlay_user_dismiss_message() : overlay.module
  • overlay_user_presave() : overlay.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- p -

  • page_example_arguments() : page_example.module
  • page_example_description() : page_example.module
  • page_example_help() : page_example.module
  • page_example_menu() : page_example.module
  • page_example_permission() : page_example.module
  • page_example_simple() : page_example.module
  • pager_default_initialize() : pager.inc
  • pager_example_help() : pager_example.module
  • pager_example_menu() : pager_example.module
  • pager_example_page() : pager_example.module
  • pager_find_page() : pager.inc
  • pager_get_query_parameters() : pager.inc
  • pager_load_array() : pager.inc
  • parse_size() : common.inc
  • PASS_THROUGH : bootstrap.inc
  • password_confirm_validate() : form.inc
  • path_admin_delete_confirm() : path.admin.inc
  • path_admin_delete_confirm_submit() : path.admin.inc
  • path_admin_edit() : path.admin.inc
  • path_admin_filter_form() : path.admin.inc
  • path_admin_filter_form_submit_filter() : path.admin.inc
  • path_admin_filter_form_submit_reset() : path.admin.inc
  • path_admin_form() : path.admin.inc
  • path_admin_form_delete_submit() : path.admin.inc
  • path_admin_form_submit() : path.admin.inc
  • path_admin_form_validate() : path.admin.inc
  • path_admin_overview() : path.admin.inc
  • path_delete() : path.inc
  • path_form_element_validate() : path.module
  • path_form_node_form_alter() : path.module
  • path_form_taxonomy_form_term_alter() : path.module
  • path_get_admin_paths() : path.inc
  • path_help() : path.module
  • path_is_admin() : path.inc
  • path_load() : path.inc
  • path_menu() : path.module
  • path_node_delete() : path.module
  • path_node_insert() : path.module
  • path_node_update() : path.module
  • path_permission() : path.module
  • path_save() : path.inc
  • path_taxonomy_term_delete() : path.module
  • path_taxonomy_term_insert() : path.module
  • path_taxonomy_term_update() : path.module
  • path_to_theme() : theme.inc
  • php_disable() : php.install
  • php_enable() : php.install
  • php_eval() : php.module
  • php_filter_info() : php.module
  • php_help() : php.module
  • php_permission() : php.module
  • phptemplate_init() : phptemplate.engine
  • phptemplate_theme() : phptemplate.engine
  • poll_block_info() : poll.module
  • poll_block_latest_poll_view() : poll.module
  • poll_block_view() : poll.module
  • poll_cancel() : poll.module
  • poll_cancel_form() : poll.module
  • poll_choice_js() : poll.module
  • poll_cron() : poll.module
  • poll_delete() : poll.module
  • poll_field_attach_prepare_translation_alter() : poll.module
  • poll_field_extra_fields() : poll.module
  • poll_form() : poll.module
  • poll_help() : poll.module
  • poll_insert() : poll.module
  • poll_load() : poll.module
  • poll_menu() : poll.module
  • poll_more_choices_submit() : poll.module
  • poll_node_form_submit() : poll.module
  • poll_node_info() : poll.module
  • poll_page() : poll.pages.inc
  • poll_permission() : poll.module
  • poll_rdf_mapping() : poll.module
  • poll_results() : poll.pages.inc
  • poll_schema() : poll.install
  • poll_teaser() : poll.module
  • poll_theme() : poll.module
  • poll_token_info() : poll.tokens.inc
  • poll_tokens() : poll.tokens.inc
  • poll_update() : poll.module
  • poll_update_7001() : poll.install
  • poll_update_7002() : poll.install
  • poll_update_7003() : poll.install
  • poll_update_7004() : poll.install
  • poll_user_cancel() : poll.module
  • poll_user_delete() : poll.module
  • poll_validate() : poll.module
  • poll_view() : poll.module
  • poll_view_results() : poll.module
  • poll_view_voting() : poll.module
  • poll_view_voting_validate() : poll.module
  • poll_vote() : poll.module
  • poll_votes() : poll.pages.inc
  • POSTGRESQL_NEXTID_LOCK : database.inc
  • PREG_CLASS_CJK : search.module
  • PREG_CLASS_NUMBERS : search.module
  • PREG_CLASS_PUNCTUATION : search.module
  • PREG_CLASS_UNICODE_WORD_BOUNDARY : unicode.inc
  • print : php-2.php
  • profile_admin_overview() : profile.admin.inc
  • profile_admin_overview_submit() : profile.admin.inc
  • profile_admin_settings_autocomplete() : profile.admin.inc
  • profile_autocomplete() : profile.pages.inc
  • profile_block_configure() : profile.module
  • profile_block_info() : profile.module
  • profile_block_save() : profile.module
  • profile_block_view() : profile.module
  • profile_browse() : profile.pages.inc
  • profile_category_access() : profile.module
  • profile_field_delete() : profile.admin.inc
  • profile_field_delete_submit() : profile.admin.inc
  • profile_field_form() : profile.admin.inc
  • profile_field_form_submit() : profile.admin.inc
  • profile_field_form_validate() : profile.admin.inc
  • profile_form_alter() : profile.module
  • profile_help() : profile.module
  • PROFILE_HIDDEN : profile.module
  • profile_menu() : profile.module
  • PROFILE_PRIVATE : profile.module
  • PROFILE_PUBLIC : profile.module
  • PROFILE_PUBLIC_LISTINGS : profile.module
  • profile_save_profile() : profile.module
  • profile_schema() : profile.install
  • profile_theme() : profile.module
  • profile_uninstall() : profile.install
  • profile_update_7001() : profile.install
  • profile_update_7002() : profile.install
  • profile_user_cancel() : profile.module
  • profile_user_categories() : profile.module
  • profile_user_delete() : profile.module
  • profile_user_form_validate() : profile.module
  • profile_user_insert() : profile.module
  • profile_user_load() : profile.module
  • profile_user_presave() : profile.module
  • profile_user_view() : profile.module
  • profile_view_field() : profile.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- q -

  • queue_example_add_remove_form() : queue_example.module
  • queue_example_add_remove_form_claim() : queue_example.module
  • queue_example_add_remove_form_clear_queue() : queue_example.module
  • queue_example_add_remove_form_delete() : queue_example.module
  • queue_example_add_remove_form_insert() : queue_example.module
  • queue_example_add_remove_form_run_cron() : queue_example.module
  • queue_example_menu() : queue_example.module
  • queue_example_retrieve_queue() : queue_example.module
  • queue_example_show_queue() : queue_example.module
  • queue_example_theme() : queue_example.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- r -

  • rdf_comment_load() : rdf.module
  • RDF_DEFAULT_BUNDLE : rdf.module
  • rdf_entity_info_alter() : rdf.module
  • rdf_entity_load() : rdf.module
  • rdf_example_help() : rdf_example.module
  • rdf_example_install() : rdf_example.install
  • rdf_example_rdf_mapping() : rdf_example.module
  • rdf_example_rdf_namespaces() : rdf_example.module
  • rdf_example_uninstall() : rdf_example.install
  • rdf_field_attach_view_alter() : rdf.module
  • rdf_get_namespaces() : rdf.module
  • rdf_help() : rdf.module
  • rdf_install() : rdf.install
  • rdf_mapping_delete() : rdf.module
  • rdf_mapping_load() : rdf.module
  • rdf_mapping_save() : rdf.module
  • rdf_modules_installed() : rdf.module
  • rdf_modules_uninstalled() : rdf.module
  • rdf_preprocess_comment() : rdf.module
  • rdf_preprocess_field() : rdf.module
  • rdf_preprocess_image() : rdf.module
  • rdf_preprocess_node() : rdf.module
  • rdf_preprocess_taxonomy_term() : rdf.module
  • rdf_preprocess_user_profile() : rdf.module
  • rdf_preprocess_username() : rdf.module
  • rdf_process() : rdf.module
  • rdf_rdf_namespaces() : rdf.module
  • rdf_rdfa_attributes() : rdf.module
  • rdf_schema() : rdf.install
  • rdf_theme() : rdf.module
  • region_select : block-admin-display-form.tpl.php
  • REGIONS_ALL : system.module
  • REGIONS_VISIBLE : system.module
  • registry_get_parsed_files() : registry.inc
  • registry_rebuild() : bootstrap.inc
  • REGISTRY_RESET_LOOKUP_CACHE : bootstrap.inc
  • registry_update() : bootstrap.inc
  • REGISTRY_WRITE_LOOKUP_CACHE : bootstrap.inc
  • render() : common.inc
  • render_example_add_hr() : render_example.module
  • render_example_add_prefix() : render_example.module
  • render_example_add_suffix() : render_example.module
  • render_example_arrays() : render_example.module
  • render_example_cache_expensive() : render_example.module
  • render_example_cache_pre_render() : render_example.module
  • render_example_change_to_ol() : render_example.module
  • render_example_demo_form() : render_example.module
  • render_example_embedded_form() : render_example.module
  • render_example_info() : render_example.module
  • render_example_menu() : render_example.module
  • render_example_page_alter() : render_example.module
  • render_example_theme() : render_example.module
  • render_example_uninstall() : render_example.install
  • request_path() : bootstrap.inc
  • REQUEST_TIME : bootstrap.inc
  • request_uri() : bootstrap.inc
  • REQUIRED_D6_SCHEMA_VERSION : update.inc
  • REQUIREMENT_ERROR : install.inc
  • REQUIREMENT_INFO : install.inc
  • REQUIREMENT_OK : install.inc
  • REQUIREMENT_WARNING : install.inc
  • row_class : block-admin-display-form.tpl.php
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- s -

  • SAVED_DELETED : common.inc
  • SAVED_NEW : common.inc
  • SAVED_UPDATED : common.inc
  • SCHEMA_INSTALLED : install.inc
  • SCHEMA_UNINSTALLED : install.inc
  • search_admin_reindex_submit() : search.admin.inc
  • search_admin_settings() : search.admin.inc
  • search_admin_settings_submit() : search.admin.inc
  • search_admin_settings_validate() : search.admin.inc
  • search_block_info() : search.module
  • search_block_view() : search.module
  • search_box() : search.module
  • search_box_form_submit() : search.module
  • search_comment_delete() : search.module
  • search_comment_insert() : search.module
  • search_comment_publish() : search.module
  • search_comment_unpublish() : search.module
  • search_comment_update() : search.module
  • search_cron() : search.module
  • search_data() : search.module
  • search_dirty() : search.module
  • search_excerpt() : search.module
  • search_expand_cjk() : search.module
  • search_expression_extract() : search.module
  • search_expression_insert() : search.module
  • search_form() : search.module
  • search_form_submit() : search.pages.inc
  • search_form_validate() : search.pages.inc
  • search_forms() : search.module
  • search_get_default_module_info() : search.module
  • search_get_info() : search.module
  • search_help() : search.module
  • search_index() : search.module
  • search_index_split() : search.module
  • search_invoke_preprocess() : search.module
  • search_is_active() : search.module
  • search_menu() : search.module
  • search_node_update() : search.module
  • search_node_update_index() : search.module
  • search_permission() : search.module
  • search_reindex() : search.module
  • search_reindex_confirm() : search.admin.inc
  • search_reindex_confirm_submit() : search.admin.inc
  • search_schema() : search.install
  • search_simplify() : search.module
  • search_simplify_excerpt_match() : search.module
  • search_theme() : search.module
  • search_touch_node() : search.module
  • search_uninstall() : search.install
  • search_update_7000() : search.install
  • search_update_totals() : search.module
  • search_view() : search.pages.inc
  • seven_admin_block_content() : template.php
  • seven_css_alter() : template.php
  • seven_node_add_list() : template.php
  • seven_preprocess_html() : template.php
  • seven_preprocess_maintenance_page() : template.php
  • seven_preprocess_page() : template.php
  • seven_tablesort_indicator() : template.php
  • shortcut_admin_add_link() : shortcut.admin.inc
  • shortcut_admin_paths() : shortcut.module
  • shortcut_block_info() : shortcut.module
  • shortcut_block_view() : shortcut.module
  • shortcut_current_displayed_set() : shortcut.module
  • shortcut_default_set() : shortcut.module
  • SHORTCUT_DEFAULT_SET_NAME : shortcut.module
  • shortcut_help() : shortcut.module
  • shortcut_install() : shortcut.install
  • shortcut_link_access() : shortcut.module
  • shortcut_link_add() : shortcut.admin.inc
  • shortcut_link_add_inline() : shortcut.admin.inc
  • shortcut_link_add_submit() : shortcut.admin.inc
  • shortcut_link_delete() : shortcut.admin.inc
  • shortcut_link_delete_submit() : shortcut.admin.inc
  • shortcut_link_edit() : shortcut.admin.inc
  • shortcut_link_edit_submit() : shortcut.admin.inc
  • shortcut_link_edit_validate() : shortcut.admin.inc
  • shortcut_max_slots() : shortcut.admin.inc
  • shortcut_menu() : shortcut.module
  • shortcut_page_alter() : shortcut.module
  • shortcut_permission() : shortcut.module
  • shortcut_preprocess_page() : shortcut.module
  • shortcut_renderable_links() : shortcut.module
  • shortcut_schema() : shortcut.install
  • shortcut_set_add_form() : shortcut.admin.inc
  • shortcut_set_add_form_submit() : shortcut.admin.inc
  • shortcut_set_add_form_validate() : shortcut.admin.inc
  • shortcut_set_admin() : shortcut.admin.inc
  • shortcut_set_assign_user() : shortcut.module
  • shortcut_set_customize() : shortcut.admin.inc
  • shortcut_set_customize_submit() : shortcut.admin.inc
  • shortcut_set_delete() : shortcut.module
  • shortcut_set_delete_access() : shortcut.module
  • shortcut_set_delete_form() : shortcut.admin.inc
  • shortcut_set_delete_form_submit() : shortcut.admin.inc
  • shortcut_set_edit_access() : shortcut.module
  • shortcut_set_edit_form() : shortcut.admin.inc
  • shortcut_set_edit_form_submit() : shortcut.admin.inc
  • shortcut_set_edit_form_validate() : shortcut.admin.inc
  • shortcut_set_get_unique_name() : shortcut.module
  • shortcut_set_load() : shortcut.module
  • shortcut_set_name() : shortcut.module
  • shortcut_set_reset_link_weights() : shortcut.module
  • shortcut_set_save() : shortcut.module
  • shortcut_set_switch() : shortcut.admin.inc
  • shortcut_set_switch_access() : shortcut.module
  • shortcut_set_switch_submit() : shortcut.admin.inc
  • shortcut_set_switch_validate() : shortcut.admin.inc
  • shortcut_set_title() : shortcut.module
  • shortcut_set_title_callback() : shortcut.module
  • shortcut_set_title_exists() : shortcut.module
  • shortcut_set_unassign_user() : shortcut.module
  • shortcut_sets() : shortcut.module
  • shortcut_theme() : shortcut.module
  • shortcut_toolbar_pre_render() : shortcut.module
  • shortcut_uninstall() : shortcut.install
  • shortcut_valid_link() : shortcut.module
  • show() : common.inc
  • simpletest_classloader_register() : simpletest.module
  • simpletest_clean_database() : simpletest.module
  • simpletest_clean_environment() : simpletest.module
  • simpletest_clean_results_table() : simpletest.module
  • simpletest_clean_temporary_directories() : simpletest.module
  • simpletest_example_empty_mysql_date() : simpletest_example.module
  • simpletest_example_form() : simpletest_example.module
  • simpletest_example_install() : simpletest_example.install
  • simpletest_example_menu() : simpletest_example.module
  • simpletest_example_node_access() : simpletest_example.module
  • simpletest_example_node_info() : simpletest_example.module
  • simpletest_example_permission() : simpletest_example.module
  • simpletest_example_update_7001() : simpletest_example.install
  • simpletest_generate_file() : simpletest.module
  • simpletest_help() : simpletest.module
  • simpletest_js_alter() : simpletest.module
  • simpletest_last_test_get() : simpletest.module
  • simpletest_log_read() : simpletest.module
  • simpletest_mail_alter() : simpletest.module
  • simpletest_menu() : simpletest.module
  • SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT : simpletest.install
  • simpletest_permission() : simpletest.module
  • simpletest_registry_files_alter() : simpletest.module
  • simpletest_requirements() : simpletest.install
  • simpletest_result_form() : simpletest.pages.inc
  • simpletest_result_form_submit() : simpletest.pages.inc
  • simpletest_result_get() : simpletest.pages.inc
  • simpletest_result_status_image() : simpletest.pages.inc
  • simpletest_run_tests() : simpletest.module
  • simpletest_schema() : simpletest.install
  • simpletest_settings_form() : simpletest.pages.inc
  • simpletest_settings_form_validate() : simpletest.pages.inc
  • simpletest_test_form() : simpletest.pages.inc
  • simpletest_test_form_submit() : simpletest.pages.inc
  • simpletest_test_get_all() : simpletest.module
  • simpletest_theme() : simpletest.module
  • simpletest_uninstall() : simpletest.install
  • simpletest_verbose() : drupal_web_test_case.php
  • st() : install.inc
  • standard_form_install_configure_form_alter() : standard.profile
  • standard_install() : standard.install
  • statistics_access_log() : statistics.admin.inc
  • statistics_block_configure() : statistics.module
  • statistics_block_info() : statistics.module
  • statistics_block_save() : statistics.module
  • statistics_block_view() : statistics.module
  • statistics_cron() : statistics.module
  • statistics_exit() : statistics.module
  • statistics_get() : statistics.module
  • statistics_help() : statistics.module
  • statistics_menu() : statistics.module
  • statistics_node_delete() : statistics.module
  • statistics_node_tracker() : statistics.pages.inc
  • statistics_node_view() : statistics.module
  • statistics_permission() : statistics.module
  • statistics_ranking() : statistics.module
  • statistics_recent_hits() : statistics.admin.inc
  • statistics_schema() : statistics.install
  • statistics_settings_form() : statistics.admin.inc
  • statistics_title_list() : statistics.module
  • statistics_token_info() : statistics.tokens.inc
  • statistics_tokens() : statistics.tokens.inc
  • statistics_top_pages() : statistics.admin.inc
  • statistics_top_referrers() : statistics.admin.inc
  • statistics_top_visitors() : statistics.admin.inc
  • statistics_uninstall() : statistics.install
  • statistics_update_7000() : statistics.install
  • statistics_update_index() : statistics.module
  • statistics_user_cancel() : statistics.module
  • statistics_user_delete() : statistics.module
  • statistics_user_tracker() : statistics.pages.inc
  • STREAM_WRAPPERS_ALL : stream_wrappers.inc
  • STREAM_WRAPPERS_HIDDEN : stream_wrappers.inc
  • STREAM_WRAPPERS_LOCAL : stream_wrappers.inc
  • STREAM_WRAPPERS_LOCAL_HIDDEN : stream_wrappers.inc
  • STREAM_WRAPPERS_LOCAL_NORMAL : stream_wrappers.inc
  • STREAM_WRAPPERS_NORMAL : stream_wrappers.inc
  • STREAM_WRAPPERS_READ : stream_wrappers.inc
  • STREAM_WRAPPERS_READ_VISIBLE : stream_wrappers.inc
  • STREAM_WRAPPERS_VISIBLE : stream_wrappers.inc
  • STREAM_WRAPPERS_WRITE : stream_wrappers.inc
  • STREAM_WRAPPERS_WRITE_VISIBLE : stream_wrappers.inc
  • syslog_facility_list() : syslog.module
  • syslog_form_system_logging_settings_alter() : syslog.module
  • syslog_help() : syslog.module
  • syslog_uninstall() : syslog.install
  • syslog_watchdog() : syslog.module
  • system_action_delete_orphans_post() : system.admin.inc
  • system_action_info() : system.module
  • system_actions_configure() : system.admin.inc
  • system_actions_configure_submit() : system.admin.inc
  • system_actions_configure_validate() : system.admin.inc
  • system_actions_delete_form() : system.admin.inc
  • system_actions_delete_form_submit() : system.admin.inc
  • system_actions_manage() : system.admin.inc
  • system_actions_manage_form() : system.admin.inc
  • system_actions_manage_form_submit() : system.admin.inc
  • system_actions_remove_orphans() : system.admin.inc
  • system_add_date_format_type_form() : system.admin.inc
  • system_add_date_format_type_form_submit() : system.admin.inc
  • system_add_date_format_type_form_validate() : system.admin.inc
  • system_add_date_formats_form_submit() : system.admin.inc
  • system_add_date_formats_form_validate() : system.admin.inc
  • system_add_module_assets() : system.module
  • system_admin_compact_mode() : system.module
  • system_admin_compact_page() : system.module
  • system_admin_config_page() : system.admin.inc
  • system_admin_index() : system.admin.inc
  • system_admin_menu_block() : system.module
  • system_admin_menu_block_page() : system.admin.inc
  • system_admin_paths() : system.module
  • system_archiver_info() : system.module
  • system_authorized_batch_process() : system.module
  • system_authorized_batch_processing_url() : system.module
  • system_authorized_get_url() : system.module
  • system_authorized_init() : system.module
  • system_authorized_run() : system.module
  • system_batch_page() : system.admin.inc
  • system_block_info() : system.module
  • system_block_ip_action() : system.module
  • system_block_view() : system.module
  • system_check_directory() : system.module
  • system_check_http_request() : system.module
  • system_clean_url_settings() : system.admin.inc
  • system_clear_cache_submit() : system.admin.inc
  • system_clear_page_cache_submit() : system.admin.inc
  • system_configure_date_formats_form() : system.admin.inc
  • system_cron() : system.module
  • system_cron_settings() : system.admin.inc
  • system_custom_theme() : system.module
  • system_date_delete_format_form() : system.admin.inc
  • system_date_delete_format_form_submit() : system.admin.inc
  • system_date_format_delete() : system.module
  • system_date_format_locale() : system.module
  • system_date_format_save() : system.module
  • system_date_format_type_delete() : system.module
  • system_date_format_type_save() : system.module
  • system_date_format_types() : system.module
  • system_date_formats() : system.module
  • system_date_formats_rebuild() : system.module
  • system_date_time_formats() : system.admin.inc
  • system_date_time_lookup() : system.admin.inc
  • system_date_time_settings() : system.admin.inc
  • system_default_date_formats() : date.inc
  • system_default_region() : system.module
  • system_delete_date_format_type_form() : system.admin.inc
  • system_delete_date_format_type_form_submit() : system.admin.inc
  • system_element_info() : system.module
  • system_entity_info() : system.module
  • system_file_system_settings() : system.admin.inc
  • system_filetransfer_info() : system.module
  • system_find_base_themes() : system.module
  • system_flush_caches() : system.module
  • system_form_user_profile_form_alter() : system.module
  • system_form_user_register_form_alter() : system.module
  • system_get_date_format() : system.module
  • system_get_date_formats() : system.module
  • system_get_date_types() : system.module
  • system_get_files_database() : system.module
  • system_get_info() : system.module
  • system_get_module_admin_tasks() : system.module
  • system_goto_action() : system.module
  • system_goto_action_form() : system.module
  • system_goto_action_submit() : system.module
  • system_help() : system.module
  • system_hook_info() : system.module
  • system_image_toolkit_settings() : system.admin.inc
  • system_image_toolkits() : system.module
  • system_init() : system.module
  • system_install() : system.install
  • system_ip_blocking() : system.admin.inc
  • system_ip_blocking_delete() : system.admin.inc
  • system_ip_blocking_delete_submit() : system.admin.inc
  • system_ip_blocking_form() : system.admin.inc
  • system_ip_blocking_form_submit() : system.admin.inc
  • system_ip_blocking_form_validate() : system.admin.inc
  • system_library() : system.module
  • system_list() : module.inc
  • system_list_reset() : module.inc
  • system_logging_settings() : system.admin.inc
  • system_mail() : system.module
  • system_menu() : system.module
  • system_message_action() : system.module
  • system_message_action_form() : system.module
  • system_message_action_submit() : system.module
  • system_modules() : system.admin.inc
  • system_modules_confirm_form() : system.admin.inc
  • system_modules_submit() : system.admin.inc
  • system_modules_uninstall() : system.admin.inc
  • system_modules_uninstall_confirm_form() : system.admin.inc
  • system_modules_uninstall_submit() : system.admin.inc
  • system_modules_uninstall_validate() : system.admin.inc
  • system_page_alter() : system.module
  • system_performance_settings() : system.admin.inc
  • system_permission() : system.module
  • system_php() : system.admin.inc
  • system_preprocess_block() : system.module
  • system_rebuild_module_data() : system.module
  • system_rebuild_theme_data() : system.module
  • system_region_list() : system.module
  • system_regional_settings() : system.admin.inc
  • system_requirements() : system.install
  • system_retrieve_file() : system.module
  • system_rss_feeds_settings() : system.admin.inc
  • system_run_automated_cron() : system.module
  • system_run_cron() : system.admin.inc
  • system_run_cron_submit() : system.admin.inc
  • system_schema() : system.install
  • system_schema_cache_7054() : system.install
  • system_send_email_action() : system.module
  • system_send_email_action_form() : system.module
  • system_send_email_action_submit() : system.module
  • system_send_email_action_validate() : system.module
  • system_settings_form() : system.module
  • system_settings_form_submit() : system.module
  • system_settings_overview() : system.admin.inc
  • system_site_information_settings() : system.admin.inc
  • system_site_information_settings_validate() : system.admin.inc
  • system_site_maintenance_mode() : system.admin.inc
  • system_sort_modules_by_info_name() : system.admin.inc
  • system_sort_themes() : system.admin.inc
  • system_status() : system.admin.inc
  • system_stream_wrappers() : system.module
  • system_system_info_alter() : system.module
  • system_theme() : system.module
  • system_theme_default() : system.admin.inc
  • system_theme_disable() : system.admin.inc
  • system_theme_enable() : system.admin.inc
  • system_theme_settings() : system.admin.inc
  • system_theme_settings_submit() : system.admin.inc
  • system_theme_settings_validate() : system.admin.inc
  • system_themes_admin_form() : system.admin.inc
  • system_themes_admin_form_submit() : system.admin.inc
  • system_themes_page() : system.admin.inc
  • system_time_zones() : system.module
  • system_timezone() : system.module
  • system_token_info() : system.tokens.inc
  • system_tokens() : system.tokens.inc
  • system_update_7000() : system.install
  • system_update_7001() : system.install
  • system_update_7002() : system.install
  • system_update_7003() : system.install
  • system_update_7004() : system.install
  • system_update_7005() : system.install
  • system_update_7007() : system.install
  • system_update_7009() : system.install
  • system_update_7011() : system.install
  • system_update_7013() : system.install
  • system_update_7015() : system.install
  • system_update_7016() : system.install
  • system_update_7017() : system.install
  • system_update_7018() : system.install
  • system_update_7020() : system.install
  • system_update_7021() : system.install
  • system_update_7027() : system.install
  • system_update_7029() : system.install
  • system_update_7032() : system.install
  • system_update_7033() : system.install
  • system_update_7034() : system.install
  • system_update_7036() : system.install
  • system_update_7042() : system.install
  • system_update_7044() : system.install
  • system_update_7045() : system.install
  • system_update_7046() : system.install
  • system_update_7047() : system.install
  • system_update_7048() : system.install
  • system_update_7049() : system.install
  • system_update_7050() : system.install
  • system_update_7051() : system.install
  • system_update_7052() : system.install
  • system_update_7053() : system.install
  • system_update_7054() : system.install
  • system_update_7055() : system.install
  • system_update_7057() : system.install
  • system_update_7058() : system.install
  • system_update_7059() : system.install
  • system_update_7060() : system.install
  • system_update_7061() : system.install
  • system_update_7062() : system.install
  • system_update_7063() : system.install
  • system_update_7064() : system.install
  • system_update_7065() : system.install
  • system_update_7066() : system.install
  • system_update_7067() : system.install
  • system_update_7068() : system.install
  • system_update_7069() : system.install
  • system_update_7070() : system.install
  • system_update_7071() : system.install
  • system_update_7072() : system.install
  • system_update_7073() : system.install
  • system_update_7074() : system.install
  • system_update_7076() : system.install
  • system_update_7077() : system.install
  • system_update_7078() : system.install
  • system_update_7079() : system.install
  • system_update_dependencies() : system.install
  • system_update_files_database() : system.module
  • system_update_last_removed() : system.install
  • system_updater_info() : system.module
  • system_user_login() : system.module
  • system_user_timezone() : system.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- t -

  • t() : bootstrap.inc
  • tabledrag_example_get_tree() : tabledrag_example_parent_form.inc
  • tabledrag_example_help() : tabledrag_example.module
  • tabledrag_example_install() : tabledrag_example.install
  • tabledrag_example_menu() : tabledrag_example.module
  • tabledrag_example_parent_form() : tabledrag_example_parent_form.inc
  • tabledrag_example_parent_form_submit() : tabledrag_example_parent_form.inc
  • tabledrag_example_parent_get_data() : tabledrag_example_parent_form.inc
  • tabledrag_example_schema() : tabledrag_example.install
  • tabledrag_example_simple_form() : tabledrag_example_simple_form.inc
  • tabledrag_example_simple_form_submit() : tabledrag_example_simple_form.inc
  • tabledrag_example_theme() : tabledrag_example.module
  • tabledrag_example_uninstall() : tabledrag_example.install
  • tablesort_cell() : tablesort.inc
  • tablesort_example_help() : tablesort_example.module
  • tablesort_example_install() : tablesort_example.install
  • tablesort_example_menu() : tablesort_example.module
  • tablesort_example_page() : tablesort_example.module
  • tablesort_example_schema() : tablesort_example.install
  • tablesort_example_uninstall() : tablesort_example.install
  • tablesort_get_order() : tablesort.inc
  • tablesort_get_query_parameters() : tablesort.inc
  • tablesort_get_sort() : tablesort.inc
  • tablesort_header() : tablesort.inc
  • tablesort_init() : tablesort.inc
  • taxonomy_admin_paths() : taxonomy.module
  • taxonomy_admin_vocabulary_title_callback() : taxonomy.module
  • taxonomy_allowed_values() : taxonomy.module
  • taxonomy_autocomplete() : taxonomy.pages.inc
  • taxonomy_autocomplete_validate() : taxonomy.module
  • taxonomy_build_node_index() : taxonomy.module
  • taxonomy_check_vocabulary_hierarchy() : taxonomy.module
  • taxonomy_delete_node_index() : taxonomy.module
  • taxonomy_entity_info() : taxonomy.module
  • taxonomy_entity_query_alter() : taxonomy.module
  • taxonomy_field_extra_fields() : taxonomy.module
  • taxonomy_field_formatter_info() : taxonomy.module
  • taxonomy_field_formatter_prepare_view() : taxonomy.module
  • taxonomy_field_formatter_view() : taxonomy.module
  • taxonomy_field_info() : taxonomy.module
  • taxonomy_field_is_empty() : taxonomy.module
  • taxonomy_field_presave() : taxonomy.module
  • taxonomy_field_schema() : taxonomy.install
  • taxonomy_field_settings_form() : taxonomy.module
  • taxonomy_field_validate() : taxonomy.module
  • taxonomy_field_widget_error() : taxonomy.module
  • taxonomy_field_widget_form() : taxonomy.module
  • taxonomy_field_widget_info() : taxonomy.module
  • taxonomy_field_widget_info_alter() : taxonomy.module
  • taxonomy_form_term() : taxonomy.admin.inc
  • taxonomy_form_term_submit() : taxonomy.admin.inc
  • taxonomy_form_term_submit_build_taxonomy_term() : taxonomy.admin.inc
  • taxonomy_form_term_validate() : taxonomy.admin.inc
  • taxonomy_form_vocabulary() : taxonomy.admin.inc
  • taxonomy_form_vocabulary_submit() : taxonomy.admin.inc
  • taxonomy_form_vocabulary_validate() : taxonomy.admin.inc
  • taxonomy_get_children() : taxonomy.module
  • taxonomy_get_parents() : taxonomy.module
  • taxonomy_get_parents_all() : taxonomy.module
  • taxonomy_get_term_by_name() : taxonomy.module
  • taxonomy_get_tree() : taxonomy.module
  • taxonomy_get_vocabularies() : taxonomy.module
  • taxonomy_help() : taxonomy.module
  • taxonomy_implode_tags() : taxonomy.module
  • taxonomy_menu() : taxonomy.module
  • taxonomy_node_delete() : taxonomy.module
  • taxonomy_node_insert() : taxonomy.module
  • taxonomy_node_update() : taxonomy.module
  • taxonomy_options_list() : taxonomy.module
  • taxonomy_overview_terms() : taxonomy.admin.inc
  • taxonomy_overview_terms_submit() : taxonomy.admin.inc
  • taxonomy_overview_vocabularies() : taxonomy.admin.inc
  • taxonomy_overview_vocabularies_submit() : taxonomy.admin.inc
  • taxonomy_permission() : taxonomy.module
  • taxonomy_rdf_mapping() : taxonomy.module
  • taxonomy_schema() : taxonomy.install
  • taxonomy_select_nodes() : taxonomy.module
  • taxonomy_taxonomy_term_delete() : taxonomy.module
  • taxonomy_taxonomy_vocabulary_update() : taxonomy.module
  • taxonomy_term_build_content() : taxonomy.module
  • taxonomy_term_confirm_delete() : taxonomy.admin.inc
  • taxonomy_term_confirm_delete_submit() : taxonomy.admin.inc
  • taxonomy_term_delete() : taxonomy.module
  • taxonomy_term_edit_access() : taxonomy.module
  • taxonomy_term_feed() : taxonomy.pages.inc
  • taxonomy_term_is_page() : taxonomy.module
  • taxonomy_term_load() : taxonomy.module
  • taxonomy_term_load_multiple() : taxonomy.module
  • taxonomy_term_page() : taxonomy.pages.inc
  • taxonomy_term_save() : taxonomy.module
  • taxonomy_term_show() : taxonomy.module
  • taxonomy_term_title() : taxonomy.module
  • taxonomy_term_uri() : taxonomy.module
  • taxonomy_term_view() : taxonomy.module
  • taxonomy_term_view_multiple() : taxonomy.module
  • taxonomy_terms_static_reset() : taxonomy.module
  • taxonomy_theme() : taxonomy.module
  • taxonomy_token_info() : taxonomy.tokens.inc
  • taxonomy_tokens() : taxonomy.tokens.inc
  • taxonomy_uninstall() : taxonomy.install
  • taxonomy_update_7001() : taxonomy.install
  • taxonomy_update_7002() : taxonomy.install
  • taxonomy_update_7003() : taxonomy.install
  • taxonomy_update_7004() : taxonomy.install
  • taxonomy_update_7005() : taxonomy.install
  • taxonomy_update_7006() : taxonomy.install
  • taxonomy_update_7007() : taxonomy.install
  • taxonomy_update_7008() : taxonomy.install
  • taxonomy_update_7009() : taxonomy.install
  • taxonomy_update_7010() : taxonomy.install
  • taxonomy_update_7011() : taxonomy.install
  • taxonomy_update_dependencies() : taxonomy.install
  • taxonomy_vocabulary_confirm_delete() : taxonomy.admin.inc
  • taxonomy_vocabulary_confirm_delete_submit() : taxonomy.admin.inc
  • taxonomy_vocabulary_confirm_reset_alphabetical() : taxonomy.admin.inc
  • taxonomy_vocabulary_confirm_reset_alphabetical_submit() : taxonomy.admin.inc
  • taxonomy_vocabulary_delete() : taxonomy.module
  • taxonomy_vocabulary_get_names() : taxonomy.module
  • taxonomy_vocabulary_load() : taxonomy.module
  • taxonomy_vocabulary_load_multiple() : taxonomy.module
  • taxonomy_vocabulary_machine_name_load() : taxonomy.module
  • taxonomy_vocabulary_save() : taxonomy.module
  • taxonomy_vocabulary_static_reset() : taxonomy.module
  • template_preprocess() : theme.inc
  • template_preprocess_aggregator_feed_source() : aggregator.pages.inc
  • template_preprocess_aggregator_item() : aggregator.pages.inc
  • template_preprocess_aggregator_summary_item() : aggregator.pages.inc
  • template_preprocess_aggregator_summary_items() : aggregator.pages.inc
  • template_preprocess_aggregator_wrapper() : aggregator.pages.inc
  • template_preprocess_block() : block.module
  • template_preprocess_block_admin_display_form() : block.admin.inc
  • template_preprocess_book_all_books_block() : book.module
  • template_preprocess_book_export_html() : book.module
  • template_preprocess_book_navigation() : book.module
  • template_preprocess_book_node_export_html() : book.module
  • template_preprocess_comment() : comment.module
  • template_preprocess_comment_wrapper() : comment.module
  • template_preprocess_contextual_links_example_object() : contextual_links_example.module
  • template_preprocess_dashboard_admin_display_form() : dashboard.module
  • template_preprocess_field() : field.module
  • template_preprocess_forum_icon() : forum.module
  • template_preprocess_forum_list() : forum.module
  • template_preprocess_forum_submitted() : forum.module
  • template_preprocess_forum_topic_list() : forum.module
  • template_preprocess_forums() : forum.module
  • template_preprocess_html() : theme.inc
  • template_preprocess_maintenance_page() : theme.inc
  • template_preprocess_menu_tree() : menu.inc
  • template_preprocess_node() : node.module
  • template_preprocess_overlay() : overlay.module
  • template_preprocess_page() : theme.inc
  • template_preprocess_poll_bar() : poll.module
  • template_preprocess_poll_results() : poll.module
  • template_preprocess_poll_vote() : poll.module
  • template_preprocess_profile_block() : profile.module
  • template_preprocess_profile_listing() : profile.module
  • template_preprocess_profile_wrapper() : profile.module
  • template_preprocess_region() : theme.inc
  • template_preprocess_search_block_form() : search.module
  • template_preprocess_search_result() : search.pages.inc
  • template_preprocess_search_results() : search.pages.inc
  • template_preprocess_taxonomy_term() : taxonomy.module
  • template_preprocess_theming_example_text_form() : theming_example.module
  • template_preprocess_user_picture() : user.module
  • template_preprocess_user_profile() : user.pages.inc
  • template_preprocess_user_profile_category() : user.pages.inc
  • template_preprocess_user_profile_item() : user.pages.inc
  • template_preprocess_username() : theme.inc
  • template_process() : theme.inc
  • template_process_field() : field.module
  • template_process_html() : theme.inc
  • template_process_maintenance_page() : theme.inc
  • template_process_overlay() : overlay.module
  • template_process_page() : theme.inc
  • template_process_username() : theme.inc
  • testing_install() : testing.install
  • text_field_formatter_info() : text.module
  • text_field_formatter_settings_form() : text.module
  • text_field_formatter_settings_summary() : text.module
  • text_field_formatter_view() : text.module
  • text_field_info() : text.module
  • text_field_instance_settings_form() : text.module
  • text_field_is_empty() : text.module
  • text_field_load() : text.module
  • text_field_prepare_translation() : text.module
  • text_field_schema() : text.install
  • text_field_settings_form() : text.module
  • text_field_validate() : text.module
  • text_field_widget_error() : text.module
  • text_field_widget_form() : text.module
  • text_field_widget_info() : text.module
  • text_field_widget_settings_form() : text.module
  • text_filter_format_disable() : text.module
  • text_filter_format_update() : text.module
  • text_help() : text.module
  • text_summary() : text.module
  • text_update_7000() : text.install
  • theme() : theme.inc
  • theme_admin_block() : system.admin.inc
  • theme_admin_block_content() : system.admin.inc
  • theme_admin_page() : system.admin.inc
  • theme_aggregator_block_item() : aggregator.module
  • theme_aggregator_categorize_items() : aggregator.pages.inc
  • theme_aggregator_page_opml() : aggregator.pages.inc
  • theme_aggregator_page_rss() : aggregator.pages.inc
  • theme_authorize_message() : theme.maintenance.inc
  • theme_authorize_report() : theme.maintenance.inc
  • theme_book_admin_table() : book.admin.inc
  • theme_book_title_link() : book.module
  • theme_breadcrumb() : theme.inc
  • theme_button() : form.inc
  • theme_checkbox() : form.inc
  • theme_checkboxes() : form.inc
  • theme_color_scheme_form() : color.module
  • theme_comment_block() : comment.module
  • theme_comment_post_forbidden() : comment.module
  • theme_confirm_form() : system.module
  • theme_container() : form.inc
  • theme_dashboard() : dashboard.module
  • theme_dashboard_admin() : dashboard.module
  • theme_dashboard_disabled_block() : dashboard.module
  • theme_dashboard_disabled_blocks() : dashboard.module
  • theme_dashboard_region() : dashboard.module
  • theme_date() : form.inc
  • theme_dblog_message() : dblog.admin.inc
  • theme_disable() : theme.inc
  • theme_enable() : theme.inc
  • theme_example_node_color() : node_example.module
  • theme_exposed_filters() : system.module
  • theme_feed_icon() : theme.inc
  • theme_field() : field.module
  • theme_field_multiple_value_form() : field.form.inc
  • theme_field_ui_table() : field_ui.admin.inc
  • theme_fieldset() : form.inc
  • theme_file() : form.inc
  • theme_file_formatter_table() : file.field.inc
  • theme_file_icon() : file.module
  • theme_file_link() : file.module
  • theme_file_managed_file() : file.module
  • theme_file_upload_help() : file.field.inc
  • theme_file_widget() : file.field.inc
  • theme_file_widget_multiple() : file.field.inc
  • theme_filter_admin_format_filter_order() : filter.admin.inc
  • theme_filter_admin_overview() : filter.admin.inc
  • theme_filter_guidelines() : filter.module
  • theme_filter_tips() : filter.pages.inc
  • theme_filter_tips_more_info() : filter.module
  • theme_form() : form.inc
  • theme_form_element() : form.inc
  • theme_form_element_label() : form.inc
  • theme_form_example_checkbox() : form_example_elements.inc
  • theme_form_example_inline_form_element() : form_example_elements.inc
  • theme_form_required_marker() : form.inc
  • theme_forum_form() : forum.admin.inc
  • theme_get_registry() : theme.inc
  • theme_get_setting() : theme.inc
  • theme_get_suggestions() : theme.inc
  • theme_hidden() : form.inc
  • theme_html_tag() : theme.inc
  • theme_image() : theme.inc
  • theme_image_anchor() : image.admin.inc
  • theme_image_button() : form.inc
  • theme_image_crop_summary() : image.admin.inc
  • theme_image_example_colorize_summary() : image_example.module
  • theme_image_example_image() : image_example.pages.inc
  • theme_image_formatter() : image.field.inc
  • theme_image_resize_summary() : image.admin.inc
  • theme_image_rotate_summary() : image.admin.inc
  • theme_image_scale_summary() : image.admin.inc
  • theme_image_style() : image.module
  • theme_image_style_effects() : image.admin.inc
  • theme_image_style_list() : image.admin.inc
  • theme_image_style_preview() : image.admin.inc
  • theme_image_widget() : image.field.inc
  • theme_indentation() : theme.inc
  • theme_install_page() : theme.maintenance.inc
  • theme_item_list() : theme.inc
  • theme_link() : theme.inc
  • theme_links() : theme.inc
  • theme_locale_date_format_form() : locale.admin.inc
  • theme_locale_languages_configure_form() : locale.admin.inc
  • theme_locale_languages_overview_form() : locale.admin.inc
  • theme_mark() : theme.inc
  • theme_menu_admin_overview() : menu.admin.inc
  • theme_menu_link() : menu.inc
  • theme_menu_local_action() : menu.inc
  • theme_menu_local_task() : menu.inc
  • theme_menu_local_tasks() : menu.inc
  • theme_menu_overview_form() : menu.admin.inc
  • theme_menu_tree() : menu.inc
  • theme_more_help_link() : theme.inc
  • theme_more_link() : theme.inc
  • theme_node_add_list() : node.pages.inc
  • theme_node_admin_overview() : content_types.inc
  • theme_node_preview() : node.pages.inc
  • theme_node_recent_block() : node.module
  • theme_node_recent_content() : node.module
  • theme_node_search_admin() : node.module
  • theme_nodeapi_example_rating() : nodeapi_example.module
  • theme_options_none() : options.module
  • theme_overlay_disable_message() : overlay.module
  • theme_pager() : pager.inc
  • theme_pager_first() : pager.inc
  • theme_pager_last() : pager.inc
  • theme_pager_link() : pager.inc
  • theme_pager_next() : pager.inc
  • theme_pager_previous() : pager.inc
  • theme_password() : form.inc
  • theme_poll_choices() : poll.module
  • theme_profile_admin_overview() : profile.admin.inc
  • theme_progress_bar() : theme.inc
  • theme_queue_items() : queue_example.module
  • theme_radio() : form.inc
  • theme_radios() : form.inc
  • theme_rdf_metadata() : rdf.module
  • theme_rdf_template_variable_wrapper() : rdf.module
  • theme_render_array() : render_example.module
  • theme_render_example_add_div() : render_example.module
  • theme_render_example_add_notes() : render_example.module
  • theme_render_example_aggregate() : render_example.module
  • theme_render_template() : theme.inc
  • theme_select() : form.inc
  • theme_shortcut_set_customize() : shortcut.admin.inc
  • theme_simpletest_result_summary() : simpletest.pages.inc
  • theme_simpletest_test_table() : simpletest.pages.inc
  • theme_status_messages() : theme.inc
  • theme_status_report() : system.admin.inc
  • theme_submit() : form.inc
  • theme_system_admin_index() : system.admin.inc
  • theme_system_compact_link() : system.module
  • theme_system_date_time_settings() : system.admin.inc
  • theme_system_modules_fieldset() : system.admin.inc
  • theme_system_modules_incompatible() : system.admin.inc
  • theme_system_modules_uninstall() : system.admin.inc
  • theme_system_powered_by() : system.module
  • theme_system_settings_form() : system.module
  • theme_system_themes_page() : system.admin.inc
  • theme_table() : theme.inc
  • theme_tabledrag_example_parent_form() : tabledrag_example_parent_form.inc
  • theme_tabledrag_example_simple_form() : tabledrag_example_simple_form.inc
  • theme_tableselect() : form.inc
  • theme_tablesort_indicator() : theme.inc
  • theme_task_list() : theme.maintenance.inc
  • theme_taxonomy_overview_terms() : taxonomy.admin.inc
  • theme_taxonomy_overview_vocabularies() : taxonomy.admin.inc
  • theme_text_format_wrapper() : filter.module
  • theme_textarea() : form.inc
  • theme_textfield() : form.inc
  • theme_theming_example_content_array() : theming_example.module
  • theme_theming_example_list() : theming_example.module
  • theme_theming_example_select_form() : theming_example.module
  • theme_toolbar_toggle() : toolbar.module
  • theme_trigger_display() : trigger.admin.inc
  • theme_update_last_check() : update.module
  • theme_update_manager_update_form() : update.manager.inc
  • theme_update_page() : theme.maintenance.inc
  • theme_update_report() : update.report.inc
  • theme_update_status_label() : update.report.inc
  • theme_update_version() : update.report.inc
  • theme_user_admin_permissions() : user.admin.inc
  • theme_user_admin_roles() : user.admin.inc
  • theme_user_list() : user.module
  • theme_user_permission_description() : user.admin.inc
  • theme_user_signature() : user.module
  • theme_username() : theme.inc
  • theme_vertical_tabs() : form.inc
  • theming_example_list_page() : theming_example.module
  • theming_example_menu() : theming_example.module
  • theming_example_page() : theming_example.module
  • theming_example_select_form() : theming_example.module
  • theming_example_select_form_submit() : theming_example.module
  • theming_example_text_form() : theming_example.module
  • theming_example_text_form_submit() : theming_example.module
  • theming_example_theme() : theming_example.module
  • tid : taxonomy-term.tpl.php
  • timer_read() : bootstrap.inc
  • timer_start() : bootstrap.inc
  • timer_stop() : bootstrap.inc
  • title : forum-topic-list.tpl.php
  • token_example_entity_info_alter() : token_example.module
  • token_example_example_form() : token_example.module
  • token_example_example_form_submit() : token_example.module
  • token_example_menu() : token_example.module
  • token_example_token_info() : token_example.tokens.inc
  • token_example_tokens() : token_example.tokens.inc
  • token_find_with_prefix() : token.inc
  • token_generate() : token.inc
  • token_info() : token.inc
  • token_replace() : token.inc
  • token_scan() : token.inc
  • toolbar_get_menu_tree() : toolbar.module
  • toolbar_help() : toolbar.module
  • toolbar_in_active_trail() : toolbar.module
  • toolbar_menu() : toolbar.module
  • toolbar_menu_navigation_links() : toolbar.module
  • toolbar_page_build() : toolbar.module
  • toolbar_permission() : toolbar.module
  • toolbar_pre_render() : toolbar.module
  • toolbar_preprocess_html() : toolbar.module
  • toolbar_preprocess_toolbar() : toolbar.module
  • toolbar_system_info_alter() : toolbar.module
  • toolbar_theme() : toolbar.module
  • toolbar_toggle_page() : toolbar.module
  • toolbar_view() : toolbar.module
  • tracker_comment_delete() : tracker.module
  • tracker_comment_publish() : tracker.module
  • tracker_comment_unpublish() : tracker.module
  • tracker_comment_update() : tracker.module
  • tracker_cron() : tracker.module
  • tracker_enable() : tracker.install
  • tracker_help() : tracker.module
  • tracker_menu() : tracker.module
  • tracker_node_delete() : tracker.module
  • tracker_node_insert() : tracker.module
  • tracker_node_update() : tracker.module
  • tracker_page() : tracker.pages.inc
  • tracker_schema() : tracker.install
  • tracker_uninstall() : tracker.install
  • tracker_update_7000() : tracker.install
  • translation_admin_paths() : translation.module
  • TRANSLATION_ENABLED : translation.module
  • translation_form_node_form_alter() : translation.module
  • translation_form_node_type_form_alter() : translation.module
  • translation_help() : translation.module
  • translation_language_switch_links_alter() : translation.module
  • translation_menu() : translation.module
  • translation_node_delete() : translation.module
  • translation_node_get_translations() : translation.module
  • translation_node_insert() : translation.module
  • translation_node_overview() : translation.pages.inc
  • translation_node_prepare() : translation.module
  • translation_node_update() : translation.module
  • translation_node_validate() : translation.module
  • translation_node_view() : translation.module
  • translation_path_get_translations() : translation.module
  • translation_permission() : translation.module
  • translation_remove_from_set() : translation.module
  • translation_supported_type() : translation.module
  • trigger_actions_delete() : trigger.module
  • trigger_assign() : trigger.admin.inc
  • trigger_assign_form() : trigger.admin.inc
  • trigger_assign_form_submit() : trigger.admin.inc
  • trigger_assign_form_validate() : trigger.admin.inc
  • trigger_comment_delete() : trigger.module
  • trigger_comment_insert() : trigger.module
  • trigger_comment_presave() : trigger.module
  • trigger_comment_update() : trigger.module
  • trigger_comment_view() : trigger.module
  • trigger_cron() : trigger.module
  • trigger_example_form() : trigger_example.module
  • trigger_example_form_submit() : trigger_example.module
  • trigger_example_help() : trigger_example.module
  • trigger_example_menu() : trigger_example.module
  • trigger_example_trigger_info() : trigger_example.module
  • trigger_example_trigger_info_alter() : trigger_example.module
  • trigger_example_triggersomething() : trigger_example.module
  • trigger_example_user_login() : trigger_example.module
  • trigger_forms() : trigger.module
  • trigger_get_assigned_actions() : trigger.module
  • trigger_help() : trigger.module
  • trigger_install() : trigger.install
  • trigger_menu() : trigger.module
  • trigger_menu_unassign_access() : trigger.module
  • trigger_node_delete() : trigger.module
  • trigger_node_insert() : trigger.module
  • trigger_node_presave() : trigger.module
  • trigger_node_update() : trigger.module
  • trigger_node_view() : trigger.module
  • trigger_schema() : trigger.install
  • trigger_taxonomy_term_delete() : trigger.module
  • trigger_taxonomy_term_insert() : trigger.module
  • trigger_taxonomy_term_update() : trigger.module
  • trigger_theme() : trigger.module
  • trigger_trigger_info() : trigger.module
  • trigger_unassign() : trigger.admin.inc
  • trigger_unassign_submit() : trigger.admin.inc
  • trigger_update_7000() : trigger.install
  • trigger_update_7001() : trigger.install
  • trigger_update_7002() : trigger.install
  • trigger_user_cancel() : trigger.module
  • trigger_user_delete() : trigger.module
  • trigger_user_insert() : trigger.module
  • trigger_user_login() : trigger.module
  • trigger_user_logout() : trigger.module
  • trigger_user_update() : trigger.module
  • trigger_user_view() : trigger.module
  • truncate_utf8() : unicode.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- u -

  • unicode_check() : unicode.inc
  • UNICODE_ERROR : unicode.inc
  • UNICODE_MULTIBYTE : unicode.inc
  • unicode_requirements() : unicode.inc
  • UNICODE_SINGLEBYTE : unicode.inc
  • update_access_allowed() : update.php
  • update_access_denied_page() : update.php
  • update_already_performed() : update.inc
  • update_authorize_batch_copy_project() : update.authorize.inc
  • update_authorize_install_batch_finished() : update.authorize.inc
  • update_authorize_run_install() : update.authorize.inc
  • update_authorize_run_update() : update.authorize.inc
  • update_authorize_update_batch_finished() : update.authorize.inc
  • update_batch() : update.inc
  • update_build_dependency_graph() : update.inc
  • update_cache_clear_submit() : update.module
  • update_calculate_project_data() : update.compare.inc
  • update_calculate_project_update_status() : update.compare.inc
  • update_check_incompatibility() : update.inc
  • update_check_requirements() : update.php
  • update_clear_update_disk_cache() : update.module
  • update_create_fetch_task() : update.module
  • update_cron() : update.module
  • UPDATE_CURRENT : update.module
  • UPDATE_DEFAULT_URL : update.module
  • update_delete_file_if_stale() : update.module
  • update_do_one() : update.inc
  • update_extra_requirements() : update.php
  • update_fetch_data() : update.module
  • update_fetch_data_batch() : update.fetch.inc
  • update_fetch_data_finished() : update.fetch.inc
  • UPDATE_FETCH_PENDING : update.module
  • update_filter_project_info() : update.compare.inc
  • update_finished() : update.inc
  • update_fix_compatibility() : update.inc
  • update_fix_d7_block_deltas() : update.inc
  • update_fix_d7_install_profile() : update.inc
  • update_fix_d7_requirements() : update.inc
  • update_flush_caches() : update.module
  • update_form_system_modules_alter() : update.module
  • update_get_available() : update.module
  • update_get_d6_session_name() : update.inc
  • update_get_project_name() : update.compare.inc
  • update_get_projects() : update.compare.inc
  • update_get_update_function_list() : update.inc
  • update_get_update_list() : update.inc
  • update_help() : update.module
  • update_helpful_links() : update.php
  • update_info_page() : update.php
  • update_init() : update.module
  • update_install() : update.install
  • update_is_missing() : update.inc
  • update_mail() : update.module
  • update_manager_access() : update.module
  • update_manager_archive_extract() : update.manager.inc
  • update_manager_archive_verify() : update.manager.inc
  • update_manager_batch_project_get() : update.manager.inc
  • update_manager_download_batch_finished() : update.manager.inc
  • update_manager_file_get() : update.manager.inc
  • update_manager_install_form() : update.manager.inc
  • update_manager_install_form_submit() : update.manager.inc
  • update_manager_install_form_validate() : update.manager.inc
  • update_manager_local_transfers_allowed() : update.manager.inc
  • update_manager_update_form() : update.manager.inc
  • update_manager_update_form_submit() : update.manager.inc
  • update_manager_update_form_validate() : update.manager.inc
  • update_manager_update_ready_form() : update.manager.inc
  • update_manager_update_ready_form_submit() : update.manager.inc
  • update_manual_status() : update.fetch.inc
  • UPDATE_MAX_FETCH_ATTEMPTS : update.module
  • UPDATE_MAX_FETCH_TIME : update.module
  • update_menu() : update.module
  • UPDATE_NOT_CHECKED : update.module
  • UPDATE_NOT_CURRENT : update.module
  • UPDATE_NOT_FETCHED : update.module
  • UPDATE_NOT_SECURE : update.module
  • UPDATE_NOT_SUPPORTED : update.module
  • update_parse_db_url() : update.inc
  • update_parse_xml() : update.fetch.inc
  • update_prepare_d7_bootstrap() : update.inc
  • update_process_project_info() : update.compare.inc
  • update_project_cache() : update.compare.inc
  • update_refresh() : update.module
  • update_requirements() : update.install
  • update_resolve_dependencies() : update.inc
  • update_results_page() : update.php
  • update_retrieve_dependencies() : update.inc
  • UPDATE_REVOKED : update.module
  • update_schema() : update.install
  • update_script_selection_form() : update.php
  • update_selection_page() : update.php
  • update_settings() : update.settings.inc
  • update_settings_submit() : update.settings.inc
  • update_settings_validate() : update.settings.inc
  • update_status() : update.report.inc
  • update_task_list() : update.php
  • update_theme() : update.module
  • update_themes_disabled() : update.module
  • update_themes_enabled() : update.module
  • update_uninstall() : update.install
  • UPDATE_UNKNOWN : update.module
  • update_update_7000() : update.install
  • update_update_7001() : update.install
  • update_verify_update_archive() : update.module
  • url() : common.inc
  • url_is_external() : common.inc
  • user_access() : user.module
  • user_account_form() : user.module
  • user_account_form_validate() : user.module
  • user_action_info() : user.module
  • user_admin() : user.admin.inc
  • user_admin_account() : user.admin.inc
  • user_admin_account_submit() : user.admin.inc
  • user_admin_account_validate() : user.admin.inc
  • user_admin_paths() : user.module
  • user_admin_permissions() : user.admin.inc
  • user_admin_permissions_submit() : user.admin.inc
  • user_admin_role() : user.admin.inc
  • user_admin_role_delete_confirm() : user.admin.inc
  • user_admin_role_delete_confirm_submit() : user.admin.inc
  • user_admin_role_delete_submit() : user.admin.inc
  • user_admin_role_submit() : user.admin.inc
  • user_admin_role_validate() : user.admin.inc
  • user_admin_roles() : user.admin.inc
  • user_admin_roles_order_submit() : user.admin.inc
  • user_admin_settings() : user.admin.inc
  • user_authenticate() : user.module
  • user_autocomplete() : user.pages.inc
  • user_block_configure() : user.module
  • user_block_info() : user.module
  • user_block_save() : user.module
  • user_block_user_action() : user.module
  • user_block_view() : user.module
  • user_build_content() : user.module
  • user_build_filter_query() : user.module
  • user_cancel() : user.module
  • user_cancel_access() : user.module
  • user_cancel_confirm() : user.pages.inc
  • user_cancel_confirm_form() : user.pages.inc
  • user_cancel_confirm_form_submit() : user.pages.inc
  • user_cancel_methods() : user.pages.inc
  • user_cancel_url() : user.module
  • user_category_load() : user.module
  • user_check_password() : password.inc
  • user_comment_view() : user.module
  • user_cookie_delete() : user.module
  • user_cookie_save() : user.module
  • user_delete() : user.module
  • user_delete_multiple() : user.module
  • user_edit_access() : user.module
  • user_edit_cancel_submit() : user.pages.inc
  • user_element_info() : user.module
  • user_entity_info() : user.module
  • user_external_load() : user.module
  • user_external_login_register() : user.module
  • user_field_extra_fields() : user.module
  • user_field_info_alter() : user.module
  • user_file_delete() : user.module
  • user_file_download() : user.module
  • user_file_download_access() : user.module
  • user_file_move() : user.module
  • user_filter_form() : user.admin.inc
  • user_filter_form_submit() : user.admin.inc
  • user_filters() : user.module
  • user_form_field_ui_field_edit_form_alter() : user.module
  • user_form_field_ui_field_edit_form_submit() : user.module
  • user_form_process_password_confirm() : user.module
  • user_get_authmaps() : user.module
  • user_hash_password() : password.inc
  • user_help() : user.module
  • user_image_style_delete() : user.module
  • user_image_style_save() : user.module
  • user_install() : user.install
  • user_is_anonymous() : user.module
  • user_is_blocked() : user.module
  • user_is_logged_in() : user.module
  • user_load() : user.module
  • user_load_by_mail() : user.module
  • user_load_by_name() : user.module
  • user_load_multiple() : user.module
  • user_login() : user.module
  • user_login_authenticate_validate() : user.module
  • user_login_block() : user.module
  • user_login_default_validators() : user.module
  • user_login_destination() : user.module
  • user_login_final_validate() : user.module
  • user_login_finalize() : user.module
  • user_login_name_validate() : user.module
  • user_login_submit() : user.module
  • user_logout() : user.pages.inc
  • user_mail() : user.module
  • user_mail_tokens() : user.module
  • user_menu() : user.module
  • user_menu_link_alter() : user.module
  • user_menu_site_status_alter() : user.module
  • user_menu_title() : user.module
  • user_module_invoke() : user.module
  • user_modules_installed() : user.module
  • user_modules_uninstalled() : user.module
  • user_multiple_cancel_confirm() : user.module
  • user_multiple_cancel_confirm_submit() : user.module
  • user_multiple_role_edit() : user.module
  • user_needs_new_hash() : password.inc
  • user_node_load() : user.module
  • user_page() : user.pages.inc
  • user_page_title() : user.module
  • user_pass() : user.pages.inc
  • user_pass_rehash() : user.module
  • user_pass_reset() : user.pages.inc
  • user_pass_reset_url() : user.module
  • user_pass_submit() : user.pages.inc
  • user_pass_validate() : user.pages.inc
  • user_password() : user.module
  • user_permission() : user.module
  • user_permission_get_modules() : user.module
  • user_preferred_language() : user.module
  • user_profile_form() : user.pages.inc
  • user_profile_form_submit() : user.pages.inc
  • user_profile_form_validate() : user.pages.inc
  • user_rdf_mapping() : user.module
  • user_register_access() : user.module
  • USER_REGISTER_ADMINISTRATORS_ONLY : user.module
  • user_register_form() : user.module
  • user_register_submit() : user.module
  • user_register_validate() : user.module
  • USER_REGISTER_VISITORS : user.module
  • USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL : user.module
  • user_role_change_permissions() : user.module
  • user_role_delete() : user.module
  • user_role_edit_access() : user.module
  • user_role_grant_permissions() : user.module
  • user_role_load() : user.module
  • user_role_load_by_name() : user.module
  • user_role_permissions() : user.module
  • user_role_revoke_permissions() : user.module
  • user_role_save() : user.module
  • user_roles() : user.module
  • user_save() : user.module
  • user_schema() : user.install
  • user_search_access() : user.module
  • user_search_execute() : user.module
  • user_search_info() : user.module
  • user_set_authmaps() : user.module
  • user_system_info_alter() : user.module
  • user_theme() : user.module
  • user_token_info() : user.tokens.inc
  • user_tokens() : user.tokens.inc
  • user_translated_menu_link_alter() : user.module
  • user_uid_only_optional_to_arg() : user.module
  • user_uid_optional_load() : user.module
  • user_uid_optional_to_arg() : user.module
  • user_update_7000() : user.install
  • user_update_7001() : user.install
  • user_update_7002() : user.install
  • user_update_7003() : user.install
  • user_update_7005() : user.install
  • user_update_7006() : user.install
  • user_update_7007() : user.install
  • user_update_7008() : user.install
  • user_update_7009() : user.install
  • user_update_7010() : user.install
  • user_update_7011() : user.install
  • user_update_7012() : user.install
  • user_update_7013() : user.install
  • user_update_7014() : user.install
  • user_update_7015() : user.install
  • user_update_7016() : user.install
  • user_update_7017() : user.install
  • user_update_7018() : user.install
  • user_update_dependencies() : user.install
  • user_uri() : user.module
  • user_user_categories() : user.module
  • user_user_operations() : user.module
  • user_user_operations_block() : user.module
  • user_user_operations_unblock() : user.module
  • user_user_presave() : user.module
  • user_user_view() : user.module
  • user_validate_current_pass() : user.module
  • user_validate_mail() : user.module
  • user_validate_name() : user.module
  • user_validate_picture() : user.module
  • user_view() : user.module
  • user_view_access() : user.module
  • user_view_page() : user.module
  • USERNAME_MAX_LENGTH : user.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- v -

  • valid_email_address() : common.inc
  • valid_url() : common.inc
  • value : profile-block.tpl.php
  • vancode2int() : comment.module
  • variable_del() : bootstrap.inc
  • variable_get() : bootstrap.inc
  • variable_initialize() : bootstrap.inc
  • variable_set() : bootstrap.inc
  • VERSION : bootstrap.inc
  • vertical_tabs_example_form_alter() : vertical_tabs_example.module
  • vertical_tabs_example_menu() : vertical_tabs_example.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- w -

  • watchdog() : bootstrap.inc
  • WATCHDOG_ALERT : bootstrap.inc
  • WATCHDOG_CRITICAL : bootstrap.inc
  • WATCHDOG_DEBUG : bootstrap.inc
  • WATCHDOG_EMERGENCY : bootstrap.inc
  • WATCHDOG_ERROR : bootstrap.inc
  • watchdog_exception() : bootstrap.inc
  • WATCHDOG_INFO : bootstrap.inc
  • WATCHDOG_NOTICE : bootstrap.inc
  • watchdog_severity_levels() : common.inc
  • WATCHDOG_WARNING : bootstrap.inc
  • weight_select : block-admin-display-form.tpl.php
  • weight_value() : form.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- x -

  • xmlrpc() : common.inc
  • xmlrpc_base64() : xmlrpc.inc
  • xmlrpc_base64_get_xml() : xmlrpc.inc
  • xmlrpc_clear_error() : xmlrpc.inc
  • xmlrpc_date() : xmlrpc.inc
  • xmlrpc_date_get_xml() : xmlrpc.inc
  • xmlrpc_errno() : xmlrpc.inc
  • xmlrpc_error() : xmlrpc.inc
  • xmlrpc_error_get_xml() : xmlrpc.inc
  • xmlrpc_error_msg() : xmlrpc.inc
  • xmlrpc_example_alter_form() : xmlrpc_example.module
  • xmlrpc_example_client_add_submit() : xmlrpc_example.module
  • xmlrpc_example_client_form() : xmlrpc_example.module
  • xmlrpc_example_client_multicall_submit() : xmlrpc_example.module
  • xmlrpc_example_client_request_methods_submit() : xmlrpc_example.module
  • xmlrpc_example_client_subtract_submit() : xmlrpc_example.module
  • xmlrpc_example_info() : xmlrpc_example.module
  • xmlrpc_example_menu() : xmlrpc_example.module
  • xmlrpc_example_server_form() : xmlrpc_example.module
  • xmlrpc_example_xmlrpc() : xmlrpc_example.module
  • xmlrpc_example_xmlrpc_alter() : xmlrpc_example.module
  • xmlrpc_message() : xmlrpc.inc
  • xmlrpc_message_cdata() : xmlrpc.inc
  • xmlrpc_message_get() : xmlrpc.inc
  • xmlrpc_message_parse() : xmlrpc.inc
  • xmlrpc_message_set() : xmlrpc.inc
  • xmlrpc_message_tag_close() : xmlrpc.inc
  • xmlrpc_message_tag_open() : xmlrpc.inc
  • xmlrpc_request() : xmlrpc.inc
  • xmlrpc_server() : xmlrpcs.inc
  • xmlrpc_server_call() : xmlrpcs.inc
  • xmlrpc_server_error() : xmlrpcs.inc
  • xmlrpc_server_get() : xmlrpcs.inc
  • xmlrpc_server_get_capabilities() : xmlrpcs.inc
  • xmlrpc_server_list_methods() : xmlrpcs.inc
  • xmlrpc_server_method_help() : xmlrpcs.inc
  • xmlrpc_server_method_signature() : xmlrpcs.inc
  • xmlrpc_server_multicall() : xmlrpcs.inc
  • xmlrpc_server_output() : xmlrpcs.inc
  • xmlrpc_server_set() : xmlrpcs.inc
  • xmlrpc_value() : xmlrpc.inc
  • xmlrpc_value_calculate_type() : xmlrpc.inc
  • xmlrpc_value_get_xml() : xmlrpc.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • z
Here is a list of all file members with links to the files they belong to:

- z -

  • zebra : forum-list.tpl.php
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- _ -

  • _action_example_page() : action_example.module
  • _aggregator_category_title() : aggregator.module
  • _aggregator_characters() : aggregator.processor.inc
  • _aggregator_get_variables() : aggregator.module
  • _aggregator_has_categories() : aggregator.module
  • _aggregator_items() : aggregator.module
  • _aggregator_page_list() : aggregator.pages.inc
  • _aggregator_parse_opml() : aggregator.admin.inc
  • _ajax_example_get_first_dropdown_options() : ajax_example.module
  • _ajax_example_get_second_dropdown_options() : ajax_example.module
  • _authorize_filetransfer_connection_settings() : authorize.inc
  • _authorize_filetransfer_connection_settings_set_defaults() : authorize.inc
  • _batch_api_percentage() : batch.inc
  • _batch_current_set() : batch.inc
  • _batch_do() : batch.inc
  • _batch_example_get_http_requests() : batch_example.module
  • _batch_example_update_http_requests() : batch_example.module
  • _batch_finished() : batch.inc
  • _batch_next_set() : batch.inc
  • _batch_page() : batch.inc
  • _batch_populate_queue() : form.inc
  • _batch_process() : batch.inc
  • _batch_progress_page_js() : batch.inc
  • _batch_progress_page_nojs() : batch.inc
  • _batch_queue() : form.inc
  • _batch_shutdown() : batch.inc
  • _batch_start() : batch.inc
  • _block_compare() : block.admin.inc
  • _block_custom_theme() : block.module
  • _block_get_cache_id() : block.module
  • _block_get_renderable_array() : block.module
  • _block_load_blocks() : block.module
  • _block_rehash() : block.module
  • _block_render_blocks() : block.module
  • _block_themes_access() : block.module
  • _blog_post_exists() : blog.module
  • _book_add_form_elements() : book.module
  • _book_admin_table() : book.admin.inc
  • _book_admin_table_tree() : book.admin.inc
  • _book_flatten_menu() : book.module
  • _book_install_type_create() : book.install
  • _book_link_defaults() : book.module
  • _book_node_is_removable() : book.module
  • _book_outline_access() : book.module
  • _book_outline_remove_access() : book.module
  • _book_parent_depth_limit() : book.module
  • _book_parent_select() : book.module
  • _book_toc_recurse() : book.module
  • _book_update_outline() : book.module
  • _cache_get_object() : cache.inc
  • _color_blend() : color.module
  • _color_gd() : color.module
  • _color_hsl2rgb() : color.module
  • _color_html_alter() : color.module
  • _color_hue2rgb() : color.module
  • _color_pack() : color.module
  • _color_page_alter() : color.module
  • _color_render_images() : color.module
  • _color_rewrite_stylesheet() : color.module
  • _color_rgb2hsl() : color.module
  • _color_save_stylesheet() : color.module
  • _color_shift() : color.module
  • _color_theme_select_form_alter() : color.module
  • _color_unpack() : color.module
  • _comment_body_field_create() : comment.module
  • _comment_get_modes() : comment.module
  • _comment_per_page() : comment.module
  • _comment_update_node_statistics() : comment.module
  • _contact_personal_tab_access() : contact.module
  • _country_get_predefined_list() : iso.inc
  • _db_create_keys_sql() : database.inc
  • _dblog_get_message_types() : dblog.module
  • _drupal_bootstrap_configuration() : bootstrap.inc
  • _drupal_bootstrap_database() : bootstrap.inc
  • _drupal_bootstrap_full() : common.inc
  • _drupal_bootstrap_page_cache() : bootstrap.inc
  • _drupal_bootstrap_page_header() : bootstrap.inc
  • _drupal_bootstrap_variables() : bootstrap.inc
  • _drupal_build_css_path() : common.inc
  • _drupal_decode_exception() : errors.inc
  • _drupal_default_html_head() : common.inc
  • _drupal_depth_first_search() : graph.inc
  • _drupal_error_handler() : bootstrap.inc
  • _drupal_error_handler_real() : errors.inc
  • _drupal_exception_handler() : bootstrap.inc
  • _drupal_flush_css_js() : common.inc
  • _drupal_get_last_caller() : errors.inc
  • _drupal_html_to_mail_urls() : mail.inc
  • _drupal_html_to_text_clean() : mail.inc
  • _drupal_html_to_text_pad() : mail.inc
  • _drupal_http_use_proxy() : common.inc
  • _drupal_load_stylesheet() : common.inc
  • _drupal_log_error() : errors.inc
  • _drupal_maintenance_theme() : theme.maintenance.inc
  • _drupal_render_exception_safe() : errors.inc
  • _drupal_schema_initialize() : common.inc
  • _drupal_session_close() : session.inc
  • _drupal_session_delete_cookie() : session.inc
  • _drupal_session_destroy() : session.inc
  • _drupal_session_garbage_collection() : session.inc
  • _drupal_session_open() : session.inc
  • _drupal_session_read() : session.inc
  • _drupal_session_write() : session.inc
  • _drupal_set_preferred_header_name() : bootstrap.inc
  • _drupal_shutdown_function() : bootstrap.inc
  • _drupal_theme_access() : theme.inc
  • _drupal_theme_initialize() : theme.inc
  • _drupal_wrap_mail_line() : mail.inc
  • _element_validate_integer() : field.module
  • _element_validate_integer_positive() : field.module
  • _element_validate_number() : field.module
  • _field_example_page() : field_example.module
  • _field_extra_fields_pre_render() : field.module
  • _field_filter_items() : field.module
  • _field_filter_xss_allowed_tags() : field.module
  • _field_filter_xss_display_allowed_tags() : field.module
  • _field_form_state_parents() : field.form.inc
  • _field_info_collate_fields() : field.info.inc
  • _field_info_collate_types() : field.info.inc
  • _field_info_field_cache() : field.info.inc
  • _field_info_prepare_extra_fields() : field.info.inc
  • _field_info_prepare_field() : field.info.inc
  • _field_info_prepare_instance() : field.info.inc
  • _field_info_prepare_instance_display() : field.info.inc
  • _field_info_prepare_instance_widget() : field.info.inc
  • _field_invoke() : field.attach.inc
  • _field_invoke_default() : field.attach.inc
  • _field_invoke_get_instances() : field.attach.inc
  • _field_invoke_multiple() : field.attach.inc
  • _field_invoke_multiple_default() : field.attach.inc
  • _field_language_suggestion() : field.multilingual.inc
  • _field_permission_example_page() : field_permission_example.module
  • _field_sort_items() : field.module
  • _field_sort_items_helper() : field.module
  • _field_sort_items_value_helper() : field.module
  • _field_sql_storage_columnname() : field_sql_storage.module
  • _field_sql_storage_indexname() : field_sql_storage.module
  • _field_sql_storage_query_columnname() : field_sql_storage.module
  • _field_sql_storage_query_field_conditions() : field_sql_storage.module
  • _field_sql_storage_query_join_entity() : field_sql_storage.module
  • _field_sql_storage_revision_tablename() : field_sql_storage.module
  • _field_sql_storage_schema() : field_sql_storage.module
  • _field_sql_storage_tablename() : field_sql_storage.module
  • _field_ui_add_default_view_mode_settings() : field_ui.admin.inc
  • _field_ui_bundle_admin_path() : field_ui.module
  • _field_ui_field_name_exists() : field_ui.admin.inc
  • _field_ui_field_overview_form_validate_add_existing() : field_ui.admin.inc
  • _field_ui_field_overview_form_validate_add_new() : field_ui.admin.inc
  • _field_ui_reduce_order() : field_ui.admin.inc
  • _field_ui_view_mode_menu_access() : field_ui.module
  • _field_write_instance() : field.crud.inc
  • _file_field_get_description_from_element() : file.field.inc
  • _file_generic_settings_extensions() : file.field.inc
  • _file_generic_settings_file_directory_validate() : file.field.inc
  • _file_generic_settings_max_filesize() : file.field.inc
  • _filter_autop() : filter.module
  • _filter_autop_tips() : filter.module
  • _filter_disable_format_access() : filter.module
  • _filter_example_filter_foo_process() : filter_example.module
  • _filter_example_filter_foo_settings() : filter_example.module
  • _filter_example_filter_foo_tips() : filter_example.module
  • _filter_example_filter_time_prepare() : filter_example.module
  • _filter_example_filter_time_process() : filter_example.module
  • _filter_example_filter_time_tips() : filter_example.module
  • _filter_example_information() : filter_example.module
  • _filter_format_is_cacheable() : filter.module
  • _filter_html() : filter.module
  • _filter_html_escape() : filter.module
  • _filter_html_escape_tips() : filter.module
  • _filter_html_settings() : filter.module
  • _filter_html_tips() : filter.module
  • _filter_htmlcorrector() : filter.module
  • _filter_list_cmp() : filter.module
  • _filter_tips() : filter.module
  • _filter_url() : filter.module
  • _filter_url_escape_comments() : filter.module
  • _filter_url_parse_email_links() : filter.module
  • _filter_url_parse_full_links() : filter.module
  • _filter_url_parse_partial_links() : filter.module
  • _filter_url_settings() : filter.module
  • _filter_url_tips() : filter.module
  • _filter_url_trim() : filter.module
  • _filter_xss_attributes() : common.inc
  • _filter_xss_split() : common.inc
  • _fix_gpc_magic() : common.inc
  • _fix_gpc_magic_files() : common.inc
  • _form_builder_handle_input_element() : form.inc
  • _form_button_was_clicked() : form.inc
  • _form_element_triggered_scripted_submission() : form.inc
  • _form_example_element_info() : form_example_elements.inc
  • _form_example_element_theme() : form_example_elements.inc
  • _form_example_steps() : form_example_wizard.inc
  • _form_options_flatten() : form.inc
  • _form_set_class() : form.inc
  • _form_validate() : form.inc
  • _format_date_callback() : common.inc
  • _forum_get_topic_order() : forum.module
  • _forum_node_check_node_type() : forum.module
  • _forum_parent_select() : forum.admin.inc
  • _forum_topics_unread() : forum.module
  • _forum_update_forum_index() : forum.module
  • _forum_user_last_visit() : forum.module
  • _image_effect_definitions_sort() : image.module
  • _image_field_resolution_validate() : image.field.inc
  • _image_update_7002_add_columns() : image.install
  • _image_update_7002_populate_dimensions() : image.install
  • _install_configure_form() : install.core.inc
  • _install_module_batch() : install.core.inc
  • _install_profile_modules_finished() : install.core.inc
  • _install_select_profile() : install.core.inc
  • _list_update_7001_extract_allowed_values() : list.install
  • _list_values_in_use() : list.module
  • _locale_batch_build() : locale.inc
  • _locale_batch_import() : locale.inc
  • _locale_batch_language_finished() : locale.inc
  • _locale_batch_system_finished() : locale.inc
  • _locale_export_get_strings() : locale.inc
  • _locale_export_po() : locale.inc
  • _locale_export_po_generate() : locale.inc
  • _locale_export_remove_plural() : locale.inc
  • _locale_export_string() : locale.inc
  • _locale_export_wrap() : locale.inc
  • _locale_get_predefined_list() : iso.inc
  • _locale_import_append_plural() : locale.inc
  • _locale_import_message() : locale.inc
  • _locale_import_one_string() : locale.inc
  • _locale_import_one_string_db() : locale.inc
  • _locale_import_parse_arithmetic() : locale.inc
  • _locale_import_parse_header() : locale.inc
  • _locale_import_parse_plural_forms() : locale.inc
  • _locale_import_parse_quoted() : locale.inc
  • _locale_import_po() : locale.inc
  • _locale_import_read_po() : locale.inc
  • _locale_import_shorten_comments() : locale.inc
  • _locale_import_tokenize_formula() : locale.inc
  • _locale_invalidate_js() : locale.inc
  • _locale_languages_common_controls() : locale.admin.inc
  • _locale_languages_configure_form_language_table() : locale.admin.inc
  • _locale_parse_js_file() : locale.inc
  • _locale_prepare_predefined_list() : locale.inc
  • _locale_rebuild_js() : locale.inc
  • _locale_translate_language_list() : locale.inc
  • _locale_translate_seek() : locale.inc
  • _locale_translate_seek_query() : locale.inc
  • _lock_id() : lock.inc
  • _menu_build_tree() : menu.inc
  • _menu_check_access() : menu.inc
  • _menu_clear_page_cache() : menu.inc
  • _menu_delete_item() : menu.inc
  • _menu_example_basic_instructions() : menu_example.module
  • _menu_example_mappings() : menu_example.module
  • _menu_example_menu_page() : menu_example.module
  • _menu_example_simple_title_callback() : menu_example.module
  • _menu_find_router_path() : menu.inc
  • _menu_get_options() : menu.module
  • _menu_item_localize() : menu.inc
  • _menu_link_build() : menu.inc
  • _menu_link_find_parent() : menu.inc
  • _menu_link_map_translate() : menu.inc
  • _menu_link_move_children() : menu.inc
  • _menu_link_parents_set() : menu.inc
  • _menu_link_translate() : menu.inc
  • _menu_load_objects() : menu.inc
  • _menu_navigation_links_rebuild() : menu.inc
  • _menu_overview_tree_form() : menu.admin.inc
  • _menu_parent_depth_limit() : menu.module
  • _menu_parents_recurse() : menu.module
  • _menu_router_build() : menu.inc
  • _menu_router_cache() : menu.inc
  • _menu_router_save() : menu.inc
  • _menu_set_expanded_menus() : menu.inc
  • _menu_site_is_offline() : menu.inc
  • _menu_translate() : menu.inc
  • _menu_tree_check_access() : menu.inc
  • _menu_tree_data() : menu.inc
  • _menu_update_parental_status() : menu.inc
  • _mime_header_decode() : unicode.inc
  • _module_build_dependencies() : module.inc
  • _node_access_rebuild_batch_finished() : node.module
  • _node_access_rebuild_batch_operation() : node.module
  • _node_add_access() : node.module
  • _node_characters() : content_types.inc
  • _node_example_installed_fields() : node_example.module
  • _node_example_installed_instances() : node_example.module
  • _node_extract_type() : node.module
  • _node_index_node() : node.module
  • _node_mass_update_batch_finished() : node.admin.inc
  • _node_mass_update_batch_process() : node.admin.inc
  • _node_mass_update_helper() : node.admin.inc
  • _node_query_node_access_alter() : node.module
  • _node_rankings() : node.module
  • _node_revision_access() : node.module
  • _node_save_revision() : node.module
  • _node_types_build() : node.module
  • _openid_create_message() : openid.inc
  • _openid_dh_base64_to_long() : openid.inc
  • _openid_dh_binary_to_long() : openid.inc
  • _openid_dh_long_to_base64() : openid.inc
  • _openid_dh_long_to_binary() : openid.inc
  • _openid_dh_rand() : openid.inc
  • _openid_dh_xorsecret() : openid.inc
  • _openid_encode_message() : openid.inc
  • _openid_get_bytes() : openid.inc
  • _openid_get_math_library() : openid.inc
  • _openid_get_params() : openid.inc
  • _openid_hmac() : openid.inc
  • _openid_invalid_openid_transition() : openid.inc
  • _openid_is_xri() : openid.inc
  • _openid_link_href() : openid.inc
  • _openid_math_add() : openid.inc
  • _openid_math_cmp() : openid.inc
  • _openid_math_div() : openid.inc
  • _openid_math_mod() : openid.inc
  • _openid_math_mul() : openid.inc
  • _openid_math_pow() : openid.inc
  • _openid_math_powmod() : openid.inc
  • _openid_meta_httpequiv() : openid.inc
  • _openid_nonce() : openid.inc
  • _openid_parse_message() : openid.inc
  • _openid_response() : openid.inc
  • _openid_select_service() : openid.inc
  • _openid_signature() : openid.inc
  • _openid_url_normalize() : openid.inc
  • _openid_user_login_form_alter() : openid.module
  • _openid_xrds_discovery() : openid.module
  • _openid_xrds_parse() : openid.inc
  • _openid_xri_discovery() : openid.module
  • _openid_xri_normalize() : openid.inc
  • _options_form_to_storage() : options.module
  • _options_get_options() : options.module
  • _options_prepare_options() : options.module
  • _options_properties() : options.module
  • _options_storage_to_form() : options.module
  • _overlay_region_list() : overlay.module
  • _password_base64_encode() : password.inc
  • _password_crypt() : password.inc
  • _password_enforce_log2_boundaries() : password.inc
  • _password_generate_salt() : password.inc
  • _password_get_count_log2() : password.inc
  • _password_itoa64() : password.inc
  • _php_filter_tips() : php.module
  • _poll_choice_form() : poll.module
  • _poll_menu_access() : poll.module
  • _profile_field_serialize() : profile.module
  • _profile_field_types() : profile.module
  • _profile_form_explanation() : profile.module
  • _profile_get_fields() : profile.module
  • _profile_update_user_fields() : profile.module
  • _rdf_example_installed_fields() : rdf_example.install
  • _rdf_example_installed_instances() : rdf_example.install
  • _rdf_get_default_mapping() : rdf.module
  • _rdf_mapping_load() : rdf.module
  • _registry_check_code() : bootstrap.inc
  • _registry_parse_file() : registry.inc
  • _registry_parse_files() : registry.inc
  • _registry_update() : registry.inc
  • _search_excerpt_match_filter() : search.module
  • _search_excerpt_replace() : search.module
  • _search_get_module_names() : search.admin.inc
  • _search_index_truncate() : search.module
  • _search_menu_access() : search.module
  • _shortcut_link_form_elements() : shortcut.admin.inc
  • _simpletest_autoload_psr0() : simpletest.module
  • _simpletest_batch_finished() : simpletest.module
  • _simpletest_batch_operation() : simpletest.module
  • _simpletest_example_explanation() : simpletest_example.module
  • _simpletest_format_summary_line() : simpletest.module
  • _statistics_format_item() : statistics.module
  • _statistics_link() : statistics.module
  • _system_batch_theme() : system.module
  • _system_date_format_types_build() : system.module
  • _system_date_formats_build() : system.module
  • _system_default_theme_features() : system.module
  • _system_info_add_path() : system.module
  • _system_is_incompatible() : system.admin.inc
  • _system_modules_build_row() : system.admin.inc
  • _system_rebuild_module_data() : system.module
  • _system_rebuild_theme_data() : system.module
  • _system_sort_requirements() : system.module
  • _system_theme_settings_validate_path() : system.admin.inc
  • _system_themes_access() : system.module
  • _system_update_bootstrap_status() : system.module
  • _taxonomy_get_tid_from_term() : taxonomy.module
  • _template_preprocess_default_variables() : theme.inc
  • _text_sanitize() : text.module
  • _theme_build_registry() : theme.inc
  • _theme_load_offline_registry() : theme.maintenance.inc
  • _theme_load_registry() : theme.inc
  • _theme_process_registry() : theme.inc
  • _theme_registry_callback() : theme.inc
  • _theme_save_registry() : theme.inc
  • _theme_table_cell() : theme.inc
  • _token_example_get_comment() : token_example.module
  • _token_example_get_file() : token_example.module
  • _token_example_get_node() : token_example.module
  • _token_example_get_taxonomy_term() : token_example.module
  • _token_example_get_user() : token_example.module
  • _toolbar_is_collapsed() : toolbar.module
  • _tracker_add() : tracker.module
  • _tracker_calculate_changed() : tracker.module
  • _tracker_myrecent_access() : tracker.module
  • _tracker_remove() : tracker.module
  • _tracker_user_access() : tracker.module
  • _translation_tab_access() : translation.module
  • _trigger_comment() : trigger.module
  • _trigger_example_first_time_login() : trigger_example.module
  • _trigger_get_all_info() : trigger.module
  • _trigger_node() : trigger.module
  • _trigger_normalize_comment_context() : trigger.module
  • _trigger_normalize_node_context() : trigger.module
  • _trigger_normalize_user_context() : trigger.module
  • _trigger_tab_information() : trigger.module
  • _trigger_taxonomy() : trigger.module
  • _trigger_user() : trigger.module
  • _unicode_caseflip() : unicode.inc
  • _unicode_check() : unicode.inc
  • _update_7000_field_create_field() : field.install
  • _update_7000_field_create_instance() : field.install
  • _update_7000_field_delete_field() : field.install
  • _update_7000_field_delete_instance() : field.install
  • _update_7000_field_read_fields() : field.install
  • _update_7000_field_sql_storage_write() : field_sql_storage.install
  • _update_7000_node_get_types() : node.install
  • _update_7000_user_role_grant_permissions() : user.install
  • _update_7002_taxonomy_get_vocabularies() : taxonomy.install
  • _update_authorize_clear_update_status() : update.authorize.inc
  • _update_batch_create_message() : update.authorize.inc
  • _update_build_fetch_url() : update.fetch.inc
  • _update_cache_clear() : update.module
  • _update_cache_get() : update.module
  • _update_cache_set() : update.module
  • _update_create_fetch_task() : update.fetch.inc
  • _update_cron_notify() : update.fetch.inc
  • _update_fetch_data() : update.fetch.inc
  • _update_get_cache_multiple() : update.module
  • _update_get_cached_available_releases() : update.module
  • _update_get_fetch_url_base() : update.fetch.inc
  • _update_manager_cache_directory() : update.module
  • _update_manager_check_backends() : update.manager.inc
  • _update_manager_extract_directory() : update.module
  • _update_manager_unique_identifier() : update.module
  • _update_message_text() : update.module
  • _update_no_data() : update.module
  • _update_process_fetch_task() : update.fetch.inc
  • _update_process_info_list() : update.compare.inc
  • _update_project_status_sort() : update.module
  • _update_refresh() : update.fetch.inc
  • _update_requirement_check() : update.install
  • _user_cancel() : user.module
  • _user_cancel_session_regenerate() : user.module
  • _user_categories() : user.module
  • _user_mail_notify() : user.module
  • _user_mail_text() : user.module
  • _user_sort() : user.module
  • _vertical_tabs_example_explanation() : vertical_tabs_example.module
  • _xmlrpc() : xmlrpc.inc
  • _xmlrpc_example_alter_add() : xmlrpc_example.module
  • _xmlrpc_example_alter_subtract() : xmlrpc_example.module
  • _xmlrpc_example_server_add() : xmlrpc_example.module
  • _xmlrpc_example_server_subtract() : xmlrpc_example.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- a -

  • action_example_action_info() : action_example.module
  • action_example_basic_action() : action_example.module
  • action_example_menu() : action_example.module
  • action_example_node_sticky_action() : action_example.module
  • action_example_node_sticky_action_form() : action_example.module
  • action_example_node_sticky_action_submit() : action_example.module
  • action_example_node_sticky_action_validate() : action_example.module
  • action_example_unblock_user_action() : action_example.module
  • actions_actions_map() : actions.inc
  • actions_delete() : actions.inc
  • actions_do() : actions.inc
  • actions_function_lookup() : actions.inc
  • actions_get_all_actions() : actions.inc
  • actions_list() : actions.inc
  • actions_load() : actions.inc
  • actions_save() : actions.inc
  • actions_synchronize() : actions.inc
  • aggregator_admin_form() : aggregator.admin.inc
  • aggregator_admin_form_submit() : aggregator.admin.inc
  • aggregator_admin_overview() : aggregator.admin.inc
  • aggregator_admin_refresh_feed() : aggregator.admin.inc
  • aggregator_admin_remove_feed() : aggregator.admin.inc
  • aggregator_admin_remove_feed_submit() : aggregator.admin.inc
  • aggregator_aggregator_fetch() : aggregator.fetcher.inc
  • aggregator_aggregator_fetch_info() : aggregator.fetcher.inc
  • aggregator_aggregator_parse() : aggregator.parser.inc
  • aggregator_aggregator_parse_info() : aggregator.parser.inc
  • aggregator_aggregator_process() : aggregator.processor.inc
  • aggregator_aggregator_process_info() : aggregator.processor.inc
  • aggregator_aggregator_remove() : aggregator.processor.inc
  • aggregator_block_configure() : aggregator.module
  • aggregator_block_info() : aggregator.module
  • aggregator_block_save() : aggregator.module
  • aggregator_block_view() : aggregator.module
  • aggregator_categorize_items() : aggregator.pages.inc
  • aggregator_categorize_items_submit() : aggregator.pages.inc
  • aggregator_category_load() : aggregator.module
  • aggregator_cron() : aggregator.module
  • aggregator_cron_queue_info() : aggregator.module
  • aggregator_element_data() : aggregator.parser.inc
  • aggregator_element_end() : aggregator.parser.inc
  • aggregator_element_start() : aggregator.parser.inc
  • aggregator_expire() : aggregator.processor.inc
  • aggregator_feed_items_load() : aggregator.pages.inc
  • aggregator_feed_load() : aggregator.module
  • aggregator_filter_xss() : aggregator.module
  • aggregator_form_aggregator_admin_form_alter() : aggregator.processor.inc
  • aggregator_form_category() : aggregator.admin.inc
  • aggregator_form_category_submit() : aggregator.admin.inc
  • aggregator_form_category_validate() : aggregator.admin.inc
  • aggregator_form_feed() : aggregator.admin.inc
  • aggregator_form_feed_submit() : aggregator.admin.inc
  • aggregator_form_feed_validate() : aggregator.admin.inc
  • aggregator_form_opml() : aggregator.admin.inc
  • aggregator_form_opml_submit() : aggregator.admin.inc
  • aggregator_form_opml_validate() : aggregator.admin.inc
  • aggregator_help() : aggregator.module
  • aggregator_menu() : aggregator.module
  • aggregator_page_categories() : aggregator.pages.inc
  • aggregator_page_category() : aggregator.pages.inc
  • aggregator_page_category_form() : aggregator.pages.inc
  • aggregator_page_last() : aggregator.pages.inc
  • aggregator_page_opml() : aggregator.pages.inc
  • aggregator_page_rss() : aggregator.pages.inc
  • aggregator_page_source() : aggregator.pages.inc
  • aggregator_page_source_form() : aggregator.pages.inc
  • aggregator_page_sources() : aggregator.pages.inc
  • aggregator_parse_feed() : aggregator.parser.inc
  • aggregator_parse_w3cdtf() : aggregator.parser.inc
  • aggregator_permission() : aggregator.module
  • aggregator_refresh() : aggregator.module
  • aggregator_remove() : aggregator.module
  • aggregator_sanitize_configuration() : aggregator.module
  • aggregator_save_category() : aggregator.module
  • aggregator_save_feed() : aggregator.module
  • aggregator_save_item() : aggregator.processor.inc
  • aggregator_schema() : aggregator.install
  • aggregator_theme() : aggregator.module
  • aggregator_uninstall() : aggregator.install
  • aggregator_update_7000() : aggregator.install
  • aggregator_update_7001() : aggregator.install
  • aggregator_update_7002() : aggregator.install
  • aggregator_update_7003() : aggregator.install
  • aggregator_view() : aggregator.admin.inc
  • ajax_base_page_theme() : ajax.inc
  • ajax_command_after() : ajax.inc
  • ajax_command_alert() : ajax.inc
  • ajax_command_append() : ajax.inc
  • ajax_command_before() : ajax.inc
  • ajax_command_changed() : ajax.inc
  • ajax_command_css() : ajax.inc
  • ajax_command_data() : ajax.inc
  • ajax_command_html() : ajax.inc
  • ajax_command_insert() : ajax.inc
  • ajax_command_invoke() : ajax.inc
  • ajax_command_prepend() : ajax.inc
  • ajax_command_remove() : ajax.inc
  • ajax_command_replace() : ajax.inc
  • ajax_command_restripe() : ajax.inc
  • ajax_command_settings() : ajax.inc
  • ajax_deliver() : ajax.inc
  • ajax_example_add_more() : ajax_example_graceful_degradation.inc
  • ajax_example_add_more_add_one() : ajax_example_graceful_degradation.inc
  • ajax_example_add_more_callback() : ajax_example_graceful_degradation.inc
  • ajax_example_add_more_remove_one() : ajax_example_graceful_degradation.inc
  • ajax_example_add_more_submit() : ajax_example_graceful_degradation.inc
  • ajax_example_advanced_commands() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_after_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_alert_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_append_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_before_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_changed_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_css_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_data_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_html_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_prepend_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_remove_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_restripe_callback() : ajax_example_advanced.inc
  • ajax_example_advanced_commands_restripe_num_rows() : ajax_example_advanced.inc
  • ajax_example_autocheckboxes() : ajax_example.module
  • ajax_example_autocheckboxes_callback() : ajax_example.module
  • ajax_example_autotextfields() : ajax_example.module
  • ajax_example_autotextfields_callback() : ajax_example.module
  • ajax_example_dependent_dropdown() : ajax_example.module
  • ajax_example_dependent_dropdown_callback() : ajax_example.module
  • ajax_example_dependent_dropdown_degrades() : ajax_example_graceful_degradation.inc
  • ajax_example_dependent_dropdown_degrades_first_callback() : ajax_example_graceful_degradation.inc
  • ajax_example_dependent_dropdown_degrades_submit() : ajax_example_graceful_degradation.inc
  • ajax_example_dynamic_sections() : ajax_example_graceful_degradation.inc
  • ajax_example_dynamic_sections_select_callback() : ajax_example_graceful_degradation.inc
  • ajax_example_dynamic_sections_submit() : ajax_example_graceful_degradation.inc
  • ajax_example_dynamic_sections_validate() : ajax_example_graceful_degradation.inc
  • ajax_example_form_node_callback() : ajax_example_node_form_alter.inc
  • ajax_example_form_node_form_alter() : ajax_example_node_form_alter.inc
  • ajax_example_intro() : ajax_example.module
  • ajax_example_menu() : ajax_example.module
  • ajax_example_node_by_author_ajax_callback() : ajax_example_autocomplete.inc
  • ajax_example_node_by_author_autocomplete() : ajax_example_autocomplete.inc
  • ajax_example_node_by_author_autocomplete_submit() : ajax_example_autocomplete.inc
  • ajax_example_node_by_author_autocomplete_validate() : ajax_example_autocomplete.inc
  • ajax_example_node_by_author_node_autocomplete_callback() : ajax_example_autocomplete.inc
  • ajax_example_node_delete() : ajax_example_node_form_alter.inc
  • ajax_example_node_insert() : ajax_example_node_form_alter.inc
  • ajax_example_node_load() : ajax_example_node_form_alter.inc
  • ajax_example_node_prepare() : ajax_example_node_form_alter.inc
  • ajax_example_node_submit() : ajax_example_node_form_alter.inc
  • ajax_example_node_update() : ajax_example_node_form_alter.inc
  • ajax_example_render_link() : ajax_example_misc.inc
  • ajax_example_render_link_ra() : ajax_example_misc.inc
  • ajax_example_schema() : ajax_example.install
  • ajax_example_simple_autocomplete() : ajax_example_autocomplete.inc
  • ajax_example_simple_user_autocomplete_callback() : ajax_example_autocomplete.inc
  • ajax_example_simplest() : ajax_example.module
  • ajax_example_simplest_callback() : ajax_example.module
  • ajax_example_submit_driven_ajax() : ajax_example.module
  • ajax_example_submit_driven_callback() : ajax_example.module
  • ajax_example_unique_autocomplete() : ajax_example_autocomplete.inc
  • ajax_example_unique_autocomplete_submit() : ajax_example_autocomplete.inc
  • ajax_example_unique_autocomplete_validate() : ajax_example_autocomplete.inc
  • ajax_example_unique_node_autocomplete_callback() : ajax_example_autocomplete.inc
  • ajax_example_update_7100() : ajax_example.install
  • ajax_example_wizard() : ajax_example_graceful_degradation.inc
  • ajax_example_wizard_callback() : ajax_example_graceful_degradation.inc
  • ajax_example_wizard_submit() : ajax_example_graceful_degradation.inc
  • ajax_footer() : ajax.inc
  • ajax_form_callback() : ajax.inc
  • ajax_get_form() : ajax.inc
  • ajax_link_response() : ajax_example_misc.inc
  • ajax_pre_render_element() : ajax.inc
  • ajax_prepare_response() : ajax.inc
  • ajax_process_form() : ajax.inc
  • ajax_render() : ajax.inc
  • archiver_get_archiver() : common.inc
  • archiver_get_extensions() : common.inc
  • archiver_get_info() : common.inc
  • arg() : bootstrap.inc
  • authorize_access_allowed() : authorize.php
  • authorize_access_denied_page() : authorize.php
  • authorize_filetransfer_form() : authorize.inc
  • authorize_filetransfer_form_submit() : authorize.inc
  • authorize_filetransfer_form_validate() : authorize.inc
  • authorize_get_filetransfer() : authorize.inc
  • authorize_run_operation() : authorize.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- b -

  • bartik_field__taxonomy_term_reference() : template.php
  • bartik_menu_tree() : template.php
  • bartik_preprocess_block() : template.php
  • bartik_preprocess_html() : template.php
  • bartik_preprocess_maintenance_page() : template.php
  • bartik_preprocess_node() : template.php
  • bartik_process_html() : template.php
  • bartik_process_maintenance_page() : template.php
  • bartik_process_page() : template.php
  • base_path() : common.inc
  • batch_example_batch_1() : batch_example.module
  • batch_example_batch_2() : batch_example.module
  • batch_example_finished() : batch_example.module
  • batch_example_lowest_nid() : batch_example.module
  • batch_example_menu() : batch_example.module
  • batch_example_op_1() : batch_example.module
  • batch_example_op_2() : batch_example.module
  • batch_example_simple_form() : batch_example.module
  • batch_example_simple_form_submit() : batch_example.module
  • batch_example_update_7100() : batch_example.install
  • batch_get() : form.inc
  • batch_load() : batch.inc
  • batch_process() : form.inc
  • batch_set() : form.inc
  • block_add_block_form() : block.admin.inc
  • block_add_block_form_submit() : block.admin.inc
  • block_add_block_form_validate() : block.admin.inc
  • block_admin_configure() : block.admin.inc
  • block_admin_configure_submit() : block.admin.inc
  • block_admin_configure_validate() : block.admin.inc
  • block_admin_demo() : block.admin.inc
  • block_admin_display() : block.admin.inc
  • block_admin_display_form() : block.admin.inc
  • block_admin_display_form_submit() : block.admin.inc
  • block_admin_display_prepare_blocks() : block.admin.inc
  • block_admin_paths() : block.module
  • block_block_configure() : block.module
  • block_block_info() : block.module
  • block_block_list_alter() : block.module
  • block_block_save() : block.module
  • block_block_view() : block.module
  • block_custom_block_delete() : block.admin.inc
  • block_custom_block_delete_submit() : block.admin.inc
  • block_custom_block_form() : block.module
  • block_custom_block_get() : block.module
  • block_custom_block_save() : block.module
  • block_example_block_configure() : block_example.module
  • block_example_block_info() : block_example.module
  • block_example_block_list_alter() : block_example.module
  • block_example_block_save() : block_example.module
  • block_example_block_view() : block_example.module
  • block_example_block_view_alter() : block_example.module
  • block_example_contents() : block_example.module
  • block_example_menu() : block_example.module
  • block_example_page() : block_example.module
  • block_example_uninstall() : block_example.install
  • block_flush_caches() : block.module
  • block_form_system_performance_settings_alter() : block.module
  • block_form_user_profile_form_alter() : block.module
  • block_get_blocks_by_region() : block.module
  • block_help() : block.module
  • block_install() : block.install
  • block_list() : block.module
  • block_load() : block.module
  • block_menu() : block.module
  • block_menu_delete() : block.module
  • block_modules_uninstalled() : block.module
  • block_page_build() : block.module
  • block_permission() : block.module
  • block_schema() : block.install
  • block_theme() : block.module
  • block_theme_initialize() : block.module
  • block_themes_enabled() : block.module
  • block_update_7000() : block.install
  • block_update_7002() : block.install
  • block_update_7003() : block.install
  • block_update_7004() : block.install
  • block_update_7005() : block.install
  • block_update_7006() : block.install
  • block_update_7007() : block.install
  • block_update_7008() : block.install
  • block_update_dependencies() : block.install
  • block_user_presave() : block.module
  • block_user_role_delete() : block.module
  • blocked_ip_load() : system.module
  • blog_block_configure() : blog.module
  • blog_block_info() : blog.module
  • blog_block_save() : blog.module
  • blog_block_view() : blog.module
  • blog_feed_last() : blog.pages.inc
  • blog_feed_user() : blog.pages.inc
  • blog_form() : blog.module
  • blog_help() : blog.module
  • blog_install() : blog.install
  • blog_menu() : blog.module
  • blog_menu_local_tasks_alter() : blog.module
  • blog_node_info() : blog.module
  • blog_node_view() : blog.module
  • blog_page_last() : blog.pages.inc
  • blog_page_user() : blog.pages.inc
  • blog_page_user_access() : blog.module
  • blog_rdf_mapping() : blog.module
  • blog_uninstall() : blog.install
  • blog_user_view() : blog.module
  • blog_view() : blog.module
  • book_admin_edit() : book.admin.inc
  • book_admin_edit_submit() : book.admin.inc
  • book_admin_edit_validate() : book.admin.inc
  • book_admin_overview() : book.admin.inc
  • book_admin_paths() : book.module
  • book_admin_settings() : book.admin.inc
  • book_admin_settings_validate() : book.admin.inc
  • book_block_configure() : book.module
  • book_block_info() : book.module
  • book_block_save() : book.module
  • book_block_view() : book.module
  • book_children() : book.module
  • book_entity_info_alter() : book.module
  • book_export() : book.pages.inc
  • book_export_html() : book.pages.inc
  • book_export_traverse() : book.module
  • book_form_node_delete_confirm_alter() : book.module
  • book_form_node_form_alter() : book.module
  • book_form_update() : book.module
  • book_get_books() : book.module
  • book_get_flat_menu() : book.module
  • book_help() : book.module
  • book_install() : book.install
  • book_link_load() : book.module
  • book_menu() : book.module
  • book_menu_name() : book.module
  • book_menu_subtree_data() : book.module
  • book_next() : book.module
  • book_node_delete() : book.module
  • book_node_export() : book.module
  • book_node_insert() : book.module
  • book_node_load() : book.module
  • book_node_prepare() : book.module
  • book_node_presave() : book.module
  • book_node_type_update() : book.module
  • book_node_update() : book.module
  • book_node_view() : book.module
  • book_node_view_link() : book.module
  • book_outline() : book.pages.inc
  • book_outline_form() : book.pages.inc
  • book_outline_form_submit() : book.pages.inc
  • book_page_alter() : book.module
  • book_permission() : book.module
  • book_pick_book_nojs_submit() : book.module
  • book_prev() : book.module
  • book_remove_button_submit() : book.pages.inc
  • book_remove_form() : book.pages.inc
  • book_remove_form_submit() : book.pages.inc
  • book_render() : book.pages.inc
  • book_schema() : book.install
  • book_theme() : book.module
  • book_toc() : book.module
  • book_type_is_allowed() : book.module
  • book_uninstall() : book.install
  • book_update_bid() : book.module
  • bootstrap_hooks() : bootstrap.inc
  • bootstrap_invoke_all() : bootstrap.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- c -

  • cache_clear_all() : cache.inc
  • cache_example_form_cache_clearing() : cache_example.module
  • cache_example_form_create_expiring_item() : cache_example.module
  • cache_example_form_expire_files() : cache_example.module
  • cache_example_menu() : cache_example.module
  • cache_example_page_form() : cache_example.module
  • cache_get() : cache.inc
  • cache_get_multiple() : cache.inc
  • cache_is_empty() : cache.inc
  • cache_set() : cache.inc
  • callback_entity_info_label() : system.api.php
  • callback_entity_info_language() : system.api.php
  • callback_entity_info_uri() : system.api.php
  • callback_filter_prepare() : filter.api.php
  • callback_filter_process() : filter.api.php
  • callback_filter_settings() : filter.api.php
  • callback_filter_tips() : filter.api.php
  • callback_search_conditions() : search.api.php
  • check_markup() : filter.module
  • check_plain() : bootstrap.inc
  • check_url() : common.inc
  • color_form_system_theme_settings_alter() : color.module
  • color_form_system_themes_alter() : color.module
  • color_get_info() : color.module
  • color_get_palette() : color.module
  • color_help() : color.module
  • color_palette_color_value() : color.module
  • color_requirements() : color.install
  • color_scheme_form() : color.module
  • color_scheme_form_submit() : color.module
  • color_scheme_form_validate() : color.module
  • color_theme() : color.module
  • color_update_7001() : color.install
  • color_valid_hexadecimal_string() : color.module
  • comment_access() : comment.module
  • comment_action_info() : comment.module
  • comment_admin() : comment.admin.inc
  • comment_admin_overview() : comment.admin.inc
  • comment_admin_overview_submit() : comment.admin.inc
  • comment_admin_overview_validate() : comment.admin.inc
  • comment_approve() : comment.pages.inc
  • comment_block_configure() : comment.module
  • comment_block_info() : comment.module
  • comment_block_save() : comment.module
  • comment_block_view() : comment.module
  • comment_build_content() : comment.module
  • comment_confirm_delete() : comment.admin.inc
  • comment_confirm_delete_page() : comment.admin.inc
  • comment_confirm_delete_submit() : comment.admin.inc
  • comment_count_unpublished() : comment.module
  • comment_delete() : comment.module
  • comment_delete_multiple() : comment.module
  • comment_edit_page() : comment.module
  • comment_enable() : comment.install
  • comment_entity_info() : comment.module
  • comment_field_extra_fields() : comment.module
  • comment_file_download_access() : comment.module
  • comment_form() : comment.module
  • comment_form_build_preview() : comment.module
  • comment_form_node_form_alter() : comment.module
  • comment_form_node_type_form_alter() : comment.module
  • comment_form_submit() : comment.module
  • comment_form_submit_build_comment() : comment.module
  • comment_form_validate() : comment.module
  • comment_forms() : comment.module
  • comment_get_display_ordinal() : comment.module
  • comment_get_display_page() : comment.module
  • comment_get_recent() : comment.module
  • comment_get_thread() : comment.module
  • comment_help() : comment.module
  • comment_links() : comment.module
  • comment_load() : comment.module
  • comment_load_multiple() : comment.module
  • comment_menu() : comment.module
  • comment_menu_alter() : comment.module
  • comment_modules_enabled() : comment.install
  • comment_multiple_delete_confirm() : comment.admin.inc
  • comment_multiple_delete_confirm_submit() : comment.admin.inc
  • comment_new_page_count() : comment.module
  • comment_node_delete() : comment.module
  • comment_node_insert() : comment.module
  • comment_node_load() : comment.module
  • comment_node_page_additions() : comment.module
  • comment_node_prepare() : comment.module
  • comment_node_search_result() : comment.module
  • comment_node_type_delete() : comment.module
  • comment_node_type_insert() : comment.module
  • comment_node_type_load() : comment.module
  • comment_node_type_update() : comment.module
  • comment_node_update_index() : comment.module
  • comment_node_view() : comment.module
  • comment_num_new() : comment.module
  • comment_permalink() : comment.module
  • comment_permission() : comment.module
  • comment_prepare_thread() : comment.module
  • comment_preview() : comment.module
  • comment_publish_action() : comment.module
  • comment_ranking() : comment.module
  • comment_rdf_mapping() : comment.module
  • comment_reply() : comment.pages.inc
  • comment_save() : comment.module
  • comment_save_action() : comment.module
  • comment_schema() : comment.install
  • comment_submit() : comment.module
  • comment_theme() : comment.module
  • comment_token_info() : comment.tokens.inc
  • comment_tokens() : comment.tokens.inc
  • comment_uninstall() : comment.install
  • comment_unpublish_action() : comment.module
  • comment_unpublish_by_keyword_action() : comment.module
  • comment_unpublish_by_keyword_action_form() : comment.module
  • comment_unpublish_by_keyword_action_submit() : comment.module
  • comment_update_7000() : comment.install
  • comment_update_7001() : comment.install
  • comment_update_7002() : comment.install
  • comment_update_7003() : comment.install
  • comment_update_7004() : comment.install
  • comment_update_7005() : comment.install
  • comment_update_7006() : comment.install
  • comment_update_7007() : comment.install
  • comment_update_7008() : comment.install
  • comment_update_7009() : comment.install
  • comment_update_dependencies() : comment.install
  • comment_update_index() : comment.module
  • comment_uri() : comment.module
  • comment_user_cancel() : comment.module
  • comment_user_delete() : comment.module
  • comment_view() : comment.module
  • comment_view_multiple() : comment.module
  • conf_path() : bootstrap.inc
  • confirm_form() : system.module
  • contact_category_delete_form() : contact.admin.inc
  • contact_category_delete_form_submit() : contact.admin.inc
  • contact_category_edit_form() : contact.admin.inc
  • contact_category_edit_form_submit() : contact.admin.inc
  • contact_category_edit_form_validate() : contact.admin.inc
  • contact_category_list() : contact.admin.inc
  • contact_form_user_admin_settings_alter() : contact.module
  • contact_form_user_profile_form_alter() : contact.module
  • contact_help() : contact.module
  • contact_install() : contact.install
  • contact_load() : contact.module
  • contact_mail() : contact.module
  • contact_menu() : contact.module
  • contact_permission() : contact.module
  • contact_personal_form() : contact.pages.inc
  • contact_personal_form_submit() : contact.pages.inc
  • contact_personal_form_validate() : contact.pages.inc
  • contact_schema() : contact.install
  • contact_site_form() : contact.pages.inc
  • contact_site_form_submit() : contact.pages.inc
  • contact_site_form_validate() : contact.pages.inc
  • contact_uninstall() : contact.install
  • contact_update_7000() : contact.install
  • contact_update_7001() : contact.install
  • contact_update_7002() : contact.install
  • contact_update_7003() : contact.install
  • contact_update_dependencies() : contact.install
  • contact_user_presave() : contact.module
  • contextual_element_info() : contextual.module
  • contextual_help() : contextual.module
  • contextual_library() : contextual.module
  • contextual_links_example_block_info() : contextual_links_example.module
  • contextual_links_example_block_view() : contextual_links_example.module
  • contextual_links_example_menu() : contextual_links_example.module
  • contextual_links_example_node_action_form() : contextual_links_example.module
  • contextual_links_example_node_action_form_submit() : contextual_links_example.module
  • contextual_links_example_object_edit_form() : contextual_links_example.module
  • contextual_links_example_object_edit_form_submit() : contextual_links_example.module
  • contextual_links_example_object_load() : contextual_links_example.module
  • contextual_links_example_object_page() : contextual_links_example.module
  • contextual_links_example_theme() : contextual_links_example.module
  • contextual_links_overview_page() : contextual_links_example.module
  • contextual_permission() : contextual.module
  • contextual_pre_render_links() : contextual.module
  • contextual_preprocess() : contextual.module
  • country_get_list() : locale.inc
  • cron_example_add_jobs_to_queue() : cron_example.module
  • cron_example_cron() : cron_example.module
  • cron_example_cron_queue_info() : cron_example.module
  • cron_example_form() : cron_example.module
  • cron_example_form_cron_run_submit() : cron_example.module
  • cron_example_menu() : cron_example.module
  • cron_example_queue_1_worker() : cron_example.module
  • cron_example_queue_2_worker() : cron_example.module
  • cron_example_queue_report_work() : cron_example.module
  • current_path() : path.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- d -

  • dashboard_admin() : dashboard.module
  • dashboard_admin_blocks() : dashboard.module
  • dashboard_block_info_alter() : dashboard.module
  • dashboard_block_list_alter() : dashboard.module
  • dashboard_dashboard_regions() : dashboard.module
  • dashboard_disable() : dashboard.install
  • dashboard_enable() : dashboard.install
  • dashboard_form_block_add_block_form_alter() : dashboard.module
  • dashboard_form_block_admin_configure_alter() : dashboard.module
  • dashboard_form_block_admin_display_form_alter() : dashboard.module
  • dashboard_form_dashboard_admin_display_form_alter() : dashboard.module
  • dashboard_forms() : dashboard.module
  • dashboard_help() : dashboard.module
  • dashboard_is_visible() : dashboard.module
  • dashboard_menu() : dashboard.module
  • dashboard_page_build() : dashboard.module
  • dashboard_permission() : dashboard.module
  • dashboard_region_descriptions() : dashboard.module
  • dashboard_regions() : dashboard.module
  • dashboard_show_block_content() : dashboard.module
  • dashboard_show_disabled() : dashboard.module
  • dashboard_system_info_alter() : dashboard.module
  • dashboard_theme() : dashboard.module
  • dashboard_uninstall() : dashboard.install
  • dashboard_update() : dashboard.module
  • date_iso8601() : common.inc
  • date_validate() : form.inc
  • db_add_field() : database.inc
  • db_add_index() : database.inc
  • db_add_primary_key() : database.inc
  • db_add_unique_key() : database.inc
  • db_and() : database.inc
  • db_change_field() : database.inc
  • db_close() : database.inc
  • db_condition() : database.inc
  • db_create_table() : database.inc
  • db_delete() : database.inc
  • db_driver() : database.inc
  • db_drop_field() : database.inc
  • db_drop_index() : database.inc
  • db_drop_primary_key() : database.inc
  • db_drop_table() : database.inc
  • db_drop_unique_key() : database.inc
  • db_escape_field() : database.inc
  • db_escape_table() : database.inc
  • db_field_exists() : database.inc
  • db_field_names() : database.inc
  • db_field_set_default() : database.inc
  • db_field_set_no_default() : database.inc
  • db_find_tables() : database.inc
  • db_ignore_slave() : database.inc
  • db_index_exists() : database.inc
  • db_insert() : database.inc
  • db_installer_object() : install.inc
  • db_like() : database.inc
  • db_merge() : database.inc
  • db_next_id() : database.inc
  • db_or() : database.inc
  • db_query() : database.inc
  • db_query_range() : database.inc
  • db_query_temporary() : database.inc
  • db_rename_table() : database.inc
  • db_run_tasks() : install.inc
  • db_select() : database.inc
  • db_set_active() : database.inc
  • db_table_exists() : database.inc
  • db_transaction() : database.inc
  • db_truncate() : database.inc
  • db_update() : database.inc
  • db_xor() : database.inc
  • dblog_build_filter_query() : dblog.admin.inc
  • dblog_clear_log_form() : dblog.admin.inc
  • dblog_clear_log_submit() : dblog.admin.inc
  • dblog_cron() : dblog.module
  • dblog_event() : dblog.admin.inc
  • dblog_filter_form() : dblog.admin.inc
  • dblog_filter_form_submit() : dblog.admin.inc
  • dblog_filter_form_validate() : dblog.admin.inc
  • dblog_filters() : dblog.admin.inc
  • dblog_form_system_logging_settings_alter() : dblog.module
  • dblog_help() : dblog.module
  • dblog_init() : dblog.module
  • dblog_menu() : dblog.module
  • dblog_overview() : dblog.admin.inc
  • dblog_schema() : dblog.install
  • dblog_theme() : dblog.module
  • dblog_top() : dblog.admin.inc
  • dblog_uninstall() : dblog.install
  • dblog_update_7001() : dblog.install
  • dblog_update_7002() : dblog.install
  • dblog_watchdog() : dblog.module
  • dbtng_example_advanced_list() : dbtng_example.module
  • dbtng_example_entry_delete() : dbtng_example.module
  • dbtng_example_entry_insert() : dbtng_example.module
  • dbtng_example_entry_load() : dbtng_example.module
  • dbtng_example_entry_update() : dbtng_example.module
  • dbtng_example_form_add() : dbtng_example.module
  • dbtng_example_form_add_submit() : dbtng_example.module
  • dbtng_example_form_update() : dbtng_example.module
  • dbtng_example_form_update_callback() : dbtng_example.module
  • dbtng_example_form_update_submit() : dbtng_example.module
  • dbtng_example_help() : dbtng_example.module
  • dbtng_example_install() : dbtng_example.install
  • dbtng_example_list() : dbtng_example.module
  • dbtng_example_menu() : dbtng_example.module
  • dbtng_example_schema() : dbtng_example.install
  • dbtng_example_uninstall() : dbtng_example.install
  • debug() : common.inc
  • decode_entities() : unicode.inc
  • drupal_access_denied() : common.inc
  • drupal_add_css() : common.inc
  • drupal_add_feed() : common.inc
  • drupal_add_html_head() : common.inc
  • drupal_add_html_head_link() : common.inc
  • drupal_add_http_header() : bootstrap.inc
  • drupal_add_js() : common.inc
  • drupal_add_library() : common.inc
  • drupal_add_region_content() : common.inc
  • drupal_add_tabledrag() : common.inc
  • drupal_aggregate_css() : common.inc
  • drupal_alter() : module.inc
  • drupal_anonymous_user() : bootstrap.inc
  • drupal_array_diff_assoc_recursive() : common.inc
  • drupal_array_get_nested_value() : common.inc
  • drupal_array_merge_deep() : bootstrap.inc
  • drupal_array_merge_deep_array() : bootstrap.inc
  • drupal_array_nested_key_exists() : common.inc
  • drupal_array_set_nested_value() : common.inc
  • drupal_attributes() : common.inc
  • drupal_autoload_class() : bootstrap.inc
  • drupal_autoload_interface() : bootstrap.inc
  • drupal_base64_encode() : bootstrap.inc
  • drupal_basename() : file.inc
  • drupal_block_denied() : bootstrap.inc
  • drupal_bootstrap() : bootstrap.inc
  • drupal_build_css_cache() : common.inc
  • drupal_build_form() : form.inc
  • drupal_build_js_cache() : common.inc
  • drupal_cache_system_paths() : path.inc
  • drupal_check_incompatibility() : common.inc
  • drupal_check_memory_limit() : bootstrap.inc
  • drupal_check_module() : install.inc
  • drupal_check_profile() : install.inc
  • drupal_chmod() : file.inc
  • drupal_clean_css_identifier() : common.inc
  • drupal_clear_css_cache() : common.inc
  • drupal_clear_js_cache() : common.inc
  • drupal_clear_path_cache() : path.inc
  • drupal_common_theme() : common.inc
  • drupal_convert_to_utf8() : unicode.inc
  • drupal_cron_cleanup() : common.inc
  • drupal_cron_run() : common.inc
  • drupal_current_script_url() : install.inc
  • drupal_delete_file_if_stale() : common.inc
  • drupal_deliver_html_page() : common.inc
  • drupal_deliver_page() : common.inc
  • drupal_depth_first_search() : graph.inc
  • drupal_detect_baseurl() : install.inc
  • drupal_detect_database_types() : install.inc
  • drupal_dirname() : file.inc
  • drupal_encode_path() : common.inc
  • drupal_environment_initialize() : bootstrap.inc
  • drupal_error_levels() : errors.inc
  • drupal_exit() : common.inc
  • drupal_explode_tags() : common.inc
  • drupal_fast_404() : bootstrap.inc
  • drupal_find_base_themes() : theme.inc
  • drupal_find_theme_functions() : theme.inc
  • drupal_find_theme_templates() : theme.inc
  • drupal_flush_all_caches() : common.inc
  • drupal_form_submit() : form.inc
  • drupal_generate_test_ua() : bootstrap.inc
  • drupal_get_bootstrap_phase() : bootstrap.inc
  • drupal_get_breadcrumb() : common.inc
  • drupal_get_complete_schema() : bootstrap.inc
  • drupal_get_css() : common.inc
  • drupal_get_database_types() : install.inc
  • drupal_get_destination() : common.inc
  • drupal_get_feeds() : common.inc
  • drupal_get_filename() : bootstrap.inc
  • drupal_get_filetransfer_info() : common.inc
  • drupal_get_form() : form.inc
  • drupal_get_hash_salt() : bootstrap.inc
  • drupal_get_html_head() : common.inc
  • drupal_get_http_header() : bootstrap.inc
  • drupal_get_installed_schema_version() : install.inc
  • drupal_get_js() : common.inc
  • drupal_get_library() : common.inc
  • drupal_get_messages() : bootstrap.inc
  • drupal_get_normal_path() : path.inc
  • drupal_get_path() : common.inc
  • drupal_get_path_alias() : path.inc
  • drupal_get_private_key() : common.inc
  • drupal_get_profile() : common.inc
  • drupal_get_query_array() : common.inc
  • drupal_get_query_parameters() : common.inc
  • drupal_get_rdf_namespaces() : common.inc
  • drupal_get_region_content() : common.inc
  • drupal_get_schema() : bootstrap.inc
  • drupal_get_schema_unprocessed() : common.inc
  • drupal_get_schema_versions() : install.inc
  • drupal_get_title() : bootstrap.inc
  • drupal_get_token() : common.inc
  • drupal_get_updaters() : common.inc
  • drupal_get_user_timezone() : bootstrap.inc
  • drupal_goto() : common.inc
  • drupal_group_css() : common.inc
  • drupal_hash_base64() : bootstrap.inc
  • drupal_help_arg() : menu.inc
  • drupal_hmac_base64() : bootstrap.inc
  • drupal_html_class() : common.inc
  • drupal_html_id() : common.inc
  • drupal_html_to_text() : mail.inc
  • drupal_http_build_query() : common.inc
  • drupal_http_header_attributes() : common.inc
  • drupal_http_request() : common.inc
  • drupal_implode_tags() : common.inc
  • drupal_install_fix_file() : install.inc
  • drupal_install_mkdir() : install.inc
  • drupal_install_profile_distribution_name() : install.inc
  • drupal_install_schema() : common.inc
  • drupal_install_system() : install.inc
  • drupal_installation_attempted() : bootstrap.inc
  • drupal_is_cli() : bootstrap.inc
  • drupal_is_denied() : bootstrap.inc
  • drupal_is_front_page() : path.inc
  • drupal_js_defaults() : common.inc
  • drupal_json_decode() : common.inc
  • drupal_json_encode() : common.inc
  • drupal_json_encode_helper() : json-encode.inc
  • drupal_json_output() : common.inc
  • drupal_language_initialize() : bootstrap.inc
  • drupal_language_types() : bootstrap.inc
  • drupal_load() : bootstrap.inc
  • drupal_load_stylesheet() : common.inc
  • drupal_load_stylesheet_content() : common.inc
  • drupal_load_updates() : install.inc
  • drupal_lookup_path() : path.inc
  • drupal_mail() : mail.inc
  • drupal_mail_system() : mail.inc
  • drupal_maintenance_theme() : bootstrap.inc
  • drupal_map_assoc() : common.inc
  • drupal_match_path() : path.inc
  • drupal_mkdir() : file.inc
  • drupal_move_uploaded_file() : file.inc
  • drupal_multilingual() : bootstrap.inc
  • drupal_not_found() : common.inc
  • drupal_override_server_variables() : bootstrap.inc
  • drupal_page_footer() : common.inc
  • drupal_page_get_cache() : bootstrap.inc
  • drupal_page_header() : bootstrap.inc
  • drupal_page_is_cacheable() : bootstrap.inc
  • drupal_page_set_cache() : common.inc
  • drupal_parse_dependency() : common.inc
  • drupal_parse_info_file() : common.inc
  • drupal_parse_info_format() : common.inc
  • drupal_parse_url() : common.inc
  • drupal_path_alias_whitelist_rebuild() : path.inc
  • drupal_path_initialize() : path.inc
  • drupal_placeholder() : bootstrap.inc
  • drupal_pre_render_conditional_comments() : common.inc
  • drupal_pre_render_link() : common.inc
  • drupal_pre_render_links() : common.inc
  • drupal_pre_render_markup() : common.inc
  • drupal_pre_render_styles() : common.inc
  • drupal_prepare_form() : form.inc
  • drupal_process_attached() : common.inc
  • drupal_process_form() : form.inc
  • drupal_process_states() : common.inc
  • drupal_random_bytes() : bootstrap.inc
  • drupal_random_key() : bootstrap.inc
  • drupal_realpath() : file.inc
  • drupal_rebuild_form() : form.inc
  • drupal_redirect_form() : form.inc
  • drupal_region_class() : common.inc
  • drupal_register_shutdown_function() : bootstrap.inc
  • drupal_render() : common.inc
  • drupal_render_cache_by_query() : common.inc
  • drupal_render_cache_get() : common.inc
  • drupal_render_cache_set() : common.inc
  • drupal_render_children() : common.inc
  • drupal_render_cid_create() : common.inc
  • drupal_render_cid_parts() : common.inc
  • drupal_render_collect_attached() : common.inc
  • drupal_render_page() : common.inc
  • drupal_required_modules() : module.inc
  • drupal_requirements_severity() : install.inc
  • drupal_requirements_url() : install.inc
  • drupal_retrieve_form() : form.inc
  • drupal_rewrite_settings() : install.inc
  • drupal_rmdir() : file.inc
  • drupal_save_session() : session.inc
  • drupal_schema_fields_sql() : common.inc
  • drupal_send_headers() : bootstrap.inc
  • drupal_serve_page_from_cache() : bootstrap.inc
  • drupal_session_commit() : session.inc
  • drupal_session_destroy_uid() : session.inc
  • drupal_session_initialize() : session.inc
  • drupal_session_regenerate() : session.inc
  • drupal_session_start() : session.inc
  • drupal_session_started() : session.inc
  • drupal_set_breadcrumb() : common.inc
  • drupal_set_installed_schema_version() : install.inc
  • drupal_set_message() : bootstrap.inc
  • drupal_set_page_content() : common.inc
  • drupal_set_time_limit() : common.inc
  • drupal_set_title() : bootstrap.inc
  • drupal_settings_initialize() : bootstrap.inc
  • drupal_site_offline() : common.inc
  • drupal_sort_css_js() : common.inc
  • drupal_sort_title() : common.inc
  • drupal_sort_weight() : common.inc
  • drupal_static() : bootstrap.inc
  • drupal_static_reset() : bootstrap.inc
  • drupal_strip_dangerous_protocols() : common.inc
  • drupal_strlen() : unicode.inc
  • drupal_strtolower() : unicode.inc
  • drupal_strtoupper() : unicode.inc
  • drupal_substr() : unicode.inc
  • drupal_system_listing() : common.inc
  • drupal_tempnam() : file.inc
  • drupal_theme_access() : theme.inc
  • drupal_theme_initialize() : theme.inc
  • drupal_theme_rebuild() : theme.inc
  • drupal_truncate_bytes() : unicode.inc
  • drupal_ucfirst() : unicode.inc
  • drupal_uninstall_modules() : install.inc
  • drupal_uninstall_schema() : common.inc
  • drupal_unlink() : file.inc
  • drupal_unpack() : bootstrap.inc
  • drupal_valid_http_host() : bootstrap.inc
  • drupal_valid_path() : path.inc
  • drupal_valid_test_ua() : bootstrap.inc
  • drupal_valid_token() : common.inc
  • drupal_validate_form() : form.inc
  • drupal_validate_utf8() : bootstrap.inc
  • drupal_var_export() : utility.inc
  • drupal_verify_install_file() : install.inc
  • drupal_verify_profile() : install.inc
  • drupal_wrap_mail() : mail.inc
  • drupal_write_record() : common.inc
  • drupal_xml_parser_create() : unicode.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- e -

  • element_child() : common.inc
  • element_children() : common.inc
  • element_get_visible_children() : common.inc
  • element_info() : common.inc
  • element_info_property() : common.inc
  • element_properties() : common.inc
  • element_property() : common.inc
  • element_set_attributes() : common.inc
  • element_sort() : common.inc
  • element_sort_by_title() : common.inc
  • element_validate_integer() : form.inc
  • element_validate_integer_positive() : form.inc
  • element_validate_number() : form.inc
  • email_example_form() : email_example.module
  • email_example_form_submit() : email_example.module
  • email_example_form_validate() : email_example.module
  • email_example_mail() : email_example.module
  • email_example_mail_alter() : email_example.module
  • email_example_mail_send() : email_example.module
  • email_example_menu() : email_example.module
  • entity_create_stub_entity() : common.inc
  • entity_example_basic_add() : entity_example.module
  • entity_example_basic_delete() : entity_example.module
  • entity_example_basic_edit_delete() : entity_example.module
  • entity_example_basic_form() : entity_example.module
  • entity_example_basic_form_submit() : entity_example.module
  • entity_example_basic_form_validate() : entity_example.module
  • entity_example_basic_list_entities() : entity_example.module
  • entity_example_basic_load() : entity_example.module
  • entity_example_basic_load_multiple() : entity_example.module
  • entity_example_basic_save() : entity_example.module
  • entity_example_basic_title() : entity_example.module
  • entity_example_basic_uri() : entity_example.module
  • entity_example_basic_view() : entity_example.module
  • entity_example_entity_info() : entity_example.module
  • entity_example_field_extra_fields() : entity_example.module
  • entity_example_info_page() : entity_example.module
  • entity_example_menu() : entity_example.module
  • entity_example_permission() : entity_example.module
  • entity_example_schema() : entity_example.install
  • entity_example_uninstall() : entity_example.install
  • entity_extract_ids() : common.inc
  • entity_form_field_validate() : common.inc
  • entity_form_submit_build_entity() : common.inc
  • entity_get_controller() : common.inc
  • entity_get_info() : common.inc
  • entity_info_cache_clear() : common.inc
  • entity_label() : common.inc
  • entity_language() : common.inc
  • entity_load() : common.inc
  • entity_load_unchanged() : common.inc
  • entity_prepare_view() : common.inc
  • entity_uri() : common.inc
  • error_displayable() : errors.inc
  • examples_help() : examples.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- f -

  • field_access() : field.module
  • field_add_more_js() : field.form.inc
  • field_add_more_submit() : field.form.inc
  • field_associate_fields() : field.module
  • field_attach_create_bundle() : field.attach.inc
  • field_attach_delete() : field.attach.inc
  • field_attach_delete_bundle() : field.attach.inc
  • field_attach_delete_revision() : field.attach.inc
  • field_attach_form() : field.attach.inc
  • field_attach_form_validate() : field.attach.inc
  • field_attach_insert() : field.attach.inc
  • field_attach_load() : field.attach.inc
  • field_attach_load_revision() : field.attach.inc
  • field_attach_prepare_translation() : field.attach.inc
  • field_attach_prepare_view() : field.attach.inc
  • field_attach_preprocess() : field.attach.inc
  • field_attach_presave() : field.attach.inc
  • field_attach_rename_bundle() : field.attach.inc
  • field_attach_submit() : field.attach.inc
  • field_attach_update() : field.attach.inc
  • field_attach_validate() : field.attach.inc
  • field_attach_view() : field.attach.inc
  • field_available_languages() : field.multilingual.inc
  • field_behaviors_widget() : field.info.inc
  • field_bundle_settings() : field.module
  • field_cache_clear() : field.module
  • field_content_languages() : field.multilingual.inc
  • field_create_field() : field.crud.inc
  • field_create_instance() : field.crud.inc
  • field_cron() : field.module
  • field_default_extract_form_values() : field.default.inc
  • field_default_form() : field.form.inc
  • field_default_form_errors() : field.form.inc
  • field_default_insert() : field.default.inc
  • field_default_prepare_translation() : field.default.inc
  • field_default_prepare_view() : field.default.inc
  • field_default_submit() : field.default.inc
  • field_default_validate() : field.default.inc
  • field_default_view() : field.default.inc
  • field_delete_field() : field.crud.inc
  • field_delete_instance() : field.crud.inc
  • field_example_3text_validate() : field_example.module
  • field_example_field_formatter_info() : field_example.module
  • field_example_field_formatter_view() : field_example.module
  • field_example_field_info() : field_example.module
  • field_example_field_is_empty() : field_example.module
  • field_example_field_schema() : field_example.install
  • field_example_field_validate() : field_example.module
  • field_example_field_widget_error() : field_example.module
  • field_example_field_widget_form() : field_example.module
  • field_example_field_widget_info() : field_example.module
  • field_example_menu() : field_example.module
  • field_extra_fields_get_display() : field.module
  • field_extract_bundle() : field.module
  • field_filter_xss() : field.module
  • field_flush_caches() : field.module
  • field_form_element_after_build() : field.form.inc
  • field_form_get_state() : field.form.inc
  • field_form_set_state() : field.form.inc
  • field_get_default_value() : field.module
  • field_get_display() : field.module
  • field_get_items() : field.module
  • field_has_data() : field.module
  • field_has_translation_handler() : field.multilingual.inc
  • field_help() : field.module
  • field_info_bundles() : field.info.inc
  • field_info_cache_clear() : field.info.inc
  • field_info_extra_fields() : field.info.inc
  • field_info_field() : field.info.inc
  • field_info_field_by_id() : field.info.inc
  • field_info_field_by_ids() : field.info.inc
  • field_info_field_map() : field.info.inc
  • field_info_field_settings() : field.info.inc
  • field_info_field_types() : field.info.inc
  • field_info_fields() : field.info.inc
  • field_info_formatter_settings() : field.info.inc
  • field_info_formatter_types() : field.info.inc
  • field_info_instance() : field.info.inc
  • field_info_instance_settings() : field.info.inc
  • field_info_instances() : field.info.inc
  • field_info_max_weight() : field.info.inc
  • field_info_storage_settings() : field.info.inc
  • field_info_storage_types() : field.info.inc
  • field_info_widget_settings() : field.info.inc
  • field_info_widget_types() : field.info.inc
  • field_is_translatable() : field.multilingual.inc
  • field_language() : field.multilingual.inc
  • field_modules_disabled() : field.module
  • field_modules_enabled() : field.module
  • field_modules_uninstalled() : field.module
  • field_multilingual_settings_changed() : field.multilingual.inc
  • field_multiple_value_form() : field.form.inc
  • field_permission_example_field_access() : field_permission_example.module
  • field_permission_example_field_formatter_info() : field_permission_example.module
  • field_permission_example_field_formatter_view() : field_permission_example.module
  • field_permission_example_field_info() : field_permission_example.module
  • field_permission_example_field_is_empty() : field_permission_example.module
  • field_permission_example_field_schema() : field_permission_example.install
  • field_permission_example_field_widget_form() : field_permission_example.module
  • field_permission_example_field_widget_info() : field_permission_example.module
  • field_permission_example_menu() : field_permission_example.module
  • field_permission_example_permission() : field_permission_example.module
  • field_purge_batch() : field.crud.inc
  • field_purge_data() : field.crud.inc
  • field_purge_field() : field.crud.inc
  • field_purge_instance() : field.crud.inc
  • field_read_field() : field.crud.inc
  • field_read_fields() : field.crud.inc
  • field_read_instance() : field.crud.inc
  • field_read_instances() : field.crud.inc
  • field_schema() : field.install
  • field_sql_storage_field_attach_rename_bundle() : field_sql_storage.module
  • field_sql_storage_field_storage_create_field() : field_sql_storage.module
  • field_sql_storage_field_storage_delete() : field_sql_storage.module
  • field_sql_storage_field_storage_delete_field() : field_sql_storage.module
  • field_sql_storage_field_storage_delete_instance() : field_sql_storage.module
  • field_sql_storage_field_storage_delete_revision() : field_sql_storage.module
  • field_sql_storage_field_storage_details() : field_sql_storage.module
  • field_sql_storage_field_storage_info() : field_sql_storage.module
  • field_sql_storage_field_storage_load() : field_sql_storage.module
  • field_sql_storage_field_storage_purge() : field_sql_storage.module
  • field_sql_storage_field_storage_purge_field() : field_sql_storage.module
  • field_sql_storage_field_storage_query() : field_sql_storage.module
  • field_sql_storage_field_storage_update_field() : field_sql_storage.module
  • field_sql_storage_field_storage_write() : field_sql_storage.module
  • field_sql_storage_field_update_forbid() : field_sql_storage.module
  • field_sql_storage_help() : field_sql_storage.module
  • field_sql_storage_schema() : field_sql_storage.install
  • field_sql_storage_update_7000() : field_sql_storage.install
  • field_sql_storage_update_7001() : field_sql_storage.install
  • field_sql_storage_update_7002() : field_sql_storage.install
  • field_sync_field_status() : field.module
  • field_system_info_alter() : field.module
  • field_theme() : field.module
  • field_ui_default_value_widget() : field_ui.admin.inc
  • field_ui_display_overview_form() : field_ui.admin.inc
  • field_ui_display_overview_form_submit() : field_ui.admin.inc
  • field_ui_display_overview_multistep_js() : field_ui.admin.inc
  • field_ui_display_overview_multistep_submit() : field_ui.admin.inc
  • field_ui_display_overview_row_region() : field_ui.admin.inc
  • field_ui_element_info() : field_ui.module
  • field_ui_existing_field_options() : field_ui.admin.inc
  • field_ui_field_attach_create_bundle() : field_ui.module
  • field_ui_field_attach_rename_bundle() : field_ui.module
  • field_ui_field_delete_form() : field_ui.admin.inc
  • field_ui_field_delete_form_submit() : field_ui.admin.inc
  • field_ui_field_edit_form() : field_ui.admin.inc
  • field_ui_field_edit_form_submit() : field_ui.admin.inc
  • field_ui_field_edit_form_validate() : field_ui.admin.inc
  • field_ui_field_edit_instance_pre_render() : field_ui.admin.inc
  • field_ui_field_overview_form() : field_ui.admin.inc
  • field_ui_field_overview_form_submit() : field_ui.admin.inc
  • field_ui_field_overview_form_validate() : field_ui.admin.inc
  • field_ui_field_overview_row_region() : field_ui.admin.inc
  • field_ui_field_settings_form() : field_ui.admin.inc
  • field_ui_field_settings_form_submit() : field_ui.admin.inc
  • field_ui_field_type_options() : field_ui.admin.inc
  • field_ui_fields_list() : field_ui.admin.inc
  • field_ui_form_node_type_form_alter() : field_ui.module
  • field_ui_form_node_type_form_submit() : field_ui.module
  • field_ui_formatter_options() : field_ui.admin.inc
  • field_ui_get_destinations() : field_ui.admin.inc
  • field_ui_help() : field_ui.module
  • field_ui_inactive_instances() : field_ui.module
  • field_ui_inactive_message() : field_ui.admin.inc
  • field_ui_menu() : field_ui.module
  • field_ui_menu_load() : field_ui.module
  • field_ui_menu_title() : field_ui.module
  • field_ui_next_destination() : field_ui.admin.inc
  • field_ui_table_pre_render() : field_ui.admin.inc
  • field_ui_theme() : field_ui.module
  • field_ui_widget_type_form() : field_ui.admin.inc
  • field_ui_widget_type_form_submit() : field_ui.admin.inc
  • field_ui_widget_type_options() : field_ui.admin.inc
  • field_update_7000() : field.install
  • field_update_7001() : field.install
  • field_update_7002() : field.install
  • field_update_7003() : field.install
  • field_update_field() : field.crud.inc
  • field_update_instance() : field.crud.inc
  • field_valid_language() : field.multilingual.inc
  • field_view_field() : field.module
  • field_view_mode_settings() : field.module
  • field_view_value() : field.module
  • field_widget_field() : field.form.inc
  • field_widget_instance() : field.form.inc
  • file_ajax_progress() : file.module
  • file_ajax_upload() : file.module
  • file_build_uri() : file.inc
  • file_copy() : file.inc
  • file_create_filename() : file.inc
  • file_create_htaccess() : file.inc
  • file_create_url() : file.inc
  • file_default_mimetype_mapping() : file.mimetypes.inc
  • file_default_scheme() : file.inc
  • file_delete() : file.inc
  • file_destination() : file.inc
  • file_directory_temp() : file.inc
  • file_download() : file.inc
  • file_element_info() : file.module
  • file_ensure_htaccess() : file.inc
  • file_example_check_directory_submit() : file_example.module
  • file_example_create_directory_submit() : file_example.module
  • file_example_delete_directory_submit() : file_example.module
  • file_example_delete_submit() : file_example.module
  • file_example_file_check_exists_submit() : file_example.module
  • file_example_get_managed_file() : file_example.module
  • file_example_intro() : file_example.module
  • file_example_managed_write_submit() : file_example.module
  • file_example_menu() : file_example.module
  • file_example_permission() : file_example.module
  • file_example_read_submit() : file_example.module
  • file_example_readwrite() : file_example.module
  • file_example_session_contents() : file_example.module
  • file_example_show_session_contents_submit() : file_example.module
  • file_example_stream_wrappers() : file_example.module
  • file_example_unmanaged_php_submit() : file_example.module
  • file_example_unmanaged_write_submit() : file_example.module
  • file_field_delete() : file.field.inc
  • file_field_delete_file() : file.field.inc
  • file_field_delete_revision() : file.field.inc
  • file_field_displayed() : file.field.inc
  • file_field_formatter_info() : file.field.inc
  • file_field_formatter_view() : file.field.inc
  • file_field_info() : file.field.inc
  • file_field_insert() : file.field.inc
  • file_field_instance_settings_form() : file.field.inc
  • file_field_is_empty() : file.field.inc
  • file_field_load() : file.field.inc
  • file_field_prepare_view() : file.field.inc
  • file_field_presave() : file.field.inc
  • file_field_schema() : file.install
  • file_field_settings_form() : file.field.inc
  • file_field_update() : file.field.inc
  • file_field_widget_form() : file.field.inc
  • file_field_widget_info() : file.field.inc
  • file_field_widget_process() : file.field.inc
  • file_field_widget_process_multiple() : file.field.inc
  • file_field_widget_settings_form() : file.field.inc
  • file_field_widget_submit() : file.field.inc
  • file_field_widget_upload_validators() : file.field.inc
  • file_field_widget_uri() : file.field.inc
  • file_field_widget_value() : file.field.inc
  • file_file_delete() : file.module
  • file_file_download() : file.module
  • file_get_content_headers() : file.inc
  • file_get_file_references() : file.module
  • file_get_mimetype() : file.inc
  • file_get_stream_wrappers() : file.inc
  • file_help() : file.module
  • file_htaccess_lines() : file.inc
  • file_icon_map() : file.module
  • file_icon_path() : file.module
  • file_icon_url() : file.module
  • file_load() : file.inc
  • file_load_multiple() : file.inc
  • file_managed_file_pre_render() : file.module
  • file_managed_file_process() : file.module
  • file_managed_file_save_upload() : file.module
  • file_managed_file_submit() : file.module
  • file_managed_file_validate() : file.module
  • file_managed_file_value() : file.module
  • file_menu() : file.module
  • file_mimetype_mapping() : file.mimetypes.inc
  • file_move() : file.inc
  • file_munge_filename() : file.inc
  • file_prepare_directory() : file.inc
  • file_progress_implementation() : file.module
  • file_requirements() : file.install
  • file_save() : file.inc
  • file_save_data() : file.inc
  • file_save_upload() : file.inc
  • file_scan_directory() : file.inc
  • file_space_used() : file.inc
  • file_stream_wrapper_get_class() : file.inc
  • file_stream_wrapper_get_instance_by_scheme() : file.inc
  • file_stream_wrapper_get_instance_by_uri() : file.inc
  • file_stream_wrapper_uri_normalize() : file.inc
  • file_stream_wrapper_valid_scheme() : file.inc
  • file_theme() : file.module
  • file_transfer() : file.inc
  • file_unmanaged_copy() : file.inc
  • file_unmanaged_delete() : file.inc
  • file_unmanaged_delete_recursive() : file.inc
  • file_unmanaged_move() : file.inc
  • file_unmanaged_save_data() : file.inc
  • file_unmunge_filename() : file.inc
  • file_upload_max_size() : file.inc
  • file_uri_scheme() : file.inc
  • file_uri_target() : file.inc
  • file_usage_add() : file.inc
  • file_usage_delete() : file.inc
  • file_usage_list() : file.inc
  • file_valid_uri() : file.inc
  • file_validate() : file.inc
  • file_validate_extensions() : file.inc
  • file_validate_image_resolution() : file.inc
  • file_validate_is_image() : file.inc
  • file_validate_name_length() : file.inc
  • file_validate_size() : file.inc
  • filter_access() : filter.module
  • filter_admin_disable() : filter.admin.inc
  • filter_admin_disable_submit() : filter.admin.inc
  • filter_admin_format_form() : filter.admin.inc
  • filter_admin_format_form_submit() : filter.admin.inc
  • filter_admin_format_form_validate() : filter.admin.inc
  • filter_admin_format_page() : filter.admin.inc
  • filter_admin_format_title() : filter.module
  • filter_admin_overview() : filter.admin.inc
  • filter_admin_overview_submit() : filter.admin.inc
  • filter_default_format() : filter.module
  • filter_dom_load() : filter.module
  • filter_dom_serialize() : filter.module
  • filter_dom_serialize_escape_cdata_element() : filter.module
  • filter_element_info() : filter.module
  • filter_example_filter_info() : filter_example.module
  • filter_example_help() : filter_example.module
  • filter_example_menu() : filter_example.module
  • filter_fallback_format() : filter.module
  • filter_fallback_format_title() : filter.module
  • filter_filter_info() : filter.module
  • filter_form_access_denied() : filter.module
  • filter_format_allowcache() : filter.module
  • filter_format_disable() : filter.module
  • filter_format_exists() : filter.module
  • filter_format_load() : filter.module
  • filter_format_save() : filter.module
  • filter_formats() : filter.module
  • filter_formats_reset() : filter.module
  • filter_get_filters() : filter.module
  • filter_get_formats_by_role() : filter.module
  • filter_get_roles_by_format() : filter.module
  • filter_help() : filter.module
  • filter_install() : filter.install
  • filter_list_format() : filter.module
  • filter_menu() : filter.module
  • filter_modules_disabled() : filter.module
  • filter_modules_enabled() : filter.module
  • filter_permission() : filter.module
  • filter_permission_name() : filter.module
  • filter_process_format() : filter.module
  • filter_schema() : filter.install
  • filter_theme() : filter.module
  • filter_tips_long() : filter.pages.inc
  • filter_update_7000() : filter.install
  • filter_update_7001() : filter.install
  • filter_update_7003() : filter.install
  • filter_update_7005() : filter.install
  • filter_update_7008() : filter.install
  • filter_update_7009() : filter.install
  • filter_update_7010() : filter.install
  • filter_update_dependencies() : filter.install
  • filter_xss() : common.inc
  • filter_xss_admin() : common.inc
  • filter_xss_bad_protocol() : common.inc
  • fix_gpc_magic() : common.inc
  • flood_clear_event() : common.inc
  • flood_is_allowed() : common.inc
  • flood_register_event() : common.inc
  • form_builder() : form.inc
  • form_clear_error() : form.inc
  • form_error() : form.inc
  • form_example_element_demo_form() : form_example_elements.inc
  • form_example_element_demo_form_submit() : form_example_elements.inc
  • form_example_element_info() : form_example.module
  • form_example_help() : form_example.module
  • form_example_intro() : form_example.module
  • form_example_menu() : form_example.module
  • form_example_phonenumber_combined_process() : form_example_elements.inc
  • form_example_phonenumber_combined_validate() : form_example_elements.inc
  • form_example_phonenumber_combined_value() : form_example_elements.inc
  • form_example_phonenumber_discrete_process() : form_example_elements.inc
  • form_example_phonenumber_discrete_validate() : form_example_elements.inc
  • form_example_states_form() : form_example_states.inc
  • form_example_states_form_submit() : form_example_states.inc
  • form_example_theme() : form_example.module
  • form_example_tutorial() : form_example_tutorial.inc
  • form_example_tutorial_1() : form_example_tutorial.inc
  • form_example_tutorial_10() : form_example_tutorial.inc
  • form_example_tutorial_10_submit() : form_example_tutorial.inc
  • form_example_tutorial_10_validate() : form_example_tutorial.inc
  • form_example_tutorial_2() : form_example_tutorial.inc
  • form_example_tutorial_3() : form_example_tutorial.inc
  • form_example_tutorial_4() : form_example_tutorial.inc
  • form_example_tutorial_5() : form_example_tutorial.inc
  • form_example_tutorial_6() : form_example_tutorial.inc
  • form_example_tutorial_6_validate() : form_example_tutorial.inc
  • form_example_tutorial_7() : form_example_tutorial.inc
  • form_example_tutorial_7_submit() : form_example_tutorial.inc
  • form_example_tutorial_7_validate() : form_example_tutorial.inc
  • form_example_tutorial_8() : form_example_tutorial.inc
  • form_example_tutorial_8_next_submit() : form_example_tutorial.inc
  • form_example_tutorial_8_next_validate() : form_example_tutorial.inc
  • form_example_tutorial_8_page_two() : form_example_tutorial.inc
  • form_example_tutorial_8_page_two_back() : form_example_tutorial.inc
  • form_example_tutorial_8_page_two_submit() : form_example_tutorial.inc
  • form_example_tutorial_9() : form_example_tutorial.inc
  • form_example_tutorial_9_add_name() : form_example_tutorial.inc
  • form_example_tutorial_9_remove_name() : form_example_tutorial.inc
  • form_example_tutorial_9_submit() : form_example_tutorial.inc
  • form_example_tutorial_9_validate() : form_example_tutorial.inc
  • form_example_wizard() : form_example_wizard.inc
  • form_example_wizard_location_info() : form_example_wizard.inc
  • form_example_wizard_location_info_validate() : form_example_wizard.inc
  • form_example_wizard_next_submit() : form_example_wizard.inc
  • form_example_wizard_other_info() : form_example_wizard.inc
  • form_example_wizard_personal_info() : form_example_wizard.inc
  • form_example_wizard_previous_submit() : form_example_wizard.inc
  • form_example_wizard_submit() : form_example_wizard.inc
  • form_execute_handlers() : form.inc
  • form_get_cache() : form.inc
  • form_get_error() : form.inc
  • form_get_errors() : form.inc
  • form_get_options() : form.inc
  • form_load_include() : form.inc
  • form_options_flatten() : form.inc
  • form_pre_render_conditional_form_element() : form.inc
  • form_pre_render_fieldset() : form.inc
  • form_process_actions() : form.inc
  • form_process_checkbox() : form.inc
  • form_process_checkboxes() : form.inc
  • form_process_container() : form.inc
  • form_process_date() : form.inc
  • form_process_fieldset() : form.inc
  • form_process_machine_name() : form.inc
  • form_process_password_confirm() : form.inc
  • form_process_radios() : form.inc
  • form_process_select() : form.inc
  • form_process_tableselect() : form.inc
  • form_process_vertical_tabs() : form.inc
  • form_process_weight() : form.inc
  • form_select_options() : form.inc
  • form_set_cache() : form.inc
  • form_set_error() : form.inc
  • form_set_value() : form.inc
  • form_state_defaults() : form.inc
  • form_state_keys_no_cache() : form.inc
  • form_state_values_clean() : form.inc
  • form_type_checkbox_value() : form.inc
  • form_type_checkboxes_value() : form.inc
  • form_type_form_example_checkbox_value() : form_example_elements.inc
  • form_type_image_button_value() : form.inc
  • form_type_password_confirm_value() : form.inc
  • form_type_radios_value() : form.inc
  • form_type_select_value() : form.inc
  • form_type_tableselect_value() : form.inc
  • form_type_textfield_value() : form.inc
  • form_type_token_value() : form.inc
  • form_validate_machine_name() : form.inc
  • format_date() : common.inc
  • format_interval() : common.inc
  • format_plural() : common.inc
  • format_rss_channel() : common.inc
  • format_rss_item() : common.inc
  • format_size() : common.inc
  • format_string() : bootstrap.inc
  • format_username() : common.inc
  • format_xml_elements() : common.inc
  • forum_admin_settings() : forum.admin.inc
  • forum_block_configure() : forum.module
  • forum_block_info() : forum.module
  • forum_block_save() : forum.module
  • forum_block_view() : forum.module
  • forum_block_view_pre_render() : forum.module
  • forum_comment_delete() : forum.module
  • forum_comment_publish() : forum.module
  • forum_comment_unpublish() : forum.module
  • forum_comment_update() : forum.module
  • forum_confirm_delete() : forum.admin.inc
  • forum_confirm_delete_submit() : forum.admin.inc
  • forum_enable() : forum.install
  • forum_entity_info_alter() : forum.module
  • forum_field_storage_pre_insert() : forum.module
  • forum_field_storage_pre_update() : forum.module
  • forum_form() : forum.module
  • forum_form_container() : forum.admin.inc
  • forum_form_forum() : forum.admin.inc
  • forum_form_main() : forum.admin.inc
  • forum_form_node_form_alter() : forum.module
  • forum_form_submit() : forum.admin.inc
  • forum_form_taxonomy_form_term_alter() : forum.module
  • forum_form_taxonomy_form_vocabulary_alter() : forum.module
  • forum_forum_load() : forum.module
  • forum_get_topics() : forum.module
  • forum_help() : forum.module
  • forum_install() : forum.install
  • forum_menu() : forum.module
  • forum_menu_local_tasks_alter() : forum.module
  • forum_node_delete() : forum.module
  • forum_node_info() : forum.module
  • forum_node_insert() : forum.module
  • forum_node_load() : forum.module
  • forum_node_presave() : forum.module
  • forum_node_update() : forum.module
  • forum_node_validate() : forum.module
  • forum_node_view() : forum.module
  • forum_overview() : forum.admin.inc
  • forum_page() : forum.pages.inc
  • forum_permission() : forum.module
  • forum_rdf_mapping() : forum.module
  • forum_schema() : forum.install
  • forum_taxonomy_term_delete() : forum.module
  • forum_theme() : forum.module
  • forum_uninstall() : forum.install
  • forum_update_7000() : forum.install
  • forum_update_7001() : forum.install
  • forum_update_7002() : forum.install
  • forum_update_7003() : forum.install
  • forum_update_7011() : forum.install
  • forum_update_7012() : forum.install
  • forum_update_dependencies() : forum.install
  • forum_uri() : forum.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- g -

  • garland_breadcrumb() : template.php
  • garland_form_system_theme_settings_alter() : theme-settings.php
  • garland_preprocess_block() : template.php
  • garland_preprocess_comment() : template.php
  • garland_preprocess_html() : template.php
  • garland_preprocess_maintenance_page() : template.php
  • garland_preprocess_node() : template.php
  • garland_preprocess_page() : template.php
  • garland_preprocess_region() : template.php
  • garland_process_html() : template.php
  • garland_process_page() : template.php
  • get_t() : bootstrap.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- h -

  • help_help() : help.module
  • help_links_as_list() : help.admin.inc
  • help_main() : help.admin.inc
  • help_menu() : help.module
  • help_page() : help.admin.inc
  • hide() : common.inc
  • hook_action_info() : system.api.php
  • hook_action_info_alter() : system.api.php
  • hook_actions_delete() : system.api.php
  • hook_admin_paths() : system.api.php
  • hook_admin_paths_alter() : system.api.php
  • hook_aggregator_fetch() : aggregator.api.php
  • hook_aggregator_fetch_info() : aggregator.api.php
  • hook_aggregator_parse() : aggregator.api.php
  • hook_aggregator_parse_info() : aggregator.api.php
  • hook_aggregator_process() : aggregator.api.php
  • hook_aggregator_process_info() : aggregator.api.php
  • hook_aggregator_remove() : aggregator.api.php
  • hook_ajax_render_alter() : system.api.php
  • hook_archiver_info() : system.api.php
  • hook_archiver_info_alter() : system.api.php
  • hook_batch_alter() : system.api.php
  • hook_block_configure() : block.api.php
  • hook_block_info() : block.api.php
  • hook_block_info_alter() : block.api.php
  • hook_block_list_alter() : block.api.php
  • hook_block_save() : block.api.php
  • hook_block_view() : block.api.php
  • hook_block_view_alter() : block.api.php
  • hook_block_view_MODULE_DELTA_alter() : block.api.php
  • hook_boot() : system.api.php
  • hook_comment_delete() : comment.api.php
  • hook_comment_insert() : comment.api.php
  • hook_comment_load() : comment.api.php
  • hook_comment_presave() : comment.api.php
  • hook_comment_publish() : comment.api.php
  • hook_comment_unpublish() : comment.api.php
  • hook_comment_update() : comment.api.php
  • hook_comment_view() : comment.api.php
  • hook_comment_view_alter() : comment.api.php
  • hook_contextual_links_view_alter() : contextual.api.php
  • hook_countries_alter() : system.api.php
  • hook_cron() : system.api.php
  • hook_cron_queue_info() : system.api.php
  • hook_cron_queue_info_alter() : system.api.php
  • hook_css_alter() : system.api.php
  • hook_custom_theme() : system.api.php
  • hook_dashboard_regions() : dashboard.api.php
  • hook_dashboard_regions_alter() : dashboard.api.php
  • hook_date_format_types() : system.api.php
  • hook_date_format_types_alter() : system.api.php
  • hook_date_formats() : system.api.php
  • hook_date_formats_alter() : system.api.php
  • hook_delete() : node.api.php
  • hook_disable() : system.api.php
  • hook_drupal_goto_alter() : system.api.php
  • hook_element_info() : system.api.php
  • hook_element_info_alter() : system.api.php
  • hook_enable() : system.api.php
  • hook_entity_delete() : system.api.php
  • hook_entity_info() : system.api.php
  • hook_entity_info_alter() : system.api.php
  • hook_entity_insert() : system.api.php
  • hook_entity_load() : system.api.php
  • hook_entity_prepare_view() : system.api.php
  • hook_entity_presave() : system.api.php
  • hook_entity_query_alter() : system.api.php
  • hook_entity_update() : system.api.php
  • hook_entity_view() : system.api.php
  • hook_entity_view_alter() : system.api.php
  • hook_entity_view_mode_alter() : system.api.php
  • hook_exit() : system.api.php
  • hook_field_access() : field.api.php
  • hook_field_attach_create_bundle() : field.api.php
  • hook_field_attach_delete() : field.api.php
  • hook_field_attach_delete_bundle() : field.api.php
  • hook_field_attach_delete_revision() : field.api.php
  • hook_field_attach_form() : field.api.php
  • hook_field_attach_insert() : field.api.php
  • hook_field_attach_load() : field.api.php
  • hook_field_attach_prepare_translation_alter() : field.api.php
  • hook_field_attach_preprocess_alter() : field.api.php
  • hook_field_attach_presave() : field.api.php
  • hook_field_attach_purge() : field.api.php
  • hook_field_attach_rename_bundle() : field.api.php
  • hook_field_attach_submit() : field.api.php
  • hook_field_attach_update() : field.api.php
  • hook_field_attach_validate() : field.api.php
  • hook_field_attach_view_alter() : field.api.php
  • hook_field_available_languages_alter() : field.api.php
  • hook_field_create_field() : field.api.php
  • hook_field_create_instance() : field.api.php
  • hook_field_delete() : field.api.php
  • hook_field_delete_field() : field.api.php
  • hook_field_delete_instance() : field.api.php
  • hook_field_delete_revision() : field.api.php
  • hook_field_display_alter() : field.api.php
  • hook_field_display_ENTITY_TYPE_alter() : field.api.php
  • hook_field_extra_fields() : field.api.php
  • hook_field_extra_fields_alter() : field.api.php
  • hook_field_extra_fields_display_alter() : field.api.php
  • hook_field_formatter_info() : field.api.php
  • hook_field_formatter_info_alter() : field.api.php
  • hook_field_formatter_prepare_view() : field.api.php
  • hook_field_formatter_settings_form() : field_ui.api.php
  • hook_field_formatter_settings_summary() : field_ui.api.php
  • hook_field_formatter_view() : field.api.php
  • hook_field_info() : field.api.php
  • hook_field_info_alter() : field.api.php
  • hook_field_info_max_weight() : field.api.php
  • hook_field_insert() : field.api.php
  • hook_field_instance_settings_form() : field_ui.api.php
  • hook_field_is_empty() : field.api.php
  • hook_field_language_alter() : field.api.php
  • hook_field_load() : field.api.php
  • hook_field_prepare_translation() : field.api.php
  • hook_field_prepare_view() : field.api.php
  • hook_field_presave() : field.api.php
  • hook_field_purge_field() : field.api.php
  • hook_field_purge_instance() : field.api.php
  • hook_field_read_field() : field.api.php
  • hook_field_read_instance() : field.api.php
  • hook_field_schema() : field.api.php
  • hook_field_settings_form() : field_ui.api.php
  • hook_field_storage_create_field() : field.api.php
  • hook_field_storage_delete() : field.api.php
  • hook_field_storage_delete_field() : field.api.php
  • hook_field_storage_delete_instance() : field.api.php
  • hook_field_storage_delete_revision() : field.api.php
  • hook_field_storage_details() : field.api.php
  • hook_field_storage_details_alter() : field.api.php
  • hook_field_storage_info() : field.api.php
  • hook_field_storage_info_alter() : field.api.php
  • hook_field_storage_load() : field.api.php
  • hook_field_storage_pre_insert() : field.api.php
  • hook_field_storage_pre_load() : field.api.php
  • hook_field_storage_pre_update() : field.api.php
  • hook_field_storage_purge() : field.api.php
  • hook_field_storage_purge_field() : field.api.php
  • hook_field_storage_purge_field_instance() : field.api.php
  • hook_field_storage_query() : field.api.php
  • hook_field_storage_update_field() : field.api.php
  • hook_field_storage_write() : field.api.php
  • hook_field_update() : field.api.php
  • hook_field_update_field() : field.api.php
  • hook_field_update_forbid() : field.api.php
  • hook_field_update_instance() : field.api.php
  • hook_field_validate() : field.api.php
  • hook_field_widget_error() : field.api.php
  • hook_field_widget_form() : field.api.php
  • hook_field_widget_form_alter() : field.api.php
  • hook_field_widget_info() : field.api.php
  • hook_field_widget_info_alter() : field.api.php
  • hook_field_widget_properties_alter() : field.api.php
  • hook_field_widget_properties_ENTITY_TYPE_alter() : field.api.php
  • hook_field_widget_settings_form() : field_ui.api.php
  • hook_field_widget_WIDGET_TYPE_form_alter() : field.api.php
  • hook_file_copy() : system.api.php
  • hook_file_delete() : system.api.php
  • hook_file_download() : system.api.php
  • hook_file_download_access() : file.api.php
  • hook_file_download_access_alter() : file.api.php
  • hook_file_insert() : system.api.php
  • hook_file_load() : system.api.php
  • hook_file_mimetype_mapping_alter() : system.api.php
  • hook_file_move() : system.api.php
  • hook_file_presave() : system.api.php
  • hook_file_update() : system.api.php
  • hook_file_url_alter() : system.api.php
  • hook_file_validate() : system.api.php
  • hook_filetransfer_info() : system.api.php
  • hook_filetransfer_info_alter() : system.api.php
  • hook_filter_format_disable() : filter.api.php
  • hook_filter_format_insert() : filter.api.php
  • hook_filter_format_update() : filter.api.php
  • hook_filter_info() : filter.api.php
  • hook_filter_info_alter() : filter.api.php
  • hook_flush_caches() : system.api.php
  • hook_form() : node.api.php
  • hook_form_alter() : system.api.php
  • hook_form_BASE_FORM_ID_alter() : system.api.php
  • hook_form_FORM_ID_alter() : system.api.php
  • hook_form_system_theme_settings_alter() : theme.api.php
  • hook_forms() : system.api.php
  • hook_help() : help.api.php
  • hook_hook_info() : system.api.php
  • hook_hook_info_alter() : system.api.php
  • hook_html_head_alter() : system.api.php
  • hook_image_default_styles() : image.api.php
  • hook_image_effect_info() : image.api.php
  • hook_image_effect_info_alter() : image.api.php
  • hook_image_style_delete() : image.api.php
  • hook_image_style_flush() : image.api.php
  • hook_image_style_save() : image.api.php
  • hook_image_styles_alter() : image.api.php
  • hook_image_toolkits() : system.api.php
  • hook_init() : system.api.php
  • hook_insert() : node.api.php
  • hook_install() : system.api.php
  • hook_install_tasks() : system.api.php
  • hook_install_tasks_alter() : system.api.php
  • hook_js_alter() : system.api.php
  • hook_language_fallback_candidates_alter() : language.api.php
  • hook_language_init() : language.api.php
  • hook_language_negotiation_info() : language.api.php
  • hook_language_negotiation_info_alter() : language.api.php
  • hook_language_switch_links_alter() : language.api.php
  • hook_language_types_info() : language.api.php
  • hook_language_types_info_alter() : language.api.php
  • hook_library() : system.api.php
  • hook_library_alter() : system.api.php
  • hook_load() : node.api.php
  • hook_locale() : locale.api.php
  • hook_mail() : system.api.php
  • hook_mail_alter() : system.api.php
  • hook_menu() : system.api.php
  • hook_menu_alter() : system.api.php
  • hook_menu_breadcrumb_alter() : system.api.php
  • hook_menu_contextual_links_alter() : system.api.php
  • hook_menu_delete() : menu.api.php
  • hook_menu_get_item_alter() : system.api.php
  • hook_menu_insert() : menu.api.php
  • hook_menu_link_alter() : system.api.php
  • hook_menu_link_delete() : system.api.php
  • hook_menu_link_insert() : system.api.php
  • hook_menu_link_update() : system.api.php
  • hook_menu_local_tasks_alter() : system.api.php
  • hook_menu_site_status_alter() : system.api.php
  • hook_menu_update() : menu.api.php
  • hook_module_implements_alter() : system.api.php
  • hook_modules_disabled() : system.api.php
  • hook_modules_enabled() : system.api.php
  • hook_modules_installed() : system.api.php
  • hook_modules_uninstalled() : system.api.php
  • hook_multilingual_settings_changed() : locale.api.php
  • hook_node_access() : node.api.php
  • hook_node_access_records() : node.api.php
  • hook_node_access_records_alter() : node.api.php
  • hook_node_delete() : node.api.php
  • hook_node_grants() : node.api.php
  • hook_node_grants_alter() : node.api.php
  • hook_node_info() : node.api.php
  • hook_node_insert() : node.api.php
  • hook_node_load() : node.api.php
  • hook_node_operations() : node.api.php
  • hook_node_prepare() : node.api.php
  • hook_node_presave() : node.api.php
  • hook_node_revision_delete() : node.api.php
  • hook_node_search_result() : node.api.php
  • hook_node_submit() : node.api.php
  • hook_node_type_delete() : node.api.php
  • hook_node_type_insert() : node.api.php
  • hook_node_type_update() : node.api.php
  • hook_node_update() : node.api.php
  • hook_node_update_index() : node.api.php
  • hook_node_validate() : node.api.php
  • hook_node_view() : node.api.php
  • hook_node_view_alter() : node.api.php
  • hook_openid() : openid.api.php
  • hook_openid_discovery_method_info() : openid.api.php
  • hook_openid_discovery_method_info_alter() : openid.api.php
  • hook_openid_normalization_method_info() : openid.api.php
  • hook_openid_normalization_method_info_alter() : openid.api.php
  • hook_openid_response() : openid.api.php
  • hook_options_list() : options.api.php
  • hook_overlay_child_initialize() : overlay.api.php
  • hook_overlay_parent_initialize() : overlay.api.php
  • hook_page_alter() : system.api.php
  • hook_page_build() : system.api.php
  • hook_page_delivery_callback_alter() : system.api.php
  • hook_path_delete() : path.api.php
  • hook_path_insert() : path.api.php
  • hook_path_update() : path.api.php
  • hook_permission() : system.api.php
  • hook_prepare() : node.api.php
  • hook_preprocess() : theme.api.php
  • hook_preprocess_HOOK() : theme.api.php
  • hook_process() : theme.api.php
  • hook_process_HOOK() : theme.api.php
  • hook_query_alter() : system.api.php
  • hook_query_TAG_alter() : system.api.php
  • hook_ranking() : node.api.php
  • hook_rdf_mapping() : rdf.api.php
  • hook_rdf_namespaces() : rdf.api.php
  • hook_registry_files_alter() : system.api.php
  • hook_requirements() : system.api.php
  • hook_schema() : system.api.php
  • hook_schema_alter() : system.api.php
  • hook_search_access() : search.api.php
  • hook_search_admin() : search.api.php
  • hook_search_execute() : search.api.php
  • hook_search_info() : search.api.php
  • hook_search_page() : search.api.php
  • hook_search_preprocess() : search.api.php
  • hook_search_reset() : search.api.php
  • hook_search_status() : search.api.php
  • hook_shortcut_default_set() : shortcut.api.php
  • hook_simpletest_alter() : simpletest.api.php
  • hook_stream_wrappers() : system.api.php
  • hook_stream_wrappers_alter() : system.api.php
  • hook_system_info_alter() : system.api.php
  • hook_system_theme_info() : system.api.php
  • hook_system_themes_page_alter() : system.api.php
  • hook_taxonomy_term_delete() : taxonomy.api.php
  • hook_taxonomy_term_insert() : taxonomy.api.php
  • hook_taxonomy_term_load() : taxonomy.api.php
  • hook_taxonomy_term_presave() : taxonomy.api.php
  • hook_taxonomy_term_update() : taxonomy.api.php
  • hook_taxonomy_term_view() : taxonomy.api.php
  • hook_taxonomy_term_view_alter() : taxonomy.api.php
  • hook_taxonomy_vocabulary_delete() : taxonomy.api.php
  • hook_taxonomy_vocabulary_insert() : taxonomy.api.php
  • hook_taxonomy_vocabulary_load() : taxonomy.api.php
  • hook_taxonomy_vocabulary_presave() : taxonomy.api.php
  • hook_taxonomy_vocabulary_update() : taxonomy.api.php
  • hook_test_finished() : simpletest.api.php
  • hook_test_group_finished() : simpletest.api.php
  • hook_test_group_started() : simpletest.api.php
  • hook_theme() : system.api.php
  • hook_theme_registry_alter() : system.api.php
  • hook_themes_disabled() : theme.api.php
  • hook_themes_enabled() : theme.api.php
  • hook_token_info() : system.api.php
  • hook_token_info_alter() : system.api.php
  • hook_tokens() : system.api.php
  • hook_tokens_alter() : system.api.php
  • hook_translated_menu_link_alter() : system.api.php
  • hook_trigger_info() : trigger.api.php
  • hook_trigger_info_alter() : trigger.api.php
  • hook_uninstall() : system.api.php
  • hook_update() : node.api.php
  • hook_update_dependencies() : system.api.php
  • hook_update_index() : search.api.php
  • hook_update_last_removed() : system.api.php
  • hook_update_N() : system.api.php
  • hook_update_projects_alter() : update.api.php
  • hook_update_status_alter() : update.api.php
  • hook_updater_info() : system.api.php
  • hook_updater_info_alter() : system.api.php
  • hook_url_inbound_alter() : system.api.php
  • hook_url_outbound_alter() : system.api.php
  • hook_user_cancel() : user.api.php
  • hook_user_cancel_methods_alter() : user.api.php
  • hook_user_categories() : user.api.php
  • hook_user_delete() : user.api.php
  • hook_user_insert() : user.api.php
  • hook_user_load() : user.api.php
  • hook_user_login() : user.api.php
  • hook_user_logout() : user.api.php
  • hook_user_operations() : user.api.php
  • hook_user_presave() : user.api.php
  • hook_user_role_delete() : user.api.php
  • hook_user_role_insert() : user.api.php
  • hook_user_role_presave() : user.api.php
  • hook_user_role_update() : user.api.php
  • hook_user_update() : user.api.php
  • hook_user_view() : user.api.php
  • hook_user_view_alter() : user.api.php
  • hook_username_alter() : system.api.php
  • hook_validate() : node.api.php
  • hook_verify_update_archive() : update.api.php
  • hook_view() : node.api.php
  • hook_watchdog() : system.api.php
  • hook_xmlrpc() : system.api.php
  • hook_xmlrpc_alter() : system.api.php
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- i -

  • image_crop() : image.inc
  • image_crop_effect() : image.effects.inc
  • image_crop_form() : image.admin.inc
  • image_default_style_revert() : image.module
  • image_default_style_save() : image.module
  • image_desaturate() : image.inc
  • image_desaturate_effect() : image.effects.inc
  • image_dimensions_scale() : image.inc
  • image_effect_apply() : image.module
  • image_effect_color_validate() : image.admin.inc
  • image_effect_definition_load() : image.module
  • image_effect_definitions() : image.module
  • image_effect_delete() : image.module
  • image_effect_delete_form() : image.admin.inc
  • image_effect_delete_form_submit() : image.admin.inc
  • image_effect_form() : image.admin.inc
  • image_effect_form_submit() : image.admin.inc
  • image_effect_integer_validate() : image.admin.inc
  • image_effect_load() : image.module
  • image_effect_save() : image.module
  • image_effect_scale_validate() : image.admin.inc
  • image_effects() : image.module
  • image_example_colorize_effect() : image_example.module
  • image_example_colorize_form() : image_example.module
  • image_example_disable() : image_example.install
  • image_example_enable() : image_example.install
  • image_example_help() : image_example.module
  • image_example_image_default_styles() : image_example.module
  • image_example_image_effect_info() : image_example.module
  • image_example_image_style_delete() : image_example.module
  • image_example_image_style_save() : image_example.module
  • image_example_image_styles_alter() : image_example.module
  • image_example_install() : image_example.install
  • image_example_menu() : image_example.module
  • image_example_style_flush() : image_example.module
  • image_example_style_form() : image_example.pages.inc
  • image_example_style_form_submit() : image_example.pages.inc
  • image_example_style_form_validate() : image_example.pages.inc
  • image_example_theme() : image_example.module
  • image_example_uninstall() : image_example.install
  • image_field_delete() : image.field.inc
  • image_field_delete_field() : image.module
  • image_field_delete_instance() : image.module
  • image_field_delete_revision() : image.field.inc
  • image_field_formatter_info() : image.field.inc
  • image_field_formatter_settings_form() : image.field.inc
  • image_field_formatter_settings_summary() : image.field.inc
  • image_field_formatter_view() : image.field.inc
  • image_field_info() : image.field.inc
  • image_field_insert() : image.field.inc
  • image_field_instance_settings_form() : image.field.inc
  • image_field_is_empty() : image.field.inc
  • image_field_load() : image.field.inc
  • image_field_prepare_view() : image.field.inc
  • image_field_presave() : image.field.inc
  • image_field_schema() : image.install
  • image_field_settings_form() : image.field.inc
  • image_field_update() : image.field.inc
  • image_field_update_field() : image.module
  • image_field_update_instance() : image.module
  • image_field_widget_form() : image.field.inc
  • image_field_widget_info() : image.field.inc
  • image_field_widget_process() : image.field.inc
  • image_field_widget_settings_form() : image.field.inc
  • image_file_delete() : image.module
  • image_file_download() : image.module
  • image_file_move() : image.module
  • image_filter_keyword() : image.module
  • image_flush_caches() : image.module
  • image_form_system_file_system_settings_alter() : image.module
  • image_gd_check_settings() : image.gd.inc
  • image_gd_create_tmp() : image.gd.inc
  • image_gd_crop() : image.gd.inc
  • image_gd_desaturate() : image.gd.inc
  • image_gd_get_info() : image.gd.inc
  • image_gd_load() : image.gd.inc
  • image_gd_resize() : image.gd.inc
  • image_gd_rotate() : image.gd.inc
  • image_gd_save() : image.gd.inc
  • image_gd_settings() : image.gd.inc
  • image_gd_settings_validate() : image.gd.inc
  • image_get_available_toolkits() : image.inc
  • image_get_info() : image.inc
  • image_get_toolkit() : image.inc
  • image_help() : image.module
  • image_image_default_styles() : image.module
  • image_image_effect_info() : image.effects.inc
  • image_image_style_delete() : image.module
  • image_image_style_save() : image.module
  • image_install() : image.install
  • image_load() : image.inc
  • image_menu() : image.module
  • image_path_flush() : image.module
  • image_permission() : image.module
  • image_requirements() : image.install
  • image_resize() : image.inc
  • image_resize_dimensions() : image.effects.inc
  • image_resize_effect() : image.effects.inc
  • image_resize_form() : image.admin.inc
  • image_rotate() : image.inc
  • image_rotate_dimensions() : image.effects.inc
  • image_rotate_effect() : image.effects.inc
  • image_rotate_form() : image.admin.inc
  • image_save() : image.inc
  • image_scale() : image.inc
  • image_scale_and_crop() : image.inc
  • image_scale_and_crop_effect() : image.effects.inc
  • image_scale_dimensions() : image.effects.inc
  • image_scale_effect() : image.effects.inc
  • image_scale_form() : image.admin.inc
  • image_schema() : image.install
  • image_style_add_form() : image.admin.inc
  • image_style_add_form_submit() : image.admin.inc
  • image_style_create_derivative() : image.module
  • image_style_delete() : image.module
  • image_style_delete_form() : image.admin.inc
  • image_style_delete_form_submit() : image.admin.inc
  • image_style_deliver() : image.module
  • image_style_effects() : image.module
  • image_style_flush() : image.module
  • image_style_form() : image.admin.inc
  • image_style_form_add_submit() : image.admin.inc
  • image_style_form_add_validate() : image.admin.inc
  • image_style_form_override_submit() : image.admin.inc
  • image_style_form_submit() : image.admin.inc
  • image_style_list() : image.admin.inc
  • image_style_load() : image.module
  • image_style_name_validate() : image.admin.inc
  • image_style_options() : image.module
  • image_style_path() : image.module
  • image_style_path_token() : image.module
  • image_style_revert_form() : image.admin.inc
  • image_style_revert_form_submit() : image.admin.inc
  • image_style_save() : image.module
  • image_style_transform_dimensions() : image.module
  • image_style_url() : image.module
  • image_styles() : image.module
  • image_system_file_system_settings_submit() : image.module
  • image_theme() : image.module
  • image_toolkit_invoke() : image.inc
  • image_uninstall() : image.install
  • image_update_7000() : image.install
  • image_update_7001() : image.install
  • image_update_7002() : image.install
  • image_update_7003() : image.install
  • image_update_7004() : image.install
  • image_update_7005() : image.install
  • image_update_dependencies() : image.install
  • install_already_done_error() : install.core.inc
  • install_begin_request() : install.core.inc
  • install_bootstrap_full() : install.core.inc
  • install_check_requirements() : install.core.inc
  • install_configure_form() : install.core.inc
  • install_configure_form_submit() : install.core.inc
  • install_configure_form_validate() : install.core.inc
  • install_database_errors() : install.core.inc
  • install_display_output() : install.core.inc
  • install_drupal() : install.core.inc
  • install_find_locales() : install.core.inc
  • install_find_profiles() : install.core.inc
  • install_finished() : install.core.inc
  • install_full_redirect_url() : install.core.inc
  • install_goto() : install.inc
  • install_import_locales() : install.core.inc
  • install_import_locales_remaining() : install.core.inc
  • install_load_profile() : install.core.inc
  • install_no_profile_error() : install.core.inc
  • install_profile_info() : install.inc
  • install_profile_modules() : install.core.inc
  • install_redirect_url() : install.core.inc
  • install_run_task() : install.core.inc
  • install_run_tasks() : install.core.inc
  • install_select_locale() : install.core.inc
  • install_select_locale_form() : install.core.inc
  • install_select_profile() : install.core.inc
  • install_select_profile_form() : install.core.inc
  • install_settings_form() : install.core.inc
  • install_settings_form_submit() : install.core.inc
  • install_settings_form_validate() : install.core.inc
  • install_state_defaults() : install.core.inc
  • install_system_module() : install.core.inc
  • install_tasks() : install.core.inc
  • install_tasks_to_display() : install.core.inc
  • install_tasks_to_perform() : install.core.inc
  • install_verify_completed_task() : install.core.inc
  • install_verify_pdo() : install.core.inc
  • install_verify_requirements() : install.core.inc
  • install_verify_settings() : install.core.inc
  • int2vancode() : comment.module
  • ip_address() : bootstrap.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- j -

  • js_example_accordion() : js_example.module
  • js_example_js_weights() : js_example.module
  • js_example_menu() : js_example.module
  • js_example_theme() : js_example.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- l -

  • l() : common.inc
  • language_default() : bootstrap.inc
  • language_fallback_get_candidates() : language.inc
  • language_from_default() : language.inc
  • language_initialize() : language.inc
  • language_list() : bootstrap.inc
  • language_negotiation_get() : language.inc
  • language_negotiation_get_any() : language.inc
  • language_negotiation_get_switch_links() : language.inc
  • language_negotiation_info() : language.inc
  • language_negotiation_purge() : language.inc
  • language_negotiation_set() : language.inc
  • language_provider_invoke() : language.inc
  • language_provider_weight() : language.inc
  • language_types() : bootstrap.inc
  • language_types_configurable() : language.inc
  • language_types_disable() : language.inc
  • language_types_info() : language.inc
  • language_types_set() : language.inc
  • language_url_split_prefix() : language.inc
  • list_allowed_values() : list.module
  • list_allowed_values_setting_validate() : list.module
  • list_allowed_values_string() : list.module
  • list_boolean_allowed_values_callback() : list.module
  • list_extract_allowed_values() : list.module
  • list_field_formatter_info() : list.module
  • list_field_formatter_view() : list.module
  • list_field_info() : list.module
  • list_field_is_empty() : list.module
  • list_field_schema() : list.install
  • list_field_settings_form() : list.module
  • list_field_update_field() : list.module
  • list_field_update_forbid() : list.module
  • list_field_validate() : list.module
  • list_field_widget_info_alter() : list.module
  • list_help() : list.module
  • list_options_list() : list.module
  • list_themes() : theme.inc
  • list_update_7001() : list.install
  • list_update_7002() : list.install
  • locale() : locale.module
  • locale_add_language() : locale.inc
  • locale_batch_by_component() : locale.inc
  • locale_batch_by_language() : locale.inc
  • locale_block_info() : locale.module
  • locale_block_view() : locale.module
  • locale_css_alter() : locale.module
  • locale_date_format_form() : locale.admin.inc
  • locale_date_format_form_submit() : locale.admin.inc
  • locale_date_format_language_overview_page() : locale.admin.inc
  • locale_date_format_reset_form() : locale.admin.inc
  • locale_date_format_reset_form_submit() : locale.admin.inc
  • locale_date_format_save() : locale.inc
  • locale_entity_info_alter() : locale.module
  • locale_field_comment_form_submit() : locale.module
  • locale_field_entity_form_submit() : locale.module
  • locale_field_language_alter() : locale.module
  • locale_field_language_fallback() : locale.module
  • locale_field_node_form_submit() : locale.module
  • locale_form_alter() : locale.module
  • locale_form_comment_form_alter() : locale.module
  • locale_form_node_form_alter() : locale.module
  • locale_form_node_type_form_alter() : locale.module
  • locale_form_path_admin_form_alter() : locale.module
  • locale_get_localized_date_format() : locale.inc
  • locale_get_plural() : locale.module
  • locale_help() : locale.module
  • locale_init() : locale.module
  • locale_install() : locale.install
  • locale_js_alter() : locale.module
  • locale_language_from_browser() : locale.inc
  • locale_language_from_interface() : locale.inc
  • locale_language_from_session() : locale.inc
  • locale_language_from_url() : locale.inc
  • locale_language_from_user() : locale.inc
  • locale_language_list() : locale.module
  • locale_language_name() : locale.module
  • locale_language_negotiation_info() : locale.module
  • locale_language_providers_session_form() : locale.admin.inc
  • locale_language_providers_url_form() : locale.admin.inc
  • locale_language_selector_form() : locale.module
  • locale_language_switcher_session() : locale.inc
  • locale_language_switcher_url() : locale.inc
  • locale_language_types_info() : locale.module
  • locale_language_url_fallback() : locale.inc
  • locale_language_url_rewrite_session() : locale.inc
  • locale_language_url_rewrite_url() : locale.inc
  • locale_languages_add_screen() : locale.admin.inc
  • locale_languages_configure_form() : locale.admin.inc
  • locale_languages_configure_form_submit() : locale.admin.inc
  • locale_languages_custom_form() : locale.admin.inc
  • locale_languages_delete_form() : locale.admin.inc
  • locale_languages_delete_form_submit() : locale.admin.inc
  • locale_languages_edit_form() : locale.admin.inc
  • locale_languages_edit_form_submit() : locale.admin.inc
  • locale_languages_edit_form_validate() : locale.admin.inc
  • locale_languages_overview_form() : locale.admin.inc
  • locale_languages_overview_form_submit() : locale.admin.inc
  • locale_languages_predefined_form() : locale.admin.inc
  • locale_languages_predefined_form_submit() : locale.admin.inc
  • locale_languages_predefined_form_validate() : locale.admin.inc
  • locale_library_alter() : locale.module
  • locale_locale() : locale.module
  • locale_menu() : locale.module
  • locale_modules_disabled() : locale.module
  • locale_modules_enabled() : locale.module
  • locale_modules_installed() : locale.module
  • locale_multilingual_node_type() : locale.module
  • locale_permission() : locale.module
  • locale_reset() : locale.module
  • locale_schema() : locale.install
  • locale_string_is_safe() : locale.inc
  • locale_system_update() : locale.module
  • locale_theme() : locale.module
  • locale_themes_enabled() : locale.module
  • locale_translate_delete_form() : locale.admin.inc
  • locale_translate_delete_form_submit() : locale.admin.inc
  • locale_translate_delete_page() : locale.admin.inc
  • locale_translate_edit_form() : locale.admin.inc
  • locale_translate_edit_form_submit() : locale.admin.inc
  • locale_translate_edit_form_validate() : locale.admin.inc
  • locale_translate_export_po_form() : locale.admin.inc
  • locale_translate_export_po_form_submit() : locale.admin.inc
  • locale_translate_export_pot_form() : locale.admin.inc
  • locale_translate_export_screen() : locale.admin.inc
  • locale_translate_import_form() : locale.admin.inc
  • locale_translate_import_form_submit() : locale.admin.inc
  • locale_translate_overview_screen() : locale.admin.inc
  • locale_translate_seek_screen() : locale.admin.inc
  • locale_translation_filter_form() : locale.admin.inc
  • locale_translation_filter_form_submit() : locale.admin.inc
  • locale_translation_filter_form_validate() : locale.admin.inc
  • locale_translation_filters() : locale.admin.inc
  • locale_uninstall() : locale.install
  • locale_update_7000() : locale.install
  • locale_update_7001() : locale.install
  • locale_update_7002() : locale.install
  • locale_update_7003() : locale.install
  • locale_update_7004() : locale.install
  • locale_update_7005() : locale.install
  • locale_url_outbound_alter() : locale.module
  • lock_acquire() : lock.inc
  • lock_initialize() : lock.inc
  • lock_may_be_available() : lock.inc
  • lock_release() : lock.inc
  • lock_release_all() : lock.inc
  • lock_wait() : lock.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- m -

  • map_month() : form.inc
  • menu_block_info() : menu.module
  • menu_block_view() : menu.module
  • menu_block_view_alter() : menu.module
  • menu_build_tree() : menu.inc
  • menu_cache_clear() : menu.inc
  • menu_cache_clear_all() : menu.inc
  • menu_configure() : menu.admin.inc
  • menu_contextual_links() : menu.inc
  • menu_custom_delete_submit() : menu.admin.inc
  • menu_delete() : menu.module
  • menu_delete_links() : menu.inc
  • menu_delete_menu_confirm() : menu.admin.inc
  • menu_delete_menu_confirm_submit() : menu.admin.inc
  • menu_delete_menu_page() : menu.admin.inc
  • menu_edit_item() : menu.admin.inc
  • menu_edit_item_submit() : menu.admin.inc
  • menu_edit_item_validate() : menu.admin.inc
  • menu_edit_menu() : menu.admin.inc
  • menu_edit_menu_name_exists() : menu.admin.inc
  • menu_edit_menu_submit() : menu.admin.inc
  • menu_enable() : menu.module
  • menu_example_arg_optional_load() : menu_example.module
  • menu_example_arg_optional_to_arg() : menu_example.module
  • menu_example_custom_access() : menu_example.module
  • menu_example_id_load() : menu_example.module
  • menu_example_menu() : menu_example.module
  • menu_example_menu_alter() : menu_example.module
  • menu_example_menu_link_alter() : menu_example.module
  • menu_example_permission() : menu_example.module
  • menu_example_user_page_title() : menu_example.module
  • menu_execute_active_handler() : menu.inc
  • menu_form_node_form_alter() : menu.module
  • menu_form_node_type_form_alter() : menu.module
  • menu_get_active_breadcrumb() : menu.inc
  • menu_get_active_help() : menu.inc
  • menu_get_active_menu_names() : menu.inc
  • menu_get_active_title() : menu.inc
  • menu_get_active_trail() : menu.inc
  • menu_get_ancestors() : menu.inc
  • menu_get_custom_theme() : menu.inc
  • menu_get_item() : menu.inc
  • menu_get_menus() : menu.module
  • menu_get_names() : menu.inc
  • menu_get_object() : menu.inc
  • menu_get_router() : menu.inc
  • menu_help() : menu.module
  • menu_install() : menu.install
  • menu_item_delete_form() : menu.admin.inc
  • menu_item_delete_form_submit() : menu.admin.inc
  • menu_item_delete_page() : menu.admin.inc
  • menu_item_delete_submit() : menu.admin.inc
  • menu_link_children_relative_depth() : menu.inc
  • menu_link_delete() : menu.inc
  • menu_link_get_preferred() : menu.inc
  • menu_link_load() : menu.inc
  • menu_link_maintain() : menu.inc
  • menu_link_save() : menu.inc
  • menu_links_clone() : menu.inc
  • menu_list_system_menus() : menu.inc
  • menu_load() : menu.module
  • menu_load_all() : menu.module
  • menu_load_links() : menu.inc
  • menu_local_actions() : menu.inc
  • menu_local_tabs() : menu.inc
  • menu_local_tasks() : menu.inc
  • menu_main_menu() : menu.inc
  • menu_menu() : menu.module
  • menu_navigation_links() : menu.inc
  • menu_node_delete() : menu.module
  • menu_node_insert() : menu.module
  • menu_node_prepare() : menu.module
  • menu_node_save() : menu.module
  • menu_node_submit() : menu.module
  • menu_node_update() : menu.module
  • menu_overview_form() : menu.admin.inc
  • menu_overview_form_submit() : menu.admin.inc
  • menu_overview_page() : menu.admin.inc
  • menu_overview_title() : menu.module
  • menu_parent_options() : menu.module
  • menu_parent_options_js() : menu.module
  • menu_permission() : menu.module
  • menu_primary_local_tasks() : menu.inc
  • menu_rebuild() : menu.inc
  • menu_reset_item() : menu.module
  • menu_reset_item_confirm() : menu.admin.inc
  • menu_reset_item_confirm_submit() : menu.admin.inc
  • menu_reset_static_cache() : menu.inc
  • menu_router_build() : menu.inc
  • menu_save() : menu.module
  • menu_schema() : menu.install
  • menu_secondary_local_tasks() : menu.inc
  • menu_secondary_menu() : menu.inc
  • menu_set_active_item() : menu.inc
  • menu_set_active_menu_names() : menu.inc
  • menu_set_active_trail() : menu.inc
  • menu_set_custom_theme() : menu.inc
  • menu_set_item() : menu.inc
  • menu_tab_root_path() : menu.inc
  • menu_tail_load() : menu.inc
  • menu_tail_to_arg() : menu.inc
  • menu_theme() : menu.module
  • menu_tree() : menu.inc
  • menu_tree_all_data() : menu.inc
  • menu_tree_check_access() : menu.inc
  • menu_tree_collect_node_links() : menu.inc
  • menu_tree_data() : menu.inc
  • menu_tree_get_path() : menu.inc
  • menu_tree_output() : menu.inc
  • menu_tree_page_data() : menu.inc
  • menu_tree_set_path() : menu.inc
  • menu_uninstall() : menu.install
  • menu_unserialize() : menu.inc
  • menu_update_7000() : menu.install
  • menu_update_7001() : menu.install
  • menu_update_7002() : menu.install
  • menu_update_7003() : menu.install
  • mime_header_decode() : unicode.inc
  • mime_header_encode() : unicode.inc
  • minimal_form_install_configure_form_alter() : minimal.profile
  • minimal_install() : minimal.install
  • module_disable() : module.inc
  • module_enable() : module.inc
  • module_exists() : module.inc
  • module_hook() : module.inc
  • module_hook_info() : module.inc
  • module_implements() : module.inc
  • module_implements_write_cache() : module.inc
  • module_invoke() : module.inc
  • module_invoke_all() : module.inc
  • module_list() : module.inc
  • module_load_all() : module.inc
  • module_load_all_includes() : module.inc
  • module_load_include() : module.inc
  • module_load_install() : module.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- n -

  • node_access() : node.module
  • node_access_acquire_grants() : node.module
  • node_access_example_form_alter() : node_access_example.module
  • node_access_example_menu() : node_access_example.module
  • node_access_example_node_access() : node_access_example.module
  • node_access_example_node_access_records() : node_access_example.module
  • node_access_example_node_delete() : node_access_example.module
  • node_access_example_node_grants() : node_access_example.module
  • node_access_example_node_insert() : node_access_example.module
  • node_access_example_node_load() : node_access_example.module
  • node_access_example_node_update() : node_access_example.module
  • node_access_example_permission() : node_access_example.module
  • node_access_example_private_node_listing() : node_access_example.module
  • node_access_example_schema() : node_access_example.install
  • node_access_grants() : node.module
  • node_access_needs_rebuild() : node.module
  • node_access_rebuild() : node.module
  • node_access_view_all_nodes() : node.module
  • node_access_write_grants() : node.module
  • node_action_info() : node.module
  • node_add() : node.pages.inc
  • node_add_body_field() : node.module
  • node_add_page() : node.pages.inc
  • node_admin_content() : node.admin.inc
  • node_admin_nodes() : node.admin.inc
  • node_admin_nodes_submit() : node.admin.inc
  • node_admin_nodes_validate() : node.admin.inc
  • node_admin_paths() : node.module
  • node_assign_owner_action() : node.module
  • node_assign_owner_action_form() : node.module
  • node_assign_owner_action_submit() : node.module
  • node_assign_owner_action_validate() : node.module
  • node_block_configure() : node.module
  • node_block_info() : node.module
  • node_block_list_alter() : node.module
  • node_block_save() : node.module
  • node_block_view() : node.module
  • node_build_content() : node.module
  • node_build_filter_query() : node.admin.inc
  • node_configure_rebuild_confirm() : node.admin.inc
  • node_configure_rebuild_confirm_submit() : node.admin.inc
  • node_content_form() : node.module
  • node_cron() : node.module
  • node_delete() : node.module
  • node_delete_confirm() : node.pages.inc
  • node_delete_confirm_submit() : node.pages.inc
  • node_delete_multiple() : node.module
  • node_entity_info() : node.module
  • node_example_entity_info_alter() : node_example.module
  • node_example_field_formatter_info() : node_example.module
  • node_example_field_formatter_view() : node_example.module
  • node_example_form() : node_example.module
  • node_example_help() : node_example.module
  • node_example_menu() : node_example.module
  • node_example_node_info() : node_example.module
  • node_example_node_type_insert() : node_example.module
  • node_example_page() : node_example.module
  • node_example_theme() : node_example.module
  • node_feed() : node.module
  • node_field_display_node_alter() : node.module
  • node_field_extra_fields() : node.module
  • node_file_download_access() : node.module
  • node_filter_form() : node.admin.inc
  • node_filter_form_submit() : node.admin.inc
  • node_filters() : node.admin.inc
  • node_form() : node.pages.inc
  • node_form_block_add_block_form_alter() : node.module
  • node_form_block_admin_configure_alter() : node.module
  • node_form_block_admin_configure_submit() : node.module
  • node_form_block_custom_block_delete_alter() : node.module
  • node_form_block_custom_block_delete_submit() : node.module
  • node_form_build_preview() : node.pages.inc
  • node_form_delete_submit() : node.pages.inc
  • node_form_search_form_alter() : node.module
  • node_form_submit() : node.pages.inc
  • node_form_submit_build_node() : node.pages.inc
  • node_form_validate() : node.pages.inc
  • node_forms() : node.module
  • node_get_recent() : node.module
  • node_help() : node.module
  • node_hook() : node.module
  • node_install() : node.install
  • node_invoke() : node.module
  • node_is_page() : node.module
  • node_last_changed() : node.module
  • node_last_viewed() : node.module
  • node_list_permissions() : node.module
  • node_load() : node.module
  • node_load_multiple() : node.module
  • node_make_sticky_action() : node.module
  • node_make_unsticky_action() : node.module
  • node_mark() : node.module
  • node_mass_update() : node.admin.inc
  • node_menu() : node.module
  • node_menu_local_tasks_alter() : node.module
  • node_modules_enabled() : node.module
  • node_modules_uninstalled() : node.module
  • node_multiple_delete_confirm() : node.admin.inc
  • node_multiple_delete_confirm_submit() : node.admin.inc
  • node_node_access() : node.module
  • node_node_operations() : node.admin.inc
  • node_node_type_insert() : content_types.inc
  • node_node_type_update() : content_types.inc
  • node_object_prepare() : node.module
  • node_overview_types() : content_types.inc
  • node_page_default() : node.module
  • node_page_edit() : node.pages.inc
  • node_page_title() : node.module
  • node_page_view() : node.module
  • node_permission() : node.module
  • node_permissions_get_configured_types() : node.module
  • node_preview() : node.pages.inc
  • node_promote_action() : node.module
  • node_publish_action() : node.module
  • node_query_entity_field_access_alter() : node.module
  • node_query_node_access_alter() : node.module
  • node_ranking() : node.module
  • node_rdf_mapping() : node.module
  • node_requirements() : node.module
  • node_revision_delete() : node.module
  • node_revision_delete_confirm() : node.pages.inc
  • node_revision_delete_confirm_submit() : node.pages.inc
  • node_revision_list() : node.module
  • node_revision_overview() : node.pages.inc
  • node_revision_revert_confirm() : node.pages.inc
  • node_revision_revert_confirm_submit() : node.pages.inc
  • node_save() : node.module
  • node_save_action() : node.module
  • node_schema() : node.install
  • node_search_access() : node.module
  • node_search_admin() : node.module
  • node_search_execute() : node.module
  • node_search_info() : node.module
  • node_search_reset() : node.module
  • node_search_status() : node.module
  • node_search_validate() : node.module
  • node_show() : node.module
  • node_submit() : node.module
  • node_tag_new() : node.module
  • node_theme() : node.module
  • node_title_list() : node.module
  • node_token_info() : node.tokens.inc
  • node_tokens() : node.tokens.inc
  • node_type_cache_reset() : node.module
  • node_type_delete() : node.module
  • node_type_delete_confirm() : content_types.inc
  • node_type_delete_confirm_submit() : content_types.inc
  • node_type_form() : content_types.inc
  • node_type_form_submit() : content_types.inc
  • node_type_form_validate() : content_types.inc
  • node_type_get_base() : node.module
  • node_type_get_name() : node.module
  • node_type_get_names() : node.module
  • node_type_get_type() : node.module
  • node_type_get_types() : node.module
  • node_type_load() : node.module
  • node_type_page_title() : node.module
  • node_type_reset() : content_types.inc
  • node_type_save() : node.module
  • node_type_set_defaults() : node.module
  • node_type_update_nodes() : node.module
  • node_types_rebuild() : node.module
  • node_unpromote_action() : node.module
  • node_unpublish_action() : node.module
  • node_unpublish_by_keyword_action() : node.module
  • node_unpublish_by_keyword_action_form() : node.module
  • node_unpublish_by_keyword_action_submit() : node.module
  • node_update_7000() : node.install
  • node_update_7001() : node.install
  • node_update_7002() : node.install
  • node_update_7003() : node.install
  • node_update_7004() : node.install
  • node_update_7005() : node.install
  • node_update_7006() : node.install
  • node_update_7007() : node.install
  • node_update_7008() : node.install
  • node_update_7009() : node.install
  • node_update_7010() : node.install
  • node_update_7011() : node.install
  • node_update_7012() : node.install
  • node_update_7013() : node.install
  • node_update_7014() : node.install
  • node_update_dependencies() : node.install
  • node_update_index() : node.module
  • node_uri() : node.module
  • node_user_cancel() : node.module
  • node_user_delete() : node.module
  • node_validate() : node.module
  • node_view() : node.module
  • node_view_multiple() : node.module
  • nodeapi_example_form_alter() : nodeapi_example.module
  • nodeapi_example_node_delete() : nodeapi_example.module
  • nodeapi_example_node_insert() : nodeapi_example.module
  • nodeapi_example_node_load() : nodeapi_example.module
  • nodeapi_example_node_update() : nodeapi_example.module
  • nodeapi_example_node_validate() : nodeapi_example.module
  • nodeapi_example_node_view() : nodeapi_example.module
  • nodeapi_example_schema() : nodeapi_example.install
  • nodeapi_example_theme() : nodeapi_example.module
  • nodeapi_example_uninstall() : nodeapi_example.install
  • number_field_formatter_info() : number.module
  • number_field_formatter_settings_form() : number.module
  • number_field_formatter_settings_summary() : number.module
  • number_field_formatter_view() : number.module
  • number_field_info() : number.module
  • number_field_instance_settings_form() : number.module
  • number_field_is_empty() : number.module
  • number_field_presave() : number.module
  • number_field_schema() : number.install
  • number_field_settings_form() : number.module
  • number_field_validate() : number.module
  • number_field_widget_error() : number.module
  • number_field_widget_form() : number.module
  • number_field_widget_info() : number.module
  • number_field_widget_validate() : number.module
  • number_help() : number.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- o -

  • openid_admin_paths() : openid.module
  • openid_association() : openid.module
  • openid_association_request() : openid.module
  • openid_authentication() : openid.module
  • openid_authentication_page() : openid.pages.inc
  • openid_authentication_request() : openid.module
  • openid_begin() : openid.module
  • openid_complete() : openid.module
  • openid_cron() : openid.module
  • openid_discovery() : openid.module
  • openid_extract_ax_values() : openid.inc
  • openid_extract_namespace() : openid.inc
  • openid_form_user_login_alter() : openid.module
  • openid_form_user_login_block_alter() : openid.module
  • openid_form_user_register_form_alter() : openid.module
  • openid_help() : openid.module
  • openid_login_validate() : openid.module
  • openid_menu() : openid.module
  • openid_menu_site_status_alter() : openid.module
  • openid_normalize() : openid.inc
  • openid_openid_discovery_method_info() : openid.module
  • openid_openid_normalization_method_info() : openid.module
  • openid_redirect() : openid.inc
  • openid_redirect_form() : openid.inc
  • openid_redirect_http() : openid.inc
  • openid_requirements() : openid.install
  • openid_schema() : openid.install
  • openid_update_6000() : openid.install
  • openid_update_7000() : openid.install
  • openid_user_add() : openid.pages.inc
  • openid_user_add_submit() : openid.pages.inc
  • openid_user_add_validate() : openid.pages.inc
  • openid_user_delete_form() : openid.pages.inc
  • openid_user_delete_form_submit() : openid.pages.inc
  • openid_user_identities() : openid.pages.inc
  • openid_user_insert() : openid.module
  • openid_user_login() : openid.module
  • openid_user_logout() : openid.module
  • openid_verify_assertion() : openid.module
  • openid_verify_assertion_nonce() : openid.module
  • openid_verify_assertion_return_url() : openid.module
  • openid_verify_assertion_signature() : openid.module
  • options_array_flatten() : options.module
  • options_array_transpose() : options.module
  • options_field_widget_error() : options.module
  • options_field_widget_form() : options.module
  • options_field_widget_info() : options.module
  • options_field_widget_settings_form() : options.module
  • options_field_widget_validate() : options.module
  • options_help() : options.module
  • options_theme() : options.module
  • overlay_admin_paths() : overlay.module
  • overlay_ajax_render_region() : overlay.module
  • overlay_batch_alter() : overlay.module
  • overlay_block_list_alter() : overlay.module
  • overlay_close_dialog() : overlay.module
  • overlay_deliver_empty_page() : overlay.module
  • overlay_disable_message() : overlay.module
  • overlay_display_empty_page() : overlay.module
  • overlay_drupal_goto_alter() : overlay.module
  • overlay_enable() : overlay.install
  • overlay_exit() : overlay.module
  • overlay_form_user_profile_form_alter() : overlay.module
  • overlay_get_mode() : overlay.module
  • overlay_get_regions_to_render() : overlay.module
  • overlay_get_rendered_content() : overlay.module
  • overlay_help() : overlay.module
  • overlay_init() : overlay.module
  • overlay_library() : overlay.module
  • overlay_menu() : overlay.module
  • overlay_overlay_child_initialize() : overlay.module
  • overlay_overlay_parent_initialize() : overlay.module
  • overlay_page_alter() : overlay.module
  • overlay_page_delivery_callback_alter() : overlay.module
  • overlay_permission() : overlay.module
  • overlay_preprocess_html() : overlay.module
  • overlay_preprocess_maintenance_page() : overlay.module
  • overlay_preprocess_page() : overlay.module
  • overlay_regions() : overlay.module
  • overlay_render_region() : overlay.module
  • overlay_request_page_refresh() : overlay.module
  • overlay_request_refresh() : overlay.module
  • overlay_set_mode() : overlay.module
  • overlay_set_regions_to_render() : overlay.module
  • overlay_store_rendered_content() : overlay.module
  • overlay_supplemental_regions() : overlay.module
  • overlay_system_info_alter() : overlay.module
  • overlay_theme() : overlay.module
  • overlay_trigger_refresh() : overlay.module
  • overlay_user_dismiss_message() : overlay.module
  • overlay_user_presave() : overlay.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- p -

  • page_example_arguments() : page_example.module
  • page_example_description() : page_example.module
  • page_example_help() : page_example.module
  • page_example_menu() : page_example.module
  • page_example_permission() : page_example.module
  • page_example_simple() : page_example.module
  • pager_default_initialize() : pager.inc
  • pager_example_help() : pager_example.module
  • pager_example_menu() : pager_example.module
  • pager_example_page() : pager_example.module
  • pager_find_page() : pager.inc
  • pager_get_query_parameters() : pager.inc
  • pager_load_array() : pager.inc
  • parse_size() : common.inc
  • password_confirm_validate() : form.inc
  • path_admin_delete_confirm() : path.admin.inc
  • path_admin_delete_confirm_submit() : path.admin.inc
  • path_admin_edit() : path.admin.inc
  • path_admin_filter_form() : path.admin.inc
  • path_admin_filter_form_submit_filter() : path.admin.inc
  • path_admin_filter_form_submit_reset() : path.admin.inc
  • path_admin_form() : path.admin.inc
  • path_admin_form_delete_submit() : path.admin.inc
  • path_admin_form_submit() : path.admin.inc
  • path_admin_form_validate() : path.admin.inc
  • path_admin_overview() : path.admin.inc
  • path_delete() : path.inc
  • path_form_element_validate() : path.module
  • path_form_node_form_alter() : path.module
  • path_form_taxonomy_form_term_alter() : path.module
  • path_get_admin_paths() : path.inc
  • path_help() : path.module
  • path_is_admin() : path.inc
  • path_load() : path.inc
  • path_menu() : path.module
  • path_node_delete() : path.module
  • path_node_insert() : path.module
  • path_node_update() : path.module
  • path_permission() : path.module
  • path_save() : path.inc
  • path_taxonomy_term_delete() : path.module
  • path_taxonomy_term_insert() : path.module
  • path_taxonomy_term_update() : path.module
  • path_to_theme() : theme.inc
  • php_disable() : php.install
  • php_enable() : php.install
  • php_eval() : php.module
  • php_filter_info() : php.module
  • php_help() : php.module
  • php_permission() : php.module
  • phptemplate_init() : phptemplate.engine
  • phptemplate_theme() : phptemplate.engine
  • poll_block_info() : poll.module
  • poll_block_latest_poll_view() : poll.module
  • poll_block_view() : poll.module
  • poll_cancel() : poll.module
  • poll_cancel_form() : poll.module
  • poll_choice_js() : poll.module
  • poll_cron() : poll.module
  • poll_delete() : poll.module
  • poll_field_attach_prepare_translation_alter() : poll.module
  • poll_field_extra_fields() : poll.module
  • poll_form() : poll.module
  • poll_help() : poll.module
  • poll_insert() : poll.module
  • poll_load() : poll.module
  • poll_menu() : poll.module
  • poll_more_choices_submit() : poll.module
  • poll_node_form_submit() : poll.module
  • poll_node_info() : poll.module
  • poll_page() : poll.pages.inc
  • poll_permission() : poll.module
  • poll_rdf_mapping() : poll.module
  • poll_results() : poll.pages.inc
  • poll_schema() : poll.install
  • poll_teaser() : poll.module
  • poll_theme() : poll.module
  • poll_token_info() : poll.tokens.inc
  • poll_tokens() : poll.tokens.inc
  • poll_update() : poll.module
  • poll_update_7001() : poll.install
  • poll_update_7002() : poll.install
  • poll_update_7003() : poll.install
  • poll_update_7004() : poll.install
  • poll_user_cancel() : poll.module
  • poll_user_delete() : poll.module
  • poll_validate() : poll.module
  • poll_view() : poll.module
  • poll_view_results() : poll.module
  • poll_view_voting() : poll.module
  • poll_view_voting_validate() : poll.module
  • poll_vote() : poll.module
  • poll_votes() : poll.pages.inc
  • profile_admin_overview() : profile.admin.inc
  • profile_admin_overview_submit() : profile.admin.inc
  • profile_admin_settings_autocomplete() : profile.admin.inc
  • profile_autocomplete() : profile.pages.inc
  • profile_block_configure() : profile.module
  • profile_block_info() : profile.module
  • profile_block_save() : profile.module
  • profile_block_view() : profile.module
  • profile_browse() : profile.pages.inc
  • profile_category_access() : profile.module
  • profile_field_delete() : profile.admin.inc
  • profile_field_delete_submit() : profile.admin.inc
  • profile_field_form() : profile.admin.inc
  • profile_field_form_submit() : profile.admin.inc
  • profile_field_form_validate() : profile.admin.inc
  • profile_form_alter() : profile.module
  • profile_help() : profile.module
  • profile_menu() : profile.module
  • profile_save_profile() : profile.module
  • profile_schema() : profile.install
  • profile_theme() : profile.module
  • profile_uninstall() : profile.install
  • profile_update_7001() : profile.install
  • profile_update_7002() : profile.install
  • profile_user_cancel() : profile.module
  • profile_user_categories() : profile.module
  • profile_user_delete() : profile.module
  • profile_user_form_validate() : profile.module
  • profile_user_insert() : profile.module
  • profile_user_load() : profile.module
  • profile_user_presave() : profile.module
  • profile_user_view() : profile.module
  • profile_view_field() : profile.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- q -

  • queue_example_add_remove_form() : queue_example.module
  • queue_example_add_remove_form_claim() : queue_example.module
  • queue_example_add_remove_form_clear_queue() : queue_example.module
  • queue_example_add_remove_form_delete() : queue_example.module
  • queue_example_add_remove_form_insert() : queue_example.module
  • queue_example_add_remove_form_run_cron() : queue_example.module
  • queue_example_menu() : queue_example.module
  • queue_example_retrieve_queue() : queue_example.module
  • queue_example_show_queue() : queue_example.module
  • queue_example_theme() : queue_example.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- r -

  • rdf_comment_load() : rdf.module
  • rdf_entity_info_alter() : rdf.module
  • rdf_entity_load() : rdf.module
  • rdf_example_help() : rdf_example.module
  • rdf_example_install() : rdf_example.install
  • rdf_example_rdf_mapping() : rdf_example.module
  • rdf_example_rdf_namespaces() : rdf_example.module
  • rdf_example_uninstall() : rdf_example.install
  • rdf_field_attach_view_alter() : rdf.module
  • rdf_get_namespaces() : rdf.module
  • rdf_help() : rdf.module
  • rdf_install() : rdf.install
  • rdf_mapping_delete() : rdf.module
  • rdf_mapping_load() : rdf.module
  • rdf_mapping_save() : rdf.module
  • rdf_modules_installed() : rdf.module
  • rdf_modules_uninstalled() : rdf.module
  • rdf_preprocess_comment() : rdf.module
  • rdf_preprocess_field() : rdf.module
  • rdf_preprocess_image() : rdf.module
  • rdf_preprocess_node() : rdf.module
  • rdf_preprocess_taxonomy_term() : rdf.module
  • rdf_preprocess_user_profile() : rdf.module
  • rdf_preprocess_username() : rdf.module
  • rdf_process() : rdf.module
  • rdf_rdf_namespaces() : rdf.module
  • rdf_rdfa_attributes() : rdf.module
  • rdf_schema() : rdf.install
  • rdf_theme() : rdf.module
  • registry_get_parsed_files() : registry.inc
  • registry_rebuild() : bootstrap.inc
  • registry_update() : bootstrap.inc
  • render() : common.inc
  • render_example_add_hr() : render_example.module
  • render_example_add_prefix() : render_example.module
  • render_example_add_suffix() : render_example.module
  • render_example_arrays() : render_example.module
  • render_example_cache_expensive() : render_example.module
  • render_example_cache_pre_render() : render_example.module
  • render_example_change_to_ol() : render_example.module
  • render_example_demo_form() : render_example.module
  • render_example_embedded_form() : render_example.module
  • render_example_info() : render_example.module
  • render_example_menu() : render_example.module
  • render_example_page_alter() : render_example.module
  • render_example_theme() : render_example.module
  • render_example_uninstall() : render_example.install
  • request_path() : bootstrap.inc
  • request_uri() : bootstrap.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- s -

  • search_admin_reindex_submit() : search.admin.inc
  • search_admin_settings() : search.admin.inc
  • search_admin_settings_submit() : search.admin.inc
  • search_admin_settings_validate() : search.admin.inc
  • search_block_info() : search.module
  • search_block_view() : search.module
  • search_box() : search.module
  • search_box_form_submit() : search.module
  • search_comment_delete() : search.module
  • search_comment_insert() : search.module
  • search_comment_publish() : search.module
  • search_comment_unpublish() : search.module
  • search_comment_update() : search.module
  • search_cron() : search.module
  • search_data() : search.module
  • search_dirty() : search.module
  • search_excerpt() : search.module
  • search_expand_cjk() : search.module
  • search_expression_extract() : search.module
  • search_expression_insert() : search.module
  • search_form() : search.module
  • search_form_submit() : search.pages.inc
  • search_form_validate() : search.pages.inc
  • search_forms() : search.module
  • search_get_default_module_info() : search.module
  • search_get_info() : search.module
  • search_help() : search.module
  • search_index() : search.module
  • search_index_split() : search.module
  • search_invoke_preprocess() : search.module
  • search_is_active() : search.module
  • search_menu() : search.module
  • search_node_update() : search.module
  • search_node_update_index() : search.module
  • search_permission() : search.module
  • search_reindex() : search.module
  • search_reindex_confirm() : search.admin.inc
  • search_reindex_confirm_submit() : search.admin.inc
  • search_schema() : search.install
  • search_simplify() : search.module
  • search_simplify_excerpt_match() : search.module
  • search_theme() : search.module
  • search_touch_node() : search.module
  • search_uninstall() : search.install
  • search_update_7000() : search.install
  • search_update_totals() : search.module
  • search_view() : search.pages.inc
  • seven_admin_block_content() : template.php
  • seven_css_alter() : template.php
  • seven_node_add_list() : template.php
  • seven_preprocess_html() : template.php
  • seven_preprocess_maintenance_page() : template.php
  • seven_preprocess_page() : template.php
  • seven_tablesort_indicator() : template.php
  • shortcut_admin_add_link() : shortcut.admin.inc
  • shortcut_admin_paths() : shortcut.module
  • shortcut_block_info() : shortcut.module
  • shortcut_block_view() : shortcut.module
  • shortcut_current_displayed_set() : shortcut.module
  • shortcut_default_set() : shortcut.module
  • shortcut_help() : shortcut.module
  • shortcut_install() : shortcut.install
  • shortcut_link_access() : shortcut.module
  • shortcut_link_add() : shortcut.admin.inc
  • shortcut_link_add_inline() : shortcut.admin.inc
  • shortcut_link_add_submit() : shortcut.admin.inc
  • shortcut_link_delete() : shortcut.admin.inc
  • shortcut_link_delete_submit() : shortcut.admin.inc
  • shortcut_link_edit() : shortcut.admin.inc
  • shortcut_link_edit_submit() : shortcut.admin.inc
  • shortcut_link_edit_validate() : shortcut.admin.inc
  • shortcut_max_slots() : shortcut.admin.inc
  • shortcut_menu() : shortcut.module
  • shortcut_page_alter() : shortcut.module
  • shortcut_permission() : shortcut.module
  • shortcut_preprocess_page() : shortcut.module
  • shortcut_renderable_links() : shortcut.module
  • shortcut_schema() : shortcut.install
  • shortcut_set_add_form() : shortcut.admin.inc
  • shortcut_set_add_form_submit() : shortcut.admin.inc
  • shortcut_set_add_form_validate() : shortcut.admin.inc
  • shortcut_set_admin() : shortcut.admin.inc
  • shortcut_set_assign_user() : shortcut.module
  • shortcut_set_customize() : shortcut.admin.inc
  • shortcut_set_customize_submit() : shortcut.admin.inc
  • shortcut_set_delete() : shortcut.module
  • shortcut_set_delete_access() : shortcut.module
  • shortcut_set_delete_form() : shortcut.admin.inc
  • shortcut_set_delete_form_submit() : shortcut.admin.inc
  • shortcut_set_edit_access() : shortcut.module
  • shortcut_set_edit_form() : shortcut.admin.inc
  • shortcut_set_edit_form_submit() : shortcut.admin.inc
  • shortcut_set_edit_form_validate() : shortcut.admin.inc
  • shortcut_set_get_unique_name() : shortcut.module
  • shortcut_set_load() : shortcut.module
  • shortcut_set_name() : shortcut.module
  • shortcut_set_reset_link_weights() : shortcut.module
  • shortcut_set_save() : shortcut.module
  • shortcut_set_switch() : shortcut.admin.inc
  • shortcut_set_switch_access() : shortcut.module
  • shortcut_set_switch_submit() : shortcut.admin.inc
  • shortcut_set_switch_validate() : shortcut.admin.inc
  • shortcut_set_title() : shortcut.module
  • shortcut_set_title_callback() : shortcut.module
  • shortcut_set_title_exists() : shortcut.module
  • shortcut_set_unassign_user() : shortcut.module
  • shortcut_sets() : shortcut.module
  • shortcut_theme() : shortcut.module
  • shortcut_toolbar_pre_render() : shortcut.module
  • shortcut_uninstall() : shortcut.install
  • shortcut_valid_link() : shortcut.module
  • show() : common.inc
  • simpletest_classloader_register() : simpletest.module
  • simpletest_clean_database() : simpletest.module
  • simpletest_clean_environment() : simpletest.module
  • simpletest_clean_results_table() : simpletest.module
  • simpletest_clean_temporary_directories() : simpletest.module
  • simpletest_example_empty_mysql_date() : simpletest_example.module
  • simpletest_example_form() : simpletest_example.module
  • simpletest_example_install() : simpletest_example.install
  • simpletest_example_menu() : simpletest_example.module
  • simpletest_example_node_access() : simpletest_example.module
  • simpletest_example_node_info() : simpletest_example.module
  • simpletest_example_permission() : simpletest_example.module
  • simpletest_example_update_7001() : simpletest_example.install
  • simpletest_generate_file() : simpletest.module
  • simpletest_help() : simpletest.module
  • simpletest_js_alter() : simpletest.module
  • simpletest_last_test_get() : simpletest.module
  • simpletest_log_read() : simpletest.module
  • simpletest_mail_alter() : simpletest.module
  • simpletest_menu() : simpletest.module
  • simpletest_permission() : simpletest.module
  • simpletest_registry_files_alter() : simpletest.module
  • simpletest_requirements() : simpletest.install
  • simpletest_result_form() : simpletest.pages.inc
  • simpletest_result_form_submit() : simpletest.pages.inc
  • simpletest_result_get() : simpletest.pages.inc
  • simpletest_result_status_image() : simpletest.pages.inc
  • simpletest_run_tests() : simpletest.module
  • simpletest_schema() : simpletest.install
  • simpletest_settings_form() : simpletest.pages.inc
  • simpletest_settings_form_validate() : simpletest.pages.inc
  • simpletest_test_form() : simpletest.pages.inc
  • simpletest_test_form_submit() : simpletest.pages.inc
  • simpletest_test_get_all() : simpletest.module
  • simpletest_theme() : simpletest.module
  • simpletest_uninstall() : simpletest.install
  • simpletest_verbose() : drupal_web_test_case.php
  • st() : install.inc
  • standard_form_install_configure_form_alter() : standard.profile
  • standard_install() : standard.install
  • statistics_access_log() : statistics.admin.inc
  • statistics_block_configure() : statistics.module
  • statistics_block_info() : statistics.module
  • statistics_block_save() : statistics.module
  • statistics_block_view() : statistics.module
  • statistics_cron() : statistics.module
  • statistics_exit() : statistics.module
  • statistics_get() : statistics.module
  • statistics_help() : statistics.module
  • statistics_menu() : statistics.module
  • statistics_node_delete() : statistics.module
  • statistics_node_tracker() : statistics.pages.inc
  • statistics_node_view() : statistics.module
  • statistics_permission() : statistics.module
  • statistics_ranking() : statistics.module
  • statistics_recent_hits() : statistics.admin.inc
  • statistics_schema() : statistics.install
  • statistics_settings_form() : statistics.admin.inc
  • statistics_title_list() : statistics.module
  • statistics_token_info() : statistics.tokens.inc
  • statistics_tokens() : statistics.tokens.inc
  • statistics_top_pages() : statistics.admin.inc
  • statistics_top_referrers() : statistics.admin.inc
  • statistics_top_visitors() : statistics.admin.inc
  • statistics_uninstall() : statistics.install
  • statistics_update_7000() : statistics.install
  • statistics_update_index() : statistics.module
  • statistics_user_cancel() : statistics.module
  • statistics_user_delete() : statistics.module
  • statistics_user_tracker() : statistics.pages.inc
  • syslog_facility_list() : syslog.module
  • syslog_form_system_logging_settings_alter() : syslog.module
  • syslog_help() : syslog.module
  • syslog_uninstall() : syslog.install
  • syslog_watchdog() : syslog.module
  • system_action_delete_orphans_post() : system.admin.inc
  • system_action_info() : system.module
  • system_actions_configure() : system.admin.inc
  • system_actions_configure_submit() : system.admin.inc
  • system_actions_configure_validate() : system.admin.inc
  • system_actions_delete_form() : system.admin.inc
  • system_actions_delete_form_submit() : system.admin.inc
  • system_actions_manage() : system.admin.inc
  • system_actions_manage_form() : system.admin.inc
  • system_actions_manage_form_submit() : system.admin.inc
  • system_actions_remove_orphans() : system.admin.inc
  • system_add_date_format_type_form() : system.admin.inc
  • system_add_date_format_type_form_submit() : system.admin.inc
  • system_add_date_format_type_form_validate() : system.admin.inc
  • system_add_date_formats_form_submit() : system.admin.inc
  • system_add_date_formats_form_validate() : system.admin.inc
  • system_add_module_assets() : system.module
  • system_admin_compact_mode() : system.module
  • system_admin_compact_page() : system.module
  • system_admin_config_page() : system.admin.inc
  • system_admin_index() : system.admin.inc
  • system_admin_menu_block() : system.module
  • system_admin_menu_block_page() : system.admin.inc
  • system_admin_paths() : system.module
  • system_archiver_info() : system.module
  • system_authorized_batch_process() : system.module
  • system_authorized_batch_processing_url() : system.module
  • system_authorized_get_url() : system.module
  • system_authorized_init() : system.module
  • system_authorized_run() : system.module
  • system_batch_page() : system.admin.inc
  • system_block_info() : system.module
  • system_block_ip_action() : system.module
  • system_block_view() : system.module
  • system_check_directory() : system.module
  • system_check_http_request() : system.module
  • system_clean_url_settings() : system.admin.inc
  • system_clear_cache_submit() : system.admin.inc
  • system_clear_page_cache_submit() : system.admin.inc
  • system_configure_date_formats_form() : system.admin.inc
  • system_cron() : system.module
  • system_cron_settings() : system.admin.inc
  • system_custom_theme() : system.module
  • system_date_delete_format_form() : system.admin.inc
  • system_date_delete_format_form_submit() : system.admin.inc
  • system_date_format_delete() : system.module
  • system_date_format_locale() : system.module
  • system_date_format_save() : system.module
  • system_date_format_type_delete() : system.module
  • system_date_format_type_save() : system.module
  • system_date_format_types() : system.module
  • system_date_formats() : system.module
  • system_date_formats_rebuild() : system.module
  • system_date_time_formats() : system.admin.inc
  • system_date_time_lookup() : system.admin.inc
  • system_date_time_settings() : system.admin.inc
  • system_default_date_formats() : date.inc
  • system_default_region() : system.module
  • system_delete_date_format_type_form() : system.admin.inc
  • system_delete_date_format_type_form_submit() : system.admin.inc
  • system_element_info() : system.module
  • system_entity_info() : system.module
  • system_file_system_settings() : system.admin.inc
  • system_filetransfer_info() : system.module
  • system_find_base_themes() : system.module
  • system_flush_caches() : system.module
  • system_form_user_profile_form_alter() : system.module
  • system_form_user_register_form_alter() : system.module
  • system_get_date_format() : system.module
  • system_get_date_formats() : system.module
  • system_get_date_types() : system.module
  • system_get_files_database() : system.module
  • system_get_info() : system.module
  • system_get_module_admin_tasks() : system.module
  • system_goto_action() : system.module
  • system_goto_action_form() : system.module
  • system_goto_action_submit() : system.module
  • system_help() : system.module
  • system_hook_info() : system.module
  • system_image_toolkit_settings() : system.admin.inc
  • system_image_toolkits() : system.module
  • system_init() : system.module
  • system_install() : system.install
  • system_ip_blocking() : system.admin.inc
  • system_ip_blocking_delete() : system.admin.inc
  • system_ip_blocking_delete_submit() : system.admin.inc
  • system_ip_blocking_form() : system.admin.inc
  • system_ip_blocking_form_submit() : system.admin.inc
  • system_ip_blocking_form_validate() : system.admin.inc
  • system_library() : system.module
  • system_list() : module.inc
  • system_list_reset() : module.inc
  • system_logging_settings() : system.admin.inc
  • system_mail() : system.module
  • system_menu() : system.module
  • system_message_action() : system.module
  • system_message_action_form() : system.module
  • system_message_action_submit() : system.module
  • system_modules() : system.admin.inc
  • system_modules_confirm_form() : system.admin.inc
  • system_modules_submit() : system.admin.inc
  • system_modules_uninstall() : system.admin.inc
  • system_modules_uninstall_confirm_form() : system.admin.inc
  • system_modules_uninstall_submit() : system.admin.inc
  • system_modules_uninstall_validate() : system.admin.inc
  • system_page_alter() : system.module
  • system_performance_settings() : system.admin.inc
  • system_permission() : system.module
  • system_php() : system.admin.inc
  • system_preprocess_block() : system.module
  • system_rebuild_module_data() : system.module
  • system_rebuild_theme_data() : system.module
  • system_region_list() : system.module
  • system_regional_settings() : system.admin.inc
  • system_requirements() : system.install
  • system_retrieve_file() : system.module
  • system_rss_feeds_settings() : system.admin.inc
  • system_run_automated_cron() : system.module
  • system_run_cron() : system.admin.inc
  • system_run_cron_submit() : system.admin.inc
  • system_schema() : system.install
  • system_schema_cache_7054() : system.install
  • system_send_email_action() : system.module
  • system_send_email_action_form() : system.module
  • system_send_email_action_submit() : system.module
  • system_send_email_action_validate() : system.module
  • system_settings_form() : system.module
  • system_settings_form_submit() : system.module
  • system_settings_overview() : system.admin.inc
  • system_site_information_settings() : system.admin.inc
  • system_site_information_settings_validate() : system.admin.inc
  • system_site_maintenance_mode() : system.admin.inc
  • system_sort_modules_by_info_name() : system.admin.inc
  • system_sort_themes() : system.admin.inc
  • system_status() : system.admin.inc
  • system_stream_wrappers() : system.module
  • system_system_info_alter() : system.module
  • system_theme() : system.module
  • system_theme_default() : system.admin.inc
  • system_theme_disable() : system.admin.inc
  • system_theme_enable() : system.admin.inc
  • system_theme_settings() : system.admin.inc
  • system_theme_settings_submit() : system.admin.inc
  • system_theme_settings_validate() : system.admin.inc
  • system_themes_admin_form() : system.admin.inc
  • system_themes_admin_form_submit() : system.admin.inc
  • system_themes_page() : system.admin.inc
  • system_time_zones() : system.module
  • system_timezone() : system.module
  • system_token_info() : system.tokens.inc
  • system_tokens() : system.tokens.inc
  • system_update_7000() : system.install
  • system_update_7001() : system.install
  • system_update_7002() : system.install
  • system_update_7003() : system.install
  • system_update_7004() : system.install
  • system_update_7005() : system.install
  • system_update_7007() : system.install
  • system_update_7009() : system.install
  • system_update_7011() : system.install
  • system_update_7013() : system.install
  • system_update_7015() : system.install
  • system_update_7016() : system.install
  • system_update_7017() : system.install
  • system_update_7018() : system.install
  • system_update_7020() : system.install
  • system_update_7021() : system.install
  • system_update_7027() : system.install
  • system_update_7029() : system.install
  • system_update_7032() : system.install
  • system_update_7033() : system.install
  • system_update_7034() : system.install
  • system_update_7036() : system.install
  • system_update_7042() : system.install
  • system_update_7044() : system.install
  • system_update_7045() : system.install
  • system_update_7046() : system.install
  • system_update_7047() : system.install
  • system_update_7048() : system.install
  • system_update_7049() : system.install
  • system_update_7050() : system.install
  • system_update_7051() : system.install
  • system_update_7052() : system.install
  • system_update_7053() : system.install
  • system_update_7054() : system.install
  • system_update_7055() : system.install
  • system_update_7057() : system.install
  • system_update_7058() : system.install
  • system_update_7059() : system.install
  • system_update_7060() : system.install
  • system_update_7061() : system.install
  • system_update_7062() : system.install
  • system_update_7063() : system.install
  • system_update_7064() : system.install
  • system_update_7065() : system.install
  • system_update_7066() : system.install
  • system_update_7067() : system.install
  • system_update_7068() : system.install
  • system_update_7069() : system.install
  • system_update_7070() : system.install
  • system_update_7071() : system.install
  • system_update_7072() : system.install
  • system_update_7073() : system.install
  • system_update_7074() : system.install
  • system_update_7076() : system.install
  • system_update_7077() : system.install
  • system_update_7078() : system.install
  • system_update_7079() : system.install
  • system_update_dependencies() : system.install
  • system_update_files_database() : system.module
  • system_update_last_removed() : system.install
  • system_updater_info() : system.module
  • system_user_login() : system.module
  • system_user_timezone() : system.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- t -

  • t() : bootstrap.inc
  • tabledrag_example_get_tree() : tabledrag_example_parent_form.inc
  • tabledrag_example_help() : tabledrag_example.module
  • tabledrag_example_install() : tabledrag_example.install
  • tabledrag_example_menu() : tabledrag_example.module
  • tabledrag_example_parent_form() : tabledrag_example_parent_form.inc
  • tabledrag_example_parent_form_submit() : tabledrag_example_parent_form.inc
  • tabledrag_example_parent_get_data() : tabledrag_example_parent_form.inc
  • tabledrag_example_schema() : tabledrag_example.install
  • tabledrag_example_simple_form() : tabledrag_example_simple_form.inc
  • tabledrag_example_simple_form_submit() : tabledrag_example_simple_form.inc
  • tabledrag_example_theme() : tabledrag_example.module
  • tabledrag_example_uninstall() : tabledrag_example.install
  • tablesort_cell() : tablesort.inc
  • tablesort_example_help() : tablesort_example.module
  • tablesort_example_install() : tablesort_example.install
  • tablesort_example_menu() : tablesort_example.module
  • tablesort_example_page() : tablesort_example.module
  • tablesort_example_schema() : tablesort_example.install
  • tablesort_example_uninstall() : tablesort_example.install
  • tablesort_get_order() : tablesort.inc
  • tablesort_get_query_parameters() : tablesort.inc
  • tablesort_get_sort() : tablesort.inc
  • tablesort_header() : tablesort.inc
  • tablesort_init() : tablesort.inc
  • taxonomy_admin_paths() : taxonomy.module
  • taxonomy_admin_vocabulary_title_callback() : taxonomy.module
  • taxonomy_allowed_values() : taxonomy.module
  • taxonomy_autocomplete() : taxonomy.pages.inc
  • taxonomy_autocomplete_validate() : taxonomy.module
  • taxonomy_build_node_index() : taxonomy.module
  • taxonomy_check_vocabulary_hierarchy() : taxonomy.module
  • taxonomy_delete_node_index() : taxonomy.module
  • taxonomy_entity_info() : taxonomy.module
  • taxonomy_entity_query_alter() : taxonomy.module
  • taxonomy_field_extra_fields() : taxonomy.module
  • taxonomy_field_formatter_info() : taxonomy.module
  • taxonomy_field_formatter_prepare_view() : taxonomy.module
  • taxonomy_field_formatter_view() : taxonomy.module
  • taxonomy_field_info() : taxonomy.module
  • taxonomy_field_is_empty() : taxonomy.module
  • taxonomy_field_presave() : taxonomy.module
  • taxonomy_field_schema() : taxonomy.install
  • taxonomy_field_settings_form() : taxonomy.module
  • taxonomy_field_validate() : taxonomy.module
  • taxonomy_field_widget_error() : taxonomy.module
  • taxonomy_field_widget_form() : taxonomy.module
  • taxonomy_field_widget_info() : taxonomy.module
  • taxonomy_field_widget_info_alter() : taxonomy.module
  • taxonomy_form_term() : taxonomy.admin.inc
  • taxonomy_form_term_submit() : taxonomy.admin.inc
  • taxonomy_form_term_submit_build_taxonomy_term() : taxonomy.admin.inc
  • taxonomy_form_term_validate() : taxonomy.admin.inc
  • taxonomy_form_vocabulary() : taxonomy.admin.inc
  • taxonomy_form_vocabulary_submit() : taxonomy.admin.inc
  • taxonomy_form_vocabulary_validate() : taxonomy.admin.inc
  • taxonomy_get_children() : taxonomy.module
  • taxonomy_get_parents() : taxonomy.module
  • taxonomy_get_parents_all() : taxonomy.module
  • taxonomy_get_term_by_name() : taxonomy.module
  • taxonomy_get_tree() : taxonomy.module
  • taxonomy_get_vocabularies() : taxonomy.module
  • taxonomy_help() : taxonomy.module
  • taxonomy_implode_tags() : taxonomy.module
  • taxonomy_menu() : taxonomy.module
  • taxonomy_node_delete() : taxonomy.module
  • taxonomy_node_insert() : taxonomy.module
  • taxonomy_node_update() : taxonomy.module
  • taxonomy_options_list() : taxonomy.module
  • taxonomy_overview_terms() : taxonomy.admin.inc
  • taxonomy_overview_terms_submit() : taxonomy.admin.inc
  • taxonomy_overview_vocabularies() : taxonomy.admin.inc
  • taxonomy_overview_vocabularies_submit() : taxonomy.admin.inc
  • taxonomy_permission() : taxonomy.module
  • taxonomy_rdf_mapping() : taxonomy.module
  • taxonomy_schema() : taxonomy.install
  • taxonomy_select_nodes() : taxonomy.module
  • taxonomy_taxonomy_term_delete() : taxonomy.module
  • taxonomy_taxonomy_vocabulary_update() : taxonomy.module
  • taxonomy_term_build_content() : taxonomy.module
  • taxonomy_term_confirm_delete() : taxonomy.admin.inc
  • taxonomy_term_confirm_delete_submit() : taxonomy.admin.inc
  • taxonomy_term_delete() : taxonomy.module
  • taxonomy_term_edit_access() : taxonomy.module
  • taxonomy_term_feed() : taxonomy.pages.inc
  • taxonomy_term_is_page() : taxonomy.module
  • taxonomy_term_load() : taxonomy.module
  • taxonomy_term_load_multiple() : taxonomy.module
  • taxonomy_term_page() : taxonomy.pages.inc
  • taxonomy_term_save() : taxonomy.module
  • taxonomy_term_show() : taxonomy.module
  • taxonomy_term_title() : taxonomy.module
  • taxonomy_term_uri() : taxonomy.module
  • taxonomy_term_view() : taxonomy.module
  • taxonomy_term_view_multiple() : taxonomy.module
  • taxonomy_terms_static_reset() : taxonomy.module
  • taxonomy_theme() : taxonomy.module
  • taxonomy_token_info() : taxonomy.tokens.inc
  • taxonomy_tokens() : taxonomy.tokens.inc
  • taxonomy_uninstall() : taxonomy.install
  • taxonomy_update_7001() : taxonomy.install
  • taxonomy_update_7002() : taxonomy.install
  • taxonomy_update_7003() : taxonomy.install
  • taxonomy_update_7004() : taxonomy.install
  • taxonomy_update_7005() : taxonomy.install
  • taxonomy_update_7006() : taxonomy.install
  • taxonomy_update_7007() : taxonomy.install
  • taxonomy_update_7008() : taxonomy.install
  • taxonomy_update_7009() : taxonomy.install
  • taxonomy_update_7010() : taxonomy.install
  • taxonomy_update_7011() : taxonomy.install
  • taxonomy_update_dependencies() : taxonomy.install
  • taxonomy_vocabulary_confirm_delete() : taxonomy.admin.inc
  • taxonomy_vocabulary_confirm_delete_submit() : taxonomy.admin.inc
  • taxonomy_vocabulary_confirm_reset_alphabetical() : taxonomy.admin.inc
  • taxonomy_vocabulary_confirm_reset_alphabetical_submit() : taxonomy.admin.inc
  • taxonomy_vocabulary_delete() : taxonomy.module
  • taxonomy_vocabulary_get_names() : taxonomy.module
  • taxonomy_vocabulary_load() : taxonomy.module
  • taxonomy_vocabulary_load_multiple() : taxonomy.module
  • taxonomy_vocabulary_machine_name_load() : taxonomy.module
  • taxonomy_vocabulary_save() : taxonomy.module
  • taxonomy_vocabulary_static_reset() : taxonomy.module
  • template_preprocess() : theme.inc
  • template_preprocess_aggregator_feed_source() : aggregator.pages.inc
  • template_preprocess_aggregator_item() : aggregator.pages.inc
  • template_preprocess_aggregator_summary_item() : aggregator.pages.inc
  • template_preprocess_aggregator_summary_items() : aggregator.pages.inc
  • template_preprocess_aggregator_wrapper() : aggregator.pages.inc
  • template_preprocess_block() : block.module
  • template_preprocess_block_admin_display_form() : block.admin.inc
  • template_preprocess_book_all_books_block() : book.module
  • template_preprocess_book_export_html() : book.module
  • template_preprocess_book_navigation() : book.module
  • template_preprocess_book_node_export_html() : book.module
  • template_preprocess_comment() : comment.module
  • template_preprocess_comment_wrapper() : comment.module
  • template_preprocess_contextual_links_example_object() : contextual_links_example.module
  • template_preprocess_dashboard_admin_display_form() : dashboard.module
  • template_preprocess_field() : field.module
  • template_preprocess_forum_icon() : forum.module
  • template_preprocess_forum_list() : forum.module
  • template_preprocess_forum_submitted() : forum.module
  • template_preprocess_forum_topic_list() : forum.module
  • template_preprocess_forums() : forum.module
  • template_preprocess_html() : theme.inc
  • template_preprocess_maintenance_page() : theme.inc
  • template_preprocess_menu_tree() : menu.inc
  • template_preprocess_node() : node.module
  • template_preprocess_overlay() : overlay.module
  • template_preprocess_page() : theme.inc
  • template_preprocess_poll_bar() : poll.module
  • template_preprocess_poll_results() : poll.module
  • template_preprocess_poll_vote() : poll.module
  • template_preprocess_profile_block() : profile.module
  • template_preprocess_profile_listing() : profile.module
  • template_preprocess_profile_wrapper() : profile.module
  • template_preprocess_region() : theme.inc
  • template_preprocess_search_block_form() : search.module
  • template_preprocess_search_result() : search.pages.inc
  • template_preprocess_search_results() : search.pages.inc
  • template_preprocess_taxonomy_term() : taxonomy.module
  • template_preprocess_theming_example_text_form() : theming_example.module
  • template_preprocess_user_picture() : user.module
  • template_preprocess_user_profile() : user.pages.inc
  • template_preprocess_user_profile_category() : user.pages.inc
  • template_preprocess_user_profile_item() : user.pages.inc
  • template_preprocess_username() : theme.inc
  • template_process() : theme.inc
  • template_process_field() : field.module
  • template_process_html() : theme.inc
  • template_process_maintenance_page() : theme.inc
  • template_process_overlay() : overlay.module
  • template_process_page() : theme.inc
  • template_process_username() : theme.inc
  • testing_install() : testing.install
  • text_field_formatter_info() : text.module
  • text_field_formatter_settings_form() : text.module
  • text_field_formatter_settings_summary() : text.module
  • text_field_formatter_view() : text.module
  • text_field_info() : text.module
  • text_field_instance_settings_form() : text.module
  • text_field_is_empty() : text.module
  • text_field_load() : text.module
  • text_field_prepare_translation() : text.module
  • text_field_schema() : text.install
  • text_field_settings_form() : text.module
  • text_field_validate() : text.module
  • text_field_widget_error() : text.module
  • text_field_widget_form() : text.module
  • text_field_widget_info() : text.module
  • text_field_widget_settings_form() : text.module
  • text_filter_format_disable() : text.module
  • text_filter_format_update() : text.module
  • text_help() : text.module
  • text_summary() : text.module
  • text_update_7000() : text.install
  • theme() : theme.inc
  • theme_admin_block() : system.admin.inc
  • theme_admin_block_content() : system.admin.inc
  • theme_admin_page() : system.admin.inc
  • theme_aggregator_block_item() : aggregator.module
  • theme_aggregator_categorize_items() : aggregator.pages.inc
  • theme_aggregator_page_opml() : aggregator.pages.inc
  • theme_aggregator_page_rss() : aggregator.pages.inc
  • theme_authorize_message() : theme.maintenance.inc
  • theme_authorize_report() : theme.maintenance.inc
  • theme_book_admin_table() : book.admin.inc
  • theme_book_title_link() : book.module
  • theme_breadcrumb() : theme.inc
  • theme_button() : form.inc
  • theme_checkbox() : form.inc
  • theme_checkboxes() : form.inc
  • theme_color_scheme_form() : color.module
  • theme_comment_block() : comment.module
  • theme_comment_post_forbidden() : comment.module
  • theme_confirm_form() : system.module
  • theme_container() : form.inc
  • theme_dashboard() : dashboard.module
  • theme_dashboard_admin() : dashboard.module
  • theme_dashboard_disabled_block() : dashboard.module
  • theme_dashboard_disabled_blocks() : dashboard.module
  • theme_dashboard_region() : dashboard.module
  • theme_date() : form.inc
  • theme_dblog_message() : dblog.admin.inc
  • theme_disable() : theme.inc
  • theme_enable() : theme.inc
  • theme_example_node_color() : node_example.module
  • theme_exposed_filters() : system.module
  • theme_feed_icon() : theme.inc
  • theme_field() : field.module
  • theme_field_multiple_value_form() : field.form.inc
  • theme_field_ui_table() : field_ui.admin.inc
  • theme_fieldset() : form.inc
  • theme_file() : form.inc
  • theme_file_formatter_table() : file.field.inc
  • theme_file_icon() : file.module
  • theme_file_link() : file.module
  • theme_file_managed_file() : file.module
  • theme_file_upload_help() : file.field.inc
  • theme_file_widget() : file.field.inc
  • theme_file_widget_multiple() : file.field.inc
  • theme_filter_admin_format_filter_order() : filter.admin.inc
  • theme_filter_admin_overview() : filter.admin.inc
  • theme_filter_guidelines() : filter.module
  • theme_filter_tips() : filter.pages.inc
  • theme_filter_tips_more_info() : filter.module
  • theme_form() : form.inc
  • theme_form_element() : form.inc
  • theme_form_element_label() : form.inc
  • theme_form_example_checkbox() : form_example_elements.inc
  • theme_form_example_inline_form_element() : form_example_elements.inc
  • theme_form_required_marker() : form.inc
  • theme_forum_form() : forum.admin.inc
  • theme_get_registry() : theme.inc
  • theme_get_setting() : theme.inc
  • theme_get_suggestions() : theme.inc
  • theme_hidden() : form.inc
  • theme_html_tag() : theme.inc
  • theme_image() : theme.inc
  • theme_image_anchor() : image.admin.inc
  • theme_image_button() : form.inc
  • theme_image_crop_summary() : image.admin.inc
  • theme_image_example_colorize_summary() : image_example.module
  • theme_image_example_image() : image_example.pages.inc
  • theme_image_formatter() : image.field.inc
  • theme_image_resize_summary() : image.admin.inc
  • theme_image_rotate_summary() : image.admin.inc
  • theme_image_scale_summary() : image.admin.inc
  • theme_image_style() : image.module
  • theme_image_style_effects() : image.admin.inc
  • theme_image_style_list() : image.admin.inc
  • theme_image_style_preview() : image.admin.inc
  • theme_image_widget() : image.field.inc
  • theme_indentation() : theme.inc
  • theme_install_page() : theme.maintenance.inc
  • theme_item_list() : theme.inc
  • theme_link() : theme.inc
  • theme_links() : theme.inc
  • theme_locale_date_format_form() : locale.admin.inc
  • theme_locale_languages_configure_form() : locale.admin.inc
  • theme_locale_languages_overview_form() : locale.admin.inc
  • theme_mark() : theme.inc
  • theme_menu_admin_overview() : menu.admin.inc
  • theme_menu_link() : menu.inc
  • theme_menu_local_action() : menu.inc
  • theme_menu_local_task() : menu.inc
  • theme_menu_local_tasks() : menu.inc
  • theme_menu_overview_form() : menu.admin.inc
  • theme_menu_tree() : menu.inc
  • theme_more_help_link() : theme.inc
  • theme_more_link() : theme.inc
  • theme_node_add_list() : node.pages.inc
  • theme_node_admin_overview() : content_types.inc
  • theme_node_preview() : node.pages.inc
  • theme_node_recent_block() : node.module
  • theme_node_recent_content() : node.module
  • theme_node_search_admin() : node.module
  • theme_nodeapi_example_rating() : nodeapi_example.module
  • theme_options_none() : options.module
  • theme_overlay_disable_message() : overlay.module
  • theme_pager() : pager.inc
  • theme_pager_first() : pager.inc
  • theme_pager_last() : pager.inc
  • theme_pager_link() : pager.inc
  • theme_pager_next() : pager.inc
  • theme_pager_previous() : pager.inc
  • theme_password() : form.inc
  • theme_poll_choices() : poll.module
  • theme_profile_admin_overview() : profile.admin.inc
  • theme_progress_bar() : theme.inc
  • theme_queue_items() : queue_example.module
  • theme_radio() : form.inc
  • theme_radios() : form.inc
  • theme_rdf_metadata() : rdf.module
  • theme_rdf_template_variable_wrapper() : rdf.module
  • theme_render_array() : render_example.module
  • theme_render_example_add_div() : render_example.module
  • theme_render_example_add_notes() : render_example.module
  • theme_render_example_aggregate() : render_example.module
  • theme_render_template() : theme.inc
  • theme_select() : form.inc
  • theme_shortcut_set_customize() : shortcut.admin.inc
  • theme_simpletest_result_summary() : simpletest.pages.inc
  • theme_simpletest_test_table() : simpletest.pages.inc
  • theme_status_messages() : theme.inc
  • theme_status_report() : system.admin.inc
  • theme_submit() : form.inc
  • theme_system_admin_index() : system.admin.inc
  • theme_system_compact_link() : system.module
  • theme_system_date_time_settings() : system.admin.inc
  • theme_system_modules_fieldset() : system.admin.inc
  • theme_system_modules_incompatible() : system.admin.inc
  • theme_system_modules_uninstall() : system.admin.inc
  • theme_system_powered_by() : system.module
  • theme_system_settings_form() : system.module
  • theme_system_themes_page() : system.admin.inc
  • theme_table() : theme.inc
  • theme_tabledrag_example_parent_form() : tabledrag_example_parent_form.inc
  • theme_tabledrag_example_simple_form() : tabledrag_example_simple_form.inc
  • theme_tableselect() : form.inc
  • theme_tablesort_indicator() : theme.inc
  • theme_task_list() : theme.maintenance.inc
  • theme_taxonomy_overview_terms() : taxonomy.admin.inc
  • theme_taxonomy_overview_vocabularies() : taxonomy.admin.inc
  • theme_text_format_wrapper() : filter.module
  • theme_textarea() : form.inc
  • theme_textfield() : form.inc
  • theme_theming_example_content_array() : theming_example.module
  • theme_theming_example_list() : theming_example.module
  • theme_theming_example_select_form() : theming_example.module
  • theme_toolbar_toggle() : toolbar.module
  • theme_trigger_display() : trigger.admin.inc
  • theme_update_last_check() : update.module
  • theme_update_manager_update_form() : update.manager.inc
  • theme_update_page() : theme.maintenance.inc
  • theme_update_report() : update.report.inc
  • theme_update_status_label() : update.report.inc
  • theme_update_version() : update.report.inc
  • theme_user_admin_permissions() : user.admin.inc
  • theme_user_admin_roles() : user.admin.inc
  • theme_user_list() : user.module
  • theme_user_permission_description() : user.admin.inc
  • theme_user_signature() : user.module
  • theme_username() : theme.inc
  • theme_vertical_tabs() : form.inc
  • theming_example_list_page() : theming_example.module
  • theming_example_menu() : theming_example.module
  • theming_example_page() : theming_example.module
  • theming_example_select_form() : theming_example.module
  • theming_example_select_form_submit() : theming_example.module
  • theming_example_text_form() : theming_example.module
  • theming_example_text_form_submit() : theming_example.module
  • theming_example_theme() : theming_example.module
  • timer_read() : bootstrap.inc
  • timer_start() : bootstrap.inc
  • timer_stop() : bootstrap.inc
  • token_example_entity_info_alter() : token_example.module
  • token_example_example_form() : token_example.module
  • token_example_example_form_submit() : token_example.module
  • token_example_menu() : token_example.module
  • token_example_token_info() : token_example.tokens.inc
  • token_example_tokens() : token_example.tokens.inc
  • token_find_with_prefix() : token.inc
  • token_generate() : token.inc
  • token_info() : token.inc
  • token_replace() : token.inc
  • token_scan() : token.inc
  • toolbar_get_menu_tree() : toolbar.module
  • toolbar_help() : toolbar.module
  • toolbar_in_active_trail() : toolbar.module
  • toolbar_menu() : toolbar.module
  • toolbar_menu_navigation_links() : toolbar.module
  • toolbar_page_build() : toolbar.module
  • toolbar_permission() : toolbar.module
  • toolbar_pre_render() : toolbar.module
  • toolbar_preprocess_html() : toolbar.module
  • toolbar_preprocess_toolbar() : toolbar.module
  • toolbar_system_info_alter() : toolbar.module
  • toolbar_theme() : toolbar.module
  • toolbar_toggle_page() : toolbar.module
  • toolbar_view() : toolbar.module
  • tracker_comment_delete() : tracker.module
  • tracker_comment_publish() : tracker.module
  • tracker_comment_unpublish() : tracker.module
  • tracker_comment_update() : tracker.module
  • tracker_cron() : tracker.module
  • tracker_enable() : tracker.install
  • tracker_help() : tracker.module
  • tracker_menu() : tracker.module
  • tracker_node_delete() : tracker.module
  • tracker_node_insert() : tracker.module
  • tracker_node_update() : tracker.module
  • tracker_page() : tracker.pages.inc
  • tracker_schema() : tracker.install
  • tracker_uninstall() : tracker.install
  • tracker_update_7000() : tracker.install
  • translation_admin_paths() : translation.module
  • translation_form_node_form_alter() : translation.module
  • translation_form_node_type_form_alter() : translation.module
  • translation_help() : translation.module
  • translation_language_switch_links_alter() : translation.module
  • translation_menu() : translation.module
  • translation_node_delete() : translation.module
  • translation_node_get_translations() : translation.module
  • translation_node_insert() : translation.module
  • translation_node_overview() : translation.pages.inc
  • translation_node_prepare() : translation.module
  • translation_node_update() : translation.module
  • translation_node_validate() : translation.module
  • translation_node_view() : translation.module
  • translation_path_get_translations() : translation.module
  • translation_permission() : translation.module
  • translation_remove_from_set() : translation.module
  • translation_supported_type() : translation.module
  • trigger_actions_delete() : trigger.module
  • trigger_assign() : trigger.admin.inc
  • trigger_assign_form() : trigger.admin.inc
  • trigger_assign_form_submit() : trigger.admin.inc
  • trigger_assign_form_validate() : trigger.admin.inc
  • trigger_comment_delete() : trigger.module
  • trigger_comment_insert() : trigger.module
  • trigger_comment_presave() : trigger.module
  • trigger_comment_update() : trigger.module
  • trigger_comment_view() : trigger.module
  • trigger_cron() : trigger.module
  • trigger_example_form() : trigger_example.module
  • trigger_example_form_submit() : trigger_example.module
  • trigger_example_help() : trigger_example.module
  • trigger_example_menu() : trigger_example.module
  • trigger_example_trigger_info() : trigger_example.module
  • trigger_example_trigger_info_alter() : trigger_example.module
  • trigger_example_triggersomething() : trigger_example.module
  • trigger_example_user_login() : trigger_example.module
  • trigger_forms() : trigger.module
  • trigger_get_assigned_actions() : trigger.module
  • trigger_help() : trigger.module
  • trigger_install() : trigger.install
  • trigger_menu() : trigger.module
  • trigger_menu_unassign_access() : trigger.module
  • trigger_node_delete() : trigger.module
  • trigger_node_insert() : trigger.module
  • trigger_node_presave() : trigger.module
  • trigger_node_update() : trigger.module
  • trigger_node_view() : trigger.module
  • trigger_schema() : trigger.install
  • trigger_taxonomy_term_delete() : trigger.module
  • trigger_taxonomy_term_insert() : trigger.module
  • trigger_taxonomy_term_update() : trigger.module
  • trigger_theme() : trigger.module
  • trigger_trigger_info() : trigger.module
  • trigger_unassign() : trigger.admin.inc
  • trigger_unassign_submit() : trigger.admin.inc
  • trigger_update_7000() : trigger.install
  • trigger_update_7001() : trigger.install
  • trigger_update_7002() : trigger.install
  • trigger_user_cancel() : trigger.module
  • trigger_user_delete() : trigger.module
  • trigger_user_insert() : trigger.module
  • trigger_user_login() : trigger.module
  • trigger_user_logout() : trigger.module
  • trigger_user_update() : trigger.module
  • trigger_user_view() : trigger.module
  • truncate_utf8() : unicode.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- u -

  • unicode_check() : unicode.inc
  • unicode_requirements() : unicode.inc
  • update_access_allowed() : update.php
  • update_access_denied_page() : update.php
  • update_already_performed() : update.inc
  • update_authorize_batch_copy_project() : update.authorize.inc
  • update_authorize_install_batch_finished() : update.authorize.inc
  • update_authorize_run_install() : update.authorize.inc
  • update_authorize_run_update() : update.authorize.inc
  • update_authorize_update_batch_finished() : update.authorize.inc
  • update_batch() : update.inc
  • update_build_dependency_graph() : update.inc
  • update_cache_clear_submit() : update.module
  • update_calculate_project_data() : update.compare.inc
  • update_calculate_project_update_status() : update.compare.inc
  • update_check_incompatibility() : update.inc
  • update_check_requirements() : update.php
  • update_clear_update_disk_cache() : update.module
  • update_create_fetch_task() : update.module
  • update_cron() : update.module
  • update_delete_file_if_stale() : update.module
  • update_do_one() : update.inc
  • update_extra_requirements() : update.php
  • update_fetch_data() : update.module
  • update_fetch_data_batch() : update.fetch.inc
  • update_fetch_data_finished() : update.fetch.inc
  • update_filter_project_info() : update.compare.inc
  • update_finished() : update.inc
  • update_fix_compatibility() : update.inc
  • update_fix_d7_block_deltas() : update.inc
  • update_fix_d7_install_profile() : update.inc
  • update_fix_d7_requirements() : update.inc
  • update_flush_caches() : update.module
  • update_form_system_modules_alter() : update.module
  • update_get_available() : update.module
  • update_get_d6_session_name() : update.inc
  • update_get_project_name() : update.compare.inc
  • update_get_projects() : update.compare.inc
  • update_get_update_function_list() : update.inc
  • update_get_update_list() : update.inc
  • update_help() : update.module
  • update_helpful_links() : update.php
  • update_info_page() : update.php
  • update_init() : update.module
  • update_install() : update.install
  • update_is_missing() : update.inc
  • update_mail() : update.module
  • update_manager_access() : update.module
  • update_manager_archive_extract() : update.manager.inc
  • update_manager_archive_verify() : update.manager.inc
  • update_manager_batch_project_get() : update.manager.inc
  • update_manager_download_batch_finished() : update.manager.inc
  • update_manager_file_get() : update.manager.inc
  • update_manager_install_form() : update.manager.inc
  • update_manager_install_form_submit() : update.manager.inc
  • update_manager_install_form_validate() : update.manager.inc
  • update_manager_local_transfers_allowed() : update.manager.inc
  • update_manager_update_form() : update.manager.inc
  • update_manager_update_form_submit() : update.manager.inc
  • update_manager_update_form_validate() : update.manager.inc
  • update_manager_update_ready_form() : update.manager.inc
  • update_manager_update_ready_form_submit() : update.manager.inc
  • update_manual_status() : update.fetch.inc
  • update_menu() : update.module
  • update_parse_db_url() : update.inc
  • update_parse_xml() : update.fetch.inc
  • update_prepare_d7_bootstrap() : update.inc
  • update_process_project_info() : update.compare.inc
  • update_project_cache() : update.compare.inc
  • update_refresh() : update.module
  • update_requirements() : update.install
  • update_resolve_dependencies() : update.inc
  • update_results_page() : update.php
  • update_retrieve_dependencies() : update.inc
  • update_schema() : update.install
  • update_script_selection_form() : update.php
  • update_selection_page() : update.php
  • update_settings() : update.settings.inc
  • update_settings_submit() : update.settings.inc
  • update_settings_validate() : update.settings.inc
  • update_status() : update.report.inc
  • update_task_list() : update.php
  • update_theme() : update.module
  • update_themes_disabled() : update.module
  • update_themes_enabled() : update.module
  • update_uninstall() : update.install
  • update_update_7000() : update.install
  • update_update_7001() : update.install
  • update_verify_update_archive() : update.module
  • url() : common.inc
  • url_is_external() : common.inc
  • user_access() : user.module
  • user_account_form() : user.module
  • user_account_form_validate() : user.module
  • user_action_info() : user.module
  • user_admin() : user.admin.inc
  • user_admin_account() : user.admin.inc
  • user_admin_account_submit() : user.admin.inc
  • user_admin_account_validate() : user.admin.inc
  • user_admin_paths() : user.module
  • user_admin_permissions() : user.admin.inc
  • user_admin_permissions_submit() : user.admin.inc
  • user_admin_role() : user.admin.inc
  • user_admin_role_delete_confirm() : user.admin.inc
  • user_admin_role_delete_confirm_submit() : user.admin.inc
  • user_admin_role_delete_submit() : user.admin.inc
  • user_admin_role_submit() : user.admin.inc
  • user_admin_role_validate() : user.admin.inc
  • user_admin_roles() : user.admin.inc
  • user_admin_roles_order_submit() : user.admin.inc
  • user_admin_settings() : user.admin.inc
  • user_authenticate() : user.module
  • user_autocomplete() : user.pages.inc
  • user_block_configure() : user.module
  • user_block_info() : user.module
  • user_block_save() : user.module
  • user_block_user_action() : user.module
  • user_block_view() : user.module
  • user_build_content() : user.module
  • user_build_filter_query() : user.module
  • user_cancel() : user.module
  • user_cancel_access() : user.module
  • user_cancel_confirm() : user.pages.inc
  • user_cancel_confirm_form() : user.pages.inc
  • user_cancel_confirm_form_submit() : user.pages.inc
  • user_cancel_methods() : user.pages.inc
  • user_cancel_url() : user.module
  • user_category_load() : user.module
  • user_check_password() : password.inc
  • user_comment_view() : user.module
  • user_cookie_delete() : user.module
  • user_cookie_save() : user.module
  • user_delete() : user.module
  • user_delete_multiple() : user.module
  • user_edit_access() : user.module
  • user_edit_cancel_submit() : user.pages.inc
  • user_element_info() : user.module
  • user_entity_info() : user.module
  • user_external_load() : user.module
  • user_external_login_register() : user.module
  • user_field_extra_fields() : user.module
  • user_field_info_alter() : user.module
  • user_file_delete() : user.module
  • user_file_download() : user.module
  • user_file_download_access() : user.module
  • user_file_move() : user.module
  • user_filter_form() : user.admin.inc
  • user_filter_form_submit() : user.admin.inc
  • user_filters() : user.module
  • user_form_field_ui_field_edit_form_alter() : user.module
  • user_form_field_ui_field_edit_form_submit() : user.module
  • user_form_process_password_confirm() : user.module
  • user_get_authmaps() : user.module
  • user_hash_password() : password.inc
  • user_help() : user.module
  • user_image_style_delete() : user.module
  • user_image_style_save() : user.module
  • user_install() : user.install
  • user_is_anonymous() : user.module
  • user_is_blocked() : user.module
  • user_is_logged_in() : user.module
  • user_load() : user.module
  • user_load_by_mail() : user.module
  • user_load_by_name() : user.module
  • user_load_multiple() : user.module
  • user_login() : user.module
  • user_login_authenticate_validate() : user.module
  • user_login_block() : user.module
  • user_login_default_validators() : user.module
  • user_login_destination() : user.module
  • user_login_final_validate() : user.module
  • user_login_finalize() : user.module
  • user_login_name_validate() : user.module
  • user_login_submit() : user.module
  • user_logout() : user.pages.inc
  • user_mail() : user.module
  • user_mail_tokens() : user.module
  • user_menu() : user.module
  • user_menu_link_alter() : user.module
  • user_menu_site_status_alter() : user.module
  • user_menu_title() : user.module
  • user_module_invoke() : user.module
  • user_modules_installed() : user.module
  • user_modules_uninstalled() : user.module
  • user_multiple_cancel_confirm() : user.module
  • user_multiple_cancel_confirm_submit() : user.module
  • user_multiple_role_edit() : user.module
  • user_needs_new_hash() : password.inc
  • user_node_load() : user.module
  • user_page() : user.pages.inc
  • user_page_title() : user.module
  • user_pass() : user.pages.inc
  • user_pass_rehash() : user.module
  • user_pass_reset() : user.pages.inc
  • user_pass_reset_url() : user.module
  • user_pass_submit() : user.pages.inc
  • user_pass_validate() : user.pages.inc
  • user_password() : user.module
  • user_permission() : user.module
  • user_permission_get_modules() : user.module
  • user_preferred_language() : user.module
  • user_profile_form() : user.pages.inc
  • user_profile_form_submit() : user.pages.inc
  • user_profile_form_validate() : user.pages.inc
  • user_rdf_mapping() : user.module
  • user_register_access() : user.module
  • user_register_form() : user.module
  • user_register_submit() : user.module
  • user_register_validate() : user.module
  • user_role_change_permissions() : user.module
  • user_role_delete() : user.module
  • user_role_edit_access() : user.module
  • user_role_grant_permissions() : user.module
  • user_role_load() : user.module
  • user_role_load_by_name() : user.module
  • user_role_permissions() : user.module
  • user_role_revoke_permissions() : user.module
  • user_role_save() : user.module
  • user_roles() : user.module
  • user_save() : user.module
  • user_schema() : user.install
  • user_search_access() : user.module
  • user_search_execute() : user.module
  • user_search_info() : user.module
  • user_set_authmaps() : user.module
  • user_system_info_alter() : user.module
  • user_theme() : user.module
  • user_token_info() : user.tokens.inc
  • user_tokens() : user.tokens.inc
  • user_translated_menu_link_alter() : user.module
  • user_uid_only_optional_to_arg() : user.module
  • user_uid_optional_load() : user.module
  • user_uid_optional_to_arg() : user.module
  • user_update_7000() : user.install
  • user_update_7001() : user.install
  • user_update_7002() : user.install
  • user_update_7003() : user.install
  • user_update_7005() : user.install
  • user_update_7006() : user.install
  • user_update_7007() : user.install
  • user_update_7008() : user.install
  • user_update_7009() : user.install
  • user_update_7010() : user.install
  • user_update_7011() : user.install
  • user_update_7012() : user.install
  • user_update_7013() : user.install
  • user_update_7014() : user.install
  • user_update_7015() : user.install
  • user_update_7016() : user.install
  • user_update_7017() : user.install
  • user_update_7018() : user.install
  • user_update_dependencies() : user.install
  • user_uri() : user.module
  • user_user_categories() : user.module
  • user_user_operations() : user.module
  • user_user_operations_block() : user.module
  • user_user_operations_unblock() : user.module
  • user_user_presave() : user.module
  • user_user_view() : user.module
  • user_validate_current_pass() : user.module
  • user_validate_mail() : user.module
  • user_validate_name() : user.module
  • user_validate_picture() : user.module
  • user_view() : user.module
  • user_view_access() : user.module
  • user_view_page() : user.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- v -

  • valid_email_address() : common.inc
  • valid_url() : common.inc
  • vancode2int() : comment.module
  • variable_del() : bootstrap.inc
  • variable_get() : bootstrap.inc
  • variable_initialize() : bootstrap.inc
  • variable_set() : bootstrap.inc
  • vertical_tabs_example_form_alter() : vertical_tabs_example.module
  • vertical_tabs_example_menu() : vertical_tabs_example.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- w -

  • watchdog() : bootstrap.inc
  • watchdog_exception() : bootstrap.inc
  • watchdog_severity_levels() : common.inc
  • weight_value() : form.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- x -

  • xmlrpc() : common.inc
  • xmlrpc_base64() : xmlrpc.inc
  • xmlrpc_base64_get_xml() : xmlrpc.inc
  • xmlrpc_clear_error() : xmlrpc.inc
  • xmlrpc_date() : xmlrpc.inc
  • xmlrpc_date_get_xml() : xmlrpc.inc
  • xmlrpc_errno() : xmlrpc.inc
  • xmlrpc_error() : xmlrpc.inc
  • xmlrpc_error_get_xml() : xmlrpc.inc
  • xmlrpc_error_msg() : xmlrpc.inc
  • xmlrpc_example_alter_form() : xmlrpc_example.module
  • xmlrpc_example_client_add_submit() : xmlrpc_example.module
  • xmlrpc_example_client_form() : xmlrpc_example.module
  • xmlrpc_example_client_multicall_submit() : xmlrpc_example.module
  • xmlrpc_example_client_request_methods_submit() : xmlrpc_example.module
  • xmlrpc_example_client_subtract_submit() : xmlrpc_example.module
  • xmlrpc_example_info() : xmlrpc_example.module
  • xmlrpc_example_menu() : xmlrpc_example.module
  • xmlrpc_example_server_form() : xmlrpc_example.module
  • xmlrpc_example_xmlrpc() : xmlrpc_example.module
  • xmlrpc_example_xmlrpc_alter() : xmlrpc_example.module
  • xmlrpc_message() : xmlrpc.inc
  • xmlrpc_message_cdata() : xmlrpc.inc
  • xmlrpc_message_get() : xmlrpc.inc
  • xmlrpc_message_parse() : xmlrpc.inc
  • xmlrpc_message_set() : xmlrpc.inc
  • xmlrpc_message_tag_close() : xmlrpc.inc
  • xmlrpc_message_tag_open() : xmlrpc.inc
  • xmlrpc_request() : xmlrpc.inc
  • xmlrpc_server() : xmlrpcs.inc
  • xmlrpc_server_call() : xmlrpcs.inc
  • xmlrpc_server_error() : xmlrpcs.inc
  • xmlrpc_server_get() : xmlrpcs.inc
  • xmlrpc_server_get_capabilities() : xmlrpcs.inc
  • xmlrpc_server_list_methods() : xmlrpcs.inc
  • xmlrpc_server_method_help() : xmlrpcs.inc
  • xmlrpc_server_method_signature() : xmlrpcs.inc
  • xmlrpc_server_multicall() : xmlrpcs.inc
  • xmlrpc_server_output() : xmlrpcs.inc
  • xmlrpc_server_set() : xmlrpcs.inc
  • xmlrpc_value() : xmlrpc.inc
  • xmlrpc_value_calculate_type() : xmlrpc.inc
  • xmlrpc_value_get_xml() : xmlrpc.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- $ -

  • $attributes : block.tpl.php , comment-wrapper.tpl.php , field.tpl.php , html.tpl.php , comment.tpl.php , node.tpl.php , user-profile-category.tpl.php , node.tpl.php , user-profile-item.tpl.php , user-profile.tpl.php , comment.tpl.php , overlay.tpl.php , comment-wrapper.tpl.php , comment.tpl.php , search-result.tpl.php , maintenance-page.tpl.php , node.tpl.php
  • $author : comment.tpl.php
  • $base_url : book-export-html.tpl.php
  • $block_html_id : block.tpl.php
  • $breadcrumb : page.tpl.php
  • $children : book-node-export-html.tpl.php
  • $choice : poll-vote.tpl.php
  • $classes : html.tpl.php , maintenance-page.tpl.php , taxonomy-term.tpl.php , toolbar.tpl.php , comment-wrapper.tpl.php , comment.tpl.php , maintenance-page.tpl.php , node.tpl.php , maintenance-page.tpl.php , contextual-links-example-object.tpl.php , block.tpl.php , comment-wrapper.tpl.php , comment.tpl.php , field.tpl.php , node.tpl.php , search-result.tpl.php
  • $conf : authorize.php , default.settings.php , update.php
  • $configurable_timezones : update.php
  • $content : contextual-links-example-object.tpl.php , aggregator-wrapper.tpl.php , book-node-export-html.tpl.php , profile-wrapper.tpl.php , maintenance-page.tpl.php , region.tpl.php , maintenance-page.tpl.php
  • $content_attributes : node.tpl.php , block.tpl.php , comment.tpl.php , field.tpl.php , node.tpl.php , overlay.tpl.php , comment.tpl.php , node.tpl.php , comment.tpl.php
  • $contents : book-export-html.tpl.php
  • $created : comment.tpl.php
  • $databases : default.settings.php
  • $depth : book-node-export-html.tpl.php
  • $dir : book-export-html.tpl.php
  • $div_close : book-export-html.tpl.php
  • $drupal_hash_salt : default.settings.php
  • $drupal_test_info : drupal_web_test_case.php
  • $feed_age : aggregator-summary-item.tpl.php
  • $feed_icons : page.tpl.php
  • $feed_title : aggregator-item.tpl.php , aggregator-summary-item.tpl.php
  • $feed_url : aggregator-item.tpl.php , aggregator-summary-item.tpl.php
  • $form_submit : block-admin-display-form.tpl.php
  • $forum_id : forum-list.tpl.php
  • $front_page : maintenance-page.tpl.php , page.tpl.php
  • $grddl_profile : html.tpl.php
  • $head : book-export-html.tpl.php , html.tpl.php , maintenance-page.tpl.php
  • $head_title : html.tpl.php , maintenance-page.tpl.php
  • $header : forum-topic-list.tpl.php , maintenance-page.tpl.php
  • $help : maintenance-page.tpl.php
  • $html_entities : unicode.entities.inc
  • $info : color.inc
  • $item_attributes : field.tpl.php
  • $last_checked : aggregator-feed-source.tpl.php
  • $links : poll-results--block.tpl.php , node.tpl.php
  • $logo : page.tpl.php , maintenance-page.tpl.php , page.tpl.php
  • $messages : page.tpl.php , maintenance-page.tpl.php , page.tpl.php
  • $module : search-results.tpl.php
  • $module_list : authorize.php
  • $name : profile-listing.tpl.php
  • $node_url : node.tpl.php
  • $op : update.php
  • $output : authorize.php
  • $page : overlay.tpl.php , html.tpl.php
  • $page_bottom : maintenance-page.tpl.php , html.tpl.php
  • $page_top : html.tpl.php , maintenance-page.tpl.php
  • $pager : forum-topic-list.tpl.php , search-results.tpl.php , aggregator-wrapper.tpl.php
  • $percentage : poll-bar--block.tpl.php , poll-bar.tpl.php
  • $permalink : comment.tpl.php
  • $picture : comment.tpl.php
  • $profile_items : user-profile-category.tpl.php
  • $rdf_namespaces : html.tpl.php
  • $results : poll-results.tpl.php
  • $row : block-admin-display-form.tpl.php
  • $scripts : maintenance-page.tpl.php , html.tpl.php , maintenance-page.tpl.php
  • $search_form : search-block-form.tpl.php
  • $search_results : search-results.tpl.php
  • $secondary_menu : page.tpl.php
  • $show_messages : authorize.php
  • $site_fields : maintenance-page.tpl.php
  • $site_html : maintenance-page.tpl.php
  • $site_name : page.tpl.php , maintenance-page.tpl.php , page.tpl.php
  • $site_slogan : maintenance-page.tpl.php , page.tpl.php
  • $site_title : maintenance-page.tpl.php
  • $snippet : search-result.tpl.php
  • $source_date : aggregator-item.tpl.php
  • $source_description : aggregator-feed-source.tpl.php
  • $source_icon : aggregator-feed-source.tpl.php
  • $source_image : aggregator-feed-source.tpl.php
  • $source_title : aggregator-item.tpl.php , aggregator-summary-item.tpl.php
  • $source_url : aggregator-summary-items.tpl.php , aggregator-feed-source.tpl.php
  • $styles : html.tpl.php , maintenance-page.tpl.php
  • $submitted : comment.tpl.php , node.tpl.php
  • $summary_list : aggregator-summary-items.tpl.php
  • $term_name : taxonomy-term.tpl.php
  • $text_form : theming-example-text-form.tpl.php
  • $title : node.tpl.php , book-export-html.tpl.php , accordion.tpl.php , search-result.tpl.php , user-profile-item.tpl.php , comment.tpl.php , contextual-links-example-object.tpl.php , poll-bar.tpl.php , poll-bar--block.tpl.php , aggregator-summary-items.tpl.php , overlay.tpl.php , book-node-export-html.tpl.php , node.tpl.php
  • $title_attributes : overlay.tpl.php , comment.tpl.php , search-result.tpl.php
  • $topic_id : forum-topic-list.tpl.php
  • $topics : forums.tpl.php
  • $tree : book-navigation.tpl.php
  • $update_free_access : default.settings.php
  • $url : search-result.tpl.php
  • $user_picture : profile-listing.tpl.php , node.tpl.php , profile-block.tpl.php
  • $value : user-profile-item.tpl.php
  • $vote : poll-vote.tpl.php
  • $zebra : comment.tpl.php
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- _ -

  • __pad0__ : forum-submitted.tpl.php , page.tpl.php , search-results.tpl.php
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- a -

  • AGGREGATOR_CLEAR_NEVER : aggregator.module
  • ARCHIVE_TAR_ATT_SEPARATOR : system.tar.inc
  • ARCHIVE_TAR_END_BLOCK : system.tar.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- b -

  • BLOCK_CUSTOM_DISABLED : block.module
  • BLOCK_CUSTOM_ENABLED : block.module
  • BLOCK_CUSTOM_FIXED : block.module
  • BLOCK_REGION_NONE : block.module
  • block_title : block-admin-display-form.tpl.php
  • BLOCK_VISIBILITY_LISTED : block.module
  • BLOCK_VISIBILITY_NOTLISTED : block.module
  • BLOCK_VISIBILITY_PHP : block.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- c -

  • CACHE_PERMANENT : bootstrap.inc
  • CACHE_TEMPORARY : bootstrap.inc
  • CHECK_PLAIN : bootstrap.inc
  • COMMENT_ANONYMOUS_MAY_CONTACT : comment.module
  • COMMENT_ANONYMOUS_MAYNOT_CONTACT : comment.module
  • COMMENT_ANONYMOUS_MUST_CONTACT : comment.module
  • COMMENT_FORM_BELOW : comment.module
  • COMMENT_FORM_SEPARATE_PAGE : comment.module
  • COMMENT_MODE_FLAT : comment.module
  • COMMENT_MODE_THREADED : comment.module
  • COMMENT_NODE_CLOSED : comment.module
  • COMMENT_NODE_HIDDEN : comment.module
  • COMMENT_NODE_OPEN : comment.module
  • COMMENT_NOT_PUBLISHED : comment.module
  • COMMENT_PUBLISHED : comment.module
  • configure_link : block-admin-display-form.tpl.php
  • created : forum-topic-list.tpl.php
  • CSS_DEFAULT : common.inc
  • CSS_SYSTEM : common.inc
  • CSS_THEME : common.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- d -

  • delete_link : block-admin-display-form.tpl.php
  • dir : html.tpl.php , maintenance-page.tpl.php
  • DRUPAL_ANONYMOUS_RID : bootstrap.inc
  • DRUPAL_AUTHENTICATED_RID : bootstrap.inc
  • DRUPAL_BOOTSTRAP_CONFIGURATION : bootstrap.inc
  • DRUPAL_BOOTSTRAP_DATABASE : bootstrap.inc
  • DRUPAL_BOOTSTRAP_FULL : bootstrap.inc
  • DRUPAL_BOOTSTRAP_LANGUAGE : bootstrap.inc
  • DRUPAL_BOOTSTRAP_PAGE_CACHE : bootstrap.inc
  • DRUPAL_BOOTSTRAP_PAGE_HEADER : bootstrap.inc
  • DRUPAL_BOOTSTRAP_SESSION : bootstrap.inc
  • DRUPAL_BOOTSTRAP_VARIABLES : bootstrap.inc
  • DRUPAL_CACHE_CUSTOM : common.inc
  • DRUPAL_CACHE_GLOBAL : common.inc
  • DRUPAL_CACHE_PER_PAGE : common.inc
  • DRUPAL_CACHE_PER_ROLE : common.inc
  • DRUPAL_CACHE_PER_USER : common.inc
  • DRUPAL_CORE_COMPATIBILITY : bootstrap.inc
  • DRUPAL_CRON_DEFAULT_THRESHOLD : system.module
  • DRUPAL_DISABLED : system.module
  • DRUPAL_HASH_COUNT : password.inc
  • DRUPAL_HASH_LENGTH : password.inc
  • DRUPAL_KILOBYTE : bootstrap.inc
  • DRUPAL_MAX_HASH_COUNT : password.inc
  • DRUPAL_MAXIMUM_TEMP_FILE_AGE : system.module
  • DRUPAL_MIN_HASH_COUNT : password.inc
  • DRUPAL_MINIMUM_PHP : bootstrap.inc
  • DRUPAL_MINIMUM_PHP_MEMORY_LIMIT : bootstrap.inc
  • DRUPAL_NO_CACHE : common.inc
  • DRUPAL_OPTIONAL : system.module
  • DRUPAL_PHP_FUNCTION_PATTERN : bootstrap.inc
  • DRUPAL_REQUIRED : system.module
  • DRUPAL_ROOT : cron.php , authorize.php , xmlrpc.php , index.php , update.php , statistics.php , install.php
  • DRUPAL_USER_TIMEZONE_DEFAULT : system.module
  • DRUPAL_USER_TIMEZONE_EMPTY : system.module
  • DRUPAL_USER_TIMEZONE_SELECT : system.module
  • DRUPAL_WEIGHT_SELECT_MAX : system.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- e -

  • else : authorize.php , cron.php , syslog.module , page.tpl.php , forum-topic-list.tpl.php , update.php
  • EMAIL_MAX_LENGTH : user.module
  • endfor : book-export-html.tpl.php
  • endforeach : block-admin-display-form.tpl.php , book-all-books-block.tpl.php , field.tpl.php , forum-list.tpl.php , forum-topic-list.tpl.php , profile-block.tpl.php , profile-listing.tpl.php
  • endif : toolbar.tpl.php , taxonomy-term.tpl.php , maintenance-page.tpl.php , page.tpl.php , maintenance-page.tpl.php , node.tpl.php , aggregator-item.tpl.php , search-block-form.tpl.php , profile-block.tpl.php , poll-vote.tpl.php , search-result.tpl.php , overlay.tpl.php , node.tpl.php , forums.tpl.php , forum-topic-list.tpl.php , forum-submitted.tpl.php , forum-list.tpl.php , field.tpl.php , user-profile-category.tpl.php , book-navigation.tpl.php , region.tpl.php , search-results.tpl.php , aggregator-summary-item.tpl.php , comment-wrapper.tpl.php , poll-results.tpl.php , page.tpl.php , comment-wrapper.tpl.php , block.tpl.php , node.tpl.php , maintenance-page.tpl.php , comment.tpl.php , user-picture.tpl.php
  • ERROR_REPORTING_DISPLAY_ALL : bootstrap.inc
  • ERROR_REPORTING_DISPLAY_SOME : bootstrap.inc
  • ERROR_REPORTING_HIDE : bootstrap.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- f -

  • FIELD_BEHAVIOR_CUSTOM : field.module
  • FIELD_BEHAVIOR_DEFAULT : field.module
  • FIELD_BEHAVIOR_NONE : field.module
  • FIELD_CARDINALITY_UNLIMITED : field.module
  • FIELD_LOAD_CURRENT : field.module
  • FIELD_LOAD_REVISION : field.module
  • FIELD_STORAGE_INSERT : field.attach.inc
  • FIELD_STORAGE_UPDATE : field.attach.inc
  • FILE_CREATE_DIRECTORY : file.inc
  • FILE_EXECUTABLE : install.inc
  • FILE_EXIST : install.inc
  • FILE_EXISTS_ERROR : file.inc
  • FILE_EXISTS_RENAME : file.inc
  • FILE_EXISTS_REPLACE : file.inc
  • FILE_MODIFY_PERMISSIONS : file.inc
  • FILE_NOT_EXECUTABLE : install.inc
  • FILE_NOT_EXIST : install.inc
  • FILE_NOT_READABLE : install.inc
  • FILE_NOT_WRITABLE : install.inc
  • FILE_READABLE : install.inc
  • FILE_STATUS_PERMANENT : file.inc
  • FILE_WRITABLE : install.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- h -

  • HTTP_REQUEST_TIMEOUT : common.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- i -

  • icon : forum-topic-list.tpl.php
  • icon_class : forum-list.tpl.php
  • icon_title : forum-list.tpl.php
  • if : install.php
  • IMAGE_DERIVATIVE_TOKEN : image.module
  • IMAGE_STORAGE_DEFAULT : image.module
  • IMAGE_STORAGE_EDITABLE : image.module
  • IMAGE_STORAGE_MODULE : image.module
  • IMAGE_STORAGE_NORMAL : image.module
  • IMAGE_STORAGE_OVERRIDE : image.module
  • INSTALL_TASK_RUN_IF_NOT_COMPLETED : install.core.inc
  • INSTALL_TASK_RUN_IF_REACHED : install.core.inc
  • INSTALL_TASK_SKIP : install.core.inc
  • is_container : forum-list.tpl.php
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- j -

  • JS_DEFAULT : common.inc
  • JS_LIBRARY : common.inc
  • JS_THEME : common.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- l -

  • language : book-export-html.tpl.php , html.tpl.php , maintenance-page.tpl.php
  • LANGUAGE_LTR : bootstrap.inc
  • LANGUAGE_NEGOTIATION_DEFAULT : language.inc
  • LANGUAGE_NONE : bootstrap.inc
  • LANGUAGE_RTL : bootstrap.inc
  • LANGUAGE_TYPE_CONTENT : bootstrap.inc
  • LANGUAGE_TYPE_INTERFACE : bootstrap.inc
  • LANGUAGE_TYPE_URL : bootstrap.inc
  • last_reply : forum-topic-list.tpl.php
  • link : forum-list.tpl.php
  • LOCALE_IMPORT_KEEP : locale.inc
  • LOCALE_IMPORT_OVERWRITE : locale.inc
  • LOCALE_JS_OBJECT : locale.inc
  • LOCALE_JS_OBJECT_CONTEXT : locale.inc
  • LOCALE_JS_STRING : locale.inc
  • LOCALE_LANGUAGE_NEGOTIATION_BROWSER : locale.inc
  • LOCALE_LANGUAGE_NEGOTIATION_INTERFACE : locale.inc
  • LOCALE_LANGUAGE_NEGOTIATION_SESSION : locale.inc
  • LOCALE_LANGUAGE_NEGOTIATION_URL : locale.inc
  • LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN : locale.inc
  • LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK : locale.inc
  • LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX : locale.inc
  • LOCALE_LANGUAGE_NEGOTIATION_USER : locale.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- m -

  • MAIL_LINE_ENDINGS : mail.inc
  • MAINTENANCE_MODE : authorize.php , update.php , install.php
  • MARK_NEW : theme.inc
  • MARK_READ : theme.inc
  • MARK_UPDATED : theme.inc
  • MENU_ACCESS_DENIED : menu.inc
  • MENU_CALLBACK : menu.inc
  • MENU_CONTEXT_INLINE : menu.inc
  • MENU_CONTEXT_NONE : menu.inc
  • MENU_CONTEXT_PAGE : menu.inc
  • MENU_CREATED_BY_ADMIN : menu.inc
  • MENU_DEFAULT_LOCAL_TASK : menu.inc
  • MENU_FOUND : menu.inc
  • MENU_IS_LOCAL_ACTION : menu.inc
  • MENU_IS_LOCAL_TASK : menu.inc
  • MENU_IS_ROOT : menu.inc
  • MENU_LINKS_TO_PARENT : menu.inc
  • MENU_LOCAL_ACTION : menu.inc
  • MENU_LOCAL_TASK : menu.inc
  • MENU_MAX_DEPTH : menu.inc
  • MENU_MAX_MENU_NAME_LENGTH_UI : menu.module
  • MENU_MAX_PARTS : menu.inc
  • MENU_MODIFIED_BY_ADMIN : menu.inc
  • MENU_NORMAL_ITEM : menu.inc
  • MENU_NOT_FOUND : menu.inc
  • MENU_PREFERRED_LINK : menu.inc
  • MENU_SITE_OFFLINE : menu.inc
  • MENU_SITE_ONLINE : menu.inc
  • MENU_SUGGESTED_ITEM : menu.inc
  • MENU_VISIBLE_IN_BREADCRUMB : menu.inc
  • MENU_VISIBLE_IN_TREE : menu.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- n -

  • name : forum-list.tpl.php
  • new_text : forum-list.tpl.php , forum-topic-list.tpl.php
  • nid : book-node-export-html.tpl.php , node.tpl.php
  • NODE_ACCESS_ALLOW : node.module
  • NODE_ACCESS_DENY : node.module
  • NODE_ACCESS_EXAMPLE_GRANT_ALL : node_access_example.module
  • NODE_ACCESS_IGNORE : node.module
  • NODE_NEW_LIMIT : node.module
  • NODE_NOT_PROMOTED : node.module
  • NODE_NOT_PUBLISHED : node.module
  • NODE_NOT_STICKY : node.module
  • NODE_PROMOTED : node.module
  • NODE_PUBLISHED : node.module
  • NODE_STICKY : node.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- o -

  • OPENID_DH_DEFAULT_GEN : openid.inc
  • OPENID_DH_DEFAULT_MOD : openid.inc
  • OPENID_NS_1_0 : openid.inc
  • OPENID_NS_1_1 : openid.inc
  • OPENID_NS_2_0 : openid.inc
  • OPENID_NS_AX : openid.inc
  • OPENID_NS_OPENID : openid.inc
  • OPENID_NS_SREG : openid.inc
  • OPENID_NS_XRD : openid.inc
  • OPENID_RAND_SOURCE : openid.inc
  • OPENID_SHA1_BLOCKSIZE : openid.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- p -

  • PASS_THROUGH : bootstrap.inc
  • POSTGRESQL_NEXTID_LOCK : database.inc
  • PREG_CLASS_CJK : search.module
  • PREG_CLASS_NUMBERS : search.module
  • PREG_CLASS_PUNCTUATION : search.module
  • PREG_CLASS_UNICODE_WORD_BOUNDARY : unicode.inc
  • print : php-2.php
  • PROFILE_HIDDEN : profile.module
  • PROFILE_PRIVATE : profile.module
  • PROFILE_PUBLIC : profile.module
  • PROFILE_PUBLIC_LISTINGS : profile.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- r -

  • RDF_DEFAULT_BUNDLE : rdf.module
  • region_select : block-admin-display-form.tpl.php
  • REGIONS_ALL : system.module
  • REGIONS_VISIBLE : system.module
  • REGISTRY_RESET_LOOKUP_CACHE : bootstrap.inc
  • REGISTRY_WRITE_LOOKUP_CACHE : bootstrap.inc
  • REQUEST_TIME : bootstrap.inc
  • REQUIRED_D6_SCHEMA_VERSION : update.inc
  • REQUIREMENT_ERROR : install.inc
  • REQUIREMENT_INFO : install.inc
  • REQUIREMENT_OK : install.inc
  • REQUIREMENT_WARNING : install.inc
  • row_class : block-admin-display-form.tpl.php
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- s -

  • SAVED_DELETED : common.inc
  • SAVED_NEW : common.inc
  • SAVED_UPDATED : common.inc
  • SCHEMA_INSTALLED : install.inc
  • SCHEMA_UNINSTALLED : install.inc
  • SHORTCUT_DEFAULT_SET_NAME : shortcut.module
  • SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT : simpletest.install
  • STREAM_WRAPPERS_ALL : stream_wrappers.inc
  • STREAM_WRAPPERS_HIDDEN : stream_wrappers.inc
  • STREAM_WRAPPERS_LOCAL : stream_wrappers.inc
  • STREAM_WRAPPERS_LOCAL_HIDDEN : stream_wrappers.inc
  • STREAM_WRAPPERS_LOCAL_NORMAL : stream_wrappers.inc
  • STREAM_WRAPPERS_NORMAL : stream_wrappers.inc
  • STREAM_WRAPPERS_READ : stream_wrappers.inc
  • STREAM_WRAPPERS_READ_VISIBLE : stream_wrappers.inc
  • STREAM_WRAPPERS_VISIBLE : stream_wrappers.inc
  • STREAM_WRAPPERS_WRITE : stream_wrappers.inc
  • STREAM_WRAPPERS_WRITE_VISIBLE : stream_wrappers.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- t -

  • tid : taxonomy-term.tpl.php
  • title : forum-topic-list.tpl.php
  • TRANSLATION_ENABLED : translation.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- u -

  • UNICODE_ERROR : unicode.inc
  • UNICODE_MULTIBYTE : unicode.inc
  • UNICODE_SINGLEBYTE : unicode.inc
  • UPDATE_CURRENT : update.module
  • UPDATE_DEFAULT_URL : update.module
  • UPDATE_FETCH_PENDING : update.module
  • UPDATE_MAX_FETCH_ATTEMPTS : update.module
  • UPDATE_MAX_FETCH_TIME : update.module
  • UPDATE_NOT_CHECKED : update.module
  • UPDATE_NOT_CURRENT : update.module
  • UPDATE_NOT_FETCHED : update.module
  • UPDATE_NOT_SECURE : update.module
  • UPDATE_NOT_SUPPORTED : update.module
  • UPDATE_REVOKED : update.module
  • UPDATE_UNKNOWN : update.module
  • USER_REGISTER_ADMINISTRATORS_ONLY : user.module
  • USER_REGISTER_VISITORS : user.module
  • USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL : user.module
  • USERNAME_MAX_LENGTH : user.module
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- v -

  • value : profile-block.tpl.php
  • VERSION : bootstrap.inc
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- w -

  • WATCHDOG_ALERT : bootstrap.inc
  • WATCHDOG_CRITICAL : bootstrap.inc
  • WATCHDOG_DEBUG : bootstrap.inc
  • WATCHDOG_EMERGENCY : bootstrap.inc
  • WATCHDOG_ERROR : bootstrap.inc
  • WATCHDOG_INFO : bootstrap.inc
  • WATCHDOG_NOTICE : bootstrap.inc
  • WATCHDOG_WARNING : bootstrap.inc
  • weight_select : block-admin-display-form.tpl.php
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: File Members

  • All
  • Functions
  • Variables
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z

- z -

  • zebra : forum-list.tpl.php
Generated on Mon Feb 3 2014 12:40:53 for Drupal 7 by doxygen 1.8.5


Drupal 7: Main Page

Drupal 7 Documentation
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Namespace List

  • Namespace List
Namespace List
Here is a list of all namespaces with brief descriptions:
\ N Archive_Tar
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Related Pages

Related Pages
Here is a list of all related documentation pages:
\ Deprecated List
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/simpletest/simpletest.api.php Source File

  • modules
  • simpletest
simpletest.api.php
Go to the documentation of this file.
1 <?php
2
21 function hook_simpletest_alter(&$groups) {
22 // An alternative session handler module would not want to run the original
23 // Session HTTPS handling test because it checks the sessions table in the
24 // database.
25 unset($groups['Session']['testHttpsSession']);
26 }
27
33 function hook_test_group_started() {
34 }
35
41 function hook_test_group_finished() {
42 }
43
54 function hook_test_finished($results) {
55 }
56
57
$results
print $results
Definition: poll-results.tpl.php:23
hook_test_group_finished
hook_test_group_finished()
Definition: simpletest.api.php:41
hook_test_finished
hook_test_finished($results)
Definition: simpletest.api.php:54
hook_simpletest_alter
hook_simpletest_alter(&$groups)
Definition: simpletest.api.php:21
hook_test_group_started
hook_test_group_started()
Definition: simpletest.api.php:33
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/overlay/overlay.install Source File

  • modules
  • overlay
overlay.install
Go to the documentation of this file.
1 <?php
2
14 function overlay_enable() {
15 if (strpos(current_path(), 'admin/modules') === 0) {
16 // Flag for a redirect to <front>#overlay=admin/modules on hook_init().
17 $_SESSION['overlay_enable_redirect'] = 1;
18 }
19 }
overlay_enable
overlay_enable()
Definition: overlay.install:14
current_path
current_path()
Definition: path.inc:354
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/filter/filter.api.php Source File

  • modules
  • filter
filter.api.php
Go to the documentation of this file.
1 <?php
2
80 function hook_filter_info() {
81 $filters['filter_html'] = array(
82 'title' => t('Limit allowed HTML tags'),
83 'description' => t('Allows you to restrict the HTML tags the user can use. It will also remove harmful content such as JavaScript events, JavaScript URLs and CSS styles from those tags that are not removed.'),
84 'process callback' => '_filter_html',
85 'settings callback' => '_filter_html_settings',
86 'default settings' => array(
87 'allowed_html' => '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>',
88 'filter_html_help' => 1,
89 'filter_html_nofollow' => 0,
90 ),
91 'tips callback' => '_filter_html_tips',
92 );
93 $filters['filter_autop'] = array(
94 'title' => t('Convert line breaks'),
95 'description' => t('Converts line breaks into HTML (i.e. &lt;br&gt; and &lt;p&gt;) tags.'),
96 'process callback' => '_filter_autop',
97 'tips callback' => '_filter_autop_tips',
98 );
99 return $filters;
100 }
101
109 function hook_filter_info_alter(&$info) {
110 // Replace the PHP evaluator process callback with an improved
111 // PHP evaluator provided by a module.
112 $info['php_code']['process callback'] = 'my_module_php_evaluator';
113
114 // Alter the default settings of the URL filter provided by core.
115 $info['filter_url']['default settings'] = array(
116 'filter_url_length' => 100,
117 );
118 }
119
162 function callback_filter_settings($form, &$form_state, $filter, $format, $defaults, $filters) {
163 $filter->settings += $defaults;
164
165 $elements = array();
166 $elements['nofollow'] = array(
167 '#type' => 'checkbox',
168 '#title' => t('Add rel="nofollow" to all links'),
169 '#default_value' => $filter->settings['nofollow'],
170 );
171 return $elements;
172 }
173
203 function callback_filter_prepare($text, $filter, $format, $langcode, $cache, $cache_id) {
204 // Escape <code> and </code> tags.
205 $text = preg_replace('|<code>(.+?)</code>|se', "[codefilter_code]$1[/codefilter_code]", $text);
206 return $text;
207 }
208
236 function callback_filter_process($text, $filter, $format, $langcode, $cache, $cache_id) {
237 $text = preg_replace('|\[codefilter_code\](.+?)\[/codefilter_code\]|se', "<pre>$1</pre>", $text);
238
239 return $text;
240 }
241
264 function callback_filter_tips($filter, $format, $long) {
265 if ($long) {
266 return t('Lines and paragraphs are automatically recognized. The &lt;br /&gt; line break, &lt;p&gt; paragraph and &lt;/p&gt; close paragraph tags are inserted automatically. If paragraphs are not recognized simply add a couple blank lines.');
267 }
268 else {
269 return t('Lines and paragraphs break automatically.');
270 }
271 }
272
287 function hook_filter_format_insert($format) {
288 mymodule_cache_rebuild();
289 }
290
304 function hook_filter_format_update($format) {
305 mymodule_cache_rebuild();
306 }
307
317 function hook_filter_format_disable($format) {
318 mymodule_cache_rebuild();
319 }
320
hook_filter_info_alter
hook_filter_info_alter(&$info)
Definition: filter.api.php:109
hook_filter_info
hook_filter_info()
Definition: filter.api.php:80
callback_filter_tips
callback_filter_tips($filter, $format, $long)
Definition: filter.api.php:264
callback_filter_prepare
callback_filter_prepare($text, $filter, $format, $langcode, $cache, $cache_id)
Definition: filter.api.php:203
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
callback_filter_settings
callback_filter_settings($form, &$form_state, $filter, $format, $defaults, $filters)
Definition: filter.api.php:162
hook_filter_format_insert
hook_filter_format_insert($format)
Definition: filter.api.php:287
$info
$info
Definition: color.inc:6
hook_filter_format_disable
hook_filter_format_disable($format)
Definition: filter.api.php:317
callback_filter_process
callback_filter_process($text, $filter, $format, $langcode, $cache, $cache_id)
Definition: filter.api.php:236
hook_filter_format_update
hook_filter_format_update($format)
Definition: filter.api.php:304
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment.pages.inc Source File

  • modules
  • comment
comment.pages.inc
Go to the documentation of this file.
1 <?php
2
33 function comment_reply($node, $pid = NULL) {
34 // Set the breadcrumb trail.
35 drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->title, 'node/' . $node->nid)));
36 $op = isset($_POST['op']) ? $_POST['op'] : '';
37 $build = array();
38
39 // The user is previewing a comment prior to submitting it.
40 if ($op == t('Preview')) {
41 if (user_access('post comments')) {
42 $build['comment_form'] = drupal_get_form("comment_node_{$node->type}_form", (object) array('pid' => $pid, 'nid' => $node->nid));
43 }
44 else {
45 drupal_set_message(t('You are not authorized to post comments.'), 'error');
46 drupal_goto("node/$node->nid");
47 }
48 }
49 else {
50 // $pid indicates that this is a reply to a comment.
51 if ($pid) {
52 if (user_access('access comments')) {
53 // Load the comment whose cid = $pid
54 $comment = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data FROM {comment} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = :cid AND c.status = :status', array(
55 ':cid' => $pid,
56 ':status' => COMMENT_PUBLISHED,
57 ))->fetchObject();
58 if ($comment) {
59 // If that comment exists, make sure that the current comment and the
60 // parent comment both belong to the same parent node.
61 if ($comment->nid != $node->nid) {
62 // Attempting to reply to a comment not belonging to the current nid.
63 drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
64 drupal_goto("node/$node->nid");
65 }
66 // Display the parent comment
67 $comment->node_type = 'comment_node_' . $node->type;
68 field_attach_load('comment', array($comment->cid => $comment));
69 $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
70 $build['comment_parent'] = comment_view($comment, $node);
71 }
72 else {
73 drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
74 drupal_goto("node/$node->nid");
75 }
76 }
77 else {
78 drupal_set_message(t('You are not authorized to view comments.'), 'error');
79 drupal_goto("node/$node->nid");
80 }
81 }
82 // This is the case where the comment is in response to a node. Display the node.
83 elseif (user_access('access content')) {
84 $build['comment_node'] = node_view($node);
85 }
86
87 // Should we show the reply box?
88 if ($node->comment != COMMENT_NODE_OPEN) {
89 drupal_set_message(t("This discussion is closed: you can't post new comments."), 'error');
90 drupal_goto("node/$node->nid");
91 }
92 elseif (user_access('post comments')) {
93 $edit = array('nid' => $node->nid, 'pid' => $pid);
94 $build['comment_form'] = drupal_get_form("comment_node_{$node->type}_form", (object) $edit);
95 }
96 else {
97 drupal_set_message(t('You are not authorized to post comments.'), 'error');
98 drupal_goto("node/$node->nid");
99 }
100 }
101
102 return $build;
103 }
104
111 function comment_approve($cid) {
112 if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], "comment/$cid/approve")) {
113 return MENU_ACCESS_DENIED;
114 }
115 if ($comment = comment_load($cid)) {
116 $comment->status = COMMENT_PUBLISHED;
117 comment_save($comment);
118
119 drupal_set_message(t('Comment approved.'));
120 drupal_goto('node/' . $comment->nid);
121 }
122 return MENU_NOT_FOUND;
123 }
$op
$op
Definition: update.php:404
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_set_breadcrumb
drupal_set_breadcrumb($breadcrumb=NULL)
Definition: common.inc:243
comment_save
comment_save($comment)
Definition: comment.module:1453
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
MENU_ACCESS_DENIED
const MENU_ACCESS_DENIED
Definition: menu.inc:239
comment_view
comment_view($comment, $node, $view_mode= 'full', $langcode=NULL)
Definition: comment.module:920
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
comment_approve
comment_approve($cid)
Definition: comment.pages.inc:111
MENU_NOT_FOUND
const MENU_NOT_FOUND
Definition: menu.inc:234
drupal_valid_token
drupal_valid_token($token, $value= '', $skip_anonymous=FALSE)
Definition: common.inc:5095
comment_load
comment_load($cid, $reset=FALSE)
Definition: comment.module:1683
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
field_attach_load
field_attach_load($entity_type, $entities, $age=FIELD_LOAD_CURRENT, $options=array())
Definition: field.attach.inc:622
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
comment_reply
comment_reply($node, $pid=NULL)
Definition: comment.pages.inc:33
COMMENT_NODE_OPEN
const COMMENT_NODE_OPEN
Definition: comment.module:70
COMMENT_PUBLISHED
const COMMENT_PUBLISHED
Definition: comment.module:20
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
node_view
node_view($node, $view_mode= 'full', $langcode=NULL)
Definition: node.module:1329
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/mysql/query.inc Source File

  • includes
  • database
  • mysql
query.inc
Go to the documentation of this file.
1 <?php
2
14 class InsertQuery_mysql extends InsertQuery {
15
16 public function execute() {
17 if (!$this->preExecute()) {
18 return NULL;
19 }
20
21 // If we're selecting from a SelectQuery, finish building the query and
22 // pass it back, as any remaining options are irrelevant.
23 if (empty($this->fromQuery)) {
24 $max_placeholder = 0;
25 $values = array();
26 foreach ($this->insertValues as $insert_values) {
27 foreach ($insert_values as $value) {
28 $values[':db_insert_placeholder_' . $max_placeholder++] = $value;
29 }
30 }
31 }
32 else {
33 $values = $this->fromQuery->getArguments();
34 }
35
36 $last_insert_id = $this->connection->query((string) $this, $values, $this->queryOptions);
37
38 // Re-initialize the values array so that we can re-use this query.
39 $this->insertValues = array();
40
41 return $last_insert_id;
42 }
43
44 public function __toString() {
45 // Create a sanitized comment string to prepend to the query.
46 $comments = $this->connection->makeComment($this->comments);
47
48 // Default fields are always placed first for consistency.
49 $insert_fields = array_merge($this->defaultFields, $this->insertFields);
50
51 // If we're selecting from a SelectQuery, finish building the query and
52 // pass it back, as any remaining options are irrelevant.
53 if (!empty($this->fromQuery)) {
54 $insert_fields_string = $insert_fields ? ' (' . implode(', ', $insert_fields) . ') ' : ' ';
55 return $comments . 'INSERT INTO {' . $this->table . '}' . $insert_fields_string . $this->fromQuery;
56 }
57
58 $query = $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES ';
59
60 $max_placeholder = 0;
61 $values = array();
62 if (count($this->insertValues)) {
63 foreach ($this->insertValues as $insert_values) {
64 $placeholders = array();
65
66 // Default fields aren't really placeholders, but this is the most convenient
67 // way to handle them.
68 $placeholders = array_pad($placeholders, count($this->defaultFields), 'default');
69
70 $new_placeholder = $max_placeholder + count($insert_values);
71 for ($i = $max_placeholder; $i < $new_placeholder; ++$i) {
72 $placeholders[] = ':db_insert_placeholder_' . $i;
73 }
74 $max_placeholder = $new_placeholder;
75 $values[] = '(' . implode(', ', $placeholders) . ')';
76 }
77 }
78 else {
79 // If there are no values, then this is a default-only query. We still need to handle that.
80 $placeholders = array_fill(0, count($this->defaultFields), 'default');
81 $values[] = '(' . implode(', ', $placeholders) . ')';
82 }
83
84 $query .= implode(', ', $values);
85
86 return $query;
87 }
88 }
89
90 class TruncateQuery_mysql extends TruncateQuery { }
91
InsertQuery\$fromQuery
$fromQuery
Definition: query.inc:486
InsertQuery_mysql\__toString
__toString()
Definition: query.inc:44
TruncateQuery_mysql
Definition: query.inc:90
InsertQuery\preExecute
preExecute()
Definition: query.inc:698
Query\$comments
$comments
Definition: query.inc:320
InsertQuery_mysql\execute
execute()
Definition: query.inc:16
InsertQuery
Definition: query.inc:441
$value
print $value
Definition: user-profile-item.tpl.php:26
InsertQuery_mysql
Definition: query.inc:14
TruncateQuery
Definition: query.inc:887
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll.module Source File

  • modules
  • poll
poll.module
Go to the documentation of this file.
1 <?php
2
12 function poll_help($path, $arg) {
13 switch ($path) {
14 case 'admin/help#poll':
15 $output = '';
16 $output .= '<h3>' . t('About') . '</h3>';
17 $output .= '<p>' . t('The Poll module can be used to create simple surveys or questionnaires that display cumulative results. A poll is a good way to receive feedback from site users and community members. For more information, see the online handbook entry for the <a href="@poll">Poll module</a>.', array('@poll' => 'http://drupal.org/documentation/modules/poll/')) . '</p>';
18 $output .= '<h3>' . t('Uses') . '</h3>';
19 $output .= '<dl>';
20 $output .= '<dt>' . t('Creating a poll') . '</dt>';
21 $output .= '<dd>' . t('Users can create a poll by clicking on Poll on the <a href="@add-content">Add new content</a> page, and entering the question being posed, the answer choices, and beginning vote counts for each choice. The status (closed or active) and duration (length of time the poll remains active for new votes) can also be specified.', array('@add-content' => url('node/add'))) . '</dd>';
22 $output .= '<dt>' . t('Viewing polls') . '</dt>';
23 $output .= '<dd>' . t('You can visit the <a href="@poll">Polls</a> page to view all current polls, or alternately enable the <em>Most recent poll</em> block on the <a href="@blocks">Blocks administration page</a>. To vote in or view the results of a specific poll, you can click on the poll itself.', array('@poll' => url('poll'), '@blocks' => url('admin/structure/block'))) . '</dd>';
24 $output .= '</dl>';
25 return $output;
26 }
27 }
28
32 function poll_theme() {
33 $theme_hooks = array(
34 'poll_vote' => array(
35 'template' => 'poll-vote',
36 'render element' => 'form',
37 ),
38 'poll_choices' => array(
39 'render element' => 'form',
40 ),
41 'poll_results' => array(
42 'template' => 'poll-results',
43 'variables' => array('raw_title' => NULL, 'results' => NULL, 'votes' => NULL, 'raw_links' => NULL, 'block' => NULL, 'nid' => NULL, 'vote' => NULL),
44 ),
45 'poll_bar' => array(
46 'template' => 'poll-bar',
47 'variables' => array('title' => NULL, 'votes' => NULL, 'total_votes' => NULL, 'vote' => NULL, 'block' => NULL),
48 ),
49 );
50 // The theme system automatically discovers the theme's functions and
51 // templates that implement more targeted "suggestions" of generic theme
52 // hooks. But suggestions implemented by a module must be explicitly
53 // registered.
54 $theme_hooks += array(
55 'poll_results__block' => array(
56 'template' => 'poll-results--block',
57 'variables' => $theme_hooks['poll_results']['variables'],
58 ),
59 'poll_bar__block' => array(
60 'template' => 'poll-bar--block',
61 'variables' => $theme_hooks['poll_bar']['variables'],
62 ),
63 );
64 return $theme_hooks;
65 }
66
70 function poll_permission() {
71 $perms = array(
72 'vote on polls' => array(
73 'title' => t('Vote on polls'),
74 ),
75 'cancel own vote' => array(
76 'title' => t('Cancel and change own votes'),
77 ),
78 'inspect all votes' => array(
79 'title' => t('View details for all votes'),
80 ),
81 );
82
83 return $perms;
84 }
85
89 function poll_menu() {
90 $items['poll'] = array(
91 'title' => 'Polls',
92 'page callback' => 'poll_page',
93 'access arguments' => array('access content'),
94 'type' => MENU_SUGGESTED_ITEM,
95 'file' => 'poll.pages.inc',
96 );
97
98 $items['node/%node/votes'] = array(
99 'title' => 'Votes',
100 'page callback' => 'poll_votes',
101 'page arguments' => array(1),
102 'access callback' => '_poll_menu_access',
103 'access arguments' => array(1, 'inspect all votes', FALSE),
104 'weight' => 3,
105 'type' => MENU_LOCAL_TASK,
106 'file' => 'poll.pages.inc',
107 );
108
109 $items['node/%node/results'] = array(
110 'title' => 'Results',
111 'page callback' => 'poll_results',
112 'page arguments' => array(1),
113 'access callback' => '_poll_menu_access',
114 'access arguments' => array(1, 'access content', TRUE),
115 'weight' => 3,
116 'type' => MENU_LOCAL_TASK,
117 'file' => 'poll.pages.inc',
118 );
119
120 return $items;
121 }
122
126 function _poll_menu_access($node, $perm, $inspect_allowvotes) {
127 return user_access($perm) && ($node->type == 'poll') && ($node->allowvotes || !$inspect_allowvotes);
128 }
129
133 function poll_block_info() {
134 $blocks['recent']['info'] = t('Most recent poll');
135 $blocks['recent']['properties']['administrative'] = TRUE;
136 return $blocks;
137 }
138
144 function poll_block_view($delta = '') {
145 if (user_access('access content')) {
146 // Retrieve the latest poll.
147 $select = db_select('node', 'n');
148 $select->join('poll', 'p', 'p.nid = n.nid');
149 $select->fields('n', array('nid'))
150 ->condition('n.status', 1)
151 ->condition('p.active', 1)
152 ->orderBy('n.created', 'DESC')
153 ->range(0, 1)
154 ->addTag('node_access');
155
156 $record = $select->execute()->fetchObject();
157 if ($record) {
158 $poll = node_load($record->nid);
159 if ($poll->nid) {
160 $poll = poll_block_latest_poll_view($poll);
161 $block['subject'] = t('Poll');
162 $block['content'] = $poll->content;
163 return $block;
164 }
165 }
166 }
167 }
168
174 function poll_cron() {
175 $nids = db_query('SELECT p.nid FROM {poll} p INNER JOIN {node} n ON p.nid = n.nid WHERE (n.created + p.runtime) < :request_time AND p.active = :active AND p.runtime <> :runtime', array(':request_time' => REQUEST_TIME, ':active' => 1, ':runtime' => 0))->fetchCol();
176 if (!empty($nids)) {
177 db_update('poll')
178 ->fields(array('active' => 0))
179 ->condition('nid', $nids, 'IN')
180 ->execute();
181 }
182 }
183
187 function poll_node_info() {
188 return array(
189 'poll' => array(
190 'name' => t('Poll'),
191 'base' => 'poll',
192 'description' => t('A <em>poll</em> is a question with a set of possible responses. A <em>poll</em>, once created, automatically provides a simple running count of the number of votes received for each response.'),
193 'title_label' => t('Question'),
194 'has_body' => FALSE,
195 )
196 );
197 }
198
202 function poll_field_extra_fields() {
203 $extra['node']['poll'] = array(
204 'form' => array(
205 'choice_wrapper' => array(
206 'label' => t('Poll choices'),
207 'description' => t('Poll choices'),
208 'weight' => -4,
209 ),
210 'settings' => array(
211 'label' => t('Poll settings'),
212 'description' => t('Poll module settings'),
213 'weight' => -3,
214 ),
215 ),
216 'display' => array(
217 'poll_view_voting' => array(
218 'label' => t('Poll vote'),
219 'description' => t('Poll vote'),
220 'weight' => 0,
221 ),
222 'poll_view_results' => array(
223 'label' => t('Poll results'),
224 'description' => t('Poll results'),
225 'weight' => 0,
226 ),
227 )
228 );
229
230 return $extra;
231 }
232
236 function poll_form($node, &$form_state) {
237 global $user;
238
239 $admin = user_access('bypass node access') || user_access('edit any poll content') || (user_access('edit own poll content') && $user->uid == $node->uid);
240
241 $type = node_type_get_type($node);
242
243 // The submit handlers to add more poll choices require that this form is
244 // cached, regardless of whether Ajax is used.
245 $form_state['cache'] = TRUE;
246
247 $form['title'] = array(
248 '#type' => 'textfield',
249 '#title' => check_plain($type->title_label),
250 '#required' => TRUE,
251 '#default_value' => $node->title,
252 '#weight' => -5,
253 );
254
255 if (isset($form_state['choice_count'])) {
256 $choice_count = $form_state['choice_count'];
257 }
258 else {
259 $choice_count = max(2, empty($node->choice) ? 2 : count($node->choice));
260 }
261
262 // Add a wrapper for the choices and more button.
263 $form['choice_wrapper'] = array(
264 '#tree' => FALSE,
265 '#weight' => -4,
266 '#prefix' => '<div class="clearfix" id="poll-choice-wrapper">',
267 '#suffix' => '</div>',
268 );
269
270 // Container for just the poll choices.
271 $form['choice_wrapper']['choice'] = array(
272 '#prefix' => '<div id="poll-choices">',
273 '#suffix' => '</div>',
274 '#theme' => 'poll_choices',
275 );
276
277 // Add the current choices to the form.
278 $delta = 0;
279 $weight = 0;
280 if (isset($node->choice)) {
281 $delta = count($node->choice);
282 foreach ($node->choice as $chid => $choice) {
283 $key = 'chid:' . $chid;
284 $form['choice_wrapper']['choice'][$key] = _poll_choice_form($key, $choice['chid'], $choice['chtext'], $choice['chvotes'], $choice['weight'], $choice_count);
285 $weight = max($choice['weight'], $weight);
286 }
287 }
288
289 // Add initial or additional choices.
290 $existing_delta = $delta;
291 for ($delta; $delta < $choice_count; $delta++) {
292 $key = 'new:' . ($delta - $existing_delta);
293 // Increase the weight of each new choice.
294 $weight++;
295 $form['choice_wrapper']['choice'][$key] = _poll_choice_form($key, NULL, '', 0, $weight, $choice_count);
296 }
297
298 // We name our button 'poll_more' to avoid conflicts with other modules using
299 // Ajax-enabled buttons with the id 'more'.
300 $form['choice_wrapper']['poll_more'] = array(
301 '#type' => 'submit',
302 '#value' => t('More choices'),
303 '#attributes' => array(
304 'title' => t("If the amount of boxes above isn't enough, click here to add more choices."),
305 ),
306 '#weight' => 1,
307 '#limit_validation_errors' => array(array('choice')),
308 '#submit' => array('poll_more_choices_submit'),
309 '#ajax' => array(
310 'callback' => 'poll_choice_js',
311 'wrapper' => 'poll-choices',
312 'effect' => 'fade',
313 ),
314 );
315
316 // Poll attributes
317 $duration = array(
318 // 1-6 days.
319 86400, 2 * 86400, 3 * 86400, 4 * 86400, 5 * 86400, 6 * 86400,
320 // 1-3 weeks (7 days).
321 604800, 2 * 604800, 3 * 604800,
322 // 1-3,6,9 months (30 days).
323 2592000, 2 * 2592000, 3 * 2592000, 6 * 2592000, 9 * 2592000,
324 // 1 year (365 days).
325 31536000,
326 );
327 $duration = array(0 => t('Unlimited')) + drupal_map_assoc($duration, 'format_interval');
328 $active = array(0 => t('Closed'), 1 => t('Active'));
329
330 $form['settings'] = array(
331 '#type' => 'fieldset',
332 '#collapsible' => TRUE,
333 '#title' => t('Poll settings'),
334 '#weight' => -3,
335 '#access' => $admin,
336 );
337
338 $form['settings']['active'] = array(
339 '#type' => 'radios',
340 '#title' => t('Poll status'),
341 '#default_value' => isset($node->active) ? $node->active : 1,
342 '#options' => $active,
343 '#description' => t('When a poll is closed, visitors can no longer vote for it.'),
344 '#access' => $admin,
345 );
346 $form['settings']['runtime'] = array(
347 '#type' => 'select',
348 '#title' => t('Poll duration'),
349 '#default_value' => isset($node->runtime) ? $node->runtime : 0,
350 '#options' => $duration,
351 '#description' => t('After this period, the poll will be closed automatically.'),
352 );
353
354 return $form;
355 }
356
366 function poll_more_choices_submit($form, &$form_state) {
367 // If this is a Ajax POST, add 1, otherwise add 5 more choices to the form.
368 if ($form_state['values']['poll_more']) {
369 $n = $_GET['q'] == 'system/ajax' ? 1 : 5;
370 $form_state['choice_count'] = count($form_state['values']['choice']) + $n;
371 }
372 // Renumber the choices. This invalidates the corresponding key/value
373 // associations in $form_state['input'], so clear that out. This requires
374 // poll_form() to rebuild the choices with the values in
375 // $form_state['node']->choice, which it does.
376 $form_state['node']->choice = array_values($form_state['values']['choice']);
377 unset($form_state['input']['choice']);
378 $form_state['rebuild'] = TRUE;
379 }
380
381 function _poll_choice_form($key, $chid = NULL, $value = '', $votes = 0, $weight = 0, $size = 10) {
382 $form = array(
383 '#tree' => TRUE,
384 '#weight' => $weight,
385 );
386
387 // We'll manually set the #parents property of these fields so that
388 // their values appear in the $form_state['values']['choice'] array.
389 $form['chid'] = array(
390 '#type' => 'value',
391 '#value' => $chid,
392 '#parents' => array('choice', $key, 'chid'),
393 );
394
395 $form['chtext'] = array(
396 '#type' => 'textfield',
397 '#title' => $value !== '' ? t('Choice label') : t('New choice label'),
398 '#title_display' => 'invisible',
399 '#default_value' => $value,
400 '#parents' => array('choice', $key, 'chtext'),
401 );
402
403 $form['chvotes'] = array(
404 '#type' => 'textfield',
405 '#title' => $value !== '' ? t('Vote count for choice @label', array('@label' => $value)) : t('Vote count for new choice'),
406 '#title_display' => 'invisible',
407 '#default_value' => $votes,
408 '#size' => 5,
409 '#maxlength' => 7,
410 '#parents' => array('choice', $key, 'chvotes'),
411 '#access' => user_access('administer nodes'),
412 '#element_validate' => array('element_validate_integer'),
413 );
414
415 $form['weight'] = array(
416 '#type' => 'weight',
417 '#title' => $value !== '' ? t('Weight for choice @label', array('@label' => $value)) : t('Weight for new choice'),
418 '#title_display' => 'invisible',
419 '#default_value' => $weight,
420 '#delta' => $size,
421 '#parents' => array('choice', $key, 'weight'),
422 );
423
424 return $form;
425 }
426
435 function poll_choice_js($form, $form_state) {
436 return $form['choice_wrapper']['choice'];
437 }
438
445 function poll_node_form_submit(&$form, &$form_state) {
446 // Renumber choices.
447 $form_state['values']['choice'] = array_values($form_state['values']['choice']);
448 $form_state['values']['teaser'] = poll_teaser((object) $form_state['values']);
449 }
450
454 function poll_validate($node, $form) {
455 if (isset($node->title)) {
456 // Check for at least two options and validate amount of votes.
457 $realchoices = 0;
458 foreach ($node->choice as $i => $choice) {
459 if ($choice['chtext'] != '') {
460 $realchoices++;
461 }
462 if (isset($choice['chvotes']) && $choice['chvotes'] < 0) {
463 form_set_error("choice][$i][chvotes", t('Negative values are not allowed.'));
464 }
465 }
466
467 if ($realchoices < 2) {
468 form_set_error("choice][$realchoices][chtext", t('You must fill in at least two choices.'));
469 }
470 }
471 }
472
476 function poll_field_attach_prepare_translation_alter(&$entity, $context) {
477 if ($context['entity_type'] == 'node' && $entity->type == 'poll') {
478 $entity->choice = $context['source_entity']->choice;
479 foreach ($entity->choice as $i => $options) {
480 $entity->choice[$i]['chvotes'] = 0;
481 }
482 }
483 }
484
488 function poll_load($nodes) {
489 global $user;
490 foreach ($nodes as $node) {
491 $poll = db_query("SELECT runtime, active FROM {poll} WHERE nid = :nid", array(':nid' => $node->nid))->fetchObject();
492
493 if (empty($poll)) {
494 $poll = new stdClass();
495 }
496
497 // Load the appropriate choices into the $poll object.
498 $poll->choice = db_select('poll_choice', 'c')
499 ->addTag('translatable')
500 ->fields('c', array('chid', 'chtext', 'chvotes', 'weight'))
501 ->condition('c.nid', $node->nid)
502 ->orderBy('weight')
503 ->execute()->fetchAllAssoc('chid', PDO::FETCH_ASSOC);
504
505 // Determine whether or not this user is allowed to vote.
506 $poll->allowvotes = FALSE;
507 if (user_access('vote on polls') && $poll->active) {
508 if ($user->uid) {
509 // If authenticated, find existing vote based on uid.
510 $poll->vote = db_query('SELECT chid FROM {poll_vote} WHERE nid = :nid AND uid = :uid', array(':nid' => $node->nid, ':uid' => $user->uid))->fetchField();
511 if (empty($poll->vote)) {
512 $poll->vote = -1;
513 $poll->allowvotes = TRUE;
514 }
515 }
516 elseif (!empty($_SESSION['poll_vote'][$node->nid])) {
517 // Otherwise the user is anonymous. Look for an existing vote in the
518 // user's session.
519 $poll->vote = $_SESSION['poll_vote'][$node->nid];
520 }
521 else {
522 // Finally, query the database for an existing vote based on anonymous
523 // user's hostname.
524 $poll->allowvotes = !db_query("SELECT 1 FROM {poll_vote} WHERE nid = :nid AND hostname = :hostname AND uid = 0", array(':nid' => $node->nid, ':hostname' => ip_address()))->fetchField();
525 }
526 }
527 foreach ($poll as $key => $value) {
528 $nodes[$node->nid]->$key = $value;
529 }
530 }
531 }
532
536 function poll_insert($node) {
537 if (!user_access('administer nodes')) {
538 // Make sure all votes are 0 initially
539 foreach ($node->choice as $i => $choice) {
540 $node->choice[$i]['chvotes'] = 0;
541 }
542 $node->active = 1;
543 }
544
545 db_insert('poll')
546 ->fields(array(
547 'nid' => $node->nid,
548 'runtime' => $node->runtime,
549 'active' => $node->active,
550 ))
551 ->execute();
552
553 foreach ($node->choice as $choice) {
554 if ($choice['chtext'] != '') {
555 db_insert('poll_choice')
556 ->fields(array(
557 'nid' => $node->nid,
558 'chtext' => $choice['chtext'],
559 'chvotes' => $choice['chvotes'],
560 'weight' => $choice['weight'],
561 ))
562 ->execute();
563 }
564 }
565 }
566
570 function poll_update($node) {
571 // Update poll settings.
572 db_update('poll')
573 ->fields(array(
574 'runtime' => $node->runtime,
575 'active' => $node->active,
576 ))
577 ->condition('nid', $node->nid)
578 ->execute();
579
580 // Poll choices with empty titles signifies removal. We remove all votes to
581 // the removed options, so people who voted on them can vote again.
582 foreach ($node->choice as $key => $choice) {
583 if (!empty($choice['chtext'])) {
584 db_merge('poll_choice')
585 ->key(array('chid' => $choice['chid']))
586 ->fields(array(
587 'chtext' => $choice['chtext'],
588 'chvotes' => (int) $choice['chvotes'],
589 'weight' => $choice['weight'],
590 ))
591 ->insertFields(array(
592 'nid' => $node->nid,
593 'chtext' => $choice['chtext'],
594 'chvotes' => (int) $choice['chvotes'],
595 'weight' => $choice['weight'],
596 ))
597 ->execute();
598 }
599 else {
600 db_delete('poll_vote')
601 ->condition('nid', $node->nid)
602 ->condition('chid', $key)
603 ->execute();
604 db_delete('poll_choice')
605 ->condition('nid', $node->nid)
606 ->condition('chid', $choice['chid'])
607 ->execute();
608 }
609 }
610 }
611
615 function poll_delete($node) {
616 db_delete('poll')
617 ->condition('nid', $node->nid)
618 ->execute();
619 db_delete('poll_choice')
620 ->condition('nid', $node->nid)
621 ->execute();
622 db_delete('poll_vote')
623 ->condition('nid', $node->nid)
624 ->execute();
625 }
626
633 function poll_block_latest_poll_view($node) {
634 global $user;
635 $output = '';
636
637 // This is necessary for shared objects because PHP doesn't copy objects, but
638 // passes them by reference. So when the objects are cached it can result in
639 // the wrong output being displayed on subsequent calls. The cloning and
640 // unsetting of $node->content prevents the block output from being the same
641 // as the node output.
642 $node = clone $node;
643 unset($node->content);
644
645 // No 'read more' link.
646 $node->readmore = FALSE;
647 $node->teaser = '';
648
649 $links = array();
650 $links[] = array('title' => t('Older polls'), 'href' => 'poll', 'attributes' => array('title' => t('View the list of polls on this site.')));
651 if ($node->allowvotes) {
652 $links[] = array('title' => t('Results'), 'href' => 'node/' . $node->nid . '/results', 'attributes' => array('title' => t('View the current poll results.')));
653 }
654
655 $node->links = $links;
656
657 if (!empty($node->allowvotes)) {
658 $node->content['poll_view_voting'] = drupal_get_form('poll_view_voting', $node, TRUE);
659 $node->content['links'] = array(
660 '#theme' => 'links',
661 '#links' => $node->links,
662 '#weight' => 5,
663 );
664 }
665 else {
666 $node->content['poll_view_results'] = array('#markup' => poll_view_results($node, TRUE, TRUE));
667 }
668
669 return $node;
670 }
671
672
676 function poll_view($node, $view_mode) {
677 global $user;
678 $output = '';
679
680 if (!empty($node->allowvotes) && empty($node->show_results)) {
681 $node->content['poll_view_voting'] = drupal_get_form('poll_view_voting', $node);
682 }
683 else {
684 $node->content['poll_view_results'] = array('#markup' => poll_view_results($node, $view_mode));
685 }
686 return $node;
687 }
688
694 function poll_teaser($node) {
695 $teaser = NULL;
696 if (is_array($node->choice)) {
697 foreach ($node->choice as $k => $choice) {
698 if ($choice['chtext'] != '') {
699 $teaser .= '* ' . check_plain($choice['chtext']) . "\n";
700 }
701 }
702 }
703 return $teaser;
704 }
705
713 function poll_view_voting($form, &$form_state, $node, $block = FALSE) {
714 if ($node->choice) {
715 $list = array();
716 foreach ($node->choice as $i => $choice) {
717 $list[$i] = check_plain($choice['chtext']);
718 }
719 $form['choice'] = array(
720 '#type' => 'radios',
721 '#title' => t('Choices'),
722 '#title_display' => 'invisible',
723 '#default_value' => -1,
724 '#options' => $list,
725 );
726 }
727
728 $form['vote'] = array(
729 '#type' => 'submit',
730 '#value' => t('Vote'),
731 '#submit' => array('poll_vote'),
732 );
733
734 // Store the node so we can get to it in submit functions.
735 $form['#node'] = $node;
736 $form['#block'] = $block;
737
738 // Set form caching because we could have multiple of these forms on
739 // the same page, and we want to ensure the right one gets picked.
740 $form_state['cache'] = TRUE;
741
742 // Provide a more cleanly named voting form theme.
743 $form['#theme'] = 'poll_vote';
744 return $form;
745 }
746
750 function poll_view_voting_validate($form, &$form_state) {
751 if ($form_state['values']['choice'] == -1) {
752 form_set_error( 'choice', t('Your vote could not be recorded because you did not select any of the choices.'));
753 }
754 }
755
759 function poll_vote($form, &$form_state) {
760 $node = $form['#node'];
761 $choice = $form_state['values']['choice'];
762
763 global $user;
764 db_insert('poll_vote')
765 ->fields(array(
766 'nid' => $node->nid,
767 'chid' => $choice,
768 'uid' => $user->uid,
769 'hostname' => ip_address(),
770 'timestamp' => REQUEST_TIME,
771 ))
772 ->execute();
773
774 // Add one to the votes.
775 db_update('poll_choice')
776 ->expression('chvotes', 'chvotes + 1')
777 ->condition('chid', $choice)
778 ->execute();
779
780 cache_clear_all();
781
782 if (!$user->uid) {
783 // The vote is recorded so the user gets the result view instead of the
784 // voting form when viewing the poll. Saving a value in $_SESSION has the
785 // convenient side effect of preventing the user from hitting the page
786 // cache. When anonymous voting is allowed, the page cache should only
787 // contain the voting form, not the results.
788 $_SESSION['poll_vote'][$node->nid] = $choice;
789 }
790
791 drupal_set_message(t('Your vote was recorded.'));
792
793 // Return the user to whatever page they voted from.
794 }
795
801 function template_preprocess_poll_vote(&$variables) {
802 $form = $variables['form'];
803 $variables['choice'] = drupal_render($form['choice']);
804 $variables['title'] = check_plain($form['#node']->title);
805 $variables['vote'] = drupal_render($form['vote']);
806 $variables['rest'] = drupal_render_children($form);
807 $variables['block'] = $form['#block'];
808 if ($variables['block']) {
809 $variables['theme_hook_suggestions'][] = 'poll_vote__block';
810 }
811 }
812
816 function poll_view_results($node, $view_mode, $block = FALSE) {
817 // Make sure that choices are ordered by their weight.
818 uasort($node->choice, 'drupal_sort_weight');
819
820 // Count the votes and find the maximum.
821 $total_votes = 0;
822 $max_votes = 0;
823 foreach ($node->choice as $choice) {
824 if (isset($choice['chvotes'])) {
825 $total_votes += $choice['chvotes'];
826 $max_votes = max($max_votes, $choice['chvotes']);
827 }
828 }
829
830 $poll_results = '';
831 foreach ($node->choice as $i => $choice) {
832 if (!empty($choice['chtext'])) {
833 $chvotes = isset($choice['chvotes']) ? $choice['chvotes'] : NULL;
834 $poll_results .= theme('poll_bar', array('title' => $choice['chtext'], 'votes' => $chvotes, 'total_votes' => $total_votes, 'vote' => isset($node->vote) && $node->vote == $i, 'block' => $block));
835 }
836 }
837
838 return theme('poll_results', array('raw_title' => $node->title, 'results' => $poll_results, 'votes' => $total_votes, 'raw_links' => isset($node->links) ? $node->links : array(), 'block' => $block, 'nid' => $node->nid, 'vote' => isset($node->vote) ? $node->vote : NULL));
839 }
840
841
851 function theme_poll_choices($variables) {
852 $form = $variables['form'];
853
854 drupal_add_tabledrag('poll-choice-table', 'order', 'sibling', 'poll-weight');
855
856 $is_admin= user_access('administer nodes');
857 $delta = 0;
858 $rows = array();
859 $headers = array('', t('Choice'));
860 if ($is_admin) {
861 $headers[] = t('Vote count');
862 }
863 $headers[] = t('Weight');
864
865 foreach (element_children($form) as $key) {
866 $delta++;
867 // Set special classes for drag and drop updating.
868 $form[$key]['weight']['#attributes']['class'] = array('poll-weight');
869
870 // Build the table row.
871 $row = array(
872 'data' => array(
873 array('class' => array('choice-flag')),
874 drupal_render($form[$key]['chtext']),
875 ),
876 'class' => array('draggable'),
877 );
878 if ($is_admin) {
879 $row['data'][] = drupal_render($form[$key]['chvotes']);
880 }
881 $row['data'][] = drupal_render($form[$key]['weight']);
882
883 // Add any additional classes set on the row.
884 if (!empty($form[$key]['#attributes']['class'])) {
885 $row['class'] = array_merge($row['class'], $form[$key]['#attributes']['class']);
886 }
887
888 $rows[] = $row;
889 }
890
891 $output = theme('table', array('header' => $headers, 'rows' => $rows, 'attributes' => array('id' => 'poll-choice-table')));
892 $output .= drupal_render_children($form);
893 return $output;
894 }
895
908 function template_preprocess_poll_results(&$variables) {
909 $variables['links'] = theme('links__poll_results', array('links' => $variables['raw_links']));
910 if (isset($variables['vote']) && $variables['vote'] > -1 && user_access('cancel own vote')) {
911 $elements = drupal_get_form('poll_cancel_form', $variables['nid']);
912 $variables['cancel_form'] = drupal_render($elements);
913 }
914 $variables['title'] = check_plain($variables['raw_title']);
915
916 if ($variables['block']) {
917 $variables['theme_hook_suggestions'][] = 'poll_results__block';
918 }
919 }
920
930 function template_preprocess_poll_bar(&$variables) {
931 if ($variables['block']) {
932 $variables['theme_hook_suggestions'][] = 'poll_bar__block';
933 }
934 $variables['title'] = check_plain($variables['title']);
935 $variables['percentage'] = round($variables['votes'] * 100 / max($variables['total_votes'], 1));
936 }
937
944 function poll_cancel_form($form, &$form_state, $nid) {
945 $form_state['cache'] = TRUE;
946
947 // Store the nid so we can get to it in submit functions.
948 $form['#nid'] = $nid;
949
950 $form['actions'] = array('#type' => 'actions');
951 $form['actions']['submit'] = array(
952 '#type' => 'submit',
953 '#value' => t('Cancel your vote'),
954 '#submit' => array('poll_cancel')
955 );
956
957 return $form;
958 }
959
963 function poll_cancel($form, &$form_state) {
964 global $user;
965 $node = node_load($form['#nid']);
966
967 db_delete('poll_vote')
968 ->condition('nid', $node->nid)
969 ->condition($user->uid ? 'uid' : 'hostname', $user->uid ? $user->uid : ip_address())
970 ->execute();
971
972 // Subtract from the votes.
973 db_update('poll_choice')
974 ->expression('chvotes', 'chvotes - 1')
975 ->condition('chid', $node->vote)
976 ->execute();
977
978 unset($_SESSION['poll_vote'][$node->nid]);
979
980 drupal_set_message(t('Your vote was cancelled.'));
981 }
982
986 function poll_user_cancel($edit, $account, $method) {
987 switch ($method) {
988 case 'user_cancel_reassign':
989 db_update('poll_vote')
990 ->fields(array('uid' => 0))
991 ->condition('uid', $account->uid)
992 ->execute();
993 break;
994 }
995 }
996
1000 function poll_user_delete($account) {
1001 db_delete('poll_vote')
1002 ->condition('uid', $account->uid)
1003 ->execute();
1004 }
1005
1009 function poll_rdf_mapping() {
1010 return array(
1011 array(
1012 'type' => 'node',
1013 'bundle' => 'poll',
1014 'mapping' => array(
1015 'rdftype' => array('sioc:Post', 'sioct:Poll'),
1016 ),
1017 ),
1018 );
1019 }
poll_delete
poll_delete($node)
Definition: poll.module:615
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
poll_field_extra_fields
poll_field_extra_fields()
Definition: poll.module:202
_poll_menu_access
_poll_menu_access($node, $perm, $inspect_allowvotes)
Definition: poll.module:126
template_preprocess_poll_vote
template_preprocess_poll_vote(&$variables)
Definition: poll.module:801
poll_node_info
poll_node_info()
Definition: poll.module:187
poll_teaser
poll_teaser($node)
Definition: poll.module:694
poll_view_voting
poll_view_voting($form, &$form_state, $node, $block=FALSE)
Definition: poll.module:713
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
poll_help
poll_help($path, $arg)
Definition: poll.module:12
theme_poll_choices
theme_poll_choices($variables)
Definition: poll.module:851
poll_field_attach_prepare_translation_alter
poll_field_attach_prepare_translation_alter(&$entity, $context)
Definition: poll.module:476
poll_view_voting_validate
poll_view_voting_validate($form, &$form_state)
Definition: poll.module:750
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
node_type_get_type
node_type_get_type($node)
Definition: node.module:410
template_preprocess_poll_results
template_preprocess_poll_results(&$variables)
Definition: poll.module:908
poll_rdf_mapping
poll_rdf_mapping()
Definition: poll.module:1009
poll_user_cancel
poll_user_cancel($edit, $account, $method)
Definition: poll.module:986
poll_choice_js
poll_choice_js($form, $form_state)
Definition: poll.module:435
poll_update
poll_update($node)
Definition: poll.module:570
ip_address
ip_address()
Definition: bootstrap.inc:2890
poll_node_form_submit
poll_node_form_submit(&$form, &$form_state)
Definition: poll.module:445
_poll_choice_form
_poll_choice_form($key, $chid=NULL, $value= '', $votes=0, $weight=0, $size=10)
Definition: poll.module:381
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
poll_insert
poll_insert($node)
Definition: poll.module:536
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
poll_cron
poll_cron()
Definition: poll.module:174
poll_view
poll_view($node, $view_mode)
Definition: poll.module:676
poll_vote
poll_vote($form, &$form_state)
Definition: poll.module:759
poll_block_latest_poll_view
poll_block_latest_poll_view($node)
Definition: poll.module:633
$value
print $value
Definition: user-profile-item.tpl.php:26
poll_block_info
poll_block_info()
Definition: poll.module:133
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
$choice
print $choice
Definition: poll-vote.tpl.php:25
MENU_SUGGESTED_ITEM
const MENU_SUGGESTED_ITEM
Definition: menu.inc:161
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$row
$row
Definition: block-admin-display-form.tpl.php:47
title
print $topic title
Definition: forum-topic-list.tpl.php:50
poll_load
poll_load($nodes)
Definition: poll.module:488
poll_block_view
poll_block_view($delta= '')
Definition: poll.module:144
poll_user_delete
poll_user_delete($account)
Definition: poll.module:1000
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
poll_theme
poll_theme()
Definition: poll.module:32
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
poll_cancel
poll_cancel($form, &$form_state)
Definition: poll.module:963
template_preprocess_poll_bar
template_preprocess_poll_bar(&$variables)
Definition: poll.module:930
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
poll_menu
poll_menu()
Definition: poll.module:89
poll_cancel_form
poll_cancel_form($form, &$form_state, $nid)
Definition: poll.module:944
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
poll_permission
poll_permission()
Definition: poll.module:70
poll_form
poll_form($node, &$form_state)
Definition: poll.module:236
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
$links
print $links
Definition: poll-results--block.tpl.php:28
poll_more_choices_submit
poll_more_choices_submit($form, &$form_state)
Definition: poll.module:366
poll_view_results
poll_view_results($node, $view_mode, $block=FALSE)
Definition: poll.module:816
poll_validate
poll_validate($node, $form)
Definition: poll.module:454
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
TaxonomyVocabularyController Member List

This is the complete list of members for TaxonomyVocabularyController, including all inherited members.

$cache | DrupalDefaultEntityController | protected
$entityCache | DrupalDefaultEntityController | protected
$entityInfo | DrupalDefaultEntityController | protected
$entityType | DrupalDefaultEntityController | protected
$hookLoadArguments | DrupalDefaultEntityController | protected
$idKey | DrupalDefaultEntityController | protected
$revisionKey | DrupalDefaultEntityController | protected
$revisionTable | DrupalDefaultEntityController | protected
__construct($entityType) | DrupalDefaultEntityController |
attachLoad(&$queried_entities, $revision_id=FALSE) | DrupalDefaultEntityController | protected
buildQuery($ids, $conditions=array(), $revision_id=FALSE) | TaxonomyVocabularyController | protected
cacheGet($ids, $conditions=array()) | DrupalDefaultEntityController | protected
cacheSet($entities) | DrupalDefaultEntityController | protected
load($ids=array(), $conditions=array()) | DrupalDefaultEntityController |
resetCache(array $ids=NULL) | DrupalDefaultEntityController |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/number/number.module Source File

  • modules
  • field
  • modules
  • number
number.module
Go to the documentation of this file.
1 <?php
2
11 function number_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#number':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t('The Number module defines various numeric field types for the Field module. Numbers can be in integer, decimal, or floating-point form, and they can be formatted when displayed. Number fields can be limited to a specific set of input values or to a range of values. See the <a href="@field-help">Field module help page</a> for more information about fields.', array('@field-help' => url('admin/help/field'))) . '</p>';
17 return $output;
18 }
19 }
20
24 function number_field_info() {
25 return array(
26 'number_integer' => array(
27 'label' => t('Integer'),
28 'description' => t('This field stores a number in the database as an integer.'),
29 'instance_settings' => array('min' => '', 'max' => '', 'prefix' => '', 'suffix' => ''),
30 'default_widget' => 'number',
31 'default_formatter' => 'number_integer',
32 ),
33 'number_decimal' => array(
34 'label' => t('Decimal'),
35 'description' => t('This field stores a number in the database in a fixed decimal format.'),
36 'settings' => array('precision' => 10, 'scale' => 2, 'decimal_separator' => '.'),
37 'instance_settings' => array('min' => '', 'max' => '', 'prefix' => '', 'suffix' => ''),
38 'default_widget' => 'number',
39 'default_formatter' => 'number_decimal',
40 ),
41 'number_float' => array(
42 'label' => t('Float'),
43 'description' => t('This field stores a number in the database in a floating point format.'),
44 'settings' => array('decimal_separator' => '.'),
45 'instance_settings' => array('min' => '', 'max' => '', 'prefix' => '', 'suffix' => ''),
46 'default_widget' => 'number',
47 'default_formatter' => 'number_decimal',
48 ),
49 );
50 }
51
55 function number_field_settings_form($field, $instance, $has_data) {
56 $settings = $field['settings'];
57 $form = array();
58
59 if ($field['type'] == 'number_decimal') {
60 $form['precision'] = array(
61 '#type' => 'select',
62 '#title' => t('Precision'),
63 '#options' => drupal_map_assoc(range(10, 32)),
64 '#default_value' => $settings['precision'],
65 '#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'),
66 '#disabled' => $has_data,
67 );
68 $form['scale'] = array(
69 '#type' => 'select',
70 '#title' => t('Scale'),
71 '#options' => drupal_map_assoc(range(0, 10)),
72 '#default_value' => $settings['scale'],
73 '#description' => t('The number of digits to the right of the decimal.'),
74 '#disabled' => $has_data,
75 );
76 }
77 if ($field['type'] == 'number_decimal' || $field['type'] == 'number_float') {
78 $form['decimal_separator'] = array(
79 '#type' => 'select',
80 '#title' => t('Decimal marker'),
81 '#options' => array('.' => t('Decimal point'), ',' => t('Comma')),
82 '#default_value' => $settings['decimal_separator'],
83 '#description' => t('The character users will input to mark the decimal point in forms.'),
84 );
85 }
86
87 return $form;
88 }
89
93 function number_field_instance_settings_form($field, $instance) {
94 $settings = $instance['settings'];
95
96 $form['min'] = array(
97 '#type' => 'textfield',
98 '#title' => t('Minimum'),
99 '#default_value' => $settings['min'],
100 '#description' => t('The minimum value that should be allowed in this field. Leave blank for no minimum.'),
101 '#element_validate' => array('element_validate_number'),
102 );
103 $form['max'] = array(
104 '#type' => 'textfield',
105 '#title' => t('Maximum'),
106 '#default_value' => $settings['max'],
107 '#description' => t('The maximum value that should be allowed in this field. Leave blank for no maximum.'),
108 '#element_validate' => array('element_validate_number'),
109 );
110 $form['prefix'] = array(
111 '#type' => 'textfield',
112 '#title' => t('Prefix'),
113 '#default_value' => $settings['prefix'],
114 '#size' => 60,
115 '#description' => t("Define a string that should be prefixed to the value, like '$ ' or '&euro; '. Leave blank for none. Separate singular and plural values with a pipe ('pound|pounds')."),
116 );
117 $form['suffix'] = array(
118 '#type' => 'textfield',
119 '#title' => t('Suffix'),
120 '#default_value' => $settings['suffix'],
121 '#size' => 60,
122 '#description' => t("Define a string that should be suffixed to the value, like ' m', ' kb/s'. Leave blank for none. Separate singular and plural values with a pipe ('pound|pounds')."),
123 );
124
125 return $form;
126 }
127
135 function number_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
136 foreach ($items as $delta => $item) {
137 if ($item['value'] != '') {
138 if (is_numeric($instance['settings']['min']) && $item['value'] < $instance['settings']['min']) {
139 $errors[$field['field_name']][$langcode][$delta][] = array(
140 'error' => 'number_min',
141 'message' => t('%name: the value may be no less than %min.', array('%name' => $instance['label'], '%min' => $instance['settings']['min'])),
142 );
143 }
144 if (is_numeric($instance['settings']['max']) && $item['value'] > $instance['settings']['max']) {
145 $errors[$field['field_name']][$langcode][$delta][] = array(
146 'error' => 'number_max',
147 'message' => t('%name: the value may be no greater than %max.', array('%name' => $instance['label'], '%max' => $instance['settings']['max'])),
148 );
149 }
150 }
151 }
152 }
153
157 function number_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
158 if ($field['type'] == 'number_decimal') {
159 // Let PHP round the value to ensure consistent behavior across storage
160 // backends.
161 foreach ($items as $delta => $item) {
162 if (isset($item['value'])) {
163 $items[$delta]['value'] = round($item['value'], $field['settings']['scale']);
164 }
165 }
166 }
167 }
168
172 function number_field_is_empty($item, $field) {
173 if (empty($item['value']) && (string) $item['value'] !== '0') {
174 return TRUE;
175 }
176 return FALSE;
177 }
178
182 function number_field_formatter_info() {
183 return array(
184 // The 'Default' formatter is different for integer fields on the one hand,
185 // and for decimal and float fields on the other hand, in order to be able
186 // to use different default values for the settings.
187 'number_integer' => array(
188 'label' => t('Default'),
189 'field types' => array('number_integer'),
190 'settings' => array(
191 'thousand_separator' => ' ',
192 // The 'decimal_separator' and 'scale' settings are not configurable
193 // through the UI, and will therefore keep their default values. They
194 // are only present so that the 'number_integer' and 'number_decimal'
195 // formatters can use the same code.
196 'decimal_separator' => '.',
197 'scale' => 0,
198 'prefix_suffix' => TRUE,
199 ),
200 ),
201 'number_decimal' => array(
202 'label' => t('Default'),
203 'field types' => array('number_decimal', 'number_float'),
204 'settings' => array(
205 'thousand_separator' => ' ',
206 'decimal_separator' => '.',
207 'scale' => 2,
208 'prefix_suffix' => TRUE,
209 ),
210 ),
211 'number_unformatted' => array(
212 'label' => t('Unformatted'),
213 'field types' => array('number_integer', 'number_decimal', 'number_float'),
214 ),
215 );
216 }
217
221 function number_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
222 $display = $instance['display'][$view_mode];
223 $settings = $display['settings'];
224
225 if ($display['type'] == 'number_decimal' || $display['type'] == 'number_integer') {
226 $options = array(
227 '' => t('<none>'),
228 '.' => t('Decimal point'),
229 ',' => t('Comma'),
230 ' ' => t('Space'),
231 );
232 $element['thousand_separator'] = array(
233 '#type' => 'select',
234 '#title' => t('Thousand marker'),
235 '#options' => $options,
236 '#default_value' => $settings['thousand_separator'],
237 );
238
239 if ($display['type'] == 'number_decimal') {
240 $element['decimal_separator'] = array(
241 '#type' => 'select',
242 '#title' => t('Decimal marker'),
243 '#options' => array('.' => t('Decimal point'), ',' => t('Comma')),
244 '#default_value' => $settings['decimal_separator'],
245 );
246 $element['scale'] = array(
247 '#type' => 'select',
248 '#title' => t('Scale'),
249 '#options' => drupal_map_assoc(range(0, 10)),
250 '#default_value' => $settings['scale'],
251 '#description' => t('The number of digits to the right of the decimal.'),
252 );
253 }
254
255 $element['prefix_suffix'] = array(
256 '#type' => 'checkbox',
257 '#title' => t('Display prefix and suffix.'),
258 '#default_value' => $settings['prefix_suffix'],
259 );
260 }
261
262 return $element;
263 }
264
268 function number_field_formatter_settings_summary($field, $instance, $view_mode) {
269 $display = $instance['display'][$view_mode];
270 $settings = $display['settings'];
271
272 $summary = array();
273 if ($display['type'] == 'number_decimal' || $display['type'] == 'number_integer') {
274 $summary[] = number_format(1234.1234567890, $settings['scale'], $settings['decimal_separator'], $settings['thousand_separator']);
275 if ($settings['prefix_suffix']) {
276 $summary[] = t('Display with prefix and suffix.');
277 }
278 }
279
280 return implode('<br />', $summary);
281 }
282
286 function number_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
287 $element = array();
288 $settings = $display['settings'];
289
290 switch ($display['type']) {
291 case 'number_integer':
292 case 'number_decimal':
293 foreach ($items as $delta => $item) {
294 $output = number_format($item['value'], $settings['scale'], $settings['decimal_separator'], $settings['thousand_separator']);
295 if ($settings['prefix_suffix']) {
296 $prefixes = isset($instance['settings']['prefix']) ? array_map('field_filter_xss', explode('|', $instance['settings']['prefix'])) : array('');
297 $suffixes = isset($instance['settings']['suffix']) ? array_map('field_filter_xss', explode('|', $instance['settings']['suffix'])) : array('');
298 $prefix = (count($prefixes) > 1) ? format_plural($item['value'], $prefixes[0], $prefixes[1]) : $prefixes[0];
299 $suffix = (count($suffixes) > 1) ? format_plural($item['value'], $suffixes[0], $suffixes[1]) : $suffixes[0];
300 $output = $prefix . $output . $suffix;
301 }
302 $element[$delta] = array('#markup' => $output);
303 }
304 break;
305
306 case 'number_unformatted':
307 foreach ($items as $delta => $item) {
308 $element[$delta] = array('#markup' => $item['value']);
309 }
310 break;
311 }
312
313 return $element;
314 }
315
319 function number_field_widget_info() {
320 return array(
321 'number' => array(
322 'label' => t('Text field'),
323 'field types' => array('number_integer', 'number_decimal', 'number_float'),
324 ),
325 );
326 }
327
331 function number_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
332 $value = isset($items[$delta]['value']) ? $items[$delta]['value'] : '';
333 // Substitute the decimal separator.
334 if ($field['type'] == 'number_decimal' || $field['type'] == 'number_float') {
335 $value = strtr($value, '.', $field['settings']['decimal_separator']);
336 }
337
338 $element += array(
339 '#type' => 'textfield',
340 '#default_value' => $value,
341 // Allow a slightly larger size that the field length to allow for some
342 // configurations where all characters won't fit in input field.
343 '#size' => $field['type'] == 'number_decimal' ? $field['settings']['precision'] + 4 : 12,
344 // Allow two extra characters for signed values and decimal separator.
345 '#maxlength' => $field['type'] == 'number_decimal' ? $field['settings']['precision'] + 2 : 10,
346 // Extract the number type from the field type name for easier validation.
347 '#number_type' => str_replace('number_', '', $field['type']),
348 );
349
350 // Add prefix and suffix.
351 if (!empty($instance['settings']['prefix'])) {
352 $prefixes = explode('|', $instance['settings']['prefix']);
353 $element['#field_prefix'] = field_filter_xss(array_pop($prefixes));
354 }
355 if (!empty($instance['settings']['suffix'])) {
356 $suffixes = explode('|', $instance['settings']['suffix']);
357 $element['#field_suffix'] = field_filter_xss(array_pop($suffixes));
358 }
359
360 $element['#element_validate'][] = 'number_field_widget_validate';
361
362 return array('value' => $element);
363 }
364
368 function number_field_widget_validate($element, &$form_state) {
369 $field = field_widget_field($element, $form_state);
370 $instance = field_widget_instance($element, $form_state);
371
372 $type = $element['#number_type'];
373 $value = $element['#value'];
374
375 // Reject invalid characters.
376 if (!empty($value)) {
377 switch ($type) {
378 case 'float':
379 case 'decimal':
380 $regexp = '@([^-0-9\\' . $field['settings']['decimal_separator'] . '])|(.-)@';
381 $message = t('Only numbers and the decimal separator (@separator) allowed in %field.', array('%field' => $instance['label'], '@separator' => $field['settings']['decimal_separator']));
382 break;
383
384 case 'integer':
385 $regexp = '@([^-0-9])|(.-)@';
386 $message = t('Only numbers are allowed in %field.', array('%field' => $instance['label']));
387 break;
388 }
389 if ($value != preg_replace($regexp, '', $value)) {
390 form_error($element, $message);
391 }
392 else {
393 if ($type == 'decimal' || $type == 'float') {
394 // Verify that only one decimal separator exists in the field.
395 if (substr_count($value, $field['settings']['decimal_separator']) > 1) {
396 $message = t('%field: There should only be one decimal separator (@separator).',
397 array(
398 '%field' => t($instance['label']),
399 '@separator' => $field['settings']['decimal_separator'],
400 )
401 );
402 form_error($element, $message);
403 }
404 else {
405 // Substitute the decimal separator; things should be fine.
406 $value = strtr($value, $field['settings']['decimal_separator'], '.');
407 }
408 }
409 form_set_value($element, $value, $form_state);
410 }
411 }
412 }
413
417 function number_field_widget_error($element, $error, $form, &$form_state) {
418 form_error($element['value'], $error['message']);
419 }
number_field_is_empty
number_field_is_empty($item, $field)
Definition: number.module:172
field_filter_xss
field_filter_xss($string)
Definition: field.module:752
number_field_formatter_settings_form
number_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state)
Definition: number.module:221
number_field_formatter_view
number_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
Definition: number.module:286
number_field_info
number_field_info()
Definition: number.module:24
number_field_widget_validate
number_field_widget_validate($element, &$form_state)
Definition: number.module:368
number_field_widget_error
number_field_widget_error($element, $error, $form, &$form_state)
Definition: number.module:417
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
field_widget_instance
field_widget_instance($element, $form_state)
Definition: field.form.inc:601
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$value
print $value
Definition: user-profile-item.tpl.php:26
number_field_widget_info
number_field_widget_info()
Definition: number.module:319
number_help
number_help($path, $arg)
Definition: number.module:11
$output
$output
Definition: authorize.php:93
number_field_formatter_settings_summary
number_field_formatter_settings_summary($field, $instance, $view_mode)
Definition: number.module:268
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
number_field_validate
number_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
Definition: number.module:135
number_field_instance_settings_form
number_field_instance_settings_form($field, $instance)
Definition: number.module:93
number_field_settings_form
number_field_settings_form($field, $instance, $has_data)
Definition: number.module:55
number_field_presave
number_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: number.module:157
field_widget_field
field_widget_field($element, $form_state)
Definition: field.form.inc:576
number_field_widget_form
number_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
Definition: number.module:331
number_field_formatter_info
number_field_formatter_info()
Definition: number.module:182
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/node.install Source File

  • modules
  • node
node.install
Go to the documentation of this file.
1 <?php
2
11 function node_schema() {
12 $schema['node'] = array(
13 'description' => 'The base table for nodes.',
14 'fields' => array(
15 'nid' => array(
16 'description' => 'The primary identifier for a node.',
17 'type' => 'serial',
18 'unsigned' => TRUE,
19 'not null' => TRUE,
20 ),
21 // Defaults to NULL in order to avoid a brief period of potential
22 // deadlocks on the index.
23 'vid' => array(
24 'description' => 'The current {node_revision}.vid version identifier.',
25 'type' => 'int',
26 'unsigned' => TRUE,
27 'not null' => FALSE,
28 'default' => NULL,
29 ),
30 'type' => array(
31 'description' => 'The {node_type}.type of this node.',
32 'type' => 'varchar',
33 'length' => 32,
34 'not null' => TRUE,
35 'default' => '',
36 ),
37 'language' => array(
38 'description' => 'The {languages}.language of this node.',
39 'type' => 'varchar',
40 'length' => 12,
41 'not null' => TRUE,
42 'default' => '',
43 ),
44 'title' => array(
45 'description' => 'The title of this node, always treated as non-markup plain text.',
46 'type' => 'varchar',
47 'length' => 255,
48 'not null' => TRUE,
49 'default' => '',
50 ),
51 'uid' => array(
52 'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.',
53 'type' => 'int',
54 'not null' => TRUE,
55 'default' => 0,
56 ),
57 'status' => array(
58 'description' => 'Boolean indicating whether the node is published (visible to non-administrators).',
59 'type' => 'int',
60 'not null' => TRUE,
61 'default' => 1,
62 ),
63 'created' => array(
64 'description' => 'The Unix timestamp when the node was created.',
65 'type' => 'int',
66 'not null' => TRUE,
67 'default' => 0,
68 ),
69 'changed' => array(
70 'description' => 'The Unix timestamp when the node was most recently saved.',
71 'type' => 'int',
72 'not null' => TRUE,
73 'default' => 0,
74 ),
75 'comment' => array(
76 'description' => 'Whether comments are allowed on this node: 0 = no, 1 = closed (read only), 2 = open (read/write).',
77 'type' => 'int',
78 'not null' => TRUE,
79 'default' => 0,
80 ),
81 'promote' => array(
82 'description' => 'Boolean indicating whether the node should be displayed on the front page.',
83 'type' => 'int',
84 'not null' => TRUE,
85 'default' => 0,
86 ),
87 'sticky' => array(
88 'description' => 'Boolean indicating whether the node should be displayed at the top of lists in which it appears.',
89 'type' => 'int',
90 'not null' => TRUE,
91 'default' => 0,
92 ),
93 'tnid' => array(
94 'description' => 'The translation set id for this node, which equals the node id of the source post in each set.',
95 'type' => 'int',
96 'unsigned' => TRUE,
97 'not null' => TRUE,
98 'default' => 0,
99 ),
100 'translate' => array(
101 'description' => 'A boolean indicating whether this translation page needs to be updated.',
102 'type' => 'int',
103 'not null' => TRUE,
104 'default' => 0,
105 ),
106 ),
107 'indexes' => array(
108 'node_changed' => array('changed'),
109 'node_created' => array('created'),
110 'node_frontpage' => array('promote', 'status', 'sticky', 'created'),
111 'node_status_type' => array('status', 'type', 'nid'),
112 'node_title_type' => array('title', array('type', 4)),
113 'node_type' => array(array('type', 4)),
114 'uid' => array('uid'),
115 'tnid' => array('tnid'),
116 'translate' => array('translate'),
117 'language' => array('language'),
118 ),
119 'unique keys' => array(
120 'vid' => array('vid'),
121 ),
122 'foreign keys' => array(
123 'node_revision' => array(
124 'table' => 'node_revision',
125 'columns' => array('vid' => 'vid'),
126 ),
127 'node_author' => array(
128 'table' => 'users',
129 'columns' => array('uid' => 'uid'),
130 ),
131 ),
132 'primary key' => array('nid'),
133 );
134
135 $schema['node_access'] = array(
136 'description' => 'Identifies which realm/grant pairs a user must possess in order to view, update, or delete specific nodes.',
137 'fields' => array(
138 'nid' => array(
139 'description' => 'The {node}.nid this record affects.',
140 'type' => 'int',
141 'unsigned' => TRUE,
142 'not null' => TRUE,
143 'default' => 0,
144 ),
145 'gid' => array(
146 'description' => "The grant ID a user must possess in the specified realm to gain this row's privileges on the node.",
147 'type' => 'int',
148 'unsigned' => TRUE,
149 'not null' => TRUE,
150 'default' => 0,
151 ),
152 'realm' => array(
153 'description' => 'The realm in which the user must possess the grant ID. Each node access node can define one or more realms.',
154 'type' => 'varchar',
155 'length' => 255,
156 'not null' => TRUE,
157 'default' => '',
158 ),
159 'grant_view' => array(
160 'description' => 'Boolean indicating whether a user with the realm/grant pair can view this node.',
161 'type' => 'int',
162 'unsigned' => TRUE,
163 'not null' => TRUE,
164 'default' => 0,
165 'size' => 'tiny',
166 ),
167 'grant_update' => array(
168 'description' => 'Boolean indicating whether a user with the realm/grant pair can edit this node.',
169 'type' => 'int',
170 'unsigned' => TRUE,
171 'not null' => TRUE,
172 'default' => 0,
173 'size' => 'tiny',
174 ),
175 'grant_delete' => array(
176 'description' => 'Boolean indicating whether a user with the realm/grant pair can delete this node.',
177 'type' => 'int',
178 'unsigned' => TRUE,
179 'not null' => TRUE,
180 'default' => 0,
181 'size' => 'tiny',
182 ),
183 ),
184 'primary key' => array('nid', 'gid', 'realm'),
185 'foreign keys' => array(
186 'affected_node' => array(
187 'table' => 'node',
188 'columns' => array('nid' => 'nid'),
189 ),
190 ),
191 );
192
193 $schema['node_revision'] = array(
194 'description' => 'Stores information about each saved version of a {node}.',
195 'fields' => array(
196 'nid' => array(
197 'description' => 'The {node} this version belongs to.',
198 'type' => 'int',
199 'unsigned' => TRUE,
200 'not null' => TRUE,
201 'default' => 0,
202 ),
203 'vid' => array(
204 'description' => 'The primary identifier for this version.',
205 'type' => 'serial',
206 'unsigned' => TRUE,
207 'not null' => TRUE,
208 ),
209 'uid' => array(
210 'description' => 'The {users}.uid that created this version.',
211 'type' => 'int',
212 'not null' => TRUE,
213 'default' => 0,
214 ),
215 'title' => array(
216 'description' => 'The title of this version.',
217 'type' => 'varchar',
218 'length' => 255,
219 'not null' => TRUE,
220 'default' => '',
221 ),
222 'log' => array(
223 'description' => 'The log entry explaining the changes in this version.',
224 'type' => 'text',
225 'not null' => TRUE,
226 'size' => 'big',
227 ),
228 'timestamp' => array(
229 'description' => 'A Unix timestamp indicating when this version was created.',
230 'type' => 'int',
231 'not null' => TRUE,
232 'default' => 0,
233 ),
234 'status' => array(
235 'description' => 'Boolean indicating whether the node (at the time of this revision) is published (visible to non-administrators).',
236 'type' => 'int',
237 'not null' => TRUE,
238 'default' => 1,
239 ),
240 'comment' => array(
241 'description' => 'Whether comments are allowed on this node (at the time of this revision): 0 = no, 1 = closed (read only), 2 = open (read/write).',
242 'type' => 'int',
243 'not null' => TRUE,
244 'default' => 0,
245 ),
246 'promote' => array(
247 'description' => 'Boolean indicating whether the node (at the time of this revision) should be displayed on the front page.',
248 'type' => 'int',
249 'not null' => TRUE,
250 'default' => 0,
251 ),
252 'sticky' => array(
253 'description' => 'Boolean indicating whether the node (at the time of this revision) should be displayed at the top of lists in which it appears.',
254 'type' => 'int',
255 'not null' => TRUE,
256 'default' => 0,
257 ),
258 ),
259 'indexes' => array(
260 'nid' => array('nid'),
261 'uid' => array('uid'),
262 ),
263 'primary key' => array('vid'),
264 'foreign keys' => array(
265 'versioned_node' => array(
266 'table' => 'node',
267 'columns' => array('nid' => 'nid'),
268 ),
269 'version_author' => array(
270 'table' => 'users',
271 'columns' => array('uid' => 'uid'),
272 ),
273 ),
274 );
275
276 $schema['node_type'] = array(
277 'description' => 'Stores information about all defined {node} types.',
278 'fields' => array(
279 'type' => array(
280 'description' => 'The machine-readable name of this type.',
281 'type' => 'varchar',
282 'length' => 32,
283 'not null' => TRUE,
284 ),
285 'name' => array(
286 'description' => 'The human-readable name of this type.',
287 'type' => 'varchar',
288 'length' => 255,
289 'not null' => TRUE,
290 'default' => '',
291 'translatable' => TRUE,
292 ),
293 'base' => array(
294 'description' => 'The base string used to construct callbacks corresponding to this node type.',
295 'type' => 'varchar',
296 'length' => 255,
297 'not null' => TRUE,
298 ),
299 'module' => array(
300 'description' => 'The module defining this node type.',
301 'type' => 'varchar',
302 'length' => 255,
303 'not null' => TRUE,
304 ),
305 'description' => array(
306 'description' => 'A brief description of this type.',
307 'type' => 'text',
308 'not null' => TRUE,
309 'size' => 'medium',
310 'translatable' => TRUE,
311 ),
312 'help' => array(
313 'description' => 'Help information shown to the user when creating a {node} of this type.',
314 'type' => 'text',
315 'not null' => TRUE,
316 'size' => 'medium',
317 'translatable' => TRUE,
318 ),
319 'has_title' => array(
320 'description' => 'Boolean indicating whether this type uses the {node}.title field.',
321 'type' => 'int',
322 'unsigned' => TRUE,
323 'not null' => TRUE,
324 'size' => 'tiny',
325 ),
326 'title_label' => array(
327 'description' => 'The label displayed for the title field on the edit form.',
328 'type' => 'varchar',
329 'length' => 255,
330 'not null' => TRUE,
331 'default' => '',
332 'translatable' => TRUE,
333 ),
334 'custom' => array(
335 'description' => 'A boolean indicating whether this type is defined by a module (FALSE) or by a user via Add content type (TRUE).',
336 'type' => 'int',
337 'not null' => TRUE,
338 'default' => 0,
339 'size' => 'tiny',
340 ),
341 'modified' => array(
342 'description' => 'A boolean indicating whether this type has been modified by an administrator; currently not used in any way.',
343 'type' => 'int',
344 'not null' => TRUE,
345 'default' => 0,
346 'size' => 'tiny',
347 ),
348 'locked' => array(
349 'description' => 'A boolean indicating whether the administrator can change the machine name of this type.',
350 'type' => 'int',
351 'not null' => TRUE,
352 'default' => 0,
353 'size' => 'tiny',
354 ),
355 'disabled' => array(
356 'description' => 'A boolean indicating whether the node type is disabled.',
357 'type' => 'int',
358 'not null' => TRUE,
359 'default' => 0,
360 'size' => 'tiny'
361 ),
362 'orig_type' => array(
363 'description' => 'The original machine-readable name of this node type. This may be different from the current type name if the locked field is 0.',
364 'type' => 'varchar',
365 'length' => 255,
366 'not null' => TRUE,
367 'default' => '',
368 ),
369 ),
370 'primary key' => array('type'),
371 );
372
373 $schema['block_node_type'] = array(
374 'description' => 'Sets up display criteria for blocks based on content types',
375 'fields' => array(
376 'module' => array(
377 'type' => 'varchar',
378 'length' => 64,
379 'not null' => TRUE,
380 'description' => "The block's origin module, from {block}.module.",
381 ),
382 'delta' => array(
383 'type' => 'varchar',
384 'length' => 32,
385 'not null' => TRUE,
386 'description' => "The block's unique delta within module, from {block}.delta.",
387 ),
388 'type' => array(
389 'type' => 'varchar',
390 'length' => 32,
391 'not null' => TRUE,
392 'description' => "The machine-readable name of this type from {node_type}.type.",
393 ),
394 ),
395 'primary key' => array('module', 'delta', 'type'),
396 'indexes' => array(
397 'type' => array('type'),
398 ),
399 );
400
401 $schema['history'] = array(
402 'description' => 'A record of which {users} have read which {node}s.',
403 'fields' => array(
404 'uid' => array(
405 'description' => 'The {users}.uid that read the {node} nid.',
406 'type' => 'int',
407 'not null' => TRUE,
408 'default' => 0,
409 ),
410 'nid' => array(
411 'description' => 'The {node}.nid that was read.',
412 'type' => 'int',
413 'not null' => TRUE,
414 'default' => 0,
415 ),
416 'timestamp' => array(
417 'description' => 'The Unix timestamp at which the read occurred.',
418 'type' => 'int',
419 'not null' => TRUE,
420 'default' => 0,
421 ),
422 ),
423 'primary key' => array('uid', 'nid'),
424 'indexes' => array(
425 'nid' => array('nid'),
426 ),
427 );
428
429 return $schema;
430 }
431
435 function node_install() {
436 // Populate the node access table.
437 db_insert('node_access')
438 ->fields(array(
439 'nid' => 0,
440 'gid' => 0,
441 'realm' => 'all',
442 'grant_view' => 1,
443 'grant_update' => 0,
444 'grant_delete' => 0,
445 ))
446 ->execute();
447 }
448
452 function node_update_dependencies() {
453 // node_update_7006() migrates node data to fields and therefore must run
454 // after all Field modules have been enabled, which happens in
455 // system_update_7027(). It also needs to query the {filter_format} table to
456 // get a list of existing text formats, so it must run after
457 // filter_update_7000(), which creates that table.
458 $dependencies['node'][7006] = array(
459 'system' => 7027,
460 'filter' => 7000,
461 );
462
463 // node_update_7008() migrates role permissions and therefore must run after
464 // the {role} and {role_permission} tables are properly set up, which happens
465 // in user_update_7007().
466 $dependencies['node'][7008] = array(
467 'user' => 7007,
468 );
469
470 return $dependencies;
471 }
472
480 function _update_7000_node_get_types() {
481 $node_types = db_query('SELECT * FROM {node_type}')->fetchAllAssoc('type', PDO::FETCH_OBJ);
482
483 // Create default settings for orphan nodes.
484 $all_types = db_query('SELECT DISTINCT type FROM {node}')->fetchCol();
485 $extra_types = array_diff($all_types, array_keys($node_types));
486
487 foreach ($extra_types as $type) {
488 $type_object = new stdClass();
489 $type_object->type = $type;
490
491 // In Drupal 6, whether you have a body field or not is a flag in the node
492 // type table. If it's enabled, nodes may or may not have an empty string
493 // for the bodies. As we can't detect what this setting should be in
494 // Drupal 7 without access to the Drupal 6 node type settings, we assume
495 // the default, which is to enable the body field.
496 $type_object->has_body = 1;
497 $type_object->body_label = 'Body';
498 $node_types[$type_object->type] = $type_object;
499 }
500 return $node_types;
501 }
502
511 function node_update_7000() {
512 // Rename the module column to base.
513 db_change_field('node_type', 'module', 'base', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE));
514
515 db_add_field('node_type', 'module', array(
516 'description' => 'The module defining this node type.',
517 'type' => 'varchar',
518 'default' => '',
519 'length' => 255,
520 'not null' => TRUE,
521 ));
522
523 db_add_field('node_type', 'disabled', array(
524 'description' => 'A boolean indicating whether the node type is disabled.',
525 'type' => 'int',
526 'not null' => TRUE,
527 'default' => 0,
528 'size' => 'tiny'
529 ));
530
531 $modules = db_select('system', 's')
532 ->fields('s', array('name'))
533 ->condition('type', 'module');
534 db_update('node_type')
535 ->expression('module', 'base')
536 ->condition('base', $modules, 'IN')
537 ->execute();
538
539 db_update('node_type')
540 ->fields(array('base' => 'node_content'))
541 ->condition('base', 'node')
542 ->execute();
543 }
544
548 function node_update_7001() {
549 db_rename_table('node_revisions', 'node_revision');
550 }
551
555 function node_update_7002() {
556 db_drop_index('node', 'node_promote_status');
557 db_add_index('node', 'node_frontpage', array('promote', 'status', 'sticky', 'created'));
558 }
559
563 function node_update_7003() {
564 if (drupal_get_installed_schema_version('statistics') == SCHEMA_UNINSTALLED) {
565 db_drop_table('node_counter');
566 }
567 }
568
572 function node_update_7004() {
573 // Get original settings and all types.
574 $original_length = variable_get('teaser_length', 600);
575 $original_preview = variable_get('node_preview', 0);
576
577 // Map old preview setting to new values order.
578 $original_preview ? $original_preview = 2 : $original_preview = 1;
579 node_type_cache_reset();
580
581 // Apply original settings to all types.
582 foreach (_update_7000_node_get_types() as $type => $type_object) {
583 variable_set('teaser_length_' . $type, $original_length);
584 variable_set('node_preview_' . $type, $original_preview);
585 }
586 // Delete old variable but leave 'teaser_length' for aggregator module upgrade.
587 variable_del('node_preview');
588 }
589
593 function node_update_7005() {
594 foreach (array('status', 'comment', 'promote', 'sticky') as $column) {
595 db_add_field('node_revision', $column, array(
596 'type' => 'int',
597 'not null' => TRUE,
598 'default' => 0,
599 ));
600 }
601 }
602
606 function node_update_7006(&$sandbox) {
607 $sandbox['#finished'] = 0;
608
609 // Get node type info for every invocation.
610 node_type_cache_reset();
611
612 if (!isset($sandbox['total'])) {
613 // Initial invocation.
614
615 // First, create the body field.
616 $body_field = array(
617 'field_name' => 'body',
618 'type' => 'text_with_summary',
619 'module' => 'text',
620 'cardinality' => 1,
621 'entity_types' => array('node'),
622 'translatable' => TRUE,
623 );
624 _update_7000_field_create_field($body_field);
625
626 $default_trim_length = variable_get('teaser_length', 600);
627
628 // Get node type info, specifically the body field settings.
629 $node_types = _update_7000_node_get_types();
630
631 // Add body field instances for existing node types.
632 foreach ($node_types as $node_type) {
633 if ($node_type->has_body) {
634 $trim_length = variable_get('teaser_length_' . $node_type->type, $default_trim_length);
635
636 $instance = array(
637 'entity_type' => 'node',
638 'bundle' => $node_type->type,
639 'label' => $node_type->body_label,
640 'description' => isset($node_type->description) ? $node_type->description : '',
641 'required' => (isset($node_type->min_word_count) && $node_type->min_word_count > 0) ? 1 : 0,
642 'widget' => array(
643 'type' => 'text_textarea_with_summary',
644 'settings' => array(
645 'rows' => 20,
646 'summary_rows' => 5,
647 ),
648 'weight' => -4,
649 'module' => 'text',
650 ),
651 'settings' => array('display_summary' => TRUE),
652 'display' => array(
653 'default' => array(
654 'label' => 'hidden',
655 'type' => 'text_default',
656 ),
657 'teaser' => array(
658 'label' => 'hidden',
659 'type' => 'text_summary_or_trimmed',
660 'trim_length' => $trim_length,
661 ),
662 ),
663 );
664 _update_7000_field_create_instance($body_field, $instance);
665 variable_del('teaser_length_' . $node_type->type);
666 }
667 // Leave 'teaser_length' variable for aggregator module upgrade.
668
669 $sandbox['node_types_info'][$node_type->type] = array(
670 'has_body' => $node_type->has_body,
671 );
672 }
673
674 // Used below when updating the stored text format of each node body.
675 $sandbox['existing_text_formats'] = db_query("SELECT format FROM {filter_format}")->fetchCol();
676
677 // Initialize state for future calls.
678 $sandbox['last'] = 0;
679 $sandbox['count'] = 0;
680
681 $query = db_select('node', 'n');
682 $query->join('node_revision', 'nr', 'n.nid = nr.nid');
683 $sandbox['total'] = $query->countQuery()->execute()->fetchField();
684
685 $sandbox['body_field_id'] = $body_field['id'];
686 }
687 else {
688 // Subsequent invocations.
689
690 $found = FALSE;
691 if ($sandbox['total']) {
692 // Operate on every revision of every node (whee!), in batches.
693 $batch_size = 200;
694 $query = db_select('node_revision', 'nr');
695 $query->innerJoin('node', 'n', 'n.nid = nr.nid');
696 $query
697 ->fields('nr', array('nid', 'vid', 'body', 'teaser', 'format'))
698 ->fields('n', array('type', 'status', 'comment', 'promote', 'sticky', 'language'))
699 ->condition('nr.vid', $sandbox['last'], '>')
700 ->orderBy('nr.vid', 'ASC')
701 ->range(0, $batch_size);
702 $revisions = $query->execute();
703
704 // Load each revision of each node, set up 'body'
705 // appropriately, and save the node's field data. Note that
706 // node_load() will not return the body or teaser values from
707 // {node_revision} because those columns have been removed from the
708 // schema structure in memory (but not yet from the database),
709 // so we get the values from the explicit query of the table
710 // instead.
711 foreach ($revisions as $revision) {
712 $found = TRUE;
713
714 if ($sandbox['node_types_info'][$revision->type]['has_body']) {
715 $node = (object) array(
716 'nid' => $revision->nid,
717 'vid' => $revision->vid,
718 'type' => $revision->type,
719 );
720 // After node_update_7009() we will always have LANGUAGE_NONE as
721 // language neutral language code, but here we still have empty
722 // strings.
723 $langcode = empty($revision->language) ? LANGUAGE_NONE : $revision->language;
724 if (!empty($revision->teaser) && $revision->teaser != text_summary($revision->body)) {
725 $node->body[$langcode][0]['summary'] = $revision->teaser;
726 }
727 // Do this after text_summary() above.
728 $break = '<!--break-->';
729 if (substr($revision->body, 0, strlen($break)) == $break) {
730 $revision->body = substr($revision->body, strlen($break));
731 }
732 $node->body[$langcode][0]['value'] = $revision->body;
733 // Update the revision's text format for the changes to the Drupal 7
734 // filter system. This uses the same kind of logic that occurs, for
735 // example, in user_update_7010(), but we do this here rather than
736 // via a separate set of database queries, since we are already
737 // migrating the data.
738 if (empty($revision->body) && empty($revision->format)) {
739 $node->body[$langcode][0]['format'] = NULL;
740 }
741 elseif (!in_array($revision->format, $sandbox['existing_text_formats'])) {
742 $node->body[$langcode][0]['format'] = variable_get('filter_default_format', 1);
743 }
744 else {
745 $node->body[$langcode][0]['format'] = $revision->format;
746 }
747 // This is a core update and no contrib modules are enabled yet, so
748 // we can assume default field storage for a faster update.
749 _update_7000_field_sql_storage_write('node', $node->type, $node->nid, $node->vid, 'body', $node->body);
750 }
751
752 // Migrate the status columns to the {node_revision} table.
753 db_update('node_revision')
754 ->fields(array(
755 'status' => $revision->status,
756 'comment' => $revision->comment,
757 'promote' => $revision->promote,
758 'sticky' => $revision->sticky,
759 ))
760 ->condition('vid', $revision->vid)
761 ->execute();
762
763 $sandbox['last'] = $revision->vid;
764 $sandbox['count'] += 1;
765 }
766
767 $sandbox['#finished'] = min(0.99, $sandbox['count'] / $sandbox['total']);
768 }
769
770 if (!$found) {
771 // All nodes are processed.
772
773 // Remove the now-obsolete body info from node_revision.
774 db_drop_field('node_revision', 'body');
775 db_drop_field('node_revision', 'teaser');
776 db_drop_field('node_revision', 'format');
777
778 // Remove node_type properties related to the former 'body'.
779 db_drop_field('node_type', 'has_body');
780 db_drop_field('node_type', 'body_label');
781
782 // We're done.
783 $sandbox['#finished'] = 1;
784 }
785 }
786 }
787
791 function node_update_7007() {
792 db_drop_field('node_type', 'min_word_count');
793 }
794
798 function node_update_7008() {
799 $roles = user_roles(FALSE, 'administer nodes');
800 foreach ($roles as $rid => $role) {
801 _update_7000_user_role_grant_permissions($rid, array('access content overview'), 'node');
802 }
803 }
804
808 function node_update_7009() {
809 db_update('node')
810 ->fields(array('language' => LANGUAGE_NONE))
811 ->condition('language', '')
812 ->execute();
813 }
814
818 function node_update_7010() {
819 $schema['block_node_type'] = array(
820 'description' => 'Sets up display criteria for blocks based on content types',
821 'fields' => array(
822 'module' => array(
823 'type' => 'varchar',
824 'length' => 64,
825 'not null' => TRUE,
826 'description' => "The block's origin module, from {block}.module.",
827 ),
828 'delta' => array(
829 'type' => 'varchar',
830 'length' => 32,
831 'not null' => TRUE,
832 'description' => "The block's unique delta within module, from {block}.delta.",
833 ),
834 'type' => array(
835 'type' => 'varchar',
836 'length' => 32,
837 'not null' => TRUE,
838 'description' => "The machine-readable name of this type from {node_type}.type.",
839 ),
840 ),
841 'primary key' => array('module', 'delta', 'type'),
842 'indexes' => array(
843 'type' => array('type'),
844 ),
845 );
846
847 db_create_table('block_node_type', $schema['block_node_type']);
848 }
849
862 function node_update_7011() {
863 // Drop node moderation field.
864 db_drop_field('node', 'moderate');
865 db_drop_index('node', 'node_moderate');
866
867 // Change {node_revision}.status field to default to 1.
868 db_change_field('node_revision', 'status', 'status', array(
869 'type' => 'int',
870 'not null' => TRUE,
871 'default' => 1,
872 ));
873
874 // Change {node_type}.module field default.
875 db_change_field('node_type', 'module', 'module', array(
876 'type' => 'varchar',
877 'length' => 255,
878 'not null' => TRUE,
879 ));
880 }
881
885 function node_update_7012() {
886 // If we are upgrading from D6, then body fields should be set back to
887 // untranslatable, as D6 did not know about the idea of translating fields,
888 // but only nodes. If a D7 > D7 update is running we need to skip this update,
889 // as it is a valid use case to have translatable body fields in this context.
890 if (variable_get('update_d6', FALSE)) {
891 // Make node bodies untranslatable: field_update_field() cannot be used
892 // throughout the upgrade process and we do not have an update counterpart
893 // for _update_7000_field_create_field(). Hence we are forced to update the
894 // 'field_config' table directly. This is a safe operation since it is
895 // being performed while upgrading from D6. Perfoming the same operation
896 // during a D7 update is highly discouraged.
897 db_update('field_config')
898 ->fields(array('translatable' => 0))
899 ->condition('field_name', 'body')
900 ->execute();
901
902 // Switch field languages to LANGUAGE_NONE, since initially they were
903 // assigned the node language.
904 foreach (array('field_data_body', 'field_revision_body') as $table) {
905 db_update($table)
906 ->fields(array('language' => LANGUAGE_NONE))
907 ->execute();
908 }
909
910 node_type_cache_reset();
911 }
912 }
913
917 function node_update_7013() {
918 db_drop_unique_key('node', 'vid');
919 db_change_field('node', 'vid', 'vid', array(
920 'description' => 'The current {node_revision}.vid version identifier.',
921 'type' => 'int',
922 'unsigned' => TRUE,
923 'not null' => FALSE,
924 'default' => NULL,
925 ));
926 db_add_unique_key('node', 'vid', array('vid'));
927 }
928
932 function node_update_7014() {
933 db_add_index('node', 'language', array('language'));
934 }
935
node_update_7000
node_update_7000()
Definition: node.install:511
node_update_7014
node_update_7014()
Definition: node.install:932
db_add_index
db_add_index($table, $name, $fields)
Definition: database.inc:2940
node_update_dependencies
node_update_dependencies()
Definition: node.install:452
node_update_7003
node_update_7003()
Definition: node.install:563
node_update_7009
node_update_7009()
Definition: node.install:808
_update_7000_user_role_grant_permissions
_update_7000_user_role_grant_permissions($rid, array $permissions, $module)
Definition: user.install:389
node_update_7005
node_update_7005()
Definition: node.install:593
node_update_7008
node_update_7008()
Definition: node.install:798
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_drop_index
db_drop_index($table, $name)
Definition: database.inc:2952
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
node_type_cache_reset
node_type_cache_reset()
Definition: node.module:783
node_update_7001
node_update_7001()
Definition: node.install:548
user_roles
user_roles($membersonly=FALSE, $permission=NULL)
Definition: user.module:2871
db_add_field
db_add_field($table, $field, $spec, $keys_new=array())
Definition: database.inc:2840
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
db_add_unique_key
db_add_unique_key($table, $name, $fields)
Definition: database.inc:2914
drupal_get_installed_schema_version
drupal_get_installed_schema_version($module, $reset=FALSE, $array=FALSE)
Definition: install.inc:146
node_install
node_install()
Definition: node.install:435
db_drop_field
db_drop_field($table, $field)
Definition: database.inc:2852
node_update_7007
node_update_7007()
Definition: node.install:791
node_update_7012
node_update_7012()
Definition: node.install:885
text_summary
text_summary($text, $format=NULL, $size=NULL)
Definition: text.module:347
node_update_7013
node_update_7013()
Definition: node.install:917
db_drop_unique_key
db_drop_unique_key($table, $name)
Definition: database.inc:2926
_update_7000_field_create_instance
_update_7000_field_create_instance($field, &$instance)
Definition: field.install:363
node_schema
node_schema()
Definition: node.install:11
node_update_7006
node_update_7006(&$sandbox)
Definition: node.install:606
node_update_7011
node_update_7011()
Definition: node.install:862
SCHEMA_UNINSTALLED
const SCHEMA_UNINSTALLED
Definition: install.inc:11
_update_7000_field_sql_storage_write
_update_7000_field_sql_storage_write($entity_type, $bundle, $entity_id, $revision_id, $field_name, $data)
Definition: field_sql_storage.install:35
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
node_update_7010
node_update_7010()
Definition: node.install:818
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
_update_7000_node_get_types
_update_7000_node_get_types()
Definition: node.install:480
node_update_7002
node_update_7002()
Definition: node.install:555
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
_update_7000_field_create_field
_update_7000_field_create_field(&$field)
Definition: field.install:177
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
node_update_7004
node_update_7004()
Definition: node.install:572
db_rename_table
db_rename_table($table, $new_name)
Definition: database.inc:2805
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
BatchQueue Member List

This is the complete list of members for BatchQueue, including all inherited members.

$name | SystemQueue | protected
__construct($name) | SystemQueue |
claimItem($lease_time=0) | BatchQueue |
createItem($data) | SystemQueue |
createQueue() | SystemQueue |
deleteItem($item) | SystemQueue |
deleteQueue() | SystemQueue |
getAllItems() | BatchQueue |
numberOfItems() | SystemQueue |
releaseItem($item) | SystemQueue |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/entity_example/entity_example.install Source File

  • examples
  • entity_example
entity_example.install
Go to the documentation of this file.
1 <?php
15 function entity_example_schema() {
16 $schema = array();
17
18 // The name of the table can be any name we choose. However, namespacing the
19 // table with the module name is best practice.
20 $schema['entity_example_basic'] = array(
21 'description' => 'The base table for our basic entity.',
22 'fields' => array(
23 'basic_id' => array(
24 'description' => 'Primary key of the basic entity.',
25 'type' => 'serial',
26 'unsigned' => TRUE,
27 'not null' => TRUE,
28 ),
29 // If we allow multiple bundles, then the schema must handle that;
30 // We'll put it in the 'bundle_type' field to avoid confusion with the
31 // entity type.
32 'bundle_type' => array(
33 'description' => 'The bundle type',
34 'type' => 'text',
35 'size' => 'medium',
36 'not null' => TRUE
37 ),
38 // Additional properties are just things that are common to all
39 // entities and don't require field storage.
40 'item_description' => array(
41 'description' => 'A description of the item',
42 'type' => 'varchar',
43 'length' => 255,
44 'not null' => TRUE,
45 'default' => '',
46 ),
47 'created' => array(
48 'description' => 'The Unix timestamp of the entity creation time.',
49 'type' => 'int',
50 'not null' => TRUE,
51 'default' => 0,
52 ),
53 ),
54 'primary key' => array('basic_id'),
55 );
56
57 return $schema;
58 }
59
60
61 /*
62 * Implements hook_uninstall().
63 *
64 * At uninstall time we'll notify field.module that the entity was deleted
65 * so that attached fields can be cleaned up.
66 *
67 * @ingroup entity_example
68 */
69 function entity_example_uninstall() {
70 field_attach_delete_bundle('entity_example_basic' , 'first_example_bundle' );
71 }
entity_example_schema
entity_example_schema()
Definition: entity_example.install:15
field_attach_delete_bundle
field_attach_delete_bundle($entity_type, $bundle)
Definition: field.attach.inc:1394
entity_example_uninstall
entity_example_uninstall()
Definition: entity_example.install:69
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/entity_example/entity_example.module Source File

  • examples
  • entity_example
entity_example.module
Go to the documentation of this file.
1 <?php
2
38 function entity_example_entity_info() {
39 $info['entity_example_basic'] = array(
40 // A human readable label to identify our entity.
41 'label' => t('Example Basic Entity'),
42
43 // The controller for our Entity, extending the Drupal core controller.
44 'controller class' => 'EntityExampleBasicController',
45
46 // The table for this entity defined in hook_schema()
47 'base table' => 'entity_example_basic',
48
49 // Returns the uri elements of an entity
50 'uri callback' => 'entity_example_basic_uri',
51
52 // IF fieldable == FALSE, we can't attach fields.
53 'fieldable' => TRUE,
54
55 // entity_keys tells the controller what database fields are used for key
56 // functions. It is not required if we don't have bundles or revisions.
57 // Here we do not support a revision, so that entity key is omitted.
58 'entity keys' => array(
59 'id' => 'basic_id' , // The 'id' (basic_id here) is the unique id.
60 'bundle' => 'bundle_type' // Bundle will be determined by the 'bundle_type' field
61 ),
62 'bundle keys' => array(
63 'bundle' => 'bundle_type',
64 ),
65
66 // FALSE disables caching. Caching functionality is handled by Drupal core.
67 'static cache' => TRUE,
68
69 // Bundles are alternative groups of fields or configuration
70 // associated with a base entity type.
71 'bundles' => array(
72 'first_example_bundle' => array(
73 'label' => 'First example bundle',
74 // 'admin' key is used by the Field UI to provide field and
75 // display UI pages.
76 'admin' => array(
77 'path' => 'admin/structure/entity_example_basic/manage',
78 'access arguments' => array('administer entity_example_basic entities'),
79 ),
80 ),
81 ),
82 // View modes allow entities to be displayed differently based on context.
83 // As a demonstration we'll support "Tweaky", but we could have and support
84 // multiple display modes.
85 'view modes' => array(
86 'tweaky' => array(
87 'label' => t('Tweaky'),
88 'custom settings' => FALSE,
89 ),
90 )
91 );
92
93 return $info;
94 }
95
118 function entity_example_basic_load($basic_id = NULL, $reset = FALSE) {
119 $basic_ids = (isset($basic_id) ? array($basic_id) : array());
120 $basic = entity_example_basic_load_multiple($basic_ids, array(), $reset);
121 return $basic ? reset($basic) : FALSE;
122 }
123
130 function entity_example_basic_load_multiple($basic_ids = FALSE, $conditions = array(), $reset = FALSE) {
131 return entity_load('entity_example_basic', $basic_ids, $conditions, $reset);
132 }
133
137 function entity_example_basic_uri($basic) {
138 return array(
139 'path' => 'examples/entity_example/basic/' . $basic->basic_id,
140 );
141 }
142
146 function entity_example_menu() {
147 $items['examples/entity_example'] = array(
148 'title' => 'Entity Example',
149 'page callback' => 'entity_example_info_page',
150 'access arguments' => array('view any entity_example_basic entity'),
151 );
152
153 // This provides a place for Field API to hang its own
154 // interface and has to be the same as what was defined
155 // in basic_entity_info() above.
156 $items['admin/structure/entity_example_basic/manage'] = array(
157 'title' => 'Administer entity_example_basic entity type',
158 'page callback' => 'entity_example_basic_list_entities',
159 'access arguments' => array('administer entity_example_basic entities'),
160 );
161
162 // Add example entities.
163 $items['admin/structure/entity_example_basic/manage/add'] = array(
164 'title' => 'Add an Entity Example Basic Entity',
165 'page callback' => 'entity_example_basic_add',
166 'access arguments' => array('create entity_example_basic entities'),
167 'type' => MENU_LOCAL_ACTION,
168 );
169
170 // List of all entity_example_basic entities.
171 $items['admin/structure/entity_example_basic/manage/list'] = array(
172 'title' => 'List',
173 'type' => MENU_DEFAULT_LOCAL_TASK,
174 );
175
176 // The page to view our entities - needs to follow what
177 // is defined in basic_uri and will use load_basic to retrieve
178 // the necessary entity info.
179 $items['examples/entity_example/basic/%entity_example_basic'] = array(
180 'title callback' => 'entity_example_basic_title',
181 'title arguments' => array(3),
182 'page callback' => 'entity_example_basic_view',
183 'page arguments' => array(3),
184 'access arguments' => array('view any entity_example_basic entity'),
185 );
186
187 // 'View' tab for an individual entity page.
188 $items['examples/entity_example/basic/%entity_example_basic/view'] = array(
189 'title' => 'View',
190 'type' => MENU_DEFAULT_LOCAL_TASK,
191 'weight' => -10,
192 );
193
194 // 'Edit' tab for an individual entity page.
195 $items['examples/entity_example/basic/%entity_example_basic/edit'] = array(
196 'title' => 'Edit',
197 'page callback' => 'drupal_get_form',
198 'page arguments' => array('entity_example_basic_form', 3),
199 'access arguments' => array('edit any entity_example_basic entity'),
200 'type' => MENU_LOCAL_TASK,
201 );
202
203 // Add example entities.
204 $items['examples/entity_example/basic/add'] = array(
205 'title' => 'Add an Entity Example Basic Entity',
206 'page callback' => 'entity_example_basic_add',
207 'access arguments' => array('create entity_example_basic entities'),
208 );
209
210 return $items;
211 }
212
216 function entity_example_info_page() {
217 $content['preface'] = array(
218 '#type' => 'item',
219 '#markup' => t('The entity example provides a simple example entity.')
220 );
221 if (user_access('administer entity_example_basic entities')) {
222 $content['preface']['#markup'] = t('You can administer these and add fields and change the view !link.',
223 array('!link' => l(t('here'), 'admin/structure/entity_example_basic/manage'))
224 );
225 }
226 $content['table'] = entity_example_basic_list_entities();
227
228 return $content;
229 }
230
234 function entity_example_permission() {
235 $permissions = array(
236 'administer entity_example_basic entities' => array(
237 'title' => t('Administer entity_example_basic entities'),
238 ),
239 'view any entity_example_basic entity' => array(
240 'title' => t('View any Entity Example Basic entity'),
241 ),
242 'edit any entity_example_basic entity' => array(
243 'title' => t('Edit any Entity Example Basic entity'),
244 ),
245 'create entity_example_basic entities' => array(
246 'title' => t('Create Entity Example Basic Entities'),
247 ),
248 );
249 return $permissions;
250 }
251
263 function entity_example_basic_list_entities() {
264 $content = array();
265 // Load all of our entities.
266 $entities = entity_example_basic_load_multiple();
267 if (!empty($entities)) {
268 foreach ( $entities as $entity ) {
269 // Create tabular rows for our entities.
270 $rows[] = array(
271 'data' => array(
272 'id' => $entity->basic_id,
273 'item_description' => l($entity->item_description, 'examples/entity_example/basic/' . $entity->basic_id),
274 'bundle' => $entity->bundle_type,
275 ),
276 );
277 }
278 // Put our entities into a themed table. See theme_table() for details.
279 $content['entity_table'] = array(
280 '#theme' => 'table',
281 '#rows' => $rows,
282 '#header' => array(t('ID'), t('Item Description'), t('Bundle')),
283 );
284 }
285 else {
286 // There were no entities. Tell the user.
287 $content[] = array(
288 '#type' => 'item',
289 '#markup' => t('No entity_example_basic entities currently exist.'),
290 );
291 }
292 return $content;
293 }
294
298 function entity_example_basic_title($entity) {
299 return t('Entity Example Basic (item_description=@item_description)', array('@item_description' => $entity->item_description));
300 }
301
312 function entity_example_basic_view($entity, $view_mode = 'tweaky') {
313 // Our entity type, for convenience.
314 $entity_type = 'entity_example_basic';
315 // Start setting up the content.
316 $entity->content = array(
317 '#view_mode' => $view_mode,
318 );
319 // Build fields content - this is where the Field API really comes in to play.
320 // The task has very little code here because it all gets taken care of by
321 // field module.
322 // field_attach_prepare_view() lets the fields load any data they need
323 // before viewing.
324 field_attach_prepare_view($entity_type, array($entity->basic_id => $entity),
325 $view_mode);
326 // We call entity_prepare_view() so it can invoke hook_entity_prepare_view()
327 // for us.
328 entity_prepare_view($entity_type, array($entity->basic_id => $entity));
329 // Now field_attach_view() generates the content for the fields.
330 $entity->content += field_attach_view($entity_type, $entity, $view_mode);
331
332 // OK, Field API done, now we can set up some of our own data.
333 $entity->content['created'] = array(
334 '#type' => 'item',
335 '#title' => t('Created date'),
336 '#markup' => format_date($entity->created),
337 );
338 $entity->content['item_description'] = array(
339 '#type' => 'item',
340 '#title' => t('Item Description'),
341 '#markup' => $entity->item_description,
342 );
343
344 // Now to invoke some hooks. We need the language code for
345 // hook_entity_view(), so let's get that.
346 global $language;
347 $langcode = $language->language;
348 // And now invoke hook_entity_view().
349 module_invoke_all('entity_view', $entity, $entity_type, $view_mode,
350 $langcode);
351 // Now invoke hook_entity_view_alter().
352 drupal_alter(array('entity_example_basic_view', 'entity_view'),
353 $entity->content, $entity_type);
354
355 // And finally return the content.
356 return $entity->content;
357 }
358
367 function entity_example_field_extra_fields() {
368 $form_elements['item_description'] = array(
369 'label' => t('Item Description'),
370 'description' => t('Item Description (an extra form field)'),
371 'weight' => -5,
372 );
373 $display_elements['created'] = array(
374 'label' => t('Creation date'),
375 'description' => t('Creation date (an extra display field)'),
376 'weight' => 0,
377 );
378 $display_elements['item_description'] = array(
379 'label' => t('Item Description'),
380 'description' => t('Just like title, but trying to point out that it is a separate property'),
381 'weight' => 0,
382 );
383
384 // Since we have only one bundle type, we'll just provide the extra_fields
385 // for it here.
386 $extra_fields['entity_example_basic']['first_example_bundle']['form'] = $form_elements;
387 $extra_fields['entity_example_basic']['first_example_bundle']['display'] = $display_elements;
388
389 return $extra_fields;
390 }
391
395 function entity_example_basic_add() {
396 // Create a basic entity structure to be used and passed to the validation
397 // and submission functions.
398 $entity = entity_get_controller('entity_example_basic')->create();
399 return drupal_get_form('entity_example_basic_form', $entity);
400 }
401
411 function entity_example_basic_form($form, &$form_state, $entity) {
412 $form['item_description'] = array(
413 '#type' => 'textfield',
414 '#title' => t('Item Description'),
415 '#required' => TRUE,
416 '#default_value' => $entity->item_description,
417 );
418
419 $form['basic_entity'] = array(
420 '#type' => 'value',
421 '#value' => $entity,
422 );
423
424 field_attach_form('entity_example_basic', $entity, $form, $form_state);
425
426 $form['submit'] = array(
427 '#type' => 'submit',
428 '#value' => t('Save'),
429 '#weight' => 100,
430 );
431 $form['delete'] = array(
432 '#type' => 'submit',
433 '#value' => t('Delete'),
434 '#submit' => array('entity_example_basic_edit_delete'),
435 '#weight' => 200,
436 );
437
438 return $form;
439 }
440
441
447 function entity_example_basic_form_validate($form, &$form_state) {
448 field_attach_form_validate('entity_example_basic', $form_state['values']['basic_entity'], $form, $form_state);
449 }
450
451
455 function entity_example_basic_form_submit($form, &$form_state) {
456 $entity = $form_state['values']['basic_entity'];
457 $entity->item_description = $form_state['values']['item_description'];
458 field_attach_submit('entity_example_basic', $entity, $form, $form_state);
459 $entity = entity_example_basic_save($entity);
460 $form_state['redirect'] = 'examples/entity_example/basic/' . $entity->basic_id;
461 }
462
468 function entity_example_basic_edit_delete( $form , &$form_state ) {
469 $entity = $form_state['values']['basic_entity'];
470 entity_example_basic_delete($entity);
471 drupal_set_message(t('The entity %item_description (ID %id) has been deleted',
472 array('%item_description' => $entity->item_description, '%id' => $entity->basic_id))
473 );
474 $form_state['redirect'] = 'examples/entity_example';
475 }
476
480 function entity_example_basic_save(&$entity) {
481 return entity_get_controller('entity_example_basic')->save($entity);
482 }
483
487 function entity_example_basic_delete($entity) {
488 entity_get_controller('entity_example_basic')->delete($entity);
489 }
490
502 interface EntityExampleBasicControllerInterface
503 extends DrupalEntityControllerInterface {
504 public function create();
505 public function save($entity);
506 public function delete($entity);
507 }
508
515 class EntityExampleBasicController
516 extends DrupalDefaultEntityController
517 implements EntityExampleBasicControllerInterface {
518
522 public function create() {
523 $entity = new stdClass();
524 $entity->type = 'entity_example_basic';
525 $entity->basic_id = 0;
526 $entity->bundle_type = 'first_example_bundle';
527 $entity->item_description = '';
528 return $entity;
529 }
530
534 public function save($entity) {
535 // If our entity has no basic_id, then we need to give it a
536 // time of creation.
537 if (empty($entity->basic_id)) {
538 $entity->created = time();
539 }
540 // Invoke hook_entity_presave().
541 module_invoke_all('entity_presave', $entity, 'entity_example_basic');
542 // The 'primary_keys' argument determines whether this will be an insert
543 // or an update. So if the entity already has an ID, we'll specify
544 // basic_id as the key.
545 $primary_keys = $entity->basic_id ? 'basic_id' : array();
546 // Write out the entity record.
547 drupal_write_record('entity_example_basic', $entity, $primary_keys);
548 // We're going to invoke either hook_entity_update() or
549 // hook_entity_insert(), depending on whether or not this is a
550 // new entity. We'll just store the name of hook_entity_insert()
551 // and change it if we need to.
552 $invocation = 'entity_insert';
553 // Now we need to either insert or update the fields which are
554 // attached to this entity. We use the same primary_keys logic
555 // to determine whether to update or insert, and which hook we
556 // need to invoke.
557 if (empty($primary_keys)) {
558 field_attach_insert('entity_example_basic', $entity);
559 }
560 else {
561 field_attach_update('entity_example_basic', $entity);
562 $invocation = 'entity_update';
563 }
564 // Invoke either hook_entity_update() or hook_entity_insert().
565 module_invoke_all($invocation, $entity, 'entity_example_basic');
566 return $entity;
567 }
568
574 public function delete($entity) {
575 $this->delete_multiple(array($entity));
576 }
577
587 public function delete_multiple($entities) {
588 $basic_ids = array();
589 if (!empty($entities)) {
590 $transaction = db_transaction();
591 try {
592 foreach ($entities as $entity) {
593 // Invoke hook_entity_delete().
594 module_invoke_all('entity_delete', $entity, 'entity_example_basic');
595 field_attach_delete('entity_example_basic', $entity);
596 $basic_ids[] = $entity->basic_id;
597 }
598 db_delete('entity_example_basic')
599 ->condition('basic_id', $basic_ids, 'IN')
600 ->execute();
601 }
602 catch (Exception $e) {
603 $transaction->rollback();
604 watchdog_exception('entity_example', $e);
605 throw $e;
606 }
607 }
608 }
609 }
610
entity_example_basic_delete
entity_example_basic_delete($entity)
Definition: entity_example.module:487
EntityExampleBasicControllerInterface::save
save($entity)
entity_example_field_extra_fields
entity_example_field_extra_fields()
Definition: entity_example.module:367
DrupalEntityControllerInterface
Definition: entity.inc:14
watchdog_exception
watchdog_exception($type, Exception $exception, $message=NULL, $variables=array(), $severity=WATCHDOG_ERROR, $link=NULL)
Definition: bootstrap.inc:1654
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
entity_example_basic_save
entity_example_basic_save(&$entity)
Definition: entity_example.module:480
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
entity_load
entity_load($entity_type, $ids=FALSE, $conditions=array(), $reset=FALSE)
Definition: common.inc:7800
l
l($text, $path, array $options=array())
Definition: common.inc:2432
entity_example_basic_add
entity_example_basic_add()
Definition: entity_example.module:395
field_attach_form
field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode=NULL, $options=array())
Definition: field.attach.inc:564
field_attach_submit
field_attach_submit($entity_type, $entity, $form, &$form_state, $options=array())
Definition: field.attach.inc:884
entity_example_permission
entity_example_permission()
Definition: entity_example.module:234
field_attach_update
field_attach_update($entity_type, $entity)
Definition: field.attach.inc:990
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
Exception
field_attach_prepare_view
field_attach_prepare_view($entity_type, $entities, $view_mode, $langcode=NULL, $options=array())
Definition: field.attach.inc:1133
entity_example_menu
entity_example_menu()
Definition: entity_example.module:146
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
entity_example_basic_title
entity_example_basic_title($entity)
Definition: entity_example.module:298
entity_example_basic_edit_delete
entity_example_basic_edit_delete($form, &$form_state)
Definition: entity_example.module:468
entity_example_basic_load
entity_example_basic_load($basic_id=NULL, $reset=FALSE)
Definition: entity_example.module:118
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
field_attach_form_validate
field_attach_form_validate($entity_type, $entity, $form, &$form_state, $options=array())
Definition: field.attach.inc:837
field_attach_insert
field_attach_insert($entity_type, $entity)
Definition: field.attach.inc:936
$info
$info
Definition: color.inc:6
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
entity_example_basic_load_multiple
entity_example_basic_load_multiple($basic_ids=FALSE, $conditions=array(), $reset=FALSE)
Definition: entity_example.module:130
EntityExampleBasicControllerInterface
Definition: entity_example.module:502
entity_example_basic_view
entity_example_basic_view($entity, $view_mode= 'tweaky')
Definition: entity_example.module:312
entity_example_basic_uri
entity_example_basic_uri($basic)
Definition: entity_example.module:137
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
EntityExampleBasicControllerInterface::create
create()
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
entity_prepare_view
entity_prepare_view($entity_type, $entities, $langcode=NULL)
Definition: common.inc:7866
EntityExampleBasicController
Definition: entity_example.module:515
db_transaction
db_transaction($name=NULL, array $options=array())
Definition: database.inc:2535
entity_get_controller
entity_get_controller($entity_type)
Definition: common.inc:7832
EntityExampleBasicController::delete_multiple
delete_multiple($entities)
Definition: entity_example.module:587
field_attach_view
field_attach_view($entity_type, $entity, $view_mode, $langcode=NULL, $options=array())
Definition: field.attach.inc:1216
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
entity_example_basic_list_entities
entity_example_basic_list_entities()
Definition: entity_example.module:263
DrupalDefaultEntityController
Definition: entity.inc:46
entity_example_basic_form_submit
entity_example_basic_form_submit($form, &$form_state)
Definition: entity_example.module:455
entity_example_info_page
entity_example_info_page()
Definition: entity_example.module:216
entity_example_basic_form_validate
entity_example_basic_form_validate($form, &$form_state)
Definition: entity_example.module:447
entity_example_basic_form
entity_example_basic_form($form, &$form_state, $entity)
Definition: entity_example.module:411
entity_example_entity_info
entity_example_entity_info()
Definition: entity_example.module:38
field_attach_delete
field_attach_delete($entity_type, $entity)
Definition: field.attach.inc:1045
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/block/block-admin-display-form.tpl.php Source File

  • modules
  • block
block-admin-display-form.tpl.php
Go to the documentation of this file.
1 <?php
2
27 ?>
28 <?php
29 // Add table javascript.
30 drupal_add_js('misc/tableheader.js');
31 drupal_add_js(drupal_get_path('module', 'block') . '/block.js');
32 foreach ($block_regions as $region => $title) {
33 drupal_add_tabledrag('blocks', 'match', 'sibling', 'block-region-select', 'block-region-' . $region, NULL, FALSE);
34 drupal_add_tabledrag('blocks', 'order', 'sibling', 'block-weight', 'block-weight-' . $region);
35 }
36 ?>
37 <table id="blocks" class="sticky-enabled">
38 <thead>
39 <tr>
40 <th><?php print t('Block'); ?></th>
41 <th><?php print t('Region'); ?></th>
42 <th><?php print t('Weight'); ?></th>
43 <th colspan="2"><?php print t('Operations'); ?></th>
44 </tr>
45 </thead>
46 <tbody>
47 <?php $row = 0; ?>
48 <?php foreach ($block_regions as $region => $title): ?>
49 <tr class="region-title region-title-<?php print $region?>">
50 <td colspan="5"><?php print $title; ?></td>
51 </tr>
52 <tr class="region-message region-<?php print $region?>-message <?php print empty($block_listing[$region]) ? 'region-empty' : 'region-populated'; ?>">
53 <td colspan="5"><em><?php print t('No blocks in this region'); ?></em></td>
54 </tr>
55 <?php foreach ($block_listing[$region] as $delta => $data): ?>
56 <tr class="draggable <?php print $row % 2 == 0 ? 'odd' : 'even'; ?><?php print $data->row_class ? ' ' . $data->row_class : ''; ?>">
57 <td class="block"><?php print $data->block_title; ?></td>
58 <td><?php print $data->region_select; ?></td>
59 <td><?php print $data->weight_select; ?></td>
60 <td><?php print $data->configure_link; ?></td>
61 <td><?php print $data->delete_link; ?></td>
62 </tr>
63 <?php $row++; ?>
64 <?php endforeach; ?>
65 <?php endforeach; ?>
66 </tbody>
67 </table>
68
69 <?php print $form_submit; ?>
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
endforeach
endforeach
Definition: block-admin-display-form.tpl.php:64
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
$row
$row
Definition: block-admin-display-form.tpl.php:47
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
$form_submit
print $form_submit
Definition: block-admin-display-form.tpl.php:69
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/node_access_example/node_access_example.install Source File

  • examples
  • node_access_example
node_access_example.install
Go to the documentation of this file.
1 <?php
2
11 function node_access_example_schema() {
12 $schema['node_access_example'] = array(
13 'description' => 'Example table for node_access_example module',
14 'fields' => array(
15 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
16 'private' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
17 ),
18 'primary key' => array('nid'),
19 );
20
21 return $schema;
22 }
node_access_example_schema
node_access_example_schema()
Definition: node_access_example.install:11
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/block_example/block_example.module Source File

  • examples
  • block_example
block_example.module
Go to the documentation of this file.
1 <?php
23 function block_example_menu() {
24 $items['examples/block_example'] = array(
25 'page callback' => 'block_example_page',
26 'access callback' => TRUE,
27 'title' => 'Block Example',
28 );
29 return $items;
30 }
31
35 function block_example_page() {
36 $page = array(
37 '#type' => 'markup',
38 '#markup' => t('The Block Example provides two sample blocks which demonstrate the various block APIs. To experiment with the blocks, enable and configure them on <a href="@url">the block admin page</a>.', array('@url' => url('admin/structure/block'))),
39 );
40 return $page;
41 }
47 function block_example_block_info() {
48 // This hook returns an array, each component of which is an array of block
49 // information. The array keys are the 'delta' values used in other block
50 // hooks.
51
52 // The required block information is a block description, which is shown
53 // to the site administrator in the list of possible blocks. You can also
54 // provide initial settings for block weight, status, etc.
55
56 // Many options are defined in hook_block_info():
57 $blocks['example_configurable_text'] = array(
58 // info: The name of the block.
59 'info' => t('Example: configurable text string'),
60 // Block caching options (per role, per user, etc.)
61 'cache' => DRUPAL_CACHE_PER_ROLE, // default
62 );
63
64 // This sample shows how to provide default settings. In this case we'll
65 // enable the block in the first sidebar and make it visible only on
66 // 'node/*' pages. See the hook_block_info() documentation for these.
67 $blocks['example_empty'] = array(
68 'info' => t('Example: empty block'),
69 'status' => TRUE,
70 'region' => 'sidebar_first', // Not usually provided.
71 'visibility' => BLOCK_VISIBILITY_LISTED, // Not usually provided.
72 'pages' => 'node/*', // Not usually provided here.
73 );
74
75 $blocks['example_uppercase'] = array(
76 // info: The name of the block.
77 'info' => t('Example: uppercase this please'),
78 'status' => TRUE,
79 'region' => 'sidebar_first', // Not usually provided.
80 );
81
82 return $blocks;
83 }
84
90 function block_example_block_configure($delta = '') {
91 // The $delta parameter tells us which block is being configured.
92 // In this example, we'll allow the administrator to customize
93 // the text of the 'configurable text string' block defined in this module.
94
95 $form = array();
96 if ($delta == 'example_configurable_text') {
97 // All we need to provide is the specific configuration options for our
98 // block. Drupal will take care of the standard block configuration options
99 // (block title, page visibility, etc.) and the save button.
100 $form['block_example_string'] = array(
101 '#type' => 'textfield',
102 '#title' => t('Block contents'),
103 '#size' => 60,
104 '#description' => t('This text will appear in the example block.'),
105 '#default_value' => variable_get('block_example_string', t('Some example content.')),
106 );
107 }
108 return $form;
109 }
110
117 function block_example_block_save($delta = '', $edit = array()) {
118 // We need to save settings from the configuration form.
119 // We need to check $delta to make sure we are saving the right block.
120 if ($delta == 'example_configurable_text') {
121 // Have Drupal save the string to the database.
122 variable_set('block_example_string', $edit['block_example_string']);
123 }
124 }
125
131 function block_example_block_view($delta = '') {
132 // The $delta parameter tells us which block is being requested.
133 switch ($delta) {
134 case 'example_configurable_text':
135 // The subject is displayed at the top of the block. Note that it
136 // should be passed through t() for translation. The title configured
137 // for the block using Drupal UI supercedes this one.
138 $block['subject'] = t('Title of first block (example_configurable_text)');
139 // The content of the block is typically generated by calling a custom
140 // function.
141 $block['content'] = block_example_contents($delta);
142 break;
143
144 case 'example_empty':
145 $block['subject'] = t('Title of second block (example_empty)');
146 $block['content'] = block_example_contents($delta);
147 break;
148
149 case 'example_uppercase':
150 $block['subject'] = t("uppercase this please");
151 $block['content'] = t("This block's title will be changed to uppercase. Any other block with 'uppercase' in the subject or title will also be altered. If you change this block's title through the UI to omit the word 'uppercase', it will still be altered to uppercase as the subject key has not been changed.");
152 break;
153 }
154 return $block;
155 }
156
160 function block_example_contents($which_block) {
161 switch ($which_block) {
162 case 'example_configurable_text':
163 // Modules would typically perform some database queries to fetch the
164 // content for their blocks. Here, we'll just use the variable set in the
165 // block configuration or, if none has set, a default value.
166 // Block content can be returned in two formats: renderable arrays
167 // (as here) are preferred though a simple string will work as well.
168 // Block content created through the UI defaults to a string.
169 return array('#markup' => variable_get('block_example_string', t('A default value. This block was created at %time', array('%time' => date('c')))));
170
171 case 'example_empty':
172 // It is possible that a block not have any content, since it is
173 // probably dynamically constructed. In this case, Drupal will not display
174 // the block at all. This block will not be displayed.
175 return;
176 }
177 }
178
179 /*
180 * The following hooks can be used to alter blocks
181 * provided by your own or other modules.
182 */
183
195 function block_example_block_list_alter(&$blocks) {
196 // We are going to make the search block sticky on bottom of regions. For
197 // this example, we will modify the block list and append the search block at
198 // the end of the list, so even if the administrator configures the block to
199 // be on the top of the region, it will demote to bottom again.
200 foreach ($blocks as $bid => $block) {
201 if (($block->module == 'search') && ($block->delta == 'form')) {
202 // Remove the block from the list and append to the end.
203 unset($blocks[$bid]);
204 $blocks[$bid] = $block;
205 break;
206 }
207 }
208 }
209
230 function block_example_block_view_alter(&$data, $block) {
231 // We'll search for the string 'uppercase'.
232 if ((!empty($block->title) && stristr($block->title, 'uppercase')) || (!empty($data['subject']) && stristr($data['subject'], 'uppercase'))) {
233 // This will uppercase the default title.
234 $data['subject'] = isset($data['subject']) ? drupal_strtoupper($data['subject']) : '';
235 // This will uppercase a title set in the UI.
236 $block->title = isset($block->title) ? drupal_strtoupper($block->title) : '';
237 }
238 }
BLOCK_VISIBILITY_LISTED
const BLOCK_VISIBILITY_LISTED
Definition: block.module:36
block_example_block_view
block_example_block_view($delta= '')
Definition: block_example.module:131
$page
print $page
Definition: overlay.tpl.php:37
block_example_page
block_example_page()
Definition: block_example.module:35
block_example_block_configure
block_example_block_configure($delta= '')
Definition: block_example.module:90
block_example_block_save
block_example_block_save($delta= '', $edit=array())
Definition: block_example.module:117
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
block_example_menu
block_example_menu()
Definition: block_example.module:23
block_example_block_view_alter
block_example_block_view_alter(&$data, $block)
Definition: block_example.module:230
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
drupal_strtoupper
drupal_strtoupper($text)
Definition: unicode.inc:496
block_example_block_list_alter
block_example_block_list_alter(&$blocks)
Definition: block_example.module:195
block_example_contents
block_example_contents($which_block)
Definition: block_example.module:160
block_example_block_info
block_example_block_info()
Definition: block_example.module:47
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
DRUPAL_CACHE_PER_ROLE
const DRUPAL_CACHE_PER_ROLE
Definition: common.inc:143
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/pager.inc Source File

  • includes
pager.inc
Go to the documentation of this file.
1 <?php
2
15 class PagerDefault extends SelectQueryExtender {
16
22 static $maxElement = 0;
23
29 protected $limit = 10;
30
36 protected $element = NULL;
37
43 protected $customCountQuery = FALSE;
44
45 public function __construct(SelectQueryInterface $query, DatabaseConnection $connection) {
46 parent::__construct($query, $connection);
47
48 // Add pager tag. Do this here to ensure that it is always added before
49 // preExecute() is called.
50 $this->addTag('pager');
51 }
52
59 public function execute() {
60
61 // Add convenience tag to mark that this is an extended query. We have to
62 // do this in the constructor to ensure that it is set before preExecute()
63 // gets called.
64 if (!$this->preExecute($this)) {
65 return NULL;
66 }
67
68 // A NULL limit is the "kill switch" for pager queries.
69 if (empty($this->limit)) {
70 return;
71 }
72 $this->ensureElement();
73
74 $total_items = $this->getCountQuery()->execute()->fetchField();
75 $current_page = pager_default_initialize($total_items, $this->limit, $this->element);
76 $this->range($current_page * $this->limit, $this->limit);
77
78 // Now that we've added our pager-based range instructions, run the query normally.
79 return $this->query->execute();
80 }
81
90 protected function ensureElement() {
91 if (!isset($this->element)) {
92 $this->element = self::$maxElement++;
93 }
94 }
95
106 public function setCountQuery(SelectQueryInterface $query) {
107 $this->customCountQuery = $query;
108 }
109
119 public function getCountQuery() {
120 if ($this->customCountQuery) {
121 return $this->customCountQuery;
122 }
123 else {
124 return $this->query->countQuery();
125 }
126 }
127
137 public function limit($limit = 10) {
138 $this->limit = $limit;
139 return $this;
140 }
141
160 public function element($element) {
161 $this->element = $element;
162 if ($element >= self::$maxElement) {
163 self::$maxElement = $element + 1;
164 }
165 return $this;
166 }
167 }
168
187 function pager_find_page($element = 0) {
188 $page = isset($_GET['page']) ? $_GET['page'] : '';
189 $page_array = explode(',', $page);
190 if (!isset($page_array[$element])) {
191 $page_array[$element] = 0;
192 }
193 return (int) $page_array[$element];
194 }
195
274 function pager_default_initialize($total, $limit, $element = 0) {
275 global $pager_page_array, $pager_total, $pager_total_items, $pager_limits;
276
277 $page = pager_find_page($element);
278
279 // We calculate the total of pages as ceil(items / limit).
280 $pager_total_items[$element] = $total;
281 $pager_total[$element] = ceil($pager_total_items[$element] / $limit);
282 $pager_page_array[$element] = max(0, min($page, ((int) $pager_total[$element]) - 1));
283 $pager_limits[$element] = $limit;
284 return $pager_page_array[$element];
285 }
286
294 function pager_get_query_parameters() {
295 $query = &drupal_static(__FUNCTION__);
296 if (!isset($query)) {
297 $query = drupal_get_query_parameters($_GET, array('q', 'page'));
298 }
299 return $query;
300 }
301
320 function theme_pager($variables) {
321 $tags = $variables['tags'];
322 $element = $variables['element'];
323 $parameters = $variables['parameters'];
324 $quantity = $variables['quantity'];
325 global $pager_page_array, $pager_total;
326
327 // Calculate various markers within this pager piece:
328 // Middle is used to "center" pages around the current page.
329 $pager_middle = ceil($quantity / 2);
330 // current is the page we are currently paged to
331 $pager_current = $pager_page_array[$element] + 1;
332 // first is the first page listed by this pager piece (re quantity)
333 $pager_first = $pager_current - $pager_middle + 1;
334 // last is the last page listed by this pager piece (re quantity)
335 $pager_last = $pager_current + $quantity - $pager_middle;
336 // max is the maximum page number
337 $pager_max = $pager_total[$element];
338 // End of marker calculations.
339
340 // Prepare for generation loop.
341 $i = $pager_first;
342 if ($pager_last > $pager_max) {
343 // Adjust "center" if at end of query.
344 $i = $i + ($pager_max - $pager_last);
345 $pager_last = $pager_max;
346 }
347 if ($i <= 0) {
348 // Adjust "center" if at start of query.
349 $pager_last = $pager_last + (1 - $i);
350 $i = 1;
351 }
352 // End of generation loop preparation.
353
354 $li_first = theme('pager_first', array('text' => (isset($tags[0]) ? $tags[0] : t('« first')), 'element' => $element, 'parameters' => $parameters));
355 $li_previous = theme('pager_previous', array('text' => (isset($tags[1]) ? $tags[1] : t('‹ previous')), 'element' => $element, 'interval' => 1, 'parameters' => $parameters));
356 $li_next = theme('pager_next', array('text' => (isset($tags[3]) ? $tags[3] : t('next ›')), 'element' => $element, 'interval' => 1, 'parameters' => $parameters));
357 $li_last = theme('pager_last', array('text' => (isset($tags[4]) ? $tags[4] : t('last »')), 'element' => $element, 'parameters' => $parameters));
358
359 if ($pager_total[$element] > 1) {
360 if ($li_first) {
361 $items[] = array(
362 'class' => array('pager-first'),
363 'data' => $li_first,
364 );
365 }
366 if ($li_previous) {
367 $items[] = array(
368 'class' => array('pager-previous'),
369 'data' => $li_previous,
370 );
371 }
372
373 // When there is more than one page, create the pager list.
374 if ($i != $pager_max) {
375 if ($i > 1) {
376 $items[] = array(
377 'class' => array('pager-ellipsis'),
378 'data' => '…',
379 );
380 }
381 // Now generate the actual pager piece.
382 for (; $i <= $pager_last && $i <= $pager_max; $i++) {
383 if ($i < $pager_current) {
384 $items[] = array(
385 'class' => array('pager-item'),
386 'data' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => ($pager_current - $i), 'parameters' => $parameters)),
387 );
388 }
389 if ($i == $pager_current) {
390 $items[] = array(
391 'class' => array('pager-current'),
392 'data' => $i,
393 );
394 }
395 if ($i > $pager_current) {
396 $items[] = array(
397 'class' => array('pager-item'),
398 'data' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => ($i - $pager_current), 'parameters' => $parameters)),
399 );
400 }
401 }
402 if ($i < $pager_max) {
403 $items[] = array(
404 'class' => array('pager-ellipsis'),
405 'data' => '…',
406 );
407 }
408 }
409 // End generation.
410 if ($li_next) {
411 $items[] = array(
412 'class' => array('pager-next'),
413 'data' => $li_next,
414 );
415 }
416 if ($li_last) {
417 $items[] = array(
418 'class' => array('pager-last'),
419 'data' => $li_last,
420 );
421 }
422 return '<h2 class="element-invisible">' . t('Pages') . '</h2>' . theme('item_list', array(
423 'items' => $items,
424 'attributes' => array('class' => array('pager')),
425 ));
426 }
427 }
428
429
451 function theme_pager_first($variables) {
452 $text = $variables['text'];
453 $element = $variables['element'];
454 $parameters = $variables['parameters'];
455 global $pager_page_array;
456 $output = '';
457
458 // If we are anywhere but the first page
459 if ($pager_page_array[$element] > 0) {
460 $output = theme('pager_link', array('text' => $text, 'page_new' => pager_load_array(0, $element, $pager_page_array), 'element' => $element, 'parameters' => $parameters));
461 }
462
463 return $output;
464 }
465
480 function theme_pager_previous($variables) {
481 $text = $variables['text'];
482 $element = $variables['element'];
483 $interval = $variables['interval'];
484 $parameters = $variables['parameters'];
485 global $pager_page_array;
486 $output = '';
487
488 // If we are anywhere but the first page
489 if ($pager_page_array[$element] > 0) {
490 $page_new = pager_load_array($pager_page_array[$element] - $interval, $element, $pager_page_array);
491
492 // If the previous page is the first page, mark the link as such.
493 if ($page_new[$element] == 0) {
494 $output = theme('pager_first', array('text' => $text, 'element' => $element, 'parameters' => $parameters));
495 }
496 // The previous page is not the first page.
497 else {
498 $output = theme('pager_link', array('text' => $text, 'page_new' => $page_new, 'element' => $element, 'parameters' => $parameters));
499 }
500 }
501
502 return $output;
503 }
504
519 function theme_pager_next($variables) {
520 $text = $variables['text'];
521 $element = $variables['element'];
522 $interval = $variables['interval'];
523 $parameters = $variables['parameters'];
524 global $pager_page_array, $pager_total;
525 $output = '';
526
527 // If we are anywhere but the last page
528 if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
529 $page_new = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array);
530 // If the next page is the last page, mark the link as such.
531 if ($page_new[$element] == ($pager_total[$element] - 1)) {
532 $output = theme('pager_last', array('text' => $text, 'element' => $element, 'parameters' => $parameters));
533 }
534 // The next page is not the last page.
535 else {
536 $output = theme('pager_link', array('text' => $text, 'page_new' => $page_new, 'element' => $element, 'parameters' => $parameters));
537 }
538 }
539
540 return $output;
541 }
542
556 function theme_pager_last($variables) {
557 $text = $variables['text'];
558 $element = $variables['element'];
559 $parameters = $variables['parameters'];
560 global $pager_page_array, $pager_total;
561 $output = '';
562
563 // If we are anywhere but the last page
564 if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
565 $output = theme('pager_link', array('text' => $text, 'page_new' => pager_load_array($pager_total[$element] - 1, $element, $pager_page_array), 'element' => $element, 'parameters' => $parameters));
566 }
567
568 return $output;
569 }
570
571
594 function theme_pager_link($variables) {
595 $text = $variables['text'];
596 $page_new = $variables['page_new'];
597 $element = $variables['element'];
598 $parameters = $variables['parameters'];
599 $attributes = $variables['attributes'];
600
601 $page = isset($_GET['page']) ? $_GET['page'] : '';
602 if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
603 $parameters['page'] = $new_page;
604 }
605
606 $query = array();
607 if (count($parameters)) {
608 $query = drupal_get_query_parameters($parameters, array());
609 }
610 if ($query_pager = pager_get_query_parameters()) {
611 $query = array_merge($query, $query_pager);
612 }
613
614 // Set each pager link title
615 if (!isset($attributes['title'])) {
616 static $titles = NULL;
617 if (!isset($titles)) {
618 $titles = array(
619 t('« first') => t('Go to first page'),
620 t('‹ previous') => t('Go to previous page'),
621 t('next ›') => t('Go to next page'),
622 t('last »') => t('Go to last page'),
623 );
624 }
625 if (isset($titles[$text])) {
626 $attributes['title'] = $titles[$text];
627 }
628 elseif (is_numeric($text)) {
629 $attributes['title'] = t('Go to page @number', array('@number' => $text));
630 }
631 }
632
633 // @todo l() cannot be used here, since it adds an 'active' class based on the
634 // path only (which is always the current path for pager links). Apparently,
635 // none of the pager links is active at any time - but it should still be
636 // possible to use l() here.
637 // @see http://drupal.org/node/1410574
638 $attributes['href'] = url($_GET['q'], array('query' => $query));
639 return '<a' . drupal_attributes($attributes) . '>' . check_plain($text) . '</a>';
640 }
641
652 function pager_load_array($value, $element, $old_array) {
653 $new_array = $old_array;
654 // Look for empty elements.
655 for ($i = 0; $i < $element; $i++) {
656 if (empty($new_array[$i])) {
657 // Load found empty element with 0.
658 $new_array[$i] = 0;
659 }
660 }
661 // Update the changed element.
662 $new_array[$element] = (int) $value;
663 return $new_array;
664 }
pager_default_initialize
pager_default_initialize($total, $limit, $element=0)
Definition: pager.inc:274
pager_find_page
pager_find_page($element=0)
Definition: pager.inc:187
theme_pager_last
theme_pager_last($variables)
Definition: pager.inc:556
theme_pager_link
theme_pager_link($variables)
Definition: pager.inc:594
theme_pager_next
theme_pager_next($variables)
Definition: pager.inc:519
theme_pager_previous
theme_pager_previous($variables)
Definition: pager.inc:480
PagerDefault\$limit
$limit
Definition: pager.inc:29
$page
print $page
Definition: overlay.tpl.php:37
pager_get_query_parameters
pager_get_query_parameters()
Definition: pager.inc:294
drupal_get_query_parameters
drupal_get_query_parameters(array $query=NULL, array $exclude=array('q'), $parent= '')
Definition: common.inc:417
PagerDefault\$maxElement
static $maxElement
Definition: pager.inc:22
SelectQueryExtender
Definition: select.inc:535
drupal_attributes
drupal_attributes(array $attributes=array())
Definition: common.inc:2377
theme_pager_first
theme_pager_first($variables)
Definition: pager.inc:451
$attributes
print $attributes
Definition: block.tpl.php:47
PagerDefault\limit
limit($limit=10)
Definition: pager.inc:137
PagerDefault\$element
$element
Definition: pager.inc:36
PagerDefault\ensureElement
ensureElement()
Definition: pager.inc:90
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
pager_load_array
pager_load_array($value, $element, $old_array)
Definition: pager.inc:652
theme_pager
theme_pager($variables)
Definition: pager.inc:320
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
SelectQueryExtender\$query
$query
Definition: select.inc:542
PagerDefault\$customCountQuery
$customCountQuery
Definition: pager.inc:43
SelectQueryExtender\addTag
addTag($tag)
Definition: select.inc:583
$value
print $value
Definition: user-profile-item.tpl.php:26
SelectQueryInterface
Definition: select.inc:39
$output
$output
Definition: authorize.php:93
PagerDefault\element
element($element)
Definition: pager.inc:160
DatabaseConnection
Definition: database.inc:184
PagerDefault\setCountQuery
setCountQuery(SelectQueryInterface $query)
Definition: pager.inc:106
PagerDefault\getCountQuery
getCountQuery()
Definition: pager.inc:119
SelectQueryExtender\range
range($start=NULL, $length=NULL)
Definition: select.inc:774
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
SelectQueryExtender\preExecute
preExecute(SelectQueryInterface $query=NULL)
Definition: select.inc:706
PagerDefault\__construct
__construct(SelectQueryInterface $query, DatabaseConnection $connection)
Definition: pager.inc:45
PagerDefault
Definition: pager.inc:15
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
SelectQueryExtender\$connection
$connection
Definition: select.inc:549
PagerDefault\execute
execute()
Definition: pager.inc:59
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book-node-export-html.tpl.php Source File

  • modules
  • book
book-node-export-html.tpl.php
Go to the documentation of this file.
1 <?php
2
20 ?>
21 <div id="node-<?php print $node->nid; ?>" class="section-<?php print $depth; ?>">
22 <h1 class="book-heading"><?php print $title; ?></h1>
23 <?php print $content; ?>
24 <?php print $children; ?>
25 </div>
print
print
Definition: php-2.php:2
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
$children
print $children
Definition: book-node-export-html.tpl.php:24
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/contextual_links_example/contextual-links-example-object.tpl.php Source File

  • examples
  • contextual_links_example
contextual-links-example-object.tpl.php
Go to the documentation of this file.
1 <?php
2
30 ?>
31 <div class="<?php print $classes; ?>">
32 <?php print render($title_prefix); ?>
33 <h2><?php print $title; ?></h2>
34 <?php print render($title_suffix); ?>
35 <?php print $content; ?>
36 </div>
print
print
Definition: php-2.php:2
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
render
render(&$element)
Definition: common.inc:5988
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/comment.tpl.php Source File

  • themes
  • garland
comment.tpl.php
Go to the documentation of this file.
1 <?php
2 ?>
3 <div class="<?php print $classes . ' ' . $zebra; ?>"<?php print $attributes; ?>>
4
5 <div class="clearfix">
6
7 <span class="submitted"><?php print $submitted ?></span>
8
9 <?php if ($new): ?>
10 <span class="new"><?php print drupal_ucfirst($new) ?></span>
11 <?php endif; ?>
12
13 <?php print $picture ?>
14
15 <?php print render($title_prefix); ?>
16 <h3<?php print $title_attributes; ?>><?php print $title ?></h3>
17 <?php print render($title_suffix); ?>
18
19 <div class="content"<?php print $content_attributes; ?>>
20 <?php hide($content['links']); print render($content); ?>
21 <?php if ($signature): ?>
22 <div class="clearfix">
23 <div>—</div>
24 <?php print $signature ?>
25 </div>
26 <?php endif; ?>
27 </div>
28 </div>
29
30 <?php print render($content['links']) ?>
31 </div>
$attributes
print $attributes
Definition: block.tpl.php:47
print
print
Definition: php-2.php:2
$content_attributes
print $content_attributes
Definition: block.tpl.php:55
$picture
print $picture
Definition: comment.tpl.php:64
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
hide
hide(&$element)
Definition: common.inc:6021
endif
endif
Definition: aggregator-item.tpl.php:31
$submitted
print $submitted
Definition: comment.tpl.php:75
render
render(&$element)
Definition: common.inc:5988
drupal_ucfirst
drupal_ucfirst($text)
Definition: unicode.inc:561
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book-navigation.tpl.php Source File

  • modules
  • book
book-navigation.tpl.php
Go to the documentation of this file.
1 <?php
2
34 ?>
35 <?php if ($tree || $has_links): ?>
36 <div id="book-navigation-<?php print $book_id; ?>" class="book-navigation">
37 <?php print $tree; ?>
38
39 <?php if ($has_links): ?>
40 <div class="page-links clearfix">
41 <?php if ($prev_url): ?>
42 <a href="<?php print $prev_url; ?>" class="page-previous" title="<?php print t('Go to previous page'); ?>"><?php print t('‹ ') . $prev_title; ?></a>
43 <?php endif; ?>
44 <?php if ($parent_url): ?>
45 <a href="<?php print $parent_url; ?>" class="page-up" title="<?php print t('Go to parent page'); ?>"><?php print t('up'); ?></a>
46 <?php endif; ?>
47 <?php if ($next_url): ?>
48 <a href="<?php print $next_url; ?>" class="page-next" title="<?php print t('Go to next page'); ?>"><?php print $next_title . t(' ›'); ?></a>
49 <?php endif; ?>
50 </div>
51 <?php endif; ?>
52
53 </div>
54 <?php endif; ?>
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
endif
endif
Definition: aggregator-item.tpl.php:31
title
print $topic title
Definition: forum-topic-list.tpl.php:50
$tree
if($tree||$has_links) print $tree
Definition: book-navigation.tpl.php:35
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/batch_example/batch_example.install Source File

  • examples
  • batch_example
batch_example.install
Go to the documentation of this file.
1 <?php
2
27 function batch_example_update_7100(&$sandbox) {
28 $ret = array();
29
30 // Use the sandbox at your convenience to store the information needed
31 // to track progression between successive calls to the function.
32 if (!isset($sandbox['progress'])) {
33 $sandbox['progress'] = 0; // The count of nodes visited so far.
34 // Total nodes that must be visited.
35 $sandbox['max'] = db_query('SELECT COUNT(nid) FROM {node}')->fetchField();
36 // A place to store messages during the run.
37 $sandbox['messages'] = array();
38 $sandbox['current_node'] = -1; // Last node read via the query.
39 }
40
41 // Process nodes by groups of 10 (arbitrary value).
42 // When a group is processed, the batch update engine determines
43 // whether it should continue processing in the same request or provide
44 // progress feedback to the user and wait for the next request.
45 $limit = 10;
46
47 // Retrieve the next group of nids.
48 $result = db_select('node', 'n')
49 ->fields('n', array('nid'))
50 ->orderBy('n.nid', 'ASC')
51 ->where('n.nid > :nid', array(':nid' => $sandbox['current_node']))
52 ->extend('PagerDefault')
53 ->limit($limit)
54 ->execute();
55 foreach ($result as $row) {
56 // Here we actually perform a dummy 'update' on the current node.
57 $node = db_query('SELECT nid FROM {node} WHERE nid = :nid', array(':nid' => $row->nid))->fetchField();
58
59 // Update our progress information.
60 $sandbox['progress']++;
61 $sandbox['current_node'] = $row->nid;
62 }
63
64 // Set the "finished" status, to tell batch engine whether this function
65 // needs to run again. If you set a float, this will indicate the progress
66 // of the batch so the progress bar will update.
67 $sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']);
68
69 // Set up a per-run message; Make a copy of $sandbox so we can change it.
70 // This is simply a debugging stanza to illustrate how to capture status
71 // from each pass through hook_update_N().
72 $sandbox_status = $sandbox;
73 unset($sandbox_status['messages']); // Don't want them in the output.
74 $sandbox['messages'][] = t('$sandbox=') . print_r($sandbox_status, TRUE);
75
76 if ($sandbox['#finished']) {
77 // hook_update_N() may optionally return a string which will be displayed
78 // to the user.
79 $final_message = '<ul><li>' . implode('</li><li>', $sandbox['messages']) . "</li></ul>";
80 return t('The batch_example demonstration update did what it was supposed to do: @message', array('@message' => $final_message));
81 }
82 }
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$row
$row
Definition: block-admin-display-form.tpl.php:47
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
batch_example_update_7100
batch_example_update_7100(&$sandbox)
Definition: batch_example.install:27
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/trigger/trigger.module Source File

  • modules
  • trigger
trigger.module
Go to the documentation of this file.
1 <?php
2
11 function trigger_help($path, $arg) {
12 // Generate help text for admin/structure/trigger/(module) tabs.
13 $matches = array();
14 if (preg_match('|^admin/structure/trigger/(.*)$|', $path, $matches)) {
15 $explanation = '<p>' . t('Triggers are events on your site, such as new content being added or a user logging in. The Trigger module associates these triggers with actions (functional tasks), such as unpublishing content containing certain keywords or e-mailing an administrator. The <a href="@url">Actions settings page</a> contains a list of existing actions and provides the ability to create and configure advanced actions (actions requiring configuration, such as an e-mail address or a list of banned words).', array('@url' => url('admin/config/system/actions'))) . '</p>';
16
17 $module = $matches[1];
18 $trigger_info = _trigger_tab_information();
19 if (!empty($trigger_info[$module])) {
20 $explanation .= '<p>' . t('There is a tab on this page for each module that defines triggers. On this tab you can assign actions to run when triggers from the <a href="@module-help">@module-name module</a> happen.', array('@module-help' => url('admin/help/' . $module), '@module-name' => $trigger_info[$module])) . '</p>';
21 }
22
23 return $explanation;
24 }
25
26 if ($path == 'admin/help#trigger') {
27 $output = '';
28 $output .= '<h3>' . t('About') . '</h3>';
29 $output .= '<p>' . t('The Trigger module provides the ability to cause <em>actions</em> to run when certain <em>triggers</em> take place on your site. Triggers are events, such as new content being added to your site or a user logging in, and actions are tasks, such as unpublishing content or e-mailing an administrator. For more information, see the online handbook entry for <a href="@trigger">Trigger module</a>.', array('@trigger' => 'http://drupal.org/documentation/modules/trigger/')) . '</p>';
30 $output .= '<h3>' . t('Uses') . '</h3>';
31 $output .= '<dl>';
32 $output .= '<dt>' . t('Configuring triggers and actions') . '</dt>';
33 $output .= '<dd>' . t('The combination of actions and triggers can perform many useful tasks, such as e-mailing an administrator if a user account is deleted, or automatically unpublishing comments that contain certain words. To set up a trigger/action combination, first visit the <a href="@actions-page">Actions configuration page</a>, where you can either verify that the action you want is already listed, or create a new <em>advanced</em> action. You will need to set up an advanced action if there are configuration options in your trigger/action combination, such as specifying an e-mail address or a list of banned words. After configuring or verifying your action, visit the <a href="@triggers-page">Triggers configuration page</a> and choose the appropriate tab (Comment, Taxonomy, etc.), where you can assign the action to run when the trigger event occurs.', array('@triggers-page' => url('admin/structure/trigger'), '@actions-page' => url('admin/config/system/actions'))) . '</dd>';
34 $output .= '</dl>';
35 return $output;
36 }
37 }
38
42 function trigger_menu() {
43 $items['admin/structure/trigger'] = array(
44 'title' => 'Triggers',
45 'description' => 'Configure when to execute actions.',
46 'page callback' => 'trigger_assign',
47 'access arguments' => array('administer actions'),
48 'file' => 'trigger.admin.inc',
49 );
50
51 $trigger_info = _trigger_tab_information();
52 foreach ($trigger_info as $module => $module_name) {
53 $items["admin/structure/trigger/$module"] = array(
54 'title' => $module_name,
55 'page callback' => 'trigger_assign',
56 'page arguments' => array($module),
57 'access arguments' => array('administer actions'),
58 'type' => MENU_LOCAL_TASK,
59 'file' => 'trigger.admin.inc',
60 );
61 }
62
63 $items['admin/structure/trigger/unassign'] = array(
64 'title' => 'Unassign',
65 'description' => 'Unassign an action from a trigger.',
66 'page callback' => 'drupal_get_form',
67 'page arguments' => array('trigger_unassign'),
68 // Only accessible if there are any actions that can be unassigned.
69 'access callback' => 'trigger_menu_unassign_access',
70 // Only output in the breadcrumb, not in menu trees.
71 'type' => MENU_VISIBLE_IN_BREADCRUMB,
72 'file' => 'trigger.admin.inc',
73 );
74
75 return $items;
76 }
77
86 function trigger_menu_unassign_access() {
87 if (!user_access('administer actions')) {
88 return FALSE;
89 }
90 $count = db_select('trigger_assignments')
91 ->countQuery()
92 ->execute()
93 ->fetchField();
94 return $count > 0;
95 }
96
102 function trigger_trigger_info() {
103 return array(
104 'node' => array(
105 'node_presave' => array(
106 'label' => t('When either saving new content or updating existing content'),
107 ),
108 'node_insert' => array(
109 'label' => t('After saving new content'),
110 ),
111 'node_update' => array(
112 'label' => t('After saving updated content'),
113 ),
114 'node_delete' => array(
115 'label' => t('After deleting content'),
116 ),
117 'node_view' => array(
118 'label' => t('When content is viewed by an authenticated user'),
119 ),
120 ),
121 'comment' => array(
122 'comment_presave' => array(
123 'label' => t('When either saving a new comment or updating an existing comment'),
124 ),
125 'comment_insert' => array(
126 'label' => t('After saving a new comment'),
127 ),
128 'comment_update' => array(
129 'label' => t('After saving an updated comment'),
130 ),
131 'comment_delete' => array(
132 'label' => t('After deleting a comment'),
133 ),
134 'comment_view' => array(
135 'label' => t('When a comment is being viewed by an authenticated user'),
136 ),
137 ),
138 'taxonomy' => array(
139 'taxonomy_term_insert' => array(
140 'label' => t('After saving a new term to the database'),
141 ),
142 'taxonomy_term_update' => array(
143 'label' => t('After saving an updated term to the database'),
144 ),
145 'taxonomy_term_delete' => array(
146 'label' => t('After deleting a term'),
147 ),
148 ),
149 'system' => array(
150 'cron' => array(
151 'label' => t('When cron runs'),
152 ),
153 ),
154 'user' => array(
155 'user_insert' => array(
156 'label' => t('After creating a new user account'),
157 ),
158 'user_update' => array(
159 'label' => t('After updating a user account'),
160 ),
161 'user_delete' => array(
162 'label' => t('After a user has been deleted'),
163 ),
164 'user_login' => array(
165 'label' => t('After a user has logged in'),
166 ),
167 'user_logout' => array(
168 'label' => t('After a user has logged out'),
169 ),
170 'user_view' => array(
171 'label' => t("When a user's profile is being viewed"),
172 ),
173 ),
174 );
175 }
176
188 function trigger_get_assigned_actions($hook) {
189 $actions = &drupal_static(__FUNCTION__, array());
190 if (!isset($actions[$hook])) {
191 $actions[$hook] = db_query("SELECT ta.aid, a.type, a.label FROM {trigger_assignments} ta LEFT JOIN {actions} a ON ta.aid = a.aid WHERE ta.hook = :hook ORDER BY ta.weight", array(
192 ':hook' => $hook,
193 ))->fetchAllAssoc('aid', PDO::FETCH_ASSOC);
194 }
195 return $actions[$hook];
196 }
197
201 function trigger_theme() {
202 return array(
203 'trigger_display' => array(
204 'render element' => 'element',
205 'file' => 'trigger.admin.inc',
206 ),
207 );
208 }
209
215 function trigger_forms() {
216 $trigger_info = _trigger_get_all_info();
217 $forms = array();
218 foreach ($trigger_info as $module => $hooks) {
219 foreach ($hooks as $hook => $description) {
220 $forms['trigger_' . $hook . '_assign_form'] = array('callback' => 'trigger_assign_form');
221 }
222 }
223
224 return $forms;
225 }
226
244 function _trigger_normalize_node_context($type, $node) {
245 // Note that comment-type actions are not supported in node contexts,
246 // because we wouldn't know which comment to choose.
247 switch ($type) {
248 // An action that works on users is being called in a node context.
249 // Load the user object of the node's author.
250 case 'user':
251 return user_load($node->uid);
252 }
253 }
254
267 function _trigger_node($node, $hook, $a3 = NULL, $a4 = NULL) {
268 // Keep objects for reuse so that changes actions make to objects can persist.
269 static $objects;
270 // Prevent recursion by tracking which operations have already been called.
271 static $recursion;
272
273 $aids = trigger_get_assigned_actions($hook);
274 if (!$aids) {
275 return;
276 }
277
278 if (isset($recursion[$hook])) {
279 return;
280 }
281 $recursion[$hook] = TRUE;
282
283 $context = array(
284 'group' => 'node',
285 'hook' => $hook,
286 );
287
288 // We need to get the expected object if the action's type is not 'node'.
289 // We keep the object in $objects so we can reuse it if we have multiple actions
290 // that make changes to an object.
291 foreach ($aids as $aid => $info) {
292 $type = $info['type'];
293 if ($type != 'node') {
294 if (!isset($objects[$type])) {
295 $objects[$type] = _trigger_normalize_node_context($type, $node);
296 }
297 // Since we know about the node, we pass that info along to the action.
298 $context['node'] = $node;
299 $result = actions_do($aid, $objects[$type], $context, $a3, $a4);
300 }
301 else {
302 actions_do($aid, $node, $context, $a3, $a4);
303 }
304 }
305
306 unset($recursion[$hook]);
307 }
308
312 function trigger_node_view($node, $view_mode) {
313 _trigger_node($node, 'node_view', $view_mode);
314 }
315
319 function trigger_node_update($node) {
320 _trigger_node($node, 'node_update');
321 }
322
326 function trigger_node_presave($node) {
327 _trigger_node($node, 'node_presave');
328 }
329
333 function trigger_node_insert($node) {
334 _trigger_node($node, 'node_insert');
335 }
336
340 function trigger_node_delete($node) {
341 _trigger_node($node, 'node_delete');
342 }
343
361 function _trigger_normalize_comment_context($type, $comment) {
362 switch ($type) {
363 // An action that works with nodes is being called in a comment context.
364 case 'node':
365 return node_load(is_array($comment) ? $comment['nid'] : $comment->nid);
366
367 // An action that works on users is being called in a comment context.
368 case 'user':
369 return user_load(is_array($comment) ? $comment['uid'] : $comment->uid);
370 }
371 }
372
376 function trigger_comment_presave($comment) {
377 _trigger_comment($comment, 'comment_presave');
378 }
379
383 function trigger_comment_insert($comment) {
384 _trigger_comment($comment, 'comment_insert');
385 }
386
390 function trigger_comment_update($comment) {
391 _trigger_comment($comment, 'comment_update');
392 }
393
397 function trigger_comment_delete($comment) {
398 _trigger_comment($comment, 'comment_delete');
399 }
400
404 function trigger_comment_view($comment) {
405 _trigger_comment($comment, 'comment_view');
406 }
407
416 function _trigger_comment($a1, $hook) {
417 // Keep objects for reuse so that changes actions make to objects can persist.
418 static $objects;
419 $aids = trigger_get_assigned_actions($hook);
420 $context = array(
421 'group' => 'comment',
422 'hook' => $hook,
423 );
424 // We need to get the expected object if the action's type is not 'comment'.
425 // We keep the object in $objects so we can reuse it if we have multiple
426 // actions that make changes to an object.
427 foreach ($aids as $aid => $info) {
428 $type = $info['type'];
429 if ($type != 'comment') {
430 if (!isset($objects[$type])) {
431 $objects[$type] = _trigger_normalize_comment_context($type, $a1);
432 }
433 // Since we know about the comment, we pass it along to the action
434 // in case it wants to peek at it.
435 $context['comment'] = (object) $a1;
436 actions_do($aid, $objects[$type], $context);
437 }
438 else {
439 actions_do($aid, $a1, $context);
440 }
441 }
442 }
443
447 function trigger_cron() {
448 $aids = trigger_get_assigned_actions('cron');
449 $context = array(
450 'group' => 'cron',
451 'hook' => 'cron',
452 );
453 // Cron does not act on any specific object.
454 $object = NULL;
455 actions_do(array_keys($aids), $object, $context);
456 }
457
475 function _trigger_normalize_user_context($type, $account) {
476 // Note that comment-type actions are not supported in user contexts,
477 // because we wouldn't know which comment to choose.
478 switch ($type) {
479 // An action that works with nodes is being called in a user context.
480 // If a single node is being viewed, return the node.
481 case 'node':
482 // If we are viewing an individual node, return the node.
483 if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == NULL) {
484 return node_load(array('nid' => arg(1)));
485 }
486 break;
487 }
488 }
489
493 function trigger_user_login(&$edit, $account, $category) {
494 _trigger_user('user_login', $edit, $account, $category);
495 }
496
500 function trigger_user_logout($account) {
501 $edit = array();
502 _trigger_user('user_logout', $edit, $account);
503 }
504
508 function trigger_user_insert(&$edit, $account, $category) {
509 _trigger_user('user_insert', $edit, $account, $category);
510 }
511
515 function trigger_user_update(&$edit, $account, $category) {
516 _trigger_user('user_update', $edit, $account, $category);
517 }
518
522 function trigger_user_cancel($edit, $account, $method) {
523 switch ($method) {
524 case 'user_cancel_reassign':
525 _trigger_user('user_delete', $edit, $account, $method);
526 break;
527 }
528 }
529
533 function trigger_user_delete($account) {
534 $edit = array();
535 _trigger_user('user_delete', $edit, $account, NULL);
536 }
537
541 function trigger_user_view($account) {
542 $edit = NULL;
543 _trigger_user('user_view', $edit, $account, NULL);
544 }
545
558 function _trigger_user($hook, &$edit, $account, $category = NULL) {
559 // Keep objects for reuse so that changes actions make to objects can persist.
560 static $objects;
561 $aids = trigger_get_assigned_actions($hook);
562 $context = array(
563 'group' => 'user',
564 'hook' => $hook,
565 'form_values' => &$edit,
566 );
567 foreach ($aids as $aid => $info) {
568 $type = $info['type'];
569 if ($type != 'user') {
570 if (!isset($objects[$type])) {
571 $objects[$type] = _trigger_normalize_user_context($type, $account);
572 }
573 $context['user'] = $account;
574 actions_do($aid, $objects[$type], $context);
575 }
576 else {
577 actions_do($aid, $account, $context, $category);
578 }
579 }
580 }
581
592 function _trigger_taxonomy($hook, $array) {
593 $aids = trigger_get_assigned_actions($hook);
594 $context = array(
595 'group' => 'taxonomy',
596 'hook' => $hook
597 );
598 actions_do(array_keys($aids), (object) $array, $context);
599 }
600
604 function trigger_taxonomy_term_insert($term) {
605 _trigger_taxonomy('taxonomy_term_insert', (array) $term);
606 }
607
611 function trigger_taxonomy_term_update($term) {
612 _trigger_taxonomy('taxonomy_term_update', (array) $term);
613 }
614
618 function trigger_taxonomy_term_delete($term) {
619 _trigger_taxonomy('taxonomy_term_delete', (array) $term);
620 }
621
627 function trigger_actions_delete($aid) {
628 db_delete('trigger_assignments')
629 ->condition('aid', $aid)
630 ->execute();
631 drupal_static_reset('trigger_get_assigned_actions');
632 }
633
640 function _trigger_get_all_info() {
641 $triggers = &drupal_static(__FUNCTION__);
642
643 if (!isset($triggers)) {
644 $triggers = module_invoke_all('trigger_info');
645 drupal_alter('trigger_info', $triggers);
646 }
647
648 return $triggers;
649 }
650
659 function _trigger_tab_information() {
660 // Gather information about all triggers and modules.
661 $trigger_info = _trigger_get_all_info();
662 $modules = system_get_info('module');
663 $modules = array_intersect_key($modules, $trigger_info);
664
665 $return_info = array();
666 foreach ($modules as $name => $info) {
667 $return_info[$name] = $info['name'];
668 }
669
670 return $return_info;
671 }
trigger_comment_insert
trigger_comment_insert($comment)
Definition: trigger.module:383
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
trigger_node_insert
trigger_node_insert($node)
Definition: trigger.module:333
trigger_get_assigned_actions
trigger_get_assigned_actions($hook)
Definition: trigger.module:188
trigger_taxonomy_term_update
trigger_taxonomy_term_update($term)
Definition: trigger.module:611
trigger_user_delete
trigger_user_delete($account)
Definition: trigger.module:533
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
trigger_node_view
trigger_node_view($node, $view_mode)
Definition: trigger.module:312
$module
print $module
Definition: search-results.tpl.php:28
_trigger_user
_trigger_user($hook, &$edit, $account, $category=NULL)
Definition: trigger.module:558
_trigger_tab_information
_trigger_tab_information()
Definition: trigger.module:659
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
trigger_comment_delete
trigger_comment_delete($comment)
Definition: trigger.module:397
trigger_user_login
trigger_user_login(&$edit, $account, $category)
Definition: trigger.module:493
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
trigger_comment_view
trigger_comment_view($comment)
Definition: trigger.module:404
trigger_menu
trigger_menu()
Definition: trigger.module:42
trigger_node_presave
trigger_node_presave($node)
Definition: trigger.module:326
trigger_node_delete
trigger_node_delete($node)
Definition: trigger.module:340
trigger_comment_update
trigger_comment_update($comment)
Definition: trigger.module:390
trigger_forms
trigger_forms()
Definition: trigger.module:215
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
trigger_menu_unassign_access
trigger_menu_unassign_access()
Definition: trigger.module:86
_trigger_normalize_node_context
_trigger_normalize_node_context($type, $node)
Definition: trigger.module:244
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
actions_do
actions_do($action_ids, $object=NULL, $context=NULL, $a1=NULL, $a2=NULL)
Definition: actions.inc:58
_trigger_get_all_info
_trigger_get_all_info()
Definition: trigger.module:640
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
system_get_info
system_get_info($type, $name=NULL)
Definition: system.module:2338
$info
$info
Definition: color.inc:6
_trigger_normalize_user_context
_trigger_normalize_user_context($type, $account)
Definition: trigger.module:475
trigger_actions_delete
trigger_actions_delete($aid)
Definition: trigger.module:627
trigger_user_insert
trigger_user_insert(&$edit, $account, $category)
Definition: trigger.module:508
trigger_user_update
trigger_user_update(&$edit, $account, $category)
Definition: trigger.module:515
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
trigger_node_update
trigger_node_update($node)
Definition: trigger.module:319
_trigger_normalize_comment_context
_trigger_normalize_comment_context($type, $comment)
Definition: trigger.module:361
trigger_user_view
trigger_user_view($account)
Definition: trigger.module:541
MENU_VISIBLE_IN_BREADCRUMB
const MENU_VISIBLE_IN_BREADCRUMB
Definition: menu.inc:96
_trigger_node
_trigger_node($node, $hook, $a3=NULL, $a4=NULL)
Definition: trigger.module:267
_trigger_taxonomy
_trigger_taxonomy($hook, $array)
Definition: trigger.module:592
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
trigger_user_cancel
trigger_user_cancel($edit, $account, $method)
Definition: trigger.module:522
_trigger_comment
_trigger_comment($a1, $hook)
Definition: trigger.module:416
trigger_comment_presave
trigger_comment_presave($comment)
Definition: trigger.module:376
trigger_user_logout
trigger_user_logout($account)
Definition: trigger.module:500
trigger_trigger_info
trigger_trigger_info()
Definition: trigger.module:102
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
trigger_help
trigger_help($path, $arg)
Definition: trigger.module:11
trigger_taxonomy_term_insert
trigger_taxonomy_term_insert($term)
Definition: trigger.module:604
trigger_theme
trigger_theme()
Definition: trigger.module:201
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
trigger_taxonomy_term_delete
trigger_taxonomy_term_delete($term)
Definition: trigger.module:618
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
trigger_cron
trigger_cron()
Definition: trigger.module:447
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.module Source File

  • modules
  • update
update.module
Go to the documentation of this file.
1 <?php
2
17 define('UPDATE_DEFAULT_URL', 'http://updates.drupal.org/release-history');
18
19 // These are internally used constants for this code, do not modify.
20
24 define('UPDATE_NOT_SECURE', 1);
25
29 define('UPDATE_REVOKED', 2);
30
34 define('UPDATE_NOT_SUPPORTED', 3);
35
39 define('UPDATE_NOT_CURRENT', 4);
40
44 define('UPDATE_CURRENT', 5);
45
49 define('UPDATE_NOT_CHECKED', -1);
50
54 define('UPDATE_UNKNOWN', -2);
55
59 define('UPDATE_NOT_FETCHED', -3);
60
64 define('UPDATE_FETCH_PENDING', -4);
65
69 define('UPDATE_MAX_FETCH_ATTEMPTS', 2);
70
74 define('UPDATE_MAX_FETCH_TIME', 5);
75
79 function update_help($path, $arg) {
80 switch ($path) {
81 case 'admin/reports/updates':
82 return '<p>' . t('Here you can find information about available updates for your installed modules and themes. Note that each module or theme is part of a "project", which may or may not have the same name, and might include multiple modules or themes within it.') . '</p>';
83
84 case 'admin/help#update':
85 $output = '';
86 $output .= '<h3>' . t('About') . '</h3>';
87 $output .= '<p>' . t("The Update manager module periodically checks for new versions of your site's software (including contributed modules and themes), and alerts administrators to available updates. In order to provide update information, anonymous usage statistics are sent to Drupal.org. If desired, you may disable the Update manager module from the <a href='@modules'>Module administration page</a>. For more information, see the online handbook entry for <a href='@update'>Update manager module</a>.", array('@update' => 'http://drupal.org/documentation/modules/update', '@modules' => url('admin/modules'))) . '</p>';
88 // Only explain the Update manager if it has not been disabled.
89 if (update_manager_access()) {
90 $output .= '<p>' . t('The Update manager also allows administrators to update and install modules and themes through the administration interface.') . '</p>';
91 }
92 $output .= '<h3>' . t('Uses') . '</h3>';
93 $output .= '<dl>';
94 $output .= '<dt>' . t('Checking for available updates') . '</dt>';
95 $output .= '<dd>' . t('A report of <a href="@update-report">available updates</a> will alert you when new releases are available for download. You may configure options for the frequency for checking updates (which are performed during <a href="@cron">cron</a> runs) and e-mail notifications at the <a href="@update-settings">Update manager settings</a> page.', array('@update-report' => url('admin/reports/updates'), '@cron' => 'http://drupal.org/cron', '@update-settings' => url('admin/reports/updates/settings'))) . '</dd>';
96 // Only explain the Update manager if it has not been disabled.
97 if (update_manager_access()) {
98 $output .= '<dt>' . t('Performing updates through the user interface') . '</dt>';
99 $output .= '<dd>' . t('The Update manager module allows administrators to perform updates directly through the administration interface. At the top of the <a href="@modules_page">modules</a> and <a href="@themes_page">themes</a> pages you will see a link to update to new releases. This will direct you to the <a href="@update-page">update page</a> where you see a listing of all the missing updates and confirm which ones you want to upgrade. From there, you are prompted for your FTP/SSH password, which then transfers the files into your Drupal installation, overwriting your old files. More detailed instructions can be found in the <a href="@update">online handbook</a>.', array('@modules_page' => url('admin/modules'), '@themes_page' => url('admin/appearance'), '@update-page' => url('admin/reports/updates/update'), '@update' => 'http://drupal.org/documentation/modules/update')) . '</dd>';
100 $output .= '<dt>' . t('Installing new modules and themes through the user interface') . '</dt>';
101 $output .= '<dd>' . t('You can also install new modules and themes in the same fashion, through the <a href="@install">install page</a>, or by clicking the <em>Install new module/theme</em> link at the top of the <a href="@modules_page">modules</a> and <a href="@themes_page">themes</a> pages. In this case, you are prompted to provide either the URL to the download, or to upload a packaged release file from your local computer.', array('@modules_page' => url('admin/modules'), '@themes_page' => url('admin/appearance'), '@install' => url('admin/reports/updates/install'))) . '</dd>';
102 }
103 $output .= '</dl>';
104 return $output;
105 }
106 }
107
111 function update_init() {
112 if (arg(0) == 'admin' && user_access('administer site configuration')) {
113 switch ($_GET['q']) {
114 // These pages don't need additional nagging.
115 case 'admin/appearance/update':
116 case 'admin/appearance/install':
117 case 'admin/modules/update':
118 case 'admin/modules/install':
119 case 'admin/reports/updates':
120 case 'admin/reports/updates/update':
121 case 'admin/reports/updates/install':
122 case 'admin/reports/updates/settings':
123 case 'admin/reports/status':
124 case 'admin/update/ready':
125 return;
126
127 // If we are on the appearance or modules list, display a detailed report
128 // of the update status.
129 case 'admin/appearance':
130 case 'admin/modules':
131 $verbose = TRUE;
132 break;
133
134 }
135 module_load_install('update');
136 $status = update_requirements('runtime');
137 foreach (array('core', 'contrib') as $report_type) {
138 $type = 'update_' . $report_type;
139 if (!empty($verbose)) {
140 if (isset($status[$type]['severity'])) {
141 if ($status[$type]['severity'] == REQUIREMENT_ERROR) {
142 drupal_set_message($status[$type]['description'], 'error', FALSE);
143 }
144 elseif ($status[$type]['severity'] == REQUIREMENT_WARNING) {
145 drupal_set_message($status[$type]['description'], 'warning', FALSE);
146 }
147 }
148 }
149 // Otherwise, if we're on *any* admin page and there's a security
150 // update missing, print an error message about it.
151 else {
152 if (isset($status[$type])
153 && isset($status[$type]['reason'])
154 && $status[$type]['reason'] === UPDATE_NOT_SECURE) {
155 drupal_set_message($status[$type]['description'], 'error', FALSE);
156 }
157 }
158 }
159 }
160 }
161
165 function update_menu() {
166 $items = array();
167
168 $items['admin/reports/updates'] = array(
169 'title' => 'Available updates',
170 'description' => 'Get a status report about available updates for your installed modules and themes.',
171 'page callback' => 'update_status',
172 'access arguments' => array('administer site configuration'),
173 'weight' => -50,
174 'file' => 'update.report.inc',
175 );
176 $items['admin/reports/updates/list'] = array(
177 'title' => 'List',
178 'access arguments' => array('administer site configuration'),
179 'type' => MENU_DEFAULT_LOCAL_TASK,
180 );
181 $items['admin/reports/updates/settings'] = array(
182 'title' => 'Settings',
183 'page callback' => 'drupal_get_form',
184 'page arguments' => array('update_settings'),
185 'access arguments' => array('administer site configuration'),
186 'file' => 'update.settings.inc',
187 'type' => MENU_LOCAL_TASK,
188 'weight' => 50,
189 );
190 $items['admin/reports/updates/check'] = array(
191 'title' => 'Manual update check',
192 'page callback' => 'update_manual_status',
193 'access arguments' => array('administer site configuration'),
194 'type' => MENU_CALLBACK,
195 'file' => 'update.fetch.inc',
196 );
197
198 // We want action links for updating projects at a few different locations:
199 // both the module and theme administration pages, and on the available
200 // updates report itself. The menu items will be mostly identical, except the
201 // paths and titles, so we just define them in a loop. We pass in a string
202 // indicating what context we're entering the action from, so that can
203 // customize the appearance as needed.
204 $paths = array(
205 'report' => 'admin/reports/updates',
206 'module' => 'admin/modules',
207 'theme' => 'admin/appearance',
208 );
209 foreach ($paths as $context => $path) {
210 $items[$path . '/install'] = array(
211 'page callback' => 'drupal_get_form',
212 'page arguments' => array('update_manager_install_form', $context),
213 'access callback' => 'update_manager_access',
214 'access arguments' => array(),
215 'weight' => 25,
216 'type' => MENU_LOCAL_ACTION,
217 'file' => 'update.manager.inc',
218 );
219 $items[$path . '/update'] = array(
220 'page callback' => 'drupal_get_form',
221 'page arguments' => array('update_manager_update_form', $context),
222 'access callback' => 'update_manager_access',
223 'access arguments' => array(),
224 'weight' => 10,
225 'title' => 'Update',
226 'type' => MENU_LOCAL_TASK,
227 'file' => 'update.manager.inc',
228 );
229 }
230 // Customize the titles of the action links depending on where they appear.
231 // We use += array() to let the translation extractor find these menu titles.
232 $items['admin/reports/updates/install'] += array('title' => 'Install new module or theme');
233 $items['admin/modules/install'] += array('title' => 'Install new module');
234 $items['admin/appearance/install'] += array('title' => 'Install new theme');
235
236 // Menu callback used for the confirmation page after all the releases
237 // have been downloaded, asking you to backup before installing updates.
238 $items['admin/update/ready'] = array(
239 'title' => 'Ready to update',
240 'page callback' => 'drupal_get_form',
241 'page arguments' => array('update_manager_update_ready_form'),
242 'access callback' => 'update_manager_access',
243 'access arguments' => array(),
244 'type' => MENU_CALLBACK,
245 'file' => 'update.manager.inc',
246 );
247
248 return $items;
249 }
250
263 function update_manager_access() {
264 return variable_get('allow_authorize_operations', TRUE) && user_access('administer software updates');
265 }
266
270 function update_theme() {
271 return array(
272 'update_manager_update_form' => array(
273 'render element' => 'form',
274 'file' => 'update.manager.inc',
275 ),
276 'update_last_check' => array(
277 'variables' => array('last' => NULL),
278 ),
279 'update_report' => array(
280 'variables' => array('data' => NULL),
281 ),
282 'update_version' => array(
283 'variables' => array('version' => NULL, 'tag' => NULL, 'class' => array()),
284 ),
285 'update_status_label' => array(
286 'variables' => array('status' => NULL),
287 ),
288 );
289 }
290
294 function update_cron() {
295 $frequency = variable_get('update_check_frequency', 1);
296 $interval = 60 * 60 * 24 * $frequency;
297 if ((REQUEST_TIME - variable_get('update_last_check', 0)) > $interval) {
298 // If the configured update interval has elapsed, we want to invalidate
299 // the cached data for all projects, attempt to re-fetch, and trigger any
300 // configured notifications about the new status.
301 update_refresh();
302 update_fetch_data();
303 }
304 else {
305 // Otherwise, see if any individual projects are now stale or still
306 // missing data, and if so, try to fetch the data.
307 update_get_available(TRUE);
308 }
309 if ((REQUEST_TIME - variable_get('update_last_email_notification', 0)) > $interval) {
310 // If configured time between notifications elapsed, send email about
311 // updates possibly available.
312 module_load_include('inc', 'update', 'update.fetch');
313 _update_cron_notify();
314 }
315
316 // Clear garbage from disk.
317 update_clear_update_disk_cache();
318 }
319
325 function update_themes_enabled($themes) {
326 // Clear all update module caches.
327 _update_cache_clear();
328 }
329
335 function update_themes_disabled($themes) {
336 // Clear all update module caches.
337 _update_cache_clear();
338 }
339
348 function update_form_system_modules_alter(&$form, $form_state) {
349 $form['#submit'][] = 'update_cache_clear_submit';
350 }
351
357 function update_cache_clear_submit($form, &$form_state) {
358 // Clear all update module caches.
359 _update_cache_clear();
360 }
361
365 function _update_no_data() {
366 $destination = drupal_get_destination();
367 return t('No update information available. <a href="@run_cron">Run cron</a> or <a href="@check_manually">check manually</a>.', array(
368 '@run_cron' => url('admin/reports/status/run-cron', array('query' => $destination)),
369 '@check_manually' => url('admin/reports/updates/check', array('query' => $destination)),
370 ));
371 }
372
394 function update_get_available($refresh = FALSE) {
395 module_load_include('inc', 'update', 'update.compare');
396 $needs_refresh = FALSE;
397
398 // Grab whatever data we currently have cached in the DB.
399 $available = _update_get_cached_available_releases();
400 $num_avail = count($available);
401
402 $projects = update_get_projects();
403 foreach ($projects as $key => $project) {
404 // If there's no data at all, we clearly need to fetch some.
405 if (empty($available[$key])) {
406 update_create_fetch_task($project);
407 $needs_refresh = TRUE;
408 continue;
409 }
410
411 // See if the .info file is newer than the last time we checked for data,
412 // and if so, mark this project's data as needing to be re-fetched. Any
413 // time an admin upgrades their local installation, the .info file will
414 // be changed, so this is the only way we can be sure we're not showing
415 // bogus information right after they upgrade.
416 if ($project['info']['_info_file_ctime'] > $available[$key]['last_fetch']) {
417 $available[$key]['fetch_status'] = UPDATE_FETCH_PENDING;
418 }
419
420 // If we have project data but no release data, we need to fetch. This
421 // can be triggered when we fail to contact a release history server.
422 if (empty($available[$key]['releases'])) {
423 $available[$key]['fetch_status'] = UPDATE_FETCH_PENDING;
424 }
425
426 // If we think this project needs to fetch, actually create the task now
427 // and remember that we think we're missing some data.
428 if (!empty($available[$key]['fetch_status']) && $available[$key]['fetch_status'] == UPDATE_FETCH_PENDING) {
429 update_create_fetch_task($project);
430 $needs_refresh = TRUE;
431 }
432 }
433
434 if ($needs_refresh && $refresh) {
435 // Attempt to drain the queue of fetch tasks.
436 update_fetch_data();
437 // After processing the queue, we've (hopefully) got better data, so pull
438 // the latest from the cache again and use that directly.
439 $available = _update_get_cached_available_releases();
440 }
441
442 return $available;
443 }
444
454 function update_create_fetch_task($project) {
455 module_load_include('inc', 'update', 'update.fetch');
456 return _update_create_fetch_task($project);
457 }
458
464 function update_refresh() {
465 module_load_include('inc', 'update', 'update.fetch');
466 return _update_refresh();
467 }
468
474 function update_fetch_data() {
475 module_load_include('inc', 'update', 'update.fetch');
476 return _update_fetch_data();
477 }
478
485 function _update_get_cached_available_releases() {
486 $data = array();
487 $cache_items = _update_get_cache_multiple('available_releases');
488 foreach ($cache_items as $cid => $cache) {
489 $cache->data['last_fetch'] = $cache->created;
490 if ($cache->expire < REQUEST_TIME) {
491 $cache->data['fetch_status'] = UPDATE_FETCH_PENDING;
492 }
493 // The project shortname is embedded in the cache ID, even if there's no
494 // data for this project in the DB at all, so use that for the indexes in
495 // the array.
496 $parts = explode('::', $cid, 2);
497 $data[$parts[1]] = $cache->data;
498 }
499 return $data;
500 }
501
521 function update_mail($key, &$message, $params) {
522 $language = $message['language'];
523 $langcode = $language->language;
524 $message['subject'] .= t('New release(s) available for !site_name', array('!site_name' => variable_get('site_name', 'Drupal')), array('langcode' => $langcode));
525 foreach ($params as $msg_type => $msg_reason) {
526 $message['body'][] = _update_message_text($msg_type, $msg_reason, FALSE, $language);
527 }
528 $message['body'][] = t('See the available updates page for more information:', array(), array('langcode' => $langcode)) . "\n" . url('admin/reports/updates', array('absolute' => TRUE, 'language' => $language));
529 if (update_manager_access()) {
530 $message['body'][] = t('You can automatically install your missing updates using the Update manager:', array(), array('langcode' => $langcode)) . "\n" . url('admin/reports/updates/update', array('absolute' => TRUE, 'language' => $language));
531 }
532 $settings_url = url('admin/reports/updates/settings', array('absolute' => TRUE));
533 if (variable_get('update_notification_threshold', 'all') == 'all') {
534 $message['body'][] = t('Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, !url.', array('!url' => $settings_url));
535 }
536 else {
537 $message['body'][] = t('Your site is currently configured to send these emails only when security updates are available. To get notified for any available updates, !url.', array('!url' => $settings_url));
538 }
539 }
540
562 function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $language = NULL) {
563 $langcode = isset($language) ? $language->language : NULL;
564 $text = '';
565 switch ($msg_reason) {
566 case UPDATE_NOT_SECURE:
567 if ($msg_type == 'core') {
568 $text = t('There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!', array(), array('langcode' => $langcode));
569 }
570 else {
571 $text = t('There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!', array(), array('langcode' => $langcode));
572 }
573 break;
574
575 case UPDATE_REVOKED:
576 if ($msg_type == 'core') {
577 $text = t('Your version of Drupal has been revoked and is no longer available for download. Upgrading is strongly recommended!', array(), array('langcode' => $langcode));
578 }
579 else {
580 $text = t('The installed version of at least one of your modules or themes has been revoked and is no longer available for download. Upgrading or disabling is strongly recommended!', array(), array('langcode' => $langcode));
581 }
582 break;
583
584 case UPDATE_NOT_SUPPORTED:
585 if ($msg_type == 'core') {
586 $text = t('Your version of Drupal is no longer supported. Upgrading is strongly recommended!', array(), array('langcode' => $langcode));
587 }
588 else {
589 $text = t('The installed version of at least one of your modules or themes is no longer supported. Upgrading or disabling is strongly recommended. See the project homepage for more details.', array(), array('langcode' => $langcode));
590 }
591 break;
592
593 case UPDATE_NOT_CURRENT:
594 if ($msg_type == 'core') {
595 $text = t('There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.', array(), array('langcode' => $langcode));
596 }
597 else {
598 $text = t('There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.', array(), array('langcode' => $langcode));
599 }
600 break;
601
602 case UPDATE_UNKNOWN:
603 case UPDATE_NOT_CHECKED:
604 case UPDATE_NOT_FETCHED:
605 case UPDATE_FETCH_PENDING:
606 if ($msg_type == 'core') {
607 $text = t('There was a problem checking <a href="@update-report">available updates</a> for Drupal.', array('@update-report' => url('admin/reports/updates')), array('langcode' => $langcode));
608 }
609 else {
610 $text = t('There was a problem checking <a href="@update-report">available updates</a> for your modules or themes.', array('@update-report' => url('admin/reports/updates')), array('langcode' => $langcode));
611 }
612 break;
613 }
614
615 if ($report_link) {
616 if (update_manager_access()) {
617 $text .= ' ' . t('See the <a href="@available_updates">available updates</a> page for more information and to install your missing updates.', array('@available_updates' => url('admin/reports/updates/update', array('language' => $language))), array('langcode' => $langcode));
618 }
619 else {
620 $text .= ' ' . t('See the <a href="@available_updates">available updates</a> page for more information.', array('@available_updates' => url('admin/reports/updates', array('language' => $language))), array('langcode' => $langcode));
621 }
622 }
623
624 return $text;
625 }
626
632 function _update_project_status_sort($a, $b) {
633 // The status constants are numerically in the right order, so we can
634 // usually subtract the two to compare in the order we want. However,
635 // negative status values should be treated as if they are huge, since we
636 // always want them at the bottom of the list.
637 $a_status = $a['status'] > 0 ? $a['status'] : (-10 * $a['status']);
638 $b_status = $b['status'] > 0 ? $b['status'] : (-10 * $b['status']);
639 return $a_status - $b_status;
640 }
641
657 function theme_update_last_check($variables) {
658 $last = $variables['last'];
659 $output = '<div class="update checked">';
660 $output .= $last ? t('Last checked: @time ago', array('@time' => format_interval(REQUEST_TIME - $last))) : t('Last checked: never');
661 $output .= ' <span class="check-manually">(' . l(t('Check manually'), 'admin/reports/updates/check', array('query' => drupal_get_destination())) . ')</span>';
662 $output .= "</div>\n";
663 return $output;
664 }
665
679 function update_verify_update_archive($project, $archive_file, $directory) {
680 $errors = array();
681
682 // Make sure this isn't a tarball of Drupal core.
683 if (
684 file_exists("$directory/$project/index.php")
685 && file_exists("$directory/$project/update.php")
686 && file_exists("$directory/$project/includes/bootstrap.inc")
687 && file_exists("$directory/$project/modules/node/node.module")
688 && file_exists("$directory/$project/modules/system/system.module")
689 ) {
690 return array(
691 'no-core' => t('Automatic updating of Drupal core is not supported. See the <a href="@upgrade-guide">upgrade guide</a> for information on how to update Drupal core manually.', array('@upgrade-guide' => 'http://drupal.org/upgrade')),
692 );
693 }
694
695 // Parse all the .info files and make sure at least one is compatible with
696 // this version of Drupal core. If one is compatible, then the project as a
697 // whole is considered compatible (since, for example, the project may ship
698 // with some out-of-date modules that are not necessary for its overall
699 // functionality).
700 $compatible_project = FALSE;
701 $incompatible = array();
702 $files = file_scan_directory("$directory/$project", '/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info$/', array('key' => 'name', 'min_depth' => 0));
703 foreach ($files as $key => $file) {
704 // Get the .info file for the module or theme this file belongs to.
705 $info = drupal_parse_info_file($file->uri);
706
707 // If the module or theme is incompatible with Drupal core, set an error.
708 if (empty($info['core']) || $info['core'] != DRUPAL_CORE_COMPATIBILITY) {
709 $incompatible[] = !empty($info['name']) ? $info['name'] : t('Unknown');
710 }
711 else {
712 $compatible_project = TRUE;
713 break;
714 }
715 }
716
717 if (empty($files)) {
718 $errors[] = t('%archive_file does not contain any .info files.', array('%archive_file' => drupal_basename($archive_file)));
719 }
720 elseif (!$compatible_project) {
721 $errors[] = format_plural(
722 count($incompatible),
723 '%archive_file contains a version of %names that is not compatible with Drupal !version.',
724 '%archive_file contains versions of modules or themes that are not compatible with Drupal !version: %names',
725 array('!version' => DRUPAL_CORE_COMPATIBILITY, '%archive_file' => drupal_basename($archive_file), '%names' => implode(', ', $incompatible))
726 );
727 }
728
729 return $errors;
730 }
731
769 function _update_cache_set($cid, $data, $expire) {
770 $fields = array(
771 'created' => REQUEST_TIME,
772 'expire' => $expire,
773 );
774 if (!is_string($data)) {
775 $fields['data'] = serialize($data);
776 $fields['serialized'] = 1;
777 }
778 else {
779 $fields['data'] = $data;
780 $fields['serialized'] = 0;
781 }
782 db_merge('cache_update')
783 ->key(array('cid' => $cid))
784 ->fields($fields)
785 ->execute();
786 }
787
799 function _update_cache_get($cid) {
800 $cache = db_query("SELECT data, created, expire, serialized FROM {cache_update} WHERE cid = :cid", array(':cid' => $cid))->fetchObject();
801 if (isset($cache->data)) {
802 if ($cache->serialized) {
803 $cache->data = unserialize($cache->data);
804 }
805 }
806 return $cache;
807 }
808
818 function _update_get_cache_multiple($cid_prefix) {
819 $data = array();
820 $result = db_select('cache_update')
821 ->fields('cache_update', array('cid', 'data', 'created', 'expire', 'serialized'))
822 ->condition('cache_update.cid', $cid_prefix . '::%', 'LIKE')
823 ->execute();
824 foreach ($result as $cache) {
825 if ($cache) {
826 if ($cache->serialized) {
827 $cache->data = unserialize($cache->data);
828 }
829 $data[$cache->cid] = $cache;
830 }
831 }
832 return $data;
833 }
834
846 function _update_cache_clear($cid = NULL, $wildcard = FALSE) {
847 if (empty($cid)) {
848 db_delete('cache_update')
849 // Clear everything except fetch task information because these are used
850 // to ensure that the fetch task queue items are not added multiple times.
851 ->condition('cid', 'fetch_task::%', 'NOT LIKE')
852 ->execute();
853 }
854 else {
855 $query = db_delete('cache_update');
856 if ($wildcard) {
857 $query->condition('cid', $cid . '%', 'LIKE');
858 }
859 else {
860 $query->condition('cid', $cid);
861 }
862 $query->execute();
863 }
864 }
865
882 function update_flush_caches() {
883 if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update') {
884 _update_cache_clear();
885 }
886 return array();
887 }
888
899 function _update_manager_unique_identifier() {
900 $id = &drupal_static(__FUNCTION__, '');
901 if (empty($id)) {
902 $id = substr(hash('sha256', drupal_get_hash_salt()), 0, 8);
903 }
904 return $id;
905 }
906
918 function _update_manager_extract_directory($create = TRUE) {
919 $directory = &drupal_static(__FUNCTION__, '');
920 if (empty($directory)) {
921 $directory = 'temporary://update-extraction-' . _update_manager_unique_identifier();
922 if ($create && !file_exists($directory)) {
923 mkdir($directory);
924 }
925 }
926 return $directory;
927 }
928
940 function _update_manager_cache_directory($create = TRUE) {
941 $directory = &drupal_static(__FUNCTION__, '');
942 if (empty($directory)) {
943 $directory = 'temporary://update-cache-' . _update_manager_unique_identifier();
944 if ($create && !file_exists($directory)) {
945 mkdir($directory);
946 }
947 }
948 return $directory;
949 }
950
954 function update_clear_update_disk_cache() {
955 // List of update module cache directories. Do not create the directories if
956 // they do not exist.
957 $directories = array(
958 _update_manager_cache_directory(FALSE),
959 _update_manager_extract_directory(FALSE),
960 );
961
962 // Search for files and directories in base folder only without recursion.
963 foreach ($directories as $directory) {
964 file_scan_directory($directory, '/.*/', array('callback' => 'update_delete_file_if_stale', 'recurse' => FALSE));
965 }
966 }
967
986 function update_delete_file_if_stale($path) {
987 if (file_exists($path)) {
988 $filectime = filectime($path);
989 if (REQUEST_TIME - $filectime > DRUPAL_MAXIMUM_TEMP_FILE_AGE || (preg_match('/.*-dev\.(tar\.gz|zip)/i', $path) && REQUEST_TIME - $filectime > 300)) {
990 file_unmanaged_delete_recursive($path);
991 }
992 }
993 }
update_themes_enabled
update_themes_enabled($themes)
Definition: update.module:325
update_mail
update_mail($key, &$message, $params)
Definition: update.module:521
_update_cache_get
_update_cache_get($cid)
Definition: update.module:799
UPDATE_NOT_CURRENT
const UPDATE_NOT_CURRENT
Definition: update.module:39
update_init
update_init()
Definition: update.module:111
_update_fetch_data
_update_fetch_data()
Definition: update.fetch.inc:108
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
l
l($text, $path, array $options=array())
Definition: common.inc:2432
update_theme
update_theme()
Definition: update.module:270
file_scan_directory
file_scan_directory($dir, $mask, $options=array(), $depth=0)
Definition: file.inc:2058
drupal_parse_info_file
drupal_parse_info_file($filename)
Definition: common.inc:7270
_update_cache_clear
_update_cache_clear($cid=NULL, $wildcard=FALSE)
Definition: update.module:846
file_unmanaged_delete_recursive
file_unmanaged_delete_recursive($path)
Definition: file.inc:1358
update_themes_disabled
update_themes_disabled($themes)
Definition: update.module:335
update_requirements
update_requirements($phase)
Definition: update.install:28
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
_update_create_fetch_task
_update_create_fetch_task($project)
Definition: update.fetch.inc:239
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
UPDATE_UNKNOWN
const UPDATE_UNKNOWN
Definition: update.module:54
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
update_help
update_help($path, $arg)
Definition: update.module:79
_update_no_data
_update_no_data()
Definition: update.module:365
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
update_verify_update_archive
update_verify_update_archive($project, $archive_file, $directory)
Definition: update.module:679
UPDATE_REVOKED
const UPDATE_REVOKED
Definition: update.module:29
REQUIREMENT_WARNING
const REQUIREMENT_WARNING
Definition: install.inc:31
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
module_load_install
module_load_install($module)
Definition: module.inc:288
update_flush_caches
update_flush_caches()
Definition: update.module:882
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
update_cron
update_cron()
Definition: update.module:294
_update_manager_extract_directory
_update_manager_extract_directory($create=TRUE)
Definition: update.module:918
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$info
$info
Definition: color.inc:6
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
update_cache_clear_submit
update_cache_clear_submit($form, &$form_state)
Definition: update.module:357
_update_manager_cache_directory
_update_manager_cache_directory($create=TRUE)
Definition: update.module:940
_update_cache_set
_update_cache_set($cid, $data, $expire)
Definition: update.module:769
UPDATE_NOT_CHECKED
const UPDATE_NOT_CHECKED
Definition: update.module:49
_update_project_status_sort
_update_project_status_sort($a, $b)
Definition: update.module:632
theme_update_last_check
theme_update_last_check($variables)
Definition: update.module:657
update_menu
update_menu()
Definition: update.module:165
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
_update_get_cached_available_releases
_update_get_cached_available_releases()
Definition: update.module:485
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
update_manager_access
update_manager_access()
Definition: update.module:263
$output
$output
Definition: authorize.php:93
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
user_access
user_access($string, $account=NULL)
Definition: user.module:794
update_create_fetch_task
update_create_fetch_task($project)
Definition: update.module:454
_update_get_cache_multiple
_update_get_cache_multiple($cid_prefix)
Definition: update.module:818
_update_cron_notify
_update_cron_notify()
Definition: update.fetch.inc:340
_update_refresh
_update_refresh()
Definition: update.fetch.inc:197
DRUPAL_MAXIMUM_TEMP_FILE_AGE
const DRUPAL_MAXIMUM_TEMP_FILE_AGE
Definition: system.module:11
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
update_get_projects
update_get_projects()
Definition: update.compare.inc:56
UPDATE_NOT_FETCHED
const UPDATE_NOT_FETCHED
Definition: update.module:59
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
_update_manager_unique_identifier
_update_manager_unique_identifier()
Definition: update.module:899
DRUPAL_CORE_COMPATIBILITY
const DRUPAL_CORE_COMPATIBILITY
Definition: bootstrap.inc:16
DRUPAL_PHP_FUNCTION_PATTERN
const DRUPAL_PHP_FUNCTION_PATTERN
Definition: bootstrap.inc:249
UPDATE_NOT_SUPPORTED
const UPDATE_NOT_SUPPORTED
Definition: update.module:34
MAINTENANCE_MODE
const MAINTENANCE_MODE
Definition: authorize.php:36
drupal_basename
drupal_basename($uri, $suffix=NULL)
Definition: file.inc:2317
update_form_system_modules_alter
update_form_system_modules_alter(&$form, $form_state)
Definition: update.module:348
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
update_get_available
update_get_available($refresh=FALSE)
Definition: update.module:394
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
_update_message_text
_update_message_text($msg_type, $msg_reason, $report_link=FALSE, $language=NULL)
Definition: update.module:562
update_clear_update_disk_cache
update_clear_update_disk_cache()
Definition: update.module:954
UPDATE_NOT_SECURE
const UPDATE_NOT_SECURE
Definition: update.module:24
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
update_delete_file_if_stale
update_delete_file_if_stale($path)
Definition: update.module:986
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
update_refresh
update_refresh()
Definition: update.module:464
drupal_get_hash_salt
drupal_get_hash_salt()
Definition: bootstrap.inc:2289
UPDATE_FETCH_PENDING
const UPDATE_FETCH_PENDING
Definition: update.module:64
update_fetch_data
update_fetch_data()
Definition: update.module:474
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/js_example/accordion.tpl.php Source File

  • examples
  • js_example
accordion.tpl.php
Go to the documentation of this file.
1 <?php
2
7 ?>
8 <div class="demo">
9 <h2><?php print $title; ?></h2>
10 <div id="accordion">
11 <h3><a href="#">Section 1</a></h3>
12 <div>
13 <p>
14 Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
15 ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
16 amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
17 odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
18 </p>
19 </div>
20 <h3><a href="#">Section 2</a></h3>
21 <div>
22 <p>
23 Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
24 purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
25 velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
26 suscipit faucibus urna.
27 </p>
28 </div>
29 <h3><a href="#">Section 3</a></h3>
30 <div>
31 <p>
32 Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
33 Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
34 ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
35 lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
36 </p>
37 <ul>
38 <li>List item one</li>
39 <li>List item two</li>
40 <li>List item three</li>
41 </ul>
42 </div>
43 <h3><a href="#">Section 4</a></h3>
44 <div>
45 <p>
46 Cras dictum. Pellentesque habitant morbi tristique senectus et netus
47 et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
48 faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
49 mauris vel est.
50 </p>
51 <p>
52 Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
53 Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
54 inceptos himenaeos.
55 </p>
56 </div>
57 </div>
58
59 </div><!-- End demo -->
print
print
Definition: php-2.php:2
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/ajax.inc Source File

  • includes
ajax.inc
Go to the documentation of this file.
1 <?php
2
232 function ajax_render($commands = array()) {
233 // Ajax responses aren't rendered with html.tpl.php, so we have to call
234 // drupal_get_css() and drupal_get_js() here, in order to have new files added
235 // during this request to be loaded by the page. We only want to send back
236 // files that the page hasn't already loaded, so we implement simple diffing
237 // logic using array_diff_key().
238 foreach (array('css', 'js') as $type) {
239 // It is highly suspicious if $_POST['ajax_page_state'][$type] is empty,
240 // since the base page ought to have at least one JS file and one CSS file
241 // loaded. It probably indicates an error, and rather than making the page
242 // reload all of the files, instead we return no new files.
243 if (empty($_POST['ajax_page_state'][$type])) {
244 $items[$type] = array();
245 }
246 else {
247 $function = 'drupal_add_' . $type;
248 $items[$type] = $function();
249 drupal_alter($type, $items[$type]);
250 // @todo Inline CSS and JS items are indexed numerically. These can't be
251 // reliably diffed with array_diff_key(), since the number can change
252 // due to factors unrelated to the inline content, so for now, we strip
253 // the inline items from Ajax responses, and can add support for them
254 // when drupal_add_css() and drupal_add_js() are changed to use a hash
255 // of the inline content as the array key.
256 foreach ($items[$type] as $key => $item) {
257 if (is_numeric($key)) {
258 unset($items[$type][$key]);
259 }
260 }
261 // Ensure that the page doesn't reload what it already has.
262 $items[$type] = array_diff_key($items[$type], $_POST['ajax_page_state'][$type]);
263 }
264 }
265
266 // Render the HTML to load these files, and add AJAX commands to insert this
267 // HTML in the page. We pass TRUE as the $skip_alter argument to prevent the
268 // data from being altered again, as we already altered it above. Settings are
269 // handled separately, afterwards.
270 if (isset($items['js']['settings'])) {
271 unset($items['js']['settings']);
272 }
273 $styles = drupal_get_css($items['css'], TRUE);
274 $scripts_footer = drupal_get_js('footer', $items['js'], TRUE);
275 $scripts_header = drupal_get_js('header', $items['js'], TRUE);
276
277 $extra_commands = array();
278 if (!empty($styles)) {
279 $extra_commands[] = ajax_command_prepend('head', $styles);
280 }
281 if (!empty($scripts_header)) {
282 $extra_commands[] = ajax_command_prepend('head', $scripts_header);
283 }
284 if (!empty($scripts_footer)) {
285 $extra_commands[] = ajax_command_append('body', $scripts_footer);
286 }
287 if (!empty($extra_commands)) {
288 $commands = array_merge($extra_commands, $commands);
289 }
290
291 // Now add a command to merge changes and additions to Drupal.settings.
292 $scripts = drupal_add_js();
293 if (!empty($scripts['settings'])) {
294 $settings = $scripts['settings'];
295 array_unshift($commands, ajax_command_settings(call_user_func_array('array_merge_recursive', $settings['data']), TRUE));
296 }
297
298 // Allow modules to alter any Ajax response.
299 drupal_alter('ajax_render', $commands);
300
301 return drupal_json_encode($commands);
302 }
303
317 function ajax_get_form() {
318 $form_state = form_state_defaults();
319
320 $form_build_id = $_POST['form_build_id'];
321
322 // Get the form from the cache.
323 $form = form_get_cache($form_build_id, $form_state);
324 if (!$form) {
325 // If $form cannot be loaded from the cache, the form_build_id in $_POST
326 // must be invalid, which means that someone performed a POST request onto
327 // system/ajax without actually viewing the concerned form in the browser.
328 // This is likely a hacking attempt as it never happens under normal
329 // circumstances, so we just do nothing.
330 watchdog('ajax', 'Invalid form POST data.', array(), WATCHDOG_WARNING);
331 drupal_exit();
332 }
333
334 // Since some of the submit handlers are run, redirects need to be disabled.
335 $form_state['no_redirect'] = TRUE;
336
337 // When a form is rebuilt after Ajax processing, its #build_id and #action
338 // should not change.
339 // @see drupal_rebuild_form()
340 $form_state['rebuild_info']['copy']['#build_id'] = TRUE;
341 $form_state['rebuild_info']['copy']['#action'] = TRUE;
342
343 // The form needs to be processed; prepare for that by setting a few internal
344 // variables.
345 $form_state['input'] = $_POST;
346 $form_id = $form['#form_id'];
347
348 return array($form, $form_state, $form_id, $form_build_id);
349 }
350
368 function ajax_form_callback() {
369 list($form, $form_state) = ajax_get_form();
370 drupal_process_form($form['#form_id'], $form, $form_state);
371
372 // We need to return the part of the form (or some other content) that needs
373 // to be re-rendered so the browser can update the page with changed content.
374 // Since this is the generic menu callback used by many Ajax elements, it is
375 // up to the #ajax['callback'] function of the element (may or may not be a
376 // button) that triggered the Ajax request to determine what needs to be
377 // rendered.
378 if (!empty($form_state['triggering_element'])) {
379 $callback = $form_state['triggering_element']['#ajax']['callback'];
380 }
381 if (!empty($callback) && function_exists($callback)) {
382 return $callback($form, $form_state);
383 }
384 }
385
406 function ajax_base_page_theme() {
407 if (!empty($_POST['ajax_page_state']['theme']) && !empty($_POST['ajax_page_state']['theme_token'])) {
408 $theme = $_POST['ajax_page_state']['theme'];
409 $token = $_POST['ajax_page_state']['theme_token'];
410
411 // Prevent a request forgery from giving a person access to a theme they
412 // shouldn't be otherwise allowed to see. However, since everyone is allowed
413 // to see the default theme, token validation isn't required for that, and
414 // bypassing it allows most use-cases to work even when accessed from the
415 // page cache.
416 if ($theme === variable_get('theme_default', 'bartik') || drupal_valid_token($token, $theme)) {
417 return $theme;
418 }
419 }
420 }
421
440 function ajax_deliver($page_callback_result) {
441 // Browsers do not allow JavaScript to read the contents of a user's local
442 // files. To work around that, the jQuery Form plugin submits forms containing
443 // a file input element to an IFRAME, instead of using XHR. Browsers do not
444 // normally expect JSON strings as content within an IFRAME, so the response
445 // must be customized accordingly.
446 // @see http://malsup.com/jquery/form/#file-upload
447 // @see Drupal.ajax.prototype.beforeSend()
448 $iframe_upload = !empty($_POST['ajax_iframe_upload']);
449
450 // Emit a Content-Type HTTP header if none has been added by the page callback
451 // or by a wrapping delivery callback.
452 if (is_null(drupal_get_http_header('Content-Type'))) {
453 if (!$iframe_upload) {
454 // Standard JSON can be returned to a browser's XHR object, and to
455 // non-browser user agents.
456 // @see http://www.ietf.org/rfc/rfc4627.txt?number=4627
457 drupal_add_http_header('Content-Type', 'application/json; charset=utf-8');
458 }
459 else {
460 // Browser IFRAMEs expect HTML. With most other content types, Internet
461 // Explorer presents the user with a download prompt.
462 drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
463 }
464 }
465
466 // Print the response.
467 $commands = ajax_prepare_response($page_callback_result);
468 $json = ajax_render($commands);
469 if (!$iframe_upload) {
470 // Standard JSON can be returned to a browser's XHR object, and to
471 // non-browser user agents.
472 print $json;
473 }
474 else {
475 // Browser IFRAMEs expect HTML. Browser extensions, such as Linkification
476 // and Skype's Browser Highlighter, convert URLs, phone numbers, etc. into
477 // links. This corrupts the JSON response. Protect the integrity of the
478 // JSON data by making it the value of a textarea.
479 // @see http://malsup.com/jquery/form/#file-upload
480 // @see http://drupal.org/node/1009382
481 print '<textarea>' . $json . '</textarea>';
482 }
483
484 // Perform end-of-request tasks.
485 ajax_footer();
486 }
487
501 function ajax_prepare_response($page_callback_result) {
502 $commands = array();
503 if (!isset($page_callback_result)) {
504 // Simply delivering an empty commands array is sufficient. This results
505 // in the Ajax request being completed, but nothing being done to the page.
506 }
507 elseif (is_int($page_callback_result)) {
508 switch ($page_callback_result) {
509 case MENU_NOT_FOUND:
510 $commands[] = ajax_command_alert(t('The requested page could not be found.'));
511 break;
512
513 case MENU_ACCESS_DENIED:
514 $commands[] = ajax_command_alert(t('You are not authorized to access this page.'));
515 break;
516
517 case MENU_SITE_OFFLINE:
518 $commands[] = ajax_command_alert(filter_xss_admin(variable_get('maintenance_mode_message',
519 t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal'))))));
520 break;
521 }
522 }
523 elseif (is_array($page_callback_result) && isset($page_callback_result['#type']) && ($page_callback_result['#type'] == 'ajax')) {
524 // Complex Ajax callbacks can return a result that contains an error message
525 // or a specific set of commands to send to the browser.
526 $page_callback_result += element_info('ajax');
527 $error = $page_callback_result['#error'];
528 if (isset($error) && $error !== FALSE) {
529 if ((empty($error) || $error === TRUE)) {
530 $error = t('An error occurred while handling the request: The server received invalid input.');
531 }
532 $commands[] = ajax_command_alert($error);
533 }
534 else {
535 $commands = $page_callback_result['#commands'];
536 }
537 }
538 else {
539 // Like normal page callbacks, simple Ajax callbacks can return HTML
540 // content, as a string or render array. This HTML is inserted in some
541 // relationship to #ajax['wrapper'], as determined by which jQuery DOM
542 // manipulation method is used. The method used is specified by
543 // #ajax['method']. The default method is 'replaceWith', which completely
544 // replaces the old wrapper element and its content with the new HTML.
545 $html = is_string($page_callback_result) ? $page_callback_result : drupal_render($page_callback_result);
546 $commands[] = ajax_command_insert(NULL, $html);
547 // Add the status messages inside the new content's wrapper element, so that
548 // on subsequent Ajax requests, it is treated as old content.
549 $commands[] = ajax_command_prepend(NULL, theme('status_messages'));
550 }
551
552 return $commands;
553 }
554
563 function ajax_footer() {
564 // Even for Ajax requests, invoke hook_exit() implementations. There may be
565 // modules that need very fast Ajax responses, and therefore, run Ajax
566 // requests with an early bootstrap.
567 if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update')) {
568 module_invoke_all('exit');
569 }
570
571 // Commit the user session. See above comment about the possibility of this
572 // function running without session.inc loaded.
573 if (function_exists('drupal_session_commit')) {
574 drupal_session_commit();
575 }
576 }
577
589 function ajax_process_form($element, &$form_state) {
590 $element = ajax_pre_render_element($element);
591 if (!empty($element['#ajax_processed'])) {
592 $form_state['cache'] = TRUE;
593 }
594 return $element;
595 }
596
618 function ajax_pre_render_element($element) {
619 // Skip already processed elements.
620 if (isset($element['#ajax_processed'])) {
621 return $element;
622 }
623 // Initialize #ajax_processed, so we do not process this element again.
624 $element['#ajax_processed'] = FALSE;
625
626 // Nothing to do if there is neither a callback nor a path.
627 if (!(isset($element['#ajax']['callback']) || isset($element['#ajax']['path']))) {
628 return $element;
629 }
630
631 // Add a reasonable default event handler if none was specified.
632 if (isset($element['#ajax']) && !isset($element['#ajax']['event'])) {
633 switch ($element['#type']) {
634 case 'submit':
635 case 'button':
636 case 'image_button':
637 // Pressing the ENTER key within a textfield triggers the click event of
638 // the form's first submit button. Triggering Ajax in this situation
639 // leads to problems, like breaking autocomplete textfields, so we bind
640 // to mousedown instead of click.
641 // @see http://drupal.org/node/216059
642 $element['#ajax']['event'] = 'mousedown';
643 // Retain keyboard accessibility by setting 'keypress'. This causes
644 // ajax.js to trigger 'event' when SPACE or ENTER are pressed while the
645 // button has focus.
646 $element['#ajax']['keypress'] = TRUE;
647 // Binding to mousedown rather than click means that it is possible to
648 // trigger a click by pressing the mouse, holding the mouse button down
649 // until the Ajax request is complete and the button is re-enabled, and
650 // then releasing the mouse button. Set 'prevent' so that ajax.js binds
651 // an additional handler to prevent such a click from triggering a
652 // non-Ajax form submission. This also prevents a textfield's ENTER
653 // press triggering this button's non-Ajax form submission behavior.
654 if (!isset($element['#ajax']['prevent'])) {
655 $element['#ajax']['prevent'] = 'click';
656 }
657 break;
658
659 case 'password':
660 case 'textfield':
661 case 'textarea':
662 $element['#ajax']['event'] = 'blur';
663 break;
664
665 case 'radio':
666 case 'checkbox':
667 case 'select':
668 $element['#ajax']['event'] = 'change';
669 break;
670
671 case 'link':
672 $element['#ajax']['event'] = 'click';
673 break;
674
675 default:
676 return $element;
677 }
678 }
679
680 // Attach JavaScript settings to the element.
681 if (isset($element['#ajax']['event'])) {
682 $element['#attached']['library'][] = array('system', 'jquery.form');
683 $element['#attached']['library'][] = array('system', 'drupal.ajax');
684
685 $settings = $element['#ajax'];
686
687 // Assign default settings.
688 $settings += array(
689 'path' => 'system/ajax',
690 'options' => array(),
691 );
692
693 // @todo Legacy support. Remove in Drupal 8.
694 if (isset($settings['method']) && $settings['method'] == 'replace') {
695 $settings['method'] = 'replaceWith';
696 }
697
698 // Change path to URL.
699 $settings['url'] = url($settings['path'], $settings['options']);
700 unset($settings['path'], $settings['options']);
701
702 // Add special data to $settings['submit'] so that when this element
703 // triggers an Ajax submission, Drupal's form processing can determine which
704 // element triggered it.
705 // @see _form_element_triggered_scripted_submission()
706 if (isset($settings['trigger_as'])) {
707 // An element can add a 'trigger_as' key within #ajax to make the element
708 // submit as though another one (for example, a non-button can use this
709 // to submit the form as though a button were clicked). When using this,
710 // the 'name' key is always required to identify the element to trigger
711 // as. The 'value' key is optional, and only needed when multiple elements
712 // share the same name, which is commonly the case for buttons.
713 $settings['submit']['_triggering_element_name'] = $settings['trigger_as']['name'];
714 if (isset($settings['trigger_as']['value'])) {
715 $settings['submit']['_triggering_element_value'] = $settings['trigger_as']['value'];
716 }
717 unset($settings['trigger_as']);
718 }
719 elseif (isset($element['#name'])) {
720 // Most of the time, elements can submit as themselves, in which case the
721 // 'trigger_as' key isn't needed, and the element's name is used.
722 $settings['submit']['_triggering_element_name'] = $element['#name'];
723 // If the element is a (non-image) button, its name may not identify it
724 // uniquely, in which case a match on value is also needed.
725 // @see _form_button_was_clicked()
726 if (isset($element['#button_type']) && empty($element['#has_garbage_value'])) {
727 $settings['submit']['_triggering_element_value'] = $element['#value'];
728 }
729 }
730
731 // Convert a simple #ajax['progress'] string into an array.
732 if (isset($settings['progress']) && is_string($settings['progress'])) {
733 $settings['progress'] = array('type' => $settings['progress']);
734 }
735 // Change progress path to a full URL.
736 if (isset($settings['progress']['path'])) {
737 $settings['progress']['url'] = url($settings['progress']['path']);
738 unset($settings['progress']['path']);
739 }
740
741 $element['#attached']['js'][] = array(
742 'type' => 'setting',
743 'data' => array('ajax' => array($element['#id'] => $settings)),
744 );
745
746 // Indicate that Ajax processing was successful.
747 $element['#ajax_processed'] = TRUE;
748 }
749 return $element;
750 }
751
780 function ajax_command_alert($text) {
781 return array(
782 'command' => 'alert',
783 'text' => $text,
784 );
785 }
786
808 function ajax_command_insert($selector, $html, $settings = NULL) {
809 return array(
810 'command' => 'insert',
811 'method' => NULL,
812 'selector' => $selector,
813 'data' => $html,
814 'settings' => $settings,
815 );
816 }
817
842 function ajax_command_replace($selector, $html, $settings = NULL) {
843 return array(
844 'command' => 'insert',
845 'method' => 'replaceWith',
846 'selector' => $selector,
847 'data' => $html,
848 'settings' => $settings,
849 );
850 }
851
875 function ajax_command_html($selector, $html, $settings = NULL) {
876 return array(
877 'command' => 'insert',
878 'method' => 'html',
879 'selector' => $selector,
880 'data' => $html,
881 'settings' => $settings,
882 );
883 }
884
908 function ajax_command_prepend($selector, $html, $settings = NULL) {
909 return array(
910 'command' => 'insert',
911 'method' => 'prepend',
912 'selector' => $selector,
913 'data' => $html,
914 'settings' => $settings,
915 );
916 }
917
941 function ajax_command_append($selector, $html, $settings = NULL) {
942 return array(
943 'command' => 'insert',
944 'method' => 'append',
945 'selector' => $selector,
946 'data' => $html,
947 'settings' => $settings,
948 );
949 }
950
974 function ajax_command_after($selector, $html, $settings = NULL) {
975 return array(
976 'command' => 'insert',
977 'method' => 'after',
978 'selector' => $selector,
979 'data' => $html,
980 'settings' => $settings,
981 );
982 }
983
1007 function ajax_command_before($selector, $html, $settings = NULL) {
1008 return array(
1009 'command' => 'insert',
1010 'method' => 'before',
1011 'selector' => $selector,
1012 'data' => $html,
1013 'settings' => $settings,
1014 );
1015 }
1016
1036 function ajax_command_remove($selector) {
1037 return array(
1038 'command' => 'remove',
1039 'selector' => $selector,
1040 );
1041 }
1042
1062 function ajax_command_changed($selector, $asterisk = '') {
1063 return array(
1064 'command' => 'changed',
1065 'selector' => $selector,
1066 'asterisk' => $asterisk,
1067 );
1068 }
1069
1090 function ajax_command_css($selector, $argument) {
1091 return array(
1092 'command' => 'css',
1093 'selector' => $selector,
1094 'argument' => $argument,
1095 );
1096 }
1097
1121 function ajax_command_settings($argument, $merge = FALSE) {
1122 return array(
1123 'command' => 'settings',
1124 'settings' => $argument,
1125 'merge' => $merge,
1126 );
1127 }
1128
1152 function ajax_command_data($selector, $name, $value) {
1153 return array(
1154 'command' => 'data',
1155 'selector' => $selector,
1156 'name' => $name,
1157 'value' => $value,
1158 );
1159 }
1160
1183 function ajax_command_invoke($selector, $method, array $arguments = array()) {
1184 return array(
1185 'command' => 'invoke',
1186 'selector' => $selector,
1187 'method' => $method,
1188 'arguments' => $arguments,
1189 );
1190 }
1191
1207 function ajax_command_restripe($selector) {
1208 return array(
1209 'command' => 'restripe',
1210 'selector' => $selector,
1211 );
1212 }
drupal_json_encode
drupal_json_encode($var)
Definition: common.inc:5003
form_get_cache
form_get_cache($form_build_id, &$form_state)
Definition: form.inc:503
drupal_get_http_header
drupal_get_http_header($name=NULL)
Definition: bootstrap.inc:1161
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
drupal_get_bootstrap_phase
drupal_get_bootstrap_phase()
Definition: bootstrap.inc:2503
drupal_get_css
drupal_get_css($css=NULL, $skip_alter=FALSE)
Definition: common.inc:3052
ajax_process_form
ajax_process_form($element, &$form_state)
Definition: ajax.inc:589
MENU_ACCESS_DENIED
const MENU_ACCESS_DENIED
Definition: menu.inc:239
ajax_command_replace
ajax_command_replace($selector, $html, $settings=NULL)
Definition: ajax.inc:842
MENU_SITE_OFFLINE
const MENU_SITE_OFFLINE
Definition: menu.inc:244
$name
print $name
Definition: profile-listing.tpl.php:43
ajax_command_alert
ajax_command_alert($text)
Definition: ajax.inc:780
ajax_command_insert
ajax_command_insert($selector, $html, $settings=NULL)
Definition: ajax.inc:808
print
print
Definition: php-2.php:2
element_info
element_info($type)
Definition: common.inc:6306
drupal_session_commit
drupal_session_commit()
Definition: session.inc:302
ajax_footer
ajax_footer()
Definition: ajax.inc:563
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
ajax_command_invoke
ajax_command_invoke($selector, $method, array $arguments=array())
Definition: ajax.inc:1183
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
ajax_command_restripe
ajax_command_restripe($selector)
Definition: ajax.inc:1207
MENU_NOT_FOUND
const MENU_NOT_FOUND
Definition: menu.inc:234
$scripts
print $scripts
Definition: html.tpl.php:53
drupal_valid_token
drupal_valid_token($token, $value= '', $skip_anonymous=FALSE)
Definition: common.inc:5095
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
ajax_command_html
ajax_command_html($selector, $html, $settings=NULL)
Definition: ajax.inc:875
ajax_command_settings
ajax_command_settings($argument, $merge=FALSE)
Definition: ajax.inc:1121
ajax_command_append
ajax_command_append($selector, $html, $settings=NULL)
Definition: ajax.inc:941
ajax_get_form
ajax_get_form()
Definition: ajax.inc:317
ajax_command_before
ajax_command_before($selector, $html, $settings=NULL)
Definition: ajax.inc:1007
ajax_prepare_response
ajax_prepare_response($page_callback_result)
Definition: ajax.inc:501
ajax_command_css
ajax_command_css($selector, $argument)
Definition: ajax.inc:1090
drupal_add_http_header
drupal_add_http_header($name, $value, $append=FALSE)
Definition: bootstrap.inc:1129
$value
print $value
Definition: user-profile-item.tpl.php:26
ajax_base_page_theme
ajax_base_page_theme()
Definition: ajax.inc:406
drupal_process_form
drupal_process_form($form_id, &$form, &$form_state)
Definition: form.inc:829
ajax_render
ajax_render($commands=array())
Definition: ajax.inc:232
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
ajax_command_prepend
ajax_command_prepend($selector, $html, $settings=NULL)
Definition: ajax.inc:908
form_state_defaults
form_state_defaults()
Definition: form.inc:396
ajax_form_callback
ajax_form_callback()
Definition: ajax.inc:368
ajax_command_after
ajax_command_after($selector, $html, $settings=NULL)
Definition: ajax.inc:974
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
drupal_exit
drupal_exit($destination=NULL)
Definition: common.inc:2721
$styles
print $styles
Definition: html.tpl.php:52
ajax_command_data
ajax_command_data($selector, $name, $value)
Definition: ajax.inc:1152
ajax_deliver
ajax_deliver($page_callback_result)
Definition: ajax.inc:440
ajax_command_changed
ajax_command_changed($selector, $asterisk= '')
Definition: ajax.inc:1062
MAINTENANCE_MODE
const MAINTENANCE_MODE
Definition: authorize.php:36
ajax_command_remove
ajax_command_remove($selector)
Definition: ajax.inc:1036
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
drupal_get_js
drupal_get_js($scope= 'header', $javascript=NULL, $skip_alter=FALSE)
Definition: common.inc:4263
DRUPAL_BOOTSTRAP_FULL
const DRUPAL_BOOTSTRAP_FULL
Definition: bootstrap.inc:157
ajax_pre_render_element
ajax_pre_render_element($element)
Definition: ajax.inc:618
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/statistics/statistics.tokens.inc Source File

  • modules
  • statistics
statistics.tokens.inc
Go to the documentation of this file.
1 <?php
2
11 function statistics_token_info() {
12 $node['total-count'] = array(
13 'name' => t("Number of views"),
14 'description' => t("The number of visitors who have read the node."),
15 );
16 $node['day-count'] = array(
17 'name' => t("Views today"),
18 'description' => t("The number of visitors who have read the node today."),
19 );
20 $node['last-view'] = array(
21 'name' => t("Last view"),
22 'description' => t("The date on which a visitor last read the node."),
23 'type' => 'date',
24 );
25
26 return array(
27 'tokens' => array('node' => $node),
28 );
29 }
30
34 function statistics_tokens($type, $tokens, array $data = array(), array $options = array()) {
35 $url_options = array('absolute' => TRUE);
36 $replacements = array();
37
38 if ($type == 'node' & !empty($data['node'])) {
39 $node = $data['node'];
40
41 foreach ($tokens as $name => $original) {
42 if ($name == 'total-count') {
43 $statistics = statistics_get($node->nid);
44 $replacements[$original] = $statistics['totalcount'];
45 }
46 elseif ($name == 'day-count') {
47 $statistics = statistics_get($node->nid);
48 $replacements[$original] = $statistics['daycount'];
49 }
50 elseif ($name == 'last-view') {
51 $statistics = statistics_get($node->nid);
52 $replacements[$original] = format_date($statistics['timestamp']);
53 }
54 }
55
56 if ($created_tokens = token_find_with_prefix($tokens, 'last-view')) {
57 $statistics = statistics_get($node->nid);
58 $replacements += token_generate('date', $created_tokens, array('date' => $statistics['timestamp']), $options);
59 }
60 }
61
62 return $replacements;
63 }
token_generate
token_generate($type, array $tokens, array $data=array(), array $options=array())
Definition: token.inc:176
statistics_tokens
statistics_tokens($type, $tokens, array $data=array(), array $options=array())
Definition: statistics.tokens.inc:34
$name
print $name
Definition: profile-listing.tpl.php:43
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
statistics_get
statistics_get($nid)
Definition: statistics.module:317
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
statistics_token_info
statistics_token_info()
Definition: statistics.tokens.inc:11
token_find_with_prefix
token_find_with_prefix(array $tokens, $prefix, $delimiter= ':')
Definition: token.inc:219
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/tracker/tracker.install Source File

  • modules
  • tracker
tracker.install
Go to the documentation of this file.
1 <?php
2
11 function tracker_uninstall() {
12 variable_del('tracker_index_nid');
13 variable_del('tracker_batch_size');
14 }
15
19 function tracker_enable() {
20 $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField();
21 if ($max_nid != 0) {
22 variable_set('tracker_index_nid', $max_nid);
23 // To avoid timing out while attempting to do a complete indexing, we
24 // simply call our cron job to remove stale records and begin the process.
25 tracker_cron();
26 }
27 }
28
32 function tracker_schema() {
33 $schema['tracker_node'] = array(
34 'description' => 'Tracks when nodes were last changed or commented on.',
35 'fields' => array(
36 'nid' => array(
37 'description' => 'The {node}.nid this record tracks.',
38 'type' => 'int',
39 'unsigned' => TRUE,
40 'not null' => TRUE,
41 'default' => 0,
42 ),
43 'published' => array(
44 'description' => 'Boolean indicating whether the node is published.',
45 'type' => 'int',
46 'not null' => FALSE,
47 'default' => 0,
48 'size' => 'tiny',
49 ),
50 'changed' => array(
51 'description' => 'The Unix timestamp when the node was most recently saved or commented on.',
52 'type' => 'int',
53 'unsigned' => TRUE,
54 'not null' => TRUE,
55 'default' => 0,
56 ),
57 ),
58 'indexes' => array(
59 'tracker' => array('published', 'changed'),
60 ),
61 'primary key' => array('nid'),
62 'foreign keys' => array(
63 'tracked_node' => array(
64 'table' => 'node',
65 'columns' => array('nid' => 'nid'),
66 ),
67 ),
68 );
69
70 $schema['tracker_user'] = array(
71 'description' => 'Tracks when nodes were last changed or commented on, for each user that authored the node or one of its comments.',
72 'fields' => array(
73 'nid' => array(
74 'description' => 'The {node}.nid this record tracks.',
75 'type' => 'int',
76 'unsigned' => TRUE,
77 'not null' => TRUE,
78 'default' => 0,
79 ),
80 'uid' => array(
81 'description' => 'The {users}.uid of the node author or commenter.',
82 'type' => 'int',
83 'not null' => TRUE,
84 'default' => 0,
85 ),
86 'published' => array(
87 'description' => 'Boolean indicating whether the node is published.',
88 'type' => 'int',
89 'not null' => FALSE,
90 'default' => 0,
91 'size' => 'tiny',
92 ),
93 'changed' => array(
94 'description' => 'The Unix timestamp when the node was most recently saved or commented on.',
95 'type' => 'int',
96 'unsigned' => TRUE,
97 'not null' => TRUE,
98 'default' => 0,
99 ),
100 ),
101 'indexes' => array(
102 'tracker' => array('uid', 'published', 'changed'),
103 ),
104 'primary key' => array('nid', 'uid'),
105 'foreign keys' => array(
106 'tracked_node' => array(
107 'table' => 'node',
108 'columns' => array('nid' => 'nid'),
109 ),
110 'tracked_user' => array(
111 'table' => 'users',
112 'columns' => array('uid' => 'uid'),
113 ),
114 ),
115 );
116
117 return $schema;
118 }
119
128 function tracker_update_7000() {
129 $schema['tracker_node'] = array(
130 'description' => 'Tracks when nodes were last changed or commented on',
131 'fields' => array(
132 'nid' => array(
133 'description' => 'The {node}.nid this record tracks.',
134 'type' => 'int',
135 'unsigned' => TRUE,
136 'not null' => TRUE,
137 'default' => 0,
138 ),
139 'published' => array(
140 'description' => 'Boolean indicating whether the node is published.',
141 'type' => 'int',
142 'not null' => FALSE,
143 'default' => 0,
144 'size' => 'tiny',
145 ),
146 'changed' => array(
147 'description' => 'The Unix timestamp when the node was most recently saved or commented on.',
148 'type' => 'int',
149 'unsigned' => TRUE,
150 'not null' => TRUE,
151 'default' => 0,
152 ),
153 ),
154 'indexes' => array(
155 'tracker' => array('published', 'changed'),
156 ),
157 'primary key' => array('nid'),
158 'foreign keys' => array(
159 'tracked_node' => array(
160 'table' => 'node',
161 'columns' => array('nid' => 'nid'),
162 ),
163 ),
164 );
165
166 $schema['tracker_user'] = array(
167 'description' => 'Tracks when nodes were last changed or commented on, for each user that authored the node or one of its comments.',
168 'fields' => array(
169 'nid' => array(
170 'description' => 'The {node}.nid this record tracks.',
171 'type' => 'int',
172 'unsigned' => TRUE,
173 'not null' => TRUE,
174 'default' => 0,
175 ),
176 'uid' => array(
177 'description' => 'The {users}.uid of the node author or commenter.',
178 'type' => 'int',
179 'not null' => TRUE,
180 'default' => 0,
181 ),
182 'published' => array(
183 'description' => 'Boolean indicating whether the node is published.',
184 'type' => 'int',
185 'not null' => FALSE,
186 'default' => 0,
187 'size' => 'tiny',
188 ),
189 'changed' => array(
190 'description' => 'The Unix timestamp when the node was most recently saved or commented on.',
191 'type' => 'int',
192 'unsigned' => TRUE,
193 'not null' => TRUE,
194 'default' => 0,
195 ),
196 ),
197 'indexes' => array(
198 'tracker' => array('uid', 'published', 'changed'),
199 ),
200 'primary key' => array('nid', 'uid'),
201 'foreign keys' => array(
202 'tracked_node' => array(
203 'table' => 'node',
204 'columns' => array('nid' => 'nid'),
205 ),
206 'tracked_user' => array(
207 'table' => 'users',
208 'columns' => array('uid' => 'uid'),
209 ),
210 ),
211 );
212
213 foreach ($schema as $name => $table) {
214 db_create_table($name, $table);
215 }
216
217 $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField();
218 if ($max_nid != 0) {
219 variable_set('tracker_index_nid', $max_nid);
220 }
221 }
222
variable_del
variable_del($name)
Definition: bootstrap.inc:996
$name
print $name
Definition: profile-listing.tpl.php:43
tracker_cron
tracker_cron()
Definition: tracker.module:79
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
tracker_update_7000
tracker_update_7000()
Definition: tracker.install:128
tracker_enable
tracker_enable()
Definition: tracker.install:19
tracker_schema
tracker_schema()
Definition: tracker.install:32
tracker_uninstall
tracker_uninstall()
Definition: tracker.install:11
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/tabledrag_example/tabledrag_example_parent_form.inc Source File

  • examples
  • tabledrag_example
tabledrag_example_parent_form.inc
Go to the documentation of this file.
1 <?php
15 function tabledrag_example_parent_form($form_state) {
16 // Identify that the elements in 'example_items' are a collection, to
17 // prevent Form API from flattening the array when submitted.
18 $form['example_items']['#tree'] = TRUE;
19
20 // Tabledrag will take care of updating the parent_id relationship on each
21 // row of our table when we drag items around, but we need to build out the
22 // initial tree structure ourselves. This means ordering our items such
23 // that children items come directly after their parent items, and all items
24 // are sorted by weight relative to their siblings.
25 // To keep this from cluttering the actual tabledrag code, we have moved
26 // this to a dedicated function.
27
28 // Fetch the example data from the database, ordered by parent/child/weight.
29 $result = tabledrag_example_parent_get_data();
30
31 // Iterate through each database result.
32 foreach ($result as $item) {
33
34 // Create a form entry for this item.
35 //
36 // Each entry will be an array using the the unique id for that item as
37 // the array key, and an array of table row data as the value.
38 $form['example_items'][$item->id] = array(
39
40 // We'll use a form element of type '#markup' to display the item name.
41 'name' => array(
42 '#markup' => $item->name,
43 ),
44
45 // We'll use a form element of type '#textfield' to display the item
46 // description, to demonstrate that form elements can be included in the
47 // table. We limit the input to 255 characters, which is the limit we
48 // set on the database field.
49 'description' => array(
50 '#type' => 'textfield',
51 '#default_value' => $item->description,
52 '#size' => 20,
53 '#maxlength' => 255,
54 ),
55
56 // For parent/child relationships, we also need to add form items to
57 // store the current item's unique id and parent item's unique id.
58 //
59 // We would normally use a hidden element for this, but for this example
60 // we'll use a disabled textfield element called 'id' so that we can
61 // display the current item's id in the table.
62 //
63 // Because tabledrag modifies the #value of this element, we use
64 // '#default_value' instead of '#value' when defining a hidden element.
65 // Also, because tabledrag modifies '#value', we cannot use a markup
66 // element, which does not support the '#value' property. (Markup
67 // elements use the '#markup' property instead.)
68 'id' => array(
69 // '#type' => 'hidden',
70 // '#default_value' => $item->id,
71 '#type' => 'textfield',
72 '#size' => 3,
73 '#default_value' => $item->id,
74 '#disabled' => TRUE,
75 ),
76
77 // The same information holds true for the parent id field as for the
78 // item id field, described above.
79 'pid' => array(
80 // '#type' => 'hidden',
81 // '#default_value' => $item->pid,
82 '#type' => 'textfield',
83 '#size' => 3,
84 '#default_value' => $item->pid,
85 ),
86
87 // The 'weight' field will be manipulated as we move the items around in
88 // the table using the tabledrag activity. We use the 'weight' element
89 // defined in Drupal's Form API.
90 'weight' => array(
91 '#type' => 'weight',
92 '#title' => t('Weight'),
93 '#default_value' => $item->weight,
94 '#delta' => 10,
95 '#title_display' => 'invisible',
96 ),
97
98 // We'll use a hidden form element to pass the current 'depth' of each
99 // item within our parent/child tree structure to the theme function.
100 // This will be used to calculate the initial amount of indentation to
101 // add before displaying any child item rows.
102 'depth' => array(
103 '#type' => 'hidden',
104 '#value' => $item->depth,
105 ),
106 );
107 }
108
109 // Now we add our submit button, for submitting the form results.
110 //
111 // The 'actions' wrapper used here isn't strictly necessary for tabledrag,
112 // but is included as a Form API recommended practice.
113 $form['actions'] = array('#type' => 'actions');
114 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save Changes'));
115 return $form;
116 }
117
129 function theme_tabledrag_example_parent_form($variables) {
130 $form = $variables['form'];
131
132 // Initialize the variable which will store our table rows.
133 $rows = array();
134
135 // Iterate over each element in our $form['example_items'] array.
136 foreach (element_children($form['example_items']) as $id) {
137
138 // Before we add our 'weight' column to the row, we need to give the
139 // element a custom class so that it can be identified in the
140 // drupal_add_tabledrag call.
141 //
142 // This could also have been done during the form declaration by adding
143 // @code
144 // '#attributes' => array('class' => 'example-item-weight'),
145 // @endcode
146 // directly to the 'weight' element in tabledrag_example_simple_form().
147 $form['example_items'][$id]['weight']['#attributes']['class'] = array('example-item-weight');
148
149 // In the parent/child example, we must also set this same custom class on
150 // our id and parent_id columns (which could also have been done within
151 // the form declaration, as above).
152 $form['example_items'][$id]['id']['#attributes']['class'] = array('example-item-id');
153 $form['example_items'][$id]['pid']['#attributes']['class'] = array('example-item-pid');
154
155 // To support the tabledrag behaviour, we need to assign each row of the
156 // table a class attribute of 'draggable'. This will add the 'draggable'
157 // class to the <tr> element for that row when the final table is
158 // rendered.
159 $class = array('draggable');
160
161 // We can add the 'tabledrag-root' class to a row in order to indicate
162 // that the row may not be nested under a parent row. In our sample data
163 // for this example, the description for the item with id '8' flags it as
164 // a 'root' item which should not be nested.
165 if ($id == '8') {
166 $class[] = 'tabledrag-root';
167 }
168
169 // We can add the 'tabledrag-leaf' class to a row in order to indicate
170 // that the row may not contain child rows. In our sample data for this
171 // example, the description for the item with id '9' flags it as a 'leaf'
172 // item which can not contain child items.
173 if ($id == '9') {
174 $class[] = 'tabledrag-leaf';
175 }
176
177 // If this is a child element, we need to add some indentation to the row,
178 // so that it appears nested under its parent. Our $depth parameter was
179 // calculated while building the tree in tabledrag_example_parent_get_data
180 $indent = theme('indentation', array('size' => $form['example_items'][$id]['depth']['#value']));
181 unset($form['example_items'][$id]['depth']);
182
183 // We are now ready to add each element of our $form data to the $rows
184 // array, so that they end up as individual table cells when rendered
185 // in the final table. We run each element through the drupal_render()
186 // function to generate the final html markup for that element.
187 $rows[] = array(
188 'data' => array(
189 // Add our 'name' column, being sure to include our indentation.
190 $indent . drupal_render($form['example_items'][$id]['name']),
191 // Add our 'description' column.
192 drupal_render($form['example_items'][$id]['description']),
193 // Add our 'weight' column.
194 drupal_render($form['example_items'][$id]['weight']),
195 // Add our hidden 'id' column.
196 drupal_render($form['example_items'][$id]['id']),
197 // Add our hidden 'parent id' column.
198 drupal_render($form['example_items'][$id]['pid']),
199 ),
200 // To support the tabledrag behaviour, we need to assign each row of the
201 // table a class attribute of 'draggable'. This will add the 'draggable'
202 // class to the <tr> element for that row when the final table is
203 // rendered.
204 'class' => $class,
205 );
206 }
207
208 // We now define the table header values. Ensure that the 'header' count
209 // matches the final column count for your table.
210 //
211 // Normally, we would hide the headers on our hidden columns, but we are
212 // leaving them visible in this example.
213 // $header = array(t('Name'), t('Description'), '', '', '');
214 $header = array(t('Name'), t('Description'), t('Weight'), t('ID'), t('PID'));
215
216 // We also need to pass the drupal_add_tabledrag() function an id which will
217 // be used to identify the <table> element containing our tabledrag form.
218 // Because an element's 'id' should be unique on a page, make sure the value
219 // you select is NOT the same as the form ID used in your form declaration.
220 $table_id = 'example-items-table';
221
222 // We can render our tabledrag table for output.
223 $output = theme('table', array(
224 'header' => $header,
225 'rows' => $rows,
226 'attributes' => array('id' => $table_id),
227 ));
228
229 // And then render any remaining form elements (such as our submit button).
230 $output .= drupal_render_children($form);
231
232 // We now call the drupal_add_tabledrag() function in order to add the
233 // tabledrag.js goodness onto our page.
234 //
235 // For our parent/child tree table, we need to pass it:
236 // - the $table_id of our <table> element (example-items-table),
237 // - the $action to be performed on our form items ('match'),
238 // - a string describing where $action should be applied ('parent'),
239 // - the $group value (pid column) class name ('example-item-pid'),
240 // - the $subgroup value (pid column) class name ('example-item-pid'),
241 // - the $source value (id column) class name ('example-item-id'),
242 // - an optional $hidden flag identifying if the columns should be hidden,
243 // - an optional $limit parameter to control the max parenting depth.
244 drupal_add_tabledrag($table_id, 'match', 'parent', 'example-item-pid', 'example-item-pid', 'example-item-id', FALSE);
245
246 // Because we also want to sort in addition to providing parenting, we call
247 // the drupal_add_tabledrag function again, instructing it to update the
248 // weight field as items at the same level are re-ordered.
249 drupal_add_tabledrag($table_id, 'order', 'sibling', 'example-item-weight', NULL, NULL, FALSE);
250
251 return $output;
252 }
253
263 function tabledrag_example_parent_form_submit($form, &$form_state) {
264 // Because the form elements were keyed with the item ids from the database,
265 // we can simply iterate through the submitted values.
266 foreach ($form_state['values']['example_items'] as $id => $item) {
267 db_query(
268 "UPDATE {tabledrag_example} SET weight = :weight, pid = :pid WHERE id = :id",
269 array(':weight' => $item['weight'], ':pid' => $item['pid'], ':id' => $id)
270 );
271 }
272 }
273
286 function tabledrag_example_parent_get_data() {
287 // Get all 'root node' items (items with no parents), sorted by weight.
288 $rootnodes = db_query('SELECT id, name, description, weight, pid
289 FROM {tabledrag_example}
290 WHERE (pid = 0)
291 ORDER BY weight ASC');
292 // Initialize a variable to store our ordered tree structure.
293 $itemtree = array();
294 // Depth will be incremented in our _get_tree() function for the first
295 // parent item, so we start it at -1.
296 $depth = -1;
297 // Loop through the root nodes, and add their trees to the array.
298 foreach ($rootnodes as $parent) {
299 tabledrag_example_get_tree($parent, $itemtree, $depth);
300 }
301 return $itemtree;
302 }
303
309 function tabledrag_example_get_tree($parentitem, &$itemtree = array(), &$depth = 0) {
310 // Increase our $depth value by one.
311 $depth++;
312 // Set the current tree 'depth' for this item, used to calculate indentation.
313 $parentitem->depth = $depth;
314 // Add the parent item to the tree.
315 $itemtree[$parentitem->id] = $parentitem;
316 // Retrieve each of the children belonging to this parent.
317 $children = db_query('SELECT id, name, description, weight, pid
318 FROM {tabledrag_example}
319 WHERE (pid = :pid)
320 ORDER BY weight ASC',
321 array(':pid' => $parentitem->id));
322 foreach ($children as $child) {
323 // Make sure this child does not already exist in the tree, to avoid loops.
324 if (!in_array($child->id, array_keys($itemtree))) {
325 // Add this child's tree to the $itemtree array.
326 tabledrag_example_get_tree($child, $itemtree, $depth);
327 }
328 }
329 // Finished processing this tree branch. Decrease our $depth value by one
330 // to represent moving to the next branch.
331 $depth--;
332 // Return.
333 return;
334 }
tabledrag_example_parent_get_data
tabledrag_example_parent_get_data()
Definition: tabledrag_example_parent_form.inc:286
$header
print $header
Definition: forum-topic-list.tpl.php:42
tabledrag_example_get_tree
tabledrag_example_get_tree($parentitem, &$itemtree=array(), &$depth=0)
Definition: tabledrag_example_parent_form.inc:309
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
tabledrag_example_parent_form
tabledrag_example_parent_form($form_state)
Definition: tabledrag_example_parent_form.inc:15
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
theme_tabledrag_example_parent_form
theme_tabledrag_example_parent_form($variables)
Definition: tabledrag_example_parent_form.inc:129
$output
$output
Definition: authorize.php:93
$depth
print $depth
Definition: book-node-export-html.tpl.php:21
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
$children
print $children
Definition: book-node-export-html.tpl.php:24
tabledrag_example_parent_form_submit
tabledrag_example_parent_form_submit($form, &$form_state)
Definition: tabledrag_example_parent_form.inc:263
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/file_example/file_example_session_streams.inc Source File

  • examples
  • file_example
file_example_session_streams.inc
Go to the documentation of this file.
1 <?php
40 class FileExampleSessionStreamWrapper implements DrupalStreamWrapperInterface {
46 public $context;
47
48
56 protected $uri;
57
65 protected $session_content;
66
70 protected $directory_pointer;
71
75 protected $directory_keys;
76
80 protected $stream_pointer;
81
82 public function __construct() {
83 $_SESSION['file_example']['.isadir.txt'] = TRUE;
84 }
85
89 function setUri($uri) {
90 $this->uri = $uri;
91 }
92
96 function getUri() {
97 return $this->uri;
98 }
99
106 function getTarget($uri = NULL) {
107 if (!isset($uri)) {
108 $uri = $this->uri;
109 }
110
111 list($scheme, $target) = explode('://', $uri, 2);
112
113 // Remove erroneous leading or trailing, forward-slashes and backslashes.
114 // In the session:// scheme, there is never a leading slash on the target.
115 return trim($target, '\/');
116 }
117
121 static function getMimeType($uri, $mapping = NULL) {
122 if (!isset($mapping)) {
123 // The default file map, defined in file.mimetypes.inc is quite big.
124 // We only load it when necessary.
125 include_once DRUPAL_ROOT . '/includes/file.mimetypes.inc';
126 $mapping = file_mimetype_mapping();
127 }
128
129 $extension = '';
130 $file_parts = explode('.', basename($uri));
131
132 // Remove the first part: a full filename should not match an extension.
133 array_shift($file_parts);
134
135 // Iterate over the file parts, trying to find a match.
136 // For my.awesome.image.jpeg, we try:
137 // - jpeg
138 // - image.jpeg, and
139 // - awesome.image.jpeg
140 while ($additional_part = array_pop($file_parts)) {
141 $extension = drupal_strtolower($additional_part . ($extension ? '.' . $extension : ''));
142 if (isset($mapping['extensions'][$extension])) {
143 return $mapping['mimetypes'][$mapping['extensions'][$extension]];
144 }
145 }
146
147 return 'application/octet-stream';
148 }
149
155 public function getDirectoryPath() {
156 return '';
157 }
158
165 function getExternalUrl() {
166 $path = $this->getLocalPath();
167 $url = url('examples/file_example/access_session/' . $path, array('absolute' => TRUE));
168 return $url;
169 }
170
174 function chmod($mode) {
175 return TRUE;
176 }
177
181 function realpath() {
182 return 'session://' . $this->getLocalPath();
183 }
184
197 protected function getLocalPath($uri = NULL) {
198 if (!isset($uri)) {
199 $uri = $this->uri;
200 }
201
202 $path = str_replace('session://', '', $uri);
203 $path = trim($path, '/');
204 return $path;
205 }
206
224 public function stream_open($uri, $mode, $options, &$opened_path) {
225 $this->uri = $uri;
226 // We make $session_content a reference to the appropriate key in the
227 // $_SESSION variable. So if the local path were
228 // /example/test.txt it $session_content would now be a
229 // reference to $_SESSION['file_example']['example']['test.txt'].
230 $this->session_content = &$this->uri_to_session_key($uri);
231
232 // Reset the stream pointer since this is an open.
233 $this->stream_pointer = 0;
234 return TRUE;
235 }
236
249 protected function &uri_to_session_key($uri, $create = TRUE) {
250 // Since our uri_to_session_key() method returns a reference, we
251 // have to set up a failure flag variable.
252 $fail = FALSE;
253 $path = $this->getLocalPath($uri);
254 $path_components = explode('/', $path);
255 // Set up a reference to the root session:// 'directory.'
256 $var = &$_SESSION['file_example'];
257 // Handle case of just session://.
258 if (count($path_components) < 1) {
259 return $var;
260 }
261 // Walk through the path components and create keys in $_SESSION,
262 // unless we're told not to create them.
263 foreach ($path_components as $component) {
264 if ($create || isset($var[$component])) {
265 $var = &$var[$component];
266 }
267 else {
268 // This path doesn't exist as keys, either because the
269 // key doesn't exist, or because we're told not to create it.
270 return $fail;
271 }
272 }
273 return $var;
274 }
275
294 public function stream_lock($operation) {
295 return TRUE;
296 }
297
309 public function stream_read($count) {
310 if (is_string($this->session_content)) {
311 $remaining_chars = drupal_strlen($this->session_content) - $this->stream_pointer;
312 $number_to_read = min($count, $remaining_chars);
313 if ($remaining_chars > 0) {
314 $buffer = drupal_substr($this->session_content, $this->stream_pointer, $number_to_read);
315 $this->stream_pointer += $number_to_read;
316 return $buffer;
317 }
318 }
319 return FALSE;
320 }
321
333 public function stream_write($data) {
334 // Sanitize the data in a simple way since we're putting it into the
335 // session variable.
336 $data = check_plain($data);
337 $this->session_content = substr_replace($this->session_content, $data, $this->stream_pointer);
338 $this->stream_pointer += drupal_strlen($data);
339 return drupal_strlen($data);
340 }
341
350 public function stream_eof() {
351 return FALSE;
352 }
353
367 public function stream_seek($offset, $whence) {
368 if (drupal_strlen($this->session_content) >= $offset) {
369 $this->stream_pointer = $offset;
370 return TRUE;
371 }
372 return FALSE;
373 }
374
385 public function stream_flush() {
386 return TRUE;
387 }
388
397 public function stream_tell() {
398 return $this->stream_pointer;
399 }
400
410 public function stream_stat() {
411 return array(
412 'size' => drupal_strlen($this->session_content),
413 );
414 }
415
424 public function stream_close() {
425 $this->stream_pointer = 0;
426 unset($this->session_content); // Unassign the reference.
427 return TRUE;
428 }
429
441 public function unlink($uri) {
442 $path = $this->getLocalPath($uri);
443 $path_components = preg_split('/\//', $path);
444 $fail = FALSE;
445 $unset = '$_SESSION[\'file_example\']';
446 foreach ($path_components as $component) {
447 $unset .= '[\'' . $component . '\']';
448 }
449 // TODO: Is there a better way to delete from an array?
450 // drupal_array_get_nested_value() doesn' t work because it only returns
451 // a reference; unsetting a reference only unsets the reference.
452 eval("unset($unset);");
453 return TRUE;
454 }
455
469 public function rename($from_uri, $to_uri) {
470 $from_key = &$this->uri_to_session_key($from_uri);
471 $to_key = &$this->uri_to_session_key($to_uri);
472 if (is_dir($to_key) || is_file($to_key)) {
473 return FALSE;
474 }
475 $to_key = $from_key;
476 unset($from_key);
477 return TRUE;
478 }
479
491 public function dirname($uri = NULL) {
492 list($scheme, $target) = explode('://', $uri, 2);
493 $target = $this->getTarget($uri);
494 if (strpos($target, '/')) {
495 $dirname = preg_replace('@/[^/]*$@', '', $target);
496 }
497 else {
498 $dirname = '';
499 }
500 return $scheme . '://' . $dirname;
501 }
502
518 public function mkdir($uri, $mode, $options) {
519 // If this already exists, then we can't mkdir.
520 if (is_dir($uri) || is_file($uri)) {
521 return FALSE;
522 }
523
524 // Create the key in $_SESSION;
525 $this->uri_to_session_key($uri, TRUE);
526
527 // Place a magic file inside it to differentiate this from an empty file.
528 $marker_uri = $uri . '/.isadir.txt';
529 $this->uri_to_session_key($marker_uri, TRUE);
530 return TRUE;
531 }
532
546 public function rmdir($uri, $options) {
547 $path = $this->getLocalPath($uri);
548 $path_components = preg_split('/\//', $path);
549 $fail = FALSE;
550 $unset = '$_SESSION[\'file_example\']';
551 foreach ($path_components as $component) {
552 $unset .= '[\'' . $component . '\']';
553 }
554 // TODO: I really don' t like this eval.
555 debug($unset, 'array element to be unset');
556 eval("unset($unset);");
557
558 return TRUE;
559 }
560
581 public function url_stat($uri, $flags) {
582 // Get a reference to the $_SESSION key for this URI.
583 $key = $this->uri_to_session_key($uri, FALSE);
584 $return = FALSE; // Default to fail.
585 $mode = 0;
586
587 // We will call an array a directory and the root is always an array.
588 if (is_array($key) && array_key_exists('.isadir.txt', $key)) {
589 $mode = 0040000; // S_IFDIR means it's a directory.
590 }
591 elseif ($key !== FALSE) {
592 $mode = 0100000; // S_IFREG, means it's a file.
593 }
594
595 if ($mode) {
596 $size = 0;
597 if ($mode == 0100000) {
598 $size = drupal_strlen($key);
599 }
600
601 $mode |= 0777; // There are no protections on this, so all writable.
602 $return = array(
603 'dev' => 0,
604 'ino' => 0,
605 'mode' => $mode,
606 'nlink' => 0,
607 'uid' => 0,
608 'gid' => 0,
609 'rdev' => 0,
610 'size' => $size,
611 'atime' => 0,
612 'mtime' => 0,
613 'ctime' => 0,
614 'blksize' => 0,
615 'blocks' => 0,
616 );
617 }
618 return $return;
619 }
620
634 public function dir_opendir($uri, $options) {
635 $var = &$this->uri_to_session_key($uri, FALSE);
636 if ($var === FALSE || !array_key_exists('.isadir.txt', $var)) {
637 return FALSE;
638 }
639
640 // We grab the list of key names, flip it so that .isadir.txt can easily
641 // be removed, then flip it back so we can easily walk it as a list.
642 $this->directory_keys = array_flip(array_keys($var));
643 unset($this->directory_keys['.isadir.txt']);
644 $this->directory_keys = array_keys($this->directory_keys);
645 $this->directory_pointer = 0;
646 return TRUE;
647 }
648
657 public function dir_readdir() {
658 if ($this->directory_pointer < count($this->directory_keys)) {
659 $next = $this->directory_keys[$this->directory_pointer];
660 $this->directory_pointer++;
661 return $next;
662 }
663 return FALSE;
664 }
665
674 public function dir_rewinddir() {
675 $this->directory_pointer = 0;
676 }
677
686 public function dir_closedir() {
687 $this->directory_pointer = 0;
688 unset($this->directory_keys);
689 return TRUE;
690 }
691 }
FileExampleSessionStreamWrapper\getMimeType
static getMimeType($uri, $mapping=NULL)
Definition: file_example_session_streams.inc:121
FileExampleSessionStreamWrapper\__construct
__construct()
Definition: file_example_session_streams.inc:82
FileExampleSessionStreamWrapper\stream_flush
stream_flush()
Definition: file_example_session_streams.inc:385
FileExampleSessionStreamWrapper\url_stat
url_stat($uri, $flags)
Definition: file_example_session_streams.inc:581
drupal_strtolower
drupal_strtolower($text)
Definition: unicode.inc:521
FileExampleSessionStreamWrapper\$directory_keys
$directory_keys
Definition: file_example_session_streams.inc:75
drupal_strlen
drupal_strlen($text)
Definition: unicode.inc:474
FileExampleSessionStreamWrapper\mkdir
mkdir($uri, $mode, $options)
Definition: file_example_session_streams.inc:518
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
FileExampleSessionStreamWrapper\getLocalPath
getLocalPath($uri=NULL)
Definition: file_example_session_streams.inc:197
FileExampleSessionStreamWrapper\stream_stat
stream_stat()
Definition: file_example_session_streams.inc:410
FileExampleSessionStreamWrapper\realpath
realpath()
Definition: file_example_session_streams.inc:181
FileExampleSessionStreamWrapper\getExternalUrl
getExternalUrl()
Definition: file_example_session_streams.inc:165
DrupalStreamWrapperInterface
Definition: stream_wrappers.inc:126
FileExampleSessionStreamWrapper\dir_readdir
dir_readdir()
Definition: file_example_session_streams.inc:657
FileExampleSessionStreamWrapper
Definition: file_example_session_streams.inc:40
FileExampleSessionStreamWrapper\dir_closedir
dir_closedir()
Definition: file_example_session_streams.inc:686
drupal_substr
drupal_substr($text, $start, $length=NULL)
Definition: unicode.inc:585
file_mimetype_mapping
file_mimetype_mapping()
Definition: file.mimetypes.inc:18
FileExampleSessionStreamWrapper\unlink
unlink($uri)
Definition: file_example_session_streams.inc:441
FileExampleSessionStreamWrapper\dir_opendir
dir_opendir($uri, $options)
Definition: file_example_session_streams.inc:634
FileExampleSessionStreamWrapper\stream_eof
stream_eof()
Definition: file_example_session_streams.inc:350
FileExampleSessionStreamWrapper\rmdir
rmdir($uri, $options)
Definition: file_example_session_streams.inc:546
FileExampleSessionStreamWrapper\dir_rewinddir
dir_rewinddir()
Definition: file_example_session_streams.inc:674
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$url
print $url
Definition: search-result.tpl.php:70
FileExampleSessionStreamWrapper\$directory_pointer
$directory_pointer
Definition: file_example_session_streams.inc:70
FileExampleSessionStreamWrapper\setUri
setUri($uri)
Definition: file_example_session_streams.inc:89
FileExampleSessionStreamWrapper\stream_seek
stream_seek($offset, $whence)
Definition: file_example_session_streams.inc:367
FileExampleSessionStreamWrapper\getUri
getUri()
Definition: file_example_session_streams.inc:96
FileExampleSessionStreamWrapper\chmod
chmod($mode)
Definition: file_example_session_streams.inc:174
FileExampleSessionStreamWrapper\rename
rename($from_uri, $to_uri)
Definition: file_example_session_streams.inc:469
FileExampleSessionStreamWrapper\$stream_pointer
$stream_pointer
Definition: file_example_session_streams.inc:80
FileExampleSessionStreamWrapper\stream_close
stream_close()
Definition: file_example_session_streams.inc:424
FileExampleSessionStreamWrapper\getDirectoryPath
getDirectoryPath()
Definition: file_example_session_streams.inc:155
FileExampleSessionStreamWrapper\uri_to_session_key
& uri_to_session_key($uri, $create=TRUE)
Definition: file_example_session_streams.inc:249
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
FileExampleSessionStreamWrapper\$uri
$uri
Definition: file_example_session_streams.inc:56
FileExampleSessionStreamWrapper\stream_lock
stream_lock($operation)
Definition: file_example_session_streams.inc:294
FileExampleSessionStreamWrapper\dirname
dirname($uri=NULL)
Definition: file_example_session_streams.inc:491
FileExampleSessionStreamWrapper\getTarget
getTarget($uri=NULL)
Definition: file_example_session_streams.inc:106
FileExampleSessionStreamWrapper\stream_tell
stream_tell()
Definition: file_example_session_streams.inc:397
FileExampleSessionStreamWrapper\$context
$context
Definition: file_example_session_streams.inc:46
debug
debug($data, $label=NULL, $print_r=FALSE)
Definition: common.inc:7515
FileExampleSessionStreamWrapper\stream_read
stream_read($count)
Definition: file_example_session_streams.inc:309
FileExampleSessionStreamWrapper\stream_open
stream_open($uri, $mode, $options, &$opened_path)
Definition: file_example_session_streams.inc:224
FileExampleSessionStreamWrapper\$session_content
$session_content
Definition: file_example_session_streams.inc:65
FileExampleSessionStreamWrapper\stream_write
stream_write($data)
Definition: file_example_session_streams.inc:333
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/node.module Source File

  • modules
  • node
node.module
Go to the documentation of this file.
1 <?php
2
12 define('NODE_NOT_PUBLISHED', 0);
13
17 define('NODE_PUBLISHED', 1);
18
22 define('NODE_NOT_PROMOTED', 0);
23
27 define('NODE_PROMOTED', 1);
28
32 define('NODE_NOT_STICKY', 0);
33
37 define('NODE_STICKY', 1);
38
45 define('NODE_NEW_LIMIT', REQUEST_TIME - 30 * 24 * 60 * 60);
46
50 define('NODE_ACCESS_ALLOW', 'allow');
51
55 define('NODE_ACCESS_DENY', 'deny');
56
60 define('NODE_ACCESS_IGNORE', NULL);
61
65 function node_help($path, $arg) {
66 // Remind site administrators about the {node_access} table being flagged
67 // for rebuild. We don't need to issue the message on the confirm form, or
68 // while the rebuild is being processed.
69 if ($path != 'admin/reports/status/rebuild' && $path != 'batch' && strpos($path, '#') === FALSE
70 && user_access('access administration pages') && node_access_needs_rebuild()) {
71 if ($path == 'admin/reports/status') {
72 $message = t('The content access permissions need to be rebuilt.');
73 }
74 else {
75 $message = t('The content access permissions need to be rebuilt. <a href="@node_access_rebuild">Rebuild permissions</a>.', array('@node_access_rebuild' => url('admin/reports/status/rebuild')));
76 }
77 drupal_set_message($message, 'error');
78 }
79
80 switch ($path) {
81 case 'admin/help#node':
82 $output = '';
83 $output .= '<h3>' . t('About') . '</h3>';
84 $output .= '<p>' . t('The Node module manages the creation, editing, deletion, settings, and display of the main site content. Content items managed by the Node module are typically displayed as pages on your site, and include a title, some meta-data (author, creation time, content type, etc.), and optional fields containing text or other data (fields are managed by the <a href="@field">Field module</a>). For more information, see the online handbook entry for <a href="@node">Node module</a>.', array('@node' => 'http://drupal.org/documentation/modules/node', '@field' => url('admin/help/field'))) . '</p>';
85 $output .= '<h3>' . t('Uses') . '</h3>';
86 $output .= '<dl>';
87 $output .= '<dt>' . t('Creating content') . '</dt>';
88 $output .= '<dd>' . t('When new content is created, the Node module records basic information about the content, including the author, date of creation, and the <a href="@content-type">Content type</a>. It also manages the <em>publishing options</em>, which define whether or not the content is published, promoted to the front page of the site, and/or sticky at the top of content lists. Default settings can be configured for each <a href="@content-type">type of content</a> on your site.', array('@content-type' => url('admin/structure/types'))) . '</dd>';
89 $output .= '<dt>' . t('Creating custom content types') . '</dt>';
90 $output .= '<dd>' . t('The Node module gives users with the <em>Administer content types</em> permission the ability to <a href="@content-new">create new content types</a> in addition to the default ones already configured. Creating custom content types allows you the flexibility to add <a href="@field">fields</a> and configure default settings that suit the differing needs of various site content.', array('@content-new' => url('admin/structure/types/add'), '@field' => url('admin/help/field'))) . '</dd>';
91 $output .= '<dt>' . t('Administering content') . '</dt>';
92 $output .= '<dd>' . t('The <a href="@content">Content administration page</a> allows you to review and bulk manage your site content.', array('@content' => url('admin/content'))) . '</dd>';
93 $output .= '<dt>' . t('Creating revisions') . '</dt>';
94 $output .= '<dd>' . t('The Node module also enables you to create multiple versions of any content, and revert to older versions using the <em>Revision information</em> settings.') . '</dd>';
95 $output .= '<dt>' . t('User permissions') . '</dt>';
96 $output .= '<dd>' . t('The Node module makes a number of permissions available for each content type, which can be set by role on the <a href="@permissions">permissions page</a>.', array('@permissions' => url('admin/people/permissions', array('fragment' => 'module-node')))) . '</dd>';
97 $output .= '</dl>';
98 return $output;
99
100 case 'admin/structure/types/add':
101 return '<p>' . t('Individual content types can have different fields, behaviors, and permissions assigned to them.') . '</p>';
102
103 case 'admin/structure/types/manage/%/display':
104 return '<p>' . t('Content items can be displayed using different view modes: Teaser, Full content, Print, RSS, etc. <em>Teaser</em> is a short format that is typically used in lists of multiple content items. <em>Full content</em> is typically used when the content is displayed on its own page.') . '</p>' .
105 '<p>' . t('Here, you can define which fields are shown and hidden when %type content is displayed in each view mode, and define how the fields are displayed in each view mode.', array('%type' => node_type_get_name($arg[4]))) . '</p>';
106
107 case 'node/%/revisions':
108 return '<p>' . t('Revisions allow you to track differences between multiple versions of your content, and revert back to older versions.') . '</p>';
109
110 case 'node/%/edit':
111 $node = node_load($arg[1]);
112 $type = node_type_get_type($node);
113 return (!empty($type->help) ? '<p>' . filter_xss_admin($type->help) . '</p>' : '');
114 }
115
116 if ($arg[0] == 'node' && $arg[1] == 'add' && $arg[2]) {
117 $type = node_type_get_type(str_replace('-', '_', $arg[2]));
118 return (!empty($type->help) ? '<p>' . filter_xss_admin($type->help) . '</p>' : '');
119 }
120 }
121
125 function node_theme() {
126 return array(
127 'node' => array(
128 'render element' => 'elements',
129 'template' => 'node',
130 ),
131 'node_search_admin' => array(
132 'render element' => 'form',
133 ),
134 'node_add_list' => array(
135 'variables' => array('content' => NULL),
136 'file' => 'node.pages.inc',
137 ),
138 'node_preview' => array(
139 'variables' => array('node' => NULL),
140 'file' => 'node.pages.inc',
141 ),
142 'node_admin_overview' => array(
143 'variables' => array('name' => NULL, 'type' => NULL),
144 'file' => 'content_types.inc',
145 ),
146 'node_recent_block' => array(
147 'variables' => array('nodes' => NULL),
148 ),
149 'node_recent_content' => array(
150 'variables' => array('node' => NULL),
151 ),
152 );
153 }
154
158 function node_cron() {
159 db_delete('history')
160 ->condition('timestamp', NODE_NEW_LIMIT, '<')
161 ->execute();
162 }
163
167 function node_entity_info() {
168 $return = array(
169 'node' => array(
170 'label' => t('Node'),
171 'controller class' => 'NodeController',
172 'base table' => 'node',
173 'revision table' => 'node_revision',
174 'uri callback' => 'node_uri',
175 'fieldable' => TRUE,
176 'entity keys' => array(
177 'id' => 'nid',
178 'revision' => 'vid',
179 'bundle' => 'type',
180 'label' => 'title',
181 'language' => 'language',
182 ),
183 'bundle keys' => array(
184 'bundle' => 'type',
185 ),
186 'bundles' => array(),
187 'view modes' => array(
188 'full' => array(
189 'label' => t('Full content'),
190 'custom settings' => FALSE,
191 ),
192 'teaser' => array(
193 'label' => t('Teaser'),
194 'custom settings' => TRUE,
195 ),
196 'rss' => array(
197 'label' => t('RSS'),
198 'custom settings' => FALSE,
199 ),
200 ),
201 ),
202 );
203
204 // Search integration is provided by node.module, so search-related view modes
205 // for nodes are defined here and not in search.module.
206 if (module_exists('search')) {
207 $return['node']['view modes'] += array(
208 'search_index' => array(
209 'label' => t('Search index'),
210 'custom settings' => FALSE,
211 ),
212 'search_result' => array(
213 'label' => t('Search result'),
214 'custom settings' => FALSE,
215 ),
216 );
217 }
218
219 // Bundles must provide a human readable name so we can create help and error
220 // messages, and the path to attach Field admin pages to.
221 foreach (node_type_get_names() as $type => $name) {
222 $return['node']['bundles'][$type] = array(
223 'label' => $name,
224 'admin' => array(
225 'path' => 'admin/structure/types/manage/%node_type',
226 'real path' => 'admin/structure/types/manage/' . str_replace('_', '-', $type),
227 'bundle argument' => 4,
228 'access arguments' => array('administer content types'),
229 ),
230 );
231 }
232
233 return $return;
234 }
235
239 function node_field_display_node_alter(&$display, $context) {
240 // Hide field labels in search index.
241 if ($context['view_mode'] == 'search_index') {
242 $display['label'] = 'hidden';
243 }
244 }
245
249 function node_uri($node) {
250 return array(
251 'path' => 'node/' . $node->nid,
252 );
253 }
254
258 function node_admin_paths() {
259 if (variable_get('node_admin_theme')) {
260 $paths = array(
261 'node/*/edit' => TRUE,
262 'node/*/delete' => TRUE,
263 'node/*/revisions' => TRUE,
264 'node/*/revisions/*/revert' => TRUE,
265 'node/*/revisions/*/delete' => TRUE,
266 'node/add' => TRUE,
267 'node/add/*' => TRUE,
268 );
269 return $paths;
270 }
271 }
272
288 function node_title_list($result, $title = NULL) {
289 $items = array();
290 $num_rows = FALSE;
291 foreach ($result as $node) {
292 $items[] = l($node->title, 'node/' . $node->nid, !empty($node->comment_count) ? array('attributes' => array('title' => format_plural($node->comment_count, '1 comment', '@count comments'))) : array());
293 $num_rows = TRUE;
294 }
295
296 return $num_rows ? array('#theme' => 'item_list__node', '#items' => $items, '#title' => $title) : FALSE;
297 }
298
305 function node_tag_new($node) {
306 global $user;
307 if ($user->uid) {
308 db_merge('history')
309 ->key(array(
310 'uid' => $user->uid,
311 'nid' => $node->nid,
312 ))
313 ->fields(array('timestamp' => REQUEST_TIME))
314 ->execute();
315 }
316 }
317
328 function node_last_viewed($nid) {
329 global $user;
330 $history = &drupal_static(__FUNCTION__, array());
331
332 if (!isset($history[$nid])) {
333 $history[$nid] = db_query("SELECT timestamp FROM {history} WHERE uid = :uid AND nid = :nid", array(':uid' => $user->uid, ':nid' => $nid))->fetchObject();
334 }
335
336 return (isset($history[$nid]->timestamp) ? $history[$nid]->timestamp : 0);
337 }
338
350 function node_mark($nid, $timestamp) {
351 global $user;
352 $cache = &drupal_static(__FUNCTION__, array());
353
354 if (!$user->uid) {
355 return MARK_READ;
356 }
357 if (!isset($cache[$nid])) {
358 $cache[$nid] = node_last_viewed($nid);
359 }
360 if ($cache[$nid] == 0 && $timestamp > NODE_NEW_LIMIT) {
361 return MARK_NEW;
362 }
363 elseif ($timestamp > $cache[$nid] && $timestamp > NODE_NEW_LIMIT) {
364 return MARK_UPDATED;
365 }
366 return MARK_READ;
367 }
368
378 function _node_extract_type($node) {
379 return is_object($node) ? $node->type : $node;
380 }
381
393 function node_type_get_types() {
394 return _node_types_build()->types;
395 }
396
410 function node_type_get_type($node) {
411 $type = _node_extract_type($node);
412 $types = _node_types_build()->types;
413 return isset($types[$type]) ? $types[$type] : FALSE;
414 }
415
431 function node_type_get_base($node) {
432 $type = _node_extract_type($node);
433 $types = _node_types_build()->types;
434 return isset($types[$type]) && isset($types[$type]->base) ? $types[$type]->base : FALSE;
435 }
436
446 function node_type_get_names() {
447 return _node_types_build()->names;
448 }
449
459 function node_type_get_name($node) {
460 $type = _node_extract_type($node);
461 $types = _node_types_build()->names;
462 return isset($types[$type]) ? $types[$type] : FALSE;
463 }
464
475 function node_types_rebuild() {
476 _node_types_build(TRUE);
477 }
478
489 function node_type_load($name) {
490 return node_type_get_type(strtr($name, array('-' => '_')));
491 }
492
525 function node_type_save($info) {
526 $existing_type = !empty($info->old_type) ? $info->old_type : $info->type;
527 $is_existing = (bool) db_query_range('SELECT 1 FROM {node_type} WHERE type = :type', 0, 1, array(':type' => $existing_type))->fetchField();
528 $type = node_type_set_defaults($info);
529
530 $fields = array(
531 'type' => (string) $type->type,
532 'name' => (string) $type->name,
533 'base' => (string) $type->base,
534 'has_title' => (int) $type->has_title,
535 'title_label' => (string) $type->title_label,
536 'description' => (string) $type->description,
537 'help' => (string) $type->help,
538 'custom' => (int) $type->custom,
539 'modified' => (int) $type->modified,
540 'locked' => (int) $type->locked,
541 'disabled' => (int) $type->disabled,
542 'module' => $type->module,
543 );
544
545 if ($is_existing) {
546 db_update('node_type')
547 ->fields($fields)
548 ->condition('type', $existing_type)
549 ->execute();
550
551 if (!empty($type->old_type) && $type->old_type != $type->type) {
552 field_attach_rename_bundle('node', $type->old_type, $type->type);
553 }
554 module_invoke_all('node_type_update', $type);
555 $status = SAVED_UPDATED;
556 }
557 else {
558 $fields['orig_type'] = (string) $type->orig_type;
559 db_insert('node_type')
560 ->fields($fields)
561 ->execute();
562
563 field_attach_create_bundle('node', $type->type);
564
565 module_invoke_all('node_type_insert', $type);
566 $status = SAVED_NEW;
567 }
568
569 // Clear the node type cache.
570 node_type_cache_reset();
571
572 return $status;
573 }
574
586 function node_add_body_field($type, $label = 'Body') {
587 // Add or remove the body field, as needed.
588 $field = field_info_field('body');
589 $instance = field_info_instance('node', 'body', $type->type);
590 if (empty($field)) {
591 $field = array(
592 'field_name' => 'body',
593 'type' => 'text_with_summary',
594 'entity_types' => array('node'),
595 );
596 $field = field_create_field($field);
597 }
598 if (empty($instance)) {
599 $instance = array(
600 'field_name' => 'body',
601 'entity_type' => 'node',
602 'bundle' => $type->type,
603 'label' => $label,
604 'widget' => array('type' => 'text_textarea_with_summary'),
605 'settings' => array('display_summary' => TRUE),
606 'display' => array(
607 'default' => array(
608 'label' => 'hidden',
609 'type' => 'text_default',
610 ),
611 'teaser' => array(
612 'label' => 'hidden',
613 'type' => 'text_summary_or_trimmed',
614 ),
615 ),
616 );
617 $instance = field_create_instance($instance);
618 }
619 return $instance;
620 }
621
625 function node_field_extra_fields() {
626 $extra = array();
627
628 foreach (node_type_get_types() as $type) {
629 if ($type->has_title) {
630 $extra['node'][$type->type] = array(
631 'form' => array(
632 'title' => array(
633 'label' => $type->title_label,
634 'description' => t('Node module element'),
635 'weight' => -5,
636 ),
637 ),
638 );
639 }
640 }
641
642 return $extra;
643 }
644
651 function node_type_delete($type) {
652 $info = node_type_get_type($type);
653 db_delete('node_type')
654 ->condition('type', $type)
655 ->execute();
656 field_attach_delete_bundle('node', $type);
657 module_invoke_all('node_type_delete', $info);
658
659 // Clear the node type cache.
660 node_type_cache_reset();
661 }
662
674 function node_type_update_nodes($old_type, $type) {
675 return db_update('node')
676 ->fields(array('type' => $type))
677 ->condition('type', $old_type)
678 ->execute();
679 }
680
705 function _node_types_build($rebuild = FALSE) {
706 $cid = 'node_types:' . $GLOBALS['language']->language;
707
708 if (!$rebuild) {
709 $_node_types = &drupal_static(__FUNCTION__);
710 if (isset($_node_types)) {
711 return $_node_types;
712 }
713 if ($cache = cache_get($cid)) {
714 $_node_types = $cache->data;
715 return $_node_types;
716 }
717 }
718
719 $_node_types = (object) array('types' => array(), 'names' => array());
720
721 foreach (module_implements('node_info') as $module) {
722 $info_array = module_invoke($module, 'node_info');
723 foreach ($info_array as $type => $info) {
724 $info['type'] = $type;
725 $_node_types->types[$type] = node_type_set_defaults($info);
726 $_node_types->types[$type]->module = $module;
727 $_node_types->names[$type] = $info['name'];
728 }
729 }
730 $query = db_select('node_type', 'nt')
731 ->addTag('translatable')
732 ->addTag('node_type_access')
733 ->fields('nt')
734 ->orderBy('nt.type', 'ASC');
735 if (!$rebuild) {
736 $query->condition('disabled', 0);
737 }
738 foreach ($query->execute() as $type_object) {
739 $type_db = $type_object->type;
740 // Original disabled value.
741 $disabled = $type_object->disabled;
742 // Check for node types from disabled modules and mark their types for removal.
743 // Types defined by the node module in the database (rather than by a separate
744 // module using hook_node_info) have a base value of 'node_content'. The isset()
745 // check prevents errors on old (pre-Drupal 7) databases.
746 if (isset($type_object->base) && $type_object->base != 'node_content' && empty($_node_types->types[$type_db])) {
747 $type_object->disabled = TRUE;
748 }
749 if (isset($_node_types->types[$type_db])) {
750 $type_object->disabled = FALSE;
751 }
752 if (!isset($_node_types->types[$type_db]) || $type_object->modified) {
753 $_node_types->types[$type_db] = $type_object;
754 $_node_types->names[$type_db] = $type_object->name;
755
756 if ($type_db != $type_object->orig_type) {
757 unset($_node_types->types[$type_object->orig_type]);
758 unset($_node_types->names[$type_object->orig_type]);
759 }
760 }
761 $_node_types->types[$type_db]->disabled = $type_object->disabled;
762 $_node_types->types[$type_db]->disabled_changed = $disabled != $type_object->disabled;
763 }
764
765 if ($rebuild) {
766 foreach ($_node_types->types as $type => $type_object) {
767 if (!empty($type_object->is_new) || !empty($type_object->disabled_changed)) {
768 node_type_save($type_object);
769 }
770 }
771 }
772
773 asort($_node_types->names);
774
775 cache_set($cid, $_node_types);
776
777 return $_node_types;
778 }
779
783 function node_type_cache_reset() {
784 cache_clear_all('node_types:', 'cache', TRUE);
785 drupal_static_reset('_node_types_build');
786 }
787
805 function node_type_set_defaults($info = array()) {
806 $info = (array) $info;
807 $new_type = $info + array(
808 'type' => '',
809 'name' => '',
810 'base' => '',
811 'description' => '',
812 'help' => '',
813 'custom' => 0,
814 'modified' => 0,
815 'locked' => 1,
816 'disabled' => 0,
817 'is_new' => 1,
818 'has_title' => 1,
819 'title_label' => 'Title',
820 );
821 $new_type = (object) $new_type;
822
823 // If the type has no title, set an empty label.
824 if (!$new_type->has_title) {
825 $new_type->title_label = '';
826 }
827 if (empty($new_type->module)) {
828 $new_type->module = $new_type->base == 'node_content' ? 'node' : '';
829 }
830 $new_type->orig_type = isset($info['type']) ? $info['type'] : '';
831
832 return $new_type;
833 }
834
838 function node_rdf_mapping() {
839 return array(
840 array(
841 'type' => 'node',
842 'bundle' => RDF_DEFAULT_BUNDLE,
843 'mapping' => array(
844 'rdftype' => array('sioc:Item', 'foaf:Document'),
845 'title' => array(
846 'predicates' => array('dc:title'),
847 ),
848 'created' => array(
849 'predicates' => array('dc:date', 'dc:created'),
850 'datatype' => 'xsd:dateTime',
851 'callback' => 'date_iso8601',
852 ),
853 'changed' => array(
854 'predicates' => array('dc:modified'),
855 'datatype' => 'xsd:dateTime',
856 'callback' => 'date_iso8601',
857 ),
858 'body' => array(
859 'predicates' => array('content:encoded'),
860 ),
861 'uid' => array(
862 'predicates' => array('sioc:has_creator'),
863 'type' => 'rel',
864 ),
865 'name' => array(
866 'predicates' => array('foaf:name'),
867 ),
868 'comment_count' => array(
869 'predicates' => array('sioc:num_replies'),
870 'datatype' => 'xsd:integer',
871 ),
872 'last_activity' => array(
873 'predicates' => array('sioc:last_activity_date'),
874 'datatype' => 'xsd:dateTime',
875 'callback' => 'date_iso8601',
876 ),
877 ),
878 ),
879 );
880 }
881
893 function node_hook($node, $hook) {
894 $base = node_type_get_base($node);
895 return module_hook($base, $hook);
896 }
897
911 function node_invoke($node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
912 if (node_hook($node, $hook)) {
913 $base = node_type_get_base($node);
914 $function = $base . '_' . $hook;
915 return ($function($node, $a2, $a3, $a4));
916 }
917 }
918
945 function node_load_multiple($nids = array(), $conditions = array(), $reset = FALSE) {
946 return entity_load('node', $nids, $conditions, $reset);
947 }
948
962 function node_load($nid = NULL, $vid = NULL, $reset = FALSE) {
963 $nids = (isset($nid) ? array($nid) : array());
964 $conditions = (isset($vid) ? array('vid' => $vid) : array());
965 $node = node_load_multiple($nids, $conditions, $reset);
966 return $node ? reset($node) : FALSE;
967 }
968
978 function node_object_prepare($node) {
979 // Set up default values, if required.
980 $node_options = variable_get('node_options_' . $node->type, array('status', 'promote'));
981 // If this is a new node, fill in the default values.
982 if (!isset($node->nid) || isset($node->is_new)) {
983 foreach (array('status', 'promote', 'sticky') as $key) {
984 // Multistep node forms might have filled in something already.
985 if (!isset($node->$key)) {
986 $node->$key = (int) in_array($key, $node_options);
987 }
988 }
989 global $user;
990 $node->uid = $user->uid;
991 $node->created = REQUEST_TIME;
992 }
993 else {
994 $node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O');
995 // Remove the log message from the original node object.
996 $node->log = NULL;
997 }
998 // Always use the default revision setting.
999 $node->revision = in_array('revision', $node_options);
1000
1001 node_invoke($node, 'prepare');
1002 module_invoke_all('node_prepare', $node);
1003 }
1004
1010 function node_validate($node, $form, &$form_state) {
1011 if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) {
1012 form_set_error('changed', t('The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved.'));
1013 }
1014
1015 // Validate the "authored by" field.
1016 if (!empty($node->name) && !($account = user_load_by_name($node->name))) {
1017 // The use of empty() is mandatory in the context of usernames
1018 // as the empty string denotes the anonymous user. In case we
1019 // are dealing with an anonymous user we set the user ID to 0.
1020 form_set_error('name', t('The username %name does not exist.', array('%name' => $node->name)));
1021 }
1022
1023 // Validate the "authored on" field.
1024 if (!empty($node->date) && strtotime($node->date) === FALSE) {
1025 form_set_error('date', t('You have to specify a valid date.'));
1026 }
1027
1028 // Invoke hook_validate() for node type specific validation and
1029 // hook_node_validate() for miscellaneous validation needed by modules. Can't
1030 // use node_invoke() or module_invoke_all(), because $form_state must be
1031 // receivable by reference.
1032 $function = node_type_get_base($node) . '_validate';
1033 if (function_exists($function)) {
1034 $function($node, $form, $form_state);
1035 }
1036 foreach (module_implements('node_validate') as $module) {
1037 $function = $module . '_node_validate';
1038 $function($node, $form, $form_state);
1039 }
1040 }
1041
1051 function node_submit($node) {
1052 // A user might assign the node author by entering a user name in the node
1053 // form, which we then need to translate to a user ID.
1054 if (isset($node->name)) {
1055 if ($account = user_load_by_name($node->name)) {
1056 $node->uid = $account->uid;
1057 }
1058 else {
1059 $node->uid = 0;
1060 }
1061 }
1062
1063 $node->created = !empty($node->date) ? strtotime($node->date) : REQUEST_TIME;
1064 $node->validated = TRUE;
1065
1066 return $node;
1067 }
1068
1076 function node_save($node) {
1077 $transaction = db_transaction();
1078
1079 try {
1080 // Load the stored entity, if any.
1081 if (!empty($node->nid) && !isset($node->original)) {
1082 $node->original = entity_load_unchanged('node', $node->nid);
1083 }
1084
1085 field_attach_presave('node', $node);
1086 global $user;
1087
1088 // Determine if we will be inserting a new node.
1089 if (!isset($node->is_new)) {
1090 $node->is_new = empty($node->nid);
1091 }
1092
1093 // Set the timestamp fields.
1094 if (empty($node->created)) {
1095 $node->created = REQUEST_TIME;
1096 }
1097 // The changed timestamp is always updated for bookkeeping purposes,
1098 // for example: revisions, searching, etc.
1099 $node->changed = REQUEST_TIME;
1100
1101 $node->timestamp = REQUEST_TIME;
1102 $update_node = TRUE;
1103
1104 // Let modules modify the node before it is saved to the database.
1105 module_invoke_all('node_presave', $node);
1106 module_invoke_all('entity_presave', $node, 'node');
1107
1108 if ($node->is_new || !empty($node->revision)) {
1109 // When inserting either a new node or a new node revision, $node->log
1110 // must be set because {node_revision}.log is a text column and therefore
1111 // cannot have a default value. However, it might not be set at this
1112 // point (for example, if the user submitting a node form does not have
1113 // permission to create revisions), so we ensure that it is at least an
1114 // empty string in that case.
1115 // @todo: Make the {node_revision}.log column nullable so that we can
1116 // remove this check.
1117 if (!isset($node->log)) {
1118 $node->log = '';
1119 }
1120 }
1121 elseif (!isset($node->log) || $node->log === '') {
1122 // If we are updating an existing node without adding a new revision, we
1123 // need to make sure $node->log is unset whenever it is empty. As long as
1124 // $node->log is unset, drupal_write_record() will not attempt to update
1125 // the existing database column when re-saving the revision; therefore,
1126 // this code allows us to avoid clobbering an existing log entry with an
1127 // empty one.
1128 unset($node->log);
1129 }
1130
1131 // When saving a new node revision, unset any existing $node->vid so as to
1132 // ensure that a new revision will actually be created, then store the old
1133 // revision ID in a separate property for use by node hook implementations.
1134 if (!$node->is_new && !empty($node->revision) && $node->vid) {
1135 $node->old_vid = $node->vid;
1136 unset($node->vid);
1137 }
1138
1139 // Save the node and node revision.
1140 if ($node->is_new) {
1141 // For new nodes, save new records for both the node itself and the node
1142 // revision.
1143 drupal_write_record('node', $node);
1144 _node_save_revision($node, $user->uid);
1145 $op = 'insert';
1146 }
1147 else {
1148 // For existing nodes, update the node record which matches the value of
1149 // $node->nid.
1150 drupal_write_record('node', $node, 'nid');
1151 // Then, if a new node revision was requested, save a new record for
1152 // that; otherwise, update the node revision record which matches the
1153 // value of $node->vid.
1154 if (!empty($node->revision)) {
1155 _node_save_revision($node, $user->uid);
1156 }
1157 else {
1158 _node_save_revision($node, $user->uid, 'vid');
1159 $update_node = FALSE;
1160 }
1161 $op = 'update';
1162 }
1163 if ($update_node) {
1164 db_update('node')
1165 ->fields(array('vid' => $node->vid))
1166 ->condition('nid', $node->nid)
1167 ->execute();
1168 }
1169
1170 // Call the node specific callback (if any). This can be
1171 // node_invoke($node, 'insert') or
1172 // node_invoke($node, 'update').
1173 node_invoke($node, $op);
1174
1175 // Save fields.
1176 $function = "field_attach_$op";
1177 $function('node', $node);
1178
1179 module_invoke_all('node_' . $op, $node);
1180 module_invoke_all('entity_' . $op, $node, 'node');
1181
1182 // Update the node access table for this node.
1183 node_access_acquire_grants($node);
1184
1185 // Clear internal properties.
1186 unset($node->is_new);
1187 unset($node->original);
1188 // Clear the static loading cache.
1189 entity_get_controller('node')->resetCache(array($node->nid));
1190
1191 // Ignore slave server temporarily to give time for the
1192 // saved node to be propagated to the slave.
1193 db_ignore_slave();
1194 }
1195 catch (Exception $e) {
1196 $transaction->rollback();
1197 watchdog_exception('node', $e);
1198 throw $e;
1199 }
1200 }
1201
1214 function _node_save_revision($node, $uid, $update = NULL) {
1215 $temp_uid = $node->uid;
1216 $node->uid = $uid;
1217 if (isset($update)) {
1218 drupal_write_record('node_revision', $node, $update);
1219 }
1220 else {
1221 drupal_write_record('node_revision', $node);
1222 }
1223 // Have node object still show node owner's uid, not revision author's.
1224 $node->uid = $temp_uid;
1225 }
1226
1233 function node_delete($nid) {
1234 node_delete_multiple(array($nid));
1235 }
1236
1243 function node_delete_multiple($nids) {
1244 $transaction = db_transaction();
1245 if (!empty($nids)) {
1246 $nodes = node_load_multiple($nids, array());
1247
1248 try {
1249 foreach ($nodes as $nid => $node) {
1250 // Call the node-specific callback (if any):
1251 node_invoke($node, 'delete');
1252 module_invoke_all('node_delete', $node);
1253 module_invoke_all('entity_delete', $node, 'node');
1254 field_attach_delete('node', $node);
1255
1256 // Remove this node from the search index if needed.
1257 // This code is implemented in node module rather than in search module,
1258 // because node module is implementing search module's API, not the other
1259 // way around.
1260 if (module_exists('search')) {
1261 search_reindex($nid, 'node');
1262 }
1263 }
1264
1265 // Delete after calling hooks so that they can query node tables as needed.
1266 db_delete('node')
1267 ->condition('nid', $nids, 'IN')
1268 ->execute();
1269 db_delete('node_revision')
1270 ->condition('nid', $nids, 'IN')
1271 ->execute();
1272 db_delete('history')
1273 ->condition('nid', $nids, 'IN')
1274 ->execute();
1275 db_delete('node_access')
1276 ->condition('nid', $nids, 'IN')
1277 ->execute();
1278 }
1279 catch (Exception $e) {
1280 $transaction->rollback();
1281 watchdog_exception('node', $e);
1282 throw $e;
1283 }
1284
1285 // Clear the page and block and node_load_multiple caches.
1286 entity_get_controller('node')->resetCache();
1287 }
1288 }
1289
1296 function node_revision_delete($revision_id) {
1297 if ($revision = node_load(NULL, $revision_id)) {
1298 // Prevent deleting the current revision.
1299 $node = node_load($revision->nid);
1300 if ($revision_id == $node->vid) {
1301 return FALSE;
1302 }
1303
1304 db_delete('node_revision')
1305 ->condition('nid', $revision->nid)
1306 ->condition('vid', $revision->vid)
1307 ->execute();
1308 module_invoke_all('node_revision_delete', $revision);
1309 field_attach_delete_revision('node', $revision);
1310 return TRUE;
1311 }
1312 return FALSE;
1313 }
1314
1329 function node_view($node, $view_mode = 'full', $langcode = NULL) {
1330 if (!isset($langcode)) {
1331 $langcode = $GLOBALS['language_content']->language;
1332 }
1333
1334 // Populate $node->content with a render() array.
1335 node_build_content($node, $view_mode, $langcode);
1336
1337 $build = $node->content;
1338 // We don't need duplicate rendering info in node->content.
1339 unset($node->content);
1340
1341 $build += array(
1342 '#theme' => 'node',
1343 '#node' => $node,
1344 '#view_mode' => $view_mode,
1345 '#language' => $langcode,
1346 );
1347
1348 // Add contextual links for this node, except when the node is already being
1349 // displayed on its own page. Modules may alter this behavior (for example,
1350 // to restrict contextual links to certain view modes) by implementing
1351 // hook_node_view_alter().
1352 if (!empty($node->nid) && !($view_mode == 'full' && node_is_page($node))) {
1353 $build['#contextual_links']['node'] = array('node', array($node->nid));
1354 }
1355
1356 // Allow modules to modify the structured node.
1357 $type = 'node';
1358 drupal_alter(array('node_view', 'entity_view'), $build, $type);
1359
1360 return $build;
1361 }
1362
1391 function node_build_content($node, $view_mode = 'full', $langcode = NULL) {
1392 if (!isset($langcode)) {
1393 $langcode = $GLOBALS['language_content']->language;
1394 }
1395
1396 // Remove previously built content, if exists.
1397 $node->content = array();
1398
1399 // Allow modules to change the view mode.
1400 $context = array(
1401 'entity_type' => 'node',
1402 'entity' => $node,
1403 'langcode' => $langcode,
1404 );
1405 drupal_alter('entity_view_mode', $view_mode, $context);
1406
1407 // The 'view' hook can be implemented to overwrite the default function
1408 // to display nodes.
1409 if (node_hook($node, 'view')) {
1410 $node = node_invoke($node, 'view', $view_mode, $langcode);
1411 }
1412
1413 // Build fields content.
1414 // In case of a multiple view, node_view_multiple() already ran the
1415 // 'prepare_view' step. An internal flag prevents the operation from running
1416 // twice.
1417 field_attach_prepare_view('node', array($node->nid => $node), $view_mode, $langcode);
1418 entity_prepare_view('node', array($node->nid => $node), $langcode);
1419 $node->content += field_attach_view('node', $node, $view_mode, $langcode);
1420
1421 // Always display a read more link on teasers because we have no way to know
1422 // when a teaser view is different than a full view.
1423 $links = array();
1424 $node->content['links'] = array(
1425 '#theme' => 'links__node',
1426 '#pre_render' => array('drupal_pre_render_links'),
1427 '#attributes' => array('class' => array('links', 'inline')),
1428 );
1429 if ($view_mode == 'teaser') {
1430 $node_title_stripped = strip_tags($node->title);
1431 $links['node-readmore'] = array(
1432 'title' => t('Read more<span class="element-invisible"> about @title</span>', array('@title' => $node_title_stripped)),
1433 'href' => 'node/' . $node->nid,
1434 'html' => TRUE,
1435 'attributes' => array('rel' => 'tag', 'title' => $node_title_stripped),
1436 );
1437 }
1438 $node->content['links']['node'] = array(
1439 '#theme' => 'links__node__node',
1440 '#links' => $links,
1441 '#attributes' => array('class' => array('links', 'inline')),
1442 );
1443
1444 // Allow modules to make their own additions to the node.
1445 module_invoke_all('node_view', $node, $view_mode, $langcode);
1446 module_invoke_all('entity_view', $node, 'node', $view_mode, $langcode);
1447
1448 // Make sure the current view mode is stored if no module has already
1449 // populated the related key.
1450 $node->content += array('#view_mode' => $view_mode);
1451 }
1452
1464 function node_show($node, $message = FALSE) {
1465 if ($message) {
1466 drupal_set_title(t('Revision of %title from %date', array('%title' => $node->title, '%date' => format_date($node->revision_timestamp))), PASS_THROUGH);
1467 }
1468
1469 // For markup consistency with other pages, use node_view_multiple() rather than node_view().
1470 $nodes = node_view_multiple(array($node->nid => $node), 'full');
1471
1472 // Update the history table, stating that this user viewed this node.
1473 node_tag_new($node);
1474
1475 return $nodes;
1476 }
1477
1487 function node_is_page($node) {
1488 $page_node = menu_get_object();
1489 return (!empty($page_node) ? $page_node->nid == $node->nid : FALSE);
1490 }
1491
1506 function template_preprocess_node(&$variables) {
1507 $variables['view_mode'] = $variables['elements']['#view_mode'];
1508 // Provide a distinct $teaser boolean.
1509 $variables['teaser'] = $variables['view_mode'] == 'teaser';
1510 $variables['node'] = $variables['elements']['#node'];
1511 $node = $variables['node'];
1512
1513 $variables['date'] = format_date($node->created);
1514 $variables['name'] = theme('username', array('account' => $node));
1515
1516 $uri = entity_uri('node', $node);
1517 $variables['node_url'] = url($uri['path'], $uri['options']);
1518 $variables['title'] = check_plain($node->title);
1519 $variables['page'] = $variables['view_mode'] == 'full' && node_is_page($node);
1520
1521 // Flatten the node object's member fields.
1522 $variables = array_merge((array) $node, $variables);
1523
1524 // Helpful $content variable for templates.
1525 $variables += array('content' => array());
1526 foreach (element_children($variables['elements']) as $key) {
1527 $variables['content'][$key] = $variables['elements'][$key];
1528 }
1529
1530 // Make the field variables available with the appropriate language.
1531 field_attach_preprocess('node', $node, $variables['content'], $variables);
1532
1533 // Display post information only on certain node types.
1534 if (variable_get('node_submitted_' . $node->type, TRUE)) {
1535 $variables['display_submitted'] = TRUE;
1536 $variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date']));
1537 $variables['user_picture'] = theme_get_setting('toggle_node_user_picture') ? theme('user_picture', array('account' => $node)) : '';
1538 }
1539 else {
1540 $variables['display_submitted'] = FALSE;
1541 $variables['submitted'] = '';
1542 $variables['user_picture'] = '';
1543 }
1544
1545 // Gather node classes.
1546 $variables['classes_array'][] = drupal_html_class('node-' . $node->type);
1547 if ($variables['promote']) {
1548 $variables['classes_array'][] = 'node-promoted';
1549 }
1550 if ($variables['sticky']) {
1551 $variables['classes_array'][] = 'node-sticky';
1552 }
1553 if (!$variables['status']) {
1554 $variables['classes_array'][] = 'node-unpublished';
1555 }
1556 if ($variables['teaser']) {
1557 $variables['classes_array'][] = 'node-teaser';
1558 }
1559 if (isset($variables['preview'])) {
1560 $variables['classes_array'][] = 'node-preview';
1561 }
1562
1563 // Clean up name so there are no underscores.
1564 $variables['theme_hook_suggestions'][] = 'node__' . $node->type;
1565 $variables['theme_hook_suggestions'][] = 'node__' . $node->nid;
1566 }
1567
1571 function node_permission() {
1572 $perms = array(
1573 'bypass node access' => array(
1574 'title' => t('Bypass content access control'),
1575 'description' => t('View, edit and delete all content regardless of permission restrictions.'),
1576 'restrict access' => TRUE,
1577 ),
1578 'administer content types' => array(
1579 'title' => t('Administer content types'),
1580 'restrict access' => TRUE,
1581 ),
1582 'administer nodes' => array(
1583 'title' => t('Administer content'),
1584 'restrict access' => TRUE,
1585 ),
1586 'access content overview' => array(
1587 'title' => t('Access the content overview page'),
1588 'description' => user_access('access content overview')
1589 ? t('Get an overview of <a href="@url">all content</a>.', array('@url' => url('admin/content')))
1590 : t('Get an overview of all content.'),
1591 ),
1592 'access content' => array(
1593 'title' => t('View published content'),
1594 ),
1595 'view own unpublished content' => array(
1596 'title' => t('View own unpublished content'),
1597 ),
1598 'view revisions' => array(
1599 'title' => t('View content revisions'),
1600 ),
1601 'revert revisions' => array(
1602 'title' => t('Revert content revisions'),
1603 ),
1604 'delete revisions' => array(
1605 'title' => t('Delete content revisions'),
1606 ),
1607 );
1608
1609 // Generate standard node permissions for all applicable node types.
1610 foreach (node_permissions_get_configured_types() as $type) {
1611 $perms += node_list_permissions($type);
1612 }
1613
1614 return $perms;
1615 }
1616
1623 function _node_rankings(SelectQueryExtender $query) {
1624 if ($ranking = module_invoke_all('ranking')) {
1625 $tables = &$query->getTables();
1626 foreach ($ranking as $rank => $values) {
1627 if ($node_rank = variable_get('node_rank_' . $rank, 0)) {
1628 // If the table defined in the ranking isn't already joined, then add it.
1629 if (isset($values['join']) && !isset($tables[$values['join']['alias']])) {
1630 $query->addJoin($values['join']['type'], $values['join']['table'], $values['join']['alias'], $values['join']['on']);
1631 }
1632 $arguments = isset($values['arguments']) ? $values['arguments'] : array();
1633 $query->addScore($values['score'], $arguments, $node_rank);
1634 }
1635 }
1636 }
1637 }
1638
1642 function node_search_info() {
1643 return array(
1644 'title' => 'Content',
1645 'path' => 'node',
1646 );
1647 }
1648
1652 function node_search_access() {
1653 return user_access('access content');
1654 }
1655
1659 function node_search_reset() {
1660 db_update('search_dataset')
1661 ->fields(array('reindex' => REQUEST_TIME))
1662 ->condition('type', 'node')
1663 ->execute();
1664 }
1665
1669 function node_search_status() {
1670 $total = db_query('SELECT COUNT(*) FROM {node}')->fetchField();
1671 $remaining = db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0")->fetchField();
1672 return array('remaining' => $remaining, 'total' => $total);
1673 }
1674
1678 function node_search_admin() {
1679 // Output form for defining rank factor weights.
1680 $form['content_ranking'] = array(
1681 '#type' => 'fieldset',
1682 '#title' => t('Content ranking'),
1683 );
1684 $form['content_ranking']['#theme'] = 'node_search_admin';
1685 $form['content_ranking']['info'] = array(
1686 '#value' => '<em>' . t('The following numbers control which properties the content search should favor when ordering the results. Higher numbers mean more influence, zero means the property is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em>'
1687 );
1688
1689 // Note: reversed to reflect that higher number = higher ranking.
1690 $options = drupal_map_assoc(range(0, 10));
1691 foreach (module_invoke_all('ranking') as $var => $values) {
1692 $form['content_ranking']['factors']['node_rank_' . $var] = array(
1693 '#title' => $values['title'],
1694 '#type' => 'select',
1695 '#options' => $options,
1696 '#default_value' => variable_get('node_rank_' . $var, 0),
1697 );
1698 }
1699 return $form;
1700 }
1701
1705 function node_search_execute($keys = NULL, $conditions = NULL) {
1706 // Build matching conditions
1707 $query = db_select('search_index', 'i', array('target' => 'slave'))->extend('SearchQuery')->extend('PagerDefault');
1708 $query->join('node', 'n', 'n.nid = i.sid');
1709 $query
1710 ->condition('n.status', 1)
1711 ->addTag('node_access')
1712 ->searchExpression($keys, 'node');
1713
1714 // Insert special keywords.
1715 $query->setOption('type', 'n.type');
1716 $query->setOption('language', 'n.language');
1717 if ($query->setOption('term', 'ti.tid')) {
1718 $query->join('taxonomy_index', 'ti', 'n.nid = ti.nid');
1719 }
1720 // Only continue if the first pass query matches.
1721 if (!$query->executeFirstPass()) {
1722 return array();
1723 }
1724
1725 // Add the ranking expressions.
1726 _node_rankings($query);
1727
1728 // Load results.
1729 $find = $query
1730 ->limit(10)
1731 ->execute();
1732 $results = array();
1733 foreach ($find as $item) {
1734 // Render the node.
1735 $node = node_load($item->sid);
1736 $build = node_view($node, 'search_result');
1737 unset($build['#theme']);
1738 $node->rendered = drupal_render($build);
1739
1740 // Fetch comments for snippet.
1741 $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node);
1742
1743 $extra = module_invoke_all('node_search_result', $node);
1744
1745 $uri = entity_uri('node', $node);
1746 $results[] = array(
1747 'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE))),
1748 'type' => check_plain(node_type_get_name($node)),
1749 'title' => $node->title,
1750 'user' => theme('username', array('account' => $node)),
1751 'date' => $node->changed,
1752 'node' => $node,
1753 'extra' => $extra,
1754 'score' => $item->calculated_score,
1755 'snippet' => search_excerpt($keys, $node->rendered),
1756 'language' => entity_language('node', $node),
1757 );
1758 }
1759 return $results;
1760 }
1761
1765 function node_ranking() {
1766 // Create the ranking array and add the basic ranking options.
1767 $ranking = array(
1768 'relevance' => array(
1769 'title' => t('Keyword relevance'),
1770 // Average relevance values hover around 0.15
1771 'score' => 'i.relevance',
1772 ),
1773 'sticky' => array(
1774 'title' => t('Content is sticky at top of lists'),
1775 // The sticky flag is either 0 or 1, which is automatically normalized.
1776 'score' => 'n.sticky',
1777 ),
1778 'promote' => array(
1779 'title' => t('Content is promoted to the front page'),
1780 // The promote flag is either 0 or 1, which is automatically normalized.
1781 'score' => 'n.promote',
1782 ),
1783 );
1784
1785 // Add relevance based on creation or changed date.
1786 if ($node_cron_last = variable_get('node_cron_last', 0)) {
1787 $ranking['recent'] = array(
1788 'title' => t('Recently posted'),
1789 // Exponential decay with half-life of 6 months, starting at last indexed node
1790 'score' => 'POW(2.0, (GREATEST(n.created, n.changed) - :node_cron_last) * 6.43e-8)',
1791 'arguments' => array(':node_cron_last' => $node_cron_last),
1792 );
1793 }
1794 return $ranking;
1795 }
1796
1800 function node_user_cancel($edit, $account, $method) {
1801 switch ($method) {
1802 case 'user_cancel_block_unpublish':
1803 // Unpublish nodes (current revisions).
1804 module_load_include('inc', 'node', 'node.admin');
1805 $nodes = db_select('node', 'n')
1806 ->fields('n', array('nid'))
1807 ->condition('uid', $account->uid)
1808 ->execute()
1809 ->fetchCol();
1810 node_mass_update($nodes, array('status' => 0));
1811 break;
1812
1813 case 'user_cancel_reassign':
1814 // Anonymize nodes (current revisions).
1815 module_load_include('inc', 'node', 'node.admin');
1816 $nodes = db_select('node', 'n')
1817 ->fields('n', array('nid'))
1818 ->condition('uid', $account->uid)
1819 ->execute()
1820 ->fetchCol();
1821 node_mass_update($nodes, array('uid' => 0));
1822 // Anonymize old revisions.
1823 db_update('node_revision')
1824 ->fields(array('uid' => 0))
1825 ->condition('uid', $account->uid)
1826 ->execute();
1827 // Clean history.
1828 db_delete('history')
1829 ->condition('uid', $account->uid)
1830 ->execute();
1831 break;
1832 }
1833 }
1834
1838 function node_user_delete($account) {
1839 // Delete nodes (current revisions).
1840 // @todo Introduce node_mass_delete() or make node_mass_update() more flexible.
1841 $nodes = db_select('node', 'n')
1842 ->fields('n', array('nid'))
1843 ->condition('uid', $account->uid)
1844 ->execute()
1845 ->fetchCol();
1846 node_delete_multiple($nodes);
1847 // Delete old revisions.
1848 $revisions = db_query('SELECT vid FROM {node_revision} WHERE uid = :uid', array(':uid' => $account->uid))->fetchCol();
1849 foreach ($revisions as $revision) {
1850 node_revision_delete($revision);
1851 }
1852 // Clean history.
1853 db_delete('history')
1854 ->condition('uid', $account->uid)
1855 ->execute();
1856 }
1857
1868 function theme_node_search_admin($variables) {
1869 $form = $variables['form'];
1870
1871 $output = drupal_render($form['info']);
1872
1873 $header = array(t('Factor'), t('Weight'));
1874 foreach (element_children($form['factors']) as $key) {
1875 $row = array();
1876 $row[] = $form['factors'][$key]['#title'];
1877 $form['factors'][$key]['#title_display'] = 'invisible';
1878 $row[] = drupal_render($form['factors'][$key]);
1879 $rows[] = $row;
1880 }
1881 $output .= theme('table', array('header' => $header, 'rows' => $rows));
1882
1883 $output .= drupal_render_children($form);
1884 return $output;
1885 }
1886
1903 function _node_revision_access($node, $op = 'view', $account = NULL) {
1904 $access = &drupal_static(__FUNCTION__, array());
1905
1906 $map = array(
1907 'view' => 'view revisions',
1908 'update' => 'revert revisions',
1909 'delete' => 'delete revisions',
1910 );
1911
1912 if (!$node || !isset($map[$op])) {
1913 // If there was no node to check against, or the $op was not one of the
1914 // supported ones, we return access denied.
1915 return FALSE;
1916 }
1917
1918 if (!isset($account)) {
1919 $account = $GLOBALS['user'];
1920 }
1921
1922 // Statically cache access by revision ID, user account ID, and operation.
1923 $cid = $node->vid . ':' . $account->uid . ':' . $op;
1924
1925 if (!isset($access[$cid])) {
1926 // Perform basic permission checks first.
1927 if (!user_access($map[$op], $account) && !user_access('administer nodes', $account)) {
1928 return $access[$cid] = FALSE;
1929 }
1930
1931 $node_current_revision = node_load($node->nid);
1932 $is_current_revision = $node_current_revision->vid == $node->vid;
1933
1934 // There should be at least two revisions. If the vid of the given node and
1935 // the vid of the current revision differ, then we already have two
1936 // different revisions so there is no need for a separate database check.
1937 // Also, if you try to revert to or delete the current revision, that's not
1938 // good.
1939 if ($is_current_revision && (db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid', array(':nid' => $node->nid))->fetchField() == 1 || $op == 'update' || $op == 'delete')) {
1940 $access[$cid] = FALSE;
1941 }
1942 elseif (user_access('administer nodes', $account)) {
1943 $access[$cid] = TRUE;
1944 }
1945 else {
1946 // First check the access to the current revision and finally, if the node
1947 // passed in is not the current revision then access to that, too.
1948 $access[$cid] = node_access($op, $node_current_revision, $account) && ($is_current_revision || node_access($op, $node, $account));
1949 }
1950 }
1951
1952 return $access[$cid];
1953 }
1954
1963 function _node_add_access() {
1964 $types = node_type_get_types();
1965 foreach ($types as $type) {
1966 if (node_hook($type->type, 'form') && node_access('create', $type->type)) {
1967 return TRUE;
1968 }
1969 }
1970 if (user_access('administer content types')) {
1971 // There are no content types defined that the user has permission to create,
1972 // but the user does have the permission to administer the content types, so
1973 // grant them access to the page anyway.
1974 return TRUE;
1975 }
1976 return FALSE;
1977 }
1978
1982 function node_menu() {
1983 $items['admin/content'] = array(
1984 'title' => 'Content',
1985 'description' => 'Find and manage content.',
1986 'page callback' => 'drupal_get_form',
1987 'page arguments' => array('node_admin_content'),
1988 'access arguments' => array('access content overview'),
1989 'weight' => -10,
1990 'file' => 'node.admin.inc',
1991 );
1992 $items['admin/content/node'] = array(
1993 'title' => 'Content',
1994 'type' => MENU_DEFAULT_LOCAL_TASK,
1995 'weight' => -10,
1996 );
1997
1998 $items['admin/reports/status/rebuild'] = array(
1999 'title' => 'Rebuild permissions',
2000 'page callback' => 'drupal_get_form',
2001 'page arguments' => array('node_configure_rebuild_confirm'),
2002 // Any user than can potentially trigger a node_access_needs_rebuild(TRUE)
2003 // has to be allowed access to the 'node access rebuild' confirm form.
2004 'access arguments' => array('access administration pages'),
2005 'type' => MENU_CALLBACK,
2006 'file' => 'node.admin.inc',
2007 );
2008
2009 $items['admin/structure/types'] = array(
2010 'title' => 'Content types',
2011 'description' => 'Manage content types, including default status, front page promotion, comment settings, etc.',
2012 'page callback' => 'node_overview_types',
2013 'access arguments' => array('administer content types'),
2014 'file' => 'content_types.inc',
2015 );
2016 $items['admin/structure/types/list'] = array(
2017 'title' => 'List',
2018 'type' => MENU_DEFAULT_LOCAL_TASK,
2019 'weight' => -10,
2020 );
2021 $items['admin/structure/types/add'] = array(
2022 'title' => 'Add content type',
2023 'page callback' => 'drupal_get_form',
2024 'page arguments' => array('node_type_form'),
2025 'access arguments' => array('administer content types'),
2026 'type' => MENU_LOCAL_ACTION,
2027 'file' => 'content_types.inc',
2028 );
2029 $items['admin/structure/types/manage/%node_type'] = array(
2030 'title' => 'Edit content type',
2031 'title callback' => 'node_type_page_title',
2032 'title arguments' => array(4),
2033 'page callback' => 'drupal_get_form',
2034 'page arguments' => array('node_type_form', 4),
2035 'access arguments' => array('administer content types'),
2036 'file' => 'content_types.inc',
2037 );
2038 $items['admin/structure/types/manage/%node_type/edit'] = array(
2039 'title' => 'Edit',
2040 'type' => MENU_DEFAULT_LOCAL_TASK,
2041 );
2042 $items['admin/structure/types/manage/%node_type/delete'] = array(
2043 'title' => 'Delete',
2044 'page arguments' => array('node_type_delete_confirm', 4),
2045 'access arguments' => array('administer content types'),
2046 'file' => 'content_types.inc',
2047 );
2048
2049 $items['node'] = array(
2050 'page callback' => 'node_page_default',
2051 'access arguments' => array('access content'),
2052 'menu_name' => 'navigation',
2053 'type' => MENU_CALLBACK,
2054 );
2055 $items['node/add'] = array(
2056 'title' => 'Add content',
2057 'page callback' => 'node_add_page',
2058 'access callback' => '_node_add_access',
2059 'file' => 'node.pages.inc',
2060 );
2061 $items['rss.xml'] = array(
2062 'title' => 'RSS feed',
2063 'page callback' => 'node_feed',
2064 'access arguments' => array('access content'),
2065 'type' => MENU_CALLBACK,
2066 // Pass a FALSE and array argument to ensure that additional path components
2067 // are not passed to node_feed().
2068 'page arguments' => array(FALSE, array()),
2069 );
2070 // @todo Remove this loop when we have a 'description callback' property.
2071 // Reset internal static cache of _node_types_build(), forces to rebuild the
2072 // node type information.
2073 node_type_cache_reset();
2074 foreach (node_type_get_types() as $type) {
2075 $type_url_str = str_replace('_', '-', $type->type);
2076 $items['node/add/' . $type_url_str] = array(
2077 'title' => $type->name,
2078 'title callback' => 'check_plain',
2079 'page callback' => 'node_add',
2080 'page arguments' => array($type->type),
2081 'access callback' => 'node_access',
2082 'access arguments' => array('create', $type->type),
2083 'description' => $type->description,
2084 'file' => 'node.pages.inc',
2085 );
2086 }
2087 $items['node/%node'] = array(
2088 'title callback' => 'node_page_title',
2089 'title arguments' => array(1),
2090 // The page callback also invokes drupal_set_title() in case
2091 // the menu router's title is overridden by a menu link.
2092 'page callback' => 'node_page_view',
2093 'page arguments' => array(1),
2094 'access callback' => 'node_access',
2095 'access arguments' => array('view', 1),
2096 );
2097 $items['node/%node/view'] = array(
2098 'title' => 'View',
2099 'type' => MENU_DEFAULT_LOCAL_TASK,
2100 'weight' => -10,
2101 );
2102 $items['node/%node/edit'] = array(
2103 'title' => 'Edit',
2104 'page callback' => 'node_page_edit',
2105 'page arguments' => array(1),
2106 'access callback' => 'node_access',
2107 'access arguments' => array('update', 1),
2108 'weight' => 0,
2109 'type' => MENU_LOCAL_TASK,
2110 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
2111 'file' => 'node.pages.inc',
2112 );
2113 $items['node/%node/delete'] = array(
2114 'title' => 'Delete',
2115 'page callback' => 'drupal_get_form',
2116 'page arguments' => array('node_delete_confirm', 1),
2117 'access callback' => 'node_access',
2118 'access arguments' => array('delete', 1),
2119 'weight' => 1,
2120 'type' => MENU_LOCAL_TASK,
2121 'context' => MENU_CONTEXT_INLINE,
2122 'file' => 'node.pages.inc',
2123 );
2124 $items['node/%node/revisions'] = array(
2125 'title' => 'Revisions',
2126 'page callback' => 'node_revision_overview',
2127 'page arguments' => array(1),
2128 'access callback' => '_node_revision_access',
2129 'access arguments' => array(1),
2130 'weight' => 2,
2131 'type' => MENU_LOCAL_TASK,
2132 'file' => 'node.pages.inc',
2133 );
2134 $items['node/%node/revisions/%/view'] = array(
2135 'title' => 'Revisions',
2136 'load arguments' => array(3),
2137 'page callback' => 'node_show',
2138 'page arguments' => array(1, TRUE),
2139 'access callback' => '_node_revision_access',
2140 'access arguments' => array(1),
2141 );
2142 $items['node/%node/revisions/%/revert'] = array(
2143 'title' => 'Revert to earlier revision',
2144 'load arguments' => array(3),
2145 'page callback' => 'drupal_get_form',
2146 'page arguments' => array('node_revision_revert_confirm', 1),
2147 'access callback' => '_node_revision_access',
2148 'access arguments' => array(1, 'update'),
2149 'file' => 'node.pages.inc',
2150 );
2151 $items['node/%node/revisions/%/delete'] = array(
2152 'title' => 'Delete earlier revision',
2153 'load arguments' => array(3),
2154 'page callback' => 'drupal_get_form',
2155 'page arguments' => array('node_revision_delete_confirm', 1),
2156 'access callback' => '_node_revision_access',
2157 'access arguments' => array(1, 'delete'),
2158 'file' => 'node.pages.inc',
2159 );
2160 return $items;
2161 }
2162
2166 function node_menu_local_tasks_alter(&$data, $router_item, $root_path) {
2167 // Add action link to 'node/add' on 'admin/content' page.
2168 if ($root_path == 'admin/content') {
2169 $item = menu_get_item('node/add');
2170 if ($item['access']) {
2171 $data['actions']['output'][] = array(
2172 '#theme' => 'menu_local_action',
2173 '#link' => $item,
2174 );
2175 }
2176 }
2177 }
2178
2190 function node_type_page_title($type) {
2191 return $type->name;
2192 }
2193
2205 function node_page_title($node) {
2206 return $node->title;
2207 }
2208
2218 function node_last_changed($nid) {
2219 return db_query('SELECT changed FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetch()->changed;
2220 }
2221
2231 function node_revision_list($node) {
2232 $revisions = array();
2233 $result = db_query('SELECT r.vid, r.title, r.log, r.uid, n.vid AS current_vid, r.timestamp, u.name FROM {node_revision} r LEFT JOIN {node} n ON n.vid = r.vid INNER JOIN {users} u ON u.uid = r.uid WHERE r.nid = :nid ORDER BY r.vid DESC', array(':nid' => $node->nid));
2234 foreach ($result as $revision) {
2235 $revisions[$revision->vid] = $revision;
2236 }
2237
2238 return $revisions;
2239 }
2240
2244 function node_block_info() {
2245 $blocks['syndicate']['info'] = t('Syndicate');
2246 // Not worth caching.
2247 $blocks['syndicate']['cache'] = DRUPAL_NO_CACHE;
2248
2249 $blocks['recent']['info'] = t('Recent content');
2250 $blocks['recent']['properties']['administrative'] = TRUE;
2251
2252 return $blocks;
2253 }
2254
2258 function node_block_view($delta = '') {
2259 $block = array();
2260
2261 switch ($delta) {
2262 case 'syndicate':
2263 $block['subject'] = t('Syndicate');
2264 $block['content'] = theme('feed_icon', array('url' => 'rss.xml', 'title' => t('Syndicate')));
2265 break;
2266
2267 case 'recent':
2268 if (user_access('access content')) {
2269 $block['subject'] = t('Recent content');
2270 if ($nodes = node_get_recent(variable_get('node_recent_block_count', 10))) {
2271 $block['content'] = theme('node_recent_block', array(
2272 'nodes' => $nodes,
2273 ));
2274 } else {
2275 $block['content'] = t('No content available.');
2276 }
2277 }
2278 break;
2279 }
2280 return $block;
2281 }
2282
2286 function node_block_configure($delta = '') {
2287 $form = array();
2288 if ($delta == 'recent') {
2289 $form['node_recent_block_count'] = array(
2290 '#type' => 'select',
2291 '#title' => t('Number of recent content items to display'),
2292 '#default_value' => variable_get('node_recent_block_count', 10),
2293 '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
2294 );
2295 }
2296 return $form;
2297 }
2298
2302 function node_block_save($delta = '', $edit = array()) {
2303 if ($delta == 'recent') {
2304 variable_set('node_recent_block_count', $edit['node_recent_block_count']);
2305 }
2306 }
2307
2318 function node_get_recent($number = 10) {
2319 $query = db_select('node', 'n');
2320
2321 if (!user_access('bypass node access')) {
2322 // If the user is able to view their own unpublished nodes, allow them to
2323 // see these in addition to published nodes. Check that they actually have
2324 // some unpublished nodes to view before adding the condition.
2325 if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT nid FROM {node} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->uid, ':status' => NODE_NOT_PUBLISHED))->fetchCol()) {
2326 $query->condition(db_or()
2327 ->condition('n.status', NODE_PUBLISHED)
2328 ->condition('n.nid', $own_unpublished, 'IN')
2329 );
2330 }
2331 else {
2332 // If not, restrict the query to published nodes.
2333 $query->condition('n.status', NODE_PUBLISHED);
2334 }
2335 }
2336 $nids = $query
2337 ->fields('n', array('nid'))
2338 ->orderBy('n.changed', 'DESC')
2339 ->range(0, $number)
2340 ->addTag('node_access')
2341 ->execute()
2342 ->fetchCol();
2343
2344 $nodes = node_load_multiple($nids);
2345
2346 return $nodes ? $nodes : array();
2347 }
2348
2358 function theme_node_recent_block($variables) {
2359 $rows = array();
2360 $output = '';
2361
2362 $l_options = array('query' => drupal_get_destination());
2363 foreach ($variables['nodes'] as $node) {
2364 $row = array();
2365 $row[] = array(
2366 'data' => theme('node_recent_content', array('node' => $node)),
2367 'class' => 'title-author',
2368 );
2369 $row[] = array(
2370 'data' => node_access('update', $node) ? l(t('edit'), 'node/' . $node->nid . '/edit', $l_options) : '',
2371 'class' => 'edit',
2372 );
2373 $row[] = array(
2374 'data' => node_access('delete', $node) ? l(t('delete'), 'node/' . $node->nid . '/delete', $l_options) : '',
2375 'class' => 'delete',
2376 );
2377 $rows[] = $row;
2378 }
2379
2380 if ($rows) {
2381 $output = theme('table', array('rows' => $rows));
2382 if (user_access('access content overview')) {
2383 $output .= theme('more_link', array('url' => 'admin/content', 'title' => t('Show more content')));
2384 }
2385 }
2386
2387 return $output;
2388 }
2389
2399 function theme_node_recent_content($variables) {
2400 $node = $variables['node'];
2401
2402 $output = '<div class="node-title">';
2403 $output .= l($node->title, 'node/' . $node->nid);
2404 $output .= theme('mark', array('type' => node_mark($node->nid, $node->changed)));
2405 $output .= '</div><div class="node-author">';
2406 $output .= theme('username', array('account' => user_load($node->uid)));
2407 $output .= '</div>';
2408
2409 return $output;
2410 }
2411
2419 function node_form_block_add_block_form_alter(&$form, &$form_state) {
2420 node_form_block_admin_configure_alter($form, $form_state);
2421 }
2422
2430 function node_form_block_admin_configure_alter(&$form, &$form_state) {
2431 $default_type_options = db_query("SELECT type FROM {block_node_type} WHERE module = :module AND delta = :delta", array(
2432 ':module' => $form['module']['#value'],
2433 ':delta' => $form['delta']['#value'],
2434 ))->fetchCol();
2435 $form['visibility']['node_type'] = array(
2436 '#type' => 'fieldset',
2437 '#title' => t('Content types'),
2438 '#collapsible' => TRUE,
2439 '#collapsed' => TRUE,
2440 '#group' => 'visibility',
2441 '#weight' => 5,
2442 );
2443 $form['visibility']['node_type']['types'] = array(
2444 '#type' => 'checkboxes',
2445 '#title' => t('Show block for specific content types'),
2446 '#default_value' => $default_type_options,
2447 '#options' => node_type_get_names(),
2448 '#description' => t('Show this block only on pages that display content of the given type(s). If you select no types, there will be no type-specific limitation.'),
2449 );
2450 $form['#submit'][] = 'node_form_block_admin_configure_submit';
2451 }
2452
2458 function node_form_block_admin_configure_submit($form, &$form_state) {
2459 db_delete('block_node_type')
2460 ->condition('module', $form_state['values']['module'])
2461 ->condition('delta', $form_state['values']['delta'])
2462 ->execute();
2463 $query = db_insert('block_node_type')->fields(array('type', 'module', 'delta'));
2464 foreach (array_filter($form_state['values']['types']) as $type) {
2465 $query->values(array(
2466 'type' => $type,
2467 'module' => $form_state['values']['module'],
2468 'delta' => $form_state['values']['delta'],
2469 ));
2470 }
2471 $query->execute();
2472 }
2473
2481 function node_form_block_custom_block_delete_alter(&$form, &$form_state) {
2482 $form['#submit'][] = 'node_form_block_custom_block_delete_submit';
2483 }
2484
2490 function node_form_block_custom_block_delete_submit($form, &$form_state) {
2491 db_delete('block_node_type')
2492 ->condition('module', 'block')
2493 ->condition('delta', $form_state['values']['bid'])
2494 ->execute();
2495 }
2496
2502 function node_modules_uninstalled($modules) {
2503 db_delete('block_node_type')
2504 ->condition('module', $modules, 'IN')
2505 ->execute();
2506 }
2507
2514 function node_block_list_alter(&$blocks) {
2515 global $theme_key;
2516
2517 // Build an array of node types for each block.
2518 $block_node_types = array();
2519 $result = db_query('SELECT module, delta, type FROM {block_node_type}');
2520 foreach ($result as $record) {
2521 $block_node_types[$record->module][$record->delta][$record->type] = TRUE;
2522 }
2523
2524 $node = menu_get_object();
2525 $node_types = node_type_get_types();
2526 if (arg(0) == 'node' && arg(1) == 'add' && arg(2)) {
2527 $node_add_arg = strtr(arg(2), '-', '_');
2528 }
2529 foreach ($blocks as $key => $block) {
2530 if (!isset($block->theme) || !isset($block->status) || $block->theme != $theme_key || $block->status != 1) {
2531 // This block was added by a contrib module, leave it in the list.
2532 continue;
2533 }
2534
2535 // If a block has no node types associated, it is displayed for every type.
2536 // For blocks with node types associated, if the node type does not match
2537 // the settings from this block, remove it from the block list.
2538 if (isset($block_node_types[$block->module][$block->delta])) {
2539 if (!empty($node)) {
2540 // This is a node or node edit page.
2541 if (!isset($block_node_types[$block->module][$block->delta][$node->type])) {
2542 // This block should not be displayed for this node type.
2543 unset($blocks[$key]);
2544 continue;
2545 }
2546 }
2547 elseif (isset($node_add_arg) && isset($node_types[$node_add_arg])) {
2548 // This is a node creation page
2549 if (!isset($block_node_types[$block->module][$block->delta][$node_add_arg])) {
2550 // This block should not be displayed for this node type.
2551 unset($blocks[$key]);
2552 continue;
2553 }
2554 }
2555 else {
2556 // This is not a node page, remove the block.
2557 unset($blocks[$key]);
2558 continue;
2559 }
2560 }
2561 }
2562 }
2563
2581 function node_feed($nids = FALSE, $channel = array()) {
2582 global $base_url, $language_content;
2583
2584 if ($nids === FALSE) {
2585 $nids = db_select('node', 'n')
2586 ->fields('n', array('nid', 'created'))
2587 ->condition('n.promote', 1)
2588 ->condition('n.status', 1)
2589 ->orderBy('n.created', 'DESC')
2590 ->range(0, variable_get('feed_default_items', 10))
2591 ->addTag('node_access')
2592 ->execute()
2593 ->fetchCol();
2594 }
2595
2596 $item_length = variable_get('feed_item_length', 'fulltext');
2597 $namespaces = array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/');
2598
2599 // Load all nodes to be rendered.
2600 $nodes = node_load_multiple($nids);
2601 $items = '';
2602 foreach ($nodes as $node) {
2603 $item_text = '';
2604
2605 $node->link = url("node/$node->nid", array('absolute' => TRUE));
2606 $node->rss_namespaces = array();
2607 $node->rss_elements = array(
2608 array('key' => 'pubDate', 'value' => gmdate('r', $node->created)),
2609 array('key' => 'dc:creator', 'value' => $node->name),
2610 array('key' => 'guid', 'value' => $node->nid . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false'))
2611 );
2612
2613 // The node gets built and modules add to or modify $node->rss_elements
2614 // and $node->rss_namespaces.
2615 $build = node_view($node, 'rss');
2616 unset($build['#theme']);
2617
2618 if (!empty($node->rss_namespaces)) {
2619 $namespaces = array_merge($namespaces, $node->rss_namespaces);
2620 }
2621
2622 if ($item_length != 'title') {
2623 // We render node contents and force links to be last.
2624 $build['links']['#weight'] = 1000;
2625 $item_text .= drupal_render($build);
2626 }
2627
2628 $items .= format_rss_item($node->title, $node->link, $item_text, $node->rss_elements);
2629 }
2630
2631 $channel_defaults = array(
2632 'version' => '2.0',
2633 'title' => variable_get('site_name', 'Drupal'),
2634 'link' => $base_url,
2635 'description' => variable_get('feed_description', ''),
2636 'language' => $language_content->language
2637 );
2638 $channel_extras = array_diff_key($channel, $channel_defaults);
2639 $channel = array_merge($channel_defaults, $channel);
2640
2641 $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
2642 $output .= "<rss version=\"" . $channel["version"] . "\" xml:base=\"" . $base_url . "\" " . drupal_attributes($namespaces) . ">\n";
2643 $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language'], $channel_extras);
2644 $output .= "</rss>\n";
2645
2646 drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
2647 print $output;
2648 }
2649
2666 function node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0, $langcode = NULL) {
2667 field_attach_prepare_view('node', $nodes, $view_mode, $langcode);
2668 entity_prepare_view('node', $nodes, $langcode);
2669 $build = array();
2670 foreach ($nodes as $node) {
2671 $build['nodes'][$node->nid] = node_view($node, $view_mode, $langcode);
2672 $build['nodes'][$node->nid]['#weight'] = $weight;
2673 $weight++;
2674 }
2675 $build['nodes']['#sorted'] = TRUE;
2676 return $build;
2677 }
2678
2687 function node_page_default() {
2688 $select = db_select('node', 'n')
2689 ->fields('n', array('nid', 'sticky', 'created'))
2690 ->condition('n.promote', 1)
2691 ->condition('n.status', 1)
2692 ->orderBy('n.sticky', 'DESC')
2693 ->orderBy('n.created', 'DESC')
2694 ->extend('PagerDefault')
2695 ->limit(variable_get('default_nodes_main', 10))
2696 ->addTag('node_access');
2697
2698 $nids = $select->execute()->fetchCol();
2699
2700 if (!empty($nids)) {
2701 $nodes = node_load_multiple($nids);
2702 $build = node_view_multiple($nodes);
2703
2704 // 'rss.xml' is a path, not a file, registered in node_menu().
2705 drupal_add_feed('rss.xml', variable_get('site_name', 'Drupal') . ' ' . t('RSS'));
2706 $build['pager'] = array(
2707 '#theme' => 'pager',
2708 '#weight' => 5,
2709 );
2710 drupal_set_title('');
2711 }
2712 else {
2713 drupal_set_title(t('Welcome to @site-name', array('@site-name' => variable_get('site_name', 'Drupal'))), PASS_THROUGH);
2714
2715 $default_message = '<p>' . t('No front page content has been created yet.') . '</p>';
2716
2717 $default_links = array();
2718 if (_node_add_access()) {
2719 $default_links[] = l(t('Add new content'), 'node/add');
2720 }
2721 if (!empty($default_links)) {
2722 $default_message .= theme('item_list', array('items' => $default_links));
2723 }
2724
2725 $build['default_message'] = array(
2726 '#markup' => $default_message,
2727 '#prefix' => '<div id="first-time">',
2728 '#suffix' => '</div>',
2729 );
2730 }
2731 return $build;
2732 }
2733
2745 function node_page_view($node) {
2746 // If there is a menu link to this node, the link becomes the last part
2747 // of the active trail, and the link name becomes the page title.
2748 // Thus, we must explicitly set the page title to be the node title.
2749 drupal_set_title($node->title);
2750 $uri = entity_uri('node', $node);
2751 // Set the node path as the canonical URL to prevent duplicate content.
2752 drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);
2753 // Set the non-aliased path as a default shortlink.
2754 drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE);
2755 return node_show($node);
2756 }
2757
2761 function node_update_index() {
2762 $limit = (int)variable_get('search_cron_limit', 100);
2763
2764 $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit, array(), array('target' => 'slave'));
2765
2766 foreach ($result as $node) {
2767 _node_index_node($node);
2768 }
2769 }
2770
2777 function _node_index_node($node) {
2778 $node = node_load($node->nid);
2779
2780 // Save the changed time of the most recent indexed node, for the search
2781 // results half-life calculation.
2782 variable_set('node_cron_last', $node->changed);
2783
2784 // Render the node.
2785 $build = node_view($node, 'search_index');
2786 unset($build['#theme']);
2787 $node->rendered = drupal_render($build);
2788
2789 $text = '<h1>' . check_plain($node->title) . '</h1>' . $node->rendered;
2790
2791 // Fetch extra data normally not visible
2792 $extra = module_invoke_all('node_update_index', $node);
2793 foreach ($extra as $t) {
2794 $text .= $t;
2795 }
2796
2797 // Update index
2798 search_index($node->nid, 'node', $text);
2799 }
2800
2804 function node_form_search_form_alter(&$form, $form_state) {
2805 if (isset($form['module']) && $form['module']['#value'] == 'node' && user_access('use advanced search')) {
2806 // Keyword boxes:
2807 $form['advanced'] = array(
2808 '#type' => 'fieldset',
2809 '#title' => t('Advanced search'),
2810 '#collapsible' => TRUE,
2811 '#collapsed' => TRUE,
2812 '#attributes' => array('class' => array('search-advanced')),
2813 );
2814 $form['advanced']['keywords'] = array(
2815 '#prefix' => '<div class="criterion">',
2816 '#suffix' => '</div>',
2817 );
2818 $form['advanced']['keywords']['or'] = array(
2819 '#type' => 'textfield',
2820 '#title' => t('Containing any of the words'),
2821 '#size' => 30,
2822 '#maxlength' => 255,
2823 );
2824 $form['advanced']['keywords']['phrase'] = array(
2825 '#type' => 'textfield',
2826 '#title' => t('Containing the phrase'),
2827 '#size' => 30,
2828 '#maxlength' => 255,
2829 );
2830 $form['advanced']['keywords']['negative'] = array(
2831 '#type' => 'textfield',
2832 '#title' => t('Containing none of the words'),
2833 '#size' => 30,
2834 '#maxlength' => 255,
2835 );
2836
2837 // Node types:
2838 $types = array_map('check_plain', node_type_get_names());
2839 $form['advanced']['type'] = array(
2840 '#type' => 'checkboxes',
2841 '#title' => t('Only of the type(s)'),
2842 '#prefix' => '<div class="criterion">',
2843 '#suffix' => '</div>',
2844 '#options' => $types,
2845 );
2846 $form['advanced']['submit'] = array(
2847 '#type' => 'submit',
2848 '#value' => t('Advanced search'),
2849 '#prefix' => '<div class="action">',
2850 '#suffix' => '</div>',
2851 '#weight' => 100,
2852 );
2853
2854 // Languages:
2855 $language_options = array();
2856 foreach (language_list('language') as $key => $entity) {
2857 if ($entity->enabled) {
2858 $language_options[$key] = $entity->name;
2859 }
2860 }
2861 if (count($language_options) > 1) {
2862 $form['advanced']['language'] = array(
2863 '#type' => 'checkboxes',
2864 '#title' => t('Languages'),
2865 '#prefix' => '<div class="criterion">',
2866 '#suffix' => '</div>',
2867 '#options' => $language_options,
2868 );
2869 }
2870
2871 $form['#validate'][] = 'node_search_validate';
2872 }
2873 }
2874
2878 function node_search_validate($form, &$form_state) {
2879 // Initialize using any existing basic search keywords.
2880 $keys = $form_state['values']['processed_keys'];
2881
2882 // Insert extra restrictions into the search keywords string.
2883 if (isset($form_state['values']['type']) && is_array($form_state['values']['type'])) {
2884 // Retrieve selected types - Form API sets the value of unselected
2885 // checkboxes to 0.
2886 $form_state['values']['type'] = array_filter($form_state['values']['type']);
2887 if (count($form_state['values']['type'])) {
2888 $keys = search_expression_insert($keys, 'type', implode(',', array_keys($form_state['values']['type'])));
2889 }
2890 }
2891
2892 if (isset($form_state['values']['term']) && is_array($form_state['values']['term']) && count($form_state['values']['term'])) {
2893 $keys = search_expression_insert($keys, 'term', implode(',', $form_state['values']['term']));
2894 }
2895 if (isset($form_state['values']['language']) && is_array($form_state['values']['language'])) {
2896 $languages = array_filter($form_state['values']['language']);
2897 if (count($languages)) {
2898 $keys = search_expression_insert($keys, 'language', implode(',', $languages));
2899 }
2900 }
2901 if ($form_state['values']['or'] != '') {
2902 if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' ' . $form_state['values']['or'], $matches)) {
2903 $keys .= ' ' . implode(' OR ', $matches[1]);
2904 }
2905 }
2906 if ($form_state['values']['negative'] != '') {
2907 if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' ' . $form_state['values']['negative'], $matches)) {
2908 $keys .= ' -' . implode(' -', $matches[1]);
2909 }
2910 }
2911 if ($form_state['values']['phrase'] != '') {
2912 $keys .= ' "' . str_replace('"', ' ', $form_state['values']['phrase']) . '"';
2913 }
2914 if (!empty($keys)) {
2915 form_set_value($form['basic']['processed_keys'], trim($keys), $form_state);
2916 }
2917 }
2918
2981 function node_access($op, $node, $account = NULL) {
2982 $rights = &drupal_static(__FUNCTION__, array());
2983
2984 if (!$node || !in_array($op, array('view', 'update', 'delete', 'create'), TRUE)) {
2985 // If there was no node to check against, or the $op was not one of the
2986 // supported ones, we return access denied.
2987 return FALSE;
2988 }
2989 // If no user object is supplied, the access check is for the current user.
2990 if (empty($account)) {
2991 $account = $GLOBALS['user'];
2992 }
2993
2994 // $node may be either an object or a node type. Since node types cannot be
2995 // an integer, use either nid or type as the static cache id.
2996
2997 $cid = is_object($node) ? $node->nid : $node;
2998
2999 // If we've already checked access for this node, user and op, return from
3000 // cache.
3001 if (isset($rights[$account->uid][$cid][$op])) {
3002 return $rights[$account->uid][$cid][$op];
3003 }
3004
3005 if (user_access('bypass node access', $account)) {
3006 $rights[$account->uid][$cid][$op] = TRUE;
3007 return TRUE;
3008 }
3009 if (!user_access('access content', $account)) {
3010 $rights[$account->uid][$cid][$op] = FALSE;
3011 return FALSE;
3012 }
3013
3014 // We grant access to the node if both of the following conditions are met:
3015 // - No modules say to deny access.
3016 // - At least one module says to grant access.
3017 // If no module specified either allow or deny, we fall back to the
3018 // node_access table.
3019 $access = module_invoke_all('node_access', $node, $op, $account);
3020 if (in_array(NODE_ACCESS_DENY, $access, TRUE)) {
3021 $rights[$account->uid][$cid][$op] = FALSE;
3022 return FALSE;
3023 }
3024 elseif (in_array(NODE_ACCESS_ALLOW, $access, TRUE)) {
3025 $rights[$account->uid][$cid][$op] = TRUE;
3026 return TRUE;
3027 }
3028
3029 // Check if authors can view their own unpublished nodes.
3030 if ($op == 'view' && !$node->status && user_access('view own unpublished content', $account) && $account->uid == $node->uid && $account->uid != 0) {
3031 $rights[$account->uid][$cid][$op] = TRUE;
3032 return TRUE;
3033 }
3034
3035 // If the module did not override the access rights, use those set in the
3036 // node_access table.
3037 if ($op != 'create' && $node->nid) {
3038 if (module_implements('node_grants')) {
3039 $query = db_select('node_access');
3040 $query->addExpression('1');
3041 $query->condition('grant_' . $op, 1, '>=');
3042 $nids = db_or()->condition('nid', $node->nid);
3043 if ($node->status) {
3044 $nids->condition('nid', 0);
3045 }
3046 $query->condition($nids);
3047 $query->range(0, 1);
3048
3049 $grants = db_or();
3050 foreach (node_access_grants($op, $account) as $realm => $gids) {
3051 foreach ($gids as $gid) {
3052 $grants->condition(db_and()
3053 ->condition('gid', $gid)
3054 ->condition('realm', $realm)
3055 );
3056 }
3057 }
3058 if (count($grants) > 0) {
3059 $query->condition($grants);
3060 }
3061 $result = (bool) $query
3062 ->execute()
3063 ->fetchField();
3064 $rights[$account->uid][$cid][$op] = $result;
3065 return $result;
3066 }
3067 elseif (is_object($node) && $op == 'view' && $node->status) {
3068 // If no modules implement hook_node_grants(), the default behavior is to
3069 // allow all users to view published nodes, so reflect that here.
3070 $rights[$account->uid][$cid][$op] = TRUE;
3071 return TRUE;
3072 }
3073 }
3074
3075 return FALSE;
3076 }
3077
3081 function node_node_access($node, $op, $account) {
3082 $type = is_string($node) ? $node : $node->type;
3083
3084 if (in_array($type, node_permissions_get_configured_types())) {
3085 if ($op == 'create' && user_access('create ' . $type . ' content', $account)) {
3086 return NODE_ACCESS_ALLOW;
3087 }
3088
3089 if ($op == 'update') {
3090 if (user_access('edit any ' . $type . ' content', $account) || (user_access('edit own ' . $type . ' content', $account) && ($account->uid == $node->uid))) {
3091 return NODE_ACCESS_ALLOW;
3092 }
3093 }
3094
3095 if ($op == 'delete') {
3096 if (user_access('delete any ' . $type . ' content', $account) || (user_access('delete own ' . $type . ' content', $account) && ($account->uid == $node->uid))) {
3097 return NODE_ACCESS_ALLOW;
3098 }
3099 }
3100 }
3101
3102 return NODE_ACCESS_IGNORE;
3103 }
3104
3114 function node_list_permissions($type) {
3115 $info = node_type_get_type($type);
3116
3117 // Build standard list of node permissions for this type.
3118 $perms = array(
3119 "create $type content" => array(
3120 'title' => t('%type_name: Create new content', array('%type_name' => $info->name)),
3121 ),
3122 "edit own $type content" => array(
3123 'title' => t('%type_name: Edit own content', array('%type_name' => $info->name)),
3124 ),
3125 "edit any $type content" => array(
3126 'title' => t('%type_name: Edit any content', array('%type_name' => $info->name)),
3127 ),
3128 "delete own $type content" => array(
3129 'title' => t('%type_name: Delete own content', array('%type_name' => $info->name)),
3130 ),
3131 "delete any $type content" => array(
3132 'title' => t('%type_name: Delete any content', array('%type_name' => $info->name)),
3133 ),
3134 );
3135
3136 return $perms;
3137 }
3138
3153 function node_permissions_get_configured_types() {
3154
3155 $configured_types = array();
3156
3157 foreach (node_type_get_types() as $type => $info) {
3158 if (variable_get('node_permissions_' . $type, 1)) {
3159 $configured_types[] = $type;
3160 }
3161 }
3162
3163 return $configured_types;
3164 }
3165
3187 function node_access_grants($op, $account = NULL) {
3188
3189 if (!isset($account)) {
3190 $account = $GLOBALS['user'];
3191 }
3192
3193 // Fetch node access grants from other modules.
3194 $grants = module_invoke_all('node_grants', $account, $op);
3195 // Allow modules to alter the assigned grants.
3196 drupal_alter('node_grants', $grants, $account, $op);
3197
3198 return array_merge(array('all' => array(0)), $grants);
3199 }
3200
3223 function node_access_view_all_nodes($account = NULL) {
3224 global $user;
3225 if (!$account) {
3226 $account = $user;
3227 }
3228
3229 // Statically cache results in an array keyed by $account->uid.
3230 $access = &drupal_static(__FUNCTION__);
3231 if (isset($access[$account->uid])) {
3232 return $access[$account->uid];
3233 }
3234
3235 // If no modules implement the node access system, access is always TRUE.
3236 if (!module_implements('node_grants')) {
3237 $access[$account->uid] = TRUE;
3238 }
3239 else {
3240 $query = db_select('node_access');
3241 $query->addExpression('COUNT(*)');
3242 $query
3243 ->condition('nid', 0)
3244 ->condition('grant_view', 1, '>=');
3245
3246 $grants = db_or();
3247 foreach (node_access_grants('view', $account) as $realm => $gids) {
3248 foreach ($gids as $gid) {
3249 $grants->condition(db_and()
3250 ->condition('gid', $gid)
3251 ->condition('realm', $realm)
3252 );
3253 }
3254 }
3255 if (count($grants) > 0 ) {
3256 $query->condition($grants);
3257 }
3258 $access[$account->uid] = $query
3259 ->execute()
3260 ->fetchField();
3261 }
3262
3263 return $access[$account->uid];
3264 }
3265
3266
3275 function node_query_node_access_alter(QueryAlterableInterface $query) {
3276 _node_query_node_access_alter($query, 'node');
3277 }
3278
3286 function node_query_entity_field_access_alter(QueryAlterableInterface $query) {
3287 _node_query_node_access_alter($query, 'entity');
3288 }
3289
3300 function _node_query_node_access_alter($query, $type) {
3301 global $user;
3302
3303 // Read meta-data from query, if provided.
3304 if (!$account = $query->getMetaData('account')) {
3305 $account = $user;
3306 }
3307 if (!$op = $query->getMetaData('op')) {
3308 $op = 'view';
3309 }
3310
3311 // If $account can bypass node access, or there are no node access modules,
3312 // or the operation is 'view' and the $account has a global view grant
3313 // (such as a view grant for node ID 0), we don't need to alter the query.
3314 if (user_access('bypass node access', $account)) {
3315 return;
3316 }
3317 if (!count(module_implements('node_grants'))) {
3318 return;
3319 }
3320 if ($op == 'view' && node_access_view_all_nodes($account)) {
3321 return;
3322 }
3323
3324 $tables = $query->getTables();
3325 $base_table = $query->getMetaData('base_table');
3326 // If no base table is specified explicitly, search for one.
3327 if (!$base_table) {
3328 $fallback = '';
3329 foreach ($tables as $alias => $table_info) {
3330 if (!($table_info instanceof SelectQueryInterface)) {
3331 $table = $table_info['table'];
3332 // If the node table is in the query, it wins immediately.
3333 if ($table == 'node') {
3334 $base_table = $table;
3335 break;
3336 }
3337 // Check whether the table has a foreign key to node.nid. If it does,
3338 // do not run this check again as we found a base table and only node
3339 // can triumph that.
3340 if (!$base_table) {
3341 // The schema is cached.
3342 $schema = drupal_get_schema($table);
3343 if (isset($schema['fields']['nid'])) {
3344 if (isset($schema['foreign keys'])) {
3345 foreach ($schema['foreign keys'] as $relation) {
3346 if ($relation['table'] === 'node' && $relation['columns'] === array('nid' => 'nid')) {
3347 $base_table = $table;
3348 }
3349 }
3350 }
3351 else {
3352 // At least it's a nid. A table with a field called nid is very
3353 // very likely to be a node.nid in a node access query.
3354 $fallback = $table;
3355 }
3356 }
3357 }
3358 }
3359 }
3360 // If there is nothing else, use the fallback.
3361 if (!$base_table) {
3362 if ($fallback) {
3363 watchdog('security', 'Your node listing query is using @fallback as a base table in a query tagged for node access. This might not be secure and might not even work. Specify foreign keys in your schema to node.nid ', array('@fallback' => $fallback), WATCHDOG_WARNING);
3364 $base_table = $fallback;
3365 }
3366 else {
3367 throw new Exception(t('Query tagged for node access but there is no nid. Add foreign keys to node.nid in schema to fix.'));
3368 }
3369 }
3370 }
3371
3372 // Find all instances of the base table being joined -- could appear
3373 // more than once in the query, and could be aliased. Join each one to
3374 // the node_access table.
3375
3376 $grants = node_access_grants($op, $account);
3377 if ($type == 'entity') {
3378 // The original query looked something like:
3379 // @code
3380 // SELECT nid FROM sometable s
3381 // INNER JOIN node_access na ON na.nid = s.nid
3382 // WHERE ($node_access_conditions)
3383 // @endcode
3384 //
3385 // Our query will look like:
3386 // @code
3387 // SELECT entity_type, entity_id
3388 // FROM field_data_something s
3389 // LEFT JOIN node_access na ON s.entity_id = na.nid
3390 // WHERE (entity_type = 'node' AND $node_access_conditions) OR (entity_type <> 'node')
3391 // @endcode
3392 //
3393 // So instead of directly adding to the query object, we need to collect
3394 // all of the node access conditions in a separate db_and() object and
3395 // then add it to the query at the end.
3396 $node_conditions = db_and();
3397 }
3398 foreach ($tables as $nalias => $tableinfo) {
3399 $table = $tableinfo['table'];
3400 if (!($table instanceof SelectQueryInterface) && $table == $base_table) {
3401 // Set the subquery.
3402 $subquery = db_select('node_access', 'na')
3403 ->fields('na', array('nid'));
3404
3405 $grant_conditions = db_or();
3406 // If any grant exists for the specified user, then user has access
3407 // to the node for the specified operation.
3408 foreach ($grants as $realm => $gids) {
3409 foreach ($gids as $gid) {
3410 $grant_conditions->condition(db_and()
3411 ->condition('na.gid', $gid)
3412 ->condition('na.realm', $realm)
3413 );
3414 }
3415 }
3416
3417 // Attach conditions to the subquery for nodes.
3418 if (count($grant_conditions->conditions())) {
3419 $subquery->condition($grant_conditions);
3420 }
3421 $subquery->condition('na.grant_' . $op, 1, '>=');
3422 $field = 'nid';
3423 // Now handle entities.
3424 if ($type == 'entity') {
3425 // Set a common alias for entities.
3426 $base_alias = $nalias;
3427 $field = 'entity_id';
3428 }
3429 $subquery->where("$nalias.$field = na.nid");
3430
3431 // For an entity query, attach the subquery to entity conditions.
3432 if ($type == 'entity') {
3433 $node_conditions->exists($subquery);
3434 }
3435 // Otherwise attach it to the node query itself.
3436 else {
3437 $query->exists($subquery);
3438 }
3439 }
3440 }
3441
3442 if ($type == 'entity' && count($subquery->conditions())) {
3443 // All the node access conditions are only for field values belonging to
3444 // nodes.
3445 $node_conditions->condition("$base_alias.entity_type", 'node');
3446 $or = db_or();
3447 $or->condition($node_conditions);
3448 // If the field value belongs to a non-node entity type then this function
3449 // does not do anything with it.
3450 $or->condition("$base_alias.entity_type", 'node', '<>');
3451 // Add the compiled set of rules to the query.
3452 $query->condition($or);
3453 }
3454
3455 }
3456
3474 function node_access_acquire_grants($node, $delete = TRUE) {
3475 $grants = module_invoke_all('node_access_records', $node);
3476 // Let modules alter the grants.
3477 drupal_alter('node_access_records', $grants, $node);
3478 // If no grants are set and the node is published, then use the default grant.
3479 if (empty($grants) && !empty($node->status)) {
3480 $grants[] = array('realm' => 'all', 'gid' => 0, 'grant_view' => 1, 'grant_update' => 0, 'grant_delete' => 0);
3481 }
3482 else {
3483 // Retain grants by highest priority.
3484 $grant_by_priority = array();
3485 foreach ($grants as $g) {
3486 $grant_by_priority[intval($g['priority'])][] = $g;
3487 }
3488 krsort($grant_by_priority);
3489 $grants = array_shift($grant_by_priority);
3490 }
3491
3492 node_access_write_grants($node, $grants, NULL, $delete);
3493 }
3494
3524 function node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE) {
3525 if ($delete) {
3526 $query = db_delete('node_access')->condition('nid', $node->nid);
3527 if ($realm) {
3528 $query->condition('realm', array($realm, 'all'), 'IN');
3529 }
3530 $query->execute();
3531 }
3532
3533 // Only perform work when node_access modules are active.
3534 if (!empty($grants) && count(module_implements('node_grants'))) {
3535 $query = db_insert('node_access')->fields(array('nid', 'realm', 'gid', 'grant_view', 'grant_update', 'grant_delete'));
3536 foreach ($grants as $grant) {
3537 if ($realm && $realm != $grant['realm']) {
3538 continue;
3539 }
3540 // Only write grants; denies are implicit.
3541 if ($grant['grant_view'] || $grant['grant_update'] || $grant['grant_delete']) {
3542 $grant['nid'] = $node->nid;
3543 $query->values($grant);
3544 }
3545 }
3546 $query->execute();
3547 }
3548 }
3549
3569 function node_access_needs_rebuild($rebuild = NULL) {
3570 if (!isset($rebuild)) {
3571 return variable_get('node_access_needs_rebuild', FALSE);
3572 }
3573 elseif ($rebuild) {
3574 variable_set('node_access_needs_rebuild', TRUE);
3575 }
3576 else {
3577 variable_del('node_access_needs_rebuild');
3578 }
3579 }
3580
3603 function node_access_rebuild($batch_mode = FALSE) {
3604 db_delete('node_access')->execute();
3605 // Only recalculate if the site is using a node_access module.
3606 if (count(module_implements('node_grants'))) {
3607 if ($batch_mode) {
3608 $batch = array(
3609 'title' => t('Rebuilding content access permissions'),
3610 'operations' => array(
3611 array('_node_access_rebuild_batch_operation', array()),
3612 ),
3613 'finished' => '_node_access_rebuild_batch_finished'
3614 );
3615 batch_set($batch);
3616 }
3617 else {
3618 // Try to allocate enough time to rebuild node grants
3619 drupal_set_time_limit(240);
3620
3621 $nids = db_query("SELECT nid FROM {node}")->fetchCol();
3622 foreach ($nids as $nid) {
3623 $node = node_load($nid, NULL, TRUE);
3624 // To preserve database integrity, only acquire grants if the node
3625 // loads successfully.
3626 if (!empty($node)) {
3627 node_access_acquire_grants($node);
3628 }
3629 }
3630 }
3631 }
3632 else {
3633 // Not using any node_access modules. Add the default grant.
3634 db_insert('node_access')
3635 ->fields(array(
3636 'nid' => 0,
3637 'realm' => 'all',
3638 'gid' => 0,
3639 'grant_view' => 1,
3640 'grant_update' => 0,
3641 'grant_delete' => 0,
3642 ))
3643 ->execute();
3644 }
3645
3646 if (!isset($batch)) {
3647 drupal_set_message(t('Content permissions have been rebuilt.'));
3648 node_access_needs_rebuild(FALSE);
3649 cache_clear_all();
3650 }
3651 }
3652
3663 function _node_access_rebuild_batch_operation(&$context) {
3664 if (empty($context['sandbox'])) {
3665 // Initiate multistep processing.
3666 $context['sandbox']['progress'] = 0;
3667 $context['sandbox']['current_node'] = 0;
3668 $context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT nid) FROM {node}')->fetchField();
3669 }
3670
3671 // Process the next 20 nodes.
3672 $limit = 20;
3673 $nids = db_query_range("SELECT nid FROM {node} WHERE nid > :nid ORDER BY nid ASC", 0, $limit, array(':nid' => $context['sandbox']['current_node']))->fetchCol();
3674 $nodes = node_load_multiple($nids, array(), TRUE);
3675 foreach ($nodes as $nid => $node) {
3676 // To preserve database integrity, only acquire grants if the node
3677 // loads successfully.
3678 if (!empty($node)) {
3679 node_access_acquire_grants($node);
3680 }
3681 $context['sandbox']['progress']++;
3682 $context['sandbox']['current_node'] = $nid;
3683 }
3684
3685 // Multistep processing : report progress.
3686 if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
3687 $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
3688 }
3689 }
3690
3701 function _node_access_rebuild_batch_finished($success, $results, $operations) {
3702 if ($success) {
3703 drupal_set_message(t('The content access permissions have been rebuilt.'));
3704 node_access_needs_rebuild(FALSE);
3705 }
3706 else {
3707 drupal_set_message(t('The content access permissions have not been properly rebuilt.'), 'error');
3708 }
3709 cache_clear_all();
3710 }
3711
3725 function node_content_form($node, $form_state) {
3726 // It is impossible to define a content type without implementing hook_form()
3727 // @todo: remove this requirement.
3728 $form = array();
3729 $type = node_type_get_type($node);
3730
3731 if ($type->has_title) {
3732 $form['title'] = array(
3733 '#type' => 'textfield',
3734 '#title' => check_plain($type->title_label),
3735 '#required' => TRUE,
3736 '#default_value' => $node->title,
3737 '#maxlength' => 255,
3738 '#weight' => -5,
3739 );
3740 }
3741
3742 return $form;
3743 }
3744
3754 function node_forms() {
3755 $forms = array();
3756 if ($types = node_type_get_types()) {
3757 foreach (array_keys($types) as $type) {
3758 $forms[$type . '_node_form']['callback'] = 'node_form';
3759 }
3760 }
3761 return $forms;
3762 }
3763
3767 function node_action_info() {
3768 return array(
3769 'node_publish_action' => array(
3770 'type' => 'node',
3771 'label' => t('Publish content'),
3772 'configurable' => FALSE,
3773 'behavior' => array('changes_property'),
3774 'triggers' => array('node_presave', 'comment_insert', 'comment_update', 'comment_delete'),
3775 ),
3776 'node_unpublish_action' => array(
3777 'type' => 'node',
3778 'label' => t('Unpublish content'),
3779 'configurable' => FALSE,
3780 'behavior' => array('changes_property'),
3781 'triggers' => array('node_presave', 'comment_insert', 'comment_update', 'comment_delete'),
3782 ),
3783 'node_make_sticky_action' => array(
3784 'type' => 'node',
3785 'label' => t('Make content sticky'),
3786 'configurable' => FALSE,
3787 'behavior' => array('changes_property'),
3788 'triggers' => array('node_presave', 'comment_insert', 'comment_update', 'comment_delete'),
3789 ),
3790 'node_make_unsticky_action' => array(
3791 'type' => 'node',
3792 'label' => t('Make content unsticky'),
3793 'configurable' => FALSE,
3794 'behavior' => array('changes_property'),
3795 'triggers' => array('node_presave', 'comment_insert', 'comment_update', 'comment_delete'),
3796 ),
3797 'node_promote_action' => array(
3798 'type' => 'node',
3799 'label' => t('Promote content to front page'),
3800 'configurable' => FALSE,
3801 'behavior' => array('changes_property'),
3802 'triggers' => array('node_presave', 'comment_insert', 'comment_update', 'comment_delete'),
3803 ),
3804 'node_unpromote_action' => array(
3805 'type' => 'node',
3806 'label' => t('Remove content from front page'),
3807 'configurable' => FALSE,
3808 'behavior' => array('changes_property'),
3809 'triggers' => array('node_presave', 'comment_insert', 'comment_update', 'comment_delete'),
3810 ),
3811 'node_assign_owner_action' => array(
3812 'type' => 'node',
3813 'label' => t('Change the author of content'),
3814 'configurable' => TRUE,
3815 'behavior' => array('changes_property'),
3816 'triggers' => array('node_presave', 'comment_insert', 'comment_update', 'comment_delete'),
3817 ),
3818 'node_save_action' => array(
3819 'type' => 'node',
3820 'label' => t('Save content'),
3821 'configurable' => FALSE,
3822 'triggers' => array('comment_insert', 'comment_update', 'comment_delete'),
3823 ),
3824 'node_unpublish_by_keyword_action' => array(
3825 'type' => 'node',
3826 'label' => t('Unpublish content containing keyword(s)'),
3827 'configurable' => TRUE,
3828 'triggers' => array('node_presave', 'node_insert', 'node_update'),
3829 ),
3830 );
3831 }
3832
3844 function node_publish_action($node, $context = array()) {
3845 $node->status = NODE_PUBLISHED;
3846 watchdog('action', 'Set @type %title to published.', array('@type' => node_type_get_name($node), '%title' => $node->title));
3847 }
3848
3860 function node_unpublish_action($node, $context = array()) {
3861 $node->status = NODE_NOT_PUBLISHED;
3862 watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_type_get_name($node), '%title' => $node->title));
3863 }
3864
3876 function node_make_sticky_action($node, $context = array()) {
3877 $node->sticky = NODE_STICKY;
3878 watchdog('action', 'Set @type %title to sticky.', array('@type' => node_type_get_name($node), '%title' => $node->title));
3879 }
3880
3892 function node_make_unsticky_action($node, $context = array()) {
3893 $node->sticky = NODE_NOT_STICKY;
3894 watchdog('action', 'Set @type %title to unsticky.', array('@type' => node_type_get_name($node), '%title' => $node->title));
3895 }
3896
3908 function node_promote_action($node, $context = array()) {
3909 $node->promote = NODE_PROMOTED;
3910 watchdog('action', 'Promoted @type %title to front page.', array('@type' => node_type_get_name($node), '%title' => $node->title));
3911 }
3912
3924 function node_unpromote_action($node, $context = array()) {
3925 $node->promote = NODE_NOT_PROMOTED;
3926 watchdog('action', 'Removed @type %title from front page.', array('@type' => node_type_get_name($node), '%title' => $node->title));
3927 }
3928
3937 function node_save_action($node) {
3938 node_save($node);
3939 watchdog('action', 'Saved @type %title', array('@type' => node_type_get_name($node), '%title' => $node->title));
3940 }
3941
3956 function node_assign_owner_action($node, $context) {
3957 $node->uid = $context['owner_uid'];
3958 $owner_name = db_query("SELECT name FROM {users} WHERE uid = :uid", array(':uid' => $context['owner_uid']))->fetchField();
3959 watchdog('action', 'Changed owner of @type %title to uid %name.', array('@type' => node_type_get_name($node), '%title' => $node->title, '%name' => $owner_name));
3960 }
3961
3975 function node_assign_owner_action_form($context) {
3976 $description = t('The username of the user to which you would like to assign ownership.');
3977 $count = db_query("SELECT COUNT(*) FROM {users}")->fetchField();
3978 $owner_name = '';
3979 if (isset($context['owner_uid'])) {
3980 $owner_name = db_query("SELECT name FROM {users} WHERE uid = :uid", array(':uid' => $context['owner_uid']))->fetchField();
3981 }
3982
3983 // Use dropdown for fewer than 200 users; textbox for more than that.
3984 if (intval($count) < 200) {
3985 $options = array();
3986 $result = db_query("SELECT uid, name FROM {users} WHERE uid > 0 ORDER BY name");
3987 foreach ($result as $data) {
3988 $options[$data->name] = $data->name;
3989 }
3990 $form['owner_name'] = array(
3991 '#type' => 'select',
3992 '#title' => t('Username'),
3993 '#default_value' => $owner_name,
3994 '#options' => $options,
3995 '#description' => $description,
3996 );
3997 }
3998 else {
3999 $form['owner_name'] = array(
4000 '#type' => 'textfield',
4001 '#title' => t('Username'),
4002 '#default_value' => $owner_name,
4003 '#autocomplete_path' => 'user/autocomplete',
4004 '#size' => '6',
4005 '#maxlength' => '60',
4006 '#description' => $description,
4007 );
4008 }
4009 return $form;
4010 }
4011
4017 function node_assign_owner_action_validate($form, $form_state) {
4018 $exists = (bool) db_query_range('SELECT 1 FROM {users} WHERE name = :name', 0, 1, array(':name' => $form_state['values']['owner_name']))->fetchField();
4019 if (!$exists) {
4020 form_set_error('owner_name', t('Enter a valid username.'));
4021 }
4022 }
4023
4029 function node_assign_owner_action_submit($form, $form_state) {
4030 // Username can change, so we need to store the ID, not the username.
4031 $uid = db_query('SELECT uid from {users} WHERE name = :name', array(':name' => $form_state['values']['owner_name']))->fetchField();
4032 return array('owner_uid' => $uid);
4033 }
4034
4046 function node_unpublish_by_keyword_action_form($context) {
4047 $form['keywords'] = array(
4048 '#title' => t('Keywords'),
4049 '#type' => 'textarea',
4050 '#description' => t('The content will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'),
4051 '#default_value' => isset($context['keywords']) ? drupal_implode_tags($context['keywords']) : '',
4052 );
4053 return $form;
4054 }
4055
4059 function node_unpublish_by_keyword_action_submit($form, $form_state) {
4060 return array('keywords' => drupal_explode_tags($form_state['values']['keywords']));
4061 }
4062
4075 function node_unpublish_by_keyword_action($node, $context) {
4076 foreach ($context['keywords'] as $keyword) {
4077 $elements = node_view(clone $node);
4078 if (strpos(drupal_render($elements), $keyword) !== FALSE || strpos($node->title, $keyword) !== FALSE) {
4079 $node->status = NODE_NOT_PUBLISHED;
4080 watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_type_get_name($node), '%title' => $node->title));
4081 break;
4082 }
4083 }
4084 }
4085
4089 function node_requirements($phase) {
4090 $requirements = array();
4091 if ($phase === 'runtime') {
4092 // Only show rebuild button if there are either 0, or 2 or more, rows
4093 // in the {node_access} table, or if there are modules that
4094 // implement hook_node_grants().
4095 $grant_count = db_query('SELECT COUNT(*) FROM {node_access}')->fetchField();
4096 if ($grant_count != 1 || count(module_implements('node_grants')) > 0) {
4097 $value = format_plural($grant_count, 'One permission in use', '@count permissions in use', array('@count' => $grant_count));
4098 }
4099 else {
4100 $value = t('Disabled');
4101 }
4102 $description = t('If the site is experiencing problems with permissions to content, you may have to rebuild the permissions cache. Rebuilding will remove all privileges to content and replace them with permissions based on the current modules and settings. Rebuilding may take some time if there is a lot of content or complex permission settings. After rebuilding has completed, content will automatically use the new permissions.');
4103
4104 $requirements['node_access'] = array(
4105 'title' => t('Node Access Permissions'),
4106 'value' => $value,
4107 'description' => $description . ' ' . l(t('Rebuild permissions'), 'admin/reports/status/rebuild'),
4108 );
4109 }
4110 return $requirements;
4111 }
4112
4116 function node_modules_enabled($modules) {
4117 // Check if any of the newly enabled modules require the node_access table to
4118 // be rebuilt.
4119 if (!node_access_needs_rebuild() && array_intersect($modules, module_implements('node_grants'))) {
4120 node_access_needs_rebuild(TRUE);
4121 }
4122 }
4123
4130 class NodeController extends DrupalDefaultEntityController {
4131
4132 protected function attachLoad(&$nodes, $revision_id = FALSE) {
4133 // Create an array of nodes for each content type and pass this to the
4134 // object type specific callback.
4135 $typed_nodes = array();
4136 foreach ($nodes as $id => $entity) {
4137 $typed_nodes[$entity->type][$id] = $entity;
4138 }
4139
4140 // Call object type specific callbacks on each typed array of nodes.
4141 foreach ($typed_nodes as $node_type => $nodes_of_type) {
4142 if (node_hook($node_type, 'load')) {
4143 $function = node_type_get_base($node_type) . '_load';
4144 $function($nodes_of_type);
4145 }
4146 }
4147 // Besides the list of nodes, pass one additional argument to
4148 // hook_node_load(), containing a list of node types that were loaded.
4149 $argument = array_keys($typed_nodes);
4150 $this->hookLoadArguments = array($argument);
4151 parent::attachLoad($nodes, $revision_id);
4152 }
4153
4154 protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
4155 // Ensure that uid is taken from the {node} table,
4156 // alias timestamp to revision_timestamp and add revision_uid.
4157 $query = parent::buildQuery($ids, $conditions, $revision_id);
4158 $fields =& $query->getFields();
4159 unset($fields['timestamp']);
4160 $query->addField('revision', 'timestamp', 'revision_timestamp');
4161 $fields['uid']['table'] = 'base';
4162 $query->addField('revision', 'uid', 'revision_uid');
4163 return $query;
4164 }
4165 }
4166
4170 function node_file_download_access($field, $entity_type, $entity) {
4171 if ($entity_type == 'node') {
4172 return node_access('view', $entity);
4173 }
4174 }
_node_types_build
_node_types_build($rebuild=FALSE)
Definition: node.module:705
node_revision_delete
node_revision_delete($revision_id)
Definition: node.module:1296
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
node_block_view
node_block_view($delta= '')
Definition: node.module:2258
_node_revision_access
_node_revision_access($node, $op= 'view', $account=NULL)
Definition: node.module:1903
node_type_save
node_type_save($info)
Definition: node.module:525
node_form_block_add_block_form_alter
node_form_block_add_block_form_alter(&$form, &$form_state)
Definition: node.module:2419
node_user_delete
node_user_delete($account)
Definition: node.module:1838
node_feed
node_feed($nids=FALSE, $channel=array())
Definition: node.module:2581
field_create_instance
field_create_instance($instance)
Definition: field.crud.inc:473
theme_node_recent_content
theme_node_recent_content($variables)
Definition: node.module:2399
node_query_entity_field_access_alter
node_query_entity_field_access_alter(QueryAlterableInterface $query)
Definition: node.module:3286
node_rdf_mapping
node_rdf_mapping()
Definition: node.module:838
watchdog_exception
watchdog_exception($type, Exception $exception, $message=NULL, $variables=array(), $severity=WATCHDOG_ERROR, $link=NULL)
Definition: bootstrap.inc:1654
node_ranking
node_ranking()
Definition: node.module:1765
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
node_page_title
node_page_title($node)
Definition: node.module:2205
node_validate
node_validate($node, $form, &$form_state)
Definition: node.module:1010
$op
$op
Definition: update.php:404
node_unpromote_action
node_unpromote_action($node, $context=array())
Definition: node.module:3924
QueryAlterableInterface
Definition: query.inc:166
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
node_type_load
node_type_load($name)
Definition: node.module:489
node_search_status
node_search_status()
Definition: node.module:1669
format_rss_channel
format_rss_channel($title, $link, $description, $items, $langcode=NULL, $args=array())
Definition: common.inc:1685
node_query_node_access_alter
node_query_node_access_alter(QueryAlterableInterface $query)
Definition: node.module:3275
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
menu_get_item
menu_get_item($path=NULL, $router_item=NULL)
Definition: menu.inc:447
MARK_READ
const MARK_READ
Definition: theme.inc:21
entity_load
entity_load($entity_type, $ids=FALSE, $conditions=array(), $reset=FALSE)
Definition: common.inc:7800
l
l($text, $path, array $options=array())
Definition: common.inc:2432
node_assign_owner_action_form
node_assign_owner_action_form($context)
Definition: node.module:3975
NODE_ACCESS_ALLOW
const NODE_ACCESS_ALLOW
Definition: node.module:50
node_last_viewed
node_last_viewed($nid)
Definition: node.module:328
node_type_delete
node_type_delete($type)
Definition: node.module:651
node_user_cancel
node_user_cancel($edit, $account, $method)
Definition: node.module:1800
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
SAVED_UPDATED
const SAVED_UPDATED
Definition: common.inc:50
NODE_ACCESS_DENY
const NODE_ACCESS_DENY
Definition: node.module:55
drupal_set_time_limit
drupal_set_time_limit($time_limit)
Definition: common.inc:2786
node_revision_list
node_revision_list($node)
Definition: node.module:2231
node_unpublish_by_keyword_action
node_unpublish_by_keyword_action($node, $context)
Definition: node.module:4075
$module
print $module
Definition: search-results.tpl.php:28
theme_node_recent_block
theme_node_recent_block($variables)
Definition: node.module:2358
node_block_info
node_block_info()
Definition: node.module:2244
node_uri
node_uri($node)
Definition: node.module:249
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
node_access_rebuild
node_access_rebuild($batch_mode=FALSE)
Definition: node.module:3603
template_preprocess_node
template_preprocess_node(&$variables)
Definition: node.module:1506
node_unpublish_by_keyword_action_submit
node_unpublish_by_keyword_action_submit($form, $form_state)
Definition: node.module:4059
field_attach_delete_revision
field_attach_delete_revision($entity_type, $entity)
Definition: field.attach.inc:1082
variable_del
variable_del($name)
Definition: bootstrap.inc:996
format_rss_item
format_rss_item($title, $link, $description, $args=array())
Definition: common.inc:1710
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
$results
print $results
Definition: poll-results.tpl.php:23
node_search_info
node_search_info()
Definition: node.module:1642
node_save
node_save($node)
Definition: node.module:1076
node_type_get_type
node_type_get_type($node)
Definition: node.module:410
NODE_PROMOTED
const NODE_PROMOTED
Definition: node.module:27
Exception
NodeController::attachLoad
attachLoad(&$nodes, $revision_id=FALSE)
Definition: node.module:4132
node_form_block_admin_configure_alter
node_form_block_admin_configure_alter(&$form, &$form_state)
Definition: node.module:2430
$header
print $header
Definition: forum-topic-list.tpl.php:42
field_attach_prepare_view
field_attach_prepare_view($entity_type, $entities, $view_mode, $langcode=NULL, $options=array())
Definition: field.attach.inc:1133
node_submit
node_submit($node)
Definition: node.module:1051
SelectQueryExtender
Definition: select.inc:535
node_type_cache_reset
node_type_cache_reset()
Definition: node.module:783
node_type_get_base
node_type_get_base($node)
Definition: node.module:431
drupal_attributes
drupal_attributes(array $attributes=array())
Definition: common.inc:2377
node_search_admin
node_search_admin()
Definition: node.module:1678
field_attach_presave
field_attach_presave($entity_type, $entity)
Definition: field.attach.inc:913
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
node_admin_paths
node_admin_paths()
Definition: node.module:258
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
module_exists
module_exists($module)
Definition: module.inc:274
node_is_page
node_is_page($node)
Definition: node.module:1487
drupal_add_html_head_link
drupal_add_html_head_link($attributes, $header=FALSE)
Definition: common.inc:2834
print
print
Definition: php-2.php:2
node_field_extra_fields
node_field_extra_fields()
Definition: node.module:625
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
node_form_block_custom_block_delete_alter
node_form_block_custom_block_delete_alter(&$form, &$form_state)
Definition: node.module:2481
node_menu_local_tasks_alter
node_menu_local_tasks_alter(&$data, $router_item, $root_path)
Definition: node.module:2166
_node_index_node
_node_index_node($node)
Definition: node.module:2777
node_type_get_name
node_type_get_name($node)
Definition: node.module:459
entity_uri
entity_uri($entity_type, $entity)
Definition: common.inc:7902
db_or
db_or()
Definition: database.inc:2662
NodeController::buildQuery
buildQuery($ids, $conditions=array(), $revision_id=FALSE)
Definition: node.module:4154
node_block_list_alter
node_block_list_alter(&$blocks)
Definition: node.module:2514
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
node_cron
node_cron()
Definition: node.module:158
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
field_create_field
field_create_field($field)
Definition: field.crud.inc:56
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
node_assign_owner_action_validate
node_assign_owner_action_validate($form, $form_state)
Definition: node.module:4017
node_file_download_access
node_file_download_access($field, $entity_type, $entity)
Definition: node.module:4170
node_content_form
node_content_form($node, $form_state)
Definition: node.module:3725
NODE_PUBLISHED
const NODE_PUBLISHED
Definition: node.module:17
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
module_hook
module_hook($module, $hook)
Definition: module.inc:659
drupal_get_schema
drupal_get_schema($table=NULL, $rebuild=FALSE)
Definition: bootstrap.inc:2940
node_type_get_types
node_type_get_types()
Definition: node.module:393
NodeController
Definition: node.module:4130
node_block_configure
node_block_configure($delta= '')
Definition: node.module:2286
node_type_set_defaults
node_type_set_defaults($info=array())
Definition: node.module:805
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
_node_extract_type
_node_extract_type($node)
Definition: node.module:378
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
node_action_info
node_action_info()
Definition: node.module:3767
batch_set
batch_set($batch_definition)
Definition: form.inc:4381
NODE_NOT_STICKY
const NODE_NOT_STICKY
Definition: node.module:32
$info
$info
Definition: color.inc:6
node_mark
node_mark($nid, $timestamp)
Definition: node.module:350
node_add_body_field
node_add_body_field($type, $label= 'Body')
Definition: node.module:586
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
node_search_execute
node_search_execute($keys=NULL, $conditions=NULL)
Definition: node.module:1705
MARK_UPDATED
const MARK_UPDATED
Definition: theme.inc:31
_node_rankings
_node_rankings(SelectQueryExtender $query)
Definition: node.module:1623
NODE_NOT_PUBLISHED
const NODE_NOT_PUBLISHED
Definition: node.module:12
node_help
node_help($path, $arg)
Definition: node.module:65
node_permission
node_permission()
Definition: node.module:1571
node_types_rebuild
node_types_rebuild()
Definition: node.module:475
node_access_view_all_nodes
node_access_view_all_nodes($account=NULL)
Definition: node.module:3223
node_access_write_grants
node_access_write_grants($node, $grants, $realm=NULL, $delete=TRUE)
Definition: node.module:3524
_node_access_rebuild_batch_finished
_node_access_rebuild_batch_finished($success, $results, $operations)
Definition: node.module:3701
entity_load_unchanged
entity_load_unchanged($entity_type, $id)
Definition: common.inc:7823
node_save_action
node_save_action($node)
Definition: node.module:3937
language_list
language_list($field= 'language')
Definition: bootstrap.inc:2723
search_index
search_index($sid, $module, $text)
Definition: search.module:552
node_assign_owner_action
node_assign_owner_action($node, $context)
Definition: node.module:3956
search_reindex
search_reindex($sid=NULL, $module=NULL, $reindex=FALSE)
Definition: search.module:308
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
node_invoke
node_invoke($node, $hook, $a2=NULL, $a3=NULL, $a4=NULL)
Definition: node.module:911
drupal_add_http_header
drupal_add_http_header($name, $value, $append=FALSE)
Definition: bootstrap.inc:1129
$value
print $value
Definition: user-profile-item.tpl.php:26
node_page_default
node_page_default()
Definition: node.module:2687
node_make_sticky_action
node_make_sticky_action($node, $context=array())
Definition: node.module:3876
SelectQueryInterface
Definition: select.inc:39
NODE_NOT_PROMOTED
const NODE_NOT_PROMOTED
Definition: node.module:22
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
entity_language
entity_language($entity_type, $entity)
Definition: common.inc:7967
node_access_grants
node_access_grants($op, $account=NULL)
Definition: node.module:3187
db_ignore_slave
db_ignore_slave()
Definition: database.inc:3027
node_node_access
node_node_access($node, $op, $account)
Definition: node.module:3081
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
SelectQueryExtender\getTables
& getTables()
Definition: select.inc:690
node_modules_uninstalled
node_modules_uninstalled($modules)
Definition: node.module:2502
node_delete
node_delete($nid)
Definition: node.module:1233
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
drupal_implode_tags
drupal_implode_tags($tags)
Definition: common.inc:7434
_node_save_revision
_node_save_revision($node, $uid, $update=NULL)
Definition: node.module:1214
MARK_NEW
const MARK_NEW
Definition: theme.inc:26
$output
$output
Definition: authorize.php:93
node_theme
node_theme()
Definition: node.module:125
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
user_access
user_access($string, $account=NULL)
Definition: user.module:794
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
field_attach_preprocess
field_attach_preprocess($entity_type, $entity, $element, &$variables)
Definition: field.attach.inc:1272
RDF_DEFAULT_BUNDLE
const RDF_DEFAULT_BUNDLE
Definition: rdf.module:74
node_form_block_custom_block_delete_submit
node_form_block_custom_block_delete_submit($form, &$form_state)
Definition: node.module:2490
theme_get_setting
theme_get_setting($setting_name, $theme=NULL)
Definition: theme.inc:1401
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
drupal_add_feed
drupal_add_feed($url=NULL, $title= '')
Definition: common.inc:368
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
node_publish_action
node_publish_action($node, $context=array())
Definition: node.module:3844
node_field_display_node_alter
node_field_display_node_alter(&$display, $context)
Definition: node.module:239
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
node_unpublish_action
node_unpublish_action($node, $context=array())
Definition: node.module:3860
node_search_reset
node_search_reset()
Definition: node.module:1659
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
node_menu
node_menu()
Definition: node.module:1982
entity_prepare_view
entity_prepare_view($entity_type, $entities, $langcode=NULL)
Definition: common.inc:7866
node_access_acquire_grants
node_access_acquire_grants($node, $delete=TRUE)
Definition: node.module:3474
node_hook
node_hook($node, $hook)
Definition: node.module:893
node_last_changed
node_last_changed($nid)
Definition: node.module:2218
SAVED_NEW
const SAVED_NEW
Definition: common.inc:45
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
node_object_prepare
node_object_prepare($node)
Definition: node.module:978
node_entity_info
node_entity_info()
Definition: node.module:167
db_transaction
db_transaction($name=NULL, array $options=array())
Definition: database.inc:2535
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
node_access
node_access($op, $node, $account=NULL)
Definition: node.module:2981
_node_query_node_access_alter
_node_query_node_access_alter($query, $type)
Definition: node.module:3300
node_type_update_nodes
node_type_update_nodes($old_type, $type)
Definition: node.module:674
entity_get_controller
entity_get_controller($entity_type)
Definition: common.inc:7832
node_type_get_names
node_type_get_names()
Definition: node.module:446
node_make_unsticky_action
node_make_unsticky_action($node, $context=array())
Definition: node.module:3892
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
node_list_permissions
node_list_permissions($type)
Definition: node.module:3114
field_attach_rename_bundle
field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new)
Definition: field.attach.inc:1360
field_attach_view
field_attach_view($entity_type, $entity, $view_mode, $langcode=NULL, $options=array())
Definition: field.attach.inc:1216
node_show
node_show($node, $message=FALSE)
Definition: node.module:1464
drupal_explode_tags
drupal_explode_tags($tags)
Definition: common.inc:7408
node_promote_action
node_promote_action($node, $context=array())
Definition: node.module:3908
node_search_access
node_search_access()
Definition: node.module:1652
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
node_form_block_admin_configure_submit
node_form_block_admin_configure_submit($form, &$form_state)
Definition: node.module:2458
DRUPAL_NO_CACHE
const DRUPAL_NO_CACHE
Definition: common.inc:127
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
DrupalDefaultEntityController
Definition: entity.inc:46
field_attach_delete_bundle
field_attach_delete_bundle($entity_type, $bundle)
Definition: field.attach.inc:1394
MENU_CONTEXT_INLINE
const MENU_CONTEXT_INLINE
Definition: menu.inc:214
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
node_modules_enabled
node_modules_enabled($modules)
Definition: node.module:4116
node_tag_new
node_tag_new($node)
Definition: node.module:305
$row
$row
Definition: block-admin-display-form.tpl.php:47
user_load_by_name
user_load_by_name($name)
Definition: user.module:397
node_search_validate
node_search_validate($form, &$form_state)
Definition: node.module:2878
node_block_save
node_block_save($delta= '', $edit=array())
Definition: node.module:2302
NODE_ACCESS_IGNORE
const NODE_ACCESS_IGNORE
Definition: node.module:60
node_assign_owner_action_submit
node_assign_owner_action_submit($form, $form_state)
Definition: node.module:4029
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
node_type_page_title
node_type_page_title($type)
Definition: node.module:2190
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
node_page_view
node_page_view($node)
Definition: node.module:2745
node_access_needs_rebuild
node_access_needs_rebuild($rebuild=NULL)
Definition: node.module:3569
node_load_multiple
node_load_multiple($nids=array(), $conditions=array(), $reset=FALSE)
Definition: node.module:945
field_attach_create_bundle
field_attach_create_bundle($entity_type, $bundle)
Definition: field.attach.inc:1342
node_view_multiple
node_view_multiple($nodes, $view_mode= 'teaser', $weight=0, $langcode=NULL)
Definition: node.module:2666
node_delete_multiple
node_delete_multiple($nids)
Definition: node.module:1243
node_form_search_form_alter
node_form_search_form_alter(&$form, $form_state)
Definition: node.module:2804
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
NODE_STICKY
const NODE_STICKY
Definition: node.module:37
node_requirements
node_requirements($phase)
Definition: node.module:4089
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
theme_node_search_admin
theme_node_search_admin($variables)
Definition: node.module:1868
node_unpublish_by_keyword_action_form
node_unpublish_by_keyword_action_form($context)
Definition: node.module:4046
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
node_build_content
node_build_content($node, $view_mode= 'full', $langcode=NULL)
Definition: node.module:1391
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
node_permissions_get_configured_types
node_permissions_get_configured_types()
Definition: node.module:3153
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
_node_access_rebuild_batch_operation
_node_access_rebuild_batch_operation(&$context)
Definition: node.module:3663
node_get_recent
node_get_recent($number=10)
Definition: node.module:2318
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
node_mass_update
node_mass_update($nodes, $updates)
Definition: node.admin.inc:279
menu_get_object
menu_get_object($type= 'node', $position=1, $path=NULL)
Definition: menu.inc:971
search_excerpt
search_excerpt($keys, $text)
Definition: search.module:1125
_node_add_access
_node_add_access()
Definition: node.module:1963
SelectQueryExtender\addJoin
addJoin($type, $table, $alias=NULL, $condition=NULL, $arguments=array())
Definition: select.inc:760
search_expression_insert
search_expression_insert($expression, $option, $value=NULL)
Definition: search.module:898
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
$links
print $links
Definition: poll-results--block.tpl.php:28
node_view
node_view($node, $view_mode= 'full', $langcode=NULL)
Definition: node.module:1329
MENU_CONTEXT_PAGE
const MENU_CONTEXT_PAGE
Definition: menu.inc:209
NODE_NEW_LIMIT
const NODE_NEW_LIMIT
Definition: node.module:45
field_attach_delete
field_attach_delete($entity_type, $entity)
Definition: field.attach.inc:1045
drupal_html_class
drupal_html_class($class)
Definition: common.inc:3841
node_update_index
node_update_index()
Definition: node.module:2761
node_forms
node_forms()
Definition: node.module:3754
db_and
db_and()
Definition: database.inc:2671
field_info_instance
field_info_instance($entity_type, $field_name, $bundle_name)
Definition: field.info.inc:623
node_title_list
node_title_list($result, $title=NULL)
Definition: node.module:288
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/tracker/tracker.module Source File

  • modules
  • tracker
tracker.module
Go to the documentation of this file.
1 <?php
2
11 function tracker_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#tracker':
14 $output = '<h3>' . t('About') . '</h3>';
15 $output .= '<p>' . t('The Tracker module displays the most recently added and updated content on your site, and allows you to follow new content created by each user. This module has no configuration options. For more information, see the online handbook entry for <a href="@tracker">Tracker module</a>.', array('@tracker' => 'http://drupal.org/documentation/modules/tracker/')) . '</p>';
16 $output .= '<h3>' . t('Uses') . '</h3>';
17 $output .= '<dl>';
18 $output .= '<dt>' . t('Navigation') . '</dt>';
19 $output .= '<dd>' . t('The Tracker module adds a new menu item to the Navigation menu, called <em>Recent content</em>. You can configure menu items via the <a href="@menus">Menus administration page</a>.', array('@menus' => url('admin/structure/menu'))) . '</dd>';
20 $output .= '<dt>' . t('Tracking new and updated site content') . '</dt>';
21 $output .= '<dd>' . t("The <a href='@recent'>Recent content</a> page shows new and updated content in reverse chronological order, listing the content type, title, author's name, number of comments, and time of last update. Content is considered updated when changes occur in the text, or when new comments are added. The <em>My recent content</em> tab limits the list to the currently logged-in user.", array('@recent' => url('tracker'))) . '</dd>';
22 $output .= '<dt>' . t('Tracking user-specific content') . '</dt>';
23 $output .= '<dd>' . t("To follow a specific user's new and updated content, select the <em>Track</em> tab from the user's profile page.") . '</dd>';
24 $output .= '</dl>';
25 return $output;
26 }
27 }
28
32 function tracker_menu() {
33 $items['tracker'] = array(
34 'title' => 'Recent content',
35 'page callback' => 'tracker_page',
36 'access arguments' => array('access content'),
37 'weight' => 1,
38 'file' => 'tracker.pages.inc',
39 );
40 $items['tracker/all'] = array(
41 'title' => 'All recent content',
42 'type' => MENU_DEFAULT_LOCAL_TASK,
43 );
44 $items['tracker/%user_uid_optional'] = array(
45 'title' => 'My recent content',
46 'page callback' => 'tracker_page',
47 'access callback' => '_tracker_myrecent_access',
48 'access arguments' => array(1),
49 'page arguments' => array(1),
50 'type' => MENU_LOCAL_TASK,
51 'file' => 'tracker.pages.inc',
52 );
53
54 $items['user/%user/track'] = array(
55 'title' => 'Track',
56 'page callback' => 'tracker_page',
57 'page arguments' => array(1, TRUE),
58 'access callback' => '_tracker_user_access',
59 'access arguments' => array(1),
60 'type' => MENU_LOCAL_TASK,
61 'file' => 'tracker.pages.inc',
62 );
63 $items['user/%user/track/content'] = array(
64 'title' => 'Track content',
65 'type' => MENU_DEFAULT_LOCAL_TASK,
66 );
67
68 return $items;
69 }
70
79 function tracker_cron() {
80 $max_nid = variable_get('tracker_index_nid', 0);
81 $batch_size = variable_get('tracker_batch_size', 1000);
82 if ($max_nid > 0) {
83 $last_nid = FALSE;
84 $result = db_query_range('SELECT nid, uid, status FROM {node} WHERE nid <= :max_nid ORDER BY nid DESC', 0, $batch_size, array(':max_nid' => $max_nid), array('target' => 'slave'));
85
86 $count = 0;
87
88 foreach ($result as $row) {
89 // Calculate the changed timestamp for this node.
90 $changed = _tracker_calculate_changed($row->nid);
91
92 // Remove existing data for this node.
93 db_delete('tracker_node')
94 ->condition('nid', $row->nid)
95 ->execute();
96 db_delete('tracker_user')
97 ->condition('nid', $row->nid)
98 ->execute();
99
100 // Insert the node-level data.
101 db_insert('tracker_node')
102 ->fields(array(
103 'nid' => $row->nid,
104 'published' => $row->status,
105 'changed' => $changed,
106 ))
107 ->execute();
108
109 // Insert the user-level data for the node's author.
110 db_insert('tracker_user')
111 ->fields(array(
112 'nid' => $row->nid,
113 'published' => $row->status,
114 'changed' => $changed,
115 'uid' => $row->uid,
116 ))
117 ->execute();
118
119 $query = db_select('comment', 'c', array('target' => 'slave'));
120 // Force PostgreSQL to do an implicit cast by adding 0.
121 $query->addExpression('0 + :changed', 'changed', array(':changed' => $changed));
122 $query->addField('c', 'status', 'published');
123 $query
124 ->distinct()
125 ->fields('c', array('uid', 'nid'))
126 ->condition('c.nid', $row->nid)
127 ->condition('c.uid', $row->uid, '<>')
128 ->condition('c.status', COMMENT_PUBLISHED);
129
130 // Insert the user-level data for the commenters (except if a commenter
131 // is the node's author).
132 db_insert('tracker_user')
133 ->from($query)
134 ->execute();
135
136 // Note that we have indexed at least one node.
137 $last_nid = $row->nid;
138
139 $count++;
140 }
141
142 if ($last_nid !== FALSE) {
143 // Prepare a starting point for the next run.
144 variable_set('tracker_index_nid', $last_nid - 1);
145
146 watchdog('tracker', 'Indexed %count content items for tracking.', array('%count' => $count));
147 }
148 else {
149 // If all nodes have been indexed, set to zero to skip future cron runs.
150 variable_set('tracker_index_nid', 0);
151 }
152 }
153 }
154
158 function _tracker_myrecent_access($account) {
159 // This path is only allowed for authenticated users looking at their own content.
160 return $account->uid && ($GLOBALS['user']->uid == $account->uid) && user_access('access content');
161 }
162
166 function _tracker_user_access($account) {
167 return user_view_access($account) && user_access('access content');
168 }
169
175 function tracker_node_insert($node, $arg = 0) {
176 _tracker_add($node->nid, $node->uid, $node->changed);
177 }
178
184 function tracker_node_update($node, $arg = 0) {
185 _tracker_add($node->nid, $node->uid, $node->changed);
186 }
187
193 function tracker_node_delete($node, $arg = 0) {
194 db_delete('tracker_node')
195 ->condition('nid', $node->nid)
196 ->execute();
197 db_delete('tracker_user')
198 ->condition('nid', $node->nid)
199 ->execute();
200 }
201
208 function tracker_comment_update($comment) {
209 // comment_save() calls hook_comment_publish() for all published comments
210 // so we need to handle all other values here.
211 if ($comment->status != COMMENT_PUBLISHED) {
212 _tracker_remove($comment->nid, $comment->uid, $comment->changed);
213 }
214 }
215
222 function tracker_comment_publish($comment) {
223 _tracker_add($comment->nid, $comment->uid, $comment->changed);
224 }
225
229 function tracker_comment_unpublish($comment) {
230 _tracker_remove($comment->nid, $comment->uid, $comment->changed);
231 }
232
236 function tracker_comment_delete($comment) {
237 _tracker_remove($comment->nid, $comment->uid, $comment->changed);
238 }
239
250 function _tracker_add($nid, $uid, $changed) {
251 $node = db_query('SELECT nid, status, uid, changed FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject();
252
253 // Adding a comment can only increase the changed timestamp, so our
254 // calculation here is simple.
255 $changed = max($node->changed, $changed);
256
257 // Update the node-level data.
258 db_merge('tracker_node')
259 ->key(array('nid' => $nid))
260 ->fields(array(
261 'changed' => $changed,
262 'published' => $node->status,
263 ))
264 ->execute();
265
266 // Create or update the user-level data.
267 db_merge('tracker_user')
268 ->key(array(
269 'nid' => $nid,
270 'uid' => $uid,
271 ))
272 ->fields(array(
273 'changed' => $changed,
274 'published' => $node->status,
275 ))
276 ->execute();
277 }
278
289 function _tracker_calculate_changed($nid) {
290 $changed = db_query('SELECT changed FROM {node} WHERE nid = :nid', array(':nid' => $nid), array('target' => 'slave'))->fetchField();
291 $latest_comment = db_query_range('SELECT cid, changed FROM {comment} WHERE nid = :nid AND status = :status ORDER BY changed DESC', 0, 1, array(
292 ':nid' => $nid,
293 ':status' => COMMENT_PUBLISHED,
294 ), array('target' => 'slave'))->fetchObject();
295 if ($latest_comment && $latest_comment->changed > $changed) {
296 $changed = $latest_comment->changed;
297 }
298 return $changed;
299 }
300
311 function _tracker_remove($nid, $uid = NULL, $changed = NULL) {
312 $node = db_query('SELECT nid, status, uid, changed FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject();
313
314 // The user only keeps his or her subscription if both of the following are true:
315 // (1) The node exists.
316 // (2) The user is either the node author or has commented on the node.
317 $keep_subscription = FALSE;
318
319 if ($node) {
320 // Self-authorship is one reason to keep the user's subscription.
321 $keep_subscription = ($node->uid == $uid);
322
323 // Comments are a second reason to keep the user's subscription.
324 if (!$keep_subscription) {
325 // Check if the user has commented at least once on the given nid.
326 $keep_subscription = db_query_range('SELECT COUNT(*) FROM {comment} WHERE nid = :nid AND uid = :uid AND status = :status', 0, 1, array(
327 ':nid' => $nid,
328 ':uid' => $uid,
329 ':status' => COMMENT_PUBLISHED,
330 ))->fetchField();
331 }
332
333 // If we haven't found a reason to keep the user's subscription, delete it.
334 if (!$keep_subscription) {
335 db_delete('tracker_user')
336 ->condition('nid', $nid)
337 ->condition('uid', $uid)
338 ->execute();
339 }
340
341 // Now we need to update the (possibly) changed timestamps for other users
342 // and the node itself.
343 // We only need to do this if the removed item has a timestamp that equals
344 // or exceeds the listed changed timestamp for the node.
345 $tracker_node = db_query('SELECT nid, changed FROM {tracker_node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject();
346 if ($tracker_node && $changed >= $tracker_node->changed) {
347 // If we're here, the item being removed is *possibly* the item that
348 // established the node's changed timestamp.
349
350 // We just have to recalculate things from scratch.
351 $changed = _tracker_calculate_changed($nid);
352
353 // And then we push the out the new changed timestamp to our denormalized
354 // tables.
355 db_update('tracker_node')
356 ->fields(array(
357 'changed' => $changed,
358 'published' => $node->status,
359 ))
360 ->condition('nid', $nid)
361 ->execute();
362 db_update('tracker_node')
363 ->fields(array(
364 'changed' => $changed,
365 'published' => $node->status,
366 ))
367 ->condition('nid', $nid)
368 ->execute();
369 }
370 }
371 else {
372 // If the node doesn't exist, remove everything.
373 db_delete('tracker_node')
374 ->condition('nid', $nid)
375 ->execute();
376 db_delete('tracker_user')
377 ->condition('nid', $nid)
378 ->execute();
379 }
380 }
tracker_comment_publish
tracker_comment_publish($comment)
Definition: tracker.module:222
_tracker_user_access
_tracker_user_access($account)
Definition: tracker.module:166
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
_tracker_add
_tracker_add($nid, $uid, $changed)
Definition: tracker.module:250
tracker_node_insert
tracker_node_insert($node, $arg=0)
Definition: tracker.module:175
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
tracker_cron
tracker_cron()
Definition: tracker.module:79
user_view_access
user_view_access($account)
Definition: user.module:1564
tracker_comment_delete
tracker_comment_delete($comment)
Definition: tracker.module:236
tracker_node_delete
tracker_node_delete($node, $arg=0)
Definition: tracker.module:193
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
_tracker_remove
_tracker_remove($nid, $uid=NULL, $changed=NULL)
Definition: tracker.module:311
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
tracker_menu
tracker_menu()
Definition: tracker.module:32
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
tracker_comment_update
tracker_comment_update($comment)
Definition: tracker.module:208
tracker_comment_unpublish
tracker_comment_unpublish($comment)
Definition: tracker.module:229
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
tracker_help
tracker_help($path, $arg)
Definition: tracker.module:11
_tracker_calculate_changed
_tracker_calculate_changed($nid)
Definition: tracker.module:289
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
tracker_node_update
tracker_node_update($node, $arg=0)
Definition: tracker.module:184
$row
$row
Definition: block-admin-display-form.tpl.php:47
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
_tracker_myrecent_access
_tracker_myrecent_access($account)
Definition: tracker.module:158
COMMENT_PUBLISHED
const COMMENT_PUBLISHED
Definition: comment.module:20
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/pgsql/install.inc Source File

  • includes
  • database
  • pgsql
install.inc
Go to the documentation of this file.
1 <?php
2
9 // PostgreSQL specific install functions
10
11 class DatabaseTasks_pgsql extends DatabaseTasks {
12 protected $pdoDriver = 'pgsql';
13
14 public function __construct() {
15 $this->tasks[] = array(
16 'function' => 'checkEncoding',
17 'arguments' => array(),
18 );
19 $this->tasks[] = array(
20 'function' => 'checkPHPVersion',
21 'arguments' => array(),
22 );
23 $this->tasks[] = array(
24 'function' => 'checkBinaryOutput',
25 'arguments' => array(),
26 );
27 $this->tasks[] = array(
28 'function' => 'initializeDatabase',
29 'arguments' => array(),
30 );
31 }
32
33 public function name() {
34 return st('PostgreSQL');
35 }
36
37 public function minimumVersion() {
38 return '8.3';
39 }
40
44 protected function checkEncoding() {
45 try {
46 if (db_query('SHOW server_encoding')->fetchField() == 'UTF8') {
47 $this->pass(st('Database is encoded in UTF-8'));
48 }
49 else {
50 $replacements = array(
51 '%encoding' => 'UTF8',
52 '%driver' => $this->name(),
53 '!link' => '<a href="INSTALL.pgsql.txt">INSTALL.pgsql.txt</a>'
54 );
55 $text = 'The %driver database must use %encoding encoding to work with Drupal.';
56 $text .= 'Recreate the database with %encoding encoding. See !link for more details.';
57 $this->fail(st($text, $replacements));
58 }
59 }
60 catch (Exception $e) {
61 $this->fail(st('Drupal could not determine the encoding of the database was set to UTF-8'));
62 }
63 }
64
76 function checkPHPVersion() {
77 if (!version_compare(PHP_VERSION, '5.2.11', '>=') || (version_compare(PHP_VERSION, '5.3.0', '>=') && !version_compare(PHP_VERSION, '5.3.1', '>='))) {
78 $this->fail(st('The version of PHP you are using has known issues with PostgreSQL. You need to upgrade PHP to 5.2.11, 5.3.1 or greater.'));
79 };
80 }
81
87 function checkBinaryOutput() {
88 // PostgreSQL < 9 doesn't support bytea_output, so verify we are running
89 // at least PostgreSQL 9.
90 $database_connection = Database::getConnection();
91 if (version_compare($database_connection->version(), '9') >= 0) {
92 if (!$this->checkBinaryOutputSuccess()) {
93 // First try to alter the database. If it fails, raise an error telling
94 // the user to do it themselves.
95 $connection_options = $database_connection->getConnectionOptions();
96 // It is safe to include the database name directly here, because this
97 // code is only called when a connection to the database is already
98 // established, thus the database name is guaranteed to be a correct
99 // value.
100 $query = "ALTER DATABASE \"" . $connection_options['database'] . "\" SET bytea_output = 'escape';";
101 try {
102 db_query($query);
103 }
104 catch (Exception $e) {
105 // Ignore possible errors when the user doesn't have the necessary
106 // privileges to ALTER the database.
107 }
108
109 // Close the database connection so that the configuration parameter
110 // is applied to the current connection.
111 db_close();
112
113 // Recheck, if it fails, finally just rely on the end user to do the
114 // right thing.
115 if (!$this->checkBinaryOutputSuccess()) {
116 $replacements = array(
117 '%setting' => 'bytea_output',
118 '%current_value' => 'hex',
119 '%needed_value' => 'escape',
120 '!query' => "<code>" . $query . "</code>",
121 );
122 $this->fail(st("The %setting setting is currently set to '%current_value', but needs to be '%needed_value'. Change this by running the following query: !query", $replacements));
123 }
124 }
125 }
126 }
127
131 protected function checkBinaryOutputSuccess() {
132 $bytea_output = db_query("SELECT 'encoding'::bytea AS output")->fetchField();
133 return ($bytea_output == 'encoding');
134 }
135
139 function initializeDatabase() {
140 // We create some functions using global names instead of prefixing them
141 // like we do with table names. This is so that we don't double up if more
142 // than one instance of Drupal is running on a single database. We therefore
143 // avoid trying to create them again in that case.
144
145 try {
146 // Create functions.
147 db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric) RETURNS numeric AS
148 \'SELECT CASE WHEN (($1 > $2) OR ($2 IS NULL)) THEN $1 ELSE $2 END;\'
149 LANGUAGE \'sql\''
150 );
151 db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric, numeric) RETURNS numeric AS
152 \'SELECT greatest($1, greatest($2, $3));\'
153 LANGUAGE \'sql\''
154 );
155 // Don't use {} around pg_proc table.
156 if (!db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'rand'")->fetchField()) {
157 db_query('CREATE OR REPLACE FUNCTION "rand"() RETURNS float AS
158 \'SELECT random();\'
159 LANGUAGE \'sql\''
160 );
161 }
162
163 db_query('CREATE OR REPLACE FUNCTION "substring_index"(text, text, integer) RETURNS text AS
164 \'SELECT array_to_string((string_to_array($1, $2)) [1:$3], $2);\'
165 LANGUAGE \'sql\''
166 );
167
168 // Using || to concatenate in Drupal is not recommeneded because there are
169 // database drivers for Drupal that do not support the syntax, however
170 // they do support CONCAT(item1, item2) which we can replicate in
171 // PostgreSQL. PostgreSQL requires the function to be defined for each
172 // different argument variation the function can handle.
173 db_query('CREATE OR REPLACE FUNCTION "concat"(anynonarray, anynonarray) RETURNS text AS
174 \'SELECT CAST($1 AS text) || CAST($2 AS text);\'
175 LANGUAGE \'sql\'
176 ');
177 db_query('CREATE OR REPLACE FUNCTION "concat"(text, anynonarray) RETURNS text AS
178 \'SELECT $1 || CAST($2 AS text);\'
179 LANGUAGE \'sql\'
180 ');
181 db_query('CREATE OR REPLACE FUNCTION "concat"(anynonarray, text) RETURNS text AS
182 \'SELECT CAST($1 AS text) || $2;\'
183 LANGUAGE \'sql\'
184 ');
185 db_query('CREATE OR REPLACE FUNCTION "concat"(text, text) RETURNS text AS
186 \'SELECT $1 || $2;\'
187 LANGUAGE \'sql\'
188 ');
189
190 $this->pass(st('PostgreSQL has initialized itself.'));
191 }
192 catch (Exception $e) {
193 $this->fail(st('Drupal could not be correctly setup with the existing database. Revise any errors.'));
194 }
195 }
196 }
197
DatabaseTasks_pgsql\checkEncoding
checkEncoding()
Definition: install.inc:44
Database\getConnection
static getConnection($target= 'default', $key=NULL)
Definition: database.inc:1460
DatabaseTasks_pgsql\checkPHPVersion
checkPHPVersion()
Definition: install.inc:76
Exception
DatabaseTasks_pgsql\initializeDatabase
initializeDatabase()
Definition: install.inc:139
DatabaseTasks
Definition: install.inc:290
DatabaseTasks\pass
pass($message)
Definition: install.inc:367
db_close
db_close(array $options=array())
Definition: database.inc:2631
st
st($string, array $args=array(), array $options=array())
Definition: install.inc:1111
DatabaseTasks\fail
fail($message)
Definition: install.inc:360
DatabaseTasks_pgsql\checkBinaryOutput
checkBinaryOutput()
Definition: install.inc:87
DatabaseTasks_pgsql
Definition: install.inc:11
DatabaseTasks_pgsql\minimumVersion
minimumVersion()
Definition: install.inc:37
DatabaseTasks_pgsql\name
name()
Definition: install.inc:33
DatabaseTasks_pgsql\__construct
__construct()
Definition: install.inc:14
DatabaseTasks_pgsql\checkBinaryOutputSuccess
checkBinaryOutputSuccess()
Definition: install.inc:131
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
DatabaseTasks_pgsql\$pdoDriver
$pdoDriver
Definition: install.inc:12
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy/taxonomy.module Source File

  • modules
  • taxonomy
taxonomy.module
Go to the documentation of this file.
1 <?php
2
19 function taxonomy_help($path, $arg) {
20 switch ($path) {
21 case 'admin/help#taxonomy':
22 $output = '';
23 $output .= '<h3>' . t('About') . '</h3>';
24 $output .= '<p>' . t('The Taxonomy module allows you to classify the content of your website. To classify content, you define <em>vocabularies</em> that contain related <em>terms</em>, and then assign the vocabularies to content types. For more information, see the online handbook entry for the <a href="@taxonomy">Taxonomy module</a>.', array('@taxonomy' => 'http://drupal.org/documentation/modules/taxonomy/')) . '</p>';
25 $output .= '<h3>' . t('Uses') . '</h3>';
26 $output .= '<dl>';
27 $output .= '<dt>' . t('Creating vocabularies') . '</dt>';
28 $output .= '<dd>' . t('Users with sufficient <a href="@perm">permissions</a> can create <em>vocabularies</em> and <em>terms</em> through the <a href="@taxo">Taxonomy page</a>. The page listing the terms provides a drag-and-drop interface for controlling the order of the terms and sub-terms within a vocabulary, in a hierarchical fashion. A <em>controlled vocabulary</em> classifying music by genre with terms and sub-terms could look as follows:', array('@taxo' => url('admin/structure/taxonomy'), '@perm' => url('admin/people/permissions', array('fragment'=>'module-taxonomy'))));
29 $output .= '<ul><li>' . t('<em>vocabulary</em>: Music') . '</li>';
30 $output .= '<ul><li>' . t('<em>term</em>: Jazz') . '</li>';
31 $output .= '<ul><li>' . t('<em>sub-term</em>: Swing') . '</li>';
32 $output .= '<li>' . t('<em>sub-term</em>: Fusion') . '</li></ul></ul>';
33 $output .= '<ul><li>' . t('<em>term</em>: Rock') . '</li>';
34 $output .= '<ul><li>' . t('<em>sub-term</em>: Country rock') . '</li>';
35 $output .= '<li>' . t('<em>sub-term</em>: Hard rock') . '</li></ul></ul></ul>';
36 $output .= t('You can assign a sub-term to multiple parent terms. For example, <em>fusion</em> can be assigned to both <em>rock</em> and <em>jazz</em>.') . '</dd>';
37 $output .= '<dd>' . t('Terms in a <em>free-tagging vocabulary</em> can be built gradually as you create or edit content. This is often done used for blogs or photo management applications.') . '</dd>';
38 $output .= '<dt>' . t('Assigning vocabularies to content types') . '</dt>';
39 $output .= '<dd>' . t('Before you can use a new vocabulary to classify your content, a new Taxonomy term field must be added to a <a href="@ctedit">content type</a> on its <em>manage fields</em> page. When adding a taxonomy field, you choose a <em>widget</em> to use to enter the taxonomy information on the content editing page: a select list, checkboxes, radio buttons, or an auto-complete field (to build a free-tagging vocabulary). After choosing the field type and widget, on the subsequent <em>field settings</em> page you can choose the desired vocabulary, whether one or multiple terms can be chosen from the vocabulary, and other settings. The same vocabulary can be added to multiple content types, by using the "Add existing field" section on the manage fields page.', array('@ctedit' => url('admin/structure/types'))) . '</dd>';
40 $output .= '<dt>' . t('Classifying content') . '</dt>';
41 $output .= '<dd>' . t('After the vocabulary is assigned to the content type, you can start classifying content. The field with terms will appear on the content editing screen when you edit or <a href="@addnode">add new content</a>.', array('@addnode' => url('node/add'))) . '</dd>';
42 $output .= '<dt>' . t('Viewing listings and RSS feeds by term') . '</dt>';
43 $output .= '<dd>' . t("Each taxonomy term automatically provides a page listing content that has its classification, and a corresponding RSS feed. For example, if the taxonomy term <em>country rock</em> has the ID 123 (you can see this by looking at the URL when hovering on the linked term, which you can click to navigate to the listing page), then you will find this list at the path <em>taxonomy/term/123</em>. The RSS feed will use the path <em>taxonomy/term/123/feed</em> (the RSS icon for this term's listing will automatically display in your browser's address bar when viewing the listing page).") . '</dd>';
44 $output .= '<dt>' . t('Extending Taxonomy module') . '</dt>';
45 $output .= '<dd>' . t('There are <a href="@taxcontrib">many contributed modules</a> that extend the behavior of the Taxonomy module for both display and organization of terms.', array('@taxcontrib' => 'http://drupal.org/project/modules?filters=tid:71&solrsort=sis_project_release_usage%20desc'));
46 $output .= '</dl>';
47 return $output;
48 case 'admin/structure/taxonomy':
49 $output = '<p>' . t('Taxonomy is for categorizing content. Terms are grouped into vocabularies. For example, a vocabulary called "Fruit" would contain the terms "Apple" and "Banana".') . '</p>';
50 return $output;
51 case 'admin/structure/taxonomy/%':
52 $vocabulary = taxonomy_vocabulary_machine_name_load($arg[3]);
53 switch ($vocabulary->hierarchy) {
54 case 0:
55 return '<p>' . t('You can reorganize the terms in %capital_name using their drag-and-drop handles, and group terms under a parent term by sliding them under and to the right of the parent.', array('%capital_name' => drupal_ucfirst($vocabulary->name), '%name' => $vocabulary->name)) . '</p>';
56 case 1:
57 return '<p>' . t('%capital_name contains terms grouped under parent terms. You can reorganize the terms in %capital_name using their drag-and-drop handles.', array('%capital_name' => drupal_ucfirst($vocabulary->name), '%name' => $vocabulary->name)) . '</p>';
58 case 2:
59 return '<p>' . t('%capital_name contains terms with multiple parents. Drag and drop of terms with multiple parents is not supported, but you can re-enable drag-and-drop support by editing each term to include only a single parent.', array('%capital_name' => drupal_ucfirst($vocabulary->name))) . '</p>';
60 }
61 }
62 }
63
67 function taxonomy_permission() {
68 $permissions = array(
69 'administer taxonomy' => array(
70 'title' => t('Administer vocabularies and terms'),
71 ),
72 );
73 foreach (taxonomy_get_vocabularies() as $vocabulary) {
74 $permissions += array(
75 'edit terms in ' . $vocabulary->vid => array(
76 'title' => t('Edit terms in %vocabulary', array('%vocabulary' => $vocabulary->name)),
77 ),
78 );
79 $permissions += array(
80 'delete terms in ' . $vocabulary->vid => array(
81 'title' => t('Delete terms from %vocabulary', array('%vocabulary' => $vocabulary->name)),
82 ),
83 );
84 }
85 return $permissions;
86 }
87
91 function taxonomy_entity_info() {
92 $return = array(
93 'taxonomy_term' => array(
94 'label' => t('Taxonomy term'),
95 'controller class' => 'TaxonomyTermController',
96 'base table' => 'taxonomy_term_data',
97 'uri callback' => 'taxonomy_term_uri',
98 'fieldable' => TRUE,
99 'entity keys' => array(
100 'id' => 'tid',
101 'bundle' => 'vocabulary_machine_name',
102 'label' => 'name',
103 ),
104 'bundle keys' => array(
105 'bundle' => 'machine_name',
106 ),
107 'bundles' => array(),
108 'view modes' => array(
109 // @todo View mode for display as a field (when attached to nodes etc).
110 'full' => array(
111 'label' => t('Taxonomy term page'),
112 'custom settings' => FALSE,
113 ),
114 ),
115 ),
116 );
117 foreach (taxonomy_vocabulary_get_names() as $machine_name => $vocabulary) {
118 $return['taxonomy_term']['bundles'][$machine_name] = array(
119 'label' => $vocabulary->name,
120 'admin' => array(
121 'path' => 'admin/structure/taxonomy/%taxonomy_vocabulary_machine_name',
122 'real path' => 'admin/structure/taxonomy/' . $machine_name,
123 'bundle argument' => 3,
124 'access arguments' => array('administer taxonomy'),
125 ),
126 );
127 }
128 $return['taxonomy_vocabulary'] = array(
129 'label' => t('Taxonomy vocabulary'),
130 'controller class' => 'TaxonomyVocabularyController',
131 'base table' => 'taxonomy_vocabulary',
132 'entity keys' => array(
133 'id' => 'vid',
134 'label' => 'name',
135 ),
136 'fieldable' => FALSE,
137 );
138
139 return $return;
140 }
141
145 function taxonomy_term_uri($term) {
146 return array(
147 'path' => 'taxonomy/term/' . $term->tid,
148 );
149 }
150
154 function taxonomy_field_extra_fields() {
155 $return = array();
156 $info = entity_get_info('taxonomy_term');
157 foreach (array_keys($info['bundles']) as $bundle) {
158 $return['taxonomy_term'][$bundle] = array(
159 'form' => array(
160 'name' => array(
161 'label' => t('Name'),
162 'description' => t('Term name textfield'),
163 'weight' => -5,
164 ),
165 'description' => array(
166 'label' => t('Description'),
167 'description' => t('Term description textarea'),
168 'weight' => 0,
169 ),
170 ),
171 'display' => array(
172 'description' => array(
173 'label' => t('Description'),
174 'description' => t('Term description'),
175 'weight' => 0,
176 ),
177 ),
178 );
179 }
180
181 return $return;
182 }
183
204 function taxonomy_select_nodes($tid, $pager = TRUE, $limit = FALSE, $order = array('t.sticky' => 'DESC', 't.created' => 'DESC')) {
205 if (!variable_get('taxonomy_maintain_index_table', TRUE)) {
206 return array();
207 }
208 $query = db_select('taxonomy_index', 't');
209 $query->addTag('node_access');
210 $query->condition('tid', $tid);
211 if ($pager) {
212 $count_query = clone $query;
213 $count_query->addExpression('COUNT(t.nid)');
214
215 $query = $query->extend('PagerDefault');
216 if ($limit !== FALSE) {
217 $query = $query->limit($limit);
218 }
219 $query->setCountQuery($count_query);
220 }
221 else {
222 if ($limit !== FALSE) {
223 $query->range(0, $limit);
224 }
225 }
226 $query->addField('t', 'nid');
227 $query->addField('t', 'tid');
228 foreach ($order as $field => $direction) {
229 $query->orderBy($field, $direction);
230 // ORDER BY fields need to be loaded too, assume they are in the form
231 // table_alias.name
232 list($table_alias, $name) = explode('.', $field);
233 $query->addField($table_alias, $name);
234 }
235 return $query->execute()->fetchCol();
236 }
237
241 function taxonomy_theme() {
242 return array(
243 'taxonomy_overview_vocabularies' => array(
244 'render element' => 'form',
245 ),
246 'taxonomy_overview_terms' => array(
247 'render element' => 'form',
248 ),
249 'taxonomy_term' => array(
250 'render element' => 'elements',
251 'template' => 'taxonomy-term',
252 ),
253 );
254 }
255
259 function taxonomy_menu() {
260 $items['admin/structure/taxonomy'] = array(
261 'title' => 'Taxonomy',
262 'description' => 'Manage tagging, categorization, and classification of your content.',
263 'page callback' => 'drupal_get_form',
264 'page arguments' => array('taxonomy_overview_vocabularies'),
265 'access arguments' => array('administer taxonomy'),
266 'file' => 'taxonomy.admin.inc',
267 );
268 $items['admin/structure/taxonomy/list'] = array(
269 'title' => 'List',
270 'type' => MENU_DEFAULT_LOCAL_TASK,
271 'weight' => -10,
272 );
273 $items['admin/structure/taxonomy/add'] = array(
274 'title' => 'Add vocabulary',
275 'page callback' => 'drupal_get_form',
276 'page arguments' => array('taxonomy_form_vocabulary'),
277 'access arguments' => array('administer taxonomy'),
278 'type' => MENU_LOCAL_ACTION,
279 'file' => 'taxonomy.admin.inc',
280 );
281
282 $items['taxonomy/term/%taxonomy_term'] = array(
283 'title' => 'Taxonomy term',
284 'title callback' => 'taxonomy_term_title',
285 'title arguments' => array(2),
286 'page callback' => 'taxonomy_term_page',
287 'page arguments' => array(2),
288 'access arguments' => array('access content'),
289 'file' => 'taxonomy.pages.inc',
290 );
291 $items['taxonomy/term/%taxonomy_term/view'] = array(
292 'title' => 'View',
293 'type' => MENU_DEFAULT_LOCAL_TASK,
294 );
295 $items['taxonomy/term/%taxonomy_term/edit'] = array(
296 'title' => 'Edit',
297 'page callback' => 'drupal_get_form',
298 // Pass a NULL argument to ensure that additional path components are not
299 // passed to taxonomy_form_term() as the vocabulary machine name argument.
300 'page arguments' => array('taxonomy_form_term', 2, NULL),
301 'access callback' => 'taxonomy_term_edit_access',
302 'access arguments' => array(2),
303 'type' => MENU_LOCAL_TASK,
304 'weight' => 10,
305 'file' => 'taxonomy.admin.inc',
306 );
307 $items['taxonomy/term/%taxonomy_term/feed'] = array(
308 'title' => 'Taxonomy term',
309 'title callback' => 'taxonomy_term_title',
310 'title arguments' => array(2),
311 'page callback' => 'taxonomy_term_feed',
312 'page arguments' => array(2),
313 'access arguments' => array('access content'),
314 'type' => MENU_CALLBACK,
315 'file' => 'taxonomy.pages.inc',
316 );
317 $items['taxonomy/autocomplete'] = array(
318 'title' => 'Autocomplete taxonomy',
319 'page callback' => 'taxonomy_autocomplete',
320 'access arguments' => array('access content'),
321 'type' => MENU_CALLBACK,
322 'file' => 'taxonomy.pages.inc',
323 );
324
325 $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name'] = array(
326 'title callback' => 'entity_label',
327 'title arguments' => array('taxonomy_vocabulary', 3),
328 'page callback' => 'drupal_get_form',
329 'page arguments' => array('taxonomy_overview_terms', 3),
330 'access arguments' => array('administer taxonomy'),
331 'file' => 'taxonomy.admin.inc',
332 );
333 $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/list'] = array(
334 'title' => 'List',
335 'type' => MENU_DEFAULT_LOCAL_TASK,
336 'weight' => -20,
337 );
338 $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/edit'] = array(
339 'title' => 'Edit',
340 'page callback' => 'drupal_get_form',
341 'page arguments' => array('taxonomy_form_vocabulary', 3),
342 'access arguments' => array('administer taxonomy'),
343 'type' => MENU_LOCAL_TASK,
344 'weight' => -10,
345 'file' => 'taxonomy.admin.inc',
346 );
347
348 $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/add'] = array(
349 'title' => 'Add term',
350 'page callback' => 'drupal_get_form',
351 'page arguments' => array('taxonomy_form_term', array(), 3),
352 'access arguments' => array('administer taxonomy'),
353 'type' => MENU_LOCAL_ACTION,
354 'file' => 'taxonomy.admin.inc',
355 );
356
357 return $items;
358 }
359
363 function taxonomy_admin_paths() {
364 $paths = array(
365 'taxonomy/term/*/edit' => TRUE,
366 );
367 return $paths;
368 }
369
373 function taxonomy_term_edit_access($term) {
374 return user_access("edit terms in $term->vid") || user_access('administer taxonomy');
375 }
376
386 function taxonomy_admin_vocabulary_title_callback($vocabulary) {
387 return check_plain($vocabulary->name);
388 }
389
413 function taxonomy_vocabulary_save($vocabulary) {
414 // Prevent leading and trailing spaces in vocabulary names.
415 if (!empty($vocabulary->name)) {
416 $vocabulary->name = trim($vocabulary->name);
417 }
418 // Load the stored entity, if any.
419 if (!empty($vocabulary->vid)) {
420 if (!isset($vocabulary->original)) {
421 $vocabulary->original = entity_load_unchanged('taxonomy_vocabulary', $vocabulary->vid);
422 }
423 // Make sure machine name changes are easily detected.
424 // @todo: Remove in Drupal 8, as it is deprecated by directly reading from
425 // $vocabulary->original.
426 $vocabulary->old_machine_name = $vocabulary->original->machine_name;
427 }
428
429 if (!isset($vocabulary->module)) {
430 $vocabulary->module = 'taxonomy';
431 }
432
433 module_invoke_all('taxonomy_vocabulary_presave', $vocabulary);
434 module_invoke_all('entity_presave', $vocabulary, 'taxonomy_vocabulary');
435
436 if (!empty($vocabulary->vid) && !empty($vocabulary->name)) {
437 $status = drupal_write_record('taxonomy_vocabulary', $vocabulary, 'vid');
438 taxonomy_vocabulary_static_reset(array($vocabulary->vid));
439 if ($vocabulary->old_machine_name != $vocabulary->machine_name) {
440 field_attach_rename_bundle('taxonomy_term', $vocabulary->old_machine_name, $vocabulary->machine_name);
441 }
442 module_invoke_all('taxonomy_vocabulary_update', $vocabulary);
443 module_invoke_all('entity_update', $vocabulary, 'taxonomy_vocabulary');
444 }
445 elseif (empty($vocabulary->vid)) {
446 $status = drupal_write_record('taxonomy_vocabulary', $vocabulary);
447 taxonomy_vocabulary_static_reset();
448 field_attach_create_bundle('taxonomy_term', $vocabulary->machine_name);
449 module_invoke_all('taxonomy_vocabulary_insert', $vocabulary);
450 module_invoke_all('entity_insert', $vocabulary, 'taxonomy_vocabulary');
451 }
452
453 unset($vocabulary->original);
454 cache_clear_all();
455
456 return $status;
457 }
458
467 function taxonomy_vocabulary_delete($vid) {
468 $vocabulary = taxonomy_vocabulary_load($vid);
469
470 $transaction = db_transaction();
471 try {
472 // Only load terms without a parent, child terms will get deleted too.
473 $result = db_query('SELECT t.tid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} th ON th.tid = t.tid WHERE t.vid = :vid AND th.parent = 0', array(':vid' => $vid))->fetchCol();
474 foreach ($result as $tid) {
475 taxonomy_term_delete($tid);
476 }
477 db_delete('taxonomy_vocabulary')
478 ->condition('vid', $vid)
479 ->execute();
480
481 field_attach_delete_bundle('taxonomy_term', $vocabulary->machine_name);
482 module_invoke_all('taxonomy_vocabulary_delete', $vocabulary);
483 module_invoke_all('entity_delete', $vocabulary, 'taxonomy_vocabulary');
484
485 // Load all Taxonomy module fields and delete those which use only this
486 // vocabulary.
487 $taxonomy_fields = field_read_fields(array('module' => 'taxonomy'));
488 foreach ($taxonomy_fields as $field_name => $taxonomy_field) {
489 $modified_field = FALSE;
490 // Term reference fields may reference terms from more than one
491 // vocabulary.
492 foreach ($taxonomy_field['settings']['allowed_values'] as $key => $allowed_value) {
493 if ($allowed_value['vocabulary'] == $vocabulary->machine_name) {
494 unset($taxonomy_field['settings']['allowed_values'][$key]);
495 $modified_field = TRUE;
496 }
497 }
498 if ($modified_field) {
499 if (empty($taxonomy_field['settings']['allowed_values'])) {
500 field_delete_field($field_name);
501 }
502 else {
503 // Update the field definition with the new allowed values.
504 field_update_field($taxonomy_field);
505 }
506 }
507 }
508
509 cache_clear_all();
510 taxonomy_vocabulary_static_reset();
511
512 return SAVED_DELETED;
513 }
514 catch (Exception $e) {
515 $transaction->rollback();
516 watchdog_exception('taxonomy', $e);
517 throw $e;
518 }
519 }
520
524 function taxonomy_taxonomy_vocabulary_update($vocabulary) {
525 // Reflect machine name changes in the definitions of existing 'taxonomy'
526 // fields.
527 if (!empty($vocabulary->old_machine_name) && $vocabulary->old_machine_name != $vocabulary->machine_name) {
528 $fields = field_read_fields();
529 foreach ($fields as $field_name => $field) {
530 $update = FALSE;
531 if ($field['type'] == 'taxonomy_term_reference') {
532 foreach ($field['settings']['allowed_values'] as $key => &$value) {
533 if ($value['vocabulary'] == $vocabulary->old_machine_name) {
534 $value['vocabulary'] = $vocabulary->machine_name;
535 $update = TRUE;
536 }
537 }
538 if ($update) {
539 field_update_field($field);
540 }
541 }
542 }
543 }
544 }
545
564 function taxonomy_check_vocabulary_hierarchy($vocabulary, $changed_term) {
565 $tree = taxonomy_get_tree($vocabulary->vid);
566 $hierarchy = 0;
567 foreach ($tree as $term) {
568 // Update the changed term with the new parent value before comparison.
569 if ($term->tid == $changed_term['tid']) {
570 $term = (object) $changed_term;
571 $term->parents = $term->parent;
572 }
573 // Check this term's parent count.
574 if (count($term->parents) > 1) {
575 $hierarchy = 2;
576 break;
577 }
578 elseif (count($term->parents) == 1 && !isset($term->parents[0])) {
579 $hierarchy = 1;
580 }
581 }
582 if ($hierarchy != $vocabulary->hierarchy) {
583 $vocabulary->hierarchy = $hierarchy;
584 taxonomy_vocabulary_save($vocabulary);
585 }
586
587 return $hierarchy;
588 }
589
621 function taxonomy_term_save($term) {
622 // Prevent leading and trailing spaces in term names.
623 $term->name = trim($term->name);
624 if (!isset($term->vocabulary_machine_name)) {
625 $vocabulary = taxonomy_vocabulary_load($term->vid);
626 $term->vocabulary_machine_name = $vocabulary->machine_name;
627 }
628
629 // Load the stored entity, if any.
630 if (!empty($term->tid) && !isset($term->original)) {
631 $term->original = entity_load_unchanged('taxonomy_term', $term->tid);
632 }
633
634 field_attach_presave('taxonomy_term', $term);
635 module_invoke_all('taxonomy_term_presave', $term);
636 module_invoke_all('entity_presave', $term, 'taxonomy_term');
637
638 if (empty($term->tid)) {
639 $op = 'insert';
640 $status = drupal_write_record('taxonomy_term_data', $term);
641 field_attach_insert('taxonomy_term', $term);
642 if (!isset($term->parent)) {
643 $term->parent = array(0);
644 }
645 }
646 else {
647 $op = 'update';
648 $status = drupal_write_record('taxonomy_term_data', $term, 'tid');
649 field_attach_update('taxonomy_term', $term);
650 if (isset($term->parent)) {
651 db_delete('taxonomy_term_hierarchy')
652 ->condition('tid', $term->tid)
653 ->execute();
654 }
655 }
656
657 if (isset($term->parent)) {
658 if (!is_array($term->parent)) {
659 $term->parent = array($term->parent);
660 }
661 $query = db_insert('taxonomy_term_hierarchy')
662 ->fields(array('tid', 'parent'));
663 foreach ($term->parent as $parent) {
664 if (is_array($parent)) {
665 foreach ($parent as $tid) {
666 $query->values(array(
667 'tid' => $term->tid,
668 'parent' => $tid
669 ));
670 }
671 }
672 else {
673 $query->values(array(
674 'tid' => $term->tid,
675 'parent' => $parent
676 ));
677 }
678 }
679 $query->execute();
680 }
681
682 // Reset the taxonomy term static variables.
683 taxonomy_terms_static_reset();
684
685 // Invoke the taxonomy hooks.
686 module_invoke_all("taxonomy_term_$op", $term);
687 module_invoke_all("entity_$op", $term, 'taxonomy_term');
688 unset($term->original);
689
690 return $status;
691 }
692
701 function taxonomy_term_delete($tid) {
702 $transaction = db_transaction();
703 try {
704 $tids = array($tid);
705 while ($tids) {
706 $children_tids = $orphans = array();
707 foreach ($tids as $tid) {
708 // See if any of the term's children are about to be become orphans:
709 if ($children = taxonomy_get_children($tid)) {
710 foreach ($children as $child) {
711 // If the term has multiple parents, we don't delete it.
712 $parents = taxonomy_get_parents($child->tid);
713 if (count($parents) == 1) {
714 $orphans[] = $child->tid;
715 }
716 }
717 }
718
719 if ($term = taxonomy_term_load($tid)) {
720 db_delete('taxonomy_term_data')
721 ->condition('tid', $tid)
722 ->execute();
723 db_delete('taxonomy_term_hierarchy')
724 ->condition('tid', $tid)
725 ->execute();
726
727 field_attach_delete('taxonomy_term', $term);
728 module_invoke_all('taxonomy_term_delete', $term);
729 module_invoke_all('entity_delete', $term, 'taxonomy_term');
730 taxonomy_terms_static_reset();
731 }
732 }
733
734 $tids = $orphans;
735 }
736 return SAVED_DELETED;
737 }
738 catch (Exception $e) {
739 $transaction->rollback();
740 watchdog_exception('taxonomy', $e);
741 throw $e;
742 }
743 }
744
753 function taxonomy_term_show($term) {
754 return taxonomy_term_view_multiple(array($term->tid => $term), 'full');
755 }
756
773 function taxonomy_term_view_multiple($terms, $view_mode = 'teaser', $weight = 0, $langcode = NULL) {
774 field_attach_prepare_view('taxonomy_term', $terms, $view_mode, $langcode);
775 entity_prepare_view('taxonomy_term', $terms, $langcode);
776 $build = array();
777 foreach ($terms as $term) {
778 $build['taxonomy_terms'][$term->tid] = taxonomy_term_view($term, $view_mode, $langcode);
779 $build['taxonomy_terms'][$term->tid]['#weight'] = $weight;
780 $weight++;
781 }
782 $build['taxonomy_terms']['#sorted'] = TRUE;
783 return $build;
784 }
785
806 function taxonomy_term_build_content($term, $view_mode = 'full', $langcode = NULL) {
807 if (!isset($langcode)) {
808 $langcode = $GLOBALS['language_content']->language;
809 }
810
811 // Remove previously built content, if exists.
812 $term->content = array();
813
814 // Allow modules to change the view mode.
815 $context = array(
816 'entity_type' => 'taxonomy_term',
817 'entity' => $term,
818 'langcode' => $langcode,
819 );
820 drupal_alter('entity_view_mode', $view_mode, $context);
821
822 // Add the term description if the term has one and it is visible.
823 $type = 'taxonomy_term';
824 $entity_ids = entity_extract_ids($type, $term);
825 $settings = field_view_mode_settings($type, $entity_ids[2]);
826 $fields = field_extra_fields_get_display($type, $entity_ids[2], $view_mode);
827 if (!empty($term->description) && isset($fields['description']) && $fields['description']['visible']) {
828 $term->content['description'] = array(
829 '#markup' => check_markup($term->description, $term->format, '', TRUE),
830 '#weight' => $fields['description']['weight'],
831 '#prefix' => '<div class="taxonomy-term-description">',
832 '#suffix' => '</div>',
833 );
834 }
835
836 // Build fields content.
837 // In case of a multiple view, taxonomy_term_view_multiple() already ran the
838 // 'prepare_view' step. An internal flag prevents the operation from running
839 // twice.
840 field_attach_prepare_view('taxonomy_term', array($term->tid => $term), $view_mode, $langcode);
841 entity_prepare_view('taxonomy_term', array($term->tid => $term), $langcode);
842 $term->content += field_attach_view('taxonomy_term', $term, $view_mode, $langcode);
843
844 // Allow modules to make their own additions to the taxonomy term.
845 module_invoke_all('taxonomy_term_view', $term, $view_mode, $langcode);
846 module_invoke_all('entity_view', $term, 'taxonomy_term', $view_mode, $langcode);
847
848 // Make sure the current view mode is stored if no module has already
849 // populated the related key.
850 $term->content += array('#view_mode' => $view_mode);
851 }
852
867 function taxonomy_term_view($term, $view_mode = 'full', $langcode = NULL) {
868 if (!isset($langcode)) {
869 $langcode = $GLOBALS['language_content']->language;
870 }
871
872 // Populate $term->content with a render() array.
873 taxonomy_term_build_content($term, $view_mode, $langcode);
874 $build = $term->content;
875
876 // We don't need duplicate rendering info in $term->content.
877 unset($term->content);
878
879 $build += array(
880 '#theme' => 'taxonomy_term',
881 '#term' => $term,
882 '#view_mode' => $view_mode,
883 '#language' => $langcode,
884 );
885
886 $build['#attached']['css'][] = drupal_get_path('module', 'taxonomy') . '/taxonomy.css';
887
888 // Allow modules to modify the structured taxonomy term.
889 $type = 'taxonomy_term';
890 drupal_alter(array('taxonomy_term_view', 'entity_view'), $build, $type);
891
892 return $build;
893 }
894
898 function template_preprocess_taxonomy_term(&$variables) {
899 $variables['view_mode'] = $variables['elements']['#view_mode'];
900 $variables['term'] = $variables['elements']['#term'];
901 $term = $variables['term'];
902
903 $uri = entity_uri('taxonomy_term', $term);
904 $variables['term_url'] = url($uri['path'], $uri['options']);
905 $variables['term_name'] = check_plain($term->name);
906 $variables['page'] = $variables['view_mode'] == 'full' && taxonomy_term_is_page($term);
907
908 // Flatten the term object's member fields.
909 $variables = array_merge((array) $term, $variables);
910
911 // Helpful $content variable for templates.
912 $variables['content'] = array();
913 foreach (element_children($variables['elements']) as $key) {
914 $variables['content'][$key] = $variables['elements'][$key];
915 }
916
917 // field_attach_preprocess() overwrites the $[field_name] variables with the
918 // values of the field in the language that was selected for display, instead
919 // of the raw values in $term->[field_name], which contain all values in all
920 // languages.
921 field_attach_preprocess('taxonomy_term', $term, $variables['content'], $variables);
922
923 // Gather classes, and clean up name so there are no underscores.
924 $vocabulary_name_css = str_replace('_', '-', $term->vocabulary_machine_name);
925 $variables['classes_array'][] = 'vocabulary-' . $vocabulary_name_css;
926
927 $variables['theme_hook_suggestions'][] = 'taxonomy_term__' . $term->vocabulary_machine_name;
928 $variables['theme_hook_suggestions'][] = 'taxonomy_term__' . $term->tid;
929 }
930
937 function taxonomy_term_is_page($term) {
938 $page_term = menu_get_object('taxonomy_term', 2);
939 return (!empty($page_term) ? $page_term->tid == $term->tid : FALSE);
940 }
941
945 function taxonomy_terms_static_reset() {
946 drupal_static_reset('taxonomy_term_count_nodes');
947 drupal_static_reset('taxonomy_get_tree');
948 drupal_static_reset('taxonomy_get_tree:parents');
949 drupal_static_reset('taxonomy_get_tree:terms');
950 drupal_static_reset('taxonomy_get_parents');
951 drupal_static_reset('taxonomy_get_parents_all');
952 drupal_static_reset('taxonomy_get_children');
953 entity_get_controller('taxonomy_term')->resetCache();
954 }
955
962 function taxonomy_vocabulary_static_reset($ids = NULL) {
963 drupal_static_reset('taxonomy_vocabulary_get_names');
964 entity_get_controller('taxonomy_vocabulary')->resetCache($ids);
965 }
966
973 function taxonomy_get_vocabularies() {
974 return taxonomy_vocabulary_load_multiple(FALSE, array());
975 }
976
987 function taxonomy_vocabulary_get_names() {
988 $names = &drupal_static(__FUNCTION__);
989
990 if (!isset($names)) {
991 $names = db_query('SELECT name, machine_name, vid FROM {taxonomy_vocabulary}')->fetchAllAssoc('machine_name');
992 }
993
994 return $names;
995 }
996
1007 function taxonomy_get_parents($tid) {
1008 $parents = &drupal_static(__FUNCTION__, array());
1009
1010 if ($tid && !isset($parents[$tid])) {
1011 $query = db_select('taxonomy_term_data', 't');
1012 $query->join('taxonomy_term_hierarchy', 'h', 'h.parent = t.tid');
1013 $query->addField('t', 'tid');
1014 $query->condition('h.tid', $tid);
1015 $query->addTag('term_access');
1016 $query->orderBy('t.weight');
1017 $query->orderBy('t.name');
1018 $tids = $query->execute()->fetchCol();
1019 $parents[$tid] = taxonomy_term_load_multiple($tids);
1020 }
1021
1022 return isset($parents[$tid]) ? $parents[$tid] : array();
1023 }
1024
1028 function taxonomy_get_parents_all($tid) {
1029 $cache = &drupal_static(__FUNCTION__, array());
1030
1031 if (isset($cache[$tid])) {
1032 return $cache[$tid];
1033 }
1034
1035 $parents = array();
1036 if ($term = taxonomy_term_load($tid)) {
1037 $parents[] = $term;
1038 $n = 0;
1039 while ($parent = taxonomy_get_parents($parents[$n]->tid)) {
1040 $parents = array_merge($parents, $parent);
1041 $n++;
1042 }
1043 }
1044
1045 $cache[$tid] = $parents;
1046
1047 return $parents;
1048 }
1049
1062 function taxonomy_get_children($tid, $vid = 0) {
1063 $children = &drupal_static(__FUNCTION__, array());
1064
1065 if ($tid && !isset($children[$tid])) {
1066 $query = db_select('taxonomy_term_data', 't');
1067 $query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
1068 $query->addField('t', 'tid');
1069 $query->condition('h.parent', $tid);
1070 if ($vid) {
1071 $query->condition('t.vid', $vid);
1072 }
1073 $query->addTag('term_access');
1074 $query->orderBy('t.weight');
1075 $query->orderBy('t.name');
1076 $tids = $query->execute()->fetchCol();
1077 $children[$tid] = taxonomy_term_load_multiple($tids);
1078 }
1079
1080 return isset($children[$tid]) ? $children[$tid] : array();
1081 }
1082
1105 function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $load_entities = FALSE) {
1106 $children = &drupal_static(__FUNCTION__, array());
1107 $parents = &drupal_static(__FUNCTION__ . ':parents', array());
1108 $terms = &drupal_static(__FUNCTION__ . ':terms', array());
1109
1110 // We cache trees, so it's not CPU-intensive to call taxonomy_get_tree() on a
1111 // term and its children, too.
1112 if (!isset($children[$vid])) {
1113 $children[$vid] = array();
1114 $parents[$vid] = array();
1115 $terms[$vid] = array();
1116
1117 $query = db_select('taxonomy_term_data', 't');
1118 $query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
1119 $result = $query
1120 ->addTag('translatable')
1121 ->addTag('term_access')
1122 ->fields('t')
1123 ->fields('h', array('parent'))
1124 ->condition('t.vid', $vid)
1125 ->orderBy('t.weight')
1126 ->orderBy('t.name')
1127 ->execute();
1128
1129 foreach ($result as $term) {
1130 $children[$vid][$term->parent][] = $term->tid;
1131 $parents[$vid][$term->tid][] = $term->parent;
1132 $terms[$vid][$term->tid] = $term;
1133 }
1134 }
1135
1136 // Load full entities, if necessary. The entity controller statically
1137 // caches the results.
1138 if ($load_entities) {
1139 $term_entities = taxonomy_term_load_multiple(array_keys($terms[$vid]));
1140 }
1141
1142 $max_depth = (!isset($max_depth)) ? count($children[$vid]) : $max_depth;
1143 $tree = array();
1144
1145 // Keeps track of the parents we have to process, the last entry is used
1146 // for the next processing step.
1147 $process_parents = array();
1148 $process_parents[] = $parent;
1149
1150 // Loops over the parent terms and adds its children to the tree array.
1151 // Uses a loop instead of a recursion, because it's more efficient.
1152 while (count($process_parents)) {
1153 $parent = array_pop($process_parents);
1154 // The number of parents determines the current depth.
1155 $depth = count($process_parents);
1156 if ($max_depth > $depth && !empty($children[$vid][$parent])) {
1157 $has_children = FALSE;
1158 $child = current($children[$vid][$parent]);
1159 do {
1160 if (empty($child)) {
1161 break;
1162 }
1163 $term = $load_entities ? $term_entities[$child] : $terms[$vid][$child];
1164 if (isset($parents[$vid][$term->tid])) {
1165 // Clone the term so that the depth attribute remains correct
1166 // in the event of multiple parents.
1167 $term = clone $term;
1168 }
1169 $term->depth = $depth;
1170 unset($term->parent);
1171 $term->parents = $parents[$vid][$term->tid];
1172 $tree[] = $term;
1173 if (!empty($children[$vid][$term->tid])) {
1174 $has_children = TRUE;
1175
1176 // We have to continue with this parent later.
1177 $process_parents[] = $parent;
1178 // Use the current term as parent for the next iteration.
1179 $process_parents[] = $term->tid;
1180
1181 // Reset pointers for child lists because we step in there more often
1182 // with multi parents.
1183 reset($children[$vid][$term->tid]);
1184 // Move pointer so that we get the correct term the next time.
1185 next($children[$vid][$parent]);
1186 break;
1187 }
1188 } while ($child = next($children[$vid][$parent]));
1189
1190 if (!$has_children) {
1191 // We processed all terms in this hierarchy-level, reset pointer
1192 // so that this function works the next time it gets called.
1193 reset($children[$vid][$parent]);
1194 }
1195 }
1196 }
1197
1198 return $tree;
1199 }
1200
1215 function taxonomy_get_term_by_name($name, $vocabulary = NULL) {
1216 $conditions = array('name' => trim($name));
1217 if (isset($vocabulary)) {
1218 $vocabularies = taxonomy_vocabulary_get_names();
1219 if (isset($vocabularies[$vocabulary])) {
1220 $conditions['vid'] = $vocabularies[$vocabulary]->vid;
1221 }
1222 else {
1223 // Return an empty array when filtering by a non-existing vocabulary.
1224 return array();
1225 }
1226 }
1227 return taxonomy_term_load_multiple(array(), $conditions);
1228 }
1229
1236 class TaxonomyTermController extends DrupalDefaultEntityController {
1237
1238 protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
1239 $query = parent::buildQuery($ids, $conditions, $revision_id);
1240 $query->addTag('translatable');
1241 $query->addTag('term_access');
1242 // When name is passed as a condition use LIKE.
1243 if (isset($conditions['name'])) {
1244 $query_conditions = &$query->conditions();
1245 foreach ($query_conditions as $key => $condition) {
1246 if (is_array($condition) && $condition['field'] == 'base.name') {
1247 $query_conditions[$key]['operator'] = 'LIKE';
1248 $query_conditions[$key]['value'] = db_like($query_conditions[$key]['value']);
1249 }
1250 }
1251 }
1252 // Add the machine name field from the {taxonomy_vocabulary} table.
1253 $query->innerJoin('taxonomy_vocabulary', 'v', 'base.vid = v.vid');
1254 $query->addField('v', 'machine_name', 'vocabulary_machine_name');
1255 return $query;
1256 }
1257
1258 protected function cacheGet($ids, $conditions = array()) {
1259 $terms = parent::cacheGet($ids, $conditions);
1260 // Name matching is case insensitive, note that with some collations
1261 // LOWER() and drupal_strtolower() may return different results.
1262 foreach ($terms as $term) {
1263 $term_values = (array) $term;
1264 if (isset($conditions['name']) && drupal_strtolower($conditions['name'] != drupal_strtolower($term_values['name']))) {
1265 unset($terms[$term->tid]);
1266 }
1267 }
1268 return $terms;
1269 }
1270 }
1271
1278 class TaxonomyVocabularyController extends DrupalDefaultEntityController {
1279
1280 protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
1281 $query = parent::buildQuery($ids, $conditions, $revision_id);
1282 $query->addTag('translatable');
1283 $query->orderBy('base.weight');
1284 $query->orderBy('base.name');
1285 return $query;
1286 }
1287 }
1288
1314 function taxonomy_term_load_multiple($tids = array(), $conditions = array()) {
1315 return entity_load('taxonomy_term', $tids, $conditions);
1316 }
1317
1335 function taxonomy_vocabulary_load_multiple($vids = array(), $conditions = array()) {
1336 return entity_load('taxonomy_vocabulary', $vids, $conditions);
1337 }
1338
1351 function taxonomy_vocabulary_load($vid) {
1352 $vocabularies = taxonomy_vocabulary_load_multiple(array($vid));
1353 return reset($vocabularies);
1354 }
1355
1368 function taxonomy_vocabulary_machine_name_load($name) {
1369 $vocabularies = taxonomy_vocabulary_load_multiple(NULL, array('machine_name' => $name));
1370 return reset($vocabularies);
1371 }
1372
1383 function taxonomy_term_load($tid) {
1384 if (!is_numeric($tid)) {
1385 return FALSE;
1386 }
1387 $term = taxonomy_term_load_multiple(array($tid), array());
1388 return $term ? $term[$tid] : FALSE;
1389 }
1390
1394 function _taxonomy_get_tid_from_term($term) {
1395 return $term->tid;
1396 }
1397
1403 function taxonomy_implode_tags($tags, $vid = NULL) {
1404 $typed_tags = array();
1405 foreach ($tags as $tag) {
1406 // Extract terms belonging to the vocabulary in question.
1407 if (!isset($vid) || $tag->vid == $vid) {
1408 // Make sure we have a completed loaded taxonomy term.
1409 if (isset($tag->name)) {
1410 // Commas and quotes in tag names are special cases, so encode 'em.
1411 if (strpos($tag->name, ',') !== FALSE || strpos($tag->name, '"') !== FALSE) {
1412 $typed_tags[] = '"' . str_replace('"', '""', $tag->name) . '"';
1413 }
1414 else {
1415 $typed_tags[] = $tag->name;
1416 }
1417 }
1418 }
1419 }
1420 return implode(', ', $typed_tags);
1421 }
1422
1434 function taxonomy_field_info() {
1435 return array(
1436 'taxonomy_term_reference' => array(
1437 'label' => t('Term reference'),
1438 'description' => t('This field stores a reference to a taxonomy term.'),
1439 'default_widget' => 'options_select',
1440 'default_formatter' => 'taxonomy_term_reference_link',
1441 'settings' => array(
1442 'allowed_values' => array(
1443 array(
1444 'vocabulary' => '',
1445 'parent' => '0',
1446 ),
1447 ),
1448 ),
1449 ),
1450 );
1451 }
1452
1456 function taxonomy_field_widget_info() {
1457 return array(
1458 'taxonomy_autocomplete' => array(
1459 'label' => t('Autocomplete term widget (tagging)'),
1460 'field types' => array('taxonomy_term_reference'),
1461 'settings' => array(
1462 'size' => 60,
1463 'autocomplete_path' => 'taxonomy/autocomplete',
1464 ),
1465 'behaviors' => array(
1466 'multiple values' => FIELD_BEHAVIOR_CUSTOM,
1467 ),
1468 ),
1469 );
1470 }
1471
1475 function taxonomy_field_widget_info_alter(&$info) {
1476 $info['options_select']['field types'][] = 'taxonomy_term_reference';
1477 $info['options_buttons']['field types'][] = 'taxonomy_term_reference';
1478 }
1479
1483 function taxonomy_options_list($field, $instance, $entity_type, $entity) {
1484 $function = !empty($field['settings']['options_list_callback']) ? $field['settings']['options_list_callback'] : 'taxonomy_allowed_values';
1485 return $function($field);
1486 }
1487
1499 function taxonomy_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
1500 // Build an array of existing term IDs so they can be loaded with
1501 // taxonomy_term_load_multiple();
1502 foreach ($items as $delta => $item) {
1503 if (!empty($item['tid']) && $item['tid'] != 'autocreate') {
1504 $tids[] = $item['tid'];
1505 }
1506 }
1507 if (!empty($tids)) {
1508 $terms = taxonomy_term_load_multiple($tids);
1509
1510 // Check each existing item to ensure it can be found in the
1511 // allowed values for this field.
1512 foreach ($items as $delta => $item) {
1513 $validate = TRUE;
1514 if (!empty($item['tid']) && $item['tid'] != 'autocreate') {
1515 $validate = FALSE;
1516 foreach ($field['settings']['allowed_values'] as $settings) {
1517 // If no parent is specified, check if the term is in the vocabulary.
1518 if (isset($settings['vocabulary']) && empty($settings['parent'])) {
1519 if ($settings['vocabulary'] == $terms[$item['tid']]->vocabulary_machine_name) {
1520 $validate = TRUE;
1521 break;
1522 }
1523 }
1524 // If a parent is specified, then to validate it must appear in the
1525 // array returned by taxonomy_get_parents_all().
1526 elseif (!empty($settings['parent'])) {
1527 $ancestors = taxonomy_get_parents_all($item['tid']);
1528 foreach ($ancestors as $ancestor) {
1529 if ($ancestor->tid == $settings['parent']) {
1530 $validate = TRUE;
1531 break 2;
1532 }
1533 }
1534 }
1535 }
1536 }
1537 if (!$validate) {
1538 $errors[$field['field_name']][$langcode][$delta][] = array(
1539 'error' => 'taxonomy_term_reference_illegal_value',
1540 'message' => t('%name: illegal value.', array('%name' => $instance['label'])),
1541 );
1542 }
1543 }
1544 }
1545 }
1546
1550 function taxonomy_field_is_empty($item, $field) {
1551 if (!is_array($item) || (empty($item['tid']) && (string) $item['tid'] !== '0')) {
1552 return TRUE;
1553 }
1554 return FALSE;
1555 }
1556
1560 function taxonomy_field_formatter_info() {
1561 return array(
1562 'taxonomy_term_reference_link' => array(
1563 'label' => t('Link'),
1564 'field types' => array('taxonomy_term_reference'),
1565 ),
1566 'taxonomy_term_reference_plain' => array(
1567 'label' => t('Plain text'),
1568 'field types' => array('taxonomy_term_reference'),
1569 ),
1570 'taxonomy_term_reference_rss_category' => array(
1571 'label' => t('RSS category'),
1572 'field types' => array('taxonomy_term_reference'),
1573 ),
1574 );
1575 }
1576
1580 function taxonomy_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
1581 $element = array();
1582
1583 // Terms whose tid is 'autocreate' do not exist
1584 // yet and $item['taxonomy_term'] is not set. Theme such terms as
1585 // just their name.
1586
1587 switch ($display['type']) {
1588 case 'taxonomy_term_reference_link':
1589 foreach ($items as $delta => $item) {
1590 if ($item['tid'] == 'autocreate') {
1591 $element[$delta] = array(
1592 '#markup' => check_plain($item['name']),
1593 );
1594 }
1595 else {
1596 $term = $item['taxonomy_term'];
1597 $uri = entity_uri('taxonomy_term', $term);
1598 $element[$delta] = array(
1599 '#type' => 'link',
1600 '#title' => $term->name,
1601 '#href' => $uri['path'],
1602 '#options' => $uri['options'],
1603 );
1604 }
1605 }
1606 break;
1607
1608 case 'taxonomy_term_reference_plain':
1609 foreach ($items as $delta => $item) {
1610 $name = ($item['tid'] != 'autocreate' ? $item['taxonomy_term']->name : $item['name']);
1611 $element[$delta] = array(
1612 '#markup' => check_plain($name),
1613 );
1614 }
1615 break;
1616
1617 case 'taxonomy_term_reference_rss_category':
1618 foreach ($items as $delta => $item) {
1619 $entity->rss_elements[] = array(
1620 'key' => 'category',
1621 'value' => $item['tid'] != 'autocreate' ? $item['taxonomy_term']->name : $item['name'],
1622 'attributes' => array(
1623 'domain' => $item['tid'] != 'autocreate' ? url('taxonomy/term/' . $item['tid'], array('absolute' => TRUE)) : '',
1624 ),
1625 );
1626 }
1627 break;
1628 }
1629
1630 return $element;
1631 }
1632
1641 function taxonomy_allowed_values($field) {
1642 $options = array();
1643 foreach ($field['settings']['allowed_values'] as $tree) {
1644 if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) {
1645 if ($terms = taxonomy_get_tree($vocabulary->vid, $tree['parent'])) {
1646 foreach ($terms as $term) {
1647 $options[$term->tid] = str_repeat('-', $term->depth) . $term->name;
1648 }
1649 }
1650 }
1651 }
1652 return $options;
1653 }
1654
1661 function taxonomy_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) {
1662 $tids = array();
1663
1664 // Collect every possible term attached to any of the fieldable entities.
1665 foreach ($entities as $id => $entity) {
1666 foreach ($items[$id] as $delta => $item) {
1667 // Force the array key to prevent duplicates.
1668 if ($item['tid'] != 'autocreate') {
1669 $tids[$item['tid']] = $item['tid'];
1670 }
1671 }
1672 }
1673 if ($tids) {
1674 $terms = taxonomy_term_load_multiple($tids);
1675
1676 // Iterate through the fieldable entities again to attach the loaded term data.
1677 foreach ($entities as $id => $entity) {
1678 $rekey = FALSE;
1679
1680 foreach ($items[$id] as $delta => $item) {
1681 // Check whether the taxonomy term field instance value could be loaded.
1682 if (isset($terms[$item['tid']])) {
1683 // Replace the instance value with the term data.
1684 $items[$id][$delta]['taxonomy_term'] = $terms[$item['tid']];
1685 }
1686 // Terms to be created are not in $terms, but are still legitimate.
1687 elseif ($item['tid'] == 'autocreate') {
1688 // Leave the item in place.
1689 }
1690 // Otherwise, unset the instance value, since the term does not exist.
1691 else {
1692 unset($items[$id][$delta]);
1693 $rekey = TRUE;
1694 }
1695 }
1696
1697 if ($rekey) {
1698 // Rekey the items array.
1699 $items[$id] = array_values($items[$id]);
1700 }
1701 }
1702 }
1703 }
1704
1714 function taxonomy_term_title($term) {
1715 return $term->name;
1716 }
1717
1721 function taxonomy_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
1722 $tags = array();
1723 foreach ($items as $item) {
1724 $tags[$item['tid']] = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['tid']);
1725 }
1726
1727 $element += array(
1728 '#type' => 'textfield',
1729 '#default_value' => taxonomy_implode_tags($tags),
1730 '#autocomplete_path' => $instance['widget']['settings']['autocomplete_path'] . '/' . $field['field_name'],
1731 '#size' => $instance['widget']['settings']['size'],
1732 '#maxlength' => 1024,
1733 '#element_validate' => array('taxonomy_autocomplete_validate'),
1734 );
1735
1736 return $element;
1737 }
1738
1742 function taxonomy_autocomplete_validate($element, &$form_state) {
1743 // Autocomplete widgets do not send their tids in the form, so we must detect
1744 // them here and process them independently.
1745 $value = array();
1746 if ($tags = $element['#value']) {
1747 // Collect candidate vocabularies.
1748 $field = field_widget_field($element, $form_state);
1749 $vocabularies = array();
1750 foreach ($field['settings']['allowed_values'] as $tree) {
1751 if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) {
1752 $vocabularies[$vocabulary->vid] = $vocabulary;
1753 }
1754 }
1755
1756 // Translate term names into actual terms.
1757 $typed_terms = drupal_explode_tags($tags);
1758 foreach ($typed_terms as $typed_term) {
1759 // See if the term exists in the chosen vocabulary and return the tid;
1760 // otherwise, create a new 'autocreate' term for insert/update.
1761 if ($possibilities = taxonomy_term_load_multiple(array(), array('name' => trim($typed_term), 'vid' => array_keys($vocabularies)))) {
1762 $term = array_pop($possibilities);
1763 }
1764 else {
1765 $vocabulary = reset($vocabularies);
1766 $term = array(
1767 'tid' => 'autocreate',
1768 'vid' => $vocabulary->vid,
1769 'name' => $typed_term,
1770 'vocabulary_machine_name' => $vocabulary->machine_name,
1771 );
1772 }
1773 $value[] = (array)$term;
1774 }
1775 }
1776
1777 form_set_value($element, $value, $form_state);
1778 }
1779
1783 function taxonomy_field_widget_error($element, $error, $form, &$form_state) {
1784 form_error($element, $error['message']);
1785 }
1789 function taxonomy_field_settings_form($field, $instance, $has_data) {
1790 // Get proper values for 'allowed_values_function', which is a core setting.
1791 $vocabularies = taxonomy_get_vocabularies();
1792 $options = array();
1793 foreach ($vocabularies as $vocabulary) {
1794 $options[$vocabulary->machine_name] = $vocabulary->name;
1795 }
1796 $form['allowed_values'] = array(
1797 '#tree' => TRUE,
1798 );
1799
1800 foreach ($field['settings']['allowed_values'] as $delta => $tree) {
1801 $form['allowed_values'][$delta]['vocabulary'] = array(
1802 '#type' => 'select',
1803 '#title' => t('Vocabulary'),
1804 '#default_value' => $tree['vocabulary'],
1805 '#options' => $options,
1806 '#required' => TRUE,
1807 '#description' => t('The vocabulary which supplies the options for this field.'),
1808 '#disabled' => $has_data,
1809 );
1810 $form['allowed_values'][$delta]['parent'] = array(
1811 '#type' => 'value',
1812 '#value' => $tree['parent'],
1813 );
1814 }
1815
1816 return $form;
1817 }
1818
1825 function taxonomy_rdf_mapping() {
1826 return array(
1827 array(
1828 'type' => 'taxonomy_term',
1829 'bundle' => RDF_DEFAULT_BUNDLE,
1830 'mapping' => array(
1831 'rdftype' => array('skos:Concept'),
1832 'name' => array(
1833 'predicates' => array('rdfs:label', 'skos:prefLabel'),
1834 ),
1835 'description' => array(
1836 'predicates' => array('skos:definition'),
1837 ),
1838 'vid' => array(
1839 'predicates' => array('skos:inScheme'),
1840 'type' => 'rel',
1841 ),
1842 'parent' => array(
1843 'predicates' => array('skos:broader'),
1844 'type' => 'rel',
1845 ),
1846 ),
1847 ),
1848 array(
1849 'type' => 'taxonomy_vocabulary',
1850 'bundle' => RDF_DEFAULT_BUNDLE,
1851 'mapping' => array(
1852 'rdftype' => array('skos:ConceptScheme'),
1853 'name' => array(
1854 'predicates' => array('dc:title'),
1855 ),
1856 'description' => array(
1857 'predicates' => array('rdfs:comment'),
1858 ),
1859 ),
1860 ),
1861 );
1862 }
1863
1887 function taxonomy_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
1888 foreach ($items as $delta => $item) {
1889 if ($item['tid'] == 'autocreate') {
1890 $term = (object) $item;
1891 unset($term->tid);
1892 taxonomy_term_save($term);
1893 $items[$delta]['tid'] = $term->tid;
1894 }
1895 }
1896 }
1897
1901 function taxonomy_node_insert($node) {
1902 // Add taxonomy index entries for the node.
1903 taxonomy_build_node_index($node);
1904 }
1905
1915 function taxonomy_build_node_index($node) {
1916 // We maintain a denormalized table of term/node relationships, containing
1917 // only data for current, published nodes.
1918 $status = NULL;
1919 if (variable_get('taxonomy_maintain_index_table', TRUE)) {
1920 // If a node property is not set in the node object when node_save() is
1921 // called, the old value from $node->original is used.
1922 if (!empty($node->original)) {
1923 $status = (int)(!empty($node->status) || (!isset($node->status) && !empty($node->original->status)));
1924 $sticky = (int)(!empty($node->sticky) || (!isset($node->sticky) && !empty($node->original->sticky)));
1925 }
1926 else {
1927 $status = (int)(!empty($node->status));
1928 $sticky = (int)(!empty($node->sticky));
1929 }
1930 }
1931 // We only maintain the taxonomy index for published nodes.
1932 if ($status) {
1933 // Collect a unique list of all the term IDs from all node fields.
1934 $tid_all = array();
1935 foreach (field_info_instances('node', $node->type) as $instance) {
1936 $field_name = $instance['field_name'];
1937 $field = field_info_field($field_name);
1938 if ($field['module'] == 'taxonomy' && $field['storage']['type'] == 'field_sql_storage') {
1939 // If a field value is not set in the node object when node_save() is
1940 // called, the old value from $node->original is used.
1941 if (isset($node->{$field_name})) {
1942 $items = $node->{$field_name};
1943 }
1944 elseif (isset($node->original->{$field_name})) {
1945 $items = $node->original->{$field_name};
1946 }
1947 else {
1948 continue;
1949 }
1950 foreach (field_available_languages('node', $field) as $langcode) {
1951 if (!empty($items[$langcode])) {
1952 foreach ($items[$langcode] as $item) {
1953 $tid_all[$item['tid']] = $item['tid'];
1954 }
1955 }
1956 }
1957 }
1958 }
1959 // Insert index entries for all the node's terms.
1960 if (!empty($tid_all)) {
1961 $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created'));
1962 foreach ($tid_all as $tid) {
1963 $query->values(array(
1964 'nid' => $node->nid,
1965 'tid' => $tid,
1966 'sticky' => $sticky,
1967 'created' => $node->created,
1968 ));
1969 }
1970 $query->execute();
1971 }
1972 }
1973 }
1974
1978 function taxonomy_node_update($node) {
1979 // Always rebuild the node's taxonomy index entries on node save.
1980 taxonomy_delete_node_index($node);
1981 taxonomy_build_node_index($node);
1982 }
1983
1987 function taxonomy_node_delete($node) {
1988 // Clean up the {taxonomy_index} table when nodes are deleted.
1989 taxonomy_delete_node_index($node);
1990 }
1991
1998 function taxonomy_delete_node_index($node) {
1999 if (variable_get('taxonomy_maintain_index_table', TRUE)) {
2000 db_delete('taxonomy_index')->condition('nid', $node->nid)->execute();
2001 }
2002 }
2003
2007 function taxonomy_taxonomy_term_delete($term) {
2008 if (variable_get('taxonomy_maintain_index_table', TRUE)) {
2009 // Clean up the {taxonomy_index} table when terms are deleted.
2010 db_delete('taxonomy_index')->condition('tid', $term->tid)->execute();
2011 }
2012 }
2013
2027 function taxonomy_entity_query_alter($query) {
2028 $conditions = &$query->entityConditions;
2029
2030 // Alter only taxonomy term queries with bundle conditions.
2031 if (isset($conditions['entity_type']) && $conditions['entity_type']['value'] == 'taxonomy_term' && isset($conditions['bundle'])) {
2032 // Convert vocabulary machine names to vocabulary IDs.
2033 $vocabulary_data = taxonomy_vocabulary_get_names();
2034 $vids = array();
2035 if (is_array($conditions['bundle']['value'])) {
2036 foreach ($conditions['bundle']['value'] as $vocabulary_machine_name) {
2037 $vids[] = $vocabulary_data[$vocabulary_machine_name]->vid;
2038 }
2039 }
2040 else {
2041 $vocabulary_machine_name = $conditions['bundle']['value'];
2042 $vids = $vocabulary_data[$vocabulary_machine_name]->vid;
2043 }
2044
2045 $query->propertyCondition('vid', $vids, $conditions['bundle']['operator']);
2046 unset($conditions['bundle']);
2047 }
2048 }
taxonomy_field_settings_form
taxonomy_field_settings_form($field, $instance, $has_data)
Definition: taxonomy.module:1789
field_read_fields
field_read_fields($params=array(), $include_additional=array())
Definition: field.crud.inc:340
TaxonomyTermController::buildQuery
buildQuery($ids, $conditions=array(), $revision_id=FALSE)
Definition: taxonomy.module:1238
field_extra_fields_get_display
field_extra_fields_get_display($entity_type, $bundle, $view_mode)
Definition: field.module:684
$pager
print $pager
Definition: aggregator-wrapper.tpl.php:19
watchdog_exception
watchdog_exception($type, Exception $exception, $message=NULL, $variables=array(), $severity=WATCHDOG_ERROR, $link=NULL)
Definition: bootstrap.inc:1654
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
$op
$op
Definition: update.php:404
taxonomy_field_info
taxonomy_field_info()
Definition: taxonomy.module:1434
taxonomy_term_show
taxonomy_term_show($term)
Definition: taxonomy.module:753
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
taxonomy_node_update
taxonomy_node_update($node)
Definition: taxonomy.module:1978
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
taxonomy_field_widget_error
taxonomy_field_widget_error($element, $error, $form, &$form_state)
Definition: taxonomy.module:1783
entity_load
entity_load($entity_type, $ids=FALSE, $conditions=array(), $reset=FALSE)
Definition: common.inc:7800
taxonomy_get_parents_all
taxonomy_get_parents_all($tid)
Definition: taxonomy.module:1028
drupal_strtolower
drupal_strtolower($text)
Definition: unicode.inc:521
taxonomy_vocabulary_machine_name_load
taxonomy_vocabulary_machine_name_load($name)
Definition: taxonomy.module:1368
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
tid
print $term tid
Definition: taxonomy-term.tpl.php:44
taxonomy_vocabulary_save
taxonomy_vocabulary_save($vocabulary)
Definition: taxonomy.module:413
taxonomy_field_widget_info
taxonomy_field_widget_info()
Definition: taxonomy.module:1456
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
field_info_instances
field_info_instances($entity_type=NULL, $bundle_name=NULL)
Definition: field.info.inc:592
taxonomy_terms_static_reset
taxonomy_terms_static_reset()
Definition: taxonomy.module:945
field_available_languages
field_available_languages($entity_type, $field)
Definition: field.multilingual.inc:89
taxonomy_menu
taxonomy_menu()
Definition: taxonomy.module:259
field_attach_update
field_attach_update($entity_type, $entity)
Definition: field.attach.inc:990
taxonomy_vocabulary_load_multiple
taxonomy_vocabulary_load_multiple($vids=array(), $conditions=array())
Definition: taxonomy.module:1335
_taxonomy_get_tid_from_term
_taxonomy_get_tid_from_term($term)
Definition: taxonomy.module:1394
taxonomy_field_widget_info_alter
taxonomy_field_widget_info_alter(&$info)
Definition: taxonomy.module:1475
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
Exception
name
print $forum name
Definition: forum-list.tpl.php:57
field_attach_prepare_view
field_attach_prepare_view($entity_type, $entities, $view_mode, $langcode=NULL, $options=array())
Definition: field.attach.inc:1133
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
taxonomy_rdf_mapping
taxonomy_rdf_mapping()
Definition: taxonomy.module:1825
taxonomy_field_formatter_prepare_view
taxonomy_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays)
Definition: taxonomy.module:1661
field_attach_presave
field_attach_presave($entity_type, $entity)
Definition: field.attach.inc:913
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
SAVED_DELETED
const SAVED_DELETED
Definition: common.inc:55
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
taxonomy_help
taxonomy_help($path, $arg)
Definition: taxonomy.module:19
taxonomy_term_uri
taxonomy_term_uri($term)
Definition: taxonomy.module:145
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
template_preprocess_taxonomy_term
template_preprocess_taxonomy_term(&$variables)
Definition: taxonomy.module:898
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
taxonomy_node_insert
taxonomy_node_insert($node)
Definition: taxonomy.module:1901
taxonomy_term_delete
taxonomy_term_delete($tid)
Definition: taxonomy.module:701
taxonomy_term_view_multiple
taxonomy_term_view_multiple($terms, $view_mode= 'teaser', $weight=0, $langcode=NULL)
Definition: taxonomy.module:773
entity_uri
entity_uri($entity_type, $entity)
Definition: common.inc:7902
TaxonomyVocabularyController::buildQuery
buildQuery($ids, $conditions=array(), $revision_id=FALSE)
Definition: taxonomy.module:1280
taxonomy_autocomplete_validate
taxonomy_autocomplete_validate($element, &$form_state)
Definition: taxonomy.module:1742
taxonomy_vocabulary_load
taxonomy_vocabulary_load($vid)
Definition: taxonomy.module:1351
taxonomy_vocabulary_delete
taxonomy_vocabulary_delete($vid)
Definition: taxonomy.module:467
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
taxonomy_node_delete
taxonomy_node_delete($node)
Definition: taxonomy.module:1987
taxonomy_field_is_empty
taxonomy_field_is_empty($item, $field)
Definition: taxonomy.module:1550
field_view_mode_settings
field_view_mode_settings($entity_type, $bundle)
Definition: field.module:617
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
field_attach_insert
field_attach_insert($entity_type, $entity)
Definition: field.attach.inc:936
taxonomy_allowed_values
taxonomy_allowed_values($field)
Definition: taxonomy.module:1641
taxonomy_options_list
taxonomy_options_list($field, $instance, $entity_type, $entity)
Definition: taxonomy.module:1483
$info
$info
Definition: color.inc:6
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
taxonomy_term_title
taxonomy_term_title($term)
Definition: taxonomy.module:1714
entity_load_unchanged
entity_load_unchanged($entity_type, $id)
Definition: common.inc:7823
taxonomy_entity_info
taxonomy_entity_info()
Definition: taxonomy.module:91
taxonomy_vocabulary_static_reset
taxonomy_vocabulary_static_reset($ids=NULL)
Definition: taxonomy.module:962
taxonomy_vocabulary_get_names
taxonomy_vocabulary_get_names()
Definition: taxonomy.module:987
TaxonomyVocabularyController
Definition: taxonomy.module:1278
$value
print $value
Definition: user-profile-item.tpl.php:26
taxonomy_get_term_by_name
taxonomy_get_term_by_name($name, $vocabulary=NULL)
Definition: taxonomy.module:1215
$output
$output
Definition: authorize.php:93
FIELD_BEHAVIOR_CUSTOM
const FIELD_BEHAVIOR_CUSTOM
Definition: field.module:262
taxonomy_field_widget_form
taxonomy_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
Definition: taxonomy.module:1721
$depth
print $depth
Definition: book-node-export-html.tpl.php:21
taxonomy_field_validate
taxonomy_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
Definition: taxonomy.module:1499
taxonomy_field_formatter_info
taxonomy_field_formatter_info()
Definition: taxonomy.module:1560
db_like
db_like($string)
Definition: database.inc:2610
user_access
user_access($string, $account=NULL)
Definition: user.module:794
taxonomy_taxonomy_term_delete
taxonomy_taxonomy_term_delete($term)
Definition: taxonomy.module:2007
field_attach_preprocess
field_attach_preprocess($entity_type, $entity, $element, &$variables)
Definition: field.attach.inc:1272
taxonomy_theme
taxonomy_theme()
Definition: taxonomy.module:241
RDF_DEFAULT_BUNDLE
const RDF_DEFAULT_BUNDLE
Definition: rdf.module:74
taxonomy_get_vocabularies
taxonomy_get_vocabularies()
Definition: taxonomy.module:973
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
TaxonomyTermController
Definition: taxonomy.module:1236
TaxonomyTermController::cacheGet
cacheGet($ids, $conditions=array())
Definition: taxonomy.module:1258
entity_prepare_view
entity_prepare_view($entity_type, $entities, $langcode=NULL)
Definition: common.inc:7866
taxonomy_term_build_content
taxonomy_term_build_content($term, $view_mode= 'full', $langcode=NULL)
Definition: taxonomy.module:806
taxonomy_admin_vocabulary_title_callback
taxonomy_admin_vocabulary_title_callback($vocabulary)
Definition: taxonomy.module:386
drupal_ucfirst
drupal_ucfirst($text)
Definition: unicode.inc:561
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
field_delete_field
field_delete_field($field_name)
Definition: field.crud.inc:411
taxonomy_permission
taxonomy_permission()
Definition: taxonomy.module:67
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
taxonomy_term_is_page
taxonomy_term_is_page($term)
Definition: taxonomy.module:937
db_transaction
db_transaction($name=NULL, array $options=array())
Definition: database.inc:2535
entity_get_controller
entity_get_controller($entity_type)
Definition: common.inc:7832
field_attach_rename_bundle
field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new)
Definition: field.attach.inc:1360
field_attach_view
field_attach_view($entity_type, $entity, $view_mode, $langcode=NULL, $options=array())
Definition: field.attach.inc:1216
drupal_explode_tags
drupal_explode_tags($tags)
Definition: common.inc:7408
taxonomy_get_children
taxonomy_get_children($tid, $vid=0)
Definition: taxonomy.module:1062
taxonomy_check_vocabulary_hierarchy
taxonomy_check_vocabulary_hierarchy($vocabulary, $changed_term)
Definition: taxonomy.module:564
DrupalDefaultEntityController
Definition: entity.inc:46
taxonomy_get_parents
taxonomy_get_parents($tid)
Definition: taxonomy.module:1007
field_attach_delete_bundle
field_attach_delete_bundle($entity_type, $bundle)
Definition: field.attach.inc:1394
taxonomy_field_presave
taxonomy_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: taxonomy.module:1887
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$children
print $children
Definition: book-node-export-html.tpl.php:24
taxonomy_field_formatter_view
taxonomy_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
Definition: taxonomy.module:1580
taxonomy_select_nodes
taxonomy_select_nodes($tid, $pager=TRUE, $limit=FALSE, $order=array('t.sticky'=> 'DESC', 't.created'=> 'DESC'))
Definition: taxonomy.module:204
taxonomy_entity_query_alter
taxonomy_entity_query_alter($query)
Definition: taxonomy.module:2027
taxonomy_admin_paths
taxonomy_admin_paths()
Definition: taxonomy.module:363
field_attach_create_bundle
field_attach_create_bundle($entity_type, $bundle)
Definition: field.attach.inc:1342
field_widget_field
field_widget_field($element, $form_state)
Definition: field.form.inc:576
taxonomy_get_tree
taxonomy_get_tree($vid, $parent=0, $max_depth=NULL, $load_entities=FALSE)
Definition: taxonomy.module:1105
check_markup
check_markup($text, $format_id=NULL, $langcode= '', $cache=FALSE)
Definition: filter.module:759
taxonomy_term_load
taxonomy_term_load($tid)
Definition: taxonomy.module:1383
$tree
if($tree||$has_links) print $tree
Definition: book-navigation.tpl.php:35
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
field_update_field
field_update_field($field)
Definition: field.crud.inc:220
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
taxonomy_term_view
taxonomy_term_view($term, $view_mode= 'full', $langcode=NULL)
Definition: taxonomy.module:867
taxonomy_taxonomy_vocabulary_update
taxonomy_taxonomy_vocabulary_update($vocabulary)
Definition: taxonomy.module:524
entity_extract_ids
entity_extract_ids($entity_type, $entity)
Definition: common.inc:7711
taxonomy_delete_node_index
taxonomy_delete_node_index($node)
Definition: taxonomy.module:1998
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
taxonomy_term_edit_access
taxonomy_term_edit_access($term)
Definition: taxonomy.module:373
taxonomy_term_save
taxonomy_term_save($term)
Definition: taxonomy.module:621
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
menu_get_object
menu_get_object($type= 'node', $position=1, $path=NULL)
Definition: menu.inc:971
taxonomy_build_node_index
taxonomy_build_node_index($node)
Definition: taxonomy.module:1915
taxonomy_implode_tags
taxonomy_implode_tags($tags, $vid=NULL)
Definition: taxonomy.module:1403
taxonomy_term_load_multiple
taxonomy_term_load_multiple($tids=array(), $conditions=array())
Definition: taxonomy.module:1314
taxonomy_field_extra_fields
taxonomy_field_extra_fields()
Definition: taxonomy.module:154
field_attach_delete
field_attach_delete($entity_type, $entity)
Definition: field.attach.inc:1045
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/color/color.inc Source File

  • themes
  • garland
  • color
color.inc
Go to the documentation of this file.
1 <?php
2
3 $info = array(
4
5 // Available colors and color labels used in theme.
6 'fields' => array(
7 'base' => t('Base color'),
8 'link' => t('Link color'),
9 'top' => t('Header top'),
10 'bottom' => t('Header bottom'),
11 'text' => t('Text color'),
12 ),
13 // Pre-defined color schemes.
14 'schemes' => array(
15 'default' => array(
16 'title' => t('Blue Lagoon (Default)'),
17 'colors' => array(
18 'base' => '#0072b9',
19 'link' => '#027ac6',
20 'top' => '#2385c2',
21 'bottom' => '#5ab5ee',
22 'text' => '#494949',
23 ),
24 ),
25 'ash' => array(
26 'title' => t('Ash'),
27 'colors' => array(
28 'base' => '#464849',
29 'link' => '#2f416f',
30 'top' => '#2a2b2d',
31 'bottom' => '#5d6779',
32 ),
33 ),
34 'aquamarine' => array(
35 'title' => t('Aquamarine'),
36 'colors' => array(
37 'base' => '#55c0e2',
38 'link' => '#000000',
39 'text' => '#696969',
40 'top' => '#085360',
41 'bottom' => '#007e94',
42 ),
43 ),
44 'chocolate' => array(
45 'title' => t('Belgian Chocolate'),
46 'colors' => array(
47 'base' => '#d5b048',
48 'link' => '#6c420e',
49 'top' => '#331900',
50 'bottom' => '#971702',
51 ),
52 ),
53 'bluemarine' => array(
54 'title' => t('Bluemarine'),
55 'colors' => array(
56 'base' => '#3f3f3f',
57 'link' => '#336699',
58 'text' => '#000000',
59 'top' => '#6598cb',
60 'bottom' => '#6598cb',
61 ),
62 ),
63 'citrus' => array(
64 'title' => t('Citrus Blast'),
65 'colors' => array(
66 'base' => '#d0cb9a',
67 'link' => '#917803',
68 'top' => '#efde01',
69 'bottom' => '#e6fb2d',
70 ),
71 ),
72 'cold' => array(
73 'title' => t('Cold Day'),
74 'colors' => array(
75 'base' => '#0f005c',
76 'link' => '#434f8c',
77 'text' => '#000000',
78 'top' => '#4d91ff',
79 'bottom' => '#1a1575',
80 ),
81 ),
82 'greenbeam' => array(
83 'title' => t('Greenbeam'),
84 'colors' => array(
85 'base' => '#c9c497',
86 'link' => '#0c7a00',
87 'top' => '#03961e',
88 'bottom' => '#7be000',
89 ),
90 ),
91 'mediterrano' => array(
92 'title' => t('Mediterrano'),
93 'colors' => array(
94 'base' => '#ffe23d',
95 'link' => '#a9290a',
96 'top' => '#fc6d1d',
97 'bottom' => '#a30f42',
98 ),
99 ),
100 'mercury' => array(
101 'title' => t('Mercury'),
102 'colors' => array(
103 'base' => '#788597',
104 'link' => '#3f728d',
105 'top' => '#a9adbc',
106 'bottom' => '#d4d4d4',
107 'text' => '#707070',
108 ),
109 ),
110 'nocturnal' => array(
111 'title' => t('Nocturnal'),
112 'colors' => array(
113 'base' => '#5b5fa9',
114 'link' => '#5b5faa',
115 'top' => '#0a2352',
116 'bottom' => '#9fa8d5',
117 ),
118 ),
119 'olivia' => array(
120 'title' => t('Olivia'),
121 'colors' => array(
122 'base' => '#7db323',
123 'link' => '#6a9915',
124 'top' => '#b5d52a',
125 'bottom' => '#7db323',
126 'text' => '#191a19',
127 ),
128 ),
129 'pink_plastic' => array(
130 'title' => t('Pink Plastic'),
131 'colors' => array(
132 'base' => '#12020b',
133 'link' => '#1b1a13',
134 'top' => '#f391c6',
135 'bottom' => '#f41063',
136 'text' => '#898080',
137 ),
138 ),
139 'shiny_tomato' => array(
140 'title' => t('Shiny Tomato'),
141 'colors' => array(
142 'base' => '#b7a0ba',
143 'link' => '#c70000',
144 'top' => '#a1443a',
145 'bottom' => '#f21107',
146 'text' => '#515d52',
147 ),
148 ),
149 'teal_top' => array(
150 'title' => t('Teal Top'),
151 'colors' => array(
152 'base' => '#18583d',
153 'link' => '#1b5f42',
154 'top' => '#34775a',
155 'bottom' => '#52bf90',
156 'text' => '#2d2d2d',
157 ),
158 ),
159 ),
160
161 // Images to copy over.
162 'copy' => array(
163 'images/menu-collapsed.gif',
164 'images/menu-collapsed-rtl.gif',
165 'images/menu-expanded.gif',
166 'images/menu-leaf.gif',
167 ),
168
169 // CSS files (excluding @import) to rewrite with new color scheme.
170 'css' => array(
171 'style.css',
172 ),
173
174 // Gradient definitions.
175 'gradients' => array(
176 array(
177 // (x, y, width, height).
178 'dimension' => array(0, 38, 760, 121),
179 // Direction of gradient ('vertical' or 'horizontal').
180 'direction' => 'vertical',
181 // Keys of colors to use for the gradient.
182 'colors' => array('top', 'bottom'),
183 ),
184 ),
185
186 // Color areas to fill (x, y, width, height).
187 'fill' => array(
188 'base' => array(0, 0, 760, 568),
189 'link' => array(107, 533, 41, 23),
190 ),
191
192 // Coordinates of all the theme slices (x, y, width, height)
193 // with their filename as used in the stylesheet.
194 'slices' => array(
195 'images/body.png' => array(0, 37, 1, 280),
196 'images/bg-bar.png' => array(202, 530, 76, 14),
197 'images/bg-bar-white.png' => array(202, 506, 76, 14),
198 'images/bg-tab.png' => array(107, 533, 41, 23),
199 'images/bg-navigation.png' => array(0, 0, 7, 37),
200 'images/bg-content-left.png' => array(40, 117, 50, 352),
201 'images/bg-content-right.png' => array(510, 117, 50, 352),
202 'images/bg-content.png' => array(299, 117, 7, 200),
203 'images/bg-navigation-item.png' => array(32, 37, 17, 12),
204 'images/bg-navigation-item-hover.png' => array(54, 37, 17, 12),
205 'images/gradient-inner.png' => array(646, 307, 112, 42),
206
207 'logo.png' => array(622, 51, 64, 73),
208 'screenshot.png' => array(0, 37, 400, 240),
209 ),
210
211 // Reference color used for blending. Matches the base.png's colors.
212 'blend_target' => '#ffffff',
213
214 // Preview files.
215 'preview_image' => 'color/preview.png',
216 'preview_css' => 'color/preview.css',
217
218 // Base file for image generation.
219 'base_image' => 'color/base.png',
220 );
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$info
$info
Definition: color.inc:6
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/tabledrag_example/tabledrag_example.module Source File

  • examples
  • tabledrag_example
tabledrag_example.module
Go to the documentation of this file.
1 <?php
19 function tabledrag_example_help($path, $arg) {
20 switch ($path) {
21 case 'examples/tabledrag_example':
22 return '<p>' . t('The form here is a themed as a table that is sortable using tabledrag handles.') . '</p>';
23 }
24 }
25
34 function tabledrag_example_menu() {
35 // Basic example with single-depth sorting.
36 $items['examples/tabledrag_example_simple'] = array(
37 'title' => 'TableDrag example (simple)',
38 'description' => 'Show a page with a sortable tabledrag form',
39 'page callback' => 'drupal_get_form',
40 'page arguments' => array('tabledrag_example_simple_form'),
41 'access callback' => TRUE,
42 'file' => 'tabledrag_example_simple_form.inc',
43 );
44 // Basic parent/child example.
45 $items['examples/tabledrag_example_parent'] = array(
46 'title' => 'TableDrag example (parent/child)',
47 'description' => 'Show a page with a sortable parent/child tabledrag form',
48 'page callback' => 'drupal_get_form',
49 'page arguments' => array('tabledrag_example_parent_form'),
50 'access callback' => TRUE,
51 'file' => 'tabledrag_example_parent_form.inc',
52 );
53 return $items;
54 }
55
68 function tabledrag_example_theme() {
69 return array(
70 // Theme function for the 'simple' example.
71 'tabledrag_example_simple_form' => array(
72 'render element' => 'form',
73 'file' => 'tabledrag_example_simple_form.inc',
74 ),
75 // Theme function for the 'parent/child' example.
76 'tabledrag_example_parent_form' => array(
77 'render element' => 'form',
78 'file' => 'tabledrag_example_parent_form.inc',
79 ),
80 );
81 }
tabledrag_example_help
tabledrag_example_help($path, $arg)
Definition: tabledrag_example.module:19
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
tabledrag_example_menu
tabledrag_example_menu()
Definition: tabledrag_example.module:34
tabledrag_example_theme
tabledrag_example_theme()
Definition: tabledrag_example.module:68
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator-summary-item.tpl.php Source File

  • modules
  • aggregator
aggregator-summary-item.tpl.php
Go to the documentation of this file.
1 <?php
2
19 ?>
20 <a href="<?php print $feed_url; ?>"><?php print $feed_title; ?></a>
21 <span class="age"><?php print $feed_age; ?></span>
22
23 <?php if ($source_url): ?>,
24 <span class="source"><a href="<?php print $source_url; ?>"><?php print $source_title; ?></a></span>
25 <?php endif; ?>
print
print
Definition: php-2.php:2
$feed_age
print $feed_age
Definition: aggregator-summary-item.tpl.php:21
$source_url
print $source_url
Definition: aggregator-feed-source.tpl.php:31
endif
endif
Definition: aggregator-item.tpl.php:31
$source_title
if($source_url) print $source_title
Definition: aggregator-item.tpl.php:29
$feed_title
print $feed_title
Definition: aggregator-item.tpl.php:25
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/unicode.inc Source File

  • includes
unicode.inc
Go to the documentation of this file.
1 <?php
2
11 define('UNICODE_ERROR', -1);
12
16 define('UNICODE_SINGLEBYTE', 0);
17
22 define('UNICODE_MULTIBYTE', 1);
23
48 define('PREG_CLASS_UNICODE_WORD_BOUNDARY',
49 '\x{0}-\x{2F}\x{3A}-\x{40}\x{5B}-\x{60}\x{7B}-\x{A9}\x{AB}-\x{B1}\x{B4}' .
50 '\x{B6}-\x{B8}\x{BB}\x{BF}\x{D7}\x{F7}\x{2C2}-\x{2C5}\x{2D2}-\x{2DF}' .
51 '\x{2E5}-\x{2EB}\x{2ED}\x{2EF}-\x{2FF}\x{375}\x{37E}-\x{385}\x{387}\x{3F6}' .
52 '\x{482}\x{55A}-\x{55F}\x{589}-\x{58A}\x{5BE}\x{5C0}\x{5C3}\x{5C6}' .
53 '\x{5F3}-\x{60F}\x{61B}-\x{61F}\x{66A}-\x{66D}\x{6D4}\x{6DD}\x{6E9}' .
54 '\x{6FD}-\x{6FE}\x{700}-\x{70F}\x{7F6}-\x{7F9}\x{830}-\x{83E}' .
55 '\x{964}-\x{965}\x{970}\x{9F2}-\x{9F3}\x{9FA}-\x{9FB}\x{AF1}\x{B70}' .
56 '\x{BF3}-\x{BFA}\x{C7F}\x{CF1}-\x{CF2}\x{D79}\x{DF4}\x{E3F}\x{E4F}' .
57 '\x{E5A}-\x{E5B}\x{F01}-\x{F17}\x{F1A}-\x{F1F}\x{F34}\x{F36}\x{F38}' .
58 '\x{F3A}-\x{F3D}\x{F85}\x{FBE}-\x{FC5}\x{FC7}-\x{FD8}\x{104A}-\x{104F}' .
59 '\x{109E}-\x{109F}\x{10FB}\x{1360}-\x{1368}\x{1390}-\x{1399}\x{1400}' .
60 '\x{166D}-\x{166E}\x{1680}\x{169B}-\x{169C}\x{16EB}-\x{16ED}' .
61 '\x{1735}-\x{1736}\x{17B4}-\x{17B5}\x{17D4}-\x{17D6}\x{17D8}-\x{17DB}' .
62 '\x{1800}-\x{180A}\x{180E}\x{1940}-\x{1945}\x{19DE}-\x{19FF}' .
63 '\x{1A1E}-\x{1A1F}\x{1AA0}-\x{1AA6}\x{1AA8}-\x{1AAD}\x{1B5A}-\x{1B6A}' .
64 '\x{1B74}-\x{1B7C}\x{1C3B}-\x{1C3F}\x{1C7E}-\x{1C7F}\x{1CD3}\x{1FBD}' .
65 '\x{1FBF}-\x{1FC1}\x{1FCD}-\x{1FCF}\x{1FDD}-\x{1FDF}\x{1FED}-\x{1FEF}' .
66 '\x{1FFD}-\x{206F}\x{207A}-\x{207E}\x{208A}-\x{208E}\x{20A0}-\x{20B8}' .
67 '\x{2100}-\x{2101}\x{2103}-\x{2106}\x{2108}-\x{2109}\x{2114}' .
68 '\x{2116}-\x{2118}\x{211E}-\x{2123}\x{2125}\x{2127}\x{2129}\x{212E}' .
69 '\x{213A}-\x{213B}\x{2140}-\x{2144}\x{214A}-\x{214D}\x{214F}' .
70 '\x{2190}-\x{244A}\x{249C}-\x{24E9}\x{2500}-\x{2775}\x{2794}-\x{2B59}' .
71 '\x{2CE5}-\x{2CEA}\x{2CF9}-\x{2CFC}\x{2CFE}-\x{2CFF}\x{2E00}-\x{2E2E}' .
72 '\x{2E30}-\x{3004}\x{3008}-\x{3020}\x{3030}\x{3036}-\x{3037}' .
73 '\x{303D}-\x{303F}\x{309B}-\x{309C}\x{30A0}\x{30FB}\x{3190}-\x{3191}' .
74 '\x{3196}-\x{319F}\x{31C0}-\x{31E3}\x{3200}-\x{321E}\x{322A}-\x{3250}' .
75 '\x{3260}-\x{327F}\x{328A}-\x{32B0}\x{32C0}-\x{33FF}\x{4DC0}-\x{4DFF}' .
76 '\x{A490}-\x{A4C6}\x{A4FE}-\x{A4FF}\x{A60D}-\x{A60F}\x{A673}\x{A67E}' .
77 '\x{A6F2}-\x{A716}\x{A720}-\x{A721}\x{A789}-\x{A78A}\x{A828}-\x{A82B}' .
78 '\x{A836}-\x{A839}\x{A874}-\x{A877}\x{A8CE}-\x{A8CF}\x{A8F8}-\x{A8FA}' .
79 '\x{A92E}-\x{A92F}\x{A95F}\x{A9C1}-\x{A9CD}\x{A9DE}-\x{A9DF}' .
80 '\x{AA5C}-\x{AA5F}\x{AA77}-\x{AA79}\x{AADE}-\x{AADF}\x{ABEB}' .
81 '\x{E000}-\x{F8FF}\x{FB29}\x{FD3E}-\x{FD3F}\x{FDFC}-\x{FDFD}' .
82 '\x{FE10}-\x{FE19}\x{FE30}-\x{FE6B}\x{FEFF}-\x{FF0F}\x{FF1A}-\x{FF20}' .
83 '\x{FF3B}-\x{FF40}\x{FF5B}-\x{FF65}\x{FFE0}-\x{FFFD}');
84
88 function unicode_check() {
89 list($GLOBALS['multibyte']) = _unicode_check();
90 }
91
103 function _unicode_check() {
104 // Ensure translations don't break during installation.
105 $t = get_t();
106
107 // Check for mbstring extension
108 if (!function_exists('mb_strlen')) {
109 return array(UNICODE_SINGLEBYTE, $t('Operations on Unicode strings are emulated on a best-effort basis. Install the <a href="@url">PHP mbstring extension</a> for improved Unicode support.', array('@url' => 'http://www.php.net/mbstring')));
110 }
111
112 // Check mbstring configuration
113 if (ini_get('mbstring.func_overload') != 0) {
114 return array(UNICODE_ERROR, $t('Multibyte string function overloading in PHP is active and must be disabled. Check the php.ini <em>mbstring.func_overload</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
115 }
116 if (ini_get('mbstring.encoding_translation') != 0) {
117 return array(UNICODE_ERROR, $t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.encoding_translation</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
118 }
119 if (ini_get('mbstring.http_input') != 'pass') {
120 return array(UNICODE_ERROR, $t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_input</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
121 }
122 if (ini_get('mbstring.http_output') != 'pass') {
123 return array(UNICODE_ERROR, $t('Multibyte string output conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_output</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
124 }
125
126 // Set appropriate configuration
127 mb_internal_encoding('utf-8');
128 mb_language('uni');
129 return array(UNICODE_MULTIBYTE, '');
130 }
131
135 function unicode_requirements() {
136 // Ensure translations don't break during installation.
137 $t = get_t();
138
139 $libraries = array(
140 UNICODE_SINGLEBYTE => $t('Standard PHP'),
141 UNICODE_MULTIBYTE => $t('PHP Mbstring Extension'),
142 UNICODE_ERROR => $t('Error'),
143 );
144 $severities = array(
145 UNICODE_SINGLEBYTE => REQUIREMENT_WARNING,
146 UNICODE_MULTIBYTE => REQUIREMENT_OK,
147 UNICODE_ERROR => REQUIREMENT_ERROR,
148 );
149 list($library, $description) = _unicode_check();
150
151 $requirements['unicode'] = array(
152 'title' => $t('Unicode library'),
153 'value' => $libraries[$library],
154 );
155 if ($description) {
156 $requirements['unicode']['description'] = $description;
157 }
158
159 $requirements['unicode']['severity'] = $severities[$library];
160
161 return $requirements;
162 }
163
185 function drupal_xml_parser_create(&$data) {
186 // Default XML encoding is UTF-8
187 $encoding = 'utf-8';
188 $bom = FALSE;
189
190 // Check for UTF-8 byte order mark (PHP5's XML parser doesn't handle it).
191 if (!strncmp($data, "\xEF\xBB\xBF", 3)) {
192 $bom = TRUE;
193 $data = substr($data, 3);
194 }
195
196 // Check for an encoding declaration in the XML prolog if no BOM was found.
197 if (!$bom && preg_match('/^<\?xml[^>]+encoding="(.+?)"/', $data, $match)) {
198 $encoding = $match[1];
199 }
200
201 // Unsupported encodings are converted here into UTF-8.
202 $php_supported = array('utf-8', 'iso-8859-1', 'us-ascii');
203 if (!in_array(strtolower($encoding), $php_supported)) {
204 $out = drupal_convert_to_utf8($data, $encoding);
205 if ($out !== FALSE) {
206 $encoding = 'utf-8';
207 $data = preg_replace('/^(<\?xml[^>]+encoding)="(.+?)"/', '\\1="utf-8"', $out);
208 }
209 else {
210 watchdog('php', 'Could not convert XML encoding %s to UTF-8.', array('%s' => $encoding), WATCHDOG_WARNING);
211 return FALSE;
212 }
213 }
214
215 $xml_parser = xml_parser_create($encoding);
216 xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, 'utf-8');
217 return $xml_parser;
218 }
219
233 function drupal_convert_to_utf8($data, $encoding) {
234 if (function_exists('iconv')) {
235 $out = @iconv($encoding, 'utf-8', $data);
236 }
237 elseif (function_exists('mb_convert_encoding')) {
238 $out = @mb_convert_encoding($data, 'utf-8', $encoding);
239 }
240 elseif (function_exists('recode_string')) {
241 $out = @recode_string($encoding . '..utf-8', $data);
242 }
243 else {
244 watchdog('php', 'Unsupported encoding %s. Please install iconv, GNU recode or mbstring for PHP.', array('%s' => $encoding), WATCHDOG_ERROR);
245 return FALSE;
246 }
247
248 return $out;
249 }
250
270 function drupal_truncate_bytes($string, $len) {
271 if (strlen($string) <= $len) {
272 return $string;
273 }
274 if ((ord($string[$len]) < 0x80) || (ord($string[$len]) >= 0xC0)) {
275 return substr($string, 0, $len);
276 }
277 // Scan backwards to beginning of the byte sequence.
278 while (--$len >= 0 && ord($string[$len]) >= 0x80 && ord($string[$len]) < 0xC0);
279
280 return substr($string, 0, $len);
281 }
282
317 function truncate_utf8($string, $max_length, $wordsafe = FALSE, $add_ellipsis = FALSE, $min_wordsafe_length = 1) {
318 $ellipsis = '';
319 $max_length = max($max_length, 0);
320 $min_wordsafe_length = max($min_wordsafe_length, 0);
321
322 if (drupal_strlen($string) <= $max_length) {
323 // No truncation needed, so don't add ellipsis, just return.
324 return $string;
325 }
326
327 if ($add_ellipsis) {
328 // Truncate ellipsis in case $max_length is small.
329 $ellipsis = drupal_substr(t('...'), 0, $max_length);
330 $max_length -= drupal_strlen($ellipsis);
331 $max_length = max($max_length, 0);
332 }
333
334 if ($max_length <= $min_wordsafe_length) {
335 // Do not attempt word-safe if lengths are bad.
336 $wordsafe = FALSE;
337 }
338
339 if ($wordsafe) {
340 $matches = array();
341 // Find the last word boundary, if there is one within $min_wordsafe_length
342 // to $max_length characters. preg_match() is always greedy, so it will
343 // find the longest string possible.
344 $found = preg_match('/^(.{' . $min_wordsafe_length . ',' . $max_length . '})[' . PREG_CLASS_UNICODE_WORD_BOUNDARY . ']/u', $string, $matches);
345 if ($found) {
346 $string = $matches[1];
347 }
348 else {
349 $string = drupal_substr($string, 0, $max_length);
350 }
351 }
352 else {
353 $string = drupal_substr($string, 0, $max_length);
354 }
355
356 if ($add_ellipsis) {
357 $string .= $ellipsis;
358 }
359
360 return $string;
361 }
362
385 function mime_header_encode($string) {
386 if (preg_match('/[^\x20-\x7E]/', $string)) {
387 $chunk_size = 47; // floor((75 - strlen("=?UTF-8?B??=")) * 0.75);
388 $len = strlen($string);
389 $output = '';
390 while ($len > 0) {
391 $chunk = drupal_truncate_bytes($string, $chunk_size);
392 $output .= ' =?UTF-8?B?' . base64_encode($chunk) . "?=\n";
393 $c = strlen($chunk);
394 $string = substr($string, $c);
395 $len -= $c;
396 }
397 return trim($output);
398 }
399 return $string;
400 }
401
413 function mime_header_decode($header) {
414 // First step: encoded chunks followed by other encoded chunks (need to collapse whitespace)
415 $header = preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=\s+(?==\?)/', '_mime_header_decode', $header);
416 // Second step: remaining chunks (do not collapse whitespace)
417 return preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=/', '_mime_header_decode', $header);
418 }
419
433 function _mime_header_decode($matches) {
434 // Regexp groups:
435 // 1: Character set name
436 // 2: Escaping method (Q or B)
437 // 3: Encoded data
438 $data = ($matches[2] == 'B') ? base64_decode($matches[3]) : str_replace('_', ' ', quoted_printable_decode($matches[3]));
439 if (strtolower($matches[1]) != 'utf-8') {
440 $data = drupal_convert_to_utf8($data, $matches[1]);
441 }
442 return $data;
443 }
444
458 function decode_entities($text) {
459 return html_entity_decode($text, ENT_QUOTES, 'UTF-8');
460 }
461
475 function drupal_strlen($text) {
476 global $multibyte;
477 if ($multibyte == UNICODE_MULTIBYTE) {
478 return mb_strlen($text);
479 }
480 else {
481 // Do not count UTF-8 continuation bytes.
482 return strlen(preg_replace("/[\x80-\xBF]/", '', $text));
483 }
484 }
485
497 function drupal_strtoupper($text) {
498 global $multibyte;
499 if ($multibyte == UNICODE_MULTIBYTE) {
500 return mb_strtoupper($text);
501 }
502 else {
503 // Use C-locale for ASCII-only uppercase
504 $text = strtoupper($text);
505 // Case flip Latin-1 accented letters
506 $text = preg_replace_callback('/\xC3[\xA0-\xB6\xB8-\xBE]/', '_unicode_caseflip', $text);
507 return $text;
508 }
509 }
510
522 function drupal_strtolower($text) {
523 global $multibyte;
524 if ($multibyte == UNICODE_MULTIBYTE) {
525 return mb_strtolower($text);
526 }
527 else {
528 // Use C-locale for ASCII-only lowercase
529 $text = strtolower($text);
530 // Case flip Latin-1 accented letters
531 $text = preg_replace_callback('/\xC3[\x80-\x96\x98-\x9E]/', '_unicode_caseflip', $text);
532 return $text;
533 }
534 }
535
547 function _unicode_caseflip($matches) {
548 return $matches[0][0] . chr(ord($matches[0][1]) ^ 32);
549 }
550
562 function drupal_ucfirst($text) {
563 // Note: no mbstring equivalent!
564 return drupal_strtoupper(drupal_substr($text, 0, 1)) . drupal_substr($text, 1);
565 }
566
586 function drupal_substr($text, $start, $length = NULL) {
587 global $multibyte;
588 if ($multibyte == UNICODE_MULTIBYTE) {
589 return $length === NULL ? mb_substr($text, $start) : mb_substr($text, $start, $length);
590 }
591 else {
592 $strlen = strlen($text);
593 // Find the starting byte offset.
594 $bytes = 0;
595 if ($start > 0) {
596 // Count all the continuation bytes from the start until we have found
597 // $start characters or the end of the string.
598 $bytes = -1; $chars = -1;
599 while ($bytes < $strlen - 1 && $chars < $start) {
600 $bytes++;
601 $c = ord($text[$bytes]);
602 if ($c < 0x80 || $c >= 0xC0) {
603 $chars++;
604 }
605 }
606 }
607 elseif ($start < 0) {
608 // Count all the continuation bytes from the end until we have found
609 // abs($start) characters.
610 $start = abs($start);
611 $bytes = $strlen; $chars = 0;
612 while ($bytes > 0 && $chars < $start) {
613 $bytes--;
614 $c = ord($text[$bytes]);
615 if ($c < 0x80 || $c >= 0xC0) {
616 $chars++;
617 }
618 }
619 }
620 $istart = $bytes;
621
622 // Find the ending byte offset.
623 if ($length === NULL) {
624 $iend = $strlen;
625 }
626 elseif ($length > 0) {
627 // Count all the continuation bytes from the starting index until we have
628 // found $length characters or reached the end of the string, then
629 // backtrace one byte.
630 $iend = $istart - 1;
631 $chars = -1;
632 $last_real = FALSE;
633 while ($iend < $strlen - 1 && $chars < $length) {
634 $iend++;
635 $c = ord($text[$iend]);
636 $last_real = FALSE;
637 if ($c < 0x80 || $c >= 0xC0) {
638 $chars++;
639 $last_real = TRUE;
640 }
641 }
642 // Backtrace one byte if the last character we found was a real character
643 // and we don't need it.
644 if ($last_real && $chars >= $length) {
645 $iend--;
646 }
647 }
648 elseif ($length < 0) {
649 // Count all the continuation bytes from the end until we have found
650 // abs($start) characters, then backtrace one byte.
651 $length = abs($length);
652 $iend = $strlen; $chars = 0;
653 while ($iend > 0 && $chars < $length) {
654 $iend--;
655 $c = ord($text[$iend]);
656 if ($c < 0x80 || $c >= 0xC0) {
657 $chars++;
658 }
659 }
660 // Backtrace one byte if we are not at the beginning of the string.
661 if ($iend > 0) {
662 $iend--;
663 }
664 }
665 else {
666 // $length == 0, return an empty string.
667 return '';
668 }
669
670 return substr($text, $istart, max(0, $iend - $istart + 1));
671 }
672 }
decode_entities
decode_entities($text)
Definition: unicode.inc:457
drupal_strtolower
drupal_strtolower($text)
Definition: unicode.inc:521
drupal_strlen
drupal_strlen($text)
Definition: unicode.inc:474
mime_header_decode
mime_header_decode($header)
Definition: unicode.inc:412
UNICODE_ERROR
const UNICODE_ERROR
Definition: unicode.inc:11
$header
print $header
Definition: forum-topic-list.tpl.php:42
drupal_substr
drupal_substr($text, $start, $length=NULL)
Definition: unicode.inc:585
drupal_convert_to_utf8
drupal_convert_to_utf8($data, $encoding)
Definition: unicode.inc:232
drupal_truncate_bytes
drupal_truncate_bytes($string, $len)
Definition: unicode.inc:269
REQUIREMENT_WARNING
const REQUIREMENT_WARNING
Definition: install.inc:31
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
REQUIREMENT_OK
const REQUIREMENT_OK
Definition: install.inc:26
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
drupal_strtoupper
drupal_strtoupper($text)
Definition: unicode.inc:496
_unicode_check
_unicode_check()
Definition: unicode.inc:102
unicode_requirements
unicode_requirements()
Definition: unicode.inc:134
get_t
get_t()
Definition: bootstrap.inc:2635
$output
$output
Definition: authorize.php:93
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
drupal_ucfirst
drupal_ucfirst($text)
Definition: unicode.inc:561
mime_header_encode
mime_header_encode($string)
Definition: unicode.inc:384
UNICODE_SINGLEBYTE
const UNICODE_SINGLEBYTE
Definition: unicode.inc:16
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
_mime_header_decode
_mime_header_decode($matches)
Definition: unicode.inc:432
_unicode_caseflip
_unicode_caseflip($matches)
Definition: unicode.inc:546
UNICODE_MULTIBYTE
const UNICODE_MULTIBYTE
Definition: unicode.inc:22
truncate_utf8
truncate_utf8($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
Definition: unicode.inc:316
PREG_CLASS_UNICODE_WORD_BOUNDARY
const PREG_CLASS_UNICODE_WORD_BOUNDARY
Definition: unicode.inc:48
drupal_xml_parser_create
drupal_xml_parser_create(&$data)
Definition: unicode.inc:184
unicode_check
unicode_check()
Definition: unicode.inc:87
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/authorize.inc Source File

  • includes
authorize.inc
Go to the documentation of this file.
1 <?php
2
17 function authorize_filetransfer_form($form, &$form_state) {
18 global $base_url, $is_https;
19 $form = array();
20
21 // If possible, we want to post this form securely via HTTPS.
22 $form['#https'] = TRUE;
23
24 // CSS we depend on lives in modules/system/maintenance.css, which is loaded
25 // via the default maintenance theme.
26 $form['#attached']['js'][] = $base_url . '/misc/authorize.js';
27
28 // Get all the available ways to transfer files.
29 if (empty($_SESSION['authorize_filetransfer_info'])) {
30 drupal_set_message(t('Unable to continue, no available methods of file transfer'), 'error');
31 return array();
32 }
33 $available_backends = $_SESSION['authorize_filetransfer_info'];
34
35 if (!$is_https) {
36 $form['information']['https_warning'] = array(
37 '#prefix' => '<div class="messages error">',
38 '#markup' => t('WARNING: You are not using an encrypted connection, so your password will be sent in plain text. <a href="@https-link">Learn more</a>.', array('@https-link' => 'http://drupal.org/https-information')),
39 '#suffix' => '</div>',
40 );
41 }
42
43 // Decide on a default backend.
44 if (isset($form_state['values']['connection_settings']['authorize_filetransfer_default'])) {
45 $authorize_filetransfer_default = $form_state['values']['connection_settings']['authorize_filetransfer_default'];
46 }
47 elseif ($authorize_filetransfer_default = variable_get('authorize_filetransfer_default', NULL));
48 else {
49 $authorize_filetransfer_default = key($available_backends);
50 }
51
52 $form['information']['main_header'] = array(
53 '#prefix' => '<h3>',
54 '#markup' => t('To continue, provide your server connection details'),
55 '#suffix' => '</h3>',
56 );
57
58 $form['connection_settings']['#tree'] = TRUE;
59 $form['connection_settings']['authorize_filetransfer_default'] = array(
60 '#type' => 'select',
61 '#title' => t('Connection method'),
62 '#default_value' => $authorize_filetransfer_default,
63 '#weight' => -10,
64 );
65
66 /*
67 * Here we create two submit buttons. For a JS enabled client, they will
68 * only ever see submit_process. However, if a client doesn't have JS
69 * enabled, they will see submit_connection on the first form (when picking
70 * what filetransfer type to use, and submit_process on the second one (which
71 * leads to the actual operation).
72 */
73 $form['submit_connection'] = array(
74 '#prefix' => "<br style='clear:both'/>",
75 '#name' => 'enter_connection_settings',
76 '#type' => 'submit',
77 '#value' => t('Enter connection settings'),
78 '#weight' => 100,
79 );
80
81 $form['submit_process'] = array(
82 '#name' => 'process_updates',
83 '#type' => 'submit',
84 '#value' => t('Continue'),
85 '#weight' => 100,
86 '#attributes' => array('style' => 'display:none'),
87 );
88
89 // Build a container for each connection type.
90 foreach ($available_backends as $name => $backend) {
91 $form['connection_settings']['authorize_filetransfer_default']['#options'][$name] = $backend['title'];
92 $form['connection_settings'][$name] = array(
93 '#type' => 'container',
94 '#attributes' => array('class' => array("filetransfer-$name", 'filetransfer')),
95 );
96 // We can't use #prefix on the container itself since then the header won't
97 // be hidden and shown when the containers are being manipulated via JS.
98 $form['connection_settings'][$name]['header'] = array(
99 '#markup' => '<h4>' . t('@backend connection settings', array('@backend' => $backend['title'])) . '</h4>',
100 );
101
102 $form['connection_settings'][$name] += _authorize_filetransfer_connection_settings($name);
103
104 // Start non-JS code.
105 if (isset($form_state['values']['connection_settings']['authorize_filetransfer_default']) && $form_state['values']['connection_settings']['authorize_filetransfer_default'] == $name) {
106
107 // If the user switches from JS to non-JS, Drupal (and Batch API) will
108 // barf. This is a known bug: http://drupal.org/node/229825.
109 setcookie('has_js', '', time() - 3600, '/');
110 unset($_COOKIE['has_js']);
111
112 // Change the submit button to the submit_process one.
113 $form['submit_process']['#attributes'] = array();
114 unset($form['submit_connection']);
115
116 // Activate the proper filetransfer settings form.
117 $form['connection_settings'][$name]['#attributes']['style'] = 'display:block';
118 // Disable the select box.
119 $form['connection_settings']['authorize_filetransfer_default']['#disabled'] = TRUE;
120
121 // Create a button for changing the type of connection.
122 $form['connection_settings']['change_connection_type'] = array(
123 '#name' => 'change_connection_type',
124 '#type' => 'submit',
125 '#value' => t('Change connection type'),
126 '#weight' => -5,
127 '#attributes' => array('class' => array('filetransfer-change-connection-type')),
128 );
129 }
130 // End non-JS code.
131 }
132 return $form;
133 }
134
146 function _authorize_filetransfer_connection_settings($backend) {
147 $defaults = variable_get('authorize_filetransfer_connection_settings_' . $backend, array());
148 $form = array();
149
150 // Create an instance of the file transfer class to get its settings form.
151 $filetransfer = authorize_get_filetransfer($backend);
152 if ($filetransfer) {
153 $form = $filetransfer->getSettingsForm();
154 }
155 // Fill in the defaults based on the saved settings, if any.
156 _authorize_filetransfer_connection_settings_set_defaults($form, NULL, $defaults);
157 return $form;
158 }
159
176 function _authorize_filetransfer_connection_settings_set_defaults(&$element, $key, array $defaults) {
177 // If we're operating on a form element which isn't a fieldset, and we have
178 // a default setting saved, stash it in #default_value.
179 if (!empty($key) && isset($defaults[$key]) && isset($element['#type']) && $element['#type'] != 'fieldset') {
180 $element['#default_value'] = $defaults[$key];
181 }
182 // Now, we walk through all the child elements, and recursively invoke
183 // ourself on each one. Since the $defaults settings array can be nested
184 // (because of #tree, any values inside fieldsets will be nested), if
185 // there's a subarray of settings for the form key we're currently
186 // processing, pass in that subarray to the recursive call. Otherwise, just
187 // pass on the whole $defaults array.
188 foreach (element_children($element) as $child_key) {
189 _authorize_filetransfer_connection_settings_set_defaults($element[$child_key], $child_key, ((isset($defaults[$key]) && is_array($defaults[$key])) ? $defaults[$key] : $defaults));
190 }
191 }
192
199 function authorize_filetransfer_form_validate($form, &$form_state) {
200 // Only validate the form if we have collected all of the user input and are
201 // ready to proceed with updating or installing.
202 if ($form_state['triggering_element']['#name'] != 'process_updates') {
203 return;
204 }
205
206 if (isset($form_state['values']['connection_settings'])) {
207 $backend = $form_state['values']['connection_settings']['authorize_filetransfer_default'];
208 $filetransfer = authorize_get_filetransfer($backend, $form_state['values']['connection_settings'][$backend]);
209 try {
210 if (!$filetransfer) {
211 throw new Exception(t('Error, this type of connection protocol (%backend) does not exist.', array('%backend' => $backend)));
212 }
213 $filetransfer->connect();
214 }
215 catch (Exception $e) {
216 // The format of this error message is similar to that used on the
217 // database connection form in the installer.
218 form_set_error('connection_settings', t('Failed to connect to the server. The server reports the following message: !message For more help installing or updating code on your server, see the <a href="@handbook_url">handbook</a>.', array(
219 '!message' => '<p class="error">' . $e->getMessage() . '</p>',
220 '@handbook_url' => 'http://drupal.org/documentation/install/modules-themes',
221 )));
222 }
223 }
224 }
225
232 function authorize_filetransfer_form_submit($form, &$form_state) {
233 global $base_url;
234 switch ($form_state['triggering_element']['#name']) {
235 case 'process_updates':
236
237 // Save the connection settings to the DB.
238 $filetransfer_backend = $form_state['values']['connection_settings']['authorize_filetransfer_default'];
239
240 // If the database is available then try to save our settings. We have
241 // to make sure it is available since this code could potentially (will
242 // likely) be called during the installation process, before the
243 // database is set up.
244 try {
245 $connection_settings = array();
246 foreach ($form_state['values']['connection_settings'][$filetransfer_backend] as $key => $value) {
247 // We do *not* want to store passwords in the database, unless the
248 // backend explicitly says so via the magic #filetransfer_save form
249 // property. Otherwise, we store everything that's not explicitly
250 // marked with #filetransfer_save set to FALSE.
251 if (!isset($form['connection_settings'][$filetransfer_backend][$key]['#filetransfer_save'])) {
252 if ($form['connection_settings'][$filetransfer_backend][$key]['#type'] != 'password') {
253 $connection_settings[$key] = $value;
254 }
255 }
256 // The attribute is defined, so only save if set to TRUE.
257 elseif ($form['connection_settings'][$filetransfer_backend][$key]['#filetransfer_save']) {
258 $connection_settings[$key] = $value;
259 }
260 }
261 // Set this one as the default authorize method.
262 variable_set('authorize_filetransfer_default', $filetransfer_backend);
263 // Save the connection settings minus the password.
264 variable_set('authorize_filetransfer_connection_settings_' . $filetransfer_backend, $connection_settings);
265
266 $filetransfer = authorize_get_filetransfer($filetransfer_backend, $form_state['values']['connection_settings'][$filetransfer_backend]);
267
268 // Now run the operation.
269 authorize_run_operation($filetransfer);
270 }
271 catch (Exception $e) {
272 // If there is no database available, we don't care and just skip
273 // this part entirely.
274 }
275
276 break;
277
278 case 'enter_connection_settings':
279 $form_state['rebuild'] = TRUE;
280 break;
281
282 case 'change_connection_type':
283 $form_state['rebuild'] = TRUE;
284 unset($form_state['values']['connection_settings']['authorize_filetransfer_default']);
285 break;
286 }
287 }
288
295 function authorize_run_operation($filetransfer) {
296 $operation = $_SESSION['authorize_operation'];
297 unset($_SESSION['authorize_operation']);
298
299 if (!empty($operation['page_title'])) {
300 drupal_set_title($operation['page_title']);
301 }
302
303 require_once DRUPAL_ROOT . '/' . $operation['file'];
304 call_user_func_array($operation['callback'], array_merge(array($filetransfer), $operation['arguments']));
305 }
306
319 function authorize_get_filetransfer($backend, $settings = array()) {
320 $filetransfer = FALSE;
321 if (!empty($_SESSION['authorize_filetransfer_info'][$backend])) {
322 $backend_info = $_SESSION['authorize_filetransfer_info'][$backend];
323 if (!empty($backend_info['file'])) {
324 $file = $backend_info['file path'] . '/' . $backend_info['file'];
325 require_once $file;
326 }
327 if (class_exists($backend_info['class'])) {
328 // PHP 5.2 doesn't support $class::factory() syntax, so we have to
329 // use call_user_func_array() until we can require PHP 5.3.
330 $filetransfer = call_user_func_array(array($backend_info['class'], 'factory'), array(DRUPAL_ROOT, $settings));
331 }
332 }
333 return $filetransfer;
334 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
_authorize_filetransfer_connection_settings
_authorize_filetransfer_connection_settings($backend)
Definition: authorize.inc:146
authorize_run_operation
authorize_run_operation($filetransfer)
Definition: authorize.inc:295
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
$name
print $name
Definition: profile-listing.tpl.php:43
Exception
_authorize_filetransfer_connection_settings_set_defaults
_authorize_filetransfer_connection_settings_set_defaults(&$element, $key, array $defaults)
Definition: authorize.inc:176
authorize_get_filetransfer
authorize_get_filetransfer($backend, $settings=array())
Definition: authorize.inc:319
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
authorize_filetransfer_form
authorize_filetransfer_form($form, &$form_state)
Definition: authorize.inc:17
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
authorize_filetransfer_form_submit
authorize_filetransfer_form_submit($form, &$form_state)
Definition: authorize.inc:232
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
authorize_filetransfer_form_validate
authorize_filetransfer_form_validate($form, &$form_state)
Definition: authorize.inc:199
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user-profile.tpl.php Source File

  • modules
  • user
user-profile.tpl.php
Go to the documentation of this file.
1 <?php
2
36 ?>
37 <div class="profile"<?php print $attributes; ?>>
38 <?php print render($user_profile); ?>
39 </div>
$attributes
print $attributes
Definition: block.tpl.php:47
print
print
Definition: php-2.php:2
render
render(&$element)
Definition: common.inc:5988
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/filter/filter.module Source File

  • modules
  • filter
filter.module
Go to the documentation of this file.
1 <?php
2
11 function filter_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#filter':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t('The Filter module allows administrators to configure text formats. A text format defines the HTML tags, codes, and other input allowed in content and comments, and is a key feature in guarding against potentially damaging input from malicious users. For more information, see the online handbook entry for <a href="@filter">Filter module</a>.', array('@filter' => 'http://drupal.org/documentation/modules/filter/')) . '</p>';
17 $output .= '<h3>' . t('Uses') . '</h3>';
18 $output .= '<dl>';
19 $output .= '<dt>' . t('Configuring text formats') . '</dt>';
20 $output .= '<dd>' . t('Configure text formats on the <a href="@formats">Text formats page</a>. <strong>Improper text format configuration is a security risk</strong>. To ensure security, untrusted users should only have access to text formats that restrict them to either plain text or a safe set of HTML tags, since certain HTML tags can allow embedding malicious links or scripts in text. More trusted registered users may be granted permission to use less restrictive text formats in order to create rich content.', array('@formats' => url('admin/config/content/formats'))) . '</dd>';
21 $output .= '<dt>' . t('Applying filters to text') . '</dt>';
22 $output .= '<dd>' . t('Each text format uses filters to manipulate text, and most formats apply several different filters to text in a specific order. Each filter is designed for a specific purpose, and generally either adds, removes, or transforms elements within user-entered text before it is displayed. A filter does not change the actual content, but instead, modifies it temporarily before it is displayed. One filter may remove unapproved HTML tags, while another automatically adds HTML to make URLs display as clickable links.') . '</dd>';
23 $output .= '<dt>' . t('Defining text formats') . '</dt>';
24 $output .= '<dd>' . t('One format is included by default: <em>Plain text</em> (which removes all HTML tags). Additional formats may be created by your installation profile when you install Drupal, and more can be created by an administrator on the <a href="@text-formats">Text formats page</a>.', array('@text-formats' => url('admin/config/content/formats'))) . '</dd>';
25 $output .= '<dt>' . t('Choosing a text format') . '</dt>';
26 $output .= '<dd>' . t('Users with access to more than one text format can use the <em>Text format</em> fieldset to choose between available text formats when creating or editing multi-line content. Administrators can define the text formats available to each user role, and control the order of formats listed in the <em>Text format</em> fieldset on the <a href="@text-formats">Text formats page</a>.', array('@text-formats' => url('admin/config/content/formats'))) . '</dd>';
27 $output .= '</dl>';
28 return $output;
29
30 case 'admin/config/content/formats':
31 $output = '<p>' . t('Text formats define the HTML tags, code, and other formatting that can be used when entering text. <strong>Improper text format configuration is a security risk</strong>. Learn more on the <a href="@filterhelp">Filter module help page</a>.', array('@filterhelp' => url('admin/help/filter'))) . '</p>';
32 $output .= '<p>' . t('Text formats are presented on content editing pages in the order defined on this page. The first format available to a user will be selected by default.') . '</p>';
33 return $output;
34
35 case 'admin/config/content/formats/%':
36 $output = '<p>' . t('A text format contains filters that change the user input, for example stripping out malicious HTML or making URLs clickable. Filters are executed from top to bottom and the order is important, since one filter may prevent another filter from doing its job. For example, when URLs are converted into links before disallowed HTML tags are removed, all links may be removed. When this happens, the order of filters may need to be re-arranged.') . '</p>';
37 return $output;
38 }
39 }
40
44 function filter_theme() {
45 return array(
46 'filter_admin_overview' => array(
47 'render element' => 'form',
48 'file' => 'filter.admin.inc',
49 ),
50 'filter_admin_format_filter_order' => array(
51 'render element' => 'element',
52 'file' => 'filter.admin.inc',
53 ),
54 'filter_tips' => array(
55 'variables' => array('tips' => NULL, 'long' => FALSE),
56 'file' => 'filter.pages.inc',
57 ),
58 'text_format_wrapper' => array(
59 'render element' => 'element',
60 ),
61 'filter_tips_more_info' => array(
62 'variables' => array(),
63 ),
64 'filter_guidelines' => array(
65 'variables' => array('format' => NULL),
66 ),
67 );
68 }
69
76 function filter_element_info() {
77 $type['text_format'] = array(
78 '#process' => array('filter_process_format'),
79 '#base_type' => 'textarea',
80 '#theme_wrappers' => array('text_format_wrapper'),
81 );
82 return $type;
83 }
84
88 function filter_menu() {
89 $items['filter/tips'] = array(
90 'title' => 'Compose tips',
91 'page callback' => 'filter_tips_long',
92 'access callback' => TRUE,
93 'type' => MENU_SUGGESTED_ITEM,
94 'file' => 'filter.pages.inc',
95 );
96 $items['admin/config/content/formats'] = array(
97 'title' => 'Text formats',
98 'description' => 'Configure how content input by users is filtered, including allowed HTML tags. Also allows enabling of module-provided filters.',
99 'page callback' => 'drupal_get_form',
100 'page arguments' => array('filter_admin_overview'),
101 'access arguments' => array('administer filters'),
102 'file' => 'filter.admin.inc',
103 );
104 $items['admin/config/content/formats/list'] = array(
105 'title' => 'List',
106 'type' => MENU_DEFAULT_LOCAL_TASK,
107 );
108 $items['admin/config/content/formats/add'] = array(
109 'title' => 'Add text format',
110 'page callback' => 'filter_admin_format_page',
111 'access arguments' => array('administer filters'),
112 'type' => MENU_LOCAL_ACTION,
113 'weight' => 1,
114 'file' => 'filter.admin.inc',
115 );
116 $items['admin/config/content/formats/%filter_format'] = array(
117 'title callback' => 'filter_admin_format_title',
118 'title arguments' => array(4),
119 'page callback' => 'filter_admin_format_page',
120 'page arguments' => array(4),
121 'access arguments' => array('administer filters'),
122 'file' => 'filter.admin.inc',
123 );
124 $items['admin/config/content/formats/%filter_format/disable'] = array(
125 'title' => 'Disable text format',
126 'page callback' => 'drupal_get_form',
127 'page arguments' => array('filter_admin_disable', 4),
128 'access callback' => '_filter_disable_format_access',
129 'access arguments' => array(4),
130 'file' => 'filter.admin.inc',
131 );
132 return $items;
133 }
134
147 function _filter_disable_format_access($format) {
148 // The fallback format can never be disabled.
149 return user_access('administer filters') && ($format->format != filter_fallback_format());
150 }
151
165 function filter_format_load($format_id) {
166 $formats = filter_formats();
167 return isset($formats[$format_id]) ? $formats[$format_id] : FALSE;
168 }
169
198 function filter_format_save($format) {
199 $format->name = trim($format->name);
200 $format->cache = _filter_format_is_cacheable($format);
201 if (!isset($format->status)) {
202 $format->status = 1;
203 }
204 if (!isset($format->weight)) {
205 $format->weight = 0;
206 }
207
208 // Insert or update the text format.
209 $return = db_merge('filter_format')
210 ->key(array('format' => $format->format))
211 ->fields(array(
212 'name' => $format->name,
213 'cache' => (int) $format->cache,
214 'status' => (int) $format->status,
215 'weight' => (int) $format->weight,
216 ))
217 ->execute();
218
219 // Programmatic saves may not contain any filters.
220 if (!isset($format->filters)) {
221 $format->filters = array();
222 }
223 $filter_info = filter_get_filters();
224 foreach ($filter_info as $name => $filter) {
225 // If the format does not specify an explicit weight for a filter, assign
226 // a default weight, either defined in hook_filter_info(), or the default of
227 // 0 by filter_get_filters()
228 if (!isset($format->filters[$name]['weight'])) {
229 $format->filters[$name]['weight'] = $filter['weight'];
230 }
231 $format->filters[$name]['status'] = isset($format->filters[$name]['status']) ? $format->filters[$name]['status'] : 0;
232 $format->filters[$name]['module'] = $filter['module'];
233
234 // If settings were passed, only ensure default settings.
235 if (isset($format->filters[$name]['settings'])) {
236 if (isset($filter['default settings'])) {
237 $format->filters[$name]['settings'] = array_merge($filter['default settings'], $format->filters[$name]['settings']);
238 }
239 }
240 // Otherwise, use default settings or fall back to an empty array.
241 else {
242 $format->filters[$name]['settings'] = isset($filter['default settings']) ? $filter['default settings'] : array();
243 }
244
245 $fields = array();
246 $fields['weight'] = $format->filters[$name]['weight'];
247 $fields['status'] = $format->filters[$name]['status'];
248 $fields['module'] = $format->filters[$name]['module'];
249 $fields['settings'] = serialize($format->filters[$name]['settings']);
250
251 db_merge('filter')
252 ->key(array(
253 'format' => $format->format,
254 'name' => $name,
255 ))
256 ->fields($fields)
257 ->execute();
258 }
259
260 if ($return == SAVED_NEW) {
261 module_invoke_all('filter_format_insert', $format);
262 }
263 else {
264 module_invoke_all('filter_format_update', $format);
265 // Explicitly indicate that the format was updated. We need to do this
266 // since if the filters were updated but the format object itself was not,
267 // the merge query above would not return an indication that anything had
268 // changed.
269 $return = SAVED_UPDATED;
270
271 // Clear the filter cache whenever a text format is updated.
272 cache_clear_all($format->format . ':', 'cache_filter', TRUE);
273 }
274
275 filter_formats_reset();
276
277 return $return;
278 }
279
291 function filter_format_disable($format) {
292 db_update('filter_format')
293 ->fields(array('status' => 0))
294 ->condition('format', $format->format)
295 ->execute();
296
297 // Allow modules to react on text format deletion.
298 module_invoke_all('filter_format_disable', $format);
299
300 // Clear the filter cache whenever a text format is disabled.
301 filter_formats_reset();
302 cache_clear_all($format->format . ':', 'cache_filter', TRUE);
303 }
304
318 function filter_format_exists($format_id) {
319 return (bool) db_query_range('SELECT 1 FROM {filter_format} WHERE format = :format', 0, 1, array(':format' => $format_id))->fetchField();
320 }
321
333 function filter_admin_format_title($format) {
334 return $format->name;
335 }
336
340 function filter_permission() {
341 $perms['administer filters'] = array(
342 'title' => t('Administer text formats and filters'),
343 'restrict access' => TRUE,
344 );
345
346 // Generate permissions for each text format. Warn the administrator that any
347 // of them are potentially unsafe.
348 foreach (filter_formats() as $format) {
349 $permission = filter_permission_name($format);
350 if (!empty($permission)) {
351 // Only link to the text format configuration page if the user who is
352 // viewing this will have access to that page.
353 $format_name_replacement = user_access('administer filters') ? l($format->name, 'admin/config/content/formats/' . $format->format) : drupal_placeholder($format->name);
354 $perms[$permission] = array(
355 'title' => t("Use the !text_format text format", array('!text_format' => $format_name_replacement,)),
356 'description' => drupal_placeholder(t('Warning: This permission may have security implications depending on how the text format is configured.')),
357 );
358 }
359 }
360 return $perms;
361 }
362
373 function filter_permission_name($format) {
374 if (isset($format->format) && $format->format != filter_fallback_format()) {
375 return 'use text format ' . $format->format;
376 }
377 return FALSE;
378 }
379
383 function filter_modules_enabled($modules) {
384 // Reset the static cache of module-provided filters, in case any of the
385 // newly enabled modules defines a new filter or alters existing ones.
386 drupal_static_reset('filter_get_filters');
387 }
388
392 function filter_modules_disabled($modules) {
393 // Reset the static cache of module-provided filters, in case any of the
394 // newly disabled modules defined or altered any filters.
395 drupal_static_reset('filter_get_filters');
396 }
397
412 function filter_formats($account = NULL) {
413 global $language;
414 $formats = &drupal_static(__FUNCTION__, array());
415
416 // All available formats are cached for performance.
417 if (!isset($formats['all'])) {
418 if ($cache = cache_get("filter_formats:{$language->language}")) {
419 $formats['all'] = $cache->data;
420 }
421 else {
422 $formats['all'] = db_select('filter_format', 'ff')
423 ->addTag('translatable')
424 ->fields('ff')
425 ->condition('status', 1)
426 ->orderBy('weight')
427 ->execute()
428 ->fetchAllAssoc('format');
429
430 cache_set("filter_formats:{$language->language}", $formats['all']);
431 }
432 }
433
434 // Build a list of user-specific formats.
435 if (isset($account) && !isset($formats['user'][$account->uid])) {
436 $formats['user'][$account->uid] = array();
437 foreach ($formats['all'] as $format) {
438 if (filter_access($format, $account)) {
439 $formats['user'][$account->uid][$format->format] = $format;
440 }
441 }
442 }
443
444 return isset($account) ? $formats['user'][$account->uid] : $formats['all'];
445 }
446
452 function filter_formats_reset() {
453 cache_clear_all('filter_formats', 'cache', TRUE);
454 cache_clear_all('filter_list_format', 'cache', TRUE);
455 drupal_static_reset('filter_list_format');
456 drupal_static_reset('filter_formats');
457 }
458
468 function filter_get_roles_by_format($format) {
469 // Handle the fallback format upfront (all roles have access to this format).
470 if ($format->format == filter_fallback_format()) {
471 return user_roles();
472 }
473 // Do not list any roles if the permission does not exist.
474 $permission = filter_permission_name($format);
475 return !empty($permission) ? user_roles(FALSE, $permission) : array();
476 }
477
488 function filter_get_formats_by_role($rid) {
489 $formats = array();
490 foreach (filter_formats() as $format) {
491 $roles = filter_get_roles_by_format($format);
492 if (isset($roles[$rid])) {
493 $formats[$format->format] = $format;
494 }
495 }
496 return $formats;
497 }
498
524 function filter_default_format($account = NULL) {
525 global $user;
526 if (!isset($account)) {
527 $account = $user;
528 }
529 // Get a list of formats for this user, ordered by weight. The first one
530 // available is the user's default format.
531 $formats = filter_formats($account);
532 $format = reset($formats);
533 return $format->format;
534 }
535
565 function filter_fallback_format() {
566 // This variable is automatically set in the database for all installations
567 // of Drupal. In the event that it gets disabled or deleted somehow, there
568 // is no safe default to return, since we do not want to risk making an
569 // existing (and potentially unsafe) text format on the site automatically
570 // available to all users. Returning NULL at least guarantees that this
571 // cannot happen.
572 return variable_get('filter_fallback_format');
573 }
574
581 function filter_fallback_format_title() {
582 $fallback_format = filter_format_load(filter_fallback_format());
583 return filter_admin_format_title($fallback_format);
584 }
585
592 function filter_get_filters() {
593 $filters = &drupal_static(__FUNCTION__, array());
594
595 if (empty($filters)) {
596 foreach (module_implements('filter_info') as $module) {
597 $info = module_invoke($module, 'filter_info');
598 if (isset($info) && is_array($info)) {
599 // Assign the name of the module implementing the filters and ensure
600 // default values.
601 foreach (array_keys($info) as $name) {
602 $info[$name]['module'] = $module;
603 $info[$name] += array(
604 'description' => '',
605 'weight' => 0,
606 );
607 }
608 $filters = array_merge($filters, $info);
609 }
610 }
611 // Allow modules to alter filter definitions.
612 drupal_alter('filter_info', $filters);
613
614 uasort($filters, '_filter_list_cmp');
615 }
616
617 return $filters;
618 }
619
625 function _filter_list_cmp($a, $b) {
626 return strcmp($a['title'], $b['title']);
627 }
628
642 function filter_format_allowcache($format_id) {
643 $format = filter_format_load($format_id);
644 return !empty($format->cache);
645 }
646
662 function _filter_format_is_cacheable($format) {
663 if (empty($format->filters)) {
664 return TRUE;
665 }
666 $filter_info = filter_get_filters();
667 foreach ($format->filters as $name => $filter) {
668 // By default, 'cache' is TRUE for all filters unless specified otherwise.
669 if (!empty($filter['status']) && isset($filter_info[$name]['cache']) && !$filter_info[$name]['cache']) {
670 return FALSE;
671 }
672 }
673 return TRUE;
674 }
675
691 function filter_list_format($format_id) {
692 $filters = &drupal_static(__FUNCTION__, array());
693 $filter_info = filter_get_filters();
694
695 if (!isset($filters['all'])) {
696 if ($cache = cache_get('filter_list_format')) {
697 $filters['all'] = $cache->data;
698 }
699 else {
700 $result = db_query('SELECT * FROM {filter} ORDER BY weight, module, name');
701 foreach ($result as $record) {
702 $filters['all'][$record->format][$record->name] = $record;
703 }
704 cache_set('filter_list_format', $filters['all']);
705 }
706 }
707
708 if (!isset($filters[$format_id])) {
709 $format_filters = array();
710 $filter_map = isset($filters['all'][$format_id]) ? $filters['all'][$format_id] : array();
711 foreach ($filter_map as $name => $filter) {
712 if (isset($filter_info[$name])) {
713 $filter->title = $filter_info[$name]['title'];
714 // Unpack stored filter settings.
715 $filter->settings = (isset($filter->settings) ? unserialize($filter->settings) : array());
716 // Merge in default settings.
717 if (isset($filter_info[$name]['default settings'])) {
718 $filter->settings += $filter_info[$name]['default settings'];
719 }
720
721 $format_filters[$name] = $filter;
722 }
723 }
724 $filters[$format_id] = $format_filters;
725 }
726
727 return isset($filters[$format_id]) ? $filters[$format_id] : array();
728 }
729
759 function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE) {
760 if (!isset($format_id)) {
761 $format_id = filter_fallback_format();
762 }
763 // If the requested text format does not exist, the text cannot be filtered.
764 if (!$format = filter_format_load($format_id)) {
765 watchdog('filter', 'Missing text format: %format.', array('%format' => $format_id), WATCHDOG_ALERT);
766 return '';
767 }
768
769 // Check for a cached version of this piece of text.
770 $cache = $cache && !empty($format->cache);
771 $cache_id = '';
772 if ($cache) {
773 $cache_id = $format->format . ':' . $langcode . ':' . hash('sha256', $text);
774 if ($cached = cache_get($cache_id, 'cache_filter')) {
775 return $cached->data;
776 }
777 }
778
779 // Convert all Windows and Mac newlines to a single newline, so filters only
780 // need to deal with one possibility.
781 $text = str_replace(array("\r\n", "\r"), "\n", $text);
782
783 // Get a complete list of filters, ordered properly.
784 $filters = filter_list_format($format->format);
785 $filter_info = filter_get_filters();
786
787 // Give filters the chance to escape HTML-like data such as code or formulas.
788 foreach ($filters as $name => $filter) {
789 if ($filter->status && isset($filter_info[$name]['prepare callback']) && function_exists($filter_info[$name]['prepare callback'])) {
790 $function = $filter_info[$name]['prepare callback'];
791 $text = $function($text, $filter, $format, $langcode, $cache, $cache_id);
792 }
793 }
794
795 // Perform filtering.
796 foreach ($filters as $name => $filter) {
797 if ($filter->status && isset($filter_info[$name]['process callback']) && function_exists($filter_info[$name]['process callback'])) {
798 $function = $filter_info[$name]['process callback'];
799 $text = $function($text, $filter, $format, $langcode, $cache, $cache_id);
800 }
801 }
802
803 // Cache the filtered text. This cache is infinitely valid. It becomes
804 // obsolete when $text changes (which leads to a new $cache_id). It is
805 // automatically flushed when the text format is updated.
806 // @see filter_format_save()
807 if ($cache) {
808 cache_set($cache_id, $text, 'cache_filter');
809 }
810
811 return $text;
812 }
813
842 function filter_process_format($element) {
843 global $user;
844
845 // Ensure that children appear as subkeys of this element.
846 $element['#tree'] = TRUE;
847 $blacklist = array(
848 // Make form_builder() regenerate child properties.
849 '#parents',
850 '#id',
851 '#name',
852 // Do not copy this #process function to prevent form_builder() from
853 // recursing infinitely.
854 '#process',
855 // Description is handled by theme_text_format_wrapper().
856 '#description',
857 // Ensure proper ordering of children.
858 '#weight',
859 // Properties already processed for the parent element.
860 '#prefix',
861 '#suffix',
862 '#attached',
863 '#processed',
864 '#theme_wrappers',
865 );
866 // Move this element into sub-element 'value'.
867 unset($element['value']);
868 foreach (element_properties($element) as $key) {
869 if (!in_array($key, $blacklist)) {
870 $element['value'][$key] = $element[$key];
871 }
872 }
873
874 $element['value']['#type'] = $element['#base_type'];
875 $element['value'] += element_info($element['#base_type']);
876
877 // Turn original element into a text format wrapper.
878 $path = drupal_get_path('module', 'filter');
879 $element['#attached']['js'][] = $path . '/filter.js';
880 $element['#attached']['css'][] = $path . '/filter.css';
881
882 // Setup child container for the text format widget.
883 $element['format'] = array(
884 '#type' => 'fieldset',
885 '#attributes' => array('class' => array('filter-wrapper')),
886 );
887
888 // Prepare text format guidelines.
889 $element['format']['guidelines'] = array(
890 '#type' => 'container',
891 '#attributes' => array('class' => array('filter-guidelines')),
892 '#weight' => 20,
893 );
894 // Get a list of formats that the current user has access to.
895 $formats = filter_formats($user);
896 foreach ($formats as $format) {
897 $options[$format->format] = $format->name;
898 $element['format']['guidelines'][$format->format] = array(
899 '#theme' => 'filter_guidelines',
900 '#format' => $format,
901 );
902 }
903
904 // Use the default format for this user if none was selected.
905 if (!isset($element['#format'])) {
906 $element['#format'] = filter_default_format($user);
907 }
908
909 $element['format']['format'] = array(
910 '#type' => 'select',
911 '#title' => t('Text format'),
912 '#options' => $options,
913 '#default_value' => $element['#format'],
914 '#access' => count($formats) > 1,
915 '#weight' => 10,
916 '#attributes' => array('class' => array('filter-list')),
917 '#parents' => array_merge($element['#parents'], array('format')),
918 );
919
920 $element['format']['help'] = array(
921 '#type' => 'container',
922 '#theme' => 'filter_tips_more_info',
923 '#attributes' => array('class' => array('filter-help')),
924 '#weight' => 0,
925 );
926
927 $all_formats = filter_formats();
928 $format_exists = isset($all_formats[$element['#format']]);
929 $user_has_access = isset($formats[$element['#format']]);
930 $user_is_admin = user_access('administer filters');
931
932 // If the stored format does not exist, administrators have to assign a new
933 // format.
934 if (!$format_exists && $user_is_admin) {
935 $element['format']['format']['#required'] = TRUE;
936 $element['format']['format']['#default_value'] = NULL;
937 // Force access to the format selector (it may have been denied above if
938 // the user only has access to a single format).
939 $element['format']['format']['#access'] = TRUE;
940 }
941 // Disable this widget, if the user is not allowed to use the stored format,
942 // or if the stored format does not exist. The 'administer filters' permission
943 // only grants access to the filter administration, not to all formats.
944 elseif (!$user_has_access || !$format_exists) {
945 // Overload default values into #value to make them unalterable.
946 $element['value']['#value'] = $element['value']['#default_value'];
947 $element['format']['format']['#value'] = $element['format']['format']['#default_value'];
948
949 // Prepend #pre_render callback to replace field value with user notice
950 // prior to rendering.
951 $element['value'] += array('#pre_render' => array());
952 array_unshift($element['value']['#pre_render'], 'filter_form_access_denied');
953
954 // Cosmetic adjustments.
955 if (isset($element['value']['#rows'])) {
956 $element['value']['#rows'] = 3;
957 }
958 $element['value']['#disabled'] = TRUE;
959 $element['value']['#resizable'] = FALSE;
960
961 // Hide the text format selector and any other child element (such as text
962 // field's summary).
963 foreach (element_children($element) as $key) {
964 if ($key != 'value') {
965 $element[$key]['#access'] = FALSE;
966 }
967 }
968 }
969
970 return $element;
971 }
972
984 function filter_form_access_denied($element) {
985 $element['#value'] = t('This field has been disabled because you do not have sufficient permissions to edit it.');
986 return $element;
987 }
988
998 function theme_text_format_wrapper($variables) {
999 $element = $variables['element'];
1000 $output = '<div class="text-format-wrapper">';
1001 $output .= $element['#children'];
1002 if (!empty($element['#description'])) {
1003 $output .= '<div class="description">' . $element['#description'] . '</div>';
1004 }
1005 $output .= "</div>\n";
1006
1007 return $output;
1008 }
1009
1022 function filter_access($format, $account = NULL) {
1023 global $user;
1024 if (!isset($account)) {
1025 $account = $user;
1026 }
1027 // Handle special cases up front. All users have access to the fallback
1028 // format.
1029 if ($format->format == filter_fallback_format()) {
1030 return TRUE;
1031 }
1032 // Check the permission if one exists; otherwise, we have a non-existent
1033 // format so we return FALSE.
1034 $permission = filter_permission_name($format);
1035 return !empty($permission) && user_access($permission, $account);
1036 }
1037
1054 function _filter_tips($format_id, $long = FALSE) {
1055 global $user;
1056
1057 $formats = filter_formats($user);
1058 $filter_info = filter_get_filters();
1059
1060 $tips = array();
1061
1062 // If only listing one format, extract it from the $formats array.
1063 if ($format_id != -1) {
1064 $formats = array($formats[$format_id]);
1065 }
1066
1067 foreach ($formats as $format) {
1068 $filters = filter_list_format($format->format);
1069 $tips[$format->name] = array();
1070 foreach ($filters as $name => $filter) {
1071 if ($filter->status && isset($filter_info[$name]['tips callback']) && function_exists($filter_info[$name]['tips callback'])) {
1072 $tip = $filter_info[$name]['tips callback']($filter, $format, $long);
1073 if (isset($tip)) {
1074 $tips[$format->name][$name] = array('tip' => $tip, 'id' => $name);
1075 }
1076 }
1077 }
1078 }
1079
1080 return $tips;
1081 }
1082
1097 function filter_dom_load($text) {
1098 $dom_document = new DOMDocument();
1099 // Ignore warnings during HTML soup loading.
1100 @$dom_document->loadHTML('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body>' . $text . '</body></html>');
1101
1102 return $dom_document;
1103 }
1104
1119 function filter_dom_serialize($dom_document) {
1120 $body_node = $dom_document->getElementsByTagName('body')->item(0);
1121 $body_content = '';
1122
1123 foreach ($body_node->getElementsByTagName('script') as $node) {
1124 filter_dom_serialize_escape_cdata_element($dom_document, $node);
1125 }
1126
1127 foreach ($body_node->getElementsByTagName('style') as $node) {
1128 filter_dom_serialize_escape_cdata_element($dom_document, $node, '/*', '*/');
1129 }
1130
1131 foreach ($body_node->childNodes as $child_node) {
1132 $body_content .= $dom_document->saveXML($child_node);
1133 }
1134 return preg_replace('|<([^> ]*)/>|i', '<$1 />', $body_content);
1135 }
1136
1158 function filter_dom_serialize_escape_cdata_element($dom_document, $dom_element, $comment_start = '//', $comment_end = '') {
1159 foreach ($dom_element->childNodes as $node) {
1160 if (get_class($node) == 'DOMCdataSection') {
1161 // See drupal_get_js(). This code is more or less duplicated there.
1162 $embed_prefix = "\n<!--{$comment_start}--><![CDATA[{$comment_start} ><!--{$comment_end}\n";
1163 $embed_suffix = "\n{$comment_start}--><!]]>{$comment_end}\n";
1164
1165 // Prevent invalid cdata escaping as this would throw a DOM error.
1166 // This is the same behavior as found in libxml2.
1167 // Related W3C standard: http://www.w3.org/TR/REC-xml/#dt-cdsection
1168 // Fix explanation: http://en.wikipedia.org/wiki/CDATA#Nesting
1169 $data = str_replace(']]>', ']]]]><![CDATA[>', $node->data);
1170
1171 $fragment = $dom_document->createDocumentFragment();
1172 $fragment->appendXML($embed_prefix . $data . $embed_suffix);
1173 $dom_element->appendChild($fragment);
1174 $dom_element->removeChild($node);
1175 }
1176 }
1177 }
1178
1184 function theme_filter_tips_more_info() {
1185 return '<p>' . l(t('More information about text formats'), 'filter/tips', array('attributes' => array('target' => '_blank'))) . '</p>';
1186 }
1187
1197 function theme_filter_guidelines($variables) {
1198 $format = $variables['format'];
1199 $attributes['class'][] = 'filter-guidelines-item';
1200 $attributes['class'][] = 'filter-guidelines-' . $format->format;
1201 $output = '<div' . drupal_attributes($attributes) . '>';
1202 $output .= '<h3>' . check_plain($format->name) . '</h3>';
1203 $output .= theme('filter_tips', array('tips' => _filter_tips($format->format, FALSE)));
1204 $output .= '</div>';
1205 return $output;
1206 }
1207
1217 function filter_filter_info() {
1218 $filters['filter_html'] = array(
1219 'title' => t('Limit allowed HTML tags'),
1220 'process callback' => '_filter_html',
1221 'settings callback' => '_filter_html_settings',
1222 'default settings' => array(
1223 'allowed_html' => '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>',
1224 'filter_html_help' => 1,
1225 'filter_html_nofollow' => 0,
1226 ),
1227 'tips callback' => '_filter_html_tips',
1228 'weight' => -10,
1229 );
1230 $filters['filter_autop'] = array(
1231 'title' => t('Convert line breaks into HTML (i.e. <code>&lt;br&gt;</code> and <code>&lt;p&gt;</code>)'),
1232 'process callback' => '_filter_autop',
1233 'tips callback' => '_filter_autop_tips',
1234 );
1235 $filters['filter_url'] = array(
1236 'title' => t('Convert URLs into links'),
1237 'process callback' => '_filter_url',
1238 'settings callback' => '_filter_url_settings',
1239 'default settings' => array(
1240 'filter_url_length' => 72,
1241 ),
1242 'tips callback' => '_filter_url_tips',
1243 );
1244 $filters['filter_htmlcorrector'] = array(
1245 'title' => t('Correct faulty and chopped off HTML'),
1246 'process callback' => '_filter_htmlcorrector',
1247 'weight' => 10,
1248 );
1249 $filters['filter_html_escape'] = array(
1250 'title' => t('Display any HTML as plain text'),
1251 'process callback' => '_filter_html_escape',
1252 'tips callback' => '_filter_html_escape_tips',
1253 'weight' => -10,
1254 );
1255 return $filters;
1256 }
1257
1263 function _filter_html_settings($form, &$form_state, $filter, $format, $defaults) {
1264 $filter->settings += $defaults;
1265
1266 $settings['allowed_html'] = array(
1267 '#type' => 'textfield',
1268 '#title' => t('Allowed HTML tags'),
1269 '#default_value' => $filter->settings['allowed_html'],
1270 '#maxlength' => 1024,
1271 '#description' => t('A list of HTML tags that can be used. JavaScript event attributes, JavaScript URLs, and CSS are always stripped.'),
1272 );
1273 $settings['filter_html_help'] = array(
1274 '#type' => 'checkbox',
1275 '#title' => t('Display basic HTML help in long filter tips'),
1276 '#default_value' => $filter->settings['filter_html_help'],
1277 );
1278 $settings['filter_html_nofollow'] = array(
1279 '#type' => 'checkbox',
1280 '#title' => t('Add rel="nofollow" to all links'),
1281 '#default_value' => $filter->settings['filter_html_nofollow'],
1282 );
1283 return $settings;
1284 }
1285
1291 function _filter_html($text, $filter) {
1292 $allowed_tags = preg_split('/\s+|<|>/', $filter->settings['allowed_html'], -1, PREG_SPLIT_NO_EMPTY);
1293 $text = filter_xss($text, $allowed_tags);
1294
1295 if ($filter->settings['filter_html_nofollow']) {
1296 $html_dom = filter_dom_load($text);
1297 $links = $html_dom->getElementsByTagName('a');
1298 foreach ($links as $link) {
1299 $link->setAttribute('rel', 'nofollow');
1300 }
1301 $text = filter_dom_serialize($html_dom);
1302 }
1303
1304 return trim($text);
1305 }
1306
1314 function _filter_html_tips($filter, $format, $long = FALSE) {
1315 global $base_url;
1316
1317 if (!($allowed_html = $filter->settings['allowed_html'])) {
1318 return;
1319 }
1320 $output = t('Allowed HTML tags: @tags', array('@tags' => $allowed_html));
1321 if (!$long) {
1322 return $output;
1323 }
1324
1325 $output = '<p>' . $output . '</p>';
1326 if (!$filter->settings['filter_html_help']) {
1327 return $output;
1328 }
1329
1330 $output .= '<p>' . t('This site allows HTML content. While learning all of HTML may feel intimidating, learning how to use a very small number of the most basic HTML "tags" is very easy. This table provides examples for each tag that is enabled on this site.') . '</p>';
1331 $output .= '<p>' . t('For more information see W3C\'s <a href="@html-specifications">HTML Specifications</a> or use your favorite search engine to find other sites that explain HTML.', array('@html-specifications' => 'http://www.w3.org/TR/html/')) . '</p>';
1332 $tips = array(
1333 'a' => array(t('Anchors are used to make links to other pages.'), '<a href="' . $base_url . '">' . check_plain(variable_get('site_name', 'Drupal')) . '</a>'),
1334 'br' => array(t('By default line break tags are automatically added, so use this tag to add additional ones. Use of this tag is different because it is not used with an open/close pair like all the others. Use the extra " /" inside the tag to maintain XHTML 1.0 compatibility'), t('Text with <br />line break')),
1335 'p' => array(t('By default paragraph tags are automatically added, so use this tag to add additional ones.'), '<p>' . t('Paragraph one.') . '</p> <p>' . t('Paragraph two.') . '</p>'),
1336 'strong' => array(t('Strong', array(), array('context' => 'Font weight')), '<strong>' . t('Strong', array(), array('context' => 'Font weight')) . '</strong>'),
1337 'em' => array(t('Emphasized'), '<em>' . t('Emphasized') . '</em>'),
1338 'cite' => array(t('Cited'), '<cite>' . t('Cited') . '</cite>'),
1339 'code' => array(t('Coded text used to show programming source code'), '<code>' . t('Coded') . '</code>'),
1340 'b' => array(t('Bolded'), '<b>' . t('Bolded') . '</b>'),
1341 'u' => array(t('Underlined'), '<u>' . t('Underlined') . '</u>'),
1342 'i' => array(t('Italicized'), '<i>' . t('Italicized') . '</i>'),
1343 'sup' => array(t('Superscripted'), t('<sup>Super</sup>scripted')),
1344 'sub' => array(t('Subscripted'), t('<sub>Sub</sub>scripted')),
1345 'pre' => array(t('Preformatted'), '<pre>' . t('Preformatted') . '</pre>'),
1346 'abbr' => array(t('Abbreviation'), t('<abbr title="Abbreviation">Abbrev.</abbr>')),
1347 'acronym' => array(t('Acronym'), t('<acronym title="Three-Letter Acronym">TLA</acronym>')),
1348 'blockquote' => array(t('Block quoted'), '<blockquote>' . t('Block quoted') . '</blockquote>'),
1349 'q' => array(t('Quoted inline'), '<q>' . t('Quoted inline') . '</q>'),
1350 // Assumes and describes tr, td, th.
1351 'table' => array(t('Table'), '<table> <tr><th>' . t('Table header') . '</th></tr> <tr><td>' . t('Table cell') . '</td></tr> </table>'),
1352 'tr' => NULL, 'td' => NULL, 'th' => NULL,
1353 'del' => array(t('Deleted'), '<del>' . t('Deleted') . '</del>'),
1354 'ins' => array(t('Inserted'), '<ins>' . t('Inserted') . '</ins>'),
1355 // Assumes and describes li.
1356 'ol' => array(t('Ordered list - use the &lt;li&gt; to begin each list item'), '<ol> <li>' . t('First item') . '</li> <li>' . t('Second item') . '</li> </ol>'),
1357 'ul' => array(t('Unordered list - use the &lt;li&gt; to begin each list item'), '<ul> <li>' . t('First item') . '</li> <li>' . t('Second item') . '</li> </ul>'),
1358 'li' => NULL,
1359 // Assumes and describes dt and dd.
1360 'dl' => array(t('Definition lists are similar to other HTML lists. &lt;dl&gt; begins the definition list, &lt;dt&gt; begins the definition term and &lt;dd&gt; begins the definition description.'), '<dl> <dt>' . t('First term') . '</dt> <dd>' . t('First definition') . '</dd> <dt>' . t('Second term') . '</dt> <dd>' . t('Second definition') . '</dd> </dl>'),
1361 'dt' => NULL, 'dd' => NULL,
1362 'h1' => array(t('Heading'), '<h1>' . t('Title') . '</h1>'),
1363 'h2' => array(t('Heading'), '<h2>' . t('Subtitle') . '</h2>'),
1364 'h3' => array(t('Heading'), '<h3>' . t('Subtitle three') . '</h3>'),
1365 'h4' => array(t('Heading'), '<h4>' . t('Subtitle four') . '</h4>'),
1366 'h5' => array(t('Heading'), '<h5>' . t('Subtitle five') . '</h5>'),
1367 'h6' => array(t('Heading'), '<h6>' . t('Subtitle six') . '</h6>')
1368 );
1369 $header = array(t('Tag Description'), t('You Type'), t('You Get'));
1370 preg_match_all('/<([a-z0-9]+)[^a-z0-9]/i', $allowed_html, $out);
1371 foreach ($out[1] as $tag) {
1372 if (!empty($tips[$tag])) {
1373 $rows[] = array(
1374 array('data' => $tips[$tag][0], 'class' => array('description')),
1375 array('data' => '<code>' . check_plain($tips[$tag][1]) . '</code>', 'class' => array('type')),
1376 array('data' => $tips[$tag][1], 'class' => array('get'))
1377 );
1378 }
1379 else {
1380 $rows[] = array(
1381 array('data' => t('No help provided for tag %tag.', array('%tag' => $tag)), 'class' => array('description'), 'colspan' => 3),
1382 );
1383 }
1384 }
1385 $output .= theme('table', array('header' => $header, 'rows' => $rows));
1386
1387 $output .= '<p>' . t('Most unusual characters can be directly entered without any problems.') . '</p>';
1388 $output .= '<p>' . t('If you do encounter problems, try using HTML character entities. A common example looks like &amp;amp; for an ampersand &amp; character. For a full list of entities see HTML\'s <a href="@html-entities">entities</a> page. Some of the available characters include:', array('@html-entities' => 'http://www.w3.org/TR/html4/sgml/entities.html')) . '</p>';
1389
1390 $entities = array(
1391 array(t('Ampersand'), '&amp;'),
1392 array(t('Greater than'), '&gt;'),
1393 array(t('Less than'), '&lt;'),
1394 array(t('Quotation mark'), '&quot;'),
1395 );
1396 $header = array(t('Character Description'), t('You Type'), t('You Get'));
1397 unset($rows);
1398 foreach ($entities as $entity) {
1399 $rows[] = array(
1400 array('data' => $entity[0], 'class' => array('description')),
1401 array('data' => '<code>' . check_plain($entity[1]) . '</code>', 'class' => array('type')),
1402 array('data' => $entity[1], 'class' => array('get'))
1403 );
1404 }
1405 $output .= theme('table', array('header' => $header, 'rows' => $rows));
1406 return $output;
1407 }
1408
1416 function _filter_url_settings($form, &$form_state, $filter, $format, $defaults) {
1417 $filter->settings += $defaults;
1418
1419 $settings['filter_url_length'] = array(
1420 '#type' => 'textfield',
1421 '#title' => t('Maximum link text length'),
1422 '#default_value' => $filter->settings['filter_url_length'],
1423 '#size' => 5,
1424 '#maxlength' => 4,
1425 '#field_suffix' => t('characters'),
1426 '#description' => t('URLs longer than this number of characters will be truncated to prevent long strings that break formatting. The link itself will be retained; just the text portion of the link will be truncated.'),
1427 '#element_validate' => array('element_validate_integer_positive'),
1428 );
1429 return $settings;
1430 }
1431
1444 function _filter_url($text, $filter) {
1445 // Tags to skip and not recurse into.
1446 $ignore_tags = 'a|script|style|code|pre';
1447
1448 // Pass length to regexp callback.
1449 _filter_url_trim(NULL, $filter->settings['filter_url_length']);
1450
1451 // Create an array which contains the regexps for each type of link.
1452 // The key to the regexp is the name of a function that is used as
1453 // callback function to process matches of the regexp. The callback function
1454 // is to return the replacement for the match. The array is used and
1455 // matching/replacement done below inside some loops.
1456 $tasks = array();
1457
1458 // Prepare protocols pattern for absolute URLs.
1459 // check_url() will replace any bad protocols with HTTP, so we need to support
1460 // the identical list. While '//' is technically optional for MAILTO only,
1461 // we cannot cleanly differ between protocols here without hard-coding MAILTO,
1462 // so '//' is optional for all protocols.
1463 // @see filter_xss_bad_protocol()
1464 $protocols = variable_get('filter_allowed_protocols', array('ftp', 'http', 'https', 'irc', 'mailto', 'news', 'nntp', 'rtsp', 'sftp', 'ssh', 'tel', 'telnet', 'webcal'));
1465 $protocols = implode(':(?://)?|', $protocols) . ':(?://)?';
1466
1467 // Prepare domain name pattern.
1468 // The ICANN seems to be on track towards accepting more diverse top level
1469 // domains, so this pattern has been "future-proofed" to allow for TLDs
1470 // of length 2-64.
1471 $domain = '(?:[A-Za-z0-9._+-]+\.)?[A-Za-z]{2,64}\b';
1472 $ip = '(?:[0-9]{1,3}\.){3}[0-9]{1,3}';
1473 $auth = '[a-zA-Z0-9:%_+*~#?&=.,/;-]+@';
1474 $trail = '[a-zA-Z0-9:%_+*~#&\[\]=/;?!\.,-]*[a-zA-Z0-9:%_+*~#&\[\]=/;-]';
1475
1476 // Prepare pattern for optional trailing punctuation.
1477 // Even these characters could have a valid meaning for the URL, such usage is
1478 // rare compared to using a URL at the end of or within a sentence, so these
1479 // trailing characters are optionally excluded.
1480 $punctuation = '[\.,?!]*?';
1481
1482 // Match absolute URLs.
1483 $url_pattern = "(?:$auth)?(?:$domain|$ip)/?(?:$trail)?";
1484 $pattern = "`((?:$protocols)(?:$url_pattern))($punctuation)`";
1485 $tasks['_filter_url_parse_full_links'] = $pattern;
1486
1487 // Match e-mail addresses.
1488 $url_pattern = "[A-Za-z0-9._-]{1,254}@(?:$domain)";
1489 $pattern = "`($url_pattern)`";
1490 $tasks['_filter_url_parse_email_links'] = $pattern;
1491
1492 // Match www domains.
1493 $url_pattern = "www\.(?:$domain)/?(?:$trail)?";
1494 $pattern = "`($url_pattern)($punctuation)`";
1495 $tasks['_filter_url_parse_partial_links'] = $pattern;
1496
1497 // Each type of URL needs to be processed separately. The text is joined and
1498 // re-split after each task, since all injected HTML tags must be correctly
1499 // protected before the next task.
1500 foreach ($tasks as $task => $pattern) {
1501 // HTML comments need to be handled separately, as they may contain HTML
1502 // markup, especially a '>'. Therefore, remove all comment contents and add
1503 // them back later.
1504 _filter_url_escape_comments('', TRUE);
1505 $text = preg_replace_callback('`<!--(.*?)-->`s', '_filter_url_escape_comments', $text);
1506
1507 // Split at all tags; ensures that no tags or attributes are processed.
1508 $chunks = preg_split('/(<.+?>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
1509 // PHP ensures that the array consists of alternating delimiters and
1510 // literals, and begins and ends with a literal (inserting NULL as
1511 // required). Therefore, the first chunk is always text:
1512 $chunk_type = 'text';
1513 // If a tag of $ignore_tags is found, it is stored in $open_tag and only
1514 // removed when the closing tag is found. Until the closing tag is found,
1515 // no replacements are made.
1516 $open_tag = '';
1517
1518 for ($i = 0; $i < count($chunks); $i++) {
1519 if ($chunk_type == 'text') {
1520 // Only process this text if there are no unclosed $ignore_tags.
1521 if ($open_tag == '') {
1522 // If there is a match, inject a link into this chunk via the callback
1523 // function contained in $task.
1524 $chunks[$i] = preg_replace_callback($pattern, $task, $chunks[$i]);
1525 }
1526 // Text chunk is done, so next chunk must be a tag.
1527 $chunk_type = 'tag';
1528 }
1529 else {
1530 // Only process this tag if there are no unclosed $ignore_tags.
1531 if ($open_tag == '') {
1532 // Check whether this tag is contained in $ignore_tags.
1533 if (preg_match("`<($ignore_tags)(?:\s|>)`i", $chunks[$i], $matches)) {
1534 $open_tag = $matches[1];
1535 }
1536 }
1537 // Otherwise, check whether this is the closing tag for $open_tag.
1538 else {
1539 if (preg_match("`<\/$open_tag>`i", $chunks[$i], $matches)) {
1540 $open_tag = '';
1541 }
1542 }
1543 // Tag chunk is done, so next chunk must be text.
1544 $chunk_type = 'text';
1545 }
1546 }
1547
1548 $text = implode($chunks);
1549 // Revert back to the original comment contents
1550 _filter_url_escape_comments('', FALSE);
1551 $text = preg_replace_callback('`<!--(.*?)-->`', '_filter_url_escape_comments', $text);
1552 }
1553
1554 return $text;
1555 }
1556
1562 function _filter_url_parse_full_links($match) {
1563 // The $i:th parenthesis in the regexp contains the URL.
1564 $i = 1;
1565
1566 $match[$i] = decode_entities($match[$i]);
1567 $caption = check_plain(_filter_url_trim($match[$i]));
1568 $match[$i] = check_plain($match[$i]);
1569 return '<a href="' . $match[$i] . '">' . $caption . '</a>' . $match[$i + 1];
1570 }
1571
1577 function _filter_url_parse_email_links($match) {
1578 // The $i:th parenthesis in the regexp contains the URL.
1579 $i = 0;
1580
1581 $match[$i] = decode_entities($match[$i]);
1582 $caption = check_plain(_filter_url_trim($match[$i]));
1583 $match[$i] = check_plain($match[$i]);
1584 return '<a href="mailto:' . $match[$i] . '">' . $caption . '</a>';
1585 }
1586
1592 function _filter_url_parse_partial_links($match) {
1593 // The $i:th parenthesis in the regexp contains the URL.
1594 $i = 1;
1595
1596 $match[$i] = decode_entities($match[$i]);
1597 $caption = check_plain(_filter_url_trim($match[$i]));
1598 $match[$i] = check_plain($match[$i]);
1599 return '<a href="http://' . $match[$i] . '">' . $caption . '</a>' . $match[$i + 1];
1600 }
1601
1615 function _filter_url_escape_comments($match, $escape = NULL) {
1616 static $mode, $comments = array();
1617
1618 if (isset($escape)) {
1619 $mode = $escape;
1620 if ($escape){
1621 $comments = array();
1622 }
1623 return;
1624 }
1625
1626 // Replace all HTML coments with a '<!-- [hash] -->' placeholder.
1627 if ($mode) {
1628 $content = $match[1];
1629 $hash = md5($content);
1630 $comments[$hash] = $content;
1631 return "<!-- $hash -->";
1632 }
1633 // Or replace placeholders with actual comment contents.
1634 else {
1635 $hash = $match[1];
1636 $hash = trim($hash);
1637 $content = $comments[$hash];
1638 return "<!--$content-->";
1639 }
1640 }
1641
1645 function _filter_url_trim($text, $length = NULL) {
1646 static $_length;
1647 if ($length !== NULL) {
1648 $_length = $length;
1649 }
1650
1651 // Use +3 for '...' string length.
1652 if ($_length && strlen($text) > $_length + 3) {
1653 $text = substr($text, 0, $_length) . '...';
1654 }
1655
1656 return $text;
1657 }
1658
1666 function _filter_url_tips($filter, $format, $long = FALSE) {
1667 return t('Web page addresses and e-mail addresses turn into links automatically.');
1668 }
1669
1675 function _filter_htmlcorrector($text) {
1676 return filter_dom_serialize(filter_dom_load($text));
1677 }
1678
1686 function _filter_autop($text) {
1687 // All block level tags
1688 $block = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|p|h[1-6]|hr)';
1689
1690 // Split at opening and closing PRE, SCRIPT, STYLE, OBJECT, IFRAME tags
1691 // and comments. We don't apply any processing to the contents of these tags
1692 // to avoid messing up code. We look for matched pairs and allow basic
1693 // nesting. For example:
1694 // "processed <pre> ignored <script> ignored </script> ignored </pre> processed"
1695 $chunks = preg_split('@(<!--.*?-->|</?(?:pre|script|style|object|iframe|!--)[^>]*>)@i', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
1696 // Note: PHP ensures the array consists of alternating delimiters and literals
1697 // and begins and ends with a literal (inserting NULL as required).
1698 $ignore = FALSE;
1699 $ignoretag = '';
1700 $output = '';
1701 foreach ($chunks as $i => $chunk) {
1702 if ($i % 2) {
1703 $comment = (substr($chunk, 0, 4) == '<!--');
1704 if ($comment) {
1705 // Nothing to do, this is a comment.
1706 $output .= $chunk;
1707 continue;
1708 }
1709 // Opening or closing tag?
1710 $open = ($chunk[1] != '/');
1711 list($tag) = preg_split('/[ >]/', substr($chunk, 2 - $open), 2);
1712 if (!$ignore) {
1713 if ($open) {
1714 $ignore = TRUE;
1715 $ignoretag = $tag;
1716 }
1717 }
1718 // Only allow a matching tag to close it.
1719 elseif (!$open && $ignoretag == $tag) {
1720 $ignore = FALSE;
1721 $ignoretag = '';
1722 }
1723 }
1724 elseif (!$ignore) {
1725 $chunk = preg_replace('|\n*$|', '', $chunk) . "\n\n"; // just to make things a little easier, pad the end
1726 $chunk = preg_replace('|<br />\s*<br />|', "\n\n", $chunk);
1727 $chunk = preg_replace('!(<' . $block . '[^>]*>)!', "\n$1", $chunk); // Space things out a little
1728 $chunk = preg_replace('!(</' . $block . '>)!', "$1\n\n", $chunk); // Space things out a little
1729 $chunk = preg_replace("/\n\n+/", "\n\n", $chunk); // take care of duplicates
1730 $chunk = preg_replace('/^\n|\n\s*\n$/', '', $chunk);
1731 $chunk = '<p>' . preg_replace('/\n\s*\n\n?(.)/', "</p>\n<p>$1", $chunk) . "</p>\n"; // make paragraphs, including one at the end
1732 $chunk = preg_replace("|<p>(<li.+?)</p>|", "$1", $chunk); // problem with nested lists
1733 $chunk = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $chunk);
1734 $chunk = str_replace('</blockquote></p>', '</p></blockquote>', $chunk);
1735 $chunk = preg_replace('|<p>\s*</p>\n?|', '', $chunk); // under certain strange conditions it could create a P of entirely whitespace
1736 $chunk = preg_replace('!<p>\s*(</?' . $block . '[^>]*>)!', "$1", $chunk);
1737 $chunk = preg_replace('!(</?' . $block . '[^>]*>)\s*</p>!', "$1", $chunk);
1738 $chunk = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $chunk); // make line breaks
1739 $chunk = preg_replace('!(</?' . $block . '[^>]*>)\s*<br />!', "$1", $chunk);
1740 $chunk = preg_replace('!<br />(\s*</?(?:p|li|div|th|pre|td|ul|ol)>)!', '$1', $chunk);
1741 $chunk = preg_replace('/&([^#])(?![A-Za-z0-9]{1,8};)/', '&amp;$1', $chunk);
1742 }
1743 $output .= $chunk;
1744 }
1745 return $output;
1746 }
1747
1755 function _filter_autop_tips($filter, $format, $long = FALSE) {
1756 if ($long) {
1757 return t('Lines and paragraphs are automatically recognized. The &lt;br /&gt; line break, &lt;p&gt; paragraph and &lt;/p&gt; close paragraph tags are inserted automatically. If paragraphs are not recognized simply add a couple blank lines.');
1758 }
1759 else {
1760 return t('Lines and paragraphs break automatically.');
1761 }
1762 }
1763
1769 function _filter_html_escape($text) {
1770 return trim(check_plain($text));
1771 }
1772
1780 function _filter_html_escape_tips($filter, $format, $long = FALSE) {
1781 return t('No HTML tags allowed.');
1782 }
1783
_filter_tips
_filter_tips($format_id, $long=FALSE)
Definition: filter.module:1054
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
decode_entities
decode_entities($text)
Definition: unicode.inc:457
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
filter_format_disable
filter_format_disable($format)
Definition: filter.module:291
filter_modules_disabled
filter_modules_disabled($modules)
Definition: filter.module:392
filter_filter_info
filter_filter_info()
Definition: filter.module:1217
filter_get_filters
filter_get_filters()
Definition: filter.module:592
filter_format_allowcache
filter_format_allowcache($format_id)
Definition: filter.module:642
filter_permission_name
filter_permission_name($format)
Definition: filter.module:373
SAVED_UPDATED
const SAVED_UPDATED
Definition: common.inc:50
_filter_html_escape_tips
_filter_html_escape_tips($filter, $format, $long=FALSE)
Definition: filter.module:1780
$module
print $module
Definition: search-results.tpl.php:28
element_properties
element_properties($element)
Definition: common.inc:6388
$name
print $name
Definition: profile-listing.tpl.php:43
$header
print $header
Definition: forum-topic-list.tpl.php:42
drupal_attributes
drupal_attributes(array $attributes=array())
Definition: common.inc:2377
_filter_list_cmp
_filter_list_cmp($a, $b)
Definition: filter.module:625
$attributes
print $attributes
Definition: block.tpl.php:47
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
user_roles
user_roles($membersonly=FALSE, $permission=NULL)
Definition: user.module:2871
_filter_html_settings
_filter_html_settings($form, &$form_state, $filter, $format, $defaults)
Definition: filter.module:1263
element_info
element_info($type)
Definition: common.inc:6306
_filter_html
_filter_html($text, $filter)
Definition: filter.module:1291
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
filter_list_format
filter_list_format($format_id)
Definition: filter.module:691
filter_admin_format_title
filter_admin_format_title($format)
Definition: filter.module:333
theme_filter_tips_more_info
theme_filter_tips_more_info()
Definition: filter.module:1184
filter_dom_serialize_escape_cdata_element
filter_dom_serialize_escape_cdata_element($dom_document, $dom_element, $comment_start= '//', $comment_end= '')
Definition: filter.module:1158
_filter_url_tips
_filter_url_tips($filter, $format, $long=FALSE)
Definition: filter.module:1666
_filter_autop_tips
_filter_autop_tips($filter, $format, $long=FALSE)
Definition: filter.module:1755
_filter_url_parse_full_links
_filter_url_parse_full_links($match)
Definition: filter.module:1562
WATCHDOG_ALERT
const WATCHDOG_ALERT
Definition: bootstrap.inc:83
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
filter_format_save
filter_format_save($format)
Definition: filter.module:198
filter_help
filter_help($path, $arg)
Definition: filter.module:11
filter_element_info
filter_element_info()
Definition: filter.module:76
filter_theme
filter_theme()
Definition: filter.module:44
$info
$info
Definition: color.inc:6
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
_filter_html_tips
_filter_html_tips($filter, $format, $long=FALSE)
Definition: filter.module:1314
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
filter_dom_load
filter_dom_load($text)
Definition: filter.module:1097
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
filter_get_formats_by_role
filter_get_formats_by_role($rid)
Definition: filter.module:488
filter_permission
filter_permission()
Definition: filter.module:340
$output
$output
Definition: authorize.php:93
theme_filter_guidelines
theme_filter_guidelines($variables)
Definition: filter.module:1197
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
filter_dom_serialize
filter_dom_serialize($dom_document)
Definition: filter.module:1119
MENU_SUGGESTED_ITEM
const MENU_SUGGESTED_ITEM
Definition: menu.inc:161
SAVED_NEW
const SAVED_NEW
Definition: common.inc:45
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
filter_formats
filter_formats($account=NULL)
Definition: filter.module:412
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
filter_format_exists
filter_format_exists($format_id)
Definition: filter.module:318
filter_process_format
filter_process_format($element)
Definition: filter.module:842
_filter_url_trim
_filter_url_trim($text, $length=NULL)
Definition: filter.module:1645
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
filter_form_access_denied
filter_form_access_denied($element)
Definition: filter.module:984
_filter_html_escape
_filter_html_escape($text)
Definition: filter.module:1769
drupal_placeholder
drupal_placeholder($text)
Definition: bootstrap.inc:3396
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
filter_access
filter_access($format, $account=NULL)
Definition: filter.module:1022
filter_get_roles_by_format
filter_get_roles_by_format($format)
Definition: filter.module:468
theme_text_format_wrapper
theme_text_format_wrapper($variables)
Definition: filter.module:998
_filter_url_escape_comments
_filter_url_escape_comments($match, $escape=NULL)
Definition: filter.module:1615
_filter_url_settings
_filter_url_settings($form, &$form_state, $filter, $format, $defaults)
Definition: filter.module:1416
filter_default_format
filter_default_format($account=NULL)
Definition: filter.module:524
_filter_htmlcorrector
_filter_htmlcorrector($text)
Definition: filter.module:1675
check_markup
check_markup($text, $format_id=NULL, $langcode= '', $cache=FALSE)
Definition: filter.module:759
_filter_url
_filter_url($text, $filter)
Definition: filter.module:1444
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
filter_formats_reset
filter_formats_reset()
Definition: filter.module:452
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
_filter_disable_format_access
_filter_disable_format_access($format)
Definition: filter.module:147
filter_fallback_format
filter_fallback_format()
Definition: filter.module:565
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
_filter_url_parse_partial_links
_filter_url_parse_partial_links($match)
Definition: filter.module:1592
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
_filter_url_parse_email_links
_filter_url_parse_email_links($match)
Definition: filter.module:1577
_filter_format_is_cacheable
_filter_format_is_cacheable($format)
Definition: filter.module:662
filter_menu
filter_menu()
Definition: filter.module:88
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
filter_fallback_format_title
filter_fallback_format_title()
Definition: filter.module:581
filter_format_load
filter_format_load($format_id)
Definition: filter.module:165
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
$links
print $links
Definition: poll-results--block.tpl.php:28
_filter_autop
_filter_autop($text)
Definition: filter.module:1686
filter_modules_enabled
filter_modules_enabled($modules)
Definition: filter.module:383
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/minimal/minimal.profile Source File

  • profiles
  • minimal
minimal.profile
Go to the documentation of this file.
1 <?php
12 function minimal_form_install_configure_form_alter(&$form, $form_state) {
13 // Pre-populate the site name with the server name.
14 $form['site_information']['site_name']['#default_value'] = $_SERVER['SERVER_NAME'];
15 }
minimal_form_install_configure_form_alter
minimal_form_install_configure_form_alter(&$form, $form_state)
Definition: minimal.profile:12
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/action_example/action_example.module Source File

  • examples
  • action_example
action_example.module
Go to the documentation of this file.
1 <?php
2
143 function action_example_action_info() {
144 return array(
145 'action_example_basic_action' => array(
146 'label' => t('Action Example: A basic example action that does nothing'),
147 'type' => 'system',
148 'configurable' => FALSE,
149 'triggers' => array('any'),
150 ),
151 'action_example_unblock_user_action' => array(
152 'label' => t('Action Example: Unblock a user'),
153 'type' => 'user',
154 'configurable' => FALSE,
155 'triggers' => array('any'),
156 ),
157 'action_example_node_sticky_action' => array(
158 'type' => 'node',
159 'label' => t('Action Example: Promote to frontpage and sticky on top any content created by :'),
160 'configurable' => TRUE,
161 'behavior' => array('changes_property'),
162 'triggers' => array('node_presave', 'node_insert', 'node_update'),
163 ),
164 );
165 }
166
167
168
174 function action_example_menu() {
175 $items['examples/action_example'] = array(
176 'title' => 'Action Example',
177 'description' => 'Provides a basic information page.',
178 'page callback' => '_action_example_page',
179 'access callback' => TRUE,
180 );
181 return $items;
182 }
183
184
188 function _action_example_page() {
189 return t("The Action Example provides three example actions which can be configured on the <a href='@actions_url'>Actions configuration page</a> and assigned to triggers on the <a href='@triggers_url'>Triggers configuration page</a>.", array('@actions_url' => url('admin/config/system/actions'), '@triggers_url' => url('admin/structure/trigger/node')));
190 }
191
205 function action_example_basic_action(&$entity, $context = array()) {
206 //
207 // In this case we are ignoring the entity and the context. This case of
208 // action is useful when your action does not depend on the context, and
209 // the function must do something regardless the scope of the trigger.
210 // Simply announces that the action was executed using a message.
211
212 drupal_set_message(t('action_example_basic_action fired'));
213 watchdog('action_example', 'action_example_basic_action fired.');
214 }
215
236 function action_example_unblock_user_action(&$entity, $context = array()) {
237
238 // First we check that entity is a user object. If this is the case, then this
239 // is a user-type trigger.
240 if (isset($entity->uid)) {
241 $uid = $entity->uid;
242 }
243 elseif (isset($context['uid'])) {
244 $uid = $context['uid'];
245 }
246 // If neither of those are valid, then block the current user.
247 else {
248 $uid = $GLOBALS['user']->uid;
249 }
250 $account = user_load($uid);
251 $account = user_save($account, array('status' => 1));
252 watchdog('action_example', 'Unblocked user %name.', array('%name' => $account->name));
253 drupal_set_message(t('Unblocked user %name', array('%name' => $account->name)));
254 }
255
285 function action_example_node_sticky_action_form($context) {
286 /*
287 * We return a configuration form to set the requirements that will
288 * match this action before being executed. This is a regular Drupal form and
289 * may include any type of information you want, but all the fields of the
290 * form will be saved into the $context variable.
291 *
292 * In this case we are promoting all content types submitted by this user, but
293 * it is possible to extend these conditions providing more options in the
294 * settings form.
295 */
296 $form['author'] = array(
297 '#title' => t('Author name'),
298 '#type' => 'textfield',
299 '#description' => t('Any content created, presaved or updated by this user will be promoted to front page and set as sticky.'),
300 '#default_value' => isset($context['author']) ? $context['author'] : '',
301 );
302 // Verify user permissions and provide an easier way to fill this field.
303 if (user_access('access user profiles')) {
304 $form['author']['#autocomplete_path'] = 'user/autocomplete';
305 }
306 // No more options, return the form.
307 return $form;
308 }
309
314 function action_example_node_sticky_action_validate($form, $form_state) {
315 if (! $account = user_load_by_name($form_state['values']['author']) ) {
316 form_set_error('author', t('Please, provide a valid username'));
317 }
318 }
319
326 function action_example_node_sticky_action_submit($form, $form_state) {
327 return array('author' => $form_state['values']['author']);
328 }
329
344 function action_example_node_sticky_action($node, $context) {
345 if (function_exists('dsm')) {
346 dsm($node, 'action_example_node_sticky_action is firing. Here is the $node');
347 dsm($context, 'action_example_node_sticky_action is firing. Here is the $context');
348 }
349 // Get the user configured for this special action.
350 $account = user_load_by_name($context['author']);
351 // Is the node created by this user? then promote and set as sticky.
352 if ($account->uid == $node->uid) {
353 $node->promote = NODE_PROMOTED;
354 $node->sticky = NODE_STICKY;
355 watchdog('action', 'Set @type %title to sticky and promoted by special action for user %username.', array('@type' => node_type_get_name($node), '%title' => $node->title, '%username' => $account->name));
356 drupal_set_message(t('Set @type %title to sticky and promoted by special action for user %username.', array('@type' => node_type_get_name($node), '%title' => $node->title, '%username' => $account->name)));
357 }
358 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
action_example_unblock_user_action
action_example_unblock_user_action(&$entity, $context=array())
Definition: action_example.module:236
action_example_action_info
action_example_action_info()
Definition: action_example.module:143
NODE_PROMOTED
const NODE_PROMOTED
Definition: node.module:27
action_example_node_sticky_action
action_example_node_sticky_action($node, $context)
Definition: action_example.module:344
user_save
user_save($account, $edit=array(), $category= 'account')
Definition: user.module:424
node_type_get_name
node_type_get_name($node)
Definition: node.module:459
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
action_example_menu
action_example_menu()
Definition: action_example.module:174
_action_example_page
_action_example_page()
Definition: action_example.module:188
action_example_node_sticky_action_validate
action_example_node_sticky_action_validate($form, $form_state)
Definition: action_example.module:314
action_example_basic_action
action_example_basic_action(&$entity, $context=array())
Definition: action_example.module:205
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
action_example_node_sticky_action_form
action_example_node_sticky_action_form($context)
Definition: action_example.module:285
user_access
user_access($string, $account=NULL)
Definition: user.module:794
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
action_example_node_sticky_action_submit
action_example_node_sticky_action_submit($form, $form_state)
Definition: action_example.module:326
user_load_by_name
user_load_by_name($name)
Definition: user.module:397
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
NODE_STICKY
const NODE_STICKY
Definition: node.module:37
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/install.inc Source File

  • includes
install.inc
Go to the documentation of this file.
1 <?php
2
11 define('SCHEMA_UNINSTALLED', -1);
12
16 define('SCHEMA_INSTALLED', 0);
17
21 define('REQUIREMENT_INFO', -1);
22
26 define('REQUIREMENT_OK', 0);
27
31 define('REQUIREMENT_WARNING', 1);
32
36 define('REQUIREMENT_ERROR', 2);
37
41 define('FILE_EXIST', 1);
42
46 define('FILE_READABLE', 2);
47
51 define('FILE_WRITABLE', 4);
52
56 define('FILE_EXECUTABLE', 8);
57
61 define('FILE_NOT_EXIST', 16);
62
66 define('FILE_NOT_READABLE', 32);
67
71 define('FILE_NOT_WRITABLE', 64);
72
76 define('FILE_NOT_EXECUTABLE', 128);
77
81 function drupal_load_updates() {
82 foreach (drupal_get_installed_schema_version(NULL, FALSE, TRUE) as $module => $schema_version) {
83 if ($schema_version > -1) {
84 module_load_install($module);
85 }
86 }
87 }
88
98 function drupal_get_schema_versions($module) {
99 $updates = &drupal_static(__FUNCTION__, NULL);
100 if (!isset($updates[$module])) {
101 $updates = array();
102
103 foreach (module_list() as $loaded_module) {
104 $updates[$loaded_module] = array();
105 }
106
107 // Prepare regular expression to match all possible defined hook_update_N().
108 $regexp = '/^(?P<module>.+)_update_(?P<version>\d+)$/';
109 $functions = get_defined_functions();
110 // Narrow this down to functions ending with an integer, since all
111 // hook_update_N() functions end this way, and there are other
112 // possible functions which match '_update_'. We use preg_grep() here
113 // instead of foreaching through all defined functions, since the loop
114 // through all PHP functions can take significant page execution time
115 // and this function is called on every administrative page via
116 // system_requirements().
117 foreach (preg_grep('/_\d+$/', $functions['user']) as $function) {
118 // If this function is a module update function, add it to the list of
119 // module updates.
120 if (preg_match($regexp, $function, $matches)) {
121 $updates[$matches['module']][] = $matches['version'];
122 }
123 }
124 // Ensure that updates are applied in numerical order.
125 foreach ($updates as &$module_updates) {
126 sort($module_updates, SORT_NUMERIC);
127 }
128 }
129 return empty($updates[$module]) ? FALSE : $updates[$module];
130 }
131
146 function drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE) {
147 static $versions = array();
148
149 if ($reset) {
150 $versions = array();
151 }
152
153 if (!$versions) {
154 $versions = array();
155 $result = db_query("SELECT name, schema_version FROM {system} WHERE type = :type", array(':type' => 'module'));
156 foreach ($result as $row) {
157 $versions[$row->name] = $row->schema_version;
158 }
159 }
160
161 if ($array) {
162 return $versions;
163 }
164 else {
165 return isset($versions[$module]) ? $versions[$module] : SCHEMA_UNINSTALLED;
166 }
167 }
168
177 function drupal_set_installed_schema_version($module, $version) {
178 db_update('system')
179 ->fields(array('schema_version' => $version))
180 ->condition('name', $module)
181 ->execute();
182
183 // Reset the static cache of module schema versions.
184 drupal_get_installed_schema_version(NULL, TRUE);
185 }
186
196 function drupal_install_profile_distribution_name() {
197 // During installation, the profile information is stored in the global
198 // installation state (it might not be saved anywhere yet).
199 if (drupal_installation_attempted()) {
200 global $install_state;
201 return $install_state['profile_info']['distribution_name'];
202 }
203 // At all other times, we load the profile via standard methods.
204 else {
205 $profile = drupal_get_profile();
206 $info = system_get_info('module', $profile);
207 return $info['distribution_name'];
208 }
209 }
210
221 function drupal_detect_baseurl($file = 'install.php') {
222 $proto = $_SERVER['HTTPS'] ? 'https://' : 'http://';
223 $host = $_SERVER['SERVER_NAME'];
224 $port = ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']);
225 $uri = preg_replace("/\?.*/", '', $_SERVER['REQUEST_URI']);
226 $dir = str_replace("/$file", '', $uri);
227
228 return "$proto$host$port$dir";
229 }
230
237 function drupal_detect_database_types() {
238 $databases = drupal_get_database_types();
239
240 foreach ($databases as $driver => $installer) {
241 $databases[$driver] = $installer->name();
242 }
243
244 return $databases;
245 }
246
253 function drupal_get_database_types() {
254 $databases = array();
255
256 // We define a driver as a directory in /includes/database that in turn
257 // contains a database.inc file. That allows us to drop in additional drivers
258 // without modifying the installer.
259 // Because we have no registry yet, we need to also include the install.inc
260 // file for the driver explicitly.
261 require_once DRUPAL_ROOT . '/includes/database/database.inc';
262 foreach (file_scan_directory(DRUPAL_ROOT . '/includes/database', '/^[a-z]*$/i', array('recurse' => FALSE)) as $file) {
263 if (file_exists($file->uri . '/database.inc') && file_exists($file->uri . '/install.inc')) {
264 $drivers[$file->filename] = $file->uri;
265 }
266 }
267
268 foreach ($drivers as $driver => $file) {
269 $installer = db_installer_object($driver);
270 if ($installer->installable()) {
271 $databases[$driver] = $installer;
272 }
273 }
274
275 // Usability: unconditionally put the MySQL driver on top.
276 if (isset($databases['mysql'])) {
277 $mysql_database = $databases['mysql'];
278 unset($databases['mysql']);
279 $databases = array('mysql' => $mysql_database) + $databases;
280 }
281
282 return $databases;
283 }
284
290 abstract class DatabaseTasks {
291
300 protected $tasks = array(
301 array(
302 'function' => 'checkEngineVersion',
303 'arguments' => array(),
304 ),
305 array(
306 'arguments' => array(
307 'CREATE TABLE {drupal_install_test} (id int NULL)',
308 'Drupal can use CREATE TABLE database commands.',
309 'Failed to <strong>CREATE</strong> a test table on your database server with the command %query. The server reports the following message: %error.<p>Are you sure the configured username has the necessary permissions to create tables in the database?</p>',
310 TRUE,
311 ),
312 ),
313 array(
314 'arguments' => array(
315 'INSERT INTO {drupal_install_test} (id) VALUES (1)',
316 'Drupal can use INSERT database commands.',
317 'Failed to <strong>INSERT</strong> a value into a test table on your database server. We tried inserting a value with the command %query and the server reported the following error: %error.',
318 ),
319 ),
320 array(
321 'arguments' => array(
322 'UPDATE {drupal_install_test} SET id = 2',
323 'Drupal can use UPDATE database commands.',
324 'Failed to <strong>UPDATE</strong> a value in a test table on your database server. We tried updating a value with the command %query and the server reported the following error: %error.',
325 ),
326 ),
327 array(
328 'arguments' => array(
329 'DELETE FROM {drupal_install_test}',
330 'Drupal can use DELETE database commands.',
331 'Failed to <strong>DELETE</strong> a value from a test table on your database server. We tried deleting a value with the command %query and the server reported the following error: %error.',
332 ),
333 ),
334 array(
335 'arguments' => array(
336 'DROP TABLE {drupal_install_test}',
337 'Drupal can use DROP TABLE database commands.',
338 'Failed to <strong>DROP</strong> a test table from your database server. We tried dropping a table with the command %query and the server reported the following error %error.',
339 ),
340 ),
341 );
342
348 protected $results = array();
349
353 protected function hasPdoDriver() {
354 return in_array($this->pdoDriver, PDO::getAvailableDrivers());
355 }
356
360 protected function fail($message) {
361 $this->results[$message] = FALSE;
362 }
363
367 protected function pass($message) {
368 $this->results[$message] = TRUE;
369 }
370
374 public function installable() {
375 return $this->hasPdoDriver() && empty($this->error);
376 }
377
381 abstract public function name();
382
390 public function minimumVersion() {
391 return NULL;
392 }
393
397 public function runTasks() {
398 // We need to establish a connection before we can run tests.
399 if ($this->connect()) {
400 foreach ($this->tasks as $task) {
401 if (!isset($task['function'])) {
402 $task['function'] = 'runTestQuery';
403 }
404 if (method_exists($this, $task['function'])) {
405 // Returning false is fatal. No other tasks can run.
406 if (FALSE === call_user_func_array(array($this, $task['function']), $task['arguments'])) {
407 break;
408 }
409 }
410 else {
411 throw new DatabaseTaskException(st("Failed to run all tasks against the database server. The task %task wasn't found.", array('%task' => $task['function'])));
412 }
413 }
414 }
415 // Check for failed results and compile message
416 $message = '';
417 foreach ($this->results as $result => $success) {
418 if (!$success) {
419 $message .= '<p class="error">' . $result . '</p>';
420 }
421 }
422 if (!empty($message)) {
423 $message = '<p>In order for Drupal to work, and to continue with the installation process, you must resolve all issues reported below. For more help with configuring your database server, see the <a href="http://drupal.org/getting-started/install">installation handbook</a>. If you are unsure what any of this means you should probably contact your hosting provider.</p>' . $message;
424 throw new DatabaseTaskException($message);
425 }
426 }
427
431 protected function connect() {
432 try {
433 // This doesn't actually test the connection.
434 db_set_active();
435 // Now actually do a check.
436 Database::getConnection();
437 $this->pass('Drupal can CONNECT to the database ok.');
438 }
439 catch (Exception $e) {
440 $this->fail(st('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
441 return FALSE;
442 }
443 return TRUE;
444 }
445
449 protected function runTestQuery($query, $pass, $fail, $fatal = FALSE) {
450 try {
451 db_query($query);
452 $this->pass(st($pass));
453 }
454 catch (Exception $e) {
455 $this->fail(st($fail, array('%query' => $query, '%error' => $e->getMessage(), '%name' => $this->name())));
456 return !$fatal;
457 }
458 }
459
463 protected function checkEngineVersion() {
464 if ($this->minimumVersion() && version_compare(Database::getConnection()->version(), $this->minimumVersion(), '<')) {
465 $this->fail(st("The database version %version is less than the minimum required version %minimum_version.", array('%version' => Database::getConnection()->version(), '%minimum_version' => $this->minimumVersion())));
466 }
467 }
468
478 public function getFormOptions($database) {
479 $form['database'] = array(
480 '#type' => 'textfield',
481 '#title' => st('Database name'),
482 '#default_value' => empty($database['database']) ? '' : $database['database'],
483 '#size' => 45,
484 '#required' => TRUE,
485 '#description' => st('The name of the database your @drupal data will be stored in. It must exist on your server before @drupal can be installed.', array('@drupal' => drupal_install_profile_distribution_name())),
486 );
487
488 $form['username'] = array(
489 '#type' => 'textfield',
490 '#title' => st('Database username'),
491 '#default_value' => empty($database['username']) ? '' : $database['username'],
492 '#required' => TRUE,
493 '#size' => 45,
494 );
495
496 $form['password'] = array(
497 '#type' => 'password',
498 '#title' => st('Database password'),
499 '#default_value' => empty($database['password']) ? '' : $database['password'],
500 '#required' => FALSE,
501 '#size' => 45,
502 );
503
504 $form['advanced_options'] = array(
505 '#type' => 'fieldset',
506 '#title' => st('Advanced options'),
507 '#collapsible' => TRUE,
508 '#collapsed' => TRUE,
509 '#description' => st("These options are only necessary for some sites. If you're not sure what you should enter here, leave the default settings or check with your hosting provider."),
510 '#weight' => 10,
511 );
512
513 $profile = drupal_get_profile();
514 $db_prefix = ($profile == 'standard') ? 'drupal_' : $profile . '_';
515 $form['advanced_options']['db_prefix'] = array(
516 '#type' => 'textfield',
517 '#title' => st('Table prefix'),
518 '#default_value' => '',
519 '#size' => 45,
520 '#description' => st('If more than one application will be sharing this database, enter a table prefix such as %prefix for your @drupal site here.', array('@drupal' => drupal_install_profile_distribution_name(), '%prefix' => $db_prefix)),
521 '#weight' => 10,
522 );
523
524 $form['advanced_options']['host'] = array(
525 '#type' => 'textfield',
526 '#title' => st('Database host'),
527 '#default_value' => empty($database['host']) ? 'localhost' : $database['host'],
528 '#size' => 45,
529 // Hostnames can be 255 characters long.
530 '#maxlength' => 255,
531 '#required' => TRUE,
532 '#description' => st('If your database is located on a different server, change this.'),
533 );
534
535 $form['advanced_options']['port'] = array(
536 '#type' => 'textfield',
537 '#title' => st('Database port'),
538 '#default_value' => empty($database['port']) ? '' : $database['port'],
539 '#size' => 45,
540 // The maximum port number is 65536, 5 digits.
541 '#maxlength' => 5,
542 '#description' => st('If your database server is listening to a non-standard port, enter its number.'),
543 );
544
545 return $form;
546 }
547
560 public function validateDatabaseSettings($database) {
561 $errors = array();
562
563 // Verify the table prefix.
564 if (!empty($database['prefix']) && is_string($database['prefix']) && !preg_match('/^[A-Za-z0-9_.]+$/', $database['prefix'])) {
565 $errors[$database['driver'] . '][advanced_options][db_prefix'] = st('The database table prefix you have entered, %prefix, is invalid. The table prefix can only contain alphanumeric characters, periods, or underscores.', array('%prefix' => $database['prefix']));
566 }
567
568 // Verify the database port.
569 if (!empty($database['port']) && !is_numeric($database['port'])) {
570 $errors[$database['driver'] . '][advanced_options][port'] = st('Database port must be a number.');
571 }
572
573 return $errors;
574 }
575
576 }
577
581 class DatabaseTaskException extends Exception {
582 }
583
590 function drupal_rewrite_settings($settings = array(), $prefix = '') {
591 $default_settings = 'sites/default/default.settings.php';
592 drupal_static_reset('conf_path');
593 $settings_file = conf_path(FALSE) . '/' . $prefix . 'settings.php';
594
595 // Build list of setting names and insert the values into the global namespace.
596 $keys = array();
597 foreach ($settings as $setting => $data) {
598 $GLOBALS[$setting] = $data['value'];
599 $keys[] = $setting;
600 }
601
602 $buffer = NULL;
603 $first = TRUE;
604 if ($fp = fopen(DRUPAL_ROOT . '/' . $default_settings, 'r')) {
605 // Step line by line through settings.php.
606 while (!feof($fp)) {
607 $line = fgets($fp);
608 if ($first && substr($line, 0, 5) != '<?php') {
609 $buffer = "<?php\n\n";
610 }
611 $first = FALSE;
612 // Check for constants.
613 if (substr($line, 0, 7) == 'define(') {
614 preg_match('/define\(\s*[\'"]([A-Z_-]+)[\'"]\s*,(.*?)\);/', $line, $variable);
615 if (in_array($variable[1], $keys)) {
616 $setting = $settings[$variable[1]];
617 $buffer .= str_replace($variable[2], " '" . $setting['value'] . "'", $line);
618 unset($settings[$variable[1]]);
619 unset($settings[$variable[2]]);
620 }
621 else {
622 $buffer .= $line;
623 }
624 }
625 // Check for variables.
626 elseif (substr($line, 0, 1) == '$') {
627 preg_match('/\$([^ ]*) /', $line, $variable);
628 if (in_array($variable[1], $keys)) {
629 // Write new value to settings.php in the following format:
630 // $'setting' = 'value'; // 'comment'
631 $setting = $settings[$variable[1]];
632 $buffer .= '$' . $variable[1] . " = " . var_export($setting['value'], TRUE) . ";" . (!empty($setting['comment']) ? ' // ' . $setting['comment'] . "\n" : "\n");
633 unset($settings[$variable[1]]);
634 }
635 else {
636 $buffer .= $line;
637 }
638 }
639 else {
640 $buffer .= $line;
641 }
642 }
643 fclose($fp);
644
645 // Add required settings that were missing from settings.php.
646 foreach ($settings as $setting => $data) {
647 if ($data['required']) {
648 $buffer .= "\$$setting = " . var_export($data['value'], TRUE) . ";\n";
649 }
650 }
651
652 $fp = fopen(DRUPAL_ROOT . '/' . $settings_file, 'w');
653 if ($fp && fwrite($fp, $buffer) === FALSE) {
654 throw new Exception(st('Failed to modify %settings. Verify the file permissions.', array('%settings' => $settings_file)));
655 }
656 }
657 else {
658 throw new Exception(st('Failed to open %settings. Verify the file permissions.', array('%settings' => $default_settings)));
659 }
660 }
661
671 function drupal_verify_profile($install_state) {
672 $profile = $install_state['parameters']['profile'];
673 $locale = $install_state['parameters']['locale'];
674
675 include_once DRUPAL_ROOT . '/includes/file.inc';
676 include_once DRUPAL_ROOT . '/includes/common.inc';
677
678 $profile_file = DRUPAL_ROOT . "/profiles/$profile/$profile.profile";
679
680 if (!isset($profile) || !file_exists($profile_file)) {
681 throw new Exception(install_no_profile_error());
682 }
683 $info = $install_state['profile_info'];
684
685 // Get a list of modules that exist in Drupal's assorted subdirectories.
686 $present_modules = array();
687 foreach (drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules', 'name', 0) as $present_module) {
688 $present_modules[] = $present_module->name;
689 }
690
691 // The installation profile is also a module, which needs to be installed
692 // after all the other dependencies have been installed.
693 $present_modules[] = drupal_get_profile();
694
695 // Verify that all of the profile's required modules are present.
696 $missing_modules = array_diff($info['dependencies'], $present_modules);
697
698 $requirements = array();
699
700 if (count($missing_modules)) {
701 $modules = array();
702 foreach ($missing_modules as $module) {
703 $modules[] = '<span class="admin-missing">' . drupal_ucfirst($module) . '</span>';
704 }
705 $requirements['required_modules'] = array(
706 'title' => st('Required modules'),
707 'value' => st('Required modules not found.'),
708 'severity' => REQUIREMENT_ERROR,
709 'description' => st('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as <em>sites/all/modules</em>. Missing modules: !modules', array('!modules' => implode(', ', $modules))),
710 );
711 }
712 return $requirements;
713 }
714
721 function drupal_install_system() {
722 $system_path = drupal_get_path('module', 'system');
723 require_once DRUPAL_ROOT . '/' . $system_path . '/system.install';
724 module_invoke('system', 'install');
725
726 $system_versions = drupal_get_schema_versions('system');
727 $system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED;
728 db_insert('system')
729 ->fields(array('filename', 'name', 'type', 'owner', 'status', 'schema_version', 'bootstrap'))
730 ->values(array(
731 'filename' => $system_path . '/system.module',
732 'name' => 'system',
733 'type' => 'module',
734 'owner' => '',
735 'status' => 1,
736 'schema_version' => $system_version,
737 'bootstrap' => 0,
738 ))
739 ->execute();
740 system_rebuild_module_data();
741 }
742
766 function drupal_uninstall_modules($module_list = array(), $uninstall_dependents = TRUE) {
767 if ($uninstall_dependents) {
768 // Get all module data so we can find dependents and sort.
769 $module_data = system_rebuild_module_data();
770 // Create an associative array with weights as values.
771 $module_list = array_flip(array_values($module_list));
772
773 $profile = drupal_get_profile();
774 while (list($module) = each($module_list)) {
775 if (!isset($module_data[$module]) || drupal_get_installed_schema_version($module) == SCHEMA_UNINSTALLED) {
776 // This module doesn't exist or is already uninstalled. Skip it.
777 unset($module_list[$module]);
778 continue;
779 }
780 $module_list[$module] = $module_data[$module]->sort;
781
782 // If the module has any dependents which are not already uninstalled and
783 // not included in the passed-in list, abort. It is not safe to uninstall
784 // them automatically because uninstalling a module is a destructive
785 // operation.
786 foreach (array_keys($module_data[$module]->required_by) as $dependent) {
787 if (!isset($module_list[$dependent]) && drupal_get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED && $dependent != $profile) {
788 return FALSE;
789 }
790 }
791 }
792
793 // Sort the module list by pre-calculated weights.
794 asort($module_list);
795 $module_list = array_keys($module_list);
796 }
797
798 foreach ($module_list as $module) {
799 // Uninstall the module.
800 module_load_install($module);
801 module_invoke($module, 'uninstall');
802 drupal_uninstall_schema($module);
803
804 watchdog('system', '%module module uninstalled.', array('%module' => $module), WATCHDOG_INFO);
805 drupal_set_installed_schema_version($module, SCHEMA_UNINSTALLED);
806 }
807
808 if (!empty($module_list)) {
809 // Let other modules react.
810 module_invoke_all('modules_uninstalled', $module_list);
811 }
812
813 return TRUE;
814 }
815
829 function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
830 $return = TRUE;
831 // Check for files that shouldn't be there.
832 if (isset($mask) && ($mask & FILE_NOT_EXIST) && file_exists($file)) {
833 return FALSE;
834 }
835 // Verify that the file is the type of file it is supposed to be.
836 if (isset($type) && file_exists($file)) {
837 $check = 'is_' . $type;
838 if (!function_exists($check) || !$check($file)) {
839 $return = FALSE;
840 }
841 }
842
843 // Verify file permissions.
844 if (isset($mask)) {
845 $masks = array(FILE_EXIST, FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
846 foreach ($masks as $current_mask) {
847 if ($mask & $current_mask) {
848 switch ($current_mask) {
849 case FILE_EXIST:
850 if (!file_exists($file)) {
851 if ($type == 'dir') {
852 drupal_install_mkdir($file, $mask);
853 }
854 if (!file_exists($file)) {
855 $return = FALSE;
856 }
857 }
858 break;
859 case FILE_READABLE:
860 if (!is_readable($file) && !drupal_install_fix_file($file, $mask)) {
861 $return = FALSE;
862 }
863 break;
864 case FILE_WRITABLE:
865 if (!is_writable($file) && !drupal_install_fix_file($file, $mask)) {
866 $return = FALSE;
867 }
868 break;
869 case FILE_EXECUTABLE:
870 if (!is_executable($file) && !drupal_install_fix_file($file, $mask)) {
871 $return = FALSE;
872 }
873 break;
874 case FILE_NOT_READABLE:
875 if (is_readable($file) && !drupal_install_fix_file($file, $mask)) {
876 $return = FALSE;
877 }
878 break;
879 case FILE_NOT_WRITABLE:
880 if (is_writable($file) && !drupal_install_fix_file($file, $mask)) {
881 $return = FALSE;
882 }
883 break;
884 case FILE_NOT_EXECUTABLE:
885 if (is_executable($file) && !drupal_install_fix_file($file, $mask)) {
886 $return = FALSE;
887 }
888 break;
889 }
890 }
891 }
892 }
893 return $return;
894 }
895
909 function drupal_install_mkdir($file, $mask, $message = TRUE) {
910 $mod = 0;
911 $masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
912 foreach ($masks as $m) {
913 if ($mask & $m) {
914 switch ($m) {
915 case FILE_READABLE:
916 $mod |= 0444;
917 break;
918 case FILE_WRITABLE:
919 $mod |= 0222;
920 break;
921 case FILE_EXECUTABLE:
922 $mod |= 0111;
923 break;
924 }
925 }
926 }
927
928 if (@drupal_mkdir($file, $mod)) {
929 return TRUE;
930 }
931 else {
932 return FALSE;
933 }
934 }
935
958 function drupal_install_fix_file($file, $mask, $message = TRUE) {
959 // If $file does not exist, fileperms() issues a PHP warning.
960 if (!file_exists($file)) {
961 return FALSE;
962 }
963
964 $mod = fileperms($file) & 0777;
965 $masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
966
967 // FILE_READABLE, FILE_WRITABLE, and FILE_EXECUTABLE permission strings
968 // can theoretically be 0400, 0200, and 0100 respectively, but to be safe
969 // we set all three access types in case the administrator intends to
970 // change the owner of settings.php after installation.
971 foreach ($masks as $m) {
972 if ($mask & $m) {
973 switch ($m) {
974 case FILE_READABLE:
975 if (!is_readable($file)) {
976 $mod |= 0444;
977 }
978 break;
979 case FILE_WRITABLE:
980 if (!is_writable($file)) {
981 $mod |= 0222;
982 }
983 break;
984 case FILE_EXECUTABLE:
985 if (!is_executable($file)) {
986 $mod |= 0111;
987 }
988 break;
989 case FILE_NOT_READABLE:
990 if (is_readable($file)) {
991 $mod &= ~0444;
992 }
993 break;
994 case FILE_NOT_WRITABLE:
995 if (is_writable($file)) {
996 $mod &= ~0222;
997 }
998 break;
999 case FILE_NOT_EXECUTABLE:
1000 if (is_executable($file)) {
1001 $mod &= ~0111;
1002 }
1003 break;
1004 }
1005 }
1006 }
1007
1008 // chmod() will work if the web server is running as owner of the file.
1009 // If PHP safe_mode is enabled the currently executing script must also
1010 // have the same owner.
1011 if (@chmod($file, $mod)) {
1012 return TRUE;
1013 }
1014 else {
1015 return FALSE;
1016 }
1017 }
1018
1027 function install_goto($path) {
1028 global $base_url;
1029 include_once DRUPAL_ROOT . '/includes/common.inc';
1030 header('Location: ' . $base_url . '/' . $path);
1031 header('Cache-Control: no-cache'); // Not a permanent redirect.
1032 drupal_exit();
1033 }
1034
1060 function drupal_current_script_url($query = array()) {
1061 $uri = $_SERVER['SCRIPT_NAME'];
1062 $query = array_merge(drupal_get_query_parameters(), $query);
1063 if (!empty($query)) {
1064 $uri .= '?' . drupal_http_build_query($query);
1065 }
1066 return $uri;
1067 }
1068
1087 function drupal_requirements_url($severity) {
1088 $query = array();
1089 // If there are no errors, only warnings, append 'continue=1' to the URL so
1090 // the user can bypass this screen on the next page load.
1091 if ($severity == REQUIREMENT_WARNING) {
1092 $query['continue'] = 1;
1093 }
1094 return drupal_current_script_url($query);
1095 }
1096
1111 function st($string, array $args = array(), array $options = array()) {
1112 static $locale_strings = NULL;
1113 global $install_state;
1114
1115 if (empty($options['context'])) {
1116 $options['context'] = '';
1117 }
1118
1119 if (!isset($locale_strings)) {
1120 $locale_strings = array();
1121 if (isset($install_state['parameters']['profile']) && isset($install_state['parameters']['locale'])) {
1122 // If the given locale was selected, there should be at least one .po file
1123 // with its name ending in {$install_state['parameters']['locale']}.po
1124 // This might or might not be the entire filename. It is also possible
1125 // that multiple files end with the same extension, even if unlikely.
1126 $po_files = file_scan_directory('./profiles/' . $install_state['parameters']['profile'] . '/translations', '/'. $install_state['parameters']['locale'] .'\.po$/', array('recurse' => FALSE));
1127 if (count($po_files)) {
1128 require_once DRUPAL_ROOT . '/includes/locale.inc';
1129 foreach ($po_files as $po_file) {
1130 _locale_import_read_po('mem-store', $po_file);
1131 }
1132 $locale_strings = _locale_import_one_string('mem-report');
1133 }
1134 }
1135 }
1136
1137 // Transform arguments before inserting them
1138 foreach ($args as $key => $value) {
1139 switch ($key[0]) {
1140 // Escaped only
1141 case '@':
1142 $args[$key] = check_plain($value);
1143 break;
1144 // Escaped and placeholder
1145 case '%':
1146 default:
1147 $args[$key] = '<em>' . check_plain($value) . '</em>';
1148 break;
1149 // Pass-through
1150 case '!':
1151 }
1152 }
1153 return strtr((!empty($locale_strings[$options['context']][$string]) ? $locale_strings[$options['context']][$string] : $string), $args);
1154 }
1155
1164 function drupal_check_profile($profile) {
1165 include_once DRUPAL_ROOT . '/includes/file.inc';
1166
1167 $profile_file = DRUPAL_ROOT . "/profiles/$profile/$profile.profile";
1168
1169 if (!isset($profile) || !file_exists($profile_file)) {
1170 throw new Exception(install_no_profile_error());
1171 }
1172
1173 $info = install_profile_info($profile);
1174
1175 // Collect requirement testing results.
1176 $requirements = array();
1177 foreach ($info['dependencies'] as $module) {
1178 module_load_install($module);
1179 $function = $module . '_requirements';
1180 if (function_exists($function)) {
1181 $requirements = array_merge($requirements, $function('install'));
1182 }
1183 }
1184 return $requirements;
1185 }
1186
1197 function drupal_requirements_severity(&$requirements) {
1198 $severity = REQUIREMENT_OK;
1199 foreach ($requirements as $requirement) {
1200 if (isset($requirement['severity'])) {
1201 $severity = max($severity, $requirement['severity']);
1202 }
1203 }
1204 return $severity;
1205 }
1206
1216 function drupal_check_module($module) {
1217 module_load_install($module);
1218 if (module_hook($module, 'requirements')) {
1219 // Check requirements
1220 $requirements = module_invoke($module, 'requirements', 'install');
1221 if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) {
1222 // Print any error messages
1223 foreach ($requirements as $requirement) {
1224 if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
1225 $message = $requirement['description'];
1226 if (isset($requirement['value']) && $requirement['value']) {
1227 $message .= ' (' . t('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) . ')';
1228 }
1229 drupal_set_message($message, 'error');
1230 }
1231 }
1232 return FALSE;
1233 }
1234 }
1235 return TRUE;
1236 }
1237
1280 function install_profile_info($profile, $locale = 'en') {
1281 $cache = &drupal_static(__FUNCTION__, array());
1282
1283 if (!isset($cache[$profile])) {
1284 // Set defaults for module info.
1285 $defaults = array(
1286 'dependencies' => array(),
1287 'description' => '',
1288 'distribution_name' => 'Drupal',
1289 'version' => NULL,
1290 'hidden' => FALSE,
1291 'php' => DRUPAL_MINIMUM_PHP,
1292 );
1293 $info = drupal_parse_info_file("profiles/$profile/$profile.info") + $defaults;
1294 $info['dependencies'] = array_unique(array_merge(
1295 drupal_required_modules(),
1296 $info['dependencies'],
1297 ($locale != 'en' && !empty($locale) ? array('locale') : array()))
1298 );
1299
1300 // drupal_required_modules() includes the current profile as a dependency.
1301 // Since a module can't depend on itself we remove that element of the array.
1302 array_shift($info['dependencies']);
1303
1304 $cache[$profile] = $info;
1305 }
1306 return $cache[$profile];
1307 }
1308
1317 function db_run_tasks($driver) {
1318 db_installer_object($driver)->runTasks();
1319 return TRUE;
1320 }
1321
1328 function db_installer_object($driver) {
1329 Database::loadDriverFile($driver, array('install.inc'));
1330 $task_class = 'DatabaseTasks_' . $driver;
1331 return new $task_class();
1332 }
FILE_NOT_WRITABLE
const FILE_NOT_WRITABLE
Definition: install.inc:71
drupal_install_profile_distribution_name
drupal_install_profile_distribution_name()
Definition: install.inc:196
module_list
module_list($refresh=FALSE, $bootstrap_refresh=FALSE, $sort=FALSE, $fixed_list=NULL)
Definition: module.inc:66
drupal_http_build_query
drupal_http_build_query(array $query, $parent= '')
Definition: common.inc:486
db_installer_object
db_installer_object($driver)
Definition: install.inc:1328
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
$databases
$databases
Definition: default.settings.php:213
SCHEMA_INSTALLED
const SCHEMA_INSTALLED
Definition: install.inc:16
file_scan_directory
file_scan_directory($dir, $mask, $options=array(), $depth=0)
Definition: file.inc:2058
Database\getConnection
static getConnection($target= 'default', $key=NULL)
Definition: database.inc:1460
drupal_parse_info_file
drupal_parse_info_file($filename)
Definition: common.inc:7270
_locale_import_one_string
_locale_import_one_string($op, $value=NULL, $mode=NULL, $lang=NULL, $file=NULL, $group= 'default')
Definition: locale.inc:976
WATCHDOG_INFO
const WATCHDOG_INFO
Definition: bootstrap.inc:108
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
$module
print $module
Definition: search-results.tpl.php:28
DatabaseTasks\connect
connect()
Definition: install.inc:431
drupal_rewrite_settings
drupal_rewrite_settings($settings=array(), $prefix= '')
Definition: install.inc:590
drupal_detect_baseurl
drupal_detect_baseurl($file= 'install.php')
Definition: install.inc:221
Exception
drupal_get_query_parameters
drupal_get_query_parameters(array $query=NULL, array $exclude=array('q'), $parent= '')
Definition: common.inc:417
drupal_check_profile
drupal_check_profile($profile)
Definition: install.inc:1164
DatabaseTasks\installable
installable()
Definition: install.inc:374
drupal_detect_database_types
drupal_detect_database_types()
Definition: install.inc:237
DatabaseTasks\checkEngineVersion
checkEngineVersion()
Definition: install.inc:463
Database\loadDriverFile
static loadDriverFile($driver, array $files=array())
Definition: database.inc:1759
drupal_install_system
drupal_install_system()
Definition: install.inc:721
drupal_current_script_url
drupal_current_script_url($query=array())
Definition: install.inc:1060
drupal_verify_install_file
drupal_verify_install_file($file, $mask=NULL, $type= 'file')
Definition: install.inc:829
REQUIREMENT_WARNING
const REQUIREMENT_WARNING
Definition: install.inc:31
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
DatabaseTasks\minimumVersion
minimumVersion()
Definition: install.inc:390
DatabaseTasks\$tasks
$tasks
Definition: install.inc:300
drupal_installation_attempted
drupal_installation_attempted()
Definition: bootstrap.inc:2605
FILE_EXIST
const FILE_EXIST
Definition: install.inc:41
drupal_get_installed_schema_version
drupal_get_installed_schema_version($module, $reset=FALSE, $array=FALSE)
Definition: install.inc:146
DatabaseTasks\runTestQuery
runTestQuery($query, $pass, $fail, $fatal=FALSE)
Definition: install.inc:449
module_load_install
module_load_install($module)
Definition: module.inc:288
REQUIREMENT_OK
const REQUIREMENT_OK
Definition: install.inc:26
drupal_get_database_types
drupal_get_database_types()
Definition: install.inc:253
$module_list
$module_list['system']['filename']
Definition: authorize.php:78
_locale_import_read_po
_locale_import_read_po($op, $file, $mode=NULL, $lang=NULL, $group= 'default')
Definition: locale.inc:690
DatabaseTasks
Definition: install.inc:290
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
system_rebuild_module_data
system_rebuild_module_data()
Definition: system.module:2444
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
module_hook
module_hook($module, $hook)
Definition: module.inc:659
drupal_load_updates
drupal_load_updates()
Definition: install.inc:81
drupal_requirements_severity
drupal_requirements_severity(&$requirements)
Definition: install.inc:1197
system_get_info
system_get_info($type, $name=NULL)
Definition: system.module:2338
FILE_NOT_EXECUTABLE
const FILE_NOT_EXECUTABLE
Definition: install.inc:76
$info
$info
Definition: color.inc:6
DatabaseTasks\pass
pass($message)
Definition: install.inc:367
DRUPAL_MINIMUM_PHP
const DRUPAL_MINIMUM_PHP
Definition: bootstrap.inc:21
drupal_set_installed_schema_version
drupal_set_installed_schema_version($module, $version)
Definition: install.inc:177
drupal_get_profile
drupal_get_profile()
Definition: common.inc:222
drupal_check_module
drupal_check_module($module)
Definition: install.inc:1216
drupal_mkdir
drupal_mkdir($uri, $mode=NULL, $recursive=FALSE, $context=NULL)
Definition: file.inc:2359
DatabaseTasks\getFormOptions
getFormOptions($database)
Definition: install.inc:478
$value
print $value
Definition: user-profile-item.tpl.php:26
DatabaseTasks\$results
$results
Definition: install.inc:348
drupal_install_fix_file
drupal_install_fix_file($file, $mask, $message=TRUE)
Definition: install.inc:958
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
DatabaseTasks\validateDatabaseSettings
validateDatabaseSettings($database)
Definition: install.inc:560
db_set_active
db_set_active($key= 'default')
Definition: database.inc:2551
FILE_EXECUTABLE
const FILE_EXECUTABLE
Definition: install.inc:56
FILE_NOT_EXIST
const FILE_NOT_EXIST
Definition: install.inc:61
drupal_verify_profile
drupal_verify_profile($install_state)
Definition: install.inc:671
drupal_install_mkdir
drupal_install_mkdir($file, $mask, $message=TRUE)
Definition: install.inc:909
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
FILE_NOT_READABLE
const FILE_NOT_READABLE
Definition: install.inc:66
SCHEMA_UNINSTALLED
const SCHEMA_UNINSTALLED
Definition: install.inc:11
drupal_ucfirst
drupal_ucfirst($text)
Definition: unicode.inc:561
install_profile_info
install_profile_info($profile, $locale= 'en')
Definition: install.inc:1280
st
st($string, array $args=array(), array $options=array())
Definition: install.inc:1111
conf_path
conf_path($require_settings=TRUE, $reset=FALSE)
Definition: bootstrap.inc:541
drupal_uninstall_modules
drupal_uninstall_modules($module_list=array(), $uninstall_dependents=TRUE)
Definition: install.inc:766
DatabaseTasks\fail
fail($message)
Definition: install.inc:360
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
FILE_READABLE
const FILE_READABLE
Definition: install.inc:46
drupal_get_schema_versions
drupal_get_schema_versions($module)
Definition: install.inc:98
DatabaseTasks\name
name()
drupal_required_modules
drupal_required_modules()
Definition: module.inc:915
drupal_exit
drupal_exit($destination=NULL)
Definition: common.inc:2721
DatabaseTasks\runTasks
runTasks()
Definition: install.inc:397
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$row
$row
Definition: block-admin-display-form.tpl.php:47
DRUPAL_PHP_FUNCTION_PATTERN
const DRUPAL_PHP_FUNCTION_PATTERN
Definition: bootstrap.inc:249
$dir
print $dir
Definition: book-export-html.tpl.php:22
install_goto
install_goto($path)
Definition: install.inc:1027
drupal_system_listing
drupal_system_listing($mask, $directory, $key= 'name', $min_depth=1)
Definition: common.inc:5368
drupal_requirements_url
drupal_requirements_url($severity)
Definition: install.inc:1087
install_no_profile_error
install_no_profile_error()
Definition: install.core.inc:1342
FILE_WRITABLE
const FILE_WRITABLE
Definition: install.inc:51
drupal_uninstall_schema
drupal_uninstall_schema($module)
Definition: common.inc:6963
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
DatabaseTaskException
Definition: install.inc:581
DatabaseTasks\hasPdoDriver
hasPdoDriver()
Definition: install.inc:353
db_run_tasks
db_run_tasks($driver)
Definition: install.inc:1317
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll.install Source File

  • modules
  • poll
poll.install
Go to the documentation of this file.
1 <?php
2
11 function poll_schema() {
12 $schema['poll'] = array(
13 'description' => 'Stores poll-specific information for poll nodes.',
14 'fields' => array(
15 'nid' => array(
16 'type' => 'int',
17 'unsigned' => TRUE,
18 'not null' => TRUE,
19 'default' => 0,
20 'description' => "The poll's {node}.nid.",
21 ),
22 'runtime' => array(
23 'type' => 'int',
24 'not null' => TRUE,
25 'default' => 0,
26 'description' => 'The number of seconds past {node}.created during which the poll is open.',
27 ),
28 'active' => array(
29 'type' => 'int',
30 'unsigned' => TRUE,
31 'not null' => TRUE,
32 'default' => 0,
33 'description' => 'Boolean indicating whether or not the poll is open.',
34 ),
35 ),
36 'primary key' => array('nid'),
37 'foreign keys' => array(
38 'poll_node' => array(
39 'table' => 'node',
40 'columns' => array('nid' => 'nid'),
41 ),
42 ),
43 );
44
45 $schema['poll_choice'] = array(
46 'description' => 'Stores information about all choices for all {poll}s.',
47 'fields' => array(
48 'chid' => array(
49 'type' => 'serial',
50 'unsigned' => TRUE,
51 'not null' => TRUE,
52 'description' => 'Unique identifier for a poll choice.',
53 ),
54 'nid' => array(
55 'type' => 'int',
56 'unsigned' => TRUE,
57 'not null' => TRUE,
58 'default' => 0,
59 'description' => 'The {node}.nid this choice belongs to.',
60 ),
61 'chtext' => array(
62 'type' => 'varchar',
63 'length' => 128,
64 'not null' => TRUE,
65 'default' => '',
66 'description' => 'The text for this choice.',
67 'translatable' => TRUE,
68 ),
69 'chvotes' => array(
70 'type' => 'int',
71 'not null' => TRUE,
72 'default' => 0,
73 'description' => 'The total number of votes this choice has received by all users.',
74 ),
75 'weight' => array(
76 'type' => 'int',
77 'not null' => TRUE,
78 'default' => 0,
79 'description' => 'The sort order of this choice among all choices for the same node.',
80 ),
81 ),
82 'indexes' => array(
83 'nid' => array('nid'),
84 ),
85 'primary key' => array('chid'),
86 'foreign keys' => array(
87 'choice_node' => array(
88 'table' => 'node',
89 'columns' => array('nid' => 'nid'),
90 ),
91 ),
92 );
93
94 $schema['poll_vote'] = array(
95 'description' => 'Stores per-{users} votes for each {poll}.',
96 'fields' => array(
97 'chid' => array(
98 'type' => 'int',
99 'unsigned' => TRUE,
100 'not null' => TRUE,
101 'description' => "The {users}'s vote for this poll.",
102 ),
103 'nid' => array(
104 'type' => 'int',
105 'unsigned' => TRUE,
106 'not null' => TRUE,
107 'description' => 'The {poll} node this vote is for.',
108 ),
109 'uid' => array(
110 'type' => 'int',
111 'unsigned' => TRUE,
112 'not null' => TRUE,
113 'default' => 0,
114 'description' => 'The {users}.uid this vote is from unless the voter was anonymous.',
115 ),
116 'hostname' => array(
117 'type' => 'varchar',
118 'length' => 128,
119 'not null' => TRUE,
120 'default' => '',
121 'description' => 'The IP address this vote is from unless the voter was logged in.',
122 ),
123 'timestamp' => array(
124 'type' => 'int',
125 'not null' => TRUE,
126 'default' => 0,
127 'description' => 'The timestamp of the vote creation.',
128 ),
129 ),
130 'primary key' => array('nid', 'uid', 'hostname'),
131 'foreign keys' => array(
132 'poll_node' => array(
133 'table' => 'node',
134 'columns' => array('nid' => 'nid'),
135 ),
136 'voter' => array(
137 'table' => 'users',
138 'columns' => array('uid' => 'uid'),
139 ),
140 ),
141 'indexes' => array(
142 'chid' => array('chid'),
143 'hostname' => array('hostname'),
144 'uid' => array('uid'),
145 ),
146 );
147
148 return $schema;
149 }
150
157 function poll_update_7001() {
158 // Add chid column and convert existing votes.
159 db_add_field('poll_votes', 'chid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
160 db_add_index('poll_votes', 'chid', array('chid'));
161 db_update('poll_votes')
162 ->expression('chid', Database::getConnection()->prefixTables('COALESCE((SELECT chid FROM {poll_choices} c WHERE {poll_votes}.chorder = c.chorder AND {poll_votes}.nid = c.nid), 0)'))
163 ->execute();
164 // Delete invalid votes.
165 db_delete('poll_votes')->condition('chid', 0)->execute();
166 // Remove old chorder column.
167 db_drop_field('poll_votes', 'chorder');
168
169 // Change the chorder column to weight in poll_choices.
170 db_change_field('poll_choices', 'chorder', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'));
171
172 db_rename_table('poll_votes', 'poll_vote');
173 db_rename_table('poll_choices', 'poll_choice');
174 }
175
179 function poll_update_7002() {
180 $field = array(
181 'type' => 'int',
182 'not null' => TRUE,
183 'default' => 0,
184 );
185 db_add_field('poll_vote', 'timestamp', $field);
186 }
187
191 function poll_update_7003() {
192 db_change_field('poll_choice', 'weight', 'weight', array(
193 'type' => 'int',
194 'not null' => TRUE,
195 'default' => 0,
196 'description' => 'The sort order of this choice among all choices for the same node.',
197 ));
198 }
199
208 function poll_update_7004() {
209 // Remove field default.
210 db_change_field('poll_vote', 'chid', 'chid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE));
211 }
212
db_add_index
db_add_index($table, $name, $fields)
Definition: database.inc:2940
Database\getConnection
static getConnection($target= 'default', $key=NULL)
Definition: database.inc:1460
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
db_add_field
db_add_field($table, $field, $spec, $keys_new=array())
Definition: database.inc:2840
db_drop_field
db_drop_field($table, $field)
Definition: database.inc:2852
poll_update_7003
poll_update_7003()
Definition: poll.install:191
poll_update_7002
poll_update_7002()
Definition: poll.install:179
poll_update_7004
poll_update_7004()
Definition: poll.install:208
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
poll_schema
poll_schema()
Definition: poll.install:11
db_rename_table
db_rename_table($table, $new_name)
Definition: database.inc:2805
poll_update_7001
poll_update_7001()
Definition: poll.install:157
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/module.inc Source File

  • includes
module.inc
Go to the documentation of this file.
1 <?php
2
19 function module_load_all($bootstrap = FALSE) {
20 static $has_run = FALSE;
21
22 if (isset($bootstrap)) {
23 foreach (module_list(TRUE, $bootstrap) as $module) {
24 drupal_load('module', $module);
25 }
26 // $has_run will be TRUE if $bootstrap is FALSE.
27 $has_run = !$bootstrap;
28 }
29 return $has_run;
30 }
31
32
66 function module_list($refresh = FALSE, $bootstrap_refresh = FALSE, $sort = FALSE, $fixed_list = NULL) {
67 static $list = array(), $sorted_list;
68
69 if (empty($list) || $refresh || $fixed_list) {
70 $list = array();
71 $sorted_list = NULL;
72 if ($fixed_list) {
73 foreach ($fixed_list as $name => $module) {
74 drupal_get_filename('module', $name, $module['filename']);
75 $list[$name] = $name;
76 }
77 }
78 else {
79 if ($refresh) {
80 // For the $refresh case, make sure that system_list() returns fresh
81 // data.
82 drupal_static_reset('system_list');
83 }
84 if ($bootstrap_refresh) {
85 $list = system_list('bootstrap');
86 }
87 else {
88 // Not using drupal_map_assoc() here as that requires common.inc.
89 $list = array_keys(system_list('module_enabled'));
90 $list = (!empty($list) ? array_combine($list, $list) : array());
91 }
92 }
93 }
94 if ($sort) {
95 if (!isset($sorted_list)) {
96 $sorted_list = $list;
97 ksort($sorted_list);
98 }
99 return $sorted_list;
100 }
101 return $list;
102 }
103
122 function system_list($type) {
123 $lists = &drupal_static(__FUNCTION__);
124
125 // For bootstrap modules, attempt to fetch the list from cache if possible.
126 // if not fetch only the required information to fire bootstrap hooks
127 // in case we are going to serve the page from cache.
128 if ($type == 'bootstrap') {
129 if (isset($lists['bootstrap'])) {
130 return $lists['bootstrap'];
131 }
132 if ($cached = cache_get('bootstrap_modules', 'cache_bootstrap')) {
133 $bootstrap_list = $cached->data;
134 }
135 else {
136 $bootstrap_list = db_query("SELECT name, filename FROM {system} WHERE status = 1 AND bootstrap = 1 AND type = 'module' ORDER BY weight ASC, name ASC")->fetchAllAssoc('name');
137 cache_set('bootstrap_modules', $bootstrap_list, 'cache_bootstrap');
138 }
139 // To avoid a separate database lookup for the filepath, prime the
140 // drupal_get_filename() static cache for bootstrap modules only.
141 // The rest is stored separately to keep the bootstrap module cache small.
142 foreach ($bootstrap_list as $module) {
143 drupal_get_filename('module', $module->name, $module->filename);
144 }
145 // We only return the module names here since module_list() doesn't need
146 // the filename itself.
147 $lists['bootstrap'] = array_keys($bootstrap_list);
148 }
149 // Otherwise build the list for enabled modules and themes.
150 elseif (!isset($lists['module_enabled'])) {
151 if ($cached = cache_get('system_list', 'cache_bootstrap')) {
152 $lists = $cached->data;
153 }
154 else {
155 $lists = array(
156 'module_enabled' => array(),
157 'theme' => array(),
158 'filepaths' => array(),
159 );
160 // The module name (rather than the filename) is used as the fallback
161 // weighting in order to guarantee consistent behavior across different
162 // Drupal installations, which might have modules installed in different
163 // locations in the file system. The ordering here must also be
164 // consistent with the one used in module_implements().
165 $result = db_query("SELECT * FROM {system} WHERE type = 'theme' OR (type = 'module' AND status = 1) ORDER BY weight ASC, name ASC");
166 foreach ($result as $record) {
167 $record->info = unserialize($record->info);
168 // Build a list of all enabled modules.
169 if ($record->type == 'module') {
170 $lists['module_enabled'][$record->name] = $record;
171 }
172 // Build a list of themes.
173 if ($record->type == 'theme') {
174 $lists['theme'][$record->name] = $record;
175 }
176 // Build a list of filenames so drupal_get_filename can use it.
177 if ($record->status) {
178 $lists['filepaths'][] = array('type' => $record->type, 'name' => $record->name, 'filepath' => $record->filename);
179 }
180 }
181 foreach ($lists['theme'] as $key => $theme) {
182 if (!empty($theme->info['base theme'])) {
183 // Make a list of the theme's base themes.
184 require_once DRUPAL_ROOT . '/includes/theme.inc';
185 $lists['theme'][$key]->base_themes = drupal_find_base_themes($lists['theme'], $key);
186 // Don't proceed if there was a problem with the root base theme.
187 if (!current($lists['theme'][$key]->base_themes)) {
188 continue;
189 }
190 // Determine the root base theme.
191 $base_key = key($lists['theme'][$key]->base_themes);
192 // Add to the list of sub-themes for each of the theme's base themes.
193 foreach (array_keys($lists['theme'][$key]->base_themes) as $base_theme) {
194 $lists['theme'][$base_theme]->sub_themes[$key] = $lists['theme'][$key]->info['name'];
195 }
196 // Add the base theme's theme engine info.
197 $lists['theme'][$key]->info['engine'] = isset($lists['theme'][$base_key]->info['engine']) ? $lists['theme'][$base_key]->info['engine'] : 'theme';
198 }
199 else {
200 // A plain theme is its own engine.
201 $base_key = $key;
202 if (!isset($lists['theme'][$key]->info['engine'])) {
203 $lists['theme'][$key]->info['engine'] = 'theme';
204 }
205 }
206 // Set the theme engine prefix.
207 $lists['theme'][$key]->prefix = ($lists['theme'][$key]->info['engine'] == 'theme') ? $base_key : $lists['theme'][$key]->info['engine'];
208 }
209 cache_set('system_list', $lists, 'cache_bootstrap');
210 }
211 // To avoid a separate database lookup for the filepath, prime the
212 // drupal_get_filename() static cache with all enabled modules and themes.
213 foreach ($lists['filepaths'] as $item) {
214 drupal_get_filename($item['type'], $item['name'], $item['filepath']);
215 }
216 }
217
218 return $lists[$type];
219 }
220
224 function system_list_reset() {
225 drupal_static_reset('system_list');
226 drupal_static_reset('system_rebuild_module_data');
227 drupal_static_reset('list_themes');
228 cache_clear_all('bootstrap_modules', 'cache_bootstrap');
229 cache_clear_all('system_list', 'cache_bootstrap');
230 }
231
245 function _module_build_dependencies($files) {
246 require_once DRUPAL_ROOT . '/includes/graph.inc';
247 foreach ($files as $filename => $file) {
248 $graph[$file->name]['edges'] = array();
249 if (isset($file->info['dependencies']) && is_array($file->info['dependencies'])) {
250 foreach ($file->info['dependencies'] as $dependency) {
251 $dependency_data = drupal_parse_dependency($dependency);
252 $graph[$file->name]['edges'][$dependency_data['name']] = $dependency_data;
253 }
254 }
255 }
256 drupal_depth_first_search($graph);
257 foreach ($graph as $module => $data) {
258 $files[$module]->required_by = isset($data['reverse_paths']) ? $data['reverse_paths'] : array();
259 $files[$module]->requires = isset($data['paths']) ? $data['paths'] : array();
260 $files[$module]->sort = $data['weight'];
261 }
262 return $files;
263 }
264
274 function module_exists($module) {
275 $list = module_list();
276 return isset($list[$module]);
277 }
278
288 function module_load_install($module) {
289 // Make sure the installation API is available
290 include_once DRUPAL_ROOT . '/includes/install.inc';
291
292 return module_load_include('install', $module);
293 }
294
322 function module_load_include($type, $module, $name = NULL) {
323 if (!isset($name)) {
324 $name = $module;
325 }
326
327 if (function_exists('drupal_get_path')) {
328 $file = DRUPAL_ROOT . '/' . drupal_get_path('module', $module) . "/$name.$type";
329 if (is_file($file)) {
330 require_once $file;
331 return $file;
332 }
333 }
334 return FALSE;
335 }
336
340 function module_load_all_includes($type, $name = NULL) {
341 $modules = module_list();
342 foreach ($modules as $module) {
343 module_load_include($type, $module, $name);
344 }
345 }
346
383 function module_enable($module_list, $enable_dependencies = TRUE) {
384 if ($enable_dependencies) {
385 // Get all module data so we can find dependencies and sort.
386 $module_data = system_rebuild_module_data();
387 // Create an associative array with weights as values.
388 $module_list = array_flip(array_values($module_list));
389
390 while (list($module) = each($module_list)) {
391 if (!isset($module_data[$module])) {
392 // This module is not found in the filesystem, abort.
393 return FALSE;
394 }
395 if ($module_data[$module]->status) {
396 // Skip already enabled modules.
397 unset($module_list[$module]);
398 continue;
399 }
400 $module_list[$module] = $module_data[$module]->sort;
401
402 // Add dependencies to the list, with a placeholder weight.
403 // The new modules will be processed as the while loop continues.
404 foreach (array_keys($module_data[$module]->requires) as $dependency) {
405 if (!isset($module_list[$dependency])) {
406 $module_list[$dependency] = 0;
407 }
408 }
409 }
410
411 if (!$module_list) {
412 // Nothing to do. All modules already enabled.
413 return TRUE;
414 }
415
416 // Sort the module list by pre-calculated weights.
417 arsort($module_list);
418 $module_list = array_keys($module_list);
419 }
420
421 // Required for module installation checks.
422 include_once DRUPAL_ROOT . '/includes/install.inc';
423
424 $modules_installed = array();
425 $modules_enabled = array();
426 foreach ($module_list as $module) {
427 // Only process modules that are not already enabled.
428 $existing = db_query("SELECT status FROM {system} WHERE type = :type AND name = :name", array(
429 ':type' => 'module',
430 ':name' => $module))
431 ->fetchObject();
432 if ($existing->status == 0) {
433 // Load the module's code.
434 drupal_load('module', $module);
435 module_load_install($module);
436
437 // Update the database and module list to reflect the new module. This
438 // needs to be done first so that the module's hook implementations,
439 // hook_schema() in particular, can be called while it is being
440 // installed.
441 db_update('system')
442 ->fields(array('status' => 1))
443 ->condition('type', 'module')
444 ->condition('name', $module)
445 ->execute();
446 // Refresh the module list to include it.
447 system_list_reset();
448 module_list(TRUE);
449 module_implements('', FALSE, TRUE);
450 _system_update_bootstrap_status();
451 // Update the registry to include it.
452 registry_update();
453 // Refresh the schema to include it.
454 drupal_get_schema(NULL, TRUE);
455 // Update the theme registry to include it.
456 drupal_theme_rebuild();
457 // Clear entity cache.
458 entity_info_cache_clear();
459
460 // Now install the module if necessary.
461 if (drupal_get_installed_schema_version($module, TRUE) == SCHEMA_UNINSTALLED) {
462 drupal_install_schema($module);
463
464 // Set the schema version to the number of the last update provided
465 // by the module.
466 $versions = drupal_get_schema_versions($module);
467 $version = $versions ? max($versions) : SCHEMA_INSTALLED;
468
469 // If the module has no current updates, but has some that were
470 // previously removed, set the version to the value of
471 // hook_update_last_removed().
472 if ($last_removed = module_invoke($module, 'update_last_removed')) {
473 $version = max($version, $last_removed);
474 }
475 drupal_set_installed_schema_version($module, $version);
476 // Allow the module to perform install tasks.
477 module_invoke($module, 'install');
478 // Record the fact that it was installed.
479 $modules_installed[] = $module;
480 watchdog('system', '%module module installed.', array('%module' => $module), WATCHDOG_INFO);
481 }
482
483 // Enable the module.
484 module_invoke($module, 'enable');
485
486 // Record the fact that it was enabled.
487 $modules_enabled[] = $module;
488 watchdog('system', '%module module enabled.', array('%module' => $module), WATCHDOG_INFO);
489 }
490 }
491
492 // If any modules were newly installed, invoke hook_modules_installed().
493 if (!empty($modules_installed)) {
494 module_invoke_all('modules_installed', $modules_installed);
495 }
496
497 // If any modules were newly enabled, invoke hook_modules_enabled().
498 if (!empty($modules_enabled)) {
499 module_invoke_all('modules_enabled', $modules_enabled);
500 }
501
502 return TRUE;
503 }
504
515 function module_disable($module_list, $disable_dependents = TRUE) {
516 if ($disable_dependents) {
517 // Get all module data so we can find dependents and sort.
518 $module_data = system_rebuild_module_data();
519 // Create an associative array with weights as values.
520 $module_list = array_flip(array_values($module_list));
521
522 $profile = drupal_get_profile();
523 while (list($module) = each($module_list)) {
524 if (!isset($module_data[$module]) || !$module_data[$module]->status) {
525 // This module doesn't exist or is already disabled, skip it.
526 unset($module_list[$module]);
527 continue;
528 }
529 $module_list[$module] = $module_data[$module]->sort;
530
531 // Add dependent modules to the list, with a placeholder weight.
532 // The new modules will be processed as the while loop continues.
533 foreach ($module_data[$module]->required_by as $dependent => $dependent_data) {
534 if (!isset($module_list[$dependent]) && $dependent != $profile) {
535 $module_list[$dependent] = 0;
536 }
537 }
538 }
539
540 // Sort the module list by pre-calculated weights.
541 asort($module_list);
542 $module_list = array_keys($module_list);
543 }
544
545 $invoke_modules = array();
546
547 foreach ($module_list as $module) {
548 if (module_exists($module)) {
549 // Check if node_access table needs rebuilding.
550 if (!node_access_needs_rebuild() && module_hook($module, 'node_grants')) {
551 node_access_needs_rebuild(TRUE);
552 }
553
554 module_load_install($module);
555 module_invoke($module, 'disable');
556 db_update('system')
557 ->fields(array('status' => 0))
558 ->condition('type', 'module')
559 ->condition('name', $module)
560 ->execute();
561 $invoke_modules[] = $module;
562 watchdog('system', '%module module disabled.', array('%module' => $module), WATCHDOG_INFO);
563 }
564 }
565
566 if (!empty($invoke_modules)) {
567 // Refresh the module list to exclude the disabled modules.
568 system_list_reset();
569 module_list(TRUE);
570 module_implements('', FALSE, TRUE);
571 entity_info_cache_clear();
572 // Invoke hook_modules_disabled before disabling modules,
573 // so we can still call module hooks to get information.
574 module_invoke_all('modules_disabled', $invoke_modules);
575 // Update the registry to remove the newly-disabled module.
576 registry_update();
577 _system_update_bootstrap_status();
578 // Update the theme registry to remove the newly-disabled module.
579 drupal_theme_rebuild();
580 }
581
582 // If there remains no more node_access module, rebuilding will be
583 // straightforward, we can do it right now.
584 if (node_access_needs_rebuild() && count(module_implements('node_grants')) == 0) {
585 node_access_rebuild();
586 }
587 }
588
659 function module_hook($module, $hook) {
660 $function = $module . '_' . $hook;
661 if (function_exists($function)) {
662 return TRUE;
663 }
664 // If the hook implementation does not exist, check whether it may live in an
665 // optional include file registered via hook_hook_info().
666 $hook_info = module_hook_info();
667 if (isset($hook_info[$hook]['group'])) {
668 module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']);
669 if (function_exists($function)) {
670 return TRUE;
671 }
672 }
673 return FALSE;
674 }
675
694 function module_implements($hook, $sort = FALSE, $reset = FALSE) {
695 // Use the advanced drupal_static() pattern, since this is called very often.
696 static $drupal_static_fast;
697 if (!isset($drupal_static_fast)) {
698 $drupal_static_fast['implementations'] = &drupal_static(__FUNCTION__);
699 }
700 $implementations = &$drupal_static_fast['implementations'];
701
702 // We maintain a persistent cache of hook implementations in addition to the
703 // static cache to avoid looping through every module and every hook on each
704 // request. Benchmarks show that the benefit of this caching outweighs the
705 // additional database hit even when using the default database caching
706 // backend and only a small number of modules are enabled. The cost of the
707 // cache_get() is more or less constant and reduced further when non-database
708 // caching backends are used, so there will be more significant gains when a
709 // large number of modules are installed or hooks invoked, since this can
710 // quickly lead to module_hook() being called several thousand times
711 // per request.
712 if ($reset) {
713 $implementations = array();
714 cache_set('module_implements', array(), 'cache_bootstrap');
715 drupal_static_reset('module_hook_info');
716 drupal_static_reset('drupal_alter');
717 cache_clear_all('hook_info', 'cache_bootstrap');
718 return;
719 }
720
721 // Fetch implementations from cache.
722 if (empty($implementations)) {
723 $implementations = cache_get('module_implements', 'cache_bootstrap');
724 if ($implementations === FALSE) {
725 $implementations = array();
726 }
727 else {
728 $implementations = $implementations->data;
729 }
730 }
731
732 if (!isset($implementations[$hook])) {
733 // The hook is not cached, so ensure that whether or not it has
734 // implementations, that the cache is updated at the end of the request.
735 $implementations['#write_cache'] = TRUE;
736 $hook_info = module_hook_info();
737 $implementations[$hook] = array();
738 $list = module_list(FALSE, FALSE, $sort);
739 foreach ($list as $module) {
740 $include_file = isset($hook_info[$hook]['group']) && module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']);
741 // Since module_hook() may needlessly try to load the include file again,
742 // function_exists() is used directly here.
743 if (function_exists($module . '_' . $hook)) {
744 $implementations[$hook][$module] = $include_file ? $hook_info[$hook]['group'] : FALSE;
745 }
746 }
747 // Allow modules to change the weight of specific implementations but avoid
748 // an infinite loop.
749 if ($hook != 'module_implements_alter') {
750 drupal_alter('module_implements', $implementations[$hook], $hook);
751 }
752 }
753 else {
754 foreach ($implementations[$hook] as $module => $group) {
755 // If this hook implementation is stored in a lazy-loaded file, so include
756 // that file first.
757 if ($group) {
758 module_load_include('inc', $module, "$module.$group");
759 }
760 // It is possible that a module removed a hook implementation without the
761 // implementations cache being rebuilt yet, so we check whether the
762 // function exists on each request to avoid undefined function errors.
763 // Since module_hook() may needlessly try to load the include file again,
764 // function_exists() is used directly here.
765 if (!function_exists($module . '_' . $hook)) {
766 // Clear out the stale implementation from the cache and force a cache
767 // refresh to forget about no longer existing hook implementations.
768 unset($implementations[$hook][$module]);
769 $implementations['#write_cache'] = TRUE;
770 }
771 }
772 }
773
774 return array_keys($implementations[$hook]);
775 }
776
787 function module_hook_info() {
788 // This function is indirectly invoked from bootstrap_invoke_all(), in which
789 // case common.inc, subsystems, and modules are not loaded yet, so it does not
790 // make sense to support hook groups resp. lazy-loaded include files prior to
791 // full bootstrap.
792 if (drupal_bootstrap(NULL, FALSE) != DRUPAL_BOOTSTRAP_FULL) {
793 return array();
794 }
795 $hook_info = &drupal_static(__FUNCTION__);
796
797 if (!isset($hook_info)) {
798 $hook_info = array();
799 $cache = cache_get('hook_info', 'cache_bootstrap');
800 if ($cache === FALSE) {
801 // Rebuild the cache and save it.
802 // We can't use module_invoke_all() here or it would cause an infinite
803 // loop.
804 foreach (module_list() as $module) {
805 $function = $module . '_hook_info';
806 if (function_exists($function)) {
807 $result = $function();
808 if (isset($result) && is_array($result)) {
809 $hook_info = array_merge_recursive($hook_info, $result);
810 }
811 }
812 }
813 // We can't use drupal_alter() for the same reason as above.
814 foreach (module_list() as $module) {
815 $function = $module . '_hook_info_alter';
816 if (function_exists($function)) {
817 $function($hook_info);
818 }
819 }
820 cache_set('hook_info', $hook_info, 'cache_bootstrap');
821 }
822 else {
823 $hook_info = $cache->data;
824 }
825 }
826
827 return $hook_info;
828 }
829
835 function module_implements_write_cache() {
836 $implementations = &drupal_static('module_implements');
837 if (isset($implementations['#write_cache'])) {
838 unset($implementations['#write_cache']);
839 cache_set('module_implements', $implementations, 'cache_bootstrap');
840 }
841 }
842
861 function module_invoke($module, $hook) {
862 $args = func_get_args();
863 // Remove $module and $hook from the arguments.
864 unset($args[0], $args[1]);
865 if (module_hook($module, $hook)) {
866 return call_user_func_array($module . '_' . $hook, $args);
867 }
868 }
869
887 function module_invoke_all($hook) {
888 $args = func_get_args();
889 // Remove $hook from the arguments.
890 unset($args[0]);
891 $return = array();
892 foreach (module_implements($hook) as $module) {
893 $function = $module . '_' . $hook;
894 if (function_exists($function)) {
895 $result = call_user_func_array($function, $args);
896 if (isset($result) && is_array($result)) {
897 $return = array_merge_recursive($return, $result);
898 }
899 elseif (isset($result)) {
900 $return[] = $result;
901 }
902 }
903 }
904
905 return $return;
906 }
907
915 function drupal_required_modules() {
916 $files = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info$/', 'modules', 'name', 0);
917 $required = array();
918
919 // An installation profile is required and one must always be loaded.
920 $required[] = drupal_get_profile();
921
922 foreach ($files as $name => $file) {
923 $info = drupal_parse_info_file($file->uri);
924 if (!empty($info) && !empty($info['required']) && $info['required']) {
925 $required[] = $name;
926 }
927 }
928
929 return $required;
930 }
931
988 function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL, &$context3 = NULL) {
989 // Use the advanced drupal_static() pattern, since this is called very often.
990 static $drupal_static_fast;
991 if (!isset($drupal_static_fast)) {
992 $drupal_static_fast['functions'] = &drupal_static(__FUNCTION__);
993 }
994 $functions = &$drupal_static_fast['functions'];
995
996 // Most of the time, $type is passed as a string, so for performance,
997 // normalize it to that. When passed as an array, usually the first item in
998 // the array is a generic type, and additional items in the array are more
999 // specific variants of it, as in the case of array('form', 'form_FORM_ID').
1000 if (is_array($type)) {
1001 $cid = implode(',', $type);
1002 $extra_types = $type;
1003 $type = array_shift($extra_types);
1004 // Allow if statements in this function to use the faster isset() rather
1005 // than !empty() both when $type is passed as a string, or as an array with
1006 // one item.
1007 if (empty($extra_types)) {
1008 unset($extra_types);
1009 }
1010 }
1011 else {
1012 $cid = $type;
1013 }
1014
1015 // Some alter hooks are invoked many times per page request, so statically
1016 // cache the list of functions to call, and on subsequent calls, iterate
1017 // through them quickly.
1018 if (!isset($functions[$cid])) {
1019 $functions[$cid] = array();
1020 $hook = $type . '_alter';
1021 $modules = module_implements($hook);
1022 if (!isset($extra_types)) {
1023 // For the more common case of a single hook, we do not need to call
1024 // function_exists(), since module_implements() returns only modules with
1025 // implementations.
1026 foreach ($modules as $module) {
1027 $functions[$cid][] = $module . '_' . $hook;
1028 }
1029 }
1030 else {
1031 // For multiple hooks, we need $modules to contain every module that
1032 // implements at least one of them.
1033 $extra_modules = array();
1034 foreach ($extra_types as $extra_type) {
1035 $extra_modules = array_merge($extra_modules, module_implements($extra_type . '_alter'));
1036 }
1037 // If any modules implement one of the extra hooks that do not implement
1038 // the primary hook, we need to add them to the $modules array in their
1039 // appropriate order. module_implements() can only return ordered
1040 // implementations of a single hook. To get the ordered implementations
1041 // of multiple hooks, we mimic the module_implements() logic of first
1042 // ordering by module_list(), and then calling
1043 // drupal_alter('module_implements').
1044 if (array_diff($extra_modules, $modules)) {
1045 // Merge the arrays and order by module_list().
1046 $modules = array_intersect(module_list(), array_merge($modules, $extra_modules));
1047 // Since module_implements() already took care of loading the necessary
1048 // include files, we can safely pass FALSE for the array values.
1049 $implementations = array_fill_keys($modules, FALSE);
1050 // Let modules adjust the order solely based on the primary hook. This
1051 // ensures the same module order regardless of whether this if block
1052 // runs. Calling drupal_alter() recursively in this way does not result
1053 // in an infinite loop, because this call is for a single $type, so we
1054 // won't end up in this code block again.
1055 drupal_alter('module_implements', $implementations, $hook);
1056 $modules = array_keys($implementations);
1057 }
1058 foreach ($modules as $module) {
1059 // Since $modules is a merged array, for any given module, we do not
1060 // know whether it has any particular implementation, so we need a
1061 // function_exists().
1062 $function = $module . '_' . $hook;
1063 if (function_exists($function)) {
1064 $functions[$cid][] = $function;
1065 }
1066 foreach ($extra_types as $extra_type) {
1067 $function = $module . '_' . $extra_type . '_alter';
1068 if (function_exists($function)) {
1069 $functions[$cid][] = $function;
1070 }
1071 }
1072 }
1073 }
1074 // Allow the theme to alter variables after the theme system has been
1075 // initialized.
1076 global $theme, $base_theme_info;
1077 if (isset($theme)) {
1078 $theme_keys = array();
1079 foreach ($base_theme_info as $base) {
1080 $theme_keys[] = $base->name;
1081 }
1082 $theme_keys[] = $theme;
1083 foreach ($theme_keys as $theme_key) {
1084 $function = $theme_key . '_' . $hook;
1085 if (function_exists($function)) {
1086 $functions[$cid][] = $function;
1087 }
1088 if (isset($extra_types)) {
1089 foreach ($extra_types as $extra_type) {
1090 $function = $theme_key . '_' . $extra_type . '_alter';
1091 if (function_exists($function)) {
1092 $functions[$cid][] = $function;
1093 }
1094 }
1095 }
1096 }
1097 }
1098 }
1099
1100 foreach ($functions[$cid] as $function) {
1101 $function($data, $context1, $context2, $context3);
1102 }
1103 }
module_list
module_list($refresh=FALSE, $bootstrap_refresh=FALSE, $sort=FALSE, $fixed_list=NULL)
Definition: module.inc:66
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
drupal_parse_dependency
drupal_parse_dependency($dependency)
Definition: common.inc:7543
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
SCHEMA_INSTALLED
const SCHEMA_INSTALLED
Definition: install.inc:16
drupal_parse_info_file
drupal_parse_info_file($filename)
Definition: common.inc:7270
WATCHDOG_INFO
const WATCHDOG_INFO
Definition: bootstrap.inc:108
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
$module
print $module
Definition: search-results.tpl.php:28
registry_update
registry_update()
Definition: bootstrap.inc:3193
node_access_rebuild
node_access_rebuild($batch_mode=FALSE)
Definition: node.module:3603
$name
print $name
Definition: profile-listing.tpl.php:43
module_exists
module_exists($module)
Definition: module.inc:274
system_list
system_list($type)
Definition: module.inc:122
drupal_bootstrap
drupal_bootstrap($phase=NULL, $new_phase=TRUE)
Definition: bootstrap.inc:2192
drupal_get_installed_schema_version
drupal_get_installed_schema_version($module, $reset=FALSE, $array=FALSE)
Definition: install.inc:146
module_load_install
module_load_install($module)
Definition: module.inc:288
entity_info_cache_clear
entity_info_cache_clear()
Definition: common.inc:7690
$module_list
$module_list['system']['filename']
Definition: authorize.php:78
module_load_all
module_load_all($bootstrap=FALSE)
Definition: module.inc:19
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
system_rebuild_module_data
system_rebuild_module_data()
Definition: system.module:2444
module_hook
module_hook($module, $hook)
Definition: module.inc:659
drupal_get_schema
drupal_get_schema($table=NULL, $rebuild=FALSE)
Definition: bootstrap.inc:2940
system_list_reset
system_list_reset()
Definition: module.inc:224
module_implements_write_cache
module_implements_write_cache()
Definition: module.inc:835
module_enable
module_enable($module_list, $enable_dependencies=TRUE)
Definition: module.inc:383
$info
$info
Definition: color.inc:6
drupal_set_installed_schema_version
drupal_set_installed_schema_version($module, $version)
Definition: install.inc:177
drupal_get_profile
drupal_get_profile()
Definition: common.inc:222
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
drupal_install_schema
drupal_install_schema($module)
Definition: common.inc:6939
_system_update_bootstrap_status
_system_update_bootstrap_status()
Definition: system.module:2467
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
drupal_depth_first_search
drupal_depth_first_search(&$graph)
Definition: graph.inc:47
module_hook_info
module_hook_info()
Definition: module.inc:787
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
SCHEMA_UNINSTALLED
const SCHEMA_UNINSTALLED
Definition: install.inc:11
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_find_base_themes
drupal_find_base_themes($themes, $key, $used_keys=array())
Definition: theme.inc:843
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
drupal_get_schema_versions
drupal_get_schema_versions($module)
Definition: install.inc:98
drupal_required_modules
drupal_required_modules()
Definition: module.inc:915
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
module_load_all_includes
module_load_all_includes($type, $name=NULL)
Definition: module.inc:340
DRUPAL_PHP_FUNCTION_PATTERN
const DRUPAL_PHP_FUNCTION_PATTERN
Definition: bootstrap.inc:249
module_disable
module_disable($module_list, $disable_dependents=TRUE)
Definition: module.inc:515
drupal_system_listing
drupal_system_listing($mask, $directory, $key= 'name', $min_depth=1)
Definition: common.inc:5368
_module_build_dependencies
_module_build_dependencies($files)
Definition: module.inc:245
node_access_needs_rebuild
node_access_needs_rebuild($rebuild=NULL)
Definition: node.module:3569
drupal_theme_rebuild
drupal_theme_rebuild()
Definition: theme.inc:352
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
drupal_load
drupal_load($type, $name)
Definition: bootstrap.inc:1093
drupal_get_filename
drupal_get_filename($type, $name, $filename=NULL)
Definition: bootstrap.inc:820
DRUPAL_BOOTSTRAP_FULL
const DRUPAL_BOOTSTRAP_FULL
Definition: bootstrap.inc:157
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/dbtng_example/dbtng_example.module Source File

  • examples
  • dbtng_example
dbtng_example.module
Go to the documentation of this file.
1 <?php
95 function dbtng_example_entry_insert($entry) {
96 $return_value = NULL;
97 try {
98 $return_value = db_insert('dbtng_example')
99 ->fields($entry)
100 ->execute();
101 }
102 catch (Exception $e) {
103 drupal_set_message(t('db_insert failed. Message = %message, query= %query',
104 array('%message' => $e->getMessage(), '%query' => $e->query_string)), 'error');
105 }
106 return $return_value;
107 }
108
131 function dbtng_example_entry_update($entry) {
132 try {
133 // db_update()...->execute() returns the number of rows updated.
134 $count = db_update('dbtng_example')
135 ->fields($entry)
136 ->condition('pid', $entry['pid'])
137 ->execute();
138 }
139 catch (Exception $e) {
140 drupal_set_message(t('db_update failed. Message = %message, query= %query',
141 array('%message' => $e->getMessage(), '%query' => $e->query_string)), 'error');
142 }
143 return $count;
144 }
145
161 function dbtng_example_entry_delete($entry) {
162 db_delete('dbtng_example')
163 ->condition('pid', $entry['pid'])
164 ->execute();
165
166 }
167
168
246 function dbtng_example_entry_load($entry = array()) {
247 // Read all fields from the dbtng_example table.
248 $select = db_select('dbtng_example', 'example');
249 $select->fields('example');
250
251 // Add each field and value as a condition to this query.
252 foreach ($entry as $field => $value) {
253 $select->condition($field, $value);
254 }
255 // Return the result in object format.
256 return $select->execute()->fetchAll();
257 }
258
282 function dbtng_example_advanced_list() {
283 $output = '';
284
285 $select = db_select('dbtng_example', 'e');
286 // Join the users table, so we can get the entry creator's username.
287 $select->join('users', 'u', 'e.uid = u.uid');
288 // Select these specific fields for the output.
289 $select->addField('e', 'pid');
290 $select->addField('u', 'name', 'username');
291 $select->addField('e', 'name');
292 $select->addField('e', 'surname');
293 $select->addField('e', 'age');
294 // Filter only persons named "John".
295 $select->condition('e.name', 'John');
296 // Filter only persons older than 18 years.
297 $select->condition('e.age', 18, '>');
298 // Make sure we only get items 0-49, for scalability reasons.
299 $select->range(0, 50);
300
301 // Now, loop all these entries and show them in a table. Note that there is no
302 // db_fetch_* object or array function being called here. Also note that the
303 // following line could have been written as
304 // $entries = $select->execute()->fetchAll() which would return each selected
305 // record as an object instead of an array.
306 $entries = $select->execute()->fetchAll(PDO::FETCH_ASSOC);
307 if (!empty($entries)) {
308 $rows = array();
309 foreach ($entries as $entry) {
310 // Sanitize the data before handing it off to the theme layer.
311 $rows[] = array_map('check_plain', $entry);
312 }
313 // Make a table for them.
314 $header = array(t('Id'), t('Created by'), t('Name'), t('Surname'), t('Age'));
315 $output .= theme('table', array('header' => $header, 'rows' => $rows));
316 }
317 else {
318 drupal_set_message(t('No entries meet the filter criteria (Name = "John" and Age > 18).'));
319 }
320 return $output;
321 }
322
324
330 function dbtng_example_help($path) {
331 $output = '';
332 switch ($path) {
333 case 'examples/dbtng':
334 $output = t('Generate a list of all entries in the database. There is no filter in the query.');
335 break;
336 case 'examples/dbtng/advanced':
337 $output = t('A more complex list of entries in the database.') . ' ';
338 $output .= t('Only the entries with name = "John" and age older than 18 years are shown, the username of the person who created the entry is also shown.');
339 break;
340 case 'examples/dbtng/update':
341 $output = t('Demonstrates a database update operation.');
342 break;
343 case 'examples/dbtng/add':
344 $output = t('Add an entry to the dbtng_example table.');
345 break;
346 }
347 return $output;
348 }
349
355 function dbtng_example_menu() {
356 $items = array();
357
358 $items['examples/dbtng'] = array(
359 'title' => 'DBTNG Example',
360 'page callback' => 'dbtng_example_list',
361 'access callback' => TRUE,
362 );
363 $items['examples/dbtng/list'] = array(
364 'title' => 'List',
365 'type' => MENU_DEFAULT_LOCAL_TASK,
366 'weight' => -10,
367 );
368 $items['examples/dbtng/add'] = array(
369 'title' => 'Add entry',
370 'page callback' => 'drupal_get_form',
371 'page arguments' => array('dbtng_example_form_add'),
372 'access callback' => TRUE,
373 'type' => MENU_LOCAL_TASK,
374 'weight' => -9,
375 );
376 $items['examples/dbtng/update'] = array(
377 'title' => 'Update entry',
378 'page callback' => 'drupal_get_form',
379 'page arguments' => array('dbtng_example_form_update'),
380 'type' => MENU_LOCAL_TASK,
381 'access callback' => TRUE,
382 'weight' => -5,
383 );
384 $items['examples/dbtng/advanced'] = array(
385 'title' => 'Advanced list',
386 'page callback' => 'dbtng_example_advanced_list',
387 'access callback' => TRUE,
388 'type' => MENU_LOCAL_TASK,
389 );
390
391 return $items;
392 }
393
397 function dbtng_example_list() {
398 $output = '';
399
400 // Get all entries in the dbtng_example table.
401 if ($entries = dbtng_example_entry_load()) {
402 $rows = array();
403 foreach ($entries as $entry) {
404 // Sanitize the data before handing it off to the theme layer.
405 $rows[] = array_map('check_plain', (array) $entry);
406 }
407 // Make a table for them.
408 $header = array(t('Id'), t('uid'), t('Name'), t('Surname'), t('Age'));
409 $output .= theme('table', array('header' => $header, 'rows' => $rows));
410 }
411 else {
412 drupal_set_message(t('No entries have been added yet.'));
413 }
414 return $output;
415 }
416
420 function dbtng_example_form_add($form, &$form_state) {
421 $form = array();
422
423 $form['add'] = array(
424 '#type' => 'fieldset',
425 '#title' => t('Add a person entry'),
426 );
427 $form['add']['name'] = array(
428 '#type' => 'textfield',
429 '#title' => t('Name'),
430 '#size' => 15,
431 );
432 $form['add']['surname'] = array(
433 '#type' => 'textfield',
434 '#title' => t('Surname'),
435 '#size' => 15,
436 );
437 $form['add']['age'] = array(
438 '#type' => 'textfield',
439 '#title' => t('Age'),
440 '#size' => 5,
441 '#description' => t("Values greater than 127 will cause an exception. Try it - it's a great example why exception handling is needed with DTBNG."),
442 );
443 $form['add']['submit'] = array(
444 '#type' => 'submit',
445 '#value' => t('Add'),
446 );
447
448 return $form;
449 }
450
454 function dbtng_example_form_add_submit($form, &$form_state) {
455 global $user;
456
457 // Save the submitted entry.
458 $entry = array(
459 'name' => $form_state['values']['name'],
460 'surname' => $form_state['values']['surname'],
461 'age' => $form_state['values']['age'],
462 'uid' => $user->uid,
463 );
464 $return = dbtng_example_entry_insert($entry);
465 if ($return) {
466 drupal_set_message(t("Created entry @entry", array('@entry' => print_r($entry, TRUE))));
467 }
468 }
469
473 function dbtng_example_form_update($form, &$form_state) {
474 $form = array(
475 '#prefix' => '<div id="updateform">',
476 '#suffix' => '</div>',
477 );
478
479 $entries = dbtng_example_entry_load();
480 $keyed_entries = array();
481 if (empty($entries)) {
482 $form['no_values'] = array(
483 '#value' => t("No entries exist in the table dbtng_example table."),
484 );
485 return $form;
486 }
487
488 foreach ($entries as $entry) {
489 $options[$entry->pid] = t("@pid: @name @surname (@age)", array('@pid' => $entry->pid, '@name' => $entry->name, '@surname' => $entry->surname, '@age' => $entry->age));
490 $keyed_entries[$entry->pid] = $entry;
491 }
492 $default_entry = !empty($form_state['values']['pid']) ? $keyed_entries[$form_state['values']['pid']] : $entries[0];
493
494 $form_state['entries'] = $keyed_entries;
495
496 $form['pid'] = array(
497 '#type' => 'select',
498 '#options' => $options,
499 '#title' => t('Choose entry to update'),
500 '#default_value' => $default_entry->pid,
501 '#ajax' => array(
502 'wrapper' => 'updateform',
503 'callback' => 'dbtng_example_form_update_callback',
504 ),
505 );
506
507 $form['name'] = array(
508 '#type' => 'textfield',
509 '#title' => t('Updated first name'),
510 '#size' => 15,
511 '#default_value' => $default_entry->name,
512 );
513
514 $form['surname'] = array(
515 '#type' => 'textfield',
516 '#title' => t('Updated last name'),
517 '#size' => 15,
518 '#default_value' => $default_entry->surname,
519 );
520 $form['age'] = array(
521 '#type' => 'textfield',
522 '#title' => t('Updated age'),
523 '#size' => 4,
524 '#default_value' => $default_entry->age,
525 '#description' => t("Values greater than 127 will cause an exception"),
526 );
527
528 $form['submit'] = array(
529 '#type' => 'submit',
530 '#value' => t('Update'),
531 );
532 return $form;
533 }
534
540 function dbtng_example_form_update_callback($form, $form_state) {
541 $entry = $form_state['entries'][$form_state['values']['pid']];
542 // Setting the #value of items is the only way I was able to figure out
543 // to get replaced defaults on these items. #default_value will not do it
544 // and shouldn't.
545 foreach (array('name', 'surname', 'age') as $item) {
546 $form[$item]['#value'] = $entry->$item;
547 }
548 return $form;
549 }
550
554 function dbtng_example_form_update_submit($form, &$form_state) {
555 global $user;
556
557 // Save the submitted entry.
558 $entry = array(
559 'pid' => $form_state['values']['pid'],
560 'name' => $form_state['values']['name'],
561 'surname' => $form_state['values']['surname'],
562 'age' => $form_state['values']['age'],
563 'uid' => $user->uid,
564 );
565 $count = dbtng_example_entry_update($entry);
566 drupal_set_message(t("Updated entry @entry (@count row updated)", array('@count' => $count, '@entry' => print_r($entry, TRUE))));
567 }
dbtng_example_form_add
dbtng_example_form_add($form, &$form_state)
Definition: dbtng_example.module:420
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
dbtng_example_entry_load
dbtng_example_entry_load($entry=array())
Definition: dbtng_example.module:246
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
dbtng_example_entry_delete
dbtng_example_entry_delete($entry)
Definition: dbtng_example.module:161
Exception
$header
print $header
Definition: forum-topic-list.tpl.php:42
dbtng_example_help
dbtng_example_help($path)
Definition: dbtng_example.module:330
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
dbtng_example_advanced_list
dbtng_example_advanced_list()
Definition: dbtng_example.module:282
dbtng_example_entry_insert
dbtng_example_entry_insert($entry)
Definition: dbtng_example.module:95
dbtng_example_form_update
dbtng_example_form_update($form, &$form_state)
Definition: dbtng_example.module:473
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
dbtng_example_form_update_submit
dbtng_example_form_update_submit($form, &$form_state)
Definition: dbtng_example.module:554
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$output
$output
Definition: authorize.php:93
dbtng_example_menu
dbtng_example_menu()
Definition: dbtng_example.module:355
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
dbtng_example_list
dbtng_example_list()
Definition: dbtng_example.module:397
dbtng_example_form_add_submit
dbtng_example_form_add_submit($form, &$form_state)
Definition: dbtng_example.module:454
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
dbtng_example_entry_update
dbtng_example_entry_update($entry)
Definition: dbtng_example.module:131
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
dbtng_example_form_update_callback
dbtng_example_form_update_callback($form, $form_state)
Definition: dbtng_example.module:540
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/rdf/rdf.api.php Source File

  • modules
  • rdf
rdf.api.php
Go to the documentation of this file.
1 <?php
2
46 function hook_rdf_mapping() {
47 return array(
48 array(
49 'type' => 'node',
50 'bundle' => 'blog',
51 'mapping' => array(
52 'rdftype' => array('sioct:Weblog'),
53 'title' => array(
54 'predicates' => array('dc:title'),
55 ),
56 'created' => array(
57 'predicates' => array('dc:date', 'dc:created'),
58 'datatype' => 'xsd:dateTime',
59 'callback' => 'date_iso8601',
60 ),
61 'body' => array(
62 'predicates' => array('content:encoded'),
63 ),
64 'uid' => array(
65 'predicates' => array('sioc:has_creator'),
66 'type' => 'rel',
67 ),
68 'name' => array(
69 'predicates' => array('foaf:name'),
70 ),
71 ),
72 ),
73 );
74 }
75
90 function hook_rdf_namespaces() {
91 return array(
92 'content' => 'http://purl.org/rss/1.0/modules/content/',
93 'dc' => 'http://purl.org/dc/terms/',
94 'foaf' => 'http://xmlns.com/foaf/0.1/',
95 'og' => 'http://ogp.me/ns#',
96 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
97 'sioc' => 'http://rdfs.org/sioc/ns#',
98 'sioct' => 'http://rdfs.org/sioc/types#',
99 'skos' => 'http://www.w3.org/2004/02/skos/core#',
100 'xsd' => 'http://www.w3.org/2001/XMLSchema#',
101 );
102 }
103
hook_rdf_mapping
hook_rdf_mapping()
Definition: rdf.api.php:46
hook_rdf_namespaces
hook_rdf_namespaces()
Definition: rdf.api.php:90
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.install Source File

  • modules
  • aggregator
aggregator.install
Go to the documentation of this file.
1 <?php
2
11 function aggregator_uninstall() {
12 variable_del('aggregator_allowed_html_tags');
13 variable_del('aggregator_summary_items');
14 variable_del('aggregator_clear');
15 variable_del('aggregator_category_selector');
16 variable_del('aggregator_fetcher');
17 variable_del('aggregator_parser');
18 variable_del('aggregator_processors');
19 variable_del('aggregator_teaser_length');
20 }
21
25 function aggregator_schema() {
26 $schema['aggregator_category'] = array(
27 'description' => 'Stores categories for aggregator feeds and feed items.',
28 'fields' => array(
29 'cid' => array(
30 'type' => 'serial',
31 'not null' => TRUE,
32 'description' => 'Primary Key: Unique aggregator category ID.',
33 ),
34 'title' => array(
35 'type' => 'varchar',
36 'length' => 255,
37 'not null' => TRUE,
38 'default' => '',
39 'description' => 'Title of the category.',
40 ),
41 'description' => array(
42 'type' => 'text',
43 'not null' => TRUE,
44 'size' => 'big',
45 'description' => 'Description of the category',
46 ),
47 'block' => array(
48 'type' => 'int',
49 'not null' => TRUE,
50 'default' => 0,
51 'size' => 'tiny',
52 'description' => 'The number of recent items to show within the category block.',
53 )
54 ),
55 'primary key' => array('cid'),
56 'unique keys' => array(
57 'title' => array('title'),
58 ),
59 );
60
61 $schema['aggregator_category_feed'] = array(
62 'description' => 'Bridge table; maps feeds to categories.',
63 'fields' => array(
64 'fid' => array(
65 'type' => 'int',
66 'not null' => TRUE,
67 'default' => 0,
68 'description' => "The feed's {aggregator_feed}.fid.",
69 ),
70 'cid' => array(
71 'type' => 'int',
72 'not null' => TRUE,
73 'default' => 0,
74 'description' => 'The {aggregator_category}.cid to which the feed is being assigned.',
75 )
76 ),
77 'primary key' => array('cid', 'fid'),
78 'indexes' => array(
79 'fid' => array('fid'),
80 ),
81 'foreign keys' => array(
82 'aggregator_category' => array(
83 'table' => 'aggregator_category',
84 'columns' => array('cid' => 'cid'),
85 ),
86 ),
87 );
88
89 $schema['aggregator_category_item'] = array(
90 'description' => 'Bridge table; maps feed items to categories.',
91 'fields' => array(
92 'iid' => array(
93 'type' => 'int',
94 'not null' => TRUE,
95 'default' => 0,
96 'description' => "The feed item's {aggregator_item}.iid.",
97 ),
98 'cid' => array(
99 'type' => 'int',
100 'not null' => TRUE,
101 'default' => 0,
102 'description' => 'The {aggregator_category}.cid to which the feed item is being assigned.',
103 )
104 ),
105 'primary key' => array('cid', 'iid'),
106 'indexes' => array(
107 'iid' => array('iid'),
108 ),
109 'foreign keys' => array(
110 'aggregator_category' => array(
111 'table' => 'aggregator_category',
112 'columns' => array('cid' => 'cid'),
113 ),
114 ),
115 );
116
117 $schema['aggregator_feed'] = array(
118 'description' => 'Stores feeds to be parsed by the aggregator.',
119 'fields' => array(
120 'fid' => array(
121 'type' => 'serial',
122 'not null' => TRUE,
123 'description' => 'Primary Key: Unique feed ID.',
124 ),
125 'title' => array(
126 'type' => 'varchar',
127 'length' => 255,
128 'not null' => TRUE,
129 'default' => '',
130 'description' => 'Title of the feed.',
131 ),
132 'url' => array(
133 'type' => 'text',
134 'not null' => TRUE,
135 'description' => 'URL to the feed.',
136 ),
137 'refresh' => array(
138 'type' => 'int',
139 'not null' => TRUE,
140 'default' => 0,
141 'description' => 'How often to check for new feed items, in seconds.',
142 ),
143 'checked' => array(
144 'type' => 'int',
145 'not null' => TRUE,
146 'default' => 0,
147 'description' => 'Last time feed was checked for new items, as Unix timestamp.',
148 ),
149 'queued' => array(
150 'type' => 'int',
151 'not null' => TRUE,
152 'default' => 0,
153 'description' => 'Time when this feed was queued for refresh, 0 if not queued.',
154 ),
155 'link' => array(
156 'type' => 'text',
157 'not null' => TRUE,
158 'description' => 'The parent website of the feed; comes from the <link> element in the feed.',
159 ),
160 'description' => array(
161 'type' => 'text',
162 'not null' => TRUE,
163 'size' => 'big',
164 'description' => "The parent website's description; comes from the <description> element in the feed.",
165 ),
166 'image' => array(
167 'type' => 'text',
168 'not null' => TRUE,
169 'size' => 'big',
170 'description' => 'An image representing the feed.',
171 ),
172 'hash' => array(
173 'type' => 'varchar',
174 'length' => 64,
175 'not null' => TRUE,
176 'default' => '',
177 'description' => 'Calculated hash of the feed data, used for validating cache.',
178 ),
179 'etag' => array(
180 'type' => 'varchar',
181 'length' => 255,
182 'not null' => TRUE,
183 'default' => '',
184 'description' => 'Entity tag HTTP response header, used for validating cache.',
185 ),
186 'modified' => array(
187 'type' => 'int',
188 'not null' => TRUE,
189 'default' => 0,
190 'description' => 'When the feed was last modified, as a Unix timestamp.',
191 ),
192 'block' => array(
193 'type' => 'int',
194 'not null' => TRUE,
195 'default' => 0,
196 'size' => 'tiny',
197 'description' => "Number of items to display in the feed's block.",
198 )
199 ),
200 'primary key' => array('fid'),
201 'indexes' => array(
202 'url' => array(array('url', 255)),
203 'queued' => array('queued'),
204 ),
205 'unique keys' => array(
206 'title' => array('title'),
207 ),
208 );
209
210 $schema['aggregator_item'] = array(
211 'description' => 'Stores the individual items imported from feeds.',
212 'fields' => array(
213 'iid' => array(
214 'type' => 'serial',
215 'not null' => TRUE,
216 'description' => 'Primary Key: Unique ID for feed item.',
217 ),
218 'fid' => array(
219 'type' => 'int',
220 'not null' => TRUE,
221 'default' => 0,
222 'description' => 'The {aggregator_feed}.fid to which this item belongs.',
223 ),
224 'title' => array(
225 'type' => 'varchar',
226 'length' => 255,
227 'not null' => TRUE,
228 'default' => '',
229 'description' => 'Title of the feed item.',
230 ),
231 'link' => array(
232 'type' => 'text',
233 'not null' => TRUE,
234 'description' => 'Link to the feed item.',
235 ),
236 'author' => array(
237 'type' => 'varchar',
238 'length' => 255,
239 'not null' => TRUE,
240 'default' => '',
241 'description' => 'Author of the feed item.',
242 ),
243 'description' => array(
244 'type' => 'text',
245 'not null' => TRUE,
246 'size' => 'big',
247 'description' => 'Body of the feed item.',
248 ),
249 'timestamp' => array(
250 'type' => 'int',
251 'not null' => FALSE,
252 'description' => 'Posted date of the feed item, as a Unix timestamp.',
253 ),
254 'guid' => array(
255 'type' => 'text',
256 'not null' => TRUE,
257 'description' => 'Unique identifier for the feed item.',
258 )
259 ),
260 'primary key' => array('iid'),
261 'indexes' => array(
262 'fid' => array('fid'),
263 ),
264 'foreign keys' => array(
265 'aggregator_feed' => array(
266 'table' => 'aggregator_feed',
267 'columns' => array('fid' => 'fid'),
268 ),
269 ),
270 );
271
272 return $schema;
273 }
274
283 function aggregator_update_7000() {
284 db_add_field('aggregator_feed', 'hash', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''));
285 }
286
290 function aggregator_update_7001() {
291 variable_set('aggregator_teaser_length', variable_get('teaser_length'));
292 }
293
297 function aggregator_update_7002() {
298 db_add_field('aggregator_feed', 'queued', array(
299 'type' => 'int',
300 'not null' => TRUE,
301 'default' => 0,
302 'description' => 'Time when this feed was queued for refresh, 0 if not queued.',
303 ));
304 db_add_index('aggregator_feed', 'queued', array('queued'));
305 }
306
319 function aggregator_update_7003() {
320 db_drop_unique_key('aggregator_feed', 'url');
321 db_change_field('aggregator_feed', 'url', 'url', array('type' => 'text', 'not null' => TRUE, 'description' => 'URL to the feed.'));
322 db_change_field('aggregator_feed', 'link', 'link', array('type' => 'text', 'not null' => TRUE, 'description' => 'The parent website of the feed; comes from the <link> element in the feed.'));
323 db_change_field('aggregator_item', 'link', 'link', array('type' => 'text', 'not null' => TRUE, 'description' => 'Link to the feed item.'));
324 db_change_field('aggregator_item', 'guid', 'guid', array('type' => 'text', 'not null' => TRUE, 'description' => 'Unique identifier for the feed item.'));
325 db_add_index('aggregator_feed', 'url', array(array('url', 255)));
326 }
327
db_add_index
db_add_index($table, $name, $fields)
Definition: database.inc:2940
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
aggregator_update_7002
aggregator_update_7002()
Definition: aggregator.install:297
db_add_field
db_add_field($table, $field, $spec, $keys_new=array())
Definition: database.inc:2840
aggregator_schema
aggregator_schema()
Definition: aggregator.install:25
aggregator_update_7000
aggregator_update_7000()
Definition: aggregator.install:283
aggregator_update_7001
aggregator_update_7001()
Definition: aggregator.install:290
aggregator_update_7003
aggregator_update_7003()
Definition: aggregator.install:319
aggregator_uninstall
aggregator_uninstall()
Definition: aggregator.install:11
db_drop_unique_key
db_drop_unique_key($table, $name)
Definition: database.inc:2926
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/help/help.module Source File

  • modules
  • help
help.module
Go to the documentation of this file.
1 <?php
2
11 function help_menu() {
12 $items['admin/help'] = array(
13 'title' => 'Help',
14 'description' => 'Reference for usage, configuration, and modules.',
15 'page callback' => 'help_main',
16 'access arguments' => array('access administration pages'),
17 'weight' => 9,
18 'file' => 'help.admin.inc',
19 );
20
21 foreach (module_implements('help', TRUE) as $module) {
22 $items['admin/help/' . $module] = array(
23 'title' => $module,
24 'page callback' => 'help_page',
25 'page arguments' => array(2),
26 'access arguments' => array('access administration pages'),
27 'type' => MENU_VISIBLE_IN_BREADCRUMB,
28 'file' => 'help.admin.inc',
29 );
30 }
31
32 return $items;
33 }
34
38 function help_help($path, $arg) {
39 switch ($path) {
40 case 'admin/help':
41 $output = '<p>' . t('Follow these steps to set up and start using your website:') . '</p>';
42 $output .= '<ol>';
43 $output .= '<li>' . t('<strong>Configure your website</strong> Once logged in, visit the <a href="@admin">administration section</a>, where you can <a href="@config">customize and configure</a> all aspects of your website.', array('@admin' => url('admin'), '@config' => url('admin/config'))) . '</li>';
44 $output .= '<li>' . t('<strong>Enable additional functionality</strong> Next, visit the <a href="@modules">module list</a> and enable features which suit your specific needs. You can find additional modules in the <a href="@download_modules">Drupal modules download section</a>.', array('@modules' => url('admin/modules'), '@download_modules' => 'http://drupal.org/project/modules')) . '</li>';
45 $output .= '<li>' . t('<strong>Customize your website design</strong> To change the "look and feel" of your website, visit the <a href="@themes">themes section</a>. You may choose from one of the included themes or download additional themes from the <a href="@download_themes">Drupal themes download section</a>.', array('@themes' => url('admin/appearance'), '@download_themes' => 'http://drupal.org/project/themes')) . '</li>';
46 $output .= '<li>' . t('<strong>Start posting content</strong> Finally, you can <a href="@content">add new content</a> for your website.', array('@content' => url('node/add'))) . '</li>';
47 $output .= '</ol>';
48 $output .= '<p>' . t('For more information, refer to the specific topics listed in the next section or to the <a href="@handbook">online Drupal handbooks</a>. You may also post at the <a href="@forum">Drupal forum</a> or view the wide range of <a href="@support">other support options</a> available.', array('@help' => url('admin/help'), '@handbook' => 'http://drupal.org/documentation', '@forum' => 'http://drupal.org/forum', '@support' => 'http://drupal.org/support')) . '</p>';
49 return $output;
50 case 'admin/help#help':
51 $output = '';
52 $output .= '<h3>' . t('About') . '</h3>';
53 $output .= '<p>' . t('The Help module provides <a href="@help-page">Help reference pages</a> and context-sensitive advice to guide you through the use and configuration of modules. It is a starting point for the online <a href="@handbook">Drupal handbooks</a>. The handbooks contain more extensive and up-to-date information, are annotated with user-contributed comments, and serve as the definitive reference point for all Drupal documentation. For more information, see the online handbook entry for the <a href="@help">Help module</a>.', array('@help' => 'http://drupal.org/documentation/modules/help/', '@handbook' => 'http://drupal.org/documentation', '@help-page' => url('admin/help'))) . '</p>';
54 $output .= '<h3>' . t('Uses') . '</h3>';
55 $output .= '<dl>';
56 $output .= '<dt>' . t('Providing a help reference') . '</dt>';
57 $output .= '<dd>' . t('The Help module displays explanations for using each module listed on the main <a href="@help">Help reference page</a>.', array('@help' => url('admin/help'))) . '</dd>';
58 $output .= '<dt>' . t('Providing context-sensitive help') . '</dt>';
59 $output .= '<dd>' . t('The Help module displays context-sensitive advice and explanations on various pages.') . '</dd>';
60 $output .= '</dl>';
61 return $output;
62 }
63 }
$module
print $module
Definition: search-results.tpl.php:28
help_menu
help_menu()
Definition: help.module:11
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$output
$output
Definition: authorize.php:93
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
MENU_VISIBLE_IN_BREADCRUMB
const MENU_VISIBLE_IN_BREADCRUMB
Definition: menu.inc:96
help_help
help_help($path, $arg)
Definition: help.module:38
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/query.inc Source File

  • includes
  • database
query.inc
Go to the documentation of this file.
1 <?php
2
16 interface QueryConditionInterface {
17
46 public function condition($field, $value = NULL, $operator = NULL);
47
60 public function where($snippet, $args = array());
61
71 public function isNull($field);
72
82 public function isNotNull($field);
83
93 public function exists(SelectQueryInterface $select);
94
104 public function notExists(SelectQueryInterface $select);
105
129 public function &conditions();
130
137 public function arguments();
138
151 public function compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder);
152
159 public function compiled();
160 }
161
162
166 interface QueryAlterableInterface {
167
183 public function addTag($tag);
184
194 public function hasTag($tag);
195
206 public function hasAllTags();
207
218 public function hasAnyTag();
219
236 public function addMetaData($key, $object);
237
247 public function getMetaData($key);
248 }
249
253 interface QueryPlaceholderInterface {
254
258 public function uniqueIdentifier();
259
266 public function nextPlaceholder();
267 }
268
275 abstract class Query implements QueryPlaceholderInterface {
276
282 protected $connection;
283
289 protected $connectionTarget;
290
296 protected $connectionKey;
297
303 protected $queryOptions;
304
308 protected $uniqueIdentifier;
309
313 protected $nextPlaceholder = 0;
314
320 protected $comments = array();
321
330 public function __construct(DatabaseConnection $connection, $options) {
331 $this->uniqueIdentifier = uniqid('', TRUE);
332
333 $this->connection = $connection;
334 $this->connectionKey = $this->connection->getKey();
335 $this->connectionTarget = $this->connection->getTarget();
336
337 $this->queryOptions = $options;
338 }
339
343 public function __sleep() {
344 $keys = get_object_vars($this);
345 unset($keys['connection']);
346 return array_keys($keys);
347 }
348
352 public function __wakeup() {
353 $this->connection = Database::getConnection($this->connectionTarget, $this->connectionKey);
354 }
355
359 public function __clone() {
360 $this->uniqueIdentifier = uniqid('', TRUE);
361 }
362
366 abstract protected function execute();
367
377 abstract public function __toString();
378
382 public function uniqueIdentifier() {
383 return $this->uniqueIdentifier;
384 }
385
392 public function nextPlaceholder() {
393 return $this->nextPlaceholder++;
394 }
395
413 public function comment($comment) {
414 $this->comments[] = $comment;
415 return $this;
416 }
417
433 public function &getComments() {
434 return $this->comments;
435 }
436 }
437
441 class InsertQuery extends Query {
442
448 protected $table;
449
455 protected $insertFields = array();
456
462 protected $defaultFields = array();
463
479 protected $insertValues = array();
480
486 protected $fromQuery;
487
498 public function __construct($connection, $table, array $options = array()) {
499 if (!isset($options['return'])) {
500 $options['return'] = Database::RETURN_INSERT_ID;
501 }
502 parent::__construct($connection, $options);
503 $this->table = $table;
504 }
505
526 public function fields(array $fields, array $values = array()) {
527 if (empty($this->insertFields)) {
528 if (empty($values)) {
529 if (!is_numeric(key($fields))) {
530 $values = array_values($fields);
531 $fields = array_keys($fields);
532 }
533 }
534 $this->insertFields = $fields;
535 if (!empty($values)) {
536 $this->insertValues[] = $values;
537 }
538 }
539
540 return $this;
541 }
542
557 public function values(array $values) {
558 if (is_numeric(key($values))) {
559 $this->insertValues[] = $values;
560 }
561 else {
562 // Reorder the submitted values to match the fields array.
563 foreach ($this->insertFields as $key) {
564 $insert_values[$key] = $values[$key];
565 }
566 // For consistency, the values array is always numerically indexed.
567 $this->insertValues[] = array_values($insert_values);
568 }
569 return $this;
570 }
571
591 public function useDefaults(array $fields) {
592 $this->defaultFields = $fields;
593 return $this;
594 }
595
605 public function from(SelectQueryInterface $query) {
606 $this->fromQuery = $query;
607 return $this;
608 }
609
619 public function execute() {
620 // If validation fails, simply return NULL. Note that validation routines
621 // in preExecute() may throw exceptions instead.
622 if (!$this->preExecute()) {
623 return NULL;
624 }
625
626 // If we're selecting from a SelectQuery, finish building the query and
627 // pass it back, as any remaining options are irrelevant.
628 if (!empty($this->fromQuery)) {
629 $sql = (string) $this;
630 // The SelectQuery may contain arguments, load and pass them through.
631 return $this->connection->query($sql, $this->fromQuery->getArguments(), $this->queryOptions);
632 }
633
634 $last_insert_id = 0;
635
636 // Each insert happens in its own query in the degenerate case. However,
637 // we wrap it in a transaction so that it is atomic where possible. On many
638 // databases, such as SQLite, this is also a notable performance boost.
639 $transaction = $this->connection->startTransaction();
640
641 try {
642 $sql = (string) $this;
643 foreach ($this->insertValues as $insert_values) {
644 $last_insert_id = $this->connection->query($sql, $insert_values, $this->queryOptions);
645 }
646 }
647 catch (Exception $e) {
648 // One of the INSERTs failed, rollback the whole batch.
649 $transaction->rollback();
650 // Rethrow the exception for the calling code.
651 throw $e;
652 }
653
654 // Re-initialize the values array so that we can re-use this query.
655 $this->insertValues = array();
656
657 // Transaction commits here where $transaction looses scope.
658
659 return $last_insert_id;
660 }
661
668 public function __toString() {
669 // Create a sanitized comment string to prepend to the query.
670 $comments = $this->connection->makeComment($this->comments);
671
672 // Default fields are always placed first for consistency.
673 $insert_fields = array_merge($this->defaultFields, $this->insertFields);
674
675 if (!empty($this->fromQuery)) {
676 return $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') ' . $this->fromQuery;
677 }
678
679 // For simplicity, we will use the $placeholders array to inject
680 // default keywords even though they are not, strictly speaking,
681 // placeholders for prepared statements.
682 $placeholders = array();
683 $placeholders = array_pad($placeholders, count($this->defaultFields), 'default');
684 $placeholders = array_pad($placeholders, count($this->insertFields), '?');
685
686 return $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES (' . implode(', ', $placeholders) . ')';
687 }
688
698 public function preExecute() {
699 // Confirm that the user did not try to specify an identical
700 // field and default field.
701 if (array_intersect($this->insertFields, $this->defaultFields)) {
702 throw new FieldsOverlapException('You may not specify the same field to have a value and a schema-default value.');
703 }
704
705 if (!empty($this->fromQuery)) {
706 // We have to assume that the used aliases match the insert fields.
707 // Regular fields are added to the query before expressions, maintain the
708 // same order for the insert fields.
709 // This behavior can be overridden by calling fields() manually as only the
710 // first call to fields() does have an effect.
711 $this->fields(array_merge(array_keys($this->fromQuery->getFields()), array_keys($this->fromQuery->getExpressions())));
712 }
713 else {
714 // Don't execute query without fields.
715 if (count($this->insertFields) + count($this->defaultFields) == 0) {
716 throw new NoFieldsException('There are no fields available to insert with.');
717 }
718 }
719
720 // If no values have been added, silently ignore this query. This can happen
721 // if values are added conditionally, so we don't want to throw an
722 // exception.
723 if (!isset($this->insertValues[0]) && count($this->insertFields) > 0 && empty($this->fromQuery)) {
724 return FALSE;
725 }
726 return TRUE;
727 }
728 }
729
733 class DeleteQuery extends Query implements QueryConditionInterface {
734
740 protected $table;
741
749 protected $condition;
750
761 public function __construct(DatabaseConnection $connection, $table, array $options = array()) {
762 $options['return'] = Database::RETURN_AFFECTED;
763 parent::__construct($connection, $options);
764 $this->table = $table;
765
766 $this->condition = new DatabaseCondition('AND');
767 }
768
772 public function condition($field, $value = NULL, $operator = NULL) {
773 $this->condition->condition($field, $value, $operator);
774 return $this;
775 }
776
780 public function isNull($field) {
781 $this->condition->isNull($field);
782 return $this;
783 }
784
788 public function isNotNull($field) {
789 $this->condition->isNotNull($field);
790 return $this;
791 }
792
796 public function exists(SelectQueryInterface $select) {
797 $this->condition->exists($select);
798 return $this;
799 }
800
804 public function notExists(SelectQueryInterface $select) {
805 $this->condition->notExists($select);
806 return $this;
807 }
808
812 public function &conditions() {
813 return $this->condition->conditions();
814 }
815
819 public function arguments() {
820 return $this->condition->arguments();
821 }
822
826 public function where($snippet, $args = array()) {
827 $this->condition->where($snippet, $args);
828 return $this;
829 }
830
834 public function compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder) {
835 return $this->condition->compile($connection, $queryPlaceholder);
836 }
837
841 public function compiled() {
842 return $this->condition->compiled();
843 }
844
851 public function execute() {
852 $values = array();
853 if (count($this->condition)) {
854 $this->condition->compile($this->connection, $this);
855 $values = $this->condition->arguments();
856 }
857
858 return $this->connection->query((string) $this, $values, $this->queryOptions);
859 }
860
867 public function __toString() {
868 // Create a sanitized comment string to prepend to the query.
869 $comments = $this->connection->makeComment($this->comments);
870
871 $query = $comments . 'DELETE FROM {' . $this->connection->escapeTable($this->table) . '} ';
872
873 if (count($this->condition)) {
874
875 $this->condition->compile($this->connection, $this);
876 $query .= "\nWHERE " . $this->condition;
877 }
878
879 return $query;
880 }
881 }
882
883
887 class TruncateQuery extends Query {
888
894 protected $table;
895
906 public function __construct(DatabaseConnection $connection, $table, array $options = array()) {
907 $options['return'] = Database::RETURN_AFFECTED;
908 parent::__construct($connection, $options);
909 $this->table = $table;
910 }
911
915 public function compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder) {
916 return $this->condition->compile($connection, $queryPlaceholder);
917 }
918
922 public function compiled() {
923 return $this->condition->compiled();
924 }
925
932 public function execute() {
933 return $this->connection->query((string) $this, array(), $this->queryOptions);
934 }
935
942 public function __toString() {
943 // Create a sanitized comment string to prepend to the query.
944 $comments = $this->connection->makeComment($this->comments);
945
946 // In most cases, TRUNCATE is not a transaction safe statement as it is a
947 // DDL statement which results in an implicit COMMIT. When we are in a
948 // transaction, fallback to the slower, but transactional, DELETE.
949 // PostgreSQL also locks the entire table for a TRUNCATE strongly reducing
950 // the concurrency with other transactions.
951 if ($this->connection->inTransaction()) {
952 return $comments . 'DELETE FROM {' . $this->connection->escapeTable($this->table) . '}';
953 }
954 else {
955 return $comments . 'TRUNCATE {' . $this->connection->escapeTable($this->table) . '} ';
956 }
957 }
958 }
959
963 class UpdateQuery extends Query implements QueryConditionInterface {
964
970 protected $table;
971
977 protected $fields = array();
978
984 protected $arguments = array();
985
993 protected $condition;
994
1008 protected $expressionFields = array();
1009
1020 public function __construct(DatabaseConnection $connection, $table, array $options = array()) {
1021 $options['return'] = Database::RETURN_AFFECTED;
1022 parent::__construct($connection, $options);
1023 $this->table = $table;
1024
1025 $this->condition = new DatabaseCondition('AND');
1026 }
1027
1031 public function condition($field, $value = NULL, $operator = NULL) {
1032 $this->condition->condition($field, $value, $operator);
1033 return $this;
1034 }
1035
1039 public function isNull($field) {
1040 $this->condition->isNull($field);
1041 return $this;
1042 }
1043
1047 public function isNotNull($field) {
1048 $this->condition->isNotNull($field);
1049 return $this;
1050 }
1051
1055 public function exists(SelectQueryInterface $select) {
1056 $this->condition->exists($select);
1057 return $this;
1058 }
1059
1063 public function notExists(SelectQueryInterface $select) {
1064 $this->condition->notExists($select);
1065 return $this;
1066 }
1067
1071 public function &conditions() {
1072 return $this->condition->conditions();
1073 }
1074
1078 public function arguments() {
1079 return $this->condition->arguments();
1080 }
1081
1085 public function where($snippet, $args = array()) {
1086 $this->condition->where($snippet, $args);
1087 return $this;
1088 }
1089
1093 public function compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder) {
1094 return $this->condition->compile($connection, $queryPlaceholder);
1095 }
1096
1100 public function compiled() {
1101 return $this->condition->compiled();
1102 }
1103
1114 public function fields(array $fields) {
1115 $this->fields = $fields;
1116 return $this;
1117 }
1118
1137 public function expression($field, $expression, array $arguments = NULL) {
1138 $this->expressionFields[$field] = array(
1139 'expression' => $expression,
1140 'arguments' => $arguments,
1141 );
1142
1143 return $this;
1144 }
1145
1152 public function execute() {
1153
1154 // Expressions take priority over literal fields, so we process those first
1155 // and remove any literal fields that conflict.
1156 $fields = $this->fields;
1157 $update_values = array();
1158 foreach ($this->expressionFields as $field => $data) {
1159 if (!empty($data['arguments'])) {
1160 $update_values += $data['arguments'];
1161 }
1162 unset($fields[$field]);
1163 }
1164
1165 // Because we filter $fields the same way here and in __toString(), the
1166 // placeholders will all match up properly.
1167 $max_placeholder = 0;
1168 foreach ($fields as $field => $value) {
1169 $update_values[':db_update_placeholder_' . ($max_placeholder++)] = $value;
1170 }
1171
1172 if (count($this->condition)) {
1173 $this->condition->compile($this->connection, $this);
1174 $update_values = array_merge($update_values, $this->condition->arguments());
1175 }
1176
1177 return $this->connection->query((string) $this, $update_values, $this->queryOptions);
1178 }
1179
1186 public function __toString() {
1187 // Create a sanitized comment string to prepend to the query.
1188 $comments = $this->connection->makeComment($this->comments);
1189
1190 // Expressions take priority over literal fields, so we process those first
1191 // and remove any literal fields that conflict.
1192 $fields = $this->fields;
1193 $update_fields = array();
1194 foreach ($this->expressionFields as $field => $data) {
1195 $update_fields[] = $field . '=' . $data['expression'];
1196 unset($fields[$field]);
1197 }
1198
1199 $max_placeholder = 0;
1200 foreach ($fields as $field => $value) {
1201 $update_fields[] = $field . '=:db_update_placeholder_' . ($max_placeholder++);
1202 }
1203
1204 $query = $comments . 'UPDATE {' . $this->connection->escapeTable($this->table) . '} SET ' . implode(', ', $update_fields);
1205
1206 if (count($this->condition)) {
1207 $this->condition->compile($this->connection, $this);
1208 // There is an implicit string cast on $this->condition.
1209 $query .= "\nWHERE " . $this->condition;
1210 }
1211
1212 return $query;
1213 }
1214
1215 }
1216
1254 class MergeQuery extends Query implements QueryConditionInterface {
1258 const STATUS_INSERT = 1;
1259
1263 const STATUS_UPDATE = 2;
1264
1270 protected $table;
1271
1275 protected $conditionTable;
1276
1282 protected $insertFields = array();
1283
1291 protected $defaultFields = array();
1292
1298 protected $insertValues = array();
1299
1305 protected $updateFields = array();
1306
1320 protected $expressionFields = array();
1321
1327 protected $needsUpdate = FALSE;
1328
1339 public function __construct(DatabaseConnection $connection, $table, array $options = array()) {
1340 $options['return'] = Database::RETURN_AFFECTED;
1341 parent::__construct($connection, $options);
1342 $this->table = $table;
1343 $this->conditionTable = $table;
1344 $this->condition = new DatabaseCondition('AND');
1345 }
1346
1357 protected function conditionTable($table) {
1358 $this->conditionTable = $table;
1359 return $this;
1360 }
1361
1372 public function updateFields(array $fields) {
1373 $this->updateFields = $fields;
1374 $this->needsUpdate = TRUE;
1375 return $this;
1376 }
1377
1397 public function expression($field, $expression, array $arguments = NULL) {
1398 $this->expressionFields[$field] = array(
1399 'expression' => $expression,
1400 'arguments' => $arguments,
1401 );
1402 $this->needsUpdate = TRUE;
1403 return $this;
1404 }
1405
1422 public function insertFields(array $fields, array $values = array()) {
1423 if ($values) {
1424 $fields = array_combine($fields, $values);
1425 }
1426 $this->insertFields = $fields;
1427 return $this;
1428 }
1429
1449 public function useDefaults(array $fields) {
1450 $this->defaultFields = $fields;
1451 return $this;
1452 }
1453
1475 public function fields(array $fields, array $values = array()) {
1476 if ($values) {
1477 $fields = array_combine($fields, $values);
1478 }
1479 foreach ($fields as $key => $value) {
1480 $this->insertFields[$key] = $value;
1481 $this->updateFields[$key] = $value;
1482 }
1483 $this->needsUpdate = TRUE;
1484 return $this;
1485 }
1486
1509 public function key(array $fields, array $values = array()) {
1510 if ($values) {
1511 $fields = array_combine($fields, $values);
1512 }
1513 foreach ($fields as $key => $value) {
1514 $this->insertFields[$key] = $value;
1515 $this->condition($key, $value);
1516 }
1517 return $this;
1518 }
1519
1523 public function condition($field, $value = NULL, $operator = NULL) {
1524 $this->condition->condition($field, $value, $operator);
1525 return $this;
1526 }
1527
1531 public function isNull($field) {
1532 $this->condition->isNull($field);
1533 return $this;
1534 }
1535
1539 public function isNotNull($field) {
1540 $this->condition->isNotNull($field);
1541 return $this;
1542 }
1543
1547 public function exists(SelectQueryInterface $select) {
1548 $this->condition->exists($select);
1549 return $this;
1550 }
1551
1555 public function notExists(SelectQueryInterface $select) {
1556 $this->condition->notExists($select);
1557 return $this;
1558 }
1559
1563 public function &conditions() {
1564 return $this->condition->conditions();
1565 }
1566
1570 public function arguments() {
1571 return $this->condition->arguments();
1572 }
1573
1577 public function where($snippet, $args = array()) {
1578 $this->condition->where($snippet, $args);
1579 return $this;
1580 }
1581
1585 public function compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder) {
1586 return $this->condition->compile($connection, $queryPlaceholder);
1587 }
1588
1592 public function compiled() {
1593 return $this->condition->compiled();
1594 }
1595
1605 public function __toString() {
1606 }
1607
1608 public function execute() {
1609 if (!count($this->condition)) {
1610 throw new InvalidMergeQueryException(t('Invalid merge query: no conditions'));
1611 }
1612 $select = $this->connection->select($this->conditionTable)
1613 ->condition($this->condition);
1614 $select->addExpression('1');
1615 if (!$select->execute()->fetchField()) {
1616 try {
1617 $insert = $this->connection->insert($this->table)->fields($this->insertFields);
1618 if ($this->defaultFields) {
1619 $insert->useDefaults($this->defaultFields);
1620 }
1621 $insert->execute();
1622 return self::STATUS_INSERT;
1623 }
1624 catch (Exception $e) {
1625 // The insert query failed, maybe it's because a racing insert query
1626 // beat us in inserting the same row. Retry the select query, if it
1627 // returns a row, ignore the error and continue with the update
1628 // query below.
1629 if (!$select->execute()->fetchField()) {
1630 throw $e;
1631 }
1632 }
1633 }
1634 if ($this->needsUpdate) {
1635 $update = $this->connection->update($this->table)
1636 ->fields($this->updateFields)
1637 ->condition($this->condition);
1638 if ($this->expressionFields) {
1639 foreach ($this->expressionFields as $field => $data) {
1640 $update->expression($field, $data['expression'], $data['arguments']);
1641 }
1642 }
1643 $update->execute();
1644 return self::STATUS_UPDATE;
1645 }
1646 }
1647 }
1648
1652 class DatabaseCondition implements QueryConditionInterface, Countable {
1653
1659 protected $conditions = array();
1660
1666 protected $arguments = array();
1667
1676 protected $changed = TRUE;
1677
1681 protected $queryPlaceholderIdentifier;
1682
1689 public function __construct($conjunction) {
1690 $this->conditions['#conjunction'] = $conjunction;
1691 }
1692
1700 public function count() {
1701 return count($this->conditions) - 1;
1702 }
1703
1707 public function condition($field, $value = NULL, $operator = NULL) {
1708 if (!isset($operator)) {
1709 if (is_array($value)) {
1710 $operator = 'IN';
1711 }
1712 elseif (!isset($value)) {
1713 $operator = 'IS NULL';
1714 }
1715 else {
1716 $operator = '=';
1717 }
1718 }
1719 $this->conditions[] = array(
1720 'field' => $field,
1721 'value' => $value,
1722 'operator' => $operator,
1723 );
1724
1725 $this->changed = TRUE;
1726
1727 return $this;
1728 }
1729
1733 public function where($snippet, $args = array()) {
1734 $this->conditions[] = array(
1735 'field' => $snippet,
1736 'value' => $args,
1737 'operator' => NULL,
1738 );
1739 $this->changed = TRUE;
1740
1741 return $this;
1742 }
1743
1747 public function isNull($field) {
1748 return $this->condition($field);
1749 }
1750
1754 public function isNotNull($field) {
1755 return $this->condition($field, NULL, 'IS NOT NULL');
1756 }
1757
1761 public function exists(SelectQueryInterface $select) {
1762 return $this->condition('', $select, 'EXISTS');
1763 }
1764
1768 public function notExists(SelectQueryInterface $select) {
1769 return $this->condition('', $select, 'NOT EXISTS');
1770 }
1771
1775 public function &conditions() {
1776 return $this->conditions;
1777 }
1778
1782 public function arguments() {
1783 // If the caller forgot to call compile() first, refuse to run.
1784 if ($this->changed) {
1785 return NULL;
1786 }
1787 return $this->arguments;
1788 }
1789
1793 public function compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder) {
1794 // Re-compile if this condition changed or if we are compiled against a
1795 // different query placeholder object.
1796 if ($this->changed || isset($this->queryPlaceholderIdentifier) && ($this->queryPlaceholderIdentifier != $queryPlaceholder->uniqueIdentifier())) {
1797 $this->queryPlaceholderIdentifier = $queryPlaceholder->uniqueIdentifier();
1798
1799 $condition_fragments = array();
1800 $arguments = array();
1801
1802 $conditions = $this->conditions;
1803 $conjunction = $conditions['#conjunction'];
1804 unset($conditions['#conjunction']);
1805 foreach ($conditions as $condition) {
1806 if (empty($condition['operator'])) {
1807 // This condition is a literal string, so let it through as is.
1808 $condition_fragments[] = ' (' . $condition['field'] . ') ';
1809 $arguments += $condition['value'];
1810 }
1811 else {
1812 // It's a structured condition, so parse it out accordingly.
1813 // Note that $condition['field'] will only be an object for a dependent
1814 // DatabaseCondition object, not for a dependent subquery.
1815 if ($condition['field'] instanceof QueryConditionInterface) {
1816 // Compile the sub-condition recursively and add it to the list.
1817 $condition['field']->compile($connection, $queryPlaceholder);
1818 $condition_fragments[] = '(' . (string) $condition['field'] . ')';
1819 $arguments += $condition['field']->arguments();
1820 }
1821 else {
1822 // For simplicity, we treat all operators as the same data structure.
1823 // In the typical degenerate case, this won't get changed.
1824 $operator_defaults = array(
1825 'prefix' => '',
1826 'postfix' => '',
1827 'delimiter' => '',
1828 'operator' => $condition['operator'],
1829 'use_value' => TRUE,
1830 );
1831 $operator = $connection->mapConditionOperator($condition['operator']);
1832 if (!isset($operator)) {
1833 $operator = $this->mapConditionOperator($condition['operator']);
1834 }
1835 $operator += $operator_defaults;
1836
1837 $placeholders = array();
1838 if ($condition['value'] instanceof SelectQueryInterface) {
1839 $condition['value']->compile($connection, $queryPlaceholder);
1840 $placeholders[] = (string) $condition['value'];
1841 $arguments += $condition['value']->arguments();
1842 // Subqueries are the actual value of the operator, we don't
1843 // need to add another below.
1844 $operator['use_value'] = FALSE;
1845 }
1846 // We assume that if there is a delimiter, then the value is an
1847 // array. If not, it is a scalar. For simplicity, we first convert
1848 // up to an array so that we can build the placeholders in the same way.
1849 elseif (!$operator['delimiter']) {
1850 $condition['value'] = array($condition['value']);
1851 }
1852 if ($operator['use_value']) {
1853 foreach ($condition['value'] as $value) {
1854 $placeholder = ':db_condition_placeholder_' . $queryPlaceholder->nextPlaceholder();
1855 $arguments[$placeholder] = $value;
1856 $placeholders[] = $placeholder;
1857 }
1858 }
1859 $condition_fragments[] = ' (' . $connection->escapeField($condition['field']) . ' ' . $operator['operator'] . ' ' . $operator['prefix'] . implode($operator['delimiter'], $placeholders) . $operator['postfix'] . ') ';
1860 }
1861 }
1862 }
1863
1864 $this->changed = FALSE;
1865 $this->stringVersion = implode($conjunction, $condition_fragments);
1866 $this->arguments = $arguments;
1867 }
1868 }
1869
1873 public function compiled() {
1874 return !$this->changed;
1875 }
1876
1883 public function __toString() {
1884 // If the caller forgot to call compile() first, refuse to run.
1885 if ($this->changed) {
1886 return NULL;
1887 }
1888 return $this->stringVersion;
1889 }
1890
1897 function __clone() {
1898 $this->changed = TRUE;
1899 foreach ($this->conditions as $key => $condition) {
1900 if ($key !== '#conjunction') {
1901 if ($condition['field'] instanceOf QueryConditionInterface) {
1902 $this->conditions[$key]['field'] = clone($condition['field']);
1903 }
1904 if ($condition['value'] instanceOf SelectQueryInterface) {
1905 $this->conditions[$key]['value'] = clone($condition['value']);
1906 }
1907 }
1908 }
1909 }
1910
1924 protected function mapConditionOperator($operator) {
1925 // $specials does not use drupal_static as its value never changes.
1926 static $specials = array(
1927 'BETWEEN' => array('delimiter' => ' AND '),
1928 'IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'),
1929 'NOT IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'),
1930 'EXISTS' => array('prefix' => ' (', 'postfix' => ')'),
1931 'NOT EXISTS' => array('prefix' => ' (', 'postfix' => ')'),
1932 'IS NULL' => array('use_value' => FALSE),
1933 'IS NOT NULL' => array('use_value' => FALSE),
1934 // Use backslash for escaping wildcard characters.
1935 'LIKE' => array('postfix' => " ESCAPE '\\\\'"),
1936 'NOT LIKE' => array('postfix' => " ESCAPE '\\\\'"),
1937 // These ones are here for performance reasons.
1938 '=' => array(),
1939 '<' => array(),
1940 '>' => array(),
1941 '>=' => array(),
1942 '<=' => array(),
1943 );
1944 if (isset($specials[$operator])) {
1945 $return = $specials[$operator];
1946 }
1947 else {
1948 // We need to upper case because PHP index matches are case sensitive but
1949 // do not need the more expensive drupal_strtoupper because SQL statements are ASCII.
1950 $operator = strtoupper($operator);
1951 $return = isset($specials[$operator]) ? $specials[$operator] : array();
1952 }
1953
1954 $return += array('operator' => $operator);
1955
1956 return $return;
1957 }
1958
1959 }
1960
Query\__clone
__clone()
Definition: query.inc:359
QueryPlaceholderInterface\nextPlaceholder
nextPlaceholder()
Query\$connectionTarget
$connectionTarget
Definition: query.inc:289
InsertQuery\$fromQuery
$fromQuery
Definition: query.inc:486
InsertQuery\from
from(SelectQueryInterface $query)
Definition: query.inc:605
Query\$nextPlaceholder
$nextPlaceholder
Definition: query.inc:313
QueryAlterableInterface
Definition: query.inc:166
MergeQuery\$updateFields
$updateFields
Definition: query.inc:1305
QueryConditionInterface\arguments
arguments()
UpdateQuery\$expressionFields
$expressionFields
Definition: query.inc:1008
DeleteQuery\$condition
$condition
Definition: query.inc:749
InsertQuery\__construct
__construct($connection, $table, array $options=array())
Definition: query.inc:498
QueryAlterableInterface\addMetaData
addMetaData($key, $object)
QueryAlterableInterface\hasTag
hasTag($tag)
Database\getConnection
static getConnection($target= 'default', $key=NULL)
Definition: database.inc:1460
MergeQuery\updateFields
updateFields(array $fields)
Definition: query.inc:1372
Query\__toString
__toString()
$snippet
if($snippet) print $snippet
Definition: search-result.tpl.php:74
QueryConditionInterface\isNull
isNull($field)
FieldsOverlapException
Definition: database.inc:1823
InsertQuery\$table
$table
Definition: query.inc:448
DatabaseCondition\count
count()
Definition: query.inc:1700
MergeQuery\STATUS_UPDATE
const STATUS_UPDATE
Definition: query.inc:1263
Exception
MergeQuery\insertFields
insertFields(array $fields, array $values=array())
Definition: query.inc:1422
UpdateQuery\$fields
$fields
Definition: query.inc:977
Query\__sleep
__sleep()
Definition: query.inc:343
Query\$queryOptions
$queryOptions
Definition: query.inc:303
InsertQuery\useDefaults
useDefaults(array $fields)
Definition: query.inc:591
InsertQuery\preExecute
preExecute()
Definition: query.inc:698
MergeQuery\$conditionTable
$conditionTable
Definition: query.inc:1275
InsertQuery\$insertFields
$insertFields
Definition: query.inc:455
QueryConditionInterface\condition
condition($field, $value=NULL, $operator=NULL)
QueryConditionInterface\compile
compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
Query\__construct
__construct(DatabaseConnection $connection, $options)
Definition: query.inc:330
UpdateQuery\$arguments
$arguments
Definition: query.inc:984
MergeQuery\STATUS_INSERT
const STATUS_INSERT
Definition: query.inc:1258
UpdateQuery\expression
expression($field, $expression, array $arguments=NULL)
Definition: query.inc:1137
Query\$comments
$comments
Definition: query.inc:320
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
DatabaseCondition
Definition: query.inc:1652
QueryAlterableInterface\hasAnyTag
hasAnyTag()
MergeQuery\key
key(array $fields, array $values=array())
Definition: query.inc:1509
QueryConditionInterface\where
where($snippet, $args=array())
Database\RETURN_INSERT_ID
const RETURN_INSERT_ID
Definition: database.inc:1345
InvalidMergeQueryException
Definition: database.inc:1815
MergeQuery\$needsUpdate
$needsUpdate
Definition: query.inc:1327
UpdateQuery\fields
fields(array $fields)
Definition: query.inc:1114
Query\execute
execute()
QueryConditionInterface
Definition: query.inc:16
InsertQuery
Definition: query.inc:441
Query\$connectionKey
$connectionKey
Definition: query.inc:296
QueryAlterableInterface\addTag
addTag($tag)
DatabaseCondition\$changed
$changed
Definition: query.inc:1676
Database\RETURN_AFFECTED
const RETURN_AFFECTED
Definition: database.inc:1340
DeleteQuery
Definition: query.inc:733
$value
print $value
Definition: user-profile-item.tpl.php:26
SelectQueryInterface
Definition: select.inc:39
InsertQuery\$insertValues
$insertValues
Definition: query.inc:479
QueryAlterableInterface\getMetaData
getMetaData($key)
QueryPlaceholderInterface\uniqueIdentifier
uniqueIdentifier()
InsertQuery\$defaultFields
$defaultFields
Definition: query.inc:462
QueryPlaceholderInterface
Definition: query.inc:253
QueryConditionInterface\notExists
notExists(SelectQueryInterface $select)
Query\comment
comment($comment)
Definition: query.inc:413
DatabaseConnection
Definition: database.inc:184
QueryAlterableInterface\hasAllTags
hasAllTags()
Query\__wakeup
__wakeup()
Definition: query.inc:352
QueryConditionInterface\isNotNull
isNotNull($field)
TruncateQuery
Definition: query.inc:887
DatabaseCondition\$conditions
$conditions
Definition: query.inc:1659
InsertQuery\fields
fields(array $fields, array $values=array())
Definition: query.inc:526
DatabaseCondition\$queryPlaceholderIdentifier
$queryPlaceholderIdentifier
Definition: query.inc:1681
QueryConditionInterface\exists
exists(SelectQueryInterface $select)
DatabaseConnection\escapeField
escapeField($field)
Definition: database.inc:936
UpdateQuery
Definition: query.inc:963
Query\getComments
& getComments()
Definition: query.inc:433
InsertQuery\values
values(array $values)
Definition: query.inc:557
Query\$uniqueIdentifier
$uniqueIdentifier
Definition: query.inc:308
Query
Definition: query.inc:275
QueryConditionInterface\conditions
& conditions()
DeleteQuery\__construct
__construct(DatabaseConnection $connection, $table, array $options=array())
Definition: query.inc:761
MergeQuery\conditionTable
conditionTable($table)
Definition: query.inc:1357
Query\$connection
$connection
Definition: query.inc:282
MergeQuery
Definition: query.inc:1254
NoFieldsException
Definition: database.inc:1828
DatabaseConnection\mapConditionOperator
mapConditionOperator($operator)
DatabaseCondition\__construct
__construct($conjunction)
Definition: query.inc:1689
QueryConditionInterface\compiled
compiled()
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/filetransfer/ssh.inc Source File

  • includes
  • filetransfer
ssh.inc
Go to the documentation of this file.
1 <?php
2
6 class FileTransferSSH extends FileTransfer implements FileTransferChmodInterface {
7
8 function __construct($jail, $username, $password, $hostname = "localhost", $port = 22) {
9 $this->username = $username;
10 $this->password = $password;
11 $this->hostname = $hostname;
12 $this->port = $port;
13 parent::__construct($jail);
14 }
15
16 function connect() {
17 $this->connection = @ssh2_connect($this->hostname, $this->port);
18 if (!$this->connection) {
19 throw new FileTransferException('SSH Connection failed to @host:@port', NULL, array('@host' => $this->hostname, '@port' => $this->port));
20 }
21 if (!@ssh2_auth_password($this->connection, $this->username, $this->password)) {
22 throw new FileTransferException('The supplied username/password combination was not accepted.');
23 }
24 }
25
26 static function factory($jail, $settings) {
27 $username = empty($settings['username']) ? '' : $settings['username'];
28 $password = empty($settings['password']) ? '' : $settings['password'];
29 $hostname = empty($settings['advanced']['hostname']) ? 'localhost' : $settings['advanced']['hostname'];
30 $port = empty($settings['advanced']['port']) ? 22 : $settings['advanced']['port'];
31 return new FileTransferSSH($jail, $username, $password, $hostname, $port);
32 }
33
34 protected function copyFileJailed($source, $destination) {
35 if (!@ssh2_scp_send($this->connection, $source, $destination)) {
36 throw new FileTransferException('Cannot copy @source_file to @destination_file.', NULL, array('@source' => $source, '@destination' => $destination));
37 }
38 }
39
40 protected function copyDirectoryJailed($source, $destination) {
41 if (@!ssh2_exec($this->connection, 'cp -Rp ' . escapeshellarg($source) . ' ' . escapeshellarg($destination))) {
42 throw new FileTransferException('Cannot copy directory @directory.', NULL, array('@directory' => $source));
43 }
44 }
45
46 protected function createDirectoryJailed($directory) {
47 if (@!ssh2_exec($this->connection, 'mkdir ' . escapeshellarg($directory))) {
48 throw new FileTransferException('Cannot create directory @directory.', NULL, array('@directory' => $directory));
49 }
50 }
51
52 protected function removeDirectoryJailed($directory) {
53 if (@!ssh2_exec($this->connection, 'rm -Rf ' . escapeshellarg($directory))) {
54 throw new FileTransferException('Cannot remove @directory.', NULL, array('@directory' => $directory));
55 }
56 }
57
58 protected function removeFileJailed($destination) {
59 if (!@ssh2_exec($this->connection, 'rm ' . escapeshellarg($destination))) {
60 throw new FileTransferException('Cannot remove @directory.', NULL, array('@directory' => $destination));
61 }
62 }
63
67 public function isDirectory($path) {
68 $directory = escapeshellarg($path);
69 $cmd = "[ -d {$directory} ] && echo 'yes'";
70 if ($output = @ssh2_exec($this->connection, $cmd)) {
71 if ($output == 'yes') {
72 return TRUE;
73 }
74 return FALSE;
75 } else {
76 throw new FileTransferException('Cannot check @path.', NULL, array('@path' => $path));
77 }
78 }
79
80 public function isFile($path) {
81 $file = escapeshellarg($path);
82 $cmd = "[ -f {$file} ] && echo 'yes'";
83 if ($output = @ssh2_exec($this->connection, $cmd)) {
84 if ($output == 'yes') {
85 return TRUE;
86 }
87 return FALSE;
88 } else {
89 throw new FileTransferException('Cannot check @path.', NULL, array('@path' => $path));
90 }
91 }
92
93 function chmodJailed($path, $mode, $recursive) {
94 $cmd = sprintf("chmod %s%o %s", $recursive ? '-R ' : '', $mode, escapeshellarg($path));
95 if (@!ssh2_exec($this->connection, $cmd)) {
96 throw new FileTransferException('Cannot change permissions of @path.', NULL, array('@path' => $path));
97 }
98 }
99
103 public function getSettingsForm() {
104 $form = parent::getSettingsForm();
105 $form['advanced']['port']['#default_value'] = 22;
106 return $form;
107 }
108 }
FileTransferSSH\connect
connect()
Definition: ssh.inc:16
FileTransferSSH\chmodJailed
chmodJailed($path, $mode, $recursive)
Definition: ssh.inc:93
FileTransferException
Definition: filetransfer.inc:363
FileTransferSSH\isDirectory
isDirectory($path)
Definition: ssh.inc:67
FileTransferSSH\isFile
isFile($path)
Definition: ssh.inc:80
FileTransfer\$password
$password
Definition: filetransfer.inc:14
FileTransferSSH\copyDirectoryJailed
copyDirectoryJailed($source, $destination)
Definition: ssh.inc:40
FileTransferSSH\createDirectoryJailed
createDirectoryJailed($directory)
Definition: ssh.inc:46
FileTransfer
Definition: filetransfer.inc:12
FileTransferChmodInterface
Definition: filetransfer.inc:376
FileTransferSSH\getSettingsForm
getSettingsForm()
Definition: ssh.inc:103
$output
$output
Definition: authorize.php:93
FileTransferSSH\removeDirectoryJailed
removeDirectoryJailed($directory)
Definition: ssh.inc:52
FileTransfer\$port
$port
Definition: filetransfer.inc:16
FileTransferSSH
Definition: ssh.inc:6
FileTransfer\$hostname
$hostname
Definition: filetransfer.inc:15
FileTransfer\$username
$username
Definition: filetransfer.inc:13
FileTransferSSH\__construct
__construct($jail, $username, $password, $hostname="localhost", $port=22)
Definition: ssh.inc:8
FileTransferSSH\copyFileJailed
copyFileJailed($source, $destination)
Definition: ssh.inc:34
FileTransferSSH\factory
static factory($jail, $settings)
Definition: ssh.inc:26
FileTransferSSH\removeFileJailed
removeFileJailed($destination)
Definition: ssh.inc:58
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalEntityControllerInterface Member List

This is the complete list of members for DrupalEntityControllerInterface, including all inherited members.

load($ids=array(), $conditions=array()) | DrupalEntityControllerInterface
resetCache(array $ids=NULL) | DrupalEntityControllerInterface
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search.api.php Source File

  • modules
  • search
search.api.php
Go to the documentation of this file.
1 <?php
2
41 function hook_search_info() {
42 return array(
43 'title' => 'Content',
44 'path' => 'node',
45 'conditions_callback' => 'callback_search_conditions',
46 );
47 }
48
56 function hook_search_access() {
57 return user_access('access content');
58 }
59
69 function hook_search_reset() {
70 db_update('search_dataset')
71 ->fields(array('reindex' => REQUEST_TIME))
72 ->condition('type', 'node')
73 ->execute();
74 }
75
90 function hook_search_status() {
91 $total = db_query('SELECT COUNT(*) FROM {node} WHERE status = 1')->fetchField();
92 $remaining = db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND d.sid IS NULL OR d.reindex <> 0")->fetchField();
93 return array('remaining' => $remaining, 'total' => $total);
94 }
95
104 function hook_search_admin() {
105 // Output form for defining rank factor weights.
106 $form['content_ranking'] = array(
107 '#type' => 'fieldset',
108 '#title' => t('Content ranking'),
109 );
110 $form['content_ranking']['#theme'] = 'node_search_admin';
111 $form['content_ranking']['info'] = array(
112 '#value' => '<em>' . t('The following numbers control which properties the content search should favor when ordering the results. Higher numbers mean more influence, zero means the property is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em>'
113 );
114
115 // Note: reversed to reflect that higher number = higher ranking.
116 $options = drupal_map_assoc(range(0, 10));
117 foreach (module_invoke_all('ranking') as $var => $values) {
118 $form['content_ranking']['factors']['node_rank_' . $var] = array(
119 '#title' => $values['title'],
120 '#type' => 'select',
121 '#options' => $options,
122 '#default_value' => variable_get('node_rank_' . $var, 0),
123 );
124 }
125 return $form;
126 }
127
167 function hook_search_execute($keys = NULL, $conditions = NULL) {
168 // Build matching conditions
169 $query = db_select('search_index', 'i', array('target' => 'slave'))->extend('SearchQuery')->extend('PagerDefault');
170 $query->join('node', 'n', 'n.nid = i.sid');
171 $query
172 ->condition('n.status', 1)
173 ->addTag('node_access')
174 ->searchExpression($keys, 'node');
175
176 // Insert special keywords.
177 $query->setOption('type', 'n.type');
178 $query->setOption('language', 'n.language');
179 if ($query->setOption('term', 'ti.tid')) {
180 $query->join('taxonomy_index', 'ti', 'n.nid = ti.nid');
181 }
182 // Only continue if the first pass query matches.
183 if (!$query->executeFirstPass()) {
184 return array();
185 }
186
187 // Add the ranking expressions.
188 _node_rankings($query);
189
190 // Load results.
191 $find = $query
192 ->limit(10)
193 ->execute();
194 $results = array();
195 foreach ($find as $item) {
196 // Build the node body.
197 $node = node_load($item->sid);
198 node_build_content($node, 'search_result');
199 $node->body = drupal_render($node->content);
200
201 // Fetch comments for snippet.
202 $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node);
203 // Fetch terms for snippet.
204 $node->rendered .= ' ' . module_invoke('taxonomy', 'node_update_index', $node);
205
206 $extra = module_invoke_all('node_search_result', $node);
207
208 $results[] = array(
209 'link' => url('node/' . $item->sid, array('absolute' => TRUE)),
210 'type' => check_plain(node_type_get_name($node)),
211 'title' => $node->title,
212 'user' => theme('username', array('account' => $node)),
213 'date' => $node->changed,
214 'node' => $node,
215 'extra' => $extra,
216 'score' => $item->calculated_score,
217 'snippet' => search_excerpt($keys, $node->body),
218 );
219 }
220 return $results;
221 }
222
244 function hook_search_page($results) {
245 $output['prefix']['#markup'] = '<ol class="search-results">';
246
247 foreach ($results as $entry) {
248 $output[] = array(
249 '#theme' => 'search_result',
250 '#result' => $entry,
251 '#module' => 'my_module_name',
252 );
253 }
254 $output['suffix']['#markup'] = '</ol>' . theme('pager');
255
256 return $output;
257 }
258
283 function hook_search_preprocess($text) {
284 // Do processing on $text
285 return $text;
286 }
287
308 function hook_update_index() {
309 $limit = (int)variable_get('search_cron_limit', 100);
310
311 $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit);
312
313 foreach ($result as $node) {
314 $node = node_load($node->nid);
315
316 // Save the changed time of the most recent indexed node, for the search
317 // results half-life calculation.
318 variable_set('node_cron_last', $node->changed);
319
320 // Render the node.
321 node_build_content($node, 'search_index');
322 $node->rendered = drupal_render($node->content);
323
324 $text = '<h1>' . check_plain($node->title) . '</h1>' . $node->rendered;
325
326 // Fetch extra data normally not visible
327 $extra = module_invoke_all('node_update_index', $node);
328 foreach ($extra as $t) {
329 $text .= $t;
330 }
331
332 // Update index
333 search_index($node->nid, 'node', $text);
334 }
335 }
363 function callback_search_conditions($keys) {
364 $conditions = array();
365
366 if (!empty($_REQUEST['keys'])) {
367 $conditions['keys'] = $_REQUEST['keys'];
368 }
369 if (!empty($_REQUEST['sample_search_keys'])) {
370 $conditions['sample_search_keys'] = $_REQUEST['sample_search_keys'];
371 }
372 if ($force_keys = config('sample_search.settings')->get('force_keywords')) {
373 $conditions['sample_search_force_keywords'] = $force_keys;
374 }
375 return $conditions;
376 }
hook_search_reset
hook_search_reset()
Definition: search.api.php:69
hook_search_info
hook_search_info()
Definition: search.api.php:41
hook_search_page
hook_search_page($results)
Definition: search.api.php:244
callback_search_conditions
callback_search_conditions($keys)
Definition: search.api.php:363
$results
print $results
Definition: poll-results.tpl.php:23
node_type_get_name
node_type_get_name($node)
Definition: node.module:459
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
_node_rankings
_node_rankings(SelectQueryExtender $query)
Definition: node.module:1623
search_index
search_index($sid, $module, $text)
Definition: search.module:552
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
hook_search_admin
hook_search_admin()
Definition: search.api.php:104
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
hook_search_status
hook_search_status()
Definition: search.api.php:90
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
hook_search_access
hook_search_access()
Definition: search.api.php:56
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
hook_search_preprocess
hook_search_preprocess($text)
Definition: search.api.php:283
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
hook_update_index
hook_update_index()
Definition: search.api.php:308
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
node_build_content
node_build_content($node, $view_mode= 'full', $langcode=NULL)
Definition: node.module:1391
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
search_excerpt
search_excerpt($keys, $text)
Definition: search.module:1125
hook_search_execute
hook_search_execute($keys=NULL, $conditions=NULL)
Definition: search.api.php:167
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example/ajax_example_misc.inc Source File

  • examples
  • ajax_example
ajax_example_misc.inc
Go to the documentation of this file.
1 <?php
2
21 function ajax_example_render_link() {
22 // drupal_add_library is invoked automatically when a form element has the
23 // '#ajax' property, but since we are not rendering a form here, we have to
24 // do it ourselves.
25 drupal_add_library('system', 'drupal.ajax');
26 $explanation = "
27 The link below has the <i>use-ajax</i> class applied to it, so if
28 javascript is enabled, ajax.js will try to submit it via an AJAX call instead
29 of a normal page load. The URL also contains the '/nojs/' magic string, which
30 is stripped if javascript is enabled, allowing the server code to tell by the
31 URL whether JS was enabled or not, letting it do different things based on that.";
32 $output = "<div>" . t($explanation) . "</div>";
33 // The use-ajax class is special, so that the link will call without causing
34 // a page reload. Note the /nojs portion of the path - if javascript is
35 // enabled, this part will be stripped from the path before it is called.
36 $link = l(t('Click here'), 'ajax_link_callback/nojs/', array('attributes' => array('class' => array('use-ajax'))));
37 $output .= "<div id='myDiv'></div><div>$link</div>";
38 return $output;
39 }
40
57 function ajax_example_render_link_ra() {
58 $explanation = "
59 The link below has been rendered as an element with the #ajax property, so if
60 javascript is enabled, ajax.js will try to submit it via an AJAX call instead
61 of a normal page load. The URL also contains the '/nojs/' magic string, which
62 is stripped if javascript is enabled, allowing the server code to tell by the
63 URL whether JS was enabled or not, letting it do different things based on that.";
64 $build['my_div'] = array(
65 '#markup' => $explanation . '<div id="myDiv"></div>',
66 );
67 $build['ajax_link'] = array(
68 '#type' => 'link',
69 '#title' => t('Click here'),
70 // Note the /nojs portion of the href - if javascript is enabled,
71 // this part will be stripped from the path before it is called.
72 '#href' => 'ajax_link_callback/nojs/',
73 '#id' => 'ajax_link',
74 '#ajax' => array(
75 'wrapper' => 'myDiv',
76 'method' => 'html',
77 ),
78 );
79 return $build;
80 }
81
98 function ajax_link_response($type = 'ajax') {
99 if ($type == 'ajax') {
100 $output = t("This is some content delivered via AJAX");
101 $commands = array();
102 // See ajax_example_advanced.inc for more details on the available commands
103 // and how to use them.
104 $commands[] = ajax_command_append('#myDiv', $output);
105 $page = array('#type' => 'ajax', '#commands' => $commands);
106 ajax_deliver($page);
107 }
108 else {
109 $output = t("This is some content delivered via a page load.");
110 return $output;
111 }
112 }
l
l($text, $path, array $options=array())
Definition: common.inc:2432
ajax_example_render_link_ra
ajax_example_render_link_ra()
Definition: ajax_example_misc.inc:57
$page
print $page
Definition: overlay.tpl.php:37
ajax_example_render_link
ajax_example_render_link()
Definition: ajax_example_misc.inc:21
ajax_link_response
ajax_link_response($type= 'ajax')
Definition: ajax_example_misc.inc:98
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
drupal_add_library
drupal_add_library($module, $name, $every_page=NULL)
Definition: common.inc:4694
ajax_command_append
ajax_command_append($selector, $html, $settings=NULL)
Definition: ajax.inc:941
$output
$output
Definition: authorize.php:93
ajax_deliver
ajax_deliver($page_callback_result)
Definition: ajax.inc:440
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalUpdaterInterface Member List

This is the complete list of members for DrupalUpdaterInterface, including all inherited members.

canUpdateDirectory($directory) | DrupalUpdaterInterface | static
getInstallDirectory() | DrupalUpdaterInterface |
getProjectName($directory) | DrupalUpdaterInterface | static
isInstalled() | DrupalUpdaterInterface |
postInstall() | DrupalUpdaterInterface |
postUpdate() | DrupalUpdaterInterface |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
FileTransfer Member List

This is the complete list of members for FileTransfer, including all inherited members.

$hostname | FileTransfer | protected
$password | FileTransfer | protected
$port | FileTransfer | protected
$username | FileTransfer | protected
__construct($jail) | FileTransfer |
__get($name) | FileTransfer |
checkPath($path) | FileTransfer | protected
chmod($path, $mode, $recursive=FALSE) | FileTransfer |
connect() | FileTransfer | protected
copyDirectory($source, $destination) | FileTransfer |
copyDirectoryJailed($source, $destination) | FileTransfer | protected
copyFile($source, $destination) | FileTransfer |
copyFileJailed($source, $destination) | FileTransfer | protected
createDirectory($directory) | FileTransfer |
createDirectoryJailed($directory) | FileTransfer | protected
factory($jail, $settings) | FileTransfer | static
findChroot() | FileTransfer |
fixRemotePath($path, $strip_chroot=TRUE) | FileTransfer | protected
getSettingsForm() | FileTransfer |
isDirectory($path) | FileTransfer |
isFile($path) | FileTransfer |
removeDirectory($directory) | FileTransfer |
removeDirectoryJailed($directory) | FileTransfer | protected
removeFile($destination) | FileTransfer |
removeFileJailed($destination) | FileTransfer | protected
sanitizePath($path) | FileTransfer |
setChroot() | FileTransfer |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/image.gd.inc Source File

  • modules
  • system
image.gd.inc
Go to the documentation of this file.
1 <?php
2
16 function image_gd_settings() {
17 if (image_gd_check_settings()) {
18 $form['status'] = array(
19 '#markup' => t('The GD toolkit is installed and working properly.')
20 );
21
22 $form['image_jpeg_quality'] = array(
23 '#type' => 'textfield',
24 '#title' => t('JPEG quality'),
25 '#description' => t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality but bigger files.'),
26 '#size' => 10,
27 '#maxlength' => 3,
28 '#default_value' => variable_get('image_jpeg_quality', 75),
29 '#field_suffix' => t('%'),
30 );
31 $form['#element_validate'] = array('image_gd_settings_validate');
32
33 return $form;
34 }
35 else {
36 form_set_error('image_toolkit', t('The GD image toolkit requires that the GD module for PHP be installed and configured properly. For more information see <a href="@url">PHP\'s image documentation</a>.', array('@url' => 'http://php.net/image')));
37 return FALSE;
38 }
39 }
40
44 function image_gd_settings_validate($form, &$form_state) {
45 // Validate image quality range.
46 $value = $form_state['values']['image_jpeg_quality'];
47 if (!is_numeric($value) || $value < 0 || $value > 100) {
48 form_set_error('image_jpeg_quality', t('JPEG quality must be a number between 0 and 100.'));
49 }
50 }
51
58 function image_gd_check_settings() {
59 if ($check = get_extension_funcs('gd')) {
60 if (in_array('imagegd2', $check)) {
61 // GD2 support is available.
62 return TRUE;
63 }
64 }
65 return FALSE;
66 }
67
83 function image_gd_resize(stdClass $image, $width, $height) {
84 $res = image_gd_create_tmp($image, $width, $height);
85
86 if (!imagecopyresampled($res, $image->resource, 0, 0, 0, 0, $width, $height, $image->info['width'], $image->info['height'])) {
87 return FALSE;
88 }
89
90 imagedestroy($image->resource);
91 // Update image object.
92 $image->resource = $res;
93 $image->info['width'] = $width;
94 $image->info['height'] = $height;
95 return TRUE;
96 }
97
117 function image_gd_rotate(stdClass $image, $degrees, $background = NULL) {
118 // PHP installations using non-bundled GD do not have imagerotate.
119 if (!function_exists('imagerotate')) {
120 watchdog('image', 'The image %file could not be rotated because the imagerotate() function is not available in this PHP installation.', array('%file' => $image->source));
121 return FALSE;
122 }
123
124 $width = $image->info['width'];
125 $height = $image->info['height'];
126
127 // Convert the hexadecimal background value to a color index value.
128 if (isset($background)) {
129 $rgb = array();
130 for ($i = 16; $i >= 0; $i -= 8) {
131 $rgb[] = (($background >> $i) & 0xFF);
132 }
133 $background = imagecolorallocatealpha($image->resource, $rgb[0], $rgb[1], $rgb[2], 0);
134 }
135 // Set the background color as transparent if $background is NULL.
136 else {
137 // Get the current transparent color.
138 $background = imagecolortransparent($image->resource);
139
140 // If no transparent colors, use white.
141 if ($background == 0) {
142 $background = imagecolorallocatealpha($image->resource, 255, 255, 255, 0);
143 }
144 }
145
146 // Images are assigned a new color palette when rotating, removing any
147 // transparency flags. For GIF images, keep a record of the transparent color.
148 if ($image->info['extension'] == 'gif') {
149 $transparent_index = imagecolortransparent($image->resource);
150 if ($transparent_index != 0) {
151 $transparent_gif_color = imagecolorsforindex($image->resource, $transparent_index);
152 }
153 }
154
155 $image->resource = imagerotate($image->resource, 360 - $degrees, $background);
156
157 // GIFs need to reassign the transparent color after performing the rotate.
158 if (isset($transparent_gif_color)) {
159 $background = imagecolorexactalpha($image->resource, $transparent_gif_color['red'], $transparent_gif_color['green'], $transparent_gif_color['blue'], $transparent_gif_color['alpha']);
160 imagecolortransparent($image->resource, $background);
161 }
162
163 $image->info['width'] = imagesx($image->resource);
164 $image->info['height'] = imagesy($image->resource);
165 return TRUE;
166 }
167
187 function image_gd_crop(stdClass $image, $x, $y, $width, $height) {
188 $res = image_gd_create_tmp($image, $width, $height);
189
190 if (!imagecopyresampled($res, $image->resource, 0, 0, $x, $y, $width, $height, $width, $height)) {
191 return FALSE;
192 }
193
194 // Destroy the original image and return the modified image.
195 imagedestroy($image->resource);
196 $image->resource = $res;
197 $image->info['width'] = $width;
198 $image->info['height'] = $height;
199 return TRUE;
200 }
201
214 function image_gd_desaturate(stdClass $image) {
215 // PHP installations using non-bundled GD do not have imagefilter.
216 if (!function_exists('imagefilter')) {
217 watchdog('image', 'The image %file could not be desaturated because the imagefilter() function is not available in this PHP installation.', array('%file' => $image->source));
218 return FALSE;
219 }
220
221 return imagefilter($image->resource, IMG_FILTER_GRAYSCALE);
222 }
223
234 function image_gd_load(stdClass $image) {
235 $extension = str_replace('jpg', 'jpeg', $image->info['extension']);
236 $function = 'imagecreatefrom' . $extension;
237 return (function_exists($function) && $image->resource = $function($image->source));
238 }
239
252 function image_gd_save(stdClass $image, $destination) {
253 $scheme = file_uri_scheme($destination);
254 // Work around lack of stream wrapper support in imagejpeg() and imagepng().
255 if ($scheme && file_stream_wrapper_valid_scheme($scheme)) {
256 // If destination is not local, save image to temporary local file.
257 $local_wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_LOCAL);
258 if (!isset($local_wrappers[$scheme])) {
259 $permanent_destination = $destination;
260 $destination = drupal_tempnam('temporary://', 'gd_');
261 }
262 // Convert stream wrapper URI to normal path.
263 $destination = drupal_realpath($destination);
264 }
265
266 $extension = str_replace('jpg', 'jpeg', $image->info['extension']);
267 $function = 'image' . $extension;
268 if (!function_exists($function)) {
269 return FALSE;
270 }
271 if ($extension == 'jpeg') {
272 $success = $function($image->resource, $destination, variable_get('image_jpeg_quality', 75));
273 }
274 else {
275 // Always save PNG images with full transparency.
276 if ($extension == 'png') {
277 imagealphablending($image->resource, FALSE);
278 imagesavealpha($image->resource, TRUE);
279 }
280 $success = $function($image->resource, $destination);
281 }
282 // Move temporary local file to remote destination.
283 if (isset($permanent_destination) && $success) {
284 return (bool) file_unmanaged_move($destination, $permanent_destination, FILE_EXISTS_REPLACE);
285 }
286 return $success;
287 }
288
301 function image_gd_create_tmp(stdClass $image, $width, $height) {
302 $res = imagecreatetruecolor($width, $height);
303
304 if ($image->info['extension'] == 'gif') {
305 // Grab transparent color index from image resource.
306 $transparent = imagecolortransparent($image->resource);
307
308 if ($transparent >= 0) {
309 // The original must have a transparent color, allocate to the new image.
310 $transparent_color = imagecolorsforindex($image->resource, $transparent);
311 $transparent = imagecolorallocate($res, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);
312
313 // Flood with our new transparent color.
314 imagefill($res, 0, 0, $transparent);
315 imagecolortransparent($res, $transparent);
316 }
317 }
318 elseif ($image->info['extension'] == 'png') {
319 imagealphablending($res, FALSE);
320 $transparency = imagecolorallocatealpha($res, 0, 0, 0, 127);
321 imagefill($res, 0, 0, $transparency);
322 imagealphablending($res, TRUE);
323 imagesavealpha($res, TRUE);
324 }
325 else {
326 imagefill($res, 0, 0, imagecolorallocate($res, 255, 255, 255));
327 }
328
329 return $res;
330 }
331
347 function image_gd_get_info(stdClass $image) {
348 $details = FALSE;
349 $data = getimagesize($image->source);
350
351 if (isset($data) && is_array($data)) {
352 $extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
353 $extension = isset($extensions[$data[2]]) ? $extensions[$data[2]] : '';
354 $details = array(
355 'width' => $data[0],
356 'height' => $data[1],
357 'extension' => $extension,
358 'mime_type' => $data['mime'],
359 );
360 }
361
362 return $details;
363 }
364
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
drupal_tempnam
drupal_tempnam($directory, $prefix)
Definition: file.inc:2424
drupal_realpath
drupal_realpath($uri)
Definition: file.inc:2259
image_gd_settings
image_gd_settings()
Definition: image.gd.inc:16
file_unmanaged_move
file_unmanaged_move($source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1103
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
image_gd_save
image_gd_save(stdClass $image, $destination)
Definition: image.gd.inc:252
file_get_stream_wrappers
file_get_stream_wrappers($filter=STREAM_WRAPPERS_ALL)
Definition: file.inc:123
file_stream_wrapper_valid_scheme
file_stream_wrapper_valid_scheme($scheme)
Definition: file.inc:218
FILE_EXISTS_REPLACE
const FILE_EXISTS_REPLACE
Definition: file.inc:56
image_gd_settings_validate
image_gd_settings_validate($form, &$form_state)
Definition: image.gd.inc:44
$value
print $value
Definition: user-profile-item.tpl.php:26
image_gd_rotate
image_gd_rotate(stdClass $image, $degrees, $background=NULL)
Definition: image.gd.inc:117
image_gd_check_settings
image_gd_check_settings()
Definition: image.gd.inc:58
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
image_gd_resize
image_gd_resize(stdClass $image, $width, $height)
Definition: image.gd.inc:83
image_gd_load
image_gd_load(stdClass $image)
Definition: image.gd.inc:234
image_gd_crop
image_gd_crop(stdClass $image, $x, $y, $width, $height)
Definition: image.gd.inc:187
file_uri_scheme
file_uri_scheme($uri)
Definition: file.inc:199
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
image_gd_get_info
image_gd_get_info(stdClass $image)
Definition: image.gd.inc:347
image_gd_desaturate
image_gd_desaturate(stdClass $image)
Definition: image.gd.inc:214
STREAM_WRAPPERS_LOCAL
const STREAM_WRAPPERS_LOCAL
Definition: stream_wrappers.inc:37
image_gd_create_tmp
image_gd_create_tmp(stdClass $image, $width, $height)
Definition: image.gd.inc:301
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/image/image.effects.inc Source File

  • modules
  • image
image.effects.inc
Go to the documentation of this file.
1 <?php
2
11 function image_image_effect_info() {
12 $effects = array(
13 'image_resize' => array(
14 'label' => t('Resize'),
15 'help' => t('Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately.'),
16 'effect callback' => 'image_resize_effect',
17 'dimensions callback' => 'image_resize_dimensions',
18 'form callback' => 'image_resize_form',
19 'summary theme' => 'image_resize_summary',
20 ),
21 'image_scale' => array(
22 'label' => t('Scale'),
23 'help' => t('Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.'),
24 'effect callback' => 'image_scale_effect',
25 'dimensions callback' => 'image_scale_dimensions',
26 'form callback' => 'image_scale_form',
27 'summary theme' => 'image_scale_summary',
28 ),
29 'image_scale_and_crop' => array(
30 'label' => t('Scale and crop'),
31 'help' => t('Scale and crop will maintain the aspect-ratio of the original image, then crop the larger dimension. This is most useful for creating perfectly square thumbnails without stretching the image.'),
32 'effect callback' => 'image_scale_and_crop_effect',
33 'dimensions callback' => 'image_resize_dimensions',
34 'form callback' => 'image_resize_form',
35 'summary theme' => 'image_resize_summary',
36 ),
37 'image_crop' => array(
38 'label' => t('Crop'),
39 'help' => t('Cropping will remove portions of an image to make it the specified dimensions.'),
40 'effect callback' => 'image_crop_effect',
41 'dimensions callback' => 'image_resize_dimensions',
42 'form callback' => 'image_crop_form',
43 'summary theme' => 'image_crop_summary',
44 ),
45 'image_desaturate' => array(
46 'label' => t('Desaturate'),
47 'help' => t('Desaturate converts an image to grayscale.'),
48 'effect callback' => 'image_desaturate_effect',
49 'dimensions passthrough' => TRUE,
50 ),
51 'image_rotate' => array(
52 'label' => t('Rotate'),
53 'help' => t('Rotating an image may cause the dimensions of an image to increase to fit the diagonal.'),
54 'effect callback' => 'image_rotate_effect',
55 'dimensions callback' => 'image_rotate_dimensions',
56 'form callback' => 'image_rotate_form',
57 'summary theme' => 'image_rotate_summary',
58 ),
59 );
60
61 return $effects;
62 }
63
80 function image_resize_effect(&$image, $data) {
81 if (!image_resize($image, $data['width'], $data['height'])) {
82 watchdog('image', 'Image resize failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
83 return FALSE;
84 }
85 return TRUE;
86 }
87
100 function image_resize_dimensions(array &$dimensions, array $data) {
101 // The new image will have the exact dimensions defined for the effect.
102 $dimensions['width'] = $data['width'];
103 $dimensions['height'] = $data['height'];
104 }
105
124 function image_scale_effect(&$image, $data) {
125 // Set sane default values.
126 $data += array(
127 'width' => NULL,
128 'height' => NULL,
129 'upscale' => FALSE,
130 );
131
132 if (!image_scale($image, $data['width'], $data['height'], $data['upscale'])) {
133 watchdog('image', 'Image scale failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
134 return FALSE;
135 }
136 return TRUE;
137 }
138
153 function image_scale_dimensions(array &$dimensions, array $data) {
154 if ($dimensions['width'] && $dimensions['height']) {
155 image_dimensions_scale($dimensions, $data['width'], $data['height'], $data['upscale']);
156 }
157 }
158
177 function image_crop_effect(&$image, $data) {
178 // Set sane default values.
179 $data += array(
180 'anchor' => 'center-center',
181 );
182
183 list($x, $y) = explode('-', $data['anchor']);
184 $x = image_filter_keyword($x, $image->info['width'], $data['width']);
185 $y = image_filter_keyword($y, $image->info['height'], $data['height']);
186 if (!image_crop($image, $x, $y, $data['width'], $data['height'])) {
187 watchdog('image', 'Image crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
188 return FALSE;
189 }
190 return TRUE;
191 }
192
207 function image_scale_and_crop_effect(&$image, $data) {
208 if (!image_scale_and_crop($image, $data['width'], $data['height'])) {
209 watchdog('image', 'Image scale and crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
210 return FALSE;
211 }
212 return TRUE;
213 }
214
226 function image_desaturate_effect(&$image, $data) {
227 if (!image_desaturate($image)) {
228 watchdog('image', 'Image desaturate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
229 return FALSE;
230 }
231 return TRUE;
232 }
233
253 function image_rotate_effect(&$image, $data) {
254 // Set sane default values.
255 $data += array(
256 'degrees' => 0,
257 'bgcolor' => NULL,
258 'random' => FALSE,
259 );
260
261 // Convert short #FFF syntax to full #FFFFFF syntax.
262 if (strlen($data['bgcolor']) == 4) {
263 $c = $data['bgcolor'];
264 $data['bgcolor'] = $c[0] . $c[1] . $c[1] . $c[2] . $c[2] . $c[3] . $c[3];
265 }
266
267 // Convert #FFFFFF syntax to hexadecimal colors.
268 if ($data['bgcolor'] != '') {
269 $data['bgcolor'] = hexdec(str_replace('#', '0x', $data['bgcolor']));
270 }
271 else {
272 $data['bgcolor'] = NULL;
273 }
274
275 if (!empty($data['random'])) {
276 $degrees = abs((float) $data['degrees']);
277 $data['degrees'] = rand(-1 * $degrees, $degrees);
278 }
279
280 if (!image_rotate($image, $data['degrees'], $data['bgcolor'])) {
281 watchdog('image', 'Image rotate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
282 return FALSE;
283 }
284 return TRUE;
285 }
286
301 function image_rotate_dimensions(array &$dimensions, array $data) {
302 // If the rotate is not random and the angle is a multiple of 90 degrees,
303 // then the new dimensions can be determined.
304 if (!$data['random'] && ((int) ($data['degrees']) == $data['degrees']) && ($data['degrees'] % 90 == 0)) {
305 if ($data['degrees'] % 180 != 0) {
306 $temp = $dimensions['width'];
307 $dimensions['width'] = $dimensions['height'];
308 $dimensions['height'] = $temp;
309 }
310 }
311 else {
312 $dimensions['width'] = $dimensions['height'] = NULL;
313 }
314 }
image_scale
image_scale(stdClass $image, $width=NULL, $height=NULL, $upscale=FALSE)
Definition: image.inc:252
image_rotate_effect
image_rotate_effect(&$image, $data)
Definition: image.effects.inc:253
image_rotate_dimensions
image_rotate_dimensions(array &$dimensions, array $data)
Definition: image.effects.inc:301
image_crop
image_crop(stdClass $image, $x, $y, $width, $height)
Definition: image.inc:331
image_rotate
image_rotate(stdClass $image, $degrees, $background=NULL)
Definition: image.inc:306
image_crop_effect
image_crop_effect(&$image, $data)
Definition: image.effects.inc:177
image_resize
image_resize(stdClass $image, $width, $height)
Definition: image.inc:279
image_scale_and_crop_effect
image_scale_and_crop_effect(&$image, $data)
Definition: image.effects.inc:207
image_resize_effect
image_resize_effect(&$image, $data)
Definition: image.effects.inc:80
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
image_desaturate_effect
image_desaturate_effect(&$image, $data)
Definition: image.effects.inc:226
image_scale_and_crop
image_scale_and_crop(stdClass $image, $width, $height)
Definition: image.inc:169
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
image_dimensions_scale
image_dimensions_scale(array &$dimensions, $width=NULL, $height=NULL, $upscale=FALSE)
Definition: image.inc:203
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
image_image_effect_info
image_image_effect_info()
Definition: image.effects.inc:11
image_scale_effect
image_scale_effect(&$image, $data)
Definition: image.effects.inc:124
image_filter_keyword
image_filter_keyword($value, $current_pixels, $new_pixels)
Definition: image.module:1370
image_desaturate
image_desaturate(stdClass $image)
Definition: image.inc:354
image_resize_dimensions
image_resize_dimensions(array &$dimensions, array $data)
Definition: image.effects.inc:100
image_scale_dimensions
image_scale_dimensions(array &$dimensions, array $data)
Definition: image.effects.inc:153
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search-result.tpl.php Source File

  • modules
  • search
search-result.tpl.php
Go to the documentation of this file.
1 <?php
2
66 ?>
67 <li class="<?php print $classes; ?>"<?php print $attributes; ?>>
68 <?php print render($title_prefix); ?>
69 <h3 class="title"<?php print $title_attributes; ?>>
70 <a href="<?php print $url; ?>"><?php print $title; ?></a>
71 </h3>
72 <?php print render($title_suffix); ?>
73 <div class="search-snippet-info">
74 <?php if ($snippet): ?>
75 <p class="search-snippet"<?php print $content_attributes; ?>><?php print $snippet; ?></p>
76 <?php endif; ?>
77 <?php if ($info): ?>
78 <p class="search-info"><?php print $info; ?></p>
79 <?php endif; ?>
80 </div>
81 </li>
$snippet
if($snippet) print $snippet
Definition: search-result.tpl.php:74
$attributes
print $attributes
Definition: block.tpl.php:47
print
print
Definition: php-2.php:2
$content_attributes
print $content_attributes
Definition: block.tpl.php:55
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
$info
$info
Definition: color.inc:6
endif
endif
Definition: aggregator-item.tpl.php:31
render
render(&$element)
Definition: common.inc:5988
$title_attributes
print $title_attributes
Definition: comment.tpl.php:70
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/path.inc Source File

  • includes
path.inc
Go to the documentation of this file.
1 <?php
2
15 function drupal_path_initialize() {
16 // Ensure $_GET['q'] is set before calling drupal_normal_path(), to support
17 // path caching with hook_url_inbound_alter().
18 if (empty($_GET['q'])) {
19 $_GET['q'] = variable_get('site_frontpage', 'node');
20 }
21 $_GET['q'] = drupal_get_normal_path($_GET['q']);
22 }
23
45 function drupal_lookup_path($action, $path = '', $path_language = NULL) {
46 global $language_url;
47 // Use the advanced drupal_static() pattern, since this is called very often.
48 static $drupal_static_fast;
49 if (!isset($drupal_static_fast)) {
50 $drupal_static_fast['cache'] = &drupal_static(__FUNCTION__);
51 }
52 $cache = &$drupal_static_fast['cache'];
53
54 if (!isset($cache)) {
55 $cache = array(
56 'map' => array(),
57 'no_source' => array(),
58 'whitelist' => NULL,
59 'system_paths' => array(),
60 'no_aliases' => array(),
61 'first_call' => TRUE,
62 );
63 }
64
65 // Retrieve the path alias whitelist.
66 if (!isset($cache['whitelist'])) {
67 $cache['whitelist'] = variable_get('path_alias_whitelist', NULL);
68 if (!isset($cache['whitelist'])) {
69 $cache['whitelist'] = drupal_path_alias_whitelist_rebuild();
70 }
71 }
72
73 // If no language is explicitly specified we default to the current URL
74 // language. If we used a language different from the one conveyed by the
75 // requested URL, we might end up being unable to check if there is a path
76 // alias matching the URL path.
77 $path_language = $path_language ? $path_language : $language_url->language;
78
79 if ($action == 'wipe') {
80 $cache = array();
81 $cache['whitelist'] = drupal_path_alias_whitelist_rebuild();
82 }
83 elseif ($cache['whitelist'] && $path != '') {
84 if ($action == 'alias') {
85 // During the first call to drupal_lookup_path() per language, load the
86 // expected system paths for the page from cache.
87 if (!empty($cache['first_call'])) {
88 $cache['first_call'] = FALSE;
89
90 $cache['map'][$path_language] = array();
91 // Load system paths from cache.
92 $cid = current_path();
93 if ($cached = cache_get($cid, 'cache_path')) {
94 $cache['system_paths'] = $cached->data;
95 // Now fetch the aliases corresponding to these system paths.
96 $args = array(
97 ':system' => $cache['system_paths'],
98 ':language' => $path_language,
99 ':language_none' => LANGUAGE_NONE,
100 );
101 // Always get the language-specific alias before the language-neutral
102 // one. For example 'de' is less than 'und' so the order needs to be
103 // ASC, while 'xx-lolspeak' is more than 'und' so the order needs to
104 // be DESC. We also order by pid ASC so that fetchAllKeyed() returns
105 // the most recently created alias for each source. Subsequent queries
106 // using fetchField() must use pid DESC to have the same effect.
107 // For performance reasons, the query builder is not used here.
108 if ($path_language == LANGUAGE_NONE) {
109 // Prevent PDO from complaining about a token the query doesn't use.
110 unset($args[':language']);
111 $result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language = :language_none ORDER BY pid ASC', $args);
112 }
113 elseif ($path_language < LANGUAGE_NONE) {
114 $result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language IN (:language, :language_none) ORDER BY language ASC, pid ASC', $args);
115 }
116 else {
117 $result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language IN (:language, :language_none) ORDER BY language DESC, pid ASC', $args);
118 }
119 $cache['map'][$path_language] = $result->fetchAllKeyed();
120 // Keep a record of paths with no alias to avoid querying twice.
121 $cache['no_aliases'][$path_language] = array_flip(array_diff_key($cache['system_paths'], array_keys($cache['map'][$path_language])));
122 }
123 }
124 // If the alias has already been loaded, return it.
125 if (isset($cache['map'][$path_language][$path])) {
126 return $cache['map'][$path_language][$path];
127 }
128 // Check the path whitelist, if the top_level part before the first /
129 // is not in the list, then there is no need to do anything further,
130 // it is not in the database.
131 elseif (!isset($cache['whitelist'][strtok($path, '/')])) {
132 return FALSE;
133 }
134 // For system paths which were not cached, query aliases individually.
135 elseif (!isset($cache['no_aliases'][$path_language][$path])) {
136 $args = array(
137 ':source' => $path,
138 ':language' => $path_language,
139 ':language_none' => LANGUAGE_NONE,
140 );
141 // See the queries above.
142 if ($path_language == LANGUAGE_NONE) {
143 unset($args[':language']);
144 $alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language = :language_none ORDER BY pid DESC", $args)->fetchField();
145 }
146 elseif ($path_language > LANGUAGE_NONE) {
147 $alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", $args)->fetchField();
148 }
149 else {
150 $alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language IN (:language, :language_none) ORDER BY language ASC, pid DESC", $args)->fetchField();
151 }
152 $cache['map'][$path_language][$path] = $alias;
153 return $alias;
154 }
155 }
156 // Check $no_source for this $path in case we've already determined that there
157 // isn't a path that has this alias
158 elseif ($action == 'source' && !isset($cache['no_source'][$path_language][$path])) {
159 // Look for the value $path within the cached $map
160 $source = FALSE;
161 if (!isset($cache['map'][$path_language]) || !($source = array_search($path, $cache['map'][$path_language]))) {
162 $args = array(
163 ':alias' => $path,
164 ':language' => $path_language,
165 ':language_none' => LANGUAGE_NONE,
166 );
167 // See the queries above.
168 if ($path_language == LANGUAGE_NONE) {
169 unset($args[':language']);
170 $result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language = :language_none ORDER BY pid DESC", $args);
171 }
172 elseif ($path_language > LANGUAGE_NONE) {
173 $result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", $args);
174 }
175 else {
176 $result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, :language_none) ORDER BY language ASC, pid DESC", $args);
177 }
178 if ($source = $result->fetchField()) {
179 $cache['map'][$path_language][$source] = $path;
180 }
181 else {
182 // We can't record anything into $map because we do not have a valid
183 // index and there is no need because we have not learned anything
184 // about any Drupal path. Thus cache to $no_source.
185 $cache['no_source'][$path_language][$path] = TRUE;
186 }
187 }
188 return $source;
189 }
190 }
191
192 return FALSE;
193 }
194
203 function drupal_cache_system_paths() {
204 // Check if the system paths for this page were loaded from cache in this
205 // request to avoid writing to cache on every request.
206 $cache = &drupal_static('drupal_lookup_path', array());
207 if (empty($cache['system_paths']) && !empty($cache['map'])) {
208 // Generate a cache ID (cid) specifically for this page.
209 $cid = current_path();
210 // The static $map array used by drupal_lookup_path() includes all
211 // system paths for the page request.
212 if ($paths = current($cache['map'])) {
213 $data = array_keys($paths);
214 $expire = REQUEST_TIME + (60 * 60 * 24);
215 cache_set($cid, $data, 'cache_path', $expire);
216 }
217 }
218 }
219
235 function drupal_get_path_alias($path = NULL, $path_language = NULL) {
236 // If no path is specified, use the current page's path.
237 if ($path == NULL) {
238 $path = $_GET['q'];
239 }
240 $result = $path;
241 if ($alias = drupal_lookup_path('alias', $path, $path_language)) {
242 $result = $alias;
243 }
244 return $result;
245 }
246
259 function drupal_get_normal_path($path, $path_language = NULL) {
260 $original_path = $path;
261
262 // Lookup the path alias first.
263 if ($source = drupal_lookup_path('source', $path, $path_language)) {
264 $path = $source;
265 }
266
267 // Allow other modules to alter the inbound URL. We cannot use drupal_alter()
268 // here because we need to run hook_url_inbound_alter() in the reverse order
269 // of hook_url_outbound_alter().
270 foreach (array_reverse(module_implements('url_inbound_alter')) as $module) {
271 $function = $module . '_url_inbound_alter';
272 $function($path, $original_path, $path_language);
273 }
274
275 return $path;
276 }
277
284 function drupal_is_front_page() {
285 // Use the advanced drupal_static() pattern, since this is called very often.
286 static $drupal_static_fast;
287 if (!isset($drupal_static_fast)) {
288 $drupal_static_fast['is_front_page'] = &drupal_static(__FUNCTION__);
289 }
290 $is_front_page = &$drupal_static_fast['is_front_page'];
291
292 if (!isset($is_front_page)) {
293 // As drupal_path_initialize updates $_GET['q'] with the 'site_frontpage' path,
294 // we can check it against the 'site_frontpage' variable.
295 $is_front_page = ($_GET['q'] == variable_get('site_frontpage', 'node'));
296 }
297
298 return $is_front_page;
299 }
300
312 function drupal_match_path($path, $patterns) {
313 $regexps = &drupal_static(__FUNCTION__);
314
315 if (!isset($regexps[$patterns])) {
316 // Convert path settings to a regular expression.
317 // Therefore replace newlines with a logical or, /* with asterisks and the <front> with the frontpage.
318 $to_replace = array(
319 '/(\r\n?|\n)/', // newlines
320 '/\\\\\*/', // asterisks
321 '/(^|\|)\\\\<front\\\\>($|\|)/' // <front>
322 );
323 $replacements = array(
324 '|',
325 '.*',
326 '\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\2'
327 );
328 $patterns_quoted = preg_quote($patterns, '/');
329 $regexps[$patterns] = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
330 }
331 return (bool)preg_match($regexps[$patterns], $path);
332 }
333
354 function current_path() {
355 return $_GET['q'];
356 }
357
367 function drupal_path_alias_whitelist_rebuild($source = NULL) {
368 // When paths are inserted, only rebuild the whitelist if the system path
369 // has a top level component which is not already in the whitelist.
370 if (!empty($source)) {
371 $whitelist = variable_get('path_alias_whitelist', NULL);
372 if (isset($whitelist[strtok($source, '/')])) {
373 return $whitelist;
374 }
375 }
376 // For each alias in the database, get the top level component of the system
377 // path it corresponds to. This is the portion of the path before the first
378 // '/', if present, otherwise the whole path itself.
379 $whitelist = array();
380 $result = db_query("SELECT DISTINCT SUBSTRING_INDEX(source, '/', 1) AS path FROM {url_alias}");
381 foreach ($result as $row) {
382 $whitelist[$row->path] = TRUE;
383 }
384 variable_set('path_alias_whitelist', $whitelist);
385 return $whitelist;
386 }
387
403 function path_load($conditions) {
404 if (is_numeric($conditions)) {
405 $conditions = array('pid' => $conditions);
406 }
407 elseif (is_string($conditions)) {
408 $conditions = array('source' => $conditions);
409 }
410 elseif (!is_array($conditions)) {
411 return FALSE;
412 }
413 $select = db_select('url_alias');
414 foreach ($conditions as $field => $value) {
415 $select->condition($field, $value);
416 }
417 return $select
418 ->fields('url_alias')
419 ->execute()
420 ->fetchAssoc();
421 }
422
433 function path_save(&$path) {
434 $path += array('language' => LANGUAGE_NONE);
435
436 // Load the stored alias, if any.
437 if (!empty($path['pid']) && !isset($path['original'])) {
438 $path['original'] = path_load($path['pid']);
439 }
440
441 if (empty($path['pid'])) {
442 drupal_write_record('url_alias', $path);
443 module_invoke_all('path_insert', $path);
444 }
445 else {
446 drupal_write_record('url_alias', $path, array('pid'));
447 module_invoke_all('path_update', $path);
448 }
449
450 // Clear internal properties.
451 unset($path['original']);
452
453 // Clear the static alias cache.
454 drupal_clear_path_cache($path['source']);
455 }
456
463 function path_delete($criteria) {
464 if (!is_array($criteria)) {
465 $criteria = array('pid' => $criteria);
466 }
467 $path = path_load($criteria);
468 $query = db_delete('url_alias');
469 foreach ($criteria as $field => $value) {
470 $query->condition($field, $value);
471 }
472 $query->execute();
473 module_invoke_all('path_delete', $path);
474 drupal_clear_path_cache($path['source']);
475 }
476
495 function path_is_admin($path) {
496 $path_map = &drupal_static(__FUNCTION__);
497 if (!isset($path_map['admin'][$path])) {
498 $patterns = path_get_admin_paths();
499 $path_map['admin'][$path] = drupal_match_path($path, $patterns['admin']);
500 $path_map['non_admin'][$path] = drupal_match_path($path, $patterns['non_admin']);
501 }
502 return $path_map['admin'][$path] && !$path_map['non_admin'][$path];
503 }
504
517 function path_get_admin_paths() {
518 $patterns = &drupal_static(__FUNCTION__);
519 if (!isset($patterns)) {
520 $paths = module_invoke_all('admin_paths');
521 drupal_alter('admin_paths', $paths);
522 // Combine all admin paths into one array, and likewise for non-admin paths,
523 // for easier handling.
524 $patterns = array();
525 $patterns['admin'] = array();
526 $patterns['non_admin'] = array();
527 foreach ($paths as $path => $enabled) {
528 if ($enabled) {
529 $patterns['admin'][] = $path;
530 }
531 else {
532 $patterns['non_admin'][] = $path;
533 }
534 }
535 $patterns['admin'] = implode("\n", $patterns['admin']);
536 $patterns['non_admin'] = implode("\n", $patterns['non_admin']);
537 }
538 return $patterns;
539 }
540
553 function drupal_valid_path($path, $dynamic_allowed = FALSE) {
554 global $menu_admin;
555 // We indicate that a menu administrator is running the menu access check.
556 $menu_admin = TRUE;
557 if ($path == '<front>' || url_is_external($path)) {
558 $item = array('access' => TRUE);
559 }
560 elseif ($dynamic_allowed && preg_match('/\/\%/', $path)) {
561 // Path is dynamic (ie 'user/%'), so check directly against menu_router table.
562 if ($item = db_query("SELECT * FROM {menu_router} where path = :path", array(':path' => $path))->fetchAssoc()) {
563 $item['link_path'] = $form_item['link_path'];
564 $item['link_title'] = $form_item['link_title'];
565 $item['external'] = FALSE;
566 $item['options'] = '';
567 _menu_link_translate($item);
568 }
569 }
570 else {
571 $item = menu_get_item($path);
572 }
573 $menu_admin = FALSE;
574 return $item && $item['access'];
575 }
576
583 function drupal_clear_path_cache($source = NULL) {
584 // Clear the drupal_lookup_path() static cache.
585 drupal_static_reset('drupal_lookup_path');
586 drupal_path_alias_whitelist_rebuild($source);
587 }
drupal_cache_system_paths
drupal_cache_system_paths()
Definition: path.inc:203
drupal_is_front_page
drupal_is_front_page()
Definition: path.inc:284
url_is_external
url_is_external($path)
Definition: common.inc:2311
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
menu_get_item
menu_get_item($path=NULL, $router_item=NULL)
Definition: menu.inc:447
path_get_admin_paths
path_get_admin_paths()
Definition: path.inc:517
drupal_valid_path
drupal_valid_path($path, $dynamic_allowed=FALSE)
Definition: path.inc:553
path_load
path_load($conditions)
Definition: path.inc:403
$module
print $module
Definition: search-results.tpl.php:28
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
path_is_admin
path_is_admin($path)
Definition: path.inc:495
_menu_link_translate
_menu_link_translate(&$item, $translate=FALSE)
Definition: menu.inc:870
drupal_clear_path_cache
drupal_clear_path_cache($source=NULL)
Definition: path.inc:583
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
drupal_get_path_alias
drupal_get_path_alias($path=NULL, $path_language=NULL)
Definition: path.inc:235
path_delete
path_delete($criteria)
Definition: path.inc:463
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_get_normal_path
drupal_get_normal_path($path, $path_language=NULL)
Definition: path.inc:259
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
path_save
path_save(&$path)
Definition: path.inc:433
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
drupal_lookup_path
drupal_lookup_path($action, $path= '', $path_language=NULL)
Definition: path.inc:45
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_match_path
drupal_match_path($path, $patterns)
Definition: path.inc:312
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
drupal_path_initialize
drupal_path_initialize()
Definition: path.inc:15
$row
$row
Definition: block-admin-display-form.tpl.php:47
drupal_path_alias_whitelist_rebuild
drupal_path_alias_whitelist_rebuild($source=NULL)
Definition: path.inc:367
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
current_path
current_path()
Definition: path.inc:354
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search-block-form.tpl.php Source File

  • modules
  • search
search-block-form.tpl.php
Go to the documentation of this file.
1 <?php
2
31 ?>
32 <div class="container-inline">
33 <?php if (empty($variables['form']['#block']->subject)): ?>
34 <h2 class="element-invisible"><?php print t('Search form'); ?></h2>
35 <?php endif; ?>
36 <?php print $search_form; ?>
37 </div>
$search_form
print $search_form
Definition: search-block-form.tpl.php:36
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
endif
endif
Definition: aggregator-item.tpl.php:31
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/filter/filter.admin.inc Source File

  • modules
  • filter
filter.admin.inc
Go to the documentation of this file.
1 <?php
2
15 function filter_admin_overview($form) {
16 // Overview of all formats.
17 $formats = filter_formats();
18 $fallback_format = filter_fallback_format();
19
20 $form['#tree'] = TRUE;
21 foreach ($formats as $id => $format) {
22 // Check whether this is the fallback text format. This format is available
23 // to all roles and cannot be disabled via the admin interface.
24 $form['formats'][$id]['#is_fallback'] = ($id == $fallback_format);
25 if ($form['formats'][$id]['#is_fallback']) {
26 $form['formats'][$id]['name'] = array('#markup' => drupal_placeholder($format->name));
27 $roles_markup = drupal_placeholder(t('All roles may use this format'));
28 }
29 else {
30 $form['formats'][$id]['name'] = array('#markup' => check_plain($format->name));
31 $roles = array_map('check_plain', filter_get_roles_by_format($format));
32 $roles_markup = $roles ? implode(', ', $roles) : t('No roles may use this format');
33 }
34 $form['formats'][$id]['roles'] = array('#markup' => $roles_markup);
35 $form['formats'][$id]['configure'] = array('#type' => 'link', '#title' => t('configure'), '#href' => 'admin/config/content/formats/' . $id);
36 $form['formats'][$id]['disable'] = array('#type' => 'link', '#title' => t('disable'), '#href' => 'admin/config/content/formats/' . $id . '/disable', '#access' => !$form['formats'][$id]['#is_fallback']);
37 $form['formats'][$id]['weight'] = array(
38 '#type' => 'weight',
39 '#title' => t('Weight for @title', array('@title' => $format->name)),
40 '#title_display' => 'invisible',
41 '#default_value' => $format->weight,
42 );
43 }
44 $form['actions'] = array('#type' => 'actions');
45 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save changes'));
46 return $form;
47 }
48
52 function filter_admin_overview_submit($form, &$form_state) {
53 foreach ($form_state['values']['formats'] as $id => $data) {
54 if (is_array($data) && isset($data['weight'])) {
55 // Only update if this is a form element with weight.
56 db_update('filter_format')
57 ->fields(array('weight' => $data['weight']))
58 ->condition('format', $id)
59 ->execute();
60 }
61 }
62 filter_formats_reset();
63 drupal_set_message(t('The text format ordering has been saved.'));
64 }
65
75 function theme_filter_admin_overview($variables) {
76 $form = $variables['form'];
77
78 $rows = array();
79 foreach (element_children($form['formats']) as $id) {
80 $form['formats'][$id]['weight']['#attributes']['class'] = array('text-format-order-weight');
81 $rows[] = array(
82 'data' => array(
83 drupal_render($form['formats'][$id]['name']),
84 drupal_render($form['formats'][$id]['roles']),
85 drupal_render($form['formats'][$id]['weight']),
86 drupal_render($form['formats'][$id]['configure']),
87 drupal_render($form['formats'][$id]['disable']),
88 ),
89 'class' => array('draggable'),
90 );
91 }
92 $header = array(t('Name'), t('Roles'), t('Weight'), array('data' => t('Operations'), 'colspan' => 2));
93 $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'text-format-order')));
94 $output .= drupal_render_children($form);
95
96 drupal_add_tabledrag('text-format-order', 'order', 'sibling', 'text-format-order-weight');
97
98 return $output;
99 }
100
123 function filter_admin_format_page($format = NULL) {
124 if (!isset($format->name)) {
125 drupal_set_title(t('Add text format'));
126 $format = (object) array(
127 'format' => NULL,
128 'name' => '',
129 );
130 }
131 return drupal_get_form('filter_admin_format_form', $format);
132 }
133
154 function filter_admin_format_form($form, &$form_state, $format) {
155 $is_fallback = ($format->format == filter_fallback_format());
156
157 $form['#format'] = $format;
158 $form['#tree'] = TRUE;
159 $form['#attached']['js'][] = drupal_get_path('module', 'filter') . '/filter.admin.js';
160 $form['#attached']['css'][] = drupal_get_path('module', 'filter') . '/filter.css';
161
162 $form['name'] = array(
163 '#type' => 'textfield',
164 '#title' => t('Name'),
165 '#default_value' => $format->name,
166 '#required' => TRUE,
167 );
168 $form['format'] = array(
169 '#type' => 'machine_name',
170 '#required' => TRUE,
171 '#default_value' => $format->format,
172 '#maxlength' => 255,
173 '#machine_name' => array(
174 'exists' => 'filter_format_exists',
175 ),
176 '#disabled' => !empty($format->format),
177 );
178
179 // Add user role access selection.
180 $form['roles'] = array(
181 '#type' => 'checkboxes',
182 '#title' => t('Roles'),
183 '#options' => array_map('check_plain', user_roles()),
184 '#disabled' => $is_fallback,
185 );
186 if ($is_fallback) {
187 $form['roles']['#description'] = t('All roles for this text format must be enabled and cannot be changed.');
188 }
189 if (!empty($format->format)) {
190 // If editing an existing text format, pre-select its current permissions.
191 $form['roles']['#default_value'] = array_keys(filter_get_roles_by_format($format));
192 }
193 elseif ($admin_role = variable_get('user_admin_role', 0)) {
194 // If adding a new text format and the site has an administrative role,
195 // pre-select that role so as to grant administrators access to the new
196 // text format permission by default.
197 $form['roles']['#default_value'] = array($admin_role);
198 }
199
200 // Retrieve available filters and load all configured filters for existing
201 // text formats.
202 $filter_info = filter_get_filters();
203 $filters = !empty($format->format) ? filter_list_format($format->format) : array();
204
205 // Prepare filters for form sections.
206 foreach ($filter_info as $name => $filter) {
207 // Create an empty filter object for new/unconfigured filters.
208 if (!isset($filters[$name])) {
209 $filters[$name] = new stdClass();
210 $filters[$name]->format = $format->format;
211 $filters[$name]->module = $filter['module'];
212 $filters[$name]->name = $name;
213 $filters[$name]->status = 0;
214 $filters[$name]->weight = $filter['weight'];
215 $filters[$name]->settings = array();
216 }
217 }
218 $form['#filters'] = $filters;
219
220 // Filter status.
221 $form['filters']['status'] = array(
222 '#type' => 'item',
223 '#title' => t('Enabled filters'),
224 '#prefix' => '<div id="filters-status-wrapper">',
225 '#suffix' => '</div>',
226 );
227 foreach ($filter_info as $name => $filter) {
228 $form['filters']['status'][$name] = array(
229 '#type' => 'checkbox',
230 '#title' => $filter['title'],
231 '#default_value' => $filters[$name]->status,
232 '#parents' => array('filters', $name, 'status'),
233 '#description' => $filter['description'],
234 '#weight' => $filter['weight'],
235 );
236 }
237
238 // Filter order (tabledrag).
239 $form['filters']['order'] = array(
240 '#type' => 'item',
241 '#title' => t('Filter processing order'),
242 '#theme' => 'filter_admin_format_filter_order',
243 );
244 foreach ($filter_info as $name => $filter) {
245 $form['filters']['order'][$name]['filter'] = array(
246 '#markup' => $filter['title'],
247 );
248 $form['filters']['order'][$name]['weight'] = array(
249 '#type' => 'weight',
250 '#title' => t('Weight for @title', array('@title' => $filter['title'])),
251 '#title_display' => 'invisible',
252 '#delta' => 50,
253 '#default_value' => $filters[$name]->weight,
254 '#parents' => array('filters', $name, 'weight'),
255 );
256 $form['filters']['order'][$name]['#weight'] = $filters[$name]->weight;
257 }
258
259 // Filter settings.
260 $form['filter_settings_title'] = array(
261 '#type' => 'item',
262 '#title' => t('Filter settings'),
263 );
264 $form['filter_settings'] = array(
265 '#type' => 'vertical_tabs',
266 );
267
268 foreach ($filter_info as $name => $filter) {
269 if (isset($filter['settings callback']) && function_exists($filter['settings callback'])) {
270 $function = $filter['settings callback'];
271 // Pass along stored filter settings and default settings, but also the
272 // format object and all filters to allow for complex implementations.
273 $defaults = (isset($filter['default settings']) ? $filter['default settings'] : array());
274 $settings_form = $function($form, $form_state, $filters[$name], $format, $defaults, $filters);
275 if (!empty($settings_form)) {
276 $form['filters']['settings'][$name] = array(
277 '#type' => 'fieldset',
278 '#title' => $filter['title'],
279 '#parents' => array('filters', $name, 'settings'),
280 '#weight' => $filter['weight'],
281 '#group' => 'filter_settings',
282 );
283 $form['filters']['settings'][$name] += $settings_form;
284 }
285 }
286 }
287
288 $form['actions'] = array('#type' => 'actions');
289 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
290
291 return $form;
292 }
293
303 function theme_filter_admin_format_filter_order($variables) {
304 $element = $variables['element'];
305
306 // Filter order (tabledrag).
307 $rows = array();
308 foreach (element_children($element, TRUE) as $name) {
309 $element[$name]['weight']['#attributes']['class'][] = 'filter-order-weight';
310 $rows[] = array(
311 'data' => array(
312 drupal_render($element[$name]['filter']),
313 drupal_render($element[$name]['weight']),
314 ),
315 'class' => array('draggable'),
316 );
317 }
318 $output = drupal_render_children($element);
319 $output .= theme('table', array('rows' => $rows, 'attributes' => array('id' => 'filter-order')));
320 drupal_add_tabledrag('filter-order', 'order', 'sibling', 'filter-order-weight', NULL, NULL, TRUE);
321
322 return $output;
323 }
324
330 function filter_admin_format_form_validate($form, &$form_state) {
331 $format_format = trim($form_state['values']['format']);
332 $format_name = trim($form_state['values']['name']);
333
334 // Ensure that the values to be saved later are exactly the ones validated.
335 form_set_value($form['format'], $format_format, $form_state);
336 form_set_value($form['name'], $format_name, $form_state);
337
338 $result = db_query("SELECT format FROM {filter_format} WHERE name = :name AND format <> :format", array(':name' => $format_name, ':format' => $format_format))->fetchField();
339 if ($result) {
340 form_set_error('name', t('Text format names must be unique. A format named %name already exists.', array('%name' => $format_name)));
341 }
342 }
343
349 function filter_admin_format_form_submit($form, &$form_state) {
350 // Remove unnecessary values.
351 form_state_values_clean($form_state);
352
353 // Add the submitted form values to the text format, and save it.
354 $format = $form['#format'];
355 foreach ($form_state['values'] as $key => $value) {
356 $format->$key = $value;
357 }
358 $status = filter_format_save($format);
359
360 // Save user permissions.
361 if ($permission = filter_permission_name($format)) {
362 foreach ($format->roles as $rid => $enabled) {
363 user_role_change_permissions($rid, array($permission => $enabled));
364 }
365 }
366
367 switch ($status) {
368 case SAVED_NEW:
369 drupal_set_message(t('Added text format %format.', array('%format' => $format->name)));
370 break;
371
372 case SAVED_UPDATED:
373 drupal_set_message(t('The text format %format has been updated.', array('%format' => $format->name)));
374 break;
375 }
376 }
377
388 function filter_admin_disable($form, &$form_state, $format) {
389 $form['#format'] = $format;
390
391 return confirm_form($form,
392 t('Are you sure you want to disable the text format %format?', array('%format' => $format->name)),
393 'admin/config/content/formats',
394 t('Disabled text formats are completely removed from the administrative interface, and any content stored with that format will not be displayed. This action cannot be undone.'),
395 t('Disable')
396 );
397 }
398
402 function filter_admin_disable_submit($form, &$form_state) {
403 $format = $form['#format'];
404 filter_format_disable($format);
405 drupal_set_message(t('Disabled text format %format.', array('%format' => $format->name)));
406
407 $form_state['redirect'] = 'admin/config/content/formats';
408 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
filter_admin_disable
filter_admin_disable($form, &$form_state, $format)
Definition: filter.admin.inc:388
filter_admin_overview
filter_admin_overview($form)
Definition: filter.admin.inc:15
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
filter_format_disable
filter_format_disable($format)
Definition: filter.module:291
filter_get_filters
filter_get_filters()
Definition: filter.module:592
filter_permission_name
filter_permission_name($format)
Definition: filter.module:373
SAVED_UPDATED
const SAVED_UPDATED
Definition: common.inc:50
form_state_values_clean
form_state_values_clean(&$form_state)
Definition: form.inc:2159
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
$name
print $name
Definition: profile-listing.tpl.php:43
$header
print $header
Definition: forum-topic-list.tpl.php:42
user_roles
user_roles($membersonly=FALSE, $permission=NULL)
Definition: user.module:2871
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
filter_list_format
filter_list_format($format_id)
Definition: filter.module:691
filter_format_save
filter_format_save($format)
Definition: filter.module:198
filter_admin_disable_submit
filter_admin_disable_submit($form, &$form_state)
Definition: filter.admin.inc:402
filter_admin_format_form_submit
filter_admin_format_form_submit($form, &$form_state)
Definition: filter.admin.inc:349
filter_admin_format_page
filter_admin_format_page($format=NULL)
Definition: filter.admin.inc:123
filter_admin_format_form
filter_admin_format_form($form, &$form_state, $format)
Definition: filter.admin.inc:154
$value
print $value
Definition: user-profile-item.tpl.php:26
user_role_change_permissions
user_role_change_permissions($rid, array $permissions=array())
Definition: user.module:3076
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
$output
$output
Definition: authorize.php:93
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
SAVED_NEW
const SAVED_NEW
Definition: common.inc:45
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
filter_formats
filter_formats($account=NULL)
Definition: filter.module:412
filter_admin_format_form_validate
filter_admin_format_form_validate($form, &$form_state)
Definition: filter.admin.inc:330
drupal_placeholder
drupal_placeholder($text)
Definition: bootstrap.inc:3396
theme_filter_admin_format_filter_order
theme_filter_admin_format_filter_order($variables)
Definition: filter.admin.inc:303
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
filter_get_roles_by_format
filter_get_roles_by_format($format)
Definition: filter.module:468
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
filter_admin_overview_submit
filter_admin_overview_submit($form, &$form_state)
Definition: filter.admin.inc:52
theme_filter_admin_overview
theme_filter_admin_overview($variables)
Definition: filter.admin.inc:75
filter_formats_reset
filter_formats_reset()
Definition: filter.module:452
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
filter_fallback_format
filter_fallback_format()
Definition: filter.module:565
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalCacheInterface Member List

This is the complete list of members for DrupalCacheInterface, including all inherited members.

clear($cid=NULL, $wildcard=FALSE) | DrupalCacheInterface
get($cid) | DrupalCacheInterface
getMultiple(&$cids) | DrupalCacheInterface
isEmpty() | DrupalCacheInterface
set($cid, $data, $expire=CACHE_PERMANENT) | DrupalCacheInterface
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/page.tpl.php Source File

  • themes
  • garland
page.tpl.php
Go to the documentation of this file.
1 <?php
2 ?>
3 <?php print render($page['header']); ?>
4
5 <div id="wrapper">
6 <div id="container" class="clearfix">
7
8 <div id="header">
9 <div id="logo-floater">
10 <?php if ($logo || $site_title): ?>
11 <?php if ($title): ?>
12 <div id="branding"><strong><a href="<?php print $front_page ?>">
13 <?php if ($logo): ?>
14 <img src="<?php print $logo ?>" alt="<?php print $site_name_and_slogan ?>" title="<?php print $site_name_and_slogan ?>" id="logo" />
15 <?php endif; ?>
16 <?php print $site_html ?>
17 </a></strong></div>
18 <?php else: /* Use h1 when the content title is empty */ ?>
19 <h1 id="branding"><a href="<?php print $front_page ?>">
20 <?php if ($logo): ?>
21 <img src="<?php print $logo ?>" alt="<?php print $site_name_and_slogan ?>" title="<?php print $site_name_and_slogan ?>" id="logo" />
22 <?php endif; ?>
23 <?php print $site_html ?>
24 </a></h1>
25 <?php endif; ?>
26 <?php endif; ?>
27 </div>
28
29 <?php if ($primary_nav): print $primary_nav; endif; ?>
30 <?php if ($secondary_nav): print $secondary_nav; endif; ?>
31 </div> <!-- /#header -->
32
33 <?php if ($page['sidebar_first']): ?>
34 <div id="sidebar-first" class="sidebar">
35 <?php print render($page['sidebar_first']); ?>
36 </div>
37 <?php endif; ?>
38
39 <div id="center"><div id="squeeze"><div class="right-corner"><div class="left-corner">
40 <?php print $breadcrumb; ?>
41 <?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?>
42 <a id="main-content"></a>
43 <?php if ($tabs): ?><div id="tabs-wrapper" class="clearfix"><?php endif; ?>
44 <?php print render($title_prefix); ?>
45 <?php if ($title): ?>
46 <h1<?php print $tabs ? ' class="with-tabs"' : '' ?>><?php print $title ?></h1>
47 <?php endif; ?>
48 <?php print render($title_suffix); ?>
49 <?php if ($tabs): ?><?php print render($tabs); ?></div><?php endif; ?>
50 <?php print render($tabs2); ?>
51 <?php print $messages; ?>
52 <?php print render($page['help']); ?>
53 <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?>
54 <div class="clearfix">
55 <?php print render($page['content']); ?>
56 </div>
57 <?php print $feed_icons ?>
58 <?php print render($page['footer']); ?>
59 </div></div></div></div> <!-- /.left-corner, /.right-corner, /#squeeze, /#center -->
60
61 <?php if ($page['sidebar_second']): ?>
62 <div id="sidebar-second" class="sidebar">
63 <?php print render($page['sidebar_second']); ?>
64 </div>
65 <?php endif; ?>
66
67 </div> <!-- /#container -->
68 </div> <!-- /#wrapper -->
$page
print $page
Definition: overlay.tpl.php:37
print
print
Definition: php-2.php:2
$feed_icons
print $feed_icons
Definition: page.tpl.php:135
$logo
print $logo
Definition: maintenance-page.tpl.php:33
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
$site_html
if($site_fields) $site_html
Definition: maintenance-page.tpl.php:46
endif
endif
Definition: aggregator-item.tpl.php:31
$messages
print $messages
Definition: page.tpl.php:121
$site_title
if($site_name) if($site_slogan) $site_title
Definition: maintenance-page.tpl.php:42
render
render(&$element)
Definition: common.inc:5988
$breadcrumb
print $breadcrumb
Definition: page.tpl.php:40
title
print $topic title
Definition: forum-topic-list.tpl.php:50
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.info.class.inc Source File

  • modules
  • field
field.info.class.inc
Go to the documentation of this file.
1 <?php
2
3 /*
4 * @file
5 * Definition of the FieldInfo class.
6 */
7
29 class FieldInfo {
30
36 protected $fieldMap;
37
43 protected $fieldsById = array();
44
50 protected $fieldIdsByName = array();
51
57 protected $loadedAllFields = FALSE;
58
64 protected $unknownFields = array();
65
71 protected $bundleInstances = array();
72
78 protected $loadedAllInstances = FALSE;
79
85 protected $emptyBundles = array();
86
92 protected $bundleExtraFields = array();
93
97 public function flush() {
98 $this->fieldMap = NULL;
99
100 $this->fieldsById = array();
101 $this->fieldIdsByName = array();
102 $this->loadedAllFields = FALSE;
103 $this->unknownFields = array();
104
105 $this->bundleInstances = array();
106 $this->loadedAllInstances = FALSE;
107 $this->emptyBundles = array();
108
109 $this->bundleExtraFields = array();
110
111 cache_clear_all('field_info:', 'cache_field', TRUE);
112 }
113
123 public function getFieldMap() {
124 // Read from the "static" cache.
125 if ($this->fieldMap !== NULL) {
126 return $this->fieldMap;
127 }
128
129 // Read from persistent cache.
130 if ($cached = cache_get('field_info:field_map', 'cache_field')) {
131 $map = $cached->data;
132
133 // Save in "static" cache.
134 $this->fieldMap = $map;
135
136 return $map;
137 }
138
139 $map = array();
140
141 $query = db_query('SELECT fc.type, fci.field_name, fci.entity_type, fci.bundle FROM {field_config_instance} fci INNER JOIN {field_config} fc ON fc.id = fci.field_id WHERE fc.active = 1 AND fc.storage_active = 1 AND fc.deleted = 0 AND fci.deleted = 0');
142 foreach ($query as $row) {
143 $map[$row->field_name]['bundles'][$row->entity_type][] = $row->bundle;
144 $map[$row->field_name]['type'] = $row->type;
145 }
146
147 // Save in "static" and persistent caches.
148 $this->fieldMap = $map;
149 cache_set('field_info:field_map', $map, 'cache_field');
150
151 return $map;
152 }
153
160 public function getFields() {
161 // Read from the "static" cache.
162 if ($this->loadedAllFields) {
163 return $this->fieldsById;
164 }
165
166 // Read from persistent cache.
167 if ($cached = cache_get('field_info:fields', 'cache_field')) {
168 $this->fieldsById = $cached->data;
169 }
170 else {
171 // Collect and prepare fields.
172 foreach (field_read_fields(array(), array('include_deleted' => TRUE)) as $field) {
173 $this->fieldsById[$field['id']] = $this->prepareField($field);
174 }
175
176 // Store in persistent cache.
177 cache_set('field_info:fields', $this->fieldsById, 'cache_field');
178 }
179
180 // Fill the name/ID map.
181 foreach ($this->fieldsById as $field) {
182 if (!$field['deleted']) {
183 $this->fieldIdsByName[$field['field_name']] = $field['id'];
184 }
185 }
186
187 $this->loadedAllFields = TRUE;
188
189 return $this->fieldsById;
190 }
191
203 public function getInstances($entity_type = NULL) {
204 // If the full list is not present in "static" cache yet.
205 if (!$this->loadedAllInstances) {
206
207 // Read from persistent cache.
208 if ($cached = cache_get('field_info:instances', 'cache_field')) {
209 $this->bundleInstances = $cached->data;
210 }
211 else {
212 // Collect and prepare instances.
213
214 // We also need to populate the static field cache, since it will not
215 // be set by subsequent getBundleInstances() calls.
216 $this->getFields();
217
218 // Initialize empty arrays for all existing entity types and bundles.
219 // This is not strictly needed, but is done to preserve the behavior of
220 // field_info_instances() before http://drupal.org/node/1915646.
221 foreach (field_info_bundles() as $existing_entity_type => $bundles) {
222 foreach ($bundles as $bundle => $bundle_info) {
223 $this->bundleInstances[$existing_entity_type][$bundle] = array();
224 }
225 }
226
227 foreach (field_read_instances() as $instance) {
228 $field = $this->getField($instance['field_name']);
229 $instance = $this->prepareInstance($instance, $field['type']);
230 $this->bundleInstances[$instance['entity_type']][$instance['bundle']][$instance['field_name']] = $instance;
231 }
232
233 // Store in persistent cache.
234 cache_set('field_info:instances', $this->bundleInstances, 'cache_field');
235 }
236
237 $this->loadedAllInstances = TRUE;
238 }
239
240 if (isset($entity_type)) {
241 return isset($this->bundleInstances[$entity_type]) ? $this->bundleInstances[$entity_type] : array();
242 }
243 else {
244 return $this->bundleInstances;
245 }
246 }
247
259 public function getField($field_name) {
260 // Read from the "static" cache.
261 if (isset($this->fieldIdsByName[$field_name])) {
262 $field_id = $this->fieldIdsByName[$field_name];
263 return $this->fieldsById[$field_id];
264 }
265 if (isset($this->unknownFields[$field_name])) {
266 return;
267 }
268
269 // Do not check the (large) persistent cache, but read the definition.
270
271 // Cache miss: read from definition.
272 if ($field = field_read_field($field_name)) {
273 $field = $this->prepareField($field);
274
275 // Save in the "static" cache.
276 $this->fieldsById[$field['id']] = $field;
277 $this->fieldIdsByName[$field['field_name']] = $field['id'];
278
279 return $field;
280 }
281 else {
282 $this->unknownFields[$field_name] = TRUE;
283 }
284 }
285
297 public function getFieldById($field_id) {
298 // Read from the "static" cache.
299 if (isset($this->fieldsById[$field_id])) {
300 return $this->fieldsById[$field_id];
301 }
302 if (isset($this->unknownFields[$field_id])) {
303 return;
304 }
305
306 // No persistent cache, fields are only persistently cached as part of a
307 // bundle.
308
309 // Cache miss: read from definition.
310 if ($fields = field_read_fields(array('id' => $field_id), array('include_deleted' => TRUE))) {
311 $field = current($fields);
312 $field = $this->prepareField($field);
313
314 // Store in the static cache.
315 $this->fieldsById[$field['id']] = $field;
316 if (!$field['deleted']) {
317 $this->fieldIdsByName[$field['field_name']] = $field['id'];
318 }
319
320 return $field;
321 }
322 else {
323 $this->unknownFields[$field_id] = TRUE;
324 }
325 }
326
341 public function getBundleInstances($entity_type, $bundle) {
342 // Read from the "static" cache.
343 if (isset($this->bundleInstances[$entity_type][$bundle])) {
344 return $this->bundleInstances[$entity_type][$bundle];
345 }
346 if (isset($this->emptyBundles[$entity_type][$bundle])) {
347 return array();
348 }
349
350 // Read from the persistent cache.
351 if ($cached = cache_get("field_info:bundle:$entity_type:$bundle", 'cache_field')) {
352 $info = $cached->data;
353
354 // Extract the field definitions and save them in the "static" cache.
355 foreach ($info['fields'] as $field) {
356 if (!isset($this->fieldsById[$field['id']])) {
357 $this->fieldsById[$field['id']] = $field;
358 if (!$field['deleted']) {
359 $this->fieldIdsByName[$field['field_name']] = $field['id'];
360 }
361 }
362 }
363 unset($info['fields']);
364
365 // Store the instance definitions in the "static" cache'. Empty (or
366 // non-existent) bundles are stored separately, so that they do not
367 // pollute the global list returned by getInstances().
368 if ($info['instances']) {
369 $this->bundleInstances[$entity_type][$bundle] = $info['instances'];
370 }
371 else {
372 $this->emptyBundles[$entity_type][$bundle] = TRUE;
373 }
374
375 return $info['instances'];
376 }
377
378 // Cache miss: collect from the definitions.
379
380 $instances = array();
381
382 // Collect the fields in the bundle.
383 $params = array('entity_type' => $entity_type, 'bundle' => $bundle);
384 $fields = field_read_fields($params);
385
386 // This iterates on non-deleted instances, so deleted fields are kept out of
387 // the persistent caches.
388 foreach (field_read_instances($params) as $instance) {
389 $field = $fields[$instance['field_name']];
390
391 $instance = $this->prepareInstance($instance, $field['type']);
392 $instances[$field['field_name']] = $instance;
393
394 // If the field is not in our global "static" list yet, add it.
395 if (!isset($this->fieldsById[$field['id']])) {
396 $field = $this->prepareField($field);
397
398 $this->fieldsById[$field['id']] = $field;
399 $this->fieldIdsByName[$field['field_name']] = $field['id'];
400 }
401 }
402
403 // Store in the 'static' cache'. Empty (or non-existent) bundles are stored
404 // separately, so that they do not pollute the global list returned by
405 // getInstances().
406 if ($instances) {
407 $this->bundleInstances[$entity_type][$bundle] = $instances;
408 }
409 else {
410 $this->emptyBundles[$entity_type][$bundle] = TRUE;
411 }
412
413 // The persistent cache additionally contains the definitions of the fields
414 // involved in the bundle.
415 $cache = array(
416 'instances' => $instances,
417 'fields' => array()
418 );
419 foreach ($instances as $instance) {
420 $cache['fields'][] = $this->fieldsById[$instance['field_id']];
421 }
422 cache_set("field_info:bundle:$entity_type:$bundle", $cache, 'cache_field');
423
424 return $instances;
425 }
426
438 public function getBundleExtraFields($entity_type, $bundle) {
439 // Read from the "static" cache.
440 if (isset($this->bundleExtraFields[$entity_type][$bundle])) {
441 return $this->bundleExtraFields[$entity_type][$bundle];
442 }
443
444 // Read from the persistent cache.
445 if ($cached = cache_get("field_info:bundle_extra:$entity_type:$bundle", 'cache_field')) {
446 $this->bundleExtraFields[$entity_type][$bundle] = $cached->data;
447 return $this->bundleExtraFields[$entity_type][$bundle];
448 }
449
450 // Cache miss: read from hook_field_extra_fields(). Note: given the current
451 // shape of the hook, we have no other way than collecting extra fields on
452 // all bundles.
453 $info = array();
454 $extra = module_invoke_all('field_extra_fields');
455 drupal_alter('field_extra_fields', $extra);
456 // Merge in saved settings.
457 if (isset($extra[$entity_type][$bundle])) {
458 $info = $this->prepareExtraFields($extra[$entity_type][$bundle], $entity_type, $bundle);
459 }
460
461 // Store in the 'static' and persistent caches.
462 $this->bundleExtraFields[$entity_type][$bundle] = $info;
463 cache_set("field_info:bundle_extra:$entity_type:$bundle", $info, 'cache_field');
464
465 return $this->bundleExtraFields[$entity_type][$bundle];
466 }
467
477 public function prepareField($field) {
478 // Make sure all expected field settings are present.
479 $field['settings'] += field_info_field_settings($field['type']);
480 $field['storage']['settings'] += field_info_storage_settings($field['storage']['type']);
481
482 // Add storage details.
483 $details = (array) module_invoke($field['storage']['module'], 'field_storage_details', $field);
484 drupal_alter('field_storage_details', $details, $field);
485 $field['storage']['details'] = $details;
486
487 // Populate the list of bundles using the field.
488 $field['bundles'] = array();
489 if (!$field['deleted']) {
490 $map = $this->getFieldMap();
491 if (isset($map[$field['field_name']])) {
492 $field['bundles'] = $map[$field['field_name']]['bundles'];
493 }
494 }
495
496 return $field;
497 }
498
510 public function prepareInstance($instance, $field_type) {
511 // Make sure all expected instance settings are present.
512 $instance['settings'] += field_info_instance_settings($field_type);
513
514 // Set a default value for the instance.
515 if (field_behaviors_widget('default value', $instance) == FIELD_BEHAVIOR_DEFAULT && !isset($instance['default_value'])) {
516 $instance['default_value'] = NULL;
517 }
518
519 // Prepare widget settings.
520 $instance['widget'] = $this->prepareInstanceWidget($instance['widget'], $field_type);
521
522 // Prepare display settings.
523 foreach ($instance['display'] as $view_mode => $display) {
524 $instance['display'][$view_mode] = $this->prepareInstanceDisplay($display, $field_type);
525 }
526
527 // Fall back to 'hidden' for view modes configured to use custom display
528 // settings, and for which the instance has no explicit settings.
529 $entity_info = entity_get_info($instance['entity_type']);
530 $view_modes = array_merge(array('default'), array_keys($entity_info['view modes']));
531 $view_mode_settings = field_view_mode_settings($instance['entity_type'], $instance['bundle']);
532 foreach ($view_modes as $view_mode) {
533 if ($view_mode == 'default' || !empty($view_mode_settings[$view_mode]['custom_settings'])) {
534 if (!isset($instance['display'][$view_mode])) {
535 $instance['display'][$view_mode] = array(
536 'type' => 'hidden',
537 'label' => 'above',
538 'settings' => array(),
539 'weight' => 0,
540 );
541 }
542 }
543 }
544
545 return $instance;
546 }
547
559 public function prepareInstanceWidget($widget, $field_type) {
560 $field_type_info = field_info_field_types($field_type);
561
562 // Fill in default values.
563 $widget += array(
564 'type' => $field_type_info['default_widget'],
565 'settings' => array(),
566 'weight' => 0,
567 );
568
569 $widget_type_info = field_info_widget_types($widget['type']);
570 // Fall back to default formatter if formatter type is not available.
571 if (!$widget_type_info) {
572 $widget['type'] = $field_type_info['default_widget'];
573 $widget_type_info = field_info_widget_types($widget['type']);
574 }
575 $widget['module'] = $widget_type_info['module'];
576 // Fill in default settings for the widget.
577 $widget['settings'] += field_info_widget_settings($widget['type']);
578
579 return $widget;
580 }
581
593 public function prepareInstanceDisplay($display, $field_type) {
594 $field_type_info = field_info_field_types($field_type);
595
596 // Fill in default values.
597 $display += array(
598 'label' => 'above',
599 'type' => $field_type_info['default_formatter'],
600 'settings' => array(),
601 'weight' => 0,
602 );
603 if ($display['type'] != 'hidden') {
604 $formatter_type_info = field_info_formatter_types($display['type']);
605 // Fall back to default formatter if formatter type is not available.
606 if (!$formatter_type_info) {
607 $display['type'] = $field_type_info['default_formatter'];
608 $formatter_type_info = field_info_formatter_types($display['type']);
609 }
610 $display['module'] = $formatter_type_info['module'];
611 // Fill in default settings for the formatter.
612 $display['settings'] += field_info_formatter_settings($display['type']);
613 }
614
615 return $display;
616 }
617
631 public function prepareExtraFields($extra_fields, $entity_type, $bundle) {
632 $entity_type_info = entity_get_info($entity_type);
633 $bundle_settings = field_bundle_settings($entity_type, $bundle);
634 $extra_fields += array('form' => array(), 'display' => array());
635
636 $result = array();
637 // Extra fields in forms.
638 foreach ($extra_fields['form'] as $name => $field_data) {
639 $settings = isset($bundle_settings['extra_fields']['form'][$name]) ? $bundle_settings['extra_fields']['form'][$name] : array();
640 if (isset($settings['weight'])) {
641 $field_data['weight'] = $settings['weight'];
642 }
643 $result['form'][$name] = $field_data;
644 }
645
646 // Extra fields in displayed entities.
647 $data = $extra_fields['display'];
648 foreach ($extra_fields['display'] as $name => $field_data) {
649 $settings = isset($bundle_settings['extra_fields']['display'][$name]) ? $bundle_settings['extra_fields']['display'][$name] : array();
650 $view_modes = array_merge(array('default'), array_keys($entity_type_info['view modes']));
651 foreach ($view_modes as $view_mode) {
652 if (isset($settings[$view_mode])) {
653 $field_data['display'][$view_mode] = $settings[$view_mode];
654 }
655 else {
656 $field_data['display'][$view_mode] = array(
657 'weight' => $field_data['weight'],
658 'visible' => TRUE,
659 );
660 }
661 }
662 unset($field_data['weight']);
663 $result['display'][$name] = $field_data;
664 }
665
666 return $result;
667 }
668 }
FieldInfo\$fieldsById
$fieldsById
Definition: field.info.class.inc:43
field_read_fields
field_read_fields($params=array(), $include_additional=array())
Definition: field.crud.inc:340
FieldInfo\$bundleInstances
$bundleInstances
Definition: field.info.class.inc:71
FieldInfo\prepareExtraFields
prepareExtraFields($extra_fields, $entity_type, $bundle)
Definition: field.info.class.inc:631
FieldInfo\getBundleExtraFields
getBundleExtraFields($entity_type, $bundle)
Definition: field.info.class.inc:438
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
FieldInfo\getFieldById
getFieldById($field_id)
Definition: field.info.class.inc:297
field_info_formatter_types
field_info_formatter_types($formatter_type=NULL)
Definition: field.info.inc:379
FieldInfo\getBundleInstances
getBundleInstances($entity_type, $bundle)
Definition: field.info.class.inc:341
FieldInfo\flush
flush()
Definition: field.info.class.inc:97
$name
print $name
Definition: profile-listing.tpl.php:43
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
FieldInfo\$fieldIdsByName
$fieldIdsByName
Definition: field.info.class.inc:50
field_read_instances
field_read_instances($params=array(), $include_additional=array())
Definition: field.crud.inc:713
FieldInfo\$loadedAllFields
$loadedAllFields
Definition: field.info.class.inc:57
FIELD_BEHAVIOR_DEFAULT
const FIELD_BEHAVIOR_DEFAULT
Definition: field.module:255
FieldInfo\$unknownFields
$unknownFields
Definition: field.info.class.inc:64
FieldInfo\getInstances
getInstances($entity_type=NULL)
Definition: field.info.class.inc:203
field_info_field_types
field_info_field_types($field_type=NULL)
Definition: field.info.inc:329
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
field_view_mode_settings
field_view_mode_settings($entity_type, $bundle)
Definition: field.module:617
field_behaviors_widget
field_behaviors_widget($op, $instance)
Definition: field.info.inc:313
FieldInfo\$emptyBundles
$emptyBundles
Definition: field.info.class.inc:85
$info
$info
Definition: color.inc:6
field_info_field_settings
field_info_field_settings($type)
Definition: field.info.inc:742
FieldInfo\$loadedAllInstances
$loadedAllInstances
Definition: field.info.class.inc:78
field_info_instance_settings
field_info_instance_settings($type)
Definition: field.info.inc:757
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
FieldInfo\getField
getField($field_name)
Definition: field.info.class.inc:259
FieldInfo\prepareField
prepareField($field)
Definition: field.info.class.inc:477
FieldInfo\$bundleExtraFields
$bundleExtraFields
Definition: field.info.class.inc:92
FieldInfo\$fieldMap
$fieldMap
Definition: field.info.class.inc:36
field_info_widget_settings
field_info_widget_settings($type)
Definition: field.info.inc:773
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
field_info_storage_settings
field_info_storage_settings($type)
Definition: field.info.inc:805
FieldInfo\prepareInstanceDisplay
prepareInstanceDisplay($display, $field_type)
Definition: field.info.class.inc:593
field_info_bundles
field_info_bundles($entity_type=NULL)
Definition: field.info.inc:428
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
$row
$row
Definition: block-admin-display-form.tpl.php:47
field_info_widget_types
field_info_widget_types($widget_type=NULL)
Definition: field.info.inc:354
field_info_formatter_settings
field_info_formatter_settings($type)
Definition: field.info.inc:789
field_bundle_settings
field_bundle_settings($entity_type, $bundle, $settings=NULL)
Definition: field.module:583
FieldInfo\prepareInstanceWidget
prepareInstanceWidget($widget, $field_type)
Definition: field.info.class.inc:559
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
FieldInfo\getFieldMap
getFieldMap()
Definition: field.info.class.inc:123
field_read_field
field_read_field($field_name, $include_additional=array())
Definition: field.crud.inc:315
FieldInfo\prepareInstance
prepareInstance($instance, $field_type)
Definition: field.info.class.inc:510
FieldInfo\getFields
getFields()
Definition: field.info.class.inc:160
FieldInfo
Definition: field.info.class.inc:29
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll.pages.inc Source File

  • modules
  • poll
poll.pages.inc
Go to the documentation of this file.
1 <?php
2
11 function poll_page() {
12 $polls_per_page = 15;
13
14 $count_select = db_select('node', 'n');
15 $count_select->addExpression('COUNT(*)', 'expression');
16 $count_select->join('poll', 'p', 'p.nid = n.nid');
17 $count_select->condition('n.status', 1);
18
19 // List all polls.
20 $select = db_select('node', 'n');
21 $select->join('poll', 'p', 'p.nid = n.nid');
22 $select->join('poll_choice', 'c', 'c.nid = n.nid');
23 $select->addExpression('SUM(c.chvotes)', 'votes');
24 $select = $select->fields('n', array('nid', 'title', 'created'))
25 ->fields('p', array('active'))
26 ->condition('n.status', 1)
27 ->orderBy('n.created', 'DESC')
28 ->groupBy('n.nid')
29 ->groupBy('n.title')
30 ->groupBy('p.active')
31 ->groupBy('n.created')
32 ->extend('PagerDefault')
33 ->limit($polls_per_page)
34 ->addTag('node_access');
35 $select->setCountQuery($count_select);
36 $queried_nodes = $select->execute()
37 ->fetchAllAssoc('nid');
38
39 $output = '<ul>';
40 foreach ($queried_nodes as $node) {
41 $output .= '<li>' . l($node->title, "node/$node->nid") . ' - ' . format_plural($node->votes, '1 vote', '@count votes') . ' - ' . ($node->active ? t('open') : t('closed')) . '</li>';
42 }
43 $output .= '</ul>';
44 $output .= theme('pager');
45 return $output;
46 }
47
51 function poll_votes($node) {
52 $votes_per_page = 20;
53 drupal_set_title($node->title);
54
55 $header[] = array('data' => t('Visitor'), 'field' => 'u.name');
56 $header[] = array('data' => t('Vote'), 'field' => 'pc.chtext');
57 $header[] = array('data' => t('Timestamp'), 'field' => 'pv.timestamp', 'sort' => 'desc');
58
59 $select = db_select('poll_vote', 'pv')->extend('PagerDefault')->extend('TableSort');
60 $select->join('poll_choice', 'pc', 'pv.chid = pc.chid');
61 $select->join('users', 'u', 'pv.uid = u.uid');
62 $queried_votes = $select
63 ->addTag('translatable')
64 ->fields('pv', array('chid', 'uid', 'hostname', 'timestamp', 'nid'))
65 ->fields('pc', array('chtext'))
66 ->fields('u', array('name'))
67 ->condition('pv.nid', $node->nid)
68 ->limit($votes_per_page)
69 ->orderByHeader($header)
70 ->execute();
71
72 $rows = array();
73 foreach ($queried_votes as $vote) {
74 $rows[] = array(
75 $vote->name ? theme('username', array('account' => $vote)) : check_plain($vote->hostname),
76 check_plain($vote->chtext),
77 format_date($vote->timestamp),
78 );
79 }
80 $build['poll_votes_table'] = array(
81 '#theme' => 'table',
82 '#header' => $header,
83 '#rows' => $rows,
84 '#prefix' => t('This table lists all the recorded votes for this poll. If anonymous users are allowed to vote, they will be identified by the IP address of the computer they used when they voted.'),
85 );
86 $build['poll_votes_pager'] = array('#theme' => 'pager');
87 return $build;
88 }
89
93 function poll_results($node) {
94 drupal_set_title($node->title);
95 $node->show_results = TRUE;
96 return node_show($node);
97 }
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
$header
print $header
Definition: forum-topic-list.tpl.php:42
poll_page
poll_page()
Definition: poll.pages.inc:11
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
$output
$output
Definition: authorize.php:93
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
poll_results
poll_results($node)
Definition: poll.pages.inc:93
poll_votes
poll_votes($node)
Definition: poll.pages.inc:51
node_show
node_show($node, $message=FALSE)
Definition: node.module:1464
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
$vote
print $vote
Definition: poll-vote.tpl.php:27
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
ArchiverZip Member List

This is the complete list of members for ArchiverZip, including all inherited members.

$zip | ArchiverZip | protected
__construct($file_path) | ArchiverZip |
add($file_path) | ArchiverZip |
extract($path, Array $files=array()) | ArchiverZip |
ArchiverInterface::extract($path, array $files=array()) | ArchiverInterface |
getArchive() | ArchiverZip |
listContents() | ArchiverZip |
remove($file_path) | ArchiverZip |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/registry.inc Source File

  • includes
registry.inc
Go to the documentation of this file.
1 <?php
2
21 function _registry_update() {
22
23 // The registry serves as a central autoloader for all classes, including
24 // the database query builders. However, the registry rebuild process
25 // requires write ability to the database, which means having access to the
26 // query builders that require the registry in order to be loaded. That
27 // causes a fatal race condition. Therefore we manually include the
28 // appropriate query builders for the currently active database before the
29 // registry rebuild process runs.
30 $connection_info = Database::getConnectionInfo();
31 $driver = $connection_info['default']['driver'];
32 require_once DRUPAL_ROOT . '/includes/database/query.inc';
33 require_once DRUPAL_ROOT . '/includes/database/select.inc';
34 require_once DRUPAL_ROOT . '/includes/database/' . $driver . '/query.inc';
35
36 // Get current list of modules and their files.
37 $modules = db_query("SELECT * FROM {system} WHERE type = 'module'")->fetchAll();
38 // Get the list of files we are going to parse.
39 $files = array();
40 foreach ($modules as &$module) {
41 $module->info = unserialize($module->info);
42 $dir = dirname($module->filename);
43
44 // Store the module directory for use in hook_registry_files_alter().
45 $module->dir = $dir;
46
47 if ($module->status) {
48 // Add files for enabled modules to the registry.
49 foreach ($module->info['files'] as $file) {
50 $files["$dir/$file"] = array('module' => $module->name, 'weight' => $module->weight);
51 }
52 }
53 }
54 foreach (file_scan_directory('includes', '/\.inc$/') as $filename => $file) {
55 $files["$filename"] = array('module' => '', 'weight' => 0);
56 }
57
58 $transaction = db_transaction();
59 try {
60 // Allow modules to manually modify the list of files before the registry
61 // parses them. The $modules array provides the .info file information, which
62 // includes the list of files registered to each module. Any files in the
63 // list can then be added to the list of files that the registry will parse,
64 // or modify attributes of a file.
65 drupal_alter('registry_files', $files, $modules);
66 foreach (registry_get_parsed_files() as $filename => $file) {
67 // Add the hash for those files we have already parsed.
68 if (isset($files[$filename])) {
69 $files[$filename]['hash'] = $file['hash'];
70 }
71 else {
72 // Flush the registry of resources in files that are no longer on disc
73 // or are in files that no installed modules require to be parsed.
74 db_delete('registry')
75 ->condition('filename', $filename)
76 ->execute();
77 db_delete('registry_file')
78 ->condition('filename', $filename)
79 ->execute();
80 }
81 }
82 $parsed_files = _registry_parse_files($files);
83
84 $unchanged_resources = array();
85 $lookup_cache = array();
86 if ($cache = cache_get('lookup_cache', 'cache_bootstrap')) {
87 $lookup_cache = $cache->data;
88 }
89 foreach ($lookup_cache as $key => $file) {
90 // If the file for this cached resource is carried over unchanged from
91 // the last registry build, then we can safely re-cache it.
92 if ($file && in_array($file, array_keys($files)) && !in_array($file, $parsed_files)) {
93 $unchanged_resources[$key] = $file;
94 }
95 }
96 module_implements('', FALSE, TRUE);
97 _registry_check_code(REGISTRY_RESET_LOOKUP_CACHE);
98 }
99 catch (Exception $e) {
100 $transaction->rollback();
101 watchdog_exception('registry', $e);
102 throw $e;
103 }
104
105 // We have some unchanged resources, warm up the cache - no need to pay
106 // for looking them up again.
107 if (count($unchanged_resources) > 0) {
108 cache_set('lookup_cache', $unchanged_resources, 'cache_bootstrap');
109 }
110 }
111
115 function registry_get_parsed_files() {
116 $files = array();
117 // We want the result as a keyed array.
118 $files = db_query("SELECT * FROM {registry_file}")->fetchAllAssoc('filename', PDO::FETCH_ASSOC);
119 return $files;
120 }
121
128 function _registry_parse_files($files) {
129 $parsed_files = array();
130 foreach ($files as $filename => $file) {
131 if (file_exists($filename)) {
132 $hash = hash_file('sha256', $filename);
133 if (empty($file['hash']) || $file['hash'] != $hash) {
134 $file['hash'] = $hash;
135 $parsed_files[$filename] = $file;
136 }
137 }
138 }
139 foreach ($parsed_files as $filename => $file) {
140 _registry_parse_file($filename, file_get_contents($filename), $file['module'], $file['weight']);
141 db_merge('registry_file')
142 ->key(array('filename' => $filename))
143 ->fields(array(
144 'hash' => $file['hash'],
145 ))
146 ->execute();
147 }
148 return array_keys($parsed_files);
149 }
150
163 function _registry_parse_file($filename, $contents, $module = '', $weight = 0) {
164 if (preg_match_all('/^\s*(?:abstract|final)?\s*(class|interface)\s+([a-zA-Z0-9_]+)/m', $contents, $matches)) {
165 foreach ($matches[2] as $key => $name) {
166 db_merge('registry')
167 ->key(array(
168 'name' => $name,
169 'type' => $matches[1][$key],
170 ))
171 ->fields(array(
172 'filename' => $filename,
173 'module' => $module,
174 'weight' => $weight,
175 ))
176 ->execute();
177 }
178 // Delete any resources for this file where the name is not in the list
179 // we just merged in.
180 db_delete('registry')
181 ->condition('filename', $filename)
182 ->condition('name', $matches[2], 'NOT IN')
183 ->execute();
184 }
185 }
186
watchdog_exception
watchdog_exception($type, Exception $exception, $message=NULL, $variables=array(), $severity=WATCHDOG_ERROR, $link=NULL)
Definition: bootstrap.inc:1654
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
file_scan_directory
file_scan_directory($dir, $mask, $options=array(), $depth=0)
Definition: file.inc:2058
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
$module
print $module
Definition: search-results.tpl.php:28
Database\getConnectionInfo
static getConnectionInfo($key= 'default')
Definition: database.inc:1593
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
Exception
$contents
print $contents
Definition: book-export-html.tpl.php:49
REGISTRY_RESET_LOOKUP_CACHE
const REGISTRY_RESET_LOOKUP_CACHE
Definition: bootstrap.inc:237
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
_registry_parse_files
_registry_parse_files($files)
Definition: registry.inc:128
_registry_update
_registry_update()
Definition: registry.inc:21
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
db_transaction
db_transaction($name=NULL, array $options=array())
Definition: database.inc:2535
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
_registry_parse_file
_registry_parse_file($filename, $contents, $module= '', $weight=0)
Definition: registry.inc:163
$dir
print $dir
Definition: book-export-html.tpl.php:22
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
_registry_check_code
_registry_check_code($type, $name=NULL)
Definition: bootstrap.inc:3103
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
registry_get_parsed_files
registry_get_parsed_files()
Definition: registry.inc:115
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalTemporaryStreamWrapper Member List

This is the complete list of members for DrupalTemporaryStreamWrapper, including all inherited members.

$context | DrupalLocalStreamWrapper |
$handle | DrupalLocalStreamWrapper |
$uri | DrupalLocalStreamWrapper | protected
chmod($mode) | DrupalLocalStreamWrapper |
dir_closedir() | DrupalLocalStreamWrapper |
dir_opendir($uri, $options) | DrupalLocalStreamWrapper |
dir_readdir() | DrupalLocalStreamWrapper |
dir_rewinddir() | DrupalLocalStreamWrapper |
dirname($uri=NULL) | DrupalLocalStreamWrapper |
getDirectoryPath() | DrupalTemporaryStreamWrapper |
getExternalUrl() | DrupalTemporaryStreamWrapper |
getLocalPath($uri=NULL) | DrupalLocalStreamWrapper | protected
getMimeType($uri, $mapping=NULL) | DrupalLocalStreamWrapper | static
getTarget($uri=NULL) | DrupalLocalStreamWrapper | protected
getUri() | DrupalLocalStreamWrapper |
mkdir($uri, $mode, $options) | DrupalLocalStreamWrapper |
realpath() | DrupalLocalStreamWrapper |
rename($from_uri, $to_uri) | DrupalLocalStreamWrapper |
rmdir($uri, $options) | DrupalLocalStreamWrapper |
setUri($uri) | DrupalLocalStreamWrapper |
stream_close() | DrupalLocalStreamWrapper |
stream_eof() | DrupalLocalStreamWrapper |
stream_flush() | DrupalLocalStreamWrapper |
stream_lock($operation) | DrupalLocalStreamWrapper |
stream_open($uri, $mode, $options, &$opened_path) | DrupalLocalStreamWrapper |
stream_read($count) | DrupalLocalStreamWrapper |
stream_seek($offset, $whence) | DrupalLocalStreamWrapper |
stream_stat() | DrupalLocalStreamWrapper |
stream_tell() | DrupalLocalStreamWrapper |
stream_write($data) | DrupalLocalStreamWrapper |
unlink($uri) | DrupalLocalStreamWrapper |
url_stat($uri, $flags) | DrupalLocalStreamWrapper |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
NodeController Member List

This is the complete list of members for NodeController, including all inherited members.

$cache | DrupalDefaultEntityController | protected
$entityCache | DrupalDefaultEntityController | protected
$entityInfo | DrupalDefaultEntityController | protected
$entityType | DrupalDefaultEntityController | protected
$hookLoadArguments | DrupalDefaultEntityController | protected
$idKey | DrupalDefaultEntityController | protected
$revisionKey | DrupalDefaultEntityController | protected
$revisionTable | DrupalDefaultEntityController | protected
__construct($entityType) | DrupalDefaultEntityController |
attachLoad(&$nodes, $revision_id=FALSE) | NodeController | protected
buildQuery($ids, $conditions=array(), $revision_id=FALSE) | NodeController | protected
cacheGet($ids, $conditions=array()) | DrupalDefaultEntityController | protected
cacheSet($entities) | DrupalDefaultEntityController | protected
load($ids=array(), $conditions=array()) | DrupalDefaultEntityController |
resetCache(array $ids=NULL) | DrupalDefaultEntityController |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalDefaultEntityController Member List

This is the complete list of members for DrupalDefaultEntityController, including all inherited members.

$cache | DrupalDefaultEntityController | protected
$entityCache | DrupalDefaultEntityController | protected
$entityInfo | DrupalDefaultEntityController | protected
$entityType | DrupalDefaultEntityController | protected
$hookLoadArguments | DrupalDefaultEntityController | protected
$idKey | DrupalDefaultEntityController | protected
$revisionKey | DrupalDefaultEntityController | protected
$revisionTable | DrupalDefaultEntityController | protected
__construct($entityType) | DrupalDefaultEntityController |
attachLoad(&$queried_entities, $revision_id=FALSE) | DrupalDefaultEntityController | protected
buildQuery($ids, $conditions=array(), $revision_id=FALSE) | DrupalDefaultEntityController | protected
cacheGet($ids, $conditions=array()) | DrupalDefaultEntityController | protected
cacheSet($entities) | DrupalDefaultEntityController | protected
load($ids=array(), $conditions=array()) | DrupalDefaultEntityController |
resetCache(array $ids=NULL) | DrupalDefaultEntityController |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/form_example/form_example_states.inc Source File

  • examples
  • form_example
form_example_states.inc
Go to the documentation of this file.
1 <?php
2
58 function form_example_states_form($form, &$form_state) {
59 $form['student_type'] = array(
60 '#type' => 'radios',
61 '#options' => array(
62 'high_school' => t('High School'),
63 'undergraduate' => t('Undergraduate'),
64 'graduate' => t('Graduate'),
65 ),
66 '#title' => t('What type of student are you?')
67 );
68 $form['high_school'] = array(
69 '#type' => 'fieldset',
70 '#title' => t('High School Information'),
71 // This #states rule says that the "high school" fieldset should only
72 // be shown if the "student_type" form element is set to "High School".
73 '#states' => array(
74 'visible' => array(
75 ':input[name="student_type"]' => array('value' => 'high_school'),
76 ),
77 ),
78 );
79
80 // High school information.
81 $form['high_school']['tests_taken'] = array(
82 '#type' => 'checkboxes',
83 '#options' => drupal_map_assoc(array(t('SAT'), t('ACT'))),
84 '#title' => t('What standardized tests did you take?'),
85 // This #states rule says that this checkboxes array will be visible only
86 // when $form['student_type'] is set to t('High School').
87 // It uses the jQuery selector :input[name=student_type] to choose the
88 // element which triggers the behavior, and then defines the "High School"
89 // value as the one that triggers visibility.
90 '#states' => array(
91 'visible' => array( // action to take.
92 ':input[name="student_type"]' => array('value' => 'high_school'),
93 ),
94 ),
95 );
96
97 $form['high_school']['sat_score'] = array(
98 '#type' => 'textfield',
99 '#title' => t('Your SAT score:'),
100 '#size' => 4,
101
102 // This #states rule limits visibility to when the $form['tests_taken']
103 // 'SAT' checkbox is checked."
104 '#states' => array(
105 'visible' => array( // action to take.
106 ':input[name="tests_taken[SAT]"]' => array('checked' => TRUE),
107 ),
108 ),
109 );
110 $form['high_school']['act_score'] = array(
111 '#type' => 'textfield',
112 '#title' => t('Your ACT score:'),
113 '#size' => 4,
114
115 // Set this element visible if the ACT checkbox above is checked.
116 '#states' => array(
117 'visible' => array( // action to take.
118 ':input[name="tests_taken[ACT]"]' => array('checked' => TRUE),
119 ),
120 ),
121 );
122
123 // Undergrad information.
124 $form['undergraduate'] = array(
125 '#type' => 'fieldset',
126 '#title' => t('Undergraduate Information'),
127 // This #states rule says that the "undergraduate" fieldset should only
128 // be shown if the "student_type" form element is set to "Undergraduate".
129 '#states' => array(
130 'visible' => array(
131 ':input[name="student_type"]' => array('value' => 'undergraduate'),
132 ),
133 ),
134 );
135
136 $form['undergraduate']['how_many_years'] = array(
137 '#type' => 'select',
138 '#title' => t('How many years have you completed?'),
139 // The options here are integers, but since all the action here happens
140 // using the DOM on the client, we will have to use strings to work with
141 // them.
142 '#options' => array(
143 1 => t('One'),
144 2 => t('Two'),
145 3 => t('Three'),
146 4 => t('Four'),
147 5 => t('Lots'),
148 ),
149 );
150
151 $form['undergraduate']['comment'] = array(
152 '#type' => 'item',
153 '#description' => t("Wow, that's a long time."),
154 '#states' => array(
155 'visible' => array(
156 // Note that '5' must be used here instead of the integer 5.
157 // The information is coming from the DOM as a string.
158 ':input[name="how_many_years"]' => array('value' => '5'),
159 ),
160 ),
161 );
162 $form['undergraduate']['school_name'] = array(
163 '#type' => 'textfield',
164 '#title' => t('Your college or university:'),
165 );
166 $form['undergraduate']['school_country'] = array(
167 '#type' => 'select',
168 '#options' => drupal_map_assoc(array(t('UK'), t('Other'))),
169 '#title' => t('In what country is your college or university located?'),
170 );
171 $form['undergraduate']['country_writein'] = array(
172 '#type' => 'textfield',
173 '#size' => 20,
174 '#title' => t('Please enter the name of the country where your college or university is located.'),
175
176 // Only show this field if school_country is set to 'Other'.
177 '#states' => array(
178 'visible' => array( // Action to take: Make visible.
179 ':input[name="school_country"]' => array('value' => t('Other')),
180 ),
181 ),
182 );
183
184 $form['undergraduate']['thanks'] = array(
185 '#type' => 'item',
186 '#description' => t('Thanks for providing both your school and your country.'),
187 '#states' => array(
188 // Here visibility requires that two separate conditions be true.
189 'visible' => array(
190 ':input[name="school_country"]' => array('value' => t('Other')),
191 ':input[name="country_writein"]' => array('filled' => TRUE),
192 ),
193 ),
194 );
195 $form['undergraduate']['go_away'] = array(
196 '#type' => 'submit',
197 '#value' => t('Done with form'),
198 '#states' => array(
199 // Here visibility requires that two separate conditions be true.
200 'visible' => array(
201 ':input[name="school_country"]' => array('value' => t('Other')),
202 ':input[name="country_writein"]' => array('filled' => TRUE),
203 ),
204 ),
205 );
206
207 // Graduate student information.
208 $form['graduate'] = array(
209 '#type' => 'fieldset',
210 '#title' => t('Graduate School Information'),
211 // This #states rule says that the "graduate" fieldset should only
212 // be shown if the "student_type" form element is set to "Graduate".
213 '#states' => array(
214 'visible' => array(
215 ':input[name="student_type"]' => array('value' => 'graduate'),
216 ),
217 ),
218 );
219 $form['graduate']['more_info'] = array(
220 '#type' => 'textarea',
221 '#title' => t('Please describe your graduate studies'),
222 );
223
224 $form['graduate']['info_provide'] = array(
225 '#type' => 'checkbox',
226 '#title' => t('Check here if you have provided information above'),
227 '#disabled' => TRUE,
228 '#states' => array(
229 // Mark this checkbox checked if the "more_info" textarea has something
230 // in it, if it's 'filled'.
231 'checked' => array( // Action to take: check the checkbox.
232 ':input[name="more_info"]' => array('filled' => TRUE),
233 ),
234 ),
235 );
236
237 $form['average'] = array(
238 '#type' => 'textfield',
239 '#title' => t('Enter your average'),
240 // To trigger a state when the same controlling element can have more than
241 // one possible value, put all values in a higher-level array.
242 '#states' => array(
243 'visible' => array(
244 ':input[name="student_type"]' => array(
245 array('value' => 'high_school'),
246 array('value' => 'undergraduate'),
247 ),
248 ),
249 ),
250 );
251
252 $form['expand_more_info'] = array(
253 '#type' => 'checkbox',
254 '#title' => t('Check here if you want to add more information.'),
255 );
256 $form['more_info'] = array(
257 '#type' => 'fieldset',
258 '#title' => t('Additional Information'),
259 '#collapsible' => TRUE,
260 '#collapsed' => TRUE,
261
262 // Expand the expand_more_info fieldset if the box is checked.
263 '#states' => array(
264 'expanded' => array(
265 ':input[name="expand_more_info"]' => array('checked' => TRUE),
266 ),
267 ),
268 );
269 $form['more_info']['feedback'] = array(
270 '#type' => 'textarea',
271 '#title' => t('What do you have to say?'),
272 );
273
274 $form['submit'] = array(
275 '#type' => 'submit',
276 '#value' => t('Submit your information'),
277 );
278
279 return $form;
280 }
281
285 function form_example_states_form_submit($form, &$form_state) {
286 drupal_set_message(t('Submitting values: @values', array('@values' => var_export($form_state['values'], TRUE))));
287 }
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
form_example_states_form_submit
form_example_states_form_submit($form, &$form_state)
Definition: form_example_states.inc:285
form_example_states_form
form_example_states_form($form, &$form_state)
Definition: form_example_states.inc:58
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator-wrapper.tpl.php Source File

  • modules
  • aggregator
aggregator-wrapper.tpl.php
Go to the documentation of this file.
1 <?php
2
16 ?>
17 <div id="aggregator">
18 <?php print $content; ?>
19 <?php print $pager; ?>
20 </div>
$pager
print $pager
Definition: aggregator-wrapper.tpl.php:19
print
print
Definition: php-2.php:2
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/filetransfer/local.inc Source File

  • includes
  • filetransfer
local.inc
Go to the documentation of this file.
1 <?php
2
6 class FileTransferLocal extends FileTransfer implements FileTransferChmodInterface {
7
8 function connect() {
9 // No-op
10 }
11
12 static function factory($jail, $settings) {
13 return new FileTransferLocal($jail);
14 }
15
16 protected function copyFileJailed($source, $destination) {
17 if (@!copy($source, $destination)) {
18 throw new FileTransferException('Cannot copy %source to %destination.', NULL, array('%source' => $source, '%destination' => $destination));
19 }
20 }
21
22 protected function createDirectoryJailed($directory) {
23 if (!is_dir($directory) && @!mkdir($directory, 0777, TRUE)) {
24 throw new FileTransferException('Cannot create directory %directory.', NULL, array('%directory' => $directory));
25 }
26 }
27
28 protected function removeDirectoryJailed($directory) {
29 if (!is_dir($directory)) {
30 // Programmer error assertion, not something we expect users to see.
31 throw new FileTransferException('removeDirectoryJailed() called with a path (%directory) that is not a directory.', NULL, array('%directory' => $directory));
32 }
33 foreach (new RecursiveIteratorIterator(new SkipDotsRecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST) as $filename => $file) {
34 if ($file->isDir()) {
35 if (@!drupal_rmdir($filename)) {
36 throw new FileTransferException('Cannot remove directory %directory.', NULL, array('%directory' => $filename));
37 }
38 }
39 elseif ($file->isFile()) {
40 if (@!drupal_unlink($filename)) {
41 throw new FileTransferException('Cannot remove file %file.', NULL, array('%file' => $filename));
42 }
43 }
44 }
45 if (@!drupal_rmdir($directory)) {
46 throw new FileTransferException('Cannot remove directory %directory.', NULL, array('%directory' => $directory));
47 }
48 }
49
50 protected function removeFileJailed($file) {
51 if (@!drupal_unlink($file)) {
52 throw new FileTransferException('Cannot remove file %file.', NULL, array('%file' => $file));
53 }
54 }
55
56 public function isDirectory($path) {
57 return is_dir($path);
58 }
59
60 public function isFile($path) {
61 return is_file($path);
62 }
63
64 public function chmodJailed($path, $mode, $recursive) {
65 if ($recursive && is_dir($path)) {
66 foreach (new RecursiveIteratorIterator(new SkipDotsRecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) {
67 if (@!chmod($filename, $mode)) {
68 throw new FileTransferException('Cannot chmod %path.', NULL, array('%path' => $filename));
69 }
70 }
71 }
72 elseif (@!chmod($path, $mode)) {
73 throw new FileTransferException('Cannot chmod %path.', NULL, array('%path' => $path));
74 }
75 }
76 }
drupal_unlink
drupal_unlink($uri, $context=NULL)
Definition: file.inc:2225
FileTransferException
Definition: filetransfer.inc:363
FileTransferLocal\factory
static factory($jail, $settings)
Definition: local.inc:12
FileTransferLocal\copyFileJailed
copyFileJailed($source, $destination)
Definition: local.inc:16
FileTransfer\chmod
chmod($path, $mode, $recursive=FALSE)
Definition: filetransfer.inc:90
FileTransfer
Definition: filetransfer.inc:12
SkipDotsRecursiveDirectoryIterator
Definition: filetransfer.inc:400
FileTransferLocal\createDirectoryJailed
createDirectoryJailed($directory)
Definition: local.inc:22
FileTransferLocal\removeDirectoryJailed
removeDirectoryJailed($directory)
Definition: local.inc:28
drupal_rmdir
drupal_rmdir($uri, $context=NULL)
Definition: file.inc:2389
FileTransferChmodInterface
Definition: filetransfer.inc:376
FileTransferLocal\removeFileJailed
removeFileJailed($file)
Definition: local.inc:50
FileTransferLocal
Definition: local.inc:6
FileTransferLocal\chmodJailed
chmodJailed($path, $mode, $recursive)
Definition: local.inc:64
FileTransferLocal\isDirectory
isDirectory($path)
Definition: local.inc:56
FileTransferLocal\connect
connect()
Definition: local.inc:8
FileTransferLocal\isFile
isFile($path)
Definition: local.inc:60
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.processor.inc Source File

  • modules
  • aggregator
aggregator.processor.inc
Go to the documentation of this file.
1 <?php
2
11 function aggregator_aggregator_process_info() {
12 return array(
13 'title' => t('Default processor'),
14 'description' => t('Creates lightweight records from feed items.'),
15 );
16 }
17
21 function aggregator_aggregator_process($feed) {
22 if (is_object($feed)) {
23 if (is_array($feed->items)) {
24 foreach ($feed->items as $item) {
25 // Save this item. Try to avoid duplicate entries as much as possible. If
26 // we find a duplicate entry, we resolve it and pass along its ID is such
27 // that we can update it if needed.
28 if (!empty($item['guid'])) {
29 $entry = db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = :fid AND guid = :guid", array(':fid' => $feed->fid, ':guid' => $item['guid']))->fetchObject();
30 }
31 elseif ($item['link'] && $item['link'] != $feed->link && $item['link'] != $feed->url) {
32 $entry = db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = :fid AND link = :link", array(':fid' => $feed->fid, ':link' => $item['link']))->fetchObject();
33 }
34 else {
35 $entry = db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = :fid AND title = :title", array(':fid' => $feed->fid, ':title' => $item['title']))->fetchObject();
36 }
37 if (!$item['timestamp']) {
38 $item['timestamp'] = isset($entry->timestamp) ? $entry->timestamp : REQUEST_TIME;
39 }
40
41 // Make sure the item title and author fit in the 255 varchar column.
42 $item['title'] = truncate_utf8($item['title'], 255, TRUE, TRUE);
43 $item['author'] = truncate_utf8($item['author'], 255, TRUE, TRUE);
44 aggregator_save_item(array('iid' => (isset($entry->iid) ? $entry->iid : ''), 'fid' => $feed->fid, 'timestamp' => $item['timestamp'], 'title' => $item['title'], 'link' => $item['link'], 'author' => $item['author'], 'description' => $item['description'], 'guid' => $item['guid']));
45 }
46 }
47 }
48 }
49
53 function aggregator_aggregator_remove($feed) {
54 $iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchCol();
55 if ($iids) {
56 db_delete('aggregator_category_item')
57 ->condition('iid', $iids, 'IN')
58 ->execute();
59 }
60 db_delete('aggregator_item')
61 ->condition('fid', $feed->fid)
62 ->execute();
63
64 drupal_set_message(t('The news items from %site have been removed.', array('%site' => $feed->title)));
65 }
66
73 function aggregator_form_aggregator_admin_form_alter(&$form, $form_state) {
74 if (in_array('aggregator', variable_get('aggregator_processors', array('aggregator')))) {
75 $info = module_invoke('aggregator', 'aggregator_process', 'info');
76 $items = drupal_map_assoc(array(3, 5, 10, 15, 20, 25), '_aggregator_items');
77 $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
78 $period[AGGREGATOR_CLEAR_NEVER] = t('Never');
79
80 // Only wrap into a collapsible fieldset if there is a basic configuration.
81 if (isset($form['basic_conf'])) {
82 $form['modules']['aggregator'] = array(
83 '#type' => 'fieldset',
84 '#title' => t('Default processor settings'),
85 '#description' => $info['description'],
86 '#collapsible' => TRUE,
87 '#collapsed' => !in_array('aggregator', variable_get('aggregator_processors', array('aggregator'))),
88 );
89 }
90 else {
91 $form['modules']['aggregator'] = array();
92 }
93
94 $form['modules']['aggregator']['aggregator_summary_items'] = array(
95 '#type' => 'select',
96 '#title' => t('Number of items shown in listing pages'),
97 '#default_value' => variable_get('aggregator_summary_items', 3),
98 '#empty_value' => 0,
99 '#options' => $items,
100 );
101
102 $form['modules']['aggregator']['aggregator_clear'] = array(
103 '#type' => 'select',
104 '#title' => t('Discard items older than'),
105 '#default_value' => variable_get('aggregator_clear', 9676800),
106 '#options' => $period,
107 '#description' => t('Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))),
108 );
109
110 $form['modules']['aggregator']['aggregator_category_selector'] = array(
111 '#type' => 'radios',
112 '#title' => t('Select categories using'),
113 '#default_value' => variable_get('aggregator_category_selector', 'checkboxes'),
114 '#options' => array('checkboxes' => t('checkboxes'),
115 'select' => t('multiple selector')),
116 '#description' => t('For a small number of categories, checkboxes are easier to use, while a multiple selector works well with large numbers of categories.'),
117 );
118 $form['modules']['aggregator']['aggregator_teaser_length'] = array(
119 '#type' => 'select',
120 '#title' => t('Length of trimmed description'),
121 '#default_value' => variable_get('aggregator_teaser_length', 600),
122 '#options' => drupal_map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), '_aggregator_characters'),
123 '#description' => t("The maximum number of characters used in the trimmed version of content.")
124 );
125
126 }
127 }
128
141 function _aggregator_characters($length) {
142 return ($length == 0) ? t('Unlimited') : format_plural($length, '1 character', '@count characters');
143 }
144
151 function aggregator_save_item($edit) {
152 if ($edit['title'] && empty($edit['iid'])) {
153 $edit['iid'] = db_insert('aggregator_item')
154 ->fields(array(
155 'title' => $edit['title'],
156 'link' => $edit['link'],
157 'author' => $edit['author'],
158 'description' => $edit['description'],
159 'guid' => $edit['guid'],
160 'timestamp' => $edit['timestamp'],
161 'fid' => $edit['fid'],
162 ))
163 ->execute();
164 }
165 if ($edit['iid'] && !$edit['title']) {
166 db_delete('aggregator_item')
167 ->condition('iid', $edit['iid'])
168 ->execute();
169 db_delete('aggregator_category_item')
170 ->condition('iid', $edit['iid'])
171 ->execute();
172 }
173 elseif ($edit['title'] && $edit['link']) {
174 // file the items in the categories indicated by the feed
175 $result = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = :fid', array(':fid' => $edit['fid']));
176 foreach ($result as $category) {
177 db_merge('aggregator_category_item')
178 ->key(array(
179 'iid' => $edit['iid'],
180 'cid' => $category->cid,
181 ))
182 ->execute();
183 }
184 }
185 }
186
193 function aggregator_expire($feed) {
194 $aggregator_clear = variable_get('aggregator_clear', 9676800);
195
196 if ($aggregator_clear != AGGREGATOR_CLEAR_NEVER) {
197 // Remove all items that are older than flush item timer.
198 $age = REQUEST_TIME - $aggregator_clear;
199 $iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid AND timestamp < :timestamp', array(
200 ':fid' => $feed->fid,
201 ':timestamp' => $age,
202 ))
203 ->fetchCol();
204 if ($iids) {
205 db_delete('aggregator_category_item')
206 ->condition('iid', $iids, 'IN')
207 ->execute();
208 db_delete('aggregator_item')
209 ->condition('iid', $iids, 'IN')
210 ->execute();
211 }
212 }
213 }
aggregator_aggregator_process_info
aggregator_aggregator_process_info()
Definition: aggregator.processor.inc:11
aggregator_aggregator_process
aggregator_aggregator_process($feed)
Definition: aggregator.processor.inc:21
aggregator_expire
aggregator_expire($feed)
Definition: aggregator.processor.inc:193
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
aggregator_aggregator_remove
aggregator_aggregator_remove($feed)
Definition: aggregator.processor.inc:53
aggregator_form_aggregator_admin_form_alter
aggregator_form_aggregator_admin_form_alter(&$form, $form_state)
Definition: aggregator.processor.inc:73
aggregator_save_item
aggregator_save_item($edit)
Definition: aggregator.processor.inc:151
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
_aggregator_characters
_aggregator_characters($length)
Definition: aggregator.processor.inc:141
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$info
$info
Definition: color.inc:6
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
truncate_utf8
truncate_utf8($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
Definition: unicode.inc:316
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
AGGREGATOR_CLEAR_NEVER
const AGGREGATOR_CLEAR_NEVER
Definition: aggregator.module:11
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/pgsql/database.inc Source File

  • includes
  • database
  • pgsql
database.inc
Go to the documentation of this file.
1 <?php
2
16 define('POSTGRESQL_NEXTID_LOCK', 1000);
17
18 class DatabaseConnection_pgsql extends DatabaseConnection {
19
20 public function __construct(array $connection_options = array()) {
21 // This driver defaults to transaction support, except if explicitly passed FALSE.
22 $this->transactionSupport = !isset($connection_options['transactions']) || ($connection_options['transactions'] !== FALSE);
23
24 // Transactional DDL is always available in PostgreSQL,
25 // but we'll only enable it if standard transactions are.
26 $this->transactionalDDLSupport = $this->transactionSupport;
27
28 // Default to TCP connection on port 5432.
29 if (empty($connection_options['port'])) {
30 $connection_options['port'] = 5432;
31 }
32
33 // PostgreSQL in trust mode doesn't require a password to be supplied.
34 if (empty($connection_options['password'])) {
35 $connection_options['password'] = NULL;
36 }
37 // If the password contains a backslash it is treated as an escape character
38 // http://bugs.php.net/bug.php?id=53217
39 // so backslashes in the password need to be doubled up.
40 // The bug was reported against pdo_pgsql 1.0.2, backslashes in passwords
41 // will break on this doubling up when the bug is fixed, so check the version
42 //elseif (phpversion('pdo_pgsql') < 'version_this_was_fixed_in') {
43 else {
44 $connection_options['password'] = str_replace('\\', '\\\\', $connection_options['password']);
45 }
46
47 $this->connectionOptions = $connection_options;
48
49 $dsn = 'pgsql:host=' . $connection_options['host'] . ' dbname=' . $connection_options['database'] . ' port=' . $connection_options['port'];
50
51 // Allow PDO options to be overridden.
52 $connection_options += array(
53 'pdo' => array(),
54 );
55 $connection_options['pdo'] += array(
56 // Prepared statements are most effective for performance when queries
57 // are recycled (used several times). However, if they are not re-used,
58 // prepared statements become ineffecient. Since most of Drupal's
59 // prepared queries are not re-used, it should be faster to emulate
60 // the preparation than to actually ready statements for re-use. If in
61 // doubt, reset to FALSE and measure performance.
62 PDO::ATTR_EMULATE_PREPARES => TRUE,
63 // Convert numeric values to strings when fetching.
64 PDO::ATTR_STRINGIFY_FETCHES => TRUE,
65 );
66 parent::__construct($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']);
67
68 // Force PostgreSQL to use the UTF-8 character set by default.
69 $this->exec("SET NAMES 'UTF8'");
70
71 // Execute PostgreSQL init_commands.
72 if (isset($connection_options['init_commands'])) {
73 $this->exec(implode('; ', $connection_options['init_commands']));
74 }
75 }
76
77 public function prepareQuery($query) {
78 // mapConditionOperator converts LIKE operations to ILIKE for consistency
79 // with MySQL. However, Postgres does not support ILIKE on bytea (blobs)
80 // fields.
81 // To make the ILIKE operator work, we type-cast bytea fields into text.
82 // @todo This workaround only affects bytea fields, but the involved field
83 // types involved in the query are unknown, so there is no way to
84 // conditionally execute this for affected queries only.
85 return parent::prepareQuery(preg_replace('/ ([^ ]+) +(I*LIKE|NOT +I*LIKE) /i', ' ${1}::text ${2} ', $query));
86 }
87
88 public function query($query, array $args = array(), $options = array()) {
89
90 $options += $this->defaultOptions();
91
92 // The PDO PostgreSQL driver has a bug which
93 // doesn't type cast booleans correctly when
94 // parameters are bound using associative
95 // arrays.
96 // See http://bugs.php.net/bug.php?id=48383
97 foreach ($args as &$value) {
98 if (is_bool($value)) {
99 $value = (int) $value;
100 }
101 }
102
103 try {
104 if ($query instanceof DatabaseStatementInterface) {
105 $stmt = $query;
106 $stmt->execute(NULL, $options);
107 }
108 else {
109 $this->expandArguments($query, $args);
110 $stmt = $this->prepareQuery($query);
111 $stmt->execute($args, $options);
112 }
113
114 switch ($options['return']) {
115 case Database::RETURN_STATEMENT:
116 return $stmt;
117 case Database::RETURN_AFFECTED:
118 return $stmt->rowCount();
119 case Database::RETURN_INSERT_ID:
120 return $this->lastInsertId($options['sequence_name']);
121 case Database::RETURN_NULL:
122 return;
123 default:
124 throw new PDOException('Invalid return directive: ' . $options['return']);
125 }
126 }
127 catch (PDOException $e) {
128 if ($options['throw_exception']) {
129 // Add additional debug information.
130 if ($query instanceof DatabaseStatementInterface) {
131 $e->query_string = $stmt->getQueryString();
132 }
133 else {
134 $e->query_string = $query;
135 }
136 $e->args = $args;
137 throw $e;
138 }
139 return NULL;
140 }
141 }
142
143 public function queryRange($query, $from, $count, array $args = array(), array $options = array()) {
144 return $this->query($query . ' LIMIT ' . (int) $count . ' OFFSET ' . (int) $from, $args, $options);
145 }
146
147 public function queryTemporary($query, array $args = array(), array $options = array()) {
148 $tablename = $this->generateTemporaryTableName();
149 $this->query(preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE {' . $tablename . '} AS SELECT', $query), $args, $options);
150 return $tablename;
151 }
152
153 public function driver() {
154 return 'pgsql';
155 }
156
157 public function databaseType() {
158 return 'pgsql';
159 }
160
161 public function mapConditionOperator($operator) {
162 static $specials;
163
164 // Function calls not allowed in static declarations, thus this method.
165 if (!isset($specials)) {
166 $specials = array(
167 // In PostgreSQL, 'LIKE' is case-sensitive. For case-insensitive LIKE
168 // statements, we need to use ILIKE instead.
169 'LIKE' => array('operator' => 'ILIKE'),
170 'NOT LIKE' => array('operator' => 'NOT ILIKE'),
171 );
172 }
173
174 return isset($specials[$operator]) ? $specials[$operator] : NULL;
175 }
176
183 public function nextId($existing = 0) {
184
185 // Retrive the name of the sequence. This information cannot be cached
186 // because the prefix may change, for example, like it does in simpletests.
187 $sequence_name = $this->makeSequenceName('sequences', 'value');
188
189 // When PostgreSQL gets a value too small then it will lock the table,
190 // retry the INSERT and if it's still too small then alter the sequence.
191 $id = $this->query("SELECT nextval('" . $sequence_name . "')")->fetchField();
192 if ($id > $existing) {
193 return $id;
194 }
195
196 // PostgreSQL advisory locks are simply locks to be used by an
197 // application such as Drupal. This will prevent other Drupal proccesses
198 // from altering the sequence while we are.
199 $this->query("SELECT pg_advisory_lock(" . POSTGRESQL_NEXTID_LOCK . ")");
200
201 // While waiting to obtain the lock, the sequence may have been altered
202 // so lets try again to obtain an adequate value.
203 $id = $this->query("SELECT nextval('" . $sequence_name . "')")->fetchField();
204 if ($id > $existing) {
205 $this->query("SELECT pg_advisory_unlock(" . POSTGRESQL_NEXTID_LOCK . ")");
206 return $id;
207 }
208
209 // Reset the sequence to a higher value than the existing id.
210 $this->query("ALTER SEQUENCE " . $sequence_name . " RESTART WITH " . ($existing + 1));
211
212 // Retrive the next id. We know this will be as high as we want it.
213 $id = $this->query("SELECT nextval('" . $sequence_name . "')")->fetchField();
214
215 $this->query("SELECT pg_advisory_unlock(" . POSTGRESQL_NEXTID_LOCK . ")");
216
217 return $id;
218 }
219 }
220
DatabaseConnection\expandArguments
expandArguments(&$query, &$args)
Definition: database.inc:729
DatabaseConnection_pgsql\query
query($query, array $args=array(), $options=array())
Definition: database.inc:88
DatabaseConnection_pgsql\databaseType
databaseType()
Definition: database.inc:157
DatabaseConnection\makeSequenceName
makeSequenceName($table, $field)
Definition: database.inc:568
DatabaseConnection_pgsql\__construct
__construct(array $connection_options=array())
Definition: database.inc:20
DatabaseConnection\defaultOptions
defaultOptions()
Definition: database.inc:373
Database\RETURN_STATEMENT
const RETURN_STATEMENT
Definition: database.inc:1335
Database\RETURN_INSERT_ID
const RETURN_INSERT_ID
Definition: database.inc:1345
DatabaseConnection_pgsql\prepareQuery
prepareQuery($query)
Definition: database.inc:77
Database\RETURN_AFFECTED
const RETURN_AFFECTED
Definition: database.inc:1340
$value
print $value
Definition: user-profile-item.tpl.php:26
DatabaseStatementInterface
Definition: database.inc:1953
DatabaseConnection
Definition: database.inc:184
DatabaseConnection_pgsql\queryTemporary
queryTemporary($query, array $args=array(), array $options=array())
Definition: database.inc:147
POSTGRESQL_NEXTID_LOCK
const POSTGRESQL_NEXTID_LOCK
Definition: database.inc:16
DatabaseConnection_pgsql\driver
driver()
Definition: database.inc:153
DatabaseConnection_pgsql
Definition: database.inc:18
DatabaseConnection_pgsql\nextId
nextId($existing=0)
Definition: database.inc:183
DatabaseConnection_pgsql\queryRange
queryRange($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:143
DatabaseConnection\generateTemporaryTableName
generateTemporaryTableName()
Definition: database.inc:1186
DatabaseConnection\$transactionSupport
$transactionSupport
Definition: database.inc:243
Database\RETURN_NULL
const RETURN_NULL
Definition: database.inc:1330
DatabaseConnection_pgsql\mapConditionOperator
mapConditionOperator($operator)
Definition: database.inc:161
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example/ajax_example_node_form_alter.inc Source File

  • examples
  • ajax_example
ajax_example_node_form_alter.inc
Go to the documentation of this file.
1 <?php
16 function ajax_example_form_node_form_alter(&$form, &$form_state, $form_id) {
17 $node = $form['#node'];
18 $form['ajax_example_1'] = array(
19 '#type' => 'checkbox',
20 '#title' => t('AJAX Example 1'),
21 '#description' => t('Enable to show second field.'),
22 '#default_value' => $node->ajax_example['example_1'],
23 '#ajax' => array(
24 'callback' => 'ajax_example_form_node_callback',
25 'wrapper' => 'ajax-example-form-node',
26 'effect' => 'fade',
27 )
28 );
29 $form['container'] = array(
30 '#prefix' => '<div id="ajax-example-form-node">',
31 '#suffix' => '</div>',
32 );
33
34 // If the state values exist and 'ajax_example_1' state value is 1 or
35 // if the state values don't exist and 'example1' variable is 1 then
36 // display the ajax_example_2 field.
37 if (!empty($form_state['values']['ajax_example_1']) && $form_state['values']['ajax_example_1'] == 1
38 || empty($form_state['values']) && $node->ajax_example['example_1']) {
39
40 $form['container']['ajax_example_2'] = array(
41 '#type' => 'textfield',
42 '#title' => t('AJAX Example 2'),
43 '#description' => t('AJAX Example 2'),
44 '#default_value' => empty($form_state['values']['ajax_example_2']) ?
45 $node->ajax_example['example_2'] :
46 $form_state['values']['ajax_example_2'],
47 );
48 }
49 }
50
58 function ajax_example_form_node_callback($form, $form_state) {
59 return $form['container'];
60 }
61
66 function ajax_example_node_submit($node, $form, &$form_state) {
67 $values = $form_state['values'];
68 // Move the new data into the node object.
69 $node->ajax_example['example_1'] = $values['ajax_example_1'];
70 // Depending on the state of ajax_example_1; it may not exist.
71 $node->ajax_example['example_2'] = isset($values['ajax_example_2']) ? $values['ajax_example_2'] : '';
72 }
73
79 function ajax_example_node_prepare($node) {
80 if (empty($node->ajax_example)) {
81 // Set default values, since this only runs when adding a new node.
82 $node->ajax_example['example_1'] = 0;
83 $node->ajax_example['example_2'] = '';
84 }
85 }
86
92 function ajax_example_node_load($nodes, $types) {
93 $result = db_query('SELECT * FROM {ajax_example_node_form_alter} WHERE nid IN(:nids)', array(':nids' => array_keys($nodes)))->fetchAllAssoc('nid');
94
95 foreach ($nodes as &$node) {
96 $node->ajax_example['example_1'] =
97 isset($result[$node->nid]->example_1) ?
98 $result[$node->nid]->example_1 : 0;
99 $node->ajax_example['example_2'] =
100 isset($result[$node->nid]->example_2) ?
101 $result[$node->nid]->example_2 : '';
102 }
103 }
104
110 function ajax_example_node_insert($node) {
111 if (isset($node->ajax_example)) {
112 db_insert('ajax_example_node_form_alter')
113 ->fields(array(
114 'nid' => $node->nid,
115 'example_1' => $node->ajax_example['example_1'],
116 'example_2' => $node->ajax_example['example_2'],
117 ))
118 ->execute();
119 }
120 }
121
126 function ajax_example_node_update($node) {
127 if (db_select('ajax_example_node_form_alter', 'a')->fields('a')->condition('nid', $node->nid, '=')->execute()->fetchAssoc()) {
128 db_update('ajax_example_node_form_alter')
129 ->fields(array(
130 'example_1' => $node->ajax_example['example_1'],
131 'example_2' => $node->ajax_example['example_2'],
132 ))
133 ->condition('nid', $node->nid)
134 ->execute();
135 }
136 else {
137 // Cleaner than doing it again.
138 ajax_example_node_insert($node);
139 }
140 }
141
146 function ajax_example_node_delete($node) {
147 db_delete('ajax_example_node_form_alter')
148 ->condition('nid', $node->nid)
149 ->execute();
150 }
ajax_example_node_update
ajax_example_node_update($node)
Definition: ajax_example_node_form_alter.inc:126
ajax_example_node_insert
ajax_example_node_insert($node)
Definition: ajax_example_node_form_alter.inc:110
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
ajax_example_node_submit
ajax_example_node_submit($node, $form, &$form_state)
Definition: ajax_example_node_form_alter.inc:66
ajax_example_form_node_form_alter
ajax_example_form_node_form_alter(&$form, &$form_state, $form_id)
Definition: ajax_example_node_form_alter.inc:16
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
ajax_example_node_prepare
ajax_example_node_prepare($node)
Definition: ajax_example_node_form_alter.inc:79
ajax_example_node_load
ajax_example_node_load($nodes, $types)
Definition: ajax_example_node_form_alter.inc:92
ajax_example_form_node_callback
ajax_example_form_node_callback($form, $form_state)
Definition: ajax_example_node_form_alter.inc:58
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
ajax_example_node_delete
ajax_example_node_delete($node)
Definition: ajax_example_node_form_alter.inc:146
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: sites/default/default.settings.php Source File

  • sites
  • default
default.settings.php
Go to the documentation of this file.
1 <?php
2
213 $databases = array();
214
226 $update_free_access = FALSE;
227
245 $drupal_hash_salt = '';
246
267 # $base_url = 'http://www.example.com'; // NO trailing slash!
268
286 ini_set('session.gc_probability', 1);
287 ini_set('session.gc_divisor', 100);
288
295 ini_set('session.gc_maxlifetime', 200000);
296
302 ini_set('session.cookie_lifetime', 2000000);
303
312 # ini_set('pcre.backtrack_limit', 200000);
313 # ini_set('pcre.recursion_limit', 200000);
314
324 # $cookie_domain = '.example.com';
325
343 # $conf['site_name'] = 'My Drupal site';
344 # $conf['theme_default'] = 'garland';
345 # $conf['anonymous'] = 'Visitor';
346
355 # $conf['maintenance_theme'] = 'bartik';
356
388 # $conf['reverse_proxy'] = TRUE;
389
394 # $conf['reverse_proxy_addresses'] = array('a.b.c.d', ...);
395
400 # $conf['reverse_proxy_header'] = 'HTTP_X_CLUSTER_CLIENT_IP';
401
418 # $conf['omit_vary_cookie'] = TRUE;
419
432 # $conf['css_gzip_compression'] = FALSE;
433 # $conf['js_gzip_compression'] = FALSE;
434
444 # $conf['locale_custom_strings_en'][''] = array(
445 # 'forum' => 'Discussion board',
446 # '@count min' => '@count minutes',
447 # );
448
468 # $conf['blocked_ips'] = array(
469 # 'a.b.c.d',
470 # );
471
491 $conf['404_fast_paths_exclude'] = '/\/(?:styles)\//';
492 $conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i';
493 $conf['404_fast_html'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>';
494
511 # drupal_fast_404();
512
524 # $conf['proxy_server'] = '';
525 # $conf['proxy_port'] = 8080;
526 # $conf['proxy_username'] = '';
527 # $conf['proxy_password'] = '';
528 # $conf['proxy_user_agent'] = '';
529 # $conf['proxy_exceptions'] = array('127.0.0.1', 'localhost');
530
553 # $conf['allow_authorize_operations'] = FALSE;
$databases
$databases
Definition: default.settings.php:213
$conf
global $conf
Definition: authorize.php:74
$update_free_access
$update_free_access
Definition: default.settings.php:226
$drupal_hash_salt
$drupal_hash_salt
Definition: default.settings.php:245
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/contextual/contextual.api.php Source File

  • modules
  • contextual
contextual.api.php
Go to the documentation of this file.
1 <?php
2
32 function hook_contextual_links_view_alter(&$element, $items) {
33 // Add another class to all contextual link lists to facilitate custom
34 // styling.
35 $element['#attributes']['class'][] = 'custom-class';
36 }
37
hook_contextual_links_view_alter
hook_contextual_links_view_alter(&$element, $items)
Definition: contextual.api.php:32
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/token_example/token_example.tokens.inc Source File

  • examples
  • token_example
token_example.tokens.inc
Go to the documentation of this file.
1 <?php
2
13 function token_example_token_info() {
14 // Add two different token types. The first is the generic text format. The
15 // second is the user's default text format, which is itself a 'format' token
16 // type so it can be used directly.
17 $info['types']['format'] = array(
18 'name' => t('Text formats'),
19 'description' => t('Tokens related to text formats.'),
20 'needs-data' => 'format',
21 );
22 $info['types']['default-format'] = array(
23 'name' => t('Default text format'),
24 'description' => t("Tokens related to the currently logged in user's default text format."),
25 'type' => 'format',
26 );
27
28 // Tokens for the text format token type.
29 $info['tokens']['format']['id'] = array(
30 'name' => t('ID'),
31 'description' => t("The unique ID of the text format."),
32 );
33 $info['tokens']['format']['name'] = array(
34 'name' => t('Name'),
35 'description' => t("The name of the text format."),
36 );
37
38 // Node tokens.
39 $info['tokens']['node']['body-format'] = array(
40 'name' => t('Body text format'),
41 'description' => t("The name of the text format used on the node's body field."),
42 'type' => 'format',
43 );
44
45 // Comment tokens.
46 if (module_exists('comment')) {
47 $info['tokens']['comment']['body-format'] = array(
48 'name' => t('Body text format'),
49 'description' => t("The name of the text format used on the comment's body field."),
50 'type' => 'format',
51 );
52 }
53
54 return $info;
55 }
56
62 function token_example_tokens($type, $tokens, array $data = array(), array $options = array()) {
63 $replacements = array();
64 $sanitize = !empty($options['sanitize']);
65
66 // Text format tokens.
67 if ($type == 'format' && !empty($data['format'])) {
68 $format = $data['format'];
69
70 foreach ($tokens as $name => $original) {
71 switch ($name) {
72 case 'id':
73 // Since {filter_format}.format is an integer and not user-entered
74 // text, it does not need to ever be sanitized.
75 $replacements[$original] = $format->format;
76 break;
77 case 'name':
78 // Since the format name is user-entered text, santize when requested.
79 $replacements[$original] = $sanitize ? filter_xss($format->name) : $format->name;
80 break;
81 }
82 }
83 }
84
85 // Default format tokens.
86 if ($type == 'default-format') {
87 $default_id = filter_default_format();
88 $default_format = filter_format_load($default_id);
89 $replacements += token_generate('format', $tokens, array('format' => $default_format), $options);
90 }
91
92 // Node tokens.
93 if ($type == 'node' && !empty($data['node'])) {
94 $node = $data['node'];
95
96 foreach ($tokens as $name => $original) {
97 switch ($name) {
98 case 'body-format':
99 if ($items = field_get_items('node', $node, 'body')) {
100 $format = filter_format_load($items[0]['format']);
101 $replacements[$original] = $sanitize ? filter_xss($format->name) : $format->name;
102 }
103 break;
104 }
105 }
106
107 // Chained token relationships.
108 if ($format_tokens = token_find_with_prefix($tokens, 'body-format')) {
109 if ($items = field_get_items('node', $node, 'body')) {
110 $body_format = filter_format_load($items[0]['format']);
111 $replacements += token_generate('format', $format_tokens, array('format' => $body_format), $options);
112 }
113 }
114 }
115
116 // Comment tokens.
117 if ($type == 'comment' && !empty($data['comment'])) {
118 $comment = $data['comment'];
119
120 foreach ($tokens as $name => $original) {
121 switch ($name) {
122 case 'body-format':
123 if ($items = field_get_items('comment', $comment, 'comment_body')) {
124 $format = filter_format_load($items[0]['format']);
125 $replacements[$original] = $sanitize ? filter_xss($format->name) : $format->name;
126 }
127 break;
128 }
129 }
130
131 // Chained token relationships.
132 if ($format_tokens = token_find_with_prefix($tokens, 'body-format')) {
133 if ($items = field_get_items('comment', $comment, 'comment_body')) {
134 $body_format = filter_format_load($items[0]['format']);
135 $replacements += token_generate('format', $format_tokens, array('format' => $body_format), $options);
136 }
137 }
138 }
139
140 return $replacements;
141 }
token_generate
token_generate($type, array $tokens, array $data=array(), array $options=array())
Definition: token.inc:176
field_get_items
field_get_items($entity_type, $entity, $field_name, $langcode=NULL)
Definition: field.module:935
$name
print $name
Definition: profile-listing.tpl.php:43
module_exists
module_exists($module)
Definition: module.inc:274
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$info
$info
Definition: color.inc:6
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
token_example_tokens
token_example_tokens($type, $tokens, array $data=array(), array $options=array())
Definition: token_example.tokens.inc:62
token_example_token_info
token_example_token_info()
Definition: token_example.tokens.inc:13
filter_default_format
filter_default_format($account=NULL)
Definition: filter.module:524
token_find_with_prefix
token_find_with_prefix(array $tokens, $prefix, $delimiter= ':')
Definition: token.inc:219
filter_format_load
filter_format_load($format_id)
Definition: filter.module:165
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/image_example/image_example.pages.inc Source File

  • examples
  • image_example
image_example.pages.inc
Go to the documentation of this file.
1 <?php
2
21 function image_example_style_form($form, &$form_state) {
22 // If there is already an uploaded image display the image here.
23 if ($image_fid = variable_get('image_example_image_fid', FALSE)) {
24 $image = file_load($image_fid);
25 $style = variable_get('image_example_style_name', 'thumbnail');
26 $form['image'] = array(
27 '#markup' => theme('image_example_image', array('image' => $image, 'style' => $style)),
28 );
29 }
30
31 // Use the #managed_file FAPI element to upload an image file.
32 $form['image_example_image_fid'] = array(
33 '#title' => t('Image'),
34 '#type' => 'managed_file',
35 '#description' => t('The uploaded image will be displayed on this page using the image style choosen below.'),
36 '#default_value' => variable_get('image_example_image_fid', ''),
37 '#upload_location' => 'public://image_example_images/',
38 );
39
40 // Provide a select field for choosing an image style to use when displaying
41 // the image.
42 $form['image_example_style_name'] = array(
43 '#title' => t('Image style'),
44 '#type' => 'select',
45 '#description' => t('Choose an image style to use when displaying this image.'),
46 // The image_style_options() function returns an array of all available
47 // image styles both the key and the value of the array are the image
48 // style's name. The fucntion takes on paramater, a boolean flag
49 // signifying wether or not the array should include a <none> option.
50 '#options' => image_style_options(TRUE),
51 '#default_value' => variable_get('image_example_style_name', ''),
52 );
53
54 // Submit Button.
55 $form['submit'] = array(
56 '#type' => 'submit',
57 '#value' => t('Save'),
58 );
59
60 return $form;
61 }
62
68 function image_example_style_form_validate($form, &$form_state) {
69 if (!isset($form_state['values']['image_example_image_fid']) || !is_numeric($form_state['values']['image_example_image_fid'])) {
70 form_set_error('image_example_image_fid', t('Please select an image to upload.'));
71 }
72 }
73
79 function image_example_style_form_submit($form, &$form_state) {
80 // When using the #managed_file form element the file is automatically
81 // uploaded an saved to the {file} table. The value of the corresponding
82 // form element is set to the {file}.fid of the new file.
83
84
85 // If fid is not 0 we have a valid file.
86 if ($form_state['values']['image_example_image_fid'] != 0) {
87 // The new file's status is set to 0 or temporary and in order to ensure
88 // that the file is not removed after 6 hours we need to change it's status
89 // to 1. Save the ID of the uploaded image for later use.
90 $file = file_load($form_state['values']['image_example_image_fid']);
91 $file->status = FILE_STATUS_PERMANENT;
92 file_save($file);
93
94 // When a module is managing a file, it must manage the usage count.
95 // Here we increment the usage count with file_usage_add().
96 file_usage_add($file, 'image_example', 'sample_image', 1);
97
98 // Save the fid of the file so that the module can reference it later.
99 variable_set('image_example_image_fid', $file->fid);
100 drupal_set_message(t('The image @image_name was uploaded and saved with an ID of @fid and will be displayed using the style @style.', array('@image_name' => $file->filename, '@fid' => $file->fid, '@style' => $form_state['values']['image_example_style_name'])));
101 }
102 // If the file was removed we need to remove the module's reference to the
103 // removed file's fid, and remove the file.
104 elseif ($form_state['values']['image_example_image_fid'] == 0) {
105 // Retrieve the old file's id.
106 $fid = variable_get('image_example_image_fid', FALSE);
107 $file = $fid ? file_load($fid) : FALSE;
108 if ($file) {
109 // When a module is managing a file, it must manage the usage count.
110 // Here we decrement the usage count with file_usage_delete().
111 file_usage_delete($file, 'image_example', 'sample_image', 1);
112
113 // The file_delete() function takes a file object and checks to see if
114 // the file is being used by any other modules. If it is the delete
115 // operation is cancelled, otherwise the file is deleted.
116 file_delete($file);
117 }
118
119 // Either way the module needs to update it's reference since even if the
120 // file is in use by another module and not deleted we no longer want to
121 // use it.
122 variable_set('image_example_image_fid', FALSE);
123 drupal_set_message(t('The image @image_name was removed.', array('@image_name' => $file->filename)));
124 }
125
126 // Save the name of the image style choosen by the user.
127 variable_set('image_example_style_name', $form_state['values']['image_example_style_name']);
128 }
129
135 function theme_image_example_image($variables) {
136 $image = $variables['image'];
137 $style = $variables['style'];
138
139 // theme_image_style() is the primary method for displaying images using
140 // one of the defined styles. The $variables array passed to the theme
141 // contains the following two important values:
142 // 'style_name': the name of the image style to use when displaying the
143 // image.
144 // 'path': the $file->uri of the image to display.
145 // When given a style and an image path the function will first determine
146 // if a derivative image already exists, in which case the existing image
147 // will be displayed. If the derivative image does not already exist the
148 // function returns an <img> tag with a specially crafted callback URL
149 // as the src attribute for the tag. When accessed, the callback URL will
150 // generate the derivative image and serve it to the browser.
151 $output = theme('image_style', array('style_name' => $style, 'path' => $image->uri, 'getsize' => FALSE));
152 $output .= '<p>' . t('This image is being displayed using the image style %style_name.', array('%style_name' => $style)) . '</p>';
153 return $output;
154 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
file_usage_add
file_usage_add(stdClass $file, $module, $type, $id, $count=1)
Definition: file.inc:682
FILE_STATUS_PERMANENT
const FILE_STATUS_PERMANENT
Definition: file.inc:70
image_example_style_form_submit
image_example_style_form_submit($form, &$form_state)
Definition: image_example.pages.inc:79
file_delete
file_delete(stdClass $file, $force=FALSE)
Definition: file.inc:1268
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
image_example_style_form_validate
image_example_style_form_validate($form, &$form_state)
Definition: image_example.pages.inc:68
theme_image_example_image
theme_image_example_image($variables)
Definition: image_example.pages.inc:135
file_load
file_load($fid)
Definition: file.inc:580
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$output
$output
Definition: authorize.php:93
image_style_options
image_style_options($include_empty=TRUE, $output=CHECK_PLAIN)
Definition: image.module:781
file_usage_delete
file_usage_delete(stdClass $file, $module, $type=NULL, $id=NULL, $count=1)
Definition: file.inc:720
image_example_style_form
image_example_style_form($form, &$form_state)
Definition: image_example.pages.inc:21
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
file_save
file_save(stdClass $file)
Definition: file.inc:599
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/statistics/statistics.install Source File

  • modules
  • statistics
statistics.install
Go to the documentation of this file.
1 <?php
2
11 function statistics_uninstall() {
12 // Remove variables.
13 variable_del('statistics_count_content_views');
14 variable_del('statistics_count_content_views_ajax');
15 variable_del('statistics_enable_access_log');
16 variable_del('statistics_flush_accesslog_timer');
17 variable_del('statistics_day_timestamp');
18 variable_del('statistics_block_top_day_num');
19 variable_del('statistics_block_top_all_num');
20 variable_del('statistics_block_top_last_num');
21 }
22
26 function statistics_schema() {
27 $schema['accesslog'] = array(
28 'description' => 'Stores site access information for statistics.',
29 'fields' => array(
30 'aid' => array(
31 'type' => 'serial',
32 'not null' => TRUE,
33 'description' => 'Primary Key: Unique accesslog ID.',
34 ),
35 'sid' => array(
36 'type' => 'varchar',
37 'length' => 128,
38 'not null' => TRUE,
39 'default' => '',
40 'description' => 'Browser session ID of user that visited page.',
41 ),
42 'title' => array(
43 'type' => 'varchar',
44 'length' => 255,
45 'not null' => FALSE,
46 'description' => 'Title of page visited.',
47 ),
48 'path' => array(
49 'type' => 'varchar',
50 'length' => 255,
51 'not null' => FALSE,
52 'description' => 'Internal path to page visited (relative to Drupal root.)',
53 ),
54 'url' => array(
55 'type' => 'text',
56 'not null' => FALSE,
57 'description' => 'Referrer URI.',
58 ),
59 'hostname' => array(
60 'type' => 'varchar',
61 'length' => 128,
62 'not null' => FALSE,
63 'description' => 'Hostname of user that visited the page.',
64 ),
65 'uid' => array(
66 'type' => 'int',
67 'unsigned' => TRUE,
68 'not null' => FALSE,
69 'default' => 0,
70 'description' => 'User {users}.uid that visited the page.',
71 ),
72 'timer' => array(
73 'type' => 'int',
74 'unsigned' => TRUE,
75 'not null' => TRUE,
76 'default' => 0,
77 'description' => 'Time in milliseconds that the page took to load.',
78 ),
79 'timestamp' => array(
80 'type' => 'int',
81 'unsigned' => TRUE,
82 'not null' => TRUE,
83 'default' => 0,
84 'description' => 'Timestamp of when the page was visited.',
85 ),
86 ),
87 'indexes' => array(
88 'accesslog_timestamp' => array('timestamp'),
89 'uid' => array('uid'),
90 ),
91 'primary key' => array('aid'),
92 'foreign keys' => array(
93 'visitor' => array(
94 'table' => 'users',
95 'columns' => array('uid' => 'uid'),
96 ),
97 ),
98 );
99
100 $schema['node_counter'] = array(
101 'description' => 'Access statistics for {node}s.',
102 'fields' => array(
103 'nid' => array(
104 'description' => 'The {node}.nid for these statistics.',
105 'type' => 'int',
106 'not null' => TRUE,
107 'default' => 0,
108 ),
109 'totalcount' => array(
110 'description' => 'The total number of times the {node} has been viewed.',
111 'type' => 'int',
112 'unsigned' => TRUE,
113 'not null' => TRUE,
114 'default' => 0,
115 'size' => 'big',
116 ),
117 'daycount' => array(
118 'description' => 'The total number of times the {node} has been viewed today.',
119 'type' => 'int',
120 'unsigned' => TRUE,
121 'not null' => TRUE,
122 'default' => 0,
123 'size' => 'medium',
124 ),
125 'timestamp' => array(
126 'description' => 'The most recent time the {node} has been viewed.',
127 'type' => 'int',
128 'unsigned' => TRUE,
129 'not null' => TRUE,
130 'default' => 0,
131 ),
132 ),
133 'primary key' => array('nid'),
134 );
135
136 return $schema;
137 }
138
147 function statistics_update_7000() {
148 db_change_field('accesslog', 'sid', 'sid', array(
149 'type' => 'varchar',
150 'length' => 128,
151 'not null' => TRUE,
152 'default' => '',
153 'description' => 'Browser session ID of user that visited page.',
154 ));
155 }
156
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
statistics_uninstall
statistics_uninstall()
Definition: statistics.install:11
statistics_update_7000
statistics_update_7000()
Definition: statistics.install:147
statistics_schema
statistics_schema()
Definition: statistics.install:26
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/date.inc Source File

  • includes
date.inc
Go to the documentation of this file.
1 <?php
2
11 function system_default_date_formats() {
12 $formats = array();
13
14 // Short date formats.
15 $formats[] = array(
16 'type' => 'short',
17 'format' => 'Y-m-d H:i',
18 'locales' => array(),
19 );
20 $formats[] = array(
21 'type' => 'short',
22 'format' => 'm/d/Y - H:i',
23 'locales' => array('en-us'),
24 );
25 $formats[] = array(
26 'type' => 'short',
27 'format' => 'd/m/Y - H:i',
28 'locales' => array('en-gb', 'en-hk', 'en-ie', 'el-gr', 'es-es', 'fr-be', 'fr-fr', 'fr-lu', 'it-it', 'nl-be', 'pt-pt'),
29 );
30 $formats[] = array(
31 'type' => 'short',
32 'format' => 'Y/m/d - H:i',
33 'locales' => array('en-ca', 'fr-ca', 'no-no', 'sv-se'),
34 );
35 $formats[] = array(
36 'type' => 'short',
37 'format' => 'd.m.Y - H:i',
38 'locales' => array('de-ch', 'de-de', 'de-lu', 'fi-fi', 'fr-ch', 'is-is', 'pl-pl', 'ro-ro', 'ru-ru'),
39 );
40 $formats[] = array(
41 'type' => 'short',
42 'format' => 'm/d/Y - g:ia',
43 'locales' => array(),
44 );
45 $formats[] = array(
46 'type' => 'short',
47 'format' => 'd/m/Y - g:ia',
48 'locales' => array(),
49 );
50 $formats[] = array(
51 'type' => 'short',
52 'format' => 'Y/m/d - g:ia',
53 'locales' => array(),
54 );
55 $formats[] = array(
56 'type' => 'short',
57 'format' => 'M j Y - H:i',
58 'locales' => array(),
59 );
60 $formats[] = array(
61 'type' => 'short',
62 'format' => 'j M Y - H:i',
63 'locales' => array(),
64 );
65 $formats[] = array(
66 'type' => 'short',
67 'format' => 'Y M j - H:i',
68 'locales' => array(),
69 );
70 $formats[] = array(
71 'type' => 'short',
72 'format' => 'M j Y - g:ia',
73 'locales' => array(),
74 );
75 $formats[] = array(
76 'type' => 'short',
77 'format' => 'j M Y - g:ia',
78 'locales' => array(),
79 );
80 $formats[] = array(
81 'type' => 'short',
82 'format' => 'Y M j - g:ia',
83 'locales' => array(),
84 );
85
86 // Medium date formats.
87 $formats[] = array(
88 'type' => 'medium',
89 'format' => 'D, Y-m-d H:i',
90 'locales' => array(),
91 );
92 $formats[] = array(
93 'type' => 'medium',
94 'format' => 'D, m/d/Y - H:i',
95 'locales' => array('en-us'),
96 );
97 $formats[] = array(
98 'type' => 'medium',
99 'format' => 'D, d/m/Y - H:i',
100 'locales' => array('en-gb', 'en-hk', 'en-ie', 'el-gr', 'es-es', 'fr-be', 'fr-fr', 'fr-lu', 'it-it', 'nl-be', 'pt-pt'),
101 );
102 $formats[] = array(
103 'type' => 'medium',
104 'format' => 'D, Y/m/d - H:i',
105 'locales' => array('en-ca', 'fr-ca', 'no-no', 'sv-se'),
106 );
107 $formats[] = array(
108 'type' => 'medium',
109 'format' => 'F j, Y - H:i',
110 'locales' => array(),
111 );
112 $formats[] = array(
113 'type' => 'medium',
114 'format' => 'j F, Y - H:i',
115 'locales' => array(),
116 );
117 $formats[] = array(
118 'type' => 'medium',
119 'format' => 'Y, F j - H:i',
120 'locales' => array(),
121 );
122 $formats[] = array(
123 'type' => 'medium',
124 'format' => 'D, m/d/Y - g:ia',
125 'locales' => array(),
126 );
127 $formats[] = array(
128 'type' => 'medium',
129 'format' => 'D, d/m/Y - g:ia',
130 'locales' => array(),
131 );
132 $formats[] = array(
133 'type' => 'medium',
134 'format' => 'D, Y/m/d - g:ia',
135 'locales' => array(),
136 );
137 $formats[] = array(
138 'type' => 'medium',
139 'format' => 'F j, Y - g:ia',
140 'locales' => array(),
141 );
142 $formats[] = array(
143 'type' => 'medium',
144 'format' => 'j F Y - g:ia',
145 'locales' => array(),
146 );
147 $formats[] = array(
148 'type' => 'medium',
149 'format' => 'Y, F j - g:ia',
150 'locales' => array(),
151 );
152 $formats[] = array(
153 'type' => 'medium',
154 'format' => 'j. F Y - G:i',
155 'locales' => array(),
156 );
157
158 // Long date formats.
159 $formats[] = array(
160 'type' => 'long',
161 'format' => 'l, F j, Y - H:i',
162 'locales' => array(),
163 );
164 $formats[] = array(
165 'type' => 'long',
166 'format' => 'l, j F, Y - H:i',
167 'locales' => array(),
168 );
169 $formats[] = array(
170 'type' => 'long',
171 'format' => 'l, Y, F j - H:i',
172 'locales' => array(),
173 );
174 $formats[] = array(
175 'type' => 'long',
176 'format' => 'l, F j, Y - g:ia',
177 'locales' => array(),
178 );
179 $formats[] = array(
180 'type' => 'long',
181 'format' => 'l, j F Y - g:ia',
182 'locales' => array(),
183 );
184 $formats[] = array(
185 'type' => 'long',
186 'format' => 'l, Y, F j - g:ia',
187 'locales' => array(),
188 );
189 $formats[] = array(
190 'type' => 'long',
191 'format' => 'l, j. F Y - G:i',
192 'locales' => array(),
193 );
194
195 return $formats;
196 }
system_default_date_formats
system_default_date_formats()
Definition: date.inc:11
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/dashboard/dashboard.module Source File

  • modules
  • dashboard
dashboard.module
Go to the documentation of this file.
1 <?php
10 function dashboard_help($path, $arg) {
11 switch ($path) {
12 case 'admin/help#dashboard':
13 $output = '';
14 $output .= '<h3>' . t('About') . '</h3>';
15 $output .= '<p>' . t('The Dashboard module provides a <a href="@dashboard">Dashboard page</a> in the administrative interface for organizing administrative tasks and navigation, and tracking information within your site. The Dashboard page contains blocks, which you can add to and arrange using the drag-and-drop interface that appears when you click on the <em>Customize dashboard</em> link. Within this interface, blocks that are not primarily used for site administration do not appear by default, but can be added via the <em>Add other blocks</em> link. For more information, see the online handbook entry for <a href="@handbook">Dashboard module</a>.', array('@handbook' => 'http://drupal.org/documentation/modules/dashboard', '@dashboard' => url('admin/dashboard'))) . '</p>';
16 $output .= '<h3>' . t('Uses') . '</h3>';
17 $output .= '<dl>';
18 $output .= '<dt>' . t('Tracking user activity') . '</dt>';
19 $output .= '<dd>' . t("By enabling blocks such as <em>Who's online</em> and <em>Who's new</em>, site users can track who is logged in and new user signups at a centralized location.") . '</dd>';
20 $output .= '<dt>' . t('Tracking content activity') . '</dt>';
21 $output .= '<dd>' . t('By enabling blocks such as <em>Recent blog posts</em>, <em>New forum topics</em> and <em>Recent comments</em>, site users can view newly added site content at a glance.') . '</dd>';
22 $output .= '</dl>';
23 return $output;
24
25 case 'admin/dashboard/configure':
26 // @todo This assumes the current page is being displayed using the same
27 // theme that the dashboard is displayed in.
28 $output = '<p>' . t('Rearrange blocks for display on the <a href="@dashboard-url">Dashboard page</a>. Blocks placed in the <em>Dashboard (inactive)</em> region are not displayed when viewing the Dashboard page, but are available within its <em>Customize dashboard</em> interface. Removing a block from active dashboard display makes it available on the main <a href="@blocks-url">blocks administration page</a>.', array('@dashboard-url' => url('admin/dashboard'), '@blocks-url' => url("admin/structure/block/list/{$GLOBALS['theme_key']}"))) . '</p>';
29 return $output;
30 }
31 }
32
36 function dashboard_menu() {
37 $items['admin/dashboard'] = array(
38 'title' => 'Dashboard',
39 'description' => 'View and customize your dashboard.',
40 'page callback' => 'dashboard_admin',
41 'access arguments' => array('access dashboard'),
42 // Make this appear first, so for example, in admin menus, it shows up on
43 // the top corner of the window as a convenient "home link".
44 'weight' => -15,
45 );
46 $items['admin/dashboard/configure'] = array(
47 'title' => 'Configure available dashboard blocks',
48 'description' => 'Configure which blocks can be shown on the dashboard.',
49 'page callback' => 'dashboard_admin_blocks',
50 'access arguments' => array('administer blocks'),
51 'type' => MENU_VISIBLE_IN_BREADCRUMB,
52 );
53 $items['admin/dashboard/customize'] = array(
54 'title' => 'Customize dashboard',
55 'description' => 'Customize your dashboard.',
56 'page callback' => 'dashboard_admin',
57 'page arguments' => array(TRUE),
58 'access arguments' => array('access dashboard'),
59 'type' => MENU_VISIBLE_IN_BREADCRUMB,
60 );
61 $items['admin/dashboard/drawer'] = array(
62 'page callback' => 'dashboard_show_disabled',
63 'access arguments' => array('administer blocks'),
64 'type' => MENU_CALLBACK,
65 );
66 $items['admin/dashboard/block-content/%/%'] = array(
67 'page callback' => 'dashboard_show_block_content',
68 'page arguments' => array(3, 4),
69 'access arguments' => array('administer blocks'),
70 'type' => MENU_CALLBACK,
71 );
72 $items['admin/dashboard/update'] = array(
73 'page callback' => 'dashboard_update',
74 'access arguments' => array('administer blocks'),
75 'type' => MENU_CALLBACK,
76 );
77
78 return $items;
79 }
80
84 function dashboard_permission() {
85 return array(
86 'access dashboard' => array(
87 'title' => t('View the administrative dashboard'),
88 // Note: We translate the 'Administer blocks' permission string here with
89 // a separate t() call, to make sure it gets the same translation as when
90 // it's in block_permission().
91 'description' => t('Customizing the dashboard requires the !permission-name permission.', array(
92 '!permission-name' => l(t('Administer blocks'), 'admin/people/permissions', array('fragment' => 'module-block')),
93 )),
94 ),
95 );
96 }
97
101 function dashboard_block_info_alter(&$blocks, $theme, $code_blocks) {
102 $admin_theme = variable_get('admin_theme');
103 if (($admin_theme && $theme == $admin_theme) || (!$admin_theme && $theme == variable_get('theme_default', 'bartik'))) {
104 foreach ($blocks as $module => &$module_blocks) {
105 foreach ($module_blocks as $delta => &$block) {
106 // Make administrative blocks that are not already in use elsewhere
107 // available for the dashboard.
108 if (empty($block['status']) && (empty($block['region']) || $block['region'] == BLOCK_REGION_NONE) && !empty($code_blocks[$module][$delta]['properties']['administrative'])) {
109 $block['status'] = 1;
110 $block['region'] = 'dashboard_inactive';
111 }
112 }
113 }
114 }
115 }
116
124 function dashboard_block_list_alter(&$blocks) {
125 if (!dashboard_is_visible()) {
126 foreach ($blocks as $key => $block) {
127 if (in_array($block->region, dashboard_regions())) {
128 unset($blocks[$key]);
129 }
130 }
131 }
132 }
133
139 function dashboard_page_build(&$page) {
140 global $theme_key;
141
142 if (dashboard_is_visible()) {
143 $block_info = array();
144
145 // Create a wrapper for the dashboard itself, then insert each dashboard
146 // region into it.
147 $page['content']['dashboard'] = array('#theme_wrappers' => array('dashboard'));
148 foreach (dashboard_regions() as $region) {
149 // Do not show dashboard blocks that are disabled.
150 if ($region == 'dashboard_inactive') {
151 continue;
152 }
153 // Insert regions even when they are empty, so that they will be
154 // displayed when the dashboard is being configured.
155 $page['content']['dashboard'][$region] = !empty($page[$region]) ? $page[$region] : array();
156 $page['content']['dashboard'][$region]['#dashboard_region'] = $region;
157 // Allow each dashboard region to be themed differently, or fall back on
158 // the generic theme wrapper function for dashboard regions.
159 $page['content']['dashboard'][$region]['#theme_wrappers'][] = array($region, 'dashboard_region');
160 unset($page[$region]);
161 $blocks_found = array();
162 foreach ($page['content']['dashboard'][$region] as $item) {
163 if (isset($item['#theme_wrappers']) && is_array($item['#theme_wrappers']) && in_array('block', $item['#theme_wrappers'])) {
164 // If this item is a block, ensure it has a subject.
165 if (empty($item['#block']->subject)) {
166 // Locally cache info data for the object for all blocks, in case
167 // we find a block similarly missing title from the same module.
168 if (!isset($block_info[$item['#block']->module])) {
169 $block_info[$item['#block']->module] = module_invoke($item['#block']->module, 'block_info');
170 }
171 $item['#block']->subject = $block_info[$item['#block']->module][$item['#block']->delta]['info'];
172 }
173 $blocks_found[$item['#block']->module . '_' . $item['#block']->delta] = TRUE;
174 }
175 }
176
177 // Find blocks which were not yet displayed on the page (were empty), and
178 // add placeholder items in their place for rendering.
179 $block_list = db_select('block')
180 ->condition('theme', $theme_key)
181 ->condition('status', 1)
182 ->condition('region', $region)
183 ->fields('block')
184 ->execute();
185 foreach ($block_list as $block) {
186 if (!isset($blocks_found[$block->module . '_' . $block->delta])) {
187 $block->enabled = $block->page_match = TRUE;
188 $block->content = array('#markup' => '<div class="dashboard-block-empty">(empty)</div>');
189 if (!isset($block_info[$block->module])) {
190 $block_info[$block->module] = module_invoke($block->module, 'block_info');
191 }
192 $block->subject = t('@title', array('@title' => $block_info[$block->module][$block->delta]['info']));
193 $block_render = array($block->module . '_' . $block->delta => $block);
194 $build = _block_get_renderable_array($block_render);
195 $page['content']['dashboard'][$block->region][] = $build;
196 }
197 }
198 }
199 }
200 }
201
207 function dashboard_system_info_alter(&$info, $file, $type) {
208 if ($type == 'theme') {
209 // Add the dashboard regions (the "inactive" region should always appear
210 // last in the list, for usability reasons).
211 $dashboard_regions = dashboard_region_descriptions();
212 if (isset($dashboard_regions['dashboard_inactive'])) {
213 $inactive_region = $dashboard_regions['dashboard_inactive'];
214 unset($dashboard_regions['dashboard_inactive']);
215 $dashboard_regions['dashboard_inactive'] = $inactive_region;
216 }
217 $info['regions'] += $dashboard_regions;
218 // Indicate that these regions are intended to be displayed whenever the
219 // dashboard is displayed in an overlay. This information is provided for
220 // any module that might need to use it, not just the core Overlay module.
221 $info['overlay_regions'] = !empty($info['overlay_regions']) ? array_merge($info['overlay_regions'], dashboard_regions()) : dashboard_regions();
222 }
223 }
224
228 function dashboard_theme() {
229 return array(
230 'dashboard' => array(
231 'render element' => 'element',
232 ),
233 'dashboard_admin' => array(
234 'render element' => 'element',
235 ),
236 'dashboard_region' => array(
237 'render element' => 'element',
238 ),
239 'dashboard_disabled_blocks' => array(
240 'variables' => array('blocks' => NULL),
241 ),
242 'dashboard_disabled_block' => array(
243 'variables' => array('block' => NULL),
244 ),
245 'dashboard_admin_display_form' => array(
246 // When building the form for configuring dashboard blocks, reuse the
247 // Block module's template for the main block configuration form.
248 'template' => 'block-admin-display-form',
249 'path' => drupal_get_path('module', 'block'),
250 'file' => 'block.admin.inc',
251 'render element' => 'form',
252 ),
253 );
254 }
255
259 function dashboard_forms() {
260 // Reroute the dashboard configuration form to the main blocks administration
261 // form. This allows us to distinguish them by form ID in hook_form_alter().
262 $forms['dashboard_admin_display_form'] = array(
263 'callback' => 'block_admin_display_form',
264 );
265
266 return $forms;
267 }
268
275 function dashboard_admin($launch_customize = FALSE) {
276 $js_settings = array(
277 'dashboard' => array(
278 'drawer' => url('admin/dashboard/drawer'),
279 'blockContent' => url('admin/dashboard/block-content'),
280 'updatePath' => url('admin/dashboard/update'),
281 'formToken' => drupal_get_token('dashboard-update'),
282 'launchCustomize' => $launch_customize,
283 'dashboard' => url('admin/dashboard'),
284 'emptyBlockText' => t('(empty)'),
285 'emptyRegionTextInactive' => t('This dashboard region is empty. Click <em>Customize dashboard</em> to add blocks to it.'),
286 'emptyRegionTextActive' => t('DRAG HERE'),
287 ),
288 );
289 $build = array(
290 '#theme' => 'dashboard_admin',
291 '#message' => t('To customize the dashboard page, move blocks to the dashboard regions on the <a href="@dashboard">Dashboard administration page</a>, or enable JavaScript on this page to use the drag-and-drop interface.', array('@dashboard' => url('admin/dashboard/configure'))),
292 '#access' => user_access('administer blocks'),
293 '#attached' => array(
294 'js' => array(
295 drupal_get_path('module', 'dashboard') . '/dashboard.js',
296 array('data' => $js_settings, 'type' => 'setting'),
297 ),
298 'library' => array(array('system', 'ui.sortable')),
299 ),
300 );
301 return $build;
302 }
303
315 function dashboard_admin_blocks() {
316 global $theme_key;
317 drupal_theme_initialize();
318 module_load_include('inc', 'block', 'block.admin');
319
320 // Prepare the blocks for the current theme, and remove those that are
321 // currently displayed in non-dashboard regions.
322 // @todo This assumes the current page is being displayed using the same
323 // theme that the dashboard is displayed in.
324 $blocks = block_admin_display_prepare_blocks($theme_key);
325 $dashboard_regions = dashboard_region_descriptions();
326 $regions_to_remove = array_diff_key(system_region_list($theme_key, REGIONS_VISIBLE), $dashboard_regions);
327 foreach ($blocks as $id => $block) {
328 if (isset($regions_to_remove[$block['region']])) {
329 unset($blocks[$id]);
330 }
331 }
332
333 // Pass in the above blocks and dashboard regions to the form, so that only
334 // dashboard-related regions will be displayed.
335 return drupal_get_form('dashboard_admin_display_form', $blocks, $theme_key, $dashboard_regions);
336 }
337
341 function dashboard_form_block_admin_display_form_alter(&$form, &$form_state, $form_id) {
342 // Hide dashboard regions (and any blocks placed within them) from the block
343 // administration form and from the options list on that form. This
344 // function is called for both the dashboard block configuration form and the
345 // standard block configuration form so that both forms can share the same
346 // constructor. As a result the form_id must be checked.
347 if ($form_id != 'dashboard_admin_display_form') {
348 $dashboard_regions = dashboard_region_descriptions();
349 $form['block_regions']['#value'] = array_diff_key($form['block_regions']['#value'], $dashboard_regions);
350 foreach (element_children($form['blocks']) as $i) {
351 $block = &$form['blocks'][$i];
352 if (isset($block['region']['#default_value']) && isset($dashboard_regions[$block['region']['#default_value']]) && $block['region']['#default_value'] != 'dashboard_inactive') {
353 $block['#access'] = FALSE;
354 }
355 elseif (isset($block['region']['#options'])) {
356 $block['region']['#options'] = array_diff_key($block['region']['#options'], $dashboard_regions);
357 }
358 // Show inactive dashboard blocks as disabled on the main block
359 // administration form, so that they are available to place in other
360 // regions of the theme. Note that when the form is submitted, any such
361 // blocks which still remain disabled will immediately be put back in the
362 // 'dashboard_inactive' region, because dashboard_block_info_alter() is
363 // called when the blocks are rehashed. Fortunately, this is the exact
364 // behavior we want.
365 if ($block['region']['#default_value'] == 'dashboard_inactive') {
366 // @todo These do not wind up in correct alphabetical order.
367 $block['region']['#default_value'] = NULL;
368 }
369 }
370 }
371 }
372
376 function dashboard_form_dashboard_admin_display_form_alter(&$form, &$form_state) {
377 // Redirect the 'configure' and 'delete' links on each block back to the
378 // dashboard blocks administration page.
379 foreach ($form['blocks'] as &$block) {
380 if (isset($block['configure']['#href'])) {
381 $block['configure']['#options']['query']['destination'] = 'admin/dashboard/configure';
382 }
383 if (isset($block['delete']['#href'])) {
384 $block['delete']['#options']['query']['destination'] = 'admin/dashboard/configure';
385 }
386 }
387 }
388
392 function dashboard_form_block_admin_configure_alter(&$form, &$form_state) {
393 global $theme_key;
394 drupal_theme_initialize();
395 // Hide the dashboard regions from the region select list on the block
396 // configuration form, for all themes except the current theme (since the
397 // other themes do not display the dashboard).
398 // @todo This assumes the current page is being displayed using the same
399 // theme that the dashboard is displayed in.
400 $dashboard_regions = dashboard_region_descriptions();
401 foreach (element_children($form['regions']) as $region_name) {
402 $region = &$form['regions'][$region_name];
403 if ($region_name != $theme_key && isset($region['#options'])) {
404 $region['#options'] = array_diff_key($region['#options'], $dashboard_regions);
405 }
406 }
407 }
408
412 function dashboard_form_block_add_block_form_alter(&$form, &$form_state) {
413 dashboard_form_block_admin_configure_alter($form, $form_state);
414 }
415
419 function template_preprocess_dashboard_admin_display_form(&$variables) {
420 template_preprocess_block_admin_display_form($variables);
421 if (isset($variables['block_regions'][BLOCK_REGION_NONE])) {
422 $variables['block_regions'][BLOCK_REGION_NONE] = t('Other blocks');
423 }
424 }
425
448 function dashboard_is_visible() {
449 static $is_visible;
450 if (!isset($is_visible)) {
451 // If the current menu item represents the page on which we want to display
452 // the dashboard, and if the current user has access to see it, return
453 // TRUE.
454 $menu_item = menu_get_item();
455 $is_visible = isset($menu_item['page_callback']) && $menu_item['page_callback'] == 'dashboard_admin' && !empty($menu_item['access']);
456 }
457 return $is_visible;
458 }
459
463 function dashboard_region_descriptions() {
464 $regions = module_invoke_all('dashboard_regions');
465 drupal_alter('dashboard_regions', $regions);
466 return $regions;
467 }
468
472 function dashboard_regions() {
473 $regions = &drupal_static(__FUNCTION__);
474 if (!isset($regions)) {
475 $regions = array_keys(dashboard_region_descriptions());
476 }
477 return $regions;
478 }
479
483 function dashboard_dashboard_regions() {
484 return array(
485 'dashboard_main' => 'Dashboard (main)',
486 'dashboard_sidebar' => 'Dashboard (sidebar)',
487 'dashboard_inactive' => 'Dashboard (inactive)',
488 );
489 }
490
494 function dashboard_show_disabled() {
495 global $theme_key;
496
497 // Blocks are not necessarily initialized at this point.
498 $blocks = _block_rehash();
499
500 // Limit the list to blocks that are marked as disabled for the dashboard.
501 foreach ($blocks as $key => $block) {
502 if ($block['theme'] != $theme_key || $block['region'] != 'dashboard_inactive') {
503 unset($blocks[$key]);
504 }
505 }
506
507 // Theme the output and end the page request.
508 print theme('dashboard_disabled_blocks', array('blocks' => $blocks));
509 drupal_exit();
510 }
511
520 function dashboard_show_block_content($module, $delta) {
521 drupal_theme_initialize();
522 global $theme_key;
523
524 $blocks = array();
525 $block_object = db_query("SELECT * FROM {block} WHERE theme = :theme AND module = :module AND delta = :delta", array(
526 ":theme" => $theme_key,
527 ":module" => $module,
528 ":delta" => $delta,
529 ))
530 ->fetchObject();
531 $block_object->enabled = $block_object->page_match = TRUE;
532 $blocks[$module . "_" . $delta] = $block_object;
533 $block_content = _block_render_blocks($blocks);
534 $build = _block_get_renderable_array($block_content);
535 $rendered_block = drupal_render($build);
536 print $rendered_block;
537 drupal_exit();
538 }
539
543 function dashboard_update() {
544 drupal_theme_initialize();
545 global $theme_key;
546 // Check the form token to make sure we have a valid request.
547 if (!empty($_REQUEST['form_token']) && drupal_valid_token($_REQUEST['form_token'], 'dashboard-update')) {
548 parse_str($_REQUEST['regions'], $regions);
549 foreach ($regions as $region_name => $blocks) {
550 if ($region_name == 'disabled_blocks') {
551 $region_name = 'dashboard_inactive';
552 }
553 foreach ($blocks as $weight => $block_string) {
554 // Parse the query string to determine the block's module and delta.
555 preg_match('/block-([^-]+)-(.+)/', $block_string, $matches);
556 $block = new stdClass();
557 $block->module = $matches[1];
558 $block->delta = $matches[2];
559
560 $block->region = $region_name;
561 $block->weight = $weight;
562 $block->status = 1;
563
564 db_merge('block')
565 ->key(array(
566 'module' => $block->module,
567 'delta' => $block->delta,
568 'theme' => $theme_key,
569 ))
570 ->fields(array(
571 'status' => $block->status,
572 'weight' => $block->weight,
573 'region' => $block->region,
574 'pages' => '',
575 ))
576 ->execute();
577 }
578 }
579 drupal_set_message(t('The configuration options have been saved.'), 'status', FALSE);
580 }
581 drupal_exit();
582 }
583
594 function theme_dashboard($variables) {
595 extract($variables);
596 drupal_add_css(drupal_get_path('module', 'dashboard') . '/dashboard.css');
597 return '<div id="dashboard" class="clearfix">' . $element['#children'] . '</div>';
598 }
599
609 function theme_dashboard_admin($variables) {
610 // We only return a simple help message, since the actual content of the page
611 // will be populated via the dashboard regions in dashboard_page_build().
612 return '<div class="customize-dashboard js-hide">' . $variables['element']['#message'] . '</div>';
613 }
614
625 function theme_dashboard_region($variables) {
626 extract($variables);
627 $output = '<div id="' . $element['#dashboard_region'] . '" class="dashboard-region">';
628 $output .= '<div class="region clearfix">';
629 $output .= $element['#children'];
630 // Closing div.region
631 $output .= '</div>';
632 // Closing div.dashboard-region
633 $output .= '</div>';
634 return $output;
635 }
636
646 function theme_dashboard_disabled_blocks($variables) {
647 extract($variables);
648 $output = '<div class="canvas-content"><p>' . t('Drag and drop these blocks to the columns below. Changes are automatically saved. More options are available on the <a href="@dashboard-url">configuration page</a>.', array('@dashboard-url' => url('admin/dashboard/configure'))) . '</p>';
649 $output .= '<div id="disabled-blocks"><div class="region disabled-blocks clearfix">';
650 foreach ($blocks as $block) {
651 $output .= theme('dashboard_disabled_block', array('block' => $block));
652 }
653 $output .= '<div class="clearfix"></div>';
654 $output .= '<p class="dashboard-add-other-blocks">' . l(t('Add other blocks'), 'admin/dashboard/configure') . '</p>';
655 $output .= '</div></div></div>';
656 return $output;
657 }
658
668 function theme_dashboard_disabled_block($variables) {
669 extract($variables);
670 $output = "";
671 if (isset($block)) {
672 $output .= '<div id="block-' . $block['module'] . '-' . $block['delta']
673 . '" class="disabled-block block block-' . $block['module'] . '-' . $block['delta']
674 . ' module-' . $block['module'] . ' delta-' . $block['delta'] . '">'
675 . '<h2>' . (!empty($block['title']) && $block['title'] != '<none>' ? check_plain($block['title']) : check_plain($block['info'])) . '</h2>'
676 . '<div class="content"></div>'
677 . '</div>';
678 }
679 return $output;
680 }
681
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
dashboard_help
dashboard_help($path, $arg)
Definition: dashboard.module:10
theme_dashboard_disabled_block
theme_dashboard_disabled_block($variables)
Definition: dashboard.module:668
dashboard_forms
dashboard_forms()
Definition: dashboard.module:259
menu_get_item
menu_get_item($path=NULL, $router_item=NULL)
Definition: menu.inc:447
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
dashboard_system_info_alter
dashboard_system_info_alter(&$info, $file, $type)
Definition: dashboard.module:207
dashboard_dashboard_regions
dashboard_dashboard_regions()
Definition: dashboard.module:483
$module
print $module
Definition: search-results.tpl.php:28
dashboard_form_dashboard_admin_display_form_alter
dashboard_form_dashboard_admin_display_form_alter(&$form, &$form_state)
Definition: dashboard.module:376
$page
print $page
Definition: overlay.tpl.php:37
dashboard_permission
dashboard_permission()
Definition: dashboard.module:84
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
template_preprocess_block_admin_display_form
template_preprocess_block_admin_display_form(&$variables)
Definition: block.admin.inc:662
theme_dashboard_region
theme_dashboard_region($variables)
Definition: dashboard.module:625
dashboard_block_list_alter
dashboard_block_list_alter(&$blocks)
Definition: dashboard.module:124
dashboard_regions
dashboard_regions()
Definition: dashboard.module:472
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
print
print
Definition: php-2.php:2
dashboard_theme
dashboard_theme()
Definition: dashboard.module:228
theme_dashboard_disabled_blocks
theme_dashboard_disabled_blocks($variables)
Definition: dashboard.module:646
dashboard_form_block_add_block_form_alter
dashboard_form_block_add_block_form_alter(&$form, &$form_state)
Definition: dashboard.module:412
dashboard_page_build
dashboard_page_build(&$page)
Definition: dashboard.module:139
_block_render_blocks
_block_render_blocks($region_blocks)
Definition: block.module:850
theme_dashboard
theme_dashboard($variables)
Definition: dashboard.module:594
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
dashboard_is_visible
dashboard_is_visible()
Definition: dashboard.module:448
dashboard_update
dashboard_update()
Definition: dashboard.module:543
dashboard_form_block_admin_display_form_alter
dashboard_form_block_admin_display_form_alter(&$form, &$form_state, $form_id)
Definition: dashboard.module:341
drupal_valid_token
drupal_valid_token($token, $value= '', $skip_anonymous=FALSE)
Definition: common.inc:5095
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
_block_rehash
_block_rehash($theme=NULL)
Definition: block.module:369
theme_dashboard_admin
theme_dashboard_admin($variables)
Definition: dashboard.module:609
$info
$info
Definition: color.inc:6
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
system_region_list
system_region_list($theme_key, $show=REGIONS_ALL)
Definition: system.module:2689
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
dashboard_form_block_admin_configure_alter
dashboard_form_block_admin_configure_alter(&$form, &$form_state)
Definition: dashboard.module:392
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
dashboard_admin
dashboard_admin($launch_customize=FALSE)
Definition: dashboard.module:275
dashboard_show_disabled
dashboard_show_disabled()
Definition: dashboard.module:494
block_admin_display_prepare_blocks
block_admin_display_prepare_blocks($theme)
Definition: block.admin.inc:51
dashboard_region_descriptions
dashboard_region_descriptions()
Definition: dashboard.module:463
MENU_VISIBLE_IN_BREADCRUMB
const MENU_VISIBLE_IN_BREADCRUMB
Definition: menu.inc:96
drupal_theme_initialize
drupal_theme_initialize()
Definition: theme.inc:70
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
dashboard_menu
dashboard_menu()
Definition: dashboard.module:36
_block_get_renderable_array
_block_get_renderable_array($list=array())
Definition: block.module:333
drupal_exit
drupal_exit($destination=NULL)
Definition: common.inc:2721
BLOCK_REGION_NONE
const BLOCK_REGION_NONE
Definition: block.module:11
drupal_get_token
drupal_get_token($value= '')
Definition: common.inc:5077
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
template_preprocess_dashboard_admin_display_form
template_preprocess_dashboard_admin_display_form(&$variables)
Definition: dashboard.module:419
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
REGIONS_VISIBLE
const REGIONS_VISIBLE
Definition: system.module:60
dashboard_show_block_content
dashboard_show_block_content($module, $delta)
Definition: dashboard.module:520
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
dashboard_block_info_alter
dashboard_block_info_alter(&$blocks, $theme, $code_blocks)
Definition: dashboard.module:101
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
dashboard_admin_blocks
dashboard_admin_blocks()
Definition: dashboard.module:315
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum.admin.inc Source File

  • modules
  • forum
forum.admin.inc
Go to the documentation of this file.
1 <?php
2
22 function forum_form_main($type, $edit = array()) {
23 $edit = (array) $edit;
24 if ((isset($_POST['op']) && $_POST['op'] == t('Delete')) || !empty($_POST['confirm'])) {
25 return drupal_get_form('forum_confirm_delete', $edit['tid']);
26 }
27 switch ($type) {
28 case 'forum':
29 return drupal_get_form('forum_form_forum', $edit);
30 break;
31 case 'container':
32 return drupal_get_form('forum_form_container', $edit);
33 break;
34 }
35 }
36
47 function forum_form_forum($form, &$form_state, $edit = array()) {
48 $edit += array(
49 'name' => '',
50 'description' => '',
51 'tid' => NULL,
52 'weight' => 0,
53 );
54 $form['name'] = array('#type' => 'textfield',
55 '#title' => t('Forum name'),
56 '#default_value' => $edit['name'],
57 '#maxlength' => 255,
58 '#description' => t('Short but meaningful name for this collection of threaded discussions.'),
59 '#required' => TRUE,
60 );
61 $form['description'] = array('#type' => 'textarea',
62 '#title' => t('Description'),
63 '#default_value' => $edit['description'],
64 '#description' => t('Description and guidelines for discussions within this forum.'),
65 );
66 $form['parent']['#tree'] = TRUE;
67 $form['parent'][0] = _forum_parent_select($edit['tid'], t('Parent'), 'forum');
68 $form['weight'] = array('#type' => 'weight',
69 '#title' => t('Weight'),
70 '#default_value' => $edit['weight'],
71 '#description' => t('Forums are displayed in ascending order by weight (forums with equal weights are displayed alphabetically).'),
72 );
73
74 $form['vid'] = array('#type' => 'hidden', '#value' => variable_get('forum_nav_vocabulary', ''));
75 $form['actions'] = array('#type' => 'actions');
76 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
77 if ($edit['tid']) {
78 $form['actions']['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
79 $form['tid'] = array('#type' => 'hidden', '#value' => $edit['tid']);
80 }
81 $form['#submit'][] = 'forum_form_submit';
82 $form['#theme'] = 'forum_form';
83
84 return $form;
85 }
86
90 function forum_form_submit($form, &$form_state) {
91 if ($form['form_id']['#value'] == 'forum_form_container') {
92 $container = TRUE;
93 $type = t('forum container');
94 }
95 else {
96 $container = FALSE;
97 $type = t('forum');
98 }
99
100 $term = (object) $form_state['values'];
101 $status = taxonomy_term_save($term);
102 switch ($status) {
103 case SAVED_NEW:
104 if ($container) {
105 $containers = variable_get('forum_containers', array());
106 $containers[] = $term->tid;
107 variable_set('forum_containers', $containers);
108 }
109 $form_state['values']['tid'] = $term->tid;
110 drupal_set_message(t('Created new @type %term.', array('%term' => $form_state['values']['name'], '@type' => $type)));
111 break;
112 case SAVED_UPDATED:
113 drupal_set_message(t('The @type %term has been updated.', array('%term' => $form_state['values']['name'], '@type' => $type)));
114 // Clear the page and block caches to avoid stale data.
115 cache_clear_all();
116 break;
117 }
118 $form_state['redirect'] = 'admin/structure/forum';
119 return;
120 }
121
134 function theme_forum_form($variables) {
135 return drupal_render_children($variables['form']);
136 }
137
148 function forum_form_container($form, &$form_state, $edit = array()) {
149 $edit += array(
150 'name' => '',
151 'description' => '',
152 'tid' => NULL,
153 'weight' => 0,
154 );
155 // Handle a delete operation.
156 $form['name'] = array(
157 '#title' => t('Container name'),
158 '#type' => 'textfield',
159 '#default_value' => $edit['name'],
160 '#maxlength' => 255,
161 '#description' => t('Short but meaningful name for this collection of related forums.'),
162 '#required' => TRUE
163 );
164
165 $form['description'] = array(
166 '#type' => 'textarea',
167 '#title' => t('Description'),
168 '#default_value' => $edit['description'],
169 '#description' => t('Description and guidelines for forums within this container.')
170 );
171 $form['parent']['#tree'] = TRUE;
172 $form['parent'][0] = _forum_parent_select($edit['tid'], t('Parent'), 'container');
173 $form['weight'] = array(
174 '#type' => 'weight',
175 '#title' => t('Weight'),
176 '#default_value' => $edit['weight'],
177 '#description' => t('Containers are displayed in ascending order by weight (containers with equal weights are displayed alphabetically).')
178 );
179
180 $form['vid'] = array(
181 '#type' => 'hidden',
182 '#value' => variable_get('forum_nav_vocabulary', ''),
183 );
184 $form['actions'] = array('#type' => 'actions');
185 $form['actions']['submit'] = array(
186 '#type' => 'submit',
187 '#value' => t('Save')
188 );
189 if ($edit['tid']) {
190 $form['actions']['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
191 $form['tid'] = array('#type' => 'value', '#value' => $edit['tid']);
192 }
193 $form['#submit'][] = 'forum_form_submit';
194 $form['#theme'] = 'forum_form';
195
196 return $form;
197 }
198
208 function forum_confirm_delete($form, &$form_state, $tid) {
209 $term = taxonomy_term_load($tid);
210
211 $form['tid'] = array('#type' => 'value', '#value' => $tid);
212 $form['name'] = array('#type' => 'value', '#value' => $term->name);
213
214 return confirm_form($form, t('Are you sure you want to delete the forum %name?', array('%name' => $term->name)), 'admin/structure/forum', t('Deleting a forum or container will also delete its sub-forums, if any. To delete posts in this forum, visit <a href="@content">content administration</a> first. This action cannot be undone.', array('@content' => url('admin/content'))), t('Delete'), t('Cancel'));
215 }
216
220 function forum_confirm_delete_submit($form, &$form_state) {
221 taxonomy_term_delete($form_state['values']['tid']);
222 drupal_set_message(t('The forum %term and all sub-forums have been deleted.', array('%term' => $form_state['values']['name'])));
223 watchdog('content', 'forum: deleted %term and all its sub-forums.', array('%term' => $form_state['values']['name']));
224
225 $form_state['redirect'] = 'admin/structure/forum';
226 return;
227 }
228
236 function forum_admin_settings($form) {
237 $number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500));
238 $form['forum_hot_topic'] = array('#type' => 'select',
239 '#title' => t('Hot topic threshold'),
240 '#default_value' => variable_get('forum_hot_topic', 15),
241 '#options' => $number,
242 '#description' => t('The number of replies a topic must have to be considered "hot".'),
243 );
244 $number = drupal_map_assoc(array(10, 25, 50, 75, 100));
245 $form['forum_per_page'] = array('#type' => 'select',
246 '#title' => t('Topics per page'),
247 '#default_value' => variable_get('forum_per_page', 25),
248 '#options' => $number,
249 '#description' => t('Default number of forum topics displayed per page.'),
250 );
251 $forder = array(1 => t('Date - newest first'), 2 => t('Date - oldest first'), 3 => t('Posts - most active first'), 4 => t('Posts - least active first'));
252 $form['forum_order'] = array('#type' => 'radios',
253 '#title' => t('Default order'),
254 '#default_value' => variable_get('forum_order', 1),
255 '#options' => $forder,
256 '#description' => t('Default display order for topics.'),
257 );
258 return system_settings_form($form);
259 }
260
270 function forum_overview($form, &$form_state) {
271 module_load_include('inc', 'taxonomy', 'taxonomy.admin');
272
273 $vid = variable_get('forum_nav_vocabulary', '');
274 $vocabulary = taxonomy_vocabulary_load($vid);
275 $form = taxonomy_overview_terms($form, $form_state, $vocabulary);
276
277 foreach (element_children($form) as $key) {
278 if (isset($form[$key]['#term'])) {
279 $term = $form[$key]['#term'];
280 $form[$key]['view']['#href'] = 'forum/' . $term['tid'];
281 if (in_array($form[$key]['#term']['tid'], variable_get('forum_containers', array()))) {
282 $form[$key]['edit']['#title'] = t('edit container');
283 $form[$key]['edit']['#href'] = 'admin/structure/forum/edit/container/' . $term['tid'];
284 }
285 else {
286 $form[$key]['edit']['#title'] = t('edit forum');
287 $form[$key]['edit']['#href'] = 'admin/structure/forum/edit/forum/' . $term['tid'];
288 }
289 }
290 }
291
292 // Remove the alphabetical reset.
293 unset($form['actions']['reset_alphabetical']);
294
295 // The form needs to have submit and validate handlers set explicitly.
296 $form['#theme'] = 'taxonomy_overview_terms';
297 $form['#submit'] = array('taxonomy_overview_terms_submit'); // Use the existing taxonomy overview submit handler.
298 $form['#empty_text'] = t('No containers or forums available. <a href="@container">Add container</a> or <a href="@forum">Add forum</a>.', array('@container' => url('admin/structure/forum/add/container'), '@forum' => url('admin/structure/forum/add/forum')));
299 return $form;
300 }
301
315 function _forum_parent_select($tid, $title, $child_type) {
316
317 $parents = taxonomy_get_parents($tid);
318 if ($parents) {
319 $parent = array_shift($parents);
320 $parent = $parent->tid;
321 }
322 else {
323 $parent = 0;
324 }
325
326 $vid = variable_get('forum_nav_vocabulary', '');
327 $children = taxonomy_get_tree($vid, $tid);
328
329 // A term can't be the child of itself, nor of its children.
330 foreach ($children as $child) {
331 $exclude[] = $child->tid;
332 }
333 $exclude[] = $tid;
334
335 $tree = taxonomy_get_tree($vid);
336 $options[0] = '<' . t('root') . '>';
337 if ($tree) {
338 foreach ($tree as $term) {
339 if (!in_array($term->tid, $exclude)) {
340 $options[$term->tid] = str_repeat(' -- ', $term->depth) . $term->name;
341 }
342 }
343 }
344 if ($child_type == 'container') {
345 $description = t('Containers are usually placed at the top (root) level, but may also be placed inside another container or forum.');
346 }
347 elseif ($child_type == 'forum') {
348 $description = t('Forums may be placed at the top (root) level, or inside another container or forum.');
349 }
350
351 return array('#type' => 'select', '#title' => $title, '#default_value' => $parent, '#options' => $options, '#description' => $description, '#required' => TRUE);
352 }
forum_form_forum
forum_form_forum($form, &$form_state, $edit=array())
Definition: forum.admin.inc:47
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
SAVED_UPDATED
const SAVED_UPDATED
Definition: common.inc:50
taxonomy_overview_terms
taxonomy_overview_terms($form, &$form_state, $vocabulary)
Definition: taxonomy.admin.inc:249
taxonomy_term_delete
taxonomy_term_delete($tid)
Definition: taxonomy.module:701
taxonomy_vocabulary_load
taxonomy_vocabulary_load($vid)
Definition: taxonomy.module:1351
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
forum_form_submit
forum_form_submit($form, &$form_state)
Definition: forum.admin.inc:90
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
forum_admin_settings
forum_admin_settings($form)
Definition: forum.admin.inc:236
forum_form_container
forum_form_container($form, &$form_state, $edit=array())
Definition: forum.admin.inc:148
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
forum_form_main
forum_form_main($type, $edit=array())
Definition: forum.admin.inc:22
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
_forum_parent_select
_forum_parent_select($tid, $title, $child_type)
Definition: forum.admin.inc:315
SAVED_NEW
const SAVED_NEW
Definition: common.inc:45
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
taxonomy_get_parents
taxonomy_get_parents($tid)
Definition: taxonomy.module:1007
forum_confirm_delete
forum_confirm_delete($form, &$form_state, $tid)
Definition: forum.admin.inc:208
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
$children
print $children
Definition: book-node-export-html.tpl.php:24
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
taxonomy_get_tree
taxonomy_get_tree($vid, $parent=0, $max_depth=NULL, $load_entities=FALSE)
Definition: taxonomy.module:1105
taxonomy_term_load
taxonomy_term_load($tid)
Definition: taxonomy.module:1383
$tree
if($tree||$has_links) print $tree
Definition: book-navigation.tpl.php:35
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
forum_confirm_delete_submit
forum_confirm_delete_submit($form, &$form_state)
Definition: forum.admin.inc:220
taxonomy_term_save
taxonomy_term_save($term)
Definition: taxonomy.module:621
system_settings_form
system_settings_form($form)
Definition: system.module:2755
theme_forum_form
theme_forum_form($variables)
Definition: forum.admin.inc:134
forum_overview
forum_overview($form, &$form_state)
Definition: forum.admin.inc:270
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/locale/locale.module Source File

  • modules
  • locale
locale.module
Go to the documentation of this file.
1 <?php
2
14 // ---------------------------------------------------------------------------------
15 // Hook implementations
16
20 function locale_help($path, $arg) {
21 switch ($path) {
22 case 'admin/help#locale':
23 $output = '';
24 $output .= '<h3>' . t('About') . '</h3>';
25 $output .= '<p>' . t('The Locale module allows your Drupal site to be presented in languages other than the default English, and to be multilingual. The Locale module works by maintaining a database of translations, and examining text as it is about to be displayed. When a translation of the text is available in the language to be displayed, the translation is displayed rather than the original text. When a translation is unavailable, the original text is displayed, and then stored for review by a translator. For more information, see the online handbook entry for <a href="@locale">Locale module</a>.', array('@locale' => 'http://drupal.org/documentation/modules/locale/')) . '</p>';
26 $output .= '<h3>' . t('Uses') . '</h3>';
27 $output .= '<dl>';
28 $output .= '<dt>' . t('Translating interface text') . '</dt>';
29 $output .= '<dd>' . t('Translations of text in the Drupal interface may be provided by:');
30 $output .= '<ul>';
31 $output .= '<li>' . t("Translating within your site, using the Locale module's integrated <a href='@translate'>translation interface</a>.", array('@translate' => url('admin/config/regional/translate'))) . '</li>';
32 $output .= '<li>' . t('Importing files from a set of existing translations, known as a translation package. A translation package enables the display of a specific version of Drupal in a specific language, and contains files in the Gettext Portable Object (<em>.po</em>) format. Although not all languages are available for every version of Drupal, translation packages for many languages are available for download from the <a href="@translations">Drupal translations page</a>.', array('@translations' => 'http://localize.drupal.org')) . '</li>';
33 $output .= '<li>' . t("If an existing translation package does not meet your needs, the Gettext Portable Object (<em>.po</em>) files within a package may be modified, or new <em>.po</em> files may be created, using a desktop Gettext editor. The Locale module's <a href='@import'>import</a> feature allows the translated strings from a new or modified <em>.po</em> file to be added to your site. The Locale module's <a href='@export'>export</a> feature generates files from your site's translated strings, that can either be shared with others or edited offline by a Gettext translation editor.", array('@import' => url('admin/config/regional/translate/import'), '@export' => url('admin/config/regional/translate/export'))) . '</li>';
34 $output .= '</ul></dd>';
35 $output .= '<dt>' . t('Configuring a multilingual site') . '</dt>';
36 $output .= '<dd>' . t("Language negotiation allows your site to automatically change language based on the domain or path used for each request. Users may (optionally) select their preferred language on their <em>My account</em> page, and your site can be configured to honor a web browser's preferred language settings. Site content can be translated using the <a href='@content-help'>Content translation module</a>.", array('@content-help' => url('admin/help/translation'))) . '</dd>';
37 $output .= '</dl>';
38 return $output;
39 case 'admin/config/regional/language':
40 $output = '<p>' . t('With multiple languages enabled, interface text can be translated, registered users may select their preferred language, and authors can assign a specific language to content. <a href="@translations">Download contributed translations</a> from Drupal.org.', array('@translations' => 'http://localize.drupal.org')) . '</p>';
41 return $output;
42 case 'admin/config/regional/language/add':
43 return '<p>' . t('Add a language to be supported by your site. If your desired language is not available in the <em>Language name</em> drop-down, click <em>Custom language</em> and provide a language code and other details manually. When providing a language code manually, be sure to enter a standardized language code, since this code may be used by browsers to determine an appropriate display language.') . '</p>';
44 case 'admin/config/regional/language/configure':
45 $output = '<p>' . t("Define how to decide which language is used to display page elements (primarily text provided by Drupal and modules, such as field labels and help text). This decision is made by evaluating a series of detection methods for languages; the first detection method that gets a result will determine which language is used for that type of text. Define the order of evaluation of language detection methods on this page.") . '</p>';
46 return $output;
47 case 'admin/config/regional/language/configure/session':
48 $output = '<p>' . t('Determine the language from a request/session parameter. Example: "http://example.com?language=de" sets language to German based on the use of "de" within the "language" parameter.') . '</p>';
49 return $output;
50 case 'admin/config/regional/translate':
51 $output = '<p>' . t('This page provides an overview of available translatable strings. Drupal displays translatable strings in text groups; modules may define additional text groups containing other translatable strings. Because text groups provide a method of grouping related strings, they are often used to focus translation efforts on specific areas of the Drupal interface.') . '</p>';
52 $output .= '<p>' . t('See the <a href="@languages">Languages page</a> for more information on adding support for additional languages.', array('@languages' => url('admin/config/regional/language'))) . '</p>';
53 return $output;
54 case 'admin/config/regional/translate/import':
55 $output = '<p>' . t('This page imports the translated strings contained in an individual Gettext Portable Object (<em>.po</em>) file. Normally distributed as part of a translation package (each translation package may contain several <em>.po</em> files), a <em>.po</em> file may need to be imported after offline editing in a Gettext translation editor. Importing an individual <em>.po</em> file may be a lengthy process.') . '</p>';
56 $output .= '<p>' . t('Note that the <em>.po</em> files within a translation package are imported automatically (if available) when new modules or themes are enabled, or as new languages are added. Since this page only allows the import of one <em>.po</em> file at a time, it may be simpler to download and extract a translation package into your Drupal installation directory and <a href="@language-add">add the language</a> (which automatically imports all <em>.po</em> files within the package). Translation packages are available for download on the <a href="@translations">Drupal translation page</a>.', array('@language-add' => url('admin/config/regional/language/add'), '@translations' => 'http://localize.drupal.org')) . '</p>';
57 return $output;
58 case 'admin/config/regional/translate/export':
59 return '<p>' . t('This page exports the translated strings used by your site. An export file may be in Gettext Portable Object (<em>.po</em>) form, which includes both the original string and the translation (used to share translations with others), or in Gettext Portable Object Template (<em>.pot</em>) form, which includes the original strings only (used to create new translations with a Gettext translation editor).') . '</p>';
60 case 'admin/config/regional/translate/translate':
61 return '<p>' . t('This page allows a translator to search for specific translated and untranslated strings, and is used when creating or editing translations. (Note: For translation tasks involving many strings, it may be more convenient to <a href="@export">export</a> strings for offline editing in a desktop Gettext translation editor.) Searches may be limited to strings found within a specific text group or in a specific language.', array('@export' => url('admin/config/regional/translate/export'))) . '</p>';
62 case 'admin/structure/block/manage/%/%':
63 if ($arg[4] == 'locale' && $arg[5] == 'language') {
64 return '<p>' . t('This block is only shown if <a href="@languages">at least two languages are enabled</a> and <a href="@configuration">language negotiation</a> is set to <em>URL</em> or <em>Session</em>.', array('@languages' => url('admin/config/regional/language'), '@configuration' => url('admin/config/regional/language/configure'))) . '</p>';
65 }
66 break;
67 }
68 }
69
73 function locale_menu() {
74 // Manage languages
75 $items['admin/config/regional/language'] = array(
76 'title' => 'Languages',
77 'description' => 'Configure languages for content and the user interface.',
78 'page callback' => 'drupal_get_form',
79 'page arguments' => array('locale_languages_overview_form'),
80 'access arguments' => array('administer languages'),
81 'file' => 'locale.admin.inc',
82 'weight' => -10,
83 );
84 $items['admin/config/regional/language/overview'] = array(
85 'title' => 'List',
86 'weight' => 0,
87 'type' => MENU_DEFAULT_LOCAL_TASK,
88 );
89 $items['admin/config/regional/language/add'] = array(
90 'title' => 'Add language',
91 'page callback' => 'locale_languages_add_screen', // two forms concatenated
92 'access arguments' => array('administer languages'),
93 'weight' => 5,
94 'type' => MENU_LOCAL_ACTION,
95 'file' => 'locale.admin.inc',
96 );
97 $items['admin/config/regional/language/configure'] = array(
98 'title' => 'Detection and selection',
99 'page callback' => 'drupal_get_form',
100 'page arguments' => array('locale_languages_configure_form'),
101 'access arguments' => array('administer languages'),
102 'weight' => 10,
103 'file' => 'locale.admin.inc',
104 'type' => MENU_LOCAL_TASK,
105 );
106 $items['admin/config/regional/language/configure/url'] = array(
107 'title' => 'URL language detection configuration',
108 'page callback' => 'drupal_get_form',
109 'page arguments' => array('locale_language_providers_url_form'),
110 'access arguments' => array('administer languages'),
111 'file' => 'locale.admin.inc',
112 'type' => MENU_VISIBLE_IN_BREADCRUMB,
113 );
114 $items['admin/config/regional/language/configure/session'] = array(
115 'title' => 'Session language detection configuration',
116 'page callback' => 'drupal_get_form',
117 'page arguments' => array('locale_language_providers_session_form'),
118 'access arguments' => array('administer languages'),
119 'file' => 'locale.admin.inc',
120 'type' => MENU_VISIBLE_IN_BREADCRUMB,
121 );
122 $items['admin/config/regional/language/edit/%'] = array(
123 'title' => 'Edit language',
124 'page callback' => 'drupal_get_form',
125 'page arguments' => array('locale_languages_edit_form', 5),
126 'access arguments' => array('administer languages'),
127 'file' => 'locale.admin.inc',
128 );
129 $items['admin/config/regional/language/delete/%'] = array(
130 'title' => 'Confirm',
131 'page callback' => 'drupal_get_form',
132 'page arguments' => array('locale_languages_delete_form', 5),
133 'access arguments' => array('administer languages'),
134 'file' => 'locale.admin.inc',
135 );
136
137 // Translation functionality
138 $items['admin/config/regional/translate'] = array(
139 'title' => 'Translate interface',
140 'description' => 'Translate the built in interface and optionally other text.',
141 'page callback' => 'locale_translate_overview_screen',
142 'access arguments' => array('translate interface'),
143 'file' => 'locale.admin.inc',
144 'weight' => -5,
145 );
146 $items['admin/config/regional/translate/overview'] = array(
147 'title' => 'Overview',
148 'weight' => 0,
149 'type' => MENU_DEFAULT_LOCAL_TASK,
150 );
151 $items['admin/config/regional/translate/translate'] = array(
152 'title' => 'Translate',
153 'weight' => 10,
154 'type' => MENU_LOCAL_TASK,
155 'page callback' => 'locale_translate_seek_screen', // search results and form concatenated
156 'access arguments' => array('translate interface'),
157 'file' => 'locale.admin.inc',
158 );
159 $items['admin/config/regional/translate/import'] = array(
160 'title' => 'Import',
161 'page callback' => 'drupal_get_form',
162 'page arguments' => array('locale_translate_import_form'),
163 'access arguments' => array('translate interface'),
164 'weight' => 20,
165 'type' => MENU_LOCAL_TASK,
166 'file' => 'locale.admin.inc',
167 );
168 $items['admin/config/regional/translate/export'] = array(
169 'title' => 'Export',
170 'page callback' => 'locale_translate_export_screen', // possibly multiple forms concatenated
171 'access arguments' => array('translate interface'),
172 'weight' => 30,
173 'type' => MENU_LOCAL_TASK,
174 'file' => 'locale.admin.inc',
175 );
176 $items['admin/config/regional/translate/edit/%'] = array(
177 'title' => 'Edit string',
178 'page callback' => 'drupal_get_form',
179 'page arguments' => array('locale_translate_edit_form', 5),
180 'access arguments' => array('translate interface'),
181 'file' => 'locale.admin.inc',
182 );
183 $items['admin/config/regional/translate/delete/%'] = array(
184 'title' => 'Delete string',
185 'page callback' => 'locale_translate_delete_page',
186 'page arguments' => array(5),
187 'access arguments' => array('translate interface'),
188 'file' => 'locale.admin.inc',
189 );
190
191 // Localize date formats.
192 $items['admin/config/regional/date-time/locale'] = array(
193 'title' => 'Localize',
194 'description' => 'Configure date formats for each locale',
195 'page callback' => 'locale_date_format_language_overview_page',
196 'access arguments' => array('administer site configuration'),
197 'type' => MENU_LOCAL_TASK,
198 'weight' => -8,
199 'file' => 'locale.admin.inc',
200 );
201 $items['admin/config/regional/date-time/locale/%/edit'] = array(
202 'title' => 'Localize date formats',
203 'description' => 'Configure date formats for each locale',
204 'page callback' => 'drupal_get_form',
205 'page arguments' => array('locale_date_format_form', 5),
206 'access arguments' => array('administer site configuration'),
207 'file' => 'locale.admin.inc',
208 );
209 $items['admin/config/regional/date-time/locale/%/reset'] = array(
210 'title' => 'Reset date formats',
211 'description' => 'Reset localized date formats to global defaults',
212 'page callback' => 'drupal_get_form',
213 'page arguments' => array('locale_date_format_reset_form', 5),
214 'access arguments' => array('administer site configuration'),
215 'file' => 'locale.admin.inc',
216 );
217
218 return $items;
219 }
220
226 function locale_init() {
227 global $conf, $language;
228 include_once DRUPAL_ROOT . '/includes/locale.inc';
229
230 // For each date type (e.g. long, short), get the localized date format
231 // for the user's current language and override the default setting for it
232 // in $conf. This should happen on all pages except the date and time formats
233 // settings page, where we want to display the site default and not the
234 // localized version.
235 if (strpos($_GET['q'], 'admin/config/regional/date-time/formats') !== 0) {
236 $languages = array($language->language);
237
238 // Setup appropriate date formats for this locale.
239 $formats = locale_get_localized_date_format($languages);
240 foreach ($formats as $format_type => $format) {
241 $conf[$format_type] = $format;
242 }
243 }
244 }
245
249 function locale_permission() {
250 return array(
251 'administer languages' => array(
252 'title' => t('Administer languages'),
253 ),
254 'translate interface' => array(
255 'title' => t('Translate interface texts'),
256 'restrict access' => TRUE,
257 ),
258 );
259 }
260
264 function locale_locale($op = 'groups') {
265 switch ($op) {
266 case 'groups':
267 return array('default' => t('Built-in interface'));
268 }
269 }
270
277 function locale_language_selector_form(&$form, &$form_state, $user) {
278 global $language;
279 $languages = language_list('enabled');
280 $languages = $languages[1];
281
282 // If the user is being created, we set the user language to the page language.
283 $user_preferred_language = $user->uid ? user_preferred_language($user) : $language;
284
285 $names = array();
286 foreach ($languages as $langcode => $item) {
287 $name = t($item->name);
288 $names[$langcode] = $name . ($item->native != $name ? ' (' . $item->native . ')' : '');
289 }
290 $form['locale'] = array(
291 '#type' => 'fieldset',
292 '#title' => t('Language settings'),
293 '#weight' => 1,
294 '#access' => ($form['#user_category'] == 'account' || ($form['#user_category'] == 'register' && user_access('administer users'))),
295 );
296
297 // Get language negotiation settings.
298 $mode = language_negotiation_get(LANGUAGE_TYPE_INTERFACE) != LANGUAGE_NEGOTIATION_DEFAULT;
299 $form['locale']['language'] = array(
300 '#type' => (count($names) <= 5 ? 'radios' : 'select'),
301 '#title' => t('Language'),
302 '#default_value' => $user_preferred_language->language,
303 '#options' => $names,
304 '#description' => $mode ? t("This account's default language for e-mails, and preferred language for site presentation.") : t("This account's default language for e-mails."),
305 );
306 }
307
311 function locale_form_path_admin_form_alter(&$form, &$form_state) {
312 $form['language'] = array(
313 '#type' => 'select',
314 '#title' => t('Language'),
315 '#options' => array(LANGUAGE_NONE => t('All languages')) + locale_language_list('name'),
316 '#default_value' => $form['language']['#value'],
317 '#weight' => -10,
318 '#description' => t('A path alias set for a specific language will always be used when displaying this page in that language, and takes precedence over path aliases set for <em>All languages</em>.'),
319 );
320 }
321
325 function locale_form_node_type_form_alter(&$form, &$form_state) {
326 if (isset($form['type'])) {
327 $form['workflow']['language_content_type'] = array(
328 '#type' => 'radios',
329 '#title' => t('Multilingual support'),
330 '#default_value' => variable_get('language_content_type_' . $form['#node_type']->type, 0),
331 '#options' => array(t('Disabled'), t('Enabled')),
332 '#description' => t('Enable multilingual support for this content type. If enabled, a language selection field will be added to the editing form, allowing you to select from one of the <a href="!languages">enabled languages</a>. If disabled, new posts are saved with the default language. Existing content will not be affected by changing this option.', array('!languages' => url('admin/config/regional/language'))),
333 );
334 }
335 }
336
343 function locale_multilingual_node_type($type_name) {
344 return (bool) variable_get('language_content_type_' . $type_name, 0);
345 }
346
352 function locale_form_alter(&$form, &$form_state, $form_id) {
353 // Only alter user forms if there is more than one language.
354 if (drupal_multilingual()) {
355 // Display language selector when either creating a user on the admin
356 // interface or editing a user account.
357 if ($form_id == 'user_register_form' || ($form_id == 'user_profile_form' && $form['#user_category'] == 'account')) {
358 locale_language_selector_form($form, $form_state, $form['#user']);
359 }
360 }
361 }
362
366 function locale_form_node_form_alter(&$form, &$form_state) {
367 if (isset($form['#node']->type) && locale_multilingual_node_type($form['#node']->type)) {
368 $form['language'] = array(
369 '#type' => 'select',
370 '#title' => t('Language'),
371 '#default_value' => (isset($form['#node']->language) ? $form['#node']->language : ''),
372 '#options' => array(LANGUAGE_NONE => t('Language neutral')) + locale_language_list('name'),
373 );
374 }
375 // Node type without language selector: assign the default for new nodes
376 elseif (!isset($form['#node']->nid)) {
377 $default = language_default();
378 $form['language'] = array(
379 '#type' => 'value',
380 '#value' => $default->language
381 );
382 }
383 $form['#submit'][] = 'locale_field_node_form_submit';
384 }
385
393 function locale_field_node_form_submit($form, &$form_state) {
394 locale_field_entity_form_submit('node', $form, $form_state);
395 }
396
400 function locale_form_comment_form_alter(&$form, &$form_state, $form_id) {
401 // If a content type has multilingual support we set the content language as
402 // comment language.
403 if ($form['language']['#value'] == LANGUAGE_NONE && locale_multilingual_node_type($form['#node']->type)) {
404 global $language_content;
405 $form['language']['#value'] = $language_content->language;
406 $submit_callback = 'locale_field_comment_form_submit';
407 array_unshift($form['actions']['preview']['#submit'], $submit_callback);
408 array_unshift($form['#submit'], $submit_callback);
409 }
410 }
411
419 function locale_field_comment_form_submit($form, &$form_state) {
420 locale_field_entity_form_submit('comment', $form, $form_state);
421 }
422
429 function locale_field_entity_form_submit($entity_type, $form, &$form_state ) {
430 if (field_has_translation_handler($entity_type, 'locale')) {
431 $entity = (object) $form_state['values'];
432 $current_language = entity_language($entity_type, $entity);
433 list(, , $bundle) = entity_extract_ids($entity_type, $entity);
434
435 foreach (field_info_instances($entity_type, $bundle) as $instance) {
436 $field_name = $instance['field_name'];
437 $field = field_info_field($field_name);
438 $previous_language = $form[$field_name]['#language'];
439
440 // Handle a possible language change: new language values are inserted,
441 // previous ones are deleted.
442 if ($field['translatable'] && $previous_language != $current_language) {
443 $form_state['values'][$field_name][$current_language] = $entity->{$field_name}[$previous_language];
444 $form_state['values'][$field_name][$previous_language] = array();
445 }
446 }
447 }
448 }
449
453 function locale_theme() {
454 return array(
455 'locale_languages_overview_form' => array(
456 'render element' => 'form',
457 ),
458 'locale_languages_configure_form' => array(
459 'render element' => 'form',
460 ),
461 'locale_date_format_form' => array(
462 'render element' => 'form',
463 ),
464 );
465 }
466
470 function locale_field_language_alter(&$display_language, $context) {
471 // Do not apply core language fallback rules if they are disabled or if Locale
472 // is not registered as a translation handler.
473 if (variable_get('locale_field_language_fallback', TRUE) && field_has_translation_handler($context['entity_type'], 'locale')) {
474 locale_field_language_fallback($display_language, $context['entity'], $context['language']);
475 }
476 }
477
496 function locale_field_language_fallback(&$display_language, $entity, $langcode) {
497 // Lazily init fallback candidates to avoid unnecessary calls.
498 $fallback_candidates = NULL;
499 $field_languages = array();
500
501 foreach ($display_language as $field_name => $field_language) {
502 // If the requested language is defined for the current field use it,
503 // otherwise search for a fallback value among the fallback candidates.
504 if (isset($entity->{$field_name}[$langcode])) {
505 $display_language[$field_name] = $langcode;
506 }
507 elseif (!empty($entity->{$field_name})) {
508 if (!isset($fallback_candidates)) {
509 require_once DRUPAL_ROOT . '/includes/language.inc';
510 $fallback_candidates = language_fallback_get_candidates();
511 }
512 foreach ($fallback_candidates as $fallback_language) {
513 if (isset($entity->{$field_name}[$fallback_language])) {
514 $display_language[$field_name] = $fallback_language;
515 break;
516 }
517 }
518 }
519 }
520 }
521
525 function locale_entity_info_alter(&$entity_info) {
526 $entity_info['node']['translation']['locale'] = TRUE;
527 if (isset($entity_info['comment'])) {
528 $entity_info['comment']['translation']['locale'] = TRUE;
529 }
530 }
531
545 function locale_language_types_info() {
546 require_once DRUPAL_ROOT . '/includes/locale.inc';
547 return array(
548 LANGUAGE_TYPE_INTERFACE => array(
549 'name' => t('User interface text'),
550 'description' => t('Order of language detection methods for user interface text. If a translation of user interface text is available in the detected language, it will be displayed.'),
551 ),
552 LANGUAGE_TYPE_CONTENT => array(
553 'name' => t('Content'),
554 'description' => t('Order of language detection methods for content. If a version of content is available in the detected language, it will be displayed.'),
555 'fixed' => array(LOCALE_LANGUAGE_NEGOTIATION_INTERFACE),
556 ),
557 LANGUAGE_TYPE_URL => array(
558 'fixed' => array(LOCALE_LANGUAGE_NEGOTIATION_URL, LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK),
559 ),
560 );
561 }
562
566 function locale_language_negotiation_info() {
567 $file = 'includes/locale.inc';
568 $providers = array();
569
570 $providers[LOCALE_LANGUAGE_NEGOTIATION_URL] = array(
571 'types' => array(LANGUAGE_TYPE_CONTENT, LANGUAGE_TYPE_INTERFACE, LANGUAGE_TYPE_URL),
572 'callbacks' => array(
573 'language' => 'locale_language_from_url',
574 'switcher' => 'locale_language_switcher_url',
575 'url_rewrite' => 'locale_language_url_rewrite_url',
576 ),
577 'file' => $file,
578 'weight' => -8,
579 'name' => t('URL'),
580 'description' => t('Determine the language from the URL (Path prefix or domain).'),
581 'config' => 'admin/config/regional/language/configure/url',
582 );
583
584 $providers[LOCALE_LANGUAGE_NEGOTIATION_SESSION] = array(
585 'callbacks' => array(
586 'language' => 'locale_language_from_session',
587 'switcher' => 'locale_language_switcher_session',
588 'url_rewrite' => 'locale_language_url_rewrite_session',
589 ),
590 'file' => $file,
591 'weight' => -6,
592 'name' => t('Session'),
593 'description' => t('Determine the language from a request/session parameter.'),
594 'config' => 'admin/config/regional/language/configure/session',
595 );
596
597 $providers[LOCALE_LANGUAGE_NEGOTIATION_USER] = array(
598 'callbacks' => array('language' => 'locale_language_from_user'),
599 'file' => $file,
600 'weight' => -4,
601 'name' => t('User'),
602 'description' => t("Follow the user's language preference."),
603 );
604
605 $providers[LOCALE_LANGUAGE_NEGOTIATION_BROWSER] = array(
606 'callbacks' => array('language' => 'locale_language_from_browser'),
607 'file' => $file,
608 'weight' => -2,
609 'cache' => 0,
610 'name' => t('Browser'),
611 'description' => t("Determine the language from the browser's language settings."),
612 );
613
614 $providers[LOCALE_LANGUAGE_NEGOTIATION_INTERFACE] = array(
615 'types' => array(LANGUAGE_TYPE_CONTENT),
616 'callbacks' => array('language' => 'locale_language_from_interface'),
617 'file' => $file,
618 'weight' => 8,
619 'name' => t('Interface'),
620 'description' => t('Use the detected interface language.'),
621 );
622
623 $providers[LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK] = array(
624 'types' => array(LANGUAGE_TYPE_URL),
625 'callbacks' => array('language' => 'locale_language_url_fallback'),
626 'file' => $file,
627 'weight' => 8,
628 'name' => t('URL fallback'),
629 'description' => t('Use an already detected language for URLs if none is found.'),
630 );
631
632 return $providers;
633 }
634
638 function locale_modules_enabled($modules) {
639 include_once DRUPAL_ROOT . '/includes/language.inc';
640 language_types_set();
641 language_negotiation_purge();
642 }
643
647 function locale_modules_disabled($modules) {
648 locale_modules_enabled($modules);
649 }
650
651 // ---------------------------------------------------------------------------------
652 // Locale core functionality
653
668 function locale($string = NULL, $context = NULL, $langcode = NULL) {
669 global $language;
670
671 // Use the advanced drupal_static() pattern, since this is called very often.
672 static $drupal_static_fast;
673 if (!isset($drupal_static_fast)) {
674 $drupal_static_fast['locale'] = &drupal_static(__FUNCTION__);
675 }
676 $locale_t = &$drupal_static_fast['locale'];
677
678
679 if (!isset($string)) {
680 // Return all cached strings if no string was specified
681 return $locale_t;
682 }
683
684 $langcode = isset($langcode) ? $langcode : $language->language;
685
686 // Store database cached translations in a static variable. Only build the
687 // cache after $language has been set to avoid an unnecessary cache rebuild.
688 if (!isset($locale_t[$langcode]) && isset($language)) {
689 $locale_t[$langcode] = array();
690 // Disabling the usage of string caching allows a module to watch for
691 // the exact list of strings used on a page. From a performance
692 // perspective that is a really bad idea, so we have no user
693 // interface for this. Be careful when turning this option off!
694 if (variable_get('locale_cache_strings', 1) == 1) {
695 if ($cache = cache_get('locale:' . $langcode, 'cache')) {
696 $locale_t[$langcode] = $cache->data;
697 }
698 elseif (lock_acquire('locale_cache_' . $langcode)) {
699 // Refresh database stored cache of translations for given language.
700 // We only store short strings used in current version, to improve
701 // performance and consume less memory.
702 $result = db_query("SELECT s.source, s.context, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.textgroup = 'default' AND s.version = :version AND LENGTH(s.source) < :length", array(':language' => $langcode, ':version' => VERSION, ':length' => variable_get('locale_cache_length', 75)));
703 foreach ($result as $data) {
704 $locale_t[$langcode][$data->context][$data->source] = (empty($data->translation) ? TRUE : $data->translation);
705 }
706 cache_set('locale:' . $langcode, $locale_t[$langcode]);
707 lock_release('locale_cache_' . $langcode);
708 }
709 }
710 }
711
712 // If we have the translation cached, skip checking the database
713 if (!isset($locale_t[$langcode][$context][$string])) {
714
715 // We do not have this translation cached, so get it from the DB.
716 $translation = db_query("SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = :source AND s.context = :context AND s.textgroup = 'default'", array(
717 ':language' => $langcode,
718 ':source' => $string,
719 ':context' => (string) $context,
720 ))->fetchObject();
721 if ($translation) {
722 // We have the source string at least.
723 // Cache translation string or TRUE if no translation exists.
724 $locale_t[$langcode][$context][$string] = (empty($translation->translation) ? TRUE : $translation->translation);
725
726 if ($translation->version != VERSION) {
727 // This is the first use of this string under current Drupal version. Save version
728 // and clear cache, to include the string into caching next time. Saved version is
729 // also a string-history information for later pruning of the tables.
730 db_update('locales_source')
731 ->fields(array('version' => VERSION))
732 ->condition('lid', $translation->lid)
733 ->execute();
734 cache_clear_all('locale:', 'cache', TRUE);
735 }
736 }
737 else {
738 // We don't have the source string, cache this as untranslated.
739 db_merge('locales_source')
740 ->insertFields(array(
741 'location' => request_uri(),
742 'version' => VERSION,
743 ))
744 ->key(array(
745 'source' => $string,
746 'context' => (string) $context,
747 'textgroup' => 'default',
748 ))
749 ->execute();
750 $locale_t[$langcode][$context][$string] = TRUE;
751 // Clear locale cache so this string can be added in a later request.
752 cache_clear_all('locale:', 'cache', TRUE);
753 }
754 }
755
756 return ($locale_t[$langcode][$context][$string] === TRUE ? $string : $locale_t[$langcode][$context][$string]);
757 }
758
762 function locale_reset() {
763 drupal_static_reset('locale');
764 }
765
782 function locale_get_plural($count, $langcode = NULL) {
783 global $language;
784
785 // Used to locally cache the plural formulas for all languages.
786 $plural_formulas = &drupal_static(__FUNCTION__, array());
787
788 // Used to store precomputed plural indexes corresponding to numbers
789 // individually for each language.
790 $plural_indexes = &drupal_static(__FUNCTION__ . ':plurals', array());
791
792 $langcode = $langcode ? $langcode : $language->language;
793
794 if (!isset($plural_indexes[$langcode][$count])) {
795 // Retrieve and statically cache the plural formulas for all languages.
796 if (empty($plural_formulas)) {
797 foreach (language_list() as $installed_language) {
798 $plural_formulas[$installed_language->language] = $installed_language->formula;
799 }
800 }
801 // If there is a plural formula for the language, evaluate it for the given
802 // $count and statically cache the result for the combination of language
803 // and count, since the result will always be identical.
804 if (!empty($plural_formulas[$langcode])) {
805 // $n is used inside the expression in the eval().
806 $n = $count;
807 $plural_indexes[$langcode][$count] = @eval('return intval(' . $plural_formulas[$langcode] . ');');
808 }
809 // In case there is no plural formula for English (no imported translation
810 // for English), use a default formula.
811 elseif ($langcode == 'en') {
812 $plural_indexes[$langcode][$count] = (int) ($count != 1);
813 }
814 // Otherwise, return -1 (unknown).
815 else {
816 $plural_indexes[$langcode][$count] = -1;
817 }
818 }
819 return $plural_indexes[$langcode][$count];
820 }
821
822
826 function locale_language_name($lang) {
827 $list = &drupal_static(__FUNCTION__);
828 if (!isset($list)) {
829 $list = locale_language_list();
830 }
831 return ($lang && isset($list[$lang])) ? $list[$lang] : t('All');
832 }
833
843 function locale_language_list($field = 'name', $all = FALSE) {
844 if ($all) {
845 $languages = language_list();
846 }
847 else {
848 $languages = language_list('enabled');
849 $languages = $languages[1];
850 }
851 $list = array();
852 foreach ($languages as $language) {
853 $list[$language->language] = ($field == 'name') ? t($language->name) : $language->$field;
854 }
855 return $list;
856 }
857
861 function locale_modules_installed($modules) {
862 locale_system_update($modules);
863 }
864
871 function locale_themes_enabled($themes) {
872 locale_system_update($themes);
873 }
874
885 function locale_system_update($components) {
886 include_once DRUPAL_ROOT . '/includes/locale.inc';
887 if ($batch = locale_batch_by_component($components)) {
888 batch_set($batch);
889 }
890 }
891
900 function locale_js_alter(&$javascript) {
901 global $language;
902
903 $dir = 'public://' . variable_get('locale_js_directory', 'languages');
904 $parsed = variable_get('javascript_parsed', array());
905 $files = $new_files = FALSE;
906
907 // Require because locale_js_alter() could be called without locale_init().
908 require_once DRUPAL_ROOT . '/includes/locale.inc';
909
910 foreach ($javascript as $item) {
911 if ($item['type'] == 'file') {
912 $files = TRUE;
913 $filepath = $item['data'];
914 if (!in_array($filepath, $parsed)) {
915 // Don't parse our own translations files.
916 if (substr($filepath, 0, strlen($dir)) != $dir) {
917 _locale_parse_js_file($filepath);
918 $parsed[] = $filepath;
919 $new_files = TRUE;
920 }
921 }
922 }
923 }
924
925 // If there are any new source files we parsed, invalidate existing
926 // JavaScript translation files for all languages, adding the refresh
927 // flags into the existing array.
928 if ($new_files) {
929 $parsed += _locale_invalidate_js();
930 }
931
932 // If necessary, rebuild the translation file for the current language.
933 if (!empty($parsed['refresh:' . $language->language])) {
934 // Don't clear the refresh flag on failure, so that another try will
935 // be performed later.
936 if (_locale_rebuild_js()) {
937 unset($parsed['refresh:' . $language->language]);
938 }
939 // Store any changes after refresh was attempted.
940 variable_set('javascript_parsed', $parsed);
941 }
942 // If no refresh was attempted, but we have new source files, we need
943 // to store them too. This occurs if current page is in English.
944 elseif ($new_files) {
945 variable_set('javascript_parsed', $parsed);
946 }
947
948 // Add the translation JavaScript file to the page.
949 if ($files && !empty($language->javascript)) {
950 // Add the translation JavaScript file to the page.
951 $file = $dir . '/' . $language->language . '_' . $language->javascript . '.js';
952 $javascript[$file] = drupal_js_defaults($file);
953 }
954 }
955
962 function locale_css_alter(&$css) {
963 global $language;
964
965 // If the current language is RTL, add the CSS file with the RTL overrides.
966 if ($language->direction == LANGUAGE_RTL) {
967 foreach ($css as $data => $item) {
968 // Only provide RTL overrides for files.
969 if ($item['type'] == 'file') {
970 $rtl_path = str_replace('.css', '-rtl.css', $item['data']);
971 if (file_exists($rtl_path) && !isset($css[$rtl_path])) {
972 // Replicate the same item, but with the RTL path and a little larger
973 // weight so that it appears directly after the original CSS file.
974 $item['data'] = $rtl_path;
975 $item['weight'] += 0.0001;
976 $css[$rtl_path] = $item;
977 }
978 }
979 }
980 }
981 }
982
988 function locale_library_alter(&$libraries, $module) {
989 if ($module == 'system' && isset($libraries['ui.datepicker'])) {
990 global $language;
991 // locale.datepicker.js should be added in the JS_LIBRARY group, so that
992 // this attach behavior will execute early. JS_LIBRARY is the default for
993 // hook_library_info_alter(), thus does not have to be specified explicitly.
994 $datepicker = drupal_get_path('module', 'locale') . '/locale.datepicker.js';
995 $libraries['ui.datepicker']['js'][$datepicker] = array();
996 $libraries['ui.datepicker']['js'][] = array(
997 'data' => array(
998 'jquery' => array(
999 'ui' => array(
1000 'datepicker' => array(
1001 'isRTL' => $language->direction == LANGUAGE_RTL,
1002 'firstDay' => variable_get('date_first_day', 0),
1003 ),
1004 ),
1005 ),
1006 ),
1007 'type' => 'setting',
1008 );
1009 }
1010 }
1011
1012 // ---------------------------------------------------------------------------------
1013 // Language switcher block
1014
1018 function locale_block_info() {
1019 include_once DRUPAL_ROOT . '/includes/language.inc';
1020 $block = array();
1021 $info = language_types_info();
1022 foreach (language_types_configurable(FALSE) as $type) {
1023 $block[$type] = array(
1024 'info' => t('Language switcher (@type)', array('@type' => $info[$type]['name'])),
1025 // Not worth caching.
1026 'cache' => DRUPAL_NO_CACHE,
1027 );
1028 }
1029 return $block;
1030 }
1031
1037 function locale_block_view($type) {
1038 if (drupal_multilingual()) {
1039 $path = drupal_is_front_page() ? '<front>' : $_GET['q'];
1040 $links = language_negotiation_get_switch_links($type, $path);
1041
1042 if (isset($links->links)) {
1043 drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
1044 $class = "language-switcher-{$links->provider}";
1045 $variables = array('links' => $links->links, 'attributes' => array('class' => array($class)));
1046 $block['content'] = theme('links__locale_block', $variables);
1047 $block['subject'] = t('Languages');
1048 return $block;
1049 }
1050 }
1051 }
1052
1058 function locale_url_outbound_alter(&$path, &$options, $original_path) {
1059 // Only modify internal URLs.
1060 if (!$options['external'] && drupal_multilingual()) {
1061 static $drupal_static_fast;
1062 if (!isset($drupal_static_fast)) {
1063 $drupal_static_fast['callbacks'] = &drupal_static(__FUNCTION__);
1064 }
1065 $callbacks = &$drupal_static_fast['callbacks'];
1066
1067 if (!isset($callbacks)) {
1068 $callbacks = array();
1069 include_once DRUPAL_ROOT . '/includes/language.inc';
1070
1071 foreach (language_types_configurable() as $type) {
1072 // Get URL rewriter callbacks only from enabled language providers.
1073 $negotiation = variable_get("language_negotiation_$type", array());
1074
1075 foreach ($negotiation as $id => $provider) {
1076 if (isset($provider['callbacks']['url_rewrite'])) {
1077 if (isset($provider['file'])) {
1078 require_once DRUPAL_ROOT . '/' . $provider['file'];
1079 }
1080 // Avoid duplicate callback entries.
1081 $callbacks[$provider['callbacks']['url_rewrite']] = TRUE;
1082 }
1083 }
1084 }
1085
1086 $callbacks = array_keys($callbacks);
1087 }
1088
1089 foreach ($callbacks as $callback) {
1090 $callback($path, $options);
1091 }
1092
1093 // No language dependent path allowed in this mode.
1094 if (empty($callbacks)) {
1095 unset($options['language']);
1096 }
1097 }
1098 }
locale_form_alter
locale_form_alter(&$form, &$form_state, $form_id)
Definition: locale.module:352
locale_reset
locale_reset()
Definition: locale.module:762
locale_themes_enabled
locale_themes_enabled($themes)
Definition: locale.module:871
drupal_is_front_page
drupal_is_front_page()
Definition: path.inc:284
$op
$op
Definition: update.php:404
locale_block_view
locale_block_view($type)
Definition: locale.module:1037
LANGUAGE_RTL
const LANGUAGE_RTL
Definition: bootstrap.inc:206
language_negotiation_get
language_negotiation_get($type, $provider_id=NULL)
Definition: language.inc:230
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
LOCALE_LANGUAGE_NEGOTIATION_BROWSER
const LOCALE_LANGUAGE_NEGOTIATION_BROWSER
Definition: locale.inc:17
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
locale_help
locale_help($path, $arg)
Definition: locale.module:20
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
field_info_instances
field_info_instances($entity_type=NULL, $bundle_name=NULL)
Definition: field.info.inc:592
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
$module
print $module
Definition: search-results.tpl.php:28
locale_language_list
locale_language_list($field= 'name', $all=FALSE)
Definition: locale.module:843
locale_init
locale_init()
Definition: locale.module:226
locale_entity_info_alter
locale_entity_info_alter(&$entity_info)
Definition: locale.module:525
locale
locale($string=NULL, $context=NULL, $langcode=NULL)
Definition: locale.module:668
locale_multilingual_node_type
locale_multilingual_node_type($type_name)
Definition: locale.module:343
locale_batch_by_component
locale_batch_by_component($components, $finished= '_locale_batch_system_finished')
Definition: locale.inc:2242
_locale_rebuild_js
_locale_rebuild_js($langcode=NULL)
Definition: locale.inc:2003
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
LOCALE_LANGUAGE_NEGOTIATION_INTERFACE
const LOCALE_LANGUAGE_NEGOTIATION_INTERFACE
Definition: locale.inc:22
$name
print $name
Definition: profile-listing.tpl.php:43
_locale_parse_js_file
_locale_parse_js_file($filepath)
Definition: locale.inc:1480
LANGUAGE_TYPE_CONTENT
const LANGUAGE_TYPE_CONTENT
Definition: bootstrap.inc:186
language_fallback_get_candidates
language_fallback_get_candidates($type=LANGUAGE_TYPE_CONTENT)
Definition: language.inc:554
locale_library_alter
locale_library_alter(&$libraries, $module)
Definition: locale.module:988
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
locale_permission
locale_permission()
Definition: locale.module:249
locale_get_plural
locale_get_plural($count, $langcode=NULL)
Definition: locale.module:782
locale_modules_installed
locale_modules_installed($modules)
Definition: locale.module:861
locale_field_comment_form_submit
locale_field_comment_form_submit($form, &$form_state)
Definition: locale.module:419
LANGUAGE_NEGOTIATION_DEFAULT
const LANGUAGE_NEGOTIATION_DEFAULT
Definition: language.inc:13
$conf
global $conf
Definition: authorize.php:74
locale_form_path_admin_form_alter
locale_form_path_admin_form_alter(&$form, &$form_state)
Definition: locale.module:311
request_uri
request_uri()
Definition: bootstrap.inc:1609
language_types_set
language_types_set()
Definition: language.inc:179
language_types_configurable
language_types_configurable($stored=TRUE)
Definition: language.inc:139
locale_system_update
locale_system_update($components)
Definition: locale.module:885
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
LOCALE_LANGUAGE_NEGOTIATION_URL
const LOCALE_LANGUAGE_NEGOTIATION_URL
Definition: locale.inc:12
locale_css_alter
locale_css_alter(&$css)
Definition: locale.module:962
LOCALE_LANGUAGE_NEGOTIATION_USER
const LOCALE_LANGUAGE_NEGOTIATION_USER
Definition: locale.inc:33
user_preferred_language
user_preferred_language($account, $default=NULL)
Definition: user.module:3524
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
batch_set
batch_set($batch_definition)
Definition: form.inc:4381
$info
$info
Definition: color.inc:6
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
nid
print $node nid
Definition: book-node-export-html.tpl.php:21
LOCALE_LANGUAGE_NEGOTIATION_SESSION
const LOCALE_LANGUAGE_NEGOTIATION_SESSION
Definition: locale.inc:38
field_has_translation_handler
field_has_translation_handler($entity_type, $handler=NULL)
Definition: field.multilingual.inc:195
language_list
language_list($field= 'language')
Definition: bootstrap.inc:2723
locale_modules_enabled
locale_modules_enabled($modules)
Definition: locale.module:638
locale_language_types_info
locale_language_types_info()
Definition: locale.module:545
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
locale_field_node_form_submit
locale_field_node_form_submit($form, &$form_state)
Definition: locale.module:393
locale_field_entity_form_submit
locale_field_entity_form_submit($entity_type, $form, &$form_state)
Definition: locale.module:429
language_negotiation_get_switch_links
language_negotiation_get_switch_links($type, $path)
Definition: language.inc:279
locale_language_negotiation_info
locale_language_negotiation_info()
Definition: locale.module:566
entity_language
entity_language($entity_type, $entity)
Definition: common.inc:7967
locale_form_node_form_alter
locale_form_node_form_alter(&$form, &$form_state)
Definition: locale.module:366
language
print $language language
Definition: book-export-html.tpl.php:22
locale_field_language_alter
locale_field_language_alter(&$display_language, $context)
Definition: locale.module:470
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
LANGUAGE_TYPE_URL
const LANGUAGE_TYPE_URL
Definition: bootstrap.inc:196
language_types_info
language_types_info()
Definition: language.inc:110
locale_language_selector_form
locale_language_selector_form(&$form, &$form_state, $user)
Definition: locale.module:277
locale_form_comment_form_alter
locale_form_comment_form_alter(&$form, &$form_state, $form_id)
Definition: locale.module:400
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
locale_language_name
locale_language_name($lang)
Definition: locale.module:826
MENU_VISIBLE_IN_BREADCRUMB
const MENU_VISIBLE_IN_BREADCRUMB
Definition: menu.inc:96
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
locale_theme
locale_theme()
Definition: locale.module:453
locale_js_alter
locale_js_alter(&$javascript)
Definition: locale.module:900
lock_acquire
lock_acquire($name, $timeout=30.0)
Definition: lock.inc:102
LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK
const LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK
Definition: locale.inc:28
DRUPAL_NO_CACHE
const DRUPAL_NO_CACHE
Definition: common.inc:127
locale_menu
locale_menu()
Definition: locale.module:73
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
language_default
language_default($property=NULL)
Definition: bootstrap.inc:2765
drupal_js_defaults
drupal_js_defaults($data=NULL)
Definition: common.inc:4215
VERSION
const VERSION
Definition: bootstrap.inc:11
$dir
print $dir
Definition: book-export-html.tpl.php:22
locale_field_language_fallback
locale_field_language_fallback(&$display_language, $entity, $langcode)
Definition: locale.module:496
locale_locale
locale_locale($op= 'groups')
Definition: locale.module:264
LANGUAGE_TYPE_INTERFACE
const LANGUAGE_TYPE_INTERFACE
Definition: bootstrap.inc:191
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
locale_modules_disabled
locale_modules_disabled($modules)
Definition: locale.module:647
language_negotiation_purge
language_negotiation_purge()
Definition: language.inc:318
_locale_invalidate_js
_locale_invalidate_js($langcode=NULL)
Definition: locale.inc:1977
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
entity_extract_ids
entity_extract_ids($entity_type, $entity)
Definition: common.inc:7711
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
locale_block_info
locale_block_info()
Definition: locale.module:1018
locale_form_node_type_form_alter
locale_form_node_type_form_alter(&$form, &$form_state)
Definition: locale.module:325
lock_release
lock_release($name)
Definition: lock.inc:247
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
$links
print $links
Definition: poll-results--block.tpl.php:28
drupal_multilingual
drupal_multilingual()
Definition: bootstrap.inc:2691
locale_get_localized_date_format
locale_get_localized_date_format($languages)
Definition: locale.inc:2395
locale_url_outbound_alter
locale_url_outbound_alter(&$path, &$options, $original_path)
Definition: locale.module:1058
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/contextual_links_example/contextual_links_example.module Source File

  • examples
  • contextual_links_example
contextual_links_example.module
Go to the documentation of this file.
1 <?php
2
51 function contextual_links_example_menu() {
52 // First example (attaching contextual links to a node):
53 //
54 // Many modules add tabs to nodes underneath the node/<nid> path. If the path
55 // you are adding corresponds to a commonly performed action on the node, you
56 // can choose to expose it as a contextual link. Since the Node module
57 // already has code to display all contextual links underneath the node/<nid>
58 // path (such as "Edit" and "Delete") when a node is being rendered outside
59 // of its own page (for example, when a teaser of the node is being displayed
60 // on the front page of the site), you only need to inform Drupal's menu
61 // system that your path is a contextual link also, and it will automatically
62 // appear with the others. In the example below, we add a contextual link
63 // named "Example action" to the list.
64 $items['node/%node/example-action'] = array(
65 'title' => 'Example action',
66 'page callback' => 'drupal_get_form',
67 'page arguments' => array('contextual_links_example_node_action_form', 1),
68 'access callback' => TRUE,
69 // To be displayed as a contextual link, a menu item should be defined as
70 // one of the node's local tasks.
71 'type' => MENU_LOCAL_TASK,
72 // To make the local task display as a contextual link, specify the
73 // optional 'context' argument. The most common method is to set both
74 // MENU_CONTEXT_PAGE and MENU_CONTEXT_INLINE (shown below), which causes
75 // the link to display as both a tab on the node page and as an entry in
76 // the contextual links dropdown. This is recommended for most cases
77 // because not all users who have permission to visit the "Example action"
78 // page will necessarily have access to contextual links, and they still
79 // need a way to get to the page via the user interface.
80 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
81 // If we give the item a large weight, we can make it display as the last
82 // tab on the page, as well as the last item inside the contextual links
83 // dropdown.
84 'weight' => 80,
85 );
86
87 // Second example (attaching contextual links to a block):
88 //
89 // If your module provides content that is displayed in a block, you can
90 // attach contextual links to the block that allow actions to be performed on
91 // it. This is useful for administrative pages that affect the content
92 // wherever it is displayed or used on the site. For configuration options
93 // that only affect the appearance of the content in the block itself, it is
94 // better to implement hook_block_configure() rather than creating a separate
95 // administrative page (this allows your options to appear when an
96 // administrator clicks the existing "Configure block" contextual link
97 // already provided by the Block module).
98 //
99 // In the code below, we assume that your module has a type of object
100 // ("contextual links example object") that will be displayed in a block. The
101 // code below defines menu items for this object using a standard pattern,
102 // with "View" and "Edit object" as the object's local tasks, and makes the
103 // "Edit object" item display as a contextual link in addition to a tab. Once
104 // the contextual links are defined here, additional steps are required to
105 // actually display the content in a block and attach the contextual links to
106 // the block itself. This occurs in contextual_links_example_block_info() and
107 // contextual_links_example_block_view().
108 $items['examples/contextual-links/%contextual_links_example_object'] = array(
109 'title' => 'Contextual links example object',
110 'page callback' => 'contextual_links_example_object_page',
111 'page arguments' => array(2),
112 'access callback' => TRUE,
113 );
114 $items['examples/contextual-links/%contextual_links_example_object/view'] = array(
115 'title' => 'View',
116 'type' => MENU_DEFAULT_LOCAL_TASK,
117 'weight' => -10,
118 );
119 $items['examples/contextual-links/%contextual_links_example_object/edit'] = array(
120 'title' => 'Edit object',
121 'page callback' => 'drupal_get_form',
122 'page arguments' => array('contextual_links_example_object_edit_form', 2),
123 'access callback' => TRUE,
124 'type' => MENU_LOCAL_TASK,
125 // As in our first example, this is the line of code that makes "Edit
126 // "object" display as a contextual link in addition to as a tab.
127 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
128 );
129
130 // Third example (attaching contextual links directly to your module's
131 // content):
132 //
133 // Sometimes your module may want to display its content in an arbitrary
134 // location and attach contextual links there. For example, you might
135 // display your content in a listing on its own page and then attach the
136 // contextual links directly to each piece of content in the listing. Here,
137 // we will reuse the menu items and contextual links that were defined for
138 // our example object above, and display them in a listing in
139 // contextual_links_overview_page().
140 $items['examples/contextual-links'] = array(
141 'title' => 'Contextual Links Example',
142 'page callback' => 'contextual_links_overview_page',
143 'access callback' => TRUE,
144 );
145
146 return $items;
147 }
148
158 function contextual_links_example_object_load($id) {
159 // In a real use case, this function might load an object from the database.
160 // For the sake of this example, we just define a stub object with a basic
161 // title and content for any numeric ID that is passed in.
162 if (is_numeric($id)) {
163 $object = new stdClass();
164 $object->id = $id;
165 $object->title = t('Title for example object @id', array('@id' => $id));
166 $object->content = t('This is the content of example object @id.', array('@id' => $id));
167 return $object;
168 }
169 else {
170 return FALSE;
171 }
172 }
173
177 function contextual_links_example_block_info() {
178 // Define the block that will display our module's content.
179 $blocks['example']['info'] = t('Contextual links example block');
180 return $blocks;
181 }
182
186 function contextual_links_example_block_view($delta = '') {
187 if ($delta == 'example') {
188 // Display our module's content inside a block. In a real use case, we
189 // might define a new block for each object that exists. For the sake of
190 // this example, though, we only define one block and hardcode it to always
191 // display object #1.
192 $id = 1;
193 $object = contextual_links_example_object_load($id);
194 $block['subject'] = t('Contextual links example block for object @id', array('@id' => $id));
195 $block['content'] = array(
196 // In order to attach contextual links, the block's content must be a
197 // renderable array. (Normally this would involve themed output using
198 // #theme, but for simplicity we just use HTML markup directly here.)
199 '#type' => 'markup',
200 '#markup' => filter_xss($object->content),
201 // Contextual links are attached to the block array using the special
202 // #contextual_links property. The #contextual_links property contains an
203 // array, keyed by the name of each module that is attaching contextual
204 // links to it.
205 '#contextual_links' => array(
206 'contextual_links_example' => array(
207 // Each element is itself an array, containing two elements which are
208 // combined together to form the base path whose contextual links
209 // should be attached. The two elements are split such that the first
210 // is the static part of the path and the second is the dynamic part.
211 // (This split is for performance reasons.) For example, the code
212 // below tells Drupal to load the menu item corresponding to the path
213 // "examples/contextual-links/$id" and attach all this item's
214 // contextual links (which were defined in hook_menu()) to the object
215 // when it is rendered. If the contextual links you are attaching
216 // don't have any dynamic elements in their path, you can pass an
217 // empty array as the second element.
218 'examples/contextual-links',
219 array($id),
220 ),
221 ),
222 );
223 // Since we are attaching our contextual links to a block, and the Block
224 // module takes care of rendering the block in such a way that contextual
225 // links are supported, we do not need to do anything else here. When the
226 // appropriate conditions are met, the contextual links we have defined
227 // will automatically appear attached to the block, next to the "Configure
228 // block" link that the Block module itself provides.
229 return $block;
230 }
231 }
232
240 function contextual_links_overview_page() {
241 $build = array();
242
243 // For simplicity, we will hardcode this example page to list five of our
244 // module's objects.
245 for ($id = 1; $id <= 5; $id++) {
246 $object = contextual_links_example_object_load($id);
247 $build[$id] = array(
248 // To support attaching contextual links to an object that we are
249 // displaying on our own, the object must be themed in a particular way.
250 // See contextual_links_example_theme() and
251 // contextual-links-example-object.tpl.php for more discussion.
252 '#theme' => 'contextual_links_example_object',
253 '#object' => $object,
254 // Contextual links are attached to the block using the special
255 // #contextual_links property. See contextual_links_example_block_view()
256 // for discussion of the syntax used here.
257 '#contextual_links' => array(
258 'contextual_links_example' => array(
259 'examples/contextual-links',
260 array($id),
261 ),
262 ),
263 );
264 }
265
266 return $build;
267 }
268
274 function contextual_links_example_theme() {
275 // The core Contextual Links module imposes two restrictions on how an object
276 // must be themed in order for it to display the object's contextual links in
277 // the user interface:
278 // - The object must use a template file rather than a theme function. See
279 // contextual-links-example-object.tpl.php for more information on how the
280 // template file should be structured.
281 // - The first variable passed to the template must be a renderable array. In
282 // this case, we accomplish that via the most common method, by passing a
283 // single renderable element.
284 return array(
285 'contextual_links_example_object' => array(
286 'template' => 'contextual-links-example-object',
287 'render element' => 'element',
288 ),
289 );
290 }
291
297 function template_preprocess_contextual_links_example_object(&$variables) {
298 // Here we take the object that is being themed and define some useful
299 // variables that we will print in the template file.
300 $variables['title'] = filter_xss($variables['element']['#object']->title);
301 $variables['content'] = filter_xss($variables['element']['#object']->content);
302 }
303
309 function contextual_links_example_object_page($object) {
310 // Here we render the object but without the #contextual_links property,
311 // since we don't want contextual links to appear when the object is already
312 // being displayed on its own page.
313 $build = array(
314 '#theme' => 'contextual_links_example_object',
315 '#object' => $object,
316 );
317
318 return $build;
319 }
320
327 function contextual_links_example_object_edit_form($form, &$form_state, $object) {
328 $form['text'] = array(
329 '#markup' => t('This is the page that would allow you to edit object @id.', array('@id' => $object->id)),
330 '#prefix' => '<p>',
331 '#suffix' => '</p>',
332 );
333 $form['object_id'] = array(
334 '#type' => 'value',
335 '#value' => $object->id,
336 );
337
338 $form['actions'] = array('#type' => 'actions');
339 $form['actions']['submit'] = array(
340 '#type' => 'submit',
341 '#value' => t('Submit'),
342 );
343
344 return $form;
345 }
346
350 function contextual_links_example_object_edit_form_submit($form, &$form_state) {
351 drupal_set_message(t('Object @id was edited.', array('@id' => $form_state['values']['object_id'])));
352 }
353
360 function contextual_links_example_node_action_form($form, &$form_state, $node) {
361 $form['text'] = array(
362 '#markup' => t('This is the page that would allow you to perform an example action on node @nid.', array('@nid' => $node->nid)),
363 '#prefix' => '<p>',
364 '#suffix' => '</p>',
365 );
366 $form['nid'] = array(
367 '#type' => 'value',
368 '#value' => $node->nid,
369 );
370
371 $form['actions'] = array('#type' => 'actions');
372 $form['actions']['submit'] = array(
373 '#type' => 'submit',
374 '#value' => t('Submit'),
375 );
376
377 return $form;
378 }
379
383 function contextual_links_example_node_action_form_submit($form, &$form_state) {
384 drupal_set_message(t('The example action was performed on node @nid.', array('@nid' => $form_state['values']['nid'])));
385 }
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
contextual_links_example_object_edit_form_submit
contextual_links_example_object_edit_form_submit($form, &$form_state)
Definition: contextual_links_example.module:350
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
contextual_links_example_object_page
contextual_links_example_object_page($object)
Definition: contextual_links_example.module:309
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
template_preprocess_contextual_links_example_object
template_preprocess_contextual_links_example_object(&$variables)
Definition: contextual_links_example.module:297
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
contextual_links_example_menu
contextual_links_example_menu()
Definition: contextual_links_example.module:51
contextual_links_example_block_info
contextual_links_example_block_info()
Definition: contextual_links_example.module:177
contextual_links_example_theme
contextual_links_example_theme()
Definition: contextual_links_example.module:274
contextual_links_example_block_view
contextual_links_example_block_view($delta= '')
Definition: contextual_links_example.module:186
contextual_links_example_object_edit_form
contextual_links_example_object_edit_form($form, &$form_state, $object)
Definition: contextual_links_example.module:327
contextual_links_example_object_load
contextual_links_example_object_load($id)
Definition: contextual_links_example.module:158
MENU_CONTEXT_INLINE
const MENU_CONTEXT_INLINE
Definition: menu.inc:214
title
print $topic title
Definition: forum-topic-list.tpl.php:50
contextual_links_example_node_action_form_submit
contextual_links_example_node_action_form_submit($form, &$form_state)
Definition: contextual_links_example.module:383
contextual_links_example_node_action_form
contextual_links_example_node_action_form($form, &$form_state, $node)
Definition: contextual_links_example.module:360
MENU_CONTEXT_PAGE
const MENU_CONTEXT_PAGE
Definition: menu.inc:209
contextual_links_overview_page
contextual_links_overview_page()
Definition: contextual_links_example.module:240
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator-summary-items.tpl.php Source File

  • modules
  • aggregator
aggregator-summary-items.tpl.php
Go to the documentation of this file.
1 <?php
2
20 ?>
21 <h3><?php print $title; ?></h3>
22 <?php print $summary_list; ?>
23 <div class="links">
24 <a href="<?php print $source_url; ?>"><?php print t('More'); ?></a>
25 </div>
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
$summary_list
print $summary_list
Definition: aggregator-summary-items.tpl.php:22
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/dbtng_example/dbtng_example.install Source File

  • examples
  • dbtng_example
dbtng_example.install
Go to the documentation of this file.
1 <?php
18 function dbtng_example_install() {
19 // Outside of the .install file we would use drupal_write_record() to
20 // populate the database, but it cannot be used here, so we'll use
21 // db_insert().
22
23 // Add a default entry.
24 $fields = array(
25 'name' => 'John',
26 'surname' => 'Doe',
27 'age' => 0,
28 );
29 db_insert('dbtng_example')
30 ->fields($fields)
31 ->execute();
32
33 // Add another entry.
34 $fields = array(
35 'name' => 'John',
36 'surname' => 'Roe',
37 'age' => 100,
38 'uid' => 1,
39 );
40 db_insert('dbtng_example')
41 ->fields($fields)
42 ->execute();
43
44 }
45
55 function dbtng_example_uninstall() {
56 // nothing.
57 }
58
59
70 function dbtng_example_schema() {
71
72 $schema['dbtng_example'] = array(
73 'description' => 'Stores example person entries for demonstration purposes.',
74 'fields' => array(
75 'pid' => array(
76 'type' => 'serial',
77 'not null' => TRUE,
78 'description' => 'Primary Key: Unique person ID.',
79 ),
80 'uid' => array(
81 'type' => 'int',
82 'not null' => TRUE,
83 'default' => 0,
84 'description' => "Creator user's {users}.uid",
85 ),
86 'name' => array(
87 'type' => 'varchar',
88 'length' => 255,
89 'not null' => TRUE,
90 'default' => '',
91 'description' => 'Name of the person.',
92 ),
93 'surname' => array(
94 'type' => 'varchar',
95 'length' => 255,
96 'not null' => TRUE,
97 'default' => '',
98 'description' => 'Surname of the person.',
99 ),
100 'age' => array(
101 'type' => 'int',
102 'not null' => TRUE,
103 'default' => 0,
104 'size' => 'tiny',
105 'description' => 'The age of the person in years.',
106 )
107 ),
108 'primary key' => array('pid'),
109 'indexes' => array(
110 'name' => array('name'),
111 'surname' => array('surname'),
112 'age' => array('age'),
113 ),
114 );
115
116 return $schema;
117 }
dbtng_example_schema
dbtng_example_schema()
Definition: dbtng_example.install:70
dbtng_example_install
dbtng_example_install()
Definition: dbtng_example.install:18
dbtng_example_uninstall
dbtng_example_uninstall()
Definition: dbtng_example.install:55
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum-topic-list.tpl.php Source File

  • modules
  • forum
forum-topic-list.tpl.php
Go to the documentation of this file.
1 <?php
2
39 ?>
40 <table id="forum-topic-<?php print $topic_id; ?>">
41 <thead>
42 <tr><?php print $header; ?></tr>
43 </thead>
44 <tbody>
45 <?php foreach ($topics as $topic): ?>
46 <tr class="<?php print $topic->zebra;?>">
47 <td class="icon"><?php print $topic->icon; ?></td>
48 <td class="title">
49 <div>
50 <?php print $topic->title; ?>
51 </div>
52 <div>
53 <?php print $topic->created; ?>
54 </div>
55 </td>
56 <?php if ($topic->moved): ?>
57 <td colspan="3"><?php print $topic->message; ?></td>
58 <?php else: ?>
59 <td class="replies">
60 <?php print $topic->comment_count; ?>
61 <?php if ($topic->new_replies): ?>
62 <br />
63 <a href="<?php print $topic->new_url; ?>"><?php print $topic->new_text; ?></a>
64 <?php endif; ?>
65 </td>
66 <td class="last-reply"><?php print $topic->last_reply; ?></td>
67 <?php endif; ?>
68 </tr>
69 <?php endforeach; ?>
70 </tbody>
71 </table>
72 <?php print $pager; ?>
$pager
print $pager
Definition: aggregator-wrapper.tpl.php:19
$topics
if($forums_defined) print $topics
Definition: forums.tpl.php:19
$header
print $header
Definition: forum-topic-list.tpl.php:42
print
print
Definition: php-2.php:2
endforeach
endforeach
Definition: block-admin-display-form.tpl.php:64
endif
endif
Definition: aggregator-item.tpl.php:31
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile/profile-wrapper.tpl.php Source File

  • modules
  • profile
profile-wrapper.tpl.php
Go to the documentation of this file.
1 <?php
2
21 ?>
22 <div id="profile">
23 <?php print $content; ?>
24 </div>
print
print
Definition: php-2.php:2
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy/taxonomy-term.tpl.php Source File

  • modules
  • taxonomy
taxonomy-term.tpl.php
Go to the documentation of this file.
1 <?php
2
43 ?>
44 <div id="taxonomy-term-<?php print $term->tid; ?>" class="<?php print $classes; ?>">
45
46 <?php if (!$page): ?>
47 <h2><a href="<?php print $term_url; ?>"><?php print $term_name; ?></a></h2>
48 <?php endif; ?>
49
50 <div class="content">
51 <?php print render($content); ?>
52 </div>
53
54 </div>
$term_name
if(!$page) print $term_name
Definition: taxonomy-term.tpl.php:46
$page
print $page
Definition: overlay.tpl.php:37
print
print
Definition: php-2.php:2
endif
endif
Definition: aggregator-item.tpl.php:31
render
render(&$element)
Definition: common.inc:5988
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
FileTransferFTPExtension Member List

This is the complete list of members for FileTransferFTPExtension, including all inherited members.

$hostname | FileTransfer | protected
$password | FileTransfer | protected
$port | FileTransfer | protected
$username | FileTransfer | protected
__construct($jail, $username, $password, $hostname, $port) | FileTransferFTP |
FileTransfer::__construct($jail) | FileTransfer |
__get($name) | FileTransfer |
checkPath($path) | FileTransfer | protected
chmod($path, $mode, $recursive=FALSE) | FileTransfer |
chmodJailed($path, $mode, $recursive) | FileTransferFTPExtension |
connect() | FileTransferFTPExtension |
copyDirectory($source, $destination) | FileTransfer |
copyDirectoryJailed($source, $destination) | FileTransfer | protected
copyFile($source, $destination) | FileTransfer |
copyFileJailed($source, $destination) | FileTransferFTPExtension | protected
createDirectory($directory) | FileTransfer |
createDirectoryJailed($directory) | FileTransferFTPExtension | protected
factory($jail, $settings) | FileTransferFTP | static
findChroot() | FileTransfer |
fixRemotePath($path, $strip_chroot=TRUE) | FileTransfer | protected
getSettingsForm() | FileTransferFTP |
isDirectory($path) | FileTransferFTPExtension |
isFile($path) | FileTransferFTPExtension |
removeDirectory($directory) | FileTransfer |
removeDirectoryJailed($directory) | FileTransferFTPExtension | protected
removeFile($destination) | FileTransfer |
removeFileJailed($destination) | FileTransferFTPExtension | protected
sanitizePath($path) | FileTransfer |
setChroot() | FileTransfer |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/dashboard/dashboard.install Source File

  • modules
  • dashboard
dashboard.install
Go to the documentation of this file.
1 <?php
2
15 function dashboard_disable() {
16 // Stash a list of currently enabled blocks.
17 $stashed_blocks = array();
18
19 $result = db_select('block', 'b')
20 ->fields('b', array('module', 'delta', 'region'))
21 ->condition('b.region', dashboard_regions(), 'IN')
22 ->execute();
23
24 foreach ($result as $block) {
25 $stashed_blocks[] = array(
26 'module' => $block->module,
27 'delta' => $block->delta,
28 'region' => $block->region,
29 );
30 }
31 variable_set('dashboard_stashed_blocks', $stashed_blocks);
32
33 // Disable the dashboard blocks.
34 db_update('block')
35 ->fields(array(
36 'status' => 0,
37 'region' => BLOCK_REGION_NONE,
38 ))
39 ->condition('region', dashboard_regions(), 'IN')
40 ->execute();
41 }
42
49 function dashboard_enable() {
50 global $theme_key;
51 if (!$stashed_blocks = variable_get('dashboard_stashed_blocks')) {
52 return;
53 }
54 if (!$admin_theme = variable_get('admin_theme')) {
55 drupal_theme_initialize();
56 $admin_theme = $theme_key;
57 }
58 foreach ($stashed_blocks as $block) {
59 db_update('block')
60 ->fields(array(
61 'status' => 1,
62 'region' => $block['region']
63 ))
64 ->condition('module', $block['module'])
65 ->condition('delta', $block['delta'])
66 ->condition('theme', $admin_theme)
67 ->condition('status', 0)
68 ->execute();
69 }
70 variable_del('dashboard_stashed_blocks');
71 }
72
76 function dashboard_uninstall() {
77 variable_del('dashboard_stashed_blocks');
78 }
variable_del
variable_del($name)
Definition: bootstrap.inc:996
dashboard_enable
dashboard_enable()
Definition: dashboard.install:49
dashboard_regions
dashboard_regions()
Definition: dashboard.module:472
dashboard_uninstall
dashboard_uninstall()
Definition: dashboard.install:76
drupal_theme_initialize
drupal_theme_initialize()
Definition: theme.inc:70
BLOCK_REGION_NONE
const BLOCK_REGION_NONE
Definition: block.module:11
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
dashboard_disable
dashboard_disable()
Definition: dashboard.install:15
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/simpletest_example/simpletest_example.install Source File

  • examples
  • simpletest_example
simpletest_example.install
Go to the documentation of this file.
1 <?php
2
13 function simpletest_example_install() {
14 // Ensure the simpletest_example node type is available.
15 node_types_rebuild();
16 $types = node_type_get_types();
17 node_add_body_field($types['simpletest_example']);
18 }
19
25 function simpletest_example_update_7001() {
26 node_types_rebuild();
27 $types = node_type_get_types();
28 node_add_body_field($types['simpletest_example']);
29 }
simpletest_example_update_7001
simpletest_example_update_7001()
Definition: simpletest_example.install:25
node_type_get_types
node_type_get_types()
Definition: node.module:393
node_add_body_field
node_add_body_field($type, $label= 'Body')
Definition: node.module:586
node_types_rebuild
node_types_rebuild()
Definition: node.module:475
simpletest_example_install
simpletest_example_install()
Definition: simpletest_example.install:13
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/file_example/file_example.module Source File

  • examples
  • file_example
file_example.module
Go to the documentation of this file.
1 <?php
27 function file_example_menu() {
28 $items = array();
29 $items['examples/file_example'] = array(
30 'title' => 'File Example',
31 'page callback' => 'file_example_intro',
32 'access callback' => TRUE,
33 'expanded' => TRUE,
34 );
35 $items['examples/file_example/fileapi'] = array(
36 'title' => 'Use File API to read/write a file',
37 'page callback' => 'drupal_get_form',
38 'access arguments' => array('use file example'),
39 'page arguments' => array('file_example_readwrite'),
40 );
41 $items['examples/file_example/access_session'] = array(
42 'page callback' => 'file_example_session_contents',
43 'access arguments' => array('use file example'),
44 'type' => MENU_CALLBACK,
45 );
46 return $items;
47 }
48
49
53 function file_example_permission() {
54 return array(
55 'use file example' => array(
56 'title' => t('Use the examples in the File Example module'),
57 ),
58 );
59 }
60
64 function file_example_intro() {
65 $markup = t('The file example module provides a form and code to demonstrate the Drupal 7 file api. Experiment with the form, and then look at the submit handlers in the code to understand the file api.');
66 return array('#markup' => $markup);
67 }
75 function file_example_readwrite($form, &$form_state) {
76 if (empty($_SESSION['file_example_default_file'])) {
77 $_SESSION['file_example_default_file'] = 'session://drupal.txt';
78 }
79 $default_file = $_SESSION['file_example_default_file'];
80 if (empty($_SESSION['file_example_default_directory'])) {
81 $_SESSION['file_example_default_directory'] = 'session://directory1';
82 }
83 $default_directory = $_SESSION['file_example_default_directory'];
84
85 $form['write_file'] = array(
86 '#type' => 'fieldset',
87 '#title' => t('Write to a file'),
88 );
89 $form['write_file']['write_contents'] = array(
90 '#type' => 'textfield',
91 '#title' => t('Enter something you would like to write to a file') . ' ' . date('m'),
92 '#default_value' => t('Put some text here or just use this text'),
93 );
94
95 $form['write_file']['destination'] = array(
96 '#type' => 'textfield',
97 '#default_value' => $default_file,
98 '#title' => t('Optional: Enter the streamwrapper saying where it should be written'),
99 '#description' => t('This may be public://some_dir/test_file.txt or private://another_dir/some_file.txt, for example. If you include a directory, it must already exist. The default is "public://". Since this example supports session://, you can also use something like session://somefile.txt.'),
100 );
101
102 $form['write_file']['managed_submit'] = array(
103 '#type' => 'submit',
104 '#value' => t('Write managed file'),
105 '#submit' => array('file_example_managed_write_submit'),
106 );
107 $form['write_file']['unmanaged_submit'] = array(
108 '#type' => 'submit',
109 '#value' => t('Write unmanaged file'),
110 '#submit' => array('file_example_unmanaged_write_submit'),
111 );
112 $form['write_file']['unmanaged_php'] = array(
113 '#type' => 'submit',
114 '#value' => t('Unmanaged using PHP'),
115 '#submit' => array('file_example_unmanaged_php_submit'),
116 );
117
118 $form['fileops'] = array(
119 '#type' => 'fieldset',
120 '#title' => t('Read from a file'),
121 );
122 $form['fileops']['fileops_file'] = array(
123 '#type' => 'textfield',
124 '#default_value' => $default_file,
125 '#title' => t('Enter the URI of a file'),
126 '#description' => t('This must be a stream-type description like public://some_file.txt or http://drupal.org or private://another_file.txt or (for this example) session://yet_another_file.txt.'),
127 );
128 $form['fileops']['read_submit'] = array(
129 '#type' => 'submit',
130 '#value' => t('Read the file and store it locally'),
131 '#submit' => array('file_example_read_submit'),
132 );
133 $form['fileops']['delete_submit'] = array(
134 '#type' => 'submit',
135 '#value' => t('Delete file'),
136 '#submit' => array('file_example_delete_submit'),
137 );
138 $form['fileops']['check_submit'] = array(
139 '#type' => 'submit',
140 '#value' => t('Check to see if file exists'),
141 '#submit' => array('file_example_file_check_exists_submit'),
142 );
143
144 $form['directory'] = array(
145 '#type' => 'fieldset',
146 '#title' => t('Create or prepare a directory'),
147 );
148
149 $form['directory']['directory_name'] = array(
150 '#type' => 'textfield',
151 '#title' => t('Directory to create/prepare/delete'),
152 '#default_value' => $default_directory,
153 '#description' => t('This is a directory as in public://some/directory or private://another/dir.'),
154 );
155 $form['directory']['create_directory'] = array(
156 '#type' => 'submit',
157 '#value' => t('Create directory'),
158 '#submit' => array('file_example_create_directory_submit'),
159 );
160 $form['directory']['delete_directory'] = array(
161 '#type' => 'submit',
162 '#value' => t('Delete directory'),
163 '#submit' => array('file_example_delete_directory_submit'),
164 );
165 $form['directory']['check_directory'] = array(
166 '#type' => 'submit',
167 '#value' => t('Check to see if directory exists'),
168 '#submit' => array('file_example_check_directory_submit'),
169 );
170
171 $form['debug'] = array(
172 '#type' => 'fieldset',
173 '#title' => t('Debugging'),
174 );
175 $form['debug']['show_raw_session'] = array(
176 '#type' => 'submit',
177 '#value' => t('Show raw $_SESSION contents'),
178 '#submit' => array('file_example_show_session_contents_submit'),
179 );
180
181 return $form;
182 }
183
197 function file_example_managed_write_submit($form, &$form_state) {
198 $data = $form_state['values']['write_contents'];
199 $uri = !empty($form_state['values']['destination']) ? $form_state['values']['destination'] : NULL;
200
201 // Managed operations work with a file object.
202 $file_object = file_save_data($data, $uri, FILE_EXISTS_RENAME);
203 if (!empty($file_object)) {
204 $url = file_create_url($file_object->uri);
205 $_SESSION['file_example_default_file'] = $file_object->uri;
206 drupal_set_message(t('Saved managed file: %file to destination %destination (accessible via !url, actual uri=<span id="uri">@uri</span>)', array('%file' => print_r($file_object, TRUE), '%destination' => $uri, '@uri' => $file_object->uri, '!url' => l(t('this URL'), $url))));
207 }
208 else {
209 drupal_set_message(t('Failed to save the managed file'), 'error');
210 }
211 }
212
226 function file_example_unmanaged_write_submit($form, &$form_state) {
227 $data = $form_state['values']['write_contents'];
228 $destination = !empty($form_state['values']['destination']) ? $form_state['values']['destination'] : NULL;
229
230 // With the unmanaged file we just get a filename back.
231 $filename = file_unmanaged_save_data($data, $destination, FILE_EXISTS_REPLACE);
232 if ($filename) {
233 $url = file_create_url($filename);
234 $_SESSION['file_example_default_file'] = $filename;
235 drupal_set_message(t('Saved file as %filename (accessible via !url, uri=<span id="uri">@uri</span>)', array('%filename' => $filename, '@uri' => $filename, '!url' => l(t('this URL'), $url))));
236 }
237 else {
238 drupal_set_message(t('Failed to save the file'), 'error');
239 }
240 }
241
242
243
256 function file_example_unmanaged_php_submit($form, &$form_state) {
257 $data = $form_state['values']['write_contents'];
258 $destination = !empty($form_state['values']['destination']) ? $form_state['values']['destination'] : NULL;
259
260 if (empty($destination)) {
261 // If no destination has been provided, use a generated name.
262 $destination = drupal_tempnam('public://', 'file');
263 }
264
265 // With all traditional PHP functions we can use the stream wrapper notation
266 // for a file as well.
267 $fp = fopen($destination, 'w');
268
269 // To demonstrate the fact that everything is based on streams, we'll do
270 // multiple 5-character writes to put this to the file. We could easily
271 // (and far more conveniently) write it in a single statement with
272 // fwrite($fp, $data).
273 $length = strlen($data);
274 $write_size = 5;
275 for ($i = 0; $i < $length; $i += $write_size) {
276 $result = fwrite($fp, substr($data, $i, $write_size));
277 if ($result === FALSE) {
278 drupal_set_message(t('Failed writing to the file %file', array('%file' => $destination)), 'error');
279 fclose($fp);
280 return;
281 }
282 }
283 $url = file_create_url($destination);
284 $_SESSION['file_example_default_file'] = $destination;
285 drupal_set_message(t('Saved file as %filename (accessible via !url, uri=<span id="uri">@uri</span>)', array('%filename' => $destination, '@uri' => $destination, '!url' => l(t('this URL'), $url))));
286 }
287
308 function file_example_read_submit($form, &$form_state) {
309 $uri = $form_state['values']['fileops_file'];
310
311 if (!is_file($uri)) {
312 drupal_set_message(t('The file %uri does not exist', array('%uri' => $uri)), 'error');
313 return;
314 }
315
316 // Make a working filename to save this by stripping off the (possible)
317 // file portion of the streamwrapper. If it's an evil file extension,
318 // file_munge_filename() will neuter it.
319 $filename = file_munge_filename(preg_replace('@^.*/@', '', $uri), '', TRUE);
320 $buffer = file_get_contents($uri);
321
322 if ($buffer) {
323 $sourcename = file_unmanaged_save_data($buffer, 'public://' . $filename);
324 if ($sourcename) {
325 $url = file_create_url($sourcename);
326 $_SESSION['file_example_default_file'] = $sourcename;
327 drupal_set_message(t('The file was read and copied to %filename which is accessible at !url', array('%filename' => $sourcename, '!url' => l($url, $url))));
328 }
329 else {
330 drupal_set_message(t('Failed to save the file'));
331 }
332 }
333 else { // We failed to get the contents of the requested file
334 drupal_set_message(t('Failed to retrieve the file %file', array('%file' => $uri)));
335 }
336 }
337
341 function file_example_delete_submit($form, &$form_state) {
342
343 $uri = $form_state['values']['fileops_file'];
344
345 // Since we don't know if the file is managed or not, look in the database
346 // to see. Normally, code would be working with either managed or unmanaged
347 // files, so this is not a typical situation.
348 $file_object = file_example_get_managed_file($uri);
349
350 // If a managed file, use file_delete().
351 if (!empty($file_object)) {
352 $result = file_delete($file_object);
353 if ($result !== TRUE) {
354 drupal_set_message(t('Failed deleting managed file %uri. Result was %result', array('%uri' => $uri, '%result' => print_r($result, TRUE))), 'error');
355 }
356 else {
357 drupal_set_message(t('Successfully deleted managed file %uri', array('%uri' => $uri)));
358 $_SESSION['file_example_default_file'] = $uri;
359 }
360 }
361 // else use file_unmanaged_delete().
362 else {
363 $result = file_unmanaged_delete($uri);
364 if ($result !== TRUE) {
365 drupal_set_message(t('Failed deleting unmanaged file %uri', array('%uri' => $uri, 'error')));
366 }
367 else {
368 drupal_set_message(t('Successfully deleted unmanaged file %uri', array('%uri' => $uri)));
369 $_SESSION['file_example_default_file'] = $uri;
370 }
371 }
372 }
373
377 function file_example_file_check_exists_submit($form, &$form_state) {
378 $uri = $form_state['values']['fileops_file'];
379 if (is_file($uri)) {
380 drupal_set_message(t('The file %uri exists.', array('%uri' => $uri)));
381 }
382 else {
383 drupal_set_message(t('The file %uri does not exist.', array('%uri' => $uri)));
384 }
385
386 }
392 function file_example_create_directory_submit($form, &$form_state) {
393 $directory = $form_state['values']['directory_name'];
394
395 // The options passed to file_prepare_directory are a bitmask, so we can
396 // specify either FILE_MODIFY_PERMISSIONS (set permissions on the directory),
397 // FILE_CREATE_DIRECTORY, or both together:
398 // FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY.
399 // FILE_MODIFY_PERMISSIONS will set the permissions of the directory by
400 // by default to 0755, or to the value of the variable 'file_chmod_directory'.
401 if (!file_prepare_directory($directory, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY)) {
402 drupal_set_message(t('Failed to create %directory.', array('%directory' => $directory)), 'error');
403 }
404 else {
405 $result = is_dir($directory);
406 drupal_set_message(t('Directory %directory is ready for use.', array('%directory' => $directory)));
407 $_SESSION['file_example_default_directory'] = $directory;
408 }
409 }
410
417 function file_example_delete_directory_submit($form, &$form_state) {
418 $directory = $form_state['values']['directory_name'];
419
420 $result = file_unmanaged_delete_recursive($directory);
421 if (!$result) {
422 drupal_set_message(t('Failed to delete %directory.', array('%directory' => $directory)), 'error');
423 }
424 else {
425 drupal_set_message(t('Recursively deleted directory %directory.', array('%directory' => $directory)));
426 $_SESSION['file_example_default_directory'] = $directory;
427 }
428 }
429
437 function file_example_check_directory_submit($form, &$form_state) {
438 $directory = $form_state['values']['directory_name'];
439 $result = is_dir($directory);
440 if (!$result) {
441 drupal_set_message(t('Directory %directory does not exist.', array('%directory' => $directory)));
442 }
443 else {
444 drupal_set_message(t('Directory %directory exists.', array('%directory' => $directory)));
445 }
446 }
447
451 function file_example_show_session_contents_submit($form, &$form_state) {
452 // If the devel module is installed, use it's nicer message format.
453 if (module_exists('devel')) {
454 dsm($_SESSION['file_example'], t('Entire $_SESSION["file_example"]'));
455 }
456 else {
457 drupal_set_message('<pre>' . print_r($_SESSION['file_example'], TRUE) . '</pre>');
458 }
459 }
460
471 function file_example_get_managed_file($uri) {
472 $fid = db_query('SELECT fid FROM {file_managed} WHERE uri = :uri', array(':uri' => $uri))->fetchField();
473 if (!empty($fid)) {
474 $file_object = file_load($fid);
475 return $file_object;
476 }
477 return FALSE;
478 }
479
489 function file_example_stream_wrappers() {
490 $wrappers = array(
491 'session' => array(
492 'name' => t('Example: $_SESSION variable storage'),
493 'class' => 'FileExampleSessionStreamWrapper',
494 'description' => t('Store files in the $_SESSION variable as an example.'),
495 ),
496 );
497 return $wrappers;
498 }
499
518 function file_example_session_contents() {
519 $path_components = func_get_args();
520 $session_path = 'session://' . join('/', $path_components);
521 $content = file_get_contents($session_path);
522 if ($content !== FALSE) {
523 return t('Contents of @path :',
524 array('@path' => check_plain($session_path))) . ' ' .
525 print_r($content, TRUE);
526 }
527 return t('Unable to load contents of: @path',
528 array('@path' => check_plain($session_path)));
529 }
530
file_example_unmanaged_php_submit
file_example_unmanaged_php_submit($form, &$form_state)
Definition: file_example.module:256
FILE_CREATE_DIRECTORY
const FILE_CREATE_DIRECTORY
Definition: file.inc:41
l
l($text, $path, array $options=array())
Definition: common.inc:2432
FILE_MODIFY_PERMISSIONS
const FILE_MODIFY_PERMISSIONS
Definition: file.inc:46
file_example_delete_submit
file_example_delete_submit($form, &$form_state)
Definition: file_example.module:341
file_unmanaged_delete_recursive
file_unmanaged_delete_recursive($path)
Definition: file.inc:1358
file_create_url
file_create_url($uri)
Definition: file.inc:372
file_example_file_check_exists_submit
file_example_file_check_exists_submit($form, &$form_state)
Definition: file_example.module:377
drupal_tempnam
drupal_tempnam($directory, $prefix)
Definition: file.inc:2424
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
module_exists
module_exists($module)
Definition: module.inc:274
file_example_show_session_contents_submit
file_example_show_session_contents_submit($form, &$form_state)
Definition: file_example.module:451
file_example_stream_wrappers
file_example_stream_wrappers()
Definition: file_example.module:489
file_example_create_directory_submit
file_example_create_directory_submit($form, &$form_state)
Definition: file_example.module:392
file_delete
file_delete(stdClass $file, $force=FALSE)
Definition: file.inc:1268
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
file_example_get_managed_file
file_example_get_managed_file($uri)
Definition: file_example.module:471
file_example_unmanaged_write_submit
file_example_unmanaged_write_submit($form, &$form_state)
Definition: file_example.module:226
$url
print $url
Definition: search-result.tpl.php:70
FILE_EXISTS_REPLACE
const FILE_EXISTS_REPLACE
Definition: file.inc:56
file_munge_filename
file_munge_filename($filename, $extensions, $alerts=TRUE)
Definition: file.inc:1143
file_example_delete_directory_submit
file_example_delete_directory_submit($form, &$form_state)
Definition: file_example.module:417
file_example_intro
file_example_intro()
Definition: file_example.module:64
file_load
file_load($fid)
Definition: file.inc:580
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
file_unmanaged_delete
file_unmanaged_delete($path)
Definition: file.inc:1317
file_example_readwrite
file_example_readwrite($form, &$form_state)
Definition: file_example.module:75
file_example_permission
file_example_permission()
Definition: file_example.module:53
file_unmanaged_save_data
file_unmanaged_save_data($data, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1932
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
FILE_EXISTS_RENAME
const FILE_EXISTS_RENAME
Definition: file.inc:51
file_prepare_directory
file_prepare_directory(&$directory, $options=FILE_MODIFY_PERMISSIONS)
Definition: file.inc:430
file_save_data
file_save_data($data, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1865
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
file_example_session_contents
file_example_session_contents()
Definition: file_example.module:518
file_example_menu
file_example_menu()
Definition: file_example.module:27
file_example_managed_write_submit
file_example_managed_write_submit($form, &$form_state)
Definition: file_example.module:197
file_example_check_directory_submit
file_example_check_directory_submit($form, &$form_state)
Definition: file_example.module:437
file_example_read_submit
file_example_read_submit($form, &$form_state)
Definition: file_example.module:308
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/trigger/trigger.install Source File

  • modules
  • trigger
trigger.install
Go to the documentation of this file.
1 <?php
2
11 function trigger_schema() {
12 // The total index length (hook and aid) must be less than 333. Since the aid
13 // field is 255 characters, the hook field can have a maximum length of 78.
14 $schema['trigger_assignments'] = array(
15 'description' => 'Maps trigger to hook and operation assignments from trigger.module.',
16 'fields' => array(
17 'hook' => array(
18 'type' => 'varchar',
19 'length' => 78,
20 'not null' => TRUE,
21 'default' => '',
22 'description' => 'Primary Key: The name of the internal Drupal hook; for example, node_insert.',
23 ),
24 'aid' => array(
25 'type' => 'varchar',
26 'length' => 255,
27 'not null' => TRUE,
28 'default' => '',
29 'description' => "Primary Key: Action's {actions}.aid.",
30 ),
31 'weight' => array(
32 'type' => 'int',
33 'not null' => TRUE,
34 'default' => 0,
35 'description' => 'The weight of the trigger assignment in relation to other triggers.',
36 ),
37 ),
38 'primary key' => array('hook', 'aid'),
39 'foreign keys' => array(
40 'action' => array(
41 'table' => 'actions',
42 'columns' => array('aid' => 'aid'),
43 ),
44 ),
45 );
46 return $schema;
47 }
48
52 function trigger_install() {
53 // Do initial synchronization of actions in code and the database.
54 actions_synchronize();
55 }
56
63 function trigger_update_7000() {
64 db_drop_primary_key('trigger_assignments');
65 db_change_field('trigger_assignments', 'hook', 'hook', array('type' => 'varchar', 'length' => 78, 'not null' => TRUE, 'default' => '', 'description' => 'Primary Key: The name of the internal Drupal hook; for example, node_insert.'));
66
67 $result = db_query("SELECT hook, op, aid FROM {trigger_assignments} WHERE op <> ''");
68
69 foreach ($result as $record) {
70 db_update('trigger_assignments')
71 ->fields(array('hook' => $record->hook . '_' . $record->op))
72 ->condition('hook', $record->hook)
73 ->condition('op', $record->op)
74 ->condition('aid', $record->aid)
75 ->execute();
76 }
77 db_drop_field('trigger_assignments', 'op');
78
79 db_add_primary_key('trigger_assignments', array('hook', 'aid'));
80 }
81
93 function trigger_update_7001() {
94 db_drop_primary_key('trigger_assignments');
95 db_change_field('trigger_assignments', 'hook', 'hook', array('type' => 'varchar', 'length' => 78, 'not null' => TRUE, 'default' => '', 'description' => 'Primary Key: The name of the internal Drupal hook; for example, node_insert.', ), array('primary key' => array('hook', 'aid')));
96 }
97
101 function trigger_update_7002() {
102 $result = db_query("SELECT hook, aid FROM {trigger_assignments}");
103
104 foreach($result as $record) {
105 $new_hook = str_replace('nodeapi', 'node', $record->hook);
106 db_update('trigger_assignments')
107 ->fields(array('hook' => $new_hook))
108 ->condition('hook', $record->hook)
109 ->condition('aid', $record->aid)
110 ->execute();
111 }
112 }
113
db_drop_primary_key
db_drop_primary_key($table)
Definition: database.inc:2900
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
db_drop_field
db_drop_field($table, $field)
Definition: database.inc:2852
db_add_primary_key
db_add_primary_key($table, $fields)
Definition: database.inc:2890
trigger_update_7002
trigger_update_7002()
Definition: trigger.install:101
trigger_update_7000
trigger_update_7000()
Definition: trigger.install:63
trigger_update_7001
trigger_update_7001()
Definition: trigger.install:93
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
trigger_schema
trigger_schema()
Definition: trigger.install:11
actions_synchronize
actions_synchronize($delete_orphans=FALSE)
Definition: actions.inc:274
trigger_install
trigger_install()
Definition: trigger.install:52
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/shortcut/shortcut.admin.inc Source File

  • modules
  • shortcut
shortcut.admin.inc
Go to the documentation of this file.
1 <?php
2
16 function shortcut_max_slots() {
17 return variable_get('shortcut_max_slots', 7);
18 }
19
38 function shortcut_set_switch($form, &$form_state, $account = NULL) {
39 global $user;
40 if (!isset($account)) {
41 $account = $user;
42 }
43
44 // Prepare the list of shortcut sets.
45 $sets = shortcut_sets();
46 $current_set = shortcut_current_displayed_set($account);
47
48 $options = array();
49 foreach ($sets as $name => $set) {
50 $options[$name] = check_plain($set->title);
51 }
52
53 // Only administrators can add shortcut sets.
54 $add_access = user_access('administer shortcuts');
55 if ($add_access) {
56 $options['new'] = t('New set');
57 }
58
59 if (count($options) > 1) {
60 $form['account'] = array(
61 '#type' => 'value',
62 '#value' => $account,
63 );
64
65 $form['set'] = array(
66 '#type' => 'radios',
67 '#title' => $user->uid == $account->uid ? t('Choose a set of shortcuts to use') : t('Choose a set of shortcuts for this user'),
68 '#options' => $options,
69 '#default_value' => $current_set->set_name,
70 );
71
72 $form['new'] = array(
73 '#type' => 'textfield',
74 '#title' => t('Name'),
75 '#title_display' => 'invisible',
76 '#description' => t('The new set is created by copying items from your default shortcut set.'),
77 '#access' => $add_access,
78 );
79
80 if ($user->uid != $account->uid) {
81 $default_set = shortcut_default_set($account);
82 $form['new']['#description'] = t('The new set is created by copying items from the %default set.', array('%default' => $default_set->title));
83 }
84
85 $form['#attached'] = array(
86 'css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.admin.css'),
87 'js' => array(drupal_get_path('module', 'shortcut') . '/shortcut.admin.js'),
88 );
89
90 $form['actions'] = array('#type' => 'actions');
91 $form['actions']['submit'] = array(
92 '#type' => 'submit',
93 '#value' => t('Change set'),
94 );
95 }
96 else {
97 // There is only 1 option, so output a message in the $form array.
98 $form['info'] = array(
99 '#markup' => '<p>' . t('You are currently using the %set-name shortcut set.', array('%set-name' => $current_set->title)) . '</p>',
100 );
101 }
102
103 return $form;
104 }
105
109 function shortcut_set_switch_validate($form, &$form_state) {
110 if ($form_state['values']['set'] == 'new') {
111 // Check to prevent creating a shortcut set with an empty title.
112 if (trim($form_state['values']['new']) == '') {
113 form_set_error('new', t('The new set name is required.'));
114 }
115 // Check to prevent a duplicate title.
116 if (shortcut_set_title_exists($form_state['values']['new'])) {
117 form_set_error('new', t('The shortcut set %name already exists. Choose another name.', array('%name' => $form_state['values']['new'])));
118 }
119 }
120 }
121
125 function shortcut_set_switch_submit($form, &$form_state) {
126 global $user;
127 $account = $form_state['values']['account'];
128
129 if ($form_state['values']['set'] == 'new') {
130 // Save a new shortcut set with links copied from the user's default set.
131 $default_set = shortcut_default_set($account);
132 $set = (object) array(
133 'title' => $form_state['values']['new'],
134 'links' => menu_links_clone($default_set->links),
135 );
136 shortcut_set_save($set);
137 $replacements = array(
138 '%user' => $account->name,
139 '%set_name' => $set->title,
140 '@switch-url' => url(current_path()),
141 );
142 if ($account->uid == $user->uid) {
143 // Only administrators can create new shortcut sets, so we know they have
144 // access to switch back.
145 drupal_set_message(t('You are now using the new %set_name shortcut set. You can edit it from this page or <a href="@switch-url">switch back to a different one.</a>', $replacements));
146 }
147 else {
148 drupal_set_message(t('%user is now using a new shortcut set called %set_name. You can edit it from this page.', $replacements));
149 }
150 $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $set->set_name;
151 }
152 else {
153 // Switch to a different shortcut set.
154 $set = shortcut_set_load($form_state['values']['set']);
155 $replacements = array(
156 '%user' => $account->name,
157 '%set_name' => $set->title,
158 );
159 drupal_set_message($account->uid == $user->uid ? t('You are now using the %set_name shortcut set.', $replacements) : t('%user is now using the %set_name shortcut set.', $replacements));
160 }
161
162 // Assign the shortcut set to the provided user account.
163 shortcut_set_assign_user($set, $account);
164 }
165
169 function shortcut_set_admin() {
170 $shortcut_sets = shortcut_sets();
171 $header = array(t('Name'), array('data' => t('Operations'), 'colspan' => 4));
172
173 $rows = array();
174 foreach ($shortcut_sets as $set) {
175 $row = array(
176 check_plain($set->title),
177 l(t('list links'), "admin/config/user-interface/shortcut/$set->set_name"),
178 l(t('edit set name'), "admin/config/user-interface/shortcut/$set->set_name/edit"),
179 );
180 if (shortcut_set_delete_access($set)) {
181 $row[] = l(t('delete set'), "admin/config/user-interface/shortcut/$set->set_name/delete");
182 }
183 else {
184 $row[] = '';
185 }
186
187 $rows[] = $row;
188 }
189
190 return theme('table', array('header' => $header, 'rows' => $rows));
191 }
192
208 function shortcut_set_add_form($form, &$form_state) {
209 $form['new'] = array(
210 '#type' => 'textfield',
211 '#title' => t('Set name'),
212 '#description' => t('The new set is created by copying items from your default shortcut set.'),
213 '#required' => TRUE,
214 );
215
216 $form['actions'] = array('#type' => 'actions');
217 $form['actions']['submit'] = array(
218 '#type' => 'submit',
219 '#value' => t('Create new set'),
220 );
221
222 return $form;
223 }
224
228 function shortcut_set_add_form_validate($form, &$form_state) {
229 // Check to prevent a duplicate title.
230 if (shortcut_set_title_exists($form_state['values']['new'])) {
231 form_set_error('new', t('The shortcut set %name already exists. Choose another name.', array('%name' => $form_state['values']['new'])));
232 }
233 }
234
238 function shortcut_set_add_form_submit($form, &$form_state) {
239 // Save a new shortcut set with links copied from the user's default set.
240 $default_set = shortcut_default_set();
241 $set = (object) array(
242 'title' => $form_state['values']['new'],
243 'links' => menu_links_clone($default_set->links),
244 );
245 shortcut_set_save($set);
246 drupal_set_message(t('The %set_name shortcut set has been created. You can edit it from this page.', array('%set_name' => $set->title)));
247 $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $set->set_name;
248 }
249
266 function shortcut_set_customize($form, &$form_state, $shortcut_set) {
267 $form['#shortcut_set_name'] = $shortcut_set->set_name;
268 $form['shortcuts'] = array(
269 '#tree' => TRUE,
270 '#weight' => -20,
271 'enabled' => array(),
272 'disabled' => array(),
273 );
274
275 foreach ($shortcut_set->links as $link) {
276 $mlid = $link['mlid'];
277 $status = $link['hidden'] ? 'disabled' : 'enabled';
278 $form['shortcuts'][$status][$mlid]['name']['#markup'] = l($link['link_title'], $link['link_path']);
279 $form['shortcuts'][$status][$mlid]['weight'] = array(
280 '#type' => 'weight',
281 '#title' => t('Weight'),
282 '#delta' => 50,
283 '#default_value' => $link['weight'],
284 '#attributes' => array('class' => array('shortcut-weight')),
285 );
286 $form['shortcuts'][$status][$mlid]['status'] = array(
287 '#type' => 'select',
288 '#title' => t('Status'),
289 '#options' => array('disabled' => t('Disabled'), 'enabled' => t('Enabled')),
290 '#default_value' => $status,
291 '#attributes' => array('class' => array('shortcut-status-select')),
292 );
293
294 $form['shortcuts'][$status][$mlid]['edit']['#markup'] = l(t('edit'), 'admin/config/user-interface/shortcut/link/' . $mlid);
295 $form['shortcuts'][$status][$mlid]['delete']['#markup'] = l(t('delete'), 'admin/config/user-interface/shortcut/link/' . $mlid . '/delete');
296 }
297
298 $form['#attached'] = array(
299 'css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.admin.css'),
300 'js' => array(drupal_get_path('module', 'shortcut') . '/shortcut.admin.js'),
301 );
302
303 $form['actions'] = array(
304 '#type' => 'actions',
305 '#access' => !empty($shortcut_set->links),
306 );
307 $form['actions']['submit'] = array(
308 '#type' => 'submit',
309 '#value' => t('Save changes'),
310 );
311
312 return $form;
313 }
314
318 function shortcut_set_customize_submit($form, &$form_state) {
319 foreach ($form_state['values']['shortcuts'] as $group => $links) {
320 foreach ($links as $mlid => $data) {
321 $link = menu_link_load($mlid);
322 $link['hidden'] = $data['status'] == 'enabled' ? 0 : 1;
323 $link['weight'] = $data['weight'];
324 menu_link_save($link);
325 }
326 }
327 drupal_set_message(t('The shortcut set has been updated.'));
328 }
329
340 function theme_shortcut_set_customize($variables) {
341 $form = $variables['form'];
342 $map = array('disabled' => t('Disabled'), 'enabled' => t('Enabled'));
343 $shortcuts_by_status = array(
344 'enabled' => element_children($form['shortcuts']['enabled']),
345 'disabled' => element_children($form['shortcuts']['disabled']),
346 );
347 // Do not add any rows to the table if there are no shortcuts to display.
348 $statuses = empty($shortcuts_by_status['enabled']) && empty($shortcuts_by_status['disabled']) ? array() : array_keys($shortcuts_by_status);
349
350 $rows = array();
351 foreach ($statuses as $status) {
352 drupal_add_tabledrag('shortcuts', 'match', 'sibling', 'shortcut-status-select');
353 drupal_add_tabledrag('shortcuts', 'order', 'sibling', 'shortcut-weight');
354 $rows[] = array(
355 'data' => array(array(
356 'colspan' => 5,
357 'data' => '<strong>' . $map[$status] . '</strong>',
358 )),
359 'class' => array('shortcut-status', 'shortcut-status-' . $status),
360 );
361
362 foreach ($shortcuts_by_status[$status] as $key) {
363 $shortcut = &$form['shortcuts'][$status][$key];
364 $row = array();
365 $row[] = drupal_render($shortcut['name']);
366 $row[] = drupal_render($shortcut['weight']);
367 $row[] = drupal_render($shortcut['status']);
368 $row[] = drupal_render($shortcut['edit']);
369 $row[] = drupal_render($shortcut['delete']);
370 $rows[] = array(
371 'data' => $row,
372 'class' => array('draggable'),
373 );
374 }
375
376 if ($status == 'enabled') {
377 for ($i = 0; $i < shortcut_max_slots(); $i++) {
378 $rows['empty-' . $i] = array(
379 'data' => array(array(
380 'colspan' => 5,
381 'data' => '<em>' . t('Empty') . '</em>',
382 )),
383 'class' => array('shortcut-slot-empty'),
384 );
385 }
386 $count_shortcuts = count($shortcuts_by_status[$status]);
387 if (!empty($count_shortcuts)) {
388 for ($i = 0; $i < min($count_shortcuts, shortcut_max_slots()); $i++) {
389 $rows['empty-' . $i]['class'][] = 'shortcut-slot-hidden';
390 }
391 }
392 }
393 }
394
395 $header = array(t('Name'), t('Weight'), t('Status'), array('data' => t('Operations'), 'colspan' => 2));
396 $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'shortcuts'), 'empty' => t('No shortcuts available. <a href="@link">Add a shortcut</a>.', array('@link' => url('admin/config/user-interface/shortcut/' . $form['#shortcut_set_name'] . '/add-link')))));
397 $output .= drupal_render($form['actions']);
398 $output = drupal_render_children($form) . $output;
399 return $output;
400 }
401
419 function shortcut_link_add($form, &$form_state, $shortcut_set) {
420 drupal_set_title(t('Add new shortcut'));
421 $form['shortcut_set'] = array(
422 '#type' => 'value',
423 '#value' => $shortcut_set,
424 );
425 $form += _shortcut_link_form_elements();
426 return $form;
427 }
428
446 function shortcut_link_edit($form, &$form_state, $shortcut_link) {
447 drupal_set_title(t('Editing @shortcut', array('@shortcut' => $shortcut_link['link_title'])));
448 $form['original_shortcut_link'] = array(
449 '#type' => 'value',
450 '#value' => $shortcut_link,
451 );
452 $form += _shortcut_link_form_elements($shortcut_link);
453 return $form;
454 }
455
466 function _shortcut_link_form_elements($shortcut_link = NULL) {
467 if (!isset($shortcut_link)) {
468 $shortcut_link = array(
469 'link_title' => '',
470 'link_path' => ''
471 );
472 }
473 else {
474 $shortcut_link['link_path'] = ($shortcut_link['link_path'] == '<front>') ? '' : drupal_get_path_alias($shortcut_link['link_path']);
475 }
476
477 $form['shortcut_link']['#tree'] = TRUE;
478 $form['shortcut_link']['link_title'] = array(
479 '#type' => 'textfield',
480 '#title' => t('Name'),
481 '#description' => t('The name of the shortcut.'),
482 '#size' => 40,
483 '#maxlength' => 255,
484 '#default_value' => $shortcut_link['link_title'],
485 '#required' => TRUE,
486 );
487
488 $form['shortcut_link']['link_path'] = array(
489 '#type' => 'textfield',
490 '#title' => t('Path'),
491 '#description' => t('The path to the shortcut.'),
492 '#size' => 40,
493 '#maxlength' => 255,
494 '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
495 '#default_value' => $shortcut_link['link_path'],
496 );
497
498 $form['#validate'][] = 'shortcut_link_edit_validate';
499
500 $form['actions'] = array('#type' => 'actions');
501 $form['actions']['submit'] = array(
502 '#type' => 'submit',
503 '#value' => t('Save'),
504 );
505
506 return $form;
507 }
508
512 function shortcut_link_edit_validate($form, &$form_state) {
513 if (!shortcut_valid_link($form_state['values']['shortcut_link']['link_path'])) {
514 form_set_error('shortcut_link][link_path', t('The link must correspond to a valid path on the site.'));
515 }
516 }
517
521 function shortcut_link_edit_submit($form, &$form_state) {
522 // Normalize the path in case it is an alias.
523 $shortcut_path = drupal_get_normal_path($form_state['values']['shortcut_link']['link_path']);
524 if (empty($shortcut_path)) {
525 $shortcut_path = '<front>';
526 }
527 $form_state['values']['shortcut_link']['link_path'] = $shortcut_path;
528
529 $shortcut_link = array_merge($form_state['values']['original_shortcut_link'], $form_state['values']['shortcut_link']);
530
531 menu_link_save($shortcut_link);
532 $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $shortcut_link['menu_name'];
533 drupal_set_message(t('The shortcut %link has been updated.', array('%link' => $shortcut_link['link_title'])));
534 }
535
539 function shortcut_link_add_submit($form, &$form_state) {
540 // Add the shortcut link to the set.
541 $shortcut_set = $form_state['values']['shortcut_set'];
542 $shortcut_link = $form_state['values']['shortcut_link'];
543 $shortcut_link['menu_name'] = $shortcut_set->set_name;
544 shortcut_admin_add_link($shortcut_link, $shortcut_set, shortcut_max_slots());
545 shortcut_set_save($shortcut_set);
546 $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $shortcut_link['menu_name'];
547 drupal_set_message(t('Added a shortcut for %title.', array('%title' => $shortcut_link['link_title'])));
548 }
549
566 function shortcut_admin_add_link($shortcut_link, &$shortcut_set, $limit = NULL) {
567 if (isset($limit)) {
568 // Disable any existing links at the end of the list that would cause the
569 // limit to be exceeded. Take into account whether or not the new link will
570 // be enabled and count towards the total.
571 $number_enabled = !empty($shortcut_link['hidden']) ? 0 : 1;
572 foreach ($shortcut_set->links as &$link) {
573 if (!$link['hidden']) {
574 $number_enabled++;
575 if ($number_enabled > $limit) {
576 $link['hidden'] = 1;
577 }
578 }
579 }
580 }
581
582 // Normalize the path in case it is an alias.
583 $shortcut_link['link_path'] = drupal_get_normal_path($shortcut_link['link_path']);
584 if (empty($shortcut_link['link_path'])) {
585 $shortcut_link['link_path'] = '<front>';
586 }
587
588 // Add the link to the end of the list.
589 $shortcut_set->links[] = $shortcut_link;
590 shortcut_set_reset_link_weights($shortcut_set);
591 }
592
611 function shortcut_set_edit_form($form, &$form_state, $shortcut_set) {
612 $form['shortcut_set'] = array(
613 '#type' => 'value',
614 '#value' => $shortcut_set,
615 );
616 $form['title'] = array(
617 '#type' => 'textfield',
618 '#title' => t('Set name'),
619 '#default_value' => $shortcut_set->title,
620 '#maxlength' => 255,
621 '#required' => TRUE,
622 '#weight' => -5,
623 );
624 $form['actions'] = array('#type' => 'actions');
625 $form['actions']['submit'] = array(
626 '#type' => 'submit',
627 '#value' => t('Save'),
628 '#weight' => 5,
629 );
630
631 return $form;
632 }
633
637 function shortcut_set_edit_form_validate($form, &$form_state) {
638 // Check to prevent a duplicate title, if the title was edited from its
639 // original value.
640 if ($form_state['values']['title'] != $form_state['values']['shortcut_set']->title && shortcut_set_title_exists($form_state['values']['title'])) {
641 form_set_error('title', t('The shortcut set %name already exists. Choose another name.', array('%name' => $form_state['values']['title'])));
642 }
643 }
644
648 function shortcut_set_edit_form_submit($form, &$form_state) {
649 $shortcut_set = $form_state['values']['shortcut_set'];
650 $shortcut_set->title = $form_state['values']['title'];
651 shortcut_set_save($shortcut_set);
652 drupal_set_message(t('Updated set name to %set-name.', array('%set-name' => $shortcut_set->title)));
653 $form_state['redirect'] = "admin/config/user-interface/shortcut/$shortcut_set->set_name";
654 }
655
673 function shortcut_set_delete_form($form, &$form_state, $shortcut_set) {
674 $form['shortcut_set'] = array(
675 '#type' => 'value',
676 '#value' => $shortcut_set->set_name,
677 );
678
679 // Find out how many users are directly assigned to this shortcut set, and
680 // make a message.
681 $number = db_query('SELECT COUNT(*) FROM {shortcut_set_users} WHERE set_name = :name', array(':name' => $shortcut_set->set_name))->fetchField();
682 $info = '';
683 if ($number) {
684 $info .= '<p>' . format_plural($number,
685 '1 user has chosen or been assigned to this shortcut set.',
686 '@count users have chosen or been assigned to this shortcut set.') . '</p>';
687 }
688
689 // Also, if a module implements hook_shortcut_default_set(), it's possible
690 // that this set is being used as a default set. Add a message about that too.
691 if (count(module_implements('shortcut_default_set')) > 0) {
692 $info .= '<p>' . t('If you have chosen this shortcut set as the default for some or all users, they may also be affected by deleting it.') . '</p>';
693 }
694
695 $form['info'] = array(
696 '#markup' => $info,
697 );
698
699 return confirm_form(
700 $form,
701 t('Are you sure you want to delete the shortcut set %title?', array('%title' => $shortcut_set->title)),
702 'admin/config/user-interface/shortcut/' . $shortcut_set->set_name,
703 t('This action cannot be undone.'),
704 t('Delete'),
705 t('Cancel')
706 );
707 }
708
712 function shortcut_set_delete_form_submit($form, &$form_state) {
713 $shortcut_set = shortcut_set_load($form_state['values']['shortcut_set']);
714 shortcut_set_delete($shortcut_set);
715 $form_state['redirect'] = 'admin/config/user-interface/shortcut';
716 drupal_set_message(t('The shortcut set %title has been deleted.', array('%title' => $shortcut_set->title)));
717 }
718
735 function shortcut_link_delete($form, &$form_state, $shortcut_link) {
736 $form['shortcut_link'] = array(
737 '#type' => 'value',
738 '#value' => $shortcut_link,
739 );
740
741 return confirm_form(
742 $form,
743 t('Are you sure you want to delete the shortcut %title?', array('%title' => $shortcut_link['link_title'])),
744 'admin/config/user-interface/shortcut/' . $shortcut_link['menu_name'],
745 t('This action cannot be undone.'),
746 t('Delete'),
747 t('Cancel')
748 );
749 }
750
754 function shortcut_link_delete_submit($form, &$form_state) {
755 $shortcut_link = $form_state['values']['shortcut_link'];
756 menu_link_delete($shortcut_link['mlid']);
757 $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $shortcut_link['menu_name'];
758 drupal_set_message(t('The shortcut %title has been deleted.', array('%title' => $shortcut_link['link_title'])));
759 }
760
769 function shortcut_link_add_inline($shortcut_set) {
770 if (isset($_REQUEST['token']) && drupal_valid_token($_REQUEST['token'], 'shortcut-add-link') && shortcut_valid_link($_GET['link'])) {
771 $item = menu_get_item($_GET['link']);
772 $title = ($item && $item['title']) ? $item['title'] : $_GET['name'];
773 $link = array(
774 'link_title' => $title,
775 'link_path' => $_GET['link'],
776 );
777 shortcut_admin_add_link($link, $shortcut_set, shortcut_max_slots());
778 if (shortcut_set_save($shortcut_set)) {
779 drupal_set_message(t('Added a shortcut for %title.', array('%title' => $link['link_title'])));
780 }
781 else {
782 drupal_set_message(t('Unable to add a shortcut for %title.', array('%title' => $link['link_title'])));
783 }
784 drupal_goto();
785 }
786
787 return MENU_ACCESS_DENIED;
788 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
shortcut_link_edit_submit
shortcut_link_edit_submit($form, &$form_state)
Definition: shortcut.admin.inc:521
shortcut_set_delete_form
shortcut_set_delete_form($form, &$form_state, $shortcut_set)
Definition: shortcut.admin.inc:673
shortcut_link_delete
shortcut_link_delete($form, &$form_state, $shortcut_link)
Definition: shortcut.admin.inc:735
shortcut_set_switch
shortcut_set_switch($form, &$form_state, $account=NULL)
Definition: shortcut.admin.inc:38
shortcut_set_switch_submit
shortcut_set_switch_submit($form, &$form_state)
Definition: shortcut.admin.inc:125
menu_link_save
menu_link_save(&$item, $existing_item=array(), $parent_candidates=array())
Definition: menu.inc:3074
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
menu_get_item
menu_get_item($path=NULL, $router_item=NULL)
Definition: menu.inc:447
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
MENU_ACCESS_DENIED
const MENU_ACCESS_DENIED
Definition: menu.inc:239
shortcut_link_edit
shortcut_link_edit($form, &$form_state, $shortcut_link)
Definition: shortcut.admin.inc:446
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
shortcut_max_slots
shortcut_max_slots()
Definition: shortcut.admin.inc:16
$name
print $name
Definition: profile-listing.tpl.php:43
shortcut_admin_add_link
shortcut_admin_add_link($shortcut_link, &$shortcut_set, $limit=NULL)
Definition: shortcut.admin.inc:566
$header
print $header
Definition: forum-topic-list.tpl.php:42
shortcut_set_delete_form_submit
shortcut_set_delete_form_submit($form, &$form_state)
Definition: shortcut.admin.inc:712
menu_link_delete
menu_link_delete($mlid, $path=NULL)
Definition: menu.inc:2996
shortcut_set_reset_link_weights
shortcut_set_reset_link_weights(&$shortcut_set)
Definition: shortcut.module:425
shortcut_link_edit_validate
shortcut_link_edit_validate($form, &$form_state)
Definition: shortcut.admin.inc:512
shortcut_set_load
shortcut_set_load($set_name)
Definition: shortcut.module:315
shortcut_link_delete_submit
shortcut_link_delete_submit($form, &$form_state)
Definition: shortcut.admin.inc:754
shortcut_current_displayed_set
shortcut_current_displayed_set($account=NULL)
Definition: shortcut.module:481
shortcut_link_add
shortcut_link_add($form, &$form_state, $shortcut_set)
Definition: shortcut.admin.inc:419
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
shortcut_set_customize_submit
shortcut_set_customize_submit($form, &$form_state)
Definition: shortcut.admin.inc:318
drupal_get_path_alias
drupal_get_path_alias($path=NULL, $path_language=NULL)
Definition: path.inc:235
shortcut_set_edit_form_validate
shortcut_set_edit_form_validate($form, &$form_state)
Definition: shortcut.admin.inc:637
drupal_valid_token
drupal_valid_token($token, $value= '', $skip_anonymous=FALSE)
Definition: common.inc:5095
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$info
$info
Definition: color.inc:6
shortcut_set_delete_access
shortcut_set_delete_access($shortcut_set)
Definition: shortcut.module:242
shortcut_link_add_inline
shortcut_link_add_inline($shortcut_set)
Definition: shortcut.admin.inc:769
menu_link_load
menu_link_load($mlid)
Definition: menu.inc:2635
shortcut_set_add_form_validate
shortcut_set_add_form_validate($form, &$form_state)
Definition: shortcut.admin.inc:228
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_get_normal_path
drupal_get_normal_path($path, $path_language=NULL)
Definition: path.inc:259
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
shortcut_set_add_form_submit
shortcut_set_add_form_submit($form, &$form_state)
Definition: shortcut.admin.inc:238
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
shortcut_set_customize
shortcut_set_customize($form, &$form_state, $shortcut_set)
Definition: shortcut.admin.inc:266
shortcut_set_edit_form
shortcut_set_edit_form($form, &$form_state, $shortcut_set)
Definition: shortcut.admin.inc:611
shortcut_sets
shortcut_sets()
Definition: shortcut.module:583
theme_shortcut_set_customize
theme_shortcut_set_customize($variables)
Definition: shortcut.admin.inc:340
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
shortcut_set_title_exists
shortcut_set_title_exists($title)
Definition: shortcut.module:599
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
shortcut_default_set
shortcut_default_set($account=NULL)
Definition: shortcut.module:521
shortcut_set_admin
shortcut_set_admin()
Definition: shortcut.admin.inc:169
shortcut_set_delete
shortcut_set_delete($shortcut_set)
Definition: shortcut.module:391
shortcut_set_switch_validate
shortcut_set_switch_validate($form, &$form_state)
Definition: shortcut.admin.inc:109
shortcut_valid_link
shortcut_valid_link($path)
Definition: shortcut.module:614
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$row
$row
Definition: block-admin-display-form.tpl.php:47
title
print $topic title
Definition: forum-topic-list.tpl.php:50
shortcut_link_add_submit
shortcut_link_add_submit($form, &$form_state)
Definition: shortcut.admin.inc:539
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
shortcut_set_assign_user
shortcut_set_assign_user($shortcut_set, $account)
Definition: shortcut.module:441
current_path
current_path()
Definition: path.inc:354
shortcut_set_save
shortcut_set_save(&$shortcut_set)
Definition: shortcut.module:351
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
shortcut_set_edit_form_submit
shortcut_set_edit_form_submit($form, &$form_state)
Definition: shortcut.admin.inc:648
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
_shortcut_link_form_elements
_shortcut_link_form_elements($shortcut_link=NULL)
Definition: shortcut.admin.inc:466
shortcut_set_add_form
shortcut_set_add_form($form, &$form_state)
Definition: shortcut.admin.inc:208
$links
print $links
Definition: poll-results--block.tpl.php:28
menu_links_clone
menu_links_clone($links, $menu_name=NULL)
Definition: menu.inc:2934
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search.extender.inc Source File

  • modules
  • search
search.extender.inc
Go to the documentation of this file.
1 <?php
2
27 class SearchQuery extends SelectQueryExtender {
33 protected $searchExpression;
34
44 protected $type;
45
51 protected $keys = array('positive' => array(), 'negative' => array());
52
58 protected $simple = TRUE;
59
68 protected $conditions;
69
75 protected $matches = 0;
76
84 protected $words = array();
85
95 protected $normalize;
96
102 protected $executedFirstPass = FALSE;
103
111 protected $scores = array();
112
118 protected $scoresArguments = array();
119
125 protected $multiply = array();
126
135 protected $expressionsIgnored = FALSE;
136
148 public function searchExpression($expression, $module) {
149 $this->searchExpression = $expression;
150 $this->type = $module;
151
152 return $this;
153 }
154
168 public function setOption($option, $column) {
169 if ($values = search_expression_extract($this->searchExpression, $option)) {
170 $or = db_or();
171 foreach (explode(',', $values) as $value) {
172 $or->condition($column, $value);
173 }
174 $this->condition($or);
175 $this->searchExpression = search_expression_insert($this->searchExpression, $option);
176 return TRUE;
177 }
178 return FALSE;
179 }
180
186 protected function parseSearchExpression() {
187 // Matchs words optionally prefixed by a dash. A word in this case is
188 // something between two spaces, optionally quoted.
189 preg_match_all('/ (-?)("[^"]+"|[^" ]+)/i', ' ' . $this->searchExpression , $keywords, PREG_SET_ORDER);
190
191 if (count($keywords) == 0) {
192 return;
193 }
194
195 // Classify tokens.
196 $or = FALSE;
197 $warning = '';
198 $limit_combinations = variable_get('search_and_or_limit', 7);
199 // The first search expression does not count as AND.
200 $and_count = -1;
201 $or_count = 0;
202 foreach ($keywords as $match) {
203 if ($or_count && $and_count + $or_count >= $limit_combinations) {
204 // Ignore all further search expressions to prevent Denial-of-Service
205 // attacks using a high number of AND/OR combinations.
206 $this->expressionsIgnored = TRUE;
207 break;
208 }
209 $phrase = FALSE;
210 // Strip off phrase quotes.
211 if ($match[2]{0} == '"') {
212 $match[2] = substr($match[2], 1, -1);
213 $phrase = TRUE;
214 $this->simple = FALSE;
215 }
216 // Simplify keyword according to indexing rules and external
217 // preprocessors. Use same process as during search indexing, so it
218 // will match search index.
219 $words = search_simplify($match[2]);
220 // Re-explode in case simplification added more words, except when
221 // matching a phrase.
222 $words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
223 // Negative matches.
224 if ($match[1] == '-') {
225 $this->keys['negative'] = array_merge($this->keys['negative'], $words);
226 }
227 // OR operator: instead of a single keyword, we store an array of all
228 // OR'd keywords.
229 elseif ($match[2] == 'OR' && count($this->keys['positive'])) {
230 $last = array_pop($this->keys['positive']);
231 // Starting a new OR?
232 if (!is_array($last)) {
233 $last = array($last);
234 }
235 $this->keys['positive'][] = $last;
236 $or = TRUE;
237 $or_count++;
238 continue;
239 }
240 // AND operator: implied, so just ignore it.
241 elseif ($match[2] == 'AND' || $match[2] == 'and') {
242 $warning = $match[2];
243 continue;
244 }
245
246 // Plain keyword.
247 else {
248 if ($match[2] == 'or') {
249 $warning = $match[2];
250 }
251 if ($or) {
252 // Add to last element (which is an array).
253 $this->keys['positive'][count($this->keys['positive']) - 1] = array_merge($this->keys['positive'][count($this->keys['positive']) - 1], $words);
254 }
255 else {
256 $this->keys['positive'] = array_merge($this->keys['positive'], $words);
257 $and_count++;
258 }
259 }
260 $or = FALSE;
261 }
262
263 // Convert keywords into SQL statements.
264 $this->conditions = db_and();
265 $simple_and = FALSE;
266 $simple_or = FALSE;
267 // Positive matches.
268 foreach ($this->keys['positive'] as $key) {
269 // Group of ORed terms.
270 if (is_array($key) && count($key)) {
271 $simple_or = TRUE;
272 $any = FALSE;
273 $queryor = db_or();
274 foreach ($key as $or) {
275 list($num_new_scores) = $this->parseWord($or);
276 $any |= $num_new_scores;
277 $queryor->condition('d.data', "% $or %", 'LIKE');
278 }
279 if (count($queryor)) {
280 $this->conditions->condition($queryor);
281 // A group of OR keywords only needs to match once.
282 $this->matches += ($any > 0);
283 }
284 }
285 // Single ANDed term.
286 else {
287 $simple_and = TRUE;
288 list($num_new_scores, $num_valid_words) = $this->parseWord($key);
289 $this->conditions->condition('d.data', "% $key %", 'LIKE');
290 if (!$num_valid_words) {
291 $this->simple = FALSE;
292 }
293 // Each AND keyword needs to match at least once.
294 $this->matches += $num_new_scores;
295 }
296 }
297 if ($simple_and && $simple_or) {
298 $this->simple = FALSE;
299 }
300 // Negative matches.
301 foreach ($this->keys['negative'] as $key) {
302 $this->conditions->condition('d.data', "% $key %", 'NOT LIKE');
303 $this->simple = FALSE;
304 }
305
306 if ($warning == 'or') {
307 drupal_set_message(t('Search for either of the two terms with uppercase <strong>OR</strong>. For example, <strong>cats OR dogs</strong>.'));
308 }
309 }
310
314 protected function parseWord($word) {
315 $num_new_scores = 0;
316 $num_valid_words = 0;
317 // Determine the scorewords of this word/phrase.
318 $split = explode(' ', $word);
319 foreach ($split as $s) {
320 $num = is_numeric($s);
321 if ($num || drupal_strlen($s) >= variable_get('minimum_word_size', 3)) {
322 if (!isset($this->words[$s])) {
323 $this->words[$s] = $s;
324 $num_new_scores++;
325 }
326 $num_valid_words++;
327 }
328 }
329 // Return matching snippet and number of added words.
330 return array($num_new_scores, $num_valid_words);
331 }
332
343 public function executeFirstPass() {
344 $this->parseSearchExpression();
345
346 if (count($this->words) == 0) {
347 form_set_error('keys', format_plural(variable_get('minimum_word_size', 3), 'You must include at least one positive keyword with 1 character or more.', 'You must include at least one positive keyword with @count characters or more.'));
348 return FALSE;
349 }
350 if ($this->expressionsIgnored) {
351 drupal_set_message(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', array('@count' => variable_get('search_and_or_limit', 7))), 'warning');
352 }
353 $this->executedFirstPass = TRUE;
354
355 if (!empty($this->words)) {
356 $or = db_or();
357 foreach ($this->words as $word) {
358 $or->condition('i.word', $word);
359 }
360 $this->condition($or);
361 }
362 // Build query for keyword normalization.
363 $this->join('search_total', 't', 'i.word = t.word');
364 $this
365 ->condition('i.type', $this->type)
366 ->groupBy('i.type')
367 ->groupBy('i.sid')
368 ->having('COUNT(*) >= :matches', array(':matches' => $this->matches));
369
370 // Clone the query object to do the firstPass query;
371 $first = clone $this->query;
372
373 // For complex search queries, add the LIKE conditions to the first pass query.
374 if (!$this->simple) {
375 $first->join('search_dataset', 'd', 'i.sid = d.sid AND i.type = d.type');
376 $first->condition($this->conditions);
377 }
378
379 // Calculate maximum keyword relevance, to normalize it.
380 $first->addExpression('SUM(i.score * t.count)', 'calculated_score');
381 $this->normalize = $first
382 ->range(0, 1)
383 ->orderBy('calculated_score', 'DESC')
384 ->execute()
385 ->fetchField();
386
387 if ($this->normalize) {
388 return TRUE;
389 }
390 return FALSE;
391 }
392
420 public function addScore($score, $arguments = array(), $multiply = FALSE) {
421 if ($multiply) {
422 $i = count($this->multiply);
423 // Modify the score expression so it is multiplied by the multiplier,
424 // with a divisor to renormalize.
425 $score = "CAST(:multiply_$i AS DECIMAL) * COALESCE(( " . $score . "), 0) / CAST(:total_$i AS DECIMAL)";
426 // Add an argument for the multiplier. The :total_$i argument is taken
427 // care of in the execute() method, which is when the total divisor is
428 // calculated.
429 $arguments[':multiply_' . $i] = $multiply;
430 $this->multiply[] = $multiply;
431 }
432
433 $this->scores[] = $score;
434 $this->scoresArguments += $arguments;
435
436 return $this;
437 }
438
450 public function execute()
451 {
452 if (!$this->executedFirstPass) {
453 $this->executeFirstPass();
454 }
455 if (!$this->normalize) {
456 return new DatabaseStatementEmpty();
457 }
458
459 // Add conditions to query.
460 $this->join('search_dataset', 'd', 'i.sid = d.sid AND i.type = d.type');
461 $this->condition($this->conditions);
462
463 if (empty($this->scores)) {
464 // Add default score.
465 $this->addScore('i.relevance');
466 }
467
468 if (count($this->multiply)) {
469 // Re-normalize scores with multipliers by dividing by the total of all
470 // multipliers. The expressions were altered in addScore(), so here just
471 // add the arguments for the total.
472 $i = 0;
473 $sum = array_sum($this->multiply);
474 foreach ($this->multiply as $total) {
475 $this->scoresArguments[':total_' . $i] = $sum;
476 $i++;
477 }
478 }
479
480 // Replace the pseudo-expression 'i.relevance' with a measure of keyword
481 // relevance in all score expressions, using string replacement. Careful
482 // though! If you just print out a float, some locales use ',' as the
483 // decimal separator in PHP, while SQL always uses '.'. So, make sure to
484 // set the number format correctly.
485 $relevance = number_format((1.0 / $this->normalize), 10, '.', '');
486 $this->scores = str_replace('i.relevance', '(' . $relevance . ' * i.score * t.count)', $this->scores);
487
488 // Add all scores together to form a query field.
489 $this->addExpression('SUM(' . implode(' + ', $this->scores) . ')', 'calculated_score', $this->scoresArguments);
490
491 // If an order has not yet been set for this query, add a default order
492 // that sorts by the calculated sum of scores.
493 if (count($this->getOrderBy()) == 0) {
494 $this->orderBy('calculated_score', 'DESC');
495 }
496
497 // Add tag and useful metadata.
498 $this
499 ->addTag('search_' . $this->type)
500 ->addMetaData('normalize', $this->normalize)
501 ->fields('i', array('type', 'sid'));
502
503 return $this->query->execute();
504 }
505
513 public function countQuery() {
514 // Clone the inner query.
515 $inner = clone $this->query;
516
517 // Add conditions to query.
518 $inner->join('search_dataset', 'd', 'i.sid = d.sid AND i.type = d.type');
519 $inner->condition($this->conditions);
520
521 // Remove existing fields and expressions, they are not needed for a count
522 // query.
523 $fields =& $inner->getFields();
524 $fields = array();
525 $expressions =& $inner->getExpressions();
526 $expressions = array();
527
528 // Add the sid as the only field and count them as a subquery.
529 $count = db_select($inner->fields('i', array('sid')), NULL, array('target' => 'slave'));
530
531 // Add the COUNT() expression.
532 $count->addExpression('COUNT(*)');
533
534 return $count;
535 }
536 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
SearchQuery\addScore
addScore($score, $arguments=array(), $multiply=FALSE)
Definition: search.extender.inc:420
SearchQuery\$keys
$keys
Definition: search.extender.inc:51
SearchQuery\$scores
$scores
Definition: search.extender.inc:111
SearchQuery\$type
$type
Definition: search.extender.inc:44
SearchQuery\$matches
$matches
Definition: search.extender.inc:75
SelectQueryExtender\orderBy
orderBy($field, $direction= 'ASC')
Definition: select.inc:764
drupal_strlen
drupal_strlen($text)
Definition: unicode.inc:474
SearchQuery\$words
$words
Definition: search.extender.inc:84
$module
print $module
Definition: search-results.tpl.php:28
SearchQuery\countQuery
countQuery()
Definition: search.extender.inc:513
SelectQueryExtender\addExpression
addExpression($expression, $alias=NULL, $arguments=array())
Definition: select.inc:740
SelectQueryExtender
Definition: select.inc:535
SearchQuery\$expressionsIgnored
$expressionsIgnored
Definition: search.extender.inc:135
SearchQuery\$conditions
$conditions
Definition: search.extender.inc:68
SearchQuery\setOption
setOption($option, $column)
Definition: search.extender.inc:168
SelectQueryExtender\condition
condition($field, $value=NULL, $operator=NULL)
Definition: select.inc:613
db_or
db_or()
Definition: database.inc:2662
SearchQuery\execute
execute()
Definition: search.extender.inc:450
DatabaseStatementEmpty
Definition: database.inc:2236
SearchQuery\$simple
$simple
Definition: search.extender.inc:58
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
SelectQueryExtender\join
join($table, $alias=NULL, $condition=NULL, $arguments=array())
Definition: select.inc:744
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
SelectQueryExtender\$query
$query
Definition: select.inc:542
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
SearchQuery\parseSearchExpression
parseSearchExpression()
Definition: search.extender.inc:186
SearchQuery\$scoresArguments
$scoresArguments
Definition: search.extender.inc:118
search_expression_extract
search_expression_extract($expression, $option)
Definition: search.module:869
SearchQuery
Definition: search.extender.inc:27
SearchQuery\parseWord
parseWord($word)
Definition: search.extender.inc:314
SearchQuery\searchExpression
searchExpression($expression, $module)
Definition: search.extender.inc:148
search_simplify
search_simplify($text)
Definition: search.module:409
SearchQuery\$multiply
$multiply
Definition: search.extender.inc:125
SelectQueryExtender\getOrderBy
& getOrderBy()
Definition: select.inc:682
SelectQueryExtender\conditions
& conditions()
Definition: select.inc:618
SearchQuery\executeFirstPass
executeFirstPass()
Definition: search.extender.inc:343
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
SearchQuery\$executedFirstPass
$executedFirstPass
Definition: search.extender.inc:102
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
SearchQuery\$searchExpression
$searchExpression
Definition: search.extender.inc:33
search_expression_insert
search_expression_insert($expression, $option, $value=NULL)
Definition: search.module:898
db_and
db_and()
Definition: database.inc:2671
SearchQuery\$normalize
$normalize
Definition: search.extender.inc:95
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/statistics/statistics.pages.inc Source File

  • modules
  • statistics
statistics.pages.inc
Go to the documentation of this file.
1 <?php
2
15 function statistics_node_tracker() {
16 if ($node = node_load(arg(1))) {
17
18 $header = array(
19 array('data' => t('Time'), 'field' => 'a.timestamp', 'sort' => 'desc'),
20 array('data' => t('Referrer'), 'field' => 'a.url'),
21 array('data' => t('User'), 'field' => 'u.name'),
22 array('data' => t('Operations')));
23
24 $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
25 $query->join('users', 'u', 'a.uid = u.uid');
26
27 $query
28 ->fields('a', array('aid', 'timestamp', 'url', 'uid'))
29 ->fields('u', array('name'))
30 ->condition(db_or()
31 ->condition('a.path', 'node/' . $node->nid)
32 ->condition('a.path', 'node/' . $node->nid . '/%', 'LIKE'))
33 ->limit(30)
34 ->orderByHeader($header);
35
36 $result = $query->execute();
37 $rows = array();
38 foreach ($result as $log) {
39 $rows[] = array(
40 array('data' => format_date($log->timestamp, 'short'), 'class' => array('nowrap')),
41 _statistics_link($log->url),
42 theme('username', array('account' => $log)),
43 l(t('details'), "admin/reports/access/$log->aid"),
44 );
45 }
46
47 drupal_set_title($node->title);
48 $build['statistics_table'] = array(
49 '#theme' => 'table',
50 '#header' => $header,
51 '#rows' => $rows,
52 '#empty' => t('No statistics available.'),
53 );
54 $build['statistics_pager'] = array('#theme' => 'pager');
55 return $build;
56 }
57 return MENU_NOT_FOUND;
58 }
59
67 function statistics_user_tracker() {
68 if ($account = user_load(arg(1))) {
69
70 $header = array(
71 array('data' => t('Timestamp'), 'field' => 'timestamp', 'sort' => 'desc'),
72 array('data' => t('Page'), 'field' => 'path'),
73 array('data' => t('Operations')));
74 $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
75 $query
76 ->fields('a', array('aid', 'timestamp', 'path', 'title'))
77 ->condition('uid', $account->uid)
78 ->limit(30)
79 ->orderByHeader($header);
80
81 $result = $query->execute();
82 $rows = array();
83 foreach ($result as $log) {
84 $rows[] = array(
85 array('data' => format_date($log->timestamp, 'short'), 'class' => array('nowrap')),
86 _statistics_format_item($log->title, $log->path),
87 l(t('details'), "admin/reports/access/$log->aid"));
88 }
89
90 drupal_set_title(format_username($account));
91 $build['statistics_table'] = array(
92 '#theme' => 'table',
93 '#header' => $header,
94 '#rows' => $rows,
95 '#empty' => t('No statistics available.'),
96 );
97 $build['statistics_pager'] = array('#theme' => 'pager');
98 return $build;
99 }
100 return MENU_NOT_FOUND;
101 }
l
l($text, $path, array $options=array())
Definition: common.inc:2432
statistics_user_tracker
statistics_user_tracker()
Definition: statistics.pages.inc:67
format_username
format_username($account)
Definition: common.inc:2106
_statistics_link
_statistics_link($path, $width=35)
Definition: statistics.module:404
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
statistics_node_tracker
statistics_node_tracker()
Definition: statistics.pages.inc:15
$header
print $header
Definition: forum-topic-list.tpl.php:42
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
db_or
db_or()
Definition: database.inc:2662
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
MENU_NOT_FOUND
const MENU_NOT_FOUND
Definition: menu.inc:234
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
_statistics_format_item
_statistics_format_item($title, $path)
Definition: statistics.module:421
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.settings.inc Source File

  • modules
  • update
update.settings.inc
Go to the documentation of this file.
1 <?php
2
15 function update_settings($form) {
16 $form['update_check_frequency'] = array(
17 '#type' => 'radios',
18 '#title' => t('Check for updates'),
19 '#default_value' => variable_get('update_check_frequency', 1),
20 '#options' => array(
21 '1' => t('Daily'),
22 '7' => t('Weekly'),
23 ),
24 '#description' => t('Select how frequently you want to automatically check for new releases of your currently installed modules and themes.'),
25 );
26
27 $form['update_check_disabled'] = array(
28 '#type' => 'checkbox',
29 '#title' => t('Check for updates of disabled modules and themes'),
30 '#default_value' => variable_get('update_check_disabled', FALSE),
31 );
32
33 $notify_emails = variable_get('update_notify_emails', array());
34 $form['update_notify_emails'] = array(
35 '#type' => 'textarea',
36 '#title' => t('E-mail addresses to notify when updates are available'),
37 '#rows' => 4,
38 '#default_value' => implode("\n", $notify_emails),
39 '#description' => t('Whenever your site checks for available updates and finds new releases, it can notify a list of users via e-mail. Put each address on a separate line. If blank, no e-mails will be sent.'),
40 );
41
42 $form['update_notification_threshold'] = array(
43 '#type' => 'radios',
44 '#title' => t('E-mail notification threshold'),
45 '#default_value' => variable_get('update_notification_threshold', 'all'),
46 '#options' => array(
47 'all' => t('All newer versions'),
48 'security' => t('Only security updates'),
49 ),
50 '#description' => t('You can choose to send e-mail only if a security update is available, or to be notified about all newer versions. If there are updates available of Drupal core or any of your installed modules and themes, your site will always print a message on the <a href="@status_report">status report</a> page, and will also display an error message on administration pages if there is a security update.', array('@status_report' => url('admin/reports/status')))
51 );
52
53 $form = system_settings_form($form);
54 // Custom validation callback for the email notification setting.
55 $form['#validate'][] = 'update_settings_validate';
56 // We need to call our own submit callback first, not the one from
57 // system_settings_form(), so that we can process and save the emails.
58 unset($form['#submit']);
59
60 return $form;
61 }
62
70 function update_settings_validate($form, &$form_state) {
71 if (!empty($form_state['values']['update_notify_emails'])) {
72 $valid = array();
73 $invalid = array();
74 foreach (explode("\n", trim($form_state['values']['update_notify_emails'])) as $email) {
75 $email = trim($email);
76 if (!empty($email)) {
77 if (valid_email_address($email)) {
78 $valid[] = $email;
79 }
80 else {
81 $invalid[] = $email;
82 }
83 }
84 }
85 if (empty($invalid)) {
86 $form_state['notify_emails'] = $valid;
87 }
88 elseif (count($invalid) == 1) {
89 form_set_error('update_notify_emails', t('%email is not a valid e-mail address.', array('%email' => reset($invalid))));
90 }
91 else {
92 form_set_error('update_notify_emails', t('%emails are not valid e-mail addresses.', array('%emails' => implode(', ', $invalid))));
93 }
94 }
95 }
96
108 function update_settings_submit($form, $form_state) {
109 $op = $form_state['values']['op'];
110
111 if (empty($form_state['notify_emails'])) {
112 variable_del('update_notify_emails');
113 }
114 else {
115 variable_set('update_notify_emails', $form_state['notify_emails']);
116 }
117 unset($form_state['notify_emails']);
118 unset($form_state['values']['update_notify_emails']);
119
120 // See if the update_check_disabled setting is being changed, and if so,
121 // invalidate all cached update status data.
122 $check_disabled = variable_get('update_check_disabled', FALSE);
123 if ($form_state['values']['update_check_disabled'] != $check_disabled) {
124 _update_cache_clear();
125 }
126
127 system_settings_form_submit($form, $form_state);
128 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
$op
$op
Definition: update.php:404
update_settings
update_settings($form)
Definition: update.settings.inc:15
_update_cache_clear
_update_cache_clear($cid=NULL, $wildcard=FALSE)
Definition: update.module:846
variable_del
variable_del($name)
Definition: bootstrap.inc:996
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
update_settings_submit
update_settings_submit($form, $form_state)
Definition: update.settings.inc:108
valid_email_address
valid_email_address($mail)
Definition: common.inc:1186
update_settings_validate
update_settings_validate($form, &$form_state)
Definition: update.settings.inc:70
system_settings_form_submit
system_settings_form_submit($form, &$form_state)
Definition: system.module:2776
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
system_settings_form
system_settings_form($form)
Definition: system.module:2755
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.module Source File

  • modules
  • field
field.module
Go to the documentation of this file.
1 <?php
13 class FieldException extends Exception {}
14
15 /*
16 * Load all public Field API functions. Drupal currently has no
17 * mechanism for auto-loading core APIs, so we have to load them on
18 * every page request.
19 */
20 require_once DRUPAL_ROOT . '/modules/field/field.crud.inc';
21 require_once DRUPAL_ROOT . '/modules/field/field.default.inc';
22 require_once DRUPAL_ROOT . '/modules/field/field.info.inc';
23 require_once DRUPAL_ROOT . '/modules/field/field.multilingual.inc';
24 require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
25 require_once DRUPAL_ROOT . '/modules/field/field.form.inc';
26
236 define('FIELD_CARDINALITY_UNLIMITED', -1);
237
243 define('FIELD_BEHAVIOR_NONE', 0x0001);
244
255 define('FIELD_BEHAVIOR_DEFAULT', 0x0002);
256
262 define('FIELD_BEHAVIOR_CUSTOM', 0x0004);
263
268 define('FIELD_LOAD_CURRENT', 'FIELD_LOAD_CURRENT');
269
274 define('FIELD_LOAD_REVISION', 'FIELD_LOAD_REVISION');
275
279 class FieldUpdateForbiddenException extends FieldException {}
280
284 function field_help($path, $arg) {
285 switch ($path) {
286 case 'admin/help#field':
287 $output = '';
288 $output .= '<h3>' . t('About') . '</h3>';
289 $output .= '<p>' . t('The Field module allows custom data fields to be defined for <em>entity</em> types (entities include content items, comments, user accounts, and taxonomy terms). The Field module takes care of storing, loading, editing, and rendering field data. Most users will not interact with the Field module directly, but will instead use the <a href="@field-ui-help">Field UI module</a> user interface. Module developers can use the Field API to make new entity types "fieldable" and thus allow fields to be attached to them. For more information, see the online handbook entry for <a href="@field">Field module</a>.', array('@field-ui-help' => url('admin/help/field_ui'), '@field' => 'http://drupal.org/documentation/modules/field')) . '</p>';
290 $output .= '<h3>' . t('Uses') . '</h3>';
291 $output .= '<dl>';
292 $output .= '<dt>' . t('Enabling field types') . '</dt>';
293 $output .= '<dd>' . t('The Field module provides the infrastructure for fields and field attachment; the field types and input widgets themselves are provided by additional modules. Some of the modules are required; the optional modules can be enabled from the <a href="@modules">Modules administration page</a>. Drupal core includes the following field type modules: Number (required), Text (required), List (required), Taxonomy (optional), Image (optional), and File (optional); the required Options module provides input widgets for other field modules. Additional fields and widgets may be provided by contributed modules, which you can find in the <a href="@contrib">contributed module section of Drupal.org</a>. Currently enabled field and input widget modules:', array('@modules' => url('admin/modules'), '@contrib' => 'http://drupal.org/project/modules', '@options' => url('admin/help/options')));
294
295 // Make a list of all widget and field modules currently enabled, in
296 // order by displayed module name (module names are not translated).
297 $items = array();
298 $info = system_get_info('module');
299 $modules = array_merge(module_implements('field_info'), module_implements('field_widget_info'));
300 $modules = array_unique($modules);
301 sort($modules);
302 foreach ($modules as $module) {
303 $display = $info[$module]['name'];
304 if (module_hook($module, 'help')) {
305 $items['items'][] = l($display, 'admin/help/' . $module);
306 }
307 else {
308 $items['items'][] = $display;
309 }
310 }
311 $output .= theme('item_list', $items) . '</dd>';
312 $output .= '<dt>' . t('Managing field data storage') . '</dt>';
313 $output .= '<dd>' . t('Developers of field modules can either use the default <a href="@sql-store">Field SQL storage module</a> to store data for their fields, or a contributed or custom module developed using the <a href="@storage-api">field storage API</a>.', array('@storage-api' => 'http://api.drupal.org/api/group/field_storage/7', '@sql-store' => url('admin/help/field_sql_storage'))) . '</dd>';
314 $output .= '</dl>';
315 return $output;
316 }
317 }
318
322 function field_theme() {
323 return array(
324 'field' => array(
325 'render element' => 'element',
326 ),
327 'field_multiple_value_form' => array(
328 'render element' => 'element',
329 ),
330 );
331 }
332
336 function field_cron() {
337 // Refresh the 'active' status of fields.
338 field_sync_field_status();
339
340 // Do a pass of purging on deleted Field API data, if any exists.
341 $limit = variable_get('field_purge_batch_size', 10);
342 field_purge_batch($limit);
343 }
344
348 function field_modules_uninstalled($modules) {
349 module_load_include('inc', 'field', 'field.crud');
350 foreach ($modules as $module) {
351 // TODO D7: field_module_delete is not yet implemented
352 // field_module_delete($module);
353 }
354 }
355
362 function field_system_info_alter(&$info, $file, $type) {
363 if ($type == 'module' && module_hook($file->name, 'field_info')) {
364 $fields = field_read_fields(array('module' => $file->name), array('include_deleted' => TRUE));
365 if ($fields) {
366 $info['required'] = TRUE;
367
368 // Provide an explanation message (only mention pending deletions if there
369 // remains no actual, non-deleted fields)
370 $non_deleted = FALSE;
371 foreach ($fields as $field) {
372 if (empty($field['deleted'])) {
373 $non_deleted = TRUE;
374 break;
375 }
376 }
377 if ($non_deleted) {
378 if (module_exists('field_ui')) {
379 $explanation = t('Field type(s) in use - see <a href="@fields-page">Field list</a>', array('@fields-page' => url('admin/reports/fields')));
380 }
381 else {
382 $explanation = t('Fields type(s) in use');
383 }
384 }
385 else {
386 $explanation = t('Fields pending deletion');
387 }
388 $info['explanation'] = $explanation;
389 }
390 }
391 }
392
396 function field_flush_caches() {
397 // Refresh the 'active' status of fields.
398 field_sync_field_status();
399
400 // Request a flush of our cache table.
401 return array('cache_field');
402 }
403
407 function field_modules_enabled($modules) {
408 // Refresh the 'active' status of fields.
409 field_sync_field_status();
410 }
411
415 function field_modules_disabled($modules) {
416 // Refresh the 'active' status of fields.
417 field_sync_field_status();
418 }
419
423 function field_sync_field_status() {
424 // Refresh the 'active' and 'storage_active' columns according to the current
425 // set of enabled modules.
426 $modules = module_list();
427 foreach ($modules as $module_name) {
428 field_associate_fields($module_name);
429 }
430 db_update('field_config')
431 ->fields(array('active' => 0))
432 ->condition('module', $modules, 'NOT IN')
433 ->execute();
434 db_update('field_config')
435 ->fields(array('storage_active' => 0))
436 ->condition('storage_module', $modules, 'NOT IN')
437 ->execute();
438 }
439
446 function field_associate_fields($module) {
447 // Associate field types.
448 $field_types = (array) module_invoke($module, 'field_info');
449 if ($field_types) {
450 db_update('field_config')
451 ->fields(array('module' => $module, 'active' => 1))
452 ->condition('type', array_keys($field_types))
453 ->execute();
454 }
455 // Associate storage backends.
456 $storage_types = (array) module_invoke($module, 'field_storage_info');
457 if ($storage_types) {
458 db_update('field_config')
459 ->fields(array('storage_module' => $module, 'storage_active' => 1))
460 ->condition('storage_type', array_keys($storage_types))
461 ->execute();
462 }
463 }
464
479 function field_get_default_value($entity_type, $entity, $field, $instance, $langcode = NULL) {
480 $items = array();
481 if (!empty($instance['default_value_function'])) {
482 $function = $instance['default_value_function'];
483 if (function_exists($function)) {
484 $items = $function($entity_type, $entity, $field, $instance, $langcode);
485 }
486 }
487 elseif (!empty($instance['default_value'])) {
488 $items = $instance['default_value'];
489 }
490 return $items;
491 }
492
505 function _field_filter_items($field, $items) {
506 $function = $field['module'] . '_field_is_empty';
507 foreach ((array) $items as $delta => $item) {
508 // Explicitly break if the function is undefined.
509 if ($function($item, $field)) {
510 unset($items[$delta]);
511 }
512 }
513 return array_values($items);
514 }
515
520 function _field_sort_items($field, $items) {
521 if (($field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED) && isset($items[0]['_weight'])) {
522 usort($items, '_field_sort_items_helper');
523 foreach ($items as $delta => $item) {
524 if (is_array($items[$delta])) {
525 unset($items[$delta]['_weight']);
526 }
527 }
528 }
529 return $items;
530 }
531
536 function _field_sort_items_helper($a, $b) {
537 $a_weight = (is_array($a) ? $a['_weight'] : 0);
538 $b_weight = (is_array($b) ? $b['_weight'] : 0);
539 return $a_weight - $b_weight;
540 }
541
545 function _field_sort_items_value_helper($a, $b) {
546 $a_weight = (is_array($a) && isset($a['_weight']['#value']) ? $a['_weight']['#value'] : 0);
547 $b_weight = (is_array($b) && isset($b['_weight']['#value']) ? $b['_weight']['#value'] : 0);
548 return $a_weight - $b_weight;
549 }
550
583 function field_bundle_settings($entity_type, $bundle, $settings = NULL) {
584 if (isset($settings)) {
585 variable_set('field_bundle_settings_' . $entity_type . '__' . $bundle, $settings);
586 field_info_cache_clear();
587 }
588 else {
589 $settings = variable_get('field_bundle_settings_' . $entity_type . '__' . $bundle, array());
590 $settings += array(
591 'view_modes' => array(),
592 'extra_fields' => array(),
593 );
594 $settings['extra_fields'] += array(
595 'form' => array(),
596 'display' => array(),
597 );
598
599 return $settings;
600 }
601 }
602
617 function field_view_mode_settings($entity_type, $bundle) {
618 $cache = &drupal_static(__FUNCTION__, array());
619
620 if (!isset($cache[$entity_type][$bundle])) {
621 $bundle_settings = field_bundle_settings($entity_type, $bundle);
622 $settings = $bundle_settings['view_modes'];
623 // Include view modes for which nothing has been stored yet, but whose
624 // definition in hook_entity_info() specify they should use custom settings
625 // by default.
626 $entity_info = entity_get_info($entity_type);
627 foreach ($entity_info['view modes'] as $view_mode => $view_mode_info) {
628 if (!isset($settings[$view_mode]['custom_settings']) && $view_mode_info['custom settings']) {
629 $settings[$view_mode]['custom_settings'] = TRUE;
630 }
631 }
632 $cache[$entity_type][$bundle] = $settings;
633 }
634
635 return $cache[$entity_type][$bundle];
636 }
637
651 function field_get_display($instance, $view_mode, $entity) {
652 // Check whether the view mode uses custom display settings or the 'default'
653 // mode.
654 $view_mode_settings = field_view_mode_settings($instance['entity_type'], $instance['bundle']);
655 $actual_mode = (!empty($view_mode_settings[$view_mode]['custom_settings']) ? $view_mode : 'default');
656 $display = $instance['display'][$actual_mode];
657
658 // Let modules alter the display settings.
659 $context = array(
660 'entity_type' => $instance['entity_type'],
661 'field' => field_info_field($instance['field_name']),
662 'instance' => $instance,
663 'entity' => $entity,
664 'view_mode' => $view_mode,
665 );
666 drupal_alter(array('field_display', 'field_display_' . $instance['entity_type']), $display, $context);
667
668 return $display;
669 }
670
684 function field_extra_fields_get_display($entity_type, $bundle, $view_mode) {
685 // Check whether the view mode uses custom display settings or the 'default'
686 // mode.
687 $view_mode_settings = field_view_mode_settings($entity_type, $bundle);
688 $actual_mode = (!empty($view_mode_settings[$view_mode]['custom_settings'])) ? $view_mode : 'default';
689 $extra_fields = field_info_extra_fields($entity_type, $bundle, 'display');
690
691 $displays = array();
692 foreach ($extra_fields as $name => $value) {
693 $displays[$name] = $extra_fields[$name]['display'][$actual_mode];
694 }
695
696 // Let modules alter the display settings.
697 $context = array(
698 'entity_type' => $entity_type,
699 'bundle' => $bundle,
700 'view_mode' => $view_mode,
701 );
702 drupal_alter('field_extra_fields_display', $displays, $context);
703
704 return $displays;
705 }
706
710 function _field_extra_fields_pre_render($elements) {
711 $entity_type = $elements['#entity_type'];
712 $bundle = $elements['#bundle'];
713
714 if (isset($elements['#type']) && $elements['#type'] == 'form') {
715 $extra_fields = field_info_extra_fields($entity_type, $bundle, 'form');
716 foreach ($extra_fields as $name => $settings) {
717 if (isset($elements[$name])) {
718 $elements[$name]['#weight'] = $settings['weight'];
719 }
720 }
721 }
722 elseif (isset($elements['#view_mode'])) {
723 $view_mode = $elements['#view_mode'];
724 $extra_fields = field_extra_fields_get_display($entity_type, $bundle, $view_mode);
725 foreach ($extra_fields as $name => $settings) {
726 if (isset($elements[$name])) {
727 $elements[$name]['#weight'] = $settings['weight'];
728 // Visibility: make sure we do not accidentally show a hidden element.
729 $elements[$name]['#access'] = isset($elements[$name]['#access']) ? ($elements[$name]['#access'] && $settings['visible']) : $settings['visible'];
730 }
731 }
732 }
733
734 return $elements;
735 }
736
740 function field_cache_clear() {
741 cache_clear_all('*', 'cache_field', TRUE);
742 field_info_cache_clear();
743 }
744
752 function field_filter_xss($string) {
753 return filter_xss($string, _field_filter_xss_allowed_tags());
754 }
755
759 function _field_filter_xss_allowed_tags() {
760 return array('a', 'b', 'big', 'code', 'del', 'em', 'i', 'ins', 'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img');
761 }
762
766 function _field_filter_xss_display_allowed_tags() {
767 return '<' . implode('> <', _field_filter_xss_allowed_tags()) . '>';
768 }
769
792 function field_view_value($entity_type, $entity, $field_name, $item, $display = array(), $langcode = NULL) {
793 $output = array();
794
795 if ($field = field_info_field($field_name)) {
796 // Determine the langcode that will be used by language fallback.
797 $langcode = field_language($entity_type, $entity, $field_name, $langcode);
798
799 // Push the item as the single value for the field, and defer to
800 // field_view_field() to build the render array for the whole field.
801 $clone = clone $entity;
802 $clone->{$field_name}[$langcode] = array($item);
803 $elements = field_view_field($entity_type, $clone, $field_name, $display, $langcode);
804
805 // Extract the part of the render array we need.
806 $output = isset($elements[0]) ? $elements[0] : array();
807 if (isset($elements['#access'])) {
808 $output['#access'] = $elements['#access'];
809 }
810 }
811
812 return $output;
813 }
814
870 function field_view_field($entity_type, $entity, $field_name, $display = array(), $langcode = NULL) {
871 $output = array();
872
873 if ($field = field_info_field($field_name)) {
874 if (is_array($display)) {
875 // When using custom display settings, fill in default values.
876 $cache = _field_info_field_cache();
877 $display = $cache->prepareInstanceDisplay($display, $field["type"]);
878 }
879
880 // Hook invocations are done through the _field_invoke() functions in
881 // 'single field' mode, to reuse the language fallback logic.
882 // Determine the actual language to display for the field, given the
883 // languages available in the field data.
884 $display_language = field_language($entity_type, $entity, $field_name, $langcode);
885 $options = array('field_name' => $field_name, 'language' => $display_language);
886 $null = NULL;
887
888 // Invoke prepare_view steps if needed.
889 if (empty($entity->_field_view_prepared)) {
890 list($id) = entity_extract_ids($entity_type, $entity);
891
892 // First let the field types do their preparation.
893 _field_invoke_multiple('prepare_view', $entity_type, array($id => $entity), $display, $null, $options);
894 // Then let the formatters do their own specific massaging.
895 _field_invoke_multiple_default('prepare_view', $entity_type, array($id => $entity), $display, $null, $options);
896 }
897
898 // Build the renderable array.
899 $result = _field_invoke_default('view', $entity_type, $entity, $display, $null, $options);
900
901 // Invoke hook_field_attach_view_alter() to let other modules alter the
902 // renderable array, as in a full field_attach_view() execution.
903 $context = array(
904 'entity_type' => $entity_type,
905 'entity' => $entity,
906 'view_mode' => '_custom',
907 'display' => $display,
908 );
909 drupal_alter('field_attach_view', $result, $context);
910
911 if (isset($result[$field_name])) {
912 $output = $result[$field_name];
913 }
914 }
915
916 return $output;
917 }
918
935 function field_get_items($entity_type, $entity, $field_name, $langcode = NULL) {
936 $langcode = field_language($entity_type, $entity, $field_name, $langcode);
937 return isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : FALSE;
938 }
939
948 function field_has_data($field) {
949 $query = new EntityFieldQuery();
950 return (bool) $query
951 ->fieldCondition($field)
952 ->range(0, 1)
953 ->count()
954 // Neutralize the 'entity_field_access' query tag added by
955 // field_sql_storage_field_storage_query(). The result cannot depend on the
956 // access grants of the current user.
957 ->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT')
958 ->execute();
959 }
960
982 function field_access($op, $field, $entity_type, $entity = NULL, $account = NULL) {
983 global $user;
984
985 if (!isset($account)) {
986 $account = $user;
987 }
988
989 foreach (module_implements('field_access') as $module) {
990 $function = $module . '_field_access';
991 $access = $function($op, $field, $entity_type, $entity, $account);
992 if ($access === FALSE) {
993 return FALSE;
994 }
995 }
996 return TRUE;
997 }
998
1010 function field_extract_bundle($entity_type, $bundle) {
1011 if (is_string($bundle)) {
1012 return $bundle;
1013 }
1014
1015 $info = entity_get_info($entity_type);
1016 if (is_object($bundle) && isset($info['bundle keys']['bundle']) && isset($bundle->{$info['bundle keys']['bundle']})) {
1017 return $bundle->{$info['bundle keys']['bundle']};
1018 }
1019 }
1020
1027 function template_preprocess_field(&$variables, $hook) {
1028 $element = $variables['element'];
1029
1030 // There's some overhead in calling check_plain() so only call it if the label
1031 // variable is being displayed. Otherwise, set it to NULL to avoid PHP
1032 // warnings if a theme implementation accesses the variable even when it's
1033 // supposed to be hidden. If a theme implementation needs to print a hidden
1034 // label, it needs to supply a preprocess function that sets it to the
1035 // sanitized element title or whatever else is wanted in its place.
1036 $variables['label_hidden'] = ($element['#label_display'] == 'hidden');
1037 $variables['label'] = $variables['label_hidden'] ? NULL : check_plain($element['#title']);
1038
1039 // We want other preprocess functions and the theme implementation to have
1040 // fast access to the field item render arrays. The item render array keys
1041 // (deltas) should always be a subset of the keys in #items, and looping on
1042 // those keys is faster than calling element_children() or looping on all keys
1043 // within $element, since that requires traversal of all element properties.
1044 $variables['items'] = array();
1045 foreach ($element['#items'] as $delta => $item) {
1046 if (!empty($element[$delta])) {
1047 $variables['items'][$delta] = $element[$delta];
1048 }
1049 }
1050
1051 // Add default CSS classes. Since there can be many fields rendered on a page,
1052 // save some overhead by calling strtr() directly instead of
1053 // drupal_html_class().
1054 $variables['field_name_css'] = strtr($element['#field_name'], '_', '-');
1055 $variables['field_type_css'] = strtr($element['#field_type'], '_', '-');
1056 $variables['classes_array'] = array(
1057 'field',
1058 'field-name-' . $variables['field_name_css'],
1059 'field-type-' . $variables['field_type_css'],
1060 'field-label-' . $element['#label_display'],
1061 );
1062 // Add a "clearfix" class to the wrapper since we float the label and the
1063 // field items in field.css if the label is inline.
1064 if ($element['#label_display'] == 'inline') {
1065 $variables['classes_array'][] = 'clearfix';
1066 }
1067
1068 // Add specific suggestions that can override the default implementation.
1069 $variables['theme_hook_suggestions'] = array(
1070 'field__' . $element['#field_type'],
1071 'field__' . $element['#field_name'],
1072 'field__' . $element['#bundle'],
1073 'field__' . $element['#field_name'] . '__' . $element['#bundle'],
1074 );
1075 }
1076
1083 function template_process_field(&$variables, $hook) {
1084 // The default theme implementation is a function, so template_process() does
1085 // not automatically run, so we need to flatten the classes and attributes
1086 // here. For best performance, only call drupal_attributes() when needed, and
1087 // note that template_preprocess_field() does not initialize the
1088 // *_attributes_array variables.
1089 $variables['classes'] = implode(' ', $variables['classes_array']);
1090 $variables['attributes'] = empty($variables['attributes_array']) ? '' : drupal_attributes($variables['attributes_array']);
1091 $variables['title_attributes'] = empty($variables['title_attributes_array']) ? '' : drupal_attributes($variables['title_attributes_array']);
1092 $variables['content_attributes'] = empty($variables['content_attributes_array']) ? '' : drupal_attributes($variables['content_attributes_array']);
1093 foreach ($variables['items'] as $delta => $item) {
1094 $variables['item_attributes'][$delta] = empty($variables['item_attributes_array'][$delta]) ? '' : drupal_attributes($variables['item_attributes_array'][$delta]);
1095 }
1096 }
1161 function theme_field($variables) {
1162 $output = '';
1163
1164 // Render the label, if it's not hidden.
1165 if (!$variables['label_hidden']) {
1166 $output .= '<div class="field-label"' . $variables['title_attributes'] . '>' . $variables['label'] . ':&nbsp;</div>';
1167 }
1168
1169 // Render the items.
1170 $output .= '<div class="field-items"' . $variables['content_attributes'] . '>';
1171 foreach ($variables['items'] as $delta => $item) {
1172 $classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even');
1173 $output .= '<div class="' . $classes . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</div>';
1174 }
1175 $output .= '</div>';
1176
1177 // Render the top-level DIV.
1178 $output = '<div class="' . $variables['classes'] . '"' . $variables['attributes'] . '>' . $output . '</div>';
1179
1180 return $output;
1181 }
1182
1191 function _element_validate_integer($element, &$form_state) {
1192 element_validate_integer($element, $form_state);
1193 }
1194
1203 function _element_validate_integer_positive($element, &$form_state) {
1204 element_validate_integer_positive($element, $form_state);
1205 }
1206
1215 function _element_validate_number($element, &$form_state) {
1216 element_validate_number($element, $form_state);
1217 }
field_read_fields
field_read_fields($params=array(), $include_additional=array())
Definition: field.crud.inc:340
_field_filter_xss_display_allowed_tags
_field_filter_xss_display_allowed_tags()
Definition: field.module:766
field_extra_fields_get_display
field_extra_fields_get_display($entity_type, $bundle, $view_mode)
Definition: field.module:684
module_list
module_list($refresh=FALSE, $bootstrap_refresh=FALSE, $sort=FALSE, $fixed_list=NULL)
Definition: module.inc:66
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
field_flush_caches
field_flush_caches()
Definition: field.module:396
$op
$op
Definition: update.php:404
theme_field
theme_field($variables)
Definition: field.module:1161
l
l($text, $path, array $options=array())
Definition: common.inc:2432
field_filter_xss
field_filter_xss($string)
Definition: field.module:752
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
_field_info_field_cache
_field_info_field_cache()
Definition: field.info.inc:14
field_system_info_alter
field_system_info_alter(&$info, $file, $type)
Definition: field.module:362
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
$module
print $module
Definition: search-results.tpl.php:28
field_associate_fields
field_associate_fields($module)
Definition: field.module:446
field_view_field
field_view_field($entity_type, $entity, $field_name, $display=array(), $langcode=NULL)
Definition: field.module:870
field_get_items
field_get_items($entity_type, $entity, $field_name, $langcode=NULL)
Definition: field.module:935
$name
print $name
Definition: profile-listing.tpl.php:43
element_validate_number
element_validate_number($element, &$form_state)
Definition: form.inc:4212
Exception
template_process_field
template_process_field(&$variables, $hook)
Definition: field.module:1083
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
drupal_attributes
drupal_attributes(array $attributes=array())
Definition: common.inc:2377
_field_sort_items_value_helper
_field_sort_items_value_helper($a, $b)
Definition: field.module:545
field_view_value
field_view_value($entity_type, $entity, $field_name, $item, $display=array(), $langcode=NULL)
Definition: field.module:792
module_exists
module_exists($module)
Definition: module.inc:274
field_access
field_access($op, $field, $entity_type, $entity=NULL, $account=NULL)
Definition: field.module:982
_element_validate_integer_positive
_element_validate_integer_positive($element, &$form_state)
Definition: field.module:1203
field_has_data
field_has_data($field)
Definition: field.module:948
field_cache_clear
field_cache_clear()
Definition: field.module:740
_field_filter_xss_allowed_tags
_field_filter_xss_allowed_tags()
Definition: field.module:759
element_validate_integer
element_validate_integer($element, &$form_state)
Definition: form.inc:4192
_field_sort_items_helper
_field_sort_items_helper($a, $b)
Definition: field.module:536
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
element_validate_integer_positive
element_validate_integer_positive($element, &$form_state)
Definition: form.inc:4202
module_hook
module_hook($module, $hook)
Definition: module.inc:659
field_cron
field_cron()
Definition: field.module:336
field_language
field_language($entity_type, $entity, $field_name=NULL, $langcode=NULL)
Definition: field.multilingual.inc:266
field_view_mode_settings
field_view_mode_settings($entity_type, $bundle)
Definition: field.module:617
field_modules_enabled
field_modules_enabled($modules)
Definition: field.module:407
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
system_get_info
system_get_info($type, $name=NULL)
Definition: system.module:2338
field_modules_uninstalled
field_modules_uninstalled($modules)
Definition: field.module:348
$info
$info
Definition: color.inc:6
_element_validate_integer
_element_validate_integer($element, &$form_state)
Definition: field.module:1191
field_info_cache_clear
field_info_cache_clear()
Definition: field.info.inc:54
field_help
field_help($path, $arg)
Definition: field.module:284
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
field_get_display
field_get_display($instance, $view_mode, $entity)
Definition: field.module:651
field_info_extra_fields
field_info_extra_fields($entity_type, $bundle, $context)
Definition: field.info.inc:684
EntityFieldQuery
Definition: entity.inc:420
$value
print $value
Definition: user-profile-item.tpl.php:26
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
$output
$output
Definition: authorize.php:93
field_purge_batch
field_purge_batch($batch_size)
Definition: field.crud.inc:880
field_get_default_value
field_get_default_value($entity_type, $entity, $field, $instance, $langcode=NULL)
Definition: field.module:479
FIELD_CARDINALITY_UNLIMITED
const FIELD_CARDINALITY_UNLIMITED
Definition: field.module:236
field_theme
field_theme()
Definition: field.module:322
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
FieldException
Definition: field.module:13
_element_validate_number
_element_validate_number($element, &$form_state)
Definition: field.module:1215
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
_field_sort_items
_field_sort_items($field, $items)
Definition: field.module:520
$classes
print $classes
Definition: contextual-links-example-object.tpl.php:31
field_modules_disabled
field_modules_disabled($modules)
Definition: field.module:415
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
_field_invoke_multiple_default
_field_invoke_multiple_default($op, $entity_type, $entities, &$a=NULL, &$b=NULL, $options=array())
Definition: field.attach.inc:397
_field_filter_items
_field_filter_items($field, $items)
Definition: field.module:505
field_bundle_settings
field_bundle_settings($entity_type, $bundle, $settings=NULL)
Definition: field.module:583
_field_invoke_default
_field_invoke_default($op, $entity_type, $entity, &$a=NULL, &$b=NULL, $options=array())
Definition: field.attach.inc:383
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
entity_extract_ids
entity_extract_ids($entity_type, $entity)
Definition: common.inc:7711
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
template_preprocess_field
template_preprocess_field(&$variables, $hook)
Definition: field.module:1027
FieldUpdateForbiddenException
Definition: field.module:279
_field_extra_fields_pre_render
_field_extra_fields_pre_render($elements)
Definition: field.module:710
_field_invoke_multiple
_field_invoke_multiple($op, $entity_type, $entities, &$a=NULL, &$b=NULL, $options=array())
Definition: field.attach.inc:278
field_extract_bundle
field_extract_bundle($entity_type, $bundle)
Definition: field.module:1010
field_sync_field_status
field_sync_field_status()
Definition: field.module:423
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/shortcut/shortcut.module Source File

  • modules
  • shortcut
shortcut.module
Go to the documentation of this file.
1 <?php
2
14 define('SHORTCUT_DEFAULT_SET_NAME', 'shortcut-set-1');
15
19 function shortcut_help($path, $arg) {
20 global $user;
21
22 switch ($path) {
23 case 'admin/help#shortcut':
24 $output = '<h3>' . t('About') . '</h3>';
25 $output .= '<p>' . t('The Shortcut module allows users to create sets of <em>shortcut</em> links to commonly-visited pages of the site. Shortcuts are contained within <em>sets</em>. Each user with <em>Select any shortcut set</em> permission can select a shortcut set created by anyone at the site. For more information, see the online handbook entry for <a href="@shortcut">Shortcut module</a>.', array('@shortcut' => 'http://drupal.org/documentation/modules/shortcut/')) . '</p>';
26 $output .= '<h3>' . t('Uses') . '</h3>';
27 $output .= '<dl><dt>' . t('Administering shortcuts') . '</dt>';
28 $output .= '<dd>' . t('Users with the <em>Administer shortcuts</em> permission can manage shortcut sets and edit the shortcuts within sets from the <a href="@shortcuts">Shortcuts administration page</a>.', array('@shortcuts' => url('admin/config/user-interface/shortcut'))) . '</dd>';
29 $output .= '<dt>' . t('Choosing shortcut sets') . '</dt>';
30 $output .= '<dd>' . t('Users with permission to switch shortcut sets can choose a shortcut set to use from the Shortcuts tab of their user account page.') . '</dd>';
31 $output .= '<dt>' . t('Adding and removing shortcuts') . '</dt>';
32 $output .= '<dd>' . t('The Shortcut module creates an add/remove link for each page on your site; the link lets you add or remove the current page from the currently-enabled set of shortcuts (if your theme displays it and you have permission to edit your shortcut set). The core Seven administration theme displays this link next to the page title, as a small + or - sign. If you click on the + sign, you will add that page to your preferred set of shortcuts. If the page is already part of your shortcut set, the link will be a - sign, and will allow you to remove the current page from your shortcut set.') . '</dd>';
33 $output .= '<dt>' . t('Displaying shortcuts') . '</dt>';
34 $output .= '<dd>' . t('You can display your shortcuts by enabling the Shortcuts block on the <a href="@blocks">Blocks administration page</a>. Certain administrative modules also display your shortcuts; for example, the core <a href="@toolbar-help">Toolbar module</a> displays them near the top of the page, along with an <em>Edit shortcuts</em> link.', array('@blocks' => url('admin/structure/block'), '@toolbar-help' => url('admin/help/toolbar'))) . '</dd>';
35 $output .= '</dl>';
36 return $output;
37
38 case 'admin/config/user-interface/shortcut':
39 case 'admin/config/user-interface/shortcut/%':
40 if (user_access('switch shortcut sets')) {
41 $output = '<p>' . t('Define which shortcut set you are using on the <a href="@shortcut-link">Shortcuts tab</a> of your account page.', array('@shortcut-link' => url("user/{$user->uid}/shortcuts"))) . '</p>';
42 return $output;
43 }
44 }
45 }
46
50 function shortcut_permission() {
51 return array(
52 'administer shortcuts' => array(
53 'title' => t('Administer shortcuts'),
54 ),
55 'customize shortcut links' => array(
56 'title' => t('Edit current shortcut set'),
57 'description' => t('Editing the current shortcut set will affect other users if that set has been assigned to or selected by other users. Granting "Select any shortcut set" permission along with this permission will grant permission to edit any shortcut set.'),
58 ),
59 'switch shortcut sets' => array(
60 'title' => t('Select any shortcut set'),
61 'description' => t('From all shortcut sets, select one to be own active set. Without this permission, an administrator selects shortcut sets for users.'),
62 ),
63 );
64 }
65
69 function shortcut_menu() {
70 $items['admin/config/user-interface/shortcut'] = array(
71 'title' => 'Shortcuts',
72 'description' => 'Add and modify shortcut sets.',
73 'page callback' => 'shortcut_set_admin',
74 'access arguments' => array('administer shortcuts'),
75 'file' => 'shortcut.admin.inc',
76 );
77 $items['admin/config/user-interface/shortcut/add-set'] = array(
78 'title' => 'Add shortcut set',
79 'page callback' => 'drupal_get_form',
80 'page arguments' => array('shortcut_set_add_form'),
81 'access arguments' => array('administer shortcuts'),
82 'type' => MENU_LOCAL_ACTION,
83 'file' => 'shortcut.admin.inc',
84 );
85 $items['admin/config/user-interface/shortcut/%shortcut_set'] = array(
86 'title' => 'Edit shortcuts',
87 'page callback' => 'drupal_get_form',
88 'page arguments' => array('shortcut_set_customize', 4),
89 'title callback' => 'shortcut_set_title_callback',
90 'title arguments' => array(4),
91 'access callback' => 'shortcut_set_edit_access',
92 'access arguments' => array(4),
93 'file' => 'shortcut.admin.inc',
94 );
95 $items['admin/config/user-interface/shortcut/%shortcut_set/links'] = array(
96 'title' => 'List links',
97 'type' => MENU_DEFAULT_LOCAL_TASK,
98 );
99 $items['admin/config/user-interface/shortcut/%shortcut_set/edit'] = array(
100 'title' => 'Edit set name',
101 'page callback' => 'drupal_get_form',
102 'page arguments' => array('shortcut_set_edit_form', 4),
103 'access callback' => 'shortcut_set_edit_access',
104 'access arguments' => array(4),
105 'type' => MENU_LOCAL_TASK,
106 'file' => 'shortcut.admin.inc',
107 'weight' => 10,
108 );
109 $items['admin/config/user-interface/shortcut/%shortcut_set/delete'] = array(
110 'title' => 'Delete shortcut set',
111 'page callback' => 'drupal_get_form',
112 'page arguments' => array('shortcut_set_delete_form', 4),
113 'access callback' => 'shortcut_set_delete_access',
114 'access arguments' => array(4),
115 'file' => 'shortcut.admin.inc',
116 );
117 $items['admin/config/user-interface/shortcut/%shortcut_set/add-link'] = array(
118 'title' => 'Add shortcut',
119 'page callback' => 'drupal_get_form',
120 'page arguments' => array('shortcut_link_add', 4),
121 'access callback' => 'shortcut_set_edit_access',
122 'access arguments' => array(4),
123 'type' => MENU_LOCAL_ACTION,
124 'file' => 'shortcut.admin.inc',
125 );
126 $items['admin/config/user-interface/shortcut/%shortcut_set/add-link-inline'] = array(
127 'title' => 'Add shortcut',
128 'page callback' => 'shortcut_link_add_inline',
129 'page arguments' => array(4),
130 'access callback' => 'shortcut_set_edit_access',
131 'access arguments' => array(4),
132 'type' => MENU_CALLBACK,
133 'file' => 'shortcut.admin.inc',
134 );
135 $items['admin/config/user-interface/shortcut/link/%menu_link'] = array(
136 'title' => 'Edit shortcut',
137 'page callback' => 'drupal_get_form',
138 'page arguments' => array('shortcut_link_edit', 5),
139 'access callback' => 'shortcut_link_access',
140 'access arguments' => array(5),
141 'file' => 'shortcut.admin.inc',
142 );
143 $items['admin/config/user-interface/shortcut/link/%menu_link/delete'] = array(
144 'title' => 'Delete shortcut',
145 'page callback' => 'drupal_get_form',
146 'page arguments' => array('shortcut_link_delete', 5),
147 'access callback' => 'shortcut_link_access',
148 'access arguments' => array(5),
149 'file' => 'shortcut.admin.inc',
150 );
151 $items['user/%user/shortcuts'] = array(
152 'title' => 'Shortcuts',
153 'page callback' => 'drupal_get_form',
154 'page arguments' => array('shortcut_set_switch', 1),
155 'access callback' => 'shortcut_set_switch_access',
156 'access arguments' => array(1),
157 'type' => MENU_LOCAL_TASK,
158 'file' => 'shortcut.admin.inc',
159 );
160
161 return $items;
162 }
163
167 function shortcut_admin_paths() {
168 $paths = array(
169 'user/*/shortcuts' => TRUE,
170 );
171 return $paths;
172 }
173
177 function shortcut_theme() {
178 return array(
179 'shortcut_set_customize' => array(
180 'render element' => 'form',
181 'file' => 'shortcut.admin.inc',
182 ),
183 );
184 }
185
189 function shortcut_block_info() {
190 $blocks['shortcuts']['info'] = t('Shortcuts');
191 // Shortcut blocks can't be cached because each menu item can have a custom
192 // access callback. menu.inc manages its own caching.
193 $blocks['shortcuts']['cache'] = DRUPAL_NO_CACHE;
194 return $blocks;
195 }
196
200 function shortcut_block_view($delta = '') {
201 if ($delta == 'shortcuts') {
202 $shortcut_set = shortcut_current_displayed_set();
203 $data['subject'] = t('@shortcut_set shortcuts', array('@shortcut_set' => $shortcut_set->title));
204 $data['content'] = shortcut_renderable_links($shortcut_set);
205 return $data;
206 }
207 }
208
220 function shortcut_set_edit_access($shortcut_set = NULL) {
221 // Sufficiently-privileged users can edit their currently displayed shortcut
222 // set, but not other sets. Shortcut administrators can edit any set.
223 if (user_access('administer shortcuts')) {
224 return TRUE;
225 }
226 if (user_access('customize shortcut links')) {
227 return !isset($shortcut_set) || $shortcut_set == shortcut_current_displayed_set();
228 }
229 return FALSE;
230 }
231
242 function shortcut_set_delete_access($shortcut_set) {
243 // Only admins can delete sets.
244 if (!user_access('administer shortcuts')) {
245 return FALSE;
246 }
247
248 // Never let the default shortcut set be deleted.
249 if ($shortcut_set->set_name == SHORTCUT_DEFAULT_SET_NAME) {
250 return FALSE;
251 }
252
253 return TRUE;
254 }
255
268 function shortcut_set_switch_access($account = NULL) {
269 global $user;
270
271 if (user_access('administer shortcuts')) {
272 // Administrators can switch anyone's shortcut set.
273 return TRUE;
274 }
275
276 if (!user_access('switch shortcut sets')) {
277 // The user has no permission to switch anyone's shortcut set.
278 return FALSE;
279 }
280
281 if (!isset($account) || $user->uid == $account->uid) {
282 // Users with the 'switch shortcut sets' permission can switch their own
283 // shortcuts sets.
284 return TRUE;
285 }
286
287 return FALSE;
288 }
289
293 function shortcut_link_access($menu_link) {
294 // The link must belong to a shortcut set that the current user has access
295 // to edit.
296 if ($shortcut_set = shortcut_set_load($menu_link['menu_name'])) {
297 return shortcut_set_edit_access($shortcut_set);
298 }
299 return FALSE;
300 }
301
315 function shortcut_set_load($set_name) {
316 $set = db_select('shortcut_set', 'ss')
317 ->fields('ss')
318 ->condition('set_name', $set_name)
319 ->execute()
320 ->fetchObject();
321 if (!$set) {
322 return FALSE;
323 }
324 $set->links = menu_load_links($set_name);
325 return $set;
326 }
327
351 function shortcut_set_save(&$shortcut_set) {
352 // First save the shortcut set itself.
353 if (isset($shortcut_set->set_name)) {
354 $return = drupal_write_record('shortcut_set', $shortcut_set, 'set_name');
355 }
356 else {
357 $shortcut_set->set_name = shortcut_set_get_unique_name();
358 $return = drupal_write_record('shortcut_set', $shortcut_set);
359 }
360 // If links were provided for the set, save them.
361 if (isset($shortcut_set->links)) {
362 foreach ($shortcut_set->links as &$link) {
363 // Do not specifically associate these links with the shortcut module,
364 // since other modules may make them editable via the menu system.
365 // However, we do need to specify the correct menu name.
366 $link['menu_name'] = $shortcut_set->set_name;
367 $link['plid'] = 0;
368 menu_link_save($link);
369 }
370 // Make sure that we have a return value, since if the links were updated
371 // but the shortcut set was not, the call to drupal_write_record() above
372 // would not return an indication that anything had changed.
373 if (empty($return)) {
374 $return = SAVED_UPDATED;
375 }
376 }
377 return $return;
378 }
379
391 function shortcut_set_delete($shortcut_set) {
392 // Don't allow deletion of the system default shortcut set.
393 if ($shortcut_set->set_name == SHORTCUT_DEFAULT_SET_NAME) {
394 return FALSE;
395 }
396
397 // First, delete any user assignments for this set, so that each of these
398 // users will go back to using whatever default set applies.
399 db_delete('shortcut_set_users')
400 ->condition('set_name', $shortcut_set->set_name)
401 ->execute();
402
403 // Next, delete the menu links for this set.
404 menu_delete_links($shortcut_set->set_name);
405
406 // Finally, delete the set itself.
407 $deleted = db_delete('shortcut_set')
408 ->condition('set_name', $shortcut_set->set_name)
409 ->execute();
410
411 return (bool) $deleted;
412 }
413
425 function shortcut_set_reset_link_weights(&$shortcut_set) {
426 $weight = -50;
427 foreach ($shortcut_set->links as &$link) {
428 $link['weight'] = $weight;
429 $weight++;
430 }
431 }
432
441 function shortcut_set_assign_user($shortcut_set, $account) {
442 db_merge('shortcut_set_users')
443 ->key(array('uid' => $account->uid))
444 ->fields(array('set_name' => $shortcut_set->set_name))
445 ->execute();
446 drupal_static_reset('shortcut_current_displayed_set');
447 }
448
462 function shortcut_set_unassign_user($account) {
463 $deleted = db_delete('shortcut_set_users')
464 ->condition('uid', $account->uid)
465 ->execute();
466 return (bool) $deleted;
467 }
468
481 function shortcut_current_displayed_set($account = NULL) {
482 $shortcut_sets = &drupal_static(__FUNCTION__, array());
483 global $user;
484 if (!isset($account)) {
485 $account = $user;
486 }
487 // Try to return a shortcut set from the static cache.
488 if (isset($shortcut_sets[$account->uid])) {
489 return $shortcut_sets[$account->uid];
490 }
491 // If none was found, try to find a shortcut set that is explicitly assigned
492 // to this user.
493 $query = db_select('shortcut_set', 's');
494 $query->addField('s', 'set_name');
495 $query->join('shortcut_set_users', 'u', 's.set_name = u.set_name');
496 $query->condition('u.uid', $account->uid);
497 $shortcut_set_name = $query->execute()->fetchField();
498 if ($shortcut_set_name) {
499 $shortcut_set = shortcut_set_load($shortcut_set_name);
500 }
501 // Otherwise, use the default set.
502 else {
503 $shortcut_set = shortcut_default_set($account);
504 }
505
506 $shortcut_sets[$account->uid] = $shortcut_set;
507 return $shortcut_set;
508 }
509
521 function shortcut_default_set($account = NULL) {
522 global $user;
523 if (!isset($account)) {
524 $account = $user;
525 }
526
527 // Allow modules to return a default shortcut set name. Since we can only
528 // have one, we allow the last module which returns a valid result to take
529 // precedence. If no module returns a valid set, fall back on the site-wide
530 // default, which is the lowest-numbered shortcut set.
531 $suggestions = array_reverse(module_invoke_all('shortcut_default_set', $account));
532 $suggestions[] = SHORTCUT_DEFAULT_SET_NAME;
533 foreach ($suggestions as $name) {
534 if ($shortcut_set = shortcut_set_load($name)) {
535 break;
536 }
537 }
538
539 return $shortcut_set;
540 }
541
545 function shortcut_set_get_unique_name() {
546 // Shortcut sets are numbered sequentially, so we keep trying until we find
547 // one that is available. For better performance, we start with a number
548 // equal to one more than the current number of shortcut sets, so that if
549 // no shortcut sets have been deleted from the database, this will
550 // automatically give us the correct one.
551 $number = db_query("SELECT COUNT(*) FROM {shortcut_set}")->fetchField() + 1;
552 do {
553 $name = shortcut_set_name($number);
554 $number++;
555 } while ($shortcut_set = shortcut_set_load($name));
556 return $name;
557 }
558
571 function shortcut_set_name($number) {
572 return "shortcut-set-$number";
573 }
574
583 function shortcut_sets() {
584 return db_select('shortcut_set', 'ss')
585 ->fields('ss')
586 ->execute()
587 ->fetchAllAssoc('set_name');
588 }
589
599 function shortcut_set_title_exists($title) {
600 return (bool) db_query_range('SELECT 1 FROM {shortcut_set} WHERE title = :title', 0, 1, array(':title' => $title))->fetchField();
601 }
602
614 function shortcut_valid_link($path) {
615 // Do not use URL aliases.
616 $normal_path = drupal_get_normal_path($path);
617 if ($path != $normal_path) {
618 $path = $normal_path;
619 }
620 // An empty path is valid too and will be converted to <front>.
621 return (!url_is_external($path) && menu_get_item($path)) || empty($path) || $path == '<front>';
622 }
623
635 function shortcut_renderable_links($shortcut_set = NULL) {
636 if (!isset($shortcut_set)) {
637 $shortcut_set = shortcut_current_displayed_set();
638 }
639 return menu_tree($shortcut_set->set_name);
640 }
641
645 function shortcut_preprocess_page(&$variables) {
646 // Only display the shortcut link if the user has the ability to edit
647 // shortcuts and if the page's actual content is being shown (for example,
648 // we do not want to display it on "access denied" or "page not found"
649 // pages).
650 if (shortcut_set_edit_access() && ($item = menu_get_item()) && $item['access']) {
651 $link = $_GET['q'];
652 $query_parameters = drupal_get_query_parameters();
653 if (!empty($query_parameters)) {
654 $link .= '?' . drupal_http_build_query($query_parameters);
655 }
656 $query = array(
657 'link' => $link,
658 'name' => drupal_get_title(),
659 );
660 $query += drupal_get_destination();
661
662 $shortcut_set = shortcut_current_displayed_set();
663
664 // Check if $link is already a shortcut and set $link_mode accordingly.
665 foreach ($shortcut_set->links as $shortcut) {
666 if ($link == $shortcut['link_path']) {
667 $mlid = $shortcut['mlid'];
668 break;
669 }
670 }
671 $link_mode = isset($mlid) ? "remove" : "add";
672
673 if ($link_mode == "add") {
674 $query['token'] = drupal_get_token('shortcut-add-link');
675 $link_text = shortcut_set_switch_access() ? t('Add to %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->title)) : t('Add to shortcuts');
676 $link_path = 'admin/config/user-interface/shortcut/' . $shortcut_set->set_name . '/add-link-inline';
677 }
678 else {
679 $query['mlid'] = $mlid;
680 $link_text = shortcut_set_switch_access() ? t('Remove from %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->title)) : t('Remove from shortcuts');
681 $link_path = 'admin/config/user-interface/shortcut/link/' . $mlid . '/delete';
682 }
683
684 if (theme_get_setting('shortcut_module_link')) {
685 $variables['title_suffix']['add_or_remove_shortcut'] = array(
686 '#attached' => array('css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.css')),
687 '#prefix' => '<div class="add-or-remove-shortcuts ' . $link_mode . '-shortcut">',
688 '#type' => 'link',
689 '#title' => '<span class="icon"></span><span class="text">' . $link_text . '</span>',
690 '#href' => $link_path,
691 '#options' => array('query' => $query, 'html' => TRUE),
692 '#suffix' => '</div>',
693 );
694 }
695 }
696 }
697
701 function shortcut_page_alter(&$page) {
702 if (isset($page['page_top']['toolbar'])) {
703 // If the toolbar is available, add a pre-render function to display the
704 // current shortcuts in the toolbar drawer.
705 $page['page_top']['toolbar']['#pre_render'][] = 'shortcut_toolbar_pre_render';
706 }
707 }
708
712 function shortcut_toolbar_pre_render($toolbar) {
713 $links = shortcut_renderable_links();
714 $links['#attached'] = array('css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.css'));
715 $links['#prefix'] = '<div class="toolbar-shortcuts">';
716 $links['#suffix'] = '</div>';
717 $shortcut_set = shortcut_current_displayed_set();
718 $configure_link = NULL;
719 if (shortcut_set_edit_access($shortcut_set)) {
720 $configure_link = array(
721 '#type' => 'link',
722 '#title' => t('Edit shortcuts'),
723 '#href' => 'admin/config/user-interface/shortcut/' . $shortcut_set->set_name,
724 '#options' => array('attributes' => array('id' => 'edit-shortcuts')),
725 );
726 }
727
728 $drawer = array(
729 'shortcuts' => $links,
730 'configure' => $configure_link,
731 );
732
733 $toolbar['toolbar_drawer'][] = $drawer;
734 return $toolbar;
735 }
736
752 function shortcut_set_title($shortcut_set) {
753 return check_plain($shortcut_set->title);
754 }
755
765 function shortcut_set_title_callback($shortcut_set) {
766 return $shortcut_set->title;
767 }
url_is_external
url_is_external($path)
Definition: common.inc:2311
drupal_http_build_query
drupal_http_build_query(array $query, $parent= '')
Definition: common.inc:486
menu_link_save
menu_link_save(&$item, $existing_item=array(), $parent_candidates=array())
Definition: menu.inc:3074
menu_delete_links
menu_delete_links($menu_name)
Definition: menu.inc:2976
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
menu_get_item
menu_get_item($path=NULL, $router_item=NULL)
Definition: menu.inc:447
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
shortcut_set_title
shortcut_set_title($shortcut_set)
Definition: shortcut.module:752
SHORTCUT_DEFAULT_SET_NAME
const SHORTCUT_DEFAULT_SET_NAME
Definition: shortcut.module:14
SAVED_UPDATED
const SAVED_UPDATED
Definition: common.inc:50
$page
print $page
Definition: overlay.tpl.php:37
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
drupal_get_query_parameters
drupal_get_query_parameters(array $query=NULL, array $exclude=array('q'), $parent= '')
Definition: common.inc:417
shortcut_admin_paths
shortcut_admin_paths()
Definition: shortcut.module:167
shortcut_menu
shortcut_menu()
Definition: shortcut.module:69
shortcut_set_reset_link_weights
shortcut_set_reset_link_weights(&$shortcut_set)
Definition: shortcut.module:425
shortcut_set_load
shortcut_set_load($set_name)
Definition: shortcut.module:315
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
shortcut_set_title_callback
shortcut_set_title_callback($shortcut_set)
Definition: shortcut.module:765
shortcut_renderable_links
shortcut_renderable_links($shortcut_set=NULL)
Definition: shortcut.module:635
shortcut_theme
shortcut_theme()
Definition: shortcut.module:177
shortcut_current_displayed_set
shortcut_current_displayed_set($account=NULL)
Definition: shortcut.module:481
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
shortcut_set_edit_access
shortcut_set_edit_access($shortcut_set=NULL)
Definition: shortcut.module:220
menu_load_links
menu_load_links($menu_name)
Definition: menu.inc:2954
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
shortcut_set_delete_access
shortcut_set_delete_access($shortcut_set)
Definition: shortcut.module:242
drupal_get_normal_path
drupal_get_normal_path($path, $path_language=NULL)
Definition: path.inc:259
shortcut_page_alter
shortcut_page_alter(&$page)
Definition: shortcut.module:701
$output
$output
Definition: authorize.php:93
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
user_access
user_access($string, $account=NULL)
Definition: user.module:794
shortcut_sets
shortcut_sets()
Definition: shortcut.module:583
theme_get_setting
theme_get_setting($setting_name, $theme=NULL)
Definition: theme.inc:1401
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
shortcut_preprocess_page
shortcut_preprocess_page(&$variables)
Definition: shortcut.module:645
shortcut_set_title_exists
shortcut_set_title_exists($title)
Definition: shortcut.module:599
shortcut_block_info
shortcut_block_info()
Definition: shortcut.module:189
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
shortcut_set_unassign_user
shortcut_set_unassign_user($account)
Definition: shortcut.module:462
shortcut_default_set
shortcut_default_set($account=NULL)
Definition: shortcut.module:521
shortcut_set_delete
shortcut_set_delete($shortcut_set)
Definition: shortcut.module:391
shortcut_help
shortcut_help($path, $arg)
Definition: shortcut.module:19
DRUPAL_NO_CACHE
const DRUPAL_NO_CACHE
Definition: common.inc:127
shortcut_permission
shortcut_permission()
Definition: shortcut.module:50
shortcut_set_get_unique_name
shortcut_set_get_unique_name()
Definition: shortcut.module:545
drupal_get_token
drupal_get_token($value= '')
Definition: common.inc:5077
shortcut_valid_link
shortcut_valid_link($path)
Definition: shortcut.module:614
shortcut_toolbar_pre_render
shortcut_toolbar_pre_render($toolbar)
Definition: shortcut.module:712
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
drupal_get_title
drupal_get_title()
Definition: bootstrap.inc:1848
shortcut_set_name
shortcut_set_name($number)
Definition: shortcut.module:571
shortcut_block_view
shortcut_block_view($delta= '')
Definition: shortcut.module:200
menu_tree
menu_tree($menu_name)
Definition: menu.inc:992
shortcut_set_assign_user
shortcut_set_assign_user($shortcut_set, $account)
Definition: shortcut.module:441
shortcut_set_save
shortcut_set_save(&$shortcut_set)
Definition: shortcut.module:351
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
shortcut_link_access
shortcut_link_access($menu_link)
Definition: shortcut.module:293
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
$links
print $links
Definition: poll-results--block.tpl.php:28
shortcut_set_switch_access
shortcut_set_switch_access($account=NULL)
Definition: shortcut.module:268
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DatabaseTasks_mysql Member List

This is the complete list of members for DatabaseTasks_mysql, including all inherited members.

$pdoDriver | DatabaseTasks_mysql | protected
$results | DatabaseTasks | protected
$tasks | DatabaseTasks | protected
checkEngineVersion() | DatabaseTasks | protected
connect() | DatabaseTasks | protected
fail($message) | DatabaseTasks | protected
getFormOptions($database) | DatabaseTasks |
hasPdoDriver() | DatabaseTasks | protected
installable() | DatabaseTasks |
minimumVersion() | DatabaseTasks_mysql |
name() | DatabaseTasks_mysql |
pass($message) | DatabaseTasks | protected
runTasks() | DatabaseTasks |
runTestQuery($query, $pass, $fail, $fatal=FALSE) | DatabaseTasks | protected
validateDatabaseSettings($database) | DatabaseTasks |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/block/block.install Source File

  • modules
  • block
block.install
Go to the documentation of this file.
1 <?php
2
11 function block_schema() {
12 $schema['block'] = array(
13 'description' => 'Stores block settings, such as region and visibility settings.',
14 'fields' => array(
15 'bid' => array(
16 'type' => 'serial',
17 'not null' => TRUE,
18 'description' => 'Primary Key: Unique block ID.',
19 ),
20 'module' => array(
21 'type' => 'varchar',
22 'length' => 64,
23 'not null' => TRUE,
24 'default' => '',
25 'description' => "The module from which the block originates; for example, 'user' for the Who's Online block, and 'block' for any custom blocks.",
26 ),
27 'delta' => array(
28 'type' => 'varchar',
29 'length' => 32,
30 'not null' => TRUE,
31 'default' => '0',
32 'description' => 'Unique ID for block within a module.',
33 ),
34 'theme' => array(
35 'type' => 'varchar',
36 'length' => 64,
37 'not null' => TRUE,
38 'default' => '',
39 'description' => 'The theme under which the block settings apply.',
40 ),
41 'status' => array(
42 'type' => 'int',
43 'not null' => TRUE,
44 'default' => 0,
45 'size' => 'tiny',
46 'description' => 'Block enabled status. (1 = enabled, 0 = disabled)',
47 ),
48 'weight' => array(
49 'type' => 'int',
50 'not null' => TRUE,
51 'default' => 0,
52 'description' => 'Block weight within region.',
53 ),
54 'region' => array(
55 'type' => 'varchar',
56 'length' => 64,
57 'not null' => TRUE,
58 'default' => '',
59 'description' => 'Theme region within which the block is set.',
60 ),
61 'custom' => array(
62 'type' => 'int',
63 'not null' => TRUE,
64 'default' => 0,
65 'size' => 'tiny',
66 'description' => 'Flag to indicate how users may control visibility of the block. (0 = Users cannot control, 1 = On by default, but can be hidden, 2 = Hidden by default, but can be shown)',
67 ),
68 'visibility' => array(
69 'type' => 'int',
70 'not null' => TRUE,
71 'default' => 0,
72 'size' => 'tiny',
73 'description' => 'Flag to indicate how to show blocks on pages. (0 = Show on all pages except listed pages, 1 = Show only on listed pages, 2 = Use custom PHP code to determine visibility)',
74 ),
75 'pages' => array(
76 'type' => 'text',
77 'not null' => TRUE,
78 'description' => 'Contents of the "Pages" block; contains either a list of paths on which to include/exclude the block or PHP code, depending on "visibility" setting.',
79 ),
80 'title' => array(
81 'type' => 'varchar',
82 'length' => 64,
83 'not null' => TRUE,
84 'default' => '',
85 'description' => 'Custom title for the block. (Empty string will use block default title, <none> will remove the title, text will cause block to use specified title.)',
86 'translatable' => TRUE,
87 ),
88 'cache' => array(
89 'type' => 'int',
90 'not null' => TRUE,
91 'default' => 1,
92 'size' => 'tiny',
93 'description' => 'Binary flag to indicate block cache mode. (-2: Custom cache, -1: Do not cache, 1: Cache per role, 2: Cache per user, 4: Cache per page, 8: Block cache global) See DRUPAL_CACHE_* constants in ../includes/common.inc for more detailed information.',
94 ),
95 ),
96 'primary key' => array('bid'),
97 'unique keys' => array(
98 'tmd' => array('theme', 'module', 'delta'),
99 ),
100 'indexes' => array(
101 'list' => array('theme', 'status', 'region', 'weight', 'module'),
102 ),
103 );
104
105 $schema['block_role'] = array(
106 'description' => 'Sets up access permissions for blocks based on user roles',
107 'fields' => array(
108 'module' => array(
109 'type' => 'varchar',
110 'length' => 64,
111 'not null' => TRUE,
112 'description' => "The block's origin module, from {block}.module.",
113 ),
114 'delta' => array(
115 'type' => 'varchar',
116 'length' => 32,
117 'not null' => TRUE,
118 'description' => "The block's unique delta within module, from {block}.delta.",
119 ),
120 'rid' => array(
121 'type' => 'int',
122 'unsigned' => TRUE,
123 'not null' => TRUE,
124 'description' => "The user's role ID from {users_roles}.rid.",
125 ),
126 ),
127 'primary key' => array('module', 'delta', 'rid'),
128 'indexes' => array(
129 'rid' => array('rid'),
130 ),
131 );
132
133 $schema['block_custom'] = array(
134 'description' => 'Stores contents of custom-made blocks.',
135 'fields' => array(
136 'bid' => array(
137 'type' => 'serial',
138 'unsigned' => TRUE,
139 'not null' => TRUE,
140 'description' => "The block's {block}.bid.",
141 ),
142 'body' => array(
143 'type' => 'text',
144 'not null' => FALSE,
145 'size' => 'big',
146 'description' => 'Block contents.',
147 'translatable' => TRUE,
148 ),
149 'info' => array(
150 'type' => 'varchar',
151 'length' => 128,
152 'not null' => TRUE,
153 'default' => '',
154 'description' => 'Block description.',
155 ),
156 'format' => array(
157 'type' => 'varchar',
158 'length' => 255,
159 'not null' => FALSE,
160 'description' => 'The {filter_format}.format of the block body.',
161 ),
162 ),
163 'unique keys' => array(
164 'info' => array('info'),
165 ),
166 'primary key' => array('bid'),
167 );
168
169 $schema['cache_block'] = drupal_get_schema_unprocessed('system', 'cache');
170 $schema['cache_block']['description'] = 'Cache table for the Block module to store already built blocks, identified by module, delta, and various contexts which may change the block, such as theme, locale, and caching mode defined for the block.';
171
172 return $schema;
173 }
174
178 function block_install() {
179
180 // Block should go first so that other modules can alter its output
181 // during hook_page_alter(). Almost everything on the page is a block,
182 // so before block module runs, there will not be much to alter.
183 db_update('system')
184 ->fields(array('weight' => -5))
185 ->condition('name', 'block')
186 ->execute();
187 }
188
192 function block_update_dependencies() {
193 // block_update_7005() needs to query the {filter_format} table to get a list
194 // of existing text formats, so it must run after filter_update_7000(), which
195 // creates that table.
196 $dependencies['block'][7005] = array(
197 'filter' => 7000,
198 );
199
200 return $dependencies;
201 }
202
215 function block_update_7000() {
216 db_update('system')
217 ->fields(array('weight' => '-5'))
218 ->condition('name', 'block')
219 ->execute();
220 }
221
226 function block_update_7002() {
227 db_drop_index('blocks', 'list');
228 db_rename_table('blocks', 'block');
229 db_rename_table('blocks_roles', 'block_role');
230 db_rename_table('boxes', 'block_custom');
231 }
232
236 function block_update_7003() {
237 db_change_field('block', 'weight', 'weight', array(
238 'type' => 'int',
239 'not null' => TRUE,
240 'default' => 0,
241 'description' => 'Block weight within region.',
242 ), array(
243 'indexes' => array(
244 'list' => array('theme', 'status', 'region', 'weight', 'module'),
245 ),
246 ));
247 }
248
252 function block_update_7004() {
253 // Collect a list of themes with blocks.
254 $themes_with_blocks = array();
255 $result = db_query("SELECT s.name FROM {system} s INNER JOIN {block} b ON s.name = b.theme WHERE s.type = 'theme' GROUP by s.name");
256
257 $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
258 foreach ($result as $theme) {
259 $themes_with_blocks[] = $theme->name;
260 // Add new system generated help block.
261 $insert->values(array(
262 'module' => 'system',
263 'delta' => 'help',
264 'theme' => $theme->name,
265 'status' => 1,
266 'weight' => 0,
267 'region' => 'help',
268 'pages' => '',
269 'cache' => DRUPAL_CACHE_PER_ROLE,
270 ));
271 // Add new system generated main page content block.
272 $insert->values(array(
273 'module' => 'system',
274 'delta' => 'main',
275 'theme' => $theme->name,
276 'status' => 1,
277 'weight' => 0,
278 'region' => 'content',
279 'pages' => '',
280 'cache' => DRUPAL_NO_CACHE,
281 ));
282 }
283 $insert->execute();
284
285 // Migrate blocks from left/right regions to first/second regions.
286 db_update('block')
287 ->fields(array('region' => 'sidebar_first'))
288 ->condition('region', 'left')
289 ->execute();
290 db_update('block')
291 ->fields(array('region' => 'sidebar_second'))
292 ->condition('region', 'right')
293 ->execute();
294
295 // Migrate contact form information.
296 $default_format = variable_get('filter_default_format', 1);
297 if ($contact_help = variable_get('contact_form_information', '')) {
298 $bid = db_insert('block_custom')
299 ->fields(array(
300 'body' => $contact_help,
301 'info' => 'Contact page help',
302 'format' => $default_format,
303 ))
304 ->execute();
305
306 $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
307 foreach ($themes_with_blocks as $theme) {
308 // Add contact help block for themes, which had blocks.
309 $insert->values(array(
310 'module' => 'block',
311 'delta' => $bid,
312 'theme' => $theme,
313 'status' => 1,
314 'weight' => 5,
315 'region' => 'help',
316 'visibility' => BLOCK_VISIBILITY_LISTED,
317 'pages' => 'contact',
318 'cache' => DRUPAL_NO_CACHE,
319 ));
320 }
321 drupal_set_message('The contact form information setting was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the site-wide contact page. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right.');
322 }
323 $insert->execute();
324
325 // Migrate user help setting.
326 if ($user_help = variable_get('user_registration_help', '')) {
327 $bid = db_insert('block_custom')->fields(array('body' => $user_help, 'info' => 'User registration guidelines', 'format' => $default_format))->execute();
328
329 $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
330 foreach ($themes_with_blocks as $theme) {
331 // Add user registration help block for themes, which had blocks.
332 $insert->values(array(
333 'module' => 'block',
334 'delta' => $bid,
335 'theme' => $theme,
336 'status' => 1,
337 'weight' => 5,
338 'region' => 'help',
339 'visibility' => BLOCK_VISIBILITY_LISTED,
340 'pages' => 'user/register',
341 'cache' => DRUPAL_NO_CACHE,
342 ));
343 }
344 drupal_set_message('The user registration guidelines were migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the user registration page. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right.');
345 $insert->execute();
346 }
347
348 // Migrate site mission setting.
349 if ($mission = variable_get('site_mission')) {
350 $bid = db_insert('block_custom')->fields(array('body' => $mission, 'info' => 'Site mission', 'format' => $default_format))->execute();
351
352 $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
353 foreach ($themes_with_blocks as $theme) {
354 // Add mission block for themes, which had blocks.
355 $insert->values(array(
356 'module' => 'block',
357 'delta' => $bid,
358 'theme' => $theme,
359 'status' => 1,
360 'weight' => 0,
361 'region' => 'highlighted',
362 'visibility' => BLOCK_VISIBILITY_LISTED,
363 'pages' => '<front>',
364 'cache' => DRUPAL_NO_CACHE,
365 ));
366 }
367 drupal_set_message('The site mission was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the front page in the highlighted content region. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right. If your theme does not have a highlighted content region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
368 $insert->execute();
369 // Migrate mission to RSS site description.
370 variable_set('feed_description', $mission);
371 }
372
373 // Migrate site footer message to a custom block.
374 if ($footer_message = variable_get('site_footer', '')) {
375 $bid = db_insert('block_custom')->fields(array('body' => $footer_message, 'info' => 'Footer message', 'format' => $default_format))->execute();
376
377 $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
378 foreach ($themes_with_blocks as $theme) {
379 // Add site footer block for themes, which had blocks.
380 // Set low weight, so the block comes early (it used to be
381 // before the other blocks).
382 $insert->values(array(
383 'module' => 'block',
384 'delta' => $bid,
385 'theme' => $theme,
386 'status' => 1,
387 'weight' => -10,
388 'region' => 'footer',
389 'pages' => '',
390 'cache' => DRUPAL_NO_CACHE,
391 ));
392 }
393 drupal_set_message('The footer message was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to appear in the footer. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right. If your theme does not have a footer region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
394 $insert->execute();
395 }
396
397 // Remove the variables (even if they were saved empty on the admin interface),
398 // to avoid keeping clutter in the variables table.
399 variable_del('contact_form_information');
400 variable_del('user_registration_help');
401 variable_del('site_mission');
402 variable_del('site_footer');
403
404 // Rebuild theme data, so the new 'help' region is identified.
405 system_rebuild_theme_data();
406 }
407
411 function block_update_7005() {
412 // For an explanation of these updates, see the code comments in
413 // user_update_7010().
414 db_change_field('block_custom', 'format', 'format', array(
415 'type' => 'int',
416 'unsigned' => TRUE,
417 'not null' => FALSE,
418 'description' => 'The {filter_format}.format of the block body.',
419 ));
420 db_update('block_custom')
421 ->fields(array('format' => NULL))
422 ->condition('body', '')
423 ->condition('format', 0)
424 ->execute();
425 $existing_formats = db_query("SELECT format FROM {filter_format}")->fetchCol();
426 $default_format = variable_get('filter_default_format', 1);
427 db_update('block_custom')
428 ->fields(array('format' => $default_format))
429 ->isNotNull('format')
430 ->condition('format', $existing_formats, 'NOT IN')
431 ->execute();
432 }
433
440 function block_update_7006() {
441 $schema = system_schema_cache_7054();
442
443 db_drop_table('cache_block');
444 db_create_table('cache_block', $schema);
445 }
446
450 function block_update_7007() {
451 db_change_field('block_custom', 'format', 'format', array(
452 'type' => 'varchar',
453 'length' => 255,
454 'not null' => FALSE,
455 'description' => 'The {filter_format}.format of the block body.',
456 ));
457 }
458
471 function block_update_7008() {
472 db_drop_field('block', 'throttle');
473 }
474
block_update_7004
block_update_7004()
Definition: block.install:252
BLOCK_VISIBILITY_LISTED
const BLOCK_VISIBILITY_LISTED
Definition: block.module:36
block_update_7003
block_update_7003()
Definition: block.install:236
block_update_dependencies
block_update_dependencies()
Definition: block.install:192
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_drop_index
db_drop_index($table, $name)
Definition: database.inc:2952
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
block_update_7008
block_update_7008()
Definition: block.install:471
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
system_rebuild_theme_data
system_rebuild_theme_data()
Definition: system.module:2609
drupal_get_schema_unprocessed
drupal_get_schema_unprocessed($module, $table=NULL)
Definition: common.inc:6998
db_drop_field
db_drop_field($table, $field)
Definition: database.inc:2852
block_update_7005
block_update_7005()
Definition: block.install:411
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
block_update_7002
block_update_7002()
Definition: block.install:226
block_update_7000
block_update_7000()
Definition: block.install:215
block_update_7006
block_update_7006()
Definition: block.install:440
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
block_schema
block_schema()
Definition: block.install:11
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
DRUPAL_NO_CACHE
const DRUPAL_NO_CACHE
Definition: common.inc:127
block_update_7007
block_update_7007()
Definition: block.install:450
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
system_schema_cache_7054
system_schema_cache_7054()
Definition: system.install:1660
block_install
block_install()
Definition: block.install:178
db_rename_table
db_rename_table($table, $new_name)
Definition: database.inc:2805
DRUPAL_CACHE_PER_ROLE
const DRUPAL_CACHE_PER_ROLE
Definition: common.inc:143
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/contact/contact.pages.inc Source File

  • modules
  • contact
contact.pages.inc
Go to the documentation of this file.
1 <?php
2
15 function contact_site_form($form, &$form_state) {
16 global $user;
17
18 // Check if flood control has been activated for sending e-mails.
19 $limit = variable_get('contact_threshold_limit', 5);
20 $window = variable_get('contact_threshold_window', 3600);
21 if (!flood_is_allowed('contact', $limit, $window) && !user_access('administer contact forms')) {
22 drupal_set_message(t("You cannot send more than %limit messages in @interval. Try again later.", array('%limit' => $limit, '@interval' => format_interval($window))), 'error');
23 drupal_access_denied();
24 drupal_exit();
25 }
26
27 // Get an array of the categories and the current default category.
28 $categories = db_select('contact', 'c')
29 ->addTag('translatable')
30 ->fields('c', array('cid', 'category'))
31 ->orderBy('weight')
32 ->orderBy('category')
33 ->execute()
34 ->fetchAllKeyed();
35 $default_category = db_query("SELECT cid FROM {contact} WHERE selected = 1")->fetchField();
36
37 // If there are no categories, do not display the form.
38 if (!$categories) {
39 if (user_access('administer contact forms')) {
40 drupal_set_message(t('The contact form has not been configured. <a href="@add">Add one or more categories</a> to the form.', array('@add' => url('admin/structure/contact/add'))), 'error');
41 }
42 else {
43 drupal_not_found();
44 drupal_exit();
45 }
46 }
47
48 // If there is more than one category available and no default category has
49 // been selected, prepend a default placeholder value.
50 if (!$default_category) {
51 if (count($categories) > 1) {
52 $categories = array(0 => t('- Please choose -')) + $categories;
53 }
54 else {
55 $default_category = key($categories);
56 }
57 }
58
59 if (!$user->uid) {
60 $form['#attached']['library'][] = array('system', 'jquery.cookie');
61 $form['#attributes']['class'][] = 'user-info-from-cookie';
62 }
63
64 $form['#attributes']['class'][] = 'contact-form';
65 $form['name'] = array(
66 '#type' => 'textfield',
67 '#title' => t('Your name'),
68 '#maxlength' => 255,
69 '#default_value' => $user->uid ? format_username($user) : '',
70 '#required' => TRUE,
71 );
72 $form['mail'] = array(
73 '#type' => 'textfield',
74 '#title' => t('Your e-mail address'),
75 '#maxlength' => 255,
76 '#default_value' => $user->uid ? $user->mail : '',
77 '#required' => TRUE,
78 );
79 $form['subject'] = array(
80 '#type' => 'textfield',
81 '#title' => t('Subject'),
82 '#maxlength' => 255,
83 '#required' => TRUE,
84 );
85 $form['cid'] = array(
86 '#type' => 'select',
87 '#title' => t('Category'),
88 '#default_value' => $default_category,
89 '#options' => $categories,
90 '#required' => TRUE,
91 '#access' => count($categories) > 1,
92 );
93 $form['message'] = array(
94 '#type' => 'textarea',
95 '#title' => t('Message'),
96 '#required' => TRUE,
97 );
98 // We do not allow anonymous users to send themselves a copy
99 // because it can be abused to spam people.
100 $form['copy'] = array(
101 '#type' => 'checkbox',
102 '#title' => t('Send yourself a copy.'),
103 '#access' => $user->uid,
104 );
105 $form['actions'] = array('#type' => 'actions');
106 $form['actions']['submit'] = array(
107 '#type' => 'submit',
108 '#value' => t('Send message'),
109 );
110
111 return $form;
112 }
113
119 function contact_site_form_validate($form, &$form_state) {
120 if (!$form_state['values']['cid']) {
121 form_set_error('cid', t('You must select a valid category.'));
122 }
123 if (!valid_email_address($form_state['values']['mail'])) {
124 form_set_error('mail', t('You must enter a valid e-mail address.'));
125 }
126 }
127
133 function contact_site_form_submit($form, &$form_state) {
134 global $user, $language;
135
136 $values = $form_state['values'];
137 $values['sender'] = $user;
138 $values['sender']->name = $values['name'];
139 $values['sender']->mail = $values['mail'];
140 $values['category'] = contact_load($values['cid']);
141
142 // Save the anonymous user information to a cookie for reuse.
143 if (!$user->uid) {
144 user_cookie_save(array_intersect_key($values, array_flip(array('name', 'mail'))));
145 }
146
147 // Get the to and from e-mail addresses.
148 $to = $values['category']['recipients'];
149 $from = $values['sender']->mail;
150
151 // Send the e-mail to the recipients using the site default language.
152 drupal_mail('contact', 'page_mail', $to, language_default(), $values, $from);
153
154 // If the user requests it, send a copy using the current language.
155 if ($values['copy']) {
156 drupal_mail('contact', 'page_copy', $from, $language, $values, $from);
157 }
158
159 // Send an auto-reply if necessary using the current language.
160 if ($values['category']['reply']) {
161 drupal_mail('contact', 'page_autoreply', $from, $language, $values, $to);
162 }
163
164 flood_register_event('contact', variable_get('contact_threshold_window', 3600));
165 watchdog('mail', '%sender-name (@sender-from) sent an e-mail regarding %category.', array('%sender-name' => $values['name'], '@sender-from' => $from, '%category' => $values['category']['category']));
166
167 // Jump to home page rather than back to contact page to avoid
168 // contradictory messages if flood control has been activated.
169 drupal_set_message(t('Your message has been sent.'));
170 $form_state['redirect'] = '';
171 }
172
183 function contact_personal_form($form, &$form_state, $recipient) {
184 global $user;
185
186 // Check if flood control has been activated for sending e-mails.
187 $limit = variable_get('contact_threshold_limit', 5);
188 $window = variable_get('contact_threshold_window', 3600);
189 if (!flood_is_allowed('contact', $limit, $window) && !user_access('administer contact forms') && !user_access('administer users')) {
190 drupal_set_message(t("You cannot send more than %limit messages in @interval. Try again later.", array('%limit' => $limit, '@interval' => format_interval($window))), 'error');
191 drupal_access_denied();
192 drupal_exit();
193 }
194
195 drupal_set_title(t('Contact @username', array('@username' => format_username($recipient))), PASS_THROUGH);
196
197 if (!$user->uid) {
198 $form['#attached']['library'][] = array('system', 'jquery.cookie');
199 $form['#attributes']['class'][] = 'user-info-from-cookie';
200 }
201
202 $form['#attributes']['class'][] = 'contact-form';
203 $form['recipient'] = array(
204 '#type' => 'value',
205 '#value' => $recipient,
206 );
207 $form['name'] = array(
208 '#type' => 'textfield',
209 '#title' => t('Your name'),
210 '#maxlength' => 255,
211 '#default_value' => $user->uid ? format_username($user) : '',
212 '#required' => TRUE,
213 );
214 $form['mail'] = array(
215 '#type' => 'textfield',
216 '#title' => t('Your e-mail address'),
217 '#maxlength' => 255,
218 '#default_value' => $user->uid ? $user->mail : '',
219 '#required' => TRUE,
220 );
221 $form['to'] = array(
222 '#type' => 'item',
223 '#title' => t('To'),
224 '#markup' => theme('username', array('account' => $recipient)),
225 );
226 $form['subject'] = array(
227 '#type' => 'textfield',
228 '#title' => t('Subject'),
229 '#maxlength' => 50,
230 '#required' => TRUE,
231 );
232 $form['message'] = array(
233 '#type' => 'textarea',
234 '#title' => t('Message'),
235 '#rows' => 15,
236 '#required' => TRUE,
237 );
238 // We do not allow anonymous users to send themselves a copy
239 // because it can be abused to spam people.
240 $form['copy'] = array(
241 '#type' => 'checkbox',
242 '#title' => t('Send yourself a copy.'),
243 '#access' => $user->uid,
244 );
245 $form['actions'] = array('#type' => 'actions');
246 $form['actions']['submit'] = array(
247 '#type' => 'submit',
248 '#value' => t('Send message'),
249 );
250 return $form;
251 }
252
258 function contact_personal_form_validate($form, &$form_state) {
259 if (!valid_email_address($form_state['values']['mail'])) {
260 form_set_error('mail', t('You must enter a valid e-mail address.'));
261 }
262 }
263
269 function contact_personal_form_submit($form, &$form_state) {
270 global $user, $language;
271
272 $values = $form_state['values'];
273 $values['sender'] = $user;
274 $values['sender']->name = $values['name'];
275 $values['sender']->mail = $values['mail'];
276
277 // Save the anonymous user information to a cookie for reuse.
278 if (!$user->uid) {
279 user_cookie_save(array_intersect_key($values, array_flip(array('name', 'mail'))));
280 }
281
282 // Get the to and from e-mail addresses.
283 $to = $values['recipient']->mail;
284 $from = $values['sender']->mail;
285
286 // Send the e-mail in the requested user language.
287 drupal_mail('contact', 'user_mail', $to, user_preferred_language($values['recipient']), $values, $from);
288
289 // Send a copy if requested, using current page language.
290 if ($values['copy']) {
291 drupal_mail('contact', 'user_copy', $from, $language, $values, $from);
292 }
293
294 flood_register_event('contact', variable_get('contact_threshold_window', 3600));
295 watchdog('mail', '%sender-name (@sender-from) sent %recipient-name an e-mail.', array('%sender-name' => $values['name'], '@sender-from' => $from, '%recipient-name' => $values['recipient']->name));
296
297 // Jump to the contacted user's profile page.
298 drupal_set_message(t('Your message has been sent.'));
299 $form_state['redirect'] = user_access('access user profiles') ? 'user/' . $values['recipient']->uid : '';
300 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
contact_personal_form_validate
contact_personal_form_validate($form, &$form_state)
Definition: contact.pages.inc:258
contact_load
contact_load($cid)
Definition: contact.module:156
flood_is_allowed
flood_is_allowed($name, $threshold, $window=3600, $identifier=NULL)
Definition: common.inc:1298
format_username
format_username($account)
Definition: common.inc:2106
drupal_mail
drupal_mail($module, $key, $to, $language, $params=array(), $from=NULL, $send=TRUE)
Definition: mail.inc:122
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
name
print $forum name
Definition: forum-list.tpl.php:57
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
user_cookie_save
user_cookie_save(array $values)
Definition: user.module:3958
contact_personal_form
contact_personal_form($form, &$form_state, $recipient)
Definition: contact.pages.inc:183
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
user_preferred_language
user_preferred_language($account, $default=NULL)
Definition: user.module:3524
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
contact_personal_form_submit
contact_personal_form_submit($form, &$form_state)
Definition: contact.pages.inc:269
contact_site_form_validate
contact_site_form_validate($form, &$form_state)
Definition: contact.pages.inc:119
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_access_denied
drupal_access_denied()
Definition: common.inc:744
valid_email_address
valid_email_address($mail)
Definition: common.inc:1186
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
drupal_exit
drupal_exit($destination=NULL)
Definition: common.inc:2721
language_default
language_default($property=NULL)
Definition: bootstrap.inc:2765
contact_site_form_submit
contact_site_form_submit($form, &$form_state)
Definition: contact.pages.inc:133
drupal_not_found
drupal_not_found()
Definition: common.inc:731
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
flood_register_event
flood_register_event($name, $window=3600, $identifier=NULL)
Definition: common.inc:1245
contact_site_form
contact_site_form($form, &$form_state)
Definition: contact.pages.inc:15
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/image_example/image_example.module Source File

  • examples
  • image_example
image_example.module
Go to the documentation of this file.
1 <?php
2
48 function image_example_menu() {
49 $items = array();
50 $items['image_example/styles'] = array(
51 'title' => 'Image Example',
52 'page callback' => 'drupal_get_form',
53 'page arguments' => array('image_example_style_form'),
54 'access arguments' => array('access content'),
55 'file' => 'image_example.pages.inc',
56 );
57 return $items;
58 }
59
63 function image_example_help($path) {
64 switch ($path) {
65 case 'image_example/styles':
66 $output = '<p>' . t('Use this form to upload an image and choose an Image Style to use when displaying the image. This demonstrates basic use of the Drupal 7 Image styles & effects system.') . '</p>';
67 $output .= '<p>' . t('Image styles can be added/edited using the !link.', array('!link' => l(t('Image styles UI'), 'admin/config/media/image-styles'))) . '</p>';
68 return $output;
69 }
70 }
71
84 function image_example_image_default_styles() {
85 // This hook returns an array, each component of which describes an image
86 // style. The array keys are the machine-readable image style names and
87 // to avoid namespace conflicts should begin with the name of the
88 // implementing module. e.g.) 'mymodule_stylename'. Styles names should
89 // use only alpha-numeric characters, underscores (_), and hyphens (-).
90 $styles = array();
91 $styles['image_example_style'] = array();
92
93 // Each style array consists of an 'effects' array that is made up of
94 // sub-arrays which define the individual image effects that are combined
95 // together to create the image style.
96 $styles['image_example_style']['effects'] = array(
97 array(
98 // Name of the image effect. See image_image_effect_info() in
99 // modules/image/image.effects.inc for a list of image effects available
100 // in Drupal 7 core.
101 'name' => 'image_scale',
102 // Arguments to pass to the effect callback function.
103 // The arguments that an effect accepts are documented with each
104 // individual image_EFFECT_NAME_effect function. See image_scale_effect()
105 // for an example.
106 'data' => array(
107 'width' => 100,
108 'height' => 100,
109 'upscale' => 1,
110 ),
111 // The order in which image effects should be applied when using this
112 // style.
113 'weight' => 0,
114 ),
115 // Add a second effect to this image style. Effects are executed in order
116 // and are cummulative. When applying an image style to an image the result
117 // will be the combination of all effects associated with that style.
118 array(
119 'name' => 'image_example_colorize',
120 'data' => array(
121 'color' => '#FFFF66',
122 ),
123 'weight' => 1,
124 ),
125 );
126
127 return $styles;
128 }
129
136 function image_example_image_style_save($style) {
137 // The $style parameter is an image style array with one notable exception.
138 // When a user has choosen to replace a deleted style with another style the
139 // $style['name'] property contains the name of the replacement style and
140 // $style['old_name'] contains the name of the style being deleted.
141
142 // Here we update a variable that contains the name of the image style that
143 // the block provided by this module uses when formating images to use the
144 // new user choosen style name.
145 if (isset($style['old_name']) && $style['old_name'] == variable_get('image_example_style_name', '')) {
146 variable_set('image_example_style_name', $style['name']);
147 }
148 }
149
157 function image_example_image_style_delete($style) {
158 // See information about $style paramater in documentation for
159 // image_example_style_save().
160
161 // Update the modules variable that contains the name of the image style
162 // being deleted to the name of the replacement style.
163 if (isset($style['old_name']) && $style['old_name'] == variable_get('image_example_style_name', '')) {
164 variable_set('image_example_style_name', $style['name']);
165 }
166 }
167
184 function image_example_style_flush($style) {
185 // The $style parameter is an image style array.
186
187 // Empty any caches populated by our module that could contain stale data
188 // after the style has been flushed. Stale data occurs because the module may
189 // have cached content with a reference to the derivative image which is
190 // being deleted.
191 cache_clear_all('*', 'image_example', TRUE);
192 }
193
204 function image_example_image_styles_alter(&$styles) {
205 // The $styles paramater is an array of image style arrays keyed by style
206 // name. You can check to see if a style has been overriden by checking the
207 // $styles['stylename']['storage'] property.
208
209 // Verify that the effect has not been overriden.
210 if ($styles['thumbnail']['storage'] == IMAGE_STORAGE_DEFAULT) {
211 // Add an additional colorize effect to the system provided thumbnail
212 // effect.
213 $styles['thumbnail']['effects'][] = array(
214 'label' => t('Colorize #FFFF66'),
215 'name' => 'image_example_colorize',
216 'effect callback' => 'image_example_colorize_effect',
217 'data' => array(
218 'color' => '#FFFF66',
219 ),
220 'weight' => 1,
221 );
222 }
223 }
224
231 function image_example_image_effect_info() {
232 $effects = array();
233
234 // The array is keyed on the machine-readable effect name.
235 $effects['image_example_colorize'] = array(
236 // Human readable name of the effect.
237 'label' => t('Colorize'),
238 // (optional) Brief description of the effect that will be shown when
239 // adding or configuring this image effect.
240 'help' => t('The colorize effect will first remove all color from the source image and then tint the image using the color specified.'),
241 // Name of function called to perform this effect.
242 'effect callback' => 'image_example_colorize_effect',
243 // (optional) Name of function that provides a $form array with options for
244 // configuring the effect. Note that you only need to return the fields
245 // specific to your module. Submit buttons will be added automatically, and
246 // configuration options will be serailized and added to the 'data' element
247 // of the effect. The function will recieve the $effect['data'] array as
248 // its only parameter.
249 'form callback' => 'image_example_colorize_form',
250 // (optional) Name of a theme function that will output a summary of this
251 // effects configuation. Used when displaying list of effects associated
252 // with an image style. In this example the function
253 // theme_image_example_colorize_summary will be called via the theme()
254 // function. Your module must also implement hook_theme() in order for this
255 // function to work correctly. See image_example_theme() and
256 // theme_image_example_colorize_summary().
257 'summary theme' => 'image_example_colorize_summary',
258 );
259
260 return $effects;
261 }
262
276 function image_example_colorize_form($data) {
277 $form = array();
278 // You do not need to worry about handling saving/updating/deleting of the
279 // data collected. The image module will automatically serialize and store
280 // all data associated with an effect.
281 $form['color'] = array(
282 '#type' => 'textfield',
283 '#title' => t('Color'),
284 '#description' => t('The color to use when colorizing the image. Use web-style hex colors. e.g.) #FF6633.'),
285 '#default_value' => isset($data['color']) ? $data['color'] : '',
286 '#size' => 7,
287 '#max_length' => 7,
288 '#required' => TRUE,
289 );
290 return $form;
291 }
292
305 function image_example_colorize_effect(&$image, $data) {
306 // Image manipulation should be done to the $image->resource, which will be
307 // automatically saved as a new image once all effects have been applied.
308 // If your effect makes changes to the $image->resource that relate to any
309 // information stored in the $image->info array (width, height, etc.) you
310 // should update that information as well. See modules/system/image.gd.inc
311 // for examples of functions that perform image manipulations.
312
313 // Not all GD installations are created equal. It is a good idea to check for
314 // the existence of image manipulation functions before using them.
315 // PHP installations using non-bundled GD do not have imagefilter(). More
316 // information about image manipulation functions is available in the PHP
317 // manual. http://www.php.net/manual/en/book.image.php
318 if (!function_exists('imagefilter')) {
319 watchdog('image', 'The image %image could not be colorized because the imagefilter() function is not available in this PHP installation.', array('%file' => $image->source));
320 return FALSE;
321 }
322
323 // Verify that Drupal is using the PHP GD library for image manipulations
324 // since this effect depends on functions in the GD library.
325 if ($image->toolkit != 'gd') {
326 watchdog('image', 'Image colorize failed on %path. Using non GD toolkit.', array('%path' => $image->source), WATCHDOG_ERROR);
327 return FALSE;
328 }
329
330 // Convert short #FFF syntax to full #FFFFFF syntax.
331 if (strlen($data['color']) == 4) {
332 $c = $data['color'];
333 $data['color'] = $c[0] . $c[1] . $c[1] . $c[2] . $c[2] . $c[3] . $c[3];
334 }
335
336 // Convert #FFFFFF syntax to hexadecimal colors.
337 $data['color'] = hexdec(str_replace('#', '0x', $data['color']));
338
339 // Convert the hexadecimal color value to a color index value.
340 $rgb = array();
341 for ($i = 16; $i >= 0; $i -= 8) {
342 $rgb[] = (($data['color'] >> $i) & 0xFF);
343 }
344
345 // First desaturate the image, and then apply the new color.
346 imagefilter($image->resource, IMG_FILTER_GRAYSCALE);
347 imagefilter($image->resource, IMG_FILTER_COLORIZE, $rgb[0], $rgb[1], $rgb[2]);
348
349 return TRUE;
350 }
351
355 function image_example_theme() {
356 return array(
357 'image_example_colorize_summary' => array(
358 'variables' => array('data' => NULL),
359 ),
360 'image_example_image' => array(
361 'variables' => array('image' => NULL, 'style' => NULL),
362 'file' => 'image_example.pages.inc',
363 ),
364 );
365 }
366
374 function theme_image_example_colorize_summary($variables) {
375 $data = $variables['data'];
376 return t('as color #@color.', array('@color' => $data['color']));
377 }
l
l($text, $path, array $options=array())
Definition: common.inc:2432
image_example_image_effect_info
image_example_image_effect_info()
Definition: image_example.module:231
image_example_theme
image_example_theme()
Definition: image_example.module:355
image_example_image_styles_alter
image_example_image_styles_alter(&$styles)
Definition: image_example.module:204
theme_image_example_colorize_summary
theme_image_example_colorize_summary($variables)
Definition: image_example.module:374
image_example_menu
image_example_menu()
Definition: image_example.module:48
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
image_example_style_flush
image_example_style_flush($style)
Definition: image_example.module:184
IMAGE_STORAGE_DEFAULT
const IMAGE_STORAGE_DEFAULT
Definition: image.module:21
$output
$output
Definition: authorize.php:93
image_example_help
image_example_help($path)
Definition: image_example.module:63
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
$styles
print $styles
Definition: html.tpl.php:52
image_example_colorize_effect
image_example_colorize_effect(&$image, $data)
Definition: image_example.module:305
image_example_image_style_delete
image_example_image_style_delete($style)
Definition: image_example.module:157
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
image_example_image_style_save
image_example_image_style_save($style)
Definition: image_example.module:136
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
image_example_image_default_styles
image_example_image_default_styles()
Definition: image_example.module:84
image_example_colorize_form
image_example_colorize_form($data)
Definition: image_example.module:276
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll-results.tpl.php Source File

  • modules
  • poll
poll-results.tpl.php
Go to the documentation of this file.
1 <?php
2
21 ?>
22 <div class="poll">
23 <?php print $results; ?>
24 <div class="total">
25 <?php print t('Total votes: @votes', array('@votes' => $votes)); ?>
26 </div>
27 <?php if (!empty($cancel_form)): ?>
28 <?php print $cancel_form; ?>
29 <?php endif; ?>
30 </div>
$results
print $results
Definition: poll-results.tpl.php:23
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
endif
endif
Definition: aggregator-item.tpl.php:31
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy/taxonomy.tokens.inc Source File

  • modules
  • taxonomy
taxonomy.tokens.inc
Go to the documentation of this file.
1 <?php
2
11 function taxonomy_token_info() {
12 $types['term'] = array(
13 'name' => t("Taxonomy terms"),
14 'description' => t("Tokens related to taxonomy terms."),
15 'needs-data' => 'term',
16 );
17 $types['vocabulary'] = array(
18 'name' => t("Vocabularies"),
19 'description' => t("Tokens related to taxonomy vocabularies."),
20 'needs-data' => 'vocabulary',
21 );
22
23 // Taxonomy term related variables.
24 $term['tid'] = array(
25 'name' => t("Term ID"),
26 'description' => t("The unique ID of the taxonomy term."),
27 );
28 $term['name'] = array(
29 'name' => t("Name"),
30 'description' => t("The name of the taxonomy term."),
31 );
32 $term['description'] = array(
33 'name' => t("Description"),
34 'description' => t("The optional description of the taxonomy term."),
35 );
36 $term['node-count'] = array(
37 'name' => t("Node count"),
38 'description' => t("The number of nodes tagged with the taxonomy term."),
39 );
40 $term['url'] = array(
41 'name' => t("URL"),
42 'description' => t("The URL of the taxonomy term."),
43 );
44
45 // Taxonomy vocabulary related variables.
46 $vocabulary['vid'] = array(
47 'name' => t("Vocabulary ID"),
48 'description' => t("The unique ID of the taxonomy vocabulary."),
49 );
50 $vocabulary['name'] = array(
51 'name' => t("Name"),
52 'description' => t("The name of the taxonomy vocabulary."),
53 );
54 $vocabulary['description'] = array(
55 'name' => t("Description"),
56 'description' => t("The optional description of the taxonomy vocabulary."),
57 );
58 $vocabulary['node-count'] = array(
59 'name' => t("Node count"),
60 'description' => t("The number of nodes tagged with terms belonging to the taxonomy vocabulary."),
61 );
62 $vocabulary['term-count'] = array(
63 'name' => t("Term count"),
64 'description' => t("The number of terms belonging to the taxonomy vocabulary."),
65 );
66
67 // Chained tokens for taxonomies
68 $term['vocabulary'] = array(
69 'name' => t("Vocabulary"),
70 'description' => t("The vocabulary the taxonomy term belongs to."),
71 'type' => 'vocabulary',
72 );
73 $term['parent'] = array(
74 'name' => t("Parent term"),
75 'description' => t("The parent term of the taxonomy term, if one exists."),
76 'type' => 'term',
77 );
78
79 return array(
80 'types' => $types,
81 'tokens' => array(
82 'term' => $term,
83 'vocabulary' => $vocabulary,
84 ),
85 );
86 }
87
91 function taxonomy_tokens($type, $tokens, array $data = array(), array $options = array()) {
92 $replacements = array();
93 $sanitize = !empty($options['sanitize']);
94
95 if ($type == 'term' && !empty($data['term'])) {
96 $term = $data['term'];
97
98 foreach ($tokens as $name => $original) {
99 switch ($name) {
100 case 'tid':
101 $replacements[$original] = $term->tid;
102 break;
103
104 case 'name':
105 $replacements[$original] = $sanitize ? check_plain($term->name) : $term->name;
106 break;
107
108 case 'description':
109 $replacements[$original] = $sanitize ? check_markup($term->description, $term->format, '', TRUE) : $term->description;
110 break;
111
112 case 'url':
113 $uri = entity_uri('taxonomy_term', $term);
114 $replacements[$original] = url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE)));
115 break;
116
117 case 'node-count':
118 $query = db_select('taxonomy_index');
119 $query->condition('tid', $term->tid);
120 $query->addTag('term_node_count');
121 $count = $query->countQuery()->execute()->fetchField();
122 $replacements[$original] = $count;
123 break;
124
125 case 'vocabulary':
126 $vocabulary = taxonomy_vocabulary_load($term->vid);
127 $replacements[$original] = check_plain($vocabulary->name);
128 break;
129
130 case 'parent':
131 if ($parents = taxonomy_get_parents($term->tid)) {
132 $parent = array_pop($parents);
133 $replacements[$original] = check_plain($parent->name);
134 }
135 break;
136 }
137 }
138
139 if ($vocabulary_tokens = token_find_with_prefix($tokens, 'vocabulary')) {
140 $vocabulary = taxonomy_vocabulary_load($term->vid);
141 $replacements += token_generate('vocabulary', $vocabulary_tokens, array('vocabulary' => $vocabulary), $options);
142 }
143
144 if (($vocabulary_tokens = token_find_with_prefix($tokens, 'parent')) && $parents = taxonomy_get_parents($term->tid)) {
145 $parent = array_pop($parents);
146 $replacements += token_generate('term', $vocabulary_tokens, array('term' => $parent), $options);
147 }
148 }
149
150 elseif ($type == 'vocabulary' && !empty($data['vocabulary'])) {
151 $vocabulary = $data['vocabulary'];
152
153 foreach ($tokens as $name => $original) {
154 switch ($name) {
155 case 'vid':
156 $replacements[$original] = $vocabulary->vid;
157 break;
158
159 case 'name':
160 $replacements[$original] = $sanitize ? check_plain($vocabulary->name) : $vocabulary->name;
161 break;
162
163 case 'description':
164 $replacements[$original] = $sanitize ? filter_xss($vocabulary->description) : $vocabulary->description;
165 break;
166
167 case 'term-count':
168 $query = db_select('taxonomy_term_data');
169 $query->condition('vid', $vocabulary->vid);
170 $query->addTag('vocabulary_term_count');
171 $count = $query->countQuery()->execute()->fetchField();
172 $replacements[$original] = $count;
173 break;
174
175 case 'node-count':
176 $query = db_select('taxonomy_index', 'ti');
177 $query->addExpression('COUNT(DISTINCT ti.nid)');
178 $query->leftJoin('taxonomy_term_data', 'td', 'ti.tid = td.tid');
179 $query->condition('td.vid', $vocabulary->vid);
180 $query->addTag('vocabulary_node_count');
181 $count = $query->execute()->fetchField();
182 $replacements[$original] = $count;
183 break;
184 }
185 }
186 }
187
188 return $replacements;
189 }
token_generate
token_generate($type, array $tokens, array $data=array(), array $options=array())
Definition: token.inc:176
$name
print $name
Definition: profile-listing.tpl.php:43
entity_uri
entity_uri($entity_type, $entity)
Definition: common.inc:7902
taxonomy_vocabulary_load
taxonomy_vocabulary_load($vid)
Definition: taxonomy.module:1351
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
taxonomy_tokens
taxonomy_tokens($type, $tokens, array $data=array(), array $options=array())
Definition: taxonomy.tokens.inc:91
taxonomy_get_parents
taxonomy_get_parents($tid)
Definition: taxonomy.module:1007
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
check_markup
check_markup($text, $format_id=NULL, $langcode= '', $cache=FALSE)
Definition: filter.module:759
token_find_with_prefix
token_find_with_prefix(array $tokens, $prefix, $delimiter= ':')
Definition: token.inc:219
taxonomy_token_info
taxonomy_token_info()
Definition: taxonomy.tokens.inc:11
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/theming_example/theming-example-text-form.tpl.php Source File

  • examples
  • theming_example
theming-example-text-form.tpl.php
Go to the documentation of this file.
1 <?php
25 ?>
26 <!-- theming-example-text-form template -->
27 <div class="container-inline">
28 <?php print $text_form; ?>
29 </div>
30 <!-- /theming-example-text-form template -->
$text_form
print $text_form
Definition: theming-example-text-form.tpl.php:28
print
print
Definition: php-2.php:2
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/examples.module Source File

  • examples
examples.module
Go to the documentation of this file.
1 <?php
2
30 function examples_help($path, $arg) {
31 // re: http://drupal.org/node/767204
32 // 5. We need a master group (Examples) that will be in a main
33 // examples.module.
34 // The examples.module should be mostly doxy comments that point to the other
35 // examples. It will also have a hook_help() explaining its purpose and how
36 // to access the other examples.
37 }
38
examples_help
examples_help($path, $arg)
Definition: examples.module:30
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/tablesort_example/tablesort_example.module Source File

  • examples
  • tablesort_example
tablesort_example.module
Go to the documentation of this file.
1 <?php
24 function tablesort_example_help($path, $arg) {
25 switch ($path) {
26 case 'examples/tablesort_example':
27 return '<p>' . t('The layout here is a themed as a table that is sortable by clicking the header name.') . '</p>';
28 }
29 }
30
34 function tablesort_example_menu() {
35 $items['examples/tablesort_example'] = array(
36 'title' => 'TableSort example',
37 'description' => 'Show a page with a sortable table',
38 'page callback' => 'tablesort_example_page',
39 'access callback' => TRUE,
40 );
41 return $items;
42 }
43
50 function tablesort_example_page() {
51 // We are going to output the results in a table with a nice header.
52 $header = array(
53 // The header gives the table the information it needs in order to make
54 // the query calls for ordering. TableSort uses the field information
55 // to know what database column to sort by.
56 array('data' => t('Numbers'), 'field' => 't.numbers'),
57 array('data' => t('Letters'), 'field' => 't.alpha'),
58 array('data' => t('Mixture'), 'field' => 't.random'),
59 );
60
61 $query = db_select('tablesort_example', 't')
62 ->extend('TableSort'); // Using the TableSort Extender is what tells the
63 // the query object that we are sorting.
64 $query->fields('t');
65
66 $result = $query
67 ->orderByHeader($header) // Don't forget to tell the query object how to
68 // find the header information.
69 ->execute();
70
71 $rows = array();
72 foreach ($result as $row) {
73 // normally we would add some nice formatting to our rows
74 // but for our purpose we are simply going to add our row
75 // to the array.
76 $rows[] = array('data' => (array) $row);
77 }
78
79 // build the table for the nice output.
80 $build['tablesort_table'] = array(
81 '#theme' => 'table',
82 '#header' => $header,
83 '#rows' => $rows,
84 );
85
86 return $build;
87 }
tablesort_example_help
tablesort_example_help($path, $arg)
Definition: tablesort_example.module:24
tablesort_example_page
tablesort_example_page()
Definition: tablesort_example.module:50
$header
print $header
Definition: forum-topic-list.tpl.php:42
tablesort_example_menu
tablesort_example_menu()
Definition: tablesort_example.module:34
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$row
$row
Definition: block-admin-display-form.tpl.php:47
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/block/block.admin.inc Source File

  • modules
  • block
block.admin.inc
Go to the documentation of this file.
1 <?php
2
11 function block_admin_demo($theme = NULL) {
12 drupal_add_css(drupal_get_path('module', 'block') . '/block.css');
13 return '';
14 }
15
23 function block_admin_display($theme = NULL) {
24 global $theme_key;
25
26 drupal_theme_initialize();
27
28 if (!isset($theme)) {
29 // If theme is not specifically set, rehash for the current theme.
30 $theme = $theme_key;
31 }
32
33 // Fetch and sort blocks.
34 $blocks = block_admin_display_prepare_blocks($theme);
35
36 return drupal_get_form('block_admin_display_form', $blocks, $theme);
37 }
38
51 function block_admin_display_prepare_blocks($theme) {
52 $blocks = _block_rehash($theme);
53 $compare_theme = &drupal_static('_block_compare:theme');
54 $compare_theme = $theme;
55 usort($blocks, '_block_compare');
56 return $blocks;
57 }
58
78 function block_admin_display_form($form, &$form_state, $blocks, $theme, $block_regions = NULL) {
79
80 $form['#attached']['css'] = array(drupal_get_path('module', 'block') . '/block.css');
81
82 // Get a list of block regions if one was not provided.
83 if (!isset($block_regions)) {
84 $block_regions = system_region_list($theme, REGIONS_VISIBLE);
85 }
86
87 // Weights range from -delta to +delta, so delta should be at least half
88 // of the amount of blocks present. This makes sure all blocks in the same
89 // region get an unique weight.
90 $weight_delta = round(count($blocks) / 2);
91
92 // Build the form tree.
93 $form['edited_theme'] = array(
94 '#type' => 'value',
95 '#value' => $theme,
96 );
97 $form['block_regions'] = array(
98 '#type' => 'value',
99 // Add a last region for disabled blocks.
100 '#value' => $block_regions + array(BLOCK_REGION_NONE => BLOCK_REGION_NONE),
101 );
102 $form['blocks'] = array();
103 $form['#tree'] = TRUE;
104
105 foreach ($blocks as $i => $block) {
106 $key = $block['module'] . '_' . $block['delta'];
107 $form['blocks'][$key]['module'] = array(
108 '#type' => 'value',
109 '#value' => $block['module'],
110 );
111 $form['blocks'][$key]['delta'] = array(
112 '#type' => 'value',
113 '#value' => $block['delta'],
114 );
115 $form['blocks'][$key]['info'] = array(
116 '#markup' => check_plain($block['info']),
117 );
118 $form['blocks'][$key]['theme'] = array(
119 '#type' => 'hidden',
120 '#value' => $theme,
121 );
122 $form['blocks'][$key]['weight'] = array(
123 '#type' => 'weight',
124 '#default_value' => $block['weight'],
125 '#delta' => $weight_delta,
126 '#title_display' => 'invisible',
127 '#title' => t('Weight for @block block', array('@block' => $block['info'])),
128 );
129 $form['blocks'][$key]['region'] = array(
130 '#type' => 'select',
131 '#default_value' => $block['region'] != BLOCK_REGION_NONE ? $block['region'] : NULL,
132 '#empty_value' => BLOCK_REGION_NONE,
133 '#title_display' => 'invisible',
134 '#title' => t('Region for @block block', array('@block' => $block['info'])),
135 '#options' => $block_regions,
136 );
137 $form['blocks'][$key]['configure'] = array(
138 '#type' => 'link',
139 '#title' => t('configure'),
140 '#href' => 'admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure',
141 );
142 if ($block['module'] == 'block') {
143 $form['blocks'][$key]['delete'] = array(
144 '#type' => 'link',
145 '#title' => t('delete'),
146 '#href' => 'admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/delete',
147 );
148 }
149 }
150 // Do not allow disabling the main system content block when it is present.
151 if (isset($form['blocks']['system_main']['region'])) {
152 $form['blocks']['system_main']['region']['#required'] = TRUE;
153 }
154
155 $form['actions'] = array(
156 '#tree' => FALSE,
157 '#type' => 'actions',
158 );
159 $form['actions']['submit'] = array(
160 '#type' => 'submit',
161 '#value' => t('Save blocks'),
162 );
163
164 return $form;
165 }
166
172 function block_admin_display_form_submit($form, &$form_state) {
173 $transaction = db_transaction();
174 try {
175 foreach ($form_state['values']['blocks'] as $block) {
176 $block['status'] = (int) ($block['region'] != BLOCK_REGION_NONE);
177 $block['region'] = $block['status'] ? $block['region'] : '';
178 db_update('block')
179 ->fields(array(
180 'status' => $block['status'],
181 'weight' => $block['weight'],
182 'region' => $block['region'],
183 ))
184 ->condition('module', $block['module'])
185 ->condition('delta', $block['delta'])
186 ->condition('theme', $block['theme'])
187 ->execute();
188 }
189 }
190 catch (Exception $e) {
191 $transaction->rollback();
192 watchdog_exception('block', $e);
193 throw $e;
194 }
195 drupal_set_message(t('The block settings have been updated.'));
196 cache_clear_all();
197 }
198
204 function _block_compare($a, $b) {
205 global $theme_key;
206
207 // Theme should be set before calling this function, or the current theme
208 // is being used.
209 $theme = &drupal_static(__FUNCTION__ . ':theme');
210 if (!isset($theme)) {
211 $theme = $theme_key;
212 }
213
214 $regions = &drupal_static(__FUNCTION__ . ':regions');
215 // We need the region list to correctly order by region.
216 if (!isset($regions)) {
217 $regions = array_flip(array_keys(system_region_list($theme)));
218 $regions[BLOCK_REGION_NONE] = count($regions);
219 }
220
221 // Separate enabled from disabled.
222 $status = $b['status'] - $a['status'];
223 if ($status) {
224 return $status;
225 }
226 // Sort by region (in the order defined by theme .info file).
227 if ((!empty($a['region']) && !empty($b['region'])) && ($place = ($regions[$a['region']] - $regions[$b['region']]))) {
228 return $place;
229 }
230 // Sort by weight, unless disabled.
231 if ($a['region'] != BLOCK_REGION_NONE) {
232 $weight = $a['weight'] - $b['weight'];
233 if ($weight) {
234 return $weight;
235 }
236 }
237 // Sort by title.
238 return strcmp($a['info'], $b['info']);
239 }
240
255 function block_admin_configure($form, &$form_state, $module, $delta) {
256 $block = block_load($module, $delta);
257 $form['module'] = array(
258 '#type' => 'value',
259 '#value' => $block->module,
260 );
261 $form['delta'] = array(
262 '#type' => 'value',
263 '#value' => $block->delta,
264 );
265
266 // Get the block subject for the page title.
267 $info = module_invoke($block->module, 'block_info');
268 if (isset($info[$block->delta])) {
269 drupal_set_title(t("'%name' block", array('%name' => $info[$block->delta]['info'])), PASS_THROUGH);
270 }
271
272 $form['settings']['title'] = array(
273 '#type' => 'textfield',
274 '#title' => t('Block title'),
275 '#maxlength' => 64,
276 '#description' => $block->module == 'block' ? t('The title of the block as shown to the user.') : t('Override the default title for the block. Use <em>!placeholder</em> to display no title, or leave blank to use the default block title.', array('!placeholder' => '&lt;none&gt;')),
277 '#default_value' => isset($block->title) ? $block->title : '',
278 '#weight' => -19,
279 );
280
281 // Module-specific block configuration.
282 if ($settings = module_invoke($block->module, 'block_configure', $block->delta)) {
283 foreach ($settings as $k => $v) {
284 $form['settings'][$k] = $v;
285 }
286 }
287
288 // Region settings.
289 $form['regions'] = array(
290 '#type' => 'fieldset',
291 '#title' => t('Region settings'),
292 '#collapsible' => FALSE,
293 '#description' => t('Specify in which themes and regions this block is displayed.'),
294 '#tree' => TRUE,
295 );
296
297 $theme_default = variable_get('theme_default', 'bartik');
298 $admin_theme = variable_get('admin_theme');
299 foreach (list_themes() as $key => $theme) {
300 // Only display enabled themes
301 if ($theme->status) {
302 $region = db_query("SELECT region FROM {block} WHERE module = :module AND delta = :delta AND theme = :theme", array(
303 ':module' => $block->module,
304 ':delta' => $block->delta,
305 ':theme' => $key,
306 ))->fetchField();
307
308 // Use a meaningful title for the main site theme and administrative
309 // theme.
310 $theme_title = $theme->info['name'];
311 if ($key == $theme_default) {
312 $theme_title = t('!theme (default theme)', array('!theme' => $theme_title));
313 }
314 elseif ($admin_theme && $key == $admin_theme) {
315 $theme_title = t('!theme (administration theme)', array('!theme' => $theme_title));
316 }
317 $form['regions'][$key] = array(
318 '#type' => 'select',
319 '#title' => $theme_title,
320 '#default_value' => !empty($region) && $region != -1 ? $region : NULL,
321 '#empty_value' => BLOCK_REGION_NONE,
322 '#options' => system_region_list($key, REGIONS_VISIBLE),
323 '#weight' => ($key == $theme_default ? 9 : 10),
324 );
325 }
326 }
327
328 // Visibility settings.
329 $form['visibility_title'] = array(
330 '#type' => 'item',
331 '#title' => t('Visibility settings'),
332 );
333 $form['visibility'] = array(
334 '#type' => 'vertical_tabs',
335 '#attached' => array(
336 'js' => array(drupal_get_path('module', 'block') . '/block.js'),
337 ),
338 );
339
340 // Per-path visibility.
341 $form['visibility']['path'] = array(
342 '#type' => 'fieldset',
343 '#title' => t('Pages'),
344 '#collapsible' => TRUE,
345 '#collapsed' => TRUE,
346 '#group' => 'visibility',
347 '#weight' => 0,
348 );
349
350 $access = user_access('use PHP for settings');
351 if (isset($block->visibility) && $block->visibility == BLOCK_VISIBILITY_PHP && !$access) {
352 $form['visibility']['path']['visibility'] = array(
353 '#type' => 'value',
354 '#value' => BLOCK_VISIBILITY_PHP,
355 );
356 $form['visibility']['path']['pages'] = array(
357 '#type' => 'value',
358 '#value' => isset($block->pages) ? $block->pages : '',
359 );
360 }
361 else {
362 $options = array(
363 BLOCK_VISIBILITY_NOTLISTED => t('All pages except those listed'),
364 BLOCK_VISIBILITY_LISTED => t('Only the listed pages'),
365 );
366 $description = t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>'));
367
368 if (module_exists('php') && $access) {
369 $options += array(BLOCK_VISIBILITY_PHP => t('Pages on which this PHP code returns <code>TRUE</code> (experts only)'));
370 $title = t('Pages or PHP code');
371 $description .= ' ' . t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Drupal site.', array('%php' => '<?php ?>'));
372 }
373 else {
374 $title = t('Pages');
375 }
376 $form['visibility']['path']['visibility'] = array(
377 '#type' => 'radios',
378 '#title' => t('Show block on specific pages'),
379 '#options' => $options,
380 '#default_value' => isset($block->visibility) ? $block->visibility : BLOCK_VISIBILITY_NOTLISTED,
381 );
382 $form['visibility']['path']['pages'] = array(
383 '#type' => 'textarea',
384 '#title' => '<span class="element-invisible">' . $title . '</span>',
385 '#default_value' => isset($block->pages) ? $block->pages : '',
386 '#description' => $description,
387 );
388 }
389
390 // Per-role visibility.
391 $default_role_options = db_query("SELECT rid FROM {block_role} WHERE module = :module AND delta = :delta", array(
392 ':module' => $block->module,
393 ':delta' => $block->delta,
394 ))->fetchCol();
395 $role_options = array_map('check_plain', user_roles());
396 $form['visibility']['role'] = array(
397 '#type' => 'fieldset',
398 '#title' => t('Roles'),
399 '#collapsible' => TRUE,
400 '#collapsed' => TRUE,
401 '#group' => 'visibility',
402 '#weight' => 10,
403 );
404 $form['visibility']['role']['roles'] = array(
405 '#type' => 'checkboxes',
406 '#title' => t('Show block for specific roles'),
407 '#default_value' => $default_role_options,
408 '#options' => $role_options,
409 '#description' => t('Show this block only for the selected role(s). If you select no roles, the block will be visible to all users.'),
410 );
411
412 // Per-user visibility.
413 $form['visibility']['user'] = array(
414 '#type' => 'fieldset',
415 '#title' => t('Users'),
416 '#collapsible' => TRUE,
417 '#collapsed' => TRUE,
418 '#group' => 'visibility',
419 '#weight' => 20,
420 );
421 $form['visibility']['user']['custom'] = array(
422 '#type' => 'radios',
423 '#title' => t('Customizable per user'),
424 '#options' => array(
425 BLOCK_CUSTOM_FIXED => t('Not customizable'),
426 BLOCK_CUSTOM_ENABLED => t('Customizable, visible by default'),
427 BLOCK_CUSTOM_DISABLED => t('Customizable, hidden by default'),
428 ),
429 '#description' => t('Allow individual users to customize the visibility of this block in their account settings.'),
430 '#default_value' => isset($block->custom) ? $block->custom : BLOCK_CUSTOM_FIXED,
431 );
432
433 $form['actions'] = array('#type' => 'actions');
434 $form['actions']['submit'] = array(
435 '#type' => 'submit',
436 '#value' => t('Save block'),
437 );
438
439 return $form;
440 }
441
448 function block_admin_configure_validate($form, &$form_state) {
449 if ($form_state['values']['module'] == 'block') {
450 $custom_block_exists = (bool) db_query_range('SELECT 1 FROM {block_custom} WHERE bid <> :bid AND info = :info', 0, 1, array(
451 ':bid' => $form_state['values']['delta'],
452 ':info' => $form_state['values']['info'],
453 ))->fetchField();
454 if (empty($form_state['values']['info']) || $custom_block_exists) {
455 form_set_error('info', t('Ensure that each block description is unique.'));
456 }
457 }
458 }
459
466 function block_admin_configure_submit($form, &$form_state) {
467 if (!form_get_errors()) {
468 $transaction = db_transaction();
469 try {
470 db_update('block')
471 ->fields(array(
472 'visibility' => (int) $form_state['values']['visibility'],
473 'pages' => trim($form_state['values']['pages']),
474 'custom' => (int) $form_state['values']['custom'],
475 'title' => $form_state['values']['title'],
476 ))
477 ->condition('module', $form_state['values']['module'])
478 ->condition('delta', $form_state['values']['delta'])
479 ->execute();
480
481 db_delete('block_role')
482 ->condition('module', $form_state['values']['module'])
483 ->condition('delta', $form_state['values']['delta'])
484 ->execute();
485 $query = db_insert('block_role')->fields(array('rid', 'module', 'delta'));
486 foreach (array_filter($form_state['values']['roles']) as $rid) {
487 $query->values(array(
488 'rid' => $rid,
489 'module' => $form_state['values']['module'],
490 'delta' => $form_state['values']['delta'],
491 ));
492 }
493 $query->execute();
494
495 // Store regions per theme for this block
496 foreach ($form_state['values']['regions'] as $theme => $region) {
497 db_merge('block')
498 ->key(array('theme' => $theme, 'delta' => $form_state['values']['delta'], 'module' => $form_state['values']['module']))
499 ->fields(array(
500 'region' => ($region == BLOCK_REGION_NONE ? '' : $region),
501 'pages' => trim($form_state['values']['pages']),
502 'status' => (int) ($region != BLOCK_REGION_NONE),
503 ))
504 ->execute();
505 }
506
507 module_invoke($form_state['values']['module'], 'block_save', $form_state['values']['delta'], $form_state['values']);
508 }
509 catch (Exception $e) {
510 $transaction->rollback();
511 watchdog_exception('block', $e);
512 throw $e;
513 }
514 drupal_set_message(t('The block configuration has been saved.'));
515 cache_clear_all();
516 $form_state['redirect'] = 'admin/structure/block';
517 }
518 }
519
527 function block_add_block_form($form, &$form_state) {
528 return block_admin_configure($form, $form_state, 'block', NULL);
529 }
530
537 function block_add_block_form_validate($form, &$form_state) {
538 $custom_block_exists = (bool) db_query_range('SELECT 1 FROM {block_custom} WHERE info = :info', 0, 1, array(':info' => $form_state['values']['info']))->fetchField();
539
540 if (empty($form_state['values']['info']) || $custom_block_exists) {
541 form_set_error('info', t('Ensure that each block description is unique.'));
542 }
543 }
544
553 function block_add_block_form_submit($form, &$form_state) {
554 $delta = db_insert('block_custom')
555 ->fields(array(
556 'body' => $form_state['values']['body']['value'],
557 'info' => $form_state['values']['info'],
558 'format' => $form_state['values']['body']['format'],
559 ))
560 ->execute();
561 // Store block delta to allow other modules to work with new block.
562 $form_state['values']['delta'] = $delta;
563
564 $query = db_insert('block')->fields(array('visibility', 'pages', 'custom', 'title', 'module', 'theme', 'status', 'weight', 'delta', 'cache'));
565 foreach (list_themes() as $key => $theme) {
566 if ($theme->status) {
567 $query->values(array(
568 'visibility' => (int) $form_state['values']['visibility'],
569 'pages' => trim($form_state['values']['pages']),
570 'custom' => (int) $form_state['values']['custom'],
571 'title' => $form_state['values']['title'],
572 'module' => $form_state['values']['module'],
573 'theme' => $theme->name,
574 'status' => 0,
575 'weight' => 0,
576 'delta' => $delta,
577 'cache' => DRUPAL_NO_CACHE,
578 ));
579 }
580 }
581 $query->execute();
582
583 $query = db_insert('block_role')->fields(array('rid', 'module', 'delta'));
584 foreach (array_filter($form_state['values']['roles']) as $rid) {
585 $query->values(array(
586 'rid' => $rid,
587 'module' => $form_state['values']['module'],
588 'delta' => $delta,
589 ));
590 }
591 $query->execute();
592
593 // Store regions per theme for this block
594 foreach ($form_state['values']['regions'] as $theme => $region) {
595 db_merge('block')
596 ->key(array('theme' => $theme, 'delta' => $delta, 'module' => $form_state['values']['module']))
597 ->fields(array(
598 'region' => ($region == BLOCK_REGION_NONE ? '' : $region),
599 'pages' => trim($form_state['values']['pages']),
600 'status' => (int) ($region != BLOCK_REGION_NONE),
601 ))
602 ->execute();
603 }
604
605 drupal_set_message(t('The block has been created.'));
606 cache_clear_all();
607 $form_state['redirect'] = 'admin/structure/block';
608 }
609
621 function block_custom_block_delete($form, &$form_state, $module, $delta) {
622 $block = block_load($module, $delta);
623 $custom_block = block_custom_block_get($block->delta);
624 $form['info'] = array('#type' => 'hidden', '#value' => $custom_block['info'] ? $custom_block['info'] : $custom_block['title']);
625 $form['bid'] = array('#type' => 'hidden', '#value' => $block->delta);
626
627 return confirm_form($form, t('Are you sure you want to delete the block %name?', array('%name' => $custom_block['info'])), 'admin/structure/block', '', t('Delete'), t('Cancel'));
628 }
629
635 function block_custom_block_delete_submit($form, &$form_state) {
636 db_delete('block_custom')
637 ->condition('bid', $form_state['values']['bid'])
638 ->execute();
639 db_delete('block')
640 ->condition('module', 'block')
641 ->condition('delta', $form_state['values']['bid'])
642 ->execute();
643 db_delete('block_role')
644 ->condition('module', 'block')
645 ->condition('delta', $form_state['values']['bid'])
646 ->execute();
647 drupal_set_message(t('The block %name has been removed.', array('%name' => $form_state['values']['info'])));
648 cache_clear_all();
649 $form_state['redirect'] = 'admin/structure/block';
650 return;
651 }
652
662 function template_preprocess_block_admin_display_form(&$variables) {
663 $variables['block_regions'] = $variables['form']['block_regions']['#value'];
664 if (isset($variables['block_regions'][BLOCK_REGION_NONE])) {
665 $variables['block_regions'][BLOCK_REGION_NONE] = t('Disabled');
666 }
667
668 foreach ($variables['block_regions'] as $key => $value) {
669 // Initialize an empty array for the region.
670 $variables['block_listing'][$key] = array();
671 }
672
673 // Initialize disabled blocks array.
674 $variables['block_listing'][BLOCK_REGION_NONE] = array();
675
676 // Add each block in the form to the appropriate place in the block listing.
677 foreach (element_children($variables['form']['blocks']) as $i) {
678 $block = &$variables['form']['blocks'][$i];
679
680 // Fetch the region for the current block.
681 $region = (isset($block['region']['#default_value']) ? $block['region']['#default_value'] : BLOCK_REGION_NONE);
682
683 // Set special classes needed for table drag and drop.
684 $block['region']['#attributes']['class'] = array('block-region-select', 'block-region-' . $region);
685 $block['weight']['#attributes']['class'] = array('block-weight', 'block-weight-' . $region);
686
687 $variables['block_listing'][$region][$i] = new stdClass();
688 $variables['block_listing'][$region][$i]->row_class = !empty($block['#attributes']['class']) ? implode(' ', $block['#attributes']['class']) : '';
689 $variables['block_listing'][$region][$i]->block_modified = !empty($block['#attributes']['class']) && in_array('block-modified', $block['#attributes']['class']);
690 $variables['block_listing'][$region][$i]->block_title = drupal_render($block['info']);
691 $variables['block_listing'][$region][$i]->region_select = drupal_render($block['region']) . drupal_render($block['theme']);
692 $variables['block_listing'][$region][$i]->weight_select = drupal_render($block['weight']);
693 $variables['block_listing'][$region][$i]->configure_link = drupal_render($block['configure']);
694 $variables['block_listing'][$region][$i]->delete_link = !empty($block['delete']) ? drupal_render($block['delete']) : '';
695 $variables['block_listing'][$region][$i]->printed = FALSE;
696 }
697
698 $variables['form_submit'] = drupal_render_children($variables['form']);
699 }
700
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
block_admin_configure_validate
block_admin_configure_validate($form, &$form_state)
Definition: block.admin.inc:448
watchdog_exception
watchdog_exception($type, Exception $exception, $message=NULL, $variables=array(), $severity=WATCHDOG_ERROR, $link=NULL)
Definition: bootstrap.inc:1654
BLOCK_VISIBILITY_LISTED
const BLOCK_VISIBILITY_LISTED
Definition: block.module:36
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
block_custom_block_delete_submit
block_custom_block_delete_submit($form, &$form_state)
Definition: block.admin.inc:635
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
block_load
block_load($module, $delta)
Definition: block.module:704
$module
print $module
Definition: search-results.tpl.php:28
block_admin_demo
block_admin_demo($theme=NULL)
Definition: block.admin.inc:11
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
block_custom_block_get
block_custom_block_get($bid)
Definition: block.module:501
BLOCK_VISIBILITY_PHP
const BLOCK_VISIBILITY_PHP
Definition: block.module:41
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
template_preprocess_block_admin_display_form
template_preprocess_block_admin_display_form(&$variables)
Definition: block.admin.inc:662
Exception
block_admin_display_form
block_admin_display_form($form, &$form_state, $blocks, $theme, $block_regions=NULL)
Definition: block.admin.inc:78
user_roles
user_roles($membersonly=FALSE, $permission=NULL)
Definition: user.module:2871
module_exists
module_exists($module)
Definition: module.inc:274
_block_compare
_block_compare($a, $b)
Definition: block.admin.inc:204
block_add_block_form_submit
block_add_block_form_submit($form, &$form_state)
Definition: block.admin.inc:553
block_admin_display
block_admin_display($theme=NULL)
Definition: block.admin.inc:23
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
block_admin_display_form_submit
block_admin_display_form_submit($form, &$form_state)
Definition: block.admin.inc:172
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
block_add_block_form
block_add_block_form($form, &$form_state)
Definition: block.admin.inc:527
_block_rehash
_block_rehash($theme=NULL)
Definition: block.module:369
$info
$info
Definition: color.inc:6
block_admin_configure
block_admin_configure($form, &$form_state, $module, $delta)
Definition: block.admin.inc:255
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
system_region_list
system_region_list($theme_key, $show=REGIONS_ALL)
Definition: system.module:2689
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
form_get_errors
form_get_errors()
Definition: form.inc:1634
block_admin_display_prepare_blocks
block_admin_display_prepare_blocks($theme)
Definition: block.admin.inc:51
drupal_theme_initialize
drupal_theme_initialize()
Definition: theme.inc:70
block_custom_block_delete
block_custom_block_delete($form, &$form_state, $module, $delta)
Definition: block.admin.inc:621
BLOCK_CUSTOM_DISABLED
const BLOCK_CUSTOM_DISABLED
Definition: block.module:26
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
BLOCK_VISIBILITY_NOTLISTED
const BLOCK_VISIBILITY_NOTLISTED
Definition: block.module:31
db_transaction
db_transaction($name=NULL, array $options=array())
Definition: database.inc:2535
BLOCK_CUSTOM_FIXED
const BLOCK_CUSTOM_FIXED
Definition: block.module:16
DRUPAL_NO_CACHE
const DRUPAL_NO_CACHE
Definition: common.inc:127
BLOCK_REGION_NONE
const BLOCK_REGION_NONE
Definition: block.module:11
block_admin_configure_submit
block_admin_configure_submit($form, &$form_state)
Definition: block.admin.inc:466
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
list_themes
list_themes($refresh=FALSE)
Definition: theme.inc:774
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
REGIONS_VISIBLE
const REGIONS_VISIBLE
Definition: system.module:60
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
block_add_block_form_validate
block_add_block_form_validate($form, &$form_state)
Definition: block.admin.inc:537
BLOCK_CUSTOM_ENABLED
const BLOCK_CUSTOM_ENABLED
Definition: block.module:21
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.install Source File

  • modules
  • update
update.install
Go to the documentation of this file.
1 <?php
2
28 function update_requirements($phase) {
29 $requirements = array();
30 if ($phase == 'runtime') {
31 if ($available = update_get_available(FALSE)) {
32 module_load_include('inc', 'update', 'update.compare');
33 $data = update_calculate_project_data($available);
34 // First, populate the requirements for core:
35 $requirements['update_core'] = _update_requirement_check($data['drupal'], 'core');
36 // We don't want to check drupal a second time.
37 unset($data['drupal']);
38 if (!empty($data)) {
39 // Now, sort our $data array based on each project's status. The
40 // status constants are numbered in the right order of precedence, so
41 // we just need to make sure the projects are sorted in ascending
42 // order of status, and we can look at the first project we find.
43 uasort($data, '_update_project_status_sort');
44 $first_project = reset($data);
45 $requirements['update_contrib'] = _update_requirement_check($first_project, 'contrib');
46 }
47 }
48 else {
49 $requirements['update_core']['title'] = t('Drupal core update status');
50 $requirements['update_core']['value'] = t('No update data available');
51 $requirements['update_core']['severity'] = REQUIREMENT_WARNING;
52 $requirements['update_core']['reason'] = UPDATE_UNKNOWN;
53 $requirements['update_core']['description'] = _update_no_data();
54 }
55 }
56 return $requirements;
57 }
58
62 function update_schema() {
63 $schema['cache_update'] = drupal_get_schema_unprocessed('system', 'cache');
64 $schema['cache_update']['description'] = 'Cache table for the Update module to store information about available releases, fetched from central server.';
65 return $schema;
66 }
67
71 function update_install() {
72 $queue = DrupalQueue::get('update_fetch_tasks', TRUE);
73 $queue->createQueue();
74 }
75
79 function update_uninstall() {
80 // Clear any variables that might be in use
81 $variables = array(
82 'update_check_frequency',
83 'update_fetch_url',
84 'update_last_check',
85 'update_last_email_notification',
86 'update_notification_threshold',
87 'update_notify_emails',
88 'update_max_fetch_attempts',
89 'update_max_fetch_time',
90 );
91 foreach ($variables as $variable) {
92 variable_del($variable);
93 }
94 $queue = DrupalQueue::get('update_fetch_tasks');
95 $queue->deleteQueue();
96 }
97
117 function _update_requirement_check($project, $type) {
118 $requirement = array();
119 if ($type == 'core') {
120 $requirement['title'] = t('Drupal core update status');
121 }
122 else {
123 $requirement['title'] = t('Module and theme update status');
124 }
125 $status = $project['status'];
126 if ($status != UPDATE_CURRENT) {
127 $requirement['reason'] = $status;
128 $requirement['description'] = _update_message_text($type, $status, TRUE);
129 $requirement['severity'] = REQUIREMENT_ERROR;
130 }
131 switch ($status) {
132 case UPDATE_NOT_SECURE:
133 $requirement_label = t('Not secure!');
134 break;
135 case UPDATE_REVOKED:
136 $requirement_label = t('Revoked!');
137 break;
138 case UPDATE_NOT_SUPPORTED:
139 $requirement_label = t('Unsupported release');
140 break;
141 case UPDATE_NOT_CURRENT:
142 $requirement_label = t('Out of date');
143 $requirement['severity'] = REQUIREMENT_WARNING;
144 break;
145 case UPDATE_UNKNOWN:
146 case UPDATE_NOT_CHECKED:
147 case UPDATE_NOT_FETCHED:
148 $requirement_label = isset($project['reason']) ? $project['reason'] : t('Can not determine status');
149 $requirement['severity'] = REQUIREMENT_WARNING;
150 break;
151 default:
152 $requirement_label = t('Up to date');
153 }
154 if ($status != UPDATE_CURRENT && $type == 'core' && isset($project['recommended'])) {
155 $requirement_label .= ' ' . t('(version @version available)', array('@version' => $project['recommended']));
156 }
157 $requirement['value'] = l($requirement_label, update_manager_access() ? 'admin/reports/updates/update' : 'admin/reports/updates');
158 return $requirement;
159 }
160
169 function update_update_7000() {
170 module_load_include('inc', 'system', 'system.queue');
171 $queue = DrupalQueue::get('update_fetch_tasks');
172 $queue->createQueue();
173 }
174
181 function update_update_7001() {
182 $schema = system_schema_cache_7054();
183
184 db_drop_table('cache_update');
185 db_create_table('cache_update', $schema);
186 }
187
update_install
update_install()
Definition: update.install:71
UPDATE_NOT_CURRENT
const UPDATE_NOT_CURRENT
Definition: update.module:39
update_update_7001
update_update_7001()
Definition: update.install:181
l
l($text, $path, array $options=array())
Definition: common.inc:2432
DrupalQueue\get
static get($name, $reliable=FALSE)
Definition: system.queue.inc:81
variable_del
variable_del($name)
Definition: bootstrap.inc:996
update_requirements
update_requirements($phase)
Definition: update.install:28
update_calculate_project_data
update_calculate_project_data($available)
Definition: update.compare.inc:335
_update_requirement_check
_update_requirement_check($project, $type)
Definition: update.install:117
UPDATE_UNKNOWN
const UPDATE_UNKNOWN
Definition: update.module:54
_update_no_data
_update_no_data()
Definition: update.module:365
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
UPDATE_REVOKED
const UPDATE_REVOKED
Definition: update.module:29
REQUIREMENT_WARNING
const REQUIREMENT_WARNING
Definition: install.inc:31
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
drupal_get_schema_unprocessed
drupal_get_schema_unprocessed($module, $table=NULL)
Definition: common.inc:6998
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
UPDATE_NOT_CHECKED
const UPDATE_NOT_CHECKED
Definition: update.module:49
update_uninstall
update_uninstall()
Definition: update.install:79
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
update_manager_access
update_manager_access()
Definition: update.module:263
UPDATE_CURRENT
const UPDATE_CURRENT
Definition: update.module:44
UPDATE_NOT_FETCHED
const UPDATE_NOT_FETCHED
Definition: update.module:59
update_update_7000
update_update_7000()
Definition: update.install:169
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
UPDATE_NOT_SUPPORTED
const UPDATE_NOT_SUPPORTED
Definition: update.module:34
update_schema
update_schema()
Definition: update.install:62
update_get_available
update_get_available($refresh=FALSE)
Definition: update.module:394
_update_message_text
_update_message_text($msg_type, $msg_reason, $report_link=FALSE, $language=NULL)
Definition: update.module:562
system_schema_cache_7054
system_schema_cache_7054()
Definition: system.install:1660
UPDATE_NOT_SECURE
const UPDATE_NOT_SECURE
Definition: update.module:24
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/node_access_example/node_access_example.module Source File

  • examples
  • node_access_example
node_access_example.module
Go to the documentation of this file.
1 <?php
2
97 function node_access_example_menu() {
98 $items['examples/node_access'] = array(
99 'title' => 'Node Access Example',
100 'page callback' => 'node_access_example_private_node_listing',
101 'access callback' => TRUE,
102 );
103 return $items;
104 }
105
120 function node_access_example_private_node_listing() {
121 $content = '<div>' . t('This example shows how a module can use the Drupal node access system to allow access to specific nodes. You will need to look at the code and then experiment with it by creating nodes, marking them private, and accessing them as various users.') . '</div>';
122
123 // Find out how many nodes are marked private.
124 $query = db_select('node', 'n');
125 $query->addExpression('COUNT(n.nid)', 'private_count');
126 $query->join('node_access_example', 'nae', 'nae.nid = n.nid');
127 $num_private = $query
128 ->condition('nae.private', 1)->execute()->fetchField();
129
130 // Find out how many nodes owned by this user are marked private.
131 $query = db_select('node', 'n');
132 $query->addExpression('COUNT(n.nid)', 'private_count');
133 $query->join('node_access_example', 'nae', 'nae.nid = n.nid');
134 $num_personal = $query
135 ->condition('n.uid', $GLOBALS['user']->uid)
136 ->condition('nae.private', 1)
137 ->execute()->fetchfield();
138
139 $content .= '<div>' . t('There are currently @num private nodes in the system @num_personal are yours.', array('@num' => $num_private, '@num_personal' => $num_personal)) . '</div>';
140
141 // Use a 'node_access' tag with a query to find out how many this user has
142 // access to. This will be the standard way to make lists while respecting
143 // node access restrictions.
144 $query = db_select('node', 'n');
145 $query->addExpression('COUNT(n.nid)', 'private_count');
146 $query->addTag('node_access');
147 $query->join('node_access_example', 'nae', 'nae.nid = n.nid');
148 $num_private_accessible = $query->condition('nae.private', 1)->execute()->fetchField();
149 $content .= '<div>' . t('You have access to @num private nodes.', array('@num' => $num_private_accessible)) . '</div>';
150
151 // Use the key 'node_access' tag to get the key data from the nodes this
152 // has access to.
153 $query = db_select('node', 'n', array('fetch' => PDO::FETCH_ASSOC));
154 $query->addTag('node_access');
155 $query->join('node_access_example', 'nae', 'nae.nid = n.nid');
156 $query->join('users', 'u', 'u.uid = n.uid');
157 $result = $query->fields('n', array('nid', 'title', 'uid'))
158 ->fields('u', array('name'))
159 ->condition('nae.private', 1)->execute();
160
161 $rows = array();
162 foreach ($result as $node) {
163 $node['nid'] = l($node['nid'], 'node/' . $node['nid']);
164 $rows[] = array('data' => $node, 'class' => array('accessible'));
165 }
166 $content .= '<div>' . t('Accessible rows:') . theme('table', array('header' => array('nid', 'title', 'uid', 'username'), 'rows' => $rows)) . '</div>';
167
168 return array('#markup' => $content);
169 }
170
188 function node_access_example_permission() {
189 return array(
190 'access any private content' => array(
191 'title' => t('Access any private content'),
192 'description' => t('May view posts of other users even though they are marked private.'),
193 ),
194 'edit any private content' => array(
195 'title' => t('Edit any private content'),
196 'description' => t('May edit posts of other users even though they are marked private.'),
197 ),
198 );
199 }
200
212 function node_access_example_node_access($node, $op, $account) {
213 // If $node is a string, the node has not yet been created. We don't care
214 // about that case.
215 if (is_string($node)) {
216 return NODE_ACCESS_IGNORE;
217 }
218 if (($op == 'view' || $op == 'update') && (!empty($account->name) && $account->name == 'foobar') && !empty($node->private)) {
219 drupal_set_message(t('Access to node @nid allowed because requester name (@name) is specifically allowed', array('@name' => $node->name, '@uid' => $account->uid)));
220 return NODE_ACCESS_ALLOW;
221 }
222 return NODE_ACCESS_IGNORE;
223 }
224
231 define('NODE_ACCESS_EXAMPLE_GRANT_ALL', 23);
232
267 function node_access_example_node_grants($account, $op) {
268 // First grant a grant to the author for own content.
269 $grants['node_access_example_author'] = array($account->uid);
270
271 // Then, if "access any private content" is allowed to the account,
272 // grant view, update, or delete as necessary.
273 if ($op == 'view' && user_access('access any private content', $account)) {
274 $grants['node_access_example_view'] = array(NODE_ACCESS_EXAMPLE_GRANT_ALL);
275 }
276
277 if (($op == 'update' || $op == 'delete') && user_access('edit any private content', $account)) {
278 $grants['node_access_example_edit'] = array(NODE_ACCESS_EXAMPLE_GRANT_ALL);
279 }
280
281 return $grants;
282 }
283
321 function node_access_example_node_access_records($node) {
322 // We only care about the node if it's been marked private. If not, it is
323 // treated just like any other node and we completely ignore it.
324 if (!empty($node->private)) {
325 $grants = array();
326 $grants[] = array(
327 'realm' => 'node_access_example_view',
328 'gid' => NODE_ACCESS_EXAMPLE_GRANT_ALL,
329 'grant_view' => 1,
330 'grant_update' => 0,
331 'grant_delete' => 0,
332 'priority' => 0,
333 );
334 $grants[] = array(
335 'realm' => 'node_access_example_edit',
336 'gid' => NODE_ACCESS_EXAMPLE_GRANT_ALL,
337 'grant_view' => 1,
338 'grant_update' => 1,
339 'grant_delete' => 1,
340 'priority' => 0,
341 );
342
343 // For the node_access_example_author realm, the grant ID (gid) is
344 // equivalent to the node author's user ID (UID).
345 $grants[] = array(
346 'realm' => 'node_access_example_author',
347 'gid' => $node->uid,
348 'grant_view' => 1,
349 'grant_update' => 1,
350 'grant_delete' => 1,
351 'priority' => 0,
352 );
353 return $grants;
354 }
355 // Return nothing if the node has not been marked private.
356 }
357
365 function node_access_example_form_alter(&$form, $form_state) {
366 if (!empty($form['#node_edit_form'])) {
367 $form['node_access_example'] = array(
368 '#type' => 'fieldset',
369 '#title' => t('Node Access Example'),
370 '#collapsible' => TRUE,
371 '#collapsed' => FALSE,
372 '#weight' => 8,
373 );
374
375 $form['node_access_example']['private'] = array(
376 '#type' => 'checkbox',
377 '#title' => t('Private'),
378 '#description' => t('Check here if this content should be set private and only shown to privileged users.'),
379 '#default_value' => isset($form['#node']->private) ? $form['#node']->private : FALSE,
380 );
381 }
382 }
383
390 function node_access_example_node_load($nodes, $types) {
391 $result = db_query('SELECT nid, private FROM {node_access_example} WHERE nid IN(:nids)', array(':nids' => array_keys($nodes)));
392 foreach ($result as $record) {
393 $nodes[$record->nid]->private = $record->private;
394 }
395 }
396
403 function node_access_example_node_delete($node) {
404 db_delete('node_access_example')->condition('nid', $node->nid)->execute();
405 }
406
413 function node_access_example_node_insert($node) {
414 if (isset($node->private)) {
415 db_insert('node_access_example')->fields(array('nid' => $node->nid, 'private' => (int)$node->private))->execute();
416 }
417 drupal_set_message(t('New node @nid was created and private=@private', array('@nid' => $node->nid, '@private' => !empty($node->private) ? 1 : 0)));
418 }
419
427 function node_access_example_node_update($node) {
428 // Find out if there is already a node_access_example record.
429 $exists = db_query('SELECT nid FROM {node_access_example} WHERE nid = :nid', array(':nid' => $node->nid))->fetchField();
430
431 // If there is already a record, update it with the new private value.
432 if ($exists) {
433 $num_updated = db_update('node_access_example')
434 ->fields(array(
435 'nid' => $node->nid,
436 'private' => !empty($node->private) ? 1 : 0,
437 ))
438 ->condition('nid', $node->nid)
439 ->execute();
440 drupal_set_message(t("Updated node @nid to set private=@private (@num nodes actually updated)", array('@private' => $node->private, '@num' => $num_updated, '@nid' => $node->nid)));
441 }
442 // Otherwise, create a new record.
443 else {
444 node_access_example_node_insert($node);
445 drupal_set_message(t('Inserted new node_access nid=@nid, private=@private', array('@nid' => $node->nid, '@private' => $node->private)));
446 }
447 }
448
$op
$op
Definition: update.php:404
l
l($text, $path, array $options=array())
Definition: common.inc:2432
NODE_ACCESS_ALLOW
const NODE_ACCESS_ALLOW
Definition: node.module:50
node_access_example_node_update
node_access_example_node_update($node)
Definition: node_access_example.module:427
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
node_access_example_node_access
node_access_example_node_access($node, $op, $account)
Definition: node_access_example.module:212
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
node_access_example_private_node_listing
node_access_example_private_node_listing()
Definition: node_access_example.module:120
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
user_access
user_access($string, $account=NULL)
Definition: user.module:794
node_access_example_node_load
node_access_example_node_load($nodes, $types)
Definition: node_access_example.module:390
node_access_example_form_alter
node_access_example_form_alter(&$form, $form_state)
Definition: node_access_example.module:365
node_access_example_node_grants
node_access_example_node_grants($account, $op)
Definition: node_access_example.module:267
node_access_example_node_insert
node_access_example_node_insert($node)
Definition: node_access_example.module:413
node_access_example_node_access_records
node_access_example_node_access_records($node)
Definition: node_access_example.module:321
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
NODE_ACCESS_EXAMPLE_GRANT_ALL
const NODE_ACCESS_EXAMPLE_GRANT_ALL
Definition: node_access_example.module:231
NODE_ACCESS_IGNORE
const NODE_ACCESS_IGNORE
Definition: node.module:60
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
node_access_example_node_delete
node_access_example_node_delete($node)
Definition: node_access_example.module:403
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
node_access_example_menu
node_access_example_menu()
Definition: node_access_example.module:97
node_access_example_permission
node_access_example_permission()
Definition: node_access_example.module:188
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile/profile.admin.inc Source File

  • modules
  • profile
profile.admin.inc
Go to the documentation of this file.
1 <?php
2
14 function profile_admin_overview($form) {
15 $result = db_query('SELECT title, name, type, category, fid, weight FROM {profile_field} ORDER BY category, weight');
16
17 $categories = array();
18 foreach ($result as $field) {
19 // Collect all category information
20 $categories[] = $field->category;
21
22 // Save all field information
23 $form[$field->fid]['name'] = array('#markup' => check_plain($field->name));
24 $form[$field->fid]['title'] = array('#markup' => check_plain($field->title));
25 $form[$field->fid]['type'] = array('#markup' => $field->type);
26 $form[$field->fid]['category'] = array(
27 '#type' => 'select',
28 '#title' => t('Category for @title', array('@title' => $field->title)),
29 '#title_display' => 'invisible',
30 '#default_value' => $field->category,
31 '#options' => array(),
32 );
33 $form[$field->fid]['weight'] = array(
34 '#type' => 'weight',
35 '#title' => t('Weight for @title', array('@title' => $field->title)),
36 '#title_display' => 'invisible',
37 '#default_value' => $field->weight,
38 );
39 $form[$field->fid]['edit'] = array('#type' => 'link', '#title' => t('edit'), '#href' => "admin/config/people/profile/edit/$field->fid");
40 $form[$field->fid]['delete'] = array('#type' => 'link', '#title' => t('delete'), '#href' => "admin/config/people/profile/delete/$field->fid");
41 }
42
43 // Add the category combo boxes
44 $categories = array_unique($categories);
45 foreach ($form as $fid => $field) {
46 foreach ($categories as $cat => $category) {
47 $form[$fid]['category']['#options'][$category] = $category;
48 }
49 }
50
51 // Display the submit button only when there's more than one field
52 if (count($form) > 1) {
53 $form['actions'] = array('#type' => 'actions');
54 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
55 }
56 else {
57 // Disable combo boxes when there isn't a submit button
58 foreach ($form as $fid => $field) {
59 unset($form[$fid]['weight']);
60 $form[$fid]['category']['#type'] = 'value';
61 }
62 }
63 $form['#tree'] = TRUE;
64
65 // @todo: Any reason this isn't done using an element with #theme = 'links'?
66 $addnewfields = '<h2>' . t('Add new field') . '</h2>';
67 $addnewfields .= '<ul>';
68 foreach (_profile_field_types() as $key => $value) {
69 $addnewfields .= '<li>' . l($value, "admin/config/people/profile/add/$key") . '</li>';
70 }
71 $addnewfields .= '</ul>';
72 $form['addnewfields'] = array('#markup' => $addnewfields);
73
74 return $form;
75 }
76
82 function profile_admin_overview_submit($form, &$form_state) {
83 foreach (element_children($form_state['values']) as $fid) {
84 if (is_numeric($fid)) {
85 $weight = $form_state['values'][$fid]['weight'];
86 $category = $form_state['values'][$fid]['category'];
87 if ($weight != $form[$fid]['weight']['#default_value'] || $category != $form[$fid]['category']['#default_value']) {
88 db_update('profile_field')
89 ->fields(array(
90 'weight' => $weight,
91 'category' => $category,
92 ))
93 ->condition('fid', $fid)
94 ->execute();
95 }
96 }
97 }
98
99 drupal_set_message(t('Profile fields have been updated.'));
100 cache_clear_all();
101 menu_rebuild();
102 }
103
114 function theme_profile_admin_overview($variables) {
115 $form = $variables['form'];
116
117 drupal_add_css(drupal_get_path('module', 'profile') . '/profile.css');
118 // Add javascript if there's more than one field.
119 if (isset($form['actions'])) {
120 drupal_add_js(drupal_get_path('module', 'profile') . '/profile.js');
121 }
122
123 $rows = array();
124 $categories = array();
125 $category_number = 0;
126 foreach (element_children($form) as $key) {
127 // Don't take form control structures.
128 if (isset($form[$key]['category'])) {
129 $field = &$form[$key];
130 $category = $field['category']['#default_value'];
131
132 if (!isset($categories[$category])) {
133 // Category classes are given numeric IDs because there's no guarantee
134 // class names won't contain invalid characters.
135 $categories[$category] = $category_number;
136 $category_field['#attributes']['class'] = array('profile-category', 'profile-category-' . $category_number);
137 $rows[] = array(array('data' => check_plain($category), 'colspan' => 7, 'class' => array('category')));
138 $rows[] = array('data' => array(array('data' => '<em>' . t('No fields in this category. If this category remains empty when saved, it will be removed.') . '</em>', 'colspan' => 7)), 'class' => array('category-' . $category_number . '-message', 'category-message', 'category-populated'));
139
140 // Make it draggable only if there is more than one field
141 if (isset($form['actions'])) {
142 drupal_add_tabledrag('profile-fields', 'order', 'sibling', 'profile-weight', 'profile-weight-' . $category_number);
143 drupal_add_tabledrag('profile-fields', 'match', 'sibling', 'profile-category', 'profile-category-' . $category_number);
144 }
145 $category_number++;
146 }
147
148 // Add special drag and drop classes that group fields together.
149 $field['weight']['#attributes']['class'] = array('profile-weight', 'profile-weight-' . $categories[$category]);
150 $field['category']['#attributes']['class'] = array('profile-category', 'profile-category-' . $categories[$category]);
151
152 // Add the row
153 $row = array();
154 $row[] = drupal_render($field['title']);
155 $row[] = drupal_render($field['name']);
156 $row[] = drupal_render($field['type']);
157 if (isset($form['actions'])) {
158 $row[] = drupal_render($field['category']);
159 $row[] = drupal_render($field['weight']);
160 }
161 $row[] = drupal_render($field['edit']);
162 $row[] = drupal_render($field['delete']);
163 $rows[] = array('data' => $row, 'class' => array('draggable'));
164 }
165 }
166
167 $header = array(t('Title'), t('Name'), t('Type'));
168 if (isset($form['actions'])) {
169 $header[] = t('Category');
170 $header[] = t('Weight');
171 }
172 $header[] = array('data' => t('Operations'), 'colspan' => 2);
173
174 $output = theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No fields available.'), 'attributes' => array('id' => 'profile-fields')));
175 $output .= drupal_render_children($form);
176
177 return $output;
178 }
179
187 function profile_field_form($form, &$form_state, $arg = NULL) {
188 if (arg(4) == 'edit') {
189 if (is_numeric($arg)) {
190 $fid = $arg;
191
192 $edit = db_query('SELECT * FROM {profile_field} WHERE fid = :fid', array('fid' => $fid))->fetchAssoc();
193
194 if (!$edit) {
195 drupal_not_found();
196 return;
197 }
198 drupal_set_title(t('Edit %title', array('%title' => $edit['title'])), PASS_THROUGH);
199 $form['fid'] = array('#type' => 'value',
200 '#value' => $fid,
201 );
202 $type = $edit['type'];
203 }
204 else {
205 drupal_not_found();
206 return;
207 }
208 }
209 else {
210 $types = _profile_field_types();
211 if (!isset($types[$arg])) {
212 drupal_not_found();
213 return;
214 }
215 $type = $arg;
216 drupal_set_title(t('Add new %type', array('%type' => $types[$type])), PASS_THROUGH);
217 $edit = array('name' => 'profile_');
218 $form['type'] = array('#type' => 'value', '#value' => $type);
219 }
220 $edit += array(
221 'category' => '',
222 'title' => '',
223 'explanation' => '',
224 'weight' => 0,
225 'page' => '',
226 'autocomplete' => '',
227 'required' => '',
228 'register' => '',
229 );
230 $form['category'] = array('#type' => 'textfield',
231 '#title' => t('Category'),
232 '#default_value' => $edit['category'],
233 '#autocomplete_path' => 'admin/config/people/profile/autocomplete',
234 '#description' => t('The category the new field should be part of. Categories are used to group fields logically. An example category is "Personal information".'),
235 '#required' => TRUE,
236 );
237 $form['title'] = array('#type' => 'textfield',
238 '#title' => t('Title'),
239 '#default_value' => $edit['title'],
240 '#description' => t('The title of the new field. The title will be shown to the user. An example title is "Favorite color".'),
241 '#required' => TRUE,
242 );
243 $form['name'] = array('#type' => 'textfield',
244 '#title' => t('Form name'),
245 '#default_value' => $edit['name'],
246 '#description' => t('The name of the field. The form name is not shown to the user but used internally in the HTML code and URLs.
247 Unless you know what you are doing, it is highly recommended that you prefix the form name with <code>profile_</code> to avoid name clashes with other fields. Spaces or any other special characters except dash (-) and underscore (_) are not allowed. An example name is "profile_favorite_color" or perhaps just "profile_color".'),
248 '#required' => TRUE,
249 );
250 $form['explanation'] = array('#type' => 'textarea',
251 '#title' => t('Explanation'),
252 '#default_value' => $edit['explanation'],
253 '#description' => t('An optional explanation to go with the new field. The explanation will be shown to the user.'),
254 );
255 if ($type == 'selection') {
256 $form['fields']['options'] = array('#type' => 'textarea',
257 '#title' => t('Selection options'),
258 '#default_value' => isset($edit['options']) ? $edit['options'] : '',
259 '#description' => t('A list of all options. Put each option on a separate line. Example options are "red", "blue", "green", etc.'),
260 );
261 }
262 $form['visibility'] = array('#type' => 'radios',
263 '#title' => t('Visibility'),
264 '#default_value' => isset($edit['visibility']) ? $edit['visibility'] : PROFILE_PUBLIC,
265 '#options' => array(PROFILE_HIDDEN => t('Hidden profile field, only accessible by administrators, modules and themes.'), PROFILE_PRIVATE => t('Private field, content only available to privileged users.'), PROFILE_PUBLIC => t('Public field, content shown on profile page but not used on member list pages.'), PROFILE_PUBLIC_LISTINGS => t('Public field, content shown on profile page and on member list pages.')),
266 );
267 if ($type == 'selection' || $type == 'list' || $type == 'textfield') {
268 $form['fields']['page'] = array('#type' => 'textfield',
269 '#title' => t('Page title'),
270 '#default_value' => $edit['page'],
271 '#description' => t('To enable browsing this field by value, enter a title for the resulting page. The word <code>%value</code> will be substituted with the corresponding value. An example page title is "People whose favorite color is %value" . This is only applicable for a public field.'),
272 );
273 }
274 elseif ($type == 'checkbox') {
275 $form['fields']['page'] = array('#type' => 'textfield',
276 '#title' => t('Page title'),
277 '#default_value' => $edit['page'],
278 '#description' => t('To enable browsing this field by value, enter a title for the resulting page. An example page title is "People who are employed" . This is only applicable for a public field.'),
279 );
280 }
281 $form['weight'] = array('#type' => 'weight',
282 '#title' => t('Weight'),
283 '#default_value' => $edit['weight'],
284 '#description' => t('The weights define the order in which the form fields are shown. Lighter fields "float up" towards the top of the category.'),
285 );
286 $form['autocomplete'] = array('#type' => 'checkbox',
287 '#title' => t('Form will auto-complete while user is typing.'),
288 '#default_value' => $edit['autocomplete'],
289 '#description' => t('For security, auto-complete will be disabled if the user does not have access to user profiles.'),
290 );
291 $form['required'] = array('#type' => 'checkbox',
292 '#title' => t('The user must enter a value.'),
293 '#default_value' => $edit['required'],
294 );
295 $form['register'] = array('#type' => 'checkbox',
296 '#title' => t('Visible in user registration form.'),
297 '#default_value' => $edit['register'],
298 );
299
300 $form['actions'] = array('#type' => 'actions');
301 $form['actions']['submit'] = array('#type' => 'submit',
302 '#value' => t('Save field'),
303 );
304 return $form;
305 }
306
310 function profile_field_form_validate($form, &$form_state) {
311 // Validate the 'field name':
312 if (preg_match('/[^a-zA-Z0-9_-]/', $form_state['values']['name'])) {
313 form_set_error('name', t('The specified form name contains one or more illegal characters. Spaces or any other special characters except dash (-) and underscore (_) are not allowed.'));
314 }
315
316 $users_table = drupal_get_schema('users');
317 if (!empty($users_table['fields'][$form_state['values']['name']])) {
318 form_set_error('name', t('The specified form name is reserved for use by Drupal.'));
319 }
320 // Validate the category:
321 if (!$form_state['values']['category']) {
322 form_set_error('category', t('You must enter a category.'));
323 }
324 if (strtolower($form_state['values']['category']) == 'account') {
325 form_set_error('category', t('The specified category name is reserved for use by Drupal.'));
326 }
327 $query = db_select('profile_field');
328 $query->fields('profile_field', array('fid'));
329
330 if (isset($form_state['values']['fid'])) {
331 $query->condition('fid', $form_state['values']['fid'], '<>');
332 }
333 $query_name = clone $query;
334
335 $title = $query
336 ->condition('title', $form_state['values']['title'])
337 ->condition('category', $form_state['values']['category'])
338 ->execute()
339 ->fetchField();
340 if ($title) {
341 form_set_error('title', t('The specified title is already in use.'));
342 }
343 $name = $query_name
344 ->condition('name', $form_state['values']['name'])
345 ->execute()
346 ->fetchField();
347 if ($name) {
348 form_set_error('name', t('The specified name is already in use.'));
349 }
350 if ($form_state['values']['visibility'] == PROFILE_HIDDEN) {
351 if ($form_state['values']['required']) {
352 form_set_error('required', t('A hidden field cannot be required.'));
353 }
354 if ($form_state['values']['register']) {
355 form_set_error('register', t('A hidden field cannot be set to visible on the user registration form.'));
356 }
357 }
358 }
359
363 function profile_field_form_submit($form, &$form_state) {
364 if (!isset($form_state['values']['options'])) {
365 $form_state['values']['options'] = '';
366 }
367 if (!isset($form_state['values']['page'])) {
368 $form_state['values']['page'] = '';
369 }
370 // Remove all elements that are not profile_field columns.
371 $values = array_intersect_key($form_state['values'], array_flip(array('type', 'category', 'title', 'name', 'explanation', 'visibility', 'page', 'weight', 'autocomplete', 'required', 'register', 'options')));
372 if (!isset($form_state['values']['fid'])) {
373 db_insert('profile_field')
374 ->fields($values)
375 ->execute();
376 drupal_set_message(t('The field has been created.'));
377 watchdog('profile', 'Profile field %field added under category %category.', array('%field' => $form_state['values']['title'], '%category' => $form_state['values']['category']), WATCHDOG_NOTICE, l(t('view'), 'admin/config/people/profile'));
378 }
379 else {
380 db_update('profile_field')
381 ->fields($values)
382 ->condition('fid', $form_state['values']['fid'])
383 ->execute();
384 drupal_set_message(t('The field has been updated.'));
385 }
386 cache_clear_all();
387 menu_rebuild();
388
389 $form_state['redirect'] = 'admin/config/people/profile';
390 return;
391 }
392
396 function profile_field_delete($form, &$form_state, $fid) {
397 $field = db_query("SELECT title FROM {profile_field} WHERE fid = :fid", array(':fid' => $fid))->fetchObject();
398 if (!$field) {
399 drupal_not_found();
400 return;
401 }
402 $form['fid'] = array('#type' => 'value', '#value' => $fid);
403 $form['title'] = array('#type' => 'value', '#value' => $field->title);
404
405 return confirm_form($form,
406 t('Are you sure you want to delete the field %field?', array('%field' => $field->title)), 'admin/config/people/profile',
407 t('This action cannot be undone. If users have entered values into this field in their profile, these entries will also be deleted. If you want to keep the user-entered data, instead of deleting the field you may wish to <a href="@edit-field">edit this field</a> and change it to a hidden profile field so that it may only be accessed by administrators.', array('@edit-field' => url('admin/config/people/profile/edit/' . $fid))),
408 t('Delete'), t('Cancel'));
409 }
410
414 function profile_field_delete_submit($form, &$form_state) {
415 db_delete('profile_field')
416 ->condition('fid', $form_state['values']['fid'])
417 ->execute();
418 db_delete('profile_value')
419 ->condition('fid', $form_state['values']['fid'])
420 ->execute();
421
422 cache_clear_all();
423
424 drupal_set_message(t('The field %field has been deleted.', array('%field' => $form_state['values']['title'])));
425 watchdog('profile', 'Profile field %field deleted.', array('%field' => $form_state['values']['title']), WATCHDOG_NOTICE, l(t('view'), 'admin/config/people/profile'));
426
427 $form_state['redirect'] = 'admin/config/people/profile';
428 return;
429 }
430
434 function profile_admin_settings_autocomplete($string) {
435 $matches = array();
436 $result = db_select('profile_field')
437 ->fields('profile_field', array('category'))
438 ->condition('category', db_like($string) . '%', 'LIKE')
439 ->range(0, 10)
440 ->execute();
441
442 foreach ($result as $data) {
443 $matches[$data->category] = check_plain($data->category);
444 }
445 drupal_json_output($matches);
446 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
profile_field_delete_submit
profile_field_delete_submit($form, &$form_state)
Definition: profile.admin.inc:414
PROFILE_PUBLIC_LISTINGS
const PROFILE_PUBLIC_LISTINGS
Definition: profile.module:21
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
profile_admin_settings_autocomplete
profile_admin_settings_autocomplete($string)
Definition: profile.admin.inc:434
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
profile_admin_overview_submit
profile_admin_overview_submit($form, &$form_state)
Definition: profile.admin.inc:82
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
drupal_json_output
drupal_json_output($var=NULL)
Definition: common.inc:5041
$header
print $header
Definition: forum-topic-list.tpl.php:42
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
_profile_field_types
_profile_field_types($type=NULL)
Definition: profile.module:599
profile_admin_overview
profile_admin_overview($form)
Definition: profile.admin.inc:14
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
drupal_get_schema
drupal_get_schema($table=NULL, $rebuild=FALSE)
Definition: bootstrap.inc:2940
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
menu_rebuild
menu_rebuild()
Definition: menu.inc:2709
PROFILE_PUBLIC
const PROFILE_PUBLIC
Definition: profile.module:16
theme_profile_admin_overview
theme_profile_admin_overview($variables)
Definition: profile.admin.inc:114
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
profile_field_form_validate
profile_field_form_validate($form, &$form_state)
Definition: profile.admin.inc:310
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
$output
$output
Definition: authorize.php:93
db_like
db_like($string)
Definition: database.inc:2610
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
PROFILE_HIDDEN
const PROFILE_HIDDEN
Definition: profile.module:26
profile_field_delete
profile_field_delete($form, &$form_state, $fid)
Definition: profile.admin.inc:396
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$row
$row
Definition: block-admin-display-form.tpl.php:47
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
drupal_not_found
drupal_not_found()
Definition: common.inc:731
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
profile_field_form
profile_field_form($form, &$form_state, $arg=NULL)
Definition: profile.admin.inc:187
profile_field_form_submit
profile_field_form_submit($form, &$form_state)
Definition: profile.admin.inc:363
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
PROFILE_PRIVATE
const PROFILE_PRIVATE
Definition: profile.module:11
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/simpletest/simpletest.pages.inc Source File

  • modules
  • simpletest
simpletest.pages.inc
Go to the documentation of this file.
1 <?php
2
11 function simpletest_test_form($form) {
12 $form['tests'] = array(
13 '#type' => 'fieldset',
14 '#title' => t('Tests'),
15 '#description' => t('Select the test(s) or test group(s) you would like to run, and click <em>Run tests</em>.'),
16 );
17
18 $form['tests']['table'] = array(
19 '#theme' => 'simpletest_test_table',
20 );
21
22 // Generate the list of tests arranged by group.
23 $groups = simpletest_test_get_all();
24 foreach ($groups as $group => $tests) {
25 $form['tests']['table'][$group] = array(
26 '#collapsed' => TRUE,
27 );
28
29 foreach ($tests as $class => $info) {
30 $form['tests']['table'][$group][$class] = array(
31 '#type' => 'checkbox',
32 '#title' => $info['name'],
33 '#description' => $info['description'],
34 );
35 }
36 }
37
38 // Operation buttons.
39 $form['tests']['op'] = array(
40 '#type' => 'submit',
41 '#value' => t('Run tests'),
42 );
43 $form['clean'] = array(
44 '#type' => 'fieldset',
45 '#collapsible' => FALSE,
46 '#collapsed' => FALSE,
47 '#title' => t('Clean test environment'),
48 '#description' => t('Remove tables with the prefix "simpletest" and temporary directories that are left over from tests that crashed. This is intended for developers when creating tests.'),
49 );
50 $form['clean']['op'] = array(
51 '#type' => 'submit',
52 '#value' => t('Clean environment'),
53 '#submit' => array('simpletest_clean_environment'),
54 );
55
56 return $form;
57 }
58
68 function theme_simpletest_test_table($variables) {
69 $table = $variables['table'];
70
71 drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css');
72 drupal_add_js(drupal_get_path('module', 'simpletest') . '/simpletest.js');
73 drupal_add_js('misc/tableselect.js');
74
75 // Create header for test selection table.
76 $header = array(
77 array('class' => array('select-all')),
78 array('data' => t('Test'), 'class' => array('simpletest_test')),
79 array('data' => t('Description'), 'class' => array('simpletest_description')),
80 );
81
82 // Define the images used to expand/collapse the test groups.
83 $js = array(
84 'images' => array(
85 theme('image', array('path' => 'misc/menu-collapsed.png', 'width' => 7, 'height' => 7, 'alt' => t('Expand'), 'title' => t('Expand'))) . ' <a href="#" class="simpletest-collapse">(' . t('Expand') . ')</a>',
86 theme('image', array('path' => 'misc/menu-expanded.png', 'width' => 7, 'height' => 7, 'alt' => t('Collapse'), 'title' => t('Collapse'))) . ' <a href="#" class="simpletest-collapse">(' . t('Collapse') . ')</a>',
87 ),
88 );
89
90 // Cycle through each test group and create a row.
91 $rows = array();
92 foreach (element_children($table) as $key) {
93 $element = &$table[$key];
94 $row = array();
95
96 // Make the class name safe for output on the page by replacing all
97 // non-word/decimal characters with a dash (-).
98 $test_class = strtolower(trim(preg_replace("/[^\w\d]/", "-", $key)));
99
100 // Select the right "expand"/"collapse" image, depending on whether the
101 // category is expanded (at least one test selected) or not.
102 $collapsed = !empty($element['#collapsed']);
103 $image_index = $collapsed ? 0 : 1;
104
105 // Place-holder for checkboxes to select group of tests.
106 $row[] = array('id' => $test_class, 'class' => array('simpletest-select-all'));
107
108 // Expand/collapse image and group title.
109 $row[] = array(
110 'data' => '<div class="simpletest-image" id="simpletest-test-group-' . $test_class . '"></div>' .
111 '<label for="' . $test_class . '-select-all" class="simpletest-group-label">' . $key . '</label>',
112 'class' => array('simpletest-group-label'),
113 );
114
115 $row[] = array(
116 'data' => '&nbsp;',
117 'class' => array('simpletest-group-description'),
118 );
119
120 $rows[] = array('data' => $row, 'class' => array('simpletest-group'));
121
122 // Add individual tests to group.
123 $current_js = array(
124 'testClass' => $test_class . '-test',
125 'testNames' => array(),
126 'imageDirection' => $image_index,
127 'clickActive' => FALSE,
128 );
129
130 // Sorting $element by children's #title attribute instead of by class name.
131 uasort($element, 'element_sort_by_title');
132
133 // Cycle through each test within the current group.
134 foreach (element_children($element) as $test_name) {
135 $test = $element[$test_name];
136 $row = array();
137
138 $current_js['testNames'][] = $test['#id'];
139
140 // Store test title and description so that checkbox won't render them.
141 $title = $test['#title'];
142 $description = $test['#description'];
143
144 $test['#title_display'] = 'invisible';
145 unset($test['#description']);
146
147 // Test name is used to determine what tests to run.
148 $test['#name'] = $test_name;
149
150 $row[] = array(
151 'data' => drupal_render($test),
152 'class' => array('simpletest-test-select'),
153 );
154 $row[] = array(
155 'data' => '<label for="' . $test['#id'] . '">' . $title . '</label>',
156 'class' => array('simpletest-test-label'),
157 );
158 $row[] = array(
159 'data' => '<div class="description">' . $description . '</div>',
160 'class' => array('simpletest-test-description'),
161 );
162
163 $rows[] = array('data' => $row, 'class' => array($test_class . '-test', ($collapsed ? 'js-hide' : '')));
164 }
165 $js['simpletest-test-group-' . $test_class] = $current_js;
166 unset($table[$key]);
167 }
168
169 // Add js array of settings.
170 drupal_add_js(array('simpleTest' => $js), 'setting');
171
172 if (empty($rows)) {
173 return '<strong>' . t('No tests to display.') . '</strong>';
174 }
175 else {
176 return theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'simpletest-form-table')));
177 }
178 }
179
183 function simpletest_test_form_submit($form, &$form_state) {
184 simpletest_classloader_register();
185 // Get list of tests.
186 $tests_list = array();
187 foreach ($form_state['values'] as $class_name => $value) {
188 // Since class_exists() will likely trigger an autoload lookup,
189 // we do the fast check first.
190 if ($value === 1 && class_exists($class_name)) {
191 $tests_list[] = $class_name;
192 }
193 }
194 if (count($tests_list) > 0 ) {
195 $test_id = simpletest_run_tests($tests_list, 'drupal');
196 $form_state['redirect'] = 'admin/config/development/testing/results/' . $test_id;
197 }
198 else {
199 drupal_set_message(t('No test(s) selected.'), 'error');
200 }
201 }
202
206 function simpletest_result_form($form, &$form_state, $test_id) {
207 // Make sure there are test results to display and a re-run is not being performed.
208 $results = array();
209 if (is_numeric($test_id) && !$results = simpletest_result_get($test_id)) {
210 drupal_set_message(t('No test results to display.'), 'error');
211 drupal_goto('admin/config/development/testing');
212 return $form;
213 }
214
215 // Load all classes and include CSS.
216 drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css');
217
218 // Keep track of which test cases passed or failed.
219 $filter = array(
220 'pass' => array(),
221 'fail' => array(),
222 );
223
224 // Summary result fieldset.
225 $form['result'] = array(
226 '#type' => 'fieldset',
227 '#title' => t('Results'),
228 );
229 $form['result']['summary'] = $summary = array(
230 '#theme' => 'simpletest_result_summary',
231 '#pass' => 0,
232 '#fail' => 0,
233 '#exception' => 0,
234 '#debug' => 0,
235 );
236
237 simpletest_classloader_register();
238
239 // Cycle through each test group.
240 $header = array(t('Message'), t('Group'), t('Filename'), t('Line'), t('Function'), array('colspan' => 2, 'data' => t('Status')));
241 $form['result']['results'] = array();
242 foreach ($results as $group => $assertions) {
243 // Create group fieldset with summary information.
244 $info = call_user_func(array($group, 'getInfo'));
245 $form['result']['results'][$group] = array(
246 '#type' => 'fieldset',
247 '#title' => $info['name'],
248 '#description' => $info['description'],
249 '#collapsible' => TRUE,
250 );
251 $form['result']['results'][$group]['summary'] = $summary;
252 $group_summary = &$form['result']['results'][$group]['summary'];
253
254 // Create table of assertions for the group.
255 $rows = array();
256 foreach ($assertions as $assertion) {
257 $row = array();
258 $row[] = $assertion->message;
259 $row[] = $assertion->message_group;
260 $row[] = drupal_basename($assertion->file);
261 $row[] = $assertion->line;
262 $row[] = $assertion->function;
263 $row[] = simpletest_result_status_image($assertion->status);
264
265 $class = 'simpletest-' . $assertion->status;
266 if ($assertion->message_group == 'Debug') {
267 $class = 'simpletest-debug';
268 }
269 $rows[] = array('data' => $row, 'class' => array($class));
270
271 $group_summary['#' . $assertion->status]++;
272 $form['result']['summary']['#' . $assertion->status]++;
273 }
274 $form['result']['results'][$group]['table'] = array(
275 '#theme' => 'table',
276 '#header' => $header,
277 '#rows' => $rows,
278 );
279
280 // Set summary information.
281 $group_summary['#ok'] = $group_summary['#fail'] + $group_summary['#exception'] == 0;
282 $form['result']['results'][$group]['#collapsed'] = $group_summary['#ok'];
283
284 // Store test group (class) as for use in filter.
285 $filter[$group_summary['#ok'] ? 'pass' : 'fail'][] = $group;
286 }
287
288 // Overal summary status.
289 $form['result']['summary']['#ok'] = $form['result']['summary']['#fail'] + $form['result']['summary']['#exception'] == 0;
290
291 // Actions.
292 $form['#action'] = url('admin/config/development/testing/results/re-run');
293 $form['action'] = array(
294 '#type' => 'fieldset',
295 '#title' => t('Actions'),
296 '#attributes' => array('class' => array('container-inline')),
297 '#weight' => -11,
298 );
299
300 $form['action']['filter'] = array(
301 '#type' => 'select',
302 '#title' => 'Filter',
303 '#options' => array(
304 'all' => t('All (@count)', array('@count' => count($filter['pass']) + count($filter['fail']))),
305 'pass' => t('Pass (@count)', array('@count' => count($filter['pass']))),
306 'fail' => t('Fail (@count)', array('@count' => count($filter['fail']))),
307 ),
308 );
309 $form['action']['filter']['#default_value'] = ($filter['fail'] ? 'fail' : 'all');
310
311 // Categorized test classes for to be used with selected filter value.
312 $form['action']['filter_pass'] = array(
313 '#type' => 'hidden',
314 '#default_value' => implode(',', $filter['pass']),
315 );
316 $form['action']['filter_fail'] = array(
317 '#type' => 'hidden',
318 '#default_value' => implode(',', $filter['fail']),
319 );
320
321 $form['action']['op'] = array(
322 '#type' => 'submit',
323 '#value' => t('Run tests'),
324 );
325
326 $form['action']['return'] = array(
327 '#type' => 'link',
328 '#title' => t('Return to list'),
329 '#href' => 'admin/config/development/testing',
330 );
331
332 if (is_numeric($test_id)) {
333 simpletest_clean_results_table($test_id);
334 }
335
336 return $form;
337 }
338
342 function simpletest_result_form_submit($form, &$form_state) {
343 $pass = $form_state['values']['filter_pass'] ? explode(',', $form_state['values']['filter_pass']) : array();
344 $fail = $form_state['values']['filter_fail'] ? explode(',', $form_state['values']['filter_fail']) : array();
345
346 if ($form_state['values']['filter'] == 'all') {
347 $classes = array_merge($pass, $fail);
348 }
349 elseif ($form_state['values']['filter'] == 'pass') {
350 $classes = $pass;
351 }
352 else {
353 $classes = $fail;
354 }
355
356 if (!$classes) {
357 $form_state['redirect'] = 'admin/config/development/testing';
358 return;
359 }
360
361 $form_state_execute = array('values' => array());
362 foreach ($classes as $class) {
363 $form_state_execute['values'][$class] = 1;
364 }
365
366 simpletest_test_form_submit(array(), $form_state_execute);
367 $form_state['redirect'] = $form_state_execute['redirect'];
368 }
369
379 function theme_simpletest_result_summary($variables) {
380 $form = $variables['form'];
381 return '<div class="simpletest-' . ($form['#ok'] ? 'pass' : 'fail') . '">' . _simpletest_format_summary_line($form) . '</div>';
382 }
383
390 function simpletest_result_get($test_id) {
391 $results = db_select('simpletest')
392 ->fields('simpletest')
393 ->condition('test_id', $test_id)
394 ->orderBy('test_class')
395 ->orderBy('message_id')
396 ->execute();
397
398 $test_results = array();
399 foreach ($results as $result) {
400 if (!isset($test_results[$result->test_class])) {
401 $test_results[$result->test_class] = array();
402 }
403 $test_results[$result->test_class][] = $result;
404 }
405 return $test_results;
406 }
407
414 function simpletest_result_status_image($status) {
415 // $map does not use drupal_static() as its value never changes.
416 static $map;
417
418 if (!isset($map)) {
419 $map = array(
420 'pass' => theme('image', array('path' => 'misc/watchdog-ok.png', 'width' => 18, 'height' => 18, 'alt' => t('Pass'))),
421 'fail' => theme('image', array('path' => 'misc/watchdog-error.png', 'width' => 18, 'height' => 18, 'alt' => t('Fail'))),
422 'exception' => theme('image', array('path' => 'misc/watchdog-warning.png', 'width' => 18, 'height' => 18, 'alt' => t('Exception'))),
423 'debug' => theme('image', array('path' => 'misc/watchdog-warning.png', 'width' => 18, 'height' => 18, 'alt' => t('Debug'))),
424 );
425 }
426 if (isset($map[$status])) {
427 return $map[$status];
428 }
429 return FALSE;
430 }
431
438 function simpletest_settings_form($form, &$form_state) {
439 $form['general'] = array(
440 '#type' => 'fieldset',
441 '#title' => t('General'),
442 );
443 $form['general']['simpletest_clear_results'] = array(
444 '#type' => 'checkbox',
445 '#title' => t('Clear results after each complete test suite run'),
446 '#description' => t('By default SimpleTest will clear the results after they have been viewed on the results page, but in some cases it may be useful to leave the results in the database. The results can then be viewed at <em>admin/config/development/testing/[test_id]</em>. The test ID can be found in the database, simpletest table, or kept track of when viewing the results the first time. Additionally, some modules may provide more analysis or features that require this setting to be disabled.'),
447 '#default_value' => variable_get('simpletest_clear_results', TRUE),
448 );
449 $form['general']['simpletest_verbose'] = array(
450 '#type' => 'checkbox',
451 '#title' => t('Provide verbose information when running tests'),
452 '#description' => t('The verbose data will be printed along with the standard assertions and is useful for debugging. The verbose data will be erased between each test suite run. The verbose data output is very detailed and should only be used when debugging.'),
453 '#default_value' => variable_get('simpletest_verbose', TRUE),
454 );
455
456 $form['httpauth'] = array(
457 '#type' => 'fieldset',
458 '#title' => t('HTTP authentication'),
459 '#description' => t('HTTP auth settings to be used by the SimpleTest browser during testing. Useful when the site requires basic HTTP authentication.'),
460 '#collapsible' => TRUE,
461 '#collapsed' => TRUE,
462 );
463 $form['httpauth']['simpletest_httpauth_method'] = array(
464 '#type' => 'select',
465 '#title' => t('Method'),
466 '#options' => array(
467 CURLAUTH_BASIC => t('Basic'),
468 CURLAUTH_DIGEST => t('Digest'),
469 CURLAUTH_GSSNEGOTIATE => t('GSS negotiate'),
470 CURLAUTH_NTLM => t('NTLM'),
471 CURLAUTH_ANY => t('Any'),
472 CURLAUTH_ANYSAFE => t('Any safe'),
473 ),
474 '#default_value' => variable_get('simpletest_httpauth_method', CURLAUTH_BASIC),
475 );
476 $username = variable_get('simpletest_httpauth_username');
477 $password = variable_get('simpletest_httpauth_password');
478 $form['httpauth']['simpletest_httpauth_username'] = array(
479 '#type' => 'textfield',
480 '#title' => t('Username'),
481 '#default_value' => $username,
482 );
483 if ($username && $password) {
484 $form['httpauth']['simpletest_httpauth_username']['#description'] = t('Leave this blank to delete both the existing username and password.');
485 }
486 $form['httpauth']['simpletest_httpauth_password'] = array(
487 '#type' => 'password',
488 '#title' => t('Password'),
489 );
490 if ($password) {
491 $form['httpauth']['simpletest_httpauth_password']['#description'] = t('To change the password, enter the new password here.');
492 }
493
494 return system_settings_form($form);
495 }
496
500 function simpletest_settings_form_validate($form, &$form_state) {
501 // If a username was provided but a password wasn't, preserve the existing
502 // password.
503 if (!empty($form_state['values']['simpletest_httpauth_username']) && empty($form_state['values']['simpletest_httpauth_password'])) {
504 $form_state['values']['simpletest_httpauth_password'] = variable_get('simpletest_httpauth_password', '');
505 }
506
507 // If a password was provided but a username wasn't, the credentials are
508 // incorrect, so throw an error.
509 if (empty($form_state['values']['simpletest_httpauth_username']) && !empty($form_state['values']['simpletest_httpauth_password'])) {
510 form_set_error('simpletest_httpauth_username', t('HTTP authentication credentials must include a username in addition to a password.'));
511 }
512 }
513
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
simpletest_result_status_image
simpletest_result_status_image($status)
Definition: simpletest.pages.inc:414
simpletest_run_tests
simpletest_run_tests($test_list, $reporter= 'drupal')
Definition: simpletest.module:125
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
simpletest_result_form_submit
simpletest_result_form_submit($form, &$form_state)
Definition: simpletest.pages.inc:342
simpletest_settings_form
simpletest_settings_form($form, &$form_state)
Definition: simpletest.pages.inc:438
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
$results
print $results
Definition: poll-results.tpl.php:23
$header
print $header
Definition: forum-topic-list.tpl.php:42
theme_simpletest_test_table
theme_simpletest_test_table($variables)
Definition: simpletest.pages.inc:68
simpletest_test_form
simpletest_test_form($form)
Definition: simpletest.pages.inc:11
simpletest_test_form_submit
simpletest_test_form_submit($form, &$form_state)
Definition: simpletest.pages.inc:183
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
theme_simpletest_result_summary
theme_simpletest_result_summary($variables)
Definition: simpletest.pages.inc:379
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$info
$info
Definition: color.inc:6
simpletest_result_get
simpletest_result_get($test_id)
Definition: simpletest.pages.inc:390
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
simpletest_test_get_all
simpletest_test_get_all()
Definition: simpletest.module:312
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
simpletest_classloader_register
simpletest_classloader_register()
Definition: simpletest.module:398
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
$classes
print $classes
Definition: contextual-links-example-object.tpl.php:31
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
$row
$row
Definition: block-admin-display-form.tpl.php:47
drupal_basename
drupal_basename($uri, $suffix=NULL)
Definition: file.inc:2317
simpletest_clean_results_table
simpletest_clean_results_table($test_id=NULL)
Definition: simpletest.module:590
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
simpletest_result_form
simpletest_result_form($form, &$form_state, $test_id)
Definition: simpletest.pages.inc:206
_simpletest_format_summary_line
_simpletest_format_summary_line($summary)
Definition: simpletest.module:103
system_settings_form
system_settings_form($form)
Definition: system.module:2755
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
simpletest_settings_form_validate
simpletest_settings_form_validate($form, &$form_state)
Definition: simpletest.pages.inc:500
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/maintenance-page.tpl.php Source File

  • modules
  • system
maintenance-page.tpl.php
Go to the documentation of this file.
1 <?php
2
15 ?>
16 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
17 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
18 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
19
20 <head>
21 <title><?php print $head_title; ?></title>
22 <?php print $head; ?>
23 <?php print $styles; ?>
24 <?php print $scripts; ?>
25 </head>
26 <body class="<?php print $classes; ?>">
27 <div id="page">
28 <div id="header">
29 <div id="logo-title">
30
31 <?php if (!empty($logo)): ?>
32 <a href="<?php print $base_path; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
33 <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
34 </a>
35 <?php endif; ?>
36
37 <div id="name-and-slogan">
38 <?php if (!empty($site_name)): ?>
39 <h1 id="site-name">
40 <a href="<?php print $base_path ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
41 </h1>
42 <?php endif; ?>
43
44 <?php if (!empty($site_slogan)): ?>
45 <div id="site-slogan"><?php print $site_slogan; ?></div>
46 <?php endif; ?>
47 </div> <!-- /name-and-slogan -->
48 </div> <!-- /logo-title -->
49
50 <?php if (!empty($header)): ?>
51 <div id="header-region">
52 <?php print $header; ?>
53 </div>
54 <?php endif; ?>
55
56 </div> <!-- /header -->
57
58 <div id="container" class="clearfix">
59
60 <?php if (!empty($sidebar_first)): ?>
61 <div id="sidebar-first" class="column sidebar">
62 <?php print $sidebar_first; ?>
63 </div> <!-- /sidebar-first -->
64 <?php endif; ?>
65
66 <div id="main" class="column"><div id="main-squeeze">
67
68 <div id="content">
69 <?php if (!empty($title)): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
70 <?php if (!empty($messages)): print $messages; endif; ?>
71 <div id="content-content" class="clearfix">
72 <?php print $content; ?>
73 </div> <!-- /content-content -->
74 </div> <!-- /content -->
75
76 </div></div> <!-- /main-squeeze /main -->
77
78 <?php if (!empty($sidebar_second)): ?>
79 <div id="sidebar-second" class="column sidebar">
80 <?php print $sidebar_second; ?>
81 </div> <!-- /sidebar-second -->
82 <?php endif; ?>
83
84 </div> <!-- /container -->
85
86 <div id="footer-wrapper">
87 <div id="footer">
88 <?php if (!empty($footer)): print $footer; endif; ?>
89 </div> <!-- /footer -->
90 </div> <!-- /footer-wrapper -->
91
92 </div> <!-- /page -->
93
94 </body>
95 </html>
dir
print $language dir
Definition: html.tpl.php:47
$head
print $head
Definition: book-export-html.tpl.php:25
name
print $forum name
Definition: forum-list.tpl.php:57
$header
print $header
Definition: forum-topic-list.tpl.php:42
print
print
Definition: php-2.php:2
$logo
print $logo
Definition: maintenance-page.tpl.php:33
$site_slogan
if($site_slogan)($hide_site_slogan) print $site_slogan
Definition: maintenance-page.tpl.php:41
$scripts
print $scripts
Definition: html.tpl.php:53
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
endif
endif
Definition: aggregator-item.tpl.php:31
$messages
print $messages
Definition: page.tpl.php:121
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
$styles
print $styles
Definition: html.tpl.php:52
title
print $topic title
Definition: forum-topic-list.tpl.php:50
$head_title
print $head_title
Definition: html.tpl.php:51
$site_name
print $site_name
Definition: maintenance-page.tpl.php:40
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
FieldInfo Member List

This is the complete list of members for FieldInfo, including all inherited members.

$bundleExtraFields | FieldInfo | protected
$bundleInstances | FieldInfo | protected
$emptyBundles | FieldInfo | protected
$fieldIdsByName | FieldInfo | protected
$fieldMap | FieldInfo | protected
$fieldsById | FieldInfo | protected
$loadedAllFields | FieldInfo | protected
$loadedAllInstances | FieldInfo | protected
$unknownFields | FieldInfo | protected
flush() | FieldInfo |
getBundleExtraFields($entity_type, $bundle) | FieldInfo |
getBundleInstances($entity_type, $bundle) | FieldInfo |
getField($field_name) | FieldInfo |
getFieldById($field_id) | FieldInfo |
getFieldMap() | FieldInfo |
getFields() | FieldInfo |
getInstances($entity_type=NULL) | FieldInfo |
prepareExtraFields($extra_fields, $entity_type, $bundle) | FieldInfo |
prepareField($field) | FieldInfo |
prepareInstance($instance, $field_type) | FieldInfo |
prepareInstanceDisplay($display, $field_type) | FieldInfo |
prepareInstanceWidget($widget, $field_type) | FieldInfo |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/archiver.inc Source File

  • includes
archiver.inc
Go to the documentation of this file.
1 <?php
2
11 interface ArchiverInterface {
12
21 public function __construct($file_path);
22
33 public function add($file_path);
34
44 public function remove($path);
45
59 public function extract($path, array $files = array());
60
67 public function listContents();
68 }
ArchiverInterface\listContents
listContents()
ArchiverInterface\add
add($file_path)
ArchiverInterface
Definition: archiver.inc:11
ArchiverInterface\extract
extract($path, array $files=array())
ArchiverInterface\__construct
__construct($file_path)
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalDatabaseCache Member List

This is the complete list of members for DrupalDatabaseCache, including all inherited members.

$bin | DrupalDatabaseCache | protected
__construct($bin) | DrupalDatabaseCache |
clear($cid=NULL, $wildcard=FALSE) | DrupalDatabaseCache |
garbageCollection() | DrupalDatabaseCache | protected
get($cid) | DrupalDatabaseCache |
getMultiple(&$cids) | DrupalDatabaseCache |
isEmpty() | DrupalDatabaseCache |
isValidBin() | DrupalDatabaseCache |
prepareItem($cache) | DrupalDatabaseCache | protected
set($cid, $data, $expire=CACHE_PERMANENT) | DrupalDatabaseCache |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
FileTransferLocal Member List

This is the complete list of members for FileTransferLocal, including all inherited members.

$hostname | FileTransfer | protected
$password | FileTransfer | protected
$port | FileTransfer | protected
$username | FileTransfer | protected
__construct($jail) | FileTransfer |
__get($name) | FileTransfer |
checkPath($path) | FileTransfer | protected
chmod($path, $mode, $recursive=FALSE) | FileTransfer |
chmodJailed($path, $mode, $recursive) | FileTransferLocal |
connect() | FileTransferLocal |
copyDirectory($source, $destination) | FileTransfer |
copyDirectoryJailed($source, $destination) | FileTransfer | protected
copyFile($source, $destination) | FileTransfer |
copyFileJailed($source, $destination) | FileTransferLocal | protected
createDirectory($directory) | FileTransfer |
createDirectoryJailed($directory) | FileTransferLocal | protected
factory($jail, $settings) | FileTransferLocal | static
findChroot() | FileTransfer |
fixRemotePath($path, $strip_chroot=TRUE) | FileTransfer | protected
getSettingsForm() | FileTransfer |
isDirectory($path) | FileTransferLocal |
isFile($path) | FileTransferLocal |
removeDirectory($directory) | FileTransfer |
removeDirectoryJailed($directory) | FileTransferLocal | protected
removeFile($destination) | FileTransfer |
removeFileJailed($file) | FileTransferLocal | protected
sanitizePath($path) | FileTransfer |
setChroot() | FileTransfer |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book.pages.inc Source File

  • modules
  • book
book.pages.inc
Go to the documentation of this file.
1 <?php
2
16 function book_render() {
17 $book_list = array();
18 foreach (book_get_books() as $book) {
19 $book_list[] = l($book['title'], $book['href'], $book['options']);
20 }
21
22 return theme('item_list', array('items' => $book_list));
23 }
24
47 function book_export($type, $nid) {
48 // Check that the node exists and that the current user has access to it.
49 $node = node_load($nid);
50 if (!$node) {
51 return MENU_NOT_FOUND;
52 }
53 if (!node_access('view', $node)) {
54 return MENU_ACCESS_DENIED;
55 }
56
57 $type = drupal_strtolower($type);
58
59 $export_function = 'book_export_' . $type;
60
61 if (function_exists($export_function)) {
62 print call_user_func($export_function, $nid);
63 }
64 else {
65 drupal_set_message(t('Unknown export format.'));
66 drupal_not_found();
67 }
68 }
69
87 function book_export_html($nid) {
88 if (user_access('access printer-friendly version')) {
89 $node = node_load($nid);
90 if (isset($node->book)) {
91 $tree = book_menu_subtree_data($node->book);
92 $contents = book_export_traverse($tree, 'book_node_export');
93 return theme('book_export_html', array('title' => $node->title, 'contents' => $contents, 'depth' => $node->book['depth']));
94 }
95 else {
96 drupal_not_found();
97 }
98 }
99 else {
100 drupal_access_denied();
101 }
102 }
103
115 function book_outline($node) {
116 drupal_set_title($node->title);
117 return drupal_get_form('book_outline_form', $node);
118 }
119
132 function book_outline_form($form, &$form_state, $node) {
133 if (!isset($node->book)) {
134 // The node is not part of any book yet - set default options.
135 $node->book = _book_link_defaults($node->nid);
136 }
137 else {
138 $node->book['original_bid'] = $node->book['bid'];
139 }
140
141 // Find the depth limit for the parent select.
142 if (!isset($node->book['parent_depth_limit'])) {
143 $node->book['parent_depth_limit'] = _book_parent_depth_limit($node->book);
144 }
145 $form['#node'] = $node;
146 $form['#id'] = 'book-outline';
147 _book_add_form_elements($form, $form_state, $node);
148
149 $form['book']['#collapsible'] = FALSE;
150
151 $form['update'] = array(
152 '#type' => 'submit',
153 '#value' => $node->book['original_bid'] ? t('Update book outline') : t('Add to book outline'),
154 '#weight' => 15,
155 );
156
157 $form['remove'] = array(
158 '#type' => 'submit',
159 '#value' => t('Remove from book outline'),
160 '#access' => _book_node_is_removable($node),
161 '#weight' => 20,
162 '#submit' => array('book_remove_button_submit'),
163 );
164
165 return $form;
166 }
167
175 function book_remove_button_submit($form, &$form_state) {
176 $form_state['redirect'] = 'node/' . $form['#node']->nid . '/outline/remove';
177 }
178
184 function book_outline_form_submit($form, &$form_state) {
185 $node = $form['#node'];
186 $form_state['redirect'] = "node/" . $node->nid;
187 $book_link = $form_state['values']['book'];
188 if (!$book_link['bid']) {
189 drupal_set_message(t('No changes were made'));
190
191 return;
192 }
193
194 $book_link['menu_name'] = book_menu_name($book_link['bid']);
195 $node->book = $book_link;
196 if (_book_update_outline($node)) {
197 if ($node->book['parent_mismatch']) {
198 // This will usually only happen when JS is disabled.
199 drupal_set_message(t('The post has been added to the selected book. You may now position it relative to other pages.'));
200 $form_state['redirect'] = "node/" . $node->nid . "/outline";
201 }
202 else {
203 drupal_set_message(t('The book outline has been updated.'));
204 }
205 }
206 else {
207 drupal_set_message(t('There was an error adding the post to the book.'), 'error');
208 }
209 }
210
220 function book_remove_form($form, &$form_state, $node) {
221 $form['#node'] = $node;
222 $title = array('%title' => $node->title);
223
224 if ($node->book['has_children']) {
225 $description = t('%title has associated child pages, which will be relocated automatically to maintain their connection to the book. To recreate the hierarchy (as it was before removing this page), %title may be added again using the Outline tab, and each of its former child pages will need to be relocated manually.', $title);
226 }
227 else {
228 $description = t('%title may be added to hierarchy again using the Outline tab.', $title);
229 }
230
231 return confirm_form($form, t('Are you sure you want to remove %title from the book hierarchy?', $title), 'node/' . $node->nid, $description, t('Remove'));
232 }
233
237 function book_remove_form_submit($form, &$form_state) {
238 $node = $form['#node'];
239 if (_book_node_is_removable($node)) {
240 menu_link_delete($node->book['mlid']);
241 db_delete('book')
242 ->condition('nid', $node->nid)
243 ->execute();
244 drupal_set_message(t('The post has been removed from the book.'));
245 }
246 $form_state['redirect'] = 'node/' . $node->nid;
247 }
book_export_traverse
book_export_traverse($tree, $visit_func)
Definition: book.module:1240
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_strtolower
drupal_strtolower($text)
Definition: unicode.inc:521
MENU_ACCESS_DENIED
const MENU_ACCESS_DENIED
Definition: menu.inc:239
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
_book_node_is_removable
_book_node_is_removable($node)
Definition: book.module:228
menu_link_delete
menu_link_delete($mlid, $path=NULL)
Definition: menu.inc:2996
book_export
book_export($type, $nid)
Definition: book.pages.inc:47
book_render
book_render()
Definition: book.pages.inc:16
print
print
Definition: php-2.php:2
book_outline_form
book_outline_form($form, &$form_state, $node)
Definition: book.pages.inc:132
$contents
print $contents
Definition: book-export-html.tpl.php:49
book_menu_name
book_menu_name($bid)
Definition: book.module:864
book_outline_form_submit
book_outline_form_submit($form, &$form_state)
Definition: book.pages.inc:184
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
MENU_NOT_FOUND
const MENU_NOT_FOUND
Definition: menu.inc:234
book_remove_form_submit
book_remove_form_submit($form, &$form_state)
Definition: book.pages.inc:237
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
book_outline
book_outline($node)
Definition: book.pages.inc:115
book_export_html
book_export_html($nid)
Definition: book.pages.inc:87
_book_link_defaults
_book_link_defaults($nid)
Definition: book.module:1057
book_remove_button_submit
book_remove_button_submit($form, &$form_state)
Definition: book.pages.inc:175
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
user_access
user_access($string, $account=NULL)
Definition: user.module:794
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
drupal_access_denied
drupal_access_denied()
Definition: common.inc:744
node_access
node_access($op, $node, $account=NULL)
Definition: node.module:2981
_book_add_form_elements
_book_add_form_elements(&$form, &$form_state, $node)
Definition: book.module:519
book_get_books
book_get_books()
Definition: book.module:380
_book_update_outline
_book_update_outline($node)
Definition: book.module:626
_book_parent_depth_limit
_book_parent_depth_limit($book_link)
Definition: book.module:1026
book_remove_form
book_remove_form($form, &$form_state, $node)
Definition: book.pages.inc:220
drupal_not_found
drupal_not_found()
Definition: common.inc:731
$tree
if($tree||$has_links) print $tree
Definition: book-navigation.tpl.php:35
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
book_menu_subtree_data
book_menu_subtree_data($link)
Definition: book.module:1380
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/menu/menu.install Source File

  • modules
  • menu
menu.install
Go to the documentation of this file.
1 <?php
2
11 function menu_schema() {
12 $schema['menu_custom'] = array(
13 'description' => 'Holds definitions for top-level custom menus (for example, Main menu).',
14 'fields' => array(
15 'menu_name' => array(
16 'type' => 'varchar',
17 'length' => 32,
18 'not null' => TRUE,
19 'default' => '',
20 'description' => 'Primary Key: Unique key for menu. This is used as a block delta so length is 32.',
21 ),
22 'title' => array(
23 'type' => 'varchar',
24 'length' => 255,
25 'not null' => TRUE,
26 'default' => '',
27 'description' => 'Menu title; displayed at top of block.',
28 'translatable' => TRUE,
29 ),
30 'description' => array(
31 'type' => 'text',
32 'not null' => FALSE,
33 'description' => 'Menu description.',
34 'translatable' => TRUE,
35 ),
36 ),
37 'primary key' => array('menu_name'),
38 );
39
40 return $schema;
41 }
42
46 function menu_install() {
47 $system_menus = menu_list_system_menus();
48 $t = get_t();
49 $descriptions = array(
50 'navigation' => $t('The <em>Navigation</em> menu contains links intended for site visitors. Links are added to the <em>Navigation</em> menu automatically by some modules.'),
51 'user-menu' => $t("The <em>User</em> menu contains links related to the user's account, as well as the 'Log out' link."),
52 'management' => $t('The <em>Management</em> menu contains links for administrative tasks.'),
53 'main-menu' => $t('The <em>Main</em> menu is used on many sites to show the major sections of the site, often in a top navigation bar.'),
54 );
55 foreach ($system_menus as $menu_name => $title) {
56 $menu = array(
57 'menu_name' => $menu_name,
58 'title' => $t($title),
59 'description' => $descriptions[$menu_name],
60 );
61 menu_save($menu);
62 }
63 }
64
68 function menu_uninstall() {
69 menu_rebuild();
70 }
71
80 function menu_update_7000() {
81 // Act only on sites originally on Drupal 6 that have a custom "Default menu
82 // for content" setting.
83 $default_node_menu = variable_get('menu_default_node_menu');
84 if (isset($default_node_menu)) {
85 // Remove variable no longer used in Drupal 7.
86 variable_del('menu_default_node_menu');
87
88 // Make sure the menu chosen as the default still exists.
89 $defined_menus = db_query('SELECT * FROM {menu_custom}')->fetchAllAssoc('menu_name', PDO::FETCH_ASSOC);
90 // If the menu does not exist, do nothing; nodes will use the default D7
91 // node menu settings.
92 if (!isset($defined_menus[$default_node_menu])) {
93 return;
94 }
95
96 // Update the menu settings for each node type.
97 foreach (_update_7000_node_get_types() as $type => $type_object) {
98 $type_menus = variable_get('menu_options_' . $type);
99 // If the site already has a custom menu setting for this node type (set
100 // on the initial upgrade to Drupal 7.0), don't override it.
101 if (!isset($type_menus)) {
102 // Set up this node type so that the Drupal 6 "Default menu for content"
103 // is still available in the "Menu settings" section.
104 variable_set('menu_options_' . $type, array($default_node_menu));
105 variable_set('menu_parent_' . $type, $default_node_menu . ':0');
106 }
107 }
108 }
109 }
110
114 function menu_update_7001() {
115 // Migrate D6 menu_primary_links_source to D7 menu_main_links_source (without
116 // renaming).
117 if (variable_get('menu_primary_links_source') !== NULL) {
118 variable_set('menu_main_links_source', variable_get('menu_primary_links_source'));
119 variable_del('menu_primary_links_source');
120 }
121
122 // Rename each menu, and any settings that refer to the old menu name.
123 // - "Primary Links" has become system menu "Main menu".
124 // - "Secondary Links" has become a new custom menu "Secondary menu".
125 $rename = array(
126 'primary-links' => array('main-menu', 'Main menu'),
127 'secondary-links' => array('secondary-menu', 'Secondary menu'),
128 );
129 foreach ($rename as $from_menu => $to) {
130 list($to_menu, $to_title) = $to;
131 // Rename the menu, and links in the menu.
132 db_update('menu_custom')
133 ->fields(array('menu_name' => $to_menu, 'title' => $to_title))
134 ->condition('menu_name', $from_menu)
135 ->execute();
136 db_update('menu_links')
137 ->fields(array('menu_name' => $to_menu))
138 ->condition('menu_name', $from_menu)
139 ->execute();
140
141 // Update any content type that used this menu as a default menu.
142 // Note: these variables may be unset/default, in which case we leave them
143 // alone. See menu_update_7000()
144 foreach (_update_7000_node_get_types() as $type => $type_object) {
145 $menu_options = variable_get('menu_options_' . $type);
146 if ($menu_options !== NULL) {
147 variable_set('menu_options_' . $type, str_replace($from_menu, $to_menu, $menu_options));
148 if (variable_get('menu_parent_' . $type) == $from_menu . ':0') {
149 variable_set('menu_parent_' . $type, $to_menu . ':0');
150 }
151 }
152 }
153
154 // Update the "source for primary links" and "source for secondary links" to
155 // follow.
156 if (variable_get('menu_main_links_source') == $from_menu) {
157 variable_set('menu_main_links_source', $to_menu);
158 }
159 if (variable_get('menu_secondary_links_source') == $from_menu) {
160 variable_set('menu_secondary_links_source', $to_menu);
161 }
162 }
163 }
164
168 function menu_update_7002(&$sandbox) {
169 // Check for the presence of old or new table names.
170 if (db_table_exists('blocks') || db_table_exists('block')) {
171 $renamed_deltas = array(
172 'menu' => array(
173 'primary-links' => 'main-menu',
174 'secondary-links' => 'secondary-menu',
175 ),
176 );
177
178 $moved_deltas = array(
179 'menu' => array('main-menu' => 'system'),
180 );
181
182 update_fix_d7_block_deltas($sandbox, $renamed_deltas, $moved_deltas);
183 }
184 }
188 function menu_update_7003(&$sandbox) {
189 // Make sure all custom menus are present in the active menus variable so that
190 // their items may appear in the active trail.
191 // @see menu_set_active_menu_names()
192 $active_menus = variable_get('menu_default_active_menus', array_keys(menu_list_system_menus()));
193 $update_variable = FALSE;
194 foreach (menu_get_names() as $menu_name) {
195 if (!in_array($menu_name, $active_menus) && (strpos($menu_name, 'menu-') === 0)) {
196 $active_menus[] = $menu_name;
197 $update_variable = TRUE;
198 }
199 }
200 if ($update_variable) {
201 variable_set('menu_default_active_menus', $active_menus);
202 }
203 // Clear the menu cache.
204 cache_clear_all(NULL, 'cache_menu');
205 }
206
menu_update_7001
menu_update_7001()
Definition: menu.install:114
menu_get_names
menu_get_names()
Definition: menu.inc:1776
menu_save
menu_save($menu)
Definition: menu.module:259
menu_update_7002
menu_update_7002(&$sandbox)
Definition: menu.install:168
variable_del
variable_del($name)
Definition: bootstrap.inc:996
update_fix_d7_block_deltas
update_fix_d7_block_deltas(&$sandbox, $renamed_deltas, $moved_deltas)
Definition: update.inc:355
menu_update_7003
menu_update_7003(&$sandbox)
Definition: menu.install:188
menu_install
menu_install()
Definition: menu.install:46
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
menu_rebuild
menu_rebuild()
Definition: menu.inc:2709
get_t
get_t()
Definition: bootstrap.inc:2635
menu_schema
menu_schema()
Definition: menu.install:11
menu_list_system_menus
menu_list_system_menus()
Definition: menu.inc:1792
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
menu_uninstall
menu_uninstall()
Definition: menu.install:68
_update_7000_node_get_types
_update_7000_node_get_types()
Definition: node.install:480
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
menu_update_7000
menu_update_7000()
Definition: menu.install:80
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_table_exists
db_table_exists($table)
Definition: database.inc:2760
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.fetch.inc Source File

  • modules
  • update
update.fetch.inc
Go to the documentation of this file.
1 <?php
2
15 function update_manual_status() {
16 _update_refresh();
17 $batch = array(
18 'operations' => array(
19 array('update_fetch_data_batch', array()),
20 ),
21 'finished' => 'update_fetch_data_finished',
22 'title' => t('Checking available update data'),
23 'progress_message' => t('Trying to check available update data ...'),
24 'error_message' => t('Error checking available update data.'),
25 'file' => drupal_get_path('module', 'update') . '/update.fetch.inc',
26 );
27 batch_set($batch);
28 batch_process('admin/reports/updates');
29 }
30
37 function update_fetch_data_batch(&$context) {
38 $queue = DrupalQueue::get('update_fetch_tasks');
39 if (empty($context['sandbox']['max'])) {
40 $context['finished'] = 0;
41 $context['sandbox']['max'] = $queue->numberOfItems();
42 $context['sandbox']['progress'] = 0;
43 $context['message'] = t('Checking available update data ...');
44 $context['results']['updated'] = 0;
45 $context['results']['failures'] = 0;
46 $context['results']['processed'] = 0;
47 }
48
49 // Grab another item from the fetch queue.
50 for ($i = 0; $i < 5; $i++) {
51 if ($item = $queue->claimItem()) {
52 if (_update_process_fetch_task($item->data)) {
53 $context['results']['updated']++;
54 $context['message'] = t('Checked available update data for %title.', array('%title' => $item->data['info']['name']));
55 }
56 else {
57 $context['message'] = t('Failed to check available update data for %title.', array('%title' => $item->data['info']['name']));
58 $context['results']['failures']++;
59 }
60 $context['sandbox']['progress']++;
61 $context['results']['processed']++;
62 $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
63 $queue->deleteItem($item);
64 }
65 else {
66 // If the queue is currently empty, we're done. It's possible that
67 // another thread might have added new fetch tasks while we were
68 // processing this batch. In that case, the usual 'finished' math could
69 // get confused, since we'd end up processing more tasks that we thought
70 // we had when we started and initialized 'max' with numberOfItems(). By
71 // forcing 'finished' to be exactly 1 here, we ensure that batch
72 // processing is terminated.
73 $context['finished'] = 1;
74 return;
75 }
76 }
77 }
78
89 function update_fetch_data_finished($success, $results) {
90 if ($success) {
91 if (!empty($results)) {
92 if (!empty($results['updated'])) {
93 drupal_set_message(format_plural($results['updated'], 'Checked available update data for one project.', 'Checked available update data for @count projects.'));
94 }
95 if (!empty($results['failures'])) {
96 drupal_set_message(format_plural($results['failures'], 'Failed to get available update data for one project.', 'Failed to get available update data for @count projects.'), 'error');
97 }
98 }
99 }
100 else {
101 drupal_set_message(t('An error occurred trying to get available update data.'), 'error');
102 }
103 }
104
108 function _update_fetch_data() {
109 $queue = DrupalQueue::get('update_fetch_tasks');
110 $end = time() + variable_get('update_max_fetch_time', UPDATE_MAX_FETCH_TIME);
111 while (time() < $end && ($item = $queue->claimItem())) {
112 _update_process_fetch_task($item->data);
113 $queue->deleteItem($item);
114 }
115 }
116
129 function _update_process_fetch_task($project) {
130 global $base_url;
131 $fail = &drupal_static(__FUNCTION__, array());
132 // This can be in the middle of a long-running batch, so REQUEST_TIME won't
133 // necessarily be valid.
134 $now = time();
135 if (empty($fail)) {
136 // If we have valid data about release history XML servers that we have
137 // failed to fetch from on previous attempts, load that from the cache.
138 if (($cache = _update_cache_get('fetch_failures')) && ($cache->expire > $now)) {
139 $fail = $cache->data;
140 }
141 }
142
143 $max_fetch_attempts = variable_get('update_max_fetch_attempts', UPDATE_MAX_FETCH_ATTEMPTS);
144
145 $success = FALSE;
146 $available = array();
147 $site_key = drupal_hmac_base64($base_url, drupal_get_private_key());
148 $url = _update_build_fetch_url($project, $site_key);
149 $fetch_url_base = _update_get_fetch_url_base($project);
150 $project_name = $project['name'];
151
152 if (empty($fail[$fetch_url_base]) || $fail[$fetch_url_base] < $max_fetch_attempts) {
153 $xml = drupal_http_request($url);
154 if (!isset($xml->error) && isset($xml->data)) {
155 $data = $xml->data;
156 }
157 }
158
159 if (!empty($data)) {
160 $available = update_parse_xml($data);
161 // @todo: Purge release data we don't need (http://drupal.org/node/238950).
162 if (!empty($available)) {
163 // Only if we fetched and parsed something sane do we return success.
164 $success = TRUE;
165 }
166 }
167 else {
168 $available['project_status'] = 'not-fetched';
169 if (empty($fail[$fetch_url_base])) {
170 $fail[$fetch_url_base] = 1;
171 }
172 else {
173 $fail[$fetch_url_base]++;
174 }
175 }
176
177 $frequency = variable_get('update_check_frequency', 1);
178 $cid = 'available_releases::' . $project_name;
179 _update_cache_set($cid, $available, $now + (60 * 60 * 24 * $frequency));
180
181 // Stash the $fail data back in the DB for the next 5 minutes.
182 _update_cache_set('fetch_failures', $fail, $now + (60 * 5));
183
184 // Whether this worked or not, we did just (try to) check for updates.
185 variable_set('update_last_check', $now);
186
187 // Now that we processed the fetch task for this project, clear out the
188 // record in {cache_update} for this task so we're willing to fetch again.
189 _update_cache_clear('fetch_task::' . $project_name);
190
191 return $success;
192 }
193
197 function _update_refresh() {
198 module_load_include('inc', 'update', 'update.compare');
199
200 // Since we're fetching new available update data, we want to clear
201 // our cache of both the projects we care about, and the current update
202 // status of the site. We do *not* want to clear the cache of available
203 // releases just yet, since that data (even if it's stale) can be useful
204 // during update_get_projects(); for example, to modules that implement
205 // hook_system_info_alter() such as cvs_deploy.
206 _update_cache_clear('update_project_projects');
207 _update_cache_clear('update_project_data');
208
209 $projects = update_get_projects();
210
211 // Now that we have the list of projects, we should also clear our cache of
212 // available release data, since even if we fail to fetch new data, we need
213 // to clear out the stale data at this point.
214 _update_cache_clear('available_releases::', TRUE);
215
216 foreach ($projects as $key => $project) {
217 update_create_fetch_task($project);
218 }
219 }
220
239 function _update_create_fetch_task($project) {
240 $fetch_tasks = &drupal_static(__FUNCTION__, array());
241 if (empty($fetch_tasks)) {
242 $fetch_tasks = _update_get_cache_multiple('fetch_task');
243 }
244 $cid = 'fetch_task::' . $project['name'];
245 if (empty($fetch_tasks[$cid])) {
246 $queue = DrupalQueue::get('update_fetch_tasks');
247 $queue->createItem($project);
248 // Due to race conditions, it is possible that another process already
249 // inserted a row into the {cache_update} table and the following query will
250 // throw an exception.
251 // @todo: Remove the need for the manual check by relying on a queue that
252 // enforces unique items.
253 try {
254 db_insert('cache_update')
255 ->fields(array(
256 'cid' => $cid,
257 'created' => REQUEST_TIME,
258 ))
259 ->execute();
260 }
261 catch (Exception $e) {
262 // The exception can be ignored safely.
263 }
264 $fetch_tasks[$cid] = REQUEST_TIME;
265 }
266 }
267
287 function _update_build_fetch_url($project, $site_key = '') {
288 $name = $project['name'];
289 $url = _update_get_fetch_url_base($project);
290 $url .= '/' . $name . '/' . DRUPAL_CORE_COMPATIBILITY;
291
292 // Only append usage information if we have a site key and the project is
293 // enabled. We do not want to record usage statistics for disabled projects.
294 if (!empty($site_key) && (strpos($project['project_type'], 'disabled') === FALSE)) {
295 // Append the site key.
296 $url .= (strpos($url, '?') !== FALSE) ? '&' : '?';
297 $url .= 'site_key=';
298 $url .= rawurlencode($site_key);
299
300 // Append the version.
301 if (!empty($project['info']['version'])) {
302 $url .= '&version=';
303 $url .= rawurlencode($project['info']['version']);
304 }
305
306 // Append the list of modules or themes enabled.
307 $list = array_keys($project['includes']);
308 $url .= '&list=';
309 $url .= rawurlencode(implode(',', $list));
310 }
311 return $url;
312 }
313
327 function _update_get_fetch_url_base($project) {
328 return isset($project['info']['project status url']) ? $project['info']['project status url'] : variable_get('update_fetch_url', UPDATE_DEFAULT_URL);
329 }
330
340 function _update_cron_notify() {
341 module_load_install('update');
342 $status = update_requirements('runtime');
343 $params = array();
344 $notify_all = (variable_get('update_notification_threshold', 'all') == 'all');
345 foreach (array('core', 'contrib') as $report_type) {
346 $type = 'update_' . $report_type;
347 if (isset($status[$type]['severity'])
348 && ($status[$type]['severity'] == REQUIREMENT_ERROR || ($notify_all && $status[$type]['reason'] == UPDATE_NOT_CURRENT))) {
349 $params[$report_type] = $status[$type]['reason'];
350 }
351 }
352 if (!empty($params)) {
353 $notify_list = variable_get('update_notify_emails', '');
354 if (!empty($notify_list)) {
355 $default_language = language_default();
356 foreach ($notify_list as $target) {
357 if ($target_user = user_load_by_mail($target)) {
358 $target_language = user_preferred_language($target_user);
359 }
360 else {
361 $target_language = $default_language;
362 }
363 $message = drupal_mail('update', 'status_notify', $target, $target_language, $params);
364 // Track when the last mail was successfully sent to avoid sending
365 // too many e-mails.
366 if ($message['result']) {
367 variable_set('update_last_email_notification', REQUEST_TIME);
368 }
369 }
370 }
371 }
372 }
373
384 function update_parse_xml($raw_xml) {
385 try {
386 $xml = new SimpleXMLElement($raw_xml);
387 }
388 catch (Exception $e) {
389 // SimpleXMLElement::__construct produces an E_WARNING error message for
390 // each error found in the XML data and throws an exception if errors
391 // were detected. Catch any exception and return failure (NULL).
392 return;
393 }
394 // If there is no valid project data, the XML is invalid, so return failure.
395 if (!isset($xml->short_name)) {
396 return;
397 }
398 $short_name = (string) $xml->short_name;
399 $data = array();
400 foreach ($xml as $k => $v) {
401 $data[$k] = (string) $v;
402 }
403 $data['releases'] = array();
404 if (isset($xml->releases)) {
405 foreach ($xml->releases->children() as $release) {
406 $version = (string) $release->version;
407 $data['releases'][$version] = array();
408 foreach ($release->children() as $k => $v) {
409 $data['releases'][$version][$k] = (string) $v;
410 }
411 $data['releases'][$version]['terms'] = array();
412 if ($release->terms) {
413 foreach ($release->terms->children() as $term) {
414 if (!isset($data['releases'][$version]['terms'][(string) $term->name])) {
415 $data['releases'][$version]['terms'][(string) $term->name] = array();
416 }
417 $data['releases'][$version]['terms'][(string) $term->name][] = (string) $term->value;
418 }
419 }
420 }
421 }
422 return $data;
423 }
batch_process
batch_process($redirect=NULL, $url= 'batch', $redirect_callback= 'drupal_goto')
Definition: form.inc:4459
_update_cache_get
_update_cache_get($cid)
Definition: update.module:799
UPDATE_NOT_CURRENT
const UPDATE_NOT_CURRENT
Definition: update.module:39
update_fetch_data_finished
update_fetch_data_finished($success, $results)
Definition: update.fetch.inc:89
_update_fetch_data
_update_fetch_data()
Definition: update.fetch.inc:108
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
DrupalQueue\get
static get($name, $reliable=FALSE)
Definition: system.queue.inc:81
update_manual_status
update_manual_status()
Definition: update.fetch.inc:15
drupal_get_private_key
drupal_get_private_key()
Definition: common.inc:5056
_update_cache_clear
_update_cache_clear($cid=NULL, $wildcard=FALSE)
Definition: update.module:846
drupal_mail
drupal_mail($module, $key, $to, $language, $params=array(), $from=NULL, $send=TRUE)
Definition: mail.inc:122
update_requirements
update_requirements($phase)
Definition: update.install:28
$name
print $name
Definition: profile-listing.tpl.php:43
_update_create_fetch_task
_update_create_fetch_task($project)
Definition: update.fetch.inc:239
$results
print $results
Definition: poll-results.tpl.php:23
Exception
update_fetch_data_batch
update_fetch_data_batch(&$context)
Definition: update.fetch.inc:37
_update_build_fetch_url
_update_build_fetch_url($project, $site_key= '')
Definition: update.fetch.inc:287
drupal_http_request
drupal_http_request($url, array $options=array())
Definition: common.inc:787
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
drupal_hmac_base64
drupal_hmac_base64($data, $key)
Definition: bootstrap.inc:2047
UPDATE_DEFAULT_URL
const UPDATE_DEFAULT_URL
Definition: update.module:17
module_load_install
module_load_install($module)
Definition: module.inc:288
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
user_load_by_mail
user_load_by_mail($mail)
Definition: user.module:381
_update_process_fetch_task
_update_process_fetch_task($project)
Definition: update.fetch.inc:129
user_preferred_language
user_preferred_language($account, $default=NULL)
Definition: user.module:3524
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
$url
print $url
Definition: search-result.tpl.php:70
batch_set
batch_set($batch_definition)
Definition: form.inc:4381
_update_cache_set
_update_cache_set($cid, $data, $expire)
Definition: update.module:769
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
update_parse_xml
update_parse_xml($raw_xml)
Definition: update.fetch.inc:384
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
update_create_fetch_task
update_create_fetch_task($project)
Definition: update.module:454
_update_get_cache_multiple
_update_get_cache_multiple($cid_prefix)
Definition: update.module:818
_update_cron_notify
_update_cron_notify()
Definition: update.fetch.inc:340
_update_refresh
_update_refresh()
Definition: update.fetch.inc:197
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
update_get_projects
update_get_projects()
Definition: update.compare.inc:56
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
_update_get_fetch_url_base
_update_get_fetch_url_base($project)
Definition: update.fetch.inc:327
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
language_default
language_default($property=NULL)
Definition: bootstrap.inc:2765
DRUPAL_CORE_COMPATIBILITY
const DRUPAL_CORE_COMPATIBILITY
Definition: bootstrap.inc:16
UPDATE_MAX_FETCH_TIME
const UPDATE_MAX_FETCH_TIME
Definition: update.module:74
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
UPDATE_MAX_FETCH_ATTEMPTS
const UPDATE_MAX_FETCH_ATTEMPTS
Definition: update.module:69
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile/profile.install Source File

  • modules
  • profile
profile.install
Go to the documentation of this file.
1 <?php
2
11 function profile_uninstall() {
12 variable_del('profile_block_author_fields');
13 }
14
18 function profile_schema() {
19 $schema['profile_field'] = array(
20 'description' => 'Stores profile field information.',
21 'fields' => array(
22 'fid' => array(
23 'type' => 'serial',
24 'not null' => TRUE,
25 'description' => 'Primary Key: Unique profile field ID.',
26 ),
27 'title' => array(
28 'type' => 'varchar',
29 'length' => 255,
30 'not null' => FALSE,
31 'description' => 'Title of the field shown to the end user.',
32 ),
33 'name' => array(
34 'type' => 'varchar',
35 'length' => 128,
36 'not null' => TRUE,
37 'default' => '',
38 'description' => 'Internal name of the field used in the form HTML and URLs.',
39 ),
40 'explanation' => array(
41 'type' => 'text',
42 'not null' => FALSE,
43 'description' => 'Explanation of the field to end users.',
44 ),
45 'category' => array(
46 'type' => 'varchar',
47 'length' => 255,
48 'not null' => FALSE,
49 'description' => 'Profile category that the field will be grouped under.',
50 ),
51 'page' => array(
52 'type' => 'varchar',
53 'length' => 255,
54 'not null' => FALSE,
55 'description' => "Title of page used for browsing by the field's value",
56 ),
57 'type' => array(
58 'type' => 'varchar',
59 'length' => 128,
60 'not null' => FALSE,
61 'description' => 'Type of form field.',
62 ),
63 'weight' => array(
64 'type' => 'int',
65 'not null' => TRUE,
66 'default' => 0,
67 'description' => 'Weight of field in relation to other profile fields.',
68 ),
69 'required' => array(
70 'type' => 'int',
71 'not null' => TRUE,
72 'default' => 0,
73 'size' => 'tiny',
74 'description' => 'Whether the user is required to enter a value. (0 = no, 1 = yes)',
75 ),
76 'register' => array(
77 'type' => 'int',
78 'not null' => TRUE,
79 'default' => 0,
80 'size' => 'tiny',
81 'description' => 'Whether the field is visible in the user registration form. (1 = yes, 0 = no)',
82 ),
83 'visibility' => array(
84 'type' => 'int',
85 'not null' => TRUE,
86 'default' => 0,
87 'size' => 'tiny',
88 'description' => 'The level of visibility for the field. (0 = hidden, 1 = private, 2 = public on profile but not member list pages, 3 = public on profile and list pages)',
89 ),
90 'autocomplete' => array(
91 'type' => 'int',
92 'not null' => TRUE,
93 'default' => 0,
94 'size' => 'tiny',
95 'description' => 'Whether form auto-completion is enabled. (0 = disabled, 1 = enabled)',
96 ),
97 'options' => array(
98 'type' => 'text',
99 'not null' => FALSE,
100 'description' => 'List of options to be used in a list selection field.',
101 ),
102 ),
103 'indexes' => array(
104 'category' => array('category'),
105 ),
106 'unique keys' => array(
107 'name' => array('name'),
108 ),
109 'primary key' => array('fid'),
110 );
111
112 $schema['profile_value'] = array(
113 'description' => 'Stores values for profile fields.',
114 'fields' => array(
115 'fid' => array(
116 'type' => 'int',
117 'unsigned' => TRUE,
118 'not null' => TRUE,
119 'default' => 0,
120 'description' => 'The {profile_field}.fid of the field.',
121 ),
122 'uid' => array(
123 'type' => 'int',
124 'unsigned' => TRUE,
125 'not null' => TRUE,
126 'default' => 0,
127 'description' => 'The {users}.uid of the profile user.',
128 ),
129 'value' => array(
130 'type' => 'text',
131 'not null' => FALSE,
132 'description' => 'The value for the field.',
133 ),
134 ),
135 'primary key' => array('uid', 'fid'),
136 'indexes' => array(
137 'fid' => array('fid'),
138 ),
139 'foreign keys' => array(
140 'profile_field' => array(
141 'table' => 'profile_field',
142 'columns' => array('fid' => 'fid'),
143 ),
144 'profile_user' => array(
145 'table' => 'users',
146 'columns' => array('uid' => 'uid'),
147 ),
148 ),
149 );
150
151 return $schema;
152 }
153
157 function profile_update_7001() {
158 db_rename_table('profile_fields', 'profile_field');
159 db_rename_table('profile_values', 'profile_value');
160 }
161
165 function profile_update_7002() {
166 db_change_field('profile_field', 'weight', 'weight', array(
167 'type' => 'int',
168 'not null' => TRUE,
169 'default' => 0,
170 'description' => 'Weight of field in relation to other profile fields.',
171 ));
172 }
variable_del
variable_del($name)
Definition: bootstrap.inc:996
profile_update_7001
profile_update_7001()
Definition: profile.install:157
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
profile_update_7002
profile_update_7002()
Definition: profile.install:165
profile_schema
profile_schema()
Definition: profile.install:18
db_rename_table
db_rename_table($table, $new_name)
Definition: database.inc:2805
profile_uninstall
profile_uninstall()
Definition: profile.install:11
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/email_example/email_example.module Source File

  • examples
  • email_example
email_example.module
Go to the documentation of this file.
1 <?php
40 function email_example_mail($key, &$message, $params) {
41 global $user;
42
43 // Each message is associated with a language, which may or may not be the
44 // current user's selected language, depending on the type of e-mail being
45 // sent. This $options array is used later in the t() calls for subject
46 // and body to ensure the proper translation takes effect.
47 $options = array(
48 'langcode' => $message['language']->language,
49 );
50
51 switch ($key) {
52 // Send a simple message from the contact form.
53 case 'contact_message':
54 $message['subject'] = t('E-mail sent from @site-name', array('@site-name' => variable_get('site_name', 'Drupal')), $options);
55 // Note that the message body is an array, not a string.
56 $message['body'][] = t('@name sent you the following message:', array('@name' => $user->name), $options);
57 // Because this is just user-entered text, we do not need to translate it.
58
59 // Since user-entered text may have unintentional HTML entities in it like
60 // '<' or '>', we need to make sure these entities are properly escaped,
61 // as the body will later be transformed from HTML to text, meaning
62 // that a normal use of '<' will result in truncation of the message.
63 $message['body'][] = check_plain($params['message']);
64 break;
65 }
66 }
67
76 function email_example_mail_send($form_values) {
77 // All system mails need to specify the module and template key (mirrored from
78 // hook_mail()) that the message they want to send comes from.
79 $module = 'email_example';
80 $key = 'contact_message';
81
82 // Specify 'to' and 'from' addresses.
83 $to = $form_values['email'];
84 $from = variable_get('site_mail', 'admin@example.com');
85
86 // "params" loads in additional context for email content completion in
87 // hook_mail(). In this case, we want to pass in the values the user entered
88 // into the form, which include the message body in $form_values['message'].
89 $params = $form_values;
90
91 // The language of the e-mail. This will one of three values:
92 // * user_preferred_language(): Used for sending mail to a particular website
93 // user, so that the mail appears in their preferred language.
94 // * global $language: Used when sending a mail back to the user currently
95 // viewing the site. This will send it in the language they're currently
96 // using.
97 // * language_default(): Used when sending mail to a pre-existing, 'neutral'
98 // address, such as the system e-mail address, or when you're unsure of the
99 // language preferences of the intended recipient.
100 //
101 // Since in our case, we are sending a message to a random e-mail address that
102 // is not necessarily tied to a user account, we will use the site's default
103 // language.
104 $language = language_default();
105
106 // Whether or not to automatically send the mail when drupal_mail() is
107 // called. This defaults to TRUE, and is normally what you want unless you
108 // need to do additional processing before drupal_mail_send() is called.
109 $send = TRUE;
110 // Send the mail, and check for success. Note that this does not guarantee
111 // message delivery; only that there were no PHP-related issues encountered
112 // while sending.
113 $result = drupal_mail($module, $key, $to, $language, $params, $from, $send);
114 if ($result['result'] == TRUE) {
115 drupal_set_message(t('Your message has been sent.'));
116 }
117 else {
118 drupal_set_message(t('There was a problem sending your message and it was not sent.'), 'error');
119 }
120
121 }
122
133 function email_example_mail_alter(&$message) {
134 // For the purpose of this example, modify all the outgoing messages and
135 // attach a site signature. The signature will be translated to the language
136 // in which message was built.
137 $options = array(
138 'langcode' => $message['language']->language,
139 );
140
141 $signature = t("\n--\nMail altered by email_example module.", array(), $options);
142 if (is_array($message['body'])) {
143 $message['body'][] = $signature;
144 }
145 else { // Some modules use the body as a string, erroneously.
146 $message['body'] .= $signature;
147 }
148 }
149
151
157 function email_example_menu() {
158 $items['example/email_example'] = array(
159 'title' => 'E-mail Example: contact form',
160 'page callback' => 'drupal_get_form',
161 'page arguments' => array('email_example_form'),
162 'access arguments' => array('access content'),
163 );
164
165 return $items;
166 }
167
171 function email_example_form() {
172 $form['intro'] = array(
173 '#markup' => t('Use this form to send a message to an e-mail address. No spamming!'),
174 );
175 $form['email'] = array(
176 '#type' => 'textfield',
177 '#title' => t('E-mail address'),
178 '#required' => TRUE,
179 );
180 $form['message'] = array(
181 '#type' => 'textarea',
182 '#title' => t('Message'),
183 '#required' => TRUE,
184 );
185 $form['submit'] = array(
186 '#type' => 'submit',
187 '#value' => t('Submit'),
188 );
189
190 return $form;
191 }
192
196 function email_example_form_validate($form, &$form_state) {
197 if (!valid_email_address($form_state['values']['email'])) {
198 form_set_error('email', t('That e-mail address is not valid.'));
199 }
200 }
201
205 function email_example_form_submit($form, &$form_state) {
206 email_example_mail_send($form_state['values']);
207 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
$module
print $module
Definition: search-results.tpl.php:28
drupal_mail
drupal_mail($module, $key, $to, $language, $params=array(), $from=NULL, $send=TRUE)
Definition: mail.inc:122
email_example_form
email_example_form()
Definition: email_example.module:171
email_example_form_validate
email_example_form_validate($form, &$form_state)
Definition: email_example.module:196
email_example_form_submit
email_example_form_submit($form, &$form_state)
Definition: email_example.module:205
email_example_mail_alter
email_example_mail_alter(&$message)
Definition: email_example.module:133
email_example_menu
email_example_menu()
Definition: email_example.module:157
email_example_mail_send
email_example_mail_send($form_values)
Definition: email_example.module:76
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
language
print $language language
Definition: book-export-html.tpl.php:22
valid_email_address
valid_email_address($mail)
Definition: common.inc:1186
language_default
language_default($property=NULL)
Definition: bootstrap.inc:2765
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
email_example_mail
email_example_mail($key, &$message, $params)
Definition: email_example.module:40
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/contact/contact.admin.inc Source File

  • modules
  • contact
contact.admin.inc
Go to the documentation of this file.
1 <?php
2
11 function contact_category_list() {
12 $header = array(
13 t('Category'),
14 t('Recipients'),
15 t('Selected'),
16 array('data' => t('Operations'), 'colspan' => 2),
17 );
18 $rows = array();
19
20 // Get all the contact categories from the database.
21 $categories = db_select('contact', 'c')
22 ->addTag('translatable')
23 ->fields('c', array('cid', 'category', 'recipients', 'selected'))
24 ->orderBy('weight')
25 ->orderBy('category')
26 ->execute()
27 ->fetchAll();
28
29 // Loop through the categories and add them to the table.
30 foreach ($categories as $category) {
31 $rows[] = array(
32 check_plain($category->category),
33 check_plain($category->recipients),
34 ($category->selected ? t('Yes') : t('No')),
35 l(t('Edit'), 'admin/structure/contact/edit/' . $category->cid),
36 l(t('Delete'), 'admin/structure/contact/delete/' . $category->cid),
37 );
38 }
39
40 if (!$rows) {
41 $rows[] = array(array(
42 'data' => t('No categories available.'),
43 'colspan' => 5,
44 ));
45 }
46
47 $build['category_table'] = array(
48 '#theme' => 'table',
49 '#header' => $header,
50 '#rows' => $rows,
51 );
52 return $build;
53 }
54
73 function contact_category_edit_form($form, &$form_state, array $category = array()) {
74 // If this is a new category, add the default values.
75 $category += array(
76 'category' => '',
77 'recipients' => '',
78 'reply' => '',
79 'weight' => 0,
80 'selected' => 0,
81 'cid' => NULL,
82 );
83
84 $form['category'] = array(
85 '#type' => 'textfield',
86 '#title' => t('Category'),
87 '#maxlength' => 255,
88 '#default_value' => $category['category'],
89 '#description' => t("Example: 'website feedback' or 'product information'."),
90 '#required' => TRUE,
91 );
92 $form['recipients'] = array(
93 '#type' => 'textarea',
94 '#title' => t('Recipients'),
95 '#default_value' => $category['recipients'],
96 '#description' => t("Example: 'webmaster@example.com' or 'sales@example.com,support@example.com' . To specify multiple recipients, separate each e-mail address with a comma."),
97 '#required' => TRUE,
98 );
99 $form['reply'] = array(
100 '#type' => 'textarea',
101 '#title' => t('Auto-reply'),
102 '#default_value' => $category['reply'],
103 '#description' => t('Optional auto-reply. Leave empty if you do not want to send the user an auto-reply message.'),
104 );
105 $form['weight'] = array(
106 '#type' => 'weight',
107 '#title' => t('Weight'),
108 '#default_value' => $category['weight'],
109 '#description' => t('When listing categories, those with lighter (smaller) weights get listed before categories with heavier (larger) weights. Categories with equal weights are sorted alphabetically.'),
110 );
111 $form['selected'] = array(
112 '#type' => 'select',
113 '#title' => t('Selected'),
114 '#options' => array(
115 0 => t('No'),
116 1 => t('Yes'),
117 ),
118 '#default_value' => $category['selected'],
119 '#description' => t('Set this to <em>Yes</em> if you would like this category to be selected by default.'),
120 );
121 $form['cid'] = array(
122 '#type' => 'value',
123 '#value' => $category['cid'],
124 );
125 $form['actions'] = array('#type' => 'actions');
126 $form['actions']['submit'] = array(
127 '#type' => 'submit',
128 '#value' => t('Save'),
129 );
130
131 return $form;
132 }
133
139 function contact_category_edit_form_validate($form, &$form_state) {
140 // Validate and each e-mail recipient.
141 $recipients = explode(',', $form_state['values']['recipients']);
142
143 // When creating a new contact form, or renaming the category on an existing
144 // contact form, make sure that the given category is unique.
145 $category = $form_state['values']['category'];
146 $query = db_select('contact', 'c')->condition('c.category', $category, '=');
147 if (!empty($form_state['values']['cid'])) {
148 $query->condition('c.cid', $form_state['values']['cid'], '<>');
149 }
150 if ($query->countQuery()->execute()->fetchField()) {
151 form_set_error('category', t('A contact form with category %category already exists.', array('%category' => $category)));
152 }
153
154 foreach ($recipients as &$recipient) {
155 $recipient = trim($recipient);
156 if (!valid_email_address($recipient)) {
157 form_set_error('recipients', t('%recipient is an invalid e-mail address.', array('%recipient' => $recipient)));
158 }
159 }
160 $form_state['values']['recipients'] = implode(',', $recipients);
161 }
162
168 function contact_category_edit_form_submit($form, &$form_state) {
169 if ($form_state['values']['selected']) {
170 // Unselect all other contact categories.
171 db_update('contact')
172 ->fields(array('selected' => '0'))
173 ->execute();
174 }
175
176 if (empty($form_state['values']['cid'])) {
177 drupal_write_record('contact', $form_state['values']);
178 }
179 else {
180 drupal_write_record('contact', $form_state['values'], array('cid'));
181 }
182
183 drupal_set_message(t('Category %category has been saved.', array('%category' => $form_state['values']['category'])));
184 watchdog('contact', 'Category %category has been saved.', array('%category' => $form_state['values']['category']), WATCHDOG_NOTICE, l(t('Edit'), 'admin/structure/contact/edit/' . $form_state['values']['cid']));
185 $form_state['redirect'] = 'admin/structure/contact';
186 }
187
198 function contact_category_delete_form($form, &$form_state, array $contact) {
199 $form['contact'] = array(
200 '#type' => 'value',
201 '#value' => $contact,
202 );
203
204 return confirm_form(
205 $form,
206 t('Are you sure you want to delete %category?', array('%category' => $contact['category'])),
207 'admin/structure/contact',
208 t('This action cannot be undone.'),
209 t('Delete'),
210 t('Cancel')
211 );
212 }
213
217 function contact_category_delete_form_submit($form, &$form_state) {
218 $contact = $form['contact']['#value'];
219
220 db_delete('contact')
221 ->condition('cid', $contact['cid'])
222 ->execute();
223
224 drupal_set_message(t('Category %category has been deleted.', array('%category' => $contact['category'])));
225 watchdog('contact', 'Category %category has been deleted.', array('%category' => $contact['category']), WATCHDOG_NOTICE);
226
227 $form_state['redirect'] = 'admin/structure/contact';
228 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
l
l($text, $path, array $options=array())
Definition: common.inc:2432
contact_category_delete_form
contact_category_delete_form($form, &$form_state, array $contact)
Definition: contact.admin.inc:198
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$header
print $header
Definition: forum-topic-list.tpl.php:42
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
contact_category_delete_form_submit
contact_category_delete_form_submit($form, &$form_state)
Definition: contact.admin.inc:217
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
contact_category_edit_form_submit
contact_category_edit_form_submit($form, &$form_state)
Definition: contact.admin.inc:168
contact_category_edit_form_validate
contact_category_edit_form_validate($form, &$form_state)
Definition: contact.admin.inc:139
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
valid_email_address
valid_email_address($mail)
Definition: common.inc:1186
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
contact_category_list
contact_category_list()
Definition: contact.admin.inc:11
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
contact_category_edit_form
contact_category_edit_form($form, &$form_state, array $category=array())
Definition: contact.admin.inc:73
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/install.core.inc Source File

  • includes
install.core.inc
Go to the documentation of this file.
1 <?php
2
19 define('INSTALL_TASK_SKIP', 1);
20
26 define('INSTALL_TASK_RUN_IF_REACHED', 2);
27
40 define('INSTALL_TASK_RUN_IF_NOT_COMPLETED', 3);
41
64 function install_drupal($settings = array()) {
65 global $install_state;
66 // Initialize the installation state with the settings that were passed in,
67 // as well as a boolean indicating whether or not this is an interactive
68 // installation.
69 $interactive = empty($settings);
70 $install_state = $settings + array('interactive' => $interactive) + install_state_defaults();
71 try {
72 // Begin the page request. This adds information about the current state of
73 // the Drupal installation to the passed-in array.
74 install_begin_request($install_state);
75 // Based on the installation state, run the remaining tasks for this page
76 // request, and collect any output.
77 $output = install_run_tasks($install_state);
78 }
79 catch (Exception $e) {
80 // When an installation error occurs, either send the error to the web
81 // browser or pass on the exception so the calling script can use it.
82 if ($install_state['interactive']) {
83 install_display_output($e->getMessage(), $install_state);
84 }
85 else {
86 throw $e;
87 }
88 }
89 // All available tasks for this page request are now complete. Interactive
90 // installations can send output to the browser or redirect the user to the
91 // next page.
92 if ($install_state['interactive']) {
93 if ($install_state['parameters_changed']) {
94 // Redirect to the correct page if the URL parameters have changed.
95 install_goto(install_redirect_url($install_state));
96 }
97 elseif (isset($output)) {
98 // Display a page only if some output is available. Otherwise it is
99 // possible that we are printing a JSON page and theme output should
100 // not be shown.
101 install_display_output($output, $install_state);
102 }
103 }
104 }
105
124 function install_state_defaults() {
125 $defaults = array(
126 // The current task being processed.
127 'active_task' => NULL,
128 // The last task that was completed during the previous installation
129 // request.
130 'completed_task' => NULL,
131 // This becomes TRUE only when Drupal's system module is installed.
132 'database_tables_exist' => FALSE,
133 // An array of forms to be programmatically submitted during the
134 // installation. The keys of each element indicate the name of the
135 // installation task that the form submission is for, and the values are
136 // used as the $form_state['values'] array that is passed on to the form
137 // submission via drupal_form_submit().
138 'forms' => array(),
139 // This becomes TRUE only at the end of the installation process, after
140 // all available tasks have been completed and Drupal is fully installed.
141 // It is used by the installer to store correct information in the database
142 // about the completed installation, as well as to inform theme functions
143 // that all tasks are finished (so that the task list can be displayed
144 // correctly).
145 'installation_finished' => FALSE,
146 // Whether or not this installation is interactive. By default this will
147 // be set to FALSE if settings are passed in to install_drupal().
148 'interactive' => TRUE,
149 // An array of available languages for the installation.
150 'locales' => array(),
151 // An array of parameters for the installation, pre-populated by the URL
152 // or by the settings passed in to install_drupal(). This is primarily
153 // used to store 'profile' (the name of the chosen installation profile)
154 // and 'locale' (the name of the chosen installation language), since
155 // these settings need to persist from page request to page request before
156 // the database is available for storage.
157 'parameters' => array(),
158 // Whether or not the parameters have changed during the current page
159 // request. For interactive installations, this will trigger a page
160 // redirect.
161 'parameters_changed' => FALSE,
162 // An array of information about the chosen installation profile. This will
163 // be filled in based on the profile's .info file.
164 'profile_info' => array(),
165 // An array of available installation profiles.
166 'profiles' => array(),
167 // An array of server variables that will be substituted into the global
168 // $_SERVER array via drupal_override_server_variables(). Used by
169 // non-interactive installations only.
170 'server' => array(),
171 // This becomes TRUE only when a valid database connection can be
172 // established.
173 'settings_verified' => FALSE,
174 // Installation tasks can set this to TRUE to force the page request to
175 // end (even if there is no themable output), in the case of an interactive
176 // installation. This is needed only rarely; for example, it would be used
177 // by an installation task that prints JSON output rather than returning a
178 // themed page. The most common example of this is during batch processing,
179 // but the Drupal installer automatically takes care of setting this
180 // parameter properly in that case, so that individual installation tasks
181 // which implement the batch API do not need to set it themselves.
182 'stop_page_request' => FALSE,
183 // Installation tasks can set this to TRUE to indicate that the task should
184 // be run again, even if it normally wouldn't be. This can be used, for
185 // example, if a single task needs to be spread out over multiple page
186 // requests, or if it needs to perform some validation before allowing
187 // itself to be marked complete. The most common examples of this are batch
188 // processing and form submissions, but the Drupal installer automatically
189 // takes care of setting this parameter properly in those cases, so that
190 // individual installation tasks which implement the batch API or form API
191 // do not need to set it themselves.
192 'task_not_complete' => FALSE,
193 // A list of installation tasks which have already been performed during
194 // the current page request.
195 'tasks_performed' => array(),
196 );
197 return $defaults;
198 }
199
210 function install_begin_request(&$install_state) {
211 // Add any installation parameters passed in via the URL.
212 $install_state['parameters'] += $_GET;
213
214 // Validate certain core settings that are used throughout the installation.
215 if (!empty($install_state['parameters']['profile'])) {
216 $install_state['parameters']['profile'] = preg_replace('/[^a-zA-Z_0-9]/', '', $install_state['parameters']['profile']);
217 }
218 if (!empty($install_state['parameters']['locale'])) {
219 $install_state['parameters']['locale'] = preg_replace('/[^a-zA-Z_0-9\-]/', '', $install_state['parameters']['locale']);
220 }
221
222 // Allow command line scripts to override server variables used by Drupal.
223 require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
224 if (!$install_state['interactive']) {
225 drupal_override_server_variables($install_state['server']);
226 }
227
228 // The user agent header is used to pass a database prefix in the request when
229 // running tests. However, for security reasons, it is imperative that no
230 // installation be permitted using such a prefix.
231 if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], "simpletest") !== FALSE) {
232 header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
233 exit;
234 }
235
236 drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
237
238 // This must go after drupal_bootstrap(), which unsets globals!
239 global $conf;
240
241 require_once DRUPAL_ROOT . '/modules/system/system.install';
242 require_once DRUPAL_ROOT . '/includes/common.inc';
243 require_once DRUPAL_ROOT . '/includes/file.inc';
244 require_once DRUPAL_ROOT . '/includes/install.inc';
245 require_once DRUPAL_ROOT . '/' . variable_get('path_inc', 'includes/path.inc');
246
247 // Load module basics (needed for hook invokes).
248 include_once DRUPAL_ROOT . '/includes/module.inc';
249 include_once DRUPAL_ROOT . '/includes/session.inc';
250
251 // Set up $language, so t() caller functions will still work.
252 drupal_language_initialize();
253
254 include_once DRUPAL_ROOT . '/includes/entity.inc';
255 require_once DRUPAL_ROOT . '/includes/ajax.inc';
256 $module_list['system']['filename'] = 'modules/system/system.module';
257 $module_list['user']['filename'] = 'modules/user/user.module';
258 module_list(TRUE, FALSE, FALSE, $module_list);
259 drupal_load('module', 'system');
260 drupal_load('module', 'user');
261
262 // Load the cache infrastructure using a "fake" cache implementation that
263 // does not attempt to write to the database. We need this during the initial
264 // part of the installer because the database is not available yet. We
265 // continue to use it even when the database does become available, in order
266 // to preserve consistency between interactive and command-line installations
267 // (the latter complete in one page request and therefore are forced to
268 // continue using the cache implementation they started with) and also
269 // because any data put in the cache during the installer is inherently
270 // suspect, due to the fact that Drupal is not fully set up yet.
271 require_once DRUPAL_ROOT . '/includes/cache.inc';
272 require_once DRUPAL_ROOT . '/includes/cache-install.inc';
273 $conf['cache_default_class'] = 'DrupalFakeCache';
274
275 // Prepare for themed output. We need to run this at the beginning of the
276 // page request to avoid a different theme accidentally getting set. (We also
277 // need to run it even in the case of command-line installations, to prevent
278 // any code in the installer that happens to initialize the theme system from
279 // accessing the database before it is set up yet.)
280 drupal_maintenance_theme();
281
282 // Check existing settings.php.
283 $install_state['settings_verified'] = install_verify_settings();
284
285 if ($install_state['settings_verified']) {
286 // Initialize the database system. Note that the connection
287 // won't be initialized until it is actually requested.
288 require_once DRUPAL_ROOT . '/includes/database/database.inc';
289
290 // Verify the last completed task in the database, if there is one.
291 $task = install_verify_completed_task();
292 }
293 else {
294 $task = NULL;
295
296 // Do not install over a configured settings.php. Check the 'db_url'
297 // variable in addition to 'databases', since previous versions of Drupal
298 // used that (and we do not want to allow installations on an existing site
299 // whose settings file has not yet been updated).
300 if (!empty($GLOBALS['databases']) || !empty($GLOBALS['db_url'])) {
301 throw new Exception(install_already_done_error());
302 }
303 }
304
305 // Modify the installation state as appropriate.
306 $install_state['completed_task'] = $task;
307 $install_state['database_tables_exist'] = !empty($task);
308 }
309
325 function install_run_tasks(&$install_state) {
326 do {
327 // Obtain a list of tasks to perform. The list of tasks itself can be
328 // dynamic (e.g., some might be defined by the installation profile,
329 // which is not necessarily known until the earlier tasks have run),
330 // so we regenerate the remaining tasks based on the installation state,
331 // each time through the loop.
332 $tasks_to_perform = install_tasks_to_perform($install_state);
333 // Run the first task on the list.
334 reset($tasks_to_perform);
335 $task_name = key($tasks_to_perform);
336 $task = array_shift($tasks_to_perform);
337 $install_state['active_task'] = $task_name;
338 $original_parameters = $install_state['parameters'];
339 $output = install_run_task($task, $install_state);
340 $install_state['parameters_changed'] = ($install_state['parameters'] != $original_parameters);
341 // Store this task as having been performed during the current request,
342 // and save it to the database as completed, if we need to and if the
343 // database is in a state that allows us to do so. Also mark the
344 // installation as 'done' when we have run out of tasks.
345 if (!$install_state['task_not_complete']) {
346 $install_state['tasks_performed'][] = $task_name;
347 $install_state['installation_finished'] = empty($tasks_to_perform);
348 if ($install_state['database_tables_exist'] && ($task['run'] == INSTALL_TASK_RUN_IF_NOT_COMPLETED || $install_state['installation_finished'])) {
349 variable_set('install_task', $install_state['installation_finished'] ? 'done' : $task_name);
350 }
351 }
352 // Stop when there are no tasks left. In the case of an interactive
353 // installation, also stop if we have some output to send to the browser,
354 // the URL parameters have changed, or an end to the page request was
355 // specifically called for.
356 $finished = empty($tasks_to_perform) || ($install_state['interactive'] && (isset($output) || $install_state['parameters_changed'] || $install_state['stop_page_request']));
357 } while (!$finished);
358 return $output;
359 }
360
373 function install_run_task($task, &$install_state) {
374 $function = $task['function'];
375
376 if ($task['type'] == 'form') {
377 require_once DRUPAL_ROOT . '/includes/form.inc';
378 if ($install_state['interactive']) {
379 // For interactive forms, build the form and ensure that it will not
380 // redirect, since the installer handles its own redirection only after
381 // marking the form submission task complete.
382 $form_state = array(
383 // We need to pass $install_state by reference in order for forms to
384 // modify it, since the form API will use it in call_user_func_array(),
385 // which requires that referenced variables be passed explicitly.
386 'build_info' => array('args' => array(&$install_state)),
387 'no_redirect' => TRUE,
388 );
389 $form = drupal_build_form($function, $form_state);
390 // If a successful form submission did not occur, the form needs to be
391 // rendered, which means the task is not complete yet.
392 if (empty($form_state['executed'])) {
393 $install_state['task_not_complete'] = TRUE;
394 return drupal_render($form);
395 }
396 // Otherwise, return nothing so the next task will run in the same
397 // request.
398 return;
399 }
400 else {
401 // For non-interactive forms, submit the form programmatically with the
402 // values taken from the installation state. Throw an exception if any
403 // errors were encountered.
404 $form_state = array(
405 'values' => !empty($install_state['forms'][$function]) ? $install_state['forms'][$function] : array(),
406 // We need to pass $install_state by reference in order for forms to
407 // modify it, since the form API will use it in call_user_func_array(),
408 // which requires that referenced variables be passed explicitly.
409 'build_info' => array('args' => array(&$install_state)),
410 );
411 drupal_form_submit($function, $form_state);
412 $errors = form_get_errors();
413 if (!empty($errors)) {
414 throw new Exception(implode("\n", $errors));
415 }
416 }
417 }
418
419 elseif ($task['type'] == 'batch') {
420 // Start a new batch based on the task function, if one is not running
421 // already.
422 $current_batch = variable_get('install_current_batch');
423 if (!$install_state['interactive'] || !$current_batch) {
424 $batch = $function($install_state);
425 if (empty($batch)) {
426 // If the task did some processing and decided no batch was necessary,
427 // there is nothing more to do here.
428 return;
429 }
430 batch_set($batch);
431 // For interactive batches, we need to store the fact that this batch
432 // task is currently running. Otherwise, we need to make sure the batch
433 // will complete in one page request.
434 if ($install_state['interactive']) {
435 variable_set('install_current_batch', $function);
436 }
437 else {
438 $batch =& batch_get();
439 $batch['progressive'] = FALSE;
440 }
441 // Process the batch. For progressive batches, this will redirect.
442 // Otherwise, the batch will complete.
443 batch_process(install_redirect_url($install_state), install_full_redirect_url($install_state));
444 }
445 // If we are in the middle of processing this batch, keep sending back
446 // any output from the batch process, until the task is complete.
447 elseif ($current_batch == $function) {
448 include_once DRUPAL_ROOT . '/includes/batch.inc';
449 $output = _batch_page();
450 // The task is complete when we try to access the batch page and receive
451 // FALSE in return, since this means we are at a URL where we are no
452 // longer requesting a batch ID.
453 if ($output === FALSE) {
454 // Return nothing so the next task will run in the same request.
455 variable_del('install_current_batch');
456 return;
457 }
458 else {
459 // We need to force the page request to end if the task is not
460 // complete, since the batch API sometimes prints JSON output
461 // rather than returning a themed page.
462 $install_state['task_not_complete'] = $install_state['stop_page_request'] = TRUE;
463 return $output;
464 }
465 }
466 }
467
468 else {
469 // For normal tasks, just return the function result, whatever it is.
470 return $function($install_state);
471 }
472 }
473
487 function install_tasks_to_perform($install_state) {
488 // Start with a list of all currently available tasks.
489 $tasks = install_tasks($install_state);
490 foreach ($tasks as $name => $task) {
491 // Remove any tasks that were already performed or that never should run.
492 // Also, if we started this page request with an indication of the last
493 // task that was completed, skip that task and all those that come before
494 // it, unless they are marked as always needing to run.
495 if ($task['run'] == INSTALL_TASK_SKIP || in_array($name, $install_state['tasks_performed']) || (!empty($install_state['completed_task']) && empty($completed_task_found) && $task['run'] != INSTALL_TASK_RUN_IF_REACHED)) {
496 unset($tasks[$name]);
497 }
498 if (!empty($install_state['completed_task']) && $name == $install_state['completed_task']) {
499 $completed_task_found = TRUE;
500 }
501 }
502 return $tasks;
503 }
504
520 function install_tasks($install_state) {
521 // Determine whether translation import tasks will need to be performed.
522 $needs_translations = count($install_state['locales']) > 1 && !empty($install_state['parameters']['locale']) && $install_state['parameters']['locale'] != 'en';
523
524 // Start with the core installation tasks that run before handing control
525 // to the installation profile.
526 $tasks = array(
527 'install_select_profile' => array(
528 'display_name' => st('Choose profile'),
529 'display' => count($install_state['profiles']) != 1,
530 'run' => INSTALL_TASK_RUN_IF_REACHED,
531 ),
532 'install_select_locale' => array(
533 'display_name' => st('Choose language'),
534 'run' => INSTALL_TASK_RUN_IF_REACHED,
535 ),
536 'install_load_profile' => array(
537 'run' => INSTALL_TASK_RUN_IF_REACHED,
538 ),
539 'install_verify_requirements' => array(
540 'display_name' => st('Verify requirements'),
541 ),
542 'install_settings_form' => array(
543 'display_name' => st('Set up database'),
544 'type' => 'form',
545 'run' => $install_state['settings_verified'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED,
546 ),
547 'install_system_module' => array(
548 ),
549 'install_bootstrap_full' => array(
550 'run' => INSTALL_TASK_RUN_IF_REACHED,
551 ),
552 'install_profile_modules' => array(
553 'display_name' => count($install_state['profiles']) == 1 ? st('Install site') : st('Install profile'),
554 'type' => 'batch',
555 ),
556 'install_import_locales' => array(
557 'display_name' => st('Set up translations'),
558 'display' => $needs_translations,
559 'type' => 'batch',
560 'run' => $needs_translations ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
561 ),
562 'install_configure_form' => array(
563 'display_name' => st('Configure site'),
564 'type' => 'form',
565 ),
566 );
567
568 // Now add any tasks defined by the installation profile.
569 if (!empty($install_state['parameters']['profile'])) {
570 // Load the profile install file, because it is not always loaded when
571 // hook_install_tasks() is invoked (e.g. batch processing).
572 $profile_install_file = DRUPAL_ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.install';
573 if (file_exists($profile_install_file)) {
574 include_once $profile_install_file;
575 }
576 $function = $install_state['parameters']['profile'] . '_install_tasks';
577 if (function_exists($function)) {
578 $result = $function($install_state);
579 if (is_array($result)) {
580 $tasks += $result;
581 }
582 }
583 }
584
585 // Finish by adding the remaining core tasks.
586 $tasks += array(
587 'install_import_locales_remaining' => array(
588 'display_name' => st('Finish translations'),
589 'display' => $needs_translations,
590 'type' => 'batch',
591 'run' => $needs_translations ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
592 ),
593 'install_finished' => array(
594 'display_name' => st('Finished'),
595 ),
596 );
597
598 // Allow the installation profile to modify the full list of tasks.
599 if (!empty($install_state['parameters']['profile'])) {
600 $profile_file = DRUPAL_ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.profile';
601 if (file_exists($profile_file)) {
602 include_once $profile_file;
603 $function = $install_state['parameters']['profile'] . '_install_tasks_alter';
604 if (function_exists($function)) {
605 $function($tasks, $install_state);
606 }
607 }
608 }
609
610 // Fill in default parameters for each task before returning the list.
611 foreach ($tasks as $task_name => &$task) {
612 $task += array(
613 'display_name' => NULL,
614 'display' => !empty($task['display_name']),
615 'type' => 'normal',
616 'run' => INSTALL_TASK_RUN_IF_NOT_COMPLETED,
617 'function' => $task_name,
618 );
619 }
620 return $tasks;
621 }
622
638 function install_tasks_to_display($install_state) {
639 $displayed_tasks = array();
640 foreach (install_tasks($install_state) as $name => $task) {
641 if ($task['display']) {
642 $displayed_tasks[$name] = $task['display_name'];
643 }
644 }
645 return $displayed_tasks;
646 }
647
661 function install_redirect_url($install_state) {
662 return 'install.php?' . drupal_http_build_query($install_state['parameters']);
663 }
664
676 function install_full_redirect_url($install_state) {
677 global $base_url;
678 return $base_url . '/' . install_redirect_url($install_state);
679 }
680
693 function install_display_output($output, $install_state) {
694 drupal_page_header();
695
696 // Prevent install.php from being indexed when installed in a sub folder.
697 // robots.txt rules are not read if the site is within domain.com/subfolder
698 // resulting in /subfolder/install.php being found through search engines.
699 // When settings.php is writeable this can be used via an external database
700 // leading a malicious user to gain php access to the server.
701 $noindex_meta_tag = array(
702 '#tag' => 'meta',
703 '#attributes' => array(
704 'name' => 'robots',
705 'content' => 'noindex, nofollow',
706 ),
707 );
708 drupal_add_html_head($noindex_meta_tag, 'install_meta_robots');
709
710 // Only show the task list if there is an active task; otherwise, the page
711 // request has ended before tasks have even been started, so there is nothing
712 // meaningful to show.
713 if (isset($install_state['active_task'])) {
714 // Let the theming function know when every step of the installation has
715 // been completed.
716 $active_task = $install_state['installation_finished'] ? NULL : $install_state['active_task'];
717 drupal_add_region_content('sidebar_first', theme('task_list', array('items' => install_tasks_to_display($install_state), 'active' => $active_task)));
718 }
719 print theme('install_page', array('content' => $output));
720 exit;
721 }
722
736 function install_verify_requirements(&$install_state) {
737 // Check the installation requirements for Drupal and this profile.
738 $requirements = install_check_requirements($install_state);
739
740 // Verify existence of all required modules.
741 $requirements += drupal_verify_profile($install_state);
742
743 // Check the severity of the requirements reported.
744 $severity = drupal_requirements_severity($requirements);
745
746 // If there are errors, always display them. If there are only warnings, skip
747 // them if the user has provided a URL parameter acknowledging the warnings
748 // and indicating a desire to continue anyway. See drupal_requirements_url().
749 if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && empty($install_state['parameters']['continue']))) {
750 if ($install_state['interactive']) {
751 drupal_set_title(st('Requirements problem'));
752 $status_report = theme('status_report', array('requirements' => $requirements));
753 $status_report .= st('Check the error messages and <a href="!url">proceed with the installation</a>.', array('!url' => check_url(drupal_requirements_url($severity))));
754 return $status_report;
755 }
756 else {
757 // Throw an exception showing any unmet requirements.
758 $failures = array();
759 foreach ($requirements as $requirement) {
760 // Skip warnings altogether for non-interactive installations; these
761 // proceed in a single request so there is no good opportunity (and no
762 // good method) to warn the user anyway.
763 if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
764 $failures[] = $requirement['title'] . ': ' . $requirement['value'] . "\n\n" . $requirement['description'];
765 }
766 }
767 if (!empty($failures)) {
768 throw new Exception(implode("\n\n", $failures));
769 }
770 }
771 }
772 }
773
780 function install_system_module(&$install_state) {
781 // Install system.module.
782 drupal_install_system();
783
784 // Call file_ensure_htaccess() to ensure that all of Drupal's standard
785 // directories (e.g., the public and private files directories) have
786 // appropriate .htaccess files. These directories will have already been
787 // created by this point in the installer, since Drupal creates them during
788 // the install_verify_requirements() task. Note that we cannot call
789 // file_ensure_htaccess() any earlier than this, since it relies on
790 // system.module in order to work.
791 file_ensure_htaccess();
792
793 // Enable the user module so that sessions can be recorded during the
794 // upcoming bootstrap step.
795 module_enable(array('user'), FALSE);
796
797 // Save the list of other modules to install for the upcoming tasks.
798 // variable_set() can be used now that system.module is installed.
799 $modules = $install_state['profile_info']['dependencies'];
800
801 // The installation profile is also a module, which needs to be installed
802 // after all the dependencies have been installed.
803 $modules[] = drupal_get_profile();
804
805 variable_set('install_profile_modules', array_diff($modules, array('system')));
806 $install_state['database_tables_exist'] = TRUE;
807 }
808
816 function install_verify_completed_task() {
817 try {
818 if ($result = db_query("SELECT value FROM {variable} WHERE name = :name", array('name' => 'install_task'))) {
819 $task = unserialize($result->fetchField());
820 }
821 }
822 // Do not trigger an error if the database query fails, since the database
823 // might not be set up yet.
824 catch (Exception $e) {
825 }
826 if (isset($task)) {
827 if ($task == 'done') {
828 throw new Exception(install_already_done_error());
829 }
830 return $task;
831 }
832 }
833
837 function install_verify_settings() {
838 global $databases;
839
840 // Verify existing settings (if any).
841 if (!empty($databases) && install_verify_pdo()) {
842 $database = $databases['default']['default'];
843 drupal_static_reset('conf_path');
844 $settings_file = './' . conf_path(FALSE) . '/settings.php';
845 $errors = install_database_errors($database, $settings_file);
846 if (empty($errors)) {
847 return TRUE;
848 }
849 }
850 return FALSE;
851 }
852
856 function install_verify_pdo() {
857 // PDO was moved to PHP core in 5.2.0, but the old extension (targeting 5.0
858 // and 5.1) is still available from PECL, and can still be built without
859 // errors. To verify that the correct version is in use, we check the
860 // PDO::ATTR_DEFAULT_FETCH_MODE constant, which is not available in the
861 // PECL extension.
862 return extension_loaded('pdo') && defined('PDO::ATTR_DEFAULT_FETCH_MODE');
863 }
864
875 function install_settings_form($form, &$form_state, &$install_state) {
876 global $databases;
877 $profile = $install_state['parameters']['profile'];
878 $install_locale = $install_state['parameters']['locale'];
879
880 drupal_static_reset('conf_path');
881 $conf_path = './' . conf_path(FALSE);
882 $settings_file = $conf_path . '/settings.php';
883 $database = isset($databases['default']['default']) ? $databases['default']['default'] : array();
884
885 drupal_set_title(st('Database configuration'));
886
887 $drivers = drupal_get_database_types();
888 $drivers_keys = array_keys($drivers);
889
890 $form['driver'] = array(
891 '#type' => 'radios',
892 '#title' => st('Database type'),
893 '#required' => TRUE,
894 '#default_value' => !empty($database['driver']) ? $database['driver'] : current($drivers_keys),
895 '#description' => st('The type of database your @drupal data will be stored in.', array('@drupal' => drupal_install_profile_distribution_name())),
896 );
897 if (count($drivers) == 1) {
898 $form['driver']['#disabled'] = TRUE;
899 $form['driver']['#description'] .= ' ' . st('Your PHP configuration only supports a single database type, so it has been automatically selected.');
900 }
901
902 // Add driver specific configuration options.
903 foreach ($drivers as $key => $driver) {
904 $form['driver']['#options'][$key] = $driver->name();
905
906 $form['settings'][$key] = $driver->getFormOptions($database);
907 $form['settings'][$key]['#prefix'] = '<h2 class="js-hide">' . st('@driver_name settings', array('@driver_name' => $driver->name())) . '</h2>';
908 $form['settings'][$key]['#type'] = 'container';
909 $form['settings'][$key]['#tree'] = TRUE;
910 $form['settings'][$key]['advanced_options']['#parents'] = array($key);
911 $form['settings'][$key]['#states'] = array(
912 'visible' => array(
913 ':input[name=driver]' => array('value' => $key),
914 )
915 );
916 }
917
918 $form['actions'] = array('#type' => 'actions');
919 $form['actions']['save'] = array(
920 '#type' => 'submit',
921 '#value' => st('Save and continue'),
922 '#limit_validation_errors' => array(
923 array('driver'),
924 array(isset($form_state['input']['driver']) ? $form_state['input']['driver'] : current($drivers_keys)),
925 ),
926 '#submit' => array('install_settings_form_submit'),
927 );
928
929 $form['errors'] = array();
930 $form['settings_file'] = array('#type' => 'value', '#value' => $settings_file);
931
932 return $form;
933 }
934
940 function install_settings_form_validate($form, &$form_state) {
941 $driver = $form_state['values']['driver'];
942 $database = $form_state['values'][$driver];
943 $database['driver'] = $driver;
944
945 // TODO: remove when PIFR will be updated to use 'db_prefix' instead of
946 // 'prefix' in the database settings form.
947 $database['prefix'] = $database['db_prefix'];
948 unset($database['db_prefix']);
949
950 $form_state['storage']['database'] = $database;
951 $errors = install_database_errors($database, $form_state['values']['settings_file']);
952 foreach ($errors as $name => $message) {
953 form_set_error($name, $message);
954 }
955 }
956
960 function install_database_errors($database, $settings_file) {
961 global $databases;
962 $errors = array();
963
964 // Check database type.
965 $database_types = drupal_get_database_types();
966 $driver = $database['driver'];
967 if (!isset($database_types[$driver])) {
968 $errors['driver'] = st("In your %settings_file file you have configured @drupal to use a %driver server, however your PHP installation currently does not support this database type.", array('%settings_file' => $settings_file, '@drupal' => drupal_install_profile_distribution_name(), '%driver' => $driver));
969 }
970 else {
971 // Run driver specific validation
972 $errors += $database_types[$driver]->validateDatabaseSettings($database);
973
974 // Run tasks associated with the database type. Any errors are caught in the
975 // calling function.
976 $databases['default']['default'] = $database;
977 // Just changing the global doesn't get the new information processed.
978 // We tell tell the Database class to re-parse $databases.
979 Database::parseConnectionInfo();
980
981 try {
982 db_run_tasks($driver);
983 }
984 catch (DatabaseTaskException $e) {
985 // These are generic errors, so we do not have any specific key of the
986 // database connection array to attach them to; therefore, we just put
987 // them in the error array with standard numeric keys.
988 $errors[$driver . '][0'] = $e->getMessage();
989 }
990 }
991 return $errors;
992 }
993
999 function install_settings_form_submit($form, &$form_state) {
1000 global $install_state;
1001
1002 // Update global settings array and save.
1003 $settings['databases'] = array(
1004 'value' => array('default' => array('default' => $form_state['storage']['database'])),
1005 'required' => TRUE,
1006 );
1007 $settings['drupal_hash_salt'] = array(
1008 'value' => drupal_random_key(),
1009 'required' => TRUE,
1010 );
1011 drupal_rewrite_settings($settings);
1012 // Indicate that the settings file has been verified, and check the database
1013 // for the last completed task, now that we have a valid connection. This
1014 // last step is important since we want to trigger an error if the new
1015 // database already has Drupal installed.
1016 $install_state['settings_verified'] = TRUE;
1017 $install_state['completed_task'] = install_verify_completed_task();
1018 }
1019
1023 function install_find_profiles() {
1024 return file_scan_directory('./profiles', '/\.profile$/', array('key' => 'name'));
1025 }
1026
1040 function install_select_profile(&$install_state) {
1041 $install_state['profiles'] += install_find_profiles();
1042 if (empty($install_state['parameters']['profile'])) {
1043 // Try to find a profile.
1044 $profile = _install_select_profile($install_state['profiles']);
1045 if (empty($profile)) {
1046 // We still don't have a profile, so display a form for selecting one.
1047 // Only do this in the case of interactive installations, since this is
1048 // not a real form with submit handlers (the database isn't even set up
1049 // yet), rather just a convenience method for setting parameters in the
1050 // URL.
1051 if ($install_state['interactive']) {
1052 include_once DRUPAL_ROOT . '/includes/form.inc';
1053 drupal_set_title(st('Select an installation profile'));
1054 $form = drupal_get_form('install_select_profile_form', $install_state['profiles']);
1055 return drupal_render($form);
1056 }
1057 else {
1058 throw new Exception(install_no_profile_error());
1059 }
1060 }
1061 else {
1062 $install_state['parameters']['profile'] = $profile;
1063 }
1064 }
1065 }
1066
1084 function _install_select_profile($profiles) {
1085 if (sizeof($profiles) == 0) {
1086 throw new Exception(install_no_profile_error());
1087 }
1088 // Don't need to choose profile if only one available.
1089 if (sizeof($profiles) == 1) {
1090 $profile = array_pop($profiles);
1091 // TODO: is this right?
1092 require_once DRUPAL_ROOT . '/' . $profile->uri;
1093 return $profile->name;
1094 }
1095 else {
1096 foreach ($profiles as $profile) {
1097 if (!empty($_POST['profile']) && ($_POST['profile'] == $profile->name)) {
1098 return $profile->name;
1099 }
1100 }
1101 }
1102 // Check for a profile marked as "exclusive" and ensure that only one
1103 // profile is marked as such.
1104 $exclusive_profile = NULL;
1105 foreach ($profiles as $profile) {
1106 $profile_info = install_profile_info($profile->name);
1107 if (!empty($profile_info['exclusive'])) {
1108 if (empty($exclusive_profile)) {
1109 $exclusive_profile = $profile->name;
1110 }
1111 else {
1112 // We found a second "exclusive" profile. There's no way to choose
1113 // between them, so we ignore the property.
1114 return;
1115 }
1116 }
1117 }
1118 return $exclusive_profile;
1119 }
1120
1131 function install_select_profile_form($form, &$form_state, $profile_files) {
1132 $profiles = array();
1133 $names = array();
1134
1135 foreach ($profile_files as $profile) {
1136 // TODO: is this right?
1137 include_once DRUPAL_ROOT . '/' . $profile->uri;
1138
1139 $details = install_profile_info($profile->name);
1140 // Don't show hidden profiles. This is used by to hide the testing profile,
1141 // which only exists to speed up test runs.
1142 if ($details['hidden'] === TRUE) {
1143 continue;
1144 }
1145 $profiles[$profile->name] = $details;
1146
1147 // Determine the name of the profile; default to file name if defined name
1148 // is unspecified.
1149 $name = isset($details['name']) ? $details['name'] : $profile->name;
1150 $names[$profile->name] = $name;
1151 }
1152
1153 // Display radio buttons alphabetically by human-readable name, but always
1154 // put the core profiles first (if they are present in the filesystem).
1155 natcasesort($names);
1156 if (isset($names['minimal'])) {
1157 // If the expert ("Minimal") core profile is present, put it in front of
1158 // any non-core profiles rather than including it with them alphabetically,
1159 // since the other profiles might be intended to group together in a
1160 // particular way.
1161 $names = array('minimal' => $names['minimal']) + $names;
1162 }
1163 if (isset($names['standard'])) {
1164 // If the default ("Standard") core profile is present, put it at the very
1165 // top of the list. This profile will have its radio button pre-selected,
1166 // so we want it to always appear at the top.
1167 $names = array('standard' => $names['standard']) + $names;
1168 }
1169
1170 foreach ($names as $profile => $name) {
1171 $form['profile'][$name] = array(
1172 '#type' => 'radio',
1173 '#value' => 'standard',
1174 '#return_value' => $profile,
1175 '#title' => $name,
1176 '#description' => isset($profiles[$profile]['description']) ? $profiles[$profile]['description'] : '',
1177 '#parents' => array('profile'),
1178 );
1179 }
1180 $form['actions'] = array('#type' => 'actions');
1181 $form['actions']['submit'] = array(
1182 '#type' => 'submit',
1183 '#value' => st('Save and continue'),
1184 );
1185 return $form;
1186 }
1187
1191 function install_find_locales($profilename) {
1192 $locales = file_scan_directory('./profiles/' . $profilename . '/translations', '/\.po$/', array('recurse' => FALSE));
1193 array_unshift($locales, (object) array('name' => 'en'));
1194 foreach ($locales as $key => $locale) {
1195 // The locale (file name) might be drupal-7.2.cs.po instead of cs.po.
1196 $locales[$key]->langcode = preg_replace('!^(.+\.)?([^\.]+)$!', '\2', $locale->name);
1197 // Language codes cannot exceed 12 characters to fit into the {languages}
1198 // table.
1199 if (strlen($locales[$key]->langcode) > 12) {
1200 unset($locales[$key]);
1201 }
1202 }
1203 return $locales;
1204 }
1205
1220 function install_select_locale(&$install_state) {
1221 // Find all available locales.
1222 $profilename = $install_state['parameters']['profile'];
1223 $locales = install_find_locales($profilename);
1224 $install_state['locales'] += $locales;
1225
1226 if (!empty($_POST['locale'])) {
1227 foreach ($locales as $locale) {
1228 if ($_POST['locale'] == $locale->langcode) {
1229 $install_state['parameters']['locale'] = $locale->langcode;
1230 return;
1231 }
1232 }
1233 }
1234
1235 if (empty($install_state['parameters']['locale'])) {
1236 // If only the built-in (English) language is available, and we are
1237 // performing an interactive installation, inform the user that the
1238 // installer can be localized. Otherwise we assume the user knows what he
1239 // is doing.
1240 if (count($locales) == 1) {
1241 if ($install_state['interactive']) {
1242 drupal_set_title(st('Choose language'));
1243 if (!empty($install_state['parameters']['localize'])) {
1244 $output = '<p>Follow these steps to translate Drupal into your language:</p>';
1245 $output .= '<ol>';
1246 $output .= '<li>Download a translation from the <a href="http://localize.drupal.org/download" target="_blank">translation server</a>.</li>';
1247 $output .= '<li>Place it into the following directory:
1248 <pre>
1249 /profiles/' . $profilename . '/translations/
1250 </pre></li>';
1251 $output .= '</ol>';
1252 $output .= '<p>For more information on installing Drupal in different languages, visit the <a href="http://drupal.org/localize" target="_blank">drupal.org handbook page</a>.</p>';
1253 $output .= '<p>How should the installation continue?</p>';
1254 $output .= '<ul>';
1255 $output .= '<li><a href="install.php?profile=' . $profilename . '">Reload the language selection page after adding translations</a></li>';
1256 $output .= '<li><a href="install.php?profile=' . $profilename . '&amp;locale=en">Continue installation in English</a></li>';
1257 $output .= '</ul>';
1258 }
1259 else {
1260 include_once DRUPAL_ROOT . '/includes/form.inc';
1261 $elements = drupal_get_form('install_select_locale_form', $locales, $profilename);
1262 $output = drupal_render($elements);
1263 }
1264 return $output;
1265 }
1266 // One language, but not an interactive installation. Assume the user
1267 // knows what he is doing.
1268 $locale = current($locales);
1269 $install_state['parameters']['locale'] = $locale->name;
1270 return;
1271 }
1272 else {
1273 // Allow profile to pre-select the language, skipping the selection.
1274 $function = $profilename . '_profile_details';
1275 if (function_exists($function)) {
1276 $details = $function();
1277 if (isset($details['language'])) {
1278 foreach ($locales as $locale) {
1279 if ($details['language'] == $locale->name) {
1280 $install_state['parameters']['locale'] = $locale->name;
1281 return;
1282 }
1283 }
1284 }
1285 }
1286
1287 // We still don't have a locale, so display a form for selecting one.
1288 // Only do this in the case of interactive installations, since this is
1289 // not a real form with submit handlers (the database isn't even set up
1290 // yet), rather just a convenience method for setting parameters in the
1291 // URL.
1292 if ($install_state['interactive']) {
1293 drupal_set_title(st('Choose language'));
1294 include_once DRUPAL_ROOT . '/includes/form.inc';
1295 $elements = drupal_get_form('install_select_locale_form', $locales, $profilename);
1296 return drupal_render($elements);
1297 }
1298 else {
1299 throw new Exception(st('Sorry, you must select a language to continue the installation.'));
1300 }
1301 }
1302 }
1303 }
1304
1310 function install_select_locale_form($form, &$form_state, $locales, $profilename) {
1311 include_once DRUPAL_ROOT . '/includes/iso.inc';
1312 $languages = _locale_get_predefined_list();
1313 foreach ($locales as $locale) {
1314 $name = $locale->langcode;
1315 if (isset($languages[$name])) {
1316 $name = $languages[$name][0] . (isset($languages[$name][1]) ? ' ' . st('(@language)', array('@language' => $languages[$name][1])) : '');
1317 }
1318 $form['locale'][$locale->langcode] = array(
1319 '#type' => 'radio',
1320 '#return_value' => $locale->langcode,
1321 '#default_value' => $locale->langcode == 'en' ? 'en' : '',
1322 '#title' => $name . ($locale->langcode == 'en' ? ' ' . st('(built-in)') : ''),
1323 '#parents' => array('locale')
1324 );
1325 }
1326 if (count($locales) == 1) {
1327 $form['help'] = array(
1328 '#markup' => '<p><a href="install.php?profile=' . $profilename . '&amp;localize=true">' . st('Learn how to install Drupal in other languages') . '</a></p>',
1329 );
1330 }
1331 $form['actions'] = array('#type' => 'actions');
1332 $form['actions']['submit'] = array(
1333 '#type' => 'submit',
1334 '#value' => st('Save and continue'),
1335 );
1336 return $form;
1337 }
1338
1342 function install_no_profile_error() {
1343 drupal_set_title(st('No profiles available'));
1344 return st('We were unable to find any installation profiles. Installation profiles tell us what modules to enable and what schema to install in the database. A profile is necessary to continue with the installation process.');
1345 }
1346
1350 function install_already_done_error() {
1351 global $base_url;
1352
1353 drupal_set_title(st('Drupal already installed'));
1354 return st('<ul><li>To start over, you must empty your existing database.</li><li>To install to a different database, edit the appropriate <em>settings.php</em> file in the <em>sites</em> folder.</li><li>To upgrade an existing installation, proceed to the <a href="@base-url/update.php">update script</a>.</li><li>View your <a href="@base-url">existing site</a>.</li></ul>', array('@base-url' => $base_url));
1355 }
1356
1365 function install_load_profile(&$install_state) {
1366 $profile_file = DRUPAL_ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.profile';
1367 if (file_exists($profile_file)) {
1368 include_once $profile_file;
1369 $install_state['profile_info'] = install_profile_info($install_state['parameters']['profile'], $install_state['parameters']['locale']);
1370 }
1371 else {
1372 throw new Exception(st('Sorry, the profile you have chosen cannot be loaded.'));
1373 }
1374 }
1375
1382 function install_bootstrap_full(&$install_state) {
1383 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
1384 }
1385
1395 function install_profile_modules(&$install_state) {
1396 $modules = variable_get('install_profile_modules', array());
1397 $files = system_rebuild_module_data();
1398 variable_del('install_profile_modules');
1399
1400 // Always install required modules first. Respect the dependencies between
1401 // the modules.
1402 $required = array();
1403 $non_required = array();
1404 // Although the profile module is marked as required, it needs to go after
1405 // every dependency, including non-required ones. So clear its required
1406 // flag for now to allow it to install late.
1407 $files[$install_state['parameters']['profile']]->info['required'] = FALSE;
1408 // Add modules that other modules depend on.
1409 foreach ($modules as $module) {
1410 if ($files[$module]->requires) {
1411 $modules = array_merge($modules, array_keys($files[$module]->requires));
1412 }
1413 }
1414 $modules = array_unique($modules);
1415 foreach ($modules as $module) {
1416 if (!empty($files[$module]->info['required'])) {
1417 $required[$module] = $files[$module]->sort;
1418 }
1419 else {
1420 $non_required[$module] = $files[$module]->sort;
1421 }
1422 }
1423 arsort($required);
1424 arsort($non_required);
1425
1426 $operations = array();
1427 foreach ($required + $non_required as $module => $weight) {
1428 $operations[] = array('_install_module_batch', array($module, $files[$module]->info['name']));
1429 }
1430 $batch = array(
1431 'operations' => $operations,
1432 'title' => st('Installing @drupal', array('@drupal' => drupal_install_profile_distribution_name())),
1433 'error_message' => st('The installation has encountered an error.'),
1434 'finished' => '_install_profile_modules_finished',
1435 );
1436 return $batch;
1437 }
1438
1448 function install_import_locales(&$install_state) {
1449 include_once DRUPAL_ROOT . '/includes/locale.inc';
1450 $install_locale = $install_state['parameters']['locale'];
1451
1452 include_once DRUPAL_ROOT . '/includes/iso.inc';
1453 $predefined = _locale_get_predefined_list();
1454 if (!isset($predefined[$install_locale])) {
1455 // Drupal does not know about this language, so we prefill its values with
1456 // our best guess. The user will be able to edit afterwards.
1457 locale_add_language($install_locale, $install_locale, $install_locale, LANGUAGE_LTR, '', '', TRUE, TRUE);
1458 }
1459 else {
1460 // A known predefined language, details will be filled in properly.
1461 locale_add_language($install_locale, NULL, NULL, NULL, '', '', TRUE, TRUE);
1462 }
1463
1464 // Collect files to import for this language.
1465 $batch = locale_batch_by_language($install_locale, NULL);
1466 if (!empty($batch)) {
1467 // Remember components we cover in this batch set.
1468 variable_set('install_locale_batch_components', $batch['#components']);
1469 return $batch;
1470 }
1471 }
1472
1483 function install_configure_form($form, &$form_state, &$install_state) {
1484 drupal_set_title(st('Configure site'));
1485
1486 // Warn about settings.php permissions risk
1487 $settings_dir = conf_path();
1488 $settings_file = $settings_dir . '/settings.php';
1489 // Check that $_POST is empty so we only show this message when the form is
1490 // first displayed, not on the next page after it is submitted. (We do not
1491 // want to repeat it multiple times because it is a general warning that is
1492 // not related to the rest of the installation process; it would also be
1493 // especially out of place on the last page of the installer, where it would
1494 // distract from the message that the Drupal installation has completed
1495 // successfully.)
1496 if (empty($_POST) && (!drupal_verify_install_file(DRUPAL_ROOT . '/' . $settings_file, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE) || !drupal_verify_install_file(DRUPAL_ROOT . '/' . $settings_dir, FILE_NOT_WRITABLE, 'dir'))) {
1497 drupal_set_message(st('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href="@handbook_url">online handbook</a>.', array('%dir' => $settings_dir, '%file' => $settings_file, '@handbook_url' => 'http://drupal.org/server-permissions')), 'warning');
1498 }
1499
1500 drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
1501 // Add JavaScript time zone detection.
1502 drupal_add_js('misc/timezone.js');
1503 // We add these strings as settings because JavaScript translation does not
1504 // work during installation.
1505 drupal_add_js(array('copyFieldValue' => array('edit-site-mail' => array('edit-account-mail'))), 'setting');
1506 drupal_add_js('jQuery(function () { Drupal.cleanURLsInstallCheck(); });', 'inline');
1507 // Add JS to show / hide the 'Email administrator about site updates' elements
1508 drupal_add_js('jQuery(function () { Drupal.hideEmailAdministratorCheckbox() });', 'inline');
1509 // Build menu to allow clean URL check.
1510 menu_rebuild();
1511
1512 // Cache a fully-built schema. This is necessary for any invocation of
1513 // index.php because: (1) setting cache table entries requires schema
1514 // information, (2) that occurs during bootstrap before any module are
1515 // loaded, so (3) if there is no cached schema, drupal_get_schema() will
1516 // try to generate one but with no loaded modules will return nothing.
1517 //
1518 // This logically could be done during the 'install_finished' task, but the
1519 // clean URL check requires it now.
1520 drupal_get_schema(NULL, TRUE);
1521
1522 // Return the form.
1523 return _install_configure_form($form, $form_state, $install_state);
1524 }
1525
1535 function install_import_locales_remaining(&$install_state) {
1536 include_once DRUPAL_ROOT . '/includes/locale.inc';
1537 // Collect files to import for this language. Skip components already covered
1538 // in the initial batch set.
1539 $install_locale = $install_state['parameters']['locale'];
1540 $batch = locale_batch_by_language($install_locale, NULL, variable_get('install_locale_batch_components', array()));
1541 // Remove temporary variable.
1542 variable_del('install_locale_batch_components');
1543 return $batch;
1544 }
1545
1555 function install_finished(&$install_state) {
1556 drupal_set_title(st('@drupal installation complete', array('@drupal' => drupal_install_profile_distribution_name())), PASS_THROUGH);
1557 $messages = drupal_set_message();
1558 $output = '<p>' . st('Congratulations, you installed @drupal!', array('@drupal' => drupal_install_profile_distribution_name())) . '</p>';
1559 $output .= '<p>' . (isset($messages['error']) ? st('Review the messages above before visiting <a href="@url">your new site</a>.', array('@url' => url(''))) : st('<a href="@url">Visit your new site</a>.', array('@url' => url('')))) . '</p>';
1560
1561 // Flush all caches to ensure that any full bootstraps during the installer
1562 // do not leave stale cached data, and that any content types or other items
1563 // registered by the installation profile are registered correctly.
1564 drupal_flush_all_caches();
1565
1566 // Remember the profile which was used.
1567 variable_set('install_profile', drupal_get_profile());
1568
1569 // Installation profiles are always loaded last
1570 db_update('system')
1571 ->fields(array('weight' => 1000))
1572 ->condition('type', 'module')
1573 ->condition('name', drupal_get_profile())
1574 ->execute();
1575
1576 // Cache a fully-built schema.
1577 drupal_get_schema(NULL, TRUE);
1578
1579 // Run cron to populate update status tables (if available) so that users
1580 // will be warned if they've installed an out of date Drupal version.
1581 // Will also trigger indexing of profile-supplied content or feeds.
1582 drupal_cron_run();
1583
1584 return $output;
1585 }
1586
1590 function _install_module_batch($module, $module_name, &$context) {
1591 // Install and enable the module right away, so that the module will be
1592 // loaded by drupal_bootstrap in subsequent batch requests, and other
1593 // modules possibly depending on it can safely perform their installation
1594 // steps.
1595 module_enable(array($module), FALSE);
1596 $context['results'][] = $module;
1597 $context['message'] = st('Installed %module module.', array('%module' => $module_name));
1598 }
1599
1603 function _install_profile_modules_finished($success, $results, $operations) {
1604 // Flush all caches to complete the module installation process. Subsequent
1605 // installation tasks will now have full access to the profile's modules.
1606 drupal_flush_all_caches();
1607 }
1608
1612 function install_check_requirements($install_state) {
1613 $profile = $install_state['parameters']['profile'];
1614
1615 // Check the profile requirements.
1616 $requirements = drupal_check_profile($profile);
1617
1618 // If Drupal is not set up already, we need to create a settings file.
1619 if (!$install_state['settings_verified']) {
1620 $writable = FALSE;
1621 $conf_path = './' . conf_path(FALSE, TRUE);
1622 $settings_file = $conf_path . '/settings.php';
1623 $default_settings_file = './sites/default/default.settings.php';
1624 $file = $conf_path;
1625 $exists = FALSE;
1626 // Verify that the directory exists.
1627 if (drupal_verify_install_file($conf_path, FILE_EXIST, 'dir')) {
1628 // Check if a settings.php file already exists.
1629 $file = $settings_file;
1630 if (drupal_verify_install_file($settings_file, FILE_EXIST)) {
1631 // If it does, make sure it is writable.
1632 $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE);
1633 $exists = TRUE;
1634 }
1635 }
1636
1637 // If default.settings.php does not exist, or is not readable, throw an
1638 // error.
1639 if (!drupal_verify_install_file($default_settings_file, FILE_EXIST|FILE_READABLE)) {
1640 $requirements['default settings file exists'] = array(
1641 'title' => st('Default settings file'),
1642 'value' => st('The default settings file does not exist.'),
1643 'severity' => REQUIREMENT_ERROR,
1644 'description' => st('The @drupal installer requires that the %default-file file not be modified in any way from the original download.', array('@drupal' => drupal_install_profile_distribution_name(), '%default-file' => $default_settings_file)),
1645 );
1646 }
1647 // Otherwise, if settings.php does not exist yet, we can try to copy
1648 // default.settings.php to create it.
1649 elseif (!$exists) {
1650 $copied = drupal_verify_install_file($conf_path, FILE_EXIST|FILE_WRITABLE, 'dir') && @copy($default_settings_file, $settings_file);
1651 if ($copied) {
1652 // If the new settings file has the same owner as default.settings.php,
1653 // this means default.settings.php is owned by the webserver user.
1654 // This is an inherent security weakness because it allows a malicious
1655 // webserver process to append arbitrary PHP code and then execute it.
1656 // However, it is also a common configuration on shared hosting, and
1657 // there is nothing Drupal can do to prevent it. In this situation,
1658 // having settings.php also owned by the webserver does not introduce
1659 // any additional security risk, so we keep the file in place.
1660 if (fileowner($default_settings_file) === fileowner($settings_file)) {
1661 $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE);
1662 $exists = TRUE;
1663 }
1664 // If settings.php and default.settings.php have different owners, this
1665 // probably means the server is set up "securely" (with the webserver
1666 // running as its own user, distinct from the user who owns all the
1667 // Drupal PHP files), although with either a group or world writable
1668 // sites directory. Keeping settings.php owned by the webserver would
1669 // therefore introduce a security risk. It would also cause a usability
1670 // problem, since site owners who do not have root access to the file
1671 // system would be unable to edit their settings file later on. We
1672 // therefore must delete the file we just created and force the
1673 // administrator to log on to the server and create it manually.
1674 else {
1675 $deleted = @drupal_unlink($settings_file);
1676 // We expect deleting the file to be successful (since we just
1677 // created it ourselves above), but if it fails somehow, we set a
1678 // variable so we can display a one-time error message to the
1679 // administrator at the bottom of the requirements list. We also try
1680 // to make the file writable, to eliminate any conflicting error
1681 // messages in the requirements list.
1682 $exists = !$deleted;
1683 if ($exists) {
1684 $settings_file_ownership_error = TRUE;
1685 $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE);
1686 }
1687 }
1688 }
1689 }
1690
1691 // If settings.php does not exist, throw an error.
1692 if (!$exists) {
1693 $requirements['settings file exists'] = array(
1694 'title' => st('Settings file'),
1695 'value' => st('The settings file does not exist.'),
1696 'severity' => REQUIREMENT_ERROR,
1697 'description' => st('The @drupal installer requires that you create a settings file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in <a href="@install_txt">INSTALL.txt</a>.', array('@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, '%default_file' => $default_settings_file, '@install_txt' => base_path() . 'INSTALL.txt')),
1698 );
1699 }
1700 else {
1701 $requirements['settings file exists'] = array(
1702 'title' => st('Settings file'),
1703 'value' => st('The %file file exists.', array('%file' => $file)),
1704 );
1705 // If settings.php is not writable, throw an error.
1706 if (!$writable) {
1707 $requirements['settings file writable'] = array(
1708 'title' => st('Settings file'),
1709 'value' => st('The settings file is not writable.'),
1710 'severity' => REQUIREMENT_ERROR,
1711 'description' => st('The @drupal installer requires write permissions to %file during the installation process. If you are unsure how to grant file permissions, consult the <a href="@handbook_url">online handbook</a>.', array('@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, '@handbook_url' => 'http://drupal.org/server-permissions')),
1712 );
1713 }
1714 else {
1715 $requirements['settings file'] = array(
1716 'title' => st('Settings file'),
1717 'value' => st('The settings file is writable.'),
1718 );
1719 }
1720 if (!empty($settings_file_ownership_error)) {
1721 $requirements['settings file ownership'] = array(
1722 'title' => st('Settings file'),
1723 'value' => st('The settings file is owned by the web server.'),
1724 'severity' => REQUIREMENT_ERROR,
1725 'description' => st('The @drupal installer failed to create a settings file with proper file ownership. Log on to your web server, remove the existing %file file, and create a new one by copying the %default_file file to %file. More details about installing Drupal are available in <a href="@install_txt">INSTALL.txt</a>. If you have problems with the file permissions on your server, consult the <a href="@handbook_url">online handbook</a>.', array('@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, '%default_file' => $default_settings_file, '@install_txt' => base_path() . 'INSTALL.txt', '@handbook_url' => 'http://drupal.org/server-permissions')),
1726 );
1727 }
1728 }
1729 }
1730 return $requirements;
1731 }
1732
1744 function _install_configure_form($form, &$form_state, &$install_state) {
1745 include_once DRUPAL_ROOT . '/includes/locale.inc';
1746
1747 $form['site_information'] = array(
1748 '#type' => 'fieldset',
1749 '#title' => st('Site information'),
1750 '#collapsible' => FALSE,
1751 );
1752 $form['site_information']['site_name'] = array(
1753 '#type' => 'textfield',
1754 '#title' => st('Site name'),
1755 '#required' => TRUE,
1756 '#weight' => -20,
1757 );
1758 $form['site_information']['site_mail'] = array(
1759 '#type' => 'textfield',
1760 '#title' => st('Site e-mail address'),
1761 '#default_value' => ini_get('sendmail_from'),
1762 '#description' => st("Automated e-mails, such as registration information, will be sent from this address. Use an address ending in your site's domain to help prevent these e-mails from being flagged as spam."),
1763 '#required' => TRUE,
1764 '#weight' => -15,
1765 );
1766 $form['admin_account'] = array(
1767 '#type' => 'fieldset',
1768 '#title' => st('Site maintenance account'),
1769 '#collapsible' => FALSE,
1770 );
1771
1772 $form['admin_account']['account']['#tree'] = TRUE;
1773 $form['admin_account']['account']['name'] = array('#type' => 'textfield',
1774 '#title' => st('Username'),
1775 '#maxlength' => USERNAME_MAX_LENGTH,
1776 '#description' => st('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.'),
1777 '#required' => TRUE,
1778 '#weight' => -10,
1779 '#attributes' => array('class' => array('username')),
1780 );
1781
1782 $form['admin_account']['account']['mail'] = array('#type' => 'textfield',
1783 '#title' => st('E-mail address'),
1784 '#maxlength' => EMAIL_MAX_LENGTH,
1785 '#required' => TRUE,
1786 '#weight' => -5,
1787 );
1788 $form['admin_account']['account']['pass'] = array(
1789 '#type' => 'password_confirm',
1790 '#required' => TRUE,
1791 '#size' => 25,
1792 '#weight' => 0,
1793 );
1794
1795 $form['server_settings'] = array(
1796 '#type' => 'fieldset',
1797 '#title' => st('Server settings'),
1798 '#collapsible' => FALSE,
1799 );
1800
1801 $countries = country_get_list();
1802 $form['server_settings']['site_default_country'] = array(
1803 '#type' => 'select',
1804 '#title' => st('Default country'),
1805 '#empty_value' => '',
1806 '#default_value' => variable_get('site_default_country', NULL),
1807 '#options' => $countries,
1808 '#description' => st('Select the default country for the site.'),
1809 '#weight' => 0,
1810 );
1811
1812 $form['server_settings']['date_default_timezone'] = array(
1813 '#type' => 'select',
1814 '#title' => st('Default time zone'),
1815 '#default_value' => date_default_timezone_get(),
1816 '#options' => system_time_zones(),
1817 '#description' => st('By default, dates in this site will be displayed in the chosen time zone.'),
1818 '#weight' => 5,
1819 '#attributes' => array('class' => array('timezone-detect')),
1820 );
1821
1822 $form['server_settings']['clean_url'] = array(
1823 '#type' => 'hidden',
1824 '#default_value' => 0,
1825 '#attributes' => array('id' => 'edit-clean-url', 'class' => array('install')),
1826 );
1827
1828 $form['update_notifications'] = array(
1829 '#type' => 'fieldset',
1830 '#title' => st('Update notifications'),
1831 '#collapsible' => FALSE,
1832 );
1833 $form['update_notifications']['update_status_module'] = array(
1834 '#type' => 'checkboxes',
1835 '#options' => array(
1836 1 => st('Check for updates automatically'),
1837 2 => st('Receive e-mail notifications'),
1838 ),
1839 '#default_value' => array(1, 2),
1840 '#description' => st('The system will notify you when updates and important security releases are available for installed components. Anonymous information about your site is sent to <a href="@drupal">Drupal.org</a>.', array('@drupal' => 'http://drupal.org')),
1841 '#weight' => 15,
1842 );
1843
1844 $form['actions'] = array('#type' => 'actions');
1845 $form['actions']['submit'] = array(
1846 '#type' => 'submit',
1847 '#value' => st('Save and continue'),
1848 '#weight' => 15,
1849 );
1850
1851 return $form;
1852 }
1853
1859 function install_configure_form_validate($form, &$form_state) {
1860 if ($error = user_validate_name($form_state['values']['account']['name'])) {
1861 form_error($form['admin_account']['account']['name'], $error);
1862 }
1863 if ($error = user_validate_mail($form_state['values']['account']['mail'])) {
1864 form_error($form['admin_account']['account']['mail'], $error);
1865 }
1866 if ($error = user_validate_mail($form_state['values']['site_mail'])) {
1867 form_error($form['site_information']['site_mail'], $error);
1868 }
1869 }
1870
1876 function install_configure_form_submit($form, &$form_state) {
1877 global $user;
1878
1879 variable_set('site_name', $form_state['values']['site_name']);
1880 variable_set('site_mail', $form_state['values']['site_mail']);
1881 variable_set('date_default_timezone', $form_state['values']['date_default_timezone']);
1882 variable_set('site_default_country', $form_state['values']['site_default_country']);
1883
1884 // Enable update.module if this option was selected.
1885 if ($form_state['values']['update_status_module'][1]) {
1886 module_enable(array('update'), FALSE);
1887
1888 // Add the site maintenance account's email address to the list of
1889 // addresses to be notified when updates are available, if selected.
1890 if ($form_state['values']['update_status_module'][2]) {
1891 variable_set('update_notify_emails', array($form_state['values']['account']['mail']));
1892 }
1893 }
1894
1895 // We precreated user 1 with placeholder values. Let's save the real values.
1896 $account = user_load(1);
1897 $merge_data = array('init' => $form_state['values']['account']['mail'], 'roles' => !empty($account->roles) ? $account->roles : array(), 'status' => 1, 'timezone' => $form_state['values']['date_default_timezone']);
1898 user_save($account, array_merge($form_state['values']['account'], $merge_data));
1899 // Load global $user and perform final login tasks.
1900 $user = user_load(1);
1901 user_login_finalize();
1902
1903 if (isset($form_state['values']['clean_url'])) {
1904 variable_set('clean_url', $form_state['values']['clean_url']);
1905 }
1906
1907 // Record when this install ran.
1908 variable_set('install_time', $_SERVER['REQUEST_TIME']);
1909 }
EMAIL_MAX_LENGTH
const EMAIL_MAX_LENGTH
Definition: user.module:16
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
_batch_page
_batch_page()
Definition: batch.inc:43
FILE_NOT_WRITABLE
const FILE_NOT_WRITABLE
Definition: install.inc:71
drupal_install_profile_distribution_name
drupal_install_profile_distribution_name()
Definition: install.inc:196
batch_process
batch_process($redirect=NULL, $url= 'batch', $redirect_callback= 'drupal_goto')
Definition: form.inc:4459
module_list
module_list($refresh=FALSE, $bootstrap_refresh=FALSE, $sort=FALSE, $fixed_list=NULL)
Definition: module.inc:66
drupal_http_build_query
drupal_http_build_query(array $query, $parent= '')
Definition: common.inc:486
install_load_profile
install_load_profile(&$install_state)
Definition: install.core.inc:1365
drupal_add_region_content
drupal_add_region_content($region=NULL, $data=NULL)
Definition: common.inc:175
install_full_redirect_url
install_full_redirect_url($install_state)
Definition: install.core.inc:676
install_run_tasks
install_run_tasks(&$install_state)
Definition: install.core.inc:325
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
$databases
$databases
Definition: default.settings.php:213
_install_module_batch
_install_module_batch($module, $module_name, &$context)
Definition: install.core.inc:1590
drupal_unlink
drupal_unlink($uri, $context=NULL)
Definition: file.inc:2225
system_time_zones
system_time_zones($blank=NULL)
Definition: system.module:3335
file_scan_directory
file_scan_directory($dir, $mask, $options=array(), $depth=0)
Definition: file.inc:2058
INSTALL_TASK_SKIP
const INSTALL_TASK_SKIP
Definition: install.core.inc:19
user_validate_mail
user_validate_mail($mail)
Definition: user.module:670
install_verify_settings
install_verify_settings()
Definition: install.core.inc:837
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
$module
print $module
Definition: search-results.tpl.php:28
_install_configure_form
_install_configure_form($form, &$form_state, &$install_state)
Definition: install.core.inc:1744
check_url
check_url($uri)
Definition: common.inc:1387
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
_locale_get_predefined_list
_locale_get_predefined_list()
Definition: iso.inc:291
variable_del
variable_del($name)
Definition: bootstrap.inc:996
drupal_rewrite_settings
drupal_rewrite_settings($settings=array(), $prefix= '')
Definition: install.inc:590
$name
print $name
Definition: profile-listing.tpl.php:43
$results
print $results
Definition: poll-results.tpl.php:23
Exception
drupal_check_profile
drupal_check_profile($profile)
Definition: install.inc:1164
install_tasks_to_display
install_tasks_to_display($install_state)
Definition: install.core.inc:638
USERNAME_MAX_LENGTH
const USERNAME_MAX_LENGTH
Definition: user.module:11
install_already_done_error
install_already_done_error()
Definition: install.core.inc:1350
drupal_install_system
drupal_install_system()
Definition: install.inc:721
INSTALL_TASK_RUN_IF_NOT_COMPLETED
const INSTALL_TASK_RUN_IF_NOT_COMPLETED
Definition: install.core.inc:40
user_validate_name
user_validate_name($name)
Definition: user.module:624
print
print
Definition: php-2.php:2
install_settings_form
install_settings_form($form, &$form_state, &$install_state)
Definition: install.core.inc:875
Database\parseConnectionInfo
static parseConnectionInfo()
Definition: database.inc:1516
drupal_verify_install_file
drupal_verify_install_file($file, $mask=NULL, $type= 'file')
Definition: install.inc:829
user_save
user_save($account, $edit=array(), $category= 'account')
Definition: user.module:424
REQUIREMENT_WARNING
const REQUIREMENT_WARNING
Definition: install.inc:31
drupal_bootstrap
drupal_bootstrap($phase=NULL, $new_phase=TRUE)
Definition: bootstrap.inc:2192
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
$conf
global $conf
Definition: authorize.php:74
FILE_EXIST
const FILE_EXIST
Definition: install.inc:41
drupal_page_header
drupal_page_header()
Definition: bootstrap.inc:1253
drupal_get_database_types
drupal_get_database_types()
Definition: install.inc:253
$module_list
$module_list['system']['filename']
Definition: authorize.php:78
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
system_rebuild_module_data
system_rebuild_module_data()
Definition: system.module:2444
install_verify_requirements
install_verify_requirements(&$install_state)
Definition: install.core.inc:736
install_finished
install_finished(&$install_state)
Definition: install.core.inc:1555
drupal_get_schema
drupal_get_schema($table=NULL, $rebuild=FALSE)
Definition: bootstrap.inc:2940
install_settings_form_submit
install_settings_form_submit($form, &$form_state)
Definition: install.core.inc:999
drupal_requirements_severity
drupal_requirements_severity(&$requirements)
Definition: install.inc:1197
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
menu_rebuild
menu_rebuild()
Definition: menu.inc:2709
locale_add_language
locale_add_language($langcode, $name=NULL, $native=NULL, $direction=LANGUAGE_LTR, $domain= '', $prefix= '', $enabled=TRUE, $default=FALSE)
Definition: locale.inc:559
batch_set
batch_set($batch_definition)
Definition: form.inc:4381
install_import_locales_remaining
install_import_locales_remaining(&$install_state)
Definition: install.core.inc:1535
module_enable
module_enable($module_list, $enable_dependencies=TRUE)
Definition: module.inc:383
drupal_get_profile
drupal_get_profile()
Definition: common.inc:222
install_select_locale
install_select_locale(&$install_state)
Definition: install.core.inc:1220
install_find_locales
install_find_locales($profilename)
Definition: install.core.inc:1191
drupal_random_key
drupal_random_key($byte_count=32)
Definition: bootstrap.inc:1945
install_configure_form
install_configure_form($form, &$form_state, &$install_state)
Definition: install.core.inc:1483
drupal_build_form
drupal_build_form($form_id, &$form_state)
Definition: form.inc:308
drupal_override_server_variables
drupal_override_server_variables($variables=array())
Definition: bootstrap.inc:608
install_select_profile
install_select_profile(&$install_state)
Definition: install.core.inc:1040
install_tasks_to_perform
install_tasks_to_perform($install_state)
Definition: install.core.inc:487
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$messages
print $messages
Definition: page.tpl.php:121
LANGUAGE_LTR
const LANGUAGE_LTR
Definition: bootstrap.inc:201
install_check_requirements
install_check_requirements($install_state)
Definition: install.core.inc:1612
$output
$output
Definition: authorize.php:93
install_tasks
install_tasks($install_state)
Definition: install.core.inc:520
install_configure_form_submit
install_configure_form_submit($form, &$form_state)
Definition: install.core.inc:1876
drupal_verify_profile
drupal_verify_profile($install_state)
Definition: install.inc:671
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
install_drupal
install_drupal($settings=array())
Definition: install.core.inc:64
form_get_errors
form_get_errors()
Definition: form.inc:1634
INSTALL_TASK_RUN_IF_REACHED
const INSTALL_TASK_RUN_IF_REACHED
Definition: install.core.inc:26
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
install_settings_form_validate
install_settings_form_validate($form, &$form_state)
Definition: install.core.inc:940
drupal_maintenance_theme
drupal_maintenance_theme()
Definition: bootstrap.inc:2569
user_login_finalize
user_login_finalize(&$edit=array())
Definition: user.module:2255
install_profile_info
install_profile_info($profile, $locale= 'en')
Definition: install.inc:1280
st
st($string, array $args=array(), array $options=array())
Definition: install.inc:1111
conf_path
conf_path($require_settings=TRUE, $reset=FALSE)
Definition: bootstrap.inc:541
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
drupal_flush_all_caches
drupal_flush_all_caches()
Definition: common.inc:7453
install_state_defaults
install_state_defaults()
Definition: install.core.inc:124
_install_profile_modules_finished
_install_profile_modules_finished($success, $results, $operations)
Definition: install.core.inc:1603
drupal_language_initialize
drupal_language_initialize()
Definition: bootstrap.inc:2648
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
FILE_READABLE
const FILE_READABLE
Definition: install.inc:46
install_display_output
install_display_output($output, $install_state)
Definition: install.core.inc:693
drupal_form_submit
drupal_form_submit($form_id, &$form_state)
Definition: form.inc:685
country_get_list
country_get_list()
Definition: locale.inc:2351
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
install_system_module
install_system_module(&$install_state)
Definition: install.core.inc:780
install_redirect_url
install_redirect_url($install_state)
Definition: install.core.inc:661
batch_get
& batch_get()
Definition: form.inc:4538
install_goto
install_goto($path)
Definition: install.inc:1027
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
install_no_profile_error
install_no_profile_error()
Definition: install.core.inc:1342
drupal_requirements_url
drupal_requirements_url($severity)
Definition: install.inc:1087
locale_batch_by_language
locale_batch_by_language($langcode, $finished=NULL, $skip=array())
Definition: locale.inc:2207
base_path
base_path()
Definition: common.inc:2817
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
_install_select_profile
_install_select_profile($profiles)
Definition: install.core.inc:1084
FILE_WRITABLE
const FILE_WRITABLE
Definition: install.inc:51
install_run_task
install_run_task($task, &$install_state)
Definition: install.core.inc:373
install_configure_form_validate
install_configure_form_validate($form, &$form_state)
Definition: install.core.inc:1859
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
drupal_add_html_head
drupal_add_html_head($data=NULL, $key=NULL)
Definition: common.inc:299
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
install_import_locales
install_import_locales(&$install_state)
Definition: install.core.inc:1448
install_verify_completed_task
install_verify_completed_task()
Definition: install.core.inc:816
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
file_ensure_htaccess
file_ensure_htaccess()
Definition: file.inc:457
install_database_errors
install_database_errors($database, $settings_file)
Definition: install.core.inc:960
DatabaseTaskException
Definition: install.inc:581
drupal_load
drupal_load($type, $name)
Definition: bootstrap.inc:1093
drupal_cron_run
drupal_cron_run()
Definition: common.inc:5227
install_bootstrap_full
install_bootstrap_full(&$install_state)
Definition: install.core.inc:1382
install_verify_pdo
install_verify_pdo()
Definition: install.core.inc:856
db_run_tasks
db_run_tasks($driver)
Definition: install.inc:1317
install_select_profile_form
install_select_profile_form($form, &$form_state, $profile_files)
Definition: install.core.inc:1131
DRUPAL_BOOTSTRAP_FULL
const DRUPAL_BOOTSTRAP_FULL
Definition: bootstrap.inc:157
install_select_locale_form
install_select_locale_form($form, &$form_state, $locales, $profilename)
Definition: install.core.inc:1310
install_find_profiles
install_find_profiles()
Definition: install.core.inc:1023
install_begin_request
install_begin_request(&$install_state)
Definition: install.core.inc:210
install_profile_modules
install_profile_modules(&$install_state)
Definition: install.core.inc:1395
DRUPAL_BOOTSTRAP_CONFIGURATION
const DRUPAL_BOOTSTRAP_CONFIGURATION
Definition: bootstrap.inc:122
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/examples.index.php Source File

  • examples
examples.index.php
Go to the documentation of this file.
1 <?php
2
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Updater Member List

This is the complete list of members for Updater, including all inherited members.

$source | Updater |
__construct($source) | Updater |
factory($source) | Updater | static
findInfoFile($directory) | Updater | static
getBackupDir() | Updater |
getInstallArgs($overrides=array()) | Updater | protected
getProjectName($directory) | Updater | static
getProjectTitle($directory) | Updater | static
getUpdaterFromDirectory($directory) | Updater | static
install(&$filetransfer, $overrides=array()) | Updater |
makeBackup(&$filetransfer, $from, $to) | Updater |
makeWorldReadable(&$filetransfer, $path, $recursive=TRUE) | Updater |
postInstall() | Updater |
postInstallTasks() | Updater |
postUpdate() | Updater |
postUpdateTasks() | Updater |
prepareInstallDirectory(&$filetransfer, $directory) | Updater |
update(&$filetransfer, $overrides=array()) | Updater |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/openid/openid.inc Source File

  • modules
  • openid
openid.inc
Go to the documentation of this file.
1 <?php
2
16 define('OPENID_DH_DEFAULT_MOD', '155172898181473697471232257763715539915724801' .
17 '966915404479707795314057629378541917580651227423698188993727816152646631' .
18 '438561595825688188889951272158842675419950341258706556549803580104870537' .
19 '681476726513255747040765857479291291572334510643245094715007229621094194' .
20 '349783925984760375594985848253359305585439638443');
21
25 define('OPENID_DH_DEFAULT_GEN', '2');
26
30 define('OPENID_SHA1_BLOCKSIZE', 64);
31
35 define('OPENID_RAND_SOURCE', '/dev/urandom');
36
40 define('OPENID_NS_2_0', 'http://specs.openid.net/auth/2.0');
41
45 define('OPENID_NS_1_1', 'http://openid.net/signon/1.1');
46
50 define('OPENID_NS_1_0', 'http://openid.net/signon/1.0');
51
55 define('OPENID_NS_OPENID', 'http://openid.net/xmlns/1.0');
56
60 define('OPENID_NS_SREG', 'http://openid.net/extensions/sreg/1.1');
61
65 define('OPENID_NS_AX', 'http://openid.net/srv/ax/1.0');
66
70 define('OPENID_NS_XRD', 'xri://$xrd*($v*2.0)');
71
75 function openid_redirect_http($url, $message) {
76 $query = array();
77 foreach ($message as $key => $val) {
78 $query[] = $key . '=' . urlencode($val);
79 }
80
81 $sep = (strpos($url, '?') === FALSE) ? '?' : '&';
82 header('Location: ' . $url . $sep . implode('&', $query), TRUE, 302);
83
84 drupal_exit();
85 }
86
90 function openid_redirect($url, $message) {
91 global $language;
92
93 $output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
94 $output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $language->language . '" lang="' . $language->language . '">' . "\n";
95 $output .= "<head>\n";
96 $output .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
97 $output .= "<title>" . t('OpenID redirect') . "</title>\n";
98 $output .= "</head>\n";
99 $output .= "<body>\n";
100 $elements = drupal_get_form('openid_redirect_form', $url, $message);
101 $output .= drupal_render($elements);
102 $output .= '<script type="text/javascript">document.getElementById("openid-redirect-form").submit();</script>' . "\n";
103 $output .= "</body>\n";
104 $output .= "</html>\n";
105 print $output;
106
107 drupal_exit();
108 }
109
110 function openid_redirect_form($form, &$form_state, $url, $message) {
111 $form['#action'] = $url;
112 $form['#method'] = "post";
113 foreach ($message as $key => $value) {
114 $form[$key] = array(
115 '#type' => 'hidden',
116 '#name' => $key,
117 '#value' => $value,
118 );
119 }
120 $form['actions'] = array('#type' => 'actions');
121 $form['actions']['submit'] = array(
122 '#type' => 'submit',
123 '#prefix' => '<noscript><div>',
124 '#suffix' => '</div></noscript>',
125 '#value' => t('Send'),
126 );
127
128 return $form;
129 }
130
139 function _openid_xrds_parse($raw_xml) {
140 $services = array();
141
142 // For PHP version >= 5.2.11, we can use this function to protect against
143 // malicious doctype declarations and other unexpected entity loading.
144 // However, we will not rely on it, and reject any XML with a DOCTYPE.
145 $disable_entity_loader = function_exists('libxml_disable_entity_loader');
146 if ($disable_entity_loader) {
147 $load_entities = libxml_disable_entity_loader(TRUE);
148 }
149
150 // Load the XML into a DOM document.
151 $dom = new DOMDocument();
152 @$dom->loadXML($raw_xml);
153
154 // Since DOCTYPE declarations from an untrusted source could be malicious, we
155 // stop parsing here and treat the XML as invalid since XRDS documents do not
156 // require, and are not expected to have, a DOCTYPE.
157 if (isset($dom->doctype)) {
158 return array();
159 }
160
161 // Parse the DOM document for the information we need.
162 if ($xml = simplexml_import_dom($dom)) {
163 foreach ($xml->children(OPENID_NS_XRD)->XRD as $xrd) {
164 foreach ($xrd->children(OPENID_NS_XRD)->Service as $service_element) {
165 $service = array(
166 'priority' => $service_element->attributes()->priority ? (int)$service_element->attributes()->priority : PHP_INT_MAX,
167 'types' => array(),
168 'uri' => (string)$service_element->children(OPENID_NS_XRD)->URI,
169 'service' => $service_element,
170 'xrd' => $xrd,
171 );
172 foreach ($service_element->Type as $type) {
173 $service['types'][] = (string)$type;
174 }
175 if ($service_element->children(OPENID_NS_XRD)->LocalID) {
176 $service['identity'] = (string)$service_element->children(OPENID_NS_XRD)->LocalID;
177 }
178 elseif ($service_element->children(OPENID_NS_OPENID)->Delegate) {
179 $service['identity'] = (string)$service_element->children(OPENID_NS_OPENID)->Delegate;
180 }
181 else {
182 $service['identity'] = FALSE;
183 }
184 $services[] = $service;
185 }
186 }
187 }
188
189 // Return the LIBXML options to the previous state before returning.
190 if ($disable_entity_loader) {
191 libxml_disable_entity_loader($load_entities);
192 }
193
194 return $services;
195 }
196
210 function _openid_select_service(array $services) {
211 // Extensible Resource Identifier (XRI) Resolution Version 2.0, section 4.3.3:
212 // Find the service with the highest priority (lowest integer value). If there
213 // is a tie, select a random one, not just the first in the XML document.
214 shuffle($services);
215 $selected_service = NULL;
216 $selected_type_priority = FALSE;
217
218 // Search for an OP Identifier Element.
219 foreach ($services as $service) {
220 if (!empty($service['uri'])) {
221 $type_priority = FALSE;
222 if (in_array('http://specs.openid.net/auth/2.0/server', $service['types'])) {
223 $service['version'] = 2;
224 $type_priority = 1;
225 }
226 elseif (in_array('http://specs.openid.net/auth/2.0/signon', $service['types'])) {
227 $service['version'] = 2;
228 $type_priority = 2;
229 }
230 elseif (in_array(OPENID_NS_1_0, $service['types']) || in_array(OPENID_NS_1_1, $service['types'])) {
231 $service['version'] = 1;
232 $type_priority = 3;
233 }
234
235 if ($type_priority
236 && (!$selected_service
237 || $type_priority < $selected_type_priority
238 || ($type_priority == $selected_type_priority && $service['priority'] < $selected_service['priority']))) {
239 $selected_service = $service;
240 $selected_type_priority = $type_priority;
241 }
242 }
243 }
244
245 if ($selected_service) {
246 // Unset SimpleXMLElement instances that cannot be saved in $_SESSION.
247 unset($selected_service['xrd']);
248 unset($selected_service['service']);
249 }
250
251 return $selected_service;
252 }
253
257 function _openid_is_xri($identifier) {
258 // Strip the xri:// scheme from the identifier if present.
259 if (stripos($identifier, 'xri://') === 0) {
260 $identifier = substr($identifier, 6);
261 }
262
263 // Test whether the identifier starts with an XRI global context symbol or (.
264 $firstchar = substr($identifier, 0, 1);
265 if (strpos("=@+$!(", $firstchar) !== FALSE) {
266 return TRUE;
267 }
268
269 return FALSE;
270 }
271
277 function openid_normalize($identifier) {
278 $methods = module_invoke_all('openid_normalization_method_info');
279 drupal_alter('openid_normalization_method_info', $methods);
280
281 // Execute each method in turn, stopping after the first method accepted
282 // the identifier.
283 foreach ($methods as $method) {
284 $result = $method($identifier);
285 if ($result !== NULL) {
286 $identifier = $result;
287 break;
288 }
289 }
290
291 return $identifier;
292 }
293
297 function _openid_xri_normalize($identifier) {
298 if (_openid_is_xri($identifier)) {
299 if (stristr($identifier, 'xri://') !== FALSE) {
300 $identifier = substr($identifier, 6);
301 }
302 return $identifier;
303 }
304 }
305
309 function _openid_url_normalize($url) {
310 $normalized_url = $url;
311
312 if (stristr($url, '://') === FALSE) {
313 $normalized_url = 'http://' . $url;
314 }
315
316 // Strip the fragment and fragment delimiter if present.
317 $normalized_url = strtok($normalized_url, '#');
318
319 if (substr_count($normalized_url, '/') < 3) {
320 $normalized_url .= '/';
321 }
322
323 return $normalized_url;
324 }
325
329 function _openid_create_message($data) {
330 $serialized = '';
331
332 foreach ($data as $key => $value) {
333 if ((strpos($key, ':') !== FALSE) || (strpos($key, "\n") !== FALSE) || (strpos($value, "\n") !== FALSE)) {
334 return NULL;
335 }
336 $serialized .= "$key:$value\n";
337 }
338 return $serialized;
339 }
340
344 function _openid_encode_message($message) {
345 $encoded_message = '';
346
347 $items = explode("\n", $message);
348 foreach ($items as $item) {
349 $parts = explode(':', $item, 2);
350
351 if (count($parts) == 2) {
352 if ($encoded_message != '') {
353 $encoded_message .= '&';
354 }
355 $encoded_message .= rawurlencode(trim($parts[0])) . '=' . rawurlencode(trim($parts[1]));
356 }
357 }
358
359 return $encoded_message;
360 }
361
366 function _openid_parse_message($message) {
367 $parsed_message = array();
368
369 $items = explode("\n", $message);
370 foreach ($items as $item) {
371 $parts = explode(':', $item, 2);
372
373 if (count($parts) == 2) {
374 $parsed_message[$parts[0]] = $parts[1];
375 }
376 }
377
378 return $parsed_message;
379 }
380
387 function _openid_nonce() {
388 // YYYY-MM-DDThh:mm:ssZ, plus some optional extra unique characters.
389 return gmdate('Y-m-d\TH:i:s\Z') .
390 chr(mt_rand(0, 25) + 65) .
391 chr(mt_rand(0, 25) + 65) .
392 chr(mt_rand(0, 25) + 65) .
393 chr(mt_rand(0, 25) + 65);
394 }
395
399 function _openid_link_href($rel, $html) {
400 $rel = preg_quote($rel);
401 preg_match('|<link\s+rel=["\'](.*)' . $rel . '(.*)["\'](.*)/?>|iUs', $html, $matches);
402 if (isset($matches[3])) {
403 preg_match('|href=["\']([^"]+)["\']|iU', $matches[3], $href);
404 return trim($href[1]);
405 }
406 return FALSE;
407 }
408
412 function _openid_meta_httpequiv($equiv, $html) {
413 preg_match('|<meta\s+http-equiv=["\']' . $equiv . '["\'](.*)/?>|iUs', $html, $matches);
414 if (isset($matches[1])) {
415 preg_match('|content=["\']([^"]+)["\']|iUs', $matches[1], $content);
416 if (isset($content[1])) {
417 return $content[1];
418 }
419 }
420 return FALSE;
421 }
422
431 function _openid_signature($association, $message_array, $keys_to_sign) {
432 $signature = '';
433 $sign_data = array();
434
435 foreach ($keys_to_sign as $key) {
436 if (isset($message_array['openid.' . $key])) {
437 $sign_data[$key] = $message_array['openid.' . $key];
438 }
439 }
440
441 $message = _openid_create_message($sign_data);
442 $secret = base64_decode($association->mac_key);
443 $signature = _openid_hmac($secret, $message);
444
445 return base64_encode($signature);
446 }
447
448 function _openid_hmac($key, $text) {
449 if (strlen($key) > OPENID_SHA1_BLOCKSIZE) {
450 $key = sha1($key, TRUE);
451 }
452
453 $key = str_pad($key, OPENID_SHA1_BLOCKSIZE, chr(0x00));
454 $ipad = str_repeat(chr(0x36), OPENID_SHA1_BLOCKSIZE);
455 $opad = str_repeat(chr(0x5c), OPENID_SHA1_BLOCKSIZE);
456 $hash1 = sha1(($key ^ $ipad) . $text, TRUE);
457 $hmac = sha1(($key ^ $opad) . $hash1, TRUE);
458
459 return $hmac;
460 }
461
462 function _openid_dh_base64_to_long($str) {
463 $b64 = base64_decode($str);
464
465 return _openid_dh_binary_to_long($b64);
466 }
467
468 function _openid_dh_long_to_base64($str) {
469 return base64_encode(_openid_dh_long_to_binary($str));
470 }
471
472 function _openid_dh_binary_to_long($str) {
473 $bytes = array_merge(unpack('C*', $str));
474
475 $n = 0;
476 foreach ($bytes as $byte) {
477 $n = _openid_math_mul($n, pow(2, 8));
478 $n = _openid_math_add($n, $byte);
479 }
480
481 return $n;
482 }
483
484 function _openid_dh_long_to_binary($long) {
485 $cmp = _openid_math_cmp($long, 0);
486 if ($cmp < 0) {
487 return FALSE;
488 }
489
490 if ($cmp == 0) {
491 return "\x00";
492 }
493
494 $bytes = array();
495
496 while (_openid_math_cmp($long, 0) > 0) {
497 array_unshift($bytes, _openid_math_mod($long, 256));
498 $long = _openid_math_div($long, pow(2, 8));
499 }
500
501 if ($bytes && ($bytes[0] > 127)) {
502 array_unshift($bytes, 0);
503 }
504
505 $string = '';
506 foreach ($bytes as $byte) {
507 $string .= pack('C', $byte);
508 }
509
510 return $string;
511 }
512
513 function _openid_dh_xorsecret($shared, $secret) {
514 $dh_shared_str = _openid_dh_long_to_binary($shared);
515 $sha1_dh_shared = sha1($dh_shared_str, TRUE);
516 $xsecret = "";
517 for ($i = 0; $i < strlen($secret); $i++) {
518 $xsecret .= chr(ord($secret[$i]) ^ ord($sha1_dh_shared[$i]));
519 }
520
521 return $xsecret;
522 }
523
524 function _openid_dh_rand($stop) {
525 $duplicate_cache = &drupal_static(__FUNCTION__, array());
526
527 // Used as the key for the duplicate cache
528 $rbytes = _openid_dh_long_to_binary($stop);
529
530 if (isset($duplicate_cache[$rbytes])) {
531 list($duplicate, $nbytes) = $duplicate_cache[$rbytes];
532 }
533 else {
534 if ($rbytes[0] == "\x00") {
535 $nbytes = strlen($rbytes) - 1;
536 }
537 else {
538 $nbytes = strlen($rbytes);
539 }
540
541 $mxrand = _openid_math_pow(256, $nbytes);
542
543 // If we get a number less than this, then it is in the
544 // duplicated range.
545 $duplicate = _openid_math_mod($mxrand, $stop);
546
547 if (count($duplicate_cache) > 10) {
548 $duplicate_cache = array();
549 }
550
551 $duplicate_cache[$rbytes] = array($duplicate, $nbytes);
552 }
553
554 do {
555 $bytes = "\x00" . drupal_random_bytes($nbytes);
556 $n = _openid_dh_binary_to_long($bytes);
557 // Keep looping if this value is in the low duplicated range.
558 } while (_openid_math_cmp($n, $duplicate) < 0);
559
560 return _openid_math_mod($n, $stop);
561 }
562
563 function _openid_get_bytes($num_bytes) {
564 return drupal_random_bytes($num_bytes);
565 }
566
567 function _openid_response($str = NULL) {
568 $data = array();
569
570 if (isset($_SERVER['REQUEST_METHOD'])) {
571 $data = _openid_get_params($_SERVER['QUERY_STRING']);
572
573 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
574 $str = file_get_contents('php://input');
575
576 $post = array();
577 if ($str !== FALSE) {
578 $post = _openid_get_params($str);
579 }
580
581 $data = array_merge($data, $post);
582 }
583 }
584
585 return $data;
586 }
587
588 function _openid_get_params($str) {
589 $chunks = explode("&", $str);
590
591 $data = array();
592 foreach ($chunks as $chunk) {
593 $parts = explode("=", $chunk, 2);
594
595 if (count($parts) == 2) {
596 list($k, $v) = $parts;
597 $data[$k] = urldecode($v);
598 }
599 }
600 return $data;
601 }
602
642 function openid_extract_namespace($response, $extension_namespace, $fallback_prefix = NULL, $only_signed = FALSE) {
643 $signed_keys = explode(',', $response['openid.signed']);
644
645 // Find the namespace prefix.
646 $prefix = $fallback_prefix;
647 foreach ($response as $key => $value) {
648 if ($value == $extension_namespace && preg_match('/^openid\.ns\.([^.]+)$/', $key, $matches)) {
649 $prefix = $matches[1];
650 if ($only_signed && !in_array('ns.' . $matches[1], $signed_keys)) {
651 // The namespace was defined but was not signed as required. In this
652 // case we do not fall back to $fallback_prefix.
653 $prefix = NULL;
654 }
655 break;
656 }
657 }
658
659 // Now extract the namespace keys from the response.
660 $output = array();
661 if (!isset($prefix)) {
662 return $output;
663 }
664 foreach ($response as $key => $value) {
665 if (preg_match('/^openid\.' . $prefix . '\.(.+)$/', $key, $matches)) {
666 $local_key = $matches[1];
667 if (!$only_signed || in_array($prefix . '.' . $local_key, $signed_keys)) {
668 $output[$local_key] = $value;
669 }
670 }
671 }
672
673 return $output;
674 }
675
692 function openid_extract_ax_values($values, $uris) {
693 $output = array();
694 foreach ($values as $key => $value) {
695 if (in_array($value, $uris) && preg_match('/^type\.([^.]+)$/', $key, $matches)) {
696 $alias = $matches[1];
697 if (isset($values['count.' . $alias])) {
698 for ($i = 1; $i <= $values['count.' . $alias]; $i++) {
699 $output[] = $values['value.' . $alias . '.' . $i];
700 }
701 }
702 elseif (isset($values['value.' . $alias])) {
703 $output[] = $values['value.' . $alias];
704 }
705 break;
706 }
707 }
708 return $output;
709 }
710
714 function _openid_get_math_library() {
715 // Not drupal_static(), because a function is not going to disappear and
716 // change the output of this under any circumstances.
717 static $library;
718
719 if (empty($library)) {
720 if (function_exists('gmp_add')) {
721 $library = 'gmp';
722 }
723 elseif (function_exists('bcadd')) {
724 $library = 'bcmath';
725 }
726 }
727
728 return $library;
729 }
730
734 function _openid_math_add($x, $y) {
735 $library = _openid_get_math_library();
736 switch ($library) {
737 case 'gmp':
738 return gmp_strval(gmp_add($x, $y));
739 case 'bcmath':
740 return bcadd($x, $y);
741 }
742 }
743
747 function _openid_math_mul($x, $y) {
748 $library = _openid_get_math_library();
749 switch ($library) {
750 case 'gmp':
751 return gmp_mul($x, $y);
752 case 'bcmath':
753 return bcmul($x, $y);
754 }
755 }
756
760 function _openid_math_div($x, $y) {
761 $library = _openid_get_math_library();
762 switch ($library) {
763 case 'gmp':
764 return gmp_div($x, $y);
765 case 'bcmath':
766 return bcdiv($x, $y);
767 }
768 }
769
773 function _openid_math_cmp($x, $y) {
774 $library = _openid_get_math_library();
775 switch ($library) {
776 case 'gmp':
777 return gmp_cmp($x, $y);
778 case 'bcmath':
779 return bccomp($x, $y);
780 }
781 }
782
786 function _openid_math_mod($x, $y) {
787 $library = _openid_get_math_library();
788 switch ($library) {
789 case 'gmp':
790 return gmp_mod($x, $y);
791 case 'bcmath':
792 return bcmod($x, $y);
793 }
794 }
795
799 function _openid_math_pow($x, $y) {
800 $library = _openid_get_math_library();
801 switch ($library) {
802 case 'gmp':
803 return gmp_pow($x, $y);
804 case 'bcmath':
805 return bcpow($x, $y);
806 }
807 }
808
812 function _openid_math_powmod($x, $y, $z) {
813 $library = _openid_get_math_library();
814 switch ($library) {
815 case 'gmp':
816 return gmp_powm($x, $y, $z);
817 case 'bcmath':
818 return bcpowmod($x, $y, $z);
819 }
820 }
821
837 function _openid_invalid_openid_transition($identity, $response) {
838 $account = FALSE;
839 $fallback_account = NULL;
840 $fallback_identity = $identity;
841
842 // Try to strip the fragment if it is present.
843 if (strpos($fallback_identity, '#') !== FALSE) {
844 $fallback_identity = preg_replace('/#.*/', '', $fallback_identity);
845 $fallback_account = user_external_load($fallback_identity);
846 }
847
848 // Try to replace HTTPS with HTTP. OpenID providers often redirect
849 // from http to https, but Drupal didn't follow the redirect.
850 if (!$fallback_account && strpos($fallback_identity, 'https://') !== FALSE) {
851 $fallback_identity = str_replace('https://', 'http://', $fallback_identity);
852 $fallback_account = user_external_load($fallback_identity);
853 }
854
855 // Try to use original identifier.
856 if (!$fallback_account && isset($_SESSION['openid']['user_login_values']['openid_identifier'])) {
857 $fallback_identity = openid_normalize($_SESSION['openid']['user_login_values']['openid_identifier']);
858 $fallback_account = user_external_load($fallback_identity);
859 }
860
861 if ($fallback_account) {
862 // Try to extract e-mail address from Simple Registration (SREG) or
863 // Attribute Exchanges (AX) keys.
864 $email = '';
865 $sreg_values = openid_extract_namespace($response, OPENID_NS_SREG, 'sreg', TRUE);
866 $ax_values = openid_extract_namespace($response, OPENID_NS_AX, 'ax', TRUE);
867 if (!empty($sreg_values['email']) && valid_email_address($sreg_values['email'])) {
868 $email = $sreg_values['email'];
869 }
870 elseif ($ax_mail_values = openid_extract_ax_values($ax_values, array('http://axschema.org/contact/email', 'http://schema.openid.net/contact/email'))) {
871 $email = current($ax_mail_values);
872 }
873
874 // If this e-mail address is the same as the e-mail address found in user
875 // account, login the user and update the claimed identifier.
876 if ($email && ($email == $fallback_account->mail || $email == $fallback_account->init)) {
877 $query = db_insert('authmap')
878 ->fields(array(
879 'authname' => $identity,
880 'uid' => $fallback_account->uid,
881 'module' => 'openid',
882 ))
883 ->execute();
884 drupal_set_message(t('New OpenID identifier %identity was added as a replacement for invalid identifier %invalid_identity. To finish the invalid OpenID transition process, please go to your <a href="@openid_url">OpenID identities page</a> and remove the old identifier %invalid_identity.', array('%invalid_identity' => $fallback_identity, '%identity' => $identity, '@openid_url' => 'user/' . $fallback_account->uid . '/openid')));
885 // Set the account to the found one.
886 $account = $fallback_account;
887 }
888 else {
889 drupal_set_message(t('There is already an existing account associated with the OpenID identifier that you have provided. However, due to a bug in the previous version of the authentication system, we can\'t be sure that this account belongs to you. If you are new on this site, please continue registering the new user account. If you already have a registered account on this site associated with the provided OpenID identifier, please try to <a href="@url_password">reset the password</a> or contact the site administrator.', array('@url_password' => 'user/password')), 'warning');
890 }
891 }
892
893 return $account;
894 }
_openid_invalid_openid_transition
_openid_invalid_openid_transition($identity, $response)
Definition: openid.inc:837
OPENID_NS_1_0
const OPENID_NS_1_0
Definition: openid.inc:50
_openid_math_div
_openid_math_div($x, $y)
Definition: openid.inc:760
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
_openid_dh_long_to_base64
_openid_dh_long_to_base64($str)
Definition: openid.inc:468
_openid_dh_base64_to_long
_openid_dh_base64_to_long($str)
Definition: openid.inc:462
_openid_is_xri
_openid_is_xri($identifier)
Definition: openid.inc:257
OPENID_NS_XRD
const OPENID_NS_XRD
Definition: openid.inc:70
openid_redirect_form
openid_redirect_form($form, &$form_state, $url, $message)
Definition: openid.inc:110
_openid_url_normalize
_openid_url_normalize($url)
Definition: openid.inc:309
_openid_link_href
_openid_link_href($rel, $html)
Definition: openid.inc:399
_openid_math_cmp
_openid_math_cmp($x, $y)
Definition: openid.inc:773
_openid_nonce
_openid_nonce()
Definition: openid.inc:387
OPENID_NS_SREG
const OPENID_NS_SREG
Definition: openid.inc:60
_openid_math_powmod
_openid_math_powmod($x, $y, $z)
Definition: openid.inc:812
_openid_get_params
_openid_get_params($str)
Definition: openid.inc:588
print
print
Definition: php-2.php:2
_openid_math_mod
_openid_math_mod($x, $y)
Definition: openid.inc:786
OPENID_NS_OPENID
const OPENID_NS_OPENID
Definition: openid.inc:55
openid_normalize
openid_normalize($identifier)
Definition: openid.inc:277
_openid_get_bytes
_openid_get_bytes($num_bytes)
Definition: openid.inc:563
_openid_parse_message
_openid_parse_message($message)
Definition: openid.inc:366
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
_openid_hmac
_openid_hmac($key, $text)
Definition: openid.inc:448
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
openid_extract_namespace
openid_extract_namespace($response, $extension_namespace, $fallback_prefix=NULL, $only_signed=FALSE)
Definition: openid.inc:642
OPENID_NS_1_1
const OPENID_NS_1_1
Definition: openid.inc:45
$url
print $url
Definition: search-result.tpl.php:70
_openid_dh_xorsecret
_openid_dh_xorsecret($shared, $secret)
Definition: openid.inc:513
openid_extract_ax_values
openid_extract_ax_values($values, $uris)
Definition: openid.inc:692
_openid_get_math_library
_openid_get_math_library()
Definition: openid.inc:714
$value
print $value
Definition: user-profile-item.tpl.php:26
_openid_select_service
_openid_select_service(array $services)
Definition: openid.inc:210
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$output
$output
Definition: authorize.php:93
_openid_encode_message
_openid_encode_message($message)
Definition: openid.inc:344
_openid_xri_normalize
_openid_xri_normalize($identifier)
Definition: openid.inc:297
drupal_random_bytes
drupal_random_bytes($count)
Definition: bootstrap.inc:1974
_openid_meta_httpequiv
_openid_meta_httpequiv($equiv, $html)
Definition: openid.inc:412
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
valid_email_address
valid_email_address($mail)
Definition: common.inc:1186
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
_openid_create_message
_openid_create_message($data)
Definition: openid.inc:329
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
openid_redirect
openid_redirect($url, $message)
Definition: openid.inc:90
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
user_external_load
user_external_load($authname)
Definition: user.module:249
drupal_exit
drupal_exit($destination=NULL)
Definition: common.inc:2721
OPENID_SHA1_BLOCKSIZE
const OPENID_SHA1_BLOCKSIZE
Definition: openid.inc:30
_openid_dh_binary_to_long
_openid_dh_binary_to_long($str)
Definition: openid.inc:472
_openid_response
_openid_response($str=NULL)
Definition: openid.inc:567
_openid_math_mul
_openid_math_mul($x, $y)
Definition: openid.inc:747
openid_redirect_http
openid_redirect_http($url, $message)
Definition: openid.inc:75
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
_openid_dh_long_to_binary
_openid_dh_long_to_binary($long)
Definition: openid.inc:484
_openid_signature
_openid_signature($association, $message_array, $keys_to_sign)
Definition: openid.inc:431
OPENID_NS_AX
const OPENID_NS_AX
Definition: openid.inc:65
_openid_dh_rand
_openid_dh_rand($stop)
Definition: openid.inc:524
_openid_math_pow
_openid_math_pow($x, $y)
Definition: openid.inc:799
_openid_xrds_parse
_openid_xrds_parse($raw_xml)
Definition: openid.inc:139
_openid_math_add
_openid_math_add($x, $y)
Definition: openid.inc:734
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
CommentController Member List

This is the complete list of members for CommentController, including all inherited members.

$cache | DrupalDefaultEntityController | protected
$entityCache | DrupalDefaultEntityController | protected
$entityInfo | DrupalDefaultEntityController | protected
$entityType | DrupalDefaultEntityController | protected
$hookLoadArguments | DrupalDefaultEntityController | protected
$idKey | DrupalDefaultEntityController | protected
$revisionKey | DrupalDefaultEntityController | protected
$revisionTable | DrupalDefaultEntityController | protected
__construct($entityType) | DrupalDefaultEntityController |
attachLoad(&$comments, $revision_id=FALSE) | CommentController | protected
buildQuery($ids, $conditions=array(), $revision_id=FALSE) | CommentController | protected
cacheGet($ids, $conditions=array()) | DrupalDefaultEntityController | protected
cacheSet($entities) | DrupalDefaultEntityController | protected
load($ids=array(), $conditions=array()) | DrupalDefaultEntityController |
resetCache(array $ids=NULL) | DrupalDefaultEntityController |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.archiver.inc Source File

  • modules
  • system
system.archiver.inc
Go to the documentation of this file.
1 <?php
2
11 class ArchiverTar implements ArchiverInterface {
12
18 protected $tar;
19
20 public function __construct($file_path) {
21 $this->tar = new Archive_Tar($file_path);
22 }
23
24 public function add($file_path) {
25 $this->tar->add($file_path);
26
27 return $this;
28 }
29
30 public function remove($file_path) {
31 // @todo Archive_Tar doesn't have a remove operation
32 // so we'll have to simulate it somehow, probably by
33 // creating a new archive with everything but the removed
34 // file.
35
36 return $this;
37 }
38
39 public function extract($path, Array $files = array()) {
40 if ($files) {
41 $this->tar->extractList($files, $path);
42 }
43 else {
44 $this->tar->extract($path);
45 }
46
47 return $this;
48 }
49
50 public function listContents() {
51 $files = array();
52 foreach ($this->tar->listContent() as $file_data) {
53 $files[] = $file_data['filename'];
54 }
55 return $files;
56 }
57
68 public function getArchive() {
69 return $this->tar;
70 }
71 }
72
78 class ArchiverZip implements ArchiverInterface {
79
85 protected $zip;
86
87 public function __construct($file_path) {
88 $this->zip = new ZipArchive();
89 if ($this->zip->open($file_path) !== TRUE) {
90 // @todo: This should be an interface-specific exception some day.
91 throw new Exception(t('Cannot open %file_path', array('%file_path' => $file_path)));
92 }
93 }
94
95 public function add($file_path) {
96 $this->zip->addFile($file_path);
97
98 return $this;
99 }
100
101 public function remove($file_path) {
102 $this->zip->deleteName($file_path);
103
104 return $this;
105 }
106
107 public function extract($path, Array $files = array()) {
108 if ($files) {
109 $this->zip->extractTo($path, $files);
110 }
111 else {
112 $this->zip->extractTo($path);
113 }
114
115 return $this;
116 }
117
118 public function listContents() {
119 $files = array();
120 for ($i=0; $i < $this->zip->numFiles; $i++) {
121 $files[] = $this->zip->getNameIndex($i);
122 }
123 return $files;
124 }
125
136 public function getArchive() {
137 return $this->zip;
138 }
139 }
ArchiverInterface
Definition: archiver.inc:11
ArchiverTar\$tar
$tar
Definition: system.archiver.inc:18
Exception
ArchiverZip\add
add($file_path)
Definition: system.archiver.inc:95
ArchiverZip\__construct
__construct($file_path)
Definition: system.archiver.inc:87
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
ArchiverTar\add
add($file_path)
Definition: system.archiver.inc:24
ArchiverTar\getArchive
getArchive()
Definition: system.archiver.inc:68
ArchiverTar
Definition: system.archiver.inc:11
Archive_Tar
Definition: system.tar.inc:57
ArchiverTar\extract
extract($path, Array $files=array())
Definition: system.archiver.inc:39
ArchiverTar\__construct
__construct($file_path)
Definition: system.archiver.inc:20
ArchiverZip\getArchive
getArchive()
Definition: system.archiver.inc:136
ArchiverZip\extract
extract($path, Array $files=array())
Definition: system.archiver.inc:107
ArchiverTar\listContents
listContents()
Definition: system.archiver.inc:50
ArchiverZip
Definition: system.archiver.inc:78
ArchiverZip\$zip
$zip
Definition: system.archiver.inc:85
ArchiverZip\listContents
listContents()
Definition: system.archiver.inc:118
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.module Source File

  • modules
  • system
system.module
Go to the documentation of this file.
1 <?php
2
11 define('DRUPAL_MAXIMUM_TEMP_FILE_AGE', 21600);
12
16 define('DRUPAL_CRON_DEFAULT_THRESHOLD', 10800);
17
21 define('DRUPAL_USER_TIMEZONE_DEFAULT', 0);
22
26 define('DRUPAL_USER_TIMEZONE_EMPTY', 1);
27
31 define('DRUPAL_USER_TIMEZONE_SELECT', 2);
32
36 define('DRUPAL_DISABLED', 0);
37
41 define('DRUPAL_OPTIONAL', 1);
42
46 define('DRUPAL_REQUIRED', 2);
47
53 define('DRUPAL_WEIGHT_SELECT_MAX', 100);
54
60 define('REGIONS_VISIBLE', 'visible');
61
67 define('REGIONS_ALL', 'all');
68
72 function system_help($path, $arg) {
73 global $base_url;
74
75 switch ($path) {
76 case 'admin/help#system':
77 $output = '';
78 $output .= '<h3>' . t('About') . '</h3>';
79 $output .= '<p>' . t('The System module is integral to the site, and provides basic but extensible functionality for use by other modules and themes. Some integral elements of Drupal are contained in and managed by the System module, including caching, enabling and disabling modules and themes, preparing and displaying the administrative page, and configuring fundamental site settings. A number of key system maintenance operations are also part of the System module. For more information, see the online handbook entry for <a href="@system">System module</a>.', array('@system' => 'http://drupal.org/documentation/modules/system')) . '</p>';
80 $output .= '<h3>' . t('Uses') . '</h3>';
81 $output .= '<dl>';
82 $output .= '<dt>' . t('Managing modules') . '</dt>';
83 $output .= '<dd>' . t('The System module allows users with the appropriate permissions to enable and disable modules on the <a href="@modules">Modules administration page</a>. Drupal comes with a number of core modules, and each module provides a discrete set of features and may be enabled or disabled depending on the needs of the site. Many additional modules contributed by members of the Drupal community are available for download at the <a href="@drupal-modules">Drupal.org module page</a>.', array('@modules' => url('admin/modules'), '@drupal-modules' => 'http://drupal.org/project/modules')) . '</dd>';
84 $output .= '<dt>' . t('Managing themes') . '</dt>';
85 $output .= '<dd>' . t('The System module allows users with the appropriate permissions to enable and disable themes on the <a href="@themes">Appearance administration page</a>. Themes determine the design and presentation of your site. Drupal comes packaged with several core themes, and additional contributed themes are available at the <a href="@drupal-themes">Drupal.org theme page</a>.', array('@themes' => url('admin/appearance'), '@drupal-themes' => 'http://drupal.org/project/themes')) . '</dd>';
86 $output .= '<dt>' . t('Managing caching') . '</dt>';
87 $output .= '<dd>' . t("The System module allows users with the appropriate permissions to manage caching on the <a href='@cache-settings'>Performance settings page</a>. Drupal has a robust caching system that allows the efficient re-use of previously-constructed web pages and web page components. Pages requested by anonymous users are stored in a compressed format; depending on your site configuration and the amount of your web traffic tied to anonymous visitors, the caching system may significantly increase the speed of your site.", array('@cache-settings' => url('admin/config/development/performance'))) . '</dd>';
88 $output .= '<dt>' . t('Performing system maintenance') . '</dt>';
89 $output .= '<dd>' . t('In order for the site and its modules to continue to operate well, a set of routine administrative operations must run on a regular basis. The System module manages this task by making use of a system cron job. You can verify the status of cron tasks by visiting the <a href="@status">Status report page</a>. For more information, see the online handbook entry for <a href="@handbook">configuring cron jobs</a>. You can set up cron job by visiting <a href="@cron">Cron configuration</a> page', array('@status' => url('admin/reports/status'), '@handbook' => 'http://drupal.org/cron', '@cron' => url('admin/config/system/cron'))) . '</dd>';
90 $output .= '<dt>' . t('Configuring basic site settings') . '</dt>';
91 $output .= '<dd>' . t('The System module also handles basic configuration options for your site, including <a href="@date-time-settings">Date and time settings</a>, <a href="@file-system">File system settings</a>, <a href="@clean-url">Clean URL support</a>, <a href="@site-info">Site name and other information</a>, and a <a href="@maintenance-mode">Maintenance mode</a> for taking your site temporarily offline.', array('@date-time-settings' => url('admin/config/regional/date-time'), '@file-system' => url('admin/config/media/file-system'), '@clean-url' => url('admin/config/search/clean-urls'), '@site-info' => url('admin/config/system/site-information'), '@maintenance-mode' => url('admin/config/development/maintenance'))) . '</dd>';
92 $output .= '<dt>' . t('Configuring actions') . '</dt>';
93 $output .= '<dd>' . t('Actions are individual tasks that the system can do, such as unpublishing a piece of content or banning a user. Modules, such as the <a href="@trigger-help">Trigger module</a>, can fire these actions when certain system events happen; for example, when a new post is added or when a user logs in. Modules may also provide additional actions. Visit the <a href="@actions">Actions page</a> to configure actions.', array('@trigger-help' => url('admin/help/trigger'), '@actions' => url('admin/config/system/actions'))) . '</dd>';
94 $output .= '</dl>';
95 return $output;
96 case 'admin/index':
97 return '<p>' . t('This page shows you all available administration tasks for each module.') . '</p>';
98 case 'admin/appearance':
99 $output = '<p>' . t('Set and configure the default theme for your website. Alternative <a href="@themes">themes</a> are available.', array('@themes' => 'http://drupal.org/project/themes')) . '</p>';
100 return $output;
101 case 'admin/appearance/settings/' . $arg[3]:
102 $theme_list = list_themes();
103 $theme = $theme_list[$arg[3]];
104 return '<p>' . t('These options control the display settings for the %name theme. When your site is displayed using this theme, these settings will be used.', array('%name' => $theme->info['name'])) . '</p>';
105 case 'admin/appearance/settings':
106 return '<p>' . t('These options control the default display settings for your entire site, across all themes. Unless they have been overridden by a specific theme, these settings will be used.') . '</p>';
107 case 'admin/modules':
108 $output = '<p>' . t('Download additional <a href="@modules">contributed modules</a> to extend Drupal\'s functionality.', array('@modules' => 'http://drupal.org/project/modules')) . '</p>';
109 if (module_exists('update')) {
110 if (update_manager_access()) {
111 $output .= '<p>' . t('Regularly review and install <a href="@updates">available updates</a> to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated.', array('@update-php' => $base_url . '/update.php', '@updates' => url('admin/reports/updates'))) . '</p>';
112 }
113 else {
114 $output .= '<p>' . t('Regularly review <a href="@updates">available updates</a> to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated.', array('@update-php' => $base_url . '/update.php', '@updates' => url('admin/reports/updates'))) . '</p>';
115 }
116 }
117 else {
118 $output .= '<p>' . t('Regularly review available updates to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated. Enable the Update manager module to update and install modules and themes.', array('@update-php' => $base_url . '/update.php')) . '</p>';
119 }
120 return $output;
121 case 'admin/modules/uninstall':
122 return '<p>' . t('The uninstall process removes all data related to a module. To uninstall a module, you must first disable it on the main <a href="@modules">Modules page</a>.', array('@modules' => url('admin/modules'))) . '</p>';
123 case 'admin/structure/block/manage':
124 if ($arg[4] == 'system' && $arg[5] == 'powered-by') {
125 return '<p>' . t('The <em>Powered by Drupal</em> block is an optional link to the home page of the Drupal project. While there is absolutely no requirement that sites feature this link, it may be used to show support for Drupal.') . '</p>';
126 }
127 break;
128 case 'admin/config/development/maintenance':
129 global $user;
130 if ($user->uid == 1) {
131 return '<p>' . t('If you are upgrading to a newer version of Drupal or upgrading contributed modules or themes, you may need to run the <a href="@update-php">update script</a>.', array('@update-php' => $base_url . '/update.php')) . '</p>';
132 }
133 break;
134 case 'admin/config/system/actions':
135 case 'admin/config/system/actions/manage':
136 $output = '';
137 $output .= '<p>' . t('There are two types of actions: simple and advanced. Simple actions do not require any additional configuration, and are listed here automatically. Advanced actions need to be created and configured before they can be used, because they have options that need to be specified; for example, sending an e-mail to a specified address, or unpublishing content containing certain words. To create an advanced action, select the action from the drop-down list in the advanced action section below and click the <em>Create</em> button.') . '</p>';
138 if (module_exists('trigger')) {
139 $output .= '<p>' . t('You may proceed to the <a href="@url">Triggers</a> page to assign these actions to system events.', array('@url' => url('admin/structure/trigger'))) . '</p>';
140 }
141 return $output;
142 case 'admin/config/system/actions/configure':
143 return t('An advanced action offers additional configuration options which may be filled out below. Changing the <em>Description</em> field is recommended, in order to better identify the precise action taking place. This description will be displayed in modules such as the Trigger module when assigning actions to system events, so it is best if it is as descriptive as possible (for example, "Send e-mail to Moderation Team" rather than simply "Send e-mail").');
144 case 'admin/config/people/ip-blocking':
145 return '<p>' . t('IP addresses listed here are blocked from your site. Blocked addresses are completely forbidden from accessing the site and instead see a brief message explaining the situation.') . '</p>';
146 case 'admin/reports/status':
147 return '<p>' . t("Here you can find a short overview of your site's parameters as well as any problems detected with your installation. It may be useful to copy and paste this information into support requests filed on drupal.org's support forums and project issue queues.") . '</p>';
148 }
149 }
150
154 function system_theme() {
155 return array_merge(drupal_common_theme(), array(
156 'system_themes_page' => array(
157 'variables' => array('theme_groups' => NULL),
158 'file' => 'system.admin.inc',
159 ),
160 'system_settings_form' => array(
161 'render element' => 'form',
162 ),
163 'confirm_form' => array(
164 'render element' => 'form',
165 ),
166 'system_modules_fieldset' => array(
167 'render element' => 'form',
168 'file' => 'system.admin.inc',
169 ),
170 'system_modules_incompatible' => array(
171 'variables' => array('message' => NULL),
172 'file' => 'system.admin.inc',
173 ),
174 'system_modules_uninstall' => array(
175 'render element' => 'form',
176 'file' => 'system.admin.inc',
177 ),
178 'status_report' => array(
179 'render element' => 'requirements',
180 'file' => 'system.admin.inc',
181 ),
182 'admin_page' => array(
183 'variables' => array('blocks' => NULL),
184 'file' => 'system.admin.inc',
185 ),
186 'admin_block' => array(
187 'variables' => array('block' => NULL),
188 'file' => 'system.admin.inc',
189 ),
190 'admin_block_content' => array(
191 'variables' => array('content' => NULL),
192 'file' => 'system.admin.inc',
193 ),
194 'system_admin_index' => array(
195 'variables' => array('menu_items' => NULL),
196 'file' => 'system.admin.inc',
197 ),
198 'system_powered_by' => array(
199 'variables' => array(),
200 ),
201 'system_compact_link' => array(
202 'variables' => array(),
203 ),
204 'system_date_time_settings' => array(
205 'render element' => 'form',
206 'file' => 'system.admin.inc',
207 ),
208 ));
209 }
210
214 function system_permission() {
215 return array(
216 'administer modules' => array(
217 'title' => t('Administer modules'),
218 ),
219 'administer site configuration' => array(
220 'title' => t('Administer site configuration'),
221 'restrict access' => TRUE,
222 ),
223 'administer themes' => array(
224 'title' => t('Administer themes'),
225 ),
226 'administer software updates' => array(
227 'title' => t('Administer software updates'),
228 'restrict access' => TRUE,
229 ),
230 'administer actions' => array(
231 'title' => t('Administer actions'),
232 ),
233 'access administration pages' => array(
234 'title' => t('Use the administration pages and help'),
235 ),
236 'access site in maintenance mode' => array(
237 'title' => t('Use the site in maintenance mode'),
238 ),
239 'view the administration theme' => array(
240 'title' => t('View the administration theme'),
241 'description' => variable_get('admin_theme') ? '' : t('This is only used when the site is configured to use a separate administration theme on the <a href="@appearance-url">Appearance</a> page.', array('@appearance-url' => url('admin/appearance'))),
242 ),
243 'access site reports' => array(
244 'title' => t('View site reports'),
245 ),
246 'block IP addresses' => array(
247 'title' => t('Block IP addresses'),
248 ),
249 );
250 }
251
255 function system_hook_info() {
256 $hooks['token_info'] = array(
257 'group' => 'tokens',
258 );
259 $hooks['token_info_alter'] = array(
260 'group' => 'tokens',
261 );
262 $hooks['tokens'] = array(
263 'group' => 'tokens',
264 );
265 $hooks['tokens_alter'] = array(
266 'group' => 'tokens',
267 );
268
269 return $hooks;
270 }
271
275 function system_entity_info() {
276 return array(
277 'file' => array(
278 'label' => t('File'),
279 'base table' => 'file_managed',
280 'entity keys' => array(
281 'id' => 'fid',
282 'label' => 'filename',
283 ),
284 'static cache' => FALSE,
285 ),
286 );
287 }
288
292 function system_element_info() {
293 // Top level elements.
294 $types['form'] = array(
295 '#method' => 'post',
296 '#action' => request_uri(),
297 '#theme_wrappers' => array('form'),
298 );
299 $types['page'] = array(
300 '#show_messages' => TRUE,
301 '#theme' => 'page',
302 '#theme_wrappers' => array('html'),
303 );
304 // By default, we don't want Ajax commands being rendered in the context of an
305 // HTML page, so we don't provide defaults for #theme or #theme_wrappers.
306 // However, modules can set these properties (for example, to provide an HTML
307 // debugging page that displays rather than executes Ajax commands).
308 $types['ajax'] = array(
309 '#header' => TRUE,
310 '#commands' => array(),
311 '#error' => NULL,
312 );
313 $types['html_tag'] = array(
314 '#theme' => 'html_tag',
315 '#pre_render' => array('drupal_pre_render_conditional_comments'),
316 '#attributes' => array(),
317 '#value' => NULL,
318 );
319 $types['styles'] = array(
320 '#items' => array(),
321 '#pre_render' => array('drupal_pre_render_styles'),
322 '#group_callback' => 'drupal_group_css',
323 '#aggregate_callback' => 'drupal_aggregate_css',
324 );
325
326 // Input elements.
327 $types['submit'] = array(
328 '#input' => TRUE,
329 '#name' => 'op',
330 '#button_type' => 'submit',
331 '#executes_submit_callback' => TRUE,
332 '#limit_validation_errors' => FALSE,
333 '#process' => array('ajax_process_form'),
334 '#theme_wrappers' => array('button'),
335 );
336 $types['button'] = array(
337 '#input' => TRUE,
338 '#name' => 'op',
339 '#button_type' => 'submit',
340 '#executes_submit_callback' => FALSE,
341 '#limit_validation_errors' => FALSE,
342 '#process' => array('ajax_process_form'),
343 '#theme_wrappers' => array('button'),
344 );
345 $types['image_button'] = array(
346 '#input' => TRUE,
347 '#button_type' => 'submit',
348 '#executes_submit_callback' => TRUE,
349 '#limit_validation_errors' => FALSE,
350 '#process' => array('ajax_process_form'),
351 '#return_value' => TRUE,
352 '#has_garbage_value' => TRUE,
353 '#src' => NULL,
354 '#theme_wrappers' => array('image_button'),
355 );
356 $types['textfield'] = array(
357 '#input' => TRUE,
358 '#size' => 60,
359 '#maxlength' => 128,
360 '#autocomplete_path' => FALSE,
361 '#process' => array('ajax_process_form'),
362 '#theme' => 'textfield',
363 '#theme_wrappers' => array('form_element'),
364 );
365 $types['machine_name'] = array(
366 '#input' => TRUE,
367 '#default_value' => NULL,
368 '#required' => TRUE,
369 '#maxlength' => 64,
370 '#size' => 60,
371 '#autocomplete_path' => FALSE,
372 '#process' => array('form_process_machine_name', 'ajax_process_form'),
373 '#element_validate' => array('form_validate_machine_name'),
374 '#theme' => 'textfield',
375 '#theme_wrappers' => array('form_element'),
376 );
377 $types['password'] = array(
378 '#input' => TRUE,
379 '#size' => 60,
380 '#maxlength' => 128,
381 '#process' => array('ajax_process_form'),
382 '#theme' => 'password',
383 '#theme_wrappers' => array('form_element'),
384 );
385 $types['password_confirm'] = array(
386 '#input' => TRUE,
387 '#process' => array('form_process_password_confirm', 'user_form_process_password_confirm'),
388 '#theme_wrappers' => array('form_element'),
389 );
390 $types['textarea'] = array(
391 '#input' => TRUE,
392 '#cols' => 60,
393 '#rows' => 5,
394 '#resizable' => TRUE,
395 '#process' => array('ajax_process_form'),
396 '#theme' => 'textarea',
397 '#theme_wrappers' => array('form_element'),
398 );
399 $types['radios'] = array(
400 '#input' => TRUE,
401 '#process' => array('form_process_radios'),
402 '#theme_wrappers' => array('radios'),
403 '#pre_render' => array('form_pre_render_conditional_form_element'),
404 );
405 $types['radio'] = array(
406 '#input' => TRUE,
407 '#default_value' => NULL,
408 '#process' => array('ajax_process_form'),
409 '#theme' => 'radio',
410 '#theme_wrappers' => array('form_element'),
411 '#title_display' => 'after',
412 );
413 $types['checkboxes'] = array(
414 '#input' => TRUE,
415 '#process' => array('form_process_checkboxes'),
416 '#theme_wrappers' => array('checkboxes'),
417 '#pre_render' => array('form_pre_render_conditional_form_element'),
418 );
419 $types['checkbox'] = array(
420 '#input' => TRUE,
421 '#return_value' => 1,
422 '#theme' => 'checkbox',
423 '#process' => array('form_process_checkbox', 'ajax_process_form'),
424 '#theme_wrappers' => array('form_element'),
425 '#title_display' => 'after',
426 );
427 $types['select'] = array(
428 '#input' => TRUE,
429 '#multiple' => FALSE,
430 '#process' => array('form_process_select', 'ajax_process_form'),
431 '#theme' => 'select',
432 '#theme_wrappers' => array('form_element'),
433 );
434 $types['weight'] = array(
435 '#input' => TRUE,
436 '#delta' => 10,
437 '#default_value' => 0,
438 '#process' => array('form_process_weight', 'ajax_process_form'),
439 );
440 $types['date'] = array(
441 '#input' => TRUE,
442 '#element_validate' => array('date_validate'),
443 '#process' => array('form_process_date'),
444 '#theme' => 'date',
445 '#theme_wrappers' => array('form_element'),
446 );
447 $types['file'] = array(
448 '#input' => TRUE,
449 '#size' => 60,
450 '#theme' => 'file',
451 '#theme_wrappers' => array('form_element'),
452 );
453 $types['tableselect'] = array(
454 '#input' => TRUE,
455 '#js_select' => TRUE,
456 '#multiple' => TRUE,
457 '#process' => array('form_process_tableselect'),
458 '#options' => array(),
459 '#empty' => '',
460 '#theme' => 'tableselect',
461 );
462
463 // Form structure.
464 $types['item'] = array(
465 '#markup' => '',
466 '#pre_render' => array('drupal_pre_render_markup'),
467 '#theme_wrappers' => array('form_element'),
468 );
469 $types['hidden'] = array(
470 '#input' => TRUE,
471 '#process' => array('ajax_process_form'),
472 '#theme' => 'hidden',
473 );
474 $types['value'] = array(
475 '#input' => TRUE,
476 );
477 $types['markup'] = array(
478 '#markup' => '',
479 '#pre_render' => array('drupal_pre_render_markup'),
480 );
481 $types['link'] = array(
482 '#pre_render' => array('drupal_pre_render_link', 'drupal_pre_render_markup'),
483 );
484 $types['fieldset'] = array(
485 '#collapsible' => FALSE,
486 '#collapsed' => FALSE,
487 '#value' => NULL,
488 '#process' => array('form_process_fieldset', 'ajax_process_form'),
489 '#pre_render' => array('form_pre_render_fieldset'),
490 '#theme_wrappers' => array('fieldset'),
491 );
492 $types['vertical_tabs'] = array(
493 '#theme_wrappers' => array('vertical_tabs'),
494 '#default_tab' => '',
495 '#process' => array('form_process_vertical_tabs'),
496 );
497
498 $types['container'] = array(
499 '#theme_wrappers' => array('container'),
500 '#process' => array('form_process_container'),
501 );
502 $types['actions'] = array(
503 '#theme_wrappers' => array('container'),
504 '#process' => array('form_process_actions', 'form_process_container'),
505 '#weight' => 100,
506 );
507
508 $types['token'] = array(
509 '#input' => TRUE,
510 '#theme' => 'hidden',
511 );
512
513 return $types;
514 }
515
519 function system_menu() {
520 $items['system/files'] = array(
521 'title' => 'File download',
522 'page callback' => 'file_download',
523 'page arguments' => array('private'),
524 'access callback' => TRUE,
525 'type' => MENU_CALLBACK,
526 );
527 $items['system/temporary'] = array(
528 'title' => 'Temporary files',
529 'page callback' => 'file_download',
530 'page arguments' => array('temporary'),
531 'access callback' => TRUE,
532 'type' => MENU_CALLBACK,
533 );
534 $items['system/ajax'] = array(
535 'title' => 'AHAH callback',
536 'page callback' => 'ajax_form_callback',
537 'delivery callback' => 'ajax_deliver',
538 'access callback' => TRUE,
539 'theme callback' => 'ajax_base_page_theme',
540 'type' => MENU_CALLBACK,
541 'file path' => 'includes',
542 'file' => 'form.inc',
543 );
544 $items['system/timezone'] = array(
545 'title' => 'Time zone',
546 'page callback' => 'system_timezone',
547 'access callback' => TRUE,
548 'type' => MENU_CALLBACK,
549 'file' => 'system.admin.inc',
550 );
551 $items['admin'] = array(
552 'title' => 'Administration',
553 'access arguments' => array('access administration pages'),
554 'page callback' => 'system_admin_menu_block_page',
555 'weight' => 9,
556 'menu_name' => 'management',
557 'file' => 'system.admin.inc',
558 );
559 $items['admin/compact'] = array(
560 'title' => 'Compact mode',
561 'page callback' => 'system_admin_compact_page',
562 'access arguments' => array('access administration pages'),
563 'type' => MENU_CALLBACK,
564 'file' => 'system.admin.inc',
565 );
566 $items['admin/tasks'] = array(
567 'title' => 'Tasks',
568 'type' => MENU_DEFAULT_LOCAL_TASK,
569 'weight' => -20,
570 );
571 $items['admin/index'] = array(
572 'title' => 'Index',
573 'page callback' => 'system_admin_index',
574 'access arguments' => array('access administration pages'),
575 'type' => MENU_LOCAL_TASK,
576 'weight' => -18,
577 'file' => 'system.admin.inc',
578 );
579
580 // Menu items that are basically just menu blocks.
581 $items['admin/structure'] = array(
582 'title' => 'Structure',
583 'description' => 'Administer blocks, content types, menus, etc.',
584 'position' => 'right',
585 'weight' => -8,
586 'page callback' => 'system_admin_menu_block_page',
587 'access arguments' => array('access administration pages'),
588 'file' => 'system.admin.inc',
589 );
590 // Appearance.
591 $items['admin/appearance'] = array(
592 'title' => 'Appearance',
593 'description' => 'Select and configure your themes.',
594 'page callback' => 'system_themes_page',
595 'access arguments' => array('administer themes'),
596 'position' => 'left',
597 'weight' => -6,
598 'file' => 'system.admin.inc',
599 );
600 $items['admin/appearance/list'] = array(
601 'title' => 'List',
602 'description' => 'Select and configure your theme',
603 'type' => MENU_DEFAULT_LOCAL_TASK,
604 'weight' => -1,
605 'file' => 'system.admin.inc',
606 );
607 $items['admin/appearance/enable'] = array(
608 'title' => 'Enable theme',
609 'page callback' => 'system_theme_enable',
610 'access arguments' => array('administer themes'),
611 'type' => MENU_CALLBACK,
612 'file' => 'system.admin.inc',
613 );
614 $items['admin/appearance/disable'] = array(
615 'title' => 'Disable theme',
616 'page callback' => 'system_theme_disable',
617 'access arguments' => array('administer themes'),
618 'type' => MENU_CALLBACK,
619 'file' => 'system.admin.inc',
620 );
621 $items['admin/appearance/default'] = array(
622 'title' => 'Set default theme',
623 'page callback' => 'system_theme_default',
624 'access arguments' => array('administer themes'),
625 'type' => MENU_CALLBACK,
626 'file' => 'system.admin.inc',
627 );
628 $items['admin/appearance/settings'] = array(
629 'title' => 'Settings',
630 'description' => 'Configure default and theme specific settings.',
631 'page callback' => 'drupal_get_form',
632 'page arguments' => array('system_theme_settings'),
633 'access arguments' => array('administer themes'),
634 'type' => MENU_LOCAL_TASK,
635 'file' => 'system.admin.inc',
636 'weight' => 20,
637 );
638 // Theme configuration subtabs.
639 $items['admin/appearance/settings/global'] = array(
640 'title' => 'Global settings',
641 'type' => MENU_DEFAULT_LOCAL_TASK,
642 'weight' => -1,
643 );
644
645 foreach (list_themes() as $theme) {
646 $items['admin/appearance/settings/' . $theme->name] = array(
647 'title' => $theme->info['name'],
648 'page arguments' => array('system_theme_settings', $theme->name),
649 'type' => MENU_LOCAL_TASK,
650 'access callback' => '_system_themes_access',
651 'access arguments' => array($theme),
652 'file' => 'system.admin.inc',
653 );
654 }
655
656 // Modules.
657 $items['admin/modules'] = array(
658 'title' => 'Modules',
659 'description' => 'Extend site functionality.',
660 'page callback' => 'drupal_get_form',
661 'page arguments' => array('system_modules'),
662 'access arguments' => array('administer modules'),
663 'file' => 'system.admin.inc',
664 'weight' => -2,
665 );
666 $items['admin/modules/list'] = array(
667 'title' => 'List',
668 'type' => MENU_DEFAULT_LOCAL_TASK,
669 );
670 $items['admin/modules/list/confirm'] = array(
671 'title' => 'List',
672 'access arguments' => array('administer modules'),
673 'type' => MENU_VISIBLE_IN_BREADCRUMB,
674 );
675 $items['admin/modules/uninstall'] = array(
676 'title' => 'Uninstall',
677 'page arguments' => array('system_modules_uninstall'),
678 'access arguments' => array('administer modules'),
679 'type' => MENU_LOCAL_TASK,
680 'file' => 'system.admin.inc',
681 'weight' => 20,
682 );
683 $items['admin/modules/uninstall/confirm'] = array(
684 'title' => 'Uninstall',
685 'access arguments' => array('administer modules'),
686 'type' => MENU_VISIBLE_IN_BREADCRUMB,
687 'file' => 'system.admin.inc',
688 );
689
690 // Configuration.
691 $items['admin/config'] = array(
692 'title' => 'Configuration',
693 'description' => 'Administer settings.',
694 'page callback' => 'system_admin_config_page',
695 'access arguments' => array('access administration pages'),
696 'file' => 'system.admin.inc',
697 );
698
699 // IP address blocking.
700 $items['admin/config/people/ip-blocking'] = array(
701 'title' => 'IP address blocking',
702 'description' => 'Manage blocked IP addresses.',
703 'page callback' => 'system_ip_blocking',
704 'access arguments' => array('block IP addresses'),
705 'file' => 'system.admin.inc',
706 'weight' => 10,
707 );
708 $items['admin/config/people/ip-blocking/delete/%blocked_ip'] = array(
709 'title' => 'Delete IP address',
710 'page callback' => 'drupal_get_form',
711 'page arguments' => array('system_ip_blocking_delete', 5),
712 'access arguments' => array('block IP addresses'),
713 'file' => 'system.admin.inc',
714 );
715
716 // Media settings.
717 $items['admin/config/media'] = array(
718 'title' => 'Media',
719 'description' => 'Media tools.',
720 'position' => 'left',
721 'weight' => -10,
722 'page callback' => 'system_admin_menu_block_page',
723 'access arguments' => array('access administration pages'),
724 'file' => 'system.admin.inc',
725 );
726 $items['admin/config/media/file-system'] = array(
727 'title' => 'File system',
728 'description' => 'Tell Drupal where to store uploaded files and how they are accessed.',
729 'page callback' => 'drupal_get_form',
730 'page arguments' => array('system_file_system_settings'),
731 'access arguments' => array('administer site configuration'),
732 'weight' => -10,
733 'file' => 'system.admin.inc',
734 );
735 $items['admin/config/media/image-toolkit'] = array(
736 'title' => 'Image toolkit',
737 'description' => 'Choose which image toolkit to use if you have installed optional toolkits.',
738 'page callback' => 'drupal_get_form',
739 'page arguments' => array('system_image_toolkit_settings'),
740 'access arguments' => array('administer site configuration'),
741 'weight' => 20,
742 'file' => 'system.admin.inc',
743 );
744
745 // Service settings.
746 $items['admin/config/services'] = array(
747 'title' => 'Web services',
748 'description' => 'Tools related to web services.',
749 'position' => 'right',
750 'weight' => 0,
751 'page callback' => 'system_admin_menu_block_page',
752 'access arguments' => array('access administration pages'),
753 'file' => 'system.admin.inc',
754 );
755 $items['admin/config/services/rss-publishing'] = array(
756 'title' => 'RSS publishing',
757 'description' => 'Configure the site description, the number of items per feed and whether feeds should be titles/teasers/full-text.',
758 'page callback' => 'drupal_get_form',
759 'page arguments' => array('system_rss_feeds_settings'),
760 'access arguments' => array('administer site configuration'),
761 'file' => 'system.admin.inc',
762 );
763
764 // Development settings.
765 $items['admin/config/development'] = array(
766 'title' => 'Development',
767 'description' => 'Development tools.',
768 'position' => 'right',
769 'weight' => -10,
770 'page callback' => 'system_admin_menu_block_page',
771 'access arguments' => array('access administration pages'),
772 'file' => 'system.admin.inc',
773 );
774 $items['admin/config/development/maintenance'] = array(
775 'title' => 'Maintenance mode',
776 'description' => 'Take the site offline for maintenance or bring it back online.',
777 'page callback' => 'drupal_get_form',
778 'page arguments' => array('system_site_maintenance_mode'),
779 'access arguments' => array('administer site configuration'),
780 'file' => 'system.admin.inc',
781 'weight' => -10,
782 );
783 $items['admin/config/development/performance'] = array(
784 'title' => 'Performance',
785 'description' => 'Enable or disable page caching for anonymous users and set CSS and JS bandwidth optimization options.',
786 'page callback' => 'drupal_get_form',
787 'page arguments' => array('system_performance_settings'),
788 'access arguments' => array('administer site configuration'),
789 'file' => 'system.admin.inc',
790 'weight' => -20,
791 );
792 $items['admin/config/development/logging'] = array(
793 'title' => 'Logging and errors',
794 'description' => "Settings for logging and alerts modules. Various modules can route Drupal's system events to different destinations, such as syslog, database, email, etc.",
795 'page callback' => 'drupal_get_form',
796 'page arguments' => array('system_logging_settings'),
797 'access arguments' => array('administer site configuration'),
798 'file' => 'system.admin.inc',
799 'weight' => -15,
800 );
801
802 // Regional and date settings.
803 $items['admin/config/regional'] = array(
804 'title' => 'Regional and language',
805 'description' => 'Regional settings, localization and translation.',
806 'position' => 'left',
807 'weight' => -5,
808 'page callback' => 'system_admin_menu_block_page',
809 'access arguments' => array('access administration pages'),
810 'file' => 'system.admin.inc',
811 );
812 $items['admin/config/regional/settings'] = array(
813 'title' => 'Regional settings',
814 'description' => "Settings for the site's default time zone and country.",
815 'page callback' => 'drupal_get_form',
816 'page arguments' => array('system_regional_settings'),
817 'access arguments' => array('administer site configuration'),
818 'weight' => -20,
819 'file' => 'system.admin.inc',
820 );
821 $items['admin/config/regional/date-time'] = array(
822 'title' => 'Date and time',
823 'description' => 'Configure display formats for date and time.',
824 'page callback' => 'drupal_get_form',
825 'page arguments' => array('system_date_time_settings'),
826 'access arguments' => array('administer site configuration'),
827 'weight' => -15,
828 'file' => 'system.admin.inc',
829 );
830 $items['admin/config/regional/date-time/types'] = array(
831 'title' => 'Types',
832 'description' => 'Configure display formats for date and time.',
833 'page callback' => 'drupal_get_form',
834 'page arguments' => array('system_date_time_settings'),
835 'access arguments' => array('administer site configuration'),
836 'type' => MENU_DEFAULT_LOCAL_TASK,
837 'weight' => -10,
838 'file' => 'system.admin.inc',
839 );
840 $items['admin/config/regional/date-time/types/add'] = array(
841 'title' => 'Add date type',
842 'description' => 'Add new date type.',
843 'page callback' => 'drupal_get_form',
844 'page arguments' => array('system_add_date_format_type_form'),
845 'access arguments' => array('administer site configuration'),
846 'type' => MENU_LOCAL_ACTION,
847 'weight' => -10,
848 'file' => 'system.admin.inc',
849 );
850 $items['admin/config/regional/date-time/types/%/delete'] = array(
851 'title' => 'Delete date type',
852 'description' => 'Allow users to delete a configured date type.',
853 'page callback' => 'drupal_get_form',
854 'page arguments' => array('system_delete_date_format_type_form', 5),
855 'access arguments' => array('administer site configuration'),
856 'file' => 'system.admin.inc',
857 );
858 $items['admin/config/regional/date-time/formats'] = array(
859 'title' => 'Formats',
860 'description' => 'Configure display format strings for date and time.',
861 'page callback' => 'system_date_time_formats',
862 'access arguments' => array('administer site configuration'),
863 'type' => MENU_LOCAL_TASK,
864 'weight' => -9,
865 'file' => 'system.admin.inc',
866 );
867 $items['admin/config/regional/date-time/formats/add'] = array(
868 'title' => 'Add format',
869 'description' => 'Allow users to add additional date formats.',
870 'type' => MENU_LOCAL_ACTION,
871 'page callback' => 'drupal_get_form',
872 'page arguments' => array('system_configure_date_formats_form'),
873 'access arguments' => array('administer site configuration'),
874 'weight' => -10,
875 'file' => 'system.admin.inc',
876 );
877 $items['admin/config/regional/date-time/formats/%/edit'] = array(
878 'title' => 'Edit date format',
879 'description' => 'Allow users to edit a configured date format.',
880 'page callback' => 'drupal_get_form',
881 'page arguments' => array('system_configure_date_formats_form', 5),
882 'access arguments' => array('administer site configuration'),
883 'file' => 'system.admin.inc',
884 );
885 $items['admin/config/regional/date-time/formats/%/delete'] = array(
886 'title' => 'Delete date format',
887 'description' => 'Allow users to delete a configured date format.',
888 'page callback' => 'drupal_get_form',
889 'page arguments' => array('system_date_delete_format_form', 5),
890 'access arguments' => array('administer site configuration'),
891 'file' => 'system.admin.inc',
892 );
893 $items['admin/config/regional/date-time/formats/lookup'] = array(
894 'title' => 'Date and time lookup',
895 'page callback' => 'system_date_time_lookup',
896 'access arguments' => array('administer site configuration'),
897 'type' => MENU_CALLBACK,
898 'file' => 'system.admin.inc',
899 );
900
901 // Search settings.
902 $items['admin/config/search'] = array(
903 'title' => 'Search and metadata',
904 'description' => 'Local site search, metadata and SEO.',
905 'position' => 'left',
906 'weight' => -10,
907 'page callback' => 'system_admin_menu_block_page',
908 'access arguments' => array('access administration pages'),
909 'file' => 'system.admin.inc',
910 );
911 $items['admin/config/search/clean-urls'] = array(
912 'title' => 'Clean URLs',
913 'description' => 'Enable or disable clean URLs for your site.',
914 'page callback' => 'drupal_get_form',
915 'page arguments' => array('system_clean_url_settings'),
916 'access arguments' => array('administer site configuration'),
917 'file' => 'system.admin.inc',
918 'weight' => 5,
919 );
920 $items['admin/config/search/clean-urls/check'] = array(
921 'title' => 'Clean URL check',
922 'page callback' => 'drupal_json_output',
923 'page arguments' => array(array('status' => TRUE)),
924 'access callback' => TRUE,
925 'type' => MENU_CALLBACK,
926 'file' => 'system.admin.inc',
927 );
928
929 // System settings.
930 $items['admin/config/system'] = array(
931 'title' => 'System',
932 'description' => 'General system related configuration.',
933 'position' => 'right',
934 'weight' => -20,
935 'page callback' => 'system_admin_menu_block_page',
936 'access arguments' => array('access administration pages'),
937 'file' => 'system.admin.inc',
938 );
939 $items['admin/config/system/actions'] = array(
940 'title' => 'Actions',
941 'description' => 'Manage the actions defined for your site.',
942 'access arguments' => array('administer actions'),
943 'page callback' => 'system_actions_manage',
944 'file' => 'system.admin.inc',
945 );
946 $items['admin/config/system/actions/manage'] = array(
947 'title' => 'Manage actions',
948 'description' => 'Manage the actions defined for your site.',
949 'page callback' => 'system_actions_manage',
950 'type' => MENU_DEFAULT_LOCAL_TASK,
951 'weight' => -2,
952 'file' => 'system.admin.inc',
953 );
954 $items['admin/config/system/actions/configure'] = array(
955 'title' => 'Configure an advanced action',
956 'page callback' => 'drupal_get_form',
957 'page arguments' => array('system_actions_configure'),
958 'access arguments' => array('administer actions'),
959 'type' => MENU_VISIBLE_IN_BREADCRUMB,
960 'file' => 'system.admin.inc',
961 );
962 $items['admin/config/system/actions/delete/%actions'] = array(
963 'title' => 'Delete action',
964 'description' => 'Delete an action.',
965 'page callback' => 'drupal_get_form',
966 'page arguments' => array('system_actions_delete_form', 5),
967 'access arguments' => array('administer actions'),
968 'file' => 'system.admin.inc',
969 );
970 $items['admin/config/system/actions/orphan'] = array(
971 'title' => 'Remove orphans',
972 'page callback' => 'system_actions_remove_orphans',
973 'access arguments' => array('administer actions'),
974 'type' => MENU_CALLBACK,
975 'file' => 'system.admin.inc',
976 );
977 $items['admin/config/system/site-information'] = array(
978 'title' => 'Site information',
979 'description' => 'Change site name, e-mail address, slogan, default front page, and number of posts per page, error pages.',
980 'page callback' => 'drupal_get_form',
981 'page arguments' => array('system_site_information_settings'),
982 'access arguments' => array('administer site configuration'),
983 'file' => 'system.admin.inc',
984 'weight' => -20,
985 );
986 $items['admin/config/system/cron'] = array(
987 'title' => 'Cron',
988 'description' => 'Manage automatic site maintenance tasks.',
989 'page callback' => 'drupal_get_form',
990 'page arguments' => array('system_cron_settings'),
991 'access arguments' => array('administer site configuration'),
992 'file' => 'system.admin.inc',
993 'weight' => 20,
994 );
995 // Additional categories
996 $items['admin/config/user-interface'] = array(
997 'title' => 'User interface',
998 'description' => 'Tools that enhance the user interface.',
999 'position' => 'right',
1000 'page callback' => 'system_admin_menu_block_page',
1001 'access arguments' => array('access administration pages'),
1002 'file' => 'system.admin.inc',
1003 'weight' => -15,
1004 );
1005 $items['admin/config/workflow'] = array(
1006 'title' => 'Workflow',
1007 'description' => 'Content workflow, editorial workflow tools.',
1008 'position' => 'right',
1009 'weight' => 5,
1010 'page callback' => 'system_admin_menu_block_page',
1011 'access arguments' => array('access administration pages'),
1012 'file' => 'system.admin.inc',
1013 );
1014 $items['admin/config/content'] = array(
1015 'title' => 'Content authoring',
1016 'description' => 'Settings related to formatting and authoring content.',
1017 'position' => 'left',
1018 'weight' => -15,
1019 'page callback' => 'system_admin_menu_block_page',
1020 'access arguments' => array('access administration pages'),
1021 'file' => 'system.admin.inc',
1022 );
1023
1024 // Reports.
1025 $items['admin/reports'] = array(
1026 'title' => 'Reports',
1027 'description' => 'View reports, updates, and errors.',
1028 'page callback' => 'system_admin_menu_block_page',
1029 'access arguments' => array('access site reports'),
1030 'weight' => 5,
1031 'position' => 'left',
1032 'file' => 'system.admin.inc',
1033 );
1034 $items['admin/reports/status'] = array(
1035 'title' => 'Status report',
1036 'description' => "Get a status report about your site's operation and any detected problems.",
1037 'page callback' => 'system_status',
1038 'weight' => -60,
1039 'access arguments' => array('administer site configuration'),
1040 'file' => 'system.admin.inc',
1041 );
1042 $items['admin/reports/status/run-cron'] = array(
1043 'title' => 'Run cron',
1044 'page callback' => 'system_run_cron',
1045 'access arguments' => array('administer site configuration'),
1046 'type' => MENU_CALLBACK,
1047 'file' => 'system.admin.inc',
1048 );
1049 $items['admin/reports/status/php'] = array(
1050 'title' => 'PHP',
1051 'page callback' => 'system_php',
1052 'access arguments' => array('administer site configuration'),
1053 'type' => MENU_CALLBACK,
1054 'file' => 'system.admin.inc',
1055 );
1056
1057 // Default page for batch operations.
1058 $items['batch'] = array(
1059 'page callback' => 'system_batch_page',
1060 'access callback' => TRUE,
1061 'theme callback' => '_system_batch_theme',
1062 'type' => MENU_CALLBACK,
1063 'file' => 'system.admin.inc',
1064 );
1065 return $items;
1066 }
1067
1071 function _system_batch_theme() {
1072 // Retrieve the current state of the batch.
1073 $batch = &batch_get();
1074 if (!$batch && isset($_REQUEST['id'])) {
1075 require_once DRUPAL_ROOT . '/includes/batch.inc';
1076 $batch = batch_load($_REQUEST['id']);
1077 }
1078 // Use the same theme as the page that started the batch.
1079 if (!empty($batch['theme'])) {
1080 return $batch['theme'];
1081 }
1082 }
1083
1087 function system_library() {
1088 // Drupal's Ajax framework.
1089 $libraries['drupal.ajax'] = array(
1090 'title' => 'Drupal AJAX',
1091 'website' => 'http://api.drupal.org/api/drupal/includes--ajax.inc/group/ajax/7',
1092 'version' => VERSION,
1093 'js' => array(
1094 'misc/ajax.js' => array('group' => JS_LIBRARY, 'weight' => 2),
1095 ),
1096 'dependencies' => array(
1097 array('system', 'drupal.progress'),
1098 ),
1099 );
1100
1101 // Drupal's batch API.
1102 $libraries['drupal.batch'] = array(
1103 'title' => 'Drupal batch API',
1104 'version' => VERSION,
1105 'js' => array(
1106 'misc/batch.js' => array('group' => JS_DEFAULT, 'cache' => FALSE),
1107 ),
1108 'dependencies' => array(
1109 array('system', 'drupal.progress'),
1110 ),
1111 );
1112
1113 // Drupal's progress indicator.
1114 $libraries['drupal.progress'] = array(
1115 'title' => 'Drupal progress indicator',
1116 'version' => VERSION,
1117 'js' => array(
1118 'misc/progress.js' => array('group' => JS_DEFAULT),
1119 ),
1120 );
1121
1122 // Drupal's form library.
1123 $libraries['drupal.form'] = array(
1124 'title' => 'Drupal form library',
1125 'version' => VERSION,
1126 'js' => array(
1127 'misc/form.js' => array('group' => JS_LIBRARY, 'weight' => 1),
1128 ),
1129 );
1130
1131 // Drupal's states library.
1132 $libraries['drupal.states'] = array(
1133 'title' => 'Drupal states',
1134 'version' => VERSION,
1135 'js' => array(
1136 'misc/states.js' => array('group' => JS_LIBRARY, 'weight' => 1),
1137 ),
1138 );
1139
1140 // Drupal's collapsible fieldset.
1141 $libraries['drupal.collapse'] = array(
1142 'title' => 'Drupal collapsible fieldset',
1143 'version' => VERSION,
1144 'js' => array(
1145 'misc/collapse.js' => array('group' => JS_DEFAULT),
1146 ),
1147 'dependencies' => array(
1148 // collapse.js relies on drupalGetSummary in form.js
1149 array('system', 'drupal.form'),
1150 ),
1151 );
1152
1153 // Drupal's resizable textarea.
1154 $libraries['drupal.textarea'] = array(
1155 'title' => 'Drupal resizable textarea',
1156 'version' => VERSION,
1157 'js' => array(
1158 'misc/textarea.js' => array('group' => JS_DEFAULT),
1159 ),
1160 );
1161
1162 // Drupal's autocomplete widget.
1163 $libraries['drupal.autocomplete'] = array(
1164 'title' => 'Drupal autocomplete',
1165 'version' => VERSION,
1166 'js' => array(
1167 'misc/autocomplete.js' => array('group' => JS_DEFAULT),
1168 ),
1169 );
1170
1171 // jQuery.
1172 $libraries['jquery'] = array(
1173 'title' => 'jQuery',
1174 'website' => 'http://jquery.com',
1175 'version' => '1.4.4',
1176 'js' => array(
1177 'misc/jquery.js' => array('group' => JS_LIBRARY, 'weight' => -20),
1178 ),
1179 );
1180
1181 // jQuery Once.
1182 $libraries['jquery.once'] = array(
1183 'title' => 'jQuery Once',
1184 'website' => 'http://plugins.jquery.com/project/once',
1185 'version' => '1.2',
1186 'js' => array(
1187 'misc/jquery.once.js' => array('group' => JS_LIBRARY, 'weight' => -19),
1188 ),
1189 );
1190
1191 // jQuery Form Plugin.
1192 $libraries['jquery.form'] = array(
1193 'title' => 'jQuery Form Plugin',
1194 'website' => 'http://malsup.com/jquery/form/',
1195 'version' => '2.52',
1196 'js' => array(
1197 'misc/jquery.form.js' => array(),
1198 ),
1199 'dependencies' => array(
1200 array('system', 'jquery.cookie'),
1201 ),
1202 );
1203
1204 // jQuery BBQ plugin.
1205 $libraries['jquery.bbq'] = array(
1206 'title' => 'jQuery BBQ',
1207 'website' => 'http://benalman.com/projects/jquery-bbq-plugin/',
1208 'version' => '1.2.1',
1209 'js' => array(
1210 'misc/jquery.ba-bbq.js' => array(),
1211 ),
1212 );
1213
1214 // Vertical Tabs.
1215 $libraries['drupal.vertical-tabs'] = array(
1216 'title' => 'Vertical Tabs',
1217 'website' => 'http://drupal.org/node/323112',
1218 'version' => '1.0',
1219 'js' => array(
1220 'misc/vertical-tabs.js' => array(),
1221 ),
1222 'css' => array(
1223 'misc/vertical-tabs.css' => array(),
1224 ),
1225 'dependencies' => array(
1226 // Vertical tabs relies on drupalGetSummary in form.js
1227 array('system', 'drupal.form'),
1228 ),
1229 );
1230
1231 // Farbtastic.
1232 $libraries['farbtastic'] = array(
1233 'title' => 'Farbtastic',
1234 'website' => 'http://code.google.com/p/farbtastic/',
1235 'version' => '1.2',
1236 'js' => array(
1237 'misc/farbtastic/farbtastic.js' => array(),
1238 ),
1239 'css' => array(
1240 'misc/farbtastic/farbtastic.css' => array(),
1241 ),
1242 );
1243
1244 // Cookie.
1245 $libraries['jquery.cookie'] = array(
1246 'title' => 'Cookie',
1247 'website' => 'http://plugins.jquery.com/project/cookie',
1248 'version' => '1.0',
1249 'js' => array(
1250 'misc/jquery.cookie.js' => array(),
1251 ),
1252 );
1253
1254 // jQuery UI.
1255 $libraries['ui'] = array(
1256 'title' => 'jQuery UI: Core',
1257 'website' => 'http://jqueryui.com',
1258 'version' => '1.8.7',
1259 'js' => array(
1260 'misc/ui/jquery.ui.core.min.js' => array('group' => JS_LIBRARY, 'weight' => -11),
1261 ),
1262 'css' => array(
1263 'misc/ui/jquery.ui.core.css' => array(),
1264 'misc/ui/jquery.ui.theme.css' => array(),
1265 ),
1266 );
1267 $libraries['ui.accordion'] = array(
1268 'title' => 'jQuery UI: Accordion',
1269 'website' => 'http://jqueryui.com/demos/accordion/',
1270 'version' => '1.8.7',
1271 'js' => array(
1272 'misc/ui/jquery.ui.accordion.min.js' => array(),
1273 ),
1274 'css' => array(
1275 'misc/ui/jquery.ui.accordion.css' => array(),
1276 ),
1277 'dependencies' => array(
1278 array('system', 'ui.widget'),
1279 ),
1280 );
1281 $libraries['ui.autocomplete'] = array(
1282 'title' => 'jQuery UI: Autocomplete',
1283 'website' => 'http://jqueryui.com/demos/autocomplete/',
1284 'version' => '1.8.7',
1285 'js' => array(
1286 'misc/ui/jquery.ui.autocomplete.min.js' => array(),
1287 ),
1288 'css' => array(
1289 'misc/ui/jquery.ui.autocomplete.css' => array(),
1290 ),
1291 'dependencies' => array(
1292 array('system', 'ui.widget'),
1293 array('system', 'ui.position'),
1294 ),
1295 );
1296 $libraries['ui.button'] = array(
1297 'title' => 'jQuery UI: Button',
1298 'website' => 'http://jqueryui.com/demos/button/',
1299 'version' => '1.8.7',
1300 'js' => array(
1301 'misc/ui/jquery.ui.button.min.js' => array(),
1302 ),
1303 'css' => array(
1304 'misc/ui/jquery.ui.button.css' => array(),
1305 ),
1306 'dependencies' => array(
1307 array('system', 'ui.widget'),
1308 ),
1309 );
1310 $libraries['ui.datepicker'] = array(
1311 'title' => 'jQuery UI: Date Picker',
1312 'website' => 'http://jqueryui.com/demos/datepicker/',
1313 'version' => '1.8.7',
1314 'js' => array(
1315 'misc/ui/jquery.ui.datepicker.min.js' => array(),
1316 ),
1317 'css' => array(
1318 'misc/ui/jquery.ui.datepicker.css' => array(),
1319 ),
1320 'dependencies' => array(
1321 array('system', 'ui'),
1322 ),
1323 );
1324 $libraries['ui.dialog'] = array(
1325 'title' => 'jQuery UI: Dialog',
1326 'website' => 'http://jqueryui.com/demos/dialog/',
1327 'version' => '1.8.7',
1328 'js' => array(
1329 'misc/ui/jquery.ui.dialog.min.js' => array(),
1330 ),
1331 'css' => array(
1332 'misc/ui/jquery.ui.dialog.css' => array(),
1333 ),
1334 'dependencies' => array(
1335 array('system', 'ui.widget'),
1336 array('system', 'ui.button'),
1337 array('system', 'ui.draggable'),
1338 array('system', 'ui.mouse'),
1339 array('system', 'ui.position'),
1340 array('system', 'ui.resizable'),
1341 ),
1342 );
1343 $libraries['ui.draggable'] = array(
1344 'title' => 'jQuery UI: Draggable',
1345 'website' => 'http://jqueryui.com/demos/draggable/',
1346 'version' => '1.8.7',
1347 'js' => array(
1348 'misc/ui/jquery.ui.draggable.min.js' => array(),
1349 ),
1350 'dependencies' => array(
1351 array('system', 'ui.widget'),
1352 array('system', 'ui.mouse'),
1353 ),
1354 );
1355 $libraries['ui.droppable'] = array(
1356 'title' => 'jQuery UI: Droppable',
1357 'website' => 'http://jqueryui.com/demos/droppable/',
1358 'version' => '1.8.7',
1359 'js' => array(
1360 'misc/ui/jquery.ui.droppable.min.js' => array(),
1361 ),
1362 'dependencies' => array(
1363 array('system', 'ui.widget'),
1364 array('system', 'ui.mouse'),
1365 array('system', 'ui.draggable'),
1366 ),
1367 );
1368 $libraries['ui.mouse'] = array(
1369 'title' => 'jQuery UI: Mouse',
1370 'website' => 'http://docs.jquery.com/UI/Mouse',
1371 'version' => '1.8.7',
1372 'js' => array(
1373 'misc/ui/jquery.ui.mouse.min.js' => array(),
1374 ),
1375 'dependencies' => array(
1376 array('system', 'ui.widget'),
1377 ),
1378 );
1379 $libraries['ui.position'] = array(
1380 'title' => 'jQuery UI: Position',
1381 'website' => 'http://jqueryui.com/demos/position/',
1382 'version' => '1.8.7',
1383 'js' => array(
1384 'misc/ui/jquery.ui.position.min.js' => array(),
1385 ),
1386 );
1387 $libraries['ui.progressbar'] = array(
1388 'title' => 'jQuery UI: Progress Bar',
1389 'website' => 'http://jqueryui.com/demos/progressbar/',
1390 'version' => '1.8.7',
1391 'js' => array(
1392 'misc/ui/jquery.ui.progressbar.min.js' => array(),
1393 ),
1394 'css' => array(
1395 'misc/ui/jquery.ui.progressbar.css' => array(),
1396 ),
1397 'dependencies' => array(
1398 array('system', 'ui.widget'),
1399 ),
1400 );
1401 $libraries['ui.resizable'] = array(
1402 'title' => 'jQuery UI: Resizable',
1403 'website' => 'http://jqueryui.com/demos/resizable/',
1404 'version' => '1.8.7',
1405 'js' => array(
1406 'misc/ui/jquery.ui.resizable.min.js' => array(),
1407 ),
1408 'css' => array(
1409 'misc/ui/jquery.ui.resizable.css' => array(),
1410 ),
1411 'dependencies' => array(
1412 array('system', 'ui.widget'),
1413 array('system', 'ui.mouse'),
1414 ),
1415 );
1416 $libraries['ui.selectable'] = array(
1417 'title' => 'jQuery UI: Selectable',
1418 'website' => 'http://jqueryui.com/demos/selectable/',
1419 'version' => '1.8.7',
1420 'js' => array(
1421 'misc/ui/jquery.ui.selectable.min.js' => array(),
1422 ),
1423 'css' => array(
1424 'misc/ui/jquery.ui.selectable.css' => array(),
1425 ),
1426 'dependencies' => array(
1427 array('system', 'ui.widget'),
1428 array('system', 'ui.mouse'),
1429 ),
1430 );
1431 $libraries['ui.slider'] = array(
1432 'title' => 'jQuery UI: Slider',
1433 'website' => 'http://jqueryui.com/demos/slider/',
1434 'version' => '1.8.7',
1435 'js' => array(
1436 'misc/ui/jquery.ui.slider.min.js' => array(),
1437 ),
1438 'css' => array(
1439 'misc/ui/jquery.ui.slider.css' => array(),
1440 ),
1441 'dependencies' => array(
1442 array('system', 'ui.widget'),
1443 array('system', 'ui.mouse'),
1444 ),
1445 );
1446 $libraries['ui.sortable'] = array(
1447 'title' => 'jQuery UI: Sortable',
1448 'website' => 'http://jqueryui.com/demos/sortable/',
1449 'version' => '1.8.7',
1450 'js' => array(
1451 'misc/ui/jquery.ui.sortable.min.js' => array(),
1452 ),
1453 'dependencies' => array(
1454 array('system', 'ui.widget'),
1455 array('system', 'ui.mouse'),
1456 ),
1457 );
1458 $libraries['ui.tabs'] = array(
1459 'title' => 'jQuery UI: Tabs',
1460 'website' => 'http://jqueryui.com/demos/tabs/',
1461 'version' => '1.8.7',
1462 'js' => array(
1463 'misc/ui/jquery.ui.tabs.min.js' => array(),
1464 ),
1465 'css' => array(
1466 'misc/ui/jquery.ui.tabs.css' => array(),
1467 ),
1468 'dependencies' => array(
1469 array('system', 'ui.widget'),
1470 ),
1471 );
1472 $libraries['ui.widget'] = array(
1473 'title' => 'jQuery UI: Widget',
1474 'website' => 'http://docs.jquery.com/UI/Widget',
1475 'version' => '1.8.7',
1476 'js' => array(
1477 'misc/ui/jquery.ui.widget.min.js' => array('group' => JS_LIBRARY, 'weight' => -10),
1478 ),
1479 'dependencies' => array(
1480 array('system', 'ui'),
1481 ),
1482 );
1483 $libraries['effects'] = array(
1484 'title' => 'jQuery UI: Effects',
1485 'website' => 'http://jqueryui.com/demos/effect/',
1486 'version' => '1.8.7',
1487 'js' => array(
1488 'misc/ui/jquery.effects.core.min.js' => array('group' => JS_LIBRARY, 'weight' => -9),
1489 ),
1490 );
1491 $libraries['effects.blind'] = array(
1492 'title' => 'jQuery UI: Effects Blind',
1493 'website' => 'http://jqueryui.com/demos/effect/',
1494 'version' => '1.8.7',
1495 'js' => array(
1496 'misc/ui/jquery.effects.blind.min.js' => array(),
1497 ),
1498 'dependencies' => array(
1499 array('system', 'effects'),
1500 ),
1501 );
1502 $libraries['effects.bounce'] = array(
1503 'title' => 'jQuery UI: Effects Bounce',
1504 'website' => 'http://jqueryui.com/demos/effect/',
1505 'version' => '1.8.7',
1506 'js' => array(
1507 'misc/ui/jquery.effects.bounce.min.js' => array(),
1508 ),
1509 'dependencies' => array(
1510 array('system', 'effects'),
1511 ),
1512 );
1513 $libraries['effects.clip'] = array(
1514 'title' => 'jQuery UI: Effects Clip',
1515 'website' => 'http://jqueryui.com/demos/effect/',
1516 'version' => '1.8.7',
1517 'js' => array(
1518 'misc/ui/jquery.effects.clip.min.js' => array(),
1519 ),
1520 'dependencies' => array(
1521 array('system', 'effects'),
1522 ),
1523 );
1524 $libraries['effects.drop'] = array(
1525 'title' => 'jQuery UI: Effects Drop',
1526 'website' => 'http://jqueryui.com/demos/effect/',
1527 'version' => '1.8.7',
1528 'js' => array(
1529 'misc/ui/jquery.effects.drop.min.js' => array(),
1530 ),
1531 'dependencies' => array(
1532 array('system', 'effects'),
1533 ),
1534 );
1535 $libraries['effects.explode'] = array(
1536 'title' => 'jQuery UI: Effects Explode',
1537 'website' => 'http://jqueryui.com/demos/effect/',
1538 'version' => '1.8.7',
1539 'js' => array(
1540 'misc/ui/jquery.effects.explode.min.js' => array(),
1541 ),
1542 'dependencies' => array(
1543 array('system', 'effects'),
1544 ),
1545 );
1546 $libraries['effects.fade'] = array(
1547 'title' => 'jQuery UI: Effects Fade',
1548 'website' => 'http://jqueryui.com/demos/effect/',
1549 'version' => '1.8.7',
1550 'js' => array(
1551 'misc/ui/jquery.effects.fade.min.js' => array(),
1552 ),
1553 'dependencies' => array(
1554 array('system', 'effects'),
1555 ),
1556 );
1557 $libraries['effects.fold'] = array(
1558 'title' => 'jQuery UI: Effects Fold',
1559 'website' => 'http://jqueryui.com/demos/effect/',
1560 'version' => '1.8.7',
1561 'js' => array(
1562 'misc/ui/jquery.effects.fold.min.js' => array(),
1563 ),
1564 'dependencies' => array(
1565 array('system', 'effects'),
1566 ),
1567 );
1568 $libraries['effects.highlight'] = array(
1569 'title' => 'jQuery UI: Effects Highlight',
1570 'website' => 'http://jqueryui.com/demos/effect/',
1571 'version' => '1.8.7',
1572 'js' => array(
1573 'misc/ui/jquery.effects.highlight.min.js' => array(),
1574 ),
1575 'dependencies' => array(
1576 array('system', 'effects'),
1577 ),
1578 );
1579 $libraries['effects.pulsate'] = array(
1580 'title' => 'jQuery UI: Effects Pulsate',
1581 'website' => 'http://jqueryui.com/demos/effect/',
1582 'version' => '1.8.7',
1583 'js' => array(
1584 'misc/ui/jquery.effects.pulsate.min.js' => array(),
1585 ),
1586 'dependencies' => array(
1587 array('system', 'effects'),
1588 ),
1589 );
1590 $libraries['effects.scale'] = array(
1591 'title' => 'jQuery UI: Effects Scale',
1592 'website' => 'http://jqueryui.com/demos/effect/',
1593 'version' => '1.8.7',
1594 'js' => array(
1595 'misc/ui/jquery.effects.scale.min.js' => array(),
1596 ),
1597 'dependencies' => array(
1598 array('system', 'effects'),
1599 ),
1600 );
1601 $libraries['effects.shake'] = array(
1602 'title' => 'jQuery UI: Effects Shake',
1603 'website' => 'http://jqueryui.com/demos/effect/',
1604 'version' => '1.8.7',
1605 'js' => array(
1606 'misc/ui/jquery.effects.shake.min.js' => array(),
1607 ),
1608 'dependencies' => array(
1609 array('system', 'effects'),
1610 ),
1611 );
1612 $libraries['effects.slide'] = array(
1613 'title' => 'jQuery UI: Effects Slide',
1614 'website' => 'http://jqueryui.com/demos/effect/',
1615 'version' => '1.8.7',
1616 'js' => array(
1617 'misc/ui/jquery.effects.slide.min.js' => array(),
1618 ),
1619 'dependencies' => array(
1620 array('system', 'effects'),
1621 ),
1622 );
1623 $libraries['effects.transfer'] = array(
1624 'title' => 'jQuery UI: Effects Transfer',
1625 'website' => 'http://jqueryui.com/demos/effect/',
1626 'version' => '1.8.7',
1627 'js' => array(
1628 'misc/ui/jquery.effects.transfer.min.js' => array(),
1629 ),
1630 'dependencies' => array(
1631 array('system', 'effects'),
1632 ),
1633 );
1634
1635 // These library names are deprecated. Earlier versions of Drupal 7 didn't
1636 // consistently namespace their libraries, so these names are included for
1637 // backwards compatibility with those versions.
1638 $libraries['once'] = &$libraries['jquery.once'];
1639 $libraries['form'] = &$libraries['jquery.form'];
1640 $libraries['jquery-bbq'] = &$libraries['jquery.bbq'];
1641 $libraries['vertical-tabs'] = &$libraries['drupal.vertical-tabs'];
1642 $libraries['cookie'] = &$libraries['jquery.cookie'];
1643
1644 return $libraries;
1645 }
1646
1650 function system_stream_wrappers() {
1651 $wrappers = array(
1652 'public' => array(
1653 'name' => t('Public files'),
1654 'class' => 'DrupalPublicStreamWrapper',
1655 'description' => t('Public local files served by the webserver.'),
1656 'type' => STREAM_WRAPPERS_LOCAL_NORMAL,
1657 ),
1658 'temporary' => array(
1659 'name' => t('Temporary files'),
1660 'class' => 'DrupalTemporaryStreamWrapper',
1661 'description' => t('Temporary local files for upload and previews.'),
1662 'type' => STREAM_WRAPPERS_LOCAL_HIDDEN,
1663 ),
1664 );
1665
1666 // Only register the private file stream wrapper if a file path has been set.
1667 if (variable_get('file_private_path', FALSE)) {
1668 $wrappers['private'] = array(
1669 'name' => t('Private files'),
1670 'class' => 'DrupalPrivateStreamWrapper',
1671 'description' => t('Private local files served by Drupal.'),
1672 'type' => STREAM_WRAPPERS_LOCAL_NORMAL,
1673 );
1674 }
1675
1676 return $wrappers;
1677 }
1678
1688 function blocked_ip_load($iid) {
1689 return db_query("SELECT * FROM {blocked_ips} WHERE iid = :iid", array(':iid' => $iid))->fetchAssoc();
1690 }
1691
1695 function _system_themes_access($theme) {
1696 return user_access('administer themes') && drupal_theme_access($theme);
1697 }
1698
1775 function system_authorized_init($callback, $file, $arguments = array(), $page_title = NULL) {
1776 // First, figure out what file transfer backends the site supports, and put
1777 // all of those in the SESSION so that authorize.php has access to all of
1778 // them via the class autoloader, even without a full bootstrap.
1779 $_SESSION['authorize_filetransfer_info'] = drupal_get_filetransfer_info();
1780
1781 // Now, define the callback to invoke.
1782 $_SESSION['authorize_operation'] = array(
1783 'callback' => $callback,
1784 'file' => $file,
1785 'arguments' => $arguments,
1786 );
1787
1788 if (isset($page_title)) {
1789 $_SESSION['authorize_operation']['page_title'] = $page_title;
1790 }
1791 }
1792
1803 function system_authorized_get_url(array $options = array()) {
1804 global $base_url;
1805 // Force HTTPS if available, regardless of what the caller specifies.
1806 $options['https'] = TRUE;
1807 // We prefix with $base_url so we get a full path even if clean URLs are
1808 // disabled.
1809 return url($base_url . '/authorize.php', $options);
1810 }
1811
1815 function system_authorized_batch_processing_url() {
1816 return system_authorized_get_url(array('query' => array('batch' => '1')));
1817 }
1818
1824 function system_authorized_run($callback, $file, $arguments = array(), $page_title = NULL) {
1825 system_authorized_init($callback, $file, $arguments, $page_title);
1826 drupal_goto(system_authorized_get_url());
1827 }
1828
1834 function system_authorized_batch_process() {
1835 $finish_url = system_authorized_get_url();
1836 $process_url = system_authorized_batch_processing_url();
1837 batch_process($finish_url, $process_url);
1838 }
1839
1847 function system_updater_info() {
1848 return array(
1849 'module' => array(
1850 'class' => 'ModuleUpdater',
1851 'name' => t('Update modules'),
1852 'weight' => 0,
1853 ),
1854 'theme' => array(
1855 'class' => 'ThemeUpdater',
1856 'name' => t('Update themes'),
1857 'weight' => 0,
1858 ),
1859 );
1860 }
1861
1865 function system_filetransfer_info() {
1866 $backends = array();
1867
1868 // This is the default, will be available on most systems.
1869 if (function_exists('ftp_connect')) {
1870 $backends['ftp'] = array(
1871 'title' => t('FTP'),
1872 'class' => 'FileTransferFTP',
1873 'file' => 'ftp.inc',
1874 'file path' => 'includes/filetransfer',
1875 'weight' => 0,
1876 );
1877 }
1878
1879 // SSH2 lib connection is only available if the proper PHP extension is
1880 // installed.
1881 if (function_exists('ssh2_connect')) {
1882 $backends['ssh'] = array(
1883 'title' => t('SSH'),
1884 'class' => 'FileTransferSSH',
1885 'file' => 'ssh.inc',
1886 'file path' => 'includes/filetransfer',
1887 'weight' => 20,
1888 );
1889 }
1890 return $backends;
1891 }
1892
1896 function system_init() {
1897 $path = drupal_get_path('module', 'system');
1898 // Add the CSS for this module. These aren't in system.info, because they
1899 // need to be in the CSS_SYSTEM group rather than the CSS_DEFAULT group.
1900 drupal_add_css($path . '/system.base.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
1901 if (path_is_admin(current_path())) {
1902 drupal_add_css($path . '/system.admin.css', array('group' => CSS_SYSTEM));
1903 }
1904 drupal_add_css($path . '/system.menus.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
1905 drupal_add_css($path . '/system.messages.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
1906 drupal_add_css($path . '/system.theme.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
1907
1908 // Ignore slave database servers for this request.
1909 //
1910 // In Drupal's distributed database structure, new data is written to the
1911 // master and then propagated to the slave servers. This means there is a
1912 // lag between when data is written to the master and when it is available on
1913 // the slave. At these times, we will want to avoid using a slave server
1914 // temporarily. For example, if a user posts a new node then we want to
1915 // disable the slave server for that user temporarily to allow the slave
1916 // server to catch up. That way, that user will see their changes immediately
1917 // while for other users we still get the benefits of having a slave server,
1918 // just with slightly stale data. Code that wants to disable the slave
1919 // server should use the db_ignore_slave() function to set
1920 // $_SESSION['ignore_slave_server'] to the timestamp after which the slave
1921 // can be re-enabled.
1922 if (isset($_SESSION['ignore_slave_server'])) {
1923 if ($_SESSION['ignore_slave_server'] >= REQUEST_TIME) {
1924 Database::ignoreTarget('default', 'slave');
1925 }
1926 else {
1927 unset($_SESSION['ignore_slave_server']);
1928 }
1929 }
1930
1931 // Add CSS/JS files from module .info files.
1932 system_add_module_assets();
1933 }
1934
1938 function system_add_module_assets() {
1939 foreach (system_get_info('module') as $module => $info) {
1940 if (!empty($info['stylesheets'])) {
1941 foreach ($info['stylesheets'] as $media => $stylesheets) {
1942 foreach ($stylesheets as $stylesheet) {
1943 drupal_add_css($stylesheet, array('every_page' => TRUE, 'media' => $media));
1944 }
1945 }
1946 }
1947 if (!empty($info['scripts'])) {
1948 foreach ($info['scripts'] as $script) {
1949 drupal_add_js($script, array('every_page' => TRUE));
1950 }
1951 }
1952 }
1953 }
1954
1958 function system_custom_theme() {
1959 if (user_access('view the administration theme') && path_is_admin(current_path())) {
1960 return variable_get('admin_theme');
1961 }
1962 }
1963
1967 function system_form_user_profile_form_alter(&$form, &$form_state) {
1968 if ($form['#user_category'] == 'account') {
1969 if (variable_get('configurable_timezones', 1)) {
1970 system_user_timezone($form, $form_state);
1971 }
1972 return $form;
1973 }
1974 }
1975
1979 function system_form_user_register_form_alter(&$form, &$form_state) {
1980 if (variable_get('configurable_timezones', 1)) {
1981 if (variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) == DRUPAL_USER_TIMEZONE_SELECT) {
1982 system_user_timezone($form, $form_state);
1983 }
1984 else {
1985 $form['account']['timezone'] = array(
1986 '#type' => 'hidden',
1987 '#value' => variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) ? '' : variable_get('date_default_timezone', ''),
1988 );
1989 }
1990 return $form;
1991 }
1992 }
1993
1997 function system_user_login(&$edit, $account) {
1998 // If the user has a NULL time zone, notify them to set a time zone.
1999 if (!$account->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) {
2000 drupal_set_message(t('Configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
2001 }
2002 }
2003
2007 function system_user_timezone(&$form, &$form_state) {
2008 global $user;
2009
2010 $account = $form['#user'];
2011
2012 $form['timezone'] = array(
2013 '#type' => 'fieldset',
2014 '#title' => t('Locale settings'),
2015 '#weight' => 6,
2016 '#collapsible' => TRUE,
2017 );
2018 $form['timezone']['timezone'] = array(
2019 '#type' => 'select',
2020 '#title' => t('Time zone'),
2021 '#default_value' => isset($account->timezone) ? $account->timezone : ($account->uid == $user->uid ? variable_get('date_default_timezone', '') : ''),
2022 '#options' => system_time_zones($account->uid != $user->uid),
2023 '#description' => t('Select the desired local time and time zone. Dates and times throughout this site will be displayed using this time zone.'),
2024 );
2025 if (!isset($account->timezone) && $account->uid == $user->uid && empty($form_state['input']['timezone'])) {
2026 $form['timezone']['#description'] = t('Your time zone setting will be automatically detected if possible. Confirm the selection and click save.');
2027 $form['timezone']['timezone']['#attributes'] = array('class' => array('timezone-detect'));
2028 drupal_add_js('misc/timezone.js');
2029 }
2030 }
2031
2035 function system_block_info() {
2036 $blocks['main'] = array(
2037 'info' => t('Main page content'),
2038 // Cached elsewhere.
2039 'cache' => DRUPAL_NO_CACHE,
2040 // Auto-enable in 'content' region by default, which always exists.
2041 // @see system_themes_page(), drupal_render_page()
2042 'status' => 1,
2043 'region' => 'content',
2044 );
2045 $blocks['powered-by'] = array(
2046 'info' => t('Powered by Drupal'),
2047 'weight' => '10',
2048 'cache' => DRUPAL_NO_CACHE,
2049 );
2050 $blocks['help'] = array(
2051 'info' => t('System help'),
2052 'weight' => '5',
2053 'cache' => DRUPAL_NO_CACHE,
2054 // Auto-enable in 'help' region by default, if the theme defines one.
2055 'status' => 1,
2056 'region' => 'help',
2057 );
2058 // System-defined menu blocks.
2059 foreach (menu_list_system_menus() as $menu_name => $title) {
2060 $blocks[$menu_name]['info'] = t($title);
2061 // Menu blocks can't be cached because each menu item can have
2062 // a custom access callback. menu.inc manages its own caching.
2063 $blocks[$menu_name]['cache'] = DRUPAL_NO_CACHE;
2064 }
2065 return $blocks;
2066 }
2067
2074 function system_block_view($delta = '') {
2075 $block = array();
2076 switch ($delta) {
2077 case 'main':
2078 $block['subject'] = NULL;
2079 $block['content'] = drupal_set_page_content();
2080 return $block;
2081 case 'powered-by':
2082 $block['subject'] = NULL;
2083 $block['content'] = theme('system_powered_by');
2084 return $block;
2085 case 'help':
2086 $block['subject'] = NULL;
2087 $block['content'] = menu_get_active_help();
2088 return $block;
2089 default:
2090 // All system menu blocks.
2091 $system_menus = menu_list_system_menus();
2092 if (isset($system_menus[$delta])) {
2093 $block['subject'] = t($system_menus[$delta]);
2094 $block['content'] = menu_tree($delta);
2095 return $block;
2096 }
2097 break;
2098 }
2099 }
2100
2104 function system_preprocess_block(&$variables) {
2105 // System menu blocks should get the same class as menu module blocks.
2106 if ($variables['block']->module == 'system' && in_array($variables['block']->delta, array_keys(menu_list_system_menus()))) {
2107 $variables['classes_array'][] = 'block-menu';
2108 }
2109 }
2110
2117 function system_admin_menu_block($item) {
2118 $cache = &drupal_static(__FUNCTION__, array());
2119 // If we are calling this function for a menu item that corresponds to a
2120 // local task (for example, admin/tasks), then we want to retrieve the
2121 // parent item's child links, not this item's (since this item won't have
2122 // any).
2123 if ($item['tab_root'] != $item['path']) {
2124 $item = menu_get_item($item['tab_root_href']);
2125 }
2126
2127 if (!isset($item['mlid'])) {
2128 $item += db_query("SELECT mlid, menu_name FROM {menu_links} ml WHERE ml.router_path = :path AND module = 'system'", array(':path' => $item['path']))->fetchAssoc();
2129 }
2130
2131 if (isset($cache[$item['mlid']])) {
2132 return $cache[$item['mlid']];
2133 }
2134
2135 $content = array();
2136 $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
2137 $query->join('menu_router', 'm', 'm.path = ml.router_path');
2138 $query
2139 ->fields('ml')
2140 // Weight should be taken from {menu_links}, not {menu_router}.
2141 ->fields('m', array_diff(drupal_schema_fields_sql('menu_router'), array('weight')))
2142 ->condition('ml.plid', $item['mlid'])
2143 ->condition('ml.menu_name', $item['menu_name'])
2144 ->condition('ml.hidden', 0);
2145
2146 foreach ($query->execute() as $link) {
2147 _menu_link_translate($link);
2148 if ($link['access']) {
2149 // The link description, either derived from 'description' in
2150 // hook_menu() or customized via menu module is used as title attribute.
2151 if (!empty($link['localized_options']['attributes']['title'])) {
2152 $link['description'] = $link['localized_options']['attributes']['title'];
2153 unset($link['localized_options']['attributes']['title']);
2154 }
2155 // Prepare for sorting as in function _menu_tree_check_access().
2156 // The weight is offset so it is always positive, with a uniform 5-digits.
2157 $key = (50000 + $link['weight']) . ' ' . drupal_strtolower($link['title']) . ' ' . $link['mlid'];
2158 $content[$key] = $link;
2159 }
2160 }
2161 ksort($content);
2162 $cache[$item['mlid']] = $content;
2163 return $content;
2164 }
2165
2175 function system_check_directory($form_element) {
2176 $directory = $form_element['#value'];
2177 if (strlen($directory) == 0) {
2178 return $form_element;
2179 }
2180
2181 if (!is_dir($directory) && !drupal_mkdir($directory, NULL, TRUE)) {
2182 // If the directory does not exists and cannot be created.
2183 form_set_error($form_element['#parents'][0], t('The directory %directory does not exist and could not be created.', array('%directory' => $directory)));
2184 watchdog('file system', 'The directory %directory does not exist and could not be created.', array('%directory' => $directory), WATCHDOG_ERROR);
2185 }
2186
2187 if (is_dir($directory) && !is_writable($directory) && !drupal_chmod($directory)) {
2188 // If the directory is not writable and cannot be made so.
2189 form_set_error($form_element['#parents'][0], t('The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory)));
2190 watchdog('file system', 'The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory), WATCHDOG_ERROR);
2191 }
2192 elseif (is_dir($directory)) {
2193 if ($form_element['#name'] == 'file_public_path') {
2194 // Create public .htaccess file.
2195 file_create_htaccess($directory, FALSE);
2196 }
2197 else {
2198 // Create private .htaccess file.
2199 file_create_htaccess($directory);
2200 }
2201 }
2202
2203 return $form_element;
2204 }
2205
2214 function system_get_files_database(&$files, $type) {
2215 // Extract current files from database.
2216 $result = db_query("SELECT filename, name, type, status, schema_version, weight FROM {system} WHERE type = :type", array(':type' => $type));
2217 foreach ($result as $file) {
2218 if (isset($files[$file->name]) && is_object($files[$file->name])) {
2219 $file->uri = $file->filename;
2220 foreach ($file as $key => $value) {
2221 if (!isset($files[$file->name]->$key)) {
2222 $files[$file->name]->$key = $value;
2223 }
2224 }
2225 }
2226 }
2227 }
2228
2237 function system_update_files_database(&$files, $type) {
2238 $result = db_query("SELECT * FROM {system} WHERE type = :type", array(':type' => $type));
2239
2240 // Add all files that need to be deleted to a DatabaseCondition.
2241 $delete = db_or();
2242 foreach ($result as $file) {
2243 if (isset($files[$file->name]) && is_object($files[$file->name])) {
2244 // Keep the old filename from the database in case the file has moved.
2245 $old_filename = $file->filename;
2246
2247 $updated_fields = array();
2248
2249 // Handle info specially, compare the serialized value.
2250 $serialized_info = serialize($files[$file->name]->info);
2251 if ($serialized_info != $file->info) {
2252 $updated_fields['info'] = $serialized_info;
2253 }
2254 unset($file->info);
2255
2256 // Scan remaining fields to find only the updated values.
2257 foreach ($file as $key => $value) {
2258 if (isset($files[$file->name]->$key) && $files[$file->name]->$key != $value) {
2259 $updated_fields[$key] = $files[$file->name]->$key;
2260 }
2261 }
2262
2263 // Update the record.
2264 if (count($updated_fields)) {
2265 db_update('system')
2266 ->fields($updated_fields)
2267 ->condition('filename', $old_filename)
2268 ->execute();
2269 }
2270
2271 // Indicate that the file exists already.
2272 $files[$file->name]->exists = TRUE;
2273 }
2274 else {
2275 // File is not found in file system, so delete record from the system table.
2276 $delete->condition('filename', $file->filename);
2277 }
2278 }
2279
2280 if (count($delete) > 0) {
2281 // Delete all missing files from the system table, but only if the plugin
2282 // has never been installed.
2283 db_delete('system')
2284 ->condition($delete)
2285 ->condition('schema_version', -1)
2286 ->execute();
2287 }
2288
2289 // All remaining files are not in the system table, so we need to add them.
2290 $query = db_insert('system')->fields(array('filename', 'name', 'type', 'owner', 'info'));
2291 foreach ($files as &$file) {
2292 if (isset($file->exists)) {
2293 unset($file->exists);
2294 }
2295 else {
2296 $query->values(array(
2297 'filename' => $file->uri,
2298 'name' => $file->name,
2299 'type' => $type,
2300 'owner' => isset($file->owner) ? $file->owner : '',
2301 'info' => serialize($file->info),
2302 ));
2303 $file->type = $type;
2304 $file->status = 0;
2305 $file->schema_version = -1;
2306 }
2307 }
2308 $query->execute();
2309
2310 // If any module or theme was moved to a new location, we need to reset the
2311 // system_list() cache or we will continue to load the old copy, look for
2312 // schema updates in the wrong place, etc.
2313 system_list_reset();
2314 }
2315
2338 function system_get_info($type, $name = NULL) {
2339 $info = array();
2340 if ($type == 'module') {
2341 $type = 'module_enabled';
2342 }
2343 $list = system_list($type);
2344 foreach ($list as $shortname => $item) {
2345 if (!empty($item->status)) {
2346 $info[$shortname] = $item->info;
2347 }
2348 }
2349 if (isset($name)) {
2350 return isset($info[$name]) ? $info[$name] : array();
2351 }
2352 return $info;
2353 }
2354
2361 function _system_rebuild_module_data() {
2362 // Find modules
2363 $modules = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules', 'name', 0);
2364
2365 // Include the installation profile in modules that are loaded.
2366 $profile = drupal_get_profile();
2367 $modules[$profile] = new stdClass();
2368 $modules[$profile]->name = $profile;
2369 $modules[$profile]->uri = 'profiles/' . $profile . '/' . $profile . '.profile';
2370 $modules[$profile]->filename = $profile . '.profile';
2371
2372 // Installation profile hooks are always executed last.
2373 $modules[$profile]->weight = 1000;
2374
2375 // Set defaults for module info.
2376 $defaults = array(
2377 'dependencies' => array(),
2378 'description' => '',
2379 'package' => 'Other',
2380 'version' => NULL,
2381 'php' => DRUPAL_MINIMUM_PHP,
2382 'files' => array(),
2383 'bootstrap' => 0,
2384 );
2385
2386 // Read info files for each module.
2387 foreach ($modules as $key => $module) {
2388 // The module system uses the key 'filename' instead of 'uri' so copy the
2389 // value so it will be used by the modules system.
2390 $modules[$key]->filename = $module->uri;
2391
2392 // Look for the info file.
2393 $module->info = drupal_parse_info_file(dirname($module->uri) . '/' . $module->name . '.info');
2394
2395 // Skip modules that don't provide info.
2396 if (empty($module->info)) {
2397 unset($modules[$key]);
2398 continue;
2399 }
2400
2401 // Merge in defaults and save.
2402 $modules[$key]->info = $module->info + $defaults;
2403
2404 // Prefix stylesheets and scripts with module path.
2405 $path = dirname($module->uri);
2406 if (isset($module->info['stylesheets'])) {
2407 $module->info['stylesheets'] = _system_info_add_path($module->info['stylesheets'], $path);
2408 }
2409 if (isset($module->info['scripts'])) {
2410 $module->info['scripts'] = _system_info_add_path($module->info['scripts'], $path);
2411 }
2412
2413 // Installation profiles are hidden by default, unless explicitly specified
2414 // otherwise in the .info file.
2415 if ($key == $profile && !isset($modules[$key]->info['hidden'])) {
2416 $modules[$key]->info['hidden'] = TRUE;
2417 }
2418
2419 // Invoke hook_system_info_alter() to give installed modules a chance to
2420 // modify the data in the .info files if necessary.
2421 $type = 'module';
2422 drupal_alter('system_info', $modules[$key]->info, $modules[$key], $type);
2423 }
2424
2425 if (isset($modules[$profile])) {
2426 // The installation profile is required, if it's a valid module.
2427 $modules[$profile]->info['required'] = TRUE;
2428 // Add a default distribution name if the profile did not provide one. This
2429 // matches the default value used in install_profile_info().
2430 if (!isset($modules[$profile]->info['distribution_name'])) {
2431 $modules[$profile]->info['distribution_name'] = 'Drupal';
2432 }
2433 }
2434
2435 return $modules;
2436 }
2437
2444 function system_rebuild_module_data() {
2445 $modules_cache = &drupal_static(__FUNCTION__);
2446 // Only rebuild once per request. $modules and $modules_cache cannot be
2447 // combined into one variable, because the $modules_cache variable is reset by
2448 // reference from system_list_reset() during the rebuild.
2449 if (!isset($modules_cache)) {
2450 $modules = _system_rebuild_module_data();
2451 ksort($modules);
2452 system_get_files_database($modules, 'module');
2453 system_update_files_database($modules, 'module');
2454 $modules = _module_build_dependencies($modules);
2455 $modules_cache = $modules;
2456 }
2457 return $modules_cache;
2458 }
2459
2467 function _system_update_bootstrap_status() {
2468 $bootstrap_modules = array();
2469 foreach (bootstrap_hooks() as $hook) {
2470 foreach (module_implements($hook) as $module) {
2471 $bootstrap_modules[] = $module;
2472 }
2473 }
2474 $query = db_update('system')->fields(array('bootstrap' => 0));
2475 if ($bootstrap_modules) {
2476 db_update('system')
2477 ->fields(array('bootstrap' => 1))
2478 ->condition('name', $bootstrap_modules, 'IN')
2479 ->execute();
2480 $query->condition('name', $bootstrap_modules, 'NOT IN');
2481 }
2482 $query->execute();
2483 // Reset the cached list of bootstrap modules.
2484 system_list_reset();
2485 }
2486
2493 function _system_rebuild_theme_data() {
2494 // Find themes
2495 $themes = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info$/', 'themes');
2496 // Allow modules to add further themes.
2497 if ($module_themes = module_invoke_all('system_theme_info')) {
2498 foreach ($module_themes as $name => $uri) {
2499 // @see file_scan_directory()
2500 $themes[$name] = (object) array(
2501 'uri' => $uri,
2502 'filename' => pathinfo($uri, PATHINFO_FILENAME),
2503 'name' => $name,
2504 );
2505 }
2506 }
2507
2508 // Find theme engines
2509 $engines = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.engine$/', 'themes/engines');
2510
2511 // Set defaults for theme info.
2512 $defaults = array(
2513 'engine' => 'phptemplate',
2514 'regions' => array(
2515 'sidebar_first' => 'Left sidebar',
2516 'sidebar_second' => 'Right sidebar',
2517 'content' => 'Content',
2518 'header' => 'Header',
2519 'footer' => 'Footer',
2520 'highlighted' => 'Highlighted',
2521 'help' => 'Help',
2522 'page_top' => 'Page top',
2523 'page_bottom' => 'Page bottom',
2524 ),
2525 'description' => '',
2526 'features' => _system_default_theme_features(),
2527 'screenshot' => 'screenshot.png',
2528 'php' => DRUPAL_MINIMUM_PHP,
2529 'stylesheets' => array(),
2530 'scripts' => array(),
2531 );
2532
2533 $sub_themes = array();
2534 // Read info files for each theme
2535 foreach ($themes as $key => $theme) {
2536 $themes[$key]->filename = $theme->uri;
2537 $themes[$key]->info = drupal_parse_info_file($theme->uri) + $defaults;
2538
2539 // Invoke hook_system_info_alter() to give installed modules a chance to
2540 // modify the data in the .info files if necessary.
2541 $type = 'theme';
2542 drupal_alter('system_info', $themes[$key]->info, $themes[$key], $type);
2543
2544 if (!empty($themes[$key]->info['base theme'])) {
2545 $sub_themes[] = $key;
2546 }
2547 if ($themes[$key]->info['engine'] == 'theme') {
2548 $filename = dirname($themes[$key]->uri) . '/' . $themes[$key]->name . '.theme';
2549 if (file_exists($filename)) {
2550 $themes[$key]->owner = $filename;
2551 $themes[$key]->prefix = $key;
2552 }
2553 }
2554 else {
2555 $engine = $themes[$key]->info['engine'];
2556 if (isset($engines[$engine])) {
2557 $themes[$key]->owner = $engines[$engine]->uri;
2558 $themes[$key]->prefix = $engines[$engine]->name;
2559 $themes[$key]->template = TRUE;
2560 }
2561 }
2562
2563 // Prefix stylesheets and scripts with module path.
2564 $path = dirname($theme->uri);
2565 $theme->info['stylesheets'] = _system_info_add_path($theme->info['stylesheets'], $path);
2566 $theme->info['scripts'] = _system_info_add_path($theme->info['scripts'], $path);
2567
2568 // Give the screenshot proper path information.
2569 if (!empty($themes[$key]->info['screenshot'])) {
2570 $themes[$key]->info['screenshot'] = $path . '/' . $themes[$key]->info['screenshot'];
2571 }
2572 }
2573
2574 // Now that we've established all our master themes, go back and fill in data
2575 // for subthemes.
2576 foreach ($sub_themes as $key) {
2577 $themes[$key]->base_themes = drupal_find_base_themes($themes, $key);
2578 // Don't proceed if there was a problem with the root base theme.
2579 if (!current($themes[$key]->base_themes)) {
2580 continue;
2581 }
2582 $base_key = key($themes[$key]->base_themes);
2583 foreach (array_keys($themes[$key]->base_themes) as $base_theme) {
2584 $themes[$base_theme]->sub_themes[$key] = $themes[$key]->info['name'];
2585 }
2586 // Copy the 'owner' and 'engine' over if the top level theme uses a theme
2587 // engine.
2588 if (isset($themes[$base_key]->owner)) {
2589 if (isset($themes[$base_key]->info['engine'])) {
2590 $themes[$key]->info['engine'] = $themes[$base_key]->info['engine'];
2591 $themes[$key]->owner = $themes[$base_key]->owner;
2592 $themes[$key]->prefix = $themes[$base_key]->prefix;
2593 }
2594 else {
2595 $themes[$key]->prefix = $key;
2596 }
2597 }
2598 }
2599
2600 return $themes;
2601 }
2602
2609 function system_rebuild_theme_data() {
2610 $themes = _system_rebuild_theme_data();
2611 ksort($themes);
2612 system_get_files_database($themes, 'theme');
2613 system_update_files_database($themes, 'theme');
2614 return $themes;
2615 }
2616
2636 function _system_info_add_path($info, $path) {
2637 foreach ($info as $key => $value) {
2638 // Recurse into nested values until we reach the deepest level.
2639 if (is_array($value)) {
2640 $info[$key] = _system_info_add_path($info[$key], $path);
2641 }
2642 // Unset the original value's key and set the new value with prefix, using
2643 // the original value as key, so original values can still be looked up.
2644 else {
2645 unset($info[$key]);
2646 $info[$value] = $path . '/' . $value;
2647 }
2648 }
2649 return $info;
2650 }
2651
2655 function _system_default_theme_features() {
2656 return array(
2657 'logo',
2658 'favicon',
2659 'name',
2660 'slogan',
2661 'node_user_picture',
2662 'comment_user_picture',
2663 'comment_user_verification',
2664 'main_menu',
2665 'secondary_menu',
2666 );
2667 }
2668
2674 function system_find_base_themes($themes, $key, $used_keys = array()) {
2675 return drupal_find_base_themes($themes, $key, $used_keys);
2676 }
2677
2689 function system_region_list($theme_key, $show = REGIONS_ALL) {
2690 $themes = list_themes();
2691 if (!isset($themes[$theme_key])) {
2692 return array();
2693 }
2694
2695 $list = array();
2696 $info = $themes[$theme_key]->info;
2697 // If requested, suppress hidden regions. See block_admin_display_form().
2698 foreach ($info['regions'] as $name => $label) {
2699 if ($show == REGIONS_ALL || !isset($info['regions_hidden']) || !in_array($name, $info['regions_hidden'])) {
2700 $list[$name] = t($label);
2701 }
2702 }
2703
2704 return $list;
2705 }
2706
2710 function system_system_info_alter(&$info, $file, $type) {
2711 // Remove page-top and page-bottom from the blocks UI since they are reserved for
2712 // modules to populate from outside the blocks system.
2713 if ($type == 'theme') {
2714 $info['regions_hidden'][] = 'page_top';
2715 $info['regions_hidden'][] = 'page_bottom';
2716 }
2717 }
2718
2727 function system_default_region($theme) {
2728 $regions = array_keys(system_region_list($theme, REGIONS_VISIBLE));
2729 return isset($regions[0]) ? $regions[0] : '';
2730 }
2731
2755 function system_settings_form($form) {
2756 $form['actions']['#type'] = 'actions';
2757 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
2758
2759 if (!empty($_POST) && form_get_errors()) {
2760 drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
2761 }
2762 $form['#submit'][] = 'system_settings_form_submit';
2763 // By default, render the form using theme_system_settings_form().
2764 if (!isset($form['#theme'])) {
2765 $form['#theme'] = 'system_settings_form';
2766 }
2767 return $form;
2768 }
2769
2776 function system_settings_form_submit($form, &$form_state) {
2777 // Exclude unnecessary elements.
2778 form_state_values_clean($form_state);
2779
2780 foreach ($form_state['values'] as $key => $value) {
2781 if (is_array($value) && isset($form_state['values']['array_filter'])) {
2782 $value = array_keys(array_filter($value));
2783 }
2784 variable_set($key, $value);
2785 }
2786
2787 drupal_set_message(t('The configuration options have been saved.'));
2788 }
2789
2793 function _system_sort_requirements($a, $b) {
2794 if (!isset($a['weight'])) {
2795 if (!isset($b['weight'])) {
2796 return strcmp($a['title'], $b['title']);
2797 }
2798 return -$b['weight'];
2799 }
2800 return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight'];
2801 }
2802
2847 function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') {
2848 $description = isset($description) ? $description : t('This action cannot be undone.');
2849
2850 // Prepare cancel link.
2851 if (isset($_GET['destination'])) {
2852 $options = drupal_parse_url(urldecode($_GET['destination']));
2853 }
2854 elseif (is_array($path)) {
2855 $options = $path;
2856 }
2857 else {
2858 $options = array('path' => $path);
2859 }
2860
2861 drupal_set_title($question, PASS_THROUGH);
2862
2863 $form['#attributes']['class'][] = 'confirmation';
2864 $form['description'] = array('#markup' => $description);
2865 $form[$name] = array('#type' => 'hidden', '#value' => 1);
2866
2867 $form['actions'] = array('#type' => 'actions');
2868 $form['actions']['submit'] = array(
2869 '#type' => 'submit',
2870 '#value' => $yes ? $yes : t('Confirm'),
2871 );
2872 $form['actions']['cancel'] = array(
2873 '#type' => 'link',
2874 '#title' => $no ? $no : t('Cancel'),
2875 '#href' => $options['path'],
2876 '#options' => $options,
2877 );
2878 // By default, render the form using theme_confirm_form().
2879 if (!isset($form['#theme'])) {
2880 $form['#theme'] = 'confirm_form';
2881 }
2882 return $form;
2883 }
2884
2902 function system_admin_compact_mode() {
2903 // PHP converts dots into underscores in cookie names to avoid problems with
2904 // its parser, so we use a converted cookie name.
2905 return isset($_COOKIE['Drupal_visitor_admin_compact_mode']) ? $_COOKIE['Drupal_visitor_admin_compact_mode'] : variable_get('admin_compact_mode', FALSE);
2906 }
2907
2914 function system_admin_compact_page($mode = 'off') {
2915 user_cookie_save(array('admin_compact_mode' => ($mode == 'on')));
2916 drupal_goto();
2917 }
2918
2930 function system_get_module_admin_tasks($module, $info) {
2931 $links = &drupal_static(__FUNCTION__);
2932
2933 if (!isset($links)) {
2934 $links = array();
2935 $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
2936 $query->join('menu_router', 'm', 'm.path = ml.router_path');
2937 $query
2938 ->fields('ml')
2939 // Weight should be taken from {menu_links}, not {menu_router}.
2940 ->fields('m', array_diff(drupal_schema_fields_sql('menu_router'), array('weight')))
2941 ->condition('ml.link_path', 'admin/%', 'LIKE')
2942 ->condition('ml.hidden', 0, '>=')
2943 ->condition('ml.module', 'system')
2944 ->condition('m.number_parts', 1, '>')
2945 ->condition('m.page_callback', 'system_admin_menu_block_page', '<>');
2946 foreach ($query->execute() as $link) {
2947 _menu_link_translate($link);
2948 if ($link['access']) {
2949 $links[$link['router_path']] = $link;
2950 }
2951 }
2952 }
2953
2954 $admin_tasks = array();
2955 $titles = array();
2956 if ($menu = module_invoke($module, 'menu')) {
2957 foreach ($menu as $path => $item) {
2958 if (isset($links[$path])) {
2959 $task = $links[$path];
2960 // The link description, either derived from 'description' in
2961 // hook_menu() or customized via menu module is used as title attribute.
2962 if (!empty($task['localized_options']['attributes']['title'])) {
2963 $task['description'] = $task['localized_options']['attributes']['title'];
2964 unset($task['localized_options']['attributes']['title']);
2965 }
2966
2967 // Check the admin tasks for duplicate names. If one is found,
2968 // append the parent menu item's title to differentiate.
2969 $duplicate_path = array_search($task['title'], $titles);
2970 if ($duplicate_path !== FALSE) {
2971 if ($parent = menu_link_load($task['plid'])) {
2972 // Append the parent item's title to this task's title.
2973 $task['title'] = t('@original_title (@parent_title)', array('@original_title' => $task['title'], '@parent_title' => $parent['title']));
2974 }
2975 if ($parent = menu_link_load($admin_tasks[$duplicate_path]['plid'])) {
2976 // Append the parent item's title to the duplicated task's title.
2977 // We use $links[$duplicate_path] in case there are triplicates.
2978 $admin_tasks[$duplicate_path]['title'] = t('@original_title (@parent_title)', array('@original_title' => $links[$duplicate_path]['title'], '@parent_title' => $parent['title']));
2979 }
2980 }
2981 else {
2982 $titles[$path] = $task['title'];
2983 }
2984
2985 $admin_tasks[$path] = $task;
2986 }
2987 }
2988 }
2989
2990 // Append link for permissions.
2991 if (module_hook($module, 'permission')) {
2992 $item = menu_get_item('admin/people/permissions');
2993 if (!empty($item['access'])) {
2994 $item['link_path'] = $item['href'];
2995 $item['title'] = t('Configure @module permissions', array('@module' => $info['name']));
2996 unset($item['description']);
2997 $item['localized_options']['fragment'] = 'module-' . $module;
2998 $admin_tasks["admin/people/permissions#module-$module"] = $item;
2999 }
3000 }
3001
3002 return $admin_tasks;
3003 }
3004
3010 function system_cron() {
3011 // Cleanup the flood.
3012 db_delete('flood')
3013 ->condition('expiration', REQUEST_TIME, '<')
3014 ->execute();
3015
3016 // Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
3017 // Use separate placeholders for the status to avoid a bug in some versions
3018 // of PHP. See http://drupal.org/node/352956.
3019 $result = db_query('SELECT fid FROM {file_managed} WHERE status <> :permanent AND timestamp < :timestamp', array(
3020 ':permanent' => FILE_STATUS_PERMANENT,
3021 ':timestamp' => REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE
3022 ));
3023 foreach ($result as $row) {
3024 if ($file = file_load($row->fid)) {
3025 $references = file_usage_list($file);
3026 if (empty($references)) {
3027 if (!file_delete($file)) {
3028 watchdog('file system', 'Could not delete temporary file "%path" during garbage collection', array('%path' => $file->uri), WATCHDOG_ERROR);
3029 }
3030 }
3031 else {
3032 watchdog('file system', 'Did not delete temporary file "%path" during garbage collection, because it is in use by the following modules: %modules.', array('%path' => $file->uri, '%modules' => implode(', ', array_keys($references))), WATCHDOG_INFO);
3033 }
3034 }
3035 }
3036
3037 $core = array('cache', 'cache_path', 'cache_filter', 'cache_page', 'cache_form', 'cache_menu');
3038 $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
3039 foreach ($cache_tables as $table) {
3040 cache_clear_all(NULL, $table);
3041 }
3042
3043 // Cleanup the batch table and the queue for failed batches.
3044 db_delete('batch')
3045 ->condition('timestamp', REQUEST_TIME - 864000, '<')
3046 ->execute();
3047 db_delete('queue')
3048 ->condition('created', REQUEST_TIME - 864000, '<')
3049 ->condition('name', 'drupal_batch:%', 'LIKE')
3050 ->execute();
3051
3052 // Reset expired items in the default queue implementation table. If that's
3053 // not used, this will simply be a no-op.
3054 db_update('queue')
3055 ->fields(array(
3056 'expire' => 0,
3057 ))
3058 ->condition('expire', 0, '<>')
3059 ->condition('expire', REQUEST_TIME, '<')
3060 ->execute();
3061 }
3062
3066 function system_flush_caches() {
3067 // Rebuild list of date formats.
3068 system_date_formats_rebuild();
3069 // Reset the menu static caches.
3070 menu_reset_static_cache();
3071 }
3072
3076 function system_action_info() {
3077 return array(
3078 'system_message_action' => array(
3079 'type' => 'system',
3080 'label' => t('Display a message to the user'),
3081 'configurable' => TRUE,
3082 'triggers' => array('any'),
3083 ),
3084 'system_send_email_action' => array(
3085 'type' => 'system',
3086 'label' => t('Send e-mail'),
3087 'configurable' => TRUE,
3088 'triggers' => array('any'),
3089 ),
3090 'system_block_ip_action' => array(
3091 'type' => 'user',
3092 'label' => t('Ban IP address of current user'),
3093 'configurable' => FALSE,
3094 'triggers' => array('any'),
3095 ),
3096 'system_goto_action' => array(
3097 'type' => 'system',
3098 'label' => t('Redirect to URL'),
3099 'configurable' => TRUE,
3100 'triggers' => array('any'),
3101 ),
3102 );
3103 }
3104
3117 function system_send_email_action_form($context) {
3118 // Set default values for form.
3119 if (!isset($context['recipient'])) {
3120 $context['recipient'] = '';
3121 }
3122 if (!isset($context['subject'])) {
3123 $context['subject'] = '';
3124 }
3125 if (!isset($context['message'])) {
3126 $context['message'] = '';
3127 }
3128
3129 $form['recipient'] = array(
3130 '#type' => 'textfield',
3131 '#title' => t('Recipient'),
3132 '#default_value' => $context['recipient'],
3133 '#maxlength' => '254',
3134 '#description' => t('The email address to which the message should be sent OR enter [node:author:mail], [comment:author:mail], etc. if you would like to send an e-mail to the author of the original post.'),
3135 );
3136 $form['subject'] = array(
3137 '#type' => 'textfield',
3138 '#title' => t('Subject'),
3139 '#default_value' => $context['subject'],
3140 '#maxlength' => '254',
3141 '#description' => t('The subject of the message.'),
3142 );
3143 $form['message'] = array(
3144 '#type' => 'textarea',
3145 '#title' => t('Message'),
3146 '#default_value' => $context['message'],
3147 '#cols' => '80',
3148 '#rows' => '20',
3149 '#description' => t('The message that should be sent. You may include placeholders like [node:title], [user:name], and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
3150 );
3151 return $form;
3152 }
3153
3157 function system_send_email_action_validate($form, $form_state) {
3158 $form_values = $form_state['values'];
3159 // Validate the configuration form.
3160 if (!valid_email_address($form_values['recipient']) && strpos($form_values['recipient'], ':mail') === FALSE) {
3161 // We want the literal %author placeholder to be emphasized in the error message.
3162 form_set_error('recipient', t('Enter a valid email address or use a token e-mail address such as %author.', array('%author' => '[node:author:mail]')));
3163 }
3164 }
3165
3169 function system_send_email_action_submit($form, $form_state) {
3170 $form_values = $form_state['values'];
3171 // Process the HTML form to store configuration. The keyed array that
3172 // we return will be serialized to the database.
3173 $params = array(
3174 'recipient' => $form_values['recipient'],
3175 'subject' => $form_values['subject'],
3176 'message' => $form_values['message'],
3177 );
3178 return $params;
3179 }
3180
3199 function system_send_email_action($entity, $context) {
3200 if (empty($context['node'])) {
3201 $context['node'] = $entity;
3202 }
3203
3204 $recipient = token_replace($context['recipient'], $context);
3205
3206 // If the recipient is a registered user with a language preference, use
3207 // the recipient's preferred language. Otherwise, use the system default
3208 // language.
3209 $recipient_account = user_load_by_mail($recipient);
3210 if ($recipient_account) {
3211 $language = user_preferred_language($recipient_account);
3212 }
3213 else {
3214 $language = language_default();
3215 }
3216 $params = array('context' => $context);
3217
3218 if (drupal_mail('system', 'action_send_email', $recipient, $language, $params)) {
3219 watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient));
3220 }
3221 else {
3222 watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient));
3223 }
3224 }
3225
3229 function system_mail($key, &$message, $params) {
3230 $context = $params['context'];
3231
3232 $subject = token_replace($context['subject'], $context);
3233 $body = token_replace($context['message'], $context);
3234
3235 $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
3236 $message['body'][] = $body;
3237 }
3238
3239 function system_message_action_form($context) {
3240 $form['message'] = array(
3241 '#type' => 'textarea',
3242 '#title' => t('Message'),
3243 '#default_value' => isset($context['message']) ? $context['message'] : '',
3244 '#required' => TRUE,
3245 '#rows' => '8',
3246 '#description' => t('The message to be displayed to the current user. You may include placeholders like [node:title], [user:name], and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
3247 );
3248 return $form;
3249 }
3250
3251 function system_message_action_submit($form, $form_state) {
3252 return array('message' => $form_state['values']['message']);
3253 }
3254
3270 function system_message_action(&$entity, $context = array()) {
3271 if (empty($context['node'])) {
3272 $context['node'] = $entity;
3273 }
3274
3275 $context['message'] = token_replace(filter_xss_admin($context['message']), $context);
3276 drupal_set_message($context['message']);
3277 }
3278
3282 function system_goto_action_form($context) {
3283 $form['url'] = array(
3284 '#type' => 'textfield',
3285 '#title' => t('URL'),
3286 '#description' => t('The URL to which the user should be redirected. This can be an internal URL like node/1234 or an external URL like http://drupal.org.'),
3287 '#default_value' => isset($context['url']) ? $context['url'] : '',
3288 '#required' => TRUE,
3289 );
3290 return $form;
3291 }
3292
3293 function system_goto_action_submit($form, $form_state) {
3294 return array(
3295 'url' => $form_state['values']['url']
3296 );
3297 }
3298
3312 function system_goto_action($entity, $context) {
3313 drupal_goto(token_replace($context['url'], $context));
3314 }
3315
3321 function system_block_ip_action() {
3322 $ip = ip_address();
3323 db_insert('blocked_ips')
3324 ->fields(array('ip' => $ip))
3325 ->execute();
3326 watchdog('action', 'Banned IP address %ip', array('%ip' => $ip));
3327 }
3328
3335 function system_time_zones($blank = NULL) {
3336 $zonelist = timezone_identifiers_list();
3337 $zones = $blank ? array('' => t('- None selected -')) : array();
3338 foreach ($zonelist as $zone) {
3339 // Because many time zones exist in PHP only for backward compatibility
3340 // reasons and should not be used, the list is filtered by a regular
3341 // expression.
3342 if (preg_match('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) {
3343 $zones[$zone] = t('@zone: @date', array('@zone' => t(str_replace('_', ' ', $zone)), '@date' => format_date(REQUEST_TIME, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') . ' O', $zone)));
3344 }
3345 }
3346 // Sort the translated time zones alphabetically.
3347 asort($zones);
3348 return $zones;
3349 }
3350
3361 function system_check_http_request() {
3362 // Try to get the content of the front page via drupal_http_request().
3363 $result = drupal_http_request(url('', array('absolute' => TRUE)), array('max_redirects' => 0));
3364 // We only care that we get a http response - this means that Drupal
3365 // can make a http request.
3366 $works = isset($result->code) && ($result->code >= 100) && ($result->code < 600);
3367 variable_set('drupal_http_request_fails', !$works);
3368 return $works;
3369 }
3370
3374 function system_timezone($abbreviation = '', $offset = -1, $is_daylight_saving_time = NULL) {
3375 // An abbreviation of "0" passed in the callback arguments should be
3376 // interpreted as the empty string.
3377 $abbreviation = $abbreviation ? $abbreviation : '';
3378 $timezone = timezone_name_from_abbr($abbreviation, intval($offset), $is_daylight_saving_time);
3379 drupal_json_output($timezone);
3380 }
3381
3387 function theme_system_powered_by() {
3388 return '<span>' . t('Powered by <a href="@poweredby">Drupal</a>', array('@poweredby' => 'http://drupal.org')) . '</span>';
3389 }
3390
3396 function theme_system_compact_link() {
3397 $output = '<div class="compact-link">';
3398 if (system_admin_compact_mode()) {
3399 $output .= l(t('Show descriptions'), 'admin/compact/off', array('attributes' => array('title' => t('Expand layout to include descriptions.')), 'query' => drupal_get_destination()));
3400 }
3401 else {
3402 $output .= l(t('Hide descriptions'), 'admin/compact/on', array('attributes' => array('title' => t('Compress layout by hiding descriptions.')), 'query' => drupal_get_destination()));
3403 }
3404 $output .= '</div>';
3405
3406 return $output;
3407 }
3408
3412 function system_image_toolkits() {
3413 include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'system') . '/' . 'image.gd.inc';
3414 return array(
3415 'gd' => array(
3416 'title' => t('GD2 image manipulation toolkit'),
3417 'available' => function_exists('image_gd_check_settings') && image_gd_check_settings(),
3418 ),
3419 );
3420 }
3421
3450 function system_retrieve_file($url, $destination = NULL, $managed = FALSE, $replace = FILE_EXISTS_RENAME) {
3451 $parsed_url = parse_url($url);
3452 if (!isset($destination)) {
3453 $path = file_build_uri(drupal_basename($parsed_url['path']));
3454 }
3455 else {
3456 if (is_dir(drupal_realpath($destination))) {
3457 // Prevent URIs with triple slashes when glueing parts together.
3458 $path = str_replace('
3459 }
3460 else {
3461 $path = $destination;
3462 }
3463 }
3464 $result = drupal_http_request($url);
3465 if ($result->code != 200) {
3466 drupal_set_message(t('HTTP error @errorcode occurred when trying to fetch @remote.', array('@errorcode' => $result->code, '@remote' => $url)), 'error');
3467 return FALSE;
3468 }
3469 $local = $managed ? file_save_data($result->data, $path, $replace) : file_unmanaged_save_data($result->data, $path, $replace);
3470 if (!$local) {
3471 drupal_set_message(t('@remote could not be saved to @path.', array('@remote' => $url, '@path' => $path)), 'error');
3472 }
3473
3474 return $local;
3475 }
3476
3480 function system_page_alter(&$page) {
3481 // Find all non-empty page regions, and add a theme wrapper function that
3482 // allows them to be consistently themed.
3483 $regions = system_region_list($GLOBALS[' theme ']);
3484 foreach (array_keys($regions) as $region) {
3485 if (!empty($page[$region])) {
3486 $page[$region]['#theme_wrappers'][] = 'region';
3487 $page[$region]['#region'] = $region;
3488 }
3489 }
3490 }
3491
3495 function system_run_automated_cron() {
3496 // If the site is not fully installed, suppress the automated cron run.
3497 // Otherwise it could be triggered prematurely by Ajax requests during
3498 // installation.
3499 if (($threshold = variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD)) > 0 && variable_get('install_task') == 'done') {
3500 $cron_last = variable_get('cron_last', NULL);
3501 if (!isset($cron_last) || (REQUEST_TIME - $cron_last > $threshold)) {
3502 drupal_cron_run();
3503 }
3504 }
3505 }
3506
3528 function system_get_date_types($type = NULL) {
3529 $types = &drupal_static(__FUNCTION__);
3530
3531 if (!isset($types)) {
3532 $types = _system_date_format_types_build();
3533 }
3534
3535 return $type ? (isset($types[$type]) ? $types[$type] : FALSE) : $types;
3536 }
3537
3541 function system_date_format_types() {
3542 return array(
3543 'long' => t('Long'),
3544 'medium' => t('Medium'),
3545 'short' => t('Short'),
3546 );
3547 }
3548
3552 function system_date_formats() {
3553 include_once DRUPAL_ROOT . '/includes/date.inc';
3554 return system_default_date_formats();
3555 }
3556
3582 function system_get_date_formats($type = NULL) {
3583 $date_formats = &drupal_static(__FUNCTION__);
3584
3585 if (!isset($date_formats)) {
3586 $date_formats = _system_date_formats_build();
3587 }
3588
3589 return $type ? (isset($date_formats[$type]) ? $date_formats[$type] : FALSE) : $date_formats;
3590 }
3591
3605 function system_get_date_format($dfid) {
3606 return db_query('SELECT df.dfid, df.format, df.type, df.locked FROM {date_formats} df WHERE df.dfid = :dfid', array(':dfid' => $dfid))->fetch();
3607 }
3608
3612 function system_date_formats_rebuild() {
3613 drupal_static_reset(' system_get_date_formats ');
3614 $date_formats = system_get_date_formats(NULL);
3615
3616 foreach ($date_formats as $type => $formats) {
3617 foreach ($formats as $format => $info) {
3618 system_date_format_save($info);
3619 }
3620 }
3621
3622 // Rebuild configured date formats locale list.
3623 drupal_static_reset(' system_date_format_locale ');
3624 system_date_format_locale();
3625
3626 _system_date_formats_build();
3627 }
3628
3645 function system_date_format_locale($langcode = NULL, $type = NULL) {
3646 $formats = &drupal_static(__FUNCTION__);
3647
3648 if (empty($formats)) {
3649 $formats = array();
3650 $result = db_query("SELECT format, type, language FROM {date_format_locale}");
3651 foreach ($result as $record) {
3652 if (!isset($formats[$record->language])) {
3653 $formats[$record->language] = array();
3654 }
3655 $formats[$record->language][$record->type] = $record->format;
3656 }
3657 }
3658
3659 if ($type && $langcode && !empty($formats[$langcode][$type])) {
3660 return $formats[$langcode][$type];
3661 }
3662 elseif ($langcode && !empty($formats[$langcode])) {
3663 return $formats[$langcode];
3664 }
3665
3666 return FALSE;
3667 }
3668
3684 function _system_date_format_types_build() {
3685 $types = array();
3686
3687 // Get list of modules that implement hook_date_format_types().
3688 $modules = module_implements('date_format_types');
3689
3690 foreach ($modules as $module) {
3691 $module_types = module_invoke($module, 'date_format_types');
3692 foreach ($module_types as $module_type => $type_title) {
3693 $type = array();
3694 $type['module'] = $module;
3695 $type['type'] = $module_type;
3696 $type[' title '] = $type_title;
3697 $type['locked'] = 1;
3698 // Will be over-ridden later if in the db.
3699 $type['is_new'] = TRUE;
3700 $types[$module_type] = $type;
3701 }
3702 }
3703
3704 // Get custom formats added to the database by the end user.
3705 $result = db_query('SELECT dft.type, dft.title, dft.locked FROM {date_format_type} dft ORDER BY dft.title');
3706 foreach ($result as $record) {
3707 if (!isset($types[$record->type])) {
3708 $type = array();
3709 $type['is_new'] = FALSE;
3710 $type['module'] = '';
3711 $type['type'] = $record->type;
3712 $type[' title '] = $record->title;
3713 $type['locked'] = $record->locked;
3714 $types[$record->type] = $type;
3715 }
3716 else {
3717 $type = array();
3718 $type['is_new'] = FALSE; // Over-riding previous setting.
3719 $types[$record->type] = array_merge($types[$record->type], $type);
3720 }
3721 }
3722
3723 // Allow other modules to modify these date types.
3724 drupal_alter('date_format_types', $types);
3725
3726 return $types;
3727 }
3728
3749 function _system_date_formats_build() {
3750 $date_formats = array();
3751
3752 // First handle hook_date_format_types().
3753 $types = _system_date_format_types_build();
3754 foreach ($types as $type => $info) {
3755 system_date_format_type_save($info);
3756 }
3757
3758 // Get formats supplied by various contrib modules.
3759 $module_formats = module_invoke_all('date_formats');
3760
3761 foreach ($module_formats as $module_format) {
3762 // System types are locked.
3763 $module_format['locked'] = 1;
3764 // If no date type is specified, assign 'custom'.
3765 if (!isset($module_format['type'])) {
3766 $module_format['type'] = 'custom';
3767 }
3768 if (!in_array($module_format['type'], array_keys($types))) {
3769 continue;
3770 }
3771 if (!isset($date_formats[$module_format['type']])) {
3772 $date_formats[$module_format['type']] = array();
3773 }
3774
3775 // If another module already set this format, merge in the new settings.
3776 if (isset($date_formats[$module_format['type']][$module_format['format']])) {
3777 $date_formats[$module_format['type']][$module_format['format']] = array_merge_recursive($date_formats[$module_format['type']][$module_format['format']], $module_format);
3778 }
3779 else {
3780 // This setting will be overridden later if it already exists in the db.
3781 $module_format['is_new'] = TRUE;
3782 $date_formats[$module_format['type']][$module_format['format']] = $module_format;
3783 }
3784 }
3785
3786 // Get custom formats added to the database by the end user.
3787 $result = db_query('SELECT df.dfid, df.format, df.type, df.locked, dfl.language FROM {date_formats} df LEFT JOIN {date_format_locale} dfl ON df.format = dfl.format AND df.type = dfl.type ORDER BY df.type, df.format');
3788 foreach ($result as $record) {
3789 // If this date type isn' t set, initialise the array.
3790 if (!isset($date_formats[$record->type])) {
3791 $date_formats[$record->type] = array();
3792 }
3793 $format = (array) $record;
3794 $format['is_new'] = FALSE; // It's in the db, so override this setting.
3795 // If this format not already present, add it to the array.
3796 if (!isset($date_formats[$record->type][$record->format])) {
3797 $format['module'] = '';
3798 $format['locales'] = array($record->language);
3799 $date_formats[$record->type][$record->format] = $format;
3800 }
3801 // Format already present, so merge in settings.
3802 else {
3803 if (!empty($record->language)) {
3804 $format['locales'] = array_merge($date_formats[$record->type][$record->format]['locales'], array($record->language));
3805 }
3806 $date_formats[$record->type][$record->format] = array_merge($date_formats[$record->type][$record->format], $format);
3807 }
3808 }
3809
3810 // Allow other modules to modify these formats.
3811 drupal_alter('date_formats', $date_formats);
3812
3813 return $date_formats;
3814 }
3815
3828 function system_date_format_type_save($type) {
3829 $info = array();
3830 $info['type'] = $type['type'];
3831 $info['title'] = $type['title'];
3832 $info['locked'] = $type['locked'];
3833
3834 // Update date_format table.
3835 if (!empty($type['is_new'])) {
3836 drupal_write_record('date_format_type', $info);
3837 }
3838 else {
3839 drupal_write_record('date_format_type', $info, 'type');
3840 }
3841 }
3842
3849 function system_date_format_type_delete($type) {
3850 db_delete('date_formats')
3851 ->condition('type', $type)
3852 ->execute();
3853 db_delete('date_format_type')
3854 ->condition('type', $type)
3855 ->execute();
3856 db_delete('date_format_locale')
3857 ->condition('type', $type)
3858 ->execute();
3859 }
3860
3877 function system_date_format_save($date_format, $dfid = 0) {
3878 $info = array();
3879 $info['dfid'] = $dfid;
3880 $info['type'] = $date_format['type'];
3881 $info['format'] = $date_format['format'];
3882 $info['locked'] = $date_format['locked'];
3883
3884 // Update date_format table.
3885 if (!empty($date_format['is_new'])) {
3886 drupal_write_record('date_formats', $info);
3887 }
3888 else {
3889 $keys = ($dfid ? array('dfid') : array('format', 'type'));
3890 drupal_write_record('date_formats', $info, $keys);
3891 }
3892
3893 // Retrieve an array of language objects for enabled languages.
3894 $languages = language_list('enabled');
3895 // This list is keyed off the value of $language->enabled; we want the ones
3896 // that are enabled (value of 1).
3897 $languages = $languages[1];
3898
3899 $locale_format = array();
3900 $locale_format['type'] = $date_format['type'];
3901 $locale_format['format'] = $date_format['format'];
3902
3903 // Check if the suggested language codes are configured and enabled.
3904 if (!empty($date_format['locales'])) {
3905 foreach ($date_format['locales'] as $langcode) {
3906 // Only proceed if language is enabled.
3907 if (isset($languages[$langcode])) {
3908 $is_existing = (bool) db_query_range('SELECT 1 FROM {date_format_locale} WHERE type = :type AND language = :language', 0, 1, array(':type' => $date_format['type'], ':language' => $langcode))->fetchField();
3909 if (!$is_existing) {
3910 $locale_format['language'] = $langcode;
3911 drupal_write_record('date_format_locale', $locale_format);
3912 }
3913 }
3914 }
3915 }
3916 }
3917
3924 function system_date_format_delete($dfid) {
3925 db_delete('date_formats')
3926 ->condition('dfid', $dfid)
3927 ->execute();
3928 }
3929
3933 function system_archiver_info() {
3934 $archivers['tar'] = array(
3935 'class' => 'ArchiverTar',
3936 'extensions' => array('tar', 'tgz', 'tar.gz', 'tar.bz2'),
3937 );
3938 if (function_exists('zip_open')) {
3939 $archivers['zip'] = array(
3940 'class' => 'ArchiverZip',
3941 'extensions' => array('zip'),
3942 );
3943 }
3944 return $archivers;
3945 }
3946
3959 function theme_confirm_form($variables) {
3960 return drupal_render_children($variables['form']);
3961 }
3962
3975 function theme_system_settings_form($variables) {
3976 return drupal_render_children($variables['form']);
3977 }
3978
3991 function theme_exposed_filters($variables) {
3992 $form = $variables['form'];
3993 $output = '';
3994
3995 if (isset($form['current'])) {
3996 $items = array();
3997 foreach (element_children($form['current']) as $key) {
3998 $items[] = drupal_render($form['current'][$key]);
3999 }
4000 $output .= theme('item_list', array('items' => $items, 'attributes' => array('class' => array('clearfix', 'current-filters'))));
4001 }
4002
4003 $output .= drupal_render_children($form);
4004
4005 return '<div class="exposed-filters">' . $output . '</div>';
4006 }
4007
4011 function system_admin_paths() {
4012 $paths = array(
4013 'admin' => TRUE,
4014 'admin/*' => TRUE,
4015 'batch' => TRUE,
4016 // This page should not be treated as administrative since it outputs its
4017 // own content (outside of any administration theme).
4018 'admin/reports/status/php' => FALSE,
4019 );
4020 return $paths;
4021 }
system_add_module_assets
system_add_module_assets()
Definition: system.module:1938
system_entity_info
system_entity_info()
Definition: system.module:275
system_send_email_action
system_send_email_action($entity, $context)
Definition: system.module:3199
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
system_form_user_register_form_alter
system_form_user_register_form_alter(&$form, &$form_state)
Definition: system.module:1979
system_preprocess_block
system_preprocess_block(&$variables)
Definition: system.module:2104
system_form_user_profile_form_alter
system_form_user_profile_form_alter(&$form, &$form_state)
Definition: system.module:1967
menu_get_active_help
menu_get_active_help()
Definition: menu.inc:1708
batch_process
batch_process($redirect=NULL, $url= 'batch', $redirect_callback= 'drupal_goto')
Definition: form.inc:4459
system_date_format_delete
system_date_format_delete($dfid)
Definition: system.module:3924
Database\ignoreTarget
static ignoreTarget($key, $target)
Definition: database.inc:1747
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
system_image_toolkits
system_image_toolkits()
Definition: system.module:3412
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
system_goto_action_form
system_goto_action_form($context)
Definition: system.module:3282
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
menu_get_item
menu_get_item($path=NULL, $router_item=NULL)
Definition: menu.inc:447
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_strtolower
drupal_strtolower($text)
Definition: unicode.inc:521
system_goto_action_submit
system_goto_action_submit($form, $form_state)
Definition: system.module:3293
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
system_block_ip_action
system_block_ip_action()
Definition: system.module:3321
system_send_email_action_form
system_send_email_action_form($context)
Definition: system.module:3117
system_authorized_run
system_authorized_run($callback, $file, $arguments=array(), $page_title=NULL)
Definition: system.module:1824
theme_exposed_filters
theme_exposed_filters($variables)
Definition: system.module:3991
REGIONS_ALL
const REGIONS_ALL
Definition: system.module:67
system_time_zones
system_time_zones($blank=NULL)
Definition: system.module:3335
blocked_ip_load
blocked_ip_load($iid)
Definition: system.module:1688
_system_rebuild_module_data
_system_rebuild_module_data()
Definition: system.module:2361
file_build_uri
file_build_uri($path)
Definition: file.inc:960
drupal_parse_info_file
drupal_parse_info_file($filename)
Definition: common.inc:7270
DRUPAL_USER_TIMEZONE_SELECT
const DRUPAL_USER_TIMEZONE_SELECT
Definition: system.module:31
system_custom_theme
system_custom_theme()
Definition: system.module:1958
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
system_block_view
system_block_view($delta= '')
Definition: system.module:2074
WATCHDOG_INFO
const WATCHDOG_INFO
Definition: bootstrap.inc:108
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
system_authorized_get_url
system_authorized_get_url(array $options=array())
Definition: system.module:1803
$module
print $module
Definition: search-results.tpl.php:28
system_retrieve_file
system_retrieve_file($url, $destination=NULL, $managed=FALSE, $replace=FILE_EXISTS_RENAME)
Definition: system.module:3450
system_admin_compact_mode
system_admin_compact_mode()
Definition: system.module:2902
form_state_values_clean
form_state_values_clean(&$form_state)
Definition: form.inc:2159
drupal_mail
drupal_mail($module, $key, $to, $language, $params=array(), $from=NULL, $send=TRUE)
Definition: mail.inc:122
system_system_info_alter
system_system_info_alter(&$info, $file, $type)
Definition: system.module:2710
system_hook_info
system_hook_info()
Definition: system.module:255
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
system_admin_menu_block
system_admin_menu_block($item)
Definition: system.module:2117
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
system_timezone
system_timezone($abbreviation= '', $offset=-1, $is_daylight_saving_time=NULL)
Definition: system.module:3374
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
system_check_http_request
system_check_http_request()
Definition: system.module:3361
path_is_admin
path_is_admin($path)
Definition: path.inc:495
drupal_json_output
drupal_json_output($var=NULL)
Definition: common.inc:5041
system_updater_info
system_updater_info()
Definition: system.module:1847
drupal_realpath
drupal_realpath($uri)
Definition: file.inc:2259
_system_rebuild_theme_data
_system_rebuild_theme_data()
Definition: system.module:2493
system_flush_caches
system_flush_caches()
Definition: system.module:3066
_system_batch_theme
_system_batch_theme()
Definition: system.module:1071
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
user_cookie_save
user_cookie_save(array $values)
Definition: user.module:3958
drupal_http_request
drupal_http_request($url, array $options=array())
Definition: common.inc:787
drupal_theme_access
drupal_theme_access($theme)
Definition: theme.inc:47
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
module_exists
module_exists($module)
Definition: module.inc:274
ip_address
ip_address()
Definition: bootstrap.inc:2890
_system_default_theme_features
_system_default_theme_features()
Definition: system.module:2655
system_list
system_list($type)
Definition: module.inc:122
_menu_link_translate
_menu_link_translate(&$item, $translate=FALSE)
Definition: menu.inc:870
FILE_STATUS_PERMANENT
const FILE_STATUS_PERMANENT
Definition: file.inc:70
system_send_email_action_submit
system_send_email_action_submit($form, $form_state)
Definition: system.module:3169
system_rebuild_theme_data
system_rebuild_theme_data()
Definition: system.module:2609
system_goto_action
system_goto_action($entity, $context)
Definition: system.module:3312
system_default_region
system_default_region($theme)
Definition: system.module:2727
menu_reset_static_cache
menu_reset_static_cache()
Definition: menu.inc:2686
system_menu
system_menu()
Definition: system.module:519
system_get_files_database
system_get_files_database(&$files, $type)
Definition: system.module:2214
db_or
db_or()
Definition: database.inc:2662
request_uri
request_uri()
Definition: bootstrap.inc:1609
_system_info_add_path
_system_info_add_path($info, $path)
Definition: system.module:2636
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
token_replace
token_replace($text, array $data=array(), array $options=array())
Definition: token.inc:79
file_delete
file_delete(stdClass $file, $force=FALSE)
Definition: file.inc:1268
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
system_rebuild_module_data
system_rebuild_module_data()
Definition: system.module:2444
CSS_SYSTEM
const CSS_SYSTEM
Definition: common.inc:60
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
system_init
system_init()
Definition: system.module:1896
system_message_action_submit
system_message_action_submit($form, $form_state)
Definition: system.module:3251
user_load_by_mail
user_load_by_mail($mail)
Definition: user.module:381
system_action_info
system_action_info()
Definition: system.module:3076
module_hook
module_hook($module, $hook)
Definition: module.inc:659
user_preferred_language
user_preferred_language($account, $default=NULL)
Definition: user.module:3524
system_list_reset
system_list_reset()
Definition: module.inc:224
system_date_formats_rebuild
system_date_formats_rebuild()
Definition: system.module:3612
system_authorized_batch_processing_url
system_authorized_batch_processing_url()
Definition: system.module:1815
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
_system_themes_access
_system_themes_access($theme)
Definition: system.module:1695
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$url
print $url
Definition: search-result.tpl.php:70
system_get_info
system_get_info($type, $name=NULL)
Definition: system.module:2338
$info
$info
Definition: color.inc:6
DRUPAL_MINIMUM_PHP
const DRUPAL_MINIMUM_PHP
Definition: bootstrap.inc:21
STREAM_WRAPPERS_LOCAL_HIDDEN
const STREAM_WRAPPERS_LOCAL_HIDDEN
Definition: stream_wrappers.inc:67
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
drupal_get_profile
drupal_get_profile()
Definition: common.inc:222
drupal_mkdir
drupal_mkdir($uri, $mode=NULL, $recursive=FALSE, $context=NULL)
Definition: file.inc:2359
theme_system_powered_by
theme_system_powered_by()
Definition: system.module:3387
system_library
system_library()
Definition: system.module:1087
system_theme
system_theme()
Definition: system.module:154
language_list
language_list($field= 'language')
Definition: bootstrap.inc:2723
system_check_directory
system_check_directory($form_element)
Definition: system.module:2175
system_admin_compact_page
system_admin_compact_page($mode= 'off')
Definition: system.module:2914
DRUPAL_USER_TIMEZONE_DEFAULT
const DRUPAL_USER_TIMEZONE_DEFAULT
Definition: system.module:21
system_date_format_locale
system_date_format_locale($langcode=NULL, $type=NULL)
Definition: system.module:3645
$value
print $value
Definition: user-profile-item.tpl.php:26
file_load
file_load($fid)
Definition: file.inc:580
menu_link_load
menu_link_load($mlid)
Definition: menu.inc:2635
batch_load
batch_load($id)
Definition: batch.inc:27
_system_update_bootstrap_status
_system_update_bootstrap_status()
Definition: system.module:2467
system_block_info
system_block_info()
Definition: system.module:2035
bootstrap_hooks
bootstrap_hooks()
Definition: bootstrap.inc:1375
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
system_region_list
system_region_list($theme_key, $show=REGIONS_ALL)
Definition: system.module:2689
theme_confirm_form
theme_confirm_form($variables)
Definition: system.module:3959
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
update_manager_access
update_manager_access()
Definition: update.module:263
$output
$output
Definition: authorize.php:93
system_cron
system_cron()
Definition: system.module:3010
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
user_access
user_access($string, $account=NULL)
Definition: user.module:794
_system_sort_requirements
_system_sort_requirements($a, $b)
Definition: system.module:2793
system_message_action_form
system_message_action_form($context)
Definition: system.module:3239
file_create_htaccess
file_create_htaccess($directory, $private=TRUE, $force_overwrite=FALSE)
Definition: file.inc:477
drupal_schema_fields_sql
drupal_schema_fields_sql($table, $prefix=NULL)
Definition: common.inc:7055
system_authorized_init
system_authorized_init($callback, $file, $arguments=array(), $page_title=NULL)
Definition: system.module:1775
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
system_date_format_save
system_date_format_save($date_format, $dfid=0)
Definition: system.module:3877
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
form_get_errors
form_get_errors()
Definition: form.inc:1634
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
drupal_parse_url
drupal_parse_url($url)
Definition: common.inc:580
menu_list_system_menus
menu_list_system_menus()
Definition: menu.inc:1792
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
MENU_VISIBLE_IN_BREADCRUMB
const MENU_VISIBLE_IN_BREADCRUMB
Definition: menu.inc:96
image_gd_check_settings
image_gd_check_settings()
Definition: image.gd.inc:58
DRUPAL_MAXIMUM_TEMP_FILE_AGE
const DRUPAL_MAXIMUM_TEMP_FILE_AGE
Definition: system.module:11
system_find_base_themes
system_find_base_themes($themes, $key, $used_keys=array())
Definition: system.module:2674
system_stream_wrappers
system_stream_wrappers()
Definition: system.module:1650
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
system_mail
system_mail($key, &$message, $params)
Definition: system.module:3229
valid_email_address
valid_email_address($mail)
Definition: common.inc:1186
drupal_find_base_themes
drupal_find_base_themes($themes, $key, $used_keys=array())
Definition: theme.inc:843
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
drupal_chmod
drupal_chmod($uri, $mode=NULL)
Definition: file.inc:2180
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
system_authorized_batch_process
system_authorized_batch_process()
Definition: system.module:1834
system_user_timezone
system_user_timezone(&$form, &$form_state)
Definition: system.module:2007
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
JS_LIBRARY
const JS_LIBRARY
Definition: common.inc:75
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
system_help
system_help($path, $arg)
Definition: system.module:72
DRUPAL_NO_CACHE
const DRUPAL_NO_CACHE
Definition: common.inc:127
system_settings_form_submit
system_settings_form_submit($form, &$form_state)
Definition: system.module:2776
STREAM_WRAPPERS_LOCAL_NORMAL
const STREAM_WRAPPERS_LOCAL_NORMAL
Definition: stream_wrappers.inc:91
language_default
language_default($property=NULL)
Definition: bootstrap.inc:2765
VERSION
const VERSION
Definition: bootstrap.inc:11
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
JS_DEFAULT
const JS_DEFAULT
Definition: common.inc:80
$row
$row
Definition: block-admin-display-form.tpl.php:47
DRUPAL_PHP_FUNCTION_PATTERN
const DRUPAL_PHP_FUNCTION_PATTERN
Definition: bootstrap.inc:249
title
print $topic title
Definition: forum-topic-list.tpl.php:50
batch_get
& batch_get()
Definition: form.inc:4538
FILE_EXISTS_RENAME
const FILE_EXISTS_RENAME
Definition: file.inc:51
file_usage_list
file_usage_list(stdClass $file)
Definition: file.inc:642
drupal_system_listing
drupal_system_listing($mask, $directory, $key= 'name', $min_depth=1)
Definition: common.inc:5368
drupal_set_page_content
drupal_set_page_content($content=NULL)
Definition: common.inc:5454
_module_build_dependencies
_module_build_dependencies($files)
Definition: module.inc:245
system_archiver_info
system_archiver_info()
Definition: system.module:3933
list_themes
list_themes($refresh=FALSE)
Definition: theme.inc:774
drupal_basename
drupal_basename($uri, $suffix=NULL)
Definition: file.inc:2317
menu_tree
menu_tree($menu_name)
Definition: menu.inc:992
drupal_common_theme
drupal_common_theme()
Definition: common.inc:6721
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
system_user_login
system_user_login(&$edit, $account)
Definition: system.module:1997
system_update_files_database
system_update_files_database(&$files, $type)
Definition: system.module:2237
system_message_action
system_message_action(&$entity, $context=array())
Definition: system.module:3270
current_path
current_path()
Definition: path.inc:354
system_date_format_type_delete
system_date_format_type_delete($type)
Definition: system.module:3849
system_get_date_formats
system_get_date_formats($type=NULL)
Definition: system.module:3582
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
theme_system_compact_link
theme_system_compact_link()
Definition: system.module:3396
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
system_admin_paths
system_admin_paths()
Definition: system.module:4011
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
REGIONS_VISIBLE
const REGIONS_VISIBLE
Definition: system.module:60
system_send_email_action_validate
system_send_email_action_validate($form, $form_state)
Definition: system.module:3157
system_permission
system_permission()
Definition: system.module:214
system_settings_form
system_settings_form($form)
Definition: system.module:2755
drupal_get_filetransfer_info
drupal_get_filetransfer_info()
Definition: common.inc:8200
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
system_get_module_admin_tasks
system_get_module_admin_tasks($module, $info)
Definition: system.module:2930
$links
print $links
Definition: poll-results--block.tpl.php:28
system_filetransfer_info
system_filetransfer_info()
Definition: system.module:1865
theme_system_settings_form
theme_system_settings_form($variables)
Definition: system.module:3975
system_element_info
system_element_info()
Definition: system.module:292
system_date_format_type_save
system_date_format_type_save($type)
Definition: system.module:3828
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/image/image.api.php Source File

  • modules
  • image
image.api.php
Go to the documentation of this file.
1 <?php
2
38 function hook_image_effect_info() {
39 $effects = array();
40
41 $effects['mymodule_resize'] = array(
42 'label' => t('Resize'),
43 'help' => t('Resize an image to an exact set of dimensions, ignoring aspect ratio.'),
44 'effect callback' => 'mymodule_resize_effect',
45 'dimensions callback' => 'mymodule_resize_dimensions',
46 'form callback' => 'mymodule_resize_form',
47 'summary theme' => 'mymodule_resize_summary',
48 );
49
50 return $effects;
51 }
52
61 function hook_image_effect_info_alter(&$effects) {
62 // Override the Image module's crop effect with more options.
63 $effects['image_crop']['effect callback'] = 'mymodule_crop_effect';
64 $effects['image_crop']['dimensions callback'] = 'mymodule_crop_dimensions';
65 $effects['image_crop']['form callback'] = 'mymodule_crop_form';
66 }
67
78 function hook_image_style_save($style) {
79 // If a module defines an image style and that style is renamed by the user
80 // the module should update any references to that style.
81 if (isset($style['old_name']) && $style['old_name'] == variable_get('mymodule_image_style', '')) {
82 variable_set('mymodule_image_style', $style['name']);
83 }
84 }
85
97 function hook_image_style_delete($style) {
98 // Administrators can choose an optional replacement style when deleting.
99 // Update the modules style variable accordingly.
100 if (isset($style['old_name']) && $style['old_name'] == variable_get('mymodule_image_style', '')) {
101 variable_set('mymodule_image_style', $style['name']);
102 }
103 }
104
117 function hook_image_style_flush($style) {
118 // Empty cached data that contains information about the style.
119 cache_clear_all('*', 'cache_mymodule', TRUE);
120 }
121
142 function hook_image_styles_alter(&$styles) {
143 // Check that we only affect a default style.
144 if ($styles['thumbnail']['storage'] == IMAGE_STORAGE_DEFAULT) {
145 // Add an additional effect to the thumbnail style.
146 $styles['thumbnail']['effects'][] = array(
147 'name' => 'image_desaturate',
148 'data' => array(),
149 'weight' => 1,
150 'effect callback' => 'image_desaturate_effect',
151 );
152 }
153 }
154
176 function hook_image_default_styles() {
177 $styles = array();
178
179 $styles['mymodule_preview'] = array(
180 'label' => 'My module preview',
181 'effects' => array(
182 array(
183 'name' => 'image_scale',
184 'data' => array('width' => 400, 'height' => 400, 'upscale' => 1),
185 'weight' => 0,
186 ),
187 array(
188 'name' => 'image_desaturate',
189 'data' => array(),
190 'weight' => 1,
191 ),
192 ),
193 );
194
195 return $styles;
196 }
197
hook_image_style_flush
hook_image_style_flush($style)
Definition: image.api.php:117
hook_image_default_styles
hook_image_default_styles()
Definition: image.api.php:176
hook_image_styles_alter
hook_image_styles_alter(&$styles)
Definition: image.api.php:142
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
IMAGE_STORAGE_DEFAULT
const IMAGE_STORAGE_DEFAULT
Definition: image.module:21
hook_image_style_save
hook_image_style_save($style)
Definition: image.api.php:78
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
$styles
print $styles
Definition: html.tpl.php:52
hook_image_style_delete
hook_image_style_delete($style)
Definition: image.api.php:97
hook_image_effect_info
hook_image_effect_info()
Definition: image.api.php:38
hook_image_effect_info_alter
hook_image_effect_info_alter(&$effects)
Definition: image.api.php:61
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll-bar.tpl.php Source File

  • modules
  • poll
poll-bar.tpl.php
Go to the documentation of this file.
1 <?php
2
18 ?>
19
20 <div class="text"><?php print $title; ?></div>
21 <div class="bar">
22 <div style="width: <?php print $percentage; ?>%;" class="foreground"></div>
23 </div>
24 <div class="percent">
25 <?php print $percentage; ?>% (<?php print format_plural($votes, '1 vote', '@count votes'); ?>)
26 </div>
$percentage
print $percentage
Definition: poll-bar--block.tpl.php:22
print
print
Definition: php-2.php:2
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.api.php Source File

  • modules
  • update
update.api.php
Go to the documentation of this file.
1 <?php
2
37 function hook_update_projects_alter(&$projects) {
38 // Hide a site-specific module from the list.
39 unset($projects['site_specific_module']);
40
41 // Add a disabled module to the list.
42 // The key for the array should be the machine-readable project "short name".
43 $projects['disabled_project_name'] = array(
44 // Machine-readable project short name (same as the array key above).
45 'name' => 'disabled_project_name',
46 // Array of values from the main .info file for this project.
47 'info' => array(
48 'name' => 'Some disabled module',
49 'description' => 'A module not enabled on the site that you want to see in the available updates report.',
50 'version' => '7.x-1.0',
51 'core' => '7.x',
52 // The maximum file change time (the "ctime" returned by the filectime()
53 // PHP method) for all of the .info files included in this project.
54 '_info_file_ctime' => 1243888165,
55 ),
56 // The date stamp when the project was released, if known. If the disabled
57 // project was an officially packaged release from drupal.org, this will
58 // be included in the .info file as the 'datestamp' field. This only
59 // really matters for development snapshot releases that are regenerated,
60 // so it can be left undefined or set to 0 in most cases.
61 'datestamp' => 1243888185,
62 // Any modules (or themes) included in this project. Keyed by machine-
63 // readable "short name", value is the human-readable project name printed
64 // in the UI.
65 'includes' => array(
66 'disabled_project' => 'Disabled module',
67 'disabled_project_helper' => 'Disabled module helper module',
68 'disabled_project_foo' => 'Disabled module foo add-on module',
69 ),
70 // Does this project contain a 'module', 'theme', 'disabled-module', or
71 // 'disabled-theme'?
72 'project_type' => 'disabled-module',
73 );
74 }
75
85 function hook_update_status_alter(&$projects) {
86 $settings = variable_get('update_advanced_project_settings', array());
87 foreach ($projects as $project => $project_info) {
88 if (isset($settings[$project]) && isset($settings[$project]['check']) &&
89 ($settings[$project]['check'] == 'never' ||
90 (isset($project_info['recommended']) &&
91 $settings[$project]['check'] === $project_info['recommended']))) {
92 $projects[$project]['status'] = UPDATE_NOT_CHECKED;
93 $projects[$project]['reason'] = t('Ignored from settings');
94 if (!empty($settings[$project]['notes'])) {
95 $projects[$project]['extra'][] = array(
96 'class' => array('admin-note'),
97 'label' => t('Administrator note'),
98 'data' => $settings[$project]['notes'],
99 );
100 }
101 }
102 }
103 }
104
122 function hook_verify_update_archive($project, $archive_file, $directory) {
123 $errors = array();
124 if (!file_exists($directory)) {
125 $errors[] = t('The %directory does not exist.', array('%directory' => $directory));
126 }
127 // Add other checks on the archive integrity here.
128 return $errors;
129 }
130
hook_verify_update_archive
hook_verify_update_archive($project, $archive_file, $directory)
Definition: update.api.php:122
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
hook_update_projects_alter
hook_update_projects_alter(&$projects)
Definition: update.api.php:37
UPDATE_NOT_CHECKED
const UPDATE_NOT_CHECKED
Definition: update.module:49
hook_update_status_alter
hook_update_status_alter(&$projects)
Definition: update.api.php:85
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/cron_example/cron_example.module Source File

  • examples
  • cron_example
cron_example.module
Go to the documentation of this file.
1 <?php
2
22 function cron_example_menu() {
23
24 $items['examples/cron_example'] = array(
25 'title' => 'Cron Example',
26 'page callback' => 'drupal_get_form',
27 'page arguments' => array('cron_example_form'),
28 'access callback' => TRUE,
29 );
30
31 return $items;
32 }
33
37 function cron_example_form($form, &$form_state) {
38 $form['status'] = array(
39 '#type' => 'fieldset',
40 '#title' => t('Cron status information'),
41 );
42 $form['status']['intro'] = array(
43 '#markup' => '<div>' . t('The cron example demonstrates hook_cron() and hook_cron_queue_info() processing. If you have administrative privileges you can run cron from this page and see the results.') . '</div>',
44 );
45 $form['status']['last'] = array(
46 '#markup' => '<div>' . t('cron_example_cron() will next execute the first time cron runs after %time (%seconds seconds from now)' . '</div>',
47 array(
48 '%time' => date_iso8601(variable_get('cron_example_next_execution', time())),
49 '%seconds' => variable_get('cron_example_next_execution', time()) - time(),
50 )
51 ),
52 );
53
54 if (user_access('administer site configuration')) {
55 $form['cron_run'] = array(
56 '#type' => 'fieldset',
57 '#title' => t('Run cron manually'),
58 );
59 $form['cron_run']['cron_reset'] = array(
60 '#type' => 'checkbox',
61 '#title' => t("Run cron_example's cron regardless of whether interval has expired."),
62 '#default_value' => FALSE,
63 );
64 $form['cron_run']['cron_trigger'] = array(
65 '#type' => 'submit',
66 '#value' => t('Run cron now'),
67 '#submit' => array('cron_example_form_cron_run_submit'),
68 );
69 }
70
71 $form['cron_queue_setup'] = array(
72 '#type' => 'fieldset',
73 '#title' => t('Cron queue setup (for hook_cron_queue_info(), etc.)'),
74 );
75 $queue_1 = DrupalQueue::get('cron_example_queue_1');
76 $queue_2 = DrupalQueue::get('cron_example_queue_2');
77 $form['cron_queue_setup']['current_cron_queue_status'] = array(
78 '#markup' => '<div>' . t('There are currently %queue_1 items in queue 1 and %queue_2 items in queue 2',
79 array(
80 '%queue_1' => $queue_1->numberOfItems(),
81 '%queue_2' => $queue_2->numberOfItems(),
82 )) . '</div>',
83 );
84 $form['cron_queue_setup']['num_items'] = array(
85 '#type' => 'select',
86 '#title' => t('Number of items to add to queue'),
87 '#options' => drupal_map_assoc(array(1, 5, 10, 100, 1000)),
88 '#default_value' => 5,
89 );
90 $form['cron_queue_setup']['queue'] = array(
91 '#type' => 'radios',
92 '#title' => t('Queue to add items to'),
93 '#options' => array(
94 'cron_example_queue_1' => t('Queue 1'),
95 'cron_example_queue_2' => t('Queue 2'),
96 ),
97 '#default_value' => 'cron_example_queue_1',
98 );
99 $form['cron_queue_setup']['submit'] = array(
100 '#type' => 'submit',
101 '#value' => t('Add jobs to queue'),
102 '#submit' => array('cron_example_add_jobs_to_queue'),
103 );
104
105 $form['configuration'] = array(
106 '#type' => 'fieldset',
107 '#title' => t('Configuration of cron_example_cron()'),
108 );
109 $form['configuration']['cron_example_interval'] = array(
110 '#type' => 'select',
111 '#title' => t('Cron interval'),
112 '#description' => t('Time after which cron_example_cron will respond to a processing request.'),
113 '#default_value' => variable_get('cron_example_interval', 60*60),
114 '#options' => array(
115 60 => t('1 minute'),
116 300 => t('5 minutes'),
117 3600 => t('1 hour'),
118 60*60*24 => t('1 day'),
119 ),
120 );
121
122 return system_settings_form($form);
123 }
124
128 function cron_example_form_cron_run_submit($form, &$form_state) {
129 if (!empty($form_state['values']['cron_reset'])) {
130 variable_set('cron_example_next_execution', 0);
131 }
132
133 // We don't usually use globals in this way. This is used here only to
134 // make it easy to tell if cron was run by this form.
135 $GLOBALS['cron_example_show_status_message'] = TRUE;
136 if (drupal_cron_run()) {
137 drupal_set_message(t('Cron ran successfully.'));
138 }
139 else {
140 drupal_set_message(t('Cron run failed.'), 'error');
141 }
142 }
143
148 function cron_example_add_jobs_to_queue($form, &$form_state) {
149 $queue = $form_state['values']['queue'];
150 $num_items = $form_state['values']['num_items'];
151
152 $queue = DrupalQueue::get($queue);
153 for ($i=1; $i <= $num_items; $i++) {
154 $item = new stdClass();
155 $item->created = time();
156 $item->sequence = $i;
157 $queue->createItem($item);
158 }
159 }
171 function cron_example_cron() {
172 // Default to an hourly interval. Of course, cron has to be running at least
173 // hourly for this to work.
174 $interval = variable_get('cron_example_interval', 60*60);
175 // We usually don't want to act every time cron runs (which could be every
176 // minute) so keep a time for the next run in a variable.
177
178 if (time() >= variable_get('cron_example_next_execution', 0)) {
179 // This is a silly example of a cron job.
180 // It just makes it obvious that the job has run without
181 // making any changes to your database.
182 watchdog('cron_example', 'cron_example ran');
183 if (!empty($GLOBALS['cron_example_show_status_message'])) {
184 drupal_set_message(t('cron_example executed at %time', array('%time' => date_iso8601(time(0)))));
185 }
186 variable_set('cron_example_next_execution', time() + $interval);
187 }
188 }
189
190
204 function cron_example_cron_queue_info() {
205 $queues['cron_example_queue_1'] = array(
206 'worker callback' => 'cron_example_queue_1_worker',
207 'time' => 1, // One second max runtime per cron run.
208 );
209 $queues['cron_example_queue_2'] = array(
210 'worker callback' => 'cron_example_queue_2_worker',
211 'time' => 10,
212 );
213 return $queues;
214 }
215
222 function cron_example_queue_1_worker($item) {
223 cron_example_queue_report_work(1, $item);
224 }
225 function cron_example_queue_2_worker($item) {
226 cron_example_queue_report_work(2, $item);
227 }
228
237 function cron_example_queue_report_work($worker, $item) {
238 if (!empty($GLOBALS['cron_example_show_status_message'])) {
239 drupal_set_message(t('Queue @worker worker processed item with sequence @sequence created at @time', array('@worker' => $worker, '@sequence' => $item->sequence, '@time' => date_iso8601($item->created))));
240 }
241 watchdog('cron_example', 'Queue @worker worker processed item with sequence @sequence created at @time', array('@worker' => $worker, '@sequence' => $item->sequence, '@time' => date_iso8601($item->created)));
242 }
243
cron_example_menu
cron_example_menu()
Definition: cron_example.module:22
cron_example_cron
cron_example_cron()
Definition: cron_example.module:171
cron_example_queue_2_worker
cron_example_queue_2_worker($item)
Definition: cron_example.module:225
DrupalQueue\get
static get($name, $reliable=FALSE)
Definition: system.queue.inc:81
cron_example_cron_queue_info
cron_example_cron_queue_info()
Definition: cron_example.module:204
cron_example_queue_1_worker
cron_example_queue_1_worker($item)
Definition: cron_example.module:222
cron_example_add_jobs_to_queue
cron_example_add_jobs_to_queue($form, &$form_state)
Definition: cron_example.module:148
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
cron_example_queue_report_work
cron_example_queue_report_work($worker, $item)
Definition: cron_example.module:237
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
cron_example_form
cron_example_form($form, &$form_state)
Definition: cron_example.module:37
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
system_settings_form
system_settings_form($form)
Definition: system.module:2755
date_iso8601
date_iso8601($date)
Definition: common.inc:2044
drupal_cron_run
drupal_cron_run()
Definition: common.inc:5227
cron_example_form_cron_run_submit
cron_example_form_cron_run_submit($form, &$form_state)
Definition: cron_example.module:128
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/filter_example/filter_example.module Source File

  • examples
  • filter_example
filter_example.module
Go to the documentation of this file.
1 <?php
43 function filter_example_menu() {
44 $items['examples/filter_example'] = array(
45 'title' => 'Filter Example',
46 'page callback' => '_filter_example_information',
47 'access callback' => TRUE,
48 );
49 return $items;
50 }
51
55 function filter_example_help($path, $arg) {
56 switch ($path) {
57 case 'admin/help#filter_example':
58 return _filter_example_information();
59 }
60 }
61
65 function _filter_example_information() {
66 return t("<p>This example provides two filters.</p><p>Foo Filter replaces
67 'foo' with a configurable replacement.</p><p>Time Tag replaces the string
68 '&lt;time /&gt;' with the current time.</p><p>To use these filters, go to !link and
69 configure an input format, or create a new one.</p>",
70 array('!link' => l("admin/config/content/formats", "admin/config/content/formats"))
71 );
72 }
73
82 function filter_example_filter_info() {
83 $filters['filter_foo'] = array(
84 'title' => t('Foo Filter (example)'),
85 'description' => t('Every instance of "foo" in the input text will be replaced with a preconfigured replacement.'),
86 'process callback' => '_filter_example_filter_foo_process',
87 'default settings' => array(
88 'filter_example_foo' => 'bar',
89 ),
90 'settings callback' => '_filter_example_filter_foo_settings',
91 'tips callback' => '_filter_example_filter_foo_tips',
92 );
93 $filters['filter_time'] = array(
94 'title' => t('Time Tag (example)'),
95 'description' => t('Every instance of the special &lt;time /&gt; tag will be replaced with the current date and time in the user\'s specified time zone.'),
96 'prepare callback' => '_filter_example_filter_time_prepare',
97 'process callback' => '_filter_example_filter_time_process',
98 'tips callback' => '_filter_example_filter_time_tips',
99 );
100 return $filters;
101 }
102
103 /*
104 * Foo filter
105 *
106 * Drupal has several text formats (they are not filters), and in our example
107 * the foo replacement can be configured for each one of them, so the module
108 * includes a settings callback, with options to configure those replacements.
109 * Also, a Tips callback will help showing the current replacement
110 * for the content type being edited.
111 */
112
124 function _filter_example_filter_foo_settings($form, $form_state, $filter, $format, $defaults) {
125 $settings['filter_example_foo'] = array(
126 '#type' => 'textfield',
127 '#title' => t('Substitution string'),
128 '#default_value' => isset($filter->settings['filter_example_foo']) ? $filter->settings['filter_example_foo'] : $defaults['filter_example_foo'],
129 '#description' => t('The string to substitute for "foo" everywhere in the text.')
130 );
131 return $settings;
132 }
133
141 function _filter_example_filter_foo_process($text, $filter, $format) {
142 $replacement = isset($filter->settings['filter_example_foo']) ? $filter->settings['filter_example_foo'] : 'bar';
143 return str_replace('foo', $replacement, $text);
144 }
145
146
155 function _filter_example_filter_foo_tips($filter, $format, $long = FALSE) {
156 $replacement = isset($filter->settings['filter_example_foo']) ? $filter->settings['filter_example_foo'] : 'bar';
157 if (!$long) {
158 // This string will be shown in the content add/edit form
159 return t('<em>foo</em> replaced with %replacement.', array('%replacement' => $replacement));
160 }
161 else {
162 return t('Every instance of "foo" in the input text will be replaced with a configurable value. You can configure this value and put whatever you want there. The replacement value is "%replacement".', array('%replacement' => $replacement));
163 }
164 }
165
174 function _filter_example_filter_time_prepare($text, $filter) {
175 return preg_replace('!<time ?/>!', '[filter-example-time]', $text);
176 }
177
184 function _filter_example_filter_time_process($text, $filter) {
185 return str_replace('[filter-example-time]', '<em>' . format_date(time()) . '</em>', $text);
186 }
187
188
197 function _filter_example_filter_time_tips($filter, $format, $long = FALSE) {
198 return t('<em>&lt;time /&gt;</em> is replaced with the current time.');
199 }
200
l
l($text, $path, array $options=array())
Definition: common.inc:2432
_filter_example_information
_filter_example_information()
Definition: filter_example.module:65
_filter_example_filter_foo_process
_filter_example_filter_foo_process($text, $filter, $format)
Definition: filter_example.module:141
_filter_example_filter_foo_tips
_filter_example_filter_foo_tips($filter, $format, $long=FALSE)
Definition: filter_example.module:155
filter_example_help
filter_example_help($path, $arg)
Definition: filter_example.module:55
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
_filter_example_filter_time_process
_filter_example_filter_time_process($text, $filter)
Definition: filter_example.module:184
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
filter_example_menu
filter_example_menu()
Definition: filter_example.module:43
_filter_example_filter_time_tips
_filter_example_filter_time_tips($filter, $format, $long=FALSE)
Definition: filter_example.module:197
_filter_example_filter_foo_settings
_filter_example_filter_foo_settings($form, $form_state, $filter, $format, $defaults)
Definition: filter_example.module:124
filter_example_filter_info
filter_example_filter_info()
Definition: filter_example.module:82
_filter_example_filter_time_prepare
_filter_example_filter_time_prepare($text, $filter)
Definition: filter_example.module:174
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/js_example/js_example.module Source File

  • examples
  • js_example
js_example.module
Go to the documentation of this file.
1 <?php
2
18 function js_example_theme() {
19 return array(
20 'my_accordion' => array(
21 'template' => 'accordion',
22 'variables' => array('title' => NULL),
23 ),
24 );
25 }
26
30 function js_example_menu() {
31 $items = array();
32 $items['js_example/weights'] = array(
33 'title' => 'JS Example: see weighting in action',
34 'page callback' => 'js_example_js_weights',
35 'access callback' => TRUE,
36 );
37 $items['js_example/accordion'] = array(
38 'title' => 'JS Example: jQuery UI accordion',
39 'page callback' => 'js_example_accordion',
40 'access callback' => TRUE,
41 );
42 return $items;
43 }
44
48 function js_example_js_weights() {
49 // Add some css to show which line is output by which script
50 drupal_add_css(drupal_get_path('module', 'js_example') . '/css/jsweights.css');
51 //
52 $weights = array(
53 'red' => 100,
54 'blue' => 23,
55 'green' => 3,
56 'brown' => 45,
57 'black' => 5,
58 'purple' => 60
59 );
60 drupal_add_js(array('js_weights' => $weights), array('type' => 'setting'));
61 drupal_add_js(drupal_get_path('module', 'js_example') . '/js/red.js', array('weight' => $weights['red']));
62 drupal_add_js(drupal_get_path('module', 'js_example') . '/js/blue.js', array('weight' => $weights['blue']));
63 drupal_add_js(drupal_get_path('module', 'js_example') . '/js/green.js', array('weight' => $weights['green']));
64 drupal_add_js(drupal_get_path('module', 'js_example') . '/js/brown.js', array('weight' => $weights['brown']));
65 drupal_add_js(drupal_get_path('module', 'js_example') . '/js/black.js', array('weight' => $weights['black']));
66 drupal_add_js(drupal_get_path('module', 'js_example') . '/js/purple.js', array('weight' => $weights['purple']));
67 $output = '<div id="js-weights"></div>';
68 return $output;
69 }
70
74 function js_example_accordion() {
75 $title = t('Click sections to expand or collapse:');
76 $build['myelement'] = array(
77 '#theme' => 'my_accordion',
78 '#title' => $title,
79 );
80 $build['myelement']['#attached']['library'][] = array('system', 'ui.accordion');
81 $build['myelement']['#attached']['js'][] = array('data' => '(function($){$(function() { $("#accordion").accordion(); })})(jQuery);', 'type' => 'inline');
82 $output = drupal_render($build);
83 return $output;
84 }
js_example_js_weights
js_example_js_weights()
Definition: js_example.module:48
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
$output
$output
Definition: authorize.php:93
js_example_accordion
js_example_accordion()
Definition: js_example.module:74
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
js_example_theme
js_example_theme()
Definition: js_example.module:18
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
js_example_menu
js_example_menu()
Definition: js_example.module:30
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.install Source File

  • modules
  • system
system.install
Go to the documentation of this file.
1 <?php
2
11 function system_requirements($phase) {
12 global $base_url;
13 $requirements = array();
14 // Ensure translations don't break during installation.
15 $t = get_t();
16
17 // Report Drupal version
18 if ($phase == 'runtime') {
19 $requirements['drupal'] = array(
20 'title' => $t('Drupal'),
21 'value' => VERSION,
22 'severity' => REQUIREMENT_INFO,
23 'weight' => -10,
24 );
25
26 // Display the currently active installation profile, if the site
27 // is not running the default installation profile.
28 $profile = drupal_get_profile();
29 if ($profile != 'standard') {
30 $info = system_get_info('module', $profile);
31 $requirements['install_profile'] = array(
32 'title' => $t('Install profile'),
33 'value' => $t('%profile_name (%profile-%version)', array(
34 '%profile_name' => $info['name'],
35 '%profile' => $profile,
36 '%version' => $info['version']
37 )),
38 'severity' => REQUIREMENT_INFO,
39 'weight' => -9
40 );
41 }
42 }
43
44 // Web server information.
45 $software = $_SERVER['SERVER_SOFTWARE'];
46 $requirements['webserver'] = array(
47 'title' => $t('Web server'),
48 'value' => $software,
49 );
50
51 // Test PHP version and show link to phpinfo() if it's available
52 $phpversion = phpversion();
53 if (function_exists('phpinfo')) {
54 $requirements['php'] = array(
55 'title' => $t('PHP'),
56 'value' => ($phase == 'runtime') ? $phpversion .' ('. l($t('more information'), 'admin/reports/status/php') .')' : $phpversion,
57 );
58 }
59 else {
60 $requirements['php'] = array(
61 'title' => $t('PHP'),
62 'value' => $phpversion,
63 'description' => $t('The phpinfo() function has been disabled for security reasons. To see your server\'s phpinfo() information, change your PHP settings or contact your server administrator. For more information, <a href="@phpinfo">Enabling and disabling phpinfo()</a> handbook page.', array('@phpinfo' => 'http://drupal.org/node/243993')),
64 'severity' => REQUIREMENT_INFO,
65 );
66 }
67
68 if (version_compare($phpversion, DRUPAL_MINIMUM_PHP) < 0) {
69 $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP));
70 $requirements['php']['severity'] = REQUIREMENT_ERROR;
71 // If PHP is old, it's not safe to continue with the requirements check.
72 return $requirements;
73 }
74 // Check that htmlspecialchars() is secure if the site is running any PHP
75 // version older than 5.2.5. We don't simply require 5.2.5, because Ubuntu
76 // 8.04 ships with PHP 5.2.4, but includes the necessary security patch.
77 elseif (version_compare($phpversion, '5.2.5') < 0 && strlen(@htmlspecialchars(chr(0xC0) . chr(0xAF), ENT_QUOTES, 'UTF-8'))) {
78 $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP 5.2.5, or PHP @version with the htmlspecialchars security patch backported.', array('@version' => DRUPAL_MINIMUM_PHP));
79 $requirements['php']['severity'] = REQUIREMENT_ERROR;
80 // If PHP is old, it's not safe to continue with the requirements check.
81 return $requirements;
82 }
83
84 // Test PHP register_globals setting.
85 $requirements['php_register_globals'] = array(
86 'title' => $t('PHP register globals'),
87 );
88 $register_globals = trim(ini_get('register_globals'));
89 // Unfortunately, ini_get() may return many different values, and we can't
90 // be certain which values mean 'on', so we instead check for 'not off'
91 // since we never want to tell the user that their site is secure
92 // (register_globals off), when it is in fact on. We can only guarantee
93 // register_globals is off if the value returned is 'off', '', or 0.
94 if (!empty($register_globals) && strtolower($register_globals) != 'off') {
95 $requirements['php_register_globals']['description'] = $t('<em>register_globals</em> is enabled. Drupal requires this configuration directive to be disabled. Your site may not be secure when <em>register_globals</em> is enabled. The PHP manual has instructions for <a href="http://php.net/configuration.changes">how to change configuration settings</a>.');
96 $requirements['php_register_globals']['severity'] = REQUIREMENT_ERROR;
97 $requirements['php_register_globals']['value'] = $t("Enabled ('@value')", array('@value' => $register_globals));
98 }
99 else {
100 $requirements['php_register_globals']['value'] = $t('Disabled');
101 }
102
103 // Test for PHP extensions.
104 $requirements['php_extensions'] = array(
105 'title' => $t('PHP extensions'),
106 );
107
108 $missing_extensions = array();
109 $required_extensions = array(
110 'date',
111 'dom',
112 'filter',
113 'gd',
114 'hash',
115 'json',
116 'pcre',
117 'pdo',
118 'session',
119 'SimpleXML',
120 'SPL',
121 'xml',
122 );
123 foreach ($required_extensions as $extension) {
124 if (!extension_loaded($extension)) {
125 $missing_extensions[] = $extension;
126 }
127 }
128
129 if (!empty($missing_extensions)) {
130 $description = $t('Drupal requires you to enable the PHP extensions in the following list (see the <a href="@system_requirements">system requirements page</a> for more information):', array(
131 '@system_requirements' => 'http://drupal.org/requirements',
132 ));
133
134 $description .= theme('item_list', array('items' => $missing_extensions));
135
136 $requirements['php_extensions']['value'] = $t('Disabled');
137 $requirements['php_extensions']['severity'] = REQUIREMENT_ERROR;
138 $requirements['php_extensions']['description'] = $description;
139 }
140 else {
141 $requirements['php_extensions']['value'] = $t('Enabled');
142 }
143
144 if ($phase == 'install' || $phase == 'update') {
145 // Test for PDO (database).
146 $requirements['database_extensions'] = array(
147 'title' => $t('Database support'),
148 );
149
150 // Make sure PDO is available.
151 $database_ok = extension_loaded('pdo');
152 if (!$database_ok) {
153 $pdo_message = $t('Your web server does not appear to support PDO (PHP Data Objects). Ask your hosting provider if they support the native PDO extension. See the <a href="@link">system requirements</a> page for more information.', array(
154 '@link' => 'http://drupal.org/requirements/pdo',
155 ));
156 }
157 else {
158 // Make sure at least one supported database driver exists.
159 $drivers = drupal_detect_database_types();
160 if (empty($drivers)) {
161 $database_ok = FALSE;
162 $pdo_message = $t('Your web server does not appear to support any common PDO database extensions. Check with your hosting provider to see if they support PDO (PHP Data Objects) and offer any databases that <a href="@drupal-databases">Drupal supports</a>.', array(
163 '@drupal-databases' => 'http://drupal.org/node/270#database',
164 ));
165 }
166 // Make sure the native PDO extension is available, not the older PEAR
167 // version. (See install_verify_pdo() for details.)
168 if (!defined('PDO::ATTR_DEFAULT_FETCH_MODE')) {
169 $database_ok = FALSE;
170 $pdo_message = $t('Your web server seems to have the wrong version of PDO installed. Drupal 7 requires the PDO extension from PHP core. This system has the older PECL version. See the <a href="@link">system requirements</a> page for more information.', array(
171 '@link' => 'http://drupal.org/requirements/pdo#pecl',
172 ));
173 }
174 }
175
176 if (!$database_ok) {
177 $requirements['database_extensions']['value'] = $t('Disabled');
178 $requirements['database_extensions']['severity'] = REQUIREMENT_ERROR;
179 $requirements['database_extensions']['description'] = $pdo_message;
180 }
181 else {
182 $requirements['database_extensions']['value'] = $t('Enabled');
183 }
184 }
185 else {
186 // Database information.
187 $class = 'DatabaseTasks_' . Database::getConnection()->driver();
188 $tasks = new $class();
189 $requirements['database_system'] = array(
190 'title' => $t('Database system'),
191 'value' => $tasks->name(),
192 );
193 $requirements['database_system_version'] = array(
194 'title' => $t('Database system version'),
195 'value' => Database::getConnection()->version(),
196 );
197 }
198
199 // Test PHP memory_limit
200 $memory_limit = ini_get('memory_limit');
201 $requirements['php_memory_limit'] = array(
202 'title' => $t('PHP memory limit'),
203 'value' => $memory_limit == -1 ? t('-1 (Unlimited)') : $memory_limit,
204 );
205
206 if (!drupal_check_memory_limit(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT, $memory_limit)) {
207 $description = '';
208 if ($phase == 'install') {
209 $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the installation process.', array('%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT));
210 }
211 elseif ($phase == 'update') {
212 $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the update process.', array('%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT));
213 }
214 elseif ($phase == 'runtime') {
215 $description = $t('Depending on your configuration, Drupal can run with a %memory_limit PHP memory limit. However, a %memory_minimum_limit PHP memory limit or above is recommended, especially if your site uses additional custom or contributed modules.', array('%memory_limit' => $memory_limit, '%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT));
216 }
217
218 if (!empty($description)) {
219 if ($php_ini_path = get_cfg_var('cfg_file_path')) {
220 $description .= ' ' . $t('Increase the memory limit by editing the memory_limit parameter in the file %configuration-file and then restart your web server (or contact your system administrator or hosting provider for assistance).', array('%configuration-file' => $php_ini_path));
221 }
222 else {
223 $description .= ' ' . $t('Contact your system administrator or hosting provider for assistance with increasing your PHP memory limit.');
224 }
225
226 $requirements['php_memory_limit']['description'] = $description . ' ' . $t('See the <a href="@url">Drupal requirements</a> for more information.', array('@url' => 'http://drupal.org/requirements'));
227 $requirements['php_memory_limit']['severity'] = REQUIREMENT_WARNING;
228 }
229 }
230
231 // Test settings.php file writability
232 if ($phase == 'runtime') {
233 $conf_dir = drupal_verify_install_file(conf_path(), FILE_NOT_WRITABLE, 'dir');
234 $conf_file = drupal_verify_install_file(conf_path() . '/settings.php', FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE);
235 if (!$conf_dir || !$conf_file) {
236 $requirements['settings.php'] = array(
237 'value' => $t('Not protected'),
238 'severity' => REQUIREMENT_ERROR,
239 'description' => '',
240 );
241 if (!$conf_dir) {
242 $requirements['settings.php']['description'] .= $t('The directory %file is not protected from modifications and poses a security risk. You must change the directory\'s permissions to be non-writable. ', array('%file' => conf_path()));
243 }
244 if (!$conf_file) {
245 $requirements['settings.php']['description'] .= $t('The file %file is not protected from modifications and poses a security risk. You must change the file\'s permissions to be non-writable.', array('%file' => conf_path() . '/settings.php'));
246 }
247 }
248 else {
249 $requirements['settings.php'] = array(
250 'value' => $t('Protected'),
251 );
252 }
253 $requirements['settings.php']['title'] = $t('Configuration file');
254 }
255
256 // Test the contents of the .htaccess files.
257 if ($phase == 'runtime') {
258 // Try to write the .htaccess files first, to prevent false alarms in case
259 // (for example) the /tmp directory was wiped.
260 file_ensure_htaccess();
261 $htaccess_files['public://.htaccess'] = array(
262 'title' => $t('Public files directory'),
263 'directory' => variable_get('file_public_path', conf_path() . '/files'),
264 );
265 if ($private_files_directory = variable_get('file_private_path')) {
266 $htaccess_files['private://.htaccess'] = array(
267 'title' => $t('Private files directory'),
268 'directory' => $private_files_directory,
269 );
270 }
271 $htaccess_files['temporary://.htaccess'] = array(
272 'title' => $t('Temporary files directory'),
273 'directory' => variable_get('file_temporary_path', file_directory_temp()),
274 );
275 foreach ($htaccess_files as $htaccess_file => $info) {
276 // Check for the string which was added to the recommended .htaccess file
277 // in the latest security update.
278 if (!file_exists($htaccess_file) || !($contents = @file_get_contents($htaccess_file)) || strpos($contents, 'Drupal_Security_Do_Not_Remove_See_SA_2013_003') === FALSE) {
279 $requirements[$htaccess_file] = array(
280 'title' => $info['title'],
281 'value' => $t('Not fully protected'),
282 'severity' => REQUIREMENT_ERROR,
283 'description' => $t('See <a href="@url">@url</a> for information about the recommended .htaccess file which should be added to the %directory directory to help protect against arbitrary code execution.', array('@url' => 'http://drupal.org/SA-CORE-2013-003', '%directory' => $info['directory'])),
284 );
285 }
286 }
287 }
288
289 // Report cron status.
290 if ($phase == 'runtime') {
291 // Cron warning threshold defaults to two days.
292 $threshold_warning = variable_get('cron_threshold_warning', 172800);
293 // Cron error threshold defaults to two weeks.
294 $threshold_error = variable_get('cron_threshold_error', 1209600);
295 // Cron configuration help text.
296 $help = $t('For more information, see the online handbook entry for <a href="@cron-handbook">configuring cron jobs</a>.', array('@cron-handbook' => 'http://drupal.org/cron'));
297
298 // Determine when cron last ran.
299 $cron_last = variable_get('cron_last');
300 if (!is_numeric($cron_last)) {
301 $cron_last = variable_get('install_time', 0);
302 }
303
304 // Determine severity based on time since cron last ran.
305 $severity = REQUIREMENT_OK;
306 if (REQUEST_TIME - $cron_last > $threshold_error) {
307 $severity = REQUIREMENT_ERROR;
308 }
309 elseif (REQUEST_TIME - $cron_last > $threshold_warning) {
310 $severity = REQUIREMENT_WARNING;
311 }
312
313 // Set summary and description based on values determined above.
314 $summary = $t('Last run !time ago', array('!time' => format_interval(REQUEST_TIME - $cron_last)));
315 $description = '';
316 if ($severity != REQUIREMENT_OK) {
317 $description = $t('Cron has not run recently.') . ' ' . $help;
318 }
319
320 $description .= ' ' . $t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/reports/status/run-cron')));
321 $description .= '<br />' . $t('To run cron from outside the site, go to <a href="!cron">!cron</a>', array('!cron' => url($base_url . '/cron.php', array('external' => TRUE, 'query' => array('cron_key' => variable_get('cron_key', 'drupal'))))));
322
323 $requirements['cron'] = array(
324 'title' => $t('Cron maintenance tasks'),
325 'severity' => $severity,
326 'value' => $summary,
327 'description' => $description
328 );
329 }
330
331 // Test files directories.
332 $directories = array(
333 variable_get('file_public_path', conf_path() . '/files'),
334 // By default no private files directory is configured. For private files
335 // to be secure the admin needs to provide a path outside the webroot.
336 variable_get('file_private_path', FALSE),
337 );
338
339 // Do not check for the temporary files directory during installation
340 // unless it has been set in settings.php. In this case the user has
341 // no alternative but to fix the directory if it is not writable.
342 if ($phase == 'install') {
343 $directories[] = variable_get('file_temporary_path', FALSE);
344 }
345 else {
346 $directories[] = variable_get('file_temporary_path', file_directory_temp());
347 }
348
349 $requirements['file system'] = array(
350 'title' => $t('File system'),
351 );
352
353 $error = '';
354 // For installer, create the directories if possible.
355 foreach ($directories as $directory) {
356 if (!$directory) {
357 continue;
358 }
359 if ($phase == 'install') {
360 file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
361 }
362 $is_writable = is_writable($directory);
363 $is_directory = is_dir($directory);
364 if (!$is_writable || !$is_directory) {
365 $description = '';
366 $requirements['file system']['value'] = $t('Not writable');
367 if (!$is_directory) {
368 $error .= $t('The directory %directory does not exist.', array('%directory' => $directory)) . ' ';
369 }
370 else {
371 $error .= $t('The directory %directory is not writable.', array('%directory' => $directory)) . ' ';
372 }
373 // The files directory requirement check is done only during install and runtime.
374 if ($phase == 'runtime') {
375 $description = $error . $t('You may need to set the correct directory at the <a href="@admin-file-system">file system settings page</a> or change the current directory\'s permissions so that it is writable.', array('@admin-file-system' => url('admin/config/media/file-system')));
376 }
377 elseif ($phase == 'install') {
378 // For the installer UI, we need different wording. 'value' will
379 // be treated as version, so provide none there.
380 $description = $error . $t('An automated attempt to create this directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the <a href="@handbook_url">online handbook</a>.', array('@handbook_url' => 'http://drupal.org/server-permissions'));
381 $requirements['file system']['value'] = '';
382 }
383 if (!empty($description)) {
384 $requirements['file system']['description'] = $description;
385 $requirements['file system']['severity'] = REQUIREMENT_ERROR;
386 }
387 }
388 else {
389 if (file_default_scheme() == 'public') {
390 $requirements['file system']['value'] = $t('Writable (<em>public</em> download method)');
391 }
392 else {
393 $requirements['file system']['value'] = $t('Writable (<em>private</em> download method)');
394 }
395 }
396 }
397
398 // See if updates are available in update.php.
399 if ($phase == 'runtime') {
400 $requirements['update'] = array(
401 'title' => $t('Database updates'),
402 'severity' => REQUIREMENT_OK,
403 'value' => $t('Up to date'),
404 );
405
406 // Check installed modules.
407 foreach (module_list() as $module) {
408 $updates = drupal_get_schema_versions($module);
409 if ($updates !== FALSE) {
410 $default = drupal_get_installed_schema_version($module);
411 if (max($updates) > $default) {
412 $requirements['update']['severity'] = REQUIREMENT_ERROR;
413 $requirements['update']['value'] = $t('Out of date');
414 $requirements['update']['description'] = $t('Some modules have database schema updates to install. You should run the <a href="@update">database update script</a> immediately.', array('@update' => base_path() . 'update.php'));
415 break;
416 }
417 }
418 }
419 }
420
421 // Verify the update.php access setting
422 if ($phase == 'runtime') {
423 if (!empty($GLOBALS['update_free_access'])) {
424 $requirements['update access'] = array(
425 'value' => $t('Not protected'),
426 'severity' => REQUIREMENT_ERROR,
427 'description' => $t('The update.php script is accessible to everyone without authentication check, which is a security risk. You must change the $update_free_access value in your settings.php back to FALSE.'),
428 );
429 }
430 else {
431 $requirements['update access'] = array(
432 'value' => $t('Protected'),
433 );
434 }
435 $requirements['update access']['title'] = $t('Access to update.php');
436 }
437
438 // Display an error if a newly introduced dependency in a module is not resolved.
439 if ($phase == 'update') {
440 $profile = drupal_get_profile();
441 $files = system_rebuild_module_data();
442 foreach ($files as $module => $file) {
443 // Ignore disabled modules and installation profiles.
444 if (!$file->status || $module == $profile) {
445 continue;
446 }
447 // Check the module's PHP version.
448 $name = $file->info['name'];
449 $php = $file->info['php'];
450 if (version_compare($php, PHP_VERSION, '>')) {
451 $requirements['php']['description'] .= $t('@name requires at least PHP @version.', array('@name' => $name, '@version' => $php));
452 $requirements['php']['severity'] = REQUIREMENT_ERROR;
453 }
454 // Check the module's required modules.
455 foreach ($file->requires as $requirement) {
456 $required_module = $requirement['name'];
457 // Check if the module exists.
458 if (!isset($files[$required_module])) {
459 $requirements["$module-$required_module"] = array(
460 'title' => $t('Unresolved dependency'),
461 'description' => $t('@name requires this module.', array('@name' => $name)),
462 'value' => t('@required_name (Missing)', array('@required_name' => $required_module)),
463 'severity' => REQUIREMENT_ERROR,
464 );
465 continue;
466 }
467 // Check for an incompatible version.
468 $required_file = $files[$required_module];
469 $required_name = $required_file->info['name'];
470 $version = str_replace(DRUPAL_CORE_COMPATIBILITY . '-', '', $required_file->info['version']);
471 $compatibility = drupal_check_incompatibility($requirement, $version);
472 if ($compatibility) {
473 $compatibility = rtrim(substr($compatibility, 2), ')');
474 $requirements["$module-$required_module"] = array(
475 'title' => $t('Unresolved dependency'),
476 'description' => $t('@name requires this module and version. Currently using @required_name version @version', array('@name' => $name, '@required_name' => $required_name, '@version' => $version)),
477 'value' => t('@required_name (Version @compatibility required)', array('@required_name' => $required_name, '@compatibility' => $compatibility)),
478 'severity' => REQUIREMENT_ERROR,
479 );
480 continue;
481 }
482 }
483 }
484 }
485
486 // Test Unicode library
487 include_once DRUPAL_ROOT . '/includes/unicode.inc';
488 $requirements = array_merge($requirements, unicode_requirements());
489
490 if ($phase == 'runtime') {
491 // Check for update status module.
492 if (!module_exists('update')) {
493 $requirements['update status'] = array(
494 'value' => $t('Not enabled'),
495 'severity' => REQUIREMENT_WARNING,
496 'description' => $t('Update notifications are not enabled. It is <strong>highly recommended</strong> that you enable the update manager module from the <a href="@module">module administration page</a> in order to stay up-to-date on new releases. For more information, <a href="@update">Update status handbook page</a>.', array('@update' => 'http://drupal.org/documentation/modules/update', '@module' => url('admin/modules'))),
497 );
498 }
499 else {
500 $requirements['update status'] = array(
501 'value' => $t('Enabled'),
502 );
503 }
504 $requirements['update status']['title'] = $t('Update notifications');
505
506 // Check that Drupal can issue HTTP requests.
507 if (variable_get('drupal_http_request_fails', TRUE) && !system_check_http_request()) {
508 $requirements['http requests'] = array(
509 'title' => $t('HTTP request status'),
510 'value' => $t('Fails'),
511 'severity' => REQUIREMENT_ERROR,
512 'description' => $t('Your system or network configuration does not allow Drupal to access web pages, resulting in reduced functionality. This could be due to your webserver configuration or PHP settings, and should be resolved in order to download information about available updates, fetch aggregator feeds, sign in via OpenID, or use other network-dependent services. If you are certain that Drupal can access web pages but you are still seeing this message, you may add <code>$conf[\'drupal_http_request_fails\'] = FALSE;</code> to the bottom of your settings.php file.'),
513 );
514 }
515 }
516
517 return $requirements;
518 }
519
523 function system_install() {
524 // Create tables.
525 drupal_install_schema('system');
526 $versions = drupal_get_schema_versions('system');
527 $version = $versions ? max($versions) : SCHEMA_INSTALLED;
528 drupal_set_installed_schema_version('system', $version);
529
530 // Clear out module list and hook implementation statics before calling
531 // system_rebuild_theme_data().
532 module_list(TRUE);
533 module_implements('', FALSE, TRUE);
534
535 // Load system theme data appropriately.
536 system_rebuild_theme_data();
537
538 // Enable the default theme.
539 variable_set('theme_default', 'bartik');
540 db_update('system')
541 ->fields(array('status' => 1))
542 ->condition('type', 'theme')
543 ->condition('name', 'bartik')
544 ->execute();
545
546 // Populate the cron key variable.
547 $cron_key = drupal_random_key();
548 variable_set('cron_key', $cron_key);
549 }
550
554 function system_schema() {
555 // NOTE: {variable} needs to be created before all other tables, as
556 // some database drivers, e.g. Oracle and DB2, will require variable_get()
557 // and variable_set() for overcoming some database specific limitations.
558 $schema['variable'] = array(
559 'description' => 'Named variable/value pairs created by Drupal core or any other module or theme. All variables are cached in memory at the start of every Drupal request so developers should not be careless about what is stored here.',
560 'fields' => array(
561 'name' => array(
562 'description' => 'The name of the variable.',
563 'type' => 'varchar',
564 'length' => 128,
565 'not null' => TRUE,
566 'default' => '',
567 ),
568 'value' => array(
569 'description' => 'The value of the variable.',
570 'type' => 'blob',
571 'not null' => TRUE,
572 'size' => 'big',
573 'translatable' => TRUE,
574 ),
575 ),
576 'primary key' => array('name'),
577 );
578
579 $schema['actions'] = array(
580 'description' => 'Stores action information.',
581 'fields' => array(
582 'aid' => array(
583 'description' => 'Primary Key: Unique actions ID.',
584 'type' => 'varchar',
585 'length' => 255,
586 'not null' => TRUE,
587 'default' => '0',
588 ),
589 'type' => array(
590 'description' => 'The object that that action acts on (node, user, comment, system or custom types.)',
591 'type' => 'varchar',
592 'length' => 32,
593 'not null' => TRUE,
594 'default' => '',
595 ),
596 'callback' => array(
597 'description' => 'The callback function that executes when the action runs.',
598 'type' => 'varchar',
599 'length' => 255,
600 'not null' => TRUE,
601 'default' => '',
602 ),
603 'parameters' => array(
604 'description' => 'Parameters to be passed to the callback function.',
605 'type' => 'blob',
606 'not null' => TRUE,
607 'size' => 'big',
608 ),
609 'label' => array(
610 'description' => 'Label of the action.',
611 'type' => 'varchar',
612 'length' => 255,
613 'not null' => TRUE,
614 'default' => '0',
615 ),
616 ),
617 'primary key' => array('aid'),
618 );
619
620 $schema['batch'] = array(
621 'description' => 'Stores details about batches (processes that run in multiple HTTP requests).',
622 'fields' => array(
623 'bid' => array(
624 'description' => 'Primary Key: Unique batch ID.',
625 // This is not a serial column, to allow both progressive and
626 // non-progressive batches. See batch_process().
627 'type' => 'int',
628 'unsigned' => TRUE,
629 'not null' => TRUE,
630 ),
631 'token' => array(
632 'description' => "A string token generated against the current user's session id and the batch id, used to ensure that only the user who submitted the batch can effectively access it.",
633 'type' => 'varchar',
634 'length' => 64,
635 'not null' => TRUE,
636 ),
637 'timestamp' => array(
638 'description' => 'A Unix timestamp indicating when this batch was submitted for processing. Stale batches are purged at cron time.',
639 'type' => 'int',
640 'not null' => TRUE,
641 ),
642 'batch' => array(
643 'description' => 'A serialized array containing the processing data for the batch.',
644 'type' => 'blob',
645 'not null' => FALSE,
646 'size' => 'big',
647 ),
648 ),
649 'primary key' => array('bid'),
650 'indexes' => array(
651 'token' => array('token'),
652 ),
653 );
654
655 $schema['blocked_ips'] = array(
656 'description' => 'Stores blocked IP addresses.',
657 'fields' => array(
658 'iid' => array(
659 'description' => 'Primary Key: unique ID for IP addresses.',
660 'type' => 'serial',
661 'unsigned' => TRUE,
662 'not null' => TRUE,
663 ),
664 'ip' => array(
665 'description' => 'IP address',
666 'type' => 'varchar',
667 'length' => 40,
668 'not null' => TRUE,
669 'default' => '',
670 ),
671 ),
672 'indexes' => array(
673 'blocked_ip' => array('ip'),
674 ),
675 'primary key' => array('iid'),
676 );
677
678 $schema['cache'] = array(
679 'description' => 'Generic cache table for caching things not separated out into their own tables. Contributed modules may also use this to store cached items.',
680 'fields' => array(
681 'cid' => array(
682 'description' => 'Primary Key: Unique cache ID.',
683 'type' => 'varchar',
684 'length' => 255,
685 'not null' => TRUE,
686 'default' => '',
687 ),
688 'data' => array(
689 'description' => 'A collection of data to cache.',
690 'type' => 'blob',
691 'not null' => FALSE,
692 'size' => 'big',
693 ),
694 'expire' => array(
695 'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
696 'type' => 'int',
697 'not null' => TRUE,
698 'default' => 0,
699 ),
700 'created' => array(
701 'description' => 'A Unix timestamp indicating when the cache entry was created.',
702 'type' => 'int',
703 'not null' => TRUE,
704 'default' => 0,
705 ),
706 'serialized' => array(
707 'description' => 'A flag to indicate whether content is serialized (1) or not (0).',
708 'type' => 'int',
709 'size' => 'small',
710 'not null' => TRUE,
711 'default' => 0,
712 ),
713 ),
714 'indexes' => array(
715 'expire' => array('expire'),
716 ),
717 'primary key' => array('cid'),
718 );
719 $schema['cache_bootstrap'] = $schema['cache'];
720 $schema['cache_bootstrap']['description'] = 'Cache table for data required to bootstrap Drupal, may be routed to a shared memory cache.';
721 $schema['cache_form'] = $schema['cache'];
722 $schema['cache_form']['description'] = 'Cache table for the form system to store recently built forms and their storage data, to be used in subsequent page requests.';
723 $schema['cache_page'] = $schema['cache'];
724 $schema['cache_page']['description'] = 'Cache table used to store compressed pages for anonymous users, if page caching is enabled.';
725 $schema['cache_menu'] = $schema['cache'];
726 $schema['cache_menu']['description'] = 'Cache table for the menu system to store router information as well as generated link trees for various menu/page/user combinations.';
727 $schema['cache_path'] = $schema['cache'];
728 $schema['cache_path']['description'] = 'Cache table for path alias lookup.';
729
730 $schema['date_format_type'] = array(
731 'description' => 'Stores configured date format types.',
732 'fields' => array(
733 'type' => array(
734 'description' => 'The date format type, e.g. medium.',
735 'type' => 'varchar',
736 'length' => 64,
737 'not null' => TRUE,
738 ),
739 'title' => array(
740 'description' => 'The human readable name of the format type.',
741 'type' => 'varchar',
742 'length' => 255,
743 'not null' => TRUE,
744 ),
745 'locked' => array(
746 'description' => 'Whether or not this is a system provided format.',
747 'type' => 'int',
748 'size' => 'tiny',
749 'default' => 0,
750 'not null' => TRUE,
751 ),
752 ),
753 'primary key' => array('type'),
754 'indexes' => array(
755 'title' => array('title'),
756 ),
757 );
758
759 // This table's name is plural as some versions of MySQL can't create a
760 // table named 'date_format'.
761 $schema['date_formats'] = array(
762 'description' => 'Stores configured date formats.',
763 'fields' => array(
764 'dfid' => array(
765 'description' => 'The date format identifier.',
766 'type' => 'serial',
767 'not null' => TRUE,
768 'unsigned' => TRUE,
769 ),
770 'format' => array(
771 'description' => 'The date format string.',
772 'type' => 'varchar',
773 'length' => 100,
774 'not null' => TRUE,
775 'binary' => TRUE,
776 ),
777 'type' => array(
778 'description' => 'The date format type, e.g. medium.',
779 'type' => 'varchar',
780 'length' => 64,
781 'not null' => TRUE,
782 ),
783 'locked' => array(
784 'description' => 'Whether or not this format can be modified.',
785 'type' => 'int',
786 'size' => 'tiny',
787 'default' => 0,
788 'not null' => TRUE,
789 ),
790 ),
791 'primary key' => array('dfid'),
792 'unique keys' => array('formats' => array('format', 'type')),
793 );
794
795 $schema['date_format_locale'] = array(
796 'description' => 'Stores configured date formats for each locale.',
797 'fields' => array(
798 'format' => array(
799 'description' => 'The date format string.',
800 'type' => 'varchar',
801 'length' => 100,
802 'not null' => TRUE,
803 ),
804 'type' => array(
805 'description' => 'The date format type, e.g. medium.',
806 'type' => 'varchar',
807 'length' => 64,
808 'not null' => TRUE,
809 ),
810 'language' => array(
811 'description' => 'A {languages}.language for this format to be used with.',
812 'type' => 'varchar',
813 'length' => 12,
814 'not null' => TRUE,
815 ),
816 ),
817 'primary key' => array('type', 'language'),
818 );
819
820 $schema['file_managed'] = array(
821 'description' => 'Stores information for uploaded files.',
822 'fields' => array(
823 'fid' => array(
824 'description' => 'File ID.',
825 'type' => 'serial',
826 'unsigned' => TRUE,
827 'not null' => TRUE,
828 ),
829 'uid' => array(
830 'description' => 'The {users}.uid of the user who is associated with the file.',
831 'type' => 'int',
832 'unsigned' => TRUE,
833 'not null' => TRUE,
834 'default' => 0,
835 ),
836 'filename' => array(
837 'description' => 'Name of the file with no path components. This may differ from the basename of the URI if the file is renamed to avoid overwriting an existing file.',
838 'type' => 'varchar',
839 'length' => 255,
840 'not null' => TRUE,
841 'default' => '',
842 ),
843 'uri' => array(
844 'description' => 'The URI to access the file (either local or remote).',
845 'type' => 'varchar',
846 'length' => 255,
847 'not null' => TRUE,
848 'default' => '',
849 'binary' => TRUE,
850 ),
851 'filemime' => array(
852 'description' => "The file's MIME type.",
853 'type' => 'varchar',
854 'length' => 255,
855 'not null' => TRUE,
856 'default' => '',
857 ),
858 'filesize' => array(
859 'description' => 'The size of the file in bytes.',
860 'type' => 'int',
861 'size' => 'big',
862 'unsigned' => TRUE,
863 'not null' => TRUE,
864 'default' => 0,
865 ),
866 'status' => array(
867 'description' => 'A field indicating the status of the file. Two status are defined in core: temporary (0) and permanent (1). Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during a cron run.',
868 'type' => 'int',
869 'not null' => TRUE,
870 'default' => 0,
871 'size' => 'tiny',
872 ),
873 'timestamp' => array(
874 'description' => 'UNIX timestamp for when the file was added.',
875 'type' => 'int',
876 'unsigned' => TRUE,
877 'not null' => TRUE,
878 'default' => 0,
879 ),
880 ),
881 'indexes' => array(
882 'uid' => array('uid'),
883 'status' => array('status'),
884 'timestamp' => array('timestamp'),
885 ),
886 'unique keys' => array(
887 'uri' => array('uri'),
888 ),
889 'primary key' => array('fid'),
890 'foreign keys' => array(
891 'file_owner' => array(
892 'table' => 'users',
893 'columns' => array('uid' => 'uid'),
894 ),
895 ),
896 );
897
898 $schema['file_usage'] = array(
899 'description' => 'Track where a file is used.',
900 'fields' => array(
901 'fid' => array(
902 'description' => 'File ID.',
903 'type' => 'int',
904 'unsigned' => TRUE,
905 'not null' => TRUE,
906 ),
907 'module' => array(
908 'description' => 'The name of the module that is using the file.',
909 'type' => 'varchar',
910 'length' => 255,
911 'not null' => TRUE,
912 'default' => '',
913 ),
914 'type' => array(
915 'description' => 'The name of the object type in which the file is used.',
916 'type' => 'varchar',
917 'length' => 64,
918 'not null' => TRUE,
919 'default' => '',
920 ),
921 'id' => array(
922 'description' => 'The primary key of the object using the file.',
923 'type' => 'int',
924 'unsigned' => TRUE,
925 'not null' => TRUE,
926 'default' => 0,
927 ),
928 'count' => array(
929 'description' => 'The number of times this file is used by this object.',
930 'type' => 'int',
931 'unsigned' => TRUE,
932 'not null' => TRUE,
933 'default' => 0,
934 ),
935 ),
936 'primary key' => array('fid', 'type', 'id', 'module'),
937 'indexes' => array(
938 'type_id' => array('type', 'id'),
939 'fid_count' => array('fid', 'count'),
940 'fid_module' => array('fid', 'module'),
941 ),
942 );
943
944 $schema['flood'] = array(
945 'description' => 'Flood controls the threshold of events, such as the number of contact attempts.',
946 'fields' => array(
947 'fid' => array(
948 'description' => 'Unique flood event ID.',
949 'type' => 'serial',
950 'not null' => TRUE,
951 ),
952 'event' => array(
953 'description' => 'Name of event (e.g. contact).',
954 'type' => 'varchar',
955 'length' => 64,
956 'not null' => TRUE,
957 'default' => '',
958 ),
959 'identifier' => array(
960 'description' => 'Identifier of the visitor, such as an IP address or hostname.',
961 'type' => 'varchar',
962 'length' => 128,
963 'not null' => TRUE,
964 'default' => '',
965 ),
966 'timestamp' => array(
967 'description' => 'Timestamp of the event.',
968 'type' => 'int',
969 'not null' => TRUE,
970 'default' => 0,
971 ),
972 'expiration' => array(
973 'description' => 'Expiration timestamp. Expired events are purged on cron run.',
974 'type' => 'int',
975 'not null' => TRUE,
976 'default' => 0,
977 ),
978 ),
979 'primary key' => array('fid'),
980 'indexes' => array(
981 'allow' => array('event', 'identifier', 'timestamp'),
982 'purge' => array('expiration'),
983 ),
984 );
985
986 $schema['menu_router'] = array(
987 'description' => 'Maps paths to various callbacks (access, page and title)',
988 'fields' => array(
989 'path' => array(
990 'description' => 'Primary Key: the Drupal path this entry describes',
991 'type' => 'varchar',
992 'length' => 255,
993 'not null' => TRUE,
994 'default' => '',
995 ),
996 'load_functions' => array(
997 'description' => 'A serialized array of function names (like node_load) to be called to load an object corresponding to a part of the current path.',
998 'type' => 'blob',
999 'not null' => TRUE,
1000 ),
1001 'to_arg_functions' => array(
1002 'description' => 'A serialized array of function names (like user_uid_optional_to_arg) to be called to replace a part of the router path with another string.',
1003 'type' => 'blob',
1004 'not null' => TRUE,
1005 ),
1006 'access_callback' => array(
1007 'description' => 'The callback which determines the access to this router path. Defaults to user_access.',
1008 'type' => 'varchar',
1009 'length' => 255,
1010 'not null' => TRUE,
1011 'default' => '',
1012 ),
1013 'access_arguments' => array(
1014 'description' => 'A serialized array of arguments for the access callback.',
1015 'type' => 'blob',
1016 'not null' => FALSE,
1017 ),
1018 'page_callback' => array(
1019 'description' => 'The name of the function that renders the page.',
1020 'type' => 'varchar',
1021 'length' => 255,
1022 'not null' => TRUE,
1023 'default' => '',
1024 ),
1025 'page_arguments' => array(
1026 'description' => 'A serialized array of arguments for the page callback.',
1027 'type' => 'blob',
1028 'not null' => FALSE,
1029 ),
1030 'delivery_callback' => array(
1031 'description' => 'The name of the function that sends the result of the page_callback function to the browser.',
1032 'type' => 'varchar',
1033 'length' => 255,
1034 'not null' => TRUE,
1035 'default' => '',
1036 ),
1037 'fit' => array(
1038 'description' => 'A numeric representation of how specific the path is.',
1039 'type' => 'int',
1040 'not null' => TRUE,
1041 'default' => 0,
1042 ),
1043 'number_parts' => array(
1044 'description' => 'Number of parts in this router path.',
1045 'type' => 'int',
1046 'not null' => TRUE,
1047 'default' => 0,
1048 'size' => 'small',
1049 ),
1050 'context' => array(
1051 'description' => 'Only for local tasks (tabs) - the context of a local task to control its placement.',
1052 'type' => 'int',
1053 'not null' => TRUE,
1054 'default' => 0,
1055 ),
1056 'tab_parent' => array(
1057 'description' => 'Only for local tasks (tabs) - the router path of the parent page (which may also be a local task).',
1058 'type' => 'varchar',
1059 'length' => 255,
1060 'not null' => TRUE,
1061 'default' => '',
1062 ),
1063 'tab_root' => array(
1064 'description' => 'Router path of the closest non-tab parent page. For pages that are not local tasks, this will be the same as the path.',
1065 'type' => 'varchar',
1066 'length' => 255,
1067 'not null' => TRUE,
1068 'default' => '',
1069 ),
1070 'title' => array(
1071 'description' => 'The title for the current page, or the title for the tab if this is a local task.',
1072 'type' => 'varchar',
1073 'length' => 255,
1074 'not null' => TRUE,
1075 'default' => '',
1076 ),
1077 'title_callback' => array(
1078 'description' => 'A function which will alter the title. Defaults to t()',
1079 'type' => 'varchar',
1080 'length' => 255,
1081 'not null' => TRUE,
1082 'default' => '',
1083 ),
1084 'title_arguments' => array(
1085 'description' => 'A serialized array of arguments for the title callback. If empty, the title will be used as the sole argument for the title callback.',
1086 'type' => 'varchar',
1087 'length' => 255,
1088 'not null' => TRUE,
1089 'default' => '',
1090 ),
1091 'theme_callback' => array(
1092 'description' => 'A function which returns the name of the theme that will be used to render this page. If left empty, the default theme will be used.',
1093 'type' => 'varchar',
1094 'length' => 255,
1095 'not null' => TRUE,
1096 'default' => '',
1097 ),
1098 'theme_arguments' => array(
1099 'description' => 'A serialized array of arguments for the theme callback.',
1100 'type' => 'varchar',
1101 'length' => 255,
1102 'not null' => TRUE,
1103 'default' => '',
1104 ),
1105 'type' => array(
1106 'description' => 'Numeric representation of the type of the menu item, like MENU_LOCAL_TASK.',
1107 'type' => 'int',
1108 'not null' => TRUE,
1109 'default' => 0,
1110 ),
1111 'description' => array(
1112 'description' => 'A description of this item.',
1113 'type' => 'text',
1114 'not null' => TRUE,
1115 ),
1116 'position' => array(
1117 'description' => 'The position of the block (left or right) on the system administration page for this item.',
1118 'type' => 'varchar',
1119 'length' => 255,
1120 'not null' => TRUE,
1121 'default' => '',
1122 ),
1123 'weight' => array(
1124 'description' => 'Weight of the element. Lighter weights are higher up, heavier weights go down.',
1125 'type' => 'int',
1126 'not null' => TRUE,
1127 'default' => 0,
1128 ),
1129 'include_file' => array(
1130 'description' => 'The file to include for this element, usually the page callback function lives in this file.',
1131 'type' => 'text',
1132 'size' => 'medium',
1133 ),
1134 ),
1135 'indexes' => array(
1136 'fit' => array('fit'),
1137 'tab_parent' => array(array('tab_parent', 64), 'weight', 'title'),
1138 'tab_root_weight_title' => array(array('tab_root', 64), 'weight', 'title'),
1139 ),
1140 'primary key' => array('path'),
1141 );
1142
1143 $schema['menu_links'] = array(
1144 'description' => 'Contains the individual links within a menu.',
1145 'fields' => array(
1146 'menu_name' => array(
1147 'description' => "The menu name. All links with the same menu name (such as 'navigation') are part of the same menu.",
1148 'type' => 'varchar',
1149 'length' => 32,
1150 'not null' => TRUE,
1151 'default' => '',
1152 ),
1153 'mlid' => array(
1154 'description' => 'The menu link ID (mlid) is the integer primary key.',
1155 'type' => 'serial',
1156 'unsigned' => TRUE,
1157 'not null' => TRUE,
1158 ),
1159 'plid' => array(
1160 'description' => 'The parent link ID (plid) is the mlid of the link above in the hierarchy, or zero if the link is at the top level in its menu.',
1161 'type' => 'int',
1162 'unsigned' => TRUE,
1163 'not null' => TRUE,
1164 'default' => 0,
1165 ),
1166 'link_path' => array(
1167 'description' => 'The Drupal path or external path this link points to.',
1168 'type' => 'varchar',
1169 'length' => 255,
1170 'not null' => TRUE,
1171 'default' => '',
1172 ),
1173 'router_path' => array(
1174 'description' => 'For links corresponding to a Drupal path (external = 0), this connects the link to a {menu_router}.path for joins.',
1175 'type' => 'varchar',
1176 'length' => 255,
1177 'not null' => TRUE,
1178 'default' => '',
1179 ),
1180 'link_title' => array(
1181 'description' => 'The text displayed for the link, which may be modified by a title callback stored in {menu_router}.',
1182 'type' => 'varchar',
1183 'length' => 255,
1184 'not null' => TRUE,
1185 'default' => '',
1186 'translatable' => TRUE,
1187 ),
1188 'options' => array(
1189 'description' => 'A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.',
1190 'type' => 'blob',
1191 'not null' => FALSE,
1192 'translatable' => TRUE,
1193 ),
1194 'module' => array(
1195 'description' => 'The name of the module that generated this link.',
1196 'type' => 'varchar',
1197 'length' => 255,
1198 'not null' => TRUE,
1199 'default' => 'system',
1200 ),
1201 'hidden' => array(
1202 'description' => 'A flag for whether the link should be rendered in menus. (1 = a disabled menu item that may be shown on admin screens, -1 = a menu callback, 0 = a normal, visible link)',
1203 'type' => 'int',
1204 'not null' => TRUE,
1205 'default' => 0,
1206 'size' => 'small',
1207 ),
1208 'external' => array(
1209 'description' => 'A flag to indicate if the link points to a full URL starting with a protocol, like http:// (1 = external, 0 = internal).',
1210 'type' => 'int',
1211 'not null' => TRUE,
1212 'default' => 0,
1213 'size' => 'small',
1214 ),
1215 'has_children' => array(
1216 'description' => 'Flag indicating whether any links have this link as a parent (1 = children exist, 0 = no children).',
1217 'type' => 'int',
1218 'not null' => TRUE,
1219 'default' => 0,
1220 'size' => 'small',
1221 ),
1222 'expanded' => array(
1223 'description' => 'Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded)',
1224 'type' => 'int',
1225 'not null' => TRUE,
1226 'default' => 0,
1227 'size' => 'small',
1228 ),
1229 'weight' => array(
1230 'description' => 'Link weight among links in the same menu at the same depth.',
1231 'type' => 'int',
1232 'not null' => TRUE,
1233 'default' => 0,
1234 ),
1235 'depth' => array(
1236 'description' => 'The depth relative to the top level. A link with plid == 0 will have depth == 1.',
1237 'type' => 'int',
1238 'not null' => TRUE,
1239 'default' => 0,
1240 'size' => 'small',
1241 ),
1242 'customized' => array(
1243 'description' => 'A flag to indicate that the user has manually created or edited the link (1 = customized, 0 = not customized).',
1244 'type' => 'int',
1245 'not null' => TRUE,
1246 'default' => 0,
1247 'size' => 'small',
1248 ),
1249 'p1' => array(
1250 'description' => 'The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the plid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.',
1251 'type' => 'int',
1252 'unsigned' => TRUE,
1253 'not null' => TRUE,
1254 'default' => 0,
1255 ),
1256 'p2' => array(
1257 'description' => 'The second mlid in the materialized path. See p1.',
1258 'type' => 'int',
1259 'unsigned' => TRUE,
1260 'not null' => TRUE,
1261 'default' => 0,
1262 ),
1263 'p3' => array(
1264 'description' => 'The third mlid in the materialized path. See p1.',
1265 'type' => 'int',
1266 'unsigned' => TRUE,
1267 'not null' => TRUE,
1268 'default' => 0,
1269 ),
1270 'p4' => array(
1271 'description' => 'The fourth mlid in the materialized path. See p1.',
1272 'type' => 'int',
1273 'unsigned' => TRUE,
1274 'not null' => TRUE,
1275 'default' => 0,
1276 ),
1277 'p5' => array(
1278 'description' => 'The fifth mlid in the materialized path. See p1.',
1279 'type' => 'int',
1280 'unsigned' => TRUE,
1281 'not null' => TRUE,
1282 'default' => 0,
1283 ),
1284 'p6' => array(
1285 'description' => 'The sixth mlid in the materialized path. See p1.',
1286 'type' => 'int',
1287 'unsigned' => TRUE,
1288 'not null' => TRUE,
1289 'default' => 0,
1290 ),
1291 'p7' => array(
1292 'description' => 'The seventh mlid in the materialized path. See p1.',
1293 'type' => 'int',
1294 'unsigned' => TRUE,
1295 'not null' => TRUE,
1296 'default' => 0,
1297 ),
1298 'p8' => array(
1299 'description' => 'The eighth mlid in the materialized path. See p1.',
1300 'type' => 'int',
1301 'unsigned' => TRUE,
1302 'not null' => TRUE,
1303 'default' => 0,
1304 ),
1305 'p9' => array(
1306 'description' => 'The ninth mlid in the materialized path. See p1.',
1307 'type' => 'int',
1308 'unsigned' => TRUE,
1309 'not null' => TRUE,
1310 'default' => 0,
1311 ),
1312 'updated' => array(
1313 'description' => 'Flag that indicates that this link was generated during the update from Drupal 5.',
1314 'type' => 'int',
1315 'not null' => TRUE,
1316 'default' => 0,
1317 'size' => 'small',
1318 ),
1319 ),
1320 'indexes' => array(
1321 'path_menu' => array(array('link_path', 128), 'menu_name'),
1322 'menu_plid_expand_child' => array('menu_name', 'plid', 'expanded', 'has_children'),
1323 'menu_parents' => array('menu_name', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'),
1324 'router_path' => array(array('router_path', 128)),
1325 ),
1326 'primary key' => array('mlid'),
1327 );
1328
1329 $schema['queue'] = array(
1330 'description' => 'Stores items in queues.',
1331 'fields' => array(
1332 'item_id' => array(
1333 'type' => 'serial',
1334 'unsigned' => TRUE,
1335 'not null' => TRUE,
1336 'description' => 'Primary Key: Unique item ID.',
1337 ),
1338 'name' => array(
1339 'type' => 'varchar',
1340 'length' => 255,
1341 'not null' => TRUE,
1342 'default' => '',
1343 'description' => 'The queue name.',
1344 ),
1345 'data' => array(
1346 'type' => 'blob',
1347 'not null' => FALSE,
1348 'size' => 'big',
1349 'serialize' => TRUE,
1350 'description' => 'The arbitrary data for the item.',
1351 ),
1352 'expire' => array(
1353 'type' => 'int',
1354 'not null' => TRUE,
1355 'default' => 0,
1356 'description' => 'Timestamp when the claim lease expires on the item.',
1357 ),
1358 'created' => array(
1359 'type' => 'int',
1360 'not null' => TRUE,
1361 'default' => 0,
1362 'description' => 'Timestamp when the item was created.',
1363 ),
1364 ),
1365 'primary key' => array('item_id'),
1366 'indexes' => array(
1367 'name_created' => array('name', 'created'),
1368 'expire' => array('expire'),
1369 ),
1370 );
1371
1372 $schema['registry'] = array(
1373 'description' => "Each record is a function, class, or interface name and the file it is in.",
1374 'fields' => array(
1375 'name' => array(
1376 'description' => 'The name of the function, class, or interface.',
1377 'type' => 'varchar',
1378 'length' => 255,
1379 'not null' => TRUE,
1380 'default' => '',
1381 ),
1382 'type' => array(
1383 'description' => 'Either function or class or interface.',
1384 'type' => 'varchar',
1385 'length' => 9,
1386 'not null' => TRUE,
1387 'default' => '',
1388 ),
1389 'filename' => array(
1390 'description' => 'Name of the file.',
1391 'type' => 'varchar',
1392 'length' => 255,
1393 'not null' => TRUE,
1394 ),
1395 'module' => array(
1396 'description' => 'Name of the module the file belongs to.',
1397 'type' => 'varchar',
1398 'length' => 255,
1399 'not null' => TRUE,
1400 'default' => ''
1401 ),
1402 'weight' => array(
1403 'description' => "The order in which this module's hooks should be invoked relative to other modules. Equal-weighted modules are ordered by name.",
1404 'type' => 'int',
1405 'not null' => TRUE,
1406 'default' => 0,
1407 ),
1408 ),
1409 'primary key' => array('name', 'type'),
1410 'indexes' => array(
1411 'hook' => array('type', 'weight', 'module'),
1412 ),
1413 );
1414
1415 $schema['registry_file'] = array(
1416 'description' => "Files parsed to build the registry.",
1417 'fields' => array(
1418 'filename' => array(
1419 'description' => 'Path to the file.',
1420 'type' => 'varchar',
1421 'length' => 255,
1422 'not null' => TRUE,
1423 ),
1424 'hash' => array(
1425 'description' => "sha-256 hash of the file's contents when last parsed.",
1426 'type' => 'varchar',
1427 'length' => 64,
1428 'not null' => TRUE,
1429 ),
1430 ),
1431 'primary key' => array('filename'),
1432 );
1433
1434 $schema['semaphore'] = array(
1435 'description' => 'Table for holding semaphores, locks, flags, etc. that cannot be stored as Drupal variables since they must not be cached.',
1436 'fields' => array(
1437 'name' => array(
1438 'description' => 'Primary Key: Unique name.',
1439 'type' => 'varchar',
1440 'length' => 255,
1441 'not null' => TRUE,
1442 'default' => ''
1443 ),
1444 'value' => array(
1445 'description' => 'A value for the semaphore.',
1446 'type' => 'varchar',
1447 'length' => 255,
1448 'not null' => TRUE,
1449 'default' => ''
1450 ),
1451 'expire' => array(
1452 'description' => 'A Unix timestamp with microseconds indicating when the semaphore should expire.',
1453 'type' => 'float',
1454 'size' => 'big',
1455 'not null' => TRUE
1456 ),
1457 ),
1458 'indexes' => array(
1459 'value' => array('value'),
1460 'expire' => array('expire'),
1461 ),
1462 'primary key' => array('name'),
1463 );
1464
1465 $schema['sequences'] = array(
1466 'description' => 'Stores IDs.',
1467 'fields' => array(
1468 'value' => array(
1469 'description' => 'The value of the sequence.',
1470 'type' => 'serial',
1471 'unsigned' => TRUE,
1472 'not null' => TRUE,
1473 ),
1474 ),
1475 'primary key' => array('value'),
1476 );
1477
1478 $schema['sessions'] = array(
1479 'description' => "Drupal's session handlers read and write into the sessions table. Each record represents a user session, either anonymous or authenticated.",
1480 'fields' => array(
1481 'uid' => array(
1482 'description' => 'The {users}.uid corresponding to a session, or 0 for anonymous user.',
1483 'type' => 'int',
1484 'unsigned' => TRUE,
1485 'not null' => TRUE,
1486 ),
1487 'sid' => array(
1488 'description' => "A session ID. The value is generated by Drupal's session handlers.",
1489 'type' => 'varchar',
1490 'length' => 128,
1491 'not null' => TRUE,
1492 ),
1493 'ssid' => array(
1494 'description' => "Secure session ID. The value is generated by Drupal's session handlers.",
1495 'type' => 'varchar',
1496 'length' => 128,
1497 'not null' => TRUE,
1498 'default' => '',
1499 ),
1500 'hostname' => array(
1501 'description' => 'The IP address that last used this session ID (sid).',
1502 'type' => 'varchar',
1503 'length' => 128,
1504 'not null' => TRUE,
1505 'default' => '',
1506 ),
1507 'timestamp' => array(
1508 'description' => 'The Unix timestamp when this session last requested a page. Old records are purged by PHP automatically.',
1509 'type' => 'int',
1510 'not null' => TRUE,
1511 'default' => 0,
1512 ),
1513 'cache' => array(
1514 'description' => "The time of this user's last post. This is used when the site has specified a minimum_cache_lifetime. See cache_get().",
1515 'type' => 'int',
1516 'not null' => TRUE,
1517 'default' => 0,
1518 ),
1519 'session' => array(
1520 'description' => 'The serialized contents of $_SESSION, an array of name/value pairs that persists across page requests by this session ID. Drupal loads $_SESSION from here at the start of each request and saves it at the end.',
1521 'type' => 'blob',
1522 'not null' => FALSE,
1523 'size' => 'big',
1524 ),
1525 ),
1526 'primary key' => array(
1527 'sid',
1528 'ssid',
1529 ),
1530 'indexes' => array(
1531 'timestamp' => array('timestamp'),
1532 'uid' => array('uid'),
1533 'ssid' => array('ssid'),
1534 ),
1535 'foreign keys' => array(
1536 'session_user' => array(
1537 'table' => 'users',
1538 'columns' => array('uid' => 'uid'),
1539 ),
1540 ),
1541 );
1542
1543 $schema['system'] = array(
1544 'description' => "A list of all modules, themes, and theme engines that are or have been installed in Drupal's file system.",
1545 'fields' => array(
1546 'filename' => array(
1547 'description' => 'The path of the primary file for this item, relative to the Drupal root; e.g. modules/node/node.module.',
1548 'type' => 'varchar',
1549 'length' => 255,
1550 'not null' => TRUE,
1551 'default' => '',
1552 ),
1553 'name' => array(
1554 'description' => 'The name of the item; e.g. node.',
1555 'type' => 'varchar',
1556 'length' => 255,
1557 'not null' => TRUE,
1558 'default' => '',
1559 ),
1560 'type' => array(
1561 'description' => 'The type of the item, either module, theme, or theme_engine.',
1562 'type' => 'varchar',
1563 'length' => 12,
1564 'not null' => TRUE,
1565 'default' => '',
1566 ),
1567 'owner' => array(
1568 'description' => "A theme's 'parent' . Can be either a theme or an engine.",
1569 'type' => 'varchar',
1570 'length' => 255,
1571 'not null' => TRUE,
1572 'default' => '',
1573 ),
1574 'status' => array(
1575 'description' => 'Boolean indicating whether or not this item is enabled.',
1576 'type' => 'int',
1577 'not null' => TRUE,
1578 'default' => 0,
1579 ),
1580 'bootstrap' => array(
1581 'description' => "Boolean indicating whether this module is loaded during Drupal's early bootstrapping phase (e.g. even before the page cache is consulted).",
1582 'type' => 'int',
1583 'not null' => TRUE,
1584 'default' => 0,
1585 ),
1586 'schema_version' => array(
1587 'description' => "The module's database schema version number. -1 if the module is not installed (its tables do not exist); 0 or the largest N of the module's hook_update_N() function that has either been run or existed when the module was first installed.",
1588 'type' => 'int',
1589 'not null' => TRUE,
1590 'default' => -1,
1591 'size' => 'small',
1592 ),
1593 'weight' => array(
1594 'description' => "The order in which this module's hooks should be invoked relative to other modules. Equal-weighted modules are ordered by name.",
1595 'type' => 'int',
1596 'not null' => TRUE,
1597 'default' => 0,
1598 ),
1599 'info' => array(
1600 'description' => "A serialized array containing information from the module's .info file; keys can include name, description, package, version, core, dependencies, and php.",
1601 'type' => 'blob',
1602 'not null' => FALSE,
1603 ),
1604 ),
1605 'primary key' => array('filename'),
1606 'indexes' => array(
1607 'system_list' => array('status', 'bootstrap', 'type', 'weight', 'name'),
1608 'type_name' => array('type', 'name'),
1609 ),
1610 );
1611
1612 $schema['url_alias'] = array(
1613 'description' => 'A list of URL aliases for Drupal paths; a user may visit either the source or destination path.',
1614 'fields' => array(
1615 'pid' => array(
1616 'description' => 'A unique path alias identifier.',
1617 'type' => 'serial',
1618 'unsigned' => TRUE,
1619 'not null' => TRUE,
1620 ),
1621 'source' => array(
1622 'description' => 'The Drupal path this alias is for; e.g. node/12.',
1623 'type' => 'varchar',
1624 'length' => 255,
1625 'not null' => TRUE,
1626 'default' => '',
1627 ),
1628 'alias' => array(
1629 'description' => 'The alias for this path; e.g. title-of-the-story.',
1630 'type' => 'varchar',
1631 'length' => 255,
1632 'not null' => TRUE,
1633 'default' => '',
1634 ),
1635 'language' => array(
1636 'description' => "The language this alias is for; if 'und', the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.",
1637 'type' => 'varchar',
1638 'length' => 12,
1639 'not null' => TRUE,
1640 'default' => '',
1641 ),
1642 ),
1643 'primary key' => array('pid'),
1644 'indexes' => array(
1645 'alias_language_pid' => array('alias', 'language', 'pid'),
1646 'source_language_pid' => array('source', 'language', 'pid'),
1647 ),
1648 );
1649
1650 return $schema;
1651 }
1652
1660 function system_schema_cache_7054() {
1661 return array(
1662 'description' => 'Generic cache table for caching things not separated out into their own tables. Contributed modules may also use this to store cached items.',
1663 'fields' => array(
1664 'cid' => array(
1665 'description' => 'Primary Key: Unique cache ID.',
1666 'type' => 'varchar',
1667 'length' => 255,
1668 'not null' => TRUE,
1669 'default' => '',
1670 ),
1671 'data' => array(
1672 'description' => 'A collection of data to cache.',
1673 'type' => 'blob',
1674 'not null' => FALSE,
1675 'size' => 'big',
1676 ),
1677 'expire' => array(
1678 'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
1679 'type' => 'int',
1680 'not null' => TRUE,
1681 'default' => 0,
1682 ),
1683 'created' => array(
1684 'description' => 'A Unix timestamp indicating when the cache entry was created.',
1685 'type' => 'int',
1686 'not null' => TRUE,
1687 'default' => 0,
1688 ),
1689 'serialized' => array(
1690 'description' => 'A flag to indicate whether content is serialized (1) or not (0).',
1691 'type' => 'int',
1692 'size' => 'small',
1693 'not null' => TRUE,
1694 'default' => 0,
1695 ),
1696 ),
1697 'indexes' => array(
1698 'expire' => array('expire'),
1699 ),
1700 'primary key' => array('cid'),
1701 );
1702 }
1703
1704
1705 // Updates for core.
1706
1707 function system_update_last_removed() {
1708 return 6055;
1709 }
1710
1714 function system_update_dependencies() {
1715 // system_update_7053() queries the {block} table, so it must run after
1716 // block_update_7002(), which creates that table.
1717 $dependencies['system'][7053] = array(
1718 'block' => 7002,
1719 );
1720
1721 // system_update_7061() queries the {node_revision} table, so it must run
1722 // after node_update_7001(), which renames the {node_revisions} table.
1723 $dependencies['system'][7061] = array(
1724 'node' => 7001,
1725 );
1726
1727 // system_update_7067() migrates role permissions and therefore must run
1728 // after the {role} and {role_permission} tables are properly set up, which
1729 // happens in user_update_7007().
1730 $dependencies['system'][7067] = array(
1731 'user' => 7007,
1732 );
1733
1734 return $dependencies;
1735 }
1736
1746 function system_update_7000() {
1747 $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
1748 foreach ($result as $role) {
1749 $renamed_permission = $role->perm;
1750 $renamed_permission = preg_replace('/(?<=^|,\ )create\ blog\ entries(?=,|$)/', 'create blog content', $renamed_permission);
1751 $renamed_permission = preg_replace('/(?<=^|,\ )edit\ own\ blog\ entries(?=,|$)/', 'edit own blog content', $renamed_permission);
1752 $renamed_permission = preg_replace('/(?<=^|,\ )edit\ any\ blog\ entry(?=,|$)/', 'edit any blog content', $renamed_permission);
1753 $renamed_permission = preg_replace('/(?<=^|,\ )delete\ own\ blog\ entries(?=,|$)/', 'delete own blog content', $renamed_permission);
1754 $renamed_permission = preg_replace('/(?<=^|,\ )delete\ any\ blog\ entry(?=,|$)/', 'delete any blog content', $renamed_permission);
1755
1756 $renamed_permission = preg_replace('/(?<=^|,\ )create\ forum\ topics(?=,|$)/', 'create forum content', $renamed_permission);
1757 $renamed_permission = preg_replace('/(?<=^|,\ )delete\ any\ forum\ topic(?=,|$)/', 'delete any forum content', $renamed_permission);
1758 $renamed_permission = preg_replace('/(?<=^|,\ )delete\ own\ forum\ topics(?=,|$)/', 'delete own forum content', $renamed_permission);
1759 $renamed_permission = preg_replace('/(?<=^|,\ )edit\ any\ forum\ topic(?=,|$)/', 'edit any forum content', $renamed_permission);
1760 $renamed_permission = preg_replace('/(?<=^|,\ )edit\ own\ forum\ topics(?=,|$)/', 'edit own forum content', $renamed_permission);
1761
1762 if ($renamed_permission != $role->perm) {
1763 db_update('permission')
1764 ->fields(array('perm' => $renamed_permission))
1765 ->condition('rid', $role->rid)
1766 ->execute();
1767 }
1768 }
1769 }
1770
1774 function system_update_7001() {
1775 variable_set('cron_key', drupal_random_key());
1776 }
1777
1781 function system_update_7002() {
1782 $schema['blocked_ips'] = array(
1783 'description' => 'Stores blocked IP addresses.',
1784 'fields' => array(
1785 'iid' => array(
1786 'description' => 'Primary Key: unique ID for IP addresses.',
1787 'type' => 'serial',
1788 'unsigned' => TRUE,
1789 'not null' => TRUE,
1790 ),
1791 'ip' => array(
1792 'description' => 'IP address',
1793 'type' => 'varchar',
1794 'length' => 32,
1795 'not null' => TRUE,
1796 'default' => '',
1797 ),
1798 ),
1799 'indexes' => array(
1800 'blocked_ip' => array('ip'),
1801 ),
1802 'primary key' => array('iid'),
1803 );
1804
1805 db_create_table('blocked_ips', $schema['blocked_ips']);
1806 }
1807
1811 function system_update_7003() {
1812 $messages = array();
1813 $type = 'host';
1814 $result = db_query("SELECT mask FROM {access} WHERE status = :status AND type = :type", array(
1815 ':status' => 0,
1816 ':type' => $type,
1817 ));
1818 foreach ($result as $blocked) {
1819 if (filter_var($blocked->mask, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) !== FALSE) {
1820 db_insert('blocked_ips')
1821 ->fields(array('ip' => $blocked->mask))
1822 ->execute();
1823 }
1824 else {
1825 $invalid_host = check_plain($blocked->mask);
1826 $messages[] = t('The host !host is no longer blocked because it is not a valid IP address.', array('!host' => $invalid_host ));
1827 }
1828 }
1829 if (isset($invalid_host)) {
1830 drupal_set_message('Drupal no longer supports wildcard IP address blocking. Visitors whose IP addresses match ranges you have previously set using <em>access rules</em> will no longer be blocked from your site when you put the site online. See the <a href="http://drupal.org/node/24302">IP address and referrer blocking Handbook page</a> for alternative methods.', 'warning');
1831 }
1832 // Make sure not to block any IP addresses that were specifically allowed by access rules.
1833 if (!empty($result)) {
1834 $result = db_query("SELECT mask FROM {access} WHERE status = :status AND type = :type", array(
1835 ':status' => 1,
1836 ':type' => $type,
1837 ));
1838 $or = db_condition('or');
1839 foreach ($result as $allowed) {
1840 $or->condition('ip', $allowed->mask, 'LIKE');
1841 }
1842 if (count($or)) {
1843 db_delete('blocked_ips')
1844 ->condition($or)
1845 ->execute();
1846 }
1847 }
1848 }
1849
1853 function system_update_7004(&$sandbox) {
1854 // Get an array of the renamed block deltas, organized by module.
1855 $renamed_deltas = array(
1856 'blog' => array('0' => 'recent'),
1857 'book' => array('0' => 'navigation'),
1858 'comment' => array('0' => 'recent'),
1859 'forum' => array(
1860 '0' => 'active',
1861 '1' => 'new',
1862 ),
1863 'locale' => array('0' => LANGUAGE_TYPE_INTERFACE),
1864 'node' => array('0' => 'syndicate'),
1865 'poll' => array('0' => 'recent'),
1866 'profile' => array('0' => 'author-information'),
1867 'search' => array('0' => 'form'),
1868 'statistics' => array('0' => 'popular'),
1869 'system' => array('0' => 'powered-by'),
1870 'user' => array(
1871 '0' => 'login',
1872 '1' => 'navigation',
1873 '2' => 'new',
1874 '3' => 'online',
1875 ),
1876 );
1877
1878 $moved_deltas = array(
1879 'user' => array('navigation' => 'system'),
1880 );
1881
1882 // Only run this the first time through the batch update.
1883 if (!isset($sandbox['progress'])) {
1884 // Rename forum module's block variables.
1885 $forum_block_num_0 = variable_get('forum_block_num_0');
1886 if (isset($forum_block_num_0)) {
1887 variable_set('forum_block_num_active', $forum_block_num_0);
1888 variable_del('forum_block_num_0');
1889 }
1890 $forum_block_num_1 = variable_get('forum_block_num_1');
1891 if (isset($forum_block_num_1)) {
1892 variable_set('forum_block_num_new', $forum_block_num_1);
1893 variable_del('forum_block_num_1');
1894 }
1895 }
1896
1897 update_fix_d7_block_deltas($sandbox, $renamed_deltas, $moved_deltas);
1898
1899 }
1900
1904 function system_update_7005() {
1905 db_drop_field('blocks', 'throttle');
1906 db_drop_field('system', 'throttle');
1907 variable_del('throttle_user');
1908 variable_del('throttle_anonymous');
1909 variable_del('throttle_level');
1910 variable_del('throttle_probability_limiter');
1911 }
1912
1916 function system_update_7007() {
1917 // Copy the permissions from the old {permission} table to the new {role_permission} table.
1918 $messages = array();
1919 $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid ASC");
1920 $query = db_insert('role_permission')->fields(array('rid', 'permission'));
1921 foreach ($result as $role) {
1922 foreach (array_unique(explode(', ', $role->perm)) as $perm) {
1923 $query->values(array(
1924 'rid' => $role->rid,
1925 'permission' => $perm,
1926 ));
1927 }
1928 $messages[] = t('Inserted into {role_permission} the permissions for role ID !id', array('!id' => $role->rid));
1929 }
1930 $query->execute();
1931 db_drop_table('permission');
1932
1933 return implode(', ', $messages);
1934 }
1935
1939 function system_update_7009() {
1940 $current_primary = variable_get('menu_primary_links_source');
1941 if (isset($current_primary)) {
1942 variable_set('menu_main_links_source', $current_primary);
1943 variable_del('menu_primary_links_source');
1944 }
1945 }
1946
1950 function system_update_7011() {
1951 // Get existing roles that can 'administer nodes'.
1952 $rids = array();
1953 $rids = db_query("SELECT rid FROM {role_permission} WHERE permission = :perm", array(':perm' => 'administer nodes'))->fetchCol();
1954 // None found.
1955 if (empty($rids)) {
1956 return;
1957 }
1958 $insert = db_insert('role_permission')->fields(array('rid', 'permission'));
1959 foreach ($rids as $rid) {
1960 $insert->values(array(
1961 'rid' => $rid,
1962 'permission' => 'bypass node access',
1963 ));
1964 }
1965 $insert->execute();
1966 }
1967
1971 function system_update_7013() {
1972 $timezone = NULL;
1973 $timezones = system_time_zones();
1974 // If the contributed Date module set a default time zone name, use this
1975 // setting as the default time zone.
1976 if (($timezone_name = variable_get('date_default_timezone_name')) && isset($timezones[$timezone_name])) {
1977 $timezone = $timezone_name;
1978 }
1979 // If the contributed Event module has set a default site time zone, look up
1980 // the time zone name and use it as the default time zone.
1981 if (!$timezone && ($timezone_id = variable_get('date_default_timezone_id', 0))) {
1982 try {
1983 $timezone_name = db_query('SELECT name FROM {event_timezones} WHERE timezone = :timezone_id', array(':timezone_id' => $timezone_id))->fetchField();
1984 if (($timezone_name = str_replace(' ', '_', $timezone_name)) && isset($timezones[$timezone_name])) {
1985 $timezone = $timezone_name;
1986 }
1987 }
1988 catch (PDOException $e) {
1989 // Ignore error if event_timezones table does not exist or unexpected
1990 // schema found.
1991 }
1992 }
1993
1994 // Check to see if timezone was overriden in update_prepare_d7_bootstrap().
1995 $offset = variable_get('date_temporary_timezone');
1996 // If not, use the default.
1997 if (!isset($offset)) {
1998 $offset = variable_get('date_default_timezone', 0);
1999 }
2000
2001 // If the previous default time zone was a non-zero offset, guess the site's
2002 // intended time zone based on that offset and the server's daylight saving
2003 // time status.
2004 if (!$timezone && $offset) {
2005 $timezone_name = timezone_name_from_abbr('', intval($offset), date('I'));
2006 if ($timezone_name && isset($timezones[$timezone_name])) {
2007 $timezone = $timezone_name;
2008 }
2009 }
2010 // Otherwise, the default time zone offset was zero, which is UTC.
2011 if (!$timezone) {
2012 $timezone = 'UTC';
2013 }
2014 variable_set('date_default_timezone', $timezone);
2015 drupal_set_message(format_string('The default time zone has been set to %timezone. Check the <a href="@config-url">date and time configuration page</a> to configure it correctly.', array('%timezone' => $timezone, '@config-url' => url('admin/config/regional/settings'))), 'warning');
2016 // Remove temporary override.
2017 variable_del('date_temporary_timezone');
2018 }
2019
2023 function system_update_7015() {
2024 db_update('menu_links')
2025 ->fields(array('link_path' => 'user/logout'))
2026 ->condition('link_path', 'logout')
2027 ->execute();
2028 db_update('menu_links')
2029 ->fields(array('router_path' => 'user/logout'))
2030 ->condition('router_path', 'logout')
2031 ->execute();
2032
2033 db_update('menu_links')
2034 ->fields(array(
2035 'menu_name' => 'user-menu',
2036 'plid' => 0,
2037 ))
2038 ->condition(db_or()
2039 ->condition('link_path', 'user/logout')
2040 ->condition('router_path', 'user/logout')
2041 )
2042 ->condition('module', 'system')
2043 ->condition('customized', 0)
2044 ->execute();
2045 }
2046
2050 function system_update_7016() {
2051 // Only run these queries if the driver used is pgsql.
2052 if (db_driver() == 'pgsql') {
2053 $result = db_query("SELECT c.relname AS table, a.attname AS field,
2054 pg_catalog.format_type(a.atttypid, a.atttypmod) AS type
2055 FROM pg_catalog.pg_attribute a
2056 LEFT JOIN pg_class c ON (c.oid = a.attrelid)
2057 WHERE pg_catalog.pg_table_is_visible(c.oid) AND c.relkind = 'r'
2058 AND pg_catalog.format_type(a.atttypid, a.atttypmod) LIKE '%unsigned%'");
2059 foreach ($result as $row) {
2060 switch ($row->type) {
2061 case 'smallint_unsigned':
2062 $datatype = 'int';
2063 break;
2064 case 'int_unsigned':
2065 case 'bigint_unsigned':
2066 default:
2067 $datatype = 'bigint';
2068 break;
2069 }
2070 db_query('ALTER TABLE ' . $row->table . ' ALTER COLUMN "' . $row->field . '" TYPE ' . $datatype);
2071 db_query('ALTER TABLE ' . $row->table . ' ADD CHECK ("' . $row->field . '" >= 0)');
2072 }
2073 db_query('DROP DOMAIN IF EXISTS smallint_unsigned');
2074 db_query('DROP DOMAIN IF EXISTS int_unsigned');
2075 db_query('DROP DOMAIN IF EXISTS bigint_unsigned');
2076 }
2077 }
2078
2082 function system_update_7017() {
2083 // Get the global theme settings.
2084 $settings = variable_get('theme_settings', array());
2085 // Get the settings of the default theme.
2086 $settings = array_merge($settings, variable_get('theme_' . variable_get('theme_default', 'garland') . '_settings', array()));
2087
2088 $types = _update_7000_node_get_types();
2089 foreach ($types as $type) {
2090 if (isset($settings['toggle_node_info_' . $type->type])) {
2091 variable_set('node_submitted_' . $type->type, $settings['toggle_node_info_' . $type->type]);
2092 }
2093 }
2094
2095 // Unset deprecated 'toggle_node_info' theme settings.
2096 $theme_settings = variable_get('theme_settings', array());
2097 foreach ($theme_settings as $setting => $value) {
2098 if (substr($setting, 0, 16) == 'toggle_node_info') {
2099 unset($theme_settings[$setting]);
2100 }
2101 }
2102 variable_set('theme_settings', $theme_settings);
2103 }
2104
2108 function system_update_7018() {
2109 db_drop_index('system', 'modules');
2110 db_drop_index('system', 'type_name');
2111 db_change_field('system', 'type', 'type', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
2112 db_add_index('system', 'type_name', array('type', 'name'));
2113 }
2114
2118 function system_update_7020() {
2119 $module_list = array('field_sql_storage', 'field', 'field_ui');
2120 module_enable($module_list, FALSE);
2121 }
2122
2126 function system_update_7021() {
2127 db_update('role_permission')
2128 ->fields(array('permission' => 'use PHP for settings'))
2129 ->condition('permission', 'use PHP for block visibility')
2130 ->execute();
2131 }
2132
2136 function system_update_7027() {
2137 $module_list = array('text', 'number', 'list', 'options');
2138 module_enable($module_list, FALSE);
2139 }
2140
2145 function system_update_7029() {
2146 db_insert('role_permission')
2147 ->fields(array(
2148 'rid' => DRUPAL_AUTHENTICATED_RID,
2149 'permission' => 'view own unpublished content',
2150 ))
2151 ->execute();
2152 }
2153
2157 function system_update_7032() {
2158 db_drop_index('flood', 'allow');
2159 db_change_field('flood', 'hostname', 'identifier', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''));
2160 db_add_index('flood', 'allow', array('event', 'identifier', 'timestamp'));
2161 }
2162
2166 function system_update_7033() {
2167 if (variable_get('cache') == 2) {
2168 variable_set('cache', 1);
2169 return t('Aggressive caching was disabled and replaced with normal caching. Read the page caching section in default.settings.php for more information on how to enable similar functionality.');
2170 }
2171 }
2172
2176 function system_update_7034() {
2177 $files_directory = variable_get('file_directory_path', NULL);
2178 if (variable_get('file_downloads', 1) == 1) {
2179 // Our default is public, so we don't need to set anything.
2180 if (!empty($files_directory)) {
2181 variable_set('file_public_path', $files_directory);
2182 }
2183 }
2184 elseif (variable_get('file_downloads', 1) == 2) {
2185 variable_set('file_default_scheme', 'private');
2186 if (!empty($files_directory)) {
2187 variable_set('file_private_path', $files_directory);
2188 }
2189 }
2190 variable_del('file_downloads');
2191
2192 $schema['file_managed'] = array(
2193 'description' => 'Stores information for uploaded files.',
2194 'fields' => array(
2195 'fid' => array(
2196 'description' => 'File ID.',
2197 'type' => 'serial',
2198 'unsigned' => TRUE,
2199 'not null' => TRUE,
2200 ),
2201 'uid' => array(
2202 'description' => 'The {user}.uid of the user who is associated with the file.',
2203 'type' => 'int',
2204 'unsigned' => TRUE,
2205 'not null' => TRUE,
2206 'default' => 0,
2207 ),
2208 'filename' => array(
2209 'description' => 'Name of the file with no path components. This may differ from the basename of the filepath if the file is renamed to avoid overwriting an existing file.',
2210 'type' => 'varchar',
2211 'length' => 255,
2212 'not null' => TRUE,
2213 'default' => '',
2214 'binary' => TRUE,
2215 ),
2216 'uri' => array(
2217 'description' => 'URI of file.',
2218 'type' => 'varchar',
2219 'length' => 255,
2220 'not null' => TRUE,
2221 'default' => '',
2222 'binary' => TRUE,
2223 ),
2224 'filemime' => array(
2225 'description' => "The file's MIME type.",
2226 'type' => 'varchar',
2227 'length' => 255,
2228 'not null' => TRUE,
2229 'default' => '',
2230 ),
2231 'filesize' => array(
2232 'description' => 'The size of the file in bytes.',
2233 'type' => 'int',
2234 'unsigned' => TRUE,
2235 'not null' => TRUE,
2236 'default' => 0,
2237 ),
2238 'status' => array(
2239 'description' => 'A field indicating the status of the file. Two status are defined in core: temporary (0) and permanent (1). Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during a cron run.',
2240 'type' => 'int',
2241 'not null' => TRUE,
2242 'default' => 0,
2243 'size' => 'tiny',
2244 ),
2245 'timestamp' => array(
2246 'description' => 'UNIX timestamp for when the file was added.',
2247 'type' => 'int',
2248 'unsigned' => TRUE,
2249 'not null' => TRUE,
2250 'default' => 0,
2251 ),
2252 ),
2253 'indexes' => array(
2254 'uid' => array('uid'),
2255 'status' => array('status'),
2256 'timestamp' => array('timestamp'),
2257 ),
2258 'unique keys' => array(
2259 'uri' => array('uri'),
2260 ),
2261 'primary key' => array('fid'),
2262 );
2263
2264 db_create_table('file_managed', $schema['file_managed']);
2265 }
2266
2270 function system_update_7036() {
2271 // Get existing roles that can 'administer site configuration'.
2272 $rids = db_query("SELECT rid FROM {role_permission} WHERE permission = :perm", array(':perm' => 'administer site configuration'))->fetchCol();
2273 // None found.
2274 if (empty($rids)) {
2275 return;
2276 }
2277 $insert = db_insert('role_permission')->fields(array('rid', 'permission'));
2278 foreach ($rids as $rid) {
2279 $insert->values(array(
2280 'rid' => $rid,
2281 'permission' => 'access site in maintenance mode',
2282 ));
2283 }
2284 $insert->execute();
2285 }
2286
2290 function system_update_7042() {
2291 // update_fix_d7_requirements() adds 'fake' source and alias columns to
2292 // allow bootstrap to run without fatal errors. Remove those columns now
2293 // so that we can rename properly.
2294 db_drop_field('url_alias', 'source');
2295 db_drop_field('url_alias', 'alias');
2296
2297 // Drop indexes.
2298 db_drop_index('url_alias', 'src_language_pid');
2299 db_drop_unique_key('url_alias', 'dst_language_pid');
2300 // Rename the fields, and increase their length to 255 characters.
2301 db_change_field('url_alias', 'src', 'source', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
2302 db_change_field('url_alias', 'dst', 'alias', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
2303 // Add indexes back. We replace the unique key with an index since it never
2304 // provided any meaningful unique constraint ('pid' is a primary key).
2305 db_add_index('url_alias', 'source_language_pid', array('source', 'language', 'pid'));
2306 db_add_index('url_alias', 'alias_language_pid', array('alias', 'language', 'pid'));
2307
2308 // Now that the URL aliases are correct, we can rebuild the whitelist.
2309 drupal_path_alias_whitelist_rebuild();
2310 }
2311
2315 function system_update_7044() {
2316 // The current value of the increment has been taken into account when
2317 // creating the sequences table in update_fix_d7_requirements().
2318 db_drop_table('actions_aid');
2319 }
2320
2324 function system_update_7045() {
2325 db_add_field('flood', 'expiration', array('description' => 'Expiration timestamp. Expired events are purged on cron run.', 'type' => 'int', 'not null' => TRUE, 'default' => 0));
2326 db_add_index('flood', 'purge', array('expiration'));
2327 }
2328
2332 function system_update_7046() {
2333 if (variable_get('theme_default') == 'minnelli' || variable_get('admin_theme') == 'minnelli') {
2334 // Make sure Garland is enabled.
2335 db_update('system')
2336 ->fields(array('status' => 1))
2337 ->condition('type', 'theme')
2338 ->condition('name', 'garland')
2339 ->execute();
2340 if (variable_get('theme_default') != 'garland') {
2341 // If the default theme isn't Garland, transfer all of Minnelli's old
2342 // settings to Garland.
2343 $settings = variable_get('theme_minnelli_settings', array());
2344 // Set the theme setting width to "fixed" to match Minnelli's old layout.
2345 $settings['garland_width'] = 'fixed';
2346 variable_set('theme_garland_settings', $settings);
2347 // Remove Garland's color files since they won't match Minnelli's.
2348 foreach (variable_get('color_garland_files', array()) as $file) {
2349 @drupal_unlink($file);
2350 }
2351 if (isset($file) && $file = dirname($file)) {
2352 @drupal_rmdir($file);
2353 }
2354 variable_del('color_garland_palette');
2355 variable_del('color_garland_stylesheets');
2356 variable_del('color_garland_logo');
2357 variable_del('color_garland_files');
2358 variable_del('color_garland_screenshot');
2359 }
2360 if (variable_get('theme_default') == 'minnelli') {
2361 variable_set('theme_default', 'garland');
2362 }
2363 if (variable_get('admin_theme') == 'minnelli') {
2364 variable_set('admin_theme', 'garland');
2365 }
2366 }
2367 }
2368
2372 function system_update_7047() {
2373 variable_set('site_frontpage', drupal_get_normal_path(variable_get('site_frontpage', 'node')));
2374 }
2375
2379 function system_update_7048() {
2380 db_update('url_alias')
2381 ->fields(array('language' => LANGUAGE_NONE))
2382 ->condition('language', '')
2383 ->execute();
2384 }
2385
2389 function system_update_7049() {
2390 if (variable_get('install_profile', 'standard') == 'default') {
2391 variable_set('install_profile', 'standard');
2392 }
2393 }
2394
2398 function system_update_7050() {
2399 db_change_field('batch', 'bid', 'bid', array('description' => 'Primary Key: Unique batch ID.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE));
2400 }
2401
2405 function system_update_7051() {
2406 db_change_field('blocked_ips', 'ip', 'ip', array('description' => 'IP address', 'type' => 'varchar', 'length' => 40, 'not null' => TRUE, 'default' => ''));
2407 }
2408
2412 function system_update_7052() {
2413 db_change_field('menu_router', 'file', 'include_file', array('type' => 'text', 'size' => 'medium'));
2414 }
2415
2419 function system_update_7053() {
2420 if (db_table_exists('menu_custom')) {
2421 // Create the same menus as in menu_install().
2422 db_insert('menu_custom')
2423 ->fields(array('menu_name' => 'user-menu', 'title' => 'User Menu', 'description' => "The <em>User</em> menu contains links related to the user's account, as well as the 'Log out' link."))
2424 ->execute();
2425
2426 db_insert('menu_custom')
2427 ->fields(array('menu_name' => 'management', 'title' => 'Management', 'description' => "The <em>Management</em> menu contains links for administrative tasks."))
2428 ->execute();
2429 }
2430
2431 block_flush_caches();
2432
2433 // Show the new menu blocks along the navigation block.
2434 $blocks = db_query("SELECT theme, status, region, weight, visibility, pages FROM {block} WHERE module = 'system' AND delta = 'navigation'");
2435 $deltas = db_or()
2436 ->condition('delta', 'user-menu')
2437 ->condition('delta', 'management');
2438
2439 foreach ($blocks as $block) {
2440 db_update('block')
2441 ->fields(array(
2442 'status' => $block->status,
2443 'region' => $block->region,
2444 'weight' => $block->weight,
2445 'visibility' => $block->visibility,
2446 'pages' => $block->pages,
2447 ))
2448 ->condition('theme', $block->theme)
2449 ->condition('module', 'system')
2450 ->condition($deltas)
2451 ->execute();
2452 }
2453 }
2454
2458 function system_update_7054() {
2459 // Update: update_fix_d7_requirements() installs this version for cache_path
2460 // already, so we don't include it in this particular update. It should be
2461 // included in later updates though.
2462 $cache_tables = array(
2463 'cache' => 'Generic cache table for caching things not separated out into their own tables. Contributed modules may also use this to store cached items.',
2464 'cache_form' => 'Cache table for the form system to store recently built forms and their storage data, to be used in subsequent page requests.',
2465 'cache_page' => 'Cache table used to store compressed pages for anonymous users, if page caching is enabled.',
2466 'cache_menu' => 'Cache table for the menu system to store router information as well as generated link trees for various menu/page/user combinations.',
2467 );
2468 $schema = system_schema_cache_7054();
2469 foreach ($cache_tables as $table => $description) {
2470 $schema['description'] = $description;
2471 db_drop_table($table);
2472 db_create_table($table, $schema);
2473 }
2474 }
2475
2479 function system_update_7055() {
2480 $spec = array(
2481 'description' => 'The value of the variable.',
2482 'type' => 'blob',
2483 'not null' => TRUE,
2484 'size' => 'big',
2485 'translatable' => TRUE,
2486 );
2487 db_change_field('variable', 'value', 'value', $spec);
2488
2489 $spec = array(
2490 'description' => 'Parameters to be passed to the callback function.',
2491 'type' => 'blob',
2492 'not null' => TRUE,
2493 'size' => 'big',
2494 );
2495 db_change_field('actions', 'parameters', 'parameters', $spec);
2496
2497 $spec = array(
2498 'description' => 'A serialized array containing the processing data for the batch.',
2499 'type' => 'blob',
2500 'not null' => FALSE,
2501 'size' => 'big',
2502 );
2503 db_change_field('batch', 'batch', 'batch', $spec);
2504
2505 $spec = array(
2506 'description' => 'A serialized array of function names (like node_load) to be called to load an object corresponding to a part of the current path.',
2507 'type' => 'blob',
2508 'not null' => TRUE,
2509 );
2510 db_change_field('menu_router', 'load_functions', 'load_functions', $spec);
2511
2512 $spec = array(
2513 'description' => 'A serialized array of function names (like user_uid_optional_to_arg) to be called to replace a part of the router path with another string.',
2514 'type' => 'blob',
2515 'not null' => TRUE,
2516 );
2517 db_change_field('menu_router', 'to_arg_functions', 'to_arg_functions', $spec);
2518
2519 $spec = array(
2520 'description' => 'A serialized array of arguments for the access callback.',
2521 'type' => 'blob',
2522 'not null' => FALSE,
2523 );
2524 db_change_field('menu_router', 'access_arguments', 'access_arguments', $spec);
2525
2526 $spec = array(
2527 'description' => 'A serialized array of arguments for the page callback.',
2528 'type' => 'blob',
2529 'not null' => FALSE,
2530 );
2531 db_change_field('menu_router', 'page_arguments', 'page_arguments', $spec);
2532
2533 $spec = array(
2534 'description' => 'A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.',
2535 'type' => 'blob',
2536 'not null' => FALSE,
2537 'translatable' => TRUE,
2538 );
2539 db_change_field('menu_links', 'options', 'options', $spec);
2540
2541 $spec = array(
2542 'description' => 'The serialized contents of $_SESSION, an array of name/value pairs that persists across page requests by this session ID. Drupal loads $_SESSION from here at the start of each request and saves it at the end.',
2543 'type' => 'blob',
2544 'not null' => FALSE,
2545 'size' => 'big',
2546 );
2547 db_change_field('sessions', 'session', 'session', $spec);
2548
2549 $spec = array(
2550 'description' => "A serialized array containing information from the module's .info file; keys can include name, description, package, version, core, dependencies, and php.",
2551 'type' => 'blob',
2552 'not null' => FALSE,
2553 );
2554 db_change_field('system', 'info', 'info', $spec);
2555 }
2556
2560 function system_update_7057() {
2561 $spec = array(
2562 'description' => "A session ID. The value is generated by PHP's Session API.",
2563 'type' => 'varchar',
2564 'length' => 128,
2565 'not null' => TRUE,
2566 'default' => '',
2567 );
2568 db_change_field('sessions', 'sid', 'sid', $spec);
2569 }
2570
2574 function system_update_7058() {
2575 variable_del('cron_semaphore');
2576 }
2577
2581 function system_update_7059() {
2582 $spec = array(
2583 'description' => 'Track where a file is used.',
2584 'fields' => array(
2585 'fid' => array(
2586 'description' => 'File ID.',
2587 'type' => 'int',
2588 'unsigned' => TRUE,
2589 'not null' => TRUE,
2590 ),
2591 'module' => array(
2592 'description' => 'The name of the module that is using the file.',
2593 'type' => 'varchar',
2594 'length' => 255,
2595 'not null' => TRUE,
2596 'default' => '',
2597 ),
2598 'type' => array(
2599 'description' => 'The name of the object type in which the file is used.',
2600 'type' => 'varchar',
2601 'length' => 64,
2602 'not null' => TRUE,
2603 'default' => '',
2604 ),
2605 'id' => array(
2606 'description' => 'The primary key of the object using the file.',
2607 'type' => 'int',
2608 'unsigned' => TRUE,
2609 'not null' => TRUE,
2610 'default' => 0,
2611 ),
2612 'count' => array(
2613 'description' => 'The number of times this file is used by this object.',
2614 'type' => 'int',
2615 'unsigned' => TRUE,
2616 'not null' => TRUE,
2617 'default' => 0,
2618 ),
2619 ),
2620 'primary key' => array('fid', 'type', 'id', 'module'),
2621 'indexes' => array(
2622 'type_id' => array('type', 'id'),
2623 'fid_count' => array('fid', 'count'),
2624 'fid_module' => array('fid', 'module'),
2625 ),
2626 );
2627 db_create_table('file_usage', $spec);
2628 }
2629
2633 function system_update_7060() {
2634 if (!db_table_exists('upload')) {
2635 return;
2636 }
2637
2638 if (!db_query_range('SELECT 1 FROM {upload}', 0, 1)->fetchField()) {
2639 // There is nothing to migrate. Delete variables and the empty table. There
2640 // is no need to create fields that are not going to be used.
2641 foreach (_update_7000_node_get_types() as $node_type) {
2642 variable_del('upload_' . $node_type->type);
2643 }
2644 db_drop_table('upload');
2645 return;
2646 }
2647
2648 // Check which node types have upload.module attachments enabled.
2649 $context['types'] = array();
2650 foreach (_update_7000_node_get_types() as $node_type) {
2651 if (variable_get('upload_' . $node_type->type, 0)) {
2652 $context['types'][$node_type->type] = $node_type->type;
2653 }
2654 }
2655
2656 // The {upload} table will be deleted when this update is complete so we
2657 // want to be careful to migrate all the data, even for node types that
2658 // may have had attachments disabled after files were uploaded. Look for
2659 // any other node types referenced by the upload records and add those to
2660 // the list. The admin can always remove the field later.
2661 $results = db_query('SELECT DISTINCT type FROM {node} n INNER JOIN {node_revision} nr ON n.nid = nr.nid INNER JOIN {upload} u ON nr.vid = u.vid');
2662 foreach ($results as $row) {
2663 if (!isset($context['types'][$row->type])) {
2664 drupal_set_message(t('The content type %rowtype had uploads disabled but contained uploaded file data. Uploads have been re-enabled to migrate the existing data. You may delete the "File attachments" field in the %rowtype type if this data is not necessary.', array('%rowtype' => $row->type)));
2665 $context['types'][$row->type] = $row->type;
2666 }
2667 }
2668
2669 // Create a single "upload" field on all the content types that have uploads
2670 // enabled, then add an instance to each enabled type.
2671 if (count($context['types']) > 0) {
2672 module_enable(array('file'));
2673 $field = array(
2674 'field_name' => 'upload',
2675 'type' => 'file',
2676 'module' => 'file',
2677 'locked' => FALSE,
2678 'cardinality' => FIELD_CARDINALITY_UNLIMITED,
2679 'translatable' => FALSE,
2680 'settings' => array(
2681 'display_field' => 1,
2682 'display_default' => variable_get('upload_list_default', 1),
2683 'uri_scheme' => file_default_scheme(),
2684 'default_file' => 0,
2685 ),
2686 );
2687
2688 $upload_size = variable_get('upload_uploadsize_default', 1);
2689 $instance = array(
2690 'field_name' => 'upload',
2691 'entity_type' => 'node',
2692 'bundle' => NULL,
2693 'label' => 'File attachments',
2694 'required' => 0,
2695 'description' => '',
2696 'widget' => array(
2697 'weight' => '1',
2698 'settings' => array(
2699 'progress_indicator' => 'throbber',
2700 ),
2701 'type' => 'file_generic',
2702 ),
2703 'settings' => array(
2704 'max_filesize' => $upload_size ? ($upload_size . ' MB') : '',
2705 'file_extensions' => variable_get('upload_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp'),
2706 'file_directory' => '',
2707 'description_field' => 1,
2708 ),
2709 'display' => array(
2710 'default' => array(
2711 'label' => 'hidden',
2712 'type' => 'file_table',
2713 'settings' => array(),
2714 'weight' => 0,
2715 'module' => 'file',
2716 ),
2717 'full' => array(
2718 'label' => 'hidden',
2719 'type' => 'file_table',
2720 'settings' => array(),
2721 'weight' => 0,
2722 'module' => 'file',
2723 ),
2724 'teaser' => array(
2725 'label' => 'hidden',
2726 'type' => 'hidden',
2727 'settings' => array(),
2728 'weight' => 0,
2729 'module' => NULL,
2730 ),
2731 'rss' => array(
2732 'label' => 'hidden',
2733 'type' => 'file_table',
2734 'settings' => array(),
2735 'weight' => 0,
2736 'module' => 'file',
2737 ),
2738 ),
2739 );
2740
2741 // Create the field.
2742 _update_7000_field_create_field($field);
2743
2744 // Create the instances.
2745 foreach ($context['types'] as $bundle) {
2746 $instance['bundle'] = $bundle;
2747 _update_7000_field_create_instance($field, $instance);
2748 // Now that the instance is created, we can safely delete any legacy
2749 // node type information.
2750 variable_del('upload_' . $bundle);
2751 }
2752 }
2753 else {
2754 // No uploads or content types with uploads enabled.
2755 db_drop_table('upload');
2756 }
2757 }
2758
2762 function system_update_7061(&$sandbox) {
2763 if (!db_table_exists('upload')) {
2764 return;
2765 }
2766
2767 if (!isset($sandbox['progress'])) {
2768 // Delete stale rows from {upload} where the fid is not in the {files} table.
2769 db_delete('upload')
2770 ->notExists(
2771 db_select('files', 'f')
2772 ->fields('f', array('fid'))
2773 ->where('f.fid = {upload}.fid')
2774 )
2775 ->execute();
2776
2777 // Delete stale rows from {upload} where the vid is not in the
2778 // {node_revision} table. The table has already been renamed in
2779 // node_update_7001().
2780 db_delete('upload')
2781 ->notExists(
2782 db_select('node_revision', 'nr')
2783 ->fields('nr', array('vid'))
2784 ->where('nr.vid = {upload}.vid')
2785 )
2786 ->execute();
2787
2788 // Retrieve a list of node revisions that have uploaded files attached.
2789 // DISTINCT queries are expensive, especially when paged, so we store the
2790 // data in its own table for the duration of the update.
2791 if (!db_table_exists('system_update_7061')) {
2792 $table = array(
2793 'description' => t('Stores temporary data for system_update_7061.'),
2794 'fields' => array('vid' => array('type' => 'int')),
2795 'primary key' => array('vid'),
2796 );
2797 db_create_table('system_update_7061', $table);
2798 }
2799 $query = db_select('upload', 'u');
2800 $query->distinct();
2801 $query->addField('u','vid');
2802 db_insert('system_update_7061')
2803 ->from($query)
2804 ->execute();
2805
2806 // Initialize batch update information.
2807 $sandbox['progress'] = 0;
2808 $sandbox['last_vid_processed'] = -1;
2809 $sandbox['max'] = db_query("SELECT COUNT(*) FROM {system_update_7061}")->fetchField();
2810 }
2811
2812 // Determine vids for this batch.
2813 // Process all files attached to a given revision during the same batch.
2814 $limit = variable_get('upload_update_batch_size', 100);
2815 $vids = db_query_range('SELECT vid FROM {system_update_7061} WHERE vid > :lastvid ORDER BY vid', 0, $limit, array(':lastvid' => $sandbox['last_vid_processed']))
2816 ->fetchCol();
2817
2818 // Retrieve information on all the files attached to these revisions.
2819 if (!empty($vids)) {
2820 $node_revisions = array();
2821 $result = db_query('SELECT u.fid, u.vid, u.list, u.description, n.nid, n.type, u.weight FROM {upload} u INNER JOIN {node_revision} nr ON u.vid = nr.vid INNER JOIN {node} n ON n.nid = nr.nid WHERE u.vid IN (:vids) ORDER BY u.vid, u.weight, u.fid', array(':vids' => $vids));
2822 foreach ($result as $record) {
2823 // For each uploaded file, retrieve the corresponding data from the old
2824 // files table (since upload doesn't know about the new entry in the
2825 // file_managed table).
2826 $file = db_select('files', 'f')
2827 ->fields('f', array('fid', 'uid', 'filename', 'filepath', 'filemime', 'filesize', 'status', 'timestamp'))
2828 ->condition('f.fid', $record->fid)
2829 ->execute()
2830 ->fetchAssoc();
2831 if (!$file) {
2832 continue;
2833 }
2834
2835 // Add in the file information from the upload table.
2836 $file['description'] = $record->description;
2837 $file['display'] = $record->list;
2838
2839 // Create one record for each revision that contains all the uploaded
2840 // files.
2841 $node_revisions[$record->vid]['nid'] = $record->nid;
2842 $node_revisions[$record->vid]['vid'] = $record->vid;
2843 $node_revisions[$record->vid]['type'] = $record->type;
2844 $node_revisions[$record->vid]['file'][LANGUAGE_NONE][] = $file;
2845 }
2846
2847 // Now that we know which files belong to which revisions, update the
2848 // files'// database entries, and save a reference to each file in the
2849 // upload field on their node revisions.
2850 $basename = variable_get('file_directory_path', conf_path() . '/files');
2851 $scheme = file_default_scheme() . '://';
2852 foreach ($node_revisions as $vid => $revision) {
2853 foreach ($revision['file'][LANGUAGE_NONE] as $delta => $file) {
2854 // We will convert filepaths to URI using the default scheme
2855 // and stripping off the existing file directory path.
2856 $file['uri'] = $scheme . preg_replace('!^' . preg_quote($basename) . '!', '', $file['filepath']);
2857 $file['uri'] = file_stream_wrapper_uri_normalize($file['uri']);
2858 unset($file['filepath']);
2859 // Insert into the file_managed table.
2860 // Each fid should only be stored once in file_managed.
2861 db_merge('file_managed')
2862 ->key(array(
2863 'fid' => $file['fid'],
2864 ))
2865 ->fields(array(
2866 'uid' => $file['uid'],
2867 'filename' => $file['filename'],
2868 'uri' => $file['uri'],
2869 'filemime' => $file['filemime'],
2870 'filesize' => $file['filesize'],
2871 'status' => $file['status'],
2872 'timestamp' => $file['timestamp'],
2873 ))
2874 ->execute();
2875
2876 // Add the usage entry for the file.
2877 $file = (object) $file;
2878 file_usage_add($file, 'file', 'node', $revision['nid']);
2879
2880 // Update the node revision's upload file field with the file data.
2881 $revision['file'][LANGUAGE_NONE][$delta] = array('fid' => $file->fid, 'display' => $file->display, 'description' => $file->description);
2882 }
2883
2884 // Write the revision's upload field data into the field_upload tables.
2885 $node = (object) $revision;
2886 _update_7000_field_sql_storage_write('node', $node->type, $node->nid, $node->vid, 'upload', $node->file);
2887
2888 // Update our progress information for the batch update.
2889 $sandbox['progress']++;
2890 $sandbox['last_vid_processed'] = $vid;
2891 }
2892 }
2893
2894 // If less than limit node revisions were processed, the update process is
2895 // finished.
2896 if (count($vids) < $limit) {
2897 $finished = TRUE;
2898 }
2899
2900 // If there's no max value then there's nothing to update and we're finished.
2901 if (empty($sandbox['max']) || isset($finished)) {
2902 db_drop_table('upload');
2903 db_drop_table('system_update_7061');
2904 return t('Upload module has been migrated to File module.');
2905 }
2906 else {
2907 // Indicate our current progress to the batch update system.
2908 $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max'];
2909 }
2910 }
2911
2915 function system_update_7062() {
2916 db_drop_index('system', 'bootstrap');
2917 db_drop_index('system', 'system_list');
2918 db_add_index('system', 'system_list', array('status', 'bootstrap', 'type', 'weight', 'name'));
2919 }
2920
2924 function system_update_7063() {
2925 // For router items where 'type' => MENU_CALLBACK, {menu_router}.type is
2926 // stored as 4 in Drupal 6, and 0 in Drupal 7. Fortunately Drupal 7 doesn't
2927 // store any types as 4, so delete both.
2928 $result = db_query('SELECT ml.mlid FROM {menu_links} ml INNER JOIN {menu_router} mr ON ml.router_path = mr.path WHERE ml.module = :system AND ml.customized = 0 AND mr.type IN(:callbacks)', array(':callbacks' => array(0, 4), ':system' => 'system'));
2929 foreach ($result as $record) {
2930 db_delete('menu_links')->condition('mlid', $record->mlid)->execute();
2931 }
2932 }
2933
2937 function system_update_7064() {
2938 db_drop_field('menu_router', 'block_callback');
2939 }
2940
2944 function system_update_7065() {
2945 $spec = array(
2946 'description' => "A session ID. The value is generated by Drupal's session handlers.",
2947 'type' => 'varchar',
2948 'length' => 128,
2949 'not null' => TRUE,
2950 );
2951 db_drop_primary_key('sessions');
2952 db_change_field('sessions', 'sid', 'sid', $spec, array('primary key' => array('sid', 'ssid')));
2953 // Delete any sessions with empty session ID.
2954 db_delete('sessions')->condition('sid', '')->execute();
2955 }
2956
2960 function system_update_7066() {
2961 $d6_file_directory_temp = variable_get('file_directory_temp', file_directory_temp());
2962 variable_set('file_temporary_path', $d6_file_directory_temp);
2963 variable_del('file_directory_temp');
2964 }
2965
2969 function system_update_7067() {
2970 // Users with access to administration pages already see the administration
2971 // theme in some places (if one is enabled on the site), so we want them to
2972 // continue seeing it.
2973 $admin_roles = user_roles(FALSE, 'access administration pages');
2974 foreach (array_keys($admin_roles) as $rid) {
2975 _update_7000_user_role_grant_permissions($rid, array('view the administration theme'), 'system');
2976 }
2977 // The above check is not guaranteed to reach all administrative users of the
2978 // site, so if the site is currently using an administration theme, display a
2979 // message also.
2980 if (variable_get('admin_theme')) {
2981 if (empty($admin_roles)) {
2982 drupal_set_message('The new "View the administration theme" permission is required in order to view your site\'s administration theme. You can grant this permission to your site\'s administrators on the <a href="' . url('admin/people/permissions', array('fragment' => 'module-system')) . '">permissions page</a>.');
2983 }
2984 else {
2985 drupal_set_message('The new "View the administration theme" permission is required in order to view your site\'s administration theme. This permission has been automatically granted to the following roles: <em>' . check_plain(implode(', ', $admin_roles)) . '</em>. You can grant this permission to other roles on the <a href="' . url('admin/people/permissions', array('fragment' => 'module-system')) . '">permissions page</a>.');
2986 }
2987 }
2988 }
2989
2993 function system_update_7068() {
2994 $spec = array(
2995 'description' => "The language this alias is for; if 'und', the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.",
2996 'type' => 'varchar',
2997 'length' => 12,
2998 'not null' => TRUE,
2999 'default' => '',
3000 );
3001 db_change_field('url_alias', 'language', 'language', $spec);
3002 }
3003
3009 function system_update_7069() {
3010 variable_del('site_offline');
3011 }
3012
3027 function system_update_7070() {
3028 variable_del('drupal_badge_color');
3029 variable_del('drupal_badge_size');
3030 }
3031
3035 function system_update_7071() {
3036 db_drop_index('date_format_type', 'title');
3037 db_add_index('date_format_type', 'title', array('title'));
3038 db_change_field('registry', 'filename', 'filename', array(
3039 'type' => 'varchar',
3040 'length' => 255,
3041 'not null' => TRUE,
3042 ));
3043 }
3044
3050 function system_update_7072() {
3051 variable_del('site_offline_message');
3052 }
3053
3058 function system_update_7073() {
3059 db_change_field('file_managed', 'filename', 'filename', array(
3060 'description' => 'Name of the file with no path components. This may differ from the basename of the URI if the file is renamed to avoid overwriting an existing file.',
3061 'type' => 'varchar',
3062 'length' => 255,
3063 'not null' => TRUE,
3064 'default' => '',
3065 'binary' => TRUE,
3066 ));
3067 db_drop_unique_key('file_managed', 'uri');
3068 db_change_field('file_managed', 'uri', 'uri', array(
3069 'description' => 'The URI to access the file (either local or remote).',
3070 'type' => 'varchar',
3071 'length' => 255,
3072 'not null' => TRUE,
3073 'default' => '',
3074 'binary' => TRUE,
3075 ));
3076 db_add_unique_key('file_managed', 'uri', array('uri'));
3077 }
3078
3082 function system_update_7074() {
3083 // This update function previously converted menu_links query strings to
3084 // arrays. It has been removed for now due to incompatibility with
3085 // PostgreSQL.
3086 }
3087
3091 function system_update_7076() {
3092 $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC))
3093 ->fields('ml', array('mlid', 'options'));
3094 foreach ($query->execute() as $menu_link) {
3095 if (strpos($menu_link['options'], 'query') !== FALSE) {
3096 $menu_link['options'] = unserialize($menu_link['options']);
3097 if (isset($menu_link['options']['query']) && is_string($menu_link['options']['query'])) {
3098 $menu_link['options']['query'] = drupal_get_query_array($menu_link['options']['query']);
3099 db_update('menu_links')
3100 ->fields(array(
3101 'options' => serialize($menu_link['options']),
3102 ))
3103 ->condition('mlid', $menu_link['mlid'], '=')
3104 ->execute();
3105 }
3106 }
3107 }
3108 }
3109
3113 function system_update_7077() {
3114 db_change_field('file_managed', 'filename', 'filename', array(
3115 'description' => 'Name of the file with no path components. This may differ from the basename of the URI if the file is renamed to avoid overwriting an existing file.',
3116 'type' => 'varchar',
3117 'length' => 255,
3118 'not null' => TRUE,
3119 'default' => '',
3120 ));
3121 }
3122
3123
3127 function system_update_7078() {
3128 db_drop_unique_key('date_formats', 'formats');
3129 db_change_field('date_formats', 'format', 'format', array(
3130 'description' => 'The date format string.',
3131 'type' => 'varchar',
3132 'length' => 100,
3133 'not null' => TRUE,
3134 'binary' => TRUE,
3135 ), array('unique keys' => array('formats' => array('format', 'type'))));
3136 }
3137
3141 function system_update_7079() {
3142 $spec = array(
3143 'description' => 'The size of the file in bytes.',
3144 'type' => 'int',
3145 'size' => 'big',
3146 'unsigned' => TRUE,
3147 'not null' => TRUE,
3148 'default' => 0,
3149 );
3150 db_change_field('file_managed', 'filesize', 'filesize', $spec);
3151 }
3152
system_update_7050
system_update_7050()
Definition: system.install:2398
FILE_NOT_WRITABLE
const FILE_NOT_WRITABLE
Definition: install.inc:71
system_update_7049
system_update_7049()
Definition: system.install:2389
module_list
module_list($refresh=FALSE, $bootstrap_refresh=FALSE, $sort=FALSE, $fixed_list=NULL)
Definition: module.inc:66
drupal_check_memory_limit
drupal_check_memory_limit($required, $memory_limit=NULL)
Definition: bootstrap.inc:3477
file_default_scheme
file_default_scheme()
Definition: file.inc:256
system_update_7016
system_update_7016()
Definition: system.install:2050
db_add_index
db_add_index($table, $name, $fields)
Definition: database.inc:2940
system_update_7036
system_update_7036()
Definition: system.install:2270
file_usage_add
file_usage_add(stdClass $file, $module, $type, $id, $count=1)
Definition: file.inc:682
FILE_CREATE_DIRECTORY
const FILE_CREATE_DIRECTORY
Definition: file.inc:41
l
l($text, $path, array $options=array())
Definition: common.inc:2432
SCHEMA_INSTALLED
const SCHEMA_INSTALLED
Definition: install.inc:16
system_update_7077
system_update_7077()
Definition: system.install:3113
drupal_unlink
drupal_unlink($uri, $context=NULL)
Definition: file.inc:2225
system_time_zones
system_time_zones($blank=NULL)
Definition: system.module:3335
system_update_7079
system_update_7079()
Definition: system.install:3141
Database\getConnection
static getConnection($target= 'default', $key=NULL)
Definition: database.inc:1460
system_update_7005
system_update_7005()
Definition: system.install:1904
_update_7000_user_role_grant_permissions
_update_7000_user_role_grant_permissions($rid, array $permissions, $module)
Definition: user.install:389
block_flush_caches
block_flush_caches()
Definition: block.module:967
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
$module
print $module
Definition: search-results.tpl.php:28
system_update_7064
system_update_7064()
Definition: system.install:2937
system_update_7062
system_update_7062()
Definition: system.install:2915
system_update_7045
system_update_7045()
Definition: system.install:2324
system_update_7052
system_update_7052()
Definition: system.install:2412
db_drop_primary_key
db_drop_primary_key($table)
Definition: database.inc:2900
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
system_update_7029
system_update_7029()
Definition: system.install:2145
db_drop_index
db_drop_index($table, $name)
Definition: database.inc:2952
$name
print $name
Definition: profile-listing.tpl.php:43
system_check_http_request
system_check_http_request()
Definition: system.module:3361
$results
print $results
Definition: poll-results.tpl.php:23
system_update_last_removed
system_update_last_removed()
Definition: system.install:1707
system_update_7034
system_update_7034()
Definition: system.install:2176
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
drupal_detect_database_types
drupal_detect_database_types()
Definition: install.inc:237
system_update_7053
system_update_7053()
Definition: system.install:2419
system_update_7013
system_update_7013()
Definition: system.install:1971
system_update_7071
system_update_7071()
Definition: system.install:3035
system_update_7072
system_update_7072()
Definition: system.install:3050
update_fix_d7_block_deltas
update_fix_d7_block_deltas(&$sandbox, $renamed_deltas, $moved_deltas)
Definition: update.inc:355
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
user_roles
user_roles($membersonly=FALSE, $permission=NULL)
Definition: user.module:2871
module_exists
module_exists($module)
Definition: module.inc:274
drupal_get_query_array
drupal_get_query_array($query)
Definition: common.inc:457
db_add_field
db_add_field($table, $field, $spec, $keys_new=array())
Definition: database.inc:2840
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
drupal_verify_install_file
drupal_verify_install_file($file, $mask=NULL, $type= 'file')
Definition: install.inc:829
REQUIREMENT_WARNING
const REQUIREMENT_WARNING
Definition: install.inc:31
system_rebuild_theme_data
system_rebuild_theme_data()
Definition: system.module:2609
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
$contents
print $contents
Definition: book-export-html.tpl.php:49
db_add_unique_key
db_add_unique_key($table, $name, $fields)
Definition: database.inc:2914
FILE_EXIST
const FILE_EXIST
Definition: install.inc:41
drupal_get_installed_schema_version
drupal_get_installed_schema_version($module, $reset=FALSE, $array=FALSE)
Definition: install.inc:146
REQUIREMENT_OK
const REQUIREMENT_OK
Definition: install.inc:26
db_or
db_or()
Definition: database.inc:2662
$module_list
$module_list['system']['filename']
Definition: authorize.php:78
system_update_7060
system_update_7060()
Definition: system.install:2633
system_update_7033
system_update_7033()
Definition: system.install:2166
system_rebuild_module_data
system_rebuild_module_data()
Definition: system.module:2444
system_update_7001
system_update_7001()
Definition: system.install:1774
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
db_drop_field
db_drop_field($table, $field)
Definition: database.inc:2852
system_update_7009
system_update_7009()
Definition: system.install:1939
system_update_7047
system_update_7047()
Definition: system.install:2372
system_update_7044
system_update_7044()
Definition: system.install:2315
system_update_7015
system_update_7015()
Definition: system.install:2023
system_update_dependencies
system_update_dependencies()
Definition: system.install:1714
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
system_get_info
system_get_info($type, $name=NULL)
Definition: system.module:2338
module_enable
module_enable($module_list, $enable_dependencies=TRUE)
Definition: module.inc:383
$info
$info
Definition: color.inc:6
DRUPAL_MINIMUM_PHP
const DRUPAL_MINIMUM_PHP
Definition: bootstrap.inc:21
system_update_7061
system_update_7061(&$sandbox)
Definition: system.install:2762
drupal_set_installed_schema_version
drupal_set_installed_schema_version($module, $version)
Definition: install.inc:177
drupal_get_profile
drupal_get_profile()
Definition: common.inc:222
system_update_7020
system_update_7020()
Definition: system.install:2118
system_update_7051
system_update_7051()
Definition: system.install:2405
system_install
system_install()
Definition: system.install:523
system_update_7065
system_update_7065()
Definition: system.install:2944
system_schema
system_schema()
Definition: system.install:554
drupal_rmdir
drupal_rmdir($uri, $context=NULL)
Definition: file.inc:2389
system_update_7018
system_update_7018()
Definition: system.install:2108
drupal_random_key
drupal_random_key($byte_count=32)
Definition: bootstrap.inc:1945
system_update_7074
system_update_7074()
Definition: system.install:3082
system_update_7003
system_update_7003()
Definition: system.install:1811
system_update_7070
system_update_7070()
Definition: system.install:3027
drupal_install_schema
drupal_install_schema($module)
Definition: common.inc:6939
$value
print $value
Definition: user-profile-item.tpl.php:26
unicode_requirements
unicode_requirements()
Definition: unicode.inc:134
get_t
get_t()
Definition: bootstrap.inc:2635
DRUPAL_AUTHENTICATED_RID
const DRUPAL_AUTHENTICATED_RID
Definition: bootstrap.inc:167
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$messages
print $messages
Definition: page.tpl.php:121
drupal_get_normal_path
drupal_get_normal_path($path, $path_language=NULL)
Definition: path.inc:259
db_drop_unique_key
db_drop_unique_key($table, $name)
Definition: database.inc:2926
_update_7000_field_create_instance
_update_7000_field_create_instance($field, &$instance)
Definition: field.install:363
system_update_7059
system_update_7059()
Definition: system.install:2581
system_update_7004
system_update_7004(&$sandbox)
Definition: system.install:1853
system_update_7042
system_update_7042()
Definition: system.install:2290
file_directory_temp
file_directory_temp()
Definition: file.inc:2446
FIELD_CARDINALITY_UNLIMITED
const FIELD_CARDINALITY_UNLIMITED
Definition: field.module:236
system_update_7069
system_update_7069()
Definition: system.install:3009
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
system_update_7073
system_update_7073()
Definition: system.install:3058
system_update_7055
system_update_7055()
Definition: system.install:2479
db_driver
db_driver()
Definition: database.inc:2620
file_stream_wrapper_uri_normalize
file_stream_wrapper_uri_normalize($uri)
Definition: file.inc:275
system_update_7027
system_update_7027()
Definition: system.install:2136
conf_path
conf_path($require_settings=TRUE, $reset=FALSE)
Definition: bootstrap.inc:541
_update_7000_field_sql_storage_write
_update_7000_field_sql_storage_write($entity_type, $bundle, $entity_id, $revision_id, $field_name, $data)
Definition: field_sql_storage.install:35
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
db_condition
db_condition($conjunction)
Definition: database.inc:2694
system_update_7002
system_update_7002()
Definition: system.install:1781
system_update_7011
system_update_7011()
Definition: system.install:1950
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
FILE_READABLE
const FILE_READABLE
Definition: install.inc:46
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
drupal_get_schema_versions
drupal_get_schema_versions($module)
Definition: install.inc:98
system_update_7057
system_update_7057()
Definition: system.install:2560
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
format_string
format_string($string, array $args=array())
Definition: bootstrap.inc:1527
system_update_7078
system_update_7078()
Definition: system.install:3127
DRUPAL_MINIMUM_PHP_MEMORY_LIMIT
const DRUPAL_MINIMUM_PHP_MEMORY_LIMIT
Definition: bootstrap.inc:26
_update_7000_node_get_types
_update_7000_node_get_types()
Definition: node.install:480
system_update_7032
system_update_7032()
Definition: system.install:2157
VERSION
const VERSION
Definition: bootstrap.inc:11
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
DRUPAL_CORE_COMPATIBILITY
const DRUPAL_CORE_COMPATIBILITY
Definition: bootstrap.inc:16
$row
$row
Definition: block-admin-display-form.tpl.php:47
system_update_7046
system_update_7046()
Definition: system.install:2332
system_requirements
system_requirements($phase)
Definition: system.install:11
drupal_check_incompatibility
drupal_check_incompatibility($v, $current_version)
Definition: common.inc:7597
$help
print $help
Definition: maintenance-page.tpl.php:69
file_prepare_directory
file_prepare_directory(&$directory, $options=FILE_MODIFY_PERMISSIONS)
Definition: file.inc:430
system_update_7054
system_update_7054()
Definition: system.install:2458
base_path
base_path()
Definition: common.inc:2817
LANGUAGE_TYPE_INTERFACE
const LANGUAGE_TYPE_INTERFACE
Definition: bootstrap.inc:191
drupal_path_alias_whitelist_rebuild
drupal_path_alias_whitelist_rebuild($source=NULL)
Definition: path.inc:367
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
system_update_7048
system_update_7048()
Definition: system.install:2379
system_update_7067
system_update_7067()
Definition: system.install:2969
REQUIREMENT_INFO
const REQUIREMENT_INFO
Definition: install.inc:21
system_update_7007
system_update_7007()
Definition: system.install:1916
system_update_7068
system_update_7068()
Definition: system.install:2993
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
_update_7000_field_create_field
_update_7000_field_create_field(&$field)
Definition: field.install:177
system_update_7017
system_update_7017()
Definition: system.install:2082
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
system_update_7063
system_update_7063()
Definition: system.install:2924
file_ensure_htaccess
file_ensure_htaccess()
Definition: file.inc:457
system_schema_cache_7054
system_schema_cache_7054()
Definition: system.install:1660
system_update_7076
system_update_7076()
Definition: system.install:3091
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
system_update_7021
system_update_7021()
Definition: system.install:2126
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
db_table_exists
db_table_exists($table)
Definition: database.inc:2760
system_update_7000
system_update_7000()
Definition: system.install:1746
system_update_7058
system_update_7058()
Definition: system.install:2574
system_update_7066
system_update_7066()
Definition: system.install:2960
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example/ajax_example.install Source File

  • examples
  • ajax_example
ajax_example.install
Go to the documentation of this file.
1 <?php
2
11 function ajax_example_schema() {
12 $schema['ajax_example_node_form_alter'] = array(
13 'description' => 'Stores example settings for nodes.',
14 'fields' => array(
15 'nid' => array(
16 'type' => 'int',
17 'unsigned' => TRUE,
18 'not null' => TRUE,
19 'default' => 0,
20 'description' => 'The {node}.nid to store settings.',
21 ),
22 'example_1' => array(
23 'type' => 'int',
24 'not null' => TRUE,
25 'default' => 0,
26 'description' => 'Node Form Example 1 checkbox',
27 ),
28 'example_2' => array(
29 'type' => 'varchar',
30 'length' => 256,
31 'not null' => FALSE,
32 'default' => '',
33 'description' => 'Node Form Example 2 textfield',
34 ),
35 ),
36 'primary key' => array('nid'),
37 'foreign keys' => array(
38 'dnv_node' => array(
39 'table' => 'node',
40 'columns' => array('nid' => 'nid'),
41 ),
42 ),
43 );
44 return $schema;
45 }
46
50 function ajax_example_update_7100() {
51 if (!db_table_exists('ajax_example_node_form_alter')) {
52 $schema = ajax_example_schema();
53 db_create_table('ajax_example_node_form_alter', $schema['ajax_example_node_form_alter']);
54 return st('Created table ajax_example_node_form_alter');
55 }
56 }
ajax_example_update_7100
ajax_example_update_7100()
Definition: ajax_example.install:50
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
st
st($string, array $args=array(), array $options=array())
Definition: install.inc:1111
db_table_exists
db_table_exists($table)
Definition: database.inc:2760
ajax_example_schema
ajax_example_schema()
Definition: ajax_example.install:11
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalUnitTestCase Member List

This is the complete list of members for DrupalUnitTestCase, including all inherited members.

$assertions | DrupalTestCase | protected
$databasePrefix | DrupalTestCase | protected
$originalFileDirectory | DrupalTestCase | protected
$results | DrupalTestCase |
$setup | DrupalTestCase | protected
$setupDatabasePrefix | DrupalTestCase | protected
$setupEnvironment | DrupalTestCase | protected
$skipClasses | DrupalTestCase | protected
$testId | DrupalTestCase | protected
$timeLimit | DrupalTestCase | protected
__construct($test_id=NULL) | DrupalUnitTestCase |
assert($status, $message= '', $group= 'Other', array $caller=NULL) | DrupalTestCase | protected
assertEqual($first, $second, $message= '', $group= 'Other') | DrupalTestCase | protected
assertFalse($value, $message= '', $group= 'Other') | DrupalTestCase | protected
assertIdentical($first, $second, $message= '', $group= 'Other') | DrupalTestCase | protected
assertNotEqual($first, $second, $message= '', $group= 'Other') | DrupalTestCase | protected
assertNotIdentical($first, $second, $message= '', $group= 'Other') | DrupalTestCase | protected
assertNotNull($value, $message= '', $group= 'Other') | DrupalTestCase | protected
assertNull($value, $message= '', $group= 'Other') | DrupalTestCase | protected
assertTrue($value, $message= '', $group= 'Other') | DrupalTestCase | protected
deleteAssert($message_id) | DrupalTestCase | static
error($message= '', $group= 'Other', array $caller=NULL) | DrupalTestCase | protected
errorHandler($severity, $message, $file=NULL, $line=NULL) | DrupalTestCase |
exceptionHandler($exception) | DrupalTestCase | protected
fail($message=NULL, $group= 'Other') | DrupalTestCase | protected
generatePermutations($parameters) | DrupalTestCase | static
getAssertionCall() | DrupalTestCase | protected
insertAssert($test_id, $test_class, $status, $message= '', $group= 'Other', array $caller=array()) | DrupalTestCase | static
pass($message=NULL, $group= 'Other') | DrupalTestCase | protected
randomName($length=8) | DrupalTestCase | static
randomString($length=8) | DrupalTestCase | static
run(array $methods=array()) | DrupalTestCase |
setUp() | DrupalUnitTestCase | protected
tearDown() | DrupalUnitTestCase | protected
verbose($message) | DrupalTestCase | protected
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/field_sql_storage/field_sql_storage.install Source File

  • modules
  • field
  • modules
  • field_sql_storage
field_sql_storage.install
Go to the documentation of this file.
1 <?php
2
11 function field_sql_storage_schema() {
12 $schema = array();
13
14 // Dynamic (data) tables.
15 if (db_table_exists('field_config')) {
16 $fields = field_read_fields(array(), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
17 drupal_load('module', 'field_sql_storage');
18 foreach ($fields as $field) {
19 if ($field['storage']['type'] == 'field_sql_storage') {
20 $schema += _field_sql_storage_schema($field);
21 }
22 }
23 }
24 return $schema;
25 }
26
35 function _update_7000_field_sql_storage_write($entity_type, $bundle, $entity_id, $revision_id, $field_name, $data) {
36 $table_name = "field_data_{$field_name}";
37 $revision_name = "field_revision_{$field_name}";
38
39 db_delete($table_name)
40 ->condition('entity_type', $entity_type)
41 ->condition('entity_id', $entity_id)
42 ->execute();
43 db_delete($revision_name)
44 ->condition('entity_type', $entity_type)
45 ->condition('entity_id', $entity_id)
46 ->condition('revision_id', $revision_id)
47 ->execute();
48
49 $columns = array();
50 foreach ($data as $langcode => $items) {
51 foreach ($items as $delta => $item) {
52 $record = array(
53 'entity_type' => $entity_type,
54 'entity_id' => $entity_id,
55 'revision_id' => $revision_id,
56 'bundle' => $bundle,
57 'delta' => $delta,
58 'language' => $langcode,
59 );
60 foreach ($item as $column => $value) {
61 $record[_field_sql_storage_columnname($field_name, $column)] = $value;
62 }
63
64 $records[] = $record;
65 // Record the columns used.
66 $columns += $record;
67 }
68 }
69
70 if ($columns) {
71 $query = db_insert($table_name)->fields(array_keys($columns));
72 $revision_query = db_insert($revision_name)->fields(array_keys($columns));
73 foreach ($records as $record) {
74 $query->values($record);
75 if ($revision_id) {
76 $revision_query->values($record);
77 }
78 }
79 $query->execute();
80 $revision_query->execute();
81 }
82 }
83
92 function field_sql_storage_update_7000() {
93 // Some update helper functions (such as
94 // _update_7000_field_sql_storage_write()) modify the database directly. They
95 // can be used safely only if the database schema matches the field module
96 // schema established for Drupal 7.0 (i.e. version 7000). This function exists
97 // solely to set the schema version to 7000, so that update functions calling
98 // those helpers can do so safely by declaring a dependency on
99 // field_sql_storage_update_7000().
100 }
101
105 function field_sql_storage_update_7001(&$sandbox) {
106 if (!isset($sandbox['progress'])) {
107 // Collect current etids.
108 $sandbox['etids'] = db_query('SELECT etid, type FROM {field_config_entity_type}')->fetchAllKeyed();
109
110 // Collect affected tables: field data, field revision data, 'deleted'
111 // tables.
112 $sandbox['tables'] = array();
113 $results = db_select('field_config', 'fc', array('fetch' => PDO::FETCH_ASSOC))
114 ->fields('fc')
115 ->condition('storage_module', 'field_sql_storage')
116 ->execute();
117 foreach ($results as $field) {
118 if ($field['deleted']) {
119 $sandbox['tables']["field_deleted_data_{$field['id']}"] = 'data';
120 $sandbox['tables']["field_deleted_revision_{$field['id']}"] = 'revision';
121 }
122 else {
123 $sandbox['tables']["field_data_{$field['field_name']}"] = 'data';
124 $sandbox['tables']["field_revision_{$field['field_name']}"] = 'revision';
125 }
126 }
127 reset($sandbox['tables']);
128
129 $sandbox['total'] = count($sandbox['tables']);
130 $sandbox['progress'] = 0;
131 }
132
133 if ($sandbox['tables']) {
134 // Grab the next table to process.
135 $table = key($sandbox['tables']);
136 $type = array_shift($sandbox['tables']);
137
138 if (db_table_exists($table)) {
139 // Add the 'entity_type' column.
140 if (!db_field_exists($table, 'entity_type')) {
141 $column = array(
142 'type' => 'varchar',
143 'length' => 128,
144 'not null' => TRUE,
145 'default' => '',
146 'description' => 'The entity type this data is attached to.',
147 );
148 db_add_field($table, 'entity_type', $column);
149
150 // Populate the 'entity_type' column based on the 'etid' column.
151 foreach ($sandbox['etids'] as $etid => $entity_type) {
152 db_update($table)
153 ->fields(array('entity_type' => $entity_type))
154 ->condition('etid', $etid)
155 ->execute();
156 }
157
158 // Index the new column.
159 db_add_index($table, 'entity_type', array('entity_type'));
160 }
161
162 // Use the 'entity_type' column in the primary key.
163 db_drop_primary_key($table);
164 $primary_keys = array(
165 'data' => array('entity_type', 'entity_id', 'deleted', 'delta', 'language'),
166 'revision' => array('entity_type', 'entity_id', 'revision_id', 'deleted', 'delta', 'language'),
167 );
168 db_add_primary_key($table, $primary_keys[$type]);
169
170 // Drop the 'etid' column.
171 if (db_field_exists($table, 'etid')) {
172 db_drop_field($table, 'etid');
173 }
174 }
175
176 // Report progress.
177 $sandbox['progress']++;
178 $sandbox['#finished'] = min(0.99, $sandbox['progress'] / $sandbox['total']);
179 }
180 else {
181 // No more tables left: drop the field_config_entity_type table.
182 db_drop_table('field_config_entity_type');
183
184 // Drop the previous 'field_sql_storage_ENTITYTYPE_etid' system variables.
185 foreach ($sandbox['etids'] as $etid => $entity_type) {
186 variable_del('field_sql_storage_' . $entity_type . '_etid');
187 }
188
189 // We're done.
190 $sandbox['#finished'] = 1;
191 }
192 }
193
197 function field_sql_storage_update_7002() {
198 $results = db_select('field_config', 'fc', array('fetch' => PDO::FETCH_ASSOC))
199 ->fields('fc')
200 ->condition('storage_module', 'field_sql_storage')
201 ->execute();
202 foreach ($results as $field) {
203 // Revision tables of deleted fields do not need to be fixed, since no new
204 // data is written to them.
205 if (!$field['deleted']) {
206 $table = "field_revision_{$field['field_name']}";
207 db_drop_primary_key($table);
208 db_add_primary_key($table, array('entity_type', 'entity_id', 'revision_id', 'deleted', 'delta', 'language'));
209 }
210 }
211 }
212
field_read_fields
field_read_fields($params=array(), $include_additional=array())
Definition: field.crud.inc:340
db_add_index
db_add_index($table, $name, $fields)
Definition: database.inc:2940
db_drop_primary_key
db_drop_primary_key($table)
Definition: database.inc:2900
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$results
print $results
Definition: poll-results.tpl.php:23
db_field_exists
db_field_exists($table, $field)
Definition: database.inc:2775
field_sql_storage_update_7002
field_sql_storage_update_7002()
Definition: field_sql_storage.install:197
field_sql_storage_update_7001
field_sql_storage_update_7001(&$sandbox)
Definition: field_sql_storage.install:105
db_add_field
db_add_field($table, $field, $spec, $keys_new=array())
Definition: database.inc:2840
field_sql_storage_update_7000
field_sql_storage_update_7000()
Definition: field_sql_storage.install:92
db_drop_field
db_drop_field($table, $field)
Definition: database.inc:2852
$value
print $value
Definition: user-profile-item.tpl.php:26
db_add_primary_key
db_add_primary_key($table, $fields)
Definition: database.inc:2890
_field_sql_storage_schema
_field_sql_storage_schema($field)
Definition: field_sql_storage.module:108
field_sql_storage_schema
field_sql_storage_schema()
Definition: field_sql_storage.install:11
_field_sql_storage_columnname
_field_sql_storage_columnname($name, $column)
Definition: field_sql_storage.module:78
_update_7000_field_sql_storage_write
_update_7000_field_sql_storage_write($entity_type, $bundle, $entity_id, $revision_id, $field_name, $data)
Definition: field_sql_storage.install:35
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
drupal_load
drupal_load($type, $name)
Definition: bootstrap.inc:1093
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
db_table_exists
db_table_exists($table)
Definition: database.inc:2760
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user.module Source File

  • modules
  • user
user.module
Go to the documentation of this file.
1 <?php
2
11 define('USERNAME_MAX_LENGTH', 60);
12
16 define('EMAIL_MAX_LENGTH', 254);
17
21 define('USER_REGISTER_ADMINISTRATORS_ONLY', 0);
22
26 define('USER_REGISTER_VISITORS', 1);
27
32 define('USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL', 2);
33
37 function user_help($path, $arg) {
38 global $user;
39
40 switch ($path) {
41 case 'admin/help#user':
42 $output = '';
43 $output .= '<h3>' . t('About') . '</h3>';
44 $output .= '<p>' . t('The User module allows users to register, log in, and log out. It also allows users with proper permissions to manage user roles (used to classify users) and permissions associated with those roles. For more information, see the online handbook entry for <a href="@user">User module</a>.', array('@user' => 'http://drupal.org/documentation/modules/user')) . '</p>';
45 $output .= '<h3>' . t('Uses') . '</h3>';
46 $output .= '<dl>';
47 $output .= '<dt>' . t('Creating and managing users') . '</dt>';
48 $output .= '<dd>' . t('The User module allows users with the appropriate <a href="@permissions">permissions</a> to create user accounts through the <a href="@people">People administration page</a>, where they can also assign users to one or more roles, and block or delete user accounts. If allowed, users without accounts (anonymous users) can create their own accounts on the <a href="@register">Create new account</a> page.', array('@permissions' => url('admin/people/permissions', array('fragment' => 'module-user')), '@people' => url('admin/people'), '@register' => url('user/register'))) . '</dd>';
49 $output .= '<dt>' . t('User roles and permissions') . '</dt>';
50 $output .= '<dd>' . t('<em>Roles</em> are used to group and classify users; each user can be assigned one or more roles. By default there are two roles: <em>anonymous user</em> (users that are not logged in) and <em>authenticated user</em> (users that are registered and logged in). Depending on choices you made when you installed Drupal, the installation process may have defined more roles, and you can create additional custom roles on the <a href="@roles">Roles page</a>. After creating roles, you can set permissions for each role on the <a href="@permissions_user">Permissions page</a>. Granting a permission allows users who have been assigned a particular role to perform an action on the site, such as viewing a particular type of content, editing or creating content, administering settings for a particular module, or using a particular function of the site (such as search).', array('@permissions_user' => url('admin/people/permissions'), '@roles' => url('admin/people/permissions/roles'))) . '</dd>';
51 $output .= '<dt>' . t('Account settings') . '</dt>';
52 $output .= '<dd>' . t('The <a href="@accounts">Account settings page</a> allows you to manage settings for the displayed name of the anonymous user role, personal contact forms, user registration, and account cancellation. On this page you can also manage settings for account personalization (including signatures and user pictures), and adapt the text for the e-mail messages that are sent automatically during the user registration process.', array('@accounts' => url('admin/config/people/accounts'))) . '</dd>';
53 $output .= '</dl>';
54 return $output;
55 case 'admin/people/create':
56 return '<p>' . t("This web page allows administrators to register new users. Users' e-mail addresses and usernames must be unique.") . '</p>';
57 case 'admin/people/permissions':
58 return '<p>' . t('Permissions let you control what users can do and see on your site. You can define a specific set of permissions for each role. (See the <a href="@role">Roles</a> page to create a role). Two important roles to consider are Authenticated Users and Administrators. Any permissions granted to the Authenticated Users role will be given to any user who can log into your site. You can make any role the Administrator role for the site, meaning this will be granted all new permissions automatically. You can do this on the <a href="@settings">User Settings</a> page. You should be careful to ensure that only trusted users are given this access and level of control of your site.', array('@role' => url('admin/people/permissions/roles'), '@settings' => url('admin/config/people/accounts'))) . '</p>';
59 case 'admin/people/permissions/roles':
60 $output = '<p>' . t('Roles allow you to fine tune the security and administration of Drupal. A role defines a group of users that have certain privileges as defined on the <a href="@permissions">permissions page</a>. Examples of roles include: anonymous user, authenticated user, moderator, administrator and so on. In this area you will define the names and order of the roles on your site. It is recommended to order your roles from least permissive (anonymous user) to most permissive (administrator). To delete a role choose "edit role".', array('@permissions' => url('admin/people/permissions'))) . '</p>';
61 $output .= '<p>' . t('By default, Drupal comes with two user roles:') . '</p>';
62 $output .= '<ul>';
63 $output .= '<li>' . t("Anonymous user: this role is used for users that don't have a user account or that are not authenticated.") . '</li>';
64 $output .= '<li>' . t('Authenticated user: this role is automatically granted to all logged in users.') . '</li>';
65 $output .= '</ul>';
66 return $output;
67 case 'admin/config/people/accounts/fields':
68 return '<p>' . t('This form lets administrators add, edit, and arrange fields for storing user data.') . '</p>';
69 case 'admin/config/people/accounts/display':
70 return '<p>' . t('This form lets administrators configure how fields should be displayed when rendering a user profile page.') . '</p>';
71 case 'admin/people/search':
72 return '<p>' . t('Enter a simple pattern ("*" may be used as a wildcard match) to search for a username or e-mail address. For example, one may search for "br" and Drupal might return "brian", "brad", and "brenda@example.com".') . '</p>';
73 }
74 }
75
98 function user_module_invoke($type, &$edit, $account, $category = NULL) {
99 foreach (module_implements('user_' . $type) as $module) {
100 $function = $module . '_user_' . $type;
101 $function($edit, $account, $category);
102 }
103 }
104
108 function user_theme() {
109 return array(
110 'user_picture' => array(
111 'variables' => array('account' => NULL),
112 'template' => 'user-picture',
113 ),
114 'user_profile' => array(
115 'render element' => 'elements',
116 'template' => 'user-profile',
117 'file' => 'user.pages.inc',
118 ),
119 'user_profile_category' => array(
120 'render element' => 'element',
121 'template' => 'user-profile-category',
122 'file' => 'user.pages.inc',
123 ),
124 'user_profile_item' => array(
125 'render element' => 'element',
126 'template' => 'user-profile-item',
127 'file' => 'user.pages.inc',
128 ),
129 'user_list' => array(
130 'variables' => array('users' => NULL, 'title' => NULL),
131 ),
132 'user_admin_permissions' => array(
133 'render element' => 'form',
134 'file' => 'user.admin.inc',
135 ),
136 'user_admin_roles' => array(
137 'render element' => 'form',
138 'file' => 'user.admin.inc',
139 ),
140 'user_permission_description' => array(
141 'variables' => array('permission_item' => NULL, 'hide' => NULL),
142 'file' => 'user.admin.inc',
143 ),
144 'user_signature' => array(
145 'variables' => array('signature' => NULL),
146 ),
147 );
148 }
149
153 function user_entity_info() {
154 $return = array(
155 'user' => array(
156 'label' => t('User'),
157 'controller class' => 'UserController',
158 'base table' => 'users',
159 'uri callback' => 'user_uri',
160 'label callback' => 'format_username',
161 'fieldable' => TRUE,
162 // $user->language is only the preferred user language for the user
163 // interface textual elements. As it is not necessarily related to the
164 // language assigned to fields, we do not define it as the entity language
165 // key.
166 'entity keys' => array(
167 'id' => 'uid',
168 ),
169 'bundles' => array(
170 'user' => array(
171 'label' => t('User'),
172 'admin' => array(
173 'path' => 'admin/config/people/accounts',
174 'access arguments' => array('administer users'),
175 ),
176 ),
177 ),
178 'view modes' => array(
179 'full' => array(
180 'label' => t('User account'),
181 'custom settings' => FALSE,
182 ),
183 ),
184 ),
185 );
186 return $return;
187 }
188
192 function user_uri($user) {
193 return array(
194 'path' => 'user/' . $user->uid,
195 );
196 }
197
201 function user_field_info_alter(&$info) {
202 // Add the 'user_register_form' instance setting to all field types.
203 foreach ($info as $field_type => &$field_type_info) {
204 $field_type_info += array('instance_settings' => array());
205 $field_type_info['instance_settings'] += array(
206 'user_register_form' => FALSE,
207 );
208 }
209 }
210
214 function user_field_extra_fields() {
215 $return['user']['user'] = array(
216 'form' => array(
217 'account' => array(
218 'label' => t('User name and password'),
219 'description' => t('User module account form elements.'),
220 'weight' => -10,
221 ),
222 'timezone' => array(
223 'label' => t('Timezone'),
224 'description' => t('User module timezone form element.'),
225 'weight' => 6,
226 ),
227 ),
228 'display' => array(
229 'summary' => array(
230 'label' => t('History'),
231 'description' => t('User module history view element.'),
232 'weight' => 5,
233 ),
234 ),
235 );
236
237 return $return;
238 }
239
249 function user_external_load($authname) {
250 $uid = db_query("SELECT uid FROM {authmap} WHERE authname = :authname", array(':authname' => $authname))->fetchField();
251
252 if ($uid) {
253 return user_load($uid);
254 }
255 else {
256 return FALSE;
257 }
258 }
259
290 function user_load_multiple($uids = array(), $conditions = array(), $reset = FALSE) {
291 return entity_load('user', $uids, $conditions, $reset);
292 }
293
300 class UserController extends DrupalDefaultEntityController {
301
302 function attachLoad(&$queried_users, $revision_id = FALSE) {
303 // Build an array of user picture IDs so that these can be fetched later.
304 $picture_fids = array();
305 foreach ($queried_users as $key => $record) {
306 $picture_fids[] = $record->picture;
307 $queried_users[$key]->data = unserialize($record->data);
308 $queried_users[$key]->roles = array();
309 if ($record->uid) {
310 $queried_users[$record->uid]->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
311 }
312 else {
313 $queried_users[$record->uid]->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
314 }
315 }
316
317 // Add any additional roles from the database.
318 $result = db_query('SELECT r.rid, r.name, ur.uid FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid IN (:uids)', array(':uids' => array_keys($queried_users)));
319 foreach ($result as $record) {
320 $queried_users[$record->uid]->roles[$record->rid] = $record->name;
321 }
322
323 // Add the full file objects for user pictures if enabled.
324 if (!empty($picture_fids) && variable_get('user_pictures', 0)) {
325 $pictures = file_load_multiple($picture_fids);
326 foreach ($queried_users as $account) {
327 if (!empty($account->picture) && isset($pictures[$account->picture])) {
328 $account->picture = $pictures[$account->picture];
329 }
330 else {
331 $account->picture = NULL;
332 }
333 }
334 }
335 // Call the default attachLoad() method. This will add fields and call
336 // hook_user_load().
337 parent::attachLoad($queried_users, $revision_id);
338 }
339 }
340
365 function user_load($uid, $reset = FALSE) {
366 $users = user_load_multiple(array($uid), array(), $reset);
367 return reset($users);
368 }
369
381 function user_load_by_mail($mail) {
382 $users = user_load_multiple(array(), array('mail' => $mail));
383 return reset($users);
384 }
385
397 function user_load_by_name($name) {
398 $users = user_load_multiple(array(), array('name' => $name));
399 return reset($users);
400 }
401
424 function user_save($account, $edit = array(), $category = 'account') {
425 $transaction = db_transaction();
426 try {
427 if (!empty($edit['pass'])) {
428 // Allow alternate password hashing schemes.
429 require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
430 $edit['pass'] = user_hash_password(trim($edit['pass']));
431 // Abort if the hashing failed and returned FALSE.
432 if (!$edit['pass']) {
433 return FALSE;
434 }
435 }
436 else {
437 // Avoid overwriting an existing password with a blank password.
438 unset($edit['pass']);
439 }
440 if (isset($edit['mail'])) {
441 $edit['mail'] = trim($edit['mail']);
442 }
443
444 // Load the stored entity, if any.
445 if (!empty($account->uid) && !isset($account->original)) {
446 $account->original = entity_load_unchanged('user', $account->uid);
447 }
448
449 if (empty($account)) {
450 $account = new stdClass();
451 }
452 if (!isset($account->is_new)) {
453 $account->is_new = empty($account->uid);
454 }
455 // Prepopulate $edit['data'] with the current value of $account->data.
456 // Modules can add to or remove from this array in hook_user_presave().
457 if (!empty($account->data)) {
458 $edit['data'] = !empty($edit['data']) ? array_merge($account->data, $edit['data']) : $account->data;
459 }
460
461 // Invoke hook_user_presave() for all modules.
462 user_module_invoke('presave', $edit, $account, $category);
463
464 // Invoke presave operations of Field Attach API and Entity API. Those APIs
465 // require a fully-fledged and updated entity object. Therefore, we need to
466 // copy any new property values of $edit into it.
467 foreach ($edit as $key => $value) {
468 $account->$key = $value;
469 }
470 field_attach_presave('user', $account);
471 module_invoke_all('entity_presave', $account, 'user');
472
473 if (is_object($account) && !$account->is_new) {
474 // Process picture uploads.
475 if (!empty($account->picture->fid) && (!isset($account->original->picture->fid) || $account->picture->fid != $account->original->picture->fid)) {
476 $picture = $account->picture;
477 // If the picture is a temporary file move it to its final location and
478 // make it permanent.
479 if (!$picture->status) {
480 $info = image_get_info($picture->uri);
481 $picture_directory = file_default_scheme() . '://' . variable_get('user_picture_path', 'pictures');
482
483 // Prepare the pictures directory.
484 file_prepare_directory($picture_directory, FILE_CREATE_DIRECTORY);
485 $destination = file_stream_wrapper_uri_normalize($picture_directory . '/picture-' . $account->uid . '-' . REQUEST_TIME . '.' . $info['extension']);
486
487 // Move the temporary file into the final location.
488 if ($picture = file_move($picture, $destination, FILE_EXISTS_RENAME)) {
489 $picture->status = FILE_STATUS_PERMANENT;
490 $account->picture = file_save($picture);
491 file_usage_add($picture, 'user', 'user', $account->uid);
492 }
493 }
494 // Delete the previous picture if it was deleted or replaced.
495 if (!empty($account->original->picture->fid)) {
496 file_usage_delete($account->original->picture, 'user', 'user', $account->uid);
497 file_delete($account->original->picture);
498 }
499 }
500 elseif (isset($edit['picture_delete']) && $edit['picture_delete']) {
501 file_usage_delete($account->original->picture, 'user', 'user', $account->uid);
502 file_delete($account->original->picture);
503 }
504 $account->picture = empty($account->picture->fid) ? 0 : $account->picture->fid;
505
506 // Do not allow 'uid' to be changed.
507 $account->uid = $account->original->uid;
508 // Save changes to the user table.
509 $success = drupal_write_record('users', $account, 'uid');
510 if ($success === FALSE) {
511 // The query failed - better to abort the save than risk further
512 // data loss.
513 return FALSE;
514 }
515
516 // Reload user roles if provided.
517 if ($account->roles != $account->original->roles) {
518 db_delete('users_roles')
519 ->condition('uid', $account->uid)
520 ->execute();
521
522 $query = db_insert('users_roles')->fields(array('uid', 'rid'));
523 foreach (array_keys($account->roles) as $rid) {
524 if (!in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
525 $query->values(array(
526 'uid' => $account->uid,
527 'rid' => $rid,
528 ));
529 }
530 }
531 $query->execute();
532 }
533
534 // Delete a blocked user's sessions to kick them if they are online.
535 if ($account->original->status != $account->status && $account->status == 0) {
536 drupal_session_destroy_uid($account->uid);
537 }
538
539 // If the password changed, delete all open sessions and recreate
540 // the current one.
541 if ($account->pass != $account->original->pass) {
542 drupal_session_destroy_uid($account->uid);
543 if ($account->uid == $GLOBALS['user']->uid) {
544 drupal_session_regenerate();
545 }
546 }
547
548 // Save Field data.
549 field_attach_update('user', $account);
550
551 // Send emails after we have the new user object.
552 if ($account->status != $account->original->status) {
553 // The user's status is changing; conditionally send notification email.
554 $op = $account->status == 1 ? 'status_activated' : 'status_blocked';
555 _user_mail_notify($op, $account);
556 }
557
558 // Update $edit with any interim changes to $account.
559 foreach ($account as $key => $value) {
560 if (!property_exists($account->original, $key) || $value !== $account->original->$key) {
561 $edit[$key] = $value;
562 }
563 }
564 user_module_invoke('update', $edit, $account, $category);
565 module_invoke_all('entity_update', $account, 'user');
566 }
567 else {
568 // Allow 'uid' to be set by the caller. There is no danger of writing an
569 // existing user as drupal_write_record will do an INSERT.
570 if (empty($account->uid)) {
571 $account->uid = db_next_id(db_query('SELECT MAX(uid) FROM {users}')->fetchField());
572 }
573 // Allow 'created' to be set by the caller.
574 if (!isset($account->created)) {
575 $account->created = REQUEST_TIME;
576 }
577 $success = drupal_write_record('users', $account);
578 if ($success === FALSE) {
579 // On a failed INSERT some other existing user's uid may be returned.
580 // We must abort to avoid overwriting their account.
581 return FALSE;
582 }
583
584 // Make sure $account is properly initialized.
585 $account->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
586
587 field_attach_insert('user', $account);
588 $edit = (array) $account;
589 user_module_invoke('insert', $edit, $account, $category);
590 module_invoke_all('entity_insert', $account, 'user');
591
592 // Save user roles.
593 if (count($account->roles) > 1) {
594 $query = db_insert('users_roles')->fields(array('uid', 'rid'));
595 foreach (array_keys($account->roles) as $rid) {
596 if (!in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
597 $query->values(array(
598 'uid' => $account->uid,
599 'rid' => $rid,
600 ));
601 }
602 }
603 $query->execute();
604 }
605 }
606 // Clear internal properties.
607 unset($account->is_new);
608 unset($account->original);
609 // Clear the static loading cache.
610 entity_get_controller('user')->resetCache(array($account->uid));
611
612 return $account;
613 }
614 catch (Exception $e) {
615 $transaction->rollback();
616 watchdog_exception('user', $e);
617 throw $e;
618 }
619 }
620
624 function user_validate_name($name) {
625 if (!$name) {
626 return t('You must enter a username.');
627 }
628 if (substr($name, 0, 1) == ' ') {
629 return t('The username cannot begin with a space.');
630 }
631 if (substr($name, -1) == ' ') {
632 return t('The username cannot end with a space.');
633 }
634 if (strpos($name, ' ') !== FALSE) {
635 return t('The username cannot contain multiple spaces in a row.');
636 }
637 if (preg_match('/[^\x{80}-\x{F7} a-z0-9@_.\'-]/i', $name)) {
638 return t('The username contains an illegal character.');
639 }
640 if (preg_match('/[\x{80}-\x{A0}' . // Non-printable ISO-8859-1 + NBSP
641 '\x{AD}' . // Soft-hyphen
642 '\x{2000}-\x{200F}' . // Various space characters
643 '\x{2028}-\x{202F}' . // Bidirectional text overrides
644 '\x{205F}-\x{206F}' . // Various text hinting characters
645 '\x{FEFF}' . // Byte order mark
646 '\x{FF01}-\x{FF60}' . // Full-width latin
647 '\x{FFF9}-\x{FFFD}' . // Replacement characters
648 '\x{0}-\x{1F}]/u', // NULL byte and control characters
649 $name)) {
650 return t('The username contains an illegal character.');
651 }
652 if (drupal_strlen($name) > USERNAME_MAX_LENGTH) {
653 return t('The username %name is too long: it must be %max characters or less.', array('%name' => $name, '%max' => USERNAME_MAX_LENGTH));
654 }
655 }
656
670 function user_validate_mail($mail) {
671 if (!$mail) {
672 return t('You must enter an e-mail address.');
673 }
674 if (!valid_email_address($mail)) {
675 return t('The e-mail address %mail is not valid.', array('%mail' => $mail));
676 }
677 }
678
684 function user_validate_picture(&$form, &$form_state) {
685 // If required, validate the uploaded picture.
686 $validators = array(
687 'file_validate_is_image' => array(),
688 'file_validate_image_resolution' => array(variable_get('user_picture_dimensions', '85x85')),
689 'file_validate_size' => array(variable_get('user_picture_file_size', '30') * 1024),
690 );
691
692 // Save the file as a temporary file.
693 $file = file_save_upload('picture_upload', $validators);
694 if ($file === FALSE) {
695 form_set_error('picture_upload', t("Failed to upload the picture image; the %directory directory doesn't exist or is not writable.", array('%directory' => variable_get('user_picture_path', 'pictures'))));
696 }
697 elseif ($file !== NULL) {
698 $form_state['values']['picture_upload'] = $file;
699 }
700 }
701
705 function user_password($length = 10) {
706 // This variable contains the list of allowable characters for the
707 // password. Note that the number 0 and the letter 'O' have been
708 // removed to avoid confusion between the two. The same is true
709 // of 'I', 1, and 'l'.
710 $allowable_characters = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789';
711
712 // Zero-based count of characters in the allowable list:
713 $len = strlen($allowable_characters) - 1;
714
715 // Declare the password as a blank string.
716 $pass = '';
717
718 // Loop the number of times specified by $length.
719 for ($i = 0; $i < $length; $i++) {
720 do {
721 // Find a secure random number within the range needed.
722 $index = ord(drupal_random_bytes(1));
723 } while ($index > $len);
724
725 // Each iteration, pick a random character from the
726 // allowable string and append it to the password:
727 $pass .= $allowable_characters[$index];
728 }
729
730 return $pass;
731 }
732
743 function user_role_permissions($roles = array()) {
744 $cache = &drupal_static(__FUNCTION__, array());
745
746 $role_permissions = $fetch = array();
747
748 if ($roles) {
749 foreach ($roles as $rid => $name) {
750 if (isset($cache[$rid])) {
751 $role_permissions[$rid] = $cache[$rid];
752 }
753 else {
754 // Add this rid to the list of those needing to be fetched.
755 $fetch[] = $rid;
756 // Prepare in case no permissions are returned.
757 $cache[$rid] = array();
758 }
759 }
760
761 if ($fetch) {
762 // Get from the database permissions that were not in the static variable.
763 // Only role IDs with at least one permission assigned will return rows.
764 $result = db_query("SELECT rid, permission FROM {role_permission} WHERE rid IN (:fetch)", array(':fetch' => $fetch));
765
766 foreach ($result as $row) {
767 $cache[$row->rid][$row->permission] = TRUE;
768 }
769 foreach ($fetch as $rid) {
770 // For every rid, we know we at least assigned an empty array.
771 $role_permissions[$rid] = $cache[$rid];
772 }
773 }
774 }
775
776 return $role_permissions;
777 }
778
794 function user_access($string, $account = NULL) {
795 global $user;
796
797 if (!isset($account)) {
798 $account = $user;
799 }
800
801 // User #1 has all privileges:
802 if ($account->uid == 1) {
803 return TRUE;
804 }
805
806 // To reduce the number of SQL queries, we cache the user's permissions
807 // in a static variable.
808 // Use the advanced drupal_static() pattern, since this is called very often.
809 static $drupal_static_fast;
810 if (!isset($drupal_static_fast)) {
811 $drupal_static_fast['perm'] = &drupal_static(__FUNCTION__);
812 }
813 $perm = &$drupal_static_fast['perm'];
814 if (!isset($perm[$account->uid])) {
815 $role_permissions = user_role_permissions($account->roles);
816
817 $perms = array();
818 foreach ($role_permissions as $one_role) {
819 $perms += $one_role;
820 }
821 $perm[$account->uid] = $perms;
822 }
823
824 return isset($perm[$account->uid][$string]);
825 }
826
837 function user_is_blocked($name) {
838 return db_select('users')
839 ->fields('users', array('name'))
840 ->condition('name', db_like($name), 'LIKE')
841 ->condition('status', 0)
842 ->execute()->fetchObject();
843 }
844
848 function user_permission() {
849 return array(
850 'administer permissions' => array(
851 'title' => t('Administer permissions'),
852 'restrict access' => TRUE,
853 ),
854 'administer users' => array(
855 'title' => t('Administer users'),
856 'restrict access' => TRUE,
857 ),
858 'access user profiles' => array(
859 'title' => t('View user profiles'),
860 ),
861 'change own username' => array(
862 'title' => t('Change own username'),
863 ),
864 'cancel account' => array(
865 'title' => t('Cancel own user account'),
866 'description' => t('Note: content may be kept, unpublished, deleted or transferred to the %anonymous-name user depending on the configured <a href="@user-settings-url">user settings</a>.', array('%anonymous-name' => variable_get('anonymous', t('Anonymous')), '@user-settings-url' => url('admin/config/people/accounts'))),
867 ),
868 'select account cancellation method' => array(
869 'title' => t('Select method for cancelling own account'),
870 'restrict access' => TRUE,
871 ),
872 );
873 }
874
880 function user_file_download($uri) {
881 if (strpos(file_uri_target($uri), variable_get('user_picture_path', 'pictures') . '/picture-') === 0) {
882 $info = image_get_info($uri);
883 return array('Content-Type' => $info['mime_type']);
884 }
885 }
886
890 function user_file_move($file, $source) {
891 // If a user's picture is replaced with a new one, update the record in
892 // the users table.
893 if (isset($file->fid) && isset($source->fid) && $file->fid != $source->fid) {
894 db_update('users')
895 ->fields(array(
896 'picture' => $file->fid,
897 ))
898 ->condition('picture', $source->fid)
899 ->execute();
900 }
901 }
902
906 function user_file_delete($file) {
907 // Remove any references to the file.
908 db_update('users')
909 ->fields(array('picture' => 0))
910 ->condition('picture', $file->fid)
911 ->execute();
912 }
913
917 function user_search_info() {
918 return array(
919 'title' => 'Users',
920 );
921 }
922
926 function user_search_access() {
927 return user_access('access user profiles');
928 }
929
933 function user_search_execute($keys = NULL, $conditions = NULL) {
934 $find = array();
935 // Replace wildcards with MySQL/PostgreSQL wildcards.
936 $keys = preg_replace('!\*+!', '%', $keys);
937 $query = db_select('users')->extend('PagerDefault');
938 $query->fields('users', array('uid'));
939 if (user_access('administer users')) {
940 // Administrators can also search in the otherwise private email field,
941 // and they don't need to be restricted to only active users.
942 $query->fields('users', array('mail'));
943 $query->condition(db_or()->
944 condition('name', '%' . db_like($keys) . '%', 'LIKE')->
945 condition('mail', '%' . db_like($keys) . '%', 'LIKE'));
946 }
947 else {
948 // Regular users can only search via usernames, and we do not show them
949 // blocked accounts.
950 $query->condition('name', '%' . db_like($keys) . '%', 'LIKE')
951 ->condition('status', 1);
952 }
953 $uids = $query
954 ->limit(15)
955 ->execute()
956 ->fetchCol();
957 $accounts = user_load_multiple($uids);
958
959 $results = array();
960 foreach ($accounts as $account) {
961 $result = array(
962 'title' => format_username($account),
963 'link' => url('user/' . $account->uid, array('absolute' => TRUE)),
964 );
965 if (user_access('administer users')) {
966 $result['title'] .= ' (' . $account->mail . ')';
967 }
968 $results[] = $result;
969 }
970
971 return $results;
972 }
973
977 function user_element_info() {
978 $types['user_profile_category'] = array(
979 '#theme_wrappers' => array('user_profile_category'),
980 );
981 $types['user_profile_item'] = array(
982 '#theme' => 'user_profile_item',
983 );
984 return $types;
985 }
986
990 function user_user_view($account) {
991 $account->content['user_picture'] = array(
992 '#markup' => theme('user_picture', array('account' => $account)),
993 '#weight' => -10,
994 );
995 if (!isset($account->content['summary'])) {
996 $account->content['summary'] = array();
997 }
998 $account->content['summary'] += array(
999 '#type' => 'user_profile_category',
1000 '#attributes' => array('class' => array('user-member')),
1001 '#weight' => 5,
1002 '#title' => t('History'),
1003 );
1004 $account->content['summary']['member_for'] = array(
1005 '#type' => 'user_profile_item',
1006 '#title' => t('Member for'),
1007 '#markup' => format_interval(REQUEST_TIME - $account->created),
1008 );
1009 }
1010
1019 function user_account_form(&$form, &$form_state) {
1020 global $user;
1021
1022 $account = $form['#user'];
1023 $register = ($form['#user']->uid > 0 ? FALSE : TRUE);
1024
1025 $admin = user_access('administer users');
1026
1027 $form['#validate'][] = 'user_account_form_validate';
1028
1029 // Account information.
1030 $form['account'] = array(
1031 '#type' => 'container',
1032 '#weight' => -10,
1033 );
1034 // Only show name field on registration form or user can change own username.
1035 $form['account']['name'] = array(
1036 '#type' => 'textfield',
1037 '#title' => t('Username'),
1038 '#maxlength' => USERNAME_MAX_LENGTH,
1039 '#description' => t('Spaces are allowed; punctuation is not allowed except for periods, hyphens, apostrophes, and underscores.'),
1040 '#required' => TRUE,
1041 '#attributes' => array('class' => array('username')),
1042 '#default_value' => (!$register ? $account->name : ''),
1043 '#access' => ($register || ($user->uid == $account->uid && user_access('change own username')) || $admin),
1044 '#weight' => -10,
1045 );
1046
1047 $form['account']['mail'] = array(
1048 '#type' => 'textfield',
1049 '#title' => t('E-mail address'),
1050 '#maxlength' => EMAIL_MAX_LENGTH,
1051 '#description' => t('A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'),
1052 '#required' => TRUE,
1053 '#default_value' => (!$register ? $account->mail : ''),
1054 );
1055
1056 // Display password field only for existing users or when user is allowed to
1057 // assign a password during registration.
1058 if (!$register) {
1059 $form['account']['pass'] = array(
1060 '#type' => 'password_confirm',
1061 '#size' => 25,
1062 '#description' => t('To change the current user password, enter the new password in both fields.'),
1063 );
1064 // To skip the current password field, the user must have logged in via a
1065 // one-time link and have the token in the URL.
1066 $pass_reset = isset($_SESSION['pass_reset_' . $account->uid]) && isset($_GET['pass-reset-token']) && ($_GET['pass-reset-token'] == $_SESSION['pass_reset_' . $account->uid]);
1067 $protected_values = array();
1068 $current_pass_description = '';
1069 // The user may only change their own password without their current
1070 // password if they logged in via a one-time login link.
1071 if (!$pass_reset) {
1072 $protected_values['mail'] = $form['account']['mail']['#title'];
1073 $protected_values['pass'] = t('Password');
1074 $request_new = l(t('Request new password'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.'))));
1075 $current_pass_description = t('Enter your current password to change the %mail or %pass. !request_new.', array('%mail' => $protected_values['mail'], '%pass' => $protected_values['pass'], '!request_new' => $request_new));
1076 }
1077 // The user must enter their current password to change to a new one.
1078 if ($user->uid == $account->uid) {
1079 $form['account']['current_pass_required_values'] = array(
1080 '#type' => 'value',
1081 '#value' => $protected_values,
1082 );
1083 $form['account']['current_pass'] = array(
1084 '#type' => 'password',
1085 '#title' => t('Current password'),
1086 '#size' => 25,
1087 '#access' => !empty($protected_values),
1088 '#description' => $current_pass_description,
1089 '#weight' => -5,
1090 // Do not let web browsers remember this password, since we are trying
1091 // to confirm that the person submitting the form actually knows the
1092 // current one.
1093 '#attributes' => array('autocomplete' => 'off'),
1094 );
1095 $form['#validate'][] = 'user_validate_current_pass';
1096 }
1097 }
1098 elseif (!variable_get('user_email_verification', TRUE) || $admin) {
1099 $form['account']['pass'] = array(
1100 '#type' => 'password_confirm',
1101 '#size' => 25,
1102 '#description' => t('Provide a password for the new account in both fields.'),
1103 '#required' => TRUE,
1104 );
1105 }
1106
1107 if ($admin) {
1108 $status = isset($account->status) ? $account->status : 1;
1109 }
1110 else {
1111 $status = $register ? variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) == USER_REGISTER_VISITORS : $account->status;
1112 }
1113 $form['account']['status'] = array(
1114 '#type' => 'radios',
1115 '#title' => t('Status'),
1116 '#default_value' => $status,
1117 '#options' => array(t('Blocked'), t('Active')),
1118 '#access' => $admin,
1119 );
1120
1121 $roles = array_map('check_plain', user_roles(TRUE));
1122 // The disabled checkbox subelement for the 'authenticated user' role
1123 // must be generated separately and added to the checkboxes element,
1124 // because of a limitation in Form API not supporting a single disabled
1125 // checkbox within a set of checkboxes.
1126 // @todo This should be solved more elegantly. See issue #119038.
1127 $checkbox_authenticated = array(
1128 '#type' => 'checkbox',
1129 '#title' => $roles[DRUPAL_AUTHENTICATED_RID],
1130 '#default_value' => TRUE,
1131 '#disabled' => TRUE,
1132 );
1133 unset($roles[DRUPAL_AUTHENTICATED_RID]);
1134 $form['account']['roles'] = array(
1135 '#type' => 'checkboxes',
1136 '#title' => t('Roles'),
1137 '#default_value' => (!$register && isset($account->roles) ? array_keys($account->roles) : array()),
1138 '#options' => $roles,
1139 '#access' => $roles && user_access('administer permissions'),
1140 DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated,
1141 );
1142
1143 $form['account']['notify'] = array(
1144 '#type' => 'checkbox',
1145 '#title' => t('Notify user of new account'),
1146 '#access' => $register && $admin,
1147 );
1148
1149 // Signature.
1150 $form['signature_settings'] = array(
1151 '#type' => 'fieldset',
1152 '#title' => t('Signature settings'),
1153 '#weight' => 1,
1154 '#access' => (!$register && variable_get('user_signatures', 0)),
1155 );
1156
1157 $form['signature_settings']['signature'] = array(
1158 '#type' => 'text_format',
1159 '#title' => t('Signature'),
1160 '#default_value' => isset($account->signature) ? $account->signature : '',
1161 '#description' => t('Your signature will be publicly displayed at the end of your comments.'),
1162 '#format' => isset($account->signature_format) ? $account->signature_format : NULL,
1163 );
1164
1165 // Picture/avatar.
1166 $form['picture'] = array(
1167 '#type' => 'fieldset',
1168 '#title' => t('Picture'),
1169 '#weight' => 1,
1170 '#access' => (!$register && variable_get('user_pictures', 0)),
1171 );
1172 $form['picture']['picture'] = array(
1173 '#type' => 'value',
1174 '#value' => isset($account->picture) ? $account->picture : NULL,
1175 );
1176 $form['picture']['picture_current'] = array(
1177 '#markup' => theme('user_picture', array('account' => $account)),
1178 );
1179 $form['picture']['picture_delete'] = array(
1180 '#type' => 'checkbox',
1181 '#title' => t('Delete picture'),
1182 '#access' => !empty($account->picture->fid),
1183 '#description' => t('Check this box to delete your current picture.'),
1184 );
1185 $form['picture']['picture_upload'] = array(
1186 '#type' => 'file',
1187 '#title' => t('Upload picture'),
1188 '#size' => 48,
1189 '#description' => t('Your virtual face or picture. Pictures larger than @dimensions pixels will be scaled down.', array('@dimensions' => variable_get('user_picture_dimensions', '85x85'))) . ' ' . filter_xss_admin(variable_get('user_picture_guidelines', '')),
1190 );
1191 $form['#validate'][] = 'user_validate_picture';
1192 }
1193
1199 function user_validate_current_pass(&$form, &$form_state) {
1200 $account = $form['#user'];
1201 foreach ($form_state['values']['current_pass_required_values'] as $key => $name) {
1202 // This validation only works for required textfields (like mail) or
1203 // form values like password_confirm that have their own validation
1204 // that prevent them from being empty if they are changed.
1205 if ((strlen(trim($form_state['values'][$key])) > 0) && ($form_state['values'][$key] != $account->$key)) {
1206 require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
1207 $current_pass_failed = empty($form_state['values']['current_pass']) || !user_check_password($form_state['values']['current_pass'], $account);
1208 if ($current_pass_failed) {
1209 form_set_error('current_pass', t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => $name)));
1210 form_set_error($key);
1211 }
1212 // We only need to check the password once.
1213 break;
1214 }
1215 }
1216 }
1217
1223 function user_account_form_validate($form, &$form_state) {
1224 if ($form['#user_category'] == 'account' || $form['#user_category'] == 'register') {
1225 $account = $form['#user'];
1226 // Validate new or changing username.
1227 if (isset($form_state['values']['name'])) {
1228 if ($error = user_validate_name($form_state['values']['name'])) {
1229 form_set_error('name', $error);
1230 }
1231 elseif ((bool) db_select('users')->fields('users', array('uid'))->condition('uid', $account->uid, '<>')->condition('name', db_like($form_state['values']['name']), 'LIKE')->range(0, 1)->execute()->fetchField()) {
1232 form_set_error('name', t('The name %name is already taken.', array('%name' => $form_state['values']['name'])));
1233 }
1234 }
1235
1236 // Trim whitespace from mail, to prevent confusing 'e-mail not valid'
1237 // warnings often caused by cutting and pasting.
1238 $mail = trim($form_state['values']['mail']);
1239 form_set_value($form['account']['mail'], $mail, $form_state);
1240
1241 // Validate the e-mail address, and check if it is taken by an existing user.
1242 if ($error = user_validate_mail($form_state['values']['mail'])) {
1243 form_set_error('mail', $error);
1244 }
1245 elseif ((bool) db_select('users')->fields('users', array('uid'))->condition('uid', $account->uid, '<>')->condition('mail', db_like($form_state['values']['mail']), 'LIKE')->range(0, 1)->execute()->fetchField()) {
1246 // Format error message dependent on whether the user is logged in or not.
1247 if ($GLOBALS['user']->uid) {
1248 form_set_error('mail', t('The e-mail address %email is already taken.', array('%email' => $form_state['values']['mail'])));
1249 }
1250 else {
1251 form_set_error('mail', t('The e-mail address %email is already registered. <a href="@password">Have you forgotten your password?</a>', array('%email' => $form_state['values']['mail'], '@password' => url('user/password'))));
1252 }
1253 }
1254
1255 // Make sure the signature isn't longer than the size of the database field.
1256 // Signatures are disabled by default, so make sure it exists first.
1257 if (isset($form_state['values']['signature'])) {
1258 // Move text format for user signature into 'signature_format'.
1259 $form_state['values']['signature_format'] = $form_state['values']['signature']['format'];
1260 // Move text value for user signature into 'signature'.
1261 $form_state['values']['signature'] = $form_state['values']['signature']['value'];
1262
1263 $user_schema = drupal_get_schema('users');
1264 if (drupal_strlen($form_state['values']['signature']) > $user_schema['fields']['signature']['length']) {
1265 form_set_error('signature', t('The signature is too long: it must be %max characters or less.', array('%max' => $user_schema['fields']['signature']['length'])));
1266 }
1267 }
1268 }
1269 }
1270
1274 function user_user_presave(&$edit, $account, $category) {
1275 if ($category == 'account' || $category == 'register') {
1276 if (!empty($edit['picture_upload'])) {
1277 $edit['picture'] = $edit['picture_upload'];
1278 }
1279 // Delete picture if requested, and if no replacement picture was given.
1280 elseif (!empty($edit['picture_delete'])) {
1281 $edit['picture'] = NULL;
1282 }
1283 // Prepare user roles.
1284 if (isset($edit['roles'])) {
1285 $edit['roles'] = array_filter($edit['roles']);
1286 }
1287 }
1288
1289 // Move account cancellation information into $user->data.
1290 foreach (array('user_cancel_method', 'user_cancel_notify') as $key) {
1291 if (isset($edit[$key])) {
1292 $edit['data'][$key] = $edit[$key];
1293 }
1294 }
1295 }
1296
1300 function user_user_categories() {
1301 return array(array(
1302 'name' => 'account',
1303 'title' => t('Account settings'),
1304 'weight' => 1,
1305 ));
1306 }
1307
1308 function user_login_block($form) {
1309 $form['#action'] = url(current_path(), array('query' => drupal_get_destination(), 'external' => FALSE));
1310 $form['#id'] = 'user-login-form';
1311 $form['#validate'] = user_login_default_validators();
1312 $form['#submit'][] = 'user_login_submit';
1313 $form['name'] = array('#type' => 'textfield',
1314 '#title' => t('Username'),
1315 '#maxlength' => USERNAME_MAX_LENGTH,
1316 '#size' => 15,
1317 '#required' => TRUE,
1318 );
1319 $form['pass'] = array('#type' => 'password',
1320 '#title' => t('Password'),
1321 '#size' => 15,
1322 '#required' => TRUE,
1323 );
1324 $form['actions'] = array('#type' => 'actions');
1325 $form['actions']['submit'] = array('#type' => 'submit',
1326 '#value' => t('Log in'),
1327 );
1328 $items = array();
1329 if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
1330 $items[] = l(t('Create new account'), 'user/register', array('attributes' => array('title' => t('Create a new user account.'))));
1331 }
1332 $items[] = l(t('Request new password'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.'))));
1333 $form['links'] = array('#markup' => theme('item_list', array('items' => $items)));
1334 return $form;
1335 }
1336
1340 function user_block_info() {
1341 global $user;
1342
1343 $blocks['login']['info'] = t('User login');
1344 // Not worth caching.
1345 $blocks['login']['cache'] = DRUPAL_NO_CACHE;
1346
1347 $blocks['new']['info'] = t('Who\'s new');
1348 $blocks['new']['properties']['administrative'] = TRUE;
1349
1350 // Too dynamic to cache.
1351 $blocks['online']['info'] = t('Who\'s online');
1352 $blocks['online']['cache'] = DRUPAL_NO_CACHE;
1353 $blocks['online']['properties']['administrative'] = TRUE;
1354
1355 return $blocks;
1356 }
1357
1361 function user_block_configure($delta = '') {
1362 global $user;
1363
1364 switch ($delta) {
1365 case 'new':
1366 $form['user_block_whois_new_count'] = array(
1367 '#type' => 'select',
1368 '#title' => t('Number of users to display'),
1369 '#default_value' => variable_get('user_block_whois_new_count', 5),
1370 '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
1371 );
1372 return $form;
1373
1374 case 'online':
1375 $period = drupal_map_assoc(array(30, 60, 120, 180, 300, 600, 900, 1800, 2700, 3600, 5400, 7200, 10800, 21600, 43200, 86400), 'format_interval');
1376 $form['user_block_seconds_online'] = array('#type' => 'select', '#title' => t('User activity'), '#default_value' => variable_get('user_block_seconds_online', 900), '#options' => $period, '#description' => t('A user is considered online for this long after they have last viewed a page.'));
1377 $form['user_block_max_list_count'] = array('#type' => 'select', '#title' => t('User list length'), '#default_value' => variable_get('user_block_max_list_count', 10), '#options' => drupal_map_assoc(array(0, 5, 10, 15, 20, 25, 30, 40, 50, 75, 100)), '#description' => t('Maximum number of currently online users to display.'));
1378 return $form;
1379 }
1380 }
1381
1385 function user_block_save($delta = '', $edit = array()) {
1386 global $user;
1387
1388 switch ($delta) {
1389 case 'new':
1390 variable_set('user_block_whois_new_count', $edit['user_block_whois_new_count']);
1391 break;
1392
1393 case 'online':
1394 variable_set('user_block_seconds_online', $edit['user_block_seconds_online']);
1395 variable_set('user_block_max_list_count', $edit['user_block_max_list_count']);
1396 break;
1397 }
1398 }
1399
1403 function user_block_view($delta = '') {
1404 global $user;
1405
1406 $block = array();
1407
1408 switch ($delta) {
1409 case 'login':
1410 // For usability's sake, avoid showing two login forms on one page.
1411 if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) {
1412
1413 $block['subject'] = t('User login');
1414 $block['content'] = drupal_get_form('user_login_block');
1415 }
1416 return $block;
1417
1418 case 'new':
1419 if (user_access('access content')) {
1420 // Retrieve a list of new users who have subsequently accessed the site successfully.
1421 $items = db_query_range('SELECT uid, name FROM {users} WHERE status <> 0 AND access <> 0 ORDER BY created DESC', 0, variable_get('user_block_whois_new_count', 5))->fetchAll();
1422 $output = theme('user_list', array('users' => $items));
1423
1424 $block['subject'] = t('Who\'s new');
1425 $block['content'] = $output;
1426 }
1427 return $block;
1428
1429 case 'online':
1430 if (user_access('access content')) {
1431 // Count users active within the defined period.
1432 $interval = REQUEST_TIME - variable_get('user_block_seconds_online', 900);
1433
1434 // Perform database queries to gather online user lists. We use s.timestamp
1435 // rather than u.access because it is much faster.
1436 $authenticated_count = db_query("SELECT COUNT(DISTINCT s.uid) FROM {sessions} s WHERE s.timestamp >= :timestamp AND s.uid > 0", array(':timestamp' => $interval))->fetchField();
1437
1438 $output = '<p>' . format_plural($authenticated_count, 'There is currently 1 user online.', 'There are currently @count users online.') . '</p>';
1439
1440 // Display a list of currently online users.
1441 $max_users = variable_get('user_block_max_list_count', 10);
1442 if ($authenticated_count && $max_users) {
1443 $items = db_query_range('SELECT u.uid, u.name, MAX(s.timestamp) AS max_timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= :interval AND s.uid > 0 GROUP BY u.uid, u.name ORDER BY max_timestamp DESC', 0, $max_users, array(':interval' => $interval))->fetchAll();
1444 $output .= theme('user_list', array('users' => $items));
1445 }
1446
1447 $block['subject'] = t('Who\'s online');
1448 $block['content'] = $output;
1449 }
1450 return $block;
1451 }
1452 }
1453
1463 function template_preprocess_user_picture(&$variables) {
1464 $variables['user_picture'] = '';
1465 if (variable_get('user_pictures', 0)) {
1466 $account = $variables['account'];
1467 if (!empty($account->picture)) {
1468 // @TODO: Ideally this function would only be passed file objects, but
1469 // since there's a lot of legacy code that JOINs the {users} table to
1470 // {node} or {comments} and passes the results into this function if we
1471 // a numeric value in the picture field we'll assume it's a file id
1472 // and load it for them. Once we've got user_load_multiple() and
1473 // comment_load_multiple() functions the user module will be able to load
1474 // the picture files in mass during the object's load process.
1475 if (is_numeric($account->picture)) {
1476 $account->picture = file_load($account->picture);
1477 }
1478 if (!empty($account->picture->uri)) {
1479 $filepath = $account->picture->uri;
1480 }
1481 }
1482 elseif (variable_get('user_picture_default', '')) {
1483 $filepath = variable_get('user_picture_default', '');
1484 }
1485 if (isset($filepath)) {
1486 $alt = t("@user's picture", array('@user' => format_username($account)));
1487 // If the image does not have a valid Drupal scheme (for eg. HTTP),
1488 // don't load image styles.
1489 if (module_exists('image') && file_valid_uri($filepath) && $style = variable_get('user_picture_style', '')) {
1490 $variables['user_picture'] = theme('image_style', array('style_name' => $style, 'path' => $filepath, 'alt' => $alt, 'title' => $alt));
1491 }
1492 else {
1493 $variables['user_picture'] = theme('image', array('path' => $filepath, 'alt' => $alt, 'title' => $alt));
1494 }
1495 if (!empty($account->uid) && user_access('access user profiles')) {
1496 $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);
1497 $variables['user_picture'] = l($variables['user_picture'], "user/$account->uid", $attributes);
1498 }
1499 }
1500 }
1501 }
1502
1514 function theme_user_list($variables) {
1515 $users = $variables['users'];
1516 $title = $variables['title'];
1517 $items = array();
1518
1519 if (!empty($users)) {
1520 foreach ($users as $user) {
1521 $items[] = theme('username', array('account' => $user));
1522 }
1523 }
1524 return theme('item_list', array('items' => $items, 'title' => $title));
1525 }
1526
1533 function user_is_anonymous() {
1534 // Menu administrators can see items for anonymous when administering.
1535 return !$GLOBALS['user']->uid || !empty($GLOBALS['menu_admin']);
1536 }
1537
1544 function user_is_logged_in() {
1545 return (bool) $GLOBALS['user']->uid;
1546 }
1547
1554 function user_register_access() {
1555 return user_is_anonymous() && variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
1556 }
1557
1564 function user_view_access($account) {
1565 $uid = is_object($account) ? $account->uid : (int) $account;
1566
1567 // Never allow access to view the anonymous user account.
1568 if ($uid) {
1569 // Admins can view all, users can view own profiles at all times.
1570 if ($GLOBALS['user']->uid == $uid || user_access('administer users')) {
1571 return TRUE;
1572 }
1573 elseif (user_access('access user profiles')) {
1574 // At this point, load the complete account object.
1575 if (!is_object($account)) {
1576 $account = user_load($uid);
1577 }
1578 return (is_object($account) && $account->status);
1579 }
1580 }
1581 return FALSE;
1582 }
1583
1587 function user_edit_access($account) {
1588 return (($GLOBALS['user']->uid == $account->uid) || user_access('administer users')) && $account->uid > 0;
1589 }
1590
1597 function user_cancel_access($account) {
1598 return ((($GLOBALS['user']->uid == $account->uid) && user_access('cancel account')) || user_access('administer users')) && $account->uid > 0;
1599 }
1600
1604 function user_menu() {
1605 $items['user/autocomplete'] = array(
1606 'title' => 'User autocomplete',
1607 'page callback' => 'user_autocomplete',
1608 'access callback' => 'user_access',
1609 'access arguments' => array('access user profiles'),
1610 'type' => MENU_CALLBACK,
1611 'file' => 'user.pages.inc',
1612 );
1613
1614 // Registration and login pages.
1615 $items['user'] = array(
1616 'title' => 'User account',
1617 'title callback' => 'user_menu_title',
1618 'page callback' => 'user_page',
1619 'access callback' => TRUE,
1620 'file' => 'user.pages.inc',
1621 'weight' => -10,
1622 'menu_name' => 'user-menu',
1623 );
1624
1625 $items['user/login'] = array(
1626 'title' => 'Log in',
1627 'access callback' => 'user_is_anonymous',
1628 'type' => MENU_DEFAULT_LOCAL_TASK,
1629 );
1630
1631 $items['user/register'] = array(
1632 'title' => 'Create new account',
1633 'page callback' => 'drupal_get_form',
1634 'page arguments' => array('user_register_form'),
1635 'access callback' => 'user_register_access',
1636 'type' => MENU_LOCAL_TASK,
1637 );
1638
1639 $items['user/password'] = array(
1640 'title' => 'Request new password',
1641 'page callback' => 'drupal_get_form',
1642 'page arguments' => array('user_pass'),
1643 'access callback' => TRUE,
1644 'type' => MENU_LOCAL_TASK,
1645 'file' => 'user.pages.inc',
1646 );
1647 $items['user/reset/%/%/%'] = array(
1648 'title' => 'Reset password',
1649 'page callback' => 'drupal_get_form',
1650 'page arguments' => array('user_pass_reset', 2, 3, 4),
1651 'access callback' => TRUE,
1652 'type' => MENU_CALLBACK,
1653 'file' => 'user.pages.inc',
1654 );
1655
1656 $items['user/logout'] = array(
1657 'title' => 'Log out',
1658 'access callback' => 'user_is_logged_in',
1659 'page callback' => 'user_logout',
1660 'weight' => 10,
1661 'menu_name' => 'user-menu',
1662 'file' => 'user.pages.inc',
1663 );
1664
1665 // User listing pages.
1666 $items['admin/people'] = array(
1667 'title' => 'People',
1668 'description' => 'Manage user accounts, roles, and permissions.',
1669 'page callback' => 'user_admin',
1670 'page arguments' => array('list'),
1671 'access arguments' => array('administer users'),
1672 'position' => 'left',
1673 'weight' => -4,
1674 'file' => 'user.admin.inc',
1675 );
1676 $items['admin/people/people'] = array(
1677 'title' => 'List',
1678 'description' => 'Find and manage people interacting with your site.',
1679 'access arguments' => array('administer users'),
1680 'type' => MENU_DEFAULT_LOCAL_TASK,
1681 'weight' => -10,
1682 'file' => 'user.admin.inc',
1683 );
1684
1685 // Permissions and role forms.
1686 $items['admin/people/permissions'] = array(
1687 'title' => 'Permissions',
1688 'description' => 'Determine access to features by selecting permissions for roles.',
1689 'page callback' => 'drupal_get_form',
1690 'page arguments' => array('user_admin_permissions'),
1691 'access arguments' => array('administer permissions'),
1692 'file' => 'user.admin.inc',
1693 'type' => MENU_LOCAL_TASK,
1694 );
1695 $items['admin/people/permissions/list'] = array(
1696 'title' => 'Permissions',
1697 'description' => 'Determine access to features by selecting permissions for roles.',
1698 'type' => MENU_DEFAULT_LOCAL_TASK,
1699 'weight' => -8,
1700 );
1701 $items['admin/people/permissions/roles'] = array(
1702 'title' => 'Roles',
1703 'description' => 'List, edit, or add user roles.',
1704 'page callback' => 'drupal_get_form',
1705 'page arguments' => array('user_admin_roles'),
1706 'access arguments' => array('administer permissions'),
1707 'file' => 'user.admin.inc',
1708 'type' => MENU_LOCAL_TASK,
1709 'weight' => -5,
1710 );
1711 $items['admin/people/permissions/roles/edit/%user_role'] = array(
1712 'title' => 'Edit role',
1713 'page arguments' => array('user_admin_role', 5),
1714 'access callback' => 'user_role_edit_access',
1715 'access arguments' => array(5),
1716 );
1717 $items['admin/people/permissions/roles/delete/%user_role'] = array(
1718 'title' => 'Delete role',
1719 'page callback' => 'drupal_get_form',
1720 'page arguments' => array('user_admin_role_delete_confirm', 5),
1721 'access callback' => 'user_role_edit_access',
1722 'access arguments' => array(5),
1723 'file' => 'user.admin.inc',
1724 );
1725
1726 $items['admin/people/create'] = array(
1727 'title' => 'Add user',
1728 'page arguments' => array('create'),
1729 'access arguments' => array('administer users'),
1730 'type' => MENU_LOCAL_ACTION,
1731 );
1732
1733 // Administration pages.
1734 $items['admin/config/people'] = array(
1735 'title' => 'People',
1736 'description' => 'Configure user accounts.',
1737 'position' => 'left',
1738 'weight' => -20,
1739 'page callback' => 'system_admin_menu_block_page',
1740 'access arguments' => array('access administration pages'),
1741 'file' => 'system.admin.inc',
1742 'file path' => drupal_get_path('module', 'system'),
1743 );
1744 $items['admin/config/people/accounts'] = array(
1745 'title' => 'Account settings',
1746 'description' => 'Configure default behavior of users, including registration requirements, e-mails, fields, and user pictures.',
1747 'page callback' => 'drupal_get_form',
1748 'page arguments' => array('user_admin_settings'),
1749 'access arguments' => array('administer users'),
1750 'file' => 'user.admin.inc',
1751 'weight' => -10,
1752 );
1753 $items['admin/config/people/accounts/settings'] = array(
1754 'title' => 'Settings',
1755 'type' => MENU_DEFAULT_LOCAL_TASK,
1756 'weight' => -10,
1757 );
1758
1759 $items['user/%user'] = array(
1760 'title' => 'My account',
1761 'title callback' => 'user_page_title',
1762 'title arguments' => array(1),
1763 'page callback' => 'user_view_page',
1764 'page arguments' => array(1),
1765 'access callback' => 'user_view_access',
1766 'access arguments' => array(1),
1767 // By assigning a different menu name, this item (and all registered child
1768 // paths) are no longer considered as children of 'user'. When accessing the
1769 // user account pages, the preferred menu link that is used to build the
1770 // active trail (breadcrumb) will be found in this menu (unless there is
1771 // more specific link), so the link to 'user' will not be in the breadcrumb.
1772 'menu_name' => 'navigation',
1773 );
1774
1775 $items['user/%user/view'] = array(
1776 'title' => 'View',
1777 'type' => MENU_DEFAULT_LOCAL_TASK,
1778 'weight' => -10,
1779 );
1780
1781 $items['user/%user/cancel'] = array(
1782 'title' => 'Cancel account',
1783 'page callback' => 'drupal_get_form',
1784 'page arguments' => array('user_cancel_confirm_form', 1),
1785 'access callback' => 'user_cancel_access',
1786 'access arguments' => array(1),
1787 'file' => 'user.pages.inc',
1788 );
1789
1790 $items['user/%user/cancel/confirm/%/%'] = array(
1791 'title' => 'Confirm account cancellation',
1792 'page callback' => 'user_cancel_confirm',
1793 'page arguments' => array(1, 4, 5),
1794 'access callback' => 'user_cancel_access',
1795 'access arguments' => array(1),
1796 'file' => 'user.pages.inc',
1797 );
1798
1799 $items['user/%user/edit'] = array(
1800 'title' => 'Edit',
1801 'page callback' => 'drupal_get_form',
1802 'page arguments' => array('user_profile_form', 1),
1803 'access callback' => 'user_edit_access',
1804 'access arguments' => array(1),
1805 'type' => MENU_LOCAL_TASK,
1806 'file' => 'user.pages.inc',
1807 );
1808
1809 $items['user/%user_category/edit/account'] = array(
1810 'title' => 'Account',
1811 'type' => MENU_DEFAULT_LOCAL_TASK,
1812 'load arguments' => array('%map', '%index'),
1813 );
1814
1815 if (($categories = _user_categories()) && (count($categories) > 1)) {
1816 foreach ($categories as $key => $category) {
1817 // 'account' is already handled by the MENU_DEFAULT_LOCAL_TASK.
1818 if ($category['name'] != 'account') {
1819 $items['user/%user_category/edit/' . $category['name']] = array(
1820 'title callback' => 'check_plain',
1821 'title arguments' => array($category['title']),
1822 'page callback' => 'drupal_get_form',
1823 'page arguments' => array('user_profile_form', 1, 3),
1824 'access callback' => isset($category['access callback']) ? $category['access callback'] : 'user_edit_access',
1825 'access arguments' => isset($category['access arguments']) ? $category['access arguments'] : array(1),
1826 'type' => MENU_LOCAL_TASK,
1827 'weight' => $category['weight'],
1828 'load arguments' => array('%map', '%index'),
1829 'tab_parent' => 'user/%/edit',
1830 'file' => 'user.pages.inc',
1831 );
1832 }
1833 }
1834 }
1835 return $items;
1836 }
1837
1841 function user_menu_site_status_alter(&$menu_site_status, $path) {
1842 if ($menu_site_status == MENU_SITE_OFFLINE) {
1843 // If the site is offline, log out unprivileged users.
1844 if (user_is_logged_in() && !user_access('access site in maintenance mode')) {
1845 module_load_include('pages.inc', 'user', 'user');
1846 user_logout();
1847 }
1848
1849 if (user_is_anonymous()) {
1850 switch ($path) {
1851 case 'user':
1852 // Forward anonymous user to login page.
1853 drupal_goto('user/login');
1854 case 'user/login':
1855 case 'user/password':
1856 // Disable offline mode.
1857 $menu_site_status = MENU_SITE_ONLINE;
1858 break;
1859 default:
1860 if (strpos($path, 'user/reset/') === 0) {
1861 // Disable offline mode.
1862 $menu_site_status = MENU_SITE_ONLINE;
1863 }
1864 break;
1865 }
1866 }
1867 }
1868 if (user_is_logged_in()) {
1869 if ($path == 'user/login') {
1870 // If user is logged in, redirect to 'user' instead of giving 403.
1871 drupal_goto('user');
1872 }
1873 if ($path == 'user/register') {
1874 // Authenticated user should be redirected to user edit page.
1875 drupal_goto('user/' . $GLOBALS['user']->uid . '/edit');
1876 }
1877 }
1878 }
1879
1883 function user_menu_link_alter(&$link) {
1884 // The path 'user' must be accessible for anonymous users, but only visible
1885 // for authenticated users. Authenticated users should see "My account", but
1886 // anonymous users should not see it at all. Therefore, invoke
1887 // user_translated_menu_link_alter() to conditionally hide the link.
1888 if ($link['link_path'] == 'user' && $link['module'] == 'system') {
1889 $link['options']['alter'] = TRUE;
1890 }
1891
1892 // Force the Logout link to appear on the top-level of 'user-menu' menu by
1893 // default (i.e., unless it has been customized).
1894 if ($link['link_path'] == 'user/logout' && $link['module'] == 'system' && empty($link['customized'])) {
1895 $link['plid'] = 0;
1896 }
1897 }
1898
1902 function user_translated_menu_link_alter(&$link) {
1903 // Hide the "User account" link for anonymous users.
1904 if ($link['link_path'] == 'user' && $link['module'] == 'system' && !$GLOBALS['user']->uid) {
1905 $link['hidden'] = 1;
1906 }
1907 }
1908
1912 function user_admin_paths() {
1913 $paths = array(
1914 'user/*/cancel' => TRUE,
1915 'user/*/edit' => TRUE,
1916 'user/*/edit/*' => TRUE,
1917 );
1918 return $paths;
1919 }
1920
1928 function user_uid_only_optional_to_arg($arg) {
1929 return user_uid_optional_to_arg($arg);
1930 }
1931
1945 function user_uid_optional_load($uid = NULL) {
1946 if (!isset($uid)) {
1947 $uid = $GLOBALS['user']->uid;
1948 }
1949 return user_load($uid);
1950 }
1951
1955 function user_category_load($uid, &$map, $index) {
1956 static $user_categories, $accounts;
1957
1958 // Cache $account - this load function will get called for each profile tab.
1959 if (!isset($accounts[$uid])) {
1960 $accounts[$uid] = user_load($uid);
1961 }
1962 $valid = TRUE;
1963 if ($account = $accounts[$uid]) {
1964 // Since the path is like user/%/edit/category_name, the category name will
1965 // be at a position 2 beyond the index corresponding to the % wildcard.
1966 $category_index = $index + 2;
1967 // Valid categories may contain slashes, and hence need to be imploded.
1968 $category_path = implode('/', array_slice($map, $category_index));
1969 if ($category_path) {
1970 // Check that the requested category exists.
1971 $valid = FALSE;
1972 if (!isset($user_categories)) {
1973 $user_categories = _user_categories();
1974 }
1975 foreach ($user_categories as $category) {
1976 if ($category['name'] == $category_path) {
1977 $valid = TRUE;
1978 // Truncate the map array in case the category name had slashes.
1979 $map = array_slice($map, 0, $category_index);
1980 // Assign the imploded category name to the last map element.
1981 $map[$category_index] = $category_path;
1982 break;
1983 }
1984 }
1985 }
1986 }
1987 return $valid ? $account : FALSE;
1988 }
1989
1995 function user_uid_optional_to_arg($arg) {
1996 // Give back the current user uid when called from eg. tracker, aka.
1997 // with an empty arg. Also use the current user uid when called from
1998 // the menu with a % for the current account link.
1999 return empty($arg) || $arg == '%' ? $GLOBALS['user']->uid : $arg;
2000 }
2001
2008 function user_menu_title() {
2009 return user_is_logged_in() ? t('My account') : t('User account');
2010 }
2011
2015 function user_page_title($account) {
2016 return is_object($account) ? format_username($account) : '';
2017 }
2018
2027 function user_get_authmaps($authname = NULL) {
2028 $authmaps = db_query("SELECT module, authname FROM {authmap} WHERE authname = :authname", array(':authname' => $authname))->fetchAllKeyed();
2029 return count($authmaps) ? $authmaps : 0;
2030 }
2031
2044 function user_set_authmaps($account, $authmaps) {
2045 foreach ($authmaps as $key => $value) {
2046 $module = explode('_', $key, 2);
2047 if ($value) {
2048 db_merge('authmap')
2049 ->key(array(
2050 'uid' => $account->uid,
2051 'module' => $module[1],
2052 ))
2053 ->fields(array('authname' => $value))
2054 ->execute();
2055 }
2056 else {
2057 db_delete('authmap')
2058 ->condition('uid', $account->uid)
2059 ->condition('module', $module[1])
2060 ->execute();
2061 }
2062 }
2063 }
2064
2070 function user_login($form, &$form_state) {
2071 global $user;
2072
2073 // If we are already logged on, go to the user page instead.
2074 if ($user->uid) {
2075 drupal_goto('user/' . $user->uid);
2076 }
2077
2078 // Display login form:
2079 $form['name'] = array('#type' => 'textfield',
2080 '#title' => t('Username'),
2081 '#size' => 60,
2082 '#maxlength' => USERNAME_MAX_LENGTH,
2083 '#required' => TRUE,
2084 );
2085
2086 $form['name']['#description'] = t('Enter your @s username.', array('@s' => variable_get('site_name', 'Drupal')));
2087 $form['pass'] = array('#type' => 'password',
2088 '#title' => t('Password'),
2089 '#description' => t('Enter the password that accompanies your username.'),
2090 '#required' => TRUE,
2091 );
2092 $form['#validate'] = user_login_default_validators();
2093 $form['actions'] = array('#type' => 'actions');
2094 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Log in'));
2095
2096 return $form;
2097 }
2098
2117 function user_login_default_validators() {
2118 return array('user_login_name_validate', 'user_login_authenticate_validate', 'user_login_final_validate');
2119 }
2120
2124 function user_login_name_validate($form, &$form_state) {
2125 if (!empty($form_state['values']['name']) && user_is_blocked($form_state['values']['name'])) {
2126 // Blocked in user administration.
2127 form_set_error('name', t('The username %name has not been activated or is blocked.', array('%name' => $form_state['values']['name'])));
2128 }
2129 }
2130
2136 function user_login_authenticate_validate($form, &$form_state) {
2137 $password = trim($form_state['values']['pass']);
2138 if (!empty($form_state['values']['name']) && !empty($password)) {
2139 // Do not allow any login from the current user's IP if the limit has been
2140 // reached. Default is 50 failed attempts allowed in one hour. This is
2141 // independent of the per-user limit to catch attempts from one IP to log
2142 // in to many different user accounts. We have a reasonably high limit
2143 // since there may be only one apparent IP for all users at an institution.
2144 if (!flood_is_allowed('failed_login_attempt_ip', variable_get('user_failed_login_ip_limit', 50), variable_get('user_failed_login_ip_window', 3600))) {
2145 $form_state['flood_control_triggered'] = 'ip';
2146 return;
2147 }
2148 $account = db_query("SELECT * FROM {users} WHERE name = :name AND status = 1", array(':name' => $form_state['values']['name']))->fetchObject();
2149 if ($account) {
2150 if (variable_get('user_failed_login_identifier_uid_only', FALSE)) {
2151 // Register flood events based on the uid only, so they apply for any
2152 // IP address. This is the most secure option.
2153 $identifier = $account->uid;
2154 }
2155 else {
2156 // The default identifier is a combination of uid and IP address. This
2157 // is less secure but more resistant to denial-of-service attacks that
2158 // could lock out all users with public user names.
2159 $identifier = $account->uid . '-' . ip_address();
2160 }
2161 $form_state['flood_control_user_identifier'] = $identifier;
2162
2163 // Don't allow login if the limit for this user has been reached.
2164 // Default is to allow 5 failed attempts every 6 hours.
2165 if (!flood_is_allowed('failed_login_attempt_user', variable_get('user_failed_login_user_limit', 5), variable_get('user_failed_login_user_window', 21600), $identifier)) {
2166 $form_state['flood_control_triggered'] = 'user';
2167 return;
2168 }
2169 }
2170 // We are not limited by flood control, so try to authenticate.
2171 // Set $form_state['uid'] as a flag for user_login_final_validate().
2172 $form_state['uid'] = user_authenticate($form_state['values']['name'], $password);
2173 }
2174 }
2175
2183 function user_login_final_validate($form, &$form_state) {
2184 if (empty($form_state['uid'])) {
2185 // Always register an IP-based failed login event.
2186 flood_register_event('failed_login_attempt_ip', variable_get('user_failed_login_ip_window', 3600));
2187 // Register a per-user failed login event.
2188 if (isset($form_state['flood_control_user_identifier'])) {
2189 flood_register_event('failed_login_attempt_user', variable_get('user_failed_login_user_window', 21600), $form_state['flood_control_user_identifier']);
2190 }
2191
2192 if (isset($form_state['flood_control_triggered'])) {
2193 if ($form_state['flood_control_triggered'] == 'user') {
2194 form_set_error('name', format_plural(variable_get('user_failed_login_user_limit', 5), 'Sorry, there has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or <a href="@url">request a new password</a>.', 'Sorry, there have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or <a href="@url">request a new password</a>.', array('@url' => url('user/password'))));
2195 }
2196 else {
2197 // We did not find a uid, so the limit is IP-based.
2198 form_set_error('name', t('Sorry, too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or <a href="@url">request a new password</a>.', array('@url' => url('user/password'))));
2199 }
2200 }
2201 else {
2202 form_set_error('name', t('Sorry, unrecognized username or password. <a href="@password">Have you forgotten your password?</a>', array('@password' => url('user/password', array('query' => array('name' => $form_state['values']['name']))))));
2203 watchdog('user', 'Login attempt failed for %user.', array('%user' => $form_state['values']['name']));
2204 }
2205 }
2206 elseif (isset($form_state['flood_control_user_identifier'])) {
2207 // Clear past failures for this user so as not to block a user who might
2208 // log in and out more than once in an hour.
2209 flood_clear_event('failed_login_attempt_user', $form_state['flood_control_user_identifier']);
2210 }
2211 }
2212
2223 function user_authenticate($name, $password) {
2224 $uid = FALSE;
2225 if (!empty($name) && !empty($password)) {
2226 $account = user_load_by_name($name);
2227 if ($account) {
2228 // Allow alternate password hashing schemes.
2229 require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
2230 if (user_check_password($password, $account)) {
2231 // Successful authentication.
2232 $uid = $account->uid;
2233
2234 // Update user to new password scheme if needed.
2235 if (user_needs_new_hash($account)) {
2236 user_save($account, array('pass' => $password));
2237 }
2238 }
2239 }
2240 }
2241 return $uid;
2242 }
2243
2255 function user_login_finalize(&$edit = array()) {
2256 global $user;
2257 watchdog('user', 'Session opened for %name.', array('%name' => $user->name));
2258 // Update the user table timestamp noting user has logged in.
2259 // This is also used to invalidate one-time login links.
2260 $user->login = REQUEST_TIME;
2261 db_update('users')
2262 ->fields(array('login' => $user->login))
2263 ->condition('uid', $user->uid)
2264 ->execute();
2265
2266 // Regenerate the session ID to prevent against session fixation attacks.
2267 // This is called before hook_user in case one of those functions fails
2268 // or incorrectly does a redirect which would leave the old session in place.
2269 drupal_session_regenerate();
2270
2271 user_module_invoke('login', $edit, $user);
2272 }
2273
2279 function user_login_submit($form, &$form_state) {
2280 global $user;
2281 $user = user_load($form_state['uid']);
2282 $form_state['redirect'] = 'user/' . $user->uid;
2283
2284 user_login_finalize($form_state);
2285 }
2286
2292 function user_external_login_register($name, $module) {
2293 $account = user_external_load($name);
2294 if (!$account) {
2295 // Register this new user.
2296 $userinfo = array(
2297 'name' => $name,
2298 'pass' => user_password(),
2299 'init' => $name,
2300 'status' => 1,
2301 'access' => REQUEST_TIME
2302 );
2303 $account = user_save(drupal_anonymous_user(), $userinfo);
2304 // Terminate if an error occurred during user_save().
2305 if (!$account) {
2306 drupal_set_message(t("Error saving user account."), 'error');
2307 return;
2308 }
2309 user_set_authmaps($account, array("authname_$module" => $name));
2310 }
2311
2312 // Log user in.
2313 $form_state['uid'] = $account->uid;
2314 user_login_submit(array(), $form_state);
2315 }
2316
2330 function user_pass_reset_url($account) {
2331 $timestamp = REQUEST_TIME;
2332 return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE));
2333 }
2334
2352 function user_cancel_url($account) {
2353 $timestamp = REQUEST_TIME;
2354 return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE));
2355 }
2356
2378 function user_pass_rehash($password, $timestamp, $login) {
2379 return drupal_hmac_base64($timestamp . $login, drupal_get_hash_salt() . $password);
2380 }
2381
2398 function user_cancel($edit, $uid, $method) {
2399 global $user;
2400
2401 $account = user_load($uid);
2402
2403 if (!$account) {
2404 drupal_set_message(t('The user account %id does not exist.', array('%id' => $uid)), 'error');
2405 watchdog('user', 'Attempted to cancel non-existing user account: %id.', array('%id' => $uid), WATCHDOG_ERROR);
2406 return;
2407 }
2408
2409 // Initialize batch (to set title).
2410 $batch = array(
2411 'title' => t('Cancelling account'),
2412 'operations' => array(),
2413 );
2414 batch_set($batch);
2415
2416 // Modules use hook_user_delete() to respond to deletion.
2417 if ($method != 'user_cancel_delete') {
2418 // Allow modules to add further sets to this batch.
2419 module_invoke_all('user_cancel', $edit, $account, $method);
2420 }
2421
2422 // Finish the batch and actually cancel the account.
2423 $batch = array(
2424 'title' => t('Cancelling user account'),
2425 'operations' => array(
2426 array('_user_cancel', array($edit, $account, $method)),
2427 ),
2428 );
2429
2430 // After cancelling account, ensure that user is logged out.
2431 if ($account->uid == $user->uid) {
2432 // Batch API stores data in the session, so use the finished operation to
2433 // manipulate the current user's session id.
2434 $batch['finished'] = '_user_cancel_session_regenerate';
2435 }
2436
2437 batch_set($batch);
2438
2439 // Batch processing is either handled via Form API or has to be invoked
2440 // manually.
2441 }
2442
2451 function _user_cancel($edit, $account, $method) {
2452 global $user;
2453
2454 switch ($method) {
2455 case 'user_cancel_block':
2456 case 'user_cancel_block_unpublish':
2457 default:
2458 // Send account blocked notification if option was checked.
2459 if (!empty($edit['user_cancel_notify'])) {
2460 _user_mail_notify('status_blocked', $account);
2461 }
2462 user_save($account, array('status' => 0));
2463 drupal_set_message(t('%name has been disabled.', array('%name' => $account->name)));
2464 watchdog('user', 'Blocked user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
2465 break;
2466
2467 case 'user_cancel_reassign':
2468 case 'user_cancel_delete':
2469 // Send account canceled notification if option was checked.
2470 if (!empty($edit['user_cancel_notify'])) {
2471 _user_mail_notify('status_canceled', $account);
2472 }
2473 user_delete($account->uid);
2474 drupal_set_message(t('%name has been deleted.', array('%name' => $account->name)));
2475 watchdog('user', 'Deleted user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
2476 break;
2477 }
2478
2479 // After cancelling account, ensure that user is logged out. We can't destroy
2480 // their session though, as we might have information in it, and we can't
2481 // regenerate it because batch API uses the session ID, we will regenerate it
2482 // in _user_cancel_session_regenerate().
2483 if ($account->uid == $user->uid) {
2484 $user = drupal_anonymous_user();
2485 }
2486
2487 // Clear the cache for anonymous users.
2488 cache_clear_all();
2489 }
2490
2496 function _user_cancel_session_regenerate() {
2497 // Regenerate the users session instead of calling session_destroy() as we
2498 // want to preserve any messages that might have been set.
2499 drupal_session_regenerate();
2500 }
2501
2508 function user_delete($uid) {
2509 user_delete_multiple(array($uid));
2510 }
2511
2518 function user_delete_multiple(array $uids) {
2519 if (!empty($uids)) {
2520 $accounts = user_load_multiple($uids, array());
2521
2522 $transaction = db_transaction();
2523 try {
2524 foreach ($accounts as $uid => $account) {
2525 module_invoke_all('user_delete', $account);
2526 module_invoke_all('entity_delete', $account, 'user');
2527 field_attach_delete('user', $account);
2528 drupal_session_destroy_uid($account->uid);
2529 }
2530
2531 db_delete('users')
2532 ->condition('uid', $uids, 'IN')
2533 ->execute();
2534 db_delete('users_roles')
2535 ->condition('uid', $uids, 'IN')
2536 ->execute();
2537 db_delete('authmap')
2538 ->condition('uid', $uids, 'IN')
2539 ->execute();
2540 }
2541 catch (Exception $e) {
2542 $transaction->rollback();
2543 watchdog_exception('user', $e);
2544 throw $e;
2545 }
2546 entity_get_controller('user')->resetCache();
2547 }
2548 }
2549
2553 function user_view_page($account) {
2554 // An administrator may try to view a non-existent account,
2555 // so we give them a 404 (versus a 403 for non-admins).
2556 return is_object($account) ? user_view($account) : MENU_NOT_FOUND;
2557 }
2558
2589 function user_view($account, $view_mode = 'full', $langcode = NULL) {
2590 if (!isset($langcode)) {
2591 $langcode = $GLOBALS['language_content']->language;
2592 }
2593
2594 // Retrieve all profile fields and attach to $account->content.
2595 user_build_content($account, $view_mode, $langcode);
2596
2597 $build = $account->content;
2598 // We don't need duplicate rendering info in account->content.
2599 unset($account->content);
2600
2601 $build += array(
2602 '#theme' => 'user_profile',
2603 '#account' => $account,
2604 '#view_mode' => $view_mode,
2605 '#language' => $langcode,
2606 );
2607
2608 // Allow modules to modify the structured user.
2609 $type = 'user';
2610 drupal_alter(array('user_view', 'entity_view'), $build, $type);
2611
2612 return $build;
2613 }
2614
2626 function user_build_content($account, $view_mode = 'full', $langcode = NULL) {
2627 if (!isset($langcode)) {
2628 $langcode = $GLOBALS['language_content']->language;
2629 }
2630
2631 // Remove previously built content, if exists.
2632 $account->content = array();
2633
2634 // Allow modules to change the view mode.
2635 $context = array(
2636 'entity_type' => 'user',
2637 'entity' => $account,
2638 'langcode' => $langcode,
2639 );
2640 drupal_alter('entity_view_mode', $view_mode, $context);
2641
2642 // Build fields content.
2643 field_attach_prepare_view('user', array($account->uid => $account), $view_mode, $langcode);
2644 entity_prepare_view('user', array($account->uid => $account), $langcode);
2645 $account->content += field_attach_view('user', $account, $view_mode, $langcode);
2646
2647 // Populate $account->content with a render() array.
2648 module_invoke_all('user_view', $account, $view_mode, $langcode);
2649 module_invoke_all('entity_view', $account, 'user', $view_mode, $langcode);
2650
2651 // Make sure the current view mode is stored if no module has already
2652 // populated the related key.
2653 $account->content += array('#view_mode' => $view_mode);
2654 }
2655
2659 function user_mail($key, &$message, $params) {
2660 $language = $message['language'];
2661 $variables = array('user' => $params['account']);
2662 $message['subject'] .= _user_mail_text($key . '_subject', $language, $variables);
2663 $message['body'][] = _user_mail_text($key . '_body', $language, $variables);
2664 }
2665
2671 function _user_mail_text($key, $language = NULL, $variables = array(), $replace = TRUE) {
2672 $langcode = isset($language) ? $language->language : NULL;
2673
2674 if ($admin_setting = variable_get('user_mail_' . $key, FALSE)) {
2675 // An admin setting overrides the default string.
2676 $text = $admin_setting;
2677 }
2678 else {
2679 // No override, return default string.
2680 switch ($key) {
2681 case 'register_no_approval_required_subject':
2682 $text = t('Account details for [user:name] at [site:name]', array(), array('langcode' => $langcode));
2683 break;
2684 case 'register_no_approval_required_body':
2685 $text = t("[user:name],
2686
2687 Thank you for registering at [site:name]. You may now log in by clicking this link or copying and pasting it to your browser:
2688
2689 [user:one-time-login-url]
2690
2691 This link can only be used once to log in and will lead you to a page where you can set your password.
2692
2693 After setting your password, you will be able to log in at [site:login-url] in the future using:
2694
2695 username: [user:name]
2696 password: Your password
2697
2698 -- [site:name] team", array(), array('langcode' => $langcode));
2699 break;
2700
2701 case 'register_admin_created_subject':
2702 $text = t('An administrator created an account for you at [site:name]', array(), array('langcode' => $langcode));
2703 break;
2704 case 'register_admin_created_body':
2705 $text = t("[user:name],
2706
2707 A site administrator at [site:name] has created an account for you. You may now log in by clicking this link or copying and pasting it to your browser:
2708
2709 [user:one-time-login-url]
2710
2711 This link can only be used once to log in and will lead you to a page where you can set your password.
2712
2713 After setting your password, you will be able to log in at [site:login-url] in the future using:
2714
2715 username: [user:name]
2716 password: Your password
2717
2718 -- [site:name] team", array(), array('langcode' => $langcode));
2719 break;
2720
2721 case 'register_pending_approval_subject':
2722 case 'register_pending_approval_admin_subject':
2723 $text = t('Account details for [user:name] at [site:name] (pending admin approval)', array(), array('langcode' => $langcode));
2724 break;
2725 case 'register_pending_approval_body':
2726 $text = t("[user:name],
2727
2728 Thank you for registering at [site:name]. Your application for an account is currently pending approval. Once it has been approved, you will receive another e-mail containing information about how to log in, set your password, and other details.
2729
2730
2731 -- [site:name] team", array(), array('langcode' => $langcode));
2732 break;
2733 case 'register_pending_approval_admin_body':
2734 $text = t("[user:name] has applied for an account.
2735
2736 [user:edit-url]", array(), array('langcode' => $langcode));
2737 break;
2738
2739 case 'password_reset_subject':
2740 $text = t('Replacement login information for [user:name] at [site:name]', array(), array('langcode' => $langcode));
2741 break;
2742 case 'password_reset_body':
2743 $text = t("[user:name],
2744
2745 A request to reset the password for your account has been made at [site:name].
2746
2747 You may now log in by clicking this link or copying and pasting it to your browser:
2748
2749 [user:one-time-login-url]
2750
2751 This link can only be used once to log in and will lead you to a page where you can set your password. It expires after one day and nothing will happen if it's not used.
2752
2753 -- [site:name] team", array(), array('langcode' => $langcode));
2754 break;
2755
2756 case 'status_activated_subject':
2757 $text = t('Account details for [user:name] at [site:name] (approved)', array(), array('langcode' => $langcode));
2758 break;
2759 case 'status_activated_body':
2760 $text = t("[user:name],
2761
2762 Your account at [site:name] has been activated.
2763
2764 You may now log in by clicking this link or copying and pasting it into your browser:
2765
2766 [user:one-time-login-url]
2767
2768 This link can only be used once to log in and will lead you to a page where you can set your password.
2769
2770 After setting your password, you will be able to log in at [site:login-url] in the future using:
2771
2772 username: [user:name]
2773 password: Your password
2774
2775 -- [site:name] team", array(), array('langcode' => $langcode));
2776 break;
2777
2778 case 'status_blocked_subject':
2779 $text = t('Account details for [user:name] at [site:name] (blocked)', array(), array('langcode' => $langcode));
2780 break;
2781 case 'status_blocked_body':
2782 $text = t("[user:name],
2783
2784 Your account on [site:name] has been blocked.
2785
2786 -- [site:name] team", array(), array('langcode' => $langcode));
2787 break;
2788
2789 case 'cancel_confirm_subject':
2790 $text = t('Account cancellation request for [user:name] at [site:name]', array(), array('langcode' => $langcode));
2791 break;
2792 case 'cancel_confirm_body':
2793 $text = t("[user:name],
2794
2795 A request to cancel your account has been made at [site:name].
2796
2797 You may now cancel your account on [site:url-brief] by clicking this link or copying and pasting it into your browser:
2798
2799 [user:cancel-url]
2800
2801 NOTE: The cancellation of your account is not reversible.
2802
2803 This link expires in one day and nothing will happen if it is not used.
2804
2805 -- [site:name] team", array(), array('langcode' => $langcode));
2806 break;
2807
2808 case 'status_canceled_subject':
2809 $text = t('Account details for [user:name] at [site:name] (canceled)', array(), array('langcode' => $langcode));
2810 break;
2811 case 'status_canceled_body':
2812 $text = t("[user:name],
2813
2814 Your account on [site:name] has been canceled.
2815
2816 -- [site:name] team", array(), array('langcode' => $langcode));
2817 break;
2818 }
2819 }
2820
2821 if ($replace) {
2822 // We do not sanitize the token replacement, since the output of this
2823 // replacement is intended for an e-mail message, not a web browser.
2824 return token_replace($text, $variables, array('language' => $language, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
2825 }
2826
2827 return $text;
2828 }
2829
2849 function user_mail_tokens(&$replacements, $data, $options) {
2850 if (isset($data['user'])) {
2851 $replacements['[user:one-time-login-url]'] = user_pass_reset_url($data['user']);
2852 $replacements['[user:cancel-url]'] = user_cancel_url($data['user']);
2853 }
2854 }
2855
2856 /*** Administrative features ***********************************************/
2857
2871 function user_roles($membersonly = FALSE, $permission = NULL) {
2872 $query = db_select('role', 'r');
2873 $query->addTag('translatable');
2874 $query->fields('r', array('rid', 'name'));
2875 $query->orderBy('weight');
2876 $query->orderBy('name');
2877 if (!empty($permission)) {
2878 $query->innerJoin('role_permission', 'p', 'r.rid = p.rid');
2879 $query->condition('p.permission', $permission);
2880 }
2881 $result = $query->execute();
2882
2883 $roles = array();
2884 foreach ($result as $role) {
2885 switch ($role->rid) {
2886 // We only translate the built in role names
2887 case DRUPAL_ANONYMOUS_RID:
2888 if (!$membersonly) {
2889 $roles[$role->rid] = t($role->name);
2890 }
2891 break;
2892 case DRUPAL_AUTHENTICATED_RID:
2893 $roles[$role->rid] = t($role->name);
2894 break;
2895 default:
2896 $roles[$role->rid] = $role->name;
2897 }
2898 }
2899
2900 return $roles;
2901 }
2902
2915 function user_role_load($rid) {
2916 return db_select('role', 'r')
2917 ->fields('r')
2918 ->condition('rid', $rid)
2919 ->execute()
2920 ->fetchObject();
2921 }
2922
2935 function user_role_load_by_name($role_name) {
2936 return db_select('role', 'r')
2937 ->fields('r')
2938 ->condition('name', $role_name)
2939 ->execute()
2940 ->fetchObject();
2941 }
2942
2955 function user_role_save($role) {
2956 if ($role->name) {
2957 // Prevent leading and trailing spaces in role names.
2958 $role->name = trim($role->name);
2959 }
2960 if (!isset($role->weight)) {
2961 // Set a role weight to make this new role last.
2962 $query = db_select('role');
2963 $query->addExpression('MAX(weight)');
2964 $role->weight = $query->execute()->fetchField() + 1;
2965 }
2966
2967 // Let modules modify the user role before it is saved to the database.
2968 module_invoke_all('user_role_presave', $role);
2969
2970 if (!empty($role->rid) && $role->name) {
2971 $status = drupal_write_record('role', $role, 'rid');
2972 module_invoke_all('user_role_update', $role);
2973 }
2974 else {
2975 $status = drupal_write_record('role', $role);
2976 module_invoke_all('user_role_insert', $role);
2977 }
2978
2979 // Clear the user access cache.
2980 drupal_static_reset('user_access');
2981 drupal_static_reset('user_role_permissions');
2982
2983 return $status;
2984 }
2985
2992 function user_role_delete($role) {
2993 if (is_int($role)) {
2994 $role = user_role_load($role);
2995 }
2996 else {
2997 $role = user_role_load_by_name($role);
2998 }
2999
3000 db_delete('role')
3001 ->condition('rid', $role->rid)
3002 ->execute();
3003 db_delete('role_permission')
3004 ->condition('rid', $role->rid)
3005 ->execute();
3006 // Update the users who have this role set:
3007 db_delete('users_roles')
3008 ->condition('rid', $role->rid)
3009 ->execute();
3010
3011 module_invoke_all('user_role_delete', $role);
3012
3013 // Clear the user access cache.
3014 drupal_static_reset('user_access');
3015 drupal_static_reset('user_role_permissions');
3016 }
3017
3021 function user_role_edit_access($role) {
3022 // Prevent the system-defined roles from being altered or removed.
3023 if ($role->rid == DRUPAL_ANONYMOUS_RID || $role->rid == DRUPAL_AUTHENTICATED_RID) {
3024 return FALSE;
3025 }
3026
3027 return user_access('administer permissions');
3028 }
3029
3036 function user_permission_get_modules() {
3037 $permissions = array();
3038 foreach (module_implements('permission') as $module) {
3039 $perms = module_invoke($module, 'permission');
3040 foreach ($perms as $key => $value) {
3041 $permissions[$key] = $module;
3042 }
3043 }
3044 return $permissions;
3045 }
3046
3076 function user_role_change_permissions($rid, array $permissions = array()) {
3077 // Grant new permissions for the role.
3078 $grant = array_filter($permissions);
3079 if (!empty($grant)) {
3080 user_role_grant_permissions($rid, array_keys($grant));
3081 }
3082 // Revoke permissions for the role.
3083 $revoke = array_diff_assoc($permissions, $grant);
3084 if (!empty($revoke)) {
3085 user_role_revoke_permissions($rid, array_keys($revoke));
3086 }
3087 }
3088
3100 function user_role_grant_permissions($rid, array $permissions = array()) {
3101 $modules = user_permission_get_modules();
3102 // Grant new permissions for the role.
3103 foreach ($permissions as $name) {
3104 db_merge('role_permission')
3105 ->key(array(
3106 'rid' => $rid,
3107 'permission' => $name,
3108 ))
3109 ->fields(array(
3110 'module' => $modules[$name],
3111 ))
3112 ->execute();
3113 }
3114
3115 // Clear the user access cache.
3116 drupal_static_reset('user_access');
3117 drupal_static_reset('user_role_permissions');
3118 }
3119
3131 function user_role_revoke_permissions($rid, array $permissions = array()) {
3132 // Revoke permissions for the role.
3133 db_delete('role_permission')
3134 ->condition('rid', $rid)
3135 ->condition('permission', $permissions, 'IN')
3136 ->execute();
3137
3138 // Clear the user access cache.
3139 drupal_static_reset('user_access');
3140 drupal_static_reset('user_role_permissions');
3141 }
3142
3146 function user_user_operations($form = array(), $form_state = array()) {
3147 $operations = array(
3148 'unblock' => array(
3149 'label' => t('Unblock the selected users'),
3150 'callback' => 'user_user_operations_unblock',
3151 ),
3152 'block' => array(
3153 'label' => t('Block the selected users'),
3154 'callback' => 'user_user_operations_block',
3155 ),
3156 'cancel' => array(
3157 'label' => t('Cancel the selected user accounts'),
3158 ),
3159 );
3160
3161 if (user_access('administer permissions')) {
3162 $roles = user_roles(TRUE);
3163 unset($roles[DRUPAL_AUTHENTICATED_RID]); // Can't edit authenticated role.
3164
3165 $add_roles = array();
3166 foreach ($roles as $key => $value) {
3167 $add_roles['add_role-' . $key] = $value;
3168 }
3169
3170 $remove_roles = array();
3171 foreach ($roles as $key => $value) {
3172 $remove_roles['remove_role-' . $key] = $value;
3173 }
3174
3175 if (count($roles)) {
3176 $role_operations = array(
3177 t('Add a role to the selected users') => array(
3178 'label' => $add_roles,
3179 ),
3180 t('Remove a role from the selected users') => array(
3181 'label' => $remove_roles,
3182 ),
3183 );
3184
3185 $operations += $role_operations;
3186 }
3187 }
3188
3189 // If the form has been posted, we need to insert the proper data for
3190 // role editing if necessary.
3191 if (!empty($form_state['submitted'])) {
3192 $operation_rid = explode('-', $form_state['values']['operation']);
3193 $operation = $operation_rid[0];
3194 if ($operation == 'add_role' || $operation == 'remove_role') {
3195 $rid = $operation_rid[1];
3196 if (user_access('administer permissions')) {
3197 $operations[$form_state['values']['operation']] = array(
3198 'callback' => 'user_multiple_role_edit',
3199 'callback arguments' => array($operation, $rid),
3200 );
3201 }
3202 else {
3203 watchdog('security', 'Detected malicious attempt to alter protected user fields.', array(), WATCHDOG_WARNING);
3204 return;
3205 }
3206 }
3207 }
3208
3209 return $operations;
3210 }
3211
3215 function user_user_operations_unblock($accounts) {
3216 $accounts = user_load_multiple($accounts);
3217 foreach ($accounts as $account) {
3218 // Skip unblocking user if they are already unblocked.
3219 if ($account !== FALSE && $account->status == 0) {
3220 user_save($account, array('status' => 1));
3221 }
3222 }
3223 }
3224
3228 function user_user_operations_block($accounts) {
3229 $accounts = user_load_multiple($accounts);
3230 foreach ($accounts as $account) {
3231 // Skip blocking user if they are already blocked.
3232 if ($account !== FALSE && $account->status == 1) {
3233 // For efficiency manually save the original account before applying any
3234 // changes.
3235 $account->original = clone $account;
3236 user_save($account, array('status' => 0));
3237 }
3238 }
3239 }
3240
3244 function user_multiple_role_edit($accounts, $operation, $rid) {
3245 // The role name is not necessary as user_save() will reload the user
3246 // object, but some modules' hook_user() may look at this first.
3247 $role_name = db_query('SELECT name FROM {role} WHERE rid = :rid', array(':rid' => $rid))->fetchField();
3248
3249 switch ($operation) {
3250 case 'add_role':
3251 $accounts = user_load_multiple($accounts);
3252 foreach ($accounts as $account) {
3253 // Skip adding the role to the user if they already have it.
3254 if ($account !== FALSE && !isset($account->roles[$rid])) {
3255 $roles = $account->roles + array($rid => $role_name);
3256 // For efficiency manually save the original account before applying
3257 // any changes.
3258 $account->original = clone $account;
3259 user_save($account, array('roles' => $roles));
3260 }
3261 }
3262 break;
3263 case 'remove_role':
3264 $accounts = user_load_multiple($accounts);
3265 foreach ($accounts as $account) {
3266 // Skip removing the role from the user if they already don't have it.
3267 if ($account !== FALSE && isset($account->roles[$rid])) {
3268 $roles = array_diff($account->roles, array($rid => $role_name));
3269 // For efficiency manually save the original account before applying
3270 // any changes.
3271 $account->original = clone $account;
3272 user_save($account, array('roles' => $roles));
3273 }
3274 }
3275 break;
3276 }
3277 }
3278
3279 function user_multiple_cancel_confirm($form, &$form_state) {
3280 $edit = $form_state['input'];
3281
3282 $form['accounts'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
3283 $accounts = user_load_multiple(array_keys(array_filter($edit['accounts'])));
3284 foreach ($accounts as $uid => $account) {
3285 // Prevent user 1 from being canceled.
3286 if ($uid <= 1) {
3287 continue;
3288 }
3289 $form['accounts'][$uid] = array(
3290 '#type' => 'hidden',
3291 '#value' => $uid,
3292 '#prefix' => '<li>',
3293 '#suffix' => check_plain($account->name) . "</li>\n",
3294 );
3295 }
3296
3297 // Output a notice that user 1 cannot be canceled.
3298 if (isset($accounts[1])) {
3299 $redirect = (count($accounts) == 1);
3300 $message = t('The user account %name cannot be cancelled.', array('%name' => $accounts[1]->name));
3301 drupal_set_message($message, $redirect ? 'error' : 'warning');
3302 // If only user 1 was selected, redirect to the overview.
3303 if ($redirect) {
3304 drupal_goto('admin/people');
3305 }
3306 }
3307
3308 $form['operation'] = array('#type' => 'hidden', '#value' => 'cancel');
3309
3310 module_load_include('inc', 'user', 'user.pages');
3311 $form['user_cancel_method'] = array(
3312 '#type' => 'item',
3313 '#title' => t('When cancelling these accounts'),
3314 );
3315 $form['user_cancel_method'] += user_cancel_methods();
3316 // Remove method descriptions.
3317 foreach (element_children($form['user_cancel_method']) as $element) {
3318 unset($form['user_cancel_method'][$element]['#description']);
3319 }
3320
3321 // Allow to send the account cancellation confirmation mail.
3322 $form['user_cancel_confirm'] = array(
3323 '#type' => 'checkbox',
3324 '#title' => t('Require e-mail confirmation to cancel account.'),
3325 '#default_value' => FALSE,
3326 '#description' => t('When enabled, the user must confirm the account cancellation via e-mail.'),
3327 );
3328 // Also allow to send account canceled notification mail, if enabled.
3329 $form['user_cancel_notify'] = array(
3330 '#type' => 'checkbox',
3331 '#title' => t('Notify user when account is canceled.'),
3332 '#default_value' => FALSE,
3333 '#access' => variable_get('user_mail_status_canceled_notify', FALSE),
3334 '#description' => t('When enabled, the user will receive an e-mail notification after the account has been cancelled.'),
3335 );
3336
3337 return confirm_form($form,
3338 t('Are you sure you want to cancel these user accounts?'),
3339 'admin/people', t('This action cannot be undone.'),
3340 t('Cancel accounts'), t('Cancel'));
3341 }
3342
3349 function user_multiple_cancel_confirm_submit($form, &$form_state) {
3350 global $user;
3351
3352 if ($form_state['values']['confirm']) {
3353 foreach ($form_state['values']['accounts'] as $uid => $value) {
3354 // Prevent programmatic form submissions from cancelling user 1.
3355 if ($uid <= 1) {
3356 continue;
3357 }
3358 // Prevent user administrators from deleting themselves without confirmation.
3359 if ($uid == $user->uid) {
3360 $admin_form_state = $form_state;
3361 unset($admin_form_state['values']['user_cancel_confirm']);
3362 $admin_form_state['values']['_account'] = $user;
3363 user_cancel_confirm_form_submit(array(), $admin_form_state);
3364 }
3365 else {
3366 user_cancel($form_state['values'], $uid, $form_state['values']['user_cancel_method']);
3367 }
3368 }
3369 }
3370 $form_state['redirect'] = 'admin/people';
3371 }
3372
3376 function _user_categories() {
3377 $categories = module_invoke_all('user_categories');
3378 usort($categories, '_user_sort');
3379
3380 return $categories;
3381 }
3382
3383 function _user_sort($a, $b) {
3384 $a = (array) $a + array('weight' => 0, 'title' => '');
3385 $b = (array) $b + array('weight' => 0, 'title' => '');
3386 return $a['weight'] < $b['weight'] ? -1 : ($a['weight'] > $b['weight'] ? 1 : ($a['title'] < $b['title'] ? -1 : 1));
3387 }
3388
3392 function user_filters() {
3393 // Regular filters
3394 $filters = array();
3395 $roles = user_roles(TRUE);
3396 unset($roles[DRUPAL_AUTHENTICATED_RID]); // Don't list authorized role.
3397 if (count($roles)) {
3398 $filters['role'] = array(
3399 'title' => t('role'),
3400 'field' => 'ur.rid',
3401 'options' => array(
3402 '[any]' => t('any'),
3403 ) + $roles,
3404 );
3405 }
3406
3407 $options = array();
3408 foreach (module_implements('permission') as $module) {
3409 $function = $module . '_permission';
3410 if ($permissions = $function()) {
3411 asort($permissions);
3412 foreach ($permissions as $permission => $description) {
3413 $options[t('@module module', array('@module' => $module))][$permission] = t($permission);
3414 }
3415 }
3416 }
3417 ksort($options);
3418 $filters['permission'] = array(
3419 'title' => t('permission'),
3420 'options' => array(
3421 '[any]' => t('any'),
3422 ) + $options,
3423 );
3424
3425 $filters['status'] = array(
3426 'title' => t('status'),
3427 'field' => 'u.status',
3428 'options' => array(
3429 '[any]' => t('any'),
3430 1 => t('active'),
3431 0 => t('blocked'),
3432 ),
3433 );
3434 return $filters;
3435 }
3436
3443 function user_build_filter_query(SelectQuery $query) {
3444 $filters = user_filters();
3445 // Extend Query with filter conditions.
3446 foreach (isset($_SESSION['user_overview_filter']) ? $_SESSION['user_overview_filter'] : array() as $filter) {
3447 list($key, $value) = $filter;
3448 // This checks to see if this permission filter is an enabled permission for
3449 // the authenticated role. If so, then all users would be listed, and we can
3450 // skip adding it to the filter query.
3451 if ($key == 'permission') {
3452 $account = new stdClass();
3453 $account->uid = 'user_filter';
3454 $account->roles = array(DRUPAL_AUTHENTICATED_RID => 1);
3455 if (user_access($value, $account)) {
3456 continue;
3457 }
3458 $users_roles_alias = $query->join('users_roles', 'ur', '%alias.uid = u.uid');
3459 $permission_alias = $query->join('role_permission', 'p', $users_roles_alias . '.rid = %alias.rid');
3460 $query->condition($permission_alias . '.permission', $value);
3461 }
3462 elseif ($key == 'role') {
3463 $users_roles_alias = $query->join('users_roles', 'ur', '%alias.uid = u.uid');
3464 $query->condition($users_roles_alias . '.rid' , $value);
3465 }
3466 else {
3467 $query->condition($filters[$key]['field'], $value);
3468 }
3469 }
3470 }
3471
3475 function user_comment_view($comment) {
3476 if (variable_get('user_signatures', 0) && !empty($comment->signature)) {
3477 // @todo This alters and replaces the original object value, so a
3478 // hypothetical process of loading, viewing, and saving will hijack the
3479 // stored data. Consider renaming to $comment->signature_safe or similar
3480 // here and elsewhere in Drupal 8.
3481 $comment->signature = check_markup($comment->signature, $comment->signature_format, '', TRUE);
3482 }
3483 else {
3484 $comment->signature = '';
3485 }
3486 }
3487
3497 function theme_user_signature($variables) {
3498 $signature = $variables['signature'];
3499 $output = '';
3500
3501 if ($signature) {
3502 $output .= '<div class="clear">';
3503 $output .= '<div>—</div>';
3504 $output .= $signature;
3505 $output .= '</div>';
3506 }
3507
3508 return $output;
3509 }
3510
3524 function user_preferred_language($account, $default = NULL) {
3525 $language_list = language_list();
3526 if (!empty($account->language) && isset($language_list[$account->language])) {
3527 return $language_list[$account->language];
3528 }
3529 else {
3530 return $default ? $default : language_default();
3531 }
3532 }
3533
3564 function _user_mail_notify($op, $account, $language = NULL) {
3565 // By default, we always notify except for canceled and blocked.
3566 $default_notify = ($op != 'status_canceled' && $op != 'status_blocked');
3567 $notify = variable_get('user_mail_' . $op . '_notify', $default_notify);
3568 if ($notify) {
3569 $params['account'] = $account;
3570 $language = $language ? $language : user_preferred_language($account);
3571 $mail = drupal_mail('user', $op, $account->mail, $language, $params);
3572 if ($op == 'register_pending_approval') {
3573 // If a user registered requiring admin approval, notify the admin, too.
3574 // We use the site default language for this.
3575 drupal_mail('user', 'register_pending_approval_admin', variable_get('site_mail', ini_get('sendmail_from')), language_default(), $params);
3576 }
3577 }
3578 return empty($mail) ? NULL : $mail['result'];
3579 }
3580
3590 function user_form_process_password_confirm($element) {
3591 global $user;
3592
3593 $js_settings = array(
3594 'password' => array(
3595 'strengthTitle' => t('Password strength:'),
3596 'hasWeaknesses' => t('To make your password stronger:'),
3597 'tooShort' => t('Make it at least 6 characters'),
3598 'addLowerCase' => t('Add lowercase letters'),
3599 'addUpperCase' => t('Add uppercase letters'),
3600 'addNumbers' => t('Add numbers'),
3601 'addPunctuation' => t('Add punctuation'),
3602 'sameAsUsername' => t('Make it different from your username'),
3603 'confirmSuccess' => t('yes'),
3604 'confirmFailure' => t('no'),
3605 'weak' => t('Weak'),
3606 'fair' => t('Fair'),
3607 'good' => t('Good'),
3608 'strong' => t('Strong'),
3609 'confirmTitle' => t('Passwords match:'),
3610 'username' => (isset($user->name) ? $user->name : ''),
3611 ),
3612 );
3613
3614 $element['#attached']['js'][] = drupal_get_path('module', 'user') . '/user.js';
3615 // Ensure settings are only added once per page.
3616 static $already_added = FALSE;
3617 if (!$already_added) {
3618 $already_added = TRUE;
3619 $element['#attached']['js'][] = array('data' => $js_settings, 'type' => 'setting');
3620 }
3621
3622 return $element;
3623 }
3624
3628 function user_node_load($nodes, $types) {
3629 // Build an array of all uids for node authors, keyed by nid.
3630 $uids = array();
3631 foreach ($nodes as $nid => $node) {
3632 $uids[$nid] = $node->uid;
3633 }
3634
3635 // Fetch name, picture, and data for these users.
3636 $user_fields = db_query("SELECT uid, name, picture, data FROM {users} WHERE uid IN (:uids)", array(':uids' => $uids))->fetchAllAssoc('uid');
3637
3638 // Add these values back into the node objects.
3639 foreach ($uids as $nid => $uid) {
3640 $nodes[$nid]->name = $user_fields[$uid]->name;
3641 $nodes[$nid]->picture = $user_fields[$uid]->picture;
3642 $nodes[$nid]->data = $user_fields[$uid]->data;
3643 }
3644 }
3645
3649 function user_image_style_delete($style) {
3650 // If a style is deleted, update the variables.
3651 // Administrators choose a replacement style when deleting.
3652 user_image_style_save($style);
3653 }
3654
3658 function user_image_style_save($style) {
3659 // If a style is renamed, update the variables that use it.
3660 if (isset($style['old_name']) && $style['old_name'] == variable_get('user_picture_style', '')) {
3661 variable_set('user_picture_style', $style['name']);
3662 }
3663 }
3664
3668 function user_action_info() {
3669 return array(
3670 'user_block_user_action' => array(
3671 'label' => t('Block current user'),
3672 'type' => 'user',
3673 'configurable' => FALSE,
3674 'triggers' => array('any'),
3675 ),
3676 );
3677 }
3678
3691 function user_block_user_action(&$entity, $context = array()) {
3692 // First priority: If there is a $entity->uid, block that user.
3693 // This is most likely a user object or the author if a node or comment.
3694 if (isset($entity->uid)) {
3695 $uid = $entity->uid;
3696 }
3697 elseif (isset($context['uid'])) {
3698 $uid = $context['uid'];
3699 }
3700 // If neither of those are valid, then block the current user.
3701 else {
3702 $uid = $GLOBALS['user']->uid;
3703 }
3704 $account = user_load($uid);
3705 $account = user_save($account, array('status' => 0));
3706 watchdog('action', 'Blocked user %name.', array('%name' => $account->name));
3707 }
3708
3715 function user_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
3716 $instance = $form['#instance'];
3717
3718 if ($instance['entity_type'] == 'user' && !$form['#field']['locked']) {
3719 $form['instance']['settings']['user_register_form'] = array(
3720 '#type' => 'checkbox',
3721 '#title' => t('Display on user registration form.'),
3722 '#description' => t("This is compulsory for 'required' fields."),
3723 // Field instances created in D7 beta releases before the setting was
3724 // introduced might be set as 'required' and 'not shown on user_register
3725 // form'. We make sure the checkbox comes as 'checked' for those.
3726 '#default_value' => $instance['settings']['user_register_form'] || $instance['required'],
3727 // Display just below the 'required' checkbox.
3728 '#weight' => $form['instance']['required']['#weight'] + .1,
3729 // Disabled when the 'required' checkbox is checked.
3730 '#states' => array(
3731 'enabled' => array('input[name="instance[required]"]' => array('checked' => FALSE)),
3732 ),
3733 // Checked when the 'required' checkbox is checked. This is done through
3734 // a custom behavior, since the #states system would also synchronize on
3735 // uncheck.
3736 '#attached' => array(
3737 'js' => array(drupal_get_path('module', 'user') . '/user.js'),
3738 ),
3739 );
3740
3741 array_unshift($form['#submit'], 'user_form_field_ui_field_edit_form_submit');
3742 }
3743 }
3744
3750 function user_form_field_ui_field_edit_form_submit($form, &$form_state) {
3751 $instance = $form_state['values']['instance'];
3752
3753 if (!empty($instance['required'])) {
3754 form_set_value($form['instance']['settings']['user_register_form'], 1, $form_state);
3755 }
3756 }
3757
3766 function user_register_form($form, &$form_state) {
3767 global $user;
3768
3769 $admin = user_access('administer users');
3770
3771 // Pass access information to the submit handler. Running an access check
3772 // inside the submit function interferes with form processing and breaks
3773 // hook_form_alter().
3774 $form['administer_users'] = array(
3775 '#type' => 'value',
3776 '#value' => $admin,
3777 );
3778
3779 // If we aren't admin but already logged on, go to the user page instead.
3780 if (!$admin && $user->uid) {
3781 drupal_goto('user/' . $user->uid);
3782 }
3783
3784 $form['#user'] = drupal_anonymous_user();
3785 $form['#user_category'] = 'register';
3786
3787 $form['#attached']['library'][] = array('system', 'jquery.cookie');
3788 $form['#attributes']['class'][] = 'user-info-from-cookie';
3789
3790 // Start with the default user account fields.
3791 user_account_form($form, $form_state);
3792
3793 // Attach field widgets, and hide the ones where the 'user_register_form'
3794 // setting is not on.
3795 $langcode = entity_language('user', $form['#user']);
3796 field_attach_form('user', $form['#user'], $form, $form_state, $langcode);
3797 foreach (field_info_instances('user', 'user') as $field_name => $instance) {
3798 if (empty($instance['settings']['user_register_form'])) {
3799 $form[$field_name]['#access'] = FALSE;
3800 }
3801 }
3802
3803 if ($admin) {
3804 // Redirect back to page which initiated the create request;
3805 // usually admin/people/create.
3806 $form_state['redirect'] = $_GET['q'];
3807 }
3808
3809 $form['actions'] = array('#type' => 'actions');
3810 $form['actions']['submit'] = array(
3811 '#type' => 'submit',
3812 '#value' => t('Create new account'),
3813 );
3814
3815 $form['#validate'][] = 'user_register_validate';
3816 // Add the final user registration form submit handler.
3817 $form['#submit'][] = 'user_register_submit';
3818
3819 return $form;
3820 }
3821
3825 function user_register_validate($form, &$form_state) {
3826 entity_form_field_validate('user', $form, $form_state);
3827 }
3828
3837 function user_register_submit($form, &$form_state) {
3838 $admin = $form_state['values']['administer_users'];
3839
3840 if (!variable_get('user_email_verification', TRUE) || $admin) {
3841 $pass = $form_state['values']['pass'];
3842 }
3843 else {
3844 $pass = user_password();
3845 }
3846 $notify = !empty($form_state['values']['notify']);
3847
3848 // Remove unneeded values.
3849 form_state_values_clean($form_state);
3850
3851 $form_state['values']['pass'] = $pass;
3852 $form_state['values']['init'] = $form_state['values']['mail'];
3853
3854 $account = $form['#user'];
3855
3856 entity_form_submit_build_entity('user', $account, $form, $form_state);
3857
3858 // Populate $edit with the properties of $account, which have been edited on
3859 // this form by taking over all values, which appear in the form values too.
3860 $edit = array_intersect_key((array) $account, $form_state['values']);
3861 $account = user_save($account, $edit);
3862
3863 // Terminate if an error occurred during user_save().
3864 if (!$account) {
3865 drupal_set_message(t("Error saving user account."), 'error');
3866 $form_state['redirect'] = '';
3867 return;
3868 }
3869 $form_state['user'] = $account;
3870 $form_state['values']['uid'] = $account->uid;
3871
3872 watchdog('user', 'New user: %name (%email).', array('%name' => $form_state['values']['name'], '%email' => $form_state['values']['mail']), WATCHDOG_NOTICE, l(t('edit'), 'user/' . $account->uid . '/edit'));
3873
3874 // Add plain text password into user account to generate mail tokens.
3875 $account->password = $pass;
3876
3877 // New administrative account without notification.
3878 $uri = entity_uri('user', $account);
3879 if ($admin && !$notify) {
3880 drupal_set_message(t('Created a new user account for <a href="@url">%name</a>. No e-mail has been sent.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name)));
3881 }
3882 // No e-mail verification required; log in user immediately.
3883 elseif (!$admin && !variable_get('user_email_verification', TRUE) && $account->status) {
3884 _user_mail_notify('register_no_approval_required', $account);
3885 $form_state['uid'] = $account->uid;
3886 user_login_submit(array(), $form_state);
3887 drupal_set_message(t('Registration successful. You are now logged in.'));
3888 $form_state['redirect'] = '';
3889 }
3890 // No administrator approval required.
3891 elseif ($account->status || $notify) {
3892 $op = $notify ? 'register_admin_created' : 'register_no_approval_required';
3893 _user_mail_notify($op, $account);
3894 if ($notify) {
3895 drupal_set_message(t('A welcome message with further instructions has been e-mailed to the new user <a href="@url">%name</a>.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name)));
3896 }
3897 else {
3898 drupal_set_message(t('A welcome message with further instructions has been sent to your e-mail address.'));
3899 $form_state['redirect'] = '';
3900 }
3901 }
3902 // Administrator approval required.
3903 else {
3904 _user_mail_notify('register_pending_approval', $account);
3905 drupal_set_message(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, a welcome message with further instructions has been sent to your e-mail address.'));
3906 $form_state['redirect'] = '';
3907 }
3908 }
3909
3913 function user_modules_installed($modules) {
3914 // Assign all available permissions to the administrator role.
3915 $rid = variable_get('user_admin_role', 0);
3916 if ($rid) {
3917 $permissions = array();
3918 foreach ($modules as $module) {
3919 if ($module_permissions = module_invoke($module, 'permission')) {
3920 $permissions = array_merge($permissions, array_keys($module_permissions));
3921 }
3922 }
3923 if (!empty($permissions)) {
3924 user_role_grant_permissions($rid, $permissions);
3925 }
3926 }
3927 }
3928
3932 function user_modules_uninstalled($modules) {
3933 db_delete('role_permission')
3934 ->condition('module', $modules, 'IN')
3935 ->execute();
3936 }
3937
3944 function user_login_destination() {
3945 $destination = drupal_get_destination();
3946 if ($destination['destination'] == 'user/login') {
3947 $destination['destination'] = 'user';
3948 }
3949 return $destination;
3950 }
3951
3958 function user_cookie_save(array $values) {
3959 foreach ($values as $field => $value) {
3960 // Set cookie for 365 days.
3961 setrawcookie('Drupal.visitor.' . $field, rawurlencode($value), REQUEST_TIME + 31536000, '/');
3962 }
3963 }
3964
3971 function user_cookie_delete($cookie_name) {
3972 setrawcookie('Drupal.visitor.' . $cookie_name, '', REQUEST_TIME - 3600, '/');
3973 }
3974
3978 function user_rdf_mapping() {
3979 return array(
3980 array(
3981 'type' => 'user',
3982 'bundle' => RDF_DEFAULT_BUNDLE,
3983 'mapping' => array(
3984 'rdftype' => array('sioc:UserAccount'),
3985 'name' => array(
3986 'predicates' => array('foaf:name'),
3987 ),
3988 'homepage' => array(
3989 'predicates' => array('foaf:page'),
3990 'type' => 'rel',
3991 ),
3992 ),
3993 ),
3994 );
3995 }
3996
4000 function user_file_download_access($field, $entity_type, $entity) {
4001 if ($entity_type == 'user') {
4002 return user_view_access($entity);
4003 }
4004 }
4005
4024 function user_system_info_alter(&$info, $file, $type) {
4025 if ($type == 'module' && $file->name == 'profile' && db_table_exists('profile_field')) {
4026 $info['hidden'] = FALSE;
4027 }
4028 }
EMAIL_MAX_LENGTH
const EMAIL_MAX_LENGTH
Definition: user.module:16
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
user_account_form_validate
user_account_form_validate($form, &$form_state)
Definition: user.module:1223
user_permission
user_permission()
Definition: user.module:848
user_node_load
user_node_load($nodes, $types)
Definition: user.module:3628
drupal_session_destroy_uid
drupal_session_destroy_uid($uid)
Definition: session.inc:477
user_field_extra_fields
user_field_extra_fields()
Definition: user.module:214
user_file_download
user_file_download($uri)
Definition: user.module:880
db_next_id
db_next_id($existing_id=0)
Definition: database.inc:2653
user_external_login_register
user_external_login_register($name, $module)
Definition: user.module:2292
watchdog_exception
watchdog_exception($type, Exception $exception, $message=NULL, $variables=array(), $severity=WATCHDOG_ERROR, $link=NULL)
Definition: bootstrap.inc:1654
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
user_file_download_access
user_file_download_access($field, $entity_type, $entity)
Definition: user.module:4000
MENU_SITE_ONLINE
const MENU_SITE_ONLINE
Definition: menu.inc:249
user_form_field_ui_field_edit_form_submit
user_form_field_ui_field_edit_form_submit($form, &$form_state)
Definition: user.module:3750
file_default_scheme
file_default_scheme()
Definition: file.inc:256
$op
$op
Definition: update.php:404
UserController::attachLoad
attachLoad(&$queried_users, $revision_id=FALSE)
Definition: user.module:302
user_theme
user_theme()
Definition: user.module:108
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
user_set_authmaps
user_set_authmaps($account, $authmaps)
Definition: user.module:2044
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
file_usage_add
file_usage_add(stdClass $file, $module, $type, $id, $count=1)
Definition: file.inc:682
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
FILE_CREATE_DIRECTORY
const FILE_CREATE_DIRECTORY
Definition: file.inc:41
entity_load
entity_load($entity_type, $ids=FALSE, $conditions=array(), $reset=FALSE)
Definition: common.inc:7800
l
l($text, $path, array $options=array())
Definition: common.inc:2432
user_role_delete
user_role_delete($role)
Definition: user.module:2992
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
user_login_authenticate_validate
user_login_authenticate_validate($form, &$form_state)
Definition: user.module:2136
user_needs_new_hash
user_needs_new_hash($account)
Definition: password.inc:278
drupal_strlen
drupal_strlen($text)
Definition: unicode.inc:474
user_edit_access
user_edit_access($account)
Definition: user.module:1587
entity_form_field_validate
entity_form_field_validate($entity_type, $form, &$form_state)
Definition: common.inc:7997
template_preprocess_user_picture
template_preprocess_user_picture(&$variables)
Definition: user.module:1463
SelectQuery
Definition: select.inc:859
field_attach_form
field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode=NULL, $options=array())
Definition: field.attach.inc:564
flood_is_allowed
flood_is_allowed($name, $threshold, $window=3600, $identifier=NULL)
Definition: common.inc:1298
user_validate_mail
user_validate_mail($mail)
Definition: user.module:670
user_filters
user_filters()
Definition: user.module:3392
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
field_info_instances
field_info_instances($entity_type=NULL, $bundle_name=NULL)
Definition: field.info.inc:592
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
$module
print $module
Definition: search-results.tpl.php:28
form_state_values_clean
form_state_values_clean(&$form_state)
Definition: form.inc:2159
format_username
format_username($account)
Definition: common.inc:2106
drupal_mail
drupal_mail($module, $key, $to, $language, $params=array(), $from=NULL, $send=TRUE)
Definition: mail.inc:122
field_attach_update
field_attach_update($entity_type, $entity)
Definition: field.attach.inc:990
user_menu_link_alter
user_menu_link_alter(&$link)
Definition: user.module:1883
user_validate_current_pass
user_validate_current_pass(&$form, &$form_state)
Definition: user.module:1199
drupal_anonymous_user
drupal_anonymous_user()
Definition: bootstrap.inc:2152
MENU_SITE_OFFLINE
const MENU_SITE_OFFLINE
Definition: menu.inc:244
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
$results
print $results
Definition: poll-results.tpl.php:23
user_user_operations
user_user_operations($form=array(), $form_state=array())
Definition: user.module:3146
Exception
name
print $forum name
Definition: forum-list.tpl.php:57
user_image_style_delete
user_image_style_delete($style)
Definition: user.module:3649
user_permission_get_modules
user_permission_get_modules()
Definition: user.module:3036
user_search_info
user_search_info()
Definition: user.module:917
user_get_authmaps
user_get_authmaps($authname=NULL)
Definition: user.module:2027
user_action_info
user_action_info()
Definition: user.module:3668
field_attach_prepare_view
field_attach_prepare_view($entity_type, $entities, $view_mode, $langcode=NULL, $options=array())
Definition: field.attach.inc:1133
_user_categories
_user_categories()
Definition: user.module:3376
user_view_access
user_view_access($account)
Definition: user.module:1564
user_cancel_access
user_cancel_access($account)
Definition: user.module:1597
USERNAME_MAX_LENGTH
const USERNAME_MAX_LENGTH
Definition: user.module:11
$attributes
print $attributes
Definition: block.tpl.php:47
file_valid_uri
file_valid_uri($uri)
Definition: file.inc:841
field_attach_presave
field_attach_presave($entity_type, $entity)
Definition: field.attach.inc:913
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
user_roles
user_roles($membersonly=FALSE, $permission=NULL)
Definition: user.module:2871
user_user_operations_block
user_user_operations_block($accounts)
Definition: user.module:3228
user_cookie_save
user_cookie_save(array $values)
Definition: user.module:3958
_user_sort
_user_sort($a, $b)
Definition: user.module:3383
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
user_role_load
user_role_load($rid)
Definition: user.module:2915
module_exists
module_exists($module)
Definition: module.inc:274
ip_address
ip_address()
Definition: bootstrap.inc:2890
user_user_categories
user_user_categories()
Definition: user.module:1300
user_validate_name
user_validate_name($name)
Definition: user.module:624
user_multiple_role_edit
user_multiple_role_edit($accounts, $operation, $rid)
Definition: user.module:3244
user_authenticate
user_authenticate($name, $password)
Definition: user.module:2223
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
_user_mail_notify
_user_mail_notify($op, $account, $language=NULL)
Definition: user.module:3564
$picture
print $picture
Definition: comment.tpl.php:64
user_save
user_save($account, $edit=array(), $category= 'account')
Definition: user.module:424
user_cancel
user_cancel($edit, $uid, $method)
Definition: user.module:2398
FILE_STATUS_PERMANENT
const FILE_STATUS_PERMANENT
Definition: file.inc:70
user_hash_password
user_hash_password($password, $count_log2=0)
Definition: password.inc:207
user_field_info_alter
user_field_info_alter(&$info)
Definition: user.module:201
drupal_hmac_base64
drupal_hmac_base64($data, $key)
Definition: bootstrap.inc:2047
user_system_info_alter
user_system_info_alter(&$info, $file, $type)
Definition: user.module:4024
user_delete_multiple
user_delete_multiple(array $uids)
Definition: user.module:2518
entity_uri
entity_uri($entity_type, $entity)
Definition: common.inc:7902
SelectQuery\condition
condition($field, $value=NULL, $operator=NULL)
Definition: select.inc:1006
user_block_info
user_block_info()
Definition: user.module:1340
user_role_grant_permissions
user_role_grant_permissions($rid, array $permissions=array())
Definition: user.module:3100
db_or
db_or()
Definition: database.inc:2662
token_replace
token_replace($text, array $data=array(), array $options=array())
Definition: token.inc:79
user_view
user_view($account, $view_mode= 'full', $langcode=NULL)
Definition: user.module:2589
file_delete
file_delete(stdClass $file, $force=FALSE)
Definition: file.inc:1268
user_pass_rehash
user_pass_rehash($password, $timestamp, $login)
Definition: user.module:2378
user_login_destination
user_login_destination()
Definition: user.module:3944
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
user_help
user_help($path, $arg)
Definition: user.module:37
user_role_edit_access
user_role_edit_access($role)
Definition: user.module:3021
user_block_save
user_block_save($delta= '', $edit=array())
Definition: user.module:1385
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
user_register_access
user_register_access()
Definition: user.module:1554
SelectQuery\join
join($table, $alias=NULL, $condition=NULL, $arguments=array())
Definition: select.inc:1337
user_load_by_mail
user_load_by_mail($mail)
Definition: user.module:381
_user_cancel
_user_cancel($edit, $account, $method)
Definition: user.module:2451
user_is_logged_in
user_is_logged_in()
Definition: user.module:1544
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
drupal_get_schema
drupal_get_schema($table=NULL, $rebuild=FALSE)
Definition: bootstrap.inc:2940
MENU_NOT_FOUND
const MENU_NOT_FOUND
Definition: menu.inc:234
user_preferred_language
user_preferred_language($account, $default=NULL)
Definition: user.module:3524
user_menu
user_menu()
Definition: user.module:1604
DRUPAL_ANONYMOUS_RID
const DRUPAL_ANONYMOUS_RID
Definition: bootstrap.inc:162
user_logout
user_logout()
Definition: user.pages.inc:170
user_register_submit
user_register_submit($form, &$form_state)
Definition: user.module:3837
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
user_admin_paths
user_admin_paths()
Definition: user.module:1912
user_page_title
user_page_title($account)
Definition: user.module:2015
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
field_attach_insert
field_attach_insert($entity_type, $entity)
Definition: field.attach.inc:936
batch_set
batch_set($batch_definition)
Definition: form.inc:4381
user_register_form
user_register_form($form, &$form_state)
Definition: user.module:3766
user_build_filter_query
user_build_filter_query(SelectQuery $query)
Definition: user.module:3443
user_is_blocked
user_is_blocked($name)
Definition: user.module:837
image_get_info
image_get_info($filepath, $toolkit=FALSE)
Definition: image.inc:124
user_search_execute
user_search_execute($keys=NULL, $conditions=NULL)
Definition: user.module:933
user_login_submit
user_login_submit($form, &$form_state)
Definition: user.module:2279
$info
$info
Definition: color.inc:6
user_image_style_save
user_image_style_save($style)
Definition: user.module:3658
user_check_password
user_check_password($password, $account)
Definition: password.inc:230
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
file_load_multiple
file_load_multiple($fids=array(), $conditions=array())
Definition: file.inc:564
user_mail_tokens
user_mail_tokens(&$replacements, $data, $options)
Definition: user.module:2849
user_rdf_mapping
user_rdf_mapping()
Definition: user.module:3978
user_user_presave
user_user_presave(&$edit, $account, $category)
Definition: user.module:1274
entity_load_unchanged
entity_load_unchanged($entity_type, $id)
Definition: common.inc:7823
user_build_content
user_build_content($account, $view_mode= 'full', $langcode=NULL)
Definition: user.module:2626
language_list
language_list($field= 'language')
Definition: bootstrap.inc:2723
user_block_configure
user_block_configure($delta= '')
Definition: user.module:1361
user_role_permissions
user_role_permissions($roles=array())
Definition: user.module:743
user_login_final_validate
user_login_final_validate($form, &$form_state)
Definition: user.module:2183
user_cancel_url
user_cancel_url($account)
Definition: user.module:2352
$value
print $value
Definition: user-profile-item.tpl.php:26
file_load
file_load($fid)
Definition: file.inc:580
user_role_change_permissions
user_role_change_permissions($rid, array $permissions=array())
Definition: user.module:3076
user_uid_only_optional_to_arg
user_uid_only_optional_to_arg($arg)
Definition: user.module:1928
DRUPAL_AUTHENTICATED_RID
const DRUPAL_AUTHENTICATED_RID
Definition: bootstrap.inc:167
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
entity_language
entity_language($entity_type, $entity)
Definition: common.inc:7967
file_move
file_move(stdClass $source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1035
user_view_page
user_view_page($account)
Definition: user.module:2553
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
theme_user_list
theme_user_list($variables)
Definition: user.module:1514
user_login_default_validators
user_login_default_validators()
Definition: user.module:2117
$output
$output
Definition: authorize.php:93
user_user_view
user_user_view($account)
Definition: user.module:990
user_search_access
user_search_access()
Definition: user.module:926
user_file_move
user_file_move($file, $source)
Definition: user.module:890
user_load_multiple
user_load_multiple($uids=array(), $conditions=array(), $reset=FALSE)
Definition: user.module:290
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
db_like
db_like($string)
Definition: database.inc:2610
user_access
user_access($string, $account=NULL)
Definition: user.module:794
user_login
user_login($form, &$form_state)
Definition: user.module:2070
user_login_block
user_login_block($form)
Definition: user.module:1308
user_comment_view
user_comment_view($comment)
Definition: user.module:3475
user_modules_installed
user_modules_installed($modules)
Definition: user.module:3913
file_usage_delete
file_usage_delete(stdClass $file, $module, $type=NULL, $id=NULL, $count=1)
Definition: file.inc:720
user_validate_picture
user_validate_picture(&$form, &$form_state)
Definition: user.module:684
drupal_random_bytes
drupal_random_bytes($count)
Definition: bootstrap.inc:1974
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
RDF_DEFAULT_BUNDLE
const RDF_DEFAULT_BUNDLE
Definition: rdf.module:74
user_password
user_password($length=10)
Definition: user.module:705
file_save_upload
file_save_upload($source, $validators=array(), $destination=FALSE, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1437
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
file_uri_target
file_uri_target($uri)
Definition: file.inc:243
user_cancel_confirm_form_submit
user_cancel_confirm_form_submit($form, &$form_state)
Definition: user.pages.inc:430
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
user_uid_optional_to_arg
user_uid_optional_to_arg($arg)
Definition: user.module:1995
entity_prepare_view
entity_prepare_view($entity_type, $entities, $langcode=NULL)
Definition: common.inc:7866
user_block_view
user_block_view($delta= '')
Definition: user.module:1403
flood_clear_event
flood_clear_event($name, $identifier=NULL)
Definition: common.inc:1267
user_login_finalize
user_login_finalize(&$edit=array())
Definition: user.module:2255
file_stream_wrapper_uri_normalize
file_stream_wrapper_uri_normalize($uri)
Definition: file.inc:275
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
valid_email_address
valid_email_address($mail)
Definition: common.inc:1186
user_entity_info
user_entity_info()
Definition: user.module:153
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
user_menu_site_status_alter
user_menu_site_status_alter(&$menu_site_status, $path)
Definition: user.module:1841
db_transaction
db_transaction($name=NULL, array $options=array())
Definition: database.inc:2535
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
entity_get_controller
entity_get_controller($entity_type)
Definition: common.inc:7832
field_attach_view
field_attach_view($entity_type, $entity, $view_mode, $langcode=NULL, $options=array())
Definition: field.attach.inc:1216
user_mail
user_mail($key, &$message, $params)
Definition: user.module:2659
user_uid_optional_load
user_uid_optional_load($uid=NULL)
Definition: user.module:1945
UserController
Definition: user.module:300
user_external_load
user_external_load($authname)
Definition: user.module:249
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
DRUPAL_NO_CACHE
const DRUPAL_NO_CACHE
Definition: common.inc:127
user_role_revoke_permissions
user_role_revoke_permissions($rid, array $permissions=array())
Definition: user.module:3131
DrupalDefaultEntityController
Definition: entity.inc:46
_user_mail_text
_user_mail_text($key, $language=NULL, $variables=array(), $replace=TRUE)
Definition: user.module:2671
language_default
language_default($property=NULL)
Definition: bootstrap.inc:2765
user_role_save
user_role_save($role)
Definition: user.module:2955
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
USER_REGISTER_VISITORS
const USER_REGISTER_VISITORS
Definition: user.module:26
user_form_process_password_confirm
user_form_process_password_confirm($element)
Definition: user.module:3590
user_module_invoke
user_module_invoke($type, &$edit, $account, $category=NULL)
Definition: user.module:98
$row
$row
Definition: block-admin-display-form.tpl.php:47
user_load_by_name
user_load_by_name($name)
Definition: user.module:397
FILE_EXISTS_RENAME
const FILE_EXISTS_RENAME
Definition: file.inc:51
user_login_name_validate
user_login_name_validate($form, &$form_state)
Definition: user.module:2124
file_prepare_directory
file_prepare_directory(&$directory, $options=FILE_MODIFY_PERMISSIONS)
Definition: file.inc:430
user_multiple_cancel_confirm
user_multiple_cancel_confirm($form, &$form_state)
Definition: user.module:3279
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
user_element_info
user_element_info()
Definition: user.module:977
user_role_load_by_name
user_role_load_by_name($role_name)
Definition: user.module:2935
user_translated_menu_link_alter
user_translated_menu_link_alter(&$link)
Definition: user.module:1902
current_path
current_path()
Definition: path.inc:354
check_markup
check_markup($text, $format_id=NULL, $langcode= '', $cache=FALSE)
Definition: filter.module:759
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
user_account_form
user_account_form(&$form, &$form_state)
Definition: user.module:1019
user_register_validate
user_register_validate($form, &$form_state)
Definition: user.module:3825
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
user_menu_title
user_menu_title()
Definition: user.module:2008
user_block_user_action
user_block_user_action(&$entity, $context=array())
Definition: user.module:3691
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
user_pass_reset_url
user_pass_reset_url($account)
Definition: user.module:2330
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
user_modules_uninstalled
user_modules_uninstalled($modules)
Definition: user.module:3932
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
user_user_operations_unblock
user_user_operations_unblock($accounts)
Definition: user.module:3215
user_form_field_ui_field_edit_form_alter
user_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id)
Definition: user.module:3715
user_cookie_delete
user_cookie_delete($cookie_name)
Definition: user.module:3971
_user_cancel_session_regenerate
_user_cancel_session_regenerate()
Definition: user.module:2496
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL
const USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL
Definition: user.module:32
file_save
file_save(stdClass $file)
Definition: file.inc:599
user_multiple_cancel_confirm_submit
user_multiple_cancel_confirm_submit($form, &$form_state)
Definition: user.module:3349
flood_register_event
flood_register_event($name, $window=3600, $identifier=NULL)
Definition: common.inc:1245
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
user_cancel_methods
user_cancel_methods()
Definition: user.pages.inc:471
entity_form_submit_build_entity
entity_form_submit_build_entity($entity_type, $entity, $form, &$form_state)
Definition: common.inc:8028
user_delete
user_delete($uid)
Definition: user.module:2508
db_table_exists
db_table_exists($table)
Definition: database.inc:2760
theme_user_signature
theme_user_signature($variables)
Definition: user.module:3497
drupal_get_hash_salt
drupal_get_hash_salt()
Definition: bootstrap.inc:2289
user_file_delete
user_file_delete($file)
Definition: user.module:906
user_category_load
user_category_load($uid, &$map, $index)
Definition: user.module:1955
field_attach_delete
field_attach_delete($entity_type, $entity)
Definition: field.attach.inc:1045
user_is_anonymous
user_is_anonymous()
Definition: user.module:1533
user_uri
user_uri($user)
Definition: user.module:192
drupal_session_regenerate
drupal_session_regenerate()
Definition: session.inc:350
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/contact/contact.module Source File

  • modules
  • contact
contact.module
Go to the documentation of this file.
1 <?php
2
11 function contact_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#contact':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t('The Contact module allows visitors to contact site administrators and other users. Users specify a subject, write their message, and can have a copy of their message sent to their own e-mail address. For more information, see the online handbook entry for <a href="@contact">Contact module</a>.', array('@contact' => 'http://drupal.org/documentation/modules/contact/')) . '</p>';
17 $output .= '<h3>' . t('Uses') . '</h3>';
18 $output .= '<dl>';
19 $output .= '<dt>' . t('User contact forms') . '</dt>';
20 $output .= '<dd>' . t('Site users can be contacted with a user contact form that keeps their e-mail address private. Users may enable or disable their personal contact forms by editing their <em>My account</em> page. If enabled, a <em>Contact</em> tab leads to a personal contact form displayed on their user profile. Site administrators are still able to use the contact form, even if has been disabled. The <em>Contact</em> tab is not shown when you view your own profile.') . '</dd>';
21 $output .= '<dt>' . t('Site-wide contact forms') . '</dt>';
22 $output .= '<dd>' . t('The <a href="@contact">Contact page</a> provides a simple form for users with the <em>Use the site-wide contact form</em> permission to send comments, feedback, or other requests. You can create categories for directing the contact form messages to a set of defined recipients. Common categories for a business site, for example, might include "Website feedback" (messages are forwarded to website administrators) and "Product information" (messages are forwarded to members of the sales department). E-mail addresses defined within a category are not displayed publicly.', array('@contact' => url('contact'))) . '</p>';
23 $output .= '<dt>' . t('Navigation') . '</dt>';
24 $output .= '<dd>' . t("When the site-wide contact form is enabled, a link in the main <em>Navigation</em> menu is created, but the link is disabled by default. This menu link can be enabled on the <a href='@menu'>Menus administration page</a>.", array('@contact' => url('contact'), '@menu' => url('admin/structure/menu'))) . '</dd>';
25 $output .= '<dt>' . t('Customization') . '</dt>';
26 $output .= '<dd>' . t('If you would like additional text to appear on the site-wide or personal contact page, use a block. You can create and edit blocks on the <a href="@blocks">Blocks administration page</a>.', array('@blocks' => url('admin/structure/block'))) . '</dd>';
27 $output .= '</dl>';
28 return $output;
29 case 'admin/structure/contact':
30 $output = '<p>' . t('Add one or more categories on this page to set up your site-wide <a href="@form">contact form</a>.', array('@form' => url('contact'))) . '</p>';
31 $output .= '<p>' . t('A <em>Contact</em> menu item (disabled by default) is added to the Navigation menu, which you can modify on the <a href="@menu-settings">Menus administration page</a>.', array('@menu-settings' => url('admin/structure/menu'))) . '</p>';
32 $output .= '<p>' . t('If you would like additional text to appear on the site-wide contact page, use a block. You can create and edit blocks on the <a href="@blocks">Blocks administration page</a>.', array('@blocks' => url('admin/structure/block'))) . '</p>';
33 return $output;
34 }
35 }
36
40 function contact_permission() {
41 return array(
42 'administer contact forms' => array(
43 'title' => t('Administer contact forms and contact form settings'),
44 ),
45 'access site-wide contact form' => array(
46 'title' => t('Use the site-wide contact form'),
47 ),
48 'access user contact forms' => array(
49 'title' => t("Use users' personal contact forms"),
50 ),
51 );
52 }
53
57 function contact_menu() {
58 $items['admin/structure/contact'] = array(
59 'title' => 'Contact form',
60 'description' => 'Create a system contact form and set up categories for the form to use.',
61 'page callback' => 'contact_category_list',
62 'access arguments' => array('administer contact forms'),
63 'file' => 'contact.admin.inc',
64 );
65 $items['admin/structure/contact/add'] = array(
66 'title' => 'Add category',
67 'page callback' => 'drupal_get_form',
68 'page arguments' => array('contact_category_edit_form'),
69 'access arguments' => array('administer contact forms'),
70 'type' => MENU_LOCAL_ACTION,
71 'weight' => 1,
72 'file' => 'contact.admin.inc',
73 );
74 $items['admin/structure/contact/edit/%contact'] = array(
75 'title' => 'Edit contact category',
76 'page callback' => 'drupal_get_form',
77 'page arguments' => array('contact_category_edit_form', 4),
78 'access arguments' => array('administer contact forms'),
79 'file' => 'contact.admin.inc',
80 );
81 $items['admin/structure/contact/delete/%contact'] = array(
82 'title' => 'Delete contact',
83 'page callback' => 'drupal_get_form',
84 'page arguments' => array('contact_category_delete_form', 4),
85 'access arguments' => array('administer contact forms'),
86 'file' => 'contact.admin.inc',
87 );
88 $items['contact'] = array(
89 'title' => 'Contact',
90 'page callback' => 'drupal_get_form',
91 'page arguments' => array('contact_site_form'),
92 'access arguments' => array('access site-wide contact form'),
93 'type' => MENU_SUGGESTED_ITEM,
94 'file' => 'contact.pages.inc',
95 );
96 $items['user/%user/contact'] = array(
97 'title' => 'Contact',
98 'page callback' => 'drupal_get_form',
99 'page arguments' => array('contact_personal_form', 1),
100 'type' => MENU_LOCAL_TASK,
101 'access callback' => '_contact_personal_tab_access',
102 'access arguments' => array(1),
103 'weight' => 2,
104 'file' => 'contact.pages.inc',
105 );
106 return $items;
107 }
108
115 function _contact_personal_tab_access($account) {
116 global $user;
117
118 // Anonymous users cannot have contact forms.
119 if (!$account->uid) {
120 return FALSE;
121 }
122
123 // User administrators should always have access to personal contact forms.
124 if (user_access('administer users')) {
125 return TRUE;
126 }
127
128 // Users may not contact themselves.
129 if ($user->uid == $account->uid) {
130 return FALSE;
131 }
132
133 // If the requested user has disabled their contact form, or this preference
134 // has not yet been saved, do not allow users to contact them.
135 if (empty($account->data['contact'])) {
136 return FALSE;
137 }
138
139 // If requested user has been blocked, do not allow users to contact them.
140 if (empty($account->status)) {
141 return FALSE;
142 }
143
144 return user_access('access user contact forms');
145 }
146
156 function contact_load($cid) {
157 return db_select('contact', 'c')
158 ->addTag('translatable')
159 ->fields('c')
160 ->condition('cid', $cid)
161 ->execute()
162 ->fetchAssoc();
163 }
164
168 function contact_mail($key, &$message, $params) {
169 $language = $message['language'];
170 $variables = array(
171 '!site-name' => variable_get('site_name', 'Drupal'),
172 '!subject' => $params['subject'],
173 '!category' => isset($params['category']['category']) ? $params['category']['category'] : '',
174 '!form-url' => url($_GET['q'], array('absolute' => TRUE, 'language' => $language)),
175 '!sender-name' => format_username($params['sender']),
176 '!sender-url' => $params['sender']->uid ? url('user/' . $params['sender']->uid, array('absolute' => TRUE, 'language' => $language)) : $params['sender']->mail,
177 );
178
179 switch ($key) {
180 case 'page_mail':
181 case 'page_copy':
182 $message['subject'] .= t('[!category] !subject', $variables, array('langcode' => $language->language));
183 $message['body'][] = t("!sender-name (!sender-url) sent a message using the contact form at !form-url.", $variables, array('langcode' => $language->language));
184 $message['body'][] = $params['message'];
185 break;
186
187 case 'page_autoreply':
188 $message['subject'] .= t('[!category] !subject', $variables, array('langcode' => $language->language));
189 $message['body'][] = $params['category']['reply'];
190 break;
191
192 case 'user_mail':
193 case 'user_copy':
194 $variables += array(
195 '!recipient-name' => format_username($params['recipient']),
196 '!recipient-edit-url' => url('user/' . $params['recipient']->uid . '/edit', array('absolute' => TRUE, 'language' => $language)),
197 );
198 $message['subject'] .= t('[!site-name] !subject', $variables, array('langcode' => $language->language));
199 $message['body'][] = t('Hello !recipient-name,', $variables, array('langcode' => $language->language));
200 $message['body'][] = t("!sender-name (!sender-url) has sent you a message via your contact form (!form-url) at !site-name.", $variables, array('langcode' => $language->language));
201 $message['body'][] = t("If you don't want to receive such e-mails, you can change your settings at !recipient-edit-url.", $variables, array('langcode' => $language->language));
202 $message['body'][] = t('Message:', array(), array('langcode' => $language->language));
203 $message['body'][] = $params['message'];
204 break;
205 }
206 }
207
215 function contact_form_user_profile_form_alter(&$form, &$form_state) {
216 if ($form['#user_category'] == 'account') {
217 $account = $form['#user'];
218 $form['contact'] = array(
219 '#type' => 'fieldset',
220 '#title' => t('Contact settings'),
221 '#weight' => 5,
222 '#collapsible' => TRUE,
223 );
224 $form['contact']['contact'] = array(
225 '#type' => 'checkbox',
226 '#title' => t('Personal contact form'),
227 '#default_value' => !empty($account->data['contact']) ? $account->data['contact'] : FALSE,
228 '#description' => t('Allow other users to contact you via a <a href="@url">personal contact form</a> which keeps your e-mail address hidden. Note that some privileged users such as site administrators are still able to contact you even if you choose to disable this feature.', array('@url' => url("user/$account->uid/contact"))),
229 );
230 }
231 }
232
236 function contact_user_presave(&$edit, $account, $category) {
237 $edit['data']['contact'] = isset($edit['contact']) ? $edit['contact'] : variable_get('contact_default_status', 1);
238 }
239
247 function contact_form_user_admin_settings_alter(&$form, &$form_state) {
248 $form['contact'] = array(
249 '#type' => 'fieldset',
250 '#title' => t('Contact settings'),
251 '#weight' => 0,
252 );
253 $form['contact']['contact_default_status'] = array(
254 '#type' => 'checkbox',
255 '#title' => t('Enable the personal contact form by default for new users.'),
256 '#description' => t('Changing this setting will not affect existing users.'),
257 '#default_value' => variable_get('contact_default_status', 1),
258 );
259 }
_contact_personal_tab_access
_contact_personal_tab_access($account)
Definition: contact.module:115
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
contact_load
contact_load($cid)
Definition: contact.module:156
format_username
format_username($account)
Definition: common.inc:2106
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
contact_help
contact_help($path, $arg)
Definition: contact.module:11
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
contact_menu
contact_menu()
Definition: contact.module:57
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
MENU_SUGGESTED_ITEM
const MENU_SUGGESTED_ITEM
Definition: menu.inc:161
contact_permission
contact_permission()
Definition: contact.module:40
contact_form_user_admin_settings_alter
contact_form_user_admin_settings_alter(&$form, &$form_state)
Definition: contact.module:247
contact_mail
contact_mail($key, &$message, $params)
Definition: contact.module:168
contact_user_presave
contact_user_presave(&$edit, $account, $category)
Definition: contact.module:236
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
contact_form_user_profile_form_alter
contact_form_user_profile_form_alter(&$form, &$form_state)
Definition: contact.module:215
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: authorize.php Source File

authorize.php
Go to the documentation of this file.
1 <?php
2
26 define('DRUPAL_ROOT', getcwd());
27
36 define('MAINTENANCE_MODE', 'update');
37
41 function authorize_access_denied_page() {
42 drupal_add_http_header('Status', '403 Forbidden');
43 watchdog('access denied', 'authorize.php', NULL, WATCHDOG_WARNING);
44 drupal_set_title('Access denied');
45 return t('You are not allowed to access this page.');
46 }
47
57 function authorize_access_allowed() {
58 return variable_get('allow_authorize_operations', TRUE) && user_access('administer software updates');
59 }
60
61 // *** Real work of the script begins here. ***
62
63 require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
64 require_once DRUPAL_ROOT . '/includes/common.inc';
65 require_once DRUPAL_ROOT . '/includes/file.inc';
66 require_once DRUPAL_ROOT . '/includes/module.inc';
67 require_once DRUPAL_ROOT . '/includes/ajax.inc';
68
69 // We prepare only a minimal bootstrap. This includes the database and
70 // variables, however, so we have access to the class autoloader registry.
71 drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
72
73 // This must go after drupal_bootstrap(), which unsets globals!
74 global $conf;
75
76 // We have to enable the user and system modules, even to check access and
77 // display errors via the maintenance theme.
78 $module_list['system']['filename'] = 'modules/system/system.module';
79 $module_list['user']['filename'] = 'modules/user/user.module';
80 module_list(TRUE, FALSE, FALSE, $module_list);
81 drupal_load('module', 'system');
82 drupal_load('module', 'user');
83
84 // We also want to have the language system available, but we do *NOT* want to
85 // actually call drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE), since that would
86 // also force us through the DRUPAL_BOOTSTRAP_PAGE_HEADER phase, which loads
87 // all the modules, and that's exactly what we're trying to avoid.
88 drupal_language_initialize();
89
90 // Initialize the maintenance theme for this administrative script.
91 drupal_maintenance_theme();
92
93 $output = '';
94 $show_messages = TRUE;
95
96 if (authorize_access_allowed()) {
97 // Load both the Form API and Batch API.
98 require_once DRUPAL_ROOT . '/includes/form.inc';
99 require_once DRUPAL_ROOT . '/includes/batch.inc';
100 // Load the code that drives the authorize process.
101 require_once DRUPAL_ROOT . '/includes/authorize.inc';
102
103 // For the sake of Batch API and a few other low-level functions, we need to
104 // initialize the URL path into $_GET['q']. However, we do not want to raise
105 // our bootstrap level, nor do we want to call drupal_initialize_path(),
106 // since that is assuming that modules are loaded and invoking hooks.
107 // However, all we really care is if we're in the middle of a batch, in which
108 // case $_GET['q'] will already be set, we just initialize it to an empty
109 // string if it's not already defined.
110 if (!isset($_GET['q'])) {
111 $_GET['q'] = '';
112 }
113
114 if (isset($_SESSION['authorize_operation']['page_title'])) {
115 drupal_set_title($_SESSION['authorize_operation']['page_title']);
116 }
117 else {
118 drupal_set_title(t('Authorize file system changes'));
119 }
120
121 // See if we've run the operation and need to display a report.
122 if (isset($_SESSION['authorize_results']) && $results = $_SESSION['authorize_results']) {
123
124 // Clear the session out.
125 unset($_SESSION['authorize_results']);
126 unset($_SESSION['authorize_operation']);
127 unset($_SESSION['authorize_filetransfer_info']);
128
129 if (!empty($results['page_title'])) {
130 drupal_set_title($results['page_title']);
131 }
132 if (!empty($results['page_message'])) {
133 drupal_set_message($results['page_message']['message'], $results['page_message']['type']);
134 }
135
136 $output = theme('authorize_report', array('messages' => $results['messages']));
137
138 $links = array();
139 if (is_array($results['tasks'])) {
140 $links += $results['tasks'];
141 }
142 else {
143 $links = array_merge($links, array(
144 l(t('Administration pages'), 'admin'),
145 l(t('Front page'), '<front>'),
146 ));
147 }
148
149 $output .= theme('item_list', array('items' => $links, 'title' => t('Next steps')));
150 }
151 // If a batch is running, let it run.
152 elseif (isset($_GET['batch'])) {
153 $output = _batch_page();
154 }
155 else {
156 if (empty($_SESSION['authorize_operation']) || empty($_SESSION['authorize_filetransfer_info'])) {
157 $output = t('It appears you have reached this page in error.');
158 }
159 elseif (!$batch = batch_get()) {
160 // We have a batch to process, show the filetransfer form.
161 $elements = drupal_get_form('authorize_filetransfer_form');
162 $output = drupal_render($elements);
163 }
164 }
165 // We defer the display of messages until all operations are done.
166 $show_messages = !(($batch = batch_get()) && isset($batch['running']));
167 }
168 else {
169 $output = authorize_access_denied_page();
170 }
171
172 if (!empty($output)) {
173 print theme('update_page', array('content' => $output, 'show_messages' => $show_messages));
174 }
_batch_page
_batch_page()
Definition: batch.inc:43
module_list
module_list($refresh=FALSE, $bootstrap_refresh=FALSE, $sort=FALSE, $fixed_list=NULL)
Definition: module.inc:66
l
l($text, $path, array $options=array())
Definition: common.inc:2432
$show_messages
$show_messages
Definition: authorize.php:94
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
$results
print $results
Definition: poll-results.tpl.php:23
authorize_access_allowed
authorize_access_allowed()
Definition: authorize.php:57
print
print
Definition: php-2.php:2
drupal_bootstrap
drupal_bootstrap($phase=NULL, $new_phase=TRUE)
Definition: bootstrap.inc:2192
$conf
global $conf
Definition: authorize.php:74
$module_list
$module_list['system']['filename']
Definition: authorize.php:78
DRUPAL_BOOTSTRAP_SESSION
const DRUPAL_BOOTSTRAP_SESSION
Definition: bootstrap.inc:142
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
drupal_add_http_header
drupal_add_http_header($name, $value, $append=FALSE)
Definition: bootstrap.inc:1129
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
drupal_maintenance_theme
drupal_maintenance_theme()
Definition: bootstrap.inc:2569
authorize_access_denied_page
authorize_access_denied_page()
Definition: authorize.php:41
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
drupal_language_initialize
drupal_language_initialize()
Definition: bootstrap.inc:2648
batch_get
& batch_get()
Definition: form.inc:4538
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
drupal_load
drupal_load($type, $name)
Definition: bootstrap.inc:1093
$links
print $links
Definition: poll-results--block.tpl.php:28
Generated on Mon Feb 3 2014 12:40:40 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
TaxonomyTermController Member List

This is the complete list of members for TaxonomyTermController, including all inherited members.

$cache | DrupalDefaultEntityController | protected
$entityCache | DrupalDefaultEntityController | protected
$entityInfo | DrupalDefaultEntityController | protected
$entityType | DrupalDefaultEntityController | protected
$hookLoadArguments | DrupalDefaultEntityController | protected
$idKey | DrupalDefaultEntityController | protected
$revisionKey | DrupalDefaultEntityController | protected
$revisionTable | DrupalDefaultEntityController | protected
__construct($entityType) | DrupalDefaultEntityController |
attachLoad(&$queried_entities, $revision_id=FALSE) | DrupalDefaultEntityController | protected
buildQuery($ids, $conditions=array(), $revision_id=FALSE) | TaxonomyTermController | protected
cacheGet($ids, $conditions=array()) | TaxonomyTermController | protected
cacheSet($entities) | DrupalDefaultEntityController | protected
load($ids=array(), $conditions=array()) | DrupalDefaultEntityController |
resetCache(array $ids=NULL) | DrupalDefaultEntityController |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/menu/menu.admin.inc Source File

  • modules
  • menu
menu.admin.inc
Go to the documentation of this file.
1 <?php
2
11 function menu_overview_page() {
12 $result = db_query("SELECT * FROM {menu_custom} ORDER BY title", array(), array('fetch' => PDO::FETCH_ASSOC));
13 $header = array(t('Title'), array('data' => t('Operations'), 'colspan' => '3'));
14 $rows = array();
15 foreach ($result as $menu) {
16 $row = array(theme('menu_admin_overview', array('title' => $menu['title'], 'name' => $menu['menu_name'], 'description' => $menu['description'])));
17 $row[] = array('data' => l(t('list links'), 'admin/structure/menu/manage/' . $menu['menu_name']));
18 $row[] = array('data' => l(t('edit menu'), 'admin/structure/menu/manage/' . $menu['menu_name'] . '/edit'));
19 $row[] = array('data' => l(t('add link'), 'admin/structure/menu/manage/' . $menu['menu_name'] . '/add'));
20 $rows[] = $row;
21 }
22
23 return theme('table', array('header' => $header, 'rows' => $rows));
24 }
25
36 function theme_menu_admin_overview($variables) {
37 $output = check_plain($variables['title']);
38 $output .= '<div class="description">' . filter_xss_admin($variables['description']) . '</div>';
39
40 return $output;
41 }
42
49 function menu_overview_form($form, &$form_state, $menu) {
50 global $menu_admin;
51 $form['#attached']['css'] = array(drupal_get_path('module', 'menu') . '/menu.css');
52 $sql = "
53 SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.delivery_callback, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
54 FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
55 WHERE ml.menu_name = :menu
56 ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC";
57 $result = db_query($sql, array(':menu' => $menu['menu_name']), array('fetch' => PDO::FETCH_ASSOC));
58 $links = array();
59 foreach ($result as $item) {
60 $links[] = $item;
61 }
62 $tree = menu_tree_data($links);
63 $node_links = array();
64 menu_tree_collect_node_links($tree, $node_links);
65 // We indicate that a menu administrator is running the menu access check.
66 $menu_admin = TRUE;
67 menu_tree_check_access($tree, $node_links);
68 $menu_admin = FALSE;
69
70 $form = array_merge($form, _menu_overview_tree_form($tree));
71 $form['#menu'] = $menu;
72
73 if (element_children($form)) {
74 $form['actions'] = array('#type' => 'actions');
75 $form['actions']['submit'] = array(
76 '#type' => 'submit',
77 '#value' => t('Save configuration'),
78 );
79 }
80 else {
81 $form['#empty_text'] = t('There are no menu links yet. <a href="@link">Add link</a>.', array('@link' => url('admin/structure/menu/manage/'. $form['#menu']['menu_name'] .'/add')));
82 }
83 return $form;
84 }
85
92 function _menu_overview_tree_form($tree) {
93 $form = &drupal_static(__FUNCTION__, array('#tree' => TRUE));
94 foreach ($tree as $data) {
95 $title = '';
96 $item = $data['link'];
97 // Don't show callbacks; these have $item['hidden'] < 0.
98 if ($item && $item['hidden'] >= 0) {
99 $mlid = 'mlid:' . $item['mlid'];
100 $form[$mlid]['#item'] = $item;
101 $form[$mlid]['#attributes'] = $item['hidden'] ? array('class' => array('menu-disabled')) : array('class' => array('menu-enabled'));
102 $form[$mlid]['title']['#markup'] = l($item['title'], $item['href'], $item['localized_options']);
103 if ($item['hidden']) {
104 $form[$mlid]['title']['#markup'] .= ' (' . t('disabled') . ')';
105 }
106 elseif ($item['link_path'] == 'user' && $item['module'] == 'system') {
107 $form[$mlid]['title']['#markup'] .= ' (' . t('logged in users only') . ')';
108 }
109
110 $form[$mlid]['hidden'] = array(
111 '#type' => 'checkbox',
112 '#title' => t('Enable @title menu link', array('@title' => $item['title'])),
113 '#title_display' => 'invisible',
114 '#default_value' => !$item['hidden'],
115 );
116 $form[$mlid]['weight'] = array(
117 '#type' => 'weight',
118 '#delta' => 50,
119 '#default_value' => $item['weight'],
120 '#title_display' => 'invisible',
121 '#title' => t('Weight for @title', array('@title' => $item['title'])),
122 );
123 $form[$mlid]['mlid'] = array(
124 '#type' => 'hidden',
125 '#value' => $item['mlid'],
126 );
127 $form[$mlid]['plid'] = array(
128 '#type' => 'hidden',
129 '#default_value' => $item['plid'],
130 );
131 // Build a list of operations.
132 $operations = array();
133 $operations['edit'] = array('#type' => 'link', '#title' => t('edit'), '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/edit');
134 // Only items created by the menu module can be deleted.
135 if ($item['module'] == 'menu' || $item['updated'] == 1) {
136 $operations['delete'] = array('#type' => 'link', '#title' => t('delete'), '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/delete');
137 }
138 // Set the reset column.
139 elseif ($item['module'] == 'system' && $item['customized']) {
140 $operations['reset'] = array('#type' => 'link', '#title' => t('reset'), '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/reset');
141 }
142 $form[$mlid]['operations'] = $operations;
143 }
144
145 if ($data['below']) {
146 _menu_overview_tree_form($data['below']);
147 }
148 }
149 return $form;
150 }
151
160 function menu_overview_form_submit($form, &$form_state) {
161 // When dealing with saving menu items, the order in which these items are
162 // saved is critical. If a changed child item is saved before its parent,
163 // the child item could be saved with an invalid path past its immediate
164 // parent. To prevent this, save items in the form in the same order they
165 // are sent by $_POST, ensuring parents are saved first, then their children.
166 // See http://drupal.org/node/181126#comment-632270
167 $order = array_flip(array_keys($form_state['input'])); // Get the $_POST order.
168 $form = array_merge($order, $form); // Update our original form with the new order.
169
170 $updated_items = array();
171 $fields = array('weight', 'plid');
172 foreach (element_children($form) as $mlid) {
173 if (isset($form[$mlid]['#item'])) {
174 $element = $form[$mlid];
175 // Update any fields that have changed in this menu item.
176 foreach ($fields as $field) {
177 if ($element[$field]['#value'] != $element[$field]['#default_value']) {
178 $element['#item'][$field] = $element[$field]['#value'];
179 $updated_items[$mlid] = $element['#item'];
180 }
181 }
182 // Hidden is a special case, the value needs to be reversed.
183 if ($element['hidden']['#value'] != $element['hidden']['#default_value']) {
184 // Convert to integer rather than boolean due to PDO cast to string.
185 $element['#item']['hidden'] = $element['hidden']['#value'] ? 0 : 1;
186 $updated_items[$mlid] = $element['#item'];
187 }
188 }
189 }
190
191 // Save all our changed items to the database.
192 foreach ($updated_items as $item) {
193 $item['customized'] = 1;
194 menu_link_save($item);
195 }
196 drupal_set_message(t('Your configuration has been saved.'));
197 }
198
208 function theme_menu_overview_form($variables) {
209 $form = $variables['form'];
210
211 drupal_add_tabledrag('menu-overview', 'match', 'parent', 'menu-plid', 'menu-plid', 'menu-mlid', TRUE, MENU_MAX_DEPTH - 1);
212 drupal_add_tabledrag('menu-overview', 'order', 'sibling', 'menu-weight');
213
214 $header = array(
215 t('Menu link'),
216 array('data' => t('Enabled'), 'class' => array('checkbox')),
217 t('Weight'),
218 array('data' => t('Operations'), 'colspan' => '3'),
219 );
220
221 $rows = array();
222 foreach (element_children($form) as $mlid) {
223 if (isset($form[$mlid]['hidden'])) {
224 $element = &$form[$mlid];
225 // Build a list of operations.
226 $operations = array();
227 foreach (element_children($element['operations']) as $op) {
228 $operations[] = array('data' => drupal_render($element['operations'][$op]), 'class' => array('menu-operations'));
229 }
230 while (count($operations) < 2) {
231 $operations[] = '';
232 }
233
234 // Add special classes to be used for tabledrag.js.
235 $element['plid']['#attributes']['class'] = array('menu-plid');
236 $element['mlid']['#attributes']['class'] = array('menu-mlid');
237 $element['weight']['#attributes']['class'] = array('menu-weight');
238
239 // Change the parent field to a hidden. This allows any value but hides the field.
240 $element['plid']['#type'] = 'hidden';
241
242 $row = array();
243 $row[] = theme('indentation', array('size' => $element['#item']['depth'] - 1)) . drupal_render($element['title']);
244 $row[] = array('data' => drupal_render($element['hidden']), 'class' => array('checkbox', 'menu-enabled'));
245 $row[] = drupal_render($element['weight']) . drupal_render($element['plid']) . drupal_render($element['mlid']);
246 $row = array_merge($row, $operations);
247
248 $row = array_merge(array('data' => $row), $element['#attributes']);
249 $row['class'][] = 'draggable';
250 $rows[] = $row;
251 }
252 }
253 $output = '';
254 if (empty($rows)) {
255 $rows[] = array(array('data' => $form['#empty_text'], 'colspan' => '7'));
256 }
257 $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'menu-overview')));
258 $output .= drupal_render_children($form);
259 return $output;
260 }
261
265 function menu_edit_item($form, &$form_state, $type, $item, $menu) {
266 if ($type == 'add' || empty($item)) {
267 // This is an add form, initialize the menu link.
268 $item = array('link_title' => '', 'mlid' => 0, 'plid' => 0, 'menu_name' => $menu['menu_name'], 'weight' => 0, 'link_path' => '', 'options' => array(), 'module' => 'menu', 'expanded' => 0, 'hidden' => 0, 'has_children' => 0);
269 }
270 else {
271 // Get the human-readable menu title from the given menu name.
272 $titles = menu_get_menus();
273 $current_title = $titles[$item['menu_name']];
274
275 // Get the current breadcrumb and add a link to that menu's overview page.
276 $breadcrumb = menu_get_active_breadcrumb();
277 $breadcrumb[] = l($current_title, 'admin/structure/menu/manage/' . $item['menu_name']);
278 drupal_set_breadcrumb($breadcrumb);
279 }
280 $form['actions'] = array('#type' => 'actions');
281 $form['link_title'] = array(
282 '#type' => 'textfield',
283 '#title' => t('Menu link title'),
284 '#default_value' => $item['link_title'],
285 '#description' => t('The text to be used for this link in the menu.'),
286 '#required' => TRUE,
287 );
288 foreach (array('link_path', 'mlid', 'module', 'has_children', 'options') as $key) {
289 $form[$key] = array('#type' => 'value', '#value' => $item[$key]);
290 }
291 // Any item created or edited via this interface is considered "customized".
292 $form['customized'] = array('#type' => 'value', '#value' => 1);
293 $form['original_item'] = array('#type' => 'value', '#value' => $item);
294
295 $path = $item['link_path'];
296 if (isset($item['options']['query'])) {
297 $path .= '?' . drupal_http_build_query($item['options']['query']);
298 }
299 if (isset($item['options']['fragment'])) {
300 $path .= '#' . $item['options']['fragment'];
301 }
302 if ($item['module'] == 'menu') {
303 $form['link_path'] = array(
304 '#type' => 'textfield',
305 '#title' => t('Path'),
306 '#maxlength' => 255,
307 '#default_value' => $path,
308 '#description' => t('The path for this menu link. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page.', array('%front' => '<front>', '%add-node' => 'node/add', '%drupal' => 'http://drupal.org')),
309 '#required' => TRUE,
310 );
311 $form['actions']['delete'] = array(
312 '#type' => 'submit',
313 '#value' => t('Delete'),
314 '#access' => $item['mlid'],
315 '#submit' => array('menu_item_delete_submit'),
316 '#weight' => 10,
317 );
318 }
319 else {
320 $form['_path'] = array(
321 '#type' => 'item',
322 '#title' => t('Path'),
323 '#description' => l($item['link_title'], $item['href'], $item['options']),
324 );
325 }
326 $form['description'] = array(
327 '#type' => 'textarea',
328 '#title' => t('Description'),
329 '#default_value' => isset($item['options']['attributes']['title']) ? $item['options']['attributes']['title'] : '',
330 '#rows' => 1,
331 '#description' => t('Shown when hovering over the menu link.'),
332 );
333 $form['enabled'] = array(
334 '#type' => 'checkbox',
335 '#title' => t('Enabled'),
336 '#default_value' => !$item['hidden'],
337 '#description' => t('Menu links that are not enabled will not be listed in any menu.'),
338 );
339 $form['expanded'] = array(
340 '#type' => 'checkbox',
341 '#title' => t('Show as expanded'),
342 '#default_value' => $item['expanded'],
343 '#description' => t('If selected and this menu link has children, the menu will always appear expanded.'),
344 );
345
346 // Generate a list of possible parents (not including this link or descendants).
347 $options = menu_parent_options(menu_get_menus(), $item);
348 $default = $item['menu_name'] . ':' . $item['plid'];
349 if (!isset($options[$default])) {
350 $default = 'navigation:0';
351 }
352 $form['parent'] = array(
353 '#type' => 'select',
354 '#title' => t('Parent link'),
355 '#default_value' => $default,
356 '#options' => $options,
357 '#description' => t('The maximum depth for a link and all its children is fixed at !maxdepth. Some menu links may not be available as parents if selecting them would exceed this limit.', array('!maxdepth' => MENU_MAX_DEPTH)),
358 '#attributes' => array('class' => array('menu-title-select')),
359 );
360 $form['weight'] = array(
361 '#type' => 'weight',
362 '#title' => t('Weight'),
363 '#delta' => 50,
364 '#default_value' => $item['weight'],
365 '#description' => t('Optional. In the menu, the heavier links will sink and the lighter links will be positioned nearer the top.'),
366 );
367 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
368
369 return $form;
370 }
371
375 function menu_edit_item_validate($form, &$form_state) {
376 $item = &$form_state['values'];
377 $normal_path = drupal_get_normal_path($item['link_path']);
378 if ($item['link_path'] != $normal_path) {
379 drupal_set_message(t('The menu system stores system paths only, but will use the URL alias for display. %link_path has been stored as %normal_path', array('%link_path' => $item['link_path'], '%normal_path' => $normal_path)));
380 $item['link_path'] = $normal_path;
381 }
382 if (!url_is_external($item['link_path'])) {
383 $parsed_link = parse_url($item['link_path']);
384 if (isset($parsed_link['query'])) {
385 $item['options']['query'] = drupal_get_query_array($parsed_link['query']);
386 }
387 else {
388 // Use unset() rather than setting to empty string
389 // to avoid redundant serialized data being stored.
390 unset($item['options']['query']);
391 }
392 if (isset($parsed_link['fragment'])) {
393 $item['options']['fragment'] = $parsed_link['fragment'];
394 }
395 else {
396 unset($item['options']['fragment']);
397 }
398 if (isset($parsed_link['path']) && $item['link_path'] != $parsed_link['path']) {
399 $item['link_path'] = $parsed_link['path'];
400 }
401 }
402 if (!trim($item['link_path']) || !drupal_valid_path($item['link_path'], TRUE)) {
403 form_set_error('link_path', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $item['link_path'])));
404 }
405 }
406
410 function menu_item_delete_submit($form, &$form_state) {
411 $form_state['redirect'] = 'admin/structure/menu/item/' . $form_state['values']['mlid'] . '/delete';
412 }
413
417 function menu_edit_item_submit($form, &$form_state) {
418 $item = &$form_state['values'];
419
420 // The value of "hidden" is the opposite of the value
421 // supplied by the "enabled" checkbox.
422 $item['hidden'] = (int) !$item['enabled'];
423 unset($item['enabled']);
424
425 $item['options']['attributes']['title'] = $item['description'];
426 list($item['menu_name'], $item['plid']) = explode(':', $item['parent']);
427 if (!menu_link_save($item)) {
428 drupal_set_message(t('There was an error saving the menu link.'), 'error');
429 }
430 else {
431 drupal_set_message(t('Your configuration has been saved.'));
432 }
433 $form_state['redirect'] = 'admin/structure/menu/manage/' . $item['menu_name'];
434 }
435
439 function menu_edit_menu($form, &$form_state, $type, $menu = array()) {
440 $system_menus = menu_list_system_menus();
441 $menu += array(
442 'menu_name' => '',
443 'old_name' => !empty($menu['menu_name']) ? $menu['menu_name'] : '',
444 'title' => '',
445 'description' => '',
446 );
447 // Allow menu_edit_menu_submit() and other form submit handlers to determine
448 // whether the menu already exists.
449 $form['#insert'] = empty($menu['old_name']);
450 $form['old_name'] = array(
451 '#type' => 'value',
452 '#value' => $menu['old_name'],
453 );
454
455 $form['title'] = array(
456 '#type' => 'textfield',
457 '#title' => t('Title'),
458 '#default_value' => $menu['title'],
459 '#required' => TRUE,
460 // The title of a system menu cannot be altered.
461 '#access' => !isset($system_menus[$menu['menu_name']]),
462 );
463
464 $form['menu_name'] = array(
465 '#type' => 'machine_name',
466 '#title' => t('Menu name'),
467 '#default_value' => $menu['menu_name'],
468 '#maxlength' => MENU_MAX_MENU_NAME_LENGTH_UI,
469 '#description' => t('A unique name to construct the URL for the menu. It must only contain lowercase letters, numbers and hyphens.'),
470 '#machine_name' => array(
471 'exists' => 'menu_edit_menu_name_exists',
472 'source' => array('title'),
473 'replace_pattern' => '[^a-z0-9-]+',
474 'replace' => '-',
475 ),
476 // A menu's machine name cannot be changed.
477 '#disabled' => !empty($menu['old_name']) || isset($system_menus[$menu['menu_name']]),
478 );
479
480 $form['description'] = array(
481 '#type' => 'textarea',
482 '#title' => t('Description'),
483 '#default_value' => $menu['description'],
484 );
485 $form['actions'] = array('#type' => 'actions');
486 $form['actions']['submit'] = array(
487 '#type' => 'submit',
488 '#value' => t('Save'),
489 );
490 // Only custom menus may be deleted.
491 $form['actions']['delete'] = array(
492 '#type' => 'submit',
493 '#value' => t('Delete'),
494 '#access' => $type == 'edit' && !isset($system_menus[$menu['menu_name']]),
495 '#submit' => array('menu_custom_delete_submit'),
496 );
497
498 return $form;
499 }
500
504 function menu_custom_delete_submit($form, &$form_state) {
505 $form_state['redirect'] = 'admin/structure/menu/manage/' . $form_state['values']['menu_name'] . '/delete';
506 }
507
511 function menu_delete_menu_page($menu) {
512 // System-defined menus may not be deleted.
513 $system_menus = menu_list_system_menus();
514 if (isset($system_menus[$menu['menu_name']])) {
515 return MENU_ACCESS_DENIED;
516 }
517 return drupal_get_form('menu_delete_menu_confirm', $menu);
518 }
519
523 function menu_delete_menu_confirm($form, &$form_state, $menu) {
524 $form['#menu'] = $menu;
525 $caption = '';
526 $num_links = db_query("SELECT COUNT(*) FROM {menu_links} WHERE menu_name = :menu", array(':menu' => $menu['menu_name']))->fetchField();
527 if ($num_links) {
528 $caption .= '<p>' . format_plural($num_links, '<strong>Warning:</strong> There is currently 1 menu link in %title. It will be deleted (system-defined items will be reset).', '<strong>Warning:</strong> There are currently @count menu links in %title. They will be deleted (system-defined links will be reset).', array('%title' => $menu['title'])) . '</p>';
529 }
530 $caption .= '<p>' . t('This action cannot be undone.') . '</p>';
531 return confirm_form($form, t('Are you sure you want to delete the custom menu %title?', array('%title' => $menu['title'])), 'admin/structure/menu/manage/' . $menu['menu_name'], $caption, t('Delete'));
532 }
533
537 function menu_delete_menu_confirm_submit($form, &$form_state) {
538 $menu = $form['#menu'];
539 $form_state['redirect'] = 'admin/structure/menu';
540
541 // System-defined menus may not be deleted - only menus defined by this module.
542 $system_menus = menu_list_system_menus();
543 if (isset($system_menus[$menu['menu_name']]) || !(db_query("SELECT 1 FROM {menu_custom} WHERE menu_name = :menu", array(':menu' => $menu['menu_name']))->fetchField())) {
544 return;
545 }
546
547 // Reset all the menu links defined by the system via hook_menu().
548 $result = db_query("SELECT * FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path WHERE ml.menu_name = :menu AND ml.module = 'system' ORDER BY m.number_parts ASC", array(':menu' => $menu['menu_name']), array('fetch' => PDO::FETCH_ASSOC));
549 foreach ($result as $link) {
550 menu_reset_item($link);
551 }
552
553 // Delete all links to the overview page for this menu.
554 $result = db_query("SELECT mlid FROM {menu_links} ml WHERE ml.link_path = :link", array(':link' => 'admin/structure/menu/manage/' . $menu['menu_name']), array('fetch' => PDO::FETCH_ASSOC));
555 foreach ($result as $link) {
556 menu_link_delete($link['mlid']);
557 }
558
559 // Delete the custom menu and all its menu links.
560 menu_delete($menu);
561
562 $t_args = array('%title' => $menu['title']);
563 drupal_set_message(t('The custom menu %title has been deleted.', $t_args));
564 watchdog('menu', 'Deleted custom menu %title and all its menu links.', $t_args, WATCHDOG_NOTICE);
565 }
566
573 function menu_edit_menu_name_exists($value) {
574 // 'menu-' is added to the menu name to avoid name-space conflicts.
575 $value = 'menu-' . $value;
576 $custom_exists = db_query_range('SELECT 1 FROM {menu_custom} WHERE menu_name = :menu', 0, 1, array(':menu' => $value))->fetchField();
577 $link_exists = db_query_range("SELECT 1 FROM {menu_links} WHERE menu_name = :menu", 0, 1, array(':menu' => $value))->fetchField();
578
579 return $custom_exists || $link_exists;
580 }
581
585 function menu_edit_menu_submit($form, &$form_state) {
586 $menu = $form_state['values'];
587 $path = 'admin/structure/menu/manage/';
588 if ($form['#insert']) {
589 // Add 'menu-' to the menu name to help avoid name-space conflicts.
590 $menu['menu_name'] = 'menu-' . $menu['menu_name'];
591 $link['link_title'] = $menu['title'];
592 $link['link_path'] = $path . $menu['menu_name'];
593 $link['router_path'] = $path . '%';
594 $link['module'] = 'menu';
595 $link['plid'] = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :link AND module = :module", array(
596 ':link' => 'admin/structure/menu',
597 ':module' => 'system'
598 ))
599 ->fetchField();
600
601 menu_link_save($link);
602 menu_save($menu);
603 }
604 else {
605 menu_save($menu);
606 $result = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :path", array(':path' => $path . $menu['menu_name']), array('fetch' => PDO::FETCH_ASSOC));
607 foreach ($result as $m) {
608 $link = menu_link_load($m['mlid']);
609 $link['link_title'] = $menu['title'];
610 menu_link_save($link);
611 }
612 }
613 drupal_set_message(t('Your configuration has been saved.'));
614 $form_state['redirect'] = $path . $menu['menu_name'];
615 }
616
620 function menu_item_delete_page($item) {
621 // Links defined via hook_menu may not be deleted. Updated items are an
622 // exception, as they can be broken.
623 if ($item['module'] == 'system' && !$item['updated']) {
624 return MENU_ACCESS_DENIED;
625 }
626 return drupal_get_form('menu_item_delete_form', $item);
627 }
628
632 function menu_item_delete_form($form, &$form_state, $item) {
633 $form['#item'] = $item;
634 return confirm_form($form, t('Are you sure you want to delete the custom menu link %item?', array('%item' => $item['link_title'])), 'admin/structure/menu/manage/' . $item['menu_name']);
635 }
636
640 function menu_item_delete_form_submit($form, &$form_state) {
641 $item = $form['#item'];
642 menu_link_delete($item['mlid']);
643 $t_args = array('%title' => $item['link_title']);
644 drupal_set_message(t('The menu link %title has been deleted.', $t_args));
645 watchdog('menu', 'Deleted menu link %title.', $t_args, WATCHDOG_NOTICE);
646 $form_state['redirect'] = 'admin/structure/menu/manage/' . $item['menu_name'];
647 }
648
652 function menu_reset_item_confirm($form, &$form_state, $item) {
653 $form['item'] = array('#type' => 'value', '#value' => $item);
654 return confirm_form($form, t('Are you sure you want to reset the link %item to its default values?', array('%item' => $item['link_title'])), 'admin/structure/menu/manage/' . $item['menu_name'], t('Any customizations will be lost. This action cannot be undone.'), t('Reset'));
655 }
656
660 function menu_reset_item_confirm_submit($form, &$form_state) {
661 $item = $form_state['values']['item'];
662 $new_item = menu_reset_item($item);
663 drupal_set_message(t('The menu link was reset to its default settings.'));
664 $form_state['redirect'] = 'admin/structure/menu/manage/' . $new_item['menu_name'];
665 }
666
670 function menu_configure() {
671 $form['intro'] = array(
672 '#type' => 'item',
673 '#markup' => t('The menu module allows on-the-fly creation of menu links in the content authoring forms. To configure these settings for a particular content type, visit the <a href="@content-types">Content types</a> page, click the <em>edit</em> link for the content type, and go to the <em>Menu settings</em> section.', array('@content-types' => url('admin/structure/types'))),
674 );
675
676 $menu_options = menu_get_menus();
677
678 $main = variable_get('menu_main_links_source', 'main-menu');
679 $form['menu_main_links_source'] = array(
680 '#type' => 'select',
681 '#title' => t('Source for the Main links'),
682 '#default_value' => variable_get('menu_main_links_source', 'main-menu'),
683 '#empty_option' => t('No Main links'),
684 '#options' => $menu_options,
685 '#tree' => FALSE,
686 '#description' => t('Select what should be displayed as the Main links (typically at the top of the page).'),
687 );
688
689 $form['menu_secondary_links_source'] = array(
690 '#type' => 'select',
691 '#title' => t('Source for the Secondary links'),
692 '#default_value' => variable_get('menu_secondary_links_source', 'user-menu'),
693 '#empty_option' => t('No Secondary links'),
694 '#options' => $menu_options,
695 '#tree' => FALSE,
696 '#description' => t('Select the source for the Secondary links. An advanced option allows you to use the same source for both Main links (currently %main) and Secondary links: if your source menu has two levels of hierarchy, the top level menu links will appear in the Main links, and the children of the active link will appear in the Secondary links.', array('%main' => $main ? $menu_options[$main] : t('none'))),
697 );
698
699 return system_settings_form($form);
700 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
menu_item_delete_form_submit
menu_item_delete_form_submit($form, &$form_state)
Definition: menu.admin.inc:640
url_is_external
url_is_external($path)
Definition: common.inc:2311
menu_overview_page
menu_overview_page()
Definition: menu.admin.inc:11
drupal_http_build_query
drupal_http_build_query(array $query, $parent= '')
Definition: common.inc:486
menu_delete_menu_confirm
menu_delete_menu_confirm($form, &$form_state, $menu)
Definition: menu.admin.inc:523
menu_link_save
menu_link_save(&$item, $existing_item=array(), $parent_candidates=array())
Definition: menu.inc:3074
$op
$op
Definition: update.php:404
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
menu_reset_item_confirm_submit
menu_reset_item_confirm_submit($form, &$form_state)
Definition: menu.admin.inc:660
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
drupal_set_breadcrumb
drupal_set_breadcrumb($breadcrumb=NULL)
Definition: common.inc:243
menu_delete
menu_delete($menu)
Definition: menu.module:313
menu_tree_check_access
menu_tree_check_access(&$tree, $node_links=array())
Definition: menu.inc:1487
drupal_valid_path
drupal_valid_path($path, $dynamic_allowed=FALSE)
Definition: path.inc:553
MENU_ACCESS_DENIED
const MENU_ACCESS_DENIED
Definition: menu.inc:239
menu_save
menu_save($menu)
Definition: menu.module:259
menu_delete_menu_page
menu_delete_menu_page($menu)
Definition: menu.admin.inc:511
$header
print $header
Definition: forum-topic-list.tpl.php:42
menu_link_delete
menu_link_delete($mlid, $path=NULL)
Definition: menu.inc:2996
menu_reset_item
menu_reset_item($link)
Definition: menu.module:448
menu_edit_item_validate
menu_edit_item_validate($form, &$form_state)
Definition: menu.admin.inc:375
drupal_get_query_array
drupal_get_query_array($query)
Definition: common.inc:457
menu_get_active_breadcrumb
menu_get_active_breadcrumb()
Definition: menu.inc:2562
menu_configure
menu_configure()
Definition: menu.admin.inc:670
theme_menu_overview_form
theme_menu_overview_form($variables)
Definition: menu.admin.inc:208
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
menu_reset_item_confirm
menu_reset_item_confirm($form, &$form_state, $item)
Definition: menu.admin.inc:652
menu_overview_form
menu_overview_form($form, &$form_state, $menu)
Definition: menu.admin.inc:49
menu_edit_item_submit
menu_edit_item_submit($form, &$form_state)
Definition: menu.admin.inc:417
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$value
print $value
Definition: user-profile-item.tpl.php:26
menu_link_load
menu_link_load($mlid)
Definition: menu.inc:2635
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_get_normal_path
drupal_get_normal_path($path, $path_language=NULL)
Definition: path.inc:259
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
$output
$output
Definition: authorize.php:93
menu_custom_delete_submit
menu_custom_delete_submit($form, &$form_state)
Definition: menu.admin.inc:504
menu_edit_menu
menu_edit_menu($form, &$form_state, $type, $menu=array())
Definition: menu.admin.inc:439
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
menu_get_menus
menu_get_menus($all=TRUE)
Definition: menu.module:783
MENU_MAX_DEPTH
const MENU_MAX_DEPTH
Definition: menu.inc:270
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
menu_list_system_menus
menu_list_system_menus()
Definition: menu.inc:1792
menu_edit_menu_submit
menu_edit_menu_submit($form, &$form_state)
Definition: menu.admin.inc:585
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
menu_item_delete_form
menu_item_delete_form($form, &$form_state, $item)
Definition: menu.admin.inc:632
menu_parent_options
menu_parent_options($menus, $item, $type= '')
Definition: menu.module:353
menu_item_delete_submit
menu_item_delete_submit($form, &$form_state)
Definition: menu.admin.inc:410
$breadcrumb
print $breadcrumb
Definition: page.tpl.php:40
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
menu_overview_form_submit
menu_overview_form_submit($form, &$form_state)
Definition: menu.admin.inc:160
$row
$row
Definition: block-admin-display-form.tpl.php:47
menu_edit_item
menu_edit_item($form, &$form_state, $type, $item, $menu)
Definition: menu.admin.inc:265
MENU_MAX_MENU_NAME_LENGTH_UI
const MENU_MAX_MENU_NAME_LENGTH_UI
Definition: menu.module:18
_menu_overview_tree_form
_menu_overview_tree_form($tree)
Definition: menu.admin.inc:92
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
menu_tree_collect_node_links
menu_tree_collect_node_links(&$tree, &$node_links)
Definition: menu.inc:1463
$tree
if($tree||$has_links) print $tree
Definition: book-navigation.tpl.php:35
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
theme_menu_admin_overview
theme_menu_admin_overview($variables)
Definition: menu.admin.inc:36
system_settings_form
system_settings_form($form)
Definition: system.module:2755
menu_item_delete_page
menu_item_delete_page($item)
Definition: menu.admin.inc:620
menu_delete_menu_confirm_submit
menu_delete_menu_confirm_submit($form, &$form_state)
Definition: menu.admin.inc:537
menu_edit_menu_name_exists
menu_edit_menu_name_exists($value)
Definition: menu.admin.inc:573
menu_tree_data
menu_tree_data(array $links, array $parents=array(), $depth=1)
Definition: menu.inc:1554
$links
print $links
Definition: poll-results--block.tpl.php:28
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/entity.inc Source File

  • includes
entity.inc
Go to the documentation of this file.
1 <?php
2
14 interface DrupalEntityControllerInterface {
15
23 public function resetCache(array $ids = NULL);
24
37 public function load($ids = array(), $conditions = array());
38 }
39
46 class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
47
53 protected $entityCache;
54
60 protected $entityType;
61
69 protected $entityInfo;
70
78 protected $hookLoadArguments;
79
85 protected $idKey;
86
94 protected $revisionKey;
95
101 protected $revisionTable;
102
110 protected $cache;
111
118 public function __construct($entityType) {
119 $this->entityType = $entityType;
120 $this->entityInfo = entity_get_info($entityType);
121 $this->entityCache = array();
122 $this->hookLoadArguments = array();
123 $this->idKey = $this->entityInfo['entity keys']['id'];
124
125 // Check if the entity type supports revisions.
126 if (!empty($this->entityInfo['entity keys']['revision'])) {
127 $this->revisionKey = $this->entityInfo['entity keys']['revision'];
128 $this->revisionTable = $this->entityInfo['revision table'];
129 }
130 else {
131 $this->revisionKey = FALSE;
132 }
133
134 // Check if the entity type supports static caching of loaded entities.
135 $this->cache = !empty($this->entityInfo['static cache']);
136 }
137
141 public function resetCache(array $ids = NULL) {
142 if (isset($ids)) {
143 foreach ($ids as $id) {
144 unset($this->entityCache[$id]);
145 }
146 }
147 else {
148 $this->entityCache = array();
149 }
150 }
151
155 public function load($ids = array(), $conditions = array()) {
156 $entities = array();
157
158 // Revisions are not statically cached, and require a different query to
159 // other conditions, so separate the revision id into its own variable.
160 if ($this->revisionKey && isset($conditions[$this->revisionKey])) {
161 $revision_id = $conditions[$this->revisionKey];
162 unset($conditions[$this->revisionKey]);
163 }
164 else {
165 $revision_id = FALSE;
166 }
167
168 // Create a new variable which is either a prepared version of the $ids
169 // array for later comparison with the entity cache, or FALSE if no $ids
170 // were passed. The $ids array is reduced as items are loaded from cache,
171 // and we need to know if it's empty for this reason to avoid querying the
172 // database when all requested entities are loaded from cache.
173 $passed_ids = !empty($ids) ? array_flip($ids) : FALSE;
174 // Try to load entities from the static cache, if the entity type supports
175 // static caching.
176 if ($this->cache && !$revision_id) {
177 $entities += $this->cacheGet($ids, $conditions);
178 // If any entities were loaded, remove them from the ids still to load.
179 if ($passed_ids) {
180 $ids = array_keys(array_diff_key($passed_ids, $entities));
181 }
182 }
183
184 // Load any remaining entities from the database. This is the case if $ids
185 // is set to FALSE (so we load all entities), if there are any ids left to
186 // load, if loading a revision, or if $conditions was passed without $ids.
187 if ($ids === FALSE || $ids || $revision_id || ($conditions && !$passed_ids)) {
188 // Build the query.
189 $query = $this->buildQuery($ids, $conditions, $revision_id);
190 $queried_entities = $query
191 ->execute()
192 ->fetchAllAssoc($this->idKey);
193 }
194
195 // Pass all entities loaded from the database through $this->attachLoad(),
196 // which attaches fields (if supported by the entity type) and calls the
197 // entity type specific load callback, for example hook_node_load().
198 if (!empty($queried_entities)) {
199 $this->attachLoad($queried_entities, $revision_id);
200 $entities += $queried_entities;
201 }
202
203 if ($this->cache) {
204 // Add entities to the cache if we are not loading a revision.
205 if (!empty($queried_entities) && !$revision_id) {
206 $this->cacheSet($queried_entities);
207 }
208 }
209
210 // Ensure that the returned array is ordered the same as the original
211 // $ids array if this was passed in and remove any invalid ids.
212 if ($passed_ids) {
213 // Remove any invalid ids from the array.
214 $passed_ids = array_intersect_key($passed_ids, $entities);
215 foreach ($entities as $entity) {
216 $passed_ids[$entity->{$this->idKey}] = $entity;
217 }
218 $entities = $passed_ids;
219 }
220
221 return $entities;
222 }
223
247 protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
248 $query = db_select($this->entityInfo['base table'], 'base');
249
250 $query->addTag($this->entityType . '_load_multiple');
251
252 if ($revision_id) {
253 $query->join($this->revisionTable, 'revision', "revision.{$this->idKey} = base.{$this->idKey} AND revision.{$this->revisionKey} = :revisionId", array(':revisionId' => $revision_id));
254 }
255 elseif ($this->revisionKey) {
256 $query->join($this->revisionTable, 'revision', "revision.{$this->revisionKey} = base.{$this->revisionKey}");
257 }
258
259 // Add fields from the {entity} table.
260 $entity_fields = $this->entityInfo['schema_fields_sql']['base table'];
261
262 if ($this->revisionKey) {
263 // Add all fields from the {entity_revision} table.
264 $entity_revision_fields = drupal_map_assoc($this->entityInfo['schema_fields_sql']['revision table']);
265 // The id field is provided by entity, so remove it.
266 unset($entity_revision_fields[$this->idKey]);
267
268 // Remove all fields from the base table that are also fields by the same
269 // name in the revision table.
270 $entity_field_keys = array_flip($entity_fields);
271 foreach ($entity_revision_fields as $key => $name) {
272 if (isset($entity_field_keys[$name])) {
273 unset($entity_fields[$entity_field_keys[$name]]);
274 }
275 }
276 $query->fields('revision', $entity_revision_fields);
277 }
278
279 $query->fields('base', $entity_fields);
280
281 if ($ids) {
282 $query->condition("base.{$this->idKey}", $ids, 'IN');
283 }
284 if ($conditions) {
285 foreach ($conditions as $field => $value) {
286 $query->condition('base.' . $field, $value);
287 }
288 }
289 return $query;
290 }
291
309 protected function attachLoad(&$queried_entities, $revision_id = FALSE) {
310 // Attach fields.
311 if ($this->entityInfo['fieldable']) {
312 if ($revision_id) {
313 field_attach_load_revision($this->entityType, $queried_entities);
314 }
315 else {
316 field_attach_load($this->entityType, $queried_entities);
317 }
318 }
319
320 // Call hook_entity_load().
321 foreach (module_implements('entity_load') as $module) {
322 $function = $module . '_entity_load';
323 $function($queried_entities, $this->entityType);
324 }
325 // Call hook_TYPE_load(). The first argument for hook_TYPE_load() are
326 // always the queried entities, followed by additional arguments set in
327 // $this->hookLoadArguments.
328 $args = array_merge(array($queried_entities), $this->hookLoadArguments);
329 foreach (module_implements($this->entityInfo['load hook']) as $module) {
330 call_user_func_array($module . '_' . $this->entityInfo['load hook'], $args);
331 }
332 }
333
345 protected function cacheGet($ids, $conditions = array()) {
346 $entities = array();
347 // Load any available entities from the internal cache.
348 if (!empty($this->entityCache)) {
349 if ($ids) {
350 $entities += array_intersect_key($this->entityCache, array_flip($ids));
351 }
352 // If loading entities only by conditions, fetch all available entities
353 // from the cache. Entities which don't match are removed later.
354 elseif ($conditions) {
355 $entities = $this->entityCache;
356 }
357 }
358
359 // Exclude any entities loaded from cache if they don't match $conditions.
360 // This ensures the same behavior whether loading from memory or database.
361 if ($conditions) {
362 foreach ($entities as $entity) {
363 $entity_values = (array) $entity;
364 if (array_diff_assoc($conditions, $entity_values)) {
365 unset($entities[$entity->{$this->idKey}]);
366 }
367 }
368 }
369 return $entities;
370 }
371
378 protected function cacheSet($entities) {
379 $this->entityCache += $entities;
380 }
381 }
382
390 class EntityFieldQueryException extends Exception {}
391
420 class EntityFieldQuery {
421
427 const RETURN_ALL = NULL;
428
437 public $altered = FALSE;
438
446 public $entityConditions = array();
447
455 public $fieldConditions = array();
456
470 public $fieldMetaConditions = array();
471
479 public $propertyConditions = array();
480
486 public $order = array();
487
495 public $range = array();
496
504 public $pager = array();
505
514 public $deleted = FALSE;
515
526 public $fields = array();
527
533 public $count = FALSE;
534
542 public $age = FIELD_LOAD_CURRENT;
543
551 public $tags = array();
552
560 public $metaData = array();
561
569 public $orderedResults = array();
570
578 public $executeCallback = '';
579
617 public function entityCondition($name, $value, $operator = NULL) {
618 // The '!=' operator is deprecated in favour of the '<>' operator since the
619 // latter is ANSI SQL compatible.
620 if ($operator == '!=') {
621 $operator = '<>';
622 }
623 $this->entityConditions[$name] = array(
624 'value' => $value,
625 'operator' => $operator,
626 );
627 return $this;
628 }
629
657 public function fieldCondition($field, $column = NULL, $value = NULL, $operator = NULL, $delta_group = NULL, $language_group = NULL) {
658 return $this->addFieldCondition($this->fieldConditions, $field, $column, $value, $operator, $delta_group, $language_group);
659 }
660
683 public function fieldLanguageCondition($field, $value = NULL, $operator = NULL, $delta_group = NULL, $language_group = NULL) {
684 return $this->addFieldCondition($this->fieldMetaConditions, $field, 'language', $value, $operator, $delta_group, $language_group);
685 }
686
709 public function fieldDeltaCondition($field, $value = NULL, $operator = NULL, $delta_group = NULL, $language_group = NULL) {
710 return $this->addFieldCondition($this->fieldMetaConditions, $field, 'delta', $value, $operator, $delta_group, $language_group);
711 }
712
756 protected function addFieldCondition(&$conditions, $field, $column = NULL, $value = NULL, $operator = NULL, $delta_group = NULL, $language_group = NULL) {
757 // The '!=' operator is deprecated in favour of the '<>' operator since the
758 // latter is ANSI SQL compatible.
759 if ($operator == '!=') {
760 $operator = '<>';
761 }
762 if (is_scalar($field)) {
763 $field_definition = field_info_field($field);
764 if (empty($field_definition)) {
765 throw new EntityFieldQueryException(t('Unknown field: @field_name', array('@field_name' => $field)));
766 }
767 $field = $field_definition;
768 }
769 // Ensure the same index is used for field conditions as for fields.
770 $index = count($this->fields);
771 $this->fields[$index] = $field;
772 if (isset($column)) {
773 $conditions[$index] = array(
774 'field' => $field,
775 'column' => $column,
776 'value' => $value,
777 'operator' => $operator,
778 'delta_group' => $delta_group,
779 'language_group' => $language_group,
780 );
781 }
782 return $this;
783 }
784
815 public function propertyCondition($column, $value, $operator = NULL) {
816 // The '!=' operator is deprecated in favour of the '<>' operator since the
817 // latter is ANSI SQL compatible.
818 if ($operator == '!=') {
819 $operator = '<>';
820 }
821 $this->propertyConditions[] = array(
822 'column' => $column,
823 'value' => $value,
824 'operator' => $operator,
825 );
826 return $this;
827 }
828
846 public function entityOrderBy($name, $direction = 'ASC') {
847 $this->order[] = array(
848 'type' => 'entity',
849 'specifier' => $name,
850 'direction' => $direction,
851 );
852 return $this;
853 }
854
874 public function fieldOrderBy($field, $column, $direction = 'ASC') {
875 if (is_scalar($field)) {
876 $field_definition = field_info_field($field);
877 if (empty($field_definition)) {
878 throw new EntityFieldQueryException(t('Unknown field: @field_name', array('@field_name' => $field)));
879 }
880 $field = $field_definition;
881 }
882 // Save the index used for the new field, for later use in field storage.
883 $index = count($this->fields);
884 $this->fields[$index] = $field;
885 $this->order[] = array(
886 'type' => 'field',
887 'specifier' => array(
888 'field' => $field,
889 'index' => $index,
890 'column' => $column,
891 ),
892 'direction' => $direction,
893 );
894 return $this;
895 }
896
915 public function propertyOrderBy($column, $direction = 'ASC') {
916 $this->order[] = array(
917 'type' => 'property',
918 'specifier' => $column,
919 'direction' => $direction,
920 );
921 return $this;
922 }
923
930 public function count() {
931 $this->count = TRUE;
932 return $this;
933 }
934
947 public function range($start = NULL, $length = NULL) {
948 $this->range = array(
949 'start' => $start,
950 'length' => $length,
951 );
952 return $this;
953 }
954
968 public function pager($limit = 10, $element = NULL) {
969 if (!isset($element)) {
970 $element = PagerDefault::$maxElement++;
971 }
972 elseif ($element >= PagerDefault::$maxElement) {
973 PagerDefault::$maxElement = $element + 1;
974 }
975
976 $this->pager = array(
977 'limit' => $limit,
978 'element' => $element,
979 );
980 return $this;
981 }
982
993 public function tableSort(&$headers) {
994 // If 'field' is not initialized, the header columns aren't clickable
995 foreach ($headers as $key =>$header) {
996 if (is_array($header) && isset($header['specifier'])) {
997 $headers[$key]['field'] = '';
998 }
999 }
1000
1001 $order = tablesort_get_order($headers);
1002 $direction = tablesort_get_sort($headers);
1003 foreach ($headers as $header) {
1004 if (is_array($header) && ($header['data'] == $order['name'])) {
1005 if ($header['type'] == 'field') {
1006 $this->fieldOrderBy($header['specifier']['field'], $header['specifier']['column'], $direction);
1007 }
1008 else {
1009 $header['direction'] = $direction;
1010 $this->order[] = $header;
1011 }
1012 }
1013 }
1014
1015 return $this;
1016 }
1017
1028 public function deleted($deleted = TRUE) {
1029 $this->deleted = $deleted;
1030 return $this;
1031 }
1032
1049 public function age($age) {
1050 $this->age = $age;
1051 return $this;
1052 }
1053
1074 public function addTag($tag) {
1075 $this->tags[$tag] = $tag;
1076 return $this;
1077 }
1078
1095 public function addMetaData($key, $object) {
1096 $this->metaData[$key] = $object;
1097 return $this;
1098 }
1099
1131 public function execute() {
1132 // Give a chance to other modules to alter the query.
1133 drupal_alter('entity_query', $this);
1134 $this->altered = TRUE;
1135
1136 // Initialize the pager.
1137 $this->initializePager();
1138
1139 // Execute the query using the correct callback.
1140 $result = call_user_func($this->queryCallback(), $this);
1141
1142 return $result;
1143 }
1144
1151 public function queryCallback() {
1152 // Use the override from $this->executeCallback. It can be set either
1153 // while building the query, or using hook_entity_query_alter().
1154 if (function_exists($this->executeCallback)) {
1155 return $this->executeCallback;
1156 }
1157 // If there are no field conditions and sorts, and no execute callback
1158 // then we default to querying entity tables in SQL.
1159 if (empty($this->fields)) {
1160 return array($this, 'propertyQuery');
1161 }
1162 // If no override, find the storage engine to be used.
1163 foreach ($this->fields as $field) {
1164 if (!isset($storage)) {
1165 $storage = $field['storage']['module'];
1166 }
1167 elseif ($storage != $field['storage']['module']) {
1168 throw new EntityFieldQueryException(t("Can't handle more than one field storage engine"));
1169 }
1170 }
1171 if ($storage) {
1172 // Use hook_field_storage_query() from the field storage.
1173 return $storage . '_field_storage_query';
1174 }
1175 else {
1176 throw new EntityFieldQueryException(t("Field storage engine not found."));
1177 }
1178 }
1179
1188 protected function propertyQuery() {
1189 if (empty($this->entityConditions['entity_type'])) {
1190 throw new EntityFieldQueryException(t('For this query an entity type must be specified.'));
1191 }
1192 $entity_type = $this->entityConditions['entity_type']['value'];
1193 $entity_info = entity_get_info($entity_type);
1194 if (empty($entity_info['base table'])) {
1195 throw new EntityFieldQueryException(t('Entity %entity has no base table.', array('%entity' => $entity_type)));
1196 }
1197 $base_table = $entity_info['base table'];
1198 $base_table_schema = drupal_get_schema($base_table);
1199 $select_query = db_select($base_table);
1200 $select_query->addExpression(':entity_type', 'entity_type', array(':entity_type' => $entity_type));
1201 // Process the property conditions.
1202 foreach ($this->propertyConditions as $property_condition) {
1203 $this->addCondition($select_query, $base_table . '.' . $property_condition['column'], $property_condition);
1204 }
1205 // Process the four possible entity condition.
1206 // The id field is always present in entity keys.
1207 $sql_field = $entity_info['entity keys']['id'];
1208 $id_map['entity_id'] = $sql_field;
1209 $select_query->addField($base_table, $sql_field, 'entity_id');
1210 if (isset($this->entityConditions['entity_id'])) {
1211 $this->addCondition($select_query, $base_table . '.' . $sql_field, $this->entityConditions['entity_id']);
1212 }
1213
1214 // If there is a revision key defined, use it.
1215 if (!empty($entity_info['entity keys']['revision'])) {
1216 $sql_field = $entity_info['entity keys']['revision'];
1217 $select_query->addField($base_table, $sql_field, 'revision_id');
1218 if (isset($this->entityConditions['revision_id'])) {
1219 $this->addCondition($select_query, $base_table . '.' . $sql_field, $this->entityConditions['revision_id']);
1220 }
1221 }
1222 else {
1223 $sql_field = 'revision_id';
1224 $select_query->addExpression('NULL', 'revision_id');
1225 }
1226 $id_map['revision_id'] = $sql_field;
1227
1228 // Handle bundles.
1229 if (!empty($entity_info['entity keys']['bundle'])) {
1230 $sql_field = $entity_info['entity keys']['bundle'];
1231 $having = FALSE;
1232
1233 if (!empty($base_table_schema['fields'][$sql_field])) {
1234 $select_query->addField($base_table, $sql_field, 'bundle');
1235 }
1236 }
1237 else {
1238 $sql_field = 'bundle';
1239 $select_query->addExpression(':bundle', 'bundle', array(':bundle' => $entity_type));
1240 $having = TRUE;
1241 }
1242 $id_map['bundle'] = $sql_field;
1243 if (isset($this->entityConditions['bundle'])) {
1244 if (!empty($entity_info['entity keys']['bundle'])) {
1245 $this->addCondition($select_query, $base_table . '.' . $sql_field, $this->entityConditions['bundle'], $having);
1246 }
1247 else {
1248 // This entity has no bundle, so invalidate the query.
1249 $select_query->where('1 = 0');
1250 }
1251 }
1252
1253 // Order the query.
1254 foreach ($this->order as $order) {
1255 if ($order['type'] == 'entity') {
1256 $key = $order['specifier'];
1257 if (!isset($id_map[$key])) {
1258 throw new EntityFieldQueryException(t('Do not know how to order on @key for @entity_type', array('@key' => $key, '@entity_type' => $entity_type)));
1259 }
1260 $select_query->orderBy($id_map[$key], $order['direction']);
1261 }
1262 elseif ($order['type'] == 'property') {
1263 $select_query->orderBy($base_table . '.' . $order['specifier'], $order['direction']);
1264 }
1265 }
1266
1267 return $this->finishQuery($select_query);
1268 }
1269
1276 function initializePager() {
1277 if ($this->pager && !empty($this->pager['limit']) && !$this->count) {
1278 $page = pager_find_page($this->pager['element']);
1279 $count_query = clone $this;
1280 $this->pager['total'] = $count_query->count()->execute();
1281 $this->pager['start'] = $page * $this->pager['limit'];
1282 pager_default_initialize($this->pager['total'], $this->pager['limit'], $this->pager['element']);
1283 $this->range($this->pager['start'], $this->pager['limit']);
1284 }
1285 }
1286
1301 function finishQuery($select_query, $id_key = 'entity_id') {
1302 foreach ($this->tags as $tag) {
1303 $select_query->addTag($tag);
1304 }
1305 foreach ($this->metaData as $key => $object) {
1306 $select_query->addMetaData($key, $object);
1307 }
1308 $select_query->addMetaData('entity_field_query', $this);
1309 if ($this->range) {
1310 $select_query->range($this->range['start'], $this->range['length']);
1311 }
1312 if ($this->count) {
1313 return $select_query->countQuery()->execute()->fetchField();
1314 }
1315 $return = array();
1316 foreach ($select_query->execute() as $partial_entity) {
1317 $bundle = isset($partial_entity->bundle) ? $partial_entity->bundle : NULL;
1318 $entity = entity_create_stub_entity($partial_entity->entity_type, array($partial_entity->entity_id, $partial_entity->revision_id, $bundle));
1319 $return[$partial_entity->entity_type][$partial_entity->$id_key] = $entity;
1320 $this->ordered_results[] = $partial_entity;
1321 }
1322 return $return;
1323 }
1324
1341 public function addCondition(SelectQuery $select_query, $sql_field, $condition, $having = FALSE) {
1342 $method = $having ? 'havingCondition' : 'condition';
1343 $like_prefix = '';
1344 switch ($condition['operator']) {
1345 case 'CONTAINS':
1346 $like_prefix = '%';
1347 case 'STARTS_WITH':
1348 $select_query->$method($sql_field, $like_prefix . db_like($condition['value']) . '%', 'LIKE');
1349 break;
1350 default:
1351 $select_query->$method($sql_field, $condition['value'], $condition['operator']);
1352 }
1353 }
1354
1355 }
1356
1360 class EntityMalformedException extends Exception { }
DrupalDefaultEntityController\resetCache
resetCache(array $ids=NULL)
Definition: entity.inc:141
EntityMalformedException
Definition: entity.inc:1360
pager_default_initialize
pager_default_initialize($total, $limit, $element=0)
Definition: pager.inc:274
pager_find_page
pager_find_page($element=0)
Definition: pager.inc:187
DrupalEntityControllerInterface
Definition: entity.inc:14
EntityFieldQuery\propertyCondition
propertyCondition($column, $value, $operator=NULL)
Definition: entity.inc:815
EntityFieldQuery\$entityConditions
$entityConditions
Definition: entity.inc:446
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
EntityFieldQuery\addCondition
addCondition(SelectQuery $select_query, $sql_field, $condition, $having=FALSE)
Definition: entity.inc:1341
DrupalDefaultEntityController\cacheGet
cacheGet($ids, $conditions=array())
Definition: entity.inc:345
EntityFieldQuery\count
count()
Definition: entity.inc:930
EntityFieldQuery\$deleted
$deleted
Definition: entity.inc:514
DrupalDefaultEntityController\buildQuery
buildQuery($ids, $conditions=array(), $revision_id=FALSE)
Definition: entity.inc:247
DrupalDefaultEntityController\$entityInfo
$entityInfo
Definition: entity.inc:69
SelectQuery
Definition: select.inc:859
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
field_attach_load_revision
field_attach_load_revision($entity_type, $entities, $options=array())
Definition: field.attach.inc:757
$module
print $module
Definition: search-results.tpl.php:28
DrupalDefaultEntityController\$revisionKey
$revisionKey
Definition: entity.inc:94
$page
print $page
Definition: overlay.tpl.php:37
EntityFieldQuery\$age
$age
Definition: entity.inc:542
EntityFieldQuery\$order
$order
Definition: entity.inc:486
$name
print $name
Definition: profile-listing.tpl.php:43
DrupalDefaultEntityController\$revisionTable
$revisionTable
Definition: entity.inc:101
Exception
EntityFieldQuery\addFieldCondition
addFieldCondition(&$conditions, $field, $column=NULL, $value=NULL, $operator=NULL, $delta_group=NULL, $language_group=NULL)
Definition: entity.inc:756
DrupalDefaultEntityController\$hookLoadArguments
$hookLoadArguments
Definition: entity.inc:78
PagerDefault\$maxElement
static $maxElement
Definition: pager.inc:22
$header
print $header
Definition: forum-topic-list.tpl.php:42
EntityFieldQuery\fieldDeltaCondition
fieldDeltaCondition($field, $value=NULL, $operator=NULL, $delta_group=NULL, $language_group=NULL)
Definition: entity.inc:709
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
tablesort_get_order
tablesort_get_order($headers)
Definition: tablesort.inc:205
EntityFieldQuery\$propertyConditions
$propertyConditions
Definition: entity.inc:479
EntityFieldQuery\addTag
addTag($tag)
Definition: entity.inc:1074
EntityFieldQuery\$fieldConditions
$fieldConditions
Definition: entity.inc:455
EntityFieldQuery\$orderedResults
$orderedResults
Definition: entity.inc:569
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
EntityFieldQuery\range
range($start=NULL, $length=NULL)
Definition: entity.inc:947
DrupalEntityControllerInterface\resetCache
resetCache(array $ids=NULL)
EntityFieldQuery\$fields
$fields
Definition: entity.inc:526
drupal_get_schema
drupal_get_schema($table=NULL, $rebuild=FALSE)
Definition: bootstrap.inc:2940
DrupalEntityControllerInterface\load
load($ids=array(), $conditions=array())
EntityFieldQuery\$metaData
$metaData
Definition: entity.inc:560
EntityFieldQuery\fieldOrderBy
fieldOrderBy($field, $column, $direction= 'ASC')
Definition: entity.inc:874
EntityFieldQuery
Definition: entity.inc:420
$value
print $value
Definition: user-profile-item.tpl.php:26
field_attach_load
field_attach_load($entity_type, $entities, $age=FIELD_LOAD_CURRENT, $options=array())
Definition: field.attach.inc:622
DrupalDefaultEntityController\attachLoad
attachLoad(&$queried_entities, $revision_id=FALSE)
Definition: entity.inc:309
db_like
db_like($string)
Definition: database.inc:2610
DrupalDefaultEntityController\__construct
__construct($entityType)
Definition: entity.inc:118
EntityFieldQuery\age
age($age)
Definition: entity.inc:1049
EntityFieldQuery\tableSort
tableSort(&$headers)
Definition: entity.inc:993
DrupalDefaultEntityController\cacheSet
cacheSet($entities)
Definition: entity.inc:378
EntityFieldQuery\queryCallback
queryCallback()
Definition: entity.inc:1151
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
EntityFieldQuery\execute
execute()
Definition: entity.inc:1131
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
EntityFieldQuery\fieldCondition
fieldCondition($field, $column=NULL, $value=NULL, $operator=NULL, $delta_group=NULL, $language_group=NULL)
Definition: entity.inc:657
EntityFieldQuery\finishQuery
finishQuery($select_query, $id_key= 'entity_id')
Definition: entity.inc:1301
EntityFieldQuery\$fieldMetaConditions
$fieldMetaConditions
Definition: entity.inc:470
DrupalDefaultEntityController\$cache
$cache
Definition: entity.inc:110
EntityFieldQuery\RETURN_ALL
const RETURN_ALL
Definition: entity.inc:427
EntityFieldQuery\$pager
$pager
Definition: entity.inc:504
EntityFieldQuery\$altered
$altered
Definition: entity.inc:437
DrupalDefaultEntityController
Definition: entity.inc:46
EntityFieldQuery\deleted
deleted($deleted=TRUE)
Definition: entity.inc:1028
entity_create_stub_entity
entity_create_stub_entity($entity_type, $ids)
Definition: common.inc:7749
EntityFieldQuery\initializePager
initializePager()
Definition: entity.inc:1276
EntityFieldQuery\fieldLanguageCondition
fieldLanguageCondition($field, $value=NULL, $operator=NULL, $delta_group=NULL, $language_group=NULL)
Definition: entity.inc:683
EntityFieldQuery\propertyOrderBy
propertyOrderBy($column, $direction= 'ASC')
Definition: entity.inc:915
DrupalDefaultEntityController\load
load($ids=array(), $conditions=array())
Definition: entity.inc:155
EntityFieldQuery\addMetaData
addMetaData($key, $object)
Definition: entity.inc:1095
EntityFieldQuery\propertyQuery
propertyQuery()
Definition: entity.inc:1188
DrupalDefaultEntityController\$idKey
$idKey
Definition: entity.inc:85
EntityFieldQuery\entityCondition
entityCondition($name, $value, $operator=NULL)
Definition: entity.inc:617
EntityFieldQueryException
Definition: entity.inc:390
EntityFieldQuery\$range
$range
Definition: entity.inc:495
DrupalDefaultEntityController\$entityCache
$entityCache
Definition: entity.inc:53
EntityFieldQuery\$executeCallback
$executeCallback
Definition: entity.inc:578
DrupalDefaultEntityController\$entityType
$entityType
Definition: entity.inc:60
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
EntityFieldQuery\entityOrderBy
entityOrderBy($name, $direction= 'ASC')
Definition: entity.inc:846
EntityFieldQuery\pager
pager($limit=10, $element=NULL)
Definition: entity.inc:968
EntityFieldQuery\$count
$count
Definition: entity.inc:533
tablesort_get_sort
tablesort_get_sort($headers)
Definition: tablesort.inc:240
EntityFieldQuery\$tags
$tags
Definition: entity.inc:551
FIELD_LOAD_CURRENT
const FIELD_LOAD_CURRENT
Definition: field.module:268
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/field_example/field_example.install Source File

  • examples
  • field_example
field_example.install
Go to the documentation of this file.
1 <?php
24 function field_example_field_schema($field) {
25 $columns = array(
26 'rgb' => array('type' => 'varchar', 'length' => 7, 'not null' => FALSE),
27 );
28 $indexes = array(
29 'rgb' => array('rgb'),
30 );
31 return array(
32 'columns' => $columns,
33 'indexes' => $indexes,
34 );
35 }
field_example_field_schema
field_example_field_schema($field)
Definition: field_example.install:24
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/simpletest/drupal_web_test_case.php Source File

  • modules
  • simpletest
drupal_web_test_case.php
Go to the documentation of this file.
1 <?php
2
13 global $drupal_test_info;
14
20 abstract class DrupalTestCase {
26 protected $testId;
27
33 protected $databasePrefix = NULL;
34
40 protected $originalFileDirectory = NULL;
41
45 protected $timeLimit = 500;
46
52 public $results = array(
53 '#pass' => 0,
54 '#fail' => 0,
55 '#exception' => 0,
56 '#debug' => 0,
57 );
58
64 protected $assertions = array();
65
74 protected $skipClasses = array(__CLASS__ => TRUE);
75
86 protected $setup = FALSE;
87
88 protected $setupDatabasePrefix = FALSE;
89
90 protected $setupEnvironment = FALSE;
91
98 public function __construct($test_id = NULL) {
99 $this->testId = $test_id;
100 }
101
119 protected function assert($status, $message = '', $group = 'Other', array $caller = NULL) {
120 // Convert boolean status to string status.
121 if (is_bool($status)) {
122 $status = $status ? 'pass' : 'fail';
123 }
124
125 // Increment summary result counter.
126 $this->results['#' . $status]++;
127
128 // Get the function information about the call to the assertion method.
129 if (!$caller) {
130 $caller = $this->getAssertionCall();
131 }
132
133 // Creation assertion array that can be displayed while tests are running.
134 $this->assertions[] = $assertion = array(
135 'test_id' => $this->testId,
136 'test_class' => get_class($this),
137 'status' => $status,
138 'message' => $message,
139 'message_group' => $group,
140 'function' => $caller['function'],
141 'line' => $caller['line'],
142 'file' => $caller['file'],
143 );
144
145 // Store assertion for display after the test has completed.
146 try {
147 $connection = Database::getConnection('default', 'simpletest_original_default');
148 }
149 catch (DatabaseConnectionNotDefinedException $e) {
150 // If the test was not set up, the simpletest_original_default
151 // connection does not exist.
152 $connection = Database::getConnection('default', 'default');
153 }
154 $connection
155 ->insert('simpletest')
156 ->fields($assertion)
157 ->execute();
158
159 // We do not use a ternary operator here to allow a breakpoint on
160 // test failure.
161 if ($status == 'pass') {
162 return TRUE;
163 }
164 else {
165 return FALSE;
166 }
167 }
168
185 public static function insertAssert($test_id, $test_class, $status, $message = '', $group = 'Other', array $caller = array()) {
186 // Convert boolean status to string status.
187 if (is_bool($status)) {
188 $status = $status ? 'pass' : 'fail';
189 }
190
191 $caller += array(
192 'function' => t('Unknown'),
193 'line' => 0,
194 'file' => t('Unknown'),
195 );
196
197 $assertion = array(
198 'test_id' => $test_id,
199 'test_class' => $test_class,
200 'status' => $status,
201 'message' => $message,
202 'message_group' => $group,
203 'function' => $caller['function'],
204 'line' => $caller['line'],
205 'file' => $caller['file'],
206 );
207
208 return db_insert('simpletest')
209 ->fields($assertion)
210 ->execute();
211 }
212
223 public static function deleteAssert($message_id) {
224 return (bool) db_delete('simpletest')
225 ->condition('message_id', $message_id)
226 ->execute();
227 }
228
235 protected function getAssertionCall() {
236 $backtrace = debug_backtrace();
237
238 // The first element is the call. The second element is the caller.
239 // We skip calls that occurred in one of the methods of our base classes
240 // or in an assertion function.
241 while (($caller = $backtrace[1]) &&
242 ((isset($caller['class']) && isset($this->skipClasses[$caller['class']])) ||
243 substr($caller['function'], 0, 6) == 'assert')) {
244 // We remove that call.
245 array_shift($backtrace);
246 }
247
248 return _drupal_get_last_caller($backtrace);
249 }
250
263 protected function assertTrue($value, $message = '', $group = 'Other') {
264 return $this->assert((bool) $value, $message ? $message : t('Value @value is TRUE.', array('@value' => var_export($value, TRUE))), $group);
265 }
266
279 protected function assertFalse($value, $message = '', $group = 'Other') {
280 return $this->assert(!$value, $message ? $message : t('Value @value is FALSE.', array('@value' => var_export($value, TRUE))), $group);
281 }
282
295 protected function assertNull($value, $message = '', $group = 'Other') {
296 return $this->assert(!isset($value), $message ? $message : t('Value @value is NULL.', array('@value' => var_export($value, TRUE))), $group);
297 }
298
311 protected function assertNotNull($value, $message = '', $group = 'Other') {
312 return $this->assert(isset($value), $message ? $message : t('Value @value is not NULL.', array('@value' => var_export($value, TRUE))), $group);
313 }
314
329 protected function assertEqual($first, $second, $message = '', $group = 'Other') {
330 return $this->assert($first == $second, $message ? $message : t('Value @first is equal to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
331 }
332
347 protected function assertNotEqual($first, $second, $message = '', $group = 'Other') {
348 return $this->assert($first != $second, $message ? $message : t('Value @first is not equal to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
349 }
350
365 protected function assertIdentical($first, $second, $message = '', $group = 'Other') {
366 return $this->assert($first === $second, $message ? $message : t('Value @first is identical to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
367 }
368
383 protected function assertNotIdentical($first, $second, $message = '', $group = 'Other') {
384 return $this->assert($first !== $second, $message ? $message : t('Value @first is not identical to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
385 }
386
397 protected function pass($message = NULL, $group = 'Other') {
398 return $this->assert(TRUE, $message, $group);
399 }
400
411 protected function fail($message = NULL, $group = 'Other') {
412 return $this->assert(FALSE, $message, $group);
413 }
414
427 protected function error($message = '', $group = 'Other', array $caller = NULL) {
428 if ($group == 'User notice') {
429 // Since 'User notice' is set by trigger_error() which is used for debug
430 // set the message to a status of 'debug'.
431 return $this->assert('debug', $message, 'Debug', $caller);
432 }
433
434 return $this->assert('exception', $message, $group, $caller);
435 }
436
448 protected function verbose($message) {
449 if ($id = simpletest_verbose($message)) {
450 $class_safe = str_replace('\\', '_', get_class($this));
451 $url = file_create_url($this->originalFileDirectory . '/simpletest/verbose/' . $class_safe . '-' . $id . '.html');
452 $this->error(l(t('Verbose message'), $url, array('attributes' => array('target' => '_blank'))), 'User notice');
453 }
454 }
455
468 public function run(array $methods = array()) {
469 // Initialize verbose debugging.
470 $class = get_class($this);
471 simpletest_verbose(NULL, variable_get('file_public_path', conf_path() . '/files'), str_replace('\\', '_', $class));
472
473 // HTTP auth settings (<username>:<password>) for the simpletest browser
474 // when sending requests to the test site.
475 $this->httpauth_method = variable_get('simpletest_httpauth_method', CURLAUTH_BASIC);
476 $username = variable_get('simpletest_httpauth_username', NULL);
477 $password = variable_get('simpletest_httpauth_password', NULL);
478 if ($username && $password) {
479 $this->httpauth_credentials = $username . ':' . $password;
480 }
481
482 set_error_handler(array($this, 'errorHandler'));
483 // Iterate through all the methods in this class, unless a specific list of
484 // methods to run was passed.
485 $class_methods = get_class_methods($class);
486 if ($methods) {
487 $class_methods = array_intersect($class_methods, $methods);
488 }
489 foreach ($class_methods as $method) {
490 // If the current method starts with "test", run it - it's a test.
491 if (strtolower(substr($method, 0, 4)) == 'test') {
492 // Insert a fail record. This will be deleted on completion to ensure
493 // that testing completed.
494 $method_info = new ReflectionMethod($class, $method);
495 $caller = array(
496 'file' => $method_info->getFileName(),
497 'line' => $method_info->getStartLine(),
498 'function' => $class . '->' . $method . '()',
499 );
500 $completion_check_id = DrupalTestCase::insertAssert($this->testId, $class, FALSE, t('The test did not complete due to a fatal error.'), 'Completion check', $caller);
501 $this->setUp();
502 if ($this->setup) {
503 try {
504 $this->$method();
505 // Finish up.
506 }
507 catch (Exception $e) {
508 $this->exceptionHandler($e);
509 }
510 $this->tearDown();
511 }
512 else {
513 $this->fail(t("The test cannot be executed because it has not been set up properly."));
514 }
515 // Remove the completion check record.
516 DrupalTestCase::deleteAssert($completion_check_id);
517 }
518 }
519 // Clear out the error messages and restore error handler.
520 drupal_get_messages();
521 restore_error_handler();
522 }
523
530 public function errorHandler($severity, $message, $file = NULL, $line = NULL) {
531 if ($severity & error_reporting()) {
532 $error_map = array(
533 E_STRICT => 'Run-time notice',
534 E_WARNING => 'Warning',
535 E_NOTICE => 'Notice',
536 E_CORE_ERROR => 'Core error',
537 E_CORE_WARNING => 'Core warning',
538 E_USER_ERROR => 'User error',
539 E_USER_WARNING => 'User warning',
540 E_USER_NOTICE => 'User notice',
541 E_RECOVERABLE_ERROR => 'Recoverable error',
542 );
543
544 // PHP 5.3 adds new error logging constants. Add these conditionally for
545 // backwards compatibility with PHP 5.2.
546 if (defined('E_DEPRECATED')) {
547 $error_map += array(
548 E_DEPRECATED => 'Deprecated',
549 E_USER_DEPRECATED => 'User deprecated',
550 );
551 }
552
553 $backtrace = debug_backtrace();
554 $this->error($message, $error_map[$severity], _drupal_get_last_caller($backtrace));
555 }
556 return TRUE;
557 }
558
564 protected function exceptionHandler($exception) {
565 $backtrace = $exception->getTrace();
566 // Push on top of the backtrace the call that generated the exception.
567 array_unshift($backtrace, array(
568 'line' => $exception->getLine(),
569 'file' => $exception->getFile(),
570 ));
571 require_once DRUPAL_ROOT . '/includes/errors.inc';
572 // The exception message is run through check_plain() by _drupal_decode_exception().
573 $this->error(t('%type: !message in %function (line %line of %file).', _drupal_decode_exception($exception)), 'Uncaught exception', _drupal_get_last_caller($backtrace));
574 }
575
595 public static function randomString($length = 8) {
596 $str = '';
597 for ($i = 0; $i < $length; $i++) {
598 $str .= chr(mt_rand(32, 126));
599 }
600 return $str;
601 }
602
623 public static function randomName($length = 8) {
624 $values = array_merge(range(65, 90), range(97, 122), range(48, 57));
625 $max = count($values) - 1;
626 $str = chr(mt_rand(97, 122));
627 for ($i = 1; $i < $length; $i++) {
628 $str .= chr($values[mt_rand(0, $max)]);
629 }
630 return $str;
631 }
632
664 public static function generatePermutations($parameters) {
665 $all_permutations = array(array());
666 foreach ($parameters as $parameter => $values) {
667 $new_permutations = array();
668 // Iterate over all values of the parameter.
669 foreach ($values as $value) {
670 // Iterate over all existing permutations.
671 foreach ($all_permutations as $permutation) {
672 // Add the new parameter value to existing permutations.
673 $new_permutations[] = $permutation + array($parameter => $value);
674 }
675 }
676 // Replace the old permutations with the new permutations.
677 $all_permutations = $new_permutations;
678 }
679 return $all_permutations;
680 }
681 }
682
690 class DrupalUnitTestCase extends DrupalTestCase {
691
695 function __construct($test_id = NULL) {
696 parent::__construct($test_id);
697 $this->skipClasses[__CLASS__] = TRUE;
698 }
699
708 protected function setUp() {
709 global $conf;
710
711 // Store necessary current values before switching to the test environment.
712 $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files');
713
714 // Reset all statics so that test is performed with a clean environment.
715 drupal_static_reset();
716
717 // Generate temporary prefixed database to ensure that tests have a clean starting point.
718 $this->databasePrefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
719
720 // Create test directory.
721 $public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10);
722 file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
723 $conf['file_public_path'] = $public_files_directory;
724
725 // Clone the current connection and replace the current prefix.
726 $connection_info = Database::getConnectionInfo('default');
727 Database::renameConnection('default', 'simpletest_original_default');
728 foreach ($connection_info as $target => $value) {
729 $connection_info[$target]['prefix'] = array(
730 'default' => $value['prefix']['default'] . $this->databasePrefix,
731 );
732 }
733 Database::addConnectionInfo('default', 'default', $connection_info['default']);
734
735 // Set user agent to be consistent with web test case.
736 $_SERVER['HTTP_USER_AGENT'] = $this->databasePrefix;
737
738 // If locale is enabled then t() will try to access the database and
739 // subsequently will fail as the database is not accessible.
740 $module_list = module_list();
741 if (isset($module_list['locale'])) {
742 // Transform the list into the format expected as input to module_list().
743 foreach ($module_list as &$module) {
744 $module = array('filename' => drupal_get_filename('module', $module));
745 }
746 $this->originalModuleList = $module_list;
747 unset($module_list['locale']);
748 module_list(TRUE, FALSE, FALSE, $module_list);
749 }
750 $this->setup = TRUE;
751 }
752
753 protected function tearDown() {
754 global $conf;
755
756 // Get back to the original connection.
757 Database::removeConnection('default');
758 Database::renameConnection('simpletest_original_default', 'default');
759
760 $conf['file_public_path'] = $this->originalFileDirectory;
761 // Restore modules if necessary.
762 if (isset($this->originalModuleList)) {
763 module_list(TRUE, FALSE, FALSE, $this->originalModuleList);
764 }
765 }
766 }
767
771 class DrupalWebTestCase extends DrupalTestCase {
777 protected $profile = 'standard';
778
784 protected $url;
785
791 protected $curlHandle;
792
798 protected $headers;
799
805 protected $content;
806
812 protected $plainTextContent;
813
819 protected $drupalSettings;
820
826 protected $elements = NULL;
827
833 protected $loggedInUser = FALSE;
834
841 protected $cookieFile = NULL;
842
848 protected $additionalCurlOptions = array();
849
855 protected $originalUser = NULL;
856
862 protected $originalShutdownCallbacks = array();
863
867 protected $httpauth_method = CURLAUTH_BASIC;
868
872 protected $httpauth_credentials = NULL;
873
877 protected $session_name = NULL;
878
882 protected $session_id = NULL;
883
887 protected $generatedTestFiles = FALSE;
888
892 protected $redirect_count;
893
897 function __construct($test_id = NULL) {
898 parent::__construct($test_id);
899 $this->skipClasses[__CLASS__] = TRUE;
900 }
901
913 function drupalGetNodeByTitle($title, $reset = FALSE) {
914 $nodes = node_load_multiple(array(), array('title' => $title), $reset);
915 // Load the first node returned from the database.
916 $returned_node = reset($nodes);
917 return $returned_node;
918 }
919
929 protected function drupalCreateNode($settings = array()) {
930 // Populate defaults array.
931 $settings += array(
932 'body' => array(LANGUAGE_NONE => array(array())),
933 'title' => $this->randomName(8),
934 'comment' => 2,
935 'changed' => REQUEST_TIME,
936 'moderate' => 0,
937 'promote' => 0,
938 'revision' => 1,
939 'log' => '',
940 'status' => 1,
941 'sticky' => 0,
942 'type' => 'page',
943 'revisions' => NULL,
944 'language' => LANGUAGE_NONE,
945 );
946
947 // Use the original node's created time for existing nodes.
948 if (isset($settings['created']) && !isset($settings['date'])) {
949 $settings['date'] = format_date($settings['created'], 'custom', 'Y-m-d H:i:s O');
950 }
951
952 // If the node's user uid is not specified manually, use the currently
953 // logged in user if available, or else the user running the test.
954 if (!isset($settings['uid'])) {
955 if ($this->loggedInUser) {
956 $settings['uid'] = $this->loggedInUser->uid;
957 }
958 else {
959 global $user;
960 $settings['uid'] = $user->uid;
961 }
962 }
963
964 // Merge body field value and format separately.
965 $body = array(
966 'value' => $this->randomName(32),
967 'format' => filter_default_format(),
968 );
969 $settings['body'][$settings['language']][0] += $body;
970
971 $node = (object) $settings;
972 node_save($node);
973
974 // Small hack to link revisions to our test user.
975 db_update('node_revision')
976 ->fields(array('uid' => $node->uid))
977 ->condition('vid', $node->vid)
978 ->execute();
979 return $node;
980 }
981
991 protected function drupalCreateContentType($settings = array()) {
992 // Find a non-existent random type name.
993 do {
994 $name = strtolower($this->randomName(8));
995 } while (node_type_get_type($name));
996
997 // Populate defaults array.
998 $defaults = array(
999 'type' => $name,
1000 'name' => $name,
1001 'base' => 'node_content',
1002 'description' => '',
1003 'help' => '',
1004 'title_label' => 'Title',
1005 'body_label' => 'Body',
1006 'has_title' => 1,
1007 'has_body' => 1,
1008 );
1009 // Imposed values for a custom type.
1010 $forced = array(
1011 'orig_type' => '',
1012 'old_type' => '',
1013 'module' => 'node',
1014 'custom' => 1,
1015 'modified' => 1,
1016 'locked' => 0,
1017 );
1018 $type = $forced + $settings + $defaults;
1019 $type = (object) $type;
1020
1021 $saved_type = node_type_save($type);
1022 node_types_rebuild();
1023 menu_rebuild();
1024 node_add_body_field($type);
1025
1026 $this->assertEqual($saved_type, SAVED_NEW, t('Created content type %type.', array('%type' => $type->type)));
1027
1028 // Reset permissions so that permissions for this content type are available.
1029 $this->checkPermissions(array(), TRUE);
1030
1031 return $type;
1032 }
1033
1044 protected function drupalGetTestFiles($type, $size = NULL) {
1045 if (empty($this->generatedTestFiles)) {
1046 // Generate binary test files.
1047 $lines = array(64, 1024);
1048 $count = 0;
1049 foreach ($lines as $line) {
1050 simpletest_generate_file('binary-' . $count++, 64, $line, 'binary');
1051 }
1052
1053 // Generate text test files.
1054 $lines = array(16, 256, 1024, 2048, 20480);
1055 $count = 0;
1056 foreach ($lines as $line) {
1057 simpletest_generate_file('text-' . $count++, 64, $line);
1058 }
1059
1060 // Copy other test files from simpletest.
1061 $original = drupal_get_path('module', 'simpletest') . '/files';
1062 $files = file_scan_directory($original, '/(html|image|javascript|php|sql)-.*/');
1063 foreach ($files as $file) {
1064 file_unmanaged_copy($file->uri, variable_get('file_public_path', conf_path() . '/files'));
1065 }
1066
1067 $this->generatedTestFiles = TRUE;
1068 }
1069
1070 $files = array();
1071 // Make sure type is valid.
1072 if (in_array($type, array('binary', 'html', 'image', 'javascript', 'php', 'sql', 'text'))) {
1073 $files = file_scan_directory('public://', '/' . $type . '\-.*/');
1074
1075 // If size is set then remove any files that are not of that size.
1076 if ($size !== NULL) {
1077 foreach ($files as $file) {
1078 $stats = stat($file->uri);
1079 if ($stats['size'] != $size) {
1080 unset($files[$file->uri]);
1081 }
1082 }
1083 }
1084 }
1085 usort($files, array($this, 'drupalCompareFiles'));
1086 return $files;
1087 }
1088
1092 protected function drupalCompareFiles($file1, $file2) {
1093 $compare_size = filesize($file1->uri) - filesize($file2->uri);
1094 if ($compare_size) {
1095 // Sort by file size.
1096 return $compare_size;
1097 }
1098 else {
1099 // The files were the same size, so sort alphabetically.
1100 return strnatcmp($file1->name, $file2->name);
1101 }
1102 }
1103
1115 protected function drupalCreateUser(array $permissions = array()) {
1116 // Create a role with the given permission set, if any.
1117 $rid = FALSE;
1118 if ($permissions) {
1119 $rid = $this->drupalCreateRole($permissions);
1120 if (!$rid) {
1121 return FALSE;
1122 }
1123 }
1124
1125 // Create a user assigned to that role.
1126 $edit = array();
1127 $edit['name'] = $this->randomName();
1128 $edit['mail'] = $edit['name'] . '@example.com';
1129 $edit['pass'] = user_password();
1130 $edit['status'] = 1;
1131 if ($rid) {
1132 $edit['roles'] = array($rid => $rid);
1133 }
1134
1135 $account = user_save(drupal_anonymous_user(), $edit);
1136
1137 $this->assertTrue(!empty($account->uid), t('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), t('User login'));
1138 if (empty($account->uid)) {
1139 return FALSE;
1140 }
1141
1142 // Add the raw password so that we can log in as this user.
1143 $account->pass_raw = $edit['pass'];
1144 return $account;
1145 }
1146
1157 protected function drupalCreateRole(array $permissions, $name = NULL) {
1158 // Generate random name if it was not passed.
1159 if (!$name) {
1160 $name = $this->randomName();
1161 }
1162
1163 // Check the all the permissions strings are valid.
1164 if (!$this->checkPermissions($permissions)) {
1165 return FALSE;
1166 }
1167
1168 // Create new role.
1169 $role = new stdClass();
1170 $role->name = $name;
1171 user_role_save($role);
1172 user_role_grant_permissions($role->rid, $permissions);
1173
1174 $this->assertTrue(isset($role->rid), t('Created role of name: @name, id: @rid', array('@name' => $name, '@rid' => (isset($role->rid) ? $role->rid : t('-n/a-')))), t('Role'));
1175 if ($role && !empty($role->rid)) {
1176 $count = db_query('SELECT COUNT(*) FROM {role_permission} WHERE rid = :rid', array(':rid' => $role->rid))->fetchField();
1177 $this->assertTrue($count == count($permissions), t('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), t('Role'));
1178 return $role->rid;
1179 }
1180 else {
1181 return FALSE;
1182 }
1183 }
1184
1195 protected function checkPermissions(array $permissions, $reset = FALSE) {
1196 $available = &drupal_static(__FUNCTION__);
1197
1198 if (!isset($available) || $reset) {
1199 $available = array_keys(module_invoke_all('permission'));
1200 }
1201
1202 $valid = TRUE;
1203 foreach ($permissions as $permission) {
1204 if (!in_array($permission, $available)) {
1205 $this->fail(t('Invalid permission %permission.', array('%permission' => $permission)), t('Role'));
1206 $valid = FALSE;
1207 }
1208 }
1209 return $valid;
1210 }
1211
1239 protected function drupalLogin(stdClass $account) {
1240 if ($this->loggedInUser) {
1241 $this->drupalLogout();
1242 }
1243
1244 $edit = array(
1245 'name' => $account->name,
1246 'pass' => $account->pass_raw
1247 );
1248 $this->drupalPost('user', $edit, t('Log in'));
1249
1250 // If a "log out" link appears on the page, it is almost certainly because
1251 // the login was successful.
1252 $pass = $this->assertLink(t('Log out'), 0, t('User %name successfully logged in.', array('%name' => $account->name)), t('User login'));
1253
1254 if ($pass) {
1255 $this->loggedInUser = $account;
1256 }
1257 }
1258
1262 protected function drupalGetToken($value = '') {
1263 $private_key = drupal_get_private_key();
1264 return drupal_hmac_base64($value, $this->session_id . $private_key);
1265 }
1266
1267 /*
1268 * Logs a user out of the internal browser, then check the login page to confirm logout.
1269 */
1270 protected function drupalLogout() {
1271 // Make a request to the logout page, and redirect to the user page, the
1272 // idea being if you were properly logged out you should be seeing a login
1273 // screen.
1274 $this->drupalGet('user/logout');
1275 $this->drupalGet('user');
1276 $pass = $this->assertField('name', t('Username field found.'), t('Logout'));
1277 $pass = $pass && $this->assertField('pass', t('Password field found.'), t('Logout'));
1278
1279 if ($pass) {
1280 $this->loggedInUser = FALSE;
1281 }
1282 }
1283
1298 protected function prepareDatabasePrefix() {
1299 $this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000);
1300
1301 // As soon as the database prefix is set, the test might start to execute.
1302 // All assertions as well as the SimpleTest batch operations are associated
1303 // with the testId, so the database prefix has to be associated with it.
1304 db_update('simpletest_test_id')
1305 ->fields(array('last_prefix' => $this->databasePrefix))
1306 ->condition('test_id', $this->testId)
1307 ->execute();
1308 }
1309
1315 protected function changeDatabasePrefix() {
1316 if (empty($this->databasePrefix)) {
1317 $this->prepareDatabasePrefix();
1318 // If $this->prepareDatabasePrefix() failed to work, return without
1319 // setting $this->setupDatabasePrefix to TRUE, so setUp() methods will
1320 // know to bail out.
1321 if (empty($this->databasePrefix)) {
1322 return;
1323 }
1324 }
1325
1326 // Clone the current connection and replace the current prefix.
1327 $connection_info = Database::getConnectionInfo('default');
1328 Database::renameConnection('default', 'simpletest_original_default');
1329 foreach ($connection_info as $target => $value) {
1330 $connection_info[$target]['prefix'] = array(
1331 'default' => $value['prefix']['default'] . $this->databasePrefix,
1332 );
1333 }
1334 Database::addConnectionInfo('default', 'default', $connection_info['default']);
1335
1336 // Indicate the database prefix was set up correctly.
1337 $this->setupDatabasePrefix = TRUE;
1338 }
1339
1353 protected function prepareEnvironment() {
1354 global $user, $language, $conf;
1355
1356 // Store necessary current values before switching to prefixed database.
1357 $this->originalLanguage = $language;
1358 $this->originalLanguageDefault = variable_get('language_default');
1359 $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files');
1360 $this->originalProfile = drupal_get_profile();
1361 $this->originalCleanUrl = variable_get('clean_url', 0);
1362 $this->originalUser = $user;
1363
1364 // Set to English to prevent exceptions from utf8_truncate() from t()
1365 // during install if the current language is not 'en'.
1366 // The following array/object conversion is copied from language_default().
1367 $language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '');
1368
1369 // Save and clean the shutdown callbacks array because it is static cached
1370 // and will be changed by the test run. Otherwise it will contain callbacks
1371 // from both environments and the testing environment will try to call the
1372 // handlers defined by the original one.
1373 $callbacks = &drupal_register_shutdown_function();
1374 $this->originalShutdownCallbacks = $callbacks;
1375 $callbacks = array();
1376
1377 // Create test directory ahead of installation so fatal errors and debug
1378 // information can be logged during installation process.
1379 // Use temporary files directory with the same prefix as the database.
1380 $this->public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10);
1381 $this->private_files_directory = $this->public_files_directory . '/private';
1382 $this->temp_files_directory = $this->private_files_directory . '/temp';
1383
1384 // Create the directories
1385 file_prepare_directory($this->public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
1386 file_prepare_directory($this->private_files_directory, FILE_CREATE_DIRECTORY);
1387 file_prepare_directory($this->temp_files_directory, FILE_CREATE_DIRECTORY);
1388 $this->generatedTestFiles = FALSE;
1389
1390 // Log fatal errors.
1391 ini_set('log_errors', 1);
1392 ini_set('error_log', $this->public_files_directory . '/error.log');
1393
1394 // Set the test information for use in other parts of Drupal.
1395 $test_info = &$GLOBALS['drupal_test_info'];
1396 $test_info['test_run_id'] = $this->databasePrefix;
1397 $test_info['in_child_site'] = FALSE;
1398
1399 // Indicate the environment was set up correctly.
1400 $this->setupEnvironment = TRUE;
1401 }
1402
1424 protected function setUp() {
1425 global $user, $language, $conf;
1426
1427 // Create the database prefix for this test.
1428 $this->prepareDatabasePrefix();
1429
1430 // Prepare the environment for running tests.
1431 $this->prepareEnvironment();
1432 if (!$this->setupEnvironment) {
1433 return FALSE;
1434 }
1435
1436 // Reset all statics and variables to perform tests in a clean environment.
1437 $conf = array();
1438 drupal_static_reset();
1439
1440 // Change the database prefix.
1441 // All static variables need to be reset before the database prefix is
1442 // changed, since DrupalCacheArray implementations attempt to
1443 // write back to persistent caches when they are destructed.
1444 $this->changeDatabasePrefix();
1445 if (!$this->setupDatabasePrefix) {
1446 return FALSE;
1447 }
1448
1449 // Preset the 'install_profile' system variable, so the first call into
1450 // system_rebuild_module_data() (in drupal_install_system()) will register
1451 // the test's profile as a module. Without this, the installation profile of
1452 // the parent site (executing the test) is registered, and the test
1453 // profile's hook_install() and other hook implementations are never invoked.
1454 $conf['install_profile'] = $this->profile;
1455
1456 // Perform the actual Drupal installation.
1457 include_once DRUPAL_ROOT . '/includes/install.inc';
1458 drupal_install_system();
1459
1460 $this->preloadRegistry();
1461
1462 // Set path variables.
1463 variable_set('file_public_path', $this->public_files_directory);
1464 variable_set('file_private_path', $this->private_files_directory);
1465 variable_set('file_temporary_path', $this->temp_files_directory);
1466
1467 // Set the 'simpletest_parent_profile' variable to add the parent profile's
1468 // search path to the child site's search paths.
1469 // @see drupal_system_listing()
1470 // @todo This may need to be primed like 'install_profile' above.
1471 variable_set('simpletest_parent_profile', $this->originalProfile);
1472
1473 // Include the testing profile.
1474 variable_set('install_profile', $this->profile);
1475 $profile_details = install_profile_info($this->profile, 'en');
1476
1477 // Install the modules specified by the testing profile.
1478 module_enable($profile_details['dependencies'], FALSE);
1479
1480 // Install modules needed for this test. This could have been passed in as
1481 // either a single array argument or a variable number of string arguments.
1482 // @todo Remove this compatibility layer in Drupal 8, and only accept
1483 // $modules as a single array argument.
1484 $modules = func_get_args();
1485 if (isset($modules[0]) && is_array($modules[0])) {
1486 $modules = $modules[0];
1487 }
1488 if ($modules) {
1489 $success = module_enable($modules, TRUE);
1490 $this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules))));
1491 }
1492
1493 // Run the profile tasks.
1494 $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array(
1495 ':name' => $this->profile,
1496 ))->fetchField();
1497 if ($install_profile_module_exists) {
1498 module_enable(array($this->profile), FALSE);
1499 }
1500
1501 // Reset/rebuild all data structures after enabling the modules.
1502 $this->resetAll();
1503
1504 // Run cron once in that environment, as install.php does at the end of
1505 // the installation process.
1506 drupal_cron_run();
1507
1508 // Ensure that the session is not written to the new environment and replace
1509 // the global $user session with uid 1 from the new test site.
1510 drupal_save_session(FALSE);
1511 // Login as uid 1.
1512 $user = user_load(1);
1513
1514 // Restore necessary variables.
1515 variable_set('install_task', 'done');
1516 variable_set('clean_url', $this->originalCleanUrl);
1517 variable_set('site_mail', 'simpletest@example.com');
1518 variable_set('date_default_timezone', date_default_timezone_get());
1519
1520 // Set up English language.
1521 unset($conf['language_default']);
1522 $language = language_default();
1523
1524 // Use the test mail class instead of the default mail handler class.
1525 variable_set('mail_system', array('default-system' => 'TestingMailSystem'));
1526
1527 drupal_set_time_limit($this->timeLimit);
1528 $this->setup = TRUE;
1529 }
1530
1538 protected function preloadRegistry() {
1539 // Use two separate queries, each with their own connections: copy the
1540 // {registry} and {registry_file} tables over from the parent installation
1541 // to the child installation.
1542 $original_connection = Database::getConnection('default', 'simpletest_original_default');
1543 $test_connection = Database::getConnection();
1544
1545 foreach (array('registry', 'registry_file') as $table) {
1546 // Find the records from the parent database.
1547 $source_query = $original_connection
1548 ->select($table, array(), array('fetch' => PDO::FETCH_ASSOC))
1549 ->fields($table);
1550
1551 $dest_query = $test_connection->insert($table);
1552
1553 $first = TRUE;
1554 foreach ($source_query->execute() as $row) {
1555 if ($first) {
1556 $dest_query->fields(array_keys($row));
1557 $first = FALSE;
1558 }
1559 // Insert the records into the child database.
1560 $dest_query->values($row);
1561 }
1562
1563 $dest_query->execute();
1564 }
1565 }
1566
1574 protected function resetAll() {
1575 // Reset all static variables.
1576 drupal_static_reset();
1577 // Reset the list of enabled modules.
1578 module_list(TRUE);
1579
1580 // Reset cached schema for new database prefix. This must be done before
1581 // drupal_flush_all_caches() so rebuilds can make use of the schema of
1582 // modules enabled on the cURL side.
1583 drupal_get_schema(NULL, TRUE);
1584
1585 // Perform rebuilds and flush remaining caches.
1586 drupal_flush_all_caches();
1587
1588 // Reload global $conf array and permissions.
1589 $this->refreshVariables();
1590 $this->checkPermissions(array(), TRUE);
1591 }
1592
1605 protected function refreshVariables() {
1606 global $conf;
1607 cache_clear_all('variables', 'cache_bootstrap');
1608 $conf = variable_initialize();
1609 }
1610
1615 protected function tearDown() {
1616 global $user, $language;
1617
1618 // In case a fatal error occurred that was not in the test process read the
1619 // log to pick up any fatal errors.
1620 simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE);
1621
1622 $emailCount = count(variable_get('drupal_test_email_collector', array()));
1623 if ($emailCount) {
1624 $message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.');
1625 $this->pass($message, t('E-mail'));
1626 }
1627
1628 // Delete temporary files directory.
1629 file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10));
1630
1631 // Remove all prefixed tables.
1632 $tables = db_find_tables($this->databasePrefix . '%');
1633 $connection_info = Database::getConnectionInfo('default');
1634 $tables = db_find_tables($connection_info['default']['prefix']['default'] . '%');
1635 if (empty($tables)) {
1636 $this->fail('Failed to find test tables to drop.');
1637 }
1638 $prefix_length = strlen($connection_info['default']['prefix']['default']);
1639 foreach ($tables as $table) {
1640 if (db_drop_table(substr($table, $prefix_length))) {
1641 unset($tables[$table]);
1642 }
1643 }
1644 if (!empty($tables)) {
1645 $this->fail('Failed to drop all prefixed tables.');
1646 }
1647
1648 // Get back to the original connection.
1649 Database::removeConnection('default');
1650 Database::renameConnection('simpletest_original_default', 'default');
1651
1652 // Restore original shutdown callbacks array to prevent original
1653 // environment of calling handlers from test run.
1654 $callbacks = &drupal_register_shutdown_function();
1655 $callbacks = $this->originalShutdownCallbacks;
1656
1657 // Return the user to the original one.
1658 $user = $this->originalUser;
1659 drupal_save_session(TRUE);
1660
1661 // Ensure that internal logged in variable and cURL options are reset.
1662 $this->loggedInUser = FALSE;
1663 $this->additionalCurlOptions = array();
1664
1665 // Reload module list and implementations to ensure that test module hooks
1666 // aren't called after tests.
1667 module_list(TRUE);
1668 module_implements('', FALSE, TRUE);
1669
1670 // Reset the Field API.
1671 field_cache_clear();
1672
1673 // Rebuild caches.
1674 $this->refreshVariables();
1675
1676 // Reset public files directory.
1677 $GLOBALS['conf']['file_public_path'] = $this->originalFileDirectory;
1678
1679 // Reset language.
1680 $language = $this->originalLanguage;
1681 if ($this->originalLanguageDefault) {
1682 $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
1683 }
1684
1685 // Close the CURL handler.
1686 $this->curlClose();
1687 }
1688
1697 protected function curlInitialize() {
1698 global $base_url;
1699
1700 if (!isset($this->curlHandle)) {
1701 $this->curlHandle = curl_init();
1702
1703 // Some versions/configurations of cURL break on a NULL cookie jar, so
1704 // supply a real file.
1705 if (empty($this->cookieFile)) {
1706 $this->cookieFile = $this->public_files_directory . '/cookie.jar';
1707 }
1708
1709 $curl_options = array(
1710 CURLOPT_COOKIEJAR => $this->cookieFile,
1711 CURLOPT_URL => $base_url,
1712 CURLOPT_FOLLOWLOCATION => FALSE,
1713 CURLOPT_RETURNTRANSFER => TRUE,
1714 CURLOPT_SSL_VERIFYPEER => FALSE, // Required to make the tests run on HTTPS.
1715 CURLOPT_SSL_VERIFYHOST => FALSE, // Required to make the tests run on HTTPS.
1716 CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'),
1717 CURLOPT_USERAGENT => $this->databasePrefix,
1718 );
1719 if (isset($this->httpauth_credentials)) {
1720 $curl_options[CURLOPT_HTTPAUTH] = $this->httpauth_method;
1721 $curl_options[CURLOPT_USERPWD] = $this->httpauth_credentials;
1722 }
1723 // curl_setopt_array() returns FALSE if any of the specified options
1724 // cannot be set, and stops processing any further options.
1725 $result = curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options);
1726 if (!$result) {
1727 throw new Exception('One or more cURL options could not be set.');
1728 }
1729
1730 // By default, the child session name should be the same as the parent.
1731 $this->session_name = session_name();
1732 }
1733 // We set the user agent header on each request so as to use the current
1734 // time and a new uniqid.
1735 if (preg_match('/simpletest\d+/', $this->databasePrefix, $matches)) {
1736 curl_setopt($this->curlHandle, CURLOPT_USERAGENT, drupal_generate_test_ua($matches[0]));
1737 }
1738 }
1739
1756 protected function curlExec($curl_options, $redirect = FALSE) {
1757 $this->curlInitialize();
1758
1759 // cURL incorrectly handles URLs with a fragment by including the
1760 // fragment in the request to the server, causing some web servers
1761 // to reject the request citing "400 - Bad Request". To prevent
1762 // this, we strip the fragment from the request.
1763 // TODO: Remove this for Drupal 8, since fixed in curl 7.20.0.
1764 if (!empty($curl_options[CURLOPT_URL]) && strpos($curl_options[CURLOPT_URL], '#')) {
1765 $original_url = $curl_options[CURLOPT_URL];
1766 $curl_options[CURLOPT_URL] = strtok($curl_options[CURLOPT_URL], '#');
1767 }
1768
1769 $url = empty($curl_options[CURLOPT_URL]) ? curl_getinfo($this->curlHandle, CURLINFO_EFFECTIVE_URL) : $curl_options[CURLOPT_URL];
1770
1771 if (!empty($curl_options[CURLOPT_POST])) {
1772 // This is a fix for the Curl library to prevent Expect: 100-continue
1773 // headers in POST requests, that may cause unexpected HTTP response
1774 // codes from some webservers (like lighttpd that returns a 417 error
1775 // code). It is done by setting an empty "Expect" header field that is
1776 // not overwritten by Curl.
1777 $curl_options[CURLOPT_HTTPHEADER][] = 'Expect:';
1778 }
1779 curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options);
1780
1781 if (!$redirect) {
1782 // Reset headers, the session ID and the redirect counter.
1783 $this->session_id = NULL;
1784 $this->headers = array();
1785 $this->redirect_count = 0;
1786 }
1787
1788 $content = curl_exec($this->curlHandle);
1789 $status = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
1790
1791 // cURL incorrectly handles URLs with fragments, so instead of
1792 // letting cURL handle redirects we take of them ourselves to
1793 // to prevent fragments being sent to the web server as part
1794 // of the request.
1795 // TODO: Remove this for Drupal 8, since fixed in curl 7.20.0.
1796 if (in_array($status, array(300, 301, 302, 303, 305, 307)) && $this->redirect_count < variable_get('simpletest_maximum_redirects', 5)) {
1797 if ($this->drupalGetHeader('location')) {
1798 $this->redirect_count++;
1799 $curl_options = array();
1800 $curl_options[CURLOPT_URL] = $this->drupalGetHeader('location');
1801 $curl_options[CURLOPT_HTTPGET] = TRUE;
1802 return $this->curlExec($curl_options, TRUE);
1803 }
1804 }
1805
1806 $this->drupalSetContent($content, isset($original_url) ? $original_url : curl_getinfo($this->curlHandle, CURLINFO_EFFECTIVE_URL));
1807 $message_vars = array(
1808 '!method' => !empty($curl_options[CURLOPT_NOBODY]) ? 'HEAD' : (empty($curl_options[CURLOPT_POSTFIELDS]) ? 'GET' : 'POST'),
1809 '@url' => isset($original_url) ? $original_url : $url,
1810 '@status' => $status,
1811 '!length' => format_size(strlen($this->drupalGetContent()))
1812 );
1813 $message = t('!method @url returned @status (!length).', $message_vars);
1814 $this->assertTrue($this->drupalGetContent() !== FALSE, $message, t('Browser'));
1815 return $this->drupalGetContent();
1816 }
1817
1828 protected function curlHeaderCallback($curlHandler, $header) {
1829 // Header fields can be extended over multiple lines by preceding each
1830 // extra line with at least one SP or HT. They should be joined on receive.
1831 // Details are in RFC2616 section 4.
1832 if ($header[0] == ' ' || $header[0] == "\t") {
1833 // Normalize whitespace between chucks.
1834 $this->headers[] = array_pop($this->headers) . ' ' . trim($header);
1835 }
1836 else {
1837 $this->headers[] = $header;
1838 }
1839
1840 // Errors are being sent via X-Drupal-Assertion-* headers,
1841 // generated by _drupal_log_error() in the exact form required
1842 // by DrupalWebTestCase::error().
1843 if (preg_match('/^X-Drupal-Assertion-[0-9]+: (.*)$/', $header, $matches)) {
1844 // Call DrupalWebTestCase::error() with the parameters from the header.
1845 call_user_func_array(array(&$this, 'error'), unserialize(urldecode($matches[1])));
1846 }
1847
1848 // Save cookies.
1849 if (preg_match('/^Set-Cookie: ([^=]+)=(.+)/', $header, $matches)) {
1850 $name = $matches[1];
1851 $parts = array_map('trim', explode(';', $matches[2]));
1852 $value = array_shift($parts);
1853 $this->cookies[$name] = array('value' => $value, 'secure' => in_array('secure', $parts));
1854 if ($name == $this->session_name) {
1855 if ($value != 'deleted') {
1856 $this->session_id = $value;
1857 }
1858 else {
1859 $this->session_id = NULL;
1860 }
1861 }
1862 }
1863
1864 // This is required by cURL.
1865 return strlen($header);
1866 }
1867
1871 protected function curlClose() {
1872 if (isset($this->curlHandle)) {
1873 curl_close($this->curlHandle);
1874 unset($this->curlHandle);
1875 }
1876 }
1877
1884 protected function parse() {
1885 if (!$this->elements) {
1886 // DOM can load HTML soup. But, HTML soup can throw warnings, suppress
1887 // them.
1888 $htmlDom = new DOMDocument();
1889 @$htmlDom->loadHTML($this->drupalGetContent());
1890 if ($htmlDom) {
1891 $this->pass(t('Valid HTML found on "@path"', array('@path' => $this->getUrl())), t('Browser'));
1892 // It's much easier to work with simplexml than DOM, luckily enough
1893 // we can just simply import our DOM tree.
1894 $this->elements = simplexml_import_dom($htmlDom);
1895 }
1896 }
1897 if (!$this->elements) {
1898 $this->fail(t('Parsed page successfully.'), t('Browser'));
1899 }
1900
1901 return $this->elements;
1902 }
1903
1917 protected function drupalGet($path, array $options = array(), array $headers = array()) {
1918 $options['absolute'] = TRUE;
1919
1920 // We re-using a CURL connection here. If that connection still has certain
1921 // options set, it might change the GET into a POST. Make sure we clear out
1922 // previous options.
1923 $out = $this->curlExec(array(CURLOPT_HTTPGET => TRUE, CURLOPT_URL => url($path, $options), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => $headers));
1924 $this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up.
1925
1926 // Replace original page output with new output from redirected page(s).
1927 if ($new = $this->checkForMetaRefresh()) {
1928 $out = $new;
1929 }
1930 $this->verbose('GET request to: ' . $path .
1931 '<hr />Ending URL: ' . $this->getUrl() .
1932 '<hr />' . $out);
1933 return $out;
1934 }
1935
1939 protected function drupalGetAJAX($path, array $options = array(), array $headers = array()) {
1940 return drupal_json_decode($this->drupalGet($path, $options, $headers));
1941 }
1942
2018 protected function drupalPost($path, $edit, $submit, array $options = array(), array $headers = array(), $form_html_id = NULL, $extra_post = NULL) {
2019 $submit_matches = FALSE;
2020 $ajax = is_array($submit);
2021 if (isset($path)) {
2022 $this->drupalGet($path, $options);
2023 }
2024 if ($this->parse()) {
2025 $edit_save = $edit;
2026 // Let's iterate over all the forms.
2027 $xpath = "//form";
2028 if (!empty($form_html_id)) {
2029 $xpath .= "[@id='" . $form_html_id . "']";
2030 }
2031 $forms = $this->xpath($xpath);
2032 foreach ($forms as $form) {
2033 // We try to set the fields of this form as specified in $edit.
2034 $edit = $edit_save;
2035 $post = array();
2036 $upload = array();
2037 $submit_matches = $this->handleForm($post, $edit, $upload, $ajax ? NULL : $submit, $form);
2038 $action = isset($form['action']) ? $this->getAbsoluteUrl((string) $form['action']) : $this->getUrl();
2039 if ($ajax) {
2040 $action = $this->getAbsoluteUrl(!empty($submit['path']) ? $submit['path'] : 'system/ajax');
2041 // Ajax callbacks verify the triggering element if necessary, so while
2042 // we may eventually want extra code that verifies it in the
2043 // handleForm() function, it's not currently a requirement.
2044 $submit_matches = TRUE;
2045 }
2046
2047 // We post only if we managed to handle every field in edit and the
2048 // submit button matches.
2049 if (!$edit && ($submit_matches || !isset($submit))) {
2050 $post_array = $post;
2051 if ($upload) {
2052 // TODO: cURL handles file uploads for us, but the implementation
2053 // is broken. This is a less than elegant workaround. Alternatives
2054 // are being explored at #253506.
2055 foreach ($upload as $key => $file) {
2056 $file = drupal_realpath($file);
2057 if ($file && is_file($file)) {
2058 // Use the new CurlFile class for file uploads when using PHP
2059 // 5.5 or higher.
2060 if (class_exists('CurlFile')) {
2061 $post[$key] = curl_file_create($file);
2062 }
2063 else {
2064 $post[$key] = '@' . $file;
2065 }
2066 }
2067 }
2068 }
2069 else {
2070 foreach ($post as $key => $value) {
2071 // Encode according to application/x-www-form-urlencoded
2072 // Both names and values needs to be urlencoded, according to
2073 // http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
2074 $post[$key] = urlencode($key) . '=' . urlencode($value);
2075 }
2076 $post = implode('&', $post) . $extra_post;
2077 }
2078 $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HTTPHEADER => $headers));
2079 // Ensure that any changes to variables in the other thread are picked up.
2080 $this->refreshVariables();
2081
2082 // Replace original page output with new output from redirected page(s).
2083 if ($new = $this->checkForMetaRefresh()) {
2084 $out = $new;
2085 }
2086 $this->verbose('POST request to: ' . $path .
2087 '<hr />Ending URL: ' . $this->getUrl() .
2088 '<hr />Fields: ' . highlight_string('<?php ' . var_export($post_array, TRUE), TRUE) .
2089 '<hr />' . $out);
2090 return $out;
2091 }
2092 }
2093 // We have not found a form which contained all fields of $edit.
2094 foreach ($edit as $name => $value) {
2095 $this->fail(t('Failed to set field @name to @value', array('@name' => $name, '@value' => $value)));
2096 }
2097 if (!$ajax && isset($submit)) {
2098 $this->assertTrue($submit_matches, t('Found the @submit button', array('@submit' => $submit)));
2099 }
2100 $this->fail(t('Found the requested form fields at @path', array('@path' => $path)));
2101 }
2102 }
2103
2146 protected function drupalPostAJAX($path, $edit, $triggering_element, $ajax_path = NULL, array $options = array(), array $headers = array(), $form_html_id = NULL, $ajax_settings = NULL) {
2147 // Get the content of the initial page prior to calling drupalPost(), since
2148 // drupalPost() replaces $this->content.
2149 if (isset($path)) {
2150 $this->drupalGet($path, $options);
2151 }
2152 $content = $this->content;
2153 $drupal_settings = $this->drupalSettings;
2154
2155 // Get the Ajax settings bound to the triggering element.
2156 if (!isset($ajax_settings)) {
2157 if (is_array($triggering_element)) {
2158 $xpath = '//*[@name="' . key($triggering_element) . '" and @value="' . current($triggering_element) . '"]';
2159 }
2160 else {
2161 $xpath = '//*[@name="' . $triggering_element . '"]';
2162 }
2163 if (isset($form_html_id)) {
2164 $xpath = '//form[@id="' . $form_html_id . '"]' . $xpath;
2165 }
2166 $element = $this->xpath($xpath);
2167 $element_id = (string) $element[0]['id'];
2168 $ajax_settings = $drupal_settings['ajax'][$element_id];
2169 }
2170
2171 // Add extra information to the POST data as ajax.js does.
2172 $extra_post = '';
2173 if (isset($ajax_settings['submit'])) {
2174 foreach ($ajax_settings['submit'] as $key => $value) {
2175 $extra_post .= '&' . urlencode($key) . '=' . urlencode($value);
2176 }
2177 }
2178 foreach ($this->xpath('//*[@id]') as $element) {
2179 $id = (string) $element['id'];
2180 $extra_post .= '&' . urlencode('ajax_html_ids[]') . '=' . urlencode($id);
2181 }
2182 if (isset($drupal_settings['ajaxPageState'])) {
2183 $extra_post .= '&' . urlencode('ajax_page_state[theme]') . '=' . urlencode($drupal_settings['ajaxPageState']['theme']);
2184 $extra_post .= '&' . urlencode('ajax_page_state[theme_token]') . '=' . urlencode($drupal_settings['ajaxPageState']['theme_token']);
2185 foreach ($drupal_settings['ajaxPageState']['css'] as $key => $value) {
2186 $extra_post .= '&' . urlencode("ajax_page_state[css][$key]") . '=1';
2187 }
2188 foreach ($drupal_settings['ajaxPageState']['js'] as $key => $value) {
2189 $extra_post .= '&' . urlencode("ajax_page_state[js][$key]") . '=1';
2190 }
2191 }
2192
2193 // Unless a particular path is specified, use the one specified by the
2194 // Ajax settings, or else 'system/ajax'.
2195 if (!isset($ajax_path)) {
2196 $ajax_path = isset($ajax_settings['url']) ? $ajax_settings['url'] : 'system/ajax';
2197 }
2198
2199 // Submit the POST request.
2200 $return = drupal_json_decode($this->drupalPost(NULL, $edit, array('path' => $ajax_path, 'triggering_element' => $triggering_element), $options, $headers, $form_html_id, $extra_post));
2201
2202 // Change the page content by applying the returned commands.
2203 if (!empty($ajax_settings) && !empty($return)) {
2204 // ajax.js applies some defaults to the settings object, so do the same
2205 // for what's used by this function.
2206 $ajax_settings += array(
2207 'method' => 'replaceWith',
2208 );
2209 // DOM can load HTML soup. But, HTML soup can throw warnings, suppress
2210 // them.
2211 $dom = new DOMDocument();
2212 @$dom->loadHTML($content);
2213 // XPath allows for finding wrapper nodes better than DOM does.
2214 $xpath = new DOMXPath($dom);
2215 foreach ($return as $command) {
2216 switch ($command['command']) {
2217 case 'settings':
2218 $drupal_settings = drupal_array_merge_deep($drupal_settings, $command['settings']);
2219 break;
2220
2221 case 'insert':
2222 $wrapperNode = NULL;
2223 // When a command doesn't specify a selector, use the
2224 // #ajax['wrapper'] which is always an HTML ID.
2225 if (!isset($command['selector'])) {
2226 $wrapperNode = $xpath->query('//*[@id="' . $ajax_settings['wrapper'] . '"]')->item(0);
2227 }
2228 // @todo Ajax commands can target any jQuery selector, but these are
2229 // hard to fully emulate with XPath. For now, just handle 'head'
2230 // and 'body', since these are used by ajax_render().
2231 elseif (in_array($command['selector'], array('head', 'body'))) {
2232 $wrapperNode = $xpath->query('//' . $command['selector'])->item(0);
2233 }
2234 if ($wrapperNode) {
2235 // ajax.js adds an enclosing DIV to work around a Safari bug.
2236 $newDom = new DOMDocument();
2237 $newDom->loadHTML('<div>' . $command['data'] . '</div>');
2238 $newNode = $dom->importNode($newDom->documentElement->firstChild->firstChild, TRUE);
2239 $method = isset($command['method']) ? $command['method'] : $ajax_settings['method'];
2240 // The "method" is a jQuery DOM manipulation function. Emulate
2241 // each one using PHP's DOMNode API.
2242 switch ($method) {
2243 case 'replaceWith':
2244 $wrapperNode->parentNode->replaceChild($newNode, $wrapperNode);
2245 break;
2246 case 'append':
2247 $wrapperNode->appendChild($newNode);
2248 break;
2249 case 'prepend':
2250 // If no firstChild, insertBefore() falls back to
2251 // appendChild().
2252 $wrapperNode->insertBefore($newNode, $wrapperNode->firstChild);
2253 break;
2254 case 'before':
2255 $wrapperNode->parentNode->insertBefore($newNode, $wrapperNode);
2256 break;
2257 case 'after':
2258 // If no nextSibling, insertBefore() falls back to
2259 // appendChild().
2260 $wrapperNode->parentNode->insertBefore($newNode, $wrapperNode->nextSibling);
2261 break;
2262 case 'html':
2263 foreach ($wrapperNode->childNodes as $childNode) {
2264 $wrapperNode->removeChild($childNode);
2265 }
2266 $wrapperNode->appendChild($newNode);
2267 break;
2268 }
2269 }
2270 break;
2271
2272 // @todo Add suitable implementations for these commands in order to
2273 // have full test coverage of what ajax.js can do.
2274 case 'remove':
2275 break;
2276 case 'changed':
2277 break;
2278 case 'css':
2279 break;
2280 case 'data':
2281 break;
2282 case 'restripe':
2283 break;
2284 }
2285 }
2286 $content = $dom->saveHTML();
2287 }
2288 $this->drupalSetContent($content);
2289 $this->drupalSetSettings($drupal_settings);
2290 return $return;
2291 }
2292
2296 protected function cronRun() {
2297 $this->drupalGet($GLOBALS['base_url'] . '/cron.php', array('external' => TRUE, 'query' => array('cron_key' => variable_get('cron_key', 'drupal'))));
2298 }
2299
2308 protected function checkForMetaRefresh() {
2309 if (strpos($this->drupalGetContent(), '<meta ') && $this->parse()) {
2310 $refresh = $this->xpath('//meta[@http-equiv="Refresh"]');
2311 if (!empty($refresh)) {
2312 // Parse the content attribute of the meta tag for the format:
2313 // "[delay]: URL=[page_to_redirect_to]".
2314 if (preg_match('/\d+;\s*URL=(?P<url>.*)/i', $refresh[0]['content'], $match)) {
2315 return $this->drupalGet($this->getAbsoluteUrl(decode_entities($match['url'])));
2316 }
2317 }
2318 }
2319 return FALSE;
2320 }
2321
2335 protected function drupalHead($path, array $options = array(), array $headers = array()) {
2336 $options['absolute'] = TRUE;
2337 $out = $this->curlExec(array(CURLOPT_NOBODY => TRUE, CURLOPT_URL => url($path, $options), CURLOPT_HTTPHEADER => $headers));
2338 $this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up.
2339 return $out;
2340 }
2341
2358 protected function handleForm(&$post, &$edit, &$upload, $submit, $form) {
2359 // Retrieve the form elements.
2360 $elements = $form->xpath('.//input[not(@disabled)]|.//textarea[not(@disabled)]|.//select[not(@disabled)]');
2361 $submit_matches = FALSE;
2362 foreach ($elements as $element) {
2363 // SimpleXML objects need string casting all the time.
2364 $name = (string) $element['name'];
2365 // This can either be the type of <input> or the name of the tag itself
2366 // for <select> or <textarea>.
2367 $type = isset($element['type']) ? (string) $element['type'] : $element->getName();
2368 $value = isset($element['value']) ? (string) $element['value'] : '';
2369 $done = FALSE;
2370 if (isset($edit[$name])) {
2371 switch ($type) {
2372 case 'text':
2373 case 'tel':
2374 case 'textarea':
2375 case 'url':
2376 case 'number':
2377 case 'range':
2378 case 'color':
2379 case 'hidden':
2380 case 'password':
2381 case 'email':
2382 case 'search':
2383 $post[$name] = $edit[$name];
2384 unset($edit[$name]);
2385 break;
2386 case 'radio':
2387 if ($edit[$name] == $value) {
2388 $post[$name] = $edit[$name];
2389 unset($edit[$name]);
2390 }
2391 break;
2392 case 'checkbox':
2393 // To prevent checkbox from being checked.pass in a FALSE,
2394 // otherwise the checkbox will be set to its value regardless
2395 // of $edit.
2396 if ($edit[$name] === FALSE) {
2397 unset($edit[$name]);
2398 continue 2;
2399 }
2400 else {
2401 unset($edit[$name]);
2402 $post[$name] = $value;
2403 }
2404 break;
2405 case 'select':
2406 $new_value = $edit[$name];
2407 $options = $this->getAllOptions($element);
2408 if (is_array($new_value)) {
2409 // Multiple select box.
2410 if (!empty($new_value)) {
2411 $index = 0;
2412 $key = preg_replace('/\[\]$/', '', $name);
2413 foreach ($options as $option) {
2414 $option_value = (string) $option['value'];
2415 if (in_array($option_value, $new_value)) {
2416 $post[$key . '[' . $index++ . ']'] = $option_value;
2417 $done = TRUE;
2418 unset($edit[$name]);
2419 }
2420 }
2421 }
2422 else {
2423 // No options selected: do not include any POST data for the
2424 // element.
2425 $done = TRUE;
2426 unset($edit[$name]);
2427 }
2428 }
2429 else {
2430 // Single select box.
2431 foreach ($options as $option) {
2432 if ($new_value == $option['value']) {
2433 $post[$name] = $new_value;
2434 unset($edit[$name]);
2435 $done = TRUE;
2436 break;
2437 }
2438 }
2439 }
2440 break;
2441 case 'file':
2442 $upload[$name] = $edit[$name];
2443 unset($edit[$name]);
2444 break;
2445 }
2446 }
2447 if (!isset($post[$name]) && !$done) {
2448 switch ($type) {
2449 case 'textarea':
2450 $post[$name] = (string) $element;
2451 break;
2452 case 'select':
2453 $single = empty($element['multiple']);
2454 $first = TRUE;
2455 $index = 0;
2456 $key = preg_replace('/\[\]$/', '', $name);
2457 $options = $this->getAllOptions($element);
2458 foreach ($options as $option) {
2459 // For single select, we load the first option, if there is a
2460 // selected option that will overwrite it later.
2461 if ($option['selected'] || ($first && $single)) {
2462 $first = FALSE;
2463 if ($single) {
2464 $post[$name] = (string) $option['value'];
2465 }
2466 else {
2467 $post[$key . '[' . $index++ . ']'] = (string) $option['value'];
2468 }
2469 }
2470 }
2471 break;
2472 case 'file':
2473 break;
2474 case 'submit':
2475 case 'image':
2476 if (isset($submit) && $submit == $value) {
2477 $post[$name] = $value;
2478 $submit_matches = TRUE;
2479 }
2480 break;
2481 case 'radio':
2482 case 'checkbox':
2483 if (!isset($element['checked'])) {
2484 break;
2485 }
2486 // Deliberate no break.
2487 default:
2488 $post[$name] = $value;
2489 }
2490 }
2491 }
2492 return $submit_matches;
2493 }
2494
2514 protected function buildXPathQuery($xpath, array $args = array()) {
2515 // Replace placeholders.
2516 foreach ($args as $placeholder => $value) {
2517 // XPath 1.0 doesn't support a way to escape single or double quotes in a
2518 // string literal. We split double quotes out of the string, and encode
2519 // them separately.
2520 if (is_string($value)) {
2521 // Explode the text at the quote characters.
2522 $parts = explode('"', $value);
2523
2524 // Quote the parts.
2525 foreach ($parts as &$part) {
2526 $part = '"' . $part . '"';
2527 }
2528
2529 // Return the string.
2530 $value = count($parts) > 1 ? 'concat(' . implode(', \'"\', ', $parts) . ')' : $parts[0];
2531 }
2532 $xpath = preg_replace('/' . preg_quote($placeholder) . '\b/', $value, $xpath);
2533 }
2534 return $xpath;
2535 }
2536
2548 protected function xpath($xpath, array $arguments = array()) {
2549 if ($this->parse()) {
2550 $xpath = $this->buildXPathQuery($xpath, $arguments);
2551 $result = $this->elements->xpath($xpath);
2552 // Some combinations of PHP / libxml versions return an empty array
2553 // instead of the documented FALSE. Forcefully convert any falsish values
2554 // to an empty array to allow foreach(...) constructions.
2555 return $result ? $result : array();
2556 }
2557 else {
2558 return FALSE;
2559 }
2560 }
2561
2570 protected function getAllOptions(SimpleXMLElement $element) {
2571 $options = array();
2572 // Add all options items.
2573 foreach ($element->option as $option) {
2574 $options[] = $option;
2575 }
2576
2577 // Search option group children.
2578 if (isset($element->optgroup)) {
2579 foreach ($element->optgroup as $group) {
2580 $options = array_merge($options, $this->getAllOptions($group));
2581 }
2582 }
2583 return $options;
2584 }
2585
2601 protected function assertLink($label, $index = 0, $message = '', $group = 'Other') {
2602 $links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
2603 $message = ($message ? $message : t('Link with label %label found.', array('%label' => $label)));
2604 return $this->assert(isset($links[$index]), $message, $group);
2605 }
2606
2621 protected function assertNoLink($label, $message = '', $group = 'Other') {
2622 $links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
2623 $message = ($message ? $message : t('Link with label %label not found.', array('%label' => $label)));
2624 return $this->assert(empty($links), $message, $group);
2625 }
2626
2642 protected function assertLinkByHref($href, $index = 0, $message = '', $group = 'Other') {
2643 $links = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href));
2644 $message = ($message ? $message : t('Link containing href %href found.', array('%href' => $href)));
2645 return $this->assert(isset($links[$index]), $message, $group);
2646 }
2647
2661 protected function assertNoLinkByHref($href, $message = '', $group = 'Other') {
2662 $links = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href));
2663 $message = ($message ? $message : t('No link containing href %href found.', array('%href' => $href)));
2664 return $this->assert(empty($links), $message, $group);
2665 }
2666
2681 protected function clickLink($label, $index = 0) {
2682 $url_before = $this->getUrl();
2683 $urls = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
2684
2685 if (isset($urls[$index])) {
2686 $url_target = $this->getAbsoluteUrl($urls[$index]['href']);
2687 }
2688
2689 $this->assertTrue(isset($urls[$index]), t('Clicked link %label (@url_target) from @url_before', array('%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before)), t('Browser'));
2690
2691 if (isset($url_target)) {
2692 return $this->drupalGet($url_target);
2693 }
2694 return FALSE;
2695 }
2696
2705 protected function getAbsoluteUrl($path) {
2706 global $base_url, $base_path;
2707
2708 $parts = parse_url($path);
2709 if (empty($parts['host'])) {
2710 // Ensure that we have a string (and no xpath object).
2711 $path = (string) $path;
2712 // Strip $base_path, if existent.
2713 $length = strlen($base_path);
2714 if (substr($path, 0, $length) === $base_path) {
2715 $path = substr($path, $length);
2716 }
2717 // Ensure that we have an absolute path.
2718 if ($path[0] !== '/') {
2719 $path = '/' . $path;
2720 }
2721 // Finally, prepend the $base_url.
2722 $path = $base_url . $path;
2723 }
2724 return $path;
2725 }
2726
2733 protected function getUrl() {
2734 return $this->url;
2735 }
2736
2756 protected function drupalGetHeaders($all_requests = FALSE) {
2757 $request = 0;
2758 $headers = array($request => array());
2759 foreach ($this->headers as $header) {
2760 $header = trim($header);
2761 if ($header === '') {
2762 $request++;
2763 }
2764 else {
2765 if (strpos($header, 'HTTP/') === 0) {
2766 $name = ':status';
2767 $value = $header;
2768 }
2769 else {
2770 list($name, $value) = explode(':', $header, 2);
2771 $name = strtolower($name);
2772 }
2773 if (isset($headers[$request][$name])) {
2774 $headers[$request][$name] .= ',' . trim($value);
2775 }
2776 else {
2777 $headers[$request][$name] = trim($value);
2778 }
2779 }
2780 }
2781 if (!$all_requests) {
2782 $headers = array_pop($headers);
2783 }
2784 return $headers;
2785 }
2786
2803 protected function drupalGetHeader($name, $all_requests = FALSE) {
2804 $name = strtolower($name);
2805 $header = FALSE;
2806 if ($all_requests) {
2807 foreach (array_reverse($this->drupalGetHeaders(TRUE)) as $headers) {
2808 if (isset($headers[$name])) {
2809 $header = $headers[$name];
2810 break;
2811 }
2812 }
2813 }
2814 else {
2815 $headers = $this->drupalGetHeaders();
2816 if (isset($headers[$name])) {
2817 $header = $headers[$name];
2818 }
2819 }
2820 return $header;
2821 }
2822
2826 protected function drupalGetContent() {
2827 return $this->content;
2828 }
2829
2833 protected function drupalGetSettings() {
2834 return $this->drupalSettings;
2835 }
2836
2845 protected function drupalGetMails($filter = array()) {
2846 $captured_emails = variable_get('drupal_test_email_collector', array());
2847 $filtered_emails = array();
2848
2849 foreach ($captured_emails as $message) {
2850 foreach ($filter as $key => $value) {
2851 if (!isset($message[$key]) || $message[$key] != $value) {
2852 continue 2;
2853 }
2854 }
2855 $filtered_emails[] = $message;
2856 }
2857
2858 return $filtered_emails;
2859 }
2860
2870 protected function drupalSetContent($content, $url = 'internal:') {
2871 $this->content = $content;
2872 $this->url = $url;
2873 $this->plainTextContent = FALSE;
2874 $this->elements = FALSE;
2875 $this->drupalSettings = array();
2876 if (preg_match('/jQuery\.extend\(Drupal\.settings, (.*?)\);/', $content, $matches)) {
2877 $this->drupalSettings = drupal_json_decode($matches[1]);
2878 }
2879 }
2880
2884 protected function drupalSetSettings($settings) {
2885 $this->drupalSettings = $settings;
2886 }
2887
2903 protected function assertUrl($path, array $options = array(), $message = '', $group = 'Other') {
2904 if (!$message) {
2905 $message = t('Current URL is @url.', array(
2906 '@url' => var_export(url($path, $options), TRUE),
2907 ));
2908 }
2909 $options['absolute'] = TRUE;
2910 return $this->assertEqual($this->getUrl(), url($path, $options), $message, $group);
2911 }
2912
2926 protected function assertRaw($raw, $message = '', $group = 'Other') {
2927 if (!$message) {
2928 $message = t('Raw "@raw" found', array('@raw' => $raw));
2929 }
2930 return $this->assert(strpos($this->drupalGetContent(), $raw) !== FALSE, $message, $group);
2931 }
2932
2946 protected function assertNoRaw($raw, $message = '', $group = 'Other') {
2947 if (!$message) {
2948 $message = t('Raw "@raw" not found', array('@raw' => $raw));
2949 }
2950 return $this->assert(strpos($this->drupalGetContent(), $raw) === FALSE, $message, $group);
2951 }
2952
2967 protected function assertText($text, $message = '', $group = 'Other') {
2968 return $this->assertTextHelper($text, $message, $group, FALSE);
2969 }
2970
2985 protected function assertNoText($text, $message = '', $group = 'Other') {
2986 return $this->assertTextHelper($text, $message, $group, TRUE);
2987 }
2988
3005 protected function assertTextHelper($text, $message = '', $group, $not_exists) {
3006 if ($this->plainTextContent === FALSE) {
3007 $this->plainTextContent = filter_xss($this->drupalGetContent(), array());
3008 }
3009 if (!$message) {
3010 $message = !$not_exists ? t('"@text" found', array('@text' => $text)) : t('"@text" not found', array('@text' => $text));
3011 }
3012 return $this->assert($not_exists == (strpos($this->plainTextContent, $text) === FALSE), $message, $group);
3013 }
3014
3031 protected function assertUniqueText($text, $message = '', $group = 'Other') {
3032 return $this->assertUniqueTextHelper($text, $message, $group, TRUE);
3033 }
3034
3051 protected function assertNoUniqueText($text, $message = '', $group = 'Other') {
3052 return $this->assertUniqueTextHelper($text, $message, $group, FALSE);
3053 }
3054
3071 protected function assertUniqueTextHelper($text, $message = '', $group, $be_unique) {
3072 if ($this->plainTextContent === FALSE) {
3073 $this->plainTextContent = filter_xss($this->drupalGetContent(), array());
3074 }
3075 if (!$message) {
3076 $message = '"' . $text . '"' . ($be_unique ? ' found only once' : ' found more than once');
3077 }
3078 $first_occurance = strpos($this->plainTextContent, $text);
3079 if ($first_occurance === FALSE) {
3080 return $this->assert(FALSE, $message, $group);
3081 }
3082 $offset = $first_occurance + strlen($text);
3083 $second_occurance = strpos($this->plainTextContent, $text, $offset);
3084 return $this->assert($be_unique == ($second_occurance === FALSE), $message, $group);
3085 }
3086
3099 protected function assertPattern($pattern, $message = '', $group = 'Other') {
3100 if (!$message) {
3101 $message = t('Pattern "@pattern" found', array('@pattern' => $pattern));
3102 }
3103 return $this->assert((bool) preg_match($pattern, $this->drupalGetContent()), $message, $group);
3104 }
3105
3118 protected function assertNoPattern($pattern, $message = '', $group = 'Other') {
3119 if (!$message) {
3120 $message = t('Pattern "@pattern" not found', array('@pattern' => $pattern));
3121 }
3122 return $this->assert(!preg_match($pattern, $this->drupalGetContent()), $message, $group);
3123 }
3124
3137 protected function assertTitle($title, $message = '', $group = 'Other') {
3138 $actual = (string) current($this->xpath('//title'));
3139 if (!$message) {
3140 $message = t('Page title @actual is equal to @expected.', array(
3141 '@actual' => var_export($actual, TRUE),
3142 '@expected' => var_export($title, TRUE),
3143 ));
3144 }
3145 return $this->assertEqual($actual, $title, $message, $group);
3146 }
3147
3160 protected function assertNoTitle($title, $message = '', $group = 'Other') {
3161 $actual = (string) current($this->xpath('//title'));
3162 if (!$message) {
3163 $message = t('Page title @actual is not equal to @unexpected.', array(
3164 '@actual' => var_export($actual, TRUE),
3165 '@unexpected' => var_export($title, TRUE),
3166 ));
3167 }
3168 return $this->assertNotEqual($actual, $title, $message, $group);
3169 }
3170
3193 protected function assertThemeOutput($callback, array $variables = array(), $expected, $message = '', $group = 'Other') {
3194 $output = theme($callback, $variables);
3195 $this->verbose('Variables:' . '<pre>' . check_plain(var_export($variables, TRUE)) . '</pre>'
3196 . '<hr />' . 'Result:' . '<pre>' . check_plain(var_export($output, TRUE)) . '</pre>'
3197 . '<hr />' . 'Expected:' . '<pre>' . check_plain(var_export($expected, TRUE)) . '</pre>'
3198 . '<hr />' . $output
3199 );
3200 if (!$message) {
3201 $message = '%callback rendered correctly.';
3202 }
3203 $message = format_string($message, array('%callback' => 'theme_' . $callback . '()'));
3204 return $this->assertIdentical($output, $expected, $message, $group);
3205 }
3206
3222 protected function assertFieldByXPath($xpath, $value = NULL, $message = '', $group = 'Other') {
3223 $fields = $this->xpath($xpath);
3224
3225 // If value specified then check array for match.
3226 $found = TRUE;
3227 if (isset($value)) {
3228 $found = FALSE;
3229 if ($fields) {
3230 foreach ($fields as $field) {
3231 if (isset($field['value']) && $field['value'] == $value) {
3232 // Input element with correct value.
3233 $found = TRUE;
3234 }
3235 elseif (isset($field->option)) {
3236 // Select element found.
3237 if ($this->getSelectedItem($field) == $value) {
3238 $found = TRUE;
3239 }
3240 else {
3241 // No item selected so use first item.
3242 $items = $this->getAllOptions($field);
3243 if (!empty($items) && $items[0]['value'] == $value) {
3244 $found = TRUE;
3245 }
3246 }
3247 }
3248 elseif ((string) $field == $value) {
3249 // Text area with correct text.
3250 $found = TRUE;
3251 }
3252 }
3253 }
3254 }
3255 return $this->assertTrue($fields && $found, $message, $group);
3256 }
3257
3266 protected function getSelectedItem(SimpleXMLElement $element) {
3267 foreach ($element->children() as $item) {
3268 if (isset($item['selected'])) {
3269 return $item['value'];
3270 }
3271 elseif ($item->getName() == 'optgroup') {
3272 if ($value = $this->getSelectedItem($item)) {
3273 return $value;
3274 }
3275 }
3276 }
3277 return FALSE;
3278 }
3279
3295 protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '', $group = 'Other') {
3296 $fields = $this->xpath($xpath);
3297
3298 // If value specified then check array for match.
3299 $found = TRUE;
3300 if (isset($value)) {
3301 $found = FALSE;
3302 if ($fields) {
3303 foreach ($fields as $field) {
3304 if ($field['value'] == $value) {
3305 $found = TRUE;
3306 }
3307 }
3308 }
3309 }
3310 return $this->assertFalse($fields && $found, $message, $group);
3311 }
3312
3327 protected function assertFieldByName($name, $value = NULL, $message = NULL) {
3328 if (!isset($message)) {
3329 if (!isset($value)) {
3330 $message = t('Found field with name @name', array(
3331 '@name' => var_export($name, TRUE),
3332 ));
3333 }
3334 else {
3335 $message = t('Found field with name @name and value @value', array(
3336 '@name' => var_export($name, TRUE),
3337 '@value' => var_export($value, TRUE),
3338 ));
3339 }
3340 }
3341 return $this->assertFieldByXPath($this->constructFieldXpath('name', $name), $value, $message, t('Browser'));
3342 }
3343
3358 protected function assertNoFieldByName($name, $value = '', $message = '') {
3359 return $this->assertNoFieldByXPath($this->constructFieldXpath('name', $name), $value, $message ? $message : t('Did not find field by name @name', array('@name' => $name)), t('Browser'));
3360 }
3361
3376 protected function assertFieldById($id, $value = '', $message = '') {
3377 return $this->assertFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : t('Found field by id @id', array('@id' => $id)), t('Browser'));
3378 }
3379
3394 protected function assertNoFieldById($id, $value = '', $message = '') {
3395 return $this->assertNoFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : t('Did not find field by id @id', array('@id' => $id)), t('Browser'));
3396 }
3397
3408 protected function assertFieldChecked($id, $message = '') {
3409 $elements = $this->xpath('//input[@id=:id]', array(':id' => $id));
3410 return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), $message ? $message : t('Checkbox field @id is checked.', array('@id' => $id)), t('Browser'));
3411 }
3412
3423 protected function assertNoFieldChecked($id, $message = '') {
3424 $elements = $this->xpath('//input[@id=:id]', array(':id' => $id));
3425 return $this->assertTrue(isset($elements[0]) && empty($elements[0]['checked']), $message ? $message : t('Checkbox field @id is not checked.', array('@id' => $id)), t('Browser'));
3426 }
3427
3442 protected function assertOptionSelected($id, $option, $message = '') {
3443 $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
3444 return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : t('Option @option for field @id is selected.', array('@option' => $option, '@id' => $id)), t('Browser'));
3445 }
3446
3459 protected function assertNoOptionSelected($id, $option, $message = '') {
3460 $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
3461 return $this->assertTrue(isset($elements[0]) && empty($elements[0]['selected']), $message ? $message : t('Option @option for field @id is not selected.', array('@option' => $option, '@id' => $id)), t('Browser'));
3462 }
3463
3476 protected function assertField($field, $message = '', $group = 'Other') {
3477 return $this->assertFieldByXPath($this->constructFieldXpath('name', $field) . '|' . $this->constructFieldXpath('id', $field), NULL, $message, $group);
3478 }
3479
3492 protected function assertNoField($field, $message = '', $group = 'Other') {
3493 return $this->assertNoFieldByXPath($this->constructFieldXpath('name', $field) . '|' . $this->constructFieldXpath('id', $field), NULL, $message, $group);
3494 }
3495
3513 protected function assertNoDuplicateIds($message = '', $group = 'Other', $ids_to_skip = array()) {
3514 $status = TRUE;
3515 foreach ($this->xpath('//*[@id]') as $element) {
3516 $id = (string) $element['id'];
3517 if (isset($seen_ids[$id]) && !in_array($id, $ids_to_skip)) {
3518 $this->fail(t('The HTML ID %id is unique.', array('%id' => $id)), $group);
3519 $status = FALSE;
3520 }
3521 $seen_ids[$id] = TRUE;
3522 }
3523 return $this->assert($status, $message, $group);
3524 }
3525
3536 protected function constructFieldXpath($attribute, $value) {
3537 $xpath = '//textarea[@' . $attribute . '=:value]|//input[@' . $attribute . '=:value]|//select[@' . $attribute . '=:value]';
3538 return $this->buildXPathQuery($xpath, array(':value' => $value));
3539 }
3540
3552 protected function assertResponse($code, $message = '') {
3553 $curl_code = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
3554 $match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
3555 return $this->assertTrue($match, $message ? $message : t('HTTP response expected !code, actual !curl_code', array('!code' => $code, '!curl_code' => $curl_code)), t('Browser'));
3556 }
3557
3570 protected function assertNoResponse($code, $message = '') {
3571 $curl_code = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
3572 $match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
3573 return $this->assertFalse($match, $message ? $message : t('HTTP response not expected !code, actual !curl_code', array('!code' => $code, '!curl_code' => $curl_code)), t('Browser'));
3574 }
3575
3591 protected function assertMail($name, $value = '', $message = '') {
3592 $captured_emails = variable_get('drupal_test_email_collector', array());
3593 $email = end($captured_emails);
3594 return $this->assertTrue($email && isset($email[$name]) && $email[$name] == $value, $message, t('E-mail'));
3595 }
3596
3610 protected function assertMailString($field_name, $string, $email_depth) {
3611 $mails = $this->drupalGetMails();
3612 $string_found = FALSE;
3613 for ($i = sizeof($mails) -1; $i >= sizeof($mails) - $email_depth && $i >= 0; $i--) {
3614 $mail = $mails[$i];
3615 // Normalize whitespace, as we don't know what the mail system might have
3616 // done. Any run of whitespace becomes a single space.
3617 $normalized_mail = preg_replace('/\s+/', ' ', $mail[$field_name]);
3618 $normalized_string = preg_replace('/\s+/', ' ', $string);
3619 $string_found = (FALSE !== strpos($normalized_mail, $normalized_string));
3620 if ($string_found) {
3621 break;
3622 }
3623 }
3624 return $this->assertTrue($string_found, t('Expected text found in @field of email message: "@expected".', array('@field' => $field_name, '@expected' => $string)));
3625 }
3626
3638 protected function assertMailPattern($field_name, $regex, $message) {
3639 $mails = $this->drupalGetMails();
3640 $mail = end($mails);
3641 $regex_found = preg_match("/$regex/", $mail[$field_name]);
3642 return $this->assertTrue($regex_found, t('Expected text found in @field of email message: "@expected".', array('@field' => $field_name, '@expected' => $regex)));
3643 }
3644
3651 protected function verboseEmail($count = 1) {
3652 $mails = $this->drupalGetMails();
3653 for ($i = sizeof($mails) -1; $i >= sizeof($mails) - $count && $i >= 0; $i--) {
3654 $mail = $mails[$i];
3655 $this->verbose(t('Email:') . '<pre>' . print_r($mail, TRUE) . '</pre>');
3656 }
3657 }
3658 }
3659
3680 function simpletest_verbose($message, $original_file_directory = NULL, $test_class = NULL) {
3681 static $file_directory = NULL, $class = NULL, $id = 1, $verbose = NULL;
3682
3683 // Will pass first time during setup phase, and when verbose is TRUE.
3684 if (!isset($original_file_directory) && !$verbose) {
3685 return FALSE;
3686 }
3687
3688 if ($message && $file_directory) {
3689 $message = '<hr />ID #' . $id . ' (<a href="' . $class . '-' . ($id - 1) . '.html">Previous</a> | <a href="' . $class . '-' . ($id + 1) . '.html">Next</a>)<hr />' . $message;
3690 file_put_contents($file_directory . "/simpletest/verbose/$class-$id.html", $message, FILE_APPEND);
3691 return $id++;
3692 }
3693
3694 if ($original_file_directory) {
3695 $file_directory = $original_file_directory;
3696 $class = $test_class;
3697 $verbose = variable_get('simpletest_verbose', TRUE);
3698 $directory = $file_directory . '/simpletest/verbose';
3699 $writable = file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
3700 if ($writable && !file_exists($directory . '/.htaccess')) {
3701 file_put_contents($directory . '/.htaccess', "<IfModule mod_expires.c>\nExpiresActive Off\n</IfModule>\n");
3702 }
3703 return $writable;
3704 }
3705 return FALSE;
3706 }
DrupalTestCase\assertNotNull
assertNotNull($value, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:311
node_type_save
node_type_save($info)
Definition: node.module:525
DrupalTestCase\$originalFileDirectory
$originalFileDirectory
Definition: drupal_web_test_case.php:40
DrupalWebTestCase\assertTextHelper
assertTextHelper($text, $message= '', $group, $not_exists)
Definition: drupal_web_test_case.php:3005
module_list
module_list($refresh=FALSE, $bootstrap_refresh=FALSE, $sort=FALSE, $fixed_list=NULL)
Definition: module.inc:66
DrupalTestCase\assertIdentical
assertIdentical($first, $second, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:365
DrupalWebTestCase\drupalGetSettings
drupalGetSettings()
Definition: drupal_web_test_case.php:2833
DrupalWebTestCase\assertNoLinkByHref
assertNoLinkByHref($href, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:2661
DrupalWebTestCase\checkForMetaRefresh
checkForMetaRefresh()
Definition: drupal_web_test_case.php:2308
DrupalWebTestCase\drupalGetAJAX
drupalGetAJAX($path, array $options=array(), array $headers=array())
Definition: drupal_web_test_case.php:1939
DrupalTestCase\assertNull
assertNull($value, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:295
decode_entities
decode_entities($text)
Definition: unicode.inc:457
DrupalWebTestCase\assertNoPattern
assertNoPattern($pattern, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:3118
DrupalWebTestCase\assertLink
assertLink($label, $index=0, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:2601
DrupalWebTestCase\drupalCreateContentType
drupalCreateContentType($settings=array())
Definition: drupal_web_test_case.php:991
FILE_CREATE_DIRECTORY
const FILE_CREATE_DIRECTORY
Definition: file.inc:41
l
l($text, $path, array $options=array())
Definition: common.inc:2432
DrupalWebTestCase\__construct
__construct($test_id=NULL)
Definition: drupal_web_test_case.php:897
DrupalWebTestCase\$profile
$profile
Definition: drupal_web_test_case.php:777
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
DrupalWebTestCase\constructFieldXpath
constructFieldXpath($attribute, $value)
Definition: drupal_web_test_case.php:3536
DrupalWebTestCase\drupalCreateRole
drupalCreateRole(array $permissions, $name=NULL)
Definition: drupal_web_test_case.php:1157
DrupalWebTestCase\assertRaw
assertRaw($raw, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:2926
DrupalTestCase\error
error($message= '', $group= 'Other', array $caller=NULL)
Definition: drupal_web_test_case.php:427
FILE_MODIFY_PERMISSIONS
const FILE_MODIFY_PERMISSIONS
Definition: file.inc:46
DrupalWebTestCase\assertNoFieldById
assertNoFieldById($id, $value= '', $message= '')
Definition: drupal_web_test_case.php:3394
DrupalUnitTestCase\tearDown
tearDown()
Definition: drupal_web_test_case.php:753
DrupalTestCase\assertNotIdentical
assertNotIdentical($first, $second, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:383
file_scan_directory
file_scan_directory($dir, $mask, $options=array(), $depth=0)
Definition: file.inc:2058
Database\getConnection
static getConnection($target= 'default', $key=NULL)
Definition: database.inc:1460
DrupalTestCase\verbose
verbose($message)
Definition: drupal_web_test_case.php:448
DrupalWebTestCase\drupalCompareFiles
drupalCompareFiles($file1, $file2)
Definition: drupal_web_test_case.php:1092
DrupalWebTestCase\curlExec
curlExec($curl_options, $redirect=FALSE)
Definition: drupal_web_test_case.php:1756
drupal_get_private_key
drupal_get_private_key()
Definition: common.inc:5056
DrupalWebTestCase\$cookieFile
$cookieFile
Definition: drupal_web_test_case.php:841
DrupalWebTestCase\prepareEnvironment
prepareEnvironment()
Definition: drupal_web_test_case.php:1353
drupal_set_time_limit
drupal_set_time_limit($time_limit)
Definition: common.inc:2786
DrupalWebTestCase\assertUrl
assertUrl($path, array $options=array(), $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:2903
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
DrupalWebTestCase\assertNoResponse
assertNoResponse($code, $message= '')
Definition: drupal_web_test_case.php:3570
$module
print $module
Definition: search-results.tpl.php:28
file_unmanaged_delete_recursive
file_unmanaged_delete_recursive($path)
Definition: file.inc:1358
file_create_url
file_create_url($uri)
Definition: file.inc:372
Database\getConnectionInfo
static getConnectionInfo($key= 'default')
Definition: database.inc:1593
DrupalWebTestCase\assertNoLink
assertNoLink($label, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:2621
DrupalWebTestCase\drupalGetToken
drupalGetToken($value= '')
Definition: drupal_web_test_case.php:1262
DrupalWebTestCase\assertNoFieldByXPath
assertNoFieldByXPath($xpath, $value=NULL, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:3295
DrupalWebTestCase\drupalHead
drupalHead($path, array $options=array(), array $headers=array())
Definition: drupal_web_test_case.php:2335
db_find_tables
db_find_tables($table_expression)
Definition: database.inc:2789
DrupalWebTestCase\$additionalCurlOptions
$additionalCurlOptions
Definition: drupal_web_test_case.php:848
DrupalWebTestCase\drupalGetHeaders
drupalGetHeaders($all_requests=FALSE)
Definition: drupal_web_test_case.php:2756
DrupalWebTestCase\assertThemeOutput
assertThemeOutput($callback, array $variables=array(), $expected, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:3193
DrupalUnitTestCase\__construct
__construct($test_id=NULL)
Definition: drupal_web_test_case.php:695
drupal_anonymous_user
drupal_anonymous_user()
Definition: bootstrap.inc:2152
DrupalWebTestCase\buildXPathQuery
buildXPathQuery($xpath, array $args=array())
Definition: drupal_web_test_case.php:2514
DrupalWebTestCase\clickLink
clickLink($label, $index=0)
Definition: drupal_web_test_case.php:2681
DrupalWebTestCase\$plainTextContent
$plainTextContent
Definition: drupal_web_test_case.php:812
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
DrupalTestCase\$assertions
$assertions
Definition: drupal_web_test_case.php:64
drupal_save_session
drupal_save_session($status=NULL)
Definition: session.inc:524
$name
print $name
Definition: profile-listing.tpl.php:43
DrupalWebTestCase\$session_name
$session_name
Definition: drupal_web_test_case.php:877
node_save
node_save($node)
Definition: node.module:1076
node_type_get_type
node_type_get_type($node)
Definition: node.module:410
Exception
DrupalWebTestCase\assertMailPattern
assertMailPattern($field_name, $regex, $message)
Definition: drupal_web_test_case.php:3638
DrupalWebTestCase\drupalPostAJAX
drupalPostAJAX($path, $edit, $triggering_element, $ajax_path=NULL, array $options=array(), array $headers=array(), $form_html_id=NULL, $ajax_settings=NULL)
Definition: drupal_web_test_case.php:2146
drupal_realpath
drupal_realpath($uri)
Definition: file.inc:2259
$header
print $header
Definition: forum-topic-list.tpl.php:42
DrupalWebTestCase\getSelectedItem
getSelectedItem(SimpleXMLElement $element)
Definition: drupal_web_test_case.php:3266
DrupalWebTestCase\drupalSetSettings
drupalSetSettings($settings)
Definition: drupal_web_test_case.php:2884
DrupalWebTestCase\drupalLogin
drupalLogin(stdClass $account)
Definition: drupal_web_test_case.php:1239
DrupalWebTestCase\drupalGetContent
drupalGetContent()
Definition: drupal_web_test_case.php:2826
DatabaseConnectionNotDefinedException
Definition: database.inc:1833
DrupalWebTestCase\tearDown
tearDown()
Definition: drupal_web_test_case.php:1615
drupal_install_system
drupal_install_system()
Definition: install.inc:721
DrupalWebTestCase\refreshVariables
refreshVariables()
Definition: drupal_web_test_case.php:1605
DrupalTestCase\pass
pass($message=NULL, $group= 'Other')
Definition: drupal_web_test_case.php:397
DrupalTestCase\exceptionHandler
exceptionHandler($exception)
Definition: drupal_web_test_case.php:564
simpletest_verbose
simpletest_verbose($message, $original_file_directory=NULL, $test_class=NULL)
Definition: drupal_web_test_case.php:3680
DrupalWebTestCase\$headers
$headers
Definition: drupal_web_test_case.php:798
DrupalTestCase\$databasePrefix
$databasePrefix
Definition: drupal_web_test_case.php:33
DrupalTestCase\run
run(array $methods=array())
Definition: drupal_web_test_case.php:468
user_save
user_save($account, $edit=array(), $category= 'account')
Definition: user.module:424
DrupalWebTestCase\drupalCreateNode
drupalCreateNode($settings=array())
Definition: drupal_web_test_case.php:929
drupal_array_merge_deep
drupal_array_merge_deep()
Definition: bootstrap.inc:2100
drupal_generate_test_ua
drupal_generate_test_ua($prefix)
Definition: bootstrap.inc:2546
drupal_hmac_base64
drupal_hmac_base64($data, $key)
Definition: bootstrap.inc:2047
DrupalWebTestCase\drupalCreateUser
drupalCreateUser(array $permissions=array())
Definition: drupal_web_test_case.php:1115
$conf
global $conf
Definition: authorize.php:74
DrupalWebTestCase\parse
parse()
Definition: drupal_web_test_case.php:1884
user_role_grant_permissions
user_role_grant_permissions($rid, array $permissions=array())
Definition: user.module:3100
DrupalTestCase\$skipClasses
$skipClasses
Definition: drupal_web_test_case.php:74
field_cache_clear
field_cache_clear()
Definition: field.module:740
DrupalWebTestCase\drupalGetNodeByTitle
drupalGetNodeByTitle($title, $reset=FALSE)
Definition: drupal_web_test_case.php:913
Database\addConnectionInfo
static addConnectionInfo($key, $target, $info)
Definition: database.inc:1581
$module_list
$module_list['system']['filename']
Definition: authorize.php:78
DrupalWebTestCase\$httpauth_credentials
$httpauth_credentials
Definition: drupal_web_test_case.php:872
DrupalWebTestCase\curlHeaderCallback
curlHeaderCallback($curlHandler, $header)
Definition: drupal_web_test_case.php:1828
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
DrupalTestCase\assertNotEqual
assertNotEqual($first, $second, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:347
DrupalTestCase\deleteAssert
static deleteAssert($message_id)
Definition: drupal_web_test_case.php:223
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
drupal_get_messages
drupal_get_messages($type=NULL, $clear_queue=TRUE)
Definition: bootstrap.inc:1820
drupal_get_schema
drupal_get_schema($table=NULL, $rebuild=FALSE)
Definition: bootstrap.inc:2940
DrupalTestCase\assertEqual
assertEqual($first, $second, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:329
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
menu_rebuild
menu_rebuild()
Definition: menu.inc:2709
$url
print $url
Definition: search-result.tpl.php:70
file_unmanaged_copy
file_unmanaged_copy($source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:884
DrupalTestCase\$setup
$setup
Definition: drupal_web_test_case.php:86
DrupalWebTestCase\$loggedInUser
$loggedInUser
Definition: drupal_web_test_case.php:833
module_enable
module_enable($module_list, $enable_dependencies=TRUE)
Definition: module.inc:383
DrupalTestCase\$timeLimit
$timeLimit
Definition: drupal_web_test_case.php:45
node_add_body_field
node_add_body_field($type, $label= 'Body')
Definition: node.module:586
DrupalWebTestCase\getAbsoluteUrl
getAbsoluteUrl($path)
Definition: drupal_web_test_case.php:2705
DrupalWebTestCase\assertNoOptionSelected
assertNoOptionSelected($id, $option, $message= '')
Definition: drupal_web_test_case.php:3459
drupal_get_profile
drupal_get_profile()
Definition: common.inc:222
DrupalTestCase\generatePermutations
static generatePermutations($parameters)
Definition: drupal_web_test_case.php:664
DrupalTestCase\$results
$results
Definition: drupal_web_test_case.php:52
Database\renameConnection
static renameConnection($old_key, $new_key)
Definition: database.inc:1613
node_types_rebuild
node_types_rebuild()
Definition: node.module:475
DrupalWebTestCase\assertNoField
assertNoField($field, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:3492
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
DrupalWebTestCase\assertFieldById
assertFieldById($id, $value= '', $message= '')
Definition: drupal_web_test_case.php:3376
DrupalWebTestCase\assertMailString
assertMailString($field_name, $string, $email_depth)
Definition: drupal_web_test_case.php:3610
DrupalWebTestCase\changeDatabasePrefix
changeDatabasePrefix()
Definition: drupal_web_test_case.php:1315
$value
print $value
Definition: user-profile-item.tpl.php:26
DrupalUnitTestCase
Definition: drupal_web_test_case.php:690
DrupalWebTestCase\$drupalSettings
$drupalSettings
Definition: drupal_web_test_case.php:819
DrupalTestCase\assert
assert($status, $message= '', $group= 'Other', array $caller=NULL)
Definition: drupal_web_test_case.php:119
DrupalWebTestCase\$originalUser
$originalUser
Definition: drupal_web_test_case.php:855
DrupalWebTestCase\$redirect_count
$redirect_count
Definition: drupal_web_test_case.php:892
DrupalWebTestCase\assertTitle
assertTitle($title, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:3137
DrupalWebTestCase\assertLinkByHref
assertLinkByHref($href, $index=0, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:2642
DrupalWebTestCase\assertOptionSelected
assertOptionSelected($id, $option, $message= '')
Definition: drupal_web_test_case.php:3442
DrupalTestCase\$setupDatabasePrefix
$setupDatabasePrefix
Definition: drupal_web_test_case.php:88
DrupalWebTestCase\drupalPost
drupalPost($path, $edit, $submit, array $options=array(), array $headers=array(), $form_html_id=NULL, $extra_post=NULL)
Definition: drupal_web_test_case.php:2018
DrupalWebTestCase\drupalGet
drupalGet($path, array $options=array(), array $headers=array())
Definition: drupal_web_test_case.php:1917
$output
$output
Definition: authorize.php:93
DrupalWebTestCase\checkPermissions
checkPermissions(array $permissions, $reset=FALSE)
Definition: drupal_web_test_case.php:1195
drupal_json_decode
drupal_json_decode($var)
Definition: common.inc:5028
DrupalTestCase\$testId
$testId
Definition: drupal_web_test_case.php:26
DrupalTestCase\errorHandler
errorHandler($severity, $message, $file=NULL, $line=NULL)
Definition: drupal_web_test_case.php:530
DrupalTestCase\assertTrue
assertTrue($value, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:263
DrupalTestCase\insertAssert
static insertAssert($test_id, $test_class, $status, $message= '', $group= 'Other', array $caller=array())
Definition: drupal_web_test_case.php:185
DrupalWebTestCase\assertUniqueTextHelper
assertUniqueTextHelper($text, $message= '', $group, $be_unique)
Definition: drupal_web_test_case.php:3071
DrupalWebTestCase\$curlHandle
$curlHandle
Definition: drupal_web_test_case.php:791
user_password
user_password($length=10)
Definition: user.module:705
DrupalWebTestCase\$originalShutdownCallbacks
$originalShutdownCallbacks
Definition: drupal_web_test_case.php:862
_drupal_decode_exception
_drupal_decode_exception($exception)
Definition: errors.inc:88
DrupalWebTestCase\curlInitialize
curlInitialize()
Definition: drupal_web_test_case.php:1697
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
DrupalWebTestCase\assertNoText
assertNoText($text, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:2985
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
DrupalWebTestCase\drupalGetHeader
drupalGetHeader($name, $all_requests=FALSE)
Definition: drupal_web_test_case.php:2803
DrupalWebTestCase\$generatedTestFiles
$generatedTestFiles
Definition: drupal_web_test_case.php:887
SAVED_NEW
const SAVED_NEW
Definition: common.inc:45
DrupalWebTestCase\prepareDatabasePrefix
prepareDatabasePrefix()
Definition: drupal_web_test_case.php:1298
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
DrupalTestCase\randomName
static randomName($length=8)
Definition: drupal_web_test_case.php:623
install_profile_info
install_profile_info($profile, $locale= 'en')
Definition: install.inc:1280
conf_path
conf_path($require_settings=TRUE, $reset=FALSE)
Definition: bootstrap.inc:541
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
DrupalTestCase\randomString
static randomString($length=8)
Definition: drupal_web_test_case.php:595
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
DrupalTestCase\fail
fail($message=NULL, $group= 'Other')
Definition: drupal_web_test_case.php:411
DrupalWebTestCase\$url
$url
Definition: drupal_web_test_case.php:784
drupal_flush_all_caches
drupal_flush_all_caches()
Definition: common.inc:7453
DrupalWebTestCase\drupalGetTestFiles
drupalGetTestFiles($type, $size=NULL)
Definition: drupal_web_test_case.php:1044
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
DrupalWebTestCase\assertUniqueText
assertUniqueText($text, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:3031
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
DrupalWebTestCase\getUrl
getUrl()
Definition: drupal_web_test_case.php:2733
DrupalTestCase\__construct
__construct($test_id=NULL)
Definition: drupal_web_test_case.php:98
DrupalWebTestCase\setUp
setUp()
Definition: drupal_web_test_case.php:1424
DrupalTestCase\assertFalse
assertFalse($value, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:279
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
DrupalWebTestCase\assertResponse
assertResponse($code, $message= '')
Definition: drupal_web_test_case.php:3552
format_string
format_string($string, array $args=array())
Definition: bootstrap.inc:1527
DrupalWebTestCase\drupalSetContent
drupalSetContent($content, $url= 'internal:')
Definition: drupal_web_test_case.php:2870
Database\removeConnection
static removeConnection($key)
Definition: database.inc:1644
DrupalWebTestCase\assertText
assertText($text, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:2967
DrupalWebTestCase\assertField
assertField($field, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:3476
DrupalWebTestCase\xpath
xpath($xpath, array $arguments=array())
Definition: drupal_web_test_case.php:2548
DrupalWebTestCase\assertNoFieldByName
assertNoFieldByName($name, $value= '', $message= '')
Definition: drupal_web_test_case.php:3358
DrupalWebTestCase\curlClose
curlClose()
Definition: drupal_web_test_case.php:1871
language_default
language_default($property=NULL)
Definition: bootstrap.inc:2765
user_role_save
user_role_save($role)
Definition: user.module:2955
DrupalWebTestCase\assertNoFieldChecked
assertNoFieldChecked($id, $message= '')
Definition: drupal_web_test_case.php:3423
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
_drupal_get_last_caller
_drupal_get_last_caller($backtrace)
Definition: errors.inc:260
DrupalWebTestCase\assertFieldByName
assertFieldByName($name, $value=NULL, $message=NULL)
Definition: drupal_web_test_case.php:3327
$row
$row
Definition: block-admin-display-form.tpl.php:47
DrupalWebTestCase\handleForm
handleForm(&$post, &$edit, &$upload, $submit, $form)
Definition: drupal_web_test_case.php:2358
DrupalWebTestCase\resetAll
resetAll()
Definition: drupal_web_test_case.php:1574
simpletest_generate_file
simpletest_generate_file($filename, $width, $lines, $type= 'binary-text')
Definition: simpletest.module:489
DrupalWebTestCase\$session_id
$session_id
Definition: drupal_web_test_case.php:882
DrupalWebTestCase\assertNoRaw
assertNoRaw($raw, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:2946
DrupalUnitTestCase\setUp
setUp()
Definition: drupal_web_test_case.php:708
file_prepare_directory
file_prepare_directory(&$directory, $options=FILE_MODIFY_PERMISSIONS)
Definition: file.inc:430
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
DrupalWebTestCase\drupalLogout
drupalLogout()
Definition: drupal_web_test_case.php:1270
DrupalWebTestCase\$httpauth_method
$httpauth_method
Definition: drupal_web_test_case.php:867
DrupalWebTestCase\assertMail
assertMail($name, $value= '', $message= '')
Definition: drupal_web_test_case.php:3591
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
node_load_multiple
node_load_multiple($nids=array(), $conditions=array(), $reset=FALSE)
Definition: node.module:945
filter_default_format
filter_default_format($account=NULL)
Definition: filter.module:524
DrupalWebTestCase\assertNoTitle
assertNoTitle($title, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:3160
DrupalWebTestCase\assertFieldChecked
assertFieldChecked($id, $message= '')
Definition: drupal_web_test_case.php:3408
format_size
format_size($size, $langcode=NULL)
Definition: common.inc:1866
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
$drupal_test_info
global $drupal_test_info
Definition: drupal_web_test_case.php:13
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
DrupalWebTestCase\getAllOptions
getAllOptions(SimpleXMLElement $element)
Definition: drupal_web_test_case.php:2570
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
DrupalWebTestCase\assertFieldByXPath
assertFieldByXPath($xpath, $value=NULL, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:3222
DrupalWebTestCase\preloadRegistry
preloadRegistry()
Definition: drupal_web_test_case.php:1538
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
DrupalTestCase
Definition: drupal_web_test_case.php:20
DrupalWebTestCase\assertNoDuplicateIds
assertNoDuplicateIds($message= '', $group= 'Other', $ids_to_skip=array())
Definition: drupal_web_test_case.php:3513
DrupalWebTestCase\cronRun
cronRun()
Definition: drupal_web_test_case.php:2296
DrupalTestCase\$setupEnvironment
$setupEnvironment
Definition: drupal_web_test_case.php:90
DrupalWebTestCase\$content
$content
Definition: drupal_web_test_case.php:805
drupal_cron_run
drupal_cron_run()
Definition: common.inc:5227
variable_initialize
variable_initialize($conf=array())
Definition: bootstrap.inc:903
DrupalWebTestCase
Definition: drupal_web_test_case.php:771
$links
print $links
Definition: poll-results--block.tpl.php:28
DrupalWebTestCase\verboseEmail
verboseEmail($count=1)
Definition: drupal_web_test_case.php:3651
DrupalTestCase\getAssertionCall
getAssertionCall()
Definition: drupal_web_test_case.php:235
drupal_get_filename
drupal_get_filename($type, $name, $filename=NULL)
Definition: bootstrap.inc:820
DrupalWebTestCase\$elements
$elements
Definition: drupal_web_test_case.php:826
DrupalWebTestCase\assertPattern
assertPattern($pattern, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:3099
simpletest_log_read
simpletest_log_read($test_id, $prefix, $test_class, $during_test=FALSE)
Definition: simpletest.module:261
DrupalWebTestCase\drupalGetMails
drupalGetMails($filter=array())
Definition: drupal_web_test_case.php:2845
drupal_register_shutdown_function
& drupal_register_shutdown_function($callback=NULL)
Definition: bootstrap.inc:3417
DrupalWebTestCase\assertNoUniqueText
assertNoUniqueText($text, $message= '', $group= 'Other')
Definition: drupal_web_test_case.php:3051
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/blog/blog.pages.inc Source File

  • modules
  • blog
blog.pages.inc
Go to the documentation of this file.
1 <?php
2
11 function blog_page_user($account) {
12 global $user;
13
14 drupal_set_title($title = t("@name's blog", array('@name' => format_username($account))), PASS_THROUGH);
15
16 $build = array();
17
18 $query = db_select('node', 'n')->extend('PagerDefault');
19 $nids = $query
20 ->fields('n', array('nid', 'sticky', 'created'))
21 ->condition('type', 'blog')
22 ->condition('uid', $account->uid)
23 ->condition('status', 1)
24 ->orderBy('sticky', 'DESC')
25 ->orderBy('created', 'DESC')
26 ->limit(variable_get('default_nodes_main', 10))
27 ->addTag('node_access')
28 ->execute()
29 ->fetchCol();
30
31 if (!empty($nids)) {
32 $nodes = node_load_multiple($nids);
33 $build += node_view_multiple($nodes);
34 $build['pager'] = array(
35 '#theme' => 'pager',
36 '#weight' => 5,
37 );
38 }
39 else {
40 if ($account->uid == $user->uid) {
41 drupal_set_message(t('You have not created any blog entries.'));
42 }
43 else {
44 drupal_set_message(t('!author has not created any blog entries.', array('!author' => theme('username', array('account' => $account)))));
45 }
46 }
47 drupal_add_feed('blog/' . $account->uid . '/feed', t('RSS - !title', array('!title' => $title)));
48
49 return $build;
50 }
51
55 function blog_page_last() {
56 global $user;
57 $build = array();
58
59 $query = db_select('node', 'n')->extend('PagerDefault');
60 $nids = $query
61 ->fields('n', array('nid', 'sticky', 'created'))
62 ->condition('type', 'blog')
63 ->condition('status', 1)
64 ->orderBy('sticky', 'DESC')
65 ->orderBy('created', 'DESC')
66 ->limit(variable_get('default_nodes_main', 10))
67 ->addTag('node_access')
68 ->execute()
69 ->fetchCol();
70
71 if (!empty($nids)) {
72 $nodes = node_load_multiple($nids);
73 $build += node_view_multiple($nodes);
74 $build['pager'] = array(
75 '#theme' => 'pager',
76 '#weight' => 5,
77 );
78 }
79 else {
80 drupal_set_message(t('No blog entries have been created.'));
81 }
82 drupal_add_feed('blog/feed', t('RSS - blogs'));
83
84 return $build;
85 }
86
90 function blog_feed_user($account) {
91
92 $nids = db_select('node', 'n')
93 ->fields('n', array('nid', 'created'))
94 ->condition('type', 'blog')
95 ->condition('uid', $account->uid)
96 ->condition('status', 1)
97 ->orderBy('created', 'DESC')
98 ->range(0, variable_get('feed_default_items', 10))
99 ->addTag('node_access')
100 ->execute()
101 ->fetchCol();
102
103 $channel['title'] = t("!name's blog", array('!name' => format_username($account)));
104 $channel['link'] = url('blog/' . $account->uid, array('absolute' => TRUE));
105
106 node_feed($nids, $channel);
107 }
108
112 function blog_feed_last() {
113 $nids = db_select('node', 'n')
114 ->fields('n', array('nid', 'created'))
115 ->condition('type', 'blog')
116 ->condition('status', 1)
117 ->orderBy('created', 'DESC')
118 ->range(0, variable_get('feed_default_items', 10))
119 ->addTag('node_access')
120 ->execute()
121 ->fetchCol();
122
123 $channel['title'] = t('!site_name blogs', array('!site_name' => variable_get('site_name', 'Drupal')));
124 $channel['link'] = url('blog', array('absolute' => TRUE));
125
126 node_feed($nids, $channel);
127 }
node_feed
node_feed($nids=FALSE, $channel=array())
Definition: node.module:2581
blog_page_user
blog_page_user($account)
Definition: blog.pages.inc:11
format_username
format_username($account)
Definition: common.inc:2106
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
blog_feed_last
blog_feed_last()
Definition: blog.pages.inc:112
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_add_feed
drupal_add_feed($url=NULL, $title= '')
Definition: common.inc:368
blog_page_last
blog_page_last()
Definition: blog.pages.inc:55
node_load_multiple
node_load_multiple($nids=array(), $conditions=array(), $reset=FALSE)
Definition: node.module:945
node_view_multiple
node_view_multiple($nodes, $view_mode= 'teaser', $weight=0, $langcode=NULL)
Definition: node.module:2666
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
blog_feed_user
blog_feed_user($account)
Definition: blog.pages.inc:90
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example/ajax_example_advanced.inc Source File

  • examples
  • ajax_example
ajax_example_advanced.inc
Go to the documentation of this file.
1 <?php
2
16 function ajax_example_advanced_commands($form, &$form_state) {
17 $form = array();
18 $form['intro'] = array(
19 '#type' => 'markup',
20 '#markup' => t("<div>Demonstrates how AJAX commands can be used.</div>"),
21 );
22
23 // Shows the 'after' command with a callback generating commands.
24 $form['after_command_example_fieldset'] = array(
25 '#type' => 'fieldset',
26 '#title' => t("This shows the Ajax 'after' command. Click to put something below the div that says 'Something can be inserted after this'")
27 );
28
29 $form['after_command_example_fieldset']['after_command_example'] = array(
30 '#value' => t("AJAX 'After': Click to put something after the div"),
31 '#type' => 'submit',
32 '#ajax' => array(
33 'callback' => 'ajax_example_advanced_commands_after_callback',
34 ),
35 '#suffix' => "<div id='after_div'>Something can be inserted after this</div>
36 <div id='after_status'>'After' Command Status: Unknown</div>",
37 );
38
39 // Shows the 'alert' command.
40 $form['alert_command_example_fieldset'] = array(
41 '#type' => 'fieldset',
42 '#title' => t("Demonstrates the AJAX 'alert' command. Click the button."),
43 );
44 $form['alert_command_example_fieldset']['alert_command_example'] = array(
45 '#value' => t("AJAX 'Alert': Click to alert"),
46 '#type' => 'submit',
47 '#ajax' => array(
48 'callback' => 'ajax_example_advanced_commands_alert_callback',
49 ),
50 );
51
52 // Shows the 'append' command.
53 $form['append_command_example_fieldset'] = array(
54 '#type' => 'fieldset',
55 '#title' => t("This shows the Ajax 'append' command. Click to put something below the div that says 'Something can be inserted after this'")
56 );
57
58 $form['append_command_example_fieldset']['append_command_example'] = array(
59 '#value' => t("AJAX 'Append': Click to append something"),
60 '#type' => 'submit',
61 '#ajax' => array(
62 'callback' => 'ajax_example_advanced_commands_append_callback',
63 ),
64 '#suffix' => "<div id='append_div'>Something can be appended inside this div... </div>
65 <div id='append_status'>'After' Command Status: Unknown</div>"
66 );
67
68
69 // Shows the 'before' command.
70 $form['before_command_example_fieldset'] = array(
71 '#type' => 'fieldset',
72 '#title' => t("This shows the Ajax 'before' command.")
73 );
74
75 $form['before_command_example_fieldset']['before_command_example'] = array(
76 '#value' => t("AJAX 'before': Click to put something before the div"),
77 '#type' => 'submit',
78 '#ajax' => array(
79 'callback' => 'ajax_example_advanced_commands_before_callback',
80 ),
81 '#suffix' => "<div id='before_div'>Something can be inserted before this</div>
82 <div id='before_status'>'before' Command Status: Unknown</div>"
83 );
84
85 // Shows the 'changed' command.
86 $form['changed_command_example_fieldset'] = array(
87 '#type' => 'fieldset',
88 '#title' => t("Demonstrates the AJAX 'changed' command. If region is 'changed', it is marked with CSS. This example also puts an asterisk by changed content."),
89 );
90
91 $form['changed_command_example_fieldset']['changed_command_example'] = array(
92 '#title' => t("AJAX changed: If checked, div is marked as changed."),
93 '#type' => 'checkbox',
94 '#default_value' => FALSE,
95 '#ajax' => array(
96 'callback' => 'ajax_example_advanced_commands_changed_callback',
97 ),
98 '#suffix' => "<div id='changed_div'> <div id='changed_div_mark_this'>This div can be marked as changed or not.</div></div>
99 <div id='changed_status'>Status: Unknown</div>"
100 );
101
102 // Shows the AJAX 'css' command.
103 $form['css_command_example_fieldset'] = array(
104 '#type' => 'fieldset',
105 '#title' => t("Demonstrates the AJAX 'css' command."),
106 );
107
108 $form['css_command_example_fieldset']['css_command_example'] = array(
109 '#title' => t("AJAX CSS: Choose the color you'd like the '#box' div to be."),
110 '#type' => 'select',
111 // '#default_value' => 'green',
112 '#options' => array('green' => 'green', 'blue' => 'blue'),
113 '#ajax' => array(
114 'callback' => 'ajax_example_advanced_commands_css_callback',
115 ),
116 '#suffix' => "<div id='css_div' style='height: 50px; width: 50px; border: 1px solid black'> box</div>
117 <div id='css_status'>Status: Unknown</div>"
118 );
119
120 // Shows the AJAX 'data' command. But there is no use of this information,
121 // as this would require a javascript client to use the data.
122 $form['data_command_example_fieldset'] = array(
123 '#type' => 'fieldset',
124 '#title' => t("Demonstrates the AJAX 'data' command."),
125 );
126
127 $form['data_command_example_fieldset']['data_command_example'] = array(
128 '#title' => t("AJAX data: Set a key/value pair on a selector."),
129 '#type' => 'textfield',
130 '#default_value' => 'color=green',
131 '#ajax' => array(
132 'callback' => 'ajax_example_advanced_commands_data_callback',
133 ),
134 '#suffix' => "<div id='data_div'>This div should have key='time'/value='a time string' attached.</div>
135 <div id='data_status'>Status: Unknown</div>"
136 );
137
138 // Shows the AJAX 'html' command.
139 $form['html_command_example_fieldset'] = array(
140 '#type' => 'fieldset',
141 '#title' => t("Demonstrates the AJAX 'html' command."),
142 );
143
144 $form['html_command_example_fieldset']['html_command_example'] = array(
145 '#title' => t("AJAX html: Replace the HTML in a selector."),
146 '#type' => 'textfield',
147 '#default_value' => 'new value',
148 '#ajax' => array(
149 'callback' => 'ajax_example_advanced_commands_html_callback',
150 ),
151 '#suffix' => "<div id='html_div'>Original contents</div>
152 <div id='html_status'>Status: Unknown</div>"
153 );
154
155 // Shows the AJAX 'prepend' command.
156 $form['prepend_command_example_fieldset'] = array(
157 '#type' => 'fieldset',
158 '#title' => t("This shows the AJAX 'prepend' command. Click to put something below the div that says 'Something can be inserted after this'")
159 );
160
161 $form['prepend_command_example_fieldset']['prepend_command_example'] = array(
162 '#value' => t("AJAX 'prepend': Click to prepend something"),
163 '#type' => 'submit',
164 '#ajax' => array(
165 'callback' => 'ajax_example_advanced_commands_prepend_callback',
166 ),
167 '#suffix' => "<div id='prepend_div'>Something can be prepended to this div... </div>
168 <div id='prepend_status'>'After' Command Status: Unknown</div>"
169 );
170
171 // Shows the AJAX 'remove' command.
172 $form['remove_command_example_fieldset'] = array(
173 '#type' => 'fieldset',
174 '#title' => t("Shows the Ajax 'remove' command.")
175 );
176
177 $form['remove_command_example_fieldset']['remove_command_example'] = array(
178 '#title' => t("AJAX 'remove': Check to remove text. Uncheck to add it back."),
179 '#type' => 'checkbox',
180 '#default_value' => FALSE,
181 '#ajax' => array(
182 'callback' => 'ajax_example_advanced_commands_remove_callback',
183 ),
184 '#suffix' => "<div id='remove_div'><div id='remove_text'>text to be removed</div></div>
185 <div id='remove_status'>'After' Command Status: Unknown</div>"
186 );
187
188 // Show off the AJAX 'restripe' command. Also shows classic AJAX replacement
189 // on the "how many rows" processing.
190 $form['restripe_command_example_fieldset'] = array(
191 '#type' => 'fieldset',
192 '#title' => t("Demonstrates the Ajax 'restripe' command.")
193 );
194
195 $form['restripe_command_example_fieldset']['restripe_num_rows'] = array(
196 '#type' => 'select',
197 '#default_value' => !empty($form_state['values']['restripe_num_rows']) ? $form_state['values']['restripe_num_rows'] : 1,
198 '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
199 '#ajax' => array(
200 'callback' => 'ajax_example_advanced_commands_restripe_num_rows',
201 'method' => 'replace',
202 'wrapper' => 'restripe_table',
203 ),
204 );
205 $form['restripe_command_example_fieldset']['restripe_restripe'] = array(
206 '#type' => 'submit',
207 '#value' => t("Restripe the table"),
208 '#ajax' => array(
209 'callback' => 'ajax_example_advanced_commands_restripe_callback',
210 ),
211 '#suffix' => "<div id='restripe_div'>
212 <table id='restripe_table' style='border: 1px solid black' >
213 <tr id='table-first'><td>first row</td></tr>
214 </table>
215 </div>
216 <div id='restripe_status'>'Restripe' Command Status: Unknown</div>",
217
218 );
219
220 $form['submit'] = array(
221 '#type' => 'submit',
222 '#value' => t('Submit'),
223 );
224
225 return $form;
226 }
227
233 function ajax_example_advanced_commands_after_callback($form, $form_state) {
234 $selector = '#after_div';
235
236 $commands = array();
237 $commands[] = ajax_command_after($selector, "New 'after'...");
238 $commands[] = ajax_command_replace("#after_status", "<div id='after_status'>Updated after_command_example " . date('r') . "</div>");
239 return array('#type' => 'ajax', '#commands' => $commands);
240 }
241
247 function ajax_example_advanced_commands_alert_callback($form, $form_state) {
248 $commands = array();
249 $commands[] = ajax_command_alert("Alert requested at " . date('r'));
250 return array('#type' => 'ajax', '#commands' => $commands);
251 }
252
258 function ajax_example_advanced_commands_append_callback($form, $form_state) {
259 $selector = '#append_div';
260
261 $commands = array();
262 $commands[] = ajax_command_append($selector, "Stuff...");
263 $commands[] = ajax_command_replace("#append_status", "<div id='append_status'>Updated append_command_example " . date('r') . "</div>");
264 return array('#type' => 'ajax', '#commands' => $commands);
265 }
266
272 function ajax_example_advanced_commands_before_callback($form, $form_state) {
273 $selector = '#before_div';
274
275 $commands = array();
276 $commands[] = ajax_command_before($selector, "New 'before'...");
277 $commands[] = ajax_command_replace("#before_status", "<div id='before_status'>Updated before_command_example " . date('r') . "</div>");
278 return array('#type' => 'ajax', '#commands' => $commands);
279 }
280
286 function ajax_example_advanced_commands_changed_callback($form, $form_state) {
287 $checkbox_value = $form_state['values']['changed_command_example'];
288 $checkbox_value_string = $checkbox_value ? "TRUE" : "FALSE";
289 $commands = array();
290 if ($checkbox_value) {
291 $commands[] = ajax_command_changed( '#changed_div', '#changed_div_mark_this');
292 }
293 else {
294 $commands[] = ajax_command_replace('#changed_div', "<div id='changed_div'> <div id='changed_div_mark_this'>This div can be marked as changed or not.</div></div>");
295 }
296 $commands[] = ajax_command_replace("#changed_status", "<div id='changed_status'>Updated changed_command_example to $checkbox_value_string: " . date('r') . "</div>");
297 return array('#type' => 'ajax', '#commands' => $commands);
298 }
299
305 function ajax_example_advanced_commands_css_callback($form, $form_state) {
306 $selector = '#css_div';
307 $color = $form_state['values']['css_command_example'];
308
309 $commands = array();
310 $commands[] = ajax_command_css($selector, array('background-color' => $color));
311 $commands[] = ajax_command_replace("#css_status", "<div id='css_status'>Updated css_command_example to '{$color}' " . date('r') . "</div>");
312 return array('#type' => 'ajax', '#commands' => $commands);
313 }
314
320 function ajax_example_advanced_commands_data_callback($form, $form_state) {
321 $selector = '#data_div';
322 $text = $form_state['values']['data_command_example'];
323 list($key, $value) = preg_split('/=/', $text);
324
325 $commands = array();
326 $commands[] = ajax_command_data($selector, $key, $value);
327 $commands[] = ajax_command_replace("#data_status", "<div id='data_status'>Updated data_command_example with key=$key, value=$value; " . date('r') . "</div>");
328 return array('#type' => 'ajax', '#commands' => $commands);
329 }
330
336 function ajax_example_advanced_commands_html_callback($form, $form_state) {
337 $text = $form_state['values']['html_command_example'];
338
339 $commands = array();
340 $commands[] = ajax_command_html('#html_div', $text);
341 $commands[] = ajax_command_replace("#html_status", "<div id='html_status'>Updated html_command_example with text=$text; " . date('r') . "</div>");
342 return array('#type' => 'ajax', '#commands' => $commands);
343 }
344
350 function ajax_example_advanced_commands_prepend_callback($form, $form_state) {
351 $commands = array();
352 $commands[] = ajax_command_prepend('#prepend_div', "Prepended Stuff...");
353 $commands[] = ajax_command_replace("#prepend_status", "<div id='prepend_status'>Updated prepend_command_example " . date('r') . "</div>");
354 return array('#type' => 'ajax', '#commands' => $commands);
355 }
356
362 function ajax_example_advanced_commands_remove_callback($form, $form_state) {
363 $commands = array();
364 $should_remove = $form_state['values']['remove_command_example'];
365 $should_remove_string = $should_remove ? 'TRUE' : 'FALSE';
366 if ($should_remove) {
367 $commands[] = ajax_command_remove('#remove_text');
368 }
369 else {
370 $commands[] = ajax_command_html('#remove_div', "<div id='remove_text'>text to be removed</div>");
371 }
372 $commands[] = ajax_command_replace("#remove_status", "<div id='remove_status'>Updated remove_command_example (value={$should_remove_string} " . date('r') . "</div>");
373 return array('#type' => 'ajax', '#commands' => $commands);
374 }
375
381 function ajax_example_advanced_commands_restripe_num_rows($form, $form_state) {
382 $num_rows = $form_state['values']['restripe_num_rows'];
383 $output = "<table id='restripe_table' style='border: 1px solid black'>";
384 for ($i=1; $i<=$num_rows; $i++) {
385 $output .= "<tr><td>Row $i</td></tr>";
386 }
387 $output .= "</table>";
388 return $output;
389 }
390
396 function ajax_example_advanced_commands_restripe_callback($form, $form_state) {
397 $commands = array();
398 $commands[] = ajax_command_restripe('#restripe_table');
399 $commands[] = ajax_command_replace("#restripe_status", "<div id='restripe_status'>Restriped table " . date('r') . "</div>");
400 return array('#type' => 'ajax', '#commands' => $commands);
401 }
ajax_example_advanced_commands_restripe_num_rows
ajax_example_advanced_commands_restripe_num_rows($form, $form_state)
Definition: ajax_example_advanced.inc:381
ajax_example_advanced_commands_remove_callback
ajax_example_advanced_commands_remove_callback($form, $form_state)
Definition: ajax_example_advanced.inc:362
ajax_command_replace
ajax_command_replace($selector, $html, $settings=NULL)
Definition: ajax.inc:842
ajax_example_advanced_commands_before_callback
ajax_example_advanced_commands_before_callback($form, $form_state)
Definition: ajax_example_advanced.inc:272
ajax_command_alert
ajax_command_alert($text)
Definition: ajax.inc:780
ajax_example_advanced_commands_prepend_callback
ajax_example_advanced_commands_prepend_callback($form, $form_state)
Definition: ajax_example_advanced.inc:350
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
ajax_command_restripe
ajax_command_restripe($selector)
Definition: ajax.inc:1207
ajax_command_html
ajax_command_html($selector, $html, $settings=NULL)
Definition: ajax.inc:875
ajax_command_append
ajax_command_append($selector, $html, $settings=NULL)
Definition: ajax.inc:941
ajax_example_advanced_commands_append_callback
ajax_example_advanced_commands_append_callback($form, $form_state)
Definition: ajax_example_advanced.inc:258
ajax_example_advanced_commands_changed_callback
ajax_example_advanced_commands_changed_callback($form, $form_state)
Definition: ajax_example_advanced.inc:286
ajax_example_advanced_commands
ajax_example_advanced_commands($form, &$form_state)
Definition: ajax_example_advanced.inc:16
ajax_command_before
ajax_command_before($selector, $html, $settings=NULL)
Definition: ajax.inc:1007
ajax_command_css
ajax_command_css($selector, $argument)
Definition: ajax.inc:1090
$value
print $value
Definition: user-profile-item.tpl.php:26
$output
$output
Definition: authorize.php:93
ajax_example_advanced_commands_data_callback
ajax_example_advanced_commands_data_callback($form, $form_state)
Definition: ajax_example_advanced.inc:320
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
ajax_command_prepend
ajax_command_prepend($selector, $html, $settings=NULL)
Definition: ajax.inc:908
ajax_example_advanced_commands_alert_callback
ajax_example_advanced_commands_alert_callback($form, $form_state)
Definition: ajax_example_advanced.inc:247
ajax_command_after
ajax_command_after($selector, $html, $settings=NULL)
Definition: ajax.inc:974
ajax_example_advanced_commands_restripe_callback
ajax_example_advanced_commands_restripe_callback($form, $form_state)
Definition: ajax_example_advanced.inc:396
ajax_command_data
ajax_command_data($selector, $name, $value)
Definition: ajax.inc:1152
ajax_example_advanced_commands_after_callback
ajax_example_advanced_commands_after_callback($form, $form_state)
Definition: ajax_example_advanced.inc:233
ajax_command_changed
ajax_command_changed($selector, $asterisk= '')
Definition: ajax.inc:1062
ajax_example_advanced_commands_css_callback
ajax_example_advanced_commands_css_callback($form, $form_state)
Definition: ajax_example_advanced.inc:305
ajax_command_remove
ajax_command_remove($selector)
Definition: ajax.inc:1036
ajax_example_advanced_commands_html_callback
ajax_example_advanced_commands_html_callback($form, $form_state)
Definition: ajax_example_advanced.inc:336
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/image/image.admin.inc Source File

  • modules
  • image
image.admin.inc
Go to the documentation of this file.
1 <?php
2
11 function image_style_list() {
12 $page = array();
13
14 $styles = image_styles();
15 $page['image_style_list'] = array(
16 '#markup' => theme('image_style_list', array('styles' => $styles)),
17 '#attached' => array(
18 'css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array()),
19 ),
20 );
21
22 return $page;
23
24 }
25
36 function image_style_form($form, &$form_state, $style) {
37 $title = t('Edit %name style', array('%name' => $style['label']));
38 drupal_set_title($title, PASS_THROUGH);
39
40 // Adjust this form for styles that must be overridden to edit.
41 $editable = (bool) ($style['storage'] & IMAGE_STORAGE_EDITABLE);
42
43 if (!$editable && empty($form_state['input'])) {
44 drupal_set_message(t('This image style is currently being provided by a module. Click the "Override defaults" button to change its settings.'), 'warning');
45 }
46
47 $form_state['image_style'] = $style;
48 $form['#tree'] = TRUE;
49 $form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array();
50
51 // Show the thumbnail preview.
52 $form['preview'] = array(
53 '#type' => 'item',
54 '#title' => t('Preview'),
55 '#markup' => theme('image_style_preview', array('style' => $style)),
56 );
57
58 // Show the Image Style label.
59 $form['label'] = array(
60 '#type' => 'textfield',
61 '#title' => t('Image style name'),
62 '#default_value' => $style['label'],
63 '#disabled' => !$editable,
64 '#required' => TRUE,
65 );
66
67 // Allow the name of the style to be changed, unless this style is
68 // provided by a module's hook_default_image_styles().
69 $form['name'] = array(
70 '#type' => 'machine_name',
71 '#size' => '64',
72 '#default_value' => $style['name'],
73 '#disabled' => !$editable,
74 '#description' => t('The name is used in URLs for generated images. Use only lowercase alphanumeric characters, underscores (_), and hyphens (-).'),
75 '#required' => TRUE,
76 '#machine_name' => array(
77 'exists' => 'image_style_load',
78 'source' => array('label'),
79 'replace_pattern' => '[^0-9a-z_\-]',
80 'error' => t('Please only use lowercase alphanumeric characters, underscores (_), and hyphens (-) for style names.'),
81 ),
82 );
83
84 // Build the list of existing image effects for this image style.
85 $form['effects'] = array(
86 '#theme' => 'image_style_effects',
87 );
88 foreach ($style['effects'] as $key => $effect) {
89 $form['effects'][$key]['#weight'] = isset($form_state['input']['effects']) ? $form_state['input']['effects'][$key]['weight'] : NULL;
90 $form['effects'][$key]['label'] = array(
91 '#markup' => $effect['label'],
92 );
93 $form['effects'][$key]['summary'] = array(
94 '#markup' => isset($effect['summary theme']) ? theme($effect['summary theme'], array('data' => $effect['data'])) : '',
95 );
96 $form['effects'][$key]['weight'] = array(
97 '#type' => 'weight',
98 '#title' => t('Weight for @title', array('@title' => $effect['label'])),
99 '#title_display' => 'invisible',
100 '#default_value' => $effect['weight'],
101 '#access' => $editable,
102 );
103
104 // Only attempt to display these fields for editable styles as the 'ieid'
105 // key is not set for styles defined in code.
106 if ($editable) {
107 $form['effects'][$key]['configure'] = array(
108 '#type' => 'link',
109 '#title' => t('edit'),
110 '#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $effect['ieid'],
111 '#access' => $editable && isset($effect['form callback']),
112 );
113 $form['effects'][$key]['remove'] = array(
114 '#type' => 'link',
115 '#title' => t('delete'),
116 '#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $effect['ieid'] . '/delete',
117 '#access' => $editable,
118 );
119 }
120 }
121
122 // Build the new image effect addition form and add it to the effect list.
123 $new_effect_options = array();
124 foreach (image_effect_definitions() as $effect => $definition) {
125 $new_effect_options[$effect] = check_plain($definition['label']);
126 }
127 $form['effects']['new'] = array(
128 '#tree' => FALSE,
129 '#weight' => isset($form_state['input']['weight']) ? $form_state['input']['weight'] : NULL,
130 '#access' => $editable,
131 );
132 $form['effects']['new']['new'] = array(
133 '#type' => 'select',
134 '#title' => t('Effect'),
135 '#title_display' => 'invisible',
136 '#options' => $new_effect_options,
137 '#empty_option' => t('Select a new effect'),
138 );
139 $form['effects']['new']['weight'] = array(
140 '#type' => 'weight',
141 '#title' => t('Weight for new effect'),
142 '#title_display' => 'invisible',
143 '#default_value' => count($form['effects']) - 1,
144 );
145 $form['effects']['new']['add'] = array(
146 '#type' => 'submit',
147 '#value' => t('Add'),
148 '#validate' => array('image_style_form_add_validate'),
149 '#submit' => array('image_style_form_submit', 'image_style_form_add_submit'),
150 );
151
152 // Show the Override or Submit button for this style.
153 $form['actions'] = array('#type' => 'actions');
154 $form['actions']['override'] = array(
155 '#type' => 'submit',
156 '#value' => t('Override defaults'),
157 '#validate' => array(),
158 '#submit' => array('image_style_form_override_submit'),
159 '#access' => !$editable,
160 );
161 $form['actions']['submit'] = array(
162 '#type' => 'submit',
163 '#value' => t('Update style'),
164 '#access' => $editable,
165 );
166
167 return $form;
168 }
169
173 function image_style_form_add_validate($form, &$form_state) {
174 if (!$form_state['values']['new']) {
175 form_error($form['effects']['new']['new'], t('Select an effect to add.'));
176 }
177 }
178
182 function image_style_form_add_submit($form, &$form_state) {
183 $style = $form_state['image_style'];
184 // Check if this field has any configuration options.
185 $effect = image_effect_definition_load($form_state['values']['new']);
186
187 // Load the configuration form for this option.
188 if (isset($effect['form callback'])) {
189 $path = 'admin/config/media/image-styles/edit/' . $form_state['image_style']['name'] . '/add/' . $form_state['values']['new'];
190 $form_state['redirect'] = array($path, array('query' => array('weight' => $form_state['values']['weight'])));
191 }
192 // If there's no form, immediately add the image effect.
193 else {
194 $effect['isid'] = $style['isid'];
195 $effect['weight'] = $form_state['values']['weight'];
196 image_effect_save($effect);
197 drupal_set_message(t('The image effect was successfully applied.'));
198 }
199 }
200
204 function image_style_form_override_submit($form, &$form_state) {
205 drupal_set_message(t('The %style style has been overridden, allowing you to change its settings.', array('%style' => $form_state['image_style']['label'])));
206 image_default_style_save($form_state['image_style']);
207 }
208
212 function image_style_form_submit($form, &$form_state) {
213 // Update the image style.
214 $style = $form_state['image_style'];
215 $style['name'] = $form_state['values']['name'];
216 $style['label'] = $form_state['values']['label'];
217
218 // Update image effect weights.
219 if (!empty($form_state['values']['effects'])) {
220 foreach ($form_state['values']['effects'] as $ieid => $effect_data) {
221 if (isset($style['effects'][$ieid])) {
222 $effect = $style['effects'][$ieid];
223 $effect['weight'] = $effect_data['weight'];
224 image_effect_save($effect);
225 }
226 }
227 }
228
229 image_style_save($style);
230 if ($form_state['values']['op'] == t('Update style')) {
231 drupal_set_message(t('Changes to the style have been saved.'));
232 }
233 $form_state['redirect'] = 'admin/config/media/image-styles/edit/' . $style['name'];
234 }
235
242 function image_style_add_form($form, &$form_state) {
243 $form['label'] = array(
244 '#type' => 'textfield',
245 '#title' => t('Style name'),
246 '#default_value' => '',
247 '#required' => TRUE,
248 );
249 $form['name'] = array(
250 '#type' => 'machine_name',
251 '#description' => t('The name is used in URLs for generated images. Use only lowercase alphanumeric characters, underscores (_), and hyphens (-).'),
252 '#size' => '64',
253 '#required' => TRUE,
254 '#machine_name' => array(
255 'exists' => 'image_style_load',
256 'source' => array('label'),
257 'replace_pattern' => '[^0-9a-z_\-]',
258 'error' => t('Please only use lowercase alphanumeric characters, underscores (_), and hyphens (-) for style names.'),
259 ),
260 );
261
262 $form['submit'] = array(
263 '#type' => 'submit',
264 '#value' => t('Create new style'),
265 );
266
267 return $form;
268 }
269
273 function image_style_add_form_submit($form, &$form_state) {
274 $style = array(
275 'name' => $form_state['values']['name'],
276 'label' => $form_state['values']['label'],
277 );
278 $style = image_style_save($style);
279 drupal_set_message(t('Style %name was created.', array('%name' => $style['label'])));
280 $form_state['redirect'] = 'admin/config/media/image-styles/edit/' . $style['name'];
281 }
282
291 function image_style_name_validate($element, $form_state) {
292 // Check for duplicates.
293 $styles = image_styles();
294 if (isset($styles[$element['#value']]) && (!isset($form_state['image_style']['isid']) || $styles[$element['#value']]['isid'] != $form_state['image_style']['isid'])) {
295 form_set_error($element['#name'], t('The image style name %name is already in use.', array('%name' => $element['#value'])));
296 }
297
298 // Check for illegal characters in image style names.
299 if (preg_match('/[^0-9a-z_\-]/', $element['#value'])) {
300 form_set_error($element['#name'], t('Please only use lowercase alphanumeric characters, underscores (_), and hyphens (-) for style names.'));
301 }
302 }
303
313 function image_style_delete_form($form, &$form_state, $style) {
314 $form_state['image_style'] = $style;
315
316 $replacement_styles = array_diff_key(image_style_options(TRUE, PASS_THROUGH), array($style['name'] => ''));
317 $form['replacement'] = array(
318 '#title' => t('Replacement style'),
319 '#type' => 'select',
320 '#options' => $replacement_styles,
321 '#empty_option' => t('No replacement, just delete'),
322 );
323
324 return confirm_form(
325 $form,
326 t('Optionally select a style before deleting %style', array('%style' => $style['label'])),
327 'admin/config/media/image-styles',
328 t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted.'),
329 t('Delete'), t('Cancel')
330 );
331 }
332
336 function image_style_delete_form_submit($form, &$form_state) {
337 $style = $form_state['image_style'];
338
339 image_style_delete($style, $form_state['values']['replacement']);
340 drupal_set_message(t('Style %name was deleted.', array('%name' => $style['label'])));
341 $form_state['redirect'] = 'admin/config/media/image-styles';
342 }
343
347 function image_style_revert_form($form, &$form_state, $style) {
348 $form_state['image_style'] = $style;
349
350 return confirm_form(
351 $form,
352 t('Revert the %style style?', array('%style' => $style['label'])),
353 'admin/config/media/image-styles',
354 t('Reverting this style will delete the customized settings and restore the defaults provided by the @module module.', array('@module' => $style['module'])),
355 t('Revert'), t('Cancel')
356 );
357 }
358
362 function image_style_revert_form_submit($form, &$form_state) {
363 drupal_set_message(t('The %style style has been reverted to its defaults.', array('%style' => $form_state['image_style']['label'])));
364 image_default_style_revert($form_state['image_style']);
365 $form_state['redirect'] = 'admin/config/media/image-styles';
366 }
367
391 function image_effect_form($form, &$form_state, $style, $effect) {
392 if (!empty($effect['data'])) {
393 $title = t('Edit %label effect', array('%label' => $effect['label']));
394 }
395 else{
396 $title = t('Add %label effect', array('%label' => $effect['label']));
397 }
398 drupal_set_title($title, PASS_THROUGH);
399
400 $form_state['image_style'] = $style;
401 $form_state['image_effect'] = $effect;
402
403 // If no configuration for this image effect, return to the image style page.
404 if (!isset($effect['form callback'])) {
405 drupal_goto('admin/config/media/image-styles/edit/' . $style['name']);
406 }
407
408 $form['#tree'] = TRUE;
409 $form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array();
410 if (function_exists($effect['form callback'])) {
411 $form['data'] = call_user_func($effect['form callback'], $effect['data']);
412 }
413
414 // Check the URL for a weight, then the image effect, otherwise use default.
415 $form['weight'] = array(
416 '#type' => 'hidden',
417 '#value' => isset($_GET['weight']) ? intval($_GET['weight']) : (isset($effect['weight']) ? $effect['weight'] : count($style['effects'])),
418 );
419
420 $form['actions'] = array('#tree' => FALSE, '#type' => 'actions');
421 $form['actions']['submit'] = array(
422 '#type' => 'submit',
423 '#value' => isset($effect['ieid']) ? t('Update effect') : t('Add effect'),
424 );
425 $form['actions']['cancel'] = array(
426 '#type' => 'link',
427 '#title' => t('Cancel'),
428 '#href' => 'admin/config/media/image-styles/edit/' . $style['name'],
429 );
430
431 return $form;
432 }
433
437 function image_effect_form_submit($form, &$form_state) {
438 $style = $form_state['image_style'];
439 $effect = array_merge($form_state['image_effect'], $form_state['values']);
440 $effect['isid'] = $style['isid'];
441 image_effect_save($effect);
442 drupal_set_message(t('The image effect was successfully applied.'));
443 $form_state['redirect'] = 'admin/config/media/image-styles/edit/' . $style['name'];
444 }
445
456 function image_effect_delete_form($form, &$form_state, $style, $effect) {
457 $form_state['image_style'] = $style;
458 $form_state['image_effect'] = $effect;
459
460 $question = t('Are you sure you want to delete the @effect effect from the %style style?', array('%style' => $style['label'], '@effect' => $effect['label']));
461 return confirm_form($form, $question, 'admin/config/media/image-styles/edit/' . $style['name'], '', t('Delete'));
462 }
463
467 function image_effect_delete_form_submit($form, &$form_state) {
468 $style = $form_state['image_style'];
469 $effect = $form_state['image_effect'];
470
471 image_effect_delete($effect);
472 drupal_set_message(t('The image effect %name has been deleted.', array('%name' => $effect['label'])));
473 $form_state['redirect'] = 'admin/config/media/image-styles/edit/' . $style['name'];
474 }
475
481 function image_effect_integer_validate($element, &$form_state) {
482 $value = empty($element['#allow_negative']) ? $element['#value'] : preg_replace('/^-/', '', $element['#value']);
483 if ($element['#value'] != '' && (!is_numeric($value) || intval($value) <= 0)) {
484 if (empty($element['#allow_negative'])) {
485 form_error($element, t('!name must be an integer.', array('!name' => $element['#title'])));
486 }
487 else {
488 form_error($element, t('!name must be a positive integer.', array('!name' => $element['#title'])));
489 }
490 }
491 }
492
496 function image_effect_color_validate($element, &$form_state) {
497 if ($element['#value'] != '') {
498 $hex_value = preg_replace('/^#/', '', $element['#value']);
499 if (!preg_match('/^#[0-9A-F]{3}([0-9A-F]{3})?$/', $element['#value'])) {
500 form_error($element, t('!name must be a hexadecimal color value.', array('!name' => $element['#title'])));
501 }
502 }
503 }
504
509 function image_effect_scale_validate($element, &$form_state) {
510 if (empty($element['width']['#value']) && empty($element['height']['#value'])) {
511 form_error($element, t('Width and height can not both be blank.'));
512 }
513 }
514
525 function image_resize_form($data) {
526 $form['width'] = array(
527 '#type' => 'textfield',
528 '#title' => t('Width'),
529 '#default_value' => isset($data['width']) ? $data['width'] : '',
530 '#field_suffix' => ' ' . t('pixels'),
531 '#required' => TRUE,
532 '#size' => 10,
533 '#element_validate' => array('image_effect_integer_validate'),
534 '#allow_negative' => FALSE,
535 );
536 $form['height'] = array(
537 '#type' => 'textfield',
538 '#title' => t('Height'),
539 '#default_value' => isset($data['height']) ? $data['height'] : '',
540 '#field_suffix' => ' ' . t('pixels'),
541 '#required' => TRUE,
542 '#size' => 10,
543 '#element_validate' => array('image_effect_integer_validate'),
544 '#allow_negative' => FALSE,
545 );
546 return $form;
547 }
548
559 function image_scale_form($data) {
560 $form = image_resize_form($data);
561 $form['#element_validate'] = array('image_effect_scale_validate');
562 $form['width']['#required'] = FALSE;
563 $form['height']['#required'] = FALSE;
564 $form['upscale'] = array(
565 '#type' => 'checkbox',
566 '#default_value' => (isset($data['upscale'])) ? $data['upscale'] : 0,
567 '#title' => t('Allow Upscaling'),
568 '#description' => t('Let scale make images larger than their original size'),
569 );
570 return $form;
571 }
572
583 function image_crop_form($data) {
584 $data += array(
585 'width' => '',
586 'height' => '',
587 'anchor' => 'center-center',
588 );
589
590 $form = image_resize_form($data);
591 $form['anchor'] = array(
592 '#type' => 'radios',
593 '#title' => t('Anchor'),
594 '#options' => array(
595 'left-top' => t('Top') . ' ' . t('Left'),
596 'center-top' => t('Top') . ' ' . t('Center'),
597 'right-top' => t('Top') . ' ' . t('Right'),
598 'left-center' => t('Center') . ' ' . t('Left'),
599 'center-center' => t('Center'),
600 'right-center' => t('Center') . ' ' . t('Right'),
601 'left-bottom' => t('Bottom') . ' ' . t('Left'),
602 'center-bottom' => t('Bottom') . ' ' . t('Center'),
603 'right-bottom' => t('Bottom') . ' ' . t('Right'),
604 ),
605 '#theme' => 'image_anchor',
606 '#default_value' => $data['anchor'],
607 '#description' => t('The part of the image that will be retained during the crop.'),
608 );
609
610 return $form;
611 }
612
623 function image_rotate_form($data) {
624 $form['degrees'] = array(
625 '#type' => 'textfield',
626 '#default_value' => (isset($data['degrees'])) ? $data['degrees'] : 0,
627 '#title' => t('Rotation angle'),
628 '#description' => t('The number of degrees the image should be rotated. Positive numbers are clockwise, negative are counter-clockwise.'),
629 '#field_suffix' => '&deg;',
630 '#required' => TRUE,
631 '#size' => 6,
632 '#maxlength' => 4,
633 '#element_validate' => array('image_effect_integer_validate'),
634 '#allow_negative' => TRUE,
635 );
636 $form['bgcolor'] = array(
637 '#type' => 'textfield',
638 '#default_value' => (isset($data['bgcolor'])) ? $data['bgcolor'] : '#FFFFFF',
639 '#title' => t('Background color'),
640 '#description' => t('The background color to use for exposed areas of the image. Use web-style hex colors (#FFFFFF for white, #000000 for black). Leave blank for transparency on image types that support it.'),
641 '#size' => 7,
642 '#maxlength' => 7,
643 '#element_validate' => array('image_effect_color_validate'),
644 );
645 $form['random'] = array(
646 '#type' => 'checkbox',
647 '#default_value' => (isset($data['random'])) ? $data['random'] : 0,
648 '#title' => t('Randomize'),
649 '#description' => t('Randomize the rotation angle for each image. The angle specified above is used as a maximum.'),
650 );
651 return $form;
652 }
653
664 function theme_image_style_list($variables) {
665 $styles = $variables['styles'];
666
667 $header = array(t('Style name'), t('Settings'), array('data' => t('Operations'), 'colspan' => 3));
668 $rows = array();
669 foreach ($styles as $style) {
670 $row = array();
671 $row[] = l($style['label'], 'admin/config/media/image-styles/edit/' . $style['name']);
672 $link_attributes = array(
673 'attributes' => array(
674 'class' => array('image-style-link'),
675 ),
676 );
677 if ($style['storage'] == IMAGE_STORAGE_NORMAL) {
678 $row[] = t('Custom');
679 $row[] = l(t('edit'), 'admin/config/media/image-styles/edit/' . $style['name'], $link_attributes);
680 $row[] = l(t('delete'), 'admin/config/media/image-styles/delete/' . $style['name'], $link_attributes);
681 }
682 elseif ($style['storage'] == IMAGE_STORAGE_OVERRIDE) {
683 $row[] = t('Overridden');
684 $row[] = l(t('edit'), 'admin/config/media/image-styles/edit/' . $style['name'], $link_attributes);
685 $row[] = l(t('revert'), 'admin/config/media/image-styles/revert/' . $style['name'], $link_attributes);
686 }
687 else {
688 $row[] = t('Default');
689 $row[] = l(t('edit'), 'admin/config/media/image-styles/edit/' . $style['name'], $link_attributes);
690 $row[] = '';
691 }
692 $rows[] = $row;
693 }
694
695 if (empty($rows)) {
696 $rows[] = array(array(
697 'colspan' => 4,
698 'data' => t('There are currently no styles. <a href="!url">Add a new one</a>.', array('!url' => url('admin/config/media/image-styles/add'))),
699 ));
700 }
701
702 return theme('table', array('header' => $header, 'rows' => $rows));
703 }
704
714 function theme_image_style_effects($variables) {
715 $form = $variables['form'];
716
717 $rows = array();
718
719 foreach (element_children($form) as $key) {
720 $row = array();
721 $form[$key]['weight']['#attributes']['class'] = array('image-effect-order-weight');
722 if (is_numeric($key)) {
723 $summary = drupal_render($form[$key]['summary']);
724 $row[] = drupal_render($form[$key]['label']) . (empty($summary) ? '' : ' ' . $summary);
725 $row[] = drupal_render($form[$key]['weight']);
726 $row[] = drupal_render($form[$key]['configure']);
727 $row[] = drupal_render($form[$key]['remove']);
728 }
729 else {
730 // Add the row for adding a new image effect.
731 $row[] = '<div class="image-style-new">' . drupal_render($form['new']['new']) . drupal_render($form['new']['add']) . '</div>';
732 $row[] = drupal_render($form['new']['weight']);
733 $row[] = array('data' => '', 'colspan' => 2);
734 }
735
736 if (!isset($form[$key]['#access']) || $form[$key]['#access']) {
737 $rows[] = array(
738 'data' => $row,
739 'class' => !empty($form[$key]['weight']['#access']) || $key == 'new' ? array('draggable') : array(),
740 );
741 }
742 }
743
744 $header = array(
745 t('Effect'),
746 t('Weight'),
747 array('data' => t('Operations'), 'colspan' => 2),
748 );
749
750 if (count($rows) == 1 && $form['new']['#access']) {
751 array_unshift($rows, array(array(
752 'data' => t('There are currently no effects in this style. Add one by selecting an option below.'),
753 'colspan' => 4,
754 )));
755 }
756
757 $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'image-style-effects')));
758 drupal_add_tabledrag('image-style-effects', 'order', 'sibling', 'image-effect-order-weight');
759 return $output;
760 }
761
771 function theme_image_style_preview($variables) {
772 $style = $variables['style'];
773
774 $sample_image = variable_get('image_style_preview_image', drupal_get_path('module', 'image') . '/sample.png');
775 $sample_width = 160;
776 $sample_height = 160;
777
778 // Set up original file information.
779 $original_path = $sample_image;
780 $original_image = image_get_info($original_path);
781 if ($original_image['width'] > $original_image['height']) {
782 $original_width = min($original_image['width'], $sample_width);
783 $original_height = round($original_width / $original_image['width'] * $original_image['height']);
784 }
785 else {
786 $original_height = min($original_image['height'], $sample_height);
787 $original_width = round($original_height / $original_image['height'] * $original_image['width']);
788 }
789 $original_attributes = array_intersect_key($original_image, array('width' => '', 'height' => ''));
790 $original_attributes['style'] = 'width: ' . $original_width . 'px; height: ' . $original_height . 'px;';
791
792 // Set up preview file information.
793 $preview_file = image_style_path($style['name'], $original_path);
794 if (!file_exists($preview_file)) {
795 image_style_create_derivative($style, $original_path, $preview_file);
796 }
797 $preview_image = image_get_info($preview_file);
798 if ($preview_image['width'] > $preview_image['height']) {
799 $preview_width = min($preview_image['width'], $sample_width);
800 $preview_height = round($preview_width / $preview_image['width'] * $preview_image['height']);
801 }
802 else {
803 $preview_height = min($preview_image['height'], $sample_height);
804 $preview_width = round($preview_height / $preview_image['height'] * $preview_image['width']);
805 }
806 $preview_attributes = array_intersect_key($preview_image, array('width' => '', 'height' => ''));
807 $preview_attributes['style'] = 'width: ' . $preview_width . 'px; height: ' . $preview_height . 'px;';
808
809 // In the previews, timestamps are added to prevent caching of images.
810 $output = '<div class="image-style-preview preview clearfix">';
811
812 // Build the preview of the original image.
813 $original_url = file_create_url($original_path);
814 $output .= '<div class="preview-image-wrapper">';
815 $output .= t('original') . ' (' . l(t('view actual size'), $original_url) . ')';
816 $output .= '<div class="preview-image original-image" style="' . $original_attributes['style'] . '">';
817 $output .= '<a href="' . $original_url . '">' . theme('image', array('path' => $original_path, 'alt' => t('Sample original image'), 'title' => '', 'attributes' => $original_attributes)) . '</a>';
818 $output .= '<div class="height" style="height: ' . $original_height . 'px"><span>' . $original_image['height'] . 'px</span></div>';
819 $output .= '<div class="width" style="width: ' . $original_width . 'px"><span>' . $original_image['width'] . 'px</span></div>';
820 $output .= '</div>'; // End preview-image.
821 $output .= '</div>'; // End preview-image-wrapper.
822
823 // Build the preview of the image style.
824 $preview_url = file_create_url($preview_file) . '?cache_bypass=' . REQUEST_TIME;
825 $output .= '<div class="preview-image-wrapper">';
826 $output .= check_plain($style['label']) . ' (' . l(t('view actual size'), file_create_url($preview_file) . '?' . time()) . ')';
827 $output .= '<div class="preview-image modified-image" style="' . $preview_attributes['style'] . '">';
828 $output .= '<a href="' . file_create_url($preview_file) . '?' . time() . '">' . theme('image', array('path' => $preview_url, 'alt' => t('Sample modified image'), 'title' => '', 'attributes' => $preview_attributes)) . '</a>';
829 $output .= '<div class="height" style="height: ' . $preview_height . 'px"><span>' . $preview_image['height'] . 'px</span></div>';
830 $output .= '<div class="width" style="width: ' . $preview_width . 'px"><span>' . $preview_image['width'] . 'px</span></div>';
831 $output .= '</div>'; // End preview-image.
832 $output .= '</div>'; // End preview-image-wrapper.
833
834 $output .= '</div>'; // End image-style-preview.
835
836 return $output;
837 }
838
848 function theme_image_anchor($variables) {
849 $element = $variables['element'];
850
851 $rows = array();
852 $row = array();
853 foreach (element_children($element) as $n => $key) {
854 $element[$key]['#attributes']['title'] = $element[$key]['#title'];
855 unset($element[$key]['#title']);
856 $row[] = drupal_render($element[$key]);
857 if ($n % 3 == 3 - 1) {
858 $rows[] = $row;
859 $row = array();
860 }
861 }
862
863 return theme('table', array('header' => array(), 'rows' => $rows, 'attributes' => array('class' => array('image-anchor'))));
864 }
865
875 function theme_image_resize_summary($variables) {
876 $data = $variables['data'];
877
878 if ($data['width'] && $data['height']) {
879 return check_plain($data['width']) . 'x' . check_plain($data['height']);
880 }
881 else {
882 return ($data['width']) ? t('width @width', array('@width' => $data['width'])) : t('height @height', array('@height' => $data['height']));
883 }
884 }
885
895 function theme_image_scale_summary($variables) {
896 $data = $variables['data'];
897 return theme('image_resize_summary', array('data' => $data)) . ' ' . ($data['upscale'] ? '(' . t('upscaling allowed') . ')' : '');
898 }
899
909 function theme_image_crop_summary($variables) {
910 return theme('image_resize_summary', $variables);
911 }
912
922 function theme_image_rotate_summary($variables) {
923 $data = $variables['data'];
924 return ($data['random']) ? t('random between -@degrees&deg and @degrees&deg', array('@degrees' => str_replace('-', '', $data['degrees']))) : t('@degrees&deg', array('@degrees' => $data['degrees']));
925 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
IMAGE_STORAGE_EDITABLE
const IMAGE_STORAGE_EDITABLE
Definition: image.module:26
image_style_form_add_submit
image_style_form_add_submit($form, &$form_state)
Definition: image.admin.inc:182
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
image_style_form_submit
image_style_form_submit($form, &$form_state)
Definition: image.admin.inc:212
image_effect_save
image_effect_save($effect)
Definition: image.module:1282
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
theme_image_rotate_summary
theme_image_rotate_summary($variables)
Definition: image.admin.inc:922
image_style_add_form_submit
image_style_add_form_submit($form, &$form_state)
Definition: image.admin.inc:273
image_style_add_form
image_style_add_form($form, &$form_state)
Definition: image.admin.inc:242
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
theme_image_scale_summary
theme_image_scale_summary($variables)
Definition: image.admin.inc:895
image_effect_delete_form
image_effect_delete_form($form, &$form_state, $style, $effect)
Definition: image.admin.inc:456
file_create_url
file_create_url($uri)
Definition: file.inc:372
image_scale_form
image_scale_form($data)
Definition: image.admin.inc:559
image_default_style_save
image_default_style_save($style)
Definition: image.module:1096
$page
print $page
Definition: overlay.tpl.php:37
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
theme_image_style_effects
theme_image_style_effects($variables)
Definition: image.admin.inc:714
$header
print $header
Definition: forum-topic-list.tpl.php:42
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
image_styles
image_styles()
Definition: image.module:565
image_style_revert_form_submit
image_style_revert_form_submit($form, &$form_state)
Definition: image.admin.inc:362
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
image_effect_definitions
image_effect_definitions()
Definition: image.module:1136
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
image_style_list
image_style_list()
Definition: image.admin.inc:11
image_style_delete
image_style_delete($style, $replacement_style_name= '')
Definition: image.module:725
image_style_delete_form_submit
image_style_delete_form_submit($form, &$form_state)
Definition: image.admin.inc:336
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
image_get_info
image_get_info($filepath, $toolkit=FALSE)
Definition: image.inc:124
image_style_revert_form
image_style_revert_form($form, &$form_state, $style)
Definition: image.admin.inc:347
image_style_form
image_style_form($form, &$form_state, $style)
Definition: image.admin.inc:36
theme_image_resize_summary
theme_image_resize_summary($variables)
Definition: image.admin.inc:875
image_style_path
image_style_path($style_name, $uri)
Definition: image.module:1074
image_effect_delete_form_submit
image_effect_delete_form_submit($form, &$form_state)
Definition: image.admin.inc:467
image_style_save
image_style_save($style)
Definition: image.module:685
theme_image_style_list
theme_image_style_list($variables)
Definition: image.admin.inc:664
$value
print $value
Definition: user-profile-item.tpl.php:26
image_style_form_override_submit
image_style_form_override_submit($form, &$form_state)
Definition: image.admin.inc:204
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
image_effect_form_submit
image_effect_form_submit($form, &$form_state)
Definition: image.admin.inc:437
$output
$output
Definition: authorize.php:93
image_style_options
image_style_options($include_empty=TRUE, $output=CHECK_PLAIN)
Definition: image.module:781
image_effect_delete
image_effect_delete($effect)
Definition: image.module:1300
image_style_form_add_validate
image_style_form_add_validate($form, &$form_state)
Definition: image.admin.inc:173
image_effect_color_validate
image_effect_color_validate($element, &$form_state)
Definition: image.admin.inc:496
image_effect_form
image_effect_form($form, &$form_state, $style, $effect)
Definition: image.admin.inc:391
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
image_crop_form
image_crop_form($data)
Definition: image.admin.inc:583
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
$styles
print $styles
Definition: html.tpl.php:52
image_effect_integer_validate
image_effect_integer_validate($element, &$form_state)
Definition: image.admin.inc:481
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$row
$row
Definition: block-admin-display-form.tpl.php:47
theme_image_anchor
theme_image_anchor($variables)
Definition: image.admin.inc:848
image_style_create_derivative
image_style_create_derivative($style, $source, $destination)
Definition: image.module:903
image_style_name_validate
image_style_name_validate($element, $form_state)
Definition: image.admin.inc:291
IMAGE_STORAGE_OVERRIDE
const IMAGE_STORAGE_OVERRIDE
Definition: image.module:16
theme_image_style_preview
theme_image_style_preview($variables)
Definition: image.admin.inc:771
image_effect_definition_load
image_effect_definition_load($effect, $style_name=NULL)
Definition: image.module:1195
theme_image_crop_summary
theme_image_crop_summary($variables)
Definition: image.admin.inc:909
image_default_style_revert
image_default_style_revert($style)
Definition: image.module:1116
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
image_resize_form
image_resize_form($data)
Definition: image.admin.inc:525
IMAGE_STORAGE_NORMAL
const IMAGE_STORAGE_NORMAL
Definition: image.module:11
image_rotate_form
image_rotate_form($data)
Definition: image.admin.inc:623
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
image_effect_scale_validate
image_effect_scale_validate($element, &$form_state)
Definition: image.admin.inc:509
image_style_delete_form
image_style_delete_form($form, &$form_state, $style)
Definition: image.admin.inc:313
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/database.inc Source File

  • includes
  • database
database.inc
Go to the documentation of this file.
1 <?php
2
184 abstract class DatabaseConnection extends PDO {
185
193 protected $target = NULL;
194
204 protected $key = NULL;
205
211 protected $logger = NULL;
212
222 protected $transactionLayers = array();
223
229 protected $driverClasses = array();
230
236 protected $statementClass = 'DatabaseStatementBase';
237
243 protected $transactionSupport = TRUE;
244
252 protected $transactionalDDLSupport = FALSE;
253
259 protected $temporaryNameIndex = 0;
260
266 protected $connectionOptions = array();
267
273 protected $schema = NULL;
274
280 protected $prefixes = array();
281
287 protected $prefixSearch = array();
288
294 protected $prefixReplace = array();
295
296 function __construct($dsn, $username, $password, $driver_options = array()) {
297 // Initialize and prepare the connection prefix.
298 $this->setPrefix(isset($this->connectionOptions['prefix']) ? $this->connectionOptions['prefix'] : '');
299
300 // Because the other methods don't seem to work right.
301 $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
302
303 // Call PDO::__construct and PDO::setAttribute.
304 parent::__construct($dsn, $username, $password, $driver_options);
305
306 // Set a Statement class, unless the driver opted out.
307 if (!empty($this->statementClass)) {
308 $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this)));
309 }
310 }
311
320 public function destroy() {
321 // Destroy all references to this connection by setting them to NULL.
322 // The Statement class attribute only accepts a new value that presents a
323 // proper callable, so we reset it to PDOStatement.
324 $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement', array()));
325 $this->schema = NULL;
326 }
327
373 protected function defaultOptions() {
374 return array(
375 'target' => 'default',
376 'fetch' => PDO::FETCH_OBJ,
377 'return' => Database::RETURN_STATEMENT,
378 'throw_exception' => TRUE,
379 );
380 }
381
394 public function getConnectionOptions() {
395 return $this->connectionOptions;
396 }
397
405 protected function setPrefix($prefix) {
406 if (is_array($prefix)) {
407 $this->prefixes = $prefix + array('default' => '');
408 }
409 else {
410 $this->prefixes = array('default' => $prefix);
411 }
412
413 // Set up variables for use in prefixTables(). Replace table-specific
414 // prefixes first.
415 $this->prefixSearch = array();
416 $this->prefixReplace = array();
417 foreach ($this->prefixes as $key => $val) {
418 if ($key != 'default') {
419 $this->prefixSearch[] = '{' . $key . '}';
420 $this->prefixReplace[] = $val . $key;
421 }
422 }
423 // Then replace remaining tables with the default prefix.
424 $this->prefixSearch[] = '{';
425 $this->prefixReplace[] = $this->prefixes['default'];
426 $this->prefixSearch[] = '}';
427 $this->prefixReplace[] = '';
428 }
429
444 public function prefixTables($sql) {
445 return str_replace($this->prefixSearch, $this->prefixReplace, $sql);
446 }
447
454 public function tablePrefix($table = 'default') {
455 if (isset($this->prefixes[$table])) {
456 return $this->prefixes[$table];
457 }
458 else {
459 return $this->prefixes['default'];
460 }
461 }
462
476 public function prepareQuery($query) {
477 $query = $this->prefixTables($query);
478
479 // Call PDO::prepare.
480 return parent::prepare($query);
481 }
482
495 public function setTarget($target = NULL) {
496 if (!isset($this->target)) {
497 $this->target = $target;
498 }
499 }
500
507 public function getTarget() {
508 return $this->target;
509 }
510
517 public function setKey($key) {
518 if (!isset($this->key)) {
519 $this->key = $key;
520 }
521 }
522
529 public function getKey() {
530 return $this->key;
531 }
532
539 public function setLogger(DatabaseLog $logger) {
540 $this->logger = $logger;
541 }
542
550 public function getLogger() {
551 return $this->logger;
552 }
553
568 public function makeSequenceName($table, $field) {
569 return $this->prefixTables('{' . $table . '}_' . $field . '_seq');
570 }
571
583 public function makeComment($comments) {
584 if (empty($comments))
585 return '';
586
587 // Flatten the array of comments.
588 $comment = implode('; ', $comments);
589
590 // Sanitize the comment string so as to avoid SQL injection attacks.
591 return '/* ' . $this->filterComment($comment) . ' */ ';
592 }
593
625 protected function filterComment($comment = '') {
626 return preg_replace('/(\/\*\s*)|(\s*\*\/)/', '', $comment);
627 }
628
664 public function query($query, array $args = array(), $options = array()) {
665
666 // Use default values if not already set.
667 $options += $this->defaultOptions();
668
669 try {
670 // We allow either a pre-bound statement object or a literal string.
671 // In either case, we want to end up with an executed statement object,
672 // which we pass to PDOStatement::execute.
673 if ($query instanceof DatabaseStatementInterface) {
674 $stmt = $query;
675 $stmt->execute(NULL, $options);
676 }
677 else {
678 $this->expandArguments($query, $args);
679 $stmt = $this->prepareQuery($query);
680 $stmt->execute($args, $options);
681 }
682
683 // Depending on the type of query we may need to return a different value.
684 // See DatabaseConnection::defaultOptions() for a description of each
685 // value.
686 switch ($options['return']) {
687 case Database::RETURN_STATEMENT:
688 return $stmt;
689 case Database::RETURN_AFFECTED:
690 return $stmt->rowCount();
691 case Database::RETURN_INSERT_ID:
692 return $this->lastInsertId();
693 case Database::RETURN_NULL:
694 return;
695 default:
696 throw new PDOException('Invalid return directive: ' . $options['return']);
697 }
698 }
699 catch (PDOException $e) {
700 if ($options['throw_exception']) {
701 // Add additional debug information.
702 if ($query instanceof DatabaseStatementInterface) {
703 $e->query_string = $stmt->getQueryString();
704 }
705 else {
706 $e->query_string = $query;
707 }
708 $e->args = $args;
709 throw $e;
710 }
711 return NULL;
712 }
713 }
714
729 protected function expandArguments(&$query, &$args) {
730 $modified = FALSE;
731
732 // If the placeholder value to insert is an array, assume that we need
733 // to expand it out into a comma-delimited set of placeholders.
734 foreach (array_filter($args, 'is_array') as $key => $data) {
735 $new_keys = array();
736 foreach ($data as $i => $value) {
737 // This assumes that there are no other placeholders that use the same
738 // name. For example, if the array placeholder is defined as :example
739 // and there is already an :example_2 placeholder, this will generate
740 // a duplicate key. We do not account for that as the calling code
741 // is already broken if that happens.
742 $new_keys[$key . '_' . $i] = $value;
743 }
744
745 // Update the query with the new placeholders.
746 // preg_replace is necessary to ensure the replacement does not affect
747 // placeholders that start with the same exact text. For example, if the
748 // query contains the placeholders :foo and :foobar, and :foo has an
749 // array of values, using str_replace would affect both placeholders,
750 // but using the following preg_replace would only affect :foo because
751 // it is followed by a non-word character.
752 $query = preg_replace('#' . $key . '\b#', implode(', ', array_keys($new_keys)), $query);
753
754 // Update the args array with the new placeholders.
755 unset($args[$key]);
756 $args += $new_keys;
757
758 $modified = TRUE;
759 }
760
761 return $modified;
762 }
763
777 public function getDriverClass($class, array $files = array(), $use_autoload = FALSE) {
778 if (empty($this->driverClasses[$class])) {
779 $driver = $this->driver();
780 $this->driverClasses[$class] = $class . '_' . $driver;
781 Database::loadDriverFile($driver, $files);
782 if (!class_exists($this->driverClasses[$class], $use_autoload)) {
783 $this->driverClasses[$class] = $class;
784 }
785 }
786 return $this->driverClasses[$class];
787 }
788
808 public function select($table, $alias = NULL, array $options = array()) {
809 $class = $this->getDriverClass('SelectQuery', array('query.inc', 'select.inc'));
810 return new $class($table, $alias, $this, $options);
811 }
812
824 public function insert($table, array $options = array()) {
825 $class = $this->getDriverClass('InsertQuery', array('query.inc'));
826 return new $class($this, $table, $options);
827 }
828
840 public function merge($table, array $options = array()) {
841 $class = $this->getDriverClass('MergeQuery', array('query.inc'));
842 return new $class($this, $table, $options);
843 }
844
845
857 public function update($table, array $options = array()) {
858 $class = $this->getDriverClass('UpdateQuery', array('query.inc'));
859 return new $class($this, $table, $options);
860 }
861
873 public function delete($table, array $options = array()) {
874 $class = $this->getDriverClass('DeleteQuery', array('query.inc'));
875 return new $class($this, $table, $options);
876 }
877
889 public function truncate($table, array $options = array()) {
890 $class = $this->getDriverClass('TruncateQuery', array('query.inc'));
891 return new $class($this, $table, $options);
892 }
893
902 public function schema() {
903 if (empty($this->schema)) {
904 $class = $this->getDriverClass('DatabaseSchema', array('schema.inc'));
905 if (class_exists($class)) {
906 $this->schema = new $class($this);
907 }
908 }
909 return $this->schema;
910 }
911
922 public function escapeTable($table) {
923 return preg_replace('/[^A-Za-z0-9_.]+/', '', $table);
924 }
925
936 public function escapeField($field) {
937 return preg_replace('/[^A-Za-z0-9_.]+/', '', $field);
938 }
939
951 public function escapeAlias($field) {
952 return preg_replace('/[^A-Za-z0-9_]+/', '', $field);
953 }
954
980 public function escapeLike($string) {
981 return addcslashes($string, '\%_');
982 }
983
990 public function inTransaction() {
991 return ($this->transactionDepth() > 0);
992 }
993
997 public function transactionDepth() {
998 return count($this->transactionLayers);
999 }
1000
1012 public function startTransaction($name = '') {
1013 $class = $this->getDriverClass('DatabaseTransaction');
1014 return new $class($this, $name);
1015 }
1016
1030 public function rollback($savepoint_name = 'drupal_transaction') {
1031 if (!$this->supportsTransactions()) {
1032 return;
1033 }
1034 if (!$this->inTransaction()) {
1035 throw new DatabaseTransactionNoActiveException();
1036 }
1037 // A previous rollback to an earlier savepoint may mean that the savepoint
1038 // in question has already been accidentally committed.
1039 if (!isset($this->transactionLayers[$savepoint_name])) {
1040 throw new DatabaseTransactionNoActiveException();
1041 }
1042
1043 // We need to find the point we're rolling back to, all other savepoints
1044 // before are no longer needed. If we rolled back other active savepoints,
1045 // we need to throw an exception.
1046 $rolled_back_other_active_savepoints = FALSE;
1047 while ($savepoint = array_pop($this->transactionLayers)) {
1048 if ($savepoint == $savepoint_name) {
1049 // If it is the last the transaction in the stack, then it is not a
1050 // savepoint, it is the transaction itself so we will need to roll back
1051 // the transaction rather than a savepoint.
1052 if (empty($this->transactionLayers)) {
1053 break;
1054 }
1055 $this->query('ROLLBACK TO SAVEPOINT ' . $savepoint);
1056 $this->popCommittableTransactions();
1057 if ($rolled_back_other_active_savepoints) {
1058 throw new DatabaseTransactionOutOfOrderException();
1059 }
1060 return;
1061 }
1062 else {
1063 $rolled_back_other_active_savepoints = TRUE;
1064 }
1065 }
1066 parent::rollBack();
1067 if ($rolled_back_other_active_savepoints) {
1068 throw new DatabaseTransactionOutOfOrderException();
1069 }
1070 }
1071
1081 public function pushTransaction($name) {
1082 if (!$this->supportsTransactions()) {
1083 return;
1084 }
1085 if (isset($this->transactionLayers[$name])) {
1086 throw new DatabaseTransactionNameNonUniqueException($name . " is already in use.");
1087 }
1088 // If we're already in a transaction then we want to create a savepoint
1089 // rather than try to create another transaction.
1090 if ($this->inTransaction()) {
1091 $this->query('SAVEPOINT ' . $name);
1092 }
1093 else {
1094 parent::beginTransaction();
1095 }
1096 $this->transactionLayers[$name] = $name;
1097 }
1098
1114 public function popTransaction($name) {
1115 if (!$this->supportsTransactions()) {
1116 return;
1117 }
1118 // The transaction has already been committed earlier. There is nothing we
1119 // need to do. If this transaction was part of an earlier out-of-order
1120 // rollback, an exception would already have been thrown by
1121 // Database::rollback().
1122 if (!isset($this->transactionLayers[$name])) {
1123 return;
1124 }
1125
1126 // Mark this layer as committable.
1127 $this->transactionLayers[$name] = FALSE;
1128 $this->popCommittableTransactions();
1129 }
1130
1134 protected function popCommittableTransactions() {
1135 // Commit all the committable layers.
1136 foreach (array_reverse($this->transactionLayers) as $name => $active) {
1137 // Stop once we found an active transaction.
1138 if ($active) {
1139 break;
1140 }
1141
1142 // If there are no more layers left then we should commit.
1143 unset($this->transactionLayers[$name]);
1144 if (empty($this->transactionLayers)) {
1145 if (!parent::commit()) {
1146 throw new DatabaseTransactionCommitFailedException();
1147 }
1148 }
1149 else {
1150 $this->query('RELEASE SAVEPOINT ' . $name);
1151 }
1152 }
1153 }
1154
1178 abstract public function queryRange($query, $from, $count, array $args = array(), array $options = array());
1179
1186 protected function generateTemporaryTableName() {
1187 return "db_temporary_" . $this->temporaryNameIndex++;
1188 }
1189
1213 abstract function queryTemporary($query, array $args = array(), array $options = array());
1214
1223 abstract public function driver();
1224
1228 public function version() {
1229 return $this->getAttribute(PDO::ATTR_SERVER_VERSION);
1230 }
1231
1238 public function supportsTransactions() {
1239 return $this->transactionSupport;
1240 }
1241
1251 public function supportsTransactionalDDL() {
1252 return $this->transactionalDDLSupport;
1253 }
1254
1258 abstract public function databaseType();
1259
1260
1277 abstract public function mapConditionOperator($operator);
1278
1291 public function commit() {
1292 throw new DatabaseTransactionExplicitCommitNotAllowedException();
1293 }
1294
1312 abstract public function nextId($existing_id = 0);
1313 }
1314
1322 abstract class Database {
1323
1330 const RETURN_NULL = 0;
1331
1335 const RETURN_STATEMENT = 1;
1336
1340 const RETURN_AFFECTED = 2;
1341
1345 const RETURN_INSERT_ID = 3;
1346
1353 static protected $connections = array();
1354
1360 static protected $databaseInfo = NULL;
1361
1367 static protected $ignoreTargets = array();
1368
1374 static protected $activeKey = 'default';
1375
1388 static protected $logs = array();
1389
1405 final public static function startLog($logging_key, $key = 'default') {
1406 if (empty(self::$logs[$key])) {
1407 self::$logs[$key] = new DatabaseLog($key);
1408
1409 // Every target already active for this connection key needs to have the
1410 // logging object associated with it.
1411 if (!empty(self::$connections[$key])) {
1412 foreach (self::$connections[$key] as $connection) {
1413 $connection->setLogger(self::$logs[$key]);
1414 }
1415 }
1416 }
1417
1418 self::$logs[$key]->start($logging_key);
1419 return self::$logs[$key];
1420 }
1421
1440 final public static function getLog($logging_key, $key = 'default') {
1441 if (empty(self::$logs[$key])) {
1442 return NULL;
1443 }
1444 $queries = self::$logs[$key]->get($logging_key);
1445 self::$logs[$key]->end($logging_key);
1446 return $queries;
1447 }
1448
1460 final public static function getConnection($target = 'default', $key = NULL) {
1461 if (!isset($key)) {
1462 // By default, we want the active connection, set in setActiveConnection.
1463 $key = self::$activeKey;
1464 }
1465 // If the requested target does not exist, or if it is ignored, we fall back
1466 // to the default target. The target is typically either "default" or
1467 // "slave", indicating to use a slave SQL server if one is available. If
1468 // it's not available, then the default/master server is the correct server
1469 // to use.
1470 if (!empty(self::$ignoreTargets[$key][$target]) || !isset(self::$databaseInfo[$key][$target])) {
1471 $target = 'default';
1472 }
1473
1474 if (!isset(self::$connections[$key][$target])) {
1475 // If necessary, a new connection is opened.
1476 self::$connections[$key][$target] = self::openConnection($key, $target);
1477 }
1478 return self::$connections[$key][$target];
1479 }
1480
1491 final public static function isActiveConnection() {
1492 return !empty(self::$activeKey) && !empty(self::$connections) && !empty(self::$connections[self::$activeKey]);
1493 }
1494
1501 final public static function setActiveConnection($key = 'default') {
1502 if (empty(self::$databaseInfo)) {
1503 self::parseConnectionInfo();
1504 }
1505
1506 if (!empty(self::$databaseInfo[$key])) {
1507 $old_key = self::$activeKey;
1508 self::$activeKey = $key;
1509 return $old_key;
1510 }
1511 }
1512
1516 final public static function parseConnectionInfo() {
1517 global $databases;
1518
1519 $database_info = is_array($databases) ? $databases : array();
1520 foreach ($database_info as $index => $info) {
1521 foreach ($database_info[$index] as $target => $value) {
1522 // If there is no "driver" property, then we assume it's an array of
1523 // possible connections for this target. Pick one at random. That allows
1524 // us to have, for example, multiple slave servers.
1525 if (empty($value['driver'])) {
1526 $database_info[$index][$target] = $database_info[$index][$target][mt_rand(0, count($database_info[$index][$target]) - 1)];
1527 }
1528
1529 // Parse the prefix information.
1530 if (!isset($database_info[$index][$target]['prefix'])) {
1531 // Default to an empty prefix.
1532 $database_info[$index][$target]['prefix'] = array(
1533 'default' => '',
1534 );
1535 }
1536 elseif (!is_array($database_info[$index][$target]['prefix'])) {
1537 // Transform the flat form into an array form.
1538 $database_info[$index][$target]['prefix'] = array(
1539 'default' => $database_info[$index][$target]['prefix'],
1540 );
1541 }
1542 }
1543 }
1544
1545 if (!is_array(self::$databaseInfo)) {
1546 self::$databaseInfo = $database_info;
1547 }
1548
1549 // Merge the new $database_info into the existing.
1550 // array_merge_recursive() cannot be used, as it would make multiple
1551 // database, user, and password keys in the same database array.
1552 else {
1553 foreach ($database_info as $database_key => $database_values) {
1554 foreach ($database_values as $target => $target_values) {
1555 self::$databaseInfo[$database_key][$target] = $target_values;
1556 }
1557 }
1558 }
1559 }
1560
1581 public static function addConnectionInfo($key, $target, $info) {
1582 if (empty(self::$databaseInfo[$key][$target])) {
1583 self::$databaseInfo[$key][$target] = $info;
1584 }
1585 }
1586
1593 final public static function getConnectionInfo($key = 'default') {
1594 if (empty(self::$databaseInfo)) {
1595 self::parseConnectionInfo();
1596 }
1597
1598 if (!empty(self::$databaseInfo[$key])) {
1599 return self::$databaseInfo[$key];
1600 }
1601 }
1602
1613 final public static function renameConnection($old_key, $new_key) {
1614 if (empty(self::$databaseInfo)) {
1615 self::parseConnectionInfo();
1616 }
1617
1618 if (!empty(self::$databaseInfo[$old_key]) && empty(self::$databaseInfo[$new_key])) {
1619 // Migrate the database connection information.
1620 self::$databaseInfo[$new_key] = self::$databaseInfo[$old_key];
1621 unset(self::$databaseInfo[$old_key]);
1622
1623 // Migrate over the DatabaseConnection object if it exists.
1624 if (isset(self::$connections[$old_key])) {
1625 self::$connections[$new_key] = self::$connections[$old_key];
1626 unset(self::$connections[$old_key]);
1627 }
1628
1629 return TRUE;
1630 }
1631 else {
1632 return FALSE;
1633 }
1634 }
1635
1644 final public static function removeConnection($key) {
1645 if (isset(self::$databaseInfo[$key])) {
1646 self::closeConnection(NULL, $key);
1647 unset(self::$databaseInfo[$key]);
1648 return TRUE;
1649 }
1650 else {
1651 return FALSE;
1652 }
1653 }
1654
1667 final protected static function openConnection($key, $target) {
1668 if (empty(self::$databaseInfo)) {
1669 self::parseConnectionInfo();
1670 }
1671
1672 // If the requested database does not exist then it is an unrecoverable
1673 // error.
1674 if (!isset(self::$databaseInfo[$key])) {
1675 throw new DatabaseConnectionNotDefinedException('The specified database connection is not defined: ' . $key);
1676 }
1677
1678 if (!$driver = self::$databaseInfo[$key][$target]['driver']) {
1679 throw new DatabaseDriverNotSpecifiedException('Driver not specified for this database connection: ' . $key);
1680 }
1681
1682 // We cannot rely on the registry yet, because the registry requires an
1683 // open database connection.
1684 $driver_class = 'DatabaseConnection_' . $driver;
1685 require_once DRUPAL_ROOT . '/includes/database/' . $driver . '/database.inc';
1686 $new_connection = new $driver_class(self::$databaseInfo[$key][$target]);
1687 $new_connection->setTarget($target);
1688 $new_connection->setKey($key);
1689
1690 // If we have any active logging objects for this connection key, we need
1691 // to associate them with the connection we just opened.
1692 if (!empty(self::$logs[$key])) {
1693 $new_connection->setLogger(self::$logs[$key]);
1694 }
1695
1696 return $new_connection;
1697 }
1698
1708 public static function closeConnection($target = NULL, $key = NULL) {
1709 // Gets the active connection by default.
1710 if (!isset($key)) {
1711 $key = self::$activeKey;
1712 }
1713 // To close a connection, it needs to be set to NULL and removed from the
1714 // static variable. In all cases, closeConnection() might be called for a
1715 // connection that was not opened yet, in which case the key is not defined
1716 // yet and we just ensure that the connection key is undefined.
1717 if (isset($target)) {
1718 if (isset(self::$connections[$key][$target])) {
1719 self::$connections[$key][$target]->destroy();
1720 self::$connections[$key][$target] = NULL;
1721 }
1722 unset(self::$connections[$key][$target]);
1723 }
1724 else {
1725 if (isset(self::$connections[$key])) {
1726 foreach (self::$connections[$key] as $target => $connection) {
1727 self::$connections[$key][$target]->destroy();
1728 self::$connections[$key][$target] = NULL;
1729 }
1730 }
1731 unset(self::$connections[$key]);
1732 }
1733 }
1734
1747 public static function ignoreTarget($key, $target) {
1748 self::$ignoreTargets[$key][$target] = TRUE;
1749 }
1750
1759 public static function loadDriverFile($driver, array $files = array()) {
1760 static $base_path;
1761
1762 if (empty($base_path)) {
1763 $base_path = dirname(realpath(__FILE__));
1764 }
1765
1766 $driver_base_path = "$base_path/$driver";
1767 foreach ($files as $file) {
1768 // Load the base file first so that classes extending base classes will
1769 // have the base class loaded.
1770 foreach (array("$base_path/$file", "$driver_base_path/$file") as $filename) {
1771 // The OS caches file_exists() and PHP caches require_once(), so
1772 // we'll let both of those take care of performance here.
1773 if (file_exists($filename)) {
1774 require_once $filename;
1775 }
1776 }
1777 }
1778 }
1779 }
1780
1784 class DatabaseTransactionNoActiveException extends Exception { }
1785
1789 class DatabaseTransactionNameNonUniqueException extends Exception { }
1790
1794 class DatabaseTransactionCommitFailedException extends Exception { }
1795
1802 class DatabaseTransactionExplicitCommitNotAllowedException extends Exception { }
1803
1807 class DatabaseTransactionOutOfOrderException extends Exception { }
1808
1815 class InvalidMergeQueryException extends Exception {}
1816
1823 class FieldsOverlapException extends Exception {}
1824
1828 class NoFieldsException extends Exception {}
1829
1833 class DatabaseConnectionNotDefinedException extends Exception {}
1834
1838 class DatabaseDriverNotSpecifiedException extends Exception {}
1839
1840
1860 class DatabaseTransaction {
1861
1867 protected $connection;
1868
1874 protected $rolledBack = FALSE;
1875
1882 protected $name;
1883
1884 public function __construct(DatabaseConnection $connection, $name = NULL) {
1885 $this->connection = $connection;
1886 // If there is no transaction depth, then no transaction has started. Name
1887 // the transaction 'drupal_transaction'.
1888 if (!$depth = $connection->transactionDepth()) {
1889 $this->name = 'drupal_transaction';
1890 }
1891 // Within transactions, savepoints are used. Each savepoint requires a
1892 // name. So if no name is present we need to create one.
1893 elseif (!$name) {
1894 $this->name = 'savepoint_' . $depth;
1895 }
1896 else {
1897 $this->name = $name;
1898 }
1899 $this->connection->pushTransaction($this->name);
1900 }
1901
1902 public function __destruct() {
1903 // If we rolled back then the transaction would have already been popped.
1904 if (!$this->rolledBack) {
1905 $this->connection->popTransaction($this->name);
1906 }
1907 }
1908
1912 public function name() {
1913 return $this->name;
1914 }
1915
1928 public function rollback() {
1929 $this->rolledBack = TRUE;
1930 $this->connection->rollback($this->name);
1931 }
1932 }
1933
1953 interface DatabaseStatementInterface extends Traversable {
1954
1967 public function execute($args = array(), $options = array());
1968
1975 public function getQueryString();
1976
1984 public function rowCount();
1985
2003 // public function setFetchMode($mode, $a1 = NULL, $a2 = array());
2004
2022 // public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL);
2023
2033 public function fetchField($index = 0);
2034
2041 // public function fetchObject();
2042
2053 public function fetchAssoc();
2054
2068 // function fetchAll($mode = NULL, $column_index = NULL, array $constructor_arguments);
2069
2081 public function fetchCol($index = 0);
2082
2101 public function fetchAllKeyed($key_index = 0, $value_index = 1);
2102
2120 public function fetchAllAssoc($key, $fetch = NULL);
2121 }
2122
2134 class DatabaseStatementBase extends PDOStatement implements DatabaseStatementInterface {
2135
2143 public $dbh;
2144
2145 protected function __construct($dbh) {
2146 $this->dbh = $dbh;
2147 $this->setFetchMode(PDO::FETCH_OBJ);
2148 }
2149
2150 public function execute($args = array(), $options = array()) {
2151 if (isset($options['fetch'])) {
2152 if (is_string($options['fetch'])) {
2153 // Default to an object. Note: db fields will be added to the object
2154 // before the constructor is run. If you need to assign fields after
2155 // the constructor is run, see http://drupal.org/node/315092.
2156 $this->setFetchMode(PDO::FETCH_CLASS, $options['fetch']);
2157 }
2158 else {
2159 $this->setFetchMode($options['fetch']);
2160 }
2161 }
2162
2163 $logger = $this->dbh->getLogger();
2164 if (!empty($logger)) {
2165 $query_start = microtime(TRUE);
2166 }
2167
2168 $return = parent::execute($args);
2169
2170 if (!empty($logger)) {
2171 $query_end = microtime(TRUE);
2172 $logger->log($this, $args, $query_end - $query_start);
2173 }
2174
2175 return $return;
2176 }
2177
2178 public function getQueryString() {
2179 return $this->queryString;
2180 }
2181
2182 public function fetchCol($index = 0) {
2183 return $this->fetchAll(PDO::FETCH_COLUMN, $index);
2184 }
2185
2186 public function fetchAllAssoc($key, $fetch = NULL) {
2187 $return = array();
2188 if (isset($fetch)) {
2189 if (is_string($fetch)) {
2190 $this->setFetchMode(PDO::FETCH_CLASS, $fetch);
2191 }
2192 else {
2193 $this->setFetchMode($fetch);
2194 }
2195 }
2196
2197 foreach ($this as $record) {
2198 $record_key = is_object($record) ? $record->$key : $record[$key];
2199 $return[$record_key] = $record;
2200 }
2201
2202 return $return;
2203 }
2204
2205 public function fetchAllKeyed($key_index = 0, $value_index = 1) {
2206 $return = array();
2207 $this->setFetchMode(PDO::FETCH_NUM);
2208 foreach ($this as $record) {
2209 $return[$record[$key_index]] = $record[$value_index];
2210 }
2211 return $return;
2212 }
2213
2214 public function fetchField($index = 0) {
2215 // Call PDOStatement::fetchColumn to fetch the field.
2216 return $this->fetchColumn($index);
2217 }
2218
2219 public function fetchAssoc() {
2220 // Call PDOStatement::fetch to fetch the row.
2221 return $this->fetch(PDO::FETCH_ASSOC);
2222 }
2223 }
2224
2236 class DatabaseStatementEmpty implements Iterator, DatabaseStatementInterface {
2237
2238 public function execute($args = array(), $options = array()) {
2239 return FALSE;
2240 }
2241
2242 public function getQueryString() {
2243 return '';
2244 }
2245
2246 public function rowCount() {
2247 return 0;
2248 }
2249
2250 public function setFetchMode($mode, $a1 = NULL, $a2 = array()) {
2251 return;
2252 }
2253
2254 public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL) {
2255 return NULL;
2256 }
2257
2258 public function fetchField($index = 0) {
2259 return NULL;
2260 }
2261
2262 public function fetchObject() {
2263 return NULL;
2264 }
2265
2266 public function fetchAssoc() {
2267 return NULL;
2268 }
2269
2270 function fetchAll($mode = NULL, $column_index = NULL, array $constructor_arguments = array()) {
2271 return array();
2272 }
2273
2274 public function fetchCol($index = 0) {
2275 return array();
2276 }
2277
2278 public function fetchAllKeyed($key_index = 0, $value_index = 1) {
2279 return array();
2280 }
2281
2282 public function fetchAllAssoc($key, $fetch = NULL) {
2283 return array();
2284 }
2285
2286 /* Implementations of Iterator. */
2287
2288 public function current() {
2289 return NULL;
2290 }
2291
2292 public function key() {
2293 return NULL;
2294 }
2295
2296 public function rewind() {
2297 // Nothing to do: our DatabaseStatement can't be rewound.
2298 }
2299
2300 public function next() {
2301 // Do nothing, since this is an always-empty implementation.
2302 }
2303
2304 public function valid() {
2305 return FALSE;
2306 }
2307 }
2308
2342 function db_query($query, array $args = array(), array $options = array()) {
2343 if (empty($options['target'])) {
2344 $options['target'] = 'default';
2345 }
2346
2347 return Database::getConnection($options['target'])->query($query, $args, $options);
2348 }
2349
2374 function db_query_range($query, $from, $count, array $args = array(), array $options = array()) {
2375 if (empty($options['target'])) {
2376 $options['target'] = 'default';
2377 }
2378
2379 return Database::getConnection($options['target'])->queryRange($query, $from, $count, $args, $options);
2380 }
2381
2404 function db_query_temporary($query, array $args = array(), array $options = array()) {
2405 if (empty($options['target'])) {
2406 $options['target'] = 'default';
2407 }
2408
2409 return Database::getConnection($options['target'])->queryTemporary($query, $args, $options);
2410 }
2411
2423 function db_insert($table, array $options = array()) {
2424 if (empty($options['target']) || $options['target'] == 'slave') {
2425 $options['target'] = 'default';
2426 }
2427 return Database::getConnection($options['target'])->insert($table, $options);
2428 }
2429
2441 function db_merge($table, array $options = array()) {
2442 if (empty($options['target']) || $options['target'] == 'slave') {
2443 $options['target'] = 'default';
2444 }
2445 return Database::getConnection($options['target'])->merge($table, $options);
2446 }
2447
2459 function db_update($table, array $options = array()) {
2460 if (empty($options['target']) || $options['target'] == 'slave') {
2461 $options['target'] = 'default';
2462 }
2463 return Database::getConnection($options['target'])->update($table, $options);
2464 }
2465
2477 function db_delete($table, array $options = array()) {
2478 if (empty($options['target']) || $options['target'] == 'slave') {
2479 $options['target'] = 'default';
2480 }
2481 return Database::getConnection($options['target'])->delete($table, $options);
2482 }
2483
2495 function db_truncate($table, array $options = array()) {
2496 if (empty($options['target']) || $options['target'] == 'slave') {
2497 $options['target'] = 'default';
2498 }
2499 return Database::getConnection($options['target'])->truncate($table, $options);
2500 }
2501
2516 function db_select($table, $alias = NULL, array $options = array()) {
2517 if (empty($options['target'])) {
2518 $options['target'] = 'default';
2519 }
2520 return Database::getConnection($options['target'])->select($table, $alias, $options);
2521 }
2522
2535 function db_transaction($name = NULL, array $options = array()) {
2536 if (empty($options['target'])) {
2537 $options['target'] = 'default';
2538 }
2539 return Database::getConnection($options['target'])->startTransaction($name);
2540 }
2541
2551 function db_set_active($key = 'default') {
2552 return Database::setActiveConnection($key);
2553 }
2554
2566 function db_escape_table($table) {
2567 return Database::getConnection()->escapeTable($table);
2568 }
2569
2581 function db_escape_field($field) {
2582 return Database::getConnection()->escapeField($field);
2583 }
2584
2610 function db_like($string) {
2611 return Database::getConnection()->escapeLike($string);
2612 }
2613
2620 function db_driver() {
2621 return Database::getConnection()->driver();
2622 }
2623
2631 function db_close(array $options = array()) {
2632 if (empty($options['target'])) {
2633 $options['target'] = NULL;
2634 }
2635 Database::closeConnection($options['target']);
2636 }
2637
2653 function db_next_id($existing_id = 0) {
2654 return Database::getConnection()->nextId($existing_id);
2655 }
2656
2662 function db_or() {
2663 return new DatabaseCondition('OR');
2664 }
2665
2671 function db_and() {
2672 return new DatabaseCondition('AND');
2673 }
2674
2680 function db_xor() {
2681 return new DatabaseCondition('XOR');
2682 }
2683
2694 function db_condition($conjunction) {
2695 return new DatabaseCondition($conjunction);
2696 }
2697
2716 function db_create_table($name, $table) {
2717 return Database::getConnection()->schema()->createTable($name, $table);
2718 }
2719
2732 function db_field_names($fields) {
2733 return Database::getConnection()->schema()->fieldNames($fields);
2734 }
2735
2747 function db_index_exists($table, $name) {
2748 return Database::getConnection()->schema()->indexExists($table, $name);
2749 }
2750
2760 function db_table_exists($table) {
2761 return Database::getConnection()->schema()->tableExists($table);
2762 }
2763
2775 function db_field_exists($table, $field) {
2776 return Database::getConnection()->schema()->fieldExists($table, $field);
2777 }
2778
2789 function db_find_tables($table_expression) {
2790 return Database::getConnection()->schema()->findTables($table_expression);
2791 }
2792
2793 function _db_create_keys_sql($spec) {
2794 return Database::getConnection()->schema()->createKeysSql($spec);
2795 }
2796
2805 function db_rename_table($table, $new_name) {
2806 return Database::getConnection()->schema()->renameTable($table, $new_name);
2807 }
2808
2815 function db_drop_table($table) {
2816 return Database::getConnection()->schema()->dropTable($table);
2817 }
2818
2840 function db_add_field($table, $field, $spec, $keys_new = array()) {
2841 return Database::getConnection()->schema()->addField($table, $field, $spec, $keys_new);
2842 }
2843
2852 function db_drop_field($table, $field) {
2853 return Database::getConnection()->schema()->dropField($table, $field);
2854 }
2855
2866 function db_field_set_default($table, $field, $default) {
2867 return Database::getConnection()->schema()->fieldSetDefault($table, $field, $default);
2868 }
2869
2878 function db_field_set_no_default($table, $field) {
2879 return Database::getConnection()->schema()->fieldSetNoDefault($table, $field);
2880 }
2881
2890 function db_add_primary_key($table, $fields) {
2891 return Database::getConnection()->schema()->addPrimaryKey($table, $fields);
2892 }
2893
2900 function db_drop_primary_key($table) {
2901 return Database::getConnection()->schema()->dropPrimaryKey($table);
2902 }
2903
2914 function db_add_unique_key($table, $name, $fields) {
2915 return Database::getConnection()->schema()->addUniqueKey($table, $name, $fields);
2916 }
2917
2926 function db_drop_unique_key($table, $name) {
2927 return Database::getConnection()->schema()->dropUniqueKey($table, $name);
2928 }
2929
2940 function db_add_index($table, $name, $fields) {
2941 return Database::getConnection()->schema()->addIndex($table, $name, $fields);
2942 }
2943
2952 function db_drop_index($table, $name) {
2953 return Database::getConnection()->schema()->dropIndex($table, $name);
2954 }
2955
3016 function db_change_field($table, $field, $field_new, $spec, $keys_new = array()) {
3017 return Database::getConnection()->schema()->changeField($table, $field, $field_new, $spec, $keys_new);
3018 }
3019
3027 function db_ignore_slave() {
3028 $connection_info = Database::getConnectionInfo();
3029 // Only set ignore_slave_server if there are slave servers being used, which
3030 // is assumed if there are more than one.
3031 if (count($connection_info) > 1) {
3032 // Five minutes is long enough to allow the slave to break and resume
3033 // interrupted replication without causing problems on the Drupal site from
3034 // the old data.
3035 $duration = variable_get('maximum_replication_lag', 300);
3036 // Set session variable with amount of time to delay before using slave.
3037 $_SESSION['ignore_slave_server'] = REQUEST_TIME + $duration;
3038 }
3039 }
DatabaseStatementEmpty\valid
valid()
Definition: database.inc:2304
DatabaseConnection\$target
$target
Definition: database.inc:193
DatabaseTransactionOutOfOrderException
Definition: database.inc:1807
DatabaseConnection\nextId
nextId($existing_id=0)
DatabaseStatementInterface\getQueryString
getQueryString()
db_field_names
db_field_names($fields)
Definition: database.inc:2732
DatabaseConnection\$prefixes
$prefixes
Definition: database.inc:280
DatabaseConnection\expandArguments
expandArguments(&$query, &$args)
Definition: database.inc:729
db_next_id
db_next_id($existing_id=0)
Definition: database.inc:2653
DatabaseConnection\$temporaryNameIndex
$temporaryNameIndex
Definition: database.inc:259
Database\ignoreTarget
static ignoreTarget($key, $target)
Definition: database.inc:1747
DatabaseConnection\update
update($table, array $options=array())
Definition: database.inc:857
DatabaseConnection\supportsTransactionalDDL
supportsTransactionalDDL()
Definition: database.inc:1251
DatabaseConnection\escapeAlias
escapeAlias($field)
Definition: database.inc:951
db_add_index
db_add_index($table, $name, $fields)
Definition: database.inc:2940
$databases
$databases
Definition: default.settings.php:213
DatabaseConnection\insert
insert($table, array $options=array())
Definition: database.inc:824
DatabaseStatementInterface\rowCount
rowCount()
DatabaseConnection\query
query($query, array $args=array(), $options=array())
Definition: database.inc:664
Database\getConnection
static getConnection($target= 'default', $key=NULL)
Definition: database.inc:1460
DatabaseConnection\select
select($table, $alias=NULL, array $options=array())
Definition: database.inc:808
db_field_set_default
db_field_set_default($table, $field, $default)
Definition: database.inc:2866
DatabaseConnection\transactionDepth
transactionDepth()
Definition: database.inc:997
DatabaseConnection\makeComment
makeComment($comments)
Definition: database.inc:583
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
DatabaseConnection\popTransaction
popTransaction($name)
Definition: database.inc:1114
DatabaseStatementEmpty\fetch
fetch($mode=NULL, $cursor_orientation=NULL, $cursor_offset=NULL)
Definition: database.inc:2254
Database\getConnectionInfo
static getConnectionInfo($key= 'default')
Definition: database.inc:1593
DatabaseConnection\prefixTables
prefixTables($sql)
Definition: database.inc:444
FieldsOverlapException
Definition: database.inc:1823
db_find_tables
db_find_tables($table_expression)
Definition: database.inc:2789
Database\startLog
static startLog($logging_key, $key= 'default')
Definition: database.inc:1405
DatabaseStatementInterface\fetchCol
fetchCol($index=0)
DatabaseConnection\getLogger
getLogger()
Definition: database.inc:550
db_drop_primary_key
db_drop_primary_key($table)
Definition: database.inc:2900
DatabaseConnection\setKey
setKey($key)
Definition: database.inc:517
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
db_drop_index
db_drop_index($table, $name)
Definition: database.inc:2952
$name
print $name
Definition: profile-listing.tpl.php:43
DatabaseConnection\$transactionalDDLSupport
$transactionalDDLSupport
Definition: database.inc:252
Exception
DatabaseStatementBase\$dbh
$dbh
Definition: database.inc:2143
db_field_exists
db_field_exists($table, $field)
Definition: database.inc:2775
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
DatabaseConnection\$transactionLayers
$transactionLayers
Definition: database.inc:222
DatabaseStatementInterface\fetchField
fetchField($index=0)
DatabaseConnection\databaseType
databaseType()
Database\openConnection
static openConnection($key, $target)
Definition: database.inc:1667
DatabaseConnectionNotDefinedException
Definition: database.inc:1833
Database\loadDriverFile
static loadDriverFile($driver, array $files=array())
Definition: database.inc:1759
DatabaseConnection\makeSequenceName
makeSequenceName($table, $field)
Definition: database.inc:568
Database\$connections
static $connections
Definition: database.inc:1353
Database\parseConnectionInfo
static parseConnectionInfo()
Definition: database.inc:1516
db_add_field
db_add_field($table, $field, $spec, $keys_new=array())
Definition: database.inc:2840
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
DatabaseTransaction\rollback
rollback()
Definition: database.inc:1928
DatabaseStatementBase
Definition: database.inc:2134
Database\getLog
static getLog($logging_key, $key= 'default')
Definition: database.inc:1440
DatabaseTransaction\$name
$name
Definition: database.inc:1882
db_field_set_no_default
db_field_set_no_default($table, $field)
Definition: database.inc:2878
db_add_unique_key
db_add_unique_key($table, $name, $fields)
Definition: database.inc:2914
Database
Definition: database.inc:1322
DatabaseConnection\getDriverClass
getDriverClass($class, array $files=array(), $use_autoload=FALSE)
Definition: database.inc:777
db_or
db_or()
Definition: database.inc:2662
DatabaseConnection\setTarget
setTarget($target=NULL)
Definition: database.inc:495
Database\addConnectionInfo
static addConnectionInfo($key, $target, $info)
Definition: database.inc:1581
DatabaseStatementEmpty
Definition: database.inc:2236
DatabaseTransactionNoActiveException
Definition: database.inc:1784
db_escape_field
db_escape_field($field)
Definition: database.inc:2581
DatabaseConnection\getKey
getKey()
Definition: database.inc:529
DatabaseConnection\defaultOptions
defaultOptions()
Definition: database.inc:373
Database\RETURN_STATEMENT
const RETURN_STATEMENT
Definition: database.inc:1335
DatabaseCondition
Definition: query.inc:1652
db_drop_field
db_drop_field($table, $field)
Definition: database.inc:2852
DatabaseConnection\$driverClasses
$driverClasses
Definition: database.inc:229
DatabaseConnection\destroy
destroy()
Definition: database.inc:320
DatabaseConnection\getConnectionOptions
getConnectionOptions()
Definition: database.inc:394
Database\RETURN_INSERT_ID
const RETURN_INSERT_ID
Definition: database.inc:1345
InvalidMergeQueryException
Definition: database.inc:1815
DatabaseConnection\prepareQuery
prepareQuery($query)
Definition: database.inc:476
$info
$info
Definition: color.inc:6
DatabaseConnection\setPrefix
setPrefix($prefix)
Definition: database.inc:405
DatabaseConnection\$schema
$schema
Definition: database.inc:273
Database\renameConnection
static renameConnection($old_key, $new_key)
Definition: database.inc:1613
db_xor
db_xor()
Definition: database.inc:2680
Database\RETURN_AFFECTED
const RETURN_AFFECTED
Definition: database.inc:1340
DatabaseConnection\filterComment
filterComment($comment= '')
Definition: database.inc:625
DatabaseStatementEmpty\fetchObject
fetchObject()
Definition: database.inc:2262
$value
print $value
Definition: user-profile-item.tpl.php:26
DatabaseConnection\$prefixReplace
$prefixReplace
Definition: database.inc:294
DatabaseTransaction
Definition: database.inc:1860
db_ignore_slave
db_ignore_slave()
Definition: database.inc:3027
db_set_active
db_set_active($key= 'default')
Definition: database.inc:2551
DatabaseStatementInterface\fetchAllKeyed
fetchAllKeyed($key_index=0, $value_index=1)
db_drop_unique_key
db_drop_unique_key($table, $name)
Definition: database.inc:2926
DatabaseStatementInterface
Definition: database.inc:1953
DatabaseStatementEmpty\next
next()
Definition: database.inc:2300
db_add_primary_key
db_add_primary_key($table, $fields)
Definition: database.inc:2890
$depth
print $depth
Definition: book-node-export-html.tpl.php:21
DatabaseConnection\escapeTable
escapeTable($table)
Definition: database.inc:922
Database\setActiveConnection
static setActiveConnection($key= 'default')
Definition: database.inc:1501
db_like
db_like($string)
Definition: database.inc:2610
Database\$databaseInfo
static $databaseInfo
Definition: database.inc:1360
DatabaseStatementEmpty\fetchAll
fetchAll($mode=NULL, $column_index=NULL, array $constructor_arguments=array())
Definition: database.inc:2270
db_close
db_close(array $options=array())
Definition: database.inc:2631
DatabaseConnection\commit
commit()
Definition: database.inc:1291
DatabaseStatementEmpty\current
current()
Definition: database.inc:2288
DatabaseStatementEmpty\key
key()
Definition: database.inc:2292
DatabaseConnection\getTarget
getTarget()
Definition: database.inc:507
DatabaseTransaction\__construct
__construct(DatabaseConnection $connection, $name=NULL)
Definition: database.inc:1884
Database\$ignoreTargets
static $ignoreTargets
Definition: database.inc:1367
DatabaseConnection\merge
merge($table, array $options=array())
Definition: database.inc:840
DatabaseConnection
Definition: database.inc:184
DatabaseConnection\queryTemporary
queryTemporary($query, array $args=array(), array $options=array())
db_index_exists
db_index_exists($table, $name)
Definition: database.inc:2747
db_driver
db_driver()
Definition: database.inc:2620
DatabaseConnection\$logger
$logger
Definition: database.inc:211
Database\$logs
static $logs
Definition: database.inc:1388
DatabaseConnection\inTransaction
inTransaction()
Definition: database.inc:990
DatabaseConnection\driver
driver()
DatabaseStatementEmpty\setFetchMode
setFetchMode($mode, $a1=NULL, $a2=array())
Definition: database.inc:2250
db_condition
db_condition($conjunction)
Definition: database.inc:2694
db_transaction
db_transaction($name=NULL, array $options=array())
Definition: database.inc:2535
Database\isActiveConnection
static isActiveConnection()
Definition: database.inc:1491
DatabaseStatementInterface\fetchAllAssoc
fetchAllAssoc($key, $fetch=NULL)
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
DatabaseConnection\$connectionOptions
$connectionOptions
Definition: database.inc:266
DatabaseConnection\schema
schema()
Definition: database.inc:902
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
DatabaseConnection\setLogger
setLogger(DatabaseLog $logger)
Definition: database.inc:539
Database\removeConnection
static removeConnection($key)
Definition: database.inc:1644
DatabaseConnection\escapeField
escapeField($field)
Definition: database.inc:936
DatabaseStatementEmpty\rewind
rewind()
Definition: database.inc:2296
DatabaseTransactionCommitFailedException
Definition: database.inc:1794
DatabaseConnection\queryRange
queryRange($query, $from, $count, array $args=array(), array $options=array())
db_escape_table
db_escape_table($table)
Definition: database.inc:2566
DatabaseConnection\tablePrefix
tablePrefix($table= 'default')
Definition: database.inc:454
DatabaseLog
Definition: log.inc:19
DatabaseDriverNotSpecifiedException
Definition: database.inc:1838
DatabaseConnection\version
version()
Definition: database.inc:1228
DatabaseStatementBase\__construct
__construct($dbh)
Definition: database.inc:2145
DatabaseConnection\startTransaction
startTransaction($name= '')
Definition: database.inc:1012
DatabaseConnection\$statementClass
$statementClass
Definition: database.inc:236
DatabaseConnection\generateTemporaryTableName
generateTemporaryTableName()
Definition: database.inc:1186
DatabaseConnection\truncate
truncate($table, array $options=array())
Definition: database.inc:889
DatabaseConnection\escapeLike
escapeLike($string)
Definition: database.inc:980
DatabaseTransactionNameNonUniqueException
Definition: database.inc:1789
DatabaseTransaction\name
name()
Definition: database.inc:1912
DatabaseConnection\pushTransaction
pushTransaction($name)
Definition: database.inc:1081
Database\$activeKey
static $activeKey
Definition: database.inc:1374
DatabaseConnection\$transactionSupport
$transactionSupport
Definition: database.inc:243
DatabaseConnection\supportsTransactions
supportsTransactions()
Definition: database.inc:1238
db_query_temporary
db_query_temporary($query, array $args=array(), array $options=array())
Definition: database.inc:2404
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
DatabaseConnection\__construct
__construct($dsn, $username, $password, $driver_options=array())
Definition: database.inc:296
DatabaseStatementInterface\fetchAssoc
fetchAssoc()
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
_db_create_keys_sql
_db_create_keys_sql($spec)
Definition: database.inc:2793
Database\RETURN_NULL
const RETURN_NULL
Definition: database.inc:1330
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
DatabaseStatementInterface\execute
execute($args=array(), $options=array())
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
DatabaseConnection\$key
$key
Definition: database.inc:204
DatabaseTransaction\$connection
$connection
Definition: database.inc:1867
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
Database\closeConnection
static closeConnection($target=NULL, $key=NULL)
Definition: database.inc:1708
DatabaseTransaction\$rolledBack
$rolledBack
Definition: database.inc:1874
NoFieldsException
Definition: database.inc:1828
db_truncate
db_truncate($table, array $options=array())
Definition: database.inc:2495
DatabaseTransactionExplicitCommitNotAllowedException
Definition: database.inc:1802
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
DatabaseConnection\popCommittableTransactions
popCommittableTransactions()
Definition: database.inc:1134
DatabaseConnection\mapConditionOperator
mapConditionOperator($operator)
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
DatabaseConnection\$prefixSearch
$prefixSearch
Definition: database.inc:287
db_table_exists
db_table_exists($table)
Definition: database.inc:2760
db_rename_table
db_rename_table($table, $new_name)
Definition: database.inc:2805
DatabaseTransaction\__destruct
__destruct()
Definition: database.inc:1902
db_and
db_and()
Definition: database.inc:2671
DatabaseConnection\rollback
rollback($savepoint_name= 'drupal_transaction')
Definition: database.inc:1030
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll-results--block.tpl.php Source File

  • modules
  • poll
poll-results--block.tpl.php
Go to the documentation of this file.
1 <?php
19 ?>
20
21 <div class="poll">
22 <div class="title"><?php print $title ?></div>
23 <?php print $results ?>
24 <div class="total">
25 <?php print t('Total votes: @votes', array('@votes' => $votes)); ?>
26 </div>
27 </div>
28 <div class="links"><?php print $links; ?></div>
$results
print $results
Definition: poll-results.tpl.php:23
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
$links
print $links
Definition: poll-results--block.tpl.php:28
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/syslog/syslog.module Source File

  • modules
  • syslog
syslog.module
Go to the documentation of this file.
1 <?php
2
8 if (defined('LOG_LOCAL0')) {
18 define('DEFAULT_SYSLOG_FACILITY', LOG_LOCAL0);
19 }
20 else {
21 define('DEFAULT_SYSLOG_FACILITY', LOG_USER);
22 }
23
27 function syslog_help($path, $arg) {
28 switch ($path) {
29 case 'admin/help#syslog':
30 $output = '';
31 $output .= '<h3>' . t('About') . '</h3>';
32 $output .= '<p>' . t("The Syslog module logs events by sending messages to the logging facility of your web server's operating system. Syslog is an operating system administrative logging tool that provides valuable information for use in system management and security auditing. Most suited to medium and large sites, Syslog provides filtering tools that allow messages to be routed by type and severity. For more information, see the online handbook entry for <a href='@syslog'>Syslog module</a> and PHP's <a href='@php_openlog'>openlog</a> and <a href='@php_syslog'>syslog</a> functions.", array('@syslog' => 'http://drupal.org/documentation/modules/syslog', '@php_openlog' => 'http://www.php.net/manual/function.openlog.php', '@php_syslog' => 'http://www.php.net/manual/function.syslog.php')) . '</p>';
33 $output .= '<h3>' . t('Uses') . '</h3>';
34 $output .= '<dl>';
35 $output .= '<dt>' . t('Logging for UNIX, Linux, and Mac OS X') . '</dt>';
36 $output .= '<dd>' . t('On UNIX, Linux, and Mac OS X, the file <em>/etc/syslog.conf</em> defines the routing configuration. Messages can be flagged with the codes <code>LOG_LOCAL0</code> through <code>LOG_LOCAL7</code>. For information on Syslog facilities, severity levels, and how to set up <em>syslog.conf</em>, see the <em>syslog.conf</em> manual page on your command line.') . '</dd>';
37 $output .= '<dt>' . t('Logging for Microsoft Windows') . '</dt>';
38 $output .= '<dd>' . t('On Microsoft Windows, messages are always sent to the Event Log using the code <code>LOG_USER</code>.') . '</dd>';
39 $output .= '</dl>';
40 return $output;
41 }
42 }
43
47 function syslog_form_system_logging_settings_alter(&$form, &$form_state) {
48 $help = module_exists('help') ? ' ' . l(t('More information'), 'admin/help/syslog') . '.' : NULL;
49 $form['syslog_identity'] = array(
50 '#type' => 'textfield',
51 '#title' => t('Syslog identity'),
52 '#default_value' => variable_get('syslog_identity', 'drupal'),
53 '#description' => t('A string that will be prepended to every message logged to Syslog. If you have multiple sites logging to the same Syslog log file, a unique identity per site makes it easy to tell the log entries apart.') . $help,
54 );
55 if (defined('LOG_LOCAL0')) {
56 $form['syslog_facility'] = array(
57 '#type' => 'select',
58 '#title' => t('Syslog facility'),
59 '#default_value' => variable_get('syslog_facility', LOG_LOCAL0),
60 '#options' => syslog_facility_list(),
61 '#description' => t('Depending on the system configuration, Syslog and other logging tools use this code to identify or filter messages from within the entire system log.') . $help,
62 );
63 }
64 $form['syslog_format'] = array(
65 '#type' => 'textarea',
66 '#title' => t('Syslog format'),
67 '#default_value' => variable_get('syslog_format', '!base_url|!timestamp|!type|!ip|!request_uri|!referer|!uid|!link|!message'),
68 '#description' => t('Specify the format of the syslog entry. Available variables are: <dl><dt><code>!base_url</code></dt><dd>Base URL of the site.</dd><dt><code>!timestamp</code></dt><dd>Unix timestamp of the log entry.</dd><dt><code>!type</code></dt><dd>The category to which this message belongs.</dd><dt><code>!ip</code></dt><dd>IP address of the user triggering the message.</dd><dt><code>!request_uri</code></dt><dd>The requested URI.</dd><dt><code>!referer</code></dt><dd>HTTP Referer if available.</dd><dt><code>!uid</code></dt><dd>User ID.</dd><dt><code>!link</code></dt><dd>A link to associate with the message.</dd><dt><code>!message</code></dt><dd>The message to store in the log.</dd></dl>'),
69 );
70 $form['actions']['#weight'] = 1;
71 }
72
79 function syslog_facility_list() {
80 return array(
81 LOG_LOCAL0 => 'LOG_LOCAL0',
82 LOG_LOCAL1 => 'LOG_LOCAL1',
83 LOG_LOCAL2 => 'LOG_LOCAL2',
84 LOG_LOCAL3 => 'LOG_LOCAL3',
85 LOG_LOCAL4 => 'LOG_LOCAL4',
86 LOG_LOCAL5 => 'LOG_LOCAL5',
87 LOG_LOCAL6 => 'LOG_LOCAL6',
88 LOG_LOCAL7 => 'LOG_LOCAL7',
89 );
90 }
91
95 function syslog_watchdog(array $log_entry) {
96 global $base_url;
97
98 $log_init = &drupal_static(__FUNCTION__, FALSE);
99
100 if (!$log_init) {
101 $log_init = TRUE;
102 $default_facility = defined('LOG_LOCAL0') ? LOG_LOCAL0 : LOG_USER;
103 openlog(variable_get('syslog_identity', 'drupal'), LOG_NDELAY, variable_get('syslog_facility', $default_facility));
104 }
105
106 $message = strtr(variable_get('syslog_format', '!base_url|!timestamp|!type|!ip|!request_uri|!referer|!uid|!link|!message'), array(
107 '!base_url' => $base_url,
108 '!timestamp' => $log_entry['timestamp'],
109 '!type' => $log_entry['type'],
110 '!ip' => $log_entry['ip'],
111 '!request_uri' => $log_entry['request_uri'],
112 '!referer' => $log_entry['referer'],
113 '!uid' => $log_entry['uid'],
114 '!link' => strip_tags($log_entry['link']),
115 '!message' => strip_tags(!isset($log_entry['variables']) ? $log_entry['message'] : strtr($log_entry['message'], $log_entry['variables'])),
116 ));
117
118 syslog($log_entry['severity'], $message);
119 }
l
l($text, $path, array $options=array())
Definition: common.inc:2432
syslog_help
syslog_help($path, $arg)
Definition: syslog.module:27
module_exists
module_exists($module)
Definition: module.inc:274
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
syslog_facility_list
syslog_facility_list()
Definition: syslog.module:79
$output
$output
Definition: authorize.php:93
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
$help
print $help
Definition: maintenance-page.tpl.php:69
syslog_watchdog
syslog_watchdog(array $log_entry)
Definition: syslog.module:95
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
syslog_form_system_logging_settings_alter
syslog_form_system_logging_settings_alter(&$form, &$form_state)
Definition: syslog.module:47
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/theme-settings.php Source File

  • themes
  • garland
theme-settings.php
Go to the documentation of this file.
1 <?php
2
16 function garland_form_system_theme_settings_alter(&$form, &$form_state) {
17
18 $form['garland_width'] = array(
19 '#type' => 'radios',
20 '#title' => t('Content width'),
21 '#options' => array(
22 'fluid' => t('Fluid width'),
23 'fixed' => t('Fixed width'),
24 ),
25 '#default_value' => theme_get_setting('garland_width'),
26 '#description' => t('Specify whether the content will wrap to a fixed width or will fluidly expand to the width of the browser window.'),
27 // Place this above the color scheme options.
28 '#weight' => -2,
29 );
30 }
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
garland_form_system_theme_settings_alter
garland_form_system_theme_settings_alter(&$form, &$form_state)
Definition: theme-settings.php:16
theme_get_setting
theme_get_setting($setting_name, $theme=NULL)
Definition: theme.inc:1401
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/node.admin.inc Source File

  • modules
  • node
node.admin.inc
Go to the documentation of this file.
1 <?php
2
15 function node_configure_rebuild_confirm() {
16 return confirm_form(array(), t('Are you sure you want to rebuild the permissions on site content?'),
17 'admin/reports/status', t('This action rebuilds all permissions on site content, and may be a lengthy process. This action cannot be undone.'), t('Rebuild permissions'), t('Cancel'));
18 }
19
25 function node_configure_rebuild_confirm_submit($form, &$form_state) {
26 node_access_rebuild(TRUE);
27 $form_state['redirect'] = 'admin/reports/status';
28 }
29
33 function node_node_operations() {
34 $operations = array(
35 'publish' => array(
36 'label' => t('Publish selected content'),
37 'callback' => 'node_mass_update',
38 'callback arguments' => array('updates' => array('status' => NODE_PUBLISHED)),
39 ),
40 'unpublish' => array(
41 'label' => t('Unpublish selected content'),
42 'callback' => 'node_mass_update',
43 'callback arguments' => array('updates' => array('status' => NODE_NOT_PUBLISHED)),
44 ),
45 'promote' => array(
46 'label' => t('Promote selected content to front page'),
47 'callback' => 'node_mass_update',
48 'callback arguments' => array('updates' => array('status' => NODE_PUBLISHED, 'promote' => NODE_PROMOTED)),
49 ),
50 'demote' => array(
51 'label' => t('Demote selected content from front page'),
52 'callback' => 'node_mass_update',
53 'callback arguments' => array('updates' => array('promote' => NODE_NOT_PROMOTED)),
54 ),
55 'sticky' => array(
56 'label' => t('Make selected content sticky'),
57 'callback' => 'node_mass_update',
58 'callback arguments' => array('updates' => array('status' => NODE_PUBLISHED, 'sticky' => NODE_STICKY)),
59 ),
60 'unsticky' => array(
61 'label' => t('Make selected content not sticky'),
62 'callback' => 'node_mass_update',
63 'callback arguments' => array('updates' => array('sticky' => NODE_NOT_STICKY)),
64 ),
65 'delete' => array(
66 'label' => t('Delete selected content'),
67 'callback' => NULL,
68 ),
69 );
70 return $operations;
71 }
72
79 function node_filters() {
80 // Regular filters
81 $filters['status'] = array(
82 'title' => t('status'),
83 'options' => array(
84 '[any]' => t('any'),
85 'status-1' => t('published'),
86 'status-0' => t('not published'),
87 'promote-1' => t('promoted'),
88 'promote-0' => t('not promoted'),
89 'sticky-1' => t('sticky'),
90 'sticky-0' => t('not sticky'),
91 ),
92 );
93 // Include translation states if we have this module enabled
94 if (module_exists('translation')) {
95 $filters['status']['options'] += array(
96 'translate-0' => t('Up to date translation'),
97 'translate-1' => t('Outdated translation'),
98 );
99 }
100
101 $filters['type'] = array(
102 'title' => t('type'),
103 'options' => array(
104 '[any]' => t('any'),
105 ) + node_type_get_names(),
106 );
107
108 // Language filter if there is a list of languages
109 if ($languages = module_invoke('locale', 'language_list')) {
110 $languages = array(LANGUAGE_NONE => t('Language neutral')) + $languages;
111 $filters['language'] = array(
112 'title' => t('language'),
113 'options' => array(
114 '[any]' => t('any'),
115 ) + $languages,
116 );
117 }
118 return $filters;
119 }
120
127 function node_build_filter_query(SelectQueryInterface $query) {
128 // Build query
129 $filter_data = isset($_SESSION['node_overview_filter']) ? $_SESSION['node_overview_filter'] : array();
130 foreach ($filter_data as $index => $filter) {
131 list($key, $value) = $filter;
132 switch ($key) {
133 case 'status':
134 // Note: no exploitable hole as $key/$value have already been checked when submitted
135 list($key, $value) = explode('-', $value, 2);
136 case 'type':
137 case 'language':
138 $query->condition('n.' . $key, $value);
139 break;
140 }
141 }
142 }
143
156 function node_filter_form() {
157 $session = isset($_SESSION['node_overview_filter']) ? $_SESSION['node_overview_filter'] : array();
158 $filters = node_filters();
159
160 $i = 0;
161 $form['filters'] = array(
162 '#type' => 'fieldset',
163 '#title' => t('Show only items where'),
164 '#theme' => 'exposed_filters__node',
165 );
166 foreach ($session as $filter) {
167 list($type, $value) = $filter;
168 if ($type == 'term') {
169 // Load term name from DB rather than search and parse options array.
170 $value = module_invoke('taxonomy', 'term_load', $value);
171 $value = $value->name;
172 }
173 elseif ($type == 'language') {
174 $value = $value == LANGUAGE_NONE ? t('Language neutral') : module_invoke('locale', 'language_name', $value);
175 }
176 else {
177 $value = $filters[$type]['options'][$value];
178 }
179 $t_args = array('%property' => $filters[$type]['title'], '%value' => $value);
180 if ($i++) {
181 $form['filters']['current'][] = array('#markup' => t('and where %property is %value', $t_args));
182 }
183 else {
184 $form['filters']['current'][] = array('#markup' => t('where %property is %value', $t_args));
185 }
186 if (in_array($type, array('type', 'language'))) {
187 // Remove the option if it is already being filtered on.
188 unset($filters[$type]);
189 }
190 }
191
192 $form['filters']['status'] = array(
193 '#type' => 'container',
194 '#attributes' => array('class' => array('clearfix')),
195 '#prefix' => ($i ? '<div class="additional-filters">' . t('and where') . '</div>' : ''),
196 );
197 $form['filters']['status']['filters'] = array(
198 '#type' => 'container',
199 '#attributes' => array('class' => array('filters')),
200 );
201 foreach ($filters as $key => $filter) {
202 $form['filters']['status']['filters'][$key] = array(
203 '#type' => 'select',
204 '#options' => $filter['options'],
205 '#title' => $filter['title'],
206 '#default_value' => '[any]',
207 );
208 }
209
210 $form['filters']['status']['actions'] = array(
211 '#type' => 'actions',
212 '#attributes' => array('class' => array('container-inline')),
213 );
214 $form['filters']['status']['actions']['submit'] = array(
215 '#type' => 'submit',
216 '#value' => count($session) ? t('Refine') : t('Filter'),
217 );
218 if (count($session)) {
219 $form['filters']['status']['actions']['undo'] = array('#type' => 'submit', '#value' => t('Undo'));
220 $form['filters']['status']['actions']['reset'] = array('#type' => 'submit', '#value' => t('Reset'));
221 }
222
223 drupal_add_js('misc/form.js');
224
225 return $form;
226 }
227
239 function node_filter_form_submit($form, &$form_state) {
240 $filters = node_filters();
241 switch ($form_state['values']['op']) {
242 case t('Filter'):
243 case t('Refine'):
244 // Apply every filter that has a choice selected other than 'any'.
245 foreach ($filters as $filter => $options) {
246 if (isset($form_state['values'][$filter]) && $form_state['values'][$filter] != '[any]') {
247 // Flatten the options array to accommodate hierarchical/nested options.
248 $flat_options = form_options_flatten($filters[$filter]['options']);
249 // Only accept valid selections offered on the dropdown, block bad input.
250 if (isset($flat_options[$form_state['values'][$filter]])) {
251 $_SESSION['node_overview_filter'][] = array($filter, $form_state['values'][$filter]);
252 }
253 }
254 }
255 break;
256 case t('Undo'):
257 array_pop($_SESSION['node_overview_filter']);
258 break;
259 case t('Reset'):
260 $_SESSION['node_overview_filter'] = array();
261 break;
262 }
263 }
264
279 function node_mass_update($nodes, $updates) {
280 // We use batch processing to prevent timeout when updating a large number
281 // of nodes.
282 if (count($nodes) > 10) {
283 $batch = array(
284 'operations' => array(
285 array('_node_mass_update_batch_process', array($nodes, $updates))
286 ),
287 'finished' => '_node_mass_update_batch_finished',
288 'title' => t('Processing'),
289 // We use a single multi-pass operation, so the default
290 // 'Remaining x of y operations' message will be confusing here.
291 'progress_message' => '',
292 'error_message' => t('The update has encountered an error.'),
293 // The operations do not live in the .module file, so we need to
294 // tell the batch engine which file to load before calling them.
295 'file' => drupal_get_path('module', 'node') . '/node.admin.inc',
296 );
297 batch_set($batch);
298 }
299 else {
300 foreach ($nodes as $nid) {
301 _node_mass_update_helper($nid, $updates);
302 }
303 drupal_set_message(t('The update has been performed.'));
304 }
305 }
306
320 function _node_mass_update_helper($nid, $updates) {
321 $node = node_load($nid, NULL, TRUE);
322 // For efficiency manually save the original node before applying any changes.
323 $node->original = clone $node;
324 foreach ($updates as $name => $value) {
325 $node->$name = $value;
326 }
327 node_save($node);
328 return $node;
329 }
330
341 function _node_mass_update_batch_process($nodes, $updates, &$context) {
342 if (!isset($context['sandbox']['progress'])) {
343 $context['sandbox']['progress'] = 0;
344 $context['sandbox']['max'] = count($nodes);
345 $context['sandbox']['nodes'] = $nodes;
346 }
347
348 // Process nodes by groups of 5.
349 $count = min(5, count($context['sandbox']['nodes']));
350 for ($i = 1; $i <= $count; $i++) {
351 // For each nid, load the node, reset the values, and save it.
352 $nid = array_shift($context['sandbox']['nodes']);
353 $node = _node_mass_update_helper($nid, $updates);
354
355 // Store result for post-processing in the finished callback.
356 $context['results'][] = l($node->title, 'node/' . $node->nid);
357
358 // Update our progress information.
359 $context['sandbox']['progress']++;
360 }
361
362 // Inform the batch engine that we are not finished,
363 // and provide an estimation of the completion level we reached.
364 if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
365 $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
366 }
367 }
368
380 function _node_mass_update_batch_finished($success, $results, $operations) {
381 if ($success) {
382 drupal_set_message(t('The update has been performed.'));
383 }
384 else {
385 drupal_set_message(t('An error occurred and processing did not complete.'), 'error');
386 $message = format_plural(count($results), '1 item successfully processed:', '@count items successfully processed:');
387 $message .= theme('item_list', array('items' => $results));
388 drupal_set_message($message);
389 }
390 }
391
405 function node_admin_content($form, $form_state) {
406 if (isset($form_state['values']['operation']) && $form_state['values']['operation'] == 'delete') {
407 return node_multiple_delete_confirm($form, $form_state, array_filter($form_state['values']['nodes']));
408 }
409 $form['filter'] = node_filter_form();
410 $form['#submit'][] = 'node_filter_form_submit';
411 $form['admin'] = node_admin_nodes();
412
413 return $form;
414 }
415
428 function node_admin_nodes() {
429 $admin_access = user_access('administer nodes');
430
431 // Build the 'Update options' form.
432 $form['options'] = array(
433 '#type' => 'fieldset',
434 '#title' => t('Update options'),
435 '#attributes' => array('class' => array('container-inline')),
436 '#access' => $admin_access,
437 );
438 $options = array();
439 foreach (module_invoke_all('node_operations') as $operation => $array) {
440 $options[$operation] = $array['label'];
441 }
442 $form['options']['operation'] = array(
443 '#type' => 'select',
444 '#title' => t('Operation'),
445 '#title_display' => 'invisible',
446 '#options' => $options,
447 '#default_value' => 'approve',
448 );
449 $form['options']['submit'] = array(
450 '#type' => 'submit',
451 '#value' => t('Update'),
452 '#validate' => array('node_admin_nodes_validate'),
453 '#submit' => array('node_admin_nodes_submit'),
454 );
455
456 // Enable language column if translation module is enabled or if we have any
457 // node with language.
458 $multilanguage = (module_exists('translation') || db_query_range("SELECT 1 FROM {node} WHERE language <> :language", 0, 1, array(':language' => LANGUAGE_NONE))->fetchField());
459
460 // Build the sortable table header.
461 $header = array(
462 'title' => array('data' => t('Title'), 'field' => 'n.title'),
463 'type' => array('data' => t('Type'), 'field' => 'n.type'),
464 'author' => t('Author'),
465 'status' => array('data' => t('Status'), 'field' => 'n.status'),
466 'changed' => array('data' => t('Updated'), 'field' => 'n.changed', 'sort' => 'desc')
467 );
468 if ($multilanguage) {
469 $header['language'] = array('data' => t('Language'), 'field' => 'n.language');
470 }
471 $header['operations'] = array('data' => t('Operations'));
472
473 $query = db_select('node', 'n')->extend('PagerDefault')->extend('TableSort');
474 node_build_filter_query($query);
475
476 if (!user_access('bypass node access')) {
477 // If the user is able to view their own unpublished nodes, allow them
478 // to see these in addition to published nodes. Check that they actually
479 // have some unpublished nodes to view before adding the condition.
480 if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT nid FROM {node} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->uid, ':status' => 0))->fetchCol()) {
481 $query->condition(db_or()
482 ->condition('n.status', 1)
483 ->condition('n.nid', $own_unpublished, 'IN')
484 );
485 }
486 else {
487 // If not, restrict the query to published nodes.
488 $query->condition('n.status', 1);
489 }
490 }
491 $nids = $query
492 ->fields('n',array('nid'))
493 ->limit(50)
494 ->orderByHeader($header)
495 ->addTag('node_access')
496 ->execute()
497 ->fetchCol();
498 $nodes = node_load_multiple($nids);
499
500 // Prepare the list of nodes.
501 $languages = language_list();
502 $destination = drupal_get_destination();
503 $options = array();
504 foreach ($nodes as $node) {
505 $langcode = entity_language('node', $node);
506 $l_options = $langcode != LANGUAGE_NONE && isset($languages[$langcode]) ? array('language' => $languages[$langcode]) : array();
507 $options[$node->nid] = array(
508 'title' => array(
509 'data' => array(
510 '#type' => 'link',
511 '#title' => $node->title,
512 '#href' => 'node/' . $node->nid,
513 '#options' => $l_options,
514 '#suffix' => ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))),
515 ),
516 ),
517 'type' => check_plain(node_type_get_name($node)),
518 'author' => theme('username', array('account' => $node)),
519 'status' => $node->status ? t('published') : t('not published'),
520 'changed' => format_date($node->changed, 'short'),
521 );
522 if ($multilanguage) {
523 if ($langcode == LANGUAGE_NONE || isset($languages[$langcode])) {
524 $options[$node->nid]['language'] = $langcode == LANGUAGE_NONE ? t('Language neutral') : t($languages[$langcode]->name);
525 }
526 else {
527 $options[$node->nid]['language'] = t('Undefined language (@langcode)', array('@langcode' => $langcode));
528 }
529 }
530 // Build a list of all the accessible operations for the current node.
531 $operations = array();
532 if (node_access('update', $node)) {
533 $operations['edit'] = array(
534 'title' => t('edit'),
535 'href' => 'node/' . $node->nid . '/edit',
536 'query' => $destination,
537 );
538 }
539 if (node_access('delete', $node)) {
540 $operations['delete'] = array(
541 'title' => t('delete'),
542 'href' => 'node/' . $node->nid . '/delete',
543 'query' => $destination,
544 );
545 }
546 $options[$node->nid]['operations'] = array();
547 if (count($operations) > 1) {
548 // Render an unordered list of operations links.
549 $options[$node->nid]['operations'] = array(
550 'data' => array(
551 '#theme' => 'links__node_operations',
552 '#links' => $operations,
553 '#attributes' => array('class' => array('links', 'inline')),
554 ),
555 );
556 }
557 elseif (!empty($operations)) {
558 // Render the first and only operation as a link.
559 $link = reset($operations);
560 $options[$node->nid]['operations'] = array(
561 'data' => array(
562 '#type' => 'link',
563 '#title' => $link['title'],
564 '#href' => $link['href'],
565 '#options' => array('query' => $link['query']),
566 ),
567 );
568 }
569 }
570
571 // Only use a tableselect when the current user is able to perform any
572 // operations.
573 if ($admin_access) {
574 $form['nodes'] = array(
575 '#type' => 'tableselect',
576 '#header' => $header,
577 '#options' => $options,
578 '#empty' => t('No content available.'),
579 );
580 }
581 // Otherwise, use a simple table.
582 else {
583 $form['nodes'] = array(
584 '#theme' => 'table',
585 '#header' => $header,
586 '#rows' => $options,
587 '#empty' => t('No content available.'),
588 );
589 }
590
591 $form['pager'] = array('#markup' => theme('pager'));
592 return $form;
593 }
594
608 function node_admin_nodes_validate($form, &$form_state) {
609 // Error if there are no items to select.
610 if (!is_array($form_state['values']['nodes']) || !count(array_filter($form_state['values']['nodes']))) {
611 form_set_error('', t('No items selected.'));
612 }
613 }
614
627 function node_admin_nodes_submit($form, &$form_state) {
628 $operations = module_invoke_all('node_operations');
629 $operation = $operations[$form_state['values']['operation']];
630 // Filter out unchecked nodes
631 $nodes = array_filter($form_state['values']['nodes']);
632 if ($function = $operation['callback']) {
633 // Add in callback arguments if present.
634 if (isset($operation['callback arguments'])) {
635 $args = array_merge(array($nodes), $operation['callback arguments']);
636 }
637 else {
638 $args = array($nodes);
639 }
640 call_user_func_array($function, $args);
641
642 cache_clear_all();
643 }
644 else {
645 // We need to rebuild the form to go to a second step. For example, to
646 // show the confirmation form for the deletion of nodes.
647 $form_state['rebuild'] = TRUE;
648 }
649 }
650
662 function node_multiple_delete_confirm($form, &$form_state, $nodes) {
663 $form['nodes'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
664 // array_filter returns only elements with TRUE values
665 foreach ($nodes as $nid => $value) {
666 $title = db_query('SELECT title FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchField();
667 $form['nodes'][$nid] = array(
668 '#type' => 'hidden',
669 '#value' => $nid,
670 '#prefix' => '<li>',
671 '#suffix' => check_plain($title) . "</li>\n",
672 );
673 }
674 $form['operation'] = array('#type' => 'hidden', '#value' => 'delete');
675 $form['#submit'][] = 'node_multiple_delete_confirm_submit';
676 $confirm_question = format_plural(count($nodes),
677 'Are you sure you want to delete this item?',
678 'Are you sure you want to delete these items?');
679 return confirm_form($form,
680 $confirm_question,
681 'admin/content', t('This action cannot be undone.'),
682 t('Delete'), t('Cancel'));
683 }
684
695 function node_multiple_delete_confirm_submit($form, &$form_state) {
696 if ($form_state['values']['confirm']) {
697 node_delete_multiple(array_keys($form_state['values']['nodes']));
698 cache_clear_all();
699 $count = count($form_state['values']['nodes']);
700 watchdog('content', 'Deleted @count posts.', array('@count' => $count));
701 drupal_set_message(format_plural($count, 'Deleted 1 post.', 'Deleted @count posts.'));
702 }
703 $form_state['redirect'] = 'admin/content';
704 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
node_filter_form_submit
node_filter_form_submit($form, &$form_state)
Definition: node.admin.inc:239
_node_mass_update_batch_finished
_node_mass_update_batch_finished($success, $results, $operations)
Definition: node.admin.inc:380
node_multiple_delete_confirm
node_multiple_delete_confirm($form, &$form_state, $nodes)
Definition: node.admin.inc:662
node_filters
node_filters()
Definition: node.admin.inc:79
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
node_access_rebuild
node_access_rebuild($batch_mode=FALSE)
Definition: node.module:3603
$name
print $name
Definition: profile-listing.tpl.php:43
$results
print $results
Definition: poll-results.tpl.php:23
node_save
node_save($node)
Definition: node.module:1076
NODE_PROMOTED
const NODE_PROMOTED
Definition: node.module:27
name
print $forum name
Definition: forum-list.tpl.php:57
$header
print $header
Definition: forum-topic-list.tpl.php:42
node_filter_form
node_filter_form()
Definition: node.admin.inc:156
module_exists
module_exists($module)
Definition: module.inc:274
node_type_get_name
node_type_get_name($node)
Definition: node.module:459
QueryConditionInterface\condition
condition($field, $value=NULL, $operator=NULL)
db_or
db_or()
Definition: database.inc:2662
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
node_multiple_delete_confirm_submit
node_multiple_delete_confirm_submit($form, &$form_state)
Definition: node.admin.inc:695
NODE_PUBLISHED
const NODE_PUBLISHED
Definition: node.module:17
node_admin_content
node_admin_content($form, $form_state)
Definition: node.admin.inc:405
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
batch_set
batch_set($batch_definition)
Definition: form.inc:4381
NODE_NOT_STICKY
const NODE_NOT_STICKY
Definition: node.module:32
node_mark
node_mark($nid, $timestamp)
Definition: node.module:350
NODE_NOT_PUBLISHED
const NODE_NOT_PUBLISHED
Definition: node.module:12
node_admin_nodes
node_admin_nodes()
Definition: node.admin.inc:428
node_configure_rebuild_confirm
node_configure_rebuild_confirm()
Definition: node.admin.inc:15
language_list
language_list($field= 'language')
Definition: bootstrap.inc:2723
$value
print $value
Definition: user-profile-item.tpl.php:26
SelectQueryInterface
Definition: select.inc:39
NODE_NOT_PROMOTED
const NODE_NOT_PROMOTED
Definition: node.module:22
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
entity_language
entity_language($entity_type, $entity)
Definition: common.inc:7967
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
user_access
user_access($string, $account=NULL)
Definition: user.module:794
node_admin_nodes_submit
node_admin_nodes_submit($form, &$form_state)
Definition: node.admin.inc:627
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
_node_mass_update_helper
_node_mass_update_helper($nid, $updates)
Definition: node.admin.inc:320
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
node_access
node_access($op, $node, $account=NULL)
Definition: node.module:2981
node_admin_nodes_validate
node_admin_nodes_validate($form, &$form_state)
Definition: node.admin.inc:608
node_type_get_names
node_type_get_names()
Definition: node.module:446
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
node_node_operations
node_node_operations()
Definition: node.admin.inc:33
_node_mass_update_batch_process
_node_mass_update_batch_process($nodes, $updates, &$context)
Definition: node.admin.inc:341
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
node_build_filter_query
node_build_filter_query(SelectQueryInterface $query)
Definition: node.admin.inc:127
node_load_multiple
node_load_multiple($nids=array(), $conditions=array(), $reset=FALSE)
Definition: node.module:945
node_delete_multiple
node_delete_multiple($nids)
Definition: node.module:1243
NODE_STICKY
const NODE_STICKY
Definition: node.module:37
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
node_configure_rebuild_confirm_submit
node_configure_rebuild_confirm_submit($form, &$form_state)
Definition: node.admin.inc:25
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
form_options_flatten
form_options_flatten($array)
Definition: form.inc:2548
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
node_mass_update
node_mass_update($nodes, $updates)
Definition: node.admin.inc:279
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile/profile.module Source File

  • modules
  • profile
profile.module
Go to the documentation of this file.
1 <?php
2
11 define('PROFILE_PRIVATE', 1);
12
16 define('PROFILE_PUBLIC', 2);
17
21 define('PROFILE_PUBLIC_LISTINGS', 3);
22
26 define('PROFILE_HIDDEN', 4);
27
31 function profile_help($path, $arg) {
32 switch ($path) {
33 case 'admin/help#profile':
34 $output = '';
35 $output .= '<h3>' . t('About') . '</h3>';
36 $output .= '<p>' . t('The Profile module allows site administrators to define custom fields (such as country, full name, or age) for user profiles, which are then displayed in the <a href="@user">My Account</a> section. This permits users of a site to share more information about themselves, and can help community-based sites organize users around specific information. For more information, see the online handbook entry for <a href="@profile">Profile module</a>.', array('@user' => url('user'), '@profile' => 'http://drupal.org/documentation/modules/profile/')) . '</p>';
37 $output .= '<h3>' . t('Uses') . '</h3>';
38 $output .= '<dl>';
39 $output .= '<dt>' . t('Adding fields to the default profile') . '</dt>';
40 $output .= '<dd>' . t('To provide the ability for users to enter more information about themselves, the Profile module allows additional fields to be added to the default user profile. Examples of common additions would be <em>Location</em>, <em>Company</em>, <em>Age</em>, or <em>About me</em>.') . '</dd>';
41 $output .= '<dt>' . t('User information pages') . '</dt>';
42 $output .= '<dd>' . t('The Profile module enables links to see further information about site users. You can view both a main <a href="@profile">User list page</a>, and more specified pages by clicking on linked fields in any profile. For example, the <a href="@profile-country">People who live in Canada</a> listing on Drupal.org displays all users who have entered <em>Canada</em> in the <em>Country</em> field on their user profile.', array('@profile' => url('profile'), '@profile-country' => 'http://drupal.org/profile/country/Canada')) . '</dd>';
43 $output .= '<dt>' . t('Author information block') . '</dt>';
44 $output .= '<dd>' . t('The <em>Author information block</em> is a default block created by the Profile module that can be enabled on the <a href="@blocks">Blocks administration page</a>. It shows visitors of your website information about the author of the page they are reading.', array('@blocks' => url('admin/structure/block'))) . '</dd>';
45 $output .= '</dl>';
46 return $output;
47 case 'admin/config/people/profile':
48 return '<p>' . t("This page displays a list of the existing custom profile fields to be displayed on a user's <em>My account</em> page. To provide structure, similar or related fields may be placed inside a category. To add a new category (or edit an existing one), edit a profile field and provide a new category name.") . '</p>';
49 }
50 }
51
55 function profile_theme() {
56 return array(
57 'profile_block' => array(
58 'variables' => array('account' => NULL, 'fields' => array()),
59 'template' => 'profile-block',
60 ),
61 'profile_listing' => array(
62 'variables' => array('account' => NULL, 'fields' => array()),
63 'template' => 'profile-listing',
64 ),
65 'profile_wrapper' => array(
66 'variables' => array('content' => NULL),
67 'template' => 'profile-wrapper',
68 ),
69 'profile_admin_overview' => array(
70 'render element' => 'form',
71 'file' => 'profile.admin.inc',
72 )
73 );
74 }
75
79 function profile_menu() {
80 $items['profile'] = array(
81 'title' => 'User list',
82 'page callback' => 'profile_browse',
83 'access arguments' => array('access user profiles'),
84 'file' => 'profile.pages.inc',
85 'type' => MENU_SUGGESTED_ITEM,
86 );
87 $items['admin/config/people/profile'] = array(
88 'title' => 'Profiles',
89 'description' => 'Create customizable fields for your users.',
90 'page callback' => 'drupal_get_form',
91 'page arguments' => array('profile_admin_overview'),
92 'access arguments' => array('administer users'),
93 'file' => 'profile.admin.inc',
94 );
95 $items['admin/config/people/profile/add'] = array(
96 'title' => 'Add field',
97 'page callback' => 'drupal_get_form',
98 'page arguments' => array('profile_field_form'),
99 'access arguments' => array('administer users'),
100 'type' => MENU_VISIBLE_IN_BREADCRUMB,
101 'file' => 'profile.admin.inc',
102 );
103 $items['admin/config/people/profile/autocomplete'] = array(
104 'title' => 'Profile category autocomplete',
105 'page callback' => 'profile_admin_settings_autocomplete',
106 'access arguments' => array('administer users'),
107 'file' => 'profile.admin.inc',
108 'type' => MENU_CALLBACK,
109 );
110 $items['admin/config/people/profile/edit'] = array(
111 'title' => 'Edit field',
112 'page callback' => 'drupal_get_form',
113 'page arguments' => array('profile_field_form'),
114 'access arguments' => array('administer users'),
115 'type' => MENU_VISIBLE_IN_BREADCRUMB,
116 'file' => 'profile.admin.inc',
117 );
118 $items['admin/config/people/profile/delete'] = array(
119 'title' => 'Delete field',
120 'page callback' => 'drupal_get_form',
121 'page arguments' => array('profile_field_delete'),
122 'access arguments' => array('administer users'),
123 'type' => MENU_VISIBLE_IN_BREADCRUMB,
124 'file' => 'profile.admin.inc',
125 );
126 $items['profile/autocomplete'] = array(
127 'title' => 'Profile autocomplete',
128 'page callback' => 'profile_autocomplete',
129 'access arguments' => array('access user profiles'),
130 'file' => 'profile.pages.inc',
131 'type' => MENU_CALLBACK,
132 );
133 return $items;
134 }
135
139 function profile_block_info() {
140 $blocks['author-information']['info'] = t('Author information');
141 $blocks['author-information']['cache'] = DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE;
142 return $blocks;
143 }
144
148 function profile_block_configure($delta = '') {
149 // Compile a list of fields to show
150 $fields = array();
151 $result = db_query('SELECT name, title, weight, visibility FROM {profile_field} WHERE visibility IN (:visibility) ORDER BY weight', array(':visibility' => array(PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS)));
152 foreach ($result as $record) {
153 $fields[$record->name] = check_plain($record->title);
154 }
155 $fields['user_profile'] = t('Link to full user profile');
156 $form['profile_block_author_fields'] = array(
157 '#type' => 'checkboxes',
158 '#title' => t('Profile fields to display'),
159 '#default_value' => variable_get('profile_block_author_fields', array()),
160 '#options' => $fields,
161 '#description' => t('Select which profile fields you wish to display in the block. Only fields designated as public in the <a href="@profile-admin">profile field configuration</a> are available.', array('@profile-admin' => url('admin/config/people/profile'))),
162 );
163 return $form;
164 }
165
169 function profile_block_save($delta = '', $edit = array()) {
170 variable_set('profile_block_author_fields', $edit['profile_block_author_fields']);
171 }
172
176 function profile_block_view($delta = '') {
177 if (user_access('access user profiles')) {
178 $output = '';
179 if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == NULL) {
180 $node = node_load(arg(1));
181 $account = user_load($node->uid);
182
183 if ($use_fields = variable_get('profile_block_author_fields', array())) {
184 // Compile a list of fields to show.
185 $fields = array();
186 $result = db_query('SELECT * FROM {profile_field} WHERE visibility IN (:visibility) ORDER BY weight', array(':visibility' => array(PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS)));
187 foreach ($result as $record) {
188 // Ensure that field is displayed only if it is among the defined block fields and, if it is private, the user has appropriate permissions.
189 if (isset($use_fields[$record->name]) && $use_fields[$record->name]) {
190 $fields[] = $record;
191 }
192 }
193 }
194
195 if (!empty($fields)) {
196 $profile = _profile_update_user_fields($fields, $account);
197 $output .= theme('profile_block', array('account' => $account, 'fields' => $profile));
198 }
199
200 if (isset($use_fields['user_profile']) && $use_fields['user_profile']) {
201 $output .= '<div>' . l(t('View full user profile'), 'user/' . $account->uid) . '</div>';
202 }
203 }
204
205 if ($output) {
206 $block['subject'] = t('About %name', array('%name' => format_username($account)));
207 $block['content'] = $output;
208 return $block;
209 }
210 }
211 }
212
216 function profile_user_presave(&$edit, $account, $category) {
217 if (!empty($account->uid)) {
218 profile_save_profile($edit, $account, $category);
219 }
220 }
221
225 function profile_user_insert(&$edit, $account, $category) {
226 profile_save_profile($edit, $account, $category, TRUE);
227 }
228
232 function profile_user_cancel($edit, $account, $method) {
233 switch ($method) {
234 case 'user_cancel_reassign':
235 db_delete('profile_value')
236 ->condition('uid', $account->uid)
237 ->execute();
238 }
239 }
240
244 function profile_user_delete($account) {
245 db_delete('profile_value')
246 ->condition('uid', $account->uid)
247 ->execute();
248 }
249
253 function profile_user_load($users) {
254 $result = db_query('SELECT f.name, f.type, v.uid, v.value FROM {profile_field} f INNER JOIN {profile_value} v ON f.fid = v.fid WHERE uid IN (:uids)', array(':uids' => array_keys($users)));
255 foreach ($result as $record) {
256 if (empty($users[$record->uid]->{$record->name})) {
257 $users[$record->uid]->{$record->name} = _profile_field_serialize($record->type) ? unserialize($record->value) : $record->value;
258 }
259 }
260 }
261
262 function profile_save_profile(&$edit, $account, $category, $register = FALSE) {
263 $result = _profile_get_fields($category, $register);
264 foreach ($result as $field) {
265 if (_profile_field_serialize($field->type)) {
266 $edit[$field->name] = serialize($edit[$field->name]);
267 }
268 db_merge('profile_value')
269 ->key(array(
270 'fid' => $field->fid,
271 'uid' => $account->uid,
272 ))
273 ->fields(array('value' => $edit[$field->name]))
274 ->execute();
275 }
276 }
277
278 function profile_view_field($account, $field) {
279 // Only allow browsing of private fields for admins, if browsing is enabled,
280 // and if a user has permission to view profiles. Note that this check is
281 // necessary because a user may always see their own profile.
282 $browse = user_access('access user profiles')
283 && (user_access('administer users') || $field->visibility != PROFILE_PRIVATE)
284 && !empty($field->page);
285
286 if (isset($account->{$field->name}) && $value = $account->{$field->name}) {
287 switch ($field->type) {
288 case 'textarea':
289 return check_markup($value, filter_default_format($account), '', TRUE);
290 case 'textfield':
291 case 'selection':
292 return $browse ? l($value, 'profile/' . $field->name . '/' . $value) : check_plain($value);
293 case 'checkbox':
294 return $browse ? l($field->title, 'profile/' . $field->name) : check_plain($field->title);
295 case 'url':
296 return '<a href="' . check_url($value) . '">' . check_plain($value) . '</a>';
297 case 'date':
298 $format = substr(variable_get('date_format_short', 'm/d/Y - H:i'), 0, 5);
299 // Note: Avoid PHP's date() because it does not handle dates before
300 // 1970 on Windows. This would make the date field useless for e.g.
301 // birthdays.
302 $replace = array(
303 'd' => sprintf('%02d', $value['day']),
304 'j' => $value['day'],
305 'm' => sprintf('%02d', $value['month']),
306 'M' => map_month($value['month']),
307 'Y' => $value['year'],
308 'H:i' => NULL,
309 'g:ia' => NULL,
310 );
311 return strtr($format, $replace);
312 case 'list':
313 $values = preg_split("/[,\n\r]/", $value);
314 $fields = array();
315 foreach ($values as $value) {
316 if ($value = trim($value)) {
317 $fields[] = $browse ? l($value, 'profile/' . $field->name . '/' . $value) : check_plain($value);
318 }
319 }
320 return implode(', ', $fields);
321 }
322 }
323 }
324
328 function profile_user_view($account) {
329 // Show private fields to administrators and people viewing their own account.
330 if (user_access('administer users') || $GLOBALS['user']->uid == $account->uid) {
331 $result = db_query('SELECT * FROM {profile_field} WHERE visibility <> :hidden ORDER BY category, weight', array(':hidden' => PROFILE_HIDDEN));
332 }
333 else {
334 $result = db_query('SELECT * FROM {profile_field} WHERE visibility <> :private AND visibility <> :hidden ORDER BY category, weight', array(':private' => PROFILE_PRIVATE, ':hidden' => PROFILE_HIDDEN));
335 }
336
337 $fields = array();
338 foreach ($result as $field) {
339 if ($value = profile_view_field($account, $field)) {
340 $title = ($field->type != 'checkbox') ? check_plain($field->title) : NULL;
341
342 // Create a single fieldset for each category.
343 if (!isset($account->content[$field->category])) {
344 $account->content[$field->category] = array(
345 '#type' => 'user_profile_category',
346 '#title' => $field->category,
347 );
348 }
349
350 $account->content[$field->category][$field->name] = array(
351 '#type' => 'user_profile_item',
352 '#title' => $title,
353 '#markup' => $value,
354 '#weight' => $field->weight,
355 '#attributes' => array('class' => array('profile-' . $field->name)),
356 );
357 }
358 }
359 }
360
361 function _profile_form_explanation($field) {
362 $output = filter_xss_admin($field->explanation);
363
364 if ($field->type == 'list') {
365 $output .= ' ' . t('Put each item on a separate line or separate them by commas. No HTML allowed.');
366 }
367
368 if ($field->visibility == PROFILE_PRIVATE) {
369 $output .= ' ' . t('The content of this field is kept private and will not be shown publicly.');
370 }
371
372 return $output;
373 }
374
378 function profile_form_alter(&$form, &$form_state, $form_id) {
379 if (!($form_id == 'user_register_form' || $form_id == 'user_profile_form')) {
380 return;
381 }
382 $form['#validate'][] = 'profile_user_form_validate';
383 $account = $form['#user'];
384 $result = _profile_get_fields($form['#user_category'], $form['#user_category'] == 'register');
385 $weight = 1;
386 foreach ($result as $field) {
387 $category = $field->category;
388 if (!isset($form[$category])) {
389 $form[$category] = array('#type' => 'fieldset', '#title' => check_plain($category), '#weight' => $weight++);
390 }
391 switch ($field->type) {
392 case 'textfield':
393 case 'url':
394 $form[$category][$field->name] = array(
395 '#type' => 'textfield',
396 '#title' => check_plain($field->title),
397 '#default_value' => isset($account->{$field->name}) ? $account->{$field->name} : '',
398 '#maxlength' => 255,
399 '#description' => _profile_form_explanation($field),
400 '#required' => $field->required,
401 );
402 if ($field->autocomplete) {
403 $form[$category][$field->name]['#autocomplete_path'] = "profile/autocomplete/" . $field->fid;
404 }
405 break;
406
407 case 'textarea':
408 $form[$category][$field->name] = array(
409 '#type' => 'textarea',
410 '#title' => check_plain($field->title),
411 '#default_value' => isset($account->{$field->name}) ? $account->{$field->name} : '',
412 '#description' => _profile_form_explanation($field),
413 '#required' => $field->required,
414 );
415 break;
416
417 case 'list':
418 $form[$category][$field->name] = array(
419 '#type' => 'textarea',
420 '#title' => check_plain($field->title),
421 '#default_value' => isset($account->{$field->name}) ? $account->{$field->name} : '',
422 '#description' => _profile_form_explanation($field),
423 '#required' => $field->required,
424 );
425 break;
426
427 case 'checkbox':
428 $form[$category][$field->name] = array(
429 '#type' => 'checkbox',
430 '#title' => check_plain($field->title),
431 '#default_value' => isset($account->{$field->name}) ? $account->{$field->name} : '',
432 '#description' => _profile_form_explanation($field),
433 '#required' => $field->required,
434 );
435 break;
436
437 case 'selection':
438 $options = array();
439 $lines = preg_split("/[\n\r]/", $field->options);
440 foreach ($lines as $line) {
441 if ($line = trim($line)) {
442 $options[$line] = $line;
443 }
444 }
445 $form[$category][$field->name] = array(
446 '#type' => 'select',
447 '#title' => check_plain($field->title),
448 '#default_value' => isset($account->{$field->name}) ? $account->{$field->name} : '',
449 '#options' => $options,
450 '#description' => _profile_form_explanation($field),
451 '#required' => $field->required,
452 '#empty_value' => 0,
453 );
454 break;
455
456 case 'date':
457 $form[$category][$field->name] = array(
458 '#type' => 'date',
459 '#title' => check_plain($field->title),
460 '#default_value' => isset($account->{$field->name}) ? $account->{$field->name} : '',
461 '#description' => _profile_form_explanation($field),
462 '#required' => $field->required,
463 );
464 break;
465 }
466 }
467 }
468
472 function _profile_update_user_fields($fields, $account) {
473 foreach ($fields as $key => $field) {
474 $fields[$key]->value = profile_view_field($account, $field);
475 }
476 return $fields;
477 }
478
484 function profile_user_form_validate($form, &$form_state) {
485 $result = _profile_get_fields($form['#user_category'], $form['#user_category'] == 'register');
486 foreach ($result as $field) {
487 if (!empty($form_state['values'][$field->name])) {
488 if ($field->type == 'url' && !valid_url($form_state['values'][$field->name], TRUE)) {
489 form_set_error($field->name, t('The value provided for %field is not a valid URL.', array('%field' => $field->title)));
490 }
491 }
492 elseif ($field->required && !user_access('administer users')) {
493 form_set_error($field->name, t('The field %field is required.', array('%field' => $field->title)));
494 }
495 }
496 }
497
501 function profile_user_categories() {
502 $result = db_query("SELECT DISTINCT(category) FROM {profile_field}");
503 $data = array();
504 foreach ($result as $category) {
505 $data[] = array(
506 'name' => $category->category,
507 'title' => $category->category,
508 'weight' => 3,
509 'access callback' => 'profile_category_access',
510 'access arguments' => array(1, $category->category)
511 );
512 }
513 return $data;
514 }
515
519 function profile_category_access($account, $category) {
520 if (user_access('administer users') && $account->uid > 0) {
521 return TRUE;
522 }
523 else {
524 $category_visible = (bool) db_query_range('SELECT 1 FROM {profile_field} WHERE category = :category AND visibility <> :visibility', 0, 1, array(
525 ':category' => $category,
526 ':visibility' => PROFILE_HIDDEN
527 ))->fetchField();
528 return user_edit_access($account) && $category_visible;
529 }
530 }
531
541 function template_preprocess_profile_block(&$variables) {
542
543 $variables['user_picture'] = theme('user_picture', array('account' => $variables['account']));
544 $variables['profile'] = array();
545 // Supply filtered version of $fields that have values.
546 foreach ($variables['fields'] as $field) {
547 if ($field->value) {
548 $variables['profile'][$field->name] = new stdClass();
549 $variables['profile'][$field->name]->title = check_plain($field->title);
550 $variables['profile'][$field->name]->value = $field->value;
551 $variables['profile'][$field->name]->type = $field->type;
552 }
553 }
554
555 }
556
566 function template_preprocess_profile_listing(&$variables) {
567
568 $variables['user_picture'] = theme('user_picture', array('account' => $variables['account']));
569 $variables['name'] = theme('username', array('account' => $variables['account']));
570 $variables['profile'] = array();
571 // Supply filtered version of $fields that have values.
572 foreach ($variables['fields'] as $field) {
573 if ($field->value) {
574 $variables['profile'][$field->name] = new stdClass();
575 $variables['profile'][$field->name]->title = $field->title;
576 $variables['profile'][$field->name]->value = $field->value;
577 $variables['profile'][$field->name]->type = $field->type;
578 }
579 }
580
581 }
582
591 function template_preprocess_profile_wrapper(&$variables) {
592 $variables['current_field'] = '';
593 if ($field = arg(1)) {
594 $variables['current_field'] = $field;
595 $variables['theme_hook_suggestions'][] = 'profile_wrapper__' . $field;
596 }
597 }
598
599 function _profile_field_types($type = NULL) {
600 $types = array('textfield' => t('single-line textfield'),
601 'textarea' => t('multi-line textfield'),
602 'checkbox' => t('checkbox'),
603 'selection' => t('list selection'),
604 'list' => t('freeform list'),
605 'url' => t('URL'),
606 'date' => t('date'));
607 return isset($type) ? $types[$type] : $types;
608 }
609
610 function _profile_field_serialize($type = NULL) {
611 return $type == 'date';
612 }
613
614 function _profile_get_fields($category, $register = FALSE) {
615 $query = db_select('profile_field');
616 if ($register) {
617 $query->condition('register', 1);
618 }
619 else {
620 $query->condition('category', db_like($category), 'LIKE');
621 }
622 if (!user_access('administer users')) {
623 $query->condition('visibility', PROFILE_HIDDEN, '<>');
624 }
625 return $query
626 ->fields('profile_field')
627 ->orderBy('category', 'ASC')
628 ->orderBy('weight', 'ASC')
629 ->execute();
630 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
profile_user_cancel
profile_user_cancel($edit, $account, $method)
Definition: profile.module:232
_profile_field_serialize
_profile_field_serialize($type=NULL)
Definition: profile.module:610
PROFILE_PUBLIC_LISTINGS
const PROFILE_PUBLIC_LISTINGS
Definition: profile.module:21
template_preprocess_profile_wrapper
template_preprocess_profile_wrapper(&$variables)
Definition: profile.module:591
l
l($text, $path, array $options=array())
Definition: common.inc:2432
user_edit_access
user_edit_access($account)
Definition: user.module:1587
DRUPAL_CACHE_PER_PAGE
const DRUPAL_CACHE_PER_PAGE
Definition: common.inc:156
profile_theme
profile_theme()
Definition: profile.module:55
profile_user_insert
profile_user_insert(&$edit, $account, $category)
Definition: profile.module:225
check_url
check_url($uri)
Definition: common.inc:1387
format_username
format_username($account)
Definition: common.inc:2106
profile_form_alter
profile_form_alter(&$form, &$form_state, $form_id)
Definition: profile.module:378
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
profile_block_info
profile_block_info()
Definition: profile.module:139
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
_profile_field_types
_profile_field_types($type=NULL)
Definition: profile.module:599
_profile_form_explanation
_profile_form_explanation($field)
Definition: profile.module:361
_profile_update_user_fields
_profile_update_user_fields($fields, $account)
Definition: profile.module:472
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
profile_save_profile
profile_save_profile(&$edit, $account, $category, $register=FALSE)
Definition: profile.module:262
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
profile_user_delete
profile_user_delete($account)
Definition: profile.module:244
profile_view_field
profile_view_field($account, $field)
Definition: profile.module:278
PROFILE_PUBLIC
const PROFILE_PUBLIC
Definition: profile.module:16
profile_help
profile_help($path, $arg)
Definition: profile.module:31
$value
print $value
Definition: user-profile-item.tpl.php:26
profile_block_view
profile_block_view($delta= '')
Definition: profile.module:176
map_month
map_month($month)
Definition: form.inc:2996
$output
$output
Definition: authorize.php:93
db_like
db_like($string)
Definition: database.inc:2610
user_access
user_access($string, $account=NULL)
Definition: user.module:794
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
MENU_VISIBLE_IN_BREADCRUMB
const MENU_VISIBLE_IN_BREADCRUMB
Definition: menu.inc:96
profile_user_load
profile_user_load($users)
Definition: profile.module:253
template_preprocess_profile_listing
template_preprocess_profile_listing(&$variables)
Definition: profile.module:566
MENU_SUGGESTED_ITEM
const MENU_SUGGESTED_ITEM
Definition: menu.inc:161
template_preprocess_profile_block
template_preprocess_profile_block(&$variables)
Definition: profile.module:541
PROFILE_HIDDEN
const PROFILE_HIDDEN
Definition: profile.module:26
profile_category_access
profile_category_access($account, $category)
Definition: profile.module:519
profile_block_configure
profile_block_configure($delta= '')
Definition: profile.module:148
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
profile_user_view
profile_user_view($account)
Definition: profile.module:328
title
print $topic title
Definition: forum-topic-list.tpl.php:50
profile_user_form_validate
profile_user_form_validate($form, &$form_state)
Definition: profile.module:484
profile_block_save
profile_block_save($delta= '', $edit=array())
Definition: profile.module:169
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
_profile_get_fields
_profile_get_fields($category, $register=FALSE)
Definition: profile.module:614
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
filter_default_format
filter_default_format($account=NULL)
Definition: filter.module:524
check_markup
check_markup($text, $format_id=NULL, $langcode= '', $cache=FALSE)
Definition: filter.module:759
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
valid_url
valid_url($url, $absolute=FALSE)
Definition: common.inc:1204
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
profile_user_categories
profile_user_categories()
Definition: profile.module:501
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
profile_menu
profile_menu()
Definition: profile.module:79
PROFILE_PRIVATE
const PROFILE_PRIVATE
Definition: profile.module:11
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
DRUPAL_CACHE_PER_ROLE
const DRUPAL_CACHE_PER_ROLE
Definition: common.inc:143
profile_user_presave
profile_user_presave(&$edit, $account, $category)
Definition: profile.module:216
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
ArchiverInterface Member List

This is the complete list of members for ArchiverInterface, including all inherited members.

__construct($file_path) | ArchiverInterface
add($file_path) | ArchiverInterface
extract($path, array $files=array()) | ArchiverInterface
listContents() | ArchiverInterface
remove($path) | ArchiverInterface
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/help/help.api.php Source File

  • modules
  • help
help.api.php
Go to the documentation of this file.
1 <?php
2
49 function hook_help($path, $arg) {
50 switch ($path) {
51 // Main module help for the block module
52 case 'admin/help#block':
53 return '<p>' . t('Blocks are boxes of content rendered into an area, or region, of a web page. The default theme Bartik, for example, implements the regions "Sidebar first", "Sidebar second", "Featured", "Content", "Header", "Footer", etc., and a block may appear in any one of these areas. The <a href="@blocks">blocks administration page</a> provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions.', array('@blocks' => url('admin/structure/block'))) . '</p>';
54
55 // Help for another path in the block module
56 case 'admin/structure/block':
57 return '<p>' . t('This page provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the <em>Save blocks</em> button at the bottom of the page.') . '</p>';
58 }
59 }
60
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
hook_help
hook_help($path, $arg)
Definition: help.api.php:49
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/node_example/node_example.module Source File

  • examples
  • node_example
node_example.module
Go to the documentation of this file.
1 <?php
2
65 function node_example_menu() {
66 $items['examples/node_example'] = array(
67 'page callback' => 'node_example_page',
68 'access arguments' => array('access content'),
69 'title' => 'Node Example',
70 );
71 return $items;
72 }
73
79 function node_example_node_info() {
80 // We define the node type as an associative array.
81 return array(
82 'node_example' => array(
83 'name' => t('Example Node Type'),
84 // 'base' tells Drupal the base string for hook functions.
85 // This is often the module name; if base is set to 'mymodule',
86 // Drupal would call mymodule_insert() or similar for node
87 // hooks. In our case, the base is 'node_example'.
88 'base' => 'node_example',
89 'description' => t('This is an example node type with a few fields.'),
90 'title_label' => t('Example Title'),
91 // We'll set the 'locked' attribute to TRUE, so users won't be
92 // able to change the machine name of our content type.
93 'locked' => TRUE,
94 ),
95 );
96 }
97
112 function node_example_node_type_insert($content_type) {
113 if ($content_type->type == 'node_example') {
114 // First we add the body field. Node API helpfully gives us
115 // node_add_body_field().
116 // We'll set the body label now, although we could also set
117 // it along with our other instance properties later.
118 $body_instance = node_add_body_field($content_type, t('Example Description'));
119
120 // Add our example_node_list view mode to the body instance
121 // display by instructing the body to display as a summary
122 $body_instance['display']['example_node_list'] = array(
123 'label' => 'hidden',
124 'type' => 'text_summary_or_trimmed',
125 );
126
127 // Save our changes to the body field instance.
128 field_update_instance($body_instance);
129
130 // Create all the fields we are adding to our content type.
131 foreach (_node_example_installed_fields() as $field) {
132 field_create_field($field);
133 }
134
135 // Create all the instances for our fields.
136 foreach (_node_example_installed_instances() as $instance) {
137 $instance['entity_type'] = 'node';
138 $instance['bundle'] = 'node_example';
139 field_create_instance($instance);
140 }
141 }
142 }
143
154 function node_example_form($node, $form_state) {
155 return node_content_form($node, $form_state);
156 }
157
171 function node_example_page() {
172 // We'll start building a renderable array that will be our page.
173 // For now we just declare the array.
174 $renderable_array = array();
175 // We query the database and find all of the nodes for the type we defined.
176 $sql = 'SELECT nid FROM {node} n WHERE n.type = :type AND n.status = :status';
177 $result = db_query($sql,
178 array(
179 ':type' => 'node_example',
180 ':status' => 1,
181 )
182 );
183 $renderable_array['explanation'] = array(
184 '#markup' => t("Node Example nodes you've created will be displayed here. Note that the color fields will be displayed differently in this list, than if you view the node normally. Click on the node title to see the difference. This is a result of using our 'example_node_list' node view type."),
185 );
186 // Loop through each of our node_example nodes and instruct node_view
187 // to use our "example_node_list" view.
188 // http://api.drupal.org/api/function/node_load/7
189 // http://api.drupal.org/api/function/node_view/7
190 foreach ($result as $row) {
191 $node = node_load($row->nid);
192 $renderable_array['node_list'][]= node_view($node, 'example_node_list');
193 }
194 return $renderable_array;
195 }
196
203 function node_example_entity_info_alter(&$entity_info) {
204 // Add our new view mode to the list of view modes...
205 $entity_info['node']['view modes']['example_node_list'] = array(
206 'label' => t('Example Node List'),
207 'custom settings' => TRUE,
208 );
209 }
210
211
215 function node_example_field_formatter_info() {
216 return array(
217 'node_example_colors' => array(
218 'label' => t('Node Example Color Handle'),
219 'field types' => array('text'),
220 ),
221 );
222 }
223
230 function node_example_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) {
231 $element = array();
232 switch ($display['type']) {
233 case 'node_example_colors':
234 foreach ($items as $delta => $item) {
235 $element[$delta]['#type'] = 'markup';
236 $color = $item['safe_value'];
237 $element[$delta]['#markup'] = theme('example_node_color', array('color' => $color));
238 }
239 break;
240 }
241
242 return $element;
243 }
244
250 function node_example_theme($existing, $type, $theme, $path) {
251 return array(
252 'example_node_color' => array(
253 'variables' => array('color' => NULL),
254 ),
255 );
256 }
257
261 function node_example_help($path, $arg) {
262 switch ($path) {
263 case 'examples/node_example':
264 return "<p>" . t("The Node Example module provides a custom node type.
265 You can create new Example Node nodes using the <a href='!nodeadd'>node add form</a>.",
266 array('!nodeadd' => url('node/add/node-example'))) . "</p>";
267 }
268 }
269
277 function theme_example_node_color($variables) {
278 $output = '<span style="background-color: #ccc; padding: 1em; margin-bottom: 1em; float: left; color: ' . $variables['color'] . '">' . $variables['color'] . '</span>';
279 return $output;
280 }
281
291 function _node_example_installed_fields() {
292 return array(
293 'node_example_color' => array(
294 'field_name' => 'node_example_color',
295 'cardinality' => 3,
296 'type' => 'text',
297 'settings' => array(
298 'max_length' => 60,
299 ),
300 ),
301 'node_example_quantity' => array(
302 'field_name' => 'node_example_quantity',
303 'cardinality' => 1,
304 'type' => 'text',
305 ),
306 'node_example_image' => array(
307 'field_name' => 'node_example_image',
308 'type' => 'image',
309 'cardinality' => 1,
310 ),
311 );
312 }
313
329 function _node_example_installed_instances() {
330 return array(
331 'node_example_color' => array(
332 'field_name' => 'node_example_color',
333 'label' => t('The colors available for this object.'),
334 'widget' => array(
335 'type' => 'text_textfield',
336 ),
337 'display' => array(
338 'example_node_list' => array(
339 'label' => 'hidden',
340 'type' => 'node_example_colors',
341 ),
342 ),
343 ),
344 'node_example_quantity' => array(
345 'field_name' => 'node_example_quantity',
346 'label' => t('Quantity required'),
347 'type' => 'text',
348 'widget' => array(
349 'type' => 'text_textfield',
350 ),
351 'display' => array(
352 'example_node_list' => array(
353 'label' => 'hidden',
354 'type' => 'hidden',
355 ),
356 ),
357 ),
358 'node_example_image' => array(
359 'field_name' => 'node_example_image',
360 'label' => t('Upload an image:'),
361 'required' => FALSE,
362 'widget' => array(
363 'type' => 'image_image',
364 'weight' => 2.10,
365 ),
366 'display' => array(
367 'example_node_list' => array(
368 'label' => 'hidden',
369 'type' => 'image_link_content__thumbnail',
370 ),
371 ),
372 ),
373 );
374 }
375
node_example_page
node_example_page()
Definition: node_example.module:171
node_example_help
node_example_help($path, $arg)
Definition: node_example.module:261
field_create_instance
field_create_instance($instance)
Definition: field.crud.inc:473
node_example_node_info
node_example_node_info()
Definition: node_example.module:79
node_example_entity_info_alter
node_example_entity_info_alter(&$entity_info)
Definition: node_example.module:203
node_example_menu
node_example_menu()
Definition: node_example.module:65
node_example_node_type_insert
node_example_node_type_insert($content_type)
Definition: node_example.module:112
_node_example_installed_instances
_node_example_installed_instances()
Definition: node_example.module:329
node_example_field_formatter_info
node_example_field_formatter_info()
Definition: node_example.module:215
field_create_field
field_create_field($field)
Definition: field.crud.inc:56
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
node_content_form
node_content_form($node, $form_state)
Definition: node.module:3725
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
node_example_field_formatter_view
node_example_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display)
Definition: node_example.module:230
node_add_body_field
node_add_body_field($type, $label= 'Body')
Definition: node.module:586
node_example_form
node_example_form($node, $form_state)
Definition: node_example.module:154
$output
$output
Definition: authorize.php:93
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
theme_example_node_color
theme_example_node_color($variables)
Definition: node_example.module:277
field_update_instance
field_update_instance($instance)
Definition: field.crud.inc:553
node_example_theme
node_example_theme($existing, $type, $theme, $path)
Definition: node_example.module:250
_node_example_installed_fields
_node_example_installed_fields()
Definition: node_example.module:291
$row
$row
Definition: block-admin-display-form.tpl.php:47
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
node_view
node_view($node, $view_mode= 'full', $langcode=NULL)
Definition: node.module:1329
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: cron.php Source File

cron.php
Go to the documentation of this file.
1 <?php
2
11 define('DRUPAL_ROOT', getcwd());
12
13 include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
14 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
15
16 if (!isset($_GET['cron_key']) || variable_get('cron_key', 'drupal') != $_GET['cron_key']) {
17 watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE);
18 drupal_access_denied();
19 }
20 elseif (variable_get('maintenance_mode', 0)) {
21 watchdog('cron', 'Cron could not run because the site is in maintenance mode.', array(), WATCHDOG_NOTICE);
22 drupal_access_denied();
23 }
24 else {
25 drupal_cron_run();
26 }
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
drupal_bootstrap
drupal_bootstrap($phase=NULL, $new_phase=TRUE)
Definition: bootstrap.inc:2192
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
drupal_access_denied
drupal_access_denied()
Definition: common.inc:744
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
drupal_cron_run
drupal_cron_run()
Definition: common.inc:5227
DRUPAL_BOOTSTRAP_FULL
const DRUPAL_BOOTSTRAP_FULL
Definition: bootstrap.inc:157
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
StreamWrapperInterface Member List

This is the complete list of members for StreamWrapperInterface, including all inherited members.

dir_closedir() | StreamWrapperInterface
dir_opendir($uri, $options) | StreamWrapperInterface
dir_readdir() | StreamWrapperInterface
dir_rewinddir() | StreamWrapperInterface
mkdir($uri, $mode, $options) | StreamWrapperInterface
rename($from_uri, $to_uri) | StreamWrapperInterface
rmdir($uri, $options) | StreamWrapperInterface
stream_close() | StreamWrapperInterface
stream_eof() | StreamWrapperInterface
stream_flush() | StreamWrapperInterface
stream_lock($operation) | StreamWrapperInterface
stream_open($uri, $mode, $options, &$opened_url) | StreamWrapperInterface
stream_read($count) | StreamWrapperInterface
stream_seek($offset, $whence) | StreamWrapperInterface
stream_stat() | StreamWrapperInterface
stream_tell() | StreamWrapperInterface
stream_write($data) | StreamWrapperInterface
unlink($uri) | StreamWrapperInterface
url_stat($uri, $flags) | StreamWrapperInterface
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/trigger_example/trigger_example.module Source File

  • examples
  • trigger_example
trigger_example.module
Go to the documentation of this file.
1 <?php
2
90 function trigger_example_trigger_info() {
91 return array(
92 'user' => array(
93 'user_first_time_login' => array(
94 'label' => t('After a user has logged in for the first time'),
95 ),
96 ),
97 'trigger_example' => array(
98 'triggersomething' => array(
99 'label' => t('After the triggersomething button is clicked'),
100 ),
101 ),
102 );
103 }
104
129 function trigger_example_triggersomething($options = array()) {
130 // Ask the trigger module for all actions enqueued for the 'triggersomething' trigger.
131 $aids = trigger_get_assigned_actions('triggersomething');
132 // prepare a basic context, indicating group and "hook", and call all the
133 // actions with this context as arguments.
134 $context = array(
135 'group' => 'trigger_example',
136 'hook' => 'triggersomething'
137 );
138 actions_do(array_keys($aids), (object) $options, $context);
139 }
140
141
158 function trigger_example_user_login(&$edit, $account, $category = NULL) {
159 // Verify user has never accessed the site: last access was creation date.
160 if ($account->access == 0) {
161 // Call the aproppriate trigger function
162 _trigger_example_first_time_login('user_first_time_login', $edit, $account, $category);
163 }
164 }
165
192 function _trigger_example_first_time_login($hook, &$edit, $account, $category = NULL) {
193 // Keep objects for reuse so that changes actions make to objects can persist.
194 static $objects;
195 // Get all assigned actions for the 'user_first_time_login' trigger.
196 $aids = trigger_get_assigned_actions($hook);
197 $context = array(
198 'group' => 'user',
199 'hook' => $hook,
200 'form_values' => &$edit,
201 );
202 // Instead of making a call to actions_do for all triggers, doing this loop
203 // we provide the oportunity for actions to alter the account object, and
204 // the next action should have this altered account object as argument.
205 foreach ($aids as $aid => $info) {
206 $type = $info['type'];
207 if ($type != 'user') {
208 if (!isset($objects[$type])) {
209 $objects[$type] = _trigger_normalize_user_context($type, $account);
210 }
211 $context['user'] = $account;
212 actions_do($aid, $objects[$type], $context);
213 }
214 else {
215 actions_do($aid, $account, $context, $category);
216 }
217 }
218 }
219
227 function trigger_example_help($path, $arg) {
228 switch ($path) {
229 case 'examples/trigger_example':
230 $explanation = t(
231 'Click the button on this page to call trigger_example_triggersomething()
232 and fire the triggersomething event. First, you need to create an action
233 and assign it to the "After the triggersomething button is clicked" trigger,
234 or nothing will happen. Use the <a href="@actions-url">Actions settings page</a>
235 and assign these actions to the triggersomething event on the
236 <a href="@triggers-url">Triggers settings page</a>. <br/><br/>
237 The other example is the "user never logged in before" example. For that one,
238 assign an action to the "After a user has logged in for the first time" trigger
239 and then log a user in.', array('@actions-url' => url('admin/config/system/actions'), '@triggers-url' => url('admin/structure/trigger/trigger_example')));
240 return "<p>$explanation</p>";
241 case 'admin/structure/trigger/system':
242 return t('you can assign actions to run everytime an email is sent by Drupal');
243 case 'admin/structure/trigger/trigger_example':
244 $explanation = t(
245 "A trigger is a system event. For the trigger example, it's just a button-press.
246 To demonstrate the trigger example, choose to associate the 'display a message to the user'
247 action with the 'after the triggersomething button is pressed' trigger.");
248 return "<p>$explanation</p>";
249 }
250 }
251
257 function trigger_example_menu() {
258 $items['examples/trigger_example'] = array(
259 'title' => 'Trigger Example',
260 'description' => 'Provides a form to demonstrate the trigger example.',
261 'page callback' => 'drupal_get_form',
262 'page arguments' => array('trigger_example_form'),
263 'access callback' => TRUE,
264 );
265 return $items;
266 }
267
273 function trigger_example_form($form_state) {
274 $form['triggersomething'] = array(
275 '#type' => 'submit',
276 '#value' => t('Run triggersomething event'),
277 );
278 return $form;
279 }
280
284 function trigger_example_form_submit($form, $form_state) {
285 // If the user clicked the button, then run the triggersomething trigger.
286 if ($form_state['values']['op'] == t('Run triggersomething event')) {
287 trigger_example_triggersomething();
288 }
289 }
290
291
314 function trigger_example_trigger_info_alter(&$triggers) {
315 // Make a simple change to an existing core trigger, altering the label
316 // "When cron runs" to our custom label "On cron execution"
317 $triggers['system']['cron']['label'] = t('On cron execution');
318 }
trigger_example_menu
trigger_example_menu()
Definition: trigger_example.module:257
trigger_get_assigned_actions
trigger_get_assigned_actions($hook)
Definition: trigger.module:188
trigger_example_help
trigger_example_help($path, $arg)
Definition: trigger_example.module:227
trigger_example_trigger_info
trigger_example_trigger_info()
Definition: trigger_example.module:90
trigger_example_trigger_info_alter
trigger_example_trigger_info_alter(&$triggers)
Definition: trigger_example.module:314
trigger_example_triggersomething
trigger_example_triggersomething($options=array())
Definition: trigger_example.module:129
trigger_example_form_submit
trigger_example_form_submit($form, $form_state)
Definition: trigger_example.module:284
trigger_example_user_login
trigger_example_user_login(&$edit, $account, $category=NULL)
Definition: trigger_example.module:158
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
actions_do
actions_do($action_ids, $object=NULL, $context=NULL, $a1=NULL, $a2=NULL)
Definition: actions.inc:58
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$info
$info
Definition: color.inc:6
_trigger_normalize_user_context
_trigger_normalize_user_context($type, $account)
Definition: trigger.module:475
_trigger_example_first_time_login
_trigger_example_first_time_login($hook, &$edit, $account, $category=NULL)
Definition: trigger_example.module:192
trigger_example_form
trigger_example_form($form_state)
Definition: trigger_example.module:273
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field_ui/field_ui.api.php Source File

  • modules
  • field_ui
field_ui.api.php
Go to the documentation of this file.
1 <?php
2
38 function hook_field_settings_form($field, $instance, $has_data) {
39 $settings = $field['settings'];
40 $form['max_length'] = array(
41 '#type' => 'textfield',
42 '#title' => t('Maximum length'),
43 '#default_value' => $settings['max_length'],
44 '#required' => FALSE,
45 '#element_validate' => array('element_validate_integer_positive'),
46 '#description' => t('The maximum length of the field in characters. Leave blank for an unlimited size.'),
47 );
48 return $form;
49 }
50
65 function hook_field_instance_settings_form($field, $instance) {
66 $settings = $instance['settings'];
67
68 $form['text_processing'] = array(
69 '#type' => 'radios',
70 '#title' => t('Text processing'),
71 '#default_value' => $settings['text_processing'],
72 '#options' => array(
73 t('Plain text'),
74 t('Filtered text (user selects text format)'),
75 ),
76 );
77 if ($field['type'] == 'text_with_summary') {
78 $form['display_summary'] = array(
79 '#type' => 'select',
80 '#title' => t('Display summary'),
81 '#options' => array(
82 t('No'),
83 t('Yes'),
84 ),
85 '#description' => t('Display the summary to allow the user to input a summary value. Hide the summary to automatically fill it with a trimmed portion from the main post.'),
86 '#default_value' => !empty($settings['display_summary']) ? $settings['display_summary'] : 0,
87 );
88 }
89
90 return $form;
91 }
92
107 function hook_field_widget_settings_form($field, $instance) {
108 $widget = $instance['widget'];
109 $settings = $widget['settings'];
110
111 if ($widget['type'] == 'text_textfield') {
112 $form['size'] = array(
113 '#type' => 'textfield',
114 '#title' => t('Size of textfield'),
115 '#default_value' => $settings['size'],
116 '#element_validate' => array('element_validate_integer_positive'),
117 '#required' => TRUE,
118 );
119 }
120 else {
121 $form['rows'] = array(
122 '#type' => 'textfield',
123 '#title' => t('Rows'),
124 '#default_value' => $settings['rows'],
125 '#element_validate' => array('element_validate_integer_positive'),
126 '#required' => TRUE,
127 );
128 }
129
130 return $form;
131 }
132
133
151 function hook_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
152 $display = $instance['display'][$view_mode];
153 $settings = $display['settings'];
154
155 $element = array();
156
157 if ($display['type'] == 'text_trimmed' || $display['type'] == 'text_summary_or_trimmed') {
158 $element['trim_length'] = array(
159 '#title' => t('Length'),
160 '#type' => 'textfield',
161 '#size' => 20,
162 '#default_value' => $settings['trim_length'],
163 '#element_validate' => array('element_validate_integer_positive'),
164 '#required' => TRUE,
165 );
166 }
167
168 return $element;
169
170 }
171
189 function hook_field_formatter_settings_summary($field, $instance, $view_mode) {
190 $display = $instance['display'][$view_mode];
191 $settings = $display['settings'];
192
193 $summary = '';
194
195 if ($display['type'] == 'text_trimmed' || $display['type'] == 'text_summary_or_trimmed') {
196 $summary = t('Length: @chars chars', array('@chars' => $settings['trim_length']));
197 }
198
199 return $summary;
200 }
201
hook_field_formatter_settings_form
hook_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state)
Definition: field_ui.api.php:151
hook_field_instance_settings_form
hook_field_instance_settings_form($field, $instance)
Definition: field_ui.api.php:65
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
hook_field_settings_form
hook_field_settings_form($field, $instance, $has_data)
Definition: field_ui.api.php:38
hook_field_formatter_settings_summary
hook_field_formatter_settings_summary($field, $instance, $view_mode)
Definition: field_ui.api.php:189
hook_field_widget_settings_form
hook_field_widget_settings_form($field, $instance)
Definition: field_ui.api.php:107
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/dblog/dblog.install Source File

  • modules
  • dblog
dblog.install
Go to the documentation of this file.
1 <?php
2
11 function dblog_schema() {
12 $schema['watchdog'] = array(
13 'description' => 'Table that contains logs of all system events.',
14 'fields' => array(
15 'wid' => array(
16 'type' => 'serial',
17 'not null' => TRUE,
18 'description' => 'Primary Key: Unique watchdog event ID.',
19 ),
20 'uid' => array(
21 'type' => 'int',
22 'not null' => TRUE,
23 'default' => 0,
24 'description' => 'The {users}.uid of the user who triggered the event.',
25 ),
26 'type' => array(
27 'type' => 'varchar',
28 'length' => 64,
29 'not null' => TRUE,
30 'default' => '',
31 'description' => 'Type of log message, for example "user" or "page not found."',
32 ),
33 'message' => array(
34 'type' => 'text',
35 'not null' => TRUE,
36 'size' => 'big',
37 'description' => 'Text of log message to be passed into the t() function.',
38 ),
39 'variables' => array(
40 'type' => 'blob',
41 'not null' => TRUE,
42 'size' => 'big',
43 'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
44 ),
45 'severity' => array(
46 'type' => 'int',
47 'unsigned' => TRUE,
48 'not null' => TRUE,
49 'default' => 0,
50 'size' => 'tiny',
51 'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)',
52 ),
53 'link' => array(
54 'type' => 'varchar',
55 'length' => 255,
56 'not null' => FALSE,
57 'default' => '',
58 'description' => 'Link to view the result of the event.',
59 ),
60 'location' => array(
61 'type' => 'text',
62 'not null' => TRUE,
63 'description' => 'URL of the origin of the event.',
64 ),
65 'referer' => array(
66 'type' => 'text',
67 'not null' => FALSE,
68 'description' => 'URL of referring page.',
69 ),
70 'hostname' => array(
71 'type' => 'varchar',
72 'length' => 128,
73 'not null' => TRUE,
74 'default' => '',
75 'description' => 'Hostname of the user who triggered the event.',
76 ),
77 'timestamp' => array(
78 'type' => 'int',
79 'not null' => TRUE,
80 'default' => 0,
81 'description' => 'Unix timestamp of when event occurred.',
82 ),
83 ),
84 'primary key' => array('wid'),
85 'indexes' => array(
86 'type' => array('type'),
87 'uid' => array('uid'),
88 'severity' => array('severity'),
89 ),
90 );
91
92 return $schema;
93 }
94
98 function dblog_uninstall() {
99 variable_del('dblog_row_limit');
100 }
101
110 function dblog_update_7001() {
111 // Allow NULL values for links.
112 db_change_field('watchdog', 'link', 'link', array(
113 'type' => 'varchar',
114 'length' => 255,
115 'not null' => FALSE,
116 'default' => '',
117 'description' => 'Link to view the result of the event.',
118 ));
119
120 // Add an index on uid.
121 db_add_index('watchdog', 'uid', array('uid'));
122
123 // Allow longer type values.
124 db_change_field('watchdog', 'type', 'type', array(
125 'type' => 'varchar',
126 'length' => 64,
127 'not null' => TRUE,
128 'default' => '',
129 'description' => 'Type of log message, for example "user" or "page not found."',
130 ));
131
132 // Convert the variables field (that stores serialized variables) from text to blob.
133 db_change_field('watchdog', 'variables', 'variables', array(
134 'type' => 'blob',
135 'not null' => TRUE,
136 'size' => 'big',
137 'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
138 ));
139 }
140
153 function dblog_update_7002() {
154 db_add_index('watchdog', 'severity', array('severity'));
155 }
156
db_add_index
db_add_index($table, $name, $fields)
Definition: database.inc:2940
dblog_uninstall
dblog_uninstall()
Definition: dblog.install:98
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
dblog_schema
dblog_schema()
Definition: dblog.install:11
dblog_update_7001
dblog_update_7001()
Definition: dblog.install:110
dblog_update_7002
dblog_update_7002()
Definition: dblog.install:153
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/testing/testing.install Source File

  • profiles
  • testing
testing.install
Go to the documentation of this file.
1 <?php
14 function testing_install() {
15 // Allow visitor account creation, but with administrative approval.
16 variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
17
18 // Enable default permissions for system roles.
19 user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content'));
20 user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content'));
21 }
user_role_grant_permissions
user_role_grant_permissions($rid, array $permissions=array())
Definition: user.module:3100
DRUPAL_ANONYMOUS_RID
const DRUPAL_ANONYMOUS_RID
Definition: bootstrap.inc:162
DRUPAL_AUTHENTICATED_RID
const DRUPAL_AUTHENTICATED_RID
Definition: bootstrap.inc:167
testing_install
testing_install()
Definition: testing.install:14
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL
const USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL
Definition: user.module:32
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DefaultMailSystem Member List

This is the complete list of members for DefaultMailSystem, including all inherited members.

format(array $message) | DefaultMailSystem
mail(array $message) | DefaultMailSystem
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/sqlite/database.inc Source File

  • includes
  • database
  • sqlite
database.inc
Go to the documentation of this file.
1 <?php
2
13 include_once DRUPAL_ROOT . '/includes/database/prefetch.inc';
14
18 class DatabaseConnection_sqlite extends DatabaseConnection {
19
28 protected $savepointSupport = FALSE;
29
35 protected $willRollback;
36
43 protected $attachedDatabases = array();
44
55 var $tableDropped = FALSE;
56
57 public function __construct(array $connection_options = array()) {
58 // We don't need a specific PDOStatement class here, we simulate it below.
59 $this->statementClass = NULL;
60
61 // This driver defaults to transaction support, except if explicitly passed FALSE.
62 $this->transactionSupport = $this->transactionalDDLSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] !== FALSE;
63
64 $this->connectionOptions = $connection_options;
65
66 // Allow PDO options to be overridden.
67 $connection_options += array(
68 'pdo' => array(),
69 );
70 $connection_options['pdo'] += array(
71 // Convert numeric values to strings when fetching.
72 PDO::ATTR_STRINGIFY_FETCHES => TRUE,
73 );
74 parent::__construct('sqlite:' . $connection_options['database'], '', '', $connection_options['pdo']);
75
76 // Attach one database for each registered prefix.
77 $prefixes = $this->prefixes;
78 foreach ($prefixes as $table => &$prefix) {
79 // Empty prefix means query the main database -- no need to attach anything.
80 if (!empty($prefix)) {
81 // Only attach the database once.
82 if (!isset($this->attachedDatabases[$prefix])) {
83 $this->attachedDatabases[$prefix] = $prefix;
84 $this->query('ATTACH DATABASE :database AS :prefix', array(':database' => $connection_options['database'] . '-' . $prefix, ':prefix' => $prefix));
85 }
86
87 // Add a ., so queries become prefix.table, which is proper syntax for
88 // querying an attached database.
89 $prefix .= '.';
90 }
91 }
92 // Regenerate the prefixes replacement table.
93 $this->setPrefix($prefixes);
94
95 // Detect support for SAVEPOINT.
96 $version = $this->query('SELECT sqlite_version()')->fetchField();
97 $this->savepointSupport = (version_compare($version, '3.6.8') >= 0);
98
99 // Create functions needed by SQLite.
100 $this->sqliteCreateFunction('if', array($this, 'sqlFunctionIf'));
101 $this->sqliteCreateFunction('greatest', array($this, 'sqlFunctionGreatest'));
102 $this->sqliteCreateFunction('pow', 'pow', 2);
103 $this->sqliteCreateFunction('length', 'strlen', 1);
104 $this->sqliteCreateFunction('md5', 'md5', 1);
105 $this->sqliteCreateFunction('concat', array($this, 'sqlFunctionConcat'));
106 $this->sqliteCreateFunction('substring', array($this, 'sqlFunctionSubstring'), 3);
107 $this->sqliteCreateFunction('substring_index', array($this, 'sqlFunctionSubstringIndex'), 3);
108 $this->sqliteCreateFunction('rand', array($this, 'sqlFunctionRand'));
109
110 // Execute sqlite init_commands.
111 if (isset($connection_options['init_commands'])) {
112 $this->exec(implode('; ', $connection_options['init_commands']));
113 }
114 }
115
123 public function __destruct() {
124 if ($this->tableDropped && !empty($this->attachedDatabases)) {
125 foreach ($this->attachedDatabases as $prefix) {
126 // Check if the database is now empty, ignore the internal SQLite tables.
127 try {
128 $count = $this->query('SELECT COUNT(*) FROM ' . $prefix . '.sqlite_master WHERE type = :type AND name NOT LIKE :pattern', array(':type' => 'table', ':pattern' => 'sqlite_%'))->fetchField();
129
130 // We can prune the database file if it doesn't have any tables.
131 if ($count == 0) {
132 // Detach the database.
133 $this->query('DETACH DATABASE :schema', array(':schema' => $prefix));
134 // Destroy the database file.
135 unlink($this->connectionOptions['database'] . '-' . $prefix);
136 }
137 }
138 catch (Exception $e) {
139 // Ignore the exception and continue. There is nothing we can do here
140 // to report the error or fail safe.
141 }
142 }
143 }
144 }
145
149 public function sqlFunctionIf($condition, $expr1, $expr2 = NULL) {
150 return $condition ? $expr1 : $expr2;
151 }
152
156 public function sqlFunctionGreatest() {
157 $args = func_get_args();
158 foreach ($args as $k => $v) {
159 if (!isset($v)) {
160 unset($args);
161 }
162 }
163 if (count($args)) {
164 return max($args);
165 }
166 else {
167 return NULL;
168 }
169 }
170
174 public function sqlFunctionConcat() {
175 $args = func_get_args();
176 return implode('', $args);
177 }
178
182 public function sqlFunctionSubstring($string, $from, $length) {
183 return substr($string, $from - 1, $length);
184 }
185
189 public function sqlFunctionSubstringIndex($string, $delimiter, $count) {
190 // If string is empty, simply return an empty string.
191 if (empty($string)) {
192 return '';
193 }
194 $end = 0;
195 for ($i = 0; $i < $count; $i++) {
196 $end = strpos($string, $delimiter, $end + 1);
197 if ($end === FALSE) {
198 $end = strlen($string);
199 }
200 }
201 return substr($string, 0, $end);
202 }
203
207 public function sqlFunctionRand($seed = NULL) {
208 if (isset($seed)) {
209 mt_srand($seed);
210 }
211 return mt_rand() / mt_getrandmax();
212 }
213
221 public function prepare($query, $options = array()) {
222 return new DatabaseStatement_sqlite($this, $query, $options);
223 }
224
237 public function PDOPrepare($query, array $options = array()) {
238 return parent::prepare($query, $options);
239 }
240
241 public function queryRange($query, $from, $count, array $args = array(), array $options = array()) {
242 return $this->query($query . ' LIMIT ' . (int) $from . ', ' . (int) $count, $args, $options);
243 }
244
245 public function queryTemporary($query, array $args = array(), array $options = array()) {
246 // Generate a new temporary table name and protect it from prefixing.
247 // SQLite requires that temporary tables to be non-qualified.
248 $tablename = $this->generateTemporaryTableName();
249 $prefixes = $this->prefixes;
250 $prefixes[$tablename] = '';
251 $this->setPrefix($prefixes);
252
253 $this->query(preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE ' . $tablename . ' AS SELECT', $query), $args, $options);
254 return $tablename;
255 }
256
257 public function driver() {
258 return 'sqlite';
259 }
260
261 public function databaseType() {
262 return 'sqlite';
263 }
264
265 public function mapConditionOperator($operator) {
266 // We don't want to override any of the defaults.
267 static $specials = array(
268 'LIKE' => array('postfix' => " ESCAPE '\\'"),
269 'NOT LIKE' => array('postfix' => " ESCAPE '\\'"),
270 );
271 return isset($specials[$operator]) ? $specials[$operator] : NULL;
272 }
273
274 public function prepareQuery($query) {
275 return $this->prepare($this->prefixTables($query));
276 }
277
278 public function nextId($existing_id = 0) {
279 $transaction = $this->startTransaction();
280 // We can safely use literal queries here instead of the slower query
281 // builder because if a given database breaks here then it can simply
282 // override nextId. However, this is unlikely as we deal with short strings
283 // and integers and no known databases require special handling for those
284 // simple cases. If another transaction wants to write the same row, it will
285 // wait until this transaction commits.
286 $stmt = $this->query('UPDATE {sequences} SET value = GREATEST(value, :existing_id) + 1', array(
287 ':existing_id' => $existing_id,
288 ));
289 if (!$stmt->rowCount()) {
290 $this->query('INSERT INTO {sequences} (value) VALUES (:existing_id + 1)', array(
291 ':existing_id' => $existing_id,
292 ));
293 }
294 // The transaction gets committed when the transaction object gets destroyed
295 // because it gets out of scope.
296 return $this->query('SELECT value FROM {sequences}')->fetchField();
297 }
298
299 public function rollback($savepoint_name = 'drupal_transaction') {
300 if ($this->savepointSupport) {
301 return parent::rollBack($savepoint_name);
302 }
303
304 if (!$this->inTransaction()) {
305 throw new DatabaseTransactionNoActiveException();
306 }
307 // A previous rollback to an earlier savepoint may mean that the savepoint
308 // in question has already been rolled back.
309 if (!in_array($savepoint_name, $this->transactionLayers)) {
310 return;
311 }
312
313 // We need to find the point we're rolling back to, all other savepoints
314 // before are no longer needed.
315 while ($savepoint = array_pop($this->transactionLayers)) {
316 if ($savepoint == $savepoint_name) {
317 // Mark whole stack of transactions as needed roll back.
318 $this->willRollback = TRUE;
319 // If it is the last the transaction in the stack, then it is not a
320 // savepoint, it is the transaction itself so we will need to roll back
321 // the transaction rather than a savepoint.
322 if (empty($this->transactionLayers)) {
323 break;
324 }
325 return;
326 }
327 }
328 if ($this->supportsTransactions()) {
329 PDO::rollBack();
330 }
331 }
332
333 public function pushTransaction($name) {
334 if ($this->savepointSupport) {
335 return parent::pushTransaction($name);
336 }
337 if (!$this->supportsTransactions()) {
338 return;
339 }
340 if (isset($this->transactionLayers[$name])) {
341 throw new DatabaseTransactionNameNonUniqueException($name . " is already in use.");
342 }
343 if (!$this->inTransaction()) {
344 PDO::beginTransaction();
345 }
346 $this->transactionLayers[$name] = $name;
347 }
348
349 public function popTransaction($name) {
350 if ($this->savepointSupport) {
351 return parent::popTransaction($name);
352 }
353 if (!$this->supportsTransactions()) {
354 return;
355 }
356 if (!$this->inTransaction()) {
357 throw new DatabaseTransactionNoActiveException();
358 }
359
360 // Commit everything since SAVEPOINT $name.
361 while($savepoint = array_pop($this->transactionLayers)) {
362 if ($savepoint != $name) continue;
363
364 // If there are no more layers left then we should commit or rollback.
365 if (empty($this->transactionLayers)) {
366 // If there was any rollback() we should roll back whole transaction.
367 if ($this->willRollback) {
368 $this->willRollback = FALSE;
369 PDO::rollBack();
370 }
371 elseif (!PDO::commit()) {
372 throw new DatabaseTransactionCommitFailedException();
373 }
374 }
375 else {
376 break;
377 }
378 }
379 }
380
381 }
382
391 class DatabaseStatement_sqlite extends DatabaseStatementPrefetch implements Iterator, DatabaseStatementInterface {
392
403 protected function getStatement($query, &$args = array()) {
404 if (count($args)) {
405 // Check if $args is a simple numeric array.
406 if (range(0, count($args) - 1) === array_keys($args)) {
407 // In that case, we have unnamed placeholders.
408 $count = 0;
409 $new_args = array();
410 foreach ($args as $value) {
411 if (is_float($value) || is_int($value)) {
412 if (is_float($value)) {
413 // Force the conversion to float so as not to loose precision
414 // in the automatic cast.
415 $value = sprintf('%F', $value);
416 }
417 $query = substr_replace($query, $value, strpos($query, '?'), 1);
418 }
419 else {
420 $placeholder = ':db_statement_placeholder_' . $count++;
421 $query = substr_replace($query, $placeholder, strpos($query, '?'), 1);
422 $new_args[$placeholder] = $value;
423 }
424 }
425 $args = $new_args;
426 }
427 else {
428 // Else, this is using named placeholders.
429 foreach ($args as $placeholder => $value) {
430 if (is_float($value) || is_int($value)) {
431 if (is_float($value)) {
432 // Force the conversion to float so as not to loose precision
433 // in the automatic cast.
434 $value = sprintf('%F', $value);
435 }
436
437 // We will remove this placeholder from the query as PDO throws an
438 // exception if the number of placeholders in the query and the
439 // arguments does not match.
440 unset($args[$placeholder]);
441 // PDO allows placeholders to not be prefixed by a colon. See
442 // http://marc.info/?l=php-internals&m=111234321827149&w=2 for
443 // more.
444 if ($placeholder[0] != ':') {
445 $placeholder = ":$placeholder";
446 }
447 // When replacing the placeholders, make sure we search for the
448 // exact placeholder. For example, if searching for
449 // ':db_placeholder_1', do not replace ':db_placeholder_11'.
450 $query = preg_replace('/' . preg_quote($placeholder) . '\b/', $value, $query);
451 }
452 }
453 }
454 }
455
456 return $this->dbh->PDOPrepare($query);
457 }
458
459 public function execute($args = array(), $options = array()) {
460 try {
461 $return = parent::execute($args, $options);
462 }
463 catch (PDOException $e) {
464 if (!empty($e->errorInfo[1]) && $e->errorInfo[1] === 17) {
465 // The schema has changed. SQLite specifies that we must resend the query.
466 $return = parent::execute($args, $options);
467 }
468 else {
469 // Rethrow the exception.
470 throw $e;
471 }
472 }
473
474 // In some weird cases, SQLite will prefix some column names by the name
475 // of the table. We post-process the data, by renaming the column names
476 // using the same convention as MySQL and PostgreSQL.
477 $rename_columns = array();
478 foreach ($this->columnNames as $k => $column) {
479 // In some SQLite versions, SELECT DISTINCT(field) will return "(field)"
480 // instead of "field".
481 if (preg_match("/^\((.*)\)$/", $column, $matches)) {
482 $rename_columns[$column] = $matches[1];
483 $this->columnNames[$k] = $matches[1];
484 $column = $matches[1];
485 }
486
487 // Remove "table." prefixes.
488 if (preg_match("/^.*\.(.*)$/", $column, $matches)) {
489 $rename_columns[$column] = $matches[1];
490 $this->columnNames[$k] = $matches[1];
491 }
492 }
493 if ($rename_columns) {
494 // DatabaseStatementPrefetch already extracted the first row,
495 // put it back into the result set.
496 if (isset($this->currentRow)) {
497 $this->data[0] = &$this->currentRow;
498 }
499
500 // Then rename all the columns across the result set.
501 foreach ($this->data as $k => $row) {
502 foreach ($rename_columns as $old_column => $new_column) {
503 $this->data[$k][$new_column] = $this->data[$k][$old_column];
504 unset($this->data[$k][$old_column]);
505 }
506 }
507
508 // Finally, extract the first row again.
509 $this->currentRow = $this->data[0];
510 unset($this->data[0]);
511 }
512
513 return $return;
514 }
515 }
516
DatabaseConnection_sqlite\nextId
nextId($existing_id=0)
Definition: database.inc:278
DatabaseConnection\$prefixes
$prefixes
Definition: database.inc:280
DatabaseConnection_sqlite\prepare
prepare($query, $options=array())
Definition: database.inc:221
DatabaseConnection_sqlite\sqlFunctionGreatest
sqlFunctionGreatest()
Definition: database.inc:156
DatabaseConnection\query
query($query, array $args=array(), $options=array())
Definition: database.inc:664
DatabaseConnection_sqlite
Definition: database.inc:18
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
DatabaseConnection_sqlite\popTransaction
popTransaction($name)
Definition: database.inc:349
DatabaseConnection\prefixTables
prefixTables($sql)
Definition: database.inc:444
$name
print $name
Definition: profile-listing.tpl.php:43
Exception
DatabaseConnection_sqlite\$willRollback
$willRollback
Definition: database.inc:35
DatabaseConnection_sqlite\databaseType
databaseType()
Definition: database.inc:261
DatabaseStatementPrefetch\$currentRow
$currentRow
Definition: prefetch.inc:59
DatabaseTransactionNoActiveException
Definition: database.inc:1784
DatabaseConnection_sqlite\__construct
__construct(array $connection_options=array())
Definition: database.inc:57
DatabaseConnection_sqlite\prepareQuery
prepareQuery($query)
Definition: database.inc:274
DatabaseConnection\setPrefix
setPrefix($prefix)
Definition: database.inc:405
DatabaseConnection_sqlite\sqlFunctionSubstring
sqlFunctionSubstring($string, $from, $length)
Definition: database.inc:182
$value
print $value
Definition: user-profile-item.tpl.php:26
DatabaseStatementInterface
Definition: database.inc:1953
DatabaseConnection_sqlite\sqlFunctionConcat
sqlFunctionConcat()
Definition: database.inc:174
DatabaseStatementPrefetch
Definition: prefetch.inc:22
DatabaseConnection
Definition: database.inc:184
DatabaseConnection_sqlite\sqlFunctionIf
sqlFunctionIf($condition, $expr1, $expr2=NULL)
Definition: database.inc:149
DatabaseConnection_sqlite\queryTemporary
queryTemporary($query, array $args=array(), array $options=array())
Definition: database.inc:245
DatabaseStatement_sqlite\getStatement
getStatement($query, &$args=array())
Definition: database.inc:403
DatabaseConnection\inTransaction
inTransaction()
Definition: database.inc:990
DatabaseConnection_sqlite\driver
driver()
Definition: database.inc:257
DatabaseConnection_sqlite\$attachedDatabases
$attachedDatabases
Definition: database.inc:43
DatabaseTransactionCommitFailedException
Definition: database.inc:1794
DatabaseConnection_sqlite\queryRange
queryRange($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:241
$row
$row
Definition: block-admin-display-form.tpl.php:47
DatabaseConnection_sqlite\sqlFunctionRand
sqlFunctionRand($seed=NULL)
Definition: database.inc:207
DatabaseConnection\startTransaction
startTransaction($name= '')
Definition: database.inc:1012
DatabaseConnection_sqlite\$savepointSupport
$savepointSupport
Definition: database.inc:28
DatabaseConnection\generateTemporaryTableName
generateTemporaryTableName()
Definition: database.inc:1186
DatabaseTransactionNameNonUniqueException
Definition: database.inc:1789
DatabaseConnection_sqlite\pushTransaction
pushTransaction($name)
Definition: database.inc:333
DatabaseConnection\supportsTransactions
supportsTransactions()
Definition: database.inc:1238
DatabaseStatement_sqlite
Definition: database.inc:391
DatabaseStatement_sqlite\execute
execute($args=array(), $options=array())
Definition: database.inc:459
DatabaseConnection_sqlite\PDOPrepare
PDOPrepare($query, array $options=array())
Definition: database.inc:237
DatabaseConnection_sqlite\mapConditionOperator
mapConditionOperator($operator)
Definition: database.inc:265
DatabaseConnection_sqlite\$tableDropped
$tableDropped
Definition: database.inc:55
DatabaseConnection_sqlite\sqlFunctionSubstringIndex
sqlFunctionSubstringIndex($string, $delimiter, $count)
Definition: database.inc:189
DatabaseConnection_sqlite\__destruct
__destruct()
Definition: database.inc:123
DatabaseConnection_sqlite\rollback
rollback($savepoint_name= 'drupal_transaction')
Definition: database.inc:299
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/password.inc Source File

  • includes
password.inc
Go to the documentation of this file.
1 <?php
2
21 define('DRUPAL_HASH_COUNT', 15);
22
26 define('DRUPAL_MIN_HASH_COUNT', 7);
27
31 define('DRUPAL_MAX_HASH_COUNT', 30);
32
36 define('DRUPAL_HASH_LENGTH', 55);
37
41 function _password_itoa64() {
42 return './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
43 }
44
56 function _password_base64_encode($input, $count) {
57 $output = '';
58 $i = 0;
59 $itoa64 = _password_itoa64();
60 do {
61 $value = ord($input[$i++]);
62 $output .= $itoa64[$value & 0x3f];
63 if ($i < $count) {
64 $value |= ord($input[$i]) << 8;
65 }
66 $output .= $itoa64[($value >> 6) & 0x3f];
67 if ($i++ >= $count) {
68 break;
69 }
70 if ($i < $count) {
71 $value |= ord($input[$i]) << 16;
72 }
73 $output .= $itoa64[($value >> 12) & 0x3f];
74 if ($i++ >= $count) {
75 break;
76 }
77 $output .= $itoa64[($value >> 18) & 0x3f];
78 } while ($i < $count);
79
80 return $output;
81 }
82
99 function _password_generate_salt($count_log2) {
100 $output = '$S$';
101 // Ensure that $count_log2 is within set bounds.
102 $count_log2 = _password_enforce_log2_boundaries($count_log2);
103 // We encode the final log2 iteration count in base 64.
104 $itoa64 = _password_itoa64();
105 $output .= $itoa64[$count_log2];
106 // 6 bytes is the standard salt for a portable phpass hash.
107 $output .= _password_base64_encode(drupal_random_bytes(6), 6);
108 return $output;
109 }
110
121 function _password_enforce_log2_boundaries($count_log2) {
122 if ($count_log2 < DRUPAL_MIN_HASH_COUNT) {
123 return DRUPAL_MIN_HASH_COUNT;
124 }
125 elseif ($count_log2 > DRUPAL_MAX_HASH_COUNT) {
126 return DRUPAL_MAX_HASH_COUNT;
127 }
128
129 return (int) $count_log2;
130 }
131
152 function _password_crypt($algo, $password, $setting) {
153 // The first 12 characters of an existing hash are its setting string.
154 $setting = substr($setting, 0, 12);
155
156 if ($setting[0] != '$' || $setting[2] != '$') {
157 return FALSE;
158 }
159 $count_log2 = _password_get_count_log2($setting);
160 // Hashes may be imported from elsewhere, so we allow != DRUPAL_HASH_COUNT
161 if ($count_log2 < DRUPAL_MIN_HASH_COUNT || $count_log2 > DRUPAL_MAX_HASH_COUNT) {
162 return FALSE;
163 }
164 $salt = substr($setting, 4, 8);
165 // Hashes must have an 8 character salt.
166 if (strlen($salt) != 8) {
167 return FALSE;
168 }
169
170 // Convert the base 2 logarithm into an integer.
171 $count = 1 << $count_log2;
172
173 // We rely on the hash() function being available in PHP 5.2+.
174 $hash = hash($algo, $salt . $password, TRUE);
175 do {
176 $hash = hash($algo, $hash . $password, TRUE);
177 } while (--$count);
178
179 $len = strlen($hash);
180 $output = $setting . _password_base64_encode($hash, $len);
181 // _password_base64_encode() of a 16 byte MD5 will always be 22 characters.
182 // _password_base64_encode() of a 64 byte sha512 will always be 86 characters.
183 $expected = 12 + ceil((8 * $len) / 6);
184 return (strlen($output) == $expected) ? substr($output, 0, DRUPAL_HASH_LENGTH) : FALSE;
185 }
186
190 function _password_get_count_log2($setting) {
191 $itoa64 = _password_itoa64();
192 return strpos($itoa64, $setting[3]);
193 }
194
207 function user_hash_password($password, $count_log2 = 0) {
208 if (empty($count_log2)) {
209 // Use the standard iteration count.
210 $count_log2 = variable_get('password_count_log2', DRUPAL_HASH_COUNT);
211 }
212 return _password_crypt('sha512', $password, _password_generate_salt($count_log2));
213 }
214
230 function user_check_password($password, $account) {
231 if (substr($account->pass, 0, 2) == 'U$') {
232 // This may be an updated password from user_update_7000(). Such hashes
233 // have 'U' added as the first character and need an extra md5().
234 $stored_hash = substr($account->pass, 1);
235 $password = md5($password);
236 }
237 else {
238 $stored_hash = $account->pass;
239 }
240
241 $type = substr($stored_hash, 0, 3);
242 switch ($type) {
243 case '$S$':
244 // A normal Drupal 7 password using sha512.
245 $hash = _password_crypt('sha512', $password, $stored_hash);
246 break;
247 case '$H$':
248 // phpBB3 uses "$H$" for the same thing as "$P$".
249 case '$P$':
250 // A phpass password generated using md5. This is an
251 // imported password or from an earlier Drupal version.
252 $hash = _password_crypt('md5', $password, $stored_hash);
253 break;
254 default:
255 return FALSE;
256 }
257 return ($hash && $stored_hash == $hash);
258 }
259
278 function user_needs_new_hash($account) {
279 // Check whether this was an updated password.
280 if ((substr($account->pass, 0, 3) != '$S$') || (strlen($account->pass) != DRUPAL_HASH_LENGTH)) {
281 return TRUE;
282 }
283 // Ensure that $count_log2 is within set bounds.
284 $count_log2 = _password_enforce_log2_boundaries(variable_get('password_count_log2', DRUPAL_HASH_COUNT));
285 // Check whether the iteration count used differs from the standard number.
286 return (_password_get_count_log2($account->pass) !== $count_log2);
287 }
DRUPAL_MAX_HASH_COUNT
const DRUPAL_MAX_HASH_COUNT
Definition: password.inc:31
_password_generate_salt
_password_generate_salt($count_log2)
Definition: password.inc:99
user_needs_new_hash
user_needs_new_hash($account)
Definition: password.inc:278
DRUPAL_HASH_COUNT
const DRUPAL_HASH_COUNT
Definition: password.inc:21
_password_enforce_log2_boundaries
_password_enforce_log2_boundaries($count_log2)
Definition: password.inc:121
user_hash_password
user_hash_password($password, $count_log2=0)
Definition: password.inc:207
user_check_password
user_check_password($password, $account)
Definition: password.inc:230
_password_crypt
_password_crypt($algo, $password, $setting)
Definition: password.inc:152
_password_base64_encode
_password_base64_encode($input, $count)
Definition: password.inc:56
$value
print $value
Definition: user-profile-item.tpl.php:26
$output
$output
Definition: authorize.php:93
DRUPAL_HASH_LENGTH
const DRUPAL_HASH_LENGTH
Definition: password.inc:36
drupal_random_bytes
drupal_random_bytes($count)
Definition: bootstrap.inc:1974
_password_get_count_log2
_password_get_count_log2($setting)
Definition: password.inc:190
DRUPAL_MIN_HASH_COUNT
const DRUPAL_MIN_HASH_COUNT
Definition: password.inc:26
_password_itoa64
_password_itoa64()
Definition: password.inc:41
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/field_permission_example/field_permission_example.module Source File

  • examples
  • field_permission_example
field_permission_example.module
Go to the documentation of this file.
1 <?php
94 function field_permission_example_permission() {
95 // Note: This would be very easy to generate programatically,
96 // but it's all typed out here for clarity.
97 // The key text is the machine name of the permission.
98 $perms['view own fieldnote'] = array('title' => t('View own fieldnote'));
99 $perms['edit own fieldnote'] = array('title' => t('Edit own fieldnote'));
100 $perms['view any fieldnote'] = array('title' => t('View any fieldnote'));
101 $perms['edit any fieldnote'] = array('title' => t('Edit any fieldnote'));
102
103 return $perms;
104 }
105
125 function field_permission_example_field_access($op, $field, $entity_type, $entity, $account) {
126 // This hook will be invoked for every field type, so we have to
127 // check that it's the one we're interested in.
128 if ($field['type'] == 'field_permission_example_fieldnote') {
129 // First we'll check if the user has the 'superuser'
130 // permissions that node provides. This way administrators
131 // will be able to administer the content types.
132 if (user_access('bypass node access', $account)) {
133 drupal_set_message(t('User can bypass node access.'));
134 return TRUE;
135 }
136 if (user_access('administer content types', $account)) {
137 drupal_set_message(t('User can administer content types.'));
138 return TRUE;
139 }
140 // Now check for our own permissions.
141 // $context will end up being either 'any' or 'own.'
142 $context = 'any';
143 switch ($entity_type) {
144 case 'user':
145 case 'node':
146 // While administering the field itself, $entity will be
147 // NULL, so we have to check it.
148 if ($entity) {
149 if ($entity->uid == $account->uid) $context = 'own';
150 }
151 }
152 // Assemble a permission string, such as
153 // 'view any fieldnote'
154 $permission = $op . ' ' . $context . ' fieldnote';
155 // Finally, ask Drupal if this account has that permission.
156 $access = user_access($permission, $account);
157 $status = 'FALSE';
158 if ($access) $status = 'TRUE';
159 drupal_set_message($permission . ': ' . $status);
160 return $access;
161 }
162 // We have no opinion on field types other than our own.
163 return TRUE;
164 }
165
171 function field_permission_example_field_info() {
172 return array(
173 // We name our field as the associative name of the array.
174 'field_permission_example_fieldnote' => array(
175 'label' => t('Fieldnote'),
176 'description' => t('Place a note-taking field on entities, with granular permissions.'),
177 'default_widget' => 'field_permission_example_widget',
178 'default_formatter' => 'field_permission_example_formatter',
179 ),
180 );
181 }
182
190 function field_permission_example_field_is_empty($item, $field) {
191 return empty($item['notes']);
192 }
193
203 function field_permission_example_field_formatter_info() {
204 return array(
205 // This formatter simply displays the text in a text field.
206 'field_permission_example_formatter' => array(
207 'label' => t('Simple text-based formatter'),
208 'field types' => array('field_permission_example_fieldnote'),
209 ),
210 );
211 }
212
224 function field_permission_example_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
225 $element = array();
226
227 switch ($display['type']) {
228 case 'field_permission_example_formatter':
229 foreach ($items as $delta => $item) {
230 $element[$delta] = array(
231 // We wrap the fieldnote content up in a div tag.
232 '#type' => 'html_tag',
233 '#tag' => 'div',
234 '#value' => check_plain($item['notes']),
235 // Let's give the note a nice sticky-note CSS appearance.
236 '#attributes' => array(
237 'class' => 'stickynote',
238 ),
239 // ..And this is the CSS for the stickynote.
240 '#attached' => array(
241 'css' => array(drupal_get_path('module', 'field_permission_example') .
242 '/field_permission_example.css'),
243 ),
244 );
245 }
246 break;
247 }
248 return $element;
249 }
250
258 function field_permission_example_field_widget_info() {
259 return array(
260 'field_permission_example_widget' => array(
261 'label' => t('Field note textarea'),
262 'field types' => array('field_permission_example_fieldnote'),
263 ),
264 );
265 }
266
275 function field_permission_example_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
276 // Grab the existing value for the field.
277 $value = isset($items[$delta]['notes']) ? $items[$delta]['notes'] : '';
278 // Grab a reference to the form element.
279 $widget = $element;
280 // Set up the delta for our return element.
281 $widget['#delta'] = $delta;
282
283 // Figure out which widget we need to generate.
284 // In our case, there's only one type.
285 switch ($instance['widget']['type']) {
286 case 'field_permission_example_widget':
287 $widget += array(
288 '#type' => 'textarea',
289 '#default_value' => $value,
290 );
291 break;
292 }
293
294 $element['notes'] = $widget;
295 return $element;
296 }
297
303 function field_permission_example_menu() {
304 $items['examples/field_permission_example'] = array(
305 'title' => 'Field Permission Example',
306 'page callback' => '_field_permission_example_page',
307 'access callback' => TRUE,
308 );
309 return $items;
310 }
311
317 function _field_permission_example_page() {
318 $page = t("<p>The Field Permission Example module shows how you can restrict view and edit permissions within your field implementation. It adds a new field type called Fieldnote. Fieldnotes appear as simple text boxes on the create/edit form, and as sticky notes when viewed. By 'sticky note' we mean 'Post-It Note' but that's a trademarked term.</p><p>To see this field in action, add it to a content type or user profile. Go to the permissions page (");
319 $page .= l('admin/people/permissions', 'admin/people/permissions');
320 $page .= t(") and look at the 'Field Permission Example' section. This allows you to change which roles can see and edit Fieldnote fields.</p><p>Creating different users with different capabilities will let you see these behaviors in action. Fieldnote helpfully displays a message telling you which permissions it is trying to resolve for the current field/user combination.</p><p>Definitely look through the code to see various implementation details.</p>");
321 return $page;
322 }
$op
$op
Definition: update.php:404
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
$page
print $page
Definition: overlay.tpl.php:37
field_permission_example_field_widget_info
field_permission_example_field_widget_info()
Definition: field_permission_example.module:258
field_permission_example_field_info
field_permission_example_field_info()
Definition: field_permission_example.module:171
field_permission_example_menu
field_permission_example_menu()
Definition: field_permission_example.module:303
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
user_access
user_access($string, $account=NULL)
Definition: user.module:794
field_permission_example_field_formatter_info
field_permission_example_field_formatter_info()
Definition: field_permission_example.module:203
field_permission_example_field_formatter_view
field_permission_example_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
Definition: field_permission_example.module:224
field_permission_example_permission
field_permission_example_permission()
Definition: field_permission_example.module:94
field_permission_example_field_is_empty
field_permission_example_field_is_empty($item, $field)
Definition: field_permission_example.module:190
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
_field_permission_example_page
_field_permission_example_page()
Definition: field_permission_example.module:317
field_permission_example_field_widget_form
field_permission_example_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
Definition: field_permission_example.module:275
field_permission_example_field_access
field_permission_example_field_access($op, $field, $entity_type, $entity, $account)
Definition: field_permission_example.module:125
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/simpletest/simpletest.install Source File

  • modules
  • simpletest
simpletest.install
Go to the documentation of this file.
1 <?php
2
11 define('SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT', '64M');
12
16 function simpletest_requirements($phase) {
17 $requirements = array();
18 $t = get_t();
19
20 $has_curl = function_exists('curl_init');
21 $has_hash = function_exists('hash_hmac');
22 $has_domdocument = method_exists('DOMDocument', 'loadHTML');
23 $open_basedir = ini_get('open_basedir');
24
25 $requirements['curl'] = array(
26 'title' => $t('cURL'),
27 'value' => $has_curl ? $t('Enabled') : $t('Not found'),
28 );
29 if (!$has_curl) {
30 $requirements['curl']['severity'] = REQUIREMENT_ERROR;
31 $requirements['curl']['description'] = $t('The testing framework could not be installed because the PHP <a href="@curl_url">cURL</a> library is not available.', array('@curl_url' => 'http://php.net/manual/en/curl.setup.php'));
32 }
33 $requirements['hash'] = array(
34 'title' => $t('hash'),
35 'value' => $has_hash ? $t('Enabled') : $t('Not found'),
36 );
37 if (!$has_hash) {
38 $requirements['hash']['severity'] = REQUIREMENT_ERROR;
39 $requirements['hash']['description'] = $t('The testing framework could not be installed because the PHP <a href="@hash_url">hash</a> extension is disabled.', array('@hash_url' => 'http://php.net/manual/en/book.hash.php'));
40 }
41
42 $requirements['php_domdocument'] = array(
43 'title' => $t('PHP DOMDocument class'),
44 'value' => $has_domdocument ? $t('Enabled') : $t('Not found'),
45 );
46 if (!$has_domdocument) {
47 $requirements['php_domdocument']['severity'] = REQUIREMENT_ERROR;
48 $requirements['php_domdocument']['description'] = $t('The testing framework requires the DOMDocument class to be available. Check the configure command at the <a href="@link-phpinfo">PHP info page</a>.', array('@link-phpinfo' => url('admin/reports/status/php')));
49 }
50
51 // SimpleTest currently needs 2 cURL options which are incompatible with
52 // having PHP's open_basedir restriction set.
53 // See http://drupal.org/node/674304.
54 $requirements['php_open_basedir'] = array(
55 'title' => $t('PHP open_basedir restriction'),
56 'value' => $open_basedir ? $t('Enabled') : $t('Disabled'),
57 );
58 if ($open_basedir) {
59 $requirements['php_open_basedir']['severity'] = REQUIREMENT_ERROR;
60 $requirements['php_open_basedir']['description'] = $t('The testing framework requires the PHP <a href="@open_basedir-url">open_basedir</a> restriction to be disabled. Check your webserver configuration or contact your web host.', array('@open_basedir-url' => 'http://php.net/manual/en/ini.core.php#ini.open-basedir'));
61 }
62
63 // Check the current memory limit. If it is set too low, SimpleTest will fail
64 // to load all tests and throw a fatal error.
65 $memory_limit = ini_get('memory_limit');
66 if (!drupal_check_memory_limit(SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT, $memory_limit)) {
67 $requirements['php_memory_limit']['severity'] = REQUIREMENT_ERROR;
68 $requirements['php_memory_limit']['description'] = $t('The testing framework requires the PHP memory limit to be at least %memory_minimum_limit. The current value is %memory_limit. <a href="@url">Follow these steps to continue</a>.', array('%memory_limit' => $memory_limit, '%memory_minimum_limit' => SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT, '@url' => 'http://drupal.org/node/207036'));
69 }
70
71 return $requirements;
72 }
73
77 function simpletest_schema() {
78 $schema['simpletest'] = array(
79 'description' => 'Stores simpletest messages',
80 'fields' => array(
81 'message_id' => array(
82 'type' => 'serial',
83 'not null' => TRUE,
84 'description' => 'Primary Key: Unique simpletest message ID.',
85 ),
86 'test_id' => array(
87 'type' => 'int',
88 'not null' => TRUE,
89 'default' => 0,
90 'description' => 'Test ID, messages belonging to the same ID are reported together',
91 ),
92 'test_class' => array(
93 'type' => 'varchar',
94 'length' => 255,
95 'not null' => TRUE,
96 'default' => '',
97 'description' => 'The name of the class that created this message.',
98 ),
99 'status' => array(
100 'type' => 'varchar',
101 'length' => 9,
102 'not null' => TRUE,
103 'default' => '',
104 'description' => 'Message status. Core understands pass, fail, exception.',
105 ),
106 'message' => array(
107 'type' => 'text',
108 'not null' => TRUE,
109 'description' => 'The message itself.',
110 ),
111 'message_group' => array(
112 'type' => 'varchar',
113 'length' => 255,
114 'not null' => TRUE,
115 'default' => '',
116 'description' => 'The message group this message belongs to. For example: warning, browser, user.',
117 ),
118 'function' => array(
119 'type' => 'varchar',
120 'length' => 255,
121 'not null' => TRUE,
122 'default' => '',
123 'description' => 'Name of the assertion function or method that created this message.',
124 ),
125 'line' => array(
126 'type' => 'int',
127 'not null' => TRUE,
128 'default' => 0,
129 'description' => 'Line number on which the function is called.',
130 ),
131 'file' => array(
132 'type' => 'varchar',
133 'length' => 255,
134 'not null' => TRUE,
135 'default' => '',
136 'description' => 'Name of the file where the function is called.',
137 ),
138 ),
139 'primary key' => array('message_id'),
140 'indexes' => array(
141 'reporter' => array('test_class', 'message_id'),
142 ),
143 );
144 $schema['simpletest_test_id'] = array(
145 'description' => 'Stores simpletest test IDs, used to auto-incrament the test ID so that a fresh test ID is used.',
146 'fields' => array(
147 'test_id' => array(
148 'type' => 'serial',
149 'not null' => TRUE,
150 'description' => 'Primary Key: Unique simpletest ID used to group test results together. Each time a set of tests
151 are run a new test ID is used.',
152 ),
153 'last_prefix' => array(
154 'type' => 'varchar',
155 'length' => 60,
156 'not null' => FALSE,
157 'default' => '',
158 'description' => 'The last database prefix used during testing.',
159 ),
160 ),
161 'primary key' => array('test_id'),
162 );
163 return $schema;
164 }
165
169 function simpletest_uninstall() {
170 drupal_load('module', 'simpletest');
171 simpletest_clean_database();
172
173 // Remove settings variables.
174 variable_del('simpletest_httpauth_method');
175 variable_del('simpletest_httpauth_username');
176 variable_del('simpletest_httpauth_password');
177 variable_del('simpletest_clear_results');
178 variable_del('simpletest_verbose');
179
180 // Remove generated files.
181 file_unmanaged_delete_recursive('public://simpletest');
182 }
drupal_check_memory_limit
drupal_check_memory_limit($required, $memory_limit=NULL)
Definition: bootstrap.inc:3477
simpletest_schema
simpletest_schema()
Definition: simpletest.install:77
file_unmanaged_delete_recursive
file_unmanaged_delete_recursive($path)
Definition: file.inc:1358
SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT
const SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT
Definition: simpletest.install:11
variable_del
variable_del($name)
Definition: bootstrap.inc:996
simpletest_clean_database
simpletest_clean_database()
Definition: simpletest.module:537
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
get_t
get_t()
Definition: bootstrap.inc:2635
simpletest_uninstall
simpletest_uninstall()
Definition: simpletest.install:169
simpletest_requirements
simpletest_requirements($phase)
Definition: simpletest.install:16
drupal_load
drupal_load($type, $name)
Definition: bootstrap.inc:1093
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
Archive_Tar Member List

This is the complete list of members for Archive_Tar, including all inherited members.

$_compress | Archive_Tar
$_compress_type | Archive_Tar
$_file | Archive_Tar
$_separator | Archive_Tar
$_tarname | Archive_Tar
$_temp_tarname | Archive_Tar
__construct($p_tarname, $p_compress=null) | Archive_Tar
__destruct() | Archive_Tar
_addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir) | Archive_Tar
_addList($p_list, $p_add_dir, $p_remove_dir) | Archive_Tar
_addString($p_filename, $p_string) | Archive_Tar
_append($p_filelist, $p_add_dir='', $p_remove_dir='') | Archive_Tar
_cleanFile() | Archive_Tar
_close() | Archive_Tar
_dirCheck($p_dir) | Archive_Tar
_error($p_message) | Archive_Tar
_extractInString($p_filename) | Archive_Tar
_extractList($p_path, &$p_list_detail, $p_mode, $p_file_list, $p_remove_path) | Archive_Tar
_isArchive($p_filename=NULL) | Archive_Tar
_jumpBlock($p_len=null) | Archive_Tar
_maliciousFilename($file) | Archive_Tar
_openAppend() | Archive_Tar
_openRead() | Archive_Tar
_openReadWrite() | Archive_Tar
_openWrite() | Archive_Tar
_pathReduction($p_dir) | Archive_Tar
_readBlock() | Archive_Tar
_readHeader($v_binary_data, &$v_header) | Archive_Tar
_readLongHeader(&$v_header) | Archive_Tar
_translateWinPath($p_path, $p_remove_disk_letter=true) | Archive_Tar
_warning($p_message) | Archive_Tar
_writeBlock($p_binary_data, $p_len=null) | Archive_Tar
_writeFooter() | Archive_Tar
_writeHeader($p_filename, $p_stored_filename) | Archive_Tar
_writeHeaderBlock($p_filename, $p_size, $p_mtime=0, $p_perms=0, $p_type='', $p_uid=0, $p_gid=0) | Archive_Tar
_writeLongHeader($p_filename) | Archive_Tar
add($p_filelist) | Archive_Tar
addModify($p_filelist, $p_add_dir, $p_remove_dir='') | Archive_Tar
addString($p_filename, $p_string) | Archive_Tar
create($p_filelist) | Archive_Tar
createModify($p_filelist, $p_add_dir, $p_remove_dir='') | Archive_Tar
extract($p_path='') | Archive_Tar
extractInString($p_filename) | Archive_Tar
extractList($p_filelist, $p_path='', $p_remove_path='') | Archive_Tar
extractModify($p_path, $p_remove_path) | Archive_Tar
listContent() | Archive_Tar
loadExtension($ext) | Archive_Tar
setAttribute() | Archive_Tar
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.tar.inc Source File

  • modules
  • system
system.tar.inc
Go to the documentation of this file.
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
43 //require_once 'PEAR.php';
44 //
45 //
46 define ('ARCHIVE_TAR_ATT_SEPARATOR', 90001);
47 define ('ARCHIVE_TAR_END_BLOCK', pack("a512", ''));
48
57 class Archive_Tar // extends PEAR
58 {
62 var $_tarname='';
63
67 var $_compress=false;
68
72 var $_compress_type='none';
73
77 var $_separator=' ';
78
82 var $_file=0;
83
87 var $_temp_tarname='';
88
89 // {{{ constructor
104 // function Archive_Tar($p_tarname, $p_compress = null)
105 function __construct($p_tarname, $p_compress = null)
106 {
107 // $this->PEAR();
108 $this->_compress = false;
109 $this->_compress_type = 'none';
110 if (($p_compress === null) || ($p_compress == '')) {
111 if (@file_exists($p_tarname)) {
112 if ($fp = @fopen($p_tarname, "rb")) {
113 // look for gzip magic cookie
114 $data = fread($fp, 2);
115 fclose($fp);
116 if ($data == "\37\213") {
117 $this->_compress = true;
118 $this->_compress_type = 'gz';
119 // No sure it's enought for a magic code ....
120 } elseif ($data == "BZ") {
121 $this->_compress = true;
122 $this->_compress_type = 'bz2';
123 }
124 }
125 } else {
126 // probably a remote file or some file accessible
127 // through a stream interface
128 if (substr($p_tarname, -2) == 'gz') {
129 $this->_compress = true;
130 $this->_compress_type = 'gz';
131 } elseif ((substr($p_tarname, -3) == 'bz2') ||
132 (substr($p_tarname, -2) == 'bz')) {
133 $this->_compress = true;
134 $this->_compress_type = 'bz2';
135 }
136 }
137 } else {
138 if (($p_compress === true) || ($p_compress == 'gz')) {
139 $this->_compress = true;
140 $this->_compress_type = 'gz';
141 } else if ($p_compress == 'bz2') {
142 $this->_compress = true;
143 $this->_compress_type = 'bz2';
144 } else {
145 die("Unsupported compression type '$p_compress'\n".
146 "Supported types are 'gz' and 'bz2'.\n");
147 return false;
148 }
149 }
150 $this->_tarname = $p_tarname;
151 if ($this->_compress) { // assert zlib or bz2 extension support
152 if ($this->_compress_type == 'gz')
153 $extname = 'zlib';
154 else if ($this->_compress_type == 'bz2')
155 $extname = 'bz2';
156
157 if (!extension_loaded($extname)) {
158 // PEAR::loadExtension($extname);
159 $this->loadExtension($extname);
160 }
161 if (!extension_loaded($extname)) {
162 die("The extension '$extname' couldn't be found.\n".
163 "Please make sure your version of PHP was built ".
164 "with '$extname' support.\n");
165 return false;
166 }
167 }
168 }
169 // }}}
170
179 function loadExtension($ext)
180 {
181 if (!extension_loaded($ext)) {
182 // if either returns true dl() will produce a FATAL error, stop that
183 if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {
184 return false;
185 }
186
187 if (OS_WINDOWS) {
188 $suffix = '.dll';
189 } elseif (PHP_OS == 'HP-UX') {
190 $suffix = '.sl';
191 } elseif (PHP_OS == 'AIX') {
192 $suffix = '.a';
193 } elseif (PHP_OS == 'OSX') {
194 $suffix = '.bundle';
195 } else {
196 $suffix = '.so';
197 }
198
199 return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
200 }
201
202 return true;
203 }
204
205
206 // {{{ destructor
207 // function _Archive_Tar()
208 function __destruct()
209 {
210 $this->_close();
211 // ----- Look for a local copy to delete
212 if ($this->_temp_tarname != '')
213 @drupal_unlink($this->_temp_tarname);
214 // $this->_PEAR();
215 }
216 // }}}
217
218 // {{{ create()
240 function create($p_filelist)
241 {
242 return $this->createModify($p_filelist, '', '');
243 }
244 // }}}
245
246 // {{{ add()
262 function add($p_filelist)
263 {
264 return $this->addModify($p_filelist, '', '');
265 }
266 // }}}
267
268 // {{{ extract()
269 function extract($p_path='')
270 {
271 return $this->extractModify($p_path, '');
272 }
273 // }}}
274
275 // {{{ listContent()
276 function listContent()
277 {
278 $v_list_detail = array();
279
280 if ($this->_openRead()) {
281 if (!$this->_extractList('', $v_list_detail, "list", '', '')) {
282 unset($v_list_detail);
283 $v_list_detail = 0;
284 }
285 $this->_close();
286 }
287
288 return $v_list_detail;
289 }
290 // }}}
291
292 // {{{ createModify()
328 function createModify($p_filelist, $p_add_dir, $p_remove_dir='')
329 {
330 $v_result = true;
331
332 if (!$this->_openWrite())
333 return false;
334
335 if ($p_filelist != '') {
336 if (is_array($p_filelist))
337 $v_list = $p_filelist;
338 elseif (is_string($p_filelist))
339 $v_list = explode($this->_separator, $p_filelist);
340 else {
341 $this->_cleanFile();
342 $this->_error('Invalid file list');
343 return false;
344 }
345
346 $v_result = $this->_addList($v_list, $p_add_dir, $p_remove_dir);
347 }
348
349 if ($v_result) {
350 $this->_writeFooter();
351 $this->_close();
352 } else
353 $this->_cleanFile();
354
355 return $v_result;
356 }
357 // }}}
358
359 // {{{ addModify()
400 function addModify($p_filelist, $p_add_dir, $p_remove_dir='')
401 {
402 $v_result = true;
403
404 if (!$this->_isArchive())
405 $v_result = $this->createModify($p_filelist, $p_add_dir,
406 $p_remove_dir);
407 else {
408 if (is_array($p_filelist))
409 $v_list = $p_filelist;
410 elseif (is_string($p_filelist))
411 $v_list = explode($this->_separator, $p_filelist);
412 else {
413 $this->_error('Invalid file list');
414 return false;
415 }
416
417 $v_result = $this->_append($v_list, $p_add_dir, $p_remove_dir);
418 }
419
420 return $v_result;
421 }
422 // }}}
423
424 // {{{ addString()
438 function addString($p_filename, $p_string)
439 {
440 $v_result = true;
441
442 if (!$this->_isArchive()) {
443 if (!$this->_openWrite()) {
444 return false;
445 }
446 $this->_close();
447 }
448
449 if (!$this->_openAppend())
450 return false;
451
452 // Need to check the get back to the temporary file ? ....
453 $v_result = $this->_addString($p_filename, $p_string);
454
455 $this->_writeFooter();
456
457 $this->_close();
458
459 return $v_result;
460 }
461 // }}}
462
463 // {{{ extractModify()
497 function extractModify($p_path, $p_remove_path)
498 {
499 $v_result = true;
500 $v_list_detail = array();
501
502 if ($v_result = $this->_openRead()) {
503 $v_result = $this->_extractList($p_path, $v_list_detail,
504 "complete", 0, $p_remove_path);
505 $this->_close();
506 }
507
508 return $v_result;
509 }
510 // }}}
511
512 // {{{ extractInString()
520 function extractInString($p_filename)
521 {
522 if ($this->_openRead()) {
523 $v_result = $this->_extractInString($p_filename);
524 $this->_close();
525 } else {
526 $v_result = NULL;
527 }
528
529 return $v_result;
530 }
531 // }}}
532
533 // {{{ extractList()
552 function extractList($p_filelist, $p_path='', $p_remove_path='')
553 {
554 $v_result = true;
555 $v_list_detail = array();
556
557 if (is_array($p_filelist))
558 $v_list = $p_filelist;
559 elseif (is_string($p_filelist))
560 $v_list = explode($this->_separator, $p_filelist);
561 else {
562 $this->_error('Invalid string list');
563 return false;
564 }
565
566 if ($v_result = $this->_openRead()) {
567 $v_result = $this->_extractList($p_path, $v_list_detail, "partial",
568 $v_list, $p_remove_path);
569 $this->_close();
570 }
571
572 return $v_result;
573 }
574 // }}}
575
576 // {{{ setAttribute()
585 function setAttribute()
586 {
587 $v_result = true;
588
589 // ----- Get the number of variable list of arguments
590 if (($v_size = func_num_args()) == 0) {
591 return true;
592 }
593
594 // ----- Get the arguments
595 $v_att_list = &func_get_args();
596
597 // ----- Read the attributes
598 $i=0;
599 while ($i<$v_size) {
600
601 // ----- Look for next option
602 switch ($v_att_list[$i]) {
603 // ----- Look for options that request a string value
604 case ARCHIVE_TAR_ATT_SEPARATOR :
605 // ----- Check the number of parameters
606 if (($i+1) >= $v_size) {
607 $this->_error('Invalid number of parameters for '
608 .'attribute ARCHIVE_TAR_ATT_SEPARATOR');
609 return false;
610 }
611
612 // ----- Get the value
613 $this->_separator = $v_att_list[$i+1];
614 $i++;
615 break;
616
617 default :
618 $this->_error('Unknow attribute code '.$v_att_list[$i].'');
619 return false;
620 }
621
622 // ----- Next attribute
623 $i++;
624 }
625
626 return $v_result;
627 }
628 // }}}
629
630 // {{{ _error()
631 function _error($p_message)
632 {
633 // ----- To be completed
634 // $this->raiseError($p_message);
635 throw new Exception($p_message);
636 }
637 // }}}
638
639 // {{{ _warning()
640 function _warning($p_message)
641 {
642 // ----- To be completed
643 // $this->raiseError($p_message);
644 throw new Exception($p_message);
645 }
646 // }}}
647
648 // {{{ _isArchive()
649 function _isArchive($p_filename=NULL)
650 {
651 if ($p_filename == NULL) {
652 $p_filename = $this->_tarname;
653 }
654 clearstatcache();
655 return @is_file($p_filename) && !@is_link($p_filename);
656 }
657 // }}}
658
659 // {{{ _openWrite()
660 function _openWrite()
661 {
662 if ($this->_compress_type == 'gz')
663 $this->_file = @gzopen($this->_tarname, "wb9");
664 else if ($this->_compress_type == 'bz2')
665 $this->_file = @bzopen($this->_tarname, "w");
666 else if ($this->_compress_type == 'none')
667 $this->_file = @fopen($this->_tarname, "wb");
668 else
669 $this->_error('Unknown or missing compression type ('
670 .$this->_compress_type.')');
671
672 if ($this->_file == 0) {
673 $this->_error('Unable to open in write mode \''
674 .$this->_tarname.'\'');
675 return false;
676 }
677
678 return true;
679 }
680 // }}}
681
682 // {{{ _openRead()
683 function _openRead()
684 {
685 if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') {
686
687 // ----- Look if a local copy need to be done
688 if ($this->_temp_tarname == '') {
689 $this->_temp_tarname = uniqid('tar').'.tmp';
690 if (!$v_file_from = @fopen($this->_tarname, 'rb')) {
691 $this->_error('Unable to open in read mode \''
692 .$this->_tarname.'\'');
693 $this->_temp_tarname = '';
694 return false;
695 }
696 if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) {
697 $this->_error('Unable to open in write mode \''
698 .$this->_temp_tarname.'\'');
699 $this->_temp_tarname = '';
700 return false;
701 }
702 while ($v_data = @fread($v_file_from, 1024))
703 @fwrite($v_file_to, $v_data);
704 @fclose($v_file_from);
705 @fclose($v_file_to);
706 }
707
708 // ----- File to open if the local copy
709 $v_filename = $this->_temp_tarname;
710
711 } else
712 // ----- File to open if the normal Tar file
713 $v_filename = $this->_tarname;
714
715 if ($this->_compress_type == 'gz')
716 $this->_file = @gzopen($v_filename, "rb");
717 else if ($this->_compress_type == 'bz2')
718 $this->_file = @bzopen($v_filename, "r");
719 else if ($this->_compress_type == 'none')
720 $this->_file = @fopen($v_filename, "rb");
721 else
722 $this->_error('Unknown or missing compression type ('
723 .$this->_compress_type.')');
724
725 if ($this->_file == 0) {
726 $this->_error('Unable to open in read mode \''.$v_filename.'\'');
727 return false;
728 }
729
730 return true;
731 }
732 // }}}
733
734 // {{{ _openReadWrite()
735 function _openReadWrite()
736 {
737 if ($this->_compress_type == 'gz')
738 $this->_file = @gzopen($this->_tarname, "r+b");
739 else if ($this->_compress_type == 'bz2') {
740 $this->_error('Unable to open bz2 in read/write mode \''
741 .$this->_tarname.'\' (limitation of bz2 extension)');
742 return false;
743 } else if ($this->_compress_type == 'none')
744 $this->_file = @fopen($this->_tarname, "r+b");
745 else
746 $this->_error('Unknown or missing compression type ('
747 .$this->_compress_type.')');
748
749 if ($this->_file == 0) {
750 $this->_error('Unable to open in read/write mode \''
751 .$this->_tarname.'\'');
752 return false;
753 }
754
755 return true;
756 }
757 // }}}
758
759 // {{{ _close()
760 function _close()
761 {
762 //if (isset($this->_file)) {
763 if (is_resource($this->_file)) {
764 if ($this->_compress_type == 'gz')
765 @gzclose($this->_file);
766 else if ($this->_compress_type == 'bz2')
767 @bzclose($this->_file);
768 else if ($this->_compress_type == 'none')
769 @fclose($this->_file);
770 else
771 $this->_error('Unknown or missing compression type ('
772 .$this->_compress_type.')');
773
774 $this->_file = 0;
775 }
776
777 // ----- Look if a local copy need to be erase
778 // Note that it might be interesting to keep the url for a time : ToDo
779 if ($this->_temp_tarname != '') {
780 @drupal_unlink($this->_temp_tarname);
781 $this->_temp_tarname = '';
782 }
783
784 return true;
785 }
786 // }}}
787
788 // {{{ _cleanFile()
789 function _cleanFile()
790 {
791 $this->_close();
792
793 // ----- Look for a local copy
794 if ($this->_temp_tarname != '') {
795 // ----- Remove the local copy but not the remote tarname
796 @drupal_unlink($this->_temp_tarname);
797 $this->_temp_tarname = '';
798 } else {
799 // ----- Remove the local tarname file
800 @drupal_unlink($this->_tarname);
801 }
802 $this->_tarname = '';
803
804 return true;
805 }
806 // }}}
807
808 // {{{ _writeBlock()
809 function _writeBlock($p_binary_data, $p_len=null)
810 {
811 if (is_resource($this->_file)) {
812 if ($p_len === null) {
813 if ($this->_compress_type == 'gz')
814 @gzputs($this->_file, $p_binary_data);
815 else if ($this->_compress_type == 'bz2')
816 @bzwrite($this->_file, $p_binary_data);
817 else if ($this->_compress_type == 'none')
818 @fputs($this->_file, $p_binary_data);
819 else
820 $this->_error('Unknown or missing compression type ('
821 .$this->_compress_type.')');
822 } else {
823 if ($this->_compress_type == 'gz')
824 @gzputs($this->_file, $p_binary_data, $p_len);
825 else if ($this->_compress_type == 'bz2')
826 @bzwrite($this->_file, $p_binary_data, $p_len);
827 else if ($this->_compress_type == 'none')
828 @fputs($this->_file, $p_binary_data, $p_len);
829 else
830 $this->_error('Unknown or missing compression type ('
831 .$this->_compress_type.')');
832
833 }
834 }
835 return true;
836 }
837 // }}}
838
839 // {{{ _readBlock()
840 function _readBlock()
841 {
842 $v_block = null;
843 if (is_resource($this->_file)) {
844 if ($this->_compress_type == 'gz')
845 $v_block = @gzread($this->_file, 512);
846 else if ($this->_compress_type == 'bz2')
847 $v_block = @bzread($this->_file, 512);
848 else if ($this->_compress_type == 'none')
849 $v_block = @fread($this->_file, 512);
850 else
851 $this->_error('Unknown or missing compression type ('
852 .$this->_compress_type.')');
853 }
854 return $v_block;
855 }
856 // }}}
857
858 // {{{ _jumpBlock()
859 function _jumpBlock($p_len=null)
860 {
861 if (is_resource($this->_file)) {
862 if ($p_len === null)
863 $p_len = 1;
864
865 if ($this->_compress_type == 'gz') {
866 @gzseek($this->_file, gztell($this->_file)+($p_len*512));
867 }
868 else if ($this->_compress_type == 'bz2') {
869 // ----- Replace missing bztell() and bzseek()
870 for ($i=0; $i<$p_len; $i++)
871 $this->_readBlock();
872 } else if ($this->_compress_type == 'none')
873 @fseek($this->_file, ftell($this->_file)+($p_len*512));
874 else
875 $this->_error('Unknown or missing compression type ('
876 .$this->_compress_type.')');
877
878 }
879 return true;
880 }
881 // }}}
882
883 // {{{ _writeFooter()
884 function _writeFooter()
885 {
886 if (is_resource($this->_file)) {
887 // ----- Write the last 0 filled block for end of archive
888 $v_binary_data = pack('a1024', '');
889 $this->_writeBlock($v_binary_data);
890 }
891 return true;
892 }
893 // }}}
894
895 // {{{ _addList()
896 function _addList($p_list, $p_add_dir, $p_remove_dir)
897 {
898 $v_result=true;
899 $v_header = array();
900
901 // ----- Remove potential windows directory separator
902 $p_add_dir = $this->_translateWinPath($p_add_dir);
903 $p_remove_dir = $this->_translateWinPath($p_remove_dir, false);
904
905 if (!$this->_file) {
906 $this->_error('Invalid file descriptor');
907 return false;
908 }
909
910 if (sizeof($p_list) == 0)
911 return true;
912
913 foreach ($p_list as $v_filename) {
914 if (!$v_result) {
915 break;
916 }
917
918 // ----- Skip the current tar name
919 if ($v_filename == $this->_tarname)
920 continue;
921
922 if ($v_filename == '')
923 continue;
924
925 if (!file_exists($v_filename)) {
926 $this->_warning("File '$v_filename' does not exist");
927 continue;
928 }
929
930 // ----- Add the file or directory header
931 if (!$this->_addFile($v_filename, $v_header, $p_add_dir, $p_remove_dir))
932 return false;
933
934 if (@is_dir($v_filename) && !@is_link($v_filename)) {
935 if (!($p_hdir = opendir($v_filename))) {
936 $this->_warning("Directory '$v_filename' can not be read");
937 continue;
938 }
939 while (false !== ($p_hitem = readdir($p_hdir))) {
940 if (($p_hitem != '.') && ($p_hitem != '..')) {
941 if ($v_filename != ".")
942 $p_temp_list[0] = $v_filename.'/'.$p_hitem;
943 else
944 $p_temp_list[0] = $p_hitem;
945
946 $v_result = $this->_addList($p_temp_list,
947 $p_add_dir,
948 $p_remove_dir);
949 }
950 }
951
952 unset($p_temp_list);
953 unset($p_hdir);
954 unset($p_hitem);
955 }
956 }
957
958 return $v_result;
959 }
960 // }}}
961
962 // {{{ _addFile()
963 function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir)
964 {
965 if (!$this->_file) {
966 $this->_error('Invalid file descriptor');
967 return false;
968 }
969
970 if ($p_filename == '') {
971 $this->_error('Invalid file name');
972 return false;
973 }
974
975 // ----- Calculate the stored filename
976 $p_filename = $this->_translateWinPath($p_filename, false);;
977 $v_stored_filename = $p_filename;
978 if (strcmp($p_filename, $p_remove_dir) == 0) {
979 return true;
980 }
981 if ($p_remove_dir != '') {
982 if (substr($p_remove_dir, -1) != '/')
983 $p_remove_dir .= '/';
984
985 if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir)
986 $v_stored_filename = substr($p_filename, strlen($p_remove_dir));
987 }
988 $v_stored_filename = $this->_translateWinPath($v_stored_filename);
989 if ($p_add_dir != '') {
990 if (substr($p_add_dir, -1) == '/')
991 $v_stored_filename = $p_add_dir.$v_stored_filename;
992 else
993 $v_stored_filename = $p_add_dir.'/'.$v_stored_filename;
994 }
995
996 $v_stored_filename = $this->_pathReduction($v_stored_filename);
997
998 if ($this->_isArchive($p_filename)) {
999 if (($v_file = @fopen($p_filename, "rb")) == 0) {
1000 $this->_warning("Unable to open file '".$p_filename
1001 ."' in binary read mode");
1002 return true;
1003 }
1004
1005 if (!$this->_writeHeader($p_filename, $v_stored_filename))
1006 return false;
1007
1008 while (($v_buffer = fread($v_file, 512)) != '') {
1009 $v_binary_data = pack("a512", "$v_buffer");
1010 $this->_writeBlock($v_binary_data);
1011 }
1012
1013 fclose($v_file);
1014
1015 } else {
1016 // ----- Only header for dir
1017 if (!$this->_writeHeader($p_filename, $v_stored_filename))
1018 return false;
1019 }
1020
1021 return true;
1022 }
1023 // }}}
1024
1025 // {{{ _addString()
1026 function _addString($p_filename, $p_string)
1027 {
1028 if (!$this->_file) {
1029 $this->_error('Invalid file descriptor');
1030 return false;
1031 }
1032
1033 if ($p_filename == '') {
1034 $this->_error('Invalid file name');
1035 return false;
1036 }
1037
1038 // ----- Calculate the stored filename
1039 $p_filename = $this->_translateWinPath($p_filename, false);;
1040
1041 if (!$this->_writeHeaderBlock($p_filename, strlen($p_string),
1042 time(), 384, "", 0, 0))
1043 return false;
1044
1045 $i=0;
1046 while (($v_buffer = substr($p_string, (($i++)*512), 512)) != '') {
1047 $v_binary_data = pack("a512", $v_buffer);
1048 $this->_writeBlock($v_binary_data);
1049 }
1050
1051 return true;
1052 }
1053 // }}}
1054
1055 // {{{ _writeHeader()
1056 function _writeHeader($p_filename, $p_stored_filename)
1057 {
1058 if ($p_stored_filename == '')
1059 $p_stored_filename = $p_filename;
1060 $v_reduce_filename = $this->_pathReduction($p_stored_filename);
1061
1062 if (strlen($v_reduce_filename) > 99) {
1063 if (!$this->_writeLongHeader($v_reduce_filename))
1064 return false;
1065 }
1066
1067 $v_info = lstat($p_filename);
1068 $v_uid = sprintf("%6s ", DecOct($v_info[4]));
1069 $v_gid = sprintf("%6s ", DecOct($v_info[5]));
1070 $v_perms = sprintf("%6s ", DecOct($v_info['mode']));
1071
1072 $v_mtime = sprintf("%11s", DecOct($v_info['mode']));
1073
1074 $v_linkname = '';
1075
1076 if (@is_link($p_filename)) {
1077 $v_typeflag = '2';
1078 $v_linkname = readlink($p_filename);
1079 $v_size = sprintf("%11s ", DecOct(0));
1080 } elseif (@is_dir($p_filename)) {
1081 $v_typeflag = "5";
1082 $v_size = sprintf("%11s ", DecOct(0));
1083 } else {
1084 $v_typeflag = '';
1085 clearstatcache();
1086 $v_size = sprintf("%11s ", DecOct($v_info['size']));
1087 }
1088
1089 $v_magic = '';
1090
1091 $v_version = '';
1092
1093 $v_uname = '';
1094
1095 $v_gname = '';
1096
1097 $v_devmajor = '';
1098
1099 $v_devminor = '';
1100
1101 $v_prefix = '';
1102
1103 $v_binary_data_first = pack("a100a8a8a8a12A12",
1104 $v_reduce_filename, $v_perms, $v_uid,
1105 $v_gid, $v_size, $v_mtime);
1106 $v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12",
1107 $v_typeflag, $v_linkname, $v_magic,
1108 $v_version, $v_uname, $v_gname,
1109 $v_devmajor, $v_devminor, $v_prefix, '');
1110
1111 // ----- Calculate the checksum
1112 $v_checksum = 0;
1113 // ..... First part of the header
1114 for ($i=0; $i<148; $i++)
1115 $v_checksum += ord(substr($v_binary_data_first,$i,1));
1116 // ..... Ignore the checksum value and replace it by ' ' (space)
1117 for ($i=148; $i<156; $i++)
1118 $v_checksum += ord(' ');
1119 // ..... Last part of the header
1120 for ($i=156, $j=0; $i<512; $i++, $j++)
1121 $v_checksum += ord(substr($v_binary_data_last,$j,1));
1122
1123 // ----- Write the first 148 bytes of the header in the archive
1124 $this->_writeBlock($v_binary_data_first, 148);
1125
1126 // ----- Write the calculated checksum
1127 $v_checksum = sprintf("%6s ", DecOct($v_checksum));
1128 $v_binary_data = pack("a8", $v_checksum);
1129 $this->_writeBlock($v_binary_data, 8);
1130
1131 // ----- Write the last 356 bytes of the header in the archive
1132 $this->_writeBlock($v_binary_data_last, 356);
1133
1134 return true;
1135 }
1136 // }}}
1137
1138 // {{{ _writeHeaderBlock()
1139 function _writeHeaderBlock($p_filename, $p_size, $p_mtime=0, $p_perms=0,
1140 $p_type='', $p_uid=0, $p_gid=0)
1141 {
1142 $p_filename = $this->_pathReduction($p_filename);
1143
1144 if (strlen($p_filename) > 99) {
1145 if (!$this->_writeLongHeader($p_filename))
1146 return false;
1147 }
1148
1149 if ($p_type == "5") {
1150 $v_size = sprintf("%11s ", DecOct(0));
1151 } else {
1152 $v_size = sprintf("%11s ", DecOct($p_size));
1153 }
1154
1155 $v_uid = sprintf("%6s ", DecOct($p_uid));
1156 $v_gid = sprintf("%6s ", DecOct($p_gid));
1157 $v_perms = sprintf("%6s ", DecOct($p_perms));
1158
1159 $v_mtime = sprintf("%11s", DecOct($p_mtime));
1160
1161 $v_linkname = '';
1162
1163 $v_magic = '';
1164
1165 $v_version = '';
1166
1167 $v_uname = '';
1168
1169 $v_gname = '';
1170
1171 $v_devmajor = '';
1172
1173 $v_devminor = '';
1174
1175 $v_prefix = '';
1176
1177 $v_binary_data_first = pack("a100a8a8a8a12A12",
1178 $p_filename, $v_perms, $v_uid, $v_gid,
1179 $v_size, $v_mtime);
1180 $v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12",
1181 $p_type, $v_linkname, $v_magic,
1182 $v_version, $v_uname, $v_gname,
1183 $v_devmajor, $v_devminor, $v_prefix, '');
1184
1185 // ----- Calculate the checksum
1186 $v_checksum = 0;
1187 // ..... First part of the header
1188 for ($i=0; $i<148; $i++)
1189 $v_checksum += ord(substr($v_binary_data_first,$i,1));
1190 // ..... Ignore the checksum value and replace it by ' ' (space)
1191 for ($i=148; $i<156; $i++)
1192 $v_checksum += ord(' ');
1193 // ..... Last part of the header
1194 for ($i=156, $j=0; $i<512; $i++, $j++)
1195 $v_checksum += ord(substr($v_binary_data_last,$j,1));
1196
1197 // ----- Write the first 148 bytes of the header in the archive
1198 $this->_writeBlock($v_binary_data_first, 148);
1199
1200 // ----- Write the calculated checksum
1201 $v_checksum = sprintf("%6s ", DecOct($v_checksum));
1202 $v_binary_data = pack("a8", $v_checksum);
1203 $this->_writeBlock($v_binary_data, 8);
1204
1205 // ----- Write the last 356 bytes of the header in the archive
1206 $this->_writeBlock($v_binary_data_last, 356);
1207
1208 return true;
1209 }
1210 // }}}
1211
1212 // {{{ _writeLongHeader()
1213 function _writeLongHeader($p_filename)
1214 {
1215 $v_size = sprintf("%11s ", DecOct(strlen($p_filename)));
1216
1217 $v_typeflag = 'L';
1218
1219 $v_linkname = '';
1220
1221 $v_magic = '';
1222
1223 $v_version = '';
1224
1225 $v_uname = '';
1226
1227 $v_gname = '';
1228
1229 $v_devmajor = '';
1230
1231 $v_devminor = '';
1232
1233 $v_prefix = '';
1234
1235 $v_binary_data_first = pack("a100a8a8a8a12A12",
1236 '././@LongLink', 0, 0, 0, $v_size, 0);
1237 $v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12",
1238 $v_typeflag, $v_linkname, $v_magic,
1239 $v_version, $v_uname, $v_gname,
1240 $v_devmajor, $v_devminor, $v_prefix, '');
1241
1242 // ----- Calculate the checksum
1243 $v_checksum = 0;
1244 // ..... First part of the header
1245 for ($i=0; $i<148; $i++)
1246 $v_checksum += ord(substr($v_binary_data_first,$i,1));
1247 // ..... Ignore the checksum value and replace it by ' ' (space)
1248 for ($i=148; $i<156; $i++)
1249 $v_checksum += ord(' ');
1250 // ..... Last part of the header
1251 for ($i=156, $j=0; $i<512; $i++, $j++)
1252 $v_checksum += ord(substr($v_binary_data_last,$j,1));
1253
1254 // ----- Write the first 148 bytes of the header in the archive
1255 $this->_writeBlock($v_binary_data_first, 148);
1256
1257 // ----- Write the calculated checksum
1258 $v_checksum = sprintf("%6s ", DecOct($v_checksum));
1259 $v_binary_data = pack("a8", $v_checksum);
1260 $this->_writeBlock($v_binary_data, 8);
1261
1262 // ----- Write the last 356 bytes of the header in the archive
1263 $this->_writeBlock($v_binary_data_last, 356);
1264
1265 // ----- Write the filename as content of the block
1266 $i=0;
1267 while (($v_buffer = substr($p_filename, (($i++)*512), 512)) != '') {
1268 $v_binary_data = pack("a512", "$v_buffer");
1269 $this->_writeBlock($v_binary_data);
1270 }
1271
1272 return true;
1273 }
1274 // }}}
1275
1276 // {{{ _readHeader()
1277 function _readHeader($v_binary_data, &$v_header)
1278 {
1279 if (strlen($v_binary_data)==0) {
1280 $v_header['filename'] = '';
1281 return true;
1282 }
1283
1284 if (strlen($v_binary_data) != 512) {
1285 $v_header['filename'] = '';
1286 $this->_error('Invalid block size : '.strlen($v_binary_data));
1287 return false;
1288 }
1289
1290 if (!is_array($v_header)) {
1291 $v_header = array();
1292 }
1293 // ----- Calculate the checksum
1294 $v_checksum = 0;
1295 // ..... First part of the header
1296 for ($i=0; $i<148; $i++)
1297 $v_checksum+=ord(substr($v_binary_data,$i,1));
1298 // ..... Ignore the checksum value and replace it by ' ' (space)
1299 for ($i=148; $i<156; $i++)
1300 $v_checksum += ord(' ');
1301 // ..... Last part of the header
1302 for ($i=156; $i<512; $i++)
1303 $v_checksum+=ord(substr($v_binary_data,$i,1));
1304
1305 $v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/"
1306 ."a8checksum/a1typeflag/a100link/a6magic/a2version/"
1307 ."a32uname/a32gname/a8devmajor/a8devminor",
1308 $v_binary_data);
1309
1310 // ----- Extract the checksum
1311 $v_header['checksum'] = OctDec(trim($v_data['checksum']));
1312 if ($v_header['checksum'] != $v_checksum) {
1313 $v_header['filename'] = '';
1314
1315 // ----- Look for last block (empty block)
1316 if (($v_checksum == 256) && ($v_header['checksum'] == 0))
1317 return true;
1318
1319 $this->_error('Invalid checksum for file "'.$v_data['filename']
1320 .'" : '.$v_checksum.' calculated, '
1321 .$v_header['checksum'].' expected');
1322 return false;
1323 }
1324
1325 // ----- Extract the properties
1326 $v_header['filename'] = trim($v_data['filename']);
1327 if ($this->_maliciousFilename($v_header['filename'])) {
1328 $this->_error('Malicious .tar detected, file "' . $v_header['filename'] .
1329 '" will not install in desired directory tree');
1330 return false;
1331 }
1332 $v_header['mode'] = OctDec(trim($v_data['mode']));
1333 $v_header['uid'] = OctDec(trim($v_data['uid']));
1334 $v_header['gid'] = OctDec(trim($v_data['gid']));
1335 $v_header['size'] = OctDec(trim($v_data['size']));
1336 $v_header['mtime'] = OctDec(trim($v_data['mtime']));
1337 if (($v_header['typeflag'] = $v_data['typeflag']) == "5") {
1338 $v_header['size'] = 0;
1339 }
1340 $v_header['link'] = trim($v_data['link']);
1341 /* ----- All these fields are removed form the header because
1342 they do not carry interesting info
1343 $v_header[magic] = trim($v_data[magic]);
1344 $v_header[version] = trim($v_data[version]);
1345 $v_header[uname] = trim($v_data[uname]);
1346 $v_header[gname] = trim($v_data[gname]);
1347 $v_header[devmajor] = trim($v_data[devmajor]);
1348 $v_header[devminor] = trim($v_data[devminor]);
1349 */
1350
1351 return true;
1352 }
1353 // }}}
1354
1355 // {{{ _maliciousFilename()
1363 function _maliciousFilename($file)
1364 {
1365 if (strpos($file, '/../') !== false) {
1366 return true;
1367 }
1368 if (strpos($file, '../') === 0) {
1369 return true;
1370 }
1371 return false;
1372 }
1373 // }}}
1374
1375 // {{{ _readLongHeader()
1376 function _readLongHeader(&$v_header)
1377 {
1378 $v_filename = '';
1379 $n = floor($v_header['size']/512);
1380 for ($i=0; $i<$n; $i++) {
1381 $v_content = $this->_readBlock();
1382 $v_filename .= $v_content;
1383 }
1384 if (($v_header['size'] % 512) != 0) {
1385 $v_content = $this->_readBlock();
1386 $v_filename .= $v_content;
1387 }
1388
1389 // ----- Read the next header
1390 $v_binary_data = $this->_readBlock();
1391
1392 if (!$this->_readHeader($v_binary_data, $v_header))
1393 return false;
1394
1395 $v_filename = trim($v_filename);
1396 $v_header['filename'] = $v_filename;
1397 if ($this->_maliciousFilename($v_filename)) {
1398 $this->_error('Malicious .tar detected, file "' . $v_filename .
1399 '" will not install in desired directory tree');
1400 return false;
1401 }
1402
1403 return true;
1404 }
1405 // }}}
1406
1407 // {{{ _extractInString()
1415 function _extractInString($p_filename)
1416 {
1417 $v_result_str = "";
1418
1419 While (strlen($v_binary_data = $this->_readBlock()) != 0)
1420 {
1421 if (!$this->_readHeader($v_binary_data, $v_header))
1422 return NULL;
1423
1424 if ($v_header['filename'] == '')
1425 continue;
1426
1427 // ----- Look for long filename
1428 if ($v_header['typeflag'] == 'L') {
1429 if (!$this->_readLongHeader($v_header))
1430 return NULL;
1431 }
1432
1433 if ($v_header['filename'] == $p_filename) {
1434 if ($v_header['typeflag'] == "5") {
1435 $this->_error('Unable to extract in string a directory '
1436 .'entry {'.$v_header['filename'].'}');
1437 return NULL;
1438 } else {
1439 $n = floor($v_header['size']/512);
1440 for ($i=0; $i<$n; $i++) {
1441 $v_result_str .= $this->_readBlock();
1442 }
1443 if (($v_header['size'] % 512) != 0) {
1444 $v_content = $this->_readBlock();
1445 $v_result_str .= substr($v_content, 0,
1446 ($v_header['size'] % 512));
1447 }
1448 return $v_result_str;
1449 }
1450 } else {
1451 $this->_jumpBlock(ceil(($v_header['size']/512)));
1452 }
1453 }
1454
1455 return NULL;
1456 }
1457 // }}}
1458
1459 // {{{ _extractList()
1460 function _extractList($p_path, &$p_list_detail, $p_mode,
1461 $p_file_list, $p_remove_path)
1462 {
1463 $v_result=true;
1464 $v_nb = 0;
1465 $v_extract_all = true;
1466 $v_listing = false;
1467
1468 $p_path = $this->_translateWinPath($p_path, false);
1469 if ($p_path == '' || (substr($p_path, 0, 1) != '/'
1470 && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) {
1471 $p_path = "./".$p_path;
1472 }
1473 $p_remove_path = $this->_translateWinPath($p_remove_path);
1474
1475 // ----- Look for path to remove format (should end by /)
1476 if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/'))
1477 $p_remove_path .= '/';
1478 $p_remove_path_size = strlen($p_remove_path);
1479
1480 switch ($p_mode) {
1481 case "complete" :
1482 $v_extract_all = TRUE;
1483 $v_listing = FALSE;
1484 break;
1485 case "partial" :
1486 $v_extract_all = FALSE;
1487 $v_listing = FALSE;
1488 break;
1489 case "list" :
1490 $v_extract_all = FALSE;
1491 $v_listing = TRUE;
1492 break;
1493 default :
1494 $this->_error('Invalid extract mode ('.$p_mode.')');
1495 return false;
1496 }
1497
1498 clearstatcache();
1499
1500 while (strlen($v_binary_data = $this->_readBlock()) != 0)
1501 {
1502 $v_extract_file = FALSE;
1503 $v_extraction_stopped = 0;
1504
1505 if (!$this->_readHeader($v_binary_data, $v_header))
1506 return false;
1507
1508 if ($v_header['filename'] == '') {
1509 continue;
1510 }
1511
1512 // ----- Look for long filename
1513 if ($v_header['typeflag'] == 'L') {
1514 if (!$this->_readLongHeader($v_header))
1515 return false;
1516 }
1517
1518 if ((!$v_extract_all) && (is_array($p_file_list))) {
1519 // ----- By default no unzip if the file is not found
1520 $v_extract_file = false;
1521
1522 for ($i=0; $i<sizeof($p_file_list); $i++) {
1523 // ----- Look if it is a directory
1524 if (substr($p_file_list[$i], -1) == '/') {
1525 // ----- Look if the directory is in the filename path
1526 if ((strlen($v_header['filename']) > strlen($p_file_list[$i]))
1527 && (substr($v_header['filename'], 0, strlen($p_file_list[$i]))
1528 == $p_file_list[$i])) {
1529 $v_extract_file = TRUE;
1530 break;
1531 }
1532 }
1533
1534 // ----- It is a file, so compare the file names
1535 elseif ($p_file_list[$i] == $v_header['filename']) {
1536 $v_extract_file = TRUE;
1537 break;
1538 }
1539 }
1540 } else {
1541 $v_extract_file = TRUE;
1542 }
1543
1544 // ----- Look if this file need to be extracted
1545 if (($v_extract_file) && (!$v_listing))
1546 {
1547 if (($p_remove_path != '')
1548 && (substr($v_header['filename'], 0, $p_remove_path_size)
1549 == $p_remove_path))
1550 $v_header['filename'] = substr($v_header['filename'],
1551 $p_remove_path_size);
1552 if (($p_path != './') && ($p_path != '/')) {
1553 while (substr($p_path, -1) == '/')
1554 $p_path = substr($p_path, 0, strlen($p_path)-1);
1555
1556 if (substr($v_header['filename'], 0, 1) == '/')
1557 $v_header['filename'] = $p_path.$v_header['filename'];
1558 else
1559 $v_header['filename'] = $p_path.'/'.$v_header['filename'];
1560 }
1561 if (file_exists($v_header['filename'])) {
1562 if ( (@is_dir($v_header['filename']))
1563 && ($v_header['typeflag'] == '')) {
1564 $this->_error('File '.$v_header['filename']
1565 .' already exists as a directory');
1566 return false;
1567 }
1568 if ( ($this->_isArchive($v_header['filename']))
1569 && ($v_header['typeflag'] == "5")) {
1570 $this->_error('Directory '.$v_header['filename']
1571 .' already exists as a file');
1572 return false;
1573 }
1574 if (!is_writeable($v_header['filename'])) {
1575 $this->_error('File '.$v_header['filename']
1576 .' already exists and is write protected');
1577 return false;
1578 }
1579 if (filemtime($v_header['filename']) > $v_header['mtime']) {
1580 // To be completed : An error or silent no replace ?
1581 }
1582 }
1583
1584 // ----- Check the directory availability and create it if necessary
1585 elseif (($v_result
1586 = $this->_dirCheck(($v_header['typeflag'] == "5"
1587 ?$v_header['filename']
1588 :dirname($v_header['filename'])))) != 1) {
1589 $this->_error('Unable to create path for '.$v_header['filename']);
1590 return false;
1591 }
1592
1593 if ($v_extract_file) {
1594 if ($v_header['typeflag'] == "5") {
1595 if (!@file_exists($v_header['filename'])) {
1596 // Drupal integration.
1597 // Changed the code to use drupal_mkdir() instead of mkdir().
1598 if (!@drupal_mkdir($v_header['filename'], 0777)) {
1599 $this->_error('Unable to create directory {'
1600 .$v_header['filename'].'}');
1601 return false;
1602 }
1603 }
1604 } elseif ($v_header['typeflag'] == "2") {
1605 if (@file_exists($v_header['filename'])) {
1606 @drupal_unlink($v_header['filename']);
1607 }
1608 if (!@symlink($v_header['link'], $v_header['filename'])) {
1609 $this->_error('Unable to extract symbolic link {'
1610 .$v_header['filename'].'}');
1611 return false;
1612 }
1613 } else {
1614 if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) {
1615 $this->_error('Error while opening {'.$v_header['filename']
1616 .'} in write binary mode');
1617 return false;
1618 } else {
1619 $n = floor($v_header['size']/512);
1620 for ($i=0; $i<$n; $i++) {
1621 $v_content = $this->_readBlock();
1622 fwrite($v_dest_file, $v_content, 512);
1623 }
1624 if (($v_header['size'] % 512) != 0) {
1625 $v_content = $this->_readBlock();
1626 fwrite($v_dest_file, $v_content, ($v_header['size'] % 512));
1627 }
1628
1629 @fclose($v_dest_file);
1630
1631 // ----- Change the file mode, mtime
1632 @touch($v_header['filename'], $v_header['mtime']);
1633 if ($v_header['mode'] & 0111) {
1634 // make file executable, obey umask
1635 $mode = fileperms($v_header['filename']) | (~umask() & 0111);
1636 @chmod($v_header['filename'], $mode);
1637 }
1638 }
1639
1640 // ----- Check the file size
1641 clearstatcache();
1642 if (filesize($v_header['filename']) != $v_header['size']) {
1643 $this->_error('Extracted file '.$v_header['filename']
1644 .' does not have the correct file size \''
1645 .filesize($v_header['filename'])
1646 .'\' ('.$v_header['size']
1647 .' expected). Archive may be corrupted.');
1648 return false;
1649 }
1650 }
1651 } else {
1652 $this->_jumpBlock(ceil(($v_header['size']/512)));
1653 }
1654 } else {
1655 $this->_jumpBlock(ceil(($v_header['size']/512)));
1656 }
1657
1658 /* TBC : Seems to be unused ...
1659 if ($this->_compress)
1660 $v_end_of_file = @gzeof($this->_file);
1661 else
1662 $v_end_of_file = @feof($this->_file);
1663 */
1664
1665 if ($v_listing || $v_extract_file || $v_extraction_stopped) {
1666 // ----- Log extracted files
1667 if (($v_file_dir = dirname($v_header['filename']))
1668 == $v_header['filename'])
1669 $v_file_dir = '';
1670 if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == ''))
1671 $v_file_dir = '/';
1672
1673 $p_list_detail[$v_nb++] = $v_header;
1674 if (is_array($p_file_list) && (count($p_list_detail) == count($p_file_list))) {
1675 return true;
1676 }
1677 }
1678 }
1679
1680 return true;
1681 }
1682 // }}}
1683
1684 // {{{ _openAppend()
1685 function _openAppend()
1686 {
1687 if (filesize($this->_tarname) == 0)
1688 return $this->_openWrite();
1689
1690 if ($this->_compress) {
1691 $this->_close();
1692
1693 if (!@rename($this->_tarname, $this->_tarname.".tmp")) {
1694 $this->_error('Error while renaming \''.$this->_tarname
1695 .'\' to temporary file \''.$this->_tarname
1696 .'.tmp\'');
1697 return false;
1698 }
1699
1700 if ($this->_compress_type == 'gz')
1701 $v_temp_tar = @gzopen($this->_tarname.".tmp", "rb");
1702 elseif ($this->_compress_type == 'bz2')
1703 $v_temp_tar = @bzopen($this->_tarname.".tmp", "r");
1704
1705 if ($v_temp_tar == 0) {
1706 $this->_error('Unable to open file \''.$this->_tarname
1707 .'.tmp\' in binary read mode');
1708 @rename($this->_tarname.".tmp", $this->_tarname);
1709 return false;
1710 }
1711
1712 if (!$this->_openWrite()) {
1713 @rename($this->_tarname.".tmp", $this->_tarname);
1714 return false;
1715 }
1716
1717 if ($this->_compress_type == 'gz') {
1718 while (!@gzeof($v_temp_tar)) {
1719 $v_buffer = @gzread($v_temp_tar, 512);
1720 if ($v_buffer == ARCHIVE_TAR_END_BLOCK) {
1721 // do not copy end blocks, we will re-make them
1722 // after appending
1723 continue;
1724 }
1725 $v_binary_data = pack("a512", $v_buffer);
1726 $this->_writeBlock($v_binary_data);
1727 }
1728
1729 @gzclose($v_temp_tar);
1730 }
1731 elseif ($this->_compress_type == 'bz2') {
1732 while (strlen($v_buffer = @bzread($v_temp_tar, 512)) > 0) {
1733 if ($v_buffer == ARCHIVE_TAR_END_BLOCK) {
1734 continue;
1735 }
1736 $v_binary_data = pack("a512", $v_buffer);
1737 $this->_writeBlock($v_binary_data);
1738 }
1739
1740 @bzclose($v_temp_tar);
1741 }
1742
1743 if (!@drupal_unlink($this->_tarname.".tmp")) {
1744 $this->_error('Error while deleting temporary file \''
1745 .$this->_tarname.'.tmp\'');
1746 }
1747
1748 } else {
1749 // ----- For not compressed tar, just add files before the last
1750 // one or two 512 bytes block
1751 if (!$this->_openReadWrite())
1752 return false;
1753
1754 clearstatcache();
1755 $v_size = filesize($this->_tarname);
1756
1757 // We might have zero, one or two end blocks.
1758 // The standard is two, but we should try to handle
1759 // other cases.
1760 fseek($this->_file, $v_size - 1024);
1761 if (fread($this->_file, 512) == ARCHIVE_TAR_END_BLOCK) {
1762 fseek($this->_file, $v_size - 1024);
1763 }
1764 elseif (fread($this->_file, 512) == ARCHIVE_TAR_END_BLOCK) {
1765 fseek($this->_file, $v_size - 512);
1766 }
1767 }
1768
1769 return true;
1770 }
1771 // }}}
1772
1773 // {{{ _append()
1774 function _append($p_filelist, $p_add_dir='', $p_remove_dir='')
1775 {
1776 if (!$this->_openAppend())
1777 return false;
1778
1779 if ($this->_addList($p_filelist, $p_add_dir, $p_remove_dir))
1780 $this->_writeFooter();
1781
1782 $this->_close();
1783
1784 return true;
1785 }
1786 // }}}
1787
1788 // {{{ _dirCheck()
1789
1798 function _dirCheck($p_dir)
1799 {
1800 clearstatcache();
1801 if ((@is_dir($p_dir)) || ($p_dir == ''))
1802 return true;
1803
1804 $p_parent_dir = dirname($p_dir);
1805
1806 if (($p_parent_dir != $p_dir) &&
1807 ($p_parent_dir != '') &&
1808 (!$this->_dirCheck($p_parent_dir)))
1809 return false;
1810
1811 // Drupal integration.
1812 // Changed the code to use drupal_mkdir() instead of mkdir().
1813 if (!@drupal_mkdir($p_dir, 0777)) {
1814 $this->_error("Unable to create directory '$p_dir'");
1815 return false;
1816 }
1817
1818 return true;
1819 }
1820
1821 // }}}
1822
1823 // {{{ _pathReduction()
1824
1836 function _pathReduction($p_dir)
1837 {
1838 $v_result = '';
1839
1840 // ----- Look for not empty path
1841 if ($p_dir != '') {
1842 // ----- Explode path by directory names
1843 $v_list = explode('/', $p_dir);
1844
1845 // ----- Study directories from last to first
1846 for ($i=sizeof($v_list)-1; $i>=0; $i--) {
1847 // ----- Look for current path
1848 if ($v_list[$i] == ".") {
1849 // ----- Ignore this directory
1850 // Should be the first $i=0, but no check is done
1851 }
1852 else if ($v_list[$i] == "..") {
1853 // ----- Ignore it and ignore the $i-1
1854 $i--;
1855 }
1856 else if ( ($v_list[$i] == '')
1857 && ($i!=(sizeof($v_list)-1))
1858 && ($i!=0)) {
1859 // ----- Ignore only the double '//' in path,
1860 // but not the first and last /
1861 } else {
1862 $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?'/'
1863 .$v_result:'');
1864 }
1865 }
1866 }
1867 $v_result = strtr($v_result, '\\', '/');
1868 return $v_result;
1869 }
1870
1871 // }}}
1872
1873 // {{{ _translateWinPath()
1874 function _translateWinPath($p_path, $p_remove_disk_letter=true)
1875 {
1876 if (defined('OS_WINDOWS') && OS_WINDOWS) {
1877 // ----- Look for potential disk letter
1878 if ( ($p_remove_disk_letter)
1879 && (($v_position = strpos($p_path, ':')) != false)) {
1880 $p_path = substr($p_path, $v_position+1);
1881 }
1882 // ----- Change potential windows directory separator
1883 if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
1884 $p_path = strtr($p_path, '\\', '/');
1885 }
1886 }
1887 return $p_path;
1888 }
1889 // }}}
1890
1891 }
1892 ?>
Archive_Tar\_addList
_addList($p_list, $p_add_dir, $p_remove_dir)
Definition: system.tar.inc:896
Archive_Tar\extract
extract($p_path='')
Definition: system.tar.inc:269
Archive_Tar\_addString
_addString($p_filename, $p_string)
Definition: system.tar.inc:1026
Archive_Tar\_error
_error($p_message)
Definition: system.tar.inc:631
Archive_Tar\createModify
createModify($p_filelist, $p_add_dir, $p_remove_dir='')
Definition: system.tar.inc:328
Archive_Tar\extractList
extractList($p_filelist, $p_path='', $p_remove_path='')
Definition: system.tar.inc:552
drupal_unlink
drupal_unlink($uri, $context=NULL)
Definition: file.inc:2225
ARCHIVE_TAR_ATT_SEPARATOR
const ARCHIVE_TAR_ATT_SEPARATOR
Definition: system.tar.inc:46
Archive_Tar\_writeHeaderBlock
_writeHeaderBlock($p_filename, $p_size, $p_mtime=0, $p_perms=0, $p_type='', $p_uid=0, $p_gid=0)
Definition: system.tar.inc:1139
Archive_Tar\_jumpBlock
_jumpBlock($p_len=null)
Definition: system.tar.inc:859
Archive_Tar\__destruct
__destruct()
Definition: system.tar.inc:208
Archive_Tar\__construct
__construct($p_tarname, $p_compress=null)
Definition: system.tar.inc:105
Archive_Tar\_append
_append($p_filelist, $p_add_dir='', $p_remove_dir='')
Definition: system.tar.inc:1774
Archive_Tar\_openRead
_openRead()
Definition: system.tar.inc:683
Archive_Tar\listContent
listContent()
Definition: system.tar.inc:276
Archive_Tar\add
add($p_filelist)
Definition: system.tar.inc:262
Exception
Archive_Tar\_translateWinPath
_translateWinPath($p_path, $p_remove_disk_letter=true)
Definition: system.tar.inc:1874
Archive_Tar\_writeBlock
_writeBlock($p_binary_data, $p_len=null)
Definition: system.tar.inc:809
if
if(version_compare(PHP_VERSION, '5.2.4')< 0)
Definition: install.php:19
Archive_Tar\_maliciousFilename
_maliciousFilename($file)
Definition: system.tar.inc:1363
Archive_Tar\$_separator
$_separator
Definition: system.tar.inc:77
Archive_Tar\_extractInString
_extractInString($p_filename)
Definition: system.tar.inc:1415
Archive_Tar\_isArchive
_isArchive($p_filename=NULL)
Definition: system.tar.inc:649
Archive_Tar\$_temp_tarname
$_temp_tarname
Definition: system.tar.inc:87
Archive_Tar\loadExtension
loadExtension($ext)
Definition: system.tar.inc:179
Archive_Tar\_readLongHeader
_readLongHeader(&$v_header)
Definition: system.tar.inc:1376
Archive_Tar\create
create($p_filelist)
Definition: system.tar.inc:240
Archive_Tar\extractInString
extractInString($p_filename)
Definition: system.tar.inc:520
Archive_Tar\_dirCheck
_dirCheck($p_dir)
Definition: system.tar.inc:1798
Archive_Tar\_writeFooter
_writeFooter()
Definition: system.tar.inc:884
Archive_Tar\_extractList
_extractList($p_path, &$p_list_detail, $p_mode, $p_file_list, $p_remove_path)
Definition: system.tar.inc:1460
Archive_Tar\addModify
addModify($p_filelist, $p_add_dir, $p_remove_dir='')
Definition: system.tar.inc:400
Archive_Tar\$_tarname
$_tarname
Definition: system.tar.inc:62
Archive_Tar\_addFile
_addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir)
Definition: system.tar.inc:963
drupal_mkdir
drupal_mkdir($uri, $mode=NULL, $recursive=FALSE, $context=NULL)
Definition: file.inc:2359
Archive_Tar\$_compress
$_compress
Definition: system.tar.inc:67
Archive_Tar\_writeHeader
_writeHeader($p_filename, $p_stored_filename)
Definition: system.tar.inc:1056
Archive_Tar\_close
_close()
Definition: system.tar.inc:760
Archive_Tar\_writeLongHeader
_writeLongHeader($p_filename)
Definition: system.tar.inc:1213
Archive_Tar\extractModify
extractModify($p_path, $p_remove_path)
Definition: system.tar.inc:497
Archive_Tar\_pathReduction
_pathReduction($p_dir)
Definition: system.tar.inc:1836
Archive_Tar\$_compress_type
$_compress_type
Definition: system.tar.inc:72
Archive_Tar\_warning
_warning($p_message)
Definition: system.tar.inc:640
Archive_Tar
Definition: system.tar.inc:57
Archive_Tar\$_file
$_file
Definition: system.tar.inc:82
Archive_Tar\_readHeader
_readHeader($v_binary_data, &$v_header)
Definition: system.tar.inc:1277
Archive_Tar\_readBlock
_readBlock()
Definition: system.tar.inc:840
Archive_Tar\_openWrite
_openWrite()
Definition: system.tar.inc:660
Archive_Tar\_openReadWrite
_openReadWrite()
Definition: system.tar.inc:735
Archive_Tar\setAttribute
setAttribute()
Definition: system.tar.inc:585
Archive_Tar\addString
addString($p_filename, $p_string)
Definition: system.tar.inc:438
Archive_Tar\_openAppend
_openAppend()
Definition: system.tar.inc:1685
ARCHIVE_TAR_END_BLOCK
const ARCHIVE_TAR_END_BLOCK
Definition: system.tar.inc:47
Archive_Tar\_cleanFile
_cleanFile()
Definition: system.tar.inc:789
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/theming_example/theming_example.module Source File

  • examples
  • theming_example
theming_example.module
Go to the documentation of this file.
1 <?php
2
74 function theming_example_menu() {
75 $items['examples/theming_example'] = array(
76 'title' => 'Theming Example',
77 'description' => 'Some theming examples.',
78 'page callback' => 'theming_example_page',
79 'access callback' => TRUE,
80 'access arguments' => array('access content'),
81 );
82 $items['examples/theming_example/theming_example_list_page'] = array(
83 'title' => 'Theming a list',
84 'page callback' => 'theming_example_list_page',
85 'access arguments' => array('access content'),
86 'weight' => 1,
87 );
88 $items['examples/theming_example/theming_example_select_form'] = array(
89 'title' => 'Theming a form (select form)',
90 'page callback' => 'drupal_get_form',
91 'page arguments' => array('theming_example_select_form'),
92 'access arguments' => array('access content'),
93 'weight' => 2,
94 );
95 $items['examples/theming_example/theming_example_text_form'] = array(
96 'title' => 'Theming a form (text form)',
97 'page callback' => 'drupal_get_form',
98 'page arguments' => array('theming_example_text_form'),
99 'access arguments' => array('access content'),
100 'weight' => 3,
101 );
102
103 return $items;
104
105 }
106
112 function theming_example_theme() {
113 return array(
114 'theming_example_content_array' => array(
115 // We use 'render element' when the item to be passed is a self-describing
116 // render array (it will have #theme_wrappers)
117 'render element' => 'element',
118 ),
119 'theming_example_list' => array(
120 // We use 'variables' when the item to be passed is an array whose
121 // structure must be described here.
122 'variables' => array(
123 'title' => NULL,
124 'items' => NULL,
125 ),
126 ),
127 'theming_example_select_form' => array(
128 'render element' => 'form',
129 ),
130 'theming_example_text_form' => array(
131 'render element' => 'form',
132 // In this one the rendering will be done by a template file
133 // (theming-example-text-form.tpl.php) instead of being rendered by a
134 // function. Note the use of dashes to separate words in place of
135 // underscores. The template file's extension is also left out so that
136 // it may be determined automatically depending on the template engine
137 // the site is using.
138 'template' => 'theming-example-text-form',
139 ),
140 );
141 }
153 function theming_example_page() {
154 $content[] = t('Some examples of pages and forms that are run through theme functions.');
155 $content[] = l(t('Simple page with a list'), 'examples/theming_example/theming_example_list_page');
156 $content[] = l(t('Simple form 1'), 'examples/theming_example/theming_example_select_form');
157 $content[] = l(t('Simple form 2'), 'examples/theming_example/theming_example_text_form');
158 $content['#theme_wrappers'] = array('theming_example_content_array');
159 return $content;
160 }
161
169 function theming_example_list_page() {
170 $items = array(
171 t('First item'),
172 t('Second item'),
173 t('Third item'),
174 t('Fourth item'),
175 );
176
177 // First we'll create a render array that simply uses theme_item_list.
178 $title = t("A list returned to be rendered using theme('item_list')");
179 $build['render_version'] = array(
180 // We use #theme here instead of #theme_wrappers because theme_item_list()
181 // is the classic type of theme function that does not just assume a
182 // render array, but instead has its own properties (#type, #title, #items).
183 '#theme' => 'item_list',
184 // '#type' => 'ul', // The default type is 'ul'
185 // We can easily make sure that a css or js file is present using #attached.
186 '#attached' => array('css' => array(drupal_get_path('module', 'theming_example') . '/theming_example.css')),
187 '#title' => $title,
188 '#items' => $items,
189 '#attributes' => array('class' => array('render-version-list'))
190 );
191
192 // Now we'll create a render array which uses our own list formatter,
193 // theme('theming_example_list').
194 $title = t("The same list rendered by theme('theming_example_list')");
195 $build['our_theme_function'] = array(
196 '#theme' => 'theming_example_list',
197 '#attached' => array('css' => array(drupal_get_path('module', 'theming_example') . '/theming_example.css')),
198 '#title' => $title,
199 '#items' => $items,
200 );
201 return $build;
202 }
203
204
211 function theming_example_select_form($form, &$form_state) {
212 $options = array(
213 'newest_first' => t('Newest first'),
214 'newest_last' => t('Newest last'),
215 'edited_first' => t('Edited first'),
216 'edited_last' => t('Edited last'),
217 'by_name' => t('By name'),
218 );
219 $form['choice'] = array(
220 '#type' => 'select',
221 '#options' => $options,
222 '#title' => t('Choose which ordering you want'),
223 );
224 $form['submit'] = array(
225 '#type' => 'submit',
226 '#value' => t('Go'),
227 );
228 return $form;
229 }
230 function theming_example_select_form_submit($form, &$form_state) {
231 drupal_set_message(t('You chose %input', array('%input' => $form_state['values']['choice'])));
232 }
233
240 function theming_example_text_form($form, &$form_state) {
241 $form['text'] = array(
242 '#type' => 'textfield',
243 '#title' => t('Please input something!'),
244 '#required' => TRUE,
245 );
246 $form['submit'] = array(
247 '#type' => 'submit',
248 '#value' => t('Go'),
249 );
250 return $form;
251 }
252 function theming_example_text_form_submit($form, &$form_state) {
253 drupal_set_message(t('You entered %input', array('%input' => $form_state['values']['text'])));
254 }
255
256
263 function theme_theming_example_content_array($variables) {
264 $element = $variables['element'];
265 $output = '';
266 foreach (element_children($element) AS $count) {
267 if (! $count) {
268 // The first paragraph is bolded.
269 $output .= '<p><strong>' . $element[$count] . '</strong></p>';
270 }
271 else {
272 // Following paragraphs are just output as routine paragraphs.
273 $output .= '<p>' . $element[$count] . '</p>';
274 }
275 }
276 return $output;
277 }
278
287 function theme_theming_example_list($variables) {
288 $title = $variables['title'];
289 $items = $variables['items'];
290
291 // Add the title to the list theme and
292 // state the list type. This defaults to 'ul'.
293 // Add a css class so that you can modify the list styling.
294 // We'll just call theme('item_list') to render.
295
296 $variables = array(
297 'items' => $items,
298 'title' => $title,
299 'type' => 'ol',
300 'attributes' => array('class' => 'theming-example-list'),
301 );
302 $output = theme('item_list', $variables);
303 return $output;
304 }
305
317 function theme_theming_example_select_form($variables) {
318 $form = $variables['form'];
319 $title = $form['choice']['#title'];
320 $form['choice']['#title'] = '';
321 $output = '<strong>' . $title . '</strong>';
322 $form['choice']['#prefix'] = '<div class="container-inline">';
323 $form['submit']['#suffix'] = '</div>';
324 $output .= drupal_render_children($form);
325 return $output;
326 }
327
340 function template_preprocess_theming_example_text_form(&$variables) {
341 $variables['text_form_content'] = array();
342 $text_form_hidden = array();
343
344 // Each form element is rendered and saved as a key in $text_form_content, to
345 // give the themer the power to print each element independently in the
346 // template file. Hidden form elements have no value in the theme, so they
347 // are grouped into a single element.
348 foreach (element_children($variables['form']) as $key) {
349 $type = $variables['form'][$key]['#type'];
350 if ($type == 'hidden' || $type == 'token') {
351 $text_form_hidden[] = drupal_render($variables['form'][$key]);
352 }
353 else {
354 $variables['text_form_content'][$key] = drupal_render($variables['form'][$key]);
355 }
356 }
357 $variables['text_form_content']['hidden'] = implode($text_form_hidden);
358
359 // The entire form is then saved in the $text_form variable, to make it easy
360 // for the themer to print the whole form.
361 $variables['text_form'] = implode($variables['text_form_content']);
362 }
theme_theming_example_list
theme_theming_example_list($variables)
Definition: theming_example.module:287
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
theming_example_list_page
theming_example_list_page()
Definition: theming_example.module:169
theming_example_menu
theming_example_menu()
Definition: theming_example.module:74
theming_example_select_form
theming_example_select_form($form, &$form_state)
Definition: theming_example.module:211
theme_theming_example_select_form
theme_theming_example_select_form($variables)
Definition: theming_example.module:317
theming_example_theme
theming_example_theme()
Definition: theming_example.module:112
theming_example_text_form
theming_example_text_form($form, &$form_state)
Definition: theming_example.module:240
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
theming_example_text_form_submit
theming_example_text_form_submit($form, &$form_state)
Definition: theming_example.module:252
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
$output
$output
Definition: authorize.php:93
theming_example_select_form_submit
theming_example_select_form_submit($form, &$form_state)
Definition: theming_example.module:230
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
template_preprocess_theming_example_text_form
template_preprocess_theming_example_text_form(&$variables)
Definition: theming_example.module:340
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
theme_theming_example_content_array
theme_theming_example_content_array($variables)
Definition: theming_example.module:263
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
theming_example_page
theming_example_page()
Definition: theming_example.module:153
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/filetransfer/ftp.inc Source File

  • includes
  • filetransfer
ftp.inc
Go to the documentation of this file.
1 <?php
2
6 abstract class FileTransferFTP extends FileTransfer {
7
8 public function __construct($jail, $username, $password, $hostname, $port) {
9 $this->username = $username;
10 $this->password = $password;
11 $this->hostname = $hostname;
12 $this->port = $port;
13 parent::__construct($jail);
14 }
15
25 static function factory($jail, $settings) {
26 $username = empty($settings['username']) ? '' : $settings['username'];
27 $password = empty($settings['password']) ? '' : $settings['password'];
28 $hostname = empty($settings['advanced']['hostname']) ? 'localhost' : $settings['advanced']['hostname'];
29 $port = empty($settings['advanced']['port']) ? 21 : $settings['advanced']['port'];
30
31 if (function_exists('ftp_connect')) {
32 $class = 'FileTransferFTPExtension';
33 }
34 else {
35 throw new FileTransferException('No FTP backend available.');
36 }
37
38 return new $class($jail, $username, $password, $hostname, $port);
39 }
40
44 public function getSettingsForm() {
45 $form = parent::getSettingsForm();
46 $form['advanced']['port']['#default_value'] = 21;
47 return $form;
48 }
49 }
50
51 class FileTransferFTPExtension extends FileTransferFTP implements FileTransferChmodInterface {
52
53 public function connect() {
54 $this->connection = ftp_connect($this->hostname, $this->port);
55
56 if (!$this->connection) {
57 throw new FileTransferException("Cannot connect to FTP Server, check settings");
58 }
59 if (!ftp_login($this->connection, $this->username, $this->password)) {
60 throw new FileTransferException("Cannot log in to FTP server. Check username and password");
61 }
62 }
63
64 protected function copyFileJailed($source, $destination) {
65 if (!@ftp_put($this->connection, $destination, $source, FTP_BINARY)) {
66 throw new FileTransferException("Cannot move @source to @destination", NULL, array("@source" => $source, "@destination" => $destination));
67 }
68 }
69
70 protected function createDirectoryJailed($directory) {
71 if (!ftp_mkdir($this->connection, $directory)) {
72 throw new FileTransferException("Cannot create directory @directory", NULL, array("@directory" => $directory));
73 }
74 }
75
76 protected function removeDirectoryJailed($directory) {
77 $pwd = ftp_pwd($this->connection);
78 if (!ftp_chdir($this->connection, $directory)) {
79 throw new FileTransferException("Unable to change to directory @directory", NULL, array('@directory' => $directory));
80 }
81 $list = @ftp_nlist($this->connection, '.');
82 if (!$list) {
83 $list = array();
84 }
85 foreach ($list as $item) {
86 if ($item == '.' || $item == '..') {
87 continue;
88 }
89 if (@ftp_chdir($this->connection, $item)) {
90 ftp_cdup($this->connection);
91 $this->removeDirectory(ftp_pwd($this->connection) . '/' . $item);
92 }
93 else {
94 $this->removeFile(ftp_pwd($this->connection) . '/' . $item);
95 }
96 }
97 ftp_chdir($this->connection, $pwd);
98 if (!ftp_rmdir($this->connection, $directory)) {
99 throw new FileTransferException("Unable to remove to directory @directory", NULL, array('@directory' => $directory));
100 }
101 }
102
103 protected function removeFileJailed($destination) {
104 if (!ftp_delete($this->connection, $destination)) {
105 throw new FileTransferException("Unable to remove to file @file", NULL, array('@file' => $destination));
106 }
107 }
108
109 public function isDirectory($path) {
110 $result = FALSE;
111 $curr = ftp_pwd($this->connection);
112 if (@ftp_chdir($this->connection, $path)) {
113 $result = TRUE;
114 }
115 ftp_chdir($this->connection, $curr);
116 return $result;
117 }
118
119 public function isFile($path) {
120 return ftp_size($this->connection, $path) != -1;
121 }
122
123 function chmodJailed($path, $mode, $recursive) {
124 if (!ftp_chmod($this->connection, $mode, $path)) {
125 throw new FileTransferException("Unable to set permissions on %file", NULL, array('%file' => $path));
126 }
127 if ($this->isDirectory($path) && $recursive) {
128 $filelist = @ftp_nlist($this->connection, $path);
129 if (!$filelist) {
130 //empty directory - returns false
131 return;
132 }
133 foreach ($filelist as $file) {
134 $this->chmodJailed($file, $mode, $recursive);
135 }
136 }
137 }
138 }
139
140 if (!function_exists('ftp_chmod')) {
141 function ftp_chmod($ftp_stream, $mode, $filename) {
142 return ftp_site($ftp_stream, sprintf('CHMOD %o %s', $mode, $filename));
143 }
144 }
FileTransferFTPExtension\createDirectoryJailed
createDirectoryJailed($directory)
Definition: ftp.inc:70
FileTransferFTPExtension\isFile
isFile($path)
Definition: ftp.inc:119
FileTransferException
Definition: filetransfer.inc:363
FileTransfer\$password
$password
Definition: filetransfer.inc:14
FileTransferFTP\__construct
__construct($jail, $username, $password, $hostname, $port)
Definition: ftp.inc:8
FileTransfer
Definition: filetransfer.inc:12
FileTransferFTPExtension\removeDirectoryJailed
removeDirectoryJailed($directory)
Definition: ftp.inc:76
FileTransferFTPExtension\isDirectory
isDirectory($path)
Definition: ftp.inc:109
FileTransferChmodInterface
Definition: filetransfer.inc:376
FileTransferFTPExtension
Definition: ftp.inc:51
FileTransfer\removeFile
removeFile($destination)
Definition: filetransfer.inc:145
FileTransfer\$port
$port
Definition: filetransfer.inc:16
FileTransfer\$hostname
$hostname
Definition: filetransfer.inc:15
FileTransferFTPExtension\connect
connect()
Definition: ftp.inc:53
FileTransferFTP\getSettingsForm
getSettingsForm()
Definition: ftp.inc:44
FileTransfer\$username
$username
Definition: filetransfer.inc:13
FileTransferFTP
Definition: ftp.inc:6
FileTransferFTPExtension\copyFileJailed
copyFileJailed($source, $destination)
Definition: ftp.inc:64
FileTransferFTP\factory
static factory($jail, $settings)
Definition: ftp.inc:25
FileTransferFTPExtension\chmodJailed
chmodJailed($path, $mode, $recursive)
Definition: ftp.inc:123
FileTransfer\removeDirectory
removeDirectory($directory)
Definition: filetransfer.inc:118
FileTransferFTPExtension\removeFileJailed
removeFileJailed($destination)
Definition: ftp.inc:103
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module Source File

  • profiles
  • testing
  • modules
  • drupal_system_listing_incompatible_test
drupal_system_listing_incompatible_test.module
Go to the documentation of this file.
1 <?php
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user-picture.tpl.php Source File

  • modules
  • user
user-picture.tpl.php
Go to the documentation of this file.
1 <?php
2
18 ?>
19 <?php if ($user_picture): ?>
20 <div class="user-picture">
21 <?php print $user_picture; ?>
22 </div>
23 <?php endif; ?>
$user_picture
print $user_picture
Definition: node.tpl.php:85
print
print
Definition: php-2.php:2
endif
endif
Definition: aggregator-item.tpl.php:31
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/file/file.module Source File

  • modules
  • file
file.module
Go to the documentation of this file.
1 <?php
2
8 // Load all Field module hooks for File.
9 require_once DRUPAL_ROOT . '/modules/file/file.field.inc';
10
14 function file_help($path, $arg) {
15 switch ($path) {
16 case 'admin/help#file':
17 $output = '';
18 $output .= '<h3>' . t('About') . '</h3>';
19 $output .= '<p>' . t('The File module defines a <em>File</em> field type for the Field module, which lets you manage and validate uploaded files attached to content on your site (see the <a href="@field-help">Field module help page</a> for more information about fields). For more information, see the online handbook entry for <a href="@file">File module</a>.', array('@field-help' => url('admin/help/field'), '@file' => 'http://drupal.org/documentation/modules/file')) . '</p>';
20 $output .= '<h3>' . t('Uses') . '</h3>';
21 $output .= '<dl>';
22 $output .= '<dt>' . t('Attaching files to content') . '</dt>';
23 $output .= '<dd>' . t('The File module allows users to attach files to content (e.g., PDF files, spreadsheets, etc.), when a <em>File</em> field is added to a given content type using the <a href="@fieldui-help">Field UI module</a>. You can add validation options to your File field, such as specifying a maximum file size and allowed file extensions.', array('@fieldui-help' => url('admin/help/field_ui'))) . '</dd>';
24 $output .= '<dt>' . t('Managing attachment display') . '</dt>';
25 $output .= '<dd>' . t('When you attach a file to content, you can specify whether it is <em>listed</em> or not. Listed files are displayed automatically in a section at the bottom of your content; non-listed files are available for embedding in your content, but are not included in the list at the bottom.') . '</dd>';
26 $output .= '<dt>' . t('Managing file locations') . '</dt>';
27 $output .= '<dd>' . t("When you create a File field, you can specify a directory where the files will be stored, which can be within either the <em>public</em> or <em>private</em> files directory. Files in the public directory can be accessed directly through the web server; when public files are listed, direct links to the files are used, and anyone who knows a file's URL can download the file. Files in the private directory are not accessible directly through the web server; when private files are listed, the links are Drupal path requests. This adds to server load and download time, since Drupal must start up and resolve the path for each file download request, but allows for access restrictions.") . '</dd>';
28 $output .= '</dl>';
29 return $output;
30 }
31 }
32
36 function file_menu() {
37 $items = array();
38
39 $items['file/ajax'] = array(
40 'page callback' => 'file_ajax_upload',
41 'delivery callback' => 'ajax_deliver',
42 'access arguments' => array('access content'),
43 'theme callback' => 'ajax_base_page_theme',
44 'type' => MENU_CALLBACK,
45 );
46 $items['file/progress'] = array(
47 'page callback' => 'file_ajax_progress',
48 'access arguments' => array('access content'),
49 'theme callback' => 'ajax_base_page_theme',
50 'type' => MENU_CALLBACK,
51 );
52
53 return $items;
54 }
55
61 function file_element_info() {
62 $file_path = drupal_get_path('module', 'file');
63 $types['managed_file'] = array(
64 '#input' => TRUE,
65 '#process' => array('file_managed_file_process'),
66 '#value_callback' => 'file_managed_file_value',
67 '#element_validate' => array('file_managed_file_validate'),
68 '#pre_render' => array('file_managed_file_pre_render'),
69 '#theme' => 'file_managed_file',
70 '#theme_wrappers' => array('form_element'),
71 '#progress_indicator' => 'throbber',
72 '#progress_message' => NULL,
73 '#upload_validators' => array(),
74 '#upload_location' => NULL,
75 '#size' => 22,
76 '#extended' => FALSE,
77 '#attached' => array(
78 'css' => array($file_path . '/file.css'),
79 'js' => array($file_path . '/file.js'),
80 ),
81 );
82 return $types;
83 }
84
88 function file_theme() {
89 return array(
90 // file.module.
91 'file_link' => array(
92 'variables' => array('file' => NULL, 'icon_directory' => NULL),
93 ),
94 'file_icon' => array(
95 'variables' => array('file' => NULL, 'icon_directory' => NULL),
96 ),
97 'file_managed_file' => array(
98 'render element' => 'element',
99 ),
100
101 // file.field.inc.
102 'file_widget' => array(
103 'render element' => 'element',
104 ),
105 'file_widget_multiple' => array(
106 'render element' => 'element',
107 ),
108 'file_formatter_table' => array(
109 'variables' => array('items' => NULL),
110 ),
111 'file_upload_help' => array(
112 'variables' => array('description' => NULL, 'upload_validators' => NULL),
113 ),
114 );
115 }
116
123 function file_file_download($uri, $field_type = 'file') {
124 global $user;
125
126 // Get the file record based on the URI. If not in the database just return.
127 $files = file_load_multiple(array(), array('uri' => $uri));
128 if (count($files)) {
129 foreach ($files as $item) {
130 // Since some database servers sometimes use a case-insensitive comparison
131 // by default, double check that the filename is an exact match.
132 if ($item->uri === $uri) {
133 $file = $item;
134 break;
135 }
136 }
137 }
138 if (!isset($file)) {
139 return;
140 }
141
142 // Find out which (if any) fields of this type contain the file.
143 $references = file_get_file_references($file, NULL, FIELD_LOAD_CURRENT, $field_type);
144
145 // Stop processing if there are no references in order to avoid returning
146 // headers for files controlled by other modules. Make an exception for
147 // temporary files where the host entity has not yet been saved (for example,
148 // an image preview on a node/add form) in which case, allow download by the
149 // file's owner.
150 if (empty($references) && ($file->status == FILE_STATUS_PERMANENT || $file->uid != $user->uid)) {
151 return;
152 }
153
154 // Default to allow access.
155 $denied = FALSE;
156 // Loop through all references of this file. If a reference explicitly allows
157 // access to the field to which this file belongs, no further checks are done
158 // and download access is granted. If a reference denies access, eventually
159 // existing additional references are checked. If all references were checked
160 // and no reference denied access, access is granted as well. If at least one
161 // reference denied access, access is denied.
162 foreach ($references as $field_name => $field_references) {
163 foreach ($field_references as $entity_type => $type_references) {
164 foreach ($type_references as $id => $reference) {
165 // Try to load $entity and $field.
166 $entity = entity_load($entity_type, array($id));
167 $entity = reset($entity);
168 $field = field_info_field($field_name);
169
170 // Load the field item that references the file.
171 $field_item = NULL;
172 if ($entity) {
173 // Load all field items for that entity.
174 $field_items = field_get_items($entity_type, $entity, $field_name);
175
176 // Find the field item with the matching URI.
177 foreach ($field_items as $item) {
178 if ($item['uri'] == $uri) {
179 $field_item = $item;
180 break;
181 }
182 }
183 }
184
185 // Check that $entity, $field and $field_item were loaded successfully
186 // and check if access to that field is not disallowed. If any of these
187 // checks fail, stop checking access for this reference.
188 if (empty($entity) || empty($field) || empty($field_item) || !field_access('view', $field, $entity_type, $entity)) {
189 $denied = TRUE;
190 break;
191 }
192
193 // Invoke hook and collect grants/denies for download access.
194 // Default to FALSE and let entities overrule this ruling.
195 $grants = array('system' => FALSE);
196 foreach (module_implements('file_download_access') as $module) {
197 $grants = array_merge($grants, array($module => module_invoke($module, 'file_download_access', $field_item, $entity_type, $entity)));
198 }
199 // Allow other modules to alter the returned grants/denies.
200 drupal_alter('file_download_access', $grants, $field_item, $entity_type, $entity);
201
202 if (in_array(TRUE, $grants)) {
203 // If TRUE is returned, access is granted and no further checks are
204 // necessary.
205 $denied = FALSE;
206 break 3;
207 }
208
209 if (in_array(FALSE, $grants)) {
210 // If an implementation returns FALSE, access to this entity is denied
211 // but the file could belong to another entity to which the user might
212 // have access. Continue with these.
213 $denied = TRUE;
214 }
215 }
216 }
217 }
218
219 // Access specifically denied.
220 if ($denied) {
221 return -1;
222 }
223
224 // Access is granted.
225 $headers = file_get_content_headers($file);
226 return $headers;
227 }
228
237 function file_ajax_upload() {
238 $form_parents = func_get_args();
239 $form_build_id = (string) array_pop($form_parents);
240
241 if (empty($_POST['form_build_id']) || $form_build_id != $_POST['form_build_id']) {
242 // Invalid request.
243 drupal_set_message(t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', array('@size' => format_size(file_upload_max_size()))), 'error');
244 $commands = array();
245 $commands[] = ajax_command_replace(NULL, theme('status_messages'));
246 return array('#type' => 'ajax', '#commands' => $commands);
247 }
248
249 list($form, $form_state) = ajax_get_form();
250
251 if (!$form) {
252 // Invalid form_build_id.
253 drupal_set_message(t('An unrecoverable error occurred. Use of this form has expired. Try reloading the page and submitting again.'), 'error');
254 $commands = array();
255 $commands[] = ajax_command_replace(NULL, theme('status_messages'));
256 return array('#type' => 'ajax', '#commands' => $commands);
257 }
258
259 // Get the current element and count the number of files.
260 $current_element = $form;
261 foreach ($form_parents as $parent) {
262 $current_element = $current_element[$parent];
263 }
264 $current_file_count = isset($current_element['#file_upload_delta']) ? $current_element['#file_upload_delta'] : 0;
265
266 // Process user input. $form and $form_state are modified in the process.
267 drupal_process_form($form['#form_id'], $form, $form_state);
268
269 // Retrieve the element to be rendered.
270 foreach ($form_parents as $parent) {
271 $form = $form[$parent];
272 }
273
274 // Add the special Ajax class if a new file was added.
275 if (isset($form['#file_upload_delta']) && $current_file_count < $form['#file_upload_delta']) {
276 $form[$current_file_count]['#attributes']['class'][] = 'ajax-new-content';
277 }
278 // Otherwise just add the new content class on a placeholder.
279 else {
280 $form['#suffix'] .= '<span class="ajax-new-content"></span>';
281 }
282
283 $output = theme('status_messages') . drupal_render($form);
284 $js = drupal_add_js();
285 $settings = call_user_func_array('array_merge_recursive', $js['settings']['data']);
286
287 $commands = array();
288 $commands[] = ajax_command_replace(NULL, $output, $settings);
289 return array('#type' => 'ajax', '#commands' => $commands);
290 }
291
298 function file_ajax_progress($key) {
299 $progress = array(
300 'message' => t('Starting upload...'),
301 'percentage' => -1,
302 );
303
304 $implementation = file_progress_implementation();
305 if ($implementation == 'uploadprogress') {
306 $status = uploadprogress_get_info($key);
307 if (isset($status['bytes_uploaded']) && !empty($status['bytes_total'])) {
308 $progress['message'] = t('Uploading... (@current of @total)', array('@current' => format_size($status['bytes_uploaded']), '@total' => format_size($status['bytes_total'])));
309 $progress['percentage'] = round(100 * $status['bytes_uploaded'] / $status['bytes_total']);
310 }
311 }
312 elseif ($implementation == 'apc') {
313 $status = apc_fetch('upload_' . $key);
314 if (isset($status['current']) && !empty($status['total'])) {
315 $progress['message'] = t('Uploading... (@current of @total)', array('@current' => format_size($status['current']), '@total' => format_size($status['total'])));
316 $progress['percentage'] = round(100 * $status['current'] / $status['total']);
317 }
318 }
319
320 drupal_json_output($progress);
321 }
322
330 function file_progress_implementation() {
331 static $implementation;
332 if (!isset($implementation)) {
333 $implementation = FALSE;
334
335 // We prefer the PECL extension uploadprogress because it supports multiple
336 // simultaneous uploads. APC only supports one at a time.
337 if (extension_loaded('uploadprogress')) {
338 $implementation = 'uploadprogress';
339 }
340 elseif (extension_loaded('apc') && ini_get('apc.rfc1867')) {
341 $implementation = 'apc';
342 }
343 }
344 return $implementation;
345 }
346
350 function file_file_delete($file) {
351 // TODO: Remove references to a file that is in-use.
352 }
353
360 function file_managed_file_process($element, &$form_state, $form) {
361 $fid = isset($element['#value']['fid']) ? $element['#value']['fid'] : 0;
362
363 // Set some default element properties.
364 $element['#progress_indicator'] = empty($element['#progress_indicator']) ? 'none' : $element['#progress_indicator'];
365 $element['#file'] = $fid ? file_load($fid) : FALSE;
366 $element['#tree'] = TRUE;
367
368 $ajax_settings = array(
369 'path' => 'file/ajax/' . implode('/', $element['#array_parents']) . '/' . $form['form_build_id']['#value'],
370 'wrapper' => $element['#id'] . '-ajax-wrapper',
371 'effect' => 'fade',
372 'progress' => array(
373 'type' => $element['#progress_indicator'],
374 'message' => $element['#progress_message'],
375 ),
376 );
377
378 // Set up the buttons first since we need to check if they were clicked.
379 $element['upload_button'] = array(
380 '#name' => implode('_', $element['#parents']) . '_upload_button',
381 '#type' => 'submit',
382 '#value' => t('Upload'),
383 '#validate' => array(),
384 '#submit' => array('file_managed_file_submit'),
385 '#limit_validation_errors' => array($element['#parents']),
386 '#ajax' => $ajax_settings,
387 '#weight' => -5,
388 );
389
390 // Force the progress indicator for the remove button to be either 'none' or
391 // 'throbber', even if the upload button is using something else.
392 $ajax_settings['progress']['type'] = ($element['#progress_indicator'] == 'none') ? 'none' : 'throbber';
393 $ajax_settings['progress']['message'] = NULL;
394 $ajax_settings['effect'] = 'none';
395 $element['remove_button'] = array(
396 '#name' => implode('_', $element['#parents']) . '_remove_button',
397 '#type' => 'submit',
398 '#value' => t('Remove'),
399 '#validate' => array(),
400 '#submit' => array('file_managed_file_submit'),
401 '#limit_validation_errors' => array($element['#parents']),
402 '#ajax' => $ajax_settings,
403 '#weight' => -5,
404 );
405
406 $element['fid'] = array(
407 '#type' => 'hidden',
408 '#value' => $fid,
409 );
410
411 // Add progress bar support to the upload if possible.
412 if ($element['#progress_indicator'] == 'bar' && $implementation = file_progress_implementation()) {
413 $upload_progress_key = mt_rand();
414
415 if ($implementation == 'uploadprogress') {
416 $element['UPLOAD_IDENTIFIER'] = array(
417 '#type' => 'hidden',
418 '#value' => $upload_progress_key,
419 '#attributes' => array('class' => array('file-progress')),
420 // Uploadprogress extension requires this field to be at the top of the
421 // form.
422 '#weight' => -20,
423 );
424 }
425 elseif ($implementation == 'apc') {
426 $element['APC_UPLOAD_PROGRESS'] = array(
427 '#type' => 'hidden',
428 '#value' => $upload_progress_key,
429 '#attributes' => array('class' => array('file-progress')),
430 // Uploadprogress extension requires this field to be at the top of the
431 // form.
432 '#weight' => -20,
433 );
434 }
435
436 // Add the upload progress callback.
437 $element['upload_button']['#ajax']['progress']['path'] = 'file/progress/' . $upload_progress_key;
438 }
439
440 // The file upload field itself.
441 $element['upload'] = array(
442 '#name' => 'files[' . implode('_', $element['#parents']) . ']',
443 '#type' => 'file',
444 '#title' => t('Choose a file'),
445 '#title_display' => 'invisible',
446 '#size' => $element['#size'],
447 '#theme_wrappers' => array(),
448 '#weight' => -10,
449 );
450
451 if ($fid && $element['#file']) {
452 $element['filename'] = array(
453 '#type' => 'markup',
454 '#markup' => theme('file_link', array('file' => $element['#file'])) . ' ',
455 '#weight' => -10,
456 );
457 }
458
459 // Add the extension list to the page as JavaScript settings.
460 if (isset($element['#upload_validators']['file_validate_extensions'][0])) {
461 $extension_list = implode(',', array_filter(explode(' ', $element['#upload_validators']['file_validate_extensions'][0])));
462 $element['upload']['#attached']['js'] = array(
463 array(
464 'type' => 'setting',
465 'data' => array('file' => array('elements' => array('#' . $element['#id'] . '-upload' => $extension_list)))
466 )
467 );
468 }
469
470 // Prefix and suffix used for Ajax replacement.
471 $element['#prefix'] = '<div id="' . $element['#id'] . '-ajax-wrapper">';
472 $element['#suffix'] = '</div>';
473
474 return $element;
475 }
476
480 function file_managed_file_value(&$element, $input = FALSE, $form_state = NULL) {
481 $fid = 0;
482
483 // Find the current value of this field from the form state.
484 $form_state_fid = $form_state['values'];
485 foreach ($element['#parents'] as $parent) {
486 $form_state_fid = isset($form_state_fid[$parent]) ? $form_state_fid[$parent] : 0;
487 }
488
489 if ($element['#extended'] && isset($form_state_fid['fid'])) {
490 $fid = $form_state_fid['fid'];
491 }
492 elseif (is_numeric($form_state_fid)) {
493 $fid = $form_state_fid;
494 }
495
496 // Process any input and save new uploads.
497 if ($input !== FALSE) {
498 $return = $input;
499
500 // Uploads take priority over all other values.
501 if ($file = file_managed_file_save_upload($element)) {
502 $fid = $file->fid;
503 }
504 else {
505 // Check for #filefield_value_callback values.
506 // Because FAPI does not allow multiple #value_callback values like it
507 // does for #element_validate and #process, this fills the missing
508 // functionality to allow File fields to be extended through FAPI.
509 if (isset($element['#file_value_callbacks'])) {
510 foreach ($element['#file_value_callbacks'] as $callback) {
511 $callback($element, $input, $form_state);
512 }
513 }
514 // Load file if the FID has changed to confirm it exists.
515 if (isset($input['fid']) && $file = file_load($input['fid'])) {
516 $fid = $file->fid;
517 }
518 }
519 }
520
521 // If there is no input, set the default value.
522 else {
523 if ($element['#extended']) {
524 $default_fid = isset($element['#default_value']['fid']) ? $element['#default_value']['fid'] : 0;
525 $return = isset($element['#default_value']) ? $element['#default_value'] : array('fid' => 0);
526 }
527 else {
528 $default_fid = isset($element['#default_value']) ? $element['#default_value'] : 0;
529 $return = array('fid' => 0);
530 }
531
532 // Confirm that the file exists when used as a default value.
533 if ($default_fid && $file = file_load($default_fid)) {
534 $fid = $file->fid;
535 }
536 }
537
538 $return['fid'] = $fid;
539
540 return $return;
541 }
542
546 function file_managed_file_validate(&$element, &$form_state) {
547 // If referencing an existing file, only allow if there are existing
548 // references. This prevents unmanaged files from being deleted if this
549 // item were to be deleted.
550 $clicked_button = end($form_state['triggering_element']['#parents']);
551 if ($clicked_button != 'remove_button' && !empty($element['fid']['#value'])) {
552 if ($file = file_load($element['fid']['#value'])) {
553 if ($file->status == FILE_STATUS_PERMANENT) {
554 $references = file_usage_list($file);
555 if (empty($references)) {
556 form_error($element, t('The file used in the !name field may not be referenced.', array('!name' => $element['#title'])));
557 }
558 }
559 }
560 else {
561 form_error($element, t('The file referenced by the !name field does not exist.', array('!name' => $element['#title'])));
562 }
563 }
564
565 // Check required property based on the FID.
566 if ($element['#required'] && empty($element['fid']['#value']) && !in_array($clicked_button, array('upload_button', 'remove_button'))) {
567 form_error($element['upload'], t('!name field is required.', array('!name' => $element['#title'])));
568 }
569
570 // Consolidate the array value of this field to a single FID.
571 if (!$element['#extended']) {
572 form_set_value($element, $element['fid']['#value'], $form_state);
573 }
574 }
575
581 function file_managed_file_submit($form, &$form_state) {
582 // Determine whether it was the upload or the remove button that was clicked,
583 // and set $element to the managed_file element that contains that button.
584 $parents = $form_state['triggering_element']['#array_parents'];
585 $button_key = array_pop($parents);
586 $element = drupal_array_get_nested_value($form, $parents);
587
588 // No action is needed here for the upload button, because all file uploads on
589 // the form are processed by file_managed_file_value() regardless of which
590 // button was clicked. Action is needed here for the remove button, because we
591 // only remove a file in response to its remove button being clicked.
592 if ($button_key == 'remove_button') {
593 // If it's a temporary file we can safely remove it immediately, otherwise
594 // it's up to the implementing module to clean up files that are in use.
595 if ($element['#file'] && $element['#file']->status == 0) {
596 file_delete($element['#file']);
597 }
598 // Update both $form_state['values'] and $form_state['input'] to reflect
599 // that the file has been removed, so that the form is rebuilt correctly.
600 // $form_state['values'] must be updated in case additional submit handlers
601 // run, and for form building functions that run during the rebuild, such as
602 // when the managed_file element is part of a field widget.
603 // $form_state['input'] must be updated so that file_managed_file_value()
604 // has correct information during the rebuild.
605 $values_element = $element['#extended'] ? $element['fid'] : $element;
606 form_set_value($values_element, NULL, $form_state);
607 drupal_array_set_nested_value($form_state['input'], $values_element['#parents'], NULL);
608 }
609
610 // Set the form to rebuild so that $form is correctly updated in response to
611 // processing the file removal. Since this function did not change $form_state
612 // if the upload button was clicked, a rebuild isn't necessary in that
613 // situation and setting $form_state['redirect'] to FALSE would suffice.
614 // However, we choose to always rebuild, to keep the form processing workflow
615 // consistent between the two buttons.
616 $form_state['rebuild'] = TRUE;
617 }
618
629 function file_managed_file_save_upload($element) {
630 $upload_name = implode('_', $element['#parents']);
631 if (empty($_FILES['files']['name'][$upload_name])) {
632 return FALSE;
633 }
634
635 $destination = isset($element['#upload_location']) ? $element['#upload_location'] : NULL;
636 if (isset($destination) && !file_prepare_directory($destination, FILE_CREATE_DIRECTORY)) {
637 watchdog('file', 'The upload directory %directory for the file field !name could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled.', array('%directory' => $destination, '!name' => $element['#field_name']));
638 form_set_error($upload_name, t('The file could not be uploaded.'));
639 return FALSE;
640 }
641
642 if (!$file = file_save_upload($upload_name, $element['#upload_validators'], $destination)) {
643 watchdog('file', 'The file upload failed. %upload', array('%upload' => $upload_name));
644 form_set_error($upload_name, t('The file in the !name field was unable to be uploaded.', array('!name' => $element['#title'])));
645 return FALSE;
646 }
647
648 return $file;
649 }
650
660 function theme_file_managed_file($variables) {
661 $element = $variables['element'];
662
663 $attributes = array();
664 if (isset($element['#id'])) {
665 $attributes['id'] = $element['#id'];
666 }
667 if (!empty($element['#attributes']['class'])) {
668 $attributes['class'] = (array) $element['#attributes']['class'];
669 }
670 $attributes['class'][] = 'form-managed-file';
671
672 // This wrapper is required to apply JS behaviors and CSS styling.
673 $output = '';
674 $output .= '<div' . drupal_attributes($attributes) . '>';
675 $output .= drupal_render_children($element);
676 $output .= '</div>';
677 return $output;
678 }
679
699 function file_managed_file_pre_render($element) {
700 // If we already have a file, we don't want to show the upload controls.
701 if (!empty($element['#value']['fid'])) {
702 $element['upload']['#access'] = FALSE;
703 $element['upload_button']['#access'] = FALSE;
704 }
705 // If we don't already have a file, there is nothing to remove.
706 else {
707 $element['remove_button']['#access'] = FALSE;
708 }
709 return $element;
710 }
711
723 function theme_file_link($variables) {
724 $file = $variables['file'];
725 $icon_directory = $variables['icon_directory'];
726
727 $url = file_create_url($file->uri);
728 $icon = theme('file_icon', array('file' => $file, 'icon_directory' => $icon_directory));
729
730 // Set options as per anchor format described at
731 // http://microformats.org/wiki/file-format-examples
732 $options = array(
733 'attributes' => array(
734 'type' => $file->filemime . '; length=' . $file->filesize,
735 ),
736 );
737
738 // Use the description as the link text if available.
739 if (empty($file->description)) {
740 $link_text = $file->filename;
741 }
742 else {
743 $link_text = $file->description;
744 $options['attributes']['title'] = check_plain($file->filename);
745 }
746
747 return '<span class="file">' . $icon . ' ' . l($link_text, $url, $options) . '</span>';
748 }
749
761 function theme_file_icon($variables) {
762 $file = $variables['file'];
763 $icon_directory = $variables['icon_directory'];
764
765 $mime = check_plain($file->filemime);
766 $icon_url = file_icon_url($file, $icon_directory);
767 return '<img class="file-icon" alt="" title="' . $mime . '" src="' . $icon_url . '" />';
768 }
769
782 function file_icon_url($file, $icon_directory = NULL) {
783 if ($icon_path = file_icon_path($file, $icon_directory)) {
784 return base_path() . $icon_path;
785 }
786 return FALSE;
787 }
788
802 function file_icon_path($file, $icon_directory = NULL) {
803 // Use the default set of icons if none specified.
804 if (!isset($icon_directory)) {
805 $icon_directory = variable_get('file_icon_directory', drupal_get_path('module', 'file') . '/icons');
806 }
807
808 // If there's an icon matching the exact mimetype, go for it.
809 $dashed_mime = strtr($file->filemime, array('/' => '-'));
810 $icon_path = $icon_directory . '/' . $dashed_mime . '.png';
811 if (file_exists($icon_path)) {
812 return $icon_path;
813 }
814
815 // For a few mimetypes, we can "manually" map to a generic icon.
816 $generic_mime = (string) file_icon_map($file);
817 $icon_path = $icon_directory . '/' . $generic_mime . '.png';
818 if ($generic_mime && file_exists($icon_path)) {
819 return $icon_path;
820 }
821
822 // Use generic icons for each category that provides such icons.
823 foreach (array('audio', 'image', 'text', 'video') as $category) {
824 if (strpos($file->filemime, $category . '/') === 0) {
825 $icon_path = $icon_directory . '/' . $category . '-x-generic.png';
826 if (file_exists($icon_path)) {
827 return $icon_path;
828 }
829 }
830 }
831
832 // Try application-octet-stream as last fallback.
833 $icon_path = $icon_directory . '/application-octet-stream.png';
834 if (file_exists($icon_path)) {
835 return $icon_path;
836 }
837
838 // No icon can be found.
839 return FALSE;
840 }
841
851 function file_icon_map($file) {
852 switch ($file->filemime) {
853 // Word document types.
854 case 'application/msword':
855 case 'application/vnd.ms-word.document.macroEnabled.12':
856 case 'application/vnd.oasis.opendocument.text':
857 case 'application/vnd.oasis.opendocument.text-template':
858 case 'application/vnd.oasis.opendocument.text-master':
859 case 'application/vnd.oasis.opendocument.text-web':
860 case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
861 case 'application/vnd.stardivision.writer':
862 case 'application/vnd.sun.xml.writer':
863 case 'application/vnd.sun.xml.writer.template':
864 case 'application/vnd.sun.xml.writer.global':
865 case 'application/vnd.wordperfect':
866 case 'application/x-abiword':
867 case 'application/x-applix-word':
868 case 'application/x-kword':
869 case 'application/x-kword-crypt':
870 return 'x-office-document';
871
872 // Spreadsheet document types.
873 case 'application/vnd.ms-excel':
874 case 'application/vnd.ms-excel.sheet.macroEnabled.12':
875 case 'application/vnd.oasis.opendocument.spreadsheet':
876 case 'application/vnd.oasis.opendocument.spreadsheet-template':
877 case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
878 case 'application/vnd.stardivision.calc':
879 case 'application/vnd.sun.xml.calc':
880 case 'application/vnd.sun.xml.calc.template':
881 case 'application/vnd.lotus-1-2-3':
882 case 'application/x-applix-spreadsheet':
883 case 'application/x-gnumeric':
884 case 'application/x-kspread':
885 case 'application/x-kspread-crypt':
886 return 'x-office-spreadsheet';
887
888 // Presentation document types.
889 case 'application/vnd.ms-powerpoint':
890 case 'application/vnd.ms-powerpoint.presentation.macroEnabled.12':
891 case 'application/vnd.oasis.opendocument.presentation':
892 case 'application/vnd.oasis.opendocument.presentation-template':
893 case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
894 case 'application/vnd.stardivision.impress':
895 case 'application/vnd.sun.xml.impress':
896 case 'application/vnd.sun.xml.impress.template':
897 case 'application/x-kpresenter':
898 return 'x-office-presentation';
899
900 // Compressed archive types.
901 case 'application/zip':
902 case 'application/x-zip':
903 case 'application/stuffit':
904 case 'application/x-stuffit':
905 case 'application/x-7z-compressed':
906 case 'application/x-ace':
907 case 'application/x-arj':
908 case 'application/x-bzip':
909 case 'application/x-bzip-compressed-tar':
910 case 'application/x-compress':
911 case 'application/x-compressed-tar':
912 case 'application/x-cpio-compressed':
913 case 'application/x-deb':
914 case 'application/x-gzip':
915 case 'application/x-java-archive':
916 case 'application/x-lha':
917 case 'application/x-lhz':
918 case 'application/x-lzop':
919 case 'application/x-rar':
920 case 'application/x-rpm':
921 case 'application/x-tzo':
922 case 'application/x-tar':
923 case 'application/x-tarz':
924 case 'application/x-tgz':
925 return 'package-x-generic';
926
927 // Script file types.
928 case 'application/ecmascript':
929 case 'application/javascript':
930 case 'application/mathematica':
931 case 'application/vnd.mozilla.xul+xml':
932 case 'application/x-asp':
933 case 'application/x-awk':
934 case 'application/x-cgi':
935 case 'application/x-csh':
936 case 'application/x-m4':
937 case 'application/x-perl':
938 case 'application/x-php':
939 case 'application/x-ruby':
940 case 'application/x-shellscript':
941 case 'text/vnd.wap.wmlscript':
942 case 'text/x-emacs-lisp':
943 case 'text/x-haskell':
944 case 'text/x-literate-haskell':
945 case 'text/x-lua':
946 case 'text/x-makefile':
947 case 'text/x-matlab':
948 case 'text/x-python':
949 case 'text/x-sql':
950 case 'text/x-tcl':
951 return 'text-x-script';
952
953 // HTML aliases.
954 case 'application/xhtml+xml':
955 return 'text-html';
956
957 // Executable types.
958 case 'application/x-macbinary':
959 case 'application/x-ms-dos-executable':
960 case 'application/x-pef-executable':
961 return 'application-x-executable';
962
963 default:
964 return FALSE;
965 }
966 }
967
993 function file_get_file_references($file, $field = NULL, $age = FIELD_LOAD_REVISION, $field_type = 'file') {
994 $references = drupal_static(__FUNCTION__, array());
995 $fields = isset($field) ? array($field['field_name'] => $field) : field_info_fields();
996
997 foreach ($fields as $field_name => $file_field) {
998 if ((empty($field_type) || $file_field['type'] == $field_type) && !isset($references[$field_name])) {
999 // Get each time this file is used within a field.
1000 $query = new EntityFieldQuery();
1001 $query
1002 ->fieldCondition($file_field, 'fid', $file->fid)
1003 ->age($age);
1004 $references[$field_name] = $query->execute();
1005 }
1006 }
1007
1008 return isset($field) ? $references[$field['field_name']] : array_filter($references);
1009 }
1010
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
theme_file_icon
theme_file_icon($variables)
Definition: file.module:761
file_upload_max_size
file_upload_max_size()
Definition: file.inc:2108
file_element_info
file_element_info()
Definition: file.module:61
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
file_managed_file_value
file_managed_file_value(&$element, $input=FALSE, $form_state=NULL)
Definition: file.module:480
FILE_CREATE_DIRECTORY
const FILE_CREATE_DIRECTORY
Definition: file.inc:41
entity_load
entity_load($entity_type, $ids=FALSE, $conditions=array(), $reset=FALSE)
Definition: common.inc:7800
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
theme_file_managed_file
theme_file_managed_file($variables)
Definition: file.module:660
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
drupal_array_get_nested_value
& drupal_array_get_nested_value(array &$array, array $parents, &$key_exists=NULL)
Definition: common.inc:6666
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
$module
print $module
Definition: search-results.tpl.php:28
file_ajax_progress
file_ajax_progress($key)
Definition: file.module:298
file_create_url
file_create_url($uri)
Definition: file.inc:372
ajax_command_replace
ajax_command_replace($selector, $html, $settings=NULL)
Definition: ajax.inc:842
field_get_items
field_get_items($entity_type, $entity, $field_name, $langcode=NULL)
Definition: field.module:935
file_get_content_headers
file_get_content_headers($file)
Definition: file.inc:2505
drupal_json_output
drupal_json_output($var=NULL)
Definition: common.inc:5041
drupal_attributes
drupal_attributes(array $attributes=array())
Definition: common.inc:2377
$attributes
print $attributes
Definition: block.tpl.php:47
file_managed_file_pre_render
file_managed_file_pre_render($element)
Definition: file.module:699
file_ajax_upload
file_ajax_upload()
Definition: file.module:237
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
field_access
field_access($op, $field, $entity_type, $entity=NULL, $account=NULL)
Definition: field.module:982
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
file_progress_implementation
file_progress_implementation()
Definition: file.module:330
FILE_STATUS_PERMANENT
const FILE_STATUS_PERMANENT
Definition: file.inc:70
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
file_theme
file_theme()
Definition: file.module:88
file_managed_file_validate
file_managed_file_validate(&$element, &$form_state)
Definition: file.module:546
file_icon_path
file_icon_path($file, $icon_directory=NULL)
Definition: file.module:802
file_delete
file_delete(stdClass $file, $force=FALSE)
Definition: file.inc:1268
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
file_help
file_help($path, $arg)
Definition: file.module:14
file_file_download
file_file_download($uri, $field_type= 'file')
Definition: file.module:123
file_managed_file_save_upload
file_managed_file_save_upload($element)
Definition: file.module:629
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$url
print $url
Definition: search-result.tpl.php:70
file_load_multiple
file_load_multiple($fids=array(), $conditions=array())
Definition: file.inc:564
file_icon_map
file_icon_map($file)
Definition: file.module:851
ajax_get_form
ajax_get_form()
Definition: ajax.inc:317
file_icon_url
file_icon_url($file, $icon_directory=NULL)
Definition: file.module:782
FIELD_LOAD_REVISION
const FIELD_LOAD_REVISION
Definition: field.module:274
EntityFieldQuery
Definition: entity.inc:420
file_load
file_load($fid)
Definition: file.inc:580
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
file_managed_file_process
file_managed_file_process($element, &$form_state, $form)
Definition: file.module:360
$output
$output
Definition: authorize.php:93
drupal_process_form
drupal_process_form($form_id, &$form, &$form_state)
Definition: form.inc:829
file_get_file_references
file_get_file_references($file, $field=NULL, $age=FIELD_LOAD_REVISION, $field_type= 'file')
Definition: file.module:993
file_save_upload
file_save_upload($source, $validators=array(), $destination=FALSE, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1437
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
file_menu
file_menu()
Definition: file.module:36
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
theme_file_link
theme_file_link($variables)
Definition: file.module:723
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
drupal_array_set_nested_value
drupal_array_set_nested_value(array &$array, array $parents, $value, $force=FALSE)
Definition: common.inc:6598
file_usage_list
file_usage_list(stdClass $file)
Definition: file.inc:642
file_file_delete
file_file_delete($file)
Definition: file.module:350
file_prepare_directory
file_prepare_directory(&$directory, $options=FILE_MODIFY_PERMISSIONS)
Definition: file.inc:430
base_path
base_path()
Definition: common.inc:2817
format_size
format_size($size, $langcode=NULL)
Definition: common.inc:1866
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
field_info_fields
field_info_fields()
Definition: field.info.inc:487
file_managed_file_submit
file_managed_file_submit($form, &$form_state)
Definition: file.module:581
FIELD_LOAD_CURRENT
const FIELD_LOAD_CURRENT
Definition: field.module:268
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/locale/locale.admin.inc Source File

  • modules
  • locale
locale.admin.inc
Go to the documentation of this file.
1 <?php
2
20 function locale_languages_overview_form() {
21 drupal_static_reset('language');
22 $languages = language_list('language');
23
24 $options = array();
25 $form['weight'] = array('#tree' => TRUE);
26 foreach ($languages as $langcode => $language) {
27
28 $options[$langcode] = '';
29 if ($language->enabled) {
30 $enabled[] = $langcode;
31 }
32 $form['weight'][$langcode] = array(
33 '#type' => 'weight',
34 '#title' => t('Weight for @title', array('@title' => $language->name)),
35 '#title_display' => 'invisible',
36 '#default_value' => $language->weight,
37 '#attributes' => array('class' => array('language-order-weight')),
38 );
39 $form['name'][$langcode] = array('#markup' => check_plain($language->name));
40 $form['native'][$langcode] = array('#markup' => check_plain($language->native));
41 $form['direction'][$langcode] = array('#markup' => ($language->direction == LANGUAGE_RTL ? t('Right to left') : t('Left to right')));
42 }
43 $form['enabled'] = array(
44 '#type' => 'checkboxes',
45 '#title' => t('Enabled languages'),
46 '#title_display' => 'invisible',
47 '#options' => $options,
48 '#default_value' => $enabled,
49 );
50 $form['site_default'] = array(
51 '#type' => 'radios',
52 '#title' => t('Default language'),
53 '#title_display' => 'invisible',
54 '#options' => $options,
55 '#default_value' => language_default('language'),
56 );
57 $form['actions'] = array('#type' => 'actions');
58 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
59 $form['#theme'] = 'locale_languages_overview_form';
60
61 return $form;
62 }
63
73 function theme_locale_languages_overview_form($variables) {
74 $form = $variables['form'];
75 $default = language_default();
76 foreach ($form['name'] as $key => $element) {
77 // Do not take form control structures.
78 if (is_array($element) && element_child($key)) {
79 // Disable checkbox for the default language, because it cannot be disabled.
80 if ($key == $default->language) {
81 $form['enabled'][$key]['#attributes']['disabled'] = 'disabled';
82 }
83
84 // Add invisible labels for the checkboxes and radio buttons in the table
85 // for accessibility. These changes are only required and valid when the
86 // form is themed as a table, so it would be wrong to perform them in the
87 // form constructor.
88 $title = drupal_render($form['name'][$key]);
89 $form['enabled'][$key]['#title'] = t('Enable !title', array('!title' => $title));
90 $form['enabled'][$key]['#title_display'] = 'invisible';
91 $form['site_default'][$key]['#title'] = t('Set !title as default', array('!title' => $title));
92 $form['site_default'][$key]['#title_display'] = 'invisible';
93 $rows[] = array(
94 'data' => array(
95 '<strong>' . $title . '</strong>',
96 drupal_render($form['native'][$key]),
97 check_plain($key),
98 drupal_render($form['direction'][$key]),
99 array('data' => drupal_render($form['enabled'][$key]), 'align' => 'center'),
100 drupal_render($form['site_default'][$key]),
101 drupal_render($form['weight'][$key]),
102 l(t('edit'), 'admin/config/regional/language/edit/' . $key) . (($key != 'en' && $key != $default->language) ? ' ' . l(t('delete'), 'admin/config/regional/language/delete/' . $key) : '')
103 ),
104 'class' => array('draggable'),
105 );
106 }
107 }
108 $header = array(array('data' => t('English name')), array('data' => t('Native name')), array('data' => t('Code')), array('data' => t('Direction')), array('data' => t('Enabled')), array('data' => t('Default')), array('data' => t('Weight')), array('data' => t('Operations')));
109 $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'language-order')));
110 $output .= drupal_render_children($form);
111
112 drupal_add_tabledrag('language-order', 'order', 'sibling', 'language-order-weight');
113
114 return $output;
115 }
116
120 function locale_languages_overview_form_submit($form, &$form_state) {
121 $languages = language_list();
122 $default = language_default();
123 $url_prefixes = variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX;
124 $enabled_count = 0;
125
126 foreach ($languages as $langcode => $language) {
127 if ($form_state['values']['site_default'] == $langcode || $default->language == $langcode) {
128 // Automatically enable the default language and the language
129 // which was default previously (because we will not get the
130 // value from that disabled checkbox).
131 $form_state['values']['enabled'][$langcode] = 1;
132 }
133
134 // If language URL prefixes are enabled we must clear language domains and
135 // assign a valid prefix to each non-default language.
136 if ($url_prefixes) {
137 $language->domain = '';
138 if (empty($language->prefix) && $form_state['values']['site_default'] != $langcode) {
139 $language->prefix = $langcode;
140 }
141 }
142
143 if ($form_state['values']['enabled'][$langcode]) {
144 $enabled_count++;
145 $language->enabled = 1;
146 }
147 else {
148 $language->enabled = 0;
149 }
150
151 $language->weight = $form_state['values']['weight'][$langcode];
152
153 db_update('languages')
154 ->fields(array(
155 'enabled' => $language->enabled,
156 'weight' => $language->weight,
157 'prefix' => $language->prefix,
158 'domain' => $language->domain,
159 ))
160 ->condition('language', $langcode)
161 ->execute();
162
163 $languages[$langcode] = $language;
164 }
165
166 variable_set('language_default', $languages[$form_state['values']['site_default']]);
167 variable_set('language_count', $enabled_count);
168 drupal_set_message(t('Configuration saved.'));
169
170 // Changing the language settings impacts the interface.
171 cache_clear_all('*', 'cache_page', TRUE);
172 module_invoke_all('multilingual_settings_changed');
173
174 $form_state['redirect'] = 'admin/config/regional/language';
175 return;
176 }
177
181 function locale_languages_add_screen() {
182 $build['predefined'] = drupal_get_form('locale_languages_predefined_form');
183 $build['custom'] = drupal_get_form('locale_languages_custom_form');
184 return $build;
185 }
186
190 function locale_languages_predefined_form($form) {
191 $predefined = _locale_prepare_predefined_list();
192 $form['language list'] = array('#type' => 'fieldset',
193 '#title' => t('Predefined language'),
194 '#collapsible' => TRUE,
195 );
196 $form['language list']['langcode'] = array('#type' => 'select',
197 '#title' => t('Language name'),
198 '#default_value' => key($predefined),
199 '#options' => $predefined,
200 '#description' => t('Use the <em>Custom language</em> section below if your desired language does not appear in this list.'),
201 );
202 $form['language list']['actions'] = array('#type' => 'actions');
203 $form['language list']['actions']['submit'] = array('#type' => 'submit', '#value' => t('Add language'));
204 return $form;
205 }
206
210 function locale_languages_custom_form($form) {
211 $form['custom language'] = array('#type' => 'fieldset',
212 '#title' => t('Custom language'),
213 '#collapsible' => TRUE,
214 '#collapsed' => TRUE,
215 );
216 _locale_languages_common_controls($form['custom language']);
217 $form['custom language']['actions'] = array('#type' => 'actions');
218 $form['custom language']['actions']['submit'] = array(
219 '#type' => 'submit',
220 '#value' => t('Add custom language')
221 );
222 // Reuse the validation and submit functions of the predefined language setup form.
223 $form['#submit'][] = 'locale_languages_predefined_form_submit';
224 $form['#validate'][] = 'locale_languages_predefined_form_validate';
225 return $form;
226 }
227
234 function locale_languages_edit_form($form, &$form_state, $langcode) {
235 if ($language = db_query("SELECT * FROM {languages} WHERE language = :language", array(':language' => $langcode))->fetchObject()) {
236 _locale_languages_common_controls($form, $language);
237 $form['actions'] = array('#type' => 'actions');
238 $form['actions']['submit'] = array(
239 '#type' => 'submit',
240 '#value' => t('Save language')
241 );
242 $form['#submit'][] = 'locale_languages_edit_form_submit';
243 $form['#validate'][] = 'locale_languages_edit_form_validate';
244 return $form;
245 }
246 else {
247 drupal_not_found();
248 drupal_exit();
249 }
250 }
251
260 function _locale_languages_common_controls(&$form, $language = NULL) {
261 if (!is_object($language)) {
262 $language = new stdClass();
263 }
264 if (isset($language->language)) {
265 $form['langcode_view'] = array(
266 '#type' => 'item',
267 '#title' => t('Language code'),
268 '#markup' => $language->language
269 );
270 $form['langcode'] = array(
271 '#type' => 'value',
272 '#value' => $language->language
273 );
274 }
275 else {
276 $form['langcode'] = array('#type' => 'textfield',
277 '#title' => t('Language code'),
278 '#maxlength' => 12,
279 '#required' => TRUE,
280 '#default_value' => @$language->language,
281 '#disabled' => (isset($language->language)),
282 '#description' => t('<a href="@rfc4646">RFC 4646</a> compliant language identifier. Language codes typically use a country code, and optionally, a script or regional variant name. <em>Examples: "en", "en-US" and "zh-Hant".</em>', array('@rfc4646' => 'http://www.ietf.org/rfc/rfc4646.txt')),
283 );
284 }
285 $form['name'] = array('#type' => 'textfield',
286 '#title' => t('Language name in English'),
287 '#maxlength' => 64,
288 '#default_value' => @$language->name,
289 '#required' => TRUE,
290 '#description' => t('Name of the language in English. Will be available for translation in all languages.'),
291 );
292 $form['native'] = array('#type' => 'textfield',
293 '#title' => t('Native language name'),
294 '#maxlength' => 64,
295 '#default_value' => @$language->native,
296 '#required' => TRUE,
297 '#description' => t('Name of the language in the language being added.'),
298 );
299 $form['prefix'] = array('#type' => 'textfield',
300 '#title' => t('Path prefix language code'),
301 '#maxlength' => 64,
302 '#default_value' => @$language->prefix,
303 '#description' => t('Language code or other custom text to use as a path prefix for URL language detection, if your <em>Detection and selection</em> settings use URL path prefixes. For the default language, this value may be left blank. <strong>Modifying this value may break existing URLs. Use with caution in a production environment.</strong> Example: Specifying "deutsch" as the path prefix code for German results in URLs like "example.com/deutsch/contact".')
304 );
305 $form['domain'] = array('#type' => 'textfield',
306 '#title' => t('Language domain'),
307 '#maxlength' => 128,
308 '#default_value' => @$language->domain,
309 '#description' => t('The domain name to use for this language if URL domains are used for <em>Detection and selection</em>. Leave blank for the default language. <strong>Changing this value may break existing URLs.</strong> Example: Specifying "de.example.com" as language domain for German will result in an URL like "http://de.example.com/contact".'),
310 );
311 $form['direction'] = array('#type' => 'radios',
312 '#title' => t('Direction'),
313 '#required' => TRUE,
314 '#description' => t('Direction that text in this language is presented.'),
315 '#default_value' => @$language->direction,
316 '#options' => array(LANGUAGE_LTR => t('Left to right'), LANGUAGE_RTL => t('Right to left'))
317 );
318 return $form;
319 }
320
324 function locale_languages_predefined_form_validate($form, &$form_state) {
325 $langcode = $form_state['values']['langcode'];
326
327 if (($duplicate = db_query("SELECT COUNT(*) FROM {languages} WHERE language = :language", array(':language' => $langcode))->fetchField()) != 0) {
328 form_set_error('langcode', t('The language %language (%code) already exists.', array('%language' => $form_state['values']['name'], '%code' => $langcode)));
329 }
330
331 if (!isset($form_state['values']['name'])) {
332 // Predefined language selection.
333 include_once DRUPAL_ROOT . '/includes/iso.inc';
334 $predefined = _locale_get_predefined_list();
335 if (!isset($predefined[$langcode])) {
336 form_set_error('langcode', t('Invalid language code.'));
337 }
338 }
339 else {
340 // Reuse the editing form validation routine if we add a custom language.
341 locale_languages_edit_form_validate($form, $form_state);
342 }
343 }
344
348 function locale_languages_predefined_form_submit($form, &$form_state) {
349 $langcode = $form_state['values']['langcode'];
350 if (isset($form_state['values']['name'])) {
351 // Custom language form.
352 locale_add_language($langcode, $form_state['values']['name'], $form_state['values']['native'], $form_state['values']['direction'], $form_state['values']['domain'], $form_state['values']['prefix']);
353 drupal_set_message(t('The language %language has been created and can now be used. More information is available on the <a href="@locale-help">help screen</a>.', array('%language' => t($form_state['values']['name']), '@locale-help' => url('admin/help/locale'))));
354 }
355 else {
356 // Predefined language selection.
357 include_once DRUPAL_ROOT . '/includes/iso.inc';
358 $predefined = _locale_get_predefined_list();
359 locale_add_language($langcode);
360 drupal_set_message(t('The language %language has been created and can now be used. More information is available on the <a href="@locale-help">help screen</a>.', array('%language' => t($predefined[$langcode][0]), '@locale-help' => url('admin/help/locale'))));
361 }
362
363 // See if we have language files to import for the newly added
364 // language, collect and import them.
365 if ($batch = locale_batch_by_language($langcode, '_locale_batch_language_finished')) {
366 batch_set($batch);
367 }
368
369 $form_state['redirect'] = 'admin/config/regional/language';
370 }
371
375 function locale_languages_edit_form_validate($form, &$form_state) {
376 // Ensure sane field values for langcode, name, and native.
377 if (!isset($form['langcode_view']) && preg_match('@[^a-zA-Z_-]@', $form_state['values']['langcode'])) {
378 form_set_error('langcode', t('%field may only contain characters a-z, underscores, or hyphens.', array('%field' => $form['langcode']['#title'])));
379 }
380 if ($form_state['values']['name'] != check_plain($form_state['values']['name'])) {
381 form_set_error('name', t('%field cannot contain any markup.', array('%field' => $form['name']['#title'])));
382 }
383 if ($form_state['values']['native'] != check_plain($form_state['values']['native'])) {
384 form_set_error('native', t('%field cannot contain any markup.', array('%field' => $form['native']['#title'])));
385 }
386
387 if (!empty($form_state['values']['domain']) && !empty($form_state['values']['prefix'])) {
388 form_set_error('prefix', t('Domain and path prefix values should not be set at the same time.'));
389 }
390 if (!empty($form_state['values']['domain']) && $duplicate = db_query("SELECT language FROM {languages} WHERE domain = :domain AND language <> :language", array(':domain' => $form_state['values']['domain'], ':language' => $form_state['values']['langcode']))->fetchField()) {
391 form_set_error('domain', t('The domain (%domain) is already tied to a language (%language).', array('%domain' => $form_state['values']['domain'], '%language' => $duplicate)));
392 }
393 if (empty($form_state['values']['prefix']) && language_default('language') != $form_state['values']['langcode'] && empty($form_state['values']['domain'])) {
394 form_set_error('prefix', t('Only the default language can have both the domain and prefix empty.'));
395 }
396 if (!empty($form_state['values']['prefix']) && $duplicate = db_query("SELECT language FROM {languages} WHERE prefix = :prefix AND language <> :language", array(':prefix' => $form_state['values']['prefix'], ':language' => $form_state['values']['langcode']))->fetchField()) {
397 form_set_error('prefix', t('The prefix (%prefix) is already tied to a language (%language).', array('%prefix' => $form_state['values']['prefix'], '%language' => $duplicate)));
398 }
399 }
400
404 function locale_languages_edit_form_submit($form, &$form_state) {
405 db_update('languages')
406 ->fields(array(
407 'name' => $form_state['values']['name'],
408 'native' => $form_state['values']['native'],
409 'domain' => $form_state['values']['domain'],
410 'prefix' => $form_state['values']['prefix'],
411 'direction' => $form_state['values']['direction'],
412 ))
413 ->condition('language', $form_state['values']['langcode'])
414 ->execute();
415 $default = language_default();
416 if ($default->language == $form_state['values']['langcode']) {
417 $properties = array('name', 'native', 'direction', 'enabled', 'plurals', 'formula', 'domain', 'prefix', 'weight');
418 foreach ($properties as $keyname) {
419 if (isset($form_state['values'][$keyname])) {
420 $default->$keyname = $form_state['values'][$keyname];
421 }
422 }
423 variable_set('language_default', $default);
424 }
425 $form_state['redirect'] = 'admin/config/regional/language';
426 return;
427 }
428
432 function locale_languages_delete_form($form, &$form_state, $langcode) {
433
434 // Do not allow deletion of English locale.
435 if ($langcode == 'en') {
436 drupal_set_message(t('The English language cannot be deleted.'));
437 drupal_goto('admin/config/regional/language');
438 }
439
440 if (language_default('language') == $langcode) {
441 drupal_set_message(t('The default language cannot be deleted.'));
442 drupal_goto('admin/config/regional/language');
443 }
444
445 // For other languages, warn user that data loss is ahead.
446 $languages = language_list();
447
448 if (!isset($languages[$langcode])) {
449 drupal_not_found();
450 drupal_exit();
451 }
452 else {
453 $form['langcode'] = array('#type' => 'value', '#value' => $langcode);
454 return confirm_form($form, t('Are you sure you want to delete the language %name?', array('%name' => t($languages[$langcode]->name))), 'admin/config/regional/language', t('Deleting a language will remove all interface translations associated with it, and posts in this language will be set to be language neutral. This action cannot be undone.'), t('Delete'), t('Cancel'));
455 }
456 }
457
461 function locale_languages_delete_form_submit($form, &$form_state) {
462 $languages = language_list();
463 if (isset($languages[$form_state['values']['langcode']])) {
464 // Remove translations first.
465 db_delete('locales_target')
466 ->condition('language', $form_state['values']['langcode'])
467 ->execute();
468 cache_clear_all('locale:' . $form_state['values']['langcode'], 'cache');
469 // With no translations, this removes existing JavaScript translations file.
470 _locale_rebuild_js($form_state['values']['langcode']);
471 // Remove the language.
472 db_delete('languages')
473 ->condition('language', $form_state['values']['langcode'])
474 ->execute();
475 db_update('node')
476 ->fields(array('language' => ''))
477 ->condition('language', $form_state['values']['langcode'])
478 ->execute();
479 if ($languages[$form_state['values']['langcode']]->enabled) {
480 variable_set('language_count', variable_get('language_count', 1) - 1);
481 }
482 module_invoke_all('multilingual_settings_changed');
483 $variables = array('%locale' => $languages[$form_state['values']['langcode']]->name);
484 drupal_set_message(t('The language %locale has been removed.', $variables));
485 watchdog('locale', 'The language %locale has been removed.', $variables);
486 }
487
488 // Changing the language settings impacts the interface:
489 cache_clear_all('*', 'cache_page', TRUE);
490
491 $form_state['redirect'] = 'admin/config/regional/language';
492 return;
493 }
494
498 function locale_languages_configure_form() {
499 include_once DRUPAL_ROOT . '/includes/language.inc';
500
501 $form = array(
502 '#submit' => array('locale_languages_configure_form_submit'),
503 '#theme' => 'locale_languages_configure_form',
504 '#language_types' => language_types_configurable(FALSE),
505 '#language_types_info' => language_types_info(),
506 '#language_providers' => language_negotiation_info(),
507 );
508
509 foreach ($form['#language_types'] as $type) {
510 _locale_languages_configure_form_language_table($form, $type);
511 }
512
513 $form['actions'] = array('#type' => 'actions');
514 $form['actions']['submit'] = array(
515 '#type' => 'submit',
516 '#value' => t('Save settings'),
517 );
518
519 return $form;
520 }
521
525 function _locale_languages_configure_form_language_table(&$form, $type) {
526 $info = $form['#language_types_info'][$type];
527
528 $table_form = array(
529 '#title' => t('@type language detection', array('@type' => $info['name'])),
530 '#tree' => TRUE,
531 '#description' => $info['description'],
532 '#language_providers' => array(),
533 '#show_operations' => FALSE,
534 'weight' => array('#tree' => TRUE),
535 'enabled' => array('#tree' => TRUE),
536 );
537
538 $language_providers = $form['#language_providers'];
539 $enabled_providers = variable_get("language_negotiation_$type", array());
540 $providers_weight = variable_get("locale_language_providers_weight_$type", array());
541
542 // Add missing data to the providers lists.
543 foreach ($language_providers as $id => $provider) {
544 if (!isset($providers_weight[$id])) {
545 $providers_weight[$id] = language_provider_weight($provider);
546 }
547 }
548
549 // Order providers list by weight.
550 asort($providers_weight);
551
552 foreach ($providers_weight as $id => $weight) {
553 // A language provider might be no more available if the defining module has
554 // been disabled after the last configuration saving.
555 if (!isset($language_providers[$id])) {
556 continue;
557 }
558
559 $enabled = isset($enabled_providers[$id]);
560 $provider = $language_providers[$id];
561
562 // List the provider only if the current type is defined in its 'types' key.
563 // If it is not defined default to all the configurable language types.
564 $types = array_flip(isset($provider['types']) ? $provider['types'] : $form['#language_types']);
565
566 if (isset($types[$type])) {
567 $table_form['#language_providers'][$id] = $provider;
568
569 $table_form['weight'][$id] = array(
570 '#type' => 'weight',
571 '#title' => t('Weight for @title', array('@title' => $provider['name'])),
572 '#title_display' => 'invisible',
573 '#default_value' => $weight,
574 '#attributes' => array('class' => array("language-provider-weight-$type")),
575 );
576
577 $table_form['title'][$id] = array('#markup' => check_plain($provider['name']));
578
579 $table_form['enabled'][$id] = array(
580 '#type' => 'checkbox',
581 '#title' => t('@title language provider', array('@title' => $provider['name'])),
582 '#title_display' => 'invisible',
583 '#default_value' => $enabled,
584 );
585 if ($id === LANGUAGE_NEGOTIATION_DEFAULT) {
586 $table_form['enabled'][$id]['#default_value'] = TRUE;
587 $table_form['enabled'][$id]['#attributes'] = array('disabled' => 'disabled');
588 }
589
590 $table_form['description'][$id] = array('#markup' => filter_xss_admin($provider['description']));
591
592 $config_op = array();
593 if (isset($provider['config'])) {
594 $config_op = array('#type' => 'link', '#title' => t('Configure'), '#href' => $provider['config']);
595 // If there is at least one operation enabled show the operation column.
596 $table_form['#show_operations'] = TRUE;
597 }
598 $table_form['operation'][$id] = $config_op;
599 }
600 }
601
602 $form[$type] = $table_form;
603 }
604
614 function theme_locale_languages_configure_form($variables) {
615 $form = $variables['form'];
616 $output = '';
617
618 foreach ($form['#language_types'] as $type) {
619 $rows = array();
620 $info = $form['#language_types_info'][$type];
621 $title = '<label>' . $form[$type]['#title'] . '</label>';
622 $description = '<div class="description">' . $form[$type]['#description'] . '</div>';
623
624 foreach ($form[$type]['title'] as $id => $element) {
625 // Do not take form control structures.
626 if (is_array($element) && element_child($id)) {
627 $row = array(
628 'data' => array(
629 '<strong>' . drupal_render($form[$type]['title'][$id]) . '</strong>',
630 drupal_render($form[$type]['description'][$id]),
631 drupal_render($form[$type]['enabled'][$id]),
632 drupal_render($form[$type]['weight'][$id]),
633 ),
634 'class' => array('draggable'),
635 );
636 if ($form[$type]['#show_operations']) {
637 $row['data'][] = drupal_render($form[$type]['operation'][$id]);
638 }
639 $rows[] = $row;
640 }
641 }
642
643 $header = array(
644 array('data' => t('Detection method')),
645 array('data' => t('Description')),
646 array('data' => t('Enabled')),
647 array('data' => t('Weight')),
648 );
649
650 // If there is at least one operation enabled show the operation column.
651 if ($form[$type]['#show_operations']) {
652 $header[] = array('data' => t('Operations'));
653 }
654
655 $variables = array(
656 'header' => $header,
657 'rows' => $rows,
658 'attributes' => array('id' => "language-negotiation-providers-$type"),
659 );
660 $table = theme('table', $variables);
661 $table .= drupal_render_children($form[$type]);
662
663 drupal_add_tabledrag("language-negotiation-providers-$type", 'order', 'sibling', "language-provider-weight-$type");
664
665 $output .= '<div class="form-item">' . $title . $description . $table . '</div>';
666 }
667
668 $output .= drupal_render_children($form);
669 return $output;
670 }
671
675 function locale_languages_configure_form_submit($form, &$form_state) {
676 $configurable_types = $form['#language_types'];
677
678 foreach ($configurable_types as $type) {
679 $negotiation = array();
680 $enabled_providers = $form_state['values'][$type]['enabled'];
681 $enabled_providers[LANGUAGE_NEGOTIATION_DEFAULT] = TRUE;
682 $providers_weight = $form_state['values'][$type]['weight'];
683
684 foreach ($providers_weight as $id => $weight) {
685 if ($enabled_providers[$id]) {
686 $provider = $form[$type]['#language_providers'][$id];
687 $provider['weight'] = $weight;
688 $negotiation[$id] = $provider;
689 }
690 }
691
692 language_negotiation_set($type, $negotiation);
693 variable_set("locale_language_providers_weight_$type", $providers_weight);
694 }
695
696 // Update non-configurable language types and the related language negotiation
697 // configuration.
698 language_types_set();
699
700 $form_state['redirect'] = 'admin/config/regional/language/configure';
701 drupal_set_message(t('Language negotiation configuration saved.'));
702 }
703
707 function locale_language_providers_url_form($form, &$form_state) {
708 $form['locale_language_negotiation_url_part'] = array(
709 '#title' => t('Part of the URL that determines language'),
710 '#type' => 'radios',
711 '#options' => array(
712 LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX => t('Path prefix'),
713 LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN => t('Domain'),
714 ),
715 '#default_value' => variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX),
716 '#description' => t('<em>Path prefix</em>: URLs like http://example.com/de/contact set language to German (de). <em>Domain</em>: URLs like http://de.example.com/contact set the language to German. <strong>Warning: Changing this setting may break incoming URLs. Use with caution on a production site.</strong>'),
717 );
718
719 $form_state['redirect'] = 'admin/config/regional/language/configure';
720
721 return system_settings_form($form);
722 }
723
727 function locale_language_providers_session_form($form, &$form_state) {
728 $form['locale_language_negotiation_session_param'] = array(
729 '#title' => t('Request/session parameter'),
730 '#type' => 'textfield',
731 '#default_value' => variable_get('locale_language_negotiation_session_param', 'language'),
732 '#description' => t('Name of the request/session parameter used to determine the desired language.'),
733 );
734
735 $form_state['redirect'] = 'admin/config/regional/language/configure';
736
737 return system_settings_form($form);
738 }
739
756 function locale_translate_overview_screen() {
757 drupal_static_reset('language_list');
758 $languages = language_list('language');
759 $groups = module_invoke_all('locale', 'groups');
760
761 // Build headers with all groups in order.
762 $headers = array_merge(array(t('Language')), array_values($groups));
763
764 // Collect summaries of all source strings in all groups.
765 $sums = db_query("SELECT COUNT(*) AS strings, textgroup FROM {locales_source} GROUP BY textgroup");
766 $groupsums = array();
767 foreach ($sums as $group) {
768 $groupsums[$group->textgroup] = $group->strings;
769 }
770
771 // Set up overview table with default values, ensuring common order for values.
772 $rows = array();
773 foreach ($languages as $langcode => $language) {
774 $rows[$langcode] = array('name' => ($langcode == 'en' ? t('English (built-in)') : t($language->name)));
775 foreach ($groups as $group => $name) {
776 $rows[$langcode][$group] = ($langcode == 'en' ? t('n/a') : '0/' . (isset($groupsums[$group]) ? $groupsums[$group] : 0) . ' (0%)');
777 }
778 }
779
780 // Languages with at least one record in the locale table.
781 $translations = db_query("SELECT COUNT(*) AS translation, t.language, s.textgroup FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid GROUP BY textgroup, language");
782 foreach ($translations as $data) {
783 $ratio = (!empty($groupsums[$data->textgroup]) && $data->translation > 0) ? round(($data->translation/$groupsums[$data->textgroup]) * 100.0, 2) : 0;
784 $rows[$data->language][$data->textgroup] = $data->translation . '/' . $groupsums[$data->textgroup] . " ($ratio%)";
785 }
786
787 return theme('table', array('header' => $headers, 'rows' => $rows));
788 }
789
793 function locale_translate_seek_screen() {
794 // Add CSS.
795 drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
796
797 $elements = drupal_get_form('locale_translation_filter_form');
798 $output = drupal_render($elements);
799 $output .= _locale_translate_seek();
800 return $output;
801 }
802
806 function locale_translation_filters() {
807 $filters = array();
808
809 // Get all languages, except English
810 drupal_static_reset('language_list');
811 $languages = locale_language_list('name');
812 unset($languages['en']);
813
814 $filters['string'] = array(
815 'title' => t('String contains'),
816 'description' => t('Leave blank to show all strings. The search is case sensitive.'),
817 );
818
819 $filters['language'] = array(
820 'title' => t('Language'),
821 'options' => array_merge(array('all' => t('All languages'), 'en' => t('English (provided by Drupal)')), $languages),
822 );
823
824 $filters['translation'] = array(
825 'title' => t('Search in'),
826 'options' => array('all' => t('Both translated and untranslated strings'), 'translated' => t('Only translated strings'), 'untranslated' => t('Only untranslated strings')),
827 );
828
829 $groups = module_invoke_all('locale', 'groups');
830 $filters['group'] = array(
831 'title' => t('Limit search to'),
832 'options' => array_merge(array('all' => t('All text groups')), $groups),
833 );
834
835 return $filters;
836 }
837
843 function locale_translation_filter_form() {
844 $filters = locale_translation_filters();
845
846 $form['filters'] = array(
847 '#type' => 'fieldset',
848 '#title' => t('Filter translatable strings'),
849 '#collapsible' => TRUE,
850 '#collapsed' => FALSE,
851 );
852 foreach ($filters as $key => $filter) {
853 // Special case for 'string' filter.
854 if ($key == 'string') {
855 $form['filters']['status']['string'] = array(
856 '#type' => 'textfield',
857 '#title' => $filter['title'],
858 '#description' => $filter['description'],
859 );
860 }
861 else {
862 $form['filters']['status'][$key] = array(
863 '#title' => $filter['title'],
864 '#type' => 'select',
865 '#empty_value' => 'all',
866 '#empty_option' => $filter['options']['all'],
867 '#size' => 0,
868 '#options' => $filter['options'],
869 );
870 }
871 if (!empty($_SESSION['locale_translation_filter'][$key])) {
872 $form['filters']['status'][$key]['#default_value'] = $_SESSION['locale_translation_filter'][$key];
873 }
874 }
875
876 $form['filters']['actions'] = array(
877 '#type' => 'actions',
878 '#attributes' => array('class' => array('container-inline')),
879 );
880 $form['filters']['actions']['submit'] = array(
881 '#type' => 'submit',
882 '#value' => t('Filter'),
883 );
884 if (!empty($_SESSION['locale_translation_filter'])) {
885 $form['filters']['actions']['reset'] = array(
886 '#type' => 'submit',
887 '#value' => t('Reset')
888 );
889 }
890
891 return $form;
892 }
893
897 function locale_translation_filter_form_validate($form, &$form_state) {
898 if ($form_state['values']['op'] == t('Filter') && empty($form_state['values']['language']) && empty($form_state['values']['group'])) {
899 form_set_error('type', t('You must select something to filter by.'));
900 }
901 }
902
906 function locale_translation_filter_form_submit($form, &$form_state) {
907 $op = $form_state['values']['op'];
908 $filters = locale_translation_filters();
909 switch ($op) {
910 case t('Filter'):
911 foreach ($filters as $name => $filter) {
912 if (isset($form_state['values'][$name])) {
913 $_SESSION['locale_translation_filter'][$name] = $form_state['values'][$name];
914 }
915 }
916 break;
917 case t('Reset'):
918 $_SESSION['locale_translation_filter'] = array();
919 break;
920 }
921
922 $form_state['redirect'] = 'admin/config/regional/translate/translate';
923 }
924
928 function locale_translate_import_form($form) {
929 // Get all languages, except English
930 drupal_static_reset('language_list');
931 $names = locale_language_list('name');
932 unset($names['en']);
933
934 if (!count($names)) {
935 $languages = _locale_prepare_predefined_list();
936 $default = key($languages);
937 }
938 else {
939 $languages = array(
940 t('Already added languages') => $names,
941 t('Languages not yet added') => _locale_prepare_predefined_list()
942 );
943 $default = key($names);
944 }
945
946 $form['import'] = array('#type' => 'fieldset',
947 '#title' => t('Import translation'),
948 );
949 $form['import']['file'] = array('#type' => 'file',
950 '#title' => t('Language file'),
951 '#size' => 50,
952 '#description' => t('A Gettext Portable Object (<em>.po</em>) file.'),
953 );
954 $form['import']['langcode'] = array('#type' => 'select',
955 '#title' => t('Import into'),
956 '#options' => $languages,
957 '#default_value' => $default,
958 '#description' => t('Choose the language you want to add strings into. If you choose a language which is not yet set up, it will be added.'),
959 );
960 $form['import']['group'] = array('#type' => 'radios',
961 '#title' => t('Text group'),
962 '#default_value' => 'default',
963 '#options' => module_invoke_all('locale', 'groups'),
964 '#description' => t('Imported translations will be added to this text group.'),
965 );
966 $form['import']['mode'] = array('#type' => 'radios',
967 '#title' => t('Mode'),
968 '#default_value' => LOCALE_IMPORT_KEEP,
969 '#options' => array(
970 LOCALE_IMPORT_OVERWRITE => t('Strings in the uploaded file replace existing ones, new ones are added. The plural format is updated.'),
971 LOCALE_IMPORT_KEEP => t('Existing strings and the plural format are kept, only new strings are added.')
972 ),
973 );
974 $form['import']['submit'] = array('#type' => 'submit', '#value' => t('Import'));
975
976 return $form;
977 }
978
982 function locale_translate_import_form_submit($form, &$form_state) {
983 $validators = array('file_validate_extensions' => array('po'));
984 // Ensure we have the file uploaded
985 if ($file = file_save_upload('file', $validators)) {
986
987 // Add language, if not yet supported
988 drupal_static_reset('language_list');
989 $languages = language_list('language');
990 $langcode = $form_state['values']['langcode'];
991 if (!isset($languages[$langcode])) {
992 include_once DRUPAL_ROOT . '/includes/iso.inc';
993 $predefined = _locale_get_predefined_list();
994 locale_add_language($langcode);
995 drupal_set_message(t('The language %language has been created.', array('%language' => t($predefined[$langcode][0]))));
996 }
997
998 // Now import strings into the language
999 if ($return = _locale_import_po($file, $langcode, $form_state['values']['mode'], $form_state['values']['group']) == FALSE) {
1000 $variables = array('%filename' => $file->filename);
1001 drupal_set_message(t('The translation import of %filename failed.', $variables), 'error');
1002 watchdog('locale', 'The translation import of %filename failed.', $variables, WATCHDOG_ERROR);
1003 }
1004 }
1005 else {
1006 drupal_set_message(t('File to import not found.'), 'error');
1007 $form_state['redirect'] = 'admin/config/regional/translate/import';
1008 return;
1009 }
1010
1011 $form_state['redirect'] = 'admin/config/regional/translate';
1012 return;
1013 }
1014
1018 function locale_translate_export_screen() {
1019 // Get all languages, except English
1020 drupal_static_reset('language_list');
1021 $names = locale_language_list('name');
1022 unset($names['en']);
1023 $output = '';
1024 // Offer translation export if any language is set up.
1025 if (count($names)) {
1026 $elements = drupal_get_form('locale_translate_export_po_form', $names);
1027 $output = drupal_render($elements);
1028 }
1029 $elements = drupal_get_form('locale_translate_export_pot_form');
1030 $output .= drupal_render($elements);
1031 return $output;
1032 }
1033
1040 function locale_translate_export_po_form($form, &$form_state, $names) {
1041 $form['export_title'] = array('#type' => 'item',
1042 '#title' => t('Export translation'),
1043 );
1044 $form['langcode'] = array('#type' => 'select',
1045 '#title' => t('Language name'),
1046 '#options' => $names,
1047 '#description' => t('Select the language to export in Gettext Portable Object (<em>.po</em>) format.'),
1048 );
1049 $form['group'] = array('#type' => 'radios',
1050 '#title' => t('Text group'),
1051 '#default_value' => 'default',
1052 '#options' => module_invoke_all('locale', 'groups'),
1053 );
1054 $form['actions'] = array('#type' => 'actions');
1055 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Export'));
1056 return $form;
1057 }
1058
1062 function locale_translate_export_pot_form() {
1063 // Complete template export of the strings
1064 $form['export_title'] = array('#type' => 'item',
1065 '#title' => t('Export template'),
1066 '#description' => t('Generate a Gettext Portable Object Template (<em>.pot</em>) file with all strings from the Drupal locale database.'),
1067 );
1068 $form['group'] = array('#type' => 'radios',
1069 '#title' => t('Text group'),
1070 '#default_value' => 'default',
1071 '#options' => module_invoke_all('locale', 'groups'),
1072 );
1073 $form['actions'] = array('#type' => 'actions');
1074 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Export'));
1075 // Reuse PO export submission callback.
1076 $form['#submit'][] = 'locale_translate_export_po_form_submit';
1077 return $form;
1078 }
1079
1083 function locale_translate_export_po_form_submit($form, &$form_state) {
1084 // If template is required, language code is not given.
1085 $language = NULL;
1086 if (isset($form_state['values']['langcode'])) {
1087 $languages = language_list();
1088 $language = $languages[$form_state['values']['langcode']];
1089 }
1090 _locale_export_po($language, _locale_export_po_generate($language, _locale_export_get_strings($language, $form_state['values']['group'])));
1091 }
1108 function locale_translate_edit_form($form, &$form_state, $lid) {
1109 // Fetch source string, if possible.
1110 $source = db_query('SELECT source, context, textgroup, location FROM {locales_source} WHERE lid = :lid', array(':lid' => $lid))->fetchObject();
1111 if (!$source) {
1112 drupal_set_message(t('String not found.'), 'error');
1113 drupal_goto('admin/config/regional/translate/translate');
1114 }
1115
1116 // Add original text to the top and some values for form altering.
1117 $form['original'] = array(
1118 '#type' => 'item',
1119 '#title' => t('Original text'),
1120 '#markup' => check_plain(wordwrap($source->source, 0)),
1121 );
1122 if (!empty($source->context)) {
1123 $form['context'] = array(
1124 '#type' => 'item',
1125 '#title' => t('Context'),
1126 '#markup' => check_plain($source->context),
1127 );
1128 }
1129 $form['lid'] = array(
1130 '#type' => 'value',
1131 '#value' => $lid
1132 );
1133 $form['textgroup'] = array(
1134 '#type' => 'value',
1135 '#value' => $source->textgroup,
1136 );
1137 $form['location'] = array(
1138 '#type' => 'value',
1139 '#value' => $source->location
1140 );
1141
1142 // Include default form controls with empty values for all languages.
1143 // This ensures that the languages are always in the same order in forms.
1144 $languages = language_list();
1145 $default = language_default();
1146 // We don't need the default language value, that value is in $source.
1147 $omit = $source->textgroup == 'default' ? 'en' : $default->language;
1148 unset($languages[($omit)]);
1149 $form['translations'] = array('#tree' => TRUE);
1150 // Approximate the number of rows to use in the default textarea.
1151 $rows = min(ceil(str_word_count($source->source) / 12), 10);
1152 foreach ($languages as $langcode => $language) {
1153 $form['translations'][$langcode] = array(
1154 '#type' => 'textarea',
1155 '#title' => t($language->name),
1156 '#rows' => $rows,
1157 '#default_value' => '',
1158 );
1159 }
1160
1161 // Fetch translations and fill in default values in the form.
1162 $result = db_query("SELECT DISTINCT translation, language FROM {locales_target} WHERE lid = :lid AND language <> :omit", array(':lid' => $lid, ':omit' => $omit));
1163 foreach ($result as $translation) {
1164 $form['translations'][$translation->language]['#default_value'] = $translation->translation;
1165 }
1166
1167 $form['actions'] = array('#type' => 'actions');
1168 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save translations'));
1169 return $form;
1170 }
1171
1175 function locale_translate_edit_form_validate($form, &$form_state) {
1176 // Locale string check is needed for default textgroup only.
1177 $safe_check_needed = $form_state['values']['textgroup'] == 'default';
1178 foreach ($form_state['values']['translations'] as $key => $value) {
1179 if ($safe_check_needed && !locale_string_is_safe($value)) {
1180 form_set_error('translations', t('The submitted string contains disallowed HTML: %string', array('%string' => $value)));
1181 watchdog('locale', 'Attempted submission of a translation string with disallowed HTML: %string', array('%string' => $value), WATCHDOG_WARNING);
1182 }
1183 }
1184 }
1185
1191 function locale_translate_edit_form_submit($form, &$form_state) {
1192 $lid = $form_state['values']['lid'];
1193 foreach ($form_state['values']['translations'] as $key => $value) {
1194 $translation = db_query("SELECT translation FROM {locales_target} WHERE lid = :lid AND language = :language", array(':lid' => $lid, ':language' => $key))->fetchField();
1195 if (!empty($value)) {
1196 // Only update or insert if we have a value to use.
1197 if (!empty($translation)) {
1198 db_update('locales_target')
1199 ->fields(array(
1200 'translation' => $value,
1201 ))
1202 ->condition('lid', $lid)
1203 ->condition('language', $key)
1204 ->execute();
1205 }
1206 else {
1207 db_insert('locales_target')
1208 ->fields(array(
1209 'lid' => $lid,
1210 'translation' => $value,
1211 'language' => $key,
1212 ))
1213 ->execute();
1214 }
1215 }
1216 elseif (!empty($translation)) {
1217 // Empty translation entered: remove existing entry from database.
1218 db_delete('locales_target')
1219 ->condition('lid', $lid)
1220 ->condition('language', $key)
1221 ->execute();
1222 }
1223
1224 // Force JavaScript translation file recreation for this language.
1225 _locale_invalidate_js($key);
1226 }
1227
1228 drupal_set_message(t('The string has been saved.'));
1229
1230 // Clear locale cache.
1231 _locale_invalidate_js();
1232 cache_clear_all('locale:', 'cache', TRUE);
1233
1234 $form_state['redirect'] = 'admin/config/regional/translate/translate';
1235 return;
1236 }
1237
1241 function locale_translate_delete_page($lid) {
1242 if ($source = db_query('SELECT lid, source FROM {locales_source} WHERE lid = :lid', array(':lid' => $lid))->fetchObject()) {
1243 return drupal_get_form('locale_translate_delete_form', $source);
1244 }
1245 return MENU_NOT_FOUND;
1246 }
1247
1251 function locale_translate_delete_form($form, &$form_state, $source) {
1252 $form['lid'] = array('#type' => 'value', '#value' => $source->lid);
1253 return confirm_form($form, t('Are you sure you want to delete the string "%source"?', array('%source' => $source->source)), 'admin/config/regional/translate/translate', t('Deleting the string will remove all translations of this string in all languages. This action cannot be undone.'), t('Delete'), t('Cancel'));
1254 }
1255
1259 function locale_translate_delete_form_submit($form, &$form_state) {
1260 db_delete('locales_source')
1261 ->condition('lid', $form_state['values']['lid'])
1262 ->execute();
1263 db_delete('locales_target')
1264 ->condition('lid', $form_state['values']['lid'])
1265 ->execute();
1266 // Force JavaScript translation file recreation for all languages.
1267 _locale_invalidate_js();
1268 cache_clear_all('locale:', 'cache', TRUE);
1269 drupal_set_message(t('The string has been removed.'));
1270 $form_state['redirect'] = 'admin/config/regional/translate/translate';
1271 }
1285 function theme_locale_date_format_form($variables) {
1286 $form = $variables['form'];
1287 $header = array(
1288 t('Date type'),
1289 t('Format'),
1290 );
1291
1292 foreach (element_children($form['date_formats']) as $key) {
1293 $row = array();
1294 $row[] = $form['date_formats'][$key]['#title'];
1295 unset($form['date_formats'][$key]['#title']);
1296 $row[] = array('data' => drupal_render($form['date_formats'][$key]));
1297 $rows[] = $row;
1298 }
1299
1300 $output = drupal_render($form['language']);
1301 $output .= theme('table', array('header' => $header, 'rows' => $rows));
1302 $output .= drupal_render_children($form);
1303
1304 return $output;
1305 }
1306
1310 function locale_date_format_language_overview_page() {
1311 $header = array(
1312 t('Language'),
1313 array('data' => t('Operations'), 'colspan' => '2'),
1314 );
1315
1316 // Get list of languages.
1317 $languages = locale_language_list('native');
1318
1319 foreach ($languages as $langcode => $info) {
1320 $row = array();
1321 $row[] = $languages[$langcode];
1322 $row[] = l(t('edit'), 'admin/config/regional/date-time/locale/' . $langcode . '/edit');
1323 $row[] = l(t('reset'), 'admin/config/regional/date-time/locale/' . $langcode . '/reset');
1324 $rows[] = $row;
1325 }
1326
1327 return theme('table', array('header' => $header, 'rows' => $rows));
1328 }
1329
1333 function locale_date_format_form($form, &$form_state, $langcode) {
1334 $languages = locale_language_list('native');
1335 $language_name = $languages[$langcode];
1336
1337 // Display the current language name.
1338 $form['language'] = array(
1339 '#type' => 'item',
1340 '#title' => t('Language'),
1341 '#markup' => check_plain($language_name),
1342 '#weight' => -10,
1343 );
1344 $form['langcode'] = array(
1345 '#type' => 'value',
1346 '#value' => $langcode,
1347 );
1348
1349 // Get list of date format types.
1350 $types = system_get_date_types();
1351
1352 // Get list of available formats.
1353 $formats = system_get_date_formats();
1354 $choices = array();
1355 foreach ($formats as $type => $list) {
1356 foreach ($list as $f => $format) {
1357 $choices[$f] = format_date(REQUEST_TIME, 'custom', $f);
1358 }
1359 }
1360 reset($formats);
1361
1362 // Get configured formats for each language.
1363 $locale_formats = system_date_format_locale($langcode);
1364 // Display a form field for each format type.
1365 foreach ($types as $type => $type_info) {
1366 if (!empty($locale_formats) && in_array($type, array_keys($locale_formats))) {
1367 $default = $locale_formats[$type];
1368 }
1369 else {
1370 $default = variable_get('date_format_' . $type, key($formats));
1371 }
1372
1373 // Show date format select list.
1374 $form['date_formats']['date_format_' . $type] = array(
1375 '#type' => 'select',
1376 '#title' => check_plain($type_info['title']),
1377 '#attributes' => array('class' => array('date-format')),
1378 '#default_value' => (isset($choices[$default]) ? $default : 'custom'),
1379 '#options' => $choices,
1380 );
1381 }
1382
1383 $form['actions'] = array('#type' => 'actions');
1384 $form['actions']['submit'] = array(
1385 '#type' => 'submit',
1386 '#value' => t('Save configuration'),
1387 );
1388
1389 return $form;
1390 }
1391
1395 function locale_date_format_form_submit($form, &$form_state) {
1396 include_once DRUPAL_ROOT . '/includes/locale.inc';
1397 $langcode = $form_state['values']['langcode'];
1398
1399 // Get list of date format types.
1400 $types = system_get_date_types();
1401 foreach ($types as $type => $type_info) {
1402 $format = $form_state['values']['date_format_' . $type];
1403 if ($format == 'custom') {
1404 $format = $form_state['values']['date_format_' . $type . '_custom'];
1405 }
1406 locale_date_format_save($langcode, $type, $format);
1407 }
1408 drupal_set_message(t('Configuration saved.'));
1409 $form_state['redirect'] = 'admin/config/regional/date-time/locale';
1410 }
1411
1418 function locale_date_format_reset_form($form, &$form_state, $langcode) {
1419 $form['langcode'] = array('#type' => 'value', '#value' => $langcode);
1420 $languages = language_list();
1421 return confirm_form($form,
1422 t('Are you sure you want to reset the date formats for %language to the global defaults?', array('%language' => $languages[$langcode]->name)),
1423 'admin/config/regional/date-time/locale',
1424 t('Resetting will remove all localized date formats for this language. This action cannot be undone.'),
1425 t('Reset'), t('Cancel'));
1426 }
1427
1431 function locale_date_format_reset_form_submit($form, &$form_state) {
1432 db_delete('date_format_locale')
1433 ->condition('language', $form_state['values']['langcode'])
1434 ->execute();
1435 $form_state['redirect'] = 'admin/config/regional/date-time/locale';
1436 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
locale_languages_configure_form_submit
locale_languages_configure_form_submit($form, &$form_state)
Definition: locale.admin.inc:675
locale_translation_filter_form
locale_translation_filter_form()
Definition: locale.admin.inc:843
$op
$op
Definition: update.php:404
LANGUAGE_RTL
const LANGUAGE_RTL
Definition: bootstrap.inc:206
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN
const LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN
Definition: locale.inc:97
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
locale_languages_overview_form_submit
locale_languages_overview_form_submit($form, &$form_state)
Definition: locale.admin.inc:120
locale_translation_filters
locale_translation_filters()
Definition: locale.admin.inc:806
locale_date_format_form
locale_date_format_form($form, &$form_state, $langcode)
Definition: locale.admin.inc:1333
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
locale_date_format_form_submit
locale_date_format_form_submit($form, &$form_state)
Definition: locale.admin.inc:1395
locale_language_providers_session_form
locale_language_providers_session_form($form, &$form_state)
Definition: locale.admin.inc:727
locale_languages_edit_form
locale_languages_edit_form($form, &$form_state, $langcode)
Definition: locale.admin.inc:234
locale_language_list
locale_language_list($field= 'name', $all=FALSE)
Definition: locale.module:843
locale_language_providers_url_form
locale_language_providers_url_form($form, &$form_state)
Definition: locale.admin.inc:707
_locale_languages_configure_form_language_table
_locale_languages_configure_form_language_table(&$form, $type)
Definition: locale.admin.inc:525
_locale_rebuild_js
_locale_rebuild_js($langcode=NULL)
Definition: locale.inc:2003
locale_translate_export_screen
locale_translate_export_screen()
Definition: locale.admin.inc:1018
_locale_get_predefined_list
_locale_get_predefined_list()
Definition: iso.inc:291
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
locale_languages_predefined_form_validate
locale_languages_predefined_form_validate($form, &$form_state)
Definition: locale.admin.inc:324
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
locale_languages_overview_form
locale_languages_overview_form()
Definition: locale.admin.inc:20
$name
print $name
Definition: profile-listing.tpl.php:43
theme_locale_languages_configure_form
theme_locale_languages_configure_form($variables)
Definition: locale.admin.inc:614
name
print $forum name
Definition: forum-list.tpl.php:57
locale_translate_edit_form
locale_translate_edit_form($form, &$form_state, $lid)
Definition: locale.admin.inc:1108
locale_languages_edit_form_validate
locale_languages_edit_form_validate($form, &$form_state)
Definition: locale.admin.inc:375
$header
print $header
Definition: forum-topic-list.tpl.php:42
locale_languages_add_screen
locale_languages_add_screen()
Definition: locale.admin.inc:181
locale_languages_delete_form
locale_languages_delete_form($form, &$form_state, $langcode)
Definition: locale.admin.inc:432
locale_translate_export_po_form_submit
locale_translate_export_po_form_submit($form, &$form_state)
Definition: locale.admin.inc:1083
language_negotiation_set
language_negotiation_set($type, $language_providers)
Definition: language.inc:347
_locale_export_get_strings
_locale_export_get_strings($language=NULL, $group= 'default')
Definition: locale.inc:1613
language_provider_weight
language_provider_weight($provider)
Definition: language.inc:470
locale_translate_overview_screen
locale_translate_overview_screen()
Definition: locale.admin.inc:756
locale_translate_delete_page
locale_translate_delete_page($lid)
Definition: locale.admin.inc:1241
LANGUAGE_NEGOTIATION_DEFAULT
const LANGUAGE_NEGOTIATION_DEFAULT
Definition: language.inc:13
locale_translate_import_form_submit
locale_translate_import_form_submit($form, &$form_state)
Definition: locale.admin.inc:982
language_types_set
language_types_set()
Definition: language.inc:179
language_types_configurable
language_types_configurable($stored=TRUE)
Definition: language.inc:139
_locale_languages_common_controls
_locale_languages_common_controls(&$form, $language=NULL)
Definition: locale.admin.inc:260
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
MENU_NOT_FOUND
const MENU_NOT_FOUND
Definition: menu.inc:234
theme_locale_date_format_form
theme_locale_date_format_form($variables)
Definition: locale.admin.inc:1285
locale_string_is_safe
locale_string_is_safe($string)
Definition: locale.inc:525
locale_languages_predefined_form
locale_languages_predefined_form($form)
Definition: locale.admin.inc:190
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
locale_add_language
locale_add_language($langcode, $name=NULL, $native=NULL, $direction=LANGUAGE_LTR, $domain= '', $prefix= '', $enabled=TRUE, $default=FALSE)
Definition: locale.inc:559
batch_set
batch_set($batch_definition)
Definition: form.inc:4381
locale_translation_filter_form_submit
locale_translation_filter_form_submit($form, &$form_state)
Definition: locale.admin.inc:906
$info
$info
Definition: color.inc:6
theme_locale_languages_overview_form
theme_locale_languages_overview_form($variables)
Definition: locale.admin.inc:73
locale_translate_seek_screen
locale_translate_seek_screen()
Definition: locale.admin.inc:793
locale_translate_edit_form_validate
locale_translate_edit_form_validate($form, &$form_state)
Definition: locale.admin.inc:1175
language_list
language_list($field= 'language')
Definition: bootstrap.inc:2723
system_date_format_locale
system_date_format_locale($langcode=NULL, $type=NULL)
Definition: system.module:3645
$value
print $value
Definition: user-profile-item.tpl.php:26
locale_languages_delete_form_submit
locale_languages_delete_form_submit($form, &$form_state)
Definition: locale.admin.inc:461
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
LANGUAGE_LTR
const LANGUAGE_LTR
Definition: bootstrap.inc:201
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
locale_date_format_language_overview_page
locale_date_format_language_overview_page()
Definition: locale.admin.inc:1310
$output
$output
Definition: authorize.php:93
LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX
const LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX
Definition: locale.inc:91
locale_translate_export_pot_form
locale_translate_export_pot_form()
Definition: locale.admin.inc:1062
_locale_prepare_predefined_list
_locale_prepare_predefined_list()
Definition: locale.inc:2157
locale_translate_delete_form
locale_translate_delete_form($form, &$form_state, $source)
Definition: locale.admin.inc:1251
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
file_save_upload
file_save_upload($source, $validators=array(), $destination=FALSE, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1437
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
language_types_info
language_types_info()
Definition: language.inc:110
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
_locale_import_po
_locale_import_po($file, $langcode, $mode, $group=NULL)
Definition: locale.inc:633
LOCALE_IMPORT_OVERWRITE
const LOCALE_IMPORT_OVERWRITE
Definition: locale.inc:79
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
system_get_date_types
system_get_date_types($type=NULL)
Definition: system.module:3528
locale_date_format_reset_form_submit
locale_date_format_reset_form_submit($form, &$form_state)
Definition: locale.admin.inc:1431
locale_languages_configure_form
locale_languages_configure_form()
Definition: locale.admin.inc:498
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
locale_translate_edit_form_submit
locale_translate_edit_form_submit($form, &$form_state)
Definition: locale.admin.inc:1191
locale_languages_predefined_form_submit
locale_languages_predefined_form_submit($form, &$form_state)
Definition: locale.admin.inc:348
locale_date_format_save
locale_date_format_save($langcode, $type, $format)
Definition: locale.inc:2370
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
_locale_translate_seek
_locale_translate_seek()
Definition: locale.inc:1849
_locale_export_po
_locale_export_po($language=NULL, $output=NULL)
Definition: locale.inc:1746
drupal_exit
drupal_exit($destination=NULL)
Definition: common.inc:2721
language_negotiation_info
language_negotiation_info()
Definition: language.inc:392
LOCALE_IMPORT_KEEP
const LOCALE_IMPORT_KEEP
Definition: locale.inc:85
language_default
language_default($property=NULL)
Definition: bootstrap.inc:2765
locale_date_format_reset_form
locale_date_format_reset_form($form, &$form_state, $langcode)
Definition: locale.admin.inc:1418
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$row
$row
Definition: block-admin-display-form.tpl.php:47
locale_batch_by_language
locale_batch_by_language($langcode, $finished=NULL, $skip=array())
Definition: locale.inc:2207
element_child
element_child($key)
Definition: common.inc:6395
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
locale_languages_custom_form
locale_languages_custom_form($form)
Definition: locale.admin.inc:210
drupal_not_found
drupal_not_found()
Definition: common.inc:731
system_get_date_formats
system_get_date_formats($type=NULL)
Definition: system.module:3582
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
_locale_invalidate_js
_locale_invalidate_js($langcode=NULL)
Definition: locale.inc:1977
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
system_settings_form
system_settings_form($form)
Definition: system.module:2755
locale_translate_export_po_form
locale_translate_export_po_form($form, &$form_state, $names)
Definition: locale.admin.inc:1040
locale_translate_import_form
locale_translate_import_form($form)
Definition: locale.admin.inc:928
_locale_export_po_generate
_locale_export_po_generate($language=NULL, $strings=array(), $header=NULL)
Definition: locale.inc:1654
locale_translation_filter_form_validate
locale_translation_filter_form_validate($form, &$form_state)
Definition: locale.admin.inc:897
locale_languages_edit_form_submit
locale_languages_edit_form_submit($form, &$form_state)
Definition: locale.admin.inc:404
locale_translate_delete_form_submit
locale_translate_delete_form_submit($form, &$form_state)
Definition: locale.admin.inc:1259
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/templates/comment.tpl.php Source File

  • themes
  • bartik
  • templates
comment.tpl.php
Go to the documentation of this file.
1 <?php
2
59 ?>
60 <div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
61
62 <div class="attribution">
63
64 <?php print $picture; ?>
65
66 <div class="submitted">
67 <p class="commenter-name">
68 <?php print $author; ?>
69 </p>
70 <p class="comment-time">
71 <?php print $created; ?>
72 </p>
73 <p class="comment-permalink">
74 <?php print $permalink; ?>
75 </p>
76 </div>
77 </div>
78
79 <div class="comment-text">
80 <div class="comment-arrow"></div>
81
82 <?php if ($new): ?>
83 <span class="new"><?php print $new; ?></span>
84 <?php endif; ?>
85
86 <?php print render($title_prefix); ?>
87 <h3<?php print $title_attributes; ?>><?php print $title; ?></h3>
88 <?php print render($title_suffix); ?>
89
90 <div class="content"<?php print $content_attributes; ?>>
91 <?php
92 // We hide the comments and links now so that we can render them later.
93 hide($content['links']);
94 print render($content);
95 ?>
96 <?php if ($signature): ?>
97 <div class="user-signature clearfix">
98 <?php print $signature; ?>
99 </div>
100 <?php endif; ?>
101 </div> <!-- /.content -->
102
103 <?php print render($content['links']); ?>
104 </div> <!-- /.comment-text -->
105 </div>
$attributes
print $attributes
Definition: block.tpl.php:47
print
print
Definition: php-2.php:2
$content_attributes
print $content_attributes
Definition: block.tpl.php:55
$picture
print $picture
Definition: comment.tpl.php:64
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
$created
print $created
Definition: comment.tpl.php:71
hide
hide(&$element)
Definition: common.inc:6021
endif
endif
Definition: aggregator-item.tpl.php:31
$author
print $author
Definition: comment.tpl.php:68
render
render(&$element)
Definition: common.inc:5988
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
$permalink
print $permalink
Definition: comment.tpl.php:74
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/form_example/form_example.module Source File

  • examples
  • form_example
form_example.module
Go to the documentation of this file.
1 <?php
2
28 function form_example_menu() {
29 $items = array();
30 $items['examples/form_example'] = array(
31 'title' => 'Form Example',
32 'page callback' => 'form_example_intro',
33 'access callback' => TRUE,
34 'expanded' => TRUE,
35 );
36 $items['examples/form_example/tutorial'] = array(
37 'title' => 'Form Tutorial',
38 'page callback' => 'drupal_get_form',
39 'page arguments' => array('form_example_tutorial_1'),
40 'access callback' => TRUE,
41 'description' => 'A set of ten tutorials',
42 'file' => 'form_example_tutorial.inc',
43 'type' => MENU_NORMAL_ITEM,
44 );
45 $items['examples/form_example/tutorial/1'] = array(
46 'title' => '#1',
47 'page callback' => 'drupal_get_form',
48 'page arguments' => array('form_example_tutorial_1'),
49 'access callback' => TRUE,
50 'description' => 'Tutorial 1: Simplest form',
51 'type' => MENU_DEFAULT_LOCAL_TASK,
52 'file' => 'form_example_tutorial.inc',
53 );
54 $items['examples/form_example/tutorial/2'] = array(
55 'title' => '#2',
56 'page callback' => 'drupal_get_form',
57 'page arguments' => array('form_example_tutorial_2'),
58 'access callback' => TRUE,
59 'description' => 'Tutorial 2: Form with a submit button',
60 'type' => MENU_LOCAL_TASK,
61 'file' => 'form_example_tutorial.inc',
62 );
63 $items['examples/form_example/tutorial/3'] = array(
64 'title' => '#3',
65 'page callback' => 'drupal_get_form',
66 'page arguments' => array('form_example_tutorial_3'),
67 'access callback' => TRUE,
68 'description' => 'Tutorial 3: Fieldsets',
69 'type' => MENU_LOCAL_TASK,
70 'file' => 'form_example_tutorial.inc',
71 );
72 $items['examples/form_example/tutorial/4'] = array(
73 'title' => '#4',
74 'page callback' => 'drupal_get_form',
75 'page arguments' => array('form_example_tutorial_4'),
76 'access callback' => TRUE,
77 'description' => 'Tutorial 4: Required fields',
78 'type' => MENU_LOCAL_TASK,
79 'file' => 'form_example_tutorial.inc',
80 );
81 $items['examples/form_example/tutorial/5'] = array(
82 'title' => '#5',
83 'page callback' => 'drupal_get_form',
84 'page arguments' => array('form_example_tutorial_5'),
85 'access callback' => TRUE,
86 'description' => 'Tutorial 5: More element attributes',
87 'type' => MENU_LOCAL_TASK,
88 'file' => 'form_example_tutorial.inc',
89 );
90 $items['examples/form_example/tutorial/6'] = array(
91 'title' => '#6',
92 'page callback' => 'drupal_get_form',
93 'page arguments' => array('form_example_tutorial_6'),
94 'access callback' => TRUE,
95 'description' => 'Tutorial 6: Form with a validate handler',
96 'type' => MENU_LOCAL_TASK,
97 'file' => 'form_example_tutorial.inc',
98 );
99 $items['examples/form_example/tutorial/7'] = array(
100 'title' => '#7',
101 'page callback' => 'drupal_get_form',
102 'page arguments' => array('form_example_tutorial_7'),
103 'access callback' => TRUE,
104 'description' => 'Tutorial 7: Form with a submit handler',
105 'type' => MENU_LOCAL_TASK,
106 'file' => 'form_example_tutorial.inc',
107 );
108 $items['examples/form_example/tutorial/8'] = array(
109 'title' => '#8',
110 'page callback' => 'drupal_get_form',
111 'page arguments' => array('form_example_tutorial_8'),
112 'access callback' => TRUE,
113 'description' => 'Tutorial 8: Basic multistep form',
114 'type' => MENU_LOCAL_TASK,
115 'file' => 'form_example_tutorial.inc',
116 );
117 $items['examples/form_example/tutorial/9'] = array(
118 'title' => '#9',
119 'page callback' => 'drupal_get_form',
120 'page arguments' => array('form_example_tutorial_9'),
121 'access callback' => TRUE,
122 'description' => 'Tutorial 9: Form with dynamically added new fields',
123 'type' => MENU_LOCAL_TASK,
124 'file' => 'form_example_tutorial.inc',
125 'weight' => 9,
126 );
127 $items['examples/form_example/tutorial/10'] = array(
128 'title' => '#10',
129 'page callback' => 'drupal_get_form',
130 'page arguments' => array('form_example_tutorial_10'),
131 'access callback' => TRUE,
132 'description' => 'Tutorial 11: Form with file upload',
133 'type' => MENU_LOCAL_TASK,
134 'file' => 'form_example_tutorial.inc',
135 'weight' => 10,
136 );
137 $items['examples/form_example/states'] = array(
138 'title' => '#states example',
139 'page callback' => 'drupal_get_form',
140 'page arguments' => array('form_example_states_form'),
141 'access callback' => TRUE,
142 'description' => 'How to use the #states attribute in FAPI',
143 'file' => 'form_example_states.inc',
144 );
145 $items['examples/form_example/wizard'] = array(
146 'title' => 'Extensible wizard example',
147 'page callback' => 'drupal_get_form',
148 'page arguments' => array('form_example_wizard'),
149 'access callback' => TRUE,
150 'description' => 'A general approach to a wizard multistep form.',
151 'file' => 'form_example_wizard.inc',
152 );
153 $items['examples/form_example/element_example'] = array(
154 'title' => 'Element example',
155 'page callback' => 'drupal_get_form',
156 'page arguments' => array('form_example_element_demo_form'),
157 'access callback' => TRUE,
158 'file' => 'form_example_elements.inc',
159 'weight' => 100,
160 );
161
162 return $items;
163 }
164
168 function form_example_intro() {
169 $markup = t('The form example module provides a tutorial, extensible multistep example, an element example, and a #states example');
170 return array('#markup' => $markup);
171 }
172
176 function form_example_help($path, $arg) {
177 switch ($path) {
178 case 'examples/form_example/tutorial':
179 // TODO: Update the URL.
180 $help = t('This form example tutorial for Drupal 7 is the code from the <a href="http://drupal.org/node/262422">Handbook 10-step tutorial</a>');
181 break;
182 case 'examples/form_example/element_example':
183 $help = t('The Element Example shows how modules can provide their own Form API element types. Four different element types are demonstrated.');
184 break;
185 }
186 if (!empty($help)) {
187 return '<p>' . $help . '</p>';
188 }
189 }
190
197 function form_example_element_info() {
198 require_once('form_example_elements.inc');
199 return _form_example_element_info();
200 }
201
209 function form_example_theme($existing, $type, $theme, $path) {
210 require_once('form_example_elements.inc');
211 return _form_example_element_theme($existing, $type, $theme, $path);
212 }
_form_example_element_info
_form_example_element_info()
Definition: form_example_elements.inc:77
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
MENU_NORMAL_ITEM
const MENU_NORMAL_ITEM
Definition: menu.inc:143
form_example_help
form_example_help($path, $arg)
Definition: form_example.module:176
form_example_element_info
form_example_element_info()
Definition: form_example.module:197
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
form_example_intro
form_example_intro()
Definition: form_example.module:168
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
form_example_theme
form_example_theme($existing, $type, $theme, $path)
Definition: form_example.module:209
_form_example_element_theme
_form_example_element_theme()
Definition: form_example_elements.inc:361
form_example_menu
form_example_menu()
Definition: form_example.module:28
$help
print $help
Definition: maintenance-page.tpl.php:69
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DatabaseLog Member List

This is the complete list of members for DatabaseLog, including all inherited members.

$connectionKey | DatabaseLog | protected
$queryLog | DatabaseLog | protected
__construct($key= 'default') | DatabaseLog |
clear($logging_key) | DatabaseLog |
end($logging_key) | DatabaseLog |
findCaller() | DatabaseLog |
get($logging_key) | DatabaseLog |
log(DatabaseStatementInterface $statement, $args, $time) | DatabaseLog |
start($logging_key) | DatabaseLog |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book.install Source File

  • modules
  • book
book.install
Go to the documentation of this file.
1 <?php
2
11 function book_install() {
12 // Add the node type.
13 _book_install_type_create();
14 }
15
19 function book_uninstall() {
20 variable_del('book_allowed_types');
21 variable_del('book_child_type');
22 variable_del('book_block_mode');
23
24 // Delete menu links.
25 db_delete('menu_links')
26 ->condition('module', 'book')
27 ->execute();
28 menu_cache_clear_all();
29 }
30
34 function _book_install_type_create() {
35 // Create an additional node type.
36 $book_node_type = array(
37 'type' => 'book',
38 'name' => t('Book page'),
39 'base' => 'node_content',
40 'description' => t('<em>Books</em> have a built-in hierarchical navigation. Use for handbooks or tutorials.'),
41 'custom' => 1,
42 'modified' => 1,
43 'locked' => 0,
44 );
45
46 $book_node_type = node_type_set_defaults($book_node_type);
47 node_type_save($book_node_type);
48 node_add_body_field($book_node_type);
49 // Default to not promoted.
50 variable_set('node_options_book', array('status'));
51 // Use this default type for adding content to books.
52 variable_set('book_allowed_types', array('book'));
53 variable_set('book_child_type', 'book');
54 }
55
59 function book_schema() {
60 $schema['book'] = array(
61 'description' => 'Stores book outline information. Uniquely connects each node in the outline to a link in {menu_links}',
62 'fields' => array(
63 'mlid' => array(
64 'type' => 'int',
65 'unsigned' => TRUE,
66 'not null' => TRUE,
67 'default' => 0,
68 'description' => "The book page's {menu_links}.mlid.",
69 ),
70 'nid' => array(
71 'type' => 'int',
72 'unsigned' => TRUE,
73 'not null' => TRUE,
74 'default' => 0,
75 'description' => "The book page's {node}.nid.",
76 ),
77 'bid' => array(
78 'type' => 'int',
79 'unsigned' => TRUE,
80 'not null' => TRUE,
81 'default' => 0,
82 'description' => "The book ID is the {book}.nid of the top-level page.",
83 ),
84 ),
85 'primary key' => array('mlid'),
86 'unique keys' => array(
87 'nid' => array('nid'),
88 ),
89 'indexes' => array(
90 'bid' => array('bid'),
91 ),
92 );
93
94 return $schema;
95 }
node_type_save
node_type_save($info)
Definition: node.module:525
book_install
book_install()
Definition: book.install:11
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
node_type_set_defaults
node_type_set_defaults($info=array())
Definition: node.module:805
node_add_body_field
node_add_body_field($type, $label= 'Body')
Definition: node.module:586
book_schema
book_schema()
Definition: book.install:59
menu_cache_clear_all
menu_cache_clear_all()
Definition: menu.inc:2678
book_uninstall
book_uninstall()
Definition: book.install:19
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
_book_install_type_create
_book_install_type_create()
Definition: book.install:34
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/tracker/tracker.pages.inc Source File

  • modules
  • tracker
tracker.pages.inc
Go to the documentation of this file.
1 <?php
2
15 function tracker_page($account = NULL, $set_title = FALSE) {
16 if ($account) {
17 $query = db_select('tracker_user', 't')->extend('PagerDefault');
18 $query->condition('t.uid', $account->uid);
19
20 if ($set_title) {
21 // When viewed from user/%user/track, display the name of the user
22 // as page title -- the tab title remains Track so this needs to be done
23 // here and not in the menu definition.
24 drupal_set_title(format_username($account));
25 }
26 }
27 else {
28 $query = db_select('tracker_node', 't', array('target' => 'slave'))->extend('PagerDefault');
29 }
30
31 // This array acts as a placeholder for the data selected later
32 // while keeping the correct order.
33 $nodes = $query
34 ->addTag('node_access')
35 ->fields('t', array('nid', 'changed'))
36 ->condition('t.published', 1)
37 ->orderBy('t.changed', 'DESC')
38 ->limit(25)
39 ->execute()
40 ->fetchAllAssoc('nid');
41
42 $rows = array();
43 if (!empty($nodes)) {
44 // Now, get the data and put into the placeholder array.
45 $result = db_query('SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid WHERE n.nid IN (:nids)', array(':nids' => array_keys($nodes)), array('target' => 'slave'));
46 foreach ($result as $node) {
47 $node->last_activity = $nodes[$node->nid]->changed;
48 $nodes[$node->nid] = $node;
49 }
50
51 // Display the data.
52 foreach ($nodes as $node) {
53 // Determine the number of comments.
54 $comments = 0;
55 if ($node->comment_count) {
56 $comments = $node->comment_count;
57
58 if ($new = comment_num_new($node->nid)) {
59 $comments .= '<br />';
60 $comments .= l(format_plural($new, '1 new', '@count new'), 'node/' . $node->nid, array('fragment' => 'new'));
61 }
62 }
63
64 $row = array(
65 'type' => check_plain(node_type_get_name($node->type)),
66 'title' => array('data' => l($node->title, 'node/' . $node->nid) . ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed)))),
67 'author' => array('data' => theme('username', array('account' => $node))),
68 'replies' => array('class' => array('replies'), 'data' => $comments),
69 'last updated' => array('data' => t('!time ago', array('!time' => format_interval(REQUEST_TIME - $node->last_activity)))),
70 );
71
72 // Adds extra RDFa markup to the $row array if the RDF module is enabled.
73 if (function_exists('rdf_mapping_load')) {
74 // Each node is not loaded for performance reasons, as a result we need
75 // to retrieve the RDF mapping for each node type.
76 $mapping = rdf_mapping_load('node', $node->type);
77 // Adds RDFa markup to the title of the node. Because the RDFa markup is
78 // added to the td tag which might contain HTML code, we specify an
79 // empty datatype to ensure the value of the title read by the RDFa
80 // parsers is a plain literal.
81 $row['title'] += rdf_rdfa_attributes($mapping['title']) + array('datatype' => '');
82 // Annotates the td tag containing the author of the node.
83 $row['author'] += rdf_rdfa_attributes($mapping['uid']);
84 // Annotates the td tag containing the number of replies. We add the
85 // content attribute to ensure that only the comment count is used as
86 // the value for 'num_replies'. Otherwise, other text such as a link
87 // to the number of new comments could be included in the 'num_replies'
88 // value.
89 $row['replies'] += rdf_rdfa_attributes($mapping['comment_count']);
90 $row['replies'] += array('content' => $node->comment_count);
91 // If the node has no comments, we assume the node itself was modified
92 // and apply 'changed' in addition to 'last_activity'. If there are
93 // comments present, we cannot infer whether the node itself was
94 // modified or a comment was posted, so we use only 'last_activity'.
95 $mapping_last_activity = rdf_rdfa_attributes($mapping['last_activity'], $node->last_activity);
96 if ($node->comment_count == 0) {
97 $mapping_changed = rdf_rdfa_attributes($mapping['changed'], $node->last_activity);
98 $mapping_last_activity['property'] = array_merge($mapping_last_activity['property'], $mapping_changed['property']);
99 }
100 $row['last updated'] += $mapping_last_activity;
101
102 // We need to add the about attribute on the tr tag to specify which
103 // node the RDFa annotations above apply to. We move the content of
104 // $row to a 'data' sub array so we can specify attributes for the row.
105 $row = array('data' => $row);
106 $row['about'] = url('node/' . $node->nid);
107 }
108 $rows[] = $row;
109 }
110 }
111
112 $page['tracker'] = array(
113 '#rows' => $rows,
114 '#header' => array(t('Type'), t('Title'), t('Author'), t('Replies'), t('Last updated')),
115 '#theme' => 'table',
116 '#empty' => t('No content available.'),
117 '#attached' => array(
118 'css' => array(drupal_get_path('module', 'tracker') . '/tracker.css' => array()),
119 ),
120 );
121 $page['pager'] = array(
122 '#theme' => 'pager',
123 '#quantity' => 25,
124 '#weight' => 10,
125 );
126 $page['#sorted'] = TRUE;
127
128 return $page;
129 }
rdf_mapping_load
rdf_mapping_load($type, $bundle=RDF_DEFAULT_BUNDLE)
Definition: rdf.module:133
tracker_page
tracker_page($account=NULL, $set_title=FALSE)
Definition: tracker.pages.inc:15
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
format_username
format_username($account)
Definition: common.inc:2106
$page
print $page
Definition: overlay.tpl.php:37
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
node_type_get_name
node_type_get_name($node)
Definition: node.module:459
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
node_mark
node_mark($nid, $timestamp)
Definition: node.module:350
comment_num_new
comment_num_new($nid, $timestamp=0)
Definition: comment.module:1729
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
rdf_rdfa_attributes
rdf_rdfa_attributes($mapping, $data=NULL)
Definition: rdf.module:291
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$row
$row
Definition: block-admin-display-form.tpl.php:47
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/maintenance-page.tpl.php Source File

  • themes
  • garland
maintenance-page.tpl.php
Go to the documentation of this file.
1 <?php
2
14 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
15 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
16 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
17 <head>
18 <title><?php print $head_title ?></title>
19 <?php print $head ?>
20 <?php print $styles ?>
21 <?php print $scripts ?>
22 </head>
23 <body class="<?php print $classes ?>">
24
25 <!-- Layout -->
26 <div id="header-region" class="clearfix"><?php print $header; ?></div>
27
28 <div id="wrapper">
29 <div id="container" class="clearfix">
30
31 <div id="header">
32 <div id="logo-floater">
33 <?php
34 // Prepare header
35 $site_fields = array();
36 if ($site_name) {
37 $site_fields[] = $site_name;
38 }
39 if ($site_slogan) {
40 $site_fields[] = $site_slogan;
41 }
42 $site_title = implode(' ', $site_fields);
43 if ($site_fields) {
44 $site_fields[0] = '<span>' . $site_fields[0] . '</span>';
45 }
46 $site_html = implode(' ', $site_fields);
47
48 if ($logo || $site_title) {
49 print '<h1 id="branding"><a href="' . $base_path . '" title="' . $site_title . '">';
50 if ($logo) {
51 print '<img src="' . $logo . '" alt="' . $site_title . '" id="logo" />';
52 }
53 print $site_html . '</a></h1>';
54 }
55 ?>
56 </div>
57
58 </div> <!-- /header -->
59
60 <?php if ($sidebar_first): ?>
61 <div id="sidebar-first" class="sidebar">
62 <?php print $sidebar_first ?>
63 </div>
64 <?php endif; ?>
65
66 <div id="center"><div id="squeeze"><div class="right-corner"><div class="left-corner">
67 <?php if ($title): ?><h2><?php print $title ?></h2><?php endif; ?>
68 <?php print $messages; ?>
69 <?php print $help; ?>
70 <div class="clearfix">
71 <?php print $content ?>
72 </div>
73 <div id="footer"><?php print $footer ?></div>
74 </div></div></div></div> <!-- /.left-corner, /.right-corner, /#squeeze, /#center -->
75
76 <?php if ($sidebar_second): ?>
77 <div id="sidebar-second" class="sidebar">
78 <?php print $sidebar_second ?>
79 </div>
80 <?php endif; ?>
81
82 </div> <!-- /container -->
83 </div>
84 <!-- /layout -->
85
86 </body>
87 </html>
dir
print $language dir
Definition: html.tpl.php:47
$head
print $head
Definition: book-export-html.tpl.php:25
$header
print $header
Definition: forum-topic-list.tpl.php:42
print
print
Definition: php-2.php:2
$logo
print $logo
Definition: maintenance-page.tpl.php:33
$site_slogan
if($site_slogan)($hide_site_slogan) print $site_slogan
Definition: maintenance-page.tpl.php:41
$scripts
print $scripts
Definition: html.tpl.php:53
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
$site_html
if($site_fields) $site_html
Definition: maintenance-page.tpl.php:46
endif
endif
Definition: aggregator-item.tpl.php:31
$messages
print $messages
Definition: page.tpl.php:121
$site_title
if($site_name) if($site_slogan) $site_title
Definition: maintenance-page.tpl.php:42
$site_fields
$site_fields
Definition: maintenance-page.tpl.php:35
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
$styles
print $styles
Definition: html.tpl.php:52
title
print $topic title
Definition: forum-topic-list.tpl.php:50
$help
print $help
Definition: maintenance-page.tpl.php:69
$head_title
print $head_title
Definition: html.tpl.php:51
$site_name
print $site_name
Definition: maintenance-page.tpl.php:40
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/seven/page.tpl.php Source File

  • themes
  • seven
page.tpl.php
Go to the documentation of this file.
1
2 <div id="branding" class="clearfix">
3 <?php print $breadcrumb; ?>
4 <?php print render($title_prefix); ?>
5 <?php if ($title): ?>
6 <h1 class="page-title"><?php print $title; ?></h1>
7 <?php endif; ?>
8 <?php print render($title_suffix); ?>
9 <?php print render($primary_local_tasks); ?>
10 </div>
11
12 <div id="page">
13 <?php if ($secondary_local_tasks): ?>
14 <div class="tabs-secondary clearfix"><?php print render($secondary_local_tasks); ?></div>
15 <?php endif; ?>
16
17 <div id="content" class="clearfix">
18 <div class="element-invisible"><a id="main-content"></a></div>
19 <?php if ($messages): ?>
20 <div id="console" class="clearfix"><?php print $messages; ?></div>
21 <?php endif; ?>
22 <?php if ($page['help']): ?>
23 <div id="help">
24 <?php print render($page['help']); ?>
25 </div>
26 <?php endif; ?>
27 <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?>
28 <?php print render($page['content']); ?>
29 </div>
30
31 <div id="footer">
32 <?php print $feed_icons; ?>
33 </div>
34
35 </div>
$page
print $page
Definition: overlay.tpl.php:37
print
print
Definition: php-2.php:2
$feed_icons
print $feed_icons
Definition: page.tpl.php:135
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
endif
endif
Definition: aggregator-item.tpl.php:31
$messages
print $messages
Definition: page.tpl.php:121
render
render(&$element)
Definition: common.inc:5988
$breadcrumb
print $breadcrumb
Definition: page.tpl.php:40
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
FileTransferFTP Member List

This is the complete list of members for FileTransferFTP, including all inherited members.

$hostname | FileTransfer | protected
$password | FileTransfer | protected
$port | FileTransfer | protected
$username | FileTransfer | protected
__construct($jail, $username, $password, $hostname, $port) | FileTransferFTP |
FileTransfer::__construct($jail) | FileTransfer |
__get($name) | FileTransfer |
checkPath($path) | FileTransfer | protected
chmod($path, $mode, $recursive=FALSE) | FileTransfer |
connect() | FileTransfer | protected
copyDirectory($source, $destination) | FileTransfer |
copyDirectoryJailed($source, $destination) | FileTransfer | protected
copyFile($source, $destination) | FileTransfer |
copyFileJailed($source, $destination) | FileTransfer | protected
createDirectory($directory) | FileTransfer |
createDirectoryJailed($directory) | FileTransfer | protected
factory($jail, $settings) | FileTransferFTP | static
findChroot() | FileTransfer |
fixRemotePath($path, $strip_chroot=TRUE) | FileTransfer | protected
getSettingsForm() | FileTransferFTP |
isDirectory($path) | FileTransfer |
isFile($path) | FileTransfer |
removeDirectory($directory) | FileTransfer |
removeDirectoryJailed($directory) | FileTransfer | protected
removeFile($destination) | FileTransfer |
removeFileJailed($destination) | FileTransfer | protected
sanitizePath($path) | FileTransfer |
setChroot() | FileTransfer |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/path/path.api.php Source File

  • modules
  • path
path.api.php
Go to the documentation of this file.
1 <?php
2
25 function hook_path_insert($path) {
26 db_insert('mytable')
27 ->fields(array(
28 'alias' => $path['alias'],
29 'pid' => $path['pid'],
30 ))
31 ->execute();
32 }
33
46 function hook_path_update($path) {
47 db_update('mytable')
48 ->fields(array('alias' => $path['alias']))
49 ->condition('pid', $path['pid'])
50 ->execute();
51 }
52
65 function hook_path_delete($path) {
66 db_delete('mytable')
67 ->condition('pid', $path['pid'])
68 ->execute();
69 }
70
hook_path_update
hook_path_update($path)
Definition: path.api.php:46
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
hook_path_insert
hook_path_insert($path)
Definition: path.api.php:25
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
hook_path_delete
hook_path_delete($path)
Definition: path.api.php:65
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
ArchiverTar Member List

This is the complete list of members for ArchiverTar, including all inherited members.

$tar | ArchiverTar | protected
__construct($file_path) | ArchiverTar |
add($file_path) | ArchiverTar |
extract($path, Array $files=array()) | ArchiverTar |
ArchiverInterface::extract($path, array $files=array()) | ArchiverInterface |
getArchive() | ArchiverTar |
listContents() | ArchiverTar |
remove($file_path) | ArchiverTar |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/field_sql_storage/field_sql_storage.module Source File

  • modules
  • field
  • modules
  • field_sql_storage
field_sql_storage.module
Go to the documentation of this file.
1 <?php
2
11 function field_sql_storage_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#field_sql_storage':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t('The Field SQL storage module stores field data in the database. It is the default field storage module; other field storage mechanisms may be available as contributed modules. See the <a href="@field-help">Field module help page</a> for more information about fields.', array('@field-help' => url('admin/help/field'))) . '</p>';
17 return $output;
18 }
19 }
20
24 function field_sql_storage_field_storage_info() {
25 return array(
26 'field_sql_storage' => array(
27 'label' => t('Default SQL storage'),
28 'description' => t('Stores fields in the local SQL database, using per-field tables.'),
29 ),
30 );
31 }
32
41 function _field_sql_storage_tablename($field) {
42 if ($field['deleted']) {
43 return "field_deleted_data_{$field['id']}";
44 }
45 else {
46 return "field_data_{$field['field_name']}";
47 }
48 }
49
58 function _field_sql_storage_revision_tablename($field) {
59 if ($field['deleted']) {
60 return "field_deleted_revision_{$field['id']}";
61 }
62 else {
63 return "field_revision_{$field['field_name']}";
64 }
65 }
66
78 function _field_sql_storage_columnname($name, $column) {
79 return $name . '_' . $column;
80 }
81
93 function _field_sql_storage_indexname($name, $index) {
94 return $name . '_' . $index;
95 }
96
108 function _field_sql_storage_schema($field) {
109 $deleted = $field['deleted'] ? 'deleted ' : '';
110 $current = array(
111 'description' => "Data storage for {$deleted}field {$field['id']} ({$field['field_name']})",
112 'fields' => array(
113 'entity_type' => array(
114 'type' => 'varchar',
115 'length' => 128,
116 'not null' => TRUE,
117 'default' => '',
118 'description' => 'The entity type this data is attached to',
119 ),
120 'bundle' => array(
121 'type' => 'varchar',
122 'length' => 128,
123 'not null' => TRUE,
124 'default' => '',
125 'description' => 'The field instance bundle to which this row belongs, used when deleting a field instance',
126 ),
127 'deleted' => array(
128 'type' => 'int',
129 'size' => 'tiny',
130 'not null' => TRUE,
131 'default' => 0,
132 'description' => 'A boolean indicating whether this data item has been deleted'
133 ),
134 'entity_id' => array(
135 'type' => 'int',
136 'unsigned' => TRUE,
137 'not null' => TRUE,
138 'description' => 'The entity id this data is attached to',
139 ),
140 'revision_id' => array(
141 'type' => 'int',
142 'unsigned' => TRUE,
143 'not null' => FALSE,
144 'description' => 'The entity revision id this data is attached to, or NULL if the entity type is not versioned',
145 ),
146 // @todo Consider storing language as integer.
147 'language' => array(
148 'type' => 'varchar',
149 'length' => 32,
150 'not null' => TRUE,
151 'default' => '',
152 'description' => 'The language for this data item.',
153 ),
154 'delta' => array(
155 'type' => 'int',
156 'unsigned' => TRUE,
157 'not null' => TRUE,
158 'description' => 'The sequence number for this data item, used for multi-value fields',
159 ),
160 ),
161 'primary key' => array('entity_type', 'entity_id', 'deleted', 'delta', 'language'),
162 'indexes' => array(
163 'entity_type' => array('entity_type'),
164 'bundle' => array('bundle'),
165 'deleted' => array('deleted'),
166 'entity_id' => array('entity_id'),
167 'revision_id' => array('revision_id'),
168 'language' => array('language'),
169 ),
170 );
171
172 $field += array('columns' => array(), 'indexes' => array(), 'foreign keys' => array());
173 // Add field columns.
174 foreach ($field['columns'] as $column_name => $attributes) {
175 $real_name = _field_sql_storage_columnname($field['field_name'], $column_name);
176 $current['fields'][$real_name] = $attributes;
177 }
178
179 // Add indexes.
180 foreach ($field['indexes'] as $index_name => $columns) {
181 $real_name = _field_sql_storage_indexname($field['field_name'], $index_name);
182 foreach ($columns as $column_name) {
183 $current['indexes'][$real_name][] = _field_sql_storage_columnname($field['field_name'], $column_name);
184 }
185 }
186
187 // Add foreign keys.
188 foreach ($field['foreign keys'] as $specifier => $specification) {
189 $real_name = _field_sql_storage_indexname($field['field_name'], $specifier);
190 $current['foreign keys'][$real_name]['table'] = $specification['table'];
191 foreach ($specification['columns'] as $column_name => $referenced) {
192 $sql_storage_column = _field_sql_storage_columnname($field['field_name'], $column_name);
193 $current['foreign keys'][$real_name]['columns'][$sql_storage_column] = $referenced;
194 }
195 }
196
197 // Construct the revision table.
198 $revision = $current;
199 $revision['description'] = "Revision archive storage for {$deleted}field {$field['id']} ({$field['field_name']})";
200 $revision['primary key'] = array('entity_type', 'entity_id', 'revision_id', 'deleted', 'delta', 'language');
201 $revision['fields']['revision_id']['not null'] = TRUE;
202 $revision['fields']['revision_id']['description'] = 'The entity revision id this data is attached to';
203
204 return array(
205 _field_sql_storage_tablename($field) => $current,
206 _field_sql_storage_revision_tablename($field) => $revision,
207 );
208 }
209
213 function field_sql_storage_field_storage_create_field($field) {
214 $schema = _field_sql_storage_schema($field);
215 foreach ($schema as $name => $table) {
216 db_create_table($name, $table);
217 }
218 drupal_get_schema(NULL, TRUE);
219 }
220
227 function field_sql_storage_field_update_forbid($field, $prior_field, $has_data) {
228 if ($has_data && $field['columns'] != $prior_field['columns']) {
229 throw new FieldUpdateForbiddenException("field_sql_storage cannot change the schema for an existing field with data.");
230 }
231 }
232
236 function field_sql_storage_field_storage_update_field($field, $prior_field, $has_data) {
237 if (! $has_data) {
238 // There is no data. Re-create the tables completely.
239
240 if (Database::getConnection()->supportsTransactionalDDL()) {
241 // If the database supports transactional DDL, we can go ahead and rely
242 // on it. If not, we will have to rollback manually if something fails.
243 $transaction = db_transaction();
244 }
245
246 try {
247 $prior_schema = _field_sql_storage_schema($prior_field);
248 foreach ($prior_schema as $name => $table) {
249 db_drop_table($name, $table);
250 }
251 $schema = _field_sql_storage_schema($field);
252 foreach ($schema as $name => $table) {
253 db_create_table($name, $table);
254 }
255 }
256 catch (Exception $e) {
257 if (Database::getConnection()->supportsTransactionalDDL()) {
258 $transaction->rollback();
259 }
260 else {
261 // Recreate tables.
262 $prior_schema = _field_sql_storage_schema($prior_field);
263 foreach ($prior_schema as $name => $table) {
264 if (!db_table_exists($name)) {
265 db_create_table($name, $table);
266 }
267 }
268 }
269 throw $e;
270 }
271 }
272 else {
273 // There is data, so there are no column changes. Drop all the
274 // prior indexes and create all the new ones, except for all the
275 // priors that exist unchanged.
276 $table = _field_sql_storage_tablename($prior_field);
277 $revision_table = _field_sql_storage_revision_tablename($prior_field);
278 foreach ($prior_field['indexes'] as $name => $columns) {
279 if (!isset($field['indexes'][$name]) || $columns != $field['indexes'][$name]) {
280 $real_name = _field_sql_storage_indexname($field['field_name'], $name);
281 db_drop_index($table, $real_name);
282 db_drop_index($revision_table, $real_name);
283 }
284 }
285 $table = _field_sql_storage_tablename($field);
286 $revision_table = _field_sql_storage_revision_tablename($field);
287 foreach ($field['indexes'] as $name => $columns) {
288 if (!isset($prior_field['indexes'][$name]) || $columns != $prior_field['indexes'][$name]) {
289 $real_name = _field_sql_storage_indexname($field['field_name'], $name);
290 $real_columns = array();
291 foreach ($columns as $column_name) {
292 $real_columns[] = _field_sql_storage_columnname($field['field_name'], $column_name);
293 }
294 db_add_index($table, $real_name, $real_columns);
295 db_add_index($revision_table, $real_name, $real_columns);
296 }
297 }
298 }
299 drupal_get_schema(NULL, TRUE);
300 }
301
305 function field_sql_storage_field_storage_delete_field($field) {
306 // Mark all data associated with the field for deletion.
307 $field['deleted'] = 0;
308 $table = _field_sql_storage_tablename($field);
309 $revision_table = _field_sql_storage_revision_tablename($field);
310 db_update($table)
311 ->fields(array('deleted' => 1))
312 ->execute();
313
314 // Move the table to a unique name while the table contents are being deleted.
315 $field['deleted'] = 1;
316 $new_table = _field_sql_storage_tablename($field);
317 $revision_new_table = _field_sql_storage_revision_tablename($field);
318 db_rename_table($table, $new_table);
319 db_rename_table($revision_table, $revision_new_table);
320 drupal_get_schema(NULL, TRUE);
321 }
322
326 function field_sql_storage_field_storage_load($entity_type, $entities, $age, $fields, $options) {
327 $load_current = $age == FIELD_LOAD_CURRENT;
328
329 foreach ($fields as $field_id => $ids) {
330 // By the time this hook runs, the relevant field definitions have been
331 // populated and cached in FieldInfo, so calling field_info_field_by_id()
332 // on each field individually is more efficient than loading all fields in
333 // memory upfront with field_info_field_by_ids().
334 $field = field_info_field_by_id($field_id);
335 $field_name = $field['field_name'];
336 $table = $load_current ? _field_sql_storage_tablename($field) : _field_sql_storage_revision_tablename($field);
337
338 $query = db_select($table, 't')
339 ->fields('t')
340 ->condition('entity_type', $entity_type)
341 ->condition($load_current ? 'entity_id' : 'revision_id', $ids, 'IN')
342 ->condition('language', field_available_languages($entity_type, $field), 'IN')
343 ->orderBy('delta');
344
345 if (empty($options['deleted'])) {
346 $query->condition('deleted', 0);
347 }
348
349 $results = $query->execute();
350
351 $delta_count = array();
352 foreach ($results as $row) {
353 if (!isset($delta_count[$row->entity_id][$row->language])) {
354 $delta_count[$row->entity_id][$row->language] = 0;
355 }
356
357 if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->language] < $field['cardinality']) {
358 $item = array();
359 // For each column declared by the field, populate the item
360 // from the prefixed database column.
361 foreach ($field['columns'] as $column => $attributes) {
362 $column_name = _field_sql_storage_columnname($field_name, $column);
363 $item[$column] = $row->$column_name;
364 }
365
366 // Add the item to the field values for the entity.
367 $entities[$row->entity_id]->{$field_name}[$row->language][] = $item;
368 $delta_count[$row->entity_id][$row->language]++;
369 }
370 }
371 }
372 }
373
377 function field_sql_storage_field_storage_write($entity_type, $entity, $op, $fields) {
378 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
379 if (!isset($vid)) {
380 $vid = $id;
381 }
382
383 foreach ($fields as $field_id) {
384 $field = field_info_field_by_id($field_id);
385 $field_name = $field['field_name'];
386 $table_name = _field_sql_storage_tablename($field);
387 $revision_name = _field_sql_storage_revision_tablename($field);
388
389 $all_languages = field_available_languages($entity_type, $field);
390 $field_languages = array_intersect($all_languages, array_keys((array) $entity->$field_name));
391
392 // Delete and insert, rather than update, in case a value was added.
393 if ($op == FIELD_STORAGE_UPDATE) {
394 // Delete languages present in the incoming $entity->$field_name.
395 // Delete all languages if $entity->$field_name is empty.
396 $languages = !empty($entity->$field_name) ? $field_languages : $all_languages;
397 if ($languages) {
398 db_delete($table_name)
399 ->condition('entity_type', $entity_type)
400 ->condition('entity_id', $id)
401 ->condition('language', $languages, 'IN')
402 ->execute();
403 db_delete($revision_name)
404 ->condition('entity_type', $entity_type)
405 ->condition('entity_id', $id)
406 ->condition('revision_id', $vid)
407 ->condition('language', $languages, 'IN')
408 ->execute();
409 }
410 }
411
412 // Prepare the multi-insert query.
413 $do_insert = FALSE;
414 $columns = array('entity_type', 'entity_id', 'revision_id', 'bundle', 'delta', 'language');
415 foreach ($field['columns'] as $column => $attributes) {
416 $columns[] = _field_sql_storage_columnname($field_name, $column);
417 }
418 $query = db_insert($table_name)->fields($columns);
419 $revision_query = db_insert($revision_name)->fields($columns);
420
421 foreach ($field_languages as $langcode) {
422 $items = (array) $entity->{$field_name}[$langcode];
423 $delta_count = 0;
424 foreach ($items as $delta => $item) {
425 // We now know we have someting to insert.
426 $do_insert = TRUE;
427 $record = array(
428 'entity_type' => $entity_type,
429 'entity_id' => $id,
430 'revision_id' => $vid,
431 'bundle' => $bundle,
432 'delta' => $delta,
433 'language' => $langcode,
434 );
435 foreach ($field['columns'] as $column => $attributes) {
436 $record[_field_sql_storage_columnname($field_name, $column)] = isset($item[$column]) ? $item[$column] : NULL;
437 }
438 $query->values($record);
439 if (isset($vid)) {
440 $revision_query->values($record);
441 }
442
443 if ($field['cardinality'] != FIELD_CARDINALITY_UNLIMITED && ++$delta_count == $field['cardinality']) {
444 break;
445 }
446 }
447 }
448
449 // Execute the query if we have values to insert.
450 if ($do_insert) {
451 $query->execute();
452 $revision_query->execute();
453 }
454 }
455 }
456
462 function field_sql_storage_field_storage_delete($entity_type, $entity, $fields) {
463 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
464
465 foreach (field_info_instances($entity_type, $bundle) as $instance) {
466 if (isset($fields[$instance['field_id']])) {
467 $field = field_info_field_by_id($instance['field_id']);
468 field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance);
469 }
470 }
471 }
472
479 function field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance) {
480 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
481
482 $table_name = _field_sql_storage_tablename($field);
483 $revision_name = _field_sql_storage_revision_tablename($field);
484 db_delete($table_name)
485 ->condition('entity_type', $entity_type)
486 ->condition('entity_id', $id)
487 ->execute();
488 db_delete($revision_name)
489 ->condition('entity_type', $entity_type)
490 ->condition('entity_id', $id)
491 ->execute();
492 }
493
497 function field_sql_storage_field_storage_query(EntityFieldQuery $query) {
498 if ($query->age == FIELD_LOAD_CURRENT) {
499 $tablename_function = '_field_sql_storage_tablename';
500 $id_key = 'entity_id';
501 }
502 else {
503 $tablename_function = '_field_sql_storage_revision_tablename';
504 $id_key = 'revision_id';
505 }
506 $table_aliases = array();
507 // Add tables for the fields used.
508 foreach ($query->fields as $key => $field) {
509 $tablename = $tablename_function($field);
510 // Every field needs a new table.
511 $table_alias = $tablename . $key;
512 $table_aliases[$key] = $table_alias;
513 if ($key) {
514 $select_query->join($tablename, $table_alias, "$table_alias.entity_type = $field_base_table.entity_type AND $table_alias.$id_key = $field_base_table.$id_key");
515 }
516 else {
517 $select_query = db_select($tablename, $table_alias);
518 // Allow queries internal to the Field API to opt out of the access
519 // check, for situations where the query's results should not depend on
520 // the access grants for the current user.
521 if (!isset($query->tags['DANGEROUS_ACCESS_CHECK_OPT_OUT'])) {
522 $select_query->addTag('entity_field_access');
523 }
524 $select_query->addMetaData('base_table', $tablename);
525 $select_query->fields($table_alias, array('entity_type', 'entity_id', 'revision_id', 'bundle'));
526 $field_base_table = $table_alias;
527 }
528 if ($field['cardinality'] != 1 || $field['translatable']) {
529 $select_query->distinct();
530 }
531 }
532
533 // Add field conditions. We need a fresh grouping cache.
534 drupal_static_reset('_field_sql_storage_query_field_conditions');
535 _field_sql_storage_query_field_conditions($query, $select_query, $query->fieldConditions, $table_aliases, '_field_sql_storage_columnname');
536
537 // Add field meta conditions.
538 _field_sql_storage_query_field_conditions($query, $select_query, $query->fieldMetaConditions, $table_aliases, '_field_sql_storage_query_columnname');
539
540 if (isset($query->deleted)) {
541 $select_query->condition("$field_base_table.deleted", (int) $query->deleted);
542 }
543
544 // Is there a need to sort the query by property?
545 $has_property_order = FALSE;
546 foreach ($query->order as $order) {
547 if ($order['type'] == 'property') {
548 $has_property_order = TRUE;
549 }
550 }
551
552 if ($query->propertyConditions || $has_property_order) {
553 if (empty($query->entityConditions['entity_type']['value'])) {
554 throw new EntityFieldQueryException('Property conditions and orders must have an entity type defined.');
555 }
556 $entity_type = $query->entityConditions['entity_type']['value'];
557 $entity_base_table = _field_sql_storage_query_join_entity($select_query, $entity_type, $field_base_table);
558 $query->entityConditions['entity_type']['operator'] = '=';
559 foreach ($query->propertyConditions as $property_condition) {
560 $query->addCondition($select_query, "$entity_base_table." . $property_condition['column'], $property_condition);
561 }
562 }
563 foreach ($query->entityConditions as $key => $condition) {
564 $query->addCondition($select_query, "$field_base_table.$key", $condition);
565 }
566
567 // Order the query.
568 foreach ($query->order as $order) {
569 if ($order['type'] == 'entity') {
570 $key = $order['specifier'];
571 $select_query->orderBy("$field_base_table.$key", $order['direction']);
572 }
573 elseif ($order['type'] == 'field') {
574 $specifier = $order['specifier'];
575 $field = $specifier['field'];
576 $table_alias = $table_aliases[$specifier['index']];
577 $sql_field = "$table_alias." . _field_sql_storage_columnname($field['field_name'], $specifier['column']);
578 $select_query->orderBy($sql_field, $order['direction']);
579 }
580 elseif ($order['type'] == 'property') {
581 $select_query->orderBy("$entity_base_table." . $order['specifier'], $order['direction']);
582 }
583 }
584
585 return $query->finishQuery($select_query, $id_key);
586 }
587
603 function _field_sql_storage_query_join_entity(SelectQuery $select_query, $entity_type, $field_base_table) {
604 $entity_info = entity_get_info($entity_type);
605 $entity_base_table = $entity_info['base table'];
606 $entity_field = $entity_info['entity keys']['id'];
607 $select_query->join($entity_base_table, $entity_base_table, "$entity_base_table.$entity_field = $field_base_table.entity_id");
608 return $entity_base_table;
609 }
610
626 function _field_sql_storage_query_field_conditions(EntityFieldQuery $query, SelectQuery $select_query, $conditions, $table_aliases, $column_callback) {
627 $groups = &drupal_static(__FUNCTION__, array());
628 foreach ($conditions as $key => $condition) {
629 $table_alias = $table_aliases[$key];
630 $field = $condition['field'];
631 // Add the specified condition.
632 $sql_field = "$table_alias." . $column_callback($field['field_name'], $condition['column']);
633 $query->addCondition($select_query, $sql_field, $condition);
634 // Add delta / language group conditions.
635 foreach (array('delta', 'language') as $column) {
636 if (isset($condition[$column . '_group'])) {
637 $group_name = $condition[$column . '_group'];
638 if (!isset($groups[$column][$group_name])) {
639 $groups[$column][$group_name] = $table_alias;
640 }
641 else {
642 $select_query->where("$table_alias.$column = " . $groups[$column][$group_name] . ".$column");
643 }
644 }
645 }
646 }
647 }
648
652 function _field_sql_storage_query_columnname($field_name, $column) {
653 return $column;
654 }
655
661 function field_sql_storage_field_storage_delete_revision($entity_type, $entity, $fields) {
662 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
663
664 if (isset($vid)) {
665 foreach ($fields as $field_id) {
666 $field = field_info_field_by_id($field_id);
667 $revision_name = _field_sql_storage_revision_tablename($field);
668 db_delete($revision_name)
669 ->condition('entity_type', $entity_type)
670 ->condition('entity_id', $id)
671 ->condition('revision_id', $vid)
672 ->execute();
673 }
674 }
675 }
676
682 function field_sql_storage_field_storage_delete_instance($instance) {
683 $field = field_info_field($instance['field_name']);
684 $table_name = _field_sql_storage_tablename($field);
685 $revision_name = _field_sql_storage_revision_tablename($field);
686 db_update($table_name)
687 ->fields(array('deleted' => 1))
688 ->condition('entity_type', $instance['entity_type'])
689 ->condition('bundle', $instance['bundle'])
690 ->execute();
691 db_update($revision_name)
692 ->fields(array('deleted' => 1))
693 ->condition('entity_type', $instance['entity_type'])
694 ->condition('bundle', $instance['bundle'])
695 ->execute();
696 }
697
701 function field_sql_storage_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
702 // We need to account for deleted or inactive fields and instances.
703 $instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle_new), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
704 foreach ($instances as $instance) {
705 $field = field_info_field_by_id($instance['field_id']);
706 if ($field['storage']['type'] == 'field_sql_storage') {
707 $table_name = _field_sql_storage_tablename($field);
708 $revision_name = _field_sql_storage_revision_tablename($field);
709 db_update($table_name)
710 ->fields(array('bundle' => $bundle_new))
711 ->condition('entity_type', $entity_type)
712 ->condition('bundle', $bundle_old)
713 ->execute();
714 db_update($revision_name)
715 ->fields(array('bundle' => $bundle_new))
716 ->condition('entity_type', $entity_type)
717 ->condition('bundle', $bundle_old)
718 ->execute();
719 }
720 }
721 }
722
729 function field_sql_storage_field_storage_purge_field($field) {
730 $table_name = _field_sql_storage_tablename($field);
731 $revision_name = _field_sql_storage_revision_tablename($field);
732 db_drop_table($table_name);
733 db_drop_table($revision_name);
734 }
735
739 function field_sql_storage_field_storage_details($field) {
740 $details = array();
741 if (!empty($field['columns'])) {
742 // Add field columns.
743 foreach ($field['columns'] as $column_name => $attributes) {
744 $real_name = _field_sql_storage_columnname($field['field_name'], $column_name);
745 $columns[$column_name] = $real_name;
746 }
747 return array(
748 'sql' => array(
749 FIELD_LOAD_CURRENT => array(
750 _field_sql_storage_tablename($field) => $columns,
751 ),
752 FIELD_LOAD_REVISION => array(
753 _field_sql_storage_revision_tablename($field) => $columns,
754 ),
755 ),
756 );
757 }
758 }
field_sql_storage_field_storage_purge
field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance)
Definition: field_sql_storage.module:479
field_sql_storage_field_storage_details
field_sql_storage_field_storage_details($field)
Definition: field_sql_storage.module:739
field_info_field_by_id
field_info_field_by_id($field_id)
Definition: field.info.inc:537
_field_sql_storage_query_field_conditions
_field_sql_storage_query_field_conditions(EntityFieldQuery $query, SelectQuery $select_query, $conditions, $table_aliases, $column_callback)
Definition: field_sql_storage.module:626
$op
$op
Definition: update.php:404
EntityFieldQuery\addCondition
addCondition(SelectQuery $select_query, $sql_field, $condition, $having=FALSE)
Definition: entity.inc:1341
db_add_index
db_add_index($table, $name, $fields)
Definition: database.inc:2940
SelectQuery
Definition: select.inc:859
Database\getConnection
static getConnection($target= 'default', $key=NULL)
Definition: database.inc:1460
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
_field_sql_storage_query_columnname
_field_sql_storage_query_columnname($field_name, $column)
Definition: field_sql_storage.module:652
FIELD_STORAGE_UPDATE
const FIELD_STORAGE_UPDATE
Definition: field.attach.inc:58
field_info_instances
field_info_instances($entity_type=NULL, $bundle_name=NULL)
Definition: field.info.inc:592
field_available_languages
field_available_languages($entity_type, $field)
Definition: field.multilingual.inc:89
_field_sql_storage_query_join_entity
_field_sql_storage_query_join_entity(SelectQuery $select_query, $entity_type, $field_base_table)
Definition: field_sql_storage.module:603
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
db_drop_index
db_drop_index($table, $name)
Definition: database.inc:2952
$name
print $name
Definition: profile-listing.tpl.php:43
$results
print $results
Definition: poll-results.tpl.php:23
field_sql_storage_field_storage_delete
field_sql_storage_field_storage_delete($entity_type, $entity, $fields)
Definition: field_sql_storage.module:462
Exception
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
$attributes
print $attributes
Definition: block.tpl.php:47
field_read_instances
field_read_instances($params=array(), $include_additional=array())
Definition: field.crud.inc:713
_field_sql_storage_indexname
_field_sql_storage_indexname($name, $index)
Definition: field_sql_storage.module:93
field_sql_storage_field_storage_delete_revision
field_sql_storage_field_storage_delete_revision($entity_type, $entity, $fields)
Definition: field_sql_storage.module:661
field_sql_storage_field_storage_create_field
field_sql_storage_field_storage_create_field($field)
Definition: field_sql_storage.module:213
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
SelectQuery\join
join($table, $alias=NULL, $condition=NULL, $arguments=array())
Definition: select.inc:1337
field_sql_storage_field_storage_query
field_sql_storage_field_storage_query(EntityFieldQuery $query)
Definition: field_sql_storage.module:497
drupal_get_schema
drupal_get_schema($table=NULL, $rebuild=FALSE)
Definition: bootstrap.inc:2940
field_sql_storage_field_storage_load
field_sql_storage_field_storage_load($entity_type, $entities, $age, $fields, $options)
Definition: field_sql_storage.module:326
SelectQuery\where
where($snippet, $args=array())
Definition: select.inc:1047
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
FIELD_LOAD_REVISION
const FIELD_LOAD_REVISION
Definition: field.module:274
EntityFieldQuery
Definition: entity.inc:420
$output
$output
Definition: authorize.php:93
_field_sql_storage_schema
_field_sql_storage_schema($field)
Definition: field_sql_storage.module:108
FIELD_CARDINALITY_UNLIMITED
const FIELD_CARDINALITY_UNLIMITED
Definition: field.module:236
EntityFieldQuery\age
age($age)
Definition: entity.inc:1049
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
_field_sql_storage_tablename
_field_sql_storage_tablename($field)
Definition: field_sql_storage.module:41
field_sql_storage_field_storage_info
field_sql_storage_field_storage_info()
Definition: field_sql_storage.module:24
field_sql_storage_field_storage_delete_instance
field_sql_storage_field_storage_delete_instance($instance)
Definition: field_sql_storage.module:682
field_sql_storage_help
field_sql_storage_help($path, $arg)
Definition: field_sql_storage.module:11
_field_sql_storage_columnname
_field_sql_storage_columnname($name, $column)
Definition: field_sql_storage.module:78
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
EntityFieldQuery\finishQuery
finishQuery($select_query, $id_key= 'entity_id')
Definition: entity.inc:1301
db_transaction
db_transaction($name=NULL, array $options=array())
Definition: database.inc:2535
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
_field_sql_storage_revision_tablename
_field_sql_storage_revision_tablename($field)
Definition: field_sql_storage.module:58
field_sql_storage_field_update_forbid
field_sql_storage_field_update_forbid($field, $prior_field, $has_data)
Definition: field_sql_storage.module:227
$row
$row
Definition: block-admin-display-form.tpl.php:47
EntityFieldQuery\deleted
deleted($deleted=TRUE)
Definition: entity.inc:1028
field_sql_storage_field_storage_purge_field
field_sql_storage_field_storage_purge_field($field)
Definition: field_sql_storage.module:729
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
EntityFieldQueryException
Definition: entity.inc:390
field_sql_storage_field_storage_delete_field
field_sql_storage_field_storage_delete_field($field)
Definition: field_sql_storage.module:305
entity_extract_ids
entity_extract_ids($entity_type, $entity)
Definition: common.inc:7711
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
field_sql_storage_field_storage_update_field
field_sql_storage_field_storage_update_field($field, $prior_field, $has_data)
Definition: field_sql_storage.module:236
FieldUpdateForbiddenException
Definition: field.module:279
db_table_exists
db_table_exists($table)
Definition: database.inc:2760
field_sql_storage_field_attach_rename_bundle
field_sql_storage_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new)
Definition: field_sql_storage.module:701
db_rename_table
db_rename_table($table, $new_name)
Definition: database.inc:2805
field_sql_storage_field_storage_write
field_sql_storage_field_storage_write($entity_type, $entity, $op, $fields)
Definition: field_sql_storage.module:377
FIELD_LOAD_CURRENT
const FIELD_LOAD_CURRENT
Definition: field.module:268
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.tokens.inc Source File

  • modules
  • system
system.tokens.inc
Go to the documentation of this file.
1 <?php
2
14 function system_token_info() {
15 $types['site'] = array(
16 'name' => t("Site information"),
17 'description' => t("Tokens for site-wide settings and other global information."),
18 );
19 $types['date'] = array(
20 'name' => t("Dates"),
21 'description' => t("Tokens related to times and dates."),
22 );
23 $types['file'] = array(
24 'name' => t("Files"),
25 'description' => t("Tokens related to uploaded files."),
26 'needs-data' => 'file',
27 );
28
29 // Site-wide global tokens.
30 $site['name'] = array(
31 'name' => t("Name"),
32 'description' => t("The name of the site."),
33 );
34 $site['slogan'] = array(
35 'name' => t("Slogan"),
36 'description' => t("The slogan of the site."),
37 );
38 $site['mail'] = array(
39 'name' => t("Email"),
40 'description' => t("The administrative email address for the site."),
41 );
42 $site['url'] = array(
43 'name' => t("URL"),
44 'description' => t("The URL of the site's front page."),
45 );
46 $site['url-brief'] = array(
47 'name' => t("URL (brief)"),
48 'description' => t("The URL of the site's front page without the protocol."),
49 );
50 $site['login-url'] = array(
51 'name' => t("Login page"),
52 'description' => t("The URL of the site's login page."),
53 );
54
55 // Date related tokens.
56 $date['short'] = array(
57 'name' => t("Short format"),
58 'description' => t("A date in 'short' format. (%date)", array('%date' => format_date(REQUEST_TIME, 'short'))),
59 );
60 $date['medium'] = array(
61 'name' => t("Medium format"),
62 'description' => t("A date in 'medium' format. (%date)", array('%date' => format_date(REQUEST_TIME, 'medium'))),
63 );
64 $date['long'] = array(
65 'name' => t("Long format"),
66 'description' => t("A date in 'long' format. (%date)", array('%date' => format_date(REQUEST_TIME, 'long'))),
67 );
68 $date['custom'] = array(
69 'name' => t("Custom format"),
70 'description' => t("A date in a custom format. See !php-date for details.", array('!php-date' => l(t('the PHP documentation'), 'http://php.net/manual/en/function.date.php'))),
71 );
72 $date['since'] = array(
73 'name' => t("Time-since"),
74 'description' => t("A date in 'time-since' format. (%date)", array('%date' => format_interval(REQUEST_TIME - 360, 2))),
75 );
76 $date['raw'] = array(
77 'name' => t("Raw timestamp"),
78 'description' => t("A date in UNIX timestamp format (%date)", array('%date' => REQUEST_TIME)),
79 );
80
81
82 // File related tokens.
83 $file['fid'] = array(
84 'name' => t("File ID"),
85 'description' => t("The unique ID of the uploaded file."),
86 );
87 $file['name'] = array(
88 'name' => t("File name"),
89 'description' => t("The name of the file on disk."),
90 );
91 $file['path'] = array(
92 'name' => t("Path"),
93 'description' => t("The location of the file relative to Drupal root."),
94 );
95 $file['mime'] = array(
96 'name' => t("MIME type"),
97 'description' => t("The MIME type of the file."),
98 );
99 $file['size'] = array(
100 'name' => t("File size"),
101 'description' => t("The size of the file."),
102 );
103 $file['url'] = array(
104 'name' => t("URL"),
105 'description' => t("The web-accessible URL for the file."),
106 );
107 $file['timestamp'] = array(
108 'name' => t("Timestamp"),
109 'description' => t("The date the file was most recently changed."),
110 'type' => 'date',
111 );
112 $file['owner'] = array(
113 'name' => t("Owner"),
114 'description' => t("The user who originally uploaded the file."),
115 'type' => 'user',
116 );
117
118 return array(
119 'types' => $types,
120 'tokens' => array(
121 'site' => $site,
122 'date' => $date,
123 'file' => $file,
124 ),
125 );
126 }
127
131 function system_tokens($type, $tokens, array $data = array(), array $options = array()) {
132 $url_options = array('absolute' => TRUE);
133 if (isset($options['language'])) {
134 $url_options['language'] = $options['language'];
135 $language_code = $options['language']->language;
136 }
137 else {
138 $language_code = NULL;
139 }
140 $sanitize = !empty($options['sanitize']);
141
142 $replacements = array();
143
144 if ($type == 'site') {
145 foreach ($tokens as $name => $original) {
146 switch ($name) {
147 case 'name':
148 $site_name = variable_get('site_name', 'Drupal');
149 $replacements[$original] = $sanitize ? check_plain($site_name) : $site_name;
150 break;
151
152 case 'slogan':
153 $slogan = variable_get('site_slogan', '');
154 $replacements[$original] = $sanitize ? check_plain($slogan) : $slogan;
155 break;
156
157 case 'mail':
158 $replacements[$original] = variable_get('site_mail', '');
159 break;
160
161 case 'url':
162 $replacements[$original] = url('<front>', $url_options);
163 break;
164
165 case 'url-brief':
166 $replacements[$original] = preg_replace(array('!^https?://!', '!/$!'), '', url('<front>', $url_options));
167 break;
168
169 case 'login-url':
170 $replacements[$original] = url('user', $url_options);
171 break;
172 }
173 }
174 }
175
176 elseif ($type == 'date') {
177 if (empty($data['date'])) {
178 $date = REQUEST_TIME;
179 }
180 else {
181 $date = $data['date'];
182 }
183
184 foreach ($tokens as $name => $original) {
185 switch ($name) {
186 case 'short':
187 $replacements[$original] = format_date($date, 'short', '', NULL, $language_code);
188 break;
189
190 case 'medium':
191 $replacements[$original] = format_date($date, 'medium', '', NULL, $language_code);
192 break;
193
194 case 'long':
195 $replacements[$original] = format_date($date, 'long', '', NULL, $language_code);
196 break;
197
198 case 'since':
199 $replacements[$original] = format_interval((REQUEST_TIME - $date), 2, $language_code);
200 break;
201
202 case 'raw':
203 $replacements[$original] = $sanitize ? check_plain($date) : $date;
204 break;
205 }
206 }
207
208 if ($created_tokens = token_find_with_prefix($tokens, 'custom')) {
209 foreach ($created_tokens as $name => $original) {
210 $replacements[$original] = format_date($date, 'custom', $name, NULL, $language_code);
211 }
212 }
213 }
214
215 elseif ($type == 'file' && !empty($data['file'])) {
216 $file = $data['file'];
217
218 foreach ($tokens as $name => $original) {
219 switch ($name) {
220 // Basic keys and values.
221 case 'fid':
222 $replacements[$original] = $file->fid;
223 break;
224
225 // Essential file data
226 case 'name':
227 $replacements[$original] = $sanitize ? check_plain($file->filename) : $file->filename;
228 break;
229
230 case 'path':
231 $replacements[$original] = $sanitize ? check_plain($file->uri) : $file->uri;
232 break;
233
234 case 'mime':
235 $replacements[$original] = $sanitize ? check_plain($file->filemime) : $file->filemime;
236 break;
237
238 case 'size':
239 $replacements[$original] = format_size($file->filesize);
240 break;
241
242 case 'url':
243 $replacements[$original] = $sanitize ? check_plain(file_create_url($file->uri)) : file_create_url($file->uri);
244 break;
245
246 // These tokens are default variations on the chained tokens handled below.
247 case 'timestamp':
248 $replacements[$original] = format_date($file->timestamp, 'medium', '', NULL, $language_code);
249 break;
250
251 case 'owner':
252 $account = user_load($file->uid);
253 $name = format_username($account);
254 $replacements[$original] = $sanitize ? check_plain($name) : $name;
255 break;
256 }
257 }
258
259 if ($date_tokens = token_find_with_prefix($tokens, 'timestamp')) {
260 $replacements += token_generate('date', $date_tokens, array('date' => $file->timestamp), $options);
261 }
262
263 if (($owner_tokens = token_find_with_prefix($tokens, 'owner')) && $account = user_load($file->uid)) {
264 $replacements += token_generate('user', $owner_tokens, array('user' => $account), $options);
265 }
266 }
267
268 return $replacements;
269 }
token_generate
token_generate($type, array $tokens, array $data=array(), array $options=array())
Definition: token.inc:176
l
l($text, $path, array $options=array())
Definition: common.inc:2432
file_create_url
file_create_url($uri)
Definition: file.inc:372
format_username
format_username($account)
Definition: common.inc:2106
$name
print $name
Definition: profile-listing.tpl.php:43
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
system_tokens
system_tokens($type, $tokens, array $data=array(), array $options=array())
Definition: system.tokens.inc:131
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
system_token_info
system_token_info()
Definition: system.tokens.inc:14
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
format_size
format_size($size, $langcode=NULL)
Definition: common.inc:1866
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
token_find_with_prefix
token_find_with_prefix(array $tokens, $prefix, $delimiter= ':')
Definition: token.inc:219
$site_name
print $site_name
Definition: maintenance-page.tpl.php:40
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/batch_example/batch_example.module Source File

  • examples
  • batch_example
batch_example.module
Go to the documentation of this file.
1 <?php
2
33 function batch_example_menu() {
34 $items = array();
35 $items['examples/batch_example'] = array(
36 'title' => 'Batch example',
37 'description' => 'Example of Drupal batch processing',
38 'page callback' => 'drupal_get_form',
39 'page arguments' => array('batch_example_simple_form'),
40 'access callback' => TRUE,
41 );
42
43 return $items;
44 }
45
49 function batch_example_simple_form() {
50 $form['description'] = array(
51 '#type' => 'markup',
52 '#markup' => t('This example offers two different batches. The first does 1000 identical operations, each completed in on run; the second does 20 operations, but each takes more than one run to operate if there are more than 5 nodes.'),
53 );
54 $form['batch'] = array(
55 '#type' => 'select',
56 '#title' => 'Choose batch',
57 '#options' => array(
58 'batch_1' => t('batch 1 - 1000 operations, each loading the same node'),
59 'batch_2' => t('batch 2 - 20 operations. each one loads all nodes 5 at a time'),
60 ),
61 );
62 $form['submit'] = array(
63 '#type' => 'submit',
64 '#value' => 'Go',
65 );
66
67 // If no nodes, prevent submission.
68 // Find out if we have a node to work with. Otherwise it won't work.
69 $nid = batch_example_lowest_nid();
70 if (empty($nid)) {
71 drupal_set_message(t("You don't currently have any nodes, and this example requires a node to work with. As a result, this form is disabled."));
72 $form['submit']['#disabled'] = TRUE;
73 }
74 return $form;
75 }
76
77 function batch_example_simple_form_submit($form, &$form_state) {
78 $function = 'batch_example_' . $form_state['values']['batch'];
79
80 $_SESSION['http_request_count'] = 0; // reset counter for debug information.
81
82 // Execute the function named batch_example_1 or batch_example_2.
83 $batch = $function();
84 batch_set($batch);
85 }
86
87
95 function batch_example_batch_1() {
96 $nid = batch_example_lowest_nid();
97 $num_operations = 1000;
98 drupal_set_message(t('Creating an array of @num operations', array('@num' => $num_operations)));
99
100 $operations = array();
101 // Set up an operations array with 1000 elements, each doing function
102 // batch_example_op_1.
103 // Each operation in the operations array means at least one new HTTP request,
104 // running Drupal from scratch to accomplish the operation. If the operation
105 // returns with $context['finished'] != TRUE, then it will be called again.
106 // In this example, $context['finished'] is always TRUE.
107 for ($i = 0; $i<$num_operations; $i++) {
108
109 // Each operation is an array consisting of
110 // - the function to call
111 // - An array of arguments to that function
112 $operations[] = array('batch_example_op_1', array($nid, t('(Operation @operation)', array('@operation' => $i))));
113 }
114 $batch = array(
115 'operations' => $operations,
116 'finished' => 'batch_example_finished',
117 );
118 return $batch;
119 }
120
125 function batch_example_op_1($nid, $operation_details, &$context) {
126 $node = node_load($nid, NULL, TRUE);
127
128 // Store some results for post-processing in the 'finished' callback.
129 // The contents of 'results' will be available as $results in the
130 // 'finished' function (in this example, batch_example_finished()).
131 $context['results'][] = $node->nid . ' : ' . check_plain($node->title);
132
133 // Optional message displayed under the progressbar.
134 $context['message'] = t('Loading node "@title"', array('@title' => $node->title)) . ' ' . $operation_details;
135
136 _batch_example_update_http_requests();
137 }
138
142 function batch_example_batch_2() {
143 $num_operations = 20;
144
145 // Give helpful information about how many nodes are being operated on.
146 $node_count = db_query('SELECT COUNT(DISTINCT nid) FROM {node}')->fetchField();
147 drupal_set_message(t('There are @node_count nodes so each of the @num operations will require @count HTTP requests.', array('@node_count' => $node_count, '@num' => $num_operations, '@count' => ceil($node_count / 5))));
148
149 $operations = array();
150 // 20 operations, each one loads all nodes.
151 for ($i = 0; $i < $num_operations; $i++) {
152 $operations[] = array('batch_example_op_2', array(t('(Operation @operation)', array('@operation' => $i))));
153 }
154 $batch = array(
155 'operations' => $operations,
156 'finished' => 'batch_example_finished',
157 // Message displayed while processing the batch. Available placeholders are:
158 // @current, @remaining, @total, @percentage, @estimate and @elapsed.
159 // These placeholders are replaced with actual values in _batch_process(),
160 // using strtr() instead of t(). The values are determined based on the
161 // number of operations in the 'operations' array (above), NOT by the number
162 // of nodes that will be processed. In this example, there are 20
163 // operations, so @total will always be 20, even though there are multiple
164 // nodes per operation.
165 // Defaults to t('Completed @current of @total.').
166 'title' => t('Processing batch 2'),
167 'init_message' => t('Batch 2 is starting.'),
168 'progress_message' => t('Processed @current out of @total.'),
169 'error_message' => t('Batch 2 has encountered an error.'),
170 );
171 return $batch;
172 }
173
179 function batch_example_op_2($operation_details, &$context) {
180 // Use the $context['sandbox'] at your convenience to store the
181 // information needed to track progression between successive calls.
182 if (empty($context['sandbox'])) {
183 $context['sandbox'] = array();
184 $context['sandbox']['progress'] = 0;
185 $context['sandbox']['current_node'] = 0;
186
187 // Save node count for the termination message.
188 $context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT nid) FROM {node}')->fetchField();
189 }
190
191 // Process nodes by groups of 5 (arbitrary value).
192 // When a group of five is processed, the batch update engine determines
193 // whether it should continue processing in the same request or provide
194 // progress feedback to the user and wait for the next request.
195 // That way even though we're already processing at the operation level
196 // the operation itself is interruptible.
197 $limit = 5;
198
199 // Retrieve the next group of nids.
200 $result = db_select('node', 'n')
201 ->fields('n', array('nid'))
202 ->orderBy('n.nid', 'ASC')
203 ->where('n.nid > :nid', array(':nid' => $context['sandbox']['current_node']))
204 ->extend('PagerDefault')
205 ->limit($limit)
206 ->execute();
207 foreach ($result as $row) {
208 // Here we actually perform our dummy 'processing' on the current node.
209 $node = node_load($row->nid, NULL, TRUE);
210
211 // Store some results for post-processing in the 'finished' callback.
212 // The contents of 'results' will be available as $results in the
213 // 'finished' function (in this example, batch_example_finished()).
214 $context['results'][] = $node->nid . ' : ' . check_plain($node->title) . ' ' . $operation_details;
215
216 // Update our progress information.
217 $context['sandbox']['progress']++;
218 $context['sandbox']['current_node'] = $node->nid;
219 $context['message'] = check_plain($node->title);
220 }
221
222 // Inform the batch engine that we are not finished,
223 // and provide an estimation of the completion level we reached.
224 if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
225 $context['finished'] = ($context['sandbox']['progress'] >= $context['sandbox']['max']);
226 }
227 _batch_example_update_http_requests();
228 }
229
233 function batch_example_finished($success, $results, $operations) {
234 if ($success) {
235 // Here we could do something meaningful with the results.
236 // We just display the number of nodes we processed...
237 drupal_set_message(t('@count results processed in @requests HTTP requests.', array('@count' => count($results), '@requests' => _batch_example_get_http_requests())));
238 drupal_set_message(t('The final result was "%final"', array('%final' => end($results))));
239 }
240 else {
241 // An error occurred.
242 // $operations contains the operations that remained unprocessed.
243 $error_operation = reset($operations);
244 drupal_set_message(t('An error occurred while processing @operation with arguments : @args', array('@operation' => $error_operation[0], '@args' => print_r($error_operation[0], TRUE))));
245 }
246 }
247
252 function batch_example_lowest_nid() {
253 $select = db_select('node', 'n')
254 ->fields('n', array('nid'))
255 ->orderBy('n.nid', 'ASC')
256 ->extend('PagerDefault')
257 ->limit(1);
258 $nid = $select->execute()->fetchField();
259 return $nid;
260 }
261
265 function _batch_example_update_http_requests() {
266 $_SESSION['http_request_count']++;
267 }
268
269 function _batch_example_get_http_requests() {
270 return !empty($_SESSION['http_request_count']) ? $_SESSION['http_request_count'] : 0;
271 }
batch_example_op_2
batch_example_op_2($operation_details, &$context)
Definition: batch_example.module:179
batch_example_batch_2
batch_example_batch_2()
Definition: batch_example.module:142
$results
print $results
Definition: poll-results.tpl.php:23
batch_example_simple_form
batch_example_simple_form()
Definition: batch_example.module:49
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
_batch_example_get_http_requests
_batch_example_get_http_requests()
Definition: batch_example.module:269
batch_example_batch_1
batch_example_batch_1()
Definition: batch_example.module:95
batch_set
batch_set($batch_definition)
Definition: form.inc:4381
batch_example_finished
batch_example_finished($success, $results, $operations)
Definition: batch_example.module:233
batch_example_simple_form_submit
batch_example_simple_form_submit($form, &$form_state)
Definition: batch_example.module:77
batch_example_lowest_nid
batch_example_lowest_nid()
Definition: batch_example.module:252
batch_example_menu
batch_example_menu()
Definition: batch_example.module:33
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
_batch_example_update_http_requests
_batch_example_update_http_requests()
Definition: batch_example.module:265
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$row
$row
Definition: block-admin-display-form.tpl.php:47
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
batch_example_op_1
batch_example_op_1($nid, $operation_details, &$context)
Definition: batch_example.module:125
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/php/php.install Source File

  • modules
  • php
php.install
Go to the documentation of this file.
1 <?php
2
11 function php_enable() {
12 $format_exists = (bool) db_query_range('SELECT 1 FROM {filter_format} WHERE name = :name', 0, 1, array(':name' => 'PHP code'))->fetchField();
13 // Add a PHP code text format, if it does not exist. Do this only for the
14 // first install (or if the format has been manually deleted) as there is no
15 // reliable method to identify the format in an uninstall hook or in
16 // subsequent clean installs.
17 if (!$format_exists) {
18 $php_format = array(
19 'format' => 'php_code',
20 'name' => 'PHP code',
21 // 'Plain text' format is installed with a weight of 10 by default. Use a
22 // higher weight here to ensure that this format will not be the default
23 // format for anyone.
24 'weight' => 11,
25 'filters' => array(
26 // Enable the PHP evaluator filter.
27 'php_code' => array(
28 'weight' => 0,
29 'status' => 1,
30 ),
31 ),
32 );
33 $php_format = (object) $php_format;
34 filter_format_save($php_format);
35
36 drupal_set_message(t('A <a href="@php-code">PHP code</a> text format has been created.', array('@php-code' => url('admin/config/content/formats/' . $php_format->format))));
37 }
38 }
39
43 function php_disable() {
44 drupal_set_message(t('The PHP module has been disabled. Any existing content that was using the PHP filter will now be visible in plain text. This might pose a security risk by exposing sensitive information, if any, used in the PHP code.'));
45 }
php_enable
php_enable()
Definition: php.install:11
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
filter_format_save
filter_format_save($format)
Definition: filter.module:198
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
php_disable
php_disable()
Definition: php.install:43
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.manager.inc Source File

  • modules
  • update
update.manager.inc
Go to the documentation of this file.
1 <?php
2
62 function update_manager_update_form($form, $form_state = array(), $context) {
63 if (!_update_manager_check_backends($form, 'update')) {
64 return $form;
65 }
66
67 $form['#theme'] = 'update_manager_update_form';
68
69 $available = update_get_available(TRUE);
70 if (empty($available)) {
71 $form['message'] = array(
72 '#markup' => t('There was a problem getting update information. Try again later.'),
73 );
74 return $form;
75 }
76
77 $form['#attached']['css'][] = drupal_get_path('module', 'update') . '/update.css';
78
79 // This will be a nested array. The first key is the kind of project, which
80 // can be either 'enabled', 'disabled', 'manual' (projects which require
81 // manual updates, such as core). Then, each subarray is an array of
82 // projects of that type, indexed by project short name, and containing an
83 // array of data for cells in that project's row in the appropriate table.
84 $projects = array();
85
86 // This stores the actual download link we're going to update from for each
87 // project in the form, regardless of if it's enabled or disabled.
88 $form['project_downloads'] = array('#tree' => TRUE);
89
90 module_load_include('inc', 'update', 'update.compare');
91 $project_data = update_calculate_project_data($available);
92 foreach ($project_data as $name => $project) {
93 // Filter out projects which are up to date already.
94 if ($project['status'] == UPDATE_CURRENT) {
95 continue;
96 }
97 // The project name to display can vary based on the info we have.
98 if (!empty($project['title'])) {
99 if (!empty($project['link'])) {
100 $project_name = l($project['title'], $project['link']);
101 }
102 else {
103 $project_name = check_plain($project['title']);
104 }
105 }
106 elseif (!empty($project['info']['name'])) {
107 $project_name = check_plain($project['info']['name']);
108 }
109 else {
110 $project_name = check_plain($name);
111 }
112 if ($project['project_type'] == 'theme' || $project['project_type'] == 'theme-disabled') {
113 $project_name .= ' ' . t('(Theme)');
114 }
115
116 if (empty($project['recommended'])) {
117 // If we don't know what to recommend they upgrade to, we should skip
118 // the project entirely.
119 continue;
120 }
121
122 $recommended_release = $project['releases'][$project['recommended']];
123 $recommended_version = $recommended_release['version'] . ' ' . l(t('(Release notes)'), $recommended_release['release_link'], array('attributes' => array('title' => t('Release notes for @project_title', array('@project_title' => $project['title'])))));
124 if ($recommended_release['version_major'] != $project['existing_major']) {
125 $recommended_version .= '<div title="Major upgrade warning" class="update-major-version-warning">' . t('This update is a major version update which means that it may not be backwards compatible with your currently running version. It is recommended that you read the release notes and proceed at your own risk.') . '</div>';
126 }
127
128 // Create an entry for this project.
129 $entry = array(
130 'title' => $project_name,
131 'installed_version' => $project['existing_version'],
132 'recommended_version' => $recommended_version,
133 );
134
135 switch ($project['status']) {
136 case UPDATE_NOT_SECURE:
137 case UPDATE_REVOKED:
138 $entry['title'] .= ' ' . t('(Security update)');
139 $entry['#weight'] = -2;
140 $type = 'security';
141 break;
142
143 case UPDATE_NOT_SUPPORTED:
144 $type = 'unsupported';
145 $entry['title'] .= ' ' . t('(Unsupported)');
146 $entry['#weight'] = -1;
147 break;
148
149 case UPDATE_UNKNOWN:
150 case UPDATE_NOT_FETCHED:
151 case UPDATE_NOT_CHECKED:
152 case UPDATE_NOT_CURRENT:
153 $type = 'recommended';
154 break;
155
156 default:
157 // Jump out of the switch and onto the next project in foreach.
158 continue 2;
159 }
160
161 $entry['#attributes'] = array('class' => array('update-' . $type));
162
163 // Drupal core needs to be upgraded manually.
164 $needs_manual = $project['project_type'] == 'core';
165
166 if ($needs_manual) {
167 // There are no checkboxes in the 'Manual updates' table so it will be
168 // rendered by theme('table'), not theme('tableselect'). Since the data
169 // formats are incompatible, we convert now to the format expected by
170 // theme('table').
171 unset($entry['#weight']);
172 $attributes = $entry['#attributes'];
173 unset($entry['#attributes']);
174 $entry = array(
175 'data' => $entry,
176 ) + $attributes;
177 }
178 else {
179 $form['project_downloads'][$name] = array(
180 '#type' => 'value',
181 '#value' => $recommended_release['download_link'],
182 );
183 }
184
185 // Based on what kind of project this is, save the entry into the
186 // appropriate subarray.
187 switch ($project['project_type']) {
188 case 'core':
189 // Core needs manual updates at this time.
190 $projects['manual'][$name] = $entry;
191 break;
192
193 case 'module':
194 case 'theme':
195 $projects['enabled'][$name] = $entry;
196 break;
197
198 case 'module-disabled':
199 case 'theme-disabled':
200 $projects['disabled'][$name] = $entry;
201 break;
202 }
203 }
204
205 if (empty($projects)) {
206 $form['message'] = array(
207 '#markup' => t('All of your projects are up to date.'),
208 );
209 return $form;
210 }
211
212 $headers = array(
213 'title' => array(
214 'data' => t('Name'),
215 'class' => array('update-project-name'),
216 ),
217 'installed_version' => t('Installed version'),
218 'recommended_version' => t('Recommended version'),
219 );
220
221 if (!empty($projects['enabled'])) {
222 $form['projects'] = array(
223 '#type' => 'tableselect',
224 '#header' => $headers,
225 '#options' => $projects['enabled'],
226 );
227 if (!empty($projects['disabled'])) {
228 $form['projects']['#prefix'] = '<h2>' . t('Enabled') . '</h2>';
229 }
230 }
231
232 if (!empty($projects['disabled'])) {
233 $form['disabled_projects'] = array(
234 '#type' => 'tableselect',
235 '#header' => $headers,
236 '#options' => $projects['disabled'],
237 '#weight' => 1,
238 '#prefix' => '<h2>' . t('Disabled') . '</h2>',
239 );
240 }
241
242 // If either table has been printed yet, we need a submit button and to
243 // validate the checkboxes.
244 if (!empty($projects['enabled']) || !empty($projects['disabled'])) {
245 $form['actions'] = array('#type' => 'actions');
246 $form['actions']['submit'] = array(
247 '#type' => 'submit',
248 '#value' => t('Download these updates'),
249 );
250 $form['#validate'][] = 'update_manager_update_form_validate';
251 }
252
253 if (!empty($projects['manual'])) {
254 $prefix = '<h2>' . t('Manual updates required') . '</h2>';
255 $prefix .= '<p>' . t('Updates of Drupal core are not supported at this time.') . '</p>';
256 $form['manual_updates'] = array(
257 '#type' => 'markup',
258 '#markup' => theme('table', array('header' => $headers, 'rows' => $projects['manual'])),
259 '#prefix' => $prefix,
260 '#weight' => 120,
261 );
262 }
263
264 return $form;
265 }
266
276 function theme_update_manager_update_form($variables) {
277 $form = $variables['form'];
278 $last = variable_get('update_last_check', 0);
279 $output = theme('update_last_check', array('last' => $last));
280 $output .= drupal_render_children($form);
281 return $output;
282 }
283
291 function update_manager_update_form_validate($form, &$form_state) {
292 if (!empty($form_state['values']['projects'])) {
293 $enabled = array_filter($form_state['values']['projects']);
294 }
295 if (!empty($form_state['values']['disabled_projects'])) {
296 $disabled = array_filter($form_state['values']['disabled_projects']);
297 }
298 if (empty($enabled) && empty($disabled)) {
299 form_set_error('projects', t('You must select at least one project to update.'));
300 }
301 }
302
310 function update_manager_update_form_submit($form, &$form_state) {
311 $projects = array();
312 foreach (array('projects', 'disabled_projects') as $type) {
313 if (!empty($form_state['values'][$type])) {
314 $projects = array_merge($projects, array_keys(array_filter($form_state['values'][$type])));
315 }
316 }
317 $operations = array();
318 foreach ($projects as $project) {
319 $operations[] = array(
320 'update_manager_batch_project_get',
321 array(
322 $project,
323 $form_state['values']['project_downloads'][$project],
324 ),
325 );
326 }
327 $batch = array(
328 'title' => t('Downloading updates'),
329 'init_message' => t('Preparing to download selected updates'),
330 'operations' => $operations,
331 'finished' => 'update_manager_download_batch_finished',
332 'file' => drupal_get_path('module', 'update') . '/update.manager.inc',
333 );
334 batch_set($batch);
335 }
336
345 function update_manager_download_batch_finished($success, $results) {
346 if (!empty($results['errors'])) {
347 $error_list = array(
348 'title' => t('Downloading updates failed:'),
349 'items' => $results['errors'],
350 );
351 drupal_set_message(theme('item_list', $error_list), 'error');
352 }
353 elseif ($success) {
354 drupal_set_message(t('Updates downloaded successfully.'));
355 $_SESSION['update_manager_update_projects'] = $results['projects'];
356 drupal_goto('admin/update/ready');
357 }
358 else {
359 // Ideally we're catching all Exceptions, so they should never see this,
360 // but just in case, we have to tell them something.
361 drupal_set_message(t('Fatal error trying to download.'), 'error');
362 }
363 }
364
382 function update_manager_update_ready_form($form, &$form_state) {
383 if (!_update_manager_check_backends($form, 'update')) {
384 return $form;
385 }
386
387 $form['backup'] = array(
388 '#prefix' => '<strong>',
389 '#markup' => t('Back up your database and site before you continue. <a href="@backup_url">Learn how</a>.', array('@backup_url' => url('http://drupal.org/node/22281'))),
390 '#suffix' => '</strong>',
391 );
392
393 $form['maintenance_mode'] = array(
394 '#title' => t('Perform updates with site in maintenance mode (strongly recommended)'),
395 '#type' => 'checkbox',
396 '#default_value' => TRUE,
397 );
398
399 $form['actions'] = array('#type' => 'actions');
400 $form['actions']['submit'] = array(
401 '#type' => 'submit',
402 '#value' => t('Continue'),
403 );
404
405 return $form;
406 }
407
421 function update_manager_update_ready_form_submit($form, &$form_state) {
422 // Store maintenance_mode setting so we can restore it when done.
423 $_SESSION['maintenance_mode'] = variable_get('maintenance_mode', FALSE);
424 if ($form_state['values']['maintenance_mode'] == TRUE) {
425 variable_set('maintenance_mode', TRUE);
426 }
427
428 if (!empty($_SESSION['update_manager_update_projects'])) {
429 // Make sure the Updater registry is loaded.
430 drupal_get_updaters();
431
432 $updates = array();
433 $directory = _update_manager_extract_directory();
434
435 $projects = $_SESSION['update_manager_update_projects'];
436 unset($_SESSION['update_manager_update_projects']);
437
438 foreach ($projects as $project => $url) {
439 $project_location = $directory . '/' . $project;
440 $updater = Updater::factory($project_location);
441 $project_real_location = drupal_realpath($project_location);
442 $updates[] = array(
443 'project' => $project,
444 'updater_name' => get_class($updater),
445 'local_url' => $project_real_location,
446 );
447 }
448
449 // If the owner of the last directory we extracted is the same as the
450 // owner of our configuration directory (e.g. sites/default) where we're
451 // trying to install the code, there's no need to prompt for FTP/SSH
452 // credentials. Instead, we instantiate a FileTransferLocal and invoke
453 // update_authorize_run_update() directly.
454 if (fileowner($project_real_location) == fileowner(conf_path())) {
455 module_load_include('inc', 'update', 'update.authorize');
456 $filetransfer = new FileTransferLocal(DRUPAL_ROOT);
457 update_authorize_run_update($filetransfer, $updates);
458 }
459 // Otherwise, go through the regular workflow to prompt for FTP/SSH
460 // credentials and invoke update_authorize_run_update() indirectly with
461 // whatever FileTransfer object authorize.php creates for us.
462 else {
463 system_authorized_init('update_authorize_run_update', drupal_get_path('module', 'update') . '/update.authorize.inc', array($updates), t('Update manager'));
464 $form_state['redirect'] = system_authorized_get_url();
465 }
466 }
467 }
468
496 function update_manager_install_form($form, &$form_state, $context) {
497 if (!_update_manager_check_backends($form, 'install')) {
498 return $form;
499 }
500
501 $form['help_text'] = array(
502 '#prefix' => '<p>',
503 '#markup' => t('You can find <a href="@module_url">modules</a> and <a href="@theme_url">themes</a> on <a href="@drupal_org_url">drupal.org</a>. The following file extensions are supported: %extensions.', array(
504 '@module_url' => 'http://drupal.org/project/modules',
505 '@theme_url' => 'http://drupal.org/project/themes',
506 '@drupal_org_url' => 'http://drupal.org',
507 '%extensions' => archiver_get_extensions(),
508 )),
509 '#suffix' => '</p>',
510 );
511
512 $form['project_url'] = array(
513 '#type' => 'textfield',
514 '#title' => t('Install from a URL'),
515 '#description' => t('For example: %url', array('%url' => 'http://ftp.drupal.org/files/projects/name.tar.gz')),
516 );
517
518 $form['information'] = array(
519 '#prefix' => '<strong>',
520 '#markup' => t('Or'),
521 '#suffix' => '</strong>',
522 );
523
524 $form['project_upload'] = array(
525 '#type' => 'file',
526 '#title' => t('Upload a module or theme archive to install'),
527 '#description' => t('For example: %filename from your local computer', array('%filename' => 'name.tar.gz')),
528 );
529
530 $form['actions'] = array('#type' => 'actions');
531 $form['actions']['submit'] = array(
532 '#type' => 'submit',
533 '#value' => t('Install'),
534 );
535
536 return $form;
537 }
538
553 function _update_manager_check_backends(&$form, $operation) {
554 // If file transfers will be performed locally, we do not need to display any
555 // warnings or notices to the user and should automatically continue the
556 // workflow, since we won't be using a FileTransfer backend that requires
557 // user input or a specific server configuration.
558 if (update_manager_local_transfers_allowed()) {
559 return TRUE;
560 }
561
562 // Otherwise, show the available backends.
563 $form['available_backends'] = array(
564 '#prefix' => '<p>',
565 '#suffix' => '</p>',
566 );
567
568 $available_backends = drupal_get_filetransfer_info();
569 if (empty($available_backends)) {
570 if ($operation == 'update') {
571 $form['available_backends']['#markup'] = t('Your server does not support updating modules and themes from this interface. Instead, update modules and themes by uploading the new versions directly to the server, as described in the <a href="@handbook_url">handbook</a>.', array('@handbook_url' => 'http://drupal.org/getting-started/install-contrib'));
572 }
573 else {
574 $form['available_backends']['#markup'] = t('Your server does not support installing modules and themes from this interface. Instead, install modules and themes by uploading them directly to the server, as described in the <a href="@handbook_url">handbook</a>.', array('@handbook_url' => 'http://drupal.org/getting-started/install-contrib'));
575 }
576 return FALSE;
577 }
578
579 $backend_names = array();
580 foreach ($available_backends as $backend) {
581 $backend_names[] = $backend['title'];
582 }
583 if ($operation == 'update') {
584 $form['available_backends']['#markup'] = format_plural(
585 count($available_backends),
586 'Updating modules and themes requires <strong>@backends access</strong> to your server. See the <a href="@handbook_url">handbook</a> for other update methods.',
587 'Updating modules and themes requires access to your server via one of the following methods: <strong>@backends</strong>. See the <a href="@handbook_url">handbook</a> for other update methods.',
588 array(
589 '@backends' => implode(', ', $backend_names),
590 '@handbook_url' => 'http://drupal.org/getting-started/install-contrib',
591 ));
592 }
593 else {
594 $form['available_backends']['#markup'] = format_plural(
595 count($available_backends),
596 'Installing modules and themes requires <strong>@backends access</strong> to your server. See the <a href="@handbook_url">handbook</a> for other installation methods.',
597 'Installing modules and themes requires access to your server via one of the following methods: <strong>@backends</strong>. See the <a href="@handbook_url">handbook</a> for other installation methods.',
598 array(
599 '@backends' => implode(', ', $backend_names),
600 '@handbook_url' => 'http://drupal.org/getting-started/install-contrib',
601 ));
602 }
603 return TRUE;
604 }
605
611 function update_manager_install_form_validate($form, &$form_state) {
612 if (!($form_state['values']['project_url'] XOR !empty($_FILES['files']['name']['project_upload']))) {
613 form_set_error('project_url', t('You must either provide a URL or upload an archive file to install.'));
614 }
615
616 if ($form_state['values']['project_url']) {
617 if (!valid_url($form_state['values']['project_url'], TRUE)) {
618 form_set_error('project_url', t('The provided URL is invalid.'));
619 }
620 }
621 }
622
639 function update_manager_install_form_submit($form, &$form_state) {
640 if ($form_state['values']['project_url']) {
641 $field = 'project_url';
642 $local_cache = update_manager_file_get($form_state['values']['project_url']);
643 if (!$local_cache) {
644 form_set_error($field, t('Unable to retrieve Drupal project from %url.', array('%url' => $form_state['values']['project_url'])));
645 return;
646 }
647 }
648 elseif ($_FILES['files']['name']['project_upload']) {
649 $validators = array('file_validate_extensions' => array(archiver_get_extensions()));
650 $field = 'project_upload';
651 if (!($finfo = file_save_upload($field, $validators, NULL, FILE_EXISTS_REPLACE))) {
652 // Failed to upload the file. file_save_upload() calls form_set_error() on
653 // failure.
654 return;
655 }
656 $local_cache = $finfo->uri;
657 }
658
659 $directory = _update_manager_extract_directory();
660 try {
661 $archive = update_manager_archive_extract($local_cache, $directory);
662 }
663 catch (Exception $e) {
664 form_set_error($field, $e->getMessage());
665 return;
666 }
667
668 $files = $archive->listContents();
669 if (!$files) {
670 form_set_error($field, t('Provided archive contains no files.'));
671 return;
672 }
673
674 // Unfortunately, we can only use the directory name to determine the project
675 // name. Some archivers list the first file as the directory (i.e., MODULE/)
676 // and others list an actual file (i.e., MODULE/README.TXT).
677 $project = strtok($files[0], '/\\');
678
679 $archive_errors = update_manager_archive_verify($project, $local_cache, $directory);
680 if (!empty($archive_errors)) {
681 form_set_error($field, array_shift($archive_errors));
682 // @todo: Fix me in D8: We need a way to set multiple errors on the same
683 // form element and have all of them appear!
684 if (!empty($archive_errors)) {
685 foreach ($archive_errors as $error) {
686 drupal_set_message($error, 'error');
687 }
688 }
689 return;
690 }
691
692 // Make sure the Updater registry is loaded.
693 drupal_get_updaters();
694
695 $project_location = $directory . '/' . $project;
696 try {
697 $updater = Updater::factory($project_location);
698 }
699 catch (Exception $e) {
700 form_set_error($field, $e->getMessage());
701 return;
702 }
703
704 try {
705 $project_title = Updater::getProjectTitle($project_location);
706 }
707 catch (Exception $e) {
708 form_set_error($field, $e->getMessage());
709 return;
710 }
711
712 if (!$project_title) {
713 form_set_error($field, t('Unable to determine %project name.', array('%project' => $project)));
714 }
715
716 if ($updater->isInstalled()) {
717 form_set_error($field, t('%project is already installed.', array('%project' => $project_title)));
718 return;
719 }
720
721 $project_real_location = drupal_realpath($project_location);
722 $arguments = array(
723 'project' => $project,
724 'updater_name' => get_class($updater),
725 'local_url' => $project_real_location,
726 );
727
728 // If the owner of the directory we extracted is the same as the
729 // owner of our configuration directory (e.g. sites/default) where we're
730 // trying to install the code, there's no need to prompt for FTP/SSH
731 // credentials. Instead, we instantiate a FileTransferLocal and invoke
732 // update_authorize_run_install() directly.
733 if (fileowner($project_real_location) == fileowner(conf_path())) {
734 module_load_include('inc', 'update', 'update.authorize');
735 $filetransfer = new FileTransferLocal(DRUPAL_ROOT);
736 call_user_func_array('update_authorize_run_install', array_merge(array($filetransfer), $arguments));
737 }
738 // Otherwise, go through the regular workflow to prompt for FTP/SSH
739 // credentials and invoke update_authorize_run_install() indirectly with
740 // whatever FileTransfer object authorize.php creates for us.
741 else {
742 system_authorized_init('update_authorize_run_install', drupal_get_path('module', 'update') . '/update.authorize.inc', $arguments, t('Update manager'));
743 $form_state['redirect'] = system_authorized_get_url();
744 }
745 }
746
773 function update_manager_archive_extract($file, $directory) {
774 $archiver = archiver_get_archiver($file);
775 if (!$archiver) {
776 throw new Exception(t('Cannot extract %file, not a valid archive.', array ('%file' => $file)));
777 }
778
779 // Remove the directory if it exists, otherwise it might contain a mixture of
780 // old files mixed with the new files (e.g. in cases where files were removed
781 // from a later release).
782 $files = $archiver->listContents();
783
784 // Unfortunately, we can only use the directory name to determine the project
785 // name. Some archivers list the first file as the directory (i.e., MODULE/)
786 // and others list an actual file (i.e., MODULE/README.TXT).
787 $project = strtok($files[0], '/\\');
788
789 $extract_location = $directory . '/' . $project;
790 if (file_exists($extract_location)) {
791 file_unmanaged_delete_recursive($extract_location);
792 }
793
794 $archiver->extract($directory);
795 return $archiver;
796 }
797
814 function update_manager_archive_verify($project, $archive_file, $directory) {
815 return module_invoke_all('verify_update_archive', $project, $archive_file, $directory);
816 }
817
829 function update_manager_file_get($url) {
830 $parsed_url = parse_url($url);
831 $remote_schemes = array('http', 'https', 'ftp', 'ftps', 'smb', 'nfs');
832 if (!in_array($parsed_url['scheme'], $remote_schemes)) {
833 // This is a local file, just return the path.
834 return drupal_realpath($url);
835 }
836
837 // Check the cache and download the file if needed.
838 $cache_directory = _update_manager_cache_directory();
839 $local = $cache_directory . '/' . drupal_basename($parsed_url['path']);
840
841 if (!file_exists($local) || update_delete_file_if_stale($local)) {
842 return system_retrieve_file($url, $local, FALSE, FILE_EXISTS_REPLACE);
843 }
844 else {
845 return $local;
846 }
847 }
848
865 function update_manager_batch_project_get($project, $url, &$context) {
866 // This is here to show the user that we are in the process of downloading.
867 if (!isset($context['sandbox']['started'])) {
868 $context['sandbox']['started'] = TRUE;
869 $context['message'] = t('Downloading %project', array('%project' => $project));
870 $context['finished'] = 0;
871 return;
872 }
873
874 // Actually try to download the file.
875 if (!($local_cache = update_manager_file_get($url))) {
876 $context['results']['errors'][$project] = t('Failed to download %project from %url', array('%project' => $project, '%url' => $url));
877 return;
878 }
879
880 // Extract it.
881 $extract_directory = _update_manager_extract_directory();
882 try {
883 update_manager_archive_extract($local_cache, $extract_directory);
884 }
885 catch (Exception $e) {
886 $context['results']['errors'][$project] = $e->getMessage();
887 return;
888 }
889
890 // Verify it.
891 $archive_errors = update_manager_archive_verify($project, $local_cache, $extract_directory);
892 if (!empty($archive_errors)) {
893 // We just need to make sure our array keys don't collide, so use the
894 // numeric keys from the $archive_errors array.
895 foreach ($archive_errors as $key => $error) {
896 $context['results']['errors']["$project-$key"] = $error;
897 }
898 return;
899 }
900
901 // Yay, success.
902 $context['results']['projects'][$project] = $url;
903 $context['finished'] = 1;
904 }
905
927 function update_manager_local_transfers_allowed() {
928 // Compare the owner of a webserver-created temporary file to the owner of
929 // the configuration directory to determine if local transfers will be
930 // allowed.
931 $temporary_file = drupal_tempnam('temporary://', 'update_');
932 $local_transfers_allowed = fileowner($temporary_file) === fileowner(conf_path());
933
934 // Clean up. If this fails, we can ignore it (since this is just a temporary
935 // file anyway).
936 @drupal_unlink($temporary_file);
937
938 return $local_transfers_allowed;
939 }
940
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
UPDATE_NOT_CURRENT
const UPDATE_NOT_CURRENT
Definition: update.module:39
update_manager_archive_verify
update_manager_archive_verify($project, $archive_file, $directory)
Definition: update.manager.inc:814
theme_update_manager_update_form
theme_update_manager_update_form($variables)
Definition: update.manager.inc:276
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
archiver_get_extensions
archiver_get_extensions()
Definition: common.inc:8119
drupal_unlink
drupal_unlink($uri, $context=NULL)
Definition: file.inc:2225
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
system_authorized_get_url
system_authorized_get_url(array $options=array())
Definition: system.module:1803
system_retrieve_file
system_retrieve_file($url, $destination=NULL, $managed=FALSE, $replace=FILE_EXISTS_RENAME)
Definition: system.module:3450
file_unmanaged_delete_recursive
file_unmanaged_delete_recursive($path)
Definition: file.inc:1358
update_manager_update_form_submit
update_manager_update_form_submit($form, &$form_state)
Definition: update.manager.inc:310
update_calculate_project_data
update_calculate_project_data($available)
Definition: update.compare.inc:335
$name
print $name
Definition: profile-listing.tpl.php:43
$results
print $results
Definition: poll-results.tpl.php:23
drupal_tempnam
drupal_tempnam($directory, $prefix)
Definition: file.inc:2424
update_manager_file_get
update_manager_file_get($url)
Definition: update.manager.inc:829
Exception
drupal_realpath
drupal_realpath($uri)
Definition: file.inc:2259
$attributes
print $attributes
Definition: block.tpl.php:47
UPDATE_UNKNOWN
const UPDATE_UNKNOWN
Definition: update.module:54
UPDATE_REVOKED
const UPDATE_REVOKED
Definition: update.module:29
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
archiver_get_archiver
archiver_get_archiver($file)
Definition: common.inc:8145
update_authorize_run_update
update_authorize_run_update($filetransfer, $projects)
Definition: update.authorize.inc:29
_update_manager_extract_directory
_update_manager_extract_directory($create=TRUE)
Definition: update.module:918
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$url
print $url
Definition: search-result.tpl.php:70
batch_set
batch_set($batch_definition)
Definition: form.inc:4381
FILE_EXISTS_REPLACE
const FILE_EXISTS_REPLACE
Definition: file.inc:56
_update_manager_cache_directory
_update_manager_cache_directory($create=TRUE)
Definition: update.module:940
update_manager_batch_project_get
update_manager_batch_project_get($project, $url, &$context)
Definition: update.manager.inc:865
Updater\getProjectTitle
static getProjectTitle($directory)
Definition: updater.inc:178
UPDATE_NOT_CHECKED
const UPDATE_NOT_CHECKED
Definition: update.module:49
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
update_manager_install_form_validate
update_manager_install_form_validate($form, &$form_state)
Definition: update.manager.inc:611
$output
$output
Definition: authorize.php:93
update_manager_update_ready_form
update_manager_update_ready_form($form, &$form_state)
Definition: update.manager.inc:382
update_manager_update_form
update_manager_update_form($form, $form_state=array(), $context)
Definition: update.manager.inc:62
update_manager_update_form_validate
update_manager_update_form_validate($form, &$form_state)
Definition: update.manager.inc:291
file_save_upload
file_save_upload($source, $validators=array(), $destination=FALSE, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1437
system_authorized_init
system_authorized_init($callback, $file, $arguments=array(), $page_title=NULL)
Definition: system.module:1775
UPDATE_CURRENT
const UPDATE_CURRENT
Definition: update.module:44
Updater\factory
static factory($source)
Definition: updater.inc:94
conf_path
conf_path($require_settings=TRUE, $reset=FALSE)
Definition: bootstrap.inc:541
update_manager_download_batch_finished
update_manager_download_batch_finished($success, $results)
Definition: update.manager.inc:345
UPDATE_NOT_FETCHED
const UPDATE_NOT_FETCHED
Definition: update.module:59
FileTransferLocal
Definition: local.inc:6
update_manager_update_ready_form_submit
update_manager_update_ready_form_submit($form, &$form_state)
Definition: update.manager.inc:421
_update_manager_check_backends
_update_manager_check_backends(&$form, $operation)
Definition: update.manager.inc:553
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
UPDATE_NOT_SUPPORTED
const UPDATE_NOT_SUPPORTED
Definition: update.module:34
drupal_basename
drupal_basename($uri, $suffix=NULL)
Definition: file.inc:2317
update_manager_install_form_submit
update_manager_install_form_submit($form, &$form_state)
Definition: update.manager.inc:639
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
drupal_get_updaters
drupal_get_updaters()
Definition: common.inc:8180
valid_url
valid_url($url, $absolute=FALSE)
Definition: common.inc:1204
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
update_get_available
update_get_available($refresh=FALSE)
Definition: update.module:394
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
update_manager_archive_extract
update_manager_archive_extract($file, $directory)
Definition: update.manager.inc:773
drupal_get_filetransfer_info
drupal_get_filetransfer_info()
Definition: common.inc:8200
UPDATE_NOT_SECURE
const UPDATE_NOT_SECURE
Definition: update.module:24
update_manager_install_form
update_manager_install_form($form, &$form_state, $context)
Definition: update.manager.inc:496
update_manager_local_transfers_allowed
update_manager_local_transfers_allowed()
Definition: update.manager.inc:927
update_delete_file_if_stale
update_delete_file_if_stale($path)
Definition: update.module:986
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/overlay/overlay.api.php Source File

  • modules
  • overlay
overlay.api.php
Go to the documentation of this file.
1 <?php
2
21 function hook_overlay_parent_initialize() {
22 // Add our custom JavaScript.
23 drupal_add_js(drupal_get_path('module', 'hook') . '/hook-overlay.js');
24 }
25
33 function hook_overlay_child_initialize() {
34 // Add our custom JavaScript.
35 drupal_add_js(drupal_get_path('module', 'hook') . '/hook-overlay-child.js');
36 }
37
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
hook_overlay_parent_initialize
hook_overlay_parent_initialize()
Definition: overlay.api.php:21
hook_overlay_child_initialize
hook_overlay_child_initialize()
Definition: overlay.api.php:33
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/utility.inc Source File

  • includes
utility.inc
Go to the documentation of this file.
1 <?php
2
19 function drupal_var_export($var, $prefix = '') {
20 if (is_array($var)) {
21 if (empty($var)) {
22 $output = 'array()';
23 }
24 else {
25 $output = "array(\n";
26 // Don't export keys if the array is non associative.
27 $export_keys = array_values($var) != $var;
28 foreach ($var as $key => $value) {
29 $output .= ' ' . ($export_keys ? drupal_var_export($key) . ' => ' : '') . drupal_var_export($value, ' ', FALSE) . ",\n";
30 }
31 $output .= ')';
32 }
33 }
34 elseif (is_bool($var)) {
35 $output = $var ? 'TRUE' : 'FALSE';
36 }
37 elseif (is_string($var)) {
38 $line_safe_var = str_replace("\n", '\n', $var);
39 if (strpos($var, "\n") !== FALSE || strpos($var, "'") !== FALSE) {
40 // If the string contains a line break or a single quote, use the
41 // double quote export mode. Encode backslash and double quotes and
42 // transform some common control characters.
43 $var = str_replace(array('\\', '"', "\n", "\r", "\t"), array('\\\\', '\"', '\n', '\r', '\t'), $var);
44 $output = '"' . $var . '"';
45 }
46 else {
47 $output = "'" . $var . "'";
48 }
49 }
50 elseif (is_object($var) && get_class($var) === 'stdClass') {
51 // var_export() will export stdClass objects using an undefined
52 // magic method __set_state() leaving the export broken. This
53 // workaround avoids this by casting the object as an array for
54 // export and casting it back to an object when evaluated.
55 $output = '(object) ' . drupal_var_export((array) $var, $prefix);
56 }
57 else {
58 $output = var_export($var, TRUE);
59 }
60
61 if ($prefix) {
62 $output = str_replace("\n", "\n$prefix", $output);
63 }
64
65 return $output;
66 }
drupal_var_export
drupal_var_export($var, $prefix= '')
Definition: utility.inc:19
$value
print $value
Definition: user-profile-item.tpl.php:26
$output
$output
Definition: authorize.php:93
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
FileTransferException Member List

This is the complete list of members for FileTransferException, including all inherited members.

$arguments | FileTransferException
__construct($message, $code=0, $arguments=array()) | FileTransferException
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/toolbar/toolbar.tpl.php Source File

  • modules
  • toolbar
toolbar.tpl.php
Go to the documentation of this file.
1 <?php
2
25 ?>
26 <div id="toolbar" class="<?php print $classes; ?> clearfix">
27 <div class="toolbar-menu clearfix">
28 <?php print render($toolbar['toolbar_home']); ?>
29 <?php print render($toolbar['toolbar_user']); ?>
30 <?php print render($toolbar['toolbar_menu']); ?>
31 <?php if ($toolbar['toolbar_drawer']):?>
32 <?php print render($toolbar['toolbar_toggle']); ?>
33 <?php endif; ?>
34 </div>
35
36 <div class="<?php echo $toolbar['toolbar_drawer_classes']; ?>">
37 <?php print render($toolbar['toolbar_drawer']); ?>
38 </div>
39 </div>
print
print
Definition: php-2.php:2
endif
endif
Definition: aggregator-item.tpl.php:31
render
render(&$element)
Definition: common.inc:5988
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/region.tpl.php Source File

  • modules
  • system
region.tpl.php
Go to the documentation of this file.
1 <?php
2
30 ?>
31 <?php if ($content): ?>
32 <div class="<?php print $classes; ?>">
33 <?php print $content; ?>
34 </div>
35 <?php endif; ?>
print
print
Definition: php-2.php:2
endif
endif
Definition: aggregator-item.tpl.php:31
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/blog/blog.install Source File

  • modules
  • blog
blog.install
Go to the documentation of this file.
1 <?php
2
11 function blog_install() {
12 // Ensure the blog node type is available.
13 node_types_rebuild();
14 $types = node_type_get_types();
15 node_add_body_field($types['blog']);
16 }
17
21 function blog_uninstall() {
22 variable_del('blog_block_count');
23 }
variable_del
variable_del($name)
Definition: bootstrap.inc:996
node_type_get_types
node_type_get_types()
Definition: node.module:393
node_add_body_field
node_add_body_field($type, $label= 'Body')
Definition: node.module:586
node_types_rebuild
node_types_rebuild()
Definition: node.module:475
blog_uninstall
blog_uninstall()
Definition: blog.install:21
blog_install
blog_install()
Definition: blog.install:11
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/help/help.admin.inc Source File

  • modules
  • help
help.admin.inc
Go to the documentation of this file.
1 <?php
2
11 function help_main() {
12 // Add CSS
13 drupal_add_css(drupal_get_path('module', 'help') . '/help.css');
14 $output = '<h2>' . t('Help topics') . '</h2><p>' . t('Help is available on the following items:') . '</p>' . help_links_as_list();
15 return $output;
16 }
17
24 function help_page($name) {
25 $output = '';
26 if (module_hook($name, 'help')) {
27 $info = system_get_info('module');
28 drupal_set_title($info[$name]['name']);
29
30 $temp = module_invoke($name, 'help', "admin/help#$name", drupal_help_arg());
31 if (empty($temp)) {
32 $output .= t("No help is available for module %module.", array('%module' => $info[$name]['name']));
33 }
34 else {
35 $output .= $temp;
36 }
37
38 // Only print list of administration pages if the module in question has
39 // any such pages associated to it.
40 $admin_tasks = system_get_module_admin_tasks($name, $info[$name]);
41 if (!empty($admin_tasks)) {
42 $links = array();
43 foreach ($admin_tasks as $task) {
44 $links[] = l($task['title'], $task['link_path'], $task['localized_options']);
45 }
46 $output .= theme('item_list', array('items' => $links, 'title' => t('@module administration pages', array('@module' => $info[$name]['name']))));
47 }
48 }
49 return $output;
50 }
51
58 function help_links_as_list() {
59 $empty_arg = drupal_help_arg();
60 $module_info = system_rebuild_module_data();
61
62 $modules = array();
63 foreach (module_implements('help', TRUE) as $module) {
64 if (module_invoke($module, 'help', "admin/help#$module", $empty_arg)) {
65 $modules[$module] = $module_info[$module]->info['name'];
66 }
67 }
68 asort($modules);
69
70 // Output pretty four-column list.
71 $count = count($modules);
72 $break = ceil($count / 4);
73 $output = '<div class="clearfix"><div class="help-items"><ul>';
74 $i = 0;
75 foreach ($modules as $module => $name) {
76 $output .= '<li>' . l($name, 'admin/help/' . $module) . '</li>';
77 if (($i + 1) % $break == 0 && ($i + 1) != $count) {
78 $output .= '</ul></div><div class="help-items' . ($i + 1 == $break * 3 ? ' help-items-last' : '') . '"><ul>';
79 }
80 $i++;
81 }
82 $output .= '</ul></div></div>';
83
84 return $output;
85 }
86
help_page
help_page($name)
Definition: help.admin.inc:24
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
help_links_as_list
help_links_as_list()
Definition: help.admin.inc:58
$module
print $module
Definition: search-results.tpl.php:28
drupal_help_arg
drupal_help_arg($arg=array())
Definition: menu.inc:1700
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
help_main
help_main()
Definition: help.admin.inc:11
$name
print $name
Definition: profile-listing.tpl.php:43
system_rebuild_module_data
system_rebuild_module_data()
Definition: system.module:2444
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
module_hook
module_hook($module, $hook)
Definition: module.inc:659
system_get_info
system_get_info($type, $name=NULL)
Definition: system.module:2338
$info
$info
Definition: color.inc:6
$output
$output
Definition: authorize.php:93
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
system_get_module_admin_tasks
system_get_module_admin_tasks($module, $info)
Definition: system.module:2930
$links
print $links
Definition: poll-results--block.tpl.php:28
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/rdf/rdf.module Source File

  • modules
  • rdf
rdf.module
Go to the documentation of this file.
1 <?php
2
11 function rdf_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#rdf':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t('The RDF module enriches your content with metadata to let other applications (e.g., search engines, aggregators, and so on) better understand its relationships and attributes. This semantically enriched, machine-readable output for Drupal sites uses the <a href="@rdfa">RDFa specification</a> which allows RDF data to be embedded in HTML markup. Other modules can define mappings of their data to RDF terms, and the RDF module makes this RDF data available to the theme. The core Drupal modules define RDF mappings for their data model, and the core Drupal themes output this RDF metadata information along with the human-readable visual information. For more information, see the online handbook entry for <a href="@rdf">RDF module</a>.', array('@rdfa' => 'http://www.w3.org/TR/xhtml-rdfa-primer/', '@rdf' => 'http://drupal.org/documentation/modules/rdf')) . '</p>';
17 return $output;
18 }
19 }
20
74 define('RDF_DEFAULT_BUNDLE', '');
75
79 function rdf_rdf_namespaces() {
80 return array(
81 'content' => 'http://purl.org/rss/1.0/modules/content/',
82 'dc' => 'http://purl.org/dc/terms/',
83 'foaf' => 'http://xmlns.com/foaf/0.1/',
84 'og' => 'http://ogp.me/ns#',
85 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
86 'sioc' => 'http://rdfs.org/sioc/ns#',
87 'sioct' => 'http://rdfs.org/sioc/types#',
88 'skos' => 'http://www.w3.org/2004/02/skos/core#',
89 'xsd' => 'http://www.w3.org/2001/XMLSchema#',
90 );
91 }
92
97 function rdf_get_namespaces() {
98 $rdf_namespaces = module_invoke_all('rdf_namespaces');
99 // module_invoke_all() uses array_merge_recursive() which might return nested
100 // arrays if several modules redefine the same prefix multiple times. We need
101 // to ensure the array of namespaces is flat and only contains strings as
102 // URIs.
103 foreach ($rdf_namespaces as $prefix => $uri) {
104 if (is_array($uri)) {
105 if (count(array_unique($uri)) == 1) {
106 // All namespaces declared for this prefix are the same, merge them all
107 // into a single namespace.
108 $rdf_namespaces[$prefix] = $uri[0];
109 }
110 else {
111 // There are conflicting namespaces for this prefix, do not include
112 // duplicates in order to avoid asserting any inaccurate RDF
113 // statements.
114 unset($rdf_namespaces[$prefix]);
115 }
116 }
117 }
118 return $rdf_namespaces;
119 }
120
133 function rdf_mapping_load($type, $bundle = RDF_DEFAULT_BUNDLE) {
134 // Retrieves the bundle-specific mapping from the entity info.
135 $entity_info = entity_get_info($type);
136 if (!empty($entity_info['bundles'][$bundle]['rdf_mapping'])) {
137 return $entity_info['bundles'][$bundle]['rdf_mapping'];
138 }
139 // If there is no mapping defined for this bundle, we return the default
140 // mapping that is defined for this entity type.
141 else {
142 return _rdf_get_default_mapping($type);
143 }
144 }
145
160 function _rdf_get_default_mapping($type) {
161 $default_mappings = &drupal_static(__FUNCTION__);
162
163 if (!isset($default_mappings)) {
164 // Get all of the modules that implement hook_rdf_mapping().
165 $modules = module_implements('rdf_mapping');
166
167 // Only consider the default entity mapping definitions.
168 foreach ($modules as $module) {
169 $mappings = module_invoke($module, 'rdf_mapping');
170 foreach ($mappings as $mapping) {
171 if ($mapping['bundle'] === RDF_DEFAULT_BUNDLE) {
172 $default_mappings[$mapping['type']] = $mapping['mapping'];
173 }
174 }
175 }
176 }
177
178 return isset($default_mappings[$type]) ? $default_mappings[$type] : array();
179 }
180
192 function _rdf_mapping_load($type, $bundle) {
193 $mapping = db_select('rdf_mapping')
194 ->fields(NULL, array('mapping'))
195 ->condition('type', $type)
196 ->condition('bundle', $bundle)
197 ->execute()
198 ->fetchField();
199
200 if (!$mapping) {
201 return array();
202 }
203 return unserialize($mapping);
204 }
205
225 function rdf_mapping_save($mapping) {
226 // In the case where a field has a mapping defined in the default entity
227 // mapping, but a mapping is not specified in the bundle-specific mapping,
228 // then use the default mapping for that field.
229 $mapping['mapping'] += _rdf_get_default_mapping($mapping['type']);
230
231 $status = db_merge('rdf_mapping')
232 ->key(array(
233 'type' => $mapping['type'],
234 'bundle' => $mapping['bundle'],
235 ))
236 ->fields(array(
237 'mapping' => serialize($mapping['mapping']),
238 ))
239 ->execute();
240
241 entity_info_cache_clear();
242
243 return $status;
244 }
245
257 function rdf_mapping_delete($type, $bundle) {
258 $num_rows = db_delete('rdf_mapping')
259 ->condition('type', $type)
260 ->condition('bundle', $bundle)
261 ->execute();
262
263 return (bool) ($num_rows > 0);
264 }
265
291 function rdf_rdfa_attributes($mapping, $data = NULL) {
292 // The type of mapping defaults to 'property'.
293 $type = isset($mapping['type']) ? $mapping['type'] : 'property';
294
295 switch ($type) {
296 // The mapping expresses the relationship between two resources.
297 case 'rel':
298 case 'rev':
299 $attributes[$type] = $mapping['predicates'];
300 break;
301
302 // The mapping expresses the relationship between a resource and some
303 // literal text.
304 case 'property':
305 $attributes['property'] = $mapping['predicates'];
306 // Convert $data to a specific format as per the callback function.
307 if (isset($data) && isset($mapping['callback']) && function_exists($mapping['callback'])) {
308 $callback = $mapping['callback'];
309 $attributes['content'] = $callback($data);
310 }
311 if (isset($mapping['datatype'])) {
312 $attributes['datatype'] = $mapping['datatype'];
313 }
314 break;
315 }
316
317 return $attributes;
318 }
319
336 function rdf_modules_installed($modules) {
337 foreach ($modules as $module) {
338 $function = $module . '_rdf_mapping';
339 if (function_exists($function)) {
340 foreach ($function() as $mapping) {
341 // Only the bundle mappings are saved in the database.
342 if ($mapping['bundle'] !== RDF_DEFAULT_BUNDLE) {
343 rdf_mapping_save($mapping);
344 }
345 }
346 }
347 }
348 }
349
353 function rdf_modules_uninstalled($modules) {
354 // @todo Remove RDF mappings of uninstalled modules.
355 }
356
368 function rdf_entity_info_alter(&$entity_info) {
369 // Loop through each entity type and its bundles.
370 foreach ($entity_info as $entity_type => $entity_type_info) {
371 if (isset($entity_type_info['bundles'])) {
372 foreach ($entity_type_info['bundles'] as $bundle => $bundle_info) {
373 if ($mapping = _rdf_mapping_load($entity_type, $bundle)) {
374 $entity_info[$entity_type]['bundles'][$bundle]['rdf_mapping'] = $mapping;
375 }
376 else {
377 // If no mapping was found in the database, assign the default RDF
378 // mapping for this entity type.
379 $entity_info[$entity_type]['bundles'][$bundle]['rdf_mapping'] = _rdf_get_default_mapping($entity_type);
380 }
381 }
382 }
383 }
384 }
385
389 function rdf_entity_load($entities, $type) {
390 foreach ($entities as $entity) {
391 // Extracts the bundle of the entity being loaded.
392 list($id, $vid, $bundle) = entity_extract_ids($type, $entity);
393 $entity->rdf_mapping = rdf_mapping_load($type, $bundle);
394 }
395 }
396
400 function rdf_comment_load($comments) {
401 foreach ($comments as $comment) {
402 // Pages with many comments can show poor performance. This information
403 // isn't needed until rdf_preprocess_comment() is called, but set it here
404 // to optimize performance for websites that implement an entity cache.
405 $comment->rdf_data['date'] = rdf_rdfa_attributes($comment->rdf_mapping['created'], $comment->created);
406 $comment->rdf_data['nid_uri'] = url('node/' . $comment->nid);
407 if ($comment->pid) {
408 $comment->rdf_data['pid_uri'] = url('comment/' . $comment->pid, array('fragment' => 'comment-' . $comment->pid));
409 }
410 }
411 }
412
416 function rdf_theme() {
417 return array(
418 'rdf_template_variable_wrapper' => array(
419 'variables' => array('content' => NULL, 'attributes' => array(), 'context' => array(), 'inline' => TRUE),
420 ),
421 'rdf_metadata' => array(
422 'variables' => array('metadata' => array()),
423 ),
424 );
425 }
426
436 function rdf_process(&$variables, $hook) {
437 // Handles attributes needed for content not covered by title, content,
438 // and field items. It does this by adjusting the variable sent to the
439 // template so that the template doesn't have to worry about it. See
440 // theme_rdf_template_variable_wrapper().
441 if (!empty($variables['rdf_template_variable_attributes_array'])) {
442 foreach ($variables['rdf_template_variable_attributes_array'] as $variable_name => $attributes) {
443 $context = array(
444 'hook' => $hook,
445 'variable_name' => $variable_name,
446 'variables' => $variables,
447 );
448 $variables[$variable_name] = theme('rdf_template_variable_wrapper', array('content' => $variables[$variable_name], 'attributes' => $attributes, 'context' => $context));
449 }
450 }
451 // Handles additional attributes about a template entity that for RDF parsing
452 // reasons, can't be placed into that template's $attributes variable. This
453 // is "meta" information that is related to particular content, so render it
454 // close to that content.
455 if (!empty($variables['rdf_metadata_attributes_array'])) {
456 if (!isset($variables['content']['#prefix'])) {
457 $variables['content']['#prefix'] = '';
458 }
459 $variables['content']['#prefix'] = theme('rdf_metadata', array('metadata' => $variables['rdf_metadata_attributes_array'])) . $variables['content']['#prefix'];
460 }
461 }
462
466 function rdf_preprocess_node(&$variables) {
467 // Adds RDFa markup to the node container. The about attribute specifies the
468 // URI of the resource described within the HTML element, while the @typeof
469 // attribute indicates its RDF type (e.g., foaf:Document, sioc:Person, and so
470 // on.)
471 $variables['attributes_array']['about'] = empty($variables['node_url']) ? NULL: $variables['node_url'];
472 $variables['attributes_array']['typeof'] = empty($variables['node']->rdf_mapping['rdftype']) ? NULL : $variables['node']->rdf_mapping['rdftype'];
473
474 // Adds RDFa markup to the title of the node. Because the RDFa markup is
475 // added to the <h2> tag which might contain HTML code, we specify an empty
476 // datatype to ensure the value of the title read by the RDFa parsers is a
477 // literal.
478 $variables['title_attributes_array']['property'] = empty($variables['node']->rdf_mapping['title']['predicates']) ? NULL : $variables['node']->rdf_mapping['title']['predicates'];
479 $variables['title_attributes_array']['datatype'] = '';
480
481 // In full node mode, the title is not displayed by node.tpl.php so it is
482 // added in the <head> tag of the HTML page.
483 if ($variables['page']) {
484 $element = array(
485 '#tag' => 'meta',
486 '#attributes' => array(
487 'content' => $variables['node']->title,
488 'about' => $variables['node_url'],
489 ),
490 );
491 if (!empty($variables['node']->rdf_mapping['title']['predicates'])) {
492 $element['#attributes']['property'] = $variables['node']->rdf_mapping['title']['predicates'];
493 }
494 drupal_add_html_head($element, 'rdf_node_title');
495 }
496
497 // Adds RDFa markup for the date.
498 if (!empty($variables['rdf_mapping']['created'])) {
499 $date_attributes_array = rdf_rdfa_attributes($variables['rdf_mapping']['created'], $variables['created']);
500 $variables['rdf_template_variable_attributes_array']['date'] = $date_attributes_array;
501 if ($variables['submitted']) {
502 $variables['rdf_template_variable_attributes_array']['submitted'] = $date_attributes_array;
503 }
504 }
505 // Adds RDFa markup for the relation between the node and its author.
506 if (!empty($variables['rdf_mapping']['uid'])) {
507 $variables['rdf_template_variable_attributes_array']['name']['rel'] = $variables['rdf_mapping']['uid']['predicates'];
508 if ($variables['submitted']) {
509 $variables['rdf_template_variable_attributes_array']['submitted']['rel'] = $variables['rdf_mapping']['uid']['predicates'];
510 }
511 }
512
513 // Adds RDFa markup annotating the number of comments a node has.
514 if (isset($variables['node']->comment_count) && !empty($variables['node']->rdf_mapping['comment_count']['predicates'])) {
515 // Annotates the 'x comments' link in teaser view.
516 if (isset($variables['content']['links']['comment']['#links']['comment-comments'])) {
517 $comment_count_attributes['property'] = $variables['node']->rdf_mapping['comment_count']['predicates'];
518 $comment_count_attributes['content'] = $variables['node']->comment_count;
519 $comment_count_attributes['datatype'] = $variables['node']->rdf_mapping['comment_count']['datatype'];
520 // According to RDFa parsing rule number 4, a new subject URI is created
521 // from the href attribute if no rel/rev attribute is present. To get the
522 // original node URL from the about attribute of the parent container we
523 // set an empty rel attribute which triggers rule number 5. See
524 // http://www.w3.org/TR/rdfa-syntax/#sec_5.5.
525 $comment_count_attributes['rel'] = '';
526 $variables['content']['links']['comment']['#links']['comment-comments']['attributes'] += $comment_count_attributes;
527 }
528 // In full node view, the number of comments is not displayed by
529 // node.tpl.php so it is expressed in RDFa in the <head> tag of the HTML
530 // page.
531 if ($variables['page'] && user_access('access comments')) {
532 $element = array(
533 '#tag' => 'meta',
534 '#attributes' => array(
535 'about' => $variables['node_url'],
536 'property' => $variables['node']->rdf_mapping['comment_count']['predicates'],
537 'content' => $variables['node']->comment_count,
538 'datatype' => $variables['node']->rdf_mapping['comment_count']['datatype'],
539 ),
540 );
541 drupal_add_html_head($element, 'rdf_node_comment_count');
542 }
543 }
544 }
545
549 function rdf_preprocess_field(&$variables) {
550 $element = $variables['element'];
551 $mapping = rdf_mapping_load($element['#entity_type'], $element['#bundle']);
552 $field_name = $element['#field_name'];
553
554 if (!empty($mapping) && !empty($mapping[$field_name])) {
555 foreach ($element['#items'] as $delta => $item) {
556 $variables['item_attributes_array'][$delta] = rdf_rdfa_attributes($mapping[$field_name], $item);
557 // If this field is an image, RDFa will not output correctly when the
558 // image is in a containing <a> tag. If the field is a file, RDFa will
559 // not output correctly if the filetype icon comes before the link to the
560 // file. We correct this by adding a resource attribute to the div if
561 // this field has a URI.
562 if (isset($item['uri'])) {
563 if (!empty($element[$delta]['#image_style'])) {
564 $variables['item_attributes_array'][$delta]['resource'] = image_style_url($element[$delta]['#image_style'], $item['uri']);
565 }
566 else {
567 $variables['item_attributes_array'][$delta]['resource'] = file_create_url($item['uri']);
568 }
569 }
570 }
571 }
572 }
573
577 function rdf_preprocess_user_profile(&$variables) {
578 $account = $variables['elements']['#account'];
579 $uri = entity_uri('user', $account);
580
581 // Adds RDFa markup to the user profile page. Fields displayed in this page
582 // will automatically describe the user.
583 if (!empty($account->rdf_mapping['rdftype'])) {
584 $variables['attributes_array']['typeof'] = $account->rdf_mapping['rdftype'];
585 $variables['attributes_array']['about'] = url($uri['path'], $uri['options']);
586 }
587 // Adds the relationship between the sioc:UserAccount and the foaf:Person who
588 // holds the account.
589 $account_holder_meta = array(
590 '#tag' => 'meta',
591 '#attributes' => array(
592 'about' => url($uri['path'], array_merge($uri['options'], array('fragment' => 'me'))),
593 'typeof' => array('foaf:Person'),
594 'rel' => array('foaf:account'),
595 'resource' => url($uri['path'], $uri['options']),
596 ),
597 );
598 // Adds the markup for username.
599 $username_meta = array(
600 '#tag' => 'meta',
601 '#attributes' => array(
602 'about' => url($uri['path'], $uri['options']),
603 'property' => $account->rdf_mapping['name']['predicates'],
604 'content' => $account->name,
605 )
606 );
607 drupal_add_html_head($account_holder_meta, 'rdf_user_account_holder');
608 drupal_add_html_head($username_meta, 'rdf_user_username');
609 }
610
614 function rdf_preprocess_username(&$variables) {
615 // Because xml:lang is set on the HTML element that wraps the page, the
616 // username inherits this language attribute. However, since the username
617 // might not be transliterated to the same language that the content is in,
618 // we do not want it to inherit the language attribute, so we set the
619 // attribute to an empty string.
620 if (empty($variables['attributes_array']['xml:lang'])) {
621 $variables['attributes_array']['xml:lang'] = '';
622 }
623
624 // $variables['account'] is a pseudo account object, and as such, does not
625 // contain the RDF mappings for the user. In the case of nodes and comments,
626 // it contains the mappings for the node or comment object instead. However,
627 // while the RDF mappings are available from a full user_load(), this should
628 // be avoided for performance reasons. Since the type and bundle for users is
629 // already known, call rdf_mapping_load() directly.
630 $rdf_mapping = rdf_mapping_load('user', 'user');
631
632 // The profile URI is used to identify the user account. The about attribute
633 // is used to set the URI as the default subject of the predicates embedded
634 // as RDFa in the child elements. Even if the user profile is not accessible
635 // to the current user, we use its URI in order to identify the user in RDF.
636 // We do not use this attribute for the anonymous user because we do not have
637 // a user profile URI for it (only a homepage which cannot be used as user
638 // profile in RDF.)
639 if ($variables['uid'] > 0) {
640 $variables['attributes_array']['about'] = url('user/' . $variables['uid']);
641 }
642
643 $attributes = array();
644 // The typeof attribute specifies the RDF type(s) of this resource. They
645 // are defined in the 'rdftype' property of the user RDF mapping.
646 if (!empty($rdf_mapping['rdftype'])) {
647 $attributes['typeof'] = $rdf_mapping['rdftype'];
648 }
649 // Annotate the username in RDFa. A property attribute is used with an empty
650 // datatype attribute to ensure the username is parsed as a plain literal
651 // in RDFa 1.0 and 1.1.
652 if (!empty($rdf_mapping['name'])) {
653 $attributes['property'] = $rdf_mapping['name']['predicates'];
654 $attributes['datatype'] = '';
655 }
656 // Add the homepage RDFa markup if present.
657 if (!empty($variables['homepage']) && !empty($rdf_mapping['homepage'])) {
658 $attributes['rel'] = $rdf_mapping['homepage']['predicates'];
659 }
660 // The remaining attributes can have multiple values listed, with whitespace
661 // separating the values in the RDFa attributes
662 // (see http://www.w3.org/TR/rdfa-syntax/#rdfa-attributes).
663 // Therefore, merge rather than override so as not to clobber values set by
664 // earlier preprocess functions.
665 $variables['attributes_array'] = array_merge_recursive($variables['attributes_array'], $attributes);
666 }
667
671 function rdf_preprocess_comment(&$variables) {
672 $comment = $variables['comment'];
673 if (!empty($comment->rdf_mapping['rdftype'])) {
674 // Adds RDFa markup to the comment container. The about attribute specifies
675 // the URI of the resource described within the HTML element, while the
676 // typeof attribute indicates its RDF type (e.g., sioc:Post, foaf:Document,
677 // and so on.)
678 $uri = entity_uri('comment', $comment);
679 $variables['attributes_array']['about'] = url($uri['path'], $uri['options']);
680 $variables['attributes_array']['typeof'] = $comment->rdf_mapping['rdftype'];
681 }
682
683 // Adds RDFa markup for the date of the comment.
684 if (!empty($comment->rdf_mapping['created'])) {
685 // The comment date is precomputed as part of the rdf_data so that it can be
686 // cached as part of the entity.
687 $date_attributes_array = $comment->rdf_data['date'];
688 $variables['rdf_template_variable_attributes_array']['created'] = $date_attributes_array;
689 $variables['rdf_template_variable_attributes_array']['submitted'] = $date_attributes_array;
690 }
691 // Adds RDFa markup for the relation between the comment and its author.
692 if (!empty($comment->rdf_mapping['uid'])) {
693 $variables['rdf_template_variable_attributes_array']['author']['rel'] = $comment->rdf_mapping['uid']['predicates'];
694 $variables['rdf_template_variable_attributes_array']['submitted']['rel'] = $comment->rdf_mapping['uid']['predicates'];
695 }
696 if (!empty($comment->rdf_mapping['title'])) {
697 // Adds RDFa markup to the subject of the comment. Because the RDFa markup
698 // is added to an <h3> tag which might contain HTML code, we specify an
699 // empty datatype to ensure the value of the title read by the RDFa parsers
700 // is a literal.
701 $variables['title_attributes_array']['property'] = $comment->rdf_mapping['title']['predicates'];
702 $variables['title_attributes_array']['datatype'] = '';
703 }
704
705 // Annotates the parent relationship between the current comment and the node
706 // it belongs to. If available, the parent comment is also annotated.
707 if (!empty($comment->rdf_mapping['pid'])) {
708 // Adds the relation to the parent node.
709 $parent_node_attributes['rel'] = $comment->rdf_mapping['pid']['predicates'];
710 // The parent node URI is precomputed as part of the rdf_data so that it can
711 // be cached as part of the entity.
712 $parent_node_attributes['resource'] = $comment->rdf_data['nid_uri'];
713 $variables['rdf_metadata_attributes_array'][] = $parent_node_attributes;
714
715 // Adds the relation to parent comment, if it exists.
716 if ($comment->pid != 0) {
717 $parent_comment_attributes['rel'] = $comment->rdf_mapping['pid']['predicates'];
718 // The parent comment URI is precomputed as part of the rdf_data so that
719 // it can be cached as part of the entity.
720 $parent_comment_attributes['resource'] = $comment->rdf_data['pid_uri'];
721 $variables['rdf_metadata_attributes_array'][] = $parent_comment_attributes;
722 }
723 }
724 }
725
729 function rdf_preprocess_taxonomy_term(&$variables) {
730 // Adds the RDF type of the term and the term name in a <meta> tag.
731 $term = $variables['term'];
732 $term_label_meta = array(
733 '#tag' => 'meta',
734 '#attributes' => array(
735 'about' => url('taxonomy/term/' . $term->tid),
736 'typeof' => $term->rdf_mapping['rdftype'],
737 'property' => $term->rdf_mapping['name']['predicates'],
738 'content' => $term->name,
739 ),
740 );
741 drupal_add_html_head($term_label_meta, 'rdf_term_label');
742 }
743
747 function rdf_field_attach_view_alter(&$output, $context) {
748 // Append term mappings on displayed taxonomy links.
749 foreach (element_children($output) as $field_name) {
750 $element = &$output[$field_name];
751 if ($element['#field_type'] == 'taxonomy_term_reference' && $element['#formatter'] == 'taxonomy_term_reference_link') {
752 foreach ($element['#items'] as $delta => $item) {
753 // This function is invoked during entity preview when taxonomy term
754 // reference items might contain free-tagging terms that do not exist
755 // yet and thus have no $item['taxonomy_term'].
756 if (isset($item['taxonomy_term'])) {
757 $term = $item['taxonomy_term'];
758 if (!empty($term->rdf_mapping['rdftype'])) {
759 $element[$delta]['#options']['attributes']['typeof'] = $term->rdf_mapping['rdftype'];
760 }
761 if (!empty($term->rdf_mapping['name']['predicates'])) {
762 // A property attribute is used with an empty datatype attribute so
763 // the term name is parsed as a plain literal in RDFa 1.0 and 1.1.
764 $element[$delta]['#options']['attributes']['property'] = $term->rdf_mapping['name']['predicates'];
765 $element[$delta]['#options']['attributes']['datatype'] = '';
766 }
767 }
768 }
769 }
770 }
771 }
772
776 function rdf_preprocess_image(&$variables) {
777 // Adds the RDF type for image. We cannot use the usual entity-based mapping
778 // to get 'foaf:Image' because image does not have its own entity type or
779 // bundle.
780 $variables['attributes']['typeof'] = array('foaf:Image');
781 }
782
836 function theme_rdf_template_variable_wrapper($variables) {
837 $output = $variables['content'];
838 if (!empty($output) && !empty($variables['attributes'])) {
839 $attributes = drupal_attributes($variables['attributes']);
840 $output = $variables['inline'] ? "<span$attributes>$output</span>" : "<div$attributes>$output</div>";
841 }
842 return $output;
843 }
844
864 function theme_rdf_metadata($variables) {
865 $output = '';
866 foreach ($variables['metadata'] as $attributes) {
867 // Add a class so that developers viewing the HTML source can see why there
868 // are empty <span> tags in the document. The class can also be used to set
869 // a CSS display:none rule in a theme where empty spans affect display.
870 $attributes['class'][] = 'rdf-meta';
871 // The XHTML+RDFa doctype allows either <span></span> or <span /> syntax to
872 // be used, but for maximum browser compatibility, W3C recommends the
873 // former when serving pages using the text/html media type, see
874 // http://www.w3.org/TR/xhtml1/#C_3.
875 $output .= '<span' . drupal_attributes($attributes) . '></span>';
876 }
877 return $output;
878 }
rdf_process
rdf_process(&$variables, $hook)
Definition: rdf.module:436
rdf_help
rdf_help($path, $arg)
Definition: rdf.module:11
theme_rdf_template_variable_wrapper
theme_rdf_template_variable_wrapper($variables)
Definition: rdf.module:836
rdf_preprocess_taxonomy_term
rdf_preprocess_taxonomy_term(&$variables)
Definition: rdf.module:729
rdf_preprocess_user_profile
rdf_preprocess_user_profile(&$variables)
Definition: rdf.module:577
rdf_mapping_load
rdf_mapping_load($type, $bundle=RDF_DEFAULT_BUNDLE)
Definition: rdf.module:133
rdf_rdf_namespaces
rdf_rdf_namespaces()
Definition: rdf.module:79
rdf_entity_info_alter
rdf_entity_info_alter(&$entity_info)
Definition: rdf.module:368
$module
print $module
Definition: search-results.tpl.php:28
file_create_url
file_create_url($uri)
Definition: file.inc:372
rdf_preprocess_node
rdf_preprocess_node(&$variables)
Definition: rdf.module:466
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
rdf_mapping_delete
rdf_mapping_delete($type, $bundle)
Definition: rdf.module:257
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
rdf_modules_uninstalled
rdf_modules_uninstalled($modules)
Definition: rdf.module:353
drupal_attributes
drupal_attributes(array $attributes=array())
Definition: common.inc:2377
$attributes
print $attributes
Definition: block.tpl.php:47
$rdf_namespaces
print $rdf_namespaces
Definition: html.tpl.php:47
rdf_preprocess_username
rdf_preprocess_username(&$variables)
Definition: rdf.module:614
_rdf_mapping_load
_rdf_mapping_load($type, $bundle)
Definition: rdf.module:192
entity_uri
entity_uri($entity_type, $entity)
Definition: common.inc:7902
rdf_get_namespaces
rdf_get_namespaces()
Definition: rdf.module:97
entity_info_cache_clear
entity_info_cache_clear()
Definition: common.inc:7690
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
theme_rdf_metadata
theme_rdf_metadata($variables)
Definition: rdf.module:864
_rdf_get_default_mapping
_rdf_get_default_mapping($type)
Definition: rdf.module:160
$output
$output
Definition: authorize.php:93
rdf_preprocess_field
rdf_preprocess_field(&$variables)
Definition: rdf.module:549
user_access
user_access($string, $account=NULL)
Definition: user.module:794
rdf_field_attach_view_alter
rdf_field_attach_view_alter(&$output, $context)
Definition: rdf.module:747
RDF_DEFAULT_BUNDLE
const RDF_DEFAULT_BUNDLE
Definition: rdf.module:74
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
image_style_url
image_style_url($style_name, $path)
Definition: image.module:1013
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
rdf_modules_installed
rdf_modules_installed($modules)
Definition: rdf.module:336
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
rdf_rdfa_attributes
rdf_rdfa_attributes($mapping, $data=NULL)
Definition: rdf.module:291
rdf_theme
rdf_theme()
Definition: rdf.module:416
title
print $topic title
Definition: forum-topic-list.tpl.php:50
rdf_entity_load
rdf_entity_load($entities, $type)
Definition: rdf.module:389
rdf_preprocess_image
rdf_preprocess_image(&$variables)
Definition: rdf.module:776
rdf_comment_load
rdf_comment_load($comments)
Definition: rdf.module:400
drupal_add_html_head
drupal_add_html_head($data=NULL, $key=NULL)
Definition: common.inc:299
entity_extract_ids
entity_extract_ids($entity_type, $entity)
Definition: common.inc:7711
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
rdf_preprocess_comment
rdf_preprocess_comment(&$variables)
Definition: rdf.module:671
rdf_mapping_save
rdf_mapping_save($mapping)
Definition: rdf.module:225
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/block/block.api.php Source File

  • modules
  • block
block.api.php
Go to the documentation of this file.
1 <?php
2
105 function hook_block_info() {
106 // This example comes from node.module.
107 $blocks['syndicate'] = array(
108 'info' => t('Syndicate'),
109 'cache' => DRUPAL_NO_CACHE
110 );
111
112 $blocks['recent'] = array(
113 'info' => t('Recent content'),
114 // DRUPAL_CACHE_PER_ROLE will be assumed.
115 );
116
117 return $blocks;
118 }
119
136 function hook_block_info_alter(&$blocks, $theme, $code_blocks) {
137 // Disable the login block.
138 $blocks['user']['login']['status'] = 0;
139 }
140
157 function hook_block_configure($delta = '') {
158 // This example comes from node.module.
159 $form = array();
160 if ($delta == 'recent') {
161 $form['node_recent_block_count'] = array(
162 '#type' => 'select',
163 '#title' => t('Number of recent content items to display'),
164 '#default_value' => variable_get('node_recent_block_count', 10),
165 '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
166 );
167 }
168 return $form;
169 }
170
188 function hook_block_save($delta = '', $edit = array()) {
189 // This example comes from node.module.
190 if ($delta == 'recent') {
191 variable_set('node_recent_block_count', $edit['node_recent_block_count']);
192 }
193 }
194
217 function hook_block_view($delta = '') {
218 // This example is adapted from node.module.
219 $block = array();
220
221 switch ($delta) {
222 case 'syndicate':
223 $block['subject'] = t('Syndicate');
224 $block['content'] = array(
225 '#theme' => 'feed_icon',
226 '#url' => 'rss.xml',
227 '#title' => t('Syndicate'),
228 );
229 break;
230
231 case 'recent':
232 if (user_access('access content')) {
233 $block['subject'] = t('Recent content');
234 if ($nodes = node_get_recent(variable_get('node_recent_block_count', 10))) {
235 $block['content'] = array(
236 '#theme' => 'node_recent_block',
237 '#nodes' => $nodes,
238 );
239 } else {
240 $block['content'] = t('No content available.');
241 }
242 }
243 break;
244 }
245 return $block;
246 }
247
274 function hook_block_view_alter(&$data, $block) {
275 // Remove the contextual links on all blocks that provide them.
276 if (is_array($data['content']) && isset($data['content']['#contextual_links'])) {
277 unset($data['content']['#contextual_links']);
278 }
279 // Add a theme wrapper function defined by the current module to all blocks
280 // provided by the "somemodule" module.
281 if (is_array($data['content']) && $block->module == 'somemodule') {
282 $data['content']['#theme_wrappers'][] = 'mymodule_special_block';
283 }
284 }
285
309 function hook_block_view_MODULE_DELTA_alter(&$data, $block) {
310 // This code will only run for a specific block. For example, if MODULE_DELTA
311 // in the function definition above is set to "mymodule_somedelta", the code
312 // will only run on the "somedelta" block provided by the "mymodule" module.
313
314 // Change the title of the "somedelta" block provided by the "mymodule"
315 // module.
316 $data['subject'] = t('New title of the block');
317 }
318
333 function hook_block_list_alter(&$blocks) {
334 global $language, $theme_key;
335
336 // This example shows how to achieve language specific visibility setting for
337 // blocks.
338
339 $result = db_query('SELECT module, delta, language FROM {my_table}');
340 $block_languages = array();
341 foreach ($result as $record) {
342 $block_languages[$record->module][$record->delta][$record->language] = TRUE;
343 }
344
345 foreach ($blocks as $key => $block) {
346 // Any module using this alter should inspect the data before changing it,
347 // to ensure it is what they expect.
348 if (!isset($block->theme) || !isset($block->status) || $block->theme != $theme_key || $block->status != 1) {
349 // This block was added by a contrib module, leave it in the list.
350 continue;
351 }
352
353 if (!isset($block_languages[$block->module][$block->delta])) {
354 // No language setting for this block, leave it in the list.
355 continue;
356 }
357
358 if (!isset($block_languages[$block->module][$block->delta][$language->language])) {
359 // This block should not be displayed with the active language, remove
360 // from the list.
361 unset($blocks[$key]);
362 }
363 }
364 }
365
hook_block_info_alter
hook_block_info_alter(&$blocks, $theme, $code_blocks)
Definition: block.api.php:136
hook_block_info
hook_block_info()
Definition: block.api.php:105
hook_block_save
hook_block_save($delta= '', $edit=array())
Definition: block.api.php:188
hook_block_configure
hook_block_configure($delta= '')
Definition: block.api.php:157
hook_block_view_MODULE_DELTA_alter
hook_block_view_MODULE_DELTA_alter(&$data, $block)
Definition: block.api.php:309
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
hook_block_view_alter
hook_block_view_alter(&$data, $block)
Definition: block.api.php:274
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
hook_block_view
hook_block_view($delta= '')
Definition: block.api.php:217
DRUPAL_NO_CACHE
const DRUPAL_NO_CACHE
Definition: common.inc:127
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
node_get_recent
node_get_recent($number=10)
Definition: node.module:2318
hook_block_list_alter
hook_block_list_alter(&$blocks)
Definition: block.api.php:333
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/contact/contact.install Source File

  • modules
  • contact
contact.install
Go to the documentation of this file.
1 <?php
2
11 function contact_schema() {
12 $schema['contact'] = array(
13 'description' => 'Contact form category settings.',
14 'fields' => array(
15 'cid' => array(
16 'type' => 'serial',
17 'unsigned' => TRUE,
18 'not null' => TRUE,
19 'description' => 'Primary Key: Unique category ID.',
20 ),
21 'category' => array(
22 'type' => 'varchar',
23 'length' => 255,
24 'not null' => TRUE,
25 'default' => '',
26 'description' => 'Category name.',
27 'translatable' => TRUE,
28 ),
29 'recipients' => array(
30 'type' => 'text',
31 'not null' => TRUE,
32 'size' => 'big',
33 'description' => 'Comma-separated list of recipient e-mail addresses.',
34 ),
35 'reply' => array(
36 'type' => 'text',
37 'not null' => TRUE,
38 'size' => 'big',
39 'description' => 'Text of the auto-reply message.',
40 ),
41 'weight' => array(
42 'type' => 'int',
43 'not null' => TRUE,
44 'default' => 0,
45 'description' => "The category's weight.",
46 ),
47 'selected' => array(
48 'type' => 'int',
49 'not null' => TRUE,
50 'default' => 0,
51 'size' => 'tiny',
52 'description' => 'Flag to indicate whether or not category is selected by default. (1 = Yes, 0 = No)',
53 ),
54 ),
55 'primary key' => array('cid'),
56 'unique keys' => array(
57 'category' => array('category'),
58 ),
59 'indexes' => array(
60 'list' => array('weight', 'category'),
61 ),
62 );
63
64 return $schema;
65 }
66
70 function contact_install() {
71 // Insert a default contact category.
72 db_insert('contact')
73 ->fields(array(
74 'category' => 'Website feedback',
75 'recipients' => variable_get('site_mail', ini_get('sendmail_from')),
76 'selected' => 1,
77 'reply' => '',
78 ))
79 ->execute();
80 }
81
85 function contact_uninstall() {
86 variable_del('contact_default_status');
87 variable_del('contact_threshold_limit');
88 variable_del('contact_threshold_window');
89 }
90
94 function contact_update_dependencies() {
95 // contact_update_7001() relies on the {role_permission} table being updated
96 // to the new format and filled with data.
97 $dependencies['contact'][7001] = array(
98 'system' => 7007,
99 );
100
101 // contact_update_7002() relies on the {role_permission} table having the
102 // module field, which is created in user_update_7006().
103 $dependencies['contact'][7002] = array(
104 'user' => 7006,
105 );
106
107 return $dependencies;
108 }
109
118 function contact_update_7000() {
119 variable_set('contact_threshold_limit', variable_get('contact_hourly_threshold', 5));
120 variable_del('contact_hourly_threshold');
121 }
122
126 function contact_update_7001() {
127 db_update('role_permission')
128 ->fields(array('permission' => 'administer contact forms'))
129 ->condition('permission', 'administer site-wide contact form')
130 ->execute();
131 }
132
136 function contact_update_7002() {
137 // Do not use user_role_grant_permission() since it relies on
138 // hook_permission(), which will not run for contact module if it is
139 // disabled.
140 db_merge('role_permission')
141 ->key(array(
142 'rid' => DRUPAL_AUTHENTICATED_RID,
143 'permission' => 'access user contact forms',
144 'module' => 'contact',
145 ))
146 ->execute();
147 }
148
152 function contact_update_7003() {
153 db_drop_index('contact', 'list');
154 db_change_field('contact', 'weight', 'weight', array(
155 'type' => 'int',
156 'not null' => TRUE,
157 'default' => 0,
158 'description' => "The category's weight.",
159 ), array(
160 'indexes' => array(
161 'list' => array('weight', 'category'),
162 ),
163 ));
164 }
165
contact_schema
contact_schema()
Definition: contact.install:11
contact_update_7003
contact_update_7003()
Definition: contact.install:152
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_drop_index
db_drop_index($table, $name)
Definition: database.inc:2952
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
contact_install
contact_install()
Definition: contact.install:70
contact_update_7000
contact_update_7000()
Definition: contact.install:118
contact_update_7001
contact_update_7001()
Definition: contact.install:126
DRUPAL_AUTHENTICATED_RID
const DRUPAL_AUTHENTICATED_RID
Definition: bootstrap.inc:167
contact_update_dependencies
contact_update_dependencies()
Definition: contact.install:94
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
contact_update_7002
contact_update_7002()
Definition: contact.install:136
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
contact_uninstall
contact_uninstall()
Definition: contact.install:85
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/updater.inc Source File

  • includes
updater.inc
Go to the documentation of this file.
1 <?php
2
21 interface DrupalUpdaterInterface {
22
28 public function isInstalled();
29
36 public static function getProjectName($directory);
37
42 public function getInstallDirectory();
43
54 public static function canUpdateDirectory($directory);
55
59 public function postInstall();
60
64 public function postUpdate();
65 }
66
70 class Updater {
71
75 public $source;
76
77 public function __construct($source) {
78 $this->source = $source;
79 $this->name = self::getProjectName($source);
80 $this->title = self::getProjectTitle($source);
81 }
82
94 public static function factory($source) {
95 if (is_dir($source)) {
96 $updater = self::getUpdaterFromDirectory($source);
97 }
98 else {
99 throw new UpdaterException(t('Unable to determine the type of the source directory.'));
100 }
101 return new $updater($source);
102 }
103
113 public static function getUpdaterFromDirectory($directory) {
114 // Gets a list of possible implementing classes.
115 $updaters = drupal_get_updaters();
116 foreach ($updaters as $updater) {
117 $class = $updater['class'];
118 if (call_user_func(array($class, 'canUpdateDirectory'), $directory)) {
119 return $class;
120 }
121 }
122 throw new UpdaterException(t('Cannot determine the type of project.'));
123 }
124
138 public static function findInfoFile($directory) {
139 $info_files = file_scan_directory($directory, '/.*\.info$/');
140 if (!$info_files) {
141 return FALSE;
142 }
143 foreach ($info_files as $info_file) {
144 if (drupal_substr($info_file->filename, 0, -5) == drupal_basename($directory)) {
145 // Info file Has the same name as the directory, return it.
146 return $info_file->uri;
147 }
148 }
149 // Otherwise, return the first one.
150 $info_file = array_shift($info_files);
151 return $info_file->uri;
152 }
153
165 public static function getProjectName($directory) {
166 return drupal_basename($directory);
167 }
168
178 public static function getProjectTitle($directory) {
179 $info_file = self::findInfoFile($directory);
180 $info = drupal_parse_info_file($info_file);
181 if (empty($info)) {
182 throw new UpdaterException(t('Unable to parse info file: %info_file.', array('%info_file' => $info_file)));
183 }
184 if (empty($info['name'])) {
185 throw new UpdaterException(t("The info file (%info_file) does not define a 'name' attribute.", array('%info_file' => $info_file)));
186 }
187 return $info['name'];
188 }
189
199 protected function getInstallArgs($overrides = array()) {
200 $args = array(
201 'make_backup' => FALSE,
202 'install_dir' => $this->getInstallDirectory(),
203 'backup_dir' => $this->getBackupDir(),
204 );
205 return array_merge($args, $overrides);
206 }
207
220 public function update(&$filetransfer, $overrides = array()) {
221 try {
222 // Establish arguments with possible overrides.
223 $args = $this->getInstallArgs($overrides);
224
225 // Take a Backup.
226 if ($args['make_backup']) {
227 $this->makeBackup($args['install_dir'], $args['backup_dir']);
228 }
229
230 if (!$this->name) {
231 // This is bad, don't want to delete the install directory.
232 throw new UpdaterException(t('Fatal error in update, cowardly refusing to wipe out the install directory.'));
233 }
234
235 // Make sure the installation parent directory exists and is writable.
236 $this->prepareInstallDirectory($filetransfer, $args['install_dir']);
237
238 // Note: If the project is installed in sites/all, it will not be
239 // deleted. It will be installed in sites/default as that will override
240 // the sites/all reference and not break other sites which are using it.
241 if (is_dir($args['install_dir'] . '/' . $this->name)) {
242 // Remove the existing installed file.
243 $filetransfer->removeDirectory($args['install_dir'] . '/' . $this->name);
244 }
245
246 // Copy the directory in place.
247 $filetransfer->copyDirectory($this->source, $args['install_dir']);
248
249 // Make sure what we just installed is readable by the web server.
250 $this->makeWorldReadable($filetransfer, $args['install_dir'] . '/' . $this->name);
251
252 // Run the updates.
253 // @TODO: decide if we want to implement this.
254 $this->postUpdate();
255
256 // For now, just return a list of links of things to do.
257 return $this->postUpdateTasks();
258 }
259 catch (FileTransferException $e) {
260 throw new UpdaterFileTransferException(t('File Transfer failed, reason: !reason', array('!reason' => strtr($e->getMessage(), $e->arguments))));
261 }
262 }
263
275 public function install(&$filetransfer, $overrides = array()) {
276 try {
277 // Establish arguments with possible overrides.
278 $args = $this->getInstallArgs($overrides);
279
280 // Make sure the installation parent directory exists and is writable.
281 $this->prepareInstallDirectory($filetransfer, $args['install_dir']);
282
283 // Copy the directory in place.
284 $filetransfer->copyDirectory($this->source, $args['install_dir']);
285
286 // Make sure what we just installed is readable by the web server.
287 $this->makeWorldReadable($filetransfer, $args['install_dir'] . '/' . $this->name);
288
289 // Potentially enable something?
290 // @TODO: decide if we want to implement this.
291 $this->postInstall();
292 // For now, just return a list of links of things to do.
293 return $this->postInstallTasks();
294 }
295 catch (FileTransferException $e) {
296 throw new UpdaterFileTransferException(t('File Transfer failed, reason: !reason', array('!reason' => strtr($e->getMessage(), $e->arguments))));
297 }
298 }
299
308 public function prepareInstallDirectory(&$filetransfer, $directory) {
309 // Make the parent dir writable if need be and create the dir.
310 if (!is_dir($directory)) {
311 $parent_dir = dirname($directory);
312 if (!is_writable($parent_dir)) {
313 @chmod($parent_dir, 0755);
314 // It is expected that this will fail if the directory is owned by the
315 // FTP user. If the FTP user == web server, it will succeed.
316 try {
317 $filetransfer->createDirectory($directory);
318 $this->makeWorldReadable($filetransfer, $directory);
319 }
320 catch (FileTransferException $e) {
321 // Probably still not writable. Try to chmod and do it again.
322 // @todo: Make a new exception class so we can catch it differently.
323 try {
324 $old_perms = substr(sprintf('%o', fileperms($parent_dir)), -4);
325 $filetransfer->chmod($parent_dir, 0755);
326 $filetransfer->createDirectory($directory);
327 $this->makeWorldReadable($filetransfer, $directory);
328 // Put the permissions back.
329 $filetransfer->chmod($parent_dir, intval($old_perms, 8));
330 }
331 catch (FileTransferException $e) {
332 $message = t($e->getMessage(), $e->arguments);
333 $throw_message = t('Unable to create %directory due to the following: %reason', array('%directory' => $directory, '%reason' => $message));
334 throw new UpdaterException($throw_message);
335 }
336 }
337 // Put the parent directory back.
338 @chmod($parent_dir, 0555);
339 }
340 }
341 }
342
353 public function makeWorldReadable(&$filetransfer, $path, $recursive = TRUE) {
354 if (!is_executable($path)) {
355 // Set it to read + execute.
356 $new_perms = substr(sprintf('%o', fileperms($path)), -4, -1) . "5";
357 $filetransfer->chmod($path, intval($new_perms, 8), $recursive);
358 }
359 }
360
366 public function makeBackup(&$filetransfer, $from, $to) {
367 }
368
372 public function getBackupDir() {
373 return file_stream_wrapper_get_instance_by_scheme('temporary')->getDirectoryPath();
374 }
375
379 public function postUpdate() {
380 }
381
385 public function postInstall() {
386 }
387
394 public function postInstallTasks() {
395 return array();
396 }
397
404 public function postUpdateTasks() {
405 return array();
406 }
407 }
408
416 class UpdaterException extends Exception {
417 }
418
426 class UpdaterFileTransferException extends UpdaterException {
427 }
Updater\postInstall
postInstall()
Definition: updater.inc:385
Updater\makeWorldReadable
makeWorldReadable(&$filetransfer, $path, $recursive=TRUE)
Definition: updater.inc:353
Updater\postInstallTasks
postInstallTasks()
Definition: updater.inc:394
Updater\postUpdate
postUpdate()
Definition: updater.inc:379
DrupalUpdaterInterface\postUpdate
postUpdate()
Updater\getUpdaterFromDirectory
static getUpdaterFromDirectory($directory)
Definition: updater.inc:113
file_scan_directory
file_scan_directory($dir, $mask, $options=array(), $depth=0)
Definition: file.inc:2058
drupal_parse_info_file
drupal_parse_info_file($filename)
Definition: common.inc:7270
FileTransferException
Definition: filetransfer.inc:363
Updater\postUpdateTasks
postUpdateTasks()
Definition: updater.inc:404
UpdaterFileTransferException
Definition: updater.inc:426
Updater\getProjectName
static getProjectName($directory)
Definition: updater.inc:165
Updater\__construct
__construct($source)
Definition: updater.inc:77
Updater\getInstallArgs
getInstallArgs($overrides=array())
Definition: updater.inc:199
Exception
name
print $forum name
Definition: forum-list.tpl.php:57
drupal_substr
drupal_substr($text, $start, $length=NULL)
Definition: unicode.inc:585
file_stream_wrapper_get_instance_by_scheme
file_stream_wrapper_get_instance_by_scheme($scheme)
Definition: file.inc:336
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
DrupalUpdaterInterface\isInstalled
isInstalled()
$info
$info
Definition: color.inc:6
Updater\getProjectTitle
static getProjectTitle($directory)
Definition: updater.inc:178
Updater\$source
$source
Definition: updater.inc:75
Updater\makeBackup
makeBackup(&$filetransfer, $from, $to)
Definition: updater.inc:366
DrupalUpdaterInterface\canUpdateDirectory
static canUpdateDirectory($directory)
Updater\factory
static factory($source)
Definition: updater.inc:94
Updater\install
install(&$filetransfer, $overrides=array())
Definition: updater.inc:275
DrupalUpdaterInterface\getInstallDirectory
getInstallDirectory()
UpdaterException
Definition: updater.inc:416
DrupalUpdaterInterface
Definition: updater.inc:21
DrupalUpdaterInterface\postInstall
postInstall()
title
print $topic title
Definition: forum-topic-list.tpl.php:50
Updater\prepareInstallDirectory
prepareInstallDirectory(&$filetransfer, $directory)
Definition: updater.inc:308
DrupalUpdaterInterface\getProjectName
static getProjectName($directory)
drupal_basename
drupal_basename($uri, $suffix=NULL)
Definition: file.inc:2317
Updater\getBackupDir
getBackupDir()
Definition: updater.inc:372
drupal_get_updaters
drupal_get_updaters()
Definition: common.inc:8180
Updater\findInfoFile
static findInfoFile($directory)
Definition: updater.inc:138
Updater
Definition: updater.inc:70
Updater\update
update(&$filetransfer, $overrides=array())
Definition: updater.inc:220
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/dblog/dblog.module Source File

  • modules
  • dblog
dblog.module
Go to the documentation of this file.
1 <?php
2
17 function dblog_help($path, $arg) {
18 switch ($path) {
19 case 'admin/help#dblog':
20 $output = '';
21 $output .= '<h3>' . t('About') . '</h3>';
22 $output .= '<p>' . t('The Database logging module logs system events in the Drupal database. For more information, see the online handbook entry for the <a href="@dblog">Database logging module</a>.', array('@dblog' => 'http://drupal.org/documentation/modules/dblog')) . '</p>';
23 $output .= '<h3>' . t('Uses') . '</h3>';
24 $output .= '<dl>';
25 $output .= '<dt>' . t('Monitoring your site') . '</dt>';
26 $output .= '<dd>' . t('The Database logging module allows you to view an event log on the <a href="@dblog">Recent log messages</a> page. The log is a chronological list of recorded events containing usage data, performance data, errors, warnings and operational information. Administrators should check the log on a regular basis to ensure their site is working properly.', array('@dblog' => url('admin/reports/dblog'))) . '</dd>';
27 $output .= '<dt>' . t('Debugging site problems') . '</dt>';
28 $output .= '<dd>' . t('In case of errors or problems with the site, the <a href="@dblog">Recent log messages</a> page can be useful for debugging, since it shows the sequence of events. The log messages include usage information, warnings, and errors.', array('@dblog' => url('admin/reports/dblog'))) . '</dd>';
29 $output .= '</dl>';
30 return $output;
31 case 'admin/reports/dblog':
32 return '<p>' . t('The Database logging module monitors your website, capturing system events in a log (shown here) to be reviewed by an authorized individual at a later time. This log is a list of recorded events containing usage data, performance data, errors, warnings and operational information. It is vital to check the Recent log messages report on a regular basis, as it is often the only way to tell what is going on.') . '</p>';
33 }
34 }
35
39 function dblog_menu() {
40 $items['admin/reports/dblog'] = array(
41 'title' => 'Recent log messages',
42 'description' => 'View events that have recently been logged.',
43 'page callback' => 'dblog_overview',
44 'access arguments' => array('access site reports'),
45 'weight' => -1,
46 'file' => 'dblog.admin.inc',
47 );
48 $items['admin/reports/page-not-found'] = array(
49 'title' => "Top 'page not found' errors",
50 'description' => "View 'page not found' errors (404s).",
51 'page callback' => 'dblog_top',
52 'page arguments' => array('page not found'),
53 'access arguments' => array('access site reports'),
54 'file' => 'dblog.admin.inc',
55 );
56 $items['admin/reports/access-denied'] = array(
57 'title' => "Top 'access denied' errors",
58 'description' => "View 'access denied' errors (403s).",
59 'page callback' => 'dblog_top',
60 'page arguments' => array('access denied'),
61 'access arguments' => array('access site reports'),
62 'file' => 'dblog.admin.inc',
63 );
64 $items['admin/reports/event/%'] = array(
65 'title' => 'Details',
66 'page callback' => 'dblog_event',
67 'page arguments' => array(3),
68 'access arguments' => array('access site reports'),
69 'file' => 'dblog.admin.inc',
70 );
71
72 if (module_exists('search')) {
73 $items['admin/reports/search'] = array(
74 'title' => 'Top search phrases',
75 'description' => 'View most popular search phrases.',
76 'page callback' => 'dblog_top',
77 'page arguments' => array('search'),
78 'access arguments' => array('access site reports'),
79 'file' => 'dblog.admin.inc',
80 );
81 }
82
83 return $items;
84 }
85
89 function dblog_init() {
90 if (arg(0) == 'admin' && arg(1) == 'reports') {
91 // Add the CSS for this module
92 drupal_add_css(drupal_get_path('module', 'dblog') . '/dblog.css');
93 }
94 }
95
101 function dblog_cron() {
102 // Cleanup the watchdog table.
103 $row_limit = variable_get('dblog_row_limit', 1000);
104
105 // For row limit n, get the wid of the nth row in descending wid order.
106 // Counting the most recent n rows avoids issues with wid number sequences,
107 // e.g. auto_increment value > 1 or rows deleted directly from the table.
108 if ($row_limit > 0) {
109 $min_row = db_select('watchdog', 'w')
110 ->fields('w', array('wid'))
111 ->orderBy('wid', 'DESC')
112 ->range($row_limit - 1, 1)
113 ->execute()->fetchField();
114
115 // Delete all table entries older than the nth row, if nth row was found.
116 if ($min_row) {
117 db_delete('watchdog')
118 ->condition('wid', $min_row, '<')
119 ->execute();
120 }
121 }
122 }
123
130 function _dblog_get_message_types() {
131 $types = array();
132
133 $result = db_query('SELECT DISTINCT(type) FROM {watchdog} ORDER BY type');
134 foreach ($result as $object) {
135 $types[] = $object->type;
136 }
137
138 return $types;
139 }
140
146 function dblog_watchdog(array $log_entry) {
147 Database::getConnection('default', 'default')->insert('watchdog')
148 ->fields(array(
149 'uid' => $log_entry['uid'],
150 'type' => substr($log_entry['type'], 0, 64),
151 'message' => $log_entry['message'],
152 'variables' => serialize($log_entry['variables']),
153 'severity' => $log_entry['severity'],
154 'link' => substr($log_entry['link'], 0, 255),
155 'location' => $log_entry['request_uri'],
156 'referer' => $log_entry['referer'],
157 'hostname' => substr($log_entry['ip'], 0, 128),
158 'timestamp' => $log_entry['timestamp'],
159 ))
160 ->execute();
161 }
162
166 function dblog_form_system_logging_settings_alter(&$form, $form_state) {
167 $form['dblog_row_limit'] = array(
168 '#type' => 'select',
169 '#title' => t('Database log messages to keep'),
170 '#default_value' => variable_get('dblog_row_limit', 1000),
171 '#options' => array(0 => t('All')) + drupal_map_assoc(array(100, 1000, 10000, 100000, 1000000)),
172 '#description' => t('The maximum number of messages to keep in the database log. Requires a <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status')))
173 );
174 $form['actions']['#weight'] = 1;
175 }
176
180 function dblog_theme() {
181 return array(
182 'dblog_message' => array(
183 'variables' => array('event' => NULL, 'link' => FALSE),
184 'file' => 'dblog.admin.inc',
185 ),
186 );
187 }
_dblog_get_message_types
_dblog_get_message_types()
Definition: dblog.module:130
dblog_form_system_logging_settings_alter
dblog_form_system_logging_settings_alter(&$form, $form_state)
Definition: dblog.module:166
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
Database\getConnection
static getConnection($target= 'default', $key=NULL)
Definition: database.inc:1460
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
module_exists
module_exists($module)
Definition: module.inc:274
dblog_help
dblog_help($path, $arg)
Definition: dblog.module:17
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$output
$output
Definition: authorize.php:93
dblog_menu
dblog_menu()
Definition: dblog.module:39
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
dblog_theme
dblog_theme()
Definition: dblog.module:180
dblog_init
dblog_init()
Definition: dblog.module:89
dblog_cron
dblog_cron()
Definition: dblog.module:101
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
dblog_watchdog
dblog_watchdog(array $log_entry)
Definition: dblog.module:146
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/vertical_tabs_example/vertical_tabs_example.module Source File

  • examples
  • vertical_tabs_example
vertical_tabs_example.module
Go to the documentation of this file.
1 <?php
2
23 function vertical_tabs_example_menu() {
24 $items['examples/vertical_tabs'] = array(
25 'title' => 'Vertical tabs example',
26 'description' => 'Shows how vertical tabs can best be supported by a custom module',
27 'page callback' => '_vertical_tabs_example_explanation',
28 'access callback' => TRUE,
29 );
30 return $items;
31 }
32
41 function vertical_tabs_example_form_alter(&$form, $form_state, $form_id) {
42 // Only include on node add/edit forms.
43 if (!empty($form['#node_edit_form'])) {
44
45 // Create a fieldset that will be included in the vertical tab.
46 $form['vertical_tabs_example'] = array(
47 '#type' => 'fieldset',
48 '#title' => t('Example vertical tab'),
49 '#collapsible' => TRUE,
50 '#collapsed' => FALSE,
51 '#tree' => TRUE,
52 // Send this tab to the top of the list.
53 '#weight' => -99,
54 // The #group value must match the name of the vertical tabs element.
55 // In most cases, this is 'additional_settings'.
56 '#group' => 'additional_settings',
57 // Vertical tabs provide its most usable appearance when they are used to
58 // include a summary of the information contained in the fieldset. To do
59 // this, we attach additional JavaScript to handle changing the summary
60 // when form settings are changed.
61 '#attached' => array(
62 'js' => array(
63 'vertical-tabs' => drupal_get_path('module', 'vertical_tabs_example') . '/vertical_tabs_example.js',
64 ),
65 ),
66 );
67
68 // The form elements below provide a demonstration of how a fieldset
69 // summary can be displayed in a collapsed tab.
70
71 // This checkbox is used to show or hide the custom settings form using
72 // javascript (altering states of a container defined later).
73 $form['vertical_tabs_example']['enabled'] = array(
74 '#type' => 'checkbox',
75 '#title' => t('Change this setting'),
76 '#default_value' => FALSE,
77 );
78
79 // This container will be used to store the whole form for our custom
80 // settings. This way, showing/hiding the form using javascript is easier,
81 // as only one element should be set visible.
82 $form['vertical_tabs_example']['vertical_tabs_examplecontainer'] = array(
83 '#type' => 'container',
84 '#parents' => array('vertical_tabs_example'),
85 '#states' => array(
86 'invisible' => array(
87 // If the checkbox is not enabled, show the container.
88 'input[name="vertical_tabs_example[enabled]"]' => array('checked' => FALSE),
89 ),
90 ),
91 );
92
93 // The string of this textfield will be shown as summary in the vertical
94 // tab.
95 $form['vertical_tabs_example']['vertical_tabs_examplecontainer']['custom_setting'] = array(
96 '#type' => 'textfield',
97 '#title' => t('Use this setting instead'),
98 '#default_value' => 'I am a setting with a summary',
99 '#description' => t('As you type into this field, the summary will be updated in the tab.'),
100 );
101 }
102 }
103
107 function _vertical_tabs_example_explanation() {
108 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')));
109 }
vertical_tabs_example_form_alter
vertical_tabs_example_form_alter(&$form, $form_state, $form_id)
Definition: vertical_tabs_example.module:41
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
_vertical_tabs_example_explanation
_vertical_tabs_example_explanation()
Definition: vertical_tabs_example.module:107
vertical_tabs_example_menu
vertical_tabs_example_menu()
Definition: vertical_tabs_example.module:23
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/sqlite/install.inc Source File

  • includes
  • database
  • sqlite
install.inc
Go to the documentation of this file.
1 <?php
2
8 class DatabaseTasks_sqlite extends DatabaseTasks {
9 protected $pdoDriver = 'sqlite';
10
11 public function name() {
12 return st('SQLite');
13 }
14
20 public function minimumVersion() {
21 return '3.3.7';
22 }
23
24 public function getFormOptions($database) {
25 $form = parent::getFormOptions($database);
26
27 // Remove the options that only apply to client/server style databases.
28 unset($form['username'], $form['password'], $form['advanced_options']['host'], $form['advanced_options']['port']);
29
30 // Make the text more accurate for SQLite.
31 $form['database']['#title'] = st('Database file');
32 $form['database']['#description'] = st('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', array('@drupal' => drupal_install_profile_distribution_name()));
33 $default_database = conf_path(FALSE, TRUE) . '/files/.ht.sqlite';
34 $form['database']['#default_value'] = empty($database['database']) ? $default_database : $database['database'];
35 return $form;
36 }
37
38 public function validateDatabaseSettings($database) {
39 // Perform standard validation.
40 $errors = parent::validateDatabaseSettings($database);
41
42 // Verify the database is writable.
43 $db_directory = new SplFileInfo(dirname($database['database']));
44 if (!$db_directory->isWritable()) {
45 $errors[$database['driver'] . '][database'] = st('The directory you specified is not writable by the web server.');
46 }
47
48 return $errors;
49 }
50 }
51
drupal_install_profile_distribution_name
drupal_install_profile_distribution_name()
Definition: install.inc:196
DatabaseTasks_sqlite\name
name()
Definition: install.inc:11
DatabaseTasks
Definition: install.inc:290
DatabaseTasks_sqlite
Definition: install.inc:8
DatabaseTasks_sqlite\$pdoDriver
$pdoDriver
Definition: install.inc:9
DatabaseTasks_sqlite\minimumVersion
minimumVersion()
Definition: install.inc:20
st
st($string, array $args=array(), array $options=array())
Definition: install.inc:1111
conf_path
conf_path($require_settings=TRUE, $reset=FALSE)
Definition: bootstrap.inc:541
DatabaseTasks_sqlite\validateDatabaseSettings
validateDatabaseSettings($database)
Definition: install.inc:38
DatabaseTasks_sqlite\getFormOptions
getFormOptions($database)
Definition: install.inc:24
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.parser.inc Source File

  • modules
  • aggregator
aggregator.parser.inc
Go to the documentation of this file.
1 <?php
2
11 function aggregator_aggregator_parse_info() {
12 return array(
13 'title' => t('Default parser'),
14 'description' => t('Parses RSS, Atom and RDF feeds.'),
15 );
16 }
17
21 function aggregator_aggregator_parse($feed) {
22 global $channel, $image;
23
24 // Filter the input data.
25 if (aggregator_parse_feed($feed->source_string, $feed)) {
26 $modified = empty($feed->http_headers['last-modified']) ? 0 : strtotime($feed->http_headers['last-modified']);
27
28 // Prepare the channel data.
29 foreach ($channel as $key => $value) {
30 $channel[$key] = trim($value);
31 }
32
33 // Prepare the image data (if any).
34 foreach ($image as $key => $value) {
35 $image[$key] = trim($value);
36 }
37
38 $etag = empty($feed->http_headers['etag']) ? '' : $feed->http_headers['etag'];
39
40 // Add parsed data to the feed object.
41 $feed->link = !empty($channel['link']) ? $channel['link'] : '';
42 $feed->description = !empty($channel['description']) ? $channel['description'] : '';
43 $feed->image = !empty($image['url']) ? $image['url'] : '';
44 $feed->etag = $etag;
45 $feed->modified = $modified;
46
47 // Clear the cache.
48 cache_clear_all();
49
50 return TRUE;
51 }
52
53 return FALSE;
54 }
55
67 function aggregator_parse_feed(&$data, $feed) {
68 global $items, $image, $channel;
69
70 // Unset the global variables before we use them.
71 unset($GLOBALS['element'], $GLOBALS['item'], $GLOBALS['tag']);
72 $items = array();
73 $image = array();
74 $channel = array();
75
76 // Parse the data.
77 $xml_parser = drupal_xml_parser_create($data);
78 xml_set_element_handler($xml_parser, 'aggregator_element_start', 'aggregator_element_end');
79 xml_set_character_data_handler($xml_parser, 'aggregator_element_data');
80
81 if (!xml_parse($xml_parser, $data, 1)) {
82 watchdog('aggregator', 'The feed from %site seems to be broken, due to an error "%error" on line %line.', array('%site' => $feed->title, '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser)), WATCHDOG_WARNING);
83 drupal_set_message(t('The feed from %site seems to be broken, because of error "%error" on line %line.', array('%site' => $feed->title, '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))), 'error');
84 return FALSE;
85 }
86 xml_parser_free($xml_parser);
87
88 // We reverse the array such that we store the first item last, and the last
89 // item first. In the database, the newest item should be at the top.
90 $items = array_reverse($items);
91
92 // Initialize items array.
93 $feed->items = array();
94 foreach ($items as $item) {
95
96 // Prepare the item:
97 foreach ($item as $key => $value) {
98 $item[$key] = trim($value);
99 }
100
101 // Resolve the item's title. If no title is found, we use up to 40
102 // characters of the description ending at a word boundary, but not
103 // splitting potential entities.
104 if (!empty($item['title'])) {
105 $item['title'] = $item['title'];
106 }
107 elseif (!empty($item['description'])) {
108 $item['title'] = preg_replace('/^(.*)[^\w;&].*?$/', "\\1", truncate_utf8($item['description'], 40));
109 }
110 else {
111 $item['title'] = '';
112 }
113
114 // Resolve the items link.
115 if (!empty($item['link'])) {
116 $item['link'] = $item['link'];
117 }
118 else {
119 $item['link'] = $feed->link;
120 }
121
122 // Atom feeds have an ID tag instead of a GUID tag.
123 if (!isset($item['guid'])) {
124 $item['guid'] = isset($item['id']) ? $item['id'] : '';
125 }
126
127 // Atom feeds have a content and/or summary tag instead of a description tag.
128 if (!empty($item['content:encoded'])) {
129 $item['description'] = $item['content:encoded'];
130 }
131 elseif (!empty($item['summary'])) {
132 $item['description'] = $item['summary'];
133 }
134 elseif (!empty($item['content'])) {
135 $item['description'] = $item['content'];
136 }
137
138 // Try to resolve and parse the item's publication date.
139 $date = '';
140 foreach (array('pubdate', 'dc:date', 'dcterms:issued', 'dcterms:created', 'dcterms:modified', 'issued', 'created', 'modified', 'published', 'updated') as $key) {
141 if (!empty($item[$key])) {
142 $date = $item[$key];
143 break;
144 }
145 }
146
147 $item['timestamp'] = strtotime($date);
148
149 if ($item['timestamp'] === FALSE) {
150 $item['timestamp'] = aggregator_parse_w3cdtf($date); // Aggregator_parse_w3cdtf() returns FALSE on failure.
151 }
152
153 // Resolve dc:creator tag as the item author if author tag is not set.
154 if (empty($item['author']) && !empty($item['dc:creator'])) {
155 $item['author'] = $item['dc:creator'];
156 }
157
158 $item += array('author' => '', 'description' => '');
159
160 // Store on $feed object. This is where processors will look for parsed items.
161 $feed->items[] = $item;
162 }
163
164 return TRUE;
165 }
166
172 function aggregator_element_start($parser, $name, $attributes) {
173 global $item, $element, $tag, $items, $channel;
174
175 $name = strtolower($name);
176 switch ($name) {
177 case 'image':
178 case 'textinput':
179 case 'summary':
180 case 'tagline':
181 case 'subtitle':
182 case 'logo':
183 case 'info':
184 $element = $name;
185 break;
186 case 'id':
187 case 'content':
188 if ($element != 'item') {
189 $element = $name;
190 }
191 case 'link':
192 // According to RFC 4287, link elements in Atom feeds without a 'rel'
193 // attribute should be interpreted as though the relation type is
194 // "alternate".
195 if (!empty($attributes['HREF']) && (empty($attributes['REL']) || $attributes['REL'] == 'alternate')) {
196 if ($element == 'item') {
197 $items[$item]['link'] = $attributes['HREF'];
198 }
199 else {
200 $channel['link'] = $attributes['HREF'];
201 }
202 }
203 break;
204 case 'item':
205 $element = $name;
206 $item += 1;
207 break;
208 case 'entry':
209 $element = 'item';
210 $item += 1;
211 break;
212 }
213
214 $tag = $name;
215 }
216
222 function aggregator_element_end($parser, $name) {
223 global $element;
224
225 switch ($name) {
226 case 'image':
227 case 'textinput':
228 case 'item':
229 case 'entry':
230 case 'info':
231 $element = '';
232 break;
233 case 'id':
234 case 'content':
235 if ($element == $name) {
236 $element = '';
237 }
238 }
239 }
240
246 function aggregator_element_data($parser, $data) {
247 global $channel, $element, $items, $item, $image, $tag;
248 $items += array($item => array());
249 switch ($element) {
250 case 'item':
251 $items[$item] += array($tag => '');
252 $items[$item][$tag] .= $data;
253 break;
254 case 'image':
255 case 'logo':
256 $image += array($tag => '');
257 $image[$tag] .= $data;
258 break;
259 case 'link':
260 if ($data) {
261 $items[$item] += array($tag => '');
262 $items[$item][$tag] .= $data;
263 }
264 break;
265 case 'content':
266 $items[$item] += array('content' => '');
267 $items[$item]['content'] .= $data;
268 break;
269 case 'summary':
270 $items[$item] += array('summary' => '');
271 $items[$item]['summary'] .= $data;
272 break;
273 case 'tagline':
274 case 'subtitle':
275 $channel += array('description' => '');
276 $channel['description'] .= $data;
277 break;
278 case 'info':
279 case 'id':
280 case 'textinput':
281 // The sub-element is not supported. However, we must recognize
282 // it or its contents will end up in the item array.
283 break;
284 default:
285 $channel += array($tag => '');
286 $channel[$tag] .= $data;
287 }
288 }
289
303 function aggregator_parse_w3cdtf($date_str) {
304 if (preg_match('/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/', $date_str, $match)) {
305 list($year, $month, $day, $hours, $minutes, $seconds) = array($match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);
306 // Calculate the epoch for current date assuming GMT.
307 $epoch = gmmktime($hours, $minutes, $seconds, $month, $day, $year);
308 if ($match[10] != 'Z') { // Z is zulu time, aka GMT
309 list($tz_mod, $tz_hour, $tz_min) = array($match[8], $match[9], $match[10]);
310 // Zero out the variables.
311 if (!$tz_hour) {
312 $tz_hour = 0;
313 }
314 if (!$tz_min) {
315 $tz_min = 0;
316 }
317 $offset_secs = (($tz_hour * 60) + $tz_min) * 60;
318 // Is timezone ahead of GMT? If yes, subtract offset.
319 if ($tz_mod == '+') {
320 $offset_secs *= -1;
321 }
322 $epoch += $offset_secs;
323 }
324 return $epoch;
325 }
326 else {
327 return FALSE;
328 }
329 }
aggregator_element_data
aggregator_element_data($parser, $data)
Definition: aggregator.parser.inc:246
aggregator_aggregator_parse
aggregator_aggregator_parse($feed)
Definition: aggregator.parser.inc:21
$name
print $name
Definition: profile-listing.tpl.php:43
$attributes
print $attributes
Definition: block.tpl.php:47
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
aggregator_parse_w3cdtf
aggregator_parse_w3cdtf($date_str)
Definition: aggregator.parser.inc:303
aggregator_element_start
aggregator_element_start($parser, $name, $attributes)
Definition: aggregator.parser.inc:172
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
aggregator_element_end
aggregator_element_end($parser, $name)
Definition: aggregator.parser.inc:222
truncate_utf8
truncate_utf8($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
Definition: unicode.inc:316
aggregator_parse_feed
aggregator_parse_feed(&$data, $feed)
Definition: aggregator.parser.inc:67
drupal_xml_parser_create
drupal_xml_parser_create(&$data)
Definition: unicode.inc:184
aggregator_aggregator_parse_info
aggregator_aggregator_parse_info()
Definition: aggregator.parser.inc:11
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/trigger/trigger.admin.inc Source File

  • modules
  • trigger
trigger.admin.inc
Go to the documentation of this file.
1 <?php
2
20 function trigger_assign($module_to_display = NULL) {
21 // If no type is specified we default to node actions, since they
22 // are the most common.
23 if (!isset($module_to_display)) {
24 drupal_goto('admin/structure/trigger/node');
25 }
26
27 $build = array();
28 $trigger_info = module_invoke_all('trigger_info');
29 drupal_alter('trigger_info', $trigger_info);
30 foreach ($trigger_info as $module => $hooks) {
31 if ($module == $module_to_display) {
32 foreach ($hooks as $hook => $description) {
33 $form_id = 'trigger_' . $hook . '_assign_form';
34 $build[$form_id] = drupal_get_form($form_id, $module, $hook, $description['label']);
35 }
36 }
37 }
38 return $build;
39 }
40
55 function trigger_unassign($form, $form_state, $module, $hook = NULL, $aid = NULL) {
56 if (!isset($hook, $aid)) {
57 drupal_goto('admin/structure/trigger');
58 }
59
60 $form['hook'] = array(
61 '#type' => 'value',
62 '#value' => $hook,
63 );
64 $form['module'] = array(
65 '#type' => 'value',
66 '#value' => $module,
67 );
68 $form['aid'] = array(
69 '#type' => 'value',
70 '#value' => $aid,
71 );
72
73 $action = actions_function_lookup($aid);
74 $actions = actions_get_all_actions();
75
76 $destination = 'admin/structure/trigger/' . $module;
77
78 return confirm_form($form,
79 t('Are you sure you want to unassign the action %title?', array('%title' => $actions[$action]['label'])),
80 $destination,
81 t('You can assign it again later if you wish.'),
82 t('Unassign'), t('Cancel')
83 );
84 }
85
89 function trigger_unassign_submit($form, &$form_state) {
90 if ($form_state['values']['confirm'] == 1) {
91 $aid = actions_function_lookup($form_state['values']['aid']);
92 db_delete('trigger_assignments')
93 ->condition('hook', $form_state['values']['hook'])
94 ->condition('aid', $aid)
95 ->execute();
96 drupal_static_reset('trigger_get_assigned_actions');
97 $actions = actions_get_all_actions();
98 watchdog('actions', 'Action %action has been unassigned.', array('%action' => $actions[$aid]['label']));
99 drupal_set_message(t('Action %action has been unassigned.', array('%action' => $actions[$aid]['label'])));
100 $form_state['redirect'] = 'admin/structure/trigger/' . $form_state['values']['module'];
101 }
102 else {
103 drupal_goto('admin/structure/trigger');
104 }
105 }
106
121 function trigger_assign_form($form, $form_state, $module, $hook, $label) {
122 $form['module'] = array(
123 '#type' => 'hidden',
124 '#value' => $module,
125 );
126 $form['hook'] = array(
127 '#type' => 'hidden',
128 '#value' => $hook,
129 );
130 // All of these forms use the same validate and submit functions.
131 $form['#validate'][] = 'trigger_assign_form_validate';
132 $form['#submit'][] = 'trigger_assign_form_submit';
133
134 $options = array();
135 $functions = array();
136 // Restrict the options list to actions that declare support for this hook.
137 foreach (actions_list() as $func => $metadata) {
138 if (isset($metadata['triggers']) && array_intersect(array($hook, 'any'), $metadata['triggers'])) {
139 $functions[] = $func;
140 }
141 }
142 foreach (actions_actions_map(actions_get_all_actions()) as $aid => $action) {
143 if (in_array($action['callback'], $functions)) {
144 $options[$action['type']][$aid] = $action['label'];
145 }
146 }
147
148 $form[$hook] = array(
149 '#type' => 'fieldset',
150 // !description is correct, since these labels are passed through t() in
151 // hook_trigger_info().
152 '#title' => t('Trigger: !description', array('!description' => $label)),
153 '#theme' => 'trigger_display',
154 );
155
156 // Retrieve actions that are already assigned to this hook combination.
157 $actions = trigger_get_assigned_actions($hook);
158 $form[$hook]['assigned']['#type'] = 'value';
159 $form[$hook]['assigned']['#value'] = array();
160 foreach ($actions as $aid => $info) {
161 // If action is defined unassign it, otherwise offer to delete all orphaned
162 // actions.
163 $hash = drupal_hash_base64($aid, TRUE);
164 if (actions_function_lookup($hash)) {
165 $form[$hook]['assigned']['#value'][$aid] = array(
166 'label' => $info['label'],
167 'link' => l(t('unassign'), "admin/structure/trigger/unassign/$module/$hook/$hash"),
168 );
169 }
170 else {
171 // Link to system_actions_remove_orphans() to do the clean up.
172 $form[$hook]['assigned']['#value'][$aid] = array(
173 'label' => $info['label'],
174 'link' => l(t('Remove orphaned actions'), "admin/config/system/actions/orphan"),
175 );
176 }
177 }
178
179 $form[$hook]['parent'] = array(
180 '#type' => 'container',
181 '#attributes' => array('class' => array('container-inline')),
182 );
183 // List possible actions that may be assigned.
184 if (count($options) != 0) {
185 $form[$hook]['parent']['aid'] = array(
186 '#type' => 'select',
187 '#title' => t('List of trigger actions when !description', array('!description' => $label)),
188 '#title_display' => 'invisible',
189 '#options' => $options,
190 '#empty_option' => t('Choose an action'),
191 );
192 $form[$hook]['parent']['submit'] = array(
193 '#type' => 'submit',
194 '#value' => t('Assign')
195 );
196 }
197 else {
198 $form[$hook]['none'] = array(
199 '#markup' => t('No actions available for this trigger. <a href="@link">Add action</a>.', array('@link' => url('admin/config/system/actions/manage')))
200 );
201 }
202 return $form;
203 }
204
212 function trigger_assign_form_validate($form, $form_state) {
213 $form_values = $form_state['values'];
214 if (!empty($form_values['aid'])) {
215 $aid = actions_function_lookup($form_values['aid']);
216 $aid_exists = db_query("SELECT aid FROM {trigger_assignments} WHERE hook = :hook AND aid = :aid", array(
217 ':hook' => $form_values['hook'],
218 ':aid' => $aid,
219 ))->fetchField();
220 if ($aid_exists) {
221 form_set_error($form_values['hook'], t('The action you chose is already assigned to that trigger.'));
222 }
223 }
224 }
225
231 function trigger_assign_form_submit($form, &$form_state) {
232 if (!empty($form_state['values']['aid'])) {
233 $aid = actions_function_lookup($form_state['values']['aid']);
234 $weight = db_query("SELECT MAX(weight) FROM {trigger_assignments} WHERE hook = :hook", array(':hook' => $form_state['values']['hook']))->fetchField();
235
236 // Insert the new action.
237 db_insert('trigger_assignments')
238 ->fields(array(
239 'hook' => $form_state['values']['hook'],
240 'aid' => $aid,
241 'weight' => $weight + 1,
242 ))
243 ->execute();
244
245 // If we are not configuring an action for a "presave" hook and this action
246 // changes an object property, then we need to save the object, so the
247 // property change will persist.
248 $actions = actions_list();
249 if (strpos($form_state['values']['hook'], 'presave') === FALSE && isset($actions[$aid]['behavior']) && in_array('changes_property', $actions[$aid]['behavior'])) {
250 // Determine the corresponding save action name for this action.
251 $save_action = strtok($aid, '_') . '_save_action';
252 // If no corresponding save action exists, we need to bail out.
253 if (!isset($actions[$save_action])) {
254 throw new Exception(t('Missing/undefined save action (%save_aid) for %aid action.', array('%save_aid' => $aid, '%aid' => $aid)));
255 }
256 // Delete previous save action if it exists, and re-add it using a higher
257 // weight.
258 $save_action_assigned = db_query("SELECT aid FROM {trigger_assignments} WHERE hook = :hook AND aid = :aid", array(':hook' => $form_state['values']['hook'], ':aid' => $save_action))->fetchField();
259
260 if ($save_action_assigned) {
261 db_delete('trigger_assignments')
262 ->condition('hook', $form_state['values']['hook'])
263 ->condition('aid', $save_action)
264 ->execute();
265 }
266 db_insert('trigger_assignments')
267 ->fields(array(
268 'hook' => $form_state['values']['hook'],
269 'aid' => $save_action,
270 'weight' => $weight + 2,
271 ))
272 ->execute();
273
274 // If no save action existed before, inform the user about it.
275 if (!$save_action_assigned) {
276 drupal_set_message(t('The %label action has been appended, which is required to save the property change.', array('%label' => $actions[$save_action]['label'])));
277 }
278 // Otherwise, just inform about the new weight.
279 else {
280 drupal_set_message(t('The %label action was moved to save the property change.', array('%label' => $actions[$save_action]['label'])));
281 }
282 }
283 }
284 drupal_static_reset('trigger_get_assigned_actions');
285 }
286
296 function theme_trigger_display($variables) {
297 $element = $variables['element'];
298
299 $header = array();
300 $rows = array();
301 if (isset($element['assigned']) && count($element['assigned']['#value'])) {
302 $header = array(array('data' => t('Name')), array('data' => t('Operation')));
303 $rows = array();
304 foreach ($element['assigned']['#value'] as $aid => $info) {
305 $rows[] = array(
306 check_plain($info['label']),
307 $info['link']
308 );
309 }
310 }
311
312 if (count($rows)) {
313 $output = theme('table', array('header' => $header, 'rows' => $rows)) . drupal_render_children($element);
314 }
315 else {
316 $output = drupal_render_children($element);
317 }
318 return $output;
319 }
trigger_assign_form
trigger_assign_form($form, $form_state, $module, $hook, $label)
Definition: trigger.admin.inc:121
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
trigger_assign_form_submit
trigger_assign_form_submit($form, &$form_state)
Definition: trigger.admin.inc:231
trigger_get_assigned_actions
trigger_get_assigned_actions($hook)
Definition: trigger.module:188
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
l
l($text, $path, array $options=array())
Definition: common.inc:2432
actions_function_lookup
actions_function_lookup($hash)
Definition: actions.inc:241
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
$module
print $module
Definition: search-results.tpl.php:28
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
Exception
$header
print $header
Definition: forum-topic-list.tpl.php:42
trigger_unassign
trigger_unassign($form, $form_state, $module, $hook=NULL, $aid=NULL)
Definition: trigger.admin.inc:55
actions_actions_map
actions_actions_map($actions)
Definition: actions.inc:216
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
theme_trigger_display
theme_trigger_display($variables)
Definition: trigger.admin.inc:296
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$info
$info
Definition: color.inc:6
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
actions_get_all_actions
actions_get_all_actions()
Definition: actions.inc:190
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
$output
$output
Definition: authorize.php:93
trigger_assign_form_validate
trigger_assign_form_validate($form, $form_state)
Definition: trigger.admin.inc:212
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
actions_list
actions_list($reset=FALSE)
Definition: actions.inc:162
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
trigger_unassign_submit
trigger_unassign_submit($form, &$form_state)
Definition: trigger.admin.inc:89
drupal_hash_base64
drupal_hash_base64($data)
Definition: bootstrap.inc:2067
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
trigger_assign
trigger_assign($module_to_display=NULL)
Definition: trigger.admin.inc:20
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/image_example/image_example.install Source File

  • examples
  • image_example
image_example.install
Go to the documentation of this file.
1 <?php
2
13 function image_example_install() {
14 // Set a variable containing the name of the style to use when the module
15 // outputs an image.
16 variable_set('image_example_style_name', 'image_example_style');
17 }
18
24 function image_example_uninstall() {
25 variable_del('image_example_style_name');
26 variable_del('image_example_image_fid');
27 }
28
34 function image_example_enable() {
35 // There is currently no way to manually flush an image style which causes
36 // problems when installing a new module that implements
37 // hook_image_styles_alter(). If the new module modifies an image style that
38 // modification will not be applied to any images that have already been
39 // generated unless the styles are flushed. This is one way around that.
40 $styles = image_styles();
41 foreach ($styles as $style) {
42 image_style_flush($style);
43 }
44 }
45
51 function image_example_disable() {
52 // Solves the same problem as image_example_enable().
53 image_example_enable();
54 }
variable_del
variable_del($name)
Definition: bootstrap.inc:996
image_styles
image_styles()
Definition: image.module:565
image_example_enable
image_example_enable()
Definition: image_example.install:34
$styles
print $styles
Definition: html.tpl.php:52
image_example_uninstall
image_example_uninstall()
Definition: image_example.install:24
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
image_example_install
image_example_install()
Definition: image_example.install:13
image_example_disable
image_example_disable()
Definition: image_example.install:51
image_style_flush
image_style_flush($style)
Definition: image.module:971
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.install Source File

  • modules
  • field
field.install
Go to the documentation of this file.
1 <?php
2
11 function field_schema() {
12 // Static (meta) tables.
13 $schema['field_config'] = array(
14 'fields' => array(
15 'id' => array(
16 'type' => 'serial',
17 'not null' => TRUE,
18 'description' => 'The primary identifier for a field',
19 ),
20 'field_name' => array(
21 'type' => 'varchar',
22 'length' => 32,
23 'not null' => TRUE,
24 'description' => 'The name of this field. Non-deleted field names are unique, but multiple deleted fields can have the same name.',
25 ),
26 'type' => array(
27 'type' => 'varchar',
28 'length' => 128,
29 'not null' => TRUE,
30 'description' => 'The type of this field.',
31 ),
32 'module' => array(
33 'type' => 'varchar',
34 'length' => 128,
35 'not null' => TRUE,
36 'default' => '',
37 'description' => 'The module that implements the field type.',
38 ),
39 'active' => array(
40 'type' => 'int',
41 'size' => 'tiny',
42 'not null' => TRUE,
43 'default' => 0,
44 'description' => 'Boolean indicating whether the module that implements the field type is enabled.',
45 ),
46 'storage_type' => array(
47 'type' => 'varchar',
48 'length' => 128,
49 'not null' => TRUE,
50 'description' => 'The storage backend for the field.',
51 ),
52 'storage_module' => array(
53 'type' => 'varchar',
54 'length' => 128,
55 'not null' => TRUE,
56 'default' => '',
57 'description' => 'The module that implements the storage backend.',
58 ),
59 'storage_active' => array(
60 'type' => 'int',
61 'size' => 'tiny',
62 'not null' => TRUE,
63 'default' => 0,
64 'description' => 'Boolean indicating whether the module that implements the storage backend is enabled.',
65 ),
66 'locked' => array(
67 'type' => 'int',
68 'size' => 'tiny',
69 'not null' => TRUE,
70 'default' => 0,
71 'description' => '@TODO',
72 ),
73 'data' => array(
74 'type' => 'blob',
75 'size' => 'big',
76 'not null' => TRUE,
77 'serialize' => TRUE,
78 'description' => 'Serialized data containing the field properties that do not warrant a dedicated column.',
79 ),
80 'cardinality' => array(
81 'type' => 'int',
82 'size' => 'tiny',
83 'not null' => TRUE,
84 'default' => 0,
85 ),
86 'translatable' => array(
87 'type' => 'int',
88 'size' => 'tiny',
89 'not null' => TRUE,
90 'default' => 0,
91 ),
92 'deleted' => array(
93 'type' => 'int',
94 'size' => 'tiny',
95 'not null' => TRUE,
96 'default' => 0,
97 ),
98 ),
99 'primary key' => array('id'),
100 'indexes' => array(
101 'field_name' => array('field_name'),
102 // Used by field_sync_field_status().
103 'active' => array('active'),
104 'storage_active' => array('storage_active'),
105 'deleted' => array('deleted'),
106 // Used by field_modules_disabled().
107 'module' => array('module'),
108 'storage_module' => array('storage_module'),
109 'type' => array('type'),
110 'storage_type' => array('storage_type'),
111 ),
112 );
113 $schema['field_config_instance'] = array(
114 'fields' => array(
115 'id' => array(
116 'type' => 'serial',
117 'not null' => TRUE,
118 'description' => 'The primary identifier for a field instance',
119 ),
120 'field_id' => array(
121 'type' => 'int',
122 'not null' => TRUE,
123 'description' => 'The identifier of the field attached by this instance',
124 ),
125 'field_name' => array(
126 'type' => 'varchar',
127 'length' => 32,
128 'not null' => TRUE,
129 'default' => ''
130 ),
131 'entity_type' => array(
132 'type' => 'varchar',
133 'length' => 32,
134 'not null' => TRUE,
135 'default' => ''
136 ),
137 'bundle' => array(
138 'type' => 'varchar',
139 'length' => 128,
140 'not null' => TRUE,
141 'default' => ''
142 ),
143 'data' => array(
144 'type' => 'blob',
145 'size' => 'big',
146 'not null' => TRUE,
147 'serialize' => TRUE,
148 ),
149 'deleted' => array(
150 'type' => 'int',
151 'size' => 'tiny',
152 'not null' => TRUE,
153 'default' => 0,
154 ),
155 ),
156 'primary key' => array('id'),
157 'indexes' => array(
158 // Used by field_delete_instance().
159 'field_name_bundle' => array('field_name', 'entity_type', 'bundle'),
160 // Used by field_read_instances().
161 'deleted' => array('deleted'),
162 ),
163 );
164 $schema['cache_field'] = drupal_get_schema_unprocessed('system', 'cache');
165
166 return $schema;
167 }
168
177 function _update_7000_field_create_field(&$field) {
178 // Merge in default values.`
179 $field += array(
180 'entity_types' => array(),
181 'cardinality' => 1,
182 'translatable' => FALSE,
183 'locked' => FALSE,
184 'settings' => array(),
185 'indexes' => array(),
186 'deleted' => 0,
187 'active' => 1,
188 );
189
190 // Set storage.
191 $field['storage'] = array(
192 'type' => 'field_sql_storage',
193 'settings' => array(),
194 'module' => 'field_sql_storage',
195 'active' => 1,
196 );
197
198 // Fetch the field schema to initialize columns and indexes. The field module
199 // is not guaranteed to be loaded at this point.
200 module_load_install($field['module']);
201 $schema = (array) module_invoke($field['module'], 'field_schema', $field);
202 $schema += array('columns' => array(), 'indexes' => array());
203 // 'columns' are hardcoded in the field type.
204 $field['columns'] = $schema['columns'];
205 // 'indexes' can be both hardcoded in the field type, and specified in the
206 // incoming $field definition.
207 $field['indexes'] += $schema['indexes'];
208
209 // The serialized 'data' column contains everything from $field that does not
210 // have its own column and is not automatically populated when the field is
211 // read.
212 $data = $field;
213 unset($data['columns'], $data['field_name'], $data['type'], $data['active'], $data['module'], $data['storage_type'], $data['storage_active'], $data['storage_module'], $data['locked'], $data['cardinality'], $data['deleted']);
214 // Additionally, do not save the 'bundles' property populated by
215 // field_info_field().
216 unset($data['bundles']);
217
218 // Write the field to the database.
219 $record = array(
220 'field_name' => $field['field_name'],
221 'type' => $field['type'],
222 'module' => $field['module'],
223 'active' => (int) $field['active'],
224 'storage_type' => $field['storage']['type'],
225 'storage_module' => $field['storage']['module'],
226 'storage_active' => (int) $field['storage']['active'],
227 'locked' => (int) $field['locked'],
228 'data' => serialize($data),
229 'cardinality' => $field['cardinality'],
230 'translatable' => (int) $field['translatable'],
231 'deleted' => (int) $field['deleted'],
232 );
233 // We don't use drupal_write_record() here because it depends on the schema.
234 $field['id'] = db_insert('field_config')
235 ->fields($record)
236 ->execute();
237
238 // Create storage for the field.
239 field_sql_storage_field_storage_create_field($field);
240 }
241
258 function _update_7000_field_delete_field($field_name) {
259 $table_name = 'field_data_' . $field_name;
260 if (db_select($table_name)->range(0, 1)->countQuery()->execute()->fetchField()) {
261 $t = get_t();
262 throw new Exception($t('This function can only be used to delete fields without data'));
263 }
264 // Delete all instances.
265 db_delete('field_config_instance')
266 ->condition('field_name', $field_name)
267 ->execute();
268
269 // Nuke field data and revision tables.
270 db_drop_table($table_name);
271 db_drop_table('field_revision_' . $field_name);
272
273 // Delete the field.
274 db_delete('field_config')
275 ->condition('field_name', $field_name)
276 ->execute();
277 }
278
279
289 function _update_7000_field_delete_instance($field_name, $entity_type, $bundle) {
290 // Delete field instance configuration data.
291 db_delete('field_config_instance')
292 ->condition('field_name', $field_name)
293 ->condition('entity_type', $entity_type)
294 ->condition('bundle', $bundle)
295 ->execute();
296
297 // Nuke data.
298 db_delete('field_data_' . $field_name)
299 ->condition('entity_type', $entity_type)
300 ->condition('bundle', $bundle)
301 ->execute();
302 db_delete('field_revision_' . $field_name)
303 ->condition('entity_type', $entity_type)
304 ->condition('bundle', $bundle)
305 ->execute();
306 }
307
328 function _update_7000_field_read_fields(array $conditions = array(), $key = 'id') {
329 $fields = array();
330 $query = db_select('field_config', 'fc', array('fetch' => PDO::FETCH_ASSOC))
331 ->fields('fc');
332 foreach ($conditions as $column => $value) {
333 $query->condition($column, $value);
334 }
335 foreach ($query->execute() as $record) {
336 $field = unserialize($record['data']);
337 $field['id'] = $record['id'];
338 $field['field_name'] = $record['field_name'];
339 $field['type'] = $record['type'];
340 $field['module'] = $record['module'];
341 $field['active'] = $record['active'];
342 $field['storage']['type'] = $record['storage_type'];
343 $field['storage']['module'] = $record['storage_module'];
344 $field['storage']['active'] = $record['storage_active'];
345 $field['locked'] = $record['locked'];
346 $field['cardinality'] = $record['cardinality'];
347 $field['translatable'] = $record['translatable'];
348 $field['deleted'] = $record['deleted'];
349
350 $fields[$field[$key]] = $field;
351 }
352 return $fields;
353 }
354
363 function _update_7000_field_create_instance($field, &$instance) {
364 // Merge in defaults.
365 $instance += array(
366 'field_id' => $field['id'],
367 'field_name' => $field['field_name'],
368 'deleted' => 0,
369 );
370
371 // The serialized 'data' column contains everything from $instance that does
372 // not have its own column and is not automatically populated when the
373 // instance is read.
374 $data = $instance;
375 unset($data['id'], $data['field_id'], $data['field_name'], $data['entity_type'], $data['bundle'], $data['deleted']);
376
377 $record = array(
378 'field_id' => $instance['field_id'],
379 'field_name' => $instance['field_name'],
380 'entity_type' => $instance['entity_type'],
381 'bundle' => $instance['bundle'],
382 'data' => serialize($data),
383 'deleted' => (int) $instance['deleted'],
384 );
385 $instance['id'] = db_insert('field_config_instance')
386 ->fields($record)
387 ->execute();
388 }
389
398 function field_update_7000() {
399 // Some update helper functions (such as _update_7000_field_create_field())
400 // modify the database directly. They can be used safely only if the database
401 // schema matches the field module schema established for Drupal 7.0 (i.e.
402 // version 7000). This function exists solely to set the schema version to
403 // 7000, so that update functions calling those helpers can do so safely
404 // by declaring a dependency on field_update_7000().
405 }
406
410 function field_update_7001() {
411 $fields = _update_7000_field_read_fields();
412 foreach ($fields as $field) {
413 // _update_7000_field_create_field() was broken in d7 RC2, and the fields
414 // created during a d6 to d7 upgrade do not correcly store the 'index'
415 // entry. See http://drupal.org/node/996160.
416
417 module_load_install($field['module']);
418 $schema = (array) module_invoke($field['module'], 'field_schema', $field);
419 $schema += array('indexes' => array());
420 // 'indexes' can be both hardcoded in the field type, and specified in the
421 // incoming $field definition.
422 $field['indexes'] += $schema['indexes'];
423
424 // Place the updated entries in the existing serialized 'data' column.
425 $data = db_query("SELECT data FROM {field_config} WHERE id = :id", array(':id' => $field['id']))->fetchField();
426 $data = unserialize($data);
427 $data['columns'] = $field['columns'];
428 $data['indexes'] = $field['indexes'];
429
430 // Save the new data.
431 $query = db_update('field_config')
432 ->condition('id', $field['id'])
433 ->fields(array('data' => serialize($data)))
434 ->execute();
435 }
436 }
437
450 function field_update_7002() {
451 $settings = variable_get('field_bundle_settings', array());
452 if ($settings) {
453 foreach ($settings as $entity_type => $entity_type_settings) {
454 foreach ($entity_type_settings as $bundle => $bundle_settings) {
455 variable_set('field_bundle_settings_' . $entity_type . '__' . $bundle, $bundle_settings);
456 }
457 }
458 variable_del('field_bundle_settings');
459 }
460 }
461
465 function field_update_7003() {
466 // Empty update to force a rebuild of the registry.
467 }
468
_update_7000_field_delete_field
_update_7000_field_delete_field($field_name)
Definition: field.install:258
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
field_update_7002
field_update_7002()
Definition: field.install:450
Exception
_update_7000_field_read_fields
_update_7000_field_read_fields(array $conditions=array(), $key= 'id')
Definition: field.install:328
field_sql_storage_field_storage_create_field
field_sql_storage_field_storage_create_field($field)
Definition: field_sql_storage.module:213
module_load_install
module_load_install($module)
Definition: module.inc:288
drupal_get_schema_unprocessed
drupal_get_schema_unprocessed($module, $table=NULL)
Definition: common.inc:6998
field_update_7003
field_update_7003()
Definition: field.install:465
field_update_7000
field_update_7000()
Definition: field.install:398
$value
print $value
Definition: user-profile-item.tpl.php:26
field_schema
field_schema()
Definition: field.install:11
get_t
get_t()
Definition: bootstrap.inc:2635
_update_7000_field_create_instance
_update_7000_field_create_instance($field, &$instance)
Definition: field.install:363
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
field_update_7001
field_update_7001()
Definition: field.install:410
_update_7000_field_delete_instance
_update_7000_field_delete_instance($field_name, $entity_type, $bundle)
Definition: field.install:289
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
_update_7000_field_create_field
_update_7000_field_create_field(&$field)
Definition: field.install:177
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/language.inc Source File

  • includes
language.inc
Go to the documentation of this file.
1 <?php
2
13 define('LANGUAGE_NEGOTIATION_DEFAULT', 'language-default');
14
110 function language_types_info() {
111 $language_types = &drupal_static(__FUNCTION__);
112
113 if (!isset($language_types)) {
114 $language_types = module_invoke_all('language_types_info');
115 // Let other modules alter the list of language types.
116 drupal_alter('language_types_info', $language_types);
117 }
118
119 return $language_types;
120 }
121
139 function language_types_configurable($stored = TRUE) {
140 $configurable = &drupal_static(__FUNCTION__);
141
142 if ($stored && !isset($configurable)) {
143 $types = variable_get('language_types', drupal_language_types());
144 $configurable = array_keys(array_filter($types));
145 }
146
147 if (!$stored) {
148 $result = array();
149 foreach (language_types_info() as $type => $info) {
150 if (!isset($info['fixed'])) {
151 $result[] = $type;
152 }
153 }
154 return $result;
155 }
156
157 return $configurable;
158 }
159
166 function language_types_disable($types) {
167 $enabled_types = variable_get('language_types', drupal_language_types());
168
169 foreach ($types as $type) {
170 unset($enabled_types[$type]);
171 }
172
173 variable_set('language_types', $enabled_types);
174 }
175
179 function language_types_set() {
180 // Ensure that we are getting the defined language negotiation information. An
181 // invocation of module_enable() or module_disable() could outdate the cached
182 // information.
183 drupal_static_reset('language_types_info');
184 drupal_static_reset('language_negotiation_info');
185
186 // Determine which language types are configurable and which not by checking
187 // whether the 'fixed' key is defined. Non-configurable (fixed) language types
188 // have their language negotiation settings stored there.
189 $defined_providers = language_negotiation_info();
190 foreach (language_types_info() as $type => $info) {
191 if (isset($info['fixed'])) {
192 $language_types[$type] = FALSE;
193 $negotiation = array();
194 foreach ($info['fixed'] as $weight => $id) {
195 if (isset($defined_providers[$id])) {
196 $negotiation[$id] = $weight;
197 }
198 }
199 language_negotiation_set($type, $negotiation);
200 }
201 else {
202 $language_types[$type] = TRUE;
203 }
204 }
205
206 // Save language types.
207 variable_set('language_types', $language_types);
208
209 // Ensure that subsequent calls of language_types_configurable() return the
210 // updated language type information.
211 drupal_static_reset('language_types_configurable');
212 }
213
230 function language_negotiation_get($type, $provider_id = NULL) {
231 $negotiation = variable_get("language_negotiation_$type", array());
232
233 if (empty($negotiation)) {
234 return empty($provider_id) ? LANGUAGE_NEGOTIATION_DEFAULT : FALSE;
235 }
236
237 if (empty($provider_id)) {
238 return key($negotiation);
239 }
240
241 if (isset($negotiation[$provider_id])) {
242 return $provider_id;
243 }
244
245 return FALSE;
246 }
247
258 function language_negotiation_get_any($provider_id) {
259 foreach (language_types_configurable() as $type) {
260 if (language_negotiation_get($type, $provider_id)) {
261 return TRUE;
262 }
263 }
264
265 return FALSE;
266 }
267
279 function language_negotiation_get_switch_links($type, $path) {
280 $links = FALSE;
281 $negotiation = variable_get("language_negotiation_$type", array());
282
283 // Only get the languages if we have more than one.
284 if (count(language_list()) >= 2) {
285 $language = language_initialize($type);
286 }
287
288 foreach ($negotiation as $id => $provider) {
289 if (isset($provider['callbacks']['switcher'])) {
290 if (isset($provider['file'])) {
291 require_once DRUPAL_ROOT . '/' . $provider['file'];
292 }
293
294 $callback = $provider['callbacks']['switcher'];
295 $result = $callback($type, $path);
296
297 // Add support for WCAG 2.0's Language of Parts to add language identifiers.
298 // http://www.w3.org/TR/UNDERSTANDING-WCAG20/meaning-other-lang-id.html
299 foreach ($result as $langcode => $link) {
300 $result[$langcode]['attributes']['lang'] = $langcode;
301 }
302
303 if (!empty($result)) {
304 // Allow modules to provide translations for specific links.
305 drupal_alter('language_switch_links', $result, $type, $path);
306 $links = (object) array('links' => $result, 'provider' => $id);
307 break;
308 }
309 }
310 }
311
312 return $links;
313 }
314
318 function language_negotiation_purge() {
319 // Ensure that we are getting the defined language negotiation information. An
320 // invocation of module_enable() or module_disable() could outdate the cached
321 // information.
322 drupal_static_reset('language_negotiation_info');
323 drupal_static_reset('language_types_info');
324
325 $defined_providers = language_negotiation_info();
326 foreach (language_types_info() as $type => $type_info) {
327 $weight = 0;
328 $negotiation = array();
329 foreach (variable_get("language_negotiation_$type", array()) as $id => $provider) {
330 if (isset($defined_providers[$id])) {
331 $negotiation[$id] = $weight++;
332 }
333 }
334 language_negotiation_set($type, $negotiation);
335 }
336 }
337
347 function language_negotiation_set($type, $language_providers) {
348 // Save only the necessary fields.
349 $provider_fields = array('callbacks', 'file', 'cache');
350
351 $negotiation = array();
352 $providers_weight = array();
353 $defined_providers = language_negotiation_info();
354 $default_types = language_types_configurable(FALSE);
355
356 // Initialize the providers weight list.
357 foreach ($language_providers as $id => $provider) {
358 $providers_weight[$id] = language_provider_weight($provider);
359 }
360
361 // Order providers list by weight.
362 asort($providers_weight);
363
364 foreach ($providers_weight as $id => $weight) {
365 if (isset($defined_providers[$id])) {
366 $provider = $defined_providers[$id];
367 // If the provider does not express any preference about types, make it
368 // available for any configurable type.
369 $types = array_flip(isset($provider['types']) ? $provider['types'] : $default_types);
370 // Check whether the provider is defined and has the right type.
371 if (isset($types[$type])) {
372 $provider_data = array();
373 foreach ($provider_fields as $field) {
374 if (isset($provider[$field])) {
375 $provider_data[$field] = $provider[$field];
376 }
377 }
378 $negotiation[$id] = $provider_data;
379 }
380 }
381 }
382
383 variable_set("language_negotiation_$type", $negotiation);
384 }
385
392 function language_negotiation_info() {
393 $language_providers = &drupal_static(__FUNCTION__);
394
395 if (!isset($language_providers)) {
396 // Collect all the module-defined language negotiation providers.
397 $language_providers = module_invoke_all('language_negotiation_info');
398
399 // Add the default language negotiation provider.
400 $language_providers[LANGUAGE_NEGOTIATION_DEFAULT] = array(
401 'callbacks' => array('language' => 'language_from_default'),
402 'weight' => 10,
403 'name' => t('Default'),
404 'description' => t('Use the default site language (@language_name).', array('@language_name' => language_default()->native)),
405 );
406
407 // Let other modules alter the list of language negotiation providers.
408 drupal_alter('language_negotiation_info', $language_providers);
409 }
410
411 return $language_providers;
412 }
413
427 function language_provider_invoke($provider_id, $provider = NULL) {
428 $results = &drupal_static(__FUNCTION__);
429
430 if (!isset($results[$provider_id])) {
431 global $user;
432
433 // Get languages grouped by status and select only the enabled ones.
434 $languages = language_list('enabled');
435 $languages = $languages[1];
436
437 if (!isset($provider)) {
438 $providers = language_negotiation_info();
439 $provider = $providers[$provider_id];
440 }
441
442 if (isset($provider['file'])) {
443 require_once DRUPAL_ROOT . '/' . $provider['file'];
444 }
445
446 // If the language negotiation provider has no cache preference or this is
447 // satisfied we can execute the callback.
448 $cache = !isset($provider['cache']) || $user->uid || $provider['cache'] == variable_get('cache', 0);
449 $callback = isset($provider['callbacks']['language']) ? $provider['callbacks']['language'] : FALSE;
450 $langcode = $cache && function_exists($callback) ? $callback($languages) : FALSE;
451 $results[$provider_id] = isset($languages[$langcode]) ? $languages[$langcode] : FALSE;
452 }
453
454 // Since objects are resources, we need to return a clone to prevent the
455 // language negotiation provider cache from being unintentionally altered. The
456 // same providers might be used with different language types based on
457 // configuration.
458 return !empty($results[$provider_id]) ? clone($results[$provider_id]) : $results[$provider_id];
459 }
460
470 function language_provider_weight($provider) {
471 $default = is_numeric($provider) ? $provider : 0;
472 return isset($provider['weight']) && is_numeric($provider['weight']) ? $provider['weight'] : $default;
473 }
474
484 function language_initialize($type) {
485 // Execute the language negotiation providers in the order they were set up and return the
486 // first valid language found.
487 $negotiation = variable_get("language_negotiation_$type", array());
488
489 foreach ($negotiation as $provider_id => $provider) {
490 $language = language_provider_invoke($provider_id, $provider);
491 if ($language) {
492 $language->provider = $provider_id;
493 return $language;
494 }
495 }
496
497 // If no other language was found use the default one.
498 $language = language_default();
499 $language->provider = LANGUAGE_NEGOTIATION_DEFAULT;
500 return $language;
501 }
502
509 function language_from_default() {
510 return language_default()->language;
511 }
512
530 function language_url_split_prefix($path, $languages) {
531 $args = empty($path) ? array() : explode('/', $path);
532 $prefix = array_shift($args);
533
534 // Search prefix within enabled languages.
535 foreach ($languages as $language) {
536 if (!empty($language->prefix) && $language->prefix == $prefix) {
537 // Rebuild $path with the language removed.
538 return array($language, implode('/', $args));
539 }
540 }
541
542 return array(FALSE, $path);
543 }
544
554 function language_fallback_get_candidates($type = LANGUAGE_TYPE_CONTENT) {
555 $fallback_candidates = &drupal_static(__FUNCTION__);
556
557 if (!isset($fallback_candidates)) {
558 $fallback_candidates = array();
559
560 // Get languages ordered by weight.
561 // Use array keys to avoid duplicated entries.
562 foreach (language_list('weight') as $languages) {
563 foreach ($languages as $language) {
564 $fallback_candidates[$language->language] = NULL;
565 }
566 }
567
568 $fallback_candidates = array_keys($fallback_candidates);
569 $fallback_candidates[] = LANGUAGE_NONE;
570
571 // Let other modules hook in and add/change candidates.
572 drupal_alter('language_fallback_candidates', $fallback_candidates);
573 }
574
575 return $fallback_candidates;
576 }
577
language_initialize
language_initialize($type)
Definition: language.inc:484
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
language_negotiation_get
language_negotiation_get($type, $provider_id=NULL)
Definition: language.inc:230
language_from_default
language_from_default()
Definition: language.inc:509
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
drupal_language_types
drupal_language_types()
Definition: bootstrap.inc:2677
$results
print $results
Definition: poll-results.tpl.php:23
LANGUAGE_TYPE_CONTENT
const LANGUAGE_TYPE_CONTENT
Definition: bootstrap.inc:186
language_fallback_get_candidates
language_fallback_get_candidates($type=LANGUAGE_TYPE_CONTENT)
Definition: language.inc:554
language_negotiation_set
language_negotiation_set($type, $language_providers)
Definition: language.inc:347
language_provider_weight
language_provider_weight($provider)
Definition: language.inc:470
LANGUAGE_NEGOTIATION_DEFAULT
const LANGUAGE_NEGOTIATION_DEFAULT
Definition: language.inc:13
language_types_set
language_types_set()
Definition: language.inc:179
language_types_configurable
language_types_configurable($stored=TRUE)
Definition: language.inc:139
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$info
$info
Definition: color.inc:6
language_list
language_list($field= 'language')
Definition: bootstrap.inc:2723
language_negotiation_get_switch_links
language_negotiation_get_switch_links($type, $path)
Definition: language.inc:279
language_negotiation_get_any
language_negotiation_get_any($provider_id)
Definition: language.inc:258
language_types_info
language_types_info()
Definition: language.inc:110
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
language_url_split_prefix
language_url_split_prefix($path, $languages)
Definition: language.inc:530
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
language_provider_invoke
language_provider_invoke($provider_id, $provider=NULL)
Definition: language.inc:427
language_negotiation_info
language_negotiation_info()
Definition: language.inc:392
language_default
language_default($property=NULL)
Definition: bootstrap.inc:2765
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
language_negotiation_purge
language_negotiation_purge()
Definition: language.inc:318
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
language_types_disable
language_types_disable($types)
Definition: language.inc:166
$links
print $links
Definition: poll-results--block.tpl.php:28
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
TableSort Member List

This is the complete list of members for TableSort, including all inherited members.

$connection | SelectQueryExtender | protected
$header | TableSort | protected
$placeholder | SelectQueryExtender | protected
$query | SelectQueryExtender | protected
$uniqueIdentifier | SelectQueryExtender | protected
__call($method, $args) | SelectQueryExtender |
__clone() | SelectQueryExtender |
__construct(SelectQueryInterface $query, DatabaseConnection $connection) | TableSort |
__toString() | SelectQueryExtender |
addExpression($expression, $alias=NULL, $arguments=array()) | SelectQueryExtender |
addField($table_alias, $field, $alias=NULL) | SelectQueryExtender |
addJoin($type, $table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
addMetaData($key, $object) | SelectQueryExtender |
addTag($tag) | SelectQueryExtender |
arguments() | SelectQueryExtender |
compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder) | SelectQueryExtender |
compiled() | SelectQueryExtender |
condition($field, $value=NULL, $operator=NULL) | SelectQueryExtender |
conditions() | SelectQueryExtender |
countQuery() | SelectQueryExtender |
distinct($distinct=TRUE) | SelectQueryExtender |
execute() | SelectQueryExtender |
exists(SelectQueryInterface $select) | SelectQueryExtender |
extend($extender_name) | SelectQueryExtender |
fields($table_alias, array $fields=array()) | SelectQueryExtender |
forUpdate($set=TRUE) | SelectQueryExtender |
getArguments(QueryPlaceholderInterface $queryPlaceholder=NULL) | SelectQueryExtender |
getExpressions() | SelectQueryExtender |
getFields() | SelectQueryExtender |
getGroupBy() | SelectQueryExtender |
getMetaData($key) | SelectQueryExtender |
getOrderBy() | SelectQueryExtender |
getQueryParameters() | TableSort | protected
getSort() | TableSort | protected
getTables() | SelectQueryExtender |
getUnion() | SelectQueryExtender |
groupBy($field) | SelectQueryExtender |
hasAllTags() | SelectQueryExtender |
hasAnyTag() | SelectQueryExtender |
hasTag($tag) | SelectQueryExtender |
having($snippet, $args=array()) | SelectQueryExtender |
havingArguments() | SelectQueryExtender |
havingCompile(DatabaseConnection $connection) | SelectQueryExtender |
havingCondition($field, $value=NULL, $operator= '=') | SelectQueryExtender |
havingConditions() | SelectQueryExtender |
init() | TableSort | protected
innerJoin($table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
isNotNull($field) | SelectQueryExtender |
isNull($field) | SelectQueryExtender |
isPrepared() | SelectQueryExtender |
join($table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
leftJoin($table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
nextPlaceholder() | SelectQueryExtender |
notExists(SelectQueryInterface $select) | SelectQueryExtender |
order() | TableSort | protected
orderBy($field, $direction= 'ASC') | SelectQueryExtender |
orderByHeader(Array $header) | TableSort |
orderRandom() | SelectQueryExtender |
preExecute(SelectQueryInterface $query=NULL) | SelectQueryExtender |
range($start=NULL, $length=NULL) | SelectQueryExtender |
rightJoin($table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
union(SelectQueryInterface $query, $type= '') | SelectQueryExtender |
uniqueIdentifier() | SelectQueryExtender |
where($snippet, $args=array()) | SelectQueryExtender |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Pager pieces

Pager pieces

Theme functions for customizing pager elements.

Note that you should NOT modify this file to customize your pager.

Generated on Mon Feb 3 2014 12:40:50 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search-results.tpl.php Source File

  • modules
  • search
search-results.tpl.php
Go to the documentation of this file.
1 <?php
2
25 ?>
26 <?php if ($search_results): ?>
27 <h2><?php print t('Search results');?></h2>
28 <ol class="search-results <?php print $module; ?>-results">
29 <?php print $search_results; ?>
30 </ol>
31 <?php print $pager; ?>
32 <?php else : ?>
33 <h2><?php print t('Your search yielded no results');?></h2>
34 <?php print search_help('search#noresults', drupal_help_arg()); ?>
35 <?php endif; ?>
$pager
print $pager
Definition: aggregator-wrapper.tpl.php:19
drupal_help_arg
drupal_help_arg($arg=array())
Definition: menu.inc:1700
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
endif
endif
Definition: aggregator-item.tpl.php:31
search_help
search_help($path, $arg)
Definition: search.module:64
$search_results
print $search_results
Definition: search-results.tpl.php:29
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/cache-install.inc Source File

  • includes
cache-install.inc
Go to the documentation of this file.
1 <?php
2
17 class DrupalFakeCache extends DrupalDatabaseCache implements DrupalCacheInterface {
18
22 function get($cid) {
23 return FALSE;
24 }
25
29 function getMultiple(&$cids) {
30 return array();
31 }
32
36 function set($cid, $data, $expire = CACHE_PERMANENT) {
37 }
38
42 function clear($cid = NULL, $wildcard = FALSE) {
43 // If there is a database cache, attempt to clear it whenever possible. The
44 // reason for doing this is that the database cache can accumulate data
45 // during installation due to any full bootstraps that may occur at the
46 // same time (for example, Ajax requests triggered by the installer). If we
47 // didn't try to clear it whenever this function is called, the data in the
48 // cache would become stale; for example, the installer sometimes calls
49 // variable_set(), which updates the {variable} table and then clears the
50 // cache to make sure that the next page request picks up the new value.
51 // Not actually clearing the cache here therefore leads old variables to be
52 // loaded on the first page requests after installation, which can cause
53 // subtle bugs, some of which would not be fixed unless the site
54 // administrator cleared the cache manually.
55 try {
56 if (class_exists('Database')) {
57 parent::clear($cid, $wildcard);
58 }
59 }
60 // If the attempt at clearing the cache causes an error, that means that
61 // either the database connection is not set up yet or the relevant cache
62 // table in the database has not yet been created, so we can safely do
63 // nothing here.
64 catch (Exception $e) {
65 }
66 }
67
71 function isEmpty() {
72 return TRUE;
73 }
74 }
DrupalFakeCache\clear
clear($cid=NULL, $wildcard=FALSE)
Definition: cache-install.inc:42
Exception
DrupalCacheInterface
Definition: cache.inc:221
DrupalFakeCache\set
set($cid, $data, $expire=CACHE_PERMANENT)
Definition: cache-install.inc:36
DrupalFakeCache\getMultiple
getMultiple(&$cids)
Definition: cache-install.inc:29
CACHE_PERMANENT
const CACHE_PERMANENT
Definition: bootstrap.inc:48
DrupalFakeCache
Definition: cache-install.inc:17
DrupalDatabaseCache
Definition: cache.inc:307
DrupalFakeCache\isEmpty
isEmpty()
Definition: cache-install.inc:71
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/simpletest/simpletest.module Source File

  • modules
  • simpletest
simpletest.module
Go to the documentation of this file.
1 <?php
2
11 function simpletest_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#simpletest':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t('The Testing module provides a framework for running automated unit tests. It can be used to verify a working state of Drupal before and after any code changes, or as a means for developers to write and execute tests for their modules. For more information, see the online handbook entry for <a href="@simpletest">Testing module</a>.', array('@simpletest' => 'http://drupal.org/documentation/modules/simpletest', '@blocks' => url('admin/structure/block'))) . '</p>';
17 $output .= '<h3>' . t('Uses') . '</h3>';
18 $output .= '<dl>';
19 $output .= '<dt>' . t('Running tests') . '</dt>';
20 $output .= '<dd>' . t('Visit the <a href="@admin-simpletest">Testing page</a> to display a list of available tests. For comprehensive testing, select <em>all</em> tests, or individually select tests for more targeted testing. Note that it might take several minutes for all tests to complete. For more information on creating and modifying your own tests, see the <a href="@simpletest-api">Testing API Documentation</a> in the Drupal handbook.', array('@simpletest-api' => 'http://drupal.org/simpletest', '@admin-simpletest' => url('admin/config/development/testing'))) . '</dd>';
21 $output .= '<dd>' . t('After the tests run, a message will be displayed next to each test group indicating whether tests within it passed, failed, or had exceptions. A pass means that the test returned the expected results, while fail means that it did not. An exception normally indicates an error outside of the test, such as a PHP warning or notice. If there were failures or exceptions, the results will be expanded to show details, and the tests that had failures or exceptions will be indicated in red or pink rows. You can then use these results to refine your code and tests, until all tests pass.') . '</dd>';
22 $output .= '</dl>';
23 return $output;
24 }
25 }
26
30 function simpletest_menu() {
31 $items['admin/config/development/testing'] = array(
32 'title' => 'Testing',
33 'page callback' => 'drupal_get_form',
34 'page arguments' => array('simpletest_test_form'),
35 'description' => 'Run tests against Drupal core and your active modules. These tests help assure that your site code is working as designed.',
36 'access arguments' => array('administer unit tests'),
37 'file' => 'simpletest.pages.inc',
38 'weight' => -5,
39 );
40 $items['admin/config/development/testing/list'] = array(
41 'title' => 'List',
42 'type' => MENU_DEFAULT_LOCAL_TASK,
43 );
44 $items['admin/config/development/testing/settings'] = array(
45 'title' => 'Settings',
46 'page callback' => 'drupal_get_form',
47 'page arguments' => array('simpletest_settings_form'),
48 'access arguments' => array('administer unit tests'),
49 'type' => MENU_LOCAL_TASK,
50 'file' => 'simpletest.pages.inc',
51 );
52 $items['admin/config/development/testing/results/%'] = array(
53 'title' => 'Test result',
54 'page callback' => 'drupal_get_form',
55 'page arguments' => array('simpletest_result_form', 5),
56 'description' => 'View result of tests.',
57 'access arguments' => array('administer unit tests'),
58 'file' => 'simpletest.pages.inc',
59 );
60 return $items;
61 }
62
66 function simpletest_permission() {
67 return array(
68 'administer unit tests' => array(
69 'title' => t('Administer tests'),
70 'restrict access' => TRUE,
71 ),
72 );
73 }
74
78 function simpletest_theme() {
79 return array(
80 'simpletest_test_table' => array(
81 'render element' => 'table',
82 'file' => 'simpletest.pages.inc',
83 ),
84 'simpletest_result_summary' => array(
85 'render element' => 'form',
86 'file' => 'simpletest.pages.inc',
87 ),
88 );
89 }
90
94 function simpletest_js_alter(&$javascript) {
95 // Since SimpleTest is a special use case for the table select, stick the
96 // SimpleTest JavaScript above the table select.
97 $simpletest = drupal_get_path('module', 'simpletest') . '/simpletest.js';
98 if (array_key_exists($simpletest, $javascript) && array_key_exists('misc/tableselect.js', $javascript)) {
99 $javascript[$simpletest]['weight'] = $javascript['misc/tableselect.js']['weight'] - 1;
100 }
101 }
102
103 function _simpletest_format_summary_line($summary) {
104 $args = array(
105 '@pass' => format_plural(isset($summary['#pass']) ? $summary['#pass'] : 0, '1 pass', '@count passes'),
106 '@fail' => format_plural(isset($summary['#fail']) ? $summary['#fail'] : 0, '1 fail', '@count fails'),
107 '@exception' => format_plural(isset($summary['#exception']) ? $summary['#exception'] : 0, '1 exception', '@count exceptions'),
108 );
109 if (!$summary['#debug']) {
110 return t('@pass, @fail, and @exception', $args);
111 }
112 $args['@debug'] = format_plural(isset($summary['#debug']) ? $summary['#debug'] : 0, '1 debug message', '@count debug messages');
113 return t('@pass, @fail, @exception, and @debug', $args);
114 }
115
125 function simpletest_run_tests($test_list, $reporter = 'drupal') {
126 $test_id = db_insert('simpletest_test_id')
127 ->useDefaults(array('test_id'))
128 ->execute();
129
130 // Clear out the previous verbose files.
131 file_unmanaged_delete_recursive('public://simpletest/verbose');
132
133 // Get the info for the first test being run.
134 $first_test = array_shift($test_list);
135 $first_instance = new $first_test();
136 array_unshift($test_list, $first_test);
137 $info = $first_instance->getInfo();
138
139 $batch = array(
140 'title' => t('Running tests'),
141 'operations' => array(
142 array('_simpletest_batch_operation', array($test_list, $test_id)),
143 ),
144 'finished' => '_simpletest_batch_finished',
145 'progress_message' => '',
146 'css' => array(drupal_get_path('module', 'simpletest') . '/simpletest.css'),
147 'init_message' => t('Processing test @num of @max - %test.', array('%test' => $info['name'], '@num' => '1', '@max' => count($test_list))),
148 );
149 batch_set($batch);
150
151 module_invoke_all('test_group_started');
152
153 return $test_id;
154 }
155
159 function _simpletest_batch_operation($test_list_init, $test_id, &$context) {
160 simpletest_classloader_register();
161 // Get working values.
162 if (!isset($context['sandbox']['max'])) {
163 // First iteration: initialize working values.
164 $test_list = $test_list_init;
165 $context['sandbox']['max'] = count($test_list);
166 $test_results = array('#pass' => 0, '#fail' => 0, '#exception' => 0, '#debug' => 0);
167 }
168 else {
169 // Nth iteration: get the current values where we last stored them.
170 $test_list = $context['sandbox']['tests'];
171 $test_results = $context['sandbox']['test_results'];
172 }
173 $max = $context['sandbox']['max'];
174
175 // Perform the next test.
176 $test_class = array_shift($test_list);
177 $test = new $test_class($test_id);
178 $test->run();
179 $size = count($test_list);
180 $info = $test->getInfo();
181
182 module_invoke_all('test_finished', $test->results);
183
184 // Gather results and compose the report.
185 $test_results[$test_class] = $test->results;
186 foreach ($test_results[$test_class] as $key => $value) {
187 $test_results[$key] += $value;
188 }
189 $test_results[$test_class]['#name'] = $info['name'];
190 $items = array();
191 foreach (element_children($test_results) as $class) {
192 array_unshift($items, '<div class="simpletest-' . ($test_results[$class]['#fail'] + $test_results[$class]['#exception'] ? 'fail' : 'pass') . '">' . t('@name: @summary', array('@name' => $test_results[$class]['#name'], '@summary' => _simpletest_format_summary_line($test_results[$class]))) . '</div>');
193 }
194 $context['message'] = t('Processed test @num of @max - %test.', array('%test' => $info['name'], '@num' => $max - $size, '@max' => $max));
195 $context['message'] .= '<div class="simpletest-' . ($test_results['#fail'] + $test_results['#exception'] ? 'fail' : 'pass') . '">Overall results: ' . _simpletest_format_summary_line($test_results) . '</div>';
196 $context['message'] .= theme('item_list', array('items' => $items));
197
198 // Save working values for the next iteration.
199 $context['sandbox']['tests'] = $test_list;
200 $context['sandbox']['test_results'] = $test_results;
201 // The test_id is the only thing we need to save for the report page.
202 $context['results']['test_id'] = $test_id;
203
204 // Multistep processing: report progress.
205 $context['finished'] = 1 - $size / $max;
206 }
207
208 function _simpletest_batch_finished($success, $results, $operations, $elapsed) {
209 if ($success) {
210 drupal_set_message(t('The test run finished in @elapsed.', array('@elapsed' => $elapsed)));
211 }
212 else {
213 // Use the test_id passed as a parameter to _simpletest_batch_operation().
214 $test_id = $operations[0][1][1];
215
216 // Retrieve the last database prefix used for testing and the last test
217 // class that was run from. Use the information to read the lgo file
218 // in case any fatal errors caused the test to crash.
219 list($last_prefix, $last_test_class) = simpletest_last_test_get($test_id);
220 simpletest_log_read($test_id, $last_prefix, $last_test_class);
221
222 drupal_set_message(t('The test run did not successfully finish.'), 'error');
223 drupal_set_message(t('Use the <em>Clean environment</em> button to clean-up temporary files and tables.'), 'warning');
224 }
225 module_invoke_all('test_group_finished');
226 }
227
237 function simpletest_last_test_get($test_id) {
238 $last_prefix = db_query_range('SELECT last_prefix FROM {simpletest_test_id} WHERE test_id = :test_id', 0, 1, array(':test_id' => $test_id))->fetchField();
239 $last_test_class = db_query_range('SELECT test_class FROM {simpletest} WHERE test_id = :test_id ORDER BY message_id DESC', 0, 1, array(':test_id' => $test_id))->fetchField();
240 return array($last_prefix, $last_test_class);
241 }
242
261 function simpletest_log_read($test_id, $prefix, $test_class, $during_test = FALSE) {
262 $log = 'public://' . ($during_test ? '' : '/simpletest/' . substr($prefix, 10)) . '/error.log';
263 $found = FALSE;
264 if (file_exists($log)) {
265 foreach (file($log) as $line) {
266 if (preg_match('/\[.*?\] (.*?): (.*?) in (.*) on line (\d+)/', $line, $match)) {
267 // Parse PHP fatal errors for example: PHP Fatal error: Call to
268 // undefined function break_me() in /path/to/file.php on line 17
269 $caller = array(
270 'line' => $match[4],
271 'file' => $match[3],
272 );
273 DrupalTestCase::insertAssert($test_id, $test_class, FALSE, $match[2], $match[1], $caller);
274 }
275 else {
276 // Unknown format, place the entire message in the log.
277 DrupalTestCase::insertAssert($test_id, $test_class, FALSE, $line, 'Fatal error');
278 }
279 $found = TRUE;
280 }
281 }
282 return $found;
283 }
284
312 function simpletest_test_get_all() {
313 $groups = &drupal_static(__FUNCTION__);
314
315 if (!$groups) {
316 // Register a simple class loader for PSR-0 test classes.
317 simpletest_classloader_register();
318
319 // Load test information from cache if available, otherwise retrieve the
320 // information from each tests getInfo() method.
321 if ($cache = cache_get('simpletest', 'cache')) {
322 $groups = $cache->data;
323 }
324 else {
325 // Select all clases in files ending with .test.
326 $classes = db_query("SELECT name FROM {registry} WHERE type = :type AND filename LIKE :name", array(':type' => 'class', ':name' => '%.test'))->fetchCol();
327
328 // Also discover PSR-0 test classes, if the PHP version allows it.
329 if (version_compare(PHP_VERSION, '5.3') > 0) {
330
331 // Select all PSR-0 classes in the Tests namespace of all modules.
332 $system_list = db_query("SELECT name, filename FROM {system}")->fetchAllKeyed();
333
334 foreach ($system_list as $name => $filename) {
335 // Build directory in which the test files would reside.
336 $tests_dir = DRUPAL_ROOT . '/' . dirname($filename) . '/lib/Drupal/' . $name . '/Tests';
337 // Scan it for test files if it exists.
338 if (is_dir($tests_dir)) {
339 $files = file_scan_directory($tests_dir, '/.*\.php/');
340 if (!empty($files)) {
341 $basedir = DRUPAL_ROOT . '/' . dirname($filename) . '/lib/';
342 foreach ($files as $file) {
343 // Convert the file name into the namespaced class name.
344 $replacements = array(
345 '/' => '\\',
346 $basedir => '',
347 '.php' => '',
348 );
349 $classes[] = strtr($file->uri, $replacements);
350 }
351 }
352 }
353 }
354 }
355
356 // Check that each class has a getInfo() method and store the information
357 // in an array keyed with the group specified in the test information.
358 $groups = array();
359 foreach ($classes as $class) {
360 // Test classes need to implement getInfo() to be valid.
361 if (class_exists($class) && method_exists($class, 'getInfo')) {
362 $info = call_user_func(array($class, 'getInfo'));
363
364 // If this test class requires a non-existing module, skip it.
365 if (!empty($info['dependencies'])) {
366 foreach ($info['dependencies'] as $module) {
367 if (!drupal_get_filename('module', $module)) {
368 continue 2;
369 }
370 }
371 }
372
373 $groups[$info['group']][$class] = $info;
374 }
375 }
376
377 // Sort the groups and tests within the groups by name.
378 uksort($groups, 'strnatcasecmp');
379 foreach ($groups as $group => &$tests) {
380 uksort($tests, 'strnatcasecmp');
381 }
382
383 // Allow modules extending core tests to disable originals.
384 drupal_alter('simpletest', $groups);
385 cache_set('simpletest', $groups);
386 }
387 }
388 return $groups;
389 }
390
391 /*
392 * Register a simple class loader that can find D8-style PSR-0 test classes.
393 *
394 * Other PSR-0 class loading can happen in contrib, but those contrib class
395 * loader modules will not be enabled when testbot runs. So we need to do this
396 * one in core.
397 */
398 function simpletest_classloader_register() {
399
400 // Prevent duplicate classloader registration.
401 static $first_run = TRUE;
402 if (!$first_run) {
403 return;
404 }
405 $first_run = FALSE;
406
407 // Only register PSR-0 class loading if we are on PHP 5.3 or higher.
408 if (version_compare(PHP_VERSION, '5.3') > 0) {
409 spl_autoload_register('_simpletest_autoload_psr0');
410 }
411 }
412
419 function _simpletest_autoload_psr0($class) {
420
421 // Static cache for extension paths.
422 // This cache is lazily filled as soon as it is needed.
423 static $extensions;
424
425 // Check that the first namespace fragment is "Drupal\"
426 if (substr($class, 0, 7) === 'Drupal\\') {
427 // Find the position of the second namespace separator.
428 $pos = strpos($class, '\\', 7);
429 // Check that the third namespace fragment is "\Tests\".
430 if (substr($class, $pos, 7) === '\\Tests\\') {
431
432 // Extract the second namespace fragment, which we expect to be the
433 // extension name.
434 $extension = substr($class, 7, $pos - 7);
435
436 // Lazy-load the extension paths, both enabled and disabled.
437 if (!isset($extensions)) {
438 $extensions = db_query("SELECT name, filename FROM {system}")->fetchAllKeyed();
439 }
440
441 // Check if the second namespace fragment is a known extension name.
442 if (isset($extensions[$extension])) {
443
444 // Split the class into namespace and classname.
445 $nspos = strrpos($class, '\\');
446 $namespace = substr($class, 0, $nspos);
447 $classname = substr($class, $nspos + 1);
448
449 // Build the filepath where we expect the class to be defined.
450 $path = dirname($extensions[$extension]) . '/lib/' .
451 str_replace('\\', '/', $namespace) . '/' .
452 str_replace('_', '/', $classname) . '.php';
453
454 // Include the file, if it does exist.
455 if (file_exists($path)) {
456 include $path;
457 }
458 }
459 }
460 }
461 }
462
469 function simpletest_registry_files_alter(&$files, $modules) {
470 foreach ($modules as $module) {
471 // Only add test files for disabled modules, as enabled modules should
472 // already include any test files they provide.
473 if (!$module->status) {
474 $dir = $module->dir;
475 if (!empty($module->info['files'])) {
476 foreach ($module->info['files'] as $file) {
477 if (substr($file, -5) == '.test') {
478 $files["$dir/$file"] = array('module' => $module->name, 'weight' => $module->weight);
479 }
480 }
481 }
482 }
483 }
484 }
485
489 function simpletest_generate_file($filename, $width, $lines, $type = 'binary-text') {
490 $size = $width * $lines - $lines;
491
492 // Generate random text
493 $text = '';
494 for ($i = 0; $i < $size; $i++) {
495 switch ($type) {
496 case 'text':
497 $text .= chr(rand(32, 126));
498 break;
499 case 'binary':
500 $text .= chr(rand(0, 31));
501 break;
502 case 'binary-text':
503 default:
504 $text .= rand(0, 1);
505 break;
506 }
507 }
508 $text = wordwrap($text, $width - 1, "\n", TRUE) . "\n"; // Add \n for symmetrical file.
509
510 // Create filename.
511 file_put_contents('public://' . $filename . '.txt', $text);
512 return $filename;
513 }
514
518 function simpletest_clean_environment() {
519 simpletest_clean_database();
520 simpletest_clean_temporary_directories();
521 if (variable_get('simpletest_clear_results', TRUE)) {
522 $count = simpletest_clean_results_table();
523 drupal_set_message(format_plural($count, 'Removed 1 test result.', 'Removed @count test results.'));
524 }
525 else {
526 drupal_set_message(t('Clear results is disabled and the test results table will not be cleared.'), 'warning');
527 }
528
529 // Detect test classes that have been added, renamed or deleted.
530 registry_rebuild();
531 cache_clear_all('simpletest', 'cache');
532 }
533
537 function simpletest_clean_database() {
538 $tables = db_find_tables(Database::getConnection()->prefixTables('{simpletest}') . '%');
539 $schema = drupal_get_schema_unprocessed('simpletest');
540 $count = 0;
541 foreach (array_diff_key($tables, $schema) as $table) {
542 // Strip the prefix and skip tables without digits following "simpletest",
543 // e.g. {simpletest_test_id}.
544 if (preg_match('/simpletest\d+.*/', $table, $matches)) {
545 db_drop_table($matches[0]);
546 $count++;
547 }
548 }
549
550 if ($count > 0) {
551 drupal_set_message(format_plural($count, 'Removed 1 leftover table.', 'Removed @count leftover tables.'));
552 }
553 else {
554 drupal_set_message(t('No leftover tables to remove.'));
555 }
556 }
557
561 function simpletest_clean_temporary_directories() {
562 $count = 0;
563 if (is_dir('public://simpletest')) {
564 $files = scandir('public://simpletest');
565 foreach ($files as $file) {
566 $path = 'public://simpletest/' . $file;
567 if (is_dir($path) && is_numeric($file)) {
568 file_unmanaged_delete_recursive($path);
569 $count++;
570 }
571 }
572 }
573
574 if ($count > 0) {
575 drupal_set_message(format_plural($count, 'Removed 1 temporary directory.', 'Removed @count temporary directories.'));
576 }
577 else {
578 drupal_set_message(t('No temporary directories to remove.'));
579 }
580 }
581
590 function simpletest_clean_results_table($test_id = NULL) {
591 if (variable_get('simpletest_clear_results', TRUE)) {
592 if ($test_id) {
593 $count = db_query('SELECT COUNT(test_id) FROM {simpletest_test_id} WHERE test_id = :test_id', array(':test_id' => $test_id))->fetchField();
594
595 db_delete('simpletest')
596 ->condition('test_id', $test_id)
597 ->execute();
598 db_delete('simpletest_test_id')
599 ->condition('test_id', $test_id)
600 ->execute();
601 }
602 else {
603 $count = db_query('SELECT COUNT(test_id) FROM {simpletest_test_id}')->fetchField();
604
605 // Clear test results.
606 db_delete('simpletest')->execute();
607 db_delete('simpletest_test_id')->execute();
608 }
609
610 return $count;
611 }
612 return 0;
613 }
614
622 function simpletest_mail_alter(&$message) {
623 if ($message['id'] == 'simpletest_cancel_test') {
624 $message['send'] = FALSE;
625 }
626 }
simpletest_js_alter
simpletest_js_alter(&$javascript)
Definition: simpletest.module:94
_simpletest_batch_operation
_simpletest_batch_operation($test_list_init, $test_id, &$context)
Definition: simpletest.module:159
_simpletest_autoload_psr0
_simpletest_autoload_psr0($class)
Definition: simpletest.module:419
registry_rebuild
registry_rebuild()
Definition: bootstrap.inc:3175
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
simpletest_mail_alter
simpletest_mail_alter(&$message)
Definition: simpletest.module:622
simpletest_run_tests
simpletest_run_tests($test_list, $reporter= 'drupal')
Definition: simpletest.module:125
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
file_scan_directory
file_scan_directory($dir, $mask, $options=array(), $depth=0)
Definition: file.inc:2058
Database\getConnection
static getConnection($target= 'default', $key=NULL)
Definition: database.inc:1460
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
$module
print $module
Definition: search-results.tpl.php:28
file_unmanaged_delete_recursive
file_unmanaged_delete_recursive($path)
Definition: file.inc:1358
db_find_tables
db_find_tables($table_expression)
Definition: database.inc:2789
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
$results
print $results
Definition: poll-results.tpl.php:23
simpletest_clean_database
simpletest_clean_database()
Definition: simpletest.module:537
simpletest_help
simpletest_help($path, $arg)
Definition: simpletest.module:11
simpletest_permission
simpletest_permission()
Definition: simpletest.module:66
drupal_get_schema_unprocessed
drupal_get_schema_unprocessed($module, $table=NULL)
Definition: common.inc:6998
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
batch_set
batch_set($batch_definition)
Definition: form.inc:4381
$info
$info
Definition: color.inc:6
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
simpletest_registry_files_alter
simpletest_registry_files_alter(&$files, $modules)
Definition: simpletest.module:469
simpletest_menu
simpletest_menu()
Definition: simpletest.module:30
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$output
$output
Definition: authorize.php:93
simpletest_last_test_get
simpletest_last_test_get($test_id)
Definition: simpletest.module:237
simpletest_test_get_all
simpletest_test_get_all()
Definition: simpletest.module:312
DrupalTestCase\insertAssert
static insertAssert($test_id, $test_class, $status, $message= '', $group= 'Other', array $caller=array())
Definition: drupal_web_test_case.php:185
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
simpletest_classloader_register
simpletest_classloader_register()
Definition: simpletest.module:398
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
$classes
print $classes
Definition: contextual-links-example-object.tpl.php:31
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
simpletest_clean_temporary_directories
simpletest_clean_temporary_directories()
Definition: simpletest.module:561
$dir
print $dir
Definition: book-export-html.tpl.php:22
simpletest_generate_file
simpletest_generate_file($filename, $width, $lines, $type= 'binary-text')
Definition: simpletest.module:489
simpletest_clean_results_table
simpletest_clean_results_table($test_id=NULL)
Definition: simpletest.module:590
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
_simpletest_format_summary_line
_simpletest_format_summary_line($summary)
Definition: simpletest.module:103
simpletest_clean_environment
simpletest_clean_environment()
Definition: simpletest.module:518
simpletest_theme
simpletest_theme()
Definition: simpletest.module:78
drupal_get_filename
drupal_get_filename($type, $name, $filename=NULL)
Definition: bootstrap.inc:820
_simpletest_batch_finished
_simpletest_batch_finished($success, $results, $operations, $elapsed)
Definition: simpletest.module:208
simpletest_log_read
simpletest_log_read($test_id, $prefix, $test_class, $during_test=FALSE)
Definition: simpletest.module:261
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment.install Source File

  • modules
  • comment
comment.install
Go to the documentation of this file.
1 <?php
2
11 function comment_uninstall() {
12 // Delete comment_body field.
13 field_delete_field('comment_body');
14
15 // Remove variables.
16 variable_del('comment_block_count');
17 $node_types = array_keys(node_type_get_types());
18 foreach ($node_types as $node_type) {
19 field_attach_delete_bundle('comment', 'comment_node_' . $node_type);
20 variable_del('comment_' . $node_type);
21 variable_del('comment_anonymous_' . $node_type);
22 variable_del('comment_controls_' . $node_type);
23 variable_del('comment_default_mode_' . $node_type);
24 variable_del('comment_default_order_' . $node_type);
25 variable_del('comment_default_per_page_' . $node_type);
26 variable_del('comment_form_location_' . $node_type);
27 variable_del('comment_preview_' . $node_type);
28 variable_del('comment_subject_field_' . $node_type);
29 }
30 }
31
35 function comment_enable() {
36 // Insert records into the node_comment_statistics for nodes that are missing.
37 $query = db_select('node', 'n');
38 $query->leftJoin('node_comment_statistics', 'ncs', 'ncs.nid = n.nid');
39 $query->addField('n', 'created', 'last_comment_timestamp');
40 $query->addField('n', 'uid', 'last_comment_uid');
41 $query->addField('n', 'nid');
42 $query->addExpression('0', 'comment_count');
43 $query->addExpression('NULL', 'last_comment_name');
44 $query->isNull('ncs.comment_count');
45
46 db_insert('node_comment_statistics')
47 ->from($query)
48 ->execute();
49 }
50
67 function comment_modules_enabled($modules) {
68 // Only react if comment module is one of the modules being enabled.
69 // hook_node_type_insert() is used to create body fields while the comment
70 // module is enabled.
71 if (in_array('comment', $modules)) {
72 // Ensure that the list of node types reflects newly enabled modules.
73 node_types_rebuild();
74
75 // Create comment body fields for each node type, if needed.
76 foreach (node_type_get_types() as $type => $info) {
77 _comment_body_field_create($info);
78 }
79 }
80 }
81
85 function comment_update_dependencies() {
86 // comment_update_7005() creates the comment body field and therefore must
87 // run after all Field modules have been enabled, which happens in
88 // system_update_7027().
89 $dependencies['comment'][7005] = array(
90 'system' => 7027,
91 );
92
93 // comment_update_7006() needs to query the {filter_format} table to get a
94 // list of existing text formats, so it must run after filter_update_7000(),
95 // which creates that table.
96 $dependencies['comment'][7006] = array(
97 'filter' => 7000,
98 );
99
100 return $dependencies;
101 }
102
111 function comment_update_7000() {
112 $types = _update_7000_node_get_types();
113 foreach ($types as $type => $type_object) {
114 variable_del('comment_default_order' . $type);
115
116 // Drupal 6 had four display modes:
117 // - COMMENT_MODE_FLAT_COLLAPSED = 1
118 // - COMMENT_MODE_FLAT_EXPANDED = 2
119 // - COMMENT_MODE_THREADED_COLLAPSED = 3
120 // - COMMENT_MODE_THREADED_EXPANDED = 4
121 //
122 // Drupal 7 doesn't support collapsed/expanded modes anymore, so we
123 // migrate all the flat modes to COMMENT_MODE_FLAT (0) and all the threaded
124 // modes to COMMENT_MODE_THREADED (1).
125 $setting = variable_get('comment_default_mode_' . $type, 4);
126 if ($setting == 3 || $setting == 4) {
127 variable_set('comment_default_mode_' . $type, 1);
128 }
129 else {
130 variable_set('comment_default_mode_' . $type, 0);
131 }
132
133 // There were only two comment modes in the past:
134 // - 1 was 'required' previously, convert into DRUPAL_REQUIRED (2).
135 // - 0 was 'optional' previously, convert into DRUPAL_OPTIONAL (1).
136 $preview = variable_get('comment_preview_' . $type, 1) ? 2 : 1;
137 variable_set('comment_preview_' . $type, $preview);
138 }
139 }
140
144 function comment_update_7001() {
145 // Choose a temporary status value different from the existing status values.
146 $tmp_status = db_query('SELECT MAX(status) FROM {comments}')->fetchField() + 1;
147
148 $changes = array(
149 0 => $tmp_status,
150 1 => 0,
151 $tmp_status => 1,
152 );
153
154 foreach ($changes as $old => $new) {
155 db_update('comments')
156 ->fields(array('status' => $new))
157 ->condition('status', $old)
158 ->execute();
159 }
160 }
161
165 function comment_update_7002() {
166 db_rename_table('comments', 'comment');
167
168 // Add user-related indexes. These may already exist from Drupal 6.
169 if (!db_index_exists('comment', 'comment_uid')) {
170 db_add_index('comment', 'comment_uid', array('uid'));
171 db_add_index('node_comment_statistics', 'last_comment_uid', array('last_comment_uid'));
172 }
173
174 // Create a language column.
175 db_add_field('comment', 'language', array(
176 'type' => 'varchar',
177 'length' => 12,
178 'not null' => TRUE,
179 'default' => '',
180 ));
181 db_add_index('comment', 'comment_nid_language', array('nid', 'language'));
182 }
183
187 function comment_update_7003() {
188 // Drop the old indexes.
189 db_drop_index('comment', 'status');
190 db_drop_index('comment', 'pid');
191
192 // Create a created column.
193 db_add_field('comment', 'created', array(
194 'type' => 'int',
195 'not null' => TRUE,
196 'default' => 0,
197 ));
198
199 // Rename the timestamp column to changed.
200 db_change_field('comment', 'timestamp', 'changed', array(
201 'type' => 'int',
202 'not null' => TRUE,
203 'default' => 0,
204 ));
205
206 // Migrate the data.
207 // @todo db_update() should support this.
208 db_query('UPDATE {comment} SET created = changed');
209
210 // Recreate the indexes.
211 // The 'comment_num_new' index is optimized for comment_num_new()
212 // and comment_new_page_count().
213 db_add_index('comment', 'comment_num_new', array('nid', 'status', 'created', 'cid', 'thread'));
214 db_add_index('comment', 'comment_pid_status', array('pid', 'status'));
215 }
216
220 function comment_update_7004() {
221 db_add_field('node_comment_statistics', 'cid', array(
222 'type' => 'int',
223 'not null' => TRUE,
224 'default' => 0,
225 'description' => 'The {comment}.cid of the last comment.',
226 ));
227 db_add_index('node_comment_statistics', 'cid', array('cid'));
228
229 // The comment_count index may have been added in Drupal 6.
230 if (!db_index_exists('node_comment_statistics', 'comment_count')) {
231 // Add an index on the comment_count.
232 db_add_index('node_comment_statistics', 'comment_count', array('comment_count'));
233 }
234 }
235
239 function comment_update_7005() {
240 // Create comment body field.
241 $field = array(
242 'field_name' => 'comment_body',
243 'type' => 'text_long',
244 'module' => 'text',
245 'entity_types' => array(
246 'comment',
247 ),
248 'settings' => array(),
249 'cardinality' => 1,
250 );
251 _update_7000_field_create_field($field);
252
253 // Add the field to comments for all existing bundles.
254 $generic_instance = array(
255 'entity_type' => 'comment',
256 'label' => t('Comment'),
257 'settings' => array(
258 'text_processing' => 1,
259 ),
260 'required' => TRUE,
261 'display' => array(
262 'default' => array(
263 'label' => 'hidden',
264 'type' => 'text_default',
265 'weight' => 0,
266 'settings' => array(),
267 'module' => 'text',
268 ),
269 ),
270 'widget' => array(
271 'type' => 'text_textarea',
272 'settings' => array(
273 'rows' => 5,
274 ),
275 'weight' => 0,
276 'module' => 'text',
277 ),
278 'description' => '',
279 );
280
281 $types = _update_7000_node_get_types();
282 foreach ($types as $type => $type_object) {
283 $instance = $generic_instance;
284 $instance['bundle'] = 'comment_node_' . $type;
285 _update_7000_field_create_instance($field, $instance);
286 }
287 }
288
292 function comment_update_7006(&$sandbox) {
293 // This is a multipass update. First set up some comment variables.
294 if (empty($sandbox['total'])) {
295 $comments = (bool) db_query_range('SELECT 1 FROM {comment}', 0, 1)->fetchField();
296 $sandbox['types'] = array();
297 if ($comments) {
298 $sandbox['types'] = array_keys(_update_7000_node_get_types());
299 }
300 $sandbox['total'] = count($sandbox['types']);
301 }
302
303 if (!empty($sandbox['types'])) {
304 $type = array_shift($sandbox['types']);
305
306 $query = db_select('comment', 'c');
307 $query->innerJoin('node', 'n', 'c.nid = n.nid AND n.type = :type', array(':type' => $type));
308 $query->addField('c', 'cid', 'entity_id');
309 $query->addExpression("'comment_node_$type'", 'bundle');
310 $query->addExpression("'comment'", 'entity_type');
311 $query->addExpression('0', 'deleted');
312 $query->addExpression("'" . LANGUAGE_NONE . "'", 'language');
313 $query->addExpression('0', 'delta');
314 $query->addField('c', 'comment', 'comment_body_value');
315 $query->addField('c', 'format', 'comment_body_format');
316
317 db_insert('field_data_comment_body')
318 ->from($query)
319 ->execute();
320
321 $sandbox['#finished'] = 1 - count($sandbox['types']) / $sandbox['total'];
322 }
323
324 // On the last pass of the update, $sandbox['types'] will be empty.
325 if (empty($sandbox['types'])) {
326 // Update the comment body text formats. For an explanation of these
327 // updates, see the code comments in user_update_7010().
328 db_update('field_data_comment_body')
329 ->fields(array('comment_body_format' => NULL))
330 ->condition('comment_body_value', '')
331 ->condition('comment_body_format', 0)
332 ->execute();
333 $existing_formats = db_query("SELECT format FROM {filter_format}")->fetchCol();
334 $default_format = variable_get('filter_default_format', 1);
335 db_update('field_data_comment_body')
336 ->fields(array('comment_body_format' => $default_format))
337 ->isNotNull('comment_body_format')
338 ->condition('comment_body_format', $existing_formats, 'NOT IN')
339 ->execute();
340
341 // Finally, remove the old comment data.
342 db_drop_field('comment', 'comment');
343 db_drop_field('comment', 'format');
344 }
345 }
346
359 function comment_update_7007() {
360 db_add_index('comment', 'comment_created', array('created'));
361 }
362
366 function comment_update_7008() {
367 // Update default status to 1.
368 db_change_field('comment', 'status', 'status', array(
369 'type' => 'int',
370 'unsigned' => TRUE,
371 'not null' => TRUE,
372 'default' => 1,
373 'size' => 'tiny',
374 ));
375
376 // Realign indexes.
377 db_drop_index('comment', 'comment_status_pid');
378 db_add_index('comment', 'comment_status_pid', array('pid', 'status'));
379 db_drop_index('comment', 'comment_pid_status');
380 db_drop_index('comment', 'nid');
381 }
382
386 function comment_update_7009() {
387 db_change_field('node_comment_statistics', 'last_comment_timestamp', 'last_comment_timestamp', array(
388 'type' => 'int',
389 'not null' => TRUE,
390 'default' => 0,
391 'description' => 'The Unix timestamp of the last comment that was posted within this node, from {comment}.changed.',
392 ));
393 }
394
402 function comment_schema() {
403 $schema['comment'] = array(
404 'description' => 'Stores comments and associated data.',
405 'fields' => array(
406 'cid' => array(
407 'type' => 'serial',
408 'not null' => TRUE,
409 'description' => 'Primary Key: Unique comment ID.',
410 ),
411 'pid' => array(
412 'type' => 'int',
413 'not null' => TRUE,
414 'default' => 0,
415 'description' => 'The {comment}.cid to which this comment is a reply. If set to 0, this comment is not a reply to an existing comment.',
416 ),
417 'nid' => array(
418 'type' => 'int',
419 'not null' => TRUE,
420 'default' => 0,
421 'description' => 'The {node}.nid to which this comment is a reply.',
422 ),
423 'uid' => array(
424 'type' => 'int',
425 'not null' => TRUE,
426 'default' => 0,
427 'description' => 'The {users}.uid who authored the comment. If set to 0, this comment was created by an anonymous user.',
428 ),
429 'subject' => array(
430 'type' => 'varchar',
431 'length' => 64,
432 'not null' => TRUE,
433 'default' => '',
434 'description' => 'The comment title.',
435 ),
436 'hostname' => array(
437 'type' => 'varchar',
438 'length' => 128,
439 'not null' => TRUE,
440 'default' => '',
441 'description' => "The author's host name.",
442 ),
443 'created' => array(
444 'type' => 'int',
445 'not null' => TRUE,
446 'default' => 0,
447 'description' => 'The time that the comment was created, as a Unix timestamp.',
448 ),
449 'changed' => array(
450 'type' => 'int',
451 'not null' => TRUE,
452 'default' => 0,
453 'description' => 'The time that the comment was last edited, as a Unix timestamp.',
454 ),
455 'status' => array(
456 'type' => 'int',
457 'unsigned' => TRUE,
458 'not null' => TRUE,
459 'default' => 1,
460 'size' => 'tiny',
461 'description' => 'The published status of a comment. (0 = Not Published, 1 = Published)',
462 ),
463 'thread' => array(
464 'type' => 'varchar',
465 'length' => 255,
466 'not null' => TRUE,
467 'description' => "The vancode representation of the comment's place in a thread.",
468 ),
469 'name' => array(
470 'type' => 'varchar',
471 'length' => 60,
472 'not null' => FALSE,
473 'description' => "The comment author's name. Uses {users}.name if the user is logged in, otherwise uses the value typed into the comment form.",
474 ),
475 'mail' => array(
476 'type' => 'varchar',
477 'length' => 64,
478 'not null' => FALSE,
479 'description' => "The comment author's e-mail address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on.",
480 ),
481 'homepage' => array(
482 'type' => 'varchar',
483 'length' => 255,
484 'not null' => FALSE,
485 'description' => "The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on.",
486 ),
487 'language' => array(
488 'description' => 'The {languages}.language of this comment.',
489 'type' => 'varchar',
490 'length' => 12,
491 'not null' => TRUE,
492 'default' => '',
493 ),
494 ),
495 'indexes' => array(
496 'comment_status_pid' => array('pid', 'status'),
497 'comment_num_new' => array('nid', 'status', 'created', 'cid', 'thread'),
498 'comment_uid' => array('uid'),
499 'comment_nid_language' => array('nid', 'language'),
500 'comment_created' => array('created'),
501 ),
502 'primary key' => array('cid'),
503 'foreign keys' => array(
504 'comment_node' => array(
505 'table' => 'node',
506 'columns' => array('nid' => 'nid'),
507 ),
508 'comment_author' => array(
509 'table' => 'users',
510 'columns' => array('uid' => 'uid'),
511 ),
512 ),
513 );
514
515 $schema['node_comment_statistics'] = array(
516 'description' => 'Maintains statistics of node and comments posts to show "new" and "updated" flags.',
517 'fields' => array(
518 'nid' => array(
519 'type' => 'int',
520 'unsigned' => TRUE,
521 'not null' => TRUE,
522 'default' => 0,
523 'description' => 'The {node}.nid for which the statistics are compiled.',
524 ),
525 'cid' => array(
526 'type' => 'int',
527 'not null' => TRUE,
528 'default' => 0,
529 'description' => 'The {comment}.cid of the last comment.',
530 ),
531 'last_comment_timestamp' => array(
532 'type' => 'int',
533 'not null' => TRUE,
534 'default' => 0,
535 'description' => 'The Unix timestamp of the last comment that was posted within this node, from {comment}.changed.',
536 ),
537 'last_comment_name' => array(
538 'type' => 'varchar',
539 'length' => 60,
540 'not null' => FALSE,
541 'description' => 'The name of the latest author to post a comment on this node, from {comment}.name.',
542 ),
543 'last_comment_uid' => array(
544 'type' => 'int',
545 'not null' => TRUE,
546 'default' => 0,
547 'description' => 'The user ID of the latest author to post a comment on this node, from {comment}.uid.',
548 ),
549 'comment_count' => array(
550 'type' => 'int',
551 'unsigned' => TRUE,
552 'not null' => TRUE,
553 'default' => 0,
554 'description' => 'The total number of comments on this node.',
555 ),
556 ),
557 'primary key' => array('nid'),
558 'indexes' => array(
559 'node_comment_timestamp' => array('last_comment_timestamp'),
560 'comment_count' => array('comment_count'),
561 'last_comment_uid' => array('last_comment_uid'),
562 ),
563 'foreign keys' => array(
564 'statistics_node' => array(
565 'table' => 'node',
566 'columns' => array('nid' => 'nid'),
567 ),
568 'last_comment_author' => array(
569 'table' => 'users',
570 'columns' => array(
571 'last_comment_uid' => 'uid',
572 ),
573 ),
574 ),
575 );
576
577 return $schema;
578 }
comment_uninstall
comment_uninstall()
Definition: comment.install:11
comment_update_7002
comment_update_7002()
Definition: comment.install:165
comment_update_7006
comment_update_7006(&$sandbox)
Definition: comment.install:292
comment_schema
comment_schema()
Definition: comment.install:402
db_add_index
db_add_index($table, $name, $fields)
Definition: database.inc:2940
comment_update_dependencies
comment_update_dependencies()
Definition: comment.install:85
comment_update_7009
comment_update_7009()
Definition: comment.install:386
comment_update_7007
comment_update_7007()
Definition: comment.install:359
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_drop_index
db_drop_index($table, $name)
Definition: database.inc:2952
comment_update_7005
comment_update_7005()
Definition: comment.install:239
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
db_add_field
db_add_field($table, $field, $spec, $keys_new=array())
Definition: database.inc:2840
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
db_drop_field
db_drop_field($table, $field)
Definition: database.inc:2852
node_type_get_types
node_type_get_types()
Definition: node.module:393
$info
$info
Definition: color.inc:6
node_types_rebuild
node_types_rebuild()
Definition: node.module:475
comment_modules_enabled
comment_modules_enabled($modules)
Definition: comment.install:67
_update_7000_field_create_instance
_update_7000_field_create_instance($field, &$instance)
Definition: field.install:363
comment_update_7004
comment_update_7004()
Definition: comment.install:220
comment_update_7008
comment_update_7008()
Definition: comment.install:366
comment_update_7003
comment_update_7003()
Definition: comment.install:187
db_index_exists
db_index_exists($table, $name)
Definition: database.inc:2747
field_delete_field
field_delete_field($field_name)
Definition: field.crud.inc:411
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
comment_update_7000
comment_update_7000()
Definition: comment.install:111
_comment_body_field_create
_comment_body_field_create($info)
Definition: comment.module:362
comment_enable
comment_enable()
Definition: comment.install:35
_update_7000_node_get_types
_update_7000_node_get_types()
Definition: node.install:480
field_attach_delete_bundle
field_attach_delete_bundle($entity_type, $bundle)
Definition: field.attach.inc:1394
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
_update_7000_field_create_field
_update_7000_field_create_field(&$field)
Definition: field.install:177
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
db_rename_table
db_rename_table($table, $new_name)
Definition: database.inc:2805
comment_update_7001
comment_update_7001()
Definition: comment.install:144
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.attach.inc Source File

  • modules
  • field
field.attach.inc
Go to the documentation of this file.
1 <?php
2
11 class FieldValidationException extends FieldException {
12 var $errors;
13
26 function __construct($errors) {
27 $this->errors = $errors;
28 parent::__construct(t('Field validation errors'));
29 }
30 }
31
58 define('FIELD_STORAGE_UPDATE', 'update');
59
65 define('FIELD_STORAGE_INSERT', 'insert');
66
181 function _field_invoke($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $options = array()) {
182 // Merge default options.
183 $default_options = array(
184 'default' => FALSE,
185 'deleted' => FALSE,
186 'language' => NULL,
187 );
188 $options += $default_options;
189
190 // Determine the list of instances to iterate on.
191 list(, , $bundle) = entity_extract_ids($entity_type, $entity);
192 $instances = _field_invoke_get_instances($entity_type, $bundle, $options);
193
194 // Iterate through the instances and collect results.
195 $return = array();
196 foreach ($instances as $instance) {
197 // field_info_field() is not available for deleted fields, so use
198 // field_info_field_by_id().
199 $field = field_info_field_by_id($instance['field_id']);
200 $field_name = $field['field_name'];
201 $function = $options['default'] ? 'field_default_' . $op : $field['module'] . '_field_' . $op;
202 if (function_exists($function)) {
203 // Determine the list of languages to iterate on.
204 $available_languages = field_available_languages($entity_type, $field);
205 $languages = _field_language_suggestion($available_languages, $options['language'], $field_name);
206
207 foreach ($languages as $langcode) {
208 $items = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array();
209 $result = $function($entity_type, $entity, $field, $instance, $langcode, $items, $a, $b);
210 if (isset($result)) {
211 // For hooks with array results, we merge results together.
212 // For hooks with scalar results, we collect results in an array.
213 if (is_array($result)) {
214 $return = array_merge($return, $result);
215 }
216 else {
217 $return[] = $result;
218 }
219 }
220
221 // Populate $items back in the field values, but avoid replacing missing
222 // fields with an empty array (those are not equivalent on update).
223 if ($items !== array() || isset($entity->{$field_name}[$langcode])) {
224 $entity->{$field_name}[$langcode] = $items;
225 }
226 }
227 }
228 }
229
230 return $return;
231 }
232
278 function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b = NULL, $options = array()) {
279 // Merge default options.
280 $default_options = array(
281 'default' => FALSE,
282 'deleted' => FALSE,
283 'language' => NULL,
284 );
285 $options += $default_options;
286
287 $fields = array();
288 $grouped_instances = array();
289 $grouped_entities = array();
290 $grouped_items = array();
291 $return = array();
292
293 // Go through the entities and collect the fields on which the hook should be
294 // invoked.
295 //
296 // We group fields by id, not by name, because this function can operate on
297 // deleted fields which may have non-unique names. However, entities can only
298 // contain data for a single field for each name, even if that field
299 // is deleted, so we reference field data via the
300 // $entity->$field_name property.
301 foreach ($entities as $entity) {
302 // Determine the list of instances to iterate on.
303 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
304 $instances = _field_invoke_get_instances($entity_type, $bundle, $options);
305
306 foreach ($instances as $instance) {
307 $field_id = $instance['field_id'];
308 $field_name = $instance['field_name'];
309 $field = field_info_field_by_id($field_id);
310 $function = $options['default'] ? 'field_default_' . $op : $field['module'] . '_field_' . $op;
311 if (function_exists($function)) {
312 // Add the field to the list of fields to invoke the hook on.
313 if (!isset($fields[$field_id])) {
314 $fields[$field_id] = $field;
315 }
316 // Extract the field values into a separate variable, easily accessed
317 // by hook implementations.
318 // Unless a language suggestion is provided we iterate on all the
319 // available languages.
320 $available_languages = field_available_languages($entity_type, $field);
321 $language = !empty($options['language'][$id]) ? $options['language'][$id] : $options['language'];
322 $languages = _field_language_suggestion($available_languages, $language, $field_name);
323 foreach ($languages as $langcode) {
324 $grouped_items[$field_id][$langcode][$id] = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array();
325 // Group the instances and entities corresponding to the current
326 // field.
327 $grouped_instances[$field_id][$langcode][$id] = $instance;
328 $grouped_entities[$field_id][$langcode][$id] = $entities[$id];
329 }
330 }
331 }
332 // Initialize the return value for each entity.
333 $return[$id] = array();
334 }
335
336 // For each field, invoke the field hook and collect results.
337 foreach ($fields as $field_id => $field) {
338 $field_name = $field['field_name'];
339 $function = $options['default'] ? 'field_default_' . $op : $field['module'] . '_field_' . $op;
340 // Iterate over all the field translations.
341 foreach ($grouped_items[$field_id] as $langcode => &$items) {
342 $entities = $grouped_entities[$field_id][$langcode];
343 $instances = $grouped_instances[$field_id][$langcode];
344 $results = $function($entity_type, $entities, $field, $instances, $langcode, $items, $a, $b);
345 if (isset($results)) {
346 // Collect results by entity.
347 // For hooks with array results, we merge results together.
348 // For hooks with scalar results, we collect results in an array.
349 foreach ($results as $id => $result) {
350 if (is_array($result)) {
351 $return[$id] = array_merge($return[$id], $result);
352 }
353 else {
354 $return[$id][] = $result;
355 }
356 }
357 }
358 }
359
360 // Populate field values back in the entities, but avoid replacing missing
361 // fields with an empty array (those are not equivalent on update).
362 foreach ($grouped_entities[$field_id] as $langcode => $entities) {
363 foreach ($entities as $id => $entity) {
364 if ($grouped_items[$field_id][$langcode][$id] !== array() || isset($entity->{$field_name}[$langcode])) {
365 $entity->{$field_name}[$langcode] = $grouped_items[$field_id][$langcode][$id];
366 }
367 }
368 }
369 }
370
371 return $return;
372 }
373
383 function _field_invoke_default($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $options = array()) {
384 $options['default'] = TRUE;
385 return _field_invoke($op, $entity_type, $entity, $a, $b, $options);
386 }
387
397 function _field_invoke_multiple_default($op, $entity_type, $entities, &$a = NULL, &$b = NULL, $options = array()) {
398 $options['default'] = TRUE;
399 return _field_invoke_multiple($op, $entity_type, $entities, $a, $b, $options);
400 }
401
420 function _field_invoke_get_instances($entity_type, $bundle, $options) {
421 if ($options['deleted']) {
422 // Deleted fields are not included in field_info_instances(), and need to
423 // be fetched from the database with field_read_instances().
424 $params = array('entity_type' => $entity_type, 'bundle' => $bundle);
425 if (isset($options['field_id'])) {
426 // Single-field mode by field id: field_read_instances() does the filtering.
427 // Single-field mode by field name is not compatible with the 'deleted'
428 // option.
429 $params['field_id'] = $options['field_id'];
430 }
431 $instances = field_read_instances($params, array('include_deleted' => TRUE));
432 }
433 elseif (isset($options['field_name'])) {
434 // Single-field mode by field name: field_info_instance() does the
435 // filtering.
436 $instances = array(field_info_instance($entity_type, $options['field_name'], $bundle));
437 }
438 else {
439 $instances = field_info_instances($entity_type, $bundle);
440 if (isset($options['field_id'])) {
441 // Single-field mode by field id: we need to loop on each instance to
442 // find the right one.
443 foreach ($instances as $instance) {
444 if ($instance['field_id'] == $options['field_id']) {
445 $instances = array($instance);
446 break;
447 }
448 }
449 }
450 }
451
452 return $instances;
453 }
454
564 function field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode = NULL, $options = array()) {
565 // Validate $options since this is a new parameter added after Drupal 7 was
566 // released.
567 $options = is_array($options) ? $options : array();
568
569 // Set #parents to 'top-level' by default.
570 $form += array('#parents' => array());
571
572 // If no language is provided use the default site language.
573 $options['language'] = field_valid_language($langcode);
574 $form += (array) _field_invoke_default('form', $entity_type, $entity, $form, $form_state, $options);
575
576 // Add custom weight handling.
577 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
578 $form['#pre_render'][] = '_field_extra_fields_pre_render';
579 $form['#entity_type'] = $entity_type;
580 $form['#bundle'] = $bundle;
581
582 // Let other modules make changes to the form.
583 // Avoid module_invoke_all() to let parameters be taken by reference.
584 foreach (module_implements('field_attach_form') as $module) {
585 $function = $module . '_field_attach_form';
586 $function($entity_type, $entity, $form, $form_state, $langcode);
587 }
588 }
589
622 function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $options = array()) {
623 $load_current = $age == FIELD_LOAD_CURRENT;
624
625 // Merge default options.
626 $default_options = array(
627 'deleted' => FALSE,
628 );
629 $options += $default_options;
630
631 $info = entity_get_info($entity_type);
632 // Only the most current revision of non-deleted fields for cacheable entity
633 // types can be cached.
634 $cache_read = $load_current && $info['field cache'] && empty($options['deleted']);
635 // In addition, do not write to the cache when loading a single field.
636 $cache_write = $cache_read && !isset($options['field_id']);
637
638 if (empty($entities)) {
639 return;
640 }
641
642 // Assume all entities will need to be queried. Entities found in the cache
643 // will be removed from the list.
644 $queried_entities = $entities;
645
646 // Fetch available entities from cache, if applicable.
647 if ($cache_read) {
648 // Build the list of cache entries to retrieve.
649 $cids = array();
650 foreach ($entities as $id => $entity) {
651 $cids[] = "field:$entity_type:$id";
652 }
653 $cache = cache_get_multiple($cids, 'cache_field');
654 // Put the cached field values back into the entities and remove them from
655 // the list of entities to query.
656 foreach ($entities as $id => $entity) {
657 $cid = "field:$entity_type:$id";
658 if (isset($cache[$cid])) {
659 unset($queried_entities[$id]);
660 foreach ($cache[$cid]->data as $field_name => $values) {
661 $entity->$field_name = $values;
662 }
663 }
664 }
665 }
666
667 // Fetch other entities from their storage location.
668 if ($queried_entities) {
669 // The invoke order is:
670 // - hook_field_storage_pre_load()
671 // - storage backend's hook_field_storage_load()
672 // - field-type module's hook_field_load()
673 // - hook_field_attach_load()
674
675 // Invoke hook_field_storage_pre_load(): let any module load field
676 // data before the storage engine, accumulating along the way.
677 $skip_fields = array();
678 foreach (module_implements('field_storage_pre_load') as $module) {
679 $function = $module . '_field_storage_pre_load';
680 $function($entity_type, $queried_entities, $age, $skip_fields, $options);
681 }
682
683 $instances = array();
684
685 // Collect the storage backends used by the remaining fields in the entities.
686 $storages = array();
687 foreach ($queried_entities as $entity) {
688 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
689 $instances = _field_invoke_get_instances($entity_type, $bundle, $options);
690
691 foreach ($instances as $instance) {
692 $field_name = $instance['field_name'];
693 $field_id = $instance['field_id'];
694 // Make sure all fields are present at least as empty arrays.
695 if (!isset($queried_entities[$id]->{$field_name})) {
696 $queried_entities[$id]->{$field_name} = array();
697 }
698 // Collect the storage backend if the field has not been loaded yet.
699 if (!isset($skip_fields[$field_id])) {
700 $field = field_info_field_by_id($field_id);
701 $storages[$field['storage']['type']][$field_id][] = $load_current ? $id : $vid;
702 }
703 }
704 }
705
706 // Invoke hook_field_storage_load() on the relevant storage backends.
707 foreach ($storages as $storage => $fields) {
708 $storage_info = field_info_storage_types($storage);
709 module_invoke($storage_info['module'], 'field_storage_load', $entity_type, $queried_entities, $age, $fields, $options);
710 }
711
712 // Invoke field-type module's hook_field_load().
713 $null = NULL;
714 _field_invoke_multiple('load', $entity_type, $queried_entities, $age, $null, $options);
715
716 // Invoke hook_field_attach_load(): let other modules act on loading the
717 // entity.
718 module_invoke_all('field_attach_load', $entity_type, $queried_entities, $age, $options);
719
720 // Build cache data.
721 if ($cache_write) {
722 foreach ($queried_entities as $id => $entity) {
723 $data = array();
724 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
725 $instances = field_info_instances($entity_type, $bundle);
726 foreach ($instances as $instance) {
727 $data[$instance['field_name']] = $queried_entities[$id]->{$instance['field_name']};
728 }
729 $cid = "field:$entity_type:$id";
730 cache_set($cid, $data, 'cache_field');
731 }
732 }
733 }
734 }
735
757 function field_attach_load_revision($entity_type, $entities, $options = array()) {
758 return field_attach_load($entity_type, $entities, FIELD_LOAD_REVISION, $options);
759 }
760
781 function field_attach_validate($entity_type, $entity, $options = array()) {
782 // Validate $options since this is a new parameter added after Drupal 7 was
783 // released.
784 $options = is_array($options) ? $options : array();
785
786 $errors = array();
787 // Check generic, field-type-agnostic errors first.
788 $null = NULL;
789 _field_invoke_default('validate', $entity_type, $entity, $errors, $null, $options);
790 // Check field-type specific errors.
791 _field_invoke('validate', $entity_type, $entity, $errors, $null, $options);
792
793 // Let other modules validate the entity.
794 // Avoid module_invoke_all() to let $errors be taken by reference.
795 foreach (module_implements('field_attach_validate') as $module) {
796 $function = $module . '_field_attach_validate';
797 $function($entity_type, $entity, $errors);
798 }
799
800 if ($errors) {
801 throw new FieldValidationException($errors);
802 }
803 }
804
837 function field_attach_form_validate($entity_type, $entity, $form, &$form_state, $options = array()) {
838 // Validate $options since this is a new parameter added after Drupal 7 was
839 // released.
840 $options = is_array($options) ? $options : array();
841
842 // Extract field values from submitted values.
843 _field_invoke_default('extract_form_values', $entity_type, $entity, $form, $form_state);
844
845 // Perform field_level validation.
846 try {
847 field_attach_validate($entity_type, $entity, $options);
848 }
849 catch (FieldValidationException $e) {
850 // Pass field-level validation errors back to widgets for accurate error
851 // flagging.
852 foreach ($e->errors as $field_name => $field_errors) {
853 foreach ($field_errors as $langcode => $errors) {
854 $field_state = field_form_get_state($form['#parents'], $field_name, $langcode, $form_state);
855 $field_state['errors'] = $errors;
856 field_form_set_state($form['#parents'], $field_name, $langcode, $form_state, $field_state);
857 }
858 }
859 _field_invoke_default('form_errors', $entity_type, $entity, $form, $form_state, $options);
860 }
861 }
862
884 function field_attach_submit($entity_type, $entity, $form, &$form_state, $options = array()) {
885 // Validate $options since this is a new parameter added after Drupal 7 was
886 // released.
887 $options = is_array($options) ? $options : array();
888
889 // Extract field values from submitted values.
890 _field_invoke_default('extract_form_values', $entity_type, $entity, $form, $form_state, $options);
891
892 _field_invoke_default('submit', $entity_type, $entity, $form, $form_state, $options);
893
894 // Let other modules act on submitting the entity.
895 // Avoid module_invoke_all() to let $form_state be taken by reference.
896 foreach (module_implements('field_attach_submit') as $module) {
897 $function = $module . '_field_attach_submit';
898 $function($entity_type, $entity, $form, $form_state);
899 }
900 }
901
913 function field_attach_presave($entity_type, $entity) {
914 _field_invoke('presave', $entity_type, $entity);
915
916 // Let other modules act on presaving the entity.
917 module_invoke_all('field_attach_presave', $entity_type, $entity);
918 }
919
936 function field_attach_insert($entity_type, $entity) {
937 _field_invoke_default('insert', $entity_type, $entity);
938 _field_invoke('insert', $entity_type, $entity);
939
940 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
941
942 // Let any module insert field data before the storage engine, accumulating
943 // saved fields along the way.
944 $skip_fields = array();
945 foreach (module_implements('field_storage_pre_insert') as $module) {
946 $function = $module . '_field_storage_pre_insert';
947 $function($entity_type, $entity, $skip_fields);
948 }
949
950 // Collect the storage backends used by the remaining fields in the entities.
951 $storages = array();
952 foreach (field_info_instances($entity_type, $bundle) as $instance) {
953 $field = field_info_field_by_id($instance['field_id']);
954 $field_id = $field['id'];
955 $field_name = $field['field_name'];
956 if (!empty($entity->$field_name)) {
957 // Collect the storage backend if the field has not been written yet.
958 if (!isset($skip_fields[$field_id])) {
959 $storages[$field['storage']['type']][$field_id] = $field_id;
960 }
961 }
962 }
963
964 // Field storage backends save any remaining unsaved fields.
965 foreach ($storages as $storage => $fields) {
966 $storage_info = field_info_storage_types($storage);
967 module_invoke($storage_info['module'], 'field_storage_write', $entity_type, $entity, FIELD_STORAGE_INSERT, $fields);
968 }
969
970 // Let other modules act on inserting the entity.
971 module_invoke_all('field_attach_insert', $entity_type, $entity);
972
973 $entity_info = entity_get_info($entity_type);
974 }
975
990 function field_attach_update($entity_type, $entity) {
991 _field_invoke('update', $entity_type, $entity);
992
993 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
994
995 // Let any module update field data before the storage engine, accumulating
996 // saved fields along the way.
997 $skip_fields = array();
998 foreach (module_implements('field_storage_pre_update') as $module) {
999 $function = $module . '_field_storage_pre_update';
1000 $function($entity_type, $entity, $skip_fields);
1001 }
1002
1003 // Collect the storage backends used by the remaining fields in the entities.
1004 $storages = array();
1005 foreach (field_info_instances($entity_type, $bundle) as $instance) {
1006 $field = field_info_field_by_id($instance['field_id']);
1007 $field_id = $field['id'];
1008 $field_name = $field['field_name'];
1009 // Leave the field untouched if $entity comes with no $field_name property,
1010 // but empty the field if it comes as a NULL value or an empty array.
1011 // Function property_exists() is slower, so we catch the more frequent
1012 // cases where it's an empty array with the faster isset().
1013 if (isset($entity->$field_name) || property_exists($entity, $field_name)) {
1014 // Collect the storage backend if the field has not been written yet.
1015 if (!isset($skip_fields[$field_id])) {
1016 $storages[$field['storage']['type']][$field_id] = $field_id;
1017 }
1018 }
1019 }
1020
1021 // Field storage backends save any remaining unsaved fields.
1022 foreach ($storages as $storage => $fields) {
1023 $storage_info = field_info_storage_types($storage);
1024 module_invoke($storage_info['module'], 'field_storage_write', $entity_type, $entity, FIELD_STORAGE_UPDATE, $fields);
1025 }
1026
1027 // Let other modules act on updating the entity.
1028 module_invoke_all('field_attach_update', $entity_type, $entity);
1029
1030 $entity_info = entity_get_info($entity_type);
1031 if ($entity_info['field cache']) {
1032 cache_clear_all("field:$entity_type:$id", 'cache_field');
1033 }
1034 }
1035
1045 function field_attach_delete($entity_type, $entity) {
1046 _field_invoke('delete', $entity_type, $entity);
1047
1048 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
1049
1050 // Collect the storage backends used by the fields in the entities.
1051 $storages = array();
1052 foreach (field_info_instances($entity_type, $bundle) as $instance) {
1053 $field = field_info_field_by_id($instance['field_id']);
1054 $field_id = $field['id'];
1055 $storages[$field['storage']['type']][$field_id] = $field_id;
1056 }
1057
1058 // Field storage backends delete their data.
1059 foreach ($storages as $storage => $fields) {
1060 $storage_info = field_info_storage_types($storage);
1061 module_invoke($storage_info['module'], 'field_storage_delete', $entity_type, $entity, $fields);
1062 }
1063
1064 // Let other modules act on deleting the entity.
1065 module_invoke_all('field_attach_delete', $entity_type, $entity);
1066
1067 $entity_info = entity_get_info($entity_type);
1068 if ($entity_info['field cache']) {
1069 cache_clear_all("field:$entity_type:$id", 'cache_field');
1070 }
1071 }
1072
1082 function field_attach_delete_revision($entity_type, $entity) {
1083 _field_invoke('delete_revision', $entity_type, $entity);
1084
1085 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
1086
1087 // Collect the storage backends used by the fields in the entities.
1088 $storages = array();
1089 foreach (field_info_instances($entity_type, $bundle) as $instance) {
1090 $field = field_info_field_by_id($instance['field_id']);
1091 $field_id = $field['id'];
1092 $storages[$field['storage']['type']][$field_id] = $field_id;
1093 }
1094
1095 // Field storage backends delete their data.
1096 foreach ($storages as $storage => $fields) {
1097 $storage_info = field_info_storage_types($storage);
1098 module_invoke($storage_info['module'], 'field_storage_delete_revision', $entity_type, $entity, $fields);
1099 }
1100
1101 // Let other modules act on deleting the revision.
1102 module_invoke_all('field_attach_delete_revision', $entity_type, $entity);
1103 }
1104
1133 function field_attach_prepare_view($entity_type, $entities, $view_mode, $langcode = NULL, $options = array()) {
1134 // Validate $options since this is a new parameter added after Drupal 7 was
1135 // released.
1136 $options = is_array($options) ? $options : array();
1137
1138 $options['language'] = array();
1139
1140 // To ensure hooks are only run once per entity, only process items without
1141 // the _field_view_prepared flag.
1142 // @todo: resolve this more generally for both entity and field level hooks.
1143 $prepare = array();
1144 foreach ($entities as $id => $entity) {
1145 if (empty($entity->_field_view_prepared)) {
1146 // Add this entity to the items to be prepared.
1147 $prepare[$id] = $entity;
1148
1149 // Determine the actual language to display for each field, given the
1150 // languages available in the field data.
1151 $options['language'][$id] = field_language($entity_type, $entity, NULL, $langcode);
1152
1153 // Mark this item as prepared.
1154 $entity->_field_view_prepared = TRUE;
1155 }
1156 }
1157
1158 $null = NULL;
1159 // First let the field types do their preparation.
1160 _field_invoke_multiple('prepare_view', $entity_type, $prepare, $null, $null, $options);
1161 // Then let the formatters do their own specific massaging.
1162 // field_default_prepare_view() takes care of dispatching to the correct
1163 // formatters according to the display settings for the view mode.
1164 _field_invoke_multiple_default('prepare_view', $entity_type, $prepare, $view_mode, $null, $options);
1165 }
1166
1216 function field_attach_view($entity_type, $entity, $view_mode, $langcode = NULL, $options = array()) {
1217 // Validate $options since this is a new parameter added after Drupal 7 was
1218 // released.
1219 $options = is_array($options) ? $options : array();
1220
1221 // Determine the actual language to display for each field, given the
1222 // languages available in the field data.
1223 $display_language = field_language($entity_type, $entity, NULL, $langcode);
1224 $options['language'] = $display_language;
1225
1226 // Invoke field_default_view().
1227 $null = NULL;
1228 $output = _field_invoke_default('view', $entity_type, $entity, $view_mode, $null, $options);
1229
1230 // Add custom weight handling.
1231 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
1232 $output['#pre_render'][] = '_field_extra_fields_pre_render';
1233 $output['#entity_type'] = $entity_type;
1234 $output['#bundle'] = $bundle;
1235
1236 // Let other modules alter the renderable array.
1237 $context = array(
1238 'entity_type' => $entity_type,
1239 'entity' => $entity,
1240 'view_mode' => $view_mode,
1241 'display' => $view_mode,
1242 'language' => $langcode,
1243 );
1244 drupal_alter('field_attach_view', $output, $context);
1245
1246 // Reset the _field_view_prepared flag set in field_attach_prepare_view(),
1247 // in case the same entity is displayed with different settings later in
1248 // the request.
1249 unset($entity->_field_view_prepared);
1250
1251 return $output;
1252 }
1253
1272 function field_attach_preprocess($entity_type, $entity, $element, &$variables) {
1273 list(, , $bundle) = entity_extract_ids($entity_type, $entity);
1274
1275 foreach (field_info_instances($entity_type, $bundle) as $instance) {
1276 $field_name = $instance['field_name'];
1277 if (isset($element[$field_name]['#language'])) {
1278 $langcode = $element[$field_name]['#language'];
1279 $variables[$field_name] = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : NULL;
1280 }
1281 }
1282
1283 // Let other modules make changes to the $variables array.
1284 $context = array(
1285 'entity_type' => $entity_type,
1286 'entity' => $entity,
1287 'element' => $element,
1288 );
1289 drupal_alter('field_attach_preprocess', $variables, $context);
1290 }
1291
1315 function field_attach_prepare_translation($entity_type, $entity, $langcode, $source_entity, $source_langcode) {
1316 $options = array('language' => $langcode);
1317 // Copy source field values into the entity to be prepared.
1318 _field_invoke_default('prepare_translation', $entity_type, $entity, $source_entity, $source_langcode, $options);
1319 // Let field types handle their own advanced translation pattern if needed.
1320 _field_invoke('prepare_translation', $entity_type, $entity, $source_entity, $source_langcode, $options);
1321 // Let other modules alter the entity translation.
1322 $context = array(
1323 'entity_type' => $entity_type,
1324 'langcode' => $langcode,
1325 'source_entity' => $source_entity,
1326 'source_langcode' => $source_langcode,
1327 );
1328 drupal_alter('field_attach_prepare_translation', $entity, $context);
1329 }
1330
1342 function field_attach_create_bundle($entity_type, $bundle) {
1343 // Clear the cache.
1344 field_cache_clear();
1345
1346 // Let other modules act on creating the bundle.
1347 module_invoke_all('field_attach_create_bundle', $entity_type, $bundle);
1348 }
1349
1360 function field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
1361 db_update('field_config_instance')
1362 ->fields(array('bundle' => $bundle_new))
1363 ->condition('entity_type', $entity_type)
1364 ->condition('bundle', $bundle_old)
1365 ->execute();
1366
1367 // Clear the cache.
1368 field_cache_clear();
1369
1370 // Update bundle settings.
1371 $settings = variable_get('field_bundle_settings_' . $entity_type . '__' . $bundle_old, array());
1372 variable_set('field_bundle_settings_' . $entity_type . '__' . $bundle_new, $settings);
1373 variable_del('field_bundle_settings_' . $entity_type . '__' . $bundle_old);
1374
1375 // Let other modules act on renaming the bundle.
1376 module_invoke_all('field_attach_rename_bundle', $entity_type, $bundle_old, $bundle_new);
1377 }
1378
1394 function field_attach_delete_bundle($entity_type, $bundle) {
1395 // First, delete the instances themselves. field_read_instances() must be
1396 // used here since field_info_instances() does not return instances for
1397 // disabled entity types or bundles.
1398 $instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle), array('include_inactive' => 1));
1399 foreach ($instances as $instance) {
1400 field_delete_instance($instance);
1401 }
1402
1403 // Clear the cache.
1404 field_cache_clear();
1405
1406 // Clear bundle display settings.
1407 variable_del('field_bundle_settings_' . $entity_type . '__' . $bundle);
1408
1409 // Let other modules act on deleting the bundle.
1410 module_invoke_all('field_attach_delete_bundle', $entity_type, $bundle, $instances);
1411 }
1412
1413
field_info_storage_types
field_info_storage_types($storage_type=NULL)
Definition: field.info.inc:404
field_info_field_by_id
field_info_field_by_id($field_id)
Definition: field.info.inc:537
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
$op
$op
Definition: update.php:404
FieldValidationException
Definition: field.attach.inc:11
field_attach_form
field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode=NULL, $options=array())
Definition: field.attach.inc:564
FieldValidationException\$errors
$errors
Definition: field.attach.inc:12
field_attach_submit
field_attach_submit($entity_type, $entity, $form, &$form_state, $options=array())
Definition: field.attach.inc:884
FIELD_STORAGE_UPDATE
const FIELD_STORAGE_UPDATE
Definition: field.attach.inc:58
field_info_instances
field_info_instances($entity_type=NULL, $bundle_name=NULL)
Definition: field.info.inc:592
field_attach_load_revision
field_attach_load_revision($entity_type, $entities, $options=array())
Definition: field.attach.inc:757
$module
print $module
Definition: search-results.tpl.php:28
field_available_languages
field_available_languages($entity_type, $field)
Definition: field.multilingual.inc:89
field_attach_update
field_attach_update($entity_type, $entity)
Definition: field.attach.inc:990
_field_invoke_get_instances
_field_invoke_get_instances($entity_type, $bundle, $options)
Definition: field.attach.inc:420
field_attach_delete_revision
field_attach_delete_revision($entity_type, $entity)
Definition: field.attach.inc:1082
variable_del
variable_del($name)
Definition: bootstrap.inc:996
$results
print $results
Definition: poll-results.tpl.php:23
FIELD_STORAGE_INSERT
const FIELD_STORAGE_INSERT
Definition: field.attach.inc:65
field_attach_prepare_view
field_attach_prepare_view($entity_type, $entities, $view_mode, $langcode=NULL, $options=array())
Definition: field.attach.inc:1133
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
field_attach_presave
field_attach_presave($entity_type, $entity)
Definition: field.attach.inc:913
field_read_instances
field_read_instances($params=array(), $include_additional=array())
Definition: field.crud.inc:713
_field_invoke
_field_invoke($op, $entity_type, $entity, &$a=NULL, &$b=NULL, $options=array())
Definition: field.attach.inc:181
field_attach_prepare_translation
field_attach_prepare_translation($entity_type, $entity, $langcode, $source_entity, $source_langcode)
Definition: field.attach.inc:1315
cache_get_multiple
cache_get_multiple(array &$cids, $bin= 'cache')
Definition: cache.inc:71
field_cache_clear
field_cache_clear()
Definition: field.module:740
field_valid_language
field_valid_language($langcode, $default=TRUE)
Definition: field.multilingual.inc:228
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
field_attach_form_validate
field_attach_form_validate($entity_type, $entity, $form, &$form_state, $options=array())
Definition: field.attach.inc:837
field_language
field_language($entity_type, $entity, $field_name=NULL, $langcode=NULL)
Definition: field.multilingual.inc:266
field_attach_insert
field_attach_insert($entity_type, $entity)
Definition: field.attach.inc:936
$info
$info
Definition: color.inc:6
FIELD_LOAD_REVISION
const FIELD_LOAD_REVISION
Definition: field.module:274
field_form_set_state
field_form_set_state($parents, $field_name, $langcode, &$form_state, $field_state)
Definition: field.form.inc:527
field_attach_load
field_attach_load($entity_type, $entities, $age=FIELD_LOAD_CURRENT, $options=array())
Definition: field.attach.inc:622
FieldValidationException\__construct
__construct($errors)
Definition: field.attach.inc:26
$output
$output
Definition: authorize.php:93
field_attach_preprocess
field_attach_preprocess($entity_type, $entity, $element, &$variables)
Definition: field.attach.inc:1272
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
FieldException
Definition: field.module:13
field_form_get_state
field_form_get_state($parents, $field_name, $langcode, &$form_state)
Definition: field.form.inc:505
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
field_attach_rename_bundle
field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new)
Definition: field.attach.inc:1360
field_attach_view
field_attach_view($entity_type, $entity, $view_mode, $langcode=NULL, $options=array())
Definition: field.attach.inc:1216
field_delete_instance
field_delete_instance($instance, $field_cleanup=TRUE)
Definition: field.crud.inc:768
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
field_attach_delete_bundle
field_attach_delete_bundle($entity_type, $bundle)
Definition: field.attach.inc:1394
field_attach_validate
field_attach_validate($entity_type, $entity, $options=array())
Definition: field.attach.inc:781
_field_invoke_multiple_default
_field_invoke_multiple_default($op, $entity_type, $entities, &$a=NULL, &$b=NULL, $options=array())
Definition: field.attach.inc:397
_field_invoke_default
_field_invoke_default($op, $entity_type, $entity, &$a=NULL, &$b=NULL, $options=array())
Definition: field.attach.inc:383
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
field_attach_create_bundle
field_attach_create_bundle($entity_type, $bundle)
Definition: field.attach.inc:1342
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
entity_extract_ids
entity_extract_ids($entity_type, $entity)
Definition: common.inc:7711
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
_field_language_suggestion
_field_language_suggestion($available_languages, $language_suggestion, $field_name)
Definition: field.multilingual.inc:131
_field_invoke_multiple
_field_invoke_multiple($op, $entity_type, $entities, &$a=NULL, &$b=NULL, $options=array())
Definition: field.attach.inc:278
field_attach_delete
field_attach_delete($entity_type, $entity)
Definition: field.attach.inc:1045
field_info_instance
field_info_instance($entity_type, $field_name, $bundle_name)
Definition: field.info.inc:623
FIELD_LOAD_CURRENT
const FIELD_LOAD_CURRENT
Definition: field.module:268
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/update.inc Source File

  • includes
update.inc
Go to the documentation of this file.
1 <?php
2
19 define('REQUIRED_D6_SCHEMA_VERSION', '6055');
20
24 function update_fix_compatibility() {
25 $incompatible = array();
26 $result = db_query("SELECT name, type, status FROM {system} WHERE status = 1 AND type IN ('module','theme')");
27 foreach ($result as $row) {
28 if (update_check_incompatibility($row->name, $row->type)) {
29 $incompatible[] = $row->name;
30 }
31 }
32 if (!empty($incompatible)) {
33 db_update('system')
34 ->fields(array('status' => 0))
35 ->condition('name', $incompatible, 'IN')
36 ->execute();
37 }
38 }
39
43 function update_check_incompatibility($name, $type = 'module') {
44 static $themes, $modules;
45
46 // Store values of expensive functions for future use.
47 if (empty($themes) || empty($modules)) {
48 // We need to do a full rebuild here to make sure the database reflects any
49 // code changes that were made in the filesystem before the update script
50 // was initiated.
51 $themes = system_rebuild_theme_data();
52 $modules = system_rebuild_module_data();
53 }
54
55 if ($type == 'module' && isset($modules[$name])) {
56 $file = $modules[$name];
57 }
58 elseif ($type == 'theme' && isset($themes[$name])) {
59 $file = $themes[$name];
60 }
61 if (!isset($file)
62 || !isset($file->info['core'])
63 || $file->info['core'] != DRUPAL_CORE_COMPATIBILITY
64 || version_compare(phpversion(), $file->info['php']) < 0) {
65 return TRUE;
66 }
67 return FALSE;
68 }
69
81 function update_prepare_d7_bootstrap() {
82 // Allow the bootstrap to proceed even if a Drupal 6 settings.php file is
83 // still being used.
84 include_once DRUPAL_ROOT . '/includes/install.inc';
85 drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
86 global $databases, $db_url, $db_prefix, $update_rewrite_settings;
87 if (empty($databases) && !empty($db_url)) {
88 $databases = update_parse_db_url($db_url, $db_prefix);
89 // Record the fact that the settings.php file will need to be rewritten.
90 $update_rewrite_settings = TRUE;
91 $settings_file = conf_path() . '/settings.php';
92 $writable = drupal_verify_install_file($settings_file, FILE_EXIST|FILE_READABLE|FILE_WRITABLE);
93 $requirements = array(
94 'settings file' => array(
95 'title' => 'Settings file',
96 'value' => $writable ? 'The settings file is writable.' : 'The settings file is not writable.',
97 'severity' => $writable ? REQUIREMENT_OK : REQUIREMENT_ERROR,
98 'description' => $writable ? '' : 'Drupal requires write permissions to <em>' . $settings_file . '</em> during the update process. If you are unsure how to grant file permissions, consult the <a href="http://drupal.org/server-permissions">online handbook</a>.',
99 ),
100 );
101 update_extra_requirements($requirements);
102 }
103
104 // The new {blocked_ips} table is used in Drupal 7 to store a list of
105 // banned IP addresses. If this table doesn't exist then we are still
106 // running on a Drupal 6 database, so we suppress the unavoidable errors
107 // that occur by creating a static list.
108 $GLOBALS['conf']['blocked_ips'] = array();
109
110 // Check that PDO is available and that the correct PDO database driver is
111 // loaded. Bootstrapping to DRUPAL_BOOTSTRAP_DATABASE will result in a fatal
112 // error otherwise.
113 $message = '';
114 $pdo_link = 'http://drupal.org/requirements/pdo';
115 // Check that PDO is loaded.
116 if (!extension_loaded('pdo')) {
117 $message = '<h2>PDO is required!</h2><p>Drupal 7 requires PHP ' . DRUPAL_MINIMUM_PHP . ' or higher with the PHP Data Objects (PDO) extension enabled.</p>';
118 }
119 // The PDO::ATTR_DEFAULT_FETCH_MODE constant is not available in the PECL
120 // version of PDO.
121 elseif (!defined('PDO::ATTR_DEFAULT_FETCH_MODE')) {
122 $message = '<h2>The wrong version of PDO is installed!</h2><p>Drupal 7 requires the PHP Data Objects (PDO) extension from PHP core to be enabled. This system has the older PECL version installed.';
123 $pdo_link = 'http://drupal.org/requirements/pdo#pecl';
124 }
125 // Check that the correct driver is loaded for the database being updated.
126 // If we have no driver information (for example, if someone tried to create
127 // the Drupal 7 $databases array themselves but did not do it correctly),
128 // this message will be confusing, so do not perform the check; instead, just
129 // let the database connection fail in the code that follows.
130 elseif (isset($databases['default']['default']['driver']) && !in_array($databases['default']['default']['driver'], PDO::getAvailableDrivers())) {
131 $message = '<h2>A PDO database driver is required!</h2><p>You need to enable the PDO_' . strtoupper($databases['default']['default']['driver']) . ' database driver for PHP ' . DRUPAL_MINIMUM_PHP . ' or higher so that Drupal 7 can access the database.</p>';
132 }
133 if ($message) {
134 print $message . '<p>See the <a href="' . $pdo_link . '">system requirements page</a> for more information.</p>';
135 exit();
136 }
137
138 // Allow the database system to work even if the registry has not been
139 // created yet.
140 drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
141
142 // If the site has not updated to Drupal 7 yet, check to make sure that it is
143 // running an up-to-date version of Drupal 6 before proceeding. Note this has
144 // to happen AFTER the database bootstraps because of
145 // drupal_get_installed_schema_version().
146 $system_schema = drupal_get_installed_schema_version('system');
147 if ($system_schema < 7000) {
148 $has_required_schema = $system_schema >= REQUIRED_D6_SCHEMA_VERSION;
149 $requirements = array(
150 'drupal 6 version' => array(
151 'title' => 'Drupal 6 version',
152 'value' => $has_required_schema ? 'You are running a current version of Drupal 6.' : 'You are not running a current version of Drupal 6',
153 'severity' => $has_required_schema ? REQUIREMENT_OK : REQUIREMENT_ERROR,
154 'description' => $has_required_schema ? '' : 'Please update your Drupal 6 installation to the most recent version before attempting to upgrade to Drupal 7',
155 ),
156 );
157
158 // Make sure that the database environment is properly set up.
159 try {
160 db_run_tasks(db_driver());
161 }
162 catch (DatabaseTaskException $e) {
163 $requirements['database tasks'] = array(
164 'title' => 'Database environment',
165 'value' => 'There is a problem with your database environment',
166 'severity' => REQUIREMENT_ERROR,
167 'description' => $e->getMessage(),
168 );
169 }
170
171 update_extra_requirements($requirements);
172
173 // Allow a D6 session to work, since the upgrade has not been performed yet.
174 $d6_session_name = update_get_d6_session_name();
175 if (!empty($_COOKIE[$d6_session_name])) {
176 // Set the current sid to the one found in the D6 cookie.
177 $sid = $_COOKIE[$d6_session_name];
178 $_COOKIE[session_name()] = $sid;
179 session_id($sid);
180 }
181
182 // Upgrading from D6 to D7.{0,1,2,3,4,8,...} is different than upgrading
183 // from D6 to D7.{5,6,7} which should be considered broken. To be able to
184 // properly handle this difference in node_update_7012 we need to keep track
185 // of whether a D6 > D7 upgrade or a D7 > D7 update is running.
186 // Since variable_set() is not available here, the D6 status is being saved
187 // in a local variable to be able to store it later.
188 $update_d6 = TRUE;
189 }
190
191 // Create the registry tables.
192 if (!db_table_exists('registry')) {
193 $schema['registry'] = array(
194 'fields' => array(
195 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
196 'type' => array('type' => 'varchar', 'length' => 9, 'not null' => TRUE, 'default' => ''),
197 'filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
198 'module' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
199 'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
200 ),
201 'primary key' => array('name', 'type'),
202 'indexes' => array(
203 'hook' => array('type', 'weight', 'module'),
204 ),
205 );
206 db_create_table('registry', $schema['registry']);
207 }
208 if (!db_table_exists('registry_file')) {
209 $schema['registry_file'] = array(
210 'fields' => array(
211 'filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
212 'hash' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE),
213 ),
214 'primary key' => array('filename'),
215 );
216 db_create_table('registry_file', $schema['registry_file']);
217 }
218
219 // Older versions of Drupal 6 do not include the semaphore table, which is
220 // required to bootstrap, so we add it now so that we can bootstrap and
221 // provide a reasonable error message.
222 if (!db_table_exists('semaphore')) {
223 $semaphore = array(
224 'description' => 'Table for holding semaphores, locks, flags, etc. that cannot be stored as Drupal variables since they must not be cached.',
225 'fields' => array(
226 'name' => array(
227 'description' => 'Primary Key: Unique name.',
228 'type' => 'varchar',
229 'length' => 255,
230 'not null' => TRUE,
231 'default' => ''
232 ),
233 'value' => array(
234 'description' => 'A value for the semaphore.',
235 'type' => 'varchar',
236 'length' => 255,
237 'not null' => TRUE,
238 'default' => ''
239 ),
240 'expire' => array(
241 'description' => 'A Unix timestamp with microseconds indicating when the semaphore should expire.',
242 'type' => 'float',
243 'size' => 'big',
244 'not null' => TRUE
245 ),
246 ),
247 'indexes' => array(
248 'value' => array('value'),
249 'expire' => array('expire'),
250 ),
251 'primary key' => array('name'),
252 );
253 db_create_table('semaphore', $semaphore);
254 }
255
256 // The new cache_bootstrap bin is required to bootstrap to
257 // DRUPAL_BOOTSTRAP_SESSION, so create it here rather than in
258 // update_fix_d7_requirements().
259 if (!db_table_exists('cache_bootstrap')) {
260 $cache_bootstrap = array(
261 'description' => 'Cache table for data required to bootstrap Drupal, may be routed to a shared memory cache.',
262 'fields' => array(
263 'cid' => array(
264 'description' => 'Primary Key: Unique cache ID.',
265 'type' => 'varchar',
266 'length' => 255,
267 'not null' => TRUE,
268 'default' => '',
269 ),
270 'data' => array(
271 'description' => 'A collection of data to cache.',
272 'type' => 'blob',
273 'not null' => FALSE,
274 'size' => 'big',
275 ),
276 'expire' => array(
277 'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
278 'type' => 'int',
279 'not null' => TRUE,
280 'default' => 0,
281 ),
282 'created' => array(
283 'description' => 'A Unix timestamp indicating when the cache entry was created.',
284 'type' => 'int',
285 'not null' => TRUE,
286 'default' => 0,
287 ),
288 'serialized' => array(
289 'description' => 'A flag to indicate whether content is serialized (1) or not (0).',
290 'type' => 'int',
291 'size' => 'small',
292 'not null' => TRUE,
293 'default' => 0,
294 ),
295 ),
296 'indexes' => array(
297 'expire' => array('expire'),
298 ),
299 'primary key' => array('cid'),
300 );
301 db_create_table('cache_bootstrap', $cache_bootstrap);
302 }
303
304 // Set a valid timezone for 6 -> 7 upgrade process.
305 drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
306 $timezone_offset = variable_get('date_default_timezone', 0);
307 if (is_numeric($timezone_offset)) {
308 // Save the original offset.
309 variable_set('date_temporary_timezone', $timezone_offset);
310 // Set the timezone for this request only.
311 $GLOBALS['conf']['date_default_timezone'] = 'UTC';
312 }
313
314 // This allows update functions to tell if an upgrade from D6 is running.
315 if (!empty($update_d6)) {
316 variable_set('update_d6', TRUE);
317 }
318 }
319
355 function update_fix_d7_block_deltas(&$sandbox, $renamed_deltas, $moved_deltas) {
356 // Loop through each block and make changes to the block tables.
357 // Only run this the first time through the batch update.
358 if (!isset($sandbox['progress'])) {
359 // Determine whether to use the old or new block table names.
360 $block_tables = db_table_exists('blocks') ? array('blocks', 'blocks_roles') : array('block', 'block_role');
361 foreach ($block_tables as $table) {
362 foreach ($renamed_deltas as $module => $deltas) {
363 foreach ($deltas as $old_delta => $new_delta) {
364 // Only do the update if the old block actually exists.
365 $block_exists = db_query("SELECT COUNT(*) FROM {" . $table . "} WHERE module = :module AND delta = :delta", array(
366 ':module' => $module,
367 ':delta' => $old_delta,
368 ))
369 ->fetchField();
370 if ($block_exists) {
371 // Delete any existing blocks with the new module+delta.
372 db_delete($table)
373 ->condition('module', $module)
374 ->condition('delta', $new_delta)
375 ->execute();
376 // Rename the old block to the new module+delta.
377 db_update($table)
378 ->fields(array('delta' => $new_delta))
379 ->condition('module', $module)
380 ->condition('delta', $old_delta)
381 ->execute();
382 }
383 }
384 }
385 foreach ($moved_deltas as $old_module => $deltas) {
386 foreach ($deltas as $delta => $new_module) {
387 // Only do the update if the old block actually exists.
388 $block_exists = db_query("SELECT COUNT(*) FROM {" . $table . "} WHERE module = :module AND delta = :delta", array(
389 ':module' => $old_module,
390 ':delta' => $delta,
391 ))
392 ->fetchField();
393 if ($block_exists) {
394 // Delete any existing blocks with the new module+delta.
395 db_delete($table)
396 ->condition('module', $new_module)
397 ->condition('delta', $delta)
398 ->execute();
399 // Rename the old block to the new module+delta.
400 db_update($table)
401 ->fields(array('module' => $new_module))
402 ->condition('module', $old_module)
403 ->condition('delta', $delta)
404 ->execute();
405 }
406 }
407 }
408 }
409
410 // Initialize batch update information.
411 $sandbox['progress'] = 0;
412 $sandbox['last_user_processed'] = -1;
413 $sandbox['max'] = db_query("SELECT COUNT(*) FROM {users} WHERE data LIKE :block", array(
414 ':block' => '%' . db_like(serialize('block')) . '%',
415 ))
416 ->fetchField();
417 }
418 // Now do the batch update of the user-specific block visibility settings.
419 $limit = 100;
420 $result = db_select('users', 'u')
421 ->fields('u', array('uid', 'data'))
422 ->condition('uid', $sandbox['last_user_processed'], '>')
423 ->condition('data', '%' . db_like(serialize('block')) . '%', 'LIKE')
424 ->orderBy('uid', 'ASC')
425 ->range(0, $limit)
426 ->execute();
427 foreach ($result as $row) {
428 $data = unserialize($row->data);
429 $user_needs_update = FALSE;
430 foreach ($renamed_deltas as $module => $deltas) {
431 foreach ($deltas as $old_delta => $new_delta) {
432 if (isset($data['block'][$module][$old_delta])) {
433 // Transfer the old block visibility settings to the newly-renamed
434 // block, and mark this user for a database update.
435 $data['block'][$module][$new_delta] = $data['block'][$module][$old_delta];
436 unset($data['block'][$module][$old_delta]);
437 $user_needs_update = TRUE;
438 }
439 }
440 }
441 foreach ($moved_deltas as $old_module => $deltas) {
442 foreach ($deltas as $delta => $new_module) {
443 if (isset($data['block'][$old_module][$delta])) {
444 // Transfer the old block visibility settings to the moved
445 // block, and mark this user for a database update.
446 $data['block'][$new_module][$delta] = $data['block'][$old_module][$delta];
447 unset($data['block'][$old_module][$delta]);
448 $user_needs_update = TRUE;
449 }
450 }
451 }
452 // Update the current user.
453 if ($user_needs_update) {
454 db_update('users')
455 ->fields(array('data' => serialize($data)))
456 ->condition('uid', $row->uid)
457 ->execute();
458 }
459 // Update our progress information for the batch update.
460 $sandbox['progress']++;
461 $sandbox['last_user_processed'] = $row->uid;
462 }
463 // Indicate our current progress to the batch update system.
464 if ($sandbox['progress'] < $sandbox['max']) {
465 $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max'];
466 }
467 }
468
478 function update_fix_d7_requirements() {
479 global $conf;
480
481 // Rewrite the settings.php file if necessary, see
482 // update_prepare_d7_bootstrap().
483 global $update_rewrite_settings, $db_url, $db_prefix;
484 if (!empty($update_rewrite_settings)) {
485 $databases = update_parse_db_url($db_url, $db_prefix);
486 $salt = drupal_hash_base64(drupal_random_bytes(55));
487 file_put_contents(conf_path() . '/settings.php', "\n" . '$databases = ' . var_export($databases, TRUE) . ";\n\$drupal_hash_salt = '$salt';", FILE_APPEND);
488 }
489 if (drupal_get_installed_schema_version('system') < 7000 && !variable_get('update_d7_requirements', FALSE)) {
490 // Change 6.x system table field values to 7.x equivalent.
491 // Change field values.
492 db_change_field('system', 'schema_version', 'schema_version', array(
493 'type' => 'int',
494 'size' => 'small',
495 'not null' => TRUE,
496 'default' => -1)
497 );
498 db_change_field('system', 'status', 'status', array(
499 'type' => 'int', 'not null' => TRUE, 'default' => 0));
500 db_change_field('system', 'weight', 'weight', array(
501 'type' => 'int', 'not null' => TRUE, 'default' => 0));
502 db_change_field('system', 'bootstrap', 'bootstrap', array(
503 'type' => 'int', 'not null' => TRUE, 'default' => 0));
504 // Drop and recreate 6.x indexes.
505 db_drop_index('system', 'bootstrap');
506 db_add_index('system', 'bootstrap', array(
507 'status', 'bootstrap', array('type', 12), 'weight', 'name'));
508
509 db_drop_index('system' ,'modules');
510 db_add_index('system', 'modules', array(array(
511 'type', 12), 'status', 'weight', 'name'));
512
513 db_drop_index('system', 'type_name');
514 db_add_index('system', 'type_name', array(array('type', 12), 'name'));
515 // Add 7.x indexes.
516 db_add_index('system', 'system_list', array('weight', 'name'));
517
518 // Add the cache_path table.
519 if (db_table_exists('cache_path')) {
520 db_drop_table('cache_path');
521 }
522 require_once('./modules/system/system.install');
523 $schema['cache_path'] = system_schema_cache_7054();
524 $schema['cache_path']['description'] = 'Cache table used for path alias lookups.';
525 db_create_table('cache_path', $schema['cache_path']);
526
527 // system_update_7042() renames columns, but these are needed to bootstrap.
528 // Add empty columns for now.
529 db_add_field('url_alias', 'source', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
530 db_add_field('url_alias', 'alias', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
531
532 // Add new columns to {menu_router}.
533 db_add_field('menu_router', 'delivery_callback', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
534 db_add_field('menu_router', 'context', array(
535 'description' => 'Only for local tasks (tabs) - the context of a local task to control its placement.',
536 'type' => 'int',
537 'not null' => TRUE,
538 'default' => 0,
539 ));
540 db_drop_index('menu_router', 'tab_parent');
541 db_add_index('menu_router', 'tab_parent', array(array('tab_parent', 64), 'weight', 'title'));
542 db_add_field('menu_router', 'theme_callback', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
543 db_add_field('menu_router', 'theme_arguments', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
544
545 // Add the role_permission table.
546 $schema['role_permission'] = array(
547 'fields' => array(
548 'rid' => array(
549 'type' => 'int',
550 'unsigned' => TRUE,
551 'not null' => TRUE,
552 ),
553 'permission' => array(
554 'type' => 'varchar',
555 'length' => 128,
556 'not null' => TRUE,
557 'default' => '',
558 ),
559 ),
560 'primary key' => array('rid', 'permission'),
561 'indexes' => array(
562 'permission' => array('permission'),
563 ),
564 );
565 db_create_table('role_permission', $schema['role_permission']);
566
567 // Drops and recreates semaphore value index.
568 db_drop_index('semaphore', 'value');
569 db_add_index('semaphore', 'value', array('value'));
570
571 $schema['date_format_type'] = array(
572 'description' => 'Stores configured date format types.',
573 'fields' => array(
574 'type' => array(
575 'description' => 'The date format type, e.g. medium.',
576 'type' => 'varchar',
577 'length' => 64,
578 'not null' => TRUE,
579 ),
580 'title' => array(
581 'description' => 'The human readable name of the format type.',
582 'type' => 'varchar',
583 'length' => 255,
584 'not null' => TRUE,
585 ),
586 'locked' => array(
587 'description' => 'Whether or not this is a system provided format.',
588 'type' => 'int',
589 'size' => 'tiny',
590 'default' => 0,
591 'not null' => TRUE,
592 ),
593 ),
594 'primary key' => array('type'),
595 );
596
597 $schema['date_formats'] = array(
598 'description' => 'Stores configured date formats.',
599 'fields' => array(
600 'dfid' => array(
601 'description' => 'The date format identifier.',
602 'type' => 'serial',
603 'not null' => TRUE,
604 'unsigned' => TRUE,
605 ),
606 'format' => array(
607 'description' => 'The date format string.',
608 'type' => 'varchar',
609 'length' => 100,
610 'not null' => TRUE,
611 ),
612 'type' => array(
613 'description' => 'The date format type, e.g. medium.',
614 'type' => 'varchar',
615 'length' => 64,
616 'not null' => TRUE,
617 ),
618 'locked' => array(
619 'description' => 'Whether or not this format can be modified.',
620 'type' => 'int',
621 'size' => 'tiny',
622 'default' => 0,
623 'not null' => TRUE,
624 ),
625 ),
626 'primary key' => array('dfid'),
627 'unique keys' => array('formats' => array('format', 'type')),
628 );
629
630 $schema['date_format_locale'] = array(
631 'description' => 'Stores configured date formats for each locale.',
632 'fields' => array(
633 'format' => array(
634 'description' => 'The date format string.',
635 'type' => 'varchar',
636 'length' => 100,
637 'not null' => TRUE,
638 ),
639 'type' => array(
640 'description' => 'The date format type, e.g. medium.',
641 'type' => 'varchar',
642 'length' => 64,
643 'not null' => TRUE,
644 ),
645 'language' => array(
646 'description' => 'A {languages}.language for this format to be used with.',
647 'type' => 'varchar',
648 'length' => 12,
649 'not null' => TRUE,
650 ),
651 ),
652 'primary key' => array('type', 'language'),
653 );
654
655 db_create_table('date_format_type', $schema['date_format_type']);
656 // Sites that have the Drupal 6 Date module installed already have the
657 // following tables.
658 if (db_table_exists('date_formats')) {
659 db_rename_table('date_formats', 'd6_date_formats');
660 }
661 db_create_table('date_formats', $schema['date_formats']);
662 if (db_table_exists('date_format_locale')) {
663 db_rename_table('date_format_locale', 'd6_date_format_locale');
664 }
665 db_create_table('date_format_locale', $schema['date_format_locale']);
666
667 // Add the queue table.
668 $schema['queue'] = array(
669 'description' => 'Stores items in queues.',
670 'fields' => array(
671 'item_id' => array(
672 'type' => 'serial',
673 'unsigned' => TRUE,
674 'not null' => TRUE,
675 'description' => 'Primary Key: Unique item ID.',
676 ),
677 'name' => array(
678 'type' => 'varchar',
679 'length' => 255,
680 'not null' => TRUE,
681 'default' => '',
682 'description' => 'The queue name.',
683 ),
684 'data' => array(
685 'type' => 'blob',
686 'not null' => FALSE,
687 'size' => 'big',
688 'serialize' => TRUE,
689 'description' => 'The arbitrary data for the item.',
690 ),
691 'expire' => array(
692 'type' => 'int',
693 'not null' => TRUE,
694 'default' => 0,
695 'description' => 'Timestamp when the claim lease expires on the item.',
696 ),
697 'created' => array(
698 'type' => 'int',
699 'not null' => TRUE,
700 'default' => 0,
701 'description' => 'Timestamp when the item was created.',
702 ),
703 ),
704 'primary key' => array('item_id'),
705 'indexes' => array(
706 'name_created' => array('name', 'created'),
707 'expire' => array('expire'),
708 ),
709 );
710 // Check for queue table that may remain from D5 or D6, if found
711 //drop it.
712 if (db_table_exists('queue')) {
713 db_drop_table('queue');
714 }
715
716 db_create_table('queue', $schema['queue']);
717
718 // Create the sequences table.
719 $schema['sequences'] = array(
720 'description' => 'Stores IDs.',
721 'fields' => array(
722 'value' => array(
723 'description' => 'The value of the sequence.',
724 'type' => 'serial',
725 'unsigned' => TRUE,
726 'not null' => TRUE,
727 ),
728 ),
729 'primary key' => array('value'),
730 );
731 // Check for sequences table that may remain from D5 or D6, if found
732 //drop it.
733 if (db_table_exists('sequences')) {
734 db_drop_table('sequences');
735 }
736 db_create_table('sequences', $schema['sequences']);
737 // Initialize the table with the maximum current increment of the tables
738 // that will rely on it for their ids.
739 $max_aid = db_query('SELECT MAX(aid) FROM {actions_aid}')->fetchField();
740 $max_uid = db_query('SELECT MAX(uid) FROM {users}')->fetchField();
741 $max_batch_id = db_query('SELECT MAX(bid) FROM {batch}')->fetchField();
742 db_insert('sequences')->fields(array('value' => max($max_aid, $max_uid, $max_batch_id)))->execute();
743
744 // Add column for locale context.
745 if (db_table_exists('locales_source')) {
746 db_add_field('locales_source', 'context', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', 'description' => 'The context this string applies to.'));
747 }
748
749 // Rename 'site_offline_message' variable to 'maintenance_mode_message'
750 // and 'site_offline' variable to 'maintenance_mode'.
751 // Old variable is removed in update for system.module, see
752 // system_update_7072().
753 if ($message = variable_get('site_offline_message', NULL)) {
754 variable_set('maintenance_mode_message', $message);
755 }
756 // Old variable is removed in update for system.module, see
757 // system_update_7069().
758 $site_offline = variable_get('site_offline', -1);
759 if ($site_offline != -1) {
760 variable_set('maintenance_mode', $site_offline);
761 }
762
763 // Add ssid column and index.
764 db_add_field('sessions', 'ssid', array('description' => "Secure session ID. The value is generated by Drupal's session handlers.", 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''));
765 db_add_index('sessions', 'ssid', array('ssid'));
766 // Drop existing primary key.
767 db_drop_primary_key('sessions');
768 // Add new primary key.
769 db_add_primary_key('sessions', array('sid', 'ssid'));
770
771 // Allow longer javascript file names.
772 if (db_table_exists('languages')) {
773 db_change_field('languages', 'javascript', 'javascript', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''));
774 }
775
776 // Rename action description to label.
777 db_change_field('actions', 'description', 'label', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '0'));
778
779 variable_set('update_d7_requirements', TRUE);
780 }
781
782 update_fix_d7_install_profile();
783 }
784
795 function update_fix_d7_install_profile() {
796 $profile = drupal_get_profile();
797
798 $results = db_select('system', 's')
799 ->fields('s', array('name', 'schema_version'))
800 ->condition('name', $profile)
801 ->condition('type', 'module')
802 ->execute()
803 ->fetchAll();
804
805 if (empty($results)) {
806 $filename = 'profiles/' . $profile . '/' . $profile . '.profile';
807
808 // Read profile info file
809 $info = drupal_parse_info_file(dirname($filename) . '/' . $profile . '.info');
810
811 // Merge in defaults.
812 $info = $info + array(
813 'dependencies' => array(),
814 'description' => '',
815 'package' => 'Other',
816 'version' => NULL,
817 'php' => DRUPAL_MINIMUM_PHP,
818 'files' => array(),
819 );
820
821 $values = array(
822 'filename' => $filename,
823 'name' => $profile,
824 'info' => serialize($info),
825 'schema_version' => 0,
826 'type' => 'module',
827 'status' => 1,
828 'owner' => '',
829 );
830
831 // Installation profile hooks are always executed last by the module system
832 $values['weight'] = 1000;
833
834 // Initializing the system table entry for the installation profile
835 db_insert('system')
836 ->fields(array_keys($values))
837 ->values($values)
838 ->execute();
839
840 // Reset the cached schema version.
841 drupal_get_installed_schema_version($profile, TRUE);
842
843 // Load the updates again to make sure the installation profile updates
844 // are loaded.
845 drupal_load_updates();
846 }
847 }
848
855 function update_parse_db_url($db_url, $db_prefix) {
856 $databases = array();
857 if (!is_array($db_url)) {
858 $db_url = array('default' => $db_url);
859 }
860 foreach ($db_url as $database => $url) {
861 $url = parse_url($url);
862 $databases[$database]['default'] = array(
863 // MySQLi uses the mysql driver.
864 'driver' => $url['scheme'] == 'mysqli' ? 'mysql' : $url['scheme'],
865 // Remove the leading slash to get the database name.
866 'database' => substr(urldecode($url['path']), 1),
867 'username' => urldecode($url['user']),
868 'password' => isset($url['pass']) ? urldecode($url['pass']) : '',
869 'host' => urldecode($url['host']),
870 'port' => isset($url['port']) ? urldecode($url['port']) : '',
871 );
872 if (isset($db_prefix)) {
873 $databases[$database]['default']['prefix'] = $db_prefix;
874 }
875 }
876 return $databases;
877 }
878
887 function update_get_d6_session_name() {
888 global $base_url, $cookie_domain;
889 $cookie_secure = ini_get('session.cookie_secure');
890
891 // If a custom cookie domain is set in settings.php, that variable forms
892 // the basis of the session name. Re-compute the D7 hashing method to find
893 // out if $cookie_domain was used as the session name.
894 if (($cookie_secure ? 'SSESS' : 'SESS') . substr(hash('sha256', $cookie_domain), 0, 32) == session_name()) {
895 $session_name = $cookie_domain;
896 }
897 else {
898 // Otherwise use $base_url as session name, without the protocol
899 // to use the same session identifiers across HTTP and HTTPS.
900 list( , $session_name) = explode('://', $base_url, 2);
901 }
902
903 if ($cookie_secure) {
904 $session_name .= 'SSL';
905 }
906
907 return 'SESS' . md5($session_name);
908 }
909
951 function update_do_one($module, $number, $dependency_map, &$context) {
952 $function = $module . '_update_' . $number;
953
954 // If this update was aborted in a previous step, or has a dependency that
955 // was aborted in a previous step, go no further.
956 if (!empty($context['results']['#abort']) && array_intersect($context['results']['#abort'], array_merge($dependency_map, array($function)))) {
957 return;
958 }
959
960 $ret = array();
961 if (function_exists($function)) {
962 try {
963 $ret['results']['query'] = $function($context['sandbox']);
964 $ret['results']['success'] = TRUE;
965 }
966 // @TODO We may want to do different error handling for different
967 // exception types, but for now we'll just log the exception and
968 // return the message for printing.
969 catch (Exception $e) {
970 watchdog_exception('update', $e);
971
972 require_once DRUPAL_ROOT . '/includes/errors.inc';
973 $variables = _drupal_decode_exception($e);
974 // The exception message is run through check_plain() by _drupal_decode_exception().
975 $ret['#abort'] = array('success' => FALSE, 'query' => t('%type: !message in %function (line %line of %file).', $variables));
976 }
977 }
978
979 if (isset($context['sandbox']['#finished'])) {
980 $context['finished'] = $context['sandbox']['#finished'];
981 unset($context['sandbox']['#finished']);
982 }
983
984 if (!isset($context['results'][$module])) {
985 $context['results'][$module] = array();
986 }
987 if (!isset($context['results'][$module][$number])) {
988 $context['results'][$module][$number] = array();
989 }
990 $context['results'][$module][$number] = array_merge($context['results'][$module][$number], $ret);
991
992 if (!empty($ret['#abort'])) {
993 // Record this function in the list of updates that were aborted.
994 $context['results']['#abort'][] = $function;
995 }
996
997 // Record the schema update if it was completed successfully.
998 if ($context['finished'] == 1 && empty($ret['#abort'])) {
999 drupal_set_installed_schema_version($module, $number);
1000 }
1001
1002 $context['message'] = 'Updating ' . check_plain($module) . ' module';
1003 }
1004
1008 class DrupalUpdateException extends Exception { }
1009
1032 function update_batch($start, $redirect = NULL, $url = NULL, $batch = array(), $redirect_callback = 'drupal_goto') {
1033 // During the update, bring the site offline so that schema changes do not
1034 // affect visiting users.
1035 $_SESSION['maintenance_mode'] = variable_get('maintenance_mode', FALSE);
1036 if ($_SESSION['maintenance_mode'] == FALSE) {
1037 variable_set('maintenance_mode', TRUE);
1038 }
1039
1040 // Resolve any update dependencies to determine the actual updates that will
1041 // be run and the order they will be run in.
1042 $updates = update_resolve_dependencies($start);
1043
1044 // Store the dependencies for each update function in an array which the
1045 // batch API can pass in to the batch operation each time it is called. (We
1046 // do not store the entire update dependency array here because it is
1047 // potentially very large.)
1048 $dependency_map = array();
1049 foreach ($updates as $function => $update) {
1050 $dependency_map[$function] = !empty($update['reverse_paths']) ? array_keys($update['reverse_paths']) : array();
1051 }
1052
1053 $operations = array();
1054 foreach ($updates as $update) {
1055 if ($update['allowed']) {
1056 // Set the installed version of each module so updates will start at the
1057 // correct place. (The updates are already sorted, so we can simply base
1058 // this on the first one we come across in the above foreach loop.)
1059 if (isset($start[$update['module']])) {
1060 drupal_set_installed_schema_version($update['module'], $update['number'] - 1);
1061 unset($start[$update['module']]);
1062 }
1063 // Add this update function to the batch.
1064 $function = $update['module'] . '_update_' . $update['number'];
1065 $operations[] = array('update_do_one', array($update['module'], $update['number'], $dependency_map[$function]));
1066 }
1067 }
1068 $batch['operations'] = $operations;
1069 $batch += array(
1070 'title' => 'Updating',
1071 'init_message' => 'Starting updates',
1072 'error_message' => 'An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.',
1073 'finished' => 'update_finished',
1074 'file' => 'includes/update.inc',
1075 );
1076 batch_set($batch);
1077 batch_process($redirect, $url, $redirect_callback);
1078 }
1079
1097 function update_finished($success, $results, $operations) {
1098 // Remove the D6 upgrade flag variable so that subsequent update runs do not
1099 // get the wrong context.
1100 variable_del('update_d6');
1101
1102 // Clear the caches in case the data has been updated.
1103 drupal_flush_all_caches();
1104
1105 $_SESSION['update_results'] = $results;
1106 $_SESSION['update_success'] = $success;
1107 $_SESSION['updates_remaining'] = $operations;
1108
1109 // Now that the update is done, we can put the site back online if it was
1110 // previously in maintenance mode.
1111 if (isset($_SESSION['maintenance_mode']) && $_SESSION['maintenance_mode'] == FALSE) {
1112 variable_set('maintenance_mode', FALSE);
1113 unset($_SESSION['maintenance_mode']);
1114 }
1115 }
1116
1135 function update_get_update_list() {
1136 // Make sure that the system module is first in the list of updates.
1137 $ret = array('system' => array());
1138
1139 $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
1140 foreach ($modules as $module => $schema_version) {
1141 // Skip uninstalled and incompatible modules.
1142 if ($schema_version == SCHEMA_UNINSTALLED || update_check_incompatibility($module)) {
1143 continue;
1144 }
1145 // Otherwise, get the list of updates defined by this module.
1146 $updates = drupal_get_schema_versions($module);
1147 if ($updates !== FALSE) {
1148 // module_invoke returns NULL for nonexisting hooks, so if no updates
1149 // are removed, it will == 0.
1150 $last_removed = module_invoke($module, 'update_last_removed');
1151 if ($schema_version < $last_removed) {
1152 $ret[$module]['warning'] = '<em>' . $module . '</em> module can not be updated. Its schema version is ' . $schema_version . '. Updates up to and including ' . $last_removed . ' have been removed in this release. In order to update <em>' . $module . '</em> module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.';
1153 continue;
1154 }
1155
1156 $updates = drupal_map_assoc($updates);
1157 foreach (array_keys($updates) as $update) {
1158 if ($update > $schema_version) {
1159 // The description for an update comes from its Doxygen.
1160 $func = new ReflectionFunction($module . '_update_' . $update);
1161 $description = str_replace(array("\n", '*', '/'), '', $func->getDocComment());
1162 $ret[$module]['pending'][$update] = "$update - $description";
1163 if (!isset($ret[$module]['start'])) {
1164 $ret[$module]['start'] = $update;
1165 }
1166 }
1167 }
1168 if (!isset($ret[$module]['start']) && isset($ret[$module]['pending'])) {
1169 $ret[$module]['start'] = $schema_version;
1170 }
1171 }
1172 }
1173
1174 if (empty($ret['system'])) {
1175 unset($ret['system']);
1176 }
1177 return $ret;
1178 }
1179
1220 function update_resolve_dependencies($starting_updates) {
1221 // Obtain a dependency graph for the requested update functions.
1222 $update_functions = update_get_update_function_list($starting_updates);
1223 $graph = update_build_dependency_graph($update_functions);
1224
1225 // Perform the depth-first search and sort the results.
1226 require_once DRUPAL_ROOT . '/includes/graph.inc';
1227 drupal_depth_first_search($graph);
1228 uasort($graph, 'drupal_sort_weight');
1229
1230 foreach ($graph as $function => &$data) {
1231 $module = $data['module'];
1232 $number = $data['number'];
1233 // If the update function is missing and has not yet been performed, mark
1234 // it and everything that ultimately depends on it as disallowed.
1235 if (update_is_missing($module, $number, $update_functions) && !update_already_performed($module, $number)) {
1236 $data['allowed'] = FALSE;
1237 foreach (array_keys($data['paths']) as $dependent) {
1238 $graph[$dependent]['allowed'] = FALSE;
1239 $graph[$dependent]['missing_dependencies'][] = $function;
1240 }
1241 }
1242 elseif (!isset($data['allowed'])) {
1243 $data['allowed'] = TRUE;
1244 $data['missing_dependencies'] = array();
1245 }
1246 // Now that we have finished processing this function, remove it from the
1247 // graph if it was not part of the original list. This ensures that we
1248 // never try to run any updates that were not specifically requested.
1249 if (!isset($update_functions[$module][$number])) {
1250 unset($graph[$function]);
1251 }
1252 }
1253
1254 return $graph;
1255 }
1256
1273 function update_get_update_function_list($starting_updates) {
1274 // Go through each module and find all updates that we need (including the
1275 // first update that was requested and any updates that run after it).
1276 $update_functions = array();
1277 foreach ($starting_updates as $module => $version) {
1278 $update_functions[$module] = array();
1279 $updates = drupal_get_schema_versions($module);
1280 if ($updates !== FALSE) {
1281 $max_version = max($updates);
1282 if ($version <= $max_version) {
1283 foreach ($updates as $update) {
1284 if ($update >= $version) {
1285 $update_functions[$module][$update] = $module . '_update_' . $update;
1286 }
1287 }
1288 }
1289 }
1290 }
1291 return $update_functions;
1292 }
1293
1336 function update_build_dependency_graph($update_functions) {
1337 // Initialize an array that will define a directed graph representing the
1338 // dependencies between update functions.
1339 $graph = array();
1340
1341 // Go through each update function and build an initial list of dependencies.
1342 foreach ($update_functions as $module => $functions) {
1343 $previous_function = NULL;
1344 foreach ($functions as $number => $function) {
1345 // Add an edge to the directed graph representing the fact that each
1346 // update function in a given module must run after the update that
1347 // numerically precedes it.
1348 if ($previous_function) {
1349 $graph[$previous_function]['edges'][$function] = TRUE;
1350 }
1351 $previous_function = $function;
1352
1353 // Define the module and update number associated with this function.
1354 $graph[$function]['module'] = $module;
1355 $graph[$function]['number'] = $number;
1356 }
1357 }
1358
1359 // Now add any explicit update dependencies declared by modules.
1360 $update_dependencies = update_retrieve_dependencies();
1361 foreach ($graph as $function => $data) {
1362 if (!empty($update_dependencies[$data['module']][$data['number']])) {
1363 foreach ($update_dependencies[$data['module']][$data['number']] as $module => $number) {
1364 $dependency = $module . '_update_' . $number;
1365 $graph[$dependency]['edges'][$function] = TRUE;
1366 $graph[$dependency]['module'] = $module;
1367 $graph[$dependency]['number'] = $number;
1368 }
1369 }
1370 }
1371
1372 return $graph;
1373 }
1374
1391 function update_is_missing($module, $number, $update_functions) {
1392 return !isset($update_functions[$module][$number]) || !function_exists($update_functions[$module][$number]);
1393 }
1394
1407 function update_already_performed($module, $number) {
1408 return $number <= drupal_get_installed_schema_version($module);
1409 }
1410
1426 function update_retrieve_dependencies() {
1427 $return = array();
1428 // Get a list of installed modules, arranged so that we invoke their hooks in
1429 // the same order that module_invoke_all() does.
1430 $modules = db_query("SELECT name FROM {system} WHERE type = 'module' AND schema_version <> :schema ORDER BY weight ASC, name ASC", array(':schema' => SCHEMA_UNINSTALLED))->fetchCol();
1431 foreach ($modules as $module) {
1432 $function = $module . '_update_dependencies';
1433 if (function_exists($function)) {
1434 $result = $function();
1435 // Each implementation of hook_update_dependencies() returns a
1436 // multidimensional, associative array containing some keys that
1437 // represent module names (which are strings) and other keys that
1438 // represent update function numbers (which are integers). We cannot use
1439 // array_merge_recursive() to properly merge these results, since it
1440 // treats strings and integers differently. Therefore, we have to
1441 // explicitly loop through the expected array structure here and perform
1442 // the merge manually.
1443 if (isset($result) && is_array($result)) {
1444 foreach ($result as $module => $module_data) {
1445 foreach ($module_data as $update => $update_data) {
1446 foreach ($update_data as $module_dependency => $update_dependency) {
1447 // If there are redundant dependencies declared for the same
1448 // update function (so that it is declared to depend on more than
1449 // one update from a particular module), record the dependency on
1450 // the highest numbered update here, since that automatically
1451 // implies the previous ones. For example, if one module's
1452 // implementation of hook_update_dependencies() required this
1453 // ordering:
1454 //
1455 // system_update_7001 ---> user_update_7000
1456 //
1457 // but another module's implementation of the hook required this
1458 // one:
1459 //
1460 // system_update_7002 ---> user_update_7000
1461 //
1462 // we record the second one, since system_update_7001() is always
1463 // guaranteed to run before system_update_7002() anyway (within
1464 // an individual module, updates are always run in numerical
1465 // order).
1466 if (!isset($return[$module][$update][$module_dependency]) || $update_dependency > $return[$module][$update][$module_dependency]) {
1467 $return[$module][$update][$module_dependency] = $update_dependency;
1468 }
1469 }
1470 }
1471 }
1472 }
1473 }
1474 }
1475
1476 return $return;
1477 }
batch_process
batch_process($redirect=NULL, $url= 'batch', $redirect_callback= 'drupal_goto')
Definition: form.inc:4459
watchdog_exception
watchdog_exception($type, Exception $exception, $message=NULL, $variables=array(), $severity=WATCHDOG_ERROR, $link=NULL)
Definition: bootstrap.inc:1654
db_add_index
db_add_index($table, $name, $fields)
Definition: database.inc:2940
update_get_d6_session_name
update_get_d6_session_name()
Definition: update.inc:887
$databases
$databases
Definition: default.settings.php:213
update_get_update_list
update_get_update_list()
Definition: update.inc:1135
drupal_parse_info_file
drupal_parse_info_file($filename)
Definition: common.inc:7270
update_is_missing
update_is_missing($module, $number, $update_functions)
Definition: update.inc:1391
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
$module
print $module
Definition: search-results.tpl.php:28
db_drop_primary_key
db_drop_primary_key($table)
Definition: database.inc:2900
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
db_drop_index
db_drop_index($table, $name)
Definition: database.inc:2952
$name
print $name
Definition: profile-listing.tpl.php:43
$results
print $results
Definition: poll-results.tpl.php:23
Exception
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
update_fix_d7_block_deltas
update_fix_d7_block_deltas(&$sandbox, $renamed_deltas, $moved_deltas)
Definition: update.inc:355
print
print
Definition: php-2.php:2
db_add_field
db_add_field($table, $field, $spec, $keys_new=array())
Definition: database.inc:2840
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
drupal_verify_install_file
drupal_verify_install_file($file, $mask=NULL, $type= 'file')
Definition: install.inc:829
drupal_bootstrap
drupal_bootstrap($phase=NULL, $new_phase=TRUE)
Definition: bootstrap.inc:2192
system_rebuild_theme_data
system_rebuild_theme_data()
Definition: system.module:2609
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
update_prepare_d7_bootstrap
update_prepare_d7_bootstrap()
Definition: update.inc:81
update_fix_d7_install_profile
update_fix_d7_install_profile()
Definition: update.inc:795
$conf
global $conf
Definition: authorize.php:74
FILE_EXIST
const FILE_EXIST
Definition: install.inc:41
drupal_get_installed_schema_version
drupal_get_installed_schema_version($module, $reset=FALSE, $array=FALSE)
Definition: install.inc:146
REQUIREMENT_OK
const REQUIREMENT_OK
Definition: install.inc:26
update_build_dependency_graph
update_build_dependency_graph($update_functions)
Definition: update.inc:1336
system_rebuild_module_data
system_rebuild_module_data()
Definition: system.module:2444
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
update_already_performed
update_already_performed($module, $number)
Definition: update.inc:1407
drupal_load_updates
drupal_load_updates()
Definition: install.inc:81
update_extra_requirements
update_extra_requirements($requirements=NULL)
Definition: update.php:341
$url
print $url
Definition: search-result.tpl.php:70
batch_set
batch_set($batch_definition)
Definition: form.inc:4381
$info
$info
Definition: color.inc:6
DRUPAL_MINIMUM_PHP
const DRUPAL_MINIMUM_PHP
Definition: bootstrap.inc:21
drupal_set_installed_schema_version
drupal_set_installed_schema_version($module, $version)
Definition: install.inc:177
drupal_get_profile
drupal_get_profile()
Definition: common.inc:222
update_parse_db_url
update_parse_db_url($db_url, $db_prefix)
Definition: update.inc:855
DRUPAL_BOOTSTRAP_VARIABLES
const DRUPAL_BOOTSTRAP_VARIABLES
Definition: bootstrap.inc:137
update_finished
update_finished($success, $results, $operations)
Definition: update.inc:1097
update_do_one
update_do_one($module, $number, $dependency_map, &$context)
Definition: update.inc:951
update_get_update_function_list
update_get_update_function_list($starting_updates)
Definition: update.inc:1273
db_add_primary_key
db_add_primary_key($table, $fields)
Definition: database.inc:2890
db_like
db_like($string)
Definition: database.inc:2610
drupal_depth_first_search
drupal_depth_first_search(&$graph)
Definition: graph.inc:47
drupal_random_bytes
drupal_random_bytes($count)
Definition: bootstrap.inc:1974
REQUIRED_D6_SCHEMA_VERSION
const REQUIRED_D6_SCHEMA_VERSION
Definition: update.inc:19
update_fix_d7_requirements
update_fix_d7_requirements()
Definition: update.inc:478
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
_drupal_decode_exception
_drupal_decode_exception($exception)
Definition: errors.inc:88
SCHEMA_UNINSTALLED
const SCHEMA_UNINSTALLED
Definition: install.inc:11
db_driver
db_driver()
Definition: database.inc:2620
conf_path
conf_path($require_settings=TRUE, $reset=FALSE)
Definition: bootstrap.inc:541
update_fix_compatibility
update_fix_compatibility()
Definition: update.inc:24
drupal_flush_all_caches
drupal_flush_all_caches()
Definition: common.inc:7453
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
FILE_READABLE
const FILE_READABLE
Definition: install.inc:46
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
drupal_get_schema_versions
drupal_get_schema_versions($module)
Definition: install.inc:98
update_check_incompatibility
update_check_incompatibility($name, $type= 'module')
Definition: update.inc:43
DRUPAL_BOOTSTRAP_DATABASE
const DRUPAL_BOOTSTRAP_DATABASE
Definition: bootstrap.inc:132
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
update_resolve_dependencies
update_resolve_dependencies($starting_updates)
Definition: update.inc:1220
DRUPAL_CORE_COMPATIBILITY
const DRUPAL_CORE_COMPATIBILITY
Definition: bootstrap.inc:16
$row
$row
Definition: block-admin-display-form.tpl.php:47
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
drupal_hash_base64
drupal_hash_base64($data)
Definition: bootstrap.inc:2067
FILE_WRITABLE
const FILE_WRITABLE
Definition: install.inc:51
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
update_batch
update_batch($start, $redirect=NULL, $url=NULL, $batch=array(), $redirect_callback= 'drupal_goto')
Definition: update.inc:1032
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
system_schema_cache_7054
system_schema_cache_7054()
Definition: system.install:1660
DrupalUpdateException
Definition: update.inc:1008
DatabaseTaskException
Definition: install.inc:581
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
db_table_exists
db_table_exists($table)
Definition: database.inc:2760
db_run_tasks
db_run_tasks($driver)
Definition: install.inc:1317
db_rename_table
db_rename_table($table, $new_name)
Definition: database.inc:2805
update_retrieve_dependencies
update_retrieve_dependencies()
Definition: update.inc:1426
DRUPAL_BOOTSTRAP_CONFIGURATION
const DRUPAL_BOOTSTRAP_CONFIGURATION
Definition: bootstrap.inc:122
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/token.inc Source File

  • includes
token.inc
Go to the documentation of this file.
1 <?php
2
79 function token_replace($text, array $data = array(), array $options = array()) {
80 $text_tokens = token_scan($text);
81 if (empty($text_tokens)) {
82 return $text;
83 }
84
85 $replacements = array();
86 foreach ($text_tokens as $type => $tokens) {
87 $replacements += token_generate($type, $tokens, $data, $options);
88 if (!empty($options['clear'])) {
89 $replacements += array_fill_keys($tokens, '');
90 }
91 }
92
93 // Optionally alter the list of replacement values.
94 if (!empty($options['callback']) && function_exists($options['callback'])) {
95 $function = $options['callback'];
96 $function($replacements, $data, $options);
97 }
98
99 $tokens = array_keys($replacements);
100 $values = array_values($replacements);
101
102 return str_replace($tokens, $values, $text);
103 }
104
114 function token_scan($text) {
115 // Matches tokens with the following pattern: [$type:$name]
116 // $type and $name may not contain [ ] characters.
117 // $type may not contain : or whitespace characters, but $name may.
118 preg_match_all('/
119 \[ # [ - pattern start
120 ([^\s\[\]:]*) # match $type not containing whitespace : [ or ]
121 : # : - separator
122 ([^\[\]]*) # match $name not containing [ or ]
123 \] # ] - pattern end
124 /x', $text, $matches);
125
126 $types = $matches[1];
127 $tokens = $matches[2];
128
129 // Iterate through the matches, building an associative array containing
130 // $tokens grouped by $types, pointing to the version of the token found in
131 // the source text. For example, $results['node']['title'] = '[node:title]';
132 $results = array();
133 for ($i = 0; $i < count($tokens); $i++) {
134 $results[$types[$i]][$tokens[$i]] = $matches[0][$i];
135 }
136
137 return $results;
138 }
139
176 function token_generate($type, array $tokens, array $data = array(), array $options = array()) {
177 $options += array('sanitize' => TRUE);
178 $replacements = module_invoke_all('tokens', $type, $tokens, $data, $options);
179
180 // Allow other modules to alter the replacements.
181 $context = array(
182 'type' => $type,
183 'tokens' => $tokens,
184 'data' => $data,
185 'options' => $options,
186 );
187 drupal_alter('tokens', $replacements, $context);
188
189 return $replacements;
190 }
191
219 function token_find_with_prefix(array $tokens, $prefix, $delimiter = ':') {
220 $results = array();
221 foreach ($tokens as $token => $raw) {
222 $parts = explode($delimiter, $token, 2);
223 if (count($parts) == 2 && $parts[0] == $prefix) {
224 $results[$parts[1]] = $raw;
225 }
226 }
227 return $results;
228 }
229
257 function token_info() {
258 $data = &drupal_static(__FUNCTION__);
259 if (!isset($data)) {
260 $data = module_invoke_all('token_info');
261 drupal_alter('token_info', $data);
262 }
263 return $data;
264 }
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
token_generate
token_generate($type, array $tokens, array $data=array(), array $options=array())
Definition: token.inc:176
token_scan
token_scan($text)
Definition: token.inc:114
$results
print $results
Definition: poll-results.tpl.php:23
token_replace
token_replace($text, array $data=array(), array $options=array())
Definition: token.inc:79
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
token_info
token_info()
Definition: token.inc:257
token_find_with_prefix
token_find_with_prefix(array $tokens, $prefix, $delimiter= ':')
Definition: token.inc:219
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/locale/locale.api.php Source File

  • modules
  • locale
locale.api.php
Go to the documentation of this file.
1 <?php
2
19 function hook_locale($op = 'groups') {
20 switch ($op) {
21 case 'groups':
22 return array('custom' => t('Custom'));
23 }
24 }
25
35 function hook_multilingual_settings_changed() {
36 field_info_cache_clear();
37 }
38
$op
$op
Definition: update.php:404
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
field_info_cache_clear
field_info_cache_clear()
Definition: field.info.inc:54
hook_multilingual_settings_changed
hook_multilingual_settings_changed()
Definition: locale.api.php:35
hook_locale
hook_locale($op= 'groups')
Definition: locale.api.php:19
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user.api.php Source File

  • modules
  • user
user.api.php
Go to the documentation of this file.
1 <?php
2
26 function hook_user_load($users) {
27 $result = db_query('SELECT uid, foo FROM {my_table} WHERE uid IN (:uids)', array(':uids' => array_keys($users)));
28 foreach ($result as $record) {
29 $users[$record->uid]->foo = $record->foo;
30 }
31 }
32
47 function hook_user_delete($account) {
48 db_delete('mytable')
49 ->condition('uid', $account->uid)
50 ->execute();
51 }
52
78 function hook_user_cancel($edit, $account, $method) {
79 switch ($method) {
80 case 'user_cancel_block_unpublish':
81 // Unpublish nodes (current revisions).
82 module_load_include('inc', 'node', 'node.admin');
83 $nodes = db_select('node', 'n')
84 ->fields('n', array('nid'))
85 ->condition('uid', $account->uid)
86 ->execute()
87 ->fetchCol();
88 node_mass_update($nodes, array('status' => 0));
89 break;
90
91 case 'user_cancel_reassign':
92 // Anonymize nodes (current revisions).
93 module_load_include('inc', 'node', 'node.admin');
94 $nodes = db_select('node', 'n')
95 ->fields('n', array('nid'))
96 ->condition('uid', $account->uid)
97 ->execute()
98 ->fetchCol();
99 node_mass_update($nodes, array('uid' => 0));
100 // Anonymize old revisions.
101 db_update('node_revision')
102 ->fields(array('uid' => 0))
103 ->condition('uid', $account->uid)
104 ->execute();
105 // Clean history.
106 db_delete('history')
107 ->condition('uid', $account->uid)
108 ->execute();
109 break;
110 }
111 }
112
135 function hook_user_cancel_methods_alter(&$methods) {
136 // Limit access to disable account and unpublish content method.
137 $methods['user_cancel_block_unpublish']['access'] = user_access('administer site configuration');
138
139 // Remove the content re-assigning method.
140 unset($methods['user_cancel_reassign']);
141
142 // Add a custom zero-out method.
143 $methods['mymodule_zero_out'] = array(
144 'title' => t('Delete the account and remove all content.'),
145 'description' => t('All your content will be replaced by empty strings.'),
146 // access should be used for administrative methods only.
147 'access' => user_access('access zero-out account cancellation method'),
148 );
149 }
150
168 function hook_user_operations() {
169 $operations = array(
170 'unblock' => array(
171 'label' => t('Unblock the selected users'),
172 'callback' => 'user_user_operations_unblock',
173 ),
174 'block' => array(
175 'label' => t('Block the selected users'),
176 'callback' => 'user_user_operations_block',
177 ),
178 'cancel' => array(
179 'label' => t('Cancel the selected user accounts'),
180 ),
181 );
182 return $operations;
183 }
184
200 function hook_user_categories() {
201 return array(array(
202 'name' => 'account',
203 'title' => t('Account settings'),
204 'weight' => 1,
205 ));
206 }
207
228 function hook_user_presave(&$edit, $account, $category) {
229 // Make sure that our form value 'mymodule_foo' is stored as
230 // 'mymodule_bar' in the 'data' (serialized) column.
231 if (isset($edit['mymodule_foo'])) {
232 $edit['data']['mymodule_bar'] = $edit['mymodule_foo'];
233 }
234 }
235
252 function hook_user_insert(&$edit, $account, $category) {
253 db_insert('mytable')
254 ->fields(array(
255 'myfield' => $edit['myfield'],
256 'uid' => $account->uid,
257 ))
258 ->execute();
259 }
260
277 function hook_user_update(&$edit, $account, $category) {
278 db_insert('user_changes')
279 ->fields(array(
280 'uid' => $account->uid,
281 'changed' => time(),
282 ))
283 ->execute();
284 }
285
294 function hook_user_login(&$edit, $account) {
295 // If the user has a NULL time zone, notify them to set a time zone.
296 if (!$account->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) {
297 drupal_set_message(t('Configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
298 }
299 }
300
315 function hook_user_logout($account) {
316 db_insert('logouts')
317 ->fields(array(
318 'uid' => $account->uid,
319 'time' => time(),
320 ))
321 ->execute();
322 }
323
348 function hook_user_view($account, $view_mode, $langcode) {
349 if (user_access('create blog content', $account)) {
350 $account->content['summary']['blog'] = array(
351 '#type' => 'user_profile_item',
352 '#title' => t('Blog'),
353 '#markup' => l(t('View recent blog entries'), "blog/$account->uid", array('attributes' => array('title' => t("Read !username's latest blog entries.", array('!username' => format_username($account)))))),
354 '#attributes' => array('class' => array('blog')),
355 );
356 }
357 }
358
377 function hook_user_view_alter(&$build) {
378 // Check for the existence of a field added by another module.
379 if (isset($build['an_additional_field'])) {
380 // Change its weight.
381 $build['an_additional_field']['#weight'] = -10;
382 }
383
384 // Add a #post_render callback to act on the rendered HTML of the user.
385 $build['#post_render'][] = 'my_module_user_post_render';
386 }
387
400 function hook_user_role_presave($role) {
401 // Set a UUID for the user role if it doesn't already exist
402 if (empty($role->uuid)) {
403 $role->uuid = uuid_uuid();
404 }
405 }
406
418 function hook_user_role_insert($role) {
419 // Save extra fields provided by the module to user roles.
420 db_insert('my_module_table')
421 ->fields(array(
422 'rid' => $role->rid,
423 'role_description' => $role->description,
424 ))
425 ->execute();
426 }
427
439 function hook_user_role_update($role) {
440 // Save extra fields provided by the module to user roles.
441 db_merge('my_module_table')
442 ->key(array('rid' => $role->rid))
443 ->fields(array(
444 'role_description' => $role->description
445 ))
446 ->execute();
447 }
448
460 function hook_user_role_delete($role) {
461 // Delete existing instances of the deleted role.
462 db_delete('my_module_table')
463 ->condition('rid', $role->rid)
464 ->execute();
465 }
466
hook_user_role_insert
hook_user_role_insert($role)
Definition: user.api.php:418
hook_user_cancel
hook_user_cancel($edit, $account, $method)
Definition: user.api.php:78
l
l($text, $path, array $options=array())
Definition: common.inc:2432
format_username
format_username($account)
Definition: common.inc:2106
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
hook_user_login
hook_user_login(&$edit, $account)
Definition: user.api.php:294
hook_user_logout
hook_user_logout($account)
Definition: user.api.php:315
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
hook_user_role_delete
hook_user_role_delete($role)
Definition: user.api.php:460
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
hook_user_update
hook_user_update(&$edit, $account, $category)
Definition: user.api.php:277
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
user_access
user_access($string, $account=NULL)
Definition: user.module:794
hook_user_delete
hook_user_delete($account)
Definition: user.api.php:47
hook_user_categories
hook_user_categories()
Definition: user.api.php:200
hook_user_view
hook_user_view($account, $view_mode, $langcode)
Definition: user.api.php:348
hook_user_cancel_methods_alter
hook_user_cancel_methods_alter(&$methods)
Definition: user.api.php:135
hook_user_role_presave
hook_user_role_presave($role)
Definition: user.api.php:400
hook_user_insert
hook_user_insert(&$edit, $account, $category)
Definition: user.api.php:252
hook_user_operations
hook_user_operations()
Definition: user.api.php:168
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
hook_user_presave
hook_user_presave(&$edit, $account, $category)
Definition: user.api.php:228
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
hook_user_view_alter
hook_user_view_alter(&$build)
Definition: user.api.php:377
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
node_mass_update
node_mass_update($nodes, $updates)
Definition: node.admin.inc:279
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
hook_user_load
hook_user_load($users)
Definition: user.api.php:26
hook_user_role_update
hook_user_role_update($role)
Definition: user.api.php:439
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
FileTransferSSH Member List

This is the complete list of members for FileTransferSSH, including all inherited members.

$hostname | FileTransfer | protected
$password | FileTransfer | protected
$port | FileTransfer | protected
$username | FileTransfer | protected
__construct($jail, $username, $password, $hostname="localhost", $port=22) | FileTransferSSH |
FileTransfer::__construct($jail) | FileTransfer |
__get($name) | FileTransfer |
checkPath($path) | FileTransfer | protected
chmod($path, $mode, $recursive=FALSE) | FileTransfer |
chmodJailed($path, $mode, $recursive) | FileTransferSSH |
connect() | FileTransferSSH |
copyDirectory($source, $destination) | FileTransfer |
copyDirectoryJailed($source, $destination) | FileTransferSSH | protected
copyFile($source, $destination) | FileTransfer |
copyFileJailed($source, $destination) | FileTransferSSH | protected
createDirectory($directory) | FileTransfer |
createDirectoryJailed($directory) | FileTransferSSH | protected
factory($jail, $settings) | FileTransferSSH | static
findChroot() | FileTransfer |
fixRemotePath($path, $strip_chroot=TRUE) | FileTransfer | protected
getSettingsForm() | FileTransferSSH |
isDirectory($path) | FileTransferSSH |
isFile($path) | FileTransferSSH |
removeDirectory($directory) | FileTransfer |
removeDirectoryJailed($directory) | FileTransferSSH | protected
removeFile($destination) | FileTransfer |
removeFileJailed($destination) | FileTransferSSH | protected
sanitizePath($path) | FileTransfer |
setChroot() | FileTransfer |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/syslog/syslog.install Source File

  • modules
  • syslog
syslog.install
Go to the documentation of this file.
1 <?php
2
11 function syslog_uninstall() {
12 variable_del('syslog_identity');
13 variable_del('syslog_facility');
14 variable_del('syslog_format');
15 }
variable_del
variable_del($name)
Definition: bootstrap.inc:996
syslog_uninstall
syslog_uninstall()
Definition: syslog.install:11
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/dashboard/dashboard.api.php Source File

  • modules
  • dashboard
dashboard.api.php
Go to the documentation of this file.
1 <?php
2
21 function hook_dashboard_regions() {
22 // Define a new dashboard region. Your module can also then define
23 // theme_mymodule_dashboard_region() as a theme wrapper function to control
24 // the region's appearance.
25 return array('mymodule_dashboard_region' => "My module's dashboard region");
26 }
27
35 function hook_dashboard_regions_alter(&$regions) {
36 // Remove the sidebar region defined by the core dashboard module.
37 unset($regions['dashboard_sidebar']);
38 }
39
hook_dashboard_regions
hook_dashboard_regions()
Definition: dashboard.api.php:21
hook_dashboard_regions_alter
hook_dashboard_regions_alter(&$regions)
Definition: dashboard.api.php:35
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book-all-books-block.tpl.php Source File

  • modules
  • book
book-all-books-block.tpl.php
Go to the documentation of this file.
1 <?php
2
18 ?>
19 <?php foreach ($book_menus as $book_id => $menu): ?>
20 <div id="book-block-menu-<?php print $book_id; ?>" class="book-block-menu">
21 <?php print render($menu); ?>
22 </div>
23 <?php endforeach; ?>
print
print
Definition: php-2.php:2
endforeach
endforeach
Definition: block-admin-display-form.tpl.php:64
render
render(&$element)
Definition: common.inc:5988
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book.module Source File

  • modules
  • book
book.module
Go to the documentation of this file.
1 <?php
2
11 function book_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#book':
14 $output = '<h3>' . t('About') . '</h3>';
15 $output .= '<p>' . t('The Book module is used for creating structured, multi-page content, such as site resource guides, manuals, and wikis. It allows you to create content that has chapters, sections, subsections, or any similarly-tiered structure. For more information, see the online handbook entry for <a href="@book">Book module</a>.', array('@book' => 'http://drupal.org/documentation/modules/book/')) . '</p>';
16 $output .= '<h3>' . t('Uses') . '</h3>';
17 $output .= '<dl>';
18 $output .= '<dt>' . t('Adding and managing book content') . '</dt>';
19 $output .= '<dd>' . t('You can assign separate permissions for <em>creating</em>, <em>editing</em>, and <em>deleting</em> book content, as well as <em>adding content to books</em>, and <em>creating new books</em>. Users with the <em>Administer book outlines</em> permission can add <em>any</em> type of content to a book by selecting the appropriate book outline while editing the content. They can also view a list of all books, and edit and rearrange section titles on the <a href="@admin-book">Book administration page</a>.', array('@admin-book' => url('admin/content/book'))) . '</dd>';
20 $output .= '<dt>' . t('Book navigation') . '</dt>';
21 $output .= '<dd>' . t("Book pages have a default book-specific navigation block. This navigation block contains links that lead to the previous and next pages in the book, and to the level above the current page in the book's structure. This block can be enabled on the <a href='@admin-block'>Blocks administration page</a>. For book pages to show up in the book navigation, they must be added to a book outline.", array('@admin-block' => url('admin/structure/block'))) . '</dd>';
22 $output .= '<dt>' . t('Collaboration') . '</dt>';
23 $output .= '<dd>' . t('Books can be created collaboratively, as they allow users with appropriate permissions to add pages into existing books, and add those pages to a custom table of contents menu.') . '</dd>';
24 $output .= '<dt>' . t('Printing books') . '</dt>';
25 $output .= '<dd>' . t("Users with the <em>View printer-friendly books</em> permission can select the <em>printer-friendly version</em> link visible at the bottom of a book page's content to generate a printer-friendly display of the page and all of its subsections.") . '</dd>';
26 $output .= '</dl>';
27 return $output;
28 case 'admin/content/book':
29 return '<p>' . t('The book module offers a means to organize a collection of related content pages, collectively known as a book. When viewed, this content automatically displays links to adjacent book pages, providing a simple navigation system for creating and reviewing structured content.') . '</p>';
30 case 'node/%/outline':
31 return '<p>' . t('The outline feature allows you to include pages in the <a href="@book">Book hierarchy</a>, as well as move them within the hierarchy or to <a href="@book-admin">reorder an entire book</a>.', array('@book' => url('book'), '@book-admin' => url('admin/content/book'))) . '</p>';
32 }
33 }
34
38 function book_theme() {
39 return array(
40 'book_navigation' => array(
41 'variables' => array('book_link' => NULL),
42 'template' => 'book-navigation',
43 ),
44 'book_export_html' => array(
45 'variables' => array('title' => NULL, 'contents' => NULL, 'depth' => NULL),
46 'template' => 'book-export-html',
47 ),
48 'book_admin_table' => array(
49 'render element' => 'form',
50 ),
51 'book_title_link' => array(
52 'variables' => array('link' => NULL),
53 ),
54 'book_all_books_block' => array(
55 'render element' => 'book_menus',
56 'template' => 'book-all-books-block',
57 ),
58 'book_node_export_html' => array(
59 'variables' => array('node' => NULL, 'children' => NULL),
60 'template' => 'book-node-export-html',
61 ),
62 );
63 }
64
68 function book_permission() {
69 return array(
70 'administer book outlines' => array(
71 'title' => t('Administer book outlines'),
72 ),
73 'create new books' => array(
74 'title' => t('Create new books'),
75 ),
76 'add content to books' => array(
77 'title' => t('Add content and child pages to books'),
78 ),
79 'access printer-friendly version' => array(
80 'title' => t('View printer-friendly books'),
81 'description' => t('View a book page and all of its sub-pages as a single document for ease of printing. Can be performance heavy.'),
82 ),
83 );
84 }
85
94 function book_node_view_link($node, $view_mode) {
95 $links = array();
96
97 if (isset($node->book['depth'])) {
98 if ($view_mode == 'full' && node_is_page($node)) {
99 $child_type = variable_get('book_child_type', 'book');
100 if ((user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && $node->book['depth'] < MENU_MAX_DEPTH) {
101 $links['book_add_child'] = array(
102 'title' => t('Add child page'),
103 'href' => 'node/add/' . str_replace('_', '-', $child_type),
104 'query' => array('parent' => $node->book['mlid']),
105 );
106 }
107
108 if (user_access('access printer-friendly version')) {
109 $links['book_printer'] = array(
110 'title' => t('Printer-friendly version'),
111 'href' => 'book/export/html/' . $node->nid,
112 'attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.'))
113 );
114 }
115 }
116 }
117
118 if (!empty($links)) {
119 $node->content['links']['book'] = array(
120 '#theme' => 'links__node__book',
121 '#links' => $links,
122 '#attributes' => array('class' => array('links', 'inline')),
123 );
124 }
125 }
126
130 function book_menu() {
131 $items['admin/content/book'] = array(
132 'title' => 'Books',
133 'description' => "Manage your site's book outlines.",
134 'page callback' => 'book_admin_overview',
135 'access arguments' => array('administer book outlines'),
136 'type' => MENU_LOCAL_TASK,
137 'file' => 'book.admin.inc',
138 );
139 $items['admin/content/book/list'] = array(
140 'title' => 'List',
141 'type' => MENU_DEFAULT_LOCAL_TASK,
142 );
143 $items['admin/content/book/settings'] = array(
144 'title' => 'Settings',
145 'page callback' => 'drupal_get_form',
146 'page arguments' => array('book_admin_settings'),
147 'access arguments' => array('administer site configuration'),
148 'type' => MENU_LOCAL_TASK,
149 'weight' => 8,
150 'file' => 'book.admin.inc',
151 );
152 $items['admin/content/book/%node'] = array(
153 'title' => 'Re-order book pages and change titles',
154 'page callback' => 'drupal_get_form',
155 'page arguments' => array('book_admin_edit', 3),
156 'access callback' => '_book_outline_access',
157 'access arguments' => array(3),
158 'type' => MENU_CALLBACK,
159 'file' => 'book.admin.inc',
160 );
161 $items['book'] = array(
162 'title' => 'Books',
163 'page callback' => 'book_render',
164 'access arguments' => array('access content'),
165 'type' => MENU_SUGGESTED_ITEM,
166 'file' => 'book.pages.inc',
167 );
168 $items['book/export/%/%'] = array(
169 'page callback' => 'book_export',
170 'page arguments' => array(2, 3),
171 'access arguments' => array('access printer-friendly version'),
172 'type' => MENU_CALLBACK,
173 'file' => 'book.pages.inc',
174 );
175 $items['node/%node/outline'] = array(
176 'title' => 'Outline',
177 'page callback' => 'book_outline',
178 'page arguments' => array(1),
179 'access callback' => '_book_outline_access',
180 'access arguments' => array(1),
181 'type' => MENU_LOCAL_TASK,
182 'weight' => 2,
183 'file' => 'book.pages.inc',
184 );
185 $items['node/%node/outline/remove'] = array(
186 'title' => 'Remove from outline',
187 'page callback' => 'drupal_get_form',
188 'page arguments' => array('book_remove_form', 1),
189 'access callback' => '_book_outline_remove_access',
190 'access arguments' => array(1),
191 'file' => 'book.pages.inc',
192 );
193
194 return $items;
195 }
196
203 function _book_outline_access($node) {
204 return user_access('administer book outlines') && node_access('view', $node);
205 }
206
215 function _book_outline_remove_access($node) {
216 return _book_node_is_removable($node) && _book_outline_access($node);
217 }
218
228 function _book_node_is_removable($node) {
229 return (!empty($node->book['bid']) && (($node->book['bid'] != $node->nid) || !$node->book['has_children']));
230 }
231
235 function book_admin_paths() {
236 if (variable_get('node_admin_theme')) {
237 $paths = array(
238 'node/*/outline' => TRUE,
239 'node/*/outline/remove' => TRUE,
240 );
241 return $paths;
242 }
243 }
244
248 function book_entity_info_alter(&$info) {
249 // Add the 'Print' view mode for nodes.
250 $info['node']['view modes'] += array(
251 'print' => array(
252 'label' => t('Print'),
253 'custom settings' => FALSE,
254 ),
255 );
256 }
257
261 function book_block_info() {
262 $block = array();
263 $block['navigation']['info'] = t('Book navigation');
264 $block['navigation']['cache'] = DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE;
265
266 return $block;
267 }
268
275 function book_block_view($delta = '') {
276 $block = array();
277 $current_bid = 0;
278 if ($node = menu_get_object()) {
279 $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid'];
280 }
281
282 if (variable_get('book_block_mode', 'all pages') == 'all pages') {
283 $block['subject'] = t('Book navigation');
284 $book_menus = array();
285 $pseudo_tree = array(0 => array('below' => FALSE));
286 foreach (book_get_books() as $book_id => $book) {
287 if ($book['bid'] == $current_bid) {
288 // If the current page is a node associated with a book, the menu
289 // needs to be retrieved.
290 $book_menus[$book_id] = menu_tree_output(menu_tree_all_data($node->book['menu_name'], $node->book));
291 }
292 else {
293 // Since we know we will only display a link to the top node, there
294 // is no reason to run an additional menu tree query for each book.
295 $book['in_active_trail'] = FALSE;
296 // Check whether user can access the book link.
297 $book_node = node_load($book['nid']);
298 $book['access'] = node_access('view', $book_node);
299 $pseudo_tree[0]['link'] = $book;
300 $book_menus[$book_id] = menu_tree_output($pseudo_tree);
301 }
302 }
303 $book_menus['#theme'] = 'book_all_books_block';
304 $block['content'] = $book_menus;
305 }
306 elseif ($current_bid) {
307 // Only display this block when the user is browsing a book.
308 $select = db_select('node', 'n')
309 ->fields('n', array('title'))
310 ->condition('n.nid', $node->book['bid'])
311 ->addTag('node_access');
312 $title = $select->execute()->fetchField();
313 // Only show the block if the user has view access for the top-level node.
314 if ($title) {
315 $tree = menu_tree_all_data($node->book['menu_name'], $node->book);
316 // There should only be one element at the top level.
317 $data = array_shift($tree);
318 $block['subject'] = theme('book_title_link', array('link' => $data['link']));
319 $block['content'] = ($data['below']) ? menu_tree_output($data['below']) : '';
320 }
321 }
322
323 return $block;
324 }
325
329 function book_block_configure($delta = '') {
330 $block = array();
331 $options = array(
332 'all pages' => t('Show block on all pages'),
333 'book pages' => t('Show block only on book pages'),
334 );
335 $form['book_block_mode'] = array(
336 '#type' => 'radios',
337 '#title' => t('Book navigation block display'),
338 '#options' => $options,
339 '#default_value' => variable_get('book_block_mode', 'all pages'),
340 '#description' => t("If <em>Show block on all pages</em> is selected, the block will contain the automatically generated menus for all of the site's books. If <em>Show block only on book pages</em> is selected, the block will contain only the one menu corresponding to the current page's book. In this case, if the current page is not in a book, no block will be displayed. The <em>Page specific visibility settings</em> or other visibility settings can be used in addition to selectively display this block."),
341 );
342
343 return $form;
344 }
345
349 function book_block_save($delta = '', $edit = array()) {
350 $block = array();
351 variable_set('book_block_mode', $edit['book_block_mode']);
352 }
353
363 function theme_book_title_link($variables) {
364 $link = $variables['link'];
365
366 $link['options']['attributes']['class'] = array('book-title');
367
368 return l($link['title'], $link['href'], $link['options']);
369 }
370
380 function book_get_books() {
381 $all_books = &drupal_static(__FUNCTION__);
382
383 if (!isset($all_books)) {
384 $all_books = array();
385 $nids = db_query("SELECT DISTINCT(bid) FROM {book}")->fetchCol();
386
387 if ($nids) {
388 $query = db_select('book', 'b', array('fetch' => PDO::FETCH_ASSOC));
389 $query->join('node', 'n', 'b.nid = n.nid');
390 $query->join('menu_links', 'ml', 'b.mlid = ml.mlid');
391 $query->addField('n', 'type', 'type');
392 $query->addField('n', 'title', 'title');
393 $query->fields('b');
394 $query->fields('ml');
395 $query->condition('n.nid', $nids, 'IN');
396 $query->condition('n.status', 1);
397 $query->orderBy('ml.weight');
398 $query->orderBy('ml.link_title');
399 $query->addTag('node_access');
400 $result2 = $query->execute();
401 foreach ($result2 as $link) {
402 $link['href'] = $link['link_path'];
403 $link['options'] = unserialize($link['options']);
404 $all_books[$link['bid']] = $link;
405 }
406 }
407 }
408
409 return $all_books;
410 }
411
419 function book_form_node_form_alter(&$form, &$form_state, $form_id) {
420 $node = $form['#node'];
421 $access = user_access('administer book outlines');
422 if (!$access) {
423 if (user_access('add content to books') && ((!empty($node->book['mlid']) && !empty($node->nid)) || book_type_is_allowed($node->type))) {
424 // Already in the book hierarchy, or this node type is allowed.
425 $access = TRUE;
426 }
427 }
428
429 if ($access) {
430 _book_add_form_elements($form, $form_state, $node);
431 // Since the "Book" dropdown can't trigger a form submission when
432 // JavaScript is disabled, add a submit button to do that. book.css hides
433 // this button when JavaScript is enabled.
434 $form['book']['pick-book'] = array(
435 '#type' => 'submit',
436 '#value' => t('Change book (update list of parents)'),
437 '#submit' => array('book_pick_book_nojs_submit'),
438 '#weight' => 20,
439 );
440 }
441 }
442
455 function book_pick_book_nojs_submit($form, &$form_state) {
456 $form_state['node']->book = $form_state['values']['book'];
457 $form_state['rebuild'] = TRUE;
458 }
459
473 function _book_parent_select($book_link) {
474 if (variable_get('menu_override_parent_selector', FALSE)) {
475 return array();
476 }
477 // Offer a message or a drop-down to choose a different parent page.
478 $form = array(
479 '#type' => 'hidden',
480 '#value' => -1,
481 '#prefix' => '<div id="edit-book-plid-wrapper">',
482 '#suffix' => '</div>',
483 );
484
485 if ($book_link['nid'] === $book_link['bid']) {
486 // This is a book - at the top level.
487 if ($book_link['original_bid'] === $book_link['bid']) {
488 $form['#prefix'] .= '<em>' . t('This is the top-level page in this book.') . '</em>';
489 }
490 else {
491 $form['#prefix'] .= '<em>' . t('This will be the top-level page in this book.') . '</em>';
492 }
493 }
494 elseif (!$book_link['bid']) {
495 $form['#prefix'] .= '<em>' . t('No book selected.') . '</em>';
496 }
497 else {
498 $form = array(
499 '#type' => 'select',
500 '#title' => t('Parent item'),
501 '#default_value' => $book_link['plid'],
502 '#description' => t('The parent page in the book. The maximum depth for a book and all child pages is !maxdepth. Some pages in the selected book may not be available as parents if selecting them would exceed this limit.', array('!maxdepth' => MENU_MAX_DEPTH)),
503 '#options' => book_toc($book_link['bid'], $book_link['parent_depth_limit'], array($book_link['mlid'])),
504 '#attributes' => array('class' => array('book-title-select')),
505 '#prefix' => '<div id="edit-book-plid-wrapper">',
506 '#suffix' => '</div>',
507 );
508 }
509
510 return $form;
511 }
512
519 function _book_add_form_elements(&$form, &$form_state, $node) {
520 // If the form is being processed during the Ajax callback of our book bid
521 // dropdown, then $form_state will hold the value that was selected.
522 if (isset($form_state['values']['book'])) {
523 $node->book = $form_state['values']['book'];
524 }
525
526 $form['book'] = array(
527 '#type' => 'fieldset',
528 '#title' => t('Book outline'),
529 '#weight' => 10,
530 '#collapsible' => TRUE,
531 '#collapsed' => TRUE,
532 '#group' => 'additional_settings',
533 '#attributes' => array(
534 'class' => array('book-outline-form'),
535 ),
536 '#attached' => array(
537 'js' => array(drupal_get_path('module', 'book') . '/book.js'),
538 ),
539 '#tree' => TRUE,
540 );
541 foreach (array('menu_name', 'mlid', 'nid', 'router_path', 'has_children', 'options', 'module', 'original_bid', 'parent_depth_limit') as $key) {
542 $form['book'][$key] = array(
543 '#type' => 'value',
544 '#value' => $node->book[$key],
545 );
546 }
547
548 $form['book']['plid'] = _book_parent_select($node->book);
549
550 // @see _book_admin_table_tree(). The weight may be larger than 15.
551 $form['book']['weight'] = array(
552 '#type' => 'weight',
553 '#title' => t('Weight'),
554 '#default_value' => $node->book['weight'],
555 '#delta' => max(15, abs($node->book['weight'])),
556 '#weight' => 5,
557 '#description' => t('Pages at a given level are ordered first by weight and then by title.'),
558 );
559 $options = array();
560 $nid = isset($node->nid) ? $node->nid : 'new';
561
562 if (isset($node->nid) && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) {
563 // This is the top level node in a maximum depth book and thus cannot be moved.
564 $options[$node->nid] = $node->title;
565 }
566 else {
567 foreach (book_get_books() as $book) {
568 $options[$book['nid']] = $book['title'];
569 }
570 }
571
572 if (user_access('create new books') && ($nid == 'new' || ($nid != $node->book['original_bid']))) {
573 // The node can become a new book, if it is not one already.
574 $options = array($nid => '<' . t('create a new book') . '>') + $options;
575 }
576 if (!$node->book['mlid']) {
577 // The node is not currently in the hierarchy.
578 $options = array(0 => '<' . t('none') . '>') + $options;
579 }
580
581 // Add a drop-down to select the destination book.
582 $form['book']['bid'] = array(
583 '#type' => 'select',
584 '#title' => t('Book'),
585 '#default_value' => $node->book['bid'],
586 '#options' => $options,
587 '#access' => (bool) $options,
588 '#description' => t('Your page will be a part of the selected book.'),
589 '#weight' => -5,
590 '#attributes' => array('class' => array('book-title-select')),
591 '#ajax' => array(
592 'callback' => 'book_form_update',
593 'wrapper' => 'edit-book-plid-wrapper',
594 'effect' => 'fade',
595 'speed' => 'fast',
596 ),
597 );
598 }
599
609 function book_form_update($form, $form_state) {
610 return $form['book']['plid'];
611 }
612
626 function _book_update_outline($node) {
627 if (empty($node->book['bid'])) {
628 return FALSE;
629 }
630 $new = empty($node->book['mlid']);
631
632 $node->book['link_path'] = 'node/' . $node->nid;
633 $node->book['link_title'] = $node->title;
634 $node->book['parent_mismatch'] = FALSE; // The normal case.
635
636 if ($node->book['bid'] == $node->nid) {
637 $node->book['plid'] = 0;
638 $node->book['menu_name'] = book_menu_name($node->nid);
639 }
640 else {
641 // Check in case the parent is not is this book; the book takes precedence.
642 if (!empty($node->book['plid'])) {
643 $parent = db_query("SELECT * FROM {book} WHERE mlid = :mlid", array(
644 ':mlid' => $node->book['plid'],
645 ))->fetchAssoc();
646 }
647 if (empty($node->book['plid']) || !$parent || $parent['bid'] != $node->book['bid']) {
648 $node->book['plid'] = db_query("SELECT mlid FROM {book} WHERE nid = :nid", array(
649 ':nid' => $node->book['bid'],
650 ))->fetchField();
651 $node->book['parent_mismatch'] = TRUE; // Likely when JS is disabled.
652 }
653 }
654
655 if (menu_link_save($node->book)) {
656 if ($new) {
657 // Insert new.
658 db_insert('book')
659 ->fields(array(
660 'nid' => $node->nid,
661 'mlid' => $node->book['mlid'],
662 'bid' => $node->book['bid'],
663 ))
664 ->execute();
665 // Reset the cache of stored books.
666 drupal_static_reset('book_get_books');
667 }
668 else {
669 if ($node->book['bid'] != db_query("SELECT bid FROM {book} WHERE nid = :nid", array(
670 ':nid' => $node->nid,
671 ))->fetchField()) {
672 // Update the bid for this page and all children.
673 book_update_bid($node->book);
674 // Reset the cache of stored books.
675 drupal_static_reset('book_get_books');
676 }
677 }
678
679 return TRUE;
680 }
681
682 // Failed to save the menu link.
683 return FALSE;
684 }
685
692 function book_update_bid($book_link) {
693 $query = db_select('menu_links');
694 $query->addField('menu_links', 'mlid');
695 for ($i = 1; $i <= MENU_MAX_DEPTH && $book_link["p$i"]; $i++) {
696 $query->condition("p$i", $book_link["p$i"]);
697 }
698 $mlids = $query->execute()->fetchCol();
699
700 if ($mlids) {
701 db_update('book')
702 ->fields(array('bid' => $book_link['bid']))
703 ->condition('mlid', $mlids, 'IN')
704 ->execute();
705 }
706 }
707
721 function book_get_flat_menu($book_link) {
722 $flat = &drupal_static(__FUNCTION__, array());
723
724 if (!isset($flat[$book_link['mlid']])) {
725 // Call menu_tree_all_data() to take advantage of the menu system's caching.
726 $tree = menu_tree_all_data($book_link['menu_name'], $book_link, $book_link['depth'] + 1);
727 $flat[$book_link['mlid']] = array();
728 _book_flatten_menu($tree, $flat[$book_link['mlid']]);
729 }
730
731 return $flat[$book_link['mlid']];
732 }
733
744 function _book_flatten_menu($tree, &$flat) {
745 foreach ($tree as $data) {
746 if (!$data['link']['hidden']) {
747 $flat[$data['link']['mlid']] = $data['link'];
748 if ($data['below']) {
749 _book_flatten_menu($data['below'], $flat);
750 }
751 }
752 }
753 }
754
765 function book_prev($book_link) {
766 // If the parent is zero, we are at the start of a book.
767 if ($book_link['plid'] == 0) {
768 return NULL;
769 }
770 $flat = book_get_flat_menu($book_link);
771 // Assigning the array to $flat resets the array pointer for use with each().
772 $curr = NULL;
773 do {
774 $prev = $curr;
775 list($key, $curr) = each($flat);
776 } while ($key && $key != $book_link['mlid']);
777
778 if ($key == $book_link['mlid']) {
779 // The previous page in the book may be a child of the previous visible link.
780 if ($prev['depth'] == $book_link['depth'] && $prev['has_children']) {
781 // The subtree will have only one link at the top level - get its data.
782 $tree = book_menu_subtree_data($prev);
783 $data = array_shift($tree);
784 // The link of interest is the last child - iterate to find the deepest one.
785 while ($data['below']) {
786 $data = end($data['below']);
787 }
788
789 return $data['link'];
790 }
791 else {
792 return $prev;
793 }
794 }
795 }
796
807 function book_next($book_link) {
808 $flat = book_get_flat_menu($book_link);
809 // Assigning the array to $flat resets the array pointer for use with each().
810 do {
811 list($key, $curr) = each($flat);
812 }
813 while ($key && $key != $book_link['mlid']);
814
815 if ($key == $book_link['mlid']) {
816 return current($flat);
817 }
818 }
819
829 function book_children($book_link) {
830 $flat = book_get_flat_menu($book_link);
831
832 $children = array();
833
834 if ($book_link['has_children']) {
835 // Walk through the array until we find the current page.
836 do {
837 $link = array_shift($flat);
838 }
839 while ($link && ($link['mlid'] != $book_link['mlid']));
840 // Continue though the array and collect the links whose parent is this page.
841 while (($link = array_shift($flat)) && $link['plid'] == $book_link['mlid']) {
842 $data['link'] = $link;
843 $data['below'] = '';
844 $children[] = $data;
845 }
846 }
847
848 if ($children) {
849 $elements = menu_tree_output($children);
850 return drupal_render($elements);
851 }
852 return '';
853 }
854
864 function book_menu_name($bid) {
865 return 'book-toc-' . $bid;
866 }
867
871 function book_node_load($nodes, $types) {
872 $result = db_query("SELECT * FROM {book} b INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE b.nid IN (:nids)", array(':nids' => array_keys($nodes)), array('fetch' => PDO::FETCH_ASSOC));
873 foreach ($result as $record) {
874 $nodes[$record['nid']]->book = $record;
875 $nodes[$record['nid']]->book['href'] = $record['link_path'];
876 $nodes[$record['nid']]->book['title'] = $record['link_title'];
877 $nodes[$record['nid']]->book['options'] = unserialize($record['options']);
878 }
879 }
880
884 function book_node_view($node, $view_mode) {
885 if ($view_mode == 'full') {
886 if (!empty($node->book['bid']) && empty($node->in_preview)) {
887 $node->content['book_navigation'] = array(
888 '#markup' => theme('book_navigation', array('book_link' => $node->book)),
889 '#weight' => 100,
890 );
891 }
892 }
893
894 if ($view_mode != 'rss') {
895 book_node_view_link($node, $view_mode);
896 }
897 }
898
905 function book_page_alter(&$page) {
906 if (($node = menu_get_object()) && !empty($node->book['bid'])) {
907 $active_menus = menu_get_active_menu_names();
908 $active_menus[] = $node->book['menu_name'];
909 menu_set_active_menu_names($active_menus);
910 }
911 }
912
916 function book_node_presave($node) {
917 // Always save a revision for non-administrators.
918 if (!empty($node->book['bid']) && !user_access('administer nodes')) {
919 $node->revision = 1;
920 // The database schema requires a log message for every revision.
921 if (!isset($node->log)) {
922 $node->log = '';
923 }
924 }
925 // Make sure a new node gets a new menu link.
926 if (empty($node->nid)) {
927 $node->book['mlid'] = NULL;
928 }
929 }
930
934 function book_node_insert($node) {
935 if (!empty($node->book['bid'])) {
936 if ($node->book['bid'] == 'new') {
937 // New nodes that are their own book.
938 $node->book['bid'] = $node->nid;
939 }
940 $node->book['nid'] = $node->nid;
941 $node->book['menu_name'] = book_menu_name($node->book['bid']);
942 _book_update_outline($node);
943 }
944 }
945
949 function book_node_update($node) {
950 if (!empty($node->book['bid'])) {
951 if ($node->book['bid'] == 'new') {
952 // New nodes that are their own book.
953 $node->book['bid'] = $node->nid;
954 }
955 $node->book['nid'] = $node->nid;
956 $node->book['menu_name'] = book_menu_name($node->book['bid']);
957 _book_update_outline($node);
958 }
959 }
960
964 function book_node_delete($node) {
965 if (!empty($node->book['bid'])) {
966 if ($node->nid == $node->book['bid']) {
967 // Handle deletion of a top-level post.
968 $result = db_query("SELECT b.nid FROM {menu_links} ml INNER JOIN {book} b on b.mlid = ml.mlid WHERE ml.plid = :plid", array(
969 ':plid' => $node->book['mlid']
970 ));
971 foreach ($result as $child) {
972 $child_node = node_load($child->nid);
973 $child_node->book['bid'] = $child_node->nid;
974 _book_update_outline($child_node);
975 }
976 }
977 menu_link_delete($node->book['mlid']);
978 db_delete('book')
979 ->condition('mlid', $node->book['mlid'])
980 ->execute();
981 drupal_static_reset('book_get_books');
982 }
983 }
984
988 function book_node_prepare($node) {
989 // Prepare defaults for the add/edit form.
990 if (empty($node->book) && (user_access('add content to books') || user_access('administer book outlines'))) {
991 $node->book = array();
992
993 if (empty($node->nid) && isset($_GET['parent']) && is_numeric($_GET['parent'])) {
994 // Handle "Add child page" links:
995 $parent = book_link_load($_GET['parent']);
996
997 if ($parent && $parent['access']) {
998 $node->book['bid'] = $parent['bid'];
999 $node->book['plid'] = $parent['mlid'];
1000 $node->book['menu_name'] = $parent['menu_name'];
1001 }
1002 }
1003 // Set defaults.
1004 $node->book += _book_link_defaults(!empty($node->nid) ? $node->nid : 'new');
1005 }
1006 else {
1007 if (isset($node->book['bid']) && !isset($node->book['original_bid'])) {
1008 $node->book['original_bid'] = $node->book['bid'];
1009 }
1010 }
1011 // Find the depth limit for the parent select.
1012 if (isset($node->book['bid']) && !isset($node->book['parent_depth_limit'])) {
1013 $node->book['parent_depth_limit'] = _book_parent_depth_limit($node->book);
1014 }
1015 }
1016
1026 function _book_parent_depth_limit($book_link) {
1027 return MENU_MAX_DEPTH - 1 - (($book_link['mlid'] && $book_link['has_children']) ? menu_link_children_relative_depth($book_link) : 0);
1028 }
1029
1037 function book_form_node_delete_confirm_alter(&$form, $form_state) {
1038 $node = node_load($form['nid']['#value']);
1039
1040 if (isset($node->book) && $node->book['has_children']) {
1041 $form['book_warning'] = array(
1042 '#markup' => '<p>' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', array('%title' => $node->title)) . '</p>',
1043 '#weight' => -10,
1044 );
1045 }
1046 }
1047
1057 function _book_link_defaults($nid) {
1058 return array('original_bid' => 0, 'menu_name' => '', 'nid' => $nid, 'bid' => 0, 'router_path' => 'node/%', 'plid' => 0, 'mlid' => 0, 'has_children' => 0, 'weight' => 0, 'module' => 'book', 'options' => array());
1059 }
1060
1074 function template_preprocess_book_all_books_block(&$variables) {
1075 // Remove all non-renderable elements.
1076 $elements = $variables['book_menus'];
1077 $variables['book_menus'] = array();
1078 foreach (element_children($elements) as $index) {
1079 $variables['book_menus'][$index] = $elements[$index];
1080 }
1081 }
1082
1092 function template_preprocess_book_navigation(&$variables) {
1093 $book_link = $variables['book_link'];
1094
1095 // Provide extra variables for themers. Not needed by default.
1096 $variables['book_id'] = $book_link['bid'];
1097 $variables['book_title'] = check_plain($book_link['link_title']);
1098 $variables['book_url'] = 'node/' . $book_link['bid'];
1099 $variables['current_depth'] = $book_link['depth'];
1100 $variables['tree'] = '';
1101
1102 if ($book_link['mlid']) {
1103 $variables['tree'] = book_children($book_link);
1104
1105 if ($prev = book_prev($book_link)) {
1106 $prev_href = url($prev['href']);
1107 drupal_add_html_head_link(array('rel' => 'prev', 'href' => $prev_href));
1108 $variables['prev_url'] = $prev_href;
1109 $variables['prev_title'] = check_plain($prev['title']);
1110 }
1111
1112 if ($book_link['plid'] && $parent = book_link_load($book_link['plid'])) {
1113 $parent_href = url($parent['href']);
1114 drupal_add_html_head_link(array('rel' => 'up', 'href' => $parent_href));
1115 $variables['parent_url'] = $parent_href;
1116 $variables['parent_title'] = check_plain($parent['title']);
1117 }
1118
1119 if ($next = book_next($book_link)) {
1120 $next_href = url($next['href']);
1121 drupal_add_html_head_link(array('rel' => 'next', 'href' => $next_href));
1122 $variables['next_url'] = $next_href;
1123 $variables['next_title'] = check_plain($next['title']);
1124 }
1125 }
1126
1127 $variables['has_links'] = FALSE;
1128 // Link variables to filter for values and set state of the flag variable.
1129 $links = array('prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title');
1130 foreach ($links as $link) {
1131 if (isset($variables[$link])) {
1132 // Flag when there is a value.
1133 $variables['has_links'] = TRUE;
1134 }
1135 else {
1136 // Set empty to prevent notices.
1137 $variables[$link] = '';
1138 }
1139 }
1140 }
1141
1165 function _book_toc_recurse($tree, $indent, &$toc, $exclude, $depth_limit) {
1166 foreach ($tree as $data) {
1167 if ($data['link']['depth'] > $depth_limit) {
1168 // Don't iterate through any links on this level.
1169 break;
1170 }
1171
1172 if (!in_array($data['link']['mlid'], $exclude)) {
1173 $toc[$data['link']['mlid']] = $indent . ' ' . truncate_utf8($data['link']['title'], 30, TRUE, TRUE);
1174 if ($data['below']) {
1175 _book_toc_recurse($data['below'], $indent . '--', $toc, $exclude, $depth_limit);
1176 }
1177 }
1178 }
1179 }
1180
1196 function book_toc($bid, $depth_limit, $exclude = array()) {
1197 $tree = menu_tree_all_data(book_menu_name($bid));
1198 $toc = array();
1199 _book_toc_recurse($tree, '', $toc, $exclude, $depth_limit);
1200
1201 return $toc;
1202 }
1203
1215 function template_preprocess_book_export_html(&$variables) {
1216 global $base_url, $language;
1217
1218 $variables['title'] = check_plain($variables['title']);
1219 $variables['base_url'] = $base_url;
1220 $variables['language'] = $language;
1221 $variables['language_rtl'] = ($language->direction == LANGUAGE_RTL);
1222 $variables['head'] = drupal_get_html_head();
1223 $variables['dir'] = $language->direction ? 'rtl' : 'ltr';
1224 }
1225
1240 function book_export_traverse($tree, $visit_func) {
1241 $output = '';
1242
1243 foreach ($tree as $data) {
1244 // Note- access checking is already performed when building the tree.
1245 if ($node = node_load($data['link']['nid'], FALSE)) {
1246 $children = '';
1247
1248 if ($data['below']) {
1249 $children = book_export_traverse($data['below'], $visit_func);
1250 }
1251
1252 if (function_exists($visit_func)) {
1253 $output .= call_user_func($visit_func, $node, $children);
1254 }
1255 else {
1256 // Use the default function.
1257 $output .= book_node_export($node, $children);
1258 }
1259 }
1260 }
1261
1262 return $output;
1263 }
1264
1279 function book_node_export($node, $children = '') {
1280 $build = node_view($node, 'print');
1281 unset($build['#theme']);
1282 // @todo Rendering should happen in the template using render().
1283 $node->rendered = drupal_render($build);
1284
1285 return theme('book_node_export_html', array('node' => $node, 'children' => $children));
1286 }
1287
1298 function template_preprocess_book_node_export_html(&$variables) {
1299 $variables['depth'] = $variables['node']->book['depth'];
1300 $variables['title'] = check_plain($variables['node']->title);
1301 $variables['content'] = $variables['node']->rendered;
1302 }
1303
1313 function book_type_is_allowed($type) {
1314 return in_array($type, variable_get('book_allowed_types', array('book')));
1315 }
1316
1323 function book_node_type_update($type) {
1324 if (!empty($type->old_type) && $type->old_type != $type->type) {
1325 // Update the list of node types that are allowed to be added to books.
1326 $allowed_types = variable_get('book_allowed_types', array('book'));
1327 $key = array_search($type->old_type, $allowed_types);
1328
1329 if ($key !== FALSE) {
1330 $allowed_types[$type->type] = $allowed_types[$key] ? $type->type : 0;
1331 unset($allowed_types[$key]);
1332 variable_set('book_allowed_types', $allowed_types);
1333 }
1334
1335 // Update the setting for the "Add child page" link.
1336 if (variable_get('book_child_type', 'book') == $type->old_type) {
1337 variable_set('book_child_type', $type->type);
1338 }
1339 }
1340 }
1341
1356 function book_link_load($mlid) {
1357 if ($item = db_query("SELECT * FROM {menu_links} ml INNER JOIN {book} b ON b.mlid = ml.mlid LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE ml.mlid = :mlid", array(
1358 ':mlid' => $mlid,
1359 ))->fetchAssoc()) {
1360 _menu_link_translate($item);
1361 return $item;
1362 }
1363
1364 return FALSE;
1365 }
1366
1380 function book_menu_subtree_data($link) {
1381 $tree = &drupal_static(__FUNCTION__, array());
1382
1383 // Generate a cache ID (cid) specific for this $menu_name and $link.
1384 $cid = 'links:' . $link['menu_name'] . ':subtree-cid:' . $link['mlid'];
1385
1386 if (!isset($tree[$cid])) {
1387 $cache = cache_get($cid, 'cache_menu');
1388
1389 if ($cache && isset($cache->data)) {
1390 // If the cache entry exists, it will just be the cid for the actual data.
1391 // This avoids duplication of large amounts of data.
1392 $cache = cache_get($cache->data, 'cache_menu');
1393
1394 if ($cache && isset($cache->data)) {
1395 $data = $cache->data;
1396 }
1397 }
1398
1399 // If the subtree data was not in the cache, $data will be NULL.
1400 if (!isset($data)) {
1401 $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
1402 $query->join('menu_router', 'm', 'm.path = ml.router_path');
1403 $query->join('book', 'b', 'ml.mlid = b.mlid');
1404 $query->fields('b');
1405 $query->fields('m', array('load_functions', 'to_arg_functions', 'access_callback', 'access_arguments', 'page_callback', 'page_arguments', 'delivery_callback', 'title', 'title_callback', 'title_arguments', 'type'));
1406 $query->fields('ml');
1407 $query->condition('menu_name', $link['menu_name']);
1408 for ($i = 1; $i <= MENU_MAX_DEPTH && $link["p$i"]; ++$i) {
1409 $query->condition("p$i", $link["p$i"]);
1410 }
1411 for ($i = 1; $i <= MENU_MAX_DEPTH; ++$i) {
1412 $query->orderBy("p$i");
1413 }
1414 $links = array();
1415 foreach ($query->execute() as $item) {
1416 $links[] = $item;
1417 }
1418 $data['tree'] = menu_tree_data($links, array(), $link['depth']);
1419 $data['node_links'] = array();
1420 menu_tree_collect_node_links($data['tree'], $data['node_links']);
1421 // Compute the real cid for book subtree data.
1422 $tree_cid = 'links:' . $item['menu_name'] . ':subtree-data:' . hash('sha256', serialize($data));
1423 // Cache the data, if it is not already in the cache.
1424
1425 if (!cache_get($tree_cid, 'cache_menu')) {
1426 cache_set($tree_cid, $data, 'cache_menu');
1427 }
1428 // Cache the cid of the (shared) data using the menu and item-specific cid.
1429 cache_set($cid, $tree_cid, 'cache_menu');
1430 }
1431 // Check access for the current user to each item in the tree.
1432 menu_tree_check_access($data['tree'], $data['node_links']);
1433 $tree[$cid] = $data['tree'];
1434 }
1435
1436 return $tree[$cid];
1437 }
book_export_traverse
book_export_traverse($tree, $visit_func)
Definition: book.module:1240
book_form_node_delete_confirm_alter
book_form_node_delete_confirm_alter(&$form, $form_state)
Definition: book.module:1037
menu_link_save
menu_link_save(&$item, $existing_item=array(), $parent_candidates=array())
Definition: menu.inc:3074
_book_outline_remove_access
_book_outline_remove_access($node)
Definition: book.module:215
LANGUAGE_RTL
const LANGUAGE_RTL
Definition: bootstrap.inc:206
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
book_node_export
book_node_export($node, $children= '')
Definition: book.module:1279
menu_tree_check_access
menu_tree_check_access(&$tree, $node_links=array())
Definition: menu.inc:1487
book_pick_book_nojs_submit
book_pick_book_nojs_submit($form, &$form_state)
Definition: book.module:455
DRUPAL_CACHE_PER_PAGE
const DRUPAL_CACHE_PER_PAGE
Definition: common.inc:156
book_block_info
book_block_info()
Definition: book.module:261
book_toc
book_toc($bid, $depth_limit, $exclude=array())
Definition: book.module:1196
$page
print $page
Definition: overlay.tpl.php:37
_book_toc_recurse
_book_toc_recurse($tree, $indent, &$toc, $exclude, $depth_limit)
Definition: book.module:1165
book_node_type_update
book_node_type_update($type)
Definition: book.module:1323
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
book_prev
book_prev($book_link)
Definition: book.module:765
_book_node_is_removable
_book_node_is_removable($node)
Definition: book.module:228
menu_link_delete
menu_link_delete($mlid, $path=NULL)
Definition: menu.inc:2996
book_block_view
book_block_view($delta= '')
Definition: book.module:275
book_help
book_help($path, $arg)
Definition: book.module:11
book_node_view_link
book_node_view_link($node, $view_mode)
Definition: book.module:94
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
node_is_page
node_is_page($node)
Definition: node.module:1487
book_node_insert
book_node_insert($node)
Definition: book.module:934
book_children
book_children($book_link)
Definition: book.module:829
drupal_add_html_head_link
drupal_add_html_head_link($attributes, $header=FALSE)
Definition: common.inc:2834
_menu_link_translate
_menu_link_translate(&$item, $translate=FALSE)
Definition: menu.inc:870
book_block_configure
book_block_configure($delta= '')
Definition: book.module:329
_book_parent_select
_book_parent_select($book_link)
Definition: book.module:473
menu_tree_output
menu_tree_output($tree)
Definition: menu.inc:1016
book_menu_name
book_menu_name($bid)
Definition: book.module:864
_book_outline_access
_book_outline_access($node)
Definition: book.module:203
book_admin_paths
book_admin_paths()
Definition: book.module:235
_book_flatten_menu
_book_flatten_menu($tree, &$flat)
Definition: book.module:744
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
theme_book_title_link
theme_book_title_link($variables)
Definition: book.module:363
book_page_alter
book_page_alter(&$page)
Definition: book.module:905
book_type_is_allowed
book_type_is_allowed($type)
Definition: book.module:1313
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$info
$info
Definition: color.inc:6
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
book_node_update
book_node_update($node)
Definition: book.module:949
book_node_prepare
book_node_prepare($node)
Definition: book.module:988
book_node_presave
book_node_presave($node)
Definition: book.module:916
menu_link_children_relative_depth
menu_link_children_relative_depth($item)
Definition: menu.inc:3432
_book_link_defaults
_book_link_defaults($nid)
Definition: book.module:1057
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
book_link_load
book_link_load($mlid)
Definition: book.module:1356
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
template_preprocess_book_navigation
template_preprocess_book_navigation(&$variables)
Definition: book.module:1092
MENU_MAX_DEPTH
const MENU_MAX_DEPTH
Definition: menu.inc:270
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
book_node_delete
book_node_delete($node)
Definition: book.module:964
menu_tree_all_data
menu_tree_all_data($menu_name, $link=NULL, $max_depth=NULL)
Definition: menu.inc:1105
MENU_SUGGESTED_ITEM
const MENU_SUGGESTED_ITEM
Definition: menu.inc:161
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
drupal_get_html_head
drupal_get_html_head()
Definition: common.inc:352
node_access
node_access($op, $node, $account=NULL)
Definition: node.module:2981
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
book_form_node_form_alter
book_form_node_form_alter(&$form, &$form_state, $form_id)
Definition: book.module:419
book_form_update
book_form_update($form, $form_state)
Definition: book.module:609
_book_add_form_elements
_book_add_form_elements(&$form, &$form_state, $node)
Definition: book.module:519
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
book_menu
book_menu()
Definition: book.module:130
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
book_node_view
book_node_view($node, $view_mode)
Definition: book.module:884
book_get_books
book_get_books()
Definition: book.module:380
$children
print $children
Definition: book-node-export-html.tpl.php:24
title
print $topic title
Definition: forum-topic-list.tpl.php:50
book_get_flat_menu
book_get_flat_menu($book_link)
Definition: book.module:721
template_preprocess_book_node_export_html
template_preprocess_book_node_export_html(&$variables)
Definition: book.module:1298
menu_set_active_menu_names
menu_set_active_menu_names($menu_names=NULL)
Definition: menu.inc:2311
template_preprocess_book_all_books_block
template_preprocess_book_all_books_block(&$variables)
Definition: book.module:1074
book_node_load
book_node_load($nodes, $types)
Definition: book.module:871
_book_update_outline
_book_update_outline($node)
Definition: book.module:626
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
_book_parent_depth_limit
_book_parent_depth_limit($book_link)
Definition: book.module:1026
menu_tree_collect_node_links
menu_tree_collect_node_links(&$tree, &$node_links)
Definition: menu.inc:1463
$tree
if($tree||$has_links) print $tree
Definition: book-navigation.tpl.php:35
menu_get_active_menu_names
menu_get_active_menu_names()
Definition: menu.inc:2326
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
book_theme
book_theme()
Definition: book.module:38
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
truncate_utf8
truncate_utf8($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
Definition: unicode.inc:316
book_entity_info_alter
book_entity_info_alter(&$info)
Definition: book.module:248
book_update_bid
book_update_bid($book_link)
Definition: book.module:692
template_preprocess_book_export_html
template_preprocess_book_export_html(&$variables)
Definition: book.module:1215
book_next
book_next($book_link)
Definition: book.module:807
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
menu_get_object
menu_get_object($type= 'node', $position=1, $path=NULL)
Definition: menu.inc:971
menu_tree_data
menu_tree_data(array $links, array $parents=array(), $depth=1)
Definition: menu.inc:1554
$links
print $links
Definition: poll-results--block.tpl.php:28
node_view
node_view($node, $view_mode= 'full', $langcode=NULL)
Definition: node.module:1329
book_permission
book_permission()
Definition: book.module:68
DRUPAL_CACHE_PER_ROLE
const DRUPAL_CACHE_PER_ROLE
Definition: common.inc:143
book_block_save
book_block_save($delta= '', $edit=array())
Definition: book.module:349
book_menu_subtree_data
book_menu_subtree_data($link)
Definition: book.module:1380
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/translation/translation.module Source File

  • modules
  • translation
translation.module
Go to the documentation of this file.
1 <?php
2
25 define('TRANSLATION_ENABLED', 2);
26
30 function translation_help($path, $arg) {
31 switch ($path) {
32 case 'admin/help#translation':
33 $output = '';
34 $output .= '<h3>' . t('About') . '</h3>';
35 $output .= '<p>' . t('The Content translation module allows content to be translated into different languages. Working with the <a href="@locale">Locale module</a> (which manages enabled languages and provides translation for the site interface), the Content translation module is key to creating and maintaining translated site content. For more information, see the online handbook entry for <a href="@translation">Content translation module</a>.', array('@locale' => url('admin/help/locale'), '@translation' => 'http://drupal.org/documentation/modules/translation/')) . '</p>';
36 $output .= '<h3>' . t('Uses') . '</h3>';
37 $output .= '<dl>';
38 $output .= '<dt>' . t('Configuring content types for translation') . '</dt>';
39 $output .= '<dd>' . t('To configure a particular content type for translation, visit the <a href="@content-types">Content types</a> page, and click the <em>edit</em> link for the content type. In the <em>Publishing options</em> section, select <em>Enabled, with translation</em> under <em>Multilingual support</em>.', array('@content-types' => url('admin/structure/types'))) . '</dd>';
40 $output .= '<dt>' . t('Assigning a language to content') . '</dt>';
41 $output .= '<dd>' . t('Use the <em>Language</em> drop down to select the appropriate language when creating or editing content.') . '</dd>';
42 $output .= '<dt>' . t('Translating content') . '</dt>';
43 $output .= '<dd>' . t('Users with the <em>translate content</em> permission can translate content, if the content type has been configured to allow translations. To translate content, select the <em>Translation</em> tab when viewing the content, select the language for which you wish to provide content, and then enter the content.') . '</dd>';
44 $output .= '<dt>' . t('Maintaining translations') . '</dt>';
45 $output .= '<dd>' . t('If editing content in one language requires that translated versions also be updated to reflect the change, use the <em>Flag translations as outdated</em> check box to mark the translations as outdated and in need of revision. Individual translations may also be marked for revision by selecting the <em>This translation needs to be updated</em> check box on the translation editing form.') . '</dd>';
46 $output .= '</dl>';
47 return $output;
48 case 'node/%/translate':
49 $output = '<p>' . t('Translations of a piece of content are managed with translation sets. Each translation set has one source post and any number of translations in any of the <a href="!languages">enabled languages</a>. All translations are tracked to be up to date or outdated based on whether the source post was modified significantly.', array('!languages' => url('admin/config/regional/language'))) . '</p>';
50 return $output;
51 }
52 }
53
57 function translation_menu() {
58 $items = array();
59 $items['node/%node/translate'] = array(
60 'title' => 'Translate',
61 'page callback' => 'translation_node_overview',
62 'page arguments' => array(1),
63 'access callback' => '_translation_tab_access',
64 'access arguments' => array(1),
65 'type' => MENU_LOCAL_TASK,
66 'weight' => 2,
67 'file' => 'translation.pages.inc',
68 );
69 return $items;
70 }
71
86 function _translation_tab_access($node) {
87 if (entity_language('node', $node) != LANGUAGE_NONE && translation_supported_type($node->type) && node_access('view', $node)) {
88 return user_access('translate content');
89 }
90 return FALSE;
91 }
92
96 function translation_admin_paths() {
97 if (variable_get('node_admin_theme')) {
98 $paths = array(
99 'node/*/translate' => TRUE,
100 );
101 return $paths;
102 }
103 }
104
108 function translation_permission() {
109 return array(
110 'translate content' => array(
111 'title' => t('Translate content'),
112 ),
113 );
114 }
115
119 function translation_form_node_type_form_alter(&$form, &$form_state) {
120 // Add translation option to content type form.
121 $form['workflow']['language_content_type']['#options'][TRANSLATION_ENABLED] = t('Enabled, with translation');
122 // Description based on text from locale.module.
123 $form['workflow']['language_content_type']['#description'] = t('Enable multilingual support for this content type. If enabled, a language selection field will be added to the editing form, allowing you to select from one of the <a href="!languages">enabled languages</a>. You can also turn on translation for this content type, which lets you have content translated to any of the installed languages. If disabled, new posts are saved with the default language. Existing content will not be affected by changing this option.', array('!languages' => url('admin/config/regional/language')));
124 }
125
134 function translation_form_node_form_alter(&$form, &$form_state) {
135 if (translation_supported_type($form['#node']->type)) {
136 $node = $form['#node'];
137 $languages = language_list('enabled');
138 $disabled_languages = isset($languages[0]) ? $languages[0] : FALSE;
139 $translator_widget = $disabled_languages && user_access('translate content');
140 $groups = array(t('Disabled'), t('Enabled'));
141 // Allow translators to enter content in disabled languages. Translators
142 // might need to distinguish between enabled and disabled languages, hence
143 // we divide them in two option groups.
144 if ($translator_widget) {
145 $options = array($groups[1] => array(LANGUAGE_NONE => t('Language neutral')));
146 $language_list = locale_language_list('name', TRUE);
147 foreach (array(1, 0) as $status) {
148 $group = $groups[$status];
149 foreach ($languages[$status] as $langcode => $language) {
150 $options[$group][$langcode] = $language_list[$langcode];
151 }
152 }
153 $form['language']['#options'] = $options;
154 }
155 if (!empty($node->translation_source)) {
156 // We are creating a translation. Add values and lock language field.
157 $form['translation_source'] = array('#type' => 'value', '#value' => $node->translation_source);
158 $form['language']['#disabled'] = TRUE;
159 }
160 elseif (!empty($node->nid) && !empty($node->tnid)) {
161 // Disable languages for existing translations, so it is not possible to switch this
162 // node to some language which is already in the translation set. Also remove the
163 // language neutral option.
164 unset($form['language']['#options'][LANGUAGE_NONE]);
165 foreach (translation_node_get_translations($node->tnid) as $langcode => $translation) {
166 if ($translation->nid != $node->nid) {
167 if ($translator_widget) {
168 $group = $groups[(int)!isset($disabled_languages[$langcode])];
169 unset($form['language']['#options'][$group][$langcode]);
170 }
171 else {
172 unset($form['language']['#options'][$langcode]);
173 }
174 }
175 }
176 // Add translation values and workflow options.
177 $form['tnid'] = array('#type' => 'value', '#value' => $node->tnid);
178 $form['translation'] = array(
179 '#type' => 'fieldset',
180 '#title' => t('Translation settings'),
181 '#access' => user_access('translate content'),
182 '#collapsible' => TRUE,
183 '#collapsed' => !$node->translate,
184 '#tree' => TRUE,
185 '#weight' => 30,
186 );
187 if ($node->tnid == $node->nid) {
188 // This is the source node of the translation
189 $form['translation']['retranslate'] = array(
190 '#type' => 'checkbox',
191 '#title' => t('Flag translations as outdated'),
192 '#default_value' => 0,
193 '#description' => t('If you made a significant change, which means translations should be updated, you can flag all translations of this post as outdated. This will not change any other property of those posts, like whether they are published or not.'),
194 );
195 $form['translation']['status'] = array('#type' => 'value', '#value' => 0);
196 }
197 else {
198 $form['translation']['status'] = array(
199 '#type' => 'checkbox',
200 '#title' => t('This translation needs to be updated'),
201 '#default_value' => $node->translate,
202 '#description' => t('When this option is checked, this translation needs to be updated because the source post has changed. Uncheck when the translation is up to date again.'),
203 );
204 }
205 }
206 }
207 }
208
216 function translation_node_view($node, $view_mode) {
217 // If the site has no translations or is not multilingual we have no content
218 // translation links to display.
219 if (isset($node->tnid) && drupal_multilingual() && $translations = translation_node_get_translations($node->tnid)) {
220 $languages = language_list('enabled');
221 $languages = $languages[1];
222
223 // There might be a language provider enabled defining custom language
224 // switch links which need to be taken into account while generating the
225 // content translation links. As custom language switch links are available
226 // only for configurable language types and interface language is the only
227 // configurable language type in core, we use it as default. Contributed
228 // modules can change this behavior by setting the system variable below.
229 $type = variable_get('translation_language_type', LANGUAGE_TYPE_INTERFACE);
230 $custom_links = language_negotiation_get_switch_links($type, "node/$node->nid");
231 $links = array();
232
233 foreach ($translations as $langcode => $translation) {
234 // Do not show links to the same node, to unpublished translations or to
235 // translations in disabled languages.
236 if ($translation->status && isset($languages[$langcode]) && $langcode != entity_language('node', $node)) {
237 $language = $languages[$langcode];
238 $key = "translation_$langcode";
239
240 if (isset($custom_links->links[$langcode])) {
241 $links[$key] = $custom_links->links[$langcode];
242 }
243 else {
244 $links[$key] = array(
245 'href' => "node/{$translation->nid}",
246 'title' => $language->native,
247 'language' => $language,
248 );
249 }
250
251 // Custom switch links are more generic than content translation links,
252 // hence we override existing attributes with the ones below.
253 $links[$key] += array('attributes' => array());
254 $attributes = array(
255 'title' => $translation->title,
256 'class' => array('translation-link'),
257 );
258 $links[$key]['attributes'] = $attributes + $links[$key]['attributes'];
259 }
260 }
261
262 $node->content['links']['translation'] = array(
263 '#theme' => 'links__node__translation',
264 '#links' => $links,
265 '#attributes' => array('class' => array('links', 'inline')),
266 );
267 }
268 }
269
273 function translation_node_prepare($node) {
274 // Only act if we are dealing with a content type supporting translations.
275 if (translation_supported_type($node->type) &&
276 // And it's a new node.
277 empty($node->nid) &&
278 // And the user has permission to translate content.
279 user_access('translate content') &&
280 // And the $_GET variables are set properly.
281 isset($_GET['translation']) &&
282 isset($_GET['target']) &&
283 is_numeric($_GET['translation'])) {
284
285 $source_node = node_load($_GET['translation']);
286 if (empty($source_node) || !node_access('view', $source_node)) {
287 // Source node not found or no access to view. We should not check
288 // for edit access, since the translator might not have permissions
289 // to edit the source node but should still be able to translate.
290 return;
291 }
292
293 $language_list = language_list();
294 $langcode = $_GET['target'];
295 if (!isset($language_list[$langcode]) || ($source_node->language == $langcode)) {
296 // If not supported language, or same language as source node, break.
297 return;
298 }
299
300 // Ensure we don't have an existing translation in this language.
301 if (!empty($source_node->tnid)) {
302 $translations = translation_node_get_translations($source_node->tnid);
303 if (isset($translations[$langcode])) {
304 drupal_set_message(t('A translation of %title in %language already exists, a new %type will be created instead of a translation.', array('%title' => $source_node->title, '%language' => $language_list[$langcode]->name, '%type' => $node->type)), 'error');
305 return;
306 }
307 }
308
309 // Populate fields based on source node.
310 $node->language = $langcode;
311 $node->translation_source = $source_node;
312 $node->title = $source_node->title;
313
314 // Add field translations and let other modules module add custom translated
315 // fields.
316 field_attach_prepare_translation('node', $node, $langcode, $source_node, $source_node->language);
317 }
318 }
319
323 function translation_node_insert($node) {
324 // Only act if we are dealing with a content type supporting translations.
325 if (translation_supported_type($node->type)) {
326 if (!empty($node->translation_source)) {
327 if ($node->translation_source->tnid) {
328 // Add node to existing translation set.
329 $tnid = $node->translation_source->tnid;
330 }
331 else {
332 // Create new translation set, using nid from the source node.
333 $tnid = $node->translation_source->nid;
334 db_update('node')
335 ->fields(array(
336 'tnid' => $tnid,
337 'translate' => 0,
338 ))
339 ->condition('nid', $node->translation_source->nid)
340 ->execute();
341 }
342 db_update('node')
343 ->fields(array(
344 'tnid' => $tnid,
345 'translate' => 0,
346 ))
347 ->condition('nid', $node->nid)
348 ->execute();
349 // Save tnid to avoid loss in case of resave.
350 $node->tnid = $tnid;
351 }
352 }
353 }
354
358 function translation_node_update($node) {
359 // Only act if we are dealing with a content type supporting translations.
360 if (translation_supported_type($node->type)) {
361 $langcode = entity_language('node', $node);
362 if (isset($node->translation) && $node->translation && !empty($langcode) && $node->tnid) {
363 // Update translation information.
364 db_update('node')
365 ->fields(array(
366 'tnid' => $node->tnid,
367 'translate' => $node->translation['status'],
368 ))
369 ->condition('nid', $node->nid)
370 ->execute();
371 if (!empty($node->translation['retranslate'])) {
372 // This is the source node, asking to mark all translations outdated.
373 db_update('node')
374 ->fields(array('translate' => 1))
375 ->condition('nid', $node->nid, '<>')
376 ->condition('tnid', $node->tnid)
377 ->execute();
378 }
379 }
380 }
381 }
382
388 function translation_node_validate($node, $form) {
389 // Only act on translatable nodes with a tnid or translation_source.
390 if (translation_supported_type($node->type) && (!empty($node->tnid) || !empty($form['#node']->translation_source->nid))) {
391 $tnid = !empty($node->tnid) ? $node->tnid : $form['#node']->translation_source->nid;
392 $translations = translation_node_get_translations($tnid);
393 $langcode = entity_language('node', $node);
394 if (isset($translations[$langcode]) && $translations[$langcode]->nid != $node->nid ) {
395 form_set_error('language', t('There is already a translation in this language.'));
396 }
397 }
398 }
399
403 function translation_node_delete($node) {
404 // Only act if we are dealing with a content type supporting translations.
405 if (translation_supported_type($node->type)) {
406 translation_remove_from_set($node);
407 }
408 }
409
416 function translation_remove_from_set($node) {
417 if (isset($node->tnid)) {
418 $query = db_update('node')
419 ->fields(array(
420 'tnid' => 0,
421 'translate' => 0,
422 ));
423 if (db_query('SELECT COUNT(*) FROM {node} WHERE tnid = :tnid', array(':tnid' => $node->tnid))->fetchField() == 1) {
424 // There is only one node left in the set: remove the set altogether.
425 $query
426 ->condition('tnid', $node->tnid)
427 ->execute();
428 }
429 else {
430 $query
431 ->condition('nid', $node->nid)
432 ->execute();
433
434 // If the node being removed was the source of the translation set,
435 // we pick a new source - preferably one that is up to date.
436 if ($node->tnid == $node->nid) {
437 $new_tnid = db_query('SELECT nid FROM {node} WHERE tnid = :tnid ORDER BY translate ASC, nid ASC', array(':tnid' => $node->tnid))->fetchField();
438 db_update('node')
439 ->fields(array('tnid' => $new_tnid))
440 ->condition('tnid', $node->tnid)
441 ->execute();
442 }
443 }
444 }
445 }
446
461 function translation_node_get_translations($tnid) {
462 if (is_numeric($tnid) && $tnid) {
463 $translations = &drupal_static(__FUNCTION__, array());
464
465 if (!isset($translations[$tnid])) {
466 $translations[$tnid] = array();
467 $result = db_select('node', 'n')
468 ->fields('n', array('nid', 'type', 'uid', 'status', 'title', 'language'))
469 ->condition('n.tnid', $tnid)
470 ->addTag('node_access')
471 ->execute();
472
473 foreach ($result as $node) {
474 $langcode = entity_language('node', $node);
475 $translations[$tnid][$langcode] = $node;
476 }
477 }
478 return $translations[$tnid];
479 }
480 }
481
488 function translation_supported_type($type) {
489 return variable_get('language_content_type_' . $type, 0) == TRANSLATION_ENABLED;
490 }
491
502 function translation_path_get_translations($path) {
503 $paths = array();
504 // Check for a node related path, and for its translations.
505 if ((preg_match("!^node/(\d+)(/.+|)$!", $path, $matches)) && ($node = node_load((int) $matches[1])) && !empty($node->tnid)) {
506 foreach (translation_node_get_translations($node->tnid) as $language => $translation_node) {
507 $paths[$language] = 'node/' . $translation_node->nid . $matches[2];
508 }
509 }
510 return $paths;
511 }
512
518 function translation_language_switch_links_alter(array &$links, $type, $path) {
519 $language_type = variable_get('translation_language_type', LANGUAGE_TYPE_INTERFACE);
520
521 if ($type == $language_type && preg_match("!^node/(\d+)(/.+|)!", $path, $matches)) {
522 $node = node_load((int) $matches[1]);
523
524 if (empty($node->tnid)) {
525 // If the node cannot be found nothing needs to be done. If it does not
526 // have translations it might be a language neutral node, in which case we
527 // must leave the language switch links unaltered. This is true also for
528 // nodes not having translation support enabled.
529 if (empty($node) || entity_language('node', $node) == LANGUAGE_NONE || !translation_supported_type($node->type)) {
530 return;
531 }
532 $langcode = entity_language('node', $node);
533 $translations = array($langcode => $node);
534 }
535 else {
536 $translations = translation_node_get_translations($node->tnid);
537 }
538
539 foreach ($links as $langcode => $link) {
540 if (isset($translations[$langcode]) && $translations[$langcode]->status) {
541 // Translation in a different node.
542 $links[$langcode]['href'] = 'node/' . $translations[$langcode]->nid . $matches[2];
543 }
544 else {
545 // No translation in this language, or no permission to view.
546 unset($links[$langcode]['href']);
547 $links[$langcode]['attributes']['class'][] = 'locale-untranslated';
548 }
549 }
550 }
551 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
TRANSLATION_ENABLED
const TRANSLATION_ENABLED
Definition: translation.module:25
translation_node_insert
translation_node_insert($node)
Definition: translation.module:323
_translation_tab_access
_translation_tab_access($node)
Definition: translation.module:86
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
translation_menu
translation_menu()
Definition: translation.module:57
locale_language_list
locale_language_list($field= 'name', $all=FALSE)
Definition: locale.module:843
translation_language_switch_links_alter
translation_language_switch_links_alter(array &$links, $type, $path)
Definition: translation.module:518
translation_node_update
translation_node_update($node)
Definition: translation.module:358
translation_admin_paths
translation_admin_paths()
Definition: translation.module:96
$attributes
print $attributes
Definition: block.tpl.php:47
translation_path_get_translations
translation_path_get_translations($path)
Definition: translation.module:502
field_attach_prepare_translation
field_attach_prepare_translation($entity_type, $entity, $langcode, $source_entity, $source_langcode)
Definition: field.attach.inc:1315
translation_permission
translation_permission()
Definition: translation.module:108
translation_node_prepare
translation_node_prepare($node)
Definition: translation.module:273
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
translation_form_node_form_alter
translation_form_node_form_alter(&$form, &$form_state)
Definition: translation.module:134
translation_supported_type
translation_supported_type($type)
Definition: translation.module:488
nid
print $node nid
Definition: book-node-export-html.tpl.php:21
language_list
language_list($field= 'language')
Definition: bootstrap.inc:2723
translation_remove_from_set
translation_remove_from_set($node)
Definition: translation.module:416
language_negotiation_get_switch_links
language_negotiation_get_switch_links($type, $path)
Definition: language.inc:279
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
entity_language
entity_language($entity_type, $entity)
Definition: common.inc:7967
translation_form_node_type_form_alter
translation_form_node_type_form_alter(&$form, &$form_state)
Definition: translation.module:119
translation_help
translation_help($path, $arg)
Definition: translation.module:30
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
translation_node_get_translations
translation_node_get_translations($tnid)
Definition: translation.module:461
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
translation_node_delete
translation_node_delete($node)
Definition: translation.module:403
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
node_access
node_access($op, $node, $account=NULL)
Definition: node.module:2981
translation_node_view
translation_node_view($node, $view_mode)
Definition: translation.module:216
LANGUAGE_TYPE_INTERFACE
const LANGUAGE_TYPE_INTERFACE
Definition: bootstrap.inc:191
translation_node_validate
translation_node_validate($node, $form)
Definition: translation.module:388
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
$links
print $links
Definition: poll-results--block.tpl.php:28
drupal_multilingual
drupal_multilingual()
Definition: bootstrap.inc:2691
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum-submitted.tpl.php Source File

  • modules
  • forum
forum-submitted.tpl.php
Go to the documentation of this file.
1 <?php
2
20 ?>
21 <?php if ($time): ?>
22 <span class="submitted">
23 <?php print t('By !author @time ago', array(
24 '@time' => $time,
25 '!author' => $author,
26 )); ?>
27 </span>
28 <?php else: ?>
29 <?php print t('n/a'); ?>
30 <?php endif; ?>
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
endif
endif
Definition: aggregator-item.tpl.php:31
$author
print $author
Definition: comment.tpl.php:68
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.multilingual.inc Source File

  • modules
  • field
field.multilingual.inc
Go to the documentation of this file.
1 <?php
2
68 function field_multilingual_settings_changed() {
69 field_info_cache_clear();
70 }
71
89 function field_available_languages($entity_type, $field) {
90 static $drupal_static_fast;
91 if (!isset($drupal_static_fast)) {
92 $drupal_static_fast['field_languages'] = &drupal_static(__FUNCTION__);
93 }
94 $field_languages = &$drupal_static_fast['field_languages'];
95 $field_name = $field['field_name'];
96
97 if (!isset($field_languages[$entity_type][$field_name])) {
98 // If the field has language support enabled we retrieve an (alterable) list
99 // of enabled languages, otherwise we return just LANGUAGE_NONE.
100 if (field_is_translatable($entity_type, $field)) {
101 $languages = field_content_languages();
102 // Let other modules alter the available languages.
103 $context = array('entity_type' => $entity_type, 'field' => $field);
104 drupal_alter('field_available_languages', $languages, $context);
105 $field_languages[$entity_type][$field_name] = $languages;
106 }
107 else {
108 $field_languages[$entity_type][$field_name] = array(LANGUAGE_NONE);
109 }
110 }
111
112 return $field_languages[$entity_type][$field_name];
113 }
114
131 function _field_language_suggestion($available_languages, $language_suggestion, $field_name) {
132 // Handle possible language suggestions.
133 if (!empty($language_suggestion)) {
134 // We might have an array of language suggestions keyed by field name.
135 if (is_array($language_suggestion) && isset($language_suggestion[$field_name])) {
136 $language_suggestion = $language_suggestion[$field_name];
137 }
138
139 // If we have a language suggestion and the suggested language is available,
140 // we return only it.
141 if (in_array($language_suggestion, $available_languages)) {
142 $available_languages = array($language_suggestion);
143 }
144 }
145
146 return $available_languages;
147 }
148
157 function field_content_languages() {
158 return array_keys(language_list() + array(LANGUAGE_NONE => NULL));
159 }
160
175 function field_is_translatable($entity_type, $field) {
176 return $field['translatable'] && field_has_translation_handler($entity_type);
177 }
178
195 function field_has_translation_handler($entity_type, $handler = NULL) {
196 $entity_info = entity_get_info($entity_type);
197
198 if (isset($handler)) {
199 return !empty($entity_info['translation'][$handler]);
200 }
201 elseif (isset($entity_info['translation'])) {
202 foreach ($entity_info['translation'] as $handler_info) {
203 // The translation handler must use a non-empty data structure.
204 if (!empty($handler_info)) {
205 return TRUE;
206 }
207 }
208 }
209
210 return FALSE;
211 }
212
228 function field_valid_language($langcode, $default = TRUE) {
229 $enabled_languages = field_content_languages();
230 if (in_array($langcode, $enabled_languages)) {
231 return $langcode;
232 }
233 global $language_content;
234 return $default ? language_default('language') : $language_content->language;
235 }
236
266 function field_language($entity_type, $entity, $field_name = NULL, $langcode = NULL) {
267 $display_languages = &drupal_static(__FUNCTION__, array());
268 list($id, , $bundle) = entity_extract_ids($entity_type, $entity);
269 $langcode = field_valid_language($langcode, FALSE);
270
271 if (!isset($display_languages[$entity_type][$id][$langcode])) {
272 $display_language = array();
273
274 // By default display language is set to LANGUAGE_NONE if the field
275 // translation is not available. It is up to translation handlers to
276 // implement language fallback rules.
277 foreach (field_info_instances($entity_type, $bundle) as $instance) {
278 $display_language[$instance['field_name']] = isset($entity->{$instance['field_name']}[$langcode]) ? $langcode : LANGUAGE_NONE;
279 }
280
281 if (field_has_translation_handler($entity_type)) {
282 $context = array(
283 'entity_type' => $entity_type,
284 'entity' => $entity,
285 'language' => $langcode,
286 );
287 drupal_alter('field_language', $display_language, $context);
288 }
289
290 $display_languages[$entity_type][$id][$langcode] = $display_language;
291 }
292
293 $display_language = $display_languages[$entity_type][$id][$langcode];
294
295 // Single-field mode.
296 if (isset($field_name)) {
297 return isset($display_language[$field_name]) ? $display_language[$field_name] : FALSE;
298 }
299
300 return $display_language;
301 }
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
field_content_languages
field_content_languages()
Definition: field.multilingual.inc:157
field_info_instances
field_info_instances($entity_type=NULL, $bundle_name=NULL)
Definition: field.info.inc:592
field_available_languages
field_available_languages($entity_type, $field)
Definition: field.multilingual.inc:89
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
field_multilingual_settings_changed
field_multilingual_settings_changed()
Definition: field.multilingual.inc:68
field_valid_language
field_valid_language($langcode, $default=TRUE)
Definition: field.multilingual.inc:228
field_language
field_language($entity_type, $entity, $field_name=NULL, $langcode=NULL)
Definition: field.multilingual.inc:266
field_info_cache_clear
field_info_cache_clear()
Definition: field.info.inc:54
field_has_translation_handler
field_has_translation_handler($entity_type, $handler=NULL)
Definition: field.multilingual.inc:195
language_list
language_list($field= 'language')
Definition: bootstrap.inc:2723
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
field_is_translatable
field_is_translatable($entity_type, $field)
Definition: field.multilingual.inc:175
language_default
language_default($property=NULL)
Definition: bootstrap.inc:2765
entity_extract_ids
entity_extract_ids($entity_type, $entity)
Definition: common.inc:7711
_field_language_suggestion
_field_language_suggestion($available_languages, $language_suggestion, $field_name)
Definition: field.multilingual.inc:131
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/dblog/dblog.admin.inc Source File

  • modules
  • dblog
dblog.admin.inc
Go to the documentation of this file.
1 <?php
2
21 function dblog_overview() {
22 $filter = dblog_build_filter_query();
23 $rows = array();
24 $classes = array(
25 WATCHDOG_DEBUG => 'dblog-debug',
26 WATCHDOG_INFO => 'dblog-info',
27 WATCHDOG_NOTICE => 'dblog-notice',
28 WATCHDOG_WARNING => 'dblog-warning',
29 WATCHDOG_ERROR => 'dblog-error',
30 WATCHDOG_CRITICAL => 'dblog-critical',
31 WATCHDOG_ALERT => 'dblog-alert',
32 WATCHDOG_EMERGENCY => 'dblog-emerg',
33 );
34
35 $build['dblog_filter_form'] = drupal_get_form('dblog_filter_form');
36 $build['dblog_clear_log_form'] = drupal_get_form('dblog_clear_log_form');
37
38 $header = array(
39 '', // Icon column.
40 array('data' => t('Type'), 'field' => 'w.type'),
41 array('data' => t('Date'), 'field' => 'w.wid', 'sort' => 'desc'),
42 t('Message'),
43 array('data' => t('User'), 'field' => 'u.name'),
44 array('data' => t('Operations')),
45 );
46
47 $query = db_select('watchdog', 'w')->extend('PagerDefault')->extend('TableSort');
48 $query->leftJoin('users', 'u', 'w.uid = u.uid');
49 $query
50 ->fields('w', array('wid', 'uid', 'severity', 'type', 'timestamp', 'message', 'variables', 'link'))
51 ->addField('u', 'name');
52 if (!empty($filter['where'])) {
53 $query->where($filter['where'], $filter['args']);
54 }
55 $result = $query
56 ->limit(50)
57 ->orderByHeader($header)
58 ->execute();
59
60 foreach ($result as $dblog) {
61 $rows[] = array('data' =>
62 array(
63 // Cells
64 array('class' => 'icon'),
65 t($dblog->type),
66 format_date($dblog->timestamp, 'short'),
67 theme('dblog_message', array('event' => $dblog, 'link' => TRUE)),
68 theme('username', array('account' => $dblog)),
69 filter_xss($dblog->link),
70 ),
71 // Attributes for tr
72 'class' => array(drupal_html_class('dblog-' . $dblog->type), $classes[$dblog->severity]),
73 );
74 }
75
76 $build['dblog_table'] = array(
77 '#theme' => 'table',
78 '#header' => $header,
79 '#rows' => $rows,
80 '#attributes' => array('id' => 'admin-dblog'),
81 '#empty' => t('No log messages available.'),
82 );
83 $build['dblog_pager'] = array('#theme' => 'pager');
84
85 return $build;
86 }
87
102 function dblog_top($type) {
103
104 $header = array(
105 array('data' => t('Count'), 'field' => 'count', 'sort' => 'desc'),
106 array('data' => t('Message'), 'field' => 'message')
107 );
108 $count_query = db_select('watchdog');
109 $count_query->addExpression('COUNT(DISTINCT(message))');
110 $count_query->condition('type', $type);
111
112 $query = db_select('watchdog', 'w')->extend('PagerDefault')->extend('TableSort');
113 $query->addExpression('COUNT(wid)', 'count');
114 $query = $query
115 ->fields('w', array('message', 'variables'))
116 ->condition('w.type', $type)
117 ->groupBy('message')
118 ->groupBy('variables')
119 ->limit(30)
120 ->orderByHeader($header);
121 $query->setCountQuery($count_query);
122 $result = $query->execute();
123
124 $rows = array();
125 foreach ($result as $dblog) {
126 $rows[] = array($dblog->count, theme('dblog_message', array('event' => $dblog)));
127 }
128
129 $build['dblog_top_table'] = array(
130 '#theme' => 'table',
131 '#header' => $header,
132 '#rows' => $rows,
133 '#empty' => t('No log messages available.'),
134 );
135 $build['dblog_top_pager'] = array('#theme' => 'pager');
136
137 return $build;
138 }
139
152 function dblog_event($id) {
153 $severity = watchdog_severity_levels();
154 $result = db_query('SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid WHERE w.wid = :id', array(':id' => $id))->fetchObject();
155 if ($dblog = $result) {
156 $rows = array(
157 array(
158 array('data' => t('Type'), 'header' => TRUE),
159 t($dblog->type),
160 ),
161 array(
162 array('data' => t('Date'), 'header' => TRUE),
163 format_date($dblog->timestamp, 'long'),
164 ),
165 array(
166 array('data' => t('User'), 'header' => TRUE),
167 theme('username', array('account' => $dblog)),
168 ),
169 array(
170 array('data' => t('Location'), 'header' => TRUE),
171 l($dblog->location, $dblog->location),
172 ),
173 array(
174 array('data' => t('Referrer'), 'header' => TRUE),
175 l($dblog->referer, $dblog->referer),
176 ),
177 array(
178 array('data' => t('Message'), 'header' => TRUE),
179 theme('dblog_message', array('event' => $dblog)),
180 ),
181 array(
182 array('data' => t('Severity'), 'header' => TRUE),
183 $severity[$dblog->severity],
184 ),
185 array(
186 array('data' => t('Hostname'), 'header' => TRUE),
187 check_plain($dblog->hostname),
188 ),
189 array(
190 array('data' => t('Operations'), 'header' => TRUE),
191 $dblog->link,
192 ),
193 );
194 $build['dblog_table'] = array(
195 '#theme' => 'table',
196 '#rows' => $rows,
197 '#attributes' => array('class' => array('dblog-event')),
198 );
199 return $build;
200 }
201 else {
202 return '';
203 }
204 }
205
212 function dblog_build_filter_query() {
213 if (empty($_SESSION['dblog_overview_filter'])) {
214 return;
215 }
216
217 $filters = dblog_filters();
218
219 // Build query
220 $where = $args = array();
221 foreach ($_SESSION['dblog_overview_filter'] as $key => $filter) {
222 $filter_where = array();
223 foreach ($filter as $value) {
224 $filter_where[] = $filters[$key]['where'];
225 $args[] = $value;
226 }
227 if (!empty($filter_where)) {
228 $where[] = '(' . implode(' OR ', $filter_where) . ')';
229 }
230 }
231 $where = !empty($where) ? implode(' AND ', $where) : '';
232
233 return array(
234 'where' => $where,
235 'args' => $args,
236 );
237 }
238
250 function dblog_filters() {
251 $filters = array();
252
253 foreach (_dblog_get_message_types() as $type) {
254 $types[$type] = t($type);
255 }
256
257 if (!empty($types)) {
258 $filters['type'] = array(
259 'title' => t('Type'),
260 'where' => "w.type = ?",
261 'options' => $types,
262 );
263 }
264
265 $filters['severity'] = array(
266 'title' => t('Severity'),
267 'where' => 'w.severity = ?',
268 'options' => watchdog_severity_levels(),
269 );
270
271 return $filters;
272 }
273
284 function theme_dblog_message($variables) {
285 $output = '';
286 $event = $variables['event'];
287 // Check for required properties.
288 if (isset($event->message) && isset($event->variables)) {
289 // Messages without variables or user specified text.
290 if ($event->variables === 'N;') {
291 $output = $event->message;
292 }
293 // Message to translate with injected variables.
294 else {
295 $output = t($event->message, unserialize($event->variables));
296 }
297 if ($variables['link'] && isset($event->wid)) {
298 // Truncate message to 56 chars.
299 $output = truncate_utf8(filter_xss($output, array()), 56, TRUE, TRUE);
300 $output = l($output, 'admin/reports/event/' . $event->wid, array('html' => TRUE));
301 }
302 }
303 return $output;
304 }
305
315 function dblog_filter_form($form) {
316 $filters = dblog_filters();
317
318 $form['filters'] = array(
319 '#type' => 'fieldset',
320 '#title' => t('Filter log messages'),
321 '#collapsible' => TRUE,
322 '#collapsed' => empty($_SESSION['dblog_overview_filter']),
323 );
324 foreach ($filters as $key => $filter) {
325 $form['filters']['status'][$key] = array(
326 '#title' => $filter['title'],
327 '#type' => 'select',
328 '#multiple' => TRUE,
329 '#size' => 8,
330 '#options' => $filter['options'],
331 );
332 if (!empty($_SESSION['dblog_overview_filter'][$key])) {
333 $form['filters']['status'][$key]['#default_value'] = $_SESSION['dblog_overview_filter'][$key];
334 }
335 }
336
337 $form['filters']['actions'] = array(
338 '#type' => 'actions',
339 '#attributes' => array('class' => array('container-inline')),
340 );
341 $form['filters']['actions']['submit'] = array(
342 '#type' => 'submit',
343 '#value' => t('Filter'),
344 );
345 if (!empty($_SESSION['dblog_overview_filter'])) {
346 $form['filters']['actions']['reset'] = array(
347 '#type' => 'submit',
348 '#value' => t('Reset')
349 );
350 }
351 return $form;
352 }
353
359 function dblog_filter_form_validate($form, &$form_state) {
360 if ($form_state['values']['op'] == t('Filter') && empty($form_state['values']['type']) && empty($form_state['values']['severity'])) {
361 form_set_error('type', t('You must select something to filter by.'));
362 }
363 }
364
370 function dblog_filter_form_submit($form, &$form_state) {
371 $op = $form_state['values']['op'];
372 $filters = dblog_filters();
373 switch ($op) {
374 case t('Filter'):
375 foreach ($filters as $name => $filter) {
376 if (isset($form_state['values'][$name])) {
377 $_SESSION['dblog_overview_filter'][$name] = $form_state['values'][$name];
378 }
379 }
380 break;
381 case t('Reset'):
382 $_SESSION['dblog_overview_filter'] = array();
383 break;
384 }
385 return 'admin/reports/dblog';
386 }
387
394 function dblog_clear_log_form($form) {
395 $form['dblog_clear'] = array(
396 '#type' => 'fieldset',
397 '#title' => t('Clear log messages'),
398 '#description' => t('This will permanently remove the log messages from the database.'),
399 '#collapsible' => TRUE,
400 '#collapsed' => TRUE,
401 );
402 $form['dblog_clear']['clear'] = array(
403 '#type' => 'submit',
404 '#value' => t('Clear log messages'),
405 '#submit' => array('dblog_clear_log_submit'),
406 );
407
408 return $form;
409 }
410
414 function dblog_clear_log_submit() {
415 $_SESSION['dblog_overview_filter'] = array();
416 db_delete('watchdog')->execute();
417 drupal_set_message(t('Database log cleared.'));
418 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
_dblog_get_message_types
_dblog_get_message_types()
Definition: dblog.module:130
dblog_filter_form_validate
dblog_filter_form_validate($form, &$form_state)
Definition: dblog.admin.inc:359
$op
$op
Definition: update.php:404
l
l($text, $path, array $options=array())
Definition: common.inc:2432
WATCHDOG_INFO
const WATCHDOG_INFO
Definition: bootstrap.inc:108
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
$header
print $header
Definition: forum-topic-list.tpl.php:42
dblog_clear_log_form
dblog_clear_log_form($form)
Definition: dblog.admin.inc:394
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
WATCHDOG_ALERT
const WATCHDOG_ALERT
Definition: bootstrap.inc:83
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
dblog_build_filter_query
dblog_build_filter_query()
Definition: dblog.admin.inc:212
dblog_filter_form
dblog_filter_form($form)
Definition: dblog.admin.inc:315
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
dblog_filter_form_submit
dblog_filter_form_submit($form, &$form_state)
Definition: dblog.admin.inc:370
$value
print $value
Definition: user-profile-item.tpl.php:26
watchdog_severity_levels
watchdog_severity_levels()
Definition: common.inc:7389
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$output
$output
Definition: authorize.php:93
WATCHDOG_DEBUG
const WATCHDOG_DEBUG
Definition: bootstrap.inc:113
dblog_event
dblog_event($id)
Definition: dblog.admin.inc:152
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
WATCHDOG_CRITICAL
const WATCHDOG_CRITICAL
Definition: bootstrap.inc:88
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
dblog_clear_log_submit
dblog_clear_log_submit()
Definition: dblog.admin.inc:414
$classes
print $classes
Definition: contextual-links-example-object.tpl.php:31
WATCHDOG_EMERGENCY
const WATCHDOG_EMERGENCY
Definition: bootstrap.inc:78
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
dblog_top
dblog_top($type)
Definition: dblog.admin.inc:102
theme_dblog_message
theme_dblog_message($variables)
Definition: dblog.admin.inc:284
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
dblog_overview
dblog_overview()
Definition: dblog.admin.inc:21
truncate_utf8
truncate_utf8($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
Definition: unicode.inc:316
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
dblog_filters
dblog_filters()
Definition: dblog.admin.inc:250
drupal_html_class
drupal_html_class($class)
Definition: common.inc:3841
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/batch.inc Source File

  • includes
batch.inc
Go to the documentation of this file.
1 <?php
2
27 function batch_load($id) {
28 $batch = db_query("SELECT batch FROM {batch} WHERE bid = :bid AND token = :token", array(
29 ':bid' => $id,
30 ':token' => drupal_get_token($id),
31 ))->fetchField();
32 if ($batch) {
33 return unserialize($batch);
34 }
35 return FALSE;
36 }
37
43 function _batch_page() {
44 $batch = &batch_get();
45
46 if (!isset($_REQUEST['id'])) {
47 return FALSE;
48 }
49
50 // Retrieve the current state of the batch.
51 if (!$batch) {
52 $batch = batch_load($_REQUEST['id']);
53 if (!$batch) {
54 drupal_set_message(t('No active batch.'), 'error');
55 drupal_goto();
56 }
57 }
58
59 // Register database update for the end of processing.
60 drupal_register_shutdown_function('_batch_shutdown');
61
62 // Add batch-specific CSS.
63 foreach ($batch['sets'] as $batch_set) {
64 if (isset($batch_set['css'])) {
65 foreach ($batch_set['css'] as $css) {
66 drupal_add_css($css);
67 }
68 }
69 }
70
71 $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
72 $output = NULL;
73 switch ($op) {
74 case 'start':
75 $output = _batch_start();
76 break;
77
78 case 'do':
79 // JavaScript-based progress page callback.
80 _batch_do();
81 break;
82
83 case 'do_nojs':
84 // Non-JavaScript-based progress page.
85 $output = _batch_progress_page_nojs();
86 break;
87
88 case 'finished':
89 $output = _batch_finished();
90 break;
91 }
92
93 return $output;
94 }
95
103 function _batch_start() {
104 if (isset($_COOKIE['has_js']) && $_COOKIE['has_js']) {
105 return _batch_progress_page_js();
106 }
107 else {
108 return _batch_progress_page_nojs();
109 }
110 }
111
123 function _batch_progress_page_js() {
124 $batch = batch_get();
125
126 $current_set = _batch_current_set();
127 drupal_set_title($current_set['title'], PASS_THROUGH);
128
129 // Merge required query parameters for batch processing into those provided by
130 // batch_set() or hook_batch_alter().
131 $batch['url_options']['query']['id'] = $batch['id'];
132
133 $js_setting = array(
134 'batch' => array(
135 'errorMessage' => $current_set['error_message'] . '<br />' . $batch['error_message'],
136 'initMessage' => $current_set['init_message'],
137 'uri' => url($batch['url'], $batch['url_options']),
138 ),
139 );
140 drupal_add_js($js_setting, 'setting');
141 drupal_add_library('system', 'drupal.batch');
142
143 return '<div id="progress"></div>';
144 }
145
152 function _batch_do() {
153 // HTTP POST required.
154 if ($_SERVER['REQUEST_METHOD'] != 'POST') {
155 drupal_set_message(t('HTTP POST is required.'), 'error');
156 drupal_set_title(t('Error'));
157 return '';
158 }
159
160 // Perform actual processing.
161 list($percentage, $message) = _batch_process();
162
163 drupal_json_output(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message));
164 }
165
171 function _batch_progress_page_nojs() {
172 $batch = &batch_get();
173
174 $current_set = _batch_current_set();
175 drupal_set_title($current_set['title'], PASS_THROUGH);
176
177 $new_op = 'do_nojs';
178
179 if (!isset($batch['running'])) {
180 // This is the first page so we return some output immediately.
181 $percentage = 0;
182 $message = $current_set['init_message'];
183 $batch['running'] = TRUE;
184 }
185 else {
186 // This is one of the later requests; do some processing first.
187
188 // Error handling: if PHP dies due to a fatal error (e.g. a nonexistent
189 // function), it will output whatever is in the output buffer, followed by
190 // the error message.
191 ob_start();
192 $fallback = $current_set['error_message'] . '<br />' . $batch['error_message'];
193 $fallback = theme('maintenance_page', array('content' => $fallback, 'show_messages' => FALSE));
194
195 // We strip the end of the page using a marker in the template, so any
196 // additional HTML output by PHP shows up inside the page rather than below
197 // it. While this causes invalid HTML, the same would be true if we didn't,
198 // as content is not allowed to appear after </html> anyway.
199 list($fallback) = explode('<!--partial-->', $fallback);
200 print $fallback;
201
202 // Perform actual processing.
203 list($percentage, $message) = _batch_process($batch);
204 if ($percentage == 100) {
205 $new_op = 'finished';
206 }
207
208 // PHP did not die; remove the fallback output.
209 ob_end_clean();
210 }
211
212 // Merge required query parameters for batch processing into those provided by
213 // batch_set() or hook_batch_alter().
214 $batch['url_options']['query']['id'] = $batch['id'];
215 $batch['url_options']['query']['op'] = $new_op;
216
217 $url = url($batch['url'], $batch['url_options']);
218 $element = array(
219 '#tag' => 'meta',
220 '#attributes' => array(
221 'http-equiv' => 'Refresh',
222 'content' => '0; URL=' . $url,
223 ),
224 );
225 drupal_add_html_head($element, 'batch_progress_meta_refresh');
226
227 return theme('progress_bar', array('percent' => $percentage, 'message' => $message));
228 }
229
241 function _batch_process() {
242 $batch = &batch_get();
243 $current_set = &_batch_current_set();
244 // Indicate that this batch set needs to be initialized.
245 $set_changed = TRUE;
246
247 // If this batch was marked for progressive execution (e.g. forms submitted by
248 // drupal_form_submit()), initialize a timer to determine whether we need to
249 // proceed with the same batch phase when a processing time of 1 second has
250 // been exceeded.
251 if ($batch['progressive']) {
252 timer_start('batch_processing');
253 }
254
255 if (empty($current_set['start'])) {
256 $current_set['start'] = microtime(TRUE);
257 }
258
259 $queue = _batch_queue($current_set);
260
261 while (!$current_set['success']) {
262 // If this is the first time we iterate this batch set in the current
263 // request, we check if it requires an additional file for functions
264 // definitions.
265 if ($set_changed && isset($current_set['file']) && is_file($current_set['file'])) {
266 include_once DRUPAL_ROOT . '/' . $current_set['file'];
267 }
268
269 $task_message = '';
270 // Assume a single pass operation and set the completion level to 1 by
271 // default.
272 $finished = 1;
273
274 if ($item = $queue->claimItem()) {
275 list($function, $args) = $item->data;
276
277 // Build the 'context' array and execute the function call.
278 $batch_context = array(
279 'sandbox' => &$current_set['sandbox'],
280 'results' => &$current_set['results'],
281 'finished' => &$finished,
282 'message' => &$task_message,
283 );
284 call_user_func_array($function, array_merge($args, array(&$batch_context)));
285
286 if ($finished >= 1) {
287 // Make sure this step is not counted twice when computing $current.
288 $finished = 0;
289 // Remove the processed operation and clear the sandbox.
290 $queue->deleteItem($item);
291 $current_set['count']--;
292 $current_set['sandbox'] = array();
293 }
294 }
295
296 // When all operations in the current batch set are completed, browse
297 // through the remaining sets, marking them 'successfully processed'
298 // along the way, until we find a set that contains operations.
299 // _batch_next_set() executes form submit handlers stored in 'control'
300 // sets (see form_execute_handlers()), which can in turn add new sets to
301 // the batch.
302 $set_changed = FALSE;
303 $old_set = $current_set;
304 while (empty($current_set['count']) && ($current_set['success'] = TRUE) && _batch_next_set()) {
305 $current_set = &_batch_current_set();
306 $current_set['start'] = microtime(TRUE);
307 $set_changed = TRUE;
308 }
309
310 // At this point, either $current_set contains operations that need to be
311 // processed or all sets have been completed.
312 $queue = _batch_queue($current_set);
313
314 // If we are in progressive mode, break processing after 1 second.
315 if ($batch['progressive'] && timer_read('batch_processing') > 1000) {
316 // Record elapsed wall clock time.
317 $current_set['elapsed'] = round((microtime(TRUE) - $current_set['start']) * 1000, 2);
318 break;
319 }
320 }
321
322 if ($batch['progressive']) {
323 // Gather progress information.
324
325 // Reporting 100% progress will cause the whole batch to be considered
326 // processed. If processing was paused right after moving to a new set,
327 // we have to use the info from the new (unprocessed) set.
328 if ($set_changed && isset($current_set['queue'])) {
329 // Processing will continue with a fresh batch set.
330 $remaining = $current_set['count'];
331 $total = $current_set['total'];
332 $progress_message = $current_set['init_message'];
333 $task_message = '';
334 }
335 else {
336 // Processing will continue with the current batch set.
337 $remaining = $old_set['count'];
338 $total = $old_set['total'];
339 $progress_message = $old_set['progress_message'];
340 }
341
342 // Total progress is the number of operations that have fully run plus the
343 // completion level of the current operation.
344 $current = $total - $remaining + $finished;
345 $percentage = _batch_api_percentage($total, $current);
346 $elapsed = isset($current_set['elapsed']) ? $current_set['elapsed'] : 0;
347 $values = array(
348 '@remaining' => $remaining,
349 '@total' => $total,
350 '@current' => floor($current),
351 '@percentage' => $percentage,
352 '@elapsed' => format_interval($elapsed / 1000),
353 // If possible, estimate remaining processing time.
354 '@estimate' => ($current > 0) ? format_interval(($elapsed * ($total - $current) / $current) / 1000) : '-',
355 );
356 $message = strtr($progress_message, $values);
357 if (!empty($message)) {
358 $message .= '<br />';
359 }
360 if (!empty($task_message)) {
361 $message .= $task_message;
362 }
363
364 return array($percentage, $message);
365 }
366 else {
367 // If we are not in progressive mode, the entire batch has been processed.
368 return _batch_finished();
369 }
370 }
371
391 function _batch_api_percentage($total, $current) {
392 if (!$total || $total == $current) {
393 // If $total doesn't evaluate as true or is equal to the current set, then
394 // we're finished, and we can return "100".
395 $percentage = "100";
396 }
397 else {
398 // We add a new digit at 200, 2000, etc. (since, for example, 199/200
399 // would round up to 100% if we didn't).
400 $decimal_places = max(0, floor(log10($total / 2.0)) - 1);
401 do {
402 // Calculate the percentage to the specified number of decimal places.
403 $percentage = sprintf('%01.' . $decimal_places . 'f', round($current / $total * 100, $decimal_places));
404 // When $current is an integer, the above calculation will always be
405 // correct. However, if $current is a floating point number (in the case
406 // of a multi-step batch operation that is not yet complete), $percentage
407 // may be erroneously rounded up to 100%. To prevent that, we add one
408 // more decimal place and try again.
409 $decimal_places++;
410 } while ($percentage == '100');
411 }
412 return $percentage;
413 }
414
418 function &_batch_current_set() {
419 $batch = &batch_get();
420 return $batch['sets'][$batch['current_set']];
421 }
422
433 function _batch_next_set() {
434 $batch = &batch_get();
435 if (isset($batch['sets'][$batch['current_set'] + 1])) {
436 $batch['current_set']++;
437 $current_set = &_batch_current_set();
438 if (isset($current_set['form_submit']) && ($function = $current_set['form_submit']) && function_exists($function)) {
439 // We use our stored copies of $form and $form_state to account for
440 // possible alterations by previous form submit handlers.
441 $function($batch['form_state']['complete form'], $batch['form_state']);
442 }
443 return TRUE;
444 }
445 }
446
453 function _batch_finished() {
454 $batch = &batch_get();
455
456 // Execute the 'finished' callbacks for each batch set, if defined.
457 foreach ($batch['sets'] as $batch_set) {
458 if (isset($batch_set['finished'])) {
459 // Check if the set requires an additional file for function definitions.
460 if (isset($batch_set['file']) && is_file($batch_set['file'])) {
461 include_once DRUPAL_ROOT . '/' . $batch_set['file'];
462 }
463 if (function_exists($batch_set['finished'])) {
464 $queue = _batch_queue($batch_set);
465 $operations = $queue->getAllItems();
466 $batch_set['finished']($batch_set['success'], $batch_set['results'], $operations, format_interval($batch_set['elapsed'] / 1000));
467 }
468 }
469 }
470
471 // Clean up the batch table and unset the static $batch variable.
472 if ($batch['progressive']) {
473 db_delete('batch')
474 ->condition('bid', $batch['id'])
475 ->execute();
476 foreach ($batch['sets'] as $batch_set) {
477 if ($queue = _batch_queue($batch_set)) {
478 $queue->deleteQueue();
479 }
480 }
481 }
482 $_batch = $batch;
483 $batch = NULL;
484
485 // Clean-up the session. Not needed for CLI updates.
486 if (isset($_SESSION)) {
487 unset($_SESSION['batches'][$batch['id']]);
488 if (empty($_SESSION['batches'])) {
489 unset($_SESSION['batches']);
490 }
491 }
492
493 // Redirect if needed.
494 if ($_batch['progressive']) {
495 // Revert the 'destination' that was saved in batch_process().
496 if (isset($_batch['destination'])) {
497 $_GET['destination'] = $_batch['destination'];
498 }
499
500 // Determine the target path to redirect to.
501 if (!isset($_batch['form_state']['redirect'])) {
502 if (isset($_batch['redirect'])) {
503 $_batch['form_state']['redirect'] = $_batch['redirect'];
504 }
505 else {
506 $_batch['form_state']['redirect'] = $_batch['source_url'];
507 }
508 }
509
510 // Use drupal_redirect_form() to handle the redirection logic.
511 drupal_redirect_form($_batch['form_state']);
512
513 // If no redirection happened, redirect to the originating page. In case the
514 // form needs to be rebuilt, save the final $form_state for
515 // drupal_build_form().
516 if (!empty($_batch['form_state']['rebuild'])) {
517 $_SESSION['batch_form_state'] = $_batch['form_state'];
518 }
519 $function = $_batch['redirect_callback'];
520 if (function_exists($function)) {
521 $function($_batch['source_url'], array('query' => array('op' => 'finish', 'id' => $_batch['id'])));
522 }
523 }
524 }
525
532 function _batch_shutdown() {
533 if ($batch = batch_get()) {
534 db_update('batch')
535 ->fields(array('batch' => serialize($batch)))
536 ->condition('bid', $batch['id'])
537 ->execute();
538 }
539 }
_batch_start
_batch_start()
Definition: batch.inc:103
_batch_page
_batch_page()
Definition: batch.inc:43
_batch_api_percentage
_batch_api_percentage($total, $current)
Definition: batch.inc:391
_batch_current_set
& _batch_current_set()
Definition: batch.inc:418
$op
$op
Definition: update.php:404
drupal_redirect_form
drupal_redirect_form($form_state)
Definition: form.inc:1249
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
drupal_json_output
drupal_json_output($var=NULL)
Definition: common.inc:5041
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
$percentage
print $percentage
Definition: poll-bar--block.tpl.php:22
print
print
Definition: php-2.php:2
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
drupal_add_library
drupal_add_library($module, $name, $every_page=NULL)
Definition: common.inc:4694
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$url
print $url
Definition: search-result.tpl.php:70
_batch_progress_page_nojs
_batch_progress_page_nojs()
Definition: batch.inc:171
_batch_process
_batch_process()
Definition: batch.inc:241
_batch_progress_page_js
_batch_progress_page_js()
Definition: batch.inc:123
timer_start
timer_start($name)
Definition: bootstrap.inc:460
batch_load
batch_load($id)
Definition: batch.inc:27
_batch_next_set
_batch_next_set()
Definition: batch.inc:433
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
_batch_finished
_batch_finished()
Definition: batch.inc:453
_batch_do
_batch_do()
Definition: batch.inc:152
$output
$output
Definition: authorize.php:93
_batch_shutdown
_batch_shutdown()
Definition: batch.inc:532
timer_read
timer_read($name)
Definition: bootstrap.inc:476
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
drupal_get_token
drupal_get_token($value= '')
Definition: common.inc:5077
batch_get
& batch_get()
Definition: form.inc:4538
_batch_queue
_batch_queue($batch_set)
Definition: form.inc:4593
drupal_add_html_head
drupal_add_html_head($data=NULL, $key=NULL)
Definition: common.inc:299
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
drupal_register_shutdown_function
& drupal_register_shutdown_function($callback=NULL)
Definition: bootstrap.inc:3417
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search.module Source File

  • modules
  • search
search.module
Go to the documentation of this file.
1 <?php
2
11 define('PREG_CLASS_NUMBERS',
12 '\x{30}-\x{39}\x{b2}\x{b3}\x{b9}\x{bc}-\x{be}\x{660}-\x{669}\x{6f0}-\x{6f9}' .
13 '\x{966}-\x{96f}\x{9e6}-\x{9ef}\x{9f4}-\x{9f9}\x{a66}-\x{a6f}\x{ae6}-\x{aef}' .
14 '\x{b66}-\x{b6f}\x{be7}-\x{bf2}\x{c66}-\x{c6f}\x{ce6}-\x{cef}\x{d66}-\x{d6f}' .
15 '\x{e50}-\x{e59}\x{ed0}-\x{ed9}\x{f20}-\x{f33}\x{1040}-\x{1049}\x{1369}-' .
16 '\x{137c}\x{16ee}-\x{16f0}\x{17e0}-\x{17e9}\x{17f0}-\x{17f9}\x{1810}-\x{1819}' .
17 '\x{1946}-\x{194f}\x{2070}\x{2074}-\x{2079}\x{2080}-\x{2089}\x{2153}-\x{2183}' .
18 '\x{2460}-\x{249b}\x{24ea}-\x{24ff}\x{2776}-\x{2793}\x{3007}\x{3021}-\x{3029}' .
19 '\x{3038}-\x{303a}\x{3192}-\x{3195}\x{3220}-\x{3229}\x{3251}-\x{325f}\x{3280}-' .
20 '\x{3289}\x{32b1}-\x{32bf}\x{ff10}-\x{ff19}');
21
25 define('PREG_CLASS_PUNCTUATION',
26 '\x{21}-\x{23}\x{25}-\x{2a}\x{2c}-\x{2f}\x{3a}\x{3b}\x{3f}\x{40}\x{5b}-\x{5d}' .
27 '\x{5f}\x{7b}\x{7d}\x{a1}\x{ab}\x{b7}\x{bb}\x{bf}\x{37e}\x{387}\x{55a}-\x{55f}' .
28 '\x{589}\x{58a}\x{5be}\x{5c0}\x{5c3}\x{5f3}\x{5f4}\x{60c}\x{60d}\x{61b}\x{61f}' .
29 '\x{66a}-\x{66d}\x{6d4}\x{700}-\x{70d}\x{964}\x{965}\x{970}\x{df4}\x{e4f}' .
30 '\x{e5a}\x{e5b}\x{f04}-\x{f12}\x{f3a}-\x{f3d}\x{f85}\x{104a}-\x{104f}\x{10fb}' .
31 '\x{1361}-\x{1368}\x{166d}\x{166e}\x{169b}\x{169c}\x{16eb}-\x{16ed}\x{1735}' .
32 '\x{1736}\x{17d4}-\x{17d6}\x{17d8}-\x{17da}\x{1800}-\x{180a}\x{1944}\x{1945}' .
33 '\x{2010}-\x{2027}\x{2030}-\x{2043}\x{2045}-\x{2051}\x{2053}\x{2054}\x{2057}' .
34 '\x{207d}\x{207e}\x{208d}\x{208e}\x{2329}\x{232a}\x{23b4}-\x{23b6}\x{2768}-' .
35 '\x{2775}\x{27e6}-\x{27eb}\x{2983}-\x{2998}\x{29d8}-\x{29db}\x{29fc}\x{29fd}' .
36 '\x{3001}-\x{3003}\x{3008}-\x{3011}\x{3014}-\x{301f}\x{3030}\x{303d}\x{30a0}' .
37 '\x{30fb}\x{fd3e}\x{fd3f}\x{fe30}-\x{fe52}\x{fe54}-\x{fe61}\x{fe63}\x{fe68}' .
38 '\x{fe6a}\x{fe6b}\x{ff01}-\x{ff03}\x{ff05}-\x{ff0a}\x{ff0c}-\x{ff0f}\x{ff1a}' .
39 '\x{ff1b}\x{ff1f}\x{ff20}\x{ff3b}-\x{ff3d}\x{ff3f}\x{ff5b}\x{ff5d}\x{ff5f}-' .
40 '\x{ff65}');
41
57 define('PREG_CLASS_CJK', '\x{1100}-\x{11FF}\x{3040}-\x{309F}\x{30A1}-\x{318E}' .
58 '\x{31A0}-\x{31B7}\x{31F0}-\x{31FF}\x{3400}-\x{4DBF}\x{4E00}-\x{9FCF}' .
59 '\x{A000}-\x{A48F}\x{A4D0}-\x{A4FD}\x{A960}-\x{A97F}\x{AC00}-\x{D7FF}' .
60 '\x{F900}-\x{FAFF}\x{FF21}-\x{FF3A}\x{FF41}-\x{FF5A}\x{FF66}-\x{FFDC}' .
61 '\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}');
62
66 function search_help($path, $arg) {
67 switch ($path) {
68 case 'admin/help#search':
69 $output = '';
70 $output .= '<h3>' . t('About') . '</h3>';
71 $output .= '<p>' . t('The Search module provides the ability to index and search for content by exact keywords, and for users by username or e-mail. For more information, see the online handbook entry for <a href="@search-module">Search module</a>.', array('@search-module' => 'http://drupal.org/documentation/modules/search/', '@search' => url('search'))) . '</p>';
72 $output .= '<h3>' . t('Uses') . '</h3>';
73 $output .= '<dl>';
74 $output .= '<dt>' . t('Searching content and users') . '</dt>';
75 $output .= '<dd>' . t('Users with <em>Use search</em> permission can use the search block and <a href="@search">Search page</a>. Users with the <em>View published content</em> permission can search for content containing exact keywords. Users with the <em>View user profiles</em> permission can search for users containing the keyword anywhere in the user name, and users with the <em>Administer users</em> permission can search for users by email address. Additionally, users with <em>Use advanced search</em> permission can find content using more complex search methods and filtering by choosing the <em>Advanced search</em> option on the <a href="@search">Search page</a>.', array('@search' => url('search'))) . '</dd>';
76 $output .= '<dt>' . t('Indexing content with cron') . '</dt>';
77 $output .= '<dd>' . t('To provide keyword searching, the search engine maintains an index of words found in the content and its fields, along with text added to your content by other modules (such as comments from the core Comment module, and taxonomy terms from the core Taxonomy module). To build and maintain this index, a correctly configured <a href="@cron">cron maintenance task</a> is required. Users with <em>Administer search</em> permission can further configure the cron settings on the <a href="@searchsettings">Search settings page</a>.', array('@cron' => 'http://drupal.org/cron', '@searchsettings' => url('admin/config/search/settings'))) . '</dd>';
78 $output .= '<dt>' . t('Content reindexing') . '</dt>';
79 $output .= '<dd>' . t('Content-related actions on your site (creating, editing, or deleting content and comments) automatically cause affected content items to be marked for indexing or reindexing at the next cron run. When content is marked for reindexing, the previous content remains in the index until cron runs, at which time it is replaced by the new content. Unlike content-related actions, actions related to the structure of your site do not cause affected content to be marked for reindexing. Examples of structure-related actions that affect content include deleting or editing taxonomy terms, enabling or disabling modules that add text to content (such as Taxonomy, Comment, and field-providing modules), and modifying the fields or display parameters of your content types. If you take one of these actions and you want to ensure that the search index is updated to reflect your changed site structure, you can mark all content for reindexing by clicking the "Re-index site" button on the <a href="@searchsettings">Search settings page</a>. If you have a lot of content on your site, it may take several cron runs for the content to be reindexed.', array('@searchsettings' => url('admin/config/search/settings'))) . '</dd>';
80 $output .= '<dt>' . t('Configuring search settings') . '</dt>';
81 $output .= '<dd>' . t('Indexing behavior can be adjusted using the <a href="@searchsettings">Search settings page</a>. Users with <em>Administer search</em> permission can control settings such as the <em>Number of items to index per cron run</em>, <em>Indexing settings</em> (word length), <em>Active search modules</em>, and <em>Content ranking</em>, which lets you adjust the priority in which indexed content is returned in results.', array('@searchsettings' => url('admin/config/search/settings'))) . '</dd>';
82 $output .= '<dt>' . t('Search block') . '</dt>';
83 $output .= '<dd>' . t('The Search module includes a default <em>Search form</em> block, which can be enabled and configured on the <a href="@blocks">Blocks administration page</a>. The block is available to users with the <em>Search content</em> permission.', array('@blocks' => url('admin/structure/block'))) . '</dd>';
84 $output .= '<dt>' . t('Extending Search module') . '</dt>';
85 $output .= '<dd>' . t('By default, the Search module only supports exact keyword matching in content searches. You can modify this behavior by installing a language-specific stemming module for your language (such as <a href="http://drupal.org/project/porterstemmer">Porter Stemmer</a> for American English), which allows words such as walk, walking, and walked to be matched in the Search module. Another approach is to use a third-party search technology with stemming or partial word matching features built in, such as <a href="http://drupal.org/project/apachesolr">Apache Solr</a> or <a href="http://drupal.org/project/sphinx">Sphinx</a>. These and other <a href="@contrib-search">search-related contributed modules</a> can be downloaded by visiting Drupal.org.', array('@contrib-search' => 'http://drupal.org/project/modules?filters=tid%3A105')) . '</dd>';
86 $output .= '</dl>';
87 return $output;
88 case 'admin/config/search/settings':
89 return '<p>' . t('The search engine maintains an index of words found in your site\'s content. To build and maintain this index, a correctly configured <a href="@cron">cron maintenance task</a> is required. Indexing behavior can be adjusted using the settings below.', array('@cron' => url('admin/reports/status'))) . '</p>';
90 case 'search#noresults':
91 return t('<ul>
92 <li>Check if your spelling is correct.</li>
93 <li>Remove quotes around phrases to search for each word individually. <em>bike shed</em> will often show more results than <em>&quot;bike shed&quot;</em>.</li>
94 <li>Consider loosening your query with <em>OR</em>. <em>bike OR shed</em> will often show more results than <em>bike shed</em>.</li>
95 </ul>');
96 }
97 }
98
102 function search_theme() {
103 return array(
104 'search_block_form' => array(
105 'render element' => 'form',
106 'template' => 'search-block-form',
107 ),
108 'search_result' => array(
109 'variables' => array('result' => NULL, 'module' => NULL),
110 'file' => 'search.pages.inc',
111 'template' => 'search-result',
112 ),
113 'search_results' => array(
114 'variables' => array('results' => NULL, 'module' => NULL),
115 'file' => 'search.pages.inc',
116 'template' => 'search-results',
117 ),
118 );
119 }
120
124 function search_permission() {
125 return array(
126 'administer search' => array(
127 'title' => t('Administer search'),
128 ),
129 'search content' => array(
130 'title' => t('Use search'),
131 ),
132 'use advanced search' => array(
133 'title' => t('Use advanced search'),
134 ),
135 );
136 }
137
141 function search_block_info() {
142 $blocks['form']['info'] = t('Search form');
143 // Not worth caching.
144 $blocks['form']['cache'] = DRUPAL_NO_CACHE;
145 $blocks['form']['properties']['administrative'] = TRUE;
146 return $blocks;
147 }
148
152 function search_block_view($delta = '') {
153 if (user_access('search content')) {
154 $block['content'] = drupal_get_form('search_block_form');
155 return $block;
156 }
157 }
158
162 function search_menu() {
163 $items['search'] = array(
164 'title' => 'Search',
165 'page callback' => 'search_view',
166 'access callback' => 'search_is_active',
167 'type' => MENU_SUGGESTED_ITEM,
168 'file' => 'search.pages.inc',
169 );
170 $items['admin/config/search/settings'] = array(
171 'title' => 'Search settings',
172 'description' => 'Configure relevance settings for search and other indexing options.',
173 'page callback' => 'drupal_get_form',
174 'page arguments' => array('search_admin_settings'),
175 'access arguments' => array('administer search'),
176 'weight' => -10,
177 'file' => 'search.admin.inc',
178 );
179 $items['admin/config/search/settings/reindex'] = array(
180 'title' => 'Clear index',
181 'page callback' => 'drupal_get_form',
182 'page arguments' => array('search_reindex_confirm'),
183 'access arguments' => array('administer search'),
184 'type' => MENU_VISIBLE_IN_BREADCRUMB,
185 'file' => 'search.admin.inc',
186 );
187
188 // Add paths for searching. We add each module search path twice: once without
189 // and once with %menu_tail appended. The reason for this is that we want to
190 // preserve keywords when switching tabs, and also to have search tabs
191 // highlighted properly. The only way to do that within the Drupal menu
192 // system appears to be having two sets of tabs. See discussion on issue
193 // http://drupal.org/node/245103 for details.
194
195 drupal_static_reset('search_get_info');
196 $default_info = search_get_default_module_info();
197 if ($default_info) {
198 foreach (search_get_info() as $module => $search_info) {
199 $path = 'search/' . $search_info['path'];
200 $items[$path] = array(
201 'title' => $search_info['title'],
202 'page callback' => 'search_view',
203 'page arguments' => array($module, ''),
204 'access callback' => '_search_menu_access',
205 'access arguments' => array($module),
206 'type' => MENU_LOCAL_TASK,
207 'file' => 'search.pages.inc',
208 'weight' => $module == $default_info['module'] ? -10 : 0,
209 );
210 $items["$path/%menu_tail"] = array(
211 'title' => $search_info['title'],
212 'load arguments' => array('%map', '%index'),
213 'page callback' => 'search_view',
214 'page arguments' => array($module, 2),
215 'access callback' => '_search_menu_access',
216 'access arguments' => array($module),
217 // The default local task points to its parent, but this item points to
218 // where it should so it should not be changed.
219 'type' => MENU_LOCAL_TASK,
220 'file' => 'search.pages.inc',
221 'weight' => 0,
222 // These tabs are not subtabs.
223 'tab_root' => 'search/' . $default_info['path'] . '/%',
224 // These tabs need to display at the same level.
225 'tab_parent' => 'search/' . $default_info['path'],
226 );
227 }
228 }
229 return $items;
230 }
231
235 function search_is_active() {
236 // This path cannot be accessed if there are no active modules.
237 return user_access('search content') && search_get_info();
238 }
239
254 function search_get_info($all = FALSE) {
255 $search_hooks = &drupal_static(__FUNCTION__);
256
257 if (!isset($search_hooks)) {
258 foreach (module_implements('search_info') as $module) {
259 $search_hooks[$module] = call_user_func($module . '_search_info');
260 // Use module name as the default value.
261 $search_hooks[$module] += array('title' => $module, 'path' => $module);
262 // Include the module name itself in the array.
263 $search_hooks[$module]['module'] = $module;
264 }
265 }
266
267 if ($all) {
268 return $search_hooks;
269 }
270
271 $active = variable_get('search_active_modules', array('node', 'user'));
272 return array_intersect_key($search_hooks, array_flip($active));
273 }
274
281 function search_get_default_module_info() {
282 $info = search_get_info();
283 $default = variable_get('search_default_module', 'node');
284 if (isset($info[$default])) {
285 return $info[$default];
286 }
287 // The variable setting does not match any active module, so just return
288 // the info for the first active module (if any).
289 return reset($info);
290 }
291
295 function _search_menu_access($name) {
296 return user_access('search content') && (!function_exists($name . '_search_access') || module_invoke($name, 'search_access'));
297 }
298
310 function search_reindex($sid = NULL, $module = NULL, $reindex = FALSE) {
311 if ($module == NULL && $sid == NULL) {
312 module_invoke_all('search_reset');
313 }
314 else {
315 db_delete('search_dataset')
316 ->condition('sid', $sid)
317 ->condition('type', $module)
318 ->execute();
319 db_delete('search_index')
320 ->condition('sid', $sid)
321 ->condition('type', $module)
322 ->execute();
323 // Don't remove links if re-indexing.
324 if (!$reindex) {
325 db_delete('search_node_links')
326 ->condition('sid', $sid)
327 ->condition('type', $module)
328 ->execute();
329 }
330 }
331 }
332
339 function search_dirty($word = NULL) {
340 $dirty = &drupal_static(__FUNCTION__, array());
341 if ($word !== NULL) {
342 $dirty[$word] = TRUE;
343 }
344 else {
345 return $dirty;
346 }
347 }
348
356 function search_cron() {
357 // We register a shutdown function to ensure that search_total is always up
358 // to date.
359 drupal_register_shutdown_function('search_update_totals');
360
361 foreach (variable_get('search_active_modules', array('node', 'user')) as $module) {
362 // Update word index
363 module_invoke($module, 'update_index');
364 }
365 }
366
373 function search_update_totals() {
374 // Update word IDF (Inverse Document Frequency) counts for new/changed words.
375 foreach (search_dirty() as $word => $dummy) {
376 // Get total count
377 $total = db_query("SELECT SUM(score) FROM {search_index} WHERE word = :word", array(':word' => $word), array('target' => 'slave'))->fetchField();
378 // Apply Zipf's law to equalize the probability distribution.
379 $total = log10(1 + 1/(max(1, $total)));
380 db_merge('search_total')
381 ->key(array('word' => $word))
382 ->fields(array('count' => $total))
383 ->execute();
384 }
385 // Find words that were deleted from search_index, but are still in
386 // search_total. We use a LEFT JOIN between the two tables and keep only the
387 // rows which fail to join.
388 $result = db_query("SELECT t.word AS realword, i.word FROM {search_total} t LEFT JOIN {search_index} i ON t.word = i.word WHERE i.word IS NULL", array(), array('target' => 'slave'));
389 $or = db_or();
390 foreach ($result as $word) {
391 $or->condition('word', $word->realword);
392 }
393 if (count($or) > 0) {
394 db_delete('search_total')
395 ->condition($or)
396 ->execute();
397 }
398 }
399
411 function search_simplify($text) {
412 // Decode entities to UTF-8
413 $text = decode_entities($text);
414
415 // Lowercase
416 $text = drupal_strtolower($text);
417
418 // Call an external processor for word handling.
419 search_invoke_preprocess($text);
420
421 // Simple CJK handling
422 if (variable_get('overlap_cjk', TRUE)) {
423 $text = preg_replace_callback('/[' . PREG_CLASS_CJK . ']+/u', 'search_expand_cjk', $text);
424 }
425
426 // To improve searching for numerical data such as dates, IP addresses
427 // or version numbers, we consider a group of numerical characters
428 // separated only by punctuation characters to be one piece.
429 // This also means that searching for e.g. '20/03/1984' also returns
430 // results with '20-03-1984' in them.
431 // Readable regexp: ([number]+)[punctuation]+(?=[number])
432 $text = preg_replace('/([' . PREG_CLASS_NUMBERS . ']+)[' . PREG_CLASS_PUNCTUATION . ']+(?=[' . PREG_CLASS_NUMBERS . '])/u', '\1', $text);
433
434 // Multiple dot and dash groups are word boundaries and replaced with space.
435 // No need to use the unicode modifer here because 0-127 ASCII characters
436 // can't match higher UTF-8 characters as the leftmost bit of those are 1.
437 $text = preg_replace('/[.-]{2,}/', ' ', $text);
438
439 // The dot, underscore and dash are simply removed. This allows meaningful
440 // search behavior with acronyms and URLs. See unicode note directly above.
441 $text = preg_replace('/[._-]+/', '', $text);
442
443 // With the exception of the rules above, we consider all punctuation,
444 // marks, spacers, etc, to be a word boundary.
445 $text = preg_replace('/[' . PREG_CLASS_UNICODE_WORD_BOUNDARY . ']+/u', ' ', $text);
446
447 // Truncate everything to 50 characters.
448 $words = explode(' ', $text);
449 array_walk($words, '_search_index_truncate');
450 $text = implode(' ', $words);
451
452 return $text;
453 }
454
475 function search_expand_cjk($matches) {
476 $min = variable_get('minimum_word_size', 3);
477 $str = $matches[0];
478 $length = drupal_strlen($str);
479 // If the text is shorter than the minimum word size, don't tokenize it.
480 if ($length <= $min) {
481 return ' ' . $str . ' ';
482 }
483 $tokens = ' ';
484 // Build a FIFO queue of characters.
485 $chars = array();
486 for ($i = 0; $i < $length; $i++) {
487 // Add the next character off the beginning of the string to the queue.
488 $current = drupal_substr($str, 0, 1);
489 $str = substr($str, strlen($current));
490 $chars[] = $current;
491 if ($i >= $min - 1) {
492 // Make a token of $min characters, and add it to the token string.
493 $tokens .= implode('', $chars) . ' ';
494 // Shift out the first character in the queue.
495 array_shift($chars);
496 }
497 }
498 return $tokens;
499 }
500
504 function search_index_split($text) {
505 $last = &drupal_static(__FUNCTION__);
506 $lastsplit = &drupal_static(__FUNCTION__ . ':lastsplit');
507
508 if ($last == $text) {
509 return $lastsplit;
510 }
511 // Process words
512 $text = search_simplify($text);
513 $words = explode(' ', $text);
514
515 // Save last keyword result
516 $last = $text;
517 $lastsplit = $words;
518
519 return $words;
520 }
521
525 function _search_index_truncate(&$text) {
526 if (is_numeric($text)) {
527 $text = ltrim($text, '0');
528 }
529 $text = truncate_utf8($text, 50);
530 }
531
535 function search_invoke_preprocess(&$text) {
536 foreach (module_implements('search_preprocess') as $module) {
537 $text = module_invoke($module, 'search_preprocess', $text);
538 }
539 }
540
554 function search_index($sid, $module, $text) {
555 $minimum_word_size = variable_get('minimum_word_size', 3);
556
557 // Link matching
558 global $base_url;
559 $node_regexp = '@href=[\'"]?(?:' . preg_quote($base_url, '@') . '/|' . preg_quote(base_path(), '@') . ')(?:\?q=)?/?((?![a-z]+:)[^\'">]+)[\'">]@i';
560
561 // Multipliers for scores of words inside certain HTML tags. The weights are stored
562 // in a variable so that modules can overwrite the default weights.
563 // Note: 'a' must be included for link ranking to work.
564 $tags = variable_get('search_tag_weights', array(
565 'h1' => 25,
566 'h2' => 18,
567 'h3' => 15,
568 'h4' => 12,
569 'h5' => 9,
570 'h6' => 6,
571 'u' => 3,
572 'b' => 3,
573 'i' => 3,
574 'strong' => 3,
575 'em' => 3,
576 'a' => 10));
577
578 // Strip off all ignored tags to speed up processing, but insert space before/after
579 // them to keep word boundaries.
580 $text = str_replace(array('<', '>'), array(' <', '> '), $text);
581 $text = strip_tags($text, '<' . implode('><', array_keys($tags)) . '>');
582
583 // Split HTML tags from plain text.
584 $split = preg_split('/\s*<([^>]+?)>\s*/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
585 // Note: PHP ensures the array consists of alternating delimiters and literals
586 // and begins and ends with a literal (inserting $null as required).
587
588 $tag = FALSE; // Odd/even counter. Tag or no tag.
589 $link = FALSE; // State variable for link analyzer
590 $score = 1; // Starting score per word
591 $accum = ' '; // Accumulator for cleaned up data
592 $tagstack = array(); // Stack with open tags
593 $tagwords = 0; // Counter for consecutive words
594 $focus = 1; // Focus state
595
596 $results = array(0 => array()); // Accumulator for words for index
597
598 foreach ($split as $value) {
599 if ($tag) {
600 // Increase or decrease score per word based on tag
601 list($tagname) = explode(' ', $value, 2);
602 $tagname = drupal_strtolower($tagname);
603 // Closing or opening tag?
604 if ($tagname[0] == '/') {
605 $tagname = substr($tagname, 1);
606 // If we encounter unexpected tags, reset score to avoid incorrect boosting.
607 if (!count($tagstack) || $tagstack[0] != $tagname) {
608 $tagstack = array();
609 $score = 1;
610 }
611 else {
612 // Remove from tag stack and decrement score
613 $score = max(1, $score - $tags[array_shift($tagstack)]);
614 }
615 if ($tagname == 'a') {
616 $link = FALSE;
617 }
618 }
619 else {
620 if (isset($tagstack[0]) && $tagstack[0] == $tagname) {
621 // None of the tags we look for make sense when nested identically.
622 // If they are, it's probably broken HTML.
623 $tagstack = array();
624 $score = 1;
625 }
626 else {
627 // Add to open tag stack and increment score
628 array_unshift($tagstack, $tagname);
629 $score += $tags[$tagname];
630 }
631 if ($tagname == 'a') {
632 // Check if link points to a node on this site
633 if (preg_match($node_regexp, $value, $match)) {
634 $path = drupal_get_normal_path($match[1]);
635 if (preg_match('!(?:node|book)/(?:view/)?([0-9]+)!i', $path, $match)) {
636 $linknid = $match[1];
637 if ($linknid > 0) {
638 $node = db_query('SELECT title, nid, vid FROM {node} WHERE nid = :nid', array(':nid' => $linknid), array('target' => 'slave'))->fetchObject();
639 $link = TRUE;
640 $linktitle = $node->title;
641 }
642 }
643 }
644 }
645 }
646 // A tag change occurred, reset counter.
647 $tagwords = 0;
648 }
649 else {
650 // Note: use of PREG_SPLIT_DELIM_CAPTURE above will introduce empty values
651 if ($value != '') {
652 if ($link) {
653 // Check to see if the node link text is its URL. If so, we use the target node title instead.
654 if (preg_match('!^https?://!i', $value)) {
655 $value = $linktitle;
656 }
657 }
658 $words = search_index_split($value);
659 foreach ($words as $word) {
660 // Add word to accumulator
661 $accum .= $word . ' ';
662 // Check wordlength
663 if (is_numeric($word) || drupal_strlen($word) >= $minimum_word_size) {
664 // Links score mainly for the target.
665 if ($link) {
666 if (!isset($results[$linknid])) {
667 $results[$linknid] = array();
668 }
669 $results[$linknid][] = $word;
670 // Reduce score of the link caption in the source.
671 $focus *= 0.2;
672 }
673 // Fall-through
674 if (!isset($results[0][$word])) {
675 $results[0][$word] = 0;
676 }
677 $results[0][$word] += $score * $focus;
678
679 // Focus is a decaying value in terms of the amount of unique words up to this point.
680 // From 100 words and more, it decays, to e.g. 0.5 at 500 words and 0.3 at 1000 words.
681 $focus = min(1, .01 + 3.5 / (2 + count($results[0]) * .015));
682 }
683 $tagwords++;
684 // Too many words inside a single tag probably mean a tag was accidentally left open.
685 if (count($tagstack) && $tagwords >= 15) {
686 $tagstack = array();
687 $score = 1;
688 }
689 }
690 }
691 }
692 $tag = !$tag;
693 }
694
695 search_reindex($sid, $module, TRUE);
696
697 // Insert cleaned up data into dataset
698 db_insert('search_dataset')
699 ->fields(array(
700 'sid' => $sid,
701 'type' => $module,
702 'data' => $accum,
703 'reindex' => 0,
704 ))
705 ->execute();
706
707 // Insert results into search index
708 foreach ($results[0] as $word => $score) {
709 // If a word already exists in the database, its score gets increased
710 // appropriately. If not, we create a new record with the appropriate
711 // starting score.
712 db_merge('search_index')
713 ->key(array(
714 'word' => $word,
715 'sid' => $sid,
716 'type' => $module,
717 ))
718 ->fields(array('score' => $score))
719 ->expression('score', 'score + :score', array(':score' => $score))
720 ->execute();
721 search_dirty($word);
722 }
723 unset($results[0]);
724
725 // Get all previous links from this item.
726 $result = db_query("SELECT nid, caption FROM {search_node_links} WHERE sid = :sid AND type = :type", array(
727 ':sid' => $sid,
728 ':type' => $module
729 ), array('target' => 'slave'));
730 $links = array();
731 foreach ($result as $link) {
732 $links[$link->nid] = $link->caption;
733 }
734
735 // Now store links to nodes.
736 foreach ($results as $nid => $words) {
737 $caption = implode(' ', $words);
738 if (isset($links[$nid])) {
739 if ($links[$nid] != $caption) {
740 // Update the existing link and mark the node for reindexing.
741 db_update('search_node_links')
742 ->fields(array('caption' => $caption))
743 ->condition('sid', $sid)
744 ->condition('type', $module)
745 ->condition('nid', $nid)
746 ->execute();
747 search_touch_node($nid);
748 }
749 // Unset the link to mark it as processed.
750 unset($links[$nid]);
751 }
752 elseif ($sid != $nid || $module != 'node') {
753 // Insert the existing link and mark the node for reindexing, but don't
754 // reindex if this is a link in a node pointing to itself.
755 db_insert('search_node_links')
756 ->fields(array(
757 'caption' => $caption,
758 'sid' => $sid,
759 'type' => $module,
760 'nid' => $nid,
761 ))
762 ->execute();
763 search_touch_node($nid);
764 }
765 }
766 // Any left-over links in $links no longer exist. Delete them and mark the nodes for reindexing.
767 foreach ($links as $nid => $caption) {
768 db_delete('search_node_links')
769 ->condition('sid', $sid)
770 ->condition('type', $module)
771 ->condition('nid', $nid)
772 ->execute();
773 search_touch_node($nid);
774 }
775 }
776
783 function search_touch_node($nid) {
784 db_update('search_dataset')
785 ->fields(array('reindex' => REQUEST_TIME))
786 ->condition('type', 'node')
787 ->condition('sid', $nid)
788 ->execute();
789 }
790
794 function search_node_update_index($node) {
795 // Transplant links to a node into the target node.
796 $result = db_query("SELECT caption FROM {search_node_links} WHERE nid = :nid", array(':nid' => $node->nid), array('target' => 'slave'));
797 $output = array();
798 foreach ($result as $link) {
799 $output[] = $link->caption;
800 }
801 if (count($output)) {
802 return '<a>(' . implode(', ', $output) . ')</a>';
803 }
804 }
805
809 function search_node_update($node) {
810 // Reindex the node when it is updated. The node is automatically indexed
811 // when it is added, simply by being added to the node table.
812 search_touch_node($node->nid);
813 }
814
818 function search_comment_insert($comment) {
819 // Reindex the node when comments are added.
820 search_touch_node($comment->nid);
821 }
822
826 function search_comment_update($comment) {
827 // Reindex the node when comments are changed.
828 search_touch_node($comment->nid);
829 }
830
834 function search_comment_delete($comment) {
835 // Reindex the node when comments are deleted.
836 search_touch_node($comment->nid);
837 }
838
842 function search_comment_publish($comment) {
843 // Reindex the node when comments are published.
844 search_touch_node($comment->nid);
845 }
846
850 function search_comment_unpublish($comment) {
851 // Reindex the node when comments are unpublished.
852 search_touch_node($comment->nid);
853 }
854
871 function search_expression_extract($expression, $option) {
872 if (preg_match('/(^| )' . $option . ':([^ ]*)( |$)/i', $expression, $matches)) {
873 return $matches[2];
874 }
875 }
876
900 function search_expression_insert($expression, $option, $value = NULL) {
901 // Remove any previous values stored with $option.
902 $expression = trim(preg_replace('/(^| )' . $option . ':[^ ]*/i', '', $expression));
903
904 // Set new value, if provided.
905 if (isset($value)) {
906 $expression .= ' ' . $option . ':' . trim($value);
907 }
908 return $expression;
909 }
910
958 function search_form($form, &$form_state, $action = '', $keys = '', $module = NULL, $prompt = NULL) {
959 $module_info = FALSE;
960 if (!$module) {
961 $module_info = search_get_default_module_info();
962 }
963 else {
964 $info = search_get_info();
965 $module_info = isset($info[$module]) ? $info[$module] : FALSE;
966 }
967
968 // Sanity check.
969 if (!$module_info) {
970 form_set_error(NULL, t('Search is currently disabled.'), 'error');
971 return $form;
972 }
973
974 if (!$action) {
975 $action = 'search/' . $module_info['path'];
976 }
977 if (!isset($prompt)) {
978 $prompt = t('Enter your keywords');
979 }
980
981 $form['#action'] = url($action);
982 // Record the $action for later use in redirecting.
983 $form_state['action'] = $action;
984 $form['#attributes']['class'][] = 'search-form';
985 $form['module'] = array('#type' => 'value', '#value' => $module);
986 $form['basic'] = array('#type' => 'container', '#attributes' => array('class' => array('container-inline')));
987 $form['basic']['keys'] = array(
988 '#type' => 'textfield',
989 '#title' => $prompt,
990 '#default_value' => $keys,
991 '#size' => $prompt ? 40 : 20,
992 '#maxlength' => 255,
993 );
994 // processed_keys is used to coordinate keyword passing between other forms
995 // that hook into the basic search form.
996 $form['basic']['processed_keys'] = array('#type' => 'value', '#value' => '');
997 $form['basic']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
998
999 return $form;
1000 }
1001
1009 function search_box($form, &$form_state, $form_id) {
1010 $form[$form_id] = array(
1011 '#type' => 'textfield',
1012 '#title' => t('Search'),
1013 '#title_display' => 'invisible',
1014 '#size' => 15,
1015 '#default_value' => '',
1016 '#attributes' => array('title' => t('Enter the terms you wish to search for.')),
1017 );
1018 $form['actions'] = array('#type' => 'actions');
1019 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
1020 $form['#submit'][] = 'search_box_form_submit';
1021
1022 return $form;
1023 }
1024
1028 function search_box_form_submit($form, &$form_state) {
1029 // The search form relies on control of the redirect destination for its
1030 // functionality, so we override any static destination set in the request,
1031 // for example by drupal_access_denied() or drupal_not_found()
1032 // (see http://drupal.org/node/292565).
1033 if (isset($_GET['destination'])) {
1034 unset($_GET['destination']);
1035 }
1036
1037 // Check to see if the form was submitted empty.
1038 // If it is empty, display an error message.
1039 // (This method is used instead of setting #required to TRUE for this field
1040 // because that results in a confusing error message. It would say a plain
1041 // "field is required" because the search keywords field has no title.
1042 // The error message would also complain about a missing #title field.)
1043 if ($form_state['values']['search_block_form'] == '') {
1044 form_set_error('keys', t('Please enter some keywords.'));
1045 }
1046
1047 $form_id = $form['form_id']['#value'];
1048 $info = search_get_default_module_info();
1049 if ($info) {
1050 $form_state['redirect'] = 'search/' . $info['path'] . '/' . trim($form_state['values'][$form_id]);
1051 }
1052 else {
1053 form_set_error(NULL, t('Search is currently disabled.'), 'error');
1054 }
1055 }
1056
1065 function template_preprocess_search_block_form(&$variables) {
1066 $variables['search'] = array();
1067 $hidden = array();
1068 // Provide variables named after form keys so themers can print each element independently.
1069 foreach (element_children($variables['form']) as $key) {
1070 $type = isset($variables['form'][$key]['#type']) ? $variables['form'][$key]['#type'] : '';
1071 if ($type == 'hidden' || $type == 'token') {
1072 $hidden[] = drupal_render($variables['form'][$key]);
1073 }
1074 else {
1075 $variables['search'][$key] = drupal_render($variables['form'][$key]);
1076 }
1077 }
1078 // Hidden form elements have no value to themers. No need for separation.
1079 $variables['search']['hidden'] = implode($hidden);
1080 // Collect all form elements to make it easier to print the whole form.
1081 $variables['search_form'] = implode($variables['search']);
1082 }
1083
1098 function search_data($keys, $module, $conditions = NULL) {
1099 if (module_hook($module, 'search_execute')) {
1100 $results = module_invoke($module, 'search_execute', $keys, $conditions);
1101 if (module_hook($module, 'search_page')) {
1102 return module_invoke($module, 'search_page', $results);
1103 }
1104 else {
1105 return array(
1106 '#theme' => 'search_results',
1107 '#results' => $results,
1108 '#module' => $module,
1109 );
1110 }
1111 }
1112 }
1113
1127 function search_excerpt($keys, $text) {
1128 // We highlight around non-indexable or CJK characters.
1129 $boundary = '(?:(?<=[' . PREG_CLASS_UNICODE_WORD_BOUNDARY . PREG_CLASS_CJK . '])|(?=[' . PREG_CLASS_UNICODE_WORD_BOUNDARY . PREG_CLASS_CJK . ']))';
1130
1131 // Extract positive keywords and phrases
1132 preg_match_all('/ ("([^"]+)"|(?!OR)([^" ]+))/', ' ' . $keys, $matches);
1133 $keys = array_merge($matches[2], $matches[3]);
1134
1135 // Prepare text by stripping HTML tags and decoding HTML entities.
1136 $text = strip_tags(str_replace(array('<', '>'), array(' <', '> '), $text));
1137 $text = decode_entities($text);
1138
1139 // Slash-escape quotes in the search keyword string.
1140 array_walk($keys, '_search_excerpt_replace');
1141 $workkeys = $keys;
1142
1143 // Extract fragments around keywords.
1144 // First we collect ranges of text around each keyword, starting/ending
1145 // at spaces, trying to get to 256 characters.
1146 // If the sum of all fragments is too short, we look for second occurrences.
1147 $ranges = array();
1148 $included = array();
1149 $foundkeys = array();
1150 $length = 0;
1151 while ($length < 256 && count($workkeys)) {
1152 foreach ($workkeys as $k => $key) {
1153 if (strlen($key) == 0) {
1154 unset($workkeys[$k]);
1155 unset($keys[$k]);
1156 continue;
1157 }
1158 if ($length >= 256) {
1159 break;
1160 }
1161 // Remember occurrence of key so we can skip over it if more occurrences
1162 // are desired.
1163 if (!isset($included[$key])) {
1164 $included[$key] = 0;
1165 }
1166 // Locate a keyword (position $p, always >0 because $text starts with a
1167 // space). First try bare keyword, but if that doesn't work, try to find a
1168 // derived form from search_simplify().
1169 $p = 0;
1170 if (preg_match('/' . $boundary . $key . $boundary . '/iu', $text, $match, PREG_OFFSET_CAPTURE, $included[$key])) {
1171 $p = $match[0][1];
1172 }
1173 else {
1174 $info = search_simplify_excerpt_match($key, $text, $included[$key], $boundary);
1175 if ($info['where']) {
1176 $p = $info['where'];
1177 if ($info['keyword']) {
1178 $foundkeys[] = $info['keyword'];
1179 }
1180 }
1181 }
1182 // Now locate a space in front (position $q) and behind it (position $s),
1183 // leaving about 60 characters extra before and after for context.
1184 // Note that a space was added to the front and end of $text above.
1185 if ($p) {
1186 if (($q = strpos(' ' . $text, ' ', max(0, $p - 61))) !== FALSE) {
1187 $end = substr($text . ' ', $p, 80);
1188 if (($s = strrpos($end, ' ')) !== FALSE) {
1189 // Account for the added spaces.
1190 $q = max($q - 1, 0);
1191 $s = min($s, strlen($end) - 1);
1192 $ranges[$q] = $p + $s;
1193 $length += $p + $s - $q;
1194 $included[$key] = $p + 1;
1195 }
1196 else {
1197 unset($workkeys[$k]);
1198 }
1199 }
1200 else {
1201 unset($workkeys[$k]);
1202 }
1203 }
1204 else {
1205 unset($workkeys[$k]);
1206 }
1207 }
1208 }
1209
1210 if (count($ranges) == 0) {
1211 // We didn't find any keyword matches, so just return the first part of the
1212 // text. We also need to re-encode any HTML special characters that we
1213 // entity-decoded above.
1214 return check_plain(truncate_utf8($text, 256, TRUE, TRUE));
1215 }
1216
1217 // Sort the text ranges by starting position.
1218 ksort($ranges);
1219
1220 // Now we collapse overlapping text ranges into one. The sorting makes it O(n).
1221 $newranges = array();
1222 foreach ($ranges as $from2 => $to2) {
1223 if (!isset($from1)) {
1224 $from1 = $from2;
1225 $to1 = $to2;
1226 continue;
1227 }
1228 if ($from2 <= $to1) {
1229 $to1 = max($to1, $to2);
1230 }
1231 else {
1232 $newranges[$from1] = $to1;
1233 $from1 = $from2;
1234 $to1 = $to2;
1235 }
1236 }
1237 $newranges[$from1] = $to1;
1238
1239 // Fetch text
1240 $out = array();
1241 foreach ($newranges as $from => $to) {
1242 $out[] = substr($text, $from, $to - $from);
1243 }
1244
1245 // Let translators have the ... separator text as one chunk.
1246 $dots = explode('!excerpt', t('... !excerpt ... !excerpt ...'));
1247
1248 $text = (isset($newranges[0]) ? '' : $dots[0]) . implode($dots[1], $out) . $dots[2];
1249 $text = check_plain($text);
1250
1251 // Slash-escape quotes in keys found in a derived form and merge with original keys.
1252 array_walk($foundkeys, '_search_excerpt_replace');
1253 $keys = array_merge($keys, $foundkeys);
1254
1255 // Highlight keywords. Must be done at once to prevent conflicts ('strong' and '<strong>').
1256 $text = preg_replace('/' . $boundary . '(' . implode('|', $keys) . ')' . $boundary . '/iu', '<strong>\0</strong>', $text);
1257 return $text;
1258 }
1259
1267 function _search_excerpt_replace(&$text) {
1268 $text = preg_quote($text, '/');
1269 }
1270
1291 function search_simplify_excerpt_match($key, $text, $offset, $boundary) {
1292 $pos = NULL;
1293 $simplified_key = search_simplify($key);
1294 $simplified_text = search_simplify($text);
1295
1296 // Return immediately if simplified key or text are empty.
1297 if (!$simplified_key || !$simplified_text) {
1298 return FALSE;
1299 }
1300
1301 // Check if we have a match after simplification in the text.
1302 if (!preg_match('/' . $boundary . $simplified_key . $boundary . '/iu', $simplified_text, $match, PREG_OFFSET_CAPTURE, $offset)) {
1303 return FALSE;
1304 }
1305
1306 // If we get here, we have a match. Now find the exact location of the match
1307 // and the original text that matched. Start by splitting up the text by all
1308 // potential starting points of the matching text and iterating through them.
1309 $split = array_filter(preg_split('/' . $boundary . '/iu', $text, -1, PREG_SPLIT_OFFSET_CAPTURE), '_search_excerpt_match_filter');
1310 foreach ($split as $value) {
1311 // Skip starting points before the offset.
1312 if ($value[1] < $offset) {
1313 continue;
1314 }
1315
1316 // Check a window of 80 characters after the starting point for a match,
1317 // based on the size of the excerpt window.
1318 $window = substr($text, $value[1], 80);
1319 $simplified_window = search_simplify($window);
1320 if (strpos($simplified_window, $simplified_key) === 0) {
1321 // We have a match in this window. Store the position of the match.
1322 $pos = $value[1];
1323 // Iterate through the text in the window until we find the full original
1324 // matching text.
1325 $length = strlen($window);
1326 for ($i = 1; $i <= $length; $i++) {
1327 $keyfound = substr($text, $value[1], $i);
1328 if ($simplified_key == search_simplify($keyfound)) {
1329 break;
1330 }
1331 }
1332 break;
1333 }
1334 }
1335
1336 return $pos ? array('where' => $pos, 'keyword' => $keyfound) : FALSE;
1337 }
1338
1342 function _search_excerpt_match_filter($var) {
1343 return strlen(trim($var[0]));
1344 }
1345
1349 function search_forms() {
1350 $forms['search_block_form']= array(
1351 'callback' => 'search_box',
1352 'callback arguments' => array('search_block_form'),
1353 );
1354 return $forms;
1355 }
1356
_search_excerpt_replace
_search_excerpt_replace(&$text)
Definition: search.module:1265
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
search_dirty
search_dirty($word=NULL)
Definition: search.module:337
search_comment_insert
search_comment_insert($comment)
Definition: search.module:816
search_block_info
search_block_info()
Definition: search.module:139
decode_entities
decode_entities($text)
Definition: unicode.inc:457
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
drupal_strtolower
drupal_strtolower($text)
Definition: unicode.inc:521
search_invoke_preprocess
search_invoke_preprocess(&$text)
Definition: search.module:533
drupal_strlen
drupal_strlen($text)
Definition: unicode.inc:474
search_expand_cjk
search_expand_cjk($matches)
Definition: search.module:473
search_get_info
search_get_info($all=FALSE)
Definition: search.module:252
$module
print $module
Definition: search-results.tpl.php:28
PREG_CLASS_CJK
const PREG_CLASS_CJK
Definition: search.module:55
_search_index_truncate
_search_index_truncate(&$text)
Definition: search.module:523
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
$results
print $results
Definition: poll-results.tpl.php:23
PREG_CLASS_PUNCTUATION
const PREG_CLASS_PUNCTUATION
Definition: search.module:24
drupal_substr
drupal_substr($text, $start, $length=NULL)
Definition: unicode.inc:585
search_theme
search_theme()
Definition: search.module:100
search_block_view
search_block_view($delta= '')
Definition: search.module:150
db_or
db_or()
Definition: database.inc:2662
search_node_update
search_node_update($node)
Definition: search.module:807
search_permission
search_permission()
Definition: search.module:122
search_box
search_box($form, &$form_state, $form_id)
Definition: search.module:1007
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
search_is_active
search_is_active()
Definition: search.module:233
search_forms
search_forms()
Definition: search.module:1347
module_hook
module_hook($module, $hook)
Definition: module.inc:659
template_preprocess_search_block_form
template_preprocess_search_block_form(&$variables)
Definition: search.module:1063
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
search_comment_delete
search_comment_delete($comment)
Definition: search.module:832
$info
$info
Definition: color.inc:6
_search_menu_access
_search_menu_access($name)
Definition: search.module:293
search_update_totals
search_update_totals()
Definition: search.module:371
search_index
search_index($sid, $module, $text)
Definition: search.module:552
search_get_default_module_info
search_get_default_module_info()
Definition: search.module:279
search_reindex
search_reindex($sid=NULL, $module=NULL, $reindex=FALSE)
Definition: search.module:308
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_get_normal_path
drupal_get_normal_path($path, $path_language=NULL)
Definition: path.inc:259
$output
$output
Definition: authorize.php:93
search_cron
search_cron()
Definition: search.module:354
user_access
user_access($string, $account=NULL)
Definition: user.module:794
search_help
search_help($path, $arg)
Definition: search.module:64
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
_search_excerpt_match_filter
_search_excerpt_match_filter($var)
Definition: search.module:1340
search_expression_extract
search_expression_extract($expression, $option)
Definition: search.module:869
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
search_simplify_excerpt_match
search_simplify_excerpt_match($key, $text, $offset, $boundary)
Definition: search.module:1289
MENU_VISIBLE_IN_BREADCRUMB
const MENU_VISIBLE_IN_BREADCRUMB
Definition: menu.inc:96
MENU_SUGGESTED_ITEM
const MENU_SUGGESTED_ITEM
Definition: menu.inc:161
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
search_form
search_form($form, &$form_state, $action= '', $keys= '', $module=NULL, $prompt=NULL)
Definition: search.module:956
search_simplify
search_simplify($text)
Definition: search.module:409
search_touch_node
search_touch_node($nid)
Definition: search.module:781
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
DRUPAL_NO_CACHE
const DRUPAL_NO_CACHE
Definition: common.inc:127
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
search_box_form_submit
search_box_form_submit($form, &$form_state)
Definition: search.module:1026
search_comment_unpublish
search_comment_unpublish($comment)
Definition: search.module:848
search_data
search_data($keys, $module, $conditions=NULL)
Definition: search.module:1096
base_path
base_path()
Definition: common.inc:2817
search_index_split
search_index_split($text)
Definition: search.module:502
search_comment_update
search_comment_update($comment)
Definition: search.module:824
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
PREG_CLASS_NUMBERS
const PREG_CLASS_NUMBERS
Definition: search.module:11
search_menu
search_menu()
Definition: search.module:160
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
search_node_update_index
search_node_update_index($node)
Definition: search.module:792
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
truncate_utf8
truncate_utf8($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
Definition: unicode.inc:316
PREG_CLASS_UNICODE_WORD_BOUNDARY
const PREG_CLASS_UNICODE_WORD_BOUNDARY
Definition: unicode.inc:48
search_excerpt
search_excerpt($keys, $text)
Definition: search.module:1125
search_expression_insert
search_expression_insert($expression, $option, $value=NULL)
Definition: search.module:898
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
$links
print $links
Definition: poll-results--block.tpl.php:28
search_comment_publish
search_comment_publish($comment)
Definition: search.module:840
drupal_register_shutdown_function
& drupal_register_shutdown_function($callback=NULL)
Definition: bootstrap.inc:3417
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/rdf_example/rdf_example.module Source File

  • examples
  • rdf_example
rdf_example.module
Go to the documentation of this file.
1 <?php
25 function rdf_example_rdf_mapping() {
26 return array(
27 array(
28 'type' => 'node',
29 'bundle' => 'recipe',
30 'mapping' => array(
31 'rdftype' => array('v:Recipe'),
32 // We don't use the default bundle mapping for title. Instead, we add
33 // the v:name property. We still want to use dc:title as well, though,
34 // so we include it in the array.
35 'title' => array(
36 'predicates' => array('dc:title', 'v:name'),
37 ),
38 'recipe_summary' => array(
39 'predicates' => array('v:summary'),
40 ),
41 // The photo URI isn't a string but instead points to a resource, so we
42 // indicate that the attribute type is rel. If type isn't specified, it
43 // defaults to property, which is used for string values.
44 'recipe_photo' => array(
45 'predicates' => array('v:photo'),
46 'type' => 'rel',
47 ),
48 ),
49 ),
50 );
51 }
52
53 /*
54 * Implements hook_rdf_namespaces().
55 *
56 * This hook should be used to define any prefixes used by this module that are
57 * not already defined in core by rdf_rdf_namespaces.
58 *
59 * http://api.drupal.org/api/drupal/modules--rdf--rdf.api.php/function/hook_rdf_namespaces/7
60 */
61 function rdf_example_rdf_namespaces() {
62 return array(
63 // Google's namespace for their custom vocabularies.
64 'v' => 'http://rdf.data-vocabulary.org/#',
65 );
66 }
67
71 function rdf_example_help($path, $arg) {
72 switch ($path) {
73 case 'examples/rdf_example':
74 return "<p>" . t(
75 "The RDF Example module provides RDF mappings for a custom node type and
76 alters another node type's RDF mapping.
77 You can check your RDF using a <a href='!parser'>parser</a> by copying
78 and pasting your HTML source code into the box. For clearest results,
79 use Turtle as your output format.",
80 array('!parser' => url('http://www.w3.org/2007/08/pyRdfa/#distill_by_input'))
81 ) . "</p>";
82 }
83 }
rdf_example_rdf_mapping
rdf_example_rdf_mapping()
Definition: rdf_example.module:25
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
rdf_example_help
rdf_example_help($path, $arg)
Definition: rdf_example.module:71
rdf_example_rdf_namespaces
rdf_example_rdf_namespaces()
Definition: rdf_example.module:61
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment.module Source File

  • modules
  • comment
comment.module
Go to the documentation of this file.
1 <?php
2
15 define('COMMENT_NOT_PUBLISHED', 0);
16
20 define('COMMENT_PUBLISHED', 1);
21
25 define('COMMENT_MODE_FLAT', 0);
26
30 define('COMMENT_MODE_THREADED', 1);
31
35 define('COMMENT_ANONYMOUS_MAYNOT_CONTACT', 0);
36
40 define('COMMENT_ANONYMOUS_MAY_CONTACT', 1);
41
45 define('COMMENT_ANONYMOUS_MUST_CONTACT', 2);
46
50 define('COMMENT_FORM_SEPARATE_PAGE', 0);
51
55 define('COMMENT_FORM_BELOW', 1);
56
60 define('COMMENT_NODE_HIDDEN', 0);
61
65 define('COMMENT_NODE_CLOSED', 1);
66
70 define('COMMENT_NODE_OPEN', 2);
71
75 function comment_help($path, $arg) {
76 switch ($path) {
77 case 'admin/help#comment':
78 $output = '<h3>' . t('About') . '</h3>';
79 $output .= '<p>' . t('The Comment module allows users to comment on site content, set commenting defaults and permissions, and moderate comments. For more information, see the online handbook entry for <a href="@comment">Comment module</a>.', array('@comment' => 'http://drupal.org/documentation/modules/comment/')) . '</p>';
80 $output .= '<h3>' . t('Uses') . '</h3>';
81 $output .= '<dl>';
82 $output .= '<dt>' . t('Default and custom settings') . '</dt>';
83 $output .= '<dd>' . t("Each <a href='@content-type'>content type</a> can have its own default comment settings configured as: <em>Open</em> to allow new comments, <em>Hidden</em> to hide existing comments and prevent new comments, or <em>Closed</em> to view existing comments, but prevent new comments. These defaults will apply to all new content created (changes to the settings on existing content must be done manually). Other comment settings can also be customized per content type, and can be overridden for any given item of content. When a comment has no replies, it remains editable by its author, as long as the author has a user account and is logged in.", array('@content-type' => url('admin/structure/types'))) . '</dd>';
84 $output .= '<dt>' . t('Comment approval') . '</dt>';
85 $output .= '<dd>' . t("Comments from users who have the <em>Skip comment approval</em> permission are published immediately. All other comments are placed in the <a href='@comment-approval'>Unapproved comments</a> queue, until a user who has permission to <em>Administer comments</em> publishes or deletes them. Published comments can be bulk managed on the <a href='@admin-comment'>Published comments</a> administration page.", array('@comment-approval' => url('admin/content/comment/approval'), '@admin-comment' => url('admin/content/comment'))) . '</dd>';
86 $output .= '</dl>';
87 return $output;
88 }
89 }
90
94 function comment_entity_info() {
95 $return = array(
96 'comment' => array(
97 'label' => t('Comment'),
98 'base table' => 'comment',
99 'uri callback' => 'comment_uri',
100 'fieldable' => TRUE,
101 'controller class' => 'CommentController',
102 'entity keys' => array(
103 'id' => 'cid',
104 'bundle' => 'node_type',
105 'label' => 'subject',
106 'language' => 'language',
107 ),
108 'bundles' => array(),
109 'view modes' => array(
110 'full' => array(
111 'label' => t('Full comment'),
112 'custom settings' => FALSE,
113 ),
114 ),
115 'static cache' => FALSE,
116 ),
117 );
118
119 foreach (node_type_get_names() as $type => $name) {
120 $return['comment']['bundles']['comment_node_' . $type] = array(
121 'label' => t('@node_type comment', array('@node_type' => $name)),
122 // Provide the node type/bundle name for other modules, so it does not
123 // have to be extracted manually from the bundle name.
124 'node bundle' => $type,
125 'admin' => array(
126 // Place the Field UI paths for comments one level below the
127 // corresponding paths for nodes, so that they appear in the same set
128 // of local tasks. Note that the paths use a different placeholder name
129 // and thus a different menu loader callback, so that Field UI page
130 // callbacks get a comment bundle name from the node type in the URL.
131 // See comment_node_type_load() and comment_menu_alter().
132 'path' => 'admin/structure/types/manage/%comment_node_type/comment',
133 'bundle argument' => 4,
134 'real path' => 'admin/structure/types/manage/' . str_replace('_', '-', $type) . '/comment',
135 'access arguments' => array('administer content types'),
136 ),
137 );
138 }
139
140 return $return;
141 }
142
148 function comment_node_type_load($name) {
149 if ($type = node_type_get_type(strtr($name, array('-' => '_')))) {
150 return 'comment_node_' . $type->type;
151 }
152 }
153
157 function comment_uri($comment) {
158 return array(
159 'path' => 'comment/' . $comment->cid,
160 'options' => array('fragment' => 'comment-' . $comment->cid),
161 );
162 }
163
167 function comment_field_extra_fields() {
168 $return = array();
169
170 foreach (node_type_get_types() as $type) {
171 if (variable_get('comment_subject_field_' . $type->type, 1) == 1) {
172 $return['comment']['comment_node_' . $type->type] = array(
173 'form' => array(
174 'author' => array(
175 'label' => t('Author'),
176 'description' => t('Author textfield'),
177 'weight' => -2,
178 ),
179 'subject' => array(
180 'label' => t('Subject'),
181 'description' => t('Subject textfield'),
182 'weight' => -1,
183 ),
184 ),
185 );
186 }
187 }
188
189 return $return;
190 }
191
195 function comment_theme() {
196 return array(
197 'comment_block' => array(
198 'variables' => array(),
199 ),
200 'comment_preview' => array(
201 'variables' => array('comment' => NULL),
202 ),
203 'comment' => array(
204 'template' => 'comment',
205 'render element' => 'elements',
206 ),
207 'comment_post_forbidden' => array(
208 'variables' => array('node' => NULL),
209 ),
210 'comment_wrapper' => array(
211 'template' => 'comment-wrapper',
212 'render element' => 'content',
213 ),
214 );
215 }
216
220 function comment_menu() {
221 $items['admin/content/comment'] = array(
222 'title' => 'Comments',
223 'description' => 'List and edit site comments and the comment approval queue.',
224 'page callback' => 'comment_admin',
225 'access arguments' => array('administer comments'),
226 'type' => MENU_LOCAL_TASK | MENU_NORMAL_ITEM,
227 'file' => 'comment.admin.inc',
228 );
229 // Tabs begin here.
230 $items['admin/content/comment/new'] = array(
231 'title' => 'Published comments',
232 'type' => MENU_DEFAULT_LOCAL_TASK,
233 'weight' => -10,
234 );
235 $items['admin/content/comment/approval'] = array(
236 'title' => 'Unapproved comments',
237 'title callback' => 'comment_count_unpublished',
238 'page arguments' => array('approval'),
239 'access arguments' => array('administer comments'),
240 'type' => MENU_LOCAL_TASK,
241 );
242 $items['comment/%'] = array(
243 'title' => 'Comment permalink',
244 'page callback' => 'comment_permalink',
245 'page arguments' => array(1),
246 'access arguments' => array('access comments'),
247 );
248 $items['comment/%/view'] = array(
249 'title' => 'View comment',
250 'type' => MENU_DEFAULT_LOCAL_TASK,
251 'weight' => -10,
252 );
253 // Every other comment path uses %, but this one loads the comment directly,
254 // so we don't end up loading it twice (in the page and access callback).
255 $items['comment/%comment/edit'] = array(
256 'title' => 'Edit',
257 'page callback' => 'comment_edit_page',
258 'page arguments' => array(1),
259 'access callback' => 'comment_access',
260 'access arguments' => array('edit', 1),
261 'type' => MENU_LOCAL_TASK,
262 'weight' => 0,
263 );
264 $items['comment/%/approve'] = array(
265 'title' => 'Approve',
266 'page callback' => 'comment_approve',
267 'page arguments' => array(1),
268 'access arguments' => array('administer comments'),
269 'file' => 'comment.pages.inc',
270 'weight' => 1,
271 );
272 $items['comment/%/delete'] = array(
273 'title' => 'Delete',
274 'page callback' => 'comment_confirm_delete_page',
275 'page arguments' => array(1),
276 'access arguments' => array('administer comments'),
277 'type' => MENU_LOCAL_TASK,
278 'file' => 'comment.admin.inc',
279 'weight' => 2,
280 );
281 $items['comment/reply/%node'] = array(
282 'title' => 'Add new comment',
283 'page callback' => 'comment_reply',
284 'page arguments' => array(2),
285 'access callback' => 'node_access',
286 'access arguments' => array('view', 2),
287 'file' => 'comment.pages.inc',
288 );
289
290 return $items;
291 }
292
296 function comment_menu_alter(&$items) {
297 // Add comments to the description for admin/content.
298 $items['admin/content']['description'] = 'Administer content and comments.';
299
300 // Adjust the Field UI tabs on admin/structure/types/manage/[node-type].
301 // See comment_entity_info().
302 $items['admin/structure/types/manage/%comment_node_type/comment/fields']['title'] = 'Comment fields';
303 $items['admin/structure/types/manage/%comment_node_type/comment/fields']['weight'] = 3;
304 $items['admin/structure/types/manage/%comment_node_type/comment/display']['title'] = 'Comment display';
305 $items['admin/structure/types/manage/%comment_node_type/comment/display']['weight'] = 4;
306 }
307
311 function comment_count_unpublished() {
312 $count = db_query('SELECT COUNT(cid) FROM {comment} WHERE status = :status', array(
313 ':status' => COMMENT_NOT_PUBLISHED,
314 ))->fetchField();
315 return t('Unapproved comments (@count)', array('@count' => $count));
316 }
317
327 function comment_node_type_insert($info) {
328 _comment_body_field_create($info);
329 }
330
334 function comment_node_type_update($info) {
335 if (!empty($info->old_type) && $info->type != $info->old_type) {
336 field_attach_rename_bundle('comment', 'comment_node_' . $info->old_type, 'comment_node_' . $info->type);
337 }
338 }
339
343 function comment_node_type_delete($info) {
344 field_attach_delete_bundle('comment', 'comment_node_' . $info->type);
345 $settings = array(
346 'comment',
347 'comment_default_mode',
348 'comment_default_per_page',
349 'comment_anonymous',
350 'comment_subject_field',
351 'comment_preview',
352 'comment_form_location',
353 );
354 foreach ($settings as $setting) {
355 variable_del($setting . '_' . $info->type);
356 }
357 }
358
362 function _comment_body_field_create($info) {
363 // Create the field if needed.
364 if (!field_read_field('comment_body', array('include_inactive' => TRUE))) {
365 $field = array(
366 'field_name' => 'comment_body',
367 'type' => 'text_long',
368 'entity_types' => array('comment'),
369 );
370 field_create_field($field);
371 }
372 // Create the instance if needed.
373 if (!field_read_instance('comment', 'comment_body', 'comment_node_' . $info->type, array('include_inactive' => TRUE))) {
374 field_attach_create_bundle('comment', 'comment_node_' . $info->type);
375 // Attaches the body field by default.
376 $instance = array(
377 'field_name' => 'comment_body',
378 'label' => 'Comment',
379 'entity_type' => 'comment',
380 'bundle' => 'comment_node_' . $info->type,
381 'settings' => array('text_processing' => 1),
382 'required' => TRUE,
383 'display' => array(
384 'default' => array(
385 'label' => 'hidden',
386 'type' => 'text_default',
387 'weight' => 0,
388 ),
389 ),
390 );
391 field_create_instance($instance);
392 }
393 }
394
398 function comment_permission() {
399 return array(
400 'administer comments' => array(
401 'title' => t('Administer comments and comment settings'),
402 ),
403 'access comments' => array(
404 'title' => t('View comments'),
405 ),
406 'post comments' => array(
407 'title' => t('Post comments'),
408 ),
409 'skip comment approval' => array(
410 'title' => t('Skip comment approval'),
411 ),
412 'edit own comments' => array(
413 'title' => t('Edit own comments'),
414 ),
415 );
416 }
417
421 function comment_block_info() {
422 $blocks['recent']['info'] = t('Recent comments');
423 $blocks['recent']['properties']['administrative'] = TRUE;
424
425 return $blocks;
426 }
427
431 function comment_block_configure($delta = '') {
432 $form['comment_block_count'] = array(
433 '#type' => 'select',
434 '#title' => t('Number of recent comments'),
435 '#default_value' => variable_get('comment_block_count', 10),
436 '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
437 );
438
439 return $form;
440 }
441
445 function comment_block_save($delta = '', $edit = array()) {
446 variable_set('comment_block_count', (int) $edit['comment_block_count']);
447 }
448
454 function comment_block_view($delta = '') {
455 if (user_access('access comments')) {
456 $block['subject'] = t('Recent comments');
457 $block['content'] = theme('comment_block');
458
459 return $block;
460 }
461 }
462
479 function comment_permalink($cid) {
480 if (($comment = comment_load($cid)) && ($node = node_load($comment->nid))) {
481
482 // Find the current display page for this comment.
483 $page = comment_get_display_page($comment->cid, $node->type);
484
485 // Set $_GET['q'] and $_GET['page'] ourselves so that the node callback
486 // behaves as it would when visiting the page directly.
487 $_GET['q'] = 'node/' . $node->nid;
488 $_GET['page'] = $page;
489
490 // Return the node view, this will show the correct comment in context.
491 return menu_execute_active_handler('node/' . $node->nid, FALSE);
492 }
493 return MENU_NOT_FOUND;
494 }
495
506 function comment_get_recent($number = 10) {
507 $query = db_select('comment', 'c');
508 $query->innerJoin('node', 'n', 'n.nid = c.nid');
509 $query->addTag('node_access');
510 $comments = $query
511 ->fields('c')
512 ->condition('c.status', COMMENT_PUBLISHED)
513 ->condition('n.status', NODE_PUBLISHED)
514 ->orderBy('c.created', 'DESC')
515 // Additionally order by cid to ensure that comments with the same timestamp
516 // are returned in the exact order posted.
517 ->orderBy('c.cid', 'DESC')
518 ->range(0, $number)
519 ->execute()
520 ->fetchAll();
521
522 return $comments ? $comments : array();
523 }
524
537 function comment_new_page_count($num_comments, $new_replies, $node) {
538 $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED);
539 $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50);
540 $pagenum = NULL;
541 $flat = $mode == COMMENT_MODE_FLAT ? TRUE : FALSE;
542 if ($num_comments <= $comments_per_page) {
543 // Only one page of comments.
544 $pageno = 0;
545 }
546 elseif ($flat) {
547 // Flat comments.
548 $count = $num_comments - $new_replies;
549 $pageno = $count / $comments_per_page;
550 }
551 else {
552 // Threaded comments: we build a query with a subquery to find the first
553 // thread with a new comment.
554
555 // 1. Find all the threads with a new comment.
556 $unread_threads_query = db_select('comment')
557 ->fields('comment', array('thread'))
558 ->condition('nid', $node->nid)
559 ->condition('status', COMMENT_PUBLISHED)
560 ->orderBy('created', 'DESC')
561 ->orderBy('cid', 'DESC')
562 ->range(0, $new_replies);
563
564 // 2. Find the first thread.
565 $first_thread = db_select($unread_threads_query, 'thread')
566 ->fields('thread', array('thread'))
567 ->orderBy('SUBSTRING(thread, 1, (LENGTH(thread) - 1))')
568 ->range(0, 1)
569 ->execute()
570 ->fetchField();
571
572 // Remove the final '/'.
573 $first_thread = substr($first_thread, 0, -1);
574
575 // Find the number of the first comment of the first unread thread.
576 $count = db_query('SELECT COUNT(*) FROM {comment} WHERE nid = :nid AND status = :status AND SUBSTRING(thread, 1, (LENGTH(thread) - 1)) < :thread', array(
577 ':status' => COMMENT_PUBLISHED,
578 ':nid' => $node->nid,
579 ':thread' => $first_thread,
580 ))->fetchField();
581
582 $pageno = $count / $comments_per_page;
583 }
584
585 if ($pageno >= 1) {
586 $pagenum = array('page' => intval($pageno));
587 }
588
589 return $pagenum;
590 }
591
597 function theme_comment_block() {
598 $items = array();
599 $number = variable_get('comment_block_count', 10);
600 foreach (comment_get_recent($number) as $comment) {
601 $items[] = l($comment->subject, 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)) . '&nbsp;<span>' . t('@time ago', array('@time' => format_interval(REQUEST_TIME - $comment->changed))) . '</span>';
602 }
603
604 if ($items) {
605 return theme('item_list', array('items' => $items));
606 }
607 else {
608 return t('No comments available.');
609 }
610 }
611
615 function comment_node_view($node, $view_mode) {
616 $links = array();
617
618 if ($node->comment != COMMENT_NODE_HIDDEN) {
619 if ($view_mode == 'rss') {
620 // Add a comments RSS element which is a URL to the comments of this node.
621 $node->rss_elements[] = array(
622 'key' => 'comments',
623 'value' => url('node/' . $node->nid, array('fragment' => 'comments', 'absolute' => TRUE))
624 );
625 }
626 elseif ($view_mode == 'teaser') {
627 // Teaser view: display the number of comments that have been posted,
628 // or a link to add new comments if the user has permission, the node
629 // is open to new comments, and there currently are none.
630 if (user_access('access comments')) {
631 if (!empty($node->comment_count)) {
632 $links['comment-comments'] = array(
633 'title' => format_plural($node->comment_count, '1 comment', '@count comments'),
634 'href' => "node/$node->nid",
635 'attributes' => array('title' => t('Jump to the first comment of this posting.')),
636 'fragment' => 'comments',
637 'html' => TRUE,
638 );
639 // Show a link to the first new comment.
640 if ($new = comment_num_new($node->nid)) {
641 $links['comment-new-comments'] = array(
642 'title' => format_plural($new, '1 new comment', '@count new comments'),
643 'href' => "node/$node->nid",
644 'query' => comment_new_page_count($node->comment_count, $new, $node),
645 'attributes' => array('title' => t('Jump to the first new comment of this posting.')),
646 'fragment' => 'new',
647 'html' => TRUE,
648 );
649 }
650 }
651 }
652 if ($node->comment == COMMENT_NODE_OPEN) {
653 if (user_access('post comments')) {
654 $links['comment-add'] = array(
655 'title' => t('Add new comment'),
656 'href' => "comment/reply/$node->nid",
657 'attributes' => array('title' => t('Add a new comment to this page.')),
658 'fragment' => 'comment-form',
659 );
660 }
661 else {
662 $links['comment_forbidden'] = array(
663 'title' => theme('comment_post_forbidden', array('node' => $node)),
664 'html' => TRUE,
665 );
666 }
667 }
668 }
669 elseif ($view_mode != 'search_index' && $view_mode != 'search_result') {
670 // Node in other view modes: add a "post comment" link if the user is
671 // allowed to post comments and if this node is allowing new comments.
672 // But we don't want this link if we're building the node for search
673 // indexing or constructing a search result excerpt.
674 if ($node->comment == COMMENT_NODE_OPEN) {
675 $comment_form_location = variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW);
676 if (user_access('post comments')) {
677 // Show the "post comment" link if the form is on another page, or
678 // if there are existing comments that the link will skip past.
679 if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE || (!empty($node->comment_count) && user_access('access comments'))) {
680 $links['comment-add'] = array(
681 'title' => t('Add new comment'),
682 'attributes' => array('title' => t('Share your thoughts and opinions related to this posting.')),
683 'href' => "node/$node->nid",
684 'fragment' => 'comment-form',
685 );
686 if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE) {
687 $links['comment-add']['href'] = "comment/reply/$node->nid";
688 }
689 }
690 }
691 else {
692 $links['comment_forbidden'] = array(
693 'title' => theme('comment_post_forbidden', array('node' => $node)),
694 'html' => TRUE,
695 );
696 }
697 }
698 }
699
700 $node->content['links']['comment'] = array(
701 '#theme' => 'links__node__comment',
702 '#links' => $links,
703 '#attributes' => array('class' => array('links', 'inline')),
704 );
705
706 // Only append comments when we are building a node on its own node detail
707 // page. We compare $node and $page_node to ensure that comments are not
708 // appended to other nodes shown on the page, for example a node_reference
709 // displayed in 'full' view mode within another node.
710 if ($node->comment && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
711 $node->content['comments'] = comment_node_page_additions($node);
712 }
713 }
714 }
715
722 function comment_node_page_additions($node) {
723 $additions = array();
724
725 // Only attempt to render comments if the node has visible comments.
726 // Unpublished comments are not included in $node->comment_count, so show
727 // comments unconditionally if the user is an administrator.
728 if (($node->comment_count && user_access('access comments')) || user_access('administer comments')) {
729 $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED);
730 $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50);
731 if ($cids = comment_get_thread($node, $mode, $comments_per_page)) {
732 $comments = comment_load_multiple($cids);
733 comment_prepare_thread($comments);
734 $build = comment_view_multiple($comments, $node);
735 $build['pager']['#theme'] = 'pager';
736 $additions['comments'] = $build;
737 }
738 }
739
740 // Append comment form if needed.
741 if (user_access('post comments') && $node->comment == COMMENT_NODE_OPEN && (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW) == COMMENT_FORM_BELOW)) {
742 $build = drupal_get_form("comment_node_{$node->type}_form", (object) array('nid' => $node->nid));
743 $additions['comment_form'] = $build;
744 }
745
746 if ($additions) {
747 $additions += array(
748 '#theme' => 'comment_wrapper__node_' . $node->type,
749 '#node' => $node,
750 'comments' => array(),
751 'comment_form' => array(),
752 );
753 }
754
755 return $additions;
756 }
757
822 function comment_get_thread($node, $mode, $comments_per_page) {
823 $query = db_select('comment', 'c')->extend('PagerDefault');
824 $query->addField('c', 'cid');
825 $query
826 ->condition('c.nid', $node->nid)
827 ->addTag('node_access')
828 ->addTag('comment_filter')
829 ->addMetaData('node', $node)
830 ->limit($comments_per_page);
831
832 $count_query = db_select('comment', 'c');
833 $count_query->addExpression('COUNT(*)');
834 $count_query
835 ->condition('c.nid', $node->nid)
836 ->addTag('node_access')
837 ->addTag('comment_filter')
838 ->addMetaData('node', $node);
839
840 if (!user_access('administer comments')) {
841 $query->condition('c.status', COMMENT_PUBLISHED);
842 $count_query->condition('c.status', COMMENT_PUBLISHED);
843 }
844 if ($mode === COMMENT_MODE_FLAT) {
845 $query->orderBy('c.cid', 'ASC');
846 }
847 else {
848 // See comment above. Analysis reveals that this doesn't cost too
849 // much. It scales much much better than having the whole comment
850 // structure.
851 $query->addExpression('SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))', 'torder');
852 $query->orderBy('torder', 'ASC');
853 }
854
855 $query->setCountQuery($count_query);
856 $cids = $query->execute()->fetchCol();
857
858 return $cids;
859 }
860
869 function comment_prepare_thread(&$comments) {
870 // A flag stating if we are still searching for first new comment on the thread.
871 $first_new = TRUE;
872
873 // A counter that helps track how indented we are.
874 $divs = 0;
875
876 foreach ($comments as $key => $comment) {
877 if ($first_new && $comment->new != MARK_READ) {
878 // Assign the anchor only for the first new comment. This avoids duplicate
879 // id attributes on a page.
880 $first_new = FALSE;
881 $comment->first_new = TRUE;
882 }
883
884 // The $divs element instructs #prefix whether to add an indent div or
885 // close existing divs (a negative value).
886 $comment->depth = count(explode('.', $comment->thread)) - 1;
887 if ($comment->depth > $divs) {
888 $comment->divs = 1;
889 $divs++;
890 }
891 else {
892 $comment->divs = $comment->depth - $divs;
893 while ($comment->depth < $divs) {
894 $divs--;
895 }
896 }
897 $comments[$key] = $comment;
898 }
899
900 // The final comment must close up some hanging divs
901 $comments[$key]->divs_final = $divs;
902 }
903
920 function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) {
921 if (!isset($langcode)) {
922 $langcode = $GLOBALS['language_content']->language;
923 }
924
925 // Populate $comment->content with a render() array.
926 comment_build_content($comment, $node, $view_mode, $langcode);
927
928 $build = $comment->content;
929 // We don't need duplicate rendering info in comment->content.
930 unset($comment->content);
931
932 $build += array(
933 '#theme' => 'comment__node_' . $node->type,
934 '#comment' => $comment,
935 '#node' => $node,
936 '#view_mode' => $view_mode,
937 '#language' => $langcode,
938 );
939
940 if (empty($comment->in_preview)) {
941 $prefix = '';
942 $is_threaded = isset($comment->divs) && variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED) == COMMENT_MODE_THREADED;
943
944 // Add 'new' anchor if needed.
945 if (!empty($comment->first_new)) {
946 $prefix .= "<a id=\"new\"></a>\n";
947 }
948
949 // Add indentation div or close open divs as needed.
950 if ($is_threaded) {
951 $prefix .= $comment->divs <= 0 ? str_repeat('</div>', abs($comment->divs)) : "\n" . '<div class="indented">';
952 }
953
954 // Add anchor for each comment.
955 $prefix .= "<a id=\"comment-$comment->cid\"></a>\n";
956 $build['#prefix'] = $prefix;
957
958 // Close all open divs.
959 if ($is_threaded && !empty($comment->divs_final)) {
960 $build['#suffix'] = str_repeat('</div>', $comment->divs_final);
961 }
962 }
963
964 // Allow modules to modify the structured comment.
965 $type = 'comment';
966 drupal_alter(array('comment_view', 'entity_view'), $build, $type);
967
968 return $build;
969 }
970
987 function comment_build_content($comment, $node, $view_mode = 'full', $langcode = NULL) {
988 if (!isset($langcode)) {
989 $langcode = $GLOBALS['language_content']->language;
990 }
991
992 // Remove previously built content, if exists.
993 $comment->content = array();
994
995 // Allow modules to change the view mode.
996 $context = array(
997 'entity_type' => 'comment',
998 'entity' => $comment,
999 'langcode' => $langcode,
1000 );
1001 drupal_alter('entity_view_mode', $view_mode, $context);
1002
1003 // Build fields content.
1004 field_attach_prepare_view('comment', array($comment->cid => $comment), $view_mode, $langcode);
1005 entity_prepare_view('comment', array($comment->cid => $comment), $langcode);
1006 $comment->content += field_attach_view('comment', $comment, $view_mode, $langcode);
1007
1008 $comment->content['links'] = array(
1009 '#theme' => 'links__comment',
1010 '#pre_render' => array('drupal_pre_render_links'),
1011 '#attributes' => array('class' => array('links', 'inline')),
1012 );
1013 if (empty($comment->in_preview)) {
1014 $comment->content['links']['comment'] = array(
1015 '#theme' => 'links__comment__comment',
1016 '#links' => comment_links($comment, $node),
1017 '#attributes' => array('class' => array('links', 'inline')),
1018 );
1019 }
1020
1021 // Allow modules to make their own additions to the comment.
1022 module_invoke_all('comment_view', $comment, $view_mode, $langcode);
1023 module_invoke_all('entity_view', $comment, 'comment', $view_mode, $langcode);
1024
1025 // Make sure the current view mode is stored if no module has already
1026 // populated the related key.
1027 $comment->content += array('#view_mode' => $view_mode);
1028 }
1029
1042 function comment_links($comment, $node) {
1043 $links = array();
1044 if ($node->comment == COMMENT_NODE_OPEN) {
1045 if (user_access('administer comments') && user_access('post comments')) {
1046 $links['comment-delete'] = array(
1047 'title' => t('delete'),
1048 'href' => "comment/$comment->cid/delete",
1049 'html' => TRUE,
1050 );
1051 $links['comment-edit'] = array(
1052 'title' => t('edit'),
1053 'href' => "comment/$comment->cid/edit",
1054 'html' => TRUE,
1055 );
1056 $links['comment-reply'] = array(
1057 'title' => t('reply'),
1058 'href' => "comment/reply/$comment->nid/$comment->cid",
1059 'html' => TRUE,
1060 );
1061 if ($comment->status == COMMENT_NOT_PUBLISHED) {
1062 $links['comment-approve'] = array(
1063 'title' => t('approve'),
1064 'href' => "comment/$comment->cid/approve",
1065 'html' => TRUE,
1066 'query' => array('token' => drupal_get_token("comment/$comment->cid/approve")),
1067 );
1068 }
1069 }
1070 elseif (user_access('post comments')) {
1071 if (comment_access('edit', $comment)) {
1072 $links['comment-edit'] = array(
1073 'title' => t('edit'),
1074 'href' => "comment/$comment->cid/edit",
1075 'html' => TRUE,
1076 );
1077 }
1078 $links['comment-reply'] = array(
1079 'title' => t('reply'),
1080 'href' => "comment/reply/$comment->nid/$comment->cid",
1081 'html' => TRUE,
1082 );
1083 }
1084 else {
1085 $links['comment_forbidden']['title'] = theme('comment_post_forbidden', array('node' => $node));
1086 $links['comment_forbidden']['html'] = TRUE;
1087 }
1088 }
1089 return $links;
1090 }
1091
1110 function comment_view_multiple($comments, $node, $view_mode = 'full', $weight = 0, $langcode = NULL) {
1111 field_attach_prepare_view('comment', $comments, $view_mode, $langcode);
1112 entity_prepare_view('comment', $comments, $langcode);
1113
1114 $build = array(
1115 '#sorted' => TRUE,
1116 );
1117 foreach ($comments as $comment) {
1118 $build[$comment->cid] = comment_view($comment, $node, $view_mode, $langcode);
1119 $build[$comment->cid]['#weight'] = $weight;
1120 $weight++;
1121 }
1122 return $build;
1123 }
1124
1128 function comment_form_node_type_form_alter(&$form, $form_state) {
1129 if (isset($form['type'])) {
1130 $form['comment'] = array(
1131 '#type' => 'fieldset',
1132 '#title' => t('Comment settings'),
1133 '#collapsible' => TRUE,
1134 '#collapsed' => TRUE,
1135 '#group' => 'additional_settings',
1136 '#attributes' => array(
1137 'class' => array('comment-node-type-settings-form'),
1138 ),
1139 '#attached' => array(
1140 'js' => array(drupal_get_path('module', 'comment') . '/comment-node-form.js'),
1141 ),
1142 );
1143 // Unlike coment_form_node_form_alter(), all of these settings are applied
1144 // as defaults to all new nodes. Therefore, it would be wrong to use #states
1145 // to hide the other settings based on the primary comment setting.
1146 $form['comment']['comment'] = array(
1147 '#type' => 'select',
1148 '#title' => t('Default comment setting for new content'),
1149 '#default_value' => variable_get('comment_' . $form['#node_type']->type, COMMENT_NODE_OPEN),
1150 '#options' => array(
1151 COMMENT_NODE_OPEN => t('Open'),
1152 COMMENT_NODE_CLOSED => t('Closed'),
1153 COMMENT_NODE_HIDDEN => t('Hidden'),
1154 ),
1155 );
1156 $form['comment']['comment_default_mode'] = array(
1157 '#type' => 'checkbox',
1158 '#title' => t('Threading'),
1159 '#default_value' => variable_get('comment_default_mode_' . $form['#node_type']->type, COMMENT_MODE_THREADED),
1160 '#description' => t('Show comment replies in a threaded list.'),
1161 );
1162 $form['comment']['comment_default_per_page'] = array(
1163 '#type' => 'select',
1164 '#title' => t('Comments per page'),
1165 '#default_value' => variable_get('comment_default_per_page_' . $form['#node_type']->type, 50),
1166 '#options' => _comment_per_page(),
1167 );
1168 $form['comment']['comment_anonymous'] = array(
1169 '#type' => 'select',
1170 '#title' => t('Anonymous commenting'),
1171 '#default_value' => variable_get('comment_anonymous_' . $form['#node_type']->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT),
1172 '#options' => array(
1173 COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
1174 COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
1175 COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information'),
1176 ),
1177 '#access' => user_access('post comments', drupal_anonymous_user()),
1178 );
1179 $form['comment']['comment_subject_field'] = array(
1180 '#type' => 'checkbox',
1181 '#title' => t('Allow comment title'),
1182 '#default_value' => variable_get('comment_subject_field_' . $form['#node_type']->type, 1),
1183 );
1184 $form['comment']['comment_form_location'] = array(
1185 '#type' => 'checkbox',
1186 '#title' => t('Show reply form on the same page as comments'),
1187 '#default_value' => variable_get('comment_form_location_' . $form['#node_type']->type, COMMENT_FORM_BELOW),
1188 );
1189 $form['comment']['comment_preview'] = array(
1190 '#type' => 'radios',
1191 '#title' => t('Preview comment'),
1192 '#default_value' => variable_get('comment_preview_' . $form['#node_type']->type, DRUPAL_OPTIONAL),
1193 '#options' => array(
1194 DRUPAL_DISABLED => t('Disabled'),
1195 DRUPAL_OPTIONAL => t('Optional'),
1196 DRUPAL_REQUIRED => t('Required'),
1197 ),
1198 );
1199 }
1200 }
1201
1205 function comment_form_node_form_alter(&$form, $form_state) {
1206 $node = $form['#node'];
1207 $form['comment_settings'] = array(
1208 '#type' => 'fieldset',
1209 '#access' => user_access('administer comments'),
1210 '#title' => t('Comment settings'),
1211 '#collapsible' => TRUE,
1212 '#collapsed' => TRUE,
1213 '#group' => 'additional_settings',
1214 '#attributes' => array(
1215 'class' => array('comment-node-settings-form'),
1216 ),
1217 '#attached' => array(
1218 'js' => array(drupal_get_path('module', 'comment') . '/comment-node-form.js'),
1219 ),
1220 '#weight' => 30,
1221 );
1222 $comment_count = isset($node->nid) ? db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array(':nid' => $node->nid))->fetchField() : 0;
1223 $comment_settings = ($node->comment == COMMENT_NODE_HIDDEN && empty($comment_count)) ? COMMENT_NODE_CLOSED : $node->comment;
1224 $form['comment_settings']['comment'] = array(
1225 '#type' => 'radios',
1226 '#title' => t('Comments'),
1227 '#title_display' => 'invisible',
1228 '#parents' => array('comment'),
1229 '#default_value' => $comment_settings,
1230 '#options' => array(
1231 COMMENT_NODE_OPEN => t('Open'),
1232 COMMENT_NODE_CLOSED => t('Closed'),
1233 COMMENT_NODE_HIDDEN => t('Hidden'),
1234 ),
1235 COMMENT_NODE_OPEN => array(
1236 '#description' => t('Users with the "Post comments" permission can post comments.'),
1237 ),
1238 COMMENT_NODE_CLOSED => array(
1239 '#description' => t('Users cannot post comments, but existing comments will be displayed.'),
1240 ),
1241 COMMENT_NODE_HIDDEN => array(
1242 '#description' => t('Comments are hidden from view.'),
1243 ),
1244 );
1245 // If the node doesn't have any comments, the "hidden" option makes no
1246 // sense, so don't even bother presenting it to the user.
1247 if (empty($comment_count)) {
1248 $form['comment_settings']['comment'][COMMENT_NODE_HIDDEN]['#access'] = FALSE;
1249 // Also adjust the description of the "closed" option.
1250 $form['comment_settings']['comment'][COMMENT_NODE_CLOSED]['#description'] = t('Users cannot post comments.');
1251 }
1252 }
1253
1257 function comment_node_load($nodes, $types) {
1258 $comments_enabled = array();
1259
1260 // Check if comments are enabled for each node. If comments are disabled,
1261 // assign values without hitting the database.
1262 foreach ($nodes as $node) {
1263 // Store whether comments are enabled for this node.
1264 if ($node->comment != COMMENT_NODE_HIDDEN) {
1265 $comments_enabled[] = $node->nid;
1266 }
1267 else {
1268 $node->cid = 0;
1269 $node->last_comment_timestamp = $node->created;
1270 $node->last_comment_name = '';
1271 $node->last_comment_uid = $node->uid;
1272 $node->comment_count = 0;
1273 }
1274 }
1275
1276 // For nodes with comments enabled, fetch information from the database.
1277 if (!empty($comments_enabled)) {
1278 $result = db_query('SELECT nid, cid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count FROM {node_comment_statistics} WHERE nid IN (:comments_enabled)', array(':comments_enabled' => $comments_enabled));
1279 foreach ($result as $record) {
1280 $nodes[$record->nid]->cid = $record->cid;
1281 $nodes[$record->nid]->last_comment_timestamp = $record->last_comment_timestamp;
1282 $nodes[$record->nid]->last_comment_name = $record->last_comment_name;
1283 $nodes[$record->nid]->last_comment_uid = $record->last_comment_uid;
1284 $nodes[$record->nid]->comment_count = $record->comment_count;
1285 }
1286 }
1287 }
1288
1292 function comment_node_prepare($node) {
1293 if (!isset($node->comment)) {
1294 $node->comment = variable_get("comment_$node->type", COMMENT_NODE_OPEN);
1295 }
1296 }
1297
1301 function comment_node_insert($node) {
1302 // Allow bulk updates and inserts to temporarily disable the
1303 // maintenance of the {node_comment_statistics} table.
1304 if (variable_get('comment_maintain_node_statistics', TRUE)) {
1305 db_insert('node_comment_statistics')
1306 ->fields(array(
1307 'nid' => $node->nid,
1308 'cid' => 0,
1309 'last_comment_timestamp' => $node->changed,
1310 'last_comment_name' => NULL,
1311 'last_comment_uid' => $node->uid,
1312 'comment_count' => 0,
1313 ))
1314 ->execute();
1315 }
1316 }
1317
1321 function comment_node_delete($node) {
1322 $cids = db_query('SELECT cid FROM {comment} WHERE nid = :nid', array(':nid' => $node->nid))->fetchCol();
1323 comment_delete_multiple($cids);
1324 db_delete('node_comment_statistics')
1325 ->condition('nid', $node->nid)
1326 ->execute();
1327 }
1328
1332 function comment_node_update_index($node) {
1333 $index_comments = &drupal_static(__FUNCTION__);
1334
1335 if ($index_comments === NULL) {
1336 // Find and save roles that can 'access comments' or 'search content'.
1337 $perms = array('access comments' => array(), 'search content' => array());
1338 $result = db_query("SELECT rid, permission FROM {role_permission} WHERE permission IN ('access comments', 'search content')");
1339 foreach ($result as $record) {
1340 $perms[$record->permission][$record->rid] = $record->rid;
1341 }
1342
1343 // Prevent indexing of comments if there are any roles that can search but
1344 // not view comments.
1345 $index_comments = TRUE;
1346 foreach ($perms['search content'] as $rid) {
1347 if (!isset($perms['access comments'][$rid]) && ($rid <= DRUPAL_AUTHENTICATED_RID || !isset($perms['access comments'][DRUPAL_AUTHENTICATED_RID]))) {
1348 $index_comments = FALSE;
1349 break;
1350 }
1351 }
1352 }
1353
1354 if ($index_comments) {
1355 $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED);
1356 $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50);
1357 if ($node->comment && $cids = comment_get_thread($node, $mode, $comments_per_page)) {
1358 $comments = comment_load_multiple($cids);
1359 comment_prepare_thread($comments);
1360 $build = comment_view_multiple($comments, $node);
1361 return drupal_render($build);
1362 }
1363 }
1364 return '';
1365 }
1366
1370 function comment_update_index() {
1371 // Store the maximum possible comments per thread (used for ranking by reply count)
1372 variable_set('node_cron_comments_scale', 1.0 / max(1, db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}')->fetchField()));
1373 }
1374
1381 function comment_node_search_result($node) {
1382 // Do not make a string if comments are hidden.
1383 if (user_access('access comments') && $node->comment != COMMENT_NODE_HIDDEN) {
1384 $comments = db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array('nid' => $node->nid))->fetchField();
1385 // Do not make a string if comments are closed and there are currently
1386 // zero comments.
1387 if ($node->comment != COMMENT_NODE_CLOSED || $comments > 0) {
1388 return array('comment' => format_plural($comments, '1 comment', '@count comments'));
1389 }
1390 }
1391 }
1392
1396 function comment_user_cancel($edit, $account, $method) {
1397 switch ($method) {
1398 case 'user_cancel_block_unpublish':
1399 $comments = comment_load_multiple(array(), array('uid' => $account->uid));
1400 foreach ($comments as $comment) {
1401 $comment->status = 0;
1402 comment_save($comment);
1403 }
1404 break;
1405
1406 case 'user_cancel_reassign':
1407 $comments = comment_load_multiple(array(), array('uid' => $account->uid));
1408 foreach ($comments as $comment) {
1409 $comment->uid = 0;
1410 comment_save($comment);
1411 }
1412 break;
1413 }
1414 }
1415
1419 function comment_user_delete($account) {
1420 $cids = db_query('SELECT c.cid FROM {comment} c WHERE uid = :uid', array(':uid' => $account->uid))->fetchCol();
1421 comment_delete_multiple($cids);
1422 }
1423
1439 function comment_access($op, $comment) {
1440 global $user;
1441
1442 if ($op == 'edit') {
1443 return ($user->uid && $user->uid == $comment->uid && $comment->status == COMMENT_PUBLISHED && user_access('edit own comments')) || user_access('administer comments');
1444 }
1445 }
1446
1453 function comment_save($comment) {
1454 global $user;
1455
1456 $transaction = db_transaction();
1457 try {
1458 $defaults = array(
1459 'mail' => '',
1460 'homepage' => '',
1461 'name' => '',
1462 'status' => user_access('skip comment approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED,
1463 );
1464 foreach ($defaults as $key => $default) {
1465 if (!isset($comment->$key)) {
1466 $comment->$key = $default;
1467 }
1468 }
1469 // Make sure we have a bundle name.
1470 if (!isset($comment->node_type)) {
1471 $node = node_load($comment->nid);
1472 $comment->node_type = 'comment_node_' . $node->type;
1473 }
1474
1475 // Load the stored entity, if any.
1476 if (!empty($comment->cid) && !isset($comment->original)) {
1477 $comment->original = entity_load_unchanged('comment', $comment->cid);
1478 }
1479
1480 field_attach_presave('comment', $comment);
1481
1482 // Allow modules to alter the comment before saving.
1483 module_invoke_all('comment_presave', $comment);
1484 module_invoke_all('entity_presave', $comment, 'comment');
1485
1486 if ($comment->cid) {
1487
1488 drupal_write_record('comment', $comment, 'cid');
1489
1490 // Ignore slave server temporarily to give time for the
1491 // saved comment to be propagated to the slave.
1492 db_ignore_slave();
1493
1494 // Update the {node_comment_statistics} table prior to executing hooks.
1495 _comment_update_node_statistics($comment->nid);
1496
1497 field_attach_update('comment', $comment);
1498 // Allow modules to respond to the updating of a comment.
1499 module_invoke_all('comment_update', $comment);
1500 module_invoke_all('entity_update', $comment, 'comment');
1501 }
1502 else {
1503 // Add the comment to database. This next section builds the thread field.
1504 // Also see the documentation for comment_view().
1505 if (!empty($comment->thread)) {
1506 // Allow calling code to set thread itself.
1507 $thread = $comment->thread;
1508 }
1509 elseif ($comment->pid == 0) {
1510 // This is a comment with no parent comment (depth 0): we start
1511 // by retrieving the maximum thread level.
1512 $max = db_query('SELECT MAX(thread) FROM {comment} WHERE nid = :nid', array(':nid' => $comment->nid))->fetchField();
1513 // Strip the "/" from the end of the thread.
1514 $max = rtrim($max, '/');
1515 // We need to get the value at the correct depth.
1516 $parts = explode('.', $max);
1517 $firstsegment = $parts[0];
1518 // Finally, build the thread field for this new comment.
1519 $thread = int2vancode(vancode2int($firstsegment) + 1) . '/';
1520 }
1521 else {
1522 // This is a comment with a parent comment, so increase the part of the
1523 // thread value at the proper depth.
1524
1525 // Get the parent comment:
1526 $parent = comment_load($comment->pid);
1527 // Strip the "/" from the end of the parent thread.
1528 $parent->thread = (string) rtrim((string) $parent->thread, '/');
1529 // Get the max value in *this* thread.
1530 $max = db_query("SELECT MAX(thread) FROM {comment} WHERE thread LIKE :thread AND nid = :nid", array(
1531 ':thread' => $parent->thread . '.%',
1532 ':nid' => $comment->nid,
1533 ))->fetchField();
1534
1535 if ($max == '') {
1536 // First child of this parent.
1537 $thread = $parent->thread . '.' . int2vancode(0) . '/';
1538 }
1539 else {
1540 // Strip the "/" at the end of the thread.
1541 $max = rtrim($max, '/');
1542 // Get the value at the correct depth.
1543 $parts = explode('.', $max);
1544 $parent_depth = count(explode('.', $parent->thread));
1545 $last = $parts[$parent_depth];
1546 // Finally, build the thread field for this new comment.
1547 $thread = $parent->thread . '.' . int2vancode(vancode2int($last) + 1) . '/';
1548 }
1549 }
1550
1551 if (empty($comment->created)) {
1552 $comment->created = REQUEST_TIME;
1553 }
1554
1555 if (empty($comment->changed)) {
1556 $comment->changed = $comment->created;
1557 }
1558
1559 if ($comment->uid === $user->uid && isset($user->name)) { // '===' Need to modify anonymous users as well.
1560 $comment->name = $user->name;
1561 }
1562
1563 // Ensure the parent id (pid) has a value set.
1564 if (empty($comment->pid)) {
1565 $comment->pid = 0;
1566 }
1567
1568 // Add the values which aren't passed into the function.
1569 $comment->thread = $thread;
1570 $comment->hostname = ip_address();
1571
1572 drupal_write_record('comment', $comment);
1573
1574 // Ignore slave server temporarily to give time for the
1575 // created comment to be propagated to the slave.
1576 db_ignore_slave();
1577
1578 // Update the {node_comment_statistics} table prior to executing hooks.
1579 _comment_update_node_statistics($comment->nid);
1580
1581 field_attach_insert('comment', $comment);
1582
1583 // Tell the other modules a new comment has been submitted.
1584 module_invoke_all('comment_insert', $comment);
1585 module_invoke_all('entity_insert', $comment, 'comment');
1586 }
1587 if ($comment->status == COMMENT_PUBLISHED) {
1588 module_invoke_all('comment_publish', $comment);
1589 }
1590 unset($comment->original);
1591 }
1592 catch (Exception $e) {
1593 $transaction->rollback('comment');
1594 watchdog_exception('comment', $e);
1595 throw $e;
1596 }
1597
1598 }
1599
1606 function comment_delete($cid) {
1607 comment_delete_multiple(array($cid));
1608 }
1609
1616 function comment_delete_multiple($cids) {
1617 $comments = comment_load_multiple($cids);
1618 if ($comments) {
1619 $transaction = db_transaction();
1620 try {
1621 // Delete the comments.
1622 db_delete('comment')
1623 ->condition('cid', array_keys($comments), 'IN')
1624 ->execute();
1625 foreach ($comments as $comment) {
1626 field_attach_delete('comment', $comment);
1627 module_invoke_all('comment_delete', $comment);
1628 module_invoke_all('entity_delete', $comment, 'comment');
1629
1630 // Delete the comment's replies.
1631 $child_cids = db_query('SELECT cid FROM {comment} WHERE pid = :cid', array(':cid' => $comment->cid))->fetchCol();
1632 comment_delete_multiple($child_cids);
1633 _comment_update_node_statistics($comment->nid);
1634 }
1635 }
1636 catch (Exception $e) {
1637 $transaction->rollback();
1638 watchdog_exception('comment', $e);
1639 throw $e;
1640 }
1641 }
1642 }
1643
1667 function comment_load_multiple($cids = array(), $conditions = array(), $reset = FALSE) {
1668 return entity_load('comment', $cids, $conditions, $reset);
1669 }
1670
1683 function comment_load($cid, $reset = FALSE) {
1684 $comment = comment_load_multiple(array($cid), array(), $reset);
1685 return $comment ? $comment[$cid] : FALSE;
1686 }
1687
1694 class CommentController extends DrupalDefaultEntityController {
1695
1696 protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
1697 $query = parent::buildQuery($ids, $conditions, $revision_id);
1698 // Specify additional fields from the user and node tables.
1699 $query->innerJoin('node', 'n', 'base.nid = n.nid');
1700 $query->addField('n', 'type', 'node_type');
1701 $query->innerJoin('users', 'u', 'base.uid = u.uid');
1702 $query->addField('u', 'name', 'registered_name');
1703 $query->fields('u', array('uid', 'signature', 'signature_format', 'picture'));
1704 return $query;
1705 }
1706
1707 protected function attachLoad(&$comments, $revision_id = FALSE) {
1708 // Setup standard comment properties.
1709 foreach ($comments as $key => $comment) {
1710 $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
1711 $comment->new = node_mark($comment->nid, $comment->changed);
1712 $comment->node_type = 'comment_node_' . $comment->node_type;
1713 $comments[$key] = $comment;
1714 }
1715 parent::attachLoad($comments, $revision_id);
1716 }
1717 }
1718
1729 function comment_num_new($nid, $timestamp = 0) {
1730 global $user;
1731
1732 if ($user->uid) {
1733 // Retrieve the timestamp at which the current user last viewed this node.
1734 if (!$timestamp) {
1735 $timestamp = node_last_viewed($nid);
1736 }
1737 $timestamp = ($timestamp > NODE_NEW_LIMIT ? $timestamp : NODE_NEW_LIMIT);
1738
1739 // Use the timestamp to retrieve the number of new comments.
1740 return db_query('SELECT COUNT(cid) FROM {comment} WHERE nid = :nid AND created > :timestamp AND status = :status', array(
1741 ':nid' => $nid,
1742 ':timestamp' => $timestamp,
1743 ':status' => COMMENT_PUBLISHED,
1744 ))->fetchField();
1745 }
1746 else {
1747 return FALSE;
1748 }
1749
1750 }
1751
1766 function comment_get_display_ordinal($cid, $node_type) {
1767 // Count how many comments (c1) are before $cid (c2) in display order. This is
1768 // the 0-based display ordinal.
1769 $query = db_select('comment', 'c1');
1770 $query->innerJoin('comment', 'c2', 'c2.nid = c1.nid');
1771 $query->addExpression('COUNT(*)', 'count');
1772 $query->condition('c2.cid', $cid);
1773 if (!user_access('administer comments')) {
1774 $query->condition('c1.status', COMMENT_PUBLISHED);
1775 }
1776 $mode = variable_get('comment_default_mode_' . $node_type, COMMENT_MODE_THREADED);
1777
1778 if ($mode == COMMENT_MODE_FLAT) {
1779 // For flat comments, cid is used for ordering comments due to
1780 // unpredicatable behavior with timestamp, so we make the same assumption
1781 // here.
1782 $query->condition('c1.cid', $cid, '<');
1783 }
1784 else {
1785 // For threaded comments, the c.thread column is used for ordering. We can
1786 // use the vancode for comparison, but must remove the trailing slash.
1787 // See comment_view_multiple().
1788 $query->where('SUBSTRING(c1.thread, 1, (LENGTH(c1.thread) -1)) < SUBSTRING(c2.thread, 1, (LENGTH(c2.thread) -1))');
1789 }
1790
1791 return $query->execute()->fetchField();
1792 }
1793
1807 function comment_get_display_page($cid, $node_type) {
1808 $ordinal = comment_get_display_ordinal($cid, $node_type);
1809 $comments_per_page = variable_get('comment_default_per_page_' . $node_type, 50);
1810 return floor($ordinal / $comments_per_page);
1811 }
1812
1816 function comment_edit_page($comment) {
1817 drupal_set_title(t('Edit comment %comment', array('%comment' => $comment->subject)), PASS_THROUGH);
1818 $node = node_load($comment->nid);
1819 return drupal_get_form("comment_node_{$node->type}_form", $comment);
1820 }
1821
1825 function comment_forms() {
1826 $forms = array();
1827 foreach (node_type_get_types() as $type) {
1828 $forms["comment_node_{$type->type}_form"]['callback'] = 'comment_form';
1829 }
1830 return $forms;
1831 }
1832
1841 function comment_form($form, &$form_state, $comment) {
1842 global $user;
1843
1844 // During initial form build, add the comment entity to the form state for
1845 // use during form building and processing. During a rebuild, use what is in
1846 // the form state.
1847 if (!isset($form_state['comment'])) {
1848 $defaults = array(
1849 'name' => '',
1850 'mail' => '',
1851 'homepage' => '',
1852 'subject' => '',
1853 'comment' => '',
1854 'cid' => NULL,
1855 'pid' => NULL,
1856 'language' => LANGUAGE_NONE,
1857 'uid' => 0,
1858 );
1859 foreach ($defaults as $key => $value) {
1860 if (!isset($comment->$key)) {
1861 $comment->$key = $value;
1862 }
1863 }
1864 $form_state['comment'] = $comment;
1865 }
1866 else {
1867 $comment = $form_state['comment'];
1868 }
1869
1870 $node = node_load($comment->nid);
1871 $form['#node'] = $node;
1872
1873 // Use #comment-form as unique jump target, regardless of node type.
1874 $form['#id'] = drupal_html_id('comment_form');
1875 $form['#attributes']['class'][] = 'comment-form';
1876 $form['#theme'] = array('comment_form__node_' . $node->type, 'comment_form');
1877
1878 $anonymous_contact = variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT);
1879 $is_admin = (!empty($comment->cid) && user_access('administer comments'));
1880
1881 if (!$user->uid && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
1882 $form['#attached']['library'][] = array('system', 'jquery.cookie');
1883 $form['#attributes']['class'][] = 'user-info-from-cookie';
1884 }
1885
1886 // If not replying to a comment, use our dedicated page callback for new
1887 // comments on nodes.
1888 if (empty($comment->cid) && empty($comment->pid)) {
1889 $form['#action'] = url('comment/reply/' . $comment->nid);
1890 }
1891
1892 if (isset($form_state['comment_preview'])) {
1893 $form += $form_state['comment_preview'];
1894 }
1895
1896 // Display author information in a fieldset for comment moderators.
1897 if ($is_admin) {
1898 $form['author'] = array(
1899 '#type' => 'fieldset',
1900 '#title' => t('Administration'),
1901 '#collapsible' => TRUE,
1902 '#collapsed' => TRUE,
1903 '#weight' => -2,
1904 );
1905 }
1906 else {
1907 // Sets the author form elements above the subject.
1908 $form['author'] = array(
1909 '#weight' => -2,
1910 );
1911 }
1912
1913 // Prepare default values for form elements.
1914 if ($is_admin) {
1915 $author = (!$comment->uid && $comment->name ? $comment->name : $comment->registered_name);
1916 $status = (isset($comment->status) ? $comment->status : COMMENT_NOT_PUBLISHED);
1917 $date = (!empty($comment->date) ? $comment->date : format_date($comment->created, 'custom', 'Y-m-d H:i O'));
1918 }
1919 else {
1920 if ($user->uid) {
1921 $author = $user->name;
1922 }
1923 else {
1924 $author = ($comment->name ? $comment->name : '');
1925 }
1926 $status = (user_access('skip comment approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED);
1927 $date = '';
1928 }
1929
1930 // Add the author name field depending on the current user.
1931 if ($is_admin) {
1932 $form['author']['name'] = array(
1933 '#type' => 'textfield',
1934 '#title' => t('Authored by'),
1935 '#default_value' => $author,
1936 '#maxlength' => 60,
1937 '#size' => 30,
1938 '#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))),
1939 '#autocomplete_path' => 'user/autocomplete',
1940 );
1941 }
1942 elseif ($user->uid) {
1943 $form['author']['_author'] = array(
1944 '#type' => 'item',
1945 '#title' => t('Your name'),
1946 '#markup' => theme('username', array('account' => $user)),
1947 );
1948 $form['author']['name'] = array(
1949 '#type' => 'value',
1950 '#value' => $author,
1951 );
1952 }
1953 else {
1954 $form['author']['name'] = array(
1955 '#type' => 'textfield',
1956 '#title' => t('Your name'),
1957 '#default_value' => $author,
1958 '#required' => (!$user->uid && $anonymous_contact == COMMENT_ANONYMOUS_MUST_CONTACT),
1959 '#maxlength' => 60,
1960 '#size' => 30,
1961 );
1962 }
1963
1964 // Add author e-mail and homepage fields depending on the current user.
1965 $form['author']['mail'] = array(
1966 '#type' => 'textfield',
1967 '#title' => t('E-mail'),
1968 '#default_value' => $comment->mail,
1969 '#required' => (!$user->uid && $anonymous_contact == COMMENT_ANONYMOUS_MUST_CONTACT),
1970 '#maxlength' => 64,
1971 '#size' => 30,
1972 '#description' => t('The content of this field is kept private and will not be shown publicly.'),
1973 '#access' => $is_admin || (!$user->uid && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT),
1974 );
1975 $form['author']['homepage'] = array(
1976 '#type' => 'textfield',
1977 '#title' => t('Homepage'),
1978 '#default_value' => $comment->homepage,
1979 '#maxlength' => 255,
1980 '#size' => 30,
1981 '#access' => $is_admin || (!$user->uid && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT),
1982 );
1983
1984 // Add administrative comment publishing options.
1985 $form['author']['date'] = array(
1986 '#type' => 'textfield',
1987 '#title' => t('Authored on'),
1988 '#default_value' => $date,
1989 '#maxlength' => 25,
1990 '#size' => 20,
1991 '#access' => $is_admin,
1992 );
1993 $form['author']['status'] = array(
1994 '#type' => 'radios',
1995 '#title' => t('Status'),
1996 '#default_value' => $status,
1997 '#options' => array(
1998 COMMENT_PUBLISHED => t('Published'),
1999 COMMENT_NOT_PUBLISHED => t('Not published'),
2000 ),
2001 '#access' => $is_admin,
2002 );
2003
2004 $form['subject'] = array(
2005 '#type' => 'textfield',
2006 '#title' => t('Subject'),
2007 '#maxlength' => 64,
2008 '#default_value' => $comment->subject,
2009 '#access' => variable_get('comment_subject_field_' . $node->type, 1) == 1,
2010 '#weight' => -1,
2011 );
2012
2013 // Used for conditional validation of author fields.
2014 $form['is_anonymous'] = array(
2015 '#type' => 'value',
2016 '#value' => ($comment->cid ? !$comment->uid : !$user->uid),
2017 );
2018
2019 // Add internal comment properties.
2020 foreach (array('cid', 'pid', 'nid', 'language', 'uid') as $key) {
2021 $form[$key] = array('#type' => 'value', '#value' => $comment->$key);
2022 }
2023 $form['node_type'] = array('#type' => 'value', '#value' => 'comment_node_' . $node->type);
2024
2025 // Only show the save button if comment previews are optional or if we are
2026 // already previewing the submission.
2027 $form['actions'] = array('#type' => 'actions');
2028 $form['actions']['submit'] = array(
2029 '#type' => 'submit',
2030 '#value' => t('Save'),
2031 '#access' => ($comment->cid && user_access('administer comments')) || variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_REQUIRED || isset($form_state['comment_preview']),
2032 '#weight' => 19,
2033 );
2034 $form['actions']['preview'] = array(
2035 '#type' => 'submit',
2036 '#value' => t('Preview'),
2037 '#access' => (variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_DISABLED),
2038 '#weight' => 20,
2039 '#submit' => array('comment_form_build_preview'),
2040 );
2041
2042 // Attach fields.
2043 $comment->node_type = 'comment_node_' . $node->type;
2044 $langcode = entity_language('comment', $comment);
2045 field_attach_form('comment', $comment, $form, $form_state, $langcode);
2046
2047 return $form;
2048 }
2049
2053 function comment_form_build_preview($form, &$form_state) {
2054 $comment = comment_form_submit_build_comment($form, $form_state);
2055 $form_state['comment_preview'] = comment_preview($comment);
2056 $form_state['rebuild'] = TRUE;
2057 }
2058
2062 function comment_preview($comment) {
2063 global $user;
2064
2065 drupal_set_title(t('Preview comment'), PASS_THROUGH);
2066
2067 $node = node_load($comment->nid);
2068
2069 if (!form_get_errors()) {
2070 $comment_body = field_get_items('comment', $comment, 'comment_body');
2071 $comment->format = $comment_body[0]['format'];
2072 // Attach the user and time information.
2073 if (!empty($comment->name)) {
2074 $account = user_load_by_name($comment->name);
2075 }
2076 elseif ($user->uid && empty($comment->is_anonymous)) {
2077 $account = $user;
2078 }
2079
2080 if (!empty($account->uid)) {
2081 $comment->uid = $account->uid;
2082 $comment->name = check_plain($account->name);
2083 $comment->signature = $account->signature;
2084 $comment->signature_format = $account->signature_format;
2085 $comment->picture = $account->picture;
2086 }
2087 elseif (empty($comment->name)) {
2088 $comment->name = variable_get('anonymous', t('Anonymous'));
2089 }
2090
2091 $comment->created = !empty($comment->created) ? $comment->created : REQUEST_TIME;
2092 $comment->changed = REQUEST_TIME;
2093 $comment->in_preview = TRUE;
2094 $comment_build = comment_view($comment, $node);
2095 $comment_build['#weight'] = -100;
2096
2097 $form['comment_preview'] = $comment_build;
2098 }
2099
2100 if ($comment->pid) {
2101 $build = array();
2102 if ($comments = comment_load_multiple(array($comment->pid), array('status' => COMMENT_PUBLISHED))) {
2103 $parent_comment = $comments[$comment->pid];
2104 $build = comment_view($parent_comment, $node);
2105 }
2106 }
2107 else {
2108 $build = node_view($node);
2109 }
2110
2111 $form['comment_output_below'] = $build;
2112 $form['comment_output_below']['#weight'] = 100;
2113
2114 return $form;
2115 }
2116
2120 function comment_form_validate($form, &$form_state) {
2121 global $user;
2122
2123 entity_form_field_validate('comment', $form, $form_state);
2124
2125 if (!empty($form_state['values']['cid'])) {
2126 // Verify the name in case it is being changed from being anonymous.
2127 $account = user_load_by_name($form_state['values']['name']);
2128 $form_state['values']['uid'] = $account ? $account->uid : 0;
2129
2130 if ($form_state['values']['date'] && strtotime($form_state['values']['date']) === FALSE) {
2131 form_set_error('date', t('You have to specify a valid date.'));
2132 }
2133 if ($form_state['values']['name'] && !$form_state['values']['is_anonymous'] && !$account) {
2134 form_set_error('name', t('You have to specify a valid author.'));
2135 }
2136 }
2137 elseif ($form_state['values']['is_anonymous']) {
2138 // Validate anonymous comment author fields (if given). If the (original)
2139 // author of this comment was an anonymous user, verify that no registered
2140 // user with this name exists.
2141 if ($form_state['values']['name']) {
2142 $query = db_select('users', 'u');
2143 $query->addField('u', 'uid', 'uid');
2144 $taken = $query
2145 ->condition('name', db_like($form_state['values']['name']), 'LIKE')
2146 ->countQuery()
2147 ->execute()
2148 ->fetchField();
2149 if ($taken) {
2150 form_set_error('name', t('The name you used belongs to a registered user.'));
2151 }
2152 }
2153 }
2154 if ($form_state['values']['mail'] && !valid_email_address($form_state['values']['mail'])) {
2155 form_set_error('mail', t('The e-mail address you specified is not valid.'));
2156 }
2157 if ($form_state['values']['homepage'] && !valid_url($form_state['values']['homepage'], TRUE)) {
2158 form_set_error('homepage', t('The URL of your homepage is not valid. Remember that it must be fully qualified, i.e. of the form <code>http://example.com/directory</code>.'));
2159 }
2160 }
2161
2165 function comment_submit($comment) {
2166 // @todo Legacy support. Remove in Drupal 8.
2167 if (is_array($comment)) {
2168 $comment += array('subject' => '');
2169 $comment = (object) $comment;
2170 }
2171
2172 if (empty($comment->date)) {
2173 $comment->date = 'now';
2174 }
2175 $comment->created = strtotime($comment->date);
2176 $comment->changed = REQUEST_TIME;
2177
2178 // If the comment was posted by a registered user, assign the author's ID.
2179 // @todo Too fragile. Should be prepared and stored in comment_form() already.
2180 if (!$comment->is_anonymous && !empty($comment->name) && ($account = user_load_by_name($comment->name))) {
2181 $comment->uid = $account->uid;
2182 }
2183 // If the comment was posted by an anonymous user and no author name was
2184 // required, use "Anonymous" by default.
2185 if ($comment->is_anonymous && (!isset($comment->name) || $comment->name === '')) {
2186 $comment->name = variable_get('anonymous', t('Anonymous'));
2187 }
2188
2189 // Validate the comment's subject. If not specified, extract from comment body.
2190 if (trim($comment->subject) == '') {
2191 // The body may be in any format, so:
2192 // 1) Filter it into HTML
2193 // 2) Strip out all HTML tags
2194 // 3) Convert entities back to plain-text.
2195 $field = field_info_field('comment_body');
2196 $langcode = field_is_translatable('comment', $field) ? entity_language('comment', $comment) : LANGUAGE_NONE;
2197 $comment_body = $comment->comment_body[$langcode][0];
2198 if (isset($comment_body['format'])) {
2199 $comment_text = check_markup($comment_body['value'], $comment_body['format']);
2200 }
2201 else {
2202 $comment_text = check_plain($comment_body['value']);
2203 }
2204 $comment->subject = truncate_utf8(trim(decode_entities(strip_tags($comment_text))), 29, TRUE);
2205 // Edge cases where the comment body is populated only by HTML tags will
2206 // require a default subject.
2207 if ($comment->subject == '') {
2208 $comment->subject = t('(No subject)');
2209 }
2210 }
2211 return $comment;
2212 }
2213
2225 function comment_form_submit_build_comment($form, &$form_state) {
2226 $comment = $form_state['comment'];
2227 entity_form_submit_build_entity('comment', $comment, $form, $form_state);
2228 comment_submit($comment);
2229 return $comment;
2230 }
2231
2235 function comment_form_submit($form, &$form_state) {
2236 $node = node_load($form_state['values']['nid']);
2237 $comment = comment_form_submit_build_comment($form, $form_state);
2238 if (user_access('post comments') && (user_access('administer comments') || $node->comment == COMMENT_NODE_OPEN)) {
2239 // Save the anonymous user information to a cookie for reuse.
2240 if (user_is_anonymous()) {
2241 user_cookie_save(array_intersect_key($form_state['values'], array_flip(array('name', 'mail', 'homepage'))));
2242 }
2243
2244 comment_save($comment);
2245 $form_state['values']['cid'] = $comment->cid;
2246
2247 // Add an entry to the watchdog log.
2248 watchdog('content', 'Comment posted: %subject.', array('%subject' => $comment->subject), WATCHDOG_NOTICE, l(t('view'), 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)));
2249
2250 // Explain the approval queue if necessary.
2251 if ($comment->status == COMMENT_NOT_PUBLISHED) {
2252 if (!user_access('administer comments')) {
2253 drupal_set_message(t('Your comment has been queued for review by site administrators and will be published after approval.'));
2254 }
2255 }
2256 else {
2257 drupal_set_message(t('Your comment has been posted.'));
2258 }
2259 $query = array();
2260 // Find the current display page for this comment.
2261 $page = comment_get_display_page($comment->cid, $node->type);
2262 if ($page > 0) {
2263 $query['page'] = $page;
2264 }
2265 // Redirect to the newly posted comment.
2266 $redirect = array('node/' . $node->nid, array('query' => $query, 'fragment' => 'comment-' . $comment->cid));
2267 }
2268 else {
2269 watchdog('content', 'Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->subject), WATCHDOG_WARNING);
2270 drupal_set_message(t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->subject)), 'error');
2271 // Redirect the user to the node they are commenting on.
2272 $redirect = 'node/' . $node->nid;
2273 }
2274 $form_state['redirect'] = $redirect;
2275 // Clear the block and page caches so that anonymous users see the comment
2276 // they have posted.
2277 cache_clear_all();
2278 }
2279
2285 function template_preprocess_comment(&$variables) {
2286 $comment = $variables['elements']['#comment'];
2287 $node = $variables['elements']['#node'];
2288 $variables['comment'] = $comment;
2289 $variables['node'] = $node;
2290 $variables['author'] = theme('username', array('account' => $comment));
2291
2292 $variables['created'] = format_date($comment->created);
2293
2294 // Avoid calling format_date() twice on the same timestamp.
2295 if ($comment->changed == $comment->created) {
2296 $variables['changed'] = $variables['created'];
2297 }
2298 else {
2299 $variables['changed'] = format_date($comment->changed);
2300 }
2301
2302 $variables['new'] = !empty($comment->new) ? t('new') : '';
2303 $variables['picture'] = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', array('account' => $comment)) : '';
2304 $variables['signature'] = $comment->signature;
2305
2306 $uri = entity_uri('comment', $comment);
2307 $uri['options'] += array('attributes' => array('class' => 'permalink', 'rel' => 'bookmark'));
2308
2309 $variables['title'] = l($comment->subject, $uri['path'], $uri['options']);
2310 $variables['permalink'] = l(t('Permalink'), $uri['path'], $uri['options']);
2311 $variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['author'], '!datetime' => $variables['created']));
2312
2313 // Preprocess fields.
2314 field_attach_preprocess('comment', $comment, $variables['elements'], $variables);
2315
2316 // Helpful $content variable for templates.
2317 foreach (element_children($variables['elements']) as $key) {
2318 $variables['content'][$key] = $variables['elements'][$key];
2319 }
2320
2321 // Set status to a string representation of comment->status.
2322 if (isset($comment->in_preview)) {
2323 $variables['status'] = 'comment-preview';
2324 }
2325 else {
2326 $variables['status'] = ($comment->status == COMMENT_NOT_PUBLISHED) ? 'comment-unpublished' : 'comment-published';
2327 }
2328
2329 // Gather comment classes.
2330 // 'comment-published' class is not needed, it is either 'comment-preview' or
2331 // 'comment-unpublished'.
2332 if ($variables['status'] != 'comment-published') {
2333 $variables['classes_array'][] = $variables['status'];
2334 }
2335 if ($variables['new']) {
2336 $variables['classes_array'][] = 'comment-new';
2337 }
2338 if (!$comment->uid) {
2339 $variables['classes_array'][] = 'comment-by-anonymous';
2340 }
2341 else {
2342 if ($comment->uid == $variables['node']->uid) {
2343 $variables['classes_array'][] = 'comment-by-node-author';
2344 }
2345 if ($comment->uid == $variables['user']->uid) {
2346 $variables['classes_array'][] = 'comment-by-viewer';
2347 }
2348 }
2349 }
2350
2360 function theme_comment_post_forbidden($variables) {
2361 $node = $variables['node'];
2362 global $user;
2363
2364 // Since this is expensive to compute, we cache it so that a page with many
2365 // comments only has to query the database once for all the links.
2366 $authenticated_post_comments = &drupal_static(__FUNCTION__, NULL);
2367
2368 if (!$user->uid) {
2369 if (!isset($authenticated_post_comments)) {
2370 // We only output a link if we are certain that users will get permission
2371 // to post comments by logging in.
2372 $comment_roles = user_roles(TRUE, 'post comments');
2373 $authenticated_post_comments = isset($comment_roles[DRUPAL_AUTHENTICATED_RID]);
2374 }
2375
2376 if ($authenticated_post_comments) {
2377 // We cannot use drupal_get_destination() because these links
2378 // sometimes appear on /node and taxonomy listing pages.
2379 if (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW) == COMMENT_FORM_SEPARATE_PAGE) {
2380 $destination = array('destination' => "comment/reply/$node->nid#comment-form");
2381 }
2382 else {
2383 $destination = array('destination' => "node/$node->nid#comment-form");
2384 }
2385
2386 if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
2387 // Users can register themselves.
2388 return t('<a href="@login">Log in</a> or <a href="@register">register</a> to post comments', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination))));
2389 }
2390 else {
2391 // Only admins can add new users, no public registration.
2392 return t('<a href="@login">Log in</a> to post comments', array('@login' => url('user/login', array('query' => $destination))));
2393 }
2394 }
2395 }
2396 }
2397
2403 function template_preprocess_comment_wrapper(&$variables) {
2404 // Provide contextual information.
2405 $variables['node'] = $variables['content']['#node'];
2406 $variables['display_mode'] = variable_get('comment_default_mode_' . $variables['node']->type, COMMENT_MODE_THREADED);
2407 // The comment form is optional and may not exist.
2408 $variables['content'] += array('comment_form' => array());
2409 }
2410
2417 function _comment_get_modes() {
2418 return array(
2419 COMMENT_MODE_FLAT => t('Flat list'),
2420 COMMENT_MODE_THREADED => t('Threaded list')
2421 );
2422 }
2423
2428 function _comment_per_page() {
2429 return drupal_map_assoc(array(10, 30, 50, 70, 90, 150, 200, 250, 300));
2430 }
2431
2442 function _comment_update_node_statistics($nid) {
2443 // Allow bulk updates and inserts to temporarily disable the
2444 // maintenance of the {node_comment_statistics} table.
2445 if (!variable_get('comment_maintain_node_statistics', TRUE)) {
2446 return;
2447 }
2448
2449 $count = db_query('SELECT COUNT(cid) FROM {comment} WHERE nid = :nid AND status = :status', array(
2450 ':nid' => $nid,
2451 ':status' => COMMENT_PUBLISHED,
2452 ))->fetchField();
2453
2454 if ($count > 0) {
2455 // Comments exist.
2456 $last_reply = db_query_range('SELECT cid, name, changed, uid FROM {comment} WHERE nid = :nid AND status = :status ORDER BY cid DESC', 0, 1, array(
2457 ':nid' => $nid,
2458 ':status' => COMMENT_PUBLISHED,
2459 ))->fetchObject();
2460 db_update('node_comment_statistics')
2461 ->fields(array(
2462 'cid' => $last_reply->cid,
2463 'comment_count' => $count,
2464 'last_comment_timestamp' => $last_reply->changed,
2465 'last_comment_name' => $last_reply->uid ? '' : $last_reply->name,
2466 'last_comment_uid' => $last_reply->uid,
2467 ))
2468 ->condition('nid', $nid)
2469 ->execute();
2470 }
2471 else {
2472 // Comments do not exist.
2473 $node = db_query('SELECT uid, created FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject();
2474 db_update('node_comment_statistics')
2475 ->fields(array(
2476 'cid' => 0,
2477 'comment_count' => 0,
2478 'last_comment_timestamp' => $node->created,
2479 'last_comment_name' => '',
2480 'last_comment_uid' => $node->uid,
2481 ))
2482 ->condition('nid', $nid)
2483 ->execute();
2484 }
2485 }
2486
2500 function int2vancode($i = 0) {
2501 $num = base_convert((int) $i, 10, 36);
2502 $length = strlen($num);
2503
2504 return chr($length + ord('0') - 1) . $num;
2505 }
2506
2510 function vancode2int($c = '00') {
2511 return base_convert(substr($c, 1), 36, 10);
2512 }
2513
2517 function comment_action_info() {
2518 return array(
2519 'comment_publish_action' => array(
2520 'label' => t('Publish comment'),
2521 'type' => 'comment',
2522 'configurable' => FALSE,
2523 'behavior' => array('changes_property'),
2524 'triggers' => array('comment_presave', 'comment_insert', 'comment_update'),
2525 ),
2526 'comment_unpublish_action' => array(
2527 'label' => t('Unpublish comment'),
2528 'type' => 'comment',
2529 'configurable' => FALSE,
2530 'behavior' => array('changes_property'),
2531 'triggers' => array('comment_presave', 'comment_insert', 'comment_update'),
2532 ),
2533 'comment_unpublish_by_keyword_action' => array(
2534 'label' => t('Unpublish comment containing keyword(s)'),
2535 'type' => 'comment',
2536 'configurable' => TRUE,
2537 'behavior' => array('changes_property'),
2538 'triggers' => array('comment_presave', 'comment_insert', 'comment_update'),
2539 ),
2540 'comment_save_action' => array(
2541 'label' => t('Save comment'),
2542 'type' => 'comment',
2543 'configurable' => FALSE,
2544 'triggers' => array('comment_insert', 'comment_update'),
2545 ),
2546 );
2547 }
2548
2560 function comment_publish_action($comment, $context = array()) {
2561 if (isset($comment->subject)) {
2562 $subject = $comment->subject;
2563 $comment->status = COMMENT_PUBLISHED;
2564 }
2565 else {
2566 $cid = $context['cid'];
2567 $subject = db_query('SELECT subject FROM {comment} WHERE cid = :cid', array(':cid' => $cid))->fetchField();
2568 db_update('comment')
2569 ->fields(array('status' => COMMENT_PUBLISHED))
2570 ->condition('cid', $cid)
2571 ->execute();
2572 }
2573 watchdog('action', 'Published comment %subject.', array('%subject' => $subject));
2574 }
2575
2587 function comment_unpublish_action($comment, $context = array()) {
2588 if (isset($comment->subject)) {
2589 $subject = $comment->subject;
2590 $comment->status = COMMENT_NOT_PUBLISHED;
2591 }
2592 else {
2593 $cid = $context['cid'];
2594 $subject = db_query('SELECT subject FROM {comment} WHERE cid = :cid', array(':cid' => $cid))->fetchField();
2595 db_update('comment')
2596 ->fields(array('status' => COMMENT_NOT_PUBLISHED))
2597 ->condition('cid', $cid)
2598 ->execute();
2599 }
2600 watchdog('action', 'Unpublished comment %subject.', array('%subject' => $subject));
2601 }
2602
2617 function comment_unpublish_by_keyword_action($comment, $context) {
2618 foreach ($context['keywords'] as $keyword) {
2619 $text = drupal_render($comment);
2620 if (strpos($text, $keyword) !== FALSE) {
2621 $comment->status = COMMENT_NOT_PUBLISHED;
2622 watchdog('action', 'Unpublished comment %subject.', array('%subject' => $comment->subject));
2623 break;
2624 }
2625 }
2626 }
2627
2635 function comment_unpublish_by_keyword_action_form($context) {
2636 $form['keywords'] = array(
2637 '#title' => t('Keywords'),
2638 '#type' => 'textarea',
2639 '#description' => t('The comment will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'),
2640 '#default_value' => isset($context['keywords']) ? drupal_implode_tags($context['keywords']) : '',
2641 );
2642
2643 return $form;
2644 }
2645
2651 function comment_unpublish_by_keyword_action_submit($form, $form_state) {
2652 return array('keywords' => drupal_explode_tags($form_state['values']['keywords']));
2653 }
2654
2660 function comment_save_action($comment) {
2661 comment_save($comment);
2662 cache_clear_all();
2663 watchdog('action', 'Saved comment %title', array('%title' => $comment->subject));
2664 }
2665
2669 function comment_ranking() {
2670 return array(
2671 'comments' => array(
2672 'title' => t('Number of comments'),
2673 'join' => array(
2674 'type' => 'LEFT',
2675 'table' => 'node_comment_statistics',
2676 'alias' => 'node_comment_statistics',
2677 'on' => 'node_comment_statistics.nid = i.sid',
2678 ),
2679 // Inverse law that maps the highest reply count on the site to 1 and 0 to 0.
2680 'score' => '2.0 - 2.0 / (1.0 + node_comment_statistics.comment_count * CAST(:scale AS DECIMAL))',
2681 'arguments' => array(':scale' => variable_get('node_cron_comments_scale', 0)),
2682 ),
2683 );
2684 }
2685
2689 function comment_rdf_mapping() {
2690 return array(
2691 array(
2692 'type' => 'comment',
2693 'bundle' => RDF_DEFAULT_BUNDLE,
2694 'mapping' => array(
2695 'rdftype' => array('sioc:Post', 'sioct:Comment'),
2696 'title' => array(
2697 'predicates' => array('dc:title'),
2698 ),
2699 'created' => array(
2700 'predicates' => array('dc:date', 'dc:created'),
2701 'datatype' => 'xsd:dateTime',
2702 'callback' => 'date_iso8601',
2703 ),
2704 'changed' => array(
2705 'predicates' => array('dc:modified'),
2706 'datatype' => 'xsd:dateTime',
2707 'callback' => 'date_iso8601',
2708 ),
2709 'comment_body' => array(
2710 'predicates' => array('content:encoded'),
2711 ),
2712 'pid' => array(
2713 'predicates' => array('sioc:reply_of'),
2714 'type' => 'rel',
2715 ),
2716 'uid' => array(
2717 'predicates' => array('sioc:has_creator'),
2718 'type' => 'rel',
2719 ),
2720 'name' => array(
2721 'predicates' => array('foaf:name'),
2722 ),
2723 ),
2724 ),
2725 );
2726 }
2727
2731 function comment_file_download_access($field, $entity_type, $entity) {
2732 if ($entity_type == 'comment') {
2733 if (user_access('access comments') && $entity->status == COMMENT_PUBLISHED || user_access('administer comments')) {
2734 $node = node_load($entity->nid);
2735 return node_access('view', $node);
2736 }
2737 return FALSE;
2738 }
2739 }
comment_node_update_index
comment_node_update_index($node)
Definition: comment.module:1332
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
comment_form_node_form_alter
comment_form_node_form_alter(&$form, $form_state)
Definition: comment.module:1205
COMMENT_FORM_SEPARATE_PAGE
const COMMENT_FORM_SEPARATE_PAGE
Definition: comment.module:50
field_create_instance
field_create_instance($instance)
Definition: field.crud.inc:473
COMMENT_MODE_THREADED
const COMMENT_MODE_THREADED
Definition: comment.module:30
comment_unpublish_action
comment_unpublish_action($comment, $context=array())
Definition: comment.module:2587
watchdog_exception
watchdog_exception($type, Exception $exception, $message=NULL, $variables=array(), $severity=WATCHDOG_ERROR, $link=NULL)
Definition: bootstrap.inc:1654
int2vancode
int2vancode($i=0)
Definition: comment.module:2500
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
comment_block_view
comment_block_view($delta= '')
Definition: comment.module:454
$op
$op
Definition: update.php:404
_comment_get_modes
_comment_get_modes()
Definition: comment.module:2417
decode_entities
decode_entities($text)
Definition: unicode.inc:457
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
MARK_READ
const MARK_READ
Definition: theme.inc:21
entity_load
entity_load($entity_type, $ids=FALSE, $conditions=array(), $reset=FALSE)
Definition: common.inc:7800
l
l($text, $path, array $options=array())
Definition: common.inc:2432
CommentController
Definition: comment.module:1694
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
comment_forms
comment_forms()
Definition: comment.module:1825
COMMENT_FORM_BELOW
const COMMENT_FORM_BELOW
Definition: comment.module:55
comment_prepare_thread
comment_prepare_thread(&$comments)
Definition: comment.module:869
entity_form_field_validate
entity_form_field_validate($entity_type, $form, &$form_state)
Definition: common.inc:7997
node_last_viewed
node_last_viewed($nid)
Definition: node.module:328
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
field_attach_form
field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode=NULL, $options=array())
Definition: field.attach.inc:564
comment_save
comment_save($comment)
Definition: comment.module:1453
comment_save_action
comment_save_action($comment)
Definition: comment.module:2660
field_attach_update
field_attach_update($entity_type, $entity)
Definition: field.attach.inc:990
COMMENT_NODE_CLOSED
const COMMENT_NODE_CLOSED
Definition: comment.module:65
comment_load_multiple
comment_load_multiple($cids=array(), $conditions=array(), $reset=FALSE)
Definition: comment.module:1667
$page
print $page
Definition: overlay.tpl.php:37
comment_links
comment_links($comment, $node)
Definition: comment.module:1042
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
comment_get_recent
comment_get_recent($number=10)
Definition: comment.module:506
COMMENT_NOT_PUBLISHED
const COMMENT_NOT_PUBLISHED
Definition: comment.module:15
drupal_anonymous_user
drupal_anonymous_user()
Definition: bootstrap.inc:2152
field_get_items
field_get_items($entity_type, $entity, $field_name, $langcode=NULL)
Definition: field.module:935
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
comment_theme
comment_theme()
Definition: comment.module:195
$name
print $name
Definition: profile-listing.tpl.php:43
comment_rdf_mapping
comment_rdf_mapping()
Definition: comment.module:2689
node_type_get_type
node_type_get_type($node)
Definition: node.module:410
Exception
comment_form_build_preview
comment_form_build_preview($form, &$form_state)
Definition: comment.module:2053
comment_form_validate
comment_form_validate($form, &$form_state)
Definition: comment.module:2120
comment_unpublish_by_keyword_action
comment_unpublish_by_keyword_action($comment, $context)
Definition: comment.module:2617
DRUPAL_OPTIONAL
const DRUPAL_OPTIONAL
Definition: system.module:41
field_attach_prepare_view
field_attach_prepare_view($entity_type, $entities, $view_mode, $langcode=NULL, $options=array())
Definition: field.attach.inc:1133
field_read_instance
field_read_instance($entity_type, $field_name, $bundle, $include_additional=array())
Definition: field.crud.inc:692
MENU_NORMAL_ITEM
const MENU_NORMAL_ITEM
Definition: menu.inc:143
field_attach_presave
field_attach_presave($entity_type, $entity)
Definition: field.attach.inc:913
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
user_roles
user_roles($membersonly=FALSE, $permission=NULL)
Definition: user.module:2871
COMMENT_MODE_FLAT
const COMMENT_MODE_FLAT
Definition: comment.module:25
user_cookie_save
user_cookie_save(array $values)
Definition: user.module:3958
comment_form
comment_form($form, &$form_state, $comment)
Definition: comment.module:1841
ip_address
ip_address()
Definition: bootstrap.inc:2890
node_is_page
node_is_page($node)
Definition: node.module:1487
comment_publish_action
comment_publish_action($comment, $context=array())
Definition: comment.module:2560
comment_get_display_ordinal
comment_get_display_ordinal($cid, $node_type)
Definition: comment.module:1766
comment_menu_alter
comment_menu_alter(&$items)
Definition: comment.module:296
_comment_update_node_statistics
_comment_update_node_statistics($nid)
Definition: comment.module:2442
entity_uri
entity_uri($entity_type, $entity)
Definition: common.inc:7902
comment_user_delete
comment_user_delete($account)
Definition: comment.module:1419
COMMENT_NODE_HIDDEN
const COMMENT_NODE_HIDDEN
Definition: comment.module:60
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
comment_view
comment_view($comment, $node, $view_mode= 'full', $langcode=NULL)
Definition: comment.module:920
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
comment_uri
comment_uri($comment)
Definition: comment.module:157
comment_help
comment_help($path, $arg)
Definition: comment.module:75
field_create_field
field_create_field($field)
Definition: field.crud.inc:56
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
comment_node_search_result
comment_node_search_result($node)
Definition: comment.module:1381
NODE_PUBLISHED
const NODE_PUBLISHED
Definition: node.module:17
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
COMMENT_ANONYMOUS_MUST_CONTACT
const COMMENT_ANONYMOUS_MUST_CONTACT
Definition: comment.module:45
MENU_NOT_FOUND
const MENU_NOT_FOUND
Definition: menu.inc:234
node_type_get_types
node_type_get_types()
Definition: node.module:393
comment_block_info
comment_block_info()
Definition: comment.module:421
comment_permalink
comment_permalink($cid)
Definition: comment.module:479
menu_execute_active_handler
menu_execute_active_handler($path=NULL, $deliver=TRUE)
Definition: menu.inc:500
template_preprocess_comment_wrapper
template_preprocess_comment_wrapper(&$variables)
Definition: comment.module:2403
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
comment_load
comment_load($cid, $reset=FALSE)
Definition: comment.module:1683
field_attach_insert
field_attach_insert($entity_type, $entity)
Definition: field.attach.inc:936
comment_new_page_count
comment_new_page_count($num_comments, $new_replies, $node)
Definition: comment.module:537
comment_action_info
comment_action_info()
Definition: comment.module:2517
comment_node_load
comment_node_load($nodes, $types)
Definition: comment.module:1257
$info
$info
Definition: color.inc:6
node_mark
node_mark($nid, $timestamp)
Definition: node.module:350
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
comment_file_download_access
comment_file_download_access($field, $entity_type, $entity)
Definition: comment.module:2731
comment_block_save
comment_block_save($delta= '', $edit=array())
Definition: comment.module:445
entity_load_unchanged
entity_load_unchanged($entity_type, $id)
Definition: common.inc:7823
comment_node_type_delete
comment_node_type_delete($info)
Definition: comment.module:343
theme_comment_block
theme_comment_block()
Definition: comment.module:597
$value
print $value
Definition: user-profile-item.tpl.php:26
comment_node_prepare
comment_node_prepare($node)
Definition: comment.module:1292
comment_delete_multiple
comment_delete_multiple($cids)
Definition: comment.module:1616
comment_count_unpublished
comment_count_unpublished()
Definition: comment.module:311
DRUPAL_AUTHENTICATED_RID
const DRUPAL_AUTHENTICATED_RID
Definition: bootstrap.inc:167
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
entity_language
entity_language($entity_type, $entity)
Definition: common.inc:7967
db_ignore_slave
db_ignore_slave()
Definition: database.inc:3027
comment_edit_page
comment_edit_page($comment)
Definition: comment.module:1816
comment_block_configure
comment_block_configure($delta= '')
Definition: comment.module:431
_comment_per_page
_comment_per_page()
Definition: comment.module:2428
drupal_implode_tags
drupal_implode_tags($tags)
Definition: common.inc:7434
$author
print $author
Definition: comment.tpl.php:68
$output
$output
Definition: authorize.php:93
comment_build_content
comment_build_content($comment, $node, $view_mode= 'full', $langcode=NULL)
Definition: comment.module:987
drupal_html_id
drupal_html_id($id)
Definition: common.inc:3879
db_like
db_like($string)
Definition: database.inc:2610
user_access
user_access($string, $account=NULL)
Definition: user.module:794
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
DRUPAL_REQUIRED
const DRUPAL_REQUIRED
Definition: system.module:46
field_attach_preprocess
field_attach_preprocess($entity_type, $entity, $element, &$variables)
Definition: field.attach.inc:1272
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
RDF_DEFAULT_BUNDLE
const RDF_DEFAULT_BUNDLE
Definition: rdf.module:74
theme_get_setting
theme_get_setting($setting_name, $theme=NULL)
Definition: theme.inc:1401
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
COMMENT_ANONYMOUS_MAY_CONTACT
const COMMENT_ANONYMOUS_MAY_CONTACT
Definition: comment.module:40
form_get_errors
form_get_errors()
Definition: form.inc:1634
comment_submit
comment_submit($comment)
Definition: comment.module:2165
vancode2int
vancode2int($c= '00')
Definition: comment.module:2510
comment_num_new
comment_num_new($nid, $timestamp=0)
Definition: comment.module:1729
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
entity_prepare_view
entity_prepare_view($entity_type, $entities, $langcode=NULL)
Definition: common.inc:7866
comment_get_thread
comment_get_thread($node, $mode, $comments_per_page)
Definition: comment.module:822
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
valid_email_address
valid_email_address($mail)
Definition: common.inc:1186
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
db_transaction
db_transaction($name=NULL, array $options=array())
Definition: database.inc:2535
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
node_access
node_access($op, $node, $account=NULL)
Definition: node.module:2981
comment_ranking
comment_ranking()
Definition: comment.module:2669
node_type_get_names
node_type_get_names()
Definition: node.module:446
CommentController::buildQuery
buildQuery($ids, $conditions=array(), $revision_id=FALSE)
Definition: comment.module:1696
field_attach_rename_bundle
field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new)
Definition: field.attach.inc:1360
field_attach_view
field_attach_view($entity_type, $entity, $view_mode, $langcode=NULL, $options=array())
Definition: field.attach.inc:1216
field_is_translatable
field_is_translatable($entity_type, $field)
Definition: field.multilingual.inc:175
drupal_explode_tags
drupal_explode_tags($tags)
Definition: common.inc:7408
comment_entity_info
comment_entity_info()
Definition: comment.module:94
_comment_body_field_create
_comment_body_field_create($info)
Definition: comment.module:362
comment_get_display_page
comment_get_display_page($cid, $node_type)
Definition: comment.module:1807
comment_unpublish_by_keyword_action_form
comment_unpublish_by_keyword_action_form($context)
Definition: comment.module:2635
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
CommentController::attachLoad
attachLoad(&$comments, $revision_id=FALSE)
Definition: comment.module:1707
comment_menu
comment_menu()
Definition: comment.module:220
drupal_get_token
drupal_get_token($value= '')
Definition: common.inc:5077
DrupalDefaultEntityController
Definition: entity.inc:46
field_attach_delete_bundle
field_attach_delete_bundle($entity_type, $bundle)
Definition: field.attach.inc:1394
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
user_load_by_name
user_load_by_name($name)
Definition: user.module:397
comment_user_cancel
comment_user_cancel($edit, $account, $method)
Definition: comment.module:1396
comment_unpublish_by_keyword_action_submit
comment_unpublish_by_keyword_action_submit($form, $form_state)
Definition: comment.module:2651
DRUPAL_DISABLED
const DRUPAL_DISABLED
Definition: system.module:36
comment_node_page_additions
comment_node_page_additions($node)
Definition: comment.module:722
comment_delete
comment_delete($cid)
Definition: comment.module:1606
theme_comment_post_forbidden
theme_comment_post_forbidden($variables)
Definition: comment.module:2360
comment_view_multiple
comment_view_multiple($comments, $node, $view_mode= 'full', $weight=0, $langcode=NULL)
Definition: comment.module:1110
comment_form_node_type_form_alter
comment_form_node_type_form_alter(&$form, $form_state)
Definition: comment.module:1128
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
comment_field_extra_fields
comment_field_extra_fields()
Definition: comment.module:167
template_preprocess_comment
template_preprocess_comment(&$variables)
Definition: comment.module:2285
field_attach_create_bundle
field_attach_create_bundle($entity_type, $bundle)
Definition: field.attach.inc:1342
COMMENT_NODE_OPEN
const COMMENT_NODE_OPEN
Definition: comment.module:70
comment_node_delete
comment_node_delete($node)
Definition: comment.module:1321
COMMENT_PUBLISHED
const COMMENT_PUBLISHED
Definition: comment.module:20
check_markup
check_markup($text, $format_id=NULL, $langcode= '', $cache=FALSE)
Definition: filter.module:759
comment_preview
comment_preview($comment)
Definition: comment.module:2062
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
valid_url
valid_url($url, $absolute=FALSE)
Definition: common.inc:1204
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
comment_form_submit
comment_form_submit($form, &$form_state)
Definition: comment.module:2235
comment_permission
comment_permission()
Definition: comment.module:398
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
field_read_field
field_read_field($field_name, $include_additional=array())
Definition: field.crud.inc:315
truncate_utf8
truncate_utf8($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
Definition: unicode.inc:316
comment_node_insert
comment_node_insert($node)
Definition: comment.module:1301
comment_form_submit_build_comment
comment_form_submit_build_comment($form, &$form_state)
Definition: comment.module:2225
comment_node_type_load
comment_node_type_load($name)
Definition: comment.module:148
comment_update_index
comment_update_index()
Definition: comment.module:1370
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL
const USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL
Definition: user.module:32
comment_node_type_update
comment_node_type_update($info)
Definition: comment.module:334
entity_form_submit_build_entity
entity_form_submit_build_entity($entity_type, $entity, $form, &$form_state)
Definition: common.inc:8028
$links
print $links
Definition: poll-results--block.tpl.php:28
node_view
node_view($node, $view_mode= 'full', $langcode=NULL)
Definition: node.module:1329
comment_node_view
comment_node_view($node, $view_mode)
Definition: comment.module:615
comment_access
comment_access($op, $comment)
Definition: comment.module:1439
NODE_NEW_LIMIT
const NODE_NEW_LIMIT
Definition: node.module:45
COMMENT_ANONYMOUS_MAYNOT_CONTACT
const COMMENT_ANONYMOUS_MAYNOT_CONTACT
Definition: comment.module:35
field_attach_delete
field_attach_delete($entity_type, $entity)
Definition: field.attach.inc:1045
user_is_anonymous
user_is_anonymous()
Definition: user.module:1533
comment_node_type_insert
comment_node_type_insert($info)
Definition: comment.module:327
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.form.inc Source File

  • modules
  • field
field.form.inc
Go to the documentation of this file.
1 <?php
2
42 function field_default_form($entity_type, $entity, $field, $instance, $langcode, $items, &$form, &$form_state, $get_delta = NULL) {
43 // This could be called with no entity, as when a UI module creates a
44 // dummy form to set default values.
45 if ($entity) {
46 list($id, , ) = entity_extract_ids($entity_type, $entity);
47 }
48
49 $parents = $form['#parents'];
50
51 $addition = array();
52 $field_name = $field['field_name'];
53 $addition[$field_name] = array();
54
55 // Populate widgets with default values when creating a new entity.
56 if (empty($items) && empty($id)) {
57 $items = field_get_default_value($entity_type, $entity, $field, $instance, $langcode);
58 }
59
60 // Let modules alter the widget properties.
61 $context = array(
62 'entity_type' => $entity_type,
63 'entity' => $entity,
64 'field' => $field,
65 'instance' => $instance,
66 );
67 drupal_alter(array('field_widget_properties', 'field_widget_properties_' . $entity_type), $instance['widget'], $context);
68
69 // Collect widget elements.
70 $elements = array();
71
72 // Store field information in $form_state.
73 if (!field_form_get_state($parents, $field_name, $langcode, $form_state)) {
74 $field_state = array(
75 'field' => $field,
76 'instance' => $instance,
77 'items_count' => count($items),
78 'array_parents' => array(),
79 'errors' => array(),
80 );
81 field_form_set_state($parents, $field_name, $langcode, $form_state, $field_state);
82 }
83
84 // If field module handles multiple values for this form element, and we are
85 // displaying an individual element, process the multiple value form.
86 if (!isset($get_delta) && field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) {
87 // Store the entity in the form.
88 $form['#entity'] = $entity;
89 $elements = field_multiple_value_form($field, $instance, $langcode, $items, $form, $form_state);
90 }
91 // If the widget is handling multiple values (e.g Options), or if we are
92 // displaying an individual element, just get a single form element and make
93 // it the $delta value.
94 else {
95 $delta = isset($get_delta) ? $get_delta : 0;
96 $function = $instance['widget']['module'] . '_field_widget_form';
97 if (function_exists($function)) {
98 $element = array(
99 '#entity' => $entity,
100 '#entity_type' => $instance['entity_type'],
101 '#bundle' => $instance['bundle'],
102 '#field_name' => $field_name,
103 '#language' => $langcode,
104 '#field_parents' => $parents,
105 '#columns' => array_keys($field['columns']),
106 '#title' => check_plain($instance['label']),
107 '#description' => field_filter_xss($instance['description']),
108 // Only the first widget should be required.
109 '#required' => $delta == 0 && $instance['required'],
110 '#delta' => $delta,
111 );
112 if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $element)) {
113 // Allow modules to alter the field widget form element.
114 $context = array(
115 'form' => $form,
116 'field' => $field,
117 'instance' => $instance,
118 'langcode' => $langcode,
119 'items' => $items,
120 'delta' => $delta,
121 );
122 drupal_alter(array('field_widget_form', 'field_widget_' . $instance['widget']['type'] . '_form'), $element, $form_state, $context);
123
124 // If we're processing a specific delta value for a field where the
125 // field module handles multiples, set the delta in the result.
126 // For fields that handle their own processing, we can't make
127 // assumptions about how the field is structured, just merge in the
128 // returned element.
129 if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) {
130 $elements[$delta] = $element;
131 }
132 else {
133 $elements = $element;
134 }
135 }
136 }
137 }
138
139 // Also aid in theming of field widgets by rendering a classified container.
140 $addition[$field_name] = array(
141 '#type' => 'container',
142 '#attributes' => array(
143 'class' => array(
144 'field-type-' . drupal_html_class($field['type']),
145 'field-name-' . drupal_html_class($field_name),
146 'field-widget-' . drupal_html_class($instance['widget']['type']),
147 ),
148 ),
149 '#weight' => $instance['widget']['weight'],
150 );
151
152 // Populate the 'array_parents' information in $form_state['field'] after
153 // the form is built, so that we catch changes in the form structure performed
154 // in alter() hooks.
155 $elements['#after_build'][] = 'field_form_element_after_build';
156 $elements['#field_name'] = $field_name;
157 $elements['#language'] = $langcode;
158 $elements['#field_parents'] = $parents;
159
160 $addition[$field_name] += array(
161 '#tree' => TRUE,
162 // The '#language' key can be used to access the field's form element
163 // when $langcode is unknown.
164 '#language' => $langcode,
165 $langcode => $elements,
166 '#access' => field_access('edit', $field, $entity_type, $entity),
167 );
168
169 return $addition;
170 }
171
180 function field_multiple_value_form($field, $instance, $langcode, $items, &$form, &$form_state) {
181 $field_name = $field['field_name'];
182 $parents = $form['#parents'];
183
184 // Determine the number of widgets to display.
185 switch ($field['cardinality']) {
186 case FIELD_CARDINALITY_UNLIMITED:
187 $field_state = field_form_get_state($parents, $field_name, $langcode, $form_state);
188 $max = $field_state['items_count'];
189 break;
190
191 default:
192 $max = $field['cardinality'] - 1;
193 break;
194 }
195
196 $title = check_plain($instance['label']);
197 $description = field_filter_xss($instance['description']);
198
199 $id_prefix = implode('-', array_merge($parents, array($field_name)));
200 $wrapper_id = drupal_html_id($id_prefix . '-add-more-wrapper');
201
202 $field_elements = array();
203
204 $function = $instance['widget']['module'] . '_field_widget_form';
205 if (function_exists($function)) {
206 for ($delta = 0; $delta <= $max; $delta++) {
207 $multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED;
208 $element = array(
209 '#entity_type' => $instance['entity_type'],
210 '#entity' => $form['#entity'],
211 '#bundle' => $instance['bundle'],
212 '#field_name' => $field_name,
213 '#language' => $langcode,
214 '#field_parents' => $parents,
215 '#columns' => array_keys($field['columns']),
216 // For multiple fields, title and description are handled by the wrapping table.
217 '#title' => $multiple ? '' : $title,
218 '#description' => $multiple ? '' : $description,
219 // Only the first widget should be required.
220 '#required' => $delta == 0 && $instance['required'],
221 '#delta' => $delta,
222 '#weight' => $delta,
223 );
224 if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $element)) {
225 // Input field for the delta (drag-n-drop reordering).
226 if ($multiple) {
227 // We name the element '_weight' to avoid clashing with elements
228 // defined by widget.
229 $element['_weight'] = array(
230 '#type' => 'weight',
231 '#title' => t('Weight for row @number', array('@number' => $delta + 1)),
232 '#title_display' => 'invisible',
233 // Note: this 'delta' is the FAPI 'weight' element's property.
234 '#delta' => $max,
235 '#default_value' => isset($items[$delta]['_weight']) ? $items[$delta]['_weight'] : $delta,
236 '#weight' => 100,
237 );
238 }
239
240 // Allow modules to alter the field widget form element.
241 $context = array(
242 'form' => $form,
243 'field' => $field,
244 'instance' => $instance,
245 'langcode' => $langcode,
246 'items' => $items,
247 'delta' => $delta,
248 );
249 drupal_alter(array('field_widget_form', 'field_widget_' . $instance['widget']['type'] . '_form'), $element, $form_state, $context);
250
251 $field_elements[$delta] = $element;
252 }
253 }
254
255 if ($field_elements) {
256 $field_elements += array(
257 '#theme' => 'field_multiple_value_form',
258 '#field_name' => $field['field_name'],
259 '#cardinality' => $field['cardinality'],
260 '#title' => $title,
261 '#required' => $instance['required'],
262 '#description' => $description,
263 '#prefix' => '<div id="' . $wrapper_id . '">',
264 '#suffix' => '</div>',
265 '#max_delta' => $max,
266 );
267 // Add 'add more' button, if not working with a programmed form.
268 if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED && empty($form_state['programmed'])) {
269 $field_elements['add_more'] = array(
270 '#type' => 'submit',
271 '#name' => strtr($id_prefix, '-', '_') . '_add_more',
272 '#value' => t('Add another item'),
273 '#attributes' => array('class' => array('field-add-more-submit')),
274 '#limit_validation_errors' => array(array_merge($parents, array($field_name, $langcode))),
275 '#submit' => array('field_add_more_submit'),
276 '#ajax' => array(
277 'callback' => 'field_add_more_js',
278 'wrapper' => $wrapper_id,
279 'effect' => 'fade',
280 ),
281 );
282 }
283 }
284 }
285
286 return $field_elements;
287 }
288
301 function theme_field_multiple_value_form($variables) {
302 $element = $variables['element'];
303 $output = '';
304
305 if ($element['#cardinality'] > 1 || $element['#cardinality'] == FIELD_CARDINALITY_UNLIMITED) {
306 $table_id = drupal_html_id($element['#field_name'] . '_values');
307 $order_class = $element['#field_name'] . '-delta-order';
308 $required = !empty($element['#required']) ? theme('form_required_marker', $variables) : '';
309
310 $header = array(
311 array(
312 'data' => '<label>' . t('!title !required', array('!title' => $element['#title'], '!required' => $required)) . "</label>",
313 'colspan' => 2,
314 'class' => array('field-label'),
315 ),
316 t('Order'),
317 );
318 $rows = array();
319
320 // Sort items according to '_weight' (needed when the form comes back after
321 // preview or failed validation)
322 $items = array();
323 foreach (element_children($element) as $key) {
324 if ($key === 'add_more') {
325 $add_more_button = &$element[$key];
326 }
327 else {
328 $items[] = &$element[$key];
329 }
330 }
331 usort($items, '_field_sort_items_value_helper');
332
333 // Add the items as table rows.
334 foreach ($items as $key => $item) {
335 $item['_weight']['#attributes']['class'] = array($order_class);
336 $delta_element = drupal_render($item['_weight']);
337 $cells = array(
338 array('data' => '', 'class' => array('field-multiple-drag')),
339 drupal_render($item),
340 array('data' => $delta_element, 'class' => array('delta-order')),
341 );
342 $rows[] = array(
343 'data' => $cells,
344 'class' => array('draggable'),
345 );
346 }
347
348 $output = '<div class="form-item">';
349 $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => $table_id, 'class' => array('field-multiple-table'))));
350 $output .= $element['#description'] ? '<div class="description">' . $element['#description'] . '</div>' : '';
351 $output .= '<div class="clearfix">' . drupal_render($add_more_button) . '</div>';
352 $output .= '</div>';
353
354 drupal_add_tabledrag($table_id, 'order', 'sibling', $order_class);
355 }
356 else {
357 foreach (element_children($element) as $key) {
358 $output .= drupal_render($element[$key]);
359 }
360 }
361
362 return $output;
363 }
364
374 function field_form_element_after_build($element, &$form_state) {
375 $parents = $element['#field_parents'];
376 $field_name = $element['#field_name'];
377 $langcode = $element['#language'];
378
379 $field_state = field_form_get_state($parents, $field_name, $langcode, $form_state);
380 $field_state['array_parents'] = $element['#array_parents'];
381 field_form_set_state($parents, $field_name, $langcode, $form_state, $field_state);
382
383 return $element;
384 }
385
389 function field_default_form_errors($entity_type, $entity, $field, $instance, $langcode, $items, $form, &$form_state) {
390 $field_state = field_form_get_state($form['#parents'], $field['field_name'], $langcode, $form_state);
391
392 if (!empty($field_state['errors'])) {
393 // Locate the correct element in the form.
394 $element = drupal_array_get_nested_value($form_state['complete form'], $field_state['array_parents']);
395 // Only set errors if the element is accessible.
396 if (!isset($element['#access']) || $element['#access']) {
397 $function = $instance['widget']['module'] . '_field_widget_error';
398 $function_exists = function_exists($function);
399
400 $multiple_widget = field_behaviors_widget('multiple values', $instance) != FIELD_BEHAVIOR_DEFAULT;
401 foreach ($field_state['errors'] as $delta => $delta_errors) {
402 // For multiple single-value widgets, pass errors by delta.
403 // For a multiple-value widget, pass all errors to the main widget.
404 $error_element = $multiple_widget ? $element : $element[$delta];
405 foreach ($delta_errors as $error) {
406 if ($function_exists) {
407 $function($error_element, $error, $form, $form_state);
408 }
409 else {
410 // Make sure that errors are reported (even incorrectly flagged) if
411 // the widget module fails to implement hook_field_widget_error().
412 form_error($error_element, $error['message']);
413 }
414 }
415 }
416 // Reinitialize the errors list for the next submit.
417 $field_state['errors'] = array();
418 field_form_set_state($form['#parents'], $field['field_name'], $langcode, $form_state, $field_state);
419 }
420 }
421 }
422
432 function field_add_more_submit($form, &$form_state) {
433 $button = $form_state['triggering_element'];
434
435 // Go one level up in the form, to the widgets container.
436 $element = drupal_array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1));
437 $field_name = $element['#field_name'];
438 $langcode = $element['#language'];
439 $parents = $element['#field_parents'];
440
441 // Increment the items count.
442 $field_state = field_form_get_state($parents, $field_name, $langcode, $form_state);
443 $field_state['items_count']++;
444 field_form_set_state($parents, $field_name, $langcode, $form_state, $field_state);
445
446 $form_state['rebuild'] = TRUE;
447 }
448
457 function field_add_more_js($form, $form_state) {
458 $button = $form_state['triggering_element'];
459
460 // Go one level up in the form, to the widgets container.
461 $element = drupal_array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1));
462 $field_name = $element['#field_name'];
463 $langcode = $element['#language'];
464 $parents = $element['#field_parents'];
465
466 $field_state = field_form_get_state($parents, $field_name, $langcode, $form_state);
467
468 $field = $field_state['field'];
469 if ($field['cardinality'] != FIELD_CARDINALITY_UNLIMITED) {
470 return;
471 }
472
473 // Add a DIV around the delta receiving the Ajax effect.
474 $delta = $element['#max_delta'];
475 $element[$delta]['#prefix'] = '<div class="ajax-new-content">' . (isset($element[$delta]['#prefix']) ? $element[$delta]['#prefix'] : '');
476 $element[$delta]['#suffix'] = (isset($element[$delta]['#suffix']) ? $element[$delta]['#suffix'] : '') . '</div>';
477
478 return $element;
479 }
480
505 function field_form_get_state($parents, $field_name, $langcode, &$form_state) {
506 $form_state_parents = _field_form_state_parents($parents, $field_name, $langcode);
507 return drupal_array_get_nested_value($form_state, $form_state_parents);
508 }
509
527 function field_form_set_state($parents, $field_name, $langcode, &$form_state, $field_state) {
528 $form_state_parents = _field_form_state_parents($parents, $field_name, $langcode);
529 drupal_array_set_nested_value($form_state, $form_state_parents, $field_state);
530 }
531
535 function _field_form_state_parents($parents, $field_name, $langcode) {
536 // To ensure backwards compatibility on regular entity forms for widgets that
537 // still access $form_state['field'][$field_name] directly,
538 // - top-level fields (empty $parents) are placed directly under
539 // $form_state['fields'][$field_name].
540 // - Other fields are placed under
541 // $form_state['field']['#parents'][...$parents...]['#fields'][$field_name]
542 // to avoid clashes between field names and $parents parts.
543 // @todo Remove backwards compatibility in Drupal 8, and use a unique
544 // $form_state['field'][...$parents...]['#fields'][$field_name] structure.
545 if (!empty($parents)) {
546 $form_state_parents = array_merge(array('#parents'), $parents, array('#fields'));
547 }
548 else {
549 $form_state_parents = array();
550 }
551 $form_state_parents = array_merge(array('field'), $form_state_parents, array($field_name, $langcode));
552
553 return $form_state_parents;
554 }
555
576 function field_widget_field($element, $form_state) {
577 $field_state = field_form_get_state($element['#field_parents'], $element['#field_name'], $element['#language'], $form_state);
578 return $field_state['field'];
579 }
580
601 function field_widget_instance($element, $form_state) {
602 $field_state = field_form_get_state($element['#field_parents'], $element['#field_name'], $element['#language'], $form_state);
603 return $field_state['instance'];
604 }
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
field_filter_xss
field_filter_xss($string)
Definition: field.module:752
field_default_form_errors
field_default_form_errors($entity_type, $entity, $field, $instance, $langcode, $items, $form, &$form_state)
Definition: field.form.inc:389
drupal_array_get_nested_value
& drupal_array_get_nested_value(array &$array, array $parents, &$key_exists=NULL)
Definition: common.inc:6666
$header
print $header
Definition: forum-topic-list.tpl.php:42
field_access
field_access($op, $field, $entity_type, $entity=NULL, $account=NULL)
Definition: field.module:982
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
FIELD_BEHAVIOR_DEFAULT
const FIELD_BEHAVIOR_DEFAULT
Definition: field.module:255
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
field_widget_instance
field_widget_instance($element, $form_state)
Definition: field.form.inc:601
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
field_behaviors_widget
field_behaviors_widget($op, $instance)
Definition: field.info.inc:313
field_default_form
field_default_form($entity_type, $entity, $field, $instance, $langcode, $items, &$form, &$form_state, $get_delta=NULL)
Definition: field.form.inc:42
field_form_set_state
field_form_set_state($parents, $field_name, $langcode, &$form_state, $field_state)
Definition: field.form.inc:527
$output
$output
Definition: authorize.php:93
drupal_html_id
drupal_html_id($id)
Definition: common.inc:3879
field_get_default_value
field_get_default_value($entity_type, $entity, $field, $instance, $langcode=NULL)
Definition: field.module:479
FIELD_CARDINALITY_UNLIMITED
const FIELD_CARDINALITY_UNLIMITED
Definition: field.module:236
field_add_more_js
field_add_more_js($form, $form_state)
Definition: field.form.inc:457
field_form_get_state
field_form_get_state($parents, $field_name, $langcode, &$form_state)
Definition: field.form.inc:505
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
field_form_element_after_build
field_form_element_after_build($element, &$form_state)
Definition: field.form.inc:374
field_add_more_submit
field_add_more_submit($form, &$form_state)
Definition: field.form.inc:432
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
drupal_array_set_nested_value
drupal_array_set_nested_value(array &$array, array $parents, $value, $force=FALSE)
Definition: common.inc:6598
field_widget_field
field_widget_field($element, $form_state)
Definition: field.form.inc:576
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
entity_extract_ids
entity_extract_ids($entity_type, $entity)
Definition: common.inc:7711
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
_field_form_state_parents
_field_form_state_parents($parents, $field_name, $langcode)
Definition: field.form.inc:535
theme_field_multiple_value_form
theme_field_multiple_value_form($variables)
Definition: field.form.inc:301
field_multiple_value_form
field_multiple_value_form($field, $instance, $langcode, $items, &$form, &$form_state)
Definition: field.form.inc:180
drupal_html_class
drupal_html_class($class)
Definition: common.inc:3841
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user.admin.inc Source File

  • modules
  • user
user.admin.inc
Go to the documentation of this file.
1 <?php
2
23 function user_admin($callback_arg = '') {
24 $op = isset($_POST['op']) ? $_POST['op'] : $callback_arg;
25
26 switch ($op) {
27 case t('Create new account'):
28 case 'create':
29 $build['user_register'] = drupal_get_form('user_register_form');
30 break;
31 default:
32 if (!empty($_POST['accounts']) && isset($_POST['operation']) && ($_POST['operation'] == 'cancel')) {
33 $build['user_multiple_cancel_confirm'] = drupal_get_form('user_multiple_cancel_confirm');
34 }
35 else {
36 $build['user_filter_form'] = drupal_get_form('user_filter_form');
37 $build['user_admin_account'] = drupal_get_form('user_admin_account');
38 }
39 }
40 return $build;
41 }
42
49 function user_filter_form() {
50 $session = isset($_SESSION['user_overview_filter']) ? $_SESSION['user_overview_filter'] : array();
51 $filters = user_filters();
52
53 $i = 0;
54 $form['filters'] = array(
55 '#type' => 'fieldset',
56 '#title' => t('Show only users where'),
57 '#theme' => 'exposed_filters__user',
58 );
59 foreach ($session as $filter) {
60 list($type, $value) = $filter;
61 if ($type == 'permission') {
62 // Merge arrays of module permissions into one.
63 // Slice past the first element '[any]' whose value is not an array.
64 $options = call_user_func_array('array_merge', array_slice($filters[$type]['options'], 1));
65 $value = $options[$value];
66 }
67 else {
68 $value = $filters[$type]['options'][$value];
69 }
70 $t_args = array('%property' => $filters[$type]['title'], '%value' => $value);
71 if ($i++) {
72 $form['filters']['current'][] = array('#markup' => t('and where %property is %value', $t_args));
73 }
74 else {
75 $form['filters']['current'][] = array('#markup' => t('%property is %value', $t_args));
76 }
77 }
78
79 $form['filters']['status'] = array(
80 '#type' => 'container',
81 '#attributes' => array('class' => array('clearfix')),
82 '#prefix' => ($i ? '<div class="additional-filters">' . t('and where') . '</div>' : ''),
83 );
84 $form['filters']['status']['filters'] = array(
85 '#type' => 'container',
86 '#attributes' => array('class' => array('filters')),
87 );
88 foreach ($filters as $key => $filter) {
89 $form['filters']['status']['filters'][$key] = array(
90 '#type' => 'select',
91 '#options' => $filter['options'],
92 '#title' => $filter['title'],
93 '#default_value' => '[any]',
94 );
95 }
96
97 $form['filters']['status']['actions'] = array(
98 '#type' => 'actions',
99 '#attributes' => array('class' => array('container-inline')),
100 );
101 $form['filters']['status']['actions']['submit'] = array(
102 '#type' => 'submit',
103 '#value' => (count($session) ? t('Refine') : t('Filter')),
104 );
105 if (count($session)) {
106 $form['filters']['status']['actions']['undo'] = array(
107 '#type' => 'submit',
108 '#value' => t('Undo'),
109 );
110 $form['filters']['status']['actions']['reset'] = array(
111 '#type' => 'submit',
112 '#value' => t('Reset'),
113 );
114 }
115
116 drupal_add_library('system', 'drupal.form');
117
118 return $form;
119 }
120
124 function user_filter_form_submit($form, &$form_state) {
125 $op = $form_state['values']['op'];
126 $filters = user_filters();
127 switch ($op) {
128 case t('Filter'):
129 case t('Refine'):
130 // Apply every filter that has a choice selected other than 'any'.
131 foreach ($filters as $filter => $options) {
132 if (isset($form_state['values'][$filter]) && $form_state['values'][$filter] != '[any]') {
133 // Merge an array of arrays into one if necessary.
134 $options = ($filter == 'permission') ? form_options_flatten($filters[$filter]['options']) : $filters[$filter]['options'];
135 // Only accept valid selections offered on the dropdown, block bad input.
136 if (isset($options[$form_state['values'][$filter]])) {
137 $_SESSION['user_overview_filter'][] = array($filter, $form_state['values'][$filter]);
138 }
139 }
140 }
141 break;
142 case t('Undo'):
143 array_pop($_SESSION['user_overview_filter']);
144 break;
145 case t('Reset'):
146 $_SESSION['user_overview_filter'] = array();
147 break;
148 case t('Update'):
149 return;
150 }
151
152 $form_state['redirect'] = 'admin/people';
153 return;
154 }
155
163 function user_admin_account() {
164
165 $header = array(
166 'username' => array('data' => t('Username'), 'field' => 'u.name'),
167 'status' => array('data' => t('Status'), 'field' => 'u.status'),
168 'roles' => array('data' => t('Roles')),
169 'member_for' => array('data' => t('Member for'), 'field' => 'u.created', 'sort' => 'desc'),
170 'access' => array('data' => t('Last access'), 'field' => 'u.access'),
171 'operations' => array('data' => t('Operations')),
172 );
173
174 $query = db_select('users', 'u');
175 $query->condition('u.uid', 0, '<>');
176 user_build_filter_query($query);
177
178 $count_query = clone $query;
179 $count_query->addExpression('COUNT(u.uid)');
180
181 $query = $query->extend('PagerDefault')->extend('TableSort');
182 $query
183 ->fields('u', array('uid', 'name', 'status', 'created', 'access'))
184 ->limit(50)
185 ->orderByHeader($header)
186 ->setCountQuery($count_query);
187 $result = $query->execute();
188
189 $form['options'] = array(
190 '#type' => 'fieldset',
191 '#title' => t('Update options'),
192 '#attributes' => array('class' => array('container-inline')),
193 );
194 $options = array();
195 foreach (module_invoke_all('user_operations') as $operation => $array) {
196 $options[$operation] = $array['label'];
197 }
198 $form['options']['operation'] = array(
199 '#type' => 'select',
200 '#title' => t('Operation'),
201 '#title_display' => 'invisible',
202 '#options' => $options,
203 '#default_value' => 'unblock',
204 );
205 $options = array();
206 $form['options']['submit'] = array(
207 '#type' => 'submit',
208 '#value' => t('Update'),
209 );
210
211 $destination = drupal_get_destination();
212
213 $status = array(t('blocked'), t('active'));
214 $roles = array_map('check_plain', user_roles(TRUE));
215 $accounts = array();
216 foreach ($result as $account) {
217 $users_roles = array();
218 $roles_result = db_query('SELECT rid FROM {users_roles} WHERE uid = :uid', array(':uid' => $account->uid));
219 foreach ($roles_result as $user_role) {
220 $users_roles[] = $roles[$user_role->rid];
221 }
222 asort($users_roles);
223
224 $options[$account->uid] = array(
225 'username' => theme('username', array('account' => $account)),
226 'status' => $status[$account->status],
227 'roles' => theme('item_list', array('items' => $users_roles)),
228 'member_for' => format_interval(REQUEST_TIME - $account->created),
229 'access' => $account->access ? t('@time ago', array('@time' => format_interval(REQUEST_TIME - $account->access))) : t('never'),
230 'operations' => array('data' => array('#type' => 'link', '#title' => t('edit'), '#href' => "user/$account->uid/edit", '#options' => array('query' => $destination))),
231 );
232 }
233
234 $form['accounts'] = array(
235 '#type' => 'tableselect',
236 '#header' => $header,
237 '#options' => $options,
238 '#empty' => t('No people available.'),
239 );
240 $form['pager'] = array('#markup' => theme('pager'));
241
242 return $form;
243 }
244
248 function user_admin_account_submit($form, &$form_state) {
249 $operations = module_invoke_all('user_operations', $form, $form_state);
250 $operation = $operations[$form_state['values']['operation']];
251 // Filter out unchecked accounts.
252 $accounts = array_filter($form_state['values']['accounts']);
253 if ($function = $operation['callback']) {
254 // Add in callback arguments if present.
255 if (isset($operation['callback arguments'])) {
256 $args = array_merge(array($accounts), $operation['callback arguments']);
257 }
258 else {
259 $args = array($accounts);
260 }
261 call_user_func_array($function, $args);
262
263 drupal_set_message(t('The update has been performed.'));
264 }
265 }
266
267 function user_admin_account_validate($form, &$form_state) {
268 $form_state['values']['accounts'] = array_filter($form_state['values']['accounts']);
269 if (count($form_state['values']['accounts']) == 0) {
270 form_set_error('', t('No users selected.'));
271 }
272 }
273
280 function user_admin_settings() {
281 // Settings for anonymous users.
282 $form['anonymous_settings'] = array(
283 '#type' => 'fieldset',
284 '#title' => t('Anonymous users'),
285 );
286 $form['anonymous_settings']['anonymous'] = array(
287 '#type' => 'textfield',
288 '#title' => t('Name'),
289 '#default_value' => variable_get('anonymous', t('Anonymous')),
290 '#description' => t('The name used to indicate anonymous users.'),
291 '#required' => TRUE,
292 );
293
294 // Administrative role option.
295 $form['admin_role'] = array(
296 '#type' => 'fieldset',
297 '#title' => t('Administrator role'),
298 );
299
300 // Do not allow users to set the anonymous or authenticated user roles as the
301 // administrator role.
302 $roles = user_roles();
303 unset($roles[DRUPAL_ANONYMOUS_RID]);
304 unset($roles[DRUPAL_AUTHENTICATED_RID]);
305 $roles[0] = t('disabled');
306
307 $form['admin_role']['user_admin_role'] = array(
308 '#type' => 'select',
309 '#title' => t('Administrator role'),
310 '#default_value' => variable_get('user_admin_role', 0),
311 '#options' => $roles,
312 '#description' => t('This role will be automatically assigned new permissions whenever a module is enabled. Changing this setting will not affect existing permissions.'),
313 );
314
315 // User registration settings.
316 $form['registration_cancellation'] = array(
317 '#type' => 'fieldset',
318 '#title' => t('Registration and cancellation'),
319 );
320 $form['registration_cancellation']['user_register'] = array(
321 '#type' => 'radios',
322 '#title' => t('Who can register accounts?'),
323 '#default_value' => variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL),
324 '#options' => array(
325 USER_REGISTER_ADMINISTRATORS_ONLY => t('Administrators only'),
326 USER_REGISTER_VISITORS => t('Visitors'),
327 USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL => t('Visitors, but administrator approval is required'),
328 )
329 );
330 $form['registration_cancellation']['user_email_verification'] = array(
331 '#type' => 'checkbox',
332 '#title' => t('Require e-mail verification when a visitor creates an account.'),
333 '#default_value' => variable_get('user_email_verification', TRUE),
334 '#description' => t('New users will be required to validate their e-mail address prior to logging into the site, and will be assigned a system-generated password. With this setting disabled, users will be logged in immediately upon registering, and may select their own passwords during registration.')
335 );
336 module_load_include('inc', 'user', 'user.pages');
337 $form['registration_cancellation']['user_cancel_method'] = array(
338 '#type' => 'item',
339 '#title' => t('When cancelling a user account'),
340 '#description' => t('Users with the %select-cancel-method or %administer-users <a href="@permissions-url">permissions</a> can override this default method.', array('%select-cancel-method' => t('Select method for cancelling account'), '%administer-users' => t('Administer users'), '@permissions-url' => url('admin/people/permissions'))),
341 );
342 $form['registration_cancellation']['user_cancel_method'] += user_cancel_methods();
343 foreach (element_children($form['registration_cancellation']['user_cancel_method']) as $element) {
344 // Remove all account cancellation methods that have #access defined, as
345 // those cannot be configured as default method.
346 if (isset($form['registration_cancellation']['user_cancel_method'][$element]['#access'])) {
347 $form['registration_cancellation']['user_cancel_method'][$element]['#access'] = FALSE;
348 }
349 // Remove the description (only displayed on the confirmation form).
350 else {
351 unset($form['registration_cancellation']['user_cancel_method'][$element]['#description']);
352 }
353 }
354
355 // Account settings.
356 $form['personalization'] = array(
357 '#type' => 'fieldset',
358 '#title' => t('Personalization'),
359 );
360 $form['personalization']['user_signatures'] = array(
361 '#type' => 'checkbox',
362 '#title' => t('Enable signatures.'),
363 '#default_value' => variable_get('user_signatures', 0),
364 );
365 // If picture support is enabled, check whether the picture directory exists.
366 if (variable_get('user_pictures', 0)) {
367 $picture_path = file_default_scheme() . '://' . variable_get('user_picture_path', 'pictures');
368 if (!file_prepare_directory($picture_path, FILE_CREATE_DIRECTORY)) {
369 form_set_error('user_picture_path', t('The directory %directory does not exist or is not writable.', array('%directory' => $picture_path)));
370 watchdog('file system', 'The directory %directory does not exist or is not writable.', array('%directory' => $picture_path), WATCHDOG_ERROR);
371 }
372 }
373 $picture_support = variable_get('user_pictures', 0);
374 $form['personalization']['user_pictures'] = array(
375 '#type' => 'checkbox',
376 '#title' => t('Enable user pictures.'),
377 '#default_value' => $picture_support,
378 );
379 drupal_add_js(drupal_get_path('module', 'user') . '/user.js');
380 $form['personalization']['pictures'] = array(
381 '#type' => 'container',
382 '#states' => array(
383 // Hide the additional picture settings when user pictures are disabled.
384 'invisible' => array(
385 'input[name="user_pictures"]' => array('checked' => FALSE),
386 ),
387 ),
388 );
389 $form['personalization']['pictures']['user_picture_path'] = array(
390 '#type' => 'textfield',
391 '#title' => t('Picture directory'),
392 '#default_value' => variable_get('user_picture_path', 'pictures'),
393 '#size' => 30,
394 '#maxlength' => 255,
395 '#description' => t('Subdirectory in the file upload directory where pictures will be stored.'),
396 );
397 $form['personalization']['pictures']['user_picture_default'] = array(
398 '#type' => 'textfield',
399 '#title' => t('Default picture'),
400 '#default_value' => variable_get('user_picture_default', ''),
401 '#size' => 30,
402 '#maxlength' => 255,
403 '#description' => t('URL of picture to display for users with no custom picture selected. Leave blank for none.'),
404 );
405 if (module_exists('image')) {
406 $form['personalization']['pictures']['settings']['user_picture_style'] = array(
407 '#type' => 'select',
408 '#title' => t('Picture display style'),
409 '#options' => image_style_options(TRUE, PASS_THROUGH),
410 '#default_value' => variable_get('user_picture_style', ''),
411 '#description' => t('The style selected will be used on display, while the original image is retained. Styles may be configured in the <a href="!url">Image styles</a> administration area.', array('!url' => url('admin/config/media/image-styles'))),
412 );
413 }
414 $form['personalization']['pictures']['user_picture_dimensions'] = array(
415 '#type' => 'textfield',
416 '#title' => t('Picture upload dimensions'),
417 '#default_value' => variable_get('user_picture_dimensions', '85x85'),
418 '#size' => 10,
419 '#maxlength' => 10,
420 '#field_suffix' => ' ' . t('pixels'),
421 '#description' => t('Pictures larger than this will be scaled down to this size.'),
422 );
423 $form['personalization']['pictures']['user_picture_file_size'] = array(
424 '#type' => 'textfield',
425 '#title' => t('Picture upload file size'),
426 '#default_value' => variable_get('user_picture_file_size', '30'),
427 '#size' => 10,
428 '#maxlength' => 10,
429 '#field_suffix' => ' ' . t('KB'),
430 '#description' => t('Maximum allowed file size for uploaded pictures. Upload size is normally limited only by the PHP maximum post and file upload settings, and images are automatically scaled down to the dimensions specified above.'),
431 '#element_validate' => array('element_validate_integer_positive'),
432 );
433 $form['personalization']['pictures']['user_picture_guidelines'] = array(
434 '#type' => 'textarea',
435 '#title' => t('Picture guidelines'),
436 '#default_value' => variable_get('user_picture_guidelines', ''),
437 '#description' => t("This text is displayed at the picture upload form in addition to the default guidelines. It's useful for helping or instructing your users."),
438 );
439
440 $form['email_title'] = array(
441 '#type' => 'item',
442 '#title' => t('E-mails'),
443 );
444 $form['email'] = array(
445 '#type' => 'vertical_tabs',
446 );
447 // These email tokens are shared for all settings, so just define
448 // the list once to help ensure they stay in sync.
449 $email_token_help = t('Available variables are: [site:name], [site:url], [user:name], [user:mail], [site:login-url], [site:url-brief], [user:edit-url], [user:one-time-login-url], [user:cancel-url].');
450
451 $form['email_admin_created'] = array(
452 '#type' => 'fieldset',
453 '#title' => t('Welcome (new user created by administrator)'),
454 '#collapsible' => TRUE,
455 '#collapsed' => (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) != USER_REGISTER_ADMINISTRATORS_ONLY),
456 '#description' => t('Edit the welcome e-mail messages sent to new member accounts created by an administrator.') . ' ' . $email_token_help,
457 '#group' => 'email',
458 );
459 $form['email_admin_created']['user_mail_register_admin_created_subject'] = array(
460 '#type' => 'textfield',
461 '#title' => t('Subject'),
462 '#default_value' => _user_mail_text('register_admin_created_subject', NULL, array(), FALSE),
463 '#maxlength' => 180,
464 );
465 $form['email_admin_created']['user_mail_register_admin_created_body'] = array(
466 '#type' => 'textarea',
467 '#title' => t('Body'),
468 '#default_value' => _user_mail_text('register_admin_created_body', NULL, array(), FALSE),
469 '#rows' => 15,
470 );
471
472 $form['email_pending_approval'] = array(
473 '#type' => 'fieldset',
474 '#title' => t('Welcome (awaiting approval)'),
475 '#collapsible' => TRUE,
476 '#collapsed' => (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) != USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL),
477 '#description' => t('Edit the welcome e-mail messages sent to new members upon registering, when administrative approval is required.') . ' ' . $email_token_help,
478 '#group' => 'email',
479 );
480 $form['email_pending_approval']['user_mail_register_pending_approval_subject'] = array(
481 '#type' => 'textfield',
482 '#title' => t('Subject'),
483 '#default_value' => _user_mail_text('register_pending_approval_subject', NULL, array(), FALSE),
484 '#maxlength' => 180,
485 );
486 $form['email_pending_approval']['user_mail_register_pending_approval_body'] = array(
487 '#type' => 'textarea',
488 '#title' => t('Body'),
489 '#default_value' => _user_mail_text('register_pending_approval_body', NULL, array(), FALSE),
490 '#rows' => 8,
491 );
492
493 $form['email_no_approval_required'] = array(
494 '#type' => 'fieldset',
495 '#title' => t('Welcome (no approval required)'),
496 '#collapsible' => TRUE,
497 '#collapsed' => (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) != USER_REGISTER_VISITORS),
498 '#description' => t('Edit the welcome e-mail messages sent to new members upon registering, when no administrator approval is required.') . ' ' . $email_token_help,
499 '#group' => 'email',
500 );
501 $form['email_no_approval_required']['user_mail_register_no_approval_required_subject'] = array(
502 '#type' => 'textfield',
503 '#title' => t('Subject'),
504 '#default_value' => _user_mail_text('register_no_approval_required_subject', NULL, array(), FALSE),
505 '#maxlength' => 180,
506 );
507 $form['email_no_approval_required']['user_mail_register_no_approval_required_body'] = array(
508 '#type' => 'textarea',
509 '#title' => t('Body'),
510 '#default_value' => _user_mail_text('register_no_approval_required_body', NULL, array(), FALSE),
511 '#rows' => 15,
512 );
513
514 $form['email_password_reset'] = array(
515 '#type' => 'fieldset',
516 '#title' => t('Password recovery'),
517 '#collapsible' => TRUE,
518 '#collapsed' => TRUE,
519 '#description' => t('Edit the e-mail messages sent to users who request a new password.') . ' ' . $email_token_help,
520 '#group' => 'email',
521 '#weight' => 10,
522 );
523 $form['email_password_reset']['user_mail_password_reset_subject'] = array(
524 '#type' => 'textfield',
525 '#title' => t('Subject'),
526 '#default_value' => _user_mail_text('password_reset_subject', NULL, array(), FALSE),
527 '#maxlength' => 180,
528 );
529 $form['email_password_reset']['user_mail_password_reset_body'] = array(
530 '#type' => 'textarea',
531 '#title' => t('Body'),
532 '#default_value' => _user_mail_text('password_reset_body', NULL, array(), FALSE),
533 '#rows' => 12,
534 );
535
536 $form['email_activated'] = array(
537 '#type' => 'fieldset',
538 '#title' => t('Account activation'),
539 '#collapsible' => TRUE,
540 '#collapsed' => TRUE,
541 '#description' => t('Enable and edit e-mail messages sent to users upon account activation (when an administrator activates an account of a user who has already registered, on a site where administrative approval is required).') . ' ' . $email_token_help,
542 '#group' => 'email',
543 );
544 $form['email_activated']['user_mail_status_activated_notify'] = array(
545 '#type' => 'checkbox',
546 '#title' => t('Notify user when account is activated.'),
547 '#default_value' => variable_get('user_mail_status_activated_notify', TRUE),
548 );
549 $form['email_activated']['settings'] = array(
550 '#type' => 'container',
551 '#states' => array(
552 // Hide the additional settings when this email is disabled.
553 'invisible' => array(
554 'input[name="user_mail_status_activated_notify"]' => array('checked' => FALSE),
555 ),
556 ),
557 );
558 $form['email_activated']['settings']['user_mail_status_activated_subject'] = array(
559 '#type' => 'textfield',
560 '#title' => t('Subject'),
561 '#default_value' => _user_mail_text('status_activated_subject', NULL, array(), FALSE),
562 '#maxlength' => 180,
563 );
564 $form['email_activated']['settings']['user_mail_status_activated_body'] = array(
565 '#type' => 'textarea',
566 '#title' => t('Body'),
567 '#default_value' => _user_mail_text('status_activated_body', NULL, array(), FALSE),
568 '#rows' => 15,
569 );
570
571 $form['email_blocked'] = array(
572 '#type' => 'fieldset',
573 '#title' => t('Account blocked'),
574 '#collapsible' => TRUE,
575 '#collapsed' => TRUE,
576 '#description' => t('Enable and edit e-mail messages sent to users when their accounts are blocked.') . ' ' . $email_token_help,
577 '#group' => 'email',
578 );
579 $form['email_blocked']['user_mail_status_blocked_notify'] = array(
580 '#type' => 'checkbox',
581 '#title' => t('Notify user when account is blocked.'),
582 '#default_value' => variable_get('user_mail_status_blocked_notify', FALSE),
583 );
584 $form['email_blocked']['settings'] = array(
585 '#type' => 'container',
586 '#states' => array(
587 // Hide the additional settings when the blocked email is disabled.
588 'invisible' => array(
589 'input[name="user_mail_status_blocked_notify"]' => array('checked' => FALSE),
590 ),
591 ),
592 );
593 $form['email_blocked']['settings']['user_mail_status_blocked_subject'] = array(
594 '#type' => 'textfield',
595 '#title' => t('Subject'),
596 '#default_value' => _user_mail_text('status_blocked_subject', NULL, array(), FALSE),
597 '#maxlength' => 180,
598 );
599 $form['email_blocked']['settings']['user_mail_status_blocked_body'] = array(
600 '#type' => 'textarea',
601 '#title' => t('Body'),
602 '#default_value' => _user_mail_text('status_blocked_body', NULL, array(), FALSE),
603 '#rows' => 3,
604 );
605
606 $form['email_cancel_confirm'] = array(
607 '#type' => 'fieldset',
608 '#title' => t('Account cancellation confirmation'),
609 '#collapsible' => TRUE,
610 '#collapsed' => TRUE,
611 '#description' => t('Edit the e-mail messages sent to users when they attempt to cancel their accounts.') . ' ' . $email_token_help,
612 '#group' => 'email',
613 );
614 $form['email_cancel_confirm']['user_mail_cancel_confirm_subject'] = array(
615 '#type' => 'textfield',
616 '#title' => t('Subject'),
617 '#default_value' => _user_mail_text('cancel_confirm_subject', NULL, array(), FALSE),
618 '#maxlength' => 180,
619 );
620 $form['email_cancel_confirm']['user_mail_cancel_confirm_body'] = array(
621 '#type' => 'textarea',
622 '#title' => t('Body'),
623 '#default_value' => _user_mail_text('cancel_confirm_body', NULL, array(), FALSE),
624 '#rows' => 3,
625 );
626
627 $form['email_canceled'] = array(
628 '#type' => 'fieldset',
629 '#title' => t('Account canceled'),
630 '#collapsible' => TRUE,
631 '#collapsed' => TRUE,
632 '#description' => t('Enable and edit e-mail messages sent to users when their accounts are canceled.') . ' ' . $email_token_help,
633 '#group' => 'email',
634 );
635 $form['email_canceled']['user_mail_status_canceled_notify'] = array(
636 '#type' => 'checkbox',
637 '#title' => t('Notify user when account is canceled.'),
638 '#default_value' => variable_get('user_mail_status_canceled_notify', FALSE),
639 );
640 $form['email_canceled']['settings'] = array(
641 '#type' => 'container',
642 '#states' => array(
643 // Hide the settings when the cancel notify checkbox is disabled.
644 'invisible' => array(
645 'input[name="user_mail_status_canceled_notify"]' => array('checked' => FALSE),
646 ),
647 ),
648 );
649 $form['email_canceled']['settings']['user_mail_status_canceled_subject'] = array(
650 '#type' => 'textfield',
651 '#title' => t('Subject'),
652 '#default_value' => _user_mail_text('status_canceled_subject', NULL, array(), FALSE),
653 '#maxlength' => 180,
654 );
655 $form['email_canceled']['settings']['user_mail_status_canceled_body'] = array(
656 '#type' => 'textarea',
657 '#title' => t('Body'),
658 '#default_value' => _user_mail_text('status_canceled_body', NULL, array(), FALSE),
659 '#rows' => 3,
660 );
661
662 return system_settings_form($form);
663 }
664
672 function user_admin_permissions($form, $form_state, $rid = NULL) {
673
674 // Retrieve role names for columns.
675 $role_names = user_roles();
676 if (is_numeric($rid)) {
677 $role_names = array($rid => $role_names[$rid]);
678 }
679 // Fetch permissions for all roles or the one selected role.
680 $role_permissions = user_role_permissions($role_names);
681
682 // Store $role_names for use when saving the data.
683 $form['role_names'] = array(
684 '#type' => 'value',
685 '#value' => $role_names,
686 );
687 // Render role/permission overview:
688 $options = array();
689 $module_info = system_get_info('module');
690 $hide_descriptions = system_admin_compact_mode();
691
692 // Get a list of all the modules implementing a hook_permission() and sort by
693 // display name.
694 $modules = array();
695 foreach (module_implements('permission') as $module) {
696 $modules[$module] = $module_info[$module]['name'];
697 }
698 asort($modules);
699
700 foreach ($modules as $module => $display_name) {
701 if ($permissions = module_invoke($module, 'permission')) {
702 $form['permission'][] = array(
703 '#markup' => $module_info[$module]['name'],
704 '#id' => $module,
705 );
706 foreach ($permissions as $perm => $perm_item) {
707 // Fill in default values for the permission.
708 $perm_item += array(
709 'description' => '',
710 'restrict access' => FALSE,
711 'warning' => !empty($perm_item['restrict access']) ? t('Warning: Give to trusted roles only; this permission has security implications.') : '',
712 );
713 $options[$perm] = '';
714 $form['permission'][$perm] = array(
715 '#type' => 'item',
716 '#markup' => $perm_item['title'],
717 '#description' => theme('user_permission_description', array('permission_item' => $perm_item, 'hide' => $hide_descriptions)),
718 );
719 foreach ($role_names as $rid => $name) {
720 // Builds arrays for checked boxes for each role
721 if (isset($role_permissions[$rid][$perm])) {
722 $status[$rid][] = $perm;
723 }
724 }
725 }
726 }
727 }
728
729 // Have to build checkboxes here after checkbox arrays are built
730 foreach ($role_names as $rid => $name) {
731 $form['checkboxes'][$rid] = array(
732 '#type' => 'checkboxes',
733 '#options' => $options,
734 '#default_value' => isset($status[$rid]) ? $status[$rid] : array(),
735 '#attributes' => array('class' => array('rid-' . $rid)),
736 );
737 $form['role_names'][$rid] = array('#markup' => check_plain($name), '#tree' => TRUE);
738 }
739
740 $form['actions'] = array('#type' => 'actions');
741 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save permissions'));
742
743 $form['#attached']['js'][] = drupal_get_path('module', 'user') . '/user.permissions.js';
744
745 return $form;
746 }
747
753 function user_admin_permissions_submit($form, &$form_state) {
754 foreach ($form_state['values']['role_names'] as $rid => $name) {
755 user_role_change_permissions($rid, $form_state['values'][$rid]);
756 }
757
758 drupal_set_message(t('The changes have been saved.'));
759
760 // Clear the cached pages and blocks.
761 cache_clear_all();
762 }
763
773 function theme_user_admin_permissions($variables) {
774 $form = $variables['form'];
775
776 $roles = user_roles();
777 foreach (element_children($form['permission']) as $key) {
778 $row = array();
779 // Module name
780 if (is_numeric($key)) {
781 $row[] = array('data' => drupal_render($form['permission'][$key]), 'class' => array('module'), 'id' => 'module-' . $form['permission'][$key]['#id'], 'colspan' => count($form['role_names']['#value']) + 1);
782 }
783 else {
784 // Permission row.
785 $row[] = array(
786 'data' => drupal_render($form['permission'][$key]),
787 'class' => array('permission'),
788 );
789 foreach (element_children($form['checkboxes']) as $rid) {
790 $form['checkboxes'][$rid][$key]['#title'] = $roles[$rid] . ': ' . $form['permission'][$key]['#markup'];
791 $form['checkboxes'][$rid][$key]['#title_display'] = 'invisible';
792 $row[] = array('data' => drupal_render($form['checkboxes'][$rid][$key]), 'class' => array('checkbox'));
793 }
794 }
795 $rows[] = $row;
796 }
797 $header[] = (t('Permission'));
798 foreach (element_children($form['role_names']) as $rid) {
799 $header[] = array('data' => drupal_render($form['role_names'][$rid]), 'class' => array('checkbox'));
800 }
801 $output = theme('system_compact_link');
802 $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'permissions')));
803 $output .= drupal_render_children($form);
804 return $output;
805 }
806
822 function theme_user_permission_description($variables) {
823 if (!$variables['hide']) {
824 $description = array();
825 $permission_item = $variables['permission_item'];
826 if (!empty($permission_item['description'])) {
827 $description[] = $permission_item['description'];
828 }
829 if (!empty($permission_item['warning'])) {
830 $description[] = '<em class="permission-warning">' . $permission_item['warning'] . '</em>';
831 }
832 if (!empty($description)) {
833 return implode(' ', $description);
834 }
835 }
836 }
837
844 function user_admin_roles($form, $form_state) {
845 $roles = user_roles();
846
847 $form['roles'] = array(
848 '#tree' => TRUE,
849 );
850 $order = 0;
851 foreach ($roles as $rid => $name) {
852 $form['roles'][$rid]['#role'] = (object) array(
853 'rid' => $rid,
854 'name' => $name,
855 'weight' => $order,
856 );
857 $form['roles'][$rid]['#weight'] = $order;
858 $form['roles'][$rid]['weight'] = array(
859 '#type' => 'textfield',
860 '#title' => t('Weight for @title', array('@title' => $name)),
861 '#title_display' => 'invisible',
862 '#size' => 4,
863 '#default_value' => $order,
864 '#attributes' => array('class' => array('role-weight')),
865 );
866 $order++;
867 }
868
869 $form['name'] = array(
870 '#type' => 'textfield',
871 '#title' => t('Name'),
872 '#title_display' => 'invisible',
873 '#size' => 32,
874 '#maxlength' => 64,
875 );
876 $form['add'] = array(
877 '#type' => 'submit',
878 '#value' => t('Add role'),
879 '#validate' => array('user_admin_role_validate'),
880 '#submit' => array('user_admin_role_submit'),
881 );
882 $form['actions'] = array('#type' => 'actions');
883 $form['actions']['submit'] = array(
884 '#type' => 'submit',
885 '#value' => t('Save order'),
886 '#submit' => array('user_admin_roles_order_submit'),
887 );
888
889 return $form;
890 }
891
895 function user_admin_roles_order_submit($form, &$form_state) {
896 foreach ($form_state['values']['roles'] as $rid => $role_values) {
897 $role = $form['roles'][$rid]['#role'];
898 $role->weight = $role_values['weight'];
899 user_role_save($role);
900 }
901 drupal_set_message(t('The role settings have been updated.'));
902 }
903
913 function theme_user_admin_roles($variables) {
914 $form = $variables['form'];
915
916 $header = array(t('Name'), t('Weight'), array('data' => t('Operations'), 'colspan' => 2));
917 foreach (element_children($form['roles']) as $rid) {
918 $name = $form['roles'][$rid]['#role']->name;
919 $row = array();
920 if (in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
921 $row[] = t('@name <em>(locked)</em>', array('@name' => $name));
922 $row[] = drupal_render($form['roles'][$rid]['weight']);
923 $row[] = '';
924 $row[] = l(t('edit permissions'), 'admin/people/permissions/' . $rid);
925 }
926 else {
927 $row[] = check_plain($name);
928 $row[] = drupal_render($form['roles'][$rid]['weight']);
929 $row[] = l(t('edit role'), 'admin/people/permissions/roles/edit/' . $rid);
930 $row[] = l(t('edit permissions'), 'admin/people/permissions/' . $rid);
931 }
932 $rows[] = array('data' => $row, 'class' => array('draggable'));
933 }
934 $rows[] = array(array('data' => drupal_render($form['name']) . drupal_render($form['add']), 'colspan' => 4, 'class' => 'edit-name'));
935
936 drupal_add_tabledrag('user-roles', 'order', 'sibling', 'role-weight');
937
938 $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'user-roles')));
939 $output .= drupal_render_children($form);
940
941 return $output;
942 }
943
951 function user_admin_role($form, $form_state, $role) {
952 if ($role->rid == DRUPAL_ANONYMOUS_RID || $role->rid == DRUPAL_AUTHENTICATED_RID) {
953 drupal_goto('admin/people/permissions/roles');
954 }
955
956 // Display the edit role form.
957 $form['name'] = array(
958 '#type' => 'textfield',
959 '#title' => t('Role name'),
960 '#default_value' => $role->name,
961 '#size' => 30,
962 '#required' => TRUE,
963 '#maxlength' => 64,
964 '#description' => t('The name for this role. Example: "moderator", "editorial board", "site architect".'),
965 );
966 $form['rid'] = array(
967 '#type' => 'value',
968 '#value' => $role->rid,
969 );
970 $form['weight'] = array(
971 '#type' => 'value',
972 '#value' => $role->weight,
973 );
974 $form['actions'] = array('#type' => 'actions');
975 $form['actions']['submit'] = array(
976 '#type' => 'submit',
977 '#value' => t('Save role'),
978 );
979 $form['actions']['delete'] = array(
980 '#type' => 'submit',
981 '#value' => t('Delete role'),
982 '#submit' => array('user_admin_role_delete_submit'),
983 );
984
985 return $form;
986 }
987
991 function user_admin_role_validate($form, &$form_state) {
992 if (!empty($form_state['values']['name'])) {
993 if ($form_state['values']['op'] == t('Save role')) {
994 $role = user_role_load_by_name($form_state['values']['name']);
995 if ($role && $role->rid != $form_state['values']['rid']) {
996 form_set_error('name', t('The role name %name already exists. Choose another role name.', array('%name' => $form_state['values']['name'])));
997 }
998 }
999 elseif ($form_state['values']['op'] == t('Add role')) {
1000 if (user_role_load_by_name($form_state['values']['name'])) {
1001 form_set_error('name', t('The role name %name already exists. Choose another role name.', array('%name' => $form_state['values']['name'])));
1002 }
1003 }
1004 }
1005 else {
1006 form_set_error('name', t('You must specify a valid role name.'));
1007 }
1008 }
1009
1013 function user_admin_role_submit($form, &$form_state) {
1014 $role = (object) $form_state['values'];
1015 if ($form_state['values']['op'] == t('Save role')) {
1016 user_role_save($role);
1017 drupal_set_message(t('The role has been renamed.'));
1018 }
1019 elseif ($form_state['values']['op'] == t('Add role')) {
1020 user_role_save($role);
1021 drupal_set_message(t('The role has been added.'));
1022 }
1023 $form_state['redirect'] = 'admin/people/permissions/roles';
1024 return;
1025 }
1026
1030 function user_admin_role_delete_submit($form, &$form_state) {
1031 $form_state['redirect'] = 'admin/people/permissions/roles/delete/' . $form_state['values']['rid'];
1032 }
1033
1037 function user_admin_role_delete_confirm($form, &$form_state, $role) {
1038 $form['rid'] = array(
1039 '#type' => 'value',
1040 '#value' => $role->rid,
1041 );
1042 return confirm_form($form, t('Are you sure you want to delete the role %name ?', array('%name' => $role->name)), 'admin/people/permissions/roles', t('This action cannot be undone.'), t('Delete'));
1043 }
1044
1048 function user_admin_role_delete_confirm_submit($form, &$form_state) {
1049 user_role_delete((int) $form_state['values']['rid']);
1050 drupal_set_message(t('The role has been deleted.'));
1051 $form_state['redirect'] = 'admin/people/permissions/roles';
1052 }
1053
USER_REGISTER_ADMINISTRATORS_ONLY
const USER_REGISTER_ADMINISTRATORS_ONLY
Definition: user.module:21
user_filter_form
user_filter_form()
Definition: user.admin.inc:49
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
theme_user_admin_roles
theme_user_admin_roles($variables)
Definition: user.admin.inc:913
file_default_scheme
file_default_scheme()
Definition: file.inc:256
$op
$op
Definition: update.php:404
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
FILE_CREATE_DIRECTORY
const FILE_CREATE_DIRECTORY
Definition: file.inc:41
l
l($text, $path, array $options=array())
Definition: common.inc:2432
user_role_delete
user_role_delete($role)
Definition: user.module:2992
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
user_admin_role_validate
user_admin_role_validate($form, &$form_state)
Definition: user.admin.inc:991
user_filter_form_submit
user_filter_form_submit($form, &$form_state)
Definition: user.admin.inc:124
user_admin_account_validate
user_admin_account_validate($form, &$form_state)
Definition: user.admin.inc:267
user_filters
user_filters()
Definition: user.module:3392
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
$module
print $module
Definition: search-results.tpl.php:28
system_admin_compact_mode
system_admin_compact_mode()
Definition: system.module:2902
theme_user_permission_description
theme_user_permission_description($variables)
Definition: user.admin.inc:822
$name
print $name
Definition: profile-listing.tpl.php:43
$header
print $header
Definition: forum-topic-list.tpl.php:42
user_admin_settings
user_admin_settings()
Definition: user.admin.inc:280
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
user_roles
user_roles($membersonly=FALSE, $permission=NULL)
Definition: user.module:2871
module_exists
module_exists($module)
Definition: module.inc:274
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
user_admin_account_submit
user_admin_account_submit($form, &$form_state)
Definition: user.admin.inc:248
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
user_admin_role_submit
user_admin_role_submit($form, &$form_state)
Definition: user.admin.inc:1013
drupal_add_library
drupal_add_library($module, $name, $every_page=NULL)
Definition: common.inc:4694
DRUPAL_ANONYMOUS_RID
const DRUPAL_ANONYMOUS_RID
Definition: bootstrap.inc:162
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
system_get_info
system_get_info($type, $name=NULL)
Definition: system.module:2338
user_build_filter_query
user_build_filter_query(SelectQuery $query)
Definition: user.module:3443
theme_user_admin_permissions
theme_user_admin_permissions($variables)
Definition: user.admin.inc:773
user_role_permissions
user_role_permissions($roles=array())
Definition: user.module:743
$value
print $value
Definition: user-profile-item.tpl.php:26
user_role_change_permissions
user_role_change_permissions($rid, array $permissions=array())
Definition: user.module:3076
DRUPAL_AUTHENTICATED_RID
const DRUPAL_AUTHENTICATED_RID
Definition: bootstrap.inc:167
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
$output
$output
Definition: authorize.php:93
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
image_style_options
image_style_options($include_empty=TRUE, $output=CHECK_PLAIN)
Definition: image.module:781
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
user_admin_role_delete_submit
user_admin_role_delete_submit($form, &$form_state)
Definition: user.admin.inc:1030
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
user_admin_role_delete_confirm_submit
user_admin_role_delete_confirm_submit($form, &$form_state)
Definition: user.admin.inc:1048
_user_mail_text
_user_mail_text($key, $language=NULL, $variables=array(), $replace=TRUE)
Definition: user.module:2671
user_role_save
user_role_save($role)
Definition: user.module:2955
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
USER_REGISTER_VISITORS
const USER_REGISTER_VISITORS
Definition: user.module:26
$row
$row
Definition: block-admin-display-form.tpl.php:47
user_admin_role
user_admin_role($form, $form_state, $role)
Definition: user.admin.inc:951
user_admin_roles
user_admin_roles($form, $form_state)
Definition: user.admin.inc:844
file_prepare_directory
file_prepare_directory(&$directory, $options=FILE_MODIFY_PERMISSIONS)
Definition: file.inc:430
user_admin_roles_order_submit
user_admin_roles_order_submit($form, &$form_state)
Definition: user.admin.inc:895
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
user_role_load_by_name
user_role_load_by_name($role_name)
Definition: user.module:2935
user_admin_permissions
user_admin_permissions($form, $form_state, $rid=NULL)
Definition: user.admin.inc:672
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
user_admin_role_delete_confirm
user_admin_role_delete_confirm($form, &$form_state, $role)
Definition: user.admin.inc:1037
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
user_admin
user_admin($callback_arg= '')
Definition: user.admin.inc:23
system_settings_form
system_settings_form($form)
Definition: system.module:2755
form_options_flatten
form_options_flatten($array)
Definition: form.inc:2548
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL
const USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL
Definition: user.module:32
user_admin_account
user_admin_account()
Definition: user.admin.inc:163
user_cancel_methods
user_cancel_methods()
Definition: user.pages.inc:471
user_admin_permissions_submit
user_admin_permissions_submit($form, &$form_state)
Definition: user.admin.inc:753
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/xmlrpc_example/xmlrpc_example.module Source File

  • examples
  • xmlrpc_example
xmlrpc_example.module
Go to the documentation of this file.
1 <?php
2
30 // This is the common part of the module, implementing all the code required
31 // for the client and the server part (most of this code is UI related). The
32 // menu definition is the only part shared in this implementation.
33 //
39 function xmlrpc_example_menu() {
40 $items['examples/xmlrpc'] = array(
41 'title' => 'XML-RPC Example',
42 'description' => 'Information about the XML-RPC example',
43 'page callback' => 'xmlrpc_example_info',
44 'access callback' => TRUE,
45 );
46 // This is the server configuration form menu entry. This form can be used to
47 // configure the settings of the exposed services. An XML-RPC server does not
48 // require a configuration form, and has been included here as an example.
49 $items['examples/xmlrpc/server'] = array(
50 'title' => 'XML-RPC Server configuration',
51 'description' => 'Server configuration form',
52 'page callback' => 'drupal_get_form',
53 'page arguments' => array('xmlrpc_example_server_form'),
54 'access callback' => TRUE,
55 'weight' => 0,
56 );
57 // This is the client form menu entry. This form is used to allow user
58 // interaction with the services, but again, user interface is not required
59 // to create an XML-RPC client with Drupal.
60 $items['examples/xmlrpc/client'] = array(
61 'title' => 'XML-RPC Client form',
62 'description' => 'Demonstrates client side XML-RPC calls with Drupal',
63 'page callback' => 'drupal_get_form',
64 'page arguments' => array('xmlrpc_example_client_form'),
65 'access callback' => TRUE,
66 'weight' => 1,
67 );
68 // This part is completely optional. It allows the modification of services
69 // defined by this or other modules. This configuration form is used to
70 // enable the hook_xmlrpc_alter API and alter current existing services.
71 $items['examples/xmlrpc/alter'] = array(
72 'title' => 'XML-RPC Alterations',
73 'description' => 'Demonstrates how to alter defined XML-RPC services',
74 'page callback' => 'drupal_get_form',
75 'page arguments' => array('xmlrpc_example_alter_form'),
76 'access callback' => TRUE,
77 'weight' => 2,
78 );
79 return $items;
80 }
81
85 function xmlrpc_example_info() {
86 $server = url($GLOBALS['base_url'] . '/xmlrpc.php', array('external' => TRUE));
87
88 $options = array(
89 'system.listMethods' => array(),
90 );
91 // Make the xmlrpc request and process the results.
92 $supported_methods = xmlrpc($server, $options);
93 if ($supported_methods === FALSE) {
94 drupal_set_message(t('Error return from xmlrpc(): Error: @errno, Message: @message', array('@errno' => xmlrpc_errno(), '@message' => xmlrpc_error_msg())));
95 }
96
97 return array(
98 'basic' => array(
99 '#markup' => t('This XML-RPC example presents code that shows <ul><li><a href="!server">XML-RPC server code</a></li><li><a href="!client">XML-RPC client code</a></li><li>and <a href="!alter">an example hook_xmlrpc_alter() call</a></li></ul>',
100 array(
101 '!server' => url('examples/xmlrpc/server'),
102 '!client' => url('examples/xmlrpc/client'),
103 '!alter' => url('examples/xmlrpc/alter'),
104 )
105 ),
106 ),
107 'method_array' => array(
108 '#markup' => theme(
109 'item_list',
110 array(
111 'title' => t('These methods are supported by !server',
112 array('!server' => $server)
113 ),
114 'items' => $supported_methods,
115 )
116 ),
117 ),
118 );
119 }
120
121 // This is the server part of the module, implementing a simple and little
122 // server with just two simple services. The server is divided in two
123 // different parts: the XML-RPC implementation (required) and a webform
124 // interface (optional) to configure some settings in the server side.
125 //
126 // The XMLRPC server will define two different services:
127 //
128 // - subtract: perform the subtraction of two numbers. The minimum and maximum
129 // values returned by the server can be configured in the server configuration
130 // form.
131 // - add: perform the addition of two numbers. The minimum and maximum values
132 // returned by the server can be configured in the server configuration form.
133 //
134 // If the result value for the operation is over the maximum limit, a custom
135 // error number 10001 is returned. This is an arbitrary number and could be any
136 // number.
137 //
138 // If the result value for the operation is below the minimum limit, a custom
139 // error number 10002 is returned. Again, this value is arbitrary and could be
140 // any other number. Client applications must know the meaning of the error
141 // numbers returned by the server.
142 //
143 // The following code is the XML-RPC implementation of the server part.
144 // The first step is to define the methods. This methods should be associated
145 // to callbacks that will be defined later.
146 //
172 function xmlrpc_example_xmlrpc() {
173 $methods[] = array(
174 // First argument is the method name.
175 'xmlrpc_example.add',
176 // Callback to execute when this method is requested.
177 '_xmlrpc_example_server_add',
178 // An array defines the types of output and input values for this method.
179 array(
180 // The first value is the return type, an integer in this case.
181 'int',
182 // First operand is an integer.
183 'int',
184 // Second operatnd is an integer.
185 'int',
186 ),
187 // Include a little description that is shown when XML-RPC server is
188 // requested for the implemented methods list.
189 // Method description.
190 t('Returns the sum of the two arguments.'),
191 );
192 // The subtract method is similar to the addition, only the method name,
193 // callback and description are different.
194 $methods[] = array(
195 'xmlrpc_example.subtract',
196 '_xmlrpc_example_server_subtract',
197 array('int', 'int', 'int'),
198 t('Return difference of the two arguments.'),
199 );
200
201 return $methods;
202 }
203
204 // The following code for the server is optional if the callbacks already exist.
205 // A server may implement methods associated to callbacks like node_load(),
206 // variable_get() or any other existing function (php functions as well).
207 //
208 // If the callbacks associated to the methods don't exist they must be
209 // created. This implementation requires two specific callbacks:
210 // - _xmlrpc_example_server_add()
211 // - _xmlrpc_example_server_subtract()
212 //
213 //
230 function _xmlrpc_example_server_add($num1, $num2) {
231 $sum = $num1 + $num2;
232 // If result is not within maximum and minimum limits,
233 // return corresponding error.
234 $max = variable_get('xmlrpc_example_server_max', 10);
235 $min = variable_get('xmlrpc_example_server_min', 0);
236 if ($sum > $max) {
237 return xmlrpc_error(10001, t('Result is over the upper limit (@max) defined by the server.', array('@max' => $max)));
238 }
239 if ($sum < $min) {
240 return xmlrpc_error(10002, t('Result is below the lower limit defined by the server (@min).', array('@min' => $min)));
241 }
242 // Otherwise return the result.
243 return $sum;
244 }
245
263 function _xmlrpc_example_server_subtract($num1, $num2) {
264 $diference = $num1 - $num2;
265 $max = variable_get('xmlrpc_example_server_max', 10);
266 $min = variable_get('xmlrpc_example_server_min', 0);
267
268 // If result is not within maximum and minimum limits,
269 // return corresponding error.
270 if ($diference > $max) {
271 return xmlrpc_error(10001, t('Result is above the upper limit (@max) defined by the server.', array('@max' => $max)));
272 }
273 if ($diference < $min) {
274 return xmlrpc_error(10002, t('Result is below the lower limit (@min) defined by the server.', array('@min' => $min)));
275 }
276 // Otherwise return the result.
277 return $diference;
278 }
279
280 // User interface for the XML-RPC Server part.
281 // A server does not require an interface at all. In this implementation we
282 // use a server configuration form to set the limits available for the addition
283 // and subtraction operations.
284 //
291 function xmlrpc_example_server_form() {
292 $form = array();
293 $form['explanation'] = array(
294 '#markup' => '<div>' . t('This is the XML-RPC server configuration page.<br />Here you may define the maximum and minimum values for the addition or subtraction exposed services.<br />') . '</div>',
295 );
296 $form['xmlrpc_example_server_min'] = array(
297 '#type' => 'textfield',
298 '#title' => t('Enter the minimum value returned by the subtraction or addition methods'),
299 '#description' => t('If the result of the operation is lower than this value, a custom XML-RPC error will be returned: 10002.'),
300 '#default_value' => variable_get('xmlrpc_example_server_min', 0),
301 '#size' => 5,
302 '#required' => TRUE,
303 );
304 $form['xmlrpc_example_server_max'] = array(
305 '#type' => 'textfield',
306 '#title' => t('Enter the maximum value returned by sub or add methods'),
307 '#description' => t('if the result of the operation is bigger than this value, a custom XML-RPC error will be returned: 10001.'),
308 '#default_value' => variable_get('xmlrpc_example_server_max', 10),
309 '#size' => 5,
310 '#required' => TRUE,
311 );
312 $form['info'] = array(
313 '#type' => 'markup',
314 '#markup' => '<div>' . t('Use the <a href="!link">XML-RPC Client example form</a> to experiment', array('!link' => url('examples/xmlrpc/client'))),
315 );
316 if (variable_get('xmlrpc_example_alter_enabled', FALSE)) {
317 $form['overridden'] = array(
318 '#type' => 'markup',
319 '#markup' => '<div><strong>' . t('Just a note of warning: The <a href="!link">alter form</a> has been used to disable the limits, so you may want to turn that off if you do not want it.', array('!link' => url('examples/xmlrpc/alter'))) . '</strong></div>',
320 );
321 }
322 return system_settings_form($form);
323 }
324
325
326 // The server part of the module ends here.
327 //
328 // This is the client part of the module. If defines a form with two input
329 // fields to call xmlrpc_example.add or xmlrpc_example.subtract methods on this
330 // host. Please note that having a user interface to query an XML-RPC service is
331 // not required. A method can be requested to a server using the xmlrpc()
332 // function directly. We have included an user interface to make the testing
333 // easier.
334 //
335 // The client user interface part of the module starts here.
336 //
343 function xmlrpc_example_client_form() {
344 $form = array();
345 $form['explanation'] = array(
346 '#markup' => '<div>' . t('This example demonstrates how to make XML-RPC calls with Drupal. <br />The "Request methods" button makes a request to the server and asks for the available list of methods, as a service discovery request. <br/>The "Add integers" and "Subtract integers" use the xmlrpc() function to act as a client, calling the XML-RPC server defined in this same example for some defined methods.<br />An XML-RPC error will result if the result in the addition or subtraction requested is out of bounds defined by the server. These error numbers are defined by the server. <br />The "Add and Subtract" button performs a multicall operation on the XML-RPC server: several requests in a single XML-RPC call.<br />') . '</div>',
347 );
348 // We are going to call add and subtract methods, and
349 // they work with integer values.
350 $form['num1'] = array(
351 '#type' => 'textfield',
352 '#title' => t('Enter an integer'),
353 '#default_value' => 2,
354 '#size' => 5,
355 '#required' => TRUE,
356 );
357 $form['num2'] = array(
358 '#type' => 'textfield',
359 '#title' => t('Enter a second integer'),
360 '#default_value' => 2,
361 '#size' => 5,
362 '#required' => TRUE,
363 );
364 // Include several buttons, each of them calling a different method.
365 // This button submits a XML-RPC call to the system.listMethods method.
366 $form['information'] = array(
367 '#type' => 'submit',
368 '#value' => t('Request methods'),
369 '#submit' => array('xmlrpc_example_client_request_methods_submit'),
370 );
371 // This button submits a XML-RPC call to the xmlrpc_example.add method.
372 $form['add'] = array(
373 '#type' => 'submit',
374 '#value' => t('Add the integers'),
375 '#submit' => array('xmlrpc_example_client_add_submit'),
376 );
377 // This button submits a XML-RPC call to the xmlrpc_example.subtract method.
378 $form['subtract'] = array(
379 '#type' => 'submit',
380 '#value' => t('Subtract the integers'),
381 '#submit' => array('xmlrpc_example_client_subtract_submit'),
382 );
383 // This button submits a XML-RPC call to the system.multicall method.
384 $form['add_subtract'] = array(
385 '#type' => 'submit',
386 '#value' => t('Add and Subtract'),
387 '#submit' => array('xmlrpc_example_client_multicall_submit'),
388 );
389 if (variable_get('xmlrpc_example_alter_enabled', FALSE)) {
390 $form['overridden'] = array(
391 '#type' => 'markup',
392 '#markup' => '<div><strong>' . t('Just a note of warning: The <a href="!link">alter form</a> has been used to disable the limits, so you may want to turn that off if you do not want it.', array('!link' => url('examples/xmlrpc/alter'))) . '</strong></div>',
393 );
394 }
395 return $form;
396 }
397
417 function xmlrpc_example_client_request_methods_submit($form, &$form_state) {
418 // First define the endpoint of the XML-RPC service, in this case this is our
419 // own server.
420 $server = url($GLOBALS['base_url'] . '/xmlrpc.php', array('external' => TRUE));
421 // Then we should define the method to call. xmlrpc() requires that all the
422 // information related to the called method be passed as an array in the form
423 // of 'method_name' => arguments_array
424 $options = array(
425 'system.listMethods' => array(),
426 );
427 // Make the xmlrpc request and process the results.
428 $result = xmlrpc($server, $options);
429 if ($result === FALSE) {
430 drupal_set_message(
431 t('Error return from xmlrpc(): Error: @errno, Message: @message',
432 array('@errno' => xmlrpc_errno(), '@message' => xmlrpc_error_msg())),
433 'error'
434 );
435 }
436 else {
437 drupal_set_message(
438 t('The XML-RPC server returned this response: <pre>@response</pre>',
439 array('@response' => print_r($result, TRUE)))
440 );
441 }
442 }
443
459 function xmlrpc_example_client_add_submit($form, &$form_state) {
460 // First define the endpoint of the XML-RPC service, in this case is our
461 // own server.
462 $server = url($GLOBALS['base_url'] . '/xmlrpc.php', array('external' => TRUE));
463 // Then we should define the method to call. xmlrpc() requires that all the
464 // information related to the called method is passed as an array in the form
465 // of 'method_name' => arguments_array
466 $options = array(
467 'xmlrpc_example.add' => array(
468 (int) $form_state['values']['num1'],
469 (int) $form_state['values']['num2'],
470 ),
471 );
472 // Make the xmlrpc request and process the results.
473 $result = xmlrpc($server, $options);
474 if ($result === FALSE) {
475 drupal_set_message(
476 t('Error return from xmlrpc(): Error: @errno, Message: @message',
477 array('@errno' => xmlrpc_errno(), '@message' => xmlrpc_error_msg())),
478 'error'
479 );
480 }
481 else {
482 drupal_set_message(
483 t('The XML-RPC server returned this response: @response',
484 array('@response' => print_r($result, TRUE)))
485 );
486 }
487 }
488
505 function xmlrpc_example_client_subtract_submit($form, &$form_state) {
506 $server = url($GLOBALS['base_url'] . '/xmlrpc.php', array('external' => TRUE));
507 $options = array(
508 'xmlrpc_example.subtract' => array(
509 (int) $form_state['values']['num1'],
510 (int) $form_state['values']['num2'],
511 ),
512 );
513 // Make the xmlrpc request and process the results.
514 $result = xmlrpc($server, $options);
515 if ($result === FALSE) {
516 drupal_set_message(
517 t('Error return from xmlrpc(): Error: @errno, Message: @message',
518 array('@errno' => xmlrpc_errno(), '@message' => xmlrpc_error_msg())),
519 'error'
520 );
521 }
522 else {
523 drupal_set_message(
524 t('The XML-RPC server returned this response: @response',
525 array('@response' => print_r($result, TRUE)))
526 );
527 }
528 }
529
548 function xmlrpc_example_client_multicall_submit($form, &$form_state) {
549 $server = url($GLOBALS['base_url'] . '/xmlrpc.php', array('external' => TRUE));
550
551 /*
552 * Drupal's built-in xmlrpc server supports the system.multicall method.
553 *
554 * To make a multicall request, the main invoked method should be the
555 * function 'system.multicall', and the arguments to make this call must be
556 * defined as an array of single method calls, being the array keys the
557 * service methods to be called, and the array elements the method arguments.
558 *
559 * See the code below this comment as example.
560 */
561
562 // Build an array of several calls, Drupal's xmlrpc built-in support will
563 // construct the correct system.multicall request for the server.
564 $options = array(
565 'xmlrpc_example.add' => array(
566 (int) $form_state['values']['num1'],
567 (int) $form_state['values']['num2'],
568 ),
569 'xmlrpc_example.subtract' => array(
570 (int) $form_state['values']['num1'],
571 (int) $form_state['values']['num2'],
572 ),
573 );
574 // Make the xmlrpc request and process the results.
575 $result = xmlrpc($server, $options);
576
577 if ($result === FALSE) {
578 drupal_set_message(
579 t('Error return from xmlrpc(): Error: @errno, Message: @message',
580 array('@errno' => xmlrpc_errno(), '@message' => xmlrpc_error_msg()))
581 );
582 }
583 else {
584 drupal_set_message(
585 t('The XML-RPC server returned this response: <pre>@response</pre>',
586 array('@response' => print_r($result, TRUE)))
587 );
588 }
589 }
590
591 // The client part of the module ends here.
592 //
593 // The alteration part of the module starts here. hook_xmlrpc_alter() is
594 // useful when you want to extend, limit or alter methods defined by other
595 // modules. This part is not required to have an XML-RPC server or client
596 // working, but is useful to understand what can we do using current xmlrpc
597 // API provided by drupal.
598 //
599 // This code can be defined in other module to alter the methods exposed by
600 // this xmlrpc demonstration server, or can be used to alter methods defined
601 // by other modules implementing hook_xmlrpc()
602 //
603 // As with the rest of the example module, an user interface is not required to
604 // make use of this hook. A configuration form is included to enable/disable
605 // this functionality, but this part is optional if you want to implement
606 // hook_xmlrpc_alter()
607 //
608 // This is the XML-RPC code for the alteration part. It will check if an option
609 // to enable the functionality is enabled and then alter it. We alter the
610 // 'xmlrpc_example.add' and 'xmlrpc_example.subtract' methods, changing the
611 // associated callback with custom functions. The modified methods (with
612 // new callbacks associated) will perform the addition or subtraction of the
613 // integer inputs, but will never check for limits nor return errors.
622 function xmlrpc_example_xmlrpc_alter(&$methods) {
623
624 // Only perform alterations if instructed to do so.
625 if (!variable_get('xmlrpc_example_alter_enabled', 0)) {
626 return;
627 }
628 // Loop all defined methods (other modules may include additional methods).
629 foreach ($methods as $index => $method) {
630 // First element in the method array is the method name.
631 if ($method[0] == 'xmlrpc_example.add') {
632 // Replace current callback with custom callback
633 // (second argument of the array).
634 $methods[$index][1] = '_xmlrpc_example_alter_add';
635 }
636 // Do the same for the substraction method.
637 if ($method[0] == 'xmlrpc_example.subtract') {
638 $methods[$index][1] = '_xmlrpc_example_alter_subtract';
639 }
640 }
641 }
642
643 // Now we define the custom callbacks replacing the original defined by the
644 // altered methods: xmlrpc_example.add and _xmlrpc_example.subtract. These
645 // new callbacks will not check if the result of the operation is within the
646 // limits defined by the server and will always return value of the operation.
660 function _xmlrpc_example_alter_add($num1, $num2) {
661 return $num1 + $num2;
662 }
663
677 function _xmlrpc_example_alter_subtract($num1, $num2) {
678 return $num1 - $num2;
679 }
680
681
682 // Our implementation of hook_xmlrpc_alter will work only if a system variable
683 // is set to true, and we need a configuration form to enable/disable this
684 // 'feature'. This is the user interface to enable or disable the
685 // hook_xmlrpc_alter operations.
689 function xmlrpc_example_alter_form() {
690 $form = array();
691 $form['explanation'] = array(
692 '#markup' => '<div>' . t('This is a configuration form to enable the alteration of XML-RPC methods using hook_xmlrpc_alter.<br />hook_xmlrpc_alter() can be used to alter the current defined methods by other modules. In this case as demonstration, we will overide current add and subtraction methods with others not being limited. Remember that this hook is optional and is not required to create XMLRPC services.<br />') . '</div>',
693 );
694 $form['xmlrpc_example_alter_enabled'] = array(
695 '#type' => 'checkbox',
696 '#title' => t('Overide current xmlrpc_example.add and xmlrpc_example.subtraction methods'),
697 '#description' => t('If this checkbox is enabled, the default methods will be replaced with custom methods that ignore the XML-RPC server maximum and minimum restrictions.'),
698 '#default_value' => variable_get('xmlrpc_example_alter_enabled', 0),
699 );
700 $form['info'] = array(
701 '#markup' => '<div>' . t('Use the <a href="!link">client submission form</a> to see the results of checking this checkbox', array('!link' => url('examples/xmlrpc/client'))) . '</div>',
702 );
703 return system_settings_form($form);
704 }
xmlrpc_example_client_request_methods_submit
xmlrpc_example_client_request_methods_submit($form, &$form_state)
Definition: xmlrpc_example.module:417
xmlrpc_example_menu
xmlrpc_example_menu()
Definition: xmlrpc_example.module:39
xmlrpc_example_server_form
xmlrpc_example_server_form()
Definition: xmlrpc_example.module:291
xmlrpc_example_xmlrpc_alter
xmlrpc_example_xmlrpc_alter(&$methods)
Definition: xmlrpc_example.module:622
xmlrpc_error_msg
xmlrpc_error_msg()
Definition: xmlrpc.inc:612
xmlrpc_example_client_multicall_submit
xmlrpc_example_client_multicall_submit($form, &$form_state)
Definition: xmlrpc_example.module:548
xmlrpc_example_alter_form
xmlrpc_example_alter_form()
Definition: xmlrpc_example.module:689
_xmlrpc_example_server_subtract
_xmlrpc_example_server_subtract($num1, $num2)
Definition: xmlrpc_example.module:263
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
xmlrpc
xmlrpc($url, $args, $options=array())
Definition: common.inc:8081
xmlrpc_example_client_add_submit
xmlrpc_example_client_add_submit($form, &$form_state)
Definition: xmlrpc_example.module:459
_xmlrpc_example_alter_subtract
_xmlrpc_example_alter_subtract($num1, $num2)
Definition: xmlrpc_example.module:677
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
xmlrpc_error
xmlrpc_error($code=NULL, $message=NULL, $reset=FALSE)
Definition: xmlrpc.inc:404
xmlrpc_example_info
xmlrpc_example_info()
Definition: xmlrpc_example.module:85
xmlrpc_example_client_form
xmlrpc_example_client_form()
Definition: xmlrpc_example.module:343
xmlrpc_example_xmlrpc
xmlrpc_example_xmlrpc()
Definition: xmlrpc_example.module:172
_xmlrpc_example_server_add
_xmlrpc_example_server_add($num1, $num2)
Definition: xmlrpc_example.module:230
_xmlrpc_example_alter_add
_xmlrpc_example_alter_add($num1, $num2)
Definition: xmlrpc_example.module:660
xmlrpc_example_client_subtract_submit
xmlrpc_example_client_subtract_submit($form, &$form_state)
Definition: xmlrpc_example.module:505
xmlrpc_errno
xmlrpc_errno()
Definition: xmlrpc.inc:604
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
system_settings_form
system_settings_form($form)
Definition: system.module:2755
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.admin.inc Source File

  • modules
  • system
system.admin.inc
Go to the documentation of this file.
1 <?php
2
11 function system_admin_config_page() {
12 // Check for status report errors.
13 if (system_status(TRUE) && user_access('administer site configuration')) {
14 drupal_set_message(t('One or more problems were detected with your Drupal installation. Check the <a href="@status">status report</a> for more information.', array('@status' => url('admin/reports/status'))), 'error');
15 }
16 $blocks = array();
17 if ($admin = db_query("SELECT menu_name, mlid FROM {menu_links} WHERE link_path = 'admin/config' AND module = 'system'")->fetchAssoc()) {
18 $result = db_query("
19 SELECT m.*, ml.*
20 FROM {menu_links} ml
21 INNER JOIN {menu_router} m ON ml.router_path = m.path
22 WHERE ml.link_path <> 'admin/help' AND menu_name = :menu_name AND ml.plid = :mlid AND hidden = 0", $admin, array('fetch' => PDO::FETCH_ASSOC));
23 foreach ($result as $item) {
24 _menu_link_translate($item);
25 if (!$item['access']) {
26 continue;
27 }
28 // The link description, either derived from 'description' in hook_menu()
29 // or customized via menu module is used as title attribute.
30 if (!empty($item['localized_options']['attributes']['title'])) {
31 $item['description'] = $item['localized_options']['attributes']['title'];
32 unset($item['localized_options']['attributes']['title']);
33 }
34 $block = $item;
35 $block['content'] = '';
36 $block['content'] .= theme('admin_block_content', array('content' => system_admin_menu_block($item)));
37 if (!empty($block['content'])) {
38 $block['show'] = TRUE;
39 }
40
41 // Prepare for sorting as in function _menu_tree_check_access().
42 // The weight is offset so it is always positive, with a uniform 5-digits.
43 $blocks[(50000 + $item['weight']) . ' ' . $item['title'] . ' ' . $item['mlid']] = $block;
44 }
45 }
46 if ($blocks) {
47 ksort($blocks);
48 return theme('admin_page', array('blocks' => $blocks));
49 }
50 else {
51 return t('You do not have any administrative items.');
52 }
53 }
54
66 function system_admin_menu_block_page() {
67 $item = menu_get_item();
68 if ($content = system_admin_menu_block($item)) {
69 $output = theme('admin_block_content', array('content' => $content));
70 }
71 else {
72 $output = t('You do not have any administrative items.');
73 }
74 return $output;
75 }
76
80 function system_admin_index() {
81 $module_info = system_get_info('module');
82 foreach ($module_info as $module => $info) {
83 $module_info[$module] = new stdClass();
84 $module_info[$module]->info = $info;
85 }
86 uasort($module_info, 'system_sort_modules_by_info_name');
87 $menu_items = array();
88
89 foreach ($module_info as $module => $info) {
90 // Only display a section if there are any available tasks.
91 if ($admin_tasks = system_get_module_admin_tasks($module, $info->info)) {
92 // Sort links by title.
93 uasort($admin_tasks, 'drupal_sort_title');
94 // Move 'Configure permissions' links to the bottom of each section.
95 $permission_key = "admin/people/permissions#module-$module";
96 if (isset($admin_tasks[$permission_key])) {
97 $permission_task = $admin_tasks[$permission_key];
98 unset($admin_tasks[$permission_key]);
99 $admin_tasks[$permission_key] = $permission_task;
100 }
101
102 $menu_items[$info->info['name']] = array($info->info['description'], $admin_tasks);
103 }
104 }
105 return theme('system_admin_index', array('menu_items' => $menu_items));
106 }
107
119 function system_settings_overview() {
120 // Check database setup if necessary
121 if (function_exists('db_check_setup') && empty($_POST)) {
122 db_check_setup();
123 }
124
125 $item = menu_get_item('admin/config');
126 $content = system_admin_menu_block($item);
127
128 $output = theme('admin_block_content', array('content' => $content));
129
130 return $output;
131 }
132
136 function system_themes_page() {
137 // Get current list of themes.
138 $themes = system_rebuild_theme_data();
139 uasort($themes, 'system_sort_modules_by_info_name');
140
141 $theme_default = variable_get('theme_default', 'bartik');
142 $theme_groups = array();
143
144 foreach ($themes as &$theme) {
145 if (!empty($theme->info['hidden'])) {
146 continue;
147 }
148 $admin_theme_options[$theme->name] = $theme->info['name'];
149 $theme->is_default = ($theme->name == $theme_default);
150
151 // Identify theme screenshot.
152 $theme->screenshot = NULL;
153 // Create a list which includes the current theme and all its base themes.
154 if (isset($themes[$theme->name]->base_themes)) {
155 $theme_keys = array_keys($themes[$theme->name]->base_themes);
156 $theme_keys[] = $theme->name;
157 }
158 else {
159 $theme_keys = array($theme->name);
160 }
161 // Look for a screenshot in the current theme or in its closest ancestor.
162 foreach (array_reverse($theme_keys) as $theme_key) {
163 if (isset($themes[$theme_key]) && file_exists($themes[$theme_key]->info['screenshot'])) {
164 $theme->screenshot = array(
165 'path' => $themes[$theme_key]->info['screenshot'],
166 'alt' => t('Screenshot for !theme theme', array('!theme' => $theme->info['name'])),
167 'title' => t('Screenshot for !theme theme', array('!theme' => $theme->info['name'])),
168 'attributes' => array('class' => array('screenshot')),
169 );
170 break;
171 }
172 }
173
174 if (empty($theme->status)) {
175 // Ensure this theme is compatible with this version of core.
176 // Require the 'content' region to make sure the main page
177 // content has a common place in all themes.
178 $theme->incompatible_core = !isset($theme->info['core']) || ($theme->info['core'] != DRUPAL_CORE_COMPATIBILITY) || (!isset($theme->info['regions']['content']));
179 $theme->incompatible_php = version_compare(phpversion(), $theme->info['php']) < 0;
180 }
181 $query['token'] = drupal_get_token('system-theme-operation-link');
182 $theme->operations = array();
183 if (!empty($theme->status) || !$theme->incompatible_core && !$theme->incompatible_php) {
184 // Create the operations links.
185 $query['theme'] = $theme->name;
186 if (drupal_theme_access($theme)) {
187 $theme->operations[] = array(
188 'title' => t('Settings'),
189 'href' => 'admin/appearance/settings/' . $theme->name,
190 'attributes' => array('title' => t('Settings for !theme theme', array('!theme' => $theme->info['name']))),
191 );
192 }
193 if (!empty($theme->status)) {
194 if (!$theme->is_default) {
195 $theme->operations[] = array(
196 'title' => t('Disable'),
197 'href' => 'admin/appearance/disable',
198 'query' => $query,
199 'attributes' => array('title' => t('Disable !theme theme', array('!theme' => $theme->info['name']))),
200 );
201 $theme->operations[] = array(
202 'title' => t('Set default'),
203 'href' => 'admin/appearance/default',
204 'query' => $query,
205 'attributes' => array('title' => t('Set !theme as default theme', array('!theme' => $theme->info['name']))),
206 );
207 }
208 }
209 else {
210 $theme->operations[] = array(
211 'title' => t('Enable'),
212 'href' => 'admin/appearance/enable',
213 'query' => $query,
214 'attributes' => array('title' => t('Enable !theme theme', array('!theme' => $theme->info['name']))),
215 );
216 $theme->operations[] = array(
217 'title' => t('Enable and set default'),
218 'href' => 'admin/appearance/default',
219 'query' => $query,
220 'attributes' => array('title' => t('Enable !theme as default theme', array('!theme' => $theme->info['name']))),
221 );
222 }
223 }
224
225 // Add notes to default and administration theme.
226 $theme->notes = array();
227 $theme->classes = array();
228 if ($theme->is_default) {
229 $theme->classes[] = 'theme-default';
230 $theme->notes[] = t('default theme');
231 }
232
233 // Sort enabled and disabled themes into their own groups.
234 $theme_groups[$theme->status ? 'enabled' : 'disabled'][] = $theme;
235 }
236
237 // There are two possible theme groups.
238 $theme_group_titles = array(
239 'enabled' => format_plural(count($theme_groups['enabled']), 'Enabled theme', 'Enabled themes'),
240 );
241 if (!empty($theme_groups['disabled'])) {
242 $theme_group_titles['disabled'] = format_plural(count($theme_groups['disabled']), 'Disabled theme', 'Disabled themes');
243 }
244
245 uasort($theme_groups['enabled'], 'system_sort_themes');
246 drupal_alter('system_themes_page', $theme_groups);
247
248 $admin_form = drupal_get_form('system_themes_admin_form', $admin_theme_options);
249 return theme('system_themes_page', array('theme_groups' => $theme_groups, 'theme_group_titles' => $theme_group_titles)) . drupal_render($admin_form);
250 }
251
258 function system_themes_admin_form($form, &$form_state, $theme_options) {
259 // Administration theme settings.
260 $form['admin_theme'] = array(
261 '#type' => 'fieldset',
262 '#title' => t('Administration theme'),
263 );
264 $form['admin_theme']['admin_theme'] = array(
265 '#type' => 'select',
266 '#options' => array(0 => t('Default theme')) + $theme_options,
267 '#title' => t('Administration theme'),
268 '#description' => t('Choose "Default theme" to always use the same theme as the rest of the site.'),
269 '#default_value' => variable_get('admin_theme', 0),
270 );
271 $form['admin_theme']['node_admin_theme'] = array(
272 '#type' => 'checkbox',
273 '#title' => t('Use the administration theme when editing or creating content'),
274 '#default_value' => variable_get('node_admin_theme', '0'),
275 );
276 $form['admin_theme']['actions'] = array('#type' => 'actions');
277 $form['admin_theme']['actions']['submit'] = array(
278 '#type' => 'submit',
279 '#value' => t('Save configuration'),
280 );
281 return $form;
282 }
283
287 function system_themes_admin_form_submit($form, &$form_state) {
288 drupal_set_message(t('The configuration options have been saved.'));
289 variable_set('admin_theme', $form_state['values']['admin_theme']);
290 variable_set('node_admin_theme', $form_state['values']['node_admin_theme']);
291 }
292
296 function system_theme_enable() {
297 if (isset($_REQUEST['theme']) && isset($_REQUEST['token']) && drupal_valid_token($_REQUEST['token'], 'system-theme-operation-link')) {
298 $theme = $_REQUEST['theme'];
299 // Get current list of themes.
300 $themes = list_themes();
301
302 // Check if the specified theme is one recognized by the system.
303 if (!empty($themes[$theme])) {
304 theme_enable(array($theme));
305 drupal_set_message(t('The %theme theme has been enabled.', array('%theme' => $themes[$theme]->info['name'])));
306 }
307 else {
308 drupal_set_message(t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
309 }
310 drupal_goto('admin/appearance');
311 }
312 return MENU_ACCESS_DENIED;
313 }
314
318 function system_theme_disable() {
319 if (isset($_REQUEST['theme']) && isset($_REQUEST['token']) && drupal_valid_token($_REQUEST['token'], 'system-theme-operation-link')) {
320 $theme = $_REQUEST['theme'];
321 // Get current list of themes.
322 $themes = list_themes();
323
324 // Check if the specified theme is one recognized by the system.
325 if (!empty($themes[$theme])) {
326 if ($theme == variable_get('theme_default', 'bartik')) {
327 // Don't disable the default theme.
328 drupal_set_message(t('%theme is the default theme and cannot be disabled.', array('%theme' => $themes[$theme]->info['name'])), 'error');
329 }
330 else {
331 theme_disable(array($theme));
332 drupal_set_message(t('The %theme theme has been disabled.', array('%theme' => $themes[$theme]->info['name'])));
333 }
334 }
335 else {
336 drupal_set_message(t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
337 }
338 drupal_goto('admin/appearance');
339 }
340 return MENU_ACCESS_DENIED;
341 }
342
346 function system_theme_default() {
347 if (isset($_REQUEST['theme']) && isset($_REQUEST['token']) && drupal_valid_token($_REQUEST['token'], 'system-theme-operation-link')) {
348 $theme = $_REQUEST['theme'];
349 // Get current list of themes.
350 $themes = list_themes();
351
352 // Check if the specified theme is one recognized by the system.
353 if (!empty($themes[$theme])) {
354 // Enable the theme if it is currently disabled.
355 if (empty($themes[$theme]->status)) {
356 theme_enable(array($theme));
357 }
358 // Set the default theme.
359 variable_set('theme_default', $theme);
360
361 // Rebuild the menu. This duplicates the menu_rebuild() in theme_enable().
362 // However, modules must know the current default theme in order to use
363 // this information in hook_menu() or hook_menu_alter() implementations,
364 // and doing the variable_set() before the theme_enable() could result
365 // in a race condition where the theme is default but not enabled.
366 menu_rebuild();
367
368 // The status message depends on whether an admin theme is currently in use:
369 // a value of 0 means the admin theme is set to be the default theme.
370 $admin_theme = variable_get('admin_theme', 0);
371 if ($admin_theme != 0 && $admin_theme != $theme) {
372 drupal_set_message(t('Please note that the administration theme is still set to the %admin_theme theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected %selected_theme theme by default.', array(
373 '%admin_theme' => $themes[$admin_theme]->info['name'],
374 '%selected_theme' => $themes[$theme]->info['name'],
375 )));
376 }
377 else {
378 drupal_set_message(t('%theme is now the default theme.', array('%theme' => $themes[$theme]->info['name'])));
379 }
380 }
381 else {
382 drupal_set_message(t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
383 }
384 drupal_goto('admin/appearance');
385 }
386 return MENU_ACCESS_DENIED;
387 }
388
399 function system_theme_settings($form, &$form_state, $key = '') {
400 // Default settings are defined in theme_get_setting() in includes/theme.inc
401 if ($key) {
402 $var = 'theme_' . $key . '_settings';
403 $themes = list_themes();
404 $features = $themes[$key]->info['features'];
405 }
406 else {
407 $var = 'theme_settings';
408 }
409
410 $form['var'] = array('#type' => 'hidden', '#value' => $var);
411
412 // Toggle settings
413 $toggles = array(
414 'logo' => t('Logo'),
415 'name' => t('Site name'),
416 'slogan' => t('Site slogan'),
417 'node_user_picture' => t('User pictures in posts'),
418 'comment_user_picture' => t('User pictures in comments'),
419 'comment_user_verification' => t('User verification status in comments'),
420 'favicon' => t('Shortcut icon'),
421 'main_menu' => t('Main menu'),
422 'secondary_menu' => t('Secondary menu'),
423 );
424
425 // Some features are not always available
426 $disabled = array();
427 if (!variable_get('user_pictures', 0)) {
428 $disabled['toggle_node_user_picture'] = TRUE;
429 $disabled['toggle_comment_user_picture'] = TRUE;
430 }
431 if (!module_exists('comment')) {
432 $disabled['toggle_comment_user_picture'] = TRUE;
433 $disabled['toggle_comment_user_verification'] = TRUE;
434 }
435
436 $form['theme_settings'] = array(
437 '#type' => 'fieldset',
438 '#title' => t('Toggle display'),
439 '#description' => t('Enable or disable the display of certain page elements.'),
440 );
441 foreach ($toggles as $name => $title) {
442 if ((!$key) || in_array($name, $features)) {
443 $form['theme_settings']['toggle_' . $name] = array('#type' => 'checkbox', '#title' => $title, '#default_value' => theme_get_setting('toggle_' . $name, $key));
444 // Disable checkboxes for features not supported in the current configuration.
445 if (isset($disabled['toggle_' . $name])) {
446 $form['theme_settings']['toggle_' . $name]['#disabled'] = TRUE;
447 }
448 }
449 }
450
451 if (!element_children($form['theme_settings'])) {
452 // If there is no element in the theme settings fieldset then do not show
453 // it -- but keep it in the form if another module wants to alter.
454 $form['theme_settings']['#access'] = FALSE;
455 }
456
457 // Logo settings
458 if ((!$key) || in_array('logo', $features)) {
459 $form['logo'] = array(
460 '#type' => 'fieldset',
461 '#title' => t('Logo image settings'),
462 '#description' => t('If toggled on, the following logo will be displayed.'),
463 '#attributes' => array('class' => array('theme-settings-bottom')),
464 );
465 $form['logo']['default_logo'] = array(
466 '#type' => 'checkbox',
467 '#title' => t('Use the default logo'),
468 '#default_value' => theme_get_setting('default_logo', $key),
469 '#tree' => FALSE,
470 '#description' => t('Check here if you want the theme to use the logo supplied with it.')
471 );
472 $form['logo']['settings'] = array(
473 '#type' => 'container',
474 '#states' => array(
475 // Hide the logo settings when using the default logo.
476 'invisible' => array(
477 'input[name="default_logo"]' => array('checked' => TRUE),
478 ),
479 ),
480 );
481 $form['logo']['settings']['logo_path'] = array(
482 '#type' => 'textfield',
483 '#title' => t('Path to custom logo'),
484 '#description' => t('The path to the file you would like to use as your logo file instead of the default logo.'),
485 '#default_value' => theme_get_setting('logo_path', $key),
486 );
487 $form['logo']['settings']['logo_upload'] = array(
488 '#type' => 'file',
489 '#title' => t('Upload logo image'),
490 '#maxlength' => 40,
491 '#description' => t("If you don't have direct file access to the server, use this field to upload your logo.")
492 );
493 }
494
495 if ((!$key) || in_array('favicon', $features)) {
496 $form['favicon'] = array(
497 '#type' => 'fieldset',
498 '#title' => t('Shortcut icon settings'),
499 '#description' => t("Your shortcut icon, or 'favicon', is displayed in the address bar and bookmarks of most browsers."),
500 );
501 $form['favicon']['default_favicon'] = array(
502 '#type' => 'checkbox',
503 '#title' => t('Use the default shortcut icon.'),
504 '#default_value' => theme_get_setting('default_favicon', $key),
505 '#description' => t('Check here if you want the theme to use the default shortcut icon.')
506 );
507 $form['favicon']['settings'] = array(
508 '#type' => 'container',
509 '#states' => array(
510 // Hide the favicon settings when using the default favicon.
511 'invisible' => array(
512 'input[name="default_favicon"]' => array('checked' => TRUE),
513 ),
514 ),
515 );
516 $form['favicon']['settings']['favicon_path'] = array(
517 '#type' => 'textfield',
518 '#title' => t('Path to custom icon'),
519 '#description' => t('The path to the image file you would like to use as your custom shortcut icon.'),
520 '#default_value' => theme_get_setting('favicon_path', $key),
521 );
522 $form['favicon']['settings']['favicon_upload'] = array(
523 '#type' => 'file',
524 '#title' => t('Upload icon image'),
525 '#description' => t("If you don't have direct file access to the server, use this field to upload your shortcut icon.")
526 );
527 }
528
529 // Inject human-friendly values for logo and favicon.
530 foreach (array('logo' => 'logo.png', 'favicon' => 'favicon.ico') as $type => $default) {
531 if (isset($form[$type]['settings'][$type . '_path'])) {
532 $element = &$form[$type]['settings'][$type . '_path'];
533
534 // If path is a public:// URI, display the path relative to the files
535 // directory; stream wrappers are not end-user friendly.
536 $original_path = $element['#default_value'];
537 $friendly_path = NULL;
538 if (file_uri_scheme($original_path) == 'public') {
539 $friendly_path = file_uri_target($original_path);
540 $element['#default_value'] = $friendly_path;
541 }
542 }
543 }
544
545 if ($key) {
546 // Call engine-specific settings.
547 $function = $themes[$key]->prefix . '_engine_settings';
548 if (function_exists($function)) {
549 $form['engine_specific'] = array(
550 '#type' => 'fieldset',
551 '#title' => t('Theme-engine-specific settings'),
552 '#description' => t('These settings only exist for the themes based on the %engine theme engine.', array('%engine' => $themes[$key]->prefix)),
553 );
554 $function($form, $form_state);
555 }
556
557 // Create a list which includes the current theme and all its base themes.
558 if (isset($themes[$key]->base_themes)) {
559 $theme_keys = array_keys($themes[$key]->base_themes);
560 $theme_keys[] = $key;
561 }
562 else {
563 $theme_keys = array($key);
564 }
565
566 // Save the name of the current theme (if any), so that we can temporarily
567 // override the current theme and allow theme_get_setting() to work
568 // without having to pass the theme name to it.
569 $default_theme = !empty($GLOBALS['theme_key']) ? $GLOBALS['theme_key'] : NULL;
570 $GLOBALS['theme_key'] = $key;
571
572 // Process the theme and all its base themes.
573 foreach ($theme_keys as $theme) {
574 // Include the theme-settings.php file.
575 $filename = DRUPAL_ROOT . '/' . str_replace("/$theme.info", '', $themes[$theme]->filename) . '/theme-settings.php';
576 if (file_exists($filename)) {
577 require_once $filename;
578 }
579
580 // Call theme-specific settings.
581 $function = $theme . '_form_system_theme_settings_alter';
582 if (function_exists($function)) {
583 $function($form, $form_state);
584 }
585 }
586
587 // Restore the original current theme.
588 if (isset($default_theme)) {
589 $GLOBALS['theme_key'] = $default_theme;
590 }
591 else {
592 unset($GLOBALS['theme_key']);
593 }
594 }
595
596 $form = system_settings_form($form);
597 // We don't want to call system_settings_form_submit(), so change #submit.
598 array_pop($form['#submit']);
599 $form['#submit'][] = 'system_theme_settings_submit';
600 $form['#validate'][] = 'system_theme_settings_validate';
601 return $form;
602 }
603
607 function system_theme_settings_validate($form, &$form_state) {
608 // Handle file uploads.
609 $validators = array('file_validate_is_image' => array());
610
611 // Check for a new uploaded logo.
612 $file = file_save_upload('logo_upload', $validators);
613 if (isset($file)) {
614 // File upload was attempted.
615 if ($file) {
616 // Put the temporary file in form_values so we can save it on submit.
617 $form_state['values']['logo_upload'] = $file;
618 }
619 else {
620 // File upload failed.
621 form_set_error('logo_upload', t('The logo could not be uploaded.'));
622 }
623 }
624
625 $validators = array('file_validate_extensions' => array('ico png gif jpg jpeg apng svg'));
626
627 // Check for a new uploaded favicon.
628 $file = file_save_upload('favicon_upload', $validators);
629 if (isset($file)) {
630 // File upload was attempted.
631 if ($file) {
632 // Put the temporary file in form_values so we can save it on submit.
633 $form_state['values']['favicon_upload'] = $file;
634 }
635 else {
636 // File upload failed.
637 form_set_error('favicon_upload', t('The favicon could not be uploaded.'));
638 }
639 }
640
641 // If the user provided a path for a logo or favicon file, make sure a file
642 // exists at that path.
643 if ($form_state['values']['logo_path']) {
644 $path = _system_theme_settings_validate_path($form_state['values']['logo_path']);
645 if (!$path) {
646 form_set_error('logo_path', t('The custom logo path is invalid.'));
647 }
648 }
649 if ($form_state['values']['favicon_path']) {
650 $path = _system_theme_settings_validate_path($form_state['values']['favicon_path']);
651 if (!$path) {
652 form_set_error('favicon_path', t('The custom favicon path is invalid.'));
653 }
654 }
655 }
656
671 function _system_theme_settings_validate_path($path) {
672 // Absolute local file paths are invalid.
673 if (drupal_realpath($path) == $path) {
674 return FALSE;
675 }
676 // A path relative to the Drupal root or a fully qualified URI is valid.
677 if (is_file($path)) {
678 return $path;
679 }
680 // Prepend 'public://' for relative file paths within public filesystem.
681 if (file_uri_scheme($path) === FALSE) {
682 $path = 'public://' . $path;
683 }
684 if (is_file($path)) {
685 return $path;
686 }
687 return FALSE;
688 }
689
693 function system_theme_settings_submit($form, &$form_state) {
694 // Exclude unnecessary elements before saving.
695 form_state_values_clean($form_state);
696
697 $values = $form_state['values'];
698
699 // Extract the name of the theme from the submitted form values, then remove
700 // it from the array so that it is not saved as part of the variable.
701 $key = $values['var'];
702 unset($values['var']);
703
704 // If the user uploaded a new logo or favicon, save it to a permanent location
705 // and use it in place of the default theme-provided file.
706 if ($file = $values['logo_upload']) {
707 unset($values['logo_upload']);
708 $filename = file_unmanaged_copy($file->uri);
709 $values['default_logo'] = 0;
710 $values['logo_path'] = $filename;
711 $values['toggle_logo'] = 1;
712 }
713 if ($file = $values['favicon_upload']) {
714 unset($values['favicon_upload']);
715 $filename = file_unmanaged_copy($file->uri);
716 $values['default_favicon'] = 0;
717 $values['favicon_path'] = $filename;
718 $values['toggle_favicon'] = 1;
719 }
720
721 // If the user entered a path relative to the system files directory for
722 // a logo or favicon, store a public:// URI so the theme system can handle it.
723 if (!empty($values['logo_path'])) {
724 $values['logo_path'] = _system_theme_settings_validate_path($values['logo_path']);
725 }
726 if (!empty($values['favicon_path'])) {
727 $values['favicon_path'] = _system_theme_settings_validate_path($values['favicon_path']);
728 }
729
730 if (empty($values['default_favicon']) && !empty($values['favicon_path'])) {
731 $values['favicon_mimetype'] = file_get_mimetype($values['favicon_path']);
732 }
733
734 variable_set($key, $values);
735 drupal_set_message(t('The configuration options have been saved.'));
736
737 cache_clear_all();
738 }
739
754 function _system_is_incompatible(&$incompatible, $files, $file) {
755 if (isset($incompatible[$file->name])) {
756 return TRUE;
757 }
758 // Recursively traverse required modules, looking for incompatible modules.
759 foreach ($file->requires as $requires) {
760 if (isset($files[$requires]) && _system_is_incompatible($incompatible, $files, $files[$requires])) {
761 $incompatible[$file->name] = TRUE;
762 return TRUE;
763 }
764 }
765 }
766
788 function system_modules($form, $form_state = array()) {
789 // Get current list of modules.
790 $files = system_rebuild_module_data();
791
792 // Remove hidden modules from display list.
793 $visible_files = $files;
794 foreach ($visible_files as $filename => $file) {
795 if (!empty($file->info['hidden'])) {
796 unset($visible_files[$filename]);
797 }
798 }
799
800 uasort($visible_files, 'system_sort_modules_by_info_name');
801
802 // If the modules form was submitted, then system_modules_submit() runs first
803 // and if there are unfilled required modules, then $form_state['storage'] is
804 // filled, triggering a rebuild. In this case we need to display a
805 // confirmation form.
806 if (!empty($form_state['storage'])) {
807 return system_modules_confirm_form($visible_files, $form_state['storage']);
808 }
809
810 $modules = array();
811 $form['modules'] = array('#tree' => TRUE);
812
813 // Used when checking if module implements a help page.
814 $help_arg = module_exists('help') ? drupal_help_arg() : FALSE;
815
816 // Used when displaying modules that are required by the installation profile.
817 require_once DRUPAL_ROOT . '/includes/install.inc';
818 $distribution_name = check_plain(drupal_install_profile_distribution_name());
819
820 // Iterate through each of the modules.
821 foreach ($visible_files as $filename => $module) {
822 $extra = array();
823 $extra['enabled'] = (bool) $module->status;
824 if (!empty($module->info['required'] )) {
825 $extra['disabled'] = TRUE;
826 $extra['required_by'][] = $distribution_name . (!empty($module->info['explanation']) ? ' ('. $module->info['explanation'] .')' : '');
827 }
828
829 // If this module requires other modules, add them to the array.
830 foreach ($module->requires as $requires => $v) {
831 if (!isset($files[$requires])) {
832 $extra['requires'][$requires] = t('@module (<span class="admin-missing">missing</span>)', array('@module' => drupal_ucfirst($requires)));
833 $extra['disabled'] = TRUE;
834 }
835 // Only display visible modules.
836 elseif (isset($visible_files[$requires])) {
837 $requires_name = $files[$requires]->info['name'];
838 // Disable this module if it is incompatible with the dependency's version.
839 if ($incompatible_version = drupal_check_incompatibility($v, str_replace(DRUPAL_CORE_COMPATIBILITY . '-', '', $files[$requires]->info['version']))) {
840 $extra['requires'][$requires] = t('@module (<span class="admin-missing">incompatible with</span> version @version)', array(
841 '@module' => $requires_name . $incompatible_version,
842 '@version' => $files[$requires]->info['version'],
843 ));
844 $extra['disabled'] = TRUE;
845 }
846 // Disable this module if the dependency is incompatible with this
847 // version of Drupal core.
848 elseif ($files[$requires]->info['core'] != DRUPAL_CORE_COMPATIBILITY) {
849 $extra['requires'][$requires] = t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', array(
850 '@module' => $requires_name,
851 ));
852 $extra['disabled'] = TRUE;
853 }
854 elseif ($files[$requires]->status) {
855 $extra['requires'][$requires] = t('@module (<span class="admin-enabled">enabled</span>)', array('@module' => $requires_name));
856 }
857 else {
858 $extra['requires'][$requires] = t('@module (<span class="admin-disabled">disabled</span>)', array('@module' => $requires_name));
859 }
860 }
861 }
862 // Generate link for module's help page, if there is one.
863 if ($help_arg && $module->status && in_array($filename, module_implements('help'))) {
864 if (module_invoke($filename, 'help', "admin/help#$filename", $help_arg)) {
865 $extra['links']['help'] = array(
866 '#type' => 'link',
867 '#title' => t('Help'),
868 '#href' => "admin/help/$filename",
869 '#options' => array('attributes' => array('class' => array('module-link', 'module-link-help'), 'title' => t('Help'))),
870 );
871 }
872 }
873 // Generate link for module's permission, if the user has access to it.
874 if ($module->status && user_access('administer permissions') && in_array($filename, module_implements('permission'))) {
875 $extra['links']['permissions'] = array(
876 '#type' => 'link',
877 '#title' => t('Permissions'),
878 '#href' => 'admin/people/permissions',
879 '#options' => array('fragment' => 'module-' . $filename, 'attributes' => array('class' => array('module-link', 'module-link-permissions'), 'title' => t('Configure permissions'))),
880 );
881 }
882 // Generate link for module's configuration page, if the module provides
883 // one.
884 if ($module->status && isset($module->info['configure'])) {
885 $configure_link = menu_get_item($module->info['configure']);
886 if ($configure_link['access']) {
887 $extra['links']['configure'] = array(
888 '#type' => 'link',
889 '#title' => t('Configure'),
890 '#href' => $configure_link['href'],
891 '#options' => array('attributes' => array('class' => array('module-link', 'module-link-configure'), 'title' => $configure_link['description'])),
892 );
893 }
894 }
895
896 // If this module is required by other modules, list those, and then make it
897 // impossible to disable this one.
898 foreach ($module->required_by as $required_by => $v) {
899 // Hidden modules are unset already.
900 if (isset($visible_files[$required_by])) {
901 if ($files[$required_by]->status == 1 && $module->status == 1) {
902 $extra['required_by'][] = t('@module (<span class="admin-enabled">enabled</span>)', array('@module' => $files[$required_by]->info['name']));
903 $extra['disabled'] = TRUE;
904 }
905 else {
906 $extra['required_by'][] = t('@module (<span class="admin-disabled">disabled</span>)', array('@module' => $files[$required_by]->info['name']));
907 }
908 }
909 }
910 $form['modules'][$module->info['package']][$filename] = _system_modules_build_row($module->info, $extra);
911 }
912
913 // Add basic information to the fieldsets.
914 foreach (element_children($form['modules']) as $package) {
915 $form['modules'][$package] += array(
916 '#type' => 'fieldset',
917 '#title' => t($package),
918 '#collapsible' => TRUE,
919 '#theme' => 'system_modules_fieldset',
920 '#header' => array(
921 array('data' => t('Enabled'), 'class' => array('checkbox')),
922 t('Name'),
923 t('Version'),
924 t('Description'),
925 array('data' => t('Operations'), 'colspan' => 3),
926 ),
927 // Ensure that the "Core" package fieldset comes first.
928 '#weight' => $package == 'Core' ? -10 : NULL,
929 );
930 }
931
932 // Lastly, sort all fieldsets by title.
933 uasort($form['modules'], 'element_sort_by_title');
934
935 $form['actions'] = array('#type' => 'actions');
936 $form['actions']['submit'] = array(
937 '#type' => 'submit',
938 '#value' => t('Save configuration'),
939 );
940 $form['#action'] = url('admin/modules/list/confirm');
941
942 return $form;
943 }
944
948 function system_sort_modules_by_info_name($a, $b) {
949 return strcasecmp($a->info['name'], $b->info['name']);
950 }
951
955 function system_sort_themes($a, $b) {
956 if ($a->is_default) {
957 return -1;
958 }
959 if ($b->is_default) {
960 return 1;
961 }
962 return strcasecmp($a->info['name'], $b->info['name']);
963 }
964
968 function _system_modules_build_row($info, $extra) {
969 // Add in the defaults.
970 $extra += array(
971 'requires' => array(),
972 'required_by' => array(),
973 'disabled' => FALSE,
974 'enabled' => FALSE,
975 'links' => array(),
976 );
977 $form = array(
978 '#tree' => TRUE,
979 );
980 // Set the basic properties.
981 $form['name'] = array(
982 '#markup' => $info['name'],
983 );
984 $form['description'] = array(
985 '#markup' => t($info['description']),
986 );
987 $form['version'] = array(
988 '#markup' => $info['version'],
989 );
990 $form['#requires'] = $extra['requires'];
991 $form['#required_by'] = $extra['required_by'];
992
993 // Check the compatibilities.
994 $compatible = TRUE;
995 $status_short = '';
996 $status_long = '';
997
998 // Check the core compatibility.
999 if (!isset($info['core']) || $info['core'] != DRUPAL_CORE_COMPATIBILITY) {
1000 $compatible = FALSE;
1001 $status_short .= t('Incompatible with this version of Drupal core.');
1002 $status_long .= t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => DRUPAL_CORE_COMPATIBILITY));
1003 }
1004
1005 // Ensure this module is compatible with the currently installed version of PHP.
1006 if (version_compare(phpversion(), $info['php']) < 0) {
1007 $compatible = FALSE;
1008 $status_short .= t('Incompatible with this version of PHP');
1009 $php_required = $info['php'];
1010 if (substr_count($info['php'], '.') < 2) {
1011 $php_required .= '.*';
1012 }
1013 $status_long .= t('This module requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $php_required, '!php_version' => phpversion()));
1014 }
1015
1016 // If this module is compatible, present a checkbox indicating
1017 // this module may be installed. Otherwise, show a big red X.
1018 if ($compatible) {
1019 $form['enable'] = array(
1020 '#type' => 'checkbox',
1021 '#title' => t('Enable'),
1022 '#default_value' => $extra['enabled'],
1023 );
1024 if ($extra['disabled']) {
1025 $form['enable']['#disabled'] = TRUE;
1026 }
1027 }
1028 else {
1029 $form['enable'] = array(
1030 '#markup' => theme('image', array('path' => 'misc/watchdog-error.png', 'alt' => $status_short, 'title' => $status_short)),
1031 );
1032 $form['description']['#markup'] .= theme('system_modules_incompatible', array('message' => $status_long));
1033 }
1034
1035 // Build operation links.
1036 foreach (array('help', 'permissions', 'configure') as $key) {
1037 $form['links'][$key] = (isset($extra['links'][$key]) ? $extra['links'][$key] : array());
1038 }
1039
1040 return $form;
1041 }
1042
1054 function system_modules_confirm_form($modules, $storage) {
1055 $items = array();
1056
1057 $form['validation_modules'] = array('#type' => 'value', '#value' => $modules);
1058 $form['status']['#tree'] = TRUE;
1059
1060 foreach ($storage['more_required'] as $info) {
1061 $t_argument = array(
1062 '@module' => $info['name'],
1063 '@required' => implode(', ', $info['requires']),
1064 );
1065 $items[] = format_plural(count($info['requires']), 'You must enable the @required module to install @module.', 'You must enable the @required modules to install @module.', $t_argument);
1066 }
1067
1068 foreach ($storage['missing_modules'] as $name => $info) {
1069 $t_argument = array(
1070 '@module' => $name,
1071 '@depends' => implode(', ', $info['depends']),
1072 );
1073 $items[] = format_plural(count($info['depends']), 'The @module module is missing, so the following module will be disabled: @depends.', 'The @module module is missing, so the following modules will be disabled: @depends.', $t_argument);
1074 }
1075
1076 $form['text'] = array('#markup' => theme('item_list', array('items' => $items)));
1077
1078 if ($form) {
1079 // Set some default form values
1080 $form = confirm_form(
1081 $form,
1082 t('Some required modules must be enabled'),
1083 'admin/modules',
1084 t('Would you like to continue with the above?'),
1085 t('Continue'),
1086 t('Cancel'));
1087 return $form;
1088 }
1089 }
1090
1094 function system_modules_submit($form, &$form_state) {
1095 include_once DRUPAL_ROOT . '/includes/install.inc';
1096
1097 // Builds list of modules.
1098 $modules = array();
1099 // If we're not coming from the confirmation form, build the list of modules.
1100 if (empty($form_state['storage'])) {
1101 // If we're not coming from the confirmation form, build the module list.
1102 foreach ($form_state['values']['modules'] as $group_name => $group) {
1103 foreach ($group as $module => $enabled) {
1104 $modules[$module] = array('group' => $group_name, 'enabled' => $enabled['enable']);
1105 }
1106 }
1107 }
1108 else {
1109 // If we are coming from the confirmation form, fetch
1110 // the modules out of $form_state.
1111 $modules = $form_state['storage']['modules'];
1112 }
1113
1114 // Collect data for all modules to be able to determine dependencies.
1115 $files = system_rebuild_module_data();
1116
1117 // Sorts modules by weight.
1118 $sort = array();
1119 foreach (array_keys($modules) as $module) {
1120 $sort[$module] = $files[$module]->sort;
1121 }
1122 array_multisort($sort, $modules);
1123
1124 // Makes sure all required modules are set to be enabled.
1125 $more_required = array();
1126 $missing_modules = array();
1127 foreach ($modules as $name => $module) {
1128 if ($module['enabled']) {
1129 // Checks that all dependencies are set to be enabled. Stores the ones
1130 // that are not in $dependencies variable so that the user can be alerted
1131 // in the confirmation form that more modules need to be enabled.
1132 $dependencies = array();
1133 foreach (array_keys($files[$name]->requires) as $required) {
1134 if (empty($modules[$required]['enabled'])) {
1135 if (isset($files[$required])) {
1136 $dependencies[] = $files[$required]->info['name'];
1137 $modules[$required]['enabled'] = TRUE;
1138 }
1139 else {
1140 $missing_modules[$required]['depends'][] = $name;
1141 $modules[$name]['enabled'] = FALSE;
1142 }
1143 }
1144 }
1145
1146 // Stores additional modules that need to be enabled in $more_required.
1147 if (!empty($dependencies)) {
1148 $more_required[$name] = array(
1149 'name' => $files[$name]->info['name'],
1150 'requires' => $dependencies,
1151 );
1152 }
1153 }
1154 }
1155
1156 // Redirects to confirmation form if more modules need to be enabled.
1157 if ((!empty($more_required) || !empty($missing_modules)) && !isset($form_state['values']['confirm'])) {
1158 $form_state['storage'] = array(
1159 'more_required' => $more_required,
1160 'modules' => $modules,
1161 'missing_modules' => $missing_modules,
1162 );
1163 $form_state['rebuild'] = TRUE;
1164 return;
1165 }
1166
1167 // Invokes hook_requirements('install'). If failures are detected, makes sure
1168 // the dependent modules aren't installed either.
1169 foreach ($modules as $name => $module) {
1170 // Only invoke hook_requirements() on modules that are going to be installed.
1171 if ($module['enabled'] && drupal_get_installed_schema_version($name) == SCHEMA_UNINSTALLED) {
1172 if (!drupal_check_module($name)) {
1173 $modules[$name]['enabled'] = FALSE;
1174 foreach (array_keys($files[$name]->required_by) as $required_by) {
1175 $modules[$required_by]['enabled'] = FALSE;
1176 }
1177 }
1178 }
1179 }
1180
1181 // Initializes array of actions.
1182 $actions = array(
1183 'enable' => array(),
1184 'disable' => array(),
1185 'install' => array(),
1186 );
1187
1188 // Builds arrays of modules that need to be enabled, disabled, and installed.
1189 foreach ($modules as $name => $module) {
1190 if ($module['enabled']) {
1191 if (drupal_get_installed_schema_version($name) == SCHEMA_UNINSTALLED) {
1192 $actions['install'][] = $name;
1193 $actions['enable'][] = $name;
1194 }
1195 elseif (!module_exists($name)) {
1196 $actions['enable'][] = $name;
1197 }
1198 }
1199 elseif (module_exists($name)) {
1200 $actions['disable'][] = $name;
1201 }
1202 }
1203
1204 // Gets list of modules prior to install process, unsets $form_state['storage']
1205 // so we don't get redirected back to the confirmation form.
1206 $pre_install_list = module_list();
1207 unset($form_state['storage']);
1208
1209 // Reverse the 'enable' list, to order dependencies before dependents.
1210 krsort($actions['enable']);
1211
1212 // Installs, enables, and disables modules.
1213 module_enable($actions['enable'], FALSE);
1214 module_disable($actions['disable'], FALSE);
1215
1216 // Gets module list after install process, flushes caches and displays a
1217 // message if there are changes.
1218 $post_install_list = module_list(TRUE);
1219 if ($pre_install_list != $post_install_list) {
1220 drupal_flush_all_caches();
1221 drupal_set_message(t('The configuration options have been saved.'));
1222 }
1223
1224 $form_state['redirect'] = 'admin/modules';
1225 }
1226
1242 function system_modules_uninstall($form, $form_state = NULL) {
1243 // Make sure the install API is available.
1244 include_once DRUPAL_ROOT . '/includes/install.inc';
1245
1246 // Display the confirm form if any modules have been submitted.
1247 if (!empty($form_state['storage']) && $confirm_form = system_modules_uninstall_confirm_form($form_state['storage'])) {
1248 return $confirm_form;
1249 }
1250
1251 // Get a list of disabled, installed modules.
1252 $all_modules = system_rebuild_module_data();
1253 $disabled_modules = array();
1254 foreach ($all_modules as $name => $module) {
1255 if (empty($module->status) && $module->schema_version > SCHEMA_UNINSTALLED) {
1256 $disabled_modules[$name] = $module;
1257 }
1258 }
1259
1260 // Only build the rest of the form if there are any modules available to
1261 // uninstall.
1262 if (!empty($disabled_modules)) {
1263 $profile = drupal_get_profile();
1264 uasort($disabled_modules, 'system_sort_modules_by_info_name');
1265 $form['uninstall'] = array('#tree' => TRUE);
1266 foreach ($disabled_modules as $module) {
1267 $module_name = $module->info['name'] ? $module->info['name'] : $module->name;
1268 $form['modules'][$module->name]['#module_name'] = $module_name;
1269 $form['modules'][$module->name]['name']['#markup'] = $module_name;
1270 $form['modules'][$module->name]['description']['#markup'] = t($module->info['description']);
1271 $form['uninstall'][$module->name] = array(
1272 '#type' => 'checkbox',
1273 '#title' => t('Uninstall @module module', array('@module' => $module_name)),
1274 '#title_display' => 'invisible',
1275 );
1276 // All modules which depend on this one must be uninstalled first, before
1277 // we can allow this module to be uninstalled. (The installation profile
1278 // is excluded from this list.)
1279 foreach (array_keys($module->required_by) as $dependent) {
1280 if ($dependent != $profile && drupal_get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED) {
1281 $dependent_name = isset($all_modules[$dependent]->info['name']) ? $all_modules[$dependent]->info['name'] : $dependent;
1282 $form['modules'][$module->name]['#required_by'][] = $dependent_name;
1283 $form['uninstall'][$module->name]['#disabled'] = TRUE;
1284 }
1285 }
1286 }
1287 $form['actions'] = array('#type' => 'actions');
1288 $form['actions']['submit'] = array(
1289 '#type' => 'submit',
1290 '#value' => t('Uninstall'),
1291 );
1292 $form['#action'] = url('admin/modules/uninstall/confirm');
1293 }
1294 else {
1295 $form['modules'] = array();
1296 }
1297
1298 return $form;
1299 }
1300
1310 function system_modules_uninstall_confirm_form($storage) {
1311 // Nothing to build.
1312 if (empty($storage)) {
1313 return;
1314 }
1315
1316 // Construct the hidden form elements and list items.
1317 foreach (array_filter($storage['uninstall']) as $module => $value) {
1318 $info = drupal_parse_info_file(drupal_get_path('module', $module) . '/' . $module . '.info');
1319 $uninstall[] = $info['name'];
1320 $form['uninstall'][$module] = array('#type' => 'hidden',
1321 '#value' => 1,
1322 );
1323 }
1324
1325 // Display a confirm form if modules have been selected.
1326 if (isset($uninstall)) {
1327 $form['#confirmed'] = TRUE;
1328 $form['uninstall']['#tree'] = TRUE;
1329 $form['modules'] = array('#markup' => '<p>' . t('The following modules will be completely uninstalled from your site, and <em>all data from these modules will be lost</em>!') . '</p>' . theme('item_list', array('items' => $uninstall)));
1330 $form = confirm_form(
1331 $form,
1332 t('Confirm uninstall'),
1333 'admin/modules/uninstall',
1334 t('Would you like to continue with uninstalling the above?'),
1335 t('Uninstall'),
1336 t('Cancel'));
1337 return $form;
1338 }
1339 }
1340
1344 function system_modules_uninstall_validate($form, &$form_state) {
1345 // Form submitted, but no modules selected.
1346 if (!count(array_filter($form_state['values']['uninstall']))) {
1347 drupal_set_message(t('No modules selected.'), 'error');
1348 drupal_goto('admin/modules/uninstall');
1349 }
1350 }
1351
1355 function system_modules_uninstall_submit($form, &$form_state) {
1356 // Make sure the install API is available.
1357 include_once DRUPAL_ROOT . '/includes/install.inc';
1358
1359 if (!empty($form['#confirmed'])) {
1360 // Call the uninstall routine for each selected module.
1361 $modules = array_keys($form_state['values']['uninstall']);
1362 drupal_uninstall_modules($modules);
1363 drupal_set_message(t('The selected modules have been uninstalled.'));
1364
1365 $form_state['redirect'] = 'admin/modules/uninstall';
1366 }
1367 else {
1368 $form_state['storage'] = $form_state['values'];
1369 $form_state['rebuild'] = TRUE;
1370 }
1371 }
1372
1380 function system_ip_blocking($default_ip = '') {
1381 $rows = array();
1382 $header = array(t('Blocked IP addresses'), t('Operations'));
1383 $result = db_query('SELECT * FROM {blocked_ips}');
1384 foreach ($result as $ip) {
1385 $rows[] = array(
1386 $ip->ip,
1387 l(t('delete'), "admin/config/people/ip-blocking/delete/$ip->iid"),
1388 );
1389 }
1390
1391 $build['system_ip_blocking_form'] = drupal_get_form('system_ip_blocking_form', $default_ip);
1392
1393 $build['system_ip_blocking_table'] = array(
1394 '#theme' => 'table',
1395 '#header' => $header,
1396 '#rows' => $rows,
1397 '#empty' => t('No blocked IP addresses available.'),
1398 );
1399
1400 return $build;
1401 }
1402
1410 function system_ip_blocking_form($form, $form_state, $default_ip) {
1411 $form['ip'] = array(
1412 '#title' => t('IP address'),
1413 '#type' => 'textfield',
1414 '#size' => 48,
1415 '#maxlength' => 40,
1416 '#default_value' => $default_ip,
1417 '#description' => t('Enter a valid IP address.'),
1418 );
1419 $form['actions'] = array('#type' => 'actions');
1420 $form['actions']['submit'] = array(
1421 '#type' => 'submit',
1422 '#value' => t('Add'),
1423 );
1424 $form['#submit'][] = 'system_ip_blocking_form_submit';
1425 $form['#validate'][] = 'system_ip_blocking_form_validate';
1426 return $form;
1427 }
1428
1429 function system_ip_blocking_form_validate($form, &$form_state) {
1430 $ip = trim($form_state['values']['ip']);
1431 if (db_query("SELECT * FROM {blocked_ips} WHERE ip = :ip", array(':ip' => $ip))->fetchField()) {
1432 form_set_error('ip', t('This IP address is already blocked.'));
1433 }
1434 elseif ($ip == ip_address()) {
1435 form_set_error('ip', t('You may not block your own IP address.'));
1436 }
1437 elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) == FALSE) {
1438 form_set_error('ip', t('Enter a valid IP address.'));
1439 }
1440 }
1441
1442 function system_ip_blocking_form_submit($form, &$form_state) {
1443 $ip = trim($form_state['values']['ip']);
1444 db_insert('blocked_ips')
1445 ->fields(array('ip' => $ip))
1446 ->execute();
1447 drupal_set_message(t('The IP address %ip has been blocked.', array('%ip' => $ip)));
1448 $form_state['redirect'] = 'admin/config/people/ip-blocking';
1449 return;
1450 }
1451
1457 function system_ip_blocking_delete($form, &$form_state, $iid) {
1458 $form['blocked_ip'] = array(
1459 '#type' => 'value',
1460 '#value' => $iid,
1461 );
1462 return confirm_form($form, t('Are you sure you want to delete %ip?', array('%ip' => $iid['ip'])), 'admin/config/people/ip-blocking', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
1463 }
1464
1468 function system_ip_blocking_delete_submit($form, &$form_state) {
1469 $blocked_ip = $form_state['values']['blocked_ip'];
1470 db_delete('blocked_ips')
1471 ->condition('iid', $blocked_ip['iid'])
1472 ->execute();
1473 watchdog('user', 'Deleted %ip', array('%ip' => $blocked_ip['ip']));
1474 drupal_set_message(t('The IP address %ip was deleted.', array('%ip' => $blocked_ip['ip'])));
1475 $form_state['redirect'] = 'admin/config/people/ip-blocking';
1476 }
1477
1484 function system_site_information_settings() {
1485 $form['site_information'] = array(
1486 '#type' => 'fieldset',
1487 '#title' => t('Site details'),
1488 );
1489 $form['site_information']['site_name'] = array(
1490 '#type' => 'textfield',
1491 '#title' => t('Site name'),
1492 '#default_value' => variable_get('site_name', 'Drupal'),
1493 '#required' => TRUE
1494 );
1495 $form['site_information']['site_slogan'] = array(
1496 '#type' => 'textfield',
1497 '#title' => t('Slogan'),
1498 '#default_value' => variable_get('site_slogan', ''),
1499 '#description' => t("How this is used depends on your site's theme."),
1500 );
1501 $form['site_information']['site_mail'] = array(
1502 '#type' => 'textfield',
1503 '#title' => t('E-mail address'),
1504 '#default_value' => variable_get('site_mail', ini_get('sendmail_from')),
1505 '#description' => t("The <em>From</em> address in automated e-mails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this e-mail being flagged as spam.)"),
1506 '#required' => TRUE,
1507 );
1508 $form['front_page'] = array(
1509 '#type' => 'fieldset',
1510 '#title' => t('Front page'),
1511 );
1512 $form['front_page']['default_nodes_main'] = array(
1513 '#type' => 'select', '#title' => t('Number of posts on front page'),
1514 '#default_value' => variable_get('default_nodes_main', 10),
1515 '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
1516 '#description' => t('The maximum number of posts displayed on overview pages such as the front page.')
1517 );
1518 $form['front_page']['site_frontpage'] = array(
1519 '#type' => 'textfield',
1520 '#title' => t('Default front page'),
1521 '#default_value' => (variable_get('site_frontpage')!='node'?drupal_get_path_alias(variable_get('site_frontpage', 'node')):''),
1522 '#size' => 40,
1523 '#description' => t('Optionally, specify a relative URL to display as the front page. Leave blank to display the default content feed.'),
1524 '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
1525 );
1526 $form['error_page'] = array(
1527 '#type' => 'fieldset',
1528 '#title' => t('Error pages'),
1529 );
1530 $form['error_page']['site_403'] = array(
1531 '#type' => 'textfield',
1532 '#title' => t('Default 403 (access denied) page'),
1533 '#default_value' => variable_get('site_403', ''),
1534 '#size' => 40,
1535 '#description' => t('This page is displayed when the requested document is denied to the current user. Leave blank to display a generic "access denied" page.'),
1536 '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
1537 );
1538 $form['error_page']['site_404'] = array(
1539 '#type' => 'textfield',
1540 '#title' => t('Default 404 (not found) page'),
1541 '#default_value' => variable_get('site_404', ''),
1542 '#size' => 40,
1543 '#description' => t('This page is displayed when no other content matches the requested document. Leave blank to display a generic "page not found" page.'),
1544 '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
1545 );
1546
1547 $form['#validate'][] = 'system_site_information_settings_validate';
1548
1549 return system_settings_form($form);
1550 }
1551
1555 function system_site_information_settings_validate($form, &$form_state) {
1556 // Validate the e-mail address.
1557 if ($error = user_validate_mail($form_state['values']['site_mail'])) {
1558 form_set_error('site_mail', $error);
1559 }
1560 // Check for empty front page path.
1561 if (empty($form_state['values']['site_frontpage'])) {
1562 // Set to default "node".
1563 form_set_value($form['front_page']['site_frontpage'], 'node', $form_state);
1564 }
1565 else {
1566 // Get the normal path of the front page.
1567 form_set_value($form['front_page']['site_frontpage'], drupal_get_normal_path($form_state['values']['site_frontpage']), $form_state);
1568 }
1569 // Validate front page path.
1570 if (!drupal_valid_path($form_state['values']['site_frontpage'])) {
1571 form_set_error('site_frontpage', t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state['values']['site_frontpage'])));
1572 }
1573 // Get the normal paths of both error pages.
1574 if (!empty($form_state['values']['site_403'])) {
1575 form_set_value($form['error_page']['site_403'], drupal_get_normal_path($form_state['values']['site_403']), $form_state);
1576 }
1577 if (!empty($form_state['values']['site_404'])) {
1578 form_set_value($form['error_page']['site_404'], drupal_get_normal_path($form_state['values']['site_404']), $form_state);
1579 }
1580 // Validate 403 error path.
1581 if (!empty($form_state['values']['site_403']) && !drupal_valid_path($form_state['values']['site_403'])) {
1582 form_set_error('site_403', t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state['values']['site_403'])));
1583 }
1584 // Validate 404 error path.
1585 if (!empty($form_state['values']['site_404']) && !drupal_valid_path($form_state['values']['site_404'])) {
1586 form_set_error('site_404', t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state['values']['site_404'])));
1587 }
1588 }
1589
1596 function system_cron_settings() {
1597 global $base_url;
1598 $form['description'] = array(
1599 '#markup' => '<p>' . t('Cron takes care of running periodic tasks like checking for updates and indexing content for search.') . '</p>',
1600 );
1601 $form['run'] = array(
1602 '#type' => 'submit',
1603 '#value' => t('Run cron'),
1604 '#submit' => array('system_run_cron_submit'),
1605 );
1606 $status = '<p>' . t('Last run: %cron-last ago.', array('%cron-last' => format_interval(REQUEST_TIME - variable_get('cron_last')),)) . '</p>';
1607 $form['status'] = array(
1608 '#markup' => $status,
1609 );
1610
1611 $form['cron_url'] = array(
1612 '#markup' => '<p>' . t('To run cron from outside the site, go to <a href="!cron">!cron</a>', array('!cron' => url($base_url . '/cron.php', array('external' => TRUE, 'query' => array('cron_key' => variable_get('cron_key', 'drupal')))))) . '</p>',
1613 );
1614
1615 $form['cron'] = array(
1616 '#type' => 'fieldset',
1617 );
1618 $form['cron']['cron_safe_threshold'] = array(
1619 '#type' => 'select',
1620 '#title' => t('Run cron every'),
1621 '#description' => t('More information about setting up scheduled tasks can be found by <a href="@url">reading the cron tutorial on drupal.org</a>.', array('@url' => url('http://drupal.org/cron'))),
1622 '#default_value' => variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD),
1623 '#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 43200, 86400, 604800), 'format_interval'),
1624 );
1625
1626 return system_settings_form($form);
1627 }
1628
1634 function system_run_cron_submit($form, &$form_state) {
1635 // Run cron manually from Cron form.
1636 if (drupal_cron_run()) {
1637 drupal_set_message(t('Cron run successfully.'));
1638 }
1639 else {
1640 drupal_set_message(t('Cron run failed.'), 'error');
1641 }
1642
1643 drupal_goto('admin/config/system/cron');
1644 }
1645
1652 function system_logging_settings() {
1653 $form['error_level'] = array(
1654 '#type' => 'radios',
1655 '#title' => t('Error messages to display'),
1656 '#default_value' => variable_get('error_level', ERROR_REPORTING_DISPLAY_ALL),
1657 '#options' => array(
1658 ERROR_REPORTING_HIDE => t('None'),
1659 ERROR_REPORTING_DISPLAY_SOME => t('Errors and warnings'),
1660 ERROR_REPORTING_DISPLAY_ALL => t('All messages'),
1661 ),
1662 '#description' => t('It is recommended that sites running on production environments do not display any errors.'),
1663 );
1664
1665 return system_settings_form($form);
1666 }
1667
1674 function system_performance_settings() {
1675 drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
1676
1677 $form['clear_cache'] = array(
1678 '#type' => 'fieldset',
1679 '#title' => t('Clear cache'),
1680 );
1681
1682 $form['clear_cache']['clear'] = array(
1683 '#type' => 'submit',
1684 '#value' => t('Clear all caches'),
1685 '#submit' => array('system_clear_cache_submit'),
1686 );
1687
1688 $form['caching'] = array(
1689 '#type' => 'fieldset',
1690 '#title' => t('Caching'),
1691 );
1692
1693 $cache = variable_get('cache', 0);
1694 $form['caching']['cache'] = array(
1695 '#type' => 'checkbox',
1696 '#title' => t('Cache pages for anonymous users'),
1697 '#default_value' => $cache,
1698 '#weight' => -2,
1699 );
1700 $period = drupal_map_assoc(array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'format_interval');
1701 $period[0] = '<' . t('none') . '>';
1702 $form['caching']['cache_lifetime'] = array(
1703 '#type' => 'select',
1704 '#title' => t('Minimum cache lifetime'),
1705 '#default_value' => variable_get('cache_lifetime', 0),
1706 '#options' => $period,
1707 '#description' => t('Cached pages will not be re-created until at least this much time has elapsed.')
1708 );
1709 $form['caching']['page_cache_maximum_age'] = array(
1710 '#type' => 'select',
1711 '#title' => t('Expiration of cached pages'),
1712 '#default_value' => variable_get('page_cache_maximum_age', 0),
1713 '#options' => $period,
1714 '#description' => t('The maximum time an external cache can use an old version of a page.')
1715 );
1716
1717 $directory = 'public://';
1718 $is_writable = is_dir($directory) && is_writable($directory);
1719 $disabled = !$is_writable;
1720 $disabled_message = '';
1721 if (!$is_writable) {
1722 $disabled_message = ' ' . t('<strong class="error">Set up the <a href="!file-system">public files directory</a> to make these optimizations available.</strong>', array('!file-system' => url('admin/config/media/file-system')));
1723 }
1724
1725 $form['bandwidth_optimization'] = array(
1726 '#type' => 'fieldset',
1727 '#title' => t('Bandwidth optimization'),
1728 '#description' => t('External resources can be optimized automatically, which can reduce both the size and number of requests made to your website.') . $disabled_message,
1729 );
1730
1731 $js_hide = $cache ? '' : ' class="js-hide"';
1732 $form['bandwidth_optimization']['page_compression'] = array(
1733 '#type' => 'checkbox',
1734 '#title' => t('Compress cached pages.'),
1735 '#default_value' => variable_get('page_compression', TRUE),
1736 '#prefix' => '<div id="page-compression-wrapper"' . $js_hide . '>',
1737 '#suffix' => '</div>',
1738 );
1739 $form['bandwidth_optimization']['preprocess_css'] = array(
1740 '#type' => 'checkbox',
1741 '#title' => t('Aggregate and compress CSS files.'),
1742 '#default_value' => intval(variable_get('preprocess_css', 0) && $is_writable),
1743 '#disabled' => $disabled,
1744 );
1745 $form['bandwidth_optimization']['preprocess_js'] = array(
1746 '#type' => 'checkbox',
1747 '#title' => t('Aggregate JavaScript files.'),
1748 '#default_value' => intval(variable_get('preprocess_js', 0) && $is_writable),
1749 '#disabled' => $disabled,
1750 );
1751
1752 $form['#submit'][] = 'drupal_clear_css_cache';
1753 $form['#submit'][] = 'drupal_clear_js_cache';
1754 // This form allows page compression settings to be changed, which can
1755 // invalidate the page cache, so it needs to be cleared on form submit.
1756 $form['#submit'][] = 'system_clear_page_cache_submit';
1757
1758 return system_settings_form($form);
1759 }
1760
1766 function system_clear_cache_submit($form, &$form_state) {
1767 drupal_flush_all_caches();
1768 drupal_set_message(t('Caches cleared.'));
1769 }
1770
1776 function system_clear_page_cache_submit($form, &$form_state) {
1777 cache_clear_all('*', 'cache_page', TRUE);
1778 }
1779
1786 function system_file_system_settings() {
1787 $form['file_public_path'] = array(
1788 '#type' => 'textfield',
1789 '#title' => t('Public file system path'),
1790 '#default_value' => variable_get('file_public_path', conf_path() . '/files'),
1791 '#maxlength' => 255,
1792 '#description' => t('A local file system path where public files will be stored. This directory must exist and be writable by Drupal. This directory must be relative to the Drupal installation directory and be accessible over the web.'),
1793 '#after_build' => array('system_check_directory'),
1794 );
1795
1796 $form['file_private_path'] = array(
1797 '#type' => 'textfield',
1798 '#title' => t('Private file system path'),
1799 '#default_value' => variable_get('file_private_path', ''),
1800 '#maxlength' => 255,
1801 '#description' => t('An existing local file system path for storing private files. It should be writable by Drupal and not accessible over the web. See the online handbook for <a href="@handbook">more information about securing private files</a>.', array('@handbook' => 'http://drupal.org/documentation/modules/file')),
1802 '#after_build' => array('system_check_directory'),
1803 );
1804
1805 $form['file_temporary_path'] = array(
1806 '#type' => 'textfield',
1807 '#title' => t('Temporary directory'),
1808 '#default_value' => variable_get('file_temporary_path', file_directory_temp()),
1809 '#maxlength' => 255,
1810 '#description' => t('A local file system path where temporary files will be stored. This directory should not be accessible over the web.'),
1811 '#after_build' => array('system_check_directory'),
1812 );
1813 // Any visible, writeable wrapper can potentially be used for the files
1814 // directory, including a remote file system that integrates with a CDN.
1815 foreach (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $info) {
1816 $options[$scheme] = check_plain($info['description']);
1817 }
1818
1819 if (!empty($options)) {
1820 $form['file_default_scheme'] = array(
1821 '#type' => 'radios',
1822 '#title' => t('Default download method'),
1823 '#default_value' => variable_get('file_default_scheme', isset($options['public']) ? 'public' : key($options)),
1824 '#options' => $options,
1825 '#description' => t('This setting is used as the preferred download method. The use of public files is more efficient, but does not provide any access control.'),
1826 );
1827 }
1828
1829 return system_settings_form($form);
1830 }
1831
1838 function system_image_toolkit_settings() {
1839 $toolkits_available = image_get_available_toolkits();
1840 $current_toolkit = image_get_toolkit();
1841
1842 if (count($toolkits_available) == 0) {
1843 variable_del('image_toolkit');
1844 $form['image_toolkit_help'] = array(
1845 '#markup' => t("No image toolkits were detected. Drupal includes support for <a href='!gd-link'>PHP's built-in image processing functions</a> but they were not detected on this system. You should consult your system administrator to have them enabled, or try using a third party toolkit.", array('gd-link' => url('http://php.net/gd'))),
1846 );
1847 return $form;
1848 }
1849
1850 if (count($toolkits_available) > 1) {
1851 $form['image_toolkit'] = array(
1852 '#type' => 'radios',
1853 '#title' => t('Select an image processing toolkit'),
1854 '#default_value' => variable_get('image_toolkit', $current_toolkit),
1855 '#options' => $toolkits_available
1856 );
1857 }
1858 else {
1859 variable_set('image_toolkit', key($toolkits_available));
1860 }
1861
1862 // Get the toolkit's settings form.
1863 $function = 'image_' . $current_toolkit . '_settings';
1864 if (function_exists($function)) {
1865 $form['image_toolkit_settings'] = $function();
1866 }
1867
1868 return system_settings_form($form);
1869 }
1870
1877 function system_rss_feeds_settings() {
1878 $form['feed_description'] = array(
1879 '#type' => 'textarea',
1880 '#title' => t('Feed description'),
1881 '#default_value' => variable_get('feed_description', ''),
1882 '#description' => t('Description of your site, included in each feed.')
1883 );
1884 $form['feed_default_items'] = array(
1885 '#type' => 'select',
1886 '#title' => t('Number of items in each feed'),
1887 '#default_value' => variable_get('feed_default_items', 10),
1888 '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
1889 '#description' => t('Default number of items to include in each feed.')
1890 );
1891 $form['feed_item_length'] = array(
1892 '#type' => 'select',
1893 '#title' => t('Feed content'),
1894 '#default_value' => variable_get('feed_item_length', 'fulltext'),
1895 '#options' => array('title' => t('Titles only'), 'teaser' => t('Titles plus teaser'), 'fulltext' => t('Full text')),
1896 '#description' => t('Global setting for the default display of content items in each feed.')
1897 );
1898
1899 return system_settings_form($form);
1900 }
1901
1909 function system_regional_settings() {
1910 include_once DRUPAL_ROOT . '/includes/locale.inc';
1911 $countries = country_get_list();
1912
1913 // Date settings:
1914 $zones = system_time_zones();
1915
1916 $form['locale'] = array(
1917 '#type' => 'fieldset',
1918 '#title' => t('Locale'),
1919 );
1920
1921 $form['locale']['site_default_country'] = array(
1922 '#type' => 'select',
1923 '#title' => t('Default country'),
1924 '#empty_value' => '',
1925 '#default_value' => variable_get('site_default_country', ''),
1926 '#options' => $countries,
1927 '#attributes' => array('class' => array('country-detect')),
1928 );
1929
1930 $form['locale']['date_first_day'] = array(
1931 '#type' => 'select',
1932 '#title' => t('First day of week'),
1933 '#default_value' => variable_get('date_first_day', 0),
1934 '#options' => array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')),
1935 );
1936
1937 $form['timezone'] = array(
1938 '#type' => 'fieldset',
1939 '#title' => t('Time zones'),
1940 );
1941
1942 $form['timezone']['date_default_timezone'] = array(
1943 '#type' => 'select',
1944 '#title' => t('Default time zone'),
1945 '#default_value' => variable_get('date_default_timezone', date_default_timezone_get()),
1946 '#options' => $zones,
1947 );
1948
1949 $configurable_timezones = variable_get('configurable_timezones', 1);
1950 $form['timezone']['configurable_timezones'] = array(
1951 '#type' => 'checkbox',
1952 '#title' => t('Users may set their own time zone.'),
1953 '#default_value' => $configurable_timezones,
1954 );
1955
1956 $form['timezone']['configurable_timezones_wrapper'] = array(
1957 '#type' => 'container',
1958 '#states' => array(
1959 // Hide the user configured timezone settings when users are forced to use
1960 // the default setting.
1961 'invisible' => array(
1962 'input[name="configurable_timezones"]' => array('checked' => FALSE),
1963 ),
1964 ),
1965 );
1966 $form['timezone']['configurable_timezones_wrapper']['empty_timezone_message'] = array(
1967 '#type' => 'checkbox',
1968 '#title' => t('Remind users at login if their time zone is not set.'),
1969 '#default_value' => variable_get('empty_timezone_message', 0),
1970 '#description' => t('Only applied if users may set their own time zone.')
1971 );
1972
1973 $form['timezone']['configurable_timezones_wrapper']['user_default_timezone'] = array(
1974 '#type' => 'radios',
1975 '#title' => t('Time zone for new users'),
1976 '#default_value' => variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT),
1977 '#options' => array(
1978 DRUPAL_USER_TIMEZONE_DEFAULT => t('Default time zone.'),
1979 DRUPAL_USER_TIMEZONE_EMPTY => t('Empty time zone.'),
1980 DRUPAL_USER_TIMEZONE_SELECT => t('Users may set their own time zone at registration.'),
1981 ),
1982 '#description' => t('Only applied if users may set their own time zone.')
1983 );
1984
1985 return system_settings_form($form);
1986 }
1987
1994 function system_date_time_settings() {
1995 // Get list of all available date types.
1996 drupal_static_reset('system_get_date_types');
1997 $format_types = system_get_date_types();
1998
1999 // Get list of all available date formats.
2000 $all_formats = array();
2001 drupal_static_reset('system_get_date_formats');
2002 $date_formats = system_get_date_formats(); // Call this to rebuild the list, and to have default list.
2003 foreach ($date_formats as $type => $format_info) {
2004 $all_formats = array_merge($all_formats, $format_info);
2005 }
2006 $custom_formats = system_get_date_formats('custom');
2007 if (!empty($format_types)) {
2008 foreach ($format_types as $type => $type_info) {
2009 // If a system type, only show the available formats for that type and
2010 // custom ones.
2011 if ($type_info['locked'] == 1) {
2012 $formats = system_get_date_formats($type);
2013 if (empty($formats)) {
2014 $formats = $all_formats;
2015 }
2016 elseif (!empty($custom_formats)) {
2017 $formats = array_merge($formats, $custom_formats);
2018 }
2019 }
2020 // If a user configured type, show all available date formats.
2021 else {
2022 $formats = $all_formats;
2023 }
2024
2025 $choices = array();
2026 foreach ($formats as $f => $format) {
2027 $choices[$f] = format_date(REQUEST_TIME, 'custom', $f);
2028 }
2029 reset($formats);
2030 $default = variable_get('date_format_' . $type, key($formats));
2031
2032 // Get date type info for this date type.
2033 $type_info = system_get_date_types($type);
2034 $form['formats']['#theme'] = 'system_date_time_settings';
2035
2036 // Show date format select list.
2037 $form['formats']['format']['date_format_' . $type] = array(
2038 '#type' => 'select',
2039 '#title' => check_plain($type_info['title']),
2040 '#attributes' => array('class' => array('date-format')),
2041 '#default_value' => (isset($choices[$default]) ? $default : 'custom'),
2042 '#options' => $choices,
2043 );
2044
2045 // If this isn't a system provided type, allow the user to remove it from
2046 // the system.
2047 if ($type_info['locked'] == 0) {
2048 $form['formats']['delete']['date_format_' . $type . '_delete'] = array(
2049 '#type' => 'link',
2050 '#title' => t('delete'),
2051 '#href' => 'admin/config/regional/date-time/types/' . $type . '/delete',
2052 );
2053 }
2054 }
2055 }
2056
2057 // Display a message if no date types configured.
2058 $form['#empty_text'] = t('No date types available. <a href="@link">Add date type</a>.', array('@link' => url('admin/config/regional/date-time/types/add')));
2059
2060 return system_settings_form($form);
2061 }
2062
2072 function theme_system_date_time_settings($variables) {
2073 $form = $variables['form'];
2074 $header = array(
2075 t('Date type'),
2076 t('Format'),
2077 t('Operations'),
2078 );
2079
2080 foreach (element_children($form['format']) as $key) {
2081 $delete_key = $key . '_delete';
2082 $row = array();
2083 $row[] = $form['format'][$key]['#title'];
2084 $form['format'][$key]['#title_display'] = 'invisible';
2085 $row[] = array('data' => drupal_render($form['format'][$key]));
2086 $row[] = array('data' => drupal_render($form['delete'][$delete_key]));
2087 $rows[] = $row;
2088 }
2089
2090 $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'system-date-types')));
2091 $output .= drupal_render_children($form);
2092
2093 return $output;
2094 }
2095
2096
2104 function system_add_date_format_type_form($form, &$form_state) {
2105 $form['date_type'] = array(
2106 '#title' => t('Date type'),
2107 '#type' => 'textfield',
2108 '#required' => TRUE,
2109 );
2110 $form['machine_name'] = array(
2111 '#type' => 'machine_name',
2112 '#machine_name' => array(
2113 'exists' => 'system_get_date_types',
2114 'source' => array('date_type'),
2115 ),
2116 );
2117
2118 // Get list of all available date formats.
2119 $formats = array();
2120 drupal_static_reset('system_get_date_formats');
2121 $date_formats = system_get_date_formats(); // Call this to rebuild the list, and to have default list.
2122 foreach ($date_formats as $type => $format_info) {
2123 $formats = array_merge($formats, $format_info);
2124 }
2125 $custom_formats = system_get_date_formats('custom');
2126 if (!empty($custom_formats)) {
2127 $formats = array_merge($formats, $custom_formats);
2128 }
2129 $choices = array();
2130 foreach ($formats as $f => $format) {
2131 $choices[$f] = format_date(REQUEST_TIME, 'custom', $f);
2132 }
2133 // Show date format select list.
2134 $form['date_format'] = array(
2135 '#type' => 'select',
2136 '#title' => t('Date format'),
2137 '#attributes' => array('class' => array('date-format')),
2138 '#options' => $choices,
2139 '#required' => TRUE,
2140 );
2141
2142 $form['actions'] = array('#type' => 'actions');
2143 $form['actions']['submit'] = array(
2144 '#type' => 'submit',
2145 '#value' => t('Add date type'),
2146 );
2147
2148 $form['#validate'][] = 'system_add_date_format_type_form_validate';
2149 $form['#submit'][] = 'system_add_date_format_type_form_submit';
2150
2151 return $form;
2152 }
2153
2157 function system_add_date_format_type_form_validate($form, &$form_state) {
2158 if (!empty($form_state['values']['machine_name']) && !empty($form_state['values']['date_type'])) {
2159 if (!preg_match("/^[a-zA-Z0-9_]+$/", trim($form_state['values']['machine_name']))) {
2160 form_set_error('machine_name', t('The date type must contain only alphanumeric characters and underscores.'));
2161 }
2162 $types = system_get_date_types();
2163 if (in_array(trim($form_state['values']['machine_name']), array_keys($types))) {
2164 form_set_error('machine_name', t('This date type already exists. Enter a unique type.'));
2165 }
2166 }
2167 }
2168
2172 function system_add_date_format_type_form_submit($form, &$form_state) {
2173 $machine_name = trim($form_state['values']['machine_name']);
2174
2175 $format_type = array();
2176 $format_type['title'] = trim($form_state['values']['date_type']);
2177 $format_type['type'] = $machine_name;
2178 $format_type['locked'] = 0;
2179 $format_type['is_new'] = 1;
2180 system_date_format_type_save($format_type);
2181 variable_set('date_format_' . $machine_name, $form_state['values']['date_format']);
2182
2183 drupal_set_message(t('New date type added successfully.'));
2184 $form_state['redirect'] = 'admin/config/regional/date-time';
2185 }
2186
2190 function system_date_time_lookup() {
2191 $result = format_date(REQUEST_TIME, 'custom', $_GET['format']);
2192 drupal_json_output($result);
2193 }
2194
2201 function system_site_maintenance_mode() {
2202 $form['maintenance_mode'] = array(
2203 '#type' => 'checkbox',
2204 '#title' => t('Put site into maintenance mode'),
2205 '#default_value' => variable_get('maintenance_mode', 0),
2206 '#description' => t('When enabled, only users with the "Use the site in maintenance mode" <a href="@permissions-url">permission</a> are able to access your site to perform maintenance; all other visitors see the maintenance mode message configured below. Authorized users can log in directly via the <a href="@user-login">user login</a> page.', array('@permissions-url' => url('admin/people/permissions'), '@user-login' => url('user'))),
2207 );
2208 $form['maintenance_mode_message'] = array(
2209 '#type' => 'textarea',
2210 '#title' => t('Maintenance mode message'),
2211 '#default_value' => variable_get('maintenance_mode_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))),
2212 '#description' => t('Message to show visitors when the site is in maintenance mode.')
2213 );
2214
2215 return system_settings_form($form);
2216 }
2217
2224 function system_clean_url_settings($form, &$form_state) {
2225 $available = FALSE;
2226 $conflict = FALSE;
2227
2228 // If the request URI is a clean URL, clean URLs must be available.
2229 // Otherwise, run a test.
2230 if (strpos(request_uri(), '?q=') === FALSE && strpos(request_uri(), '&q=') === FALSE) {
2231 $available = TRUE;
2232 }
2233 else {
2234 $request = drupal_http_request($GLOBALS['base_url'] . '/admin/config/search/clean-urls/check');
2235 // If the request returns HTTP 200, clean URLs are available.
2236 if (isset($request->code) && $request->code == 200) {
2237 $available = TRUE;
2238 // If the user started the clean URL test, provide explicit feedback.
2239 if (isset($form_state['input']['clean_url_test_execute'])) {
2240 drupal_set_message(t('The clean URL test passed.'));
2241 }
2242 }
2243 else {
2244 // If the test failed while clean URLs are enabled, make sure clean URLs
2245 // can be disabled.
2246 if (variable_get('clean_url', 0)) {
2247 $conflict = TRUE;
2248 // Warn the user of a conflicting situation, unless after processing
2249 // a submitted form.
2250 if (!isset($form_state['input']['op'])) {
2251 drupal_set_message(t('Clean URLs are enabled, but the clean URL test failed. Uncheck the box below to disable clean URLs.'), 'warning');
2252 }
2253 }
2254 // If the user started the clean URL test, provide explicit feedback.
2255 elseif (isset($form_state['input']['clean_url_test_execute'])) {
2256 drupal_set_message(t('The clean URL test failed.'), 'warning');
2257 }
2258 }
2259 }
2260
2261 // Show the enable/disable form if clean URLs are available or if the user
2262 // must be able to resolve a conflicting setting.
2263 if ($available || $conflict) {
2264 $form['clean_url'] = array(
2265 '#type' => 'checkbox',
2266 '#title' => t('Enable clean URLs'),
2267 '#default_value' => variable_get('clean_url', 0),
2268 '#description' => t('Use URLs like <code>example.com/user</code> instead of <code>example.com/?q=user</code>.'),
2269 );
2270 $form = system_settings_form($form);
2271 if ($conflict) {
2272 // $form_state['redirect'] needs to be set to the non-clean URL,
2273 // otherwise the setting is not saved.
2274 $form_state['redirect'] = url('', array('query' => array('q' => '/admin/config/search/clean-urls')));
2275 }
2276 }
2277 // Show the clean URLs test form.
2278 else {
2279 drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
2280
2281 $form_state['redirect'] = url('admin/config/search/clean-urls');
2282 $form['clean_url_description'] = array(
2283 '#type' => 'markup',
2284 '#markup' => '<p>' . t('Use URLs like <code>example.com/user</code> instead of <code>example.com/?q=user</code>.'),
2285 );
2286 // Explain why the user is seeing this page and what to expect after
2287 // clicking the 'Run the clean URL test' button.
2288 $form['clean_url_test_result'] = array(
2289 '#type' => 'markup',
2290 '#markup' => '<p>' . t('Clean URLs cannot be enabled. If you are directed to this page or to a <em>Page not found (404)</em> error after testing for clean URLs, see the <a href="@handbook">online handbook</a>.', array('@handbook' => 'http://drupal.org/node/15365')) . '</p>',
2291 );
2292 $form['actions'] = array(
2293 '#type' => 'actions',
2294 'clean_url_test' => array(
2295 '#type' => 'submit',
2296 '#value' => t('Run the clean URL test'),
2297 ),
2298 );
2299 $form['clean_url_test_execute'] = array(
2300 '#type' => 'hidden',
2301 '#value' => 1,
2302 );
2303 }
2304
2305 return $form;
2306 }
2307
2314 function system_status($check = FALSE) {
2315 // Load .install files
2316 include_once DRUPAL_ROOT . '/includes/install.inc';
2317 drupal_load_updates();
2318
2319 // Check run-time requirements and status information.
2320 $requirements = module_invoke_all('requirements', 'runtime');
2321 usort($requirements, '_system_sort_requirements');
2322
2323 if ($check) {
2324 return drupal_requirements_severity($requirements) == REQUIREMENT_ERROR;
2325 }
2326 // MySQL import might have set the uid of the anonymous user to autoincrement
2327 // value. Let's try fixing it. See http://drupal.org/node/204411
2328 db_update('users')
2329 ->expression('uid', 'uid - uid')
2330 ->condition('name', '')
2331 ->condition('pass', '')
2332 ->condition('status', 0)
2333 ->execute();
2334 return theme('status_report', array('requirements' => $requirements));
2335 }
2336
2340 function system_run_cron() {
2341 // Run cron manually
2342 if (drupal_cron_run()) {
2343 drupal_set_message(t('Cron ran successfully.'));
2344 }
2345 else {
2346 drupal_set_message(t('Cron run failed.'), 'error');
2347 }
2348
2349 drupal_goto('admin/reports/status');
2350 }
2351
2355 function system_php() {
2356 phpinfo();
2357 drupal_exit();
2358 }
2359
2363 function system_batch_page() {
2364 require_once DRUPAL_ROOT . '/includes/batch.inc';
2365 $output = _batch_page();
2366
2367 if ($output === FALSE) {
2368 drupal_access_denied();
2369 }
2370 elseif (isset($output)) {
2371 // Force a page without blocks or messages to
2372 // display a list of collected messages later.
2373 drupal_set_page_content($output);
2374 $page = element_info('page');
2375 $page['#show_messages'] = FALSE;
2376 return $page;
2377 }
2378 }
2379
2394 function theme_admin_block($variables) {
2395 $block = $variables['block'];
2396 $output = '';
2397
2398 // Don't display the block if it has no content to display.
2399 if (empty($block['show'])) {
2400 return $output;
2401 }
2402
2403 $output .= '<div class="admin-panel">';
2404 if (!empty($block['title'])) {
2405 $output .= '<h3>' . $block['title'] . '</h3>';
2406 }
2407 if (!empty($block['content'])) {
2408 $output .= '<div class="body">' . $block['content'] . '</div>';
2409 }
2410 else {
2411 $output .= '<div class="description">' . $block['description'] . '</div>';
2412 }
2413 $output .= '</div>';
2414
2415 return $output;
2416 }
2417
2430 function theme_admin_block_content($variables) {
2431 $content = $variables['content'];
2432 $output = '';
2433
2434 if (!empty($content)) {
2435 $class = 'admin-list';
2436 if ($compact = system_admin_compact_mode()) {
2437 $class .= ' compact';
2438 }
2439 $output .= '<dl class="' . $class . '">';
2440 foreach ($content as $item) {
2441 $output .= '<dt>' . l($item['title'], $item['href'], $item['localized_options']) . '</dt>';
2442 if (!$compact && isset($item['description'])) {
2443 $output .= '<dd>' . filter_xss_admin($item['description']) . '</dd>';
2444 }
2445 }
2446 $output .= '</dl>';
2447 }
2448 return $output;
2449 }
2450
2463 function theme_admin_page($variables) {
2464 $blocks = $variables['blocks'];
2465
2466 $stripe = 0;
2467 $container = array();
2468
2469 foreach ($blocks as $block) {
2470 if ($block_output = theme('admin_block', array('block' => $block))) {
2471 if (empty($block['position'])) {
2472 // perform automatic striping.
2473 $block['position'] = ++$stripe % 2 ? 'left' : 'right';
2474 }
2475 if (!isset($container[$block['position']])) {
2476 $container[$block['position']] = '';
2477 }
2478 $container[$block['position']] .= $block_output;
2479 }
2480 }
2481
2482 $output = '<div class="admin clearfix">';
2483 $output .= theme('system_compact_link');
2484
2485 foreach ($container as $id => $data) {
2486 $output .= '<div class="' . $id . ' clearfix">';
2487 $output .= $data;
2488 $output .= '</div>';
2489 }
2490 $output .= '</div>';
2491 return $output;
2492 }
2493
2503 function theme_system_admin_index($variables) {
2504 $menu_items = $variables['menu_items'];
2505
2506 $stripe = 0;
2507 $container = array('left' => '', 'right' => '');
2508 $flip = array('left' => 'right', 'right' => 'left');
2509 $position = 'left';
2510
2511 // Iterate over all modules.
2512 foreach ($menu_items as $module => $block) {
2513 list($description, $items) = $block;
2514
2515 // Output links.
2516 if (count($items)) {
2517 $block = array();
2518 $block['title'] = $module;
2519 $block['content'] = theme('admin_block_content', array('content' => $items));
2520 $block['description'] = t($description);
2521 $block['show'] = TRUE;
2522
2523 if ($block_output = theme('admin_block', array('block' => $block))) {
2524 if (!isset($block['position'])) {
2525 // Perform automatic striping.
2526 $block['position'] = $position;
2527 $position = $flip[$position];
2528 }
2529 $container[$block['position']] .= $block_output;
2530 }
2531 }
2532 }
2533
2534 $output = '<div class="admin clearfix">';
2535 $output .= theme('system_compact_link');
2536 foreach ($container as $id => $data) {
2537 $output .= '<div class="' . $id . ' clearfix">';
2538 $output .= $data;
2539 $output .= '</div>';
2540 }
2541 $output .= '</div>';
2542
2543 return $output;
2544 }
2545
2555 function theme_status_report($variables) {
2556 $requirements = $variables['requirements'];
2557 $severities = array(
2558 REQUIREMENT_INFO => array(
2559 'title' => t('Info'),
2560 'class' => 'info',
2561 ),
2562 REQUIREMENT_OK => array(
2563 'title' => t('OK'),
2564 'class' => 'ok',
2565 ),
2566 REQUIREMENT_WARNING => array(
2567 'title' => t('Warning'),
2568 'class' => 'warning',
2569 ),
2570 REQUIREMENT_ERROR => array(
2571 'title' => t('Error'),
2572 'class' => 'error',
2573 ),
2574 );
2575 $output = '<table class="system-status-report">';
2576
2577 foreach ($requirements as $requirement) {
2578 if (empty($requirement['#type'])) {
2579 $severity = $severities[isset($requirement['severity']) ? (int) $requirement['severity'] : REQUIREMENT_OK];
2580 $severity['icon'] = '<div title="' . $severity['title'] . '"><span class="element-invisible">' . $severity['title'] . '</span></div>';
2581
2582 // Output table row(s)
2583 if (!empty($requirement['description'])) {
2584 $output .= '<tr class="' . $severity['class'] . ' merge-down"><td class="status-icon">' . $severity['icon'] . '</td><td class="status-title">' . $requirement['title'] . '</td><td class="status-value">' . $requirement['value'] . '</td></tr>';
2585 $output .= '<tr class="' . $severity['class'] . ' merge-up"><td colspan="3" class="status-description">' . $requirement['description'] . '</td></tr>';
2586 }
2587 else {
2588 $output .= '<tr class="' . $severity['class'] . '"><td class="status-icon">' . $severity['icon'] . '</td><td class="status-title">' . $requirement['title'] . '</td><td class="status-value">' . $requirement['value'] . '</td></tr>';
2589 }
2590 }
2591 }
2592
2593 $output .= '</table>';
2594 return $output;
2595 }
2596
2606 function theme_system_modules_fieldset($variables) {
2607 $form = $variables['form'];
2608
2609 // Individual table headers.
2610 $rows = array();
2611 // Iterate through all the modules, which are
2612 // children of this fieldset.
2613 foreach (element_children($form) as $key) {
2614 // Stick it into $module for easier accessing.
2615 $module = $form[$key];
2616 $row = array();
2617 unset($module['enable']['#title']);
2618 $row[] = array('class' => array('checkbox'), 'data' => drupal_render($module['enable']));
2619 $label = '<label';
2620 if (isset($module['enable']['#id'])) {
2621 $label .= ' for="' . $module['enable']['#id'] . '"';
2622 }
2623 $row[] = $label . '><strong>' . drupal_render($module['name']) . '</strong></label>';
2624 $row[] = drupal_render($module['version']);
2625 // Add the description, along with any modules it requires.
2626 $description = drupal_render($module['description']);
2627 if ($module['#requires']) {
2628 $description .= '<div class="admin-requirements">' . t('Requires: !module-list', array('!module-list' => implode(', ', $module['#requires']))) . '</div>';
2629 }
2630 if ($module['#required_by']) {
2631 $description .= '<div class="admin-requirements">' . t('Required by: !module-list', array('!module-list' => implode(', ', $module['#required_by']))) . '</div>';
2632 }
2633 $row[] = array('data' => $description, 'class' => array('description'));
2634 // Display links (such as help or permissions) in their own columns.
2635 foreach (array('help', 'permissions', 'configure') as $key) {
2636 $row[] = array('data' => drupal_render($module['links'][$key]), 'class' => array($key));
2637 }
2638 $rows[] = $row;
2639 }
2640
2641 return theme('table', array('header' => $form['#header'], 'rows' => $rows));
2642 }
2643
2653 function theme_system_modules_incompatible($variables) {
2654 return '<div class="incompatible">' . $variables['message'] . '</div>';
2655 }
2656
2666 function theme_system_modules_uninstall($variables) {
2667 $form = $variables['form'];
2668
2669 // No theming for the confirm form.
2670 if (isset($form['confirm'])) {
2671 return drupal_render($form);
2672 }
2673
2674 // Table headers.
2675 $header = array(t('Uninstall'),
2676 t('Name'),
2677 t('Description'),
2678 );
2679
2680 // Display table.
2681 $rows = array();
2682 foreach (element_children($form['modules']) as $module) {
2683 if (!empty($form['modules'][$module]['#required_by'])) {
2684 $disabled_message = format_plural(count($form['modules'][$module]['#required_by']),
2685 'To uninstall @module, the following module must be uninstalled first: @required_modules',
2686 'To uninstall @module, the following modules must be uninstalled first: @required_modules',
2687 array('@module' => $form['modules'][$module]['#module_name'], '@required_modules' => implode(', ', $form['modules'][$module]['#required_by'])));
2688 $disabled_message = '<div class="admin-requirements">' . $disabled_message . '</div>';
2689 }
2690 else {
2691 $disabled_message = '';
2692 }
2693 $rows[] = array(
2694 array('data' => drupal_render($form['uninstall'][$module]), 'align' => 'center'),
2695 '<strong><label for="' . $form['uninstall'][$module]['#id'] . '">' . drupal_render($form['modules'][$module]['name']) . '</label></strong>',
2696 array('data' => drupal_render($form['modules'][$module]['description']) . $disabled_message, 'class' => array('description')),
2697 );
2698 }
2699
2700 $output = theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No modules are available to uninstall.')));
2701 $output .= drupal_render_children($form);
2702
2703 return $output;
2704 }
2705
2715 function theme_system_themes_page($variables) {
2716 $theme_groups = $variables['theme_groups'];
2717
2718 $output = '<div id="system-themes-page">';
2719
2720 foreach ($variables['theme_group_titles'] as $state => $title) {
2721 if (!count($theme_groups[$state])) {
2722 // Skip this group of themes if no theme is there.
2723 continue;
2724 }
2725 // Start new theme group.
2726 $output .= '<div class="system-themes-list system-themes-list-'. $state .' clearfix"><h2>'. $title .'</h2>';
2727
2728 foreach ($theme_groups[$state] as $theme) {
2729
2730 // Theme the screenshot.
2731 $screenshot = $theme->screenshot ? theme('image', $theme->screenshot) : '<div class="no-screenshot">' . t('no screenshot') . '</div>';
2732
2733 // Localize the theme description.
2734 $description = t($theme->info['description']);
2735
2736 // Style theme info
2737 $notes = count($theme->notes) ? ' (' . join(', ', $theme->notes) . ')' : '';
2738 $theme->classes[] = 'theme-selector';
2739 $theme->classes[] = 'clearfix';
2740 $output .= '<div class="'. join(' ', $theme->classes) .'">' . $screenshot . '<div class="theme-info"><h3>' . $theme->info['name'] . ' ' . (isset($theme->info['version']) ? $theme->info['version'] : '') . $notes . '</h3><div class="theme-description">' . $description . '</div>';
2741
2742 // Make sure to provide feedback on compatibility.
2743 if (!empty($theme->incompatible_core)) {
2744 $output .= '<div class="incompatible">' . t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => DRUPAL_CORE_COMPATIBILITY)) . '</div>';
2745 }
2746 elseif (!empty($theme->incompatible_php)) {
2747 if (substr_count($theme->info['php'], '.') < 2) {
2748 $theme->info['php'] .= '.*';
2749 }
2750 $output .= '<div class="incompatible">' . t('This theme requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $theme->info['php'], '!php_version' => phpversion())) . '</div>';
2751 }
2752 else {
2753 $output .= theme('links', array('links' => $theme->operations, 'attributes' => array('class' => array('operations', 'clearfix'))));
2754 }
2755 $output .= '</div></div>';
2756 }
2757 $output .= '</div>';
2758 }
2759 $output .= '</div>';
2760
2761 return $output;
2762 }
2763
2767 function system_date_delete_format_form($form, &$form_state, $dfid) {
2768 $form['dfid'] = array(
2769 '#type' => 'value',
2770 '#value' => $dfid,
2771 );
2772 $format = system_get_date_format($dfid);
2773
2774 $output = confirm_form($form,
2775 t('Are you sure you want to remove the format %format?', array('%format' => format_date(REQUEST_TIME, 'custom', $format->format))),
2776 'admin/config/regional/date-time/formats',
2777 t('This action cannot be undone.'),
2778 t('Remove'), t('Cancel'),
2779 'confirm'
2780 );
2781
2782 return $output;
2783 }
2784
2788 function system_date_delete_format_form_submit($form, &$form_state) {
2789 if ($form_state['values']['confirm']) {
2790 $format = system_get_date_format($form_state['values']['dfid']);
2791 system_date_format_delete($form_state['values']['dfid']);
2792 drupal_set_message(t('Removed date format %format.', array('%format' => format_date(REQUEST_TIME, 'custom', $format->format))));
2793 $form_state['redirect'] = 'admin/config/regional/date-time/formats';
2794 }
2795 }
2796
2800 function system_delete_date_format_type_form($form, &$form_state, $format_type) {
2801 $form['format_type'] = array(
2802 '#type' => 'value',
2803 '#value' => $format_type,
2804 );
2805 $type_info = system_get_date_types($format_type);
2806
2807 $output = confirm_form($form,
2808 t('Are you sure you want to remove the date type %type?', array('%type' => $type_info['title'])),
2809 'admin/config/regional/date-time',
2810 t('This action cannot be undone.'),
2811 t('Remove'), t('Cancel'),
2812 'confirm'
2813 );
2814
2815 return $output;
2816 }
2817
2821 function system_delete_date_format_type_form_submit($form, &$form_state) {
2822 if ($form_state['values']['confirm']) {
2823 $type_info = system_get_date_types($form_state['values']['format_type']);
2824 system_date_format_type_delete($form_state['values']['format_type']);
2825 drupal_set_message(t('Removed date type %type.', array('%type' => $type_info['title'])));
2826 $form_state['redirect'] = 'admin/config/regional/date-time';
2827 }
2828 }
2829
2830
2834 function system_date_time_formats() {
2835 $header = array(t('Format'), array('data' => t('Operations'), 'colspan' => '2'));
2836 $rows = array();
2837
2838 drupal_static_reset('system_get_date_formats');
2839 $formats = system_get_date_formats('custom');
2840 if (!empty($formats)) {
2841 foreach ($formats as $format) {
2842 $row = array();
2843 $row[] = array('data' => format_date(REQUEST_TIME, 'custom', $format['format']));
2844 $row[] = array('data' => l(t('edit'), 'admin/config/regional/date-time/formats/' . $format['dfid'] . '/edit'));
2845 $row[] = array('data' => l(t('delete'), 'admin/config/regional/date-time/formats/' . $format['dfid'] . '/delete'));
2846 $rows[] = $row;
2847 }
2848 }
2849
2850 $build['date_formats_table'] = array(
2851 '#theme' => 'table',
2852 '#header' => $header,
2853 '#rows' => $rows,
2854 '#empty' => t('No custom date formats available. <a href="@link">Add date format</a>.', array('@link' => url('admin/config/regional/date-time/formats/add'))),
2855 );
2856
2857 return $build;
2858 }
2859
2863 function system_configure_date_formats_form($form, &$form_state, $dfid = 0) {
2864 $js_settings = array(
2865 'type' => 'setting',
2866 'data' => array(
2867 'dateTime' => array(
2868 'date-format' => array(
2869 'text' => t('Displayed as'),
2870 'lookup' => url('admin/config/regional/date-time/formats/lookup'),
2871 ),
2872 ),
2873 ),
2874 );
2875
2876 if ($dfid) {
2877 $form['dfid'] = array(
2878 '#type' => 'value',
2879 '#value' => $dfid,
2880 );
2881 $format = system_get_date_format($dfid);
2882 }
2883
2884 $now = ($dfid ? t('Displayed as %date', array('%date' => format_date(REQUEST_TIME, 'custom', $format->format))) : '');
2885
2886 $form['date_format'] = array(
2887 '#type' => 'textfield',
2888 '#title' => t('Format string'),
2889 '#maxlength' => 100,
2890 '#description' => t('A user-defined date format. See the <a href="@url">PHP manual</a> for available options.', array('@url' => 'http://php.net/manual/function.date.php')),
2891 '#default_value' => ($dfid ? $format->format : ''),
2892 '#field_suffix' => ' <small id="edit-date-format-suffix">' . $now . '</small>',
2893 '#attached' => array(
2894 'js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
2895 ),
2896 '#required' => TRUE,
2897 );
2898
2899 $form['actions'] = array('#type' => 'actions');
2900 $form['actions']['update'] = array(
2901 '#type' => 'submit',
2902 '#value' => ($dfid ? t('Save format') : t('Add format')),
2903 );
2904
2905 $form['#validate'][] = 'system_add_date_formats_form_validate';
2906 $form['#submit'][] = 'system_add_date_formats_form_submit';
2907
2908 return $form;
2909 }
2910
2914 function system_add_date_formats_form_validate($form, &$form_state) {
2915 $formats = system_get_date_formats('custom');
2916 $format = trim($form_state['values']['date_format']);
2917 if (!empty($formats) && in_array($format, array_keys($formats)) && (!isset($form_state['values']['dfid']) || $form_state['values']['dfid'] != $formats[$format]['dfid'])) {
2918 form_set_error('date_format', t('This format already exists. Enter a unique format string.'));
2919 }
2920 }
2921
2925 function system_add_date_formats_form_submit($form, &$form_state) {
2926 $format = array();
2927 $format['format'] = trim($form_state['values']['date_format']);
2928 $format['type'] = 'custom';
2929 $format['locked'] = 0;
2930 if (!empty($form_state['values']['dfid'])) {
2931 system_date_format_save($format, $form_state['values']['dfid']);
2932 drupal_set_message(t('Custom date format updated.'));
2933 }
2934 else {
2935 $format['is_new'] = 1;
2936 system_date_format_save($format);
2937 drupal_set_message(t('Custom date format added.'));
2938 }
2939
2940 $form_state['redirect'] = 'admin/config/regional/date-time/formats';
2941 }
2942
2946 function system_actions_manage() {
2947 actions_synchronize();
2948 $actions = actions_list();
2949 $actions_map = actions_actions_map($actions);
2950 $options = array();
2951 $unconfigurable = array();
2952
2953 foreach ($actions_map as $key => $array) {
2954 if ($array['configurable']) {
2955 $options[$key] = $array['label'] . '...';
2956 }
2957 else {
2958 $unconfigurable[] = $array;
2959 }
2960 }
2961
2962 $row = array();
2963 $instances_present = db_query("SELECT aid FROM {actions} WHERE parameters <> ''")->fetchField();
2964 $header = array(
2965 array('data' => t('Action type'), 'field' => 'type'),
2966 array('data' => t('Label'), 'field' => 'label'),
2967 array('data' => $instances_present ? t('Operations') : '', 'colspan' => '2')
2968 );
2969 $query = db_select('actions')->extend('PagerDefault')->extend('TableSort');
2970 $result = $query
2971 ->fields('actions')
2972 ->limit(50)
2973 ->orderByHeader($header)
2974 ->execute();
2975
2976 foreach ($result as $action) {
2977 $row[] = array(
2978 array('data' => $action->type),
2979 array('data' => check_plain($action->label)),
2980 array('data' => $action->parameters ? l(t('configure'), "admin/config/system/actions/configure/$action->aid") : ''),
2981 array('data' => $action->parameters ? l(t('delete'), "admin/config/system/actions/delete/$action->aid") : '')
2982 );
2983 }
2984
2985 if ($row) {
2986 $pager = theme('pager');
2987 if (!empty($pager)) {
2988 $row[] = array(array('data' => $pager, 'colspan' => '3'));
2989 }
2990 $build['system_actions_header'] = array('#markup' => '<h3>' . t('Available actions:') . '</h3>');
2991 $build['system_actions_table'] = array('#markup' => theme('table', array('header' => $header, 'rows' => $row)));
2992 }
2993
2994 if ($actions_map) {
2995 $build['system_actions_manage_form'] = drupal_get_form('system_actions_manage_form', $options);
2996 }
2997
2998 return $build;
2999 }
3000
3014 function system_actions_manage_form($form, &$form_state, $options = array()) {
3015 $form['parent'] = array(
3016 '#type' => 'fieldset',
3017 '#title' => t('Create an advanced action'),
3018 '#attributes' => array('class' => array('container-inline')),
3019 );
3020 $form['parent']['action'] = array(
3021 '#type' => 'select',
3022 '#title' => t('Action'),
3023 '#title_display' => 'invisible',
3024 '#options' => $options,
3025 '#empty_option' => t('Choose an advanced action'),
3026 );
3027 $form['parent']['actions'] = array('#type' => 'actions');
3028 $form['parent']['actions']['submit'] = array(
3029 '#type' => 'submit',
3030 '#value' => t('Create'),
3031 );
3032 return $form;
3033 }
3034
3040 function system_actions_manage_form_submit($form, &$form_state) {
3041 if ($form_state['values']['action']) {
3042 $form_state['redirect'] = 'admin/config/system/actions/configure/' . $form_state['values']['action'];
3043 }
3044 }
3045
3064 function system_actions_configure($form, &$form_state, $action = NULL) {
3065 if ($action === NULL) {
3066 drupal_goto('admin/config/system/actions');
3067 }
3068
3069 $actions_map = actions_actions_map(actions_list());
3070 $edit = array();
3071
3072 // Numeric action denotes saved instance of a configurable action.
3073 if (is_numeric($action)) {
3074 $aid = $action;
3075 // Load stored parameter values from database.
3076 $data = db_query("SELECT * FROM {actions} WHERE aid = :aid", array(':aid' => $aid))->fetch();
3077 $edit['actions_label'] = $data->label;
3078 $edit['actions_type'] = $data->type;
3079 $function = $data->callback;
3080 $action = drupal_hash_base64($data->callback);
3081 $params = unserialize($data->parameters);
3082 if ($params) {
3083 foreach ($params as $name => $val) {
3084 $edit[$name] = $val;
3085 }
3086 }
3087 }
3088 // Otherwise, we are creating a new action instance.
3089 else {
3090 $function = $actions_map[$action]['callback'];
3091 $edit['actions_label'] = $actions_map[$action]['label'];
3092 $edit['actions_type'] = $actions_map[$action]['type'];
3093 }
3094
3095 $form['actions_label'] = array(
3096 '#type' => 'textfield',
3097 '#title' => t('Label'),
3098 '#default_value' => $edit['actions_label'],
3099 '#maxlength' => '255',
3100 '#description' => t('A unique label for this advanced action. This label will be displayed in the interface of modules that integrate with actions, such as Trigger module.'),
3101 '#weight' => -10
3102 );
3103 $action_form = $function . '_form';
3104 $form = array_merge($form, $action_form($edit));
3105 $form['actions_type'] = array(
3106 '#type' => 'value',
3107 '#value' => $edit['actions_type'],
3108 );
3109 $form['actions_action'] = array(
3110 '#type' => 'hidden',
3111 '#value' => $action,
3112 );
3113 // $aid is set when configuring an existing action instance.
3114 if (isset($aid)) {
3115 $form['actions_aid'] = array(
3116 '#type' => 'hidden',
3117 '#value' => $aid,
3118 );
3119 }
3120 $form['actions_configured'] = array(
3121 '#type' => 'hidden',
3122 '#value' => '1',
3123 );
3124 $form['actions'] = array('#type' => 'actions');
3125 $form['actions']['submit'] = array(
3126 '#type' => 'submit',
3127 '#value' => t('Save'),
3128 '#weight' => 13
3129 );
3130
3131 return $form;
3132 }
3133
3137 function system_actions_configure_validate($form, &$form_state) {
3138 $function = actions_function_lookup($form_state['values']['actions_action']) . '_validate';
3139 // Hand off validation to the action.
3140 if (function_exists($function)) {
3141 $function($form, $form_state);
3142 }
3143 }
3144
3148 function system_actions_configure_submit($form, &$form_state) {
3149 $function = actions_function_lookup($form_state['values']['actions_action']);
3150 $submit_function = $function . '_submit';
3151
3152 // Action will return keyed array of values to store.
3153 $params = $submit_function($form, $form_state);
3154 $aid = isset($form_state['values']['actions_aid']) ? $form_state['values']['actions_aid'] : NULL;
3155
3156 actions_save($function, $form_state['values']['actions_type'], $params, $form_state['values']['actions_label'], $aid);
3157 drupal_set_message(t('The action has been successfully saved.'));
3158
3159 $form_state['redirect'] = 'admin/config/system/actions/manage';
3160 }
3161
3168 function system_actions_delete_form($form, &$form_state, $action) {
3169 $form['aid'] = array(
3170 '#type' => 'hidden',
3171 '#value' => $action->aid,
3172 );
3173 return confirm_form($form,
3174 t('Are you sure you want to delete the action %action?', array('%action' => $action->label)),
3175 'admin/config/system/actions/manage',
3176 t('This cannot be undone.'),
3177 t('Delete'),
3178 t('Cancel')
3179 );
3180 }
3181
3187 function system_actions_delete_form_submit($form, &$form_state) {
3188 $aid = $form_state['values']['aid'];
3189 $action = actions_load($aid);
3190 actions_delete($aid);
3191 watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $aid, '%action' => $action->label));
3192 drupal_set_message(t('Action %action was deleted', array('%action' => $action->label)));
3193 $form_state['redirect'] = 'admin/config/system/actions/manage';
3194 }
3195
3202 function system_action_delete_orphans_post($orphaned) {
3203 foreach ($orphaned as $callback) {
3204 drupal_set_message(t("Deleted orphaned action (%action).", array('%action' => $callback)));
3205 }
3206 }
3207
3211 function system_actions_remove_orphans() {
3212 actions_synchronize(TRUE);
3213 drupal_goto('admin/config/system/actions/manage');
3214 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
_batch_page
_batch_page()
Definition: batch.inc:43
system_configure_date_formats_form
system_configure_date_formats_form($form, &$form_state, $dfid=0)
Definition: system.admin.inc:2863
drupal_install_profile_distribution_name
drupal_install_profile_distribution_name()
Definition: install.inc:196
theme_system_date_time_settings
theme_system_date_time_settings($variables)
Definition: system.admin.inc:2072
system_add_date_formats_form_validate
system_add_date_formats_form_validate($form, &$form_state)
Definition: system.admin.inc:2914
$pager
print $pager
Definition: aggregator-wrapper.tpl.php:19
image_get_toolkit
image_get_toolkit()
Definition: image.inc:63
module_list
module_list($refresh=FALSE, $bootstrap_refresh=FALSE, $sort=FALSE, $fixed_list=NULL)
Definition: module.inc:66
system_date_format_delete
system_date_format_delete($dfid)
Definition: system.module:3924
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
system_add_date_format_type_form_validate
system_add_date_format_type_form_validate($form, &$form_state)
Definition: system.admin.inc:2157
system_admin_config_page
system_admin_config_page()
Definition: system.admin.inc:11
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
menu_get_item
menu_get_item($path=NULL, $router_item=NULL)
Definition: menu.inc:447
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
system_modules
system_modules($form, $form_state=array())
Definition: system.admin.inc:788
system_ip_blocking_form
system_ip_blocking_form($form, $form_state, $default_ip)
Definition: system.admin.inc:1410
system_time_zones
system_time_zones($blank=NULL)
Definition: system.module:3335
system_actions_delete_form
system_actions_delete_form($form, &$form_state, $action)
Definition: system.admin.inc:3168
drupal_parse_info_file
drupal_parse_info_file($filename)
Definition: common.inc:7270
DRUPAL_USER_TIMEZONE_SELECT
const DRUPAL_USER_TIMEZONE_SELECT
Definition: system.module:31
actions_function_lookup
actions_function_lookup($hash)
Definition: actions.inc:241
user_validate_mail
user_validate_mail($mail)
Definition: user.module:670
theme_admin_block_content
theme_admin_block_content($variables)
Definition: system.admin.inc:2430
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
system_themes_admin_form
system_themes_admin_form($form, &$form_state, $theme_options)
Definition: system.admin.inc:258
drupal_valid_path
drupal_valid_path($path, $dynamic_allowed=FALSE)
Definition: path.inc:553
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
MENU_ACCESS_DENIED
const MENU_ACCESS_DENIED
Definition: menu.inc:239
$module
print $module
Definition: search-results.tpl.php:28
system_themes_admin_form_submit
system_themes_admin_form_submit($form, &$form_state)
Definition: system.admin.inc:287
system_admin_compact_mode
system_admin_compact_mode()
Definition: system.module:2902
form_state_values_clean
form_state_values_clean(&$form_state)
Definition: form.inc:2159
system_logging_settings
system_logging_settings()
Definition: system.admin.inc:1652
system_actions_manage_form
system_actions_manage_form($form, &$form_state, $options=array())
Definition: system.admin.inc:3014
system_ip_blocking_delete
system_ip_blocking_delete($form, &$form_state, $iid)
Definition: system.admin.inc:1457
drupal_help_arg
drupal_help_arg($arg=array())
Definition: menu.inc:1700
system_site_maintenance_mode
system_site_maintenance_mode()
Definition: system.admin.inc:2201
$page
print $page
Definition: overlay.tpl.php:37
theme_system_admin_index
theme_system_admin_index($variables)
Definition: system.admin.inc:2503
_system_is_incompatible
_system_is_incompatible(&$incompatible, $files, $file)
Definition: system.admin.inc:754
system_admin_menu_block
system_admin_menu_block($item)
Definition: system.module:2117
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
theme_disable
theme_disable($theme_list)
Definition: theme.inc:1554
$name
print $name
Definition: profile-listing.tpl.php:43
system_delete_date_format_type_form_submit
system_delete_date_format_type_form_submit($form, &$form_state)
Definition: system.admin.inc:2821
drupal_json_output
drupal_json_output($var=NULL)
Definition: common.inc:5041
system_php
system_php()
Definition: system.admin.inc:2355
system_ip_blocking
system_ip_blocking($default_ip= '')
Definition: system.admin.inc:1380
system_run_cron_submit
system_run_cron_submit($form, &$form_state)
Definition: system.admin.inc:1634
if
if(version_compare(PHP_VERSION, '5.2.4')< 0)
Definition: install.php:19
system_date_time_settings
system_date_time_settings()
Definition: system.admin.inc:1994
drupal_realpath
drupal_realpath($uri)
Definition: file.inc:2259
$header
print $header
Definition: forum-topic-list.tpl.php:42
system_theme_default
system_theme_default()
Definition: system.admin.inc:346
theme_system_modules_fieldset
theme_system_modules_fieldset($variables)
Definition: system.admin.inc:2606
system_date_delete_format_form_submit
system_date_delete_format_form_submit($form, &$form_state)
Definition: system.admin.inc:2788
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
system_theme_disable
system_theme_disable()
Definition: system.admin.inc:318
drupal_http_request
drupal_http_request($url, array $options=array())
Definition: common.inc:787
drupal_theme_access
drupal_theme_access($theme)
Definition: theme.inc:47
_system_modules_build_row
_system_modules_build_row($info, $extra)
Definition: system.admin.inc:968
module_exists
module_exists($module)
Definition: module.inc:274
ip_address
ip_address()
Definition: bootstrap.inc:2890
system_sort_themes
system_sort_themes($a, $b)
Definition: system.admin.inc:955
theme_admin_page
theme_admin_page($variables)
Definition: system.admin.inc:2463
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
system_add_date_formats_form_submit
system_add_date_formats_form_submit($form, &$form_state)
Definition: system.admin.inc:2925
system_sort_modules_by_info_name
system_sort_modules_by_info_name($a, $b)
Definition: system.admin.inc:948
_menu_link_translate
_menu_link_translate(&$item, $translate=FALSE)
Definition: menu.inc:870
image_get_available_toolkits
image_get_available_toolkits()
Definition: image.inc:42
REQUIREMENT_WARNING
const REQUIREMENT_WARNING
Definition: install.inc:31
$configurable_timezones
$configurable_timezones
Definition: update.php:392
system_rebuild_theme_data
system_rebuild_theme_data()
Definition: system.module:2609
element_info
element_info($type)
Definition: common.inc:6306
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
theme_enable
theme_enable($theme_list)
Definition: theme.inc:1529
drupal_get_installed_schema_version
drupal_get_installed_schema_version($module, $reset=FALSE, $array=FALSE)
Definition: install.inc:146
system_image_toolkit_settings
system_image_toolkit_settings()
Definition: system.admin.inc:1838
REQUIREMENT_OK
const REQUIREMENT_OK
Definition: install.inc:26
request_uri
request_uri()
Definition: bootstrap.inc:1609
actions_actions_map
actions_actions_map($actions)
Definition: actions.inc:216
system_admin_menu_block_page
system_admin_menu_block_page()
Definition: system.admin.inc:66
system_actions_configure_validate
system_actions_configure_validate($form, &$form_state)
Definition: system.admin.inc:3137
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
theme_system_themes_page
theme_system_themes_page($variables)
Definition: system.admin.inc:2715
system_rebuild_module_data
system_rebuild_module_data()
Definition: system.module:2444
system_date_time_lookup
system_date_time_lookup()
Definition: system.admin.inc:2190
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
_system_theme_settings_validate_path
_system_theme_settings_validate_path($path)
Definition: system.admin.inc:671
system_file_system_settings
system_file_system_settings()
Definition: system.admin.inc:1786
ERROR_REPORTING_DISPLAY_SOME
const ERROR_REPORTING_DISPLAY_SOME
Definition: bootstrap.inc:36
drupal_load_updates
drupal_load_updates()
Definition: install.inc:81
file_get_stream_wrappers
file_get_stream_wrappers($filter=STREAM_WRAPPERS_ALL)
Definition: file.inc:123
drupal_get_path_alias
drupal_get_path_alias($path=NULL, $path_language=NULL)
Definition: path.inc:235
drupal_requirements_severity
drupal_requirements_severity(&$requirements)
Definition: install.inc:1197
system_modules_uninstall_validate
system_modules_uninstall_validate($form, &$form_state)
Definition: system.admin.inc:1344
drupal_valid_token
drupal_valid_token($token, $value= '', $skip_anonymous=FALSE)
Definition: common.inc:5095
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
menu_rebuild
menu_rebuild()
Definition: menu.inc:2709
system_get_info
system_get_info($type, $name=NULL)
Definition: system.module:2338
file_unmanaged_copy
file_unmanaged_copy($source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:884
module_enable
module_enable($module_list, $enable_dependencies=TRUE)
Definition: module.inc:383
$info
$info
Definition: color.inc:6
system_themes_page
system_themes_page()
Definition: system.admin.inc:136
drupal_get_profile
drupal_get_profile()
Definition: common.inc:222
drupal_check_module
drupal_check_module($module)
Definition: install.inc:1216
system_ip_blocking_form_submit
system_ip_blocking_form_submit($form, &$form_state)
Definition: system.admin.inc:1442
system_batch_page
system_batch_page()
Definition: system.admin.inc:2363
system_performance_settings
system_performance_settings()
Definition: system.admin.inc:1674
system_status
system_status($check=FALSE)
Definition: system.admin.inc:2314
system_actions_manage_form_submit
system_actions_manage_form_submit($form, &$form_state)
Definition: system.admin.inc:3040
DRUPAL_USER_TIMEZONE_DEFAULT
const DRUPAL_USER_TIMEZONE_DEFAULT
Definition: system.module:21
$value
print $value
Definition: user-profile-item.tpl.php:26
system_site_information_settings
system_site_information_settings()
Definition: system.admin.inc:1484
system_ip_blocking_delete_submit
system_ip_blocking_delete_submit($form, &$form_state)
Definition: system.admin.inc:1468
system_admin_index
system_admin_index()
Definition: system.admin.inc:80
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_get_normal_path
drupal_get_normal_path($path, $path_language=NULL)
Definition: path.inc:259
actions_save
actions_save($function, $type, $params, $label, $aid=NULL)
Definition: actions.inc:343
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
$output
$output
Definition: authorize.php:93
file_directory_temp
file_directory_temp()
Definition: file.inc:2446
system_action_delete_orphans_post
system_action_delete_orphans_post($orphaned)
Definition: system.admin.inc:3202
user_access
user_access($string, $account=NULL)
Definition: user.module:794
system_modules_confirm_form
system_modules_confirm_form($modules, $storage)
Definition: system.admin.inc:1054
system_modules_submit
system_modules_submit($form, &$form_state)
Definition: system.admin.inc:1094
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
file_save_upload
file_save_upload($source, $validators=array(), $destination=FALSE, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1437
system_date_format_save
system_date_format_save($date_format, $dfid=0)
Definition: system.module:3877
theme_get_setting
theme_get_setting($setting_name, $theme=NULL)
Definition: theme.inc:1401
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
file_uri_target
file_uri_target($uri)
Definition: file.inc:243
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
system_rss_feeds_settings
system_rss_feeds_settings()
Definition: system.admin.inc:1877
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
system_theme_settings_validate
system_theme_settings_validate($form, &$form_state)
Definition: system.admin.inc:607
system_theme_enable
system_theme_enable()
Definition: system.admin.inc:296
ERROR_REPORTING_HIDE
const ERROR_REPORTING_HIDE
Definition: bootstrap.inc:31
STREAM_WRAPPERS_WRITE_VISIBLE
const STREAM_WRAPPERS_WRITE_VISIBLE
Definition: stream_wrappers.inc:72
SCHEMA_UNINSTALLED
const SCHEMA_UNINSTALLED
Definition: install.inc:11
actions_load
actions_load($aid)
Definition: actions.inc:373
DRUPAL_USER_TIMEZONE_EMPTY
const DRUPAL_USER_TIMEZONE_EMPTY
Definition: system.module:26
drupal_ucfirst
drupal_ucfirst($text)
Definition: unicode.inc:561
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_access_denied
drupal_access_denied()
Definition: common.inc:744
conf_path
conf_path($require_settings=TRUE, $reset=FALSE)
Definition: bootstrap.inc:541
system_get_date_types
system_get_date_types($type=NULL)
Definition: system.module:3528
drupal_uninstall_modules
drupal_uninstall_modules($module_list=array(), $uninstall_dependents=TRUE)
Definition: install.inc:766
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
actions_list
actions_list($reset=FALSE)
Definition: actions.inc:162
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
drupal_flush_all_caches
drupal_flush_all_caches()
Definition: common.inc:7453
system_run_cron
system_run_cron()
Definition: system.admin.inc:2340
system_actions_remove_orphans
system_actions_remove_orphans()
Definition: system.admin.inc:3211
system_actions_configure
system_actions_configure($form, &$form_state, $action=NULL)
Definition: system.admin.inc:3064
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
system_modules_uninstall
system_modules_uninstall($form, $form_state=NULL)
Definition: system.admin.inc:1242
system_actions_manage
system_actions_manage()
Definition: system.admin.inc:2946
system_add_date_format_type_form_submit
system_add_date_format_type_form_submit($form, &$form_state)
Definition: system.admin.inc:2172
country_get_list
country_get_list()
Definition: locale.inc:2351
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
system_site_information_settings_validate
system_site_information_settings_validate($form, &$form_state)
Definition: system.admin.inc:1555
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
drupal_exit
drupal_exit($destination=NULL)
Definition: common.inc:2721
system_theme_settings
system_theme_settings($form, &$form_state, $key= '')
Definition: system.admin.inc:399
drupal_get_token
drupal_get_token($value= '')
Definition: common.inc:5077
system_add_date_format_type_form
system_add_date_format_type_form($form, &$form_state)
Definition: system.admin.inc:2104
system_ip_blocking_form_validate
system_ip_blocking_form_validate($form, &$form_state)
Definition: system.admin.inc:1429
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
DRUPAL_CRON_DEFAULT_THRESHOLD
const DRUPAL_CRON_DEFAULT_THRESHOLD
Definition: system.module:16
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
system_settings_overview
system_settings_overview()
Definition: system.admin.inc:119
DRUPAL_CORE_COMPATIBILITY
const DRUPAL_CORE_COMPATIBILITY
Definition: bootstrap.inc:16
theme_admin_block
theme_admin_block($variables)
Definition: system.admin.inc:2394
$row
$row
Definition: block-admin-display-form.tpl.php:47
ERROR_REPORTING_DISPLAY_ALL
const ERROR_REPORTING_DISPLAY_ALL
Definition: bootstrap.inc:41
theme_system_modules_incompatible
theme_system_modules_incompatible($variables)
Definition: system.admin.inc:2653
theme_status_report
theme_status_report($variables)
Definition: system.admin.inc:2555
module_disable
module_disable($module_list, $disable_dependents=TRUE)
Definition: module.inc:515
drupal_set_page_content
drupal_set_page_content($content=NULL)
Definition: common.inc:5454
drupal_check_incompatibility
drupal_check_incompatibility($v, $current_version)
Definition: common.inc:7597
system_theme_settings_submit
system_theme_settings_submit($form, &$form_state)
Definition: system.admin.inc:693
list_themes
list_themes($refresh=FALSE)
Definition: theme.inc:774
system_clean_url_settings
system_clean_url_settings($form, &$form_state)
Definition: system.admin.inc:2224
system_date_time_formats
system_date_time_formats()
Definition: system.admin.inc:2834
system_modules_uninstall_submit
system_modules_uninstall_submit($form, &$form_state)
Definition: system.admin.inc:1355
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
REQUIREMENT_INFO
const REQUIREMENT_INFO
Definition: install.inc:21
file_uri_scheme
file_uri_scheme($uri)
Definition: file.inc:199
system_cron_settings
system_cron_settings()
Definition: system.admin.inc:1596
drupal_hash_base64
drupal_hash_base64($data)
Definition: bootstrap.inc:2067
system_clear_page_cache_submit
system_clear_page_cache_submit($form, &$form_state)
Definition: system.admin.inc:1776
system_date_format_type_delete
system_date_format_type_delete($type)
Definition: system.module:3849
system_get_date_formats
system_get_date_formats($type=NULL)
Definition: system.module:3582
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
system_regional_settings
system_regional_settings()
Definition: system.admin.inc:1909
system_actions_delete_form_submit
system_actions_delete_form_submit($form, &$form_state)
Definition: system.admin.inc:3187
system_actions_configure_submit
system_actions_configure_submit($form, &$form_state)
Definition: system.admin.inc:3148
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
system_clear_cache_submit
system_clear_cache_submit($form, &$form_state)
Definition: system.admin.inc:1766
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
system_date_delete_format_form
system_date_delete_format_form($form, &$form_state, $dfid)
Definition: system.admin.inc:2767
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
system_delete_date_format_type_form
system_delete_date_format_type_form($form, &$form_state, $format_type)
Definition: system.admin.inc:2800
system_settings_form
system_settings_form($form)
Definition: system.module:2755
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
system_get_date_format
system_get_date_format($dfid)
Definition: system.module:3605
drupal_cron_run
drupal_cron_run()
Definition: common.inc:5227
system_get_module_admin_tasks
system_get_module_admin_tasks($module, $info)
Definition: system.module:2930
system_modules_uninstall_confirm_form
system_modules_uninstall_confirm_form($storage)
Definition: system.admin.inc:1310
actions_synchronize
actions_synchronize($delete_orphans=FALSE)
Definition: actions.inc:274
actions_delete
actions_delete($aid)
Definition: actions.inc:383
file_get_mimetype
file_get_mimetype($uri, $mapping=NULL)
Definition: file.inc:2143
theme_system_modules_uninstall
theme_system_modules_uninstall($variables)
Definition: system.admin.inc:2666
system_date_format_type_save
system_date_format_type_save($type)
Definition: system.module:3828
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/standard/standard.profile Source File

  • profiles
  • standard
standard.profile
Go to the documentation of this file.
1 <?php
12 function standard_form_install_configure_form_alter(&$form, $form_state) {
13 // Pre-populate the site name with the server name.
14 $form['site_information']['site_name']['#default_value'] = $_SERVER['SERVER_NAME'];
15 }
standard_form_install_configure_form_alter
standard_form_install_configure_form_alter(&$form, $form_state)
Definition: standard.profile:12
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/color/color.inc Source File

  • themes
  • bartik
  • color
color.inc
Go to the documentation of this file.
1 <?php
2
3 // Put the logo path into JavaScript for the live preview.
4 drupal_add_js(array('color' => array('logo' => theme_get_setting('logo', 'bartik'))), 'setting');
5
6 $info = array(
7 // Available colors and color labels used in theme.
8 'fields' => array(
9 'top' => t('Header top'),
10 'bottom' => t('Header bottom'),
11 'bg' => t('Main background'),
12 'sidebar' => t('Sidebar background'),
13 'sidebarborders' => t('Sidebar borders'),
14 'footer' => t('Footer background'),
15 'titleslogan' => t('Title and slogan'),
16 'text' => t('Text color'),
17 'link' => t('Link color'),
18 ),
19 // Pre-defined color schemes.
20 'schemes' => array(
21 'default' => array(
22 'title' => t('Blue Lagoon (default)'),
23 'colors' => array(
24 'top' => '#0779bf',
25 'bottom' => '#48a9e4',
26 'bg' => '#ffffff',
27 'sidebar' => '#f6f6f2',
28 'sidebarborders' => '#f9f9f9',
29 'footer' => '#292929',
30 'titleslogan' => '#fffeff',
31 'text' => '#3b3b3b',
32 'link' => '#0071B3',
33 ),
34 ),
35 'firehouse' => array(
36 'title' => t('Firehouse'),
37 'colors' => array(
38 'top' => '#cd2d2d',
39 'bottom' => '#cf3535',
40 'bg' => '#ffffff',
41 'sidebar' => '#f1f4f0',
42 'sidebarborders' => '#ededed',
43 'footer' => '#1f1d1c',
44 'titleslogan' => '#fffeff',
45 'text' => '#3b3b3b',
46 'link' => '#d6121f',
47 ),
48 ),
49 'ice' => array(
50 'title' => t('Ice'),
51 'colors' => array(
52 'top' => '#d0d0d0',
53 'bottom' => '#c2c4c5',
54 'bg' => '#ffffff',
55 'sidebar' => '#ffffff',
56 'sidebarborders' => '#cccccc',
57 'footer' => '#24272c',
58 'titleslogan' => '#000000',
59 'text' => '#4a4a4a',
60 'link' => '#019dbf',
61 ),
62 ),
63 'plum' => array(
64 'title' => t('Plum'),
65 'colors' => array(
66 'top' => '#4c1c58',
67 'bottom' => '#593662',
68 'bg' => '#fffdf7',
69 'sidebar' => '#edede7',
70 'sidebarborders' => '#e7e7e7',
71 'footer' => '#2c2c28',
72 'titleslogan' => '#ffffff',
73 'text' => '#301313',
74 'link' => '#9d408d',
75 ),
76 ),
77 'slate' => array(
78 'title' => t('Slate'),
79 'colors' => array(
80 'top' => '#4a4a4a',
81 'bottom' => '#4e4e4e',
82 'bg' => '#ffffff',
83 'sidebar' => '#ffffff',
84 'sidebarborders' => '#d0d0d0',
85 'footer' => '#161617',
86 'titleslogan' => '#ffffff',
87 'text' => '#3b3b3b',
88 'link' => '#0073b6',
89 ),
90 ),
91 ),
92
93 // CSS files (excluding @import) to rewrite with new color scheme.
94 'css' => array(
95 'css/colors.css',
96 ),
97
98 // Files to copy.
99 'copy' => array(
100 'logo.png',
101 ),
102
103 // Gradient definitions.
104 'gradients' => array(
105 array(
106 // (x, y, width, height).
107 'dimension' => array(0, 0, 0, 0),
108 // Direction of gradient ('vertical' or 'horizontal').
109 'direction' => 'vertical',
110 // Keys of colors to use for the gradient.
111 'colors' => array('top', 'bottom'),
112 ),
113 ),
114
115 // Color areas to fill (x, y, width, height).
116 'fill' => array(),
117
118 // Coordinates of all the theme slices (x, y, width, height)
119 // with their filename as used in the stylesheet.
120 'slices' => array(),
121
122 // Reference color used for blending. Matches the base.png's colors.
123 'blend_target' => '#ffffff',
124
125 // Preview files.
126 'preview_css' => 'color/preview.css',
127 'preview_js' => 'color/preview.js',
128 'preview_html' => 'color/preview.html',
129
130 // Base file for image generation.
131 'base_image' => 'color/base.png',
132 );
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$info
$info
Definition: color.inc:6
theme_get_setting
theme_get_setting($setting_name, $theme=NULL)
Definition: theme.inc:1401
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: install.php Source File

install.php
Go to the documentation of this file.
1 <?php
2
11 define('DRUPAL_ROOT', getcwd());
12
16 define('MAINTENANCE_MODE', 'install');
17
18 // Exit early if running an incompatible PHP version to avoid fatal errors.
19 if (version_compare(PHP_VERSION, '5.2.4') < 0) {
20 print 'Your PHP installation is too old. Drupal requires at least PHP 5.2.4. See the <a href="http://drupal.org/requirements">system requirements</a> page for more information.';
21 exit;
22 }
23
24 // Start the installer.
25 require_once DRUPAL_ROOT . '/includes/install.core.inc';
26 install_drupal();
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
print
print
Definition: php-2.php:2
install_drupal
install_drupal($settings=array())
Definition: install.core.inc:64
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/node.tpl.php Source File

  • themes
  • garland
node.tpl.php
Go to the documentation of this file.
1 <?php
2 ?>
3 <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
4
5 <?php print $user_picture; ?>
6
7 <?php print render($title_prefix); ?>
8 <?php if (!$page): ?>
9 <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
10 <?php endif; ?>
11 <?php print render($title_suffix); ?>
12
13 <?php if ($display_submitted): ?>
14 <span class="submitted"><?php print $submitted ?></span>
15 <?php endif; ?>
16
17 <div class="content clearfix"<?php print $content_attributes; ?>>
18 <?php
19 // We hide the comments and links now so that we can render them later.
20 hide($content['comments']);
21 hide($content['links']);
22 print render($content);
23 ?>
24 </div>
25
26 <div class="clearfix">
27 <?php if (!empty($content['links'])): ?>
28 <div class="links"><?php print render($content['links']); ?></div>
29 <?php endif; ?>
30
31 <?php print render($content['comments']); ?>
32 </div>
33
34 </div>
$page
print $page
Definition: overlay.tpl.php:37
$attributes
print $attributes
Definition: block.tpl.php:47
$user_picture
print $user_picture
Definition: node.tpl.php:85
print
print
Definition: php-2.php:2
$content_attributes
print $content_attributes
Definition: block.tpl.php:55
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
hide
hide(&$element)
Definition: common.inc:6021
endif
endif
Definition: aggregator-item.tpl.php:31
$submitted
print $submitted
Definition: comment.tpl.php:75
render
render(&$element)
Definition: common.inc:5988
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/text/text.install Source File

  • modules
  • field
  • modules
  • text
text.install
Go to the documentation of this file.
1 <?php
2
11 function text_field_schema($field) {
12 switch ($field['type']) {
13 case 'text':
14 $columns = array(
15 'value' => array(
16 'type' => 'varchar',
17 'length' => $field['settings']['max_length'],
18 'not null' => FALSE,
19 ),
20 );
21 break;
22
23 case 'text_long':
24 $columns = array(
25 'value' => array(
26 'type' => 'text',
27 'size' => 'big',
28 'not null' => FALSE,
29 ),
30 );
31 break;
32
33 case 'text_with_summary':
34 $columns = array(
35 'value' => array(
36 'type' => 'text',
37 'size' => 'big',
38 'not null' => FALSE,
39 ),
40 'summary' => array(
41 'type' => 'text',
42 'size' => 'big',
43 'not null' => FALSE,
44 ),
45 );
46 break;
47 }
48 $columns += array(
49 'format' => array(
50 'type' => 'varchar',
51 'length' => 255,
52 'not null' => FALSE,
53 ),
54 );
55 return array(
56 'columns' => $columns,
57 'indexes' => array(
58 'format' => array('format'),
59 ),
60 'foreign keys' => array(
61 'format' => array(
62 'table' => 'filter_format',
63 'columns' => array('format' => 'format'),
64 ),
65 ),
66 );
67 }
68
72 function text_update_7000() {
73 $spec = array(
74 'type' => 'varchar',
75 'length' => 255,
76 'not null' => FALSE,
77 );
78 $fields = _update_7000_field_read_fields(array(
79 'module' => 'text',
80 'storage_type' => 'field_sql_storage',
81 ));
82 foreach ($fields as $field) {
83 if ($field['deleted']) {
84 $table = "field_deleted_data_{$field['id']}";
85 $revision_table = "field_deleted_revision_{$field['id']}";
86 }
87 else {
88 $table = "field_data_{$field['field_name']}";
89 $revision_table = "field_revision_{$field['field_name']}";
90 }
91 $column = $field['field_name'] . '_' . 'format';
92 db_change_field($table, $column, $column, $spec);
93 db_change_field($revision_table, $column, $column, $spec);
94 }
95 }
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
_update_7000_field_read_fields
_update_7000_field_read_fields(array $conditions=array(), $key= 'id')
Definition: field.install:328
text_field_schema
text_field_schema($field)
Definition: text.install:11
text_update_7000
text_update_7000()
Definition: text.install:72
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/tabledrag_example/tabledrag_example.install Source File

  • examples
  • tabledrag_example
tabledrag_example.install
Go to the documentation of this file.
1 <?php
17 function tabledrag_example_schema() {
18 $schema['tabledrag_example'] = array(
19 'description' => 'Stores some entries for our tabledrag fun.',
20 'fields' => array(
21 'id' => array(
22 'description' => 'The primary identifier for each item',
23 'type' => 'serial',
24 'unsigned' => TRUE,
25 'not null' => TRUE,
26 ),
27 'name' => array(
28 'description' => 'A name for this item',
29 'type' => 'varchar',
30 'length' => 32,
31 'not null' => TRUE,
32 'default' => '',
33 ),
34 'description' => array(
35 'description' => 'A description for this item',
36 'type' => 'varchar',
37 'length' => 255,
38 'not null' => TRUE,
39 'default' => '',
40 ),
41 'itemgroup' => array(
42 'description' => 'The group this item belongs to',
43 'type' => 'varchar',
44 'length' => 32,
45 'not null' => TRUE,
46 'default' => '',
47 ),
48 'weight' => array(
49 'description' => 'The sortable weight for this item',
50 'type' => 'int',
51 'length' => 11,
52 'not null' => TRUE,
53 'default' => 0,
54 ),
55 'pid' => array(
56 'description' => 'The primary id of the parent for this item',
57 'type' => 'int',
58 'length' => 11,
59 'unsigned' => TRUE,
60 'not null' => TRUE,
61 'default' => 0,
62 ),
63 'depth' => array(
64 'description' => 'The depth of this item within the tree',
65 'type' => 'int',
66 'size' => 'small',
67 'unsigned' => TRUE,
68 'not null' => TRUE,
69 'default' => 0,
70 ),
71 ),
72 'primary key' => array('id'),
73 );
74 return $schema;
75 }
76
84 function tabledrag_example_install() {
85 // Ensure translations don't break at install time.
86 $t = get_t();
87 // Insert some values into the database.
88 $rows = array(
89 array(
90 'name' => $t('Item One'),
91 'description' => $t('The first item'),
92 'itemgroup' => $t('Group1'),
93 ),
94 array(
95 'name' => $t('Item Two'),
96 'description' => $t('The second item'),
97 'itemgroup' => $t('Group1'),
98 ),
99 array(
100 'name' => $t('Item Three'),
101 'description' => $t('The third item'),
102 'itemgroup' => $t('Group1'),
103 ),
104 array(
105 'name' => $t('Item Four'),
106 'description' => $t('The fourth item'),
107 'itemgroup' => $t('Group2'),
108 ),
109 array(
110 'name' => $t('Item Five'),
111 'description' => $t('The fifth item'),
112 'itemgroup' => $t('Group2'),
113 ),
114 array(
115 'name' => $t('Item Six'),
116 'description' => $t('The sixth item'),
117 'itemgroup' => $t('Group2'),
118 ),
119 array(
120 'name' => $t('Item Seven'),
121 'description' => $t('The seventh item'),
122 'itemgroup' => $t('Group3'),
123 ),
124 array(
125 'name' => $t('A Root Node'),
126 'description' => $t('This item cannot be nested under a parent item'),
127 'itemgroup' => $t('Group3'),
128 ),
129 array(
130 'name' => $t('A Leaf Item'),
131 'description' => $t('This item cannot have child items'),
132 'itemgroup' => $t('Group3'),
133 ),
134 );
135 if (db_table_exists('tabledrag_example')) {
136 foreach ($rows as $row) {
137 db_insert('tabledrag_example')->fields($row)->execute();
138 }
139 }
140 }
141
149 function tabledrag_example_uninstall() {
150 db_drop_table('tabledrag_example');
151 }
tabledrag_example_uninstall
tabledrag_example_uninstall()
Definition: tabledrag_example.install:149
get_t
get_t()
Definition: bootstrap.inc:2635
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
$row
$row
Definition: block-admin-display-form.tpl.php:47
tabledrag_example_schema
tabledrag_example_schema()
Definition: tabledrag_example.install:17
tabledrag_example_install
tabledrag_example_install()
Definition: tabledrag_example.install:84
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_table_exists
db_table_exists($table)
Definition: database.inc:2760
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/templates/comment-wrapper.tpl.php Source File

  • themes
  • bartik
  • templates
comment-wrapper.tpl.php
Go to the documentation of this file.
1 <?php
2
36 ?>
37 <div id="comments" class="<?php print $classes; ?>"<?php print $attributes; ?>>
38 <?php if ($content['comments'] && $node->type != 'forum'): ?>
39 <?php print render($title_prefix); ?>
40 <h2 class="title"><?php print t('Comments'); ?></h2>
41 <?php print render($title_suffix); ?>
42 <?php endif; ?>
43
44 <?php print render($content['comments']); ?>
45
46 <?php if ($content['comment_form']): ?>
47 <h2 class="title comment-form"><?php print t('Add new comment'); ?></h2>
48 <?php print render($content['comment_form']); ?>
49 <?php endif; ?>
50 </div>
$attributes
print $attributes
Definition: block.tpl.php:47
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
endif
endif
Definition: aggregator-item.tpl.php:31
render
render(&$element)
Definition: common.inc:5988
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/mysql/database.inc Source File

  • includes
  • database
  • mysql
database.inc
Go to the documentation of this file.
1 <?php
2
13 class DatabaseConnection_mysql extends DatabaseConnection {
14
20 protected $needsCleanup = FALSE;
21
22 public function __construct(array $connection_options = array()) {
23 // This driver defaults to transaction support, except if explicitly passed FALSE.
24 $this->transactionSupport = !isset($connection_options['transactions']) || ($connection_options['transactions'] !== FALSE);
25
26 // MySQL never supports transactional DDL.
27 $this->transactionalDDLSupport = FALSE;
28
29 $this->connectionOptions = $connection_options;
30
31 // The DSN should use either a socket or a host/port.
32 if (isset($connection_options['unix_socket'])) {
33 $dsn = 'mysql:unix_socket=' . $connection_options['unix_socket'];
34 }
35 else {
36 // Default to TCP connection on port 3306.
37 $dsn = 'mysql:host=' . $connection_options['host'] . ';port=' . (empty($connection_options['port']) ? 3306 : $connection_options['port']);
38 }
39 $dsn .= ';dbname=' . $connection_options['database'];
40 // Allow PDO options to be overridden.
41 $connection_options += array(
42 'pdo' => array(),
43 );
44 $connection_options['pdo'] += array(
45 // So we don't have to mess around with cursors and unbuffered queries by default.
46 PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE,
47 // Because MySQL's prepared statements skip the query cache, because it's dumb.
48 PDO::ATTR_EMULATE_PREPARES => TRUE,
49 );
50
51 parent::__construct($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']);
52
53 // Force MySQL to use the UTF-8 character set. Also set the collation, if a
54 // certain one has been set; otherwise, MySQL defaults to 'utf8_general_ci'
55 // for UTF-8.
56 if (!empty($connection_options['collation'])) {
57 $this->exec('SET NAMES utf8 COLLATE ' . $connection_options['collation']);
58 }
59 else {
60 $this->exec('SET NAMES utf8');
61 }
62
63 // Set MySQL init_commands if not already defined. Default Drupal's MySQL
64 // behavior to conform more closely to SQL standards. This allows Drupal
65 // to run almost seamlessly on many different kinds of database systems.
66 // These settings force MySQL to behave the same as postgresql, or sqlite
67 // in regards to syntax interpretation and invalid data handling. See
68 // http://drupal.org/node/344575 for further discussion. Also, as MySQL 5.5
69 // changed the meaning of TRADITIONAL we need to spell out the modes one by
70 // one.
71 $connection_options += array(
72 'init_commands' => array(),
73 );
74 $connection_options['init_commands'] += array(
75 'sql_mode' => "SET sql_mode = 'ANSI,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER'",
76 );
77 // Set connection options.
78 $this->exec(implode('; ', $connection_options['init_commands']));
79 }
80
81 public function __destruct() {
82 if ($this->needsCleanup) {
83 $this->nextIdDelete();
84 }
85 }
86
87 public function queryRange($query, $from, $count, array $args = array(), array $options = array()) {
88 return $this->query($query . ' LIMIT ' . (int) $from . ', ' . (int) $count, $args, $options);
89 }
90
91 public function queryTemporary($query, array $args = array(), array $options = array()) {
92 $tablename = $this->generateTemporaryTableName();
93 $this->query(preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE {' . $tablename . '} Engine=MEMORY SELECT', $query), $args, $options);
94 return $tablename;
95 }
96
97 public function driver() {
98 return 'mysql';
99 }
100
101 public function databaseType() {
102 return 'mysql';
103 }
104
105 public function mapConditionOperator($operator) {
106 // We don't want to override any of the defaults.
107 return NULL;
108 }
109
110 public function nextId($existing_id = 0) {
111 $new_id = $this->query('INSERT INTO {sequences} () VALUES ()', array(), array('return' => Database::RETURN_INSERT_ID));
112 // This should only happen after an import or similar event.
113 if ($existing_id >= $new_id) {
114 // If we INSERT a value manually into the sequences table, on the next
115 // INSERT, MySQL will generate a larger value. However, there is no way
116 // of knowing whether this value already exists in the table. MySQL
117 // provides an INSERT IGNORE which would work, but that can mask problems
118 // other than duplicate keys. Instead, we use INSERT ... ON DUPLICATE KEY
119 // UPDATE in such a way that the UPDATE does not do anything. This way,
120 // duplicate keys do not generate errors but everything else does.
121 $this->query('INSERT INTO {sequences} (value) VALUES (:value) ON DUPLICATE KEY UPDATE value = value', array(':value' => $existing_id));
122 $new_id = $this->query('INSERT INTO {sequences} () VALUES ()', array(), array('return' => Database::RETURN_INSERT_ID));
123 }
124 $this->needsCleanup = TRUE;
125 return $new_id;
126 }
127
128 public function nextIdDelete() {
129 // While we want to clean up the table to keep it up from occupying too
130 // much storage and memory, we must keep the highest value in the table
131 // because InnoDB uses an in-memory auto-increment counter as long as the
132 // server runs. When the server is stopped and restarted, InnoDB
133 // reinitializes the counter for each table for the first INSERT to the
134 // table based solely on values from the table so deleting all values would
135 // be a problem in this case. Also, TRUNCATE resets the auto increment
136 // counter.
137 try {
138 $max_id = $this->query('SELECT MAX(value) FROM {sequences}')->fetchField();
139 // We know we are using MySQL here, no need for the slower db_delete().
140 $this->query('DELETE FROM {sequences} WHERE value < :value', array(':value' => $max_id));
141 }
142 // During testing, this function is called from shutdown with the
143 // simpletest prefix stored in $this->connection, and those tables are gone
144 // by the time shutdown is called so we need to ignore the database
145 // errors. There is no problem with completely ignoring errors here: if
146 // these queries fail, the sequence will work just fine, just use a bit
147 // more database storage and memory.
148 catch (PDOException $e) {
149 }
150 }
151
155 protected function popCommittableTransactions() {
156 // Commit all the committable layers.
157 foreach (array_reverse($this->transactionLayers) as $name => $active) {
158 // Stop once we found an active transaction.
159 if ($active) {
160 break;
161 }
162
163 // If there are no more layers left then we should commit.
164 unset($this->transactionLayers[$name]);
165 if (empty($this->transactionLayers)) {
166 if (!PDO::commit()) {
167 throw new DatabaseTransactionCommitFailedException();
168 }
169 }
170 else {
171 // Attempt to release this savepoint in the standard way.
172 try {
173 $this->query('RELEASE SAVEPOINT ' . $name);
174 }
175 catch (PDOException $e) {
176 // However, in MySQL (InnoDB), savepoints are automatically committed
177 // when tables are altered or created (DDL transactions are not
178 // supported). This can cause exceptions due to trying to release
179 // savepoints which no longer exist.
180 //
181 // To avoid exceptions when no actual error has occurred, we silently
182 // succeed for MySQL error code 1305 ("SAVEPOINT does not exist").
183 if ($e->errorInfo[1] == '1305') {
184 // If one SAVEPOINT was released automatically, then all were.
185 // Therefore, clean the transaction stack.
186 $this->transactionLayers = array();
187 // We also have to explain to PDO that the transaction stack has
188 // been cleaned-up.
189 PDO::commit();
190 }
191 else {
192 throw $e;
193 }
194 }
195 }
196 }
197 }
198 }
199
200
DatabaseConnection_mysql\nextId
nextId($existing_id=0)
Definition: database.inc:110
DatabaseConnection\query
query($query, array $args=array(), $options=array())
Definition: database.inc:664
$name
print $name
Definition: profile-listing.tpl.php:43
DatabaseConnection_mysql\databaseType
databaseType()
Definition: database.inc:101
DatabaseConnection_mysql\__construct
__construct(array $connection_options=array())
Definition: database.inc:22
Database\RETURN_INSERT_ID
const RETURN_INSERT_ID
Definition: database.inc:1345
DatabaseConnection_mysql
Definition: database.inc:13
DatabaseConnection
Definition: database.inc:184
DatabaseConnection_mysql\queryTemporary
queryTemporary($query, array $args=array(), array $options=array())
Definition: database.inc:91
DatabaseConnection_mysql\driver
driver()
Definition: database.inc:97
DatabaseConnection_mysql\$needsCleanup
$needsCleanup
Definition: database.inc:20
DatabaseTransactionCommitFailedException
Definition: database.inc:1794
DatabaseConnection_mysql\queryRange
queryRange($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:87
DatabaseConnection\generateTemporaryTableName
generateTemporaryTableName()
Definition: database.inc:1186
DatabaseConnection_mysql\popCommittableTransactions
popCommittableTransactions()
Definition: database.inc:155
DatabaseConnection_mysql\mapConditionOperator
mapConditionOperator($operator)
Definition: database.inc:105
DatabaseConnection_mysql\nextIdDelete
nextIdDelete()
Definition: database.inc:128
DatabaseConnection_mysql\__destruct
__destruct()
Definition: database.inc:81
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/xmlrpcs.inc Source File

  • includes
xmlrpcs.inc
Go to the documentation of this file.
1 <?php
2
14 function xmlrpc_server($callbacks) {
15 $xmlrpc_server = new stdClass();
16 // Define built-in XML-RPC method names
17 $defaults = array(
18 'system.multicall' => 'xmlrpc_server_multicall',
19 array(
20 'system.methodSignature',
21 'xmlrpc_server_method_signature',
22 array('array', 'string'),
23 'Returns an array describing the return type and required parameters of a method.',
24 ),
25 array(
26 'system.getCapabilities',
27 'xmlrpc_server_get_capabilities',
28 array('struct'),
29 'Returns a struct describing the XML-RPC specifications supported by this server.',
30 ),
31 array(
32 'system.listMethods',
33 'xmlrpc_server_list_methods',
34 array('array'),
35 'Returns an array of available methods on this server.',
36 ),
37 array(
38 'system.methodHelp',
39 'xmlrpc_server_method_help',
40 array('string', 'string'),
41 'Returns a documentation string for the specified method.',
42 ),
43 );
44 // We build an array of all method names by combining the built-ins
45 // with those defined by modules implementing the _xmlrpc hook.
46 // Built-in methods are overridable.
47 $callbacks = array_merge($defaults, (array) $callbacks);
48 drupal_alter('xmlrpc', $callbacks);
49 foreach ($callbacks as $key => $callback) {
50 // we could check for is_array($callback)
51 if (is_int($key)) {
52 $method = $callback[0];
53 $xmlrpc_server->callbacks[$method] = $callback[1];
54 $xmlrpc_server->signatures[$method] = $callback[2];
55 $xmlrpc_server->help[$method] = $callback[3];
56 }
57 else {
58 $xmlrpc_server->callbacks[$key] = $callback;
59 $xmlrpc_server->signatures[$key] = '';
60 $xmlrpc_server->help[$key] = '';
61 }
62 }
63
64 $data = file_get_contents('php://input');
65 if (!$data) {
66 print 'XML-RPC server accepts POST requests only.';
67 drupal_exit();
68 }
69 $xmlrpc_server->message = xmlrpc_message($data);
70 if (!xmlrpc_message_parse($xmlrpc_server->message)) {
71 xmlrpc_server_error(-32700, t('Parse error. Request not well formed.'));
72 }
73 if ($xmlrpc_server->message->messagetype != 'methodCall') {
74 xmlrpc_server_error(-32600, t('Server error. Invalid XML-RPC. Request must be a methodCall.'));
75 }
76 if (!isset($xmlrpc_server->message->params)) {
77 $xmlrpc_server->message->params = array();
78 }
79 xmlrpc_server_set($xmlrpc_server);
80 $result = xmlrpc_server_call($xmlrpc_server, $xmlrpc_server->message->methodname, $xmlrpc_server->message->params);
81
82 if (is_object($result) && !empty($result->is_error)) {
83 xmlrpc_server_error($result);
84 }
85 // Encode the result
86 $r = xmlrpc_value($result);
87 // Create the XML
88 $xml = '
89 <methodResponse>
90 <params>
91 <param>
92 <value>' . xmlrpc_value_get_xml($r) . '</value>
93 </param>
94 </params>
95 </methodResponse>
96
97 ';
98 // Send it
99 xmlrpc_server_output($xml);
100 }
101
111 function xmlrpc_server_error($error, $message = FALSE) {
112 if ($message && !is_object($error)) {
113 $error = xmlrpc_error($error, $message);
114 }
115 xmlrpc_server_output(xmlrpc_error_get_xml($error));
116 }
117
124 function xmlrpc_server_output($xml) {
125 $xml = '<?xml version="1.0"?>' . "\n" . $xml;
126 drupal_add_http_header('Content-Length', strlen($xml));
127 drupal_add_http_header('Content-Type', 'text/xml');
128 echo $xml;
129 drupal_exit();
130 }
131
144 function xmlrpc_server_set($xmlrpc_server = NULL) {
145 static $server;
146 if (!isset($server)) {
147 $server = $xmlrpc_server;
148 }
149 return $server;
150 }
151
160 function xmlrpc_server_get() {
161 return xmlrpc_server_set();
162 }
163
178 function xmlrpc_server_call($xmlrpc_server, $methodname, $args) {
179 // Make sure parameters are in an array
180 if ($args && !is_array($args)) {
181 $args = array($args);
182 }
183 // Has this method been mapped to a Drupal function by us or by modules?
184 if (!isset($xmlrpc_server->callbacks[$methodname])) {
185 return xmlrpc_error(-32601, t('Server error. Requested method @methodname not specified.', array("@methodname" => $xmlrpc_server->message->methodname)));
186 }
187 $method = $xmlrpc_server->callbacks[$methodname];
188 $signature = $xmlrpc_server->signatures[$methodname];
189
190 // If the method has a signature, validate the request against the signature
191 if (is_array($signature)) {
192 $ok = TRUE;
193 $return_type = array_shift($signature);
194 // Check the number of arguments
195 if (count($args) != count($signature)) {
196 return xmlrpc_error(-32602, t('Server error. Wrong number of method parameters.'));
197 }
198 // Check the argument types
199 foreach ($signature as $key => $type) {
200 $arg = $args[$key];
201 switch ($type) {
202 case 'int':
203 case 'i4':
204 if (is_array($arg) || !is_int($arg)) {
205 $ok = FALSE;
206 }
207 break;
208
209 case 'base64':
210 case 'string':
211 if (!is_string($arg)) {
212 $ok = FALSE;
213 }
214 break;
215
216 case 'boolean':
217 if ($arg !== FALSE && $arg !== TRUE) {
218 $ok = FALSE;
219 }
220 break;
221
222 case 'float':
223 case 'double':
224 if (!is_float($arg)) {
225 $ok = FALSE;
226 }
227 break;
228
229 case 'date':
230 case 'dateTime.iso8601':
231 if (!$arg->is_date) {
232 $ok = FALSE;
233 }
234 break;
235 }
236 if (!$ok) {
237 return xmlrpc_error(-32602, t('Server error. Invalid method parameters.'));
238 }
239 }
240 }
241
242 if (!function_exists($method)) {
243 return xmlrpc_error(-32601, t('Server error. Requested function @method does not exist.', array("@method" => $method)));
244 }
245 // Call the mapped function
246 return call_user_func_array($method, $args);
247 }
248
263 function xmlrpc_server_multicall($methodcalls) {
264 // See http://www.xmlrpc.com/discuss/msgReader$1208
265 $return = array();
266 $xmlrpc_server = xmlrpc_server_get();
267 foreach ($methodcalls as $call) {
268 $ok = TRUE;
269 if (!isset($call['methodName']) || !isset($call['params'])) {
270 $result = xmlrpc_error(3, t('Invalid syntax for system.multicall.'));
271 $ok = FALSE;
272 }
273 $method = $call['methodName'];
274 $params = $call['params'];
275 if ($method == 'system.multicall') {
276 $result = xmlrpc_error(-32600, t('Recursive calls to system.multicall are forbidden.'));
277 }
278 elseif ($ok) {
279 $result = xmlrpc_server_call($xmlrpc_server, $method, $params);
280 }
281 if (is_object($result) && !empty($result->is_error)) {
282 $return[] = array(
283 'faultCode' => $result->code,
284 'faultString' => $result->message,
285 );
286 }
287 else {
288 $return[] = array($result);
289 }
290 }
291 return $return;
292 }
293
302 function xmlrpc_server_list_methods() {
303 $xmlrpc_server = xmlrpc_server_get();
304 return array_keys($xmlrpc_server->callbacks);
305 }
306
317 function xmlrpc_server_get_capabilities() {
318 return array(
319 'xmlrpc' => array(
320 'specUrl' => 'http://www.xmlrpc.com/spec',
321 'specVersion' => 1,
322 ),
323 'faults_interop' => array(
324 'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
325 'specVersion' => 20010516,
326 ),
327 'system.multicall' => array(
328 'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
329 'specVersion' => 1,
330 ),
331 'introspection' => array(
332 'specUrl' => 'http://scripts.incutio.com/xmlrpc/introspection.html',
333 'specVersion' => 1,
334 ),
335 );
336 }
337
354 function xmlrpc_server_method_signature($methodname) {
355 $xmlrpc_server = xmlrpc_server_get();
356 if (!isset($xmlrpc_server->callbacks[$methodname])) {
357 return xmlrpc_error(-32601, t('Server error. Requested method @methodname not specified.', array("@methodname" => $methodname)));
358 }
359 if (!is_array($xmlrpc_server->signatures[$methodname])) {
360 return xmlrpc_error(-32601, t('Server error. Requested method @methodname signature not specified.', array("@methodname" => $methodname)));
361 }
362 // We array of types
363 $return = array();
364 foreach ($xmlrpc_server->signatures[$methodname] as $type) {
365 $return[] = $type;
366 }
367 return array($return);
368 }
369
381 function xmlrpc_server_method_help($method) {
382 $xmlrpc_server = xmlrpc_server_get();
383 return $xmlrpc_server->help[$method];
384 }
xmlrpc_server_list_methods
xmlrpc_server_list_methods()
Definition: xmlrpcs.inc:302
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
xmlrpc_server_multicall
xmlrpc_server_multicall($methodcalls)
Definition: xmlrpcs.inc:263
xmlrpc_server_output
xmlrpc_server_output($xml)
Definition: xmlrpcs.inc:124
xmlrpc_server_get_capabilities
xmlrpc_server_get_capabilities()
Definition: xmlrpcs.inc:317
xmlrpc_server_set
xmlrpc_server_set($xmlrpc_server=NULL)
Definition: xmlrpcs.inc:144
xmlrpc_value_get_xml
xmlrpc_value_get_xml($xmlrpc_value)
Definition: xmlrpc.inc:96
xmlrpc_server
xmlrpc_server($callbacks)
Definition: xmlrpcs.inc:14
print
print
Definition: php-2.php:2
xmlrpc_message
xmlrpc_message($message)
Definition: xmlrpc.inc:149
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
xmlrpc_server_method_signature
xmlrpc_server_method_signature($methodname)
Definition: xmlrpcs.inc:354
xmlrpc_server_get
xmlrpc_server_get()
Definition: xmlrpcs.inc:160
drupal_add_http_header
drupal_add_http_header($name, $value, $append=FALSE)
Definition: bootstrap.inc:1129
xmlrpc_error
xmlrpc_error($code=NULL, $message=NULL, $reset=FALSE)
Definition: xmlrpc.inc:404
xmlrpc_message_parse
xmlrpc_message_parse($xmlrpc_message)
Definition: xmlrpc.inc:173
xmlrpc_server_error
xmlrpc_server_error($error, $message=FALSE)
Definition: xmlrpcs.inc:111
drupal_exit
drupal_exit($destination=NULL)
Definition: common.inc:2721
xmlrpc_server_method_help
xmlrpc_server_method_help($method)
Definition: xmlrpcs.inc:381
xmlrpc_error_get_xml
xmlrpc_error_get_xml($xmlrpc_error)
Definition: xmlrpc.inc:427
xmlrpc_value
xmlrpc_value($data, $type=FALSE)
Definition: xmlrpc.inc:25
xmlrpc_server_call
xmlrpc_server_call($xmlrpc_server, $methodname, $args)
Definition: xmlrpcs.inc:178
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.api.php Source File

  • modules
  • field
field.api.php
Go to the documentation of this file.
1 <?php
2
41 function hook_field_extra_fields() {
42 $extra['node']['poll'] = array(
43 'form' => array(
44 'choice_wrapper' => array(
45 'label' => t('Poll choices'),
46 'description' => t('Poll choices'),
47 'weight' => -4,
48 ),
49 'settings' => array(
50 'label' => t('Poll settings'),
51 'description' => t('Poll module settings'),
52 'weight' => -3,
53 ),
54 ),
55 'display' => array(
56 'poll_view_voting' => array(
57 'label' => t('Poll vote'),
58 'description' => t('Poll vote'),
59 'weight' => 0,
60 ),
61 'poll_view_results' => array(
62 'label' => t('Poll results'),
63 'description' => t('Poll results'),
64 'weight' => 0,
65 ),
66 )
67 );
68
69 return $extra;
70 }
71
80 function hook_field_extra_fields_alter(&$info) {
81 // Force node title to always be at the top of the list by default.
82 foreach (node_type_get_types() as $bundle) {
83 if (isset($info['node'][$bundle->type]['form']['title'])) {
84 $info['node'][$bundle->type]['form']['title']['weight'] = -20;
85 }
86 }
87 }
88
152 function hook_field_info() {
153 return array(
154 'text' => array(
155 'label' => t('Text'),
156 'description' => t('This field stores varchar text in the database.'),
157 'settings' => array('max_length' => 255),
158 'instance_settings' => array('text_processing' => 0),
159 'default_widget' => 'text_textfield',
160 'default_formatter' => 'text_default',
161 ),
162 'text_long' => array(
163 'label' => t('Long text'),
164 'description' => t('This field stores long text in the database.'),
165 'settings' => array('max_length' => ''),
166 'instance_settings' => array('text_processing' => 0),
167 'default_widget' => 'text_textarea',
168 'default_formatter' => 'text_default',
169 ),
170 'text_with_summary' => array(
171 'label' => t('Long text and summary'),
172 'description' => t('This field stores long text in the database along with optional summary text.'),
173 'settings' => array('max_length' => ''),
174 'instance_settings' => array('text_processing' => 1, 'display_summary' => 0),
175 'default_widget' => 'text_textarea_with_summary',
176 'default_formatter' => 'text_summary_or_trimmed',
177 ),
178 );
179 }
180
188 function hook_field_info_alter(&$info) {
189 // Add a setting to all field types.
190 foreach ($info as $field_type => $field_type_info) {
191 $info[$field_type]['settings'] += array(
192 'mymodule_additional_setting' => 'default value',
193 );
194 }
195
196 // Change the default widget for fields of type 'foo'.
197 if (isset($info['foo'])) {
198 $info['foo']['default widget'] = 'mymodule_widget';
199 }
200 }
201
233 function hook_field_schema($field) {
234 if ($field['type'] == 'text_long') {
235 $columns = array(
236 'value' => array(
237 'type' => 'text',
238 'size' => 'big',
239 'not null' => FALSE,
240 ),
241 );
242 }
243 else {
244 $columns = array(
245 'value' => array(
246 'type' => 'varchar',
247 'length' => $field['settings']['max_length'],
248 'not null' => FALSE,
249 ),
250 );
251 }
252 $columns += array(
253 'format' => array(
254 'type' => 'varchar',
255 'length' => 255,
256 'not null' => FALSE,
257 ),
258 );
259 return array(
260 'columns' => $columns,
261 'indexes' => array(
262 'format' => array('format'),
263 ),
264 'foreign keys' => array(
265 'format' => array(
266 'table' => 'filter_format',
267 'columns' => array('format' => 'format'),
268 ),
269 ),
270 );
271 }
272
308 function hook_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
309 // Sample code from text.module: precompute sanitized strings so they are
310 // stored in the field cache.
311 foreach ($entities as $id => $entity) {
312 foreach ($items[$id] as $delta => $item) {
313 // Only process items with a cacheable format, the rest will be handled
314 // by formatters if needed.
315 if (empty($instances[$id]['settings']['text_processing']) || filter_format_allowcache($item['format'])) {
316 $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $langcode, $item, 'value') : '';
317 if ($field['type'] == 'text_with_summary') {
318 $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : '';
319 }
320 }
321 }
322 }
323 }
324
354 function hook_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) {
355 // Sample code from image.module: if there are no images specified at all,
356 // use the default image.
357 foreach ($entities as $id => $entity) {
358 if (empty($items[$id]) && $field['settings']['default_image']) {
359 if ($file = file_load($field['settings']['default_image'])) {
360 $items[$id][0] = (array) $file + array(
361 'is_default' => TRUE,
362 'alt' => '',
363 'title' => '',
364 );
365 }
366 }
367 }
368 }
369
396 function hook_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
397 foreach ($items as $delta => $item) {
398 if (!empty($item['value'])) {
399 if (!empty($field['settings']['max_length']) && drupal_strlen($item['value']) > $field['settings']['max_length']) {
400 $errors[$field['field_name']][$langcode][$delta][] = array(
401 'error' => 'text_max_length',
402 'message' => t('%name: the value may not be longer than %max characters.', array('%name' => $instance['label'], '%max' => $field['settings']['max_length'])),
403 );
404 }
405 }
406 }
407 }
408
428 function hook_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
429 if ($field['type'] == 'number_decimal') {
430 // Let PHP round the value to ensure consistent behavior across storage
431 // backends.
432 foreach ($items as $delta => $item) {
433 if (isset($item['value'])) {
434 $items[$delta]['value'] = round($item['value'], $field['settings']['scale']);
435 }
436 }
437 }
438 }
439
466 function hook_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
467 if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node' && $entity->status) {
468 $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created', ));
469 foreach ($items as $item) {
470 $query->values(array(
471 'nid' => $entity->nid,
472 'tid' => $item['tid'],
473 'sticky' => $entity->sticky,
474 'created' => $entity->created,
475 ));
476 }
477 $query->execute();
478 }
479 }
480
507 function hook_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
508 if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node') {
509 $first_call = &drupal_static(__FUNCTION__, array());
510
511 // We don't maintain data for old revisions, so clear all previous values
512 // from the table. Since this hook runs once per field, per object, make
513 // sure we only wipe values once.
514 if (!isset($first_call[$entity->nid])) {
515 $first_call[$entity->nid] = FALSE;
516 db_delete('taxonomy_index')->condition('nid', $entity->nid)->execute();
517 }
518 // Only save data to the table if the node is published.
519 if ($entity->status) {
520 $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created'));
521 foreach ($items as $item) {
522 $query->values(array(
523 'nid' => $entity->nid,
524 'tid' => $item['tid'],
525 'sticky' => $entity->sticky,
526 'created' => $entity->created,
527 ));
528 }
529 $query->execute();
530 }
531 }
532 }
533
550 function hook_field_storage_update_field($field, $prior_field, $has_data) {
551 if (!$has_data) {
552 // There is no data. Re-create the tables completely.
553 $prior_schema = _field_sql_storage_schema($prior_field);
554 foreach ($prior_schema as $name => $table) {
555 db_drop_table($name, $table);
556 }
557 $schema = _field_sql_storage_schema($field);
558 foreach ($schema as $name => $table) {
559 db_create_table($name, $table);
560 }
561 }
562 else {
563 // There is data. See field_sql_storage_field_storage_update_field() for
564 // an example of what to do to modify the schema in place, preserving the
565 // old data as much as possible.
566 }
567 drupal_get_schema(NULL, TRUE);
568 }
569
596 function hook_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
597 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
598 foreach ($items as $delta => $item) {
599 // For hook_file_references(), remember that this is being deleted.
600 $item['file_field_name'] = $field['field_name'];
601 // Pass in the ID of the object that is being removed so all references can
602 // be counted in hook_file_references().
603 $item['file_field_type'] = $entity_type;
604 $item['file_field_id'] = $id;
605 file_field_delete_file($item, $field, $entity_type, $id);
606 }
607 }
608
629 function hook_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) {
630 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
631 foreach ($items as $delta => $item) {
632 // For hook_file_references, remember that this file is being deleted.
633 $item['file_field_name'] = $field['field_name'];
634 if (file_field_delete_file($item, $field, $entity_type, $id)) {
635 $items[$delta] = NULL;
636 }
637 }
638 }
639
660 function hook_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
661 // If the translating user is not permitted to use the assigned text format,
662 // we must not expose the source values.
663 $field_name = $field['field_name'];
664 $formats = filter_formats();
665 $format_id = $source_entity->{$field_name}[$source_langcode][0]['format'];
666 if (!filter_access($formats[$format_id])) {
667 $items = array();
668 }
669 }
670
683 function hook_field_is_empty($item, $field) {
684 if (empty($item['value']) && (string) $item['value'] !== '0') {
685 return TRUE;
686 }
687 return FALSE;
688 }
689
754 function hook_field_widget_info() {
755 return array(
756 'text_textfield' => array(
757 'label' => t('Text field'),
758 'field types' => array('text'),
759 'settings' => array('size' => 60),
760 'behaviors' => array(
761 'multiple values' => FIELD_BEHAVIOR_DEFAULT,
762 'default value' => FIELD_BEHAVIOR_DEFAULT,
763 ),
764 ),
765 'text_textarea' => array(
766 'label' => t('Text area (multiple rows)'),
767 'field types' => array('text_long'),
768 'settings' => array('rows' => 5),
769 'behaviors' => array(
770 'multiple values' => FIELD_BEHAVIOR_DEFAULT,
771 'default value' => FIELD_BEHAVIOR_DEFAULT,
772 ),
773 ),
774 'text_textarea_with_summary' => array(
775 'label' => t('Text area with a summary'),
776 'field types' => array('text_with_summary'),
777 'settings' => array('rows' => 20, 'summary_rows' => 5),
778 'behaviors' => array(
779 'multiple values' => FIELD_BEHAVIOR_DEFAULT,
780 'default value' => FIELD_BEHAVIOR_DEFAULT,
781 ),
782 // As an advanced widget, force it to sink to the bottom of the choices.
783 'weight' => 2,
784 ),
785 );
786 }
787
795 function hook_field_widget_info_alter(&$info) {
796 // Add a setting to a widget type.
797 $info['text_textfield']['settings'] += array(
798 'mymodule_additional_setting' => 'default value',
799 );
800
801 // Let a new field type re-use an existing widget.
802 $info['options_select']['field types'][] = 'my_field_type';
803 }
804
883 function hook_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
884 $element += array(
885 '#type' => $instance['widget']['type'],
886 '#default_value' => isset($items[$delta]) ? $items[$delta] : '',
887 );
888 return array('value' => $element);
889 }
890
912 function hook_field_widget_form_alter(&$element, &$form_state, $context) {
913 // Add a css class to widget form elements for all fields of type mytype.
914 if ($context['field']['type'] == 'mytype') {
915 // Be sure not to overwrite existing attributes.
916 $element['#attributes']['class'][] = 'myclass';
917 }
918 }
919
946 function hook_field_widget_WIDGET_TYPE_form_alter(&$element, &$form_state, $context) {
947 // Code here will only act on widgets of type WIDGET_TYPE. For example,
948 // hook_field_widget_mymodule_autocomplete_form_alter() will only act on
949 // widgets of type 'mymodule_autocomplete'.
950 $element['#autocomplete_path'] = 'mymodule/autocomplete_path';
951 }
952
976 function hook_field_widget_properties_alter(&$widget, $context) {
977 // Change a widget's type according to the time of day.
978 $field = $context['field'];
979 if ($context['entity_type'] == 'node' && $field['field_name'] == 'field_foo') {
980 $time = date('H');
981 $widget['type'] = $time < 12 ? 'widget_am' : 'widget_pm';
982 }
983 }
984
1004 function hook_field_widget_error($element, $error, $form, &$form_state) {
1005 form_error($element, $error['message']);
1006 }
1007
1008
1055 function hook_field_formatter_info() {
1056 return array(
1057 'text_default' => array(
1058 'label' => t('Default'),
1059 'field types' => array('text', 'text_long', 'text_with_summary'),
1060 ),
1061 'text_plain' => array(
1062 'label' => t('Plain text'),
1063 'field types' => array('text', 'text_long', 'text_with_summary'),
1064 ),
1065
1066 // The text_trimmed formatter displays the trimmed version of the
1067 // full element of the field. It is intended to be used with text
1068 // and text_long fields. It also works with text_with_summary
1069 // fields though the text_summary_or_trimmed formatter makes more
1070 // sense for that field type.
1071 'text_trimmed' => array(
1072 'label' => t('Trimmed'),
1073 'field types' => array('text', 'text_long', 'text_with_summary'),
1074 ),
1075
1076 // The 'summary or trimmed' field formatter for text_with_summary
1077 // fields displays returns the summary element of the field or, if
1078 // the summary is empty, the trimmed version of the full element
1079 // of the field.
1080 'text_summary_or_trimmed' => array(
1081 'label' => t('Summary or trimmed'),
1082 'field types' => array('text_with_summary'),
1083 ),
1084 );
1085 }
1086
1094 function hook_field_formatter_info_alter(&$info) {
1095 // Add a setting to a formatter type.
1096 $info['text_default']['settings'] += array(
1097 'mymodule_additional_setting' => 'default value',
1098 );
1099
1100 // Let a new field type re-use an existing formatter.
1101 $info['text_default']['field types'][] = 'my_field_type';
1102 }
1103
1139 function hook_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) {
1140 $tids = array();
1141
1142 // Collect every possible term attached to any of the fieldable entities.
1143 foreach ($entities as $id => $entity) {
1144 foreach ($items[$id] as $delta => $item) {
1145 // Force the array key to prevent duplicates.
1146 $tids[$item['tid']] = $item['tid'];
1147 }
1148 }
1149
1150 if ($tids) {
1151 $terms = taxonomy_term_load_multiple($tids);
1152
1153 // Iterate through the fieldable entities again to attach the loaded term
1154 // data.
1155 foreach ($entities as $id => $entity) {
1156 $rekey = FALSE;
1157
1158 foreach ($items[$id] as $delta => $item) {
1159 // Check whether the taxonomy term field instance value could be loaded.
1160 if (isset($terms[$item['tid']])) {
1161 // Replace the instance value with the term data.
1162 $items[$id][$delta]['taxonomy_term'] = $terms[$item['tid']];
1163 }
1164 // Otherwise, unset the instance value, since the term does not exist.
1165 else {
1166 unset($items[$id][$delta]);
1167 $rekey = TRUE;
1168 }
1169 }
1170
1171 if ($rekey) {
1172 // Rekey the items array.
1173 $items[$id] = array_values($items[$id]);
1174 }
1175 }
1176 }
1177 }
1178
1204 function hook_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
1205 $element = array();
1206 $settings = $display['settings'];
1207
1208 switch ($display['type']) {
1209 case 'sample_field_formatter_simple':
1210 // Common case: each value is displayed individually in a sub-element
1211 // keyed by delta. The field.tpl.php template specifies the markup
1212 // wrapping each value.
1213 foreach ($items as $delta => $item) {
1214 $element[$delta] = array('#markup' => $settings['some_setting'] . $item['value']);
1215 }
1216 break;
1217
1218 case 'sample_field_formatter_themeable':
1219 // More elaborate formatters can defer to a theme function for easier
1220 // customization.
1221 foreach ($items as $delta => $item) {
1222 $element[$delta] = array(
1223 '#theme' => 'mymodule_theme_sample_field_formatter_themeable',
1224 '#data' => $item['value'],
1225 '#some_setting' => $settings['some_setting'],
1226 );
1227 }
1228 break;
1229
1230 case 'sample_field_formatter_combined':
1231 // Some formatters might need to display all values within a single piece
1232 // of markup.
1233 $rows = array();
1234 foreach ($items as $delta => $item) {
1235 $rows[] = array($delta, $item['value']);
1236 }
1237 $element[0] = array(
1238 '#theme' => 'table',
1239 '#header' => array(t('Delta'), t('Value')),
1240 '#rows' => $rows,
1241 );
1242 break;
1243 }
1244
1245 return $element;
1246 }
1247
1281 function hook_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
1282 // Add a checkbox allowing a given field to be emptied.
1283 // See hook_field_attach_submit() for the corresponding processing code.
1284 $form['empty_field_foo'] = array(
1285 '#type' => 'checkbox',
1286 '#title' => t("Empty the 'field_foo' field"),
1287 );
1288 }
1289
1305 function hook_field_attach_load($entity_type, $entities, $age, $options) {
1306 // @todo Needs function body.
1307 }
1308
1316 function hook_field_attach_validate($entity_type, $entity, &$errors) {
1317 // @todo Needs function body.
1318 }
1319
1338 function hook_field_attach_submit($entity_type, $entity, $form, &$form_state) {
1339 // Sample case of an 'Empty the field' checkbox added on the form, allowing
1340 // a given field to be emptied.
1341 $values = drupal_array_get_nested_value($form_state['values'], $form['#parents']);
1342 if (!empty($values['empty_field_foo'])) {
1343 unset($entity->field_foo);
1344 }
1345 }
1346
1354 function hook_field_attach_presave($entity_type, $entity) {
1355 // @todo Needs function body.
1356 }
1357
1365 function hook_field_attach_insert($entity_type, $entity) {
1366 // @todo Needs function body.
1367 }
1368
1376 function hook_field_attach_update($entity_type, $entity) {
1377 // @todo Needs function body.
1378 }
1379
1395 function hook_field_attach_preprocess_alter(&$variables, $context) {
1396 // @todo Needs function body.
1397 }
1398
1406 function hook_field_attach_delete($entity_type, $entity) {
1407 // @todo Needs function body.
1408 }
1409
1417 function hook_field_attach_delete_revision($entity_type, $entity) {
1418 // @todo Needs function body.
1419 }
1420
1441 function hook_field_attach_purge($entity_type, $entity, $field, $instance) {
1442 // find the corresponding data in mymodule and purge it
1443 if ($entity_type == 'node' && $field->field_name == 'my_field_name') {
1444 mymodule_remove_mydata($entity->nid);
1445 }
1446 }
1447
1468 function hook_field_attach_view_alter(&$output, $context) {
1469 // Append RDF term mappings on displayed taxonomy links.
1470 foreach (element_children($output) as $field_name) {
1471 $element = &$output[$field_name];
1472 if ($element['#field_type'] == 'taxonomy_term_reference' && $element['#formatter'] == 'taxonomy_term_reference_link') {
1473 foreach ($element['#items'] as $delta => $item) {
1474 $term = $item['taxonomy_term'];
1475 if (!empty($term->rdf_mapping['rdftype'])) {
1476 $element[$delta]['#options']['attributes']['typeof'] = $term->rdf_mapping['rdftype'];
1477 }
1478 if (!empty($term->rdf_mapping['name']['predicates'])) {
1479 $element[$delta]['#options']['attributes']['property'] = $term->rdf_mapping['name']['predicates'];
1480 }
1481 }
1482 }
1483 }
1484 }
1485
1500 function hook_field_attach_prepare_translation_alter(&$entity, $context) {
1501 if ($context['entity_type'] == 'custom_entity_type') {
1502 $entity->custom_field = $context['source_entity']->custom_field;
1503 }
1504 }
1505
1520 function hook_field_language_alter(&$display_language, $context) {
1521 // Do not apply core language fallback rules if they are disabled or if Locale
1522 // is not registered as a translation handler.
1523 if (variable_get('locale_field_language_fallback', TRUE) && field_has_translation_handler($context['entity_type'], 'locale')) {
1524 locale_field_language_fallback($display_language, $context['entity'], $context['language']);
1525 }
1526 }
1527
1541 function hook_field_available_languages_alter(&$languages, $context) {
1542 // Add an unavailable language.
1543 $languages[] = 'xx';
1544
1545 // Remove an available language.
1546 $index = array_search('yy', $languages);
1547 unset($languages[$index]);
1548 }
1549
1557 function hook_field_attach_create_bundle($entity_type, $bundle) {
1558 // When a new bundle is created, the menu needs to be rebuilt to add the
1559 // Field UI menu item tabs.
1560 variable_set('menu_rebuild_needed', TRUE);
1561 }
1562
1570 function hook_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
1571 // Update the extra weights variable with new information.
1572 if ($bundle_old !== $bundle_new) {
1573 $extra_weights = variable_get('field_extra_weights', array());
1574 if (isset($info[$entity_type][$bundle_old])) {
1575 $extra_weights[$entity_type][$bundle_new] = $extra_weights[$entity_type][$bundle_old];
1576 unset($extra_weights[$entity_type][$bundle_old]);
1577 variable_set('field_extra_weights', $extra_weights);
1578 }
1579 }
1580 }
1581
1595 function hook_field_attach_delete_bundle($entity_type, $bundle, $instances) {
1596 // Remove the extra weights variable information for this bundle.
1597 $extra_weights = variable_get('field_extra_weights', array());
1598 if (isset($extra_weights[$entity_type][$bundle])) {
1599 unset($extra_weights[$entity_type][$bundle]);
1600 variable_set('field_extra_weights', $extra_weights);
1601 }
1602 }
1603
1628 function hook_field_storage_info() {
1629 return array(
1630 'field_sql_storage' => array(
1631 'label' => t('Default SQL storage'),
1632 'description' => t('Stores fields in the local SQL database, using per-field tables.'),
1633 'settings' => array(),
1634 ),
1635 );
1636 }
1637
1645 function hook_field_storage_info_alter(&$info) {
1646 // Add a setting to a storage type.
1647 $info['field_sql_storage']['settings'] += array(
1648 'mymodule_additional_setting' => 'default value',
1649 );
1650 }
1651
1674 function hook_field_storage_details($field) {
1675 $details = array();
1676
1677 // Add field columns.
1678 foreach ((array) $field['columns'] as $column_name => $attributes) {
1679 $real_name = _field_sql_storage_columnname($field['field_name'], $column_name);
1680 $columns[$column_name] = $real_name;
1681 }
1682 return array(
1683 'sql' => array(
1684 FIELD_LOAD_CURRENT => array(
1685 _field_sql_storage_tablename($field) => $columns,
1686 ),
1687 FIELD_LOAD_REVISION => array(
1688 _field_sql_storage_revision_tablename($field) => $columns,
1689 ),
1690 ),
1691 );
1692 }
1693
1705 function hook_field_storage_details_alter(&$details, $field) {
1706 if ($field['field_name'] == 'field_of_interest') {
1707 $columns = array();
1708 foreach ((array) $field['columns'] as $column_name => $attributes) {
1709 $columns[$column_name] = $column_name;
1710 }
1711 $details['drupal_variables'] = array(
1712 FIELD_LOAD_CURRENT => array(
1713 'moon' => $columns,
1714 ),
1715 FIELD_LOAD_REVISION => array(
1716 'mars' => $columns,
1717 ),
1718 );
1719 }
1720 }
1721
1749 function hook_field_storage_load($entity_type, $entities, $age, $fields, $options) {
1750 $load_current = $age == FIELD_LOAD_CURRENT;
1751
1752 foreach ($fields as $field_id => $ids) {
1753 // By the time this hook runs, the relevant field definitions have been
1754 // populated and cached in FieldInfo, so calling field_info_field_by_id()
1755 // on each field individually is more efficient than loading all fields in
1756 // memory upfront with field_info_field_by_ids().
1757 $field = field_info_field_by_id($field_id);
1758 $field_name = $field['field_name'];
1759 $table = $load_current ? _field_sql_storage_tablename($field) : _field_sql_storage_revision_tablename($field);
1760
1761 $query = db_select($table, 't')
1762 ->fields('t')
1763 ->condition('entity_type', $entity_type)
1764 ->condition($load_current ? 'entity_id' : 'revision_id', $ids, 'IN')
1765 ->condition('language', field_available_languages($entity_type, $field), 'IN')
1766 ->orderBy('delta');
1767
1768 if (empty($options['deleted'])) {
1769 $query->condition('deleted', 0);
1770 }
1771
1772 $results = $query->execute();
1773
1774 $delta_count = array();
1775 foreach ($results as $row) {
1776 if (!isset($delta_count[$row->entity_id][$row->language])) {
1777 $delta_count[$row->entity_id][$row->language] = 0;
1778 }
1779
1780 if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->language] < $field['cardinality']) {
1781 $item = array();
1782 // For each column declared by the field, populate the item
1783 // from the prefixed database column.
1784 foreach ($field['columns'] as $column => $attributes) {
1785 $column_name = _field_sql_storage_columnname($field_name, $column);
1786 $item[$column] = $row->$column_name;
1787 }
1788
1789 // Add the item to the field values for the entity.
1790 $entities[$row->entity_id]->{$field_name}[$row->language][] = $item;
1791 $delta_count[$row->entity_id][$row->language]++;
1792 }
1793 }
1794 }
1795 }
1796
1814 function hook_field_storage_write($entity_type, $entity, $op, $fields) {
1815 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
1816 if (!isset($vid)) {
1817 $vid = $id;
1818 }
1819
1820 foreach ($fields as $field_id) {
1821 $field = field_info_field_by_id($field_id);
1822 $field_name = $field['field_name'];
1823 $table_name = _field_sql_storage_tablename($field);
1824 $revision_name = _field_sql_storage_revision_tablename($field);
1825
1826 $all_languages = field_available_languages($entity_type, $field);
1827 $field_languages = array_intersect($all_languages, array_keys((array) $entity->$field_name));
1828
1829 // Delete and insert, rather than update, in case a value was added.
1830 if ($op == FIELD_STORAGE_UPDATE) {
1831 // Delete languages present in the incoming $entity->$field_name.
1832 // Delete all languages if $entity->$field_name is empty.
1833 $languages = !empty($entity->$field_name) ? $field_languages : $all_languages;
1834 if ($languages) {
1835 db_delete($table_name)
1836 ->condition('entity_type', $entity_type)
1837 ->condition('entity_id', $id)
1838 ->condition('language', $languages, 'IN')
1839 ->execute();
1840 db_delete($revision_name)
1841 ->condition('entity_type', $entity_type)
1842 ->condition('entity_id', $id)
1843 ->condition('revision_id', $vid)
1844 ->condition('language', $languages, 'IN')
1845 ->execute();
1846 }
1847 }
1848
1849 // Prepare the multi-insert query.
1850 $do_insert = FALSE;
1851 $columns = array('entity_type', 'entity_id', 'revision_id', 'bundle', 'delta', 'language');
1852 foreach ($field['columns'] as $column => $attributes) {
1853 $columns[] = _field_sql_storage_columnname($field_name, $column);
1854 }
1855 $query = db_insert($table_name)->fields($columns);
1856 $revision_query = db_insert($revision_name)->fields($columns);
1857
1858 foreach ($field_languages as $langcode) {
1859 $items = (array) $entity->{$field_name}[$langcode];
1860 $delta_count = 0;
1861 foreach ($items as $delta => $item) {
1862 // We now know we have someting to insert.
1863 $do_insert = TRUE;
1864 $record = array(
1865 'entity_type' => $entity_type,
1866 'entity_id' => $id,
1867 'revision_id' => $vid,
1868 'bundle' => $bundle,
1869 'delta' => $delta,
1870 'language' => $langcode,
1871 );
1872 foreach ($field['columns'] as $column => $attributes) {
1873 $record[_field_sql_storage_columnname($field_name, $column)] = isset($item[$column]) ? $item[$column] : NULL;
1874 }
1875 $query->values($record);
1876 if (isset($vid)) {
1877 $revision_query->values($record);
1878 }
1879
1880 if ($field['cardinality'] != FIELD_CARDINALITY_UNLIMITED && ++$delta_count == $field['cardinality']) {
1881 break;
1882 }
1883 }
1884 }
1885
1886 // Execute the query if we have values to insert.
1887 if ($do_insert) {
1888 $query->execute();
1889 $revision_query->execute();
1890 }
1891 }
1892 }
1893
1908 function hook_field_storage_delete($entity_type, $entity, $fields) {
1909 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
1910
1911 foreach (field_info_instances($entity_type, $bundle) as $instance) {
1912 if (isset($fields[$instance['field_id']])) {
1913 $field = field_info_field_by_id($instance['field_id']);
1914 field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance);
1915 }
1916 }
1917 }
1918
1938 function hook_field_storage_delete_revision($entity_type, $entity, $fields) {
1939 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
1940
1941 if (isset($vid)) {
1942 foreach ($fields as $field_id) {
1943 $field = field_info_field_by_id($field_id);
1944 $revision_name = _field_sql_storage_revision_tablename($field);
1945 db_delete($revision_name)
1946 ->condition('entity_type', $entity_type)
1947 ->condition('entity_id', $id)
1948 ->condition('revision_id', $vid)
1949 ->execute();
1950 }
1951 }
1952 }
1953
1968 function hook_field_storage_query($query) {
1969 $groups = array();
1970 if ($query->age == FIELD_LOAD_CURRENT) {
1971 $tablename_function = '_field_sql_storage_tablename';
1972 $id_key = 'entity_id';
1973 }
1974 else {
1975 $tablename_function = '_field_sql_storage_revision_tablename';
1976 $id_key = 'revision_id';
1977 }
1978 $table_aliases = array();
1979 // Add tables for the fields used.
1980 foreach ($query->fields as $key => $field) {
1981 $tablename = $tablename_function($field);
1982 // Every field needs a new table.
1983 $table_alias = $tablename . $key;
1984 $table_aliases[$key] = $table_alias;
1985 if ($key) {
1986 $select_query->join($tablename, $table_alias, "$table_alias.entity_type = $field_base_table.entity_type AND $table_alias.$id_key = $field_base_table.$id_key");
1987 }
1988 else {
1989 $select_query = db_select($tablename, $table_alias);
1990 $select_query->addTag('entity_field_access');
1991 $select_query->addMetaData('base_table', $tablename);
1992 $select_query->fields($table_alias, array('entity_type', 'entity_id', 'revision_id', 'bundle'));
1993 $field_base_table = $table_alias;
1994 }
1995 if ($field['cardinality'] != 1) {
1996 $select_query->distinct();
1997 }
1998 }
1999
2000 // Add field conditions.
2001 foreach ($query->fieldConditions as $key => $condition) {
2002 $table_alias = $table_aliases[$key];
2003 $field = $condition['field'];
2004 // Add the specified condition.
2005 $sql_field = "$table_alias." . _field_sql_storage_columnname($field['field_name'], $condition['column']);
2006 $query->addCondition($select_query, $sql_field, $condition);
2007 // Add delta / language group conditions.
2008 foreach (array('delta', 'language') as $column) {
2009 if (isset($condition[$column . '_group'])) {
2010 $group_name = $condition[$column . '_group'];
2011 if (!isset($groups[$column][$group_name])) {
2012 $groups[$column][$group_name] = $table_alias;
2013 }
2014 else {
2015 $select_query->where("$table_alias.$column = " . $groups[$column][$group_name] . ".$column");
2016 }
2017 }
2018 }
2019 }
2020
2021 if (isset($query->deleted)) {
2022 $select_query->condition("$field_base_table.deleted", (int) $query->deleted);
2023 }
2024
2025 // Is there a need to sort the query by property?
2026 $has_property_order = FALSE;
2027 foreach ($query->order as $order) {
2028 if ($order['type'] == 'property') {
2029 $has_property_order = TRUE;
2030 }
2031 }
2032
2033 if ($query->propertyConditions || $has_property_order) {
2034 if (empty($query->entityConditions['entity_type']['value'])) {
2035 throw new EntityFieldQueryException('Property conditions and orders must have an entity type defined.');
2036 }
2037 $entity_type = $query->entityConditions['entity_type']['value'];
2038 $entity_base_table = _field_sql_storage_query_join_entity($select_query, $entity_type, $field_base_table);
2039 $query->entityConditions['entity_type']['operator'] = '=';
2040 foreach ($query->propertyConditions as $property_condition) {
2041 $query->addCondition($select_query, "$entity_base_table." . $property_condition['column'], $property_condition);
2042 }
2043 }
2044 foreach ($query->entityConditions as $key => $condition) {
2045 $query->addCondition($select_query, "$field_base_table.$key", $condition);
2046 }
2047
2048 // Order the query.
2049 foreach ($query->order as $order) {
2050 if ($order['type'] == 'entity') {
2051 $key = $order['specifier'];
2052 $select_query->orderBy("$field_base_table.$key", $order['direction']);
2053 }
2054 elseif ($order['type'] == 'field') {
2055 $specifier = $order['specifier'];
2056 $field = $specifier['field'];
2057 $table_alias = $table_aliases[$specifier['index']];
2058 $sql_field = "$table_alias." . _field_sql_storage_columnname($field['field_name'], $specifier['column']);
2059 $select_query->orderBy($sql_field, $order['direction']);
2060 }
2061 elseif ($order['type'] == 'property') {
2062 $select_query->orderBy("$entity_base_table." . $order['specifier'], $order['direction']);
2063 }
2064 }
2065
2066 return $query->finishQuery($select_query, $id_key);
2067 }
2068
2079 function hook_field_storage_create_field($field) {
2080 $schema = _field_sql_storage_schema($field);
2081 foreach ($schema as $name => $table) {
2082 db_create_table($name, $table);
2083 }
2084 drupal_get_schema(NULL, TRUE);
2085 }
2086
2096 function hook_field_storage_delete_field($field) {
2097 // Mark all data associated with the field for deletion.
2098 $field['deleted'] = 0;
2099 $table = _field_sql_storage_tablename($field);
2100 $revision_table = _field_sql_storage_revision_tablename($field);
2101 db_update($table)
2102 ->fields(array('deleted' => 1))
2103 ->execute();
2104
2105 // Move the table to a unique name while the table contents are being deleted.
2106 $field['deleted'] = 1;
2107 $new_table = _field_sql_storage_tablename($field);
2108 $revision_new_table = _field_sql_storage_revision_tablename($field);
2109 db_rename_table($table, $new_table);
2110 db_rename_table($revision_table, $revision_new_table);
2111 drupal_get_schema(NULL, TRUE);
2112 }
2113
2123 function hook_field_storage_delete_instance($instance) {
2124 $field = field_info_field($instance['field_name']);
2125 $table_name = _field_sql_storage_tablename($field);
2126 $revision_name = _field_sql_storage_revision_tablename($field);
2127 db_update($table_name)
2128 ->fields(array('deleted' => 1))
2129 ->condition('entity_type', $instance['entity_type'])
2130 ->condition('bundle', $instance['bundle'])
2131 ->execute();
2132 db_update($revision_name)
2133 ->fields(array('deleted' => 1))
2134 ->condition('entity_type', $instance['entity_type'])
2135 ->condition('bundle', $instance['bundle'])
2136 ->execute();
2137 }
2138
2172 function hook_field_storage_pre_load($entity_type, $entities, $age, &$skip_fields, $options) {
2173 // @todo Needs function body.
2174 }
2175
2193 function hook_field_storage_pre_insert($entity_type, $entity, &$skip_fields) {
2194 if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) {
2195 $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
2196 foreach ($entity->taxonomy_forums as $language) {
2197 foreach ($language as $delta) {
2198 $query->values(array(
2199 'nid' => $entity->nid,
2200 'title' => $entity->title,
2201 'tid' => $delta['value'],
2202 'sticky' => $entity->sticky,
2203 'created' => $entity->created,
2204 'comment_count' => 0,
2205 'last_comment_timestamp' => $entity->created,
2206 ));
2207 }
2208 }
2209 $query->execute();
2210 }
2211 }
2212
2230 function hook_field_storage_pre_update($entity_type, $entity, &$skip_fields) {
2231 $first_call = &drupal_static(__FUNCTION__, array());
2232
2233 if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) {
2234 // We don't maintain data for old revisions, so clear all previous values
2235 // from the table. Since this hook runs once per field, per entity, make
2236 // sure we only wipe values once.
2237 if (!isset($first_call[$entity->nid])) {
2238 $first_call[$entity->nid] = FALSE;
2239 db_delete('forum_index')->condition('nid', $entity->nid)->execute();
2240 }
2241 // Only save data to the table if the node is published.
2242 if ($entity->status) {
2243 $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
2244 foreach ($entity->taxonomy_forums as $language) {
2245 foreach ($language as $delta) {
2246 $query->values(array(
2247 'nid' => $entity->nid,
2248 'title' => $entity->title,
2249 'tid' => $delta['value'],
2250 'sticky' => $entity->sticky,
2251 'created' => $entity->created,
2252 'comment_count' => 0,
2253 'last_comment_timestamp' => $entity->created,
2254 ));
2255 }
2256 }
2257 $query->execute();
2258 // The logic for determining last_comment_count is fairly complex, so
2259 // call _forum_update_forum_index() too.
2260 _forum_update_forum_index($entity->nid);
2261 }
2262 }
2263 }
2264
2282 function hook_field_info_max_weight($entity_type, $bundle, $context) {
2283 $weights = array();
2284
2285 foreach (my_module_entity_additions($entity_type, $bundle, $context) as $addition) {
2286 $weights[] = $addition['weight'];
2287 }
2288
2289 return $weights ? max($weights) : NULL;
2290 }
2291
2316 function hook_field_display_alter(&$display, $context) {
2317 // Leave field labels out of the search index.
2318 // Note: The check against $context['entity_type'] == 'node' could be avoided
2319 // by using hook_field_display_node_alter() instead of
2320 // hook_field_display_alter(), resulting in less function calls when
2321 // rendering non-node entities.
2322 if ($context['entity_type'] == 'node' && $context['view_mode'] == 'search_index') {
2323 $display['label'] = 'hidden';
2324 }
2325 }
2326
2351 function hook_field_display_ENTITY_TYPE_alter(&$display, $context) {
2352 // Leave field labels out of the search index.
2353 if ($context['view_mode'] == 'search_index') {
2354 $display['label'] = 'hidden';
2355 }
2356 }
2357
2374 function hook_field_extra_fields_display_alter(&$displays, $context) {
2375 if ($context['entity_type'] == 'taxonomy_term' && $context['view_mode'] == 'full') {
2376 $displays['description']['visible'] = FALSE;
2377 }
2378 }
2379
2403 function hook_field_widget_properties_ENTITY_TYPE_alter(&$widget, $context) {
2404 // Change a widget's type according to the time of day.
2405 $field = $context['field'];
2406 if ($field['field_name'] == 'field_foo') {
2407 $time = date('H');
2408 $widget['type'] = $time < 12 ? 'widget_am' : 'widget_pm';
2409 }
2410 }
2411
2430 function hook_field_create_field($field) {
2431 // @todo Needs function body.
2432 }
2433
2443 function hook_field_create_instance($instance) {
2444 // @todo Needs function body.
2445 }
2446
2466 function hook_field_update_forbid($field, $prior_field, $has_data) {
2467 // A 'list' field stores integer keys mapped to display values. If
2468 // the new field will have fewer values, and any data exists for the
2469 // abandoned keys, the field will have no way to display them. So,
2470 // forbid such an update.
2471 if ($has_data && count($field['settings']['allowed_values']) < count($prior_field['settings']['allowed_values'])) {
2472 // Identify the keys that will be lost.
2473 $lost_keys = array_diff(array_keys($field['settings']['allowed_values']), array_keys($prior_field['settings']['allowed_values']));
2474 // If any data exist for those keys, forbid the update.
2475 $query = new EntityFieldQuery();
2476 $found = $query
2477 ->fieldCondition($prior_field['field_name'], 'value', $lost_keys)
2478 ->range(0, 1)
2479 ->execute();
2480 if ($found) {
2481 throw new FieldUpdateForbiddenException("Cannot update a list field not to include keys with existing data");
2482 }
2483 }
2484 }
2485
2498 function hook_field_update_field($field, $prior_field, $has_data) {
2499 // Reset the static value that keeps track of allowed values for list fields.
2500 drupal_static_reset('list_allowed_values');
2501 }
2502
2511 function hook_field_delete_field($field) {
2512 // @todo Needs function body.
2513 }
2514
2526 function hook_field_update_instance($instance, $prior_instance) {
2527 // @todo Needs function body.
2528 }
2529
2539 function hook_field_delete_instance($instance) {
2540 // @todo Needs function body.
2541 }
2542
2551 function hook_field_read_field($field) {
2552 // @todo Needs function body.
2553 }
2554
2563 function hook_field_read_instance($instance) {
2564 // @todo Needs function body.
2565 }
2566
2579 function hook_field_purge_field($field) {
2580 db_delete('my_module_field_info')
2581 ->condition('id', $field['id'])
2582 ->execute();
2583 }
2584
2597 function hook_field_purge_instance($instance) {
2598 db_delete('my_module_field_instance_info')
2599 ->condition('id', $instance['id'])
2600 ->execute();
2601 }
2602
2612 function hook_field_storage_purge_field($field) {
2613 $table_name = _field_sql_storage_tablename($field);
2614 $revision_name = _field_sql_storage_revision_tablename($field);
2615 db_drop_table($table_name);
2616 db_drop_table($revision_name);
2617 }
2618
2629 function hook_field_storage_purge_field_instance($instance) {
2630 db_delete('my_module_field_instance_info')
2631 ->condition('id', $instance['id'])
2632 ->execute();
2633 }
2634
2650 function hook_field_storage_purge($entity_type, $entity, $field, $instance) {
2651 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
2652
2653 $table_name = _field_sql_storage_tablename($field);
2654 $revision_name = _field_sql_storage_revision_tablename($field);
2655 db_delete($table_name)
2656 ->condition('entity_type', $entity_type)
2657 ->condition('entity_id', $id)
2658 ->execute();
2659 db_delete($revision_name)
2660 ->condition('entity_type', $entity_type)
2661 ->condition('entity_id', $id)
2662 ->execute();
2663 }
2664
2689 function hook_field_access($op, $field, $entity_type, $entity, $account) {
2690 if ($field['field_name'] == 'field_of_interest' && $op == 'edit') {
2691 return user_access('edit field of interest', $account);
2692 }
2693 return TRUE;
2694 }
2695
hook_field_storage_pre_load
hook_field_storage_pre_load($entity_type, $entities, $age, &$skip_fields, $options)
Definition: field.api.php:2172
hook_field_update
hook_field_update($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: field.api.php:507
hook_field_storage_delete_revision
hook_field_storage_delete_revision($entity_type, $entity, $fields)
Definition: field.api.php:1938
hook_field_storage_info
hook_field_storage_info()
Definition: field.api.php:1628
field_sql_storage_field_storage_purge
field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance)
Definition: field_sql_storage.module:479
hook_field_extra_fields_alter
hook_field_extra_fields_alter(&$info)
Definition: field.api.php:80
hook_field_widget_error
hook_field_widget_error($element, $error, $form, &$form_state)
Definition: field.api.php:1004
hook_field_available_languages_alter
hook_field_available_languages_alter(&$languages, $context)
Definition: field.api.php:1541
field_info_field_by_id
field_info_field_by_id($field_id)
Definition: field.info.inc:537
$op
$op
Definition: update.php:404
hook_field_is_empty
hook_field_is_empty($item, $field)
Definition: field.api.php:683
hook_field_load
hook_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age)
Definition: field.api.php:308
hook_field_formatter_prepare_view
hook_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays)
Definition: field.api.php:1139
hook_field_update_field
hook_field_update_field($field, $prior_field, $has_data)
Definition: field.api.php:2498
drupal_strlen
drupal_strlen($text)
Definition: unicode.inc:474
filter_format_allowcache
filter_format_allowcache($format_id)
Definition: filter.module:642
hook_field_attach_delete_revision
hook_field_attach_delete_revision($entity_type, $entity)
Definition: field.api.php:1417
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
drupal_array_get_nested_value
& drupal_array_get_nested_value(array &$array, array $parents, &$key_exists=NULL)
Definition: common.inc:6666
hook_field_extra_fields_display_alter
hook_field_extra_fields_display_alter(&$displays, $context)
Definition: field.api.php:2374
hook_field_storage_load
hook_field_storage_load($entity_type, $entities, $age, $fields, $options)
Definition: field.api.php:1749
FIELD_STORAGE_UPDATE
const FIELD_STORAGE_UPDATE
Definition: field.attach.inc:58
hook_field_storage_purge_field
hook_field_storage_purge_field($field)
Definition: field.api.php:2612
field_info_instances
field_info_instances($entity_type=NULL, $bundle_name=NULL)
Definition: field.info.inc:592
hook_field_formatter_view
hook_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
Definition: field.api.php:1204
field_available_languages
field_available_languages($entity_type, $field)
Definition: field.multilingual.inc:89
hook_field_storage_create_field
hook_field_storage_create_field($field)
Definition: field.api.php:2079
hook_field_purge_instance
hook_field_purge_instance($instance)
Definition: field.api.php:2597
hook_field_attach_form
hook_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode)
Definition: field.api.php:1281
_field_sql_storage_query_join_entity
_field_sql_storage_query_join_entity(SelectQuery $select_query, $entity_type, $field_base_table)
Definition: field_sql_storage.module:603
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
hook_field_widget_form_alter
hook_field_widget_form_alter(&$element, &$form_state, $context)
Definition: field.api.php:912
$name
print $name
Definition: profile-listing.tpl.php:43
$results
print $results
Definition: poll-results.tpl.php:23
hook_field_delete_field
hook_field_delete_field($field)
Definition: field.api.php:2511
hook_field_presave
hook_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: field.api.php:428
file_field_delete_file
file_field_delete_file($item, $field, $entity_type, $id, $count=1)
Definition: file.field.inc:350
hook_field_storage_delete_instance
hook_field_storage_delete_instance($instance)
Definition: field.api.php:2123
hook_field_update_forbid
hook_field_update_forbid($field, $prior_field, $has_data)
Definition: field.api.php:2466
hook_field_storage_info_alter
hook_field_storage_info_alter(&$info)
Definition: field.api.php:1645
$attributes
print $attributes
Definition: block.tpl.php:47
hook_field_widget_properties_ENTITY_TYPE_alter
hook_field_widget_properties_ENTITY_TYPE_alter(&$widget, $context)
Definition: field.api.php:2403
hook_field_read_instance
hook_field_read_instance($instance)
Definition: field.api.php:2563
hook_field_info_max_weight
hook_field_info_max_weight($entity_type, $bundle, $context)
Definition: field.api.php:2282
hook_field_info
hook_field_info()
Definition: field.api.php:152
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
hook_field_attach_validate
hook_field_attach_validate($entity_type, $entity, &$errors)
Definition: field.api.php:1316
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
FIELD_BEHAVIOR_DEFAULT
const FIELD_BEHAVIOR_DEFAULT
Definition: field.module:255
hook_field_storage_pre_update
hook_field_storage_pre_update($entity_type, $entity, &$skip_fields)
Definition: field.api.php:2230
hook_field_storage_write
hook_field_storage_write($entity_type, $entity, $op, $fields)
Definition: field.api.php:1814
_forum_node_check_node_type
_forum_node_check_node_type($node)
Definition: forum.module:255
hook_field_attach_insert
hook_field_attach_insert($entity_type, $entity)
Definition: field.api.php:1365
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
drupal_get_schema
drupal_get_schema($table=NULL, $rebuild=FALSE)
Definition: bootstrap.inc:2940
node_type_get_types
node_type_get_types()
Definition: node.module:393
hook_field_attach_delete
hook_field_attach_delete($entity_type, $entity)
Definition: field.api.php:1406
hook_field_widget_WIDGET_TYPE_form_alter
hook_field_widget_WIDGET_TYPE_form_alter(&$element, &$form_state, $context)
Definition: field.api.php:946
hook_field_widget_info_alter
hook_field_widget_info_alter(&$info)
Definition: field.api.php:795
hook_field_schema
hook_field_schema($field)
Definition: field.api.php:233
hook_field_attach_load
hook_field_attach_load($entity_type, $entities, $age, $options)
Definition: field.api.php:1305
hook_field_storage_details_alter
hook_field_storage_details_alter(&$details, $field)
Definition: field.api.php:1705
_text_sanitize
_text_sanitize($instance, $langcode, $item, $column)
Definition: text.module:313
hook_field_storage_details
hook_field_storage_details($field)
Definition: field.api.php:1674
hook_field_read_field
hook_field_read_field($field)
Definition: field.api.php:2551
$info
$info
Definition: color.inc:6
hook_field_info_alter
hook_field_info_alter(&$info)
Definition: field.api.php:188
hook_field_storage_delete
hook_field_storage_delete($entity_type, $entity, $fields)
Definition: field.api.php:1908
hook_field_formatter_info_alter
hook_field_formatter_info_alter(&$info)
Definition: field.api.php:1094
hook_field_purge_field
hook_field_purge_field($field)
Definition: field.api.php:2579
hook_field_storage_update_field
hook_field_storage_update_field($field, $prior_field, $has_data)
Definition: field.api.php:550
field_has_translation_handler
field_has_translation_handler($entity_type, $handler=NULL)
Definition: field.multilingual.inc:195
hook_field_attach_update
hook_field_attach_update($entity_type, $entity)
Definition: field.api.php:1376
FIELD_LOAD_REVISION
const FIELD_LOAD_REVISION
Definition: field.module:274
EntityFieldQuery
Definition: entity.inc:420
hook_field_validate
hook_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
Definition: field.api.php:396
file_load
file_load($fid)
Definition: file.inc:580
hook_field_delete_instance
hook_field_delete_instance($instance)
Definition: field.api.php:2539
hook_field_widget_info
hook_field_widget_info()
Definition: field.api.php:754
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
_field_sql_storage_schema
_field_sql_storage_schema($field)
Definition: field_sql_storage.module:108
hook_field_attach_purge
hook_field_attach_purge($entity_type, $entity, $field, $instance)
Definition: field.api.php:1441
FIELD_CARDINALITY_UNLIMITED
const FIELD_CARDINALITY_UNLIMITED
Definition: field.module:236
hook_field_attach_preprocess_alter
hook_field_attach_preprocess_alter(&$variables, $context)
Definition: field.api.php:1395
hook_field_formatter_info
hook_field_formatter_info()
Definition: field.api.php:1055
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
hook_field_storage_purge_field_instance
hook_field_storage_purge_field_instance($instance)
Definition: field.api.php:2629
_field_sql_storage_tablename
_field_sql_storage_tablename($field)
Definition: field_sql_storage.module:41
hook_field_display_ENTITY_TYPE_alter
hook_field_display_ENTITY_TYPE_alter(&$display, $context)
Definition: field.api.php:2351
hook_field_attach_delete_bundle
hook_field_attach_delete_bundle($entity_type, $bundle, $instances)
Definition: field.api.php:1595
hook_field_widget_properties_alter
hook_field_widget_properties_alter(&$widget, $context)
Definition: field.api.php:976
_field_sql_storage_columnname
_field_sql_storage_columnname($name, $column)
Definition: field_sql_storage.module:78
hook_field_attach_create_bundle
hook_field_attach_create_bundle($entity_type, $bundle)
Definition: field.api.php:1557
hook_field_widget_form
hook_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
Definition: field.api.php:883
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
hook_field_create_field
hook_field_create_field($field)
Definition: field.api.php:2430
hook_field_prepare_translation
hook_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode)
Definition: field.api.php:660
filter_formats
filter_formats($account=NULL)
Definition: filter.module:412
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
_field_sql_storage_revision_tablename
_field_sql_storage_revision_tablename($field)
Definition: field_sql_storage.module:58
hook_field_attach_submit
hook_field_attach_submit($entity_type, $entity, $form, &$form_state)
Definition: field.api.php:1338
hook_field_language_alter
hook_field_language_alter(&$display_language, $context)
Definition: field.api.php:1520
hook_field_delete
hook_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: field.api.php:596
hook_field_storage_delete_field
hook_field_storage_delete_field($field)
Definition: field.api.php:2096
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
$row
$row
Definition: block-admin-display-form.tpl.php:47
hook_field_storage_query
hook_field_storage_query($query)
Definition: field.api.php:1968
filter_access
filter_access($format, $account=NULL)
Definition: filter.module:1022
hook_field_attach_prepare_translation_alter
hook_field_attach_prepare_translation_alter(&$entity, $context)
Definition: field.api.php:1500
locale_field_language_fallback
locale_field_language_fallback(&$display_language, $entity, $langcode)
Definition: locale.module:496
hook_field_update_instance
hook_field_update_instance($instance, $prior_instance)
Definition: field.api.php:2526
hook_field_extra_fields
hook_field_extra_fields()
Definition: field.api.php:41
hook_field_delete_revision
hook_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: field.api.php:629
hook_field_create_instance
hook_field_create_instance($instance)
Definition: field.api.php:2443
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
hook_field_attach_rename_bundle
hook_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new)
Definition: field.api.php:1570
hook_field_display_alter
hook_field_display_alter(&$display, $context)
Definition: field.api.php:2316
hook_field_attach_view_alter
hook_field_attach_view_alter(&$output, $context)
Definition: field.api.php:1468
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
EntityFieldQueryException
Definition: entity.inc:390
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
entity_extract_ids
entity_extract_ids($entity_type, $entity)
Definition: common.inc:7711
hook_field_attach_presave
hook_field_attach_presave($entity_type, $entity)
Definition: field.api.php:1354
hook_field_storage_pre_insert
hook_field_storage_pre_insert($entity_type, $entity, &$skip_fields)
Definition: field.api.php:2193
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
_forum_update_forum_index
_forum_update_forum_index($nid)
Definition: forum.module:1339
hook_field_storage_purge
hook_field_storage_purge($entity_type, $entity, $field, $instance)
Definition: field.api.php:2650
hook_field_access
hook_field_access($op, $field, $entity_type, $entity, $account)
Definition: field.api.php:2689
FieldUpdateForbiddenException
Definition: field.module:279
taxonomy_term_load_multiple
taxonomy_term_load_multiple($tids=array(), $conditions=array())
Definition: taxonomy.module:1314
hook_field_prepare_view
hook_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items)
Definition: field.api.php:354
db_rename_table
db_rename_table($table, $new_name)
Definition: database.inc:2805
hook_field_insert
hook_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: field.api.php:466
FIELD_LOAD_CURRENT
const FIELD_LOAD_CURRENT
Definition: field.module:268
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/actions.inc Source File

  • includes
actions.inc
Go to the documentation of this file.
1 <?php
2
58 function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a2 = NULL) {
59 // $stack tracks the number of recursive calls.
60 static $stack;
61 $stack++;
62 if ($stack > variable_get('actions_max_stack', 35)) {
63 watchdog('actions', 'Stack overflow: too many calls to actions_do(). Aborting to prevent infinite recursion.', array(), WATCHDOG_ERROR);
64 return;
65 }
66 $actions = array();
67 $available_actions = actions_list();
68 $actions_result = array();
69 if (is_array($action_ids)) {
70 $conditions = array();
71 foreach ($action_ids as $action_id) {
72 if (is_numeric($action_id)) {
73 $conditions[] = $action_id;
74 }
75 elseif (isset($available_actions[$action_id])) {
76 $actions[$action_id] = $available_actions[$action_id];
77 }
78 }
79
80 // When we have action instances we must go to the database to retrieve
81 // instance data.
82 if (!empty($conditions)) {
83 $query = db_select('actions');
84 $query->addField('actions', 'aid');
85 $query->addField('actions', 'type');
86 $query->addField('actions', 'callback');
87 $query->addField('actions', 'parameters');
88 $query->condition('aid', $conditions, 'IN');
89 $result = $query->execute();
90 foreach ($result as $action) {
91 $actions[$action->aid] = $action->parameters ? unserialize($action->parameters) : array();
92 $actions[$action->aid]['callback'] = $action->callback;
93 $actions[$action->aid]['type'] = $action->type;
94 }
95 }
96
97 // Fire actions, in no particular order.
98 foreach ($actions as $action_id => $params) {
99 // Configurable actions need parameters.
100 if (is_numeric($action_id)) {
101 $function = $params['callback'];
102 if (function_exists($function)) {
103 $context = array_merge($context, $params);
104 $actions_result[$action_id] = $function($object, $context, $a1, $a2);
105 }
106 else {
107 $actions_result[$action_id] = FALSE;
108 }
109 }
110 // Singleton action; $action_id is the function name.
111 else {
112 $actions_result[$action_id] = $action_id($object, $context, $a1, $a2);
113 }
114 }
115 }
116 // Optimized execution of a single action.
117 else {
118 // If it's a configurable action, retrieve stored parameters.
119 if (is_numeric($action_ids)) {
120 $action = db_query("SELECT callback, parameters FROM {actions} WHERE aid = :aid", array(':aid' => $action_ids))->fetchObject();
121 $function = $action->callback;
122 if (function_exists($function)) {
123 $context = array_merge($context, unserialize($action->parameters));
124 $actions_result[$action_ids] = $function($object, $context, $a1, $a2);
125 }
126 else {
127 $actions_result[$action_ids] = FALSE;
128 }
129 }
130 // Singleton action; $action_ids is the function name.
131 else {
132 if (function_exists($action_ids)) {
133 $actions_result[$action_ids] = $action_ids($object, $context, $a1, $a2);
134 }
135 else {
136 // Set to avoid undefined index error messages later.
137 $actions_result[$action_ids] = FALSE;
138 }
139 }
140 }
141 $stack--;
142 return $actions_result;
143 }
144
162 function actions_list($reset = FALSE) {
163 $actions = &drupal_static(__FUNCTION__);
164 if (!isset($actions) || $reset) {
165 $actions = module_invoke_all('action_info');
166 drupal_alter('action_info', $actions);
167 }
168
169 // See module_implements() for an explanation of this cast.
170 return (array) $actions;
171 }
172
190 function actions_get_all_actions() {
191 $actions = db_query("SELECT aid, type, callback, parameters, label FROM {actions}")->fetchAllAssoc('aid', PDO::FETCH_ASSOC);
192 foreach ($actions as &$action) {
193 $action['configurable'] = (bool) $action['parameters'];
194 unset($action['parameters']);
195 unset($action['aid']);
196 }
197 return $actions;
198 }
199
216 function actions_actions_map($actions) {
217 $actions_map = array();
218 foreach ($actions as $callback => $array) {
219 $key = drupal_hash_base64($callback);
220 $actions_map[$key]['callback'] = isset($array['callback']) ? $array['callback'] : $callback;
221 $actions_map[$key]['label'] = $array['label'];
222 $actions_map[$key]['type'] = $array['type'];
223 $actions_map[$key]['configurable'] = $array['configurable'];
224 }
225 return $actions_map;
226 }
227
241 function actions_function_lookup($hash) {
242 // Check for a function name match.
243 $actions_list = actions_list();
244 foreach ($actions_list as $function => $array) {
245 if (drupal_hash_base64($function) == $hash) {
246 return $function;
247 }
248 }
249 $aid = FALSE;
250 // Must be a configurable action; check database.
251 $result = db_query("SELECT aid FROM {actions} WHERE parameters <> ''")->fetchAll(PDO::FETCH_ASSOC);
252 foreach ($result as $row) {
253 if (drupal_hash_base64($row['aid']) == $hash) {
254 $aid = $row['aid'];
255 break;
256 }
257 }
258 return $aid;
259 }
260
274 function actions_synchronize($delete_orphans = FALSE) {
275 $actions_in_code = actions_list(TRUE);
276 $actions_in_db = db_query("SELECT aid, callback, label FROM {actions} WHERE parameters = ''")->fetchAllAssoc('callback', PDO::FETCH_ASSOC);
277
278 // Go through all the actions provided by modules.
279 foreach ($actions_in_code as $callback => $array) {
280 // Ignore configurable actions since their instances get put in when the
281 // user adds the action.
282 if (!$array['configurable']) {
283 // If we already have an action ID for this action, no need to assign aid.
284 if (isset($actions_in_db[$callback])) {
285 unset($actions_in_db[$callback]);
286 }
287 else {
288 // This is a new singleton that we don't have an aid for; assign one.
289 db_insert('actions')
290 ->fields(array(
291 'aid' => $callback,
292 'type' => $array['type'],
293 'callback' => $callback,
294 'parameters' => '',
295 'label' => $array['label'],
296 ))
297 ->execute();
298 watchdog('actions', "Action '%action' added.", array('%action' => $array['label']));
299 }
300 }
301 }
302
303 // Any actions that we have left in $actions_in_db are orphaned.
304 if ($actions_in_db) {
305 $orphaned = array_keys($actions_in_db);
306
307 if ($delete_orphans) {
308 $actions = db_query('SELECT aid, label FROM {actions} WHERE callback IN (:orphaned)', array(':orphaned' => $orphaned))->fetchAll();
309 foreach ($actions as $action) {
310 actions_delete($action->aid);
311 watchdog('actions', "Removed orphaned action '%action' from database.", array('%action' => $action->label));
312 }
313 }
314 else {
315 $link = l(t('Remove orphaned actions'), 'admin/config/system/actions/orphan');
316 $count = count($actions_in_db);
317 $orphans = implode(', ', $orphaned);
318 watchdog('actions', '@count orphaned actions (%orphans) exist in the actions table. !link', array('@count' => $count, '%orphans' => $orphans, '!link' => $link), WATCHDOG_INFO);
319 }
320 }
321 }
322
343 function actions_save($function, $type, $params, $label, $aid = NULL) {
344 // aid is the callback for singleton actions so we need to keep a separate
345 // table for numeric aids.
346 if (!$aid) {
347 $aid = db_next_id();
348 }
349
350 db_merge('actions')
351 ->key(array('aid' => $aid))
352 ->fields(array(
353 'callback' => $function,
354 'type' => $type,
355 'parameters' => serialize($params),
356 'label' => $label,
357 ))
358 ->execute();
359
360 watchdog('actions', 'Action %action saved.', array('%action' => $label));
361 return $aid;
362 }
363
373 function actions_load($aid) {
374 return db_query("SELECT aid, type, callback, parameters, label FROM {actions} WHERE aid = :aid", array(':aid' => $aid))->fetchObject();
375 }
376
383 function actions_delete($aid) {
384 db_delete('actions')
385 ->condition('aid', $aid)
386 ->execute();
387 module_invoke_all('actions_delete', $aid);
388 }
db_next_id
db_next_id($existing_id=0)
Definition: database.inc:2653
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
l
l($text, $path, array $options=array())
Definition: common.inc:2432
actions_function_lookup
actions_function_lookup($hash)
Definition: actions.inc:241
WATCHDOG_INFO
const WATCHDOG_INFO
Definition: bootstrap.inc:108
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
actions_actions_map
actions_actions_map($actions)
Definition: actions.inc:216
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
actions_do
actions_do($action_ids, $object=NULL, $context=NULL, $a1=NULL, $a2=NULL)
Definition: actions.inc:58
actions_save
actions_save($function, $type, $params, $label, $aid=NULL)
Definition: actions.inc:343
actions_get_all_actions
actions_get_all_actions()
Definition: actions.inc:190
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
actions_load
actions_load($aid)
Definition: actions.inc:373
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
actions_list
actions_list($reset=FALSE)
Definition: actions.inc:162
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
$row
$row
Definition: block-admin-display-form.tpl.php:47
drupal_hash_base64
drupal_hash_base64($data)
Definition: bootstrap.inc:2067
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
actions_synchronize
actions_synchronize($delete_orphans=FALSE)
Definition: actions.inc:274
actions_delete
actions_delete($aid)
Definition: actions.inc:383
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment.api.php Source File

  • modules
  • comment
comment.api.php
Go to the documentation of this file.
1 <?php
2
21 function hook_comment_presave($comment) {
22 // Remove leading & trailing spaces from the comment subject.
23 $comment->subject = trim($comment->subject);
24 }
25
32 function hook_comment_insert($comment) {
33 // Reindex the node when comments are added.
34 search_touch_node($comment->nid);
35 }
36
43 function hook_comment_update($comment) {
44 // Reindex the node when comments are updated.
45 search_touch_node($comment->nid);
46 }
47
54 function hook_comment_load($comments) {
55 $result = db_query('SELECT cid, foo FROM {mytable} WHERE cid IN (:cids)', array(':cids' => array_keys($comments)));
56 foreach ($result as $record) {
57 $comments[$record->cid]->foo = $record->foo;
58 }
59 }
60
73 function hook_comment_view($comment, $view_mode, $langcode) {
74 // how old is the comment
75 $comment->time_ago = time() - $comment->changed;
76 }
77
96 function hook_comment_view_alter(&$build) {
97 // Check for the existence of a field added by another module.
98 if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
99 // Change its weight.
100 $build['an_additional_field']['#weight'] = -10;
101 }
102
103 // Add a #post_render callback to act on the rendered HTML of the comment.
104 $build['#post_render'][] = 'my_module_comment_post_render';
105 }
106
115 function hook_comment_publish($comment) {
116 drupal_set_message(t('Comment: @subject has been published', array('@subject' => $comment->subject)));
117 }
118
127 function hook_comment_unpublish($comment) {
128 drupal_set_message(t('Comment: @subject has been unpublished', array('@subject' => $comment->subject)));
129 }
130
139 function hook_comment_delete($comment) {
140 drupal_set_message(t('Comment: @subject has been deleted', array('@subject' => $comment->subject)));
141 }
142
hook_comment_publish
hook_comment_publish($comment)
Definition: comment.api.php:115
hook_comment_insert
hook_comment_insert($comment)
Definition: comment.api.php:32
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
hook_comment_delete
hook_comment_delete($comment)
Definition: comment.api.php:139
hook_comment_unpublish
hook_comment_unpublish($comment)
Definition: comment.api.php:127
hook_comment_view_alter
hook_comment_view_alter(&$build)
Definition: comment.api.php:96
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
hook_comment_view
hook_comment_view($comment, $view_mode, $langcode)
Definition: comment.api.php:73
hook_comment_presave
hook_comment_presave($comment)
Definition: comment.api.php:21
search_touch_node
search_touch_node($nid)
Definition: search.module:781
hook_comment_load
hook_comment_load($comments)
Definition: comment.api.php:54
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
hook_comment_update
hook_comment_update($comment)
Definition: comment.api.php:43
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.default.inc Source File

  • modules
  • field
field.default.inc
Go to the documentation of this file.
1 <?php
2
35 function field_default_extract_form_values($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state) {
36 $path = array_merge($form['#parents'], array($field['field_name'], $langcode));
37 $key_exists = NULL;
38 $values = drupal_array_get_nested_value($form_state['values'], $path, $key_exists);
39 if ($key_exists) {
40 // Remove the 'value' of the 'add more' button.
41 unset($values['add_more']);
42 $items = $values;
43 }
44 }
45
74 function field_default_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
75 // Filter out empty values.
76 $items = _field_filter_items($field, $items);
77
78 // Check that the number of values doesn't exceed the field cardinality.
79 // For form submitted values, this can only happen with 'multiple value'
80 // widgets.
81 if ($field['cardinality'] != FIELD_CARDINALITY_UNLIMITED && count($items) > $field['cardinality']) {
82 $errors[$field['field_name']][$langcode][0][] = array(
83 'error' => 'field_cardinality',
84 'message' => t('%name: this field cannot hold more than @count values.', array('%name' => $instance['label'], '@count' => $field['cardinality'])),
85 );
86 }
87 }
88
89 function field_default_submit($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state) {
90 // Filter out empty values.
91 $items = _field_filter_items($field, $items);
92 // Reorder items to account for drag-n-drop reordering.
93 $items = _field_sort_items($field, $items);
94 }
95
103 function field_default_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
104 // _field_invoke() populates $items with an empty array if the $entity has no
105 // entry for the field, so we check on the $entity itself.
106 // We also check that the current field translation is actually defined before
107 // assigning it a default value. This way we ensure that only the intended
108 // languages get a default value. Otherwise we could have default values for
109 // not yet open languages.
110 if (empty($entity) || !property_exists($entity, $field['field_name']) ||
111 (isset($entity->{$field['field_name']}[$langcode]) && count($entity->{$field['field_name']}[$langcode]) == 0)) {
112 $items = field_get_default_value($entity_type, $entity, $field, $instance, $langcode);
113 }
114 }
115
138 function field_default_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $display) {
139 // Group entities, instances and items by formatter module.
140 $modules = array();
141 foreach ($instances as $id => $instance) {
142 if (is_string($display)) {
143 $view_mode = $display;
144 $instance_display = field_get_display($instance, $view_mode, $entities[$id]);
145 }
146 else {
147 $instance_display = $display;
148 }
149
150 if ($instance_display['type'] !== 'hidden') {
151 $module = $instance_display['module'];
152 $modules[$module] = $module;
153 $grouped_entities[$module][$id] = $entities[$id];
154 $grouped_instances[$module][$id] = $instance;
155 $grouped_displays[$module][$id] = $instance_display;
156 // hook_field_formatter_prepare_view() alters $items by reference.
157 $grouped_items[$module][$id] = &$items[$id];
158 }
159 }
160
161 foreach ($modules as $module) {
162 // Invoke hook_field_formatter_prepare_view().
163 $function = $module . '_field_formatter_prepare_view';
164 if (function_exists($function)) {
165 $function($entity_type, $grouped_entities[$module], $field, $grouped_instances[$module], $langcode, $grouped_items[$module], $grouped_displays[$module]);
166 }
167 }
168 }
169
191 function field_default_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
192 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
193
194 $addition = array();
195
196 // Prepare incoming display specifications.
197 if (is_string($display)) {
198 $view_mode = $display;
199 $display = field_get_display($instance, $view_mode, $entity);
200 }
201 else {
202 $view_mode = '_custom_display';
203 }
204
205 if ($display['type'] !== 'hidden') {
206 // Calling the formatter function through module_invoke() can have a
207 // performance impact on pages with many fields and values.
208 $function = $display['module'] . '_field_formatter_view';
209 if (function_exists($function)) {
210 $elements = $function($entity_type, $entity, $field, $instance, $langcode, $items, $display);
211
212 if ($elements) {
213 $info = array(
214 '#theme' => 'field',
215 '#weight' => $display['weight'],
216 '#title' => $instance['label'],
217 '#access' => field_access('view', $field, $entity_type, $entity),
218 '#label_display' => $display['label'],
219 '#view_mode' => $view_mode,
220 '#language' => $langcode,
221 '#field_name' => $field['field_name'],
222 '#field_type' => $field['type'],
223 '#field_translatable' => $field['translatable'],
224 '#entity_type' => $entity_type,
225 '#bundle' => $bundle,
226 '#object' => $entity,
227 '#items' => $items,
228 '#formatter' => $display['type']
229 );
230
231 $addition[$field['field_name']] = array_merge($info, $elements);
232 }
233 }
234 }
235
236 return $addition;
237 }
238
259 function field_default_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
260 $field_name = $field['field_name'];
261 // If the field is untranslatable keep using LANGUAGE_NONE.
262 if ($langcode == LANGUAGE_NONE) {
263 $source_langcode = LANGUAGE_NONE;
264 }
265 if (isset($source_entity->{$field_name}[$source_langcode])) {
266 $items = $source_entity->{$field_name}[$source_langcode];
267 }
268 }
drupal_array_get_nested_value
& drupal_array_get_nested_value(array &$array, array $parents, &$key_exists=NULL)
Definition: common.inc:6666
field_default_prepare_translation
field_default_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode)
Definition: field.default.inc:259
field_default_extract_form_values
field_default_extract_form_values($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state)
Definition: field.default.inc:35
$module
print $module
Definition: search-results.tpl.php:28
field_access
field_access($op, $field, $entity_type, $entity=NULL, $account=NULL)
Definition: field.module:982
field_default_view
field_default_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
Definition: field.default.inc:191
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$info
$info
Definition: color.inc:6
field_get_display
field_get_display($instance, $view_mode, $entity)
Definition: field.module:651
field_default_submit
field_default_submit($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state)
Definition: field.default.inc:89
field_get_default_value
field_get_default_value($entity_type, $entity, $field, $instance, $langcode=NULL)
Definition: field.module:479
FIELD_CARDINALITY_UNLIMITED
const FIELD_CARDINALITY_UNLIMITED
Definition: field.module:236
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
field_default_validate
field_default_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
Definition: field.default.inc:74
_field_sort_items
_field_sort_items($field, $items)
Definition: field.module:520
_field_filter_items
_field_filter_items($field, $items)
Definition: field.module:505
field_default_prepare_view
field_default_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $display)
Definition: field.default.inc:138
entity_extract_ids
entity_extract_ids($entity_type, $entity)
Definition: common.inc:7711
field_default_insert
field_default_insert($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: field.default.inc:103
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/text/text.module Source File

  • modules
  • field
  • modules
  • text
text.module
Go to the documentation of this file.
1 <?php
2
11 function text_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#text':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t("The Text module defines various text field types for the Field module. A text field may contain plain text only, or optionally, may use Drupal's <a href='@filter-help'>text filters</a> to securely manage HTML output. Text input fields may be either a single line (text field), multiple lines (text area), or for greater input control, a select box, checkbox, or radio buttons. If desired, the field can be validated, so that it is limited to a set of allowed values. See the <a href='@field-help'>Field module help page</a> for more information about fields.", array('@field-help' => url('admin/help/field'), '@filter-help' => url('admin/help/filter'))) . '</p>';
17 return $output;
18 }
19 }
20
32 function text_field_info() {
33 return array(
34 'text' => array(
35 'label' => t('Text'),
36 'description' => t('This field stores varchar text in the database.'),
37 'settings' => array('max_length' => 255),
38 'instance_settings' => array('text_processing' => 0),
39 'default_widget' => 'text_textfield',
40 'default_formatter' => 'text_default',
41 ),
42 'text_long' => array(
43 'label' => t('Long text'),
44 'description' => t('This field stores long text in the database.'),
45 'instance_settings' => array('text_processing' => 0),
46 'default_widget' => 'text_textarea',
47 'default_formatter' => 'text_default',
48 ),
49 'text_with_summary' => array(
50 'label' => t('Long text and summary'),
51 'description' => t('This field stores long text in the database along with optional summary text.'),
52 'instance_settings' => array('text_processing' => 1, 'display_summary' => 0),
53 'default_widget' => 'text_textarea_with_summary',
54 'default_formatter' => 'text_default',
55 ),
56 );
57 }
58
62 function text_field_settings_form($field, $instance, $has_data) {
63 $settings = $field['settings'];
64
65 $form = array();
66
67 if ($field['type'] == 'text') {
68 $form['max_length'] = array(
69 '#type' => 'textfield',
70 '#title' => t('Maximum length'),
71 '#default_value' => $settings['max_length'],
72 '#required' => TRUE,
73 '#description' => t('The maximum length of the field in characters.'),
74 '#element_validate' => array('element_validate_integer_positive'),
75 // @todo: If $has_data, add a validate handler that only allows
76 // max_length to increase.
77 '#disabled' => $has_data,
78 );
79 }
80
81 return $form;
82 }
83
87 function text_field_instance_settings_form($field, $instance) {
88 $settings = $instance['settings'];
89
90 $form['text_processing'] = array(
91 '#type' => 'radios',
92 '#title' => t('Text processing'),
93 '#default_value' => $settings['text_processing'],
94 '#options' => array(
95 t('Plain text'),
96 t('Filtered text (user selects text format)'),
97 ),
98 );
99 if ($field['type'] == 'text_with_summary') {
100 $form['display_summary'] = array(
101 '#type' => 'checkbox',
102 '#title' => t('Summary input'),
103 '#default_value' => $settings['display_summary'],
104 '#description' => t('This allows authors to input an explicit summary, to be displayed instead of the automatically trimmed text when using the "Summary or trimmed" display type.'),
105 );
106 }
107
108 return $form;
109 }
110
118 function text_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
119 foreach ($items as $delta => $item) {
120 // @todo Length is counted separately for summary and value, so the maximum
121 // length can be exceeded very easily.
122 foreach (array('value', 'summary') as $column) {
123 if (!empty($item[$column])) {
124 if (!empty($field['settings']['max_length']) && drupal_strlen($item[$column]) > $field['settings']['max_length']) {
125 switch ($column) {
126 case 'value':
127 $message = t('%name: the text may not be longer than %max characters.', array('%name' => $instance['label'], '%max' => $field['settings']['max_length']));
128 break;
129
130 case 'summary':
131 $message = t('%name: the summary may not be longer than %max characters.', array('%name' => $instance['label'], '%max' => $field['settings']['max_length']));
132 break;
133 }
134 $errors[$field['field_name']][$langcode][$delta][] = array(
135 'error' => "text_{$column}_length",
136 'message' => $message,
137 );
138 }
139 }
140 }
141 }
142 }
143
153 function text_field_load($entity_type, $entities, $field, $instances, $langcode, &$items) {
154 foreach ($entities as $id => $entity) {
155 foreach ($items[$id] as $delta => $item) {
156 // Only process items with a cacheable format, the rest will be handled
157 // by formatters if needed.
158 if (empty($instances[$id]['settings']['text_processing']) || filter_format_allowcache($item['format'])) {
159 $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $langcode, $item, 'value') : '';
160 if ($field['type'] == 'text_with_summary') {
161 $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : '';
162 }
163 }
164 }
165 }
166 }
167
171 function text_field_is_empty($item, $field) {
172 if (!isset($item['value']) || $item['value'] === '') {
173 return !isset($item['summary']) || $item['summary'] === '';
174 }
175 return FALSE;
176 }
177
181 function text_field_formatter_info() {
182 return array(
183 'text_default' => array(
184 'label' => t('Default'),
185 'field types' => array('text', 'text_long', 'text_with_summary'),
186 ),
187 'text_plain' => array(
188 'label' => t('Plain text'),
189 'field types' => array('text', 'text_long', 'text_with_summary'),
190 ),
191
192 // The text_trimmed formatter displays the trimmed version of the
193 // full element of the field. It is intended to be used with text
194 // and text_long fields. It also works with text_with_summary
195 // fields though the text_summary_or_trimmed formatter makes more
196 // sense for that field type.
197 'text_trimmed' => array(
198 'label' => t('Trimmed'),
199 'field types' => array('text', 'text_long', 'text_with_summary'),
200 'settings' => array('trim_length' => 600),
201 ),
202
203 // The 'summary or trimmed' field formatter for text_with_summary
204 // fields displays returns the summary element of the field or, if
205 // the summary is empty, the trimmed version of the full element
206 // of the field.
207 'text_summary_or_trimmed' => array(
208 'label' => t('Summary or trimmed'),
209 'field types' => array('text_with_summary'),
210 'settings' => array('trim_length' => 600),
211 ),
212 );
213 }
214
218 function text_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
219 $display = $instance['display'][$view_mode];
220 $settings = $display['settings'];
221
222 $element = array();
223
224 if (strpos($display['type'], '_trimmed') !== FALSE) {
225 $element['trim_length'] = array(
226 '#title' => t('Trim length'),
227 '#type' => 'textfield',
228 '#size' => 10,
229 '#default_value' => $settings['trim_length'],
230 '#element_validate' => array('element_validate_integer_positive'),
231 '#required' => TRUE,
232 );
233 }
234
235 return $element;
236 }
237
241 function text_field_formatter_settings_summary($field, $instance, $view_mode) {
242 $display = $instance['display'][$view_mode];
243 $settings = $display['settings'];
244
245 $summary = '';
246
247 if (strpos($display['type'], '_trimmed') !== FALSE) {
248 $summary = t('Trim length') . ': ' . $settings['trim_length'];
249 }
250
251 return $summary;
252 }
253
257 function text_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
258 $element = array();
259
260 switch ($display['type']) {
261 case 'text_default':
262 case 'text_trimmed':
263 foreach ($items as $delta => $item) {
264 $output = _text_sanitize($instance, $langcode, $item, 'value');
265 if ($display['type'] == 'text_trimmed') {
266 $output = text_summary($output, $instance['settings']['text_processing'] ? $item['format'] : NULL, $display['settings']['trim_length']);
267 }
268 $element[$delta] = array('#markup' => $output);
269 }
270 break;
271
272 case 'text_summary_or_trimmed':
273 foreach ($items as $delta => $item) {
274 if (!empty($item['summary'])) {
275 $output = _text_sanitize($instance, $langcode, $item, 'summary');
276 }
277 else {
278 $output = _text_sanitize($instance, $langcode, $item, 'value');
279 $output = text_summary($output, $instance['settings']['text_processing'] ? $item['format'] : NULL, $display['settings']['trim_length']);
280 }
281 $element[$delta] = array('#markup' => $output);
282 }
283 break;
284
285 case 'text_plain':
286 foreach ($items as $delta => $item) {
287 $element[$delta] = array('#markup' => strip_tags($item['value']));
288 }
289 break;
290 }
291
292 return $element;
293 }
294
313 function _text_sanitize($instance, $langcode, $item, $column) {
314 // If the value uses a cacheable text format, text_field_load() precomputes
315 // the sanitized string.
316 if (isset($item["safe_$column"])) {
317 return $item["safe_$column"];
318 }
319 return $instance['settings']['text_processing'] ? check_markup($item[$column], $item['format'], $langcode) : check_plain($item[$column]);
320 }
321
347 function text_summary($text, $format = NULL, $size = NULL) {
348
349 if (!isset($size)) {
350 // What used to be called 'teaser' is now called 'summary', but
351 // the variable 'teaser_length' is preserved for backwards compatibility.
352 $size = variable_get('teaser_length', 600);
353 }
354
355 // Find where the delimiter is in the body
356 $delimiter = strpos($text, '<!--break-->');
357
358 // If the size is zero, and there is no delimiter, the entire body is the summary.
359 if ($size == 0 && $delimiter === FALSE) {
360 return $text;
361 }
362
363 // If a valid delimiter has been specified, use it to chop off the summary.
364 if ($delimiter !== FALSE) {
365 return substr($text, 0, $delimiter);
366 }
367
368 // We check for the presence of the PHP evaluator filter in the current
369 // format. If the body contains PHP code, we do not split it up to prevent
370 // parse errors.
371 if (isset($format)) {
372 $filters = filter_list_format($format);
373 if (isset($filters['php_code']) && $filters['php_code']->status && strpos($text, '<?') !== FALSE) {
374 return $text;
375 }
376 }
377
378 // If we have a short body, the entire body is the summary.
379 if (drupal_strlen($text) <= $size) {
380 return $text;
381 }
382
383 // If the delimiter has not been specified, try to split at paragraph or
384 // sentence boundaries.
385
386 // The summary may not be longer than maximum length specified. Initial slice.
387 $summary = truncate_utf8($text, $size);
388
389 // Store the actual length of the UTF8 string -- which might not be the same
390 // as $size.
391 $max_rpos = strlen($summary);
392
393 // How much to cut off the end of the summary so that it doesn't end in the
394 // middle of a paragraph, sentence, or word.
395 // Initialize it to maximum in order to find the minimum.
396 $min_rpos = $max_rpos;
397
398 // Store the reverse of the summary. We use strpos on the reversed needle and
399 // haystack for speed and convenience.
400 $reversed = strrev($summary);
401
402 // Build an array of arrays of break points grouped by preference.
403 $break_points = array();
404
405 // A paragraph near the end of sliced summary is most preferable.
406 $break_points[] = array('</p>' => 0);
407
408 // If no complete paragraph then treat line breaks as paragraphs.
409 $line_breaks = array('<br />' => 6, '<br>' => 4);
410 // Newline only indicates a line break if line break converter
411 // filter is present.
412 if (isset($filters['filter_autop'])) {
413 $line_breaks["\n"] = 1;
414 }
415 $break_points[] = $line_breaks;
416
417 // If the first paragraph is too long, split at the end of a sentence.
418 $break_points[] = array('. ' => 1, '! ' => 1, '? ' => 1, '。' => 0, '؟ ' => 1);
419
420 // Iterate over the groups of break points until a break point is found.
421 foreach ($break_points as $points) {
422 // Look for each break point, starting at the end of the summary.
423 foreach ($points as $point => $offset) {
424 // The summary is already reversed, but the break point isn't.
425 $rpos = strpos($reversed, strrev($point));
426 if ($rpos !== FALSE) {
427 $min_rpos = min($rpos + $offset, $min_rpos);
428 }
429 }
430
431 // If a break point was found in this group, slice and stop searching.
432 if ($min_rpos !== $max_rpos) {
433 // Don't slice with length 0. Length must be <0 to slice from RHS.
434 $summary = ($min_rpos === 0) ? $summary : substr($summary, 0, 0 - $min_rpos);
435 break;
436 }
437 }
438
439 // If the htmlcorrector filter is present, apply it to the generated summary.
440 if (isset($filters['filter_htmlcorrector'])) {
441 $summary = _filter_htmlcorrector($summary);
442 }
443
444 return $summary;
445 }
446
450 function text_field_widget_info() {
451 return array(
452 'text_textfield' => array(
453 'label' => t('Text field'),
454 'field types' => array('text'),
455 'settings' => array('size' => 60),
456 ),
457 'text_textarea' => array(
458 'label' => t('Text area (multiple rows)'),
459 'field types' => array('text_long'),
460 'settings' => array('rows' => 5),
461 ),
462 'text_textarea_with_summary' => array(
463 'label' => t('Text area with a summary'),
464 'field types' => array('text_with_summary'),
465 'settings' => array('rows' => 20, 'summary_rows' => 5),
466 ),
467 );
468 }
469
473 function text_field_widget_settings_form($field, $instance) {
474 $widget = $instance['widget'];
475 $settings = $widget['settings'];
476
477 if ($widget['type'] == 'text_textfield') {
478 $form['size'] = array(
479 '#type' => 'textfield',
480 '#title' => t('Size of textfield'),
481 '#default_value' => $settings['size'],
482 '#required' => TRUE,
483 '#element_validate' => array('element_validate_integer_positive'),
484 );
485 }
486 else {
487 $form['rows'] = array(
488 '#type' => 'textfield',
489 '#title' => t('Rows'),
490 '#default_value' => $settings['rows'],
491 '#required' => TRUE,
492 '#element_validate' => array('element_validate_integer_positive'),
493 );
494 }
495
496 return $form;
497 }
498
502 function text_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
503 $summary_widget = array();
504 $main_widget = array();
505
506 switch ($instance['widget']['type']) {
507 case 'text_textfield':
508 $main_widget = $element + array(
509 '#type' => 'textfield',
510 '#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : NULL,
511 '#size' => $instance['widget']['settings']['size'],
512 '#maxlength' => $field['settings']['max_length'],
513 '#attributes' => array('class' => array('text-full')),
514 );
515 break;
516
517 case 'text_textarea_with_summary':
518 $display = !empty($items[$delta]['summary']) || !empty($instance['settings']['display_summary']);
519 $summary_widget = array(
520 '#type' => $display ? 'textarea' : 'value',
521 '#default_value' => isset($items[$delta]['summary']) ? $items[$delta]['summary'] : NULL,
522 '#title' => t('Summary'),
523 '#rows' => $instance['widget']['settings']['summary_rows'],
524 '#description' => t('Leave blank to use trimmed value of full text as the summary.'),
525 '#attached' => array(
526 'js' => array(drupal_get_path('module', 'text') . '/text.js'),
527 ),
528 '#attributes' => array('class' => array('text-summary')),
529 '#prefix' => '<div class="text-summary-wrapper">',
530 '#suffix' => '</div>',
531 '#weight' => -10,
532 );
533 // Fall through to the next case.
534
535 case 'text_textarea':
536 $main_widget = $element + array(
537 '#type' => 'textarea',
538 '#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : NULL,
539 '#rows' => $instance['widget']['settings']['rows'],
540 '#attributes' => array('class' => array('text-full')),
541 );
542 break;
543 }
544
545 if ($main_widget) {
546 // Conditionally alter the form element's type if text processing is enabled.
547 if ($instance['settings']['text_processing']) {
548 $element = $main_widget;
549 $element['#type'] = 'text_format';
550 $element['#format'] = isset($items[$delta]['format']) ? $items[$delta]['format'] : NULL;
551 $element['#base_type'] = $main_widget['#type'];
552 }
553 else {
554 $element['value'] = $main_widget;
555 }
556 }
557 if ($summary_widget) {
558 $element['summary'] = $summary_widget;
559 }
560
561 return $element;
562 }
563
567 function text_field_widget_error($element, $error, $form, &$form_state) {
568 switch ($error['error']) {
569 case 'text_summary_max_length':
570 $error_element = $element[$element['#columns'][1]];
571 break;
572
573 default:
574 $error_element = $element[$element['#columns'][0]];
575 break;
576 }
577
578 form_error($error_element, $error['message']);
579 }
580
584 function text_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
585 // If the translating user is not permitted to use the assigned text format,
586 // we must not expose the source values.
587 $field_name = $field['field_name'];
588 if (!empty($source_entity->{$field_name}[$source_langcode])) {
589 $formats = filter_formats();
590 foreach ($source_entity->{$field_name}[$source_langcode] as $delta => $item) {
591 $format_id = $item['format'];
592 if (!empty($format_id) && !filter_access($formats[$format_id])) {
593 unset($items[$delta]);
594 }
595 }
596 }
597 }
598
602 function text_filter_format_update($format) {
603 field_cache_clear();
604 }
605
609 function text_filter_format_disable($format) {
610 field_cache_clear();
611 }
text_field_info
text_field_info()
Definition: text.module:32
text_field_instance_settings_form
text_field_instance_settings_form($field, $instance)
Definition: text.module:87
text_field_formatter_settings_summary
text_field_formatter_settings_summary($field, $instance, $view_mode)
Definition: text.module:241
text_filter_format_disable
text_filter_format_disable($format)
Definition: text.module:609
text_field_formatter_info
text_field_formatter_info()
Definition: text.module:181
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
drupal_strlen
drupal_strlen($text)
Definition: unicode.inc:474
text_field_widget_form
text_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
Definition: text.module:502
filter_format_allowcache
filter_format_allowcache($format_id)
Definition: filter.module:642
text_help
text_help($path, $arg)
Definition: text.module:11
text_field_settings_form
text_field_settings_form($field, $instance, $has_data)
Definition: text.module:62
text_field_formatter_view
text_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
Definition: text.module:257
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
text_field_load
text_field_load($entity_type, $entities, $field, $instances, $langcode, &$items)
Definition: text.module:153
text_field_widget_error
text_field_widget_error($element, $error, $form, &$form_state)
Definition: text.module:567
field_cache_clear
field_cache_clear()
Definition: field.module:740
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
filter_list_format
filter_list_format($format_id)
Definition: filter.module:691
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
_text_sanitize
_text_sanitize($instance, $langcode, $item, $column)
Definition: text.module:313
text_field_prepare_translation
text_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode)
Definition: text.module:584
text_filter_format_update
text_filter_format_update($format)
Definition: text.module:602
text_field_formatter_settings_form
text_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state)
Definition: text.module:218
text_summary
text_summary($text, $format=NULL, $size=NULL)
Definition: text.module:347
$output
$output
Definition: authorize.php:93
text_field_validate
text_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
Definition: text.module:118
text_field_widget_info
text_field_widget_info()
Definition: text.module:450
filter_formats
filter_formats($account=NULL)
Definition: filter.module:412
text_field_is_empty
text_field_is_empty($item, $field)
Definition: text.module:171
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
filter_access
filter_access($format, $account=NULL)
Definition: filter.module:1022
text_field_widget_settings_form
text_field_widget_settings_form($field, $instance)
Definition: text.module:473
_filter_htmlcorrector
_filter_htmlcorrector($text)
Definition: filter.module:1675
check_markup
check_markup($text, $format_id=NULL, $langcode= '', $cache=FALSE)
Definition: filter.module:759
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
truncate_utf8
truncate_utf8($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
Definition: unicode.inc:316
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.crud.inc Source File

  • modules
  • field
field.crud.inc
Go to the documentation of this file.
1 <?php
2
56 function field_create_field($field) {
57 // Field name is required.
58 if (empty($field['field_name'])) {
59 throw new FieldException('Attempt to create an unnamed field.');
60 }
61 // Field type is required.
62 if (empty($field['type'])) {
63 throw new FieldException('Attempt to create a field with no type.');
64 }
65 // Field name cannot contain invalid characters.
66 if (!preg_match('/^[_a-z]+[_a-z0-9]*$/', $field['field_name'])) {
67 throw new FieldException('Attempt to create a field with invalid characters. Only lowercase alphanumeric characters and underscores are allowed, and only lowercase letters and underscore are allowed as the first character');
68 }
69
70 // Field name cannot be longer than 32 characters. We use drupal_strlen()
71 // because the DB layer assumes that column widths are given in characters,
72 // not bytes.
73 if (drupal_strlen($field['field_name']) > 32) {
74 throw new FieldException(t('Attempt to create a field with a name longer than 32 characters: %name',
75 array('%name' => $field['field_name'])));
76 }
77
78 // Ensure the field name is unique over active and disabled fields.
79 // We do not care about deleted fields.
80 $prior_field = field_read_field($field['field_name'], array('include_inactive' => TRUE));
81 if (!empty($prior_field)) {
82 $message = $prior_field['active']?
83 t('Attempt to create field name %name which already exists and is active.', array('%name' => $field['field_name'])):
84 t('Attempt to create field name %name which already exists, although it is inactive.', array('%name' => $field['field_name']));
85 throw new FieldException($message);
86 }
87
88 // Disallow reserved field names. This can't prevent all field name
89 // collisions with existing entity properties, but some is better
90 // than none.
91 foreach (entity_get_info() as $type => $info) {
92 if (in_array($field['field_name'], $info['entity keys'])) {
93 throw new FieldException(t('Attempt to create field name %name which is reserved by entity type %type.', array('%name' => $field['field_name'], '%type' => $type)));
94 }
95 }
96
97 $field += array(
98 'entity_types' => array(),
99 'cardinality' => 1,
100 'translatable' => FALSE,
101 'locked' => FALSE,
102 'settings' => array(),
103 'storage' => array(),
104 'deleted' => 0,
105 );
106
107 // Check that the field type is known.
108 $field_type = field_info_field_types($field['type']);
109 if (!$field_type) {
110 throw new FieldException(t('Attempt to create a field of unknown type %type.', array('%type' => $field['type'])));
111 }
112 // Create all per-field-type properties (needed here as long as we have
113 // settings that impact column definitions).
114 $field['settings'] += field_info_field_settings($field['type']);
115 $field['module'] = $field_type['module'];
116 $field['active'] = 1;
117
118 // Provide default storage.
119 $field['storage'] += array(
120 'type' => variable_get('field_storage_default', 'field_sql_storage'),
121 'settings' => array(),
122 );
123 // Check that the storage type is known.
124 $storage_type = field_info_storage_types($field['storage']['type']);
125 if (!$storage_type) {
126 throw new FieldException(t('Attempt to create a field with unknown storage type %type.', array('%type' => $field['storage']['type'])));
127 }
128 // Provide default storage settings.
129 $field['storage']['settings'] += field_info_storage_settings($field['storage']['type']);
130 $field['storage']['module'] = $storage_type['module'];
131 $field['storage']['active'] = 1;
132 // Collect storage information.
133 module_load_install($field['module']);
134 $schema = (array) module_invoke($field['module'], 'field_schema', $field);
135 $schema += array('columns' => array(), 'indexes' => array(), 'foreign keys' => array());
136 // 'columns' are hardcoded in the field type.
137 $field['columns'] = $schema['columns'];
138 // 'foreign keys' are hardcoded in the field type.
139 $field['foreign keys'] = $schema['foreign keys'];
140 // 'indexes' can be both hardcoded in the field type, and specified in the
141 // incoming $field definition.
142 $field += array(
143 'indexes' => array(),
144 );
145 $field['indexes'] += $schema['indexes'];
146
147 // The serialized 'data' column contains everything from $field that does not
148 // have its own column and is not automatically populated when the field is
149 // read.
150 $data = $field;
151 unset($data['columns'], $data['field_name'], $data['type'], $data['active'], $data['module'], $data['storage_type'], $data['storage_active'], $data['storage_module'], $data['locked'], $data['cardinality'], $data['deleted']);
152 // Additionally, do not save the 'bundles' property populated by
153 // field_info_field().
154 unset($data['bundles']);
155
156 $record = array(
157 'field_name' => $field['field_name'],
158 'type' => $field['type'],
159 'module' => $field['module'],
160 'active' => $field['active'],
161 'storage_type' => $field['storage']['type'],
162 'storage_module' => $field['storage']['module'],
163 'storage_active' => $field['storage']['active'],
164 'locked' => $field['locked'],
165 'data' => $data,
166 'cardinality' => $field['cardinality'],
167 'translatable' => $field['translatable'],
168 'deleted' => $field['deleted'],
169 );
170
171 // Store the field and get the id back.
172 drupal_write_record('field_config', $record);
173 $field['id'] = $record['id'];
174
175 // Invoke hook_field_storage_create_field after the field is
176 // complete (e.g. it has its id).
177 try {
178 // Invoke hook_field_storage_create_field after
179 // drupal_write_record() sets the field id.
180 module_invoke($storage_type['module'], 'field_storage_create_field', $field);
181 }
182 catch (Exception $e) {
183 // If storage creation failed, remove the field_config record before
184 // rethrowing the exception.
185 db_delete('field_config')
186 ->condition('id', $field['id'])
187 ->execute();
188 throw $e;
189 }
190
191 // Clear caches
192 field_cache_clear(TRUE);
193
194 // Invoke external hooks after the cache is cleared for API consistency.
195 module_invoke_all('field_create_field', $field);
196
197 return $field;
198 }
199
220 function field_update_field($field) {
221 // Check that the specified field exists.
222 $prior_field = field_read_field($field['field_name']);
223 if (empty($prior_field)) {
224 throw new FieldException('Attempt to update a non-existent field.');
225 }
226
227 // Use the prior field values for anything not specifically set by the new
228 // field to be sure that all values are set.
229 $field += $prior_field;
230 $field['settings'] += $prior_field['settings'];
231
232 // Some updates are always disallowed.
233 if ($field['type'] != $prior_field['type']) {
234 throw new FieldException("Cannot change an existing field's type.");
235 }
236 if ($field['entity_types'] != $prior_field['entity_types']) {
237 throw new FieldException("Cannot change an existing field's entity_types property.");
238 }
239 if ($field['storage']['type'] != $prior_field['storage']['type']) {
240 throw new FieldException("Cannot change an existing field's storage type.");
241 }
242
243 // Collect the new storage information, since what is in
244 // $prior_field may no longer be right.
245 module_load_install($field['module']);
246 $schema = (array) module_invoke($field['module'], 'field_schema', $field);
247 $schema += array('columns' => array(), 'indexes' => array(), 'foreign keys' => array());
248 // 'columns' are hardcoded in the field type.
249 $field['columns'] = $schema['columns'];
250 // 'foreign keys' are hardcoded in the field type.
251 $field['foreign keys'] = $schema['foreign keys'];
252 // 'indexes' can be both hardcoded in the field type, and specified in the
253 // incoming $field definition.
254 $field += array(
255 'indexes' => array(),
256 );
257 $field['indexes'] += $schema['indexes'];
258
259 $has_data = field_has_data($field);
260
261 // See if any module forbids the update by throwing an exception.
262 foreach (module_implements('field_update_forbid') as $module) {
263 $function = $module . '_field_update_forbid';
264 $function($field, $prior_field, $has_data);
265 }
266
267 // Tell the storage engine to update the field. Do this before
268 // saving the new definition since it still might fail.
269 $storage_type = field_info_storage_types($field['storage']['type']);
270 module_invoke($storage_type['module'], 'field_storage_update_field', $field, $prior_field, $has_data);
271
272 // Save the new field definition. @todo: refactor with
273 // field_create_field.
274
275 // The serialized 'data' column contains everything from $field that does not
276 // have its own column and is not automatically populated when the field is
277 // read.
278 $data = $field;
279 unset($data['columns'], $data['field_name'], $data['type'], $data['locked'], $data['module'], $data['cardinality'], $data['active'], $data['deleted']);
280 // Additionally, do not save the 'bundles' property populated by
281 // field_info_field().
282 unset($data['bundles']);
283
284 $field['data'] = $data;
285
286 // Store the field and create the id.
287 $primary_key = array('id');
288 drupal_write_record('field_config', $field, $primary_key);
289
290 // Clear caches
291 field_cache_clear(TRUE);
292
293 // Invoke external hooks after the cache is cleared for API consistency.
294 module_invoke_all('field_update_field', $field, $prior_field, $has_data);
295 }
296
315 function field_read_field($field_name, $include_additional = array()) {
316 $fields = field_read_fields(array('field_name' => $field_name), $include_additional);
317 return $fields ? current($fields) : FALSE;
318 }
319
340 function field_read_fields($params = array(), $include_additional = array()) {
341 $query = db_select('field_config', 'fc', array('fetch' => PDO::FETCH_ASSOC));
342 $query->fields('fc');
343
344 // Turn the conditions into a query.
345 foreach ($params as $key => $value) {
346 // Allow filtering on the 'entity_type' and 'bundle' columns of the
347 // field_config_instance table.
348 if ($key == 'entity_type' || $key == 'bundle') {
349 if (empty($fci_join)) {
350 $fci_join = $query->join('field_config_instance', 'fci', 'fc.id = fci.field_id');
351 }
352 $key = 'fci.' . $key;
353 }
354 else {
355 $key = 'fc.' . $key;
356 }
357
358 $query->condition($key, $value);
359 }
360
361 if (!isset($include_additional['include_inactive']) || !$include_additional['include_inactive']) {
362 $query
363 ->condition('fc.active', 1)
364 ->condition('fc.storage_active', 1);
365 }
366 $include_deleted = (isset($include_additional['include_deleted']) && $include_additional['include_deleted']);
367 if (!$include_deleted) {
368 $query->condition('fc.deleted', 0);
369 }
370
371 $fields = array();
372 $results = $query->execute();
373 foreach ($results as $record) {
374 $field = unserialize($record['data']);
375 $field['id'] = $record['id'];
376 $field['field_name'] = $record['field_name'];
377 $field['type'] = $record['type'];
378 $field['module'] = $record['module'];
379 $field['active'] = $record['active'];
380 $field['storage']['type'] = $record['storage_type'];
381 $field['storage']['module'] = $record['storage_module'];
382 $field['storage']['active'] = $record['storage_active'];
383 $field['locked'] = $record['locked'];
384 $field['cardinality'] = $record['cardinality'];
385 $field['translatable'] = $record['translatable'];
386 $field['deleted'] = $record['deleted'];
387
388 module_invoke_all('field_read_field', $field);
389
390 // Populate storage information.
391 module_load_install($field['module']);
392 $schema = (array) module_invoke($field['module'], 'field_schema', $field);
393 $schema += array('columns' => array(), 'indexes' => array());
394 $field['columns'] = $schema['columns'];
395
396 $field_name = $field['field_name'];
397 if ($include_deleted) {
398 $field_name = $field['id'];
399 }
400 $fields[$field_name] = $field;
401 }
402 return $fields;
403 }
404
411 function field_delete_field($field_name) {
412 // Delete all non-deleted instances.
413 $field = field_info_field($field_name);
414 if (isset($field['bundles'])) {
415 foreach ($field['bundles'] as $entity_type => $bundles) {
416 foreach ($bundles as $bundle) {
417 $instance = field_info_instance($entity_type, $field_name, $bundle);
418 field_delete_instance($instance, FALSE);
419 }
420 }
421 }
422
423 // Mark field data for deletion.
424 module_invoke($field['storage']['module'], 'field_storage_delete_field', $field);
425
426 // Mark the field for deletion.
427 db_update('field_config')
428 ->fields(array('deleted' => 1))
429 ->condition('field_name', $field_name)
430 ->execute();
431
432 // Clear the cache.
433 field_cache_clear(TRUE);
434
435 module_invoke_all('field_delete_field', $field);
436 }
437
473 function field_create_instance($instance) {
474 $field = field_read_field($instance['field_name']);
475 if (empty($field)) {
476 throw new FieldException(t("Attempt to create an instance of a field @field_name that doesn't exist or is currently inactive.", array('@field_name' => $instance['field_name'])));
477 }
478 // Check that the required properties exists.
479 if (empty($instance['entity_type'])) {
480 throw new FieldException(t('Attempt to create an instance of field @field_name without an entity type.', array('@field_name' => $instance['field_name'])));
481 }
482 if (empty($instance['bundle'])) {
483 throw new FieldException(t('Attempt to create an instance of field @field_name without a bundle.', array('@field_name' => $instance['field_name'])));
484 }
485 // Check that the field can be attached to this entity type.
486 if (!empty($field['entity_types']) && !in_array($instance['entity_type'], $field['entity_types'])) {
487 throw new FieldException(t('Attempt to create an instance of field @field_name on forbidden entity type @entity_type.', array('@field_name' => $instance['field_name'], '@entity_type' => $instance['entity_type'])));
488 }
489
490 // Set the field id.
491 $instance['field_id'] = $field['id'];
492
493 // Note that we do *not* prevent creating a field on non-existing bundles,
494 // because that would break the 'Body as field' upgrade for contrib
495 // node types.
496
497 // TODO: Check that the widget type is known and can handle the field type ?
498 // TODO: Check that the formatters are known and can handle the field type ?
499 // TODO: Check that the display view modes are known for the entity type ?
500 // Those checks should probably happen in _field_write_instance() ?
501 // Problem : this would mean that a UI module cannot update an instance with a disabled formatter.
502
503 // Ensure the field instance is unique within the bundle.
504 // We only check for instances of active fields, since adding an instance of
505 // a disabled field is not supported.
506 $prior_instance = field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']);
507 if (!empty($prior_instance)) {
508 $message = t('Attempt to create an instance of field @field_name on bundle @bundle that already has an instance of that field.', array('@field_name' => $instance['field_name'], '@bundle' => $instance['bundle']));
509 throw new FieldException($message);
510 }
511
512 _field_write_instance($instance);
513
514 // Clear caches
515 field_cache_clear();
516
517 // Invoke external hooks after the cache is cleared for API consistency.
518 module_invoke_all('field_create_instance', $instance);
519
520 return $instance;
521 }
522
553 function field_update_instance($instance) {
554 // Check that the specified field exists.
555 $field = field_read_field($instance['field_name']);
556 if (empty($field)) {
557 throw new FieldException(t('Attempt to update an instance of a nonexistent field @field.', array('@field' => $instance['field_name'])));
558 }
559
560 // Check that the field instance exists (even if it is inactive, since we
561 // want to be able to replace inactive widgets with new ones).
562 $prior_instance = field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle'], array('include_inactive' => TRUE));
563 if (empty($prior_instance)) {
564 throw new FieldException(t("Attempt to update an instance of field @field on bundle @bundle that doesn't exist.", array('@field' => $instance['field_name'], '@bundle' => $instance['bundle'])));
565 }
566
567 $instance['id'] = $prior_instance['id'];
568 $instance['field_id'] = $prior_instance['field_id'];
569
570 _field_write_instance($instance, TRUE);
571
572 // Clear caches.
573 field_cache_clear();
574
575 module_invoke_all('field_update_instance', $instance, $prior_instance);
576 }
577
586 function _field_write_instance($instance, $update = FALSE) {
587 $field = field_read_field($instance['field_name']);
588 $field_type = field_info_field_types($field['type']);
589
590 // Set defaults.
591 $instance += array(
592 'settings' => array(),
593 'display' => array(),
594 'widget' => array(),
595 'required' => FALSE,
596 'label' => $instance['field_name'],
597 'description' => '',
598 'deleted' => 0,
599 );
600
601 // Set default instance settings.
602 $instance['settings'] += field_info_instance_settings($field['type']);
603
604 // Set default widget and settings.
605 $instance['widget'] += array(
606 // TODO: what if no 'default_widget' specified ?
607 'type' => $field_type['default_widget'],
608 'settings' => array(),
609 );
610 // If no weight specified, make sure the field sinks at the bottom.
611 if (!isset($instance['widget']['weight'])) {
612 $max_weight = field_info_max_weight($instance['entity_type'], $instance['bundle'], 'form');
613 $instance['widget']['weight'] = isset($max_weight) ? $max_weight + 1 : 0;
614 }
615 // Check widget module.
616 $widget_type = field_info_widget_types($instance['widget']['type']);
617 $instance['widget']['module'] = $widget_type['module'];
618 $instance['widget']['settings'] += field_info_widget_settings($instance['widget']['type']);
619
620 // Make sure there are at least display settings for the 'default' view mode,
621 // and fill in defaults for each view mode specified in the definition.
622 $instance['display'] += array(
623 'default' => array(),
624 );
625 foreach ($instance['display'] as $view_mode => $display) {
626 $display += array(
627 'label' => 'above',
628 'type' => isset($field_type['default_formatter']) ? $field_type['default_formatter'] : 'hidden',
629 'settings' => array(),
630 );
631 if ($display['type'] != 'hidden') {
632 $formatter_type = field_info_formatter_types($display['type']);
633 $display['module'] = $formatter_type['module'];
634 $display['settings'] += field_info_formatter_settings($display['type']);
635 }
636 // If no weight specified, make sure the field sinks at the bottom.
637 if (!isset($display['weight'])) {
638 $max_weight = field_info_max_weight($instance['entity_type'], $instance['bundle'], $view_mode);
639 $display['weight'] = isset($max_weight) ? $max_weight + 1 : 0;
640 }
641 $instance['display'][$view_mode] = $display;
642 }
643
644 // The serialized 'data' column contains everything from $instance that does
645 // not have its own column and is not automatically populated when the
646 // instance is read.
647 $data = $instance;
648 unset($data['id'], $data['field_id'], $data['field_name'], $data['entity_type'], $data['bundle'], $data['deleted']);
649
650 $record = array(
651 'field_id' => $instance['field_id'],
652 'field_name' => $instance['field_name'],
653 'entity_type' => $instance['entity_type'],
654 'bundle' => $instance['bundle'],
655 'data' => $data,
656 'deleted' => $instance['deleted'],
657 );
658 // We need to tell drupal_update_record() the primary keys to trigger an
659 // update.
660 if ($update) {
661 $record['id'] = $instance['id'];
662 $primary_key = array('id');
663 }
664 else {
665 $primary_key = array();
666 }
667 drupal_write_record('field_config_instance', $record, $primary_key);
668 }
669
692 function field_read_instance($entity_type, $field_name, $bundle, $include_additional = array()) {
693 $instances = field_read_instances(array('entity_type' => $entity_type, 'field_name' => $field_name, 'bundle' => $bundle), $include_additional);
694 return $instances ? current($instances) : FALSE;
695 }
696
713 function field_read_instances($params = array(), $include_additional = array()) {
714 $include_inactive = isset($include_additional['include_inactive']) && $include_additional['include_inactive'];
715 $include_deleted = isset($include_additional['include_deleted']) && $include_additional['include_deleted'];
716
717 $query = db_select('field_config_instance', 'fci', array('fetch' => PDO::FETCH_ASSOC));
718 $query->join('field_config', 'fc', 'fc.id = fci.field_id');
719 $query->fields('fci');
720
721 // Turn the conditions into a query.
722 foreach ($params as $key => $value) {
723 $query->condition('fci.' . $key, $value);
724 }
725 if (!$include_inactive) {
726 $query
727 ->condition('fc.active', 1)
728 ->condition('fc.storage_active', 1);
729 }
730 if (!$include_deleted) {
731 $query->condition('fc.deleted', 0);
732 $query->condition('fci.deleted', 0);
733 }
734
735 $instances = array();
736 $results = $query->execute();
737
738 foreach ($results as $record) {
739 // Filter out instances on unknown entity types (for instance because the
740 // module exposing them was disabled).
741 $entity_info = entity_get_info($record['entity_type']);
742 if ($include_inactive || $entity_info) {
743 $instance = unserialize($record['data']);
744 $instance['id'] = $record['id'];
745 $instance['field_id'] = $record['field_id'];
746 $instance['field_name'] = $record['field_name'];
747 $instance['entity_type'] = $record['entity_type'];
748 $instance['bundle'] = $record['bundle'];
749 $instance['deleted'] = $record['deleted'];
750
751 module_invoke_all('field_read_instance', $instance);
752 $instances[] = $instance;
753 }
754 }
755 return $instances;
756 }
757
768 function field_delete_instance($instance, $field_cleanup = TRUE) {
769 // Mark the field instance for deletion.
770 db_update('field_config_instance')
771 ->fields(array('deleted' => 1))
772 ->condition('field_name', $instance['field_name'])
773 ->condition('entity_type', $instance['entity_type'])
774 ->condition('bundle', $instance['bundle'])
775 ->execute();
776
777 // Clear the cache.
778 field_cache_clear();
779
780 // Mark instance data for deletion.
781 $field = field_info_field($instance['field_name']);
782 module_invoke($field['storage']['module'], 'field_storage_delete_instance', $instance);
783
784 // Let modules react to the deletion of the instance.
785 module_invoke_all('field_delete_instance', $instance);
786
787 // Delete the field itself if we just deleted its last instance.
788 if ($field_cleanup && count($field['bundles']) == 0) {
789 field_delete_field($field['field_name']);
790 }
791 }
792
880 function field_purge_batch($batch_size) {
881 // Retrieve all deleted field instances. We cannot use field_info_instances()
882 // because that function does not return deleted instances.
883 $instances = field_read_instances(array('deleted' => 1), array('include_deleted' => 1));
884
885 foreach ($instances as $instance) {
886 // field_purge_data() will need the field array.
887 $field = field_info_field_by_id($instance['field_id']);
888 // Retrieve some entities.
889 $query = new EntityFieldQuery();
890 $results = $query
891 ->fieldCondition($field)
892 ->entityCondition('bundle', $instance['bundle'])
893 ->deleted(TRUE)
894 ->range(0, $batch_size)
895 ->execute();
896
897 if ($results) {
898 foreach ($results as $entity_type => $stub_entities) {
899 field_attach_load($entity_type, $stub_entities, FIELD_LOAD_CURRENT, array('field_id' => $field['id'], 'deleted' => 1));
900 foreach ($stub_entities as $stub_entity) {
901 // Purge the data for the entity.
902 field_purge_data($entity_type, $stub_entity, $field, $instance);
903 }
904 }
905 }
906 else {
907 // No field data remains for the instance, so we can remove it.
908 field_purge_instance($instance);
909 }
910 }
911
912 // Retrieve all deleted fields. Any that have no instances can be purged.
913 $fields = field_read_fields(array('deleted' => 1), array('include_deleted' => 1));
914 foreach ($fields as $field) {
915 $instances = field_read_instances(array('field_id' => $field['id']), array('include_deleted' => 1));
916 if (empty($instances)) {
917 field_purge_field($field);
918 }
919 }
920 }
921
938 function field_purge_data($entity_type, $entity, $field, $instance) {
939 // Each field type's hook_field_delete() only expects to operate on a single
940 // field at a time, so we can use it as-is for purging.
941 $options = array('field_id' => $instance['field_id'], 'deleted' => TRUE);
942 _field_invoke('delete', $entity_type, $entity, $dummy, $dummy, $options);
943
944 // Tell the field storage system to purge the data.
945 module_invoke($field['storage']['module'], 'field_storage_purge', $entity_type, $entity, $field, $instance);
946
947 // Let other modules act on purging the data.
948 foreach (module_implements('field_attach_purge') as $module) {
949 $function = $module . '_field_attach_purge';
950 $function($entity_type, $entity, $field, $instance);
951 }
952 }
953
963 function field_purge_instance($instance) {
964 db_delete('field_config_instance')
965 ->condition('id', $instance['id'])
966 ->execute();
967
968 // Notify the storage engine.
969 $field = field_info_field_by_id($instance['field_id']);
970 module_invoke($field['storage']['module'], 'field_storage_purge_instance', $instance);
971
972 // Clear the cache.
973 field_info_cache_clear();
974
975 // Invoke external hooks after the cache is cleared for API consistency.
976 module_invoke_all('field_purge_instance', $instance);
977 }
978
988 function field_purge_field($field) {
989 $instances = field_read_instances(array('field_id' => $field['id']), array('include_deleted' => 1));
990 if (count($instances) > 0) {
991 throw new FieldException(t('Attempt to purge a field @field_name that still has instances.', array('@field_name' => $field['field_name'])));
992 }
993
994 db_delete('field_config')
995 ->condition('id', $field['id'])
996 ->execute();
997
998 // Notify the storage engine.
999 module_invoke($field['storage']['module'], 'field_storage_purge_field', $field);
1000
1001 // Clear the cache.
1002 field_info_cache_clear();
1003
1004 // Invoke external hooks after the cache is cleared for API consistency.
1005 module_invoke_all('field_purge_field', $field);
1006 }
1007
field_info_storage_types
field_info_storage_types($storage_type=NULL)
Definition: field.info.inc:404
field_read_fields
field_read_fields($params=array(), $include_additional=array())
Definition: field.crud.inc:340
field_create_instance
field_create_instance($instance)
Definition: field.crud.inc:473
field_info_field_by_id
field_info_field_by_id($field_id)
Definition: field.info.inc:537
field_purge_instance
field_purge_instance($instance)
Definition: field.crud.inc:963
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
field_info_formatter_types
field_info_formatter_types($formatter_type=NULL)
Definition: field.info.inc:379
drupal_strlen
drupal_strlen($text)
Definition: unicode.inc:474
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
$module
print $module
Definition: search-results.tpl.php:28
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$results
print $results
Definition: poll-results.tpl.php:23
Exception
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
field_read_instance
field_read_instance($entity_type, $field_name, $bundle, $include_additional=array())
Definition: field.crud.inc:692
field_read_instances
field_read_instances($params=array(), $include_additional=array())
Definition: field.crud.inc:713
_field_invoke
_field_invoke($op, $entity_type, $entity, &$a=NULL, &$b=NULL, $options=array())
Definition: field.attach.inc:181
field_has_data
field_has_data($field)
Definition: field.module:948
module_load_install
module_load_install($module)
Definition: module.inc:288
field_cache_clear
field_cache_clear()
Definition: field.module:740
field_info_field_types
field_info_field_types($field_type=NULL)
Definition: field.info.inc:329
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
field_create_field
field_create_field($field)
Definition: field.crud.inc:56
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$info
$info
Definition: color.inc:6
field_info_field_settings
field_info_field_settings($type)
Definition: field.info.inc:742
field_info_cache_clear
field_info_cache_clear()
Definition: field.info.inc:54
field_info_instance_settings
field_info_instance_settings($type)
Definition: field.info.inc:757
EntityFieldQuery
Definition: entity.inc:420
$value
print $value
Definition: user-profile-item.tpl.php:26
field_attach_load
field_attach_load($entity_type, $entities, $age=FIELD_LOAD_CURRENT, $options=array())
Definition: field.attach.inc:622
field_purge_batch
field_purge_batch($batch_size)
Definition: field.crud.inc:880
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
FieldException
Definition: field.module:13
field_info_widget_settings
field_info_widget_settings($type)
Definition: field.info.inc:773
field_purge_field
field_purge_field($field)
Definition: field.crud.inc:988
field_delete_field
field_delete_field($field_name)
Definition: field.crud.inc:411
field_info_storage_settings
field_info_storage_settings($type)
Definition: field.info.inc:805
_field_write_instance
_field_write_instance($instance, $update=FALSE)
Definition: field.crud.inc:586
field_delete_instance
field_delete_instance($instance, $field_cleanup=TRUE)
Definition: field.crud.inc:768
field_update_instance
field_update_instance($instance)
Definition: field.crud.inc:553
field_purge_data
field_purge_data($entity_type, $entity, $field, $instance)
Definition: field.crud.inc:938
field_info_max_weight
field_info_max_weight($entity_type, $bundle, $context)
Definition: field.info.inc:708
field_info_widget_types
field_info_widget_types($widget_type=NULL)
Definition: field.info.inc:354
field_info_formatter_settings
field_info_formatter_settings($type)
Definition: field.info.inc:789
field_update_field
field_update_field($field)
Definition: field.crud.inc:220
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
field_read_field
field_read_field($field_name, $include_additional=array())
Definition: field.crud.inc:315
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
field_info_instance
field_info_instance($entity_type, $field_name, $bundle_name)
Definition: field.info.inc:623
FIELD_LOAD_CURRENT
const FIELD_LOAD_CURRENT
Definition: field.module:268
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile/profile-block.tpl.php Source File

  • modules
  • profile
profile-block.tpl.php
Go to the documentation of this file.
1 <?php
2
31 ?>
32 <?php print $user_picture; ?>
33
34 <?php foreach ($profile as $field): ?>
35 <p>
36 <?php if ($field->type != 'checkbox'): ?>
37 <strong><?php print $field->title; ?></strong><br />
38 <?php endif; ?>
39 <?php print $field->value; ?>
40 </p>
41 <?php endforeach; ?>
$user_picture
print $user_picture
Definition: node.tpl.php:85
print
print
Definition: php-2.php:2
endforeach
endforeach
Definition: block-admin-display-form.tpl.php:64
endif
endif
Definition: aggregator-item.tpl.php:31
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalStreamWrapperInterface Member List

This is the complete list of members for DrupalStreamWrapperInterface, including all inherited members.

chmod($mode) | DrupalStreamWrapperInterface |
dir_closedir() | StreamWrapperInterface |
dir_opendir($uri, $options) | StreamWrapperInterface |
dir_readdir() | StreamWrapperInterface |
dir_rewinddir() | StreamWrapperInterface |
dirname($uri=NULL) | DrupalStreamWrapperInterface |
getExternalUrl() | DrupalStreamWrapperInterface |
getMimeType($uri, $mapping=NULL) | DrupalStreamWrapperInterface | static
getUri() | DrupalStreamWrapperInterface |
mkdir($uri, $mode, $options) | StreamWrapperInterface |
realpath() | DrupalStreamWrapperInterface |
rename($from_uri, $to_uri) | StreamWrapperInterface |
rmdir($uri, $options) | StreamWrapperInterface |
setUri($uri) | DrupalStreamWrapperInterface |
stream_close() | StreamWrapperInterface |
stream_eof() | StreamWrapperInterface |
stream_flush() | StreamWrapperInterface |
stream_lock($operation) | StreamWrapperInterface |
stream_open($uri, $mode, $options, &$opened_url) | StreamWrapperInterface |
stream_read($count) | StreamWrapperInterface |
stream_seek($offset, $whence) | StreamWrapperInterface |
stream_stat() | StreamWrapperInterface |
stream_tell() | StreamWrapperInterface |
stream_write($data) | StreamWrapperInterface |
unlink($uri) | StreamWrapperInterface |
url_stat($uri, $flags) | StreamWrapperInterface |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/blog/blog.module Source File

  • modules
  • blog
blog.module
Go to the documentation of this file.
1 <?php
2
11 function blog_node_info() {
12 return array(
13 'blog' => array(
14 'name' => t('Blog entry'),
15 'base' => 'blog',
16 'description' => t('Use for multi-user blogs. Every user gets a personal blog.'),
17 )
18 );
19 }
20
24 function blog_user_view($account) {
25 if (user_access('create blog content', $account)) {
26 $account->content['summary']['blog'] = array(
27 '#type' => 'user_profile_item',
28 '#title' => t('Blog'),
29 // l() escapes the attributes, so we should not escape !username here.
30 '#markup' => l(t('View recent blog entries'), "blog/$account->uid", array('attributes' => array('title' => t("Read !username's latest blog entries.", array('!username' => format_username($account)))))),
31 '#attributes' => array('class' => array('blog')),
32 );
33 }
34 }
35
39 function blog_help($path, $arg) {
40 switch ($path) {
41 case 'admin/help#blog':
42 $output = '<h3>' . t('About') . '</h3>';
43 $output .= '<p>' . t("The Blog module allows registered users to maintain an online journal, or <em>blog</em>. Blogs are made up of individual <em>blog entries</em>. By default, the blog entries are displayed by creation time in descending order, with comments enabled, and are promoted to the site's front page. For more information, see the online handbook entry for <a href='@blog'>Blog module</a>.", array('@blog' => 'http://drupal.org/documentation/modules/blog/')) . '</p>';
44 $output .= '<h3>' . t('Uses') . '</h3>';
45 $output .= '<dl>';
46 $output .= '<dt>' . t('Single-user blogs') . '</dt>';
47 $output .= '<dd>' . t("Each user's blog entries are automatically displayed with a link to the user's main blog page. You can create as many single-user blogs as you have site users with permission to create blog content.") . '</dd>';
48 $output .= '<dt>' . t('Multi-user blogs') . '</dt>';
49 $output .= '<dd>' . t("Blog entries from each single-user blog are also aggregated into one central multi-user blog, which displays the blog content of all users in a single listing.") . '</dd>';
50 $output .= '<dt>' . t('Navigation') . '</dt>';
51 $output .= '<dd>' . t("There is an optional <em>Blogs</em> menu item added to the Navigation menu, which displays all blogs available on your site, and a <em>My blog</em> item displaying the current user's blog entries.") . '</dd>';
52 $output .= '<dt>' . t('Blocks') . '</dt>';
53 $output .= '<dd>' . t('The Blog module also creates a default <em>Recent blog posts</em> block that may be enabled at the <a href="@blocks">blocks administration page</a>.', array('@blocks' => url('admin/structure/block'))) . '</dd>';
54 $output .= '</dl>';
55 return $output;
56 }
57 }
58
62 function blog_form($node, $form_state) {
63 return node_content_form($node, $form_state);
64 }
65
69 function blog_view($node, $view_mode) {
70 if ($view_mode == 'full' && node_is_page($node)) {
71 // Breadcrumb navigation. l() escapes title, so we should not escape !name.
72 drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Blogs'), 'blog'), l(t("!name's blog", array('!name' => format_username($node))), 'blog/' . $node->uid)));
73 }
74 return $node;
75 }
76
80 function blog_node_view($node, $view_mode) {
81 if ($view_mode != 'rss') {
82 if ($node->type == 'blog' && (arg(0) != 'blog' || arg(1) != $node->uid)) {
83 // This goes to l(), which escapes !username in both title and attributes.
84 $links['blog_usernames_blog'] = array(
85 'title' => t("!username's blog", array('!username' => format_username($node))),
86 'href' => "blog/$node->uid",
87 'attributes' => array('title' => t("Read !username's latest blog entries.", array('!username' => format_username($node)))),
88 );
89 $node->content['links']['blog'] = array(
90 '#theme' => 'links__node__blog',
91 '#links' => $links,
92 '#attributes' => array('class' => array('links', 'inline')),
93 );
94 }
95 }
96 }
97
101 function blog_menu() {
102 $items['blog'] = array(
103 'title' => 'Blogs',
104 'page callback' => 'blog_page_last',
105 'access arguments' => array('access content'),
106 'type' => MENU_SUGGESTED_ITEM,
107 'file' => 'blog.pages.inc',
108 );
109 $items['blog/%user_uid_optional'] = array(
110 'title' => 'My blog',
111 'page callback' => 'blog_page_user',
112 'page arguments' => array(1),
113 'access callback' => 'blog_page_user_access',
114 'access arguments' => array(1),
115 'file' => 'blog.pages.inc',
116 );
117 $items['blog/%user/feed'] = array(
118 'title' => 'Blogs',
119 'page callback' => 'blog_feed_user',
120 'page arguments' => array(1),
121 'access callback' => 'blog_page_user_access',
122 'access arguments' => array(1),
123 'type' => MENU_CALLBACK,
124 'file' => 'blog.pages.inc',
125 );
126 $items['blog/feed'] = array(
127 'title' => 'Blogs',
128 'page callback' => 'blog_feed_last',
129 'access arguments' => array('access content'),
130 'type' => MENU_CALLBACK,
131 'file' => 'blog.pages.inc',
132 );
133
134 return $items;
135 }
136
140 function blog_menu_local_tasks_alter(&$data, $router_item, $root_path) {
141 global $user;
142
143 // Add action link to 'node/add/blog' on 'blog' page.
144 if ($root_path == 'blog') {
145 $item = menu_get_item('node/add/blog');
146 if ($item['access']) {
147 $item['title'] = t('Create new blog entry');
148 $data['actions']['output'][] = array(
149 '#theme' => 'menu_local_action',
150 '#link' => $item,
151 );
152 }
153 }
154 // Provide a helper action link to the author on the 'blog/%' page.
155 elseif ($root_path == 'blog/%' && $router_item['page_arguments'][0]->uid == $user->uid) {
156 $data['actions']['output']['blog'] = array(
157 '#theme' => 'menu_local_action',
158 );
159 if (user_access('create blog content')) {
160 $data['actions']['output']['blog']['#link']['title'] = t('Post new blog entry.');
161 $data['actions']['output']['blog']['#link']['href'] = 'node/add/blog';
162 }
163 else {
164 $data['actions']['output']['blog']['#link']['title'] = t('You are not allowed to post a new blog entry.');
165 }
166 }
167 }
168
172 function blog_page_user_access($account) {
173 // The visitor must be able to access the site's content.
174 // For a blog to 'exist' the user must either be able to
175 // create new blog entries, or it must have existing posts.
176 return $account->uid && user_access('access content') && (user_access('create blog content', $account) || _blog_post_exists($account));
177 }
178
182 function _blog_post_exists($account) {
183 return (bool)db_select('node', 'n')
184 ->fields('n', array('nid'))
185 ->condition('type', 'blog')
186 ->condition('uid', $account->uid)
187 ->condition('status', 1)
188 ->range(0, 1)
189 ->addTag('node_access')
190 ->execute()
191 ->fetchField();
192 }
193
197 function blog_block_info() {
198 $block['recent']['info'] = t('Recent blog posts');
199 $block['recent']['properties']['administrative'] = TRUE;
200 return $block;
201 }
202
206 function blog_block_configure($delta = '') {
207 if ($delta == 'recent') {
208 $form['blog_block_count'] = array(
209 '#type' => 'select',
210 '#title' => t('Number of recent blog posts to display'),
211 '#default_value' => variable_get('blog_block_count', 10),
212 '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
213 );
214 return $form;
215 }
216 }
217
221 function blog_block_save($delta = '', $edit = array()) {
222 if ($delta == 'recent') {
223 variable_set('blog_block_count', $edit['blog_block_count']);
224 }
225 }
226
232 function blog_block_view($delta = '') {
233 global $user;
234
235 if (user_access('access content')) {
236 $result = db_select('node', 'n')
237 ->fields('n', array('nid', 'title', 'created'))
238 ->condition('type', 'blog')
239 ->condition('status', 1)
240 ->orderBy('created', 'DESC')
241 ->range(0, variable_get('blog_block_count', 10))
242 ->addTag('node_access')
243 ->execute();
244
245 if ($node_title_list = node_title_list($result)) {
246 $block['subject'] = t('Recent blog posts');
247 $block['content']['blog_list'] = $node_title_list;
248 $block['content']['blog_more'] = array(
249 '#theme' => 'more_link',
250 '#url' => 'blog',
251 '#title' => t('Read the latest blog entries.'),
252 );
253
254 return $block;
255 }
256 }
257 }
258
262 function blog_rdf_mapping() {
263 return array(
264 array(
265 'type' => 'node',
266 'bundle' => 'blog',
267 'mapping' => array(
268 'rdftype' => array('sioc:Post', 'sioct:BlogPost'),
269 ),
270 ),
271 );
272 }
blog_user_view
blog_user_view($account)
Definition: blog.module:24
menu_get_item
menu_get_item($path=NULL, $router_item=NULL)
Definition: menu.inc:447
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_set_breadcrumb
drupal_set_breadcrumb($breadcrumb=NULL)
Definition: common.inc:243
blog_rdf_mapping
blog_rdf_mapping()
Definition: blog.module:262
format_username
format_username($account)
Definition: common.inc:2106
blog_block_save
blog_block_save($delta= '', $edit=array())
Definition: blog.module:221
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
blog_help
blog_help($path, $arg)
Definition: blog.module:39
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
node_is_page
node_is_page($node)
Definition: node.module:1487
blog_view
blog_view($node, $view_mode)
Definition: blog.module:69
blog_node_view
blog_node_view($node, $view_mode)
Definition: blog.module:80
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
node_content_form
node_content_form($node, $form_state)
Definition: node.module:3725
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
_blog_post_exists
_blog_post_exists($account)
Definition: blog.module:182
blog_block_view
blog_block_view($delta= '')
Definition: blog.module:232
blog_page_user_access
blog_page_user_access($account)
Definition: blog.module:172
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
blog_block_info
blog_block_info()
Definition: blog.module:197
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
MENU_SUGGESTED_ITEM
const MENU_SUGGESTED_ITEM
Definition: menu.inc:161
blog_menu
blog_menu()
Definition: blog.module:101
blog_form
blog_form($node, $form_state)
Definition: blog.module:62
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
blog_node_info
blog_node_info()
Definition: blog.module:11
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
blog_menu_local_tasks_alter
blog_menu_local_tasks_alter(&$data, $router_item, $root_path)
Definition: blog.module:140
$links
print $links
Definition: poll-results--block.tpl.php:28
blog_block_configure
blog_block_configure($delta= '')
Definition: blog.module:206
node_title_list
node_title_list($result, $title=NULL)
Definition: node.module:288
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/stream_wrappers.inc Source File

  • includes
stream_wrappers.inc
Go to the documentation of this file.
1 <?php
2
32 define('STREAM_WRAPPERS_ALL', 0x0000);
33
37 define('STREAM_WRAPPERS_LOCAL', 0x0001);
38
42 define('STREAM_WRAPPERS_READ', 0x0004);
43
47 define('STREAM_WRAPPERS_WRITE', 0x0008);
48
52 define('STREAM_WRAPPERS_VISIBLE', 0x0010);
53
62 define('STREAM_WRAPPERS_HIDDEN', STREAM_WRAPPERS_READ | STREAM_WRAPPERS_WRITE);
63
67 define('STREAM_WRAPPERS_LOCAL_HIDDEN', STREAM_WRAPPERS_LOCAL | STREAM_WRAPPERS_HIDDEN);
68
72 define('STREAM_WRAPPERS_WRITE_VISIBLE', STREAM_WRAPPERS_READ | STREAM_WRAPPERS_WRITE | STREAM_WRAPPERS_VISIBLE);
73
77 define('STREAM_WRAPPERS_READ_VISIBLE', STREAM_WRAPPERS_READ | STREAM_WRAPPERS_VISIBLE);
78
86 define('STREAM_WRAPPERS_NORMAL', STREAM_WRAPPERS_WRITE_VISIBLE);
87
91 define('STREAM_WRAPPERS_LOCAL_NORMAL', STREAM_WRAPPERS_LOCAL | STREAM_WRAPPERS_NORMAL);
92
98 interface StreamWrapperInterface {
99 public function stream_open($uri, $mode, $options, &$opened_url);
100 public function stream_close();
101 public function stream_lock($operation);
102 public function stream_read($count);
103 public function stream_write($data);
104 public function stream_eof();
105 public function stream_seek($offset, $whence);
106 public function stream_flush();
107 public function stream_tell();
108 public function stream_stat();
109 public function unlink($uri);
110 public function rename($from_uri, $to_uri);
111 public function mkdir($uri, $mode, $options);
112 public function rmdir($uri, $options);
113 public function url_stat($uri, $flags);
114 public function dir_opendir($uri, $options);
115 public function dir_readdir();
116 public function dir_rewinddir();
117 public function dir_closedir();
118 }
119
126 interface DrupalStreamWrapperInterface extends StreamWrapperInterface {
136 function setUri($uri);
137
144 public function getUri();
145
157 public function getExternalUrl();
158
173 public static function getMimeType($uri, $mapping = NULL);
174
188 public function chmod($mode);
189
202 public function realpath();
203
219 public function dirname($uri = NULL);
220 }
221
222
234 abstract class DrupalLocalStreamWrapper implements DrupalStreamWrapperInterface {
240 public $context;
241
247 public $handle = NULL;
248
256 protected $uri;
257
265 abstract function getDirectoryPath();
266
270 function setUri($uri) {
271 $this->uri = $uri;
272 }
273
277 function getUri() {
278 return $this->uri;
279 }
280
297 protected function getTarget($uri = NULL) {
298 if (!isset($uri)) {
299 $uri = $this->uri;
300 }
301
302 list($scheme, $target) = explode('://', $uri, 2);
303
304 // Remove erroneous leading or trailing, forward-slashes and backslashes.
305 return trim($target, '\/');
306 }
307
311 static function getMimeType($uri, $mapping = NULL) {
312 if (!isset($mapping)) {
313 // The default file map, defined in file.mimetypes.inc is quite big.
314 // We only load it when necessary.
315 include_once DRUPAL_ROOT . '/includes/file.mimetypes.inc';
316 $mapping = file_mimetype_mapping();
317 }
318
319 $extension = '';
320 $file_parts = explode('.', drupal_basename($uri));
321
322 // Remove the first part: a full filename should not match an extension.
323 array_shift($file_parts);
324
325 // Iterate over the file parts, trying to find a match.
326 // For my.awesome.image.jpeg, we try:
327 // - jpeg
328 // - image.jpeg, and
329 // - awesome.image.jpeg
330 while ($additional_part = array_pop($file_parts)) {
331 $extension = strtolower($additional_part . ($extension ? '.' . $extension : ''));
332 if (isset($mapping['extensions'][$extension])) {
333 return $mapping['mimetypes'][$mapping['extensions'][$extension]];
334 }
335 }
336
337 return 'application/octet-stream';
338 }
339
343 function chmod($mode) {
344 $output = @chmod($this->getLocalPath(), $mode);
345 // We are modifying the underlying file here, so we have to clear the stat
346 // cache so that PHP understands that URI has changed too.
347 clearstatcache();
348 return $output;
349 }
350
354 function realpath() {
355 return $this->getLocalPath();
356 }
357
372 protected function getLocalPath($uri = NULL) {
373 if (!isset($uri)) {
374 $uri = $this->uri;
375 }
376 $path = $this->getDirectoryPath() . '/' . $this->getTarget($uri);
377 $realpath = realpath($path);
378 if (!$realpath) {
379 // This file does not yet exist.
380 $realpath = realpath(dirname($path)) . '/' . drupal_basename($path);
381 }
382 $directory = realpath($this->getDirectoryPath());
383 if (!$realpath || !$directory || strpos($realpath, $directory) !== 0) {
384 return FALSE;
385 }
386 return $realpath;
387 }
388
406 public function stream_open($uri, $mode, $options, &$opened_path) {
407 $this->uri = $uri;
408 $path = $this->getLocalPath();
409 $this->handle = ($options & STREAM_REPORT_ERRORS) ? fopen($path, $mode) : @fopen($path, $mode);
410
411 if ((bool) $this->handle && $options & STREAM_USE_PATH) {
412 $opened_path = $path;
413 }
414
415 return (bool) $this->handle;
416 }
417
434 public function stream_lock($operation) {
435 if (in_array($operation, array(LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB))) {
436 return flock($this->handle, $operation);
437 }
438
439 return TRUE;
440 }
441
453 public function stream_read($count) {
454 return fread($this->handle, $count);
455 }
456
468 public function stream_write($data) {
469 return fwrite($this->handle, $data);
470 }
471
480 public function stream_eof() {
481 return feof($this->handle);
482 }
483
497 public function stream_seek($offset, $whence) {
498 // fseek returns 0 on success and -1 on a failure.
499 // stream_seek 1 on success and 0 on a failure.
500 return !fseek($this->handle, $offset, $whence);
501 }
502
511 public function stream_flush() {
512 return fflush($this->handle);
513 }
514
523 public function stream_tell() {
524 return ftell($this->handle);
525 }
526
536 public function stream_stat() {
537 return fstat($this->handle);
538 }
539
548 public function stream_close() {
549 return fclose($this->handle);
550 }
551
563 public function unlink($uri) {
564 $this->uri = $uri;
565 return drupal_unlink($this->getLocalPath());
566 }
567
581 public function rename($from_uri, $to_uri) {
582 return rename($this->getLocalPath($from_uri), $this->getLocalPath($to_uri));
583 }
584
600 public function dirname($uri = NULL) {
601 list($scheme, $target) = explode('://', $uri, 2);
602 $target = $this->getTarget($uri);
603 $dirname = dirname($target);
604
605 if ($dirname == '.') {
606 $dirname = '';
607 }
608
609 return $scheme . '://' . $dirname;
610 }
611
627 public function mkdir($uri, $mode, $options) {
628 $this->uri = $uri;
629 $recursive = (bool) ($options & STREAM_MKDIR_RECURSIVE);
630 if ($recursive) {
631 // $this->getLocalPath() fails if $uri has multiple levels of directories
632 // that do not yet exist.
633 $localpath = $this->getDirectoryPath() . '/' . $this->getTarget($uri);
634 }
635 else {
636 $localpath = $this->getLocalPath($uri);
637 }
638 if ($options & STREAM_REPORT_ERRORS) {
639 return mkdir($localpath, $mode, $recursive);
640 }
641 else {
642 return @mkdir($localpath, $mode, $recursive);
643 }
644 }
645
659 public function rmdir($uri, $options) {
660 $this->uri = $uri;
661 if ($options & STREAM_REPORT_ERRORS) {
662 return drupal_rmdir($this->getLocalPath());
663 }
664 else {
665 return @drupal_rmdir($this->getLocalPath());
666 }
667 }
668
683 public function url_stat($uri, $flags) {
684 $this->uri = $uri;
685 $path = $this->getLocalPath();
686 // Suppress warnings if requested or if the file or directory does not
687 // exist. This is consistent with PHP's plain filesystem stream wrapper.
688 if ($flags & STREAM_URL_STAT_QUIET || !file_exists($path)) {
689 return @stat($path);
690 }
691 else {
692 return stat($path);
693 }
694 }
695
709 public function dir_opendir($uri, $options) {
710 $this->uri = $uri;
711 $this->handle = opendir($this->getLocalPath());
712
713 return (bool) $this->handle;
714 }
715
724 public function dir_readdir() {
725 return readdir($this->handle);
726 }
727
736 public function dir_rewinddir() {
737 rewinddir($this->handle);
738 // We do not really have a way to signal a failure as rewinddir() does not
739 // have a return value and there is no way to read a directory handler
740 // without advancing to the next file.
741 return TRUE;
742 }
743
752 public function dir_closedir() {
753 closedir($this->handle);
754 // We do not really have a way to signal a failure as closedir() does not
755 // have a return value.
756 return TRUE;
757 }
758 }
759
766 class DrupalPublicStreamWrapper extends DrupalLocalStreamWrapper {
770 public function getDirectoryPath() {
771 return variable_get('file_public_path', conf_path() . '/files');
772 }
773
779 function getExternalUrl() {
780 $path = str_replace('\\', '/', $this->getTarget());
781 return $GLOBALS['base_url'] . '/' . self::getDirectoryPath() . '/' . drupal_encode_path($path);
782 }
783 }
784
785
792 class DrupalPrivateStreamWrapper extends DrupalLocalStreamWrapper {
796 public function getDirectoryPath() {
797 return variable_get('file_private_path', '');
798 }
799
805 function getExternalUrl() {
806 $path = str_replace('\\', '/', $this->getTarget());
807 return url('system/files/' . $path, array('absolute' => TRUE));
808 }
809 }
810
819 class DrupalTemporaryStreamWrapper extends DrupalLocalStreamWrapper {
823 public function getDirectoryPath() {
824 return variable_get('file_temporary_path', file_directory_temp());
825 }
826
830 public function getExternalUrl() {
831 $path = str_replace('\\', '/', $this->getTarget());
832 return url('system/temporary/' . $path, array('absolute' => TRUE));
833 }
834 }
StreamWrapperInterface\rmdir
rmdir($uri, $options)
DrupalLocalStreamWrapper\getUri
getUri()
Definition: stream_wrappers.inc:277
DrupalLocalStreamWrapper\dirname
dirname($uri=NULL)
Definition: stream_wrappers.inc:600
DrupalLocalStreamWrapper\dir_opendir
dir_opendir($uri, $options)
Definition: stream_wrappers.inc:709
DrupalLocalStreamWrapper\getTarget
getTarget($uri=NULL)
Definition: stream_wrappers.inc:297
STREAM_WRAPPERS_READ
const STREAM_WRAPPERS_READ
Definition: stream_wrappers.inc:42
STREAM_WRAPPERS_HIDDEN
const STREAM_WRAPPERS_HIDDEN
Definition: stream_wrappers.inc:62
drupal_unlink
drupal_unlink($uri, $context=NULL)
Definition: file.inc:2225
DrupalLocalStreamWrapper\dir_rewinddir
dir_rewinddir()
Definition: stream_wrappers.inc:736
DrupalLocalStreamWrapper\$handle
$handle
Definition: stream_wrappers.inc:247
StreamWrapperInterface\stream_seek
stream_seek($offset, $whence)
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
DrupalPublicStreamWrapper\getDirectoryPath
getDirectoryPath()
Definition: stream_wrappers.inc:770
DrupalLocalStreamWrapper\rmdir
rmdir($uri, $options)
Definition: stream_wrappers.inc:659
STREAM_WRAPPERS_WRITE
const STREAM_WRAPPERS_WRITE
Definition: stream_wrappers.inc:47
DrupalLocalStreamWrapper\stream_close
stream_close()
Definition: stream_wrappers.inc:548
StreamWrapperInterface
Definition: stream_wrappers.inc:98
DrupalLocalStreamWrapper\dir_closedir
dir_closedir()
Definition: stream_wrappers.inc:752
DrupalStreamWrapperInterface\chmod
chmod($mode)
DrupalStreamWrapperInterface
Definition: stream_wrappers.inc:126
StreamWrapperInterface\stream_tell
stream_tell()
DrupalLocalStreamWrapper\realpath
realpath()
Definition: stream_wrappers.inc:354
StreamWrapperInterface\stream_eof
stream_eof()
file_mimetype_mapping
file_mimetype_mapping()
Definition: file.mimetypes.inc:18
StreamWrapperInterface\dir_closedir
dir_closedir()
StreamWrapperInterface\stream_flush
stream_flush()
DrupalLocalStreamWrapper\chmod
chmod($mode)
Definition: stream_wrappers.inc:343
StreamWrapperInterface\dir_rewinddir
dir_rewinddir()
DrupalStreamWrapperInterface\getMimeType
static getMimeType($uri, $mapping=NULL)
StreamWrapperInterface\stream_read
stream_read($count)
DrupalLocalStreamWrapper
Definition: stream_wrappers.inc:234
DrupalLocalStreamWrapper\stream_stat
stream_stat()
Definition: stream_wrappers.inc:536
DrupalLocalStreamWrapper\$uri
$uri
Definition: stream_wrappers.inc:256
StreamWrapperInterface\url_stat
url_stat($uri, $flags)
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
StreamWrapperInterface\stream_lock
stream_lock($operation)
DrupalPrivateStreamWrapper\getExternalUrl
getExternalUrl()
Definition: stream_wrappers.inc:805
DrupalLocalStreamWrapper\stream_lock
stream_lock($operation)
Definition: stream_wrappers.inc:434
StreamWrapperInterface\stream_open
stream_open($uri, $mode, $options, &$opened_url)
StreamWrapperInterface\dir_readdir
dir_readdir()
DrupalTemporaryStreamWrapper\getExternalUrl
getExternalUrl()
Definition: stream_wrappers.inc:830
STREAM_WRAPPERS_VISIBLE
const STREAM_WRAPPERS_VISIBLE
Definition: stream_wrappers.inc:52
DrupalStreamWrapperInterface\getExternalUrl
getExternalUrl()
drupal_rmdir
drupal_rmdir($uri, $context=NULL)
Definition: file.inc:2389
DrupalLocalStreamWrapper\rename
rename($from_uri, $to_uri)
Definition: stream_wrappers.inc:581
DrupalStreamWrapperInterface\setUri
setUri($uri)
StreamWrapperInterface\stream_close
stream_close()
$output
$output
Definition: authorize.php:93
file_directory_temp
file_directory_temp()
Definition: file.inc:2446
DrupalLocalStreamWrapper\getDirectoryPath
getDirectoryPath()
StreamWrapperInterface\stream_write
stream_write($data)
DrupalLocalStreamWrapper\stream_flush
stream_flush()
Definition: stream_wrappers.inc:511
DrupalTemporaryStreamWrapper\getDirectoryPath
getDirectoryPath()
Definition: stream_wrappers.inc:823
StreamWrapperInterface\rename
rename($from_uri, $to_uri)
DrupalLocalStreamWrapper\dir_readdir
dir_readdir()
Definition: stream_wrappers.inc:724
DrupalLocalStreamWrapper\setUri
setUri($uri)
Definition: stream_wrappers.inc:270
DrupalLocalStreamWrapper\stream_seek
stream_seek($offset, $whence)
Definition: stream_wrappers.inc:497
STREAM_WRAPPERS_WRITE_VISIBLE
const STREAM_WRAPPERS_WRITE_VISIBLE
Definition: stream_wrappers.inc:72
DrupalPublicStreamWrapper
Definition: stream_wrappers.inc:766
conf_path
conf_path($require_settings=TRUE, $reset=FALSE)
Definition: bootstrap.inc:541
DrupalPublicStreamWrapper\getExternalUrl
getExternalUrl()
Definition: stream_wrappers.inc:779
drupal_encode_path
drupal_encode_path($path)
Definition: common.inc:639
StreamWrapperInterface\mkdir
mkdir($uri, $mode, $options)
DrupalLocalStreamWrapper\stream_eof
stream_eof()
Definition: stream_wrappers.inc:480
DrupalLocalStreamWrapper\stream_read
stream_read($count)
Definition: stream_wrappers.inc:453
DrupalStreamWrapperInterface\dirname
dirname($uri=NULL)
DrupalLocalStreamWrapper\stream_tell
stream_tell()
Definition: stream_wrappers.inc:523
DrupalLocalStreamWrapper\unlink
unlink($uri)
Definition: stream_wrappers.inc:563
DrupalLocalStreamWrapper\url_stat
url_stat($uri, $flags)
Definition: stream_wrappers.inc:683
DrupalPrivateStreamWrapper\getDirectoryPath
getDirectoryPath()
Definition: stream_wrappers.inc:796
DrupalTemporaryStreamWrapper
Definition: stream_wrappers.inc:819
DrupalLocalStreamWrapper\mkdir
mkdir($uri, $mode, $options)
Definition: stream_wrappers.inc:627
DrupalStreamWrapperInterface\getUri
getUri()
drupal_basename
drupal_basename($uri, $suffix=NULL)
Definition: file.inc:2317
StreamWrapperInterface\unlink
unlink($uri)
StreamWrapperInterface\stream_stat
stream_stat()
DrupalPrivateStreamWrapper
Definition: stream_wrappers.inc:792
DrupalStreamWrapperInterface\realpath
realpath()
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
STREAM_WRAPPERS_NORMAL
const STREAM_WRAPPERS_NORMAL
Definition: stream_wrappers.inc:86
DrupalLocalStreamWrapper\stream_open
stream_open($uri, $mode, $options, &$opened_path)
Definition: stream_wrappers.inc:406
STREAM_WRAPPERS_LOCAL
const STREAM_WRAPPERS_LOCAL
Definition: stream_wrappers.inc:37
DrupalLocalStreamWrapper\getLocalPath
getLocalPath($uri=NULL)
Definition: stream_wrappers.inc:372
StreamWrapperInterface\dir_opendir
dir_opendir($uri, $options)
DrupalLocalStreamWrapper\stream_write
stream_write($data)
Definition: stream_wrappers.inc:468
DrupalLocalStreamWrapper\$context
$context
Definition: stream_wrappers.inc:240
DrupalLocalStreamWrapper\getMimeType
static getMimeType($uri, $mapping=NULL)
Definition: stream_wrappers.inc:311
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search.admin.inc Source File

  • modules
  • search
search.admin.inc
Go to the documentation of this file.
1 <?php
2
11 function search_reindex_confirm() {
12 return confirm_form(array(), t('Are you sure you want to re-index the site?'),
13 'admin/config/search/settings', t('The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed. This action cannot be undone.'), t('Re-index site'), t('Cancel'));
14 }
15
19 function search_reindex_confirm_submit(&$form, &$form_state) {
20 if ($form['confirm']) {
21 search_reindex();
22 drupal_set_message(t('The index will be rebuilt.'));
23 $form_state['redirect'] = 'admin/config/search/settings';
24 return;
25 }
26 }
27
31 function _search_get_module_names() {
32
33 $search_info = search_get_info(TRUE);
34 $system_info = system_get_info('module');
35 $names = array();
36 foreach ($search_info as $module => $info) {
37 $names[$module] = $system_info[$module]['name'];
38 }
39 asort($names, SORT_STRING);
40 return $names;
41 }
42
52 function search_admin_settings($form) {
53 // Collect some stats
54 $remaining = 0;
55 $total = 0;
56 foreach (variable_get('search_active_modules', array('node', 'user')) as $module) {
57 if ($status = module_invoke($module, 'search_status')) {
58 $remaining += $status['remaining'];
59 $total += $status['total'];
60 }
61 }
62
63 $count = format_plural($remaining, 'There is 1 item left to index.', 'There are @count items left to index.');
64 $percentage = ((int)min(100, 100 * ($total - $remaining) / max(1, $total))) . '%';
65 $status = '<p><strong>' . t('%percentage of the site has been indexed.', array('%percentage' => $percentage)) . ' ' . $count . '</strong></p>';
66 $form['status'] = array('#type' => 'fieldset', '#title' => t('Indexing status'));
67 $form['status']['status'] = array('#markup' => $status);
68 $form['status']['wipe'] = array('#type' => 'submit', '#value' => t('Re-index site'), '#submit' => array('search_admin_reindex_submit'));
69
70 $items = drupal_map_assoc(array(10, 20, 50, 100, 200, 500));
71
72 // Indexing throttle:
73 $form['indexing_throttle'] = array(
74 '#type' => 'fieldset',
75 '#title' => t('Indexing throttle')
76 );
77 $form['indexing_throttle']['search_cron_limit'] = array(
78 '#type' => 'select',
79 '#title' => t('Number of items to index per cron run'),
80 '#default_value' => variable_get('search_cron_limit', 100),
81 '#options' => $items,
82 '#description' => t('The maximum number of items indexed in each pass of a <a href="@cron">cron maintenance task</a>. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status')))
83 );
84 // Indexing settings:
85 $form['indexing_settings'] = array(
86 '#type' => 'fieldset',
87 '#title' => t('Indexing settings')
88 );
89 $form['indexing_settings']['info'] = array(
90 '#markup' => t('<p><em>Changing the settings below will cause the site index to be rebuilt. The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed.</em></p><p><em>The default settings should be appropriate for the majority of sites.</em></p>')
91 );
92 $form['indexing_settings']['minimum_word_size'] = array(
93 '#type' => 'textfield',
94 '#title' => t('Minimum word length to index'),
95 '#default_value' => variable_get('minimum_word_size', 3),
96 '#size' => 5,
97 '#maxlength' => 3,
98 '#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).'),
99 '#element_validate' => array('element_validate_integer_positive'),
100 );
101 $form['indexing_settings']['overlap_cjk'] = array(
102 '#type' => 'checkbox',
103 '#title' => t('Simple CJK handling'),
104 '#default_value' => variable_get('overlap_cjk', TRUE),
105 '#description' => t('Whether to apply a simple Chinese/Japanese/Korean tokenizer based on overlapping sequences. Turn this off if you want to use an external preprocessor for this instead. Does not affect other languages.')
106 );
107
108 $form['active'] = array(
109 '#type' => 'fieldset',
110 '#title' => t('Active search modules')
111 );
112 $module_options = _search_get_module_names();
113 $form['active']['search_active_modules'] = array(
114 '#type' => 'checkboxes',
115 '#title' => t('Active modules'),
116 '#title_display' => 'invisible',
117 '#default_value' => variable_get('search_active_modules', array('node', 'user')),
118 '#options' => $module_options,
119 '#description' => t('Choose which search modules are active from the available modules.')
120 );
121 $form['active']['search_default_module'] = array(
122 '#title' => t('Default search module'),
123 '#type' => 'radios',
124 '#default_value' => variable_get('search_default_module', 'node'),
125 '#options' => $module_options,
126 '#description' => t('Choose which search module is the default.')
127 );
128 $form['#validate'][] = 'search_admin_settings_validate';
129 $form['#submit'][] = 'search_admin_settings_submit';
130
131 // Per module settings
132 foreach (variable_get('search_active_modules', array('node', 'user')) as $module) {
133 $added_form = module_invoke($module, 'search_admin');
134 if (is_array($added_form)) {
135 $form = array_merge($form, $added_form);
136 }
137 }
138
139 return system_settings_form($form);
140 }
141
145 function search_admin_settings_validate($form, &$form_state) {
146 // Check whether we selected a valid default.
147 if ($form_state['triggering_element']['#value'] != t('Reset to defaults')) {
148 $new_modules = array_filter($form_state['values']['search_active_modules']);
149 $default = $form_state['values']['search_default_module'];
150 if (!in_array($default, $new_modules, TRUE)) {
151 form_set_error('search_default_module', t('Your default search module is not selected as an active module.'));
152 }
153 }
154 }
155
159 function search_admin_settings_submit($form, &$form_state) {
160 // If these settings change, the index needs to be rebuilt.
161 if ((variable_get('minimum_word_size', 3) != $form_state['values']['minimum_word_size']) ||
162 (variable_get('overlap_cjk', TRUE) != $form_state['values']['overlap_cjk'])) {
163 drupal_set_message(t('The index will be rebuilt.'));
164 search_reindex();
165 }
166 $current_modules = variable_get('search_active_modules', array('node', 'user'));
167 // Check whether we are resetting the values.
168 if ($form_state['triggering_element']['#value'] == t('Reset to defaults')) {
169 $new_modules = array('node', 'user');
170 }
171 else {
172 $new_modules = array_filter($form_state['values']['search_active_modules']);
173 }
174 if (array_diff($current_modules, $new_modules)) {
175 drupal_set_message(t('The active search modules have been changed.'));
176 variable_set('menu_rebuild_needed', TRUE);
177 }
178 }
179
183 function search_admin_reindex_submit($form, &$form_state) {
184 // send the user to the confirmation page
185 $form_state['redirect'] = 'admin/config/search/settings/reindex';
186 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
search_admin_settings_submit
search_admin_settings_submit($form, &$form_state)
Definition: search.admin.inc:159
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
search_get_info
search_get_info($all=FALSE)
Definition: search.module:252
$module
print $module
Definition: search-results.tpl.php:28
_search_get_module_names
_search_get_module_names()
Definition: search.admin.inc:31
search_admin_settings
search_admin_settings($form)
Definition: search.admin.inc:52
$percentage
print $percentage
Definition: poll-bar--block.tpl.php:22
search_reindex_confirm_submit
search_reindex_confirm_submit(&$form, &$form_state)
Definition: search.admin.inc:19
search_admin_reindex_submit
search_admin_reindex_submit($form, &$form_state)
Definition: search.admin.inc:183
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
search_admin_settings_validate
search_admin_settings_validate($form, &$form_state)
Definition: search.admin.inc:145
system_get_info
system_get_info($type, $name=NULL)
Definition: system.module:2338
$info
$info
Definition: color.inc:6
search_reindex
search_reindex($sid=NULL, $module=NULL, $reindex=FALSE)
Definition: search.module:308
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
system_settings_form
system_settings_form($form)
Definition: system.module:2755
search_reindex_confirm
search_reindex_confirm()
Definition: search.admin.inc:11
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/node.api.php Source File

  • modules
  • node
node.api.php
Go to the documentation of this file.
1 <?php
2
194 function hook_node_grants($account, $op) {
195 if (user_access('access private content', $account)) {
196 $grants['example'] = array(1);
197 }
198 $grants['example_owner'] = array($account->uid);
199 return $grants;
200 }
201
268 function hook_node_access_records($node) {
269 // We only care about the node if it has been marked private. If not, it is
270 // treated just like any other node and we completely ignore it.
271 if ($node->private) {
272 $grants = array();
273 // Only published nodes should be viewable to all users. If we allow access
274 // blindly here, then all users could view an unpublished node.
275 if ($node->status) {
276 $grants[] = array(
277 'realm' => 'example',
278 'gid' => 1,
279 'grant_view' => 1,
280 'grant_update' => 0,
281 'grant_delete' => 0,
282 'priority' => 0,
283 );
284 }
285 // For the example_author array, the GID is equivalent to a UID, which
286 // means there are many groups of just 1 user.
287 // Note that an author can always view his or her nodes, even if they
288 // have status unpublished.
289 $grants[] = array(
290 'realm' => 'example_author',
291 'gid' => $node->uid,
292 'grant_view' => 1,
293 'grant_update' => 1,
294 'grant_delete' => 1,
295 'priority' => 0,
296 );
297
298 return $grants;
299 }
300 }
301
335 function hook_node_access_records_alter(&$grants, $node) {
336 // Our module allows editors to mark specific articles with the 'is_preview'
337 // field. If the node being saved has a TRUE value for that field, then only
338 // our grants are retained, and other grants are removed. Doing so ensures
339 // that our rules are enforced no matter what priority other grants are given.
340 if ($node->is_preview) {
341 // Our module grants are set in $grants['example'].
342 $temp = $grants['example'];
343 // Now remove all module grants but our own.
344 $grants = array('example' => $temp);
345 }
346 }
347
382 function hook_node_grants_alter(&$grants, $account, $op) {
383 // Our sample module never allows certain roles to edit or delete
384 // content. Since some other node access modules might allow this
385 // permission, we expressly remove it by returning an empty $grants
386 // array for roles specified in our variable setting.
387
388 // Get our list of banned roles.
389 $restricted = variable_get('example_restricted_roles', array());
390
391 if ($op != 'view' && !empty($restricted)) {
392 // Now check the roles for this account against the restrictions.
393 foreach ($restricted as $role_id) {
394 if (isset($account->roles[$role_id])) {
395 $grants = array();
396 }
397 }
398 }
399 }
400
419 function hook_node_operations() {
420 $operations = array(
421 'publish' => array(
422 'label' => t('Publish selected content'),
423 'callback' => 'node_mass_update',
424 'callback arguments' => array('updates' => array('status' => NODE_PUBLISHED)),
425 ),
426 'unpublish' => array(
427 'label' => t('Unpublish selected content'),
428 'callback' => 'node_mass_update',
429 'callback arguments' => array('updates' => array('status' => NODE_NOT_PUBLISHED)),
430 ),
431 'promote' => array(
432 'label' => t('Promote selected content to front page'),
433 'callback' => 'node_mass_update',
434 'callback arguments' => array('updates' => array('status' => NODE_PUBLISHED, 'promote' => NODE_PROMOTED)),
435 ),
436 'demote' => array(
437 'label' => t('Demote selected content from front page'),
438 'callback' => 'node_mass_update',
439 'callback arguments' => array('updates' => array('promote' => NODE_NOT_PROMOTED)),
440 ),
441 'sticky' => array(
442 'label' => t('Make selected content sticky'),
443 'callback' => 'node_mass_update',
444 'callback arguments' => array('updates' => array('status' => NODE_PUBLISHED, 'sticky' => NODE_STICKY)),
445 ),
446 'unsticky' => array(
447 'label' => t('Make selected content not sticky'),
448 'callback' => 'node_mass_update',
449 'callback arguments' => array('updates' => array('sticky' => NODE_NOT_STICKY)),
450 ),
451 'delete' => array(
452 'label' => t('Delete selected content'),
453 'callback' => NULL,
454 ),
455 );
456 return $operations;
457 }
458
472 function hook_node_delete($node) {
473 db_delete('mytable')
474 ->condition('nid', $node->nid)
475 ->execute();
476 }
477
490 function hook_node_revision_delete($node) {
491 db_delete('mytable')
492 ->condition('vid', $node->vid)
493 ->execute();
494 }
495
517 function hook_node_insert($node) {
518 db_insert('mytable')
519 ->fields(array(
520 'nid' => $node->nid,
521 'extra' => $node->extra,
522 ))
523 ->execute();
524 }
525
554 function hook_node_load($nodes, $types) {
555 // Decide whether any of $types are relevant to our purposes.
556 if (count(array_intersect($types_we_want_to_process, $types))) {
557 // Gather our extra data for each of these nodes.
558 $result = db_query('SELECT nid, foo FROM {mytable} WHERE nid IN(:nids)', array(':nids' => array_keys($nodes)));
559 // Add our extra data to the node objects.
560 foreach ($result as $record) {
561 $nodes[$record->nid]->foo = $record->foo;
562 }
563 }
564 }
565
605 function hook_node_access($node, $op, $account) {
606 $type = is_string($node) ? $node : $node->type;
607
608 if (in_array($type, node_permissions_get_configured_types())) {
609 if ($op == 'create' && user_access('create ' . $type . ' content', $account)) {
610 return NODE_ACCESS_ALLOW;
611 }
612
613 if ($op == 'update') {
614 if (user_access('edit any ' . $type . ' content', $account) || (user_access('edit own ' . $type . ' content', $account) && ($account->uid == $node->uid))) {
615 return NODE_ACCESS_ALLOW;
616 }
617 }
618
619 if ($op == 'delete') {
620 if (user_access('delete any ' . $type . ' content', $account) || (user_access('delete own ' . $type . ' content', $account) && ($account->uid == $node->uid))) {
621 return NODE_ACCESS_ALLOW;
622 }
623 }
624 }
625
626 // Returning nothing from this function would have the same effect.
627 return NODE_ACCESS_IGNORE;
628 }
629
630
642 function hook_node_prepare($node) {
643 if (!isset($node->comment)) {
644 $node->comment = variable_get("comment_$node->type", COMMENT_NODE_OPEN);
645 }
646 }
647
668 function hook_node_search_result($node) {
669 $comments = db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array('nid' => $node->nid))->fetchField();
670 return array('comment' => format_plural($comments, '1 comment', '@count comments'));
671 }
672
684 function hook_node_presave($node) {
685 if ($node->nid && $node->moderate) {
686 // Reset votes when node is updated:
687 $node->score = 0;
688 $node->users = '';
689 $node->votes = 0;
690 }
691 }
692
714 function hook_node_update($node) {
715 db_update('mytable')
716 ->fields(array('extra' => $node->extra))
717 ->condition('nid', $node->nid)
718 ->execute();
719 }
720
735 function hook_node_update_index($node) {
736 $text = '';
737 $comments = db_query('SELECT subject, comment, format FROM {comment} WHERE nid = :nid AND status = :status', array(':nid' => $node->nid, ':status' => COMMENT_PUBLISHED));
738 foreach ($comments as $comment) {
739 $text .= '<h2>' . check_plain($comment->subject) . '</h2>' . check_markup($comment->comment, $comment->format, '', TRUE);
740 }
741 return $text;
742 }
743
768 function hook_node_validate($node, $form, &$form_state) {
769 if (isset($node->end) && isset($node->start)) {
770 if ($node->start > $node->end) {
771 form_set_error('time', t('An event may not end before it starts.'));
772 }
773 }
774 }
775
796 function hook_node_submit($node, $form, &$form_state) {
797 // Decompose the selected menu parent option into 'menu_name' and 'plid', if
798 // the form used the default parent selection widget.
799 if (!empty($form_state['values']['menu']['parent'])) {
800 list($node->menu['menu_name'], $node->menu['plid']) = explode(':', $form_state['values']['menu']['parent']);
801 }
802 }
803
831 function hook_node_view($node, $view_mode, $langcode) {
832 $node->content['my_additional_field'] = array(
833 '#markup' => $additional_field,
834 '#weight' => 10,
835 '#theme' => 'mymodule_my_additional_field',
836 );
837 }
838
859 function hook_node_view_alter(&$build) {
860 if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
861 // Change its weight.
862 $build['an_additional_field']['#weight'] = -10;
863 }
864
865 // Add a #post_render callback to act on the rendered HTML of the node.
866 $build['#post_render'][] = 'my_module_node_post_render';
867 }
868
914 function hook_node_info() {
915 return array(
916 'blog' => array(
917 'name' => t('Blog entry'),
918 'base' => 'blog',
919 'description' => t('Use for multi-user blogs. Every user gets a personal blog.'),
920 )
921 );
922 }
923
967 function hook_ranking() {
968 // If voting is disabled, we can avoid returning the array, no hard feelings.
969 if (variable_get('vote_node_enabled', TRUE)) {
970 return array(
971 'vote_average' => array(
972 'title' => t('Average vote'),
973 // Note that we use i.sid, the search index's search item id, rather than
974 // n.nid.
975 'join' => 'LEFT JOIN {vote_node_data} vote_node_data ON vote_node_data.nid = i.sid',
976 // The highest possible score should be 1, and the lowest possible score,
977 // always 0, should be 0.
978 'score' => 'vote_node_data.average / CAST(%f AS DECIMAL)',
979 // Pass in the highest possible voting score as a decimal argument.
980 'arguments' => array(variable_get('vote_score_max', 5)),
981 ),
982 );
983 }
984 }
985
986
996 function hook_node_type_insert($info) {
997 drupal_set_message(t('You have just created a content type with a machine name %type.', array('%type' => $info->type)));
998 }
999
1009 function hook_node_type_update($info) {
1010 if (!empty($info->old_type) && $info->old_type != $info->type) {
1011 $setting = variable_get('comment_' . $info->old_type, COMMENT_NODE_OPEN);
1012 variable_del('comment_' . $info->old_type);
1013 variable_set('comment_' . $info->type, $setting);
1014 }
1015 }
1016
1026 function hook_node_type_delete($info) {
1027 variable_del('comment_' . $info->type);
1028 }
1029
1045 function hook_delete($node) {
1046 db_delete('mytable')
1047 ->condition('nid', $node->nid)
1048 ->execute();
1049 }
1050
1065 function hook_prepare($node) {
1066 if ($file = file_check_upload($field_name)) {
1067 $file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE));
1068 if ($file) {
1069 if (!image_get_info($file->uri)) {
1070 form_set_error($field_name, t('Uploaded file is not a valid image'));
1071 return;
1072 }
1073 }
1074 else {
1075 return;
1076 }
1077 $node->images['_original'] = $file->uri;
1078 _image_build_derivatives($node, TRUE);
1079 $node->new_file = TRUE;
1080 }
1081 }
1082
1107 function hook_form($node, &$form_state) {
1108 $type = node_type_get_type($node);
1109
1110 $form['title'] = array(
1111 '#type' => 'textfield',
1112 '#title' => check_plain($type->title_label),
1113 '#default_value' => !empty($node->title) ? $node->title : '',
1114 '#required' => TRUE, '#weight' => -5
1115 );
1116
1117 $form['field1'] = array(
1118 '#type' => 'textfield',
1119 '#title' => t('Custom field'),
1120 '#default_value' => $node->field1,
1121 '#maxlength' => 127,
1122 );
1123 $form['selectbox'] = array(
1124 '#type' => 'select',
1125 '#title' => t('Select box'),
1126 '#default_value' => $node->selectbox,
1127 '#options' => array(
1128 1 => 'Option A',
1129 2 => 'Option B',
1130 3 => 'Option C',
1131 ),
1132 '#description' => t('Choose an option.'),
1133 );
1134
1135 return $form;
1136 }
1137
1153 function hook_insert($node) {
1154 db_insert('mytable')
1155 ->fields(array(
1156 'nid' => $node->nid,
1157 'extra' => $node->extra,
1158 ))
1159 ->execute();
1160 }
1161
1189 function hook_load($nodes) {
1190 $result = db_query('SELECT nid, foo FROM {mytable} WHERE nid IN (:nids)', array(':nids' => array_keys($nodes)));
1191 foreach ($result as $record) {
1192 $nodes[$record->nid]->foo = $record->foo;
1193 }
1194 }
1195
1211 function hook_update($node) {
1212 db_update('mytable')
1213 ->fields(array('extra' => $node->extra))
1214 ->condition('nid', $node->nid)
1215 ->execute();
1216 }
1217
1244 function hook_validate($node, $form, &$form_state) {
1245 if (isset($node->end) && isset($node->start)) {
1246 if ($node->start > $node->end) {
1247 form_set_error('time', t('An event may not end before it starts.'));
1248 }
1249 }
1250 }
1251
1279 function hook_view($node, $view_mode) {
1280 if ($view_mode == 'full' && node_is_page($node)) {
1281 $breadcrumb = array();
1282 $breadcrumb[] = l(t('Home'), NULL);
1283 $breadcrumb[] = l(t('Example'), 'example');
1284 $breadcrumb[] = l($node->field1, 'example/' . $node->field1);
1285 drupal_set_breadcrumb($breadcrumb);
1286 }
1287
1288 $node->content['myfield'] = array(
1289 '#markup' => theme('mymodule_myfield', $node->myfield),
1290 '#weight' => 1,
1291 );
1292
1293 return $node;
1294 }
1295
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
hook_node_type_delete
hook_node_type_delete($info)
Definition: node.api.php:1026
hook_node_revision_delete
hook_node_revision_delete($node)
Definition: node.api.php:490
$op
$op
Definition: update.php:404
hook_node_grants_alter
hook_node_grants_alter(&$grants, $account, $op)
Definition: node.api.php:382
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_set_breadcrumb
drupal_set_breadcrumb($breadcrumb=NULL)
Definition: common.inc:243
NODE_ACCESS_ALLOW
const NODE_ACCESS_ALLOW
Definition: node.module:50
hook_node_update_index
hook_node_update_index($node)
Definition: node.api.php:735
hook_node_insert
hook_node_insert($node)
Definition: node.api.php:517
hook_node_presave
hook_node_presave($node)
Definition: node.api.php:684
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
hook_insert
hook_insert($node)
Definition: node.api.php:1153
node_type_get_type
node_type_get_type($node)
Definition: node.module:410
NODE_PROMOTED
const NODE_PROMOTED
Definition: node.module:27
node_is_page
node_is_page($node)
Definition: node.module:1487
hook_node_view_alter
hook_node_view_alter(&$build)
Definition: node.api.php:859
hook_node_validate
hook_node_validate($node, $form, &$form_state)
Definition: node.api.php:768
hook_load
hook_load($nodes)
Definition: node.api.php:1189
hook_node_prepare
hook_node_prepare($node)
Definition: node.api.php:642
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
NODE_PUBLISHED
const NODE_PUBLISHED
Definition: node.module:17
hook_node_info
hook_node_info()
Definition: node.api.php:914
hook_node_access_records
hook_node_access_records($node)
Definition: node.api.php:268
hook_node_type_update
hook_node_type_update($info)
Definition: node.api.php:1009
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
image_get_info
image_get_info($filepath, $toolkit=FALSE)
Definition: image.inc:124
NODE_NOT_STICKY
const NODE_NOT_STICKY
Definition: node.module:32
$info
$info
Definition: color.inc:6
hook_view
hook_view($node, $view_mode)
Definition: node.api.php:1279
NODE_NOT_PUBLISHED
const NODE_NOT_PUBLISHED
Definition: node.module:12
hook_prepare
hook_prepare($node)
Definition: node.api.php:1065
hook_node_view
hook_node_view($node, $view_mode, $langcode)
Definition: node.api.php:831
hook_node_grants
hook_node_grants($account, $op)
Definition: node.api.php:194
NODE_NOT_PROMOTED
const NODE_NOT_PROMOTED
Definition: node.module:22
hook_validate
hook_validate($node, $form, &$form_state)
Definition: node.api.php:1244
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
hook_node_operations
hook_node_operations()
Definition: node.api.php:419
user_access
user_access($string, $account=NULL)
Definition: user.module:794
file_save_upload
file_save_upload($source, $validators=array(), $destination=FALSE, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1437
hook_update
hook_update($node)
Definition: node.api.php:1211
hook_node_access_records_alter
hook_node_access_records_alter(&$grants, $node)
Definition: node.api.php:335
hook_node_delete
hook_node_delete($node)
Definition: node.api.php:472
hook_node_update
hook_node_update($node)
Definition: node.api.php:714
hook_form
hook_form($node, &$form_state)
Definition: node.api.php:1107
$breadcrumb
print $breadcrumb
Definition: page.tpl.php:40
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
NODE_ACCESS_IGNORE
const NODE_ACCESS_IGNORE
Definition: node.module:60
hook_node_search_result
hook_node_search_result($node)
Definition: node.api.php:668
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
hook_delete
hook_delete($node)
Definition: node.api.php:1045
COMMENT_NODE_OPEN
const COMMENT_NODE_OPEN
Definition: comment.module:70
COMMENT_PUBLISHED
const COMMENT_PUBLISHED
Definition: comment.module:20
hook_ranking
hook_ranking()
Definition: node.api.php:967
check_markup
check_markup($text, $format_id=NULL, $langcode= '', $cache=FALSE)
Definition: filter.module:759
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
NODE_STICKY
const NODE_STICKY
Definition: node.module:37
hook_node_submit
hook_node_submit($node, $form, &$form_state)
Definition: node.api.php:796
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
node_permissions_get_configured_types
node_permissions_get_configured_types()
Definition: node.module:3153
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
hook_node_access
hook_node_access($node, $op, $account)
Definition: node.api.php:605
hook_node_type_insert
hook_node_type_insert($info)
Definition: node.api.php:996
hook_node_load
hook_node_load($nodes, $types)
Definition: node.api.php:554
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/garland/template.php Source File

  • themes
  • garland
template.php
Go to the documentation of this file.
1 <?php
2
6 function garland_breadcrumb($variables) {
7 $breadcrumb = $variables['breadcrumb'];
8
9 if (!empty($breadcrumb)) {
10 // Provide a navigational heading to give context for breadcrumb links to
11 // screen-reader users. Make the heading invisible with .element-invisible.
12 $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
13
14 $output .= '<div class="breadcrumb">' . implode(' › ', $breadcrumb) . '</div>';
15 return $output;
16 }
17 }
18
22 function garland_preprocess_maintenance_page(&$vars) {
23 // While markup for normal pages is split into page.tpl.php and html.tpl.php,
24 // the markup for the maintenance page is all in the single
25 // maintenance-page.tpl.php template. So, to have what's done in
26 // garland_preprocess_html() also happen on the maintenance page, it has to be
27 // called here.
28 garland_preprocess_html($vars);
29 }
30
34 function garland_preprocess_html(&$vars) {
35 // Toggle fixed or fluid width.
36 if (theme_get_setting('garland_width') == 'fluid') {
37 $vars['classes_array'][] = 'fluid-width';
38 }
39 // Add conditional CSS for IE6.
40 drupal_add_css(path_to_theme() . '/fix-ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lt IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
41 }
42
46 function garland_process_html(&$vars) {
47 // Hook into color.module
48 if (module_exists('color')) {
49 _color_html_alter($vars);
50 }
51 }
52
56 function garland_preprocess_page(&$vars) {
57 // Move secondary tabs into a separate variable.
58 $vars['tabs2'] = array(
59 '#theme' => 'menu_local_tasks',
60 '#secondary' => $vars['tabs']['#secondary'],
61 );
62 unset($vars['tabs']['#secondary']);
63
64 if (isset($vars['main_menu'])) {
65 $vars['primary_nav'] = theme('links__system_main_menu', array(
66 'links' => $vars['main_menu'],
67 'attributes' => array(
68 'class' => array('links', 'inline', 'main-menu'),
69 ),
70 'heading' => array(
71 'text' => t('Main menu'),
72 'level' => 'h2',
73 'class' => array('element-invisible'),
74 )
75 ));
76 }
77 else {
78 $vars['primary_nav'] = FALSE;
79 }
80 if (isset($vars['secondary_menu'])) {
81 $vars['secondary_nav'] = theme('links__system_secondary_menu', array(
82 'links' => $vars['secondary_menu'],
83 'attributes' => array(
84 'class' => array('links', 'inline', 'secondary-menu'),
85 ),
86 'heading' => array(
87 'text' => t('Secondary menu'),
88 'level' => 'h2',
89 'class' => array('element-invisible'),
90 )
91 ));
92 }
93 else {
94 $vars['secondary_nav'] = FALSE;
95 }
96
97 // Prepare header.
98 $site_fields = array();
99 if (!empty($vars['site_name'])) {
100 $site_fields[] = $vars['site_name'];
101 }
102 if (!empty($vars['site_slogan'])) {
103 $site_fields[] = $vars['site_slogan'];
104 }
105 $vars['site_title'] = implode(' ', $site_fields);
106 if (!empty($site_fields)) {
107 $site_fields[0] = '<span>' . $site_fields[0] . '</span>';
108 }
109 $vars['site_html'] = implode(' ', $site_fields);
110
111 // Set a variable for the site name title and logo alt attributes text.
112 $slogan_text = $vars['site_slogan'];
113 $site_name_text = $vars['site_name'];
114 $vars['site_name_and_slogan'] = $site_name_text . ' ' . $slogan_text;
115 }
116
120 function garland_preprocess_node(&$vars) {
121 $vars['submitted'] = $vars['date'] . ' — ' . $vars['name'];
122 }
123
127 function garland_preprocess_comment(&$vars) {
128 $vars['submitted'] = $vars['created'] . ' — ' . $vars['author'];
129 }
130
134 function garland_preprocess_block(&$vars) {
135 $vars['title_attributes_array']['class'][] = 'title';
136 $vars['classes_array'][] = 'clearfix';
137 }
138
142 function garland_process_page(&$vars) {
143 // Hook into color.module
144 if (module_exists('color')) {
145 _color_page_alter($vars);
146 }
147 }
148
152 function garland_preprocess_region(&$vars) {
153 if ($vars['region'] == 'header') {
154 $vars['classes_array'][] = 'clearfix';
155 }
156 }
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
garland_preprocess_page
garland_preprocess_page(&$vars)
Definition: template.php:56
path_to_theme
path_to_theme()
Definition: theme.inc:1219
module_exists
module_exists($module)
Definition: module.inc:274
garland_preprocess_node
garland_preprocess_node(&$vars)
Definition: template.php:120
garland_process_html
garland_process_html(&$vars)
Definition: template.php:46
garland_breadcrumb
garland_breadcrumb($variables)
Definition: template.php:6
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
CSS_THEME
const CSS_THEME
Definition: common.inc:70
garland_process_page
garland_process_page(&$vars)
Definition: template.php:142
garland_preprocess_maintenance_page
garland_preprocess_maintenance_page(&$vars)
Definition: template.php:22
$output
$output
Definition: authorize.php:93
$site_fields
$site_fields
Definition: maintenance-page.tpl.php:35
garland_preprocess_region
garland_preprocess_region(&$vars)
Definition: template.php:152
theme_get_setting
theme_get_setting($setting_name, $theme=NULL)
Definition: theme.inc:1401
$breadcrumb
print $breadcrumb
Definition: page.tpl.php:40
_color_page_alter
_color_page_alter(&$vars)
Definition: color.module:120
garland_preprocess_block
garland_preprocess_block(&$vars)
Definition: template.php:134
garland_preprocess_comment
garland_preprocess_comment(&$vars)
Definition: template.php:127
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
garland_preprocess_html
garland_preprocess_html(&$vars)
Definition: template.php:34
_color_html_alter
_color_html_alter(&$vars)
Definition: color.module:85
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/color/color.module Source File

  • modules
  • color
color.module
Go to the documentation of this file.
1 <?php
10 function color_help($path, $arg) {
11 switch ($path) {
12 case 'admin/help#color':
13 $output = '<h3>' . t('About') . '</h3>';
14 $output .= '<p>' . t('The Color module allows users with the <em>Administer site configuration</em> permission to quickly and easily change the color scheme of themes that have been built to be compatible with it. For more information, see the online handbook entry for <a href="@color">Color module</a>.', array('@color' => 'http://drupal.org/documentation/modules/color')) . '</p>';
15 $output .= '<h3>' . t('Uses') . '</h3>';
16 $output .= '<dl>';
17 $output .= '<dt>' . t('Changing colors') . '</dt>';
18 $output .= '<dd>' . t("Using the Color module allows you to easily change the color of links, backgrounds, text, and other theme elements. To change the color settings for a compatible theme, select the <em>Settings</em> link for your theme on the <a href='@configure'>Themes administration page</a>. If you don't see a color picker on that page, then your theme is not compatible with the color module. If you are sure that the theme does indeed support the color module, but the color picker does not appear, then <a href='@troubleshoot'>follow these troubleshooting procedures</a>.", array('@configure' => url('admin/appearance'), '@troubleshoot' => 'http://drupal.org/node/109457')) . '</dd>';
19 $output .= '<dd>' . t("The Color module saves a modified copy of the theme's specified stylesheets in the files directory. This means that if you make any manual changes to your theme's stylesheet, <em>you must save your color settings again, even if they haven't changed</em>. This step is required because the module stylesheets (in the files directory) need to be recreated to include your changes.") . '</dd>';
20 $output .= '</dl>';
21 return $output;
22 }
23 }
24
28 function color_theme() {
29 return array(
30 'color_scheme_form' => array(
31 'render element' => 'form',
32 ),
33 );
34 }
35
39 function color_form_system_theme_settings_alter(&$form, &$form_state) {
40 if (isset($form_state['build_info']['args'][0]) && ($theme = $form_state['build_info']['args'][0]) && color_get_info($theme) && function_exists('gd_info')) {
41 $form['color'] = array(
42 '#type' => 'fieldset',
43 '#title' => t('Color scheme'),
44 '#weight' => -1,
45 '#attributes' => array('id' => 'color_scheme_form'),
46 '#theme' => 'color_scheme_form',
47 );
48 $form['color'] += color_scheme_form($form, $form_state, $theme);
49 $form['#validate'][] = 'color_scheme_form_validate';
50 $form['#submit'][] = 'color_scheme_form_submit';
51 }
52 }
53
57 function color_form_system_themes_alter(&$form, &$form_state) {
58 _color_theme_select_form_alter($form, $form_state);
59 }
60
64 function _color_theme_select_form_alter(&$form, &$form_state) {
65 // Use the generated screenshot in the theme list.
66 $themes = list_themes();
67 foreach (element_children($form) as $theme) {
68 if ($screenshot = variable_get('color_' . $theme . '_screenshot')) {
69 if (isset($form[$theme]['screenshot'])) {
70 $form[$theme]['screenshot']['#markup'] = theme('image', array('path' => $screenshot, 'title' => '', 'attributes' => array('class' => array('screenshot'))));
71 }
72 }
73 }
74 }
75
85 function _color_html_alter(&$vars) {
86 global $theme_key;
87 $themes = list_themes();
88
89 // Override stylesheets.
90 $color_paths = variable_get('color_' . $theme_key . '_stylesheets', array());
91 if (!empty($color_paths)) {
92
93 foreach ($themes[$theme_key]->stylesheets['all'] as $base_filename => $old_path) {
94 // Loop over the path array with recolored CSS files to find matching
95 // paths which could replace the non-recolored paths.
96 foreach ($color_paths as $color_path) {
97 // Color module currently requires unique file names to be used,
98 // which allows us to compare different file paths.
99 if (drupal_basename($old_path) == drupal_basename($color_path)) {
100 // Replace the path to the new css file.
101 // This keeps the order of the stylesheets intact.
102 $vars['css'][$old_path]['data'] = $color_path;
103 }
104 }
105 }
106
107 $vars['styles'] = drupal_get_css($vars['css']);
108 }
109 }
110
120 function _color_page_alter(&$vars) {
121 global $theme_key;
122
123 // Override logo.
124 $logo = variable_get('color_' . $theme_key . '_logo');
125 if ($logo && $vars['logo'] && preg_match('!' . $theme_key . '/logo.png$!', $vars['logo'])) {
126 $vars['logo'] = file_create_url($logo);
127 }
128 }
129
133 function color_get_info($theme) {
134 static $theme_info = array();
135
136 if (isset($theme_info[$theme])) {
137 return $theme_info[$theme];
138 }
139
140 $path = drupal_get_path('theme', $theme);
141 $file = DRUPAL_ROOT . '/' . $path . '/color/color.inc';
142 if ($path && file_exists($file)) {
143 include $file;
144 $theme_info[$theme] = $info;
145 return $info;
146 }
147 }
148
152 function color_get_palette($theme, $default = FALSE) {
153 // Fetch and expand default palette.
154 $info = color_get_info($theme);
155 $palette = $info['schemes']['default']['colors'];
156
157 // Load variable.
158 return $default ? $palette : variable_get('color_' . $theme . '_palette', $palette);
159 }
160
171 function color_scheme_form($complete_form, &$form_state, $theme) {
172 $base = drupal_get_path('module', 'color');
173 $info = color_get_info($theme);
174
175 $info['schemes'][''] = array('title' => t('Custom'), 'colors' => array());
176 $color_sets = array();
177 $schemes = array();
178 foreach ($info['schemes'] as $key => $scheme) {
179 $color_sets[$key] = $scheme['title'];
180 $schemes[$key] = $scheme['colors'];
181 $schemes[$key] += $info['schemes']['default']['colors'];
182 }
183
184 // See if we're using a predefined scheme.
185 // Note: we use the original theme when the default scheme is chosen.
186 $current_scheme = variable_get('color_' . $theme . '_palette', array());
187 foreach ($schemes as $key => $scheme) {
188 if ($current_scheme == $scheme) {
189 $scheme_name = $key;
190 break;
191 }
192 }
193 if (empty($scheme_name)) {
194 if (empty($current_scheme)) {
195 $scheme_name = 'default';
196 }
197 else {
198 $scheme_name = '';
199 }
200 }
201
202 // Add scheme selector.
203 $form['scheme'] = array(
204 '#type' => 'select',
205 '#title' => t('Color set'),
206 '#options' => $color_sets,
207 '#default_value' => $scheme_name,
208 '#attached' => array(
209 // Add Farbtastic color picker.
210 'library' => array(
211 array('system', 'farbtastic'),
212 ),
213 // Add custom CSS.
214 'css' => array(
215 $base . '/color.css' => array(),
216 ),
217 // Add custom JavaScript.
218 'js' => array(
219 $base . '/color.js',
220 array(
221 'data' => array(
222 'color' => array(
223 'reference' => color_get_palette($theme, TRUE),
224 'schemes' => $schemes,
225 ),
226 'gradients' => $info['gradients'],
227 ),
228 'type' => 'setting',
229 ),
230 ),
231 ),
232 );
233
234 // Add palette fields.
235 $palette = color_get_palette($theme);
236 $names = $info['fields'];
237 $form['palette']['#tree'] = TRUE;
238 foreach ($palette as $name => $value) {
239 if (isset($names[$name])) {
240 $form['palette'][$name] = array(
241 '#type' => 'textfield',
242 '#title' => check_plain($names[$name]),
243 '#value_callback' => 'color_palette_color_value',
244 '#default_value' => $value,
245 '#size' => 8,
246 );
247 }
248 }
249 $form['theme'] = array('#type' => 'value', '#value' => $theme);
250 $form['info'] = array('#type' => 'value', '#value' => $info);
251
252 return $form;
253 }
254
264 function theme_color_scheme_form($variables) {
265 $form = $variables['form'];
266
267 $theme = $form['theme']['#value'];
268 $info = $form['info']['#value'];
269 $path = drupal_get_path('theme', $theme) . '/';
270 drupal_add_css($path . $info['preview_css']);
271
272 $preview_js_path = isset($info['preview_js']) ? $path . $info['preview_js'] : drupal_get_path('module', 'color') . '/' . 'preview.js';
273 // Add the JS at a weight below color.js.
274 drupal_add_js($preview_js_path, array('weight' => -1));
275
276 $output = '';
277 $output .= '<div class="color-form clearfix">';
278 // Color schemes
279 $output .= drupal_render($form['scheme']);
280 // Palette
281 $output .= '<div id="palette" class="clearfix">';
282 foreach (element_children($form['palette']) as $name) {
283 $output .= drupal_render($form['palette'][$name]);
284 }
285 $output .= '</div>';
286 // Preview
287 $output .= drupal_render_children($form);
288 $output .= '<h2>' . t('Preview') . '</h2>';
289 // Attempt to load preview HTML if the theme provides it.
290 $preview_html_path = DRUPAL_ROOT . '/' . (isset($info['preview_html']) ? drupal_get_path('theme', $theme) . '/' . $info['preview_html'] : drupal_get_path('module', 'color') . '/preview.html');
291 $output .= file_get_contents($preview_html_path);
292 // Close the wrapper div.
293 $output .= '</div>';
294
295 return $output;
296 }
297
313 function color_palette_color_value($element, $input = FALSE, $form_state = array()) {
314 // If we suspect a possible cross-site request forgery attack, only accept
315 // hexadecimal CSS color strings from user input, to avoid problems when this
316 // value is used in the JavaScript preview.
317 if ($input !== FALSE) {
318 // Start with the provided value for this textfield, and validate that if
319 // necessary, falling back on the default value.
320 $value = form_type_textfield_value($element, $input, $form_state);
321 if (!$value || !isset($form_state['complete form']['#token']) || color_valid_hexadecimal_string($value) || drupal_valid_token($form_state['values']['form_token'], $form_state['complete form']['#token'])) {
322 return $value;
323 }
324 else {
325 return $element['#default_value'];
326 }
327 }
328 }
329
340 function color_valid_hexadecimal_string($color) {
341 return preg_match('/^#([a-f0-9]{3}){1,2}$/iD', $color);
342 }
343
349 function color_scheme_form_validate($form, &$form_state) {
350 // Only accept hexadecimal CSS color strings to avoid XSS upon use.
351 foreach ($form_state['values']['palette'] as $key => $color) {
352 if (!color_valid_hexadecimal_string($color)) {
353 form_set_error('palette][' . $key, t('%name must be a valid hexadecimal CSS color value.', array('%name' => $form['color']['palette'][$key]['#title'])));
354 }
355 }
356 }
357
363 function color_scheme_form_submit($form, &$form_state) {
364 // Get theme coloring info.
365 if (!isset($form_state['values']['info'])) {
366 return;
367 }
368 $theme = $form_state['values']['theme'];
369 $info = $form_state['values']['info'];
370
371 // Resolve palette.
372 $palette = $form_state['values']['palette'];
373 if ($form_state['values']['scheme'] != '') {
374 foreach ($palette as $key => $color) {
375 if (isset($info['schemes'][$form_state['values']['scheme']]['colors'][$key])) {
376 $palette[$key] = $info['schemes'][$form_state['values']['scheme']]['colors'][$key];
377 }
378 }
379 $palette += $info['schemes']['default']['colors'];
380 }
381
382 // Make sure enough memory is available, if PHP's memory limit is compiled in.
383 if (function_exists('memory_get_usage')) {
384 // Fetch source image dimensions.
385 $source = drupal_get_path('theme', $theme) . '/' . $info['base_image'];
386 list($width, $height) = getimagesize($source);
387
388 // We need at least a copy of the source and a target buffer of the same
389 // size (both at 32bpp).
390 $required = $width * $height * 8;
391 // We intend to prevent color scheme changes if there isn't enough memory
392 // available. memory_get_usage(TRUE) returns a more accurate number than
393 // memory_get_usage(), therefore we won't inadvertently reject a color
394 // scheme change based on a faulty memory calculation.
395 $usage = memory_get_usage(TRUE);
396 $memory_limit = ini_get('memory_limit');
397 $size = parse_size($memory_limit);
398 if (!drupal_check_memory_limit($usage + $required, $memory_limit)) {
399 drupal_set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the <a href="@url">PHP documentation</a> for more information.', array('%size' => format_size($usage + $required - $size), '@url' => 'http://www.php.net/manual/ini.core.php#ini.sect.resource-limits')), 'error');
400 return;
401 }
402 }
403
404 // Delete old files.
405 foreach (variable_get('color_' . $theme . '_files', array()) as $file) {
406 @drupal_unlink($file);
407 }
408 if (isset($file) && $file = dirname($file)) {
409 @drupal_rmdir($file);
410 }
411
412 // Don't render the default colorscheme, use the standard theme instead.
413 if (implode(',', color_get_palette($theme, TRUE)) == implode(',', $palette)) {
414 variable_del('color_' . $theme . '_palette');
415 variable_del('color_' . $theme . '_stylesheets');
416 variable_del('color_' . $theme . '_logo');
417 variable_del('color_' . $theme . '_files');
418 variable_del('color_' . $theme . '_screenshot');
419 return;
420 }
421
422 // Prepare target locations for generated files.
423 $id = $theme . '-' . substr(hash('sha256', serialize($palette) . microtime()), 0, 8);
424 $paths['color'] = 'public://color';
425 $paths['target'] = $paths['color'] . '/' . $id;
426 foreach ($paths as $path) {
427 file_prepare_directory($path, FILE_CREATE_DIRECTORY);
428 }
429 $paths['target'] = $paths['target'] . '/';
430 $paths['id'] = $id;
431 $paths['source'] = drupal_get_path('theme', $theme) . '/';
432 $paths['files'] = $paths['map'] = array();
433
434 // Save palette and logo location.
435 variable_set('color_' . $theme . '_palette', $palette);
436 variable_set('color_' . $theme . '_logo', $paths['target'] . 'logo.png');
437
438 // Copy over neutral images.
439 foreach ($info['copy'] as $file) {
440 $base = drupal_basename($file);
441 $source = $paths['source'] . $file;
442 $filepath = file_unmanaged_copy($source, $paths['target'] . $base);
443 $paths['map'][$file] = $base;
444 $paths['files'][] = $filepath;
445 }
446
447 // Render new images, if image has been provided.
448 if ($info['base_image']) {
449 _color_render_images($theme, $info, $paths, $palette);
450 }
451
452 // Rewrite theme stylesheets.
453 $css = array();
454 foreach ($info['css'] as $stylesheet) {
455 // Build a temporary array with LTR and RTL files.
456 $files = array();
457 if (file_exists($paths['source'] . $stylesheet)) {
458 $files[] = $stylesheet;
459
460 $rtl_file = str_replace('.css', '-rtl.css', $stylesheet);
461 if (file_exists($paths['source'] . $rtl_file)) {
462 $files[] = $rtl_file;
463 }
464 }
465
466 foreach ($files as $file) {
467 // Aggregate @imports recursively for each configured top level CSS file
468 // without optimization. Aggregation and optimization will be
469 // handled by drupal_build_css_cache() only.
470 $style = drupal_load_stylesheet($paths['source'] . $file, FALSE);
471
472 // Return the path to where this CSS file originated from, stripping
473 // off the name of the file at the end of the path.
474 $base = base_path() . dirname($paths['source'] . $file) . '/';
475 _drupal_build_css_path(NULL, $base);
476
477 // Prefix all paths within this CSS file, ignoring absolute paths.
478 $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', '_drupal_build_css_path', $style);
479
480 // Rewrite stylesheet with new colors.
481 $style = _color_rewrite_stylesheet($theme, $info, $paths, $palette, $style);
482 $base_file = drupal_basename($file);
483 $css[] = $paths['target'] . $base_file;
484 _color_save_stylesheet($paths['target'] . $base_file, $style, $paths);
485 }
486 }
487
488 // Maintain list of files.
489 variable_set('color_' . $theme . '_stylesheets', $css);
490 variable_set('color_' . $theme . '_files', $paths['files']);
491 }
492
496 function _color_rewrite_stylesheet($theme, &$info, &$paths, $palette, $style) {
497 $themes = list_themes();
498 // Prepare color conversion table.
499 $conversion = $palette;
500 foreach ($conversion as $k => $v) {
501 $conversion[$k] = drupal_strtolower($v);
502 }
503 $default = color_get_palette($theme, TRUE);
504
505 // Split off the "Don't touch" section of the stylesheet.
506 $split = "Color Module: Don't touch";
507 if (strpos($style, $split) !== FALSE) {
508 list($style, $fixed) = explode($split, $style);
509 }
510
511 // Find all colors in the stylesheet and the chunks in between.
512 $style = preg_split('/(#[0-9a-f]{6}|#[0-9a-f]{3})/i', $style, -1, PREG_SPLIT_DELIM_CAPTURE);
513 $is_color = FALSE;
514 $output = '';
515 $base = 'base';
516
517 // Iterate over all the parts.
518 foreach ($style as $chunk) {
519 if ($is_color) {
520 $chunk = drupal_strtolower($chunk);
521 // Check if this is one of the colors in the default palette.
522 if ($key = array_search($chunk, $default)) {
523 $chunk = $conversion[$key];
524 }
525 // Not a pre-set color. Extrapolate from the base.
526 else {
527 $chunk = _color_shift($palette[$base], $default[$base], $chunk, $info['blend_target']);
528 }
529 }
530 else {
531 // Determine the most suitable base color for the next color.
532
533 // 'a' declarations. Use link.
534 if (preg_match('@[^a-z0-9_-](a)[^a-z0-9_-][^/{]*{[^{]+$@i', $chunk)) {
535 $base = 'link';
536 }
537 // 'color:' styles. Use text.
538 elseif (preg_match('/(?<!-)color[^{:]*:[^{#]*$/i', $chunk)) {
539 $base = 'text';
540 }
541 // Reset back to base.
542 else {
543 $base = 'base';
544 }
545 }
546 $output .= $chunk;
547 $is_color = !$is_color;
548 }
549 // Append fixed colors segment.
550 if (isset($fixed)) {
551 $output .= $fixed;
552 }
553
554 // Replace paths to images.
555 foreach ($paths['map'] as $before => $after) {
556 $before = base_path() . $paths['source'] . $before;
557 $before = preg_replace('`(^|/)(?!../)([^/]+)/../`', '$1', $before);
558 $output = str_replace($before, $after, $output);
559 }
560
561 return $output;
562 }
563
567 function _color_save_stylesheet($file, $style, &$paths) {
568 $filepath = file_unmanaged_save_data($style, $file, FILE_EXISTS_REPLACE);
569 $paths['files'][] = $filepath;
570
571 // Set standard file permissions for webserver-generated files.
572 drupal_chmod($file);
573 }
574
578 function _color_render_images($theme, &$info, &$paths, $palette) {
579 // Prepare template image.
580 $source = $paths['source'] . '/' . $info['base_image'];
581 $source = imagecreatefrompng($source);
582 $width = imagesx($source);
583 $height = imagesy($source);
584
585 // Prepare target buffer.
586 $target = imagecreatetruecolor($width, $height);
587 imagealphablending($target, TRUE);
588
589 // Fill regions of solid color.
590 foreach ($info['fill'] as $color => $fill) {
591 imagefilledrectangle($target, $fill[0], $fill[1], $fill[0] + $fill[2], $fill[1] + $fill[3], _color_gd($target, $palette[$color]));
592 }
593
594 // Render gradients.
595 foreach ($info['gradients'] as $gradient) {
596 // Get direction of the gradient.
597 if (isset($gradient['direction']) && $gradient['direction'] == 'horizontal') {
598 // Horizontal gradient.
599 for ($x = 0; $x < $gradient['dimension'][2]; $x++) {
600 $color = _color_blend($target, $palette[$gradient['colors'][0]], $palette[$gradient['colors'][1]], $x / ($gradient['dimension'][2] - 1));
601 imagefilledrectangle($target, ($gradient['dimension'][0] + $x), $gradient['dimension'][1], ($gradient['dimension'][0] + $x + 1), ($gradient['dimension'][1] + $gradient['dimension'][3]), $color);
602 }
603 }
604 else {
605 // Vertical gradient.
606 for ($y = 0; $y < $gradient['dimension'][3]; $y++) {
607 $color = _color_blend($target, $palette[$gradient['colors'][0]], $palette[$gradient['colors'][1]], $y / ($gradient['dimension'][3] - 1));
608 imagefilledrectangle($target, $gradient['dimension'][0], $gradient['dimension'][1] + $y, $gradient['dimension'][0] + $gradient['dimension'][2], $gradient['dimension'][1] + $y + 1, $color);
609 }
610 }
611 }
612
613 // Blend over template.
614 imagecopy($target, $source, 0, 0, 0, 0, $width, $height);
615
616 // Clean up template image.
617 imagedestroy($source);
618
619 // Cut out slices.
620 foreach ($info['slices'] as $file => $coord) {
621 list($x, $y, $width, $height) = $coord;
622 $base = drupal_basename($file);
623 $image = drupal_realpath($paths['target'] . $base);
624
625 // Cut out slice.
626 if ($file == 'screenshot.png') {
627 $slice = imagecreatetruecolor(150, 90);
628 imagecopyresampled($slice, $target, 0, 0, $x, $y, 150, 90, $width, $height);
629 variable_set('color_' . $theme . '_screenshot', $image);
630 }
631 else {
632 $slice = imagecreatetruecolor($width, $height);
633 imagecopy($slice, $target, 0, 0, $x, $y, $width, $height);
634 }
635
636 // Save image.
637 imagepng($slice, $image);
638 imagedestroy($slice);
639 $paths['files'][] = $image;
640
641 // Set standard file permissions for webserver-generated files
642 drupal_chmod($image);
643
644 // Build before/after map of image paths.
645 $paths['map'][$file] = $base;
646 }
647
648 // Clean up target buffer.
649 imagedestroy($target);
650 }
651
664 function _color_shift($given, $ref1, $ref2, $target) {
665 // We assume that ref2 is a blend of ref1 and target and find
666 // delta based on the length of the difference vectors.
667
668 // delta = 1 - |ref2 - ref1| / |white - ref1|
669 $target = _color_unpack($target, TRUE);
670 $ref1 = _color_unpack($ref1, TRUE);
671 $ref2 = _color_unpack($ref2, TRUE);
672 $numerator = 0;
673 $denominator = 0;
674 for ($i = 0; $i < 3; ++$i) {
675 $numerator += ($ref2[$i] - $ref1[$i]) * ($ref2[$i] - $ref1[$i]);
676 $denominator += ($target[$i] - $ref1[$i]) * ($target[$i] - $ref1[$i]);
677 }
678 $delta = ($denominator > 0) ? (1 - sqrt($numerator / $denominator)) : 0;
679
680 // Calculate the color that ref2 would be if the assumption was true.
681 for ($i = 0; $i < 3; ++$i) {
682 $ref3[$i] = $target[$i] + ($ref1[$i] - $target[$i]) * $delta;
683 }
684
685 // If the assumption is not true, there is a difference between ref2 and ref3.
686 // We measure this in HSL space. Notation: x' = hsl(x).
687 $ref2 = _color_rgb2hsl($ref2);
688 $ref3 = _color_rgb2hsl($ref3);
689 for ($i = 0; $i < 3; ++$i) {
690 $shift[$i] = $ref2[$i] - $ref3[$i];
691 }
692
693 // Take the given color, and blend it towards the target.
694 $given = _color_unpack($given, TRUE);
695 for ($i = 0; $i < 3; ++$i) {
696 $result[$i] = $target[$i] + ($given[$i] - $target[$i]) * $delta;
697 }
698
699 // Finally, we apply the extra shift in HSL space.
700 // Note: if ref2 is a pure blend of ref1 and target, then |shift| = 0.
701 $result = _color_rgb2hsl($result);
702 for ($i = 0; $i < 3; ++$i) {
703 $result[$i] = min(1, max(0, $result[$i] + $shift[$i]));
704 }
705 $result = _color_hsl2rgb($result);
706
707 // Return hex color.
708 return _color_pack($result, TRUE);
709 }
710
714 function _color_gd($img, $hex) {
715 $c = array_merge(array($img), _color_unpack($hex));
716 return call_user_func_array('imagecolorallocate', $c);
717 }
718
722 function _color_blend($img, $hex1, $hex2, $alpha) {
723 $in1 = _color_unpack($hex1);
724 $in2 = _color_unpack($hex2);
725 $out = array($img);
726 for ($i = 0; $i < 3; ++$i) {
727 $out[] = $in1[$i] + ($in2[$i] - $in1[$i]) * $alpha;
728 }
729
730 return call_user_func_array('imagecolorallocate', $out);
731 }
732
736 function _color_unpack($hex, $normalize = FALSE) {
737 if (strlen($hex) == 4) {
738 $hex = $hex[1] . $hex[1] . $hex[2] . $hex[2] . $hex[3] . $hex[3];
739 }
740 $c = hexdec($hex);
741 for ($i = 16; $i >= 0; $i -= 8) {
742 $out[] = (($c >> $i) & 0xFF) / ($normalize ? 255 : 1);
743 }
744
745 return $out;
746 }
747
751 function _color_pack($rgb, $normalize = FALSE) {
752 $out = 0;
753 foreach ($rgb as $k => $v) {
754 $out |= (($v * ($normalize ? 255 : 1)) << (16 - $k * 8));
755 }
756
757 return '#' . str_pad(dechex($out), 6, 0, STR_PAD_LEFT);
758 }
759
763 function _color_hsl2rgb($hsl) {
764 $h = $hsl[0];
765 $s = $hsl[1];
766 $l = $hsl[2];
767 $m2 = ($l <= 0.5) ? $l * ($s + 1) : $l + $s - $l*$s;
768 $m1 = $l * 2 - $m2;
769
770 return array(
771 _color_hue2rgb($m1, $m2, $h + 0.33333),
772 _color_hue2rgb($m1, $m2, $h),
773 _color_hue2rgb($m1, $m2, $h - 0.33333),
774 );
775 }
776
780 function _color_hue2rgb($m1, $m2, $h) {
781 $h = ($h < 0) ? $h + 1 : (($h > 1) ? $h - 1 : $h);
782 if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6;
783 if ($h * 2 < 1) return $m2;
784 if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (0.66666 - $h) * 6;
785
786 return $m1;
787 }
788
792 function _color_rgb2hsl($rgb) {
793 $r = $rgb[0];
794 $g = $rgb[1];
795 $b = $rgb[2];
796 $min = min($r, min($g, $b));
797 $max = max($r, max($g, $b));
798 $delta = $max - $min;
799 $l = ($min + $max) / 2;
800 $s = 0;
801
802 if ($l > 0 && $l < 1) {
803 $s = $delta / ($l < 0.5 ? (2 * $l) : (2 - 2 * $l));
804 }
805
806 $h = 0;
807 if ($delta > 0) {
808 if ($max == $r && $max != $g) $h += ($g - $b) / $delta;
809 if ($max == $g && $max != $b) $h += (2 + ($b - $r) / $delta);
810 if ($max == $b && $max != $r) $h += (4 + ($r - $g) / $delta);
811 $h /= 6;
812 }
813
814 return array($h, $s, $l);
815 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
color_scheme_form_validate
color_scheme_form_validate($form, &$form_state)
Definition: color.module:349
_color_shift
_color_shift($given, $ref1, $ref2, $target)
Definition: color.module:664
color_get_info
color_get_info($theme)
Definition: color.module:133
color_theme
color_theme()
Definition: color.module:28
_color_gd
_color_gd($img, $hex)
Definition: color.module:714
drupal_check_memory_limit
drupal_check_memory_limit($required, $memory_limit=NULL)
Definition: bootstrap.inc:3477
color_get_palette
color_get_palette($theme, $default=FALSE)
Definition: color.module:152
FILE_CREATE_DIRECTORY
const FILE_CREATE_DIRECTORY
Definition: file.inc:41
_color_unpack
_color_unpack($hex, $normalize=FALSE)
Definition: color.module:736
drupal_strtolower
drupal_strtolower($text)
Definition: unicode.inc:521
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
drupal_load_stylesheet
drupal_load_stylesheet($file, $optimize=NULL, $reset_basepath=TRUE)
Definition: common.inc:3659
drupal_get_css
drupal_get_css($css=NULL, $skip_alter=FALSE)
Definition: common.inc:3052
drupal_unlink
drupal_unlink($uri, $context=NULL)
Definition: file.inc:2225
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
file_create_url
file_create_url($uri)
Definition: file.inc:372
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
variable_del
variable_del($name)
Definition: bootstrap.inc:996
$name
print $name
Definition: profile-listing.tpl.php:43
form_type_textfield_value
form_type_textfield_value($element, $input=FALSE)
Definition: form.inc:2475
color_palette_color_value
color_palette_color_value($element, $input=FALSE, $form_state=array())
Definition: color.module:313
drupal_realpath
drupal_realpath($uri)
Definition: file.inc:2259
color_form_system_themes_alter
color_form_system_themes_alter(&$form, &$form_state)
Definition: color.module:57
color_help
color_help($path, $arg)
Definition: color.module:10
$logo
print $logo
Definition: maintenance-page.tpl.php:33
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
_color_theme_select_form_alter
_color_theme_select_form_alter(&$form, &$form_state)
Definition: color.module:64
drupal_valid_token
drupal_valid_token($token, $value= '', $skip_anonymous=FALSE)
Definition: common.inc:5095
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
file_unmanaged_copy
file_unmanaged_copy($source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:884
color_scheme_form_submit
color_scheme_form_submit($form, &$form_state)
Definition: color.module:363
$info
$info
Definition: color.inc:6
FILE_EXISTS_REPLACE
const FILE_EXISTS_REPLACE
Definition: file.inc:56
drupal_rmdir
drupal_rmdir($uri, $context=NULL)
Definition: file.inc:2389
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
_color_hue2rgb
_color_hue2rgb($m1, $m2, $h)
Definition: color.module:780
$output
$output
Definition: authorize.php:93
_color_save_stylesheet
_color_save_stylesheet($file, $style, &$paths)
Definition: color.module:567
_drupal_build_css_path
_drupal_build_css_path($matches, $base=NULL)
Definition: common.inc:3621
parse_size
parse_size($size)
Definition: common.inc:1842
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
file_unmanaged_save_data
file_unmanaged_save_data($data, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1932
drupal_chmod
drupal_chmod($uri, $mode=NULL)
Definition: file.inc:2180
_color_render_images
_color_render_images($theme, &$info, &$paths, $palette)
Definition: color.module:578
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
color_valid_hexadecimal_string
color_valid_hexadecimal_string($color)
Definition: color.module:340
_color_blend
_color_blend($img, $hex1, $hex2, $alpha)
Definition: color.module:722
_color_page_alter
_color_page_alter(&$vars)
Definition: color.module:120
color_scheme_form
color_scheme_form($complete_form, &$form_state, $theme)
Definition: color.module:171
theme_color_scheme_form
theme_color_scheme_form($variables)
Definition: color.module:264
file_prepare_directory
file_prepare_directory(&$directory, $options=FILE_MODIFY_PERMISSIONS)
Definition: file.inc:430
list_themes
list_themes($refresh=FALSE)
Definition: theme.inc:774
drupal_basename
drupal_basename($uri, $suffix=NULL)
Definition: file.inc:2317
base_path
base_path()
Definition: common.inc:2817
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
_color_hsl2rgb
_color_hsl2rgb($hsl)
Definition: color.module:763
_color_rgb2hsl
_color_rgb2hsl($rgb)
Definition: color.module:792
format_size
format_size($size, $langcode=NULL)
Definition: common.inc:1866
color_form_system_theme_settings_alter
color_form_system_theme_settings_alter(&$form, &$form_state)
Definition: color.module:39
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
_color_html_alter
_color_html_alter(&$vars)
Definition: color.module:85
_color_rewrite_stylesheet
_color_rewrite_stylesheet($theme, &$info, &$paths, $palette, $style)
Definition: color.module:496
_color_pack
_color_pack($rgb, $normalize=FALSE)
Definition: color.module:751
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.mail.inc Source File

  • modules
  • system
system.mail.inc
Go to the documentation of this file.
1 <?php
2
11 class DefaultMailSystem implements MailSystemInterface {
21 public function format(array $message) {
22 // Join the body array into one string.
23 $message['body'] = implode("\n\n", $message['body']);
24 // Convert any HTML to plain-text.
25 $message['body'] = drupal_html_to_text($message['body']);
26 // Wrap the mail body for sending.
27 $message['body'] = drupal_wrap_mail($message['body']);
28 return $message;
29 }
30
42 public function mail(array $message) {
43 // If 'Return-Path' isn't already set in php.ini, we pass it separately
44 // as an additional parameter instead of in the header.
45 // However, if PHP's 'safe_mode' is on, this is not allowed.
46 if (isset($message['headers']['Return-Path']) && !ini_get('safe_mode')) {
47 $return_path_set = strpos(ini_get('sendmail_path'), ' -f');
48 if (!$return_path_set) {
49 $message['Return-Path'] = $message['headers']['Return-Path'];
50 unset($message['headers']['Return-Path']);
51 }
52 }
53 $mimeheaders = array();
54 foreach ($message['headers'] as $name => $value) {
55 $mimeheaders[] = $name . ': ' . mime_header_encode($value);
56 }
57 $line_endings = variable_get('mail_line_endings', MAIL_LINE_ENDINGS);
58 // Prepare mail commands.
59 $mail_subject = mime_header_encode($message['subject']);
60 // Note: e-mail uses CRLF for line-endings. PHP's API requires LF
61 // on Unix and CRLF on Windows. Drupal automatically guesses the
62 // line-ending format appropriate for your system. If you need to
63 // override this, adjust $conf['mail_line_endings'] in settings.php.
64 $mail_body = preg_replace('@\r?\n@', $line_endings, $message['body']);
65 // For headers, PHP's API suggests that we use CRLF normally,
66 // but some MTAs incorrectly replace LF with CRLF. See #234403.
67 $mail_headers = join("\n", $mimeheaders);
68
69 // We suppress warnings and notices from mail() because of issues on some
70 // hosts. The return value of this method will still indicate whether mail
71 // was sent successfully.
72 if (!isset($_SERVER['WINDIR']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Win32') === FALSE) {
73 if (isset($message['Return-Path']) && !ini_get('safe_mode')) {
74 // On most non-Windows systems, the "-f" option to the sendmail command
75 // is used to set the Return-Path. There is no space between -f and
76 // the value of the return path.
77 $mail_result = @mail(
78 $message['to'],
79 $mail_subject,
80 $mail_body,
81 $mail_headers,
82 '-f' . $message['Return-Path']
83 );
84 }
85 else {
86 // The optional $additional_parameters argument to mail() is not
87 // allowed if safe_mode is enabled. Passing any value throws a PHP
88 // warning and makes mail() return FALSE.
89 $mail_result = @mail(
90 $message['to'],
91 $mail_subject,
92 $mail_body,
93 $mail_headers
94 );
95 }
96 }
97 else {
98 // On Windows, PHP will use the value of sendmail_from for the
99 // Return-Path header.
100 $old_from = ini_get('sendmail_from');
101 ini_set('sendmail_from', $message['Return-Path']);
102 $mail_result = @mail(
103 $message['to'],
104 $mail_subject,
105 $mail_body,
106 $mail_headers
107 );
108 ini_set('sendmail_from', $old_from);
109 }
110 return $mail_result;
111 }
112 }
113
119 class TestingMailSystem extends DefaultMailSystem implements MailSystemInterface {
126 public function mail(array $message) {
127 $captured_emails = variable_get('drupal_test_email_collector', array());
128 $captured_emails[] = $message;
129 variable_set('drupal_test_email_collector', $captured_emails);
130 return TRUE;
131 }
132 }
133
$name
print $name
Definition: profile-listing.tpl.php:43
TestingMailSystem
Definition: system.mail.inc:119
MailSystemInterface
Definition: mail.inc:292
TestingMailSystem\mail
mail(array $message)
Definition: system.mail.inc:126
MAIL_LINE_ENDINGS
const MAIL_LINE_ENDINGS
Definition: mail.inc:13
DefaultMailSystem
Definition: system.mail.inc:11
drupal_html_to_text
drupal_html_to_text($string, $allowed_tags=NULL)
Definition: mail.inc:402
$value
print $value
Definition: user-profile-item.tpl.php:26
DefaultMailSystem\mail
mail(array $message)
Definition: system.mail.inc:42
mime_header_encode
mime_header_encode($string)
Definition: unicode.inc:384
drupal_wrap_mail
drupal_wrap_mail($text, $indent= '')
Definition: mail.inc:351
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
DefaultMailSystem\format
format(array $message)
Definition: system.mail.inc:21
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/image/image.module Source File

  • modules
  • image
image.module
Go to the documentation of this file.
1 <?php
2
11 define('IMAGE_STORAGE_NORMAL', 1);
12
16 define('IMAGE_STORAGE_OVERRIDE', 2);
17
21 define('IMAGE_STORAGE_DEFAULT', 4);
22
26 define('IMAGE_STORAGE_EDITABLE', IMAGE_STORAGE_NORMAL | IMAGE_STORAGE_OVERRIDE);
27
31 define('IMAGE_STORAGE_MODULE', IMAGE_STORAGE_OVERRIDE | IMAGE_STORAGE_DEFAULT);
32
36 define('IMAGE_DERIVATIVE_TOKEN', 'itok');
37
38 // Load all Field module hooks for Image.
39 require_once DRUPAL_ROOT . '/modules/image/image.field.inc';
40
44 function image_help($path, $arg) {
45 switch ($path) {
46 case 'admin/help#image':
47 $output = '';
48 $output .= '<h3>' . t('About') . '</h3>';
49 $output .= '<p>' . t('The Image module allows you to manipulate images on your website. It exposes a setting for using the <em>Image toolkit</em>, allows you to configure <em>Image styles</em> that can be used for resizing or adjusting images on display, and provides an <em>Image</em> field for attaching images to content. For more information, see the online handbook entry for <a href="@image">Image module</a>.', array('@image' => 'http://drupal.org/documentation/modules/image')) . '</p>';
50 $output .= '<h3>' . t('Uses') . '</h3>';
51 $output .= '<dl>';
52 $output .= '<dt>' . t('Manipulating images') . '</dt>';
53 $output .= '<dd>' . t('With the Image module you can scale, crop, resize, rotate and desaturate images without affecting the original image using <a href="@image">image styles</a>. When you change an image style, the module automatically refreshes all created images. Every image style must have a name, which will be used in the URL of the generated images. There are two common approaches to naming image styles (which you use will depend on how the image style is being applied):',array('@image' => url('admin/config/media/image-styles')));
54 $output .= '<ul><li>' . t('Based on where it will be used: eg. <em>profile-picture</em>') . '</li>';
55 $output .= '<li>' . t('Describing its appearance: eg. <em>square-85x85</em>') . '</li></ul>';
56 $output .= t('After you create an image style, you can add effects: crop, scale, resize, rotate, and desaturate (other contributed modules provide additional effects). For example, by combining effects as crop, scale, and desaturate, you can create square, grayscale thumbnails.') . '<dd>';
57 $output .= '<dt>' . t('Attaching images to content as fields') . '</dt>';
58 $output .= '<dd>' . t("Image module also allows you to attach images to content as fields. To add an image field to a <a href='@content-type'>content type</a>, go to the content type's <em>manage fields</em> page, and add a new field of type <em>Image</em>. Attaching images to content this way allows image styles to be applied and maintained, and also allows you more flexibility when theming.", array('@content-type' => url('admin/structure/types'))) . '</dd>';
59 $output .= '</dl>';
60 return $output;
61 case 'admin/config/media/image-styles':
62 return '<p>' . t('Image styles commonly provide thumbnail sizes by scaling and cropping images, but can also add various effects before an image is displayed. When an image is displayed with a style, a new file is created and the original image is left unchanged.') . '</p>';
63 case 'admin/config/media/image-styles/edit/%/add/%':
64 $effect = image_effect_definition_load($arg[7]);
65 return isset($effect['help']) ? ('<p>' . $effect['help'] . '</p>') : NULL;
66 case 'admin/config/media/image-styles/edit/%/effects/%':
67 $effect = ($arg[5] == 'add') ? image_effect_definition_load($arg[6]) : image_effect_load($arg[6], $arg[4]);
68 return isset($effect['help']) ? ('<p>' . $effect['help'] . '</p>') : NULL;
69 }
70 }
71
75 function image_menu() {
76 $items = array();
77
78 // Generate image derivatives of publicly available files.
79 // If clean URLs are disabled, image derivatives will always be served
80 // through the menu system.
81 // If clean URLs are enabled and the image derivative already exists,
82 // PHP will be bypassed.
83 $directory_path = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath();
84 $items[$directory_path . '/styles/%image_style'] = array(
85 'title' => 'Generate image style',
86 'page callback' => 'image_style_deliver',
87 'page arguments' => array(count(explode('/', $directory_path)) + 1),
88 'access callback' => TRUE,
89 'type' => MENU_CALLBACK,
90 );
91 // Generate and deliver image derivatives of private files.
92 // These image derivatives are always delivered through the menu system.
93 $items['system/files/styles/%image_style'] = array(
94 'title' => 'Generate image style',
95 'page callback' => 'image_style_deliver',
96 'page arguments' => array(3),
97 'access callback' => TRUE,
98 'type' => MENU_CALLBACK,
99 );
100 $items['admin/config/media/image-styles'] = array(
101 'title' => 'Image styles',
102 'description' => 'Configure styles that can be used for resizing or adjusting images on display.',
103 'page callback' => 'image_style_list',
104 'access arguments' => array('administer image styles'),
105 'file' => 'image.admin.inc',
106 );
107 $items['admin/config/media/image-styles/list'] = array(
108 'title' => 'List',
109 'description' => 'List the current image styles on the site.',
110 'page callback' => 'image_style_list',
111 'access arguments' => array('administer image styles'),
112 'type' => MENU_DEFAULT_LOCAL_TASK,
113 'weight' => 1,
114 'file' => 'image.admin.inc',
115 );
116 $items['admin/config/media/image-styles/add'] = array(
117 'title' => 'Add style',
118 'description' => 'Add a new image style.',
119 'page callback' => 'drupal_get_form',
120 'page arguments' => array('image_style_add_form'),
121 'access arguments' => array('administer image styles'),
122 'type' => MENU_LOCAL_ACTION,
123 'weight' => 2,
124 'file' => 'image.admin.inc',
125 );
126 $items['admin/config/media/image-styles/edit/%image_style'] = array(
127 'title' => 'Edit style',
128 'description' => 'Configure an image style.',
129 'page callback' => 'drupal_get_form',
130 'page arguments' => array('image_style_form', 5),
131 'access arguments' => array('administer image styles'),
132 'file' => 'image.admin.inc',
133 );
134 $items['admin/config/media/image-styles/delete/%image_style'] = array(
135 'title' => 'Delete style',
136 'description' => 'Delete an image style.',
137 'load arguments' => array(NULL, (string) IMAGE_STORAGE_NORMAL),
138 'page callback' => 'drupal_get_form',
139 'page arguments' => array('image_style_delete_form', 5),
140 'access arguments' => array('administer image styles'),
141 'file' => 'image.admin.inc',
142 );
143 $items['admin/config/media/image-styles/revert/%image_style'] = array(
144 'title' => 'Revert style',
145 'description' => 'Revert an image style.',
146 'load arguments' => array(NULL, (string) IMAGE_STORAGE_OVERRIDE),
147 'page callback' => 'drupal_get_form',
148 'page arguments' => array('image_style_revert_form', 5),
149 'access arguments' => array('administer image styles'),
150 'file' => 'image.admin.inc',
151 );
152 $items['admin/config/media/image-styles/edit/%image_style/effects/%image_effect'] = array(
153 'title' => 'Edit image effect',
154 'description' => 'Edit an existing effect within a style.',
155 'load arguments' => array(5, (string) IMAGE_STORAGE_EDITABLE),
156 'page callback' => 'drupal_get_form',
157 'page arguments' => array('image_effect_form', 5, 7),
158 'access arguments' => array('administer image styles'),
159 'file' => 'image.admin.inc',
160 );
161 $items['admin/config/media/image-styles/edit/%image_style/effects/%image_effect/delete'] = array(
162 'title' => 'Delete image effect',
163 'description' => 'Delete an existing effect from a style.',
164 'load arguments' => array(5, (string) IMAGE_STORAGE_EDITABLE),
165 'page callback' => 'drupal_get_form',
166 'page arguments' => array('image_effect_delete_form', 5, 7),
167 'access arguments' => array('administer image styles'),
168 'file' => 'image.admin.inc',
169 );
170 $items['admin/config/media/image-styles/edit/%image_style/add/%image_effect_definition'] = array(
171 'title' => 'Add image effect',
172 'description' => 'Add a new effect to a style.',
173 'load arguments' => array(5),
174 'page callback' => 'drupal_get_form',
175 'page arguments' => array('image_effect_form', 5, 7),
176 'access arguments' => array('administer image styles'),
177 'file' => 'image.admin.inc',
178 );
179
180 return $items;
181 }
182
186 function image_theme() {
187 return array(
188 // Theme functions in image.module.
189 'image_style' => array(
190 'variables' => array(
191 'style_name' => NULL,
192 'path' => NULL,
193 'width' => NULL,
194 'height' => NULL,
195 'alt' => '',
196 'title' => NULL,
197 'attributes' => array(),
198 ),
199 ),
200
201 // Theme functions in image.admin.inc.
202 'image_style_list' => array(
203 'variables' => array('styles' => NULL),
204 ),
205 'image_style_effects' => array(
206 'render element' => 'form',
207 ),
208 'image_style_preview' => array(
209 'variables' => array('style' => NULL),
210 ),
211 'image_anchor' => array(
212 'render element' => 'element',
213 ),
214 'image_resize_summary' => array(
215 'variables' => array('data' => NULL),
216 ),
217 'image_scale_summary' => array(
218 'variables' => array('data' => NULL),
219 ),
220 'image_crop_summary' => array(
221 'variables' => array('data' => NULL),
222 ),
223 'image_rotate_summary' => array(
224 'variables' => array('data' => NULL),
225 ),
226
227 // Theme functions in image.field.inc.
228 'image_widget' => array(
229 'render element' => 'element',
230 ),
231 'image_formatter' => array(
232 'variables' => array('item' => NULL, 'path' => NULL, 'image_style' => NULL),
233 ),
234 );
235 }
236
240 function image_permission() {
241 return array(
242 'administer image styles' => array(
243 'title' => t('Administer image styles'),
244 'description' => t('Create and modify styles for generating image modifications such as thumbnails.'),
245 ),
246 );
247 }
248
252 function image_form_system_file_system_settings_alter(&$form, &$form_state) {
253 $form['#submit'][] = 'image_system_file_system_settings_submit';
254 }
255
262 function image_system_file_system_settings_submit($form, &$form_state) {
263 if ($form['file_public_path']['#default_value'] !== $form_state['values']['file_public_path']) {
264 variable_set('menu_rebuild_needed', TRUE);
265 }
266 }
267
271 function image_flush_caches() {
272 return array('cache_image');
273 }
274
280 function image_file_download($uri) {
281 $path = file_uri_target($uri);
282
283 // Private file access for image style derivatives.
284 if (strpos($path, 'styles/') === 0) {
285 $args = explode('/', $path);
286 // Discard the first part of the path (styles).
287 array_shift($args);
288 // Get the style name from the second part.
289 $style_name = array_shift($args);
290 // Remove the scheme from the path.
291 array_shift($args);
292
293 // Then the remaining parts are the path to the image.
294 $original_uri = file_uri_scheme($uri) . '://' . implode('/', $args);
295
296 // Check that the file exists and is an image.
297 if ($info = image_get_info($uri)) {
298 // Check the permissions of the original to grant access to this image.
299 $headers = module_invoke_all('file_download', $original_uri);
300 // Confirm there's at least one module granting access and none denying access.
301 if (!empty($headers) && !in_array(-1, $headers)) {
302 return array(
303 // Send headers describing the image's size, and MIME-type...
304 'Content-Type' => $info['mime_type'],
305 'Content-Length' => $info['file_size'],
306 // By not explicitly setting them here, this uses normal Drupal
307 // Expires, Cache-Control and ETag headers to prevent proxy or
308 // browser caching of private images.
309 );
310 }
311 }
312 return -1;
313 }
314
315 // Private file access for the original files. Note that we only check access
316 // for non-temporary images, since file.module will grant access for all
317 // temporary files.
318 $files = file_load_multiple(array(), array('uri' => $uri));
319 if (count($files)) {
320 $file = reset($files);
321 if ($file->status) {
322 return file_file_download($uri, 'image');
323 }
324 }
325 }
326
330 function image_file_move($file, $source) {
331 // Delete any image derivatives at the original image path.
332 image_path_flush($source->uri);
333 }
334
338 function image_file_delete($file) {
339 // Delete any image derivatives of this image.
340 image_path_flush($file->uri);
341 }
342
346 function image_image_default_styles() {
347 $styles = array();
348
349 $styles['thumbnail'] = array(
350 'label' => 'Thumbnail (100x100)',
351 'effects' => array(
352 array(
353 'name' => 'image_scale',
354 'data' => array('width' => 100, 'height' => 100, 'upscale' => 1),
355 'weight' => 0,
356 ),
357 )
358 );
359
360 $styles['medium'] = array(
361 'label' => 'Medium (220x220)',
362 'effects' => array(
363 array(
364 'name' => 'image_scale',
365 'data' => array('width' => 220, 'height' => 220, 'upscale' => 1),
366 'weight' => 0,
367 ),
368 )
369 );
370
371 $styles['large'] = array(
372 'label' => 'Large (480x480)',
373 'effects' => array(
374 array(
375 'name' => 'image_scale',
376 'data' => array('width' => 480, 'height' => 480, 'upscale' => 0),
377 'weight' => 0,
378 ),
379 )
380 );
381
382 return $styles;
383 }
384
388 function image_image_style_save($style) {
389 if (isset($style['old_name']) && $style['old_name'] != $style['name']) {
390 $instances = field_read_instances();
391 // Loop through all fields searching for image fields.
392 foreach ($instances as $instance) {
393 if ($instance['widget']['module'] == 'image') {
394 $instance_changed = FALSE;
395 foreach ($instance['display'] as $view_mode => $display) {
396 // Check if the formatter involves an image style.
397 if ($display['type'] == 'image' && $display['settings']['image_style'] == $style['old_name']) {
398 // Update display information for any instance using the image
399 // style that was just deleted.
400 $instance['display'][$view_mode]['settings']['image_style'] = $style['name'];
401 $instance_changed = TRUE;
402 }
403 }
404 if ($instance['widget']['settings']['preview_image_style'] == $style['old_name']) {
405 $instance['widget']['settings']['preview_image_style'] = $style['name'];
406 $instance_changed = TRUE;
407 }
408 if ($instance_changed) {
409 field_update_instance($instance);
410 }
411 }
412 }
413 }
414 }
415
419 function image_image_style_delete($style) {
420 image_image_style_save($style);
421 }
422
426 function image_field_delete_field($field) {
427 if ($field['type'] != 'image') {
428 return;
429 }
430
431 // The value of a managed_file element can be an array if #extended == TRUE.
432 $fid = (is_array($field['settings']['default_image']) ? $field['settings']['default_image']['fid'] : $field['settings']['default_image']);
433 if ($fid && ($file = file_load($fid))) {
434 file_usage_delete($file, 'image', 'default_image', $field['id']);
435 }
436 }
437
441 function image_field_update_field($field, $prior_field, $has_data) {
442 if ($field['type'] != 'image') {
443 return;
444 }
445
446 // The value of a managed_file element can be an array if #extended == TRUE.
447 $fid_new = (is_array($field['settings']['default_image']) ? $field['settings']['default_image']['fid'] : $field['settings']['default_image']);
448 $fid_old = (is_array($prior_field['settings']['default_image']) ? $prior_field['settings']['default_image']['fid'] : $prior_field['settings']['default_image']);
449
450 $file_new = $fid_new ? file_load($fid_new) : FALSE;
451
452 if ($fid_new != $fid_old) {
453
454 // Is there a new file?
455 if ($file_new) {
456 $file_new->status = FILE_STATUS_PERMANENT;
457 file_save($file_new);
458 file_usage_add($file_new, 'image', 'default_image', $field['id']);
459 }
460
461 // Is there an old file?
462 if ($fid_old && ($file_old = file_load($fid_old))) {
463 file_usage_delete($file_old, 'image', 'default_image', $field['id']);
464 }
465 }
466
467 // If the upload destination changed, then move the file.
468 if ($file_new && (file_uri_scheme($file_new->uri) != $field['settings']['uri_scheme'])) {
469 $directory = $field['settings']['uri_scheme'] . '://default_images/';
470 file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
471 file_move($file_new, $directory . $file_new->filename);
472 }
473 }
474
478 function image_field_delete_instance($instance) {
479 // Only act on image fields.
480 $field = field_read_field($instance['field_name']);
481 if ($field['type'] != 'image') {
482 return;
483 }
484
485 // The value of a managed_file element can be an array if the #extended
486 // property is set to TRUE.
487 $fid = $instance['settings']['default_image'];
488 if (is_array($fid)) {
489 $fid = $fid['fid'];
490 }
491
492 // Remove the default image when the instance is deleted.
493 if ($fid && ($file = file_load($fid))) {
494 file_usage_delete($file, 'image', 'default_image', $instance['id']);
495 }
496 }
497
501 function image_field_update_instance($instance, $prior_instance) {
502 // Only act on image fields.
503 $field = field_read_field($instance['field_name']);
504 if ($field['type'] != 'image') {
505 return;
506 }
507
508 // The value of a managed_file element can be an array if the #extended
509 // property is set to TRUE.
510 $fid_new = $instance['settings']['default_image'];
511 if (is_array($fid_new)) {
512 $fid_new = $fid_new['fid'];
513 }
514 $fid_old = $prior_instance['settings']['default_image'];
515 if (is_array($fid_old)) {
516 $fid_old = $fid_old['fid'];
517 }
518
519 // If the old and new files do not match, update the default accordingly.
520 $file_new = $fid_new ? file_load($fid_new) : FALSE;
521 if ($fid_new != $fid_old) {
522 // Save the new file, if present.
523 if ($file_new) {
524 $file_new->status = FILE_STATUS_PERMANENT;
525 file_save($file_new);
526 file_usage_add($file_new, 'image', 'default_image', $instance['id']);
527 }
528 // Delete the old file, if present.
529 if ($fid_old && ($file_old = file_load($fid_old))) {
530 file_usage_delete($file_old, 'image', 'default_image', $instance['id']);
531 }
532 }
533
534 // If the upload destination changed, then move the file.
535 if ($file_new && (file_uri_scheme($file_new->uri) != $field['settings']['uri_scheme'])) {
536 $directory = $field['settings']['uri_scheme'] . '://default_images/';
537 file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
538 file_move($file_new, $directory . $file_new->filename);
539 }
540 }
541
548 function image_path_flush($path) {
549 $styles = image_styles();
550 foreach ($styles as $style) {
551 $image_path = image_style_path($style['name'], $path);
552 if (file_exists($image_path)) {
553 file_unmanaged_delete($image_path);
554 }
555 }
556 }
557
565 function image_styles() {
566 $styles = &drupal_static(__FUNCTION__);
567
568 // Grab from cache or build the array.
569 if (!isset($styles)) {
570 if ($cache = cache_get('image_styles', 'cache')) {
571 $styles = $cache->data;
572 }
573 else {
574 $styles = array();
575
576 // Select the module-defined styles.
577 foreach (module_implements('image_default_styles') as $module) {
578 $module_styles = module_invoke($module, 'image_default_styles');
579 foreach ($module_styles as $style_name => $style) {
580 $style['name'] = $style_name;
581 $style['label'] = empty($style['label']) ? $style_name : $style['label'];
582 $style['module'] = $module;
583 $style['storage'] = IMAGE_STORAGE_DEFAULT;
584 foreach ($style['effects'] as $key => $effect) {
585 $definition = image_effect_definition_load($effect['name']);
586 $effect = array_merge($definition, $effect);
587 $style['effects'][$key] = $effect;
588 }
589 $styles[$style_name] = $style;
590 }
591 }
592
593 // Select all the user-defined styles.
594 $user_styles = db_select('image_styles', NULL, array('fetch' => PDO::FETCH_ASSOC))
595 ->fields('image_styles')
596 ->orderBy('name')
597 ->execute()
598 ->fetchAllAssoc('name', PDO::FETCH_ASSOC);
599
600 // Allow the user styles to override the module styles.
601 foreach ($user_styles as $style_name => $style) {
602 $style['module'] = NULL;
603 $style['storage'] = IMAGE_STORAGE_NORMAL;
604 $style['effects'] = image_style_effects($style);
605 if (isset($styles[$style_name]['module'])) {
606 $style['module'] = $styles[$style_name]['module'];
607 $style['storage'] = IMAGE_STORAGE_OVERRIDE;
608 }
609 $styles[$style_name] = $style;
610 }
611
612 drupal_alter('image_styles', $styles);
613 cache_set('image_styles', $styles);
614 }
615 }
616
617 return $styles;
618 }
619
641 function image_style_load($name = NULL, $isid = NULL, $include = NULL) {
642 $styles = image_styles();
643
644 // If retrieving by name.
645 if (isset($name) && isset($styles[$name])) {
646 $style = $styles[$name];
647 }
648
649 // If retrieving by image style id.
650 if (!isset($name) && isset($isid)) {
651 foreach ($styles as $name => $database_style) {
652 if (isset($database_style['isid']) && $database_style['isid'] == $isid) {
653 $style = $database_style;
654 break;
655 }
656 }
657 }
658
659 // Restrict to the specific type of flag. This bitwise operation basically
660 // states "if the storage is X, then allow".
661 if (isset($style) && (!isset($include) || ($style['storage'] & (int) $include))) {
662 return $style;
663 }
664
665 // Otherwise the style was not found.
666 return FALSE;
667 }
668
685 function image_style_save($style) {
686 if (isset($style['isid']) && is_numeric($style['isid'])) {
687 // Load the existing style to make sure we account for renamed styles.
688 $old_style = image_style_load(NULL, $style['isid']);
689 image_style_flush($old_style);
690 drupal_write_record('image_styles', $style, 'isid');
691 if ($old_style['name'] != $style['name']) {
692 $style['old_name'] = $old_style['name'];
693 }
694 }
695 else {
696 // Add a default label when not given.
697 if (empty($style['label'])) {
698 $style['label'] = $style['name'];
699 }
700 drupal_write_record('image_styles', $style);
701 $style['is_new'] = TRUE;
702 }
703
704 // Let other modules update as necessary on save.
705 module_invoke_all('image_style_save', $style);
706
707 // Clear all caches and flush.
708 image_style_flush($style);
709
710 return $style;
711 }
712
725 function image_style_delete($style, $replacement_style_name = '') {
726 image_style_flush($style);
727
728 db_delete('image_effects')->condition('isid', $style['isid'])->execute();
729 db_delete('image_styles')->condition('isid', $style['isid'])->execute();
730
731 // Let other modules update as necessary on save.
732 $style['old_name'] = $style['name'];
733 $style['name'] = $replacement_style_name;
734 module_invoke_all('image_style_delete', $style);
735
736 return TRUE;
737 }
738
752 function image_style_effects($style) {
753 $effects = image_effects();
754 $style_effects = array();
755 foreach ($effects as $effect) {
756 if ($style['isid'] == $effect['isid']) {
757 $style_effects[$effect['ieid']] = $effect;
758 }
759 }
760
761 return $style_effects;
762 }
763
781 function image_style_options($include_empty = TRUE, $output = CHECK_PLAIN) {
782 $styles = image_styles();
783 $options = array();
784 if ($include_empty && !empty($styles)) {
785 $options[''] = t('<none>');
786 }
787 foreach ($styles as $name => $style) {
788 $options[$name] = ($output == PASS_THROUGH) ? $style['label'] : check_plain($style['label']);
789 }
790
791 if (empty($options)) {
792 $options[''] = t('No defined styles');
793 }
794 return $options;
795 }
796
805 function image_style_deliver($style, $scheme) {
806 $args = func_get_args();
807 array_shift($args);
808 array_shift($args);
809 $target = implode('/', $args);
810
811 // Check that the style is defined, the scheme is valid, and the image
812 // derivative token is valid. (Sites which require image derivatives to be
813 // generated without a token can set the 'image_allow_insecure_derivatives'
814 // variable to TRUE to bypass the latter check, but this will increase the
815 // site's vulnerability to denial-of-service attacks. To prevent this
816 // variable from leaving the site vulnerable to the most serious attacks, a
817 // token is always required when a derivative of a derivative is requested.)
818 $valid = !empty($style) && file_stream_wrapper_valid_scheme($scheme);
819 if (!variable_get('image_allow_insecure_derivatives', FALSE) || strpos(ltrim($target, '\/'), 'styles/') === 0) {
820 $valid = $valid && isset($_GET[IMAGE_DERIVATIVE_TOKEN]) && $_GET[IMAGE_DERIVATIVE_TOKEN] === image_style_path_token($style['name'], $scheme . '://' . $target);
821 }
822 if (!$valid) {
823 return MENU_ACCESS_DENIED;
824 }
825
826 $image_uri = $scheme . '://' . $target;
827 $derivative_uri = image_style_path($style['name'], $image_uri);
828
829 // If using the private scheme, let other modules provide headers and
830 // control access to the file.
831 if ($scheme == 'private') {
832 if (file_exists($derivative_uri)) {
833 file_download($scheme, file_uri_target($derivative_uri));
834 }
835 else {
836 $headers = module_invoke_all('file_download', $image_uri);
837 if (in_array(-1, $headers) || empty($headers)) {
838 return MENU_ACCESS_DENIED;
839 }
840 if (count($headers)) {
841 foreach ($headers as $name => $value) {
842 drupal_add_http_header($name, $value);
843 }
844 }
845 }
846 }
847
848 // Don't start generating the image if the derivative already exists or if
849 // generation is in progress in another thread.
850 $lock_name = 'image_style_deliver:' . $style['name'] . ':' . drupal_hash_base64($image_uri);
851 if (!file_exists($derivative_uri)) {
852 $lock_acquired = lock_acquire($lock_name);
853 if (!$lock_acquired) {
854 // Tell client to retry again in 3 seconds. Currently no browsers are known
855 // to support Retry-After.
856 drupal_add_http_header('Status', '503 Service Unavailable');
857 drupal_add_http_header('Retry-After', 3);
858 print t('Image generation in progress. Try again shortly.');
859 drupal_exit();
860 }
861 }
862
863 // Try to generate the image, unless another thread just did it while we were
864 // acquiring the lock.
865 $success = file_exists($derivative_uri) || image_style_create_derivative($style, $image_uri, $derivative_uri);
866
867 if (!empty($lock_acquired)) {
868 lock_release($lock_name);
869 }
870
871 if ($success) {
872 $image = image_load($derivative_uri);
873 file_transfer($image->source, array('Content-Type' => $image->info['mime_type'], 'Content-Length' => $image->info['file_size']));
874 }
875 else {
876 watchdog('image', 'Unable to generate the derived image located at %path.', array('%path' => $derivative_uri));
877 drupal_add_http_header('Status', '500 Internal Server Error');
878 print t('Error generating image.');
879 drupal_exit();
880 }
881 }
882
903 function image_style_create_derivative($style, $source, $destination) {
904 // If the source file doesn't exist, return FALSE without creating folders.
905 if (!$image = image_load($source)) {
906 return FALSE;
907 }
908
909 // Get the folder for the final location of this style.
910 $directory = drupal_dirname($destination);
911
912 // Build the destination folder tree if it doesn't already exist.
913 if (!file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
914 watchdog('image', 'Failed to create style directory: %directory', array('%directory' => $directory), WATCHDOG_ERROR);
915 return FALSE;
916 }
917
918 foreach ($style['effects'] as $effect) {
919 image_effect_apply($image, $effect);
920 }
921
922 if (!image_save($image, $destination)) {
923 if (file_exists($destination)) {
924 watchdog('image', 'Cached image file %destination already exists. There may be an issue with your rewrite configuration.', array('%destination' => $destination), WATCHDOG_ERROR);
925 }
926 return FALSE;
927 }
928
929 return TRUE;
930 }
931
943 function image_style_transform_dimensions($style_name, array &$dimensions) {
944 module_load_include('inc', 'image', 'image.effects');
945 $style = image_style_load($style_name);
946
947 if (!is_array($style)) {
948 return;
949 }
950
951 foreach ($style['effects'] as $effect) {
952 if (isset($effect['dimensions passthrough'])) {
953 continue;
954 }
955
956 if (isset($effect['dimensions callback'])) {
957 $effect['dimensions callback']($dimensions, $effect['data']);
958 }
959 else {
960 $dimensions['width'] = $dimensions['height'] = NULL;
961 }
962 }
963 }
964
971 function image_style_flush($style) {
972 // Delete the style directory in each registered wrapper.
973 $wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE);
974 foreach ($wrappers as $wrapper => $wrapper_data) {
975 if (file_exists($directory = $wrapper . '://styles/' . $style['name'])) {
976 file_unmanaged_delete_recursive($directory);
977 }
978 }
979
980 // Let other modules update as necessary on flush.
981 module_invoke_all('image_style_flush', $style);
982
983 // Clear image style and effect caches.
984 cache_clear_all('image_styles', 'cache');
985 cache_clear_all('image_effects:', 'cache', TRUE);
986 drupal_static_reset('image_styles');
987 drupal_static_reset('image_effects');
988
989 // Clear field caches so that formatters may be added for this style.
990 field_info_cache_clear();
991 drupal_theme_rebuild();
992
993 // Clear page caches when flushing.
994 if (module_exists('block')) {
995 cache_clear_all('*', 'cache_block', TRUE);
996 }
997 cache_clear_all('*', 'cache_page', TRUE);
998 }
999
1013 function image_style_url($style_name, $path) {
1014 $uri = image_style_path($style_name, $path);
1015
1016 // The passed-in $path variable can be either a relative path or a full URI.
1017 $original_uri = file_uri_scheme($path) ? file_stream_wrapper_uri_normalize($path) : file_build_uri($path);
1018
1019 // The token query is added even if the 'image_allow_insecure_derivatives'
1020 // variable is TRUE, so that the emitted links remain valid if it is changed
1021 // back to the default FALSE.
1022 $token_query = array(IMAGE_DERIVATIVE_TOKEN => image_style_path_token($style_name, $original_uri));
1023
1024 // If not using clean URLs, the image derivative callback is only available
1025 // with the query string. If the file does not exist, use url() to ensure
1026 // that it is included. Once the file exists it's fine to fall back to the
1027 // actual file path, this avoids bootstrapping PHP once the files are built.
1028 if (!variable_get('clean_url') && file_uri_scheme($uri) == 'public' && !file_exists($uri)) {
1029 $directory_path = file_stream_wrapper_get_instance_by_uri($uri)->getDirectoryPath();
1030 return url($directory_path . '/' . file_uri_target($uri), array('absolute' => TRUE, 'query' => $token_query));
1031 }
1032
1033 $file_url = file_create_url($uri);
1034 // Append the query string with the token.
1035 return $file_url . (strpos($file_url, '?') !== FALSE ? '&' : '?') . drupal_http_build_query($token_query);
1036 }
1037
1054 function image_style_path_token($style_name, $uri) {
1055 // Return the first eight characters.
1056 return substr(drupal_hmac_base64($style_name . ':' . $uri, drupal_get_private_key() . drupal_get_hash_salt()), 0, 8);
1057 }
1058
1074 function image_style_path($style_name, $uri) {
1075 $scheme = file_uri_scheme($uri);
1076 if ($scheme) {
1077 $path = file_uri_target($uri);
1078 }
1079 else {
1080 $path = $uri;
1081 $scheme = file_default_scheme();
1082 }
1083 return $scheme . '://styles/' . $style_name . '/' . $scheme . '/' . $path;
1084 }
1085
1096 function image_default_style_save($style) {
1097 $style = image_style_save($style);
1098 $effects = array();
1099 foreach ($style['effects'] as $effect) {
1100 $effect['isid'] = $style['isid'];
1101 $effect = image_effect_save($effect);
1102 $effects[$effect['ieid']] = $effect;
1103 }
1104 $style['effects'] = $effects;
1105 return $style;
1106 }
1107
1116 function image_default_style_revert($style) {
1117 image_style_flush($style);
1118
1119 db_delete('image_effects')->condition('isid', $style['isid'])->execute();
1120 db_delete('image_styles')->condition('isid', $style['isid'])->execute();
1121
1122 return TRUE;
1123 }
1124
1136 function image_effect_definitions() {
1137 global $language;
1138
1139 // hook_image_effect_info() includes translated strings, so each language is
1140 // cached separately.
1141 $langcode = $language->language;
1142
1143 $effects = &drupal_static(__FUNCTION__);
1144
1145 if (!isset($effects)) {
1146 if ($cache = cache_get("image_effects:$langcode")) {
1147 $effects = $cache->data;
1148 }
1149 else {
1150 $effects = array();
1151 include_once DRUPAL_ROOT . '/modules/image/image.effects.inc';
1152 foreach (module_implements('image_effect_info') as $module) {
1153 foreach (module_invoke($module, 'image_effect_info') as $name => $effect) {
1154 // Ensure the current toolkit supports the effect.
1155 $effect['module'] = $module;
1156 $effect['name'] = $name;
1157 $effect['data'] = isset($effect['data']) ? $effect['data'] : array();
1158 $effects[$name] = $effect;
1159 }
1160 }
1161 uasort($effects, '_image_effect_definitions_sort');
1162 drupal_alter('image_effect_info', $effects);
1163 cache_set("image_effects:$langcode", $effects);
1164 }
1165 }
1166
1167 return $effects;
1168 }
1169
1195 function image_effect_definition_load($effect, $style_name = NULL) {
1196 $definitions = image_effect_definitions();
1197
1198 // If a style is specified, do not allow loading of default style
1199 // effects.
1200 if (isset($style_name)) {
1201 $style = image_style_load($style_name, NULL);
1202 if ($style['storage'] == IMAGE_STORAGE_DEFAULT) {
1203 return FALSE;
1204 }
1205 }
1206
1207 return isset($definitions[$effect]) ? $definitions[$effect] : FALSE;
1208 }
1209
1217 function image_effects() {
1218 $effects = &drupal_static(__FUNCTION__);
1219
1220 if (!isset($effects)) {
1221 $effects = array();
1222
1223 // Add database image effects.
1224 $result = db_select('image_effects', NULL, array('fetch' => PDO::FETCH_ASSOC))
1225 ->fields('image_effects')
1226 ->orderBy('image_effects.weight', 'ASC')
1227 ->execute();
1228 foreach ($result as $effect) {
1229 $effect['data'] = unserialize($effect['data']);
1230 $definition = image_effect_definition_load($effect['name']);
1231 // Do not load image effects whose definition cannot be found.
1232 if ($definition) {
1233 $effect = array_merge($definition, $effect);
1234 $effects[$effect['ieid']] = $effect;
1235 }
1236 }
1237 }
1238
1239 return $effects;
1240 }
1241
1266 function image_effect_load($ieid, $style_name, $include = NULL) {
1267 if (($style = image_style_load($style_name, NULL, $include)) && isset($style['effects'][$ieid])) {
1268 return $style['effects'][$ieid];
1269 }
1270 return FALSE;
1271 }
1272
1282 function image_effect_save($effect) {
1283 if (!empty($effect['ieid'])) {
1284 drupal_write_record('image_effects', $effect, 'ieid');
1285 }
1286 else {
1287 drupal_write_record('image_effects', $effect);
1288 }
1289 $style = image_style_load(NULL, $effect['isid']);
1290 image_style_flush($style);
1291 return $effect;
1292 }
1293
1300 function image_effect_delete($effect) {
1301 db_delete('image_effects')->condition('ieid', $effect['ieid'])->execute();
1302 $style = image_style_load(NULL, $effect['isid']);
1303 image_style_flush($style);
1304 }
1305
1317 function image_effect_apply($image, $effect) {
1318 module_load_include('inc', 'image', 'image.effects');
1319 $function = $effect['effect callback'];
1320 if (function_exists($function)) {
1321 return $function($image, $effect['data']);
1322 }
1323 return FALSE;
1324 }
1325
1346 function theme_image_style($variables) {
1347 // Determine the dimensions of the styled image.
1348 $dimensions = array(
1349 'width' => $variables['width'],
1350 'height' => $variables['height'],
1351 );
1352
1353 image_style_transform_dimensions($variables['style_name'], $dimensions);
1354
1355 $variables['width'] = $dimensions['width'];
1356 $variables['height'] = $dimensions['height'];
1357
1358 // Determine the URL for the styled image.
1359 $variables['path'] = image_style_url($variables['style_name'], $variables['path']);
1360 return theme('image', $variables);
1361 }
1362
1370 function image_filter_keyword($value, $current_pixels, $new_pixels) {
1371 switch ($value) {
1372 case 'top':
1373 case 'left':
1374 return 0;
1375
1376 case 'bottom':
1377 case 'right':
1378 return $current_pixels - $new_pixels;
1379
1380 case 'center':
1381 return $current_pixels / 2 - $new_pixels / 2;
1382 }
1383 return $value;
1384 }
1385
1391 function _image_effect_definitions_sort($a, $b) {
1392 return strcasecmp($a['name'], $b['name']);
1393 }
image_file_move
image_file_move($file, $source)
Definition: image.module:330
theme_image_style
theme_image_style($variables)
Definition: image.module:1346
drupal_http_build_query
drupal_http_build_query(array $query, $parent= '')
Definition: common.inc:486
IMAGE_STORAGE_EDITABLE
const IMAGE_STORAGE_EDITABLE
Definition: image.module:26
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
file_default_scheme
file_default_scheme()
Definition: file.inc:256
IMAGE_DERIVATIVE_TOKEN
const IMAGE_DERIVATIVE_TOKEN
Definition: image.module:36
_image_effect_definitions_sort
_image_effect_definitions_sort($a, $b)
Definition: image.module:1391
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
image_path_flush
image_path_flush($path)
Definition: image.module:548
file_usage_add
file_usage_add(stdClass $file, $module, $type, $id, $count=1)
Definition: file.inc:682
image_effect_save
image_effect_save($effect)
Definition: image.module:1282
FILE_CREATE_DIRECTORY
const FILE_CREATE_DIRECTORY
Definition: file.inc:41
FILE_MODIFY_PERMISSIONS
const FILE_MODIFY_PERMISSIONS
Definition: file.inc:46
image_field_delete_instance
image_field_delete_instance($instance)
Definition: image.module:478
image_flush_caches
image_flush_caches()
Definition: image.module:271
file_build_uri
file_build_uri($path)
Definition: file.inc:960
drupal_get_private_key
drupal_get_private_key()
Definition: common.inc:5056
image_field_delete_field
image_field_delete_field($field)
Definition: image.module:426
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
MENU_ACCESS_DENIED
const MENU_ACCESS_DENIED
Definition: menu.inc:239
$module
print $module
Definition: search-results.tpl.php:28
file_unmanaged_delete_recursive
file_unmanaged_delete_recursive($path)
Definition: file.inc:1358
file_create_url
file_create_url($uri)
Definition: file.inc:372
image_default_style_save
image_default_style_save($style)
Definition: image.module:1096
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
image_menu
image_menu()
Definition: image.module:75
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
field_read_instances
field_read_instances($params=array(), $include_additional=array())
Definition: field.crud.inc:713
image_system_file_system_settings_submit
image_system_file_system_settings_submit($form, &$form_state)
Definition: image.module:262
image_permission
image_permission()
Definition: image.module:240
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
module_exists
module_exists($module)
Definition: module.inc:274
file_stream_wrapper_get_instance_by_scheme
file_stream_wrapper_get_instance_by_scheme($scheme)
Definition: file.inc:336
image_effects
image_effects()
Definition: image.module:1217
drupal_dirname
drupal_dirname($uri)
Definition: file.inc:2295
image_style_effects
image_style_effects($style)
Definition: image.module:752
image_style_load
image_style_load($name=NULL, $isid=NULL, $include=NULL)
Definition: image.module:641
image_field_update_instance
image_field_update_instance($instance, $prior_instance)
Definition: image.module:501
print
print
Definition: php-2.php:2
image_field_update_field
image_field_update_field($field, $prior_field, $has_data)
Definition: image.module:441
FILE_STATUS_PERMANENT
const FILE_STATUS_PERMANENT
Definition: file.inc:70
drupal_hmac_base64
drupal_hmac_base64($data, $key)
Definition: bootstrap.inc:2047
image_styles
image_styles()
Definition: image.module:565
image_style_transform_dimensions
image_style_transform_dimensions($style_name, array &$dimensions)
Definition: image.module:943
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
image_effect_definitions
image_effect_definitions()
Definition: image.module:1136
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
image_effect_apply
image_effect_apply($image, $effect)
Definition: image.module:1317
file_download
file_download()
Definition: file.inc:1989
image_help
image_help($path, $arg)
Definition: image.module:44
file_file_download
file_file_download($uri, $field_type= 'file')
Definition: file.module:123
file_get_stream_wrappers
file_get_stream_wrappers($filter=STREAM_WRAPPERS_ALL)
Definition: file.inc:123
image_style_delete
image_style_delete($style, $replacement_style_name= '')
Definition: image.module:725
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
file_stream_wrapper_valid_scheme
file_stream_wrapper_valid_scheme($scheme)
Definition: file.inc:218
image_get_info
image_get_info($filepath, $toolkit=FALSE)
Definition: image.inc:124
image_form_system_file_system_settings_alter
image_form_system_file_system_settings_alter(&$form, &$form_state)
Definition: image.module:252
$info
$info
Definition: color.inc:6
IMAGE_STORAGE_DEFAULT
const IMAGE_STORAGE_DEFAULT
Definition: image.module:21
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
file_load_multiple
file_load_multiple($fids=array(), $conditions=array())
Definition: file.inc:564
image_file_download
image_file_download($uri)
Definition: image.module:280
field_info_cache_clear
field_info_cache_clear()
Definition: field.info.inc:54
image_style_path_token
image_style_path_token($style_name, $uri)
Definition: image.module:1054
image_style_path
image_style_path($style_name, $uri)
Definition: image.module:1074
image_load
image_load($file, $toolkit=FALSE)
Definition: image.inc:383
image_style_save
image_style_save($style)
Definition: image.module:685
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
image_file_delete
image_file_delete($file)
Definition: image.module:338
image_image_style_save
image_image_style_save($style)
Definition: image.module:388
drupal_add_http_header
drupal_add_http_header($name, $value, $append=FALSE)
Definition: bootstrap.inc:1129
$value
print $value
Definition: user-profile-item.tpl.php:26
file_load
file_load($fid)
Definition: file.inc:580
image_image_style_delete
image_image_style_delete($style)
Definition: image.module:419
file_move
file_move(stdClass $source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1035
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
$output
$output
Definition: authorize.php:93
CHECK_PLAIN
const CHECK_PLAIN
Definition: bootstrap.inc:225
file_unmanaged_delete
file_unmanaged_delete($path)
Definition: file.inc:1317
image_style_options
image_style_options($include_empty=TRUE, $output=CHECK_PLAIN)
Definition: image.module:781
file_usage_delete
file_usage_delete(stdClass $file, $module, $type=NULL, $id=NULL, $count=1)
Definition: file.inc:720
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
image_effect_delete
image_effect_delete($effect)
Definition: image.module:1300
file_uri_target
file_uri_target($uri)
Definition: file.inc:243
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
image_style_url
image_style_url($style_name, $path)
Definition: image.module:1013
STREAM_WRAPPERS_WRITE_VISIBLE
const STREAM_WRAPPERS_WRITE_VISIBLE
Definition: stream_wrappers.inc:72
file_stream_wrapper_uri_normalize
file_stream_wrapper_uri_normalize($uri)
Definition: file.inc:275
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
lock_acquire
lock_acquire($name, $timeout=30.0)
Definition: lock.inc:102
field_update_instance
field_update_instance($instance)
Definition: field.crud.inc:553
drupal_exit
drupal_exit($destination=NULL)
Definition: common.inc:2721
$styles
print $styles
Definition: html.tpl.php:52
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
file_stream_wrapper_get_instance_by_uri
file_stream_wrapper_get_instance_by_uri($uri)
Definition: file.inc:303
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
image_style_create_derivative
image_style_create_derivative($style, $source, $destination)
Definition: image.module:903
IMAGE_STORAGE_OVERRIDE
const IMAGE_STORAGE_OVERRIDE
Definition: image.module:16
file_prepare_directory
file_prepare_directory(&$directory, $options=FILE_MODIFY_PERMISSIONS)
Definition: file.inc:430
image_effect_definition_load
image_effect_definition_load($effect, $style_name=NULL)
Definition: image.module:1195
image_style_deliver
image_style_deliver($style, $scheme)
Definition: image.module:805
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
drupal_theme_rebuild
drupal_theme_rebuild()
Definition: theme.inc:352
image_default_style_revert
image_default_style_revert($style)
Definition: image.module:1116
file_uri_scheme
file_uri_scheme($uri)
Definition: file.inc:199
drupal_hash_base64
drupal_hash_base64($data)
Definition: bootstrap.inc:2067
IMAGE_STORAGE_NORMAL
const IMAGE_STORAGE_NORMAL
Definition: image.module:11
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
image_save
image_save(stdClass $image, $destination=NULL)
Definition: image.inc:417
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
field_read_field
field_read_field($field_name, $include_additional=array())
Definition: field.crud.inc:315
image_theme
image_theme()
Definition: image.module:186
image_filter_keyword
image_filter_keyword($value, $current_pixels, $new_pixels)
Definition: image.module:1370
image_effect_load
image_effect_load($ieid, $style_name, $include=NULL)
Definition: image.module:1266
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
file_save
file_save(stdClass $file)
Definition: file.inc:599
lock_release
lock_release($name)
Definition: lock.inc:247
drupal_get_hash_salt
drupal_get_hash_salt()
Definition: bootstrap.inc:2289
image_image_default_styles
image_image_default_styles()
Definition: image.module:346
image_style_flush
image_style_flush($style)
Definition: image.module:971
file_transfer
file_transfer($uri, $headers)
Definition: file.inc:1954
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/sqlite/select.inc Source File

  • includes
  • database
  • sqlite
select.inc
Go to the documentation of this file.
1 <?php
2
16 class SelectQuery_sqlite extends SelectQuery {
17 public function forUpdate($set = TRUE) {
18 // SQLite does not support FOR UPDATE so nothing to do.
19 return $this;
20 }
21 }
22
SelectQuery
Definition: select.inc:859
SelectQuery_sqlite
Definition: select.inc:16
SelectQuery_sqlite\forUpdate
forUpdate($set=TRUE)
Definition: select.inc:17
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/image.inc Source File

  • includes
image.inc
Go to the documentation of this file.
1 <?php
2
42 function image_get_available_toolkits() {
43 // hook_image_toolkits returns an array of toolkit names.
44 $toolkits = module_invoke_all('image_toolkits');
45
46 $output = array();
47 foreach ($toolkits as $name => $info) {
48 // Only allow modules that aren't marked as unavailable.
49 if ($info['available']) {
50 $output[$name] = $info['title'];
51 }
52 }
53
54 return $output;
55 }
56
63 function image_get_toolkit() {
64 static $toolkit;
65
66 if (!isset($toolkit)) {
67 $toolkits = image_get_available_toolkits();
68 $toolkit = variable_get('image_toolkit', 'gd');
69 if (!isset($toolkits[$toolkit]) || !function_exists('image_' . $toolkit . '_load')) {
70 // The selected toolkit isn't available so return the first one found. If
71 // none are available this will return FALSE.
72 reset($toolkits);
73 $toolkit = key($toolkits);
74 }
75 }
76
77 return $toolkit;
78 }
79
93 function image_toolkit_invoke($method, stdClass $image, array $params = array()) {
94 $function = 'image_' . $image->toolkit . '_' . $method;
95 if (function_exists($function)) {
96 array_unshift($params, $image);
97 return call_user_func_array($function, $params);
98 }
99 watchdog('image', 'The selected image handling toolkit %toolkit can not correctly process %function.', array('%toolkit' => $image->toolkit, '%function' => $function), WATCHDOG_ERROR);
100 return FALSE;
101 }
102
124 function image_get_info($filepath, $toolkit = FALSE) {
125 $details = FALSE;
126 if (!is_file($filepath) && !is_uploaded_file($filepath)) {
127 return $details;
128 }
129
130 if (!$toolkit) {
131 $toolkit = image_get_toolkit();
132 }
133 if ($toolkit) {
134 $image = new stdClass();
135 $image->source = $filepath;
136 $image->toolkit = $toolkit;
137 $details = image_toolkit_invoke('get_info', $image);
138 if (isset($details) && is_array($details)) {
139 $details['file_size'] = filesize($filepath);
140 }
141 }
142
143 return $details;
144 }
145
169 function image_scale_and_crop(stdClass $image, $width, $height) {
170 $scale = max($width / $image->info['width'], $height / $image->info['height']);
171 $x = ($image->info['width'] * $scale - $width) / 2;
172 $y = ($image->info['height'] * $scale - $height) / 2;
173
174 if (image_resize($image, $image->info['width'] * $scale, $image->info['height'] * $scale)) {
175 return image_crop($image, $x, $y, $width, $height);
176 }
177 return FALSE;
178 }
179
203 function image_dimensions_scale(array &$dimensions, $width = NULL, $height = NULL, $upscale = FALSE) {
204 $aspect = $dimensions['height'] / $dimensions['width'];
205
206 // Calculate one of the dimensions from the other target dimension,
207 // ensuring the same aspect ratio as the source dimensions. If one of the
208 // target dimensions is missing, that is the one that is calculated. If both
209 // are specified then the dimension calculated is the one that would not be
210 // calculated to be bigger than its target.
211 if (($width && !$height) || ($width && $height && $aspect < $height / $width)) {
212 $height = (int) round($width * $aspect);
213 }
214 else {
215 $width = (int) round($height / $aspect);
216 }
217
218 // Don't upscale if the option isn't enabled.
219 if (!$upscale && ($width >= $dimensions['width'] || $height >= $dimensions['height'])) {
220 return FALSE;
221 }
222
223 $dimensions['width'] = $width;
224 $dimensions['height'] = $height;
225 return TRUE;
226 }
227
252 function image_scale(stdClass $image, $width = NULL, $height = NULL, $upscale = FALSE) {
253 $dimensions = $image->info;
254
255 // Scale the dimensions - if they don't change then just return success.
256 if (!image_dimensions_scale($dimensions, $width, $height, $upscale)) {
257 return TRUE;
258 }
259
260 return image_resize($image, $dimensions['width'], $dimensions['height']);
261 }
262
279 function image_resize(stdClass $image, $width, $height) {
280 $width = (int) round($width);
281 $height = (int) round($height);
282
283 return image_toolkit_invoke('resize', $image, array($width, $height));
284 }
285
306 function image_rotate(stdClass $image, $degrees, $background = NULL) {
307 return image_toolkit_invoke('rotate', $image, array($degrees, $background));
308 }
309
331 function image_crop(stdClass $image, $x, $y, $width, $height) {
332 $aspect = $image->info['height'] / $image->info['width'];
333 if (empty($height)) $height = $width / $aspect;
334 if (empty($width)) $width = $height * $aspect;
335
336 $width = (int) round($width);
337 $height = (int) round($height);
338
339 return image_toolkit_invoke('crop', $image, array($x, $y, $width, $height));
340 }
341
354 function image_desaturate(stdClass $image) {
355 return image_toolkit_invoke('desaturate', $image);
356 }
357
383 function image_load($file, $toolkit = FALSE) {
384 if (!$toolkit) {
385 $toolkit = image_get_toolkit();
386 }
387 if ($toolkit) {
388 $image = new stdClass();
389 $image->source = $file;
390 $image->info = image_get_info($file, $toolkit);
391 if (isset($image->info) && is_array($image->info)) {
392 $image->toolkit = $toolkit;
393 if (image_toolkit_invoke('load', $image)) {
394 return $image;
395 }
396 }
397 }
398 return FALSE;
399 }
400
417 function image_save(stdClass $image, $destination = NULL) {
418 if (empty($destination)) {
419 $destination = $image->source;
420 }
421 if ($return = image_toolkit_invoke('save', $image, array($destination))) {
422 // Clear the cached file size and refresh the image information.
423 clearstatcache();
424 $image->info = image_get_info($destination, $image->toolkit);
425
426 if (drupal_chmod($destination)) {
427 return $return;
428 }
429 }
430 return FALSE;
431 }
432
image_scale
image_scale(stdClass $image, $width=NULL, $height=NULL, $upscale=FALSE)
Definition: image.inc:252
image_get_toolkit
image_get_toolkit()
Definition: image.inc:63
image_crop
image_crop(stdClass $image, $x, $y, $width, $height)
Definition: image.inc:331
image_rotate
image_rotate(stdClass $image, $degrees, $background=NULL)
Definition: image.inc:306
$name
print $name
Definition: profile-listing.tpl.php:43
image_resize
image_resize(stdClass $image, $width, $height)
Definition: image.inc:279
image_get_available_toolkits
image_get_available_toolkits()
Definition: image.inc:42
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
image_get_info
image_get_info($filepath, $toolkit=FALSE)
Definition: image.inc:124
$info
$info
Definition: color.inc:6
image_load
image_load($file, $toolkit=FALSE)
Definition: image.inc:383
image_scale_and_crop
image_scale_and_crop(stdClass $image, $width, $height)
Definition: image.inc:169
$output
$output
Definition: authorize.php:93
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
image_dimensions_scale
image_dimensions_scale(array &$dimensions, $width=NULL, $height=NULL, $upscale=FALSE)
Definition: image.inc:203
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
drupal_chmod
drupal_chmod($uri, $mode=NULL)
Definition: file.inc:2180
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
image_save
image_save(stdClass $image, $destination=NULL)
Definition: image.inc:417
image_desaturate
image_desaturate(stdClass $image)
Definition: image.inc:354
image_toolkit_invoke
image_toolkit_invoke($method, stdClass $image, array $params=array())
Definition: image.inc:93
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll.tokens.inc Source File

  • modules
  • poll
poll.tokens.inc
Go to the documentation of this file.
1 <?php
2
11 function poll_token_info() {
12 $node['poll-votes'] = array(
13 'name' => t("Poll votes"),
14 'description' => t("The number of votes that have been cast on a poll."),
15 );
16 $node['poll-winner'] = array(
17 'name' => t("Poll winner"),
18 'description' => t("The winning poll answer."),
19 );
20 $node['poll-winner-votes'] = array(
21 'name' => t("Poll winner votes"),
22 'description' => t("The number of votes received by the winning poll answer."),
23 );
24 $node['poll-winner-percent'] = array(
25 'name' => t("Poll winner percent"),
26 'description' => t("The percentage of votes received by the winning poll answer."),
27 );
28 $node['poll-duration'] = array(
29 'name' => t("Poll duration"),
30 'description' => t("The length of time the poll is set to run."),
31 );
32
33 return array(
34 'tokens' => array('node' => $node),
35 );
36 }
37
41 function poll_tokens($type, $tokens, array $data = array(), array $options = array()) {
42 $sanitize = !empty($options['sanitize']);
43 if (isset($options['language'])) {
44 $url_options['language'] = $options['language'];
45 $language_code = $options['language']->language;
46 }
47 else {
48 $language_code = NULL;
49 }
50
51 $replacements = array();
52
53 if ($type == 'node' && !empty($data['node']) && $data['node']->type == 'poll') {
54 $node = $data['node'];
55
56 $total_votes = 0;
57 $highest_votes = 0;
58 foreach ($node->choice as $choice) {
59 if ($choice['chvotes'] > $highest_votes) {
60 $winner = $choice;
61 $highest_votes = $choice['chvotes'];
62 }
63 $total_votes = $total_votes + $choice['chvotes'];
64 }
65 foreach ($tokens as $name => $original) {
66 switch ($name) {
67 case 'poll-votes':
68 $replacements[$original] = $total_votes;
69 break;
70
71 case 'poll-winner':
72 if (isset($winner)) {
73 $replacements[$original] = $sanitize ? filter_xss($winner['chtext']) : $winner['chtext'];
74 }
75 else {
76 $replacements[$original] = '';
77 }
78 break;
79
80 case 'poll-winner-votes':
81 if (isset($winner)) {
82 $replacements[$original] = $winner['chvotes'];
83 }
84 else {
85 $replacements[$original] = '';
86 }
87 break;
88
89 case 'poll-winner-percent':
90 if (isset($winner)) {
91 $percent = ($winner['chvotes'] / $total_votes) * 100;
92 $replacements[$original] = number_format($percent, 0);
93 }
94 else {
95 $replacements[$original] = '';
96 }
97 break;
98
99 case 'poll-duration':
100 $replacements[$original] = format_interval($node->runtime, 1, $language_code);
101 break;
102 }
103 }
104 }
105
106 return $replacements;
107 }
$name
print $name
Definition: profile-listing.tpl.php:43
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
poll_tokens
poll_tokens($type, $tokens, array $data=array(), array $options=array())
Definition: poll.tokens.inc:41
$choice
print $choice
Definition: poll-vote.tpl.php:25
poll_token_info
poll_token_info()
Definition: poll.tokens.inc:11
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.admin.inc Source File

  • modules
  • aggregator
aggregator.admin.inc
Go to the documentation of this file.
1 <?php
2
11 function aggregator_admin_overview() {
12 return aggregator_view();
13 }
14
21 function aggregator_view() {
22 $result = db_query('SELECT f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.hash, f.etag, f.modified, f.image, f.block, COUNT(i.iid) AS items FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.hash, f.etag, f.modified, f.image, f.block ORDER BY f.title');
23
24 $output = '<h3>' . t('Feed overview') . '</h3>';
25
26 $header = array(t('Title'), t('Items'), t('Last update'), t('Next update'), array('data' => t('Operations'), 'colspan' => '3'));
27 $rows = array();
28 foreach ($result as $feed) {
29 $rows[] = array(
30 l($feed->title, "aggregator/sources/$feed->fid"),
31 format_plural($feed->items, '1 item', '@count items'),
32 ($feed->checked ? t('@time ago', array('@time' => format_interval(REQUEST_TIME - $feed->checked))) : t('never')),
33 ($feed->checked && $feed->refresh ? t('%time left', array('%time' => format_interval($feed->checked + $feed->refresh - REQUEST_TIME))) : t('never')),
34 l(t('edit'), "admin/config/services/aggregator/edit/feed/$feed->fid"),
35 l(t('remove items'), "admin/config/services/aggregator/remove/$feed->fid"),
36 l(t('update items'), "admin/config/services/aggregator/update/$feed->fid", array('query' => array('token' => drupal_get_token("aggregator/update/$feed->fid")))),
37 );
38 }
39 $output .= theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No feeds available. <a href="@link">Add feed</a>.', array('@link' => url('admin/config/services/aggregator/add/feed')))));
40
41 $result = db_query('SELECT c.cid, c.title, COUNT(ci.iid) as items FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid GROUP BY c.cid, c.title ORDER BY title');
42
43 $output .= '<h3>' . t('Category overview') . '</h3>';
44
45 $header = array(t('Title'), t('Items'), t('Operations'));
46 $rows = array();
47 foreach ($result as $category) {
48 $rows[] = array(l($category->title, "aggregator/categories/$category->cid"), format_plural($category->items, '1 item', '@count items'), l(t('edit'), "admin/config/services/aggregator/edit/category/$category->cid"));
49 }
50 $output .= theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No categories available. <a href="@link">Add category</a>.', array('@link' => url('admin/config/services/aggregator/add/category')))));
51
52 return $output;
53 }
54
66 function aggregator_form_feed($form, &$form_state, stdClass $feed = NULL) {
67 $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
68 $period[AGGREGATOR_CLEAR_NEVER] = t('Never');
69
70 $form['title'] = array('#type' => 'textfield',
71 '#title' => t('Title'),
72 '#default_value' => isset($feed->title) ? $feed->title : '',
73 '#maxlength' => 255,
74 '#description' => t('The name of the feed (or the name of the website providing the feed).'),
75 '#required' => TRUE,
76 );
77 $form['url'] = array('#type' => 'textfield',
78 '#title' => t('URL'),
79 '#default_value' => isset($feed->url) ? $feed->url : '',
80 '#maxlength' => NULL,
81 '#description' => t('The fully-qualified URL of the feed.'),
82 '#required' => TRUE,
83 );
84 $form['refresh'] = array('#type' => 'select',
85 '#title' => t('Update interval'),
86 '#default_value' => isset($feed->refresh) ? $feed->refresh : 3600,
87 '#options' => $period,
88 '#description' => t('The length of time between feed updates. Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))),
89 );
90 $form['block'] = array('#type' => 'select',
91 '#title' => t('News items in block'),
92 '#default_value' => isset($feed->block) ? $feed->block : 5,
93 '#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)),
94 '#description' => t("Drupal can make a block with the most recent news items of this feed. You can <a href=\"@block-admin\">configure blocks</a> to be displayed in the sidebar of your page. This setting lets you configure the number of news items to show in this feed's block. If you choose '0' this feed's block will be disabled.", array('@block-admin' => url('admin/structure/block'))),
95 );
96
97 // Handling of categories.
98 $options = array();
99 $values = array();
100 $categories = db_query('SELECT c.cid, c.title, f.fid FROM {aggregator_category} c LEFT JOIN {aggregator_category_feed} f ON c.cid = f.cid AND f.fid = :fid ORDER BY title', array(':fid' => isset($feed->fid) ? $feed->fid : NULL));
101 foreach ($categories as $category) {
102 $options[$category->cid] = check_plain($category->title);
103 if ($category->fid) $values[] = $category->cid;
104 }
105
106 if ($options) {
107 $form['category'] = array(
108 '#type' => 'checkboxes',
109 '#title' => t('Categorize news items'),
110 '#default_value' => $values,
111 '#options' => $options,
112 '#description' => t('New feed items are automatically filed in the checked categories.'),
113 );
114 }
115
116 $form['actions'] = array('#type' => 'actions');
117 $form['actions']['submit'] = array(
118 '#type' => 'submit',
119 '#value' => t('Save'),
120 );
121 if (!empty($feed->fid)) {
122 $form['actions']['delete'] = array(
123 '#type' => 'submit',
124 '#value' => t('Delete'),
125 );
126 $form['fid'] = array(
127 '#type' => 'hidden',
128 '#value' => $feed->fid,
129 );
130 }
131
132 return $form;
133 }
134
140 function aggregator_form_feed_validate($form, &$form_state) {
141 if ($form_state['values']['op'] == t('Save')) {
142 // Ensure URL is valid.
143 if (!valid_url($form_state['values']['url'], TRUE)) {
144 form_set_error('url', t('The URL %url is invalid. Enter a fully-qualified URL, such as http://www.example.com/feed.xml.', array('%url' => $form_state['values']['url'])));
145 }
146 // Check for duplicate titles.
147 if (isset($form_state['values']['fid'])) {
148 $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE (title = :title OR url = :url) AND fid <> :fid", array(':title' => $form_state['values']['title'], ':url' => $form_state['values']['url'], ':fid' => $form_state['values']['fid']));
149 }
150 else {
151 $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = :title OR url = :url", array(':title' => $form_state['values']['title'], ':url' => $form_state['values']['url']));
152 }
153 foreach ($result as $feed) {
154 if (strcasecmp($feed->title, $form_state['values']['title']) == 0) {
155 form_set_error('title', t('A feed named %feed already exists. Enter a unique title.', array('%feed' => $form_state['values']['title'])));
156 }
157 if (strcasecmp($feed->url, $form_state['values']['url']) == 0) {
158 form_set_error('url', t('A feed with this URL %url already exists. Enter a unique URL.', array('%url' => $form_state['values']['url'])));
159 }
160 }
161 }
162 }
163
171 function aggregator_form_feed_submit($form, &$form_state) {
172 if ($form_state['values']['op'] == t('Delete')) {
173 $title = $form_state['values']['title'];
174 // Unset the title.
175 unset($form_state['values']['title']);
176 }
177 aggregator_save_feed($form_state['values']);
178 if (isset($form_state['values']['fid'])) {
179 if (isset($form_state['values']['title'])) {
180 drupal_set_message(t('The feed %feed has been updated.', array('%feed' => $form_state['values']['title'])));
181 if (arg(0) == 'admin') {
182 $form_state['redirect'] = 'admin/config/services/aggregator/';
183 return;
184 }
185 else {
186 $form_state['redirect'] = 'aggregator/sources/' . $form_state['values']['fid'];
187 return;
188 }
189 }
190 else {
191 watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $title));
192 drupal_set_message(t('The feed %feed has been deleted.', array('%feed' => $title)));
193 if (arg(0) == 'admin') {
194 $form_state['redirect'] = 'admin/config/services/aggregator/';
195 return;
196 }
197 else {
198 $form_state['redirect'] = 'aggregator/sources/';
199 return;
200 }
201 }
202 }
203 else {
204 watchdog('aggregator', 'Feed %feed added.', array('%feed' => $form_state['values']['title']), WATCHDOG_NOTICE, l(t('view'), 'admin/config/services/aggregator'));
205 drupal_set_message(t('The feed %feed has been added.', array('%feed' => $form_state['values']['title'])));
206 }
207 }
208
217 function aggregator_admin_remove_feed($form, $form_state, $feed) {
218 return confirm_form(
219 array(
220 'feed' => array(
221 '#type' => 'value',
222 '#value' => $feed,
223 ),
224 ),
225 t('Are you sure you want to remove all items from the feed %feed?', array('%feed' => $feed->title)),
226 'admin/config/services/aggregator',
227 t('This action cannot be undone.'),
228 t('Remove items'),
229 t('Cancel')
230 );
231 }
232
238 function aggregator_admin_remove_feed_submit($form, &$form_state) {
239 aggregator_remove($form_state['values']['feed']);
240 $form_state['redirect'] = 'admin/config/services/aggregator';
241 }
242
250 function aggregator_form_opml($form, &$form_state) {
251 $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
252
253 $form['upload'] = array(
254 '#type' => 'file',
255 '#title' => t('OPML File'),
256 '#description' => t('Upload an OPML file containing a list of feeds to be imported.'),
257 );
258 $form['remote'] = array(
259 '#type' => 'textfield',
260 '#title' => t('OPML Remote URL'),
261 '#maxlength' => 1024,
262 '#description' => t('Enter the URL of an OPML file. This file will be downloaded and processed only once on submission of the form.'),
263 );
264 $form['refresh'] = array(
265 '#type' => 'select',
266 '#title' => t('Update interval'),
267 '#default_value' => 3600,
268 '#options' => $period,
269 '#description' => t('The length of time between feed updates. Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))),
270 );
271 $form['block'] = array('#type' => 'select',
272 '#title' => t('News items in block'),
273 '#default_value' => 5,
274 '#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)),
275 '#description' => t("Drupal can make a block with the most recent news items of a feed. You can <a href=\"@block-admin\">configure blocks</a> to be displayed in the sidebar of your page. This setting lets you configure the number of news items to show in a feed's block. If you choose '0' these feeds' blocks will be disabled.", array('@block-admin' => url('admin/structure/block'))),
276 );
277
278 // Handling of categories.
279 $options = array_map('check_plain', db_query("SELECT cid, title FROM {aggregator_category} ORDER BY title")->fetchAllKeyed());
280 if ($options) {
281 $form['category'] = array(
282 '#type' => 'checkboxes',
283 '#title' => t('Categorize news items'),
284 '#options' => $options,
285 '#description' => t('New feed items are automatically filed in the checked categories.'),
286 );
287 }
288 $form['actions'] = array('#type' => 'actions');
289 $form['actions']['submit'] = array(
290 '#type' => 'submit',
291 '#value' => t('Import')
292 );
293
294 return $form;
295 }
296
302 function aggregator_form_opml_validate($form, &$form_state) {
303 // If both fields are empty or filled, cancel.
304 if (empty($form_state['values']['remote']) == empty($_FILES['files']['name']['upload'])) {
305 form_set_error('remote', t('You must <em>either</em> upload a file or enter a URL.'));
306 }
307
308 // Validate the URL, if one was entered.
309 if (!empty($form_state['values']['remote']) && !valid_url($form_state['values']['remote'], TRUE)) {
310 form_set_error('remote', t('This URL is not valid.'));
311 }
312 }
313
319 function aggregator_form_opml_submit($form, &$form_state) {
320 $data = '';
321 $validators = array('file_validate_extensions' => array('opml xml'));
322 if ($file = file_save_upload('upload', $validators)) {
323 $data = file_get_contents($file->uri);
324 }
325 else {
326 $response = drupal_http_request($form_state['values']['remote']);
327 if (!isset($response->error)) {
328 $data = $response->data;
329 }
330 }
331
332 $feeds = _aggregator_parse_opml($data);
333 if (empty($feeds)) {
334 drupal_set_message(t('No new feed has been added.'));
335 return;
336 }
337
338 $form_state['values']['op'] = t('Save');
339
340 foreach ($feeds as $feed) {
341 // Ensure URL is valid.
342 if (!valid_url($feed['url'], TRUE)) {
343 drupal_set_message(t('The URL %url is invalid.', array('%url' => $feed['url'])), 'warning');
344 continue;
345 }
346
347 // Check for duplicate titles or URLs.
348 $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = :title OR url = :url", array(':title' => $feed['title'], ':url' => $feed['url']));
349 foreach ($result as $old) {
350 if (strcasecmp($old->title, $feed['title']) == 0) {
351 drupal_set_message(t('A feed named %title already exists.', array('%title' => $old->title)), 'warning');
352 continue 2;
353 }
354 if (strcasecmp($old->url, $feed['url']) == 0) {
355 drupal_set_message(t('A feed with the URL %url already exists.', array('%url' => $old->url)), 'warning');
356 continue 2;
357 }
358 }
359
360 $form_state['values']['title'] = $feed['title'];
361 $form_state['values']['url'] = $feed['url'];
362 drupal_form_submit('aggregator_form_feed', $form_state);
363 }
364
365 $form_state['redirect'] = 'admin/config/services/aggregator';
366 }
367
383 function _aggregator_parse_opml($opml) {
384 $feeds = array();
385 $xml_parser = drupal_xml_parser_create($opml);
386 if (xml_parse_into_struct($xml_parser, $opml, $values)) {
387 foreach ($values as $entry) {
388 if ($entry['tag'] == 'OUTLINE' && isset($entry['attributes'])) {
389 $item = $entry['attributes'];
390 if (!empty($item['XMLURL']) && !empty($item['TEXT'])) {
391 $feeds[] = array('title' => $item['TEXT'], 'url' => $item['XMLURL']);
392 }
393 }
394 }
395 }
396 xml_parser_free($xml_parser);
397
398 return $feeds;
399 }
400
407 function aggregator_admin_refresh_feed($feed) {
408 if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], 'aggregator/update/' . $feed->fid)) {
409 return MENU_ACCESS_DENIED;
410 }
411 aggregator_refresh($feed);
412 drupal_goto('admin/config/services/aggregator');
413 }
414
421 function aggregator_admin_form($form, $form_state) {
422 // Global aggregator settings.
423 $form['aggregator_allowed_html_tags'] = array(
424 '#type' => 'textfield',
425 '#title' => t('Allowed HTML tags'),
426 '#size' => 80,
427 '#maxlength' => 255,
428 '#default_value' => variable_get('aggregator_allowed_html_tags', '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'),
429 '#description' => t('A space-separated list of HTML tags allowed in the content of feed items. Disallowed tags are stripped from the content.'),
430 );
431
432 // Make sure configuration is sane.
433 aggregator_sanitize_configuration();
434
435 // Get all available fetchers.
436 $fetchers = module_implements('aggregator_fetch');
437 foreach ($fetchers as $k => $module) {
438 if ($info = module_invoke($module, 'aggregator_fetch_info')) {
439 $label = $info['title'] . ' <span class="description">' . $info['description'] . '</span>';
440 }
441 else {
442 $label = $module;
443 }
444 unset($fetchers[$k]);
445 $fetchers[$module] = $label;
446 }
447
448 // Get all available parsers.
449 $parsers = module_implements('aggregator_parse');
450 foreach ($parsers as $k => $module) {
451 if ($info = module_invoke($module, 'aggregator_parse_info')) {
452 $label = $info['title'] . ' <span class="description">' . $info['description'] . '</span>';
453 }
454 else {
455 $label = $module;
456 }
457 unset($parsers[$k]);
458 $parsers[$module] = $label;
459 }
460
461 // Get all available processors.
462 $processors = module_implements('aggregator_process');
463 foreach ($processors as $k => $module) {
464 if ($info = module_invoke($module, 'aggregator_process_info')) {
465 $label = $info['title'] . ' <span class="description">' . $info['description'] . '</span>';
466 }
467 else {
468 $label = $module;
469 }
470 unset($processors[$k]);
471 $processors[$module] = $label;
472 }
473
474 // Only show basic configuration if there are actually options.
475 $basic_conf = array();
476 if (count($fetchers) > 1) {
477 $basic_conf['aggregator_fetcher'] = array(
478 '#type' => 'radios',
479 '#title' => t('Fetcher'),
480 '#description' => t('Fetchers download data from an external source. Choose a fetcher suitable for the external source you would like to download from.'),
481 '#options' => $fetchers,
482 '#default_value' => variable_get('aggregator_fetcher', 'aggregator'),
483 );
484 }
485 if (count($parsers) > 1) {
486 $basic_conf['aggregator_parser'] = array(
487 '#type' => 'radios',
488 '#title' => t('Parser'),
489 '#description' => t('Parsers transform downloaded data into standard structures. Choose a parser suitable for the type of feeds you would like to aggregate.'),
490 '#options' => $parsers,
491 '#default_value' => variable_get('aggregator_parser', 'aggregator'),
492 );
493 }
494 if (count($processors) > 1) {
495 $basic_conf['aggregator_processors'] = array(
496 '#type' => 'checkboxes',
497 '#title' => t('Processors'),
498 '#description' => t('Processors act on parsed feed data, for example they store feed items. Choose the processors suitable for your task.'),
499 '#options' => $processors,
500 '#default_value' => variable_get('aggregator_processors', array('aggregator')),
501 );
502 }
503 if (count($basic_conf)) {
504 $form['basic_conf'] = array(
505 '#type' => 'fieldset',
506 '#title' => t('Basic configuration'),
507 '#description' => t('For most aggregation tasks, the default settings are fine.'),
508 '#collapsible' => TRUE,
509 '#collapsed' => FALSE,
510 );
511 $form['basic_conf'] += $basic_conf;
512 }
513
514 // Implementing modules will expect an array at $form['modules'].
515 $form['modules'] = array();
516
517 $form['actions'] = array('#type' => 'actions');
518 $form['actions']['submit'] = array(
519 '#type' => 'submit',
520 '#value' => t('Save configuration'),
521 );
522
523 return $form;
524 }
525
529 function aggregator_admin_form_submit($form, &$form_state) {
530 if (isset($form_state['values']['aggregator_processors'])) {
531 $form_state['values']['aggregator_processors'] = array_filter($form_state['values']['aggregator_processors']);
532 }
533 system_settings_form_submit($form, $form_state);
534 }
535
549 function aggregator_form_category($form, &$form_state, $edit = array('title' => '', 'description' => '', 'cid' => NULL)) {
550 $form['title'] = array('#type' => 'textfield',
551 '#title' => t('Title'),
552 '#default_value' => $edit['title'],
553 '#maxlength' => 64,
554 '#required' => TRUE,
555 );
556 $form['description'] = array('#type' => 'textarea',
557 '#title' => t('Description'),
558 '#default_value' => $edit['description'],
559 );
560 $form['actions'] = array('#type' => 'actions');
561 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
562 if ($edit['cid']) {
563 $form['actions']['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
564 $form['cid'] = array('#type' => 'hidden', '#value' => $edit['cid']);
565 }
566
567 return $form;
568 }
569
575 function aggregator_form_category_validate($form, &$form_state) {
576 if ($form_state['values']['op'] == t('Save')) {
577 // Check for duplicate titles
578 if (isset($form_state['values']['cid'])) {
579 $category = db_query("SELECT cid FROM {aggregator_category} WHERE title = :title AND cid <> :cid", array(':title' => $form_state['values']['title'], ':cid' => $form_state['values']['cid']))->fetchObject();
580 }
581 else {
582 $category = db_query("SELECT cid FROM {aggregator_category} WHERE title = :title", array(':title' => $form_state['values']['title']))->fetchObject();
583 }
584 if ($category) {
585 form_set_error('title', t('A category named %category already exists. Enter a unique title.', array('%category' => $form_state['values']['title'])));
586 }
587 }
588 }
589
597 function aggregator_form_category_submit($form, &$form_state) {
598 if ($form_state['values']['op'] == t('Delete')) {
599 $title = $form_state['values']['title'];
600 // Unset the title.
601 unset($form_state['values']['title']);
602 }
603 aggregator_save_category($form_state['values']);
604 if (isset($form_state['values']['cid'])) {
605 if (isset($form_state['values']['title'])) {
606 drupal_set_message(t('The category %category has been updated.', array('%category' => $form_state['values']['title'])));
607 if (arg(0) == 'admin') {
608 $form_state['redirect'] = 'admin/config/services/aggregator/';
609 return;
610 }
611 else {
612 $form_state['redirect'] = 'aggregator/categories/' . $form_state['values']['cid'];
613 return;
614 }
615 }
616 else {
617 watchdog('aggregator', 'Category %category deleted.', array('%category' => $title));
618 drupal_set_message(t('The category %category has been deleted.', array('%category' => $title)));
619 if (arg(0) == 'admin') {
620 $form_state['redirect'] = 'admin/config/services/aggregator/';
621 return;
622 }
623 else {
624 $form_state['redirect'] = 'aggregator/categories/';
625 return;
626 }
627 }
628 }
629 else {
630 watchdog('aggregator', 'Category %category added.', array('%category' => $form_state['values']['title']), WATCHDOG_NOTICE, l(t('view'), 'admin/config/services/aggregator'));
631 drupal_set_message(t('The category %category has been added.', array('%category' => $form_state['values']['title'])));
632 }
633 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
l
l($text, $path, array $options=array())
Definition: common.inc:2432
aggregator_admin_remove_feed_submit
aggregator_admin_remove_feed_submit($form, &$form_state)
Definition: aggregator.admin.inc:238
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
MENU_ACCESS_DENIED
const MENU_ACCESS_DENIED
Definition: menu.inc:239
$module
print $module
Definition: search-results.tpl.php:28
aggregator_admin_form
aggregator_admin_form($form, $form_state)
Definition: aggregator.admin.inc:421
$header
print $header
Definition: forum-topic-list.tpl.php:42
aggregator_save_feed
aggregator_save_feed($edit)
Definition: aggregator.module:491
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
drupal_http_request
drupal_http_request($url, array $options=array())
Definition: common.inc:787
aggregator_form_feed
aggregator_form_feed($form, &$form_state, stdClass $feed=NULL)
Definition: aggregator.admin.inc:66
aggregator_sanitize_configuration
aggregator_sanitize_configuration()
Definition: aggregator.module:747
aggregator_admin_form_submit
aggregator_admin_form_submit($form, &$form_state)
Definition: aggregator.admin.inc:529
aggregator_form_feed_validate
aggregator_form_feed_validate($form, &$form_state)
Definition: aggregator.admin.inc:140
aggregator_form_category
aggregator_form_category($form, &$form_state, $edit=array('title'=> '', 'description'=> '', 'cid'=> NULL))
Definition: aggregator.admin.inc:549
aggregator_admin_refresh_feed
aggregator_admin_refresh_feed($feed)
Definition: aggregator.admin.inc:407
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
aggregator_form_opml_submit
aggregator_form_opml_submit($form, &$form_state)
Definition: aggregator.admin.inc:319
aggregator_form_category_validate
aggregator_form_category_validate($form, &$form_state)
Definition: aggregator.admin.inc:575
drupal_valid_token
drupal_valid_token($token, $value= '', $skip_anonymous=FALSE)
Definition: common.inc:5095
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
aggregator_form_opml_validate
aggregator_form_opml_validate($form, &$form_state)
Definition: aggregator.admin.inc:302
$info
$info
Definition: color.inc:6
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$output
$output
Definition: authorize.php:93
aggregator_form_feed_submit
aggregator_form_feed_submit($form, &$form_state)
Definition: aggregator.admin.inc:171
file_save_upload
file_save_upload($source, $validators=array(), $destination=FALSE, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1437
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
aggregator_form_opml
aggregator_form_opml($form, &$form_state)
Definition: aggregator.admin.inc:250
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
aggregator_refresh
aggregator_refresh($feed)
Definition: aggregator.module:612
drupal_form_submit
drupal_form_submit($form_id, &$form_state)
Definition: form.inc:685
aggregator_remove
aggregator_remove($feed)
Definition: aggregator.module:567
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
system_settings_form_submit
system_settings_form_submit($form, &$form_state)
Definition: system.module:2776
drupal_get_token
drupal_get_token($value= '')
Definition: common.inc:5077
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
aggregator_save_category
aggregator_save_category($edit)
Definition: aggregator.module:440
aggregator_form_category_submit
aggregator_form_category_submit($form, &$form_state)
Definition: aggregator.admin.inc:597
valid_url
valid_url($url, $absolute=FALSE)
Definition: common.inc:1204
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
_aggregator_parse_opml
_aggregator_parse_opml($opml)
Definition: aggregator.admin.inc:383
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
aggregator_admin_overview
aggregator_admin_overview()
Definition: aggregator.admin.inc:11
drupal_xml_parser_create
drupal_xml_parser_create(&$data)
Definition: unicode.inc:184
aggregator_view
aggregator_view()
Definition: aggregator.admin.inc:21
aggregator_admin_remove_feed
aggregator_admin_remove_feed($form, $form_state, $feed)
Definition: aggregator.admin.inc:217
AGGREGATOR_CLEAR_NEVER
const AGGREGATOR_CLEAR_NEVER
Definition: aggregator.module:11
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/form_example/form_example_wizard.inc Source File

  • examples
  • form_example
form_example_wizard.inc
Go to the documentation of this file.
1 <?php
2
44 function _form_example_steps() {
45 return array(
46 1 => array(
47 'form' => 'form_example_wizard_personal_info',
48 ),
49 2 => array(
50 'form' => 'form_example_wizard_location_info',
51 ),
52 3 => array(
53 'form' => 'form_example_wizard_other_info',
54 ),
55 );
56 }
57
77 function form_example_wizard($form, &$form_state) {
78
79 // Initialize a description of the steps for the wizard.
80 if (empty($form_state['step'])) {
81 $form_state['step'] = 1;
82
83 // This array contains the function to be called at each step to get the
84 // relevant form elements. It will also store state information for each
85 // step.
86 $form_state['step_information'] = _form_example_steps();
87 }
88 $step = &$form_state['step'];
89 drupal_set_title(t('Extensible Wizard: Step @step', array('@step' => $step)));
90
91 // Call the function named in $form_state['step_information'] to get the
92 // form elements to display for this step.
93 $form = $form_state['step_information'][$step]['form']($form, $form_state);
94
95 // Show the 'previous' button if appropriate. Note that #submit is set to
96 // a special submit handler, and that we use #limit_validation_errors to
97 // skip all complaints about validation when using the back button. The
98 // values entered will be discarded, but they will not be validated, which
99 // would be annoying in a "back" button.
100 if ($step > 1) {
101 $form['prev'] = array(
102 '#type' => 'submit',
103 '#value' => t('Previous'),
104 '#name' => 'prev',
105 '#submit' => array('form_example_wizard_previous_submit'),
106 '#limit_validation_errors' => array(),
107 );
108 }
109
110 // Show the Next button only if there are more steps defined.
111 if ($step < count($form_state['step_information'])) {
112 // The Next button should be included on every step
113 $form['next'] = array(
114 '#type' => 'submit',
115 '#value' => t('Next'),
116 '#name' => 'next',
117 '#submit' => array('form_example_wizard_next_submit'),
118 );
119 }
120 else {
121 // Just in case there are no more steps, we use the default submit handler
122 // of the form wizard. Call this button Finish, Submit, or whatever you
123 // want to show. When this button is clicked, the
124 // form_example_wizard_submit handler will be called.
125 $form['finish'] = array(
126 '#type' => 'submit',
127 '#value' => t('Finish'),
128 );
129 }
130
131 // Include each validation function defined for the different steps.
132 if (function_exists($form_state['step_information'][$step]['form'] . '_validate')) {
133 $form['next']['#validate'] = array($form_state['step_information'][$step]['form'] . '_validate');
134 }
135
136 return $form;
137 }
138
150 function form_example_wizard_previous_submit($form, &$form_state) {
151 $current_step = &$form_state['step'];
152 $form_state['step_information'][$current_step]['stored_values'] = $form_state['values'];
153 if ($current_step > 1) {
154 $current_step--;
155 $form_state['values'] = $form_state['step_information'][$current_step]['stored_values'];
156 }
157 $form_state['rebuild'] = TRUE;
158 }
159
175 function form_example_wizard_next_submit($form, &$form_state) {
176 $current_step = &$form_state['step'];
177 $form_state['step_information'][$current_step]['stored_values'] = $form_state['values'];
178
179 if ($current_step < count($form_state['step_information'])) {
180 $current_step++;
181 if (!empty($form_state['step_information'][$current_step]['stored_values'])) {
182 $form_state['values'] = $form_state['step_information'][$current_step]['stored_values'];
183 }
184 else {
185 $form_state['values'] = array();
186 }
187 $form_state['rebuild'] = TRUE; // Force rebuild with next step.
188 return;
189 }
190 }
191
211 function form_example_wizard_personal_info($form, &$form_state) {
212 $form = array();
213 $form['first_name'] = array(
214 '#type' => 'textfield',
215 '#title' => t('First Name'),
216 '#default_value' => !empty($form_state['values']['first_name']) ? $form_state['values']['first_name'] : '',
217 );
218 $form['last_name'] = array(
219 '#type' => 'textfield',
220 '#title' => t('Last Name'),
221 '#default_value' => !empty($form_state['values']['last_name']) ? $form_state['values']['last_name'] : '',
222 );
223 return $form;
224 }
225
233 function form_example_wizard_location_info($form, &$form_state) {
234 $form = array();
235 $form['city'] = array(
236 '#type' => 'textfield',
237 '#title' => t('City'),
238 '#description' => t('Hint: Do not enter "San Francisco", and do not leave this out.'),
239 '#required' => TRUE,
240 '#default_value' => !empty($form_state['values']['city']) ? $form_state['values']['city'] : '',
241
242 );
243 return $form;
244 }
245
254 function form_example_wizard_location_info_validate($form, &$form_state) {
255 if ($form_state['values']['city'] == 'San Francisco') {
256 form_set_error('city', t('You were warned not to enter "San Francisco"'));
257 }
258 }
259
266 function form_example_wizard_other_info($form, &$form_state) {
267 $form = array();
268 $form['aunts_name'] = array(
269 '#type' => 'textfield',
270 '#title' => t("Your first cousin's aunt's Social Security number"),
271 '#default_value' => !empty($form_state['values']['aunts_name']) ? $form_state['values']['aunts_name'] : '',
272 );
273 return $form;
274 }
275
276 // And now comes the magic of the wizard, the function that should handle all the
277 // inputs from the user on each different step.
291 function form_example_wizard_submit($form, &$form_state) {
292 $current_step = &$form_state['step'];
293 $form_state['step_information'][$current_step]['stored_values'] = $form_state['values'];
294
295 // In this case we've completed the final page of the wizard, so process the
296 // submitted information.
297 drupal_set_message(t('This information was collected by this wizard:'));
298 foreach ($form_state['step_information'] as $index => $value) {
299 // Remove FAPI fields included in the values (form_token, form_id and form_build_id
300 // This is not required, you may access the values using $value['stored_values']
301 // but I'm removing them to make a more clear representation of the collected
302 // information as the complete array will be passed through drupal_set_message().
303 unset($value['stored_values']['form_id']);
304 unset($value['stored_values']['form_build_id']);
305 unset($value['stored_values']['form_token']);
306
307 // Now show all the values.
308 drupal_set_message(t('Step @num collected the following values: <pre>@result</pre>', array('@num' => $index, '@result' => print_r($value['stored_values'], TRUE))));
309 }
310 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
form_example_wizard_location_info
form_example_wizard_location_info($form, &$form_state)
Definition: form_example_wizard.inc:233
form_example_wizard_submit
form_example_wizard_submit($form, &$form_state)
Definition: form_example_wizard.inc:291
form_example_wizard_previous_submit
form_example_wizard_previous_submit($form, &$form_state)
Definition: form_example_wizard.inc:150
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
form_example_wizard_next_submit
form_example_wizard_next_submit($form, &$form_state)
Definition: form_example_wizard.inc:175
form_example_wizard_location_info_validate
form_example_wizard_location_info_validate($form, &$form_state)
Definition: form_example_wizard.inc:254
form_example_wizard
form_example_wizard($form, &$form_state)
Definition: form_example_wizard.inc:77
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
_form_example_steps
_form_example_steps()
Definition: form_example_wizard.inc:44
form_example_wizard_personal_info
form_example_wizard_personal_info($form, &$form_state)
Definition: form_example_wizard.inc:211
form_example_wizard_other_info
form_example_wizard_other_info($form, &$form_state)
Definition: form_example_wizard.inc:266
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: update.php Source File

update.php
Go to the documentation of this file.
1 <?php
2
6 define('DRUPAL_ROOT', getcwd());
7
28 define('MAINTENANCE_MODE', 'update');
29
33 function update_selection_page() {
34 drupal_set_title('Drupal database update');
35 $elements = drupal_get_form('update_script_selection_form');
36 $output = drupal_render($elements);
37
38 update_task_list('select');
39
40 return $output;
41 }
42
46 function update_script_selection_form($form, &$form_state) {
47 $count = 0;
48 $incompatible_count = 0;
49 $form['start'] = array(
50 '#tree' => TRUE,
51 '#type' => 'fieldset',
52 '#collapsed' => TRUE,
53 '#collapsible' => TRUE,
54 );
55
56 // Ensure system.module's updates appear first.
57 $form['start']['system'] = array();
58
59 $updates = update_get_update_list();
60 $starting_updates = array();
61 $incompatible_updates_exist = FALSE;
62 foreach ($updates as $module => $update) {
63 if (!isset($update['start'])) {
64 $form['start'][$module] = array(
65 '#type' => 'item',
66 '#title' => $module . ' module',
67 '#markup' => $update['warning'],
68 '#prefix' => '<div class="messages warning">',
69 '#suffix' => '</div>',
70 );
71 $incompatible_updates_exist = TRUE;
72 continue;
73 }
74 if (!empty($update['pending'])) {
75 $starting_updates[$module] = $update['start'];
76 $form['start'][$module] = array(
77 '#type' => 'hidden',
78 '#value' => $update['start'],
79 );
80 $form['start'][$module . '_updates'] = array(
81 '#theme' => 'item_list',
82 '#items' => $update['pending'],
83 '#title' => $module . ' module',
84 );
85 }
86 if (isset($update['pending'])) {
87 $count = $count + count($update['pending']);
88 }
89 }
90
91 // Find and label any incompatible updates.
92 foreach (update_resolve_dependencies($starting_updates) as $function => $data) {
93 if (!$data['allowed']) {
94 $incompatible_updates_exist = TRUE;
95 $incompatible_count++;
96 $module_update_key = $data['module'] . '_updates';
97 if (isset($form['start'][$module_update_key]['#items'][$data['number']])) {
98 $text = $data['missing_dependencies'] ? 'This update will been skipped due to the following missing dependencies: <em>' . implode(', ', $data['missing_dependencies']) . '</em>' : "This update will be skipped due to an error in the module's code.";
99 $form['start'][$module_update_key]['#items'][$data['number']] .= '<div class="warning">' . $text . '</div>';
100 }
101 // Move the module containing this update to the top of the list.
102 $form['start'] = array($module_update_key => $form['start'][$module_update_key]) + $form['start'];
103 }
104 }
105
106 // Warn the user if any updates were incompatible.
107 if ($incompatible_updates_exist) {
108 drupal_set_message('Some of the pending updates cannot be applied because their dependencies were not met.', 'warning');
109 }
110
111 if (empty($count)) {
112 drupal_set_message(t('No pending updates.'));
113 unset($form);
114 $form['links'] = array(
115 '#markup' => theme('item_list', array('items' => update_helpful_links())),
116 );
117
118 // No updates to run, so caches won't get flushed later. Clear them now.
119 drupal_flush_all_caches();
120 }
121 else {
122 $form['help'] = array(
123 '#markup' => '<p>The version of Drupal you are updating from has been automatically detected.</p>',
124 '#weight' => -5,
125 );
126 if ($incompatible_count) {
127 $form['start']['#title'] = format_plural(
128 $count,
129 '1 pending update (@number_applied to be applied, @number_incompatible skipped)',
130 '@count pending updates (@number_applied to be applied, @number_incompatible skipped)',
131 array('@number_applied' => $count - $incompatible_count, '@number_incompatible' => $incompatible_count)
132 );
133 }
134 else {
135 $form['start']['#title'] = format_plural($count, '1 pending update', '@count pending updates');
136 }
137 $form['has_js'] = array(
138 '#type' => 'hidden',
139 '#default_value' => FALSE,
140 );
141 $form['actions'] = array('#type' => 'actions');
142 $form['actions']['submit'] = array(
143 '#type' => 'submit',
144 '#value' => 'Apply pending updates',
145 );
146 }
147 return $form;
148 }
149
153 function update_helpful_links() {
154 $links[] = '<a href="' . base_path() . '">Front page</a>';
155 if (user_access('access administration pages')) {
156 $links[] = '<a href="' . base_path() . '?q=admin">Administration pages</a>';
157 }
158 return $links;
159 }
160
164 function update_results_page() {
165 drupal_set_title('Drupal database update');
166 $links = update_helpful_links();
167
168 update_task_list();
169 // Report end result.
170 if (module_exists('dblog') && user_access('access site reports')) {
171 $log_message = ' All errors have been <a href="' . base_path() . '?q=admin/reports/dblog">logged</a>.';
172 }
173 else {
174 $log_message = ' All errors have been logged.';
175 }
176
177 if ($_SESSION['update_success']) {
178 $output = '<p>Updates were attempted. If you see no failures below, you may proceed happily back to your <a href="' . base_path() . '">site</a>. Otherwise, you may need to update your database manually.' . $log_message . '</p>';
179 }
180 else {
181 $updates_remaining = reset($_SESSION['updates_remaining']);
182 list($module, $version) = array_pop($updates_remaining);
183 $output = '<p class="error">The update process was aborted prematurely while running <strong>update #' . $version . ' in ' . $module . '.module</strong>.' . $log_message;
184 if (module_exists('dblog')) {
185 $output .= ' You may need to check the <code>watchdog</code> database table manually.';
186 }
187 $output .= '</p>';
188 }
189
190 if (!empty($GLOBALS['update_free_access'])) {
191 $output .= "<p><strong>Reminder: don't forget to set the <code>\$update_free_access</code> value in your <code>settings.php</code> file back to <code>FALSE</code>.</strong></p>";
192 }
193
194 $output .= theme('item_list', array('items' => $links));
195
196 // Output a list of queries executed.
197 if (!empty($_SESSION['update_results'])) {
198 $all_messages = '';
199 foreach ($_SESSION['update_results'] as $module => $updates) {
200 if ($module != '#abort') {
201 $module_has_message = FALSE;
202 $query_messages = '';
203 foreach ($updates as $number => $queries) {
204 $messages = array();
205 foreach ($queries as $query) {
206 // If there is no message for this update, don't show anything.
207 if (empty($query['query'])) {
208 continue;
209 }
210
211 if ($query['success']) {
212 $messages[] = '<li class="success">' . $query['query'] . '</li>';
213 }
214 else {
215 $messages[] = '<li class="failure"><strong>Failed:</strong> ' . $query['query'] . '</li>';
216 }
217 }
218
219 if ($messages) {
220 $module_has_message = TRUE;
221 $query_messages .= '<h4>Update #' . $number . "</h4>\n";
222 $query_messages .= '<ul>' . implode("\n", $messages) . "</ul>\n";
223 }
224 }
225
226 // If there were any messages in the queries then prefix them with the
227 // module name and add it to the global message list.
228 if ($module_has_message) {
229 $all_messages .= '<h3>' . $module . " module</h3>\n" . $query_messages;
230 }
231 }
232 }
233 if ($all_messages) {
234 $output .= '<div id="update-results"><h2>The following updates returned messages</h2>';
235 $output .= $all_messages;
236 $output .= '</div>';
237 }
238 }
239 unset($_SESSION['update_results']);
240 unset($_SESSION['update_success']);
241
242 return $output;
243 }
244
254 function update_info_page() {
255 // Change query-strings on css/js files to enforce reload for all users.
256 _drupal_flush_css_js();
257 // Flush the cache of all data for the update status module.
258 if (db_table_exists('cache_update')) {
259 cache_clear_all('*', 'cache_update', TRUE);
260 }
261
262 update_task_list('info');
263 drupal_set_title('Drupal database update');
264 $token = drupal_get_token('update');
265 $output = '<p>Use this utility to update your database whenever a new release of Drupal or a module is installed.</p><p>For more detailed information, see the <a href="http://drupal.org/upgrade">upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>';
266 $output .= "<ol>\n";
267 $output .= "<li><strong>Back up your database</strong>. This process will change your database values and in case of emergency you may need to revert to a backup.</li>\n";
268 $output .= "<li><strong>Back up your code</strong>. Hint: when backing up module code, do not leave that backup in the 'modules' or 'sites/*/modules' directories as this may confuse Drupal's auto-discovery mechanism.</li>\n";
269 $output .= '<li>Put your site into <a href="' . base_path() . '?q=admin/config/development/maintenance">maintenance mode</a>.</li>' . "\n";
270 $output .= "<li>Install your new files in the appropriate location, as described in the handbook.</li>\n";
271 $output .= "</ol>\n";
272 $output .= "<p>When you have performed the steps above, you may proceed.</p>\n";
273 $form_action = check_url(drupal_current_script_url(array('op' => 'selection', 'token' => $token)));
274 $output .= '<form method="post" action="' . $form_action . '"><p><input type="submit" value="Continue" class="form-submit" /></p></form>';
275 $output .= "\n";
276 return $output;
277 }
278
285 function update_access_denied_page() {
286 drupal_add_http_header('Status', '403 Forbidden');
287 watchdog('access denied', 'update.php', NULL, WATCHDOG_WARNING);
288 drupal_set_title('Access denied');
289 return '<p>Access denied. You are not authorized to access this page. Log in using either an account with the <em>administer software updates</em> permission or the site maintenance account (the account you created during installation). If you cannot log in, you will have to edit <code>settings.php</code> to bypass this access check. To do this:</p>
290 <ol>
291 <li>With a text editor find the settings.php file on your system. From the main Drupal directory that you installed all the files into, go to <code>sites/your_site_name</code> if such directory exists, or else to <code>sites/default</code> which applies otherwise.</li>
292 <li>There is a line inside your settings.php file that says <code>$update_free_access = FALSE;</code>. Change it to <code>$update_free_access = TRUE;</code>.</li>
293 <li>As soon as the update.php script is done, you must change the settings.php file back to its original form with <code>$update_free_access = FALSE;</code>.</li>
294 <li>To avoid having this problem in the future, remember to log in to your website using either an account with the <em>administer software updates</em> permission or the site maintenance account (the account you created during installation) before you backup your database at the beginning of the update process.</li>
295 </ol>';
296 }
297
304 function update_access_allowed() {
305 global $update_free_access, $user;
306
307 // Allow the global variable in settings.php to override the access check.
308 if (!empty($update_free_access)) {
309 return TRUE;
310 }
311 // Calls to user_access() might fail during the Drupal 6 to 7 update process,
312 // so we fall back on requiring that the user be logged in as user #1.
313 try {
314 require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'user') . '/user.module';
315 return user_access('administer software updates');
316 }
317 catch (Exception $e) {
318 return ($user->uid == 1);
319 }
320 }
321
325 function update_task_list($active = NULL) {
326 // Default list of tasks.
327 $tasks = array(
328 'requirements' => 'Verify requirements',
329 'info' => 'Overview',
330 'select' => 'Review updates',
331 'run' => 'Run updates',
332 'finished' => 'Review log',
333 );
334
335 drupal_add_region_content('sidebar_first', theme('task_list', array('items' => $tasks, 'active' => $active)));
336 }
337
341 function update_extra_requirements($requirements = NULL) {
342 static $extra_requirements = array();
343 if (isset($requirements)) {
344 $extra_requirements += $requirements;
345 }
346 return $extra_requirements;
347 }
348
357 function update_check_requirements($skip_warnings = FALSE) {
358 // Check requirements of all loaded modules.
359 $requirements = module_invoke_all('requirements', 'update');
360 $requirements += update_extra_requirements();
361 $severity = drupal_requirements_severity($requirements);
362
363 // If there are errors, always display them. If there are only warnings, skip
364 // them if the caller has indicated they should be skipped.
365 if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && !$skip_warnings)) {
366 update_task_list('requirements');
367 drupal_set_title('Requirements problem');
368 $status_report = theme('status_report', array('requirements' => $requirements));
369 $status_report .= 'Check the error messages and <a href="' . check_url(drupal_requirements_url($severity)) . '">try again</a>.';
370 print theme('update_page', array('content' => $status_report));
371 exit();
372 }
373 }
374
375 // Some unavoidable errors happen because the database is not yet up-to-date.
376 // Our custom error handler is not yet installed, so we just suppress them.
377 ini_set('display_errors', FALSE);
378
379 // We prepare a minimal bootstrap for the update requirements check to avoid
380 // reaching the PHP memory limit.
381 require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
382 require_once DRUPAL_ROOT . '/includes/update.inc';
383 require_once DRUPAL_ROOT . '/includes/common.inc';
384 require_once DRUPAL_ROOT . '/includes/file.inc';
385 require_once DRUPAL_ROOT . '/includes/entity.inc';
386 require_once DRUPAL_ROOT . '/includes/unicode.inc';
387 update_prepare_d7_bootstrap();
388
389 // Temporarily disable configurable timezones so the upgrade process uses the
390 // site-wide timezone. This prevents a PHP notice during session initlization
391 // and before offsets have been converted in user_update_7002().
392 $configurable_timezones = variable_get('configurable_timezones', 1);
393 $conf['configurable_timezones'] = 0;
394
395 // Determine if the current user has access to run update.php.
396 drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
397
398 // Reset configurable timezones.
399 $conf['configurable_timezones'] = $configurable_timezones;
400
401 // Only allow the requirements check to proceed if the current user has access
402 // to run updates (since it may expose sensitive information about the site's
403 // configuration).
404 $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
405 if (empty($op) && update_access_allowed()) {
406 require_once DRUPAL_ROOT . '/includes/install.inc';
407 require_once DRUPAL_ROOT . '/modules/system/system.install';
408
409 // Load module basics.
410 include_once DRUPAL_ROOT . '/includes/module.inc';
411 $module_list['system']['filename'] = 'modules/system/system.module';
412 module_list(TRUE, FALSE, FALSE, $module_list);
413 drupal_load('module', 'system');
414
415 // Reset the module_implements() cache so that any new hook implementations
416 // in updated code are picked up.
417 module_implements('', FALSE, TRUE);
418
419 // Set up $language, since the installer components require it.
420 drupal_language_initialize();
421
422 // Set up theme system for the maintenance page.
423 drupal_maintenance_theme();
424
425 // Check the update requirements for Drupal. Only report on errors at this
426 // stage, since the real requirements check happens further down.
427 update_check_requirements(TRUE);
428
429 // Redirect to the update information page if all requirements were met.
430 install_goto('update.php?op=info');
431 }
432
433 // update_fix_d7_requirements() needs to run before bootstrapping beyond path.
434 // So bootstrap to DRUPAL_BOOTSTRAP_LANGUAGE then include unicode.inc.
435
436 drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE);
437 include_once DRUPAL_ROOT . '/includes/unicode.inc';
438
439 update_fix_d7_requirements();
440
441 // Now proceed with a full bootstrap.
442
443 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
444 drupal_maintenance_theme();
445
446 // Turn error reporting back on. From now on, only fatal errors (which are
447 // not passed through the error handler) will cause a message to be printed.
448 ini_set('display_errors', TRUE);
449
450 // Only proceed with updates if the user is allowed to run them.
451 if (update_access_allowed()) {
452
453 include_once DRUPAL_ROOT . '/includes/install.inc';
454 include_once DRUPAL_ROOT . '/includes/batch.inc';
455 drupal_load_updates();
456
457 update_fix_compatibility();
458
459 // Check the update requirements for all modules. If there are warnings, but
460 // no errors, skip reporting them if the user has provided a URL parameter
461 // acknowledging the warnings and indicating a desire to continue anyway. See
462 // drupal_requirements_url().
463 $skip_warnings = !empty($_GET['continue']);
464 update_check_requirements($skip_warnings);
465
466 $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
467 switch ($op) {
468 // update.php ops.
469
470 case 'selection':
471 if (isset($_GET['token']) && drupal_valid_token($_GET['token'], 'update')) {
472 $output = update_selection_page();
473 break;
474 }
475
476 case 'Apply pending updates':
477 if (isset($_GET['token']) && drupal_valid_token($_GET['token'], 'update')) {
478 // Generate absolute URLs for the batch processing (using $base_root),
479 // since the batch API will pass them to url() which does not handle
480 // update.php correctly by default.
481 $batch_url = $base_root . drupal_current_script_url();
482 $redirect_url = $base_root . drupal_current_script_url(array('op' => 'results'));
483 update_batch($_POST['start'], $redirect_url, $batch_url);
484 break;
485 }
486
487 case 'info':
488 $output = update_info_page();
489 break;
490
491 case 'results':
492 $output = update_results_page();
493 break;
494
495 // Regular batch ops : defer to batch processing API.
496 default:
497 update_task_list('run');
498 $output = _batch_page();
499 break;
500 }
501 }
502 else {
503 $output = update_access_denied_page();
504 }
505 if (isset($output) && $output) {
506 // Explicitly start a session so that the update.php token will be accepted.
507 drupal_session_start();
508 // We defer the display of messages until all updates are done.
509 $progress_page = ($batch = batch_get()) && isset($batch['running']);
510 print theme('update_page', array('content' => $output, 'show_messages' => !$progress_page));
511 }
_batch_page
_batch_page()
Definition: batch.inc:43
module_list
module_list($refresh=FALSE, $bootstrap_refresh=FALSE, $sort=FALSE, $fixed_list=NULL)
Definition: module.inc:66
drupal_add_region_content
drupal_add_region_content($region=NULL, $data=NULL)
Definition: common.inc:175
$op
$op
Definition: update.php:404
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
update_get_update_list
update_get_update_list()
Definition: update.inc:1135
_drupal_flush_css_js
_drupal_flush_css_js()
Definition: common.inc:7495
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
update_script_selection_form
update_script_selection_form($form, &$form_state)
Definition: update.php:46
$module
print $module
Definition: search-results.tpl.php:28
check_url
check_url($uri)
Definition: common.inc:1387
update_access_allowed
update_access_allowed()
Definition: update.php:304
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
drupal_session_start
drupal_session_start()
Definition: session.inc:281
Exception
module_exists
module_exists($module)
Definition: module.inc:274
drupal_current_script_url
drupal_current_script_url($query=array())
Definition: install.inc:1060
print
print
Definition: php-2.php:2
REQUIREMENT_WARNING
const REQUIREMENT_WARNING
Definition: install.inc:31
drupal_bootstrap
drupal_bootstrap($phase=NULL, $new_phase=TRUE)
Definition: bootstrap.inc:2192
$configurable_timezones
$configurable_timezones
Definition: update.php:392
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
update_prepare_d7_bootstrap
update_prepare_d7_bootstrap()
Definition: update.inc:81
$conf
global $conf
Definition: authorize.php:74
update_check_requirements
update_check_requirements($skip_warnings=FALSE)
Definition: update.php:357
$module_list
$module_list['system']['filename']
Definition: authorize.php:78
update_info_page
update_info_page()
Definition: update.php:254
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
update_selection_page
update_selection_page()
Definition: update.php:33
DRUPAL_BOOTSTRAP_SESSION
const DRUPAL_BOOTSTRAP_SESSION
Definition: bootstrap.inc:142
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
drupal_load_updates
drupal_load_updates()
Definition: install.inc:81
drupal_requirements_severity
drupal_requirements_severity(&$requirements)
Definition: install.inc:1197
drupal_valid_token
drupal_valid_token($token, $value= '', $skip_anonymous=FALSE)
Definition: common.inc:5095
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
update_extra_requirements
update_extra_requirements($requirements=NULL)
Definition: update.php:341
$update_free_access
$update_free_access
Definition: default.settings.php:226
drupal_add_http_header
drupal_add_http_header($name, $value, $append=FALSE)
Definition: bootstrap.inc:1129
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$messages
print $messages
Definition: page.tpl.php:121
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
update_fix_d7_requirements
update_fix_d7_requirements()
Definition: update.inc:478
update_access_denied_page
update_access_denied_page()
Definition: update.php:285
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
drupal_maintenance_theme
drupal_maintenance_theme()
Definition: bootstrap.inc:2569
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
update_fix_compatibility
update_fix_compatibility()
Definition: update.inc:24
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
drupal_flush_all_caches
drupal_flush_all_caches()
Definition: common.inc:7453
drupal_language_initialize
drupal_language_initialize()
Definition: bootstrap.inc:2648
drupal_get_token
drupal_get_token($value= '')
Definition: common.inc:5077
update_resolve_dependencies
update_resolve_dependencies($starting_updates)
Definition: update.inc:1220
DRUPAL_BOOTSTRAP_LANGUAGE
const DRUPAL_BOOTSTRAP_LANGUAGE
Definition: bootstrap.inc:152
batch_get
& batch_get()
Definition: form.inc:4538
install_goto
install_goto($path)
Definition: install.inc:1027
update_results_page
update_results_page()
Definition: update.php:164
drupal_requirements_url
drupal_requirements_url($severity)
Definition: install.inc:1087
base_path
base_path()
Definition: common.inc:2817
update_helpful_links
update_helpful_links()
Definition: update.php:153
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
update_batch
update_batch($start, $redirect=NULL, $url=NULL, $batch=array(), $redirect_callback= 'drupal_goto')
Definition: update.inc:1032
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
drupal_load
drupal_load($type, $name)
Definition: bootstrap.inc:1093
update_task_list
update_task_list($active=NULL)
Definition: update.php:325
db_table_exists
db_table_exists($table)
Definition: database.inc:2760
$links
print $links
Definition: poll-results--block.tpl.php:28
DRUPAL_BOOTSTRAP_FULL
const DRUPAL_BOOTSTRAP_FULL
Definition: bootstrap.inc:157
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/translation/translation.pages.inc Source File

  • modules
  • translation
translation.pages.inc
Go to the documentation of this file.
1 <?php
2
19 function translation_node_overview($node) {
20 include_once DRUPAL_ROOT . '/includes/language.inc';
21
22 if ($node->tnid) {
23 // Already part of a set, grab that set.
24 $tnid = $node->tnid;
25 $translations = translation_node_get_translations($node->tnid);
26 }
27 else {
28 // We have no translation source nid, this could be a new set, emulate that.
29 $tnid = $node->nid;
30 $translations = array(entity_language('node', $node) => $node);
31 }
32
33 $type = variable_get('translation_language_type', LANGUAGE_TYPE_INTERFACE);
34 $header = array(t('Language'), t('Title'), t('Status'), t('Operations'));
35
36 foreach (language_list() as $langcode => $language) {
37 $options = array();
38 $language_name = $language->name;
39 if (isset($translations[$langcode])) {
40 // Existing translation in the translation set: display status.
41 // We load the full node to check whether the user can edit it.
42 $translation_node = node_load($translations[$langcode]->nid);
43 $path = 'node/' . $translation_node->nid;
44 $links = language_negotiation_get_switch_links($type, $path);
45 $title = empty($links->links[$langcode]['href']) ? l($translation_node->title, $path) : l($translation_node->title, $links->links[$langcode]['href'], $links->links[$langcode]);
46 if (node_access('update', $translation_node)) {
47 $text = t('edit');
48 $path = 'node/' . $translation_node->nid . '/edit';
49 $links = language_negotiation_get_switch_links($type, $path);
50 $options[] = empty($links->links[$langcode]['href']) ? l($text, $path) : l($text, $links->links[$langcode]['href'], $links->links[$langcode]);
51 }
52 $status = $translation_node->status ? t('Published') : t('Not published');
53 $status .= $translation_node->translate ? ' - <span class="marker">' . t('outdated') . '</span>' : '';
54 if ($translation_node->nid == $tnid) {
55 $language_name = t('<strong>@language_name</strong> (source)', array('@language_name' => $language_name));
56 }
57 }
58 else {
59 // No such translation in the set yet: help user to create it.
60 $title = t('n/a');
61 if (node_access('create', $node)) {
62 $text = t('add translation');
63 $path = 'node/add/' . str_replace('_', '-', $node->type);
64 $links = language_negotiation_get_switch_links($type, $path);
65 $query = array('query' => array('translation' => $node->nid, 'target' => $langcode));
66 $options[] = empty($links->links[$langcode]['href']) ? l($text, $path, $query) : l($text, $links->links[$langcode]['href'], array_merge_recursive($links->links[$langcode], $query));
67 }
68 $status = t('Not translated');
69 }
70 $rows[] = array($language_name, $title, $status, implode(" | ", $options));
71 }
72
73 drupal_set_title(t('Translations of %title', array('%title' => $node->title)), PASS_THROUGH);
74
75 $build['translation_node_overview'] = array(
76 '#theme' => 'table',
77 '#header' => $header,
78 '#rows' => $rows,
79 );
80
81 return $build;
82 }
translation_node_overview
translation_node_overview($node)
Definition: translation.pages.inc:19
l
l($text, $path, array $options=array())
Definition: common.inc:2432
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
$header
print $header
Definition: forum-topic-list.tpl.php:42
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
nid
print $node nid
Definition: book-node-export-html.tpl.php:21
language_list
language_list($field= 'language')
Definition: bootstrap.inc:2723
language_negotiation_get_switch_links
language_negotiation_get_switch_links($type, $path)
Definition: language.inc:279
entity_language
entity_language($entity_type, $entity)
Definition: common.inc:7967
translation_node_get_translations
translation_node_get_translations($tnid)
Definition: translation.module:461
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
node_access
node_access($op, $node, $account=NULL)
Definition: node.module:2981
LANGUAGE_TYPE_INTERFACE
const LANGUAGE_TYPE_INTERFACE
Definition: bootstrap.inc:191
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
$links
print $links
Definition: poll-results--block.tpl.php:28
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/filetransfer/filetransfer.inc Source File

  • includes
  • filetransfer
filetransfer.inc
Go to the documentation of this file.
1 <?php
2
3 /*
4 * Base FileTransfer class.
5 *
6 * Classes extending this class perform file operations on directories not
7 * writable by the webserver. To achieve this, the class should connect back
8 * to the server using some backend (for example FTP or SSH). To keep security,
9 * the password should always be asked from the user and never stored. For
10 * safety, all methods operate only inside a "jail", by default the Drupal root.
11 */
12 abstract class FileTransfer {
13 protected $username;
14 protected $password;
15 protected $hostname = 'localhost';
16 protected $port;
17
22 function __construct($jail) {
23 $this->jail = $jail;
24 }
25
40 static function factory($jail, $settings) {
41 throw new FileTransferException('FileTransfer::factory() static method not overridden by FileTransfer subclass.');
42 }
43
51 function __get($name) {
52 if ($name == 'connection') {
53 $this->connect();
54 return $this->connection;
55 }
56
57 if ($name == 'chroot') {
58 $this->setChroot();
59 return $this->chroot;
60 }
61 }
62
66 abstract protected function connect();
67
76 public final function copyDirectory($source, $destination) {
77 $source = $this->sanitizePath($source);
78 $destination = $this->fixRemotePath($destination);
79 $this->checkPath($destination);
80 $this->copyDirectoryJailed($source, $destination);
81 }
82
90 public final function chmod($path, $mode, $recursive = FALSE) {
91 if (!in_array('FileTransferChmodInterface', class_implements(get_class($this)))) {
92 throw new FileTransferException('Unable to change file permissions');
93 }
94 $path = $this->sanitizePath($path);
95 $path = $this->fixRemotePath($path);
96 $this->checkPath($path);
97 $this->chmodJailed($path, $mode, $recursive);
98 }
99
106 public final function createDirectory($directory) {
107 $directory = $this->fixRemotePath($directory);
108 $this->checkPath($directory);
109 $this->createDirectoryJailed($directory);
110 }
111
118 public final function removeDirectory($directory) {
119 $directory = $this->fixRemotePath($directory);
120 $this->checkPath($directory);
121 $this->removeDirectoryJailed($directory);
122 }
123
132 public final function copyFile($source, $destination) {
133 $source = $this->sanitizePath($source);
134 $destination = $this->fixRemotePath($destination);
135 $this->checkPath($destination);
136 $this->copyFileJailed($source, $destination);
137 }
138
145 public final function removeFile($destination) {
146 $destination = $this->fixRemotePath($destination);
147 $this->checkPath($destination);
148 $this->removeFileJailed($destination);
149 }
150
157 protected final function checkPath($path) {
158 $full_jail = $this->chroot . $this->jail;
159 $full_path = drupal_realpath(substr($this->chroot . $path, 0, strlen($full_jail)));
160 $full_path = $this->fixRemotePath($full_path, FALSE);
161 if ($full_jail !== $full_path) {
162 throw new FileTransferException('@directory is outside of the @jail', NULL, array('@directory' => $path, '@jail' => $this->jail));
163 }
164 }
165
177 protected final function fixRemotePath($path, $strip_chroot = TRUE) {
178 $path = $this->sanitizePath($path);
179 $path = preg_replace('|^([a-z]{1}):|i', '', $path); // Strip out windows driveletter if its there.
180 if ($strip_chroot) {
181 if ($this->chroot && strpos($path, $this->chroot) === 0) {
182 $path = ($path == $this->chroot) ? '' : substr($path, strlen($this->chroot));
183 }
184 }
185 return $path;
186 }
187
194 function sanitizePath($path) {
195 $path = str_replace('\\', '/', $path); // Windows path sanitization.
196 if (substr($path, -1) == '/') {
197 $path = substr($path, 0, -1);
198 }
199 return $path;
200 }
201
212 protected function copyDirectoryJailed($source, $destination) {
213 if ($this->isDirectory($destination)) {
214 $destination = $destination . '/' . drupal_basename($source);
215 }
216 $this->createDirectory($destination);
217 foreach (new RecursiveIteratorIterator(new SkipDotsRecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) {
218 $relative_path = substr($filename, strlen($source));
219 if ($file->isDir()) {
220 $this->createDirectory($destination . $relative_path);
221 }
222 else {
223 $this->copyFile($file->getPathName(), $destination . $relative_path);
224 }
225 }
226 }
227
234 abstract protected function createDirectoryJailed($directory);
235
242 abstract protected function removeDirectoryJailed($directory);
243
252 abstract protected function copyFileJailed($source, $destination);
253
260 abstract protected function removeFileJailed($destination);
261
270 abstract public function isDirectory($path);
271
280 abstract public function isFile($path);
281
291 function findChroot() {
292 // If the file exists as is, there is no chroot.
293 $path = __FILE__;
294 $path = $this->fixRemotePath($path, FALSE);
295 if ($this->isFile($path)) {
296 return FALSE;
297 }
298
299 $path = dirname(__FILE__);
300 $path = $this->fixRemotePath($path, FALSE);
301 $parts = explode('/', $path);
302 $chroot = '';
303 while (count($parts)) {
304 $check = implode($parts, '/');
305 if ($this->isFile($check . '/' . drupal_basename(__FILE__))) {
306 // Remove the trailing slash.
307 return substr($chroot, 0, -1);
308 }
309 $chroot .= array_shift($parts) . '/';
310 }
311 return FALSE;
312 }
313
318 function setChroot() {
319 $this->chroot = $this->findChroot();
320 $this->jail = $this->fixRemotePath($this->jail);
321 }
322
329 public function getSettingsForm() {
330 $form['username'] = array(
331 '#type' => 'textfield',
332 '#title' => t('Username'),
333 );
334 $form['password'] = array(
335 '#type' => 'password',
336 '#title' => t('Password'),
337 '#description' => t('Your password is not saved in the database and is only used to establish a connection.'),
338 );
339 $form['advanced'] = array(
340 '#type' => 'fieldset',
341 '#title' => t('Advanced settings'),
342 '#collapsible' => TRUE,
343 '#collapsed' => TRUE,
344 );
345 $form['advanced']['hostname'] = array(
346 '#type' => 'textfield',
347 '#title' => t('Host'),
348 '#default_value' => 'localhost',
349 '#description' => t('The connection will be created between your web server and the machine hosting the web server files. In the vast majority of cases, this will be the same machine, and "localhost" is correct.'),
350 );
351 $form['advanced']['port'] = array(
352 '#type' => 'textfield',
353 '#title' => t('Port'),
354 '#default_value' => NULL,
355 );
356 return $form;
357 }
358 }
359
363 class FileTransferException extends Exception {
364 public $arguments;
365
366 function __construct($message, $code = 0, $arguments = array()) {
367 parent::__construct($message, $code);
368 $this->arguments = $arguments;
369 }
370 }
371
372
376 interface FileTransferChmodInterface {
377
388 function chmodJailed($path, $mode, $recursive);
389 }
390
400 class SkipDotsRecursiveDirectoryIterator extends RecursiveDirectoryIterator {
407 function __construct($path) {
408 parent::__construct($path);
409 $this->skipdots();
410 }
411
412 function rewind() {
413 parent::rewind();
414 $this->skipdots();
415 }
416
417 function next() {
418 parent::next();
419 $this->skipdots();
420 }
421
422 protected function skipdots() {
423 while ($this->isDot()) {
424 parent::next();
425 }
426 }
427 }
FileTransfer\createDirectory
createDirectory($directory)
Definition: filetransfer.inc:106
SkipDotsRecursiveDirectoryIterator\rewind
rewind()
Definition: filetransfer.inc:412
FileTransferException
Definition: filetransfer.inc:363
FileTransfer\copyFile
copyFile($source, $destination)
Definition: filetransfer.inc:132
SkipDotsRecursiveDirectoryIterator\next
next()
Definition: filetransfer.inc:417
FileTransfer\removeFileJailed
removeFileJailed($destination)
FileTransfer\copyDirectoryJailed
copyDirectoryJailed($source, $destination)
Definition: filetransfer.inc:212
FileTransfer\__get
__get($name)
Definition: filetransfer.inc:51
$name
print $name
Definition: profile-listing.tpl.php:43
SkipDotsRecursiveDirectoryIterator\__construct
__construct($path)
Definition: filetransfer.inc:407
Exception
drupal_realpath
drupal_realpath($uri)
Definition: file.inc:2259
FileTransfer\findChroot
findChroot()
Definition: filetransfer.inc:291
FileTransfer\isDirectory
isDirectory($path)
FileTransfer\$password
$password
Definition: filetransfer.inc:14
FileTransfer\connect
connect()
FileTransferException\__construct
__construct($message, $code=0, $arguments=array())
Definition: filetransfer.inc:366
FileTransferException\$arguments
$arguments
Definition: filetransfer.inc:364
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
FileTransfer\chmod
chmod($path, $mode, $recursive=FALSE)
Definition: filetransfer.inc:90
FileTransfer
Definition: filetransfer.inc:12
SkipDotsRecursiveDirectoryIterator
Definition: filetransfer.inc:400
FileTransfer\checkPath
checkPath($path)
Definition: filetransfer.inc:157
FileTransfer\factory
static factory($jail, $settings)
Definition: filetransfer.inc:40
SkipDotsRecursiveDirectoryIterator\skipdots
skipdots()
Definition: filetransfer.inc:422
FileTransfer\fixRemotePath
fixRemotePath($path, $strip_chroot=TRUE)
Definition: filetransfer.inc:177
FileTransfer\setChroot
setChroot()
Definition: filetransfer.inc:318
FileTransferChmodInterface
Definition: filetransfer.inc:376
FileTransfer\isFile
isFile($path)
FileTransfer\createDirectoryJailed
createDirectoryJailed($directory)
FileTransfer\removeFile
removeFile($destination)
Definition: filetransfer.inc:145
FileTransfer\$port
$port
Definition: filetransfer.inc:16
FileTransfer\$hostname
$hostname
Definition: filetransfer.inc:15
FileTransfer\copyFileJailed
copyFileJailed($source, $destination)
FileTransfer\removeDirectoryJailed
removeDirectoryJailed($directory)
FileTransfer\$username
$username
Definition: filetransfer.inc:13
FileTransfer\copyDirectory
copyDirectory($source, $destination)
Definition: filetransfer.inc:76
FileTransferChmodInterface\chmodJailed
chmodJailed($path, $mode, $recursive)
FileTransfer\sanitizePath
sanitizePath($path)
Definition: filetransfer.inc:194
FileTransfer\__construct
__construct($jail)
Definition: filetransfer.inc:22
drupal_basename
drupal_basename($uri, $suffix=NULL)
Definition: file.inc:2317
FileTransfer\removeDirectory
removeDirectory($directory)
Definition: filetransfer.inc:118
FileTransfer\getSettingsForm
getSettingsForm()
Definition: filetransfer.inc:329
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forums.tpl.php Source File

  • modules
  • forum
forums.tpl.php
Go to the documentation of this file.
1 <?php
2
18 ?>
19 <?php if ($forums_defined): ?>
20 <div id="forum">
21 <?php print $forums; ?>
22 <?php print $topics; ?>
23 </div>
24 <?php endif; ?>
$topics
if($forums_defined) print $topics
Definition: forums.tpl.php:19
print
print
Definition: php-2.php:2
endif
endif
Definition: aggregator-item.tpl.php:31
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
SkipDotsRecursiveDirectoryIterator Member List

This is the complete list of members for SkipDotsRecursiveDirectoryIterator, including all inherited members.

__construct($path) | SkipDotsRecursiveDirectoryIterator |
next() | SkipDotsRecursiveDirectoryIterator |
rewind() | SkipDotsRecursiveDirectoryIterator |
skipdots() | SkipDotsRecursiveDirectoryIterator | protected
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DatabaseTasks Member List

This is the complete list of members for DatabaseTasks, including all inherited members.

$results | DatabaseTasks | protected
$tasks | DatabaseTasks | protected
checkEngineVersion() | DatabaseTasks | protected
connect() | DatabaseTasks | protected
fail($message) | DatabaseTasks | protected
getFormOptions($database) | DatabaseTasks |
hasPdoDriver() | DatabaseTasks | protected
installable() | DatabaseTasks |
minimumVersion() | DatabaseTasks |
name() | DatabaseTasks |
pass($message) | DatabaseTasks | protected
runTasks() | DatabaseTasks |
runTestQuery($query, $pass, $fail, $fatal=FALSE) | DatabaseTasks | protected
validateDatabaseSettings($database) | DatabaseTasks |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalCacheArray Member List

This is the complete list of members for DrupalCacheArray, including all inherited members.

$bin | DrupalCacheArray | protected
$cid | DrupalCacheArray | protected
$completeRegistry | DrupalCacheArray | protected
$keysToPersist | DrupalCacheArray | protected
$persistable | DrupalCacheArray | protected
$storage | DrupalCacheArray | protected
__construct($cid, $bin) | DrupalCacheArray |
__construct($cid, $bin) | DrupalCacheArray |
__destruct() | DrupalCacheArray |
initializeRegistry() | DrupalCacheArray |
offsetExists($offset) | DrupalCacheArray |
offsetExists($offset) | DrupalCacheArray |
offsetGet($offset) | DrupalCacheArray |
offsetGet($offset) | DrupalCacheArray |
offsetSet($offset, $value) | DrupalCacheArray |
offsetUnset($offset) | DrupalCacheArray |
persist($offset, $persist=TRUE) | DrupalCacheArray | protected
resolveCacheMiss($offset) | DrupalCacheArray | protected
resolveCacheMiss($offset) | DrupalCacheArray |
set($data, $lock=TRUE) | DrupalCacheArray | protected
set($data, $lock=TRUE) | DrupalCacheArray |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/overlay/overlay.tpl.php Source File

  • modules
  • overlay
overlay.tpl.php
Go to the documentation of this file.
1 <?php
2
23 ?>
24
25 <?php print render($disable_overlay); ?>
26 <div id="overlay" <?php print $attributes; ?>>
27 <div id="overlay-titlebar" class="clearfix">
28 <div id="overlay-title-wrapper" class="clearfix">
29 <h1 id="overlay-title"<?php print $title_attributes; ?>><?php print $title; ?></h1>
30 </div>
31 <div id="overlay-close-wrapper">
32 <a id="overlay-close" href="#" class="overlay-close"><span class="element-invisible"><?php print t('Close overlay'); ?></span></a>
33 </div>
34 <?php if ($tabs): ?><h2 class="element-invisible"><?php print t('Primary tabs'); ?></h2><ul id="overlay-tabs"><?php print render($tabs); ?></ul><?php endif; ?>
35 </div>
36 <div id="overlay-content"<?php print $content_attributes; ?>>
37 <?php print $page; ?>
38 </div>
39 </div>
$page
print $page
Definition: overlay.tpl.php:37
$attributes
print $attributes
Definition: block.tpl.php:47
print
print
Definition: php-2.php:2
$content_attributes
print $content_attributes
Definition: block.tpl.php:55
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
endif
endif
Definition: aggregator-item.tpl.php:31
render
render(&$element)
Definition: common.inc:5988
$title_attributes
print $title_attributes
Definition: comment.tpl.php:70
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/menu.inc Source File

  • includes
menu.inc
Go to the documentation of this file.
1 <?php
2
86 define('MENU_IS_ROOT', 0x0001);
87
91 define('MENU_VISIBLE_IN_TREE', 0x0002);
92
96 define('MENU_VISIBLE_IN_BREADCRUMB', 0x0004);
97
101 define('MENU_LINKS_TO_PARENT', 0x0008);
102
106 define('MENU_MODIFIED_BY_ADMIN', 0x0020);
107
111 define('MENU_CREATED_BY_ADMIN', 0x0040);
112
116 define('MENU_IS_LOCAL_TASK', 0x0080);
117
121 define('MENU_IS_LOCAL_ACTION', 0x0100);
122
143 define('MENU_NORMAL_ITEM', MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB);
144
151 define('MENU_CALLBACK', 0x0000);
152
161 define('MENU_SUGGESTED_ITEM', MENU_VISIBLE_IN_BREADCRUMB | 0x0010);
162
170 define('MENU_LOCAL_TASK', MENU_IS_LOCAL_TASK | MENU_VISIBLE_IN_BREADCRUMB);
171
178 define('MENU_DEFAULT_LOCAL_TASK', MENU_IS_LOCAL_TASK | MENU_LINKS_TO_PARENT | MENU_VISIBLE_IN_BREADCRUMB);
179
186 define('MENU_LOCAL_ACTION', MENU_IS_LOCAL_TASK | MENU_IS_LOCAL_ACTION | MENU_VISIBLE_IN_BREADCRUMB);
187
204 define('MENU_CONTEXT_NONE', 0x0000);
205
209 define('MENU_CONTEXT_PAGE', 0x0001);
210
214 define('MENU_CONTEXT_INLINE', 0x0002);
215
229 define('MENU_FOUND', 1);
230
234 define('MENU_NOT_FOUND', 2);
235
239 define('MENU_ACCESS_DENIED', 3);
240
244 define('MENU_SITE_OFFLINE', 4);
245
249 define('MENU_SITE_ONLINE', 5);
250
264 define('MENU_MAX_PARTS', 9);
265
266
270 define('MENU_MAX_DEPTH', 9);
271
272
289 define('MENU_PREFERRED_LINK', '1cf698d64d1aa4b83907cf6ed55db3a7f8e92c91');
290
319 function menu_get_ancestors($parts) {
320 $number_parts = count($parts);
321 $ancestors = array();
322 $length = $number_parts - 1;
323 $end = (1 << $number_parts) - 1;
324 $masks = variable_get('menu_masks');
325 // If the optimized menu_masks array is not available use brute force to get
326 // the correct $ancestors and $placeholders returned. Do not use this as the
327 // default value of the menu_masks variable to avoid building such a big
328 // array.
329 if (!$masks) {
330 $masks = range(511, 1);
331 }
332 // Only examine patterns that actually exist as router items (the masks).
333 foreach ($masks as $i) {
334 if ($i > $end) {
335 // Only look at masks that are not longer than the path of interest.
336 continue;
337 }
338 elseif ($i < (1 << $length)) {
339 // We have exhausted the masks of a given length, so decrease the length.
340 --$length;
341 }
342 $current = '';
343 for ($j = $length; $j >= 0; $j--) {
344 // Check the bit on the $j offset.
345 if ($i & (1 << $j)) {
346 // Bit one means the original value.
347 $current .= $parts[$length - $j];
348 }
349 else {
350 // Bit zero means means wildcard.
351 $current .= '%';
352 }
353 // Unless we are at offset 0, add a slash.
354 if ($j) {
355 $current .= '/';
356 }
357 }
358 $ancestors[] = $current;
359 }
360 return $ancestors;
361 }
362
398 function menu_unserialize($data, $map) {
399 if ($data = unserialize($data)) {
400 foreach ($data as $k => $v) {
401 if (is_int($v)) {
402 $data[$k] = isset($map[$v]) ? $map[$v] : '';
403 }
404 }
405 return $data;
406 }
407 else {
408 return array();
409 }
410 }
411
412
413
425 function menu_set_item($path, $router_item) {
426 menu_get_item($path, $router_item);
427 }
428
447 function menu_get_item($path = NULL, $router_item = NULL) {
448 $router_items = &drupal_static(__FUNCTION__);
449 if (!isset($path)) {
450 $path = $_GET['q'];
451 }
452 if (isset($router_item)) {
453 $router_items[$path] = $router_item;
454 }
455 if (!isset($router_items[$path])) {
456 // Rebuild if we know it's needed, or if the menu masks are missing which
457 // occurs rarely, likely due to a race condition of multiple rebuilds.
458 if (variable_get('menu_rebuild_needed', FALSE) || !variable_get('menu_masks', array())) {
459 menu_rebuild();
460 }
461 $original_map = arg(NULL, $path);
462
463 $parts = array_slice($original_map, 0, MENU_MAX_PARTS);
464 $ancestors = menu_get_ancestors($parts);
465 $router_item = db_query_range('SELECT * FROM {menu_router} WHERE path IN (:ancestors) ORDER BY fit DESC', 0, 1, array(':ancestors' => $ancestors))->fetchAssoc();
466
467 if ($router_item) {
468 // Allow modules to alter the router item before it is translated and
469 // checked for access.
470 drupal_alter('menu_get_item', $router_item, $path, $original_map);
471
472 $map = _menu_translate($router_item, $original_map);
473 $router_item['original_map'] = $original_map;
474 if ($map === FALSE) {
475 $router_items[$path] = FALSE;
476 return FALSE;
477 }
478 if ($router_item['access']) {
479 $router_item['map'] = $map;
480 $router_item['page_arguments'] = array_merge(menu_unserialize($router_item['page_arguments'], $map), array_slice($map, $router_item['number_parts']));
481 $router_item['theme_arguments'] = array_merge(menu_unserialize($router_item['theme_arguments'], $map), array_slice($map, $router_item['number_parts']));
482 }
483 }
484 $router_items[$path] = $router_item;
485 }
486 return $router_items[$path];
487 }
488
500 function menu_execute_active_handler($path = NULL, $deliver = TRUE) {
501 // Check if site is offline.
502 $page_callback_result = _menu_site_is_offline() ? MENU_SITE_OFFLINE : MENU_SITE_ONLINE;
503
504 // Allow other modules to change the site status but not the path because that
505 // would not change the global variable. hook_url_inbound_alter() can be used
506 // to change the path. Code later will not use the $read_only_path variable.
507 $read_only_path = !empty($path) ? $path : $_GET['q'];
508 drupal_alter('menu_site_status', $page_callback_result, $read_only_path);
509
510 // Only continue if the site status is not set.
511 if ($page_callback_result == MENU_SITE_ONLINE) {
512 if ($router_item = menu_get_item($path)) {
513 if ($router_item['access']) {
514 if ($router_item['include_file']) {
515 require_once DRUPAL_ROOT . '/' . $router_item['include_file'];
516 }
517 $page_callback_result = call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
518 }
519 else {
520 $page_callback_result = MENU_ACCESS_DENIED;
521 }
522 }
523 else {
524 $page_callback_result = MENU_NOT_FOUND;
525 }
526 }
527
528 // Deliver the result of the page callback to the browser, or if requested,
529 // return it raw, so calling code can do more processing.
530 if ($deliver) {
531 $default_delivery_callback = (isset($router_item) && $router_item) ? $router_item['delivery_callback'] : NULL;
532 drupal_deliver_page($page_callback_result, $default_delivery_callback);
533 }
534 else {
535 return $page_callback_result;
536 }
537 }
538
554 function _menu_load_objects(&$item, &$map) {
555 if ($load_functions = $item['load_functions']) {
556 // If someone calls this function twice, then unserialize will fail.
557 if (!is_array($load_functions)) {
558 $load_functions = unserialize($load_functions);
559 }
560 $path_map = $map;
561 foreach ($load_functions as $index => $function) {
562 if ($function) {
563 $value = isset($path_map[$index]) ? $path_map[$index] : '';
564 if (is_array($function)) {
565 // Set up arguments for the load function. These were pulled from
566 // 'load arguments' in the hook_menu() entry, but they need
567 // some processing. In this case the $function is the key to the
568 // load_function array, and the value is the list of arguments.
569 list($function, $args) = each($function);
570 $load_functions[$index] = $function;
571
572 // Some arguments are placeholders for dynamic items to process.
573 foreach ($args as $i => $arg) {
574 if ($arg === '%index') {
575 // Pass on argument index to the load function, so multiple
576 // occurrences of the same placeholder can be identified.
577 $args[$i] = $index;
578 }
579 if ($arg === '%map') {
580 // Pass on menu map by reference. The accepting function must
581 // also declare this as a reference if it wants to modify
582 // the map.
583 $args[$i] = &$map;
584 }
585 if (is_int($arg)) {
586 $args[$i] = isset($path_map[$arg]) ? $path_map[$arg] : '';
587 }
588 }
589 array_unshift($args, $value);
590 $return = call_user_func_array($function, $args);
591 }
592 else {
593 $return = $function($value);
594 }
595 // If callback returned an error or there is no callback, trigger 404.
596 if ($return === FALSE) {
597 $item['access'] = FALSE;
598 $map = FALSE;
599 return FALSE;
600 }
601 $map[$index] = $return;
602 }
603 }
604 $item['load_functions'] = $load_functions;
605 }
606 return TRUE;
607 }
608
620 function _menu_check_access(&$item, $map) {
621 $item['access'] = FALSE;
622 // Determine access callback, which will decide whether or not the current
623 // user has access to this path.
624 $callback = empty($item['access_callback']) ? 0 : trim($item['access_callback']);
625 // Check for a TRUE or FALSE value.
626 if (is_numeric($callback)) {
627 $item['access'] = (bool) $callback;
628 }
629 else {
630 $arguments = menu_unserialize($item['access_arguments'], $map);
631 // As call_user_func_array is quite slow and user_access is a very common
632 // callback, it is worth making a special case for it.
633 if ($callback == 'user_access') {
634 $item['access'] = (count($arguments) == 1) ? user_access($arguments[0]) : user_access($arguments[0], $arguments[1]);
635 }
636 elseif (function_exists($callback)) {
637 $item['access'] = call_user_func_array($callback, $arguments);
638 }
639 }
640 }
641
668 function _menu_item_localize(&$item, $map, $link_translate = FALSE) {
669 $callback = $item['title_callback'];
670 $item['localized_options'] = $item['options'];
671 // All 'class' attributes are assumed to be an array during rendering, but
672 // links stored in the database may use an old string value.
673 // @todo In order to remove this code we need to implement a database update
674 // including unserializing all existing link options and running this code
675 // on them, as well as adding validation to menu_link_save().
676 if (isset($item['options']['attributes']['class']) && is_string($item['options']['attributes']['class'])) {
677 $item['localized_options']['attributes']['class'] = explode(' ', $item['options']['attributes']['class']);
678 }
679 // If we are translating the title of a menu link, and its title is the same
680 // as the corresponding router item, then we can use the title information
681 // from the router. If it's customized, then we need to use the link title
682 // itself; can't localize.
683 // If we are translating a router item (tabs, page, breadcrumb), then we
684 // can always use the information from the router item.
685 if (!$link_translate || ($item['title'] == $item['link_title'])) {
686 // t() is a special case. Since it is used very close to all the time,
687 // we handle it directly instead of using indirect, slower methods.
688 if ($callback == 't') {
689 if (empty($item['title_arguments'])) {
690 $item['title'] = t($item['title']);
691 }
692 else {
693 $item['title'] = t($item['title'], menu_unserialize($item['title_arguments'], $map));
694 }
695 }
696 elseif ($callback && function_exists($callback)) {
697 if (empty($item['title_arguments'])) {
698 $item['title'] = $callback($item['title']);
699 }
700 else {
701 $item['title'] = call_user_func_array($callback, menu_unserialize($item['title_arguments'], $map));
702 }
703 // Avoid calling check_plain again on l() function.
704 if ($callback == 'check_plain') {
705 $item['localized_options']['html'] = TRUE;
706 }
707 }
708 }
709 elseif ($link_translate) {
710 $item['title'] = $item['link_title'];
711 }
712
713 // Translate description, see the motivation above.
714 if (!empty($item['description'])) {
715 $original_description = $item['description'];
716 $item['description'] = t($item['description']);
717 if ($link_translate && isset($item['options']['attributes']['title']) && $item['options']['attributes']['title'] == $original_description) {
718 $item['localized_options']['attributes']['title'] = $item['description'];
719 }
720 }
721 }
722
753 function _menu_translate(&$router_item, $map, $to_arg = FALSE) {
754 if ($to_arg && !empty($router_item['to_arg_functions'])) {
755 // Fill in missing path elements, such as the current uid.
756 _menu_link_map_translate($map, $router_item['to_arg_functions']);
757 }
758 // The $path_map saves the pieces of the path as strings, while elements in
759 // $map may be replaced with loaded objects.
760 $path_map = $map;
761 if (!empty($router_item['load_functions']) && !_menu_load_objects($router_item, $map)) {
762 // An error occurred loading an object.
763 $router_item['access'] = FALSE;
764 return FALSE;
765 }
766
767 // Generate the link path for the page request or local tasks.
768 $link_map = explode('/', $router_item['path']);
769 if (isset($router_item['tab_root'])) {
770 $tab_root_map = explode('/', $router_item['tab_root']);
771 }
772 if (isset($router_item['tab_parent'])) {
773 $tab_parent_map = explode('/', $router_item['tab_parent']);
774 }
775 for ($i = 0; $i < $router_item['number_parts']; $i++) {
776 if ($link_map[$i] == '%') {
777 $link_map[$i] = $path_map[$i];
778 }
779 if (isset($tab_root_map[$i]) && $tab_root_map[$i] == '%') {
780 $tab_root_map[$i] = $path_map[$i];
781 }
782 if (isset($tab_parent_map[$i]) && $tab_parent_map[$i] == '%') {
783 $tab_parent_map[$i] = $path_map[$i];
784 }
785 }
786 $router_item['href'] = implode('/', $link_map);
787 $router_item['tab_root_href'] = implode('/', $tab_root_map);
788 $router_item['tab_parent_href'] = implode('/', $tab_parent_map);
789 $router_item['options'] = array();
790 _menu_check_access($router_item, $map);
791
792 // For performance, don't localize an item the user can't access.
793 if ($router_item['access']) {
794 _menu_item_localize($router_item, $map);
795 }
796
797 return $map;
798 }
799
810 function _menu_link_map_translate(&$map, $to_arg_functions) {
811 $to_arg_functions = unserialize($to_arg_functions);
812 foreach ($to_arg_functions as $index => $function) {
813 // Translate place-holders into real values.
814 $arg = $function(!empty($map[$index]) ? $map[$index] : '', $map, $index);
815 if (!empty($map[$index]) || isset($arg)) {
816 $map[$index] = $arg;
817 }
818 else {
819 unset($map[$index]);
820 }
821 }
822 }
823
827 function menu_tail_to_arg($arg, $map, $index) {
828 return implode('/', array_slice($map, $index));
829 }
830
842 function menu_tail_load($arg, &$map, $index) {
843 $arg = implode('/', array_slice($map, $index));
844 $map = array_slice($map, 0, $index);
845 return $arg;
846 }
847
870 function _menu_link_translate(&$item, $translate = FALSE) {
871 if (!is_array($item['options'])) {
872 $item['options'] = unserialize($item['options']);
873 }
874 if ($item['external']) {
875 $item['access'] = 1;
876 $map = array();
877 $item['href'] = $item['link_path'];
878 $item['title'] = $item['link_title'];
879 $item['localized_options'] = $item['options'];
880 }
881 else {
882 // Complete the path of the menu link with elements from the current path,
883 // if it contains dynamic placeholders (%).
884 $map = explode('/', $item['link_path']);
885 if (strpos($item['link_path'], '%') !== FALSE) {
886 // Invoke registered to_arg callbacks.
887 if (!empty($item['to_arg_functions'])) {
888 _menu_link_map_translate($map, $item['to_arg_functions']);
889 }
890 // Or try to derive the path argument map from the current router item,
891 // if this $item's path is within the router item's path. This means
892 // that if we are on the current path 'foo/%/bar/%/baz', then
893 // menu_get_item() will have translated the menu router item for the
894 // current path, and we can take over the argument map for a link like
895 // 'foo/%/bar'. This inheritance is only valid for breadcrumb links.
896 // @see _menu_tree_check_access()
897 // @see menu_get_active_breadcrumb()
898 elseif ($translate && ($current_router_item = menu_get_item())) {
899 // If $translate is TRUE, then this link is in the active trail.
900 // Only translate paths within the current path.
901 if (strpos($current_router_item['path'], $item['link_path']) === 0) {
902 $count = count($map);
903 $map = array_slice($current_router_item['original_map'], 0, $count);
904 $item['original_map'] = $map;
905 if (isset($current_router_item['map'])) {
906 $item['map'] = array_slice($current_router_item['map'], 0, $count);
907 }
908 // Reset access to check it (for the first time).
909 unset($item['access']);
910 }
911 }
912 }
913 $item['href'] = implode('/', $map);
914
915 // Skip links containing untranslated arguments.
916 if (strpos($item['href'], '%') !== FALSE) {
917 $item['access'] = FALSE;
918 return FALSE;
919 }
920 // menu_tree_check_access() may set this ahead of time for links to nodes.
921 if (!isset($item['access'])) {
922 if (!empty($item['load_functions']) && !_menu_load_objects($item, $map)) {
923 // An error occurred loading an object.
924 $item['access'] = FALSE;
925 return FALSE;
926 }
927 _menu_check_access($item, $map);
928 }
929 // For performance, don't localize a link the user can't access.
930 if ($item['access']) {
931 _menu_item_localize($item, $map, TRUE);
932 }
933 }
934
935 // Allow other customizations - e.g. adding a page-specific query string to the
936 // options array. For performance reasons we only invoke this hook if the link
937 // has the 'alter' flag set in the options array.
938 if (!empty($item['options']['alter'])) {
939 drupal_alter('translated_menu_link', $item, $map);
940 }
941
942 return $map;
943 }
944
971 function menu_get_object($type = 'node', $position = 1, $path = NULL) {
972 $router_item = menu_get_item($path);
973 if (isset($router_item['load_functions'][$position]) && !empty($router_item['map'][$position]) && $router_item['load_functions'][$position] == $type . '_load') {
974 return $router_item['map'][$position];
975 }
976 }
977
992 function menu_tree($menu_name) {
993 $menu_output = &drupal_static(__FUNCTION__, array());
994
995 if (!isset($menu_output[$menu_name])) {
996 $tree = menu_tree_page_data($menu_name);
997 $menu_output[$menu_name] = menu_tree_output($tree);
998 }
999 return $menu_output[$menu_name];
1000 }
1001
1016 function menu_tree_output($tree) {
1017 $build = array();
1018 $items = array();
1019
1020 // Pull out just the menu links we are going to render so that we
1021 // get an accurate count for the first/last classes.
1022 foreach ($tree as $data) {
1023 if ($data['link']['access'] && !$data['link']['hidden']) {
1024 $items[] = $data;
1025 }
1026 }
1027
1028 $router_item = menu_get_item();
1029 $num_items = count($items);
1030 foreach ($items as $i => $data) {
1031 $class = array();
1032 if ($i == 0) {
1033 $class[] = 'first';
1034 }
1035 if ($i == $num_items - 1) {
1036 $class[] = 'last';
1037 }
1038 // Set a class for the <li>-tag. Since $data['below'] may contain local
1039 // tasks, only set 'expanded' class if the link also has children within
1040 // the current menu.
1041 if ($data['link']['has_children'] && $data['below']) {
1042 $class[] = 'expanded';
1043 }
1044 elseif ($data['link']['has_children']) {
1045 $class[] = 'collapsed';
1046 }
1047 else {
1048 $class[] = 'leaf';
1049 }
1050 // Set a class if the link is in the active trail.
1051 if ($data['link']['in_active_trail']) {
1052 $class[] = 'active-trail';
1053 $data['link']['localized_options']['attributes']['class'][] = 'active-trail';
1054 }
1055 // Normally, l() compares the href of every link with $_GET['q'] and sets
1056 // the active class accordingly. But local tasks do not appear in menu
1057 // trees, so if the current path is a local task, and this link is its
1058 // tab root, then we have to set the class manually.
1059 if ($data['link']['href'] == $router_item['tab_root_href'] && $data['link']['href'] != $_GET['q']) {
1060 $data['link']['localized_options']['attributes']['class'][] = 'active';
1061 }
1062
1063 // Allow menu-specific theme overrides.
1064 $element['#theme'] = 'menu_link__' . strtr($data['link']['menu_name'], '-', '_');
1065 $element['#attributes']['class'] = $class;
1066 $element['#title'] = $data['link']['title'];
1067 $element['#href'] = $data['link']['href'];
1068 $element['#localized_options'] = !empty($data['link']['localized_options']) ? $data['link']['localized_options'] : array();
1069 $element['#below'] = $data['below'] ? menu_tree_output($data['below']) : $data['below'];
1070 $element['#original_link'] = $data['link'];
1071 // Index using the link's unique mlid.
1072 $build[$data['link']['mlid']] = $element;
1073 }
1074 if ($build) {
1075 // Make sure drupal_render() does not re-order the links.
1076 $build['#sorted'] = TRUE;
1077 // Add the theme wrapper for outer markup.
1078 // Allow menu-specific theme overrides.
1079 $build['#theme_wrappers'][] = 'menu_tree__' . strtr($data['link']['menu_name'], '-', '_');
1080 }
1081
1082 return $build;
1083 }
1084
1105 function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
1106 $tree = &drupal_static(__FUNCTION__, array());
1107
1108 // Use $mlid as a flag for whether the data being loaded is for the whole tree.
1109 $mlid = isset($link['mlid']) ? $link['mlid'] : 0;
1110 // Generate a cache ID (cid) specific for this $menu_name, $link, $language, and depth.
1111 $cid = 'links:' . $menu_name . ':all:' . $mlid . ':' . $GLOBALS['language']->language . ':' . (int) $max_depth;
1112
1113 if (!isset($tree[$cid])) {
1114 // If the static variable doesn't have the data, check {cache_menu}.
1115 $cache = cache_get($cid, 'cache_menu');
1116 if ($cache && isset($cache->data)) {
1117 // If the cache entry exists, it contains the parameters for
1118 // menu_build_tree().
1119 $tree_parameters = $cache->data;
1120 }
1121 // If the tree data was not in the cache, build $tree_parameters.
1122 if (!isset($tree_parameters)) {
1123 $tree_parameters = array(
1124 'min_depth' => 1,
1125 'max_depth' => $max_depth,
1126 );
1127 if ($mlid) {
1128 // The tree is for a single item, so we need to match the values in its
1129 // p columns and 0 (the top level) with the plid values of other links.
1130 $parents = array(0);
1131 for ($i = 1; $i < MENU_MAX_DEPTH; $i++) {
1132 if (!empty($link["p$i"])) {
1133 $parents[] = $link["p$i"];
1134 }
1135 }
1136 $tree_parameters['expanded'] = $parents;
1137 $tree_parameters['active_trail'] = $parents;
1138 $tree_parameters['active_trail'][] = $mlid;
1139 }
1140
1141 // Cache the tree building parameters using the page-specific cid.
1142 cache_set($cid, $tree_parameters, 'cache_menu');
1143 }
1144
1145 // Build the tree using the parameters; the resulting tree will be cached
1146 // by _menu_build_tree()).
1147 $tree[$cid] = menu_build_tree($menu_name, $tree_parameters);
1148 }
1149
1150 return $tree[$cid];
1151 }
1152
1170 function menu_tree_set_path($menu_name, $path = NULL) {
1171 $paths = &drupal_static(__FUNCTION__);
1172 if (isset($path)) {
1173 $paths[$menu_name] = $path;
1174 }
1175 return isset($paths[$menu_name]) ? $paths[$menu_name] : NULL;
1176 }
1177
1188 function menu_tree_get_path($menu_name) {
1189 return menu_tree_set_path($menu_name);
1190 }
1191
1214 function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = FALSE) {
1215 $tree = &drupal_static(__FUNCTION__, array());
1216
1217 // Check if the active trail has been overridden for this menu tree.
1218 $active_path = menu_tree_get_path($menu_name);
1219 // Load the menu item corresponding to the current page.
1220 if ($item = menu_get_item($active_path)) {
1221 if (isset($max_depth)) {
1222 $max_depth = min($max_depth, MENU_MAX_DEPTH);
1223 }
1224 // Generate a cache ID (cid) specific for this page.
1225 $cid = 'links:' . $menu_name . ':page:' . $item['href'] . ':' . $GLOBALS['language']->language . ':' . (int) $item['access'] . ':' . (int) $max_depth;
1226 // If we are asked for the active trail only, and $menu_name has not been
1227 // built and cached for this page yet, then this likely means that it
1228 // won't be built anymore, as this function is invoked from
1229 // template_process_page(). So in order to not build a giant menu tree
1230 // that needs to be checked for access on all levels, we simply check
1231 // whether we have the menu already in cache, or otherwise, build a minimum
1232 // tree containing the breadcrumb/active trail only.
1233 // @see menu_set_active_trail()
1234 if (!isset($tree[$cid]) && $only_active_trail) {
1235 $cid .= ':trail';
1236 }
1237
1238 if (!isset($tree[$cid])) {
1239 // If the static variable doesn't have the data, check {cache_menu}.
1240 $cache = cache_get($cid, 'cache_menu');
1241 if ($cache && isset($cache->data)) {
1242 // If the cache entry exists, it contains the parameters for
1243 // menu_build_tree().
1244 $tree_parameters = $cache->data;
1245 }
1246 // If the tree data was not in the cache, build $tree_parameters.
1247 if (!isset($tree_parameters)) {
1248 $tree_parameters = array(
1249 'min_depth' => 1,
1250 'max_depth' => $max_depth,
1251 );
1252 // Parent mlids; used both as key and value to ensure uniqueness.
1253 // We always want all the top-level links with plid == 0.
1254 $active_trail = array(0 => 0);
1255
1256 // If the item for the current page is accessible, build the tree
1257 // parameters accordingly.
1258 if ($item['access']) {
1259 // Find a menu link corresponding to the current path. If $active_path
1260 // is NULL, let menu_link_get_preferred() determine the path.
1261 if ($active_link = menu_link_get_preferred($active_path, $menu_name)) {
1262 // The active link may only be taken into account to build the
1263 // active trail, if it resides in the requested menu. Otherwise,
1264 // we'd needlessly re-run _menu_build_tree() queries for every menu
1265 // on every page.
1266 if ($active_link['menu_name'] == $menu_name) {
1267 // Use all the coordinates, except the last one because there
1268 // can be no child beyond the last column.
1269 for ($i = 1; $i < MENU_MAX_DEPTH; $i++) {
1270 if ($active_link['p' . $i]) {
1271 $active_trail[$active_link['p' . $i]] = $active_link['p' . $i];
1272 }
1273 }
1274 // If we are asked to build links for the active trail only, skip
1275 // the entire 'expanded' handling.
1276 if ($only_active_trail) {
1277 $tree_parameters['only_active_trail'] = TRUE;
1278 }
1279 }
1280 }
1281 $parents = $active_trail;
1282
1283 $expanded = variable_get('menu_expanded', array());
1284 // Check whether the current menu has any links set to be expanded.
1285 if (!$only_active_trail && in_array($menu_name, $expanded)) {
1286 // Collect all the links set to be expanded, and then add all of
1287 // their children to the list as well.
1288 do {
1289 $result = db_select('menu_links', NULL, array('fetch' => PDO::FETCH_ASSOC))
1290 ->fields('menu_links', array('mlid'))
1291 ->condition('menu_name', $menu_name)
1292 ->condition('expanded', 1)
1293 ->condition('has_children', 1)
1294 ->condition('plid', $parents, 'IN')
1295 ->condition('mlid', $parents, 'NOT IN')
1296 ->execute();
1297 $num_rows = FALSE;
1298 foreach ($result as $item) {
1299 $parents[$item['mlid']] = $item['mlid'];
1300 $num_rows = TRUE;
1301 }
1302 } while ($num_rows);
1303 }
1304 $tree_parameters['expanded'] = $parents;
1305 $tree_parameters['active_trail'] = $active_trail;
1306 }
1307 // If access is denied, we only show top-level links in menus.
1308 else {
1309 $tree_parameters['expanded'] = $active_trail;
1310 $tree_parameters['active_trail'] = $active_trail;
1311 }
1312 // Cache the tree building parameters using the page-specific cid.
1313 cache_set($cid, $tree_parameters, 'cache_menu');
1314 }
1315
1316 // Build the tree using the parameters; the resulting tree will be cached
1317 // by _menu_build_tree().
1318 $tree[$cid] = menu_build_tree($menu_name, $tree_parameters);
1319 }
1320 return $tree[$cid];
1321 }
1322
1323 return array();
1324 }
1325
1351 function menu_build_tree($menu_name, array $parameters = array()) {
1352 // Build the menu tree.
1353 $data = _menu_build_tree($menu_name, $parameters);
1354 // Check access for the current user to each item in the tree.
1355 menu_tree_check_access($data['tree'], $data['node_links']);
1356 return $data['tree'];
1357 }
1358
1368 function _menu_build_tree($menu_name, array $parameters = array()) {
1369 // Static cache of already built menu trees.
1370 $trees = &drupal_static(__FUNCTION__, array());
1371
1372 // Build the cache id; sort parents to prevent duplicate storage and remove
1373 // default parameter values.
1374 if (isset($parameters['expanded'])) {
1375 sort($parameters['expanded']);
1376 }
1377 $tree_cid = 'links:' . $menu_name . ':tree-data:' . $GLOBALS['language']->language . ':' . hash('sha256', serialize($parameters));
1378
1379 // If we do not have this tree in the static cache, check {cache_menu}.
1380 if (!isset($trees[$tree_cid])) {
1381 $cache = cache_get($tree_cid, 'cache_menu');
1382 if ($cache && isset($cache->data)) {
1383 $trees[$tree_cid] = $cache->data;
1384 }
1385 }
1386
1387 if (!isset($trees[$tree_cid])) {
1388 // Select the links from the table, and recursively build the tree. We
1389 // LEFT JOIN since there is no match in {menu_router} for an external
1390 // link.
1391 $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
1392 $query->addTag('translatable');
1393 $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
1394 $query->fields('ml');
1395 $query->fields('m', array(
1396 'load_functions',
1397 'to_arg_functions',
1398 'access_callback',
1399 'access_arguments',
1400 'page_callback',
1401 'page_arguments',
1402 'delivery_callback',
1403 'tab_parent',
1404 'tab_root',
1405 'title',
1406 'title_callback',
1407 'title_arguments',
1408 'theme_callback',
1409 'theme_arguments',
1410 'type',
1411 'description',
1412 ));
1413 for ($i = 1; $i <= MENU_MAX_DEPTH; $i++) {
1414 $query->orderBy('p' . $i, 'ASC');
1415 }
1416 $query->condition('ml.menu_name', $menu_name);
1417 if (!empty($parameters['expanded'])) {
1418 $query->condition('ml.plid', $parameters['expanded'], 'IN');
1419 }
1420 elseif (!empty($parameters['only_active_trail'])) {
1421 $query->condition('ml.mlid', $parameters['active_trail'], 'IN');
1422 }
1423 $min_depth = (isset($parameters['min_depth']) ? $parameters['min_depth'] : 1);
1424 if ($min_depth != 1) {
1425 $query->condition('ml.depth', $min_depth, '>=');
1426 }
1427 if (isset($parameters['max_depth'])) {
1428 $query->condition('ml.depth', $parameters['max_depth'], '<=');
1429 }
1430 // Add custom query conditions, if any were passed.
1431 if (isset($parameters['conditions'])) {
1432 foreach ($parameters['conditions'] as $column => $value) {
1433 $query->condition($column, $value);
1434 }
1435 }
1436
1437 // Build an ordered array of links using the query result object.
1438 $links = array();
1439 foreach ($query->execute() as $item) {
1440 $links[] = $item;
1441 }
1442 $active_trail = (isset($parameters['active_trail']) ? $parameters['active_trail'] : array());
1443 $data['tree'] = menu_tree_data($links, $active_trail, $min_depth);
1444 $data['node_links'] = array();
1445 menu_tree_collect_node_links($data['tree'], $data['node_links']);
1446
1447 // Cache the data, if it is not already in the cache.
1448 cache_set($tree_cid, $data, 'cache_menu');
1449 $trees[$tree_cid] = $data;
1450 }
1451
1452 return $trees[$tree_cid];
1453 }
1454
1463 function menu_tree_collect_node_links(&$tree, &$node_links) {
1464 foreach ($tree as $key => $v) {
1465 if ($tree[$key]['link']['router_path'] == 'node/%') {
1466 $nid = substr($tree[$key]['link']['link_path'], 5);
1467 if (is_numeric($nid)) {
1468 $node_links[$nid][$tree[$key]['link']['mlid']] = &$tree[$key]['link'];
1469 $tree[$key]['link']['access'] = FALSE;
1470 }
1471 }
1472 if ($tree[$key]['below']) {
1473 menu_tree_collect_node_links($tree[$key]['below'], $node_links);
1474 }
1475 }
1476 }
1477
1487 function menu_tree_check_access(&$tree, $node_links = array()) {
1488 if ($node_links) {
1489 $nids = array_keys($node_links);
1490 $select = db_select('node', 'n');
1491 $select->addField('n', 'nid');
1492 $select->condition('n.status', 1);
1493 $select->condition('n.nid', $nids, 'IN');
1494 $select->addTag('node_access');
1495 $nids = $select->execute()->fetchCol();
1496 foreach ($nids as $nid) {
1497 foreach ($node_links[$nid] as $mlid => $link) {
1498 $node_links[$nid][$mlid]['access'] = TRUE;
1499 }
1500 }
1501 }
1502 _menu_tree_check_access($tree);
1503 }
1504
1508 function _menu_tree_check_access(&$tree) {
1509 $new_tree = array();
1510 foreach ($tree as $key => $v) {
1511 $item = &$tree[$key]['link'];
1512 _menu_link_translate($item);
1513 if ($item['access'] || ($item['in_active_trail'] && strpos($item['href'], '%') !== FALSE)) {
1514 if ($tree[$key]['below']) {
1515 _menu_tree_check_access($tree[$key]['below']);
1516 }
1517 // The weights are made a uniform 5 digits by adding 50000 as an offset.
1518 // After _menu_link_translate(), $item['title'] has the localized link title.
1519 // Adding the mlid to the end of the index insures that it is unique.
1520 $new_tree[(50000 + $item['weight']) . ' ' . $item['title'] . ' ' . $item['mlid']] = $tree[$key];
1521 }
1522 }
1523 // Sort siblings in the tree based on the weights and localized titles.
1524 ksort($new_tree);
1525 $tree = $new_tree;
1526 }
1527
1554 function menu_tree_data(array $links, array $parents = array(), $depth = 1) {
1555 // Reverse the array so we can use the more efficient array_pop() function.
1556 $links = array_reverse($links);
1557 return _menu_tree_data($links, $parents, $depth);
1558 }
1559
1566 function _menu_tree_data(&$links, $parents, $depth) {
1567 $tree = array();
1568 while ($item = array_pop($links)) {
1569 // We need to determine if we're on the path to root so we can later build
1570 // the correct active trail and breadcrumb.
1571 $item['in_active_trail'] = in_array($item['mlid'], $parents);
1572 // Add the current link to the tree.
1573 $tree[$item['mlid']] = array(
1574 'link' => $item,
1575 'below' => array(),
1576 );
1577 // Look ahead to the next link, but leave it on the array so it's available
1578 // to other recursive function calls if we return or build a sub-tree.
1579 $next = end($links);
1580 // Check whether the next link is the first in a new sub-tree.
1581 if ($next && $next['depth'] > $depth) {
1582 // Recursively call _menu_tree_data to build the sub-tree.
1583 $tree[$item['mlid']]['below'] = _menu_tree_data($links, $parents, $next['depth']);
1584 // Fetch next link after filling the sub-tree.
1585 $next = end($links);
1586 }
1587 // Determine if we should exit the loop and return.
1588 if (!$next || $next['depth'] < $depth) {
1589 break;
1590 }
1591 }
1592 return $tree;
1593 }
1594
1598 function template_preprocess_menu_tree(&$variables) {
1599 $variables['tree'] = $variables['tree']['#children'];
1600 }
1601
1612 function theme_menu_tree($variables) {
1613 return '<ul class="menu">' . $variables['tree'] . '</ul>';
1614 }
1615
1625 function theme_menu_link(array $variables) {
1626 $element = $variables['element'];
1627 $sub_menu = '';
1628
1629 if ($element['#below']) {
1630 $sub_menu = drupal_render($element['#below']);
1631 }
1632 $output = l($element['#title'], $element['#href'], $element['#localized_options']);
1633 return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
1634 }
1635
1648 function theme_menu_local_task($variables) {
1649 $link = $variables['element']['#link'];
1650 $link_text = $link['title'];
1651
1652 if (!empty($variables['element']['#active'])) {
1653 // Add text to indicate active tab for non-visual users.
1654 $active = '<span class="element-invisible">' . t('(active tab)') . '</span>';
1655
1656 // If the link does not contain HTML already, check_plain() it now.
1657 // After we set 'html'=TRUE the link will not be sanitized by l().
1658 if (empty($link['localized_options']['html'])) {
1659 $link['title'] = check_plain($link['title']);
1660 }
1661 $link['localized_options']['html'] = TRUE;
1662 $link_text = t('!local-task-title!active', array('!local-task-title' => $link['title'], '!active' => $active));
1663 }
1664
1665 return '<li' . (!empty($variables['element']['#active']) ? ' class="active"' : '') . '>' . l($link_text, $link['href'], $link['localized_options']) . "</li>\n";
1666 }
1667
1679 function theme_menu_local_action($variables) {
1680 $link = $variables['element']['#link'];
1681
1682 $output = '<li>';
1683 if (isset($link['href'])) {
1684 $output .= l($link['title'], $link['href'], isset($link['localized_options']) ? $link['localized_options'] : array());
1685 }
1686 elseif (!empty($link['localized_options']['html'])) {
1687 $output .= $link['title'];
1688 }
1689 else {
1690 $output .= check_plain($link['title']);
1691 }
1692 $output .= "</li>\n";
1693
1694 return $output;
1695 }
1696
1700 function drupal_help_arg($arg = array()) {
1701 // Note - the number of empty elements should be > MENU_MAX_PARTS.
1702 return $arg + array('', '', '', '', '', '', '', '', '', '', '', '');
1703 }
1704
1708 function menu_get_active_help() {
1709 $output = '';
1710 $router_path = menu_tab_root_path();
1711 // We will always have a path unless we are on a 403 or 404.
1712 if (!$router_path) {
1713 return '';
1714 }
1715
1716 $arg = drupal_help_arg(arg(NULL));
1717
1718 foreach (module_implements('help') as $module) {
1719 $function = $module . '_help';
1720 // Lookup help for this path.
1721 if ($help = $function($router_path, $arg)) {
1722 $output .= $help . "\n";
1723 }
1724 }
1725 return $output;
1726 }
1727
1740 function menu_get_custom_theme($initialize = FALSE) {
1741 $custom_theme = &drupal_static(__FUNCTION__);
1742 // Skip this if the site is offline or being installed or updated, since the
1743 // menu system may not be correctly initialized then.
1744 if ($initialize && !_menu_site_is_offline(TRUE) && (!defined('MAINTENANCE_MODE') || (MAINTENANCE_MODE != 'update' && MAINTENANCE_MODE != 'install'))) {
1745 // First allow modules to dynamically set a custom theme for the current
1746 // page. Since we can only have one, the last module to return a valid
1747 // theme takes precedence.
1748 $custom_themes = array_filter(module_invoke_all('custom_theme'), 'drupal_theme_access');
1749 if (!empty($custom_themes)) {
1750 $custom_theme = array_pop($custom_themes);
1751 }
1752 // If there is a theme callback function for the current page, execute it.
1753 // If this returns a valid theme, it will override any theme that was set
1754 // by a hook_custom_theme() implementation above.
1755 $router_item = menu_get_item();
1756 if (!empty($router_item['access']) && !empty($router_item['theme_callback']) && function_exists($router_item['theme_callback'])) {
1757 $theme_name = call_user_func_array($router_item['theme_callback'], $router_item['theme_arguments']);
1758 if (drupal_theme_access($theme_name)) {
1759 $custom_theme = $theme_name;
1760 }
1761 }
1762 }
1763 return $custom_theme;
1764 }
1765
1769 function menu_set_custom_theme() {
1770 menu_get_custom_theme(TRUE);
1771 }
1772
1776 function menu_get_names() {
1777 $names = &drupal_static(__FUNCTION__);
1778
1779 if (empty($names)) {
1780 $names = db_select('menu_links')
1781 ->distinct()
1782 ->fields('menu_links', array('menu_name'))
1783 ->orderBy('menu_name')
1784 ->execute()->fetchCol();
1785 }
1786 return $names;
1787 }
1788
1792 function menu_list_system_menus() {
1793 return array(
1794 'navigation' => 'Navigation',
1795 'management' => 'Management',
1796 'user-menu' => 'User menu',
1797 'main-menu' => 'Main menu',
1798 );
1799 }
1800
1804 function menu_main_menu() {
1805 return menu_navigation_links(variable_get('menu_main_links_source', 'main-menu'));
1806 }
1807
1811 function menu_secondary_menu() {
1812
1813 // If the secondary menu source is set as the primary menu, we display the
1814 // second level of the primary menu.
1815 if (variable_get('menu_secondary_links_source', 'user-menu') == variable_get('menu_main_links_source', 'main-menu')) {
1816 return menu_navigation_links(variable_get('menu_main_links_source', 'main-menu'), 1);
1817 }
1818 else {
1819 return menu_navigation_links(variable_get('menu_secondary_links_source', 'user-menu'), 0);
1820 }
1821 }
1822
1834 function menu_navigation_links($menu_name, $level = 0) {
1835 // Don't even bother querying the menu table if no menu is specified.
1836 if (empty($menu_name)) {
1837 return array();
1838 }
1839
1840 // Get the menu hierarchy for the current page.
1841 $tree = menu_tree_page_data($menu_name, $level + 1);
1842
1843 // Go down the active trail until the right level is reached.
1844 while ($level-- > 0 && $tree) {
1845 // Loop through the current level's items until we find one that is in trail.
1846 while ($item = array_shift($tree)) {
1847 if ($item['link']['in_active_trail']) {
1848 // If the item is in the active trail, we continue in the subtree.
1849 $tree = empty($item['below']) ? array() : $item['below'];
1850 break;
1851 }
1852 }
1853 }
1854
1855 // Create a single level of links.
1856 $router_item = menu_get_item();
1857 $links = array();
1858 foreach ($tree as $item) {
1859 if (!$item['link']['hidden']) {
1860 $class = '';
1861 $l = $item['link']['localized_options'];
1862 $l['href'] = $item['link']['href'];
1863 $l['title'] = $item['link']['title'];
1864 if ($item['link']['in_active_trail']) {
1865 $class = ' active-trail';
1866 $l['attributes']['class'][] = 'active-trail';
1867 }
1868 // Normally, l() compares the href of every link with $_GET['q'] and sets
1869 // the active class accordingly. But local tasks do not appear in menu
1870 // trees, so if the current path is a local task, and this link is its
1871 // tab root, then we have to set the class manually.
1872 if ($item['link']['href'] == $router_item['tab_root_href'] && $item['link']['href'] != $_GET['q']) {
1873 $l['attributes']['class'][] = 'active';
1874 }
1875 // Keyed with the unique mlid to generate classes in theme_links().
1876 $links['menu-' . $item['link']['mlid'] . $class] = $l;
1877 }
1878 }
1879 return $links;
1880 }
1881
1899 function menu_local_tasks($level = 0) {
1900 $data = &drupal_static(__FUNCTION__);
1901 $root_path = &drupal_static(__FUNCTION__ . ':root_path', '');
1902 $empty = array(
1903 'tabs' => array('count' => 0, 'output' => array()),
1904 'actions' => array('count' => 0, 'output' => array()),
1905 'root_path' => &$root_path,
1906 );
1907
1908 if (!isset($data)) {
1909 $data = array();
1910 // Set defaults in case there are no actions or tabs.
1911 $actions = $empty['actions'];
1912 $tabs = array();
1913
1914 $router_item = menu_get_item();
1915
1916 // If this router item points to its parent, start from the parents to
1917 // compute tabs and actions.
1918 if ($router_item && ($router_item['type'] & MENU_LINKS_TO_PARENT)) {
1919 $router_item = menu_get_item($router_item['tab_parent_href']);
1920 }
1921
1922 // If we failed to fetch a router item or the current user doesn't have
1923 // access to it, don't bother computing the tabs.
1924 if (!$router_item || !$router_item['access']) {
1925 return $empty;
1926 }
1927
1928 // Get all tabs (also known as local tasks) and the root page.
1929 $cid = 'local_tasks:' . $router_item['tab_root'];
1930 if ($cache = cache_get($cid, 'cache_menu')) {
1931 $result = $cache->data;
1932 }
1933 else {
1934 $result = db_select('menu_router', NULL, array('fetch' => PDO::FETCH_ASSOC))
1935 ->fields('menu_router')
1936 ->condition('tab_root', $router_item['tab_root'])
1937 ->condition('context', MENU_CONTEXT_INLINE, '<>')
1938 ->orderBy('weight')
1939 ->orderBy('title')
1940 ->execute()
1941 ->fetchAll();
1942 cache_set($cid, $result, 'cache_menu');
1943 }
1944 $map = $router_item['original_map'];
1945 $children = array();
1946 $tasks = array();
1947 $root_path = $router_item['path'];
1948
1949 foreach ($result as $item) {
1950 _menu_translate($item, $map, TRUE);
1951 if ($item['tab_parent']) {
1952 // All tabs, but not the root page.
1953 $children[$item['tab_parent']][$item['path']] = $item;
1954 }
1955 // Store the translated item for later use.
1956 $tasks[$item['path']] = $item;
1957 }
1958
1959 // Find all tabs below the current path.
1960 $path = $router_item['path'];
1961 // Tab parenting may skip levels, so the number of parts in the path may not
1962 // equal the depth. Thus we use the $depth counter (offset by 1000 for ksort).
1963 $depth = 1001;
1964 $actions['count'] = 0;
1965 $actions['output'] = array();
1966 while (isset($children[$path])) {
1967 $tabs_current = array();
1968 $actions_current = array();
1969 $next_path = '';
1970 $tab_count = 0;
1971 $action_count = 0;
1972 foreach ($children[$path] as $item) {
1973 // Local tasks can be normal items too, so bitmask with
1974 // MENU_IS_LOCAL_TASK before checking.
1975 if (!($item['type'] & MENU_IS_LOCAL_TASK)) {
1976 // This item is not a tab, skip it.
1977 continue;
1978 }
1979 if ($item['access']) {
1980 $link = $item;
1981 // The default task is always active. As tabs can be normal items
1982 // too, so bitmask with MENU_LINKS_TO_PARENT before checking.
1983 if (($item['type'] & MENU_LINKS_TO_PARENT) == MENU_LINKS_TO_PARENT) {
1984 // Find the first parent which is not a default local task or action.
1985 for ($p = $item['tab_parent']; ($tasks[$p]['type'] & MENU_LINKS_TO_PARENT) == MENU_LINKS_TO_PARENT; $p = $tasks[$p]['tab_parent']);
1986 // Use the path of the parent instead.
1987 $link['href'] = $tasks[$p]['href'];
1988 // Mark the link as active, if the current path happens to be the
1989 // path of the default local task itself (i.e., instead of its
1990 // tab_parent_href or tab_root_href). Normally, links for default
1991 // local tasks link to their parent, but the path of default local
1992 // tasks can still be accessed directly, in which case this link
1993 // would not be marked as active, since l() only compares the href
1994 // with $_GET['q'].
1995 if ($link['href'] != $_GET['q']) {
1996 $link['localized_options']['attributes']['class'][] = 'active';
1997 }
1998 $tabs_current[] = array(
1999 '#theme' => 'menu_local_task',
2000 '#link' => $link,
2001 '#active' => TRUE,
2002 );
2003 $next_path = $item['path'];
2004 $tab_count++;
2005 }
2006 else {
2007 // Actions can be normal items too, so bitmask with
2008 // MENU_IS_LOCAL_ACTION before checking.
2009 if (($item['type'] & MENU_IS_LOCAL_ACTION) == MENU_IS_LOCAL_ACTION) {
2010 // The item is an action, display it as such.
2011 $actions_current[] = array(
2012 '#theme' => 'menu_local_action',
2013 '#link' => $link,
2014 );
2015 $action_count++;
2016 }
2017 else {
2018 // Otherwise, it's a normal tab.
2019 $tabs_current[] = array(
2020 '#theme' => 'menu_local_task',
2021 '#link' => $link,
2022 );
2023 $tab_count++;
2024 }
2025 }
2026 }
2027 }
2028 $path = $next_path;
2029 $tabs[$depth]['count'] = $tab_count;
2030 $tabs[$depth]['output'] = $tabs_current;
2031 $actions['count'] += $action_count;
2032 $actions['output'] = array_merge($actions['output'], $actions_current);
2033 $depth++;
2034 }
2035 $data['actions'] = $actions;
2036 // Find all tabs at the same level or above the current one.
2037 $parent = $router_item['tab_parent'];
2038 $path = $router_item['path'];
2039 $current = $router_item;
2040 $depth = 1000;
2041 while (isset($children[$parent])) {
2042 $tabs_current = array();
2043 $next_path = '';
2044 $next_parent = '';
2045 $count = 0;
2046 foreach ($children[$parent] as $item) {
2047 // Skip local actions.
2048 if ($item['type'] & MENU_IS_LOCAL_ACTION) {
2049 continue;
2050 }
2051 if ($item['access']) {
2052 $count++;
2053 $link = $item;
2054 // Local tasks can be normal items too, so bitmask with
2055 // MENU_LINKS_TO_PARENT before checking.
2056 if (($item['type'] & MENU_LINKS_TO_PARENT) == MENU_LINKS_TO_PARENT) {
2057 // Find the first parent which is not a default local task.
2058 for ($p = $item['tab_parent']; ($tasks[$p]['type'] & MENU_LINKS_TO_PARENT) == MENU_LINKS_TO_PARENT; $p = $tasks[$p]['tab_parent']);
2059 // Use the path of the parent instead.
2060 $link['href'] = $tasks[$p]['href'];
2061 if ($item['path'] == $router_item['path']) {
2062 $root_path = $tasks[$p]['path'];
2063 }
2064 }
2065 // We check for the active tab.
2066 if ($item['path'] == $path) {
2067 // Mark the link as active, if the current path is a (second-level)
2068 // local task of a default local task. Since this default local task
2069 // links to its parent, l() will not mark it as active, as it only
2070 // compares the link's href to $_GET['q'].
2071 if ($link['href'] != $_GET['q']) {
2072 $link['localized_options']['attributes']['class'][] = 'active';
2073 }
2074 $tabs_current[] = array(
2075 '#theme' => 'menu_local_task',
2076 '#link' => $link,
2077 '#active' => TRUE,
2078 );
2079 $next_path = $item['tab_parent'];
2080 if (isset($tasks[$next_path])) {
2081 $next_parent = $tasks[$next_path]['tab_parent'];
2082 }
2083 }
2084 else {
2085 $tabs_current[] = array(
2086 '#theme' => 'menu_local_task',
2087 '#link' => $link,
2088 );
2089 }
2090 }
2091 }
2092 $path = $next_path;
2093 $parent = $next_parent;
2094 $tabs[$depth]['count'] = $count;
2095 $tabs[$depth]['output'] = $tabs_current;
2096 $depth--;
2097 }
2098 // Sort by depth.
2099 ksort($tabs);
2100 // Remove the depth, we are interested only in their relative placement.
2101 $tabs = array_values($tabs);
2102 $data['tabs'] = $tabs;
2103
2104 // Allow modules to alter local tasks or dynamically append further tasks.
2105 drupal_alter('menu_local_tasks', $data, $router_item, $root_path);
2106 }
2107
2108 if (isset($data['tabs'][$level])) {
2109 return array(
2110 'tabs' => $data['tabs'][$level],
2111 'actions' => $data['actions'],
2112 'root_path' => $root_path,
2113 );
2114 }
2115 // @todo If there are no tabs, then there still can be actions; for example,
2116 // when added via hook_menu_local_tasks_alter().
2117 elseif (!empty($data['actions']['output'])) {
2118 return array('actions' => $data['actions']) + $empty;
2119 }
2120 return $empty;
2121 }
2122
2159 function menu_contextual_links($module, $parent_path, $args) {
2160 static $path_empty = array();
2161
2162 $links = array();
2163 // Performance: In case a previous invocation for the same parent path did not
2164 // return any links, we immediately return here.
2165 if (isset($path_empty[$parent_path]) && strpos($parent_path, '%') !== FALSE) {
2166 return $links;
2167 }
2168 // Construct the item-specific parent path.
2169 $path = $parent_path . '/' . implode('/', $args);
2170
2171 // Get the router item for the given parent link path.
2172 $router_item = menu_get_item($path);
2173 if (!$router_item || !$router_item['access']) {
2174 $path_empty[$parent_path] = TRUE;
2175 return $links;
2176 }
2177 $data = &drupal_static(__FUNCTION__, array());
2178 $root_path = $router_item['path'];
2179
2180 // Performance: For a single, normalized path (such as 'node/%') we only query
2181 // available tasks once per request.
2182 if (!isset($data[$root_path])) {
2183 // Get all contextual links that are direct children of the router item and
2184 // not of the tab type 'view'.
2185 $data[$root_path] = db_select('menu_router', 'm')
2186 ->fields('m')
2187 ->condition('tab_parent', $router_item['tab_root'])
2188 ->condition('context', MENU_CONTEXT_NONE, '<>')
2189 ->condition('context', MENU_CONTEXT_PAGE, '<>')
2190 ->orderBy('weight')
2191 ->orderBy('title')
2192 ->execute()
2193 ->fetchAllAssoc('path', PDO::FETCH_ASSOC);
2194 }
2195 $parent_length = drupal_strlen($root_path) + 1;
2196 $map = $router_item['original_map'];
2197 foreach ($data[$root_path] as $item) {
2198 // Extract the actual "task" string from the path argument.
2199 $key = drupal_substr($item['path'], $parent_length);
2200
2201 // Denormalize and translate the contextual link.
2202 _menu_translate($item, $map, TRUE);
2203 if (!$item['access']) {
2204 continue;
2205 }
2206 // All contextual links are keyed by the actual "task" path argument,
2207 // prefixed with the name of the implementing module.
2208 $links[$module . '-' . $key] = $item;
2209 }
2210
2211 // Allow modules to alter contextual links.
2212 drupal_alter('menu_contextual_links', $links, $router_item, $root_path);
2213
2214 // Performance: If the current user does not have access to any links for this
2215 // router path and no other module added further links, we assign FALSE here
2216 // to skip the entire process the next time the same router path is requested.
2217 if (empty($links)) {
2218 $path_empty[$parent_path] = TRUE;
2219 }
2220
2221 return $links;
2222 }
2223
2227 function menu_primary_local_tasks() {
2228 $links = menu_local_tasks(0);
2229 // Do not display single tabs.
2230 return ($links['tabs']['count'] > 1 ? $links['tabs']['output'] : '');
2231 }
2232
2236 function menu_secondary_local_tasks() {
2237 $links = menu_local_tasks(1);
2238 // Do not display single tabs.
2239 return ($links['tabs']['count'] > 1 ? $links['tabs']['output'] : '');
2240 }
2241
2245 function menu_local_actions() {
2246 $links = menu_local_tasks();
2247 return $links['actions']['output'];
2248 }
2249
2253 function menu_tab_root_path() {
2254 $links = menu_local_tasks();
2255 return $links['root_path'];
2256 }
2257
2261 function menu_local_tabs() {
2262 return array(
2263 '#theme' => 'menu_local_tasks',
2264 '#primary' => menu_primary_local_tasks(),
2265 '#secondary' => menu_secondary_local_tasks(),
2266 );
2267 }
2268
2280 function theme_menu_local_tasks(&$variables) {
2281 $output = '';
2282
2283 if (!empty($variables['primary'])) {
2284 $variables['primary']['#prefix'] = '<h2 class="element-invisible">' . t('Primary tabs') . '</h2>';
2285 $variables['primary']['#prefix'] .= '<ul class="tabs primary">';
2286 $variables['primary']['#suffix'] = '</ul>';
2287 $output .= drupal_render($variables['primary']);
2288 }
2289 if (!empty($variables['secondary'])) {
2290 $variables['secondary']['#prefix'] = '<h2 class="element-invisible">' . t('Secondary tabs') . '</h2>';
2291 $variables['secondary']['#prefix'] .= '<ul class="tabs secondary">';
2292 $variables['secondary']['#suffix'] = '</ul>';
2293 $output .= drupal_render($variables['secondary']);
2294 }
2295
2296 return $output;
2297 }
2298
2311 function menu_set_active_menu_names($menu_names = NULL) {
2312 $active = &drupal_static(__FUNCTION__);
2313
2314 if (isset($menu_names) && is_array($menu_names)) {
2315 $active = $menu_names;
2316 }
2317 elseif (!isset($active)) {
2318 $active = variable_get('menu_default_active_menus', array_keys(menu_list_system_menus()));
2319 }
2320 return $active;
2321 }
2322
2326 function menu_get_active_menu_names() {
2327 return menu_set_active_menu_names();
2328 }
2329
2340 function menu_set_active_item($path) {
2341 $_GET['q'] = $path;
2342 // Since the active item has changed, the active menu trail may also be out
2343 // of date.
2344 drupal_static_reset('menu_set_active_trail');
2345 }
2346
2367 function menu_set_active_trail($new_trail = NULL) {
2368 $trail = &drupal_static(__FUNCTION__);
2369
2370 if (isset($new_trail)) {
2371 $trail = $new_trail;
2372 }
2373 elseif (!isset($trail)) {
2374 $trail = array();
2375 $trail[] = array(
2376 'title' => t('Home'),
2377 'href' => '<front>',
2378 'link_path' => '',
2379 'localized_options' => array(),
2380 'type' => 0,
2381 );
2382
2383 // Try to retrieve a menu link corresponding to the current path. If more
2384 // than one exists, the link from the most preferred menu is returned.
2385 $preferred_link = menu_link_get_preferred();
2386 $current_item = menu_get_item();
2387
2388 // There is a link for the current path.
2389 if ($preferred_link) {
2390 // Pass TRUE for $only_active_trail to make menu_tree_page_data() build
2391 // a stripped down menu tree containing the active trail only, in case
2392 // the given menu has not been built in this request yet.
2393 $tree = menu_tree_page_data($preferred_link['menu_name'], NULL, TRUE);
2394 list($key, $curr) = each($tree);
2395 }
2396 // There is no link for the current path.
2397 else {
2398 $preferred_link = $current_item;
2399 $curr = FALSE;
2400 }
2401
2402 while ($curr) {
2403 $link = $curr['link'];
2404 if ($link['in_active_trail']) {
2405 // Add the link to the trail, unless it links to its parent.
2406 if (!($link['type'] & MENU_LINKS_TO_PARENT)) {
2407 // The menu tree for the active trail may contain additional links
2408 // that have not been translated yet, since they contain dynamic
2409 // argument placeholders (%). Such links are not contained in regular
2410 // menu trees, and have only been loaded for the additional
2411 // translation that happens here, so as to be able to display them in
2412 // the breadcumb for the current page.
2413 // @see _menu_tree_check_access()
2414 // @see _menu_link_translate()
2415 if (strpos($link['href'], '%') !== FALSE) {
2416 _menu_link_translate($link, TRUE);
2417 }
2418 if ($link['access']) {
2419 $trail[] = $link;
2420 }
2421 }
2422 $tree = $curr['below'] ? $curr['below'] : array();
2423 }
2424 list($key, $curr) = each($tree);
2425 }
2426 // Make sure the current page is in the trail to build the page title, by
2427 // appending either the preferred link or the menu router item for the
2428 // current page. Exclude it if we are on the front page.
2429 $last = end($trail);
2430 if ($preferred_link && $last['href'] != $preferred_link['href'] && !drupal_is_front_page()) {
2431 $trail[] = $preferred_link;
2432 }
2433 }
2434 return $trail;
2435 }
2436
2454 function menu_link_get_preferred($path = NULL, $selected_menu = NULL) {
2455 $preferred_links = &drupal_static(__FUNCTION__);
2456
2457 if (!isset($path)) {
2458 $path = $_GET['q'];
2459 }
2460
2461 if (empty($selected_menu)) {
2462 // Use an illegal menu name as the key for the preferred menu link.
2463 $selected_menu = MENU_PREFERRED_LINK;
2464 }
2465
2466 if (!isset($preferred_links[$path])) {
2467 // Look for the correct menu link by building a list of candidate paths,
2468 // which are ordered by priority (translated hrefs are preferred over
2469 // untranslated paths). Afterwards, the most relevant path is picked from
2470 // the menus, ordered by menu preference.
2471 $item = menu_get_item($path);
2472 $path_candidates = array();
2473 // 1. The current item href.
2474 $path_candidates[$item['href']] = $item['href'];
2475 // 2. The tab root href of the current item (if any).
2476 if ($item['tab_parent'] && ($tab_root = menu_get_item($item['tab_root_href']))) {
2477 $path_candidates[$tab_root['href']] = $tab_root['href'];
2478 }
2479 // 3. The current item path (with wildcards).
2480 $path_candidates[$item['path']] = $item['path'];
2481 // 4. The tab root path of the current item (if any).
2482 if (!empty($tab_root)) {
2483 $path_candidates[$tab_root['path']] = $tab_root['path'];
2484 }
2485
2486 // Retrieve a list of menu names, ordered by preference.
2487 $menu_names = menu_get_active_menu_names();
2488 // Put the selected menu at the front of the list.
2489 array_unshift($menu_names, $selected_menu);
2490
2491 $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
2492 $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
2493 $query->fields('ml');
2494 // Weight must be taken from {menu_links}, not {menu_router}.
2495 $query->addField('ml', 'weight', 'link_weight');
2496 $query->fields('m');
2497 $query->condition('ml.link_path', $path_candidates, 'IN');
2498
2499 // Sort candidates by link path and menu name.
2500 $candidates = array();
2501 foreach ($query->execute() as $candidate) {
2502 $candidate['weight'] = $candidate['link_weight'];
2503 $candidates[$candidate['link_path']][$candidate['menu_name']] = $candidate;
2504 // Add any menus not already in the menu name search list.
2505 if (!in_array($candidate['menu_name'], $menu_names)) {
2506 $menu_names[] = $candidate['menu_name'];
2507 }
2508 }
2509
2510 // Store the most specific link for each menu. Also save the most specific
2511 // link of the most preferred menu in $preferred_link.
2512 foreach ($path_candidates as $link_path) {
2513 if (isset($candidates[$link_path])) {
2514 foreach ($menu_names as $menu_name) {
2515 if (empty($preferred_links[$path][$menu_name]) && isset($candidates[$link_path][$menu_name])) {
2516 $candidate_item = $candidates[$link_path][$menu_name];
2517 $map = explode('/', $path);
2518 _menu_translate($candidate_item, $map);
2519 if ($candidate_item['access']) {
2520 $preferred_links[$path][$menu_name] = $candidate_item;
2521 if (empty($preferred_links[$path][MENU_PREFERRED_LINK])) {
2522 // Store the most specific link.
2523 $preferred_links[$path][MENU_PREFERRED_LINK] = $candidate_item;
2524 }
2525 }
2526 }
2527 }
2528 }
2529 }
2530 }
2531
2532 return isset($preferred_links[$path][$selected_menu]) ? $preferred_links[$path][$selected_menu] : FALSE;
2533 }
2534
2553 function menu_get_active_trail() {
2554 return menu_set_active_trail();
2555 }
2556
2562 function menu_get_active_breadcrumb() {
2563 $breadcrumb = array();
2564
2565 // No breadcrumb for the front page.
2566 if (drupal_is_front_page()) {
2567 return $breadcrumb;
2568 }
2569
2570 $item = menu_get_item();
2571 if (!empty($item['access'])) {
2572 $active_trail = menu_get_active_trail();
2573
2574 // Allow modules to alter the breadcrumb, if possible, as that is much
2575 // faster than rebuilding an entirely new active trail.
2576 drupal_alter('menu_breadcrumb', $active_trail, $item);
2577
2578 // Don't show a link to the current page in the breadcrumb trail.
2579 $end = end($active_trail);
2580 if ($item['href'] == $end['href']) {
2581 array_pop($active_trail);
2582 }
2583
2584 // Remove the tab root (parent) if the current path links to its parent.
2585 // Normally, the tab root link is included in the breadcrumb, as soon as we
2586 // are on a local task or any other child link. However, if we are on a
2587 // default local task (e.g., node/%/view), then we do not want the tab root
2588 // link (e.g., node/%) to appear, as it would be identical to the current
2589 // page. Since this behavior also needs to work recursively (i.e., on
2590 // default local tasks of default local tasks), and since the last non-task
2591 // link in the trail is used as page title (see menu_get_active_title()),
2592 // this condition cannot be cleanly integrated into menu_get_active_trail().
2593 // menu_get_active_trail() already skips all links that link to their parent
2594 // (commonly MENU_DEFAULT_LOCAL_TASK). In order to also hide the parent link
2595 // itself, we always remove the last link in the trail, if the current
2596 // router item links to its parent.
2597 if (($item['type'] & MENU_LINKS_TO_PARENT) == MENU_LINKS_TO_PARENT) {
2598 array_pop($active_trail);
2599 }
2600
2601 foreach ($active_trail as $parent) {
2602 $breadcrumb[] = l($parent['title'], $parent['href'], $parent['localized_options']);
2603 }
2604 }
2605 return $breadcrumb;
2606 }
2607
2611 function menu_get_active_title() {
2612 $active_trail = menu_get_active_trail();
2613
2614 foreach (array_reverse($active_trail) as $item) {
2615 if (!(bool) ($item['type'] & MENU_IS_LOCAL_TASK)) {
2616 return $item['title'];
2617 }
2618 }
2619 }
2620
2635 function menu_link_load($mlid) {
2636 if (is_numeric($mlid)) {
2637 $query = db_select('menu_links', 'ml');
2638 $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
2639 $query->fields('ml');
2640 // Weight should be taken from {menu_links}, not {menu_router}.
2641 $query->addField('ml', 'weight', 'link_weight');
2642 $query->fields('m');
2643 $query->condition('ml.mlid', $mlid);
2644 if ($item = $query->execute()->fetchAssoc()) {
2645 $item['weight'] = $item['link_weight'];
2646 _menu_link_translate($item);
2647 return $item;
2648 }
2649 }
2650 return FALSE;
2651 }
2652
2656 function menu_cache_clear($menu_name = 'navigation') {
2657 $cache_cleared = &drupal_static(__FUNCTION__, array());
2658
2659 if (empty($cache_cleared[$menu_name])) {
2660 cache_clear_all('links:' . $menu_name . ':', 'cache_menu', TRUE);
2661 $cache_cleared[$menu_name] = 1;
2662 }
2663 elseif ($cache_cleared[$menu_name] == 1) {
2664 drupal_register_shutdown_function('cache_clear_all', 'links:' . $menu_name . ':', 'cache_menu', TRUE);
2665 $cache_cleared[$menu_name] = 2;
2666 }
2667
2668 // Also clear the menu system static caches.
2669 menu_reset_static_cache();
2670 }
2671
2678 function menu_cache_clear_all() {
2679 cache_clear_all('*', 'cache_menu', TRUE);
2680 menu_reset_static_cache();
2681 }
2682
2686 function menu_reset_static_cache() {
2687 drupal_static_reset('_menu_build_tree');
2688 drupal_static_reset('menu_tree');
2689 drupal_static_reset('menu_tree_all_data');
2690 drupal_static_reset('menu_tree_page_data');
2691 drupal_static_reset('menu_load_all');
2692 drupal_static_reset('menu_link_get_preferred');
2693 }
2694
2709 function menu_rebuild() {
2710 if (!lock_acquire('menu_rebuild')) {
2711 // Wait for another request that is already doing this work.
2712 // We choose to block here since otherwise the router item may not
2713 // be available in menu_execute_active_handler() resulting in a 404.
2714 lock_wait('menu_rebuild');
2715 return FALSE;
2716 }
2717
2718 $transaction = db_transaction();
2719
2720 try {
2721 list($menu, $masks) = menu_router_build();
2722 _menu_router_save($menu, $masks);
2723 _menu_navigation_links_rebuild($menu);
2724 // Clear the menu, page and block caches.
2725 menu_cache_clear_all();
2726 _menu_clear_page_cache();
2727
2728 if (defined('MAINTENANCE_MODE')) {
2729 variable_set('menu_rebuild_needed', TRUE);
2730 }
2731 else {
2732 variable_del('menu_rebuild_needed');
2733 }
2734 }
2735 catch (Exception $e) {
2736 $transaction->rollback();
2737 watchdog_exception('menu', $e);
2738 }
2739
2740 lock_release('menu_rebuild');
2741 return TRUE;
2742 }
2743
2747 function menu_router_build() {
2748 // We need to manually call each module so that we can know which module
2749 // a given item came from.
2750 $callbacks = array();
2751 foreach (module_implements('menu') as $module) {
2752 $router_items = call_user_func($module . '_menu');
2753 if (isset($router_items) && is_array($router_items)) {
2754 foreach (array_keys($router_items) as $path) {
2755 $router_items[$path]['module'] = $module;
2756 }
2757 $callbacks = array_merge($callbacks, $router_items);
2758 }
2759 }
2760 // Alter the menu as defined in modules, keys are like user/%user.
2761 drupal_alter('menu', $callbacks);
2762 list($menu, $masks) = _menu_router_build($callbacks);
2763 _menu_router_cache($menu);
2764
2765 return array($menu, $masks);
2766 }
2767
2771 function _menu_router_cache($new_menu = NULL) {
2772 $menu = &drupal_static(__FUNCTION__);
2773
2774 if (isset($new_menu)) {
2775 $menu = $new_menu;
2776 }
2777 return $menu;
2778 }
2779
2783 function menu_get_router() {
2784 // Check first if we have it in memory already.
2785 $menu = _menu_router_cache();
2786 if (empty($menu)) {
2787 list($menu, $masks) = menu_router_build();
2788 }
2789 return $menu;
2790 }
2791
2795 function _menu_link_build($item) {
2796 // Suggested items are disabled by default.
2797 if ($item['type'] == MENU_SUGGESTED_ITEM) {
2798 $item['hidden'] = 1;
2799 }
2800 // Hide all items that are not visible in the tree.
2801 elseif (!($item['type'] & MENU_VISIBLE_IN_TREE)) {
2802 $item['hidden'] = -1;
2803 }
2804 // Note, we set this as 'system', so that we can be sure to distinguish all
2805 // the menu links generated automatically from entries in {menu_router}.
2806 $item['module'] = 'system';
2807 $item += array(
2808 'menu_name' => 'navigation',
2809 'link_title' => $item['title'],
2810 'link_path' => $item['path'],
2811 'hidden' => 0,
2812 'options' => empty($item['description']) ? array() : array('attributes' => array('title' => $item['description'])),
2813 );
2814 return $item;
2815 }
2816
2820 function _menu_navigation_links_rebuild($menu) {
2821 // Add normal and suggested items as links.
2822 $menu_links = array();
2823 foreach ($menu as $path => $item) {
2824 if ($item['_visible']) {
2825 $menu_links[$path] = $item;
2826 $sort[$path] = $item['_number_parts'];
2827 }
2828 }
2829 if ($menu_links) {
2830 // Keep an array of processed menu links, to allow menu_link_save() to
2831 // check this for parents instead of querying the database.
2832 $parent_candidates = array();
2833 // Make sure no child comes before its parent.
2834 array_multisort($sort, SORT_NUMERIC, $menu_links);
2835
2836 foreach ($menu_links as $key => $item) {
2837 $existing_item = db_select('menu_links')
2838 ->fields('menu_links')
2839 ->condition('link_path', $item['path'])
2840 ->condition('module', 'system')
2841 ->execute()->fetchAssoc();
2842 if ($existing_item) {
2843 $item['mlid'] = $existing_item['mlid'];
2844 // A change in hook_menu may move the link to a different menu
2845 if (empty($item['menu_name']) || ($item['menu_name'] == $existing_item['menu_name'])) {
2846 $item['menu_name'] = $existing_item['menu_name'];
2847 $item['plid'] = $existing_item['plid'];
2848 }
2849 else {
2850 // It moved to a new menu. Let menu_link_save() try to find a new
2851 // parent based on the path.
2852 unset($item['plid']);
2853 }
2854 $item['has_children'] = $existing_item['has_children'];
2855 $item['updated'] = $existing_item['updated'];
2856 }
2857 if ($existing_item && $existing_item['customized']) {
2858 $parent_candidates[$existing_item['mlid']] = $existing_item;
2859 }
2860 else {
2861 $item = _menu_link_build($item);
2862 menu_link_save($item, $existing_item, $parent_candidates);
2863 $parent_candidates[$item['mlid']] = $item;
2864 unset($menu_links[$key]);
2865 }
2866 }
2867 }
2868 $paths = array_keys($menu);
2869 // Updated and customized items whose router paths are gone need new ones.
2870 $result = db_select('menu_links', NULL, array('fetch' => PDO::FETCH_ASSOC))
2871 ->fields('menu_links', array(
2872 'link_path',
2873 'mlid',
2874 'router_path',
2875 'updated',
2876 ))
2877 ->condition(db_or()
2878 ->condition('updated', 1)
2879 ->condition(db_and()
2880 ->condition('router_path', $paths, 'NOT IN')
2881 ->condition('external', 0)
2882 ->condition('customized', 1)
2883 )
2884 )
2885 ->execute();
2886 foreach ($result as $item) {
2887 $router_path = _menu_find_router_path($item['link_path']);
2888 if (!empty($router_path) && ($router_path != $item['router_path'] || $item['updated'])) {
2889 // If the router path and the link path matches, it's surely a working
2890 // item, so we clear the updated flag.
2891 $updated = $item['updated'] && $router_path != $item['link_path'];
2892 db_update('menu_links')
2893 ->fields(array(
2894 'router_path' => $router_path,
2895 'updated' => (int) $updated,
2896 ))
2897 ->condition('mlid', $item['mlid'])
2898 ->execute();
2899 }
2900 }
2901 // Find any item whose router path does not exist any more.
2902 $result = db_select('menu_links')
2903 ->fields('menu_links')
2904 ->condition('router_path', $paths, 'NOT IN')
2905 ->condition('external', 0)
2906 ->condition('updated', 0)
2907 ->condition('customized', 0)
2908 ->orderBy('depth', 'DESC')
2909 ->execute();
2910 // Remove all such items. Starting from those with the greatest depth will
2911 // minimize the amount of re-parenting done by menu_link_delete().
2912 foreach ($result as $item) {
2913 _menu_delete_item($item, TRUE);
2914 }
2915 }
2916
2934 function menu_links_clone($links, $menu_name = NULL) {
2935 foreach ($links as &$link) {
2936 unset($link['mlid']);
2937 unset($link['plid']);
2938 if (isset($menu_name)) {
2939 $link['menu_name'] = $menu_name;
2940 }
2941 }
2942 return $links;
2943 }
2944
2954 function menu_load_links($menu_name) {
2955 $links = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC))
2956 ->fields('ml')
2957 ->condition('ml.menu_name', $menu_name)
2958 // Order by weight so as to be helpful for menus that are only one level
2959 // deep.
2960 ->orderBy('weight')
2961 ->execute()
2962 ->fetchAll();
2963
2964 foreach ($links as &$link) {
2965 $link['options'] = unserialize($link['options']);
2966 }
2967 return $links;
2968 }
2969
2976 function menu_delete_links($menu_name) {
2977 $links = menu_load_links($menu_name);
2978 foreach ($links as $link) {
2979 // To speed up the deletion process, we reset some link properties that
2980 // would trigger re-parenting logic in _menu_delete_item() and
2981 // _menu_update_parental_status().
2982 $link['has_children'] = FALSE;
2983 $link['plid'] = 0;
2984 _menu_delete_item($link);
2985 }
2986 }
2987
2996 function menu_link_delete($mlid, $path = NULL) {
2997 if (isset($mlid)) {
2998 _menu_delete_item(db_query("SELECT * FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $mlid))->fetchAssoc());
2999 }
3000 else {
3001 $result = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path", array(':link_path' => $path));
3002 foreach ($result as $link) {
3003 _menu_delete_item($link);
3004 }
3005 }
3006 }
3007
3018 function _menu_delete_item($item, $force = FALSE) {
3019 $item = is_object($item) ? get_object_vars($item) : $item;
3020 if ($item && ($item['module'] != 'system' || $item['updated'] || $force)) {
3021 // Children get re-attached to the item's parent.
3022 if ($item['has_children']) {
3023 $result = db_query("SELECT mlid FROM {menu_links} WHERE plid = :plid", array(':plid' => $item['mlid']));
3024 foreach ($result as $m) {
3025 $child = menu_link_load($m->mlid);
3026 $child['plid'] = $item['plid'];
3027 menu_link_save($child);
3028 }
3029 }
3030
3031 // Notify modules we are deleting the item.
3032 module_invoke_all('menu_link_delete', $item);
3033
3034 db_delete('menu_links')->condition('mlid', $item['mlid'])->execute();
3035
3036 // Update the has_children status of the parent.
3037 _menu_update_parental_status($item);
3038 menu_cache_clear($item['menu_name']);
3039 _menu_clear_page_cache();
3040 }
3041 }
3042
3074 function menu_link_save(&$item, $existing_item = array(), $parent_candidates = array()) {
3075 drupal_alter('menu_link', $item);
3076
3077 // This is the easiest way to handle the unique internal path '<front>',
3078 // since a path marked as external does not need to match a router path.
3079 $item['external'] = (url_is_external($item['link_path']) || $item['link_path'] == '<front>') ? 1 : 0;
3080 // Load defaults.
3081 $item += array(
3082 'menu_name' => 'navigation',
3083 'weight' => 0,
3084 'link_title' => '',
3085 'hidden' => 0,
3086 'has_children' => 0,
3087 'expanded' => 0,
3088 'options' => array(),
3089 'module' => 'menu',
3090 'customized' => 0,
3091 'updated' => 0,
3092 );
3093 if (isset($item['mlid'])) {
3094 if (!$existing_item) {
3095 $existing_item = db_query('SELECT * FROM {menu_links} WHERE mlid = :mlid', array('mlid' => $item['mlid']))->fetchAssoc();
3096 }
3097 if ($existing_item) {
3098 $existing_item['options'] = unserialize($existing_item['options']);
3099 }
3100 }
3101 else {
3102 $existing_item = FALSE;
3103 }
3104
3105 // Try to find a parent link. If found, assign it and derive its menu.
3106 $parent = _menu_link_find_parent($item, $parent_candidates);
3107 if (!empty($parent['mlid'])) {
3108 $item['plid'] = $parent['mlid'];
3109 $item['menu_name'] = $parent['menu_name'];
3110 }
3111 // If no corresponding parent link was found, move the link to the top-level.
3112 else {
3113 $item['plid'] = 0;
3114 }
3115 $menu_name = $item['menu_name'];
3116
3117 if (!$existing_item) {
3118 $item['mlid'] = db_insert('menu_links')
3119 ->fields(array(
3120 'menu_name' => $item['menu_name'],
3121 'plid' => $item['plid'],
3122 'link_path' => $item['link_path'],
3123 'hidden' => $item['hidden'],
3124 'external' => $item['external'],
3125 'has_children' => $item['has_children'],
3126 'expanded' => $item['expanded'],
3127 'weight' => $item['weight'],
3128 'module' => $item['module'],
3129 'link_title' => $item['link_title'],
3130 'options' => serialize($item['options']),
3131 'customized' => $item['customized'],
3132 'updated' => $item['updated'],
3133 ))
3134 ->execute();
3135 }
3136
3137 // Directly fill parents for top-level links.
3138 if ($item['plid'] == 0) {
3139 $item['p1'] = $item['mlid'];
3140 for ($i = 2; $i <= MENU_MAX_DEPTH; $i++) {
3141 $item["p$i"] = 0;
3142 }
3143 $item['depth'] = 1;
3144 }
3145 // Otherwise, ensure that this link's depth is not beyond the maximum depth
3146 // and fill parents based on the parent link.
3147 else {
3148 if ($item['has_children'] && $existing_item) {
3149 $limit = MENU_MAX_DEPTH - menu_link_children_relative_depth($existing_item) - 1;
3150 }
3151 else {
3152 $limit = MENU_MAX_DEPTH - 1;
3153 }
3154 if ($parent['depth'] > $limit) {
3155 return FALSE;
3156 }
3157 $item['depth'] = $parent['depth'] + 1;
3158 _menu_link_parents_set($item, $parent);
3159 }
3160 // Need to check both plid and menu_name, since plid can be 0 in any menu.
3161 if ($existing_item && ($item['plid'] != $existing_item['plid'] || $menu_name != $existing_item['menu_name'])) {
3162 _menu_link_move_children($item, $existing_item);
3163 }
3164 // Find the router_path.
3165 if (empty($item['router_path']) || !$existing_item || ($existing_item['link_path'] != $item['link_path'])) {
3166 if ($item['external']) {
3167 $item['router_path'] = '';
3168 }
3169 else {
3170 // Find the router path which will serve this path.
3171 $item['parts'] = explode('/', $item['link_path'], MENU_MAX_PARTS);
3172 $item['router_path'] = _menu_find_router_path($item['link_path']);
3173 }
3174 }
3175 // If every value in $existing_item is the same in the $item, there is no
3176 // reason to run the update queries or clear the caches. We use
3177 // array_intersect_key() with the $item as the first parameter because
3178 // $item may have additional keys left over from building a router entry.
3179 // The intersect removes the extra keys, allowing a meaningful comparison.
3180 if (!$existing_item || (array_intersect_key($item, $existing_item) != $existing_item)) {
3181 db_update('menu_links')
3182 ->fields(array(
3183 'menu_name' => $item['menu_name'],
3184 'plid' => $item['plid'],
3185 'link_path' => $item['link_path'],
3186 'router_path' => $item['router_path'],
3187 'hidden' => $item['hidden'],
3188 'external' => $item['external'],
3189 'has_children' => $item['has_children'],
3190 'expanded' => $item['expanded'],
3191 'weight' => $item['weight'],
3192 'depth' => $item['depth'],
3193 'p1' => $item['p1'],
3194 'p2' => $item['p2'],
3195 'p3' => $item['p3'],
3196 'p4' => $item['p4'],
3197 'p5' => $item['p5'],
3198 'p6' => $item['p6'],
3199 'p7' => $item['p7'],
3200 'p8' => $item['p8'],
3201 'p9' => $item['p9'],
3202 'module' => $item['module'],
3203 'link_title' => $item['link_title'],
3204 'options' => serialize($item['options']),
3205 'customized' => $item['customized'],
3206 ))
3207 ->condition('mlid', $item['mlid'])
3208 ->execute();
3209 // Check the has_children status of the parent.
3210 _menu_update_parental_status($item);
3211 menu_cache_clear($menu_name);
3212 if ($existing_item && $menu_name != $existing_item['menu_name']) {
3213 menu_cache_clear($existing_item['menu_name']);
3214 }
3215 // Notify modules we have acted on a menu item.
3216 $hook = 'menu_link_insert';
3217 if ($existing_item) {
3218 $hook = 'menu_link_update';
3219 }
3220 module_invoke_all($hook, $item);
3221 // Now clear the cache.
3222 _menu_clear_page_cache();
3223 }
3224 return $item['mlid'];
3225 }
3226
3247 function _menu_link_find_parent($menu_link, $parent_candidates = array()) {
3248 $parent = FALSE;
3249
3250 // This item is explicitely top-level, skip the rest of the parenting.
3251 if (isset($menu_link['plid']) && empty($menu_link['plid'])) {
3252 return $parent;
3253 }
3254
3255 // If we have a parent link ID, try to use that.
3256 $candidates = array();
3257 if (isset($menu_link['plid'])) {
3258 $candidates[] = $menu_link['plid'];
3259 }
3260
3261 // Else, if we have a link hierarchy try to find a valid parent in there.
3262 if (!empty($menu_link['depth']) && $menu_link['depth'] > 1) {
3263 for ($depth = $menu_link['depth'] - 1; $depth >= 1; $depth--) {
3264 $candidates[] = $menu_link['p' . $depth];
3265 }
3266 }
3267
3268 foreach ($candidates as $mlid) {
3269 if (isset($parent_candidates[$mlid])) {
3270 $parent = $parent_candidates[$mlid];
3271 }
3272 else {
3273 $parent = db_query("SELECT * FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $mlid))->fetchAssoc();
3274 }
3275 if ($parent) {
3276 return $parent;
3277 }
3278 }
3279
3280 // If everything else failed, try to derive the parent from the path
3281 // hierarchy. This only makes sense for links derived from menu router
3282 // items (ie. from hook_menu()).
3283 if ($menu_link['module'] == 'system') {
3284 $query = db_select('menu_links');
3285 $query->condition('module', 'system');
3286 // We always respect the link's 'menu_name'; inheritance for router items is
3287 // ensured in _menu_router_build().
3288 $query->condition('menu_name', $menu_link['menu_name']);
3289
3290 // Find the parent - it must be unique.
3291 $parent_path = $menu_link['link_path'];
3292 do {
3293 $parent = FALSE;
3294 $parent_path = substr($parent_path, 0, strrpos($parent_path, '/'));
3295 $new_query = clone $query;
3296 $new_query->condition('link_path', $parent_path);
3297 // Only valid if we get a unique result.
3298 if ($new_query->countQuery()->execute()->fetchField() == 1) {
3299 $parent = $new_query->fields('menu_links')->execute()->fetchAssoc();
3300 }
3301 } while ($parent === FALSE && $parent_path);
3302 }
3303
3304 return $parent;
3305 }
3306
3310 function _menu_clear_page_cache() {
3311 $cache_cleared = &drupal_static(__FUNCTION__, 0);
3312
3313 // Clear the page and block caches, but at most twice, including at
3314 // the end of the page load when there are multiple links saved or deleted.
3315 if ($cache_cleared == 0) {
3316 cache_clear_all();
3317 // Keep track of which menus have expanded items.
3318 _menu_set_expanded_menus();
3319 $cache_cleared = 1;
3320 }
3321 elseif ($cache_cleared == 1) {
3322 drupal_register_shutdown_function('cache_clear_all');
3323 // Keep track of which menus have expanded items.
3324 drupal_register_shutdown_function('_menu_set_expanded_menus');
3325 $cache_cleared = 2;
3326 }
3327 }
3328
3332 function _menu_set_expanded_menus() {
3333 $names = db_query("SELECT menu_name FROM {menu_links} WHERE expanded <> 0 GROUP BY menu_name")->fetchCol();
3334 variable_set('menu_expanded', $names);
3335 }
3336
3347 function _menu_find_router_path($link_path) {
3348 // $menu will only have data during a menu rebuild.
3349 $menu = _menu_router_cache();
3350
3351 $router_path = $link_path;
3352 $parts = explode('/', $link_path, MENU_MAX_PARTS);
3353 $ancestors = menu_get_ancestors($parts);
3354
3355 if (empty($menu)) {
3356 // Not during a menu rebuild, so look up in the database.
3357 $router_path = (string) db_select('menu_router')
3358 ->fields('menu_router', array('path'))
3359 ->condition('path', $ancestors, 'IN')
3360 ->orderBy('fit', 'DESC')
3361 ->range(0, 1)
3362 ->execute()->fetchField();
3363 }
3364 elseif (!isset($menu[$router_path])) {
3365 // Add an empty router path as a fallback.
3366 $ancestors[] = '';
3367 foreach ($ancestors as $key => $router_path) {
3368 if (isset($menu[$router_path])) {
3369 // Exit the loop leaving $router_path as the first match.
3370 break;
3371 }
3372 }
3373 // If we did not find the path, $router_path will be the empty string
3374 // at the end of $ancestors.
3375 }
3376 return $router_path;
3377 }
3378
3395 function menu_link_maintain($module, $op, $link_path, $link_title) {
3396 switch ($op) {
3397 case 'insert':
3398 $menu_link = array(
3399 'link_title' => $link_title,
3400 'link_path' => $link_path,
3401 'module' => $module,
3402 );
3403 return menu_link_save($menu_link);
3404 break;
3405 case 'update':
3406 $result = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path AND module = :module AND customized = 0", array(':link_path' => $link_path, ':module' => $module))->fetchAll(PDO::FETCH_ASSOC);
3407 foreach ($result as $link) {
3408 $link['link_title'] = $link_title;
3409 $link['options'] = unserialize($link['options']);
3410 menu_link_save($link);
3411 }
3412 break;
3413 case 'delete':
3414 menu_link_delete(NULL, $link_path);
3415 break;
3416 }
3417 }
3418
3432 function menu_link_children_relative_depth($item) {
3433 $query = db_select('menu_links');
3434 $query->addField('menu_links', 'depth');
3435 $query->condition('menu_name', $item['menu_name']);
3436 $query->orderBy('depth', 'DESC');
3437 $query->range(0, 1);
3438
3439 $i = 1;
3440 $p = 'p1';
3441 while ($i <= MENU_MAX_DEPTH && $item[$p]) {
3442 $query->condition($p, $item[$p]);
3443 $p = 'p' . ++$i;
3444 }
3445
3446 $max_depth = $query->execute()->fetchField();
3447
3448 return ($max_depth > $item['depth']) ? $max_depth - $item['depth'] : 0;
3449 }
3450
3457 function _menu_link_move_children($item, $existing_item) {
3458 $query = db_update('menu_links');
3459
3460 $query->fields(array('menu_name' => $item['menu_name']));
3461
3462 $p = 'p1';
3463 $expressions = array();
3464 for ($i = 1; $i <= $item['depth']; $p = 'p' . ++$i) {
3465 $expressions[] = array($p, ":p_$i", array(":p_$i" => $item[$p]));
3466 }
3467 $j = $existing_item['depth'] + 1;
3468 while ($i <= MENU_MAX_DEPTH && $j <= MENU_MAX_DEPTH) {
3469 $expressions[] = array('p' . $i++, 'p' . $j++, array());
3470 }
3471 while ($i <= MENU_MAX_DEPTH) {
3472 $expressions[] = array('p' . $i++, 0, array());
3473 }
3474
3475 $shift = $item['depth'] - $existing_item['depth'];
3476 if ($shift > 0) {
3477 // The order of expressions must be reversed so the new values don't
3478 // overwrite the old ones before they can be used because "Single-table
3479 // UPDATE assignments are generally evaluated from left to right"
3480 // see: http://dev.mysql.com/doc/refman/5.0/en/update.html
3481 $expressions = array_reverse($expressions);
3482 }
3483 foreach ($expressions as $expression) {
3484 $query->expression($expression[0], $expression[1], $expression[2]);
3485 }
3486
3487 $query->expression('depth', 'depth + :depth', array(':depth' => $shift));
3488 $query->condition('menu_name', $existing_item['menu_name']);
3489 $p = 'p1';
3490 for ($i = 1; $i <= MENU_MAX_DEPTH && $existing_item[$p]; $p = 'p' . ++$i) {
3491 $query->condition($p, $existing_item[$p]);
3492 }
3493
3494 $query->execute();
3495
3496 // Check the has_children status of the parent, while excluding this item.
3497 _menu_update_parental_status($existing_item, TRUE);
3498 }
3499
3503 function _menu_update_parental_status($item, $exclude = FALSE) {
3504 // If plid == 0, there is nothing to update.
3505 if ($item['plid']) {
3506 // Check if at least one visible child exists in the table.
3507 $query = db_select('menu_links');
3508 $query->addField('menu_links', 'mlid');
3509 $query->condition('menu_name', $item['menu_name']);
3510 $query->condition('hidden', 0);
3511 $query->condition('plid', $item['plid']);
3512 $query->range(0, 1);
3513 if ($exclude) {
3514 $query->condition('mlid', $item['mlid'], '<>');
3515 }
3516 $parent_has_children = ((bool) $query->execute()->fetchField()) ? 1 : 0;
3517 db_update('menu_links')
3518 ->fields(array('has_children' => $parent_has_children))
3519 ->condition('mlid', $item['plid'])
3520 ->execute();
3521 }
3522 }
3523
3527 function _menu_link_parents_set(&$item, $parent) {
3528 $i = 1;
3529 while ($i < $item['depth']) {
3530 $p = 'p' . $i++;
3531 $item[$p] = $parent[$p];
3532 }
3533 $p = 'p' . $i++;
3534 // The parent (p1 - p9) corresponding to the depth always equals the mlid.
3535 $item[$p] = $item['mlid'];
3536 while ($i <= MENU_MAX_DEPTH) {
3537 $p = 'p' . $i++;
3538 $item[$p] = 0;
3539 }
3540 }
3541
3545 function _menu_router_build($callbacks) {
3546 // First pass: separate callbacks from paths, making paths ready for
3547 // matching. Calculate fitness, and fill some default values.
3548 $menu = array();
3549 $masks = array();
3550 foreach ($callbacks as $path => $item) {
3551 $load_functions = array();
3552 $to_arg_functions = array();
3553 $fit = 0;
3554 $move = FALSE;
3555
3556 $parts = explode('/', $path, MENU_MAX_PARTS);
3557 $number_parts = count($parts);
3558 // We store the highest index of parts here to save some work in the fit
3559 // calculation loop.
3560 $slashes = $number_parts - 1;
3561 // Extract load and to_arg functions.
3562 foreach ($parts as $k => $part) {
3563 $match = FALSE;
3564 // Look for wildcards in the form allowed to be used in PHP functions,
3565 // because we are using these to construct the load function names.
3566 if (preg_match('/^%(|' . DRUPAL_PHP_FUNCTION_PATTERN . ')$/', $part, $matches)) {
3567 if (empty($matches[1])) {
3568 $match = TRUE;
3569 $load_functions[$k] = NULL;
3570 }
3571 else {
3572 if (function_exists($matches[1] . '_to_arg')) {
3573 $to_arg_functions[$k] = $matches[1] . '_to_arg';
3574 $load_functions[$k] = NULL;
3575 $match = TRUE;
3576 }
3577 if (function_exists($matches[1] . '_load')) {
3578 $function = $matches[1] . '_load';
3579 // Create an array of arguments that will be passed to the _load
3580 // function when this menu path is checked, if 'load arguments'
3581 // exists.
3582 $load_functions[$k] = isset($item['load arguments']) ? array($function => $item['load arguments']) : $function;
3583 $match = TRUE;
3584 }
3585 }
3586 }
3587 if ($match) {
3588 $parts[$k] = '%';
3589 }
3590 else {
3591 $fit |= 1 << ($slashes - $k);
3592 }
3593 }
3594 if ($fit) {
3595 $move = TRUE;
3596 }
3597 else {
3598 // If there is no %, it fits maximally.
3599 $fit = (1 << $number_parts) - 1;
3600 }
3601 $masks[$fit] = 1;
3602 $item['_load_functions'] = $load_functions;
3603 $item['to_arg_functions'] = empty($to_arg_functions) ? '' : serialize($to_arg_functions);
3604 $item += array(
3605 'title' => '',
3606 'weight' => 0,
3607 'type' => MENU_NORMAL_ITEM,
3608 'module' => '',
3609 '_number_parts' => $number_parts,
3610 '_parts' => $parts,
3611 '_fit' => $fit,
3612 );
3613 $item += array(
3614 '_visible' => (bool) ($item['type'] & MENU_VISIBLE_IN_BREADCRUMB),
3615 '_tab' => (bool) ($item['type'] & MENU_IS_LOCAL_TASK),
3616 );
3617 if ($move) {
3618 $new_path = implode('/', $item['_parts']);
3619 $menu[$new_path] = $item;
3620 $sort[$new_path] = $number_parts;
3621 }
3622 else {
3623 $menu[$path] = $item;
3624 $sort[$path] = $number_parts;
3625 }
3626 }
3627 array_multisort($sort, SORT_NUMERIC, $menu);
3628 // Apply inheritance rules.
3629 foreach ($menu as $path => $v) {
3630 $item = &$menu[$path];
3631 if (!$item['_tab']) {
3632 // Non-tab items.
3633 $item['tab_parent'] = '';
3634 $item['tab_root'] = $path;
3635 }
3636 // If not specified, assign the default tab type for local tasks.
3637 elseif (!isset($item['context'])) {
3638 $item['context'] = MENU_CONTEXT_PAGE;
3639 }
3640 for ($i = $item['_number_parts'] - 1; $i; $i--) {
3641 $parent_path = implode('/', array_slice($item['_parts'], 0, $i));
3642 if (isset($menu[$parent_path])) {
3643
3644 $parent = &$menu[$parent_path];
3645
3646 // If we have no menu name, try to inherit it from parent items.
3647 if (!isset($item['menu_name'])) {
3648 // If the parent item of this item does not define a menu name (and no
3649 // previous iteration assigned one already), try to find the menu name
3650 // of the parent item in the currently stored menu links.
3651 if (!isset($parent['menu_name'])) {
3652 $menu_name = db_query("SELECT menu_name FROM {menu_links} WHERE router_path = :router_path AND module = 'system'", array(':router_path' => $parent_path))->fetchField();
3653 if ($menu_name) {
3654 $parent['menu_name'] = $menu_name;
3655 }
3656 }
3657 // If the parent item defines a menu name, inherit it.
3658 if (!empty($parent['menu_name'])) {
3659 $item['menu_name'] = $parent['menu_name'];
3660 }
3661 }
3662 if (!isset($item['tab_parent'])) {
3663 // Parent stores the parent of the path.
3664 $item['tab_parent'] = $parent_path;
3665 }
3666 if (!isset($item['tab_root']) && !$parent['_tab']) {
3667 $item['tab_root'] = $parent_path;
3668 }
3669 // If an access callback is not found for a default local task we use
3670 // the callback from the parent, since we expect them to be identical.
3671 // In all other cases, the access parameters must be specified.
3672 if (($item['type'] == MENU_DEFAULT_LOCAL_TASK) && !isset($item['access callback']) && isset($parent['access callback'])) {
3673 $item['access callback'] = $parent['access callback'];
3674 if (!isset($item['access arguments']) && isset($parent['access arguments'])) {
3675 $item['access arguments'] = $parent['access arguments'];
3676 }
3677 }
3678 // Same for page callbacks.
3679 if (!isset($item['page callback']) && isset($parent['page callback'])) {
3680 $item['page callback'] = $parent['page callback'];
3681 if (!isset($item['page arguments']) && isset($parent['page arguments'])) {
3682 $item['page arguments'] = $parent['page arguments'];
3683 }
3684 if (!isset($item['file path']) && isset($parent['file path'])) {
3685 $item['file path'] = $parent['file path'];
3686 }
3687 if (!isset($item['file']) && isset($parent['file'])) {
3688 $item['file'] = $parent['file'];
3689 if (empty($item['file path']) && isset($item['module']) && isset($parent['module']) && $item['module'] != $parent['module']) {
3690 $item['file path'] = drupal_get_path('module', $parent['module']);
3691 }
3692 }
3693 }
3694 // Same for delivery callbacks.
3695 if (!isset($item['delivery callback']) && isset($parent['delivery callback'])) {
3696 $item['delivery callback'] = $parent['delivery callback'];
3697 }
3698 // Same for theme callbacks.
3699 if (!isset($item['theme callback']) && isset($parent['theme callback'])) {
3700 $item['theme callback'] = $parent['theme callback'];
3701 if (!isset($item['theme arguments']) && isset($parent['theme arguments'])) {
3702 $item['theme arguments'] = $parent['theme arguments'];
3703 }
3704 }
3705 // Same for load arguments: if a loader doesn't have any explict
3706 // arguments, try to find arguments in the parent.
3707 if (!isset($item['load arguments'])) {
3708 foreach ($item['_load_functions'] as $k => $function) {
3709 // This loader doesn't have any explict arguments...
3710 if (!is_array($function)) {
3711 // ... check the parent for a loader at the same position
3712 // using the same function name and defining arguments...
3713 if (isset($parent['_load_functions'][$k]) && is_array($parent['_load_functions'][$k]) && key($parent['_load_functions'][$k]) === $function) {
3714 // ... and inherit the arguments on the child.
3715 $item['_load_functions'][$k] = $parent['_load_functions'][$k];
3716 }
3717 }
3718 }
3719 }
3720 }
3721 }
3722 if (!isset($item['access callback']) && isset($item['access arguments'])) {
3723 // Default callback.
3724 $item['access callback'] = 'user_access';
3725 }
3726 if (!isset($item['access callback']) || empty($item['page callback'])) {
3727 $item['access callback'] = 0;
3728 }
3729 if (is_bool($item['access callback'])) {
3730 $item['access callback'] = intval($item['access callback']);
3731 }
3732
3733 $item['load_functions'] = empty($item['_load_functions']) ? '' : serialize($item['_load_functions']);
3734 $item += array(
3735 'access arguments' => array(),
3736 'access callback' => '',
3737 'page arguments' => array(),
3738 'page callback' => '',
3739 'delivery callback' => '',
3740 'title arguments' => array(),
3741 'title callback' => 't',
3742 'theme arguments' => array(),
3743 'theme callback' => '',
3744 'description' => '',
3745 'position' => '',
3746 'context' => 0,
3747 'tab_parent' => '',
3748 'tab_root' => $path,
3749 'path' => $path,
3750 'file' => '',
3751 'file path' => '',
3752 'include file' => '',
3753 );
3754
3755 // Calculate out the file to be included for each callback, if any.
3756 if ($item['file']) {
3757 $file_path = $item['file path'] ? $item['file path'] : drupal_get_path('module', $item['module']);
3758 $item['include file'] = $file_path . '/' . $item['file'];
3759 }
3760 }
3761
3762 // Sort the masks so they are in order of descending fit.
3763 $masks = array_keys($masks);
3764 rsort($masks);
3765
3766 return array($menu, $masks);
3767 }
3768
3772 function _menu_router_save($menu, $masks) {
3773 // Delete the existing router since we have some data to replace it.
3774 db_truncate('menu_router')->execute();
3775
3776 // Prepare insert object.
3777 $insert = db_insert('menu_router')
3778 ->fields(array(
3779 'path',
3780 'load_functions',
3781 'to_arg_functions',
3782 'access_callback',
3783 'access_arguments',
3784 'page_callback',
3785 'page_arguments',
3786 'delivery_callback',
3787 'fit',
3788 'number_parts',
3789 'context',
3790 'tab_parent',
3791 'tab_root',
3792 'title',
3793 'title_callback',
3794 'title_arguments',
3795 'theme_callback',
3796 'theme_arguments',
3797 'type',
3798 'description',
3799 'position',
3800 'weight',
3801 'include_file',
3802 ));
3803
3804 $num_records = 0;
3805
3806 foreach ($menu as $path => $item) {
3807 // Fill in insert object values.
3808 $insert->values(array(
3809 'path' => $item['path'],
3810 'load_functions' => $item['load_functions'],
3811 'to_arg_functions' => $item['to_arg_functions'],
3812 'access_callback' => $item['access callback'],
3813 'access_arguments' => serialize($item['access arguments']),
3814 'page_callback' => $item['page callback'],
3815 'page_arguments' => serialize($item['page arguments']),
3816 'delivery_callback' => $item['delivery callback'],
3817 'fit' => $item['_fit'],
3818 'number_parts' => $item['_number_parts'],
3819 'context' => $item['context'],
3820 'tab_parent' => $item['tab_parent'],
3821 'tab_root' => $item['tab_root'],
3822 'title' => $item['title'],
3823 'title_callback' => $item['title callback'],
3824 'title_arguments' => ($item['title arguments'] ? serialize($item['title arguments']) : ''),
3825 'theme_callback' => $item['theme callback'],
3826 'theme_arguments' => serialize($item['theme arguments']),
3827 'type' => $item['type'],
3828 'description' => $item['description'],
3829 'position' => $item['position'],
3830 'weight' => $item['weight'],
3831 'include_file' => $item['include file'],
3832 ));
3833
3834 // Execute in batches to avoid the memory overhead of all of those records
3835 // in the query object.
3836 if (++$num_records == 20) {
3837 $insert->execute();
3838 $num_records = 0;
3839 }
3840 }
3841 // Insert any remaining records.
3842 $insert->execute();
3843 // Store the masks.
3844 variable_set('menu_masks', $masks);
3845
3846 return $menu;
3847 }
3848
3866 function _menu_site_is_offline($check_only = FALSE) {
3867 // Check if site is in maintenance mode.
3868 if (variable_get('maintenance_mode', 0)) {
3869 if (user_access('access site in maintenance mode')) {
3870 // Ensure that the maintenance mode message is displayed only once
3871 // (allowing for page redirects) and specifically suppress its display on
3872 // the maintenance mode settings page.
3873 if (!$check_only && $_GET['q'] != 'admin/config/development/maintenance') {
3874 if (user_access('administer site configuration')) {
3875 drupal_set_message(t('Operating in maintenance mode. <a href="@url">Go online.</a>', array('@url' => url('admin/config/development/maintenance'))), 'status', FALSE);
3876 }
3877 else {
3878 drupal_set_message(t('Operating in maintenance mode.'), 'status', FALSE);
3879 }
3880 }
3881 }
3882 else {
3883 return TRUE;
3884 }
3885 }
3886 return FALSE;
3887 }
3888
menu_get_active_help
menu_get_active_help()
Definition: menu.inc:1708
_menu_router_save
_menu_router_save($menu, $masks)
Definition: menu.inc:3772
menu_link_maintain
menu_link_maintain($module, $op, $link_path, $link_title)
Definition: menu.inc:3395
drupal_is_front_page
drupal_is_front_page()
Definition: path.inc:284
url_is_external
url_is_external($path)
Definition: common.inc:2311
watchdog_exception
watchdog_exception($type, Exception $exception, $message=NULL, $variables=array(), $severity=WATCHDOG_ERROR, $link=NULL)
Definition: bootstrap.inc:1654
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
_menu_item_localize
_menu_item_localize(&$item, $map, $link_translate=FALSE)
Definition: menu.inc:668
MENU_SITE_ONLINE
const MENU_SITE_ONLINE
Definition: menu.inc:249
menu_get_router
menu_get_router()
Definition: menu.inc:2783
menu_link_save
menu_link_save(&$item, $existing_item=array(), $parent_candidates=array())
Definition: menu.inc:3074
$op
$op
Definition: update.php:404
menu_delete_links
menu_delete_links($menu_name)
Definition: menu.inc:2976
menu_set_custom_theme
menu_set_custom_theme()
Definition: menu.inc:1769
menu_get_item
menu_get_item($path=NULL, $router_item=NULL)
Definition: menu.inc:447
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
menu_local_tasks
menu_local_tasks($level=0)
Definition: menu.inc:1899
drupal_strlen
drupal_strlen($text)
Definition: unicode.inc:474
menu_tree_check_access
menu_tree_check_access(&$tree, $node_links=array())
Definition: menu.inc:1487
menu_get_names
menu_get_names()
Definition: menu.inc:1776
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
MENU_ACCESS_DENIED
const MENU_ACCESS_DENIED
Definition: menu.inc:239
$module
print $module
Definition: search-results.tpl.php:28
MENU_CONTEXT_NONE
const MENU_CONTEXT_NONE
Definition: menu.inc:204
menu_get_active_title
menu_get_active_title()
Definition: menu.inc:2611
menu_tree_set_path
menu_tree_set_path($menu_name, $path=NULL)
Definition: menu.inc:1170
drupal_help_arg
drupal_help_arg($arg=array())
Definition: menu.inc:1700
_menu_tree_check_access
_menu_tree_check_access(&$tree)
Definition: menu.inc:1508
_menu_link_move_children
_menu_link_move_children($item, $existing_item)
Definition: menu.inc:3457
MENU_SITE_OFFLINE
const MENU_SITE_OFFLINE
Definition: menu.inc:244
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
menu_tree_page_data
menu_tree_page_data($menu_name, $max_depth=NULL, $only_active_trail=FALSE)
Definition: menu.inc:1214
Exception
_menu_build_tree
_menu_build_tree($menu_name, array $parameters=array())
Definition: menu.inc:1368
menu_set_active_item
menu_set_active_item($path)
Definition: menu.inc:2340
theme_menu_local_action
theme_menu_local_action($variables)
Definition: menu.inc:1679
menu_get_custom_theme
menu_get_custom_theme($initialize=FALSE)
Definition: menu.inc:1740
menu_local_actions
menu_local_actions()
Definition: menu.inc:2245
menu_link_delete
menu_link_delete($mlid, $path=NULL)
Definition: menu.inc:2996
_menu_link_build
_menu_link_build($item)
Definition: menu.inc:2795
drupal_attributes
drupal_attributes(array $attributes=array())
Definition: common.inc:2377
menu_tab_root_path
menu_tab_root_path()
Definition: menu.inc:2253
MENU_NORMAL_ITEM
const MENU_NORMAL_ITEM
Definition: menu.inc:143
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
drupal_substr
drupal_substr($text, $start, $length=NULL)
Definition: unicode.inc:585
drupal_theme_access
drupal_theme_access($theme)
Definition: theme.inc:47
_menu_router_cache
_menu_router_cache($new_menu=NULL)
Definition: menu.inc:2771
template_preprocess_menu_tree
template_preprocess_menu_tree(&$variables)
Definition: menu.inc:1598
_menu_link_translate
_menu_link_translate(&$item, $translate=FALSE)
Definition: menu.inc:870
menu_primary_local_tasks
menu_primary_local_tasks()
Definition: menu.inc:2227
menu_get_active_breadcrumb
menu_get_active_breadcrumb()
Definition: menu.inc:2562
menu_reset_static_cache
menu_reset_static_cache()
Definition: menu.inc:2686
db_or
db_or()
Definition: database.inc:2662
_menu_clear_page_cache
_menu_clear_page_cache()
Definition: menu.inc:3310
menu_router_build
menu_router_build()
Definition: menu.inc:2747
menu_tree_output
menu_tree_output($tree)
Definition: menu.inc:1016
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
menu_unserialize
menu_unserialize($data, $map)
Definition: menu.inc:398
MENU_NOT_FOUND
const MENU_NOT_FOUND
Definition: menu.inc:234
menu_load_links
menu_load_links($menu_name)
Definition: menu.inc:2954
menu_execute_active_handler
menu_execute_active_handler($path=NULL, $deliver=TRUE)
Definition: menu.inc:500
_menu_link_parents_set
_menu_link_parents_set(&$item, $parent)
Definition: menu.inc:3527
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
menu_rebuild
menu_rebuild()
Definition: menu.inc:2709
_menu_link_map_translate
_menu_link_map_translate(&$map, $to_arg_functions)
Definition: menu.inc:810
MENU_MAX_PARTS
const MENU_MAX_PARTS
Definition: menu.inc:264
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
MENU_LINKS_TO_PARENT
const MENU_LINKS_TO_PARENT
Definition: menu.inc:101
_menu_link_find_parent
_menu_link_find_parent($menu_link, $parent_candidates=array())
Definition: menu.inc:3247
menu_link_children_relative_depth
menu_link_children_relative_depth($item)
Definition: menu.inc:3432
menu_secondary_menu
menu_secondary_menu()
Definition: menu.inc:1811
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
$value
print $value
Definition: user-profile-item.tpl.php:26
menu_link_load
menu_link_load($mlid)
Definition: menu.inc:2635
menu_contextual_links
menu_contextual_links($module, $parent_path, $args)
Definition: menu.inc:2159
menu_get_active_trail
menu_get_active_trail()
Definition: menu.inc:2553
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
_menu_translate
_menu_translate(&$router_item, $map, $to_arg=FALSE)
Definition: menu.inc:753
theme_menu_local_task
theme_menu_local_task($variables)
Definition: menu.inc:1648
_menu_navigation_links_rebuild
_menu_navigation_links_rebuild($menu)
Definition: menu.inc:2820
$output
$output
Definition: authorize.php:93
MENU_IS_LOCAL_TASK
const MENU_IS_LOCAL_TASK
Definition: menu.inc:116
$depth
print $depth
Definition: book-node-export-html.tpl.php:21
_menu_site_is_offline
_menu_site_is_offline($check_only=FALSE)
Definition: menu.inc:3866
user_access
user_access($string, $account=NULL)
Definition: user.module:794
menu_link_get_preferred
menu_link_get_preferred($path=NULL, $selected_menu=NULL)
Definition: menu.inc:2454
_menu_check_access
_menu_check_access(&$item, $map)
Definition: menu.inc:620
menu_cache_clear_all
menu_cache_clear_all()
Definition: menu.inc:2678
menu_secondary_local_tasks
menu_secondary_local_tasks()
Definition: menu.inc:2236
_menu_load_objects
_menu_load_objects(&$item, &$map)
Definition: menu.inc:554
MENU_IS_LOCAL_ACTION
const MENU_IS_LOCAL_ACTION
Definition: menu.inc:121
MENU_MAX_DEPTH
const MENU_MAX_DEPTH
Definition: menu.inc:270
menu_main_menu
menu_main_menu()
Definition: menu.inc:1804
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
_menu_delete_item
_menu_delete_item($item, $force=FALSE)
Definition: menu.inc:3018
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
menu_list_system_menus
menu_list_system_menus()
Definition: menu.inc:1792
MENU_VISIBLE_IN_BREADCRUMB
const MENU_VISIBLE_IN_BREADCRUMB
Definition: menu.inc:96
_menu_set_expanded_menus
_menu_set_expanded_menus()
Definition: menu.inc:3332
theme_menu_tree
theme_menu_tree($variables)
Definition: menu.inc:1612
menu_tree_all_data
menu_tree_all_data($menu_name, $link=NULL, $max_depth=NULL)
Definition: menu.inc:1105
MENU_SUGGESTED_ITEM
const MENU_SUGGESTED_ITEM
Definition: menu.inc:161
menu_tail_load
menu_tail_load($arg, &$map, $index)
Definition: menu.inc:842
MENU_PREFERRED_LINK
const MENU_PREFERRED_LINK
Definition: menu.inc:289
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
db_transaction
db_transaction($name=NULL, array $options=array())
Definition: database.inc:2535
theme_menu_link
theme_menu_link(array $variables)
Definition: menu.inc:1625
menu_set_active_trail
menu_set_active_trail($new_trail=NULL)
Definition: menu.inc:2367
theme_menu_local_tasks
theme_menu_local_tasks(&$variables)
Definition: menu.inc:2280
_menu_router_build
_menu_router_build($callbacks)
Definition: menu.inc:3545
_menu_tree_data
_menu_tree_data(&$links, $parents, $depth)
Definition: menu.inc:1566
lock_acquire
lock_acquire($name, $timeout=30.0)
Definition: lock.inc:102
lock_wait
lock_wait($name, $delay=30)
Definition: lock.inc:203
MENU_VISIBLE_IN_TREE
const MENU_VISIBLE_IN_TREE
Definition: menu.inc:91
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
$breadcrumb
print $breadcrumb
Definition: page.tpl.php:40
MENU_CONTEXT_INLINE
const MENU_CONTEXT_INLINE
Definition: menu.inc:214
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
_menu_find_router_path
_menu_find_router_path($link_path)
Definition: menu.inc:3347
_menu_update_parental_status
_menu_update_parental_status($item, $exclude=FALSE)
Definition: menu.inc:3503
menu_cache_clear
menu_cache_clear($menu_name= 'navigation')
Definition: menu.inc:2656
$children
print $children
Definition: book-node-export-html.tpl.php:24
DRUPAL_PHP_FUNCTION_PATTERN
const DRUPAL_PHP_FUNCTION_PATTERN
Definition: bootstrap.inc:249
menu_tail_to_arg
menu_tail_to_arg($arg, $map, $index)
Definition: menu.inc:827
menu_set_active_menu_names
menu_set_active_menu_names($menu_names=NULL)
Definition: menu.inc:2311
MAINTENANCE_MODE
const MAINTENANCE_MODE
Definition: authorize.php:36
$help
print $help
Definition: maintenance-page.tpl.php:69
menu_tree
menu_tree($menu_name)
Definition: menu.inc:992
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
menu_tree_collect_node_links
menu_tree_collect_node_links(&$tree, &$node_links)
Definition: menu.inc:1463
$tree
if($tree||$has_links) print $tree
Definition: book-navigation.tpl.php:35
menu_get_active_menu_names
menu_get_active_menu_names()
Definition: menu.inc:2326
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
menu_get_ancestors
menu_get_ancestors($parts)
Definition: menu.inc:319
menu_tree_get_path
menu_tree_get_path($menu_name)
Definition: menu.inc:1188
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
menu_navigation_links
menu_navigation_links($menu_name, $level=0)
Definition: menu.inc:1834
drupal_deliver_page
drupal_deliver_page($page_callback_result, $default_delivery_callback=NULL)
Definition: common.inc:2554
db_truncate
db_truncate($table, array $options=array())
Definition: database.inc:2495
menu_set_item
menu_set_item($path, $router_item)
Definition: menu.inc:425
menu_local_tabs
menu_local_tabs()
Definition: menu.inc:2261
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
menu_get_object
menu_get_object($type= 'node', $position=1, $path=NULL)
Definition: menu.inc:971
menu_build_tree
menu_build_tree($menu_name, array $parameters=array())
Definition: menu.inc:1351
lock_release
lock_release($name)
Definition: lock.inc:247
menu_tree_data
menu_tree_data(array $links, array $parents=array(), $depth=1)
Definition: menu.inc:1554
$links
print $links
Definition: poll-results--block.tpl.php:28
MENU_CONTEXT_PAGE
const MENU_CONTEXT_PAGE
Definition: menu.inc:209
drupal_register_shutdown_function
& drupal_register_shutdown_function($callback=NULL)
Definition: bootstrap.inc:3417
db_and
db_and()
Definition: database.inc:2671
menu_links_clone
menu_links_clone($links, $menu_name=NULL)
Definition: menu.inc:2934
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.module Source File

  • modules
  • aggregator
aggregator.module
Go to the documentation of this file.
1 <?php
2
11 define('AGGREGATOR_CLEAR_NEVER', 0);
12
16 function aggregator_help($path, $arg) {
17 switch ($path) {
18 case 'admin/help#aggregator':
19 $output = '';
20 $output .= '<h3>' . t('About') . '</h3>';
21 $output .= '<p>' . t('The Aggregator module is an on-site syndicator and news reader that gathers and displays fresh content from RSS-, RDF-, and Atom-based feeds made available across the web. Thousands of sites (particularly news sites and blogs) publish their latest headlines in feeds, using a number of standardized XML-based formats. For more information, see the online handbook entry for <a href="@aggregator-module">Aggregator module</a>.', array('@aggregator-module' => 'http://drupal.org/documentation/modules/aggregator', '@aggregator' => url('aggregator'))) . '</p>';
22 $output .= '<h3>' . t('Uses') . '</h3>';
23 $output .= '<dl>';
24 $output .= '<dt>' . t('Viewing feeds') . '</dt>';
25 $output .= '<dd>' . t('Feeds contain published content, and may be grouped in categories, generally by topic. Users view feed content in the <a href="@aggregator">main aggregator display</a>, or by <a href="@aggregator-sources">their source</a> (usually via an RSS feed reader). The most recent content in a feed or category can be displayed as a block through the <a href="@admin-block">Blocks administration page</a>.', array('@aggregator' => url('aggregator'), '@aggregator-sources' => url('aggregator/sources'), '@admin-block' => url('admin/structure/block'))) . '</a></dd>';
26 $output .= '<dt>' . t('Adding, editing, and deleting feeds') . '</dt>';
27 $output .= '<dd>' . t('Administrators can add, edit, and delete feeds, and choose how often to check each feed for newly updated items on the <a href="@feededit">Feed aggregator administration page</a>.', array('@feededit' => url('admin/config/services/aggregator'))) . '</dd>';
28 $output .= '<dt>' . t('OPML integration') . '</dt>';
29 $output .= '<dd>' . t('A <a href="@aggregator-opml">machine-readable OPML file</a> of all feeds is available. OPML is an XML-based file format used to share outline-structured information such as a list of RSS feeds. Feeds can also be <a href="@import-opml">imported via an OPML file</a>.', array('@aggregator-opml' => url('aggregator/opml'), '@import-opml' => url('admin/config/services/aggregator'))) . '</dd>';
30 $output .= '<dt>' . t('Configuring cron') . '</dt>';
31 $output .= '<dd>' . t('A correctly configured <a href="@cron">cron maintenance task</a> is required to update feeds automatically.', array('@cron' => 'http://drupal.org/cron')) . '</dd>';
32 $output .= '</dl>';
33 return $output;
34 case 'admin/config/services/aggregator':
35 $output = '<p>' . t('Thousands of sites (particularly news sites and blogs) publish their latest headlines and posts in feeds, using a number of standardized XML-based formats. Formats supported by the aggregator include <a href="@rss">RSS</a>, <a href="@rdf">RDF</a>, and <a href="@atom">Atom</a>.', array('@rss' => 'http://cyber.law.harvard.edu/rss/', '@rdf' => 'http://www.w3.org/RDF/', '@atom' => 'http://www.atomenabled.org')) . '</p>';
36 $output .= '<p>' . t('Current feeds are listed below, and <a href="@addfeed">new feeds may be added</a>. For each feed or feed category, the <em>latest items</em> block may be enabled at the <a href="@block">blocks administration page</a>.', array('@addfeed' => url('admin/config/services/aggregator/add/feed'), '@block' => url('admin/structure/block'))) . '</p>';
37 return $output;
38 case 'admin/config/services/aggregator/add/feed':
39 return '<p>' . t('Add a feed in RSS, RDF or Atom format. A feed may only have one entry.') . '</p>';
40 case 'admin/config/services/aggregator/add/category':
41 return '<p>' . t('Categories allow feed items from different feeds to be grouped together. For example, several sport-related feeds may belong to a category named <em>Sports</em>. Feed items may be grouped automatically (by selecting a category when creating or editing a feed) or manually (via the <em>Categorize</em> page available from feed item listings). Each category provides its own feed page and block.') . '</p>';
42 case 'admin/config/services/aggregator/add/opml':
43 return '<p>' . t('<acronym title="Outline Processor Markup Language">OPML</acronym> is an XML format used to exchange multiple feeds between aggregators. A single OPML document may contain a collection of many feeds. Drupal can parse such a file and import all feeds at once, saving you the effort of adding them manually. You may either upload a local file from your computer or enter a URL where Drupal can download it.') . '</p>';
44 }
45 }
46
50 function aggregator_theme() {
51 return array(
52 'aggregator_wrapper' => array(
53 'variables' => array('content' => NULL),
54 'file' => 'aggregator.pages.inc',
55 'template' => 'aggregator-wrapper',
56 ),
57 'aggregator_categorize_items' => array(
58 'render element' => 'form',
59 'file' => 'aggregator.pages.inc',
60 ),
61 'aggregator_feed_source' => array(
62 'variables' => array('feed' => NULL),
63 'file' => 'aggregator.pages.inc',
64 'template' => 'aggregator-feed-source',
65 ),
66 'aggregator_block_item' => array(
67 'variables' => array('item' => NULL, 'feed' => 0),
68 ),
69 'aggregator_summary_items' => array(
70 'variables' => array('summary_items' => NULL, 'source' => NULL),
71 'file' => 'aggregator.pages.inc',
72 'template' => 'aggregator-summary-items',
73 ),
74 'aggregator_summary_item' => array(
75 'variables' => array('item' => NULL),
76 'file' => 'aggregator.pages.inc',
77 'template' => 'aggregator-summary-item',
78 ),
79 'aggregator_item' => array(
80 'variables' => array('item' => NULL),
81 'file' => 'aggregator.pages.inc',
82 'template' => 'aggregator-item',
83 ),
84 'aggregator_page_opml' => array(
85 'variables' => array('feeds' => NULL),
86 'file' => 'aggregator.pages.inc',
87 ),
88 'aggregator_page_rss' => array(
89 'variables' => array('feeds' => NULL, 'category' => NULL),
90 'file' => 'aggregator.pages.inc',
91 ),
92 );
93 }
94
98 function aggregator_menu() {
99 $items['admin/config/services/aggregator'] = array(
100 'title' => 'Feed aggregator',
101 'description' => "Configure which content your site aggregates from other sites, how often it polls them, and how they're categorized.",
102 'page callback' => 'aggregator_admin_overview',
103 'access arguments' => array('administer news feeds'),
104 'weight' => 10,
105 'file' => 'aggregator.admin.inc',
106 );
107 $items['admin/config/services/aggregator/add/feed'] = array(
108 'title' => 'Add feed',
109 'page callback' => 'drupal_get_form',
110 'page arguments' => array('aggregator_form_feed'),
111 'access arguments' => array('administer news feeds'),
112 'type' => MENU_LOCAL_ACTION,
113 'file' => 'aggregator.admin.inc',
114 );
115 $items['admin/config/services/aggregator/add/category'] = array(
116 'title' => 'Add category',
117 'page callback' => 'drupal_get_form',
118 'page arguments' => array('aggregator_form_category'),
119 'access arguments' => array('administer news feeds'),
120 'type' => MENU_LOCAL_ACTION,
121 'file' => 'aggregator.admin.inc',
122 );
123 $items['admin/config/services/aggregator/add/opml'] = array(
124 'title' => 'Import OPML',
125 'page callback' => 'drupal_get_form',
126 'page arguments' => array('aggregator_form_opml'),
127 'access arguments' => array('administer news feeds'),
128 'type' => MENU_LOCAL_ACTION,
129 'file' => 'aggregator.admin.inc',
130 );
131 $items['admin/config/services/aggregator/remove/%aggregator_feed'] = array(
132 'title' => 'Remove items',
133 'page callback' => 'drupal_get_form',
134 'page arguments' => array('aggregator_admin_remove_feed', 5),
135 'access arguments' => array('administer news feeds'),
136 'file' => 'aggregator.admin.inc',
137 );
138 $items['admin/config/services/aggregator/update/%aggregator_feed'] = array(
139 'title' => 'Update items',
140 'page callback' => 'aggregator_admin_refresh_feed',
141 'page arguments' => array(5),
142 'access arguments' => array('administer news feeds'),
143 'file' => 'aggregator.admin.inc',
144 );
145 $items['admin/config/services/aggregator/list'] = array(
146 'title' => 'List',
147 'type' => MENU_DEFAULT_LOCAL_TASK,
148 'weight' => -10,
149 );
150 $items['admin/config/services/aggregator/settings'] = array(
151 'title' => 'Settings',
152 'description' => 'Configure the behavior of the feed aggregator, including when to discard feed items and how to present feed items and categories.',
153 'page callback' => 'drupal_get_form',
154 'page arguments' => array('aggregator_admin_form'),
155 'access arguments' => array('administer news feeds'),
156 'type' => MENU_LOCAL_TASK,
157 'file' => 'aggregator.admin.inc',
158 );
159 $items['aggregator'] = array(
160 'title' => 'Feed aggregator',
161 'page callback' => 'aggregator_page_last',
162 'access arguments' => array('access news feeds'),
163 'weight' => 5,
164 'file' => 'aggregator.pages.inc',
165 );
166 $items['aggregator/sources'] = array(
167 'title' => 'Sources',
168 'page callback' => 'aggregator_page_sources',
169 'access arguments' => array('access news feeds'),
170 'file' => 'aggregator.pages.inc',
171 );
172 $items['aggregator/categories'] = array(
173 'title' => 'Categories',
174 'page callback' => 'aggregator_page_categories',
175 'access callback' => '_aggregator_has_categories',
176 'file' => 'aggregator.pages.inc',
177 );
178 $items['aggregator/rss'] = array(
179 'title' => 'RSS feed',
180 'page callback' => 'aggregator_page_rss',
181 'access arguments' => array('access news feeds'),
182 'type' => MENU_CALLBACK,
183 'file' => 'aggregator.pages.inc',
184 );
185 $items['aggregator/opml'] = array(
186 'title' => 'OPML feed',
187 'page callback' => 'aggregator_page_opml',
188 'access arguments' => array('access news feeds'),
189 'type' => MENU_CALLBACK,
190 'file' => 'aggregator.pages.inc',
191 );
192 $items['aggregator/categories/%aggregator_category'] = array(
193 'title callback' => '_aggregator_category_title',
194 'title arguments' => array(2),
195 'page callback' => 'aggregator_page_category',
196 'page arguments' => array(2),
197 'access arguments' => array('access news feeds'),
198 'file' => 'aggregator.pages.inc',
199 );
200 $items['aggregator/categories/%aggregator_category/view'] = array(
201 'title' => 'View',
202 'type' => MENU_DEFAULT_LOCAL_TASK,
203 'weight' => -10,
204 );
205 $items['aggregator/categories/%aggregator_category/categorize'] = array(
206 'title' => 'Categorize',
207 'page callback' => 'drupal_get_form',
208 'page arguments' => array('aggregator_page_category_form', 2),
209 'access arguments' => array('administer news feeds'),
210 'type' => MENU_LOCAL_TASK,
211 'file' => 'aggregator.pages.inc',
212 );
213 $items['aggregator/categories/%aggregator_category/configure'] = array(
214 'title' => 'Configure',
215 'page callback' => 'drupal_get_form',
216 'page arguments' => array('aggregator_form_category', 2),
217 'access arguments' => array('administer news feeds'),
218 'type' => MENU_LOCAL_TASK,
219 'weight' => 1,
220 'file' => 'aggregator.admin.inc',
221 );
222 $items['aggregator/sources/%aggregator_feed'] = array(
223 'page callback' => 'aggregator_page_source',
224 'page arguments' => array(2),
225 'access arguments' => array('access news feeds'),
226 'file' => 'aggregator.pages.inc',
227 );
228 $items['aggregator/sources/%aggregator_feed/view'] = array(
229 'title' => 'View',
230 'type' => MENU_DEFAULT_LOCAL_TASK,
231 'weight' => -10,
232 );
233 $items['aggregator/sources/%aggregator_feed/categorize'] = array(
234 'title' => 'Categorize',
235 'page callback' => 'drupal_get_form',
236 'page arguments' => array('aggregator_page_source_form', 2),
237 'access arguments' => array('administer news feeds'),
238 'type' => MENU_LOCAL_TASK,
239 'file' => 'aggregator.pages.inc',
240 );
241 $items['aggregator/sources/%aggregator_feed/configure'] = array(
242 'title' => 'Configure',
243 'page callback' => 'drupal_get_form',
244 'page arguments' => array('aggregator_form_feed', 2),
245 'access arguments' => array('administer news feeds'),
246 'type' => MENU_LOCAL_TASK,
247 'weight' => 1,
248 'file' => 'aggregator.admin.inc',
249 );
250 $items['admin/config/services/aggregator/edit/feed/%aggregator_feed'] = array(
251 'title' => 'Edit feed',
252 'page callback' => 'drupal_get_form',
253 'page arguments' => array('aggregator_form_feed', 6),
254 'access arguments' => array('administer news feeds'),
255 'file' => 'aggregator.admin.inc',
256 );
257 $items['admin/config/services/aggregator/edit/category/%aggregator_category'] = array(
258 'title' => 'Edit category',
259 'page callback' => 'drupal_get_form',
260 'page arguments' => array('aggregator_form_category', 6),
261 'access arguments' => array('administer news feeds'),
262 'file' => 'aggregator.admin.inc',
263 );
264
265 return $items;
266 }
267
277 function _aggregator_category_title($category) {
278 return $category['title'];
279 }
280
288 function _aggregator_has_categories() {
289 return user_access('access news feeds') && (bool) db_query_range('SELECT 1 FROM {aggregator_category}', 0, 1)->fetchField();
290 }
291
295 function aggregator_permission() {
296 return array(
297 'administer news feeds' => array(
298 'title' => t('Administer news feeds'),
299 ),
300 'access news feeds' => array(
301 'title' => t('View news feeds'),
302 ),
303 );
304 }
305
311 function aggregator_cron() {
312 $result = db_query('SELECT * FROM {aggregator_feed} WHERE queued = 0 AND checked + refresh < :time AND refresh <> :never', array(
313 ':time' => REQUEST_TIME,
314 ':never' => AGGREGATOR_CLEAR_NEVER
315 ));
316 $queue = DrupalQueue::get('aggregator_feeds');
317 foreach ($result as $feed) {
318 if ($queue->createItem($feed)) {
319 // Add timestamp to avoid queueing item more than once.
320 db_update('aggregator_feed')
321 ->fields(array('queued' => REQUEST_TIME))
322 ->condition('fid', $feed->fid)
323 ->execute();
324 }
325 }
326
327 // Remove queued timestamp after 6 hours assuming the update has failed.
328 db_update('aggregator_feed')
329 ->fields(array('queued' => 0))
330 ->condition('queued', REQUEST_TIME - (3600 * 6), '<')
331 ->execute();
332 }
333
337 function aggregator_cron_queue_info() {
338 $queues['aggregator_feeds'] = array(
339 'worker callback' => 'aggregator_refresh',
340 'time' => 60,
341 );
342 return $queues;
343 }
344
348 function aggregator_block_info() {
349 $blocks = array();
350 $result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title');
351 foreach ($result as $category) {
352 $blocks['category-' . $category->cid]['info'] = t('!title category latest items', array('!title' => $category->title));
353 }
354 $result = db_query('SELECT fid, title FROM {aggregator_feed} WHERE block <> 0 ORDER BY fid');
355 foreach ($result as $feed) {
356 $blocks['feed-' . $feed->fid]['info'] = t('!title feed latest items', array('!title' => $feed->title));
357 }
358 return $blocks;
359 }
360
364 function aggregator_block_configure($delta = '') {
365 list($type, $id) = explode('-', $delta);
366 if ($type == 'category') {
367 $value = db_query('SELECT block FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $id))->fetchField();
368 $form['block'] = array(
369 '#type' => 'select',
370 '#title' => t('Number of news items in block'),
371 '#default_value' => $value,
372 '#options' => drupal_map_assoc(range(2, 20)),
373 );
374 return $form;
375 }
376 }
377
381 function aggregator_block_save($delta = '', $edit = array()) {
382 list($type, $id) = explode('-', $delta);
383 if ($type == 'category') {
384 db_update('aggregator_category')
385 ->fields(array('block' => $edit['block']))
386 ->condition('cid', $id)
387 ->execute();
388 }
389 }
390
396 function aggregator_block_view($delta = '') {
397 if (user_access('access news feeds')) {
398 $block = array();
399 list($type, $id) = explode('-', $delta);
400 $result = FALSE;
401 switch ($type) {
402 case 'feed':
403 if ($feed = db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = :fid', array(':fid' => $id))->fetchObject()) {
404 $block['subject'] = check_plain($feed->title);
405 $result = db_query_range("SELECT * FROM {aggregator_item} WHERE fid = :fid ORDER BY timestamp DESC, iid DESC", 0, $feed->block, array(':fid' => $id));
406 $read_more = theme('more_link', array('url' => 'aggregator/sources/' . $feed->fid, 'title' => t("View this feed's recent news.")));
407 }
408 break;
409
410 case 'category':
411 if ($category = db_query('SELECT cid, title, block FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $id))->fetchObject()) {
412 $block['subject'] = check_plain($category->title);
413 $result = db_query_range('SELECT i.* FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON ci.iid = i.iid WHERE ci.cid = :cid ORDER BY i.timestamp DESC, i.iid DESC', 0, $category->block, array(':cid' => $category->cid));
414 $read_more = theme('more_link', array('url' => 'aggregator/categories/' . $category->cid, 'title' => t("View this category's recent news.")));
415 }
416 break;
417 }
418
419 $items = array();
420 if (!empty($result)) {
421 foreach ($result as $item) {
422 $items[] = theme('aggregator_block_item', array('item' => $item));
423 }
424 }
425
426 // Only display the block if there are items to show.
427 if (count($items) > 0) {
428 $block['content'] = theme('item_list', array('items' => $items)) . $read_more;
429 }
430 return $block;
431 }
432 }
433
440 function aggregator_save_category($edit) {
441 $link_path = 'aggregator/categories/';
442 if (!empty($edit['cid'])) {
443 $link_path .= $edit['cid'];
444 if (!empty($edit['title'])) {
445 db_merge('aggregator_category')
446 ->key(array('cid' => $edit['cid']))
447 ->fields(array(
448 'title' => $edit['title'],
449 'description' => $edit['description'],
450 ))
451 ->execute();
452 $op = 'update';
453 }
454 else {
455 db_delete('aggregator_category')
456 ->condition('cid', $edit['cid'])
457 ->execute();
458 // Make sure there is no active block for this category.
459 if (module_exists('block')) {
460 db_delete('block')
461 ->condition('module', 'aggregator')
462 ->condition('delta', 'category-' . $edit['cid'])
463 ->execute();
464 }
465 $edit['title'] = '';
466 $op = 'delete';
467 }
468 }
469 elseif (!empty($edit['title'])) {
470 // A single unique id for bundles and feeds, to use in blocks.
471 $link_path .= db_insert('aggregator_category')
472 ->fields(array(
473 'title' => $edit['title'],
474 'description' => $edit['description'],
475 'block' => 5,
476 ))
477 ->execute();
478 $op = 'insert';
479 }
480 if (isset($op)) {
481 menu_link_maintain('aggregator', $op, $link_path, $edit['title']);
482 }
483 }
484
491 function aggregator_save_feed($edit) {
492 if (!empty($edit['fid'])) {
493 // An existing feed is being modified, delete the category listings.
494 db_delete('aggregator_category_feed')
495 ->condition('fid', $edit['fid'])
496 ->execute();
497 }
498 if (!empty($edit['fid']) && !empty($edit['title'])) {
499 db_update('aggregator_feed')
500 ->condition('fid', $edit['fid'])
501 ->fields(array(
502 'title' => $edit['title'],
503 'url' => $edit['url'],
504 'refresh' => $edit['refresh'],
505 'block' => $edit['block'],
506 ))
507 ->execute();
508 }
509 elseif (!empty($edit['fid'])) {
510 $iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $edit['fid']))->fetchCol();
511 if ($iids) {
512 db_delete('aggregator_category_item')
513 ->condition('iid', $iids, 'IN')
514 ->execute();
515 }
516 db_delete('aggregator_feed')->
517 condition('fid', $edit['fid'])
518 ->execute();
519 db_delete('aggregator_item')
520 ->condition('fid', $edit['fid'])
521 ->execute();
522 // Make sure there is no active block for this feed.
523 if (module_exists('block')) {
524 db_delete('block')
525 ->condition('module', 'aggregator')
526 ->condition('delta', 'feed-' . $edit['fid'])
527 ->execute();
528 }
529 }
530 elseif (!empty($edit['title'])) {
531 $edit['fid'] = db_insert('aggregator_feed')
532 ->fields(array(
533 'title' => $edit['title'],
534 'url' => $edit['url'],
535 'refresh' => $edit['refresh'],
536 'block' => $edit['block'],
537 'link' => '',
538 'description' => '',
539 'image' => '',
540 ))
541 ->execute();
542
543 }
544 if (!empty($edit['title'])) {
545 // The feed is being saved, save the categories as well.
546 if (!empty($edit['category'])) {
547 foreach ($edit['category'] as $cid => $value) {
548 if ($value) {
549 db_insert('aggregator_category_feed')
550 ->fields(array(
551 'fid' => $edit['fid'],
552 'cid' => $cid,
553 ))
554 ->execute();
555 }
556 }
557 }
558 }
559 }
560
567 function aggregator_remove($feed) {
568 _aggregator_get_variables();
569 // Call hook_aggregator_remove() on all modules.
570 module_invoke_all('aggregator_remove', $feed);
571 // Reset feed.
572 db_update('aggregator_feed')
573 ->condition('fid', $feed->fid)
574 ->fields(array(
575 'checked' => 0,
576 'hash' => '',
577 'etag' => '',
578 'modified' => 0,
579 ))
580 ->execute();
581 }
582
589 function _aggregator_get_variables() {
590 // Fetch the feed.
591 $fetcher = variable_get('aggregator_fetcher', 'aggregator');
592 if ($fetcher == 'aggregator') {
593 include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator.fetcher.inc';
594 }
595 $parser = variable_get('aggregator_parser', 'aggregator');
596 if ($parser == 'aggregator') {
597 include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator.parser.inc';
598 }
599 $processors = variable_get('aggregator_processors', array('aggregator'));
600 if (in_array('aggregator', $processors)) {
601 include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator.processor.inc';
602 }
603 return array($fetcher, $parser, $processors);
604 }
605
612 function aggregator_refresh($feed) {
613 // Store feed URL to track changes.
614 $feed_url = $feed->url;
615
616 // Fetch the feed.
617 list($fetcher, $parser, $processors) = _aggregator_get_variables();
618 $success = module_invoke($fetcher, 'aggregator_fetch', $feed);
619
620 // We store the hash of feed data in the database. When refreshing a
621 // feed we compare stored hash and new hash calculated from downloaded
622 // data. If both are equal we say that feed is not updated.
623 $hash = hash('sha256', $feed->source_string);
624
625 if ($success && ($feed->hash != $hash)) {
626 // Parse the feed.
627 if (module_invoke($parser, 'aggregator_parse', $feed)) {
628 // Update feed with parsed data.
629 db_merge('aggregator_feed')
630 ->key(array('fid' => $feed->fid))
631 ->fields(array(
632 'url' => $feed->url,
633 'link' => empty($feed->link) ? $feed->url : $feed->link,
634 'description' => empty($feed->description) ? '' : $feed->description,
635 'image' => empty($feed->image) ? '' : $feed->image,
636 'hash' => $hash,
637 'etag' => empty($feed->etag) ? '' : $feed->etag,
638 'modified' => empty($feed->modified) ? 0 : $feed->modified,
639 ))
640 ->execute();
641
642 // Log if feed URL has changed.
643 if ($feed->url != $feed_url) {
644 watchdog('aggregator', 'Updated URL for feed %title to %url.', array('%title' => $feed->title, '%url' => $feed->url));
645 }
646
647 watchdog('aggregator', 'There is new syndicated content from %site.', array('%site' => $feed->title));
648 drupal_set_message(t('There is new syndicated content from %site.', array('%site' => $feed->title)));
649
650 // If there are items on the feed, let all enabled processors do their work on it.
651 if (@count($feed->items)) {
652 foreach ($processors as $processor) {
653 module_invoke($processor, 'aggregator_process', $feed);
654 }
655 }
656 }
657 }
658 else {
659 drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed->title)));
660 }
661
662 // Regardless of successful or not, indicate that this feed has been checked.
663 db_update('aggregator_feed')
664 ->fields(array('checked' => REQUEST_TIME, 'queued' => 0))
665 ->condition('fid', $feed->fid)
666 ->execute();
667
668 // Expire old feed items.
669 if (function_exists('aggregator_expire')) {
670 aggregator_expire($feed);
671 }
672 }
673
683 function aggregator_feed_load($fid) {
684 $feeds = &drupal_static(__FUNCTION__);
685 if (!isset($feeds[$fid])) {
686 $feeds[$fid] = db_query('SELECT * FROM {aggregator_feed} WHERE fid = :fid', array(':fid' => $fid))->fetchObject();
687 }
688
689 return $feeds[$fid];
690 }
691
701 function aggregator_category_load($cid) {
702 $categories = &drupal_static(__FUNCTION__);
703 if (!isset($categories[$cid])) {
704 $categories[$cid] = db_query('SELECT * FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $cid))->fetchAssoc();
705 }
706
707 return $categories[$cid];
708 }
709
720 function theme_aggregator_block_item($variables) {
721 // Display the external link to the item.
722 return '<a href="' . check_url($variables['item']->link) . '">' . check_plain($variables['item']->title) . "</a>\n";
723 }
724
734 function aggregator_filter_xss($value) {
735 return filter_xss($value, preg_split('/\s+|<|>/', variable_get('aggregator_allowed_html_tags', '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'), -1, PREG_SPLIT_NO_EMPTY));
736 }
737
747 function aggregator_sanitize_configuration() {
748 $reset = FALSE;
749 list($fetcher, $parser, $processors) = _aggregator_get_variables();
750 if (!module_exists($fetcher)) {
751 $reset = TRUE;
752 }
753 if (!module_exists($parser)) {
754 $reset = TRUE;
755 }
756 foreach ($processors as $processor) {
757 if (!module_exists($processor)) {
758 $reset = TRUE;
759 break;
760 }
761 }
762 if ($reset) {
763 variable_del('aggregator_fetcher');
764 variable_del('aggregator_parser');
765 variable_del('aggregator_processors');
766 return TRUE;
767 }
768 return FALSE;
769 }
770
780 function _aggregator_items($count) {
781 return format_plural($count, '1 item', '@count items');
782 }
menu_link_maintain
menu_link_maintain($module, $op, $link_path, $link_title)
Definition: menu.inc:3395
$op
$op
Definition: update.php:404
_aggregator_get_variables
_aggregator_get_variables()
Definition: aggregator.module:589
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
DrupalQueue\get
static get($name, $reliable=FALSE)
Definition: system.queue.inc:81
aggregator_category_load
aggregator_category_load($cid)
Definition: aggregator.module:701
theme_aggregator_block_item
theme_aggregator_block_item($variables)
Definition: aggregator.module:720
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
check_url
check_url($uri)
Definition: common.inc:1387
aggregator_expire
aggregator_expire($feed)
Definition: aggregator.processor.inc:193
aggregator_block_info
aggregator_block_info()
Definition: aggregator.module:348
_aggregator_items
_aggregator_items($count)
Definition: aggregator.module:780
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
_aggregator_has_categories
_aggregator_has_categories()
Definition: aggregator.module:288
aggregator_block_configure
aggregator_block_configure($delta= '')
Definition: aggregator.module:364
aggregator_permission
aggregator_permission()
Definition: aggregator.module:295
aggregator_save_feed
aggregator_save_feed($edit)
Definition: aggregator.module:491
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
module_exists
module_exists($module)
Definition: module.inc:274
aggregator_cron_queue_info
aggregator_cron_queue_info()
Definition: aggregator.module:337
aggregator_block_save
aggregator_block_save($delta= '', $edit=array())
Definition: aggregator.module:381
aggregator_sanitize_configuration
aggregator_sanitize_configuration()
Definition: aggregator.module:747
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
aggregator_cron
aggregator_cron()
Definition: aggregator.module:311
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
aggregator_theme
aggregator_theme()
Definition: aggregator.module:50
$value
print $value
Definition: user-profile-item.tpl.php:26
_aggregator_category_title
_aggregator_category_title($category)
Definition: aggregator.module:277
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
aggregator_block_view
aggregator_block_view($delta= '')
Definition: aggregator.module:396
link
print $forum link
Definition: forum-list.tpl.php:57
aggregator_feed_load
aggregator_feed_load($fid)
Definition: aggregator.module:683
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
aggregator_filter_xss
aggregator_filter_xss($value)
Definition: aggregator.module:734
aggregator_help
aggregator_help($path, $arg)
Definition: aggregator.module:16
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
aggregator_refresh
aggregator_refresh($feed)
Definition: aggregator.module:612
aggregator_remove
aggregator_remove($feed)
Definition: aggregator.module:567
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
title
print $topic title
Definition: forum-topic-list.tpl.php:50
aggregator_save_category
aggregator_save_category($edit)
Definition: aggregator.module:440
$feed_url
print $feed_url
Definition: aggregator-item.tpl.php:25
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
aggregator_menu
aggregator_menu()
Definition: aggregator.module:98
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
AGGREGATOR_CLEAR_NEVER
const AGGREGATOR_CLEAR_NEVER
Definition: aggregator.module:11
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/options/options.api.php Source File

  • modules
  • field
  • modules
  • options
options.api.php
Go to the documentation of this file.
1 <?php
2
38 function hook_options_list($field, $instance, $entity_type, $entity) {
39 // Sample structure.
40 $options = array(
41 0 => t('Zero'),
42 1 => t('One'),
43 2 => t('Two'),
44 3 => t('Three'),
45 );
46
47 // Sample structure with groups. Only one level of nesting is allowed. This
48 // is only supported by the 'options_select' widget. Other widgets will
49 // flatten the array.
50 $options = array(
51 t('First group') => array(
52 0 => t('Zero'),
53 ),
54 t('Second group') => array(
55 1 => t('One'),
56 2 => t('Two'),
57 ),
58 3 => t('Three'),
59 );
60
61 // In actual implementations, the array of options will most probably depend
62 // on properties of the field. Example from taxonomy.module:
63 $options = array();
64 foreach ($field['settings']['allowed_values'] as $tree) {
65 $terms = taxonomy_get_tree($tree['vid'], $tree['parent']);
66 if ($terms) {
67 foreach ($terms as $term) {
68 $options[$term->tid] = str_repeat('-', $term->depth) . $term->name;
69 }
70 }
71 }
72
73 return $options;
74 }
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
hook_options_list
hook_options_list($field, $instance, $entity_type, $entity)
Definition: options.api.php:38
taxonomy_get_tree
taxonomy_get_tree($vid, $parent=0, $max_depth=NULL, $load_entities=FALSE)
Definition: taxonomy.module:1105
$tree
if($tree||$has_links) print $tree
Definition: book-navigation.tpl.php:35
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/content_types.inc Source File

  • modules
  • node
content_types.inc
Go to the documentation of this file.
1 <?php
2
11 function node_overview_types() {
12 $types = node_type_get_types();
13 $names = node_type_get_names();
14 $field_ui = module_exists('field_ui');
15 $header = array(t('Name'), array('data' => t('Operations'), 'colspan' => $field_ui ? '4' : '2'));
16 $rows = array();
17
18 foreach ($names as $key => $name) {
19 $type = $types[$key];
20 if (node_hook($type->type, 'form')) {
21 $type_url_str = str_replace('_', '-', $type->type);
22 $row = array(theme('node_admin_overview', array('name' => $name, 'type' => $type)));
23 // Set the edit column.
24 $row[] = array('data' => l(t('edit'), 'admin/structure/types/manage/' . $type_url_str));
25
26 if ($field_ui) {
27 // Manage fields.
28 $row[] = array('data' => l(t('manage fields'), 'admin/structure/types/manage/' . $type_url_str . '/fields'));
29
30 // Display fields.
31 $row[] = array('data' => l(t('manage display'), 'admin/structure/types/manage/' . $type_url_str . '/display'));
32 }
33
34 // Set the delete column.
35 if ($type->custom) {
36 $row[] = array('data' => l(t('delete'), 'admin/structure/types/manage/' . $type_url_str . '/delete'));
37 }
38 else {
39 $row[] = array('data' => '');
40 }
41
42 $rows[] = $row;
43 }
44 }
45
46 $build['node_table'] = array(
47 '#theme' => 'table',
48 '#header' => $header,
49 '#rows' => $rows,
50 '#empty' => t('No content types available. <a href="@link">Add content type</a>.', array('@link' => url('admin/structure/types/add'))),
51 );
52
53 return $build;
54 }
55
67 function theme_node_admin_overview($variables) {
68 $name = $variables['name'];
69 $type = $variables['type'];
70
71 $output = check_plain($name);
72 $output .= ' <small>' . t('(Machine name: @type)', array('@type' => $type->type)) . '</small>';
73 $output .= '<div class="description">' . filter_xss_admin($type->description) . '</div>';
74 return $output;
75 }
76
88 function node_type_form($form, &$form_state, $type = NULL) {
89 if (!isset($type->type)) {
90 // This is a new type. Node module managed types are custom and unlocked.
91 $type = node_type_set_defaults(array('custom' => 1, 'locked' => 0));
92 }
93
94 // Make the type object available to implementations of hook_form_alter.
95 $form['#node_type'] = $type;
96
97 $form['name'] = array(
98 '#title' => t('Name'),
99 '#type' => 'textfield',
100 '#default_value' => $type->name,
101 '#description' => t('The human-readable name of this content type. This text will be displayed as part of the list on the <em>Add new content</em> page. It is recommended that this name begin with a capital letter and contain only letters, numbers, and spaces. This name must be unique.'),
102 '#required' => TRUE,
103 '#size' => 30,
104 );
105
106 $form['type'] = array(
107 '#type' => 'machine_name',
108 '#default_value' => $type->type,
109 '#maxlength' => 32,
110 '#disabled' => $type->locked,
111 '#machine_name' => array(
112 'exists' => 'node_type_load',
113 ),
114 '#description' => t('A unique machine-readable name for this content type. It must only contain lowercase letters, numbers, and underscores. This name will be used for constructing the URL of the %node-add page, in which underscores will be converted into hyphens.', array(
115 '%node-add' => t('Add new content'),
116 )),
117 );
118
119 $form['description'] = array(
120 '#title' => t('Description'),
121 '#type' => 'textarea',
122 '#default_value' => $type->description,
123 '#description' => t('Describe this content type. The text will be displayed on the <em>Add new content</em> page.'),
124 );
125
126 $form['additional_settings'] = array(
127 '#type' => 'vertical_tabs',
128 '#attached' => array(
129 'js' => array(drupal_get_path('module', 'node') . '/content_types.js'),
130 ),
131 );
132
133 $form['submission'] = array(
134 '#type' => 'fieldset',
135 '#title' => t('Submission form settings'),
136 '#collapsible' => TRUE,
137 '#group' => 'additional_settings',
138 );
139 $form['submission']['title_label'] = array(
140 '#title' => t('Title field label'),
141 '#type' => 'textfield',
142 '#default_value' => $type->title_label,
143 '#required' => TRUE,
144 );
145 if (!$type->has_title) {
146 // Avoid overwriting a content type that intentionally does not have a
147 // title field.
148 $form['submission']['title_label']['#attributes'] = array('disabled' => 'disabled');
149 $form['submission']['title_label']['#description'] = t('This content type does not have a title field.');
150 $form['submission']['title_label']['#required'] = FALSE;
151 }
152 $form['submission']['node_preview'] = array(
153 '#type' => 'radios',
154 '#title' => t('Preview before submitting'),
155 '#default_value' => variable_get('node_preview_' . $type->type, DRUPAL_OPTIONAL),
156 '#options' => array(
157 DRUPAL_DISABLED => t('Disabled'),
158 DRUPAL_OPTIONAL => t('Optional'),
159 DRUPAL_REQUIRED => t('Required'),
160 ),
161 );
162 $form['submission']['help'] = array(
163 '#type' => 'textarea',
164 '#title' => t('Explanation or submission guidelines'),
165 '#default_value' => $type->help,
166 '#description' => t('This text will be displayed at the top of the page when creating or editing content of this type.'),
167 );
168 $form['workflow'] = array(
169 '#type' => 'fieldset',
170 '#title' => t('Publishing options'),
171 '#collapsible' => TRUE,
172 '#collapsed' => TRUE,
173 '#group' => 'additional_settings',
174 );
175 $form['workflow']['node_options'] = array('#type' => 'checkboxes',
176 '#title' => t('Default options'),
177 '#default_value' => variable_get('node_options_' . $type->type, array('status', 'promote')),
178 '#options' => array(
179 'status' => t('Published'),
180 'promote' => t('Promoted to front page'),
181 'sticky' => t('Sticky at top of lists'),
182 'revision' => t('Create new revision'),
183 ),
184 '#description' => t('Users with the <em>Administer content</em> permission will be able to override these options.'),
185 );
186 $form['display'] = array(
187 '#type' => 'fieldset',
188 '#title' => t('Display settings'),
189 '#collapsible' => TRUE,
190 '#collapsed' => TRUE,
191 '#group' => 'additional_settings',
192 );
193 $form['display']['node_submitted'] = array(
194 '#type' => 'checkbox',
195 '#title' => t('Display author and date information.'),
196 '#default_value' => variable_get('node_submitted_' . $type->type, TRUE),
197 '#description' => t('Author username and publish date will be displayed.'),
198 );
199 $form['old_type'] = array(
200 '#type' => 'value',
201 '#value' => $type->type,
202 );
203 $form['orig_type'] = array(
204 '#type' => 'value',
205 '#value' => isset($type->orig_type) ? $type->orig_type : '',
206 );
207 $form['base'] = array(
208 '#type' => 'value',
209 '#value' => $type->base,
210 );
211 $form['custom'] = array(
212 '#type' => 'value',
213 '#value' => $type->custom,
214 );
215 $form['modified'] = array(
216 '#type' => 'value',
217 '#value' => $type->modified,
218 );
219 $form['locked'] = array(
220 '#type' => 'value',
221 '#value' => $type->locked,
222 );
223
224 $form['actions'] = array('#type' => 'actions');
225 $form['actions']['submit'] = array(
226 '#type' => 'submit',
227 '#value' => t('Save content type'),
228 '#weight' => 40,
229 );
230
231 if ($type->custom) {
232 if (!empty($type->type)) {
233 $form['actions']['delete'] = array(
234 '#type' => 'submit',
235 '#value' => t('Delete content type'),
236 '#weight' => 45,
237 );
238 }
239 }
240
241 return $form;
242 }
243
247 function _node_characters($length) {
248 return ($length == 0) ? t('Unlimited') : format_plural($length, '1 character', '@count characters');
249 }
250
256 function node_type_form_validate($form, &$form_state) {
257 $type = new stdClass();
258 $type->type = $form_state['values']['type'];
259 $type->name = trim($form_state['values']['name']);
260
261 // Work out what the type was before the user submitted this form
262 $old_type = $form_state['values']['old_type'];
263
264 $types = node_type_get_names();
265
266 if (!$form_state['values']['locked']) {
267 // 'theme' conflicts with theme_node_form().
268 // '0' is invalid, since elsewhere we check it using empty().
269 if (in_array($type->type, array('0', 'theme'))) {
270 form_set_error('type', t("Invalid machine-readable name. Enter a name other than %invalid.", array('%invalid' => $type->type)));
271 }
272 }
273
274 $names = array_flip($types);
275
276 if (isset($names[$type->name]) && $names[$type->name] != $old_type) {
277 form_set_error('name', t('The human-readable name %name is already taken.', array('%name' => $type->name)));
278 }
279 }
280
286 function node_type_form_submit($form, &$form_state) {
287 $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
288
289 $type = node_type_set_defaults();
290
291 $type->type = $form_state['values']['type'];
292 $type->name = trim($form_state['values']['name']);
293 $type->orig_type = trim($form_state['values']['orig_type']);
294 $type->old_type = isset($form_state['values']['old_type']) ? $form_state['values']['old_type'] : $type->type;
295
296 $type->description = $form_state['values']['description'];
297 $type->help = $form_state['values']['help'];
298 $type->title_label = $form_state['values']['title_label'];
299 // title_label is required in core; has_title will always be true, unless a
300 // module alters the title field.
301 $type->has_title = ($type->title_label != '');
302
303 $type->base = !empty($form_state['values']['base']) ? $form_state['values']['base'] : 'node_content';
304 $type->custom = $form_state['values']['custom'];
305 $type->modified = TRUE;
306 $type->locked = $form_state['values']['locked'];
307 if (isset($form['#node_type']->module)) {
308 $type->module = $form['#node_type']->module;
309 }
310
311 if ($op == t('Delete content type')) {
312 $form_state['redirect'] = 'admin/structure/types/manage/' . str_replace('_', '-', $type->old_type) . '/delete';
313 return;
314 }
315
316 $variables = $form_state['values'];
317
318 // Remove everything that's been saved already - whatever's left is assumed
319 // to be a persistent variable.
320 foreach ($variables as $key => $value) {
321 if (isset($type->$key)) {
322 unset($variables[$key]);
323 }
324 }
325
326 unset($variables['form_token'], $variables['op'], $variables['submit'], $variables['delete'], $variables['reset'], $variables['form_id'], $variables['form_build_id']);
327
328 // Save or reset persistent variable values.
329 foreach ($variables as $key => $value) {
330 $variable_new = $key . '_' . $type->type;
331 $variable_old = $key . '_' . $type->old_type;
332
333 if (is_array($value)) {
334 $value = array_keys(array_filter($value));
335 }
336 variable_set($variable_new, $value);
337
338 if ($variable_new != $variable_old) {
339 variable_del($variable_old);
340 }
341 }
342
343 // Saving the content type after saving the variables allows modules to act
344 // on those variables via hook_node_type_insert().
345 $status = node_type_save($type);
346
347 node_types_rebuild();
348 menu_rebuild();
349 $t_args = array('%name' => $type->name);
350
351 if ($status == SAVED_UPDATED) {
352 drupal_set_message(t('The content type %name has been updated.', $t_args));
353 }
354 elseif ($status == SAVED_NEW) {
355 node_add_body_field($type);
356 drupal_set_message(t('The content type %name has been added.', $t_args));
357 watchdog('node', 'Added content type %name.', $t_args, WATCHDOG_NOTICE, l(t('view'), 'admin/structure/types'));
358 }
359
360 $form_state['redirect'] = 'admin/structure/types';
361 return;
362 }
363
367 function node_node_type_insert($info) {
368 if (!empty($info->old_type) && $info->old_type != $info->type) {
369 $update_count = node_type_update_nodes($info->old_type, $info->type);
370
371 if ($update_count) {
372 drupal_set_message(format_plural($update_count, 'Changed the content type of 1 post from %old-type to %type.', 'Changed the content type of @count posts from %old-type to %type.', array('%old-type' => $info->old_type, '%type' => $info->type)));
373 }
374 }
375 }
376
380 function node_node_type_update($info) {
381 if (!empty($info->old_type) && $info->old_type != $info->type) {
382 $update_count = node_type_update_nodes($info->old_type, $info->type);
383
384 if ($update_count) {
385 drupal_set_message(format_plural($update_count, 'Changed the content type of 1 post from %old-type to %type.', 'Changed the content type of @count posts from %old-type to %type.', array('%old-type' => $info->old_type, '%type' => $info->type)));
386 }
387 }
388 }
389
398 function node_type_reset($type) {
399 $info_array = module_invoke_all('node_info');
400 if (isset($info_array[$type->orig_type])) {
401 $info_array[$type->orig_type]['type'] = $type->orig_type;
402 $info = node_type_set_defaults($info_array[$type->orig_type]);
403
404 foreach ($info as $field => $value) {
405 $type->$field = $value;
406 }
407 }
408 }
409
415 function node_type_delete_confirm($form, &$form_state, $type) {
416 $form['type'] = array('#type' => 'value', '#value' => $type->type);
417 $form['name'] = array('#type' => 'value', '#value' => $type->name);
418
419 $message = t('Are you sure you want to delete the content type %type?', array('%type' => $type->name));
420 $caption = '';
421
422 $num_nodes = db_query("SELECT COUNT(*) FROM {node} WHERE type = :type", array(':type' => $type->type))->fetchField();
423 if ($num_nodes) {
424 $caption .= '<p>' . format_plural($num_nodes, '%type is used by 1 piece of content on your site. If you remove this content type, you will not be able to edit the %type content and it may not display correctly.', '%type is used by @count pieces of content on your site. If you remove %type, you will not be able to edit the %type content and it may not display correctly.', array('%type' => $type->name)) . '</p>';
425 }
426
427 $caption .= '<p>' . t('This action cannot be undone.') . '</p>';
428
429 return confirm_form($form, $message, 'admin/structure/types', $caption, t('Delete'));
430 }
431
437 function node_type_delete_confirm_submit($form, &$form_state) {
438 node_type_delete($form_state['values']['type']);
439
440 variable_del('node_preview_' . $form_state['values']['type']);
441 $t_args = array('%name' => $form_state['values']['name']);
442 drupal_set_message(t('The content type %name has been deleted.', $t_args));
443 watchdog('node', 'Deleted content type %name.', $t_args, WATCHDOG_NOTICE);
444
445 node_types_rebuild();
446 menu_rebuild();
447
448 $form_state['redirect'] = 'admin/structure/types';
449 return;
450 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
node_type_save
node_type_save($info)
Definition: node.module:525
node_type_reset
node_type_reset($type)
Definition: content_types.inc:398
node_type_delete_confirm_submit
node_type_delete_confirm_submit($form, &$form_state)
Definition: content_types.inc:437
$op
$op
Definition: update.php:404
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
node_type_delete
node_type_delete($type)
Definition: node.module:651
SAVED_UPDATED
const SAVED_UPDATED
Definition: common.inc:50
node_type_delete_confirm
node_type_delete_confirm($form, &$form_state, $type)
Definition: content_types.inc:415
node_node_type_insert
node_node_type_insert($info)
Definition: content_types.inc:367
variable_del
variable_del($name)
Definition: bootstrap.inc:996
$name
print $name
Definition: profile-listing.tpl.php:43
node_type_form_validate
node_type_form_validate($form, &$form_state)
Definition: content_types.inc:256
_node_characters
_node_characters($length)
Definition: content_types.inc:247
DRUPAL_OPTIONAL
const DRUPAL_OPTIONAL
Definition: system.module:41
$header
print $header
Definition: forum-topic-list.tpl.php:42
module_exists
module_exists($module)
Definition: module.inc:274
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
node_type_get_types
node_type_get_types()
Definition: node.module:393
node_type_set_defaults
node_type_set_defaults($info=array())
Definition: node.module:805
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
node_overview_types
node_overview_types()
Definition: content_types.inc:11
menu_rebuild
menu_rebuild()
Definition: menu.inc:2709
$info
$info
Definition: color.inc:6
node_add_body_field
node_add_body_field($type, $label= 'Body')
Definition: node.module:586
node_types_rebuild
node_types_rebuild()
Definition: node.module:475
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$output
$output
Definition: authorize.php:93
node_node_type_update
node_node_type_update($info)
Definition: content_types.inc:380
DRUPAL_REQUIRED
const DRUPAL_REQUIRED
Definition: system.module:46
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
node_type_form_submit
node_type_form_submit($form, &$form_state)
Definition: content_types.inc:286
node_hook
node_hook($node, $hook)
Definition: node.module:893
SAVED_NEW
const SAVED_NEW
Definition: common.inc:45
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
node_type_update_nodes
node_type_update_nodes($old_type, $type)
Definition: node.module:674
node_type_get_names
node_type_get_names()
Definition: node.module:446
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$row
$row
Definition: block-admin-display-form.tpl.php:47
theme_node_admin_overview
theme_node_admin_overview($variables)
Definition: content_types.inc:67
DRUPAL_DISABLED
const DRUPAL_DISABLED
Definition: system.module:36
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
node_type_form
node_type_form($form, &$form_state, $type=NULL)
Definition: content_types.inc:88
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/graph.inc Source File

  • includes
graph.inc
Go to the documentation of this file.
1 <?php
2
47 function drupal_depth_first_search(&$graph) {
48 $state = array(
49 // The order of last visit of the depth first search. This is the reverse
50 // of the topological order if the graph is acyclic.
51 'last_visit_order' => array(),
52 // The components of the graph.
53 'components' => array(),
54 );
55 // Perform the actual search.
56 foreach ($graph as $start => $data) {
57 _drupal_depth_first_search($graph, $state, $start);
58 }
59
60 // We do such a numbering that every component starts with 0. This is useful
61 // for module installs as we can install every 0 weighted module in one
62 // request, and then every 1 weighted etc.
63 $component_weights = array();
64
65 foreach ($state['last_visit_order'] as $vertex) {
66 $component = $graph[$vertex]['component'];
67 if (!isset($component_weights[$component])) {
68 $component_weights[$component] = 0;
69 }
70 $graph[$vertex]['weight'] = $component_weights[$component]--;
71 }
72 }
73
90 function _drupal_depth_first_search(&$graph, &$state, $start, &$component = NULL) {
91 // Assign new component for each new vertex, i.e. when not called recursively.
92 if (!isset($component)) {
93 $component = $start;
94 }
95 // Nothing to do, if we already visited this vertex.
96 if (isset($graph[$start]['paths'])) {
97 return;
98 }
99 // Mark $start as visited.
100 $graph[$start]['paths'] = array();
101
102 // Assign $start to the current component.
103 $graph[$start]['component'] = $component;
104 $state['components'][$component][] = $start;
105
106 // Visit edges of $start.
107 if (isset($graph[$start]['edges'])) {
108 foreach ($graph[$start]['edges'] as $end => $v) {
109 // Mark that $start can reach $end.
110 $graph[$start]['paths'][$end] = $v;
111
112 if (isset($graph[$end]['component']) && $component != $graph[$end]['component']) {
113 // This vertex already has a component, use that from now on and
114 // reassign all the previously explored vertices.
115 $new_component = $graph[$end]['component'];
116 foreach ($state['components'][$component] as $vertex) {
117 $graph[$vertex]['component'] = $new_component;
118 $state['components'][$new_component][] = $vertex;
119 }
120 unset($state['components'][$component]);
121 $component = $new_component;
122 }
123 // Only visit existing vertices.
124 if (isset($graph[$end])) {
125 // Visit the connected vertex.
126 _drupal_depth_first_search($graph, $state, $end, $component);
127
128 // All vertices reachable by $end are also reachable by $start.
129 $graph[$start]['paths'] += $graph[$end]['paths'];
130 }
131 }
132 }
133
134 // Now that any other subgraph has been explored, add $start to all reverse
135 // paths.
136 foreach ($graph[$start]['paths'] as $end => $v) {
137 if (isset($graph[$end])) {
138 $graph[$end]['reverse_paths'][$start] = $v;
139 }
140 }
141
142 // Record the order of the last visit. This is the reverse of the
143 // topological order if the graph is acyclic.
144 $state['last_visit_order'][] = $start;
145 }
drupal_depth_first_search
drupal_depth_first_search(&$graph)
Definition: graph.inc:47
_drupal_depth_first_search
_drupal_depth_first_search(&$graph, &$state, $start, &$component=NULL)
Definition: graph.inc:90
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/testing/testing.profile Source File

  • profiles
  • testing
testing.profile
Go to the documentation of this file.
1 <?php
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
UserController Member List

This is the complete list of members for UserController, including all inherited members.

$cache | DrupalDefaultEntityController | protected
$entityCache | DrupalDefaultEntityController | protected
$entityInfo | DrupalDefaultEntityController | protected
$entityType | DrupalDefaultEntityController | protected
$hookLoadArguments | DrupalDefaultEntityController | protected
$idKey | DrupalDefaultEntityController | protected
$revisionKey | DrupalDefaultEntityController | protected
$revisionTable | DrupalDefaultEntityController | protected
__construct($entityType) | DrupalDefaultEntityController |
attachLoad(&$queried_users, $revision_id=FALSE) | UserController |
buildQuery($ids, $conditions=array(), $revision_id=FALSE) | DrupalDefaultEntityController | protected
cacheGet($ids, $conditions=array()) | DrupalDefaultEntityController | protected
cacheSet($entities) | DrupalDefaultEntityController | protected
load($ids=array(), $conditions=array()) | DrupalDefaultEntityController |
resetCache(array $ids=NULL) | DrupalDefaultEntityController |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/seven/maintenance-page.tpl.php Source File

  • themes
  • seven
maintenance-page.tpl.php
Go to the documentation of this file.
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
4 <head>
5 <title><?php print $head_title; ?></title>
6 <?php print $head; ?>
7 <?php print $styles; ?>
8 <?php print $scripts; ?>
9 </head>
10 <body class="<?php print $classes; ?>">
11
12 <?php print $page_top; ?>
13
14 <div id="branding">
15 <?php if ($title): ?><h1 class="page-title"><?php print $title; ?></h1><?php endif; ?>
16 </div>
17
18 <div id="page">
19
20 <?php if ($sidebar_first): ?>
21 <div id="sidebar-first" class="sidebar">
22 <?php if ($logo): ?>
23 <img id="logo" src="<?php print $logo ?>" alt="<?php print $site_name ?>" />
24 <?php endif; ?>
25 <?php print $sidebar_first ?>
26 </div>
27 <?php endif; ?>
28
29 <div id="content" class="clearfix">
30 <?php if ($messages): ?>
31 <div id="console"><?php print $messages; ?></div>
32 <?php endif; ?>
33 <?php if ($help): ?>
34 <div id="help">
35 <?php print $help; ?>
36 </div>
37 <?php endif; ?>
38 <?php print $content; ?>
39 </div>
40
41 </div>
42
43 <?php print $page_bottom; ?>
44
45 </body>
46 </html>
dir
print $language dir
Definition: html.tpl.php:47
$head
print $head
Definition: book-export-html.tpl.php:25
print
print
Definition: php-2.php:2
$logo
print $logo
Definition: maintenance-page.tpl.php:33
$scripts
print $scripts
Definition: html.tpl.php:53
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
endif
endif
Definition: aggregator-item.tpl.php:31
$messages
print $messages
Definition: page.tpl.php:121
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
$styles
print $styles
Definition: html.tpl.php:52
title
print $topic title
Definition: forum-topic-list.tpl.php:50
$page_top
print $page_top
Definition: html.tpl.php:59
$help
print $help
Definition: maintenance-page.tpl.php:69
$head_title
print $head_title
Definition: html.tpl.php:51
$page_bottom
print $page_bottom
Definition: html.tpl.php:61
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/nodeapi_example/nodeapi_example.install Source File

  • examples
  • nodeapi_example
nodeapi_example.install
Go to the documentation of this file.
1 <?php
2
13 function nodeapi_example_schema() {
14 $schema['nodeapi_example'] = array(
15 'description' => 'Stores information of extended content.',
16 'fields' => array(
17 'nid' => array(
18 'description' => 'Node ID that the rating is applied to.',
19 'type' => 'int',
20 'unsigned' => TRUE,
21 'not null' => TRUE,
22 'default' => 0
23 ),
24 'vid' => array(
25 'description' => 'Revision ID, as we are tracking rating with node revisions',
26 'type' => 'int',
27 'unsigned' => TRUE,
28 'not null' => TRUE,
29 'default' => 0
30 ),
31 'rating' => array(
32 'description' => 'The rating of the node.',
33 'type' => 'int',
34 'unsigned' => TRUE,
35 'not null' => TRUE,
36 'default' => 0
37 ),
38 ),
39 'primary key' => array('vid'),
40 'indexes' => array(
41 'nid' => array('nid'),
42 ),
43 );
44
45 return $schema;
46 }
47
70 function nodeapi_example_uninstall() {
71 // Simple DB query to get the names of our variables.
72 $results = db_select('variable', 'v')
73 ->fields('v', array('name'))
74 ->condition('name', 'nodeapi_example_node_type_%', 'LIKE')
75 ->execute();
76 // Loop through and delete each of our variables.
77 foreach ($results as $result) {
78 variable_del($result->name);
79 }
80 }
variable_del
variable_del($name)
Definition: bootstrap.inc:996
$results
print $results
Definition: poll-results.tpl.php:23
nodeapi_example_schema
nodeapi_example_schema()
Definition: nodeapi_example.install:13
nodeapi_example_uninstall
nodeapi_example_uninstall()
Definition: nodeapi_example.install:70
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search.install Source File

  • modules
  • search
search.install
Go to the documentation of this file.
1 <?php
2
11 function search_uninstall() {
12 variable_del('minimum_word_size');
13 variable_del('overlap_cjk');
14 variable_del('search_cron_limit');
15 }
16
20 function search_schema() {
21 $schema['search_dataset'] = array(
22 'description' => 'Stores items that will be searched.',
23 'fields' => array(
24 'sid' => array(
25 'type' => 'int',
26 'unsigned' => TRUE,
27 'not null' => TRUE,
28 'default' => 0,
29 'description' => 'Search item ID, e.g. node ID for nodes.',
30 ),
31 'type' => array(
32 'type' => 'varchar',
33 'length' => 16,
34 'not null' => TRUE,
35 'description' => 'Type of item, e.g. node.',
36 ),
37 'data' => array(
38 'type' => 'text',
39 'not null' => TRUE,
40 'size' => 'big',
41 'description' => 'List of space-separated words from the item.',
42 ),
43 'reindex' => array(
44 'type' => 'int',
45 'unsigned' => TRUE,
46 'not null' => TRUE,
47 'default' => 0,
48 'description' => 'Set to force node reindexing.',
49 ),
50 ),
51 'primary key' => array('sid', 'type'),
52 );
53
54 $schema['search_index'] = array(
55 'description' => 'Stores the search index, associating words, items and scores.',
56 'fields' => array(
57 'word' => array(
58 'type' => 'varchar',
59 'length' => 50,
60 'not null' => TRUE,
61 'default' => '',
62 'description' => 'The {search_total}.word that is associated with the search item.',
63 ),
64 'sid' => array(
65 'type' => 'int',
66 'unsigned' => TRUE,
67 'not null' => TRUE,
68 'default' => 0,
69 'description' => 'The {search_dataset}.sid of the searchable item to which the word belongs.',
70 ),
71 'type' => array(
72 'type' => 'varchar',
73 'length' => 16,
74 'not null' => TRUE,
75 'description' => 'The {search_dataset}.type of the searchable item to which the word belongs.',
76 ),
77 'score' => array(
78 'type' => 'float',
79 'not null' => FALSE,
80 'description' => 'The numeric score of the word, higher being more important.',
81 ),
82 ),
83 'indexes' => array(
84 'sid_type' => array('sid', 'type'),
85 ),
86 'foreign keys' => array(
87 'search_dataset' => array(
88 'table' => 'search_dataset',
89 'columns' => array(
90 'sid' => 'sid',
91 'type' => 'type',
92 ),
93 ),
94 ),
95 'primary key' => array('word', 'sid', 'type'),
96 );
97
98 $schema['search_total'] = array(
99 'description' => 'Stores search totals for words.',
100 'fields' => array(
101 'word' => array(
102 'description' => 'Primary Key: Unique word in the search index.',
103 'type' => 'varchar',
104 'length' => 50,
105 'not null' => TRUE,
106 'default' => '',
107 ),
108 'count' => array(
109 'description' => "The count of the word in the index using Zipf's law to equalize the probability distribution.",
110 'type' => 'float',
111 'not null' => FALSE,
112 ),
113 ),
114 'primary key' => array('word'),
115 );
116
117 $schema['search_node_links'] = array(
118 'description' => 'Stores items (like nodes) that link to other nodes, used to improve search scores for nodes that are frequently linked to.',
119 'fields' => array(
120 'sid' => array(
121 'type' => 'int',
122 'unsigned' => TRUE,
123 'not null' => TRUE,
124 'default' => 0,
125 'description' => 'The {search_dataset}.sid of the searchable item containing the link to the node.',
126 ),
127 'type' => array(
128 'type' => 'varchar',
129 'length' => 16,
130 'not null' => TRUE,
131 'default' => '',
132 'description' => 'The {search_dataset}.type of the searchable item containing the link to the node.',
133 ),
134 'nid' => array(
135 'type' => 'int',
136 'unsigned' => TRUE,
137 'not null' => TRUE,
138 'default' => 0,
139 'description' => 'The {node}.nid that this item links to.',
140 ),
141 'caption' => array(
142 'type' => 'text',
143 'size' => 'big',
144 'not null' => FALSE,
145 'description' => 'The text used to link to the {node}.nid.',
146 ),
147 ),
148 'primary key' => array('sid', 'type', 'nid'),
149 'indexes' => array(
150 'nid' => array('nid'),
151 ),
152 );
153
154 return $schema;
155 }
156
160 function search_update_7000() {
161 db_drop_unique_key('search_dataset', 'sid_type');
162 $dataset_type_spec = array(
163 'type' => 'varchar',
164 'length' => 16,
165 'not null' => TRUE,
166 'description' => 'Type of item, e.g. node.',
167 );
168 db_change_field('search_dataset', 'type', 'type', $dataset_type_spec);
169 db_add_primary_key('search_dataset', array('sid', 'type'));
170
171 db_drop_index('search_index', 'word');
172 db_drop_unique_key('search_index', 'word_sid_type');
173 $index_type_spec = array(
174 'type' => 'varchar',
175 'length' => 16,
176 'not null' => TRUE,
177 'description' => 'The {search_dataset}.type of the searchable item to which the word belongs.',
178 );
179 db_change_field('search_index', 'type', 'type', $index_type_spec);
180 db_add_primary_key('search_index', array('word', 'sid', 'type'));
181 }
182
search_update_7000
search_update_7000()
Definition: search.install:160
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_drop_index
db_drop_index($table, $name)
Definition: database.inc:2952
search_schema
search_schema()
Definition: search.install:20
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
db_drop_unique_key
db_drop_unique_key($table, $name)
Definition: database.inc:2926
db_add_primary_key
db_add_primary_key($table, $fields)
Definition: database.inc:2890
search_uninstall
search_uninstall()
Definition: search.install:11
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Deprecated List

Deprecated List
Member _element_validate_integer ($element, &$form_state)
Member _element_validate_integer_positive ($element, &$form_state)
Member _element_validate_number ($element, &$form_state)
Member system_settings_overview ()
Generated on Mon Feb 3 2014 12:40:48 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/pgsql/select.inc Source File

  • includes
  • database
  • pgsql
select.inc
Go to the documentation of this file.
1 <?php
2
13 class SelectQuery_pgsql extends SelectQuery {
14
15 public function orderRandom() {
16 $alias = $this->addExpression('RANDOM()', 'random_field');
17 $this->orderBy($alias);
18 return $this;
19 }
20
50 public function orderBy($field, $direction = 'ASC') {
51 // Call parent function to order on this.
52 $return = parent::orderBy($field, $direction);
53
54 // If there is a table alias specified, split it up.
55 if (strpos($field, '.') !== FALSE) {
56 list($table, $table_field) = explode('.', $field);
57 }
58 // Figure out if the field has already been added.
59 foreach ($this->fields as $existing_field) {
60 if (!empty($table)) {
61 // If table alias is given, check if field and table exists.
62 if ($existing_field['table'] == $table && $existing_field['field'] == $table_field) {
63 return $return;
64 }
65 }
66 else {
67 // If there is no table, simply check if the field exists as a field or
68 // an aliased field.
69 if ($existing_field['alias'] == $field) {
70 return $return;
71 }
72 }
73 }
74
75 // Also check expression aliases.
76 foreach ($this->expressions as $expression) {
77 if ($expression['alias'] == $field) {
78 return $return;
79 }
80 }
81
82 // If a table loads all fields, it can not be added again. It would
83 // result in an ambigious alias error because that field would be loaded
84 // twice: Once through table_alias.* and once directly. If the field
85 // actually belongs to a different table, it must be added manually.
86 foreach ($this->tables as $table) {
87 if (!empty($table['all_fields'])) {
88 return $return;
89 }
90 }
91
92 // If $field contains an characters which are not allowed in a field name
93 // it is considered an expression, these can't be handeld automatically
94 // either.
95 if ($this->connection->escapeField($field) != $field) {
96 return $return;
97 }
98
99 // This is a case that can be handled automatically, add the field.
100 $this->addField(NULL, $field);
101 return $return;
102 }
103 }
104
SelectQuery\fields
fields($table_alias, array $fields=array())
Definition: select.inc:1300
SelectQuery_pgsql\orderBy
orderBy($field, $direction= 'ASC')
Definition: select.inc:50
SelectQuery
Definition: select.inc:859
SelectQuery\addExpression
addExpression($expression, $alias=NULL, $arguments=array())
Definition: select.inc:1316
SelectQuery\addField
addField($table_alias, $field, $alias=NULL)
Definition: select.inc:1272
SelectQuery_pgsql\orderRandom
orderRandom()
Definition: select.inc:15
SelectQuery_pgsql
Definition: select.inc:13
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/common.inc Source File

  • includes
common.inc
Go to the documentation of this file.
1 <?php
2
45 define('SAVED_NEW', 1);
46
50 define('SAVED_UPDATED', 2);
51
55 define('SAVED_DELETED', 3);
56
60 define('CSS_SYSTEM', -100);
61
65 define('CSS_DEFAULT', 0);
66
70 define('CSS_THEME', 100);
71
75 define('JS_LIBRARY', -100);
76
80 define('JS_DEFAULT', 0);
81
85 define('JS_THEME', 100);
86
92 define('HTTP_REQUEST_TIMEOUT', -1);
93
127 define('DRUPAL_NO_CACHE', -1);
128
135 define('DRUPAL_CACHE_CUSTOM', -2);
136
143 define('DRUPAL_CACHE_PER_ROLE', 0x0001);
144
151 define('DRUPAL_CACHE_PER_USER', 0x0002);
152
156 define('DRUPAL_CACHE_PER_PAGE', 0x0004);
157
161 define('DRUPAL_CACHE_GLOBAL', 0x0008);
162
175 function drupal_add_region_content($region = NULL, $data = NULL) {
176 static $content = array();
177
178 if (isset($region) && isset($data)) {
179 $content[$region][] = $data;
180 }
181 return $content;
182 }
183
193 function drupal_get_region_content($region = NULL, $delimiter = ' ') {
194 $content = drupal_add_region_content();
195 if (isset($region)) {
196 if (isset($content[$region]) && is_array($content[$region])) {
197 return implode($delimiter, $content[$region]);
198 }
199 }
200 else {
201 foreach (array_keys($content) as $region) {
202 if (is_array($content[$region])) {
203 $content[$region] = implode($delimiter, $content[$region]);
204 }
205 }
206 return $content;
207 }
208 }
209
222 function drupal_get_profile() {
223 global $install_state;
224
225 if (isset($install_state['parameters']['profile'])) {
226 $profile = $install_state['parameters']['profile'];
227 }
228 else {
229 $profile = variable_get('install_profile', 'standard');
230 }
231
232 return $profile;
233 }
234
235
243 function drupal_set_breadcrumb($breadcrumb = NULL) {
244 $stored_breadcrumb = &drupal_static(__FUNCTION__);
245
246 if (isset($breadcrumb)) {
247 $stored_breadcrumb = $breadcrumb;
248 }
249 return $stored_breadcrumb;
250 }
251
255 function drupal_get_breadcrumb() {
256 $breadcrumb = drupal_set_breadcrumb();
257
258 if (!isset($breadcrumb)) {
259 $breadcrumb = menu_get_active_breadcrumb();
260 }
261
262 return $breadcrumb;
263 }
264
269 function drupal_get_rdf_namespaces() {
270 $xml_rdf_namespaces = array();
271
272 // Serializes the RDF namespaces in XML namespace syntax.
273 if (function_exists('rdf_get_namespaces')) {
274 foreach (rdf_get_namespaces() as $prefix => $uri) {
275 $xml_rdf_namespaces[] = 'xmlns:' . $prefix . '="' . $uri . '"';
276 }
277 }
278 return count($xml_rdf_namespaces) ? "\n " . implode("\n ", $xml_rdf_namespaces) : '';
279 }
280
299 function drupal_add_html_head($data = NULL, $key = NULL) {
300 $stored_head = &drupal_static(__FUNCTION__);
301
302 if (!isset($stored_head)) {
303 // Make sure the defaults, including Content-Type, come first.
304 $stored_head = _drupal_default_html_head();
305 }
306
307 if (isset($data) && isset($key)) {
308 if (!isset($data['#type'])) {
309 $data['#type'] = 'html_tag';
310 }
311 $stored_head[$key] = $data;
312 }
313 return $stored_head;
314 }
315
319 function _drupal_default_html_head() {
320 // Add default elements. Make sure the Content-Type comes first because the
321 // IE browser may be vulnerable to XSS via encoding attacks from any content
322 // that comes before this META tag, such as a TITLE tag.
323 $elements['system_meta_content_type'] = array(
324 '#type' => 'html_tag',
325 '#tag' => 'meta',
326 '#attributes' => array(
327 'http-equiv' => 'Content-Type',
328 'content' => 'text/html; charset=utf-8',
329 ),
330 // Security: This always has to be output first.
331 '#weight' => -1000,
332 );
333 // Show Drupal and the major version number in the META GENERATOR tag.
334 // Get the major version.
335 list($version, ) = explode('.', VERSION);
336 $elements['system_meta_generator'] = array(
337 '#type' => 'html_tag',
338 '#tag' => 'meta',
339 '#attributes' => array(
340 'name' => 'Generator',
341 'content' => 'Drupal ' . $version . ' (http://drupal.org)',
342 ),
343 );
344 // Also send the generator in the HTTP header.
345 $elements['system_meta_generator']['#attached']['drupal_add_http_header'][] = array('X-Generator', $elements['system_meta_generator']['#attributes']['content']);
346 return $elements;
347 }
348
352 function drupal_get_html_head() {
353 $elements = drupal_add_html_head();
354 drupal_alter('html_head', $elements);
355 return drupal_render($elements);
356 }
357
368 function drupal_add_feed($url = NULL, $title = '') {
369 $stored_feed_links = &drupal_static(__FUNCTION__, array());
370
371 if (isset($url)) {
372 $stored_feed_links[$url] = theme('feed_icon', array('url' => $url, 'title' => $title));
373
374 drupal_add_html_head_link(array(
375 'rel' => 'alternate',
376 'type' => 'application/rss+xml',
377 'title' => $title,
378 // Force the URL to be absolute, for consistency with other <link> tags
379 // output by Drupal.
380 'href' => url($url, array('absolute' => TRUE)),
381 ));
382 }
383 return $stored_feed_links;
384 }
385
392 function drupal_get_feeds($delimiter = "\n") {
393 $feeds = drupal_add_feed();
394 return implode($feeds, $delimiter);
395 }
396
417 function drupal_get_query_parameters(array $query = NULL, array $exclude = array('q'), $parent = '') {
418 // Set defaults, if none given.
419 if (!isset($query)) {
420 $query = $_GET;
421 }
422 // If $exclude is empty, there is nothing to filter.
423 if (empty($exclude)) {
424 return $query;
425 }
426 elseif (!$parent) {
427 $exclude = array_flip($exclude);
428 }
429
430 $params = array();
431 foreach ($query as $key => $value) {
432 $string_key = ($parent ? $parent . '[' . $key . ']' : $key);
433 if (isset($exclude[$string_key])) {
434 continue;
435 }
436
437 if (is_array($value)) {
438 $params[$key] = drupal_get_query_parameters($value, $exclude, $string_key);
439 }
440 else {
441 $params[$key] = $value;
442 }
443 }
444
445 return $params;
446 }
447
457 function drupal_get_query_array($query) {
458 $result = array();
459 if (!empty($query)) {
460 foreach (explode('&', $query) as $param) {
461 $param = explode('=', $param);
462 $result[$param[0]] = isset($param[1]) ? rawurldecode($param[1]) : '';
463 }
464 }
465 return $result;
466 }
467
486 function drupal_http_build_query(array $query, $parent = '') {
487 $params = array();
488
489 foreach ($query as $key => $value) {
490 $key = ($parent ? $parent . '[' . rawurlencode($key) . ']' : rawurlencode($key));
491
492 // Recurse into children.
493 if (is_array($value)) {
494 $params[] = drupal_http_build_query($value, $key);
495 }
496 // If a query parameter value is NULL, only append its key.
497 elseif (!isset($value)) {
498 $params[] = $key;
499 }
500 else {
501 // For better readability of paths in query strings, we decode slashes.
502 $params[] = $key . '=' . str_replace('%2F', '/', rawurlencode($value));
503 }
504 }
505
506 return implode('&', $params);
507 }
508
525 function drupal_get_destination() {
526 $destination = &drupal_static(__FUNCTION__);
527
528 if (isset($destination)) {
529 return $destination;
530 }
531
532 if (isset($_GET['destination'])) {
533 $destination = array('destination' => $_GET['destination']);
534 }
535 else {
536 $path = $_GET['q'];
537 $query = drupal_http_build_query(drupal_get_query_parameters());
538 if ($query != '') {
539 $path .= '?' . $query;
540 }
541 $destination = array('destination' => $path);
542 }
543 return $destination;
544 }
545
580 function drupal_parse_url($url) {
581 $options = array(
582 'path' => NULL,
583 'query' => array(),
584 'fragment' => '',
585 );
586
587 // External URLs: not using parse_url() here, so we do not have to rebuild
588 // the scheme, host, and path without having any use for it.
589 if (strpos($url, '://') !== FALSE) {
590 // Split off everything before the query string into 'path'.
591 $parts = explode('?', $url);
592 $options['path'] = $parts[0];
593 // If there is a query string, transform it into keyed query parameters.
594 if (isset($parts[1])) {
595 $query_parts = explode('#', $parts[1]);
596 parse_str($query_parts[0], $options['query']);
597 // Take over the fragment, if there is any.
598 if (isset($query_parts[1])) {
599 $options['fragment'] = $query_parts[1];
600 }
601 }
602 }
603 // Internal URLs.
604 else {
605 // parse_url() does not support relative URLs, so make it absolute. E.g. the
606 // relative URL "foo/bar:1" isn't properly parsed.
607 $parts = parse_url('http://example.com/' . $url);
608 // Strip the leading slash that was just added.
609 $options['path'] = substr($parts['path'], 1);
610 if (isset($parts['query'])) {
611 parse_str($parts['query'], $options['query']);
612 }
613 if (isset($parts['fragment'])) {
614 $options['fragment'] = $parts['fragment'];
615 }
616 }
617 // The 'q' parameter contains the path of the current page if clean URLs are
618 // disabled. It overrides the 'path' of the URL when present, even if clean
619 // URLs are enabled, due to how Apache rewriting rules work.
620 if (isset($options['query']['q'])) {
621 $options['path'] = $options['query']['q'];
622 unset($options['query']['q']);
623 }
624
625 return $options;
626 }
627
639 function drupal_encode_path($path) {
640 return str_replace('%2F', '/', rawurlencode($path));
641 }
642
686 function drupal_goto($path = '', array $options = array(), $http_response_code = 302) {
687 // A destination in $_GET always overrides the function arguments.
688 // We do not allow absolute URLs to be passed via $_GET, as this can be an attack vector.
689 if (isset($_GET['destination']) && !url_is_external($_GET['destination'])) {
690 $destination = drupal_parse_url($_GET['destination']);
691 $path = $destination['path'];
692 $options['query'] = $destination['query'];
693 $options['fragment'] = $destination['fragment'];
694 }
695
696 drupal_alter('drupal_goto', $path, $options, $http_response_code);
697
698 // The 'Location' HTTP header must be absolute.
699 $options['absolute'] = TRUE;
700
701 $url = url($path, $options);
702
703 header('Location: ' . $url, TRUE, $http_response_code);
704
705 // The "Location" header sends a redirect status code to the HTTP daemon. In
706 // some cases this can be wrong, so we make sure none of the code below the
707 // drupal_goto() call gets executed upon redirection.
708 drupal_exit($url);
709 }
710
719 function drupal_site_offline() {
720 drupal_deliver_page(MENU_SITE_OFFLINE);
721 }
722
731 function drupal_not_found() {
732 drupal_deliver_page(MENU_NOT_FOUND);
733 }
734
744 function drupal_access_denied() {
745 drupal_deliver_page(MENU_ACCESS_DENIED);
746 }
747
787 function drupal_http_request($url, array $options = array()) {
788 // Allow an alternate HTTP client library to replace Drupal's default
789 // implementation.
790 $override_function = variable_get('drupal_http_request_function', FALSE);
791 if (!empty($override_function) && function_exists($override_function)) {
792 return $override_function($url, $options);
793 }
794
795 $result = new stdClass();
796
797 // Parse the URL and make sure we can handle the schema.
798 $uri = @parse_url($url);
799
800 if ($uri == FALSE) {
801 $result->error = 'unable to parse URL';
802 $result->code = -1001;
803 return $result;
804 }
805
806 if (!isset($uri['scheme'])) {
807 $result->error = 'missing schema';
808 $result->code = -1002;
809 return $result;
810 }
811
812 timer_start(__FUNCTION__);
813
814 // Merge the default options.
815 $options += array(
816 'headers' => array(),
817 'method' => 'GET',
818 'data' => NULL,
819 'max_redirects' => 3,
820 'timeout' => 30.0,
821 'context' => NULL,
822 );
823
824 // Merge the default headers.
825 $options['headers'] += array(
826 'User-Agent' => 'Drupal (+http://drupal.org/)',
827 );
828
829 // stream_socket_client() requires timeout to be a float.
830 $options['timeout'] = (float) $options['timeout'];
831
832 // Use a proxy if one is defined and the host is not on the excluded list.
833 $proxy_server = variable_get('proxy_server', '');
834 if ($proxy_server && _drupal_http_use_proxy($uri['host'])) {
835 // Set the scheme so we open a socket to the proxy server.
836 $uri['scheme'] = 'proxy';
837 // Set the path to be the full URL.
838 $uri['path'] = $url;
839 // Since the URL is passed as the path, we won't use the parsed query.
840 unset($uri['query']);
841
842 // Add in username and password to Proxy-Authorization header if needed.
843 if ($proxy_username = variable_get('proxy_username', '')) {
844 $proxy_password = variable_get('proxy_password', '');
845 $options['headers']['Proxy-Authorization'] = 'Basic ' . base64_encode($proxy_username . (!empty($proxy_password) ? ":" . $proxy_password : ''));
846 }
847 // Some proxies reject requests with any User-Agent headers, while others
848 // require a specific one.
849 $proxy_user_agent = variable_get('proxy_user_agent', '');
850 // The default value matches neither condition.
851 if ($proxy_user_agent === NULL) {
852 unset($options['headers']['User-Agent']);
853 }
854 elseif ($proxy_user_agent) {
855 $options['headers']['User-Agent'] = $proxy_user_agent;
856 }
857 }
858
859 switch ($uri['scheme']) {
860 case 'proxy':
861 // Make the socket connection to a proxy server.
862 $socket = 'tcp://' . $proxy_server . ':' . variable_get('proxy_port', 8080);
863 // The Host header still needs to match the real request.
864 $options['headers']['Host'] = $uri['host'];
865 $options['headers']['Host'] .= isset($uri['port']) && $uri['port'] != 80 ? ':' . $uri['port'] : '';
866 break;
867
868 case 'http':
869 case 'feed':
870 $port = isset($uri['port']) ? $uri['port'] : 80;
871 $socket = 'tcp://' . $uri['host'] . ':' . $port;
872 // RFC 2616: "non-standard ports MUST, default ports MAY be included".
873 // We don't add the standard port to prevent from breaking rewrite rules
874 // checking the host that do not take into account the port number.
875 $options['headers']['Host'] = $uri['host'] . ($port != 80 ? ':' . $port : '');
876 break;
877
878 case 'https':
879 // Note: Only works when PHP is compiled with OpenSSL support.
880 $port = isset($uri['port']) ? $uri['port'] : 443;
881 $socket = 'ssl://' . $uri['host'] . ':' . $port;
882 $options['headers']['Host'] = $uri['host'] . ($port != 443 ? ':' . $port : '');
883 break;
884
885 default:
886 $result->error = 'invalid schema ' . $uri['scheme'];
887 $result->code = -1003;
888 return $result;
889 }
890
891 if (empty($options['context'])) {
892 $fp = @stream_socket_client($socket, $errno, $errstr, $options['timeout']);
893 }
894 else {
895 // Create a stream with context. Allows verification of a SSL certificate.
896 $fp = @stream_socket_client($socket, $errno, $errstr, $options['timeout'], STREAM_CLIENT_CONNECT, $options['context']);
897 }
898
899 // Make sure the socket opened properly.
900 if (!$fp) {
901 // When a network error occurs, we use a negative number so it does not
902 // clash with the HTTP status codes.
903 $result->code = -$errno;
904 $result->error = trim($errstr) ? trim($errstr) : t('Error opening socket @socket', array('@socket' => $socket));
905
906 // Mark that this request failed. This will trigger a check of the web
907 // server's ability to make outgoing HTTP requests the next time that
908 // requirements checking is performed.
909 // See system_requirements().
910 variable_set('drupal_http_request_fails', TRUE);
911
912 return $result;
913 }
914
915 // Construct the path to act on.
916 $path = isset($uri['path']) ? $uri['path'] : '/';
917 if (isset($uri['query'])) {
918 $path .= '?' . $uri['query'];
919 }
920
921 // Only add Content-Length if we actually have any content or if it is a POST
922 // or PUT request. Some non-standard servers get confused by Content-Length in
923 // at least HEAD/GET requests, and Squid always requires Content-Length in
924 // POST/PUT requests.
925 $content_length = strlen($options['data']);
926 if ($content_length > 0 || $options['method'] == 'POST' || $options['method'] == 'PUT') {
927 $options['headers']['Content-Length'] = $content_length;
928 }
929
930 // If the server URL has a user then attempt to use basic authentication.
931 if (isset($uri['user'])) {
932 $options['headers']['Authorization'] = 'Basic ' . base64_encode($uri['user'] . (isset($uri['pass']) ? ':' . $uri['pass'] : ':'));
933 }
934
935 // If the database prefix is being used by SimpleTest to run the tests in a copied
936 // database then set the user-agent header to the database prefix so that any
937 // calls to other Drupal pages will run the SimpleTest prefixed database. The
938 // user-agent is used to ensure that multiple testing sessions running at the
939 // same time won't interfere with each other as they would if the database
940 // prefix were stored statically in a file or database variable.
941 $test_info = &$GLOBALS['drupal_test_info'];
942 if (!empty($test_info['test_run_id'])) {
943 $options['headers']['User-Agent'] = drupal_generate_test_ua($test_info['test_run_id']);
944 }
945
946 $request = $options['method'] . ' ' . $path . " HTTP/1.0\r\n";
947 foreach ($options['headers'] as $name => $value) {
948 $request .= $name . ': ' . trim($value) . "\r\n";
949 }
950 $request .= "\r\n" . $options['data'];
951 $result->request = $request;
952 // Calculate how much time is left of the original timeout value.
953 $timeout = $options['timeout'] - timer_read(__FUNCTION__) / 1000;
954 if ($timeout > 0) {
955 stream_set_timeout($fp, floor($timeout), floor(1000000 * fmod($timeout, 1)));
956 fwrite($fp, $request);
957 }
958
959 // Fetch response. Due to PHP bugs like http://bugs.php.net/bug.php?id=43782
960 // and http://bugs.php.net/bug.php?id=46049 we can't rely on feof(), but
961 // instead must invoke stream_get_meta_data() each iteration.
962 $info = stream_get_meta_data($fp);
963 $alive = !$info['eof'] && !$info['timed_out'];
964 $response = '';
965
966 while ($alive) {
967 // Calculate how much time is left of the original timeout value.
968 $timeout = $options['timeout'] - timer_read(__FUNCTION__) / 1000;
969 if ($timeout <= 0) {
970 $info['timed_out'] = TRUE;
971 break;
972 }
973 stream_set_timeout($fp, floor($timeout), floor(1000000 * fmod($timeout, 1)));
974 $chunk = fread($fp, 1024);
975 $response .= $chunk;
976 $info = stream_get_meta_data($fp);
977 $alive = !$info['eof'] && !$info['timed_out'] && $chunk;
978 }
979 fclose($fp);
980
981 if ($info['timed_out']) {
982 $result->code = HTTP_REQUEST_TIMEOUT;
983 $result->error = 'request timed out';
984 return $result;
985 }
986 // Parse response headers from the response body.
987 // Be tolerant of malformed HTTP responses that separate header and body with
988 // \n\n or \r\r instead of \r\n\r\n.
989 list($response, $result->data) = preg_split("/\r\n\r\n|\n\n|\r\r/", $response, 2);
990 $response = preg_split("/\r\n|\n|\r/", $response);
991
992 // Parse the response status line.
993 list($protocol, $code, $status_message) = explode(' ', trim(array_shift($response)), 3);
994 $result->protocol = $protocol;
995 $result->status_message = $status_message;
996
997 $result->headers = array();
998
999 // Parse the response headers.
1000 while ($line = trim(array_shift($response))) {
1001 list($name, $value) = explode(':', $line, 2);
1002 $name = strtolower($name);
1003 if (isset($result->headers[$name]) && $name == 'set-cookie') {
1004 // RFC 2109: the Set-Cookie response header comprises the token Set-
1005 // Cookie:, followed by a comma-separated list of one or more cookies.
1006 $result->headers[$name] .= ',' . trim($value);
1007 }
1008 else {
1009 $result->headers[$name] = trim($value);
1010 }
1011 }
1012
1013 $responses = array(
1014 100 => 'Continue',
1015 101 => 'Switching Protocols',
1016 200 => 'OK',
1017 201 => 'Created',
1018 202 => 'Accepted',
1019 203 => 'Non-Authoritative Information',
1020 204 => 'No Content',
1021 205 => 'Reset Content',
1022 206 => 'Partial Content',
1023 300 => 'Multiple Choices',
1024 301 => 'Moved Permanently',
1025 302 => 'Found',
1026 303 => 'See Other',
1027 304 => 'Not Modified',
1028 305 => 'Use Proxy',
1029 307 => 'Temporary Redirect',
1030 400 => 'Bad Request',
1031 401 => 'Unauthorized',
1032 402 => 'Payment Required',
1033 403 => 'Forbidden',
1034 404 => 'Not Found',
1035 405 => 'Method Not Allowed',
1036 406 => 'Not Acceptable',
1037 407 => 'Proxy Authentication Required',
1038 408 => 'Request Time-out',
1039 409 => 'Conflict',
1040 410 => 'Gone',
1041 411 => 'Length Required',
1042 412 => 'Precondition Failed',
1043 413 => 'Request Entity Too Large',
1044 414 => 'Request-URI Too Large',
1045 415 => 'Unsupported Media Type',
1046 416 => 'Requested range not satisfiable',
1047 417 => 'Expectation Failed',
1048 500 => 'Internal Server Error',
1049 501 => 'Not Implemented',
1050 502 => 'Bad Gateway',
1051 503 => 'Service Unavailable',
1052 504 => 'Gateway Time-out',
1053 505 => 'HTTP Version not supported',
1054 );
1055 // RFC 2616 states that all unknown HTTP codes must be treated the same as the
1056 // base code in their class.
1057 if (!isset($responses[$code])) {
1058 $code = floor($code / 100) * 100;
1059 }
1060 $result->code = $code;
1061
1062 switch ($code) {
1063 case 200: // OK
1064 case 304: // Not modified
1065 break;
1066 case 301: // Moved permanently
1067 case 302: // Moved temporarily
1068 case 307: // Moved temporarily
1069 $location = $result->headers['location'];
1070 $options['timeout'] -= timer_read(__FUNCTION__) / 1000;
1071 if ($options['timeout'] <= 0) {
1072 $result->code = HTTP_REQUEST_TIMEOUT;
1073 $result->error = 'request timed out';
1074 }
1075 elseif ($options['max_redirects']) {
1076 // Redirect to the new location.
1077 $options['max_redirects']--;
1078 $result = drupal_http_request($location, $options);
1079 $result->redirect_code = $code;
1080 }
1081 if (!isset($result->redirect_url)) {
1082 $result->redirect_url = $location;
1083 }
1084 break;
1085 default:
1086 $result->error = $status_message;
1087 }
1088
1089 return $result;
1090 }
1091
1098 function _drupal_http_use_proxy($host) {
1099 $proxy_exceptions = variable_get('proxy_exceptions', array('localhost', '127.0.0.1'));
1100 return !in_array(strtolower($host), $proxy_exceptions, TRUE);
1101 }
1102
1115 function _fix_gpc_magic(&$item) {
1116 if (is_array($item)) {
1117 array_walk($item, '_fix_gpc_magic');
1118 }
1119 else {
1120 $item = stripslashes($item);
1121 }
1122 }
1123
1139 function _fix_gpc_magic_files(&$item, $key) {
1140 if ($key != 'tmp_name') {
1141 if (is_array($item)) {
1142 array_walk($item, '_fix_gpc_magic_files');
1143 }
1144 else {
1145 $item = stripslashes($item);
1146 }
1147 }
1148 }
1149
1156 function fix_gpc_magic() {
1157 static $fixed = FALSE;
1158 if (!$fixed && ini_get('magic_quotes_gpc')) {
1159 array_walk($_GET, '_fix_gpc_magic');
1160 array_walk($_POST, '_fix_gpc_magic');
1161 array_walk($_COOKIE, '_fix_gpc_magic');
1162 array_walk($_REQUEST, '_fix_gpc_magic');
1163 array_walk($_FILES, '_fix_gpc_magic_files');
1164 }
1165 $fixed = TRUE;
1166 }
1167
1186 function valid_email_address($mail) {
1187 return (bool)filter_var($mail, FILTER_VALIDATE_EMAIL);
1188 }
1189
1204 function valid_url($url, $absolute = FALSE) {
1205 if ($absolute) {
1206 return (bool)preg_match("
1207 /^ # Start at the beginning of the text
1208 (?:ftp|https?|feed):\/\/ # Look for ftp, http, https or feed schemes
1209 (?: # Userinfo (optional) which is typically
1210 (?:(?:[\w\.\-\+!$&'\(\)*\+,;=]|%[0-9a-f]{2})+:)* # a username or a username and password
1211 (?:[\w\.\-\+%!$&'\(\)*\+,;=]|%[0-9a-f]{2})+@ # combination
1212 )?
1213 (?:
1214 (?:[a-z0-9\-\.]|%[0-9a-f]{2})+ # A domain name or a IPv4 address
1215 |(?:\[(?:[0-9a-f]{0,4}:)*(?:[0-9a-f]{0,4})\]) # or a well formed IPv6 address
1216 )
1217 (?::[0-9]+)? # Server port number (optional)
1218 (?:[\/|\?]
1219 (?:[\w#!:\.\?\+=&@$'~*,;\/\(\)\[\]\-]|%[0-9a-f]{2}) # The path and query (optional)
1220 *)?
1221 $/xi", $url);
1222 }
1223 else {
1224 return (bool)preg_match("/^(?:[\w#!:\.\?\+=&@$'~*,;\/\(\)\[\]\-]|%[0-9a-f]{2})+$/i", $url);
1225 }
1226 }
1227
1245 function flood_register_event($name, $window = 3600, $identifier = NULL) {
1246 if (!isset($identifier)) {
1247 $identifier = ip_address();
1248 }
1249 db_insert('flood')
1250 ->fields(array(
1251 'event' => $name,
1252 'identifier' => $identifier,
1253 'timestamp' => REQUEST_TIME,
1254 'expiration' => REQUEST_TIME + $window,
1255 ))
1256 ->execute();
1257 }
1258
1267 function flood_clear_event($name, $identifier = NULL) {
1268 if (!isset($identifier)) {
1269 $identifier = ip_address();
1270 }
1271 db_delete('flood')
1272 ->condition('event', $name)
1273 ->condition('identifier', $identifier)
1274 ->execute();
1275 }
1276
1298 function flood_is_allowed($name, $threshold, $window = 3600, $identifier = NULL) {
1299 if (!isset($identifier)) {
1300 $identifier = ip_address();
1301 }
1302 $number = db_query("SELECT COUNT(*) FROM {flood} WHERE event = :event AND identifier = :identifier AND timestamp > :timestamp", array(
1303 ':event' => $name,
1304 ':identifier' => $identifier,
1305 ':timestamp' => REQUEST_TIME - $window))
1306 ->fetchField();
1307 return ($number < $threshold);
1308 }
1309
1340 function drupal_strip_dangerous_protocols($uri) {
1341 static $allowed_protocols;
1342
1343 if (!isset($allowed_protocols)) {
1344 $allowed_protocols = array_flip(variable_get('filter_allowed_protocols', array('ftp', 'http', 'https', 'irc', 'mailto', 'news', 'nntp', 'rtsp', 'sftp', 'ssh', 'tel', 'telnet', 'webcal')));
1345 }
1346
1347 // Iteratively remove any invalid protocol found.
1348 do {
1349 $before = $uri;
1350 $colonpos = strpos($uri, ':');
1351 if ($colonpos > 0) {
1352 // We found a colon, possibly a protocol. Verify.
1353 $protocol = substr($uri, 0, $colonpos);
1354 // If a colon is preceded by a slash, question mark or hash, it cannot
1355 // possibly be part of the URL scheme. This must be a relative URL, which
1356 // inherits the (safe) protocol of the base document.
1357 if (preg_match('![/?#]!', $protocol)) {
1358 break;
1359 }
1360 // Check if this is a disallowed protocol. Per RFC2616, section 3.2.3
1361 // (URI Comparison) scheme comparison must be case-insensitive.
1362 if (!isset($allowed_protocols[strtolower($protocol)])) {
1363 $uri = substr($uri, $colonpos + 1);
1364 }
1365 }
1366 } while ($before != $uri);
1367
1368 return $uri;
1369 }
1370
1387 function check_url($uri) {
1388 return check_plain(drupal_strip_dangerous_protocols($uri));
1389 }
1390
1401 function filter_xss_admin($string) {
1402 return filter_xss($string, array('a', 'abbr', 'acronym', 'address', 'article', 'aside', 'b', 'bdi', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'command', 'dd', 'del', 'details', 'dfn', 'div', 'dl', 'dt', 'em', 'figcaption', 'figure', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'mark', 'menu', 'meter', 'nav', 'ol', 'output', 'p', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'small', 'span', 'strong', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', 'tr', 'tt', 'u', 'ul', 'var', 'wbr'));
1403 }
1404
1431 function filter_xss($string, $allowed_tags = array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd')) {
1432 // Only operate on valid UTF-8 strings. This is necessary to prevent cross
1433 // site scripting issues on Internet Explorer 6.
1434 if (!drupal_validate_utf8($string)) {
1435 return '';
1436 }
1437 // Store the text format.
1438 _filter_xss_split($allowed_tags, TRUE);
1439 // Remove NULL characters (ignored by some browsers).
1440 $string = str_replace(chr(0), '', $string);
1441 // Remove Netscape 4 JS entities.
1442 $string = preg_replace('%&\s*\{[^}]*(\}\s*;?|$)%', '', $string);
1443
1444 // Defuse all HTML entities.
1445 $string = str_replace('&', '&amp;', $string);
1446 // Change back only well-formed entities in our whitelist:
1447 // Decimal numeric entities.
1448 $string = preg_replace('/&amp;#([0-9]+;)/', '&#\1', $string);
1449 // Hexadecimal numeric entities.
1450 $string = preg_replace('/&amp;#[Xx]0*((?:[0-9A-Fa-f]{2})+;)/', '&#x\1', $string);
1451 // Named entities.
1452 $string = preg_replace('/&amp;([A-Za-z][A-Za-z0-9]*;)/', '&\1', $string);
1453
1454 return preg_replace_callback('%
1455 (
1456 <(?=[^a-zA-Z!/]) # a lone <
1457 | # or
1458 <!--.*?--> # a comment
1459 | # or
1460 <[^>]*(>|$) # a string that starts with a <, up until the > or the end of the string
1461 | # or
1462 > # just a >
1463 )%x', '_filter_xss_split', $string);
1464 }
1465
1480 function _filter_xss_split($m, $store = FALSE) {
1481 static $allowed_html;
1482
1483 if ($store) {
1484 $allowed_html = array_flip($m);
1485 return;
1486 }
1487
1488 $string = $m[1];
1489
1490 if (substr($string, 0, 1) != '<') {
1491 // We matched a lone ">" character.
1492 return '&gt;';
1493 }
1494 elseif (strlen($string) == 1) {
1495 // We matched a lone "<" character.
1496 return '&lt;';
1497 }
1498
1499 if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?|(<!--.*?-->)$%', $string, $matches)) {
1500 // Seriously malformed.
1501 return '';
1502 }
1503
1504 $slash = trim($matches[1]);
1505 $elem = &$matches[2];
1506 $attrlist = &$matches[3];
1507 $comment = &$matches[4];
1508
1509 if ($comment) {
1510 $elem = '!--';
1511 }
1512
1513 if (!isset($allowed_html[strtolower($elem)])) {
1514 // Disallowed HTML element.
1515 return '';
1516 }
1517
1518 if ($comment) {
1519 return $comment;
1520 }
1521
1522 if ($slash != '') {
1523 return "</$elem>";
1524 }
1525
1526 // Is there a closing XHTML slash at the end of the attributes?
1527 $attrlist = preg_replace('%(\s?)/\s*$%', '\1', $attrlist, -1, $count);
1528 $xhtml_slash = $count ? ' /' : '';
1529
1530 // Clean up attributes.
1531 $attr2 = implode(' ', _filter_xss_attributes($attrlist));
1532 $attr2 = preg_replace('/[<>]/', '', $attr2);
1533 $attr2 = strlen($attr2) ? ' ' . $attr2 : '';
1534
1535 return "<$elem$attr2$xhtml_slash>";
1536 }
1537
1544 function _filter_xss_attributes($attr) {
1545 $attrarr = array();
1546 $mode = 0;
1547 $attrname = '';
1548
1549 while (strlen($attr) != 0) {
1550 // Was the last operation successful?
1551 $working = 0;
1552
1553 switch ($mode) {
1554 case 0:
1555 // Attribute name, href for instance.
1556 if (preg_match('/^([-a-zA-Z]+)/', $attr, $match)) {
1557 $attrname = strtolower($match[1]);
1558 $skip = ($attrname == 'style' || substr($attrname, 0, 2) == 'on');
1559 $working = $mode = 1;
1560 $attr = preg_replace('/^[-a-zA-Z]+/', '', $attr);
1561 }
1562 break;
1563
1564 case 1:
1565 // Equals sign or valueless ("selected").
1566 if (preg_match('/^\s*=\s*/', $attr)) {
1567 $working = 1; $mode = 2;
1568 $attr = preg_replace('/^\s*=\s*/', '', $attr);
1569 break;
1570 }
1571
1572 if (preg_match('/^\s+/', $attr)) {
1573 $working = 1; $mode = 0;
1574 if (!$skip) {
1575 $attrarr[] = $attrname;
1576 }
1577 $attr = preg_replace('/^\s+/', '', $attr);
1578 }
1579 break;
1580
1581 case 2:
1582 // Attribute value, a URL after href= for instance.
1583 if (preg_match('/^"([^"]*)"(\s+|$)/', $attr, $match)) {
1584 $thisval = filter_xss_bad_protocol($match[1]);
1585
1586 if (!$skip) {
1587 $attrarr[] = "$attrname=\"$thisval\"";
1588 }
1589 $working = 1;
1590 $mode = 0;
1591 $attr = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr);
1592 break;
1593 }
1594
1595 if (preg_match("/^'([^']*)'(\s+|$)/", $attr, $match)) {
1596 $thisval = filter_xss_bad_protocol($match[1]);
1597
1598 if (!$skip) {
1599 $attrarr[] = "$attrname='$thisval'";
1600 }
1601 $working = 1; $mode = 0;
1602 $attr = preg_replace("/^'[^']*'(\s+|$)/", '', $attr);
1603 break;
1604 }
1605
1606 if (preg_match("%^([^\s\"']+)(\s+|$)%", $attr, $match)) {
1607 $thisval = filter_xss_bad_protocol($match[1]);
1608
1609 if (!$skip) {
1610 $attrarr[] = "$attrname=\"$thisval\"";
1611 }
1612 $working = 1; $mode = 0;
1613 $attr = preg_replace("%^[^\s\"']+(\s+|$)%", '', $attr);
1614 }
1615 break;
1616 }
1617
1618 if ($working == 0) {
1619 // Not well formed; remove and try again.
1620 $attr = preg_replace('/
1621 ^
1622 (
1623 "[^"]*("|$) # - a string that starts with a double quote, up until the next double quote or the end of the string
1624 | # or
1625 \'[^\']*(\'|$)| # - a string that starts with a quote, up until the next quote or the end of the string
1626 | # or
1627 \S # - a non-whitespace character
1628 )* # any number of the above three
1629 \s* # any number of whitespaces
1630 /x', '', $attr);
1631 $mode = 0;
1632 }
1633 }
1634
1635 // The attribute list ends with a valueless attribute like "selected".
1636 if ($mode == 1 && !$skip) {
1637 $attrarr[] = $attrname;
1638 }
1639 return $attrarr;
1640 }
1641
1656 function filter_xss_bad_protocol($string, $decode = TRUE) {
1657 // Get the plain text representation of the attribute value (i.e. its meaning).
1658 // @todo Remove the $decode parameter in Drupal 8, and always assume an HTML
1659 // string that needs decoding.
1660 if ($decode) {
1661 if (!function_exists('decode_entities')) {
1662 require_once DRUPAL_ROOT . '/includes/unicode.inc';
1663 }
1664
1665 $string = decode_entities($string);
1666 }
1667 return check_plain(drupal_strip_dangerous_protocols($string));
1668 }
1669
1685 function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) {
1686 global $language_content;
1687 $langcode = $langcode ? $langcode : $language_content->language;
1688
1689 $output = "<channel>\n";
1690 $output .= ' <title>' . check_plain($title) . "</title>\n";
1691 $output .= ' <link>' . check_url($link) . "</link>\n";
1692
1693 // The RSS 2.0 "spec" doesn't indicate HTML can be used in the description.
1694 // We strip all HTML tags, but need to prevent double encoding from properly
1695 // escaped source data (such as &amp becoming &amp;amp;).
1696 $output .= ' <description>' . check_plain(decode_entities(strip_tags($description))) . "</description>\n";
1697 $output .= ' <language>' . check_plain($langcode) . "</language>\n";
1698 $output .= format_xml_elements($args);
1699 $output .= $items;
1700 $output .= "</channel>\n";
1701
1702 return $output;
1703 }
1704
1710 function format_rss_item($title, $link, $description, $args = array()) {
1711 $output = "<item>\n";
1712 $output .= ' <title>' . check_plain($title) . "</title>\n";
1713 $output .= ' <link>' . check_url($link) . "</link>\n";
1714 $output .= ' <description>' . check_plain($description) . "</description>\n";
1715 $output .= format_xml_elements($args);
1716 $output .= "</item>\n";
1717
1718 return $output;
1719 }
1720
1735 function format_xml_elements($array) {
1736 $output = '';
1737 foreach ($array as $key => $value) {
1738 if (is_numeric($key)) {
1739 if ($value['key']) {
1740 $output .= ' <' . $value['key'];
1741 if (isset($value['attributes']) && is_array($value['attributes'])) {
1742 $output .= drupal_attributes($value['attributes']);
1743 }
1744
1745 if (isset($value['value']) && $value['value'] != '') {
1746 $output .= '>' . (is_array($value['value']) ? format_xml_elements($value['value']) : check_plain($value['value'])) . '</' . $value['key'] . ">\n";
1747 }
1748 else {
1749 $output .= " />\n";
1750 }
1751 }
1752 }
1753 else {
1754 $output .= ' <' . $key . '>' . (is_array($value) ? format_xml_elements($value) : check_plain($value)) . "</$key>\n";
1755 }
1756 }
1757 return $output;
1758 }
1759
1805 function format_plural($count, $singular, $plural, array $args = array(), array $options = array()) {
1806 $args['@count'] = $count;
1807 if ($count == 1) {
1808 return t($singular, $args, $options);
1809 }
1810
1811 // Get the plural index through the gettext formula.
1812 $index = (function_exists('locale_get_plural')) ? locale_get_plural($count, isset($options['langcode']) ? $options['langcode'] : NULL) : -1;
1813 // If the index cannot be computed, use the plural as a fallback (which
1814 // allows for most flexiblity with the replaceable @count value).
1815 if ($index < 0) {
1816 return t($plural, $args, $options);
1817 }
1818 else {
1819 switch ($index) {
1820 case "0":
1821 return t($singular, $args, $options);
1822 case "1":
1823 return t($plural, $args, $options);
1824 default:
1825 unset($args['@count']);
1826 $args['@count[' . $index . ']'] = $count;
1827 return t(strtr($plural, array('@count' => '@count[' . $index . ']')), $args, $options);
1828 }
1829 }
1830 }
1831
1842 function parse_size($size) {
1843 $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
1844 $size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
1845 if ($unit) {
1846 // Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
1847 return round($size * pow(DRUPAL_KILOBYTE, stripos('bkmgtpezy', $unit[0])));
1848 }
1849 else {
1850 return round($size);
1851 }
1852 }
1853
1866 function format_size($size, $langcode = NULL) {
1867 if ($size < DRUPAL_KILOBYTE) {
1868 return format_plural($size, '1 byte', '@count bytes', array(), array('langcode' => $langcode));
1869 }
1870 else {
1871 $size = $size / DRUPAL_KILOBYTE; // Convert bytes to kilobytes.
1872 $units = array(
1873 t('@size KB', array(), array('langcode' => $langcode)),
1874 t('@size MB', array(), array('langcode' => $langcode)),
1875 t('@size GB', array(), array('langcode' => $langcode)),
1876 t('@size TB', array(), array('langcode' => $langcode)),
1877 t('@size PB', array(), array('langcode' => $langcode)),
1878 t('@size EB', array(), array('langcode' => $langcode)),
1879 t('@size ZB', array(), array('langcode' => $langcode)),
1880 t('@size YB', array(), array('langcode' => $langcode)),
1881 );
1882 foreach ($units as $unit) {
1883 if (round($size, 2) >= DRUPAL_KILOBYTE) {
1884 $size = $size / DRUPAL_KILOBYTE;
1885 }
1886 else {
1887 break;
1888 }
1889 }
1890 return str_replace('@size', round($size, 2), $unit);
1891 }
1892 }
1893
1908 function format_interval($interval, $granularity = 2, $langcode = NULL) {
1909 $units = array(
1910 '1 year|@count years' => 31536000,
1911 '1 month|@count months' => 2592000,
1912 '1 week|@count weeks' => 604800,
1913 '1 day|@count days' => 86400,
1914 '1 hour|@count hours' => 3600,
1915 '1 min|@count min' => 60,
1916 '1 sec|@count sec' => 1
1917 );
1918 $output = '';
1919 foreach ($units as $key => $value) {
1920 $key = explode('|', $key);
1921 if ($interval >= $value) {
1922 $output .= ($output ? ' ' : '') . format_plural(floor($interval / $value), $key[0], $key[1], array(), array('langcode' => $langcode));
1923 $interval %= $value;
1924 $granularity--;
1925 }
1926
1927 if ($granularity == 0) {
1928 break;
1929 }
1930 }
1931 return $output ? $output : t('0 sec', array(), array('langcode' => $langcode));
1932 }
1933
1962 function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
1963 // Use the advanced drupal_static() pattern, since this is called very often.
1964 static $drupal_static_fast;
1965 if (!isset($drupal_static_fast)) {
1966 $drupal_static_fast['timezones'] = &drupal_static(__FUNCTION__);
1967 }
1968 $timezones = &$drupal_static_fast['timezones'];
1969
1970 if (!isset($timezone)) {
1971 $timezone = date_default_timezone_get();
1972 }
1973 // Store DateTimeZone objects in an array rather than repeatedly
1974 // constructing identical objects over the life of a request.
1975 if (!isset($timezones[$timezone])) {
1976 $timezones[$timezone] = timezone_open($timezone);
1977 }
1978
1979 // Use the default langcode if none is set.
1980 global $language;
1981 if (empty($langcode)) {
1982 $langcode = isset($language->language) ? $language->language : 'en';
1983 }
1984
1985 switch ($type) {
1986 case 'short':
1987 $format = variable_get('date_format_short', 'm/d/Y - H:i');
1988 break;
1989
1990 case 'long':
1991 $format = variable_get('date_format_long', 'l, F j, Y - H:i');
1992 break;
1993
1994 case 'custom':
1995 // No change to format.
1996 break;
1997
1998 case 'medium':
1999 default:
2000 // Retrieve the format of the custom $type passed.
2001 if ($type != 'medium') {
2002 $format = variable_get('date_format_' . $type, '');
2003 }
2004 // Fall back to 'medium'.
2005 if ($format === '') {
2006 $format = variable_get('date_format_medium', 'D, m/d/Y - H:i');
2007 }
2008 break;
2009 }
2010
2011 // Create a DateTime object from the timestamp.
2012 $date_time = date_create('@' . $timestamp);
2013 // Set the time zone for the DateTime object.
2014 date_timezone_set($date_time, $timezones[$timezone]);
2015
2016 // Encode markers that should be translated. 'A' becomes '\xEF\AA\xFF'.
2017 // xEF and xFF are invalid UTF-8 sequences, and we assume they are not in the
2018 // input string.
2019 // Paired backslashes are isolated to prevent errors in read-ahead evaluation.
2020 // The read-ahead expression ensures that A matches, but not \A.
2021 $format = preg_replace(array('/\\\\\\\\/', '/(?<!\\\\)([AaeDlMTF])/'), array("\xEF\\\\\\\\\xFF", "\xEF\\\\\$1\$1\xFF"), $format);
2022
2023 // Call date_format().
2024 $format = date_format($date_time, $format);
2025
2026 // Pass the langcode to _format_date_callback().
2027 _format_date_callback(NULL, $langcode);
2028
2029 // Translate the marked sequences.
2030 return preg_replace_callback('/\xEF([AaeDlMTF]?)(.*?)\xFF/', '_format_date_callback', $format);
2031 }
2032
2044 function date_iso8601($date) {
2045 // The DATE_ISO8601 constant cannot be used here because it does not match
2046 // date('c') and produces invalid RDF markup.
2047 return date('c', $date);
2048 }
2049
2055 function _format_date_callback(array $matches = NULL, $new_langcode = NULL) {
2056 // We cache translations to avoid redundant and rather costly calls to t().
2057 static $cache, $langcode;
2058
2059 if (!isset($matches)) {
2060 $langcode = $new_langcode;
2061 return;
2062 }
2063
2064 $code = $matches[1];
2065 $string = $matches[2];
2066
2067 if (!isset($cache[$langcode][$code][$string])) {
2068 $options = array(
2069 'langcode' => $langcode,
2070 );
2071
2072 if ($code == 'F') {
2073 $options['context'] = 'Long month name';
2074 }
2075
2076 if ($code == '') {
2077 $cache[$langcode][$code][$string] = $string;
2078 }
2079 else {
2080 $cache[$langcode][$code][$string] = t($string, array(), $options);
2081 }
2082 }
2083 return $cache[$langcode][$code][$string];
2084 }
2085
2106 function format_username($account) {
2107 $name = !empty($account->name) ? $account->name : variable_get('anonymous', t('Anonymous'));
2108 drupal_alter('username', $name, $account);
2109 return $name;
2110 }
2111
2181 function url($path = NULL, array $options = array()) {
2182 // Merge in defaults.
2183 $options += array(
2184 'fragment' => '',
2185 'query' => array(),
2186 'absolute' => FALSE,
2187 'alias' => FALSE,
2188 'prefix' => ''
2189 );
2190
2191 if (!isset($options['external'])) {
2192 // Return an external link if $path contains an allowed absolute URL. Only
2193 // call the slow drupal_strip_dangerous_protocols() if $path contains a ':'
2194 // before any / ? or #. Note: we could use url_is_external($path) here, but
2195 // that would require another function call, and performance inside url() is
2196 // critical.
2197 $colonpos = strpos($path, ':');
2198 $options['external'] = ($colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && drupal_strip_dangerous_protocols($path) == $path);
2199 }
2200
2201 // Preserve the original path before altering or aliasing.
2202 $original_path = $path;
2203
2204 // Allow other modules to alter the outbound URL and options.
2205 drupal_alter('url_outbound', $path, $options, $original_path);
2206
2207 if (isset($options['fragment']) && $options['fragment'] !== '') {
2208 $options['fragment'] = '#' . $options['fragment'];
2209 }
2210
2211 if ($options['external']) {
2212 // Split off the fragment.
2213 if (strpos($path, '#') !== FALSE) {
2214 list($path, $old_fragment) = explode('#', $path, 2);
2215 // If $options contains no fragment, take it over from the path.
2216 if (isset($old_fragment) && !$options['fragment']) {
2217 $options['fragment'] = '#' . $old_fragment;
2218 }
2219 }
2220 // Append the query.
2221 if ($options['query']) {
2222 $path .= (strpos($path, '?') !== FALSE ? '&' : '?') . drupal_http_build_query($options['query']);
2223 }
2224 if (isset($options['https']) && variable_get('https', FALSE)) {
2225 if ($options['https'] === TRUE) {
2226 $path = str_replace('http://', 'https://', $path);
2227 }
2228 elseif ($options['https'] === FALSE) {
2229 $path = str_replace('https://', 'http://', $path);
2230 }
2231 }
2232 // Reassemble.
2233 return $path . $options['fragment'];
2234 }
2235
2236 global $base_url, $base_secure_url, $base_insecure_url;
2237
2238 // The base_url might be rewritten from the language rewrite in domain mode.
2239 if (!isset($options['base_url'])) {
2240 if (isset($options['https']) && variable_get('https', FALSE)) {
2241 if ($options['https'] === TRUE) {
2242 $options['base_url'] = $base_secure_url;
2243 $options['absolute'] = TRUE;
2244 }
2245 elseif ($options['https'] === FALSE) {
2246 $options['base_url'] = $base_insecure_url;
2247 $options['absolute'] = TRUE;
2248 }
2249 }
2250 else {
2251 $options['base_url'] = $base_url;
2252 }
2253 }
2254
2255 // The special path '<front>' links to the default front page.
2256 if ($path == '<front>') {
2257 $path = '';
2258 }
2259 elseif (!empty($path) && !$options['alias']) {
2260 $language = isset($options['language']) && isset($options['language']->language) ? $options['language']->language : '';
2261 $alias = drupal_get_path_alias($original_path, $language);
2262 if ($alias != $original_path) {
2263 $path = $alias;
2264 }
2265 }
2266
2267 $base = $options['absolute'] ? $options['base_url'] . '/' : base_path();
2268 $prefix = empty($path) ? rtrim($options['prefix'], '/') : $options['prefix'];
2269
2270 // With Clean URLs.
2271 if (!empty($GLOBALS['conf']['clean_url'])) {
2272 $path = drupal_encode_path($prefix . $path);
2273 if ($options['query']) {
2274 return $base . $path . '?' . drupal_http_build_query($options['query']) . $options['fragment'];
2275 }
2276 else {
2277 return $base . $path . $options['fragment'];
2278 }
2279 }
2280 // Without Clean URLs.
2281 else {
2282 $path = $prefix . $path;
2283 $query = array();
2284 if (!empty($path)) {
2285 $query['q'] = $path;
2286 }
2287 if ($options['query']) {
2288 // We do not use array_merge() here to prevent overriding $path via query
2289 // parameters.
2290 $query += $options['query'];
2291 }
2292 $query = $query ? ('?' . drupal_http_build_query($query)) : '';
2293 $script = isset($options['script']) ? $options['script'] : '';
2294 return $base . $script . $query . $options['fragment'];
2295 }
2296 }
2297
2311 function url_is_external($path) {
2312 $colonpos = strpos($path, ':');
2313 // Avoid calling drupal_strip_dangerous_protocols() if there is any
2314 // slash (/), hash (#) or question_mark (?) before the colon (:)
2315 // occurrence - if any - as this would clearly mean it is not a URL.
2316 return $colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && drupal_strip_dangerous_protocols($path) == $path;
2317 }
2318
2331 function drupal_http_header_attributes(array $attributes = array()) {
2332 foreach ($attributes as $attribute => &$data) {
2333 if (is_array($data)) {
2334 $data = implode(' ', $data);
2335 }
2336 $data = $attribute . '="' . $data . '"';
2337 }
2338 return $attributes ? ' ' . implode('; ', $attributes) : '';
2339 }
2340
2377 function drupal_attributes(array $attributes = array()) {
2378 foreach ($attributes as $attribute => &$data) {
2379 $data = implode(' ', (array) $data);
2380 $data = $attribute . '="' . check_plain($data) . '"';
2381 }
2382 return $attributes ? ' ' . implode(' ', $attributes) : '';
2383 }
2384
2432 function l($text, $path, array $options = array()) {
2433 global $language_url;
2434 static $use_theme = NULL;
2435
2436 // Merge in defaults.
2437 $options += array(
2438 'attributes' => array(),
2439 'html' => FALSE,
2440 );
2441
2442 // Append active class.
2443 if (($path == $_GET['q'] || ($path == '<front>' && drupal_is_front_page())) &&
2444 (empty($options['language']) || $options['language']->language == $language_url->language)) {
2445 $options['attributes']['class'][] = 'active';
2446 }
2447
2448 // Remove all HTML and PHP tags from a tooltip. For best performance, we act only
2449 // if a quick strpos() pre-check gave a suspicion (because strip_tags() is expensive).
2450 if (isset($options['attributes']['title']) && strpos($options['attributes']['title'], '<') !== FALSE) {
2451 $options['attributes']['title'] = strip_tags($options['attributes']['title']);
2452 }
2453
2454 // Determine if rendering of the link is to be done with a theme function
2455 // or the inline default. Inline is faster, but if the theme system has been
2456 // loaded and a module or theme implements a preprocess or process function
2457 // or overrides the theme_link() function, then invoke theme(). Preliminary
2458 // benchmarks indicate that invoking theme() can slow down the l() function
2459 // by 20% or more, and that some of the link-heavy Drupal pages spend more
2460 // than 10% of the total page request time in the l() function.
2461 if (!isset($use_theme) && function_exists('theme')) {
2462 // Allow edge cases to prevent theme initialization and force inline link
2463 // rendering.
2464 if (variable_get('theme_link', TRUE)) {
2465 drupal_theme_initialize();
2466 $registry = theme_get_registry(FALSE);
2467 // We don't want to duplicate functionality that's in theme(), so any
2468 // hint of a module or theme doing anything at all special with the 'link'
2469 // theme hook should simply result in theme() being called. This includes
2470 // the overriding of theme_link() with an alternate function or template,
2471 // the presence of preprocess or process functions, or the presence of
2472 // include files.
2473 $use_theme = !isset($registry['link']['function']) || ($registry['link']['function'] != 'theme_link');
2474 $use_theme = $use_theme || !empty($registry['link']['preprocess functions']) || !empty($registry['link']['process functions']) || !empty($registry['link']['includes']);
2475 }
2476 else {
2477 $use_theme = FALSE;
2478 }
2479 }
2480 if ($use_theme) {
2481 return theme('link', array('text' => $text, 'path' => $path, 'options' => $options));
2482 }
2483 // The result of url() is a plain-text URL. Because we are using it here
2484 // in an HTML argument context, we need to encode it properly.
2485 return '<a href="' . check_plain(url($path, $options)) . '"' . drupal_attributes($options['attributes']) . '>' . ($options['html'] ? $text : check_plain($text)) . '</a>';
2486 }
2487
2554 function drupal_deliver_page($page_callback_result, $default_delivery_callback = NULL) {
2555 if (!isset($default_delivery_callback) && ($router_item = menu_get_item())) {
2556 $default_delivery_callback = $router_item['delivery_callback'];
2557 }
2558 $delivery_callback = !empty($default_delivery_callback) ? $default_delivery_callback : 'drupal_deliver_html_page';
2559 // Give modules a chance to alter the delivery callback used, based on
2560 // request-time context (e.g., HTTP request headers).
2561 drupal_alter('page_delivery_callback', $delivery_callback);
2562 if (function_exists($delivery_callback)) {
2563 $delivery_callback($page_callback_result);
2564 }
2565 else {
2566 // If a delivery callback is specified, but doesn't exist as a function,
2567 // something is wrong, but don't print anything, since it's not known
2568 // what format the response needs to be in.
2569 watchdog('delivery callback not found', 'callback %callback not found: %q.', array('%callback' => $delivery_callback, '%q' => $_GET['q']), WATCHDOG_ERROR);
2570 }
2571 }
2572
2585 function drupal_deliver_html_page($page_callback_result) {
2586 // Emit the correct charset HTTP header, but not if the page callback
2587 // result is NULL, since that likely indicates that it printed something
2588 // in which case, no further headers may be sent, and not if code running
2589 // for this page request has already set the content type header.
2590 if (isset($page_callback_result) && is_null(drupal_get_http_header('Content-Type'))) {
2591 drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
2592 }
2593
2594 // Send appropriate HTTP-Header for browsers and search engines.
2595 global $language;
2596 drupal_add_http_header('Content-Language', $language->language);
2597
2598 // Menu status constants are integers; page content is a string or array.
2599 if (is_int($page_callback_result)) {
2600 // @todo: Break these up into separate functions?
2601 switch ($page_callback_result) {
2602 case MENU_NOT_FOUND:
2603 // Print a 404 page.
2604 drupal_add_http_header('Status', '404 Not Found');
2605
2606 watchdog('page not found', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
2607
2608 // Check for and return a fast 404 page if configured.
2609 drupal_fast_404();
2610
2611 // Keep old path for reference, and to allow forms to redirect to it.
2612 if (!isset($_GET['destination'])) {
2613 $_GET['destination'] = $_GET['q'];
2614 }
2615
2616 $path = drupal_get_normal_path(variable_get('site_404', ''));
2617 if ($path && $path != $_GET['q']) {
2618 // Custom 404 handler. Set the active item in case there are tabs to
2619 // display, or other dependencies on the path.
2620 menu_set_active_item($path);
2621 $return = menu_execute_active_handler($path, FALSE);
2622 }
2623
2624 if (empty($return) || $return == MENU_NOT_FOUND || $return == MENU_ACCESS_DENIED) {
2625 // Standard 404 handler.
2626 drupal_set_title(t('Page not found'));
2627 $return = t('The requested page "@path" could not be found.', array('@path' => request_uri()));
2628 }
2629
2630 drupal_set_page_content($return);
2631 $page = element_info('page');
2632 print drupal_render_page($page);
2633 break;
2634
2635 case MENU_ACCESS_DENIED:
2636 // Print a 403 page.
2637 drupal_add_http_header('Status', '403 Forbidden');
2638 watchdog('access denied', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
2639
2640 // Keep old path for reference, and to allow forms to redirect to it.
2641 if (!isset($_GET['destination'])) {
2642 $_GET['destination'] = $_GET['q'];
2643 }
2644
2645 $path = drupal_get_normal_path(variable_get('site_403', ''));
2646 if ($path && $path != $_GET['q']) {
2647 // Custom 403 handler. Set the active item in case there are tabs to
2648 // display or other dependencies on the path.
2649 menu_set_active_item($path);
2650 $return = menu_execute_active_handler($path, FALSE);
2651 }
2652
2653 if (empty($return) || $return == MENU_NOT_FOUND || $return == MENU_ACCESS_DENIED) {
2654 // Standard 403 handler.
2655 drupal_set_title(t('Access denied'));
2656 $return = t('You are not authorized to access this page.');
2657 }
2658
2659 print drupal_render_page($return);
2660 break;
2661
2662 case MENU_SITE_OFFLINE:
2663 // Print a 503 page.
2664 drupal_maintenance_theme();
2665 drupal_add_http_header('Status', '503 Service unavailable');
2666 drupal_set_title(t('Site under maintenance'));
2667 print theme('maintenance_page', array('content' => filter_xss_admin(variable_get('maintenance_mode_message',
2668 t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))))));
2669 break;
2670 }
2671 }
2672 elseif (isset($page_callback_result)) {
2673 // Print anything besides a menu constant, assuming it's not NULL or
2674 // undefined.
2675 print drupal_render_page($page_callback_result);
2676 }
2677
2678 // Perform end-of-request tasks.
2679 drupal_page_footer();
2680 }
2681
2688 function drupal_page_footer() {
2689 global $user;
2690
2691 module_invoke_all('exit');
2692
2693 // Commit the user session, if needed.
2694 drupal_session_commit();
2695
2696 if (variable_get('cache', 0) && ($cache = drupal_page_set_cache())) {
2697 drupal_serve_page_from_cache($cache);
2698 }
2699 else {
2700 ob_flush();
2701 }
2702
2703 _registry_check_code(REGISTRY_WRITE_LOOKUP_CACHE);
2704 drupal_cache_system_paths();
2705 module_implements_write_cache();
2706 system_run_automated_cron();
2707 }
2708
2721 function drupal_exit($destination = NULL) {
2722 if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL) {
2723 if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
2724 module_invoke_all('exit', $destination);
2725 }
2726 drupal_session_commit();
2727 }
2728 exit;
2729 }
2730
2748 function drupal_map_assoc($array, $function = NULL) {
2749 // array_combine() fails with empty arrays:
2750 // http://bugs.php.net/bug.php?id=34857.
2751 $array = !empty($array) ? array_combine($array, $array) : array();
2752 if (is_callable($function)) {
2753 $array = array_map($function, $array);
2754 }
2755 return $array;
2756 }
2757
2786 function drupal_set_time_limit($time_limit) {
2787 if (function_exists('set_time_limit')) {
2788 @set_time_limit($time_limit);
2789 }
2790 }
2791
2803 function drupal_get_path($type, $name) {
2804 return dirname(drupal_get_filename($type, $name));
2805 }
2806
2817 function base_path() {
2818 return $GLOBALS['base_path'];
2819 }
2820
2834 function drupal_add_html_head_link($attributes, $header = FALSE) {
2835 $element = array(
2836 '#tag' => 'link',
2837 '#attributes' => $attributes,
2838 );
2839 $href = $attributes['href'];
2840
2841 if ($header) {
2842 // Also add a HTTP header "Link:".
2843 $href = '<' . check_plain($attributes['href']) . '>;';
2844 unset($attributes['href']);
2845 $element['#attached']['drupal_add_http_header'][] = array('Link', $href . drupal_http_header_attributes($attributes), TRUE);
2846 }
2847
2848 drupal_add_html_head($element, 'drupal_add_html_head_link:' . $attributes['rel'] . ':' . $href);
2849 }
2850
2967 function drupal_add_css($data = NULL, $options = NULL) {
2968 $css = &drupal_static(__FUNCTION__, array());
2969
2970 // Construct the options, taking the defaults into consideration.
2971 if (isset($options)) {
2972 if (!is_array($options)) {
2973 $options = array('type' => $options);
2974 }
2975 }
2976 else {
2977 $options = array();
2978 }
2979
2980 // Create an array of CSS files for each media type first, since each type needs to be served
2981 // to the browser differently.
2982 if (isset($data)) {
2983 $options += array(
2984 'type' => 'file',
2985 'group' => CSS_DEFAULT,
2986 'weight' => 0,
2987 'every_page' => FALSE,
2988 'media' => 'all',
2989 'preprocess' => TRUE,
2990 'data' => $data,
2991 'browsers' => array(),
2992 );
2993 $options['browsers'] += array(
2994 'IE' => TRUE,
2995 '!IE' => TRUE,
2996 );
2997
2998 // Files with a query string cannot be preprocessed.
2999 if ($options['type'] === 'file' && $options['preprocess'] && strpos($options['data'], '?') !== FALSE) {
3000 $options['preprocess'] = FALSE;
3001 }
3002
3003 // Always add a tiny value to the weight, to conserve the insertion order.
3004 $options['weight'] += count($css) / 1000;
3005
3006 // Add the data to the CSS array depending on the type.
3007 switch ($options['type']) {
3008 case 'inline':
3009 // For inline stylesheets, we don't want to use the $data as the array
3010 // key as $data could be a very long string of CSS.
3011 $css[] = $options;
3012 break;
3013 default:
3014 // Local and external files must keep their name as the associative key
3015 // so the same CSS file is not be added twice.
3016 $css[$data] = $options;
3017 }
3018 }
3019
3020 return $css;
3021 }
3022
3052 function drupal_get_css($css = NULL, $skip_alter = FALSE) {
3053 if (!isset($css)) {
3054 $css = drupal_add_css();
3055 }
3056
3057 // Allow modules and themes to alter the CSS items.
3058 if (!$skip_alter) {
3059 drupal_alter('css', $css);
3060 }
3061
3062 // Sort CSS items, so that they appear in the correct order.
3063 uasort($css, 'drupal_sort_css_js');
3064
3065 // Provide the page with information about the individual CSS files used,
3066 // information not otherwise available when CSS aggregation is enabled. The
3067 // setting is attached later in this function, but is set here, so that CSS
3068 // files removed below are still considered "used" and prevented from being
3069 // added in a later AJAX request.
3070 // Skip if no files were added to the page or jQuery.extend() will overwrite
3071 // the Drupal.settings.ajaxPageState.css object with an empty array.
3072 if (!empty($css)) {
3073 // Cast the array to an object to be on the safe side even if not empty.
3074 $setting['ajaxPageState']['css'] = (object) array_fill_keys(array_keys($css), 1);
3075 }
3076
3077 // Remove the overridden CSS files. Later CSS files override former ones.
3078 $previous_item = array();
3079 foreach ($css as $key => $item) {
3080 if ($item['type'] == 'file') {
3081 // If defined, force a unique basename for this file.
3082 $basename = isset($item['basename']) ? $item['basename'] : drupal_basename($item['data']);
3083 if (isset($previous_item[$basename])) {
3084 // Remove the previous item that shared the same base name.
3085 unset($css[$previous_item[$basename]]);
3086 }
3087 $previous_item[$basename] = $key;
3088 }
3089 }
3090
3091 // Render the HTML needed to load the CSS.
3092 $styles = array(
3093 '#type' => 'styles',
3094 '#items' => $css,
3095 );
3096
3097 if (!empty($setting)) {
3098 $styles['#attached']['js'][] = array('type' => 'setting', 'data' => $setting);
3099 }
3100
3101 return drupal_render($styles);
3102 }
3103
3124 function drupal_sort_css_js($a, $b) {
3125 // First order by group, so that, for example, all items in the CSS_SYSTEM
3126 // group appear before items in the CSS_DEFAULT group, which appear before
3127 // all items in the CSS_THEME group. Modules may create additional groups by
3128 // defining their own constants.
3129 if ($a['group'] < $b['group']) {
3130 return -1;
3131 }
3132 elseif ($a['group'] > $b['group']) {
3133 return 1;
3134 }
3135 // Within a group, order all infrequently needed, page-specific files after
3136 // common files needed throughout the website. Separating this way allows for
3137 // the aggregate file generated for all of the common files to be reused
3138 // across a site visit without being cut by a page using a less common file.
3139 elseif ($a['every_page'] && !$b['every_page']) {
3140 return -1;
3141 }
3142 elseif (!$a['every_page'] && $b['every_page']) {
3143 return 1;
3144 }
3145 // Finally, order by weight.
3146 elseif ($a['weight'] < $b['weight']) {
3147 return -1;
3148 }
3149 elseif ($a['weight'] > $b['weight']) {
3150 return 1;
3151 }
3152 else {
3153 return 0;
3154 }
3155 }
3156
3191 function drupal_group_css($css) {
3192 $groups = array();
3193 // If a group can contain multiple items, we track the information that must
3194 // be the same for each item in the group, so that when we iterate the next
3195 // item, we can determine if it can be put into the current group, or if a
3196 // new group needs to be made for it.
3197 $current_group_keys = NULL;
3198 // When creating a new group, we pre-increment $i, so by initializing it to
3199 // -1, the first group will have index 0.
3200 $i = -1;
3201 foreach ($css as $item) {
3202 // The browsers for which the CSS item needs to be loaded is part of the
3203 // information that determines when a new group is needed, but the order of
3204 // keys in the array doesn't matter, and we don't want a new group if all
3205 // that's different is that order.
3206 ksort($item['browsers']);
3207
3208 // If the item can be grouped with other items, set $group_keys to an array
3209 // of information that must be the same for all items in its group. If the
3210 // item can't be grouped with other items, set $group_keys to FALSE. We
3211 // put items into a group that can be aggregated together: whether they will
3212 // be aggregated is up to the _drupal_css_aggregate() function or an
3213 // override of that function specified in hook_css_alter(), but regardless
3214 // of the details of that function, a group represents items that can be
3215 // aggregated. Since a group may be rendered with a single HTML tag, all
3216 // items in the group must share the same information that would need to be
3217 // part of that HTML tag.
3218 switch ($item['type']) {
3219 case 'file':
3220 // Group file items if their 'preprocess' flag is TRUE.
3221 // Help ensure maximum reuse of aggregate files by only grouping
3222 // together items that share the same 'group' value and 'every_page'
3223 // flag. See drupal_add_css() for details about that.
3224 $group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['every_page'], $item['media'], $item['browsers']) : FALSE;
3225 break;
3226 case 'inline':
3227 // Always group inline items.
3228 $group_keys = array($item['type'], $item['media'], $item['browsers']);
3229 break;
3230 case 'external':
3231 // Do not group external items.
3232 $group_keys = FALSE;
3233 break;
3234 }
3235
3236 // If the group keys don't match the most recent group we're working with,
3237 // then a new group must be made.
3238 if ($group_keys !== $current_group_keys) {
3239 $i++;
3240 // Initialize the new group with the same properties as the first item
3241 // being placed into it. The item's 'data' and 'weight' properties are
3242 // unique to the item and should not be carried over to the group.
3243 $groups[$i] = $item;
3244 unset($groups[$i]['data'], $groups[$i]['weight']);
3245 $groups[$i]['items'] = array();
3246 $current_group_keys = $group_keys ? $group_keys : NULL;
3247 }
3248
3249 // Add the item to the current group.
3250 $groups[$i]['items'][] = $item;
3251 }
3252 return $groups;
3253 }
3254
3274 function drupal_aggregate_css(&$css_groups) {
3275 $preprocess_css = (variable_get('preprocess_css', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update'));
3276
3277 // For each group that needs aggregation, aggregate its items.
3278 foreach ($css_groups as $key => $group) {
3279 switch ($group['type']) {
3280 // If a file group can be aggregated into a single file, do so, and set
3281 // the group's data property to the file path of the aggregate file.
3282 case 'file':
3283 if ($group['preprocess'] && $preprocess_css) {
3284 $css_groups[$key]['data'] = drupal_build_css_cache($group['items']);
3285 }
3286 break;
3287 // Aggregate all inline CSS content into the group's data property.
3288 case 'inline':
3289 $css_groups[$key]['data'] = '';
3290 foreach ($group['items'] as $item) {
3291 $css_groups[$key]['data'] .= drupal_load_stylesheet_content($item['data'], $item['preprocess']);
3292 }
3293 break;
3294 }
3295 }
3296 }
3297
3359 function drupal_pre_render_styles($elements) {
3360 // Group and aggregate the items.
3361 if (isset($elements['#group_callback'])) {
3362 $elements['#groups'] = $elements['#group_callback']($elements['#items']);
3363 }
3364 if (isset($elements['#aggregate_callback'])) {
3365 $elements['#aggregate_callback']($elements['#groups']);
3366 }
3367
3368 // A dummy query-string is added to filenames, to gain control over
3369 // browser-caching. The string changes on every update or full cache
3370 // flush, forcing browsers to load a new copy of the files, as the
3371 // URL changed.
3372 $query_string = variable_get('css_js_query_string', '0');
3373
3374 // For inline CSS to validate as XHTML, all CSS containing XHTML needs to be
3375 // wrapped in CDATA. To make that backwards compatible with HTML 4, we need to
3376 // comment out the CDATA-tag.
3377 $embed_prefix = "\n<!--/*--><![CDATA[/*><!--*/\n";
3378 $embed_suffix = "\n/*]]>*/-->\n";
3379
3380 // Defaults for LINK and STYLE elements.
3381 $link_element_defaults = array(
3382 '#type' => 'html_tag',
3383 '#tag' => 'link',
3384 '#attributes' => array(
3385 'type' => 'text/css',
3386 'rel' => 'stylesheet',
3387 ),
3388 );
3389 $style_element_defaults = array(
3390 '#type' => 'html_tag',
3391 '#tag' => 'style',
3392 '#attributes' => array(
3393 'type' => 'text/css',
3394 ),
3395 );
3396
3397 // Loop through each group.
3398 foreach ($elements['#groups'] as $group) {
3399 switch ($group['type']) {
3400 // For file items, there are three possibilites.
3401 // - The group has been aggregated: in this case, output a LINK tag for
3402 // the aggregate file.
3403 // - The group can be aggregated but has not been (most likely because
3404 // the site administrator disabled the site-wide setting): in this case,
3405 // output as few STYLE tags for the group as possible, using @import
3406 // statement for each file in the group. This enables us to stay within
3407 // IE's limit of 31 total CSS inclusion tags.
3408 // - The group contains items not eligible for aggregation (their
3409 // 'preprocess' flag has been set to FALSE): in this case, output a LINK
3410 // tag for each file.
3411 case 'file':
3412 // The group has been aggregated into a single file: output a LINK tag
3413 // for the aggregate file.
3414 if (isset($group['data'])) {
3415 $element = $link_element_defaults;
3416 $element['#attributes']['href'] = file_create_url($group['data']);
3417 $element['#attributes']['media'] = $group['media'];
3418 $element['#browsers'] = $group['browsers'];
3419 $elements[] = $element;
3420 }
3421 // The group can be aggregated, but hasn't been: combine multiple items
3422 // into as few STYLE tags as possible.
3423 elseif ($group['preprocess']) {
3424 $import = array();
3425 foreach ($group['items'] as $item) {
3426 // A theme's .info file may have an entry for a file that doesn't
3427 // exist as a way of overriding a module or base theme CSS file from
3428 // being added to the page. Normally, file_exists() calls that need
3429 // to run for every page request should be minimized, but this one
3430 // is okay, because it only runs when CSS aggregation is disabled.
3431 // On a server under heavy enough load that file_exists() calls need
3432 // to be minimized, CSS aggregation should be enabled, in which case
3433 // this code is not run. When aggregation is enabled,
3434 // drupal_load_stylesheet() checks file_exists(), but only when
3435 // building the aggregate file, which is then reused for many page
3436 // requests.
3437 if (file_exists($item['data'])) {
3438 // The dummy query string needs to be added to the URL to control
3439 // browser-caching. IE7 does not support a media type on the
3440 // @import statement, so we instead specify the media for the
3441 // group on the STYLE tag.
3442 $import[] = '@import url("' . check_plain(file_create_url($item['data']) . '?' . $query_string) . '");';
3443 }
3444 }
3445 // In addition to IE's limit of 31 total CSS inclusion tags, it also
3446 // has a limit of 31 @import statements per STYLE tag.
3447 while (!empty($import)) {
3448 $import_batch = array_slice($import, 0, 31);
3449 $import = array_slice($import, 31);
3450 $element = $style_element_defaults;
3451 $element['#value'] = implode("\n", $import_batch);
3452 $element['#attributes']['media'] = $group['media'];
3453 $element['#browsers'] = $group['browsers'];
3454 $elements[] = $element;
3455 }
3456 }
3457 // The group contains items ineligible for aggregation: output a LINK
3458 // tag for each file.
3459 else {
3460 foreach ($group['items'] as $item) {
3461 $element = $link_element_defaults;
3462 // We do not check file_exists() here, because this code runs for
3463 // files whose 'preprocess' is set to FALSE, and therefore, even
3464 // when aggregation is enabled, and we want to avoid needlessly
3465 // taxing a server that may be under heavy load. The file_exists()
3466 // performed above for files whose 'preprocess' is TRUE is done for
3467 // the benefit of theme .info files, but code that deals with files
3468 // whose 'preprocess' is FALSE is responsible for ensuring the file
3469 // exists.
3470 // The dummy query string needs to be added to the URL to control
3471 // browser-caching.
3472 $query_string_separator = (strpos($item['data'], '?') !== FALSE) ? '&' : '?';
3473 $element['#attributes']['href'] = file_create_url($item['data']) . $query_string_separator . $query_string;
3474 $element['#attributes']['media'] = $item['media'];
3475 $element['#browsers'] = $group['browsers'];
3476 $elements[] = $element;
3477 }
3478 }
3479 break;
3480 // For inline content, the 'data' property contains the CSS content. If
3481 // the group's 'data' property is set, then output it in a single STYLE
3482 // tag. Otherwise, output a separate STYLE tag for each item.
3483 case 'inline':
3484 if (isset($group['data'])) {
3485 $element = $style_element_defaults;
3486 $element['#value'] = $group['data'];
3487 $element['#value_prefix'] = $embed_prefix;
3488 $element['#value_suffix'] = $embed_suffix;
3489 $element['#attributes']['media'] = $group['media'];
3490 $element['#browsers'] = $group['browsers'];
3491 $elements[] = $element;
3492 }
3493 else {
3494 foreach ($group['items'] as $item) {
3495 $element = $style_element_defaults;
3496 $element['#value'] = $item['data'];
3497 $element['#value_prefix'] = $embed_prefix;
3498 $element['#value_suffix'] = $embed_suffix;
3499 $element['#attributes']['media'] = $item['media'];
3500 $element['#browsers'] = $group['browsers'];
3501 $elements[] = $element;
3502 }
3503 }
3504 break;
3505 // Output a LINK tag for each external item. The item's 'data' property
3506 // contains the full URL.
3507 case 'external':
3508 foreach ($group['items'] as $item) {
3509 $element = $link_element_defaults;
3510 $element['#attributes']['href'] = $item['data'];
3511 $element['#attributes']['media'] = $item['media'];
3512 $element['#browsers'] = $group['browsers'];
3513 $elements[] = $element;
3514 }
3515 break;
3516 }
3517 }
3518
3519 return $elements;
3520 }
3521
3546 function drupal_build_css_cache($css) {
3547 $data = '';
3548 $uri = '';
3549 $map = variable_get('drupal_css_cache_files', array());
3550 // Create a new array so that only the file names are used to create the hash.
3551 // This prevents new aggregates from being created unnecessarily.
3552 $css_data = array();
3553 foreach ($css as $css_file) {
3554 $css_data[] = $css_file['data'];
3555 }
3556 $key = hash('sha256', serialize($css_data));
3557 if (isset($map[$key])) {
3558 $uri = $map[$key];
3559 }
3560
3561 if (empty($uri) || !file_exists($uri)) {
3562 // Build aggregate CSS file.
3563 foreach ($css as $stylesheet) {
3564 // Only 'file' stylesheets can be aggregated.
3565 if ($stylesheet['type'] == 'file') {
3566 $contents = drupal_load_stylesheet($stylesheet['data'], TRUE);
3567
3568 // Build the base URL of this CSS file: start with the full URL.
3569 $css_base_url = file_create_url($stylesheet['data']);
3570 // Move to the parent.
3571 $css_base_url = substr($css_base_url, 0, strrpos($css_base_url, '/'));
3572 // Simplify to a relative URL if the stylesheet URL starts with the
3573 // base URL of the website.
3574 if (substr($css_base_url, 0, strlen($GLOBALS['base_root'])) == $GLOBALS['base_root']) {
3575 $css_base_url = substr($css_base_url, strlen($GLOBALS['base_root']));
3576 }
3577
3578 _drupal_build_css_path(NULL, $css_base_url . '/');
3579 // Anchor all paths in the CSS with its base URL, ignoring external and absolute paths.
3580 $data .= preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', '_drupal_build_css_path', $contents);
3581 }
3582 }
3583
3584 // Per the W3C specification at http://www.w3.org/TR/REC-CSS2/cascade.html#at-import,
3585 // @import rules must proceed any other style, so we move those to the top.
3586 $regexp = '/@import[^;]+;/i';
3587 preg_match_all($regexp, $data, $matches);
3588 $data = preg_replace($regexp, '', $data);
3589 $data = implode('', $matches[0]) . $data;
3590
3591 // Prefix filename to prevent blocking by firewalls which reject files
3592 // starting with "ad*".
3593 $filename = 'css_' . drupal_hash_base64($data) . '.css';
3594 // Create the css/ within the files folder.
3595 $csspath = 'public://css';
3596 $uri = $csspath . '/' . $filename;
3597 // Create the CSS file.
3598 file_prepare_directory($csspath, FILE_CREATE_DIRECTORY);
3599 if (!file_exists($uri) && !file_unmanaged_save_data($data, $uri, FILE_EXISTS_REPLACE)) {
3600 return FALSE;
3601 }
3602 // If CSS gzip compression is enabled, clean URLs are enabled (which means
3603 // that rewrite rules are working) and the zlib extension is available then
3604 // create a gzipped version of this file. This file is served conditionally
3605 // to browsers that accept gzip using .htaccess rules.
3606 if (variable_get('css_gzip_compression', TRUE) && variable_get('clean_url', 0) && extension_loaded('zlib')) {
3607 if (!file_exists($uri . '.gz') && !file_unmanaged_save_data(gzencode($data, 9, FORCE_GZIP), $uri . '.gz', FILE_EXISTS_REPLACE)) {
3608 return FALSE;
3609 }
3610 }
3611 // Save the updated map.
3612 $map[$key] = $uri;
3613 variable_set('drupal_css_cache_files', $map);
3614 }
3615 return $uri;
3616 }
3617
3621 function _drupal_build_css_path($matches, $base = NULL) {
3622 $_base = &drupal_static(__FUNCTION__);
3623 // Store base path for preg_replace_callback.
3624 if (isset($base)) {
3625 $_base = $base;
3626 }
3627
3628 // Prefix with base and remove '../' segments where possible.
3629 $path = $_base . $matches[1];
3630 $last = '';
3631 while ($path != $last) {
3632 $last = $path;
3633 $path = preg_replace('`(^|/)(?!\.\./)([^/]+)/\.\./`', '$1', $path);
3634 }
3635 return 'url(' . $path . ')';
3636 }
3637
3659 function drupal_load_stylesheet($file, $optimize = NULL, $reset_basepath = TRUE) {
3660 // These statics are not cache variables, so we don't use drupal_static().
3661 static $_optimize, $basepath;
3662 if ($reset_basepath) {
3663 $basepath = '';
3664 }
3665 // Store the value of $optimize for preg_replace_callback with nested
3666 // @import loops.
3667 if (isset($optimize)) {
3668 $_optimize = $optimize;
3669 }
3670
3671 // Stylesheets are relative one to each other. Start by adding a base path
3672 // prefix provided by the parent stylesheet (if necessary).
3673 if ($basepath && !file_uri_scheme($file)) {
3674 $file = $basepath . '/' . $file;
3675 }
3676 // Store the parent base path to restore it later.
3677 $parent_base_path = $basepath;
3678 // Set the current base path to process possible child imports.
3679 $basepath = dirname($file);
3680
3681 // Load the CSS stylesheet. We suppress errors because themes may specify
3682 // stylesheets in their .info file that don't exist in the theme's path,
3683 // but are merely there to disable certain module CSS files.
3684 $content = '';
3685 if ($contents = @file_get_contents($file)) {
3686 // Return the processed stylesheet.
3687 $content = drupal_load_stylesheet_content($contents, $_optimize);
3688 }
3689
3690 // Restore the parent base path as the file and its childen are processed.
3691 $basepath = $parent_base_path;
3692 return $content;
3693 }
3694
3707 function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
3708 // Remove multiple charset declarations for standards compliance (and fixing Safari problems).
3709 $contents = preg_replace('/^@charset\s+[\'"](\S*?)\b[\'"];/i', '', $contents);
3710
3711 if ($optimize) {
3712 // Perform some safe CSS optimizations.
3713 // Regexp to match comment blocks.
3714 $comment = '/\*[^*]*\*+(?:[^/*][^*]*\*+)*/';
3715 // Regexp to match double quoted strings.
3716 $double_quot = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"';
3717 // Regexp to match single quoted strings.
3718 $single_quot = "'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'";
3719 // Strip all comment blocks, but keep double/single quoted strings.
3720 $contents = preg_replace(
3721 "<($double_quot|$single_quot)|$comment>Ss",
3722 "$1",
3723 $contents
3724 );
3725 // Remove certain whitespace.
3726 // There are different conditions for removing leading and trailing
3727 // whitespace.
3728 // @see http://php.net/manual/regexp.reference.subpatterns.php
3729 $contents = preg_replace('<
3730 # Strip leading and trailing whitespace.
3731 \s*([@{};,])\s*
3732 # Strip only leading whitespace from:
3733 # - Closing parenthesis: Retain "@media (bar) and foo".
3734 | \s+([\)])
3735 # Strip only trailing whitespace from:
3736 # - Opening parenthesis: Retain "@media (bar) and foo".
3737 # - Colon: Retain :pseudo-selectors.
3738 | ([\(:])\s+
3739 >xS',
3740 // Only one of the three capturing groups will match, so its reference
3741 // will contain the wanted value and the references for the
3742 // two non-matching groups will be replaced with empty strings.
3743 '$1$2$3',
3744 $contents
3745 );
3746 // End the file with a new line.
3747 $contents = trim($contents);
3748 $contents .= "\n";
3749 }
3750
3751 // Replaces @import commands with the actual stylesheet content.
3752 // This happens recursively but omits external files.
3753 $contents = preg_replace_callback('/@import\s*(?:url\(\s*)?[\'"]?(?![a-z]+:)([^\'"\()]+)[\'"]?\s*\)?\s*;/', '_drupal_load_stylesheet', $contents);
3754 return $contents;
3755 }
3756
3763 function _drupal_load_stylesheet($matches) {
3764 $filename = $matches[1];
3765 // Load the imported stylesheet and replace @import commands in there as well.
3766 $file = drupal_load_stylesheet($filename, NULL, FALSE);
3767
3768 // Determine the file's directory.
3769 $directory = dirname($filename);
3770 // If the file is in the current directory, make sure '.' doesn't appear in
3771 // the url() path.
3772 $directory = $directory == '.' ? '' : $directory .'/';
3773
3774 // Alter all internal url() paths. Leave external paths alone. We don't need
3775 // to normalize absolute paths here (i.e. remove folder/... segments) because
3776 // that will be done later.
3777 return preg_replace('/url\(\s*([\'"]?)(?![a-z]+:|\/+)/i', 'url(\1'. $directory, $file);
3778 }
3779
3783 function drupal_clear_css_cache() {
3784 variable_del('drupal_css_cache_files');
3785 file_scan_directory('public://css', '/.*/', array('callback' => 'drupal_delete_file_if_stale'));
3786 }
3787
3791 function drupal_delete_file_if_stale($uri) {
3792 // Default stale file threshold is 30 days.
3793 if (REQUEST_TIME - filemtime($uri) > variable_get('drupal_stale_file_threshold', 2592000)) {
3794 file_unmanaged_delete($uri);
3795 }
3796 }
3797
3812 function drupal_clean_css_identifier($identifier, $filter = array(' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => '')) {
3813 // By default, we filter using Drupal's coding standards.
3814 $identifier = strtr($identifier, $filter);
3815
3816 // Valid characters in a CSS identifier are:
3817 // - the hyphen (U+002D)
3818 // - a-z (U+0030 - U+0039)
3819 // - A-Z (U+0041 - U+005A)
3820 // - the underscore (U+005F)
3821 // - 0-9 (U+0061 - U+007A)
3822 // - ISO 10646 characters U+00A1 and higher
3823 // We strip out any character not in the above list.
3824 $identifier = preg_replace('/[^\x{002D}\x{0030}-\x{0039}\x{0041}-\x{005A}\x{005F}\x{0061}-\x{007A}\x{00A1}-\x{FFFF}]/u', '', $identifier);
3825
3826 return $identifier;
3827 }
3828
3841 function drupal_html_class($class) {
3842 // The output of this function will never change, so this uses a normal
3843 // static instead of drupal_static().
3844 static $classes = array();
3845
3846 if (!isset($classes[$class])) {
3847 $classes[$class] = drupal_clean_css_identifier(drupal_strtolower($class));
3848 }
3849 return $classes[$class];
3850 }
3851
3879 function drupal_html_id($id) {
3880 // If this is an Ajax request, then content returned by this page request will
3881 // be merged with content already on the base page. The HTML IDs must be
3882 // unique for the fully merged content. Therefore, initialize $seen_ids to
3883 // take into account IDs that are already in use on the base page.
3884 $seen_ids_init = &drupal_static(__FUNCTION__ . ':init');
3885 if (!isset($seen_ids_init)) {
3886 // Ideally, Drupal would provide an API to persist state information about
3887 // prior page requests in the database, and we'd be able to add this
3888 // function's $seen_ids static variable to that state information in order
3889 // to have it properly initialized for this page request. However, no such
3890 // page state API exists, so instead, ajax.js adds all of the in-use HTML
3891 // IDs to the POST data of Ajax submissions. Direct use of $_POST is
3892 // normally not recommended as it could open up security risks, but because
3893 // the raw POST data is cast to a number before being returned by this
3894 // function, this usage is safe.
3895 if (empty($_POST['ajax_html_ids'])) {
3896 $seen_ids_init = array();
3897 }
3898 else {
3899 // This function ensures uniqueness by appending a counter to the base id
3900 // requested by the calling function after the first occurrence of that
3901 // requested id. $_POST['ajax_html_ids'] contains the ids as they were
3902 // returned by this function, potentially with the appended counter, so
3903 // we parse that to reconstruct the $seen_ids array.
3904 if (isset($_POST['ajax_html_ids'][0]) && strpos($_POST['ajax_html_ids'][0], ',') === FALSE) {
3905 $ajax_html_ids = $_POST['ajax_html_ids'];
3906 }
3907 else {
3908 // jquery.form.js may send the server a comma-separated string as the
3909 // first element of an array (see http://drupal.org/node/1575060), so
3910 // we need to convert it to an array in that case.
3911 $ajax_html_ids = explode(',', $_POST['ajax_html_ids'][0]);
3912 }
3913 foreach ($ajax_html_ids as $seen_id) {
3914 // We rely on '--' being used solely for separating a base id from the
3915 // counter, which this function ensures when returning an id.
3916 $parts = explode('--', $seen_id, 2);
3917 if (!empty($parts[1]) && is_numeric($parts[1])) {
3918 list($seen_id, $i) = $parts;
3919 }
3920 else {
3921 $i = 1;
3922 }
3923 if (!isset($seen_ids_init[$seen_id]) || ($i > $seen_ids_init[$seen_id])) {
3924 $seen_ids_init[$seen_id] = $i;
3925 }
3926 }
3927 }
3928 }
3929 $seen_ids = &drupal_static(__FUNCTION__, $seen_ids_init);
3930
3931 $id = strtr(drupal_strtolower($id), array(' ' => '-', '_' => '-', '[' => '-', ']' => ''));
3932
3933 // As defined in http://www.w3.org/TR/html4/types.html#type-name, HTML IDs can
3934 // only contain letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
3935 // colons (":"), and periods ("."). We strip out any character not in that
3936 // list. Note that the CSS spec doesn't allow colons or periods in identifiers
3937 // (http://www.w3.org/TR/CSS21/syndata.html#characters), so we strip those two
3938 // characters as well.
3939 $id = preg_replace('/[^A-Za-z0-9\-_]/', '', $id);
3940
3941 // Removing multiple consecutive hyphens.
3942 $id = preg_replace('/\-+/', '-', $id);
3943 // Ensure IDs are unique by appending a counter after the first occurrence.
3944 // The counter needs to be appended with a delimiter that does not exist in
3945 // the base ID. Requiring a unique delimiter helps ensure that we really do
3946 // return unique IDs and also helps us re-create the $seen_ids array during
3947 // Ajax requests.
3948 if (isset($seen_ids[$id])) {
3949 $id = $id . '--' . ++$seen_ids[$id];
3950 }
3951 else {
3952 $seen_ids[$id] = 1;
3953 }
3954
3955 return $id;
3956 }
3957
3976 function drupal_region_class($region) {
3977 return drupal_html_class("region-$region");
3978 }
3979
4128 function drupal_add_js($data = NULL, $options = NULL) {
4129 $javascript = &drupal_static(__FUNCTION__, array());
4130
4131 // Construct the options, taking the defaults into consideration.
4132 if (isset($options)) {
4133 if (!is_array($options)) {
4134 $options = array('type' => $options);
4135 }
4136 }
4137 else {
4138 $options = array();
4139 }
4140 $options += drupal_js_defaults($data);
4141
4142 // Preprocess can only be set if caching is enabled.
4143 $options['preprocess'] = $options['cache'] ? $options['preprocess'] : FALSE;
4144
4145 // Tweak the weight so that files of the same weight are included in the
4146 // order of the calls to drupal_add_js().
4147 $options['weight'] += count($javascript) / 1000;
4148
4149 if (isset($data)) {
4150 // Add jquery.js and drupal.js, as well as the basePath setting, the
4151 // first time a JavaScript file is added.
4152 if (empty($javascript)) {
4153 // url() generates the prefix using hook_url_outbound_alter(). Instead of
4154 // running the hook_url_outbound_alter() again here, extract the prefix
4155 // from url().
4156 url('', array('prefix' => &$prefix));
4157 $javascript = array(
4158 'settings' => array(
4159 'data' => array(
4160 array('basePath' => base_path()),
4161 array('pathPrefix' => empty($prefix) ? '' : $prefix),
4162 ),
4163 'type' => 'setting',
4164 'scope' => 'header',
4165 'group' => JS_LIBRARY,
4166 'every_page' => TRUE,
4167 'weight' => 0,
4168 ),
4169 'misc/drupal.js' => array(
4170 'data' => 'misc/drupal.js',
4171 'type' => 'file',
4172 'scope' => 'header',
4173 'group' => JS_LIBRARY,
4174 'every_page' => TRUE,
4175 'weight' => -1,
4176 'preprocess' => TRUE,
4177 'cache' => TRUE,
4178 'defer' => FALSE,
4179 ),
4180 );
4181 // Register all required libraries.
4182 drupal_add_library('system', 'jquery', TRUE);
4183 drupal_add_library('system', 'jquery.once', TRUE);
4184 }
4185
4186 switch ($options['type']) {
4187 case 'setting':
4188 // All JavaScript settings are placed in the header of the page with
4189 // the library weight so that inline scripts appear afterwards.
4190 $javascript['settings']['data'][] = $data;
4191 break;
4192
4193 case 'inline':
4194 $javascript[] = $options;
4195 break;
4196
4197 default: // 'file' and 'external'
4198 // Local and external files must keep their name as the associative key
4199 // so the same JavaScript file is not added twice.
4200 $javascript[$options['data']] = $options;
4201 }
4202 }
4203 return $javascript;
4204 }
4205
4215 function drupal_js_defaults($data = NULL) {
4216 return array(
4217 'type' => 'file',
4218 'group' => JS_DEFAULT,
4219 'every_page' => FALSE,
4220 'weight' => 0,
4221 'scope' => 'header',
4222 'cache' => TRUE,
4223 'defer' => FALSE,
4224 'preprocess' => TRUE,
4225 'version' => NULL,
4226 'data' => $data,
4227 );
4228 }
4229
4263 function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALSE) {
4264 if (!isset($javascript)) {
4265 $javascript = drupal_add_js();
4266 }
4267 if (empty($javascript)) {
4268 return '';
4269 }
4270
4271 // Allow modules to alter the JavaScript.
4272 if (!$skip_alter) {
4273 drupal_alter('js', $javascript);
4274 }
4275
4276 // Filter out elements of the given scope.
4277 $items = array();
4278 foreach ($javascript as $key => $item) {
4279 if ($item['scope'] == $scope) {
4280 $items[$key] = $item;
4281 }
4282 }
4283
4284 $output = '';
4285 // The index counter is used to keep aggregated and non-aggregated files in
4286 // order by weight.
4287 $index = 1;
4288 $processed = array();
4289 $files = array();
4290 $preprocess_js = (variable_get('preprocess_js', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update'));
4291
4292 // A dummy query-string is added to filenames, to gain control over
4293 // browser-caching. The string changes on every update or full cache
4294 // flush, forcing browsers to load a new copy of the files, as the
4295 // URL changed. Files that should not be cached (see drupal_add_js())
4296 // get REQUEST_TIME as query-string instead, to enforce reload on every
4297 // page request.
4298 $default_query_string = variable_get('css_js_query_string', '0');
4299
4300 // For inline JavaScript to validate as XHTML, all JavaScript containing
4301 // XHTML needs to be wrapped in CDATA. To make that backwards compatible
4302 // with HTML 4, we need to comment out the CDATA-tag.
4303 $embed_prefix = "\n<!--//--><![CDATA[//><!--\n";
4304 $embed_suffix = "\n//--><!]]>\n";
4305
4306 // Since JavaScript may look for arguments in the URL and act on them, some
4307 // third-party code might require the use of a different query string.
4308 $js_version_string = variable_get('drupal_js_version_query_string', 'v=');
4309
4310 // Sort the JavaScript so that it appears in the correct order.
4311 uasort($items, 'drupal_sort_css_js');
4312
4313 // Provide the page with information about the individual JavaScript files
4314 // used, information not otherwise available when aggregation is enabled.
4315 $setting['ajaxPageState']['js'] = array_fill_keys(array_keys($items), 1);
4316 unset($setting['ajaxPageState']['js']['settings']);
4317 drupal_add_js($setting, 'setting');
4318
4319 // If we're outputting the header scope, then this might be the final time
4320 // that drupal_get_js() is running, so add the setting to this output as well
4321 // as to the drupal_add_js() cache. If $items['settings'] doesn't exist, it's
4322 // because drupal_get_js() was intentionally passed a $javascript argument
4323 // stripped off settings, potentially in order to override how settings get
4324 // output, so in this case, do not add the setting to this output.
4325 if ($scope == 'header' && isset($items['settings'])) {
4326 $items['settings']['data'][] = $setting;
4327 }
4328
4329 // Loop through the JavaScript to construct the rendered output.
4330 $element = array(
4331 '#tag' => 'script',
4332 '#value' => '',
4333 '#attributes' => array(
4334 'type' => 'text/javascript',
4335 ),
4336 );
4337 foreach ($items as $item) {
4338 $query_string = empty($item['version']) ? $default_query_string : $js_version_string . $item['version'];
4339
4340 switch ($item['type']) {
4341 case 'setting':
4342 $js_element = $element;
4343 $js_element['#value_prefix'] = $embed_prefix;
4344 $js_element['#value'] = 'jQuery.extend(Drupal.settings, ' . drupal_json_encode(drupal_array_merge_deep_array($item['data'])) . ");";
4345 $js_element['#value_suffix'] = $embed_suffix;
4346 $output .= theme('html_tag', array('element' => $js_element));
4347 break;
4348
4349 case 'inline':
4350 $js_element = $element;
4351 if ($item['defer']) {
4352 $js_element['#attributes']['defer'] = 'defer';
4353 }
4354 $js_element['#value_prefix'] = $embed_prefix;
4355 $js_element['#value'] = $item['data'];
4356 $js_element['#value_suffix'] = $embed_suffix;
4357 $processed[$index++] = theme('html_tag', array('element' => $js_element));
4358 break;
4359
4360 case 'file':
4361 $js_element = $element;
4362 if (!$item['preprocess'] || !$preprocess_js) {
4363 if ($item['defer']) {
4364 $js_element['#attributes']['defer'] = 'defer';
4365 }
4366 $query_string_separator = (strpos($item['data'], '?') !== FALSE) ? '&' : '?';
4367 $js_element['#attributes']['src'] = file_create_url($item['data']) . $query_string_separator . ($item['cache'] ? $query_string : REQUEST_TIME);
4368 $processed[$index++] = theme('html_tag', array('element' => $js_element));
4369 }
4370 else {
4371 // By increasing the index for each aggregated file, we maintain
4372 // the relative ordering of JS by weight. We also set the key such
4373 // that groups are split by items sharing the same 'group' value and
4374 // 'every_page' flag. While this potentially results in more aggregate
4375 // files, it helps make each one more reusable across a site visit,
4376 // leading to better front-end performance of a website as a whole.
4377 // See drupal_add_js() for details.
4378 $key = 'aggregate_' . $item['group'] . '_' . $item['every_page'] . '_' . $index;
4379 $processed[$key] = '';
4380 $files[$key][$item['data']] = $item;
4381 }
4382 break;
4383
4384 case 'external':
4385 $js_element = $element;
4386 // Preprocessing for external JavaScript files is ignored.
4387 if ($item['defer']) {
4388 $js_element['#attributes']['defer'] = 'defer';
4389 }
4390 $js_element['#attributes']['src'] = $item['data'];
4391 $processed[$index++] = theme('html_tag', array('element' => $js_element));
4392 break;
4393 }
4394 }
4395
4396 // Aggregate any remaining JS files that haven't already been output.
4397 if ($preprocess_js && count($files) > 0) {
4398 foreach ($files as $key => $file_set) {
4399 $uri = drupal_build_js_cache($file_set);
4400 // Only include the file if was written successfully. Errors are logged
4401 // using watchdog.
4402 if ($uri) {
4403 $preprocess_file = file_create_url($uri);
4404 $js_element = $element;
4405 $js_element['#attributes']['src'] = $preprocess_file;
4406 $processed[$key] = theme('html_tag', array('element' => $js_element));
4407 }
4408 }
4409 }
4410
4411 // Keep the order of JS files consistent as some are preprocessed and others are not.
4412 // Make sure any inline or JS setting variables appear last after libraries have loaded.
4413 return implode('', $processed) . $output;
4414 }
4415
4472 function drupal_process_attached($elements, $group = JS_DEFAULT, $dependency_check = FALSE, $every_page = NULL) {
4473 // Add defaults to the special attached structures that should be processed differently.
4474 $elements['#attached'] += array(
4475 'library' => array(),
4476 'js' => array(),
4477 'css' => array(),
4478 );
4479
4480 // Add the libraries first.
4481 $success = TRUE;
4482 foreach ($elements['#attached']['library'] as $library) {
4483 if (drupal_add_library($library[0], $library[1], $every_page) === FALSE) {
4484 $success = FALSE;
4485 // Exit if the dependency is missing.
4486 if ($dependency_check) {
4487 return $success;
4488 }
4489 }
4490 }
4491 unset($elements['#attached']['library']);
4492
4493 // Add both the JavaScript and the CSS.
4494 // The parameters for drupal_add_js() and drupal_add_css() require special
4495 // handling.
4496 foreach (array('js', 'css') as $type) {
4497 foreach ($elements['#attached'][$type] as $data => $options) {
4498 // If the value is not an array, it's a filename and passed as first
4499 // (and only) argument.
4500 if (!is_array($options)) {
4501 $data = $options;
4502 $options = NULL;
4503 }
4504 // In some cases, the first parameter ($data) is an array. Arrays can't be
4505 // passed as keys in PHP, so we have to get $data from the value array.
4506 if (is_numeric($data)) {
4507 $data = $options['data'];
4508 unset($options['data']);
4509 }
4510 // Apply the default group if it isn't explicitly given.
4511 if (!isset($options['group'])) {
4512 $options['group'] = $group;
4513 }
4514 // Set the every_page flag if one was passed.
4515 if (isset($every_page)) {
4516 $options['every_page'] = $every_page;
4517 }
4518 call_user_func('drupal_add_' . $type, $data, $options);
4519 }
4520 unset($elements['#attached'][$type]);
4521 }
4522
4523 // Add additional types of attachments specified in the render() structure.
4524 // Libraries, JavaScript and CSS have been added already, as they require
4525 // special handling.
4526 foreach ($elements['#attached'] as $callback => $options) {
4527 if (function_exists($callback)) {
4528 foreach ($elements['#attached'][$callback] as $args) {
4529 call_user_func_array($callback, $args);
4530 }
4531 }
4532 }
4533
4534 return $success;
4535 }
4536
4660 function drupal_process_states(&$elements) {
4661 $elements['#attached']['library'][] = array('system', 'drupal.states');
4662 $elements['#attached']['js'][] = array(
4663 'type' => 'setting',
4664 'data' => array('states' => array('#' . $elements['#id'] => $elements['#states'])),
4665 );
4666 }
4667
4694 function drupal_add_library($module, $name, $every_page = NULL) {
4695 $added = &drupal_static(__FUNCTION__, array());
4696
4697 // Only process the library if it exists and it was not added already.
4698 if (!isset($added[$module][$name])) {
4699 if ($library = drupal_get_library($module, $name)) {
4700 // Add all components within the library.
4701 $elements['#attached'] = array(
4702 'library' => $library['dependencies'],
4703 'js' => $library['js'],
4704 'css' => $library['css'],
4705 );
4706 $added[$module][$name] = drupal_process_attached($elements, JS_LIBRARY, TRUE, $every_page);
4707 }
4708 else {
4709 // Requested library does not exist.
4710 $added[$module][$name] = FALSE;
4711 }
4712 }
4713
4714 return $added[$module][$name];
4715 }
4716
4748 function drupal_get_library($module, $name = NULL) {
4749 $libraries = &drupal_static(__FUNCTION__, array());
4750
4751 if (!isset($libraries[$module])) {
4752 // Retrieve all libraries associated with the module.
4753 $module_libraries = module_invoke($module, 'library');
4754 if (empty($module_libraries)) {
4755 $module_libraries = array();
4756 }
4757 // Allow modules to alter the module's registered libraries.
4758 drupal_alter('library', $module_libraries, $module);
4759
4760 foreach ($module_libraries as $key => $data) {
4761 if (is_array($data)) {
4762 // Add default elements to allow for easier processing.
4763 $module_libraries[$key] += array('dependencies' => array(), 'js' => array(), 'css' => array());
4764 foreach ($module_libraries[$key]['js'] as $file => $options) {
4765 $module_libraries[$key]['js'][$file]['version'] = $module_libraries[$key]['version'];
4766 }
4767 }
4768 }
4769 $libraries[$module] = $module_libraries;
4770 }
4771 if (isset($name)) {
4772 if (!isset($libraries[$module][$name])) {
4773 $libraries[$module][$name] = FALSE;
4774 }
4775 return $libraries[$module][$name];
4776 }
4777 return $libraries[$module];
4778 }
4779
4887 function drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup = NULL, $source = NULL, $hidden = TRUE, $limit = 0) {
4888 $js_added = &drupal_static(__FUNCTION__, FALSE);
4889 if (!$js_added) {
4890 // Add the table drag JavaScript to the page before the module JavaScript
4891 // to ensure that table drag behaviors are registered before any module
4892 // uses it.
4893 drupal_add_library('system', 'jquery.cookie');
4894 drupal_add_js('misc/tabledrag.js', array('weight' => -1));
4895 $js_added = TRUE;
4896 }
4897
4898 // If a subgroup or source isn't set, assume it is the same as the group.
4899 $target = isset($subgroup) ? $subgroup : $group;
4900 $source = isset($source) ? $source : $target;
4901 $settings['tableDrag'][$table_id][$group][] = array(
4902 'target' => $target,
4903 'source' => $source,
4904 'relationship' => $relationship,
4905 'action' => $action,
4906 'hidden' => $hidden,
4907 'limit' => $limit,
4908 );
4909 drupal_add_js($settings, 'setting');
4910 }
4911
4936 function drupal_build_js_cache($files) {
4937 $contents = '';
4938 $uri = '';
4939 $map = variable_get('drupal_js_cache_files', array());
4940 // Create a new array so that only the file names are used to create the hash.
4941 // This prevents new aggregates from being created unnecessarily.
4942 $js_data = array();
4943 foreach ($files as $file) {
4944 $js_data[] = $file['data'];
4945 }
4946 $key = hash('sha256', serialize($js_data));
4947 if (isset($map[$key])) {
4948 $uri = $map[$key];
4949 }
4950
4951 if (empty($uri) || !file_exists($uri)) {
4952 // Build aggregate JS file.
4953 foreach ($files as $path => $info) {
4954 if ($info['preprocess']) {
4955 // Append a ';' and a newline after each JS file to prevent them from running together.
4956 $contents .= file_get_contents($path) . ";\n";
4957 }
4958 }
4959 // Prefix filename to prevent blocking by firewalls which reject files
4960 // starting with "ad*".
4961 $filename = 'js_' . drupal_hash_base64($contents) . '.js';
4962 // Create the js/ within the files folder.
4963 $jspath = 'public://js';
4964 $uri = $jspath . '/' . $filename;
4965 // Create the JS file.
4966 file_prepare_directory($jspath, FILE_CREATE_DIRECTORY);
4967 if (!file_exists($uri) && !file_unmanaged_save_data($contents, $uri, FILE_EXISTS_REPLACE)) {
4968 return FALSE;
4969 }
4970 // If JS gzip compression is enabled, clean URLs are enabled (which means
4971 // that rewrite rules are working) and the zlib extension is available then
4972 // create a gzipped version of this file. This file is served conditionally
4973 // to browsers that accept gzip using .htaccess rules.
4974 if (variable_get('js_gzip_compression', TRUE) && variable_get('clean_url', 0) && extension_loaded('zlib')) {
4975 if (!file_exists($uri . '.gz') && !file_unmanaged_save_data(gzencode($contents, 9, FORCE_GZIP), $uri . '.gz', FILE_EXISTS_REPLACE)) {
4976 return FALSE;
4977 }
4978 }
4979 $map[$key] = $uri;
4980 variable_set('drupal_js_cache_files', $map);
4981 }
4982 return $uri;
4983 }
4984
4988 function drupal_clear_js_cache() {
4989 variable_del('javascript_parsed');
4990 variable_del('drupal_js_cache_files');
4991 file_scan_directory('public://js', '/.*/', array('callback' => 'drupal_delete_file_if_stale'));
4992 }
4993
5003 function drupal_json_encode($var) {
5004 // The PHP version cannot change within a request.
5005 static $php530;
5006
5007 if (!isset($php530)) {
5008 $php530 = version_compare(PHP_VERSION, '5.3.0', '>=');
5009 }
5010
5011 if ($php530) {
5012 // Encode <, >, ', &, and " using the json_encode() options parameter.
5013 return json_encode($var, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
5014 }
5015
5016 // json_encode() escapes <, >, ', &, and " using its options parameter, but
5017 // does not support this parameter prior to PHP 5.3.0. Use a helper instead.
5018 include_once DRUPAL_ROOT . '/includes/json-encode.inc';
5019 return drupal_json_encode_helper($var);
5020 }
5021
5028 function drupal_json_decode($var) {
5029 return json_decode($var, TRUE);
5030 }
5031
5041 function drupal_json_output($var = NULL) {
5042 // We are returning JSON, so tell the browser.
5043 drupal_add_http_header('Content-Type', 'application/json');
5044
5045 if (isset($var)) {
5046 echo drupal_json_encode($var);
5047 }
5048 }
5049
5056 function drupal_get_private_key() {
5057 if (!($key = variable_get('drupal_private_key', 0))) {
5058 $key = drupal_random_key();
5059 variable_set('drupal_private_key', $key);
5060 }
5061 return $key;
5062 }
5063
5077 function drupal_get_token($value = '') {
5078 return drupal_hmac_base64($value, session_id() . drupal_get_private_key() . drupal_get_hash_salt());
5079 }
5080
5095 function drupal_valid_token($token, $value = '', $skip_anonymous = FALSE) {
5096 global $user;
5097 return (($skip_anonymous && $user->uid == 0) || ($token === drupal_get_token($value)));
5098 }
5099
5100 function _drupal_bootstrap_full() {
5101 static $called = FALSE;
5102
5103 if ($called) {
5104 return;
5105 }
5106 $called = TRUE;
5107 require_once DRUPAL_ROOT . '/' . variable_get('path_inc', 'includes/path.inc');
5108 require_once DRUPAL_ROOT . '/includes/theme.inc';
5109 require_once DRUPAL_ROOT . '/includes/pager.inc';
5110 require_once DRUPAL_ROOT . '/' . variable_get('menu_inc', 'includes/menu.inc');
5111 require_once DRUPAL_ROOT . '/includes/tablesort.inc';
5112 require_once DRUPAL_ROOT . '/includes/file.inc';
5113 require_once DRUPAL_ROOT . '/includes/unicode.inc';
5114 require_once DRUPAL_ROOT . '/includes/image.inc';
5115 require_once DRUPAL_ROOT . '/includes/form.inc';
5116 require_once DRUPAL_ROOT . '/includes/mail.inc';
5117 require_once DRUPAL_ROOT . '/includes/actions.inc';
5118 require_once DRUPAL_ROOT . '/includes/ajax.inc';
5119 require_once DRUPAL_ROOT . '/includes/token.inc';
5120 require_once DRUPAL_ROOT . '/includes/errors.inc';
5121
5122 // Detect string handling method
5123 unicode_check();
5124 // Undo magic quotes
5125 fix_gpc_magic();
5126 // Load all enabled modules
5127 module_load_all();
5128 // Make sure all stream wrappers are registered.
5129 file_get_stream_wrappers();
5130 // Ensure mt_rand is reseeded, to prevent random values from one page load
5131 // being exploited to predict random values in subsequent page loads.
5132 $seed = unpack("L", drupal_random_bytes(4));
5133 mt_srand($seed[1]);
5134
5135 $test_info = &$GLOBALS['drupal_test_info'];
5136 if (!empty($test_info['in_child_site'])) {
5137 // Running inside the simpletest child site, log fatal errors to test
5138 // specific file directory.
5139 ini_set('log_errors', 1);
5140 ini_set('error_log', 'public://error.log');
5141 }
5142
5143 // Initialize $_GET['q'] prior to invoking hook_init().
5144 drupal_path_initialize();
5145
5146 // Let all modules take action before the menu system handles the request.
5147 // We do not want this while running update.php.
5148 if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
5149 // Prior to invoking hook_init(), initialize the theme (potentially a custom
5150 // one for this page), so that:
5151 // - Modules with hook_init() implementations that call theme() or
5152 // theme_get_registry() don't initialize the incorrect theme.
5153 // - The theme can have hook_*_alter() implementations affect page building
5154 // (e.g., hook_form_alter(), hook_node_view_alter(), hook_page_alter()),
5155 // ahead of when rendering starts.
5156 menu_set_custom_theme();
5157 drupal_theme_initialize();
5158 module_invoke_all('init');
5159 }
5160 }
5161
5175 function drupal_page_set_cache() {
5176 global $base_root;
5177
5178 if (drupal_page_is_cacheable()) {
5179
5180 // Check whether the current page might be compressed.
5181 $page_compressed = variable_get('page_compression', TRUE) && extension_loaded('zlib');
5182
5183 $cache = (object) array(
5184 'cid' => $base_root . request_uri(),
5185 'data' => array(
5186 'path' => $_GET['q'],
5187 'body' => ob_get_clean(),
5188 'title' => drupal_get_title(),
5189 'headers' => array(),
5190 // We need to store whether page was compressed or not,
5191 // because by the time it is read, the configuration might change.
5192 'page_compressed' => $page_compressed,
5193 ),
5194 'expire' => CACHE_TEMPORARY,
5195 'created' => REQUEST_TIME,
5196 );
5197
5198 // Restore preferred header names based on the lower-case names returned
5199 // by drupal_get_http_header().
5200 $header_names = _drupal_set_preferred_header_name();
5201 foreach (drupal_get_http_header() as $name_lower => $value) {
5202 $cache->data['headers'][$header_names[$name_lower]] = $value;
5203 if ($name_lower == 'expires') {
5204 // Use the actual timestamp from an Expires header if available.
5205 $cache->expire = strtotime($value);
5206 }
5207 }
5208
5209 if ($cache->data['body']) {
5210 if ($page_compressed) {
5211 $cache->data['body'] = gzencode($cache->data['body'], 9, FORCE_GZIP);
5212 }
5213 cache_set($cache->cid, $cache->data, 'cache_page', $cache->expire);
5214 }
5215 return $cache;
5216 }
5217 }
5218
5227 function drupal_cron_run() {
5228 // Allow execution to continue even if the request gets canceled.
5229 @ignore_user_abort(TRUE);
5230
5231 // Prevent session information from being saved while cron is running.
5232 $original_session_saving = drupal_save_session();
5233 drupal_save_session(FALSE);
5234
5235 // Force the current user to anonymous to ensure consistent permissions on
5236 // cron runs.
5237 $original_user = $GLOBALS['user'];
5238 $GLOBALS['user'] = drupal_anonymous_user();
5239
5240 // Try to allocate enough time to run all the hook_cron implementations.
5241 drupal_set_time_limit(240);
5242
5243 $return = FALSE;
5244 // Grab the defined cron queues.
5245 $queues = module_invoke_all('cron_queue_info');
5246 drupal_alter('cron_queue_info', $queues);
5247
5248 // Try to acquire cron lock.
5249 if (!lock_acquire('cron', 240.0)) {
5250 // Cron is still running normally.
5251 watchdog('cron', 'Attempting to re-run cron while it is already running.', array(), WATCHDOG_WARNING);
5252 }
5253 else {
5254 // Make sure every queue exists. There is no harm in trying to recreate an
5255 // existing queue.
5256 foreach ($queues as $queue_name => $info) {
5257 DrupalQueue::get($queue_name)->createQueue();
5258 }
5259 // Register shutdown callback.
5260 drupal_register_shutdown_function('drupal_cron_cleanup');
5261
5262 // Iterate through the modules calling their cron handlers (if any):
5263 foreach (module_implements('cron') as $module) {
5264 // Do not let an exception thrown by one module disturb another.
5265 try {
5266 module_invoke($module, 'cron');
5267 }
5268 catch (Exception $e) {
5269 watchdog_exception('cron', $e);
5270 }
5271 }
5272
5273 // Record cron time.
5274 variable_set('cron_last', REQUEST_TIME);
5275 watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE);
5276
5277 // Release cron lock.
5278 lock_release('cron');
5279
5280 // Return TRUE so other functions can check if it did run successfully
5281 $return = TRUE;
5282 }
5283
5284 foreach ($queues as $queue_name => $info) {
5285 if (!empty($info['skip on cron'])) {
5286 // Do not run if queue wants to skip.
5287 continue;
5288 }
5289 $function = $info['worker callback'];
5290 $end = time() + (isset($info['time']) ? $info['time'] : 15);
5291 $queue = DrupalQueue::get($queue_name);
5292 while (time() < $end && ($item = $queue->claimItem())) {
5293 $function($item->data);
5294 $queue->deleteItem($item);
5295 }
5296 }
5297 // Restore the user.
5298 $GLOBALS['user'] = $original_user;
5299 drupal_save_session($original_session_saving);
5300
5301 return $return;
5302 }
5303
5310 function drupal_cron_cleanup() {
5311 // See if the semaphore is still locked.
5312 if (variable_get('cron_semaphore', FALSE)) {
5313 watchdog('cron', 'Cron run exceeded the time limit and was aborted.', array(), WATCHDOG_WARNING);
5314
5315 // Release cron semaphore.
5316 variable_del('cron_semaphore');
5317 }
5318 }
5319
5368 function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) {
5369 $config = conf_path();
5370
5371 $searchdir = array($directory);
5372 $files = array();
5373
5374 // The 'profiles' directory contains pristine collections of modules and
5375 // themes as organized by a distribution. It is pristine in the same way
5376 // that /modules is pristine for core; users should avoid changing anything
5377 // there in favor of sites/all or sites/<domain> directories.
5378 $profiles = array();
5379 $profile = drupal_get_profile();
5380 // For SimpleTest to be able to test modules packaged together with a
5381 // distribution we need to include the profile of the parent site (in which
5382 // test runs are triggered).
5383 if (drupal_valid_test_ua()) {
5384 $testing_profile = variable_get('simpletest_parent_profile', FALSE);
5385 if ($testing_profile && $testing_profile != $profile) {
5386 $profiles[] = $testing_profile;
5387 }
5388 }
5389 // In case both profile directories contain the same extension, the actual
5390 // profile always has precedence.
5391 $profiles[] = $profile;
5392 foreach ($profiles as $profile) {
5393 if (file_exists("profiles/$profile/$directory")) {
5394 $searchdir[] = "profiles/$profile/$directory";
5395 }
5396 }
5397
5398 // Always search sites/all/* as well as the global directories.
5399 $searchdir[] = 'sites/all/' . $directory;
5400
5401 if (file_exists("$config/$directory")) {
5402 $searchdir[] = "$config/$directory";
5403 }
5404
5405 // Get current list of items.
5406 if (!function_exists('file_scan_directory')) {
5407 require_once DRUPAL_ROOT . '/includes/file.inc';
5408 }
5409 foreach ($searchdir as $dir) {
5410 $files_to_add = file_scan_directory($dir, $mask, array('key' => $key, 'min_depth' => $min_depth));
5411
5412 // Duplicate files found in later search directories take precedence over
5413 // earlier ones, so we want them to overwrite keys in our resulting
5414 // $files array.
5415 // The exception to this is if the later file is from a module or theme not
5416 // compatible with Drupal core. This may occur during upgrades of Drupal
5417 // core when new modules exist in core while older contrib modules with the
5418 // same name exist in a directory such as sites/all/modules/.
5419 foreach (array_intersect_key($files_to_add, $files) as $file_key => $file) {
5420 // If it has no info file, then we just behave liberally and accept the
5421 // new resource on the list for merging.
5422 if (file_exists($info_file = dirname($file->uri) . '/' . $file->name . '.info')) {
5423 // Get the .info file for the module or theme this file belongs to.
5424 $info = drupal_parse_info_file($info_file);
5425
5426 // If the module or theme is incompatible with Drupal core, remove it
5427 // from the array for the current search directory, so it is not
5428 // overwritten when merged with the $files array.
5429 if (isset($info['core']) && $info['core'] != DRUPAL_CORE_COMPATIBILITY) {
5430 unset($files_to_add[$file_key]);
5431 }
5432 }
5433 }
5434 $files = array_merge($files, $files_to_add);
5435 }
5436
5437 return $files;
5438 }
5439
5454 function drupal_set_page_content($content = NULL) {
5455 $content_block = &drupal_static(__FUNCTION__, NULL);
5456 $main_content_display = &drupal_static('system_main_content_added', FALSE);
5457
5458 if (!empty($content)) {
5459 $content_block = (is_array($content) ? $content : array('main' => array('#markup' => $content)));
5460 }
5461 else {
5462 // Indicate that the main content has been requested. We assume that
5463 // the module requesting the content will be adding it to the page.
5464 // A module can indicate that it does not handle the content by setting
5465 // the static variable back to FALSE after calling this function.
5466 $main_content_display = TRUE;
5467 return $content_block;
5468 }
5469 }
5470
5500 function drupal_pre_render_conditional_comments($elements) {
5501 $browsers = isset($elements['#browsers']) ? $elements['#browsers'] : array();
5502 $browsers += array(
5503 'IE' => TRUE,
5504 '!IE' => TRUE,
5505 );
5506
5507 // If rendering in all browsers, no need for conditional comments.
5508 if ($browsers['IE'] === TRUE && $browsers['!IE']) {
5509 return $elements;
5510 }
5511
5512 // Determine the conditional comment expression for Internet Explorer to
5513 // evaluate.
5514 if ($browsers['IE'] === TRUE) {
5515 $expression = 'IE';
5516 }
5517 elseif ($browsers['IE'] === FALSE) {
5518 $expression = '!IE';
5519 }
5520 else {
5521 $expression = $browsers['IE'];
5522 }
5523
5524 // Wrap the element's potentially existing #prefix and #suffix properties with
5525 // conditional comment markup. The conditional comment expression is evaluated
5526 // by Internet Explorer only. To control the rendering by other browsers,
5527 // either the "downlevel-hidden" or "downlevel-revealed" technique must be
5528 // used. See http://en.wikipedia.org/wiki/Conditional_comment for details.
5529 $elements += array(
5530 '#prefix' => '',
5531 '#suffix' => '',
5532 );
5533 if (!$browsers['!IE']) {
5534 // "downlevel-hidden".
5535 $elements['#prefix'] = "\n<!--[if $expression]>\n" . $elements['#prefix'];
5536 $elements['#suffix'] .= "<![endif]-->\n";
5537 }
5538 else {
5539 // "downlevel-revealed".
5540 $elements['#prefix'] = "\n<!--[if $expression]><!-->\n" . $elements['#prefix'];
5541 $elements['#suffix'] .= "<!--<![endif]-->\n";
5542 }
5543
5544 return $elements;
5545 }
5546
5561 function drupal_pre_render_link($element) {
5562 // By default, link options to pass to l() are normally set in #options.
5563 $element += array('#options' => array());
5564 // However, within the scope of renderable elements, #attributes is a valid
5565 // way to specify attributes, too. Take them into account, but do not override
5566 // attributes from #options.
5567 if (isset($element['#attributes'])) {
5568 $element['#options'] += array('attributes' => array());
5569 $element['#options']['attributes'] += $element['#attributes'];
5570 }
5571
5572 // This #pre_render callback can be invoked from inside or outside of a Form
5573 // API context, and depending on that, a HTML ID may be already set in
5574 // different locations. #options should have precedence over Form API's #id.
5575 // #attributes have been taken over into #options above already.
5576 if (isset($element['#options']['attributes']['id'])) {
5577 $element['#id'] = $element['#options']['attributes']['id'];
5578 }
5579 elseif (isset($element['#id'])) {
5580 $element['#options']['attributes']['id'] = $element['#id'];
5581 }
5582
5583 // Conditionally invoke ajax_pre_render_element(), if #ajax is set.
5584 if (isset($element['#ajax']) && !isset($element['#ajax_processed'])) {
5585 // If no HTML ID was found above, automatically create one.
5586 if (!isset($element['#id'])) {
5587 $element['#id'] = $element['#options']['attributes']['id'] = drupal_html_id('ajax-link');
5588 }
5589 // If #ajax['path] was not specified, use the href as Ajax request URL.
5590 if (!isset($element['#ajax']['path'])) {
5591 $element['#ajax']['path'] = $element['#href'];
5592 $element['#ajax']['options'] = $element['#options'];
5593 }
5594 $element = ajax_pre_render_element($element);
5595 }
5596
5597 $element['#markup'] = l($element['#title'], $element['#href'], $element['#options']);
5598 return $element;
5599 }
5600
5676 function drupal_pre_render_links($element) {
5677 $element += array('#links' => array());
5678 foreach (element_children($element) as $key) {
5679 $child = &$element[$key];
5680 // If the child has links which have not been printed yet and the user has
5681 // access to it, merge its links in to the parent.
5682 if (isset($child['#links']) && empty($child['#printed']) && (!isset($child['#access']) || $child['#access'])) {
5683 $element['#links'] += $child['#links'];
5684 // Mark the child as having been printed already (so that its links
5685 // cannot be mistakenly rendered twice).
5686 $child['#printed'] = TRUE;
5687 }
5688 }
5689 return $element;
5690 }
5691
5708 function drupal_pre_render_markup($elements) {
5709 $elements['#children'] = $elements['#markup'];
5710 return $elements;
5711 }
5712
5727 function drupal_render_page($page) {
5728 $main_content_display = &drupal_static('system_main_content_added', FALSE);
5729
5730 // Allow menu callbacks to return strings or arbitrary arrays to render.
5731 // If the array returned is not of #type page directly, we need to fill
5732 // in the page with defaults.
5733 if (is_string($page) || (is_array($page) && (!isset($page['#type']) || ($page['#type'] != 'page')))) {
5734 drupal_set_page_content($page);
5735 $page = element_info('page');
5736 }
5737
5738 // Modules can add elements to $page as needed in hook_page_build().
5739 foreach (module_implements('page_build') as $module) {
5740 $function = $module . '_page_build';
5741 $function($page);
5742 }
5743 // Modules alter the $page as needed. Blocks are populated into regions like
5744 // 'sidebar_first', 'footer', etc.
5745 drupal_alter('page', $page);
5746
5747 // If no module has taken care of the main content, add it to the page now.
5748 // This allows the site to still be usable even if no modules that
5749 // control page regions (for example, the Block module) are enabled.
5750 if (!$main_content_display) {
5751 $page['content']['system_main'] = drupal_set_page_content();
5752 }
5753
5754 return drupal_render($page);
5755 }
5756
5834 function drupal_render(&$elements) {
5835 // Early-return nothing if user does not have access.
5836 if (empty($elements) || (isset($elements['#access']) && !$elements['#access'])) {
5837 return '';
5838 }
5839
5840 // Do not print elements twice.
5841 if (!empty($elements['#printed'])) {
5842 return '';
5843 }
5844
5845 // Try to fetch the element's markup from cache and return.
5846 if (isset($elements['#cache'])) {
5847 $cached_output = drupal_render_cache_get($elements);
5848 if ($cached_output !== FALSE) {
5849 return $cached_output;
5850 }
5851 }
5852
5853 // If #markup is set, ensure #type is set. This allows to specify just #markup
5854 // on an element without setting #type.
5855 if (isset($elements['#markup']) && !isset($elements['#type'])) {
5856 $elements['#type'] = 'markup';
5857 }
5858
5859 // If the default values for this element have not been loaded yet, populate
5860 // them.
5861 if (isset($elements['#type']) && empty($elements['#defaults_loaded'])) {
5862 $elements += element_info($elements['#type']);
5863 }
5864
5865 // Make any final changes to the element before it is rendered. This means
5866 // that the $element or the children can be altered or corrected before the
5867 // element is rendered into the final text.
5868 if (isset($elements['#pre_render'])) {
5869 foreach ($elements['#pre_render'] as $function) {
5870 if (function_exists($function)) {
5871 $elements = $function($elements);
5872 }
5873 }
5874 }
5875
5876 // Allow #pre_render to abort rendering.
5877 if (!empty($elements['#printed'])) {
5878 return '';
5879 }
5880
5881 // Get the children of the element, sorted by weight.
5882 $children = element_children($elements, TRUE);
5883
5884 // Initialize this element's #children, unless a #pre_render callback already
5885 // preset #children.
5886 if (!isset($elements['#children'])) {
5887 $elements['#children'] = '';
5888 }
5889 // Call the element's #theme function if it is set. Then any children of the
5890 // element have to be rendered there.
5891 if (isset($elements['#theme'])) {
5892 $elements['#children'] = theme($elements['#theme'], $elements);
5893 }
5894 // If #theme was not set and the element has children, render them now.
5895 // This is the same process as drupal_render_children() but is inlined
5896 // for speed.
5897 if ($elements['#children'] == '') {
5898 foreach ($children as $key) {
5899 $elements['#children'] .= drupal_render($elements[$key]);
5900 }
5901 }
5902
5903 // Let the theme functions in #theme_wrappers add markup around the rendered
5904 // children.
5905 if (isset($elements['#theme_wrappers'])) {
5906 foreach ($elements['#theme_wrappers'] as $theme_wrapper) {
5907 $elements['#children'] = theme($theme_wrapper, $elements);
5908 }
5909 }
5910
5911 // Filter the outputted content and make any last changes before the
5912 // content is sent to the browser. The changes are made on $content
5913 // which allows the output'ed text to be filtered.
5914 if (isset($elements['#post_render'])) {
5915 foreach ($elements['#post_render'] as $function) {
5916 if (function_exists($function)) {
5917 $elements['#children'] = $function($elements['#children'], $elements);
5918 }
5919 }
5920 }
5921
5922 // Add any JavaScript state information associated with the element.
5923 if (!empty($elements['#states'])) {
5924 drupal_process_states($elements);
5925 }
5926
5927 // Add additional libraries, CSS, JavaScript an other custom
5928 // attached data associated with this element.
5929 if (!empty($elements['#attached'])) {
5930 drupal_process_attached($elements);
5931 }
5932
5933 $prefix = isset($elements['#prefix']) ? $elements['#prefix'] : '';
5934 $suffix = isset($elements['#suffix']) ? $elements['#suffix'] : '';
5935 $output = $prefix . $elements['#children'] . $suffix;
5936
5937 // Cache the processed element if #cache is set.
5938 if (isset($elements['#cache'])) {
5939 drupal_render_cache_set($output, $elements);
5940 }
5941
5942 $elements['#printed'] = TRUE;
5943 return $output;
5944 }
5945
5958 function drupal_render_children(&$element, $children_keys = NULL) {
5959 if ($children_keys === NULL) {
5960 $children_keys = element_children($element);
5961 }
5962 $output = '';
5963 foreach ($children_keys as $key) {
5964 if (!empty($element[$key])) {
5965 $output .= drupal_render($element[$key]);
5966 }
5967 }
5968 return $output;
5969 }
5970
5988 function render(&$element) {
5989 if (is_array($element)) {
5990 show($element);
5991 return drupal_render($element);
5992 }
5993 else {
5994 // Safe-guard for inappropriate use of render() on flat variables: return
5995 // the variable as-is.
5996 return $element;
5997 }
5998 }
5999
6021 function hide(&$element) {
6022 $element['#printed'] = TRUE;
6023 return $element;
6024 }
6025
6050 function show(&$element) {
6051 $element['#printed'] = FALSE;
6052 return $element;
6053 }
6054
6068 function drupal_render_cache_get($elements) {
6069 if (!in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) || !$cid = drupal_render_cid_create($elements)) {
6070 return FALSE;
6071 }
6072 $bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache';
6073
6074 if (!empty($cid) && $cache = cache_get($cid, $bin)) {
6075 // Add additional libraries, JavaScript, CSS and other data attached
6076 // to this element.
6077 if (isset($cache->data['#attached'])) {
6078 drupal_process_attached($cache->data);
6079 }
6080 // Return the rendered output.
6081 return $cache->data['#markup'];
6082 }
6083 return FALSE;
6084 }
6085
6099 function drupal_render_cache_set(&$markup, $elements) {
6100 // Create the cache ID for the element.
6101 if (!in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) || !$cid = drupal_render_cid_create($elements)) {
6102 return FALSE;
6103 }
6104
6105 // Cache implementations are allowed to modify the markup, to support
6106 // replacing markup with edge-side include commands. The supporting cache
6107 // backend will store the markup in some other key (like
6108 // $data['#real-value']) and return an include command instead. When the
6109 // ESI command is executed by the content accelerator, the real value can
6110 // be retrieved and used.
6111 $data['#markup'] = &$markup;
6112 // Persist attached data associated with this element.
6113 $attached = drupal_render_collect_attached($elements, TRUE);
6114 if ($attached) {
6115 $data['#attached'] = $attached;
6116 }
6117 $bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache';
6118 $expire = isset($elements['#cache']['expire']) ? $elements['#cache']['expire'] : CACHE_PERMANENT;
6119 cache_set($cid, $data, $bin, $expire);
6120 }
6121
6138 function drupal_render_collect_attached($elements, $return = FALSE) {
6139 $attached = &drupal_static(__FUNCTION__, array());
6140
6141 // Collect all #attached for this element.
6142 if (isset($elements['#attached'])) {
6143 foreach ($elements['#attached'] as $key => $value) {
6144 if (!isset($attached[$key])) {
6145 $attached[$key] = array();
6146 }
6147 $attached[$key] = array_merge($attached[$key], $value);
6148 }
6149 }
6150 if ($children = element_children($elements)) {
6151 foreach ($children as $child) {
6152 drupal_render_collect_attached($elements[$child]);
6153 }
6154 }
6155
6156 // If this was the first call to the function, return all attached elements
6157 // and reset the static cache.
6158 if ($return) {
6159 $return = $attached;
6160 $attached = array();
6161 return $return;
6162 }
6163 }
6164
6192 function drupal_render_cache_by_query($query, $function, $expire = CACHE_TEMPORARY, $granularity = NULL) {
6193 $cache_keys = array_merge(array($function), drupal_render_cid_parts($granularity));
6194 $query->preExecute();
6195 $cache_keys[] = hash('sha256', serialize(array((string) $query, $query->getArguments())));
6196 return array(
6197 '#query' => $query,
6198 '#pre_render' => array($function . '_pre_render'),
6199 '#cache' => array(
6200 'keys' => $cache_keys,
6201 'expire' => $expire,
6202 ),
6203 );
6204 }
6205
6222 function drupal_render_cid_parts($granularity = NULL) {
6223 global $theme, $base_root, $user;
6224
6225 $cid_parts[] = $theme;
6226 // If Locale is enabled but we have only one language we do not need it as cid
6227 // part.
6228 if (drupal_multilingual()) {
6229 foreach (language_types_configurable() as $language_type) {
6230 $cid_parts[] = $GLOBALS[$language_type]->language;
6231 }
6232 }
6233
6234 if (!empty($granularity)) {
6235 // 'PER_ROLE' and 'PER_USER' are mutually exclusive. 'PER_USER' can be a
6236 // resource drag for sites with many users, so when a module is being
6237 // equivocal, we favor the less expensive 'PER_ROLE' pattern.
6238 if ($granularity & DRUPAL_CACHE_PER_ROLE) {
6239 $cid_parts[] = 'r.' . implode(',', array_keys($user->roles));
6240 }
6241 elseif ($granularity & DRUPAL_CACHE_PER_USER) {
6242 $cid_parts[] = "u.$user->uid";
6243 }
6244
6245 if ($granularity & DRUPAL_CACHE_PER_PAGE) {
6246 $cid_parts[] = $base_root . request_uri();
6247 }
6248 }
6249
6250 return $cid_parts;
6251 }
6252
6266 function drupal_render_cid_create($elements) {
6267 if (isset($elements['#cache']['cid'])) {
6268 return $elements['#cache']['cid'];
6269 }
6270 elseif (isset($elements['#cache']['keys'])) {
6271 $granularity = isset($elements['#cache']['granularity']) ? $elements['#cache']['granularity'] : NULL;
6272 // Merge in additional cache ID parts based provided by drupal_render_cid_parts().
6273 $cid_parts = array_merge($elements['#cache']['keys'], drupal_render_cid_parts($granularity));
6274 return implode(':', $cid_parts);
6275 }
6276 return FALSE;
6277 }
6278
6282 function element_sort($a, $b) {
6283 $a_weight = (is_array($a) && isset($a['#weight'])) ? $a['#weight'] : 0;
6284 $b_weight = (is_array($b) && isset($b['#weight'])) ? $b['#weight'] : 0;
6285 if ($a_weight == $b_weight) {
6286 return 0;
6287 }
6288 return ($a_weight < $b_weight) ? -1 : 1;
6289 }
6290
6294 function element_sort_by_title($a, $b) {
6295 $a_title = (is_array($a) && isset($a['#title'])) ? $a['#title'] : '';
6296 $b_title = (is_array($b) && isset($b['#title'])) ? $b['#title'] : '';
6297 return strnatcasecmp($a_title, $b_title);
6298 }
6299
6306 function element_info($type) {
6307 // Use the advanced drupal_static() pattern, since this is called very often.
6308 static $drupal_static_fast;
6309 if (!isset($drupal_static_fast)) {
6310 $drupal_static_fast['cache'] = &drupal_static(__FUNCTION__);
6311 }
6312 $cache = &$drupal_static_fast['cache'];
6313
6314 if (!isset($cache)) {
6315 $cache = module_invoke_all('element_info');
6316 foreach ($cache as $element_type => $info) {
6317 $cache[$element_type]['#type'] = $element_type;
6318 }
6319 // Allow modules to alter the element type defaults.
6320 drupal_alter('element_info', $cache);
6321 }
6322
6323 return isset($cache[$type]) ? $cache[$type] : array();
6324 }
6325
6337 function element_info_property($type, $property_name, $default = NULL) {
6338 return (($info = element_info($type)) && array_key_exists($property_name, $info)) ? $info[$property_name] : $default;
6339 }
6340
6356 function drupal_sort_weight($a, $b) {
6357 $a_weight = (is_array($a) && isset($a['weight'])) ? $a['weight'] : 0;
6358 $b_weight = (is_array($b) && isset($b['weight'])) ? $b['weight'] : 0;
6359 if ($a_weight == $b_weight) {
6360 return 0;
6361 }
6362 return ($a_weight < $b_weight) ? -1 : 1;
6363 }
6364
6368 function drupal_sort_title($a, $b) {
6369 if (!isset($b['title'])) {
6370 return -1;
6371 }
6372 if (!isset($a['title'])) {
6373 return 1;
6374 }
6375 return strcasecmp($a['title'], $b['title']);
6376 }
6377
6381 function element_property($key) {
6382 return $key[0] == '#';
6383 }
6384
6388 function element_properties($element) {
6389 return array_filter(array_keys((array) $element), 'element_property');
6390 }
6391
6395 function element_child($key) {
6396 return !isset($key[0]) || $key[0] != '#';
6397 }
6398
6413 function element_children(&$elements, $sort = FALSE) {
6414 // Do not attempt to sort elements which have already been sorted.
6415 $sort = isset($elements['#sorted']) ? !$elements['#sorted'] : $sort;
6416
6417 // Filter out properties from the element, leaving only children.
6418 $children = array();
6419 $sortable = FALSE;
6420 foreach ($elements as $key => $value) {
6421 if ($key === '' || $key[0] !== '#') {
6422 $children[$key] = $value;
6423 if (is_array($value) && isset($value['#weight'])) {
6424 $sortable = TRUE;
6425 }
6426 }
6427 }
6428 // Sort the children if necessary.
6429 if ($sort && $sortable) {
6430 uasort($children, 'element_sort');
6431 // Put the sorted children back into $elements in the correct order, to
6432 // preserve sorting if the same element is passed through
6433 // element_children() twice.
6434 foreach ($children as $key => $child) {
6435 unset($elements[$key]);
6436 $elements[$key] = $child;
6437 }
6438 $elements['#sorted'] = TRUE;
6439 }
6440
6441 return array_keys($children);
6442 }
6443
6453 function element_get_visible_children(array $elements) {
6454 $visible_children = array();
6455
6456 foreach (element_children($elements) as $key) {
6457 $child = $elements[$key];
6458
6459 // Skip un-accessible children.
6460 if (isset($child['#access']) && !$child['#access']) {
6461 continue;
6462 }
6463
6464 // Skip value and hidden elements, since they are not rendered.
6465 if (isset($child['#type']) && in_array($child['#type'], array('value', 'hidden'))) {
6466 continue;
6467 }
6468
6469 $visible_children[$key] = $child;
6470 }
6471
6472 return array_keys($visible_children);
6473 }
6474
6487 function element_set_attributes(array &$element, array $map) {
6488 foreach ($map as $property => $attribute) {
6489 // If the key is numeric, the attribute name needs to be taken over.
6490 if (is_int($property)) {
6491 $property = '#' . $attribute;
6492 }
6493 // Do not overwrite already existing attributes.
6494 if (isset($element[$property]) && !isset($element['#attributes'][$attribute])) {
6495 $element['#attributes'][$attribute] = $element[$property];
6496 }
6497 }
6498 }
6499
6515 function drupal_array_diff_assoc_recursive($array1, $array2) {
6516 $difference = array();
6517
6518 foreach ($array1 as $key => $value) {
6519 if (is_array($value)) {
6520 if (!array_key_exists($key, $array2) || !is_array($array2[$key])) {
6521 $difference[$key] = $value;
6522 }
6523 else {
6524 $new_diff = drupal_array_diff_assoc_recursive($value, $array2[$key]);
6525 if (!empty($new_diff)) {
6526 $difference[$key] = $new_diff;
6527 }
6528 }
6529 }
6530 elseif (!array_key_exists($key, $array2) || $array2[$key] !== $value) {
6531 $difference[$key] = $value;
6532 }
6533 }
6534
6535 return $difference;
6536 }
6537
6598 function drupal_array_set_nested_value(array &$array, array $parents, $value, $force = FALSE) {
6599 $ref = &$array;
6600 foreach ($parents as $parent) {
6601 // PHP auto-creates container arrays and NULL entries without error if $ref
6602 // is NULL, but throws an error if $ref is set, but not an array.
6603 if ($force && isset($ref) && !is_array($ref)) {
6604 $ref = array();
6605 }
6606 $ref = &$ref[$parent];
6607 }
6608 $ref = $value;
6609 }
6610
6666 function &drupal_array_get_nested_value(array &$array, array $parents, &$key_exists = NULL) {
6667 $ref = &$array;
6668 foreach ($parents as $parent) {
6669 if (is_array($ref) && array_key_exists($parent, $ref)) {
6670 $ref = &$ref[$parent];
6671 }
6672 else {
6673 $key_exists = FALSE;
6674 $null = NULL;
6675 return $null;
6676 }
6677 }
6678 $key_exists = TRUE;
6679 return $ref;
6680 }
6681
6710 function drupal_array_nested_key_exists(array $array, array $parents) {
6711 // Although this function is similar to PHP's array_key_exists(), its
6712 // arguments should be consistent with drupal_array_get_nested_value().
6713 $key_exists = NULL;
6714 drupal_array_get_nested_value($array, $parents, $key_exists);
6715 return $key_exists;
6716 }
6717
6721 function drupal_common_theme() {
6722 return array(
6723 // From theme.inc.
6724 'html' => array(
6725 'render element' => 'page',
6726 'template' => 'html',
6727 ),
6728 'page' => array(
6729 'render element' => 'page',
6730 'template' => 'page',
6731 ),
6732 'region' => array(
6733 'render element' => 'elements',
6734 'template' => 'region',
6735 ),
6736 'status_messages' => array(
6737 'variables' => array('display' => NULL),
6738 ),
6739 'link' => array(
6740 'variables' => array('text' => NULL, 'path' => NULL, 'options' => array()),
6741 ),
6742 'links' => array(
6743 'variables' => array('links' => NULL, 'attributes' => array('class' => array('links')), 'heading' => array()),
6744 ),
6745 'image' => array(
6746 // HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft
6747 // allows the alt attribute to be omitted in some cases. Therefore,
6748 // default the alt attribute to an empty string, but allow code calling
6749 // theme('image') to pass explicit NULL for it to be omitted. Usually,
6750 // neither omission nor an empty string satisfies accessibility
6751 // requirements, so it is strongly encouraged for code calling
6752 // theme('image') to pass a meaningful value for the alt variable.
6753 // - http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.8
6754 // - http://www.w3.org/TR/xhtml1/dtds.html
6755 // - http://dev.w3.org/html5/spec/Overview.html#alt
6756 // The title attribute is optional in all cases, so it is omitted by
6757 // default.
6758 'variables' => array('path' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => array()),
6759 ),
6760 'breadcrumb' => array(
6761 'variables' => array('breadcrumb' => NULL),
6762 ),
6763 'help' => array(
6764 'variables' => array(),
6765 ),
6766 'table' => array(
6767 'variables' => array('header' => NULL, 'rows' => NULL, 'attributes' => array(), 'caption' => NULL, 'colgroups' => array(), 'sticky' => TRUE, 'empty' => ''),
6768 ),
6769 'tablesort_indicator' => array(
6770 'variables' => array('style' => NULL),
6771 ),
6772 'mark' => array(
6773 'variables' => array('type' => MARK_NEW),
6774 ),
6775 'item_list' => array(
6776 'variables' => array('items' => array(), 'title' => NULL, 'type' => 'ul', 'attributes' => array()),
6777 ),
6778 'more_help_link' => array(
6779 'variables' => array('url' => NULL),
6780 ),
6781 'feed_icon' => array(
6782 'variables' => array('url' => NULL, 'title' => NULL),
6783 ),
6784 'more_link' => array(
6785 'variables' => array('url' => NULL, 'title' => NULL)
6786 ),
6787 'username' => array(
6788 'variables' => array('account' => NULL),
6789 ),
6790 'progress_bar' => array(
6791 'variables' => array('percent' => NULL, 'message' => NULL),
6792 ),
6793 'indentation' => array(
6794 'variables' => array('size' => 1),
6795 ),
6796 'html_tag' => array(
6797 'render element' => 'element',
6798 ),
6799 // From theme.maintenance.inc.
6800 'maintenance_page' => array(
6801 'variables' => array('content' => NULL, 'show_messages' => TRUE),
6802 'template' => 'maintenance-page',
6803 ),
6804 'update_page' => array(
6805 'variables' => array('content' => NULL, 'show_messages' => TRUE),
6806 ),
6807 'install_page' => array(
6808 'variables' => array('content' => NULL),
6809 ),
6810 'task_list' => array(
6811 'variables' => array('items' => NULL, 'active' => NULL),
6812 ),
6813 'authorize_message' => array(
6814 'variables' => array('message' => NULL, 'success' => TRUE),
6815 ),
6816 'authorize_report' => array(
6817 'variables' => array('messages' => array()),
6818 ),
6819 // From pager.inc.
6820 'pager' => array(
6821 'variables' => array('tags' => array(), 'element' => 0, 'parameters' => array(), 'quantity' => 9),
6822 ),
6823 'pager_first' => array(
6824 'variables' => array('text' => NULL, 'element' => 0, 'parameters' => array()),
6825 ),
6826 'pager_previous' => array(
6827 'variables' => array('text' => NULL, 'element' => 0, 'interval' => 1, 'parameters' => array()),
6828 ),
6829 'pager_next' => array(
6830 'variables' => array('text' => NULL, 'element' => 0, 'interval' => 1, 'parameters' => array()),
6831 ),
6832 'pager_last' => array(
6833 'variables' => array('text' => NULL, 'element' => 0, 'parameters' => array()),
6834 ),
6835 'pager_link' => array(
6836 'variables' => array('text' => NULL, 'page_new' => NULL, 'element' => NULL, 'parameters' => array(), 'attributes' => array()),
6837 ),
6838 // From menu.inc.
6839 'menu_link' => array(
6840 'render element' => 'element',
6841 ),
6842 'menu_tree' => array(
6843 'render element' => 'tree',
6844 ),
6845 'menu_local_task' => array(
6846 'render element' => 'element',
6847 ),
6848 'menu_local_action' => array(
6849 'render element' => 'element',
6850 ),
6851 'menu_local_tasks' => array(
6852 'variables' => array('primary' => array(), 'secondary' => array()),
6853 ),
6854 // From form.inc.
6855 'select' => array(
6856 'render element' => 'element',
6857 ),
6858 'fieldset' => array(
6859 'render element' => 'element',
6860 ),
6861 'radio' => array(
6862 'render element' => 'element',
6863 ),
6864 'radios' => array(
6865 'render element' => 'element',
6866 ),
6867 'date' => array(
6868 'render element' => 'element',
6869 ),
6870 'exposed_filters' => array(
6871 'render element' => 'form',
6872 ),
6873 'checkbox' => array(
6874 'render element' => 'element',
6875 ),
6876 'checkboxes' => array(
6877 'render element' => 'element',
6878 ),
6879 'button' => array(
6880 'render element' => 'element',
6881 ),
6882 'image_button' => array(
6883 'render element' => 'element',
6884 ),
6885 'hidden' => array(
6886 'render element' => 'element',
6887 ),
6888 'textfield' => array(
6889 'render element' => 'element',
6890 ),
6891 'form' => array(
6892 'render element' => 'element',
6893 ),
6894 'textarea' => array(
6895 'render element' => 'element',
6896 ),
6897 'password' => array(
6898 'render element' => 'element',
6899 ),
6900 'file' => array(
6901 'render element' => 'element',
6902 ),
6903 'tableselect' => array(
6904 'render element' => 'element',
6905 ),
6906 'form_element' => array(
6907 'render element' => 'element',
6908 ),
6909 'form_required_marker' => array(
6910 'render element' => 'element',
6911 ),
6912 'form_element_label' => array(
6913 'render element' => 'element',
6914 ),
6915 'vertical_tabs' => array(
6916 'render element' => 'element',
6917 ),
6918 'container' => array(
6919 'render element' => 'element',
6920 ),
6921 );
6922 }
6923
6939 function drupal_install_schema($module) {
6940 $schema = drupal_get_schema_unprocessed($module);
6941 _drupal_schema_initialize($schema, $module, FALSE);
6942
6943 foreach ($schema as $name => $table) {
6944 db_create_table($name, $table);
6945 }
6946 }
6947
6963 function drupal_uninstall_schema($module) {
6964 $schema = drupal_get_schema_unprocessed($module);
6965 _drupal_schema_initialize($schema, $module, FALSE);
6966
6967 foreach ($schema as $table) {
6968 if (db_table_exists($table['name'])) {
6969 db_drop_table($table['name']);
6970 }
6971 }
6972 }
6973
6998 function drupal_get_schema_unprocessed($module, $table = NULL) {
6999 // Load the .install file to get hook_schema.
7000 module_load_install($module);
7001 $schema = module_invoke($module, 'schema');
7002
7003 if (isset($table) && isset($schema[$table])) {
7004 return $schema[$table];
7005 }
7006 elseif (!empty($schema)) {
7007 return $schema;
7008 }
7009 return array();
7010 }
7011
7025 function _drupal_schema_initialize(&$schema, $module, $remove_descriptions = TRUE) {
7026 // Set the name and module key for all tables.
7027 foreach ($schema as $name => &$table) {
7028 if (empty($table['module'])) {
7029 $table['module'] = $module;
7030 }
7031 if (!isset($table['name'])) {
7032 $table['name'] = $name;
7033 }
7034 if ($remove_descriptions) {
7035 unset($table['description']);
7036 foreach ($table['fields'] as &$field) {
7037 unset($field['description']);
7038 }
7039 }
7040 }
7041 }
7042
7055 function drupal_schema_fields_sql($table, $prefix = NULL) {
7056 $schema = drupal_get_schema($table);
7057 $fields = array_keys($schema['fields']);
7058 if ($prefix) {
7059 $columns = array();
7060 foreach ($fields as $field) {
7061 $columns[] = "$prefix.$field";
7062 }
7063 return $columns;
7064 }
7065 else {
7066 return $fields;
7067 }
7068 }
7069
7097 function drupal_write_record($table, &$record, $primary_keys = array()) {
7098 // Standardize $primary_keys to an array.
7099 if (is_string($primary_keys)) {
7100 $primary_keys = array($primary_keys);
7101 }
7102
7103 $schema = drupal_get_schema($table);
7104 if (empty($schema)) {
7105 return FALSE;
7106 }
7107
7108 $object = (object) $record;
7109 $fields = array();
7110
7111 // Go through the schema to determine fields to write.
7112 foreach ($schema['fields'] as $field => $info) {
7113 if ($info['type'] == 'serial') {
7114 // Skip serial types if we are updating.
7115 if (!empty($primary_keys)) {
7116 continue;
7117 }
7118 // Track serial field so we can helpfully populate them after the query.
7119 // NOTE: Each table should come with one serial field only.
7120 $serial = $field;
7121 }
7122
7123 // Skip field if it is in $primary_keys as it is unnecessary to update a
7124 // field to the value it is already set to.
7125 if (in_array($field, $primary_keys)) {
7126 continue;
7127 }
7128
7129 if (!property_exists($object, $field)) {
7130 // Skip fields that are not provided, default values are already known
7131 // by the database.
7132 continue;
7133 }
7134
7135 // Build array of fields to update or insert.
7136 if (empty($info['serialize'])) {
7137 $fields[$field] = $object->$field;
7138 }
7139 else {
7140 $fields[$field] = serialize($object->$field);
7141 }
7142
7143 // Type cast to proper datatype, except when the value is NULL and the
7144 // column allows this.
7145 //
7146 // MySQL PDO silently casts e.g. FALSE and '' to 0 when inserting the value
7147 // into an integer column, but PostgreSQL PDO does not. Also type cast NULL
7148 // when the column does not allow this.
7149 if (isset($object->$field) || !empty($info['not null'])) {
7150 if ($info['type'] == 'int' || $info['type'] == 'serial') {
7151 $fields[$field] = (int) $fields[$field];
7152 }
7153 elseif ($info['type'] == 'float') {
7154 $fields[$field] = (float) $fields[$field];
7155 }
7156 else {
7157 $fields[$field] = (string) $fields[$field];
7158 }
7159 }
7160 }
7161
7162 if (empty($fields)) {
7163 return;
7164 }
7165
7166 // Build the SQL.
7167 if (empty($primary_keys)) {
7168 // We are doing an insert.
7169 $options = array('return' => Database::RETURN_INSERT_ID);
7170 if (isset($serial) && isset($fields[$serial])) {
7171 // If the serial column has been explicitly set with an ID, then we don't
7172 // require the database to return the last insert id.
7173 if ($fields[$serial]) {
7174 $options['return'] = Database::RETURN_AFFECTED;
7175 }
7176 // If a serial column does exist with no value (i.e. 0) then remove it as
7177 // the database will insert the correct value for us.
7178 else {
7179 unset($fields[$serial]);
7180 }
7181 }
7182 $query = db_insert($table, $options)->fields($fields);
7183 $return = SAVED_NEW;
7184 }
7185 else {
7186 $query = db_update($table)->fields($fields);
7187 foreach ($primary_keys as $key) {
7188 $query->condition($key, $object->$key);
7189 }
7190 $return = SAVED_UPDATED;
7191 }
7192
7193 // Execute the SQL.
7194 if ($query_return = $query->execute()) {
7195 if (isset($serial)) {
7196 // If the database was not told to return the last insert id, it will be
7197 // because we already know it.
7198 if (isset($options) && $options['return'] != Database::RETURN_INSERT_ID) {
7199 $object->$serial = $fields[$serial];
7200 }
7201 else {
7202 $object->$serial = $query_return;
7203 }
7204 }
7205 }
7206 // If we have a single-field primary key but got no insert ID, the
7207 // query failed. Note that we explicitly check for FALSE, because
7208 // a valid update query which doesn't change any values will return
7209 // zero (0) affected rows.
7210 elseif ($query_return === FALSE && count($primary_keys) == 1) {
7211 $return = FALSE;
7212 }
7213
7214 // If we are inserting, populate empty fields with default values.
7215 if (empty($primary_keys)) {
7216 foreach ($schema['fields'] as $field => $info) {
7217 if (isset($info['default']) && !property_exists($object, $field)) {
7218 $object->$field = $info['default'];
7219 }
7220 }
7221 }
7222
7223 // If we began with an array, convert back.
7224 if (is_array($record)) {
7225 $record = (array) $object;
7226 }
7227
7228 return $return;
7229 }
7230
7270 function drupal_parse_info_file($filename) {
7271 $info = &drupal_static(__FUNCTION__, array());
7272
7273 if (!isset($info[$filename])) {
7274 if (!file_exists($filename)) {
7275 $info[$filename] = array();
7276 }
7277 else {
7278 $data = file_get_contents($filename);
7279 $info[$filename] = drupal_parse_info_format($data);
7280 }
7281 }
7282 return $info[$filename];
7283 }
7284
7322 function drupal_parse_info_format($data) {
7323 $info = array();
7324 $constants = get_defined_constants();
7325
7326 if (preg_match_all('
7327 @^\s* # Start at the beginning of a line, ignoring leading whitespace
7328 ((?:
7329 [^=;\[\]]| # Key names cannot contain equal signs, semi-colons or square brackets,
7330 \[[^\[\]]*\] # unless they are balanced and not nested
7331 )+?)
7332 \s*=\s* # Key/value pairs are separated by equal signs (ignoring white-space)
7333 (?:
7334 ("(?:[^"]|(?<=\\\\)")*")| # Double-quoted string, which may contain slash-escaped quotes/slashes
7335 (\'(?:[^\']|(?<=\\\\)\')*\')| # Single-quoted string, which may contain slash-escaped quotes/slashes
7336 ([^\r\n]*?) # Non-quoted string
7337 )\s*$ # Stop at the next end of a line, ignoring trailing whitespace
7338 @msx', $data, $matches, PREG_SET_ORDER)) {
7339 foreach ($matches as $match) {
7340 // Fetch the key and value string.
7341 $i = 0;
7342 foreach (array('key', 'value1', 'value2', 'value3') as $var) {
7343 $$var = isset($match[++$i]) ? $match[$i] : '';
7344 }
7345 $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3;
7346
7347 // Parse array syntax.
7348 $keys = preg_split('/\]?\[/', rtrim($key, ']'));
7349 $last = array_pop($keys);
7350 $parent = &$info;
7351
7352 // Create nested arrays.
7353 foreach ($keys as $key) {
7354 if ($key == '') {
7355 $key = count($parent);
7356 }
7357 if (!isset($parent[$key]) || !is_array($parent[$key])) {
7358 $parent[$key] = array();
7359 }
7360 $parent = &$parent[$key];
7361 }
7362
7363 // Handle PHP constants.
7364 if (isset($constants[$value])) {
7365 $value = $constants[$value];
7366 }
7367
7368 // Insert actual value.
7369 if ($last == '') {
7370 $last = count($parent);
7371 }
7372 $parent[$last] = $value;
7373 }
7374 }
7375
7376 return $info;
7377 }
7378
7389 function watchdog_severity_levels() {
7390 return array(
7391 WATCHDOG_EMERGENCY => t('emergency'),
7392 WATCHDOG_ALERT => t('alert'),
7393 WATCHDOG_CRITICAL => t('critical'),
7394 WATCHDOG_ERROR => t('error'),
7395 WATCHDOG_WARNING => t('warning'),
7396 WATCHDOG_NOTICE => t('notice'),
7397 WATCHDOG_INFO => t('info'),
7398 WATCHDOG_DEBUG => t('debug'),
7399 );
7400 }
7401
7402
7408 function drupal_explode_tags($tags) {
7409 // This regexp allows the following types of user input:
7410 // this, "somecompany, llc", "and ""this"" w,o.rks", foo bar
7411 $regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x';
7412 preg_match_all($regexp, $tags, $matches);
7413 $typed_tags = array_unique($matches[1]);
7414
7415 $tags = array();
7416 foreach ($typed_tags as $tag) {
7417 // If a user has escaped a term (to demonstrate that it is a group,
7418 // or includes a comma or quote character), we remove the escape
7419 // formatting so to save the term into the database as the user intends.
7420 $tag = trim(str_replace('""', '"', preg_replace('/^"(.*)"$/', '\1', $tag)));
7421 if ($tag != "") {
7422 $tags[] = $tag;
7423 }
7424 }
7425
7426 return $tags;
7427 }
7428
7434 function drupal_implode_tags($tags) {
7435 $encoded_tags = array();
7436 foreach ($tags as $tag) {
7437 // Commas and quotes in tag names are special cases, so encode them.
7438 if (strpos($tag, ',') !== FALSE || strpos($tag, '"') !== FALSE) {
7439 $tag = '"' . str_replace('"', '""', $tag) . '"';
7440 }
7441
7442 $encoded_tags[] = $tag;
7443 }
7444 return implode(', ', $encoded_tags);
7445 }
7446
7453 function drupal_flush_all_caches() {
7454 // Change query-strings on css/js files to enforce reload for all users.
7455 _drupal_flush_css_js();
7456
7457 registry_rebuild();
7458 drupal_clear_css_cache();
7459 drupal_clear_js_cache();
7460
7461 // Rebuild the theme data. Note that the module data is rebuilt above, as
7462 // part of registry_rebuild().
7463 system_rebuild_theme_data();
7464 drupal_theme_rebuild();
7465
7466 entity_info_cache_clear();
7467 node_types_rebuild();
7468 // node_menu() defines menu items based on node types so it needs to come
7469 // after node types are rebuilt.
7470 menu_rebuild();
7471
7472 // Synchronize to catch any actions that were added or removed.
7473 actions_synchronize();
7474
7475 // Don't clear cache_form - in-progress form submissions may break.
7476 // Ordered so clearing the page cache will always be the last action.
7477 $core = array('cache', 'cache_path', 'cache_filter', 'cache_bootstrap', 'cache_page');
7478 $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
7479 foreach ($cache_tables as $table) {
7480 cache_clear_all('*', $table, TRUE);
7481 }
7482
7483 // Rebuild the bootstrap module list. We do this here so that developers
7484 // can get new hook_boot() implementations registered without having to
7485 // write a hook_update_N() function.
7486 _system_update_bootstrap_status();
7487 }
7488
7495 function _drupal_flush_css_js() {
7496 // The timestamp is converted to base 36 in order to make it more compact.
7497 variable_set('css_js_query_string', base_convert(REQUEST_TIME, 10, 36));
7498 }
7499
7515 function debug($data, $label = NULL, $print_r = FALSE) {
7516 // Print $data contents to string.
7517 $string = check_plain($print_r ? print_r($data, TRUE) : var_export($data, TRUE));
7518
7519 // Display values with pre-formatting to increase readability.
7520 $string = '<pre>' . $string . '</pre>';
7521
7522 trigger_error(trim($label ? "$label: $string" : $string));
7523 }
7524
7543 function drupal_parse_dependency($dependency) {
7544 // We use named subpatterns and support every op that version_compare
7545 // supports. Also, op is optional and defaults to equals.
7546 $p_op = '(?P<operation>!=|==|=|<|<=|>|>=|<>)?';
7547 // Core version is always optional: 7.x-2.x and 2.x is treated the same.
7548 $p_core = '(?:' . preg_quote(DRUPAL_CORE_COMPATIBILITY) . '-)?';
7549 $p_major = '(?P<major>\d+)';
7550 // By setting the minor version to x, branches can be matched.
7551 $p_minor = '(?P<minor>(?:\d+|x)(?:-[A-Za-z]+\d+)?)';
7552 $value = array();
7553 $parts = explode('(', $dependency, 2);
7554 $value['name'] = trim($parts[0]);
7555 if (isset($parts[1])) {
7556 $value['original_version'] = ' (' . $parts[1];
7557 foreach (explode(',', $parts[1]) as $version) {
7558 if (preg_match("/^\s*$p_op\s*$p_core$p_major\.$p_minor/", $version, $matches)) {
7559 $op = !empty($matches['operation']) ? $matches['operation'] : '=';
7560 if ($matches['minor'] == 'x') {
7561 // Drupal considers "2.x" to mean any version that begins with
7562 // "2" (e.g. 2.0, 2.9 are all "2.x"). PHP's version_compare(),
7563 // on the other hand, treats "x" as a string; so to
7564 // version_compare(), "2.x" is considered less than 2.0. This
7565 // means that >=2.x and <2.x are handled by version_compare()
7566 // as we need, but > and <= are not.
7567 if ($op == '>' || $op == '<=') {
7568 $matches['major']++;
7569 }
7570 // Equivalence can be checked by adding two restrictions.
7571 if ($op == '=' || $op == '==') {
7572 $value['versions'][] = array('op' => '<', 'version' => ($matches['major'] + 1) . '.x');
7573 $op = '>=';
7574 }
7575 }
7576 $value['versions'][] = array('op' => $op, 'version' => $matches['major'] . '.' . $matches['minor']);
7577 }
7578 }
7579 }
7580 return $value;
7581 }
7582
7597 function drupal_check_incompatibility($v, $current_version) {
7598 if (!empty($v['versions'])) {
7599 foreach ($v['versions'] as $required_version) {
7600 if ((isset($required_version['op']) && !version_compare($current_version, $required_version['version'], $required_version['op']))) {
7601 return $v['original_version'];
7602 }
7603 }
7604 }
7605 }
7606
7617 function entity_get_info($entity_type = NULL) {
7618 global $language;
7619
7620 // Use the advanced drupal_static() pattern, since this is called very often.
7621 static $drupal_static_fast;
7622 if (!isset($drupal_static_fast)) {
7623 $drupal_static_fast['entity_info'] = &drupal_static(__FUNCTION__);
7624 }
7625 $entity_info = &$drupal_static_fast['entity_info'];
7626
7627 // hook_entity_info() includes translated strings, so each language is cached
7628 // separately.
7629 $langcode = $language->language;
7630
7631 if (empty($entity_info)) {
7632 if ($cache = cache_get("entity_info:$langcode")) {
7633 $entity_info = $cache->data;
7634 }
7635 else {
7636 $entity_info = module_invoke_all('entity_info');
7637 // Merge in default values.
7638 foreach ($entity_info as $name => $data) {
7639 $entity_info[$name] += array(
7640 'fieldable' => FALSE,
7641 'controller class' => 'DrupalDefaultEntityController',
7642 'static cache' => TRUE,
7643 'field cache' => TRUE,
7644 'load hook' => $name . '_load',
7645 'bundles' => array(),
7646 'view modes' => array(),
7647 'entity keys' => array(),
7648 'translation' => array(),
7649 );
7650 $entity_info[$name]['entity keys'] += array(
7651 'revision' => '',
7652 'bundle' => '',
7653 );
7654 foreach ($entity_info[$name]['view modes'] as $view_mode => $view_mode_info) {
7655 $entity_info[$name]['view modes'][$view_mode] += array(
7656 'custom settings' => FALSE,
7657 );
7658 }
7659 // If no bundle key is provided, assume a single bundle, named after
7660 // the entity type.
7661 if (empty($entity_info[$name]['entity keys']['bundle']) && empty($entity_info[$name]['bundles'])) {
7662 $entity_info[$name]['bundles'] = array($name => array('label' => $entity_info[$name]['label']));
7663 }
7664 // Prepare entity schema fields SQL info for
7665 // DrupalEntityControllerInterface::buildQuery().
7666 if (isset($entity_info[$name]['base table'])) {
7667 $entity_info[$name]['schema_fields_sql']['base table'] = drupal_schema_fields_sql($entity_info[$name]['base table']);
7668 if (isset($entity_info[$name]['revision table'])) {
7669 $entity_info[$name]['schema_fields_sql']['revision table'] = drupal_schema_fields_sql($entity_info[$name]['revision table']);
7670 }
7671 }
7672 }
7673 // Let other modules alter the entity info.
7674 drupal_alter('entity_info', $entity_info);
7675 cache_set("entity_info:$langcode", $entity_info);
7676 }
7677 }
7678
7679 if (empty($entity_type)) {
7680 return $entity_info;
7681 }
7682 elseif (isset($entity_info[$entity_type])) {
7683 return $entity_info[$entity_type];
7684 }
7685 }
7686
7690 function entity_info_cache_clear() {
7691 drupal_static_reset('entity_get_info');
7692 // Clear all languages.
7693 cache_clear_all('entity_info:', 'cache', TRUE);
7694 }
7695
7711 function entity_extract_ids($entity_type, $entity) {
7712 $info = entity_get_info($entity_type);
7713
7714 // Objects being created might not have id/vid yet.
7715 $id = isset($entity->{$info['entity keys']['id']}) ? $entity->{$info['entity keys']['id']} : NULL;
7716 $vid = ($info['entity keys']['revision'] && isset($entity->{$info['entity keys']['revision']})) ? $entity->{$info['entity keys']['revision']} : NULL;
7717
7718 if (!empty($info['entity keys']['bundle'])) {
7719 // Explicitly fail for malformed entities missing the bundle property.
7720 if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
7721 throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
7722 }
7723 $bundle = $entity->{$info['entity keys']['bundle']};
7724 }
7725 else {
7726 // The entity type provides no bundle key: assume a single bundle, named
7727 // after the entity type.
7728 $bundle = $entity_type;
7729 }
7730
7731 return array($id, $vid, $bundle);
7732 }
7733
7749 function entity_create_stub_entity($entity_type, $ids) {
7750 $entity = new stdClass();
7751 $info = entity_get_info($entity_type);
7752 $entity->{$info['entity keys']['id']} = $ids[0];
7753 if (!empty($info['entity keys']['revision']) && isset($ids[1])) {
7754 $entity->{$info['entity keys']['revision']} = $ids[1];
7755 }
7756 if (!empty($info['entity keys']['bundle']) && isset($ids[2])) {
7757 $entity->{$info['entity keys']['bundle']} = $ids[2];
7758 }
7759 return $entity;
7760 }
7761
7800 function entity_load($entity_type, $ids = FALSE, $conditions = array(), $reset = FALSE) {
7801 if ($reset) {
7802 entity_get_controller($entity_type)->resetCache();
7803 }
7804 return entity_get_controller($entity_type)->load($ids, $conditions);
7805 }
7806
7823 function entity_load_unchanged($entity_type, $id) {
7824 entity_get_controller($entity_type)->resetCache(array($id));
7825 $result = entity_get_controller($entity_type)->load(array($id));
7826 return reset($result);
7827 }
7828
7832 function entity_get_controller($entity_type) {
7833 $controllers = &drupal_static(__FUNCTION__, array());
7834 if (!isset($controllers[$entity_type])) {
7835 $type_info = entity_get_info($entity_type);
7836 $class = $type_info['controller class'];
7837 $controllers[$entity_type] = new $class($entity_type);
7838 }
7839 return $controllers[$entity_type];
7840 }
7841
7866 function entity_prepare_view($entity_type, $entities, $langcode = NULL) {
7867 if (!isset($langcode)) {
7868 $langcode = $GLOBALS['language_content']->language;
7869 }
7870
7871 // To ensure hooks are only run once per entity, check for an
7872 // entity_view_prepared flag and only process items without it.
7873 // @todo: resolve this more generally for both entity and field level hooks.
7874 $prepare = array();
7875 foreach ($entities as $id => $entity) {
7876 if (empty($entity->entity_view_prepared)) {
7877 // Add this entity to the items to be prepared.
7878 $prepare[$id] = $entity;
7879
7880 // Mark this item as prepared.
7881 $entity->entity_view_prepared = TRUE;
7882 }
7883 }
7884
7885 if (!empty($prepare)) {
7886 module_invoke_all('entity_prepare_view', $prepare, $entity_type, $langcode);
7887 }
7888 }
7889
7902 function entity_uri($entity_type, $entity) {
7903 $info = entity_get_info($entity_type);
7904 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
7905
7906 // A bundle-specific callback takes precedence over the generic one for the
7907 // entity type.
7908 if (isset($info['bundles'][$bundle]['uri callback'])) {
7909 $uri_callback = $info['bundles'][$bundle]['uri callback'];
7910 }
7911 elseif (isset($info['uri callback'])) {
7912 $uri_callback = $info['uri callback'];
7913 }
7914 else {
7915 return NULL;
7916 }
7917
7918 // Invoke the callback to get the URI. If there is no callback, return NULL.
7919 if (isset($uri_callback) && function_exists($uri_callback)) {
7920 $uri = $uri_callback($entity);
7921 // Pass the entity data to url() so that alter functions do not need to
7922 // lookup this entity again.
7923 $uri['options']['entity_type'] = $entity_type;
7924 $uri['options']['entity'] = $entity;
7925 return $uri;
7926 }
7927 }
7928
7943 function entity_label($entity_type, $entity) {
7944 $label = FALSE;
7945 $info = entity_get_info($entity_type);
7946 if (isset($info['label callback']) && function_exists($info['label callback'])) {
7947 $label = $info['label callback']($entity, $entity_type);
7948 }
7949 elseif (!empty($info['entity keys']['label']) && isset($entity->{$info['entity keys']['label']})) {
7950 $label = $entity->{$info['entity keys']['label']};
7951 }
7952
7953 return $label;
7954 }
7955
7967 function entity_language($entity_type, $entity) {
7968 $info = entity_get_info($entity_type);
7969
7970 // Invoke the callback to get the language. If there is no callback, try to
7971 // get it from a property of the entity, otherwise NULL.
7972 if (isset($info['language callback']) && function_exists($info['language callback'])) {
7973 $langcode = $info['language callback']($entity_type, $entity);
7974 }
7975 elseif (!empty($info['entity keys']['language']) && isset($entity->{$info['entity keys']['language']})) {
7976 $langcode = $entity->{$info['entity keys']['language']};
7977 }
7978 else {
7979 // The value returned in D8 would be LANGUAGE_NONE, we cannot use it here to
7980 // preserve backward compatibility. In fact this function has been
7981 // introduced very late in the D7 life cycle, mainly as the proper default
7982 // for field_attach_form(). By returning LANGUAGE_NONE when no language
7983 // information is available, we would introduce a potentially BC-breaking
7984 // API change, since field_attach_form() defaults to the default language
7985 // instead of LANGUAGE_NONE. Moreover this allows us to distinguish between
7986 // entities that have no language specified from ones that do not have
7987 // language support at all.
7988 $langcode = NULL;
7989 }
7990
7991 return $langcode;
7992 }
7993
7997 function entity_form_field_validate($entity_type, $form, &$form_state) {
7998 // All field attach API functions act on an entity object, but during form
7999 // validation, we don't have one. $form_state contains the entity as it was
8000 // prior to processing the current form submission, and we must not update it
8001 // until we have fully validated the submitted input. Therefore, for
8002 // validation, act on a pseudo entity created out of the form values.
8003 $pseudo_entity = (object) $form_state['values'];
8004 field_attach_form_validate($entity_type, $pseudo_entity, $form, $form_state);
8005 }
8006
8028 function entity_form_submit_build_entity($entity_type, $entity, $form, &$form_state) {
8029 $info = entity_get_info($entity_type);
8030 list(, , $bundle) = entity_extract_ids($entity_type, $entity);
8031
8032 // Copy top-level form values that are not for fields to entity properties,
8033 // without changing existing entity properties that are not being edited by
8034 // this form. Copying field values must be done using field_attach_submit().
8035 $values_excluding_fields = $info['fieldable'] ? array_diff_key($form_state['values'], field_info_instances($entity_type, $bundle)) : $form_state['values'];
8036 foreach ($values_excluding_fields as $key => $value) {
8037 $entity->$key = $value;
8038 }
8039
8040 // Invoke all specified builders for copying form values to entity properties.
8041 if (isset($form['#entity_builders'])) {
8042 foreach ($form['#entity_builders'] as $function) {
8043 $function($entity_type, $entity, $form, $form_state);
8044 }
8045 }
8046
8047 // Copy field values to the entity.
8048 if ($info['fieldable']) {
8049 field_attach_submit($entity_type, $entity, $form, $form_state);
8050 }
8051 }
8052
8081 function xmlrpc($url, $args, $options = array()) {
8082 require_once DRUPAL_ROOT . '/includes/xmlrpc.inc';
8083 return _xmlrpc($url, $args, $options);
8084 }
8085
8092 function archiver_get_info() {
8093 $archiver_info = &drupal_static(__FUNCTION__, array());
8094
8095 if (empty($archiver_info)) {
8096 $cache = cache_get('archiver_info');
8097 if ($cache === FALSE) {
8098 // Rebuild the cache and save it.
8099 $archiver_info = module_invoke_all('archiver_info');
8100 drupal_alter('archiver_info', $archiver_info);
8101 uasort($archiver_info, 'drupal_sort_weight');
8102 cache_set('archiver_info', $archiver_info);
8103 }
8104 else {
8105 $archiver_info = $cache->data;
8106 }
8107 }
8108
8109 return $archiver_info;
8110 }
8111
8119 function archiver_get_extensions() {
8120 $valid_extensions = array();
8121 foreach (archiver_get_info() as $archive) {
8122 foreach ($archive['extensions'] as $extension) {
8123 foreach (explode('.', $extension) as $part) {
8124 if (!in_array($part, $valid_extensions)) {
8125 $valid_extensions[] = $part;
8126 }
8127 }
8128 }
8129 }
8130 return implode(' ', $valid_extensions);
8131 }
8132
8145 function archiver_get_archiver($file) {
8146 // Archivers can only work on local paths
8147 $filepath = drupal_realpath($file);
8148 if (!is_file($filepath)) {
8149 throw new Exception(t('Archivers can only operate on local files: %file not supported', array('%file' => $file)));
8150 }
8151 $archiver_info = archiver_get_info();
8152
8153 foreach ($archiver_info as $implementation) {
8154 foreach ($implementation['extensions'] as $extension) {
8155 // Because extensions may be multi-part, such as .tar.gz,
8156 // we cannot use simpler approaches like substr() or pathinfo().
8157 // This method isn't quite as clean but gets the job done.
8158 // Also note that the file may not yet exist, so we cannot rely
8159 // on fileinfo() or other disk-level utilities.
8160 if (strrpos($filepath, '.' . $extension) === strlen($filepath) - strlen('.' . $extension)) {
8161 return new $implementation['class']($filepath);
8162 }
8163 }
8164 }
8165 }
8166
8180 function drupal_get_updaters() {
8181 $updaters = &drupal_static(__FUNCTION__);
8182 if (!isset($updaters)) {
8183 $updaters = module_invoke_all('updater_info');
8184 drupal_alter('updater_info', $updaters);
8185 uasort($updaters, 'drupal_sort_weight');
8186 }
8187 return $updaters;
8188 }
8189
8200 function drupal_get_filetransfer_info() {
8201 $info = &drupal_static(__FUNCTION__);
8202 if (!isset($info)) {
8203 // Since we have to manually set the 'file path' default for each
8204 // module separately, we can't use module_invoke_all().
8205 $info = array();
8206 foreach (module_implements('filetransfer_info') as $module) {
8207 $function = $module . '_filetransfer_info';
8208 if (function_exists($function)) {
8209 $result = $function();
8210 if (isset($result) && is_array($result)) {
8211 foreach ($result as &$values) {
8212 if (empty($values['file path'])) {
8213 $values['file path'] = drupal_get_path('module', $module);
8214 }
8215 }
8216 $info = array_merge_recursive($info, $result);
8217 }
8218 }
8219 }
8220 drupal_alter('filetransfer_info', $info);
8221 uasort($info, 'drupal_sort_weight');
8222 }
8223 return $info;
8224 }
drupal_render_cache_by_query
drupal_render_cache_by_query($query, $function, $expire=CACHE_TEMPORARY, $granularity=NULL)
Definition: common.inc:6192
drupal_cron_cleanup
drupal_cron_cleanup()
Definition: common.inc:5310
drupal_json_encode
drupal_json_encode($var)
Definition: common.inc:5003
EntityMalformedException
Definition: entity.inc:1360
drupal_cache_system_paths
drupal_cache_system_paths()
Definition: path.inc:203
drupal_is_front_page
drupal_is_front_page()
Definition: path.inc:284
drupal_process_attached
drupal_process_attached($elements, $group=JS_DEFAULT, $dependency_check=FALSE, $every_page=NULL)
Definition: common.inc:4472
registry_rebuild
registry_rebuild()
Definition: bootstrap.inc:3175
url_is_external
url_is_external($path)
Definition: common.inc:2311
drupal_http_build_query
drupal_http_build_query(array $query, $parent= '')
Definition: common.inc:486
element_sort
element_sort($a, $b)
Definition: common.inc:6282
drupal_get_http_header
drupal_get_http_header($name=NULL)
Definition: bootstrap.inc:1161
watchdog_exception
watchdog_exception($type, Exception $exception, $message=NULL, $variables=array(), $severity=WATCHDOG_ERROR, $link=NULL)
Definition: bootstrap.inc:1654
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
drupal_sort_title
drupal_sort_title($a, $b)
Definition: common.inc:6368
drupal_add_region_content
drupal_add_region_content($region=NULL, $data=NULL)
Definition: common.inc:175
$op
$op
Definition: update.php:404
filter_xss_bad_protocol
filter_xss_bad_protocol($string, $decode=TRUE)
Definition: common.inc:1656
drupal_valid_test_ua
drupal_valid_test_ua()
Definition: bootstrap.inc:2515
decode_entities
decode_entities($text)
Definition: unicode.inc:457
drupal_build_css_cache
drupal_build_css_cache($css)
Definition: common.inc:3546
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
drupal_parse_dependency
drupal_parse_dependency($dependency)
Definition: common.inc:7543
format_rss_channel
format_rss_channel($title, $link, $description, $items, $langcode=NULL, $args=array())
Definition: common.inc:1685
drupal_get_bootstrap_phase
drupal_get_bootstrap_phase()
Definition: bootstrap.inc:2503
FILE_CREATE_DIRECTORY
const FILE_CREATE_DIRECTORY
Definition: file.inc:41
menu_set_custom_theme
menu_set_custom_theme()
Definition: menu.inc:1769
CSS_DEFAULT
const CSS_DEFAULT
Definition: common.inc:65
menu_get_item
menu_get_item($path=NULL, $router_item=NULL)
Definition: menu.inc:447
entity_load
entity_load($entity_type, $ids=FALSE, $conditions=array(), $reset=FALSE)
Definition: common.inc:7800
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_strtolower
drupal_strtolower($text)
Definition: unicode.inc:521
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
HTTP_REQUEST_TIMEOUT
const HTTP_REQUEST_TIMEOUT
Definition: common.inc:92
drupal_load_stylesheet
drupal_load_stylesheet($file, $optimize=NULL, $reset_basepath=TRUE)
Definition: common.inc:3659
show
show(&$element)
Definition: common.inc:6050
drupal_set_breadcrumb
drupal_set_breadcrumb($breadcrumb=NULL)
Definition: common.inc:243
drupal_sort_css_js
drupal_sort_css_js($a, $b)
Definition: common.inc:3124
DrupalQueue\get
static get($name, $reliable=FALSE)
Definition: system.queue.inc:81
drupal_array_nested_key_exists
drupal_array_nested_key_exists(array $array, array $parents)
Definition: common.inc:6710
entity_form_field_validate
entity_form_field_validate($entity_type, $form, &$form_state)
Definition: common.inc:7997
archiver_get_extensions
archiver_get_extensions()
Definition: common.inc:8119
drupal_get_css
drupal_get_css($css=NULL, $skip_alter=FALSE)
Definition: common.inc:3052
DRUPAL_CACHE_PER_PAGE
const DRUPAL_CACHE_PER_PAGE
Definition: common.inc:156
_drupal_flush_css_js
_drupal_flush_css_js()
Definition: common.inc:7495
drupal_pre_render_conditional_comments
drupal_pre_render_conditional_comments($elements)
Definition: common.inc:5500
file_scan_directory
file_scan_directory($dir, $mask, $options=array(), $depth=0)
Definition: file.inc:2058
drupal_array_get_nested_value
& drupal_array_get_nested_value(array &$array, array $parents, &$key_exists=NULL)
Definition: common.inc:6666
flood_is_allowed
flood_is_allowed($name, $threshold, $window=3600, $identifier=NULL)
Definition: common.inc:1298
drupal_parse_info_file
drupal_parse_info_file($filename)
Definition: common.inc:7270
drupal_get_private_key
drupal_get_private_key()
Definition: common.inc:5056
SAVED_UPDATED
const SAVED_UPDATED
Definition: common.inc:50
DRUPAL_CACHE_PER_USER
const DRUPAL_CACHE_PER_USER
Definition: common.inc:151
field_attach_submit
field_attach_submit($entity_type, $entity, $form, &$form_state, $options=array())
Definition: field.attach.inc:884
drupal_set_time_limit
drupal_set_time_limit($time_limit)
Definition: common.inc:2786
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
WATCHDOG_INFO
const WATCHDOG_INFO
Definition: bootstrap.inc:108
field_info_instances
field_info_instances($entity_type=NULL, $bundle_name=NULL)
Definition: field.info.inc:592
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
drupal_clear_css_cache
drupal_clear_css_cache()
Definition: common.inc:3783
MENU_ACCESS_DENIED
const MENU_ACCESS_DENIED
Definition: menu.inc:239
$module
print $module
Definition: search-results.tpl.php:28
drupal_json_encode_helper
drupal_json_encode_helper($var)
Definition: json-encode.inc:13
file_create_url
file_create_url($uri)
Definition: file.inc:372
drupal_page_is_cacheable
drupal_page_is_cacheable($allow_caching=NULL)
Definition: bootstrap.inc:1048
check_url
check_url($uri)
Definition: common.inc:1387
drupal_process_states
drupal_process_states(&$elements)
Definition: common.inc:4660
format_username
format_username($account)
Definition: common.inc:2106
element_properties
element_properties($element)
Definition: common.inc:6388
$page
print $page
Definition: overlay.tpl.php:37
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
drupal_anonymous_user
drupal_anonymous_user()
Definition: bootstrap.inc:2152
MENU_SITE_OFFLINE
const MENU_SITE_OFFLINE
Definition: menu.inc:244
variable_del
variable_del($name)
Definition: bootstrap.inc:996
format_rss_item
format_rss_item($title, $link, $description, $args=array())
Definition: common.inc:1710
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
drupal_save_session
drupal_save_session($status=NULL)
Definition: session.inc:524
$name
print $name
Definition: profile-listing.tpl.php:43
DRUPAL_KILOBYTE
const DRUPAL_KILOBYTE
Definition: bootstrap.inc:174
Exception
_drupal_schema_initialize
_drupal_schema_initialize(&$schema, $module, $remove_descriptions=TRUE)
Definition: common.inc:7025
drupal_json_output
drupal_json_output($var=NULL)
Definition: common.inc:5041
drupal_get_query_parameters
drupal_get_query_parameters(array $query=NULL, array $exclude=array('q'), $parent= '')
Definition: common.inc:417
drupal_realpath
drupal_realpath($uri)
Definition: file.inc:2259
element_get_visible_children
element_get_visible_children(array $elements)
Definition: common.inc:6453
$header
print $header
Definition: forum-topic-list.tpl.php:42
menu_set_active_item
menu_set_active_item($path)
Definition: menu.inc:2340
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
drupal_attributes
drupal_attributes(array $attributes=array())
Definition: common.inc:2377
drupal_sort_weight
drupal_sort_weight($a, $b)
Definition: common.inc:6356
$attributes
print $attributes
Definition: block.tpl.php:47
drupal_strip_dangerous_protocols
drupal_strip_dangerous_protocols($uri)
Definition: common.inc:1340
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
drupal_http_request
drupal_http_request($url, array $options=array())
Definition: common.inc:787
ip_address
ip_address()
Definition: bootstrap.inc:2890
locale_get_plural
locale_get_plural($count, $langcode=NULL)
Definition: locale.module:782
drupal_get_query_array
drupal_get_query_array($query)
Definition: common.inc:457
drupal_site_offline
drupal_site_offline()
Definition: common.inc:719
drupal_add_html_head_link
drupal_add_html_head_link($attributes, $header=FALSE)
Definition: common.inc:2834
print
print
Definition: php-2.php:2
drupal_clear_js_cache
drupal_clear_js_cache()
Definition: common.inc:4988
drupal_pre_render_styles
drupal_pre_render_styles($elements)
Definition: common.inc:3359
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
drupal_pre_render_link
drupal_pre_render_link($element)
Definition: common.inc:5561
system_rebuild_theme_data
system_rebuild_theme_data()
Definition: system.module:2609
element_info
element_info($type)
Definition: common.inc:6306
drupal_generate_test_ua
drupal_generate_test_ua($prefix)
Definition: bootstrap.inc:2546
drupal_hmac_base64
drupal_hmac_base64($data, $key)
Definition: bootstrap.inc:2047
_xmlrpc
_xmlrpc($url, $args, $options=array())
Definition: xmlrpc.inc:546
$contents
print $contents
Definition: book-export-html.tpl.php:49
entity_uri
entity_uri($entity_type, $entity)
Definition: common.inc:7902
drupal_fast_404
drupal_fast_404()
Definition: bootstrap.inc:2588
drupal_session_commit
drupal_session_commit()
Definition: session.inc:302
menu_get_active_breadcrumb
menu_get_active_breadcrumb()
Definition: menu.inc:2562
element_property
element_property($key)
Definition: common.inc:6381
module_load_install
module_load_install($module)
Definition: module.inc:288
rdf_get_namespaces
rdf_get_namespaces()
Definition: rdf.module:97
request_uri
request_uri()
Definition: bootstrap.inc:1609
entity_info_cache_clear
entity_info_cache_clear()
Definition: common.inc:7690
drupal_validate_utf8
drupal_validate_utf8($text)
Definition: bootstrap.inc:1593
language_types_configurable
language_types_configurable($stored=TRUE)
Definition: language.inc:139
drupal_get_schema_unprocessed
drupal_get_schema_unprocessed($module, $table=NULL)
Definition: common.inc:6998
module_load_all
module_load_all($bootstrap=FALSE)
Definition: module.inc:19
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
archiver_get_info
archiver_get_info()
Definition: common.inc:8092
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
drupal_get_schema
drupal_get_schema($table=NULL, $rebuild=FALSE)
Definition: bootstrap.inc:2940
MENU_NOT_FOUND
const MENU_NOT_FOUND
Definition: menu.inc:234
drupal_array_diff_assoc_recursive
drupal_array_diff_assoc_recursive($array1, $array2)
Definition: common.inc:6515
drupal_add_library
drupal_add_library($module, $name, $every_page=NULL)
Definition: common.inc:4694
archiver_get_archiver
archiver_get_archiver($file)
Definition: common.inc:8145
drupal_render_collect_attached
drupal_render_collect_attached($elements, $return=FALSE)
Definition: common.inc:6138
field_attach_form_validate
field_attach_form_validate($entity_type, $entity, $form, &$form_state, $options=array())
Definition: field.attach.inc:837
file_get_stream_wrappers
file_get_stream_wrappers($filter=STREAM_WRAPPERS_ALL)
Definition: file.inc:123
drupal_get_path_alias
drupal_get_path_alias($path=NULL, $path_language=NULL)
Definition: path.inc:235
drupal_render_page
drupal_render_page($page)
Definition: common.inc:5727
menu_execute_active_handler
menu_execute_active_handler($path=NULL, $deliver=TRUE)
Definition: menu.inc:500
module_implements_write_cache
module_implements_write_cache()
Definition: module.inc:835
Database\RETURN_INSERT_ID
const RETURN_INSERT_ID
Definition: database.inc:1345
WATCHDOG_ALERT
const WATCHDOG_ALERT
Definition: bootstrap.inc:83
drupal_get_library
drupal_get_library($module, $name=NULL)
Definition: common.inc:4748
drupal_valid_token
drupal_valid_token($token, $value= '', $skip_anonymous=FALSE)
Definition: common.inc:5095
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
_drupal_load_stylesheet
_drupal_load_stylesheet($matches)
Definition: common.inc:3763
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
entity_label
entity_label($entity_type, $entity)
Definition: common.inc:7943
menu_rebuild
menu_rebuild()
Definition: menu.inc:2709
xmlrpc
xmlrpc($url, $args, $options=array())
Definition: common.inc:8081
$url
print $url
Definition: search-result.tpl.php:70
$info
$info
Definition: color.inc:6
drupal_pre_render_links
drupal_pre_render_links($element)
Definition: common.inc:5676
FILE_EXISTS_REPLACE
const FILE_EXISTS_REPLACE
Definition: file.inc:56
drupal_get_profile
drupal_get_profile()
Definition: common.inc:222
drupal_parse_info_format
drupal_parse_info_format($data)
Definition: common.inc:7322
drupal_aggregate_css
drupal_aggregate_css(&$css_groups)
Definition: common.inc:3274
_filter_xss_attributes
_filter_xss_attributes($attr)
Definition: common.inc:1544
hide
hide(&$element)
Definition: common.inc:6021
node_types_rebuild
node_types_rebuild()
Definition: node.module:475
drupal_serve_page_from_cache
drupal_serve_page_from_cache(stdClass $cache)
Definition: bootstrap.inc:1280
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
entity_load_unchanged
entity_load_unchanged($entity_type, $id)
Definition: common.inc:7823
drupal_build_js_cache
drupal_build_js_cache($files)
Definition: common.inc:4936
drupal_random_key
drupal_random_key($byte_count=32)
Definition: bootstrap.inc:1945
Database\RETURN_AFFECTED
const RETURN_AFFECTED
Definition: database.inc:1340
timer_start
timer_start($name)
Definition: bootstrap.inc:460
_fix_gpc_magic_files
_fix_gpc_magic_files(&$item, $key)
Definition: common.inc:1139
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
fix_gpc_magic
fix_gpc_magic()
Definition: common.inc:1156
drupal_clean_css_identifier
drupal_clean_css_identifier($identifier, $filter=array(' '=> '-', '_'=> '-', '/'=> '-', '['=> '-', ']'=> ''))
Definition: common.inc:3812
drupal_install_schema
drupal_install_schema($module)
Definition: common.inc:6939
drupal_add_http_header
drupal_add_http_header($name, $value, $append=FALSE)
Definition: bootstrap.inc:1129
$value
print $value
Definition: user-profile-item.tpl.php:26
_format_date_callback
_format_date_callback(array $matches=NULL, $new_langcode=NULL)
Definition: common.inc:2055
watchdog_severity_levels
watchdog_severity_levels()
Definition: common.inc:7389
_system_update_bootstrap_status
_system_update_bootstrap_status()
Definition: system.module:2467
theme_get_registry
theme_get_registry($complete=TRUE)
Definition: theme.inc:255
entity_language
entity_language($entity_type, $entity)
Definition: common.inc:7967
drupal_get_normal_path
drupal_get_normal_path($path, $path_language=NULL)
Definition: path.inc:259
language
print $language language
Definition: book-export-html.tpl.php:22
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
drupal_implode_tags
drupal_implode_tags($tags)
Definition: common.inc:7434
MARK_NEW
const MARK_NEW
Definition: theme.inc:26
drupal_get_region_content
drupal_get_region_content($region=NULL, $delimiter= ' ')
Definition: common.inc:193
$output
$output
Definition: authorize.php:93
WATCHDOG_DEBUG
const WATCHDOG_DEBUG
Definition: bootstrap.inc:113
drupal_html_id
drupal_html_id($id)
Definition: common.inc:3879
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
drupal_json_decode
drupal_json_decode($var)
Definition: common.inc:5028
drupal_render_cid_create
drupal_render_cid_create($elements)
Definition: common.inc:6266
render
render(&$element)
Definition: common.inc:5988
file_unmanaged_delete
file_unmanaged_delete($path)
Definition: file.inc:1317
system_run_automated_cron
system_run_automated_cron()
Definition: system.module:3495
REGISTRY_WRITE_LOOKUP_CACHE
const REGISTRY_WRITE_LOOKUP_CACHE
Definition: bootstrap.inc:242
_drupal_build_css_path
_drupal_build_css_path($matches, $base=NULL)
Definition: common.inc:3621
parse_size
parse_size($size)
Definition: common.inc:1842
drupal_random_bytes
drupal_random_bytes($count)
Definition: bootstrap.inc:1974
drupal_array_merge_deep_array
drupal_array_merge_deep_array($arrays)
Definition: bootstrap.inc:2122
drupal_schema_fields_sql
drupal_schema_fields_sql($table, $prefix=NULL)
Definition: common.inc:7055
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
drupal_render_cache_get
drupal_render_cache_get($elements)
Definition: common.inc:6068
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
drupal_add_feed
drupal_add_feed($url=NULL, $title= '')
Definition: common.inc:368
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
drupal_parse_url
drupal_parse_url($url)
Definition: common.inc:580
WATCHDOG_CRITICAL
const WATCHDOG_CRITICAL
Definition: bootstrap.inc:88
element_set_attributes
element_set_attributes(array &$element, array $map)
Definition: common.inc:6487
_drupal_default_html_head
_drupal_default_html_head()
Definition: common.inc:319
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
entity_prepare_view
entity_prepare_view($entity_type, $entities, $langcode=NULL)
Definition: common.inc:7866
flood_clear_event
flood_clear_event($name, $identifier=NULL)
Definition: common.inc:1267
element_info_property
element_info_property($type, $property_name, $default=NULL)
Definition: common.inc:6337
drupal_theme_initialize
drupal_theme_initialize()
Definition: theme.inc:70
drupal_region_class
drupal_region_class($region)
Definition: common.inc:3976
drupal_maintenance_theme
drupal_maintenance_theme()
Definition: bootstrap.inc:2569
drupal_delete_file_if_stale
drupal_delete_file_if_stale($uri)
Definition: common.inc:3791
SAVED_NEW
const SAVED_NEW
Definition: common.inc:45
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_access_denied
drupal_access_denied()
Definition: common.inc:744
conf_path
conf_path($require_settings=TRUE, $reset=FALSE)
Definition: bootstrap.inc:541
drupal_render_cache_set
drupal_render_cache_set(&$markup, $elements)
Definition: common.inc:6099
valid_email_address
valid_email_address($mail)
Definition: common.inc:1186
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
_filter_xss_split
_filter_xss_split($m, $store=FALSE)
Definition: common.inc:1480
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
drupal_page_footer
drupal_page_footer()
Definition: common.inc:2688
_drupal_set_preferred_header_name
_drupal_set_preferred_header_name($name=NULL)
Definition: bootstrap.inc:1178
file_unmanaged_save_data
file_unmanaged_save_data($data, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1932
drupal_get_html_head
drupal_get_html_head()
Definition: common.inc:352
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
drupal_flush_all_caches
drupal_flush_all_caches()
Definition: common.inc:7453
entity_get_controller
entity_get_controller($entity_type)
Definition: common.inc:7832
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
drupal_explode_tags
drupal_explode_tags($tags)
Definition: common.inc:7408
timer_read
timer_read($name)
Definition: bootstrap.inc:476
drupal_encode_path
drupal_encode_path($path)
Definition: common.inc:639
lock_acquire
lock_acquire($name, $timeout=30.0)
Definition: lock.inc:102
format_xml_elements
format_xml_elements($array)
Definition: common.inc:1735
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
JS_LIBRARY
const JS_LIBRARY
Definition: common.inc:75
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
drupal_http_header_attributes
drupal_http_header_attributes(array $attributes=array())
Definition: common.inc:2331
drupal_exit
drupal_exit($destination=NULL)
Definition: common.inc:2721
$classes
print $classes
Definition: contextual-links-example-object.tpl.php:31
WATCHDOG_EMERGENCY
const WATCHDOG_EMERGENCY
Definition: bootstrap.inc:78
$styles
print $styles
Definition: html.tpl.php:52
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
CACHE_TEMPORARY
const CACHE_TEMPORARY
Definition: bootstrap.inc:53
drupal_get_token
drupal_get_token($value= '')
Definition: common.inc:5077
$breadcrumb
print $breadcrumb
Definition: page.tpl.php:40
drupal_path_initialize
drupal_path_initialize()
Definition: path.inc:15
drupal_js_defaults
drupal_js_defaults($data=NULL)
Definition: common.inc:4215
VERSION
const VERSION
Definition: bootstrap.inc:11
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
JS_DEFAULT
const JS_DEFAULT
Definition: common.inc:80
DRUPAL_CORE_COMPATIBILITY
const DRUPAL_CORE_COMPATIBILITY
Definition: bootstrap.inc:16
$children
print $children
Definition: book-node-export-html.tpl.php:24
CACHE_PERMANENT
const CACHE_PERMANENT
Definition: bootstrap.inc:48
entity_create_stub_entity
entity_create_stub_entity($entity_type, $ids)
Definition: common.inc:7749
drupal_get_title
drupal_get_title()
Definition: bootstrap.inc:1848
drupal_get_breadcrumb
drupal_get_breadcrumb()
Definition: common.inc:255
_drupal_http_use_proxy
_drupal_http_use_proxy($host)
Definition: common.inc:1098
drupal_group_css
drupal_group_css($css)
Definition: common.inc:3191
element_sort_by_title
element_sort_by_title($a, $b)
Definition: common.inc:6294
$dir
print $dir
Definition: book-export-html.tpl.php:22
drupal_array_set_nested_value
drupal_array_set_nested_value(array &$array, array $parents, $value, $force=FALSE)
Definition: common.inc:6598
drupal_render_cid_parts
drupal_render_cid_parts($granularity=NULL)
Definition: common.inc:6222
drupal_system_listing
drupal_system_listing($mask, $directory, $key= 'name', $min_depth=1)
Definition: common.inc:5368
MAINTENANCE_MODE
const MAINTENANCE_MODE
Definition: authorize.php:36
drupal_set_page_content
drupal_set_page_content($content=NULL)
Definition: common.inc:5454
drupal_check_incompatibility
drupal_check_incompatibility($v, $current_version)
Definition: common.inc:7597
_fix_gpc_magic
_fix_gpc_magic(&$item)
Definition: common.inc:1115
file_prepare_directory
file_prepare_directory(&$directory, $options=FILE_MODIFY_PERMISSIONS)
Definition: file.inc:430
drupal_basename
drupal_basename($uri, $suffix=NULL)
Definition: file.inc:2317
drupal_pre_render_markup
drupal_pre_render_markup($elements)
Definition: common.inc:5708
drupal_common_theme
drupal_common_theme()
Definition: common.inc:6721
base_path
base_path()
Definition: common.inc:2817
element_child
element_child($key)
Definition: common.inc:6395
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
drupal_deliver_html_page
drupal_deliver_html_page($page_callback_result)
Definition: common.inc:2585
drupal_theme_rebuild
drupal_theme_rebuild()
Definition: theme.inc:352
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
file_uri_scheme
file_uri_scheme($uri)
Definition: file.inc:199
debug
debug($data, $label=NULL, $print_r=FALSE)
Definition: common.inc:7515
drupal_hash_base64
drupal_hash_base64($data)
Definition: bootstrap.inc:2067
drupal_not_found
drupal_not_found()
Definition: common.inc:731
format_size
format_size($size, $langcode=NULL)
Definition: common.inc:1866
drupal_get_feeds
drupal_get_feeds($delimiter="\n")
Definition: common.inc:392
drupal_uninstall_schema
drupal_uninstall_schema($module)
Definition: common.inc:6963
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
drupal_get_updaters
drupal_get_updaters()
Definition: common.inc:8180
valid_url
valid_url($url, $absolute=FALSE)
Definition: common.inc:1204
_drupal_bootstrap_full
_drupal_bootstrap_full()
Definition: common.inc:5100
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
drupal_add_html_head
drupal_add_html_head($data=NULL, $key=NULL)
Definition: common.inc:299
entity_extract_ids
entity_extract_ids($entity_type, $entity)
Definition: common.inc:7711
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
drupal_deliver_page
drupal_deliver_page($page_callback_result, $default_delivery_callback=NULL)
Definition: common.inc:2554
drupal_get_rdf_namespaces
drupal_get_rdf_namespaces()
Definition: common.inc:269
drupal_load_stylesheet_content
drupal_load_stylesheet_content($contents, $optimize=FALSE)
Definition: common.inc:3707
drupal_get_filetransfer_info
drupal_get_filetransfer_info()
Definition: common.inc:8200
_registry_check_code
_registry_check_code($type, $name=NULL)
Definition: bootstrap.inc:3103
date_iso8601
date_iso8601($date)
Definition: common.inc:2044
drupal_cron_run
drupal_cron_run()
Definition: common.inc:5227
flood_register_event
flood_register_event($name, $window=3600, $identifier=NULL)
Definition: common.inc:1245
lock_release
lock_release($name)
Definition: lock.inc:247
entity_form_submit_build_entity
entity_form_submit_build_entity($entity_type, $entity, $form, &$form_state)
Definition: common.inc:8028
db_table_exists
db_table_exists($table)
Definition: database.inc:2760
unicode_check
unicode_check()
Definition: unicode.inc:87
drupal_get_hash_salt
drupal_get_hash_salt()
Definition: bootstrap.inc:2289
drupal_page_set_cache
drupal_page_set_cache()
Definition: common.inc:5175
actions_synchronize
actions_synchronize($delete_orphans=FALSE)
Definition: actions.inc:274
drupal_get_js
drupal_get_js($scope= 'header', $javascript=NULL, $skip_alter=FALSE)
Definition: common.inc:4263
drupal_multilingual
drupal_multilingual()
Definition: bootstrap.inc:2691
drupal_get_filename
drupal_get_filename($type, $name, $filename=NULL)
Definition: bootstrap.inc:820
drupal_html_class
drupal_html_class($class)
Definition: common.inc:3841
DRUPAL_BOOTSTRAP_FULL
const DRUPAL_BOOTSTRAP_FULL
Definition: bootstrap.inc:157
drupal_register_shutdown_function
& drupal_register_shutdown_function($callback=NULL)
Definition: bootstrap.inc:3417
DRUPAL_CACHE_PER_ROLE
const DRUPAL_CACHE_PER_ROLE
Definition: common.inc:143
ajax_pre_render_element
ajax_pre_render_element($element)
Definition: ajax.inc:618
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/path/path.module Source File

  • modules
  • path
path.module
Go to the documentation of this file.
1 <?php
2
11 function path_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#path':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t('The Path module allows you to specify an alias, or custom URL, for any existing internal system path. Aliases should not be confused with URL redirects, which allow you to forward a changed or inactive URL to a new URL. In addition to making URLs more readable, aliases also help search engines index content more effectively. Multiple aliases may be used for a single internal system path. To automate the aliasing of paths, you can install the contributed module <a href="@pathauto">Pathauto</a>. For more information, see the online handbook entry for the <a href="@path">Path module</a>.', array('@path' => 'http://drupal.org/documentation/modules/path', '@pathauto' => 'http://drupal.org/project/pathauto')) . '</p>';
17 $output .= '<h3>' . t('Uses') . '</h3>';
18 $output .= '<dl>';
19 $output .= '<dt>' . t('Creating aliases') . '</dt>';
20 $output .= '<dd>' . t('Users with sufficient <a href="@permissions">permissions</a> can create aliases under the <em>URL path settings</em> section when they create or edit content. Some examples of aliases are: ', array('@permissions' => url('admin/people/permissions', array('fragment' => 'module-path'))));
21 $output .= '<ul><li>' . t('<em>member/jane-smith</em> aliased to internal path <em>user/123</em>') . '</li>';
22 $output .= '<li>' . t('<em>about-us/team</em> aliased to internal path <em>node/456</em>') . '</li>';
23 $output .= '</ul></dd>';
24 $output .= '<dt>' . t('Managing aliases') . '</dt>';
25 $output .= '<dd>' . t('The Path module provides a way to search and view a <a href="@aliases">list of all aliases</a> that are in use on your website. Aliases can be added, edited and deleted through this list.', array('@aliases' => url('admin/config/search/path'))) . '</dd>';
26 $output .= '</dl>';
27 return $output;
28
29 case 'admin/config/search/path':
30 return '<p>' . t("An alias defines a different name for an existing URL path - for example, the alias 'about' for the URL path 'node/1'. A URL path can have multiple aliases.") . '</p>';
31
32 case 'admin/config/search/path/add':
33 return '<p>' . t('Enter the path you wish to create the alias for, followed by the name of the new alias.') . '</p>';
34 }
35 }
36
40 function path_permission() {
41 return array(
42 'administer url aliases' => array(
43 'title' => t('Administer URL aliases'),
44 ),
45 'create url aliases' => array(
46 'title' => t('Create and edit URL aliases'),
47 ),
48 );
49 }
50
54 function path_menu() {
55 $items['admin/config/search/path'] = array(
56 'title' => 'URL aliases',
57 'description' => "Change your site's URL paths by aliasing them.",
58 'page callback' => 'path_admin_overview',
59 'access arguments' => array('administer url aliases'),
60 'weight' => -5,
61 'file' => 'path.admin.inc',
62 );
63 $items['admin/config/search/path/edit/%path'] = array(
64 'title' => 'Edit alias',
65 'page callback' => 'path_admin_edit',
66 'page arguments' => array(5),
67 'access arguments' => array('administer url aliases'),
68 'file' => 'path.admin.inc',
69 );
70 $items['admin/config/search/path/delete/%path'] = array(
71 'title' => 'Delete alias',
72 'page callback' => 'drupal_get_form',
73 'page arguments' => array('path_admin_delete_confirm', 5),
74 'access arguments' => array('administer url aliases'),
75 'file' => 'path.admin.inc',
76 );
77 $items['admin/config/search/path/list'] = array(
78 'title' => 'List',
79 'type' => MENU_DEFAULT_LOCAL_TASK,
80 'weight' => -10,
81 );
82 $items['admin/config/search/path/add'] = array(
83 'title' => 'Add alias',
84 'page callback' => 'path_admin_edit',
85 'access arguments' => array('administer url aliases'),
86 'type' => MENU_LOCAL_ACTION,
87 'file' => 'path.admin.inc',
88 );
89
90 return $items;
91 }
92
98 function path_form_node_form_alter(&$form, $form_state) {
99 $path = array();
100 if (!empty($form['#node']->nid)) {
101 $conditions = array('source' => 'node/' . $form['#node']->nid);
102 $langcode = entity_language('node', $form['#node']);
103 if ($langcode != LANGUAGE_NONE) {
104 $conditions['language'] = $langcode;
105 }
106 $path = path_load($conditions);
107 if ($path === FALSE) {
108 $path = array();
109 }
110 }
111 $path += array(
112 'pid' => NULL,
113 'source' => isset($form['#node']->nid) ? 'node/' . $form['#node']->nid : NULL,
114 'alias' => '',
115 'language' => isset($langcode) ? $langcode : LANGUAGE_NONE,
116 );
117
118 $form['path'] = array(
119 '#type' => 'fieldset',
120 '#title' => t('URL path settings'),
121 '#collapsible' => TRUE,
122 '#collapsed' => empty($path['alias']),
123 '#group' => 'additional_settings',
124 '#attributes' => array(
125 'class' => array('path-form'),
126 ),
127 '#attached' => array(
128 'js' => array(drupal_get_path('module', 'path') . '/path.js'),
129 ),
130 '#access' => user_access('create url aliases') || user_access('administer url aliases'),
131 '#weight' => 30,
132 '#tree' => TRUE,
133 '#element_validate' => array('path_form_element_validate'),
134 );
135 $form['path']['alias'] = array(
136 '#type' => 'textfield',
137 '#title' => t('URL alias'),
138 '#default_value' => $path['alias'],
139 '#maxlength' => 255,
140 '#description' => t('Optionally specify an alternative URL by which this content can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
141 );
142 $form['path']['pid'] = array('#type' => 'value', '#value' => $path['pid']);
143 $form['path']['source'] = array('#type' => 'value', '#value' => $path['source']);
144 $form['path']['language'] = array('#type' => 'value', '#value' => $path['language']);
145 }
146
152 function path_form_element_validate($element, &$form_state, $complete_form) {
153 // Trim the submitted value.
154 $alias = trim($form_state['values']['path']['alias']);
155 if (!empty($alias)) {
156 form_set_value($element['alias'], $alias, $form_state);
157 // Node language (Locale module) needs special care. Since the language of
158 // the URL alias depends on the node language, and the node language can be
159 // switched right within the same form, we need to conditionally overload
160 // the originally assigned URL alias language.
161 // @todo Remove this after converting Path module to a field, and, after
162 // stopping Locale module from abusing the content language system.
163 if (isset($form_state['values']['language'])) {
164 form_set_value($element['language'], $form_state['values']['language'], $form_state);
165 }
166
167 $path = $form_state['values']['path'];
168
169 // Ensure that the submitted alias does not exist yet.
170 $query = db_select('url_alias')
171 ->condition('alias', $path['alias'])
172 ->condition('language', $path['language']);
173 if (!empty($path['source'])) {
174 $query->condition('source', $path['source'], '<>');
175 }
176 $query->addExpression('1');
177 $query->range(0, 1);
178 if ($query->execute()->fetchField()) {
179 form_error($element, t('The alias is already in use.'));
180 }
181 }
182 }
183
187 function path_node_insert($node) {
188 if (isset($node->path)) {
189 $path = $node->path;
190 $path['alias'] = trim($path['alias']);
191 // Only save a non-empty alias.
192 if (!empty($path['alias'])) {
193 // Ensure fields for programmatic executions.
194 $langcode = entity_language('node', $node);
195 $path['source'] = 'node/' . $node->nid;
196 $path['language'] = isset($langcode) ? $langcode : LANGUAGE_NONE;
197 path_save($path);
198 }
199 }
200 }
201
205 function path_node_update($node) {
206 if (isset($node->path)) {
207 $path = $node->path;
208 $path['alias'] = trim($path['alias']);
209 // Delete old alias if user erased it.
210 if (!empty($path['pid']) && empty($path['alias'])) {
211 path_delete($path['pid']);
212 }
213 path_node_insert($node);
214 }
215 }
216
220 function path_node_delete($node) {
221 // Delete all aliases associated with this node.
222 path_delete(array('source' => 'node/' . $node->nid));
223 }
224
228 function path_form_taxonomy_form_term_alter(&$form, $form_state) {
229 // Make sure this does not show up on the delete confirmation form.
230 if (empty($form_state['confirm_delete'])) {
231 $langcode = entity_language('taxonomy_term', (object) $form['#term']);
232 $langcode = !empty($langcode) ? $langcode : LANGUAGE_NONE;
233 $conditions = array('source' => 'taxonomy/term/' . $form['#term']['tid'], 'language' => $langcode);
234 $path = (isset($form['#term']['tid']) ? path_load($conditions) : array());
235 if ($path === FALSE) {
236 $path = array();
237 }
238 $path += array(
239 'pid' => NULL,
240 'source' => isset($form['#term']['tid']) ? 'taxonomy/term/' . $form['#term']['tid'] : NULL,
241 'alias' => '',
242 'language' => $langcode,
243 );
244 $form['path'] = array(
245 '#access' => user_access('create url aliases') || user_access('administer url aliases'),
246 '#tree' => TRUE,
247 '#element_validate' => array('path_form_element_validate'),
248 );
249 $form['path']['alias'] = array(
250 '#type' => 'textfield',
251 '#title' => t('URL alias'),
252 '#default_value' => $path['alias'],
253 '#maxlength' => 255,
254 '#weight' => 0,
255 '#description' => t("Optionally specify an alternative URL by which this term can be accessed. Use a relative path and don't add a trailing slash or the URL alias won't work."),
256 );
257 $form['path']['pid'] = array('#type' => 'value', '#value' => $path['pid']);
258 $form['path']['source'] = array('#type' => 'value', '#value' => $path['source']);
259 $form['path']['language'] = array('#type' => 'value', '#value' => $path['language']);
260 }
261 }
262
266 function path_taxonomy_term_insert($term) {
267 if (isset($term->path)) {
268 $path = $term->path;
269 $path['alias'] = trim($path['alias']);
270 // Only save a non-empty alias.
271 if (!empty($path['alias'])) {
272 // Ensure fields for programmatic executions.
273 $path['source'] = 'taxonomy/term/' . $term->tid;
274 // Core does not provide a way to store the term language but contrib
275 // modules can do it so we need to take this into account.
276 $langcode = entity_language('taxonomy_term', $term);
277 $path['language'] = !empty($langcode) ? $langcode : LANGUAGE_NONE;
278 path_save($path);
279 }
280 }
281 }
282
286 function path_taxonomy_term_update($term) {
287 if (isset($term->path)) {
288 $path = $term->path;
289 $path['alias'] = trim($path['alias']);
290 // Delete old alias if user erased it.
291 if (!empty($path['pid']) && empty($path['alias'])) {
292 path_delete($path['pid']);
293 }
294 // Only save a non-empty alias.
295 if (!empty($path['alias'])) {
296 // Ensure fields for programmatic executions.
297 $path['source'] = 'taxonomy/term/' . $term->tid;
298 // Core does not provide a way to store the term language but contrib
299 // modules can do it so we need to take this into account.
300 $langcode = entity_language('taxonomy_term', $term);
301 $path['language'] = !empty($langcode) ? $langcode : LANGUAGE_NONE;
302 path_save($path);
303 }
304 }
305 }
306
310 function path_taxonomy_term_delete($term) {
311 // Delete all aliases associated with this term.
312 path_delete(array('source' => 'taxonomy/term/' . $term->tid));
313 }
path_permission
path_permission()
Definition: path.module:40
path_node_insert
path_node_insert($node)
Definition: path.module:187
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
path_load
path_load($conditions)
Definition: path.inc:403
path_taxonomy_term_delete
path_taxonomy_term_delete($term)
Definition: path.module:310
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
path_taxonomy_term_update
path_taxonomy_term_update($term)
Definition: path.module:286
path_form_element_validate
path_form_element_validate($element, &$form_state, $complete_form)
Definition: path.module:152
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
path_form_taxonomy_form_term_alter
path_form_taxonomy_form_term_alter(&$form, $form_state)
Definition: path.module:228
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
path_node_update
path_node_update($node)
Definition: path.module:205
nid
print $node nid
Definition: book-node-export-html.tpl.php:21
path_delete
path_delete($criteria)
Definition: path.inc:463
path_help
path_help($path, $arg)
Definition: path.module:11
entity_language
entity_language($entity_type, $entity)
Definition: common.inc:7967
path_node_delete
path_node_delete($node)
Definition: path.module:220
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
path_menu
path_menu()
Definition: path.module:54
path_save
path_save(&$path)
Definition: path.inc:433
path_taxonomy_term_insert
path_taxonomy_term_insert($term)
Definition: path.module:266
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
path_form_node_form_alter
path_form_node_form_alter(&$form, $form_state)
Definition: path.module:98
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.api.php Source File

  • modules
  • system
system.api.php
Go to the documentation of this file.
1 <?php
2
37 function hook_hook_info() {
38 $hooks['token_info'] = array(
39 'group' => 'tokens',
40 );
41 $hooks['tokens'] = array(
42 'group' => 'tokens',
43 );
44 return $hooks;
45 }
46
55 function hook_hook_info_alter(&$hooks) {
56 // Our module wants to completely override the core tokens, so make
57 // sure the core token hooks are not found.
58 $hooks['token_info']['group'] = 'mytokens';
59 $hooks['tokens']['group'] = 'mytokens';
60 }
61
202 function hook_entity_info() {
203 $return = array(
204 'node' => array(
205 'label' => t('Node'),
206 'controller class' => 'NodeController',
207 'base table' => 'node',
208 'revision table' => 'node_revision',
209 'uri callback' => 'node_uri',
210 'fieldable' => TRUE,
211 'translation' => array(
212 'locale' => TRUE,
213 ),
214 'entity keys' => array(
215 'id' => 'nid',
216 'revision' => 'vid',
217 'bundle' => 'type',
218 'language' => 'language',
219 ),
220 'bundle keys' => array(
221 'bundle' => 'type',
222 ),
223 'bundles' => array(),
224 'view modes' => array(
225 'full' => array(
226 'label' => t('Full content'),
227 'custom settings' => FALSE,
228 ),
229 'teaser' => array(
230 'label' => t('Teaser'),
231 'custom settings' => TRUE,
232 ),
233 'rss' => array(
234 'label' => t('RSS'),
235 'custom settings' => FALSE,
236 ),
237 ),
238 ),
239 );
240
241 // Search integration is provided by node.module, so search-related
242 // view modes for nodes are defined here and not in search.module.
243 if (module_exists('search')) {
244 $return['node']['view modes'] += array(
245 'search_index' => array(
246 'label' => t('Search index'),
247 'custom settings' => FALSE,
248 ),
249 'search_result' => array(
250 'label' => t('Search result'),
251 'custom settings' => FALSE,
252 ),
253 );
254 }
255
256 // Bundles must provide a human readable name so we can create help and error
257 // messages, and the path to attach Field admin pages to.
258 foreach (node_type_get_names() as $type => $name) {
259 $return['node']['bundles'][$type] = array(
260 'label' => $name,
261 'admin' => array(
262 'path' => 'admin/structure/types/manage/%node_type',
263 'real path' => 'admin/structure/types/manage/' . str_replace('_', '-', $type),
264 'bundle argument' => 4,
265 'access arguments' => array('administer content types'),
266 ),
267 );
268 }
269
270 return $return;
271 }
272
285 function hook_entity_info_alter(&$entity_info) {
286 // Set the controller class for nodes to an alternate implementation of the
287 // DrupalEntityController interface.
288 $entity_info['node']['controller class'] = 'MyCustomNodeController';
289 }
290
302 function hook_entity_load($entities, $type) {
303 foreach ($entities as $entity) {
304 $entity->foo = mymodule_add_something($entity, $type);
305 }
306 }
307
316 function hook_entity_presave($entity, $type) {
317 $entity->changed = REQUEST_TIME;
318 }
319
328 function hook_entity_insert($entity, $type) {
329 // Insert the new entity into a fictional table of all entities.
330 $info = entity_get_info($type);
331 list($id) = entity_extract_ids($type, $entity);
332 db_insert('example_entity')
333 ->fields(array(
334 'type' => $type,
335 'id' => $id,
336 'created' => REQUEST_TIME,
337 'updated' => REQUEST_TIME,
338 ))
339 ->execute();
340 }
341
350 function hook_entity_update($entity, $type) {
351 // Update the entity's entry in a fictional table of all entities.
352 $info = entity_get_info($type);
353 list($id) = entity_extract_ids($type, $entity);
354 db_update('example_entity')
355 ->fields(array(
356 'updated' => REQUEST_TIME,
357 ))
358 ->condition('type', $type)
359 ->condition('id', $id)
360 ->execute();
361 }
362
371 function hook_entity_delete($entity, $type) {
372 // Delete the entity's entry from a fictional table of all entities.
373 $info = entity_get_info($type);
374 list($id) = entity_extract_ids($type, $entity);
375 db_delete('example_entity')
376 ->condition('type', $type)
377 ->condition('id', $id)
378 ->execute();
379 }
380
403 function hook_entity_query_alter($query) {
404 $query->executeCallback = 'my_module_query_callback';
405 }
406
428 function hook_entity_view($entity, $type, $view_mode, $langcode) {
429 $entity->content['my_additional_field'] = array(
430 '#markup' => $additional_field,
431 '#weight' => 10,
432 '#theme' => 'mymodule_my_additional_field',
433 );
434 }
435
459 function hook_entity_view_alter(&$build, $type) {
460 if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
461 // Change its weight.
462 $build['an_additional_field']['#weight'] = -10;
463
464 // Add a #post_render callback to act on the rendered HTML of the entity.
465 $build['#post_render'][] = 'my_module_node_post_render';
466 }
467 }
468
480 function hook_entity_view_mode_alter(&$view_mode, $context) {
481 // For nodes, change the view mode when it is teaser.
482 if ($context['entity_type'] == 'node' && $view_mode == 'teaser') {
483 $view_mode = 'my_custom_view_mode';
484 }
485 }
486
508 function hook_admin_paths() {
509 $paths = array(
510 'mymodule/*/add' => TRUE,
511 'mymodule/*/edit' => TRUE,
512 );
513 return $paths;
514 }
515
525 function hook_admin_paths_alter(&$paths) {
526 // Treat all user pages as administrative.
527 $paths['user'] = TRUE;
528 $paths['user/*'] = TRUE;
529 // Treat the forum topic node form as a non-administrative page.
530 $paths['node/add/forum'] = FALSE;
531 }
532
547 function hook_entity_prepare_view($entities, $type, $langcode) {
548 // Load a specific node into the user object for later theming.
549 if ($type == 'user') {
550 $nodes = mymodule_get_user_nodes(array_keys($entities));
551 foreach ($entities as $uid => $entity) {
552 $entity->user_node = $nodes[$uid];
553 }
554 }
555 }
556
575 function hook_cron() {
576 // Short-running operation example, not using a queue:
577 // Delete all expired records since the last cron run.
578 $expires = variable_get('mymodule_cron_last_run', REQUEST_TIME);
579 db_delete('mymodule_table')
580 ->condition('expires', $expires, '>=')
581 ->execute();
582 variable_set('mymodule_cron_last_run', REQUEST_TIME);
583
584 // Long-running operation example, leveraging a queue:
585 // Fetch feeds from other sites.
586 $result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < :time AND refresh <> :never', array(
587 ':time' => REQUEST_TIME,
588 ':never' => AGGREGATOR_CLEAR_NEVER,
589 ));
590 $queue = DrupalQueue::get('aggregator_feeds');
591 foreach ($result as $feed) {
592 $queue->createItem($feed);
593 }
594 }
595
620 function hook_cron_queue_info() {
621 $queues['aggregator_feeds'] = array(
622 'worker callback' => 'aggregator_refresh',
623 'time' => 60,
624 );
625 return $queues;
626 }
627
640 function hook_cron_queue_info_alter(&$queues) {
641 // This site has many feeds so let's spend 90 seconds on each cron run
642 // updating feeds instead of the default 60.
643 $queues['aggregator_feeds']['time'] = 90;
644 }
645
684 function hook_element_info() {
685 $types['filter_format'] = array(
686 '#input' => TRUE,
687 );
688 return $types;
689 }
690
702 function hook_element_info_alter(&$type) {
703 // Decrease the default size of textfields.
704 if (isset($type['textfield']['#size'])) {
705 $type['textfield']['#size'] = 40;
706 }
707 }
708
728 function hook_exit($destination = NULL) {
729 db_update('counter')
730 ->expression('hits', 'hits + 1')
731 ->condition('type', 1)
732 ->execute();
733 }
734
746 function hook_js_alter(&$javascript) {
747 // Swap out jQuery to use an updated version of the library.
748 $javascript['misc/jquery.js']['data'] = drupal_get_path('module', 'jquery_update') . '/jquery.js';
749 }
750
786 function hook_library() {
787 // Library One.
788 $libraries['library-1'] = array(
789 'title' => 'Library One',
790 'website' => 'http://example.com/library-1',
791 'version' => '1.2',
792 'js' => array(
793 drupal_get_path('module', 'my_module') . '/library-1.js' => array(),
794 ),
795 'css' => array(
796 drupal_get_path('module', 'my_module') . '/library-2.css' => array(
797 'type' => 'file',
798 'media' => 'screen',
799 ),
800 ),
801 );
802 // Library Two.
803 $libraries['library-2'] = array(
804 'title' => 'Library Two',
805 'website' => 'http://example.com/library-2',
806 'version' => '3.1-beta1',
807 'js' => array(
808 // JavaScript settings may use the 'data' key.
809 array(
810 'type' => 'setting',
811 'data' => array('library2' => TRUE),
812 ),
813 ),
814 'dependencies' => array(
815 // Require jQuery UI core by System module.
816 array('system', 'ui'),
817 // Require our other library.
818 array('my_module', 'library-1'),
819 // Require another library.
820 array('other_module', 'library-3'),
821 ),
822 );
823 return $libraries;
824 }
825
842 function hook_library_alter(&$libraries, $module) {
843 // Update Farbtastic to version 2.0.
844 if ($module == 'system' && isset($libraries['farbtastic'])) {
845 // Verify existing version is older than the one we are updating to.
846 if (version_compare($libraries['farbtastic']['version'], '2.0', '<')) {
847 // Update the existing Farbtastic to version 2.0.
848 $libraries['farbtastic']['version'] = '2.0';
849 $libraries['farbtastic']['js'] = array(
850 drupal_get_path('module', 'farbtastic_update') . '/farbtastic-2.0.js' => array(),
851 );
852 }
853 }
854 }
855
865 function hook_css_alter(&$css) {
866 // Remove defaults.css file.
867 unset($css[drupal_get_path('module', 'system') . '/defaults.css']);
868 }
869
878 function hook_ajax_render_alter($commands) {
879 // Inject any new status messages into the content area.
880 $commands[] = ajax_command_prepend('#block-system-main .content', theme('status_messages'));
881 }
882
905 function hook_page_build(&$page) {
906 if (menu_get_object('node', 1)) {
907 // We are on a node detail page. Append a standard disclaimer to the
908 // content region.
909 $page['content']['disclaimer'] = array(
910 '#markup' => t('Acme, Inc. is not responsible for the contents of this sample code.'),
911 '#weight' => 25,
912 );
913 }
914 }
915
940 function hook_menu_get_item_alter(&$router_item, $path, $original_map) {
941 // When retrieving the router item for the current path...
942 if ($path == $_GET['q']) {
943 // ...call a function that prepares something for this request.
944 mymodule_prepare_something();
945 }
946 }
947
1264 function hook_menu() {
1265 $items['example'] = array(
1266 'title' => 'Example Page',
1267 'page callback' => 'example_page',
1268 'access arguments' => array('access content'),
1269 'type' => MENU_SUGGESTED_ITEM,
1270 );
1271 $items['example/feed'] = array(
1272 'title' => 'Example RSS feed',
1273 'page callback' => 'example_feed',
1274 'access arguments' => array('access content'),
1275 'type' => MENU_CALLBACK,
1276 );
1277
1278 return $items;
1279 }
1280
1292 function hook_menu_alter(&$items) {
1293 // Example - disable the page at node/add
1294 $items['node/add']['access callback'] = FALSE;
1295 }
1296
1305 function hook_menu_link_alter(&$item) {
1306 // Make all new admin links hidden (a.k.a disabled).
1307 if (strpos($item['link_path'], 'admin') === 0 && empty($item['mlid'])) {
1308 $item['hidden'] = 1;
1309 }
1310 // Flag a link to be altered by hook_translated_menu_link_alter().
1311 if ($item['link_path'] == 'devel/cache/clear') {
1312 $item['options']['alter'] = TRUE;
1313 }
1314 // Flag a link to be altered by hook_translated_menu_link_alter(), but only
1315 // if it is derived from a menu router item; i.e., do not alter a custom
1316 // menu link pointing to the same path that has been created by a user.
1317 if ($item['link_path'] == 'user' && $item['module'] == 'system') {
1318 $item['options']['alter'] = TRUE;
1319 }
1320 }
1321
1346 function hook_translated_menu_link_alter(&$item, $map) {
1347 if ($item['href'] == 'devel/cache/clear') {
1348 $item['localized_options']['query'] = drupal_get_destination();
1349 }
1350 }
1351
1365 function hook_menu_link_insert($link) {
1366 // In our sample case, we track menu items as editing sections
1367 // of the site. These are stored in our table as 'disabled' items.
1368 $record['mlid'] = $link['mlid'];
1369 $record['menu_name'] = $link['menu_name'];
1370 $record['status'] = 0;
1371 drupal_write_record('menu_example', $record);
1372 }
1373
1387 function hook_menu_link_update($link) {
1388 // If the parent menu has changed, update our record.
1389 $menu_name = db_query("SELECT menu_name FROM {menu_example} WHERE mlid = :mlid", array(':mlid' => $link['mlid']))->fetchField();
1390 if ($menu_name != $link['menu_name']) {
1391 db_update('menu_example')
1392 ->fields(array('menu_name' => $link['menu_name']))
1393 ->condition('mlid', $link['mlid'])
1394 ->execute();
1395 }
1396 }
1397
1411 function hook_menu_link_delete($link) {
1412 // Delete the record from our table.
1413 db_delete('menu_example')
1414 ->condition('mlid', $link['mlid'])
1415 ->execute();
1416 }
1417
1451 function hook_menu_local_tasks_alter(&$data, $router_item, $root_path) {
1452 // Add an action linking to node/add to all pages.
1453 $data['actions']['output'][] = array(
1454 '#theme' => 'menu_local_task',
1455 '#link' => array(
1456 'title' => t('Add new content'),
1457 'href' => 'node/add',
1458 'localized_options' => array(
1459 'attributes' => array(
1460 'title' => t('Add new content'),
1461 ),
1462 ),
1463 ),
1464 );
1465
1466 // Add a tab linking to node/add to all pages.
1467 $data['tabs'][0]['output'][] = array(
1468 '#theme' => 'menu_local_task',
1469 '#link' => array(
1470 'title' => t('Example tab'),
1471 'href' => 'node/add',
1472 'localized_options' => array(
1473 'attributes' => array(
1474 'title' => t('Add new content'),
1475 ),
1476 ),
1477 ),
1478 // Define whether this link is active. This can be omitted for
1479 // implementations that add links to pages outside of the current page
1480 // context.
1481 '#active' => ($router_item['path'] == $root_path),
1482 );
1483 }
1484
1519 function hook_menu_breadcrumb_alter(&$active_trail, $item) {
1520 // Always display a link to the current page by duplicating the last link in
1521 // the active trail. This means that menu_get_active_breadcrumb() will remove
1522 // the last link (for the current page), but since it is added once more here,
1523 // it will appear.
1524 if (!drupal_is_front_page()) {
1525 $end = end($active_trail);
1526 if ($item['href'] == $end['href']) {
1527 $active_trail[] = $end;
1528 }
1529 }
1530 }
1531
1561 function hook_menu_contextual_links_alter(&$links, $router_item, $root_path) {
1562 // Add a link to all contextual links for nodes.
1563 if ($root_path == 'node/%') {
1564 $links['foo'] = array(
1565 'title' => t('Do fu'),
1566 'href' => 'foo/do',
1567 'localized_options' => array(
1568 'query' => array(
1569 'foo' => 'bar',
1570 ),
1571 ),
1572 );
1573 }
1574 }
1575
1627 function hook_page_alter(&$page) {
1628 // Add help text to the user login block.
1629 $page['sidebar_first']['user_login']['help'] = array(
1630 '#weight' => -10,
1631 '#markup' => t('To post comments or add new content, you first have to log in.'),
1632 );
1633 }
1634
1671 function hook_form_alter(&$form, &$form_state, $form_id) {
1672 if (isset($form['type']) && $form['type']['#value'] . '_node_settings' == $form_id) {
1673 $form['workflow']['upload_' . $form['type']['#value']] = array(
1674 '#type' => 'radios',
1675 '#title' => t('Attachments'),
1676 '#default_value' => variable_get('upload_' . $form['type']['#value'], 1),
1677 '#options' => array(t('Disabled'), t('Enabled')),
1678 );
1679 }
1680 }
1681
1708 function hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
1709 // Modification for the form with the given form ID goes here. For example, if
1710 // FORM_ID is "user_register_form" this code would run only on the user
1711 // registration form.
1712
1713 // Add a checkbox to registration form about agreeing to terms of use.
1714 $form['terms_of_use'] = array(
1715 '#type' => 'checkbox',
1716 '#title' => t("I agree with the website's terms and conditions."),
1717 '#required' => TRUE,
1718 );
1719 }
1720
1757 function hook_form_BASE_FORM_ID_alter(&$form, &$form_state, $form_id) {
1758 // Modification for the form with the given BASE_FORM_ID goes here. For
1759 // example, if BASE_FORM_ID is "node_form", this code would run on every
1760 // node form, regardless of node type.
1761
1762 // Add a checkbox to the node form about agreeing to terms of use.
1763 $form['terms_of_use'] = array(
1764 '#type' => 'checkbox',
1765 '#title' => t("I agree with the website's terms and conditions."),
1766 '#required' => TRUE,
1767 );
1768 }
1769
1824 function hook_forms($form_id, $args) {
1825 // Simply reroute the (non-existing) $form_id 'mymodule_first_form' to
1826 // 'mymodule_main_form'.
1827 $forms['mymodule_first_form'] = array(
1828 'callback' => 'mymodule_main_form',
1829 );
1830
1831 // Reroute the $form_id and prepend an additional argument that gets passed to
1832 // the 'mymodule_main_form' form builder function.
1833 $forms['mymodule_second_form'] = array(
1834 'callback' => 'mymodule_main_form',
1835 'callback arguments' => array('some parameter'),
1836 );
1837
1838 // Reroute the $form_id, but invoke the form builder function
1839 // 'mymodule_main_form_wrapper' first, so we can prepopulate the $form array
1840 // that is passed to the actual form builder 'mymodule_main_form'.
1841 $forms['mymodule_wrapped_form'] = array(
1842 'callback' => 'mymodule_main_form',
1843 'wrapper_callback' => 'mymodule_main_form_wrapper',
1844 );
1845
1846 return $forms;
1847 }
1848
1861 function hook_boot() {
1862 // We need user_access() in the shutdown function. Make sure it gets loaded.
1863 drupal_load('module', 'user');
1864 drupal_register_shutdown_function('devel_shutdown');
1865 }
1866
1882 function hook_init() {
1883 // Since this file should only be loaded on the front page, it cannot be
1884 // declared in the info file.
1885 if (drupal_is_front_page()) {
1886 drupal_add_css(drupal_get_path('module', 'foo') . '/foo.css');
1887 }
1888 }
1889
1915 function hook_image_toolkits() {
1916 return array(
1917 'working' => array(
1918 'title' => t('A toolkit that works.'),
1919 'available' => TRUE,
1920 ),
1921 'broken' => array(
1922 'title' => t('A toolkit that is "broken" and will not be listed.'),
1923 'available' => FALSE,
1924 ),
1925 );
1926 }
1927
1974 function hook_mail_alter(&$message) {
1975 if ($message['id'] == 'modulename_messagekey') {
1976 if (!example_notifications_optin($message['to'], $message['id'])) {
1977 // If the recipient has opted to not receive such messages, cancel
1978 // sending.
1979 $message['send'] = FALSE;
1980 return;
1981 }
1982 $message['body'][] = "--\nMail sent out from " . variable_get('site_name', t('Drupal'));
1983 }
1984 }
1985
2009 function hook_module_implements_alter(&$implementations, $hook) {
2010 if ($hook == 'rdf_mapping') {
2011 // Move my_module_rdf_mapping() to the end of the list. module_implements()
2012 // iterates through $implementations with a foreach loop which PHP iterates
2013 // in the order that the items were added, so to move an item to the end of
2014 // the array, we remove it and then add it.
2015 $group = $implementations['my_module'];
2016 unset($implementations['my_module']);
2017 $implementations['my_module'] = $group;
2018 }
2019 }
2020
2035 function hook_system_theme_info() {
2036 $themes['mymodule_test_theme'] = drupal_get_path('module', 'mymodule') . '/mymodule_test_theme/mymodule_test_theme.info';
2037 return $themes;
2038 }
2039
2057 function hook_system_info_alter(&$info, $file, $type) {
2058 // Only fill this in if the .info file does not define a 'datestamp'.
2059 if (empty($info['datestamp'])) {
2060 $info['datestamp'] = filemtime($file->filename);
2061 }
2062 }
2063
2103 function hook_permission() {
2104 return array(
2105 'administer my module' => array(
2106 'title' => t('Administer my module'),
2107 'description' => t('Perform administration tasks for my module.'),
2108 ),
2109 );
2110 }
2111
2220 function hook_theme($existing, $type, $theme, $path) {
2221 return array(
2222 'forum_display' => array(
2223 'variables' => array('forums' => NULL, 'topics' => NULL, 'parents' => NULL, 'tid' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL),
2224 ),
2225 'forum_list' => array(
2226 'variables' => array('forums' => NULL, 'parents' => NULL, 'tid' => NULL),
2227 ),
2228 'forum_topic_list' => array(
2229 'variables' => array('tid' => NULL, 'topics' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL),
2230 ),
2231 'forum_icon' => array(
2232 'variables' => array('new_posts' => NULL, 'num_posts' => 0, 'comment_mode' => 0, 'sticky' => 0),
2233 ),
2234 'status_report' => array(
2235 'render element' => 'requirements',
2236 'file' => 'system.admin.inc',
2237 ),
2238 'system_date_time_settings' => array(
2239 'render element' => 'form',
2240 'file' => 'system.admin.inc',
2241 ),
2242 );
2243 }
2244
2282 function hook_theme_registry_alter(&$theme_registry) {
2283 // Kill the next/previous forum topic navigation links.
2284 foreach ($theme_registry['forum_topic_navigation']['preprocess functions'] as $key => $value) {
2285 if ($value == 'template_preprocess_forum_topic_navigation') {
2286 unset($theme_registry['forum_topic_navigation']['preprocess functions'][$key]);
2287 }
2288 }
2289 }
2290
2316 function hook_custom_theme() {
2317 // Allow the user to request a particular theme via a query parameter.
2318 if (isset($_GET['theme'])) {
2319 return $_GET['theme'];
2320 }
2321 }
2322
2356 function hook_xmlrpc() {
2357 return array(
2358 'drupal.login' => 'drupal_login',
2359 array(
2360 'drupal.site.ping',
2361 'drupal_directory_ping',
2362 array('boolean', 'string', 'string', 'string', 'string', 'string'),
2363 t('Handling ping request'))
2364 );
2365 }
2366
2384 function hook_xmlrpc_alter(&$methods) {
2385 // Directly change a simple method.
2386 $methods['drupal.login'] = 'mymodule_login';
2387
2388 // Alter complex definitions.
2389 foreach ($methods as $key => &$method) {
2390 // Skip simple method definitions.
2391 if (!is_int($key)) {
2392 continue;
2393 }
2394 // Perform the wanted manipulation.
2395 if ($method[0] == 'drupal.site.ping') {
2396 $method[1] = 'mymodule_directory_ping';
2397 }
2398 }
2399 }
2400
2438 function hook_watchdog(array $log_entry) {
2439 global $base_url, $language;
2440
2441 $severity_list = array(
2442 WATCHDOG_EMERGENCY => t('Emergency'),
2443 WATCHDOG_ALERT => t('Alert'),
2444 WATCHDOG_CRITICAL => t('Critical'),
2445 WATCHDOG_ERROR => t('Error'),
2446 WATCHDOG_WARNING => t('Warning'),
2447 WATCHDOG_NOTICE => t('Notice'),
2448 WATCHDOG_INFO => t('Info'),
2449 WATCHDOG_DEBUG => t('Debug'),
2450 );
2451
2452 $to = 'someone@example.com';
2453 $params = array();
2454 $params['subject'] = t('[@site_name] @severity_desc: Alert from your web site', array(
2455 '@site_name' => variable_get('site_name', 'Drupal'),
2456 '@severity_desc' => $severity_list[$log_entry['severity']],
2457 ));
2458
2459 $params['message'] = "\nSite: @base_url";
2460 $params['message'] .= "\nSeverity: (@severity) @severity_desc";
2461 $params['message'] .= "\nTimestamp: @timestamp";
2462 $params['message'] .= "\nType: @type";
2463 $params['message'] .= "\nIP Address: @ip";
2464 $params['message'] .= "\nRequest URI: @request_uri";
2465 $params['message'] .= "\nReferrer URI: @referer_uri";
2466 $params['message'] .= "\nUser: (@uid) @name";
2467 $params['message'] .= "\nLink: @link";
2468 $params['message'] .= "\nMessage: \n\n@message";
2469
2470 $params['message'] = t($params['message'], array(
2471 '@base_url' => $base_url,
2472 '@severity' => $log_entry['severity'],
2473 '@severity_desc' => $severity_list[$log_entry['severity']],
2474 '@timestamp' => format_date($log_entry['timestamp']),
2475 '@type' => $log_entry['type'],
2476 '@ip' => $log_entry['ip'],
2477 '@request_uri' => $log_entry['request_uri'],
2478 '@referer_uri' => $log_entry['referer'],
2479 '@uid' => $log_entry['uid'],
2480 '@name' => $log_entry['user']->name,
2481 '@link' => strip_tags($log_entry['link']),
2482 '@message' => strip_tags($log_entry['message']),
2483 ));
2484
2485 drupal_mail('emaillog', 'entry', $to, $language, $params);
2486 }
2487
2518 function hook_mail($key, &$message, $params) {
2519 $account = $params['account'];
2520 $context = $params['context'];
2521 $variables = array(
2522 '%site_name' => variable_get('site_name', 'Drupal'),
2523 '%username' => format_username($account),
2524 );
2525 if ($context['hook'] == 'taxonomy') {
2526 $entity = $params['entity'];
2527 $vocabulary = taxonomy_vocabulary_load($entity->vid);
2528 $variables += array(
2529 '%term_name' => $entity->name,
2530 '%term_description' => $entity->description,
2531 '%term_id' => $entity->tid,
2532 '%vocabulary_name' => $vocabulary->name,
2533 '%vocabulary_description' => $vocabulary->description,
2534 '%vocabulary_id' => $vocabulary->vid,
2535 );
2536 }
2537
2538 // Node-based variable translation is only available if we have a node.
2539 if (isset($params['node'])) {
2540 $node = $params['node'];
2541 $variables += array(
2542 '%uid' => $node->uid,
2543 '%node_url' => url('node/' . $node->nid, array('absolute' => TRUE)),
2544 '%node_type' => node_type_get_name($node),
2545 '%title' => $node->title,
2546 '%teaser' => $node->teaser,
2547 '%body' => $node->body,
2548 );
2549 }
2550 $subject = strtr($context['subject'], $variables);
2551 $body = strtr($context['message'], $variables);
2552 $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
2553 $message['body'][] = drupal_html_to_text($body);
2554 }
2555
2568 function hook_flush_caches() {
2569 return array('cache_example');
2570 }
2571
2588 function hook_modules_installed($modules) {
2589 if (in_array('lousy_module', $modules)) {
2590 variable_set('lousy_module_conflicting_variable', FALSE);
2591 }
2592 }
2593
2610 function hook_modules_enabled($modules) {
2611 if (in_array('lousy_module', $modules)) {
2612 drupal_set_message(t('mymodule is not compatible with lousy_module'), 'error');
2613 mymodule_disable_functionality();
2614 }
2615 }
2616
2630 function hook_modules_disabled($modules) {
2631 if (in_array('lousy_module', $modules)) {
2632 mymodule_enable_functionality();
2633 }
2634 }
2635
2652 function hook_modules_uninstalled($modules) {
2653 foreach ($modules as $module) {
2654 db_delete('mymodule_table')
2655 ->condition('module', $module)
2656 ->execute();
2657 }
2658 mymodule_cache_rebuild();
2659 }
2660
2691 function hook_stream_wrappers() {
2692 return array(
2693 'public' => array(
2694 'name' => t('Public files'),
2695 'class' => 'DrupalPublicStreamWrapper',
2696 'description' => t('Public local files served by the webserver.'),
2697 'type' => STREAM_WRAPPERS_LOCAL_NORMAL,
2698 ),
2699 'private' => array(
2700 'name' => t('Private files'),
2701 'class' => 'DrupalPrivateStreamWrapper',
2702 'description' => t('Private local files served by Drupal.'),
2703 'type' => STREAM_WRAPPERS_LOCAL_NORMAL,
2704 ),
2705 'temp' => array(
2706 'name' => t('Temporary files'),
2707 'class' => 'DrupalTempStreamWrapper',
2708 'description' => t('Temporary local files for upload and previews.'),
2709 'type' => STREAM_WRAPPERS_LOCAL_HIDDEN,
2710 ),
2711 'cdn' => array(
2712 'name' => t('Content delivery network files'),
2713 'class' => 'MyModuleCDNStreamWrapper',
2714 'description' => t('Files served by a content delivery network.'),
2715 // 'type' can be omitted to use the default of STREAM_WRAPPERS_NORMAL
2716 ),
2717 'youtube' => array(
2718 'name' => t('YouTube video'),
2719 'class' => 'MyModuleYouTubeStreamWrapper',
2720 'description' => t('Video streamed from YouTube.'),
2721 // A module implementing YouTube integration may decide to support using
2722 // the YouTube API for uploading video, but here, we assume that this
2723 // particular module only supports playing YouTube video.
2724 'type' => STREAM_WRAPPERS_READ_VISIBLE,
2725 ),
2726 );
2727 }
2728
2735 function hook_stream_wrappers_alter(&$wrappers) {
2736 // Change the name of private files to reflect the performance.
2737 $wrappers['private']['name'] = t('Slow files');
2738 }
2739
2752 function hook_file_load($files) {
2753 // Add the upload specific data into the file object.
2754 $result = db_query('SELECT * FROM {upload} u WHERE u.fid IN (:fids)', array(':fids' => array_keys($files)))->fetchAll(PDO::FETCH_ASSOC);
2755 foreach ($result as $record) {
2756 foreach ($record as $key => $value) {
2757 $files[$record['fid']]->$key = $value;
2758 }
2759 }
2760 }
2761
2776 function hook_file_validate($file) {
2777 $errors = array();
2778
2779 if (empty($file->filename)) {
2780 $errors[] = t("The file's name is empty. Please give a name to the file.");
2781 }
2782 if (strlen($file->filename) > 255) {
2783 $errors[] = t("The file's name exceeds the 255 characters limit. Please rename the file and try again.");
2784 }
2785
2786 return $errors;
2787 }
2788
2801 function hook_file_presave($file) {
2802 // Change the file timestamp to an hour prior.
2803 $file->timestamp -= 3600;
2804 }
2805
2818 function hook_file_insert($file) {
2819 // Add a message to the log, if the file is a jpg
2820 $validate = file_validate_extensions($file, 'jpg');
2821 if (empty($validate)) {
2822 watchdog('file', 'A jpg has been added.');
2823 }
2824 }
2825
2836 function hook_file_update($file) {
2837 $file_user = user_load($file->uid);
2838 // Make sure that the file name starts with the owner's user name.
2839 if (strpos($file->filename, $file_user->name) !== 0) {
2840 $old_filename = $file->filename;
2841 $file->filename = $file_user->name . '_' . $file->filename;
2842 $file->save();
2843
2844 watchdog('file', t('%source has been renamed to %destination', array('%source' => $old_filename, '%destination' => $file->filename)));
2845 }
2846 }
2847
2858 function hook_file_copy($file, $source) {
2859 $file_user = user_load($file->uid);
2860 // Make sure that the file name starts with the owner's user name.
2861 if (strpos($file->filename, $file_user->name) !== 0) {
2862 $file->filename = $file_user->name . '_' . $file->filename;
2863 $file->save();
2864
2865 watchdog('file', t('Copied file %source has been renamed to %destination', array('%source' => $source->filename, '%destination' => $file->filename)));
2866 }
2867 }
2868
2879 function hook_file_move($file, $source) {
2880 $file_user = user_load($file->uid);
2881 // Make sure that the file name starts with the owner's user name.
2882 if (strpos($file->filename, $file_user->name) !== 0) {
2883 $file->filename = $file_user->name . '_' . $file->filename;
2884 $file->save();
2885
2886 watchdog('file', t('Moved file %source has been renamed to %destination', array('%source' => $source->filename, '%destination' => $file->filename)));
2887 }
2888 }
2889
2898 function hook_file_delete($file) {
2899 // Delete all information associated with the file.
2900 db_delete('upload')->condition('fid', $file->fid)->execute();
2901 }
2902
2920 function hook_file_download($uri) {
2921 // Check if the file is controlled by the current module.
2922 if (!file_prepare_directory($uri)) {
2923 $uri = FALSE;
2924 }
2925 if (strpos(file_uri_target($uri), variable_get('user_picture_path', 'pictures') . '/picture-') === 0) {
2926 if (!user_access('access user profiles')) {
2927 // Access to the file is denied.
2928 return -1;
2929 }
2930 else {
2931 $info = image_get_info($uri);
2932 return array('Content-Type' => $info['mime_type']);
2933 }
2934 }
2935 }
2936
2952 function hook_file_url_alter(&$uri) {
2953 global $user;
2954
2955 // User 1 will always see the local file in this example.
2956 if ($user->uid == 1) {
2957 return;
2958 }
2959
2960 $cdn1 = 'http://cdn1.example.com';
2961 $cdn2 = 'http://cdn2.example.com';
2962 $cdn_extensions = array('css', 'js', 'gif', 'jpg', 'jpeg', 'png');
2963
2964 // Most CDNs don't support private file transfers without a lot of hassle,
2965 // so don't support this in the common case.
2966 $schemes = array('public');
2967
2968 $scheme = file_uri_scheme($uri);
2969
2970 // Only serve shipped files and public created files from the CDN.
2971 if (!$scheme || in_array($scheme, $schemes)) {
2972 // Shipped files.
2973 if (!$scheme) {
2974 $path = $uri;
2975 }
2976 // Public created files.
2977 else {
2978 $wrapper = file_stream_wrapper_get_instance_by_scheme($scheme);
2979 $path = $wrapper->getDirectoryPath() . '/' . file_uri_target($uri);
2980 }
2981
2982 // Clean up Windows paths.
2983 $path = str_replace('\\', '/', $path);
2984
2985 // Serve files with one of the CDN extensions from CDN 1, all others from
2986 // CDN 2.
2987 $pathinfo = pathinfo($path);
2988 if (isset($pathinfo['extension']) && in_array($pathinfo['extension'], $cdn_extensions)) {
2989 $uri = $cdn1 . '/' . $path;
2990 }
2991 else {
2992 $uri = $cdn2 . '/' . $path;
2993 }
2994 }
2995 }
2996
3053 function hook_requirements($phase) {
3054 $requirements = array();
3055 // Ensure translations don't break during installation.
3056 $t = get_t();
3057
3058 // Report Drupal version
3059 if ($phase == 'runtime') {
3060 $requirements['drupal'] = array(
3061 'title' => $t('Drupal'),
3062 'value' => VERSION,
3063 'severity' => REQUIREMENT_INFO
3064 );
3065 }
3066
3067 // Test PHP version
3068 $requirements['php'] = array(
3069 'title' => $t('PHP'),
3070 'value' => ($phase == 'runtime') ? l(phpversion(), 'admin/reports/status/php') : phpversion(),
3071 );
3072 if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) {
3073 $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP));
3074 $requirements['php']['severity'] = REQUIREMENT_ERROR;
3075 }
3076
3077 // Report cron status
3078 if ($phase == 'runtime') {
3079 $cron_last = variable_get('cron_last');
3080
3081 if (is_numeric($cron_last)) {
3082 $requirements['cron']['value'] = $t('Last run !time ago', array('!time' => format_interval(REQUEST_TIME - $cron_last)));
3083 }
3084 else {
3085 $requirements['cron'] = array(
3086 'description' => $t('Cron has not run. It appears cron jobs have not been setup on your system. Check the help pages for <a href="@url">configuring cron jobs</a>.', array('@url' => 'http://drupal.org/cron')),
3087 'severity' => REQUIREMENT_ERROR,
3088 'value' => $t('Never run'),
3089 );
3090 }
3091
3092 $requirements['cron']['description'] .= ' ' . $t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/reports/status/run-cron')));
3093
3094 $requirements['cron']['title'] = $t('Cron maintenance tasks');
3095 }
3096
3097 return $requirements;
3098 }
3099
3133 function hook_schema() {
3134 $schema['node'] = array(
3135 // Example (partial) specification for table "node".
3136 'description' => 'The base table for nodes.',
3137 'fields' => array(
3138 'nid' => array(
3139 'description' => 'The primary identifier for a node.',
3140 'type' => 'serial',
3141 'unsigned' => TRUE,
3142 'not null' => TRUE,
3143 ),
3144 'vid' => array(
3145 'description' => 'The current {node_revision}.vid version identifier.',
3146 'type' => 'int',
3147 'unsigned' => TRUE,
3148 'not null' => TRUE,
3149 'default' => 0,
3150 ),
3151 'type' => array(
3152 'description' => 'The {node_type} of this node.',
3153 'type' => 'varchar',
3154 'length' => 32,
3155 'not null' => TRUE,
3156 'default' => '',
3157 ),
3158 'title' => array(
3159 'description' => 'The title of this node, always treated as non-markup plain text.',
3160 'type' => 'varchar',
3161 'length' => 255,
3162 'not null' => TRUE,
3163 'default' => '',
3164 ),
3165 ),
3166 'indexes' => array(
3167 'node_changed' => array('changed'),
3168 'node_created' => array('created'),
3169 ),
3170 'unique keys' => array(
3171 'nid_vid' => array('nid', 'vid'),
3172 'vid' => array('vid'),
3173 ),
3174 'foreign keys' => array(
3175 'node_revision' => array(
3176 'table' => 'node_revision',
3177 'columns' => array('vid' => 'vid'),
3178 ),
3179 'node_author' => array(
3180 'table' => 'users',
3181 'columns' => array('uid' => 'uid'),
3182 ),
3183 ),
3184 'primary key' => array('nid'),
3185 );
3186 return $schema;
3187 }
3188
3204 function hook_schema_alter(&$schema) {
3205 // Add field to existing schema.
3206 $schema['users']['fields']['timezone_id'] = array(
3207 'type' => 'int',
3208 'not null' => TRUE,
3209 'default' => 0,
3210 'description' => 'Per-user timezone configuration.',
3211 );
3212 }
3213
3228 function hook_query_alter(QueryAlterableInterface $query) {
3229 if ($query->hasTag('micro_limit')) {
3230 $query->range(0, 2);
3231 }
3232 }
3233
3245 function hook_query_TAG_alter(QueryAlterableInterface $query) {
3246 // Skip the extra expensive alterations if site has no node access control modules.
3247 if (!node_access_view_all_nodes()) {
3248 // Prevent duplicates records.
3249 $query->distinct();
3250 // The recognized operations are 'view', 'update', 'delete'.
3251 if (!$op = $query->getMetaData('op')) {
3252 $op = 'view';
3253 }
3254 // Skip the extra joins and conditions for node admins.
3255 if (!user_access('bypass node access')) {
3256 // The node_access table has the access grants for any given node.
3257 $access_alias = $query->join('node_access', 'na', '%alias.nid = n.nid');
3258 $or = db_or();
3259 // If any grant exists for the specified user, then user has access to the node for the specified operation.
3260 foreach (node_access_grants($op, $query->getMetaData('account')) as $realm => $gids) {
3261 foreach ($gids as $gid) {
3262 $or->condition(db_and()
3263 ->condition($access_alias . '.gid', $gid)
3264 ->condition($access_alias . '.realm', $realm)
3265 );
3266 }
3267 }
3268
3269 if (count($or->conditions())) {
3270 $query->condition($or);
3271 }
3272
3273 $query->condition($access_alias . 'grant_' . $op, 1, '>=');
3274 }
3275 }
3276 }
3277
3310 function hook_install() {
3311 // Populate the default {node_access} record.
3312 db_insert('node_access')
3313 ->fields(array(
3314 'nid' => 0,
3315 'gid' => 0,
3316 'realm' => 'all',
3317 'grant_view' => 1,
3318 'grant_update' => 0,
3319 'grant_delete' => 0,
3320 ))
3321 ->execute();
3322 }
3323
3402 function hook_update_N(&$sandbox) {
3403 // For non-multipass updates, the signature can simply be;
3404 // function hook_update_N() {
3405
3406 // For most updates, the following is sufficient.
3407 db_add_field('mytable1', 'newcol', array('type' => 'int', 'not null' => TRUE, 'description' => 'My new integer column.'));
3408
3409 // However, for more complex operations that may take a long time,
3410 // you may hook into Batch API as in the following example.
3411
3412 // Update 3 users at a time to have an exclamation point after their names.
3413 // (They're really happy that we can do batch API in this hook!)
3414 if (!isset($sandbox['progress'])) {
3415 $sandbox['progress'] = 0;
3416 $sandbox['current_uid'] = 0;
3417 // We'll -1 to disregard the uid 0...
3418 $sandbox['max'] = db_query('SELECT COUNT(DISTINCT uid) FROM {users}')->fetchField() - 1;
3419 }
3420
3421 $users = db_select('users', 'u')
3422 ->fields('u', array('uid', 'name'))
3423 ->condition('uid', $sandbox['current_uid'], '>')
3424 ->range(0, 3)
3425 ->orderBy('uid', 'ASC')
3426 ->execute();
3427
3428 foreach ($users as $user) {
3429 $user->name .= '!';
3430 db_update('users')
3431 ->fields(array('name' => $user->name))
3432 ->condition('uid', $user->uid)
3433 ->execute();
3434
3435 $sandbox['progress']++;
3436 $sandbox['current_uid'] = $user->uid;
3437 }
3438
3439 $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
3440
3441 // To display a message to the user when the update is completed, return it.
3442 // If you do not want to display a completion message, simply return nothing.
3443 return t('The update did what it was supposed to do.');
3444
3445 // In case of an error, simply throw an exception with an error message.
3446 throw new DrupalUpdateException('Something went wrong; here is what you should do.');
3447 }
3448
3474 function hook_update_dependencies() {
3475 // Indicate that the mymodule_update_7000() function provided by this module
3476 // must run after the another_module_update_7002() function provided by the
3477 // 'another_module' module.
3478 $dependencies['mymodule'][7000] = array(
3479 'another_module' => 7002,
3480 );
3481 // Indicate that the mymodule_update_7001() function provided by this module
3482 // must run before the yet_another_module_update_7004() function provided by
3483 // the 'yet_another_module' module. (Note that declaring dependencies in this
3484 // direction should be done only in rare situations, since it can lead to the
3485 // following problem: If a site has already run the yet_another_module
3486 // module's database updates before it updates its codebase to pick up the
3487 // newest mymodule code, then the dependency declared here will be ignored.)
3488 $dependencies['yet_another_module'][7004] = array(
3489 'mymodule' => 7001,
3490 );
3491 return $dependencies;
3492 }
3493
3510 function hook_update_last_removed() {
3511 // We've removed the 5.x-1.x version of mymodule, including database updates.
3512 // The next update function is mymodule_update_5200().
3513 return 5103;
3514 }
3515
3544 function hook_uninstall() {
3545 variable_del('upload_file_types');
3546 }
3547
3559 function hook_enable() {
3560 mymodule_cache_rebuild();
3561 }
3562
3573 function hook_disable() {
3574 mymodule_cache_rebuild();
3575 }
3576
3615 function hook_registry_files_alter(&$files, $modules) {
3616 foreach ($modules as $module) {
3617 // Only add test files for disabled modules, as enabled modules should
3618 // already include any test files they provide.
3619 if (!$module->status) {
3620 $dir = $module->dir;
3621 foreach ($module->info['files'] as $file) {
3622 if (substr($file, -5) == '.test') {
3623 $files["$dir/$file"] = array('module' => $module->name, 'weight' => $module->weight);
3624 }
3625 }
3626 }
3627 }
3628 }
3629
3730 function hook_install_tasks(&$install_state) {
3731 // Here, we define a variable to allow tasks to indicate that a particular,
3732 // processor-intensive batch process needs to be triggered later on in the
3733 // installation.
3734 $myprofile_needs_batch_processing = variable_get('myprofile_needs_batch_processing', FALSE);
3735 $tasks = array(
3736 // This is an example of a task that defines a form which the user who is
3737 // installing the site will be asked to fill out. To implement this task,
3738 // your profile would define a function named myprofile_data_import_form()
3739 // as a normal form API callback function, with associated validation and
3740 // submit handlers. In the submit handler, in addition to saving whatever
3741 // other data you have collected from the user, you might also call
3742 // variable_set('myprofile_needs_batch_processing', TRUE) if the user has
3743 // entered data which requires that batch processing will need to occur
3744 // later on.
3745 'myprofile_data_import_form' => array(
3746 'display_name' => st('Data import options'),
3747 'type' => 'form',
3748 ),
3749 // Similarly, to implement this task, your profile would define a function
3750 // named myprofile_settings_form() with associated validation and submit
3751 // handlers. This form might be used to collect and save additional
3752 // information from the user that your profile needs. There are no extra
3753 // steps required for your profile to act as an "installation wizard"; you
3754 // can simply define as many tasks of type 'form' as you wish to execute,
3755 // and the forms will be presented to the user, one after another.
3756 'myprofile_settings_form' => array(
3757 'display_name' => st('Additional options'),
3758 'type' => 'form',
3759 ),
3760 // This is an example of a task that performs batch operations. To
3761 // implement this task, your profile would define a function named
3762 // myprofile_batch_processing() which returns a batch API array definition
3763 // that the installer will use to execute your batch operations. Due to the
3764 // 'myprofile_needs_batch_processing' variable used here, this task will be
3765 // hidden and skipped unless your profile set it to TRUE in one of the
3766 // previous tasks.
3767 'myprofile_batch_processing' => array(
3768 'display_name' => st('Import additional data'),
3769 'display' => $myprofile_needs_batch_processing,
3770 'type' => 'batch',
3771 'run' => $myprofile_needs_batch_processing ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
3772 ),
3773 // This is an example of a task that will not be displayed in the list that
3774 // the user sees. To implement this task, your profile would define a
3775 // function named myprofile_final_site_setup(), in which additional,
3776 // automated site setup operations would be performed. Since this is the
3777 // last task defined by your profile, you should also use this function to
3778 // call variable_del('myprofile_needs_batch_processing') and clean up the
3779 // variable that was used above. If you want the user to pass to the final
3780 // Drupal installation tasks uninterrupted, return no output from this
3781 // function. Otherwise, return themed output that the user will see (for
3782 // example, a confirmation page explaining that your profile's tasks are
3783 // complete, with a link to reload the current page and therefore pass on
3784 // to the final Drupal installation tasks when the user is ready to do so).
3785 'myprofile_final_site_setup' => array(
3786 ),
3787 );
3788 return $tasks;
3789 }
3790
3802 function hook_drupal_goto_alter(&$path, &$options, &$http_response_code) {
3803 // A good addition to misery module.
3804 $http_response_code = 500;
3805 }
3806
3819 function hook_html_head_alter(&$head_elements) {
3820 foreach ($head_elements as $key => $element) {
3821 if (isset($element['#attributes']['rel']) && $element['#attributes']['rel'] == 'canonical') {
3822 // I want a custom canonical URL.
3823 $head_elements[$key]['#attributes']['href'] = mymodule_canonical_url();
3824 }
3825 }
3826 }
3827
3839 function hook_install_tasks_alter(&$tasks, $install_state) {
3840 // Replace the "Choose language" installation task provided by Drupal core
3841 // with a custom callback function defined by this installation profile.
3842 $tasks['install_select_locale']['function'] = 'myprofile_locale_selection';
3843 }
3844
3859 function hook_file_mimetype_mapping_alter(&$mapping) {
3860 // Add new MIME type 'drupal/info'.
3861 $mapping['mimetypes']['example_info'] = 'drupal/info';
3862 // Add new extension '.info' and map it to the 'drupal/info' MIME type.
3863 $mapping['extensions']['info'] = 'example_info';
3864 // Override existing extension mapping for '.ogg' files.
3865 $mapping['extensions']['ogg'] = 189;
3866 }
3867
3916 function hook_action_info() {
3917 return array(
3918 'comment_unpublish_action' => array(
3919 'type' => 'comment',
3920 'label' => t('Unpublish comment'),
3921 'configurable' => FALSE,
3922 'behavior' => array('changes_property'),
3923 'triggers' => array('comment_presave', 'comment_insert', 'comment_update'),
3924 ),
3925 'comment_unpublish_by_keyword_action' => array(
3926 'type' => 'comment',
3927 'label' => t('Unpublish comment containing keyword(s)'),
3928 'configurable' => TRUE,
3929 'behavior' => array('changes_property'),
3930 'triggers' => array('comment_presave', 'comment_insert', 'comment_update'),
3931 ),
3932 'comment_save_action' => array(
3933 'type' => 'comment',
3934 'label' => t('Save comment'),
3935 'configurable' => FALSE,
3936 'triggers' => array('comment_insert', 'comment_update'),
3937 ),
3938 );
3939 }
3940
3947 function hook_actions_delete($aid) {
3948 db_delete('actions_assignments')
3949 ->condition('aid', $aid)
3950 ->execute();
3951 }
3952
3961 function hook_action_info_alter(&$actions) {
3962 $actions['node_unpublish_action']['label'] = t('Unpublish and remove from public view.');
3963 }
3964
3983 function hook_archiver_info() {
3984 return array(
3985 'tar' => array(
3986 'class' => 'ArchiverTar',
3987 'extensions' => array('tar', 'tar.gz', 'tar.bz2'),
3988 ),
3989 );
3990 }
3991
4001 function hook_archiver_info_alter(&$info) {
4002 $info['tar']['extensions'][] = 'tgz';
4003 }
4004
4036 function hook_date_format_types() {
4037 // Define the core date format types.
4038 return array(
4039 'long' => t('Long'),
4040 'medium' => t('Medium'),
4041 'short' => t('Short'),
4042 );
4043 }
4044
4062 function hook_date_format_types_alter(&$types) {
4063 foreach ($types as $name => $type) {
4064 $types[$name]['locked'] = 1;
4065 }
4066 }
4067
4110 function hook_date_formats() {
4111 return array(
4112 array(
4113 'type' => 'mymodule_extra_long',
4114 'format' => 'l jS F Y H:i:s e',
4115 'locales' => array('en-ie'),
4116 ),
4117 array(
4118 'type' => 'mymodule_extra_long',
4119 'format' => 'l jS F Y h:i:sa',
4120 'locales' => array('en', 'en-us'),
4121 ),
4122 array(
4123 'type' => 'short',
4124 'format' => 'F Y',
4125 'locales' => array(),
4126 ),
4127 );
4128 }
4129
4136 function hook_date_formats_alter(&$formats) {
4137 foreach ($formats as $id => $format) {
4138 $formats[$id]['locales'][] = 'en-ca';
4139 }
4140 }
4141
4178 function hook_page_delivery_callback_alter(&$callback) {
4179 // jQuery sets a HTTP_X_REQUESTED_WITH header of 'XMLHttpRequest'.
4180 // If a page would normally be delivered as an html page, and it is called
4181 // from jQuery, deliver it instead as an Ajax response.
4182 if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' && $callback == 'drupal_deliver_html_page') {
4183 $callback = 'ajax_deliver';
4184 }
4185 }
4186
4195 function hook_system_themes_page_alter(&$theme_groups) {
4196 foreach ($theme_groups as $state => &$group) {
4197 foreach ($theme_groups[$state] as &$theme) {
4198 // Add a foo link to each list of theme operations.
4199 $theme->operations[] = array(
4200 'title' => t('Foo'),
4201 'href' => 'admin/appearance/foo',
4202 'query' => array('theme' => $theme->name)
4203 );
4204 }
4205 }
4206 }
4207
4223 function hook_url_inbound_alter(&$path, $original_path, $path_language) {
4224 // Create the path user/me/edit, which allows a user to edit their account.
4225 if (preg_match('|^user/me/edit(/.*)?|', $path, $matches)) {
4226 global $user;
4227 $path = 'user/' . $user->uid . '/edit' . $matches[1];
4228 }
4229 }
4230
4248 function hook_url_outbound_alter(&$path, &$options, $original_path) {
4249 // Use an external RSS feed rather than the Drupal one.
4250 if ($path == 'rss.xml') {
4251 $path = 'http://example.com/rss.xml';
4252 $options['external'] = TRUE;
4253 }
4254
4255 // Instead of pointing to user/[uid]/edit, point to user/me/edit.
4256 if (preg_match('|^user/([0-9]*)/edit(/.*)?|', $path, $matches)) {
4257 global $user;
4258 if ($user->uid == $matches[1]) {
4259 $path = 'user/me/edit' . $matches[2];
4260 }
4261 }
4262 }
4263
4279 function hook_username_alter(&$name, $account) {
4280 // Display the user's uid instead of name.
4281 if (isset($account->uid)) {
4282 $name = t('User !uid', array('!uid' => $account->uid));
4283 }
4284 }
4285
4320 function hook_tokens($type, $tokens, array $data = array(), array $options = array()) {
4321 $url_options = array('absolute' => TRUE);
4322 if (isset($options['language'])) {
4323 $url_options['language'] = $options['language'];
4324 $language_code = $options['language']->language;
4325 }
4326 else {
4327 $language_code = NULL;
4328 }
4329 $sanitize = !empty($options['sanitize']);
4330
4331 $replacements = array();
4332
4333 if ($type == 'node' && !empty($data['node'])) {
4334 $node = $data['node'];
4335
4336 foreach ($tokens as $name => $original) {
4337 switch ($name) {
4338 // Simple key values on the node.
4339 case 'nid':
4340 $replacements[$original] = $node->nid;
4341 break;
4342
4343 case 'title':
4344 $replacements[$original] = $sanitize ? check_plain($node->title) : $node->title;
4345 break;
4346
4347 case 'edit-url':
4348 $replacements[$original] = url('node/' . $node->nid . '/edit', $url_options);
4349 break;
4350
4351 // Default values for the chained tokens handled below.
4352 case 'author':
4353 $name = ($node->uid == 0) ? variable_get('anonymous', t('Anonymous')) : $node->name;
4354 $replacements[$original] = $sanitize ? filter_xss($name) : $name;
4355 break;
4356
4357 case 'created':
4358 $replacements[$original] = format_date($node->created, 'medium', '', NULL, $language_code);
4359 break;
4360 }
4361 }
4362
4363 if ($author_tokens = token_find_with_prefix($tokens, 'author')) {
4364 $author = user_load($node->uid);
4365 $replacements += token_generate('user', $author_tokens, array('user' => $author), $options);
4366 }
4367
4368 if ($created_tokens = token_find_with_prefix($tokens, 'created')) {
4369 $replacements += token_generate('date', $created_tokens, array('date' => $node->created), $options);
4370 }
4371 }
4372
4373 return $replacements;
4374 }
4375
4392 function hook_tokens_alter(array &$replacements, array $context) {
4393 $options = $context['options'];
4394
4395 if (isset($options['language'])) {
4396 $url_options['language'] = $options['language'];
4397 $language_code = $options['language']->language;
4398 }
4399 else {
4400 $language_code = NULL;
4401 }
4402 $sanitize = !empty($options['sanitize']);
4403
4404 if ($context['type'] == 'node' && !empty($context['data']['node'])) {
4405 $node = $context['data']['node'];
4406
4407 // Alter the [node:title] token, and replace it with the rendered content
4408 // of a field (field_title).
4409 if (isset($context['tokens']['title'])) {
4410 $title = field_view_field('node', $node, 'field_title', 'default', $language_code);
4411 $replacements[$context['tokens']['title']] = drupal_render($title);
4412 }
4413 }
4414 }
4415
4460 function hook_token_info() {
4461 $type = array(
4462 'name' => t('Nodes'),
4463 'description' => t('Tokens related to individual nodes.'),
4464 'needs-data' => 'node',
4465 );
4466
4467 // Core tokens for nodes.
4468 $node['nid'] = array(
4469 'name' => t("Node ID"),
4470 'description' => t("The unique ID of the node."),
4471 );
4472 $node['title'] = array(
4473 'name' => t("Title"),
4474 'description' => t("The title of the node."),
4475 );
4476 $node['edit-url'] = array(
4477 'name' => t("Edit URL"),
4478 'description' => t("The URL of the node's edit page."),
4479 );
4480
4481 // Chained tokens for nodes.
4482 $node['created'] = array(
4483 'name' => t("Date created"),
4484 'description' => t("The date the node was posted."),
4485 'type' => 'date',
4486 );
4487 $node['author'] = array(
4488 'name' => t("Author"),
4489 'description' => t("The author of the node."),
4490 'type' => 'user',
4491 );
4492
4493 return array(
4494 'types' => array('node' => $type),
4495 'tokens' => array('node' => $node),
4496 );
4497 }
4498
4507 function hook_token_info_alter(&$data) {
4508 // Modify description of node tokens for our site.
4509 $data['tokens']['node']['nid'] = array(
4510 'name' => t("Node ID"),
4511 'description' => t("The unique ID of the article."),
4512 );
4513 $data['tokens']['node']['title'] = array(
4514 'name' => t("Title"),
4515 'description' => t("The title of the article."),
4516 );
4517
4518 // Chained tokens for nodes.
4519 $data['tokens']['node']['created'] = array(
4520 'name' => t("Date created"),
4521 'description' => t("The date the article was posted."),
4522 'type' => 'date',
4523 );
4524 }
4525
4541 function hook_batch_alter(&$batch) {
4542 // If the current page request is inside the overlay, add ?render=overlay to
4543 // the success callback URL, so that it appears correctly within the overlay.
4544 if (overlay_get_mode() == 'child') {
4545 if (isset($batch['url_options']['query'])) {
4546 $batch['url_options']['query']['render'] = 'overlay';
4547 }
4548 else {
4549 $batch['url_options']['query'] = array('render' => 'overlay');
4550 }
4551 }
4552 }
4553
4578 function hook_updater_info() {
4579 return array(
4580 'module' => array(
4581 'class' => 'ModuleUpdater',
4582 'name' => t('Update modules'),
4583 'weight' => 0,
4584 ),
4585 'theme' => array(
4586 'class' => 'ThemeUpdater',
4587 'name' => t('Update themes'),
4588 'weight' => 0,
4589 ),
4590 );
4591 }
4592
4607 function hook_updater_info_alter(&$updaters) {
4608 // Adjust weight so that the theme Updater gets a chance to handle a given
4609 // update task before module updaters.
4610 $updaters['theme']['weight'] = -1;
4611 }
4612
4622 function hook_countries_alter(&$countries) {
4623 // Elbonia is now independent, so add it to the country list.
4624 $countries['EB'] = 'Elbonia';
4625 }
4626
4645 function hook_menu_site_status_alter(&$menu_site_status, $path) {
4646 // Allow access to my_module/authentication even if site is in offline mode.
4647 if ($menu_site_status == MENU_SITE_OFFLINE && user_is_anonymous() && $path == 'my_module/authentication') {
4648 $menu_site_status = MENU_SITE_ONLINE;
4649 }
4650 }
4651
4687 function hook_filetransfer_info() {
4688 $info['sftp'] = array(
4689 'title' => t('SFTP (Secure FTP)'),
4690 'file' => 'sftp.filetransfer.inc',
4691 'class' => 'FileTransferSFTP',
4692 'weight' => 10,
4693 );
4694 return $info;
4695 }
4696
4706 function hook_filetransfer_info_alter(&$filetransfer_info) {
4707 if (variable_get('paranoia', FALSE)) {
4708 // Remove the FTP option entirely.
4709 unset($filetransfer_info['ftp']);
4710 // Make sure the SSH option is listed first.
4711 $filetransfer_info['ssh']['weight'] = -10;
4712 }
4713 }
4714
4739 function callback_entity_info_uri($entity) {
4740 return array(
4741 'path' => 'node/' . $entity->nid,
4742 );
4743 }
4744
4760 function callback_entity_info_label($entity, $entity_type) {
4761 return empty($entity->title) ? 'Untitled entity' : $entity->title;
4762 }
4763
4782 function callback_entity_info_language($entity, $entity_type) {
4783 return $entity->language;
4784 }
4785
hook_library_alter
hook_library_alter(&$libraries, $module)
Definition: system.api.php:842
hook_menu_site_status_alter
hook_menu_site_status_alter(&$menu_site_status, $path)
Definition: system.api.php:4645
hook_page_build
hook_page_build(&$page)
Definition: system.api.php:905
hook_menu_alter
hook_menu_alter(&$items)
Definition: system.api.php:1292
hook_library
hook_library()
Definition: system.api.php:786
hook_filetransfer_info
hook_filetransfer_info()
Definition: system.api.php:4687
hook_install
hook_install()
Definition: system.api.php:3310
hook_page_alter
hook_page_alter(&$page)
Definition: system.api.php:1627
drupal_is_front_page
drupal_is_front_page()
Definition: path.inc:284
hook_query_TAG_alter
hook_query_TAG_alter(QueryAlterableInterface $query)
Definition: system.api.php:3245
MENU_SITE_ONLINE
const MENU_SITE_ONLINE
Definition: menu.inc:249
hook_menu_link_update
hook_menu_link_update($link)
Definition: system.api.php:1387
$op
$op
Definition: update.php:404
hook_action_info_alter
hook_action_info_alter(&$actions)
Definition: system.api.php:3961
QueryAlterableInterface
Definition: query.inc:166
hook_hook_info_alter
hook_hook_info_alter(&$hooks)
Definition: system.api.php:55
token_generate
token_generate($type, array $tokens, array $data=array(), array $options=array())
Definition: token.inc:176
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
l
l($text, $path, array $options=array())
Definition: common.inc:2432
hook_admin_paths_alter
hook_admin_paths_alter(&$paths)
Definition: system.api.php:525
callback_entity_info_language
callback_entity_info_language($entity, $entity_type)
Definition: system.api.php:4782
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
hook_entity_load
hook_entity_load($entities, $type)
Definition: system.api.php:302
hook_entity_delete
hook_entity_delete($entity, $type)
Definition: system.api.php:371
hook_url_outbound_alter
hook_url_outbound_alter(&$path, &$options, $original_path)
Definition: system.api.php:4248
DrupalQueue\get
static get($name, $reliable=FALSE)
Definition: system.queue.inc:81
QueryAlterableInterface\hasTag
hasTag($tag)
hook_css_alter
hook_css_alter(&$css)
Definition: system.api.php:865
hook_boot
hook_boot()
Definition: system.api.php:1861
INSTALL_TASK_SKIP
const INSTALL_TASK_SKIP
Definition: install.core.inc:19
hook_xmlrpc
hook_xmlrpc()
Definition: system.api.php:2356
hook_entity_presave
hook_entity_presave($entity, $type)
Definition: system.api.php:316
WATCHDOG_INFO
const WATCHDOG_INFO
Definition: bootstrap.inc:108
hook_ajax_render_alter
hook_ajax_render_alter($commands)
Definition: system.api.php:878
$module
print $module
Definition: search-results.tpl.php:28
format_username
format_username($account)
Definition: common.inc:2106
drupal_mail
drupal_mail($module, $key, $to, $language, $params=array(), $from=NULL, $send=TRUE)
Definition: mail.inc:122
$page
print $page
Definition: overlay.tpl.php:37
hook_menu_link_insert
hook_menu_link_insert($link)
Definition: system.api.php:1365
hook_mail_alter
hook_mail_alter(&$message)
Definition: system.api.php:1974
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
field_view_field
field_view_field($entity_type, $entity, $field_name, $display=array(), $langcode=NULL)
Definition: field.module:870
MENU_SITE_OFFLINE
const MENU_SITE_OFFLINE
Definition: menu.inc:244
variable_del
variable_del($name)
Definition: bootstrap.inc:996
hook_update_last_removed
hook_update_last_removed()
Definition: system.api.php:3510
hook_file_update
hook_file_update($file)
Definition: system.api.php:2836
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
hook_username_alter
hook_username_alter(&$name, $account)
Definition: system.api.php:4279
hook_archiver_info
hook_archiver_info()
Definition: system.api.php:3983
$name
print $name
Definition: profile-listing.tpl.php:43
hook_menu_link_delete
hook_menu_link_delete($link)
Definition: system.api.php:1411
hook_file_url_alter
hook_file_url_alter(&$uri)
Definition: system.api.php:2952
hook_page_delivery_callback_alter
hook_page_delivery_callback_alter(&$callback)
Definition: system.api.php:4178
name
print $forum name
Definition: forum-list.tpl.php:57
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
hook_token_info
hook_token_info()
Definition: system.api.php:4460
hook_tokens
hook_tokens($type, $tokens, array $data=array(), array $options=array())
Definition: system.api.php:4320
hook_system_themes_page_alter
hook_system_themes_page_alter(&$theme_groups)
Definition: system.api.php:4195
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
hook_file_validate
hook_file_validate($file)
Definition: system.api.php:2776
hook_xmlrpc_alter
hook_xmlrpc_alter(&$methods)
Definition: system.api.php:2384
INSTALL_TASK_RUN_IF_NOT_COMPLETED
const INSTALL_TASK_RUN_IF_NOT_COMPLETED
Definition: install.core.inc:40
hook_form_alter
hook_form_alter(&$form, &$form_state, $form_id)
Definition: system.api.php:1671
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
module_exists
module_exists($module)
Definition: module.inc:274
hook_stream_wrappers_alter
hook_stream_wrappers_alter(&$wrappers)
Definition: system.api.php:2735
file_stream_wrapper_get_instance_by_scheme
file_stream_wrapper_get_instance_by_scheme($scheme)
Definition: file.inc:336
file_validate_extensions
file_validate_extensions(stdClass $file, $extensions)
Definition: file.inc:1713
hook_install_tasks
hook_install_tasks(&$install_state)
Definition: system.api.php:3730
hook_mail
hook_mail($key, &$message, $params)
Definition: system.api.php:2518
db_add_field
db_add_field($table, $field, $spec, $keys_new=array())
Definition: database.inc:2840
hook_modules_uninstalled
hook_modules_uninstalled($modules)
Definition: system.api.php:2652
hook_date_formats
hook_date_formats()
Definition: system.api.php:4110
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
hook_element_info_alter
hook_element_info_alter(&$type)
Definition: system.api.php:702
node_type_get_name
node_type_get_name($node)
Definition: node.module:459
hook_actions_delete
hook_actions_delete($aid)
Definition: system.api.php:3947
db_or
db_or()
Definition: database.inc:2662
hook_requirements
hook_requirements($phase)
Definition: system.api.php:3053
hook_init
hook_init()
Definition: system.api.php:1882
hook_file_load
hook_file_load($files)
Definition: system.api.php:2752
STREAM_WRAPPERS_READ_VISIBLE
const STREAM_WRAPPERS_READ_VISIBLE
Definition: stream_wrappers.inc:77
taxonomy_vocabulary_load
taxonomy_vocabulary_load($vid)
Definition: taxonomy.module:1351
hook_entity_prepare_view
hook_entity_prepare_view($entities, $type, $langcode)
Definition: system.api.php:547
overlay_get_mode
overlay_get_mode()
Definition: overlay.module:589
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
hook_cron
hook_cron()
Definition: system.api.php:575
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
hook_hook_info
hook_hook_info()
Definition: system.api.php:37
hook_menu_local_tasks_alter
hook_menu_local_tasks_alter(&$data, $router_item, $root_path)
Definition: system.api.php:1451
hook_watchdog
hook_watchdog(array $log_entry)
Definition: system.api.php:2438
hook_entity_insert
hook_entity_insert($entity, $type)
Definition: system.api.php:328
hook_registry_files_alter
hook_registry_files_alter(&$files, $modules)
Definition: system.api.php:3615
hook_file_move
hook_file_move($file, $source)
Definition: system.api.php:2879
hook_drupal_goto_alter
hook_drupal_goto_alter(&$path, &$options, &$http_response_code)
Definition: system.api.php:3802
WATCHDOG_ALERT
const WATCHDOG_ALERT
Definition: bootstrap.inc:83
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
hook_stream_wrappers
hook_stream_wrappers()
Definition: system.api.php:2691
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
hook_element_info
hook_element_info()
Definition: system.api.php:684
image_get_info
image_get_info($filepath, $toolkit=FALSE)
Definition: image.inc:124
$info
$info
Definition: color.inc:6
DRUPAL_MINIMUM_PHP
const DRUPAL_MINIMUM_PHP
Definition: bootstrap.inc:21
STREAM_WRAPPERS_LOCAL_HIDDEN
const STREAM_WRAPPERS_LOCAL_HIDDEN
Definition: stream_wrappers.inc:67
drupal_html_to_text
drupal_html_to_text($string, $allowed_tags=NULL)
Definition: mail.inc:402
hook_menu
hook_menu()
Definition: system.api.php:1264
hook_archiver_info_alter
hook_archiver_info_alter(&$info)
Definition: system.api.php:4001
hook_date_formats_alter
hook_date_formats_alter(&$formats)
Definition: system.api.php:4136
node_access_view_all_nodes
node_access_view_all_nodes($account=NULL)
Definition: node.module:3223
hook_theme
hook_theme($existing, $type, $theme, $path)
Definition: system.api.php:2220
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
hook_schema_alter
hook_schema_alter(&$schema)
Definition: system.api.php:3204
hook_update_dependencies
hook_update_dependencies()
Definition: system.api.php:3474
$value
print $value
Definition: user-profile-item.tpl.php:26
hook_tokens_alter
hook_tokens_alter(array &$replacements, array $context)
Definition: system.api.php:4392
get_t
get_t()
Definition: bootstrap.inc:2635
hook_js_alter
hook_js_alter(&$javascript)
Definition: system.api.php:746
hook_entity_query_alter
hook_entity_query_alter($query)
Definition: system.api.php:403
QueryAlterableInterface\getMetaData
getMetaData($key)
hook_menu_link_alter
hook_menu_link_alter(&$item)
Definition: system.api.php:1305
hook_filetransfer_info_alter
hook_filetransfer_info_alter(&$filetransfer_info)
Definition: system.api.php:4706
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
node_access_grants
node_access_grants($op, $account=NULL)
Definition: node.module:3187
hook_entity_info
hook_entity_info()
Definition: system.api.php:202
hook_flush_caches
hook_flush_caches()
Definition: system.api.php:2568
$author
print $author
Definition: comment.tpl.php:68
WATCHDOG_DEBUG
const WATCHDOG_DEBUG
Definition: bootstrap.inc:113
hook_html_head_alter
hook_html_head_alter(&$head_elements)
Definition: system.api.php:3819
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
hook_cron_queue_info_alter
hook_cron_queue_info_alter(&$queues)
Definition: system.api.php:640
user_access
user_access($string, $account=NULL)
Definition: user.module:794
hook_file_presave
hook_file_presave($file)
Definition: system.api.php:2801
hook_modules_installed
hook_modules_installed($modules)
Definition: system.api.php:2588
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
file_uri_target
file_uri_target($uri)
Definition: file.inc:243
hook_custom_theme
hook_custom_theme()
Definition: system.api.php:2316
ajax_command_prepend
ajax_command_prepend($selector, $html, $settings=NULL)
Definition: ajax.inc:908
hook_theme_registry_alter
hook_theme_registry_alter(&$theme_registry)
Definition: system.api.php:2282
WATCHDOG_CRITICAL
const WATCHDOG_CRITICAL
Definition: bootstrap.inc:88
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
hook_entity_view_mode_alter
hook_entity_view_mode_alter(&$view_mode, $context)
Definition: system.api.php:480
hook_action_info
hook_action_info()
Definition: system.api.php:3916
MENU_SUGGESTED_ITEM
const MENU_SUGGESTED_ITEM
Definition: menu.inc:161
hook_url_inbound_alter
hook_url_inbound_alter(&$path, $original_path, $path_language)
Definition: system.api.php:4223
hook_file_download
hook_file_download($uri)
Definition: system.api.php:2920
hook_file_mimetype_mapping_alter
hook_file_mimetype_mapping_alter(&$mapping)
Definition: system.api.php:3859
st
st($string, array $args=array(), array $options=array())
Definition: install.inc:1111
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
hook_file_insert
hook_file_insert($file)
Definition: system.api.php:2818
node_type_get_names
node_type_get_names()
Definition: node.module:446
hook_install_tasks_alter
hook_install_tasks_alter(&$tasks, $install_state)
Definition: system.api.php:3839
hook_uninstall
hook_uninstall()
Definition: system.api.php:3544
hook_menu_breadcrumb_alter
hook_menu_breadcrumb_alter(&$active_trail, $item)
Definition: system.api.php:1519
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
hook_enable
hook_enable()
Definition: system.api.php:3559
hook_system_info_alter
hook_system_info_alter(&$info, $file, $type)
Definition: system.api.php:2057
hook_form_BASE_FORM_ID_alter
hook_form_BASE_FORM_ID_alter(&$form, &$form_state, $form_id)
Definition: system.api.php:1757
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
hook_date_format_types
hook_date_format_types()
Definition: system.api.php:4036
callback_entity_info_uri
callback_entity_info_uri($entity)
Definition: system.api.php:4739
WATCHDOG_EMERGENCY
const WATCHDOG_EMERGENCY
Definition: bootstrap.inc:78
hook_entity_info_alter
hook_entity_info_alter(&$entity_info)
Definition: system.api.php:285
STREAM_WRAPPERS_LOCAL_NORMAL
const STREAM_WRAPPERS_LOCAL_NORMAL
Definition: stream_wrappers.inc:91
VERSION
const VERSION
Definition: bootstrap.inc:11
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
hook_cron_queue_info
hook_cron_queue_info()
Definition: system.api.php:620
hook_system_theme_info
hook_system_theme_info()
Definition: system.api.php:2035
hook_token_info_alter
hook_token_info_alter(&$data)
Definition: system.api.php:4507
$dir
print $dir
Definition: book-export-html.tpl.php:22
hook_permission
hook_permission()
Definition: system.api.php:2103
hook_disable
hook_disable()
Definition: system.api.php:3573
hook_file_copy
hook_file_copy($file, $source)
Definition: system.api.php:2858
hook_update_N
hook_update_N(&$sandbox)
Definition: system.api.php:3402
file_prepare_directory
file_prepare_directory(&$directory, $options=FILE_MODIFY_PERMISSIONS)
Definition: file.inc:430
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
hook_menu_get_item_alter
hook_menu_get_item_alter(&$router_item, $path, $original_map)
Definition: system.api.php:940
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
hook_entity_view
hook_entity_view($entity, $type, $view_mode, $langcode)
Definition: system.api.php:428
hook_form_FORM_ID_alter
hook_form_FORM_ID_alter(&$form, &$form_state, $form_id)
Definition: system.api.php:1708
REQUIREMENT_INFO
const REQUIREMENT_INFO
Definition: install.inc:21
hook_updater_info
hook_updater_info()
Definition: system.api.php:4578
file_uri_scheme
file_uri_scheme($uri)
Definition: file.inc:199
hook_module_implements_alter
hook_module_implements_alter(&$implementations, $hook)
Definition: system.api.php:2009
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
hook_entity_view_alter
hook_entity_view_alter(&$build, $type)
Definition: system.api.php:459
hook_translated_menu_link_alter
hook_translated_menu_link_alter(&$item, $map)
Definition: system.api.php:1346
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
token_find_with_prefix
token_find_with_prefix(array $tokens, $prefix, $delimiter= ':')
Definition: token.inc:219
hook_query_alter
hook_query_alter(QueryAlterableInterface $query)
Definition: system.api.php:3228
entity_extract_ids
entity_extract_ids($entity_type, $entity)
Definition: common.inc:7711
callback_entity_info_label
callback_entity_info_label($entity, $entity_type)
Definition: system.api.php:4760
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
hook_countries_alter
hook_countries_alter(&$countries)
Definition: system.api.php:4622
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
DrupalUpdateException
Definition: update.inc:1008
hook_admin_paths
hook_admin_paths()
Definition: system.api.php:508
hook_file_delete
hook_file_delete($file)
Definition: system.api.php:2898
drupal_load
drupal_load($type, $name)
Definition: bootstrap.inc:1093
hook_date_format_types_alter
hook_date_format_types_alter(&$types)
Definition: system.api.php:4062
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
menu_get_object
menu_get_object($type= 'node', $position=1, $path=NULL)
Definition: menu.inc:971
hook_modules_enabled
hook_modules_enabled($modules)
Definition: system.api.php:2610
hook_updater_info_alter
hook_updater_info_alter(&$updaters)
Definition: system.api.php:4607
hook_entity_update
hook_entity_update($entity, $type)
Definition: system.api.php:350
$links
print $links
Definition: poll-results--block.tpl.php:28
hook_schema
hook_schema()
Definition: system.api.php:3133
hook_batch_alter
hook_batch_alter(&$batch)
Definition: system.api.php:4541
hook_menu_contextual_links_alter
hook_menu_contextual_links_alter(&$links, $router_item, $root_path)
Definition: system.api.php:1561
hook_forms
hook_forms($form_id, $args)
Definition: system.api.php:1824
AGGREGATOR_CLEAR_NEVER
const AGGREGATOR_CLEAR_NEVER
Definition: aggregator.module:11
user_is_anonymous
user_is_anonymous()
Definition: user.module:1533
hook_exit
hook_exit($destination=NULL)
Definition: system.api.php:728
drupal_register_shutdown_function
& drupal_register_shutdown_function($callback=NULL)
Definition: bootstrap.inc:3417
hook_modules_disabled
hook_modules_disabled($modules)
Definition: system.api.php:2630
db_and
db_and()
Definition: database.inc:2671
hook_image_toolkits
hook_image_toolkits()
Definition: system.api.php:1915
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.report.inc Source File

  • modules
  • update
update.report.inc
Go to the documentation of this file.
1 <?php
2
13 function update_status() {
14 if ($available = update_get_available(TRUE)) {
15 module_load_include('inc', 'update', 'update.compare');
16 $data = update_calculate_project_data($available);
17 return theme('update_report', array('data' => $data));
18 }
19 else {
20 return theme('update_report', array('data' => _update_no_data()));
21 }
22 }
23
33 function theme_update_report($variables) {
34 $data = $variables['data'];
35
36 $last = variable_get('update_last_check', 0);
37 $output = theme('update_last_check', array('last' => $last));
38
39 if (!is_array($data)) {
40 $output .= '<p>' . $data . '</p>';
41 return $output;
42 }
43
44 $header = array();
45 $rows = array();
46
47 $notification_level = variable_get('update_notification_threshold', 'all');
48
49 // Create an array of status values keyed by module or theme name, since
50 // we'll need this while generating the report if we have to cross reference
51 // anything (e.g. subthemes which have base themes missing an update).
52 foreach ($data as $project) {
53 foreach ($project['includes'] as $key => $name) {
54 $status[$key] = $project['status'];
55 }
56 }
57
58 foreach ($data as $project) {
59 switch ($project['status']) {
60 case UPDATE_CURRENT:
61 $class = 'ok';
62 $icon = theme('image', array('path' => 'misc/watchdog-ok.png', 'width' => 18, 'height' => 18, 'alt' => t('ok'), 'title' => t('ok')));
63 break;
64 case UPDATE_UNKNOWN:
65 case UPDATE_FETCH_PENDING:
66 case UPDATE_NOT_FETCHED:
67 $class = 'unknown';
68 $icon = theme('image', array('path' => 'misc/watchdog-warning.png', 'width' => 18, 'height' => 18, 'alt' => t('warning'), 'title' => t('warning')));
69 break;
70 case UPDATE_NOT_SECURE:
71 case UPDATE_REVOKED:
72 case UPDATE_NOT_SUPPORTED:
73 $class = 'error';
74 $icon = theme('image', array('path' => 'misc/watchdog-error.png', 'width' => 18, 'height' => 18, 'alt' => t('error'), 'title' => t('error')));
75 break;
76 case UPDATE_NOT_CHECKED:
77 case UPDATE_NOT_CURRENT:
78 default:
79 $class = 'warning';
80 $icon = theme('image', array('path' => 'misc/watchdog-warning.png', 'width' => 18, 'height' => 18, 'alt' => t('warning'), 'title' => t('warning')));
81 break;
82 }
83
84 $row = '<div class="version-status">';
85 $status_label = theme('update_status_label', array('status' => $project['status']));
86 $row .= !empty($status_label) ? $status_label : check_plain($project['reason']);
87 $row .= '<span class="icon">' . $icon . '</span>';
88 $row .= "</div>\n";
89
90 $row .= '<div class="project">';
91 if (isset($project['title'])) {
92 if (isset($project['link'])) {
93 $row .= l($project['title'], $project['link']);
94 }
95 else {
96 $row .= check_plain($project['title']);
97 }
98 }
99 else {
100 $row .= check_plain($project['name']);
101 }
102 $row .= ' ' . check_plain($project['existing_version']);
103 if ($project['install_type'] == 'dev' && !empty($project['datestamp'])) {
104 $row .= ' <span class="version-date">(' . format_date($project['datestamp'], 'custom', 'Y-M-d') . ')</span>';
105 }
106 $row .= "</div>\n";
107
108 $versions_inner = '';
109 $security_class = array();
110 $version_class = array();
111 if (isset($project['recommended'])) {
112 if ($project['status'] != UPDATE_CURRENT || $project['existing_version'] !== $project['recommended']) {
113
114 // First, figure out what to recommend.
115 // If there's only 1 security update and it has the same version we're
116 // recommending, give it the same CSS class as if it was recommended,
117 // but don't print out a separate "Recommended" line for this project.
118 if (!empty($project['security updates']) && count($project['security updates']) == 1 && $project['security updates'][0]['version'] === $project['recommended']) {
119 $security_class[] = 'version-recommended';
120 $security_class[] = 'version-recommended-strong';
121 }
122 else {
123 $version_class[] = 'version-recommended';
124 // Apply an extra class if we're displaying both a recommended
125 // version and anything else for an extra visual hint.
126 if ($project['recommended'] !== $project['latest_version']
127 || !empty($project['also'])
128 || ($project['install_type'] == 'dev'
129 && isset($project['dev_version'])
130 && $project['latest_version'] !== $project['dev_version']
131 && $project['recommended'] !== $project['dev_version'])
132 || (isset($project['security updates'][0])
133 && $project['recommended'] !== $project['security updates'][0])
134 ) {
135 $version_class[] = 'version-recommended-strong';
136 }
137 $versions_inner .= theme('update_version', array('version' => $project['releases'][$project['recommended']], 'tag' => t('Recommended version:'), 'class' => $version_class));
138 }
139
140 // Now, print any security updates.
141 if (!empty($project['security updates'])) {
142 $security_class[] = 'version-security';
143 foreach ($project['security updates'] as $security_update) {
144 $versions_inner .= theme('update_version', array('version' => $security_update, 'tag' => t('Security update:'), 'class' => $security_class));
145 }
146 }
147 }
148
149 if ($project['recommended'] !== $project['latest_version']) {
150 $versions_inner .= theme('update_version', array('version' => $project['releases'][$project['latest_version']], 'tag' => t('Latest version:'), 'class' => array('version-latest')));
151 }
152 if ($project['install_type'] == 'dev'
153 && $project['status'] != UPDATE_CURRENT
154 && isset($project['dev_version'])
155 && $project['recommended'] !== $project['dev_version']) {
156 $versions_inner .= theme('update_version', array('version' => $project['releases'][$project['dev_version']], 'tag' => t('Development version:'), 'class' => array('version-latest')));
157 }
158 }
159
160 if (isset($project['also'])) {
161 foreach ($project['also'] as $also) {
162 $versions_inner .= theme('update_version', array('version' => $project['releases'][$also], 'tag' => t('Also available:'), 'class' => array('version-also-available')));
163 }
164 }
165
166 if (!empty($versions_inner)) {
167 $row .= "<div class=\"versions\">\n" . $versions_inner . "</div>\n";
168 }
169 $row .= "<div class=\"info\">\n";
170 if (!empty($project['extra'])) {
171 $row .= '<div class="extra">' . "\n";
172 foreach ($project['extra'] as $key => $value) {
173 $row .= '<div class="' . implode(' ', $value['class']) . '">';
174 $row .= check_plain($value['label']) . ': ';
175 $row .= drupal_placeholder($value['data']);
176 $row .= "</div>\n";
177 }
178 $row .= "</div>\n"; // extra div.
179 }
180
181 $row .= '<div class="includes">';
182 sort($project['includes']);
183 if (!empty($project['disabled'])) {
184 sort($project['disabled']);
185 // Make sure we start with a clean slate for each project in the report.
186 $includes_items = array();
187 $row .= t('Includes:');
188 $includes_items[] = t('Enabled: %includes', array('%includes' => implode(', ', $project['includes'])));
189 $includes_items[] = t('Disabled: %disabled', array('%disabled' => implode(', ', $project['disabled'])));
190 $row .= theme('item_list', array('items' => $includes_items));
191 }
192 else {
193 $row .= t('Includes: %includes', array('%includes' => implode(', ', $project['includes'])));
194 }
195 $row .= "</div>\n";
196
197 if (!empty($project['base_themes'])) {
198 $row .= '<div class="basethemes">';
199 asort($project['base_themes']);
200 $base_themes = array();
201 foreach ($project['base_themes'] as $base_key => $base_theme) {
202 switch ($status[$base_key]) {
203 case UPDATE_NOT_SECURE:
204 case UPDATE_REVOKED:
205 case UPDATE_NOT_SUPPORTED:
206 $base_themes[] = t('%base_theme (!base_label)', array('%base_theme' => $base_theme, '!base_label' => theme('update_status_label', array('status' => $status[$base_key]))));
207 break;
208
209 default:
210 $base_themes[] = drupal_placeholder($base_theme);
211 }
212 }
213 $row .= t('Depends on: !basethemes', array('!basethemes' => implode(', ', $base_themes)));
214 $row .= "</div>\n";
215 }
216
217 if (!empty($project['sub_themes'])) {
218 $row .= '<div class="subthemes">';
219 sort($project['sub_themes']);
220 $row .= t('Required by: %subthemes', array('%subthemes' => implode(', ', $project['sub_themes'])));
221 $row .= "</div>\n";
222 }
223
224 $row .= "</div>\n"; // info div.
225
226 if (!isset($rows[$project['project_type']])) {
227 $rows[$project['project_type']] = array();
228 }
229 $row_key = isset($project['title']) ? drupal_strtolower($project['title']) : drupal_strtolower($project['name']);
230 $rows[$project['project_type']][$row_key] = array(
231 'class' => array($class),
232 'data' => array($row),
233 );
234 }
235
236 $project_types = array(
237 'core' => t('Drupal core'),
238 'module' => t('Modules'),
239 'theme' => t('Themes'),
240 'module-disabled' => t('Disabled modules'),
241 'theme-disabled' => t('Disabled themes'),
242 );
243 foreach ($project_types as $type_name => $type_label) {
244 if (!empty($rows[$type_name])) {
245 ksort($rows[$type_name]);
246 $output .= "\n<h3>" . $type_label . "</h3>\n";
247 $output .= theme('table', array('header' => $header, 'rows' => $rows[$type_name], 'attributes' => array('class' => array('update'))));
248 }
249 }
250 drupal_add_css(drupal_get_path('module', 'update') . '/update.css');
251 return $output;
252 }
253
264 function theme_update_status_label($variables) {
265 switch ($variables['status']) {
266 case UPDATE_NOT_SECURE:
267 return '<span class="security-error">' . t('Security update required!') . '</span>';
268
269 case UPDATE_REVOKED:
270 return '<span class="revoked">' . t('Revoked!') . '</span>';
271
272 case UPDATE_NOT_SUPPORTED:
273 return '<span class="not-supported">' . t('Not supported!') . '</span>';
274
275 case UPDATE_NOT_CURRENT:
276 return '<span class="not-current">' . t('Update available') . '</span>';
277
278 case UPDATE_CURRENT:
279 return '<span class="current">' . t('Up to date') . '</span>';
280
281 }
282 }
283
299 function theme_update_version($variables) {
300 $version = $variables['version'];
301 $tag = $variables['tag'];
302 $class = implode(' ', $variables['class']);
303
304 $output = '';
305 $output .= '<table class="version ' . $class . '">';
306 $output .= '<tr>';
307 $output .= '<td class="version-title">' . $tag . "</td>\n";
308 $output .= '<td class="version-details">';
309 $output .= l($version['version'], $version['release_link']);
310 $output .= ' <span class="version-date">(' . format_date($version['date'], 'custom', 'Y-M-d') . ')</span>';
311 $output .= "</td>\n";
312 $output .= '<td class="version-links">';
313 $links = array();
314 $links['update-download'] = array(
315 'title' => t('Download'),
316 'href' => $version['download_link'],
317 );
318 $links['update-release-notes'] = array(
319 'title' => t('Release notes'),
320 'href' => $version['release_link'],
321 );
322 $output .= theme('links__update_version', array('links' => $links));
323 $output .= '</td>';
324 $output .= '</tr>';
325 $output .= "</table>\n";
326 return $output;
327 }
UPDATE_NOT_CURRENT
const UPDATE_NOT_CURRENT
Definition: update.module:39
theme_update_version
theme_update_version($variables)
Definition: update.report.inc:299
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_strtolower
drupal_strtolower($text)
Definition: unicode.inc:521
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
update_calculate_project_data
update_calculate_project_data($available)
Definition: update.compare.inc:335
$name
print $name
Definition: profile-listing.tpl.php:43
$header
print $header
Definition: forum-topic-list.tpl.php:42
UPDATE_UNKNOWN
const UPDATE_UNKNOWN
Definition: update.module:54
_update_no_data
_update_no_data()
Definition: update.module:365
UPDATE_REVOKED
const UPDATE_REVOKED
Definition: update.module:29
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
theme_update_report
theme_update_report($variables)
Definition: update.report.inc:33
UPDATE_NOT_CHECKED
const UPDATE_NOT_CHECKED
Definition: update.module:49
$value
print $value
Definition: user-profile-item.tpl.php:26
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
theme_update_status_label
theme_update_status_label($variables)
Definition: update.report.inc:264
$output
$output
Definition: authorize.php:93
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
UPDATE_CURRENT
const UPDATE_CURRENT
Definition: update.module:44
UPDATE_NOT_FETCHED
const UPDATE_NOT_FETCHED
Definition: update.module:59
update_status
update_status()
Definition: update.report.inc:13
drupal_placeholder
drupal_placeholder($text)
Definition: bootstrap.inc:3396
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$row
$row
Definition: block-admin-display-form.tpl.php:47
UPDATE_NOT_SUPPORTED
const UPDATE_NOT_SUPPORTED
Definition: update.module:34
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
update_get_available
update_get_available($refresh=FALSE)
Definition: update.module:394
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
UPDATE_NOT_SECURE
const UPDATE_NOT_SECURE
Definition: update.module:24
$links
print $links
Definition: poll-results--block.tpl.php:28
UPDATE_FETCH_PENDING
const UPDATE_FETCH_PENDING
Definition: update.module:64
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/statistics/statistics.php Source File

  • modules
  • statistics
statistics.php
Go to the documentation of this file.
1 <?php
2
11 define('DRUPAL_ROOT', substr($_SERVER['SCRIPT_FILENAME'], 0, strpos($_SERVER['SCRIPT_FILENAME'], '/modules/statistics/statistics.php')));
12 // Change the directory to the Drupal root.
13 chdir(DRUPAL_ROOT);
14
15 include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
16 drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
17 if (variable_get('statistics_count_content_views', 0) && variable_get('statistics_count_content_views_ajax', 0)) {
18 $nid = $_POST['nid'];
19 if (is_numeric($nid)) {
20 db_merge('node_counter')
21 ->key(array('nid' => $nid))
22 ->fields(array(
23 'daycount' => 1,
24 'totalcount' => 1,
25 'timestamp' => REQUEST_TIME,
26 ))
27 ->expression('daycount', 'daycount + 1')
28 ->expression('totalcount', 'totalcount + 1')
29 ->execute();
30 }
31 }
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
drupal_bootstrap
drupal_bootstrap($phase=NULL, $new_phase=TRUE)
Definition: bootstrap.inc:2192
DRUPAL_BOOTSTRAP_VARIABLES
const DRUPAL_BOOTSTRAP_VARIABLES
Definition: bootstrap.inc:137
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/block_example/block_example.install Source File

  • examples
  • block_example
block_example.install
Go to the documentation of this file.
1 <?php
12 function block_example_uninstall() {
13 variable_del('block_example_string');
14 }
variable_del
variable_del($name)
Definition: bootstrap.inc:996
block_example_uninstall
block_example_uninstall()
Definition: block_example.install:12
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/templates/node.tpl.php Source File

  • themes
  • bartik
  • templates
node.tpl.php
Go to the documentation of this file.
1 <?php
2
80 ?>
81 <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
82
83 <?php print render($title_prefix); ?>
84 <?php if (!$page): ?>
85 <h2<?php print $title_attributes; ?>>
86 <a href="<?php print $node_url; ?>"><?php print $title; ?></a>
87 </h2>
88 <?php endif; ?>
89 <?php print render($title_suffix); ?>
90
91 <?php if ($display_submitted): ?>
92 <div class="meta submitted">
93 <?php print $user_picture; ?>
94 <?php print $submitted; ?>
95 </div>
96 <?php endif; ?>
97
98 <div class="content clearfix"<?php print $content_attributes; ?>>
99 <?php
100 // We hide the comments and links now so that we can render them later.
101 hide($content['comments']);
102 hide($content['links']);
103 print render($content);
104 ?>
105 </div>
106
107 <?php
108 // Remove the "Add new comment" link on the teaser page or if the comment
109 // form is being displayed on the same page.
110 if ($teaser || !empty($content['comments']['comment_form'])) {
111 unset($content['links']['comment']['#links']['comment-add']);
112 }
113 // Only display the wrapper div if there are links.
114 $links = render($content['links']);
115 if ($links):
116 ?>
117 <div class="link-wrapper">
118 <?php print $links; ?>
119 </div>
120 <?php endif; ?>
121
122 <?php print render($content['comments']); ?>
123
124 </div>
$page
print $page
Definition: overlay.tpl.php:37
$attributes
print $attributes
Definition: block.tpl.php:47
$user_picture
print $user_picture
Definition: node.tpl.php:85
print
print
Definition: php-2.php:2
$content_attributes
print $content_attributes
Definition: block.tpl.php:55
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
hide
hide(&$element)
Definition: common.inc:6021
endif
endif
Definition: aggregator-item.tpl.php:31
$submitted
print $submitted
Definition: comment.tpl.php:75
render
render(&$element)
Definition: common.inc:5988
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
$links
print $links
Definition: poll-results--block.tpl.php:28
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/xmlrpc.inc Source File

  • includes
xmlrpc.inc
Go to the documentation of this file.
1 <?php
2
25 function xmlrpc_value($data, $type = FALSE) {
26 $xmlrpc_value = new stdClass();
27 $xmlrpc_value->data = $data;
28 if (!$type) {
29 $type = xmlrpc_value_calculate_type($xmlrpc_value);
30 }
31 $xmlrpc_value->type = $type;
32 if ($type == 'struct') {
33 // Turn all the values in the array into new xmlrpc_values
34 foreach ($xmlrpc_value->data as $key => $value) {
35 $xmlrpc_value->data[$key] = xmlrpc_value($value);
36 }
37 }
38 if ($type == 'array') {
39 for ($i = 0, $j = count($xmlrpc_value->data); $i < $j; $i++) {
40 $xmlrpc_value->data[$i] = xmlrpc_value($xmlrpc_value->data[$i]);
41 }
42 }
43 return $xmlrpc_value;
44 }
45
57 function xmlrpc_value_calculate_type($xmlrpc_value) {
58 // http://www.php.net/gettype: Never use gettype() to test for a certain type
59 // [...] Instead, use the is_* functions.
60 if (is_bool($xmlrpc_value->data)) {
61 return 'boolean';
62 }
63 if (is_double($xmlrpc_value->data)) {
64 return 'double';
65 }
66 if (is_int($xmlrpc_value->data)) {
67 return 'int';
68 }
69 if (is_array($xmlrpc_value->data)) {
70 // empty or integer-indexed arrays are 'array', string-indexed arrays 'struct'
71 return empty($xmlrpc_value->data) || range(0, count($xmlrpc_value->data) - 1) === array_keys($xmlrpc_value->data) ? 'array' : 'struct';
72 }
73 if (is_object($xmlrpc_value->data)) {
74 if (isset($xmlrpc_value->data->is_date)) {
75 return 'date';
76 }
77 if (isset($xmlrpc_value->data->is_base64)) {
78 return 'base64';
79 }
80 $xmlrpc_value->data = get_object_vars($xmlrpc_value->data);
81 return 'struct';
82 }
83 // default
84 return 'string';
85 }
86
96 function xmlrpc_value_get_xml($xmlrpc_value) {
97 switch ($xmlrpc_value->type) {
98 case 'boolean':
99 return '<boolean>' . (($xmlrpc_value->data) ? '1' : '0') . '</boolean>';
100
101 case 'int':
102 return '<int>' . $xmlrpc_value->data . '</int>';
103
104 case 'double':
105 return '<double>' . $xmlrpc_value->data . '</double>';
106
107 case 'string':
108 // Note: we don't escape apostrophes because of the many blogging clients
109 // that don't support numerical entities (and XML in general) properly.
110 return '<string>' . htmlspecialchars($xmlrpc_value->data) . '</string>';
111
112 case 'array':
113 $return = '<array><data>' . "\n";
114 foreach ($xmlrpc_value->data as $item) {
115 $return .= ' <value>' . xmlrpc_value_get_xml($item) . "</value>\n";
116 }
117 $return .= '</data></array>';
118 return $return;
119
120 case 'struct':
121 $return = '<struct>' . "\n";
122 foreach ($xmlrpc_value->data as $name => $value) {
123 $return .= " <member><name>" . check_plain($name) . "</name><value>";
124 $return .= xmlrpc_value_get_xml($value) . "</value></member>\n";
125 }
126 $return .= '</struct>';
127 return $return;
128
129 case 'date':
130 return xmlrpc_date_get_xml($xmlrpc_value->data);
131
132 case 'base64':
133 return xmlrpc_base64_get_xml($xmlrpc_value->data);
134 }
135 return FALSE;
136 }
137
149 function xmlrpc_message($message) {
150 $xmlrpc_message = new stdClass();
151 // The stack used to keep track of the current array/struct
152 $xmlrpc_message->array_structs = array();
153 // The stack used to keep track of if things are structs or array
154 $xmlrpc_message->array_structs_types = array();
155 // A stack as well
156 $xmlrpc_message->current_struct_name = array();
157 $xmlrpc_message->message = $message;
158 return $xmlrpc_message;
159 }
160
173 function xmlrpc_message_parse($xmlrpc_message) {
174 $xmlrpc_message->_parser = xml_parser_create();
175 // Set XML parser to take the case of tags into account.
176 xml_parser_set_option($xmlrpc_message->_parser, XML_OPTION_CASE_FOLDING, FALSE);
177 // Set XML parser callback functions
178 xml_set_element_handler($xmlrpc_message->_parser, 'xmlrpc_message_tag_open', 'xmlrpc_message_tag_close');
179 xml_set_character_data_handler($xmlrpc_message->_parser, 'xmlrpc_message_cdata');
180 xmlrpc_message_set($xmlrpc_message);
181 if (!xml_parse($xmlrpc_message->_parser, $xmlrpc_message->message)) {
182 return FALSE;
183 }
184 xml_parser_free($xmlrpc_message->_parser);
185
186 // Grab the error messages, if any.
187 $xmlrpc_message = xmlrpc_message_get();
188 if (!isset($xmlrpc_message->messagetype)) {
189 return FALSE;
190 }
191 elseif ($xmlrpc_message->messagetype == 'fault') {
192 $xmlrpc_message->fault_code = $xmlrpc_message->params[0]['faultCode'];
193 $xmlrpc_message->fault_string = $xmlrpc_message->params[0]['faultString'];
194 }
195 return TRUE;
196 }
197
209 function xmlrpc_message_set($value = NULL) {
210 static $xmlrpc_message;
211 if ($value) {
212 $xmlrpc_message = $value;
213 }
214 return $xmlrpc_message;
215 }
216
225 function xmlrpc_message_get() {
226 return xmlrpc_message_set();
227 }
228
232 function xmlrpc_message_tag_open($parser, $tag, $attr) {
233 $xmlrpc_message = xmlrpc_message_get();
234 $xmlrpc_message->current_tag_contents = '';
235 $xmlrpc_message->last_open = $tag;
236 switch ($tag) {
237 case 'methodCall':
238 case 'methodResponse':
239 case 'fault':
240 $xmlrpc_message->messagetype = $tag;
241 break;
242
243 // Deal with stacks of arrays and structs
244 case 'data':
245 $xmlrpc_message->array_structs_types[] = 'array';
246 $xmlrpc_message->array_structs[] = array();
247 break;
248
249 case 'struct':
250 $xmlrpc_message->array_structs_types[] = 'struct';
251 $xmlrpc_message->array_structs[] = array();
252 break;
253 }
254 xmlrpc_message_set($xmlrpc_message);
255 }
256
260 function xmlrpc_message_cdata($parser, $cdata) {
261 $xmlrpc_message = xmlrpc_message_get();
262 $xmlrpc_message->current_tag_contents .= $cdata;
263 xmlrpc_message_set($xmlrpc_message);
264 }
265
269 function xmlrpc_message_tag_close($parser, $tag) {
270 $xmlrpc_message = xmlrpc_message_get();
271 $value_flag = FALSE;
272 switch ($tag) {
273 case 'int':
274 case 'i4':
275 $value = (int)trim($xmlrpc_message->current_tag_contents);
276 $value_flag = TRUE;
277 break;
278
279 case 'double':
280 $value = (double)trim($xmlrpc_message->current_tag_contents);
281 $value_flag = TRUE;
282 break;
283
284 case 'string':
285 $value = $xmlrpc_message->current_tag_contents;
286 $value_flag = TRUE;
287 break;
288
289 case 'dateTime.iso8601':
290 $value = xmlrpc_date(trim($xmlrpc_message->current_tag_contents));
291 // $value = $iso->getTimestamp();
292 $value_flag = TRUE;
293 break;
294
295 case 'value':
296 // If no type is indicated, the type is string
297 // We take special care for empty values
298 if (trim($xmlrpc_message->current_tag_contents) != '' || (isset($xmlrpc_message->last_open) && ($xmlrpc_message->last_open == 'value'))) {
299 $value = (string) $xmlrpc_message->current_tag_contents;
300 $value_flag = TRUE;
301 }
302 unset($xmlrpc_message->last_open);
303 break;
304
305 case 'boolean':
306 $value = (boolean)trim($xmlrpc_message->current_tag_contents);
307 $value_flag = TRUE;
308 break;
309
310 case 'base64':
311 $value = base64_decode(trim($xmlrpc_message->current_tag_contents));
312 $value_flag = TRUE;
313 break;
314
315 // Deal with stacks of arrays and structs
316 case 'data':
317 case 'struct':
318 $value = array_pop($xmlrpc_message->array_structs);
319 array_pop($xmlrpc_message->array_structs_types);
320 $value_flag = TRUE;
321 break;
322
323 case 'member':
324 array_pop($xmlrpc_message->current_struct_name);
325 break;
326
327 case 'name':
328 $xmlrpc_message->current_struct_name[] = trim($xmlrpc_message->current_tag_contents);
329 break;
330
331 case 'methodName':
332 $xmlrpc_message->methodname = trim($xmlrpc_message->current_tag_contents);
333 break;
334 }
335 if ($value_flag) {
336 if (count($xmlrpc_message->array_structs) > 0) {
337 // Add value to struct or array
338 if ($xmlrpc_message->array_structs_types[count($xmlrpc_message->array_structs_types) - 1] == 'struct') {
339 // Add to struct
340 $xmlrpc_message->array_structs[count($xmlrpc_message->array_structs) - 1][$xmlrpc_message->current_struct_name[count($xmlrpc_message->current_struct_name) - 1]] = $value;
341 }
342 else {
343 // Add to array
344 $xmlrpc_message->array_structs[count($xmlrpc_message->array_structs) - 1][] = $value;
345 }
346 }
347 else {
348 // Just add as a parameter
349 $xmlrpc_message->params[] = $value;
350 }
351 }
352 if (!in_array($tag, array("data", "struct", "member"))) {
353 $xmlrpc_message->current_tag_contents = '';
354 }
355 xmlrpc_message_set($xmlrpc_message);
356 }
357
369 function xmlrpc_request($method, $args) {
370 $xmlrpc_request = new stdClass();
371 $xmlrpc_request->method = $method;
372 $xmlrpc_request->args = $args;
373 $xmlrpc_request->xml = <<<EOD
374 <?xml version="1.0"?>
375 <methodCall>
376 <methodName>{$xmlrpc_request->method}</methodName>
377 <params>
378
379 EOD;
380 foreach ($xmlrpc_request->args as $arg) {
381 $xmlrpc_request->xml .= '<param><value>';
382 $v = xmlrpc_value($arg);
383 $xmlrpc_request->xml .= xmlrpc_value_get_xml($v);
384 $xmlrpc_request->xml .= "</value></param>\n";
385 }
386 $xmlrpc_request->xml .= '</params></methodCall>';
387 return $xmlrpc_request;
388 }
389
404 function xmlrpc_error($code = NULL, $message = NULL, $reset = FALSE) {
405 static $xmlrpc_error;
406 if (isset($code)) {
407 $xmlrpc_error = new stdClass();
408 $xmlrpc_error->is_error = TRUE;
409 $xmlrpc_error->code = $code;
410 $xmlrpc_error->message = $message;
411 }
412 elseif ($reset) {
413 $xmlrpc_error = NULL;
414 }
415 return $xmlrpc_error;
416 }
417
427 function xmlrpc_error_get_xml($xmlrpc_error) {
428 return <<<EOD
429 <methodResponse>
430 <fault>
431 <value>
432 <struct>
433 <member>
434 <name>faultCode</name>
435 <value><int>{$xmlrpc_error->code}</int></value>
436 </member>
437 <member>
438 <name>faultString</name>
439 <value><string>{$xmlrpc_error->message}</string></value>
440 </member>
441 </struct>
442 </value>
443 </fault>
444 </methodResponse>
445
446 EOD;
447 }
448
458 function xmlrpc_date($time) {
459 $xmlrpc_date = new stdClass();
460 $xmlrpc_date->is_date = TRUE;
461 // $time can be a PHP timestamp or an ISO one
462 if (is_numeric($time)) {
463 $xmlrpc_date->year = gmdate('Y', $time);
464 $xmlrpc_date->month = gmdate('m', $time);
465 $xmlrpc_date->day = gmdate('d', $time);
466 $xmlrpc_date->hour = gmdate('H', $time);
467 $xmlrpc_date->minute = gmdate('i', $time);
468 $xmlrpc_date->second = gmdate('s', $time);
469 $xmlrpc_date->iso8601 = gmdate('Ymd\TH:i:s', $time);
470 }
471 else {
472 $xmlrpc_date->iso8601 = $time;
473 $time = str_replace(array('-', ':'), '', $time);
474 $xmlrpc_date->year = substr($time, 0, 4);
475 $xmlrpc_date->month = substr($time, 4, 2);
476 $xmlrpc_date->day = substr($time, 6, 2);
477 $xmlrpc_date->hour = substr($time, 9, 2);
478 $xmlrpc_date->minute = substr($time, 11, 2);
479 $xmlrpc_date->second = substr($time, 13, 2);
480 }
481 return $xmlrpc_date;
482 }
483
493 function xmlrpc_date_get_xml($xmlrpc_date) {
494 return '<dateTime.iso8601>' . $xmlrpc_date->year . $xmlrpc_date->month . $xmlrpc_date->day . 'T' . $xmlrpc_date->hour . ':' . $xmlrpc_date->minute . ':' . $xmlrpc_date->second . '</dateTime.iso8601>';
495 }
496
506 function xmlrpc_base64($data) {
507 $xmlrpc_base64 = new stdClass();
508 $xmlrpc_base64->is_base64 = TRUE;
509 $xmlrpc_base64->data = $data;
510 return $xmlrpc_base64;
511 }
512
522 function xmlrpc_base64_get_xml($xmlrpc_base64) {
523 return '<base64>' . base64_encode($xmlrpc_base64->data) . '</base64>';
524 }
525
546 function _xmlrpc($url, $args, $options = array()) {
547 xmlrpc_clear_error();
548 if (count($args) > 1) {
549 $multicall_args = array();
550 foreach ($args as $method => $call) {
551 $multicall_args[] = array('methodName' => $method, 'params' => $call);
552 }
553 $method = 'system.multicall';
554 $args = array($multicall_args);
555 }
556 else {
557 $method = key($args);
558 $args = $args[$method];
559 }
560 $xmlrpc_request = xmlrpc_request($method, $args);
561 // Required options which will replace any that are passed in.
562 $options['method'] = 'POST';
563 $options['headers']['Content-Type'] = 'text/xml';
564 $options['data'] = $xmlrpc_request->xml;
565 $result = drupal_http_request($url, $options);
566 if ($result->code != 200) {
567 xmlrpc_error($result->code, $result->error);
568 return FALSE;
569 }
570 $message = xmlrpc_message($result->data);
571 // Now parse what we've got back
572 if (!xmlrpc_message_parse($message)) {
573 // XML error
574 xmlrpc_error(-32700, t('Parse error. Not well formed'));
575 return FALSE;
576 }
577 // Is the message a fault?
578 if ($message->messagetype == 'fault') {
579 xmlrpc_error($message->fault_code, $message->fault_string);
580 return FALSE;
581 }
582 // We now know that the message is well-formed and a non-fault result.
583 if ($method == 'system.multicall') {
584 // Return per-method results or error objects.
585 $return = array();
586 foreach ($message->params[0] as $result) {
587 if (array_keys($result) == array(0)) {
588 $return[] = $result[0];
589 }
590 else {
591 $return[] = xmlrpc_error($result['faultCode'], $result['faultString']);
592 }
593 }
594 }
595 else {
596 $return = $message->params[0];
597 }
598 return $return;
599 }
600
604 function xmlrpc_errno() {
605 $error = xmlrpc_error();
606 return ($error != NULL ? $error->code : NULL);
607 }
608
612 function xmlrpc_error_msg() {
613 $error = xmlrpc_error();
614 return ($error != NULL ? $error->message : NULL);
615 }
616
622 function xmlrpc_clear_error() {
623 xmlrpc_error(NULL, NULL, TRUE);
624 }
xmlrpc_error_msg
xmlrpc_error_msg()
Definition: xmlrpc.inc:612
xmlrpc_message_tag_close
xmlrpc_message_tag_close($parser, $tag)
Definition: xmlrpc.inc:269
value
print $field value
Definition: profile-block.tpl.php:39
xmlrpc_date_get_xml
xmlrpc_date_get_xml($xmlrpc_date)
Definition: xmlrpc.inc:493
xmlrpc_base64
xmlrpc_base64($data)
Definition: xmlrpc.inc:506
$name
print $name
Definition: profile-listing.tpl.php:43
xmlrpc_value_get_xml
xmlrpc_value_get_xml($xmlrpc_value)
Definition: xmlrpc.inc:96
name
print $forum name
Definition: forum-list.tpl.php:57
xmlrpc_message_set
xmlrpc_message_set($value=NULL)
Definition: xmlrpc.inc:209
xmlrpc_message_tag_open
xmlrpc_message_tag_open($parser, $tag, $attr)
Definition: xmlrpc.inc:232
xmlrpc_message_cdata
xmlrpc_message_cdata($parser, $cdata)
Definition: xmlrpc.inc:260
drupal_http_request
drupal_http_request($url, array $options=array())
Definition: common.inc:787
_xmlrpc
_xmlrpc($url, $args, $options=array())
Definition: xmlrpc.inc:546
xmlrpc_message
xmlrpc_message($message)
Definition: xmlrpc.inc:149
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
xmlrpc_request
xmlrpc_request($method, $args)
Definition: xmlrpc.inc:369
xmlrpc_clear_error
xmlrpc_clear_error()
Definition: xmlrpc.inc:622
$url
print $url
Definition: search-result.tpl.php:70
xmlrpc_base64_get_xml
xmlrpc_base64_get_xml($xmlrpc_base64)
Definition: xmlrpc.inc:522
xmlrpc_date
xmlrpc_date($time)
Definition: xmlrpc.inc:458
xmlrpc_value_calculate_type
xmlrpc_value_calculate_type($xmlrpc_value)
Definition: xmlrpc.inc:57
$value
print $value
Definition: user-profile-item.tpl.php:26
xmlrpc_error
xmlrpc_error($code=NULL, $message=NULL, $reset=FALSE)
Definition: xmlrpc.inc:404
xmlrpc_message_parse
xmlrpc_message_parse($xmlrpc_message)
Definition: xmlrpc.inc:173
xmlrpc_message_get
xmlrpc_message_get()
Definition: xmlrpc.inc:225
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
xmlrpc_error_get_xml
xmlrpc_error_get_xml($xmlrpc_error)
Definition: xmlrpc.inc:427
xmlrpc_errno
xmlrpc_errno()
Definition: xmlrpc.inc:604
xmlrpc_value
xmlrpc_value($data, $type=FALSE)
Definition: xmlrpc.inc:25
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
InsertQuery_pgsql Member List

This is the complete list of members for InsertQuery_pgsql, including all inherited members.

$comments | Query | protected
$connection | Query | protected
$connectionKey | Query | protected
$connectionTarget | Query | protected
$defaultFields | InsertQuery | protected
$fromQuery | InsertQuery | protected
$insertFields | InsertQuery | protected
$insertValues | InsertQuery | protected
$nextPlaceholder | Query | protected
$queryOptions | Query | protected
$table | InsertQuery | protected
$uniqueIdentifier | Query | protected
__clone() | Query |
__construct($connection, $table, array $options=array()) | InsertQuery |
Query::__construct(DatabaseConnection $connection, $options) | Query |
__sleep() | Query |
__toString() | InsertQuery_pgsql |
__wakeup() | Query |
comment($comment) | Query |
execute() | InsertQuery_pgsql |
fields(array $fields, array $values=array()) | InsertQuery |
from(SelectQueryInterface $query) | InsertQuery |
getComments() | Query |
nextPlaceholder() | Query |
preExecute() | InsertQuery |
uniqueIdentifier() | Query |
useDefaults(array $fields) | InsertQuery |
values(array $values) | InsertQuery |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator-item.tpl.php Source File

  • modules
  • aggregator
aggregator-item.tpl.php
Go to the documentation of this file.
1 <?php
2
22 ?>
23 <div class="feed-item">
24 <h3 class="feed-item-title">
25 <a href="<?php print $feed_url; ?>"><?php print $feed_title; ?></a>
26 </h3>
27
28 <div class="feed-item-meta">
29 <?php if ($source_url): ?>
30 <a href="<?php print $source_url; ?>" class="feed-item-source"><?php print $source_title; ?></a> -
31 <?php endif; ?>
32 <span class="feed-item-date"><?php print $source_date; ?></span>
33 </div>
34
35 <?php if ($content): ?>
36 <div class="feed-item-body">
37 <?php print $content; ?>
38 </div>
39 <?php endif; ?>
40
41 <?php if ($categories): ?>
42 <div class="feed-item-categories">
43 <?php print t('Categories'); ?>: <?php print implode(', ', $categories); ?>
44 </div>
45 <?php endif ;?>
46
47 </div>
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$source_url
print $source_url
Definition: aggregator-feed-source.tpl.php:31
endif
endif
Definition: aggregator-item.tpl.php:31
$source_date
print $source_date
Definition: aggregator-item.tpl.php:32
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
$source_title
if($source_url) print $source_title
Definition: aggregator-item.tpl.php:29
$feed_title
print $feed_title
Definition: aggregator-item.tpl.php:25
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/locale.inc Source File

  • includes
locale.inc
Go to the documentation of this file.
1 <?php
2
12 define('LOCALE_LANGUAGE_NEGOTIATION_URL', 'locale-url');
13
17 define('LOCALE_LANGUAGE_NEGOTIATION_BROWSER', 'locale-browser');
18
22 define('LOCALE_LANGUAGE_NEGOTIATION_INTERFACE', 'locale-interface');
23
28 define('LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK', 'locale-url-fallback');
29
33 define('LOCALE_LANGUAGE_NEGOTIATION_USER', 'locale-user');
34
38 define('LOCALE_LANGUAGE_NEGOTIATION_SESSION', 'locale-session');
39
43 define('LOCALE_JS_STRING', '(?:(?:\'(?:\\\\\'|[^\'])*\'|"(?:\\\\"|[^"])*")(?:\s*\+\s*)?)+');
44
51 define('LOCALE_JS_OBJECT', '\{.*?\}');
52
59 define('LOCALE_JS_OBJECT_CONTEXT', '
60 \{ # match object literal start
61 .*? # match anything, non-greedy
62 (?: # match a form of "context"
63 \'context\'
64 |
65 "context"
66 |
67 context
68 )
69 \s*:\s* # match key-value separator ":"
70 (' . LOCALE_JS_STRING . ') # match context string
71 .*? # match anything, non-greedy
72 \} # match end of object literal
73 ');
74
79 define('LOCALE_IMPORT_OVERWRITE', 0);
80
85 define('LOCALE_IMPORT_KEEP', 1);
86
91 define('LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX', 0);
92
97 define('LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN', 1);
98
114 function locale_language_from_interface() {
115 global $language;
116 return isset($language->language) ? $language->language : FALSE;
117 }
118
131 function locale_language_from_browser($languages) {
132 if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
133 return FALSE;
134 }
135
136 // The Accept-Language header contains information about the language
137 // preferences configured in the user's browser / operating system.
138 // RFC 2616 (section 14.4) defines the Accept-Language header as follows:
139 // Accept-Language = "Accept-Language" ":"
140 // 1#( language-range [ ";" "q" "=" qvalue ] )
141 // language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )
142 // Samples: "hu, en-us;q=0.66, en;q=0.33", "hu,en-us;q=0.5"
143 $browser_langcodes = array();
144 if (preg_match_all('@(?<=[, ]|^)([a-zA-Z-]+|\*)(?:;q=([0-9.]+))?(?:$|\s*,\s*)@', trim($_SERVER['HTTP_ACCEPT_LANGUAGE']), $matches, PREG_SET_ORDER)) {
145 foreach ($matches as $match) {
146 // We can safely use strtolower() here, tags are ASCII.
147 // RFC2616 mandates that the decimal part is no more than three digits,
148 // so we multiply the qvalue by 1000 to avoid floating point comparisons.
149 $langcode = strtolower($match[1]);
150 $qvalue = isset($match[2]) ? (float) $match[2] : 1;
151 $browser_langcodes[$langcode] = (int) ($qvalue * 1000);
152 }
153 }
154
155 // We should take pristine values from the HTTP headers, but Internet Explorer
156 // from version 7 sends only specific language tags (eg. fr-CA) without the
157 // corresponding generic tag (fr) unless explicitly configured. In that case,
158 // we assume that the lowest value of the specific tags is the value of the
159 // generic language to be as close to the HTTP 1.1 spec as possible.
160 // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 and
161 // http://blogs.msdn.com/b/ie/archive/2006/10/17/accept-language-header-for-internet-explorer-7.aspx
162 asort($browser_langcodes);
163 foreach ($browser_langcodes as $langcode => $qvalue) {
164 $generic_tag = strtok($langcode, '-');
165 if (!isset($browser_langcodes[$generic_tag])) {
166 $browser_langcodes[$generic_tag] = $qvalue;
167 }
168 }
169
170 // Find the enabled language with the greatest qvalue, following the rules
171 // of RFC 2616 (section 14.4). If several languages have the same qvalue,
172 // prefer the one with the greatest weight.
173 $best_match_langcode = FALSE;
174 $max_qvalue = 0;
175 foreach ($languages as $langcode => $language) {
176 // Language tags are case insensitive (RFC2616, sec 3.10).
177 $langcode = strtolower($langcode);
178
179 // If nothing matches below, the default qvalue is the one of the wildcard
180 // language, if set, or is 0 (which will never match).
181 $qvalue = isset($browser_langcodes['*']) ? $browser_langcodes['*'] : 0;
182
183 // Find the longest possible prefix of the browser-supplied language
184 // ('the language-range') that matches this site language ('the language tag').
185 $prefix = $langcode;
186 do {
187 if (isset($browser_langcodes[$prefix])) {
188 $qvalue = $browser_langcodes[$prefix];
189 break;
190 }
191 }
192 while ($prefix = substr($prefix, 0, strrpos($prefix, '-')));
193
194 // Find the best match.
195 if ($qvalue > $max_qvalue) {
196 $best_match_langcode = $language->language;
197 $max_qvalue = $qvalue;
198 }
199 }
200
201 return $best_match_langcode;
202 }
203
213 function locale_language_from_user($languages) {
214 // User preference (only for logged users).
215 global $user;
216
217 if ($user->uid) {
218 return $user->language;
219 }
220
221 // No language preference from the user.
222 return FALSE;
223 }
224
234 function locale_language_from_session($languages) {
235 $param = variable_get('locale_language_negotiation_session_param', 'language');
236
237 // Request parameter: we need to update the session parameter only if we have
238 // an authenticated user.
239 if (isset($_GET[$param]) && isset($languages[$langcode = $_GET[$param]])) {
240 global $user;
241 if ($user->uid) {
242 $_SESSION[$param] = $langcode;
243 }
244 return $langcode;
245 }
246
247 // Session parameter.
248 if (isset($_SESSION[$param])) {
249 return $_SESSION[$param];
250 }
251
252 return FALSE;
253 }
254
264 function locale_language_from_url($languages) {
265 $language_url = FALSE;
266
267 if (!language_negotiation_get_any(LOCALE_LANGUAGE_NEGOTIATION_URL)) {
268 return $language_url;
269 }
270
271 switch (variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX)) {
272 case LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX:
273 // $_GET['q'] might not be available at this time, because
274 // path initialization runs after the language bootstrap phase.
275 list($language, $_GET['q']) = language_url_split_prefix(isset($_GET['q']) ? $_GET['q'] : NULL, $languages);
276 if ($language !== FALSE) {
277 $language_url = $language->language;
278 }
279 break;
280
281 case LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN:
282 // Get only the host, not the port.
283 $http_host= $_SERVER['HTTP_HOST'];
284 if (strpos($http_host, ':') !== FALSE) {
285 $http_host_tmp = explode(':', $http_host);
286 $http_host = current($http_host_tmp);
287 }
288 foreach ($languages as $language) {
289 // Skip check if the language doesn't have a domain.
290 if ($language->domain) {
291 // Only compare the domains not the protocols or ports.
292 // Remove protocol and add http:// so parse_url works
293 $host = 'http://' . str_replace(array('http://', 'https://'), '', $language->domain);
294 $host = parse_url($host, PHP_URL_HOST);
295 if ($http_host == $host) {
296 $language_url = $language->language;
297 break;
298 }
299 }
300 }
301 break;
302 }
303
304 return $language_url;
305 }
306
339 function locale_language_url_fallback($language = NULL, $language_type = LANGUAGE_TYPE_INTERFACE) {
340 $default = language_default();
341 $prefix = (variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX);
342
343 // If the default language is not configured to convey language information,
344 // a missing URL language information indicates that URL language should be
345 // the default one, otherwise we fall back to an already detected language.
346 if (($prefix && empty($default->prefix)) || (!$prefix && empty($default->domain))) {
347 return $default->language;
348 }
349 else {
350 return $GLOBALS[$language_type]->language;
351 }
352 }
353
358 function locale_language_switcher_url($type, $path) {
359 $languages = language_list('enabled');
360 $links = array();
361
362 foreach ($languages[1] as $language) {
363 $links[$language->language] = array(
364 'href' => $path,
365 'title' => $language->native,
366 'language' => $language,
367 'attributes' => array('class' => array('language-link')),
368 );
369 }
370
371 return $links;
372 }
373
377 function locale_language_switcher_session($type, $path) {
378 drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
379
380 $param = variable_get('locale_language_negotiation_session_param', 'language');
381 $language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : $GLOBALS[$type]->language;
382
383 $languages = language_list('enabled');
384 $links = array();
385
386 $query = $_GET;
387 unset($query['q']);
388
389 foreach ($languages[1] as $language) {
390 $langcode = $language->language;
391 $links[$langcode] = array(
392 'href' => $path,
393 'title' => $language->native,
394 'attributes' => array('class' => array('language-link')),
395 'query' => $query,
396 );
397 if ($language_query != $langcode) {
398 $links[$langcode]['query'][$param] = $langcode;
399 }
400 else {
401 $links[$langcode]['attributes']['class'][] = ' session-active';
402 }
403 }
404
405 return $links;
406 }
407
411 function locale_language_url_rewrite_url(&$path, &$options) {
412 static $drupal_static_fast;
413 if (!isset($drupal_static_fast)) {
414 $drupal_static_fast['languages'] = &drupal_static(__FUNCTION__);
415 }
416 $languages = &$drupal_static_fast['languages'];
417
418 if (!isset($languages)) {
419 $languages = language_list('enabled');
420 $languages = array_flip(array_keys($languages[1]));
421 }
422
423 // Language can be passed as an option, or we go for current URL language.
424 if (!isset($options['language'])) {
425 global $language_url;
426 $options['language'] = $language_url;
427 }
428 // We allow only enabled languages here.
429 elseif (!isset($languages[$options['language']->language])) {
430 unset($options['language']);
431 return;
432 }
433
434 if (isset($options['language'])) {
435 switch (variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX)) {
436 case LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN:
437 if ($options['language']->domain) {
438 // Ask for an absolute URL with our modified base_url.
439 global $is_https;
440 $url_scheme = ($is_https) ? 'https://' : 'http://';
441 $options['absolute'] = TRUE;
442
443 // Take the domain without ports or protocols so we can apply the
444 // protocol needed. The setting might include a protocol.
445 // This is changed in Drupal 8 but we need to keep backwards
446 // compatibility for Drupal 7.
447 $host = 'http://' . str_replace(array('http://', 'https://'), '', $options['language']->domain);
448 $host = parse_url($host, PHP_URL_HOST);
449
450 // Apply the appropriate protocol to the URL.
451 $options['base_url'] = $url_scheme . $host;
452 if (isset($options['https']) && variable_get('https', FALSE)) {
453 if ($options['https'] === TRUE) {
454 $options['base_url'] = str_replace('http://', 'https://', $options['base_url']);
455 }
456 elseif ($options['https'] === FALSE) {
457 $options['base_url'] = str_replace('https://', 'http://', $options['base_url']);
458 }
459 }
460 }
461 break;
462
463 case LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX:
464 if (!empty($options['language']->prefix)) {
465 $options['prefix'] = $options['language']->prefix . '/';
466 }
467 break;
468 }
469 }
470 }
471
475 function locale_language_url_rewrite_session(&$path, &$options) {
476 static $query_rewrite, $query_param, $query_value;
477
478 // The following values are not supposed to change during a single page
479 // request processing.
480 if (!isset($query_rewrite)) {
481 global $user;
482 if (!$user->uid) {
483 $languages = language_list('enabled');
484 $languages = $languages[1];
485 $query_param = check_plain(variable_get('locale_language_negotiation_session_param', 'language'));
486 $query_value = isset($_GET[$query_param]) ? check_plain($_GET[$query_param]) : NULL;
487 $query_rewrite = isset($languages[$query_value]) && language_negotiation_get_any(LOCALE_LANGUAGE_NEGOTIATION_SESSION);
488 }
489 else {
490 $query_rewrite = FALSE;
491 }
492 }
493
494 // If the user is anonymous, the user language provider is enabled, and the
495 // corresponding option has been set, we must preserve any explicit user
496 // language preference even with cookies disabled.
497 if ($query_rewrite) {
498 if (is_string($options['query'])) {
499 $options['query'] = drupal_get_query_array($options['query']);
500 }
501 if (!isset($options['query'][$query_param])) {
502 $options['query'][$query_param] = $query_value;
503 }
504 }
505 }
506
525 function locale_string_is_safe($string) {
526 return decode_entities($string) == decode_entities(filter_xss($string, array('a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'ins', 'kbd', 'li', 'ol', 'p', 'pre', 'q', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'ul', 'var')));
527 }
528
559 function locale_add_language($langcode, $name = NULL, $native = NULL, $direction = LANGUAGE_LTR, $domain = '', $prefix = '', $enabled = TRUE, $default = FALSE) {
560 // Default prefix on language code.
561 if (empty($prefix)) {
562 $prefix = $langcode;
563 }
564
565 // If name was not set, we add a predefined language.
566 if (!isset($name)) {
567 include_once DRUPAL_ROOT . '/includes/iso.inc';
568 $predefined = _locale_get_predefined_list();
569 $name = $predefined[$langcode][0];
570 $native = isset($predefined[$langcode][1]) ? $predefined[$langcode][1] : $predefined[$langcode][0];
571 $direction = isset($predefined[$langcode][2]) ? $predefined[$langcode][2] : LANGUAGE_LTR;
572 }
573
574 db_insert('languages')
575 ->fields(array(
576 'language' => $langcode,
577 'name' => $name,
578 'native' => $native,
579 'direction' => $direction,
580 'domain' => $domain,
581 'prefix' => $prefix,
582 'enabled' => $enabled,
583 ))
584 ->execute();
585
586 // Only set it as default if enabled.
587 if ($enabled && $default) {
588 variable_set('language_default', (object) array('language' => $langcode, 'name' => $name, 'native' => $native, 'direction' => $direction, 'enabled' => (int) $enabled, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => $prefix, 'weight' => 0, 'javascript' => ''));
589 }
590
591 if ($enabled) {
592 // Increment enabled language count if we are adding an enabled language.
593 variable_set('language_count', variable_get('language_count', 1) + 1);
594 }
595
596 // Kill the static cache in language_list().
597 drupal_static_reset('language_list');
598
599 // Force JavaScript translation file creation for the newly added language.
600 _locale_invalidate_js($langcode);
601
602 watchdog('locale', 'The %language language (%code) has been created.', array('%language' => $name, '%code' => $langcode));
603
604 module_invoke_all('multilingual_settings_changed');
605 }
633 function _locale_import_po($file, $langcode, $mode, $group = NULL) {
634 // Try to allocate enough time to parse and import the data.
635 drupal_set_time_limit(240);
636
637 // Check if we have the language already in the database.
638 if (!db_query("SELECT COUNT(language) FROM {languages} WHERE language = :language", array(':language' => $langcode))->fetchField()) {
639 drupal_set_message(t('The language selected for import is not supported.'), 'error');
640 return FALSE;
641 }
642
643 // Get strings from file (returns on failure after a partial import, or on success)
644 $status = _locale_import_read_po('db-store', $file, $mode, $langcode, $group);
645 if ($status === FALSE) {
646 // Error messages are set in _locale_import_read_po().
647 return FALSE;
648 }
649
650 // Get status information on import process.
651 list($header_done, $additions, $updates, $deletes, $skips) = _locale_import_one_string('db-report');
652
653 if (!$header_done) {
654 drupal_set_message(t('The translation file %filename appears to have a missing or malformed header.', array('%filename' => $file->filename)), 'error');
655 }
656
657 // Clear cache and force refresh of JavaScript translations.
658 _locale_invalidate_js($langcode);
659 cache_clear_all('locale:', 'cache', TRUE);
660
661 // Rebuild the menu, strings may have changed.
662 menu_rebuild();
663
664 drupal_set_message(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => $additions, '%update' => $updates, '%delete' => $deletes)));
665 watchdog('locale', 'Imported %file into %locale: %number new strings added, %update updated and %delete removed.', array('%file' => $file->filename, '%locale' => $langcode, '%number' => $additions, '%update' => $updates, '%delete' => $deletes));
666 if ($skips) {
667 $skip_message = format_plural($skips, 'One translation string was skipped because it contains disallowed HTML.', '@count translation strings were skipped because they contain disallowed HTML.');
668 drupal_set_message($skip_message);
669 watchdog('locale', '@count disallowed HTML string(s) in %file', array('@count' => $skips, '%file' => $file->uri), WATCHDOG_WARNING);
670 }
671 return TRUE;
672 }
673
690 function _locale_import_read_po($op, $file, $mode = NULL, $lang = NULL, $group = 'default') {
691
692 // The file will get closed by PHP on returning from this function.
693 $fd = fopen($file->uri, 'rb');
694 if (!$fd) {
695 _locale_import_message('The translation import failed, because the file %filename could not be read.', $file);
696 return FALSE;
697 }
698
699 /*
700 * The parser context. Can be:
701 * - 'COMMENT' (#)
702 * - 'MSGID' (msgid)
703 * - 'MSGID_PLURAL' (msgid_plural)
704 * - 'MSGCTXT' (msgctxt)
705 * - 'MSGSTR' (msgstr or msgstr[])
706 * - 'MSGSTR_ARR' (msgstr_arg)
707 */
708 $context = 'COMMENT';
709
710 // Current entry being read.
711 $current = array();
712
713 // Current plurality for 'msgstr[]'.
714 $plural = 0;
715
716 // Current line.
717 $lineno = 0;
718
719 while (!feof($fd)) {
720 // A line should not be longer than 10 * 1024.
721 $line = fgets($fd, 10 * 1024);
722
723 if ($lineno == 0) {
724 // The first line might come with a UTF-8 BOM, which should be removed.
725 $line = str_replace("\xEF\xBB\xBF", '', $line);
726 }
727
728 $lineno++;
729
730 // Trim away the linefeed.
731 $line = trim(strtr($line, array("\\\n" => "")));
732
733 if (!strncmp('#', $line, 1)) {
734 // Lines starting with '#' are comments.
735
736 if ($context == 'COMMENT') {
737 // Already in comment token, insert the comment.
738 $current['#'][] = substr($line, 1);
739 }
740 elseif (($context == 'MSGSTR') || ($context == 'MSGSTR_ARR')) {
741 // We are currently in string token, close it out.
742 _locale_import_one_string($op, $current, $mode, $lang, $file, $group);
743
744 // Start a new entry for the comment.
745 $current = array();
746 $current['#'][] = substr($line, 1);
747
748 $context = 'COMMENT';
749 }
750 else {
751 // A comment following any other token is a syntax error.
752 _locale_import_message('The translation file %filename contains an error: "msgstr" was expected but not found on line %line.', $file, $lineno);
753 return FALSE;
754 }
755 }
756 elseif (!strncmp('msgid_plural', $line, 12)) {
757 // A plural form for the current message.
758
759 if ($context != 'MSGID') {
760 // A plural form cannot be added to anything else but the id directly.
761 _locale_import_message('The translation file %filename contains an error: "msgid_plural" was expected but not found on line %line.', $file, $lineno);
762 return FALSE;
763 }
764
765 // Remove 'msgid_plural' and trim away whitespace.
766 $line = trim(substr($line, 12));
767 // At this point, $line should now contain only the plural form.
768
769 $quoted = _locale_import_parse_quoted($line);
770 if ($quoted === FALSE) {
771 // The plural form must be wrapped in quotes.
772 _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno);
773 return FALSE;
774 }
775
776 // Append the plural form to the current entry.
777 $current['msgid'] .= "\0" . $quoted;
778
779 $context = 'MSGID_PLURAL';
780 }
781 elseif (!strncmp('msgid', $line, 5)) {
782 // Starting a new message.
783
784 if (($context == 'MSGSTR') || ($context == 'MSGSTR_ARR')) {
785 // We are currently in a message string, close it out.
786 _locale_import_one_string($op, $current, $mode, $lang, $file, $group);
787
788 // Start a new context for the id.
789 $current = array();
790 }
791 elseif ($context == 'MSGID') {
792 // We are currently already in the context, meaning we passed an id with no data.
793 _locale_import_message('The translation file %filename contains an error: "msgid" is unexpected on line %line.', $file, $lineno);
794 return FALSE;
795 }
796
797 // Remove 'msgid' and trim away whitespace.
798 $line = trim(substr($line, 5));
799 // At this point, $line should now contain only the message id.
800
801 $quoted = _locale_import_parse_quoted($line);
802 if ($quoted === FALSE) {
803 // The message id must be wrapped in quotes.
804 _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno);
805 return FALSE;
806 }
807
808 $current['msgid'] = $quoted;
809 $context = 'MSGID';
810 }
811 elseif (!strncmp('msgctxt', $line, 7)) {
812 // Starting a new context.
813
814 if (($context == 'MSGSTR') || ($context == 'MSGSTR_ARR')) {
815 // We are currently in a message, start a new one.
816 _locale_import_one_string($op, $current, $mode, $lang, $file, $group);
817 $current = array();
818 }
819 elseif (!empty($current['msgctxt'])) {
820 // A context cannot apply to another context.
821 _locale_import_message('The translation file %filename contains an error: "msgctxt" is unexpected on line %line.', $file, $lineno);
822 return FALSE;
823 }
824
825 // Remove 'msgctxt' and trim away whitespaces.
826 $line = trim(substr($line, 7));
827 // At this point, $line should now contain the context.
828
829 $quoted = _locale_import_parse_quoted($line);
830 if ($quoted === FALSE) {
831 // The context string must be quoted.
832 _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno);
833 return FALSE;
834 }
835
836 $current['msgctxt'] = $quoted;
837
838 $context = 'MSGCTXT';
839 }
840 elseif (!strncmp('msgstr[', $line, 7)) {
841 // A message string for a specific plurality.
842
843 if (($context != 'MSGID') && ($context != 'MSGCTXT') && ($context != 'MSGID_PLURAL') && ($context != 'MSGSTR_ARR')) {
844 // Message strings must come after msgid, msgxtxt, msgid_plural, or other msgstr[] entries.
845 _locale_import_message('The translation file %filename contains an error: "msgstr[]" is unexpected on line %line.', $file, $lineno);
846 return FALSE;
847 }
848
849 // Ensure the plurality is terminated.
850 if (strpos($line, ']') === FALSE) {
851 _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno);
852 return FALSE;
853 }
854
855 // Extract the plurality.
856 $frombracket = strstr($line, '[');
857 $plural = substr($frombracket, 1, strpos($frombracket, ']') - 1);
858
859 // Skip to the next whitespace and trim away any further whitespace, bringing $line to the message data.
860 $line = trim(strstr($line, " "));
861
862 $quoted = _locale_import_parse_quoted($line);
863 if ($quoted === FALSE) {
864 // The string must be quoted.
865 _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno);
866 return FALSE;
867 }
868
869 $current['msgstr'][$plural] = $quoted;
870
871 $context = 'MSGSTR_ARR';
872 }
873 elseif (!strncmp("msgstr", $line, 6)) {
874 // A string for the an id or context.
875
876 if (($context != 'MSGID') && ($context != 'MSGCTXT')) {
877 // Strings are only valid within an id or context scope.
878 _locale_import_message('The translation file %filename contains an error: "msgstr" is unexpected on line %line.', $file, $lineno);
879 return FALSE;
880 }
881
882 // Remove 'msgstr' and trim away away whitespaces.
883 $line = trim(substr($line, 6));
884 // At this point, $line should now contain the message.
885
886 $quoted = _locale_import_parse_quoted($line);
887 if ($quoted === FALSE) {
888 // The string must be quoted.
889 _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno);
890 return FALSE;
891 }
892
893 $current['msgstr'] = $quoted;
894
895 $context = 'MSGSTR';
896 }
897 elseif ($line != '') {
898 // Anything that is not a token may be a continuation of a previous token.
899
900 $quoted = _locale_import_parse_quoted($line);
901 if ($quoted === FALSE) {
902 // The string must be quoted.
903 _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno);
904 return FALSE;
905 }
906
907 // Append the string to the current context.
908 if (($context == 'MSGID') || ($context == 'MSGID_PLURAL')) {
909 $current['msgid'] .= $quoted;
910 }
911 elseif ($context == 'MSGCTXT') {
912 $current['msgctxt'] .= $quoted;
913 }
914 elseif ($context == 'MSGSTR') {
915 $current['msgstr'] .= $quoted;
916 }
917 elseif ($context == 'MSGSTR_ARR') {
918 $current['msgstr'][$plural] .= $quoted;
919 }
920 else {
921 // No valid context to append to.
922 _locale_import_message('The translation file %filename contains an error: there is an unexpected string on line %line.', $file, $lineno);
923 return FALSE;
924 }
925 }
926 }
927
928 // End of PO file, closed out the last entry.
929 if (($context == 'MSGSTR') || ($context == 'MSGSTR_ARR')) {
930 _locale_import_one_string($op, $current, $mode, $lang, $file, $group);
931 }
932 elseif ($context != 'COMMENT') {
933 _locale_import_message('The translation file %filename ended unexpectedly at line %line.', $file, $lineno);
934 return FALSE;
935 }
936 }
937
948 function _locale_import_message($message, $file, $lineno = NULL) {
949 $vars = array('%filename' => $file->filename);
950 if (isset($lineno)) {
951 $vars['%line'] = $lineno;
952 }
953 $t = get_t();
954 drupal_set_message($t($message, $vars), 'error');
955 }
956
976 function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NULL, $file = NULL, $group = 'default') {
977 $report = &drupal_static(__FUNCTION__, array('additions' => 0, 'updates' => 0, 'deletes' => 0, 'skips' => 0));
978 $header_done = &drupal_static(__FUNCTION__ . ':header_done', FALSE);
979 $strings = &drupal_static(__FUNCTION__ . ':strings', array());
980
981 switch ($op) {
982 // Return stored strings
983 case 'mem-report':
984 return $strings;
985
986 // Store string in memory (only supports single strings)
987 case 'mem-store':
988 $strings[isset($value['msgctxt']) ? $value['msgctxt'] : ''][$value['msgid']] = $value['msgstr'];
989 return;
990
991 // Called at end of import to inform the user
992 case 'db-report':
993 return array($header_done, $report['additions'], $report['updates'], $report['deletes'], $report['skips']);
994
995 // Store the string we got in the database.
996 case 'db-store':
997 // We got header information.
998 if ($value['msgid'] == '') {
999 $languages = language_list();
1000 if (($mode != LOCALE_IMPORT_KEEP) || empty($languages[$lang]->plurals)) {
1001 // Since we only need to parse the header if we ought to update the
1002 // plural formula, only run this if we don't need to keep existing
1003 // data untouched or if we don't have an existing plural formula.
1004 $header = _locale_import_parse_header($value['msgstr']);
1005
1006 // Get and store the plural formula if available.
1007 if (isset($header["Plural-Forms"]) && $p = _locale_import_parse_plural_forms($header["Plural-Forms"], $file->uri)) {
1008 list($nplurals, $plural) = $p;
1009 db_update('languages')
1010 ->fields(array(
1011 'plurals' => $nplurals,
1012 'formula' => $plural,
1013 ))
1014 ->condition('language', $lang)
1015 ->execute();
1016 }
1017 }
1018 $header_done = TRUE;
1019 }
1020
1021 else {
1022 // Some real string to import.
1023 $comments = _locale_import_shorten_comments(empty($value['#']) ? array() : $value['#']);
1024
1025 if (strpos($value['msgid'], "\0")) {
1026 // This string has plural versions.
1027 $english = explode("\0", $value['msgid'], 2);
1028 $entries = array_keys($value['msgstr']);
1029 for ($i = 3; $i <= count($entries); $i++) {
1030 $english[] = $english[1];
1031 }
1032 $translation = array_map('_locale_import_append_plural', $value['msgstr'], $entries);
1033 $english = array_map('_locale_import_append_plural', $english, $entries);
1034 foreach ($translation as $key => $trans) {
1035 if ($key == 0) {
1036 $plid = 0;
1037 }
1038 $plid = _locale_import_one_string_db($report, $lang, isset($value['msgctxt']) ? $value['msgctxt'] : '', $english[$key], $trans, $group, $comments, $mode, $plid, $key);
1039 }
1040 }
1041
1042 else {
1043 // A simple string to import.
1044 $english = $value['msgid'];
1045 $translation = $value['msgstr'];
1046 _locale_import_one_string_db($report, $lang, isset($value['msgctxt']) ? $value['msgctxt'] : '', $english, $translation, $group, $comments, $mode);
1047 }
1048 }
1049 } // end of db-store operation
1050 }
1051
1080 function _locale_import_one_string_db(&$report, $langcode, $context, $source, $translation, $textgroup, $location, $mode, $plid = 0, $plural = 0) {
1081 $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = :context AND textgroup = :textgroup", array(':source' => $source, ':context' => $context, ':textgroup' => $textgroup))->fetchField();
1082
1083 if (!empty($translation)) {
1084 // Skip this string unless it passes a check for dangerous code.
1085 // Text groups other than default still can contain HTML tags
1086 // (i.e. translatable blocks).
1087 if ($textgroup == "default" && !locale_string_is_safe($translation)) {
1088 $report['skips']++;
1089 $lid = 0;
1090 }
1091 elseif ($lid) {
1092 // We have this source string saved already.
1093 db_update('locales_source')
1094 ->fields(array(
1095 'location' => $location,
1096 ))
1097 ->condition('lid', $lid)
1098 ->execute();
1099
1100 $exists = db_query("SELECT COUNT(lid) FROM {locales_target} WHERE lid = :lid AND language = :language", array(':lid' => $lid, ':language' => $langcode))->fetchField();
1101
1102 if (!$exists) {
1103 // No translation in this language.
1104 db_insert('locales_target')
1105 ->fields(array(
1106 'lid' => $lid,
1107 'language' => $langcode,
1108 'translation' => $translation,
1109 'plid' => $plid,
1110 'plural' => $plural,
1111 ))
1112 ->execute();
1113
1114 $report['additions']++;
1115 }
1116 elseif ($mode == LOCALE_IMPORT_OVERWRITE) {
1117 // Translation exists, only overwrite if instructed.
1118 db_update('locales_target')
1119 ->fields(array(
1120 'translation' => $translation,
1121 'plid' => $plid,
1122 'plural' => $plural,
1123 ))
1124 ->condition('language', $langcode)
1125 ->condition('lid', $lid)
1126 ->execute();
1127
1128 $report['updates']++;
1129 }
1130 }
1131 else {
1132 // No such source string in the database yet.
1133 $lid = db_insert('locales_source')
1134 ->fields(array(
1135 'location' => $location,
1136 'source' => $source,
1137 'context' => (string) $context,
1138 'textgroup' => $textgroup,
1139 ))
1140 ->execute();
1141
1142 db_insert('locales_target')
1143 ->fields(array(
1144 'lid' => $lid,
1145 'language' => $langcode,
1146 'translation' => $translation,
1147 'plid' => $plid,
1148 'plural' => $plural
1149 ))
1150 ->execute();
1151
1152 $report['additions']++;
1153 }
1154 }
1155 elseif ($mode == LOCALE_IMPORT_OVERWRITE) {
1156 // Empty translation, remove existing if instructed.
1157 db_delete('locales_target')
1158 ->condition('language', $langcode)
1159 ->condition('lid', $lid)
1160 ->condition('plid', $plid)
1161 ->condition('plural', $plural)
1162 ->execute();
1163
1164 $report['deletes']++;
1165 }
1166
1167 return $lid;
1168 }
1169
1179 function _locale_import_parse_header($header) {
1180 $header_parsed = array();
1181 $lines = array_map('trim', explode("\n", $header));
1182 foreach ($lines as $line) {
1183 if ($line) {
1184 list($tag, $contents) = explode(":", $line, 2);
1185 $header_parsed[trim($tag)] = trim($contents);
1186 }
1187 }
1188 return $header_parsed;
1189 }
1190
1203 function _locale_import_parse_plural_forms($pluralforms, $filepath) {
1204 // First, delete all whitespace
1205 $pluralforms = strtr($pluralforms, array(" " => "", "\t" => ""));
1206
1207 // Select the parts that define nplurals and plural
1208 $nplurals = strstr($pluralforms, "nplurals=");
1209 if (strpos($nplurals, ";")) {
1210 $nplurals = substr($nplurals, 9, strpos($nplurals, ";") - 9);
1211 }
1212 else {
1213 return FALSE;
1214 }
1215 $plural = strstr($pluralforms, "plural=");
1216 if (strpos($plural, ";")) {
1217 $plural = substr($plural, 7, strpos($plural, ";") - 7);
1218 }
1219 else {
1220 return FALSE;
1221 }
1222
1223 // Get PHP version of the plural formula
1224 $plural = _locale_import_parse_arithmetic($plural);
1225
1226 if ($plural !== FALSE) {
1227 return array($nplurals, $plural);
1228 }
1229 else {
1230 drupal_set_message(t('The translation file %filepath contains an error: the plural formula could not be parsed.', array('%filepath' => $filepath)), 'error');
1231 return FALSE;
1232 }
1233 }
1234
1247 function _locale_import_parse_arithmetic($string) {
1248 // Operator precedence table
1249 $precedence = array("(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8);
1250 // Right associativity
1251 $right_associativity = array("?" => 1, ":" => 1);
1252
1253 $tokens = _locale_import_tokenize_formula($string);
1254
1255 // Parse by converting into infix notation then back into postfix
1256 // Operator stack - holds math operators and symbols
1257 $operator_stack = array();
1258 // Element Stack - holds data to be operated on
1259 $element_stack = array();
1260
1261 foreach ($tokens as $token) {
1262 $current_token = $token;
1263
1264 // Numbers and the $n variable are simply pushed into $element_stack
1265 if (is_numeric($token)) {
1266 $element_stack[] = $current_token;
1267 }
1268 elseif ($current_token == "n") {
1269 $element_stack[] = '$n';
1270 }
1271 elseif ($current_token == "(") {
1272 $operator_stack[] = $current_token;
1273 }
1274 elseif ($current_token == ")") {
1275 $topop = array_pop($operator_stack);
1276 while (isset($topop) && ($topop != "(")) {
1277 $element_stack[] = $topop;
1278 $topop = array_pop($operator_stack);
1279 }
1280 }
1281 elseif (!empty($precedence[$current_token])) {
1282 // If it's an operator, then pop from $operator_stack into $element_stack until the
1283 // precedence in $operator_stack is less than current, then push into $operator_stack
1284 $topop = array_pop($operator_stack);
1285 while (isset($topop) && ($precedence[$topop] >= $precedence[$current_token]) && !(($precedence[$topop] == $precedence[$current_token]) && !empty($right_associativity[$topop]) && !empty($right_associativity[$current_token]))) {
1286 $element_stack[] = $topop;
1287 $topop = array_pop($operator_stack);
1288 }
1289 if ($topop) {
1290 $operator_stack[] = $topop; // Return element to top
1291 }
1292 $operator_stack[] = $current_token; // Parentheses are not needed
1293 }
1294 else {
1295 return FALSE;
1296 }
1297 }
1298
1299 // Flush operator stack
1300 $topop = array_pop($operator_stack);
1301 while ($topop != NULL) {
1302 $element_stack[] = $topop;
1303 $topop = array_pop($operator_stack);
1304 }
1305
1306 // Now extract formula from stack
1307 $previous_size = count($element_stack) + 1;
1308 while (count($element_stack) < $previous_size) {
1309 $previous_size = count($element_stack);
1310 for ($i = 2; $i < count($element_stack); $i++) {
1311 $op = $element_stack[$i];
1312 if (!empty($precedence[$op])) {
1313 $f = "";
1314 if ($op == ":") {
1315 $f = $element_stack[$i - 2] . "):" . $element_stack[$i - 1] . ")";
1316 }
1317 elseif ($op == "?") {
1318 $f = "(" . $element_stack[$i - 2] . "?(" . $element_stack[$i - 1];
1319 }
1320 else {
1321 $f = "(" . $element_stack[$i - 2] . $op . $element_stack[$i - 1] . ")";
1322 }
1323 array_splice($element_stack, $i - 2, 3, $f);
1324 break;
1325 }
1326 }
1327 }
1328
1329 // If only one element is left, the number of operators is appropriate
1330 if (count($element_stack) == 1) {
1331 return $element_stack[0];
1332 }
1333 else {
1334 return FALSE;
1335 }
1336 }
1337
1347 function _locale_import_tokenize_formula($formula) {
1348 $formula = str_replace(" ", "", $formula);
1349 $tokens = array();
1350 for ($i = 0; $i < strlen($formula); $i++) {
1351 if (is_numeric($formula[$i])) {
1352 $num = $formula[$i];
1353 $j = $i + 1;
1354 while ($j < strlen($formula) && is_numeric($formula[$j])) {
1355 $num .= $formula[$j];
1356 $j++;
1357 }
1358 $i = $j - 1;
1359 $tokens[] = $num;
1360 }
1361 elseif ($pos = strpos(" =<>!&|", $formula[$i])) { // We won't have a space
1362 $next = $formula[$i + 1];
1363 switch ($pos) {
1364 case 1:
1365 case 2:
1366 case 3:
1367 case 4:
1368 if ($next == '=') {
1369 $tokens[] = $formula[$i] . '=';
1370 $i++;
1371 }
1372 else {
1373 $tokens[] = $formula[$i];
1374 }
1375 break;
1376 case 5:
1377 if ($next == '&') {
1378 $tokens[] = '&&';
1379 $i++;
1380 }
1381 else {
1382 $tokens[] = $formula[$i];
1383 }
1384 break;
1385 case 6:
1386 if ($next == '|') {
1387 $tokens[] = '||';
1388 $i++;
1389 }
1390 else {
1391 $tokens[] = $formula[$i];
1392 }
1393 break;
1394 }
1395 }
1396 else {
1397 $tokens[] = $formula[$i];
1398 }
1399 }
1400 return $tokens;
1401 }
1402
1413 function _locale_import_append_plural($entry, $key) {
1414 // No modifications for 0, 1
1415 if ($key == 0 || $key == 1) {
1416 return $entry;
1417 }
1418
1419 // First remove any possibly false indices, then add new ones
1420 $entry = preg_replace('/(@count)\[[0-9]\]/', '\\1', $entry);
1421 return preg_replace('/(@count)/', "\\1[$key]", $entry);
1422 }
1423
1433 function _locale_import_shorten_comments($comment) {
1434 $comm = '';
1435 while (count($comment)) {
1436 $test = $comm . substr(array_shift($comment), 1) . ', ';
1437 if (strlen($comm) < 130) {
1438 $comm = $test;
1439 }
1440 else {
1441 break;
1442 }
1443 }
1444 return trim(substr($comm, 0, -2));
1445 }
1446
1456 function _locale_import_parse_quoted($string) {
1457 if (substr($string, 0, 1) != substr($string, -1, 1)) {
1458 return FALSE; // Start and end quotes must be the same
1459 }
1460 $quote = substr($string, 0, 1);
1461 $string = substr($string, 1, -1);
1462 if ($quote == '"') { // Double quotes: strip slashes
1463 return stripcslashes($string);
1464 }
1465 elseif ($quote == "'") { // Simple quote: return as-is
1466 return $string;
1467 }
1468 else {
1469 return FALSE; // Unrecognized quote
1470 }
1471 }
1480 function _locale_parse_js_file($filepath) {
1481 global $language;
1482
1483 // The file path might contain a query string, so make sure we only use the
1484 // actual file.
1485 $parsed_url = drupal_parse_url($filepath);
1486 $filepath = $parsed_url['path'];
1487 // Load the JavaScript file.
1488 $file = file_get_contents($filepath);
1489
1490 // Match all calls to Drupal.t() in an array.
1491 // Note: \s also matches newlines with the 's' modifier.
1492 preg_match_all('~
1493 [^\w]Drupal\s*\.\s*t\s* # match "Drupal.t" with whitespace
1494 \(\s* # match "(" argument list start
1495 (' . LOCALE_JS_STRING . ')\s* # capture string argument
1496 (?:,\s*' . LOCALE_JS_OBJECT . '\s* # optionally capture str args
1497 (?:,\s*' . LOCALE_JS_OBJECT_CONTEXT . '\s*) # optionally capture context
1498 ?)? # close optional args
1499 [,\)] # match ")" or "," to finish
1500 ~sx', $file, $t_matches);
1501
1502 // Match all Drupal.formatPlural() calls in another array.
1503 preg_match_all('~
1504 [^\w]Drupal\s*\.\s*formatPlural\s* # match "Drupal.formatPlural" with whitespace
1505 \( # match "(" argument list start
1506 \s*.+?\s*,\s* # match count argument
1507 (' . LOCALE_JS_STRING . ')\s*,\s* # match singular string argument
1508 ( # capture plural string argument
1509 (?: # non-capturing group to repeat string pieces
1510 (?:
1511 \' # match start of single-quoted string
1512 (?:\\\\\'|[^\'])* # match any character except unescaped single-quote
1513 @count # match "@count"
1514 (?:\\\\\'|[^\'])* # match any character except unescaped single-quote
1515 \' # match end of single-quoted string
1516 |
1517 " # match start of double-quoted string
1518 (?:\\\\"|[^"])* # match any character except unescaped double-quote
1519 @count # match "@count"
1520 (?:\\\\"|[^"])* # match any character except unescaped double-quote
1521 " # match end of double-quoted string
1522 )
1523 (?:\s*\+\s*)? # match "+" with possible whitespace, for str concat
1524 )+ # match multiple because we supports concatenating strs
1525 )\s* # end capturing of plural string argument
1526 (?:,\s*' . LOCALE_JS_OBJECT . '\s* # optionally capture string args
1527 (?:,\s*' . LOCALE_JS_OBJECT_CONTEXT . '\s*)? # optionally capture context
1528 )?
1529 [,\)]
1530 ~sx', $file, $plural_matches);
1531
1532 $matches = array();
1533
1534 // Add strings from Drupal.t().
1535 foreach ($t_matches[1] as $key => $string) {
1536 $matches[] = array(
1537 'string' => $string,
1538 'context' => $t_matches[2][$key],
1539 );
1540 }
1541
1542 // Add string from Drupal.formatPlural().
1543 foreach ($plural_matches[1] as $key => $string) {
1544 $matches[] = array(
1545 'string' => $string,
1546 'context' => $plural_matches[3][$key],
1547 );
1548
1549 // If there is also a plural version of this string, add it to the strings array.
1550 if (isset($plural_matches[2][$key])) {
1551 $matches[] = array(
1552 'string' => $plural_matches[2][$key],
1553 'context' => $plural_matches[3][$key],
1554 );
1555 }
1556 }
1557
1558 foreach ($matches as $key => $match) {
1559 // Remove the quotes and string concatenations from the string.
1560 $string = implode('', preg_split('~(?<!\\\\)[\'"]\s*\+\s*[\'"]~s', substr($match['string'], 1, -1)));
1561 $context = implode('', preg_split('~(?<!\\\\)[\'"]\s*\+\s*[\'"]~s', substr($match['context'], 1, -1)));
1562
1563 $source = db_query("SELECT lid, location FROM {locales_source} WHERE source = :source AND context = :context AND textgroup = 'default'", array(':source' => $string, ':context' => $context))->fetchObject();
1564 if ($source) {
1565 // We already have this source string and now have to add the location
1566 // to the location column, if this file is not yet present in there.
1567 $locations = preg_split('~\s*;\s*~', $source->location);
1568
1569 if (!in_array($filepath, $locations)) {
1570 $locations[] = $filepath;
1571 $locations = implode('; ', $locations);
1572
1573 // Save the new locations string to the database.
1574 db_update('locales_source')
1575 ->fields(array(
1576 'location' => $locations,
1577 ))
1578 ->condition('lid', $source->lid)
1579 ->execute();
1580 }
1581 }
1582 else {
1583 // We don't have the source string yet, thus we insert it into the database.
1584 db_insert('locales_source')
1585 ->fields(array(
1586 'location' => $filepath,
1587 'source' => $string,
1588 'context' => $context,
1589 'textgroup' => 'default',
1590 ))
1591 ->execute();
1592 }
1593 }
1594 }
1595
1613 function _locale_export_get_strings($language = NULL, $group = 'default') {
1614 if (isset($language)) {
1615 $result = db_query("SELECT s.lid, s.source, s.context, s.location, t.translation, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.textgroup = :textgroup ORDER BY t.plid, t.plural", array(':language' => $language->language, ':textgroup' => $group));
1616 }
1617 else {
1618 $result = db_query("SELECT s.lid, s.source, s.context, s.location, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid WHERE s.textgroup = :textgroup ORDER BY t.plid, t.plural", array(':textgroup' => $group));
1619 }
1620 $strings = array();
1621 foreach ($result as $child) {
1622 $string = array(
1623 'comment' => $child->location,
1624 'source' => $child->source,
1625 'context' => $child->context,
1626 'translation' => isset($child->translation) ? $child->translation : '',
1627 );
1628 if ($child->plid) {
1629 // Has a parent lid. Since we process in the order of plids,
1630 // we already have the parent in the array, so we can add the
1631 // lid to the next plural version to it. This builds a linked
1632 // list of plurals.
1633 $string['child'] = TRUE;
1634 $strings[$child->plid]['plural'] = $child->lid;
1635 }
1636 $strings[$child->lid] = $string;
1637 }
1638 return $strings;
1639 }
1640
1654 function _locale_export_po_generate($language = NULL, $strings = array(), $header = NULL) {
1655 global $user;
1656
1657 if (!isset($header)) {
1658 if (isset($language)) {
1659 $header = '# ' . $language->name . ' translation of ' . variable_get('site_name', 'Drupal') . "\n";
1660 $header .= '# Generated by ' . $user->name . ' <' . $user->mail . ">\n";
1661 $header .= "#\n";
1662 $header .= "msgid \"\"\n";
1663 $header .= "msgstr \"\"\n";
1664 $header .= "\"Project-Id-Version: PROJECT VERSION\\n\"\n";
1665 $header .= "\"POT-Creation-Date: " . date("Y-m-d H:iO") . "\\n\"\n";
1666 $header .= "\"PO-Revision-Date: " . date("Y-m-d H:iO") . "\\n\"\n";
1667 $header .= "\"Last-Translator: NAME <EMAIL@ADDRESS>\\n\"\n";
1668 $header .= "\"Language-Team: LANGUAGE <EMAIL@ADDRESS>\\n\"\n";
1669 $header .= "\"MIME-Version: 1.0\\n\"\n";
1670 $header .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n";
1671 $header .= "\"Content-Transfer-Encoding: 8bit\\n\"\n";
1672 if ($language->formula && $language->plurals) {
1673 $header .= "\"Plural-Forms: nplurals=" . $language->plurals . "; plural=" . strtr($language->formula, array('$' => '')) . ";\\n\"\n";
1674 }
1675 }
1676 else {
1677 $header = "# LANGUAGE translation of PROJECT\n";
1678 $header .= "# Copyright (c) YEAR NAME <EMAIL@ADDRESS>\n";
1679 $header .= "#\n";
1680 $header .= "msgid \"\"\n";
1681 $header .= "msgstr \"\"\n";
1682 $header .= "\"Project-Id-Version: PROJECT VERSION\\n\"\n";
1683 $header .= "\"POT-Creation-Date: " . date("Y-m-d H:iO") . "\\n\"\n";
1684 $header .= "\"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\\n\"\n";
1685 $header .= "\"Last-Translator: NAME <EMAIL@ADDRESS>\\n\"\n";
1686 $header .= "\"Language-Team: LANGUAGE <EMAIL@ADDRESS>\\n\"\n";
1687 $header .= "\"MIME-Version: 1.0\\n\"\n";
1688 $header .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n";
1689 $header .= "\"Content-Transfer-Encoding: 8bit\\n\"\n";
1690 $header .= "\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n\"\n";
1691 }
1692 }
1693
1694 $output = $header . "\n";
1695
1696 foreach ($strings as $lid => $string) {
1697 // Only process non-children, children are output below their parent.
1698 if (!isset($string['child'])) {
1699 if ($string['comment']) {
1700 $output .= '#: ' . $string['comment'] . "\n";
1701 }
1702 if (!empty($string['context'])) {
1703 $output .= 'msgctxt ' . _locale_export_string($string['context']);
1704 }
1705 $output .= 'msgid ' . _locale_export_string($string['source']);
1706 if (!empty($string['plural'])) {
1707 $plural = $string['plural'];
1708 $output .= 'msgid_plural ' . _locale_export_string($strings[$plural]['source']);
1709 if (isset($language)) {
1710 $translation = $string['translation'];
1711 for ($i = 0; $i < $language->plurals; $i++) {
1712 $output .= 'msgstr[' . $i . '] ' . _locale_export_string($translation);
1713 if ($plural) {
1714 $translation = _locale_export_remove_plural($strings[$plural]['translation']);
1715 $plural = isset($strings[$plural]['plural']) ? $strings[$plural]['plural'] : 0;
1716 }
1717 else {
1718 $translation = '';
1719 }
1720 }
1721 }
1722 else {
1723 $output .= 'msgstr[0] ""' . "\n";
1724 $output .= 'msgstr[1] ""' . "\n";
1725 }
1726 }
1727 else {
1728 $output .= 'msgstr ' . _locale_export_string($string['translation']);
1729 }
1730 $output .= "\n";
1731 }
1732 }
1733 return $output;
1734 }
1735
1746 function _locale_export_po($language = NULL, $output = NULL) {
1747 // Log the export event.
1748 if (isset($language)) {
1749 $filename = $language->language . '.po';
1750 watchdog('locale', 'Exported %locale translation file: %filename.', array('%locale' => $language->name, '%filename' => $filename));
1751 }
1752 else {
1753 $filename = 'drupal.pot';
1754 watchdog('locale', 'Exported translation file: %filename.', array('%filename' => $filename));
1755 }
1756 // Download the file for the client.
1757 header("Content-Disposition: attachment; filename=$filename");
1758 header("Content-Type: text/plain; charset=utf-8");
1759 print $output;
1760 drupal_exit();
1761 }
1762
1766 function _locale_export_string($str) {
1767 $stri = addcslashes($str, "\0..\37\\\"");
1768 $parts = array();
1769
1770 // Cut text into several lines
1771 while ($stri != "") {
1772 $i = strpos($stri, "\\n");
1773 if ($i === FALSE) {
1774 $curstr = $stri;
1775 $stri = "";
1776 }
1777 else {
1778 $curstr = substr($stri, 0, $i + 2);
1779 $stri = substr($stri, $i + 2);
1780 }
1781 $curparts = explode("\n", _locale_export_wrap($curstr, 70));
1782 $parts = array_merge($parts, $curparts);
1783 }
1784
1785 // Multiline string
1786 if (count($parts) > 1) {
1787 return "\"\"\n\"" . implode("\"\n\"", $parts) . "\"\n";
1788 }
1789 // Single line string
1790 elseif (count($parts) == 1) {
1791 return "\"$parts[0]\"\n";
1792 }
1793 // No translation
1794 else {
1795 return "\"\"\n";
1796 }
1797 }
1798
1802 function _locale_export_wrap($str, $len) {
1803 $words = explode(' ', $str);
1804 $return = array();
1805
1806 $cur = "";
1807 $nstr = 1;
1808 while (count($words)) {
1809 $word = array_shift($words);
1810 if ($nstr) {
1811 $cur = $word;
1812 $nstr = 0;
1813 }
1814 elseif (strlen("$cur $word") > $len) {
1815 $return[] = $cur . " ";
1816 $cur = $word;
1817 }
1818 else {
1819 $cur = "$cur $word";
1820 }
1821 }
1822 $return[] = $cur;
1823
1824 return implode("\n", $return);
1825 }
1826
1830 function _locale_export_remove_plural($entry) {
1831 return preg_replace('/(@count)\[[0-9]\]/', '\\1', $entry);
1832 }
1849 function _locale_translate_seek() {
1850 $output = '';
1851
1852 // We have at least one criterion to match
1853 if (!($query = _locale_translate_seek_query())) {
1854 $query = array(
1855 'translation' => 'all',
1856 'group' => 'all',
1857 'language' => 'all',
1858 'string' => '',
1859 );
1860 }
1861
1862 $sql_query = db_select('locales_source', 's');
1863
1864 $limit_language = NULL;
1865 if ($query['language'] != 'en' && $query['language'] != 'all') {
1866 $sql_query->leftJoin('locales_target', 't', "t.lid = s.lid AND t.language = :langcode", array(':langcode' => $query['language']));
1867 $limit_language = $query['language'];
1868 }
1869 else {
1870 $sql_query->leftJoin('locales_target', 't', 't.lid = s.lid');
1871 }
1872
1873 $sql_query->fields('s', array('source', 'location', 'context', 'lid', 'textgroup'));
1874 $sql_query->fields('t', array('translation', 'language'));
1875
1876 // Compute LIKE section.
1877 switch ($query['translation']) {
1878 case 'translated':
1879 $sql_query->condition('t.translation', '%' . db_like($query['string']) . '%', 'LIKE');
1880 $sql_query->orderBy('t.translation', 'DESC');
1881 break;
1882 case 'untranslated':
1883 $sql_query->condition(db_and()
1884 ->condition('s.source', '%' . db_like($query['string']) . '%', 'LIKE')
1885 ->isNull('t.translation')
1886 );
1887 $sql_query->orderBy('s.source');
1888 break;
1889 case 'all' :
1890 default:
1891 $condition = db_or()
1892 ->condition('s.source', '%' . db_like($query['string']) . '%', 'LIKE');
1893 if ($query['language'] != 'en') {
1894 // Only search in translations if the language is not forced to English.
1895 $condition->condition('t.translation', '%' . db_like($query['string']) . '%', 'LIKE');
1896 }
1897 $sql_query->condition($condition);
1898 break;
1899 }
1900
1901 // Add a condition on the text group.
1902 if (!empty($query['group']) && $query['group'] != 'all') {
1903 $sql_query->condition('s.textgroup', $query['group']);
1904 }
1905
1906 $sql_query = $sql_query->extend('PagerDefault')->limit(50);
1907 $locales = $sql_query->execute();
1908
1909 $groups = module_invoke_all('locale', 'groups');
1910 $header = array(t('Text group'), t('String'), t('Context'), ($limit_language) ? t('Language') : t('Languages'), array('data' => t('Operations'), 'colspan' => '2'));
1911
1912 $strings = array();
1913 foreach ($locales as $locale) {
1914 if (!isset($strings[$locale->lid])) {
1915 $strings[$locale->lid] = array(
1916 'group' => $locale->textgroup,
1917 'languages' => array(),
1918 'location' => $locale->location,
1919 'source' => $locale->source,
1920 'context' => $locale->context,
1921 );
1922 }
1923 if (isset($locale->language)) {
1924 $strings[$locale->lid]['languages'][$locale->language] = $locale->translation;
1925 }
1926 }
1927
1928 $rows = array();
1929 foreach ($strings as $lid => $string) {
1930 $rows[] = array(
1931 $groups[$string['group']],
1932 array('data' => check_plain(truncate_utf8($string['source'], 150, FALSE, TRUE)) . '<br /><small>' . $string['location'] . '</small>'),
1933 $string['context'],
1934 array('data' => _locale_translate_language_list($string['languages'], $limit_language), 'align' => 'center'),
1935 array('data' => l(t('edit'), "admin/config/regional/translate/edit/$lid", array('query' => drupal_get_destination())), 'class' => array('nowrap')),
1936 array('data' => l(t('delete'), "admin/config/regional/translate/delete/$lid", array('query' => drupal_get_destination())), 'class' => array('nowrap')),
1937 );
1938 }
1939
1940 $output .= theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No strings available.')));
1941 $output .= theme('pager');
1942
1943 return $output;
1944 }
1945
1949 function _locale_translate_seek_query() {
1950 $query = &drupal_static(__FUNCTION__);
1951 if (!isset($query)) {
1952 $query = array();
1953 $fields = array('string', 'language', 'translation', 'group');
1954 foreach ($fields as $field) {
1955 if (isset($_SESSION['locale_translation_filter'][$field])) {
1956 $query[$field] = $_SESSION['locale_translation_filter'][$field];
1957 }
1958 }
1959 }
1960 return $query;
1961 }
1962
1977 function _locale_invalidate_js($langcode = NULL) {
1978 $parsed = variable_get('javascript_parsed', array());
1979
1980 if (empty($langcode)) {
1981 // Invalidate all languages.
1982 $languages = language_list();
1983 unset($languages['en']);
1984 foreach ($languages as $lcode => $data) {
1985 $parsed['refresh:' . $lcode] = 'waiting';
1986 }
1987 }
1988 else {
1989 // Invalidate single language.
1990 $parsed['refresh:' . $langcode] = 'waiting';
1991 }
1992
1993 variable_set('javascript_parsed', $parsed);
1994 return $parsed;
1995 }
1996
2003 function _locale_rebuild_js($langcode = NULL) {
2004 if (!isset($langcode)) {
2005 global $language;
2006 }
2007 else {
2008 // Get information about the locale.
2009 $languages = language_list();
2010 $language = $languages[$langcode];
2011 }
2012
2013 // Construct the array for JavaScript translations.
2014 // Only add strings with a translation to the translations array.
2015 $result = db_query("SELECT s.lid, s.source, s.context, t.translation FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.location LIKE '%.js%' AND s.textgroup = :textgroup", array(':language' => $language->language, ':textgroup' => 'default'));
2016
2017 $translations = array();
2018 foreach ($result as $data) {
2019 $translations[$data->context][$data->source] = $data->translation;
2020 }
2021
2022 // Construct the JavaScript file, if there are translations.
2023 $data_hash = NULL;
2024 $data = $status = '';
2025 if (!empty($translations)) {
2026
2027 $data = "Drupal.locale = { ";
2028
2029 if (!empty($language->formula)) {
2030 $data .= "'pluralFormula': function (\$n) { return Number({$language->formula}); }, ";
2031 }
2032
2033 $data .= "'strings': " . drupal_json_encode($translations) . " };";
2034 $data_hash = drupal_hash_base64($data);
2035 }
2036
2037 // Construct the filepath where JS translation files are stored.
2038 // There is (on purpose) no front end to edit that variable.
2039 $dir = 'public://' . variable_get('locale_js_directory', 'languages');
2040
2041 // Delete old file, if we have no translations anymore, or a different file to be saved.
2042 $changed_hash = $language->javascript != $data_hash;
2043 if (!empty($language->javascript) && (!$data || $changed_hash)) {
2044 file_unmanaged_delete($dir . '/' . $language->language . '_' . $language->javascript . '.js');
2045 $language->javascript = '';
2046 $status = 'deleted';
2047 }
2048
2049 // Only create a new file if the content has changed or the original file got
2050 // lost.
2051 $dest = $dir . '/' . $language->language . '_' . $data_hash . '.js';
2052 if ($data && ($changed_hash || !file_exists($dest))) {
2053 // Ensure that the directory exists and is writable, if possible.
2054 file_prepare_directory($dir, FILE_CREATE_DIRECTORY);
2055
2056 // Save the file.
2057 if (file_unmanaged_save_data($data, $dest)) {
2058 $language->javascript = $data_hash;
2059 // If we deleted a previous version of the file and we replace it with a
2060 // new one we have an update.
2061 if ($status == 'deleted') {
2062 $status = 'updated';
2063 }
2064 // If the file did not exist previously and the data has changed we have
2065 // a fresh creation.
2066 elseif ($changed_hash) {
2067 $status = 'created';
2068 }
2069 // If the data hash is unchanged the translation was lost and has to be
2070 // rebuilt.
2071 else {
2072 $status = 'rebuilt';
2073 }
2074 }
2075 else {
2076 $language->javascript = '';
2077 $status = 'error';
2078 }
2079 }
2080
2081 // Save the new JavaScript hash (or an empty value if the file just got
2082 // deleted). Act only if some operation was executed that changed the hash
2083 // code.
2084 if ($status && $changed_hash) {
2085 db_update('languages')
2086 ->fields(array(
2087 'javascript' => $language->javascript,
2088 ))
2089 ->condition('language', $language->language)
2090 ->execute();
2091
2092 // Update the default language variable if the default language has been altered.
2093 // This is necessary to keep the variable consistent with the database
2094 // version of the language and to prevent checking against an outdated hash.
2095 $default_langcode = language_default('language');
2096 if ($default_langcode == $language->language) {
2097 $default = db_query("SELECT * FROM {languages} WHERE language = :language", array(':language' => $default_langcode))->fetchObject();
2098 variable_set('language_default', $default);
2099 }
2100 }
2101
2102 // Log the operation and return success flag.
2103 switch ($status) {
2104 case 'updated':
2105 watchdog('locale', 'Updated JavaScript translation file for the language %language.', array('%language' => t($language->name)));
2106 return TRUE;
2107 case 'rebuilt':
2108 watchdog('locale', 'JavaScript translation file %file.js was lost.', array('%file' => $language->javascript), WATCHDOG_WARNING);
2109 // Proceed to the 'created' case as the JavaScript translation file has
2110 // been created again.
2111 case 'created':
2112 watchdog('locale', 'Created JavaScript translation file for the language %language.', array('%language' => t($language->name)));
2113 return TRUE;
2114 case 'deleted':
2115 watchdog('locale', 'Removed JavaScript translation file for the language %language, because no translations currently exist for that language.', array('%language' => t($language->name)));
2116 return TRUE;
2117 case 'error':
2118 watchdog('locale', 'An error occurred during creation of the JavaScript translation file for the language %language.', array('%language' => t($language->name)), WATCHDOG_ERROR);
2119 return FALSE;
2120 default:
2121 // No operation needed.
2122 return TRUE;
2123 }
2124 }
2125
2129 function _locale_translate_language_list($translation, $limit_language) {
2130 // Add CSS.
2131 drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
2132
2133 $languages = language_list();
2134 unset($languages['en']);
2135 $output = '';
2136 foreach ($languages as $langcode => $language) {
2137 if (!$limit_language || $limit_language == $langcode) {
2138 $output .= (!empty($translation[$langcode])) ? $langcode . ' ' : "<em class=\"locale-untranslated\">$langcode</em> ";
2139 }
2140 }
2141
2142 return $output;
2143 }
2157 function _locale_prepare_predefined_list() {
2158 include_once DRUPAL_ROOT . '/includes/iso.inc';
2159 $languages = language_list();
2160 $predefined = _locale_get_predefined_list();
2161 foreach ($predefined as $key => $value) {
2162 if (isset($languages[$key])) {
2163 unset($predefined[$key]);
2164 continue;
2165 }
2166 // Include native name in output, if possible
2167 if (count($value) > 1) {
2168 $tname = t($value[0]);
2169 $predefined[$key] = ($tname == $value[1]) ? $tname : "$tname ($value[1])";
2170 }
2171 else {
2172 $predefined[$key] = t($value[0]);
2173 }
2174 }
2175 asort($predefined);
2176 return $predefined;
2177 }
2178
2207 function locale_batch_by_language($langcode, $finished = NULL, $skip = array()) {
2208 // Collect all files to import for all enabled modules and themes.
2209 $files = array();
2210 $components = array();
2211 $query = db_select('system', 's');
2212 $query->fields('s', array('name', 'filename'));
2213 $query->condition('s.status', 1);
2214 if (count($skip)) {
2215 $query->condition('name', $skip, 'NOT IN');
2216 }
2217 $result = $query->execute();
2218 foreach ($result as $component) {
2219 // Collect all files for all components, names as $langcode.po or
2220 // with names ending with $langcode.po. This allows for filenames
2221 // like node-module.de.po to let translators use small files and
2222 // be able to import in smaller chunks.
2223 $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', '/(^|\.)' . $langcode . '\.po$/', array('recurse' => FALSE)));
2224 $components[] = $component->name;
2225 }
2226
2227 return _locale_batch_build($files, $finished, $components);
2228 }
2229
2242 function locale_batch_by_component($components, $finished = '_locale_batch_system_finished') {
2243 $files = array();
2244 $languages = language_list('enabled');
2245 unset($languages[1]['en']);
2246 if (count($languages[1])) {
2247 $language_list = join('|', array_keys($languages[1]));
2248 // Collect all files to import for all $components.
2249 $result = db_query("SELECT name, filename FROM {system} WHERE status = 1");
2250 foreach ($result as $component) {
2251 if (in_array($component->name, $components)) {
2252 // Collect all files for this component in all enabled languages, named
2253 // as $langcode.po or with names ending with $langcode.po. This allows
2254 // for filenames like node-module.de.po to let translators use small
2255 // files and be able to import in smaller chunks.
2256 $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', '/(^|\.)(' . $language_list . ')\.po$/', array('recurse' => FALSE)));
2257 }
2258 }
2259 return _locale_batch_build($files, $finished);
2260 }
2261 return FALSE;
2262 }
2263
2277 function _locale_batch_build($files, $finished = NULL, $components = array()) {
2278 $t = get_t();
2279 if (count($files)) {
2280 $operations = array();
2281 foreach ($files as $file) {
2282 // We call _locale_batch_import for every batch operation.
2283 $operations[] = array('_locale_batch_import', array($file->uri));
2284 }
2285 $batch = array(
2286 'operations' => $operations,
2287 'title' => $t('Importing interface translations'),
2288 'init_message' => $t('Starting import'),
2289 'error_message' => $t('Error importing interface translations'),
2290 'file' => 'includes/locale.inc',
2291 // This is not a batch API construct, but data passed along to the
2292 // installer, so we know what did we import already.
2293 '#components' => $components,
2294 );
2295 if (isset($finished)) {
2296 $batch['finished'] = $finished;
2297 }
2298 return $batch;
2299 }
2300 return FALSE;
2301 }
2302
2311 function _locale_batch_import($filepath, &$context) {
2312 // The filename is either {langcode}.po or {prefix}.{langcode}.po, so
2313 // we can extract the language code to use for the import from the end.
2314 if (preg_match('!(/|\.)([^\./]+)\.po$!', $filepath, $langcode)) {
2315 $file = (object) array('filename' => drupal_basename($filepath), 'uri' => $filepath);
2316 _locale_import_read_po('db-store', $file, LOCALE_IMPORT_KEEP, $langcode[2]);
2317 $context['results'][] = $filepath;
2318 }
2319 }
2320
2325 function _locale_batch_system_finished($success, $results) {
2326 if ($success) {
2327 drupal_set_message(format_plural(count($results), 'One translation file imported for the newly installed modules.', '@count translation files imported for the newly installed modules.'));
2328 }
2329 }
2330
2335 function _locale_batch_language_finished($success, $results) {
2336 if ($success) {
2337 drupal_set_message(format_plural(count($results), 'One translation file imported for the enabled modules.', '@count translation files imported for the enabled modules.'));
2338 }
2339 }
2340
2351 function country_get_list() {
2352 include_once DRUPAL_ROOT . '/includes/iso.inc';
2353 $countries = _country_get_predefined_list();
2354 // Allow other modules to modify the country list.
2355 drupal_alter('countries', $countries);
2356 return $countries;
2357 }
2358
2370 function locale_date_format_save($langcode, $type, $format) {
2371 $locale_format = array();
2372 $locale_format['language'] = $langcode;
2373 $locale_format['type'] = $type;
2374 $locale_format['format'] = $format;
2375
2376 $is_existing = (bool) db_query_range('SELECT 1 FROM {date_format_locale} WHERE language = :langcode AND type = :type', 0, 1, array(':langcode' => $langcode, ':type' => $type))->fetchField();
2377 if ($is_existing) {
2378 $keys = array('type', 'language');
2379 drupal_write_record('date_format_locale', $locale_format, $keys);
2380 }
2381 else {
2382 drupal_write_record('date_format_locale', $locale_format);
2383 }
2384 }
2385
2395 function locale_get_localized_date_format($languages) {
2396 $formats = array();
2397
2398 // Get list of different format types.
2399 $format_types = system_get_date_types();
2400 $short_default = variable_get('date_format_short', 'm/d/Y - H:i');
2401
2402 // Loop through each language until we find one with some date formats
2403 // configured.
2404 foreach ($languages as $language) {
2405 $date_formats = system_date_format_locale($language);
2406 if (!empty($date_formats)) {
2407 // We have locale-specific date formats, so check for their types. If
2408 // we're missing a type, use the default setting instead.
2409 foreach ($format_types as $type => $type_info) {
2410 // If format exists for this language, use it.
2411 if (!empty($date_formats[$type])) {
2412 $formats['date_format_' . $type] = $date_formats[$type];
2413 }
2414 // Otherwise get default variable setting. If this is not set, default
2415 // to the short format.
2416 else {
2417 $formats['date_format_' . $type] = variable_get('date_format_' . $type, $short_default);
2418 }
2419 }
2420
2421 // Return on the first match.
2422 return $formats;
2423 }
2424 }
2425
2426 // No locale specific formats found, so use defaults.
2427 $system_types = array('short', 'medium', 'long');
2428 // Handle system types separately as they have defaults if no variable exists.
2429 $formats['date_format_short'] = $short_default;
2430 $formats['date_format_medium'] = variable_get('date_format_medium', 'D, m/d/Y - H:i');
2431 $formats['date_format_long'] = variable_get('date_format_long', 'l, F j, Y - H:i');
2432
2433 // For non-system types, get the default setting, otherwise use the short
2434 // format.
2435 foreach ($format_types as $type => $type_info) {
2436 if (!in_array($type, $system_types)) {
2437 $formats['date_format_' . $type] = variable_get('date_format_' . $type, $short_default);
2438 }
2439 }
2440
2441 return $formats;
2442 }
drupal_json_encode
drupal_json_encode($var)
Definition: common.inc:5003
_locale_translate_language_list
_locale_translate_language_list($translation, $limit_language)
Definition: locale.inc:2129
_locale_export_string
_locale_export_string($str)
Definition: locale.inc:1766
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
$op
$op
Definition: update.php:404
_locale_batch_build
_locale_batch_build($files, $finished=NULL, $components=array())
Definition: locale.inc:2277
decode_entities
decode_entities($text)
Definition: unicode.inc:457
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN
const LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN
Definition: locale.inc:97
FILE_CREATE_DIRECTORY
const FILE_CREATE_DIRECTORY
Definition: file.inc:41
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
file_scan_directory
file_scan_directory($dir, $mask, $options=array(), $depth=0)
Definition: file.inc:2058
_locale_import_parse_arithmetic
_locale_import_parse_arithmetic($string)
Definition: locale.inc:1247
_locale_import_one_string
_locale_import_one_string($op, $value=NULL, $mode=NULL, $lang=NULL, $file=NULL, $group= 'default')
Definition: locale.inc:976
drupal_set_time_limit
drupal_set_time_limit($time_limit)
Definition: common.inc:2786
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
LOCALE_JS_OBJECT_CONTEXT
const LOCALE_JS_OBJECT_CONTEXT
Definition: locale.inc:59
locale_batch_by_component
locale_batch_by_component($components, $finished= '_locale_batch_system_finished')
Definition: locale.inc:2242
_locale_rebuild_js
_locale_rebuild_js($langcode=NULL)
Definition: locale.inc:2003
_locale_get_predefined_list
_locale_get_predefined_list()
Definition: iso.inc:291
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
_locale_batch_system_finished
_locale_batch_system_finished($success, $results)
Definition: locale.inc:2325
$name
print $name
Definition: profile-listing.tpl.php:43
$results
print $results
Definition: poll-results.tpl.php:23
LOCALE_JS_STRING
const LOCALE_JS_STRING
Definition: locale.inc:43
_locale_parse_js_file
_locale_parse_js_file($filepath)
Definition: locale.inc:1480
$header
print $header
Definition: forum-topic-list.tpl.php:42
_locale_export_get_strings
_locale_export_get_strings($language=NULL, $group= 'default')
Definition: locale.inc:1613
drupal_get_query_array
drupal_get_query_array($query)
Definition: common.inc:457
_locale_translate_seek_query
_locale_translate_seek_query()
Definition: locale.inc:1949
print
print
Definition: php-2.php:2
$contents
print $contents
Definition: book-export-html.tpl.php:49
locale_language_from_browser
locale_language_from_browser($languages)
Definition: locale.inc:131
_locale_import_parse_plural_forms
_locale_import_parse_plural_forms($pluralforms, $filepath)
Definition: locale.inc:1203
db_or
db_or()
Definition: database.inc:2662
_locale_import_read_po
_locale_import_read_po($op, $file, $mode=NULL, $lang=NULL, $group= 'default')
Definition: locale.inc:690
locale_language_switcher_session
locale_language_switcher_session($type, $path)
Definition: locale.inc:377
_locale_export_wrap
_locale_export_wrap($str, $len)
Definition: locale.inc:1802
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
LOCALE_LANGUAGE_NEGOTIATION_URL
const LOCALE_LANGUAGE_NEGOTIATION_URL
Definition: locale.inc:12
locale_string_is_safe
locale_string_is_safe($string)
Definition: locale.inc:525
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
menu_rebuild
menu_rebuild()
Definition: menu.inc:2709
locale_add_language
locale_add_language($langcode, $name=NULL, $native=NULL, $direction=LANGUAGE_LTR, $domain= '', $prefix= '', $enabled=TRUE, $default=FALSE)
Definition: locale.inc:559
_locale_import_message
_locale_import_message($message, $file, $lineno=NULL)
Definition: locale.inc:948
_locale_batch_import
_locale_batch_import($filepath, &$context)
Definition: locale.inc:2311
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
LOCALE_LANGUAGE_NEGOTIATION_SESSION
const LOCALE_LANGUAGE_NEGOTIATION_SESSION
Definition: locale.inc:38
language_list
language_list($field= 'language')
Definition: bootstrap.inc:2723
_locale_export_remove_plural
_locale_export_remove_plural($entry)
Definition: locale.inc:1830
_country_get_predefined_list
_country_get_predefined_list()
Definition: iso.inc:17
_locale_import_shorten_comments
_locale_import_shorten_comments($comment)
Definition: locale.inc:1433
system_date_format_locale
system_date_format_locale($langcode=NULL, $type=NULL)
Definition: system.module:3645
$value
print $value
Definition: user-profile-item.tpl.php:26
get_t
get_t()
Definition: bootstrap.inc:2635
language_negotiation_get_any
language_negotiation_get_any($provider_id)
Definition: language.inc:258
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
LANGUAGE_LTR
const LANGUAGE_LTR
Definition: bootstrap.inc:201
_locale_import_tokenize_formula
_locale_import_tokenize_formula($formula)
Definition: locale.inc:1347
language
print $language language
Definition: book-export-html.tpl.php:22
$output
$output
Definition: authorize.php:93
LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX
const LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX
Definition: locale.inc:91
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
db_like
db_like($string)
Definition: database.inc:2610
locale_language_url_rewrite_session
locale_language_url_rewrite_session(&$path, &$options)
Definition: locale.inc:475
file_unmanaged_delete
file_unmanaged_delete($path)
Definition: file.inc:1317
_locale_prepare_predefined_list
_locale_prepare_predefined_list()
Definition: locale.inc:2157
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
drupal_parse_url
drupal_parse_url($url)
Definition: common.inc:580
locale_language_from_session
locale_language_from_session($languages)
Definition: locale.inc:234
_locale_import_po
_locale_import_po($file, $langcode, $mode, $group=NULL)
Definition: locale.inc:633
language_url_split_prefix
language_url_split_prefix($path, $languages)
Definition: language.inc:530
locale_language_switcher_url
locale_language_switcher_url($type, $path)
Definition: locale.inc:358
LOCALE_IMPORT_OVERWRITE
const LOCALE_IMPORT_OVERWRITE
Definition: locale.inc:79
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
system_get_date_types
system_get_date_types($type=NULL)
Definition: system.module:3528
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
file_unmanaged_save_data
file_unmanaged_save_data($data, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1932
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
locale_language_url_rewrite_url
locale_language_url_rewrite_url(&$path, &$options)
Definition: locale.inc:411
_locale_import_append_plural
_locale_import_append_plural($entry, $key)
Definition: locale.inc:1413
LOCALE_JS_OBJECT
const LOCALE_JS_OBJECT
Definition: locale.inc:51
locale_date_format_save
locale_date_format_save($langcode, $type, $format)
Definition: locale.inc:2370
country_get_list
country_get_list()
Definition: locale.inc:2351
locale_language_from_interface
locale_language_from_interface()
Definition: locale.inc:114
_locale_translate_seek
_locale_translate_seek()
Definition: locale.inc:1849
_locale_export_po
_locale_export_po($language=NULL, $output=NULL)
Definition: locale.inc:1746
drupal_exit
drupal_exit($destination=NULL)
Definition: common.inc:2721
_locale_batch_language_finished
_locale_batch_language_finished($success, $results)
Definition: locale.inc:2335
LOCALE_IMPORT_KEEP
const LOCALE_IMPORT_KEEP
Definition: locale.inc:85
language_default
language_default($property=NULL)
Definition: bootstrap.inc:2765
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$dir
print $dir
Definition: book-export-html.tpl.php:22
locale_language_from_url
locale_language_from_url($languages)
Definition: locale.inc:264
file_prepare_directory
file_prepare_directory(&$directory, $options=FILE_MODIFY_PERMISSIONS)
Definition: file.inc:430
drupal_basename
drupal_basename($uri, $suffix=NULL)
Definition: file.inc:2317
locale_batch_by_language
locale_batch_by_language($langcode, $finished=NULL, $skip=array())
Definition: locale.inc:2207
LANGUAGE_TYPE_INTERFACE
const LANGUAGE_TYPE_INTERFACE
Definition: bootstrap.inc:191
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
drupal_hash_base64
drupal_hash_base64($data)
Definition: bootstrap.inc:2067
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
_locale_import_one_string_db
_locale_import_one_string_db(&$report, $langcode, $context, $source, $translation, $textgroup, $location, $mode, $plid=0, $plural=0)
Definition: locale.inc:1080
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
locale_language_url_fallback
locale_language_url_fallback($language=NULL, $language_type=LANGUAGE_TYPE_INTERFACE)
Definition: locale.inc:339
_locale_import_parse_header
_locale_import_parse_header($header)
Definition: locale.inc:1179
_locale_invalidate_js
_locale_invalidate_js($langcode=NULL)
Definition: locale.inc:1977
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
truncate_utf8
truncate_utf8($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
Definition: unicode.inc:316
_locale_import_parse_quoted
_locale_import_parse_quoted($string)
Definition: locale.inc:1456
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
$links
print $links
Definition: poll-results--block.tpl.php:28
_locale_export_po_generate
_locale_export_po_generate($language=NULL, $strings=array(), $header=NULL)
Definition: locale.inc:1654
locale_get_localized_date_format
locale_get_localized_date_format($languages)
Definition: locale.inc:2395
locale_language_from_user
locale_language_from_user($languages)
Definition: locale.inc:213
db_and
db_and()
Definition: database.inc:2671
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/pager_example/pager_example.module Source File

  • examples
  • pager_example
pager_example.module
Go to the documentation of this file.
1 <?php
2 // $Id$
24 function pager_example_help($path, $arg) {
25 switch ($path) {
26 case 'examples/pager_example':
27 return '<p>' . t('The layout here is a themed as a table with a default limit of 10 rows per page. The limit can be changed in the code by changing the limit to some other value. This can be extended to add a filter form as well so the user can choose how many they would like to see on each screen.') . '</p>';
28 }
29 }
30
34 function pager_example_menu() {
35 $items['examples/pager_example'] = array(
36 'title' => 'Pager example',
37 'description' => 'Show a page with a long list across multiple pages',
38 'page callback' => 'pager_example_page',
39 'access callback' => TRUE
40 );
41 return $items;
42 }
43
54 function pager_example_page() {
55 // we are going to output the results in a table with a nice header
56 $header = array(
57 array('data' => t('DFID')),
58 array('data' => t('Format')),
59 array('data' => t('Type')),
60 );
61
62 // we are extending the PagerDefault class here
63 // it has a default of 10 rows per page
64 // the extend('PagerDefault') part here does all the magic.
65 $query = db_select('date_formats', 'd')->extend('PagerDefault');
66 $query->fields('d', array('dfid', 'format', 'type'));
67
68 $result = $query
69 ->limit(10) // this is where you change the number of rows
70 ->orderBy('d.dfid')
71 ->execute();
72
73 $rows = array();
74 foreach ($result as $row) {
75 // normally we would add some nice formatting to our rows
76 // but for our purpose we are simply going to add our row
77 // to the array.
78 $rows[] = array('data' => (array) $row);
79 }
80
81 // Create a render array ($build) which will be themed as a table with a
82 // pager.
83 $build['pager_table'] = array(
84 '#theme' => 'table',
85 '#header' => $header,
86 '#rows' => $rows,
87 '#empty' => t('There are no date formats found in the db'),
88 );
89
90 // attach the pager theme
91 $build['pager_pager'] = array('#theme' => 'pager');
92
93 return $build;
94 }
$header
print $header
Definition: forum-topic-list.tpl.php:42
pager_example_page
pager_example_page()
Definition: pager_example.module:54
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
pager_example_help
pager_example_help($path, $arg)
Definition: pager_example.module:24
$row
$row
Definition: block-admin-display-form.tpl.php:47
pager_example_menu
pager_example_menu()
Definition: pager_example.module:34
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.authorize.inc Source File

  • modules
  • update
update.authorize.inc
Go to the documentation of this file.
1 <?php
2
29 function update_authorize_run_update($filetransfer, $projects) {
30 $operations = array();
31 foreach ($projects as $project => $project_info) {
32 $operations[] = array(
33 'update_authorize_batch_copy_project',
34 array(
35 $project_info['project'],
36 $project_info['updater_name'],
37 $project_info['local_url'],
38 $filetransfer,
39 ),
40 );
41 }
42
43 $batch = array(
44 'title' => t('Installing updates'),
45 'init_message' => t('Preparing to update your site'),
46 'operations' => $operations,
47 'finished' => 'update_authorize_update_batch_finished',
48 'file' => drupal_get_path('module', 'update') . '/update.authorize.inc',
49 );
50
51 batch_set($batch);
52 // Invoke the batch via authorize.php.
53 system_authorized_batch_process();
54 }
55
73 function update_authorize_run_install($filetransfer, $project, $updater_name, $local_url) {
74 $operations[] = array(
75 'update_authorize_batch_copy_project',
76 array(
77 $project,
78 $updater_name,
79 $local_url,
80 $filetransfer,
81 ),
82 );
83
84 // @todo Instantiate our Updater to set the human-readable title?
85 $batch = array(
86 'title' => t('Installing %project', array('%project' => $project)),
87 'init_message' => t('Preparing to install'),
88 'operations' => $operations,
89 // @todo Use a different finished callback for different messages?
90 'finished' => 'update_authorize_install_batch_finished',
91 'file' => drupal_get_path('module', 'update') . '/update.authorize.inc',
92 );
93 batch_set($batch);
94
95 // Invoke the batch via authorize.php.
96 system_authorized_batch_process();
97 }
98
114 function update_authorize_batch_copy_project($project, $updater_name, $local_url, $filetransfer, &$context) {
115
116 // Initialize some variables in the Batch API $context array.
117 if (!isset($context['results']['log'])) {
118 $context['results']['log'] = array();
119 }
120 if (!isset($context['results']['log'][$project])) {
121 $context['results']['log'][$project] = array();
122 }
123
124 if (!isset($context['results']['tasks'])) {
125 $context['results']['tasks'] = array();
126 }
127
128 // The batch API uses a session, and since all the arguments are serialized
129 // and unserialized between requests, although the FileTransfer object itself
130 // will be reconstructed, the connection pointer itself will be lost. However,
131 // the FileTransfer object will still have the connection variable, even
132 // though the connection itself is now gone. So, although it's ugly, we have
133 // to unset the connection variable at this point so that the FileTransfer
134 // object will re-initiate the actual connection.
135 unset($filetransfer->connection);
136
137 if (!empty($context['results']['log'][$project]['#abort'])) {
138 $context['finished'] = 1;
139 return;
140 }
141
142 $updater = new $updater_name($local_url);
143
144 try {
145 if ($updater->isInstalled()) {
146 // This is an update.
147 $tasks = $updater->update($filetransfer);
148 }
149 else {
150 $tasks = $updater->install($filetransfer);
151 }
152 }
153 catch (UpdaterException $e) {
154 _update_batch_create_message($context['results']['log'][$project], t('Error installing / updating'), FALSE);
155 _update_batch_create_message($context['results']['log'][$project], $e->getMessage(), FALSE);
156 $context['results']['log'][$project]['#abort'] = TRUE;
157 return;
158 }
159
160 _update_batch_create_message($context['results']['log'][$project], t('Installed %project_name successfully', array('%project_name' => $project)));
161 if (!empty($tasks)) {
162 $context['results']['tasks'] += $tasks;
163 }
164
165 // This particular operation is now complete, even though the batch might
166 // have other operations to perform.
167 $context['finished'] = 1;
168 }
169
182 function update_authorize_update_batch_finished($success, $results) {
183 foreach ($results['log'] as $project => $messages) {
184 if (!empty($messages['#abort'])) {
185 $success = FALSE;
186 }
187 }
188 $offline = variable_get('maintenance_mode', FALSE);
189 if ($success) {
190 // Now that the update completed, we need to clear the cache of available
191 // update data and recompute our status, so prevent show bogus results.
192 _update_authorize_clear_update_status();
193
194 // Take the site out of maintenance mode if it was previously that way.
195 if ($offline && isset($_SESSION['maintenance_mode']) && $_SESSION['maintenance_mode'] == FALSE) {
196 variable_set('maintenance_mode', FALSE);
197 $page_message = array(
198 'message' => t('Update was completed successfully. Your site has been taken out of maintenance mode.'),
199 'type' => 'status',
200 );
201 }
202 else {
203 $page_message = array(
204 'message' => t('Update was completed successfully.'),
205 'type' => 'status',
206 );
207 }
208 }
209 elseif (!$offline) {
210 $page_message = array(
211 'message' => t('Update failed! See the log below for more information.'),
212 'type' => 'error',
213 );
214 }
215 else {
216 $page_message = array(
217 'message' => t('Update failed! See the log below for more information. Your site is still in maintenance mode.'),
218 'type' => 'error',
219 );
220 }
221 // Since we're doing an update of existing code, always add a task for
222 // running update.php.
223 $results['tasks'][] = t('Your modules have been downloaded and updated.');
224 $results['tasks'][] = t('<a href="@update">Run database updates</a>', array('@update' => base_path() . 'update.php'));
225
226 // Unset the variable since it is no longer needed.
227 unset($_SESSION['maintenance_mode']);
228
229 // Set all these values into the SESSION so authorize.php can display them.
230 $_SESSION['authorize_results']['success'] = $success;
231 $_SESSION['authorize_results']['page_message'] = $page_message;
232 $_SESSION['authorize_results']['messages'] = $results['log'];
233 $_SESSION['authorize_results']['tasks'] = $results['tasks'];
234 $_SESSION['authorize_operation']['page_title'] = t('Update manager');
235 }
236
249 function update_authorize_install_batch_finished($success, $results) {
250 foreach ($results['log'] as $project => $messages) {
251 if (!empty($messages['#abort'])) {
252 $success = FALSE;
253 }
254 }
255 $offline = variable_get('maintenance_mode', FALSE);
256 if ($success) {
257 // Take the site out of maintenance mode if it was previously that way.
258 if ($offline && isset($_SESSION['maintenance_mode']) && $_SESSION['maintenance_mode'] == FALSE) {
259 variable_set('maintenance_mode', FALSE);
260 $page_message = array(
261 'message' => t('Installation was completed successfully. Your site has been taken out of maintenance mode.'),
262 'type' => 'status',
263 );
264 }
265 else {
266 $page_message = array(
267 'message' => t('Installation was completed successfully.'),
268 'type' => 'status',
269 );
270 }
271 }
272 elseif (!$success && !$offline) {
273 $page_message = array(
274 'message' => t('Installation failed! See the log below for more information.'),
275 'type' => 'error',
276 );
277 }
278 else {
279 $page_message = array(
280 'message' => t('Installation failed! See the log below for more information. Your site is still in maintenance mode.'),
281 'type' => 'error',
282 );
283 }
284
285 // Unset the variable since it is no longer needed.
286 unset($_SESSION['maintenance_mode']);
287
288 // Set all these values into the SESSION so authorize.php can display them.
289 $_SESSION['authorize_results']['success'] = $success;
290 $_SESSION['authorize_results']['page_message'] = $page_message;
291 $_SESSION['authorize_results']['messages'] = $results['log'];
292 $_SESSION['authorize_results']['tasks'] = $results['tasks'];
293 $_SESSION['authorize_operation']['page_title'] = t('Update manager');
294 }
295
307 function _update_batch_create_message(&$project_results, $message, $success = TRUE) {
308 $project_results[] = array('message' => $message, 'success' => $success);
309 }
310
325 function _update_authorize_clear_update_status() {
326 $query = db_delete('cache_update');
327 $query->condition(
328 db_or()
329 ->condition('cid', 'update_project_%', 'LIKE')
330 ->condition('cid', 'available_releases::%', 'LIKE')
331 );
332 $query->execute();
333 }
update_authorize_install_batch_finished
update_authorize_install_batch_finished($success, $results)
Definition: update.authorize.inc:249
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
_update_batch_create_message
_update_batch_create_message(&$project_results, $message, $success=TRUE)
Definition: update.authorize.inc:307
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$results
print $results
Definition: poll-results.tpl.php:23
db_or
db_or()
Definition: database.inc:2662
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
update_authorize_run_update
update_authorize_run_update($filetransfer, $projects)
Definition: update.authorize.inc:29
batch_set
batch_set($batch_definition)
Definition: form.inc:4381
$messages
print $messages
Definition: page.tpl.php:121
update_authorize_update_batch_finished
update_authorize_update_batch_finished($success, $results)
Definition: update.authorize.inc:182
UpdaterException
Definition: updater.inc:416
_update_authorize_clear_update_status
_update_authorize_clear_update_status()
Definition: update.authorize.inc:325
system_authorized_batch_process
system_authorized_batch_process()
Definition: system.module:1834
base_path
base_path()
Definition: common.inc:2817
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
update_authorize_run_install
update_authorize_run_install($filetransfer, $project, $updater_name, $local_url)
Definition: update.authorize.inc:73
update_authorize_batch_copy_project
update_authorize_batch_copy_project($project, $updater_name, $local_url, $filetransfer, &$context)
Definition: update.authorize.inc:114
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy/taxonomy.pages.inc Source File

  • modules
  • taxonomy
taxonomy.pages.inc
Go to the documentation of this file.
1 <?php
2
16 function taxonomy_term_page($term) {
17 // If there is a menu link to this term, the link becomes the last part of
18 // the active trail, and the link name becomes the page title. Thus, we must
19 // explicitly set the page title to be the term title.
20 drupal_set_title($term->name);
21
22 // Build breadcrumb based on the hierarchy of the term.
23 $current = (object) array(
24 'tid' => $term->tid,
25 );
26 // @todo This overrides any other possible breadcrumb and is a pure hard-coded
27 // presumption. Make this behavior configurable per vocabulary or term.
28 $breadcrumb = array();
29 while ($parents = taxonomy_get_parents($current->tid)) {
30 $current = array_shift($parents);
31 $breadcrumb[] = l($current->name, 'taxonomy/term/' . $current->tid);
32 }
33 $breadcrumb[] = l(t('Home'), NULL);
34 $breadcrumb = array_reverse($breadcrumb);
35 drupal_set_breadcrumb($breadcrumb);
36 drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->name);
37
38 // Set the term path as the canonical URL to prevent duplicate content.
39 $uri = entity_uri('taxonomy_term', $term);
40 drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);
41 // Set the non-aliased path as a default shortlink.
42 drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE);
43
44 // Normally we would call taxonomy_term_show() here, but for backwards
45 // compatibility in Drupal 7 we do not want to do that (it produces different
46 // data structures and HTML markup than what Drupal 7 released with). Calling
47 // taxonomy_term_view() directly provides essentially the same thing, but
48 // allows us to wrap the rendered term in our desired array structure.
49 $build['term_heading'] = array(
50 '#prefix' => '<div class="term-listing-heading">',
51 '#suffix' => '</div>',
52 'term' => taxonomy_term_view($term, 'full'),
53 );
54
55 if ($nids = taxonomy_select_nodes($term->tid, TRUE, variable_get('default_nodes_main', 10))) {
56 $nodes = node_load_multiple($nids);
57 $build += node_view_multiple($nodes);
58 $build['pager'] = array(
59 '#theme' => 'pager',
60 '#weight' => 5,
61 );
62 }
63 else {
64 $build['no_content'] = array(
65 '#prefix' => '<p>',
66 '#markup' => t('There is currently no content classified with this term.'),
67 '#suffix' => '</p>',
68 );
69 }
70 return $build;
71 }
72
79 function taxonomy_term_feed($term) {
80 $channel['link'] = url('taxonomy/term/' . $term->tid, array('absolute' => TRUE));
81 $channel['title'] = variable_get('site_name', 'Drupal') . ' - ' . $term->name;
82 // Only display the description if we have a single term, to avoid clutter and confusion.
83 // HTML will be removed from feed description.
84 $channel['description'] = check_markup($term->description, $term->format, '', TRUE);
85 $nids = taxonomy_select_nodes($term->tid, FALSE, variable_get('feed_default_items', 10));
86
87 node_feed($nids, $channel);
88 }
89
121 function taxonomy_autocomplete($field_name = '', $tags_typed = '') {
122 // If the request has a '/' in the search text, then the menu system will have
123 // split it into multiple arguments, recover the intended $tags_typed.
124 $args = func_get_args();
125 // Shift off the $field_name argument.
126 array_shift($args);
127 $tags_typed = implode('/', $args);
128
129 // Make sure the field exists and is a taxonomy field.
130 if (!($field = field_info_field($field_name)) || $field['type'] !== 'taxonomy_term_reference') {
131 // Error string. The JavaScript handler will realize this is not JSON and
132 // will display it as debugging information.
133 print t('Taxonomy field @field_name not found.', array('@field_name' => $field_name));
134 exit;
135 }
136
137 // The user enters a comma-separated list of tags. We only autocomplete the last tag.
138 $tags_typed = drupal_explode_tags($tags_typed);
139 $tag_last = drupal_strtolower(array_pop($tags_typed));
140
141 $term_matches = array();
142 if ($tag_last != '') {
143
144 // Part of the criteria for the query come from the field's own settings.
145 $vids = array();
146 $vocabularies = taxonomy_vocabulary_get_names();
147 foreach ($field['settings']['allowed_values'] as $tree) {
148 $vids[] = $vocabularies[$tree['vocabulary']]->vid;
149 }
150
151 $query = db_select('taxonomy_term_data', 't');
152 $query->addTag('translatable');
153 $query->addTag('term_access');
154
155 // Do not select already entered terms.
156 if (!empty($tags_typed)) {
157 $query->condition('t.name', $tags_typed, 'NOT IN');
158 }
159 // Select rows that match by term name.
160 $tags_return = $query
161 ->fields('t', array('tid', 'name'))
162 ->condition('t.vid', $vids)
163 ->condition('t.name', '%' . db_like($tag_last) . '%', 'LIKE')
164 ->range(0, 10)
165 ->execute()
166 ->fetchAllKeyed();
167
168 $prefix = count($tags_typed) ? drupal_implode_tags($tags_typed) . ', ' : '';
169
170 foreach ($tags_return as $tid => $name) {
171 $n = $name;
172 // Term names containing commas or quotes must be wrapped in quotes.
173 if (strpos($name, ',') !== FALSE || strpos($name, '"') !== FALSE) {
174 $n = '"' . str_replace('"', '""', $name) . '"';
175 }
176 $term_matches[$prefix . $n] = check_plain($name);
177 }
178 }
179
180 drupal_json_output($term_matches);
181 }
node_feed
node_feed($nids=FALSE, $channel=array())
Definition: node.module:2581
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_strtolower
drupal_strtolower($text)
Definition: unicode.inc:521
taxonomy_autocomplete
taxonomy_autocomplete($field_name= '', $tags_typed= '')
Definition: taxonomy.pages.inc:121
drupal_set_breadcrumb
drupal_set_breadcrumb($breadcrumb=NULL)
Definition: common.inc:243
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
$name
print $name
Definition: profile-listing.tpl.php:43
drupal_json_output
drupal_json_output($var=NULL)
Definition: common.inc:5041
drupal_add_html_head_link
drupal_add_html_head_link($attributes, $header=FALSE)
Definition: common.inc:2834
print
print
Definition: php-2.php:2
entity_uri
entity_uri($entity_type, $entity)
Definition: common.inc:7902
taxonomy_term_page
taxonomy_term_page($term)
Definition: taxonomy.pages.inc:16
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
taxonomy_vocabulary_get_names
taxonomy_vocabulary_get_names()
Definition: taxonomy.module:987
drupal_implode_tags
drupal_implode_tags($tags)
Definition: common.inc:7434
db_like
db_like($string)
Definition: database.inc:2610
drupal_add_feed
drupal_add_feed($url=NULL, $title= '')
Definition: common.inc:368
drupal_explode_tags
drupal_explode_tags($tags)
Definition: common.inc:7408
taxonomy_term_feed
taxonomy_term_feed($term)
Definition: taxonomy.pages.inc:79
$breadcrumb
print $breadcrumb
Definition: page.tpl.php:40
taxonomy_get_parents
taxonomy_get_parents($tid)
Definition: taxonomy.module:1007
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
taxonomy_select_nodes
taxonomy_select_nodes($tid, $pager=TRUE, $limit=FALSE, $order=array('t.sticky'=> 'DESC', 't.created'=> 'DESC'))
Definition: taxonomy.module:204
node_load_multiple
node_load_multiple($nids=array(), $conditions=array(), $reset=FALSE)
Definition: node.module:945
node_view_multiple
node_view_multiple($nodes, $view_mode= 'teaser', $weight=0, $langcode=NULL)
Definition: node.module:2666
check_markup
check_markup($text, $format_id=NULL, $langcode= '', $cache=FALSE)
Definition: filter.module:759
$tree
if($tree||$has_links) print $tree
Definition: book-navigation.tpl.php:35
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
taxonomy_term_view
taxonomy_term_view($term, $view_mode= 'full', $langcode=NULL)
Definition: taxonomy.module:867
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user-profile-category.tpl.php Source File

  • modules
  • user
user-profile-category.tpl.php
Go to the documentation of this file.
1 <?php
2
26 ?>
27 <?php if ($title): ?>
28 <h3><?php print $title; ?></h3>
29 <?php endif; ?>
30
31 <dl<?php print $attributes; ?>>
32 <?php print $profile_items; ?>
33 </dl>
print
print
Definition: php-2.php:2
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
endif
endif
Definition: aggregator-item.tpl.php:31
$profile_items
print $profile_items
Definition: user-profile-category.tpl.php:32
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment.tokens.inc Source File

  • modules
  • comment
comment.tokens.inc
Go to the documentation of this file.
1 <?php
2
11 function comment_token_info() {
12 $type = array(
13 'name' => t('Comments'),
14 'description' => t('Tokens for comments posted on the site.'),
15 'needs-data' => 'comment',
16 );
17
18 // Comment-related tokens for nodes
19 $node['comment-count'] = array(
20 'name' => t("Comment count"),
21 'description' => t("The number of comments posted on a node."),
22 );
23 $node['comment-count-new'] = array(
24 'name' => t("New comment count"),
25 'description' => t("The number of comments posted on a node since the reader last viewed it."),
26 );
27
28 // Core comment tokens
29 $comment['cid'] = array(
30 'name' => t("Comment ID"),
31 'description' => t("The unique ID of the comment."),
32 );
33 $comment['hostname'] = array(
34 'name' => t("IP Address"),
35 'description' => t("The IP address of the computer the comment was posted from."),
36 );
37 $comment['name'] = array(
38 'name' => t("Name"),
39 'description' => t("The name left by the comment author."),
40 );
41 $comment['mail'] = array(
42 'name' => t("Email address"),
43 'description' => t("The email address left by the comment author."),
44 );
45 $comment['homepage'] = array(
46 'name' => t("Home page"),
47 'description' => t("The home page URL left by the comment author."),
48 );
49 $comment['title'] = array(
50 'name' => t("Title"),
51 'description' => t("The title of the comment."),
52 );
53 $comment['body'] = array(
54 'name' => t("Content"),
55 'description' => t("The formatted content of the comment itself."),
56 );
57 $comment['url'] = array(
58 'name' => t("URL"),
59 'description' => t("The URL of the comment."),
60 );
61 $comment['edit-url'] = array(
62 'name' => t("Edit URL"),
63 'description' => t("The URL of the comment's edit page."),
64 );
65
66 // Chained tokens for comments
67 $comment['created'] = array(
68 'name' => t("Date created"),
69 'description' => t("The date the comment was posted."),
70 'type' => 'date',
71 );
72 $comment['changed'] = array(
73 'name' => t("Date changed"),
74 'description' => t("The date the comment was most recently updated."),
75 'type' => 'date',
76 );
77 $comment['parent'] = array(
78 'name' => t("Parent"),
79 'description' => t("The comment's parent, if comment threading is active."),
80 'type' => 'comment',
81 );
82 $comment['node'] = array(
83 'name' => t("Node"),
84 'description' => t("The node the comment was posted to."),
85 'type' => 'node',
86 );
87 $comment['author'] = array(
88 'name' => t("Author"),
89 'description' => t("The author of the comment, if they were logged in."),
90 'type' => 'user',
91 );
92
93 return array(
94 'types' => array('comment' => $type),
95 'tokens' => array(
96 'node' => $node,
97 'comment' => $comment,
98 ),
99 );
100 }
101
105 function comment_tokens($type, $tokens, array $data = array(), array $options = array()) {
106 $url_options = array('absolute' => TRUE);
107 if (isset($options['language'])) {
108 $url_options['language'] = $options['language'];
109 $language_code = $options['language']->language;
110 }
111 else {
112 $language_code = NULL;
113 }
114 $sanitize = !empty($options['sanitize']);
115
116 $replacements = array();
117
118 if ($type == 'comment' && !empty($data['comment'])) {
119 $comment = $data['comment'];
120
121 foreach ($tokens as $name => $original) {
122 switch ($name) {
123 // Simple key values on the comment.
124 case 'cid':
125 $replacements[$original] = $comment->cid;
126 break;
127
128 // Poster identity information for comments
129 case 'hostname':
130 $replacements[$original] = $sanitize ? check_plain($comment->hostname) : $comment->hostname;
131 break;
132
133 case 'name':
134 $name = ($comment->uid == 0) ? variable_get('anonymous', t('Anonymous')) : $comment->name;
135 $replacements[$original] = $sanitize ? filter_xss($name) : $name;
136 break;
137
138 case 'mail':
139 if ($comment->uid != 0) {
140 $account = user_load($comment->uid);
141 $mail = $account->mail;
142 }
143 else {
144 $mail = $comment->mail;
145 }
146 $replacements[$original] = $sanitize ? check_plain($mail) : $mail;
147 break;
148
149 case 'homepage':
150 $replacements[$original] = $sanitize ? check_url($comment->homepage) : $comment->homepage;
151 break;
152
153 case 'title':
154 $replacements[$original] = $sanitize ? filter_xss($comment->subject) : $comment->subject;
155 break;
156
157 case 'body':
158 if ($items = field_get_items('comment', $comment, 'comment_body', $language_code)) {
159 $instance = field_info_instance('comment', 'body', 'comment_body');
160 $field_langcode = field_language('comment', $comment, 'comment_body', $language_code);
161 $replacements[$original] = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'value') : $items[0]['value'];
162 }
163 break;
164
165 // Comment related URLs.
166 case 'url':
167 $url_options['fragment'] = 'comment-' . $comment->cid;
168 $replacements[$original] = url('comment/' . $comment->cid, $url_options);
169 break;
170
171 case 'edit-url':
172 $url_options['fragment'] = NULL;
173 $replacements[$original] = url('comment/' . $comment->cid . '/edit', $url_options);
174 break;
175
176 // Default values for the chained tokens handled below.
177 case 'author':
178 $replacements[$original] = $sanitize ? filter_xss($comment->name) : $comment->name;
179 break;
180
181 case 'parent':
182 if (!empty($comment->pid)) {
183 $parent = comment_load($comment->pid);
184 $replacements[$original] = $sanitize ? filter_xss($parent->subject) : $parent->subject;
185 }
186 break;
187
188 case 'created':
189 $replacements[$original] = format_date($comment->created, 'medium', '', NULL, $language_code);
190 break;
191
192 case 'changed':
193 $replacements[$original] = format_date($comment->changed, 'medium', '', NULL, $language_code);
194 break;
195
196 case 'node':
197 $node = node_load($comment->nid);
198 $title = $node->title;
199 $replacements[$original] = $sanitize ? filter_xss($title) : $title;
200 break;
201 }
202 }
203
204 // Chained token relationships.
205 if ($node_tokens = token_find_with_prefix($tokens, 'node')) {
206 $node = node_load($comment->nid);
207 $replacements += token_generate('node', $node_tokens, array('node' => $node), $options);
208 }
209
210 if ($date_tokens = token_find_with_prefix($tokens, 'created')) {
211 $replacements += token_generate('date', $date_tokens, array('date' => $comment->created), $options);
212 }
213
214 if ($date_tokens = token_find_with_prefix($tokens, 'changed')) {
215 $replacements += token_generate('date', $date_tokens, array('date' => $comment->changed), $options);
216 }
217
218 if (($parent_tokens = token_find_with_prefix($tokens, 'parent')) && $parent = comment_load($comment->pid)) {
219 $replacements += token_generate('comment', $parent_tokens, array('comment' => $parent), $options);
220 }
221
222 if (($author_tokens = token_find_with_prefix($tokens, 'author')) && $account = user_load($comment->uid)) {
223 $replacements += token_generate('user', $author_tokens, array('user' => $account), $options);
224 }
225 }
226 elseif ($type == 'node' & !empty($data['node'])) {
227 $node = $data['node'];
228
229 foreach ($tokens as $name => $original) {
230 switch($name) {
231 case 'comment-count':
232 $replacements[$original] = $node->comment_count;
233 break;
234
235 case 'comment-count-new':
236 $replacements[$original] = comment_num_new($node->nid);
237 break;
238 }
239 }
240 }
241
242 return $replacements;
243 }
comment_token_info
comment_token_info()
Definition: comment.tokens.inc:11
token_generate
token_generate($type, array $tokens, array $data=array(), array $options=array())
Definition: token.inc:176
check_url
check_url($uri)
Definition: common.inc:1387
field_get_items
field_get_items($entity_type, $entity, $field_name, $langcode=NULL)
Definition: field.module:935
$name
print $name
Definition: profile-listing.tpl.php:43
comment_tokens
comment_tokens($type, $tokens, array $data=array(), array $options=array())
Definition: comment.tokens.inc:105
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
field_language
field_language($entity_type, $entity, $field_name=NULL, $langcode=NULL)
Definition: field.multilingual.inc:266
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
comment_load
comment_load($cid, $reset=FALSE)
Definition: comment.module:1683
_text_sanitize
_text_sanitize($instance, $langcode, $item, $column)
Definition: text.module:313
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
comment_num_new
comment_num_new($nid, $timestamp=0)
Definition: comment.module:1729
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
token_find_with_prefix
token_find_with_prefix(array $tokens, $prefix, $delimiter= ':')
Definition: token.inc:219
field_info_instance
field_info_instance($entity_type, $field_name, $bundle_name)
Definition: field.info.inc:623
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/block/block.module Source File

  • modules
  • block
block.module
Go to the documentation of this file.
1 <?php
2
11 define('BLOCK_REGION_NONE', -1);
12
16 define('BLOCK_CUSTOM_FIXED', 0);
17
21 define('BLOCK_CUSTOM_ENABLED', 1);
22
26 define('BLOCK_CUSTOM_DISABLED', 2);
27
31 define('BLOCK_VISIBILITY_NOTLISTED', 0);
32
36 define('BLOCK_VISIBILITY_LISTED', 1);
37
41 define('BLOCK_VISIBILITY_PHP', 2);
42
46 function block_help($path, $arg) {
47 switch ($path) {
48 case 'admin/help#block':
49 $output = '';
50 $output .= '<h3>' . t('About') . '</h3>';
51 $output .= '<p>' . t('The Block module allows you to create boxes of content, which are rendered into an area, or region, of one or more pages of a website. The core Seven administration theme, for example, implements the regions "Content", "Help", "Dashboard main", and "Dashboard sidebar", and a block may appear in any one of these regions. The <a href="@blocks">Blocks administration page</a> provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. For more information, see the online handbook entry for <a href="@block">Block module</a>.', array('@block' => 'http://drupal.org/documentation/modules/block/', '@blocks' => url('admin/structure/block'))) . '</p>';
52 $output .= '<h3>' . t('Uses') . '</h3>';
53 $output .= '<dl>';
54 $output .= '<dt>' . t('Positioning content') . '</dt>';
55 $output .= '<dd>' . t('When working with blocks, remember that all themes do <em>not</em> implement the same regions, or display regions in the same way. Blocks are positioned on a per-theme basis. Users with the <em>Administer blocks</em> permission can disable blocks. Disabled blocks are listed on the <a href="@blocks">Blocks administration page</a>, but are not displayed in any region.', array('@block' => 'http://drupal.org/documentation/modules/block/', '@blocks' => url('admin/structure/block'))) . '</dd>';
56 $output .= '<dt>' . t('Controlling visibility') . '</dt>';
57 $output .= '<dd>' . t('Blocks can be configured to be visible only on certain pages, only to users of certain roles, or only on pages displaying certain <a href="@content-type">content types</a>. Administrators can also allow specific blocks to be enabled or disabled by users when they edit their <a href="@user">My account</a> page. Some dynamic blocks, such as those generated by modules, will be displayed only on certain pages.', array('@content-type' => url('admin/structure/types'), '@user' => url('user'))) . '</dd>';
58 $output .= '<dt>' . t('Creating custom blocks') . '</dt>';
59 $output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can <a href="@block-add">add custom blocks</a>, which are then listed on the <a href="@blocks">Blocks administration page</a>. Once created, custom blocks behave just like default and module-generated blocks.', array('@blocks' => url('admin/structure/block'), '@block-add' => url('admin/structure/block/add'))) . '</dd>';
60 $output .= '</dl>';
61 return $output;
62 case 'admin/structure/block/add':
63 return '<p>' . t('Use this page to create a new custom block.') . '</p>';
64 }
65 if ($arg[0] == 'admin' && $arg[1] == 'structure' && $arg['2'] == 'block' && (empty($arg[3]) || $arg[3] == 'list')) {
66 $demo_theme = !empty($arg[4]) ? $arg[4] : variable_get('theme_default', 'bartik');
67 $themes = list_themes();
68 $output = '<p>' . t('This page provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the <em>Save blocks</em> button at the bottom of the page. Click the <em>configure</em> link next to each block to configure its specific title and visibility settings.') . '</p>';
69 $output .= '<p>' . l(t('Demonstrate block regions (@theme)', array('@theme' => $themes[$demo_theme]->info['name'])), 'admin/structure/block/demo/' . $demo_theme) . '</p>';
70 return $output;
71 }
72 }
73
77 function block_theme() {
78 return array(
79 'block' => array(
80 'render element' => 'elements',
81 'template' => 'block',
82 ),
83 'block_admin_display_form' => array(
84 'template' => 'block-admin-display-form',
85 'file' => 'block.admin.inc',
86 'render element' => 'form',
87 ),
88 );
89 }
90
94 function block_permission() {
95 return array(
96 'administer blocks' => array(
97 'title' => t('Administer blocks'),
98 ),
99 );
100 }
101
105 function block_menu() {
106 $default_theme = variable_get('theme_default', 'bartik');
107 $items['admin/structure/block'] = array(
108 'title' => 'Blocks',
109 'description' => 'Configure what block content appears in your site\'s sidebars and other regions.',
110 'page callback' => 'block_admin_display',
111 'page arguments' => array($default_theme),
112 'access arguments' => array('administer blocks'),
113 'file' => 'block.admin.inc',
114 );
115 $items['admin/structure/block/manage/%/%'] = array(
116 'title' => 'Configure block',
117 'page callback' => 'drupal_get_form',
118 'page arguments' => array('block_admin_configure', 4, 5),
119 'access arguments' => array('administer blocks'),
120 'file' => 'block.admin.inc',
121 );
122 $items['admin/structure/block/manage/%/%/configure'] = array(
123 'title' => 'Configure block',
124 'type' => MENU_DEFAULT_LOCAL_TASK,
125 'context' => MENU_CONTEXT_INLINE,
126 );
127 $items['admin/structure/block/manage/%/%/delete'] = array(
128 'title' => 'Delete block',
129 'page callback' => 'drupal_get_form',
130 'page arguments' => array('block_custom_block_delete', 4, 5),
131 'access arguments' => array('administer blocks'),
132 'type' => MENU_LOCAL_TASK,
133 'context' => MENU_CONTEXT_NONE,
134 'file' => 'block.admin.inc',
135 );
136 $items['admin/structure/block/add'] = array(
137 'title' => 'Add block',
138 'page callback' => 'drupal_get_form',
139 'page arguments' => array('block_add_block_form'),
140 'access arguments' => array('administer blocks'),
141 'type' => MENU_LOCAL_ACTION,
142 'file' => 'block.admin.inc',
143 );
144 foreach (list_themes() as $key => $theme) {
145 $items['admin/structure/block/list/' . $key] = array(
146 'title' => check_plain($theme->info['name']),
147 'page arguments' => array($key),
148 'type' => $key == $default_theme ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
149 'weight' => $key == $default_theme ? -10 : 0,
150 'access callback' => '_block_themes_access',
151 'access arguments' => array($theme),
152 'file' => 'block.admin.inc',
153 );
154 if ($key != $default_theme) {
155 $items['admin/structure/block/list/' . $key . '/add'] = array(
156 'title' => 'Add block',
157 'page callback' => 'drupal_get_form',
158 'page arguments' => array('block_add_block_form'),
159 'access arguments' => array('administer blocks'),
160 'type' => MENU_LOCAL_ACTION,
161 'file' => 'block.admin.inc',
162 );
163 }
164 $items['admin/structure/block/demo/' . $key] = array(
165 'title' => check_plain($theme->info['name']),
166 'page callback' => 'block_admin_demo',
167 'page arguments' => array($key),
168 'type' => MENU_CALLBACK,
169 'access callback' => '_block_themes_access',
170 'access arguments' => array($theme),
171 'theme callback' => '_block_custom_theme',
172 'theme arguments' => array($key),
173 'file' => 'block.admin.inc',
174 );
175 }
176 return $items;
177 }
178
182 function _block_themes_access($theme) {
183 return user_access('administer blocks') && drupal_theme_access($theme);
184 }
185
196 function _block_custom_theme($theme = NULL) {
197 // We return exactly what was passed in, to guarantee that the page will
198 // always be displayed using the theme whose blocks are being configured.
199 return $theme;
200 }
201
205 function block_block_info() {
206 $blocks = array();
207
208 $result = db_query('SELECT bid, info FROM {block_custom} ORDER BY info');
209 foreach ($result as $block) {
210 $blocks[$block->bid]['info'] = $block->info;
211 // Not worth caching.
212 $blocks[$block->bid]['cache'] = DRUPAL_NO_CACHE;
213 }
214 return $blocks;
215 }
216
220 function block_block_configure($delta = 0) {
221 if ($delta) {
222 $custom_block = block_custom_block_get($delta);
223 }
224 else {
225 $custom_block = array();
226 }
227 return block_custom_block_form($custom_block);
228 }
229
233 function block_block_save($delta = 0, $edit = array()) {
234 block_custom_block_save($edit, $delta);
235 }
236
242 function block_block_view($delta = '') {
243 $block = db_query('SELECT body, format FROM {block_custom} WHERE bid = :bid', array(':bid' => $delta))->fetchObject();
244 $data['subject'] = NULL;
245 $data['content'] = check_markup($block->body, $block->format, '', TRUE);
246 return $data;
247 }
248
254 function block_page_build(&$page) {
255 global $theme;
256
257 // The theme system might not yet be initialized. We need $theme.
258 drupal_theme_initialize();
259
260 // Fetch a list of regions for the current theme.
261 $all_regions = system_region_list($theme);
262
263 $item = menu_get_item();
264 if ($item['path'] != 'admin/structure/block/demo/' . $theme) {
265 // Load all region content assigned via blocks.
266 foreach (array_keys($all_regions) as $region) {
267 // Assign blocks to region.
268 if ($blocks = block_get_blocks_by_region($region)) {
269 $page[$region] = $blocks;
270 }
271 }
272 // Once we've finished attaching all blocks to the page, clear the static
273 // cache to allow modules to alter the block list differently in different
274 // contexts. For example, any code that triggers hook_page_build() more
275 // than once in the same page request may need to alter the block list
276 // differently each time, so that only certain parts of the page are
277 // actually built. We do not clear the cache any earlier than this, though,
278 // because it is used each time block_get_blocks_by_region() gets called
279 // above.
280 drupal_static_reset('block_list');
281 }
282 else {
283 // Append region description if we are rendering the regions demo page.
284 $item = menu_get_item();
285 if ($item['path'] == 'admin/structure/block/demo/' . $theme) {
286 $visible_regions = array_keys(system_region_list($theme, REGIONS_VISIBLE));
287 foreach ($visible_regions as $region) {
288 $description = '<div class="block-region">' . $all_regions[$region] . '</div>';
289 $page[$region]['block_description'] = array(
290 '#markup' => $description,
291 '#weight' => 15,
292 );
293 }
294 $page['page_top']['backlink'] = array(
295 '#type' => 'link',
296 '#title' => t('Exit block region demonstration'),
297 '#href' => 'admin/structure/block' . (variable_get('theme_default', 'bartik') == $theme ? '' : '/list/' . $theme),
298 // Add the "overlay-restore" class to indicate this link should restore
299 // the context in which the region demonstration page was opened.
300 '#options' => array('attributes' => array('class' => array('block-demo-backlink', 'overlay-restore'))),
301 '#weight' => -10,
302 );
303 }
304 }
305 }
306
316 function block_get_blocks_by_region($region) {
317 $build = array();
318 if ($list = block_list($region)) {
319 $build = _block_get_renderable_array($list);
320 }
321 return $build;
322 }
323
333 function _block_get_renderable_array($list = array()) {
334 $weight = 0;
335 $build = array();
336 foreach ($list as $key => $block) {
337 $build[$key] = $block->content;
338 unset($block->content);
339
340 // Add contextual links for this block; skip the main content block, since
341 // contextual links are basically output as tabs/local tasks already. Also
342 // skip the help block, since we assume that most users do not need or want
343 // to perform contextual actions on the help block, and the links needlessly
344 // draw attention on it.
345 if ($key != 'system_main' && $key != 'system_help') {
346 $build[$key]['#contextual_links']['block'] = array('admin/structure/block/manage', array($block->module, $block->delta));
347 }
348
349 $build[$key] += array(
350 '#block' => $block,
351 '#weight' => ++$weight,
352 );
353 $build[$key]['#theme_wrappers'][] ='block';
354 }
355 $build['#sorted'] = TRUE;
356 return $build;
357 }
358
369 function _block_rehash($theme = NULL) {
370 global $theme_key;
371
372 drupal_theme_initialize();
373 if (!isset($theme)) {
374 // If theme is not specifically set, rehash for the current theme.
375 $theme = $theme_key;
376 }
377 $regions = system_region_list($theme);
378
379 // These are the blocks the function will return.
380 $blocks = array();
381 // These are the blocks defined by code and modified by the database.
382 $current_blocks = array();
383 // These are {block}.bid values to be kept.
384 $bids = array();
385 $or = db_or();
386 // Gather the blocks defined by modules.
387 foreach (module_implements('block_info') as $module) {
388 $module_blocks = module_invoke($module, 'block_info');
389 foreach ($module_blocks as $delta => $block) {
390 // Compile a condition to retrieve this block from the database.
391 $condition = db_and()
392 ->condition('module', $module)
393 ->condition('delta', $delta);
394 $or->condition($condition);
395 // Add identifiers.
396 $block['module'] = $module;
397 $block['delta'] = $delta;
398 $block['theme'] = $theme;
399 $current_blocks[$module][$delta] = $block;
400 }
401 }
402 // Save the blocks defined in code for alter context.
403 $code_blocks = $current_blocks;
404 $database_blocks = db_select('block', 'b', array('fetch' => PDO::FETCH_ASSOC))
405 ->fields('b')
406 ->condition($or)
407 ->condition('theme', $theme)
408 ->execute();
409 $original_database_blocks = array();
410 foreach ($database_blocks as $block) {
411 $module = $block['module'];
412 $delta = $block['delta'];
413 $original_database_blocks[$module][$delta] = $block;
414 // The cache mode can only by set from hook_block_info(), so that has
415 // precedence over the database's value.
416 if (isset($current_blocks[$module][$delta]['cache'])) {
417 $block['cache'] = $current_blocks[$module][$delta]['cache'];
418 }
419 // Preserve info which is not in the database.
420 $block['info'] = $current_blocks[$module][$delta]['info'];
421 // Blocks stored in the database override the blocks defined in code.
422 $current_blocks[$module][$delta] = $block;
423 // Preserve this block.
424 $bids[$block['bid']] = $block['bid'];
425 }
426 drupal_alter('block_info', $current_blocks, $theme, $code_blocks);
427 foreach ($current_blocks as $module => $module_blocks) {
428 foreach ($module_blocks as $delta => $block) {
429 if (!isset($block['pages'])) {
430 // {block}.pages is type 'text', so it cannot have a
431 // default value, and not null, so we need to provide
432 // value if the module did not.
433 $block['pages'] = '';
434 }
435 // Make sure weight is set.
436 if (!isset($block['weight'])) {
437 $block['weight'] = 0;
438 }
439 if (!empty($block['region']) && $block['region'] != BLOCK_REGION_NONE && !isset($regions[$block['region']]) && $block['status'] == 1) {
440 drupal_set_message(t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => $block['info'], '%region' => $block['region'])), 'warning');
441 // Disabled modules are moved into the BLOCK_REGION_NONE later so no
442 // need to move the block to another region.
443 $block['status'] = 0;
444 }
445 // Set region to none if not enabled and make sure status is set.
446 if (empty($block['status'])) {
447 $block['status'] = 0;
448 $block['region'] = BLOCK_REGION_NONE;
449 }
450 // There is no point saving disabled blocks. Still, we need to save them
451 // because the 'title' attribute is saved to the {blocks} table.
452 if (isset($block['bid'])) {
453 // If the block has a bid property, it comes from the database and
454 // the record needs to be updated, so set the primary key to 'bid'
455 // before passing to drupal_write_record().
456 $primary_keys = array('bid');
457 // Remove a block from the list of blocks to keep if it became disabled.
458 unset($bids[$block['bid']]);
459 }
460 else {
461 $primary_keys = array();
462 }
463 // If the block is new or differs from the original database block, save
464 // it. To determine whether there was a change it is enough to examine
465 // the values for the keys in the original database record as that
466 // contained every database field.
467 if (!$primary_keys || array_diff_assoc($original_database_blocks[$module][$delta], $block)) {
468 drupal_write_record('block', $block, $primary_keys);
469 // Make it possible to test this.
470 $block['saved'] = TRUE;
471 }
472 // Add to the list of blocks we return.
473 $blocks[] = $block;
474 }
475 }
476 if ($bids) {
477 // Remove disabled that are no longer defined by the code from the
478 // database.
479 db_delete('block')
480 ->condition('bid', $bids, 'NOT IN')
481 ->condition('theme', $theme)
482 ->execute();
483 }
484 return $blocks;
485 }
486
501 function block_custom_block_get($bid) {
502 return db_query("SELECT * FROM {block_custom} WHERE bid = :bid", array(':bid' => $bid))->fetchAssoc();
503 }
504
515 function block_custom_block_form($edit = array()) {
516 $edit += array(
517 'info' => '',
518 'body' => '',
519 );
520 $form['info'] = array(
521 '#type' => 'textfield',
522 '#title' => t('Block description'),
523 '#default_value' => $edit['info'],
524 '#maxlength' => 64,
525 '#description' => t('A brief description of your block. Used on the <a href="@overview">Blocks administration page</a>.', array('@overview' => url('admin/structure/block'))),
526 '#required' => TRUE,
527 '#weight' => -18,
528 );
529 $form['body_field']['#weight'] = -17;
530 $form['body_field']['body'] = array(
531 '#type' => 'text_format',
532 '#title' => t('Block body'),
533 '#default_value' => $edit['body'],
534 '#format' => isset($edit['format']) ? $edit['format'] : NULL,
535 '#rows' => 15,
536 '#description' => t('The content of the block as shown to the user.'),
537 '#required' => TRUE,
538 '#weight' => -17,
539 );
540
541 return $form;
542 }
543
559 function block_custom_block_save($edit, $delta) {
560 db_update('block_custom')
561 ->fields(array(
562 'body' => $edit['body']['value'],
563 'info' => $edit['info'],
564 'format' => $edit['body']['format'],
565 ))
566 ->condition('bid', $delta)
567 ->execute();
568 return TRUE;
569 }
570
574 function block_form_user_profile_form_alter(&$form, &$form_state) {
575 if ($form['#user_category'] == 'account') {
576 $account = $form['#user'];
577 $rids = array_keys($account->roles);
578 $result = db_query("SELECT DISTINCT b.* FROM {block} b LEFT JOIN {block_role} r ON b.module = r.module AND b.delta = r.delta WHERE b.status = 1 AND b.custom <> 0 AND (r.rid IN (:rids) OR r.rid IS NULL) ORDER BY b.weight, b.module", array(':rids' => $rids));
579
580 $blocks = array();
581 foreach ($result as $block) {
582 $data = module_invoke($block->module, 'block_info');
583 if ($data[$block->delta]['info']) {
584 $blocks[$block->module][$block->delta] = array(
585 '#type' => 'checkbox',
586 '#title' => check_plain($data[$block->delta]['info']),
587 '#default_value' => isset($account->data['block'][$block->module][$block->delta]) ? $account->data['block'][$block->module][$block->delta] : ($block->custom == 1),
588 );
589 }
590 }
591 // Only display the fieldset if there are any personalizable blocks.
592 if ($blocks) {
593 $form['block'] = array(
594 '#type' => 'fieldset',
595 '#title' => t('Personalize blocks'),
596 '#description' => t('Blocks consist of content or information that complements the main content of the page. Enable or disable optional blocks using the checkboxes below.'),
597 '#weight' => 3,
598 '#collapsible' => TRUE,
599 '#tree' => TRUE,
600 );
601 $form['block'] += $blocks;
602 }
603 }
604 }
605
609 function block_user_presave(&$edit, $account, $category) {
610 if (isset($edit['block'])) {
611 $edit['data']['block'] = $edit['block'];
612 }
613 }
614
621 function block_themes_enabled($theme_list) {
622 foreach ($theme_list as $theme) {
623 block_theme_initialize($theme);
624 }
625 }
626
638 function block_theme_initialize($theme) {
639 // Initialize theme's blocks if none already registered.
640 $has_blocks = (bool) db_query_range('SELECT 1 FROM {block} WHERE theme = :theme', 0, 1, array(':theme' => $theme))->fetchField();
641 if (!$has_blocks) {
642 $default_theme = variable_get('theme_default', 'bartik');
643 // Apply only to new theme's visible regions.
644 $regions = system_region_list($theme, REGIONS_VISIBLE);
645 $result = db_query("SELECT * FROM {block} WHERE theme = :theme", array(':theme' => $default_theme), array('fetch' => PDO::FETCH_ASSOC));
646 foreach ($result as $block) {
647 // If the region isn't supported by the theme, assign the block to the theme's default region.
648 if ($block['status'] && !isset($regions[$block['region']])) {
649 $block['region'] = system_default_region($theme);
650 }
651 $block['theme'] = $theme;
652 unset($block['bid']);
653 drupal_write_record('block', $block);
654 }
655 }
656 }
657
674 function block_list($region) {
675 $blocks = &drupal_static(__FUNCTION__);
676
677 if (!isset($blocks)) {
678 $blocks = _block_load_blocks();
679 }
680
681 // Create an empty array if there are no entries.
682 if (!isset($blocks[$region])) {
683 $blocks[$region] = array();
684 }
685 else {
686 $blocks[$region] = _block_render_blocks($blocks[$region]);
687 }
688
689 return $blocks[$region];
690 }
691
704 function block_load($module, $delta) {
705 if (isset($delta)) {
706 $block = db_query('SELECT * FROM {block} WHERE module = :module AND delta = :delta', array(':module' => $module, ':delta' => $delta))->fetchObject();
707 }
708
709 // If the block does not exist in the database yet return a stub block
710 // object.
711 if (empty($block)) {
712 $block = new stdClass();
713 $block->module = $module;
714 $block->delta = $delta;
715 }
716
717 return $block;
718 }
719
726 function _block_load_blocks() {
727 global $theme_key;
728
729 $query = db_select('block', 'b');
730 $result = $query
731 ->fields('b')
732 ->condition('b.theme', $theme_key)
733 ->condition('b.status', 1)
734 ->orderBy('b.region')
735 ->orderBy('b.weight')
736 ->orderBy('b.module')
737 ->addTag('block_load')
738 ->addTag('translatable')
739 ->execute();
740
741 $block_info = $result->fetchAllAssoc('bid');
742 // Allow modules to modify the block list.
743 drupal_alter('block_list', $block_info);
744
745 $blocks = array();
746 foreach ($block_info as $block) {
747 $blocks[$block->region]["{$block->module}_{$block->delta}"] = $block;
748 }
749 return $blocks;
750 }
751
758 function block_block_list_alter(&$blocks) {
759 global $user, $theme_key;
760
761 // Build an array of roles for each block.
762 $block_roles = array();
763 $result = db_query('SELECT module, delta, rid FROM {block_role}');
764 foreach ($result as $record) {
765 $block_roles[$record->module][$record->delta][] = $record->rid;
766 }
767
768 foreach ($blocks as $key => $block) {
769 if (!isset($block->theme) || !isset($block->status) || $block->theme != $theme_key || $block->status != 1) {
770 // This block was added by a contrib module, leave it in the list.
771 continue;
772 }
773
774 // If a block has no roles associated, it is displayed for every role.
775 // For blocks with roles associated, if none of the user's roles matches
776 // the settings from this block, remove it from the block list.
777 if (isset($block_roles[$block->module][$block->delta]) && !array_intersect($block_roles[$block->module][$block->delta], array_keys($user->roles))) {
778 // No match.
779 unset($blocks[$key]);
780 continue;
781 }
782
783 // Use the user's block visibility setting, if necessary.
784 if ($block->custom != BLOCK_CUSTOM_FIXED) {
785 if ($user->uid && isset($user->data['block'][$block->module][$block->delta])) {
786 $enabled = $user->data['block'][$block->module][$block->delta];
787 }
788 else {
789 $enabled = ($block->custom == BLOCK_CUSTOM_ENABLED);
790 }
791 }
792 else {
793 $enabled = TRUE;
794 }
795
796 // Limited visibility blocks must list at least one page.
797 if ($block->visibility == BLOCK_VISIBILITY_LISTED && empty($block->pages)) {
798 $enabled = FALSE;
799 }
800
801 if (!$enabled) {
802 unset($blocks[$key]);
803 continue;
804 }
805
806 // Match path if necessary.
807 if ($block->pages) {
808 // Convert path to lowercase. This allows comparison of the same path
809 // with different case. Ex: /Page, /page, /PAGE.
810 $pages = drupal_strtolower($block->pages);
811 if ($block->visibility < BLOCK_VISIBILITY_PHP) {
812 // Convert the Drupal path to lowercase
813 $path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
814 // Compare the lowercase internal and lowercase path alias (if any).
815 $page_match = drupal_match_path($path, $pages);
816 if ($path != $_GET['q']) {
817 $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
818 }
819 // When $block->visibility has a value of 0 (BLOCK_VISIBILITY_NOTLISTED),
820 // the block is displayed on all pages except those listed in $block->pages.
821 // When set to 1 (BLOCK_VISIBILITY_LISTED), it is displayed only on those
822 // pages listed in $block->pages.
823 $page_match = !($block->visibility xor $page_match);
824 }
825 elseif (module_exists('php')) {
826 $page_match = php_eval($block->pages);
827 }
828 else {
829 $page_match = FALSE;
830 }
831 }
832 else {
833 $page_match = TRUE;
834 }
835 if (!$page_match) {
836 unset($blocks[$key]);
837 }
838 }
839 }
840
850 function _block_render_blocks($region_blocks) {
851 // Block caching is not compatible with node access modules. We also
852 // preserve the submission of forms in blocks, by fetching from cache only
853 // if the request method is 'GET' (or 'HEAD').
854 $cacheable = !count(module_implements('node_grants')) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD');
855
856 // Proceed to loop over all blocks in order to compute their respective cache
857 // identifiers; this allows us to do one single cache_get_multiple() call
858 // instead of doing one cache_get() call per block.
859 $cached_blocks = array();
860 $cids = array();
861
862 if ($cacheable) {
863 foreach ($region_blocks as $key => $block) {
864 if (!isset($block->content)) {
865 if (($cid = _block_get_cache_id($block))) {
866 $cids[$key] = $cid;
867 }
868 }
869 }
870
871 if ($cids) {
872 // We cannot pass $cids in directly because cache_get_multiple() will
873 // modify it, and we need to use it later on in this function.
874 $cid_values = array_values($cids);
875 $cached_blocks = cache_get_multiple($cid_values, 'cache_block');
876 }
877 }
878
879 foreach ($region_blocks as $key => $block) {
880 // Render the block content if it has not been created already.
881 if (!isset($block->content)) {
882 // Erase the block from the static array - we'll put it back if it has
883 // content.
884 unset($region_blocks[$key]);
885
886 $cid = empty($cids[$key]) ? NULL : $cids[$key];
887
888 // Try fetching the block from the previously loaded cache entries.
889 if (isset($cached_blocks[$cid])) {
890 $array = $cached_blocks[$cid]->data;
891 }
892 else {
893 $array = module_invoke($block->module, 'block_view', $block->delta);
894
895 // Valid PHP function names cannot contain hyphens.
896 $delta = str_replace('-', '_', $block->delta);
897 // Allow modules to modify the block before it is viewed, via either
898 // hook_block_view_alter() or hook_block_view_MODULE_DELTA_alter().
899 drupal_alter(array('block_view', "block_view_{$block->module}_{$delta}"), $array, $block);
900
901 if (isset($cid)) {
902 cache_set($cid, $array, 'cache_block', CACHE_TEMPORARY);
903 }
904 }
905
906 if (isset($array) && is_array($array)) {
907 foreach ($array as $k => $v) {
908 $block->$k = $v;
909 }
910 }
911 if (isset($block->content) && $block->content) {
912 // Normalize to the drupal_render() structure.
913 if (is_string($block->content)) {
914 $block->content = array('#markup' => $block->content);
915 }
916 // Override default block title if a custom display title is present.
917 if ($block->title) {
918 // Check plain here to allow module generated titles to keep any
919 // markup.
920 $block->subject = $block->title == '<none>' ? '' : check_plain($block->title);
921 }
922 if (!isset($block->subject)) {
923 $block->subject = '';
924 }
925 $region_blocks["{$block->module}_{$block->delta}"] = $block;
926 }
927 }
928 }
929 return $region_blocks;
930 }
931
947 function _block_get_cache_id($block) {
948 global $user;
949
950 // User 1 being out of the regular 'roles define permissions' schema,
951 // it brings too many chances of having unwanted output get in the cache
952 // and later be served to other users. We therefore exclude user 1 from
953 // block caching.
954 if (variable_get('block_cache', FALSE) && !in_array($block->cache, array(DRUPAL_NO_CACHE, DRUPAL_CACHE_CUSTOM)) && $user->uid != 1) {
955 // Start with common sub-patterns: block identification, theme, language.
956 $cid_parts[] = $block->module;
957 $cid_parts[] = $block->delta;
958 $cid_parts = array_merge($cid_parts, drupal_render_cid_parts($block->cache));
959
960 return implode(':', $cid_parts);
961 }
962 }
963
967 function block_flush_caches() {
968 // Rehash blocks for active themes. We don't use list_themes() here,
969 // because if MAINTENANCE_MODE is defined it skips reading the database,
970 // and we can't tell which themes are active.
971 $themes = db_query("SELECT name FROM {system} WHERE type = 'theme' AND status = 1");
972 foreach ($themes as $theme) {
973 _block_rehash($theme->name);
974 }
975
976 return array('cache_block');
977 }
978
996 function template_preprocess_block(&$variables) {
997 $block_counter = &drupal_static(__FUNCTION__, array());
998 $variables['block'] = $variables['elements']['#block'];
999 // All blocks get an independent counter for each region.
1000 if (!isset($block_counter[$variables['block']->region])) {
1001 $block_counter[$variables['block']->region] = 1;
1002 }
1003 // Same with zebra striping.
1004 $variables['block_zebra'] = ($block_counter[$variables['block']->region] % 2) ? 'odd' : 'even';
1005 $variables['block_id'] = $block_counter[$variables['block']->region]++;
1006
1007 // Create the $content variable that templates expect.
1008 $variables['content'] = $variables['elements']['#children'];
1009
1010 $variables['classes_array'][] = drupal_html_class('block-' . $variables['block']->module);
1011
1012 $variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->region;
1013 $variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->module;
1014 // Hyphens (-) and underscores (_) play a special role in theme suggestions.
1015 // Theme suggestions should only contain underscores, because within
1016 // drupal_find_theme_templates(), underscores are converted to hyphens to
1017 // match template file names, and then converted back to underscores to match
1018 // pre-processing and other function names. So if your theme suggestion
1019 // contains a hyphen, it will end up as an underscore after this conversion,
1020 // and your function names won't be recognized. So, we need to convert
1021 // hyphens to underscores in block deltas for the theme suggestions.
1022 $variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->module . '__' . strtr($variables['block']->delta, '-', '_');
1023
1024 // Create a valid HTML ID and make sure it is unique.
1025 $variables['block_html_id'] = drupal_html_id('block-' . $variables['block']->module . '-' . $variables['block']->delta);
1026 }
1027
1033 function block_user_role_delete($role) {
1034 db_delete('block_role')
1035 ->condition('rid', $role->rid)
1036 ->execute();
1037 }
1038
1042 function block_menu_delete($menu) {
1043 db_delete('block')
1044 ->condition('module', 'menu')
1045 ->condition('delta', $menu['menu_name'])
1046 ->execute();
1047 db_delete('block_role')
1048 ->condition('module', 'menu')
1049 ->condition('delta', $menu['menu_name'])
1050 ->execute();
1051 }
1052
1056 function block_form_system_performance_settings_alter(&$form, &$form_state) {
1057 $disabled = count(module_implements('node_grants'));
1058 $form['caching']['block_cache'] = array(
1059 '#type' => 'checkbox',
1060 '#title' => t('Cache blocks'),
1061 '#default_value' => variable_get('block_cache', FALSE),
1062 '#disabled' => $disabled,
1063 '#description' => $disabled ? t('Block caching is inactive because you have enabled modules defining content access restrictions.') : NULL,
1064 '#weight' => -1,
1065 );
1066 }
1067
1071 function block_admin_paths() {
1072 $paths = array(
1073 // Exclude the block demonstration page from admin (overlay) treatment.
1074 // This allows us to present this page in its true form, full page.
1075 'admin/structure/block/demo/*' => FALSE,
1076 );
1077 return $paths;
1078 }
1079
1085 function block_modules_uninstalled($modules) {
1086 db_delete('block')
1087 ->condition('module', $modules, 'IN')
1088 ->execute();
1089 db_delete('block_role')
1090 ->condition('module', $modules, 'IN')
1091 ->execute();
1092 }
block_user_presave
block_user_presave(&$edit, $account, $category)
Definition: block.module:609
block_theme_initialize
block_theme_initialize($theme)
Definition: block.module:638
block_theme
block_theme()
Definition: block.module:77
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
BLOCK_VISIBILITY_LISTED
const BLOCK_VISIBILITY_LISTED
Definition: block.module:36
_block_get_cache_id
_block_get_cache_id($block)
Definition: block.module:947
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
menu_get_item
menu_get_item($path=NULL, $router_item=NULL)
Definition: menu.inc:447
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_strtolower
drupal_strtolower($text)
Definition: unicode.inc:521
block_custom_block_form
block_custom_block_form($edit=array())
Definition: block.module:515
block_load
block_load($module, $delta)
Definition: block.module:704
block_flush_caches
block_flush_caches()
Definition: block.module:967
_block_custom_theme
_block_custom_theme($theme=NULL)
Definition: block.module:196
$module
print $module
Definition: search-results.tpl.php:28
MENU_CONTEXT_NONE
const MENU_CONTEXT_NONE
Definition: menu.inc:204
_block_themes_access
_block_themes_access($theme)
Definition: block.module:182
$page
print $page
Definition: overlay.tpl.php:37
block_custom_block_get
block_custom_block_get($bid)
Definition: block.module:501
BLOCK_VISIBILITY_PHP
const BLOCK_VISIBILITY_PHP
Definition: block.module:41
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
block_custom_block_save
block_custom_block_save($edit, $delta)
Definition: block.module:559
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
drupal_theme_access
drupal_theme_access($theme)
Definition: theme.inc:47
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
module_exists
module_exists($module)
Definition: module.inc:274
template_preprocess_block
template_preprocess_block(&$variables)
Definition: block.module:996
system_default_region
system_default_region($theme)
Definition: system.module:2727
cache_get_multiple
cache_get_multiple(array &$cids, $bin= 'cache')
Definition: cache.inc:71
_block_render_blocks
_block_render_blocks($region_blocks)
Definition: block.module:850
db_or
db_or()
Definition: database.inc:2662
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
block_form_system_performance_settings_alter
block_form_system_performance_settings_alter(&$form, &$form_state)
Definition: block.module:1056
block_form_user_profile_form_alter
block_form_user_profile_form_alter(&$form, &$form_state)
Definition: block.module:574
drupal_get_path_alias
drupal_get_path_alias($path=NULL, $path_language=NULL)
Definition: path.inc:235
block_menu_delete
block_menu_delete($menu)
Definition: block.module:1042
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
_block_rehash
_block_rehash($theme=NULL)
Definition: block.module:369
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
block_permission
block_permission()
Definition: block.module:94
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
system_region_list
system_region_list($theme_key, $show=REGIONS_ALL)
Definition: system.module:2689
block_modules_uninstalled
block_modules_uninstalled($modules)
Definition: block.module:1085
php_eval
php_eval($code)
Definition: php.module:63
$output
$output
Definition: authorize.php:93
drupal_html_id
drupal_html_id($id)
Definition: common.inc:3879
block_get_blocks_by_region
block_get_blocks_by_region($region)
Definition: block.module:316
user_access
user_access($string, $account=NULL)
Definition: user.module:794
_block_load_blocks
_block_load_blocks()
Definition: block.module:726
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
block_user_role_delete
block_user_role_delete($role)
Definition: block.module:1033
block_menu
block_menu()
Definition: block.module:105
drupal_theme_initialize
drupal_theme_initialize()
Definition: theme.inc:70
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
block_themes_enabled
block_themes_enabled($theme_list)
Definition: block.module:621
BLOCK_CUSTOM_FIXED
const BLOCK_CUSTOM_FIXED
Definition: block.module:16
drupal_match_path
drupal_match_path($path, $patterns)
Definition: path.inc:312
_block_get_renderable_array
_block_get_renderable_array($list=array())
Definition: block.module:333
DRUPAL_NO_CACHE
const DRUPAL_NO_CACHE
Definition: common.inc:127
BLOCK_REGION_NONE
const BLOCK_REGION_NONE
Definition: block.module:11
CACHE_TEMPORARY
const CACHE_TEMPORARY
Definition: bootstrap.inc:53
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
block_block_view
block_block_view($delta= '')
Definition: block.module:242
MENU_CONTEXT_INLINE
const MENU_CONTEXT_INLINE
Definition: menu.inc:214
block_list
block_list($region)
Definition: block.module:674
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
block_admin_paths
block_admin_paths()
Definition: block.module:1071
block_block_save
block_block_save($delta=0, $edit=array())
Definition: block.module:233
drupal_render_cid_parts
drupal_render_cid_parts($granularity=NULL)
Definition: common.inc:6222
list_themes
list_themes($refresh=FALSE)
Definition: theme.inc:774
check_markup
check_markup($text, $format_id=NULL, $langcode= '', $cache=FALSE)
Definition: filter.module:759
block_block_list_alter
block_block_list_alter(&$blocks)
Definition: block.module:758
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
block_help
block_help($path, $arg)
Definition: block.module:46
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
block_page_build
block_page_build(&$page)
Definition: block.module:254
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
REGIONS_VISIBLE
const REGIONS_VISIBLE
Definition: system.module:60
block_block_configure
block_block_configure($delta=0)
Definition: block.module:220
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
DRUPAL_CACHE_CUSTOM
const DRUPAL_CACHE_CUSTOM
Definition: common.inc:135
drupal_html_class
drupal_html_class($class)
Definition: common.inc:3841
BLOCK_CUSTOM_ENABLED
const BLOCK_CUSTOM_ENABLED
Definition: block.module:21
block_block_info
block_block_info()
Definition: block.module:205
db_and
db_and()
Definition: database.inc:2671
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
FieldValidationException Member List

This is the complete list of members for FieldValidationException, including all inherited members.

$errors | FieldValidationException
__construct($errors) | FieldValidationException
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/filter/filter.install Source File

  • modules
  • filter
filter.install
Go to the documentation of this file.
1 <?php
2
11 function filter_schema() {
12 $schema['filter'] = array(
13 'description' => 'Table that maps filters (HTML corrector) to text formats (Filtered HTML).',
14 'fields' => array(
15 'format' => array(
16 'type' => 'varchar',
17 'length' => 255,
18 'not null' => TRUE,
19 'description' => 'Foreign key: The {filter_format}.format to which this filter is assigned.',
20 ),
21 'module' => array(
22 'type' => 'varchar',
23 'length' => 64,
24 'not null' => TRUE,
25 'default' => '',
26 'description' => 'The origin module of the filter.',
27 ),
28 'name' => array(
29 'type' => 'varchar',
30 'length' => 32,
31 'not null' => TRUE,
32 'default' => '',
33 'description' => 'Name of the filter being referenced.',
34 ),
35 'weight' => array(
36 'type' => 'int',
37 'not null' => TRUE,
38 'default' => 0,
39 'description' => 'Weight of filter within format.',
40 ),
41 'status' => array(
42 'type' => 'int',
43 'not null' => TRUE,
44 'default' => 0,
45 'description' => 'Filter enabled status. (1 = enabled, 0 = disabled)',
46 ),
47 'settings' => array(
48 'type' => 'blob',
49 'not null' => FALSE,
50 'size' => 'big',
51 'serialize' => TRUE,
52 'description' => 'A serialized array of name value pairs that store the filter settings for the specific format.',
53 ),
54 ),
55 'primary key' => array('format', 'name'),
56 'indexes' => array(
57 'list' => array('weight', 'module', 'name'),
58 ),
59 );
60 $schema['filter_format'] = array(
61 'description' => 'Stores text formats: custom groupings of filters, such as Filtered HTML.',
62 'fields' => array(
63 'format' => array(
64 'type' => 'varchar',
65 'length' => 255,
66 'not null' => TRUE,
67 'description' => 'Primary Key: Unique machine name of the format.',
68 ),
69 'name' => array(
70 'type' => 'varchar',
71 'length' => 255,
72 'not null' => TRUE,
73 'default' => '',
74 'description' => 'Name of the text format (Filtered HTML).',
75 'translatable' => TRUE,
76 ),
77 'cache' => array(
78 'type' => 'int',
79 'not null' => TRUE,
80 'default' => 0,
81 'size' => 'tiny',
82 'description' => 'Flag to indicate whether format is cacheable. (1 = cacheable, 0 = not cacheable)',
83 ),
84 'status' => array(
85 'type' => 'int',
86 'unsigned' => TRUE,
87 'not null' => TRUE,
88 'default' => 1,
89 'size' => 'tiny',
90 'description' => 'The status of the text format. (1 = enabled, 0 = disabled)',
91 ),
92 'weight' => array(
93 'type' => 'int',
94 'not null' => TRUE,
95 'default' => 0,
96 'description' => 'Weight of text format to use when listing.',
97 ),
98 ),
99 'primary key' => array('format'),
100 'unique keys' => array(
101 'name' => array('name'),
102 ),
103 'indexes' => array(
104 'status_weight' => array('status', 'weight'),
105 ),
106 );
107
108 $schema['cache_filter'] = drupal_get_schema_unprocessed('system', 'cache');
109 $schema['cache_filter']['description'] = 'Cache table for the Filter module to store already filtered pieces of text, identified by text format and hash of the text.';
110
111 return $schema;
112 }
113
117 function filter_install() {
118 // All sites require at least one text format (the fallback format) that all
119 // users have access to, so add it here. We initialize it as a simple, safe
120 // plain text format with very basic formatting, but it can be modified by
121 // installation profiles to have other properties.
122 $plain_text_format = array(
123 'format' => 'plain_text',
124 'name' => 'Plain text',
125 'weight' => 10,
126 'filters' => array(
127 // Escape all HTML.
128 'filter_html_escape' => array(
129 'weight' => 0,
130 'status' => 1,
131 ),
132 // URL filter.
133 'filter_url' => array(
134 'weight' => 1,
135 'status' => 1,
136 ),
137 // Line break filter.
138 'filter_autop' => array(
139 'weight' => 2,
140 'status' => 1,
141 ),
142 ),
143 );
144 $plain_text_format = (object) $plain_text_format;
145 filter_format_save($plain_text_format);
146
147 // Set the fallback format to plain text.
148 variable_set('filter_fallback_format', $plain_text_format->format);
149 }
150
154 function filter_update_dependencies() {
155 // filter_update_7005() migrates role permissions and therefore must run
156 // after the {role} and {role_permission} tables are properly set up, which
157 // happens in user_update_7007().
158 $dependencies['filter'][7005] = array(
159 'user' => 7007,
160 );
161
162 return $dependencies;
163 }
172 function filter_update_7000() {
173 db_rename_table('filter_formats', 'filter_format');
174
175 // Add the new {filter_format}.status and {filter_format}.weight column.
176 db_add_field('filter_format', 'status', array(
177 'type' => 'int',
178 'unsigned' => TRUE,
179 'not null' => TRUE,
180 'default' => 1,
181 'size' => 'tiny',
182 'description' => 'The status of the text format. (1 = enabled, 0 = disabled)',
183 ));
184 db_add_field('filter_format', 'weight', array(
185 'type' => 'int',
186 'not null' => TRUE,
187 'default' => 0,
188 'description' => 'Weight of text format to use when listing.',
189 ), array(
190 'indexes' => array(
191 'status_weight' => array('status', 'weight'),
192 ),
193 ));
194 }
195
199 function filter_update_7001() {
200 $result = db_query("SELECT format FROM {filter_format}")->fetchCol();
201 $insert = db_insert('filters')->fields(array('format', 'module', 'delta', 'weight'));
202
203 foreach ($result as $format_id) {
204 // Deprecated constants FILTER_HTML_STRIP = 1 and FILTER_HTML_ESCAPE = 2.
205 if (variable_get('filter_html_' . $format_id, 1) == 2) {
206 $insert->values(array(
207 'format' => $format_id,
208 'module' => 'filter',
209 'delta' => 4,
210 'weight' => 0,
211 ));
212 }
213 variable_del('filter_html_' . $format_id);
214 }
215
216 $insert->execute();
217 }
218
222 function filter_update_7003() {
223 // Duplicates the {filters} table since core cannot take care of the potential
224 // contributed module filters.
225 db_rename_table('filters', 'd6_upgrade_filter');
226 // Creates the Drupal 7 filter table.
227 $filter_table = array(
228 'description' => 'Table that maps filters (HTML corrector) to text formats (Filtered HTML).',
229 'fields' => array(
230 'format' => array(
231 'type' => 'int',
232 'not null' => TRUE,
233 'default' => 0,
234 'description' => 'Foreign key: The {filter_format}.format to which this filter is assigned.',
235 ),
236 'module' => array(
237 'type' => 'varchar',
238 'length' => 64,
239 'not null' => TRUE,
240 'default' => '',
241 'description' => 'The origin module of the filter.',
242 ),
243 'name' => array(
244 'type' => 'varchar',
245 'length' => 32,
246 'not null' => TRUE,
247 'default' => '',
248 'description' => 'Name of the filter being referenced.',
249 ),
250 'weight' => array(
251 'type' => 'int',
252 'not null' => TRUE,
253 'default' => 0,
254 'description' => 'Weight of filter within format.',
255 ),
256 'status' => array(
257 'type' => 'int',
258 'not null' => TRUE,
259 'default' => 0,
260 'description' => 'Filter enabled status. (1 = enabled, 0 = disabled)',
261 ),
262 'settings' => array(
263 'type' => 'blob',
264 'not null' => FALSE,
265 'size' => 'big',
266 'serialize' => TRUE,
267 'description' => 'A serialized array of name value pairs that store the filter settings for the specific format.',
268 ),
269 ),
270 'primary key' => array('format', 'name'),
271 'indexes' => array(
272 'list' => array('weight', 'module', 'name'),
273 ),
274 );
275 db_create_table('filter', $filter_table);
276
277 // Get an array of the renamed filter deltas, organized by module.
278 $renamed_deltas = array(
279 'filter' => array(
280 '0' => 'filter_html',
281 '1' => 'filter_autop',
282 '2' => 'filter_url',
283 '3' => 'filter_htmlcorrector',
284 '4' => 'filter_html_escape',
285 ),
286 'php' => array(
287 '0' => 'php_code',
288 ),
289 );
290
291 // Loop through each filter and make changes to the core filter table by
292 // each record from the old to the new table.
293 foreach ($renamed_deltas as $module => $deltas) {
294 foreach ($deltas as $old_delta => $new_name) {
295 $query = db_select('d6_upgrade_filter')
296 ->fields('d6_upgrade_filter', array('format', 'weight'))
297 ->condition('module', $module)
298 ->condition('delta', $old_delta)
299 ->distinct();
300
301 foreach ($query->execute() as $record) {
302 // Port the filter settings.
303 $settings = array();
304 if ($new_name == 'filter_html') {
305 if ($setting = variable_get("allowed_html_{$record->format}", NULL)) {
306 $settings['allowed_html'] = $setting;
307 variable_del("allowed_html_{$record->format}");
308 }
309 if ($setting = variable_get("filter_html_help_{$record->format}", NULL)) {
310 $settings['filter_html_help'] = $setting;
311 variable_del("filter_html_help_{$record->format}");
312 }
313 if ($setting = variable_get("filter_html_nofollow_{$record->format}", NULL)) {
314 $settings['filter_html_nofollow'] = $setting;
315 variable_del("filter_html_nofollow_{$record->format}");
316 }
317 }
318 elseif ($new_name == 'filter_url') {
319 if ($setting = variable_get("filter_url_length_{$record->format}", NULL)) {
320 $settings['filter_url_length'] = $setting;
321 variable_del("filter_url_length_{$record->format}");
322 }
323 }
324
325 db_insert('filter')
326 ->fields(array(
327 'format' => $record->format,
328 'module' => $module,
329 'name' => $new_name,
330 'weight' => $record->weight,
331 'settings' => serialize($settings),
332 'status' => 1,
333 ))
334 ->execute();
335 }
336 db_delete('d6_upgrade_filter')
337 ->condition('module', $module)
338 ->condition('delta', $old_delta)
339 ->execute();
340 }
341 }
342 }
343
352 function filter_update_7005() {
353 // Move role data from the filter system to the user permission system.
354 $all_roles = array_keys(user_roles());
355 $default_format = variable_get('filter_default_format', 1);
356 $result = db_query("SELECT * FROM {filter_format}");
357 foreach ($result as $format) {
358 // We need to assign the default format to all roles (regardless of what
359 // was stored in the database) to preserve the behavior of the site at the
360 // moment of the upgrade.
361 $format_roles = ($format->format == $default_format ? $all_roles : explode(',', $format->roles));
362 foreach ($format_roles as $format_role) {
363 if (in_array($format_role, $all_roles)) {
364 _update_7000_user_role_grant_permissions($format_role, array('use text format ' . $format->format), 'filter');
365 }
366 }
367 }
368
369 // Drop the roles field from the {filter_format} table.
370 db_drop_field('filter_format', 'roles');
371
372 // Add a fallback text format which outputs plain text and appears last on
373 // the list for all users. Generate a unique name for it, starting with
374 // "Plain text".
375 $start_name = 'Plain text';
376 $format_name = $start_name;
377 while ($format = db_query('SELECT format FROM {filter_format} WHERE name = :name', array(':name' => $format_name))->fetchField()) {
378 $id = empty($id) ? 2 : $id + 1;
379 $format_name = $start_name . ' ' . $id;
380 }
381
382 // Insert the filter format.
383 $format_id = db_insert('filter_format')
384 ->fields(array(
385 'name' => $format_name,
386 'cache' => 1,
387 'weight' => 1,
388 'status' => 1,
389 ))
390 ->execute();
391
392 // This format should output plain text, so we escape all HTML and apply the
393 // line break and URL filters only.
394 db_insert('filter')
395 ->fields(array(
396 'format',
397 'name',
398 'weight',
399 'status',
400 'module',
401 'settings',
402 ))
403 ->values(array(
404 'format' => $format_id,
405 'name' => 'filter_html_escape',
406 'weight' => 0,
407 'status' => 1,
408 'module' => 'filter',
409 'settings' => serialize(array()),
410 ))
411 ->values(array(
412 'format' => $format_id,
413 'name' => 'filter_url',
414 'weight' => 1,
415 'status' => 1,
416 'module' => 'filter',
417 'settings' => serialize(array()),
418 ))
419 ->values(array(
420 'format' => $format_id,
421 'name' => 'filter_autop',
422 'weight' => 2,
423 'status' => 1,
424 'module' => 'filter',
425 'settings' => serialize(array()),
426 ))
427 ->execute();
428
429 variable_set('filter_fallback_format', $format_id);
430 drupal_set_message('A new <em>Plain text</em> format has been created which will be available to all users. You can configure this text format on the <a href="' . url('admin/config/content/formats/' . $format) . '">text format configuration page</a>.');
431
432 // Move the former site-wide default text format to the top of the list, so
433 // that it continues to be the default text format for all users.
434 db_update('filter_format')
435 ->fields(array('weight' => -1))
436 ->condition('format', $default_format)
437 ->execute();
438
439 // We do not delete the 'filter_default_format' variable, since other modules
440 // need it in their update functions; for an example, see user_update_7010().
441 // @todo This variable can be deleted in Drupal 8.
442 }
443
447 function filter_update_7008() {
448 // Build the list of permissions to grant.
449 $permissions = array();
450 foreach (db_query('SELECT format FROM {filter_format}')->fetchCol() as $format_id) {
451 if ($format_id != variable_get('filter_fallback_format')) {
452 $permissions[] = 'use text format ' . $format_id;
453 }
454 }
455 // Grant text format permissions to all roles that can 'administer filters'.
456 // Albeit anonymous users *should not* have the permission, we cannot presume
457 // that they do not or must not.
458 if ($roles = user_roles(FALSE, 'administer filters')) {
459 foreach ($roles as $rid => $name) {
460 _update_7000_user_role_grant_permissions($rid, $permissions, 'filter');
461 }
462 }
463 }
464
468 function filter_update_7009() {
469 $schema = system_schema_cache_7054();
470 db_drop_table('cache_filter');
471 db_create_table('cache_filter', $schema);
472 }
473
477 function filter_update_7010() {
478 db_change_field('filter_format', 'format', 'format', array(
479 'type' => 'varchar',
480 'length' => 255,
481 'not null' => TRUE,
482 'description' => 'Primary Key: Unique machine name of the format.',
483 ));
484 db_change_field('filter', 'format', 'format', array(
485 'type' => 'varchar',
486 'length' => 255,
487 'not null' => TRUE,
488 'description' => 'Foreign key: The {filter_format}.format to which this filter is assigned.',
489 ));
490 }
491
filter_update_7001
filter_update_7001()
Definition: filter.install:199
filter_install
filter_install()
Definition: filter.install:117
_update_7000_user_role_grant_permissions
_update_7000_user_role_grant_permissions($rid, array $permissions, $module)
Definition: user.install:389
$module
print $module
Definition: search-results.tpl.php:28
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
filter_update_7010
filter_update_7010()
Definition: filter.install:477
user_roles
user_roles($membersonly=FALSE, $permission=NULL)
Definition: user.module:2871
db_add_field
db_add_field($table, $field, $spec, $keys_new=array())
Definition: database.inc:2840
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
drupal_get_schema_unprocessed
drupal_get_schema_unprocessed($module, $table=NULL)
Definition: common.inc:6998
db_drop_field
db_drop_field($table, $field)
Definition: database.inc:2852
filter_update_dependencies
filter_update_dependencies()
Definition: filter.install:154
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
filter_format_save
filter_format_save($format)
Definition: filter.module:198
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
filter_update_7008
filter_update_7008()
Definition: filter.install:447
filter_update_7000
filter_update_7000()
Definition: filter.install:172
filter_update_7009
filter_update_7009()
Definition: filter.install:468
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
filter_update_7005
filter_update_7005()
Definition: filter.install:352
filter_schema
filter_schema()
Definition: filter.install:11
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
system_schema_cache_7054
system_schema_cache_7054()
Definition: system.install:1660
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
filter_update_7003
filter_update_7003()
Definition: filter.install:222
db_rename_table
db_rename_table($table, $new_name)
Definition: database.inc:2805
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy/taxonomy.admin.inc Source File

  • modules
  • taxonomy
taxonomy.admin.inc
Go to the documentation of this file.
1 <?php
2
15 function taxonomy_overview_vocabularies($form) {
16 $vocabularies = taxonomy_get_vocabularies();
17 $form['#tree'] = TRUE;
18 foreach ($vocabularies as $vocabulary) {
19 $form[$vocabulary->vid]['#vocabulary'] = $vocabulary;
20 $form[$vocabulary->vid]['name'] = array('#markup' => check_plain($vocabulary->name));
21 $form[$vocabulary->vid]['weight'] = array(
22 '#type' => 'weight',
23 '#title' => t('Weight for @title', array('@title' => $vocabulary->name)),
24 '#title_display' => 'invisible',
25 '#delta' => 10,
26 '#default_value' => $vocabulary->weight,
27 );
28 $form[$vocabulary->vid]['edit'] = array('#type' => 'link', '#title' => t('edit vocabulary'), '#href' => "admin/structure/taxonomy/$vocabulary->machine_name/edit");
29 $form[$vocabulary->vid]['list'] = array('#type' => 'link', '#title' => t('list terms'), '#href' => "admin/structure/taxonomy/$vocabulary->machine_name");
30 $form[$vocabulary->vid]['add'] = array('#type' => 'link', '#title' => t('add terms'), '#href' => "admin/structure/taxonomy/$vocabulary->machine_name/add");
31 }
32
33 // Only make this form include a submit button and weight if more than one
34 // vocabulary exists.
35 if (count($vocabularies) > 1) {
36 $form['actions'] = array('#type' => 'actions');
37 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
38 }
39 elseif (isset($vocabulary)) {
40 unset($form[$vocabulary->vid]['weight']);
41 }
42 return $form;
43 }
44
50 function taxonomy_overview_vocabularies_submit($form, &$form_state) {
51 foreach ($form_state['values'] as $vid => $vocabulary) {
52 if (is_numeric($vid) && $form[$vid]['#vocabulary']->weight != $form_state['values'][$vid]['weight']) {
53 $form[$vid]['#vocabulary']->weight = $form_state['values'][$vid]['weight'];
54 taxonomy_vocabulary_save($form[$vid]['#vocabulary']);
55 }
56 }
57 drupal_set_message(t('The configuration options have been saved.'));
58 }
59
70 function theme_taxonomy_overview_vocabularies($variables) {
71 $form = $variables['form'];
72
73 $rows = array();
74
75 foreach (element_children($form) as $key) {
76 if (isset($form[$key]['name'])) {
77 $vocabulary = &$form[$key];
78
79 $row = array();
80 $row[] = drupal_render($vocabulary['name']);
81 if (isset($vocabulary['weight'])) {
82 $vocabulary['weight']['#attributes']['class'] = array('vocabulary-weight');
83 $row[] = drupal_render($vocabulary['weight']);
84 }
85 $row[] = drupal_render($vocabulary['edit']);
86 $row[] = drupal_render($vocabulary['list']);
87 $row[] = drupal_render($vocabulary['add']);
88 $rows[] = array('data' => $row, 'class' => array('draggable'));
89 }
90 }
91
92 $header = array(t('Vocabulary name'));
93 if (isset($form['actions'])) {
94 $header[] = t('Weight');
95 drupal_add_tabledrag('taxonomy', 'order', 'sibling', 'vocabulary-weight');
96 }
97 $header[] = array('data' => t('Operations'), 'colspan' => '3');
98 return theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No vocabularies available. <a href="@link">Add vocabulary</a>.', array('@link' => url('admin/structure/taxonomy/add'))), 'attributes' => array('id' => 'taxonomy'))) . drupal_render_children($form);
99 }
100
108 function taxonomy_form_vocabulary($form, &$form_state, $edit = array()) {
109 // During initial form build, add the entity to the form state for use
110 // during form building and processing. During a rebuild, use what is in the
111 // form state.
112 if (!isset($form_state['vocabulary'])) {
113 $vocabulary = is_object($edit) ? $edit : (object) $edit;
114 $defaults = array(
115 'name' => '',
116 'machine_name' => '',
117 'description' => '',
118 'hierarchy' => 0,
119 'weight' => 0,
120 );
121 foreach ($defaults as $key => $value) {
122 if (!isset($vocabulary->$key)) {
123 $vocabulary->$key = $value;
124 }
125 }
126 $form_state['vocabulary'] = $vocabulary;
127 }
128 else {
129 $vocabulary = $form_state['vocabulary'];
130 }
131
132 // @todo Legacy support. Modules are encouraged to access the entity using
133 // $form_state. Remove in Drupal 8.
134 $form['#vocabulary'] = $form_state['vocabulary'];
135
136 // Check whether we need a deletion confirmation form.
137 if (isset($form_state['confirm_delete']) && isset($form_state['values']['vid'])) {
138 return taxonomy_vocabulary_confirm_delete($form, $form_state, $form_state['values']['vid']);
139 }
140 $form['name'] = array(
141 '#type' => 'textfield',
142 '#title' => t('Name'),
143 '#default_value' => $vocabulary->name,
144 '#maxlength' => 255,
145 '#required' => TRUE,
146 );
147 $form['machine_name'] = array(
148 '#type' => 'machine_name',
149 '#default_value' => $vocabulary->machine_name,
150 '#maxlength' => 255,
151 '#machine_name' => array(
152 'exists' => 'taxonomy_vocabulary_machine_name_load',
153 ),
154 );
155 $form['old_machine_name'] = array(
156 '#type' => 'value',
157 '#value' => $vocabulary->machine_name,
158 );
159 $form['description'] = array(
160 '#type' => 'textfield',
161 '#title' => t('Description'),
162 '#default_value' => $vocabulary->description,
163 );
164 // Set the hierarchy to "multiple parents" by default. This simplifies the
165 // vocabulary form and standardizes the term form.
166 $form['hierarchy'] = array(
167 '#type' => 'value',
168 '#value' => '0',
169 );
170
171 $form['actions'] = array('#type' => 'actions');
172 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
173 if (isset($vocabulary->vid)) {
174 $form['actions']['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
175 $form['vid'] = array('#type' => 'value', '#value' => $vocabulary->vid);
176 $form['module'] = array('#type' => 'value', '#value' => $vocabulary->module);
177 }
178 $form['#validate'][] = 'taxonomy_form_vocabulary_validate';
179
180 return $form;
181 }
182
193 function taxonomy_form_vocabulary_validate($form, &$form_state) {
194 // During the deletion there is no 'machine_name' key
195 if (isset($form_state['values']['machine_name'])) {
196 // Do not allow machine names to conflict with taxonomy path arguments.
197 $machine_name = $form_state['values']['machine_name'];
198 $disallowed = array('add', 'list');
199 if (in_array($machine_name, $disallowed)) {
200 form_set_error('machine_name', t('The machine-readable name cannot be "add" or "list".'));
201 }
202 }
203 }
204
211 function taxonomy_form_vocabulary_submit($form, &$form_state) {
212 if ($form_state['triggering_element']['#value'] == t('Delete')) {
213 // Rebuild the form to confirm vocabulary deletion.
214 $form_state['rebuild'] = TRUE;
215 $form_state['confirm_delete'] = TRUE;
216 return;
217 }
218
219 $vocabulary = $form_state['vocabulary'];
220 entity_form_submit_build_entity('taxonomy_vocabulary', $vocabulary, $form, $form_state);
221
222 switch (taxonomy_vocabulary_save($vocabulary)) {
223 case SAVED_NEW:
224 drupal_set_message(t('Created new vocabulary %name.', array('%name' => $vocabulary->name)));
225 watchdog('taxonomy', 'Created new vocabulary %name.', array('%name' => $vocabulary->name), WATCHDOG_NOTICE, l(t('edit'), 'admin/structure/taxonomy/' . $vocabulary->machine_name . '/edit'));
226 break;
227
228 case SAVED_UPDATED:
229 drupal_set_message(t('Updated vocabulary %name.', array('%name' => $vocabulary->name)));
230 watchdog('taxonomy', 'Updated vocabulary %name.', array('%name' => $vocabulary->name), WATCHDOG_NOTICE, l(t('edit'), 'admin/structure/taxonomy/' . $vocabulary->machine_name . '/edit'));
231 break;
232 }
233
234 $form_state['values']['vid'] = $vocabulary->vid;
235 $form_state['vid'] = $vocabulary->vid;
236 $form_state['redirect'] = 'admin/structure/taxonomy';
237 }
238
249 function taxonomy_overview_terms($form, &$form_state, $vocabulary) {
250 global $pager_page_array, $pager_total, $pager_total_items;
251
252 // Check for confirmation forms.
253 if (isset($form_state['confirm_reset_alphabetical'])) {
254 return taxonomy_vocabulary_confirm_reset_alphabetical($form, $form_state, $vocabulary->vid);
255 }
256
257 $form['#vocabulary'] = $vocabulary;
258 $form['#tree'] = TRUE;
259 $form['#parent_fields'] = FALSE;
260
261 $page = isset($_GET['page']) ? $_GET['page'] : 0;
262 $page_increment = variable_get('taxonomy_terms_per_page_admin', 100); // Number of terms per page.
263 $page_entries = 0; // Elements shown on this page.
264 $before_entries = 0; // Elements at the root level before this page.
265 $after_entries = 0; // Elements at the root level after this page.
266 $root_entries = 0; // Elements at the root level on this page.
267
268 // Terms from previous and next pages are shown if the term tree would have
269 // been cut in the middle. Keep track of how many extra terms we show on each
270 // page of terms.
271 $back_step = NULL;
272 $forward_step = 0;
273
274 // An array of the terms to be displayed on this page.
275 $current_page = array();
276
277 $delta = 0;
278 $term_deltas = array();
279 $tree = taxonomy_get_tree($vocabulary->vid);
280 $term = current($tree);
281 do {
282 // In case this tree is completely empty.
283 if (empty($term)) {
284 break;
285 }
286 $delta++;
287 // Count entries before the current page.
288 if ($page && ($page * $page_increment) > $before_entries && !isset($back_step)) {
289 $before_entries++;
290 continue;
291 }
292 // Count entries after the current page.
293 elseif ($page_entries > $page_increment && isset($complete_tree)) {
294 $after_entries++;
295 continue;
296 }
297
298 // Do not let a term start the page that is not at the root.
299 if (isset($term->depth) && ($term->depth > 0) && !isset($back_step)) {
300 $back_step = 0;
301 while ($pterm = prev($tree)) {
302 $before_entries--;
303 $back_step++;
304 if ($pterm->depth == 0) {
305 prev($tree);
306 continue 2; // Jump back to the start of the root level parent.
307 }
308 }
309 }
310 $back_step = isset($back_step) ? $back_step : 0;
311
312 // Continue rendering the tree until we reach the a new root item.
313 if ($page_entries >= $page_increment + $back_step + 1 && $term->depth == 0 && $root_entries > 1) {
314 $complete_tree = TRUE;
315 // This new item at the root level is the first item on the next page.
316 $after_entries++;
317 continue;
318 }
319 if ($page_entries >= $page_increment + $back_step) {
320 $forward_step++;
321 }
322
323 // Finally, if we've gotten down this far, we're rendering a term on this page.
324 $page_entries++;
325 $term_deltas[$term->tid] = isset($term_deltas[$term->tid]) ? $term_deltas[$term->tid] + 1 : 0;
326 $key = 'tid:' . $term->tid . ':' . $term_deltas[$term->tid];
327
328 // Keep track of the first term displayed on this page.
329 if ($page_entries == 1) {
330 $form['#first_tid'] = $term->tid;
331 }
332 // Keep a variable to make sure at least 2 root elements are displayed.
333 if ($term->parents[0] == 0) {
334 $root_entries++;
335 }
336 $current_page[$key] = $term;
337 } while ($term = next($tree));
338
339 // Because we didn't use a pager query, set the necessary pager variables.
340 $total_entries = $before_entries + $page_entries + $after_entries;
341 $pager_total_items[0] = $total_entries;
342 $pager_page_array[0] = $page;
343 $pager_total[0] = ceil($total_entries / $page_increment);
344
345 // If this form was already submitted once, it's probably hit a validation
346 // error. Ensure the form is rebuilt in the same order as the user submitted.
347 if (!empty($form_state['input'])) {
348 $order = array_flip(array_keys($form_state['input'])); // Get the $_POST order.
349 $current_page = array_merge($order, $current_page); // Update our form with the new order.
350 foreach ($current_page as $key => $term) {
351 // Verify this is a term for the current page and set at the current depth.
352 if (is_array($form_state['input'][$key]) && is_numeric($form_state['input'][$key]['tid'])) {
353 $current_page[$key]->depth = $form_state['input'][$key]['depth'];
354 }
355 else {
356 unset($current_page[$key]);
357 }
358 }
359 }
360
361 // Build the actual form.
362 foreach ($current_page as $key => $term) {
363 // Save the term for the current page so we don't have to load it a second time.
364 $form[$key]['#term'] = (array) $term;
365 if (isset($term->parents)) {
366 $form[$key]['#term']['parent'] = $term->parent = $term->parents[0];
367 unset($form[$key]['#term']['parents'], $term->parents);
368 }
369
370 $form[$key]['view'] = array('#type' => 'link', '#title' => $term->name, '#href' => "taxonomy/term/$term->tid");
371 if ($vocabulary->hierarchy < 2 && count($tree) > 1) {
372 $form['#parent_fields'] = TRUE;
373 $form[$key]['tid'] = array(
374 '#type' => 'hidden',
375 '#value' => $term->tid
376 );
377 $form[$key]['parent'] = array(
378 '#type' => 'hidden',
379 // Yes, default_value on a hidden. It needs to be changeable by the javascript.
380 '#default_value' => $term->parent,
381 );
382 $form[$key]['depth'] = array(
383 '#type' => 'hidden',
384 // Same as above, the depth is modified by javascript, so it's a default_value.
385 '#default_value' => $term->depth,
386 );
387 $form[$key]['weight'] = array(
388 '#type' => 'weight',
389 '#delta' => $delta,
390 '#title_display' => 'invisible',
391 '#title' => t('Weight for added term'),
392 '#default_value' => $term->weight,
393 );
394 }
395 $form[$key]['edit'] = array('#type' => 'link', '#title' => t('edit'), '#href' => 'taxonomy/term/' . $term->tid . '/edit', '#options' => array('query' => drupal_get_destination()));
396 }
397
398 $form['#total_entries'] = $total_entries;
399 $form['#page_increment'] = $page_increment;
400 $form['#page_entries'] = $page_entries;
401 $form['#back_step'] = $back_step;
402 $form['#forward_step'] = $forward_step;
403 $form['#empty_text'] = t('No terms available. <a href="@link">Add term</a>.', array('@link' => url('admin/structure/taxonomy/' . $vocabulary->machine_name . '/add')));
404
405 if ($vocabulary->hierarchy < 2 && count($tree) > 1) {
406 $form['actions'] = array('#type' => 'actions', '#tree' => FALSE);
407 $form['actions']['submit'] = array(
408 '#type' => 'submit',
409 '#value' => t('Save')
410 );
411 $form['actions']['reset_alphabetical'] = array(
412 '#type' => 'submit',
413 '#value' => t('Reset to alphabetical')
414 );
415 $form_state['redirect'] = array($_GET['q'], (isset($_GET['page']) ? array('query' => array('page' => $_GET['page'])) : array()));
416 }
417
418 return $form;
419 }
420
436 function taxonomy_overview_terms_submit($form, &$form_state) {
437 if ($form_state['triggering_element']['#value'] == t('Reset to alphabetical')) {
438 // Execute the reset action.
439 if ($form_state['values']['reset_alphabetical'] === TRUE) {
440 return taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, $form_state);
441 }
442 // Rebuild the form to confirm the reset action.
443 $form_state['rebuild'] = TRUE;
444 $form_state['confirm_reset_alphabetical'] = TRUE;
445 return;
446 }
447
448 // Sort term order based on weight.
449 uasort($form_state['values'], 'drupal_sort_weight');
450
451 $vocabulary = $form['#vocabulary'];
452 $hierarchy = 0; // Update the current hierarchy type as we go.
453
454 $changed_terms = array();
455 $tree = taxonomy_get_tree($vocabulary->vid);
456
457 if (empty($tree)) {
458 return;
459 }
460
461 // Build a list of all terms that need to be updated on previous pages.
462 $weight = 0;
463 $term = (array) $tree[0];
464 while ($term['tid'] != $form['#first_tid']) {
465 if ($term['parents'][0] == 0 && $term['weight'] != $weight) {
466 $term['parent'] = $term['parents'][0];
467 $term['weight'] = $weight;
468 $changed_terms[$term['tid']] = $term;
469 }
470 $weight++;
471 $hierarchy = $term['parents'][0] != 0 ? 1 : $hierarchy;
472 $term = (array) $tree[$weight];
473 }
474
475 // Renumber the current page weights and assign any new parents.
476 $level_weights = array();
477 foreach ($form_state['values'] as $tid => $values) {
478 if (isset($form[$tid]['#term'])) {
479 $term = $form[$tid]['#term'];
480 // Give terms at the root level a weight in sequence with terms on previous pages.
481 if ($values['parent'] == 0 && $term['weight'] != $weight) {
482 $term['weight'] = $weight;
483 $changed_terms[$term['tid']] = $term;
484 }
485 // Terms not at the root level can safely start from 0 because they're all on this page.
486 elseif ($values['parent'] > 0) {
487 $level_weights[$values['parent']] = isset($level_weights[$values['parent']]) ? $level_weights[$values['parent']] + 1 : 0;
488 if ($level_weights[$values['parent']] != $term['weight']) {
489 $term['weight'] = $level_weights[$values['parent']];
490 $changed_terms[$term['tid']] = $term;
491 }
492 }
493 // Update any changed parents.
494 if ($values['parent'] != $term['parent']) {
495 $term['parent'] = $values['parent'];
496 $changed_terms[$term['tid']] = $term;
497 }
498 $hierarchy = $term['parent'] != 0 ? 1 : $hierarchy;
499 $weight++;
500 }
501 }
502
503 // Build a list of all terms that need to be updated on following pages.
504 for ($weight; $weight < count($tree); $weight++) {
505 $term = (array) $tree[$weight];
506 if ($term['parents'][0] == 0 && $term['weight'] != $weight) {
507 $term['parent'] = $term['parents'][0];
508 $term['weight'] = $weight;
509 $changed_terms[$term['tid']] = $term;
510 }
511 $hierarchy = $term['parents'][0] != 0 ? 1 : $hierarchy;
512 }
513
514 // Save all updated terms.
515 foreach ($changed_terms as $changed) {
516 $term = (object) $changed;
517 // Update term_hierachy and term_data directly since we don't have a
518 // fully populated term object to save.
519 db_update('taxonomy_term_hierarchy')
520 ->fields(array('parent' => $term->parent))
521 ->condition('tid', $term->tid, '=')
522 ->execute();
523
524 db_update('taxonomy_term_data')
525 ->fields(array('weight' => $term->weight))
526 ->condition('tid', $term->tid, '=')
527 ->execute();
528 }
529
530 // Update the vocabulary hierarchy to flat or single hierarchy.
531 if ($vocabulary->hierarchy != $hierarchy) {
532 $vocabulary->hierarchy = $hierarchy;
533 taxonomy_vocabulary_save($vocabulary);
534 }
535 drupal_set_message(t('The configuration options have been saved.'));
536 }
537
548 function theme_taxonomy_overview_terms($variables) {
549 $form = $variables['form'];
550
551 $page_increment = $form['#page_increment'];
552 $page_entries = $form['#page_entries'];
553 $back_step = $form['#back_step'];
554 $forward_step = $form['#forward_step'];
555
556 // Add drag and drop if parent fields are present in the form.
557 if ($form['#parent_fields']) {
558 drupal_add_tabledrag('taxonomy', 'match', 'parent', 'term-parent', 'term-parent', 'term-id', FALSE);
559 drupal_add_tabledrag('taxonomy', 'depth', 'group', 'term-depth', NULL, NULL, FALSE);
560 drupal_add_js(drupal_get_path('module', 'taxonomy') . '/taxonomy.js');
561 drupal_add_js(array('taxonomy' => array('backStep' => $back_step, 'forwardStep' => $forward_step)), 'setting');
562 drupal_add_css(drupal_get_path('module', 'taxonomy') . '/taxonomy.css');
563 }
564 drupal_add_tabledrag('taxonomy', 'order', 'sibling', 'term-weight');
565
566 $errors = form_get_errors() != FALSE ? form_get_errors() : array();
567 $rows = array();
568 foreach (element_children($form) as $key) {
569 if (isset($form[$key]['#term'])) {
570 $term = &$form[$key];
571
572 $row = array();
573 $row[] = (isset($term['#term']['depth']) && $term['#term']['depth'] > 0 ? theme('indentation', array('size' => $term['#term']['depth'])) : ''). drupal_render($term['view']);
574 if ($form['#parent_fields']) {
575 $term['tid']['#attributes']['class'] = array('term-id');
576 $term['parent']['#attributes']['class'] = array('term-parent');
577 $term['depth']['#attributes']['class'] = array('term-depth');
578 $row[0] .= drupal_render($term['parent']) . drupal_render($term['tid']) . drupal_render($term['depth']);
579 }
580 $term['weight']['#attributes']['class'] = array('term-weight');
581 $row[] = drupal_render($term['weight']);
582 $row[] = drupal_render($term['edit']);
583 $row = array('data' => $row);
584 $rows[$key] = $row;
585 }
586 }
587
588 // Add necessary classes to rows.
589 $row_position = 0;
590 foreach ($rows as $key => $row) {
591 $rows[$key]['class'] = array();
592 if (isset($form['#parent_fields'])) {
593 $rows[$key]['class'][] = 'draggable';
594 }
595
596 // Add classes that mark which terms belong to previous and next pages.
597 if ($row_position < $back_step || $row_position >= $page_entries - $forward_step) {
598 $rows[$key]['class'][] = 'taxonomy-term-preview';
599 }
600
601 if ($row_position !== 0 && $row_position !== count($rows) - 1) {
602 if ($row_position == $back_step - 1 || $row_position == $page_entries - $forward_step - 1) {
603 $rows[$key]['class'][] = 'taxonomy-term-divider-top';
604 }
605 elseif ($row_position == $back_step || $row_position == $page_entries - $forward_step) {
606 $rows[$key]['class'][] = 'taxonomy-term-divider-bottom';
607 }
608 }
609
610 // Add an error class if this row contains a form error.
611 foreach ($errors as $error_key => $error) {
612 if (strpos($error_key, $key) === 0) {
613 $rows[$key]['class'][] = 'error';
614 }
615 }
616 $row_position++;
617 }
618
619 if (empty($rows)) {
620 $rows[] = array(array('data' => $form['#empty_text'], 'colspan' => '3'));
621 }
622
623 $header = array(t('Name'), t('Weight'), t('Operations'));
624 $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'taxonomy')));
625 $output .= drupal_render_children($form);
626 $output .= theme('pager');
627
628 return $output;
629 }
630
637 function taxonomy_form_term($form, &$form_state, $edit = array(), $vocabulary = NULL) {
638 // During initial form build, add the term entity to the form state for use
639 // during form building and processing. During a rebuild, use what is in the
640 // form state.
641 if (!isset($form_state['term'])) {
642 $term = is_object($edit) ? $edit : (object) $edit;
643 if (!isset($vocabulary) && isset($term->vid)) {
644 $vocabulary = taxonomy_vocabulary_load($term->vid);
645 }
646 $defaults = array(
647 'name' => '',
648 'description' => '',
649 'format' => NULL,
650 'vocabulary_machine_name' => isset($vocabulary) ? $vocabulary->machine_name : NULL,
651 'tid' => NULL,
652 'weight' => 0,
653 );
654 foreach ($defaults as $key => $value) {
655 if (!isset($term->$key)) {
656 $term->$key = $value;
657 }
658 }
659 $form_state['term'] = $term;
660 }
661 else {
662 $term = $form_state['term'];
663 if (!isset($vocabulary) && isset($term->vid)) {
664 $vocabulary = taxonomy_vocabulary_load($term->vid);
665 }
666 }
667
668 $parent = array_keys(taxonomy_get_parents($term->tid));
669 $form['#term'] = (array) $term;
670 $form['#term']['parent'] = $parent;
671 $form['#vocabulary'] = $vocabulary;
672
673 // Check for confirmation forms.
674 if (isset($form_state['confirm_delete'])) {
675 return array_merge($form, taxonomy_term_confirm_delete($form, $form_state, $term->tid));
676 }
677
678 $form['name'] = array(
679 '#type' => 'textfield',
680 '#title' => t('Name'),
681 '#default_value' => $term->name,
682 '#maxlength' => 255,
683 '#required' => TRUE,
684 '#weight' => -5,
685 );
686 $form['description'] = array(
687 '#type' => 'text_format',
688 '#title' => t('Description'),
689 '#default_value' => $term->description,
690 '#format' => $term->format,
691 '#weight' => 0,
692 );
693
694 $form['vocabulary_machine_name'] = array(
695 '#type' => 'value',
696 '#value' => isset($term->vocabulary_machine_name) ? $term->vocabulary_machine_name : $vocabulary->name,
697 );
698
699 $langcode = entity_language('taxonomy_term', $term);
700 field_attach_form('taxonomy_term', $term, $form, $form_state, $langcode);
701
702 $form['relations'] = array(
703 '#type' => 'fieldset',
704 '#title' => t('Relations'),
705 '#collapsible' => TRUE,
706 '#collapsed' => $vocabulary->hierarchy < 2,
707 '#weight' => 10,
708 );
709
710 // taxonomy_get_tree and taxonomy_get_parents may contain large numbers of
711 // items so we check for taxonomy_override_selector before loading the
712 // full vocabulary. Contrib modules can then intercept before
713 // hook_form_alter to provide scalable alternatives.
714 if (!variable_get('taxonomy_override_selector', FALSE)) {
715 $parent = array_keys(taxonomy_get_parents($term->tid));
716 $children = taxonomy_get_tree($vocabulary->vid, $term->tid);
717
718 // A term can't be the child of itself, nor of its children.
719 foreach ($children as $child) {
720 $exclude[] = $child->tid;
721 }
722 $exclude[] = $term->tid;
723
724 $tree = taxonomy_get_tree($vocabulary->vid);
725 $options = array('<' . t('root') . '>');
726 if (empty($parent)) {
727 $parent = array(0);
728 }
729 foreach ($tree as $item) {
730 if (!in_array($item->tid, $exclude)) {
731 $options[$item->tid] = str_repeat('-', $item->depth) . $item->name;
732 }
733 }
734 $form['relations']['parent'] = array(
735 '#type' => 'select',
736 '#title' => t('Parent terms'),
737 '#options' => $options,
738 '#default_value' => $parent,
739 '#multiple' => TRUE,
740 );
741
742 }
743 $form['relations']['weight'] = array(
744 '#type' => 'textfield',
745 '#title' => t('Weight'),
746 '#size' => 6,
747 '#default_value' => $term->weight,
748 '#description' => t('Terms are displayed in ascending order by weight.'),
749 '#required' => TRUE,
750 );
751 $form['vid'] = array(
752 '#type' => 'value',
753 '#value' => $vocabulary->vid,
754 );
755 $form['tid'] = array(
756 '#type' => 'value',
757 '#value' => $term->tid,
758 );
759
760 $form['actions'] = array('#type' => 'actions');
761 $form['actions']['submit'] = array(
762 '#type' => 'submit',
763 '#value' => t('Save'),
764 '#weight' => 5,
765 );
766
767 if ($term->tid) {
768 $form['actions']['delete'] = array(
769 '#type' => 'submit',
770 '#value' => t('Delete'),
771 '#access' => user_access("delete terms in $vocabulary->vid") || user_access('administer taxonomy'),
772 '#weight' => 10,
773 );
774 }
775 else {
776 $form_state['redirect'] = $_GET['q'];
777 }
778
779 return $form;
780 }
781
787 function taxonomy_form_term_validate($form, &$form_state) {
788 entity_form_field_validate('taxonomy_term', $form, $form_state);
789
790 // Ensure numeric values.
791 if (isset($form_state['values']['weight']) && !is_numeric($form_state['values']['weight'])) {
792 form_set_error('weight', t('Weight value must be numeric.'));
793 }
794 }
795
801 function taxonomy_form_term_submit($form, &$form_state) {
802 if ($form_state['triggering_element']['#value'] == t('Delete')) {
803 // Execute the term deletion.
804 if ($form_state['values']['delete'] === TRUE) {
805 return taxonomy_term_confirm_delete_submit($form, $form_state);
806 }
807 // Rebuild the form to confirm term deletion.
808 $form_state['rebuild'] = TRUE;
809 $form_state['confirm_delete'] = TRUE;
810 return;
811 }
812
813 $term = taxonomy_form_term_submit_build_taxonomy_term($form, $form_state);
814
815 $status = taxonomy_term_save($term);
816 switch ($status) {
817 case SAVED_NEW:
818 drupal_set_message(t('Created new term %term.', array('%term' => $term->name)));
819 watchdog('taxonomy', 'Created new term %term.', array('%term' => $term->name), WATCHDOG_NOTICE, l(t('edit'), 'taxonomy/term/' . $term->tid . '/edit'));
820 break;
821 case SAVED_UPDATED:
822 drupal_set_message(t('Updated term %term.', array('%term' => $term->name)));
823 watchdog('taxonomy', 'Updated term %term.', array('%term' => $term->name), WATCHDOG_NOTICE, l(t('edit'), 'taxonomy/term/' . $term->tid . '/edit'));
824 // Clear the page and block caches to avoid stale data.
825 cache_clear_all();
826 break;
827 }
828
829 $current_parent_count = count($form_state['values']['parent']);
830 $previous_parent_count = count($form['#term']['parent']);
831 // Root doesn't count if it's the only parent.
832 if ($current_parent_count == 1 && isset($form_state['values']['parent'][0])) {
833 $current_parent_count = 0;
834 $form_state['values']['parent'] = array();
835 }
836
837 // If the number of parents has been reduced to one or none, do a check on the
838 // parents of every term in the vocabulary value.
839 if ($current_parent_count < $previous_parent_count && $current_parent_count < 2) {
840 taxonomy_check_vocabulary_hierarchy($form['#vocabulary'], $form_state['values']);
841 }
842 // If we've increased the number of parents and this is a single or flat
843 // hierarchy, update the vocabulary immediately.
844 elseif ($current_parent_count > $previous_parent_count && $form['#vocabulary']->hierarchy < 2) {
845 $form['#vocabulary']->hierarchy = $current_parent_count == 1 ? 1 : 2;
846 taxonomy_vocabulary_save($form['#vocabulary']);
847 }
848
849 $form_state['values']['tid'] = $term->tid;
850 $form_state['tid'] = $term->tid;
851 }
852
856 function taxonomy_form_term_submit_build_taxonomy_term($form, &$form_state) {
857 $term = $form_state['term'];
858 entity_form_submit_build_entity('taxonomy_term', $term, $form, $form_state);
859
860 // Convert text_format field into values expected by taxonomy_term_save().
861 $description = $form_state['values']['description'];
862 $term->description = $description['value'];
863 $term->format = $description['format'];
864 return $term;
865 }
866
873 function taxonomy_term_confirm_delete($form, &$form_state, $tid) {
874 $term = taxonomy_term_load($tid);
875
876 // Always provide entity id in the same form key as in the entity edit form.
877 $form['tid'] = array('#type' => 'value', '#value' => $tid);
878
879 $form['#term'] = $term;
880 $form['type'] = array('#type' => 'value', '#value' => 'term');
881 $form['name'] = array('#type' => 'value', '#value' => $term->name);
882 $form['vocabulary_machine_name'] = array('#type' => 'value', '#value' => $term->vocabulary_machine_name);
883 $form['delete'] = array('#type' => 'value', '#value' => TRUE);
884 return confirm_form($form,
885 t('Are you sure you want to delete the term %title?',
886 array('%title' => $term->name)),
887 'admin/structure/taxonomy',
888 t('Deleting a term will delete all its children if there are any. This action cannot be undone.'),
889 t('Delete'),
890 t('Cancel'));
891 }
892
898 function taxonomy_term_confirm_delete_submit($form, &$form_state) {
899 taxonomy_term_delete($form_state['values']['tid']);
900 taxonomy_check_vocabulary_hierarchy($form['#vocabulary'], $form_state['values']);
901 drupal_set_message(t('Deleted term %name.', array('%name' => $form_state['values']['name'])));
902 watchdog('taxonomy', 'Deleted term %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
903 $form_state['redirect'] = 'admin/structure/taxonomy';
904 cache_clear_all();
905 return;
906 }
907
914 function taxonomy_vocabulary_confirm_delete($form, &$form_state, $vid) {
915 $vocabulary = taxonomy_vocabulary_load($vid);
916
917 // Always provide entity id in the same form key as in the entity edit form.
918 $form['vid'] = array('#type' => 'value', '#value' => $vid);
919
920 $form['#vocabulary'] = $vocabulary;
921 $form['#id'] = 'taxonomy_vocabulary_confirm_delete';
922 $form['type'] = array('#type' => 'value', '#value' => 'vocabulary');
923 $form['name'] = array('#type' => 'value', '#value' => $vocabulary->name);
924 $form['#submit'] = array('taxonomy_vocabulary_confirm_delete_submit');
925 return confirm_form($form,
926 t('Are you sure you want to delete the vocabulary %title?',
927 array('%title' => $vocabulary->name)),
928 'admin/structure/taxonomy',
929 t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'),
930 t('Delete'),
931 t('Cancel'));
932 }
933
939 function taxonomy_vocabulary_confirm_delete_submit($form, &$form_state) {
940 $status = taxonomy_vocabulary_delete($form_state['values']['vid']);
941 drupal_set_message(t('Deleted vocabulary %name.', array('%name' => $form_state['values']['name'])));
942 watchdog('taxonomy', 'Deleted vocabulary %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
943 $form_state['redirect'] = 'admin/structure/taxonomy';
944 cache_clear_all();
945 return;
946 }
947
954 function taxonomy_vocabulary_confirm_reset_alphabetical($form, &$form_state, $vid) {
955 $vocabulary = taxonomy_vocabulary_load($vid);
956
957 $form['type'] = array('#type' => 'value', '#value' => 'vocabulary');
958 $form['vid'] = array('#type' => 'value', '#value' => $vid);
959 $form['machine_name'] = array('#type' => 'value', '#value' => $vocabulary->machine_name);
960 $form['name'] = array('#type' => 'value', '#value' => $vocabulary->name);
961 $form['reset_alphabetical'] = array('#type' => 'value', '#value' => TRUE);
962 return confirm_form($form,
963 t('Are you sure you want to reset the vocabulary %title to alphabetical order?',
964 array('%title' => $vocabulary->name)),
965 'admin/structure/taxonomy/' . $vocabulary->machine_name,
966 t('Resetting a vocabulary will discard all custom ordering and sort items alphabetically.'),
967 t('Reset to alphabetical'),
968 t('Cancel'));
969 }
970
976 function taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, &$form_state) {
977 db_update('taxonomy_term_data')
978 ->fields(array('weight' => 0))
979 ->condition('vid', $form_state['values']['vid'])
980 ->execute();
981 drupal_set_message(t('Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name'])));
982 watchdog('taxonomy', 'Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
983 $form_state['redirect'] = 'admin/structure/taxonomy/' . $form_state['values']['machine_name'];
984 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
taxonomy_form_vocabulary
taxonomy_form_vocabulary($form, &$form_state, $edit=array())
Definition: taxonomy.admin.inc:108
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
entity_form_field_validate
entity_form_field_validate($entity_type, $form, &$form_state)
Definition: common.inc:7997
taxonomy_vocabulary_confirm_delete_submit
taxonomy_vocabulary_confirm_delete_submit($form, &$form_state)
Definition: taxonomy.admin.inc:939
taxonomy_vocabulary_save
taxonomy_vocabulary_save($vocabulary)
Definition: taxonomy.module:413
field_attach_form
field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode=NULL, $options=array())
Definition: field.attach.inc:564
SAVED_UPDATED
const SAVED_UPDATED
Definition: common.inc:50
$page
print $page
Definition: overlay.tpl.php:37
taxonomy_overview_terms
taxonomy_overview_terms($form, &$form_state, $vocabulary)
Definition: taxonomy.admin.inc:249
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
taxonomy_overview_vocabularies_submit
taxonomy_overview_vocabularies_submit($form, &$form_state)
Definition: taxonomy.admin.inc:50
$header
print $header
Definition: forum-topic-list.tpl.php:42
taxonomy_form_vocabulary_validate
taxonomy_form_vocabulary_validate($form, &$form_state)
Definition: taxonomy.admin.inc:193
taxonomy_term_delete
taxonomy_term_delete($tid)
Definition: taxonomy.module:701
taxonomy_vocabulary_load
taxonomy_vocabulary_load($vid)
Definition: taxonomy.module:1351
taxonomy_form_term_submit
taxonomy_form_term_submit($form, &$form_state)
Definition: taxonomy.admin.inc:801
taxonomy_vocabulary_delete
taxonomy_vocabulary_delete($vid)
Definition: taxonomy.module:467
taxonomy_overview_vocabularies
taxonomy_overview_vocabularies($form)
Definition: taxonomy.admin.inc:15
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
taxonomy_form_term
taxonomy_form_term($form, &$form_state, $edit=array(), $vocabulary=NULL)
Definition: taxonomy.admin.inc:637
taxonomy_vocabulary_confirm_delete
taxonomy_vocabulary_confirm_delete($form, &$form_state, $vid)
Definition: taxonomy.admin.inc:914
$value
print $value
Definition: user-profile-item.tpl.php:26
taxonomy_overview_terms_submit
taxonomy_overview_terms_submit($form, &$form_state)
Definition: taxonomy.admin.inc:436
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
entity_language
entity_language($entity_type, $entity)
Definition: common.inc:7967
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
$output
$output
Definition: authorize.php:93
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
user_access
user_access($string, $account=NULL)
Definition: user.module:794
taxonomy_get_vocabularies
taxonomy_get_vocabularies()
Definition: taxonomy.module:973
form_get_errors
form_get_errors()
Definition: form.inc:1634
SAVED_NEW
const SAVED_NEW
Definition: common.inc:45
taxonomy_form_term_validate
taxonomy_form_term_validate($form, &$form_state)
Definition: taxonomy.admin.inc:787
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
taxonomy_form_vocabulary_submit
taxonomy_form_vocabulary_submit($form, &$form_state)
Definition: taxonomy.admin.inc:211
taxonomy_form_term_submit_build_taxonomy_term
taxonomy_form_term_submit_build_taxonomy_term($form, &$form_state)
Definition: taxonomy.admin.inc:856
taxonomy_term_confirm_delete
taxonomy_term_confirm_delete($form, &$form_state, $tid)
Definition: taxonomy.admin.inc:873
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
taxonomy_check_vocabulary_hierarchy
taxonomy_check_vocabulary_hierarchy($vocabulary, $changed_term)
Definition: taxonomy.module:564
taxonomy_get_parents
taxonomy_get_parents($tid)
Definition: taxonomy.module:1007
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
theme_taxonomy_overview_vocabularies
theme_taxonomy_overview_vocabularies($variables)
Definition: taxonomy.admin.inc:70
$children
print $children
Definition: book-node-export-html.tpl.php:24
$row
$row
Definition: block-admin-display-form.tpl.php:47
taxonomy_vocabulary_confirm_reset_alphabetical
taxonomy_vocabulary_confirm_reset_alphabetical($form, &$form_state, $vid)
Definition: taxonomy.admin.inc:954
theme_taxonomy_overview_terms
theme_taxonomy_overview_terms($variables)
Definition: taxonomy.admin.inc:548
taxonomy_get_tree
taxonomy_get_tree($vid, $parent=0, $max_depth=NULL, $load_entities=FALSE)
Definition: taxonomy.module:1105
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
taxonomy_term_load
taxonomy_term_load($tid)
Definition: taxonomy.module:1383
$tree
if($tree||$has_links) print $tree
Definition: book-navigation.tpl.php:35
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
taxonomy_term_confirm_delete_submit
taxonomy_term_confirm_delete_submit($form, &$form_state)
Definition: taxonomy.admin.inc:898
taxonomy_term_save
taxonomy_term_save($term)
Definition: taxonomy.module:621
taxonomy_vocabulary_confirm_reset_alphabetical_submit
taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, &$form_state)
Definition: taxonomy.admin.inc:976
entity_form_submit_build_entity
entity_form_submit_build_entity($entity_type, $entity, $form, &$form_state)
Definition: common.inc:8028
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/engines/phptemplate/phptemplate.engine Source File

  • themes
  • engines
  • phptemplate
phptemplate.engine
Go to the documentation of this file.
1 <?php
2
11 function phptemplate_init($template) {
12 $file = dirname($template->filename) . '/template.php';
13 if (file_exists($file)) {
14 include_once DRUPAL_ROOT . '/' . $file;
15 }
16 }
17
21 function phptemplate_theme($existing, $type, $theme, $path) {
22 $templates = drupal_find_theme_functions($existing, array($theme));
23 $templates += drupal_find_theme_templates($existing, '.tpl.php', $path);
24 return $templates;
25 }
phptemplate_theme
phptemplate_theme($existing, $type, $theme, $path)
Definition: phptemplate.engine:21
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
drupal_find_theme_functions
drupal_find_theme_functions($cache, $prefixes)
Definition: theme.inc:1240
phptemplate_init
phptemplate_init($template)
Definition: phptemplate.engine:11
drupal_find_theme_templates
drupal_find_theme_templates($cache, $extension, $path)
Definition: theme.inc:1296
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/lock.inc Source File

  • includes
lock.inc
Go to the documentation of this file.
1 <?php
2
67 function lock_initialize() {
68 global $locks;
69
70 $locks = array();
71 }
72
76 function _lock_id() {
77 // Do not use drupal_static(). This identifier refers to the current
78 // client request, and must not be changed under any circumstances
79 // else the shutdown handler may fail to release our locks.
80 static $lock_id;
81
82 if (!isset($lock_id)) {
83 // Assign a unique id.
84 $lock_id = uniqid(mt_rand(), TRUE);
85 // We only register a shutdown function if a lock is used.
86 drupal_register_shutdown_function('lock_release_all', $lock_id);
87 }
88 return $lock_id;
89 }
90
102 function lock_acquire($name, $timeout = 30.0) {
103 global $locks;
104
105 // Insure that the timeout is at least 1 ms.
106 $timeout = max($timeout, 0.001);
107 $expire = microtime(TRUE) + $timeout;
108 if (isset($locks[$name])) {
109 // Try to extend the expiration of a lock we already acquired.
110 $success = (bool) db_update('semaphore')
111 ->fields(array('expire' => $expire))
112 ->condition('name', $name)
113 ->condition('value', _lock_id())
114 ->execute();
115 if (!$success) {
116 // The lock was broken.
117 unset($locks[$name]);
118 }
119 return $success;
120 }
121 else {
122 // Optimistically try to acquire the lock, then retry once if it fails.
123 // The first time through the loop cannot be a retry.
124 $retry = FALSE;
125 // We always want to do this code at least once.
126 do {
127 try {
128 db_insert('semaphore')
129 ->fields(array(
130 'name' => $name,
131 'value' => _lock_id(),
132 'expire' => $expire,
133 ))
134 ->execute();
135 // We track all acquired locks in the global variable.
136 $locks[$name] = TRUE;
137 // We never need to try again.
138 $retry = FALSE;
139 }
140 catch (PDOException $e) {
141 // Suppress the error. If this is our first pass through the loop,
142 // then $retry is FALSE. In this case, the insert must have failed
143 // meaning some other request acquired the lock but did not release it.
144 // We decide whether to retry by checking lock_may_be_available()
145 // Since this will break the lock in case it is expired.
146 $retry = $retry ? FALSE : lock_may_be_available($name);
147 }
148 // We only retry in case the first attempt failed, but we then broke
149 // an expired lock.
150 } while ($retry);
151 }
152 return isset($locks[$name]);
153 }
154
166 function lock_may_be_available($name) {
167 $lock = db_query('SELECT expire, value FROM {semaphore} WHERE name = :name', array(':name' => $name))->fetchAssoc();
168 if (!$lock) {
169 return TRUE;
170 }
171 $expire = (float) $lock['expire'];
172 $now = microtime(TRUE);
173 if ($now > $expire) {
174 // We check two conditions to prevent a race condition where another
175 // request acquired the lock and set a new expire time. We add a small
176 // number to $expire to avoid errors with float to string conversion.
177 return (bool) db_delete('semaphore')
178 ->condition('name', $name)
179 ->condition('value', $lock['value'])
180 ->condition('expire', 0.0001 + $expire, '<=')
181 ->execute();
182 }
183 return FALSE;
184 }
185
203 function lock_wait($name, $delay = 30) {
204 // Pause the process for short periods between calling
205 // lock_may_be_available(). This prevents hitting the database with constant
206 // database queries while waiting, which could lead to performance issues.
207 // However, if the wait period is too long, there is the potential for a
208 // large number of processes to be blocked waiting for a lock, especially
209 // if the item being rebuilt is commonly requested. To address both of these
210 // concerns, begin waiting for 25ms, then add 25ms to the wait period each
211 // time until it reaches 500ms. After this point polling will continue every
212 // 500ms until $delay is reached.
213
214 // $delay is passed in seconds, but we will be using usleep(), which takes
215 // microseconds as a parameter. Multiply it by 1 million so that all
216 // further numbers are equivalent.
217 $delay = (int) $delay * 1000000;
218
219 // Begin sleeping at 25ms.
220 $sleep = 25000;
221 while ($delay > 0) {
222 // This function should only be called by a request that failed to get a
223 // lock, so we sleep first to give the parallel request a chance to finish
224 // and release the lock.
225 usleep($sleep);
226 // After each sleep, increase the value of $sleep until it reaches
227 // 500ms, to reduce the potential for a lock stampede.
228 $delay = $delay - $sleep;
229 $sleep = min(500000, $sleep + 25000, $delay);
230 if (lock_may_be_available($name)) {
231 // No longer need to wait.
232 return FALSE;
233 }
234 }
235 // The caller must still wait longer to get the lock.
236 return TRUE;
237 }
238
247 function lock_release($name) {
248 global $locks;
249
250 unset($locks[$name]);
251 db_delete('semaphore')
252 ->condition('name', $name)
253 ->condition('value', _lock_id())
254 ->execute();
255 }
256
260 function lock_release_all($lock_id = NULL) {
261 global $locks;
262
263 $locks = array();
264 if (empty($lock_id)) {
265 $lock_id = _lock_id();
266 }
267 db_delete('semaphore')
268 ->condition('value', $lock_id)
269 ->execute();
270 }
271
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
lock_initialize
lock_initialize()
Definition: lock.inc:67
_lock_id
_lock_id()
Definition: lock.inc:76
lock_acquire
lock_acquire($name, $timeout=30.0)
Definition: lock.inc:102
lock_wait
lock_wait($name, $delay=30)
Definition: lock.inc:203
lock_may_be_available
lock_may_be_available($name)
Definition: lock.inc:166
lock_release_all
lock_release_all($lock_id=NULL)
Definition: lock.inc:260
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
lock_release
lock_release($name)
Definition: lock.inc:247
drupal_register_shutdown_function
& drupal_register_shutdown_function($callback=NULL)
Definition: bootstrap.inc:3417
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/seven/template.php Source File

  • themes
  • seven
template.php
Go to the documentation of this file.
1 <?php
2
6 function seven_preprocess_maintenance_page(&$vars) {
7 // While markup for normal pages is split into page.tpl.php and html.tpl.php,
8 // the markup for the maintenance page is all in the single
9 // maintenance-page.tpl.php template. So, to have what's done in
10 // seven_preprocess_html() also happen on the maintenance page, it has to be
11 // called here.
12 seven_preprocess_html($vars);
13 }
14
18 function seven_preprocess_html(&$vars) {
19 // Add conditional CSS for IE8 and below.
20 drupal_add_css(path_to_theme() . '/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE), 'weight' => 999, 'preprocess' => FALSE));
21 // Add conditional CSS for IE7 and below.
22 drupal_add_css(path_to_theme() . '/ie7.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'weight' => 999, 'preprocess' => FALSE));
23 // Add conditional CSS for IE6.
24 drupal_add_css(path_to_theme() . '/ie6.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 6', '!IE' => FALSE), 'weight' => 999, 'preprocess' => FALSE));
25 }
26
30 function seven_preprocess_page(&$vars) {
31 $vars['primary_local_tasks'] = $vars['tabs'];
32 unset($vars['primary_local_tasks']['#secondary']);
33 $vars['secondary_local_tasks'] = array(
34 '#theme' => 'menu_local_tasks',
35 '#secondary' => $vars['tabs']['#secondary'],
36 );
37 }
38
42 function seven_node_add_list($variables) {
43 $content = $variables['content'];
44 $output = '';
45 if ($content) {
46 $output = '<ul class="admin-list">';
47 foreach ($content as $item) {
48 $output .= '<li class="clearfix">';
49 $output .= '<span class="label">' . l($item['title'], $item['href'], $item['localized_options']) . '</span>';
50 $output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>';
51 $output .= '</li>';
52 }
53 $output .= '</ul>';
54 }
55 else {
56 $output = '<p>' . t('You have not created any content types yet. Go to the <a href="@create-content">content type creation page</a> to add a new content type.', array('@create-content' => url('admin/structure/types/add'))) . '</p>';
57 }
58 return $output;
59 }
60
66 function seven_admin_block_content($variables) {
67 $content = $variables['content'];
68 $output = '';
69 if (!empty($content)) {
70 $output = system_admin_compact_mode() ? '<ul class="admin-list compact">' : '<ul class="admin-list">';
71 foreach ($content as $item) {
72 $output .= '<li class="leaf">';
73 $output .= l($item['title'], $item['href'], $item['localized_options']);
74 if (isset($item['description']) && !system_admin_compact_mode()) {
75 $output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>';
76 }
77 $output .= '</li>';
78 }
79 $output .= '</ul>';
80 }
81 return $output;
82 }
83
89 function seven_tablesort_indicator($variables) {
90 $style = $variables['style'];
91 $theme_path = drupal_get_path('theme', 'seven');
92 if ($style == 'asc') {
93 return theme('image', array('path' => $theme_path . '/images/arrow-asc.png', 'alt' => t('sort ascending'), 'width' => 13, 'height' => 13, 'title' => t('sort ascending')));
94 }
95 else {
96 return theme('image', array('path' => $theme_path . '/images/arrow-desc.png', 'alt' => t('sort descending'), 'width' => 13, 'height' => 13, 'title' => t('sort descending')));
97 }
98 }
99
103 function seven_css_alter(&$css) {
104 // Use Seven's vertical tabs style instead of the default one.
105 if (isset($css['misc/vertical-tabs.css'])) {
106 $css['misc/vertical-tabs.css']['data'] = drupal_get_path('theme', 'seven') . '/vertical-tabs.css';
107 $css['misc/vertical-tabs.css']['type'] = 'file';
108 }
109 if (isset($css['misc/vertical-tabs-rtl.css'])) {
110 $css['misc/vertical-tabs-rtl.css']['data'] = drupal_get_path('theme', 'seven') . '/vertical-tabs-rtl.css';
111 $css['misc/vertical-tabs-rtl.css']['type'] = 'file';
112 }
113 // Use Seven's jQuery UI theme style instead of the default one.
114 if (isset($css['misc/ui/jquery.ui.theme.css'])) {
115 $css['misc/ui/jquery.ui.theme.css']['data'] = drupal_get_path('theme', 'seven') . '/jquery.ui.theme.css';
116 $css['misc/ui/jquery.ui.theme.css']['type'] = 'file';
117 }
118 }
seven_admin_block_content
seven_admin_block_content($variables)
Definition: template.php:66
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
system_admin_compact_mode
system_admin_compact_mode()
Definition: system.module:2902
seven_tablesort_indicator
seven_tablesort_indicator($variables)
Definition: template.php:89
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
seven_node_add_list
seven_node_add_list($variables)
Definition: template.php:42
path_to_theme
path_to_theme()
Definition: theme.inc:1219
seven_css_alter
seven_css_alter(&$css)
Definition: template.php:103
seven_preprocess_page
seven_preprocess_page(&$vars)
Definition: template.php:30
seven_preprocess_html
seven_preprocess_html(&$vars)
Definition: template.php:18
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
CSS_THEME
const CSS_THEME
Definition: common.inc:70
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
seven_preprocess_maintenance_page
seven_preprocess_maintenance_page(&$vars)
Definition: template.php:6
$output
$output
Definition: authorize.php:93
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/list/list.module Source File

  • modules
  • field
  • modules
  • list
list.module
Go to the documentation of this file.
1 <?php
2
11 function list_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#list':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t('The List module defines various fields for storing a list of items, for use with the Field module. Usually these items are entered through a select list, checkboxes, or radio buttons. See the <a href="@field-help">Field module help page</a> for more information about fields.', array('@field-help' => url('admin/help/field'))) . '</p>';
17 return $output;
18 }
19 }
20
24 function list_field_info() {
25 return array(
26 'list_integer' => array(
27 'label' => t('List (integer)'),
28 'description' => t("This field stores integer values from a list of allowed 'value => label' pairs, i.e. 'Lifetime in days': 1 => 1 day, 7 => 1 week, 31 => 1 month."),
29 'settings' => array('allowed_values' => array(), 'allowed_values_function' => ''),
30 'default_widget' => 'options_select',
31 'default_formatter' => 'list_default',
32 ),
33 'list_float' => array(
34 'label' => t('List (float)'),
35 'description' => t("This field stores float values from a list of allowed 'value => label' pairs, i.e. 'Fraction': 0 => 0, .25 => 1/4, .75 => 3/4, 1 => 1."),
36 'settings' => array('allowed_values' => array(), 'allowed_values_function' => ''),
37 'default_widget' => 'options_select',
38 'default_formatter' => 'list_default',
39 ),
40 'list_text' => array(
41 'label' => t('List (text)'),
42 'description' => t("This field stores text values from a list of allowed 'value => label' pairs, i.e. 'US States': IL => Illinois, IA => Iowa, IN => Indiana."),
43 'settings' => array('allowed_values' => array(), 'allowed_values_function' => ''),
44 'default_widget' => 'options_select',
45 'default_formatter' => 'list_default',
46 ),
47 'list_boolean' => array(
48 'label' => t('Boolean'),
49 'description' => t('This field stores simple on/off or yes/no options.'),
50 'settings' => array('allowed_values' => array(), 'allowed_values_function' => ''),
51 'default_widget' => 'options_buttons',
52 'default_formatter' => 'list_default',
53 ),
54 );
55 }
56
60 function list_field_settings_form($field, $instance, $has_data) {
61 $settings = $field['settings'];
62
63 switch ($field['type']) {
64 case 'list_integer':
65 case 'list_float':
66 case 'list_text':
67 $form['allowed_values'] = array(
68 '#type' => 'textarea',
69 '#title' => t('Allowed values list'),
70 '#default_value' => list_allowed_values_string($settings['allowed_values']),
71 '#rows' => 10,
72 '#element_validate' => array('list_allowed_values_setting_validate'),
73 '#field_has_data' => $has_data,
74 '#field' => $field,
75 '#field_type' => $field['type'],
76 '#access' => empty($settings['allowed_values_function']),
77 );
78
79 $description = '<p>' . t('The possible values this field can contain. Enter one value per line, in the format key|label.');
80 if ($field['type'] == 'list_integer' || $field['type'] == 'list_float') {
81 $description .= '<br/>' . t('The key is the stored value, and must be numeric. The label will be used in displayed values and edit forms.');
82 $description .= '<br/>' . t('The label is optional: if a line contains a single number, it will be used as key and label.');
83 $description .= '<br/>' . t('Lists of labels are also accepted (one label per line), only if the field does not hold any values yet. Numeric keys will be automatically generated from the positions in the list.');
84 }
85 else {
86 $description .= '<br/>' . t('The key is the stored value. The label will be used in displayed values and edit forms.');
87 $description .= '<br/>' . t('The label is optional: if a line contains a single string, it will be used as key and label.');
88 }
89 $description .= '</p>';
90 $form['allowed_values']['#description'] = $description;
91
92 break;
93
94 case 'list_boolean':
95 $values = $settings['allowed_values'];
96 $off_value = array_shift($values);
97 $on_value = array_shift($values);
98
99 $form['allowed_values'] = array(
100 '#type' => 'value',
101 '#description' => '',
102 '#value_callback' => 'list_boolean_allowed_values_callback',
103 '#access' => empty($settings['allowed_values_function']),
104 );
105 $form['allowed_values']['on'] = array(
106 '#type' => 'textfield',
107 '#title' => t('On value'),
108 '#default_value' => $on_value,
109 '#required' => FALSE,
110 '#description' => t('If left empty, "1" will be used.'),
111 // Change #parents to make sure the element is not saved into field
112 // settings.
113 '#parents' => array('on'),
114 );
115 $form['allowed_values']['off'] = array(
116 '#type' => 'textfield',
117 '#title' => t('Off value'),
118 '#default_value' => $off_value,
119 '#required' => FALSE,
120 '#description' => t('If left empty, "0" will be used.'),
121 // Change #parents to make sure the element is not saved into field
122 // settings.
123 '#parents' => array('off'),
124 );
125
126 // Link the allowed value to the on / off elements to prepare for the rare
127 // case of an alter changing #parents.
128 $form['allowed_values']['#on_parents'] = &$form['allowed_values']['on']['#parents'];
129 $form['allowed_values']['#off_parents'] = &$form['allowed_values']['off']['#parents'];
130
131 break;
132 }
133
134 // Alter the description for allowed values depending on the widget type.
135 if ($instance['widget']['type'] == 'options_onoff') {
136 $form['allowed_values']['#description'] .= '<p>' . t("For a 'single on/off checkbox' widget, define the 'off' value first, then the 'on' value in the <strong>Allowed values</strong> section. Note that the checkbox will be labeled with the label of the 'on' value.") . '</p>';
137 }
138 elseif ($instance['widget']['type'] == 'options_buttons') {
139 $form['allowed_values']['#description'] .= '<p>' . t("The 'checkboxes/radio buttons' widget will display checkboxes if the <em>Number of values</em> option is greater than 1 for this field, otherwise radios will be displayed.") . '</p>';
140 }
141 $form['allowed_values']['#description'] .= '<p>' . t('Allowed HTML tags in labels: @tags', array('@tags' => _field_filter_xss_display_allowed_tags())) . '</p>';
142
143 $form['allowed_values_function'] = array(
144 '#type' => 'value',
145 '#value' => $settings['allowed_values_function'],
146 );
147 $form['allowed_values_function_display'] = array(
148 '#type' => 'item',
149 '#title' => t('Allowed values list'),
150 '#markup' => t('The value of this field is being determined by the %function function and may not be changed.', array('%function' => $settings['allowed_values_function'])),
151 '#access' => !empty($settings['allowed_values_function']),
152 );
153
154 return $form;
155 }
156
160 function list_allowed_values_setting_validate($element, &$form_state) {
161 $field = $element['#field'];
162 $has_data = $element['#field_has_data'];
163 $field_type = $field['type'];
164 $generate_keys = ($field_type == 'list_integer' || $field_type == 'list_float') && !$has_data;
165
166 $values = list_extract_allowed_values($element['#value'], $field['type'], $generate_keys);
167
168 if (!is_array($values)) {
169 form_error($element, t('Allowed values list: invalid input.'));
170 }
171 else {
172 // Check that keys are valid for the field type.
173 foreach ($values as $key => $value) {
174 if ($field_type == 'list_integer' && !preg_match('/^-?\d+$/', $key)) {
175 form_error($element, t('Allowed values list: keys must be integers.'));
176 break;
177 }
178 if ($field_type == 'list_float' && !is_numeric($key)) {
179 form_error($element, t('Allowed values list: each key must be a valid integer or decimal.'));
180 break;
181 }
182 elseif ($field_type == 'list_text' && drupal_strlen($key) > 255) {
183 form_error($element, t('Allowed values list: each key must be a string at most 255 characters long.'));
184 break;
185 }
186 }
187
188 // Prevent removing values currently in use.
189 if ($has_data) {
190 $lost_keys = array_diff(array_keys($field['settings']['allowed_values']), array_keys($values));
191 if (_list_values_in_use($field, $lost_keys)) {
192 form_error($element, t('Allowed values list: some values are being removed while currently in use.'));
193 }
194 }
195
196 form_set_value($element, $values, $form_state);
197 }
198 }
199
203 function list_boolean_allowed_values_callback($element, $input, $form_state) {
204 $on = drupal_array_get_nested_value($form_state['input'], $element['#on_parents']);
205 $off = drupal_array_get_nested_value($form_state['input'], $element['#off_parents']);
206 return array($off, $on);
207 }
208
212 function list_field_update_field($field, $prior_field, $has_data) {
213 drupal_static_reset('list_allowed_values');
214 }
215
235 function list_allowed_values($field, $instance = NULL, $entity_type = NULL, $entity = NULL) {
236 $allowed_values = &drupal_static(__FUNCTION__, array());
237
238 if (!isset($allowed_values[$field['id']])) {
239 $function = $field['settings']['allowed_values_function'];
240 // If $cacheable is FALSE, then the allowed values are not statically
241 // cached. See list_test_dynamic_values_callback() for an example of
242 // generating dynamic and uncached values.
243 $cacheable = TRUE;
244 if (!empty($function) && function_exists($function)) {
245 $values = $function($field, $instance, $entity_type, $entity, $cacheable);
246 }
247 else {
248 $values = $field['settings']['allowed_values'];
249 }
250
251 if ($cacheable) {
252 $allowed_values[$field['id']] = $values;
253 }
254 else {
255 return $values;
256 }
257 }
258
259 return $allowed_values[$field['id']];
260 }
261
280 function list_extract_allowed_values($string, $field_type, $generate_keys) {
281 $values = array();
282
283 $list = explode("\n", $string);
284 $list = array_map('trim', $list);
285 $list = array_filter($list, 'strlen');
286
287 $generated_keys = $explicit_keys = FALSE;
288 foreach ($list as $position => $text) {
289 $value = $key = FALSE;
290
291 // Check for an explicit key.
292 $matches = array();
293 if (preg_match('/(.*)\|(.*)/', $text, $matches)) {
294 $key = $matches[1];
295 $value = $matches[2];
296 $explicit_keys = TRUE;
297 }
298 // Otherwise see if we can use the value as the key. Detecting true integer
299 // strings takes a little trick.
300 elseif ($field_type == 'list_text'
301 || ($field_type == 'list_float' && is_numeric($text))
302 || ($field_type == 'list_integer' && is_numeric($text) && (float) $text == intval($text))) {
303 $key = $value = $text;
304 $explicit_keys = TRUE;
305 }
306 // Otherwise see if we can generate a key from the position.
307 elseif ($generate_keys) {
308 $key = (string) $position;
309 $value = $text;
310 $generated_keys = TRUE;
311 }
312 else {
313 return;
314 }
315
316 // Float keys are represented as strings and need to be disambiguated
317 // ('.5' is '0.5').
318 if ($field_type == 'list_float' && is_numeric($key)) {
319 $key = (string) (float) $key;
320 }
321
322 $values[$key] = $value;
323 }
324
325 // We generate keys only if the list contains no explicit key at all.
326 if ($explicit_keys && $generated_keys) {
327 return;
328 }
329
330 return $values;
331 }
332
347 function list_allowed_values_string($values) {
348 $lines = array();
349 foreach ($values as $key => $value) {
350 $lines[] = "$key|$value";
351 }
352 return implode("\n", $lines);
353 }
354
358 function list_field_update_forbid($field, $prior_field, $has_data) {
359 if ($field['module'] == 'list' && $has_data) {
360 // Forbid any update that removes allowed values with actual data.
361 $lost_keys = array_diff(array_keys($prior_field['settings']['allowed_values']), array_keys($field['settings']['allowed_values']));
362 if (_list_values_in_use($field, $lost_keys)) {
363 throw new FieldUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', array('@field_name' => $field['field_name'])));
364 }
365 }
366 }
367
371 function _list_values_in_use($field, $values) {
372 if ($values) {
373 $query = new EntityFieldQuery();
374 $found = $query
375 ->fieldCondition($field['field_name'], 'value', $values)
376 ->range(0, 1)
377 ->execute();
378 return !empty($found);
379 }
380
381 return FALSE;
382 }
383
390 function list_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
391 $allowed_values = list_allowed_values($field, $instance, $entity_type, $entity);
392 foreach ($items as $delta => $item) {
393 if (!empty($item['value'])) {
394 if (!empty($allowed_values) && !isset($allowed_values[$item['value']])) {
395 $errors[$field['field_name']][$langcode][$delta][] = array(
396 'error' => 'list_illegal_value',
397 'message' => t('%name: illegal value.', array('%name' => $instance['label'])),
398 );
399 }
400 }
401 }
402 }
403
407 function list_field_is_empty($item, $field) {
408 if (empty($item['value']) && (string) $item['value'] !== '0') {
409 return TRUE;
410 }
411 return FALSE;
412 }
413
422 function list_field_widget_info_alter(&$info) {
423 $widgets = array(
424 'options_select' => array('list_integer', 'list_float', 'list_text'),
425 'options_buttons' => array('list_integer', 'list_float', 'list_text', 'list_boolean'),
426 'options_onoff' => array('list_boolean'),
427 );
428
429 foreach ($widgets as $widget => $field_types) {
430 $info[$widget]['field types'] = array_merge($info[$widget]['field types'], $field_types);
431 }
432 }
433
437 function list_options_list($field, $instance, $entity_type, $entity) {
438 return list_allowed_values($field, $instance, $entity_type, $entity);
439 }
440
444 function list_field_formatter_info() {
445 return array(
446 'list_default' => array(
447 'label' => t('Default'),
448 'field types' => array('list_integer', 'list_float', 'list_text', 'list_boolean'),
449 ),
450 'list_key' => array(
451 'label' => t('Key'),
452 'field types' => array('list_integer', 'list_float', 'list_text', 'list_boolean'),
453 ),
454 );
455 }
456
460 function list_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
461 $element = array();
462
463 switch ($display['type']) {
464 case 'list_default':
465 $allowed_values = list_allowed_values($field, $instance, $entity_type, $entity);
466 foreach ($items as $delta => $item) {
467 if (isset($allowed_values[$item['value']])) {
468 $output = field_filter_xss($allowed_values[$item['value']]);
469 }
470 else {
471 // If no match was found in allowed values, fall back to the key.
472 $output = field_filter_xss($item['value']);
473 }
474 $element[$delta] = array('#markup' => $output);
475 }
476 break;
477
478 case 'list_key':
479 foreach ($items as $delta => $item) {
480 $element[$delta] = array('#markup' => field_filter_xss($item['value']));
481 }
482 break;
483 }
484
485 return $element;
486 }
_field_filter_xss_display_allowed_tags
_field_filter_xss_display_allowed_tags()
Definition: field.module:766
_list_values_in_use
_list_values_in_use($field, $values)
Definition: list.module:371
list_field_validate
list_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
Definition: list.module:390
drupal_strlen
drupal_strlen($text)
Definition: unicode.inc:474
field_filter_xss
field_filter_xss($string)
Definition: field.module:752
drupal_array_get_nested_value
& drupal_array_get_nested_value(array &$array, array $parents, &$key_exists=NULL)
Definition: common.inc:6666
list_extract_allowed_values
list_extract_allowed_values($string, $field_type, $generate_keys)
Definition: list.module:280
list_field_is_empty
list_field_is_empty($item, $field)
Definition: list.module:407
list_allowed_values_string
list_allowed_values_string($values)
Definition: list.module:347
list_field_update_field
list_field_update_field($field, $prior_field, $has_data)
Definition: list.module:212
list_allowed_values
list_allowed_values($field, $instance=NULL, $entity_type=NULL, $entity=NULL)
Definition: list.module:235
list_help
list_help($path, $arg)
Definition: list.module:11
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
list_field_formatter_info
list_field_formatter_info()
Definition: list.module:444
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$info
$info
Definition: color.inc:6
EntityFieldQuery
Definition: entity.inc:420
$value
print $value
Definition: user-profile-item.tpl.php:26
$output
$output
Definition: authorize.php:93
list_field_widget_info_alter
list_field_widget_info_alter(&$info)
Definition: list.module:422
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
list_field_info
list_field_info()
Definition: list.module:24
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
list_allowed_values_setting_validate
list_allowed_values_setting_validate($element, &$form_state)
Definition: list.module:160
list_options_list
list_options_list($field, $instance, $entity_type, $entity)
Definition: list.module:437
list_field_formatter_view
list_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
Definition: list.module:460
list_field_settings_form
list_field_settings_form($field, $instance, $has_data)
Definition: list.module:60
FieldUpdateForbiddenException
Definition: field.module:279
list_boolean_allowed_values_callback
list_boolean_allowed_values_callback($element, $input, $form_state)
Definition: list.module:203
list_field_update_forbid
list_field_update_forbid($field, $prior_field, $has_data)
Definition: list.module:358
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/menu_example/menu_example.module Source File

  • examples
  • menu_example
menu_example.module
Go to the documentation of this file.
1 <?php
2
27 function menu_example_menu() {
28
29 // A simple example which defines a page callback and a menu entry.
30
31 // Menu items are defined by placing them in an $items array. The array key
32 // (in this case 'menu_example') is the path that defines the menu router
33 // entry, so the page will be accessible from the URL
34 // example.com/examples/menu_example.
35 $items['examples/menu_example'] = array(
36 // We are using the default menu type, so this can be omitted.
37 // 'type' => MENU_NORMAL_ITEM,
38
39 // The menu title. Do NOT use t() which is called by default. You can
40 // override the use of t() by defining a 'title callback'. This is explained
41 // in the 'menu_example/title_callbacks' example below.
42 'title' => 'Menu Example',
43
44 // Description (hover flyover for menu link). Does NOT use t(), which is
45 // called automatically.
46 'description' => 'Simplest possible menu type, and the parent menu entry for others',
47
48 // Function to be called when this path is accessed.
49 'page callback' => '_menu_example_basic_instructions',
50
51 // Arguments to the page callback. Here's we'll use them just to provide
52 // content for our page.
53 'page arguments' => array(t('This page is displayed by the simplest (and base) menu example. Note that the title of the page is the same as the link title. You can also <a href="!link">visit a similar page with no menu link</a>. Also, note that there is a hook_menu_alter() example that has changed the path of one of the menu items.', array('!link' => url('examples/menu_example/path_only')))),
54
55 // If the page is meant to be accessible to all users, you can set 'access
56 // callback' to TRUE. This bypasses all access checks. For an explanation on
57 // how to use the permissions system to restrict access for certain users,
58 // see the example 'examples/menu_example/permissioned/controlled' below.
59 'access callback' => TRUE,
60
61 // If the page callback is located in another file, specify it here and
62 // that file will be automatically loaded when needed.
63 // 'file' => 'menu_example.module',
64
65 // We can choose which menu gets the link. The default is 'navigation'.
66 // 'menu_name' => 'navigation',
67
68 // Show the menu link as expanded.
69 'expanded' => TRUE,
70 );
71
72 // Show a menu link in a menu other than the default "Navigation" menu.
73 // The menu must already exist.
74 $items['examples/menu_example_alternate_menu'] = array(
75 'title' => 'Menu Example: Menu in alternate menu',
76
77 // Machine name of the menu in which the link should appear.
78 'menu_name' => 'primary-links',
79
80 'page callback' => '_menu_example_menu_page',
81 'page arguments' => array(t('This will be in the Primary Links menu instead of the default Navigation menu')),
82 'access callback' => TRUE,
83 );
84
85 // A menu entry with simple permissions using user_access().
86
87 // First, provide a courtesy menu item that mentions the existence of the
88 // permissioned item.
89 $items['examples/menu_example/permissioned'] = array(
90 'title' => 'Permissioned Example',
91 'page callback' => '_menu_example_menu_page',
92 'page arguments' => array(t('A menu item that requires the "access protected menu example" permission is at <a href="!link">examples/menu_example/permissioned/controlled</a>', array('!link' => url('examples/menu_example/permissioned/controlled')))),
93 'access callback' => TRUE,
94 'expanded' => TRUE,
95 );
96
97 // Now provide the actual permissioned menu item.
98 $items['examples/menu_example/permissioned/controlled'] = array(
99
100 // The title - do NOT use t() as t() is called automatically.
101 'title' => 'Permissioned Menu Item',
102 'description' => 'This menu entry will not appear and the page will not be accessible without the "access protected menu example" permission.',
103 'page callback' => '_menu_example_menu_page',
104 'page arguments' => array(t('This menu entry will not show and the page will not be accessible without the "access protected menu example" permission.')),
105
106 // For a permissioned menu entry, we provide an access callback which
107 // determines whether the current user should have access. The default is
108 // user_access(), which we'll use in this case. Since it's the default,
109 // we don't even have to enter it.
110 // 'access callback' => 'user_access',
111
112 // The 'access arguments' are passed to the 'access callback' to help it
113 // do its job. In the case of user_access(), we need to pass a permission
114 // as the first argument.
115 'access arguments' => array('access protected menu example'),
116
117 // The optional weight element tells how to order the submenu items.
118 // Higher weights are "heavier", dropping to the bottom of the menu.
119 'weight' => 10,
120 );
121
122 /*
123 * We will define our own "access callback" function i.e is "menu_example_custom_access",
124 * rather than the default 'user_access'.
125 *
126 * The function takes a "role" of the user as an argument.
127 */
128 $items['examples/menu_example/custom_access'] = array(
129 'title' => 'Custom Access Example',
130 'page callback' => '_menu_example_menu_page',
131 'page arguments' => array(t('A menu item that requires the user to posess a role of "authenticated user" is at <a href="!link">examples/menu_example/custom_access/page</a>', array('!link' => url('examples/menu_example/custom_access/page')))),
132 'access callback' => TRUE,
133 'expanded' => TRUE,
134 'weight' => -5,
135 );
136
137 $items['examples/menu_example/custom_access/page'] = array(
138 'title' => 'Custom Access Menu Item',
139 'description' => 'This menu entry will not show and the page will not be accessible without the user being an "authenticated user".',
140 'page callback' => '_menu_example_menu_page',
141 'page arguments' => array(t('This menu entry will not be visible and access will result in a 403 error unless the user has the "authenticated user" role. This is accomplished with a custom access callback.')),
142 'access callback' => 'menu_example_custom_access',
143 'access arguments' => array('authenticated user'),
144 );
145
146 // A menu router entry with no menu link. This could be used any time we
147 // don't want the user to see a link in the menu. Otherwise, it's the same
148 // as the "simplest" entry above. MENU_CALLBACK is used for all menu items
149 // which don't need a visible menu link, including services and other pages
150 // that may be linked to but are not intended to be accessed directly.
151
152 // First, provide a courtesy link in the menu so people can find this.
153 $items['examples/menu_example/path_only'] = array(
154 'title' => 'MENU_CALLBACK example',
155 'page callback' => '_menu_example_menu_page',
156 'page arguments' => array(t('A menu entry with no menu link (MENU_CALLBACK) is at <a href="!link">!link</a>', array('!link' => url('examples/menu_example/path_only/callback')))),
157 'access callback' => TRUE,
158 'weight' => 20,
159 );
160 $items['examples/menu_example/path_only/callback'] = array(
161
162 // A type of MENU_CALLBACK means leave the path completely out of the menu
163 // links.
164 'type' => MENU_CALLBACK,
165
166 // The title is still used for the page title, even though it's not used
167 // for the menu link text, since there's no menu link.
168 'title' => 'Callback Only',
169
170 'page callback' => '_menu_example_menu_page',
171 'page arguments' => array(t('The menu entry for this page is of type MENU_CALLBACK, so it provides only a path but not a link in the menu links, but it is the same in every other way to the simplest example.')),
172 'access callback' => TRUE,
173 );
174
175
176 // A menu entry with tabs.
177 // For tabs we need at least 3 things:
178 // 1. A parent MENU_NORMAL_ITEM menu item (examples/menu_example/tabs in this
179 // example.)
180 // 2. A primary tab (the one that is active when we land on the base menu).
181 // This tab is of type MENU_DEFAULT_LOCAL_TASK.
182 // 3. Some other menu entries for the other tabs, of type MENU_LOCAL_TASK.
183 $items['examples/menu_example/tabs'] = array(
184 // 'type' => MENU_NORMAL_ITEM, // Not necessary since this is the default.
185 'title' => 'Tabs',
186 'description' => 'Shows how to create primary and secondary tabs',
187 'page callback' => '_menu_example_menu_page',
188 'page arguments' => array(t('This is the "tabs" menu entry.')),
189 'access callback' => TRUE,
190 'weight' => 30,
191 );
192
193 // For the default local task, we need very little configuration, as the
194 // callback and other conditions are handled by the parent callback.
195 $items['examples/menu_example/tabs/default'] = array(
196 'type' => MENU_DEFAULT_LOCAL_TASK,
197 'title' => 'Default primary tab',
198 'weight' => 1,
199 );
200 // Now add the rest of the tab entries.
201 foreach (array(t('second') => 2, t('third') => 3, t('fourth') => 4) as $tabname => $weight) {
202 $items["examples/menu_example/tabs/$tabname"] = array(
203 'type' => MENU_LOCAL_TASK,
204 'title' => $tabname,
205 'page callback' => '_menu_example_menu_page',
206 'page arguments' => array(t('This is the tab "@tabname" in the "basic tabs" example', array('@tabname' => $tabname))),
207 'access callback' => TRUE,
208
209 // The weight property overrides the default alphabetic ordering of menu
210 // entries, allowing us to get our tabs in the order we want.
211 'weight' => $weight,
212 );
213 }
214
215 // Finally, we'll add secondary tabs to the default tab of the tabs entry.
216
217 // The default local task needs very little information.
218 $items['examples/menu_example/tabs/default/first'] = array(
219 'type' => MENU_DEFAULT_LOCAL_TASK,
220 'title' => 'Default secondary tab',
221 // The additional page callback and related items are handled by the
222 // parent menu item.
223 );
224 foreach (array(t('second'), t('third')) as $tabname) {
225 $items["examples/menu_example/tabs/default/$tabname"] = array(
226 'type' => MENU_LOCAL_TASK,
227 'title' => $tabname,
228 'page callback' => '_menu_example_menu_page',
229 'page arguments' => array(t('This is the secondary tab "@tabname" in the "basic tabs" example "default" tab', array('@tabname' => $tabname))),
230 'access callback' => TRUE,
231 );
232 }
233
234 // All the portions of the URL after the base menu are passed to the page
235 // callback as separate arguments, and can be captured by the page callback
236 // in its argument list. Our _menu_example_menu_page() function captures
237 // arguments in its function signature and can output them.
238 $items['examples/menu_example/use_url_arguments'] = array(
239 'title' => 'Extra Arguments',
240 'description' => 'The page callback can use the arguments provided after the path used as key',
241 'page callback' => '_menu_example_menu_page',
242 'page arguments' => array(t('This page demonstrates using arguments in the path (portions of the path after "menu_example/url_arguments". For example, access it with <a href="!link1">!link1</a> or <a href="!link2">!link2</a>).', array('!link1' => url('examples/menu_example/use_url_arguments/one/two'), '!link2' => url('examples/menu_example/use_url_arguments/firstarg/secondarg')))),
243 'access callback' => TRUE,
244 'weight' => 40,
245 );
246
247 // The menu title can be dynamically created by using the 'title callback'
248 // which by default is t(). Here we provide a title callback which adjusts
249 // the menu title based on the current user's username.
250 $items['examples/menu_example/title_callbacks'] = array(
251 'title callback' => '_menu_example_simple_title_callback',
252 'title arguments' => array(t('Dynamic title: username=')),
253 'description' => 'The title of this menu item is dynamically generated',
254 'page callback' => '_menu_example_menu_page',
255 'page arguments' => array(t('The menu title is dynamically changed by the title callback')),
256 'access callback' => TRUE,
257 'weight' => 50,
258 );
259
260 // Sometimes we need to capture a specific argument within the menu path,
261 // as with the menu entry 'example/menu_example/placeholder_argument/3333/display',
262 // where we need to capture the "3333". In that case, we use a placeholder in
263 // the path provided in the menu entry. The (odd) way this is done is by using
264 // array(numeric_position_value) as the value for 'page arguments'. The
265 // numeric_position_value is the zero-based index of the portion of the URL
266 // which should be passed to the 'page callback'.
267
268 // First we provide a courtesy link with information on how to access
269 // an item with a placeholder.
270 $items['examples/menu_example/placeholder_argument'] = array(
271 'title' => 'Placeholder Arguments',
272 'page callback' => '_menu_example_menu_page',
273 'page arguments' => array(t('Demonstrate placeholders by visiting <a href="!link">examples/menu_example/placeholder_argument/3343/display</a>', array('!link' => url('examples/menu_example/placeholder_argument/3343/display')))),
274 'access callback' => TRUE,
275 'weight' => 60,
276 );
277
278 // Now the actual entry.
279 $items['examples/menu_example/placeholder_argument/%/display'] = array(
280 'title' => 'Placeholder Arguments',
281 'page callback' => '_menu_example_menu_page',
282
283 // Pass the value of '%', which is zero-based argument 3, to the
284 // 'page callback'. So if the URL is
285 // 'examples/menu_example/placeholder_argument/333/display' then the value 333
286 // will be passed into the 'page callback'.
287 'page arguments' => array(3),
288 'access callback' => TRUE,
289 );
290
291 // Drupal provides magic placeholder processing as well, so if the placeholder
292 // is '%menu_example_arg_optional', the function
293 // menu_example_arg_optional_load($arg) will be called to translate the path
294 // argument to a more substantial object. $arg will be the value of the
295 // placeholder. Then the return value of menu_example_id_load($arg) will be
296 // passed to the 'page callback'.
297 // In addition, if (in this case) menu_example_arg_optional_to_arg() exists,
298 // then a menu link can be created using the results of that function as a
299 // default for %menu_example_arg_optional.
300 $items['examples/menu_example/default_arg/%menu_example_arg_optional'] = array(
301 'title' => 'Processed Placeholder Arguments',
302 'page callback' => '_menu_example_menu_page',
303 'page arguments' => array(3), // arg 3 (4rd arg) is the one we want.
304 'access callback' => TRUE,
305 'weight' => 70,
306 );
307
308 $items['examples/menu_example/menu_original_path'] = array(
309 'title' => 'Menu path that will be altered by hook_menu_alter()',
310 'page callback' => '_menu_example_menu_page',
311 'page arguments' => array(t('This menu item was created strictly to allow the hook_menu_alter() function to have something to operate on. hook_menu defined the path as examples/menu_example/menu_original_path. The hook_menu_alter() changes it to examples/menu_example/menu_altered_path. You can try navigating to both paths and see what happens!')),
312 'access callback' => TRUE,
313 'weight' => 80,
314 );
315 return $items;
316 }
317
324 function _menu_example_basic_instructions($content = NULL) {
325 $base_content = t(
326 'This is the base page of the Menu Example. There are a number of examples
327 here, from the most basic (like this one) to extravagant mappings of loaded
328 placeholder arguments. Enjoy!');
329 return '<div>' . $base_content . '</div><br /><div>' . $content . '</div>';
330 }
331
343 function _menu_example_menu_page($content = NULL, $arg1 = NULL, $arg2 = NULL) {
344 $output = '<div>' . $content . '</div>';
345
346 if (!empty($arg1)) {
347 $output .= '<div>' . t('Argument 1=%arg', array('%arg' => $arg1)) . '</div>';
348 }
349 if (!empty($arg2)) {
350 $output .= '<div>' . t('Argument 2=%arg', array('%arg' => $arg2)) . '</div>';
351 }
352 return $output;
353 }
354
359 function menu_example_permission() {
360 return array(
361 'access protected menu example' => array(
362 'title' => t('Access the protected menu example'),
363 ),
364 );
365
366 }
367
376 function menu_example_custom_access($role_name){
377 $access_granted = in_array($role_name, $GLOBALS['user']->roles);
378 return $access_granted;
379 }
380
391 function _menu_example_mappings($id) {
392 $mapped_value = NULL;
393 static $mappings = array(
394 1 => 'one',
395 2 => 'two',
396 3 => 'three',
397 99 => 'jackpot! default',
398 );
399 if (isset($mappings[$id])) {
400 $mapped_value = $mappings[$id];
401 }
402 return $mapped_value;
403 }
404
418 function menu_example_id_load($id) {
419 // Just map a magic value here. Normally this would load some more complex
420 // object from the database or other context.
421 $mapped_value = _menu_example_mappings($id);
422 if (!empty($mapped_value)) {
423 return t('Loaded value was %loaded', array('%loaded' => $mapped_value));
424 }
425 else {
426 return t('Sorry, the id %id was not found to be loaded', array('%id' => $id));
427 }
428 }
429
443 function menu_example_menu_alter(&$items) {
444 // Change the path 'examples/menu_example/menu_original_path' to 'examples/menu_example/menu_altered_path'. This change will
445 // prevent the page from appearing at the original path (since the item is being unset).
446 // You will need to go to examples/menu_example/menu_altered_path manually to see the page.
447 if (!empty($items['examples/menu_example/menu_original_path'])) {
448 $items['examples/menu_example/menu_altered_path'] = $items['examples/menu_example/menu_original_path'];
449 $items['examples/menu_example/menu_altered_path']['title'] = 'Menu item altered by hook_menu_alter()';
450 unset($items['examples/menu_example/menu_original_path']);
451 }
452
453 // Here we will change the title callback to our own function, changing the
454 // 'user' link from the traditional to always being "username's account".
455 if (!empty($items['user/%user'])) {
456 $items['user/%user']['title callback'] = 'menu_example_user_page_title';
457 }
458 }
459
466 function _menu_example_simple_title_callback($base_string) {
467 global $user;
468 $username = !empty($user->name) ? $user->name : t('anonymous');
469 return $base_string . ' ' . $username;
470 }
477 function menu_example_user_page_title($account) {
478 return is_object($account) ? t("@name's account", array('@name' => format_username($account))) : '';
479 }
480
493 function menu_example_menu_link_alter(&$item, $menu) {
494 // Force the link title to remain 'Clear Cache' no matter what the admin
495 // does with the web interface.
496 if ($item['link_path'] == 'devel/cache/clear') {
497 $item['link_title'] = 'Clear Cache';
498 };
499 }
500
509 function menu_example_arg_optional_load($id) {
510 $mapped_value = _menu_example_mappings($id);
511 if (!empty($mapped_value)) {
512 return t('Loaded value was %loaded', array('%loaded' => $mapped_value));
513 }
514 else {
515 return t('Sorry, the id %id was not found to be loaded', array('%id' => $id));
516 }
517 }
518
533 function menu_example_arg_optional_to_arg($arg) {
534 // If our argument is not provided, give a default of 99.
535 return (empty($arg) || $arg == '%') ? 99 : $arg;
536 }
menu_example_permission
menu_example_permission()
Definition: menu_example.module:359
_menu_example_basic_instructions
_menu_example_basic_instructions($content=NULL)
Definition: menu_example.module:324
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
format_username
format_username($account)
Definition: common.inc:2106
menu_example_arg_optional_to_arg
menu_example_arg_optional_to_arg($arg)
Definition: menu_example.module:533
menu_example_custom_access
menu_example_custom_access($role_name)
Definition: menu_example.module:376
menu_example_menu
menu_example_menu()
Definition: menu_example.module:27
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
menu_example_menu_link_alter
menu_example_menu_link_alter(&$item, $menu)
Definition: menu_example.module:493
_menu_example_mappings
_menu_example_mappings($id)
Definition: menu_example.module:391
menu_example_arg_optional_load
menu_example_arg_optional_load($id)
Definition: menu_example.module:509
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
$output
$output
Definition: authorize.php:93
menu_example_id_load
menu_example_id_load($id)
Definition: menu_example.module:418
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
menu_example_user_page_title
menu_example_user_page_title($account)
Definition: menu_example.module:477
_menu_example_menu_page
_menu_example_menu_page($content=NULL, $arg1=NULL, $arg2=NULL)
Definition: menu_example.module:343
menu_example_menu_alter
menu_example_menu_alter(&$items)
Definition: menu_example.module:443
_menu_example_simple_title_callback
_menu_example_simple_title_callback($base_string)
Definition: menu_example.module:466
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/minimal/minimal.install Source File

  • profiles
  • minimal
minimal.install
Go to the documentation of this file.
1 <?php
14 function minimal_install() {
15 // Enable some standard blocks.
16 $default_theme = variable_get('theme_default', 'bartik');
17 $values = array(
18 array(
19 'module' => 'system',
20 'delta' => 'main',
21 'theme' => $default_theme,
22 'status' => 1,
23 'weight' => 0,
24 'region' => 'content',
25 'pages' => '',
26 'cache' => -1,
27 ),
28 array(
29 'module' => 'user',
30 'delta' => 'login',
31 'theme' => $default_theme,
32 'status' => 1,
33 'weight' => 0,
34 'region' => 'sidebar_first',
35 'pages' => '',
36 'cache' => -1,
37 ),
38 array(
39 'module' => 'system',
40 'delta' => 'navigation',
41 'theme' => $default_theme,
42 'status' => 1,
43 'weight' => 0,
44 'region' => 'sidebar_first',
45 'pages' => '',
46 'cache' => -1,
47 ),
48 array(
49 'module' => 'system',
50 'delta' => 'management',
51 'theme' => $default_theme,
52 'status' => 1,
53 'weight' => 1,
54 'region' => 'sidebar_first',
55 'pages' => '',
56 'cache' => -1,
57 ),
58 array(
59 'module' => 'system',
60 'delta' => 'help',
61 'theme' => $default_theme,
62 'status' => 1,
63 'weight' => 0,
64 'region' => 'help',
65 'pages' => '',
66 'cache' => -1,
67 ),
68 );
69 $query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
70 foreach ($values as $record) {
71 $query->values($record);
72 }
73 $query->execute();
74
75 // Allow visitor account creation, but with administrative approval.
76 variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
77
78 // Enable default permissions for system roles.
79 user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content'));
80 user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content'));
81 }
user_role_grant_permissions
user_role_grant_permissions($rid, array $permissions=array())
Definition: user.module:3100
DRUPAL_ANONYMOUS_RID
const DRUPAL_ANONYMOUS_RID
Definition: bootstrap.inc:162
DRUPAL_AUTHENTICATED_RID
const DRUPAL_AUTHENTICATED_RID
Definition: bootstrap.inc:167
minimal_install
minimal_install()
Definition: minimal.install:14
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL
const USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL
Definition: user.module:32
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/pgsql/query.inc Source File

  • includes
  • database
  • pgsql
query.inc
Go to the documentation of this file.
1 <?php
2
14 class InsertQuery_pgsql extends InsertQuery {
15
16 public function execute() {
17 if (!$this->preExecute()) {
18 return NULL;
19 }
20
21 $stmt = $this->connection->prepareQuery((string) $this);
22
23 // Fetch the list of blobs and sequences used on that table.
24 $table_information = $this->connection->schema()->queryTableInformation($this->table);
25
26 $max_placeholder = 0;
27 $blobs = array();
28 $blob_count = 0;
29 foreach ($this->insertValues as $insert_values) {
30 foreach ($this->insertFields as $idx => $field) {
31 if (isset($table_information->blob_fields[$field])) {
32 $blobs[$blob_count] = fopen('php://memory', 'a');
33 fwrite($blobs[$blob_count], $insert_values[$idx]);
34 rewind($blobs[$blob_count]);
35
36 $stmt->bindParam(':db_insert_placeholder_' . $max_placeholder++, $blobs[$blob_count], PDO::PARAM_LOB);
37
38 // Pre-increment is faster in PHP than increment.
39 ++$blob_count;
40 }
41 else {
42 $stmt->bindParam(':db_insert_placeholder_' . $max_placeholder++, $insert_values[$idx]);
43 }
44 }
45 // Check if values for a serial field has been passed.
46 if (!empty($table_information->serial_fields)) {
47 foreach ($table_information->serial_fields as $index => $serial_field) {
48 $serial_key = array_search($serial_field, $this->insertFields);
49 if ($serial_key !== FALSE) {
50 $serial_value = $insert_values[$serial_key];
51
52 // Force $last_insert_id to the specified value. This is only done
53 // if $index is 0.
54 if ($index == 0) {
55 $last_insert_id = $serial_value;
56 }
57 // Set the sequence to the bigger value of either the passed
58 // value or the max value of the column. It can happen that another
59 // thread calls nextval() which could lead to a serial number being
60 // used twice. However, trying to insert a value into a serial
61 // column should only be done in very rare cases and is not thread
62 // safe by definition.
63 $this->connection->query("SELECT setval('" . $table_information->sequences[$index] . "', GREATEST(MAX(" . $serial_field . "), :serial_value)) FROM {" . $this->table . "}", array(':serial_value' => (int)$serial_value));
64 }
65 }
66 }
67 }
68 if (!empty($this->fromQuery)) {
69 // bindParam stores only a reference to the variable that is followed when
70 // the statement is executed. We pass $arguments[$key] instead of $value
71 // because the second argument to bindParam is passed by reference and
72 // the foreach statement assigns the element to the existing reference.
73 $arguments = $this->fromQuery->getArguments();
74 foreach ($arguments as $key => $value) {
75 $stmt->bindParam($key, $arguments[$key]);
76 }
77 }
78
79 // PostgreSQL requires the table name to be specified explicitly
80 // when requesting the last insert ID, so we pass that in via
81 // the options array.
82 $options = $this->queryOptions;
83
84 if (!empty($table_information->sequences)) {
85 $options['sequence_name'] = $table_information->sequences[0];
86 }
87 // If there are no sequences then we can't get a last insert id.
88 elseif ($options['return'] == Database::RETURN_INSERT_ID) {
89 $options['return'] = Database::RETURN_NULL;
90 }
91 // Only use the returned last_insert_id if it is not already set.
92 if (!empty($last_insert_id)) {
93 $this->connection->query($stmt, array(), $options);
94 }
95 else {
96 $last_insert_id = $this->connection->query($stmt, array(), $options);
97 }
98
99 // Re-initialize the values array so that we can re-use this query.
100 $this->insertValues = array();
101
102 return $last_insert_id;
103 }
104
105 public function __toString() {
106 // Create a sanitized comment string to prepend to the query.
107 $comments = $this->connection->makeComment($this->comments);
108
109 // Default fields are always placed first for consistency.
110 $insert_fields = array_merge($this->defaultFields, $this->insertFields);
111
112 // If we're selecting from a SelectQuery, finish building the query and
113 // pass it back, as any remaining options are irrelevant.
114 if (!empty($this->fromQuery)) {
115 $insert_fields_string = $insert_fields ? ' (' . implode(', ', $insert_fields) . ') ' : ' ';
116 return $comments . 'INSERT INTO {' . $this->table . '}' . $insert_fields_string . $this->fromQuery;
117 }
118
119 $query = $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES ';
120
121 $max_placeholder = 0;
122 $values = array();
123 if (count($this->insertValues)) {
124 foreach ($this->insertValues as $insert_values) {
125 $placeholders = array();
126
127 // Default fields aren't really placeholders, but this is the most convenient
128 // way to handle them.
129 $placeholders = array_pad($placeholders, count($this->defaultFields), 'default');
130
131 $new_placeholder = $max_placeholder + count($insert_values);
132 for ($i = $max_placeholder; $i < $new_placeholder; ++$i) {
133 $placeholders[] = ':db_insert_placeholder_' . $i;
134 }
135 $max_placeholder = $new_placeholder;
136 $values[] = '(' . implode(', ', $placeholders) . ')';
137 }
138 }
139 else {
140 // If there are no values, then this is a default-only query. We still need to handle that.
141 $placeholders = array_fill(0, count($this->defaultFields), 'default');
142 $values[] = '(' . implode(', ', $placeholders) . ')';
143 }
144
145 $query .= implode(', ', $values);
146
147 return $query;
148 }
149 }
150
151 class UpdateQuery_pgsql extends UpdateQuery {
152 public function execute() {
153 $max_placeholder = 0;
154 $blobs = array();
155 $blob_count = 0;
156
157 // Because we filter $fields the same way here and in __toString(), the
158 // placeholders will all match up properly.
159 $stmt = $this->connection->prepareQuery((string) $this);
160
161 // Fetch the list of blobs and sequences used on that table.
162 $table_information = $this->connection->schema()->queryTableInformation($this->table);
163
164 // Expressions take priority over literal fields, so we process those first
165 // and remove any literal fields that conflict.
166 $fields = $this->fields;
167 $expression_fields = array();
168 foreach ($this->expressionFields as $field => $data) {
169 if (!empty($data['arguments'])) {
170 foreach ($data['arguments'] as $placeholder => $argument) {
171 // We assume that an expression will never happen on a BLOB field,
172 // which is a fairly safe assumption to make since in most cases
173 // it would be an invalid query anyway.
174 $stmt->bindParam($placeholder, $data['arguments'][$placeholder]);
175 }
176 }
177 unset($fields[$field]);
178 }
179
180 foreach ($fields as $field => $value) {
181 $placeholder = ':db_update_placeholder_' . ($max_placeholder++);
182
183 if (isset($table_information->blob_fields[$field])) {
184 $blobs[$blob_count] = fopen('php://memory', 'a');
185 fwrite($blobs[$blob_count], $value);
186 rewind($blobs[$blob_count]);
187 $stmt->bindParam($placeholder, $blobs[$blob_count], PDO::PARAM_LOB);
188 ++$blob_count;
189 }
190 else {
191 $stmt->bindParam($placeholder, $fields[$field]);
192 }
193 }
194
195 if (count($this->condition)) {
196 $this->condition->compile($this->connection, $this);
197
198 $arguments = $this->condition->arguments();
199 foreach ($arguments as $placeholder => $value) {
200 $stmt->bindParam($placeholder, $arguments[$placeholder]);
201 }
202 }
203
204 $options = $this->queryOptions;
205 $options['already_prepared'] = TRUE;
206 $this->connection->query($stmt, $options);
207
208 return $stmt->rowCount();
209 }
210 }
InsertQuery\$fromQuery
$fromQuery
Definition: query.inc:486
InsertQuery_pgsql\__toString
__toString()
Definition: query.inc:105
UpdateQuery\$fields
$fields
Definition: query.inc:977
InsertQuery_pgsql\execute
execute()
Definition: query.inc:16
Query\$queryOptions
$queryOptions
Definition: query.inc:303
InsertQuery\preExecute
preExecute()
Definition: query.inc:698
UpdateQuery\condition
condition($field, $value=NULL, $operator=NULL)
Definition: query.inc:1031
UpdateQuery\$arguments
$arguments
Definition: query.inc:984
UpdateQuery_pgsql\execute
execute()
Definition: query.inc:152
Query\$comments
$comments
Definition: query.inc:320
Database\RETURN_INSERT_ID
const RETURN_INSERT_ID
Definition: database.inc:1345
UpdateQuery_pgsql
Definition: query.inc:151
InsertQuery
Definition: query.inc:441
$value
print $value
Definition: user-profile-item.tpl.php:26
UpdateQuery
Definition: query.inc:963
Database\RETURN_NULL
const RETURN_NULL
Definition: database.inc:1330
InsertQuery_pgsql
Definition: query.inc:14
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field_ui/field_ui.admin.inc Source File

  • modules
  • field_ui
field_ui.admin.inc
Go to the documentation of this file.
1 <?php
2
11 function field_ui_fields_list() {
12 $instances = field_info_instances();
13 $field_types = field_info_field_types();
14 $bundles = field_info_bundles();
15
16 $modules = system_rebuild_module_data();
17
18 $header = array(t('Field name'), t('Field type'), t('Used in'));
19 $rows = array();
20 foreach ($instances as $entity_type => $type_bundles) {
21 foreach ($type_bundles as $bundle => $bundle_instances) {
22 foreach ($bundle_instances as $field_name => $instance) {
23 $field = field_info_field($field_name);
24
25 // Initialize the row if we encounter the field for the first time.
26 if (!isset($rows[$field_name])) {
27 $rows[$field_name]['class'] = $field['locked'] ? array('menu-disabled') : array('');
28 $rows[$field_name]['data'][0] = $field['locked'] ? t('@field_name (Locked)', array('@field_name' => $field_name)) : $field_name;
29 $module_name = $field_types[$field['type']]['module'];
30 $rows[$field_name]['data'][1] = $field_types[$field['type']]['label'] . ' ' . t('(module: !module)', array('!module' => $modules[$module_name]->info['name']));
31 }
32
33 // Add the current instance.
34 $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
35 $rows[$field_name]['data'][2][] = $admin_path ? l($bundles[$entity_type][$bundle]['label'], $admin_path . '/fields') : $bundles[$entity_type][$bundle]['label'];
36 }
37 }
38 }
39 foreach ($rows as $field_name => $cell) {
40 $rows[$field_name]['data'][2] = implode(', ', $cell['data'][2]);
41 }
42 if (empty($rows)) {
43 $output = t('No fields have been defined yet.');
44 }
45 else {
46 // Sort rows by field name.
47 ksort($rows);
48 $output = theme('table', array('header' => $header, 'rows' => $rows));
49 }
50 return $output;
51 }
52
56 function field_ui_inactive_message($entity_type, $bundle) {
57 $inactive_instances = field_ui_inactive_instances($entity_type, $bundle);
58 if (!empty($inactive_instances)) {
59 $field_types = field_info_field_types();
60 $widget_types = field_info_widget_types();
61
62 foreach ($inactive_instances as $field_name => $instance) {
63 $list[] = t('%field (@field_name) field requires the %widget_type widget provided by %widget_module module', array(
64 '%field' => $instance['label'],
65 '@field_name' => $instance['field_name'],
66 '%widget_type' => isset($widget_types[$instance['widget']['type']]) ? $widget_types[$instance['widget']['type']]['label'] : $instance['widget']['type'],
67 '%widget_module' => $instance['widget']['module'],
68 ));
69 }
70 drupal_set_message(t('Inactive fields are not shown unless their providing modules are enabled. The following fields are not enabled: !list', array('!list' => theme('item_list', array('items' => $list)))), 'error');
71 }
72 }
73
79 function _field_ui_reduce_order($array, $a) {
80 $array = !isset($array) ? array() : $array;
81 if ($a['name']) {
82 $array[] = $a['name'];
83 }
84 if (!empty($a['children'])) {
85 uasort($a['children'], 'drupal_sort_weight');
86 $array = array_merge($array, array_reduce($a['children'], '_field_ui_reduce_order'));
87 }
88 return $array;
89 }
90
98 function field_ui_field_overview_row_region($row) {
99 switch ($row['#row_type']) {
100 case 'field':
101 case 'extra_field':
102 return 'main';
103 case 'add_new_field':
104 // If no input in 'label', assume the row has not been dragged out of the
105 // 'add new' section.
106 return (!empty($row['label']['#value']) ? 'main' : 'add_new');
107 }
108 }
109
117 function field_ui_display_overview_row_region($row) {
118 switch ($row['#row_type']) {
119 case 'field':
120 case 'extra_field':
121 return ($row['format']['type']['#value'] == 'hidden' ? 'hidden' : 'visible');
122 }
123 }
124
128 function field_ui_table_pre_render($elements) {
129 $js_settings = array();
130
131 // For each region, build the tree structure from the weight and parenting
132 // data contained in the flat form structure, to determine row order and
133 // indentation.
134 $regions = $elements['#regions'];
135 $tree = array('' => array('name' => '', 'children' => array()));
136 $trees = array_fill_keys(array_keys($regions), $tree);
137
138 $parents = array();
139 $list = drupal_map_assoc(element_children($elements));
140
141 // Iterate on rows until we can build a known tree path for all of them.
142 while ($list) {
143 foreach ($list as $name) {
144 $row = &$elements[$name];
145 $parent = $row['parent_wrapper']['parent']['#value'];
146 // Proceed if parent is known.
147 if (empty($parent) || isset($parents[$parent])) {
148 // Grab parent, and remove the row from the next iteration.
149 $parents[$name] = $parent ? array_merge($parents[$parent], array($parent)) : array();
150 unset($list[$name]);
151
152 // Determine the region for the row.
153 $function = $row['#region_callback'];
154 $region_name = $function($row);
155
156 // Add the element in the tree.
157 $target = &$trees[$region_name][''];
158 foreach ($parents[$name] as $key) {
159 $target = &$target['children'][$key];
160 }
161 $target['children'][$name] = array('name' => $name, 'weight' => $row['weight']['#value']);
162
163 // Add tabledrag indentation to the first row cell.
164 if ($depth = count($parents[$name])) {
165 $children = element_children($row);
166 $cell = current($children);
167 $row[$cell]['#prefix'] = theme('indentation', array('size' => $depth)) . (isset($row[$cell]['#prefix']) ? $row[$cell]['#prefix'] : '');
168 }
169
170 // Add row id and associate JS settings.
171 $id = drupal_html_class($name);
172 $row['#attributes']['id'] = $id;
173 if (isset($row['#js_settings'])) {
174 $row['#js_settings'] += array(
175 'rowHandler' => $row['#row_type'],
176 'name' => $name,
177 'region' => $region_name,
178 );
179 $js_settings[$id] = $row['#js_settings'];
180 }
181 }
182 }
183 }
184 // Determine rendering order from the tree structure.
185 foreach ($regions as $region_name => $region) {
186 $elements['#regions'][$region_name]['rows_order'] = array_reduce($trees[$region_name], '_field_ui_reduce_order');
187 }
188
189 $elements['#attached']['js'][] = array(
190 'type' => 'setting',
191 'data' => array('fieldUIRowsData' => $js_settings),
192 );
193
194 return $elements;
195 }
196
207 function theme_field_ui_table($variables) {
208 $elements = $variables['elements'];
209 $table = array();
210 $js_settings = array();
211
212 // Add table headers and attributes.
213 foreach (array('header', 'attributes') as $key) {
214 if (isset($elements["#$key"])) {
215 $table[$key] = $elements["#$key"];
216 }
217 }
218
219 // Determine the colspan to use for region rows, by checking the number of
220 // columns in the headers.
221 $columns_count = 0;
222 foreach ($table['header'] as $header) {
223 $columns_count += (is_array($header) && isset($header['colspan']) ? $header['colspan'] : 1);
224 }
225
226 // Render rows, region by region.
227 foreach ($elements['#regions'] as $region_name => $region) {
228 $region_name_class = drupal_html_class($region_name);
229
230 // Add region rows.
231 if (isset($region['title'])) {
232 $table['rows'][] = array(
233 'class' => array('region-title', 'region-' . $region_name_class . '-title'),
234 'no_striping' => TRUE,
235 'data' => array(
236 array('data' => $region['title'], 'colspan' => $columns_count),
237 ),
238 );
239 }
240 if (isset($region['message'])) {
241 $class = (empty($region['rows_order']) ? 'region-empty' : 'region-populated');
242 $table['rows'][] = array(
243 'class' => array('region-message', 'region-' . $region_name_class . '-message', $class),
244 'no_striping' => TRUE,
245 'data' => array(
246 array('data' => $region['message'], 'colspan' => $columns_count),
247 ),
248 );
249 }
250
251 // Add form rows, in the order determined at pre-render time.
252 foreach ($region['rows_order'] as $name) {
253 $element = $elements[$name];
254
255 $row = array('data' => array());
256 if (isset($element['#attributes'])) {
257 $row += $element['#attributes'];
258 }
259
260 // Render children as table cells.
261 foreach (element_children($element) as $cell_key) {
262 $child = &$element[$cell_key];
263 // Do not render a cell for children of #type 'value'.
264 if (!(isset($child['#type']) && $child['#type'] == 'value')) {
265 $cell = array('data' => drupal_render($child));
266 if (isset($child['#cell_attributes'])) {
267 $cell += $child['#cell_attributes'];
268 }
269 $row['data'][] = $cell;
270 }
271 }
272 $table['rows'][] = $row;
273 }
274 }
275
276 return theme('table', $table);
277 }
278
288 function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle) {
289 $bundle = field_extract_bundle($entity_type, $bundle);
290
291 field_ui_inactive_message($entity_type, $bundle);
292 $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
293
294 // When displaying the form, make sure the list of fields is up-to-date.
295 if (empty($form_state['post'])) {
296 field_info_cache_clear();
297 }
298
299 // Gather bundle information.
300 $instances = field_info_instances($entity_type, $bundle);
301 $field_types = field_info_field_types();
302 $widget_types = field_info_widget_types();
303
304 $extra_fields = field_info_extra_fields($entity_type, $bundle, 'form');
305
306 $form += array(
307 '#entity_type' => $entity_type,
308 '#bundle' => $bundle,
309 '#fields' => array_keys($instances),
310 '#extra' => array_keys($extra_fields),
311 );
312
313 $table = array(
314 '#type' => 'field_ui_table',
315 '#tree' => TRUE,
316 '#header' => array(
317 t('Label'),
318 t('Weight'),
319 t('Parent'),
320 t('Machine name'),
321 t('Field type'),
322 t('Widget'),
323 array('data' => t('Operations'), 'colspan' => 2),
324 ),
325 '#parent_options' => array(),
326 '#regions' => array(
327 'main' => array('message' => t('No fields are present yet.')),
328 'add_new' => array('title' => '&nbsp;'),
329 ),
330 '#attributes' => array(
331 'class' => array('field-ui-overview'),
332 'id' => 'field-overview',
333 ),
334 );
335
336 // Fields.
337 foreach ($instances as $name => $instance) {
338 $field = field_info_field($instance['field_name']);
339 $admin_field_path = $admin_path . '/fields/' . $instance['field_name'];
340 $table[$name] = array(
341 '#attributes' => array('class' => array('draggable', 'tabledrag-leaf')),
342 '#row_type' => 'field',
343 '#region_callback' => 'field_ui_field_overview_row_region',
344 'label' => array(
345 '#markup' => check_plain($instance['label']),
346 ),
347 'weight' => array(
348 '#type' => 'textfield',
349 '#title' => t('Weight for @title', array('@title' => $instance['label'])),
350 '#title_display' => 'invisible',
351 '#default_value' => $instance['widget']['weight'],
352 '#size' => 3,
353 '#attributes' => array('class' => array('field-weight')),
354 ),
355 'parent_wrapper' => array(
356 'parent' => array(
357 '#type' => 'select',
358 '#title' => t('Parent for @title', array('@title' => $instance['label'])),
359 '#title_display' => 'invisible',
360 '#options' => $table['#parent_options'],
361 '#empty_value' => '',
362 '#attributes' => array('class' => array('field-parent')),
363 '#parents' => array('fields', $name, 'parent'),
364 ),
365 'hidden_name' => array(
366 '#type' => 'hidden',
367 '#default_value' => $name,
368 '#attributes' => array('class' => array('field-name')),
369 ),
370 ),
371 'field_name' => array(
372 '#markup' => $instance['field_name'],
373 ),
374 'type' => array(
375 '#type' => 'link',
376 '#title' => t($field_types[$field['type']]['label']),
377 '#href' => $admin_field_path . '/field-settings',
378 '#options' => array('attributes' => array('title' => t('Edit field settings.'))),
379 ),
380 'widget_type' => array(
381 '#type' => 'link',
382 '#title' => t($widget_types[$instance['widget']['type']]['label']),
383 '#href' => $admin_field_path . '/widget-type',
384 '#options' => array('attributes' => array('title' => t('Change widget type.'))),
385 ),
386 'edit' => array(
387 '#type' => 'link',
388 '#title' => t('edit'),
389 '#href' => $admin_field_path,
390 '#options' => array('attributes' => array('title' => t('Edit instance settings.'))),
391 ),
392 'delete' => array(
393 '#type' => 'link',
394 '#title' => t('delete'),
395 '#href' => $admin_field_path . '/delete',
396 '#options' => array('attributes' => array('title' => t('Delete instance.'))),
397 ),
398 );
399
400 if (!empty($instance['locked'])) {
401 $table[$name]['edit'] = array('#value' => t('Locked'));
402 $table[$name]['delete'] = array();
403 $table[$name]['#attributes']['class'][] = 'menu-disabled';
404 }
405 }
406
407 // Non-field elements.
408 foreach ($extra_fields as $name => $extra_field) {
409 $table[$name] = array(
410 '#attributes' => array('class' => array('draggable', 'tabledrag-leaf')),
411 '#row_type' => 'extra_field',
412 '#region_callback' => 'field_ui_field_overview_row_region',
413 'label' => array(
414 '#markup' => check_plain($extra_field['label']),
415 ),
416 'weight' => array(
417 '#type' => 'textfield',
418 '#default_value' => $extra_field['weight'],
419 '#size' => 3,
420 '#attributes' => array('class' => array('field-weight')),
421 '#title_display' => 'invisible',
422 '#title' => t('Weight for @title', array('@title' => $extra_field['label'])),
423 ),
424 'parent_wrapper' => array(
425 'parent' => array(
426 '#type' => 'select',
427 '#title' => t('Parent for @title', array('@title' => $extra_field['label'])),
428 '#title_display' => 'invisible',
429 '#options' => $table['#parent_options'],
430 '#empty_value' => '',
431 '#attributes' => array('class' => array('field-parent')),
432 '#parents' => array('fields', $name, 'parent'),
433 ),
434 'hidden_name' => array(
435 '#type' => 'hidden',
436 '#default_value' => $name,
437 '#attributes' => array('class' => array('field-name')),
438 ),
439 ),
440 'field_name' => array(
441 '#markup' => $name,
442 ),
443 'type' => array(
444 '#markup' => isset($extra_field['description']) ? $extra_field['description'] : '',
445 '#cell_attributes' => array('colspan' => 2),
446 ),
447 'edit' => array(
448 '#markup' => isset($extra_field['edit']) ? $extra_field['edit'] : '',
449 ),
450 'delete' => array(
451 '#markup' => isset($extra_field['delete']) ? $extra_field['delete'] : '',
452 ),
453 );
454 }
455
456 // Additional row: add new field.
457 $max_weight = field_info_max_weight($entity_type, $bundle, 'form');
458 $field_type_options = field_ui_field_type_options();
459 $widget_type_options = field_ui_widget_type_options(NULL, TRUE);
460 if ($field_type_options && $widget_type_options) {
461 $name = '_add_new_field';
462 $table[$name] = array(
463 '#attributes' => array('class' => array('draggable', 'tabledrag-leaf', 'add-new')),
464 '#row_type' => 'add_new_field',
465 '#region_callback' => 'field_ui_field_overview_row_region',
466 'label' => array(
467 '#type' => 'textfield',
468 '#title' => t('New field label'),
469 '#title_display' => 'invisible',
470 '#size' => 15,
471 '#description' => t('Label'),
472 '#prefix' => '<div class="label-input"><div class="add-new-placeholder">' . t('Add new field') .'</div>',
473 '#suffix' => '</div>',
474 ),
475 'weight' => array(
476 '#type' => 'textfield',
477 '#default_value' => $max_weight + 1,
478 '#size' => 3,
479 '#title_display' => 'invisible',
480 '#title' => t('Weight for new field'),
481 '#attributes' => array('class' => array('field-weight')),
482 '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
483 ),
484 'parent_wrapper' => array(
485 'parent' => array(
486 '#type' => 'select',
487 '#title' => t('Parent for new field'),
488 '#title_display' => 'invisible',
489 '#options' => $table['#parent_options'],
490 '#empty_value' => '',
491 '#attributes' => array('class' => array('field-parent')),
492 '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
493 '#parents' => array('fields', $name, 'parent'),
494 ),
495 'hidden_name' => array(
496 '#type' => 'hidden',
497 '#default_value' => $name,
498 '#attributes' => array('class' => array('field-name')),
499 ),
500 ),
501 'field_name' => array(
502 '#type' => 'machine_name',
503 '#title' => t('New field name'),
504 '#title_display' => 'invisible',
505 // This field should stay LTR even for RTL languages.
506 '#field_prefix' => '<span dir="ltr">field_',
507 '#field_suffix' => '</span>&lrm;',
508 '#size' => 15,
509 '#description' => t('A unique machine-readable name containing letters, numbers, and underscores.'),
510 // 32 characters minus the 'field_' prefix.
511 '#maxlength' => 26,
512 '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
513 '#machine_name' => array(
514 'source' => array('fields', $name, 'label'),
515 'exists' => '_field_ui_field_name_exists',
516 'standalone' => TRUE,
517 'label' => '',
518 ),
519 '#required' => FALSE,
520 ),
521 'type' => array(
522 '#type' => 'select',
523 '#title' => t('Type of new field'),
524 '#title_display' => 'invisible',
525 '#options' => $field_type_options,
526 '#empty_option' => t('- Select a field type -'),
527 '#description' => t('Type of data to store.'),
528 '#attributes' => array('class' => array('field-type-select')),
529 '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
530 ),
531 'widget_type' => array(
532 '#type' => 'select',
533 '#title' => t('Widget for new field'),
534 '#title_display' => 'invisible',
535 '#options' => $widget_type_options,
536 '#empty_option' => t('- Select a widget -'),
537 '#description' => t('Form element to edit the data.'),
538 '#attributes' => array('class' => array('widget-type-select')),
539 '#cell_attributes' => array('colspan' => 3),
540 '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
541 ),
542 // Place the 'translatable' property as an explicit value so that contrib
543 // modules can form_alter() the value for newly created fields.
544 'translatable' => array(
545 '#type' => 'value',
546 '#value' => FALSE,
547 ),
548 );
549 }
550
551 // Additional row: add existing field.
552 $existing_fields = field_ui_existing_field_options($entity_type, $bundle);
553 if ($existing_fields && $widget_type_options) {
554 // Build list of options.
555 $existing_field_options = array();
556 foreach ($existing_fields as $field_name => $info) {
557 $text = t('@type: @field (@label)', array(
558 '@type' => $info['type_label'],
559 '@label' => $info['label'],
560 '@field' => $info['field'],
561 ));
562 $existing_field_options[$field_name] = truncate_utf8($text, 80, FALSE, TRUE);
563 }
564 asort($existing_field_options);
565 $name = '_add_existing_field';
566 $table[$name] = array(
567 '#attributes' => array('class' => array('draggable', 'tabledrag-leaf', 'add-new')),
568 '#row_type' => 'add_new_field',
569 '#region_callback' => 'field_ui_field_overview_row_region',
570 'label' => array(
571 '#type' => 'textfield',
572 '#title' => t('Existing field label'),
573 '#title_display' => 'invisible',
574 '#size' => 15,
575 '#description' => t('Label'),
576 '#attributes' => array('class' => array('label-textfield')),
577 '#prefix' => '<div class="label-input"><div class="add-new-placeholder">' . t('Add existing field') .'</div>',
578 '#suffix' => '</div>',
579 ),
580 'weight' => array(
581 '#type' => 'textfield',
582 '#default_value' => $max_weight + 2,
583 '#size' => 3,
584 '#title_display' => 'invisible',
585 '#title' => t('Weight for added field'),
586 '#attributes' => array('class' => array('field-weight')),
587 '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
588 ),
589 'parent_wrapper' => array(
590 'parent' => array(
591 '#type' => 'select',
592 '#title' => t('Parent for existing field'),
593 '#title_display' => 'invisible',
594 '#options' => $table['#parent_options'],
595 '#empty_value' => '',
596 '#attributes' => array('class' => array('field-parent')),
597 '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
598 '#parents' => array('fields', $name, 'parent'),
599 ),
600 'hidden_name' => array(
601 '#type' => 'hidden',
602 '#default_value' => $name,
603 '#attributes' => array('class' => array('field-name')),
604 ),
605 ),
606 'field_name' => array(
607 '#type' => 'select',
608 '#title' => t('Existing field to share'),
609 '#title_display' => 'invisible',
610 '#options' => $existing_field_options,
611 '#empty_option' => t('- Select an existing field -'),
612 '#description' => t('Field to share'),
613 '#attributes' => array('class' => array('field-select')),
614 '#cell_attributes' => array('colspan' => 2),
615 '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
616 ),
617 'widget_type' => array(
618 '#type' => 'select',
619 '#title' => t('Widget for existing field'),
620 '#title_display' => 'invisible',
621 '#options' => $widget_type_options,
622 '#empty_option' => t('- Select a widget -'),
623 '#description' => t('Form element to edit the data.'),
624 '#attributes' => array('class' => array('widget-type-select')),
625 '#cell_attributes' => array('colspan' => 3),
626 '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
627 ),
628 );
629 }
630 $form['fields'] = $table;
631
632 $form['actions'] = array('#type' => 'actions');
633 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
634
635 $form['#attached']['css'][] = drupal_get_path('module', 'field_ui') . '/field_ui.css';
636 $form['#attached']['js'][] = drupal_get_path('module', 'field_ui') . '/field_ui.js';
637
638 // Add settings for the update selects behavior.
639 $js_fields = array();
640 foreach ($existing_fields as $field_name => $info) {
641 $js_fields[$field_name] = array('label' => $info['label'], 'type' => $info['type'], 'widget' => $info['widget_type']);
642 }
643
644 $form['#attached']['js'][] = array(
645 'type' => 'setting',
646 'data' => array('fields' => $js_fields, 'fieldWidgetTypes' => field_ui_widget_type_options()),
647 );
648
649 // Add tabledrag behavior.
650 $form['#attached']['drupal_add_tabledrag'][] = array('field-overview', 'order', 'sibling', 'field-weight');
651 $form['#attached']['drupal_add_tabledrag'][] = array('field-overview', 'match', 'parent', 'field-parent', 'field-parent', 'field-name');
652
653 return $form;
654 }
655
661 function field_ui_field_overview_form_validate($form, &$form_state) {
662 _field_ui_field_overview_form_validate_add_new($form, $form_state);
663 _field_ui_field_overview_form_validate_add_existing($form, $form_state);
664 }
665
671 function _field_ui_field_overview_form_validate_add_new($form, &$form_state) {
672 $field = $form_state['values']['fields']['_add_new_field'];
673
674 // Validate if any information was provided in the 'add new field' row.
675 if (array_filter(array($field['label'], $field['field_name'], $field['type'], $field['widget_type']))) {
676 // Missing label.
677 if (!$field['label']) {
678 form_set_error('fields][_add_new_field][label', t('Add new field: you need to provide a label.'));
679 }
680
681 // Missing field name.
682 if (!$field['field_name']) {
683 form_set_error('fields][_add_new_field][field_name', t('Add new field: you need to provide a field name.'));
684 }
685 // Field name validation.
686 else {
687 $field_name = $field['field_name'];
688
689 // Add the 'field_' prefix.
690 $field_name = 'field_' . $field_name;
691 form_set_value($form['fields']['_add_new_field']['field_name'], $field_name, $form_state);
692 }
693
694 // Missing field type.
695 if (!$field['type']) {
696 form_set_error('fields][_add_new_field][type', t('Add new field: you need to select a field type.'));
697 }
698
699 // Missing widget type.
700 if (!$field['widget_type']) {
701 form_set_error('fields][_add_new_field][widget_type', t('Add new field: you need to select a widget.'));
702 }
703 // Wrong widget type.
704 elseif ($field['type']) {
705 $widget_types = field_ui_widget_type_options($field['type']);
706 if (!isset($widget_types[$field['widget_type']])) {
707 form_set_error('fields][_add_new_field][widget_type', t('Add new field: invalid widget.'));
708 }
709 }
710 }
711 }
712
722 function _field_ui_field_name_exists($value) {
723 // Prefix with 'field_'.
724 $field_name = 'field_' . $value;
725
726 // We need to check inactive fields as well, so we can't use
727 // field_info_fields().
728 return (bool) field_read_fields(array('field_name' => $field_name), array('include_inactive' => TRUE));
729 }
730
736 function _field_ui_field_overview_form_validate_add_existing($form, &$form_state) {
737 // The form element might be absent if no existing fields can be added to
738 // this bundle.
739 if (isset($form_state['values']['fields']['_add_existing_field'])) {
740 $field = $form_state['values']['fields']['_add_existing_field'];
741
742 // Validate if any information was provided in the 'add existing field' row.
743 if (array_filter(array($field['label'], $field['field_name'], $field['widget_type']))) {
744 // Missing label.
745 if (!$field['label']) {
746 form_set_error('fields][_add_existing_field][label', t('Add existing field: you need to provide a label.'));
747 }
748
749 // Missing existing field name.
750 if (!$field['field_name']) {
751 form_set_error('fields][_add_existing_field][field_name', t('Add existing field: you need to select a field.'));
752 }
753
754 // Missing widget type.
755 if (!$field['widget_type']) {
756 form_set_error('fields][_add_existing_field][widget_type', t('Add existing field: you need to select a widget.'));
757 }
758 // Wrong widget type.
759 elseif ($field['field_name'] && ($existing_field = field_info_field($field['field_name']))) {
760 $widget_types = field_ui_widget_type_options($existing_field['type']);
761 if (!isset($widget_types[$field['widget_type']])) {
762 form_set_error('fields][_add_existing_field][widget_type', t('Add existing field: invalid widget.'));
763 }
764 }
765 }
766 }
767 }
768
774 function field_ui_field_overview_form_submit($form, &$form_state) {
775 $form_values = $form_state['values']['fields'];
776 $entity_type = $form['#entity_type'];
777 $bundle = $form['#bundle'];
778 $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
779
780 $bundle_settings = field_bundle_settings($entity_type, $bundle);
781
782 // Update field weights.
783 foreach ($form_values as $key => $values) {
784 if (in_array($key, $form['#fields'])) {
785 $instance = field_read_instance($entity_type, $key, $bundle);
786 $instance['widget']['weight'] = $values['weight'];
787 field_update_instance($instance);
788 }
789 elseif (in_array($key, $form['#extra'])) {
790 $bundle_settings['extra_fields']['form'][$key]['weight'] = $values['weight'];
791 }
792 }
793
794 field_bundle_settings($entity_type, $bundle, $bundle_settings);
795
796 $destinations = array();
797
798 // Create new field.
799 $field = array();
800 if (!empty($form_values['_add_new_field']['field_name'])) {
801 $values = $form_values['_add_new_field'];
802
803 $field = array(
804 'field_name' => $values['field_name'],
805 'type' => $values['type'],
806 'translatable' => $values['translatable'],
807 );
808 $instance = array(
809 'field_name' => $field['field_name'],
810 'entity_type' => $entity_type,
811 'bundle' => $bundle,
812 'label' => $values['label'],
813 'widget' => array(
814 'type' => $values['widget_type'],
815 'weight' => $values['weight'],
816 ),
817 );
818
819 // Create the field and instance.
820 try {
821 field_create_field($field);
822 field_create_instance($instance);
823
824 $destinations[] = $admin_path . '/fields/' . $field['field_name'] . '/field-settings';
825 $destinations[] = $admin_path . '/fields/' . $field['field_name'];
826
827 // Store new field information for any additional submit handlers.
828 $form_state['fields_added']['_add_new_field'] = $field['field_name'];
829 }
830 catch (Exception $e) {
831 drupal_set_message(t('There was a problem creating field %label: !message', array('%label' => $instance['label'], '!message' => $e->getMessage())), 'error');
832 }
833 }
834
835 // Add existing field.
836 if (!empty($form_values['_add_existing_field']['field_name'])) {
837 $values = $form_values['_add_existing_field'];
838 $field = field_info_field($values['field_name']);
839 if (!empty($field['locked'])) {
840 drupal_set_message(t('The field %label cannot be added because it is locked.', array('%label' => $values['label'])), 'error');
841 }
842 else {
843 $instance = array(
844 'field_name' => $field['field_name'],
845 'entity_type' => $entity_type,
846 'bundle' => $bundle,
847 'label' => $values['label'],
848 'widget' => array(
849 'type' => $values['widget_type'],
850 'weight' => $values['weight'],
851 ),
852 );
853
854 try {
855 field_create_instance($instance);
856 $destinations[] = $admin_path . '/fields/' . $instance['field_name'] . '/edit';
857 // Store new field information for any additional submit handlers.
858 $form_state['fields_added']['_add_existing_field'] = $instance['field_name'];
859 }
860 catch (Exception $e) {
861 drupal_set_message(t('There was a problem creating field instance %label: @message.', array('%label' => $instance['label'], '@message' => $e->getMessage())), 'error');
862 }
863 }
864 }
865
866 if ($destinations) {
867 $destination = drupal_get_destination();
868 $destinations[] = $destination['destination'];
869 unset($_GET['destination']);
870 $form_state['redirect'] = field_ui_get_destinations($destinations);
871 }
872 else {
873 drupal_set_message(t('Your settings have been saved.'));
874 }
875 }
876
884 function field_ui_display_overview_form($form, &$form_state, $entity_type, $bundle, $view_mode) {
885 $bundle = field_extract_bundle($entity_type, $bundle);
886
887 field_ui_inactive_message($entity_type, $bundle);
888 $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
889
890 // Gather type information.
891 $instances = field_info_instances($entity_type, $bundle);
892 $field_types = field_info_field_types();
893 $extra_fields = field_info_extra_fields($entity_type, $bundle, 'display');
894
895 $form_state += array(
896 'formatter_settings_edit' => NULL,
897 );
898
899 $form += array(
900 '#entity_type' => $entity_type,
901 '#bundle' => $bundle,
902 '#view_mode' => $view_mode,
903 '#fields' => array_keys($instances),
904 '#extra' => array_keys($extra_fields),
905 );
906
907 if (empty($instances) && empty($extra_fields)) {
908 drupal_set_message(t('There are no fields yet added. You can add new fields on the <a href="@link">Manage fields</a> page.', array('@link' => url($admin_path . '/fields'))), 'warning');
909 return $form;
910 }
911
912 $table = array(
913 '#type' => 'field_ui_table',
914 '#tree' => TRUE,
915 '#header' => array(
916 t('Field'),
917 t('Weight'),
918 t('Parent'),
919 t('Label'),
920 array('data' => t('Format'), 'colspan' => 3),
921 ),
922 '#regions' => array(
923 'visible' => array('message' => t('No field is displayed.')),
924 'hidden' => array('title' => t('Hidden'), 'message' => t('No field is hidden.')),
925 ),
926 '#parent_options' => array(),
927 '#attributes' => array(
928 'class' => array('field-ui-overview'),
929 'id' => 'field-display-overview',
930 ),
931 // Add Ajax wrapper.
932 '#prefix' => '<div id="field-display-overview-wrapper">',
933 '#suffix' => '</div>',
934 );
935
936 $field_label_options = array(
937 'above' => t('Above'),
938 'inline' => t('Inline'),
939 'hidden' => t('<Hidden>'),
940 );
941 $extra_visibility_options = array(
942 'visible' => t('Visible'),
943 'hidden' => t('Hidden'),
944 );
945
946 // Field rows.
947 foreach ($instances as $name => $instance) {
948 $field = field_info_field($instance['field_name']);
949 $display = $instance['display'][$view_mode];
950 $table[$name] = array(
951 '#attributes' => array('class' => array('draggable', 'tabledrag-leaf')),
952 '#row_type' => 'field',
953 '#region_callback' => 'field_ui_display_overview_row_region',
954 '#js_settings' => array(
955 'rowHandler' => 'field',
956 'defaultFormatter' => $field_types[$field['type']]['default_formatter'],
957 ),
958 'human_name' => array(
959 '#markup' => check_plain($instance['label']),
960 ),
961 'weight' => array(
962 '#type' => 'textfield',
963 '#title' => t('Weight for @title', array('@title' => $instance['label'])),
964 '#title_display' => 'invisible',
965 '#default_value' => $display['weight'],
966 '#size' => 3,
967 '#attributes' => array('class' => array('field-weight')),
968 ),
969 'parent_wrapper' => array(
970 'parent' => array(
971 '#type' => 'select',
972 '#title' => t('Label display for @title', array('@title' => $instance['label'])),
973 '#title_display' => 'invisible',
974 '#options' => $table['#parent_options'],
975 '#empty_value' => '',
976 '#attributes' => array('class' => array('field-parent')),
977 '#parents' => array('fields', $name, 'parent'),
978 ),
979 'hidden_name' => array(
980 '#type' => 'hidden',
981 '#default_value' => $name,
982 '#attributes' => array('class' => array('field-name')),
983 ),
984 ),
985 'label' => array(
986 '#type' => 'select',
987 '#title' => t('Label display for @title', array('@title' => $instance['label'])),
988 '#title_display' => 'invisible',
989 '#options' => $field_label_options,
990 '#default_value' => $display['label'],
991 ),
992 );
993
994 $formatter_options = field_ui_formatter_options($field['type']);
995 $formatter_options['hidden'] = t('<Hidden>');
996 $table[$name]['format'] = array(
997 'type' => array(
998 '#type' => 'select',
999 '#title' => t('Formatter for @title', array('@title' => $instance['label'])),
1000 '#title_display' => 'invisible',
1001 '#options' => $formatter_options,
1002 '#default_value' => $display['type'],
1003 '#parents' => array('fields', $name, 'type'),
1004 '#attributes' => array('class' => array('field-formatter-type')),
1005 ),
1006 'settings_edit_form' => array(),
1007 );
1008
1009 // Formatter settings.
1010
1011 // Check the currently selected formatter, and merge persisted values for
1012 // formatter settings.
1013 if (isset($form_state['values']['fields'][$name]['type'])) {
1014 $formatter_type = $form_state['values']['fields'][$name]['type'];
1015 }
1016 else {
1017 $formatter_type = $display['type'];
1018 }
1019 if (isset($form_state['formatter_settings'][$name])) {
1020 $settings = $form_state['formatter_settings'][$name];
1021 }
1022 else {
1023 $settings = $display['settings'];
1024 }
1025 $settings += field_info_formatter_settings($formatter_type);
1026
1027 $instance['display'][$view_mode]['type'] = $formatter_type;
1028 $formatter = field_info_formatter_types($formatter_type);
1029 $instance['display'][$view_mode]['module'] = $formatter['module'];
1030 $instance['display'][$view_mode]['settings'] = $settings;
1031
1032 // Base button element for the various formatter settings actions.
1033 $base_button = array(
1034 '#submit' => array('field_ui_display_overview_multistep_submit'),
1035 '#ajax' => array(
1036 'callback' => 'field_ui_display_overview_multistep_js',
1037 'wrapper' => 'field-display-overview-wrapper',
1038 'effect' => 'fade',
1039 ),
1040 '#field_name' => $name,
1041 );
1042
1043 if ($form_state['formatter_settings_edit'] == $name) {
1044 // We are currently editing this field's formatter settings. Display the
1045 // settings form and submit buttons.
1046 $table[$name]['format']['settings_edit_form'] = array();
1047
1048 $settings_form = array();
1049 $function = $formatter['module'] . '_field_formatter_settings_form';
1050 if (function_exists($function)) {
1051 $settings_form = $function($field, $instance, $view_mode, $form, $form_state);
1052 }
1053
1054 if ($settings_form) {
1055 $table[$name]['format']['#cell_attributes'] = array('colspan' => 3);
1056 $table[$name]['format']['settings_edit_form'] = array(
1057 '#type' => 'container',
1058 '#attributes' => array('class' => array('field-formatter-settings-edit-form')),
1059 '#parents' => array('fields', $name, 'settings_edit_form'),
1060 'label' => array(
1061 '#markup' => t('Format settings:') . ' <span class="formatter-name">' . $formatter['label'] . '</span>',
1062 ),
1063 'settings' => $settings_form,
1064 'actions' => array(
1065 '#type' => 'actions',
1066 'save_settings' => $base_button + array(
1067 '#type' => 'submit',
1068 '#name' => $name . '_formatter_settings_update',
1069 '#value' => t('Update'),
1070 '#op' => 'update',
1071 ),
1072 'cancel_settings' => $base_button + array(
1073 '#type' => 'submit',
1074 '#name' => $name . '_formatter_settings_cancel',
1075 '#value' => t('Cancel'),
1076 '#op' => 'cancel',
1077 // Do not check errors for the 'Cancel' button, but make sure we
1078 // get the value of the 'formatter type' select.
1079 '#limit_validation_errors' => array(array('fields', $name, 'type')),
1080 ),
1081 ),
1082 );
1083 $table[$name]['#attributes']['class'][] = 'field-formatter-settings-editing';
1084 }
1085 }
1086 else {
1087 // Display a summary of the current formatter settings.
1088 $summary = module_invoke($formatter['module'], 'field_formatter_settings_summary', $field, $instance, $view_mode);
1089 $table[$name]['settings_summary'] = array();
1090 $table[$name]['settings_edit'] = array();
1091 if ($summary) {
1092 $table[$name]['settings_summary'] = array(
1093 '#markup' => '<div class="field-formatter-summary">' . $summary . '</div>',
1094 '#cell_attributes' => array('class' => array('field-formatter-summary-cell')),
1095 );
1096 $table[$name]['settings_edit'] = $base_button + array(
1097 '#type' => 'image_button',
1098 '#name' => $name . '_formatter_settings_edit',
1099 '#src' => 'misc/configure.png',
1100 '#attributes' => array('class' => array('field-formatter-settings-edit'), 'alt' => t('Edit')),
1101 '#op' => 'edit',
1102 // Do not check errors for the 'Edit' button, but make sure we get
1103 // the value of the 'formatter type' select.
1104 '#limit_validation_errors' => array(array('fields', $name, 'type')),
1105 '#prefix' => '<div class="field-formatter-settings-edit-wrapper">',
1106 '#suffix' => '</div>',
1107 );
1108 }
1109 }
1110 }
1111
1112 // Non-field elements.
1113 foreach ($extra_fields as $name => $extra_field) {
1114 $display = $extra_field['display'][$view_mode];
1115 $table[$name] = array(
1116 '#attributes' => array('class' => array('draggable', 'tabledrag-leaf')),
1117 '#row_type' => 'extra_field',
1118 '#region_callback' => 'field_ui_display_overview_row_region',
1119 '#js_settings' => array('rowHandler' => 'field'),
1120 'human_name' => array(
1121 '#markup' => check_plain($extra_field['label']),
1122 ),
1123 'weight' => array(
1124 '#type' => 'textfield',
1125 '#title' => t('Weight for @title', array('@title' => $extra_field['label'])),
1126 '#title_display' => 'invisible',
1127 '#default_value' => $display['weight'],
1128 '#size' => 3,
1129 '#attributes' => array('class' => array('field-weight')),
1130 ),
1131 'parent_wrapper' => array(
1132 'parent' => array(
1133 '#type' => 'select',
1134 '#title' => t('Parents for @title', array('@title' => $extra_field['label'])),
1135 '#title_display' => 'invisible',
1136 '#options' => $table['#parent_options'],
1137 '#empty_value' => '',
1138 '#attributes' => array('class' => array('field-parent')),
1139 '#parents' => array('fields', $name, 'parent'),
1140 ),
1141 'hidden_name' => array(
1142 '#type' => 'hidden',
1143 '#default_value' => $name,
1144 '#attributes' => array('class' => array('field-name')),
1145 ),
1146 ),
1147 'empty_cell' => array(
1148 '#markup' => '&nbsp;',
1149 ),
1150 'format' => array(
1151 'type' => array(
1152 '#type' => 'select',
1153 '#title' => t('Visibility for @title', array('@title' => $extra_field['label'])),
1154 '#title_display' => 'invisible',
1155 '#options' => $extra_visibility_options,
1156 '#default_value' => $display['visible'] ? 'visible' : 'hidden',
1157 '#parents' => array('fields', $name, 'type'),
1158 '#attributes' => array('class' => array('field-formatter-type')),
1159 ),
1160 ),
1161 'settings_summary' => array(),
1162 'settings_edit' => array(),
1163 );
1164 }
1165
1166 $form['fields'] = $table;
1167
1168 // Custom display settings.
1169 if ($view_mode == 'default') {
1170 $form['modes'] = array(
1171 '#type' => 'fieldset',
1172 '#title' => t('Custom display settings'),
1173 '#collapsible' => TRUE,
1174 '#collapsed' => TRUE,
1175 );
1176 // Collect options and default values for the 'Custom display settings'
1177 // checkboxes.
1178 $options = array();
1179 $default = array();
1180 $entity_info = entity_get_info($entity_type);
1181 $view_modes = $entity_info['view modes'];
1182 $view_mode_settings = field_view_mode_settings($entity_type, $bundle);
1183 foreach ($view_modes as $view_mode_name => $view_mode_info) {
1184 $options[$view_mode_name] = $view_mode_info['label'];
1185 if (!empty($view_mode_settings[$view_mode_name]['custom_settings'])) {
1186 $default[] = $view_mode_name;
1187 }
1188 }
1189 $form['modes']['view_modes_custom'] = array(
1190 '#type' => 'checkboxes',
1191 '#title' => t('Use custom display settings for the following view modes'),
1192 '#options' => $options,
1193 '#default_value' => $default,
1194 );
1195 }
1196
1197 // In overviews involving nested rows from contributed modules (i.e
1198 // field_group), the 'format type' selects can trigger a series of changes in
1199 // child rows. The #ajax behavior is therefore not attached directly to the
1200 // selects, but triggered by the client-side script through a hidden #ajax
1201 // 'Refresh' button. A hidden 'refresh_rows' input tracks the name of
1202 // affected rows.
1203 $form['refresh_rows'] = array('#type' => 'hidden');
1204 $form['refresh'] = array(
1205 '#type' => 'submit',
1206 '#value' => t('Refresh'),
1207 '#op' => 'refresh_table',
1208 '#submit' => array('field_ui_display_overview_multistep_submit'),
1209 '#ajax' => array(
1210 'callback' => 'field_ui_display_overview_multistep_js',
1211 'wrapper' => 'field-display-overview-wrapper',
1212 'effect' => 'fade',
1213 // The button stays hidden, so we hide the Ajax spinner too. Ad-hoc
1214 // spinners will be added manually by the client-side script.
1215 'progress' => 'none',
1216 ),
1217 );
1218
1219 $form['actions'] = array('#type' => 'actions');
1220 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
1221
1222 $form['#attached']['js'][] = drupal_get_path('module', 'field_ui') . '/field_ui.js';
1223 $form['#attached']['css'][] = drupal_get_path('module', 'field_ui') . '/field_ui.css';
1224
1225 // Add tabledrag behavior.
1226 $form['#attached']['drupal_add_tabledrag'][] = array('field-display-overview', 'order', 'sibling', 'field-weight');
1227 $form['#attached']['drupal_add_tabledrag'][] = array('field-display-overview', 'match', 'parent', 'field-parent', 'field-parent', 'field-name');
1228
1229 return $form;
1230 }
1231
1232
1236 function field_ui_display_overview_multistep_submit($form, &$form_state) {
1237 $trigger = $form_state['triggering_element'];
1238 $op = $trigger['#op'];
1239
1240 switch ($op) {
1241 case 'edit':
1242 // Store the field whose settings are currently being edited.
1243 $field_name = $trigger['#field_name'];
1244 $form_state['formatter_settings_edit'] = $field_name;
1245 break;
1246
1247 case 'update':
1248 // Store the saved settings, and set the field back to 'non edit' mode.
1249 $field_name = $trigger['#field_name'];
1250 $values = $form_state['values']['fields'][$field_name]['settings_edit_form']['settings'];
1251 $form_state['formatter_settings'][$field_name] = $values;
1252 unset($form_state['formatter_settings_edit']);
1253 break;
1254
1255 case 'cancel':
1256 // Set the field back to 'non edit' mode.
1257 unset($form_state['formatter_settings_edit']);
1258 break;
1259
1260 case 'refresh_table':
1261 // If the currently edited field is one of the rows to be refreshed, set
1262 // it back to 'non edit' mode.
1263 $updated_rows = explode(' ', $form_state['values']['refresh_rows']);
1264 if (isset($form_state['formatter_settings_edit']) && in_array($form_state['formatter_settings_edit'], $updated_rows)) {
1265 unset($form_state['formatter_settings_edit']);
1266 }
1267 break;
1268 }
1269
1270 $form_state['rebuild'] = TRUE;
1271 }
1272
1276 function field_ui_display_overview_multistep_js($form, &$form_state) {
1277 $trigger = $form_state['triggering_element'];
1278 $op = $trigger['#op'];
1279
1280 // Pick the elements that need to receive the ajax-new-content effect.
1281 switch ($op) {
1282 case 'edit':
1283 $updated_rows = array($trigger['#field_name']);
1284 $updated_columns = array('format');
1285 break;
1286
1287 case 'update':
1288 case 'cancel':
1289 $updated_rows = array($trigger['#field_name']);
1290 $updated_columns = array('format', 'settings_summary', 'settings_edit');
1291 break;
1292
1293 case 'refresh_table':
1294 $updated_rows = array_values(explode(' ', $form_state['values']['refresh_rows']));
1295 $updated_columns = array('settings_summary', 'settings_edit');
1296 break;
1297 }
1298
1299 foreach ($updated_rows as $name) {
1300 foreach ($updated_columns as $key) {
1301 $element = &$form['fields'][$name][$key];
1302 $element['#prefix'] = '<div class="ajax-new-content">' . (isset($element['#prefix']) ? $element['#prefix'] : '');
1303 $element['#suffix'] = (isset($element['#suffix']) ? $element['#suffix'] : '') . '</div>';
1304 }
1305 }
1306
1307 // Return the whole table.
1308 return $form['fields'];
1309 }
1310
1314 function field_ui_display_overview_form_submit($form, &$form_state) {
1315 $form_values = $form_state['values'];
1316 $entity_type = $form['#entity_type'];
1317 $bundle = $form['#bundle'];
1318 $view_mode = $form['#view_mode'];
1319
1320 // Save data for 'regular' fields.
1321 foreach ($form['#fields'] as $field_name) {
1322 // Retrieve the stored instance settings to merge with the incoming values.
1323 $instance = field_read_instance($entity_type, $field_name, $bundle);
1324 $values = $form_values['fields'][$field_name];
1325 // Get formatter settings. They lie either directly in submitted form
1326 // values (if the whole form was submitted while some formatter
1327 // settings were being edited), or have been persisted in
1328 // $form_state.
1329 $settings = array();
1330 if (isset($values['settings_edit_form']['settings'])) {
1331 $settings = $values['settings_edit_form']['settings'];
1332 }
1333 elseif (isset($form_state['formatter_settings'][$field_name])) {
1334 $settings = $form_state['formatter_settings'][$field_name];
1335 }
1336 elseif (isset($instance['display'][$view_mode]['settings'])) {
1337 $settings = $instance['display'][$view_mode]['settings'];
1338 }
1339
1340 // Only save settings actually used by the selected formatter.
1341 $default_settings = field_info_formatter_settings($values['type']);
1342 $settings = array_intersect_key($settings, $default_settings);
1343
1344 $instance['display'][$view_mode] = array(
1345 'label' => $values['label'],
1346 'type' => $values['type'],
1347 'weight' => $values['weight'],
1348 'settings' => $settings,
1349 );
1350 field_update_instance($instance);
1351 }
1352
1353 // Get current bundle settings.
1354 $bundle_settings = field_bundle_settings($entity_type, $bundle);
1355
1356 // Save data for 'extra' fields.
1357 foreach ($form['#extra'] as $name) {
1358 $bundle_settings['extra_fields']['display'][$name][$view_mode] = array(
1359 'weight' => $form_values['fields'][$name]['weight'],
1360 'visible' => $form_values['fields'][$name]['type'] == 'visible',
1361 );
1362 }
1363
1364 // Save view modes data.
1365 if ($view_mode == 'default') {
1366 $entity_info = entity_get_info($entity_type);
1367 foreach ($form_values['view_modes_custom'] as $view_mode_name => $value) {
1368 // Display a message for each view mode newly configured to use custom
1369 // settings.
1370 $view_mode_settings = field_view_mode_settings($entity_type, $bundle);
1371 if (!empty($value) && empty($view_mode_settings[$view_mode_name]['custom_settings'])) {
1372 $view_mode_label = $entity_info['view modes'][$view_mode_name]['label'];
1373 $path = _field_ui_bundle_admin_path($entity_type, $bundle) . "/display/$view_mode_name";
1374 drupal_set_message(t('The %view_mode mode now uses custom display settings. You might want to <a href="@url">configure them</a>.', array('%view_mode' => $view_mode_label, '@url' => url($path))));
1375 // Initialize the newly customized view mode with the display settings
1376 // from the default view mode.
1377 _field_ui_add_default_view_mode_settings($entity_type, $bundle, $view_mode_name, $bundle_settings);
1378 }
1379 $bundle_settings['view_modes'][$view_mode_name]['custom_settings'] = !empty($value);
1380 }
1381 }
1382
1383 // Save updated bundle settings.
1384 field_bundle_settings($entity_type, $bundle, $bundle_settings);
1385
1386 drupal_set_message(t('Your settings have been saved.'));
1387 }
1388
1412 function _field_ui_add_default_view_mode_settings($entity_type, $bundle, $view_mode, &$settings) {
1413 // Update display settings for field instances.
1414 $instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle));
1415 foreach ($instances as $instance) {
1416 // If this field instance has display settings defined for this view mode,
1417 // respect those settings.
1418 if (!isset($instance['display'][$view_mode])) {
1419 // The instance doesn't specify anything for this view mode, so use the
1420 // default display settings.
1421 $instance['display'][$view_mode] = $instance['display']['default'];
1422 field_update_instance($instance);
1423 }
1424 }
1425
1426 // Update display settings for 'extra fields'.
1427 foreach (array_keys($settings['extra_fields']['display']) as $name) {
1428 if (!isset($settings['extra_fields']['display'][$name][$view_mode])) {
1429 $settings['extra_fields']['display'][$name][$view_mode] = $settings['extra_fields']['display'][$name]['default'];
1430 }
1431 }
1432 }
1433
1437 function field_ui_field_type_options() {
1438 $options = &drupal_static(__FUNCTION__);
1439
1440 if (!isset($options)) {
1441 $options = array();
1442 $field_types = field_info_field_types();
1443 $field_type_options = array();
1444 foreach ($field_types as $name => $field_type) {
1445 // Skip field types which have no widget types, or should not be add via
1446 // uesr interface.
1447 if (field_ui_widget_type_options($name) && empty($field_type['no_ui'])) {
1448 $options[$name] = $field_type['label'];
1449 }
1450 }
1451 asort($options);
1452 }
1453 return $options;
1454 }
1455
1462 function field_ui_widget_type_options($field_type = NULL, $by_label = FALSE) {
1463 $options = &drupal_static(__FUNCTION__);
1464
1465 if (!isset($options)) {
1466 $options = array();
1467 $field_types = field_info_field_types();
1468 foreach (field_info_widget_types() as $name => $widget_type) {
1469 foreach ($widget_type['field types'] as $widget_field_type) {
1470 // Check that the field type exists.
1471 if (isset($field_types[$widget_field_type])) {
1472 $options[$widget_field_type][$name] = $widget_type['label'];
1473 }
1474 }
1475 }
1476 }
1477
1478 if (isset($field_type)) {
1479 return !empty($options[$field_type]) ? $options[$field_type] : array();
1480 }
1481 if ($by_label) {
1482 $field_types = field_info_field_types();
1483 $options_by_label = array();
1484 foreach ($options as $field_type => $widgets) {
1485 $options_by_label[$field_types[$field_type]['label']] = $widgets;
1486 }
1487 return $options_by_label;
1488 }
1489 return $options;
1490 }
1491
1498 function field_ui_formatter_options($field_type = NULL) {
1499 $options = &drupal_static(__FUNCTION__);
1500
1501 if (!isset($options)) {
1502 $field_types = field_info_field_types();
1503 $options = array();
1504 foreach (field_info_formatter_types() as $name => $formatter) {
1505 foreach ($formatter['field types'] as $formatter_field_type) {
1506 // Check that the field type exists.
1507 if (isset($field_types[$formatter_field_type])) {
1508 $options[$formatter_field_type][$name] = $formatter['label'];
1509 }
1510 }
1511 }
1512 }
1513
1514 if ($field_type) {
1515 return !empty($options[$field_type]) ? $options[$field_type] : array();
1516 }
1517 return $options;
1518 }
1519
1523 function field_ui_existing_field_options($entity_type, $bundle) {
1524 $info = array();
1525 $field_types = field_info_field_types();
1526
1527 foreach (field_info_instances() as $existing_entity_type => $bundles) {
1528 foreach ($bundles as $existing_bundle => $instances) {
1529 // No need to look in the current bundle.
1530 if (!($existing_bundle == $bundle && $existing_entity_type == $entity_type)) {
1531 foreach ($instances as $instance) {
1532 $field = field_info_field($instance['field_name']);
1533 // Don't show
1534 // - locked fields,
1535 // - fields already in the current bundle,
1536 // - fields that cannot be added to the entity type,
1537 // - fields that should not be added via user interface.
1538
1539 if (empty($field['locked'])
1540 && !field_info_instance($entity_type, $field['field_name'], $bundle)
1541 && (empty($field['entity_types']) || in_array($entity_type, $field['entity_types']))
1542 && empty($field_types[$field['type']]['no_ui'])) {
1543 $info[$instance['field_name']] = array(
1544 'type' => $field['type'],
1545 'type_label' => $field_types[$field['type']]['label'],
1546 'field' => $field['field_name'],
1547 'label' => $instance['label'],
1548 'widget_type' => $instance['widget']['type'],
1549 );
1550 }
1551 }
1552 }
1553 }
1554 }
1555 return $info;
1556 }
1557
1564 function field_ui_field_settings_form($form, &$form_state, $instance) {
1565 $bundle = $instance['bundle'];
1566 $entity_type = $instance['entity_type'];
1567 $field = field_info_field($instance['field_name']);
1568
1569 drupal_set_title($instance['label']);
1570
1571 $description = '<p>' . t('These settings apply to the %field field everywhere it is used. These settings impact the way that data is stored in the database and cannot be changed once data has been created.', array('%field' => $instance['label'])) . '</p>';
1572
1573 // Create a form structure for the field values.
1574 $form['field'] = array(
1575 '#type' => 'fieldset',
1576 '#title' => t('Field settings'),
1577 '#description' => $description,
1578 '#tree' => TRUE,
1579 );
1580
1581 // See if data already exists for this field.
1582 // If so, prevent changes to the field settings.
1583 $has_data = field_has_data($field);
1584 if ($has_data) {
1585 $form['field']['#description'] = '<div class="messages error">' . t('There is data for this field in the database. The field settings can no longer be changed.') . '</div>' . $form['field']['#description'];
1586 }
1587
1588 // Build the non-configurable field values.
1589 $form['field']['field_name'] = array('#type' => 'value', '#value' => $field['field_name']);
1590 $form['field']['type'] = array('#type' => 'value', '#value' => $field['type']);
1591 $form['field']['module'] = array('#type' => 'value', '#value' => $field['module']);
1592 $form['field']['active'] = array('#type' => 'value', '#value' => $field['active']);
1593
1594 // Add settings provided by the field module. The field module is
1595 // responsible for not returning settings that cannot be changed if
1596 // the field already has data.
1597 $form['field']['settings'] = array();
1598 $additions = module_invoke($field['module'], 'field_settings_form', $field, $instance, $has_data);
1599 if (is_array($additions)) {
1600 $form['field']['settings'] = $additions;
1601 }
1602 if (empty($form['field']['settings'])) {
1603 $form['field']['settings'] = array(
1604 '#markup' => t('%field has no field settings.', array('%field' => $instance['label'])),
1605 );
1606 }
1607 $form['#entity_type'] = $entity_type;
1608 $form['#bundle'] = $bundle;
1609
1610 $form['actions'] = array('#type' => 'actions');
1611 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save field settings'));
1612 return $form;
1613 }
1614
1618 function field_ui_field_settings_form_submit($form, &$form_state) {
1619 $form_values = $form_state['values'];
1620 $field_values = $form_values['field'];
1621
1622 // Merge incoming form values into the existing field.
1623 $field = field_info_field($field_values['field_name']);
1624
1625 $entity_type = $form['#entity_type'];
1626 $bundle = $form['#bundle'];
1627 $instance = field_info_instance($entity_type, $field['field_name'], $bundle);
1628
1629 // Update the field.
1630 $field = array_merge($field, $field_values);
1631
1632 try {
1633 field_update_field($field);
1634 drupal_set_message(t('Updated field %label field settings.', array('%label' => $instance['label'])));
1635 $form_state['redirect'] = field_ui_next_destination($entity_type, $bundle);
1636 }
1637 catch (Exception $e) {
1638 drupal_set_message(t('Attempt to update field %label failed: %message.', array('%label' => $instance['label'], '%message' => $e->getMessage())), 'error');
1639 }
1640 }
1641
1653 function field_ui_widget_type_form($form, &$form_state, $instance) {
1654 drupal_set_title($instance['label']);
1655
1656 $bundle = $instance['bundle'];
1657 $entity_type = $instance['entity_type'];
1658 $field_name = $instance['field_name'];
1659
1660 $field = field_info_field($field_name);
1661 $field_type = field_info_field_types($field['type']);
1662 $widget_type = field_info_widget_types($instance['widget']['type']);
1663 $bundles = field_info_bundles();
1664 $bundle_label = $bundles[$entity_type][$bundle]['label'];
1665
1666 $form = array(
1667 '#bundle' => $bundle,
1668 '#entity_type' => $entity_type,
1669 '#field_name' => $field_name,
1670 );
1671
1672 $form['basic'] = array(
1673 '#type' => 'fieldset',
1674 '#title' => t('Change widget'),
1675 );
1676 $form['basic']['widget_type'] = array(
1677 '#type' => 'select',
1678 '#title' => t('Widget type'),
1679 '#required' => TRUE,
1680 '#options' => field_ui_widget_type_options($field['type']),
1681 '#default_value' => $instance['widget']['type'],
1682 '#description' => t('The type of form element you would like to present to the user when creating this field in the %type type.', array('%type' => $bundle_label)),
1683 );
1684
1685 $form['actions'] = array('#type' => 'actions');
1686 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Continue'));
1687
1688 $form['#validate'] = array();
1689 $form['#submit'] = array('field_ui_widget_type_form_submit');
1690
1691 return $form;
1692 }
1693
1697 function field_ui_widget_type_form_submit($form, &$form_state) {
1698 $form_values = $form_state['values'];
1699 $bundle = $form['#bundle'];
1700 $entity_type = $form['#entity_type'];
1701 $field_name = $form['#field_name'];
1702
1703 // Retrieve the stored instance settings to merge with the incoming values.
1704 $instance = field_read_instance($entity_type, $field_name, $bundle);
1705
1706 // Set the right module information.
1707 $widget_type = field_info_widget_types($form_values['widget_type']);
1708 $widget_module = $widget_type['module'];
1709
1710 $instance['widget']['type'] = $form_values['widget_type'];
1711 $instance['widget']['module'] = $widget_module;
1712
1713 try {
1714 field_update_instance($instance);
1715 drupal_set_message(t('Changed the widget for field %label.', array('%label' => $instance['label'])));
1716 }
1717 catch (Exception $e) {
1718 drupal_set_message(t('There was a problem changing the widget for field %label.', array('%label' => $instance['label'])), 'error');
1719 }
1720
1721 $form_state['redirect'] = field_ui_next_destination($entity_type, $bundle);
1722 }
1723
1730 function field_ui_field_delete_form($form, &$form_state, $instance) {
1731 $bundle = $instance['bundle'];
1732 $entity_type = $instance['entity_type'];
1733 $field = field_info_field($instance['field_name']);
1734
1735 $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
1736
1737 $form['entity_type'] = array('#type' => 'value', '#value' => $entity_type);
1738 $form['bundle'] = array('#type' => 'value', '#value' => $bundle);
1739 $form['field_name'] = array('#type' => 'value', '#value' => $field['field_name']);
1740
1741 $output = confirm_form($form,
1742 t('Are you sure you want to delete the field %field?', array('%field' => $instance['label'])),
1743 $admin_path . '/fields',
1744 t('If you have any content left in this field, it will be lost. This action cannot be undone.'),
1745 t('Delete'), t('Cancel'),
1746 'confirm'
1747 );
1748
1749 if ($field['locked']) {
1750 unset($output['actions']['submit']);
1751 $output['description']['#markup'] = t('This field is <strong>locked</strong> and cannot be deleted.');
1752 }
1753
1754 return $output;
1755 }
1756
1763 function field_ui_field_delete_form_submit($form, &$form_state) {
1764 $form_values = $form_state['values'];
1765 $field_name = $form_values['field_name'];
1766 $bundle = $form_values['bundle'];
1767 $entity_type = $form_values['entity_type'];
1768
1769 $field = field_info_field($field_name);
1770 $instance = field_info_instance($entity_type, $field_name, $bundle);
1771 $bundles = field_info_bundles();
1772 $bundle_label = $bundles[$entity_type][$bundle]['label'];
1773
1774 if (!empty($bundle) && $field && !$field['locked'] && $form_values['confirm']) {
1775 field_delete_instance($instance);
1776 drupal_set_message(t('The field %field has been deleted from the %type content type.', array('%field' => $instance['label'], '%type' => $bundle_label)));
1777 }
1778 else {
1779 drupal_set_message(t('There was a problem removing the %field from the %type content type.', array('%field' => $instance['label'], '%type' => $bundle_label)), 'error');
1780 }
1781
1782 $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
1783 $form_state['redirect'] = field_ui_get_destinations(array($admin_path . '/fields'));
1784
1785 // Fields are purged on cron. However field module prevents disabling modules
1786 // when field types they provided are used in a field until it is fully
1787 // purged. In the case that a field has minimal or no content, a single call
1788 // to field_purge_batch() will remove it from the system. Call this with a
1789 // low batch limit to avoid administrators having to wait for cron runs when
1790 // removing instances that meet this criteria.
1791 field_purge_batch(10);
1792 }
1793
1801 function field_ui_field_edit_form($form, &$form_state, $instance) {
1802 $bundle = $instance['bundle'];
1803 $entity_type = $instance['entity_type'];
1804 $field = field_info_field($instance['field_name']);
1805
1806 drupal_set_title($instance['label']);
1807
1808 $form['#field'] = $field;
1809 $form['#instance'] = $instance;
1810
1811 if (!empty($field['locked'])) {
1812 $form['locked'] = array(
1813 '#markup' => t('The field %field is locked and cannot be edited.', array('%field' => $instance['label'])),
1814 );
1815 return $form;
1816 }
1817
1818 $field_type = field_info_field_types($field['type']);
1819 $widget_type = field_info_widget_types($instance['widget']['type']);
1820 $bundles = field_info_bundles();
1821
1822 // Create a form structure for the instance values.
1823 $form['instance'] = array(
1824 '#tree' => TRUE,
1825 '#type' => 'fieldset',
1826 '#title' => t('%type settings', array('%type' => $bundles[$entity_type][$bundle]['label'])),
1827 '#description' => t('These settings apply only to the %field field when used in the %type type.', array(
1828 '%field' => $instance['label'],
1829 '%type' => $bundles[$entity_type][$bundle]['label'],
1830 )),
1831 // Ensure field_ui_field_edit_instance_pre_render() gets called in addition
1832 // to, not instead of, the #pre_render function(s) needed by all fieldsets.
1833 '#pre_render' => array_merge(array('field_ui_field_edit_instance_pre_render'), element_info_property('fieldset', '#pre_render', array())),
1834 );
1835
1836 // Build the non-configurable instance values.
1837 $form['instance']['field_name'] = array(
1838 '#type' => 'value',
1839 '#value' => $instance['field_name'],
1840 );
1841 $form['instance']['entity_type'] = array(
1842 '#type' => 'value',
1843 '#value' => $entity_type,
1844 );
1845 $form['instance']['bundle'] = array(
1846 '#type' => 'value',
1847 '#value' => $bundle,
1848 );
1849 $form['instance']['widget']['weight'] = array(
1850 '#type' => 'value',
1851 '#value' => !empty($instance['widget']['weight']) ? $instance['widget']['weight'] : 0,
1852 );
1853
1854 // Build the configurable instance values.
1855 $form['instance']['label'] = array(
1856 '#type' => 'textfield',
1857 '#title' => t('Label'),
1858 '#default_value' => !empty($instance['label']) ? $instance['label'] : $field['field_name'],
1859 '#required' => TRUE,
1860 '#weight' => -20,
1861 );
1862 $form['instance']['required'] = array(
1863 '#type' => 'checkbox',
1864 '#title' => t('Required field'),
1865 '#default_value' => !empty($instance['required']),
1866 '#weight' => -10,
1867 );
1868
1869 $form['instance']['description'] = array(
1870 '#type' => 'textarea',
1871 '#title' => t('Help text'),
1872 '#default_value' => !empty($instance['description']) ? $instance['description'] : '',
1873 '#rows' => 5,
1874 '#description' => t('Instructions to present to the user below this field on the editing form.<br />Allowed HTML tags: @tags', array('@tags' => _field_filter_xss_display_allowed_tags())),
1875 '#weight' => -5,
1876 );
1877
1878 // Build the widget component of the instance.
1879 $form['instance']['widget']['type'] = array(
1880 '#type' => 'value',
1881 '#value' => $instance['widget']['type'],
1882 );
1883 $form['instance']['widget']['module'] = array(
1884 '#type' => 'value',
1885 '#value' => $widget_type['module'],
1886 );
1887 $form['instance']['widget']['active'] = array(
1888 '#type' => 'value',
1889 '#value' => !empty($field['instance']['widget']['active']) ? 1 : 0,
1890 );
1891
1892 // Add additional field instance settings from the field module.
1893 $additions = module_invoke($field['module'], 'field_instance_settings_form', $field, $instance);
1894 if (is_array($additions)) {
1895 $form['instance']['settings'] = $additions;
1896 }
1897
1898 // Add additional widget settings from the widget module.
1899 $additions = module_invoke($widget_type['module'], 'field_widget_settings_form', $field, $instance);
1900 if (is_array($additions)) {
1901 $form['instance']['widget']['settings'] = $additions;
1902 $form['instance']['widget']['active']['#value'] = 1;
1903 }
1904
1905 // Add handling for default value if not provided by any other module.
1906 if (field_behaviors_widget('default value', $instance) == FIELD_BEHAVIOR_DEFAULT && empty($instance['default_value_function'])) {
1907 $form['instance']['default_value_widget'] = field_ui_default_value_widget($field, $instance, $form, $form_state);
1908 }
1909
1910 $has_data = field_has_data($field);
1911 if ($has_data) {
1912 $description = '<p>' . t('These settings apply to the %field field everywhere it is used. Because the field already has data, some settings can no longer be changed.', array('%field' => $instance['label'])) . '</p>';
1913 }
1914 else {
1915 $description = '<p>' . t('These settings apply to the %field field everywhere it is used.', array('%field' => $instance['label'])) . '</p>';
1916 }
1917
1918 // Create a form structure for the field values.
1919 $form['field'] = array(
1920 '#type' => 'fieldset',
1921 '#title' => t('%field field settings', array('%field' => $instance['label'])),
1922 '#description' => $description,
1923 '#tree' => TRUE,
1924 );
1925
1926 // Build the configurable field values.
1927 $description = t('Maximum number of values users can enter for this field.');
1928 if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) {
1929 $description .= '<br/>' . t("'Unlimited' will provide an 'Add more' button so the users can add as many values as they like.");
1930 }
1931 $form['field']['cardinality'] = array(
1932 '#type' => 'select',
1933 '#title' => t('Number of values'),
1934 '#options' => array(FIELD_CARDINALITY_UNLIMITED => t('Unlimited')) + drupal_map_assoc(range(1, 10)),
1935 '#default_value' => $field['cardinality'],
1936 '#description' => $description,
1937 );
1938
1939 // Add additional field type settings. The field type module is
1940 // responsible for not returning settings that cannot be changed if
1941 // the field already has data.
1942 $additions = module_invoke($field['module'], 'field_settings_form', $field, $instance, $has_data);
1943 if (is_array($additions)) {
1944 $form['field']['settings'] = $additions;
1945 }
1946
1947 $form['actions'] = array('#type' => 'actions');
1948 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save settings'));
1949 return $form;
1950 }
1951
1959 function field_ui_field_edit_instance_pre_render($element) {
1960 // Merge the widget settings into the main form.
1961 if (isset($element['widget']['settings'])) {
1962 foreach (element_children($element['widget']['settings']) as $key) {
1963 $element['widget_' . $key] = $element['widget']['settings'][$key];
1964 }
1965 unset($element['widget']['settings']);
1966 }
1967
1968 // Merge the instance settings into the main form.
1969 if (isset($element['settings'])) {
1970 foreach (element_children($element['settings']) as $key) {
1971 $element['instance_' . $key] = $element['settings'][$key];
1972 }
1973 unset($element['settings']);
1974 }
1975
1976 return $element;
1977 }
1978
1982 function field_ui_default_value_widget($field, $instance, &$form, &$form_state) {
1983 $field_name = $field['field_name'];
1984
1985 $element = array(
1986 '#type' => 'fieldset',
1987 '#title' => t('Default value'),
1988 '#collapsible' => FALSE,
1989 '#tree' => TRUE,
1990 '#description' => t('The default value for this field, used when creating new content.'),
1991 // Stick to an empty 'parents' on this form in order not to breaks widgets
1992 // that do not use field_widget_[field|instance]() and still access
1993 // $form_state['field'] directly.
1994 '#parents' => array(),
1995 );
1996
1997 // Insert the widget.
1998 $items = $instance['default_value'];
1999 $instance['required'] = FALSE;
2000 $instance['description'] = '';
2001
2002 // @todo Allow multiple values (requires more work on 'add more' JS handler).
2003 $element += field_default_form($instance['entity_type'], NULL, $field, $instance, LANGUAGE_NONE, $items, $element, $form_state, 0);
2004
2005 return $element;
2006 }
2007
2013 function field_ui_field_edit_form_validate($form, &$form_state) {
2014 // Take the incoming values as the $instance definition, so that the 'default
2015 // value' gets validated using the instance settings being submitted.
2016 $instance = $form_state['values']['instance'];
2017 $field_name = $instance['field_name'];
2018
2019 if (isset($form['instance']['default_value_widget'])) {
2020 $element = $form['instance']['default_value_widget'];
2021
2022 $field_state = field_form_get_state($element['#parents'], $field_name, LANGUAGE_NONE, $form_state);
2023 $field = $field_state['field'];
2024
2025 // Extract the 'default value'.
2026 $items = array();
2027 field_default_extract_form_values(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $element, $form_state);
2028
2029 // Validate the value and report errors.
2030 $errors = array();
2031 $function = $field['module'] . '_field_validate';
2032 if (function_exists($function)) {
2033 $function(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $errors);
2034 }
2035 if (isset($errors[$field_name][LANGUAGE_NONE])) {
2036 // Store reported errors in $form_state.
2037 $field_state['errors'] = $errors[$field_name][LANGUAGE_NONE];
2038 field_form_set_state($element['#parents'], $field_name, LANGUAGE_NONE, $form_state, $field_state);
2039 // Assign reported errors to the correct form element.
2040 field_default_form_errors(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $element, $form_state);
2041 }
2042 }
2043 }
2044
2050 function field_ui_field_edit_form_submit($form, &$form_state) {
2051 $instance = $form_state['values']['instance'];
2052 $field = $form_state['values']['field'];
2053
2054 // Update any field settings that have changed.
2055 $field_source = field_info_field($instance['field_name']);
2056 $field = array_merge($field_source, $field);
2057 try {
2058 field_update_field($field);
2059 }
2060 catch (Exception $e) {
2061 drupal_set_message(t('Attempt to update field %label failed: %message.', array('%label' => $instance['label'], '%message' => $e->getMessage())), 'error');
2062 return;
2063 }
2064
2065 // Handle the default value.
2066 if (isset($form['instance']['default_value_widget'])) {
2067 $element = $form['instance']['default_value_widget'];
2068
2069 // Extract field values.
2070 $items = array();
2071 field_default_extract_form_values(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $element, $form_state);
2072 field_default_submit(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $element, $form_state);
2073
2074 $instance['default_value'] = $items ? $items : NULL;
2075 }
2076
2077 // Retrieve the stored instance settings to merge with the incoming values.
2078 $instance_source = field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']);
2079 $instance = array_merge($instance_source, $instance);
2080 field_update_instance($instance);
2081
2082 drupal_set_message(t('Saved %label configuration.', array('%label' => $instance['label'])));
2083
2084 $form_state['redirect'] = field_ui_next_destination($instance['entity_type'], $instance['bundle']);
2085 }
2086
2092 function field_ui_get_destinations($destinations) {
2093 $path = array_shift($destinations);
2094 $options = drupal_parse_url($path);
2095 if ($destinations) {
2096 $options['query']['destinations'] = $destinations;
2097 }
2098 return array($options['path'], $options);
2099 }
2100
2104 function field_ui_next_destination($entity_type, $bundle) {
2105 $destinations = !empty($_REQUEST['destinations']) ? $_REQUEST['destinations'] : array();
2106 if (!empty($destinations)) {
2107 unset($_REQUEST['destinations']);
2108 return field_ui_get_destinations($destinations);
2109 }
2110 $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
2111 return $admin_path . '/fields';
2112 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
field_read_fields
field_read_fields($params=array(), $include_additional=array())
Definition: field.crud.inc:340
_field_filter_xss_display_allowed_tags
_field_filter_xss_display_allowed_tags()
Definition: field.module:766
field_create_instance
field_create_instance($instance)
Definition: field.crud.inc:473
_field_ui_field_name_exists
_field_ui_field_name_exists($value)
Definition: field_ui.admin.inc:722
$op
$op
Definition: update.php:404
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
_field_ui_reduce_order
_field_ui_reduce_order($array, $a)
Definition: field_ui.admin.inc:79
field_info_formatter_types
field_info_formatter_types($formatter_type=NULL)
Definition: field.info.inc:379
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
field_ui_field_edit_form_submit
field_ui_field_edit_form_submit($form, &$form_state)
Definition: field_ui.admin.inc:2050
field_ui_field_delete_form_submit
field_ui_field_delete_form_submit($form, &$form_state)
Definition: field_ui.admin.inc:1763
_field_ui_field_overview_form_validate_add_new
_field_ui_field_overview_form_validate_add_new($form, &$form_state)
Definition: field_ui.admin.inc:671
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
field_default_form_errors
field_default_form_errors($entity_type, $entity, $field, $instance, $langcode, $items, $form, &$form_state)
Definition: field.form.inc:389
field_ui_default_value_widget
field_ui_default_value_widget($field, $instance, &$form, &$form_state)
Definition: field_ui.admin.inc:1982
field_default_extract_form_values
field_default_extract_form_values($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state)
Definition: field.default.inc:35
field_info_instances
field_info_instances($entity_type=NULL, $bundle_name=NULL)
Definition: field.info.inc:592
field_ui_display_overview_row_region
field_ui_display_overview_row_region($row)
Definition: field_ui.admin.inc:117
field_ui_widget_type_options
field_ui_widget_type_options($field_type=NULL, $by_label=FALSE)
Definition: field_ui.admin.inc:1462
theme_field_ui_table
theme_field_ui_table($variables)
Definition: field_ui.admin.inc:207
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
_field_ui_field_overview_form_validate_add_existing
_field_ui_field_overview_form_validate_add_existing($form, &$form_state)
Definition: field_ui.admin.inc:736
field_ui_field_settings_form
field_ui_field_settings_form($form, &$form_state, $instance)
Definition: field_ui.admin.inc:1564
$name
print $name
Definition: profile-listing.tpl.php:43
Exception
field_ui_get_destinations
field_ui_get_destinations($destinations)
Definition: field_ui.admin.inc:2092
$header
print $header
Definition: forum-topic-list.tpl.php:42
field_ui_field_overview_row_region
field_ui_field_overview_row_region($row)
Definition: field_ui.admin.inc:98
field_ui_inactive_instances
field_ui_inactive_instances($entity_type, $bundle_name=NULL)
Definition: field_ui.module:334
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
field_read_instance
field_read_instance($entity_type, $field_name, $bundle, $include_additional=array())
Definition: field.crud.inc:692
field_ui_inactive_message
field_ui_inactive_message($entity_type, $bundle)
Definition: field_ui.admin.inc:56
field_read_instances
field_read_instances($params=array(), $include_additional=array())
Definition: field.crud.inc:713
field_ui_field_settings_form_submit
field_ui_field_settings_form_submit($form, &$form_state)
Definition: field_ui.admin.inc:1618
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
field_ui_display_overview_form
field_ui_display_overview_form($form, &$form_state, $entity_type, $bundle, $view_mode)
Definition: field_ui.admin.inc:884
field_has_data
field_has_data($field)
Definition: field.module:948
FIELD_BEHAVIOR_DEFAULT
const FIELD_BEHAVIOR_DEFAULT
Definition: field.module:255
field_ui_next_destination
field_ui_next_destination($entity_type, $bundle)
Definition: field_ui.admin.inc:2104
field_ui_widget_type_form
field_ui_widget_type_form($form, &$form_state, $instance)
Definition: field_ui.admin.inc:1653
field_info_field_types
field_info_field_types($field_type=NULL)
Definition: field.info.inc:329
field_ui_formatter_options
field_ui_formatter_options($field_type=NULL)
Definition: field_ui.admin.inc:1498
system_rebuild_module_data
system_rebuild_module_data()
Definition: system.module:2444
field_create_field
field_create_field($field)
Definition: field.crud.inc:56
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
field_view_mode_settings
field_view_mode_settings($entity_type, $bundle)
Definition: field.module:617
field_ui_field_overview_form_submit
field_ui_field_overview_form_submit($form, &$form_state)
Definition: field_ui.admin.inc:774
field_ui_existing_field_options
field_ui_existing_field_options($entity_type, $bundle)
Definition: field_ui.admin.inc:1523
field_ui_field_type_options
field_ui_field_type_options()
Definition: field_ui.admin.inc:1437
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
field_behaviors_widget
field_behaviors_widget($op, $instance)
Definition: field.info.inc:313
field_default_form
field_default_form($entity_type, $entity, $field, $instance, $langcode, $items, &$form, &$form_state, $get_delta=NULL)
Definition: field.form.inc:42
$info
$info
Definition: color.inc:6
field_info_cache_clear
field_info_cache_clear()
Definition: field.info.inc:54
field_ui_field_edit_instance_pre_render
field_ui_field_edit_instance_pre_render($element)
Definition: field_ui.admin.inc:1959
field_ui_field_overview_form
field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle)
Definition: field_ui.admin.inc:288
field_ui_display_overview_multistep_submit
field_ui_display_overview_multistep_submit($form, &$form_state)
Definition: field_ui.admin.inc:1236
field_default_submit
field_default_submit($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state)
Definition: field.default.inc:89
field_info_extra_fields
field_info_extra_fields($entity_type, $bundle, $context)
Definition: field.info.inc:684
field_ui_widget_type_form_submit
field_ui_widget_type_form_submit($form, &$form_state)
Definition: field_ui.admin.inc:1697
$value
print $value
Definition: user-profile-item.tpl.php:26
field_form_set_state
field_form_set_state($parents, $field_name, $langcode, &$form_state, $field_state)
Definition: field.form.inc:527
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$output
$output
Definition: authorize.php:93
field_purge_batch
field_purge_batch($batch_size)
Definition: field.crud.inc:880
$depth
print $depth
Definition: book-node-export-html.tpl.php:21
_field_ui_add_default_view_mode_settings
_field_ui_add_default_view_mode_settings($entity_type, $bundle, $view_mode, &$settings)
Definition: field_ui.admin.inc:1412
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
FIELD_CARDINALITY_UNLIMITED
const FIELD_CARDINALITY_UNLIMITED
Definition: field.module:236
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
drupal_parse_url
drupal_parse_url($url)
Definition: common.inc:580
field_ui_fields_list
field_ui_fields_list()
Definition: field_ui.admin.inc:11
element_info_property
element_info_property($type, $property_name, $default=NULL)
Definition: common.inc:6337
field_form_get_state
field_form_get_state($parents, $field_name, $langcode, &$form_state)
Definition: field.form.inc:505
field_ui_field_edit_form_validate
field_ui_field_edit_form_validate($form, &$form_state)
Definition: field_ui.admin.inc:2013
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
field_info_bundles
field_info_bundles($entity_type=NULL)
Definition: field.info.inc:428
_field_ui_bundle_admin_path
_field_ui_bundle_admin_path($entity_type, $bundle_name)
Definition: field_ui.module:323
field_ui_table_pre_render
field_ui_table_pre_render($elements)
Definition: field_ui.admin.inc:128
field_ui_field_edit_form
field_ui_field_edit_form($form, &$form_state, $instance)
Definition: field_ui.admin.inc:1801
field_delete_instance
field_delete_instance($instance, $field_cleanup=TRUE)
Definition: field.crud.inc:768
field_update_instance
field_update_instance($instance)
Definition: field.crud.inc:553
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
field_info_max_weight
field_info_max_weight($entity_type, $bundle, $context)
Definition: field.info.inc:708
$children
print $children
Definition: book-node-export-html.tpl.php:24
$row
$row
Definition: block-admin-display-form.tpl.php:47
field_info_widget_types
field_info_widget_types($widget_type=NULL)
Definition: field.info.inc:354
field_info_formatter_settings
field_info_formatter_settings($type)
Definition: field.info.inc:789
field_bundle_settings
field_bundle_settings($entity_type, $bundle, $settings=NULL)
Definition: field.module:583
field_ui_field_delete_form
field_ui_field_delete_form($form, &$form_state, $instance)
Definition: field_ui.admin.inc:1730
field_ui_display_overview_form_submit
field_ui_display_overview_form_submit($form, &$form_state)
Definition: field_ui.admin.inc:1314
$tree
if($tree||$has_links) print $tree
Definition: book-navigation.tpl.php:35
field_update_field
field_update_field($field)
Definition: field.crud.inc:220
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
field_ui_field_overview_form_validate
field_ui_field_overview_form_validate($form, &$form_state)
Definition: field_ui.admin.inc:661
truncate_utf8
truncate_utf8($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
Definition: unicode.inc:316
drupal_html_class
drupal_html_class($class)
Definition: common.inc:3841
field_extract_bundle
field_extract_bundle($entity_type, $bundle)
Definition: field.module:1010
field_info_instance
field_info_instance($entity_type, $field_name, $bundle_name)
Definition: field.info.inc:623
field_ui_display_overview_multistep_js
field_ui_display_overview_multistep_js($form, &$form_state)
Definition: field_ui.admin.inc:1276
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.api.php Source File

  • modules
  • aggregator
aggregator.api.php
Go to the documentation of this file.
1 <?php
2
39 function hook_aggregator_fetch($feed) {
40 $feed->source_string = mymodule_fetch($feed->url);
41 }
42
61 function hook_aggregator_fetch_info() {
62 return array(
63 'title' => t('Default fetcher'),
64 'description' => t('Default fetcher for resources available by URL.'),
65 );
66 }
67
110 function hook_aggregator_parse($feed) {
111 if ($items = mymodule_parse($feed->source_string)) {
112 $feed->items = $items;
113 return TRUE;
114 }
115 return FALSE;
116 }
117
136 function hook_aggregator_parse_info() {
137 return array(
138 'title' => t('Default parser'),
139 'description' => t('Default parser for RSS, Atom and RDF feeds.'),
140 );
141 }
142
168 function hook_aggregator_process($feed) {
169 foreach ($feed->items as $item) {
170 mymodule_save($item);
171 }
172 }
173
192 function hook_aggregator_process_info() {
193 return array(
194 'title' => t('Default processor'),
195 'description' => t('Creates lightweight records of feed items.'),
196 );
197 }
198
214 function hook_aggregator_remove($feed) {
215 mymodule_remove_items($feed->fid);
216 }
217
hook_aggregator_process_info
hook_aggregator_process_info()
Definition: aggregator.api.php:192
hook_aggregator_fetch
hook_aggregator_fetch($feed)
Definition: aggregator.api.php:39
hook_aggregator_remove
hook_aggregator_remove($feed)
Definition: aggregator.api.php:214
hook_aggregator_process
hook_aggregator_process($feed)
Definition: aggregator.api.php:168
hook_aggregator_fetch_info
hook_aggregator_fetch_info()
Definition: aggregator.api.php:61
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
hook_aggregator_parse
hook_aggregator_parse($feed)
Definition: aggregator.api.php:110
hook_aggregator_parse_info
hook_aggregator_parse_info()
Definition: aggregator.api.php:136
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/contextual/contextual.module Source File

  • modules
  • contextual
contextual.module
Go to the documentation of this file.
1 <?php
2
11 function contextual_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#contextual':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t('The Contextual links module displays links related to regions of pages on your site to users with <em>access contextual links</em> permission. For more information, see the online handbook entry for <a href="@contextual">Contextual links module</a>.', array('@contextual' => 'http://drupal.org/documentation/modules/contextual')) . '</p>';
17 $output .= '<h3>' . t('Uses') . '</h3>';
18 $output .= '<dl>';
19 $output .= '<dt>' . t('Displaying contextual links') . '</dt>';
20 $output .= '<dd>' . t('Contextual links are supplied by modules, to give you quick access to tasks associated with regions of pages on your site. For instance, if you have a custom menu block displayed in a sidebar of your site, the Blocks and Menus modules will supply links to configure the block and edit the menu. The Contextual links module collects these links into a list for display by your theme, and also adds JavaScript code to the page to hide the links initially, and display them when your mouse hovers over the block.') . '</dd>';
21 $output .= '</dl>';
22 return $output;
23 }
24 }
25
29 function contextual_permission() {
30 return array(
31 'access contextual links' => array(
32 'title' => t('Use contextual links'),
33 'description' => t('Use contextual links to perform actions related to elements on a page.'),
34 ),
35 );
36 }
37
41 function contextual_library() {
42 $path = drupal_get_path('module', 'contextual');
43 $libraries['contextual-links'] = array(
44 'title' => 'Contextual links',
45 'website' => 'http://drupal.org/node/473268',
46 'version' => '1.0',
47 'js' => array(
48 $path . '/contextual.js' => array(),
49 ),
50 'css' => array(
51 $path . '/contextual.css' => array(),
52 ),
53 );
54 return $libraries;
55 }
56
60 function contextual_element_info() {
61 $types['contextual_links'] = array(
62 '#pre_render' => array('contextual_pre_render_links'),
63 '#theme' => 'links__contextual',
64 '#links' => array(),
65 '#prefix' => '<div class="contextual-links-wrapper">',
66 '#suffix' => '</div>',
67 '#attributes' => array(
68 'class' => array('contextual-links'),
69 ),
70 '#attached' => array(
71 'library' => array(
72 array('contextual', 'contextual-links'),
73 ),
74 ),
75 );
76 return $types;
77 }
78
84 function contextual_preprocess(&$variables, $hook) {
85 // Nothing to do here if the user is not permitted to access contextual links.
86 if (!user_access('access contextual links')) {
87 return;
88 }
89
90 $hooks = theme_get_registry(FALSE);
91
92 // Determine the primary theme function argument.
93 if (!empty($hooks[$hook]['variables'])) {
94 $keys = array_keys($hooks[$hook]['variables']);
95 $key = $keys[0];
96 }
97 elseif (!empty($hooks[$hook]['render element'])) {
98 $key = $hooks[$hook]['render element'];
99 }
100 if (!empty($key) && isset($variables[$key])) {
101 $element = $variables[$key];
102 }
103
104 if (isset($element) && is_array($element) && !empty($element['#contextual_links'])) {
105 // Initialize the template variable as a renderable array.
106 $variables['title_suffix']['contextual_links'] = array(
107 '#type' => 'contextual_links',
108 '#contextual_links' => $element['#contextual_links'],
109 '#element' => $element,
110 );
111 // Mark this element as potentially having contextual links attached to it.
112 $variables['classes_array'][] = 'contextual-links-region';
113 }
114 }
115
137 function contextual_pre_render_links($element) {
138 // Retrieve contextual menu links.
139 $items = array();
140 foreach ($element['#contextual_links'] as $module => $args) {
141 $items += menu_contextual_links($module, $args[0], $args[1]);
142 }
143
144 // Transform contextual links into parameters suitable for theme_link().
145 $links = array();
146 foreach ($items as $class => $item) {
147 $class = drupal_html_class($class);
148 $links[$class] = array(
149 'title' => $item['title'],
150 'href' => $item['href'],
151 );
152 // @todo theme_links() should *really* use the same parameters as l().
153 $item['localized_options'] += array('query' => array());
154 $item['localized_options']['query'] += drupal_get_destination();
155 $links[$class] += $item['localized_options'];
156 }
157 $element['#links'] = $links;
158
159 // Allow modules to alter the renderable contextual links element.
160 drupal_alter('contextual_links_view', $element, $items);
161
162 // If there are no links, tell drupal_render() to abort rendering.
163 if (empty($element['#links'])) {
164 $element['#printed'] = TRUE;
165 }
166
167 return $element;
168 }
169
contextual_help
contextual_help($path, $arg)
Definition: contextual.module:11
contextual_pre_render_links
contextual_pre_render_links($element)
Definition: contextual.module:137
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
$module
print $module
Definition: search-results.tpl.php:28
contextual_element_info
contextual_element_info()
Definition: contextual.module:60
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
contextual_library
contextual_library()
Definition: contextual.module:41
menu_contextual_links
menu_contextual_links($module, $parent_path, $args)
Definition: menu.inc:2159
theme_get_registry
theme_get_registry($complete=TRUE)
Definition: theme.inc:255
$output
$output
Definition: authorize.php:93
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
user_access
user_access($string, $account=NULL)
Definition: user.module:794
contextual_permission
contextual_permission()
Definition: contextual.module:29
contextual_preprocess
contextual_preprocess(&$variables, $hook)
Definition: contextual.module:84
$links
print $links
Definition: poll-results--block.tpl.php:28
drupal_html_class
drupal_html_class($class)
Definition: common.inc:3841
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/template.php Source File

  • themes
  • bartik
template.php
Go to the documentation of this file.
1 <?php
2
6 function bartik_preprocess_html(&$variables) {
7 if (!empty($variables['page']['featured'])) {
8 $variables['classes_array'][] = 'featured';
9 }
10
11 if (!empty($variables['page']['triptych_first'])
12 || !empty($variables['page']['triptych_middle'])
13 || !empty($variables['page']['triptych_last'])) {
14 $variables['classes_array'][] = 'triptych';
15 }
16
17 if (!empty($variables['page']['footer_firstcolumn'])
18 || !empty($variables['page']['footer_secondcolumn'])
19 || !empty($variables['page']['footer_thirdcolumn'])
20 || !empty($variables['page']['footer_fourthcolumn'])) {
21 $variables['classes_array'][] = 'footer-columns';
22 }
23
24 // Add conditional stylesheets for IE
25 drupal_add_css(path_to_theme() . '/css/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
26 drupal_add_css(path_to_theme() . '/css/ie6.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 6', '!IE' => FALSE), 'preprocess' => FALSE));
27 }
28
32 function bartik_process_html(&$variables) {
33 // Hook into color.module.
34 if (module_exists('color')) {
35 _color_html_alter($variables);
36 }
37 }
38
42 function bartik_process_page(&$variables) {
43 // Hook into color.module.
44 if (module_exists('color')) {
45 _color_page_alter($variables);
46 }
47 // Always print the site name and slogan, but if they are toggled off, we'll
48 // just hide them visually.
49 $variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
50 $variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
51 if ($variables['hide_site_name']) {
52 // If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
53 $variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
54 }
55 if ($variables['hide_site_slogan']) {
56 // If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
57 $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
58 }
59 // Since the title and the shortcut link are both block level elements,
60 // positioning them next to each other is much simpler with a wrapper div.
61 if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
62 // Add a wrapper div using the title_prefix and title_suffix render elements.
63 $variables['title_prefix']['shortcut_wrapper'] = array(
64 '#markup' => '<div class="shortcut-wrapper clearfix">',
65 '#weight' => 100,
66 );
67 $variables['title_suffix']['shortcut_wrapper'] = array(
68 '#markup' => '</div>',
69 '#weight' => -99,
70 );
71 // Make sure the shortcut link is the first item in title_suffix.
72 $variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
73 }
74 }
75
79 function bartik_preprocess_maintenance_page(&$variables) {
80 // By default, site_name is set to Drupal if no db connection is available
81 // or during site installation. Setting site_name to an empty string makes
82 // the site and update pages look cleaner.
83 // @see template_preprocess_maintenance_page
84 if (!$variables['db_is_active']) {
85 $variables['site_name'] = '';
86 }
87 drupal_add_css(drupal_get_path('theme', 'bartik') . '/css/maintenance-page.css');
88 }
89
93 function bartik_process_maintenance_page(&$variables) {
94 // Always print the site name and slogan, but if they are toggled off, we'll
95 // just hide them visually.
96 $variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
97 $variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
98 if ($variables['hide_site_name']) {
99 // If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
100 $variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
101 }
102 if ($variables['hide_site_slogan']) {
103 // If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
104 $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
105 }
106 }
107
111 function bartik_preprocess_node(&$variables) {
112 if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
113 $variables['classes_array'][] = 'node-full';
114 }
115 }
116
120 function bartik_preprocess_block(&$variables) {
121 // In the header region visually hide block titles.
122 if ($variables['block']->region == 'header') {
123 $variables['title_attributes_array']['class'][] = 'element-invisible';
124 }
125 }
126
130 function bartik_menu_tree($variables) {
131 return '<ul class="menu clearfix">' . $variables['tree'] . '</ul>';
132 }
133
137 function bartik_field__taxonomy_term_reference($variables) {
138 $output = '';
139
140 // Render the label, if it's not hidden.
141 if (!$variables['label_hidden']) {
142 $output .= '<h3 class="field-label">' . $variables['label'] . ': </h3>';
143 }
144
145 // Render the items.
146 $output .= ($variables['element']['#label_display'] == 'inline') ? '<ul class="links inline">' : '<ul class="links">';
147 foreach ($variables['items'] as $delta => $item) {
148 $output .= '<li class="taxonomy-term-reference-' . $delta . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</li>';
149 }
150 $output .= '</ul>';
151
152 // Render the top-level DIV.
153 $output = '<div class="' . $variables['classes'] . (!in_array('clearfix', $variables['classes_array']) ? ' clearfix' : '') . '"' . $variables['attributes'] .'>' . $output . '</div>';
154
155 return $output;
156 }
bartik_process_page
bartik_process_page(&$variables)
Definition: template.php:42
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
bartik_menu_tree
bartik_menu_tree($variables)
Definition: template.php:130
bartik_process_html
bartik_process_html(&$variables)
Definition: template.php:32
bartik_preprocess_html
bartik_preprocess_html(&$variables)
Definition: template.php:6
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
path_to_theme
path_to_theme()
Definition: theme.inc:1219
bartik_process_maintenance_page
bartik_process_maintenance_page(&$variables)
Definition: template.php:93
module_exists
module_exists($module)
Definition: module.inc:274
node_is_page
node_is_page($node)
Definition: node.module:1487
bartik_preprocess_node
bartik_preprocess_node(&$variables)
Definition: template.php:111
CSS_THEME
const CSS_THEME
Definition: common.inc:70
bartik_preprocess_maintenance_page
bartik_preprocess_maintenance_page(&$variables)
Definition: template.php:79
bartik_preprocess_block
bartik_preprocess_block(&$variables)
Definition: template.php:120
$output
$output
Definition: authorize.php:93
theme_get_setting
theme_get_setting($setting_name, $theme=NULL)
Definition: theme.inc:1401
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
bartik_field__taxonomy_term_reference
bartik_field__taxonomy_term_reference($variables)
Definition: template.php:137
_color_page_alter
_color_page_alter(&$vars)
Definition: color.module:120
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
_color_html_alter
_color_html_alter(&$vars)
Definition: color.module:85
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/rdf/rdf.install Source File

  • modules
  • rdf
rdf.install
Go to the documentation of this file.
1 <?php
2
11 function rdf_schema() {
12 $schema['rdf_mapping'] = array(
13 'description' => 'Stores custom RDF mappings for user defined content types or overriden module-defined mappings',
14 'fields' => array(
15 'type' => array(
16 'type' => 'varchar',
17 'length' => 128,
18 'not null' => TRUE,
19 'description' => 'The name of the entity type a mapping applies to (node, user, comment, etc.).',
20 ),
21 'bundle' => array(
22 'type' => 'varchar',
23 'length' => 128,
24 'not null' => TRUE,
25 'description' => 'The name of the bundle a mapping applies to.',
26 ),
27 'mapping' => array(
28 'description' => 'The serialized mapping of the bundle type and fields to RDF terms.',
29 'type' => 'blob',
30 'not null' => FALSE,
31 'size' => 'big',
32 'serialize' => TRUE,
33 ),
34 ),
35 'primary key' => array('type', 'bundle'),
36 );
37
38 return $schema;
39 }
40
44 function rdf_install() {
45 // Collect any RDF mappings that were declared by modules installed before
46 // this one.
47 $modules = module_implements('rdf_mapping');
48 rdf_modules_installed($modules);
49 }
rdf_install
rdf_install()
Definition: rdf.install:44
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
rdf_schema
rdf_schema()
Definition: rdf.install:11
rdf_modules_installed
rdf_modules_installed($modules)
Definition: rdf.module:336
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/theme.inc Source File

  • includes
theme.inc
Go to the documentation of this file.
1 <?php
2
21 define('MARK_READ', 0);
22
26 define('MARK_NEW', 1);
27
31 define('MARK_UPDATED', 2);
32
47 function drupal_theme_access($theme) {
48 if (is_object($theme)) {
49 return _drupal_theme_access($theme);
50 }
51 else {
52 $themes = list_themes();
53 return isset($themes[$theme]) && _drupal_theme_access($themes[$theme]);
54 }
55 }
56
62 function _drupal_theme_access($theme) {
63 $admin_theme = variable_get('admin_theme');
64 return !empty($theme->status) || ($admin_theme && $theme->name == $admin_theme);
65 }
66
70 function drupal_theme_initialize() {
71 global $theme, $user, $theme_key;
72
73 // If $theme is already set, assume the others are set, too, and do nothing
74 if (isset($theme)) {
75 return;
76 }
77
78 drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
79 $themes = list_themes();
80
81 // Only select the user selected theme if it is available in the
82 // list of themes that can be accessed.
83 $theme = !empty($user->theme) && drupal_theme_access($user->theme) ? $user->theme : variable_get('theme_default', 'bartik');
84
85 // Allow modules to override the theme. Validation has already been performed
86 // inside menu_get_custom_theme(), so we do not need to check it again here.
87 $custom_theme = menu_get_custom_theme();
88 $theme = !empty($custom_theme) ? $custom_theme : $theme;
89
90 // Store the identifier for retrieving theme settings with.
91 $theme_key = $theme;
92
93 // Find all our ancestor themes and put them in an array.
94 $base_theme = array();
95 $ancestor = $theme;
96 while ($ancestor && isset($themes[$ancestor]->base_theme)) {
97 $ancestor = $themes[$ancestor]->base_theme;
98 $base_theme[] = $themes[$ancestor];
99 }
100 _drupal_theme_initialize($themes[$theme], array_reverse($base_theme));
101
102 // Themes can have alter functions, so reset the drupal_alter() cache.
103 drupal_static_reset('drupal_alter');
104
105 // Provide the page with information about the theme that's used, so that a
106 // later Ajax request can be rendered using the same theme.
107 // @see ajax_base_page_theme()
108 $setting['ajaxPageState'] = array(
109 'theme' => $theme_key,
110 'theme_token' => drupal_get_token($theme_key),
111 );
112 drupal_add_js($setting, 'setting');
113 }
114
141 function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callback = '_theme_load_registry') {
142 global $theme_info, $base_theme_info, $theme_engine, $theme_path;
143 $theme_info = $theme;
144 $base_theme_info = $base_theme;
145
146 $theme_path = dirname($theme->filename);
147
148 // Prepare stylesheets from this theme as well as all ancestor themes.
149 // We work it this way so that we can have child themes override parent
150 // theme stylesheets easily.
151 $final_stylesheets = array();
152
153 // Grab stylesheets from base theme
154 foreach ($base_theme as $base) {
155 if (!empty($base->stylesheets)) {
156 foreach ($base->stylesheets as $media => $stylesheets) {
157 foreach ($stylesheets as $name => $stylesheet) {
158 $final_stylesheets[$media][$name] = $stylesheet;
159 }
160 }
161 }
162 }
163
164 // Add stylesheets used by this theme.
165 if (!empty($theme->stylesheets)) {
166 foreach ($theme->stylesheets as $media => $stylesheets) {
167 foreach ($stylesheets as $name => $stylesheet) {
168 $final_stylesheets[$media][$name] = $stylesheet;
169 }
170 }
171 }
172
173 // And now add the stylesheets properly
174 foreach ($final_stylesheets as $media => $stylesheets) {
175 foreach ($stylesheets as $stylesheet) {
176 drupal_add_css($stylesheet, array('group' => CSS_THEME, 'every_page' => TRUE, 'media' => $media));
177 }
178 }
179
180 // Do basically the same as the above for scripts
181 $final_scripts = array();
182
183 // Grab scripts from base theme
184 foreach ($base_theme as $base) {
185 if (!empty($base->scripts)) {
186 foreach ($base->scripts as $name => $script) {
187 $final_scripts[$name] = $script;
188 }
189 }
190 }
191
192 // Add scripts used by this theme.
193 if (!empty($theme->scripts)) {
194 foreach ($theme->scripts as $name => $script) {
195 $final_scripts[$name] = $script;
196 }
197 }
198
199 // Add scripts used by this theme.
200 foreach ($final_scripts as $script) {
201 drupal_add_js($script, array('group' => JS_THEME, 'every_page' => TRUE));
202 }
203
204 $theme_engine = NULL;
205
206 // Initialize the theme.
207 if (isset($theme->engine)) {
208 // Include the engine.
209 include_once DRUPAL_ROOT . '/' . $theme->owner;
210
211 $theme_engine = $theme->engine;
212 if (function_exists($theme_engine . '_init')) {
213 foreach ($base_theme as $base) {
214 call_user_func($theme_engine . '_init', $base);
215 }
216 call_user_func($theme_engine . '_init', $theme);
217 }
218 }
219 else {
220 // include non-engine theme files
221 foreach ($base_theme as $base) {
222 // Include the theme file or the engine.
223 if (!empty($base->owner)) {
224 include_once DRUPAL_ROOT . '/' . $base->owner;
225 }
226 }
227 // and our theme gets one too.
228 if (!empty($theme->owner)) {
229 include_once DRUPAL_ROOT . '/' . $theme->owner;
230 }
231 }
232
233 if (isset($registry_callback)) {
234 _theme_registry_callback($registry_callback, array($theme, $base_theme, $theme_engine));
235 }
236 }
237
255 function theme_get_registry($complete = TRUE) {
256 // Use the advanced drupal_static() pattern, since this is called very often.
257 static $drupal_static_fast;
258 if (!isset($drupal_static_fast)) {
259 $drupal_static_fast['registry'] = &drupal_static('theme_get_registry');
260 }
261 $theme_registry = &$drupal_static_fast['registry'];
262
263 // Initialize the theme, if this is called early in the bootstrap, or after
264 // static variables have been reset.
265 if (!is_array($theme_registry)) {
266 drupal_theme_initialize();
267 $theme_registry = array();
268 }
269
270 $key = (int) $complete;
271
272 if (!isset($theme_registry[$key])) {
273 list($callback, $arguments) = _theme_registry_callback();
274 if (!$complete) {
275 $arguments[] = FALSE;
276 }
277 $theme_registry[$key] = call_user_func_array($callback, $arguments);
278 }
279
280 return $theme_registry[$key];
281 }
282
291 function _theme_registry_callback($callback = NULL, array $arguments = array()) {
292 static $stored;
293 if (isset($callback)) {
294 $stored = array($callback, $arguments);
295 }
296 return $stored;
297 }
298
316 function _theme_load_registry($theme, $base_theme = NULL, $theme_engine = NULL, $complete = TRUE) {
317 if ($complete) {
318 // Check the theme registry cache; if it exists, use it.
319 $cached = cache_get("theme_registry:$theme->name");
320 if (isset($cached->data)) {
321 $registry = $cached->data;
322 }
323 else {
324 // If not, build one and cache it.
325 $registry = _theme_build_registry($theme, $base_theme, $theme_engine);
326 // Only persist this registry if all modules are loaded. This assures a
327 // complete set of theme hooks.
328 if (module_load_all(NULL)) {
329 _theme_save_registry($theme, $registry);
330 }
331 }
332 return $registry;
333 }
334 else {
335 return new ThemeRegistry('theme_registry:runtime:' . $theme->name, 'cache');
336 }
337 }
338
342 function _theme_save_registry($theme, $registry) {
343 cache_set("theme_registry:$theme->name", $registry);
344 }
345
352 function drupal_theme_rebuild() {
353 drupal_static_reset('theme_get_registry');
354 cache_clear_all('theme_registry', 'cache', TRUE);
355 }
356
365 class ThemeRegistry Extends DrupalCacheArray {
366
374 protected $persistable;
375
379 protected $completeRegistry;
380
381 function __construct($cid, $bin) {
382 $this->cid = $cid;
383 $this->bin = $bin;
384 $this->persistable = module_load_all(NULL) && $_SERVER['REQUEST_METHOD'] == 'GET';
385
386 $data = array();
387 if ($this->persistable && $cached = cache_get($this->cid, $this->bin)) {
388 $data = $cached->data;
389 }
390 else {
391 // If there is no runtime cache stored, fetch the full theme registry,
392 // but then initialize each value to NULL. This allows offsetExists()
393 // to function correctly on non-registered theme hooks without triggering
394 // a call to resolveCacheMiss().
395 $data = $this->initializeRegistry();
396 if ($this->persistable) {
397 $this->set($data);
398 }
399 }
400 $this->storage = $data;
401 }
402
410 function initializeRegistry() {
411 $this->completeRegistry = theme_get_registry();
412
413 return array_fill_keys(array_keys($this->completeRegistry), NULL);
414 }
415
416 public function offsetExists($offset) {
417 // Since the theme registry allows for theme hooks to be requested that
418 // are not registered, just check the existence of the key in the registry.
419 // Use array_key_exists() here since a NULL value indicates that the theme
420 // hook exists but has not yet been requested.
421 return array_key_exists($offset, $this->storage);
422 }
423
424 public function offsetGet($offset) {
425 // If the offset is set but empty, it is a registered theme hook that has
426 // not yet been requested. Offsets that do not exist at all were not
427 // registered in hook_theme().
428 if (isset($this->storage[$offset])) {
429 return $this->storage[$offset];
430 }
431 elseif (array_key_exists($offset, $this->storage)) {
432 return $this->resolveCacheMiss($offset);
433 }
434 }
435
436 public function resolveCacheMiss($offset) {
437 if (!isset($this->completeRegistry)) {
438 $this->completeRegistry = theme_get_registry();
439 }
440 $this->storage[$offset] = $this->completeRegistry[$offset];
441 if ($this->persistable) {
442 $this->persist($offset);
443 }
444 return $this->storage[$offset];
445 }
446
447 public function set($data, $lock = TRUE) {
448 $lock_name = $this->cid . ':' . $this->bin;
449 if (!$lock || lock_acquire($lock_name)) {
450 if ($cached = cache_get($this->cid, $this->bin)) {
451 // Use array merge instead of union so that filled in values in $data
452 // overwrite empty values in the current cache.
453 $data = array_merge($cached->data, $data);
454 }
455 else {
456 $registry = $this->initializeRegistry();
457 $data = array_merge($registry, $data);
458 }
459 cache_set($this->cid, $data, $this->bin);
460 if ($lock) {
461 lock_release($lock_name);
462 }
463 }
464 }
465 }
466
515 function _theme_process_registry(&$cache, $name, $type, $theme, $path) {
516 $result = array();
517
518 // Processor functions work in two distinct phases with the process
519 // functions always being executed after the preprocess functions.
520 $variable_process_phases = array(
521 'preprocess functions' => 'preprocess',
522 'process functions' => 'process',
523 );
524
525 $hook_defaults = array(
526 'variables' => TRUE,
527 'render element' => TRUE,
528 'pattern' => TRUE,
529 'base hook' => TRUE,
530 );
531
532 // Invoke the hook_theme() implementation, process what is returned, and
533 // merge it into $cache.
534 $function = $name . '_theme';
535 if (function_exists($function)) {
536 $result = $function($cache, $type, $theme, $path);
537 foreach ($result as $hook => $info) {
538 // When a theme or engine overrides a module's theme function
539 // $result[$hook] will only contain key/value pairs for information being
540 // overridden. Pull the rest of the information from what was defined by
541 // an earlier hook.
542
543 // Fill in the type and path of the module, theme, or engine that
544 // implements this theme function.
545 $result[$hook]['type'] = $type;
546 $result[$hook]['theme path'] = $path;
547
548 // If function and file are omitted, default to standard naming
549 // conventions.
550 if (!isset($info['template']) && !isset($info['function'])) {
551 $result[$hook]['function'] = ($type == 'module' ? 'theme_' : $name . '_') . $hook;
552 }
553
554 if (isset($cache[$hook]['includes'])) {
555 $result[$hook]['includes'] = $cache[$hook]['includes'];
556 }
557
558 // If the theme implementation defines a file, then also use the path
559 // that it defined. Otherwise use the default path. This allows
560 // system.module to declare theme functions on behalf of core .include
561 // files.
562 if (isset($info['file'])) {
563 $include_file = isset($info['path']) ? $info['path'] : $path;
564 $include_file .= '/' . $info['file'];
565 include_once DRUPAL_ROOT . '/' . $include_file;
566 $result[$hook]['includes'][] = $include_file;
567 }
568
569 // If the default keys are not set, use the default values registered
570 // by the module.
571 if (isset($cache[$hook])) {
572 $result[$hook] += array_intersect_key($cache[$hook], $hook_defaults);
573 }
574
575 // The following apply only to theming hooks implemented as templates.
576 if (isset($info['template'])) {
577 // Prepend the current theming path when none is set.
578 if (!isset($info['path'])) {
579 $result[$hook]['template'] = $path . '/' . $info['template'];
580 }
581 }
582
583 // Allow variable processors for all theming hooks, whether the hook is
584 // implemented as a template or as a function.
585 foreach ($variable_process_phases as $phase_key => $phase) {
586 // Check for existing variable processors. Ensure arrayness.
587 if (!isset($info[$phase_key]) || !is_array($info[$phase_key])) {
588 $info[$phase_key] = array();
589 $prefixes = array();
590 if ($type == 'module') {
591 // Default variable processor prefix.
592 $prefixes[] = 'template';
593 // Add all modules so they can intervene with their own variable
594 // processors. This allows them to provide variable processors even
595 // if they are not the owner of the current hook.
596 $prefixes += module_list();
597 }
598 elseif ($type == 'theme_engine' || $type == 'base_theme_engine') {
599 // Theme engines get an extra set that come before the normally
600 // named variable processors.
601 $prefixes[] = $name . '_engine';
602 // The theme engine registers on behalf of the theme using the
603 // theme's name.
604 $prefixes[] = $theme;
605 }
606 else {
607 // This applies when the theme manually registers their own variable
608 // processors.
609 $prefixes[] = $name;
610 }
611 foreach ($prefixes as $prefix) {
612 // Only use non-hook-specific variable processors for theming hooks
613 // implemented as templates. See theme().
614 if (isset($info['template']) && function_exists($prefix . '_' . $phase)) {
615 $info[$phase_key][] = $prefix . '_' . $phase;
616 }
617 if (function_exists($prefix . '_' . $phase . '_' . $hook)) {
618 $info[$phase_key][] = $prefix . '_' . $phase . '_' . $hook;
619 }
620 }
621 }
622 // Check for the override flag and prevent the cached variable
623 // processors from being used. This allows themes or theme engines to
624 // remove variable processors set earlier in the registry build.
625 if (!empty($info['override ' . $phase_key])) {
626 // Flag not needed inside the registry.
627 unset($result[$hook]['override ' . $phase_key]);
628 }
629 elseif (isset($cache[$hook][$phase_key]) && is_array($cache[$hook][$phase_key])) {
630 $info[$phase_key] = array_merge($cache[$hook][$phase_key], $info[$phase_key]);
631 }
632 $result[$hook][$phase_key] = $info[$phase_key];
633 }
634 }
635
636 // Merge the newly created theme hooks into the existing cache.
637 $cache = $result + $cache;
638 }
639
640 // Let themes have variable processors even if they didn't register a
641 // template.
642 if ($type == 'theme' || $type == 'base_theme') {
643 foreach ($cache as $hook => $info) {
644 // Check only if not registered by the theme or engine.
645 if (empty($result[$hook])) {
646 foreach ($variable_process_phases as $phase_key => $phase) {
647 if (!isset($info[$phase_key])) {
648 $cache[$hook][$phase_key] = array();
649 }
650 // Only use non-hook-specific variable processors for theming hooks
651 // implemented as templates. See theme().
652 if (isset($info['template']) && function_exists($name . '_' . $phase)) {
653 $cache[$hook][$phase_key][] = $name . '_' . $phase;
654 }
655 if (function_exists($name . '_' . $phase . '_' . $hook)) {
656 $cache[$hook][$phase_key][] = $name . '_' . $phase . '_' . $hook;
657 $cache[$hook]['theme path'] = $path;
658 }
659 // Ensure uniqueness.
660 $cache[$hook][$phase_key] = array_unique($cache[$hook][$phase_key]);
661 }
662 }
663 }
664 }
665 }
666
678 function _theme_build_registry($theme, $base_theme, $theme_engine) {
679 $cache = array();
680 // First, process the theme hooks advertised by modules. This will
681 // serve as the basic registry. Since the list of enabled modules is the same
682 // regardless of the theme used, this is cached in its own entry to save
683 // building it for every theme.
684 if ($cached = cache_get('theme_registry:build:modules')) {
685 $cache = $cached->data;
686 }
687 else {
688 foreach (module_implements('theme') as $module) {
689 _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module));
690 }
691 // Only cache this registry if all modules are loaded.
692 if (module_load_all(NULL)) {
693 cache_set('theme_registry:build:modules', $cache);
694 }
695 }
696
697 // Process each base theme.
698 foreach ($base_theme as $base) {
699 // If the base theme uses a theme engine, process its hooks.
700 $base_path = dirname($base->filename);
701 if ($theme_engine) {
702 _theme_process_registry($cache, $theme_engine, 'base_theme_engine', $base->name, $base_path);
703 }
704 _theme_process_registry($cache, $base->name, 'base_theme', $base->name, $base_path);
705 }
706
707 // And then the same thing, but for the theme.
708 if ($theme_engine) {
709 _theme_process_registry($cache, $theme_engine, 'theme_engine', $theme->name, dirname($theme->filename));
710 }
711
712 // Finally, hooks provided by the theme itself.
713 _theme_process_registry($cache, $theme->name, 'theme', $theme->name, dirname($theme->filename));
714
715 // Let modules alter the registry.
716 drupal_alter('theme_registry', $cache);
717
718 // Optimize the registry to not have empty arrays for functions.
719 foreach ($cache as $hook => $info) {
720 foreach (array('preprocess functions', 'process functions') as $phase) {
721 if (empty($info[$phase])) {
722 unset($cache[$hook][$phase]);
723 }
724 }
725 }
726 return $cache;
727 }
728
774 function list_themes($refresh = FALSE) {
775 $list = &drupal_static(__FUNCTION__, array());
776
777 if ($refresh) {
778 $list = array();
779 system_list_reset();
780 }
781
782 if (empty($list)) {
783 $list = array();
784 $themes = array();
785 // Extract from the database only when it is available.
786 // Also check that the site is not in the middle of an install or update.
787 if (!defined('MAINTENANCE_MODE')) {
788 try {
789 $themes = system_list('theme');
790 }
791 catch (Exception $e) {
792 // If the database is not available, rebuild the theme data.
793 $themes = _system_rebuild_theme_data();
794 }
795 }
796 else {
797 // Scan the installation when the database should not be read.
798 $themes = _system_rebuild_theme_data();
799 }
800
801 foreach ($themes as $theme) {
802 foreach ($theme->info['stylesheets'] as $media => $stylesheets) {
803 foreach ($stylesheets as $stylesheet => $path) {
804 $theme->stylesheets[$media][$stylesheet] = $path;
805 }
806 }
807 foreach ($theme->info['scripts'] as $script => $path) {
808 $theme->scripts[$script] = $path;
809 }
810 if (isset($theme->info['engine'])) {
811 $theme->engine = $theme->info['engine'];
812 }
813 if (isset($theme->info['base theme'])) {
814 $theme->base_theme = $theme->info['base theme'];
815 }
816 // Status is normally retrieved from the database. Add zero values when
817 // read from the installation directory to prevent notices.
818 if (!isset($theme->status)) {
819 $theme->status = 0;
820 }
821 $list[$theme->name] = $theme;
822 }
823 }
824
825 return $list;
826 }
827
843 function drupal_find_base_themes($themes, $key, $used_keys = array()) {
844 $base_key = $themes[$key]->info['base theme'];
845 // Does the base theme exist?
846 if (!isset($themes[$base_key])) {
847 return array($base_key => NULL);
848 }
849
850 $current_base_theme = array($base_key => $themes[$base_key]->info['name']);
851
852 // Is the base theme itself a child of another theme?
853 if (isset($themes[$base_key]->info['base theme'])) {
854 // Do we already know the base themes of this theme?
855 if (isset($themes[$base_key]->base_themes)) {
856 return $themes[$base_key]->base_themes + $current_base_theme;
857 }
858 // Prevent loops.
859 if (!empty($used_keys[$base_key])) {
860 return array($base_key => NULL);
861 }
862 $used_keys[$base_key] = TRUE;
863 return drupal_find_base_themes($themes, $base_key, $used_keys) + $current_base_theme;
864 }
865 // If we get here, then this is our parent theme.
866 return $current_base_theme;
867 }
868
1012 function theme($hook, $variables = array()) {
1013 // If called before all modules are loaded, we do not necessarily have a full
1014 // theme registry to work with, and therefore cannot process the theme
1015 // request properly. See also _theme_load_registry().
1016 if (!module_load_all(NULL) && !defined('MAINTENANCE_MODE')) {
1017 throw new Exception(t('theme() may not be called until all modules are loaded.'));
1018 }
1019
1020 $hooks = theme_get_registry(FALSE);
1021
1022 // If an array of hook candidates were passed, use the first one that has an
1023 // implementation.
1024 if (is_array($hook)) {
1025 foreach ($hook as $candidate) {
1026 if (isset($hooks[$candidate])) {
1027 break;
1028 }
1029 }
1030 $hook = $candidate;
1031 }
1032
1033 // If there's no implementation, check for more generic fallbacks. If there's
1034 // still no implementation, log an error and return an empty string.
1035 if (!isset($hooks[$hook])) {
1036 // Iteratively strip everything after the last '__' delimiter, until an
1037 // implementation is found.
1038 while ($pos = strrpos($hook, '__')) {
1039 $hook = substr($hook, 0, $pos);
1040 if (isset($hooks[$hook])) {
1041 break;
1042 }
1043 }
1044 if (!isset($hooks[$hook])) {
1045 // Only log a message when not trying theme suggestions ($hook being an
1046 // array).
1047 if (!isset($candidate)) {
1048 watchdog('theme', 'Theme hook %hook not found.', array('%hook' => $hook), WATCHDOG_WARNING);
1049 }
1050 return '';
1051 }
1052 }
1053
1054 $info = $hooks[$hook];
1055 global $theme_path;
1056 $temp = $theme_path;
1057 // point path_to_theme() to the currently used theme path:
1058 $theme_path = $info['theme path'];
1059
1060 // Include a file if the theme function or variable processor is held
1061 // elsewhere.
1062 if (!empty($info['includes'])) {
1063 foreach ($info['includes'] as $include_file) {
1064 include_once DRUPAL_ROOT . '/' . $include_file;
1065 }
1066 }
1067
1068 // If a renderable array is passed as $variables, then set $variables to
1069 // the arguments expected by the theme function.
1070 if (isset($variables['#theme']) || isset($variables['#theme_wrappers'])) {
1071 $element = $variables;
1072 $variables = array();
1073 if (isset($info['variables'])) {
1074 foreach (array_keys($info['variables']) as $name) {
1075 if (isset($element["#$name"])) {
1076 $variables[$name] = $element["#$name"];
1077 }
1078 }
1079 }
1080 else {
1081 $variables[$info['render element']] = $element;
1082 }
1083 }
1084
1085 // Merge in argument defaults.
1086 if (!empty($info['variables'])) {
1087 $variables += $info['variables'];
1088 }
1089 elseif (!empty($info['render element'])) {
1090 $variables += array($info['render element'] => array());
1091 }
1092
1093 // Invoke the variable processors, if any. The processors may specify
1094 // alternate suggestions for which hook's template/function to use. If the
1095 // hook is a suggestion of a base hook, invoke the variable processors of
1096 // the base hook, but retain the suggestion as a high priority suggestion to
1097 // be used unless overridden by a variable processor function.
1098 if (isset($info['base hook'])) {
1099 $base_hook = $info['base hook'];
1100 $base_hook_info = $hooks[$base_hook];
1101 // Include files required by the base hook, since its variable processors
1102 // might reside there.
1103 if (!empty($base_hook_info['includes'])) {
1104 foreach ($base_hook_info['includes'] as $include_file) {
1105 include_once DRUPAL_ROOT . '/' . $include_file;
1106 }
1107 }
1108 if (isset($base_hook_info['preprocess functions']) || isset($base_hook_info['process functions'])) {
1109 $variables['theme_hook_suggestion'] = $hook;
1110 $hook = $base_hook;
1111 $info = $base_hook_info;
1112 }
1113 }
1114 if (isset($info['preprocess functions']) || isset($info['process functions'])) {
1115 $variables['theme_hook_suggestions'] = array();
1116 foreach (array('preprocess functions', 'process functions') as $phase) {
1117 if (!empty($info[$phase])) {
1118 foreach ($info[$phase] as $processor_function) {
1119 if (function_exists($processor_function)) {
1120 // We don't want a poorly behaved process function changing $hook.
1121 $hook_clone = $hook;
1122 $processor_function($variables, $hook_clone);
1123 }
1124 }
1125 }
1126 }
1127 // If the preprocess/process functions specified hook suggestions, and the
1128 // suggestion exists in the theme registry, use it instead of the hook that
1129 // theme() was called with. This allows the preprocess/process step to
1130 // route to a more specific theme hook. For example, a function may call
1131 // theme('node', ...), but a preprocess function can add 'node__article' as
1132 // a suggestion, enabling a theme to have an alternate template file for
1133 // article nodes. Suggestions are checked in the following order:
1134 // - The 'theme_hook_suggestion' variable is checked first. It overrides
1135 // all others.
1136 // - The 'theme_hook_suggestions' variable is checked in FILO order, so the
1137 // last suggestion added to the array takes precedence over suggestions
1138 // added earlier.
1139 $suggestions = array();
1140 if (!empty($variables['theme_hook_suggestions'])) {
1141 $suggestions = $variables['theme_hook_suggestions'];
1142 }
1143 if (!empty($variables['theme_hook_suggestion'])) {
1144 $suggestions[] = $variables['theme_hook_suggestion'];
1145 }
1146 foreach (array_reverse($suggestions) as $suggestion) {
1147 if (isset($hooks[$suggestion])) {
1148 $info = $hooks[$suggestion];
1149 break;
1150 }
1151 }
1152 }
1153
1154 // Generate the output using either a function or a template.
1155 $output = '';
1156 if (isset($info['function'])) {
1157 if (function_exists($info['function'])) {
1158 $output = $info['function']($variables);
1159 }
1160 }
1161 else {
1162 // Default render function and extension.
1163 $render_function = 'theme_render_template';
1164 $extension = '.tpl.php';
1165
1166 // The theme engine may use a different extension and a different renderer.
1167 global $theme_engine;
1168 if (isset($theme_engine)) {
1169 if ($info['type'] != 'module') {
1170 if (function_exists($theme_engine . '_render_template')) {
1171 $render_function = $theme_engine . '_render_template';
1172 }
1173 $extension_function = $theme_engine . '_extension';
1174 if (function_exists($extension_function)) {
1175 $extension = $extension_function();
1176 }
1177 }
1178 }
1179
1180 // In some cases, a template implementation may not have had
1181 // template_preprocess() run (for example, if the default implementation is
1182 // a function, but a template overrides that default implementation). In
1183 // these cases, a template should still be able to expect to have access to
1184 // the variables provided by template_preprocess(), so we add them here if
1185 // they don't already exist. We don't want to run template_preprocess()
1186 // twice (it would be inefficient and mess up zebra striping), so we use the
1187 // 'directory' variable to determine if it has already run, which while not
1188 // completely intuitive, is reasonably safe, and allows us to save on the
1189 // overhead of adding some new variable to track that.
1190 if (!isset($variables['directory'])) {
1191 $default_template_variables = array();
1192 template_preprocess($default_template_variables, $hook);
1193 $variables += $default_template_variables;
1194 }
1195
1196 // Render the output using the template file.
1197 $template_file = $info['template'] . $extension;
1198 if (isset($info['path'])) {
1199 $template_file = $info['path'] . '/' . $template_file;
1200 }
1201 $output = $render_function($template_file, $variables);
1202 }
1203
1204 // restore path_to_theme()
1205 $theme_path = $temp;
1206 return $output;
1207 }
1208
1219 function path_to_theme() {
1220 global $theme_path;
1221
1222 if (!isset($theme_path)) {
1223 drupal_theme_initialize();
1224 }
1225
1226 return $theme_path;
1227 }
1228
1240 function drupal_find_theme_functions($cache, $prefixes) {
1241 $implementations = array();
1242 $functions = get_defined_functions();
1243
1244 foreach ($cache as $hook => $info) {
1245 foreach ($prefixes as $prefix) {
1246 // Find theme functions that implement possible "suggestion" variants of
1247 // registered theme hooks and add those as new registered theme hooks.
1248 // The 'pattern' key defines a common prefix that all suggestions must
1249 // start with. The default is the name of the hook followed by '__'. An
1250 // 'base hook' key is added to each entry made for a found suggestion,
1251 // so that common functionality can be implemented for all suggestions of
1252 // the same base hook. To keep things simple, deep hierarchy of
1253 // suggestions is not supported: each suggestion's 'base hook' key
1254 // refers to a base hook, not to another suggestion, and all suggestions
1255 // are found using the base hook's pattern, not a pattern from an
1256 // intermediary suggestion.
1257 $pattern = isset($info['pattern']) ? $info['pattern'] : ($hook . '__');
1258 if (!isset($info['base hook']) && !empty($pattern)) {
1259 $matches = preg_grep('/^' . $prefix . '_' . $pattern . '/', $functions['user']);
1260 if ($matches) {
1261 foreach ($matches as $match) {
1262 $new_hook = substr($match, strlen($prefix) + 1);
1263 $arg_name = isset($info['variables']) ? 'variables' : 'render element';
1264 $implementations[$new_hook] = array(
1265 'function' => $match,
1266 $arg_name => $info[$arg_name],
1267 'base hook' => $hook,
1268 );
1269 }
1270 }
1271 }
1272 // Find theme functions that implement registered theme hooks and include
1273 // that in what is returned so that the registry knows that the theme has
1274 // this implementation.
1275 if (function_exists($prefix . '_' . $hook)) {
1276 $implementations[$hook] = array(
1277 'function' => $prefix . '_' . $hook,
1278 );
1279 }
1280 }
1281 }
1282
1283 return $implementations;
1284 }
1285
1296 function drupal_find_theme_templates($cache, $extension, $path) {
1297 $implementations = array();
1298
1299 // Collect paths to all sub-themes grouped by base themes. These will be
1300 // used for filtering. This allows base themes to have sub-themes in its
1301 // folder hierarchy without affecting the base themes template discovery.
1302 $theme_paths = array();
1303 foreach (list_themes() as $theme_info) {
1304 if (!empty($theme_info->base_theme)) {
1305 $theme_paths[$theme_info->base_theme][$theme_info->name] = dirname($theme_info->filename);
1306 }
1307 }
1308 foreach ($theme_paths as $basetheme => $subthemes) {
1309 foreach ($subthemes as $subtheme => $subtheme_path) {
1310 if (isset($theme_paths[$subtheme])) {
1311 $theme_paths[$basetheme] = array_merge($theme_paths[$basetheme], $theme_paths[$subtheme]);
1312 }
1313 }
1314 }
1315 global $theme;
1316 $subtheme_paths = isset($theme_paths[$theme]) ? $theme_paths[$theme] : array();
1317
1318 // Escape the periods in the extension.
1319 $regex = '/' . str_replace('.', '\.', $extension) . '$/';
1320 // Get a listing of all template files in the path to search.
1321 $files = drupal_system_listing($regex, $path, 'name', 0);
1322
1323 // Find templates that implement registered theme hooks and include that in
1324 // what is returned so that the registry knows that the theme has this
1325 // implementation.
1326 foreach ($files as $template => $file) {
1327 // Ignore sub-theme templates for the current theme.
1328 if (strpos($file->uri, str_replace($subtheme_paths, '', $file->uri)) !== 0) {
1329 continue;
1330 }
1331 // Chop off the remaining extensions if there are any. $template already
1332 // has the rightmost extension removed, but there might still be more,
1333 // such as with .tpl.php, which still has .tpl in $template at this point.
1334 if (($pos = strpos($template, '.')) !== FALSE) {
1335 $template = substr($template, 0, $pos);
1336 }
1337 // Transform - in filenames to _ to match function naming scheme
1338 // for the purposes of searching.
1339 $hook = strtr($template, '-', '_');
1340 if (isset($cache[$hook])) {
1341 $implementations[$hook] = array(
1342 'template' => $template,
1343 'path' => dirname($file->uri),
1344 );
1345 }
1346 }
1347
1348 // Find templates that implement possible "suggestion" variants of registered
1349 // theme hooks and add those as new registered theme hooks. See
1350 // drupal_find_theme_functions() for more information about suggestions and
1351 // the use of 'pattern' and 'base hook'.
1352 $patterns = array_keys($files);
1353 foreach ($cache as $hook => $info) {
1354 $pattern = isset($info['pattern']) ? $info['pattern'] : ($hook . '__');
1355 if (!isset($info['base hook']) && !empty($pattern)) {
1356 // Transform _ in pattern to - to match file naming scheme
1357 // for the purposes of searching.
1358 $pattern = strtr($pattern, '_', '-');
1359
1360 $matches = preg_grep('/^' . $pattern . '/', $patterns);
1361 if ($matches) {
1362 foreach ($matches as $match) {
1363 $file = substr($match, 0, strpos($match, '.'));
1364 // Put the underscores back in for the hook name and register this
1365 // pattern.
1366 $arg_name = isset($info['variables']) ? 'variables' : 'render element';
1367 $implementations[strtr($file, '-', '_')] = array(
1368 'template' => $file,
1369 'path' => dirname($files[$match]->uri),
1370 $arg_name => $info[$arg_name],
1371 'base hook' => $hook,
1372 );
1373 }
1374 }
1375 }
1376 }
1377 return $implementations;
1378 }
1379
1401 function theme_get_setting($setting_name, $theme = NULL) {
1402 $cache = &drupal_static(__FUNCTION__, array());
1403
1404 // If no key is given, use the current theme if we can determine it.
1405 if (!isset($theme)) {
1406 $theme = !empty($GLOBALS['theme_key']) ? $GLOBALS['theme_key'] : '';
1407 }
1408
1409 if (empty($cache[$theme])) {
1410 // Set the default values for each global setting.
1411 // To add new global settings, add their default values below, and then
1412 // add form elements to system_theme_settings() in system.admin.inc.
1413 $cache[$theme] = array(
1414 'default_logo' => 1,
1415 'logo_path' => '',
1416 'default_favicon' => 1,
1417 'favicon_path' => '',
1418 // Use the IANA-registered MIME type for ICO files as default.
1419 'favicon_mimetype' => 'image/vnd.microsoft.icon',
1420 );
1421 // Turn on all default features.
1422 $features = _system_default_theme_features();
1423 foreach ($features as $feature) {
1424 $cache[$theme]['toggle_' . $feature] = 1;
1425 }
1426
1427 // Get the values for the theme-specific settings from the .info files of
1428 // the theme and all its base themes.
1429 if ($theme) {
1430 $themes = list_themes();
1431 $theme_object = $themes[$theme];
1432
1433 // Create a list which includes the current theme and all its base themes.
1434 if (isset($theme_object->base_themes)) {
1435 $theme_keys = array_keys($theme_object->base_themes);
1436 $theme_keys[] = $theme;
1437 }
1438 else {
1439 $theme_keys = array($theme);
1440 }
1441 foreach ($theme_keys as $theme_key) {
1442 if (!empty($themes[$theme_key]->info['settings'])) {
1443 $cache[$theme] = array_merge($cache[$theme], $themes[$theme_key]->info['settings']);
1444 }
1445 }
1446 }
1447
1448 // Get the saved global settings from the database.
1449 $cache[$theme] = array_merge($cache[$theme], variable_get('theme_settings', array()));
1450
1451 if ($theme) {
1452 // Get the saved theme-specific settings from the database.
1453 $cache[$theme] = array_merge($cache[$theme], variable_get('theme_' . $theme . '_settings', array()));
1454
1455 // If the theme does not support a particular feature, override the global
1456 // setting and set the value to NULL.
1457 if (!empty($theme_object->info['features'])) {
1458 foreach ($features as $feature) {
1459 if (!in_array($feature, $theme_object->info['features'])) {
1460 $cache[$theme]['toggle_' . $feature] = NULL;
1461 }
1462 }
1463 }
1464
1465 // Generate the path to the logo image.
1466 if ($cache[$theme]['toggle_logo']) {
1467 if ($cache[$theme]['default_logo']) {
1468 $cache[$theme]['logo'] = file_create_url(dirname($theme_object->filename) . '/logo.png');
1469 }
1470 elseif ($cache[$theme]['logo_path']) {
1471 $cache[$theme]['logo'] = file_create_url($cache[$theme]['logo_path']);
1472 }
1473 }
1474
1475 // Generate the path to the favicon.
1476 if ($cache[$theme]['toggle_favicon']) {
1477 if ($cache[$theme]['default_favicon']) {
1478 if (file_exists($favicon = dirname($theme_object->filename) . '/favicon.ico')) {
1479 $cache[$theme]['favicon'] = file_create_url($favicon);
1480 }
1481 else {
1482 $cache[$theme]['favicon'] = file_create_url('misc/favicon.ico');
1483 }
1484 }
1485 elseif ($cache[$theme]['favicon_path']) {
1486 $cache[$theme]['favicon'] = file_create_url($cache[$theme]['favicon_path']);
1487 }
1488 else {
1489 $cache[$theme]['toggle_favicon'] = FALSE;
1490 }
1491 }
1492 }
1493 }
1494
1495 return isset($cache[$theme][$setting_name]) ? $cache[$theme][$setting_name] : NULL;
1496 }
1497
1509 function theme_render_template($template_file, $variables) {
1510 // Extract the variables to a local namespace
1511 extract($variables, EXTR_SKIP);
1512
1513 // Start output buffering
1514 ob_start();
1515
1516 // Include the template file
1517 include DRUPAL_ROOT . '/' . $template_file;
1518
1519 // End buffering and return its contents
1520 return ob_get_clean();
1521 }
1522
1529 function theme_enable($theme_list) {
1530 drupal_clear_css_cache();
1531
1532 foreach ($theme_list as $key) {
1533 db_update('system')
1534 ->fields(array('status' => 1))
1535 ->condition('type', 'theme')
1536 ->condition('name', $key)
1537 ->execute();
1538 }
1539
1540 list_themes(TRUE);
1541 menu_rebuild();
1542 drupal_theme_rebuild();
1543
1544 // Invoke hook_themes_enabled() after the themes have been enabled.
1545 module_invoke_all('themes_enabled', $theme_list);
1546 }
1547
1554 function theme_disable($theme_list) {
1555 // Don't disable the default theme.
1556 if ($pos = array_search(variable_get('theme_default', 'bartik'), $theme_list) !== FALSE) {
1557 unset($theme_list[$pos]);
1558 if (empty($theme_list)) {
1559 return;
1560 }
1561 }
1562
1563 drupal_clear_css_cache();
1564
1565 foreach ($theme_list as $key) {
1566 db_update('system')
1567 ->fields(array('status' => 0))
1568 ->condition('type', 'theme')
1569 ->condition('name', $key)
1570 ->execute();
1571 }
1572
1573 list_themes(TRUE);
1574 menu_rebuild();
1575 drupal_theme_rebuild();
1576
1577 // Invoke hook_themes_disabled after the themes have been disabled.
1578 module_invoke_all('themes_disabled', $theme_list);
1579 }
1580
1598 function theme_status_messages($variables) {
1599 $display = $variables['display'];
1600 $output = '';
1601
1602 $status_heading = array(
1603 'status' => t('Status message'),
1604 'error' => t('Error message'),
1605 'warning' => t('Warning message'),
1606 );
1607 foreach (drupal_get_messages($display) as $type => $messages) {
1608 $output .= "<div class=\"messages $type\">\n";
1609 if (!empty($status_heading[$type])) {
1610 $output .= '<h2 class="element-invisible">' . $status_heading[$type] . "</h2>\n";
1611 }
1612 if (count($messages) > 1) {
1613 $output .= " <ul>\n";
1614 foreach ($messages as $message) {
1615 $output .= ' <li>' . $message . "</li>\n";
1616 }
1617 $output .= " </ul>\n";
1618 }
1619 else {
1620 $output .= $messages[0];
1621 }
1622 $output .= "</div>\n";
1623 }
1624 return $output;
1625 }
1626
1645 function theme_link($variables) {
1646 return '<a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . drupal_attributes($variables['options']['attributes']) . '>' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '</a>';
1647 }
1648
1685 function theme_links($variables) {
1686 $links = $variables['links'];
1687 $attributes = $variables['attributes'];
1688 $heading = $variables['heading'];
1689 global $language_url;
1690 $output = '';
1691
1692 if (count($links) > 0) {
1693 $output = '';
1694
1695 // Treat the heading first if it is present to prepend it to the
1696 // list of links.
1697 if (!empty($heading)) {
1698 if (is_string($heading)) {
1699 // Prepare the array that will be used when the passed heading
1700 // is a string.
1701 $heading = array(
1702 'text' => $heading,
1703 // Set the default level of the heading.
1704 'level' => 'h2',
1705 );
1706 }
1707 $output .= '<' . $heading['level'];
1708 if (!empty($heading['class'])) {
1709 $output .= drupal_attributes(array('class' => $heading['class']));
1710 }
1711 $output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>';
1712 }
1713
1714 $output .= '<ul' . drupal_attributes($attributes) . '>';
1715
1716 $num_links = count($links);
1717 $i = 1;
1718
1719 foreach ($links as $key => $link) {
1720 $class = array($key);
1721
1722 // Add first, last and active classes to the list of links to help out themers.
1723 if ($i == 1) {
1724 $class[] = 'first';
1725 }
1726 if ($i == $num_links) {
1727 $class[] = 'last';
1728 }
1729 if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
1730 && (empty($link['language']) || $link['language']->language == $language_url->language)) {
1731 $class[] = 'active';
1732 }
1733 $output .= '<li' . drupal_attributes(array('class' => $class)) . '>';
1734
1735 if (isset($link['href'])) {
1736 // Pass in $link as $options, they share the same keys.
1737 $output .= l($link['title'], $link['href'], $link);
1738 }
1739 elseif (!empty($link['title'])) {
1740 // Some links are actually not links, but we wrap these in <span> for adding title and class attributes.
1741 if (empty($link['html'])) {
1742 $link['title'] = check_plain($link['title']);
1743 }
1744 $span_attributes = '';
1745 if (isset($link['attributes'])) {
1746 $span_attributes = drupal_attributes($link['attributes']);
1747 }
1748 $output .= '<span' . $span_attributes . '>' . $link['title'] . '</span>';
1749 }
1750
1751 $i++;
1752 $output .= "</li>\n";
1753 }
1754
1755 $output .= '</ul>';
1756 }
1757
1758 return $output;
1759 }
1760
1784 function theme_image($variables) {
1785 $attributes = $variables['attributes'];
1786 $attributes['src'] = file_create_url($variables['path']);
1787
1788 foreach (array('width', 'height', 'alt', 'title') as $key) {
1789
1790 if (isset($variables[$key])) {
1791 $attributes[$key] = $variables[$key];
1792 }
1793 }
1794
1795 return '<img' . drupal_attributes($attributes) . ' />';
1796 }
1797
1805 function theme_breadcrumb($variables) {
1806 $breadcrumb = $variables['breadcrumb'];
1807
1808 if (!empty($breadcrumb)) {
1809 // Provide a navigational heading to give context for breadcrumb links to
1810 // screen-reader users. Make the heading invisible with .element-invisible.
1811 $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
1812
1813 $output .= '<div class="breadcrumb">' . implode(' » ', $breadcrumb) . '</div>';
1814 return $output;
1815 }
1816 }
1817
1895 function theme_table($variables) {
1896 $header = $variables['header'];
1897 $rows = $variables['rows'];
1898 $attributes = $variables['attributes'];
1899 $caption = $variables['caption'];
1900 $colgroups = $variables['colgroups'];
1901 $sticky = $variables['sticky'];
1902 $empty = $variables['empty'];
1903
1904 // Add sticky headers, if applicable.
1905 if (count($header) && $sticky) {
1906 drupal_add_js('misc/tableheader.js');
1907 // Add 'sticky-enabled' class to the table to identify it for JS.
1908 // This is needed to target tables constructed by this function.
1909 $attributes['class'][] = 'sticky-enabled';
1910 }
1911
1912 $output = '<table' . drupal_attributes($attributes) . ">\n";
1913
1914 if (isset($caption)) {
1915 $output .= '<caption>' . $caption . "</caption>\n";
1916 }
1917
1918 // Format the table columns:
1919 if (count($colgroups)) {
1920 foreach ($colgroups as $number => $colgroup) {
1921 $attributes = array();
1922
1923 // Check if we're dealing with a simple or complex column
1924 if (isset($colgroup['data'])) {
1925 foreach ($colgroup as $key => $value) {
1926 if ($key == 'data') {
1927 $cols = $value;
1928 }
1929 else {
1930 $attributes[$key] = $value;
1931 }
1932 }
1933 }
1934 else {
1935 $cols = $colgroup;
1936 }
1937
1938 // Build colgroup
1939 if (is_array($cols) && count($cols)) {
1940 $output .= ' <colgroup' . drupal_attributes($attributes) . '>';
1941 $i = 0;
1942 foreach ($cols as $col) {
1943 $output .= ' <col' . drupal_attributes($col) . ' />';
1944 }
1945 $output .= " </colgroup>\n";
1946 }
1947 else {
1948 $output .= ' <colgroup' . drupal_attributes($attributes) . " />\n";
1949 }
1950 }
1951 }
1952
1953 // Add the 'empty' row message if available.
1954 if (!count($rows) && $empty) {
1955 $header_count = 0;
1956 foreach ($header as $header_cell) {
1957 if (is_array($header_cell)) {
1958 $header_count += isset($header_cell['colspan']) ? $header_cell['colspan'] : 1;
1959 }
1960 else {
1961 $header_count++;
1962 }
1963 }
1964 $rows[] = array(array('data' => $empty, 'colspan' => $header_count, 'class' => array('empty', 'message')));
1965 }
1966
1967 // Format the table header:
1968 if (count($header)) {
1969 $ts = tablesort_init($header);
1970 // HTML requires that the thead tag has tr tags in it followed by tbody
1971 // tags. Using ternary operator to check and see if we have any rows.
1972 $output .= (count($rows) ? ' <thead><tr>' : ' <tr>');
1973 foreach ($header as $cell) {
1974 $cell = tablesort_header($cell, $header, $ts);
1975 $output .= _theme_table_cell($cell, TRUE);
1976 }
1977 // Using ternary operator to close the tags based on whether or not there are rows
1978 $output .= (count($rows) ? " </tr></thead>\n" : "</tr>\n");
1979 }
1980 else {
1981 $ts = array();
1982 }
1983
1984 // Format the table rows:
1985 if (count($rows)) {
1986 $output .= "<tbody>\n";
1987 $flip = array('even' => 'odd', 'odd' => 'even');
1988 $class = 'even';
1989 foreach ($rows as $number => $row) {
1990 // Check if we're dealing with a simple or complex row
1991 if (isset($row['data'])) {
1992 $cells = $row['data'];
1993 $no_striping = isset($row['no_striping']) ? $row['no_striping'] : FALSE;
1994
1995 // Set the attributes array and exclude 'data' and 'no_striping'.
1996 $attributes = $row;
1997 unset($attributes['data']);
1998 unset($attributes['no_striping']);
1999 }
2000 else {
2001 $cells = $row;
2002 $attributes = array();
2003 $no_striping = FALSE;
2004 }
2005 if (count($cells)) {
2006 // Add odd/even class
2007 if (!$no_striping) {
2008 $class = $flip[$class];
2009 $attributes['class'][] = $class;
2010 }
2011
2012 // Build row
2013 $output .= ' <tr' . drupal_attributes($attributes) . '>';
2014 $i = 0;
2015 foreach ($cells as $cell) {
2016 $cell = tablesort_cell($cell, $header, $ts, $i++);
2017 $output .= _theme_table_cell($cell);
2018 }
2019 $output .= " </tr>\n";
2020 }
2021 }
2022 $output .= "</tbody>\n";
2023 }
2024
2025 $output .= "</table>\n";
2026 return $output;
2027 }
2028
2037 function theme_tablesort_indicator($variables) {
2038 if ($variables['style'] == "asc") {
2039 return theme('image', array('path' => 'misc/arrow-asc.png', 'width' => 13, 'height' => 13, 'alt' => t('sort ascending'), 'title' => t('sort ascending')));
2040 }
2041 else {
2042 return theme('image', array('path' => 'misc/arrow-desc.png', 'width' => 13, 'height' => 13, 'alt' => t('sort descending'), 'title' => t('sort descending')));
2043 }
2044 }
2045
2054 function theme_mark($variables) {
2055 $type = $variables['type'];
2056 global $user;
2057 if ($user->uid) {
2058 if ($type == MARK_NEW) {
2059 return ' <span class="marker">' . t('new') . '</span>';
2060 }
2061 elseif ($type == MARK_UPDATED) {
2062 return ' <span class="marker">' . t('updated') . '</span>';
2063 }
2064 }
2065 }
2066
2082 function theme_item_list($variables) {
2083 $items = $variables['items'];
2084 $title = $variables['title'];
2085 $type = $variables['type'];
2086 $attributes = $variables['attributes'];
2087
2088 // Only output the list container and title, if there are any list items.
2089 // Check to see whether the block title exists before adding a header.
2090 // Empty headers are not semantic and present accessibility challenges.
2091 $output = '<div class="item-list">';
2092 if (isset($title) && $title !== '') {
2093 $output .= '<h3>' . $title . '</h3>';
2094 }
2095
2096 if (!empty($items)) {
2097 $output .= "<$type" . drupal_attributes($attributes) . '>';
2098 $num_items = count($items);
2099 $i = 0;
2100 foreach ($items as $item) {
2101 $attributes = array();
2102 $children = array();
2103 $data = '';
2104 $i++;
2105 if (is_array($item)) {
2106 foreach ($item as $key => $value) {
2107 if ($key == 'data') {
2108 $data = $value;
2109 }
2110 elseif ($key == 'children') {
2111 $children = $value;
2112 }
2113 else {
2114 $attributes[$key] = $value;
2115 }
2116 }
2117 }
2118 else {
2119 $data = $item;
2120 }
2121 if (count($children) > 0) {
2122 // Render nested list.
2123 $data .= theme_item_list(array('items' => $children, 'title' => NULL, 'type' => $type, 'attributes' => $attributes));
2124 }
2125 if ($i == 1) {
2126 $attributes['class'][] = 'first';
2127 }
2128 if ($i == $num_items) {
2129 $attributes['class'][] = 'last';
2130 }
2131 $output .= '<li' . drupal_attributes($attributes) . '>' . $data . "</li>\n";
2132 }
2133 $output .= "</$type>";
2134 }
2135 $output .= '</div>';
2136 return $output;
2137 }
2138
2146 function theme_more_help_link($variables) {
2147 return '<div class="more-help-link">' . l(t('More help'), $variables['url']) . '</div>';
2148 }
2149
2159 function theme_feed_icon($variables) {
2160 $text = t('Subscribe to !feed-title', array('!feed-title' => $variables['title']));
2161 if ($image = theme('image', array('path' => 'misc/feed.png', 'width' => 16, 'height' => 16, 'alt' => $text))) {
2162 return l($image, $variables['url'], array('html' => TRUE, 'attributes' => array('class' => array('feed-icon'), 'title' => $text)));
2163 }
2164 }
2165
2185 function theme_html_tag($variables) {
2186 $element = $variables['element'];
2187 $attributes = isset($element['#attributes']) ? drupal_attributes($element['#attributes']) : '';
2188 if (!isset($element['#value'])) {
2189 return '<' . $element['#tag'] . $attributes . " />\n";
2190 }
2191 else {
2192 $output = '<' . $element['#tag'] . $attributes . '>';
2193 if (isset($element['#value_prefix'])) {
2194 $output .= $element['#value_prefix'];
2195 }
2196 $output .= $element['#value'];
2197 if (isset($element['#value_suffix'])) {
2198 $output .= $element['#value_suffix'];
2199 }
2200 $output .= '</' . $element['#tag'] . ">\n";
2201 return $output;
2202 }
2203 }
2204
2213 function theme_more_link($variables) {
2214 return '<div class="more-link">' . l(t('More'), $variables['url'], array('attributes' => array('title' => $variables['title']))) . '</div>';
2215 }
2216
2235 function theme_username($variables) {
2236 if (isset($variables['link_path'])) {
2237 // We have a link path, so we should generate a link using l().
2238 // Additional classes may be added as array elements like
2239 // $variables['link_options']['attributes']['class'][] = 'myclass';
2240 $output = l($variables['name'] . $variables['extra'], $variables['link_path'], $variables['link_options']);
2241 }
2242 else {
2243 // Modules may have added important attributes so they must be included
2244 // in the output. Additional classes may be added as array elements like
2245 // $variables['attributes_array']['class'][] = 'myclass';
2246 $output = '<span' . drupal_attributes($variables['attributes_array']) . '>' . $variables['name'] . $variables['extra'] . '</span>';
2247 }
2248 return $output;
2249 }
2250
2261 function theme_progress_bar($variables) {
2262 $output = '<div id="progress" class="progress">';
2263 $output .= '<div class="bar"><div class="filled" style="width: ' . $variables['percent'] . '%"></div></div>';
2264 $output .= '<div class="percentage">' . $variables['percent'] . '%</div>';
2265 $output .= '<div class="message">' . $variables['message'] . '</div>';
2266 $output .= '</div>';
2267
2268 return $output;
2269 }
2270
2278 function theme_indentation($variables) {
2279 $output = '';
2280 for ($n = 0; $n < $variables['size']; $n++) {
2281 $output .= '<div class="indentation">&nbsp;</div>';
2282 }
2283 return $output;
2284 }
2285
2303 function _theme_table_cell($cell, $header = FALSE) {
2304 $attributes = '';
2305
2306 if (is_array($cell)) {
2307 $data = isset($cell['data']) ? $cell['data'] : '';
2308 // Cell's data property can be a string or a renderable array.
2309 if (is_array($data)) {
2310 $data = drupal_render($data);
2311 }
2312 $header |= isset($cell['header']);
2313 unset($cell['data']);
2314 unset($cell['header']);
2315 $attributes = drupal_attributes($cell);
2316 }
2317 else {
2318 $data = $cell;
2319 }
2320
2321 if ($header) {
2322 $output = "<th$attributes>$data</th>";
2323 }
2324 else {
2325 $output = "<td$attributes>$data</td>";
2326 }
2327
2328 return $output;
2329 }
2330
2343 function template_preprocess(&$variables, $hook) {
2344 global $user;
2345 static $count = array();
2346
2347 // Track run count for each hook to provide zebra striping. See
2348 // "template_preprocess_block()" which provides the same feature specific to
2349 // blocks.
2350 $count[$hook] = isset($count[$hook]) && is_int($count[$hook]) ? $count[$hook] : 1;
2351 $variables['zebra'] = ($count[$hook] % 2) ? 'odd' : 'even';
2352 $variables['id'] = $count[$hook]++;
2353
2354 // Tell all templates where they are located.
2355 $variables['directory'] = path_to_theme();
2356
2357 // Initialize html class attribute for the current hook.
2358 $variables['classes_array'] = array(drupal_html_class($hook));
2359
2360 // Merge in variables that don't depend on hook and don't change during a
2361 // single page request.
2362 // Use the advanced drupal_static() pattern, since this is called very often.
2363 static $drupal_static_fast;
2364 if (!isset($drupal_static_fast)) {
2365 $drupal_static_fast['default_variables'] = &drupal_static(__FUNCTION__);
2366 }
2367 $default_variables = &$drupal_static_fast['default_variables'];
2368 // Global $user object shouldn't change during a page request once rendering
2369 // has started, but if there's an edge case where it does, re-fetch the
2370 // variables appropriate for the new user.
2371 if (!isset($default_variables) || ($user !== $default_variables['user'])) {
2372 $default_variables = _template_preprocess_default_variables();
2373 }
2374 $variables += $default_variables;
2375 }
2376
2380 function _template_preprocess_default_variables() {
2381 global $user;
2382
2383 // Variables that don't depend on a database connection.
2384 $variables = array(
2385 'attributes_array' => array(),
2386 'title_attributes_array' => array(),
2387 'content_attributes_array' => array(),
2388 'title_prefix' => array(),
2389 'title_suffix' => array(),
2390 'user' => $user,
2391 'db_is_active' => !defined('MAINTENANCE_MODE'),
2392 'is_admin' => FALSE,
2393 'logged_in' => FALSE,
2394 );
2395
2396 // The user object has no uid property when the database does not exist during
2397 // install. The user_access() check deals with issues when in maintenance mode
2398 // as uid is set but the user.module has not been included.
2399 if (isset($user->uid) && function_exists('user_access')) {
2400 $variables['is_admin'] = user_access('access administration pages');
2401 $variables['logged_in'] = ($user->uid > 0);
2402 }
2403
2404 // drupal_is_front_page() might throw an exception.
2405 try {
2406 $variables['is_front'] = drupal_is_front_page();
2407 }
2408 catch (Exception $e) {
2409 // If the database is not yet available, set default values for these
2410 // variables.
2411 $variables['is_front'] = FALSE;
2412 $variables['db_is_active'] = FALSE;
2413 }
2414
2415 return $variables;
2416 }
2417
2433 function template_process(&$variables, $hook) {
2434 // Flatten out classes.
2435 $variables['classes'] = implode(' ', $variables['classes_array']);
2436
2437 // Flatten out attributes, title_attributes, and content_attributes.
2438 // Because this function can be called very often, and often with empty
2439 // attributes, optimize performance by only calling drupal_attributes() if
2440 // necessary.
2441 $variables['attributes'] = $variables['attributes_array'] ? drupal_attributes($variables['attributes_array']) : '';
2442 $variables['title_attributes'] = $variables['title_attributes_array'] ? drupal_attributes($variables['title_attributes_array']) : '';
2443 $variables['content_attributes'] = $variables['content_attributes_array'] ? drupal_attributes($variables['content_attributes_array']) : '';
2444 }
2445
2452 function template_preprocess_html(&$variables) {
2453 // Compile a list of classes that are going to be applied to the body element.
2454 // This allows advanced theming based on context (home page, node of certain type, etc.).
2455 // Add a class that tells us whether we're on the front page or not.
2456 $variables['classes_array'][] = $variables['is_front'] ? 'front' : 'not-front';
2457 // Add a class that tells us whether the page is viewed by an authenticated user or not.
2458 $variables['classes_array'][] = $variables['logged_in'] ? 'logged-in' : 'not-logged-in';
2459
2460 // Add information about the number of sidebars.
2461 if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) {
2462 $variables['classes_array'][] = 'two-sidebars';
2463 }
2464 elseif (!empty($variables['page']['sidebar_first'])) {
2465 $variables['classes_array'][] = 'one-sidebar sidebar-first';
2466 }
2467 elseif (!empty($variables['page']['sidebar_second'])) {
2468 $variables['classes_array'][] = 'one-sidebar sidebar-second';
2469 }
2470 else {
2471 $variables['classes_array'][] = 'no-sidebars';
2472 }
2473
2474 // Populate the body classes.
2475 if ($suggestions = theme_get_suggestions(arg(), 'page', '-')) {
2476 foreach ($suggestions as $suggestion) {
2477 if ($suggestion != 'page-front') {
2478 // Add current suggestion to page classes to make it possible to theme
2479 // the page depending on the current page type (e.g. node, admin, user,
2480 // etc.) as well as more specific data like node-12 or node-edit.
2481 $variables['classes_array'][] = drupal_html_class($suggestion);
2482 }
2483 }
2484 }
2485
2486 // If on an individual node page, add the node type to body classes.
2487 if ($node = menu_get_object()) {
2488 $variables['classes_array'][] = drupal_html_class('node-type-' . $node->type);
2489 }
2490
2491 // RDFa allows annotation of XHTML pages with RDF data, while GRDDL provides
2492 // mechanisms for extraction of this RDF content via XSLT transformation
2493 // using an associated GRDDL profile.
2494 $variables['rdf_namespaces'] = drupal_get_rdf_namespaces();
2495 $variables['grddl_profile'] = 'http://www.w3.org/1999/xhtml/vocab';
2496 $variables['language'] = $GLOBALS['language'];
2497 $variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
2498
2499 // Add favicon.
2500 if (theme_get_setting('toggle_favicon')) {
2501 $favicon = theme_get_setting('favicon');
2502 $type = theme_get_setting('favicon_mimetype');
2503 drupal_add_html_head_link(array('rel' => 'shortcut icon', 'href' => drupal_strip_dangerous_protocols($favicon), 'type' => $type));
2504 }
2505
2506 // Construct page title.
2507 if (drupal_get_title()) {
2508 $head_title = array(
2509 'title' => strip_tags(drupal_get_title()),
2510 'name' => check_plain(variable_get('site_name', 'Drupal')),
2511 );
2512 }
2513 else {
2514 $head_title = array('name' => check_plain(variable_get('site_name', 'Drupal')));
2515 if (variable_get('site_slogan', '')) {
2516 $head_title['slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
2517 }
2518 }
2519 $variables['head_title_array'] = $head_title;
2520 $variables['head_title'] = implode(' | ', $head_title);
2521
2522 // Populate the page template suggestions.
2523 if ($suggestions = theme_get_suggestions(arg(), 'html')) {
2524 $variables['theme_hook_suggestions'] = $suggestions;
2525 }
2526 }
2527
2545 function template_preprocess_page(&$variables) {
2546 // Move some variables to the top level for themer convenience and template cleanliness.
2547 $variables['show_messages'] = $variables['page']['#show_messages'];
2548
2549 foreach (system_region_list($GLOBALS['theme']) as $region_key => $region_name) {
2550 if (!isset($variables['page'][$region_key])) {
2551 $variables['page'][$region_key] = array();
2552 }
2553 }
2554
2555 // Set up layout variable.
2556 $variables['layout'] = 'none';
2557 if (!empty($variables['page']['sidebar_first'])) {
2558 $variables['layout'] = 'first';
2559 }
2560 if (!empty($variables['page']['sidebar_second'])) {
2561 $variables['layout'] = ($variables['layout'] == 'first') ? 'both' : 'second';
2562 }
2563
2564 $variables['base_path'] = base_path();
2565 $variables['front_page'] = url();
2566 $variables['feed_icons'] = drupal_get_feeds();
2567 $variables['language'] = $GLOBALS['language'];
2568 $variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
2569 $variables['logo'] = theme_get_setting('logo');
2570 $variables['main_menu'] = theme_get_setting('toggle_main_menu') ? menu_main_menu() : array();
2571 $variables['secondary_menu'] = theme_get_setting('toggle_secondary_menu') ? menu_secondary_menu() : array();
2572 $variables['action_links'] = menu_local_actions();
2573 $variables['site_name'] = (theme_get_setting('toggle_name') ? filter_xss_admin(variable_get('site_name', 'Drupal')) : '');
2574 $variables['site_slogan'] = (theme_get_setting('toggle_slogan') ? filter_xss_admin(variable_get('site_slogan', '')) : '');
2575 $variables['tabs'] = menu_local_tabs();
2576
2577 if ($node = menu_get_object()) {
2578 $variables['node'] = $node;
2579 }
2580
2581 // Populate the page template suggestions.
2582 if ($suggestions = theme_get_suggestions(arg(), 'page')) {
2583 $variables['theme_hook_suggestions'] = $suggestions;
2584 }
2585 }
2586
2596 function template_process_page(&$variables) {
2597 if (!isset($variables['breadcrumb'])) {
2598 // Build the breadcrumb last, so as to increase the chance of being able to
2599 // re-use the cache of an already rendered menu containing the active link
2600 // for the current page.
2601 // @see menu_tree_page_data()
2602 $variables['breadcrumb'] = theme('breadcrumb', array('breadcrumb' => drupal_get_breadcrumb()));
2603 }
2604 if (!isset($variables['title'])) {
2605 $variables['title'] = drupal_get_title();
2606 }
2607
2608 // Generate messages last in order to capture as many as possible for the
2609 // current page.
2610 if (!isset($variables['messages'])) {
2611 $variables['messages'] = $variables['show_messages'] ? theme('status_messages') : '';
2612 }
2613 }
2614
2625 function template_process_html(&$variables) {
2626 // Render page_top and page_bottom into top level variables.
2627 $variables['page_top'] = drupal_render($variables['page']['page_top']);
2628 $variables['page_bottom'] = drupal_render($variables['page']['page_bottom']);
2629 // Place the rendered HTML for the page body into a top level variable.
2630 $variables['page'] = $variables['page']['#children'];
2631 $variables['page_bottom'] .= drupal_get_js('footer');
2632
2633 $variables['head'] = drupal_get_html_head();
2634 $variables['css'] = drupal_add_css();
2635 $variables['styles'] = drupal_get_css();
2636 $variables['scripts'] = drupal_get_js();
2637 }
2638
2661 function theme_get_suggestions($args, $base, $delimiter = '__') {
2662
2663 // Build a list of suggested theme hooks or body classes in order of
2664 // specificity. One suggestion is made for every element of the current path,
2665 // though numeric elements are not carried to subsequent suggestions. For
2666 // example, for $base='page', http://www.example.com/node/1/edit would result
2667 // in the following suggestions and body classes:
2668 //
2669 // page__node page-node
2670 // page__node__% page-node-%
2671 // page__node__1 page-node-1
2672 // page__node__edit page-node-edit
2673
2674 $suggestions = array();
2675 $prefix = $base;
2676 foreach ($args as $arg) {
2677 // Remove slashes or null per SA-CORE-2009-003 and change - (hyphen) to _
2678 // (underscore).
2679 //
2680 // When we discover templates in @see drupal_find_theme_templates,
2681 // hyphens (-) are converted to underscores (_) before the theme hook
2682 // is registered. We do this because the hyphens used for delimiters
2683 // in hook suggestions cannot be used in the function names of the
2684 // associated preprocess functions. Any page templates designed to be used
2685 // on paths that contain a hyphen are also registered with these hyphens
2686 // converted to underscores so here we must convert any hyphens in path
2687 // arguments to underscores here before fetching theme hook suggestions
2688 // to ensure the templates are appropriately recognized.
2689 $arg = str_replace(array("/", "\\", "\0", '-'), array('', '', '', '_'), $arg);
2690 // The percent acts as a wildcard for numeric arguments since
2691 // asterisks are not valid filename characters on many filesystems.
2692 if (is_numeric($arg)) {
2693 $suggestions[] = $prefix . $delimiter . '%';
2694 }
2695 $suggestions[] = $prefix . $delimiter . $arg;
2696 if (!is_numeric($arg)) {
2697 $prefix .= $delimiter . $arg;
2698 }
2699 }
2700 if (drupal_is_front_page()) {
2701 // Front templates should be based on root only, not prefixed arguments.
2702 $suggestions[] = $base . $delimiter . 'front';
2703 }
2704
2705 return $suggestions;
2706 }
2707
2722 function template_preprocess_maintenance_page(&$variables) {
2723 // Add favicon
2724 if (theme_get_setting('toggle_favicon')) {
2725 $favicon = theme_get_setting('favicon');
2726 $type = theme_get_setting('favicon_mimetype');
2727 drupal_add_html_head_link(array('rel' => 'shortcut icon', 'href' => drupal_strip_dangerous_protocols($favicon), 'type' => $type));
2728 }
2729
2730 global $theme;
2731 // Retrieve the theme data to list all available regions.
2732 $theme_data = list_themes();
2733 $regions = $theme_data[$theme]->info['regions'];
2734
2735 // Get all region content set with drupal_add_region_content().
2736 foreach (array_keys($regions) as $region) {
2737 // Assign region to a region variable.
2738 $region_content = drupal_get_region_content($region);
2739 isset($variables[$region]) ? $variables[$region] .= $region_content : $variables[$region] = $region_content;
2740 }
2741
2742 // Setup layout variable.
2743 $variables['layout'] = 'none';
2744 if (!empty($variables['sidebar_first'])) {
2745 $variables['layout'] = 'first';
2746 }
2747 if (!empty($variables['sidebar_second'])) {
2748 $variables['layout'] = ($variables['layout'] == 'first') ? 'both' : 'second';
2749 }
2750
2751 // Construct page title
2752 if (drupal_get_title()) {
2753 $head_title = array(
2754 'title' => strip_tags(drupal_get_title()),
2755 'name' => variable_get('site_name', 'Drupal'),
2756 );
2757 }
2758 else {
2759 $head_title = array('name' => variable_get('site_name', 'Drupal'));
2760 if (variable_get('site_slogan', '')) {
2761 $head_title['slogan'] = variable_get('site_slogan', '');
2762 }
2763 }
2764
2765 // set the default language if necessary
2766 $language = isset($GLOBALS['language']) ? $GLOBALS['language'] : language_default();
2767
2768 $variables['head_title_array'] = $head_title;
2769 $variables['head_title'] = implode(' | ', $head_title);
2770 $variables['base_path'] = base_path();
2771 $variables['front_page'] = url();
2772 $variables['breadcrumb'] = '';
2773 $variables['feed_icons'] = '';
2774 $variables['help'] = '';
2775 $variables['language'] = $language;
2776 $variables['language']->dir = $language->direction ? 'rtl' : 'ltr';
2777 $variables['logo'] = theme_get_setting('logo');
2778 $variables['messages'] = $variables['show_messages'] ? theme('status_messages') : '';
2779 $variables['main_menu'] = array();
2780 $variables['secondary_menu'] = array();
2781 $variables['site_name'] = (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : '');
2782 $variables['site_slogan'] = (theme_get_setting('toggle_slogan') ? variable_get('site_slogan', '') : '');
2783 $variables['tabs'] = '';
2784 $variables['title'] = drupal_get_title();
2785
2786 // Compile a list of classes that are going to be applied to the body element.
2787 $variables['classes_array'][] = 'in-maintenance';
2788 if (isset($variables['db_is_active']) && !$variables['db_is_active']) {
2789 $variables['classes_array'][] = 'db-offline';
2790 }
2791 if ($variables['layout'] == 'both') {
2792 $variables['classes_array'][] = 'two-sidebars';
2793 }
2794 elseif ($variables['layout'] == 'none') {
2795 $variables['classes_array'][] = 'no-sidebars';
2796 }
2797 else {
2798 $variables['classes_array'][] = 'one-sidebar sidebar-' . $variables['layout'];
2799 }
2800
2801 // Dead databases will show error messages so supplying this template will
2802 // allow themers to override the page and the content completely.
2803 if (isset($variables['db_is_active']) && !$variables['db_is_active']) {
2804 $variables['theme_hook_suggestion'] = 'maintenance_page__offline';
2805 }
2806 }
2807
2817 function template_process_maintenance_page(&$variables) {
2818 $variables['head'] = drupal_get_html_head();
2819 $variables['css'] = drupal_add_css();
2820 $variables['styles'] = drupal_get_css();
2821 $variables['scripts'] = drupal_get_js();
2822 }
2823
2834 function template_preprocess_region(&$variables) {
2835 // Create the $content variable that templates expect.
2836 $variables['content'] = $variables['elements']['#children'];
2837 $variables['region'] = $variables['elements']['#region'];
2838
2839 $variables['classes_array'][] = drupal_region_class($variables['region']);
2840 $variables['theme_hook_suggestions'][] = 'region__' . $variables['region'];
2841 }
2842
2852 function template_preprocess_username(&$variables) {
2853 $account = $variables['account'];
2854
2855 $variables['extra'] = '';
2856 if (empty($account->uid)) {
2857 $variables['uid'] = 0;
2858 if (theme_get_setting('toggle_comment_user_verification')) {
2859 $variables['extra'] = ' (' . t('not verified') . ')';
2860 }
2861 }
2862 else {
2863 $variables['uid'] = (int) $account->uid;
2864 }
2865
2866 // Set the name to a formatted name that is safe for printing and
2867 // that won't break tables by being too long. Keep an unshortened,
2868 // unsanitized version, in case other preprocess functions want to implement
2869 // their own shortening logic or add markup. If they do so, they must ensure
2870 // that $variables['name'] is safe for printing.
2871 $name = $variables['name_raw'] = format_username($account);
2872 if (drupal_strlen($name) > 20) {
2873 $name = drupal_substr($name, 0, 15) . '...';
2874 }
2875 $variables['name'] = check_plain($name);
2876
2877 $variables['profile_access'] = user_access('access user profiles');
2878 $variables['link_attributes'] = array();
2879 // Populate link path and attributes if appropriate.
2880 if ($variables['uid'] && $variables['profile_access']) {
2881 // We are linking to a local user.
2882 $variables['link_attributes'] = array('title' => t('View user profile.'));
2883 $variables['link_path'] = 'user/' . $variables['uid'];
2884 }
2885 elseif (!empty($account->homepage)) {
2886 // Like the 'class' attribute, the 'rel' attribute can hold a
2887 // space-separated set of values, so initialize it as an array to make it
2888 // easier for other preprocess functions to append to it.
2889 $variables['link_attributes'] = array('rel' => array('nofollow'));
2890 $variables['link_path'] = $account->homepage;
2891 $variables['homepage'] = $account->homepage;
2892 }
2893 // We do not want the l() function to check_plain() a second time.
2894 $variables['link_options']['html'] = TRUE;
2895 // Set a default class.
2896 $variables['attributes_array'] = array('class' => array('username'));
2897 }
2898
2904 function template_process_username(&$variables) {
2905 // Finalize the link_options array for passing to the l() function.
2906 // This is done in the process phase so that attributes may be added by
2907 // modules or the theme during the preprocess phase.
2908 if (isset($variables['link_path'])) {
2909 // $variables['attributes_array'] contains attributes that should be applied
2910 // regardless of whether a link is being rendered or not.
2911 // $variables['link_attributes'] contains attributes that should only be
2912 // applied if a link is being rendered. Preprocess functions are encouraged
2913 // to use the former unless they want to add attributes on the link only.
2914 // If a link is being rendered, these need to be merged. Some attributes are
2915 // themselves arrays, so the merging needs to be recursive.
2916 $variables['link_options']['attributes'] = array_merge_recursive($variables['link_attributes'], $variables['attributes_array']);
2917 }
2918 }
template_process_page
template_process_page(&$variables)
Definition: theme.inc:2596
drupal_is_front_page
drupal_is_front_page()
Definition: path.inc:284
module_list
module_list($refresh=FALSE, $bootstrap_refresh=FALSE, $sort=FALSE, $fixed_list=NULL)
Definition: module.inc:66
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
template_process_maintenance_page
template_process_maintenance_page(&$variables)
Definition: theme.inc:2817
_theme_process_registry
_theme_process_registry(&$cache, $name, $type, $theme, $path)
Definition: theme.inc:515
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
_theme_registry_callback
_theme_registry_callback($callback=NULL, array $arguments=array())
Definition: theme.inc:291
DrupalCacheArray\$persistable
$persistable
Definition: theme.inc:374
theme_status_messages
theme_status_messages($variables)
Definition: theme.inc:1598
drupal_strlen
drupal_strlen($text)
Definition: unicode.inc:474
drupal_get_css
drupal_get_css($css=NULL, $skip_alter=FALSE)
Definition: common.inc:3052
DrupalCacheArray\offsetExists
offsetExists($offset)
Definition: theme.inc:416
_drupal_theme_initialize
_drupal_theme_initialize($theme, $base_theme=array(), $registry_callback= '_theme_load_registry')
Definition: theme.inc:141
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
drupal_clear_css_cache
drupal_clear_css_cache()
Definition: common.inc:3783
$module
print $module
Definition: search-results.tpl.php:28
file_create_url
file_create_url($uri)
Definition: file.inc:372
format_username
format_username($account)
Definition: common.inc:2106
_drupal_theme_access
_drupal_theme_access($theme)
Definition: theme.inc:62
DrupalCacheArray\$completeRegistry
$completeRegistry
Definition: theme.inc:379
drupal_find_theme_functions
drupal_find_theme_functions($cache, $prefixes)
Definition: theme.inc:1240
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
theme_disable
theme_disable($theme_list)
Definition: theme.inc:1554
$name
print $name
Definition: profile-listing.tpl.php:43
Exception
theme_more_help_link
theme_more_help_link($variables)
Definition: theme.inc:2146
tablesort_cell
tablesort_cell($cell, $header, $ts, $i)
Definition: tablesort.inc:171
$header
print $header
Definition: forum-topic-list.tpl.php:42
menu_get_custom_theme
menu_get_custom_theme($initialize=FALSE)
Definition: menu.inc:1740
menu_local_actions
menu_local_actions()
Definition: menu.inc:2245
_system_rebuild_theme_data
_system_rebuild_theme_data()
Definition: system.module:2493
drupal_attributes
drupal_attributes(array $attributes=array())
Definition: common.inc:2377
$attributes
print $attributes
Definition: block.tpl.php:47
path_to_theme
path_to_theme()
Definition: theme.inc:1219
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
DrupalCacheArray\__construct
__construct($cid, $bin)
Definition: theme.inc:381
drupal_strip_dangerous_protocols
drupal_strip_dangerous_protocols($uri)
Definition: common.inc:1340
drupal_substr
drupal_substr($text, $start, $length=NULL)
Definition: unicode.inc:585
drupal_theme_access
drupal_theme_access($theme)
Definition: theme.inc:47
drupal_add_html_head_link
drupal_add_html_head_link($attributes, $header=FALSE)
Definition: common.inc:2834
_system_default_theme_features
_system_default_theme_features()
Definition: system.module:2655
system_list
system_list($type)
Definition: module.inc:122
theme_get_suggestions
theme_get_suggestions($args, $base, $delimiter= '__')
Definition: theme.inc:2661
drupal_bootstrap
drupal_bootstrap($phase=NULL, $new_phase=TRUE)
Definition: bootstrap.inc:2192
theme_enable
theme_enable($theme_list)
Definition: theme.inc:1529
module_load_all
module_load_all($bootstrap=FALSE)
Definition: module.inc:19
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
DrupalCacheArray\offsetGet
offsetGet($offset)
Definition: theme.inc:424
template_process_html
template_process_html(&$variables)
Definition: theme.inc:2625
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
drupal_get_messages
drupal_get_messages($type=NULL, $clear_queue=TRUE)
Definition: bootstrap.inc:1820
theme_item_list
theme_item_list($variables)
Definition: theme.inc:2082
_theme_load_registry
_theme_load_registry($theme, $base_theme=NULL, $theme_engine=NULL, $complete=TRUE)
Definition: theme.inc:316
system_list_reset
system_list_reset()
Definition: module.inc:224
CSS_THEME
const CSS_THEME
Definition: common.inc:70
tablesort_header
tablesort_header($cell, $header, $ts)
Definition: tablesort.inc:133
template_preprocess
template_preprocess(&$variables, $hook)
Definition: theme.inc:2343
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
menu_rebuild
menu_rebuild()
Definition: menu.inc:2709
$info
$info
Definition: color.inc:6
DrupalCacheArray\set
set($data, $lock=TRUE)
Definition: theme.inc:447
MARK_UPDATED
const MARK_UPDATED
Definition: theme.inc:31
drupal_find_theme_templates
drupal_find_theme_templates($cache, $extension, $path)
Definition: theme.inc:1296
template_process_username
template_process_username(&$variables)
Definition: theme.inc:2904
theme_breadcrumb
theme_breadcrumb($variables)
Definition: theme.inc:1805
menu_secondary_menu
menu_secondary_menu()
Definition: menu.inc:1811
_template_preprocess_default_variables
_template_preprocess_default_variables()
Definition: theme.inc:2380
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
$value
print $value
Definition: user-profile-item.tpl.php:26
template_preprocess_html
template_preprocess_html(&$variables)
Definition: theme.inc:2452
theme_get_registry
theme_get_registry($complete=TRUE)
Definition: theme.inc:255
$messages
print $messages
Definition: page.tpl.php:121
system_region_list
system_region_list($theme_key, $show=REGIONS_ALL)
Definition: system.module:2689
theme_render_template
theme_render_template($template_file, $variables)
Definition: theme.inc:1509
theme_table
theme_table($variables)
Definition: theme.inc:1895
language
print $language language
Definition: book-export-html.tpl.php:22
MARK_NEW
const MARK_NEW
Definition: theme.inc:26
drupal_get_region_content
drupal_get_region_content($region=NULL, $delimiter= ' ')
Definition: common.inc:193
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
theme_username
theme_username($variables)
Definition: theme.inc:2235
theme_links
theme_links($variables)
Definition: theme.inc:1685
theme_get_setting
theme_get_setting($setting_name, $theme=NULL)
Definition: theme.inc:1401
_theme_save_registry
_theme_save_registry($theme, $registry)
Definition: theme.inc:342
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
menu_main_menu
menu_main_menu()
Definition: menu.inc:1804
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
template_preprocess_page
template_preprocess_page(&$variables)
Definition: theme.inc:2545
template_preprocess_maintenance_page
template_preprocess_maintenance_page(&$variables)
Definition: theme.inc:2722
_theme_build_registry
_theme_build_registry($theme, $base_theme, $theme_engine)
Definition: theme.inc:678
drupal_theme_initialize
drupal_theme_initialize()
Definition: theme.inc:70
drupal_region_class
drupal_region_class($region)
Definition: common.inc:3976
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
DrupalCacheArray
Definition: bootstrap.inc:306
drupal_find_base_themes
drupal_find_base_themes($themes, $key, $used_keys=array())
Definition: theme.inc:843
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
drupal_get_html_head
drupal_get_html_head()
Definition: common.inc:352
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
theme_indentation
theme_indentation($variables)
Definition: theme.inc:2278
theme_tablesort_indicator
theme_tablesort_indicator($variables)
Definition: theme.inc:2037
theme_progress_bar
theme_progress_bar($variables)
Definition: theme.inc:2261
theme_html_tag
theme_html_tag($variables)
Definition: theme.inc:2185
DrupalCacheArray\resolveCacheMiss
resolveCacheMiss($offset)
Definition: theme.inc:436
lock_acquire
lock_acquire($name, $timeout=30.0)
Definition: lock.inc:102
theme_link
theme_link($variables)
Definition: theme.inc:1645
theme_image
theme_image($variables)
Definition: theme.inc:1784
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
drupal_get_token
drupal_get_token($value= '')
Definition: common.inc:5077
$breadcrumb
print $breadcrumb
Definition: page.tpl.php:40
DrupalCacheArray\initializeRegistry
initializeRegistry()
Definition: theme.inc:410
language_default
language_default($property=NULL)
Definition: bootstrap.inc:2765
DRUPAL_BOOTSTRAP_DATABASE
const DRUPAL_BOOTSTRAP_DATABASE
Definition: bootstrap.inc:132
template_preprocess_username
template_preprocess_username(&$variables)
Definition: theme.inc:2852
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$children
print $children
Definition: book-node-export-html.tpl.php:24
$row
$row
Definition: block-admin-display-form.tpl.php:47
drupal_get_title
drupal_get_title()
Definition: bootstrap.inc:1848
drupal_get_breadcrumb
drupal_get_breadcrumb()
Definition: common.inc:255
theme_mark
theme_mark($variables)
Definition: theme.inc:2054
template_preprocess_region
template_preprocess_region(&$variables)
Definition: theme.inc:2834
drupal_system_listing
drupal_system_listing($mask, $directory, $key= 'name', $min_depth=1)
Definition: common.inc:5368
list_themes
list_themes($refresh=FALSE)
Definition: theme.inc:774
base_path
base_path()
Definition: common.inc:2817
drupal_theme_rebuild
drupal_theme_rebuild()
Definition: theme.inc:352
tablesort_init
tablesort_init($header)
Definition: tablesort.inc:110
_theme_table_cell
_theme_table_cell($cell, $header=FALSE)
Definition: theme.inc:2303
$head_title
print $head_title
Definition: html.tpl.php:51
drupal_get_feeds
drupal_get_feeds($delimiter="\n")
Definition: common.inc:392
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
theme_feed_icon
theme_feed_icon($variables)
Definition: theme.inc:2159
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
drupal_get_rdf_namespaces
drupal_get_rdf_namespaces()
Definition: common.inc:269
menu_local_tabs
menu_local_tabs()
Definition: menu.inc:2261
menu_get_object
menu_get_object($type= 'node', $position=1, $path=NULL)
Definition: menu.inc:971
theme_more_link
theme_more_link($variables)
Definition: theme.inc:2213
lock_release
lock_release($name)
Definition: lock.inc:247
$links
print $links
Definition: poll-results--block.tpl.php:28
drupal_get_js
drupal_get_js($scope= 'header', $javascript=NULL, $skip_alter=FALSE)
Definition: common.inc:4263
template_process
template_process(&$variables, $hook)
Definition: theme.inc:2433
JS_THEME
const JS_THEME
Definition: common.inc:85
drupal_html_class
drupal_html_class($class)
Definition: common.inc:3841
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.updater.inc Source File

  • modules
  • system
system.updater.inc
Go to the documentation of this file.
1 <?php
2
12 class ModuleUpdater extends Updater implements DrupalUpdaterInterface {
13
26 public function getInstallDirectory() {
27 if ($relative_path = drupal_get_path('module', $this->name)) {
28 $relative_path = dirname($relative_path);
29 }
30 else {
31 $relative_path = 'sites/all/modules';
32 }
33 return DRUPAL_ROOT . '/' . $relative_path;
34 }
35
36 public function isInstalled() {
37 return (bool) drupal_get_path('module', $this->name);
38 }
39
40 public static function canUpdateDirectory($directory) {
41 if (file_scan_directory($directory, '/.*\.module$/')) {
42 return TRUE;
43 }
44 return FALSE;
45 }
46
47 public static function canUpdate($project_name) {
48 return (bool) drupal_get_path('module', $project_name);
49 }
50
54 public function getSchemaUpdates() {
55 require_once DRUPAL_ROOT . '/includes/install.inc';
56 require_once DRUPAL_ROOT . '/includes/update.inc';
57
58 if (_update_get_project_type($project) != 'module') {
59 return array();
60 }
61 module_load_include('install', $project);
62
63 if (!$updates = drupal_get_schema_versions($project)) {
64 return array();
65 }
66 $updates_to_run = array();
67 $modules_with_updates = update_get_update_list();
68 if ($updates = $modules_with_updates[$project]) {
69 if ($updates['start']) {
70 return $updates['pending'];
71 }
72 }
73 return array();
74 }
75
79 public function postInstallTasks() {
80 return array(
81 l(t('Install another module'), 'admin/modules/install'),
82 l(t('Enable newly added modules'), 'admin/modules'),
83 l(t('Administration pages'), 'admin'),
84 );
85 }
86
87 public function postUpdateTasks() {
88 // We don't want to check for DB updates here, we do that once for all
89 // updated modules on the landing page.
90 }
91
92 }
93
97 class ThemeUpdater extends Updater implements DrupalUpdaterInterface {
98
111 public function getInstallDirectory() {
112 if ($relative_path = drupal_get_path('theme', $this->name)) {
113 $relative_path = dirname($relative_path);
114 }
115 else {
116 $relative_path = 'sites/all/themes';
117 }
118 return DRUPAL_ROOT . '/' . $relative_path;
119 }
120
121 public function isInstalled() {
122 return (bool) drupal_get_path('theme', $this->name);
123 }
124
125 static function canUpdateDirectory($directory) {
126 // This is a lousy test, but don't know how else to confirm it is a theme.
127 if (file_scan_directory($directory, '/.*\.module$/')) {
128 return FALSE;
129 }
130 return TRUE;
131 }
132
133 public static function canUpdate($project_name) {
134 return (bool) drupal_get_path('theme', $project_name);
135 }
136
137 public function postInstall() {
138 // Update the system table.
139 clearstatcache();
140 system_rebuild_theme_data();
141
142 }
143
144 public function postInstallTasks() {
145 return array(
146 l(t('Enable newly added themes'), 'admin/appearance'),
147 l(t('Administration pages'), 'admin'),
148 );
149 }
150 }
ModuleUpdater\postInstallTasks
postInstallTasks()
Definition: system.updater.inc:79
ModuleUpdater
Definition: system.updater.inc:12
ModuleUpdater\getInstallDirectory
getInstallDirectory()
Definition: system.updater.inc:26
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
update_get_update_list
update_get_update_list()
Definition: update.inc:1135
file_scan_directory
file_scan_directory($dir, $mask, $options=array(), $depth=0)
Definition: file.inc:2058
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
ThemeUpdater\canUpdateDirectory
static canUpdateDirectory($directory)
Definition: system.updater.inc:125
ModuleUpdater\canUpdate
static canUpdate($project_name)
Definition: system.updater.inc:47
name
print $forum name
Definition: forum-list.tpl.php:57
ThemeUpdater\postInstall
postInstall()
Definition: system.updater.inc:137
ThemeUpdater
Definition: system.updater.inc:97
ThemeUpdater\postInstallTasks
postInstallTasks()
Definition: system.updater.inc:144
system_rebuild_theme_data
system_rebuild_theme_data()
Definition: system.module:2609
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
ModuleUpdater\postUpdateTasks
postUpdateTasks()
Definition: system.updater.inc:87
ModuleUpdater\getSchemaUpdates
getSchemaUpdates()
Definition: system.updater.inc:54
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
ModuleUpdater\canUpdateDirectory
static canUpdateDirectory($directory)
Definition: system.updater.inc:40
ThemeUpdater\canUpdate
static canUpdate($project_name)
Definition: system.updater.inc:133
ModuleUpdater\isInstalled
isInstalled()
Definition: system.updater.inc:36
drupal_get_schema_versions
drupal_get_schema_versions($module)
Definition: install.inc:98
DrupalUpdaterInterface
Definition: updater.inc:21
Updater
Definition: updater.inc:70
ThemeUpdater\getInstallDirectory
getInstallDirectory()
Definition: system.updater.inc:111
ThemeUpdater\isInstalled
isInstalled()
Definition: system.updater.inc:121
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book-export-html.tpl.php Source File

  • modules
  • book
book-export-html.tpl.php
Go to the documentation of this file.
1 <?php
2
20 ?>
21 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
22 <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language->language; ?>" xml:lang="<?php print $language->language; ?>" dir="<?php print $dir; ?>">
23 <head>
24 <title><?php print $title; ?></title>
25 <?php print $head; ?>
26 <base href="<?php print $base_url; ?>" />
27 <link type="text/css" rel="stylesheet" href="misc/print.css" />
28 <?php if ($language_rtl): ?>
29 <link type="text/css" rel="stylesheet" href="misc/print-rtl.css" />
30 <?php endif; ?>
31 </head>
32 <body>
33 <?php
43 $div_close = '';
44 ?>
45 <?php for ($i = 1; $i < $depth; $i++): ?>
46 <div class="section-<?php print $i; ?>">
47 <?php $div_close .= '</div>'; ?>
48 <?php endfor; ?>
49 <?php print $contents; ?>
50 <?php print $div_close; ?>
51 </body>
52 </html>
dir
print $language dir
Definition: html.tpl.php:47
$head
print $head
Definition: book-export-html.tpl.php:25
print
print
Definition: php-2.php:2
$contents
print $contents
Definition: book-export-html.tpl.php:49
$div_close
if($language_rtl) $div_close
Definition: book-export-html.tpl.php:43
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
endif
endif
Definition: aggregator-item.tpl.php:31
link
print $forum link
Definition: forum-list.tpl.php:57
endfor
endfor
Definition: book-export-html.tpl.php:48
title
print $topic title
Definition: forum-topic-list.tpl.php:50
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum.module Source File

  • modules
  • forum
forum.module
Go to the documentation of this file.
1 <?php
2
11 function forum_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#forum':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t('The Forum module lets you create threaded discussion forums with functionality similar to other message board systems. Forums are useful because they allow community members to discuss topics with one another while ensuring those conversations are archived for later reference. In a forum, users post topics and threads in nested hierarchies, allowing discussions to be categorized and grouped. The forum hierarchy consists of:') . '</p>';
17 $output .= '<ul>';
18 $output .= '<li>' . t('Optional containers (for example, <em>Support</em>), which can hold:') . '</li>';
19 $output .= '<ul><li>' . t('Forums (for example, <em>Installing Drupal</em>), which can hold:') . '</li>';
20 $output .= '<ul><li>' . t('Forum topics submitted by users (for example, <em>How to start a Drupal 6 Multisite</em>), which start discussions and are starting points for:') . '</li>';
21 $output .= '<ul><li>' . t('Threaded comments submitted by users (for example, <em>You have these options...</em>).') . '</li>';
22 $output .= '</ul>';
23 $output .= '</ul>';
24 $output .= '</ul>';
25 $output .= '</ul>';
26 $output .= '<p>' . t('For more information, see the online handbook entry for <a href="@forum">Forum module</a>.', array('@forum' => 'http://drupal.org/documentation/modules/forum')) . '</p>';
27 $output .= '<h3>' . t('Uses') . '</h3>';
28 $output .= '<dl>';
29 $output .= '<dt>' . t('Setting up forum structure') . '</dt>';
30 $output .= '<dd>' . t('Visit the <a href="@forums">Forums page</a> to set up containers and forums to hold your discussion topics.', array('@forums' => url('admin/structure/forum'))) . '</dd>';
31 $output .= '<dt>' . t('Starting a discussion') . '</dt>';
32 $output .= '<dd>' . t('The <a href="@create-topic">Forum topic</a> link on the <a href="@content-add">Add new content</a> page creates the first post of a new threaded discussion, or thread.', array('@create-topic' => url('node/add/forum'), '@content-add' => url('node/add'))) . '</dd>';
33 $output .= '<dt>' . t('Navigation') . '</dt>';
34 $output .= '<dd>' . t('Enabling the Forum module provides a default <em>Forums</em> menu item in the navigation menu that links to the <a href="@forums">Forums page</a>.', array('@forums' => url('forum'))) . '</dd>';
35 $output .= '<dt>' . t('Moving forum topics') . '</dt>';
36 $output .= '<dd>' . t('A forum topic (and all of its comments) may be moved between forums by selecting a different forum while editing a forum topic. When moving a forum topic between forums, the <em>Leave shadow copy</em> option creates a link in the original forum pointing to the new location.') . '</dd>';
37 $output .= '<dt>' . t('Locking and disabling comments') . '</dt>';
38 $output .= '<dd>' . t('Selecting <em>Closed</em> under <em>Comment settings</em> while editing a forum topic will lock (prevent new comments on) the thread. Selecting <em>Hidden</em> under <em>Comment settings</em> while editing a forum topic will hide all existing comments on the thread, and prevent new ones.') . '</dd>';
39 $output .= '</dl>';
40 return $output;
41 case 'admin/structure/forum':
42 $output = '<p>' . t('Forums contain forum topics. Use containers to group related forums.') . '</p>';
43 $output .= theme('more_help_link', array('url' => 'admin/help/forum'));
44 return $output;
45 case 'admin/structure/forum/add/container':
46 return '<p>' . t('Use containers to group related forums.') . '</p>';
47 case 'admin/structure/forum/add/forum':
48 return '<p>' . t('A forum holds related forum topics.') . '</p>';
49 case 'admin/structure/forum/settings':
50 return '<p>' . t('Adjust the display of your forum topics. Organize the forums on the <a href="@forum-structure">forum structure page</a>.', array('@forum-structure' => url('admin/structure/forum'))) . '</p>';
51 }
52 }
53
57 function forum_theme() {
58 return array(
59 'forums' => array(
60 'template' => 'forums',
61 'variables' => array('forums' => NULL, 'topics' => NULL, 'parents' => NULL, 'tid' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL),
62 ),
63 'forum_list' => array(
64 'template' => 'forum-list',
65 'variables' => array('forums' => NULL, 'parents' => NULL, 'tid' => NULL),
66 ),
67 'forum_topic_list' => array(
68 'template' => 'forum-topic-list',
69 'variables' => array('tid' => NULL, 'topics' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL),
70 ),
71 'forum_icon' => array(
72 'template' => 'forum-icon',
73 'variables' => array('new_posts' => NULL, 'num_posts' => 0, 'comment_mode' => 0, 'sticky' => 0, 'first_new' => FALSE),
74 ),
75 'forum_submitted' => array(
76 'template' => 'forum-submitted',
77 'variables' => array('topic' => NULL),
78 ),
79 'forum_form' => array(
80 'render element' => 'form',
81 'file' => 'forum.admin.inc',
82 ),
83 );
84 }
85
89 function forum_menu() {
90 $items['forum'] = array(
91 'title' => 'Forums',
92 'page callback' => 'forum_page',
93 'access arguments' => array('access content'),
94 'file' => 'forum.pages.inc',
95 );
96 $items['forum/%forum_forum'] = array(
97 'title' => 'Forums',
98 'page callback' => 'forum_page',
99 'page arguments' => array(1),
100 'access arguments' => array('access content'),
101 'file' => 'forum.pages.inc',
102 );
103 $items['admin/structure/forum'] = array(
104 'title' => 'Forums',
105 'description' => 'Control forum hierarchy settings.',
106 'page callback' => 'drupal_get_form',
107 'page arguments' => array('forum_overview'),
108 'access arguments' => array('administer forums'),
109 'file' => 'forum.admin.inc',
110 );
111 $items['admin/structure/forum/list'] = array(
112 'title' => 'List',
113 'type' => MENU_DEFAULT_LOCAL_TASK,
114 'weight' => -10,
115 );
116 $items['admin/structure/forum/add/container'] = array(
117 'title' => 'Add container',
118 'page callback' => 'forum_form_main',
119 'page arguments' => array('container'),
120 'access arguments' => array('administer forums'),
121 'type' => MENU_LOCAL_ACTION,
122 'parent' => 'admin/structure/forum',
123 'file' => 'forum.admin.inc',
124 );
125 $items['admin/structure/forum/add/forum'] = array(
126 'title' => 'Add forum',
127 'page callback' => 'forum_form_main',
128 'page arguments' => array('forum'),
129 'access arguments' => array('administer forums'),
130 'type' => MENU_LOCAL_ACTION,
131 'parent' => 'admin/structure/forum',
132 'file' => 'forum.admin.inc',
133 );
134 $items['admin/structure/forum/settings'] = array(
135 'title' => 'Settings',
136 'page callback' => 'drupal_get_form',
137 'page arguments' => array('forum_admin_settings'),
138 'access arguments' => array('administer forums'),
139 'weight' => 5,
140 'type' => MENU_LOCAL_TASK,
141 'parent' => 'admin/structure/forum',
142 'file' => 'forum.admin.inc',
143 );
144 $items['admin/structure/forum/edit/container/%taxonomy_term'] = array(
145 'title' => 'Edit container',
146 'page callback' => 'forum_form_main',
147 'page arguments' => array('container', 5),
148 'access arguments' => array('administer forums'),
149 'file' => 'forum.admin.inc',
150 );
151 $items['admin/structure/forum/edit/forum/%taxonomy_term'] = array(
152 'title' => 'Edit forum',
153 'page callback' => 'forum_form_main',
154 'page arguments' => array('forum', 5),
155 'access arguments' => array('administer forums'),
156 'file' => 'forum.admin.inc',
157 );
158 return $items;
159 }
160
164 function forum_menu_local_tasks_alter(&$data, $router_item, $root_path) {
165 global $user;
166
167 // Add action link to 'node/add/forum' on 'forum' sub-pages.
168 if ($root_path == 'forum' || $root_path == 'forum/%') {
169 $tid = (isset($router_item['page_arguments'][0]) ? $router_item['page_arguments'][0]->tid : 0);
170 $forum_term = forum_forum_load($tid);
171 if ($forum_term) {
172 $links = array();
173 // Loop through all bundles for forum taxonomy vocabulary field.
174 $field = field_info_field('taxonomy_forums');
175 foreach ($field['bundles']['node'] as $type) {
176 if (node_access('create', $type)) {
177 $links[$type] = array(
178 '#theme' => 'menu_local_action',
179 '#link' => array(
180 'title' => t('Add new @node_type', array('@node_type' => node_type_get_name($type))),
181 'href' => 'node/add/' . str_replace('_', '-', $type) . '/' . $forum_term->tid,
182 ),
183 );
184 }
185 }
186 if (empty($links)) {
187 // Authenticated user does not have access to create new topics.
188 if ($user->uid) {
189 $links['disallowed'] = array(
190 '#theme' => 'menu_local_action',
191 '#link' => array(
192 'title' => t('You are not allowed to post new content in the forum.'),
193 ),
194 );
195 }
196 // Anonymous user does not have access to create new topics.
197 else {
198 $links['login'] = array(
199 '#theme' => 'menu_local_action',
200 '#link' => array(
201 'title' => t('<a href="@login">Log in</a> to post new content in the forum.', array(
202 '@login' => url('user/login', array('query' => drupal_get_destination())),
203 )),
204 'localized_options' => array('html' => TRUE),
205 ),
206 );
207 }
208 }
209 $data['actions']['output'] = array_merge($data['actions']['output'], $links);
210 }
211 }
212 }
213
217 function forum_entity_info_alter(&$info) {
218 // Take over URI construction for taxonomy terms that are forums.
219 if ($vid = variable_get('forum_nav_vocabulary', 0)) {
220 // Within hook_entity_info(), we can't invoke entity_load() as that would
221 // cause infinite recursion, so we call taxonomy_vocabulary_get_names()
222 // instead of taxonomy_vocabulary_load(). All we need is the machine name
223 // of $vid, so retrieving and iterating all the vocabulary names is somewhat
224 // inefficient, but entity info is cached across page requests, and an
225 // iteration of all vocabularies once per cache clearing isn't a big deal,
226 // and is done as part of taxonomy_entity_info() anyway.
227 foreach (taxonomy_vocabulary_get_names() as $machine_name => $vocabulary) {
228 if ($vid == $vocabulary->vid) {
229 $info['taxonomy_term']['bundles'][$machine_name]['uri callback'] = 'forum_uri';
230 }
231 }
232 }
233 }
234
240 function forum_uri($forum) {
241 return array(
242 'path' => 'forum/' . $forum->tid,
243 );
244 }
245
255 function _forum_node_check_node_type($node) {
256 // Fetch information about the forum field.
257 $field = field_info_instance('node', 'taxonomy_forums', $node->type);
258
259 return is_array($field);
260 }
261
265 function forum_node_view($node, $view_mode) {
266 $vid = variable_get('forum_nav_vocabulary', 0);
267 $vocabulary = taxonomy_vocabulary_load($vid);
268 if (_forum_node_check_node_type($node)) {
269 if ($view_mode == 'full' && node_is_page($node)) {
270 // Breadcrumb navigation
271 $breadcrumb[] = l(t('Home'), NULL);
272 $breadcrumb[] = l($vocabulary->name, 'forum');
273 if ($parents = taxonomy_get_parents_all($node->forum_tid)) {
274 $parents = array_reverse($parents);
275 foreach ($parents as $parent) {
276 $breadcrumb[] = l($parent->name, 'forum/' . $parent->tid);
277 }
278 }
279 drupal_set_breadcrumb($breadcrumb);
280
281 }
282 }
283 }
284
291 function forum_node_validate($node, $form) {
292 if (_forum_node_check_node_type($node)) {
293 $langcode = $form['taxonomy_forums']['#language'];
294 // vocabulary is selected, not a "container" term.
295 if (!empty($node->taxonomy_forums[$langcode])) {
296 // Extract the node's proper topic ID.
297 $containers = variable_get('forum_containers', array());
298 foreach ($node->taxonomy_forums[$langcode] as $delta => $item) {
299 // If no term was selected (e.g. when no terms exist yet), remove the
300 // item.
301 if (empty($item['tid'])) {
302 unset($node->taxonomy_forums[$langcode][$delta]);
303 continue;
304 }
305 $term = taxonomy_term_load($item['tid']);
306 if (!$term) {
307 form_set_error('taxonomy_forums', t('Select a forum.'));
308 continue;
309 }
310 $used = db_query_range('SELECT 1 FROM {taxonomy_term_data} WHERE tid = :tid AND vid = :vid',0 , 1, array(
311 ':tid' => $term->tid,
312 ':vid' => $term->vid,
313 ))->fetchField();
314 if ($used && in_array($term->tid, $containers)) {
315 form_set_error('taxonomy_forums', t('The item %forum is a forum container, not a forum. Select one of the forums below instead.', array('%forum' => $term->name)));
316 }
317 }
318 }
319 }
320 }
321
327 function forum_node_presave($node) {
328 if (_forum_node_check_node_type($node)) {
329 // Make sure all fields are set properly:
330 $node->icon = !empty($node->icon) ? $node->icon : '';
331 reset($node->taxonomy_forums);
332 $langcode = key($node->taxonomy_forums);
333 if (!empty($node->taxonomy_forums[$langcode])) {
334 $node->forum_tid = $node->taxonomy_forums[$langcode][0]['tid'];
335 if (isset($node->nid)) {
336 $old_tid = db_query_range("SELECT f.tid FROM {forum} f INNER JOIN {node} n ON f.vid = n.vid WHERE n.nid = :nid ORDER BY f.vid DESC", 0, 1, array(':nid' => $node->nid))->fetchField();
337 if ($old_tid && isset($node->forum_tid) && ($node->forum_tid != $old_tid) && !empty($node->shadow)) {
338 // A shadow copy needs to be created. Retain new term and add old term.
339 $node->taxonomy_forums[$langcode][] = array('tid' => $old_tid);
340 }
341 }
342 }
343 }
344 }
345
349 function forum_node_update($node) {
350 if (_forum_node_check_node_type($node)) {
351 if (empty($node->revision) && db_query('SELECT tid FROM {forum} WHERE nid=:nid', array(':nid' => $node->nid))->fetchField()) {
352 if (!empty($node->forum_tid)) {
353 db_update('forum')
354 ->fields(array('tid' => $node->forum_tid))
355 ->condition('vid', $node->vid)
356 ->execute();
357 }
358 // The node is removed from the forum.
359 else {
360 db_delete('forum')
361 ->condition('nid', $node->nid)
362 ->execute();
363 }
364 }
365 else {
366 if (!empty($node->forum_tid)) {
367 db_insert('forum')
368 ->fields(array(
369 'tid' => $node->forum_tid,
370 'vid' => $node->vid,
371 'nid' => $node->nid,
372 ))
373 ->execute();
374 }
375 }
376 // If the node has a shadow forum topic, update the record for this
377 // revision.
378 if (!empty($node->shadow)) {
379 db_delete('forum')
380 ->condition('nid', $node->nid)
381 ->condition('vid', $node->vid)
382 ->execute();
383 db_insert('forum')
384 ->fields(array(
385 'nid' => $node->nid,
386 'vid' => $node->vid,
387 'tid' => $node->forum_tid,
388 ))
389 ->execute();
390 }
391 }
392 }
393
397 function forum_node_insert($node) {
398 if (_forum_node_check_node_type($node)) {
399 if (!empty($node->forum_tid)) {
400 $nid = db_insert('forum')
401 ->fields(array(
402 'tid' => $node->forum_tid,
403 'vid' => $node->vid,
404 'nid' => $node->nid,
405 ))
406 ->execute();
407 }
408 }
409 }
410
414 function forum_node_delete($node) {
415 if (_forum_node_check_node_type($node)) {
416 db_delete('forum')
417 ->condition('nid', $node->nid)
418 ->execute();
419 db_delete('forum_index')
420 ->condition('nid', $node->nid)
421 ->execute();
422 }
423 }
424
428 function forum_node_load($nodes) {
429 $node_vids = array();
430 foreach ($nodes as $node) {
431 if (_forum_node_check_node_type($node)) {
432 $node_vids[] = $node->vid;
433 }
434 }
435 if (!empty($node_vids)) {
436 $query = db_select('forum', 'f');
437 $query
438 ->fields('f', array('nid', 'tid'))
439 ->condition('f.vid', $node_vids);
440 $result = $query->execute();
441 foreach ($result as $record) {
442 $nodes[$record->nid]->forum_tid = $record->tid;
443 }
444 }
445 }
446
450 function forum_node_info() {
451 return array(
452 'forum' => array(
453 'name' => t('Forum topic'),
454 'base' => 'forum',
455 'description' => t('A <em>forum topic</em> starts a new discussion thread within a forum.'),
456 'title_label' => t('Subject'),
457 )
458 );
459 }
460
464 function forum_permission() {
465 $perms = array(
466 'administer forums' => array(
467 'title' => t('Administer forums'),
468 ),
469 );
470 return $perms;
471 }
472
476 function forum_taxonomy_term_delete($term) {
477 // For containers, remove the tid from the forum_containers variable.
478 $containers = variable_get('forum_containers', array());
479 $key = array_search($term->tid, $containers);
480 if ($key !== FALSE) {
481 unset($containers[$key]);
482 }
483 variable_set('forum_containers', $containers);
484 }
485
492 function forum_comment_publish($comment) {
493 _forum_update_forum_index($comment->nid);
494 }
495
502 function forum_comment_update($comment) {
503 // comment_save() calls hook_comment_publish() for all published comments,
504 // so we need to handle all other values here.
505 if (!$comment->status) {
506 _forum_update_forum_index($comment->nid);
507 }
508 }
509
513 function forum_comment_unpublish($comment) {
514 _forum_update_forum_index($comment->nid);
515 }
516
520 function forum_comment_delete($comment) {
521 _forum_update_forum_index($comment->nid);
522 }
523
527 function forum_field_storage_pre_insert($entity_type, $entity, &$skip_fields) {
528 if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) {
529 $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
530 foreach ($entity->taxonomy_forums as $language) {
531 foreach ($language as $item) {
532 $query->values(array(
533 'nid' => $entity->nid,
534 'title' => $entity->title,
535 'tid' => $item['tid'],
536 'sticky' => $entity->sticky,
537 'created' => $entity->created,
538 'comment_count' => 0,
539 'last_comment_timestamp' => $entity->created,
540 ));
541 }
542 }
543 $query->execute();
544 }
545 }
546
550 function forum_field_storage_pre_update($entity_type, $entity, &$skip_fields) {
551 $first_call = &drupal_static(__FUNCTION__, array());
552
553 if ($entity_type == 'node' && _forum_node_check_node_type($entity)) {
554
555 // If the node is published, update the forum index.
556 if ($entity->status) {
557
558 // We don't maintain data for old revisions, so clear all previous values
559 // from the table. Since this hook runs once per field, per object, make
560 // sure we only wipe values once.
561 if (!isset($first_call[$entity->nid])) {
562 $first_call[$entity->nid] = FALSE;
563 db_delete('forum_index')->condition('nid', $entity->nid)->execute();
564 }
565 $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
566 foreach ($entity->taxonomy_forums as $language) {
567 foreach ($language as $item) {
568 $query->values(array(
569 'nid' => $entity->nid,
570 'title' => $entity->title,
571 'tid' => $item['tid'],
572 'sticky' => $entity->sticky,
573 'created' => $entity->created,
574 'comment_count' => 0,
575 'last_comment_timestamp' => $entity->created,
576 ));
577 }
578 }
579 $query->execute();
580 // The logic for determining last_comment_count is fairly complex, so
581 // call _forum_update_forum_index() too.
582 _forum_update_forum_index($entity->nid);
583 }
584
585 // When a forum node is unpublished, remove it from the forum_index table.
586 else {
587 db_delete('forum_index')->condition('nid', $entity->nid)->execute();
588 }
589
590 }
591 }
592
596 function forum_form_taxonomy_form_vocabulary_alter(&$form, &$form_state, $form_id) {
597 $vid = variable_get('forum_nav_vocabulary', 0);
598 if (isset($form['vid']['#value']) && $form['vid']['#value'] == $vid) {
599 $form['help_forum_vocab'] = array(
600 '#markup' => t('This is the designated forum vocabulary. Some of the normal vocabulary options have been removed.'),
601 '#weight' => -1,
602 );
603 // Forum's vocabulary always has single hierarchy. Forums and containers
604 // have only one parent or no parent for root items. By default this value
605 // is 0.
606 $form['hierarchy']['#value'] = 1;
607 // Do not allow to delete forum's vocabulary.
608 $form['actions']['delete']['#access'] = FALSE;
609 }
610 }
611
615 function forum_form_taxonomy_form_term_alter(&$form, &$form_state, $form_id) {
616 $vid = variable_get('forum_nav_vocabulary', 0);
617 if (isset($form['vid']['#value']) && $form['vid']['#value'] == $vid) {
618 // Hide multiple parents select from forum terms.
619 $form['relations']['parent']['#access'] = FALSE;
620 }
621 }
622
626 function forum_form_node_form_alter(&$form, &$form_state, $form_id) {
627 if (isset($form['taxonomy_forums'])) {
628 $langcode = $form['taxonomy_forums']['#language'];
629 // Make the vocabulary required for 'real' forum-nodes.
630 $form['taxonomy_forums'][$langcode]['#required'] = TRUE;
631 $form['taxonomy_forums'][$langcode]['#multiple'] = FALSE;
632 if (empty($form['taxonomy_forums'][$langcode]['#default_value'])) {
633 // If there is no default forum already selected, try to get the forum
634 // ID from the URL (e.g., if we are on a page like node/add/forum/2, we
635 // expect "2" to be the ID of the forum that was requested).
636 $requested_forum_id = arg(3);
637 $form['taxonomy_forums'][$langcode]['#default_value'] = is_numeric($requested_forum_id) ? $requested_forum_id : '';
638 }
639 }
640 }
641
645 function forum_block_info() {
646 $blocks['active'] = array(
647 'info' => t('Active forum topics'),
648 'cache' => DRUPAL_CACHE_CUSTOM,
649 'properties' => array('administrative' => TRUE),
650 );
651 $blocks['new'] = array(
652 'info' => t('New forum topics'),
653 'cache' => DRUPAL_CACHE_CUSTOM,
654 'properties' => array('administrative' => TRUE),
655 );
656 return $blocks;
657 }
658
662 function forum_block_configure($delta = '') {
663 $form['forum_block_num_' . $delta] = array(
664 '#type' => 'select',
665 '#title' => t('Number of topics'),
666 '#default_value' => variable_get('forum_block_num_' . $delta, '5'),
667 '#options' => drupal_map_assoc(range(2, 20))
668 );
669 return $form;
670 }
671
675 function forum_block_save($delta = '', $edit = array()) {
676 variable_set('forum_block_num_' . $delta, $edit['forum_block_num_' . $delta]);
677 }
678
685 function forum_block_view($delta = '') {
686 $query = db_select('forum_index', 'f')
687 ->fields('f')
688 ->addTag('node_access');
689 switch ($delta) {
690 case 'active':
691 $title = t('Active forum topics');
692 $query
693 ->orderBy('f.last_comment_timestamp', 'DESC')
694 ->range(0, variable_get('forum_block_num_active', '5'));
695 break;
696
697 case 'new':
698 $title = t('New forum topics');
699 $query
700 ->orderBy('f.created', 'DESC')
701 ->range(0, variable_get('forum_block_num_new', '5'));
702 break;
703 }
704
705 $block['subject'] = $title;
706 // Cache based on the altered query. Enables us to cache with node access enabled.
707 $block['content'] = drupal_render_cache_by_query($query, 'forum_block_view');
708 $block['content']['#access'] = user_access('access content');
709 return $block;
710 }
711
719 function forum_block_view_pre_render($elements) {
720 $result = $elements['#query']->execute();
721 if ($node_title_list = node_title_list($result)) {
722 $elements['forum_list'] = $node_title_list;
723 $elements['forum_more'] = array('#theme' => 'more_link', '#url' => 'forum', '#title' => t('Read the latest forum topics.'));
724 }
725 return $elements;
726 }
727
731 function forum_form($node, $form_state) {
732 $type = node_type_get_type($node);
733 $form['title'] = array(
734 '#type' => 'textfield',
735 '#title' => check_plain($type->title_label),
736 '#default_value' => !empty($node->title) ? $node->title : '',
737 '#required' => TRUE, '#weight' => -5
738 );
739
740 if (!empty($node->nid)) {
741 $forum_terms = $node->taxonomy_forums;
742 // If editing, give option to leave shadows.
743 $shadow = (count($forum_terms) > 1);
744 $form['shadow'] = array('#type' => 'checkbox', '#title' => t('Leave shadow copy'), '#default_value' => $shadow, '#description' => t('If you move this topic, you can leave a link in the old forum to the new forum.'));
745 $form['forum_tid'] = array('#type' => 'value', '#value' => $node->forum_tid);
746 }
747
748 return $form;
749 }
750
765 function forum_forum_load($tid = NULL) {
766 $cache = &drupal_static(__FUNCTION__, array());
767
768 // Return a cached forum tree if available.
769 if (!isset($tid)) {
770 $tid = 0;
771 }
772 if (isset($cache[$tid])) {
773 return $cache[$tid];
774 }
775
776 $vid = variable_get('forum_nav_vocabulary', 0);
777
778 // Load and validate the parent term.
779 if ($tid) {
780 $forum_term = taxonomy_term_load($tid);
781 if (!$forum_term || ($forum_term->vid != $vid)) {
782 return $cache[$tid] = FALSE;
783 }
784 }
785 // If $tid is 0, create an empty object to hold the child terms.
786 elseif ($tid === 0) {
787 $forum_term = (object) array(
788 'tid' => 0,
789 );
790 }
791
792 // Determine if the requested term is a container.
793 if (!$forum_term->tid || in_array($forum_term->tid, variable_get('forum_containers', array()))) {
794 $forum_term->container = 1;
795 }
796
797 // Load parent terms.
798 $forum_term->parents = taxonomy_get_parents_all($forum_term->tid);
799
800 // Load the tree below.
801 $forums = array();
802 $_forums = taxonomy_get_tree($vid, $tid);
803
804 if (count($_forums)) {
805 $query = db_select('node', 'n');
806 $query->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid');
807 $query->join('forum', 'f', 'n.vid = f.vid');
808 $query->addExpression('COUNT(n.nid)', 'topic_count');
809 $query->addExpression('SUM(ncs.comment_count)', 'comment_count');
810 $counts = $query
811 ->fields('f', array('tid'))
812 ->condition('n.status', 1)
813 ->groupBy('tid')
814 ->addTag('node_access')
815 ->execute()
816 ->fetchAllAssoc('tid');
817 }
818
819 foreach ($_forums as $forum) {
820 // Determine if the child term is a container.
821 if (in_array($forum->tid, variable_get('forum_containers', array()))) {
822 $forum->container = 1;
823 }
824
825 // Merge in the topic and post counters.
826 if (!empty($counts[$forum->tid])) {
827 $forum->num_topics = $counts[$forum->tid]->topic_count;
828 $forum->num_posts = $counts[$forum->tid]->topic_count + $counts[$forum->tid]->comment_count;
829 }
830 else {
831 $forum->num_topics = 0;
832 $forum->num_posts = 0;
833 }
834
835 // Query "Last Post" information for this forum.
836 $query = db_select('node', 'n');
837 $query->join('users', 'u1', 'n.uid = u1.uid');
838 $query->join('forum', 'f', 'n.vid = f.vid AND f.tid = :tid', array(':tid' => $forum->tid));
839 $query->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid');
840 $query->join('users', 'u2', 'ncs.last_comment_uid = u2.uid');
841 $query->addExpression('CASE ncs.last_comment_uid WHEN 0 THEN ncs.last_comment_name ELSE u2.name END', 'last_comment_name');
842
843 $topic = $query
844 ->fields('ncs', array('last_comment_timestamp', 'last_comment_uid'))
845 ->condition('n.status', 1)
846 ->orderBy('last_comment_timestamp', 'DESC')
847 ->range(0, 1)
848 ->addTag('node_access')
849 ->execute()
850 ->fetchObject();
851
852 // Merge in the "Last Post" information.
853 $last_post = new stdClass();
854 if (!empty($topic->last_comment_timestamp)) {
855 $last_post->created = $topic->last_comment_timestamp;
856 $last_post->name = $topic->last_comment_name;
857 $last_post->uid = $topic->last_comment_uid;
858 }
859 $forum->last_post = $last_post;
860
861 $forums[$forum->tid] = $forum;
862 }
863
864 // Cache the result, and return the tree.
865 $forum_term->forums = $forums;
866 $cache[$tid] = $forum_term;
867 return $forum_term;
868 }
869
883 function _forum_topics_unread($term, $uid) {
884 $query = db_select('node', 'n');
885 $query->join('forum', 'f', 'n.vid = f.vid AND f.tid = :tid', array(':tid' => $term));
886 $query->leftJoin('history', 'h', 'n.nid = h.nid AND h.uid = :uid', array(':uid' => $uid));
887 $query->addExpression('COUNT(n.nid)', 'count');
888 return $query
889 ->condition('status', 1)
890 ->condition('n.created', NODE_NEW_LIMIT, '>')
891 ->isNull('h.nid')
892 ->addTag('node_access')
893 ->execute()
894 ->fetchField();
895 }
896
914 function forum_get_topics($tid, $sortby, $forum_per_page) {
915 global $user, $forum_topic_list_header;
916
917 $forum_topic_list_header = array(
918 NULL,
919 array('data' => t('Topic'), 'field' => 'f.title'),
920 array('data' => t('Replies'), 'field' => 'f.comment_count'),
921 array('data' => t('Last reply'), 'field' => 'f.last_comment_timestamp'),
922 );
923
924 $order = _forum_get_topic_order($sortby);
925 for ($i = 0; $i < count($forum_topic_list_header); $i++) {
926 if ($forum_topic_list_header[$i]['field'] == $order['field']) {
927 $forum_topic_list_header[$i]['sort'] = $order['sort'];
928 }
929 }
930
931 $query = db_select('forum_index', 'f')->extend('PagerDefault')->extend('TableSort');
932 $query->fields('f');
933 $query
934 ->condition('f.tid', $tid)
935 ->addTag('node_access')
936 ->orderBy('f.sticky', 'DESC')
937 ->orderByHeader($forum_topic_list_header)
938 ->limit($forum_per_page);
939
940 $count_query = db_select('forum_index', 'f');
941 $count_query->condition('f.tid', $tid);
942 $count_query->addExpression('COUNT(*)');
943 $count_query->addTag('node_access');
944
945 $query->setCountQuery($count_query);
946 $result = $query->execute();
947 $nids = array();
948 foreach ($result as $record) {
949 $nids[] = $record->nid;
950 }
951 if ($nids) {
952 $query = db_select('node', 'n')->extend('TableSort');
953 $query->fields('n', array('title', 'nid', 'type', 'sticky', 'created', 'uid'));
954 $query->addField('n', 'comment', 'comment_mode');
955
956 $query->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid');
957 $query->fields('ncs', array('cid', 'last_comment_uid', 'last_comment_timestamp', 'comment_count'));
958
959 $query->join('forum_index', 'f', 'f.nid = ncs.nid');
960 $query->addField('f', 'tid', 'forum_tid');
961
962 $query->join('users', 'u', 'n.uid = u.uid');
963 $query->addField('u', 'name');
964
965 $query->join('users', 'u2', 'ncs.last_comment_uid = u2.uid');
966
967 $query->addExpression('CASE ncs.last_comment_uid WHEN 0 THEN ncs.last_comment_name ELSE u2.name END', 'last_comment_name');
968
969 $query
970 ->orderBy('f.sticky', 'DESC')
971 ->orderByHeader($forum_topic_list_header)
972 ->condition('n.nid', $nids);
973
974 $result = $query->execute();
975 }
976 else {
977 $result = array();
978 }
979
980 $topics = array();
981 $first_new_found = FALSE;
982 foreach ($result as $topic) {
983 if ($user->uid) {
984 // A forum is new if the topic is new, or if there are new comments since
985 // the user's last visit.
986 if ($topic->forum_tid != $tid) {
987 $topic->new = 0;
988 }
989 else {
990 $history = _forum_user_last_visit($topic->nid);
991 $topic->new_replies = comment_num_new($topic->nid, $history);
992 $topic->new = $topic->new_replies || ($topic->last_comment_timestamp > $history);
993 }
994 }
995 else {
996 // Do not track "new replies" status for topics if the user is anonymous.
997 $topic->new_replies = 0;
998 $topic->new = 0;
999 }
1000
1001 // Make sure only one topic is indicated as the first new topic.
1002 $topic->first_new = FALSE;
1003 if ($topic->new != 0 && !$first_new_found) {
1004 $topic->first_new = TRUE;
1005 $first_new_found = TRUE;
1006 }
1007
1008 if ($topic->comment_count > 0) {
1009 $last_reply = new stdClass();
1010 $last_reply->created = $topic->last_comment_timestamp;
1011 $last_reply->name = $topic->last_comment_name;
1012 $last_reply->uid = $topic->last_comment_uid;
1013 $topic->last_reply = $last_reply;
1014 }
1015 $topics[] = $topic;
1016 }
1017
1018 return $topics;
1019 }
1020
1041 function template_preprocess_forums(&$variables) {
1042 global $user;
1043
1044 $vid = variable_get('forum_nav_vocabulary', 0);
1045 $vocabulary = taxonomy_vocabulary_load($vid);
1046 $title = !empty($vocabulary->name) ? $vocabulary->name : '';
1047
1048 // Breadcrumb navigation:
1049 $breadcrumb[] = l(t('Home'), NULL);
1050 if ($variables['tid']) {
1051 $breadcrumb[] = l($vocabulary->name, 'forum');
1052 }
1053 if ($variables['parents']) {
1054 $variables['parents'] = array_reverse($variables['parents']);
1055 foreach ($variables['parents'] as $p) {
1056 if ($p->tid == $variables['tid']) {
1057 $title = $p->name;
1058 }
1059 else {
1060 $breadcrumb[] = l($p->name, 'forum/' . $p->tid);
1061 }
1062 }
1063 }
1064 drupal_set_breadcrumb($breadcrumb);
1065 drupal_set_title($title);
1066
1067 if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) {
1068 if (!empty($variables['forums'])) {
1069 $variables['forums'] = theme('forum_list', $variables);
1070 }
1071 else {
1072 $variables['forums'] = '';
1073 }
1074
1075 if ($variables['tid'] && !in_array($variables['tid'], variable_get('forum_containers', array()))) {
1076 $variables['topics'] = theme('forum_topic_list', $variables);
1077 drupal_add_feed('taxonomy/term/' . $variables['tid'] . '/feed', 'RSS - ' . $title);
1078 }
1079 else {
1080 $variables['topics'] = '';
1081 }
1082
1083 // Provide separate template suggestions based on what's being output. Topic id is also accounted for.
1084 // Check both variables to be safe then the inverse. Forums with topic ID's take precedence.
1085 if ($variables['forums'] && !$variables['topics']) {
1086 $variables['theme_hook_suggestions'][] = 'forums__containers';
1087 $variables['theme_hook_suggestions'][] = 'forums__' . $variables['tid'];
1088 $variables['theme_hook_suggestions'][] = 'forums__containers__' . $variables['tid'];
1089 }
1090 elseif (!$variables['forums'] && $variables['topics']) {
1091 $variables['theme_hook_suggestions'][] = 'forums__topics';
1092 $variables['theme_hook_suggestions'][] = 'forums__' . $variables['tid'];
1093 $variables['theme_hook_suggestions'][] = 'forums__topics__' . $variables['tid'];
1094 }
1095 else {
1096 $variables['theme_hook_suggestions'][] = 'forums__' . $variables['tid'];
1097 }
1098
1099 }
1100 else {
1101 drupal_set_title(t('No forums defined'));
1102 $variables['forums'] = '';
1103 $variables['topics'] = '';
1104 }
1105 }
1106
1121 function template_preprocess_forum_list(&$variables) {
1122 global $user;
1123 $row = 0;
1124 // Sanitize each forum so that the template can safely print the data.
1125 foreach ($variables['forums'] as $id => $forum) {
1126 $variables['forums'][$id]->description = !empty($forum->description) ? filter_xss_admin($forum->description) : '';
1127 $variables['forums'][$id]->link = url("forum/$forum->tid");
1128 $variables['forums'][$id]->name = check_plain($forum->name);
1129 $variables['forums'][$id]->is_container = !empty($forum->container);
1130 $variables['forums'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even';
1131 $row++;
1132
1133 $variables['forums'][$id]->new_text = '';
1134 $variables['forums'][$id]->new_url = '';
1135 $variables['forums'][$id]->new_topics = 0;
1136 $variables['forums'][$id]->old_topics = $forum->num_topics;
1137 $variables['forums'][$id]->icon_class = 'default';
1138 $variables['forums'][$id]->icon_title = t('No new posts');
1139 if ($user->uid) {
1140 $variables['forums'][$id]->new_topics = _forum_topics_unread($forum->tid, $user->uid);
1141 if ($variables['forums'][$id]->new_topics) {
1142 $variables['forums'][$id]->new_text = format_plural($variables['forums'][$id]->new_topics, '1 new', '@count new');
1143 $variables['forums'][$id]->new_url = url("forum/$forum->tid", array('fragment' => 'new'));
1144 $variables['forums'][$id]->icon_class = 'new';
1145 $variables['forums'][$id]->icon_title = t('New posts');
1146 }
1147 $variables['forums'][$id]->old_topics = $forum->num_topics - $variables['forums'][$id]->new_topics;
1148 }
1149 $variables['forums'][$id]->last_reply = theme('forum_submitted', array('topic' => $forum->last_post));
1150 }
1151 // Give meaning to $tid for themers. $tid actually stands for term id.
1152 $variables['forum_id'] = $variables['tid'];
1153 unset($variables['tid']);
1154 }
1155
1168 function template_preprocess_forum_topic_list(&$variables) {
1169 global $forum_topic_list_header;
1170
1171 // Create the tablesorting header.
1172 $ts = tablesort_init($forum_topic_list_header);
1173 $header = '';
1174 foreach ($forum_topic_list_header as $cell) {
1175 $cell = tablesort_header($cell, $forum_topic_list_header, $ts);
1176 $header .= _theme_table_cell($cell, TRUE);
1177 }
1178 $variables['header'] = $header;
1179
1180 if (!empty($variables['topics'])) {
1181 $row = 0;
1182 foreach ($variables['topics'] as $id => $topic) {
1183 $variables['topics'][$id]->icon = theme('forum_icon', array('new_posts' => $topic->new, 'num_posts' => $topic->comment_count, 'comment_mode' => $topic->comment_mode, 'sticky' => $topic->sticky, 'first_new' => $topic->first_new));
1184 $variables['topics'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even';
1185 $row++;
1186
1187 // We keep the actual tid in forum table, if it's different from the
1188 // current tid then it means the topic appears in two forums, one of
1189 // them is a shadow copy.
1190 if ($variables['tid'] != $topic->forum_tid) {
1191 $variables['topics'][$id]->moved = TRUE;
1192 $variables['topics'][$id]->title = check_plain($topic->title);
1193 $variables['topics'][$id]->message = l(t('This topic has been moved'), "forum/$topic->forum_tid");
1194 }
1195 else {
1196 $variables['topics'][$id]->moved = FALSE;
1197 $variables['topics'][$id]->title = l($topic->title, "node/$topic->nid");
1198 $variables['topics'][$id]->message = '';
1199 }
1200 $variables['topics'][$id]->created = theme('forum_submitted', array('topic' => $topic));
1201 $variables['topics'][$id]->last_reply = theme('forum_submitted', array('topic' => isset($topic->last_reply) ? $topic->last_reply : NULL));
1202
1203 $variables['topics'][$id]->new_text = '';
1204 $variables['topics'][$id]->new_url = '';
1205 if ($topic->new_replies) {
1206 $variables['topics'][$id]->new_text = format_plural($topic->new_replies, '1 new', '@count new');
1207 $variables['topics'][$id]->new_url = url("node/$topic->nid", array('query' => comment_new_page_count($topic->comment_count, $topic->new_replies, $topic), 'fragment' => 'new'));
1208 }
1209
1210 }
1211 }
1212 else {
1213 // Make this safe for the template.
1214 $variables['topics'] = array();
1215 }
1216 // Give meaning to $tid for themers. $tid actually stands for term id.
1217 $variables['topic_id'] = $variables['tid'];
1218 unset($variables['tid']);
1219
1220 $variables['pager'] = theme('pager');
1221 }
1222
1238 function template_preprocess_forum_icon(&$variables) {
1239 $variables['hot_threshold'] = variable_get('forum_hot_topic', 15);
1240 if ($variables['num_posts'] > $variables['hot_threshold']) {
1241 $variables['icon_class'] = $variables['new_posts'] ? 'hot-new' : 'hot';
1242 $variables['icon_title'] = $variables['new_posts'] ? t('Hot topic, new comments') : t('Hot topic');
1243 }
1244 else {
1245 $variables['icon_class'] = $variables['new_posts'] ? 'new' : 'default';
1246 $variables['icon_title'] = $variables['new_posts'] ? t('New comments') : t('Normal topic');
1247 }
1248
1249 if ($variables['comment_mode'] == COMMENT_NODE_CLOSED || $variables['comment_mode'] == COMMENT_NODE_HIDDEN) {
1250 $variables['icon_class'] = 'closed';
1251 $variables['icon_title'] = t('Closed topic');
1252 }
1253
1254 if ($variables['sticky'] == 1) {
1255 $variables['icon_class'] = 'sticky';
1256 $variables['icon_title'] = t('Sticky topic');
1257 }
1258 }
1259
1273 function template_preprocess_forum_submitted(&$variables) {
1274 $variables['author'] = isset($variables['topic']->uid) ? theme('username', array('account' => $variables['topic'])) : '';
1275 $variables['time'] = isset($variables['topic']->created) ? format_interval(REQUEST_TIME - $variables['topic']->created) : '';
1276 }
1277
1288 function _forum_user_last_visit($nid) {
1289 global $user;
1290 $history = &drupal_static(__FUNCTION__, array());
1291
1292 if (empty($history)) {
1293 $result = db_query('SELECT nid, timestamp FROM {history} WHERE uid = :uid', array(':uid' => $user->uid));
1294 foreach ($result as $t) {
1295 $history[$t->nid] = $t->timestamp > NODE_NEW_LIMIT ? $t->timestamp : NODE_NEW_LIMIT;
1296 }
1297 }
1298 return isset($history[$nid]) ? $history[$nid] : NODE_NEW_LIMIT;
1299 }
1300
1316 function _forum_get_topic_order($sortby) {
1317 switch ($sortby) {
1318 case 1:
1319 return array('field' => 'f.last_comment_timestamp', 'sort' => 'desc');
1320 break;
1321 case 2:
1322 return array('field' => 'f.last_comment_timestamp', 'sort' => 'asc');
1323 break;
1324 case 3:
1325 return array('field' => 'f.comment_count', 'sort' => 'desc');
1326 break;
1327 case 4:
1328 return array('field' => 'f.comment_count', 'sort' => 'asc');
1329 break;
1330 }
1331 }
1332
1339 function _forum_update_forum_index($nid) {
1340 $count = db_query('SELECT COUNT(cid) FROM {comment} c INNER JOIN {forum_index} i ON c.nid = i.nid WHERE c.nid = :nid AND c.status = :status', array(
1341 ':nid' => $nid,
1342 ':status' => COMMENT_PUBLISHED,
1343 ))->fetchField();
1344
1345 if ($count > 0) {
1346 // Comments exist.
1347 $last_reply = db_query_range('SELECT cid, name, created, uid FROM {comment} WHERE nid = :nid AND status = :status ORDER BY cid DESC', 0, 1, array(
1348 ':nid' => $nid,
1349 ':status' => COMMENT_PUBLISHED,
1350 ))->fetchObject();
1351 db_update('forum_index')
1352 ->fields( array(
1353 'comment_count' => $count,
1354 'last_comment_timestamp' => $last_reply->created,
1355 ))
1356 ->condition('nid', $nid)
1357 ->execute();
1358 }
1359 else {
1360 // Comments do not exist.
1361 $node = db_query('SELECT uid, created FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject();
1362 db_update('forum_index')
1363 ->fields( array(
1364 'comment_count' => 0,
1365 'last_comment_timestamp' => $node->created,
1366 ))
1367 ->condition('nid', $nid)
1368 ->execute();
1369 }
1370 }
1371
1375 function forum_rdf_mapping() {
1376 return array(
1377 array(
1378 'type' => 'node',
1379 'bundle' => 'forum',
1380 'mapping' => array(
1381 'rdftype' => array('sioc:Post', 'sioct:BoardPost'),
1382 'taxonomy_forums' => array(
1383 'predicates' => array('sioc:has_container'),
1384 'type' => 'rel',
1385 ),
1386 ),
1387 ),
1388 array(
1389 'type' => 'taxonomy_term',
1390 'bundle' => 'forums',
1391 'mapping' => array(
1392 'rdftype' => array('sioc:Container', 'sioc:Forum'),
1393 ),
1394 ),
1395 );
1396 }
forum_node_load
forum_node_load($nodes)
Definition: forum.module:428
drupal_render_cache_by_query
drupal_render_cache_by_query($query, $function, $expire=CACHE_TEMPORARY, $granularity=NULL)
Definition: common.inc:6192
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
created
print $topic created
Definition: forum-topic-list.tpl.php:53
template_preprocess_forum_icon
template_preprocess_forum_icon(&$variables)
Definition: forum.module:1238
forum_get_topics
forum_get_topics($tid, $sortby, $forum_per_page)
Definition: forum.module:914
$topics
if($forums_defined) print $topics
Definition: forums.tpl.php:19
forum_node_delete
forum_node_delete($node)
Definition: forum.module:414
forum_comment_delete
forum_comment_delete($comment)
Definition: forum.module:520
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
l
l($text, $path, array $options=array())
Definition: common.inc:2432
taxonomy_get_parents_all
taxonomy_get_parents_all($tid)
Definition: taxonomy.module:1028
forum_form_taxonomy_form_term_alter
forum_form_taxonomy_form_term_alter(&$form, &$form_state, $form_id)
Definition: forum.module:615
forum_taxonomy_term_delete
forum_taxonomy_term_delete($term)
Definition: forum.module:476
drupal_set_breadcrumb
drupal_set_breadcrumb($breadcrumb=NULL)
Definition: common.inc:243
forum_comment_update
forum_comment_update($comment)
Definition: forum.module:502
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
COMMENT_NODE_CLOSED
const COMMENT_NODE_CLOSED
Definition: comment.module:65
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
forum_block_configure
forum_block_configure($delta= '')
Definition: forum.module:662
template_preprocess_forum_list
template_preprocess_forum_list(&$variables)
Definition: forum.module:1121
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
forum_form_taxonomy_form_vocabulary_alter
forum_form_taxonomy_form_vocabulary_alter(&$form, &$form_state, $form_id)
Definition: forum.module:596
node_type_get_type
node_type_get_type($node)
Definition: node.module:410
forum_uri
forum_uri($forum)
Definition: forum.module:240
forum_node_insert
forum_node_insert($node)
Definition: forum.module:397
$header
print $header
Definition: forum-topic-list.tpl.php:42
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
node_is_page
node_is_page($node)
Definition: node.module:1487
forum_field_storage_pre_update
forum_field_storage_pre_update($entity_type, $entity, &$skip_fields)
Definition: forum.module:550
template_preprocess_forums
template_preprocess_forums(&$variables)
Definition: forum.module:1041
_forum_node_check_node_type
_forum_node_check_node_type($node)
Definition: forum.module:255
node_type_get_name
node_type_get_name($node)
Definition: node.module:459
COMMENT_NODE_HIDDEN
const COMMENT_NODE_HIDDEN
Definition: comment.module:60
forum_rdf_mapping
forum_rdf_mapping()
Definition: forum.module:1375
taxonomy_vocabulary_load
taxonomy_vocabulary_load($vid)
Definition: taxonomy.module:1351
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
template_preprocess_forum_submitted
template_preprocess_forum_submitted(&$variables)
Definition: forum.module:1273
template_preprocess_forum_topic_list
template_preprocess_forum_topic_list(&$variables)
Definition: forum.module:1168
forum_block_view
forum_block_view($delta= '')
Definition: forum.module:685
tablesort_header
tablesort_header($cell, $header, $ts)
Definition: tablesort.inc:133
forum_node_update
forum_node_update($node)
Definition: forum.module:349
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
comment_new_page_count
comment_new_page_count($num_comments, $new_replies, $node)
Definition: comment.module:537
forum_comment_unpublish
forum_comment_unpublish($comment)
Definition: forum.module:513
$info
$info
Definition: color.inc:6
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
forum_node_presave
forum_node_presave($node)
Definition: forum.module:327
forum_field_storage_pre_insert
forum_field_storage_pre_insert($entity_type, $entity, &$skip_fields)
Definition: forum.module:527
forum_entity_info_alter
forum_entity_info_alter(&$info)
Definition: forum.module:217
taxonomy_vocabulary_get_names
taxonomy_vocabulary_get_names()
Definition: taxonomy.module:987
forum_menu
forum_menu()
Definition: forum.module:89
forum_block_info
forum_block_info()
Definition: forum.module:645
forum_node_view
forum_node_view($node, $view_mode)
Definition: forum.module:265
$output
$output
Definition: authorize.php:93
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
forum_theme
forum_theme()
Definition: forum.module:57
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
drupal_add_feed
drupal_add_feed($url=NULL, $title= '')
Definition: common.inc:368
_forum_get_topic_order
_forum_get_topic_order($sortby)
Definition: forum.module:1316
comment_num_new
comment_num_new($nid, $timestamp=0)
Definition: comment.module:1729
forum_forum_load
forum_forum_load($tid=NULL)
Definition: forum.module:765
_forum_topics_unread
_forum_topics_unread($term, $uid)
Definition: forum.module:883
forum_block_view_pre_render
forum_block_view_pre_render($elements)
Definition: forum.module:719
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
node_access
node_access($op, $node, $account=NULL)
Definition: node.module:2981
forum_menu_local_tasks_alter
forum_menu_local_tasks_alter(&$data, $router_item, $root_path)
Definition: forum.module:164
forum_form_node_form_alter
forum_form_node_form_alter(&$form, &$form_state, $form_id)
Definition: forum.module:626
forum_node_validate
forum_node_validate($node, $form)
Definition: forum.module:291
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
forum_node_info
forum_node_info()
Definition: forum.module:450
$breadcrumb
print $breadcrumb
Definition: page.tpl.php:40
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
forum_permission
forum_permission()
Definition: forum.module:464
$row
$row
Definition: block-admin-display-form.tpl.php:47
forum_comment_publish
forum_comment_publish($comment)
Definition: forum.module:492
forum_help
forum_help($path, $arg)
Definition: forum.module:11
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
forum_block_save
forum_block_save($delta= '', $edit=array())
Definition: forum.module:675
tablesort_init
tablesort_init($header)
Definition: tablesort.inc:110
taxonomy_get_tree
taxonomy_get_tree($vid, $parent=0, $max_depth=NULL, $load_entities=FALSE)
Definition: taxonomy.module:1105
COMMENT_PUBLISHED
const COMMENT_PUBLISHED
Definition: comment.module:20
_theme_table_cell
_theme_table_cell($cell, $header=FALSE)
Definition: theme.inc:2303
taxonomy_term_load
taxonomy_term_load($tid)
Definition: taxonomy.module:1383
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
forum_form
forum_form($node, $form_state)
Definition: forum.module:731
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
_forum_user_last_visit
_forum_user_last_visit($nid)
Definition: forum.module:1288
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
DRUPAL_CACHE_CUSTOM
const DRUPAL_CACHE_CUSTOM
Definition: common.inc:135
_forum_update_forum_index
_forum_update_forum_index($nid)
Definition: forum.module:1339
$links
print $links
Definition: poll-results--block.tpl.php:28
NODE_NEW_LIMIT
const NODE_NEW_LIMIT
Definition: node.module:45
field_info_instance
field_info_instance($entity_type, $field_name, $bundle_name)
Definition: field.info.inc:623
node_title_list
node_title_list($result, $title=NULL)
Definition: node.module:288
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/block/block.tpl.php Source File

  • modules
  • block
block.tpl.php
Go to the documentation of this file.
1 <?php
2
46 ?>
47 <div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
48
49 <?php print render($title_prefix); ?>
50 <?php if ($block->subject): ?>
51 <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
52 <?php endif;?>
53 <?php print render($title_suffix); ?>
54
55 <div class="content"<?php print $content_attributes; ?>>
56 <?php print $content ?>
57 </div>
58 </div>
$attributes
print $attributes
Definition: block.tpl.php:47
print
print
Definition: php-2.php:2
$content_attributes
print $content_attributes
Definition: block.tpl.php:55
endif
endif
Definition: aggregator-item.tpl.php:31
render
render(&$element)
Definition: common.inc:5988
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field_ui/field_ui.module Source File

  • modules
  • field_ui
field_ui.module
Go to the documentation of this file.
1 <?php
10 function field_ui_help($path, $arg) {
11 switch ($path) {
12 case 'admin/help#field_ui':
13 $output = '';
14 $output .= '<h3>' . t('About') . '</h3>';
15 $output .= '<p>' . t('The Field UI module provides an administrative user interface (UI) for attaching and managing fields. Fields can be defined at the content-type level for content items and comments, at the vocabulary level for taxonomy terms, and at the site level for user accounts. Other modules may also enable fields to be defined for their data. Field types (text, image, number, etc.) are defined by modules, and collected and managed by the <a href="@field">Field module</a>. For more information, see the online handbook entry for <a href="@field_ui" target="_blank">Field UI module</a>.', array('@field' => url('admin/help/field'), '@field_ui' => 'http://drupal.org/documentation/modules/field-ui')) . '</p>';
16 $output .= '<h3>' . t('Uses') . '</h3>';
17 $output .= '<dl>';
18 $output .= '<dt>' . t('Planning fields') . '</dt>';
19 $output .= '<dd>' . t('There are several decisions you will need to make before defining a field for content, comments, etc.:') . '<dl>';
20 $output .= '<dt>' . t('What the field will be called') . '</dt>';
21 $output .= '<dd>' . t('A field has a <em>label</em> (the name displayed in the user interface) and a <em>machine name</em> (the name used internally). The label can be changed after you create the field, if needed, but the machine name cannot be changed after you have created the field.') . '</li>';
22 $output .= '<dt>' . t('What type of data the field will store') . '</dt>';
23 $output .= '<dd>' . t('Each field can store one type of data (text, number, file, etc.). When you define a field, you choose a particular <em>field type</em>, which corresponds to the type of data you want to store. The field type cannot be changed after you have created the field.') . '</dd>';
24 $output .= '<dt>' . t('How the data will be input and displayed') . '</dt>';
25 $output .= '<dd>' . t('Each field type has one or more available <em>widgets</em> associated with it; each widget provides a mechanism for data input when you are editing (text box, select list, file upload, etc.). Each field type also has one or more display options, which determine how the field is displayed to site visitors. The widget and display options can be changed after you have created the field.') . '</dd>';
26 $output .= '<dt>' . t('How many values the field will store') . '</dt>';
27 $output .= '<dd>' . t('You can store one value, a specific maximum number of values, or an unlimited number of values in each field. For example, an employee identification number field might store a single number, whereas a phone number field might store multiple phone numbers. This setting can be changed after you have created the field, but if you reduce the maximum number of values, you may lose information.') . '</dd>';
28 $output .= '</dl>';
29 $output .= '<dt>' . t('Reusing fields') . '</dt>';
30 $output .= '<dd>' . t('Once you have defined a field, you can reuse it. For example, if you define a custom image field for one content type, and you need to have an image field with the same parameters on another content type, you can add the same field to the second content type, in the <em>Add existing field</em> area of the user interface. You could also add this field to a taxonomy vocabulary, comments, user accounts, etc.') . '</dd>';
31 $output .= '<dd>' . t('Some settings of a reused field are unique to each use of the field; others are shared across all places you use the field. For example, the label of a text field is unique to each use, while the setting for the number of values is shared.') . '</dd>';
32 $output .= '<dd>' . t('There are two main reasons for reusing fields. First, reusing fields can save you time over defining new fields. Second, reusing fields also allows you to display, filter, group, and sort content together by field across content types. For example, the contributed Views module allows you to create lists and tables of content. So if you use the same field on multiple content types, you can create a View containing all of those content types together displaying that field, sorted by that field, and/or filtered by that field.') . '</dd>';
33 $output .= '<dt>' . t('Fields on content items') . '</dt>';
34 $output .= '<dd>' . t('Fields on content items are defined at the content-type level, on the <em>Manage fields</em> tab of the content type edit page (which you can reach from the <a href="@types">Content types page</a>). When you define a field for a content type, each content item of that type will have that field added to it. Some fields, such as the Title and Body, are provided for you when you create a content type, or are provided on content types created by your installation profile.', array('@types' => url('admin/structure/types'))) . '</dd>';
35 $output .= '<dt>' . t('Fields on taxonomy terms') . '</dt>';
36 $output .= '<dd>' . t('Fields on taxonomy terms are defined at the taxonomy vocabulary level, on the <em>Manage fields</em> tab of the vocabulary edit page (which you can reach from the <a href="@taxonomy">Taxonomy page</a>). When you define a field for a vocabulary, each term in that vocabulary will have that field added to it. For example, you could define an image field for a vocabulary to store an icon with each term.', array('@taxonomy' => url('admin/structure/taxonomy'))) . '</dd>';
37 $output .= '<dt>' . t('Fields on user accounts') . '</dt>';
38 $output .= '<dd>' . t('Fields on user accounts are defined on a site-wide basis on the <a href="@fields">Manage fields tab</a> of the <a href="@accounts">Account settings</a> page. When you define a field for user accounts, each user account will have that field added to it. For example, you could add a long text field to allow users to include a biography.', array('@fields' => url('admin/config/people/accounts/fields'), '@accounts' => url('admin/config/people/accounts'))) . '</dd>';
39 $output .= '<dt>' . t('Fields on comments') . '</dt>';
40 $output .= '<dd>' . t('Fields on comments are defined at the content-type level, on the <em>Comment fields</em> tab of the content type edit page (which you can reach from the <a href="@types">Content types page</a>). When you add a field for comments, each comment on a content item of that type will have that field added to it. For example, you could add a website field to the comments on forum posts, to allow forum commenters to add a link to their website.', array('@types' => url('admin/structure/types'))) . '</dd>';
41 $output .= '</dl>';
42 return $output;
43
44 case 'admin/reports/fields':
45 return '<p>' . t('This list shows all fields currently in use for easy reference.') . '</p>';
46 }
47 }
48
52 function field_ui_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
53 // The Field UI relies on entity_get_info() to build menu items for entity
54 // field administration pages. Clear the entity info cache and ensure that
55 // the menu is rebuilt.
56 entity_info_cache_clear();
57 menu_rebuild();
58 }
59
63 function field_ui_menu() {
64 $items['admin/reports/fields'] = array(
65 'title' => 'Field list',
66 'description' => 'Overview of fields on all entity types.',
67 'page callback' => 'field_ui_fields_list',
68 'access arguments' => array('administer content types'),
69 'type' => MENU_NORMAL_ITEM,
70 'file' => 'field_ui.admin.inc',
71 );
72
73 // Ensure the following is not executed until field_bundles is working and
74 // tables are updated. Needed to avoid errors on initial installation.
75 if (defined('MAINTENANCE_MODE')) {
76 return $items;
77 }
78
79 // Create tabs for all possible bundles.
80 foreach (entity_get_info() as $entity_type => $entity_info) {
81 if ($entity_info['fieldable']) {
82 foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
83 if (isset($bundle_info['admin'])) {
84 // Extract path information from the bundle.
85 $path = $bundle_info['admin']['path'];
86 // Different bundles can appear on the same path (e.g. %node_type and
87 // %comment_node_type). To allow field_ui_menu_load() to extract the
88 // actual bundle object from the translated menu router path
89 // arguments, we need to identify the argument position of the bundle
90 // name string ('bundle argument') and pass that position to the menu
91 // loader. The position needs to be casted into a string; otherwise it
92 // would be replaced with the bundle name string.
93 if (isset($bundle_info['admin']['bundle argument'])) {
94 $bundle_arg = $bundle_info['admin']['bundle argument'];
95 $bundle_pos = (string) $bundle_arg;
96 }
97 else {
98 $bundle_arg = $bundle_name;
99 $bundle_pos = '0';
100 }
101 // This is the position of the %field_ui_menu placeholder in the
102 // items below.
103 $field_position = count(explode('/', $path)) + 1;
104
105 // Extract access information, providing defaults.
106 $access = array_intersect_key($bundle_info['admin'], drupal_map_assoc(array('access callback', 'access arguments')));
107 $access += array(
108 'access callback' => 'user_access',
109 'access arguments' => array('administer site configuration'),
110 );
111
112 $items["$path/fields"] = array(
113 'title' => 'Manage fields',
114 'page callback' => 'drupal_get_form',
115 'page arguments' => array('field_ui_field_overview_form', $entity_type, $bundle_arg),
116 'type' => MENU_LOCAL_TASK,
117 'weight' => 1,
118 'file' => 'field_ui.admin.inc',
119 ) + $access;
120 $items["$path/fields/%field_ui_menu"] = array(
121 'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'),
122 'title callback' => 'field_ui_menu_title',
123 'title arguments' => array($field_position),
124 'page callback' => 'drupal_get_form',
125 'page arguments' => array('field_ui_field_edit_form', $field_position),
126 'file' => 'field_ui.admin.inc',
127 ) + $access;
128 $items["$path/fields/%field_ui_menu/edit"] = array(
129 'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'),
130 'title' => 'Edit',
131 'page callback' => 'drupal_get_form',
132 'page arguments' => array('field_ui_field_edit_form', $field_position),
133 'type' => MENU_DEFAULT_LOCAL_TASK,
134 'file' => 'field_ui.admin.inc',
135 ) + $access;
136 $items["$path/fields/%field_ui_menu/field-settings"] = array(
137 'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'),
138 'title' => 'Field settings',
139 'page callback' => 'drupal_get_form',
140 'page arguments' => array('field_ui_field_settings_form', $field_position),
141 'type' => MENU_LOCAL_TASK,
142 'file' => 'field_ui.admin.inc',
143 ) + $access;
144 $items["$path/fields/%field_ui_menu/widget-type"] = array(
145 'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'),
146 'title' => 'Widget type',
147 'page callback' => 'drupal_get_form',
148 'page arguments' => array('field_ui_widget_type_form', $field_position),
149 'type' => MENU_LOCAL_TASK,
150 'file' => 'field_ui.admin.inc',
151 ) + $access;
152 $items["$path/fields/%field_ui_menu/delete"] = array(
153 'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'),
154 'title' => 'Delete',
155 'page callback' => 'drupal_get_form',
156 'page arguments' => array('field_ui_field_delete_form', $field_position),
157 'type' => MENU_LOCAL_TASK,
158 'weight' => 10,
159 'file' => 'field_ui.admin.inc',
160 ) + $access;
161
162 // 'Manage display' tab.
163 $items["$path/display"] = array(
164 'title' => 'Manage display',
165 'page callback' => 'drupal_get_form',
166 'page arguments' => array('field_ui_display_overview_form', $entity_type, $bundle_arg, 'default'),
167 'type' => MENU_LOCAL_TASK,
168 'weight' => 2,
169 'file' => 'field_ui.admin.inc',
170 ) + $access;
171
172 // View modes secondary tabs.
173 // The same base $path for the menu item (with a placeholder) can be
174 // used for all bundles of a given entity type; but depending on
175 // administrator settings, each bundle has a different set of view
176 // modes available for customisation. So we define menu items for all
177 // view modes, and use an access callback to determine which ones are
178 // actually visible for a given bundle.
179 $weight = 0;
180 $view_modes = array('default' => array('label' => t('Default'))) + $entity_info['view modes'];
181 foreach ($view_modes as $view_mode => $view_mode_info) {
182 $items["$path/display/$view_mode"] = array(
183 'title' => $view_mode_info['label'],
184 'page arguments' => array('field_ui_display_overview_form', $entity_type, $bundle_arg, $view_mode),
185 // The access callback needs to check both the current 'custom
186 // display' setting for the view mode, and the overall access
187 // rules for the bundle admin pages.
188 'access callback' => '_field_ui_view_mode_menu_access',
189 'access arguments' => array_merge(array($entity_type, $bundle_arg, $view_mode, $access['access callback']), $access['access arguments']),
190 'type' => ($view_mode == 'default' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK),
191 'weight' => ($view_mode == 'default' ? -10 : $weight++),
192 'file' => 'field_ui.admin.inc',
193 );
194 }
195 }
196 }
197 }
198 }
199 return $items;
200 }
201
221 function field_ui_menu_load($field_name, $entity_type, $bundle_name, $bundle_pos, $map) {
222 // Extract the actual bundle name from the translated argument map.
223 // The menu router path to manage fields of an entity can be shared among
224 // multiple bundles. For example:
225 // - admin/structure/types/manage/%node_type/fields/%field_ui_menu
226 // - admin/structure/types/manage/%comment_node_type/fields/%field_ui_menu
227 // The menu system will automatically load the correct bundle depending on the
228 // actual path arguments, but this menu loader function only receives the node
229 // type string as $bundle_name, which is not the bundle name for comments.
230 // We therefore leverage the dynamically translated $map provided by the menu
231 // system to retrieve the actual bundle and bundle name for the current path.
232 if ($bundle_pos > 0) {
233 $bundle = $map[$bundle_pos];
234 $bundle_name = field_extract_bundle($entity_type, $bundle);
235 }
236 // Check whether the field exists at all.
237 if ($field = field_info_field($field_name)) {
238 // Only return the field if a field instance exists for the given entity
239 // type and bundle.
240 if ($instance = field_info_instance($entity_type, $field_name, $bundle_name)) {
241 return $instance;
242 }
243 }
244 return FALSE;
245 }
246
250 function field_ui_menu_title($instance) {
251 return $instance['label'];
252 }
253
257 function _field_ui_view_mode_menu_access($entity_type, $bundle, $view_mode, $access_callback) {
258 // First, determine visibility according to the 'use custom display'
259 // setting for the view mode.
260 $bundle = field_extract_bundle($entity_type, $bundle);
261 $view_mode_settings = field_view_mode_settings($entity_type, $bundle);
262 $visibility = ($view_mode == 'default') || !empty($view_mode_settings[$view_mode]['custom_settings']);
263
264 // Then, determine access according to the $access parameter. This duplicates
265 // part of _menu_check_access().
266 if ($visibility) {
267 // Grab the variable 'access arguments' part.
268 $all_args = func_get_args();
269 $args = array_slice($all_args, 4);
270 $callback = empty($access_callback) ? 0 : trim($access_callback);
271 if (is_numeric($callback)) {
272 return (bool) $callback;
273 }
274 else {
275 // As call_user_func_array() is quite slow and user_access is a very
276 // common callback, it is worth making a special case for it.
277 if ($access_callback == 'user_access') {
278 return (count($args) == 1) ? user_access($args[0]) : user_access($args[0], $args[1]);
279 }
280 elseif (function_exists($access_callback)) {
281 return call_user_func_array($access_callback, $args);
282 }
283 }
284 }
285 }
286
290 function field_ui_theme() {
291 return array(
292 'field_ui_table' => array(
293 'render element' => 'elements',
294 ),
295 );
296 }
297
301 function field_ui_element_info() {
302 return array(
303 'field_ui_table' => array(
304 '#theme' => 'field_ui_table',
305 '#pre_render' => array('field_ui_table_pre_render'),
306 '#regions' => array('' => array()),
307 ),
308 );
309 }
310
314 function field_ui_field_attach_create_bundle($entity_type, $bundle) {
315 // When a new bundle is created, the menu needs to be rebuilt to add our
316 // menu item tabs.
317 variable_set('menu_rebuild_needed', TRUE);
318 }
319
323 function _field_ui_bundle_admin_path($entity_type, $bundle_name) {
324 $bundles = field_info_bundles($entity_type);
325 $bundle_info = $bundles[$bundle_name];
326 if (isset($bundle_info['admin'])) {
327 return isset($bundle_info['admin']['real path']) ? $bundle_info['admin']['real path'] : $bundle_info['admin']['path'];
328 }
329 }
330
334 function field_ui_inactive_instances($entity_type, $bundle_name = NULL) {
335 $params = array('entity_type' => $entity_type);
336
337 if (empty($bundle_name)) {
338 $active = field_info_instances($entity_type);
339 $inactive = array();
340 }
341 else {
342 // Restrict to the specified bundle. For consistency with the case where
343 // $bundle_name is NULL, the $active and $inactive arrays are keyed by
344 // bundle name first.
345 $params['bundle'] = $bundle_name;
346 $active = array($bundle_name => field_info_instances($entity_type, $bundle_name));
347 $inactive = array($bundle_name => array());
348 }
349
350 // Iterate on existing definitions, and spot those that do not appear in the
351 // $active list collected earlier.
352 $all_instances = field_read_instances($params, array('include_inactive' => TRUE));
353 foreach ($all_instances as $instance) {
354 if (!isset($active[$instance['bundle']][$instance['field_name']])) {
355 $inactive[$instance['bundle']][$instance['field_name']] = $instance;
356 }
357 }
358
359 if (!empty($bundle_name)) {
360 return $inactive[$bundle_name];
361 }
362 return $inactive;
363 }
364
373 function field_ui_form_node_type_form_alter(&$form, $form_state) {
374 // We want to display the button only on add page.
375 if (empty($form['#node_type']->type)) {
376 $form['actions']['save_continue'] = array(
377 '#type' => 'submit',
378 '#value' => t('Save and add fields'),
379 '#weight' => 45,
380 );
381 $form['#submit'][] = 'field_ui_form_node_type_form_submit';
382 }
383 }
384
390 function field_ui_form_node_type_form_submit($form, &$form_state) {
391 if ($form_state['triggering_element']['#parents'][0] === 'save_continue') {
392 $form_state['redirect'] = _field_ui_bundle_admin_path('node', $form_state['values']['type']) .'/fields';
393 }
394 }
field_ui_menu_title
field_ui_menu_title($instance)
Definition: field_ui.module:250
field_ui_field_attach_rename_bundle
field_ui_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new)
Definition: field_ui.module:52
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
field_ui_menu
field_ui_menu()
Definition: field_ui.module:63
field_info_instances
field_info_instances($entity_type=NULL, $bundle_name=NULL)
Definition: field.info.inc:592
field_ui_menu_load
field_ui_menu_load($field_name, $entity_type, $bundle_name, $bundle_pos, $map)
Definition: field_ui.module:221
field_ui_form_node_type_form_submit
field_ui_form_node_type_form_submit($form, &$form_state)
Definition: field_ui.module:390
field_ui_inactive_instances
field_ui_inactive_instances($entity_type, $bundle_name=NULL)
Definition: field_ui.module:334
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
MENU_NORMAL_ITEM
const MENU_NORMAL_ITEM
Definition: menu.inc:143
field_read_instances
field_read_instances($params=array(), $include_additional=array())
Definition: field.crud.inc:713
_field_ui_view_mode_menu_access
_field_ui_view_mode_menu_access($entity_type, $bundle, $view_mode, $access_callback)
Definition: field_ui.module:257
entity_info_cache_clear
entity_info_cache_clear()
Definition: common.inc:7690
field_ui_form_node_type_form_alter
field_ui_form_node_type_form_alter(&$form, $form_state)
Definition: field_ui.module:373
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
field_ui_theme
field_ui_theme()
Definition: field_ui.module:290
field_view_mode_settings
field_view_mode_settings($entity_type, $bundle)
Definition: field.module:617
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
menu_rebuild
menu_rebuild()
Definition: menu.inc:2709
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
field_ui_element_info
field_ui_element_info()
Definition: field_ui.module:301
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
field_info_bundles
field_info_bundles($entity_type=NULL)
Definition: field.info.inc:428
_field_ui_bundle_admin_path
_field_ui_bundle_admin_path($entity_type, $bundle_name)
Definition: field_ui.module:323
field_ui_field_attach_create_bundle
field_ui_field_attach_create_bundle($entity_type, $bundle)
Definition: field_ui.module:314
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
field_ui_help
field_ui_help($path, $arg)
Definition: field_ui.module:10
field_extract_bundle
field_extract_bundle($entity_type, $bundle)
Definition: field.module:1010
field_info_instance
field_info_instance($entity_type, $field_name, $bundle_name)
Definition: field.info.inc:623
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/iso.inc Source File

  • includes
iso.inc
Go to the documentation of this file.
1 <?php
2
17 function _country_get_predefined_list() {
18 static $countries;
19
20 if (isset($countries)) {
21 return $countries;
22 }
23 $t = get_t();
24
25 $countries = array(
26 'AD' => $t('Andorra'),
27 'AE' => $t('United Arab Emirates'),
28 'AF' => $t('Afghanistan'),
29 'AG' => $t('Antigua and Barbuda'),
30 'AI' => $t('Anguilla'),
31 'AL' => $t('Albania'),
32 'AM' => $t('Armenia'),
33 'AN' => $t('Netherlands Antilles'),
34 'AO' => $t('Angola'),
35 'AQ' => $t('Antarctica'),
36 'AR' => $t('Argentina'),
37 'AS' => $t('American Samoa'),
38 'AT' => $t('Austria'),
39 'AU' => $t('Australia'),
40 'AW' => $t('Aruba'),
41 'AX' => $t('Aland Islands'),
42 'AZ' => $t('Azerbaijan'),
43 'BA' => $t('Bosnia and Herzegovina'),
44 'BB' => $t('Barbados'),
45 'BD' => $t('Bangladesh'),
46 'BE' => $t('Belgium'),
47 'BF' => $t('Burkina Faso'),
48 'BG' => $t('Bulgaria'),
49 'BH' => $t('Bahrain'),
50 'BI' => $t('Burundi'),
51 'BJ' => $t('Benin'),
52 'BL' => $t('Saint Barthélemy'),
53 'BM' => $t('Bermuda'),
54 'BN' => $t('Brunei'),
55 'BO' => $t('Bolivia'),
56 'BR' => $t('Brazil'),
57 'BS' => $t('Bahamas'),
58 'BT' => $t('Bhutan'),
59 'BV' => $t('Bouvet Island'),
60 'BW' => $t('Botswana'),
61 'BY' => $t('Belarus'),
62 'BZ' => $t('Belize'),
63 'CA' => $t('Canada'),
64 'CC' => $t('Cocos (Keeling) Islands'),
65 'CD' => $t('Congo (Kinshasa)'),
66 'CF' => $t('Central African Republic'),
67 'CG' => $t('Congo (Brazzaville)'),
68 'CH' => $t('Switzerland'),
69 'CI' => $t('Ivory Coast'),
70 'CK' => $t('Cook Islands'),
71 'CL' => $t('Chile'),
72 'CM' => $t('Cameroon'),
73 'CN' => $t('China'),
74 'CO' => $t('Colombia'),
75 'CR' => $t('Costa Rica'),
76 'CU' => $t('Cuba'),
77 'CW' => $t('Curaçao'),
78 'CV' => $t('Cape Verde'),
79 'CX' => $t('Christmas Island'),
80 'CY' => $t('Cyprus'),
81 'CZ' => $t('Czech Republic'),
82 'DE' => $t('Germany'),
83 'DJ' => $t('Djibouti'),
84 'DK' => $t('Denmark'),
85 'DM' => $t('Dominica'),
86 'DO' => $t('Dominican Republic'),
87 'DZ' => $t('Algeria'),
88 'EC' => $t('Ecuador'),
89 'EE' => $t('Estonia'),
90 'EG' => $t('Egypt'),
91 'EH' => $t('Western Sahara'),
92 'ER' => $t('Eritrea'),
93 'ES' => $t('Spain'),
94 'ET' => $t('Ethiopia'),
95 'FI' => $t('Finland'),
96 'FJ' => $t('Fiji'),
97 'FK' => $t('Falkland Islands'),
98 'FM' => $t('Micronesia'),
99 'FO' => $t('Faroe Islands'),
100 'FR' => $t('France'),
101 'GA' => $t('Gabon'),
102 'GB' => $t('United Kingdom'),
103 'GD' => $t('Grenada'),
104 'GE' => $t('Georgia'),
105 'GF' => $t('French Guiana'),
106 'GG' => $t('Guernsey'),
107 'GH' => $t('Ghana'),
108 'GI' => $t('Gibraltar'),
109 'GL' => $t('Greenland'),
110 'GM' => $t('Gambia'),
111 'GN' => $t('Guinea'),
112 'GP' => $t('Guadeloupe'),
113 'GQ' => $t('Equatorial Guinea'),
114 'GR' => $t('Greece'),
115 'GS' => $t('South Georgia and the South Sandwich Islands'),
116 'GT' => $t('Guatemala'),
117 'GU' => $t('Guam'),
118 'GW' => $t('Guinea-Bissau'),
119 'GY' => $t('Guyana'),
120 'HK' => $t('Hong Kong S.A.R., China'),
121 'HM' => $t('Heard Island and McDonald Islands'),
122 'HN' => $t('Honduras'),
123 'HR' => $t('Croatia'),
124 'HT' => $t('Haiti'),
125 'HU' => $t('Hungary'),
126 'ID' => $t('Indonesia'),
127 'IE' => $t('Ireland'),
128 'IL' => $t('Israel'),
129 'IM' => $t('Isle of Man'),
130 'IN' => $t('India'),
131 'IO' => $t('British Indian Ocean Territory'),
132 'IQ' => $t('Iraq'),
133 'IR' => $t('Iran'),
134 'IS' => $t('Iceland'),
135 'IT' => $t('Italy'),
136 'JE' => $t('Jersey'),
137 'JM' => $t('Jamaica'),
138 'JO' => $t('Jordan'),
139 'JP' => $t('Japan'),
140 'KE' => $t('Kenya'),
141 'KG' => $t('Kyrgyzstan'),
142 'KH' => $t('Cambodia'),
143 'KI' => $t('Kiribati'),
144 'KM' => $t('Comoros'),
145 'KN' => $t('Saint Kitts and Nevis'),
146 'KP' => $t('North Korea'),
147 'KR' => $t('South Korea'),
148 'KW' => $t('Kuwait'),
149 'KY' => $t('Cayman Islands'),
150 'KZ' => $t('Kazakhstan'),
151 'LA' => $t('Laos'),
152 'LB' => $t('Lebanon'),
153 'LC' => $t('Saint Lucia'),
154 'LI' => $t('Liechtenstein'),
155 'LK' => $t('Sri Lanka'),
156 'LR' => $t('Liberia'),
157 'LS' => $t('Lesotho'),
158 'LT' => $t('Lithuania'),
159 'LU' => $t('Luxembourg'),
160 'LV' => $t('Latvia'),
161 'LY' => $t('Libya'),
162 'MA' => $t('Morocco'),
163 'MC' => $t('Monaco'),
164 'MD' => $t('Moldova'),
165 'ME' => $t('Montenegro'),
166 'MF' => $t('Saint Martin (French part)'),
167 'MG' => $t('Madagascar'),
168 'MH' => $t('Marshall Islands'),
169 'MK' => $t('Macedonia'),
170 'ML' => $t('Mali'),
171 'MM' => $t('Myanmar'),
172 'MN' => $t('Mongolia'),
173 'MO' => $t('Macao S.A.R., China'),
174 'MP' => $t('Northern Mariana Islands'),
175 'MQ' => $t('Martinique'),
176 'MR' => $t('Mauritania'),
177 'MS' => $t('Montserrat'),
178 'MT' => $t('Malta'),
179 'MU' => $t('Mauritius'),
180 'MV' => $t('Maldives'),
181 'MW' => $t('Malawi'),
182 'MX' => $t('Mexico'),
183 'MY' => $t('Malaysia'),
184 'MZ' => $t('Mozambique'),
185 'NA' => $t('Namibia'),
186 'NC' => $t('New Caledonia'),
187 'NE' => $t('Niger'),
188 'NF' => $t('Norfolk Island'),
189 'NG' => $t('Nigeria'),
190 'NI' => $t('Nicaragua'),
191 'NL' => $t('Netherlands'),
192 'NO' => $t('Norway'),
193 'NP' => $t('Nepal'),
194 'NR' => $t('Nauru'),
195 'NU' => $t('Niue'),
196 'NZ' => $t('New Zealand'),
197 'OM' => $t('Oman'),
198 'PA' => $t('Panama'),
199 'PE' => $t('Peru'),
200 'PF' => $t('French Polynesia'),
201 'PG' => $t('Papua New Guinea'),
202 'PH' => $t('Philippines'),
203 'PK' => $t('Pakistan'),
204 'PL' => $t('Poland'),
205 'PM' => $t('Saint Pierre and Miquelon'),
206 'PN' => $t('Pitcairn'),
207 'PR' => $t('Puerto Rico'),
208 'PS' => $t('Palestinian Territory'),
209 'PT' => $t('Portugal'),
210 'PW' => $t('Palau'),
211 'PY' => $t('Paraguay'),
212 'QA' => $t('Qatar'),
213 'RE' => $t('Reunion'),
214 'RO' => $t('Romania'),
215 'RS' => $t('Serbia'),
216 'RU' => $t('Russia'),
217 'RW' => $t('Rwanda'),
218 'SA' => $t('Saudi Arabia'),
219 'SB' => $t('Solomon Islands'),
220 'SC' => $t('Seychelles'),
221 'SD' => $t('Sudan'),
222 'SE' => $t('Sweden'),
223 'SG' => $t('Singapore'),
224 'SH' => $t('Saint Helena'),
225 'SI' => $t('Slovenia'),
226 'SJ' => $t('Svalbard and Jan Mayen'),
227 'SK' => $t('Slovakia'),
228 'SL' => $t('Sierra Leone'),
229 'SM' => $t('San Marino'),
230 'SN' => $t('Senegal'),
231 'SO' => $t('Somalia'),
232 'SR' => $t('Suriname'),
233 'ST' => $t('Sao Tome and Principe'),
234 'SV' => $t('El Salvador'),
235 'SY' => $t('Syria'),
236 'SZ' => $t('Swaziland'),
237 'TC' => $t('Turks and Caicos Islands'),
238 'TD' => $t('Chad'),
239 'TF' => $t('French Southern Territories'),
240 'TG' => $t('Togo'),
241 'TH' => $t('Thailand'),
242 'TJ' => $t('Tajikistan'),
243 'TK' => $t('Tokelau'),
244 'TL' => $t('Timor-Leste'),
245 'TM' => $t('Turkmenistan'),
246 'TN' => $t('Tunisia'),
247 'TO' => $t('Tonga'),
248 'TR' => $t('Turkey'),
249 'TT' => $t('Trinidad and Tobago'),
250 'TV' => $t('Tuvalu'),
251 'TW' => $t('Taiwan'),
252 'TZ' => $t('Tanzania'),
253 'UA' => $t('Ukraine'),
254 'UG' => $t('Uganda'),
255 'UM' => $t('United States Minor Outlying Islands'),
256 'US' => $t('United States'),
257 'UY' => $t('Uruguay'),
258 'UZ' => $t('Uzbekistan'),
259 'VA' => $t('Vatican'),
260 'VC' => $t('Saint Vincent and the Grenadines'),
261 'VE' => $t('Venezuela'),
262 'VG' => $t('British Virgin Islands'),
263 'VI' => $t('U.S. Virgin Islands'),
264 'VN' => $t('Vietnam'),
265 'VU' => $t('Vanuatu'),
266 'WF' => $t('Wallis and Futuna'),
267 'WS' => $t('Samoa'),
268 'YE' => $t('Yemen'),
269 'YT' => $t('Mayotte'),
270 'ZA' => $t('South Africa'),
271 'ZM' => $t('Zambia'),
272 'ZW' => $t('Zimbabwe'),
273 );
274
275 // Sort the list.
276 natcasesort($countries);
277
278 return $countries;
279 }
280
291 function _locale_get_predefined_list() {
292 return array(
293 'aa' => array('Afar'),
294 'ab' => array('Abkhazian', 'аҧсуа бызшәа'),
295 'ae' => array('Avestan'),
296 'af' => array('Afrikaans'),
297 'ak' => array('Akan'),
298 'am' => array('Amharic', 'አማርኛ'),
299 'ar' => array('Arabic', /* Left-to-right marker "‭" */ 'العربية', LANGUAGE_RTL),
300 'as' => array('Assamese'),
301 'ast' => array('Asturian'),
302 'av' => array('Avar'),
303 'ay' => array('Aymara'),
304 'az' => array('Azerbaijani', 'azərbaycan'),
305 'ba' => array('Bashkir'),
306 'be' => array('Belarusian', 'Беларуская'),
307 'bg' => array('Bulgarian', 'Български'),
308 'bh' => array('Bihari'),
309 'bi' => array('Bislama'),
310 'bm' => array('Bambara', 'Bamanankan'),
311 'bn' => array('Bengali'),
312 'bo' => array('Tibetan'),
313 'br' => array('Breton'),
314 'bs' => array('Bosnian', 'Bosanski'),
315 'ca' => array('Catalan', 'Català'),
316 'ce' => array('Chechen'),
317 'ch' => array('Chamorro'),
318 'co' => array('Corsican'),
319 'cr' => array('Cree'),
320 'cs' => array('Czech', 'Čeština'),
321 'cu' => array('Old Slavonic'),
322 'cv' => array('Chuvash'),
323 'cy' => array('Welsh', 'Cymraeg'),
324 'da' => array('Danish', 'Dansk'),
325 'de' => array('German', 'Deutsch'),
326 'dv' => array('Maldivian'),
327 'dz' => array('Bhutani'),
328 'ee' => array('Ewe', 'Ɛʋɛ'),
329 'el' => array('Greek', 'Ελληνικά'),
330 'en' => array('English'),
331 'en-gb' => array('English, British'),
332 'eo' => array('Esperanto'),
333 'es' => array('Spanish', 'Español'),
334 'et' => array('Estonian', 'Eesti'),
335 'eu' => array('Basque', 'Euskera'),
336 'fa' => array('Persian', /* Left-to-right marker "‭" */ 'فارسی', LANGUAGE_RTL),
337 'ff' => array('Fulah', 'Fulfulde'),
338 'fi' => array('Finnish', 'Suomi'),
339 'fil' => array('Filipino'),
340 'fj' => array('Fiji'),
341 'fo' => array('Faeroese'),
342 'fr' => array('French', 'Français'),
343 'fy' => array('Frisian', 'Frysk'),
344 'ga' => array('Irish', 'Gaeilge'),
345 'gd' => array('Scots Gaelic'),
346 'gl' => array('Galician', 'Galego'),
347 'gn' => array('Guarani'),
348 'gsw-berne' => array('Swiss German'),
349 'gu' => array('Gujarati'),
350 'gv' => array('Manx'),
351 'ha' => array('Hausa'),
352 'he' => array('Hebrew', /* Left-to-right marker "‭" */ 'עברית', LANGUAGE_RTL),
353 'hi' => array('Hindi', 'हिन्दी'),
354 'ho' => array('Hiri Motu'),
355 'hr' => array('Croatian', 'Hrvatski'),
356 'ht' => array('Haitian Creole'),
357 'hu' => array('Hungarian', 'Magyar'),
358 'hy' => array('Armenian', 'Հայերեն'),
359 'hz' => array('Herero'),
360 'ia' => array('Interlingua'),
361 'id' => array('Indonesian', 'Bahasa Indonesia'),
362 'ie' => array('Interlingue'),
363 'ig' => array('Igbo'),
364 'ik' => array('Inupiak'),
365 'is' => array('Icelandic', 'Íslenska'),
366 'it' => array('Italian', 'Italiano'),
367 'iu' => array('Inuktitut'),
368 'ja' => array('Japanese', '日本語'),
369 'jv' => array('Javanese'),
370 'ka' => array('Georgian'),
371 'kg' => array('Kongo'),
372 'ki' => array('Kikuyu'),
373 'kj' => array('Kwanyama'),
374 'kk' => array('Kazakh', 'Қазақ'),
375 'kl' => array('Greenlandic'),
376 'km' => array('Cambodian'),
377 'kn' => array('Kannada', 'ಕನ್ನಡ'),
378 'ko' => array('Korean', '한국어'),
379 'kr' => array('Kanuri'),
380 'ks' => array('Kashmiri'),
381 'ku' => array('Kurdish', 'Kurdî'),
382 'kv' => array('Komi'),
383 'kw' => array('Cornish'),
384 'ky' => array('Kyrgyz', 'Кыргызча'),
385 'la' => array('Latin', 'Latina'),
386 'lb' => array('Luxembourgish'),
387 'lg' => array('Luganda'),
388 'ln' => array('Lingala'),
389 'lo' => array('Laothian'),
390 'lt' => array('Lithuanian', 'Lietuvių'),
391 'lv' => array('Latvian', 'Latviešu'),
392 'mg' => array('Malagasy'),
393 'mh' => array('Marshallese'),
394 'mi' => array('Māori'),
395 'mk' => array('Macedonian', 'Македонски'),
396 'ml' => array('Malayalam', 'മലയാളം'),
397 'mn' => array('Mongolian'),
398 'mo' => array('Moldavian'),
399 'mr' => array('Marathi'),
400 'ms' => array('Malay', 'Bahasa Melayu'),
401 'mt' => array('Maltese', 'Malti'),
402 'my' => array('Burmese'),
403 'na' => array('Nauru'),
404 'nd' => array('North Ndebele'),
405 'ne' => array('Nepali'),
406 'ng' => array('Ndonga'),
407 'nl' => array('Dutch', 'Nederlands'),
408 'nb' => array('Norwegian Bokmål', 'Bokmål'),
409 'nn' => array('Norwegian Nynorsk', 'Nynorsk'),
410 'nr' => array('South Ndebele'),
411 'nv' => array('Navajo'),
412 'ny' => array('Chichewa'),
413 'oc' => array('Occitan'),
414 'om' => array('Oromo'),
415 'or' => array('Oriya'),
416 'os' => array('Ossetian'),
417 'pa' => array('Punjabi'),
418 'pi' => array('Pali'),
419 'pl' => array('Polish', 'Polski'),
420 'ps' => array('Pashto', /* Left-to-right marker "‭" */ 'پښتو', LANGUAGE_RTL),
421 'pt' => array('Portuguese, International'),
422 'pt-pt' => array('Portuguese, Portugal', 'Português'),
423 'pt-br' => array('Portuguese, Brazil', 'Português'),
424 'qu' => array('Quechua'),
425 'rm' => array('Rhaeto-Romance'),
426 'rn' => array('Kirundi'),
427 'ro' => array('Romanian', 'Română'),
428 'ru' => array('Russian', 'Русский'),
429 'rw' => array('Kinyarwanda'),
430 'sa' => array('Sanskrit'),
431 'sc' => array('Sardinian'),
432 'sco' => array('Scots'),
433 'sd' => array('Sindhi'),
434 'se' => array('Northern Sami'),
435 'sg' => array('Sango'),
436 'sh' => array('Serbo-Croatian'),
437 'si' => array('Sinhala', 'සිංහල'),
438 'sk' => array('Slovak', 'Slovenčina'),
439 'sl' => array('Slovenian', 'Slovenščina'),
440 'sm' => array('Samoan'),
441 'sn' => array('Shona'),
442 'so' => array('Somali'),
443 'sq' => array('Albanian', 'Shqip'),
444 'sr' => array('Serbian', 'Српски'),
445 'ss' => array('Siswati'),
446 'st' => array('Sesotho'),
447 'su' => array('Sudanese'),
448 'sv' => array('Swedish', 'Svenska'),
449 'sw' => array('Swahili', 'Kiswahili'),
450 'ta' => array('Tamil', 'தமிழ்'),
451 'te' => array('Telugu', 'తెలుగు'),
452 'tg' => array('Tajik'),
453 'th' => array('Thai', 'ภาษาไทย'),
454 'ti' => array('Tigrinya'),
455 'tk' => array('Turkmen'),
456 'tl' => array('Tagalog'),
457 'tn' => array('Setswana'),
458 'to' => array('Tonga'),
459 'tr' => array('Turkish', 'Türkçe'),
460 'ts' => array('Tsonga'),
461 'tt' => array('Tatar', 'Tatarça'),
462 'tw' => array('Twi'),
463 'ty' => array('Tahitian'),
464 'ug' => array('Uyghur'),
465 'uk' => array('Ukrainian', 'Українська'),
466 'ur' => array('Urdu', /* Left-to-right marker "‭" */ 'اردو', LANGUAGE_RTL),
467 'uz' => array('Uzbek', "o'zbek"),
468 've' => array('Venda'),
469 'vi' => array('Vietnamese', 'Tiếng Việt'),
470 'wo' => array('Wolof'),
471 'xh' => array('Xhosa', 'isiXhosa'),
472 'xx-lolspeak' => array('Lolspeak'),
473 'yi' => array('Yiddish'),
474 'yo' => array('Yoruba', 'Yorùbá'),
475 'za' => array('Zhuang'),
476 'zh-hans' => array('Chinese, Simplified', '简体中文'),
477 'zh-hant' => array('Chinese, Traditional', '繁體中文'),
478 'zu' => array('Zulu', 'isiZulu'),
479 );
480 }
LANGUAGE_RTL
const LANGUAGE_RTL
Definition: bootstrap.inc:206
_locale_get_predefined_list
_locale_get_predefined_list()
Definition: iso.inc:291
_country_get_predefined_list
_country_get_predefined_list()
Definition: iso.inc:17
get_t
get_t()
Definition: bootstrap.inc:2635
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/mysql/schema.inc Source File

  • includes
  • database
  • mysql
schema.inc
Go to the documentation of this file.
1 <?php
2
14 class DatabaseSchema_mysql extends DatabaseSchema {
15
19 const COMMENT_MAX_TABLE = 60;
20
24 const COMMENT_MAX_COLUMN = 255;
25
32 protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) {
33 $info = array('prefix' => $this->connection->tablePrefix($table));
34 if ($add_prefix) {
35 $table = $info['prefix'] . $table;
36 }
37 if (($pos = strpos($table, '.')) !== FALSE) {
38 $info['database'] = substr($table, 0, $pos);
39 $info['table'] = substr($table, ++$pos);
40 }
41 else {
42 $db_info = Database::getConnectionInfo();
43 $info['database'] = $db_info['default']['database'];
44 $info['table'] = $table;
45 }
46 return $info;
47 }
48
57 protected function buildTableNameCondition($table_name, $operator = '=', $add_prefix = TRUE) {
58 $info = $this->connection->getConnectionOptions();
59
60 $table_info = $this->getPrefixInfo($table_name, $add_prefix);
61
62 $condition = new DatabaseCondition('AND');
63 $condition->condition('table_schema', $table_info['database']);
64 $condition->condition('table_name', $table_info['table'], $operator);
65 return $condition;
66 }
67
78 protected function createTableSql($name, $table) {
79 $info = $this->connection->getConnectionOptions();
80
81 // Provide defaults if needed.
82 $table += array(
83 'mysql_engine' => 'InnoDB',
84 'mysql_character_set' => 'utf8',
85 );
86
87 $sql = "CREATE TABLE {" . $name . "} (\n";
88
89 // Add the SQL statement for each field.
90 foreach ($table['fields'] as $field_name => $field) {
91 $sql .= $this->createFieldSql($field_name, $this->processField($field)) . ", \n";
92 }
93
94 // Process keys & indexes.
95 $keys = $this->createKeysSql($table);
96 if (count($keys)) {
97 $sql .= implode(", \n", $keys) . ", \n";
98 }
99
100 // Remove the last comma and space.
101 $sql = substr($sql, 0, -3) . "\n) ";
102
103 $sql .= 'ENGINE = ' . $table['mysql_engine'] . ' DEFAULT CHARACTER SET ' . $table['mysql_character_set'];
104 // By default, MySQL uses the default collation for new tables, which is
105 // 'utf8_general_ci' for utf8. If an alternate collation has been set, it
106 // needs to be explicitly specified.
107 // @see DatabaseConnection_mysql
108 if (!empty($info['collation'])) {
109 $sql .= ' COLLATE ' . $info['collation'];
110 }
111
112 // Add table comment.
113 if (!empty($table['description'])) {
114 $sql .= ' COMMENT ' . $this->prepareComment($table['description'], self::COMMENT_MAX_TABLE);
115 }
116
117 return array($sql);
118 }
119
131 protected function createFieldSql($name, $spec) {
132 $sql = "`" . $name . "` " . $spec['mysql_type'];
133
134 if (in_array($spec['mysql_type'], array('VARCHAR', 'CHAR', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'TEXT'))) {
135 if (isset($spec['length'])) {
136 $sql .= '(' . $spec['length'] . ')';
137 }
138 if (!empty($spec['binary'])) {
139 $sql .= ' BINARY';
140 }
141 }
142 elseif (isset($spec['precision']) && isset($spec['scale'])) {
143 $sql .= '(' . $spec['precision'] . ', ' . $spec['scale'] . ')';
144 }
145
146 if (!empty($spec['unsigned'])) {
147 $sql .= ' unsigned';
148 }
149
150 if (isset($spec['not null'])) {
151 if ($spec['not null']) {
152 $sql .= ' NOT NULL';
153 }
154 else {
155 $sql .= ' NULL';
156 }
157 }
158
159 if (!empty($spec['auto_increment'])) {
160 $sql .= ' auto_increment';
161 }
162
163 // $spec['default'] can be NULL, so we explicitly check for the key here.
164 if (array_key_exists('default', $spec)) {
165 if (is_string($spec['default'])) {
166 $spec['default'] = "'" . $spec['default'] . "'";
167 }
168 elseif (!isset($spec['default'])) {
169 $spec['default'] = 'NULL';
170 }
171 $sql .= ' DEFAULT ' . $spec['default'];
172 }
173
174 if (empty($spec['not null']) && !isset($spec['default'])) {
175 $sql .= ' DEFAULT NULL';
176 }
177
178 // Add column comment.
179 if (!empty($spec['description'])) {
180 $sql .= ' COMMENT ' . $this->prepareComment($spec['description'], self::COMMENT_MAX_COLUMN);
181 }
182
183 return $sql;
184 }
185
192 protected function processField($field) {
193
194 if (!isset($field['size'])) {
195 $field['size'] = 'normal';
196 }
197
198 // Set the correct database-engine specific datatype.
199 // In case one is already provided, force it to uppercase.
200 if (isset($field['mysql_type'])) {
201 $field['mysql_type'] = drupal_strtoupper($field['mysql_type']);
202 }
203 else {
204 $map = $this->getFieldTypeMap();
205 $field['mysql_type'] = $map[$field['type'] . ':' . $field['size']];
206 }
207
208 if (isset($field['type']) && $field['type'] == 'serial') {
209 $field['auto_increment'] = TRUE;
210 }
211
212 return $field;
213 }
214
215 public function getFieldTypeMap() {
216 // Put :normal last so it gets preserved by array_flip. This makes
217 // it much easier for modules (such as schema.module) to map
218 // database types back into schema types.
219 // $map does not use drupal_static as its value never changes.
220 static $map = array(
221 'varchar:normal' => 'VARCHAR',
222 'char:normal' => 'CHAR',
223
224 'text:tiny' => 'TINYTEXT',
225 'text:small' => 'TINYTEXT',
226 'text:medium' => 'MEDIUMTEXT',
227 'text:big' => 'LONGTEXT',
228 'text:normal' => 'TEXT',
229
230 'serial:tiny' => 'TINYINT',
231 'serial:small' => 'SMALLINT',
232 'serial:medium' => 'MEDIUMINT',
233 'serial:big' => 'BIGINT',
234 'serial:normal' => 'INT',
235
236 'int:tiny' => 'TINYINT',
237 'int:small' => 'SMALLINT',
238 'int:medium' => 'MEDIUMINT',
239 'int:big' => 'BIGINT',
240 'int:normal' => 'INT',
241
242 'float:tiny' => 'FLOAT',
243 'float:small' => 'FLOAT',
244 'float:medium' => 'FLOAT',
245 'float:big' => 'DOUBLE',
246 'float:normal' => 'FLOAT',
247
248 'numeric:normal' => 'DECIMAL',
249
250 'blob:big' => 'LONGBLOB',
251 'blob:normal' => 'BLOB',
252 );
253 return $map;
254 }
255
256 protected function createKeysSql($spec) {
257 $keys = array();
258
259 if (!empty($spec['primary key'])) {
260 $keys[] = 'PRIMARY KEY (' . $this->createKeysSqlHelper($spec['primary key']) . ')';
261 }
262 if (!empty($spec['unique keys'])) {
263 foreach ($spec['unique keys'] as $key => $fields) {
264 $keys[] = 'UNIQUE KEY `' . $key . '` (' . $this->createKeysSqlHelper($fields) . ')';
265 }
266 }
267 if (!empty($spec['indexes'])) {
268 foreach ($spec['indexes'] as $index => $fields) {
269 $keys[] = 'INDEX `' . $index . '` (' . $this->createKeysSqlHelper($fields) . ')';
270 }
271 }
272
273 return $keys;
274 }
275
276 protected function createKeySql($fields) {
277 $return = array();
278 foreach ($fields as $field) {
279 if (is_array($field)) {
280 $return[] = '`' . $field[0] . '`(' . $field[1] . ')';
281 }
282 else {
283 $return[] = '`' . $field . '`';
284 }
285 }
286 return implode(', ', $return);
287 }
288
289 protected function createKeysSqlHelper($fields) {
290 $return = array();
291 foreach ($fields as $field) {
292 if (is_array($field)) {
293 $return[] = '`' . $field[0] . '`(' . $field[1] . ')';
294 }
295 else {
296 $return[] = '`' . $field . '`';
297 }
298 }
299 return implode(', ', $return);
300 }
301
302 public function renameTable($table, $new_name) {
303 if (!$this->tableExists($table)) {
304 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot rename %table to %table_new: table %table doesn't exist.", array('%table' => $table, '%table_new' => $new_name)));
305 }
306 if ($this->tableExists($new_name)) {
307 throw new DatabaseSchemaObjectExistsException(t("Cannot rename %table to %table_new: table %table_new already exists.", array('%table' => $table, '%table_new' => $new_name)));
308 }
309
310 $info = $this->getPrefixInfo($new_name);
311 return $this->connection->query('ALTER TABLE {' . $table . '} RENAME TO `' . $info['table'] . '`');
312 }
313
314 public function dropTable($table) {
315 if (!$this->tableExists($table)) {
316 return FALSE;
317 }
318
319 $this->connection->query('DROP TABLE {' . $table . '}');
320 return TRUE;
321 }
322
323 public function addField($table, $field, $spec, $keys_new = array()) {
324 if (!$this->tableExists($table)) {
325 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add field %table.%field: table doesn't exist.", array('%field' => $field, '%table' => $table)));
326 }
327 if ($this->fieldExists($table, $field)) {
328 throw new DatabaseSchemaObjectExistsException(t("Cannot add field %table.%field: field already exists.", array('%field' => $field, '%table' => $table)));
329 }
330
331 $fixnull = FALSE;
332 if (!empty($spec['not null']) && !isset($spec['default'])) {
333 $fixnull = TRUE;
334 $spec['not null'] = FALSE;
335 }
336 $query = 'ALTER TABLE {' . $table . '} ADD ';
337 $query .= $this->createFieldSql($field, $this->processField($spec));
338 if ($keys_sql = $this->createKeysSql($keys_new)) {
339 $query .= ', ADD ' . implode(', ADD ', $keys_sql);
340 }
341 $this->connection->query($query);
342 if (isset($spec['initial'])) {
343 $this->connection->update($table)
344 ->fields(array($field => $spec['initial']))
345 ->execute();
346 }
347 if ($fixnull) {
348 $spec['not null'] = TRUE;
349 $this->changeField($table, $field, $field, $spec);
350 }
351 }
352
353 public function dropField($table, $field) {
354 if (!$this->fieldExists($table, $field)) {
355 return FALSE;
356 }
357
358 $this->connection->query('ALTER TABLE {' . $table . '} DROP `' . $field . '`');
359 return TRUE;
360 }
361
362 public function fieldSetDefault($table, $field, $default) {
363 if (!$this->fieldExists($table, $field)) {
364 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
365 }
366
367 if (!isset($default)) {
368 $default = 'NULL';
369 }
370 else {
371 $default = is_string($default) ? "'$default'" : $default;
372 }
373
374 $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` SET DEFAULT ' . $default);
375 }
376
377 public function fieldSetNoDefault($table, $field) {
378 if (!$this->fieldExists($table, $field)) {
379 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
380 }
381
382 $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` DROP DEFAULT');
383 }
384
385 public function indexExists($table, $name) {
386 // Returns one row for each column in the index. Result is string or FALSE.
387 // Details at http://dev.mysql.com/doc/refman/5.0/en/show-index.html
388 $row = $this->connection->query('SHOW INDEX FROM {' . $table . "} WHERE key_name = '$name'")->fetchAssoc();
389 return isset($row['Key_name']);
390 }
391
392 public function addPrimaryKey($table, $fields) {
393 if (!$this->tableExists($table)) {
394 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add primary key to table %table: table doesn't exist.", array('%table' => $table)));
395 }
396 if ($this->indexExists($table, 'PRIMARY')) {
397 throw new DatabaseSchemaObjectExistsException(t("Cannot add primary key to table %table: primary key already exists.", array('%table' => $table)));
398 }
399
400 $this->connection->query('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . $this->createKeySql($fields) . ')');
401 }
402
403 public function dropPrimaryKey($table) {
404 if (!$this->indexExists($table, 'PRIMARY')) {
405 return FALSE;
406 }
407
408 $this->connection->query('ALTER TABLE {' . $table . '} DROP PRIMARY KEY');
409 return TRUE;
410 }
411
412 public function addUniqueKey($table, $name, $fields) {
413 if (!$this->tableExists($table)) {
414 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add unique key %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
415 }
416 if ($this->indexExists($table, $name)) {
417 throw new DatabaseSchemaObjectExistsException(t("Cannot add unique key %name to table %table: unique key already exists.", array('%table' => $table, '%name' => $name)));
418 }
419
420 $this->connection->query('ALTER TABLE {' . $table . '} ADD UNIQUE KEY `' . $name . '` (' . $this->createKeySql($fields) . ')');
421 }
422
423 public function dropUniqueKey($table, $name) {
424 if (!$this->indexExists($table, $name)) {
425 return FALSE;
426 }
427
428 $this->connection->query('ALTER TABLE {' . $table . '} DROP KEY `' . $name . '`');
429 return TRUE;
430 }
431
432 public function addIndex($table, $name, $fields) {
433 if (!$this->tableExists($table)) {
434 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add index %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
435 }
436 if ($this->indexExists($table, $name)) {
437 throw new DatabaseSchemaObjectExistsException(t("Cannot add index %name to table %table: index already exists.", array('%table' => $table, '%name' => $name)));
438 }
439
440 $this->connection->query('ALTER TABLE {' . $table . '} ADD INDEX `' . $name . '` (' . $this->createKeySql($fields) . ')');
441 }
442
443 public function dropIndex($table, $name) {
444 if (!$this->indexExists($table, $name)) {
445 return FALSE;
446 }
447
448 $this->connection->query('ALTER TABLE {' . $table . '} DROP INDEX `' . $name . '`');
449 return TRUE;
450 }
451
452 public function changeField($table, $field, $field_new, $spec, $keys_new = array()) {
453 if (!$this->fieldExists($table, $field)) {
454 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.", array('%table' => $table, '%name' => $field)));
455 }
456 if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
457 throw new DatabaseSchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
458 }
459
460 $sql = 'ALTER TABLE {' . $table . '} CHANGE `' . $field . '` ' . $this->createFieldSql($field_new, $this->processField($spec));
461 if ($keys_sql = $this->createKeysSql($keys_new)) {
462 $sql .= ', ADD ' . implode(', ADD ', $keys_sql);
463 }
464 $this->connection->query($sql);
465 }
466
467 public function prepareComment($comment, $length = NULL) {
468 // Work around a bug in some versions of PDO, see http://bugs.php.net/bug.php?id=41125
469 $comment = str_replace("'", '’', $comment);
470
471 // Truncate comment to maximum comment length.
472 if (isset($length)) {
473 // Add table prefixes before truncating.
474 $comment = truncate_utf8($this->connection->prefixTables($comment), $length, TRUE, TRUE);
475 }
476
477 return $this->connection->quote($comment);
478 }
479
483 public function getComment($table, $column = NULL) {
484 $condition = $this->buildTableNameCondition($table);
485 if (isset($column)) {
486 $condition->condition('column_name', $column);
487 $condition->compile($this->connection, $this);
488 // Don't use {} around information_schema.columns table.
489 return $this->connection->query("SELECT column_comment FROM information_schema.columns WHERE " . (string) $condition, $condition->arguments())->fetchField();
490 }
491 $condition->compile($this->connection, $this);
492 // Don't use {} around information_schema.tables table.
493 $comment = $this->connection->query("SELECT table_comment FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments())->fetchField();
494 // Work-around for MySQL 5.0 bug http://bugs.mysql.com/bug.php?id=11379
495 return preg_replace('/; InnoDB free:.*$/', '', $comment);
496 }
497
498 public function tableExists($table) {
499 // The information_schema table is very slow to query under MySQL 5.0.
500 // Instead, we try to select from the table in question. If it fails,
501 // the most likely reason is that it does not exist. That is dramatically
502 // faster than using information_schema.
503 // @link http://bugs.mysql.com/bug.php?id=19588
504 // @todo: This override should be removed once we require a version of MySQL
505 // that has that bug fixed.
506 try {
507 $this->connection->queryRange("SELECT 1 FROM {" . $table . "}", 0, 1);
508 return TRUE;
509 }
510 catch (Exception $e) {
511 return FALSE;
512 }
513 }
514
515 public function fieldExists($table, $column) {
516 // The information_schema table is very slow to query under MySQL 5.0.
517 // Instead, we try to select from the table and field in question. If it
518 // fails, the most likely reason is that it does not exist. That is
519 // dramatically faster than using information_schema.
520 // @link http://bugs.mysql.com/bug.php?id=19588
521 // @todo: This override should be removed once we require a version of MySQL
522 // that has that bug fixed.
523 try {
524 $this->connection->queryRange("SELECT $column FROM {" . $table . "}", 0, 1);
525 return TRUE;
526 }
527 catch (Exception $e) {
528 return FALSE;
529 }
530 }
531
532 }
533
DatabaseSchema_mysql\addPrimaryKey
addPrimaryKey($table, $fields)
Definition: schema.inc:392
DatabaseSchema_mysql\fieldSetNoDefault
fieldSetNoDefault($table, $field)
Definition: schema.inc:377
DatabaseSchema_mysql\createKeysSqlHelper
createKeysSqlHelper($fields)
Definition: schema.inc:289
DatabaseSchema_mysql\COMMENT_MAX_COLUMN
const COMMENT_MAX_COLUMN
Definition: schema.inc:24
DatabaseSchema_mysql\fieldSetDefault
fieldSetDefault($table, $field, $default)
Definition: schema.inc:362
DatabaseSchemaObjectExistsException
Definition: schema.inc:713
Database\getConnectionInfo
static getConnectionInfo($key= 'default')
Definition: database.inc:1593
$name
print $name
Definition: profile-listing.tpl.php:43
DatabaseSchema_mysql\COMMENT_MAX_TABLE
const COMMENT_MAX_TABLE
Definition: schema.inc:19
Exception
DatabaseSchema
Definition: schema.inc:164
DatabaseSchema_mysql\addField
addField($table, $field, $spec, $keys_new=array())
Definition: schema.inc:323
DatabaseSchema_mysql\indexExists
indexExists($table, $name)
Definition: schema.inc:385
DatabaseSchema_mysql\dropUniqueKey
dropUniqueKey($table, $name)
Definition: schema.inc:423
DatabaseSchema_mysql\createKeysSql
createKeysSql($spec)
Definition: schema.inc:256
DatabaseSchema_mysql\processField
processField($field)
Definition: schema.inc:192
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
DatabaseCondition
Definition: query.inc:1652
DatabaseSchema_mysql
Definition: schema.inc:14
$info
$info
Definition: color.inc:6
DatabaseSchemaObjectDoesNotExistException
Definition: schema.inc:722
drupal_strtoupper
drupal_strtoupper($text)
Definition: unicode.inc:496
DatabaseSchema_mysql\addUniqueKey
addUniqueKey($table, $name, $fields)
Definition: schema.inc:412
DatabaseSchema_mysql\dropPrimaryKey
dropPrimaryKey($table)
Definition: schema.inc:403
DatabaseSchema_mysql\createFieldSql
createFieldSql($name, $spec)
Definition: schema.inc:131
DatabaseSchema_mysql\dropField
dropField($table, $field)
Definition: schema.inc:353
DatabaseSchema_mysql\createTableSql
createTableSql($name, $table)
Definition: schema.inc:78
DatabaseSchema_mysql\renameTable
renameTable($table, $new_name)
Definition: schema.inc:302
DatabaseSchema_mysql\getPrefixInfo
getPrefixInfo($table= 'default', $add_prefix=TRUE)
Definition: schema.inc:32
DatabaseSchema_mysql\buildTableNameCondition
buildTableNameCondition($table_name, $operator= '=', $add_prefix=TRUE)
Definition: schema.inc:57
DatabaseSchema_mysql\dropTable
dropTable($table)
Definition: schema.inc:314
DatabaseSchema_mysql\addIndex
addIndex($table, $name, $fields)
Definition: schema.inc:432
DatabaseSchema_mysql\tableExists
tableExists($table)
Definition: schema.inc:498
$row
$row
Definition: block-admin-display-form.tpl.php:47
DatabaseSchema_mysql\prepareComment
prepareComment($comment, $length=NULL)
Definition: schema.inc:467
DatabaseSchema_mysql\changeField
changeField($table, $field, $field_new, $spec, $keys_new=array())
Definition: schema.inc:452
DatabaseSchema_mysql\dropIndex
dropIndex($table, $name)
Definition: schema.inc:443
DatabaseSchema_mysql\fieldExists
fieldExists($table, $column)
Definition: schema.inc:515
truncate_utf8
truncate_utf8($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
Definition: unicode.inc:316
DatabaseSchema_mysql\getFieldTypeMap
getFieldTypeMap()
Definition: schema.inc:215
DatabaseSchema_mysql\createKeySql
createKeySql($fields)
Definition: schema.inc:276
DatabaseSchema_mysql\getComment
getComment($table, $column=NULL)
Definition: schema.inc:483
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/overlay/overlay.module Source File

  • modules
  • overlay
overlay.module
Go to the documentation of this file.
1 <?php
2
11 function overlay_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#overlay':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t('The Overlay module makes the administration pages on your site display in a JavaScript overlay of the page you were viewing when you clicked the administrative link, instead of replacing the page in your browser window. Use the close link on the overlay to return to the page you were viewing when you clicked the link. For more information, see the online handbook entry for <a href="@overlay">Overlay module</a>.', array('@overlay' => 'http://drupal.org/documentation/modules/overlay')) . '</p>';
17 return $output;
18 }
19 }
20
24 function overlay_menu() {
25 $items['overlay-ajax/%'] = array(
26 'title' => '',
27 'page callback' => 'overlay_ajax_render_region',
28 'page arguments' => array(1),
29 'access arguments' => array('access overlay'),
30 'type' => MENU_CALLBACK,
31 );
32 $items['overlay/dismiss-message'] = array(
33 'title' => '',
34 'page callback' => 'overlay_user_dismiss_message',
35 'access arguments' => array('access overlay'),
36 'type' => MENU_CALLBACK,
37 );
38 return $items;
39 }
40
44 function overlay_admin_paths() {
45 $paths = array(
46 // This is marked as an administrative path so that if it is visited from
47 // within the overlay, the user will stay within the overlay while the
48 // callback is being processed.
49 'overlay/dismiss-message' => TRUE,
50 );
51 return $paths;
52 }
53
57 function overlay_permission() {
58 return array(
59 'access overlay' => array(
60 'title' => t('Access the administrative overlay'),
61 'description' => t('View administrative pages in the overlay.'),
62 ),
63 );
64 }
65
69 function overlay_theme() {
70 return array(
71 'overlay' => array(
72 'render element' => 'page',
73 'template' => 'overlay',
74 ),
75 'overlay_disable_message' => array(
76 'render element' => 'element',
77 ),
78 );
79 }
80
84 function overlay_form_user_profile_form_alter(&$form, &$form_state) {
85 if ($form['#user_category'] == 'account') {
86 $account = $form['#user'];
87 if (user_access('access overlay', $account)) {
88 $form['overlay_control'] = array(
89 '#type' => 'fieldset',
90 '#title' => t('Administrative overlay'),
91 '#weight' => 4,
92 '#collapsible' => TRUE,
93 );
94
95 $form['overlay_control']['overlay'] = array(
96 '#type' => 'checkbox',
97 '#title' => t('Use the overlay for administrative pages.'),
98 '#description' => t('Show administrative pages on top of the page you started from.'),
99 '#default_value' => isset($account->data['overlay']) ? $account->data['overlay'] : 1,
100 );
101 }
102 }
103 }
104
108 function overlay_user_presave(&$edit, $account, $category) {
109 if (isset($edit['overlay'])) {
110 $edit['data']['overlay'] = $edit['overlay'];
111 }
112 }
113
122 function overlay_init() {
123 global $user;
124
125 $mode = overlay_get_mode();
126
127 // Only act if the user has access to the overlay and a mode was not already
128 // set. Other modules can also enable the overlay directly for other uses.
129 $use_overlay = !isset($user->data['overlay']) || $user->data['overlay'];
130 if (empty($mode) && user_access('access overlay') && $use_overlay) {
131 $current_path = current_path();
132 // After overlay is enabled on the modules page, redirect to
133 // <front>#overlay=admin/modules to actually enable the overlay.
134 if (isset($_SESSION['overlay_enable_redirect']) && $_SESSION['overlay_enable_redirect']) {
135 unset($_SESSION['overlay_enable_redirect']);
136 drupal_goto('<front>', array('fragment' => 'overlay=' . $current_path));
137 }
138
139 if (isset($_GET['render']) && $_GET['render'] == 'overlay') {
140 // If a previous page requested that we close the overlay, close it and
141 // redirect to the final destination.
142 if (isset($_SESSION['overlay_close_dialog'])) {
143 call_user_func_array('overlay_close_dialog', $_SESSION['overlay_close_dialog']);
144 unset($_SESSION['overlay_close_dialog']);
145 }
146 // If this page shouldn't be rendered inside the overlay, redirect to the
147 // parent.
148 elseif (!path_is_admin($current_path)) {
149 // Prevent open redirects by ensuring the current path is not an absolute URL.
150 if (url_is_external($current_path)) {
151 $current_path = '<front>';
152 }
153 overlay_close_dialog($current_path, array('query' => drupal_get_query_parameters(NULL, array('q', 'render'))));
154 }
155
156 // Indicate that we are viewing an overlay child page.
157 overlay_set_mode('child');
158
159 // Unset the render parameter to avoid it being included in URLs on the page.
160 unset($_GET['render']);
161 }
162 // Do not enable the overlay if we already are on an admin page.
163 elseif (!path_is_admin($current_path)) {
164 // Otherwise add overlay parent code and our behavior.
165 overlay_set_mode('parent');
166 }
167 }
168 }
169
176 function overlay_exit() {
177 // Check that we are in an overlay child page. Note that this should never
178 // return TRUE on a cached page view, since the child mode is not set until
179 // overlay_init() is called.
180 if (overlay_get_mode() == 'child') {
181 // Load any markup that was stored earlier in the page request, via calls
182 // to overlay_store_rendered_content(). If none was stored, this is not a
183 // page request where we expect any changes to the overlay supplemental
184 // regions to have occurred, so we do not need to proceed any further.
185 $original_markup = overlay_get_rendered_content();
186 if (!empty($original_markup)) {
187 // Compare the original markup to the current markup that we get from
188 // rendering each overlay supplemental region now. If they don't match,
189 // something must have changed, so we request a refresh of that region
190 // within the parent window on the next page request.
191 foreach (overlay_supplemental_regions() as $region) {
192 if (!isset($original_markup[$region]) || $original_markup[$region] != overlay_render_region($region)) {
193 overlay_request_refresh($region);
194 }
195 }
196 }
197 }
198 }
199
203 function overlay_library() {
204 $module_path = drupal_get_path('module', 'overlay');
205
206 // Overlay parent.
207 $libraries['parent'] = array(
208 'title' => 'Overlay: Parent',
209 'website' => 'http://drupal.org/documentation/modules/overlay',
210 'version' => '1.0',
211 'js' => array(
212 $module_path . '/overlay-parent.js' => array(),
213 ),
214 'css' => array(
215 $module_path . '/overlay-parent.css' => array(),
216 ),
217 'dependencies' => array(
218 array('system', 'ui'),
219 array('system', 'jquery.bbq'),
220 ),
221 );
222 // Overlay child.
223 $libraries['child'] = array(
224 'title' => 'Overlay: Child',
225 'website' => 'http://drupal.org/documentation/modules/overlay',
226 'version' => '1.0',
227 'js' => array(
228 $module_path . '/overlay-child.js' => array(),
229 ),
230 'css' => array(
231 $module_path . '/overlay-child.css' => array(),
232 ),
233 );
234
235 return $libraries;
236 }
237
241 function overlay_drupal_goto_alter(&$path, &$options, &$http_response_code) {
242 if (overlay_get_mode() == 'child') {
243 // The authorize.php script bootstraps Drupal to a very low level, where
244 // the PHP code that is necessary to close the overlay properly will not be
245 // loaded. Therefore, if we are redirecting to authorize.php inside the
246 // overlay, instead redirect back to the current page with instructions to
247 // close the overlay there before redirecting to the final destination; see
248 // overlay_init().
249 if ($path == system_authorized_get_url() || $path == system_authorized_batch_processing_url()) {
250 $_SESSION['overlay_close_dialog'] = array($path, $options);
251 $path = current_path();
252 $options = drupal_get_query_parameters();
253 }
254
255 // If the current page request is inside the overlay, add ?render=overlay
256 // to the new path, so that it appears correctly inside the overlay.
257 if (isset($options['query'])) {
258 $options['query'] += array('render' => 'overlay');
259 }
260 else {
261 $options['query'] = array('render' => 'overlay');
262 }
263 }
264 }
265
274 function overlay_batch_alter(&$batch) {
275 if (overlay_get_mode() == 'child') {
276 if (isset($batch['url_options']['query'])) {
277 $batch['url_options']['query']['render'] = 'overlay';
278 }
279 else {
280 $batch['url_options']['query'] = array('render' => 'overlay');
281 }
282 }
283 }
284
288 function overlay_page_alter(&$page) {
289 // If we are limiting rendering to a subset of page regions, deny access to
290 // all other regions so that they will not be processed.
291 if ($regions_to_render = overlay_get_regions_to_render()) {
292 $skipped_regions = array_diff(element_children($page), $regions_to_render);
293 foreach ($skipped_regions as $skipped_region) {
294 $page[$skipped_region]['#access'] = FALSE;
295 }
296 }
297
298 $mode = overlay_get_mode();
299 if ($mode == 'child') {
300 // Add the overlay wrapper before the html wrapper.
301 array_unshift($page['#theme_wrappers'], 'overlay');
302 }
303 elseif ($mode == 'parent' && ($message = overlay_disable_message())) {
304 $page['page_top']['disable_overlay'] = $message;
305 }
306 }
307
314 function overlay_user_dismiss_message() {
315 global $user;
316 // It's unlikely, but possible that "access overlay" permission is granted to
317 // the anonymous role. In this case, we do not display the message to disable
318 // the overlay, so there is nothing to dismiss. Also, protect against
319 // cross-site request forgeries by validating a token.
320 if (empty($user->uid) || !isset($_GET['token']) || !drupal_valid_token($_GET['token'], 'overlay')) {
321 return MENU_ACCESS_DENIED;
322 }
323 else {
324 user_save(user_load($user->uid), array('data' => array('overlay_message_dismissed' => 1)));
325 drupal_set_message(t('The message has been dismissed. You can change your overlay settings at any time by visiting your profile page.'));
326 // Destination is normally given. Go to the user profile as a fallback.
327 drupal_goto('user/' . $user->uid . '/edit');
328 }
329 }
330
344 function overlay_disable_message() {
345 global $user;
346
347 if (!empty($user->uid) && empty($user->data['overlay_message_dismissed']) && (!isset($user->data['overlay']) || $user->data['overlay']) && user_access('access overlay')) {
348 $build = array(
349 '#theme' => 'overlay_disable_message',
350 '#weight' => -99,
351 // Link to the user's profile page, where the overlay can be disabled.
352 'profile_link' => array(
353 '#type' => 'link',
354 '#title' => t('If you have problems accessing administrative pages on this site, disable the overlay on your profile page.'),
355 '#href' => 'user/' . $user->uid . '/edit',
356 '#options' => array(
357 'query' => drupal_get_destination(),
358 'fragment' => 'edit-overlay-control',
359 'attributes' => array(
360 'id' => 'overlay-profile-link',
361 // Prevent the target page from being opened in the overlay.
362 'class' => array('overlay-exclude'),
363 ),
364 ),
365 ),
366 // Link to a menu callback that allows this message to be permanently
367 // dismissed for the current user.
368 'dismiss_message_link' => array(
369 '#type' => 'link',
370 '#title' => t('Dismiss this message.'),
371 '#href' => 'overlay/dismiss-message',
372 '#options' => array(
373 'query' => drupal_get_destination() + array(
374 // Add a token to protect against cross-site request forgeries.
375 'token' => drupal_get_token('overlay'),
376 ),
377 'attributes' => array(
378 'id' => 'overlay-dismiss-message',
379 // If this message is being displayed outside the overlay, prevent
380 // this link from opening the overlay.
381 'class' => (overlay_get_mode() == 'parent') ? array('overlay-exclude') : array(),
382 ),
383 ),
384 )
385 );
386 }
387 else {
388 $build = array();
389 }
390
391 return $build;
392 }
393
405 function theme_overlay_disable_message($variables) {
406 $element = $variables['element'];
407
408 // Add CSS classes to hide the links from most sighted users, while keeping
409 // them accessible to screen-reader users and keyboard-only users. To assist
410 // screen-reader users, this message appears in both the parent and child
411 // documents, but only the one in the child document is part of the tab order.
412 foreach (array('profile_link', 'dismiss_message_link') as $key) {
413 $element[$key]['#options']['attributes']['class'][] = 'element-invisible';
414 if (overlay_get_mode() == 'child') {
415 $element[$key]['#options']['attributes']['class'][] = 'element-focusable';
416 }
417 }
418
419 // Render the links.
420 $output = drupal_render($element['profile_link']) . ' ' . drupal_render($element['dismiss_message_link']);
421
422 // Add a heading for screen-reader users. The heading doesn't need to be seen
423 // by sighted users.
424 $output = '<h3 class="element-invisible">' . t('Options for the administrative overlay') . '</h3>' . $output;
425
426 // Wrap in a container for styling.
427 $output = '<div id="overlay-disable-message" class="clearfix">' . $output . '</div>';
428
429 return $output;
430 }
431
435 function overlay_block_list_alter(&$blocks) {
436 // If we are limiting rendering to a subset of page regions, hide all blocks
437 // which appear in regions not on that list. Note that overlay_page_alter()
438 // does a more comprehensive job of preventing unwanted regions from being
439 // displayed (regardless of whether they contain blocks or not), but the
440 // reason for duplicating effort here is performance; we do not even want
441 // these blocks to be built if they are not going to be displayed.
442 if ($regions_to_render = overlay_get_regions_to_render()) {
443 foreach ($blocks as $bid => $block) {
444 if (!in_array($block->region, $regions_to_render)) {
445 unset($blocks[$bid]);
446 }
447 }
448 }
449 }
450
456 function overlay_system_info_alter(&$info, $file, $type) {
457 if ($type == 'theme') {
458 $info['overlay_regions'][] = 'content';
459 $info['overlay_regions'][] = 'help';
460 }
461 }
462
471 function overlay_preprocess_html(&$variables) {
472 if (overlay_get_mode() == 'child') {
473 // Add overlay class, so themes can react to being displayed in the overlay.
474 $variables['classes_array'][] = 'overlay';
475 }
476 }
477
486 function overlay_preprocess_maintenance_page(&$variables) {
487 overlay_preprocess_html($variables);
488 }
489
499 function template_preprocess_overlay(&$variables) {
500 $variables['tabs'] = menu_primary_local_tasks();
501 $variables['title'] = drupal_get_title();
502 $variables['disable_overlay'] = overlay_disable_message();
503 $variables['content_attributes_array']['class'][] = 'clearfix';
504 }
505
514 function template_process_overlay(&$variables) {
515 $variables['page'] = $variables['page']['#children'];
516 }
517
525 function overlay_preprocess_page(&$variables) {
526 if (overlay_get_mode() == 'child') {
527 unset($variables['tabs']['#primary']);
528 }
529 }
530
555 function overlay_display_empty_page($value = NULL) {
556 $display_empty_page = &drupal_static(__FUNCTION__, FALSE);
557 if (isset($value)) {
558 $display_empty_page = $value;
559 }
560 return $display_empty_page;
561 }
562
566 function overlay_page_delivery_callback_alter(&$callback) {
567 if (overlay_display_empty_page()) {
568 $callback = 'overlay_deliver_empty_page';
569 }
570 }
571
578 function overlay_deliver_empty_page() {
579 $empty_page = '<html><head><title></title>' . drupal_get_css() . drupal_get_js() . '</head><body class="overlay"></body></html>';
580 print $empty_page;
581 drupal_exit();
582 }
583
589 function overlay_get_mode() {
590 return overlay_set_mode(NULL);
591 }
592
625 function overlay_set_mode($mode = NULL) {
626 global $base_path;
627 $overlay_mode = &drupal_static(__FUNCTION__);
628
629 // Make sure external resources are not included more than once. Also return
630 // the current mode, if no mode was specified.
631 if (isset($overlay_mode) || !isset($mode)) {
632 return $overlay_mode;
633 }
634 $overlay_mode = $mode;
635
636 switch ($overlay_mode) {
637 case 'parent':
638 drupal_add_library('overlay', 'parent');
639
640 // Allow modules to act upon overlay events.
641 module_invoke_all('overlay_parent_initialize');
642 break;
643
644 case 'child':
645 drupal_add_library('overlay', 'child');
646
647 // Allow modules to act upon overlay events.
648 module_invoke_all('overlay_child_initialize');
649 break;
650 }
651 return $overlay_mode;
652 }
653
657 function overlay_overlay_parent_initialize() {
658 // Let the client side know which paths are administrative.
659 $paths = path_get_admin_paths();
660 foreach ($paths as &$type) {
661 $type = str_replace('<front>', variable_get('site_frontpage', 'node'), $type);
662 }
663 drupal_add_js(array('overlay' => array('paths' => $paths)), 'setting');
664 $path_prefixes = array();
665 if (module_exists('locale') && variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) {
666 // Get languages grouped by status and select only the enabled ones.
667 $languages = language_list('enabled');
668 $languages = $languages[1];
669
670 $path_prefixes = array();
671 foreach ($languages as $language) {
672 if ($language->prefix) {
673 $path_prefixes[] = $language->prefix;
674 }
675 }
676 }
677 drupal_add_js(array('overlay' => array('pathPrefixes' => $path_prefixes)), 'setting');
678 // Pass along the Ajax callback for rerendering sections of the parent window.
679 drupal_add_js(array('overlay' => array('ajaxCallback' => 'overlay-ajax')), 'setting');
680 }
681
685 function overlay_overlay_child_initialize() {
686 // Check if the parent window needs to refresh any page regions on this page
687 // request.
688 overlay_trigger_refresh();
689 // If this is a POST request, or a GET request with a token parameter, we
690 // have an indication that something in the supplemental regions of the
691 // overlay might change during the current page request. We therefore store
692 // the initial rendered content of those regions here, so that we can compare
693 // it to the same content rendered in overlay_exit(), at the end of the page
694 // request. This allows us to check if anything actually did change, and, if
695 // so, trigger an immediate Ajax refresh of the parent window.
696 if (!empty($_POST) || isset($_GET['token'])) {
697 foreach (overlay_supplemental_regions() as $region) {
698 overlay_store_rendered_content($region, overlay_render_region($region));
699 }
700 // In addition, notify the parent window that when the overlay closes,
701 // the entire parent window should be refreshed.
702 overlay_request_page_refresh();
703 }
704 // Indicate that when the main page rendering occurs later in the page
705 // request, only the regions that appear within the overlay should be
706 // rendered.
707 overlay_set_regions_to_render(overlay_regions());
708 }
709
722 function overlay_close_dialog($redirect = NULL, $redirect_options = array()) {
723 $settings = array(
724 'overlayChild' => array(
725 'closeOverlay' => TRUE,
726 ),
727 );
728
729 // Tell the child window to perform the redirection when requested to.
730 if (isset($redirect)) {
731 $settings['overlayChild']['redirect'] = url($redirect, $redirect_options);
732 }
733
734 drupal_add_js($settings, array('type' => 'setting'));
735
736 // Since we are closing the overlay as soon as the page is displayed, we do
737 // not want to show any of the page's actual content.
738 overlay_display_empty_page(TRUE);
739 }
740
754 function overlay_regions() {
755 return _overlay_region_list('overlay_regions');
756 }
757
776 function overlay_supplemental_regions() {
777 return _overlay_region_list('overlay_supplemental_regions');
778 }
779
794 function _overlay_region_list($type) {
795 // Obtain the current theme. We need to first make sure the theme system is
796 // initialized, since this function can be called early in the page request.
797 drupal_theme_initialize();
798 $themes = list_themes();
799 $theme = $themes[$GLOBALS['theme']];
800 // Return the list of regions stored within the theme's info array, or an
801 // empty array if no regions of the appropriate type are defined.
802 return !empty($theme->info[$type]) ? $theme->info[$type] : array();
803 }
804
817 function overlay_get_regions_to_render() {
818 return overlay_set_regions_to_render();
819 }
820
839 function overlay_set_regions_to_render($regions = NULL) {
840 $regions_to_render = &drupal_static(__FUNCTION__, array());
841 if (isset($regions)) {
842 $regions_to_render = $regions;
843 }
844 return $regions_to_render;
845 }
846
864 function overlay_render_region($region) {
865 // Indicate the region that we will be rendering, so that other regions will
866 // be hidden by overlay_page_alter() and overlay_block_list_alter().
867 overlay_set_regions_to_render(array($region));
868 // Do what is necessary to force drupal_render_page() to only display HTML
869 // from the requested region. Specifically, declare that the main page
870 // content does not need to automatically be added to the page, and pass in
871 // a page array that has all theme functions removed (so that overall HTML
872 // for the page will not be added either).
873 $system_main_content_added = &drupal_static('system_main_content_added');
874 $system_main_content_added = TRUE;
875 $page = array(
876 '#type' => 'page',
877 '#theme' => NULL,
878 '#theme_wrappers' => array(),
879 );
880 // Render the region, but do not cache any JavaScript or CSS associated with
881 // it. This region might not be included the next time drupal_render_page()
882 // is called, and we do not want its JavaScript or CSS to erroneously appear
883 // on the final rendered page.
884 $original_js = drupal_add_js();
885 $original_css = drupal_add_css();
886 $original_libraries = drupal_static('drupal_add_library');
887 $js = &drupal_static('drupal_add_js');
888 $css = &drupal_static('drupal_add_css');
889 $libraries = &drupal_static('drupal_add_library');
890 $markup = drupal_render_page($page);
891 $js = $original_js;
892 $css = $original_css;
893 $libraries = $original_libraries;
894 // Indicate that the main page content has not, in fact, been displayed, so
895 // that future calls to drupal_render_page() will be able to render it
896 // correctly.
897 $system_main_content_added = FALSE;
898 // Restore the original behavior of rendering all regions for the next time
899 // drupal_render_page() is called.
900 overlay_set_regions_to_render(array());
901 return $markup;
902 }
903
914 function overlay_get_rendered_content() {
915 return overlay_store_rendered_content();
916 }
917
938 function overlay_store_rendered_content($id = NULL, $content = NULL) {
939 $rendered_content = &drupal_static(__FUNCTION__, array());
940 if (isset($id)) {
941 $rendered_content[$id] = $content;
942 }
943 return $rendered_content;
944 }
945
956 function overlay_request_refresh($region) {
957 $class = drupal_region_class($region);
958 $_SESSION['overlay_regions_to_refresh'][] = array($class => $region);
959 }
960
966 function overlay_request_page_refresh() {
967 $_SESSION['overlay_refresh_parent'] = TRUE;
968 }
969
982 function overlay_trigger_refresh() {
983 if (!empty($_SESSION['overlay_regions_to_refresh'])) {
984 $settings = array(
985 'overlayChild' => array(
986 'refreshRegions' => $_SESSION['overlay_regions_to_refresh'],
987 ),
988 );
989 drupal_add_js($settings, array('type' => 'setting'));
990 unset($_SESSION['overlay_regions_to_refresh']);
991 }
992 if (!empty($_SESSION['overlay_refresh_parent'])) {
993 drupal_add_js(array('overlayChild' => array('refreshPage' => TRUE)), array('type' => 'setting'));
994 unset($_SESSION['overlay_refresh_parent']);
995 }
996 }
997
1008 function overlay_ajax_render_region($region) {
1009 print overlay_render_region($region);
1010 }
overlay_store_rendered_content
overlay_store_rendered_content($id=NULL, $content=NULL)
Definition: overlay.module:938
url_is_external
url_is_external($path)
Definition: common.inc:2311
overlay_get_rendered_content
overlay_get_rendered_content()
Definition: overlay.module:914
overlay_close_dialog
overlay_close_dialog($redirect=NULL, $redirect_options=array())
Definition: overlay.module:722
overlay_overlay_parent_initialize
overlay_overlay_parent_initialize()
Definition: overlay.module:657
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
path_get_admin_paths
path_get_admin_paths()
Definition: path.inc:517
overlay_disable_message
overlay_disable_message()
Definition: overlay.module:344
drupal_get_css
drupal_get_css($css=NULL, $skip_alter=FALSE)
Definition: common.inc:3052
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
overlay_ajax_render_region
overlay_ajax_render_region($region)
Definition: overlay.module:1008
overlay_form_user_profile_form_alter
overlay_form_user_profile_form_alter(&$form, &$form_state)
Definition: overlay.module:84
MENU_ACCESS_DENIED
const MENU_ACCESS_DENIED
Definition: menu.inc:239
system_authorized_get_url
system_authorized_get_url(array $options=array())
Definition: system.module:1803
overlay_preprocess_html
overlay_preprocess_html(&$variables)
Definition: overlay.module:471
template_preprocess_overlay
template_preprocess_overlay(&$variables)
Definition: overlay.module:499
overlay_exit
overlay_exit()
Definition: overlay.module:176
$page
print $page
Definition: overlay.tpl.php:37
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
overlay_block_list_alter
overlay_block_list_alter(&$blocks)
Definition: overlay.module:435
overlay_admin_paths
overlay_admin_paths()
Definition: overlay.module:44
path_is_admin
path_is_admin($path)
Definition: path.inc:495
drupal_get_query_parameters
drupal_get_query_parameters(array $query=NULL, array $exclude=array('q'), $parent= '')
Definition: common.inc:417
overlay_page_delivery_callback_alter
overlay_page_delivery_callback_alter(&$callback)
Definition: overlay.module:566
overlay_render_region
overlay_render_region($region)
Definition: overlay.module:864
overlay_set_mode
overlay_set_mode($mode=NULL)
Definition: overlay.module:625
overlay_menu
overlay_menu()
Definition: overlay.module:24
overlay_library
overlay_library()
Definition: overlay.module:203
overlay_permission
overlay_permission()
Definition: overlay.module:57
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
module_exists
module_exists($module)
Definition: module.inc:274
print
print
Definition: php-2.php:2
menu_primary_local_tasks
menu_primary_local_tasks()
Definition: menu.inc:2227
user_save
user_save($account, $edit=array(), $category= 'account')
Definition: user.module:424
overlay_supplemental_regions
overlay_supplemental_regions()
Definition: overlay.module:776
overlay_preprocess_maintenance_page
overlay_preprocess_maintenance_page(&$variables)
Definition: overlay.module:486
overlay_get_regions_to_render
overlay_get_regions_to_render()
Definition: overlay.module:817
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
overlay_help
overlay_help($path, $arg)
Definition: overlay.module:11
overlay_get_mode
overlay_get_mode()
Definition: overlay.module:589
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
drupal_add_library
drupal_add_library($module, $name, $every_page=NULL)
Definition: common.inc:4694
overlay_theme
overlay_theme()
Definition: overlay.module:69
drupal_render_page
drupal_render_page($page)
Definition: common.inc:5727
drupal_valid_token
drupal_valid_token($token, $value= '', $skip_anonymous=FALSE)
Definition: common.inc:5095
system_authorized_batch_processing_url
system_authorized_batch_processing_url()
Definition: system.module:1815
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$info
$info
Definition: color.inc:6
overlay_deliver_empty_page
overlay_deliver_empty_page()
Definition: overlay.module:578
overlay_page_alter
overlay_page_alter(&$page)
Definition: overlay.module:288
overlay_regions
overlay_regions()
Definition: overlay.module:754
_overlay_region_list
_overlay_region_list($type)
Definition: overlay.module:794
language_list
language_list($field= 'language')
Definition: bootstrap.inc:2723
overlay_drupal_goto_alter
overlay_drupal_goto_alter(&$path, &$options, &$http_response_code)
Definition: overlay.module:241
overlay_trigger_refresh
overlay_trigger_refresh()
Definition: overlay.module:982
overlay_batch_alter
overlay_batch_alter(&$batch)
Definition: overlay.module:274
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
overlay_preprocess_page
overlay_preprocess_page(&$variables)
Definition: overlay.module:525
theme_overlay_disable_message
theme_overlay_disable_message($variables)
Definition: overlay.module:405
overlay_request_refresh
overlay_request_refresh($region)
Definition: overlay.module:956
$output
$output
Definition: authorize.php:93
LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX
const LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX
Definition: locale.inc:91
overlay_request_page_refresh
overlay_request_page_refresh()
Definition: overlay.module:966
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
user_access
user_access($string, $account=NULL)
Definition: user.module:794
overlay_display_empty_page
overlay_display_empty_page($value=NULL)
Definition: overlay.module:555
drupal_theme_initialize
drupal_theme_initialize()
Definition: theme.inc:70
drupal_region_class
drupal_region_class($region)
Definition: common.inc:3976
overlay_user_presave
overlay_user_presave(&$edit, $account, $category)
Definition: overlay.module:108
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
overlay_set_regions_to_render
overlay_set_regions_to_render($regions=NULL)
Definition: overlay.module:839
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
overlay_init
overlay_init()
Definition: overlay.module:122
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
drupal_exit
drupal_exit($destination=NULL)
Definition: common.inc:2721
overlay_overlay_child_initialize
overlay_overlay_child_initialize()
Definition: overlay.module:685
drupal_get_token
drupal_get_token($value= '')
Definition: common.inc:5077
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
drupal_get_title
drupal_get_title()
Definition: bootstrap.inc:1848
list_themes
list_themes($refresh=FALSE)
Definition: theme.inc:774
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
overlay_system_info_alter
overlay_system_info_alter(&$info, $file, $type)
Definition: overlay.module:456
current_path
current_path()
Definition: path.inc:354
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
overlay_user_dismiss_message
overlay_user_dismiss_message()
Definition: overlay.module:314
template_process_overlay
template_process_overlay(&$variables)
Definition: overlay.module:514
drupal_get_js
drupal_get_js($scope= 'header', $javascript=NULL, $skip_alter=FALSE)
Definition: common.inc:4263
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/list/list.install Source File

  • modules
  • field
  • modules
  • list
list.install
Go to the documentation of this file.
1 <?php
2
11 function list_field_schema($field) {
12 switch ($field['type']) {
13 case 'list_text':
14 $columns = array(
15 'value' => array(
16 'type' => 'varchar',
17 'length' => 255,
18 'not null' => FALSE,
19 ),
20 );
21 break;
22 case 'list_float':
23 $columns = array(
24 'value' => array(
25 'type' => 'float',
26 'not null' => FALSE,
27 ),
28 );
29 break;
30 case 'list_integer':
31 case 'list_boolean':
32 $columns = array(
33 'value' => array(
34 'type' => 'int',
35 'not null' => FALSE,
36 ),
37 );
38 break;
39 }
40 return array(
41 'columns' => $columns,
42 'indexes' => array(
43 'value' => array('value'),
44 ),
45 );
46 }
47
51 function list_update_7001() {
52 $fields = _update_7000_field_read_fields(array('module' => 'list'));
53 foreach ($fields as $field) {
54 $update = array();
55
56 // Translate the old string format into the new array format.
57 $allowed_values = $field['settings']['allowed_values'];
58 if (is_string($allowed_values)) {
59 $position_keys = ($field['type'] == 'list');
60 $allowed_values = _list_update_7001_extract_allowed_values($allowed_values, $position_keys);
61
62 // Additionally, float keys need to be disambiguated ('.5' is '0.5').
63 if ($field['type'] == 'list_number' && !empty($allowed_values)) {
64 $keys = array_map(create_function('$a', 'return (string) (float) $a;'), array_keys($allowed_values));
65 $allowed_values = array_combine($keys, array_values($allowed_values));
66 }
67
68 // Place the new setting in the existing serialized 'data' column.
69 $data = db_query("SELECT data FROM {field_config} WHERE id = :id", array(':id' => $field['id']))->fetchField();
70 $data = unserialize($data);
71 $data['settings']['allowed_values'] = $allowed_values;
72 $update['data'] = serialize($data);
73 }
74
75 // Rename field types.
76 $types = array('list' => 'list_integer', 'list_number' => 'list_float');
77 if (isset($types[$field['type']])) {
78 $update['type'] = $types[$field['type']];
79 }
80
81 // Save the new data.
82 if ($update) {
83 $query = db_update('field_config')
84 ->condition('id', $field['id'])
85 ->fields($update)
86 ->execute();
87 }
88 }
89 }
90
96 function _list_update_7001_extract_allowed_values($string, $position_keys) {
97 $values = array();
98
99 $list = explode("\n", $string);
100 $list = array_map('trim', $list);
101 $list = array_filter($list, 'strlen');
102
103 foreach ($list as $key => $value) {
104 // Check for a manually specified key.
105 if (strpos($value, '|') !== FALSE) {
106 list($key, $value) = explode('|', $value);
107 }
108 // Otherwise see if we need to use the value as the key. The "list" type
109 // will automatically convert non-keyed lines to integers.
110 elseif (!$position_keys) {
111 $key = $value;
112 }
113 $values[$key] = (isset($value) && $value !== '') ? $value : $key;
114 }
115
116 return $values;
117 }
118
127 function list_update_7002() {
128 // See http://drupal.org/node/1022924: list_update_7001() intitally
129 // overlooked deleted fields, which then caused fatal errors when the fields
130 // were being purged.
131 // list_update_7001() has the required checks to ensure it is reentrant, so
132 // it can simply be executed once more..
133 list_update_7001();
134 }
135
_update_7000_field_read_fields
_update_7000_field_read_fields(array $conditions=array(), $key= 'id')
Definition: field.install:328
list_update_7002
list_update_7002()
Definition: list.install:127
$value
print $value
Definition: user-profile-item.tpl.php:26
list_field_schema
list_field_schema($field)
Definition: list.install:11
list_update_7001
list_update_7001()
Definition: list.install:51
_list_update_7001_extract_allowed_values
_list_update_7001_extract_allowed_values($string, $position_keys)
Definition: list.install:96
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/tablesort.inc Source File

  • includes
tablesort.inc
Go to the documentation of this file.
1 <?php
2
15 class TableSort extends SelectQueryExtender {
16
22 protected $header = array();
23
24 public function __construct(SelectQueryInterface $query, DatabaseConnection $connection) {
25 parent::__construct($query, $connection);
26
27 // Add convenience tag to mark that this is an extended query. We have to
28 // do this in the constructor to ensure that it is set before preExecute()
29 // gets called.
30 $this->addTag('tablesort');
31 }
32
42 public function orderByHeader(Array $header) {
43 $this->header = $header;
44 $ts = $this->init();
45 if (!empty($ts['sql'])) {
46 // Based on code from db_escape_table(), but this can also contain a dot.
47 $field = preg_replace('/[^A-Za-z0-9_.]+/', '', $ts['sql']);
48
49 // Sort order can only be ASC or DESC.
50 $sort = drupal_strtoupper($ts['sort']);
51 $sort = in_array($sort, array('ASC', 'DESC')) ? $sort : '';
52 $this->orderBy($field, $sort);
53 }
54 return $this;
55 }
56
60 protected function init() {
61 $ts = $this->order();
62 $ts['sort'] = $this->getSort();
63 $ts['query'] = $this->getQueryParameters();
64 return $ts;
65 }
66
75 protected function getSort() {
76 return tablesort_get_sort($this->header);
77 }
78
88 protected function getQueryParameters() {
89 return tablesort_get_query_parameters();
90 }
91
102 protected function order() {
103 return tablesort_get_order($this->header);
104 }
105 }
106
110 function tablesort_init($header) {
111 $ts = tablesort_get_order($header);
112 $ts['sort'] = tablesort_get_sort($header);
113 $ts['query'] = tablesort_get_query_parameters();
114 return $ts;
115 }
116
133 function tablesort_header($cell, $header, $ts) {
134 // Special formatting for the currently sorted column header.
135 if (is_array($cell) && isset($cell['field'])) {
136 $title = t('sort by @s', array('@s' => $cell['data']));
137 if ($cell['data'] == $ts['name']) {
138 $ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'asc');
139 $cell['class'][] = 'active';
140 $image = theme('tablesort_indicator', array('style' => $ts['sort']));
141 }
142 else {
143 // If the user clicks a different header, we want to sort ascending initially.
144 $ts['sort'] = 'asc';
145 $image = '';
146 }
147 $cell['data'] = l($cell['data'] . $image, $_GET['q'], array('attributes' => array('title' => $title), 'query' => array_merge($ts['query'], array('sort' => $ts['sort'], 'order' => $cell['data'])), 'html' => TRUE));
148
149 unset($cell['field'], $cell['sort']);
150 }
151 return $cell;
152 }
153
171 function tablesort_cell($cell, $header, $ts, $i) {
172 if (isset($header[$i]['data']) && $header[$i]['data'] == $ts['name'] && !empty($header[$i]['field'])) {
173 if (is_array($cell)) {
174 $cell['class'][] = 'active';
175 }
176 else {
177 $cell = array('data' => $cell, 'class' => array('active'));
178 }
179 }
180 return $cell;
181 }
182
190 function tablesort_get_query_parameters() {
191 return drupal_get_query_parameters($_GET, array('q', 'sort', 'order'));
192 }
193
205 function tablesort_get_order($headers) {
206 $order = isset($_GET['order']) ? $_GET['order'] : '';
207 foreach ($headers as $header) {
208 if (is_array($header)) {
209 if (isset($header['data']) && $order == $header['data']) {
210 $default = $header;
211 break;
212 }
213
214 if (empty($default) && isset($header['sort']) && ($header['sort'] == 'asc' || $header['sort'] == 'desc')) {
215 $default = $header;
216 }
217 }
218 }
219
220 if (!isset($default)) {
221 $default = reset($headers);
222 if (!is_array($default)) {
223 $default = array('data' => $default);
224 }
225 }
226
227 $default += array('data' => NULL, 'field' => NULL);
228 return array('name' => $default['data'], 'sql' => $default['field']);
229 }
230
240 function tablesort_get_sort($headers) {
241 if (isset($_GET['sort'])) {
242 return (strtolower($_GET['sort']) == 'desc') ? 'desc' : 'asc';
243 }
244 // The user has not specified a sort. Use the default for the currently sorted
245 // header if specified; otherwise use "asc".
246 else {
247 // Find out which header is currently being sorted.
248 $ts = tablesort_get_order($headers);
249 foreach ($headers as $header) {
250 if (is_array($header) && isset($header['data']) && $header['data'] == $ts['name'] && isset($header['sort'])) {
251 return $header['sort'];
252 }
253 }
254 }
255 return 'asc';
256 }
TableSort\getQueryParameters
getQueryParameters()
Definition: tablesort.inc:88
l
l($text, $path, array $options=array())
Definition: common.inc:2432
SelectQueryExtender\orderBy
orderBy($field, $direction= 'ASC')
Definition: select.inc:764
drupal_get_query_parameters
drupal_get_query_parameters(array $query=NULL, array $exclude=array('q'), $parent= '')
Definition: common.inc:417
tablesort_cell
tablesort_cell($cell, $header, $ts, $i)
Definition: tablesort.inc:171
$header
print $header
Definition: forum-topic-list.tpl.php:42
SelectQueryExtender
Definition: select.inc:535
TableSort\getSort
getSort()
Definition: tablesort.inc:75
tablesort_get_order
tablesort_get_order($headers)
Definition: tablesort.inc:205
TableSort\init
init()
Definition: tablesort.inc:60
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
tablesort_header
tablesort_header($cell, $header, $ts)
Definition: tablesort.inc:133
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
drupal_strtoupper
drupal_strtoupper($text)
Definition: unicode.inc:496
TableSort\__construct
__construct(SelectQueryInterface $query, DatabaseConnection $connection)
Definition: tablesort.inc:24
SelectQueryExtender\$query
$query
Definition: select.inc:542
TableSort\$header
$header
Definition: tablesort.inc:22
TableSort\order
order()
Definition: tablesort.inc:102
SelectQueryExtender\addTag
addTag($tag)
Definition: select.inc:583
SelectQueryInterface
Definition: select.inc:39
tablesort_get_query_parameters
tablesort_get_query_parameters()
Definition: tablesort.inc:190
DatabaseConnection
Definition: database.inc:184
TableSort
Definition: tablesort.inc:15
TableSort\orderByHeader
orderByHeader(Array $header)
Definition: tablesort.inc:42
tablesort_init
tablesort_init($header)
Definition: tablesort.inc:110
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
SelectQueryExtender\$connection
$connection
Definition: select.inc:549
tablesort_get_sort
tablesort_get_sort($headers)
Definition: tablesort.inc:240
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/cache_example/cache_example.module Source File

  • examples
  • cache_example
cache_example.module
Go to the documentation of this file.
1 <?php
2
33 function cache_example_menu() {
34 $items = array();
35 $items['examples/cache_example'] = array(
36 'title' => 'Cache example',
37 'description' => 'Example of Drupal Cache API',
38 'page callback' => 'drupal_get_form',
39 'page arguments' => array('cache_example_page_form'),
40 'access callback' => TRUE,
41 );
42
43 return $items;
44 }
45
51 function cache_example_page_form($form, &$form_state) {
52 // Log execution time.
53 $start_time = microtime(TRUE);
54
55
56 // Try to load the files count from cache. This function will accept two
57 // arguments:
58 // - cache object name (cid)
59 // - cache bin, the (optional) cache bin (most often a database table) where
60 // the object is to be saved.
61 //
62 // cache_get() returns the cached object or FALSE if object does not exist.
63 if ($cache = cache_get('cache_example_files_count')) {
64 /*
65 * Get cached data. Complex data types will be unserialized automatically.
66 */
67 $files_count = $cache->data;
68 }
69 else {
70 // If there was no cached data available we have to search filesystem.
71 // Recursively get all files from Drupal's folder.
72 $files_count = count(file_scan_directory('.', '/.*/'));
73
74
75 // Since we have recalculated, we now need to store the new data into cache.
76 // Complex data types will be automatically serialized before being saved
77 // into cache.
78 // Here we use the default setting and create an unexpiring cache item.
79 // See below for an example that creates an expiring cache item.
80 cache_set('cache_example_files_count', $files_count);
81 }
82
83 $end_time = microtime(TRUE);
84 $duration = $end_time - $start_time;
85
86
87 // Format intro message.
88 $intro_message = '<p>' . t('This example will search the entire drupal folder and display a count of the files in it.') . ' ';
89 $intro_message .= t('This can take a while, since there are a lot of files to be searched.') . ' ';
90 $intro_message .= t('We will search filesystem just once and save output to the cache. We will use cached data for later requests.') . '</p>';
91 $intro_message .= '<p>' . t('<a href="@url">Reload this page</a> to see cache in action.', array('@url' => request_uri())) . ' ';
92 $intro_message .= t('You can use the button below to remove cached data.') . '</p>';
93
94 $form['file_search'] = array(
95 '#type' => 'fieldset',
96 '#title' => t('File search caching'),
97 );
98 $form['file_search']['introduction'] = array(
99 '#markup' => $intro_message,
100 );
101
102 $color = empty($cache) ? 'red' : 'green';
103 $retrieval = empty($cache) ? t('calculated by traversing the filesystem') : t('retrieved from cache');
104
105 $form['file_search']['statistics'] = array(
106 '#type' => 'item',
107 '#markup' => t('%count files exist in this Drupal installation; @retrieval in @time ms. <br/>(Source: <span style="color:@color;">@source</span>)',
108 array(
109 '%count' => $files_count,
110 '@retrieval' => $retrieval,
111 '@time' => number_format($duration * 1000, 2),
112 '@color' => $color,
113 '@source' => empty($cache) ? t('actual file search') : t('cached'),
114 )
115 ),
116 );
117 $form['file_search']['remove_file_count'] = array(
118 '#type' => 'submit',
119 '#submit' => array('cache_example_form_expire_files'),
120 '#value' => t('Explicitly remove cached file count'),
121 );
122
123 $form['expiration_demo'] = array(
124 '#type' => 'fieldset',
125 '#title' => t('Cache expiration settings'),
126 );
127 $form['expiration_demo']['explanation'] = array(
128 '#markup' => t('A cache item can be set as CACHE_PERMANENT, meaning that it will only be removed when explicitly cleared, or it can have an expiration time (a Unix timestamp).'),
129 );
130 $expiring_item = cache_get('cache_example_expiring_item');
131 $item_status = $expiring_item ?
132 t('Cache item exists and is set to expire at %time', array('%time' => $expiring_item->data)) :
133 t('Cache item does not exist');
134 $form['expiration_demo']['current_status'] = array(
135 '#type' => 'item',
136 '#title' => t('Current status of cache item "cache_example_expiring_item"'),
137 '#markup' => $item_status,
138 );
139 $form['expiration_demo']['expiration'] = array(
140 '#type' => 'select',
141 '#title' => t('Time before cache expiration'),
142 '#options' => array(
143 'never_remove' => t('CACHE_PERMANENT'),
144 -10 => t('Immediate expiration'),
145 10 => t('10 seconds from form submission'),
146 60 => t('1 minute from form submission'),
147 300 => t('5 minutes from form submission'),
148 ),
149 '#default_value' => -10,
150 '#description' => t('Any cache item can be set to only expire when explicitly cleared, or to expire at a given time.')
151 );
152 $form['expiration_demo']['create_cache_item'] = array(
153 '#type' => 'submit',
154 '#value' => t('Create a cache item with this expiration'),
155 '#submit' => array('cache_example_form_create_expiring_item'),
156 );
157
158 $form['cache_clearing'] = array(
159 '#type' => 'fieldset',
160 '#title' => t('Expire and remove options'),
161 '#description' => t("We have APIs to expire cached items and also to just remove them. Unfortunately, they're all the same API, cache_clear_all"),
162 );
163 $form['cache_clearing']['cache_clear_type'] = array(
164 '#type' => 'radios',
165 '#title' => t('Type of cache clearing to do'),
166 '#options' => array(
167 'expire' => t('Remove items from the "cache" bin that have expired'),
168 'remove_all' => t('Remove all items from the "cache" bin regardless of expiration (super-wildcard)'),
169 'remove_wildcard' => t('Remove all items from the "cache" bin that match the pattern "cache_example"'),
170 ),
171 '#default_value' => 'expire',
172 );
173 // Submit button to clear cached data.
174 $form['cache_clearing']['clear_expired'] = array(
175 '#type' => 'submit',
176 '#value' => t('Clear or expire cache'),
177 '#submit' => array('cache_example_form_cache_clearing'),
178 '#access' => user_access('administer site configuration'),
179 );
180 return $form;
181 }
182
186 function cache_example_form_expire_files($form, &$form_state) {
187 // Clear cached data. This function will delete cached object from cache bin.
188 //
189 // The first argument is cache id to be deleted. Since we've provided it
190 // explicitly, it will be removed whether or not it has an associated
191 // expiration time. The second argument (required here) is the cache bin.
192 // Using cache_clear_all() explicitly in this way
193 // forces removal of the cached item.
194 cache_clear_all('cache_example_files_count', 'cache');
195
196 // Display message to the user.
197 drupal_set_message(t('Cached data key "cache_example_files_count" was cleared.'), 'status');
198 }
199
203 function cache_example_form_create_expiring_item($form, &$form_state) {
204 $interval = $form_state['values']['expiration'];
205 if ($interval == 'never_remove') {
206 $expiration = CACHE_PERMANENT;
207 $expiration_friendly = t('Never expires');
208 }
209 else {
210 $expiration = time() + $interval;
211 $expiration_friendly = format_date($expiration);
212 }
213 // Set the expiration to the actual Unix timestamp of the end of the required
214 // interval.
215 cache_set('cache_example_expiring_item', $expiration_friendly, 'cache', $expiration);
216 drupal_set_message(t('cache_example_expiring_item was set to expire at %time', array('%time' => $expiration_friendly)));
217 }
218
222 function cache_example_form_cache_clearing($form, &$form_state) {
223 switch ($form_state['values']['cache_clear_type']) {
224 case 'expire':
225 // Here we'll remove all cache keys in the 'cache' bin that have expired.
226 cache_clear_all(NULL, 'cache');
227 drupal_set_message(t('cache_clear_all(NULL, "cache") was called, removing any expired cache items.'));
228 break;
229 case 'remove_all':
230 // This removes all keys in a bin using a super-wildcard. This
231 // has nothing to do with expiration. It's just brute-force removal.
232 cache_clear_all('*', 'cache', TRUE);
233 drupal_set_message(t('ALL entries in the "cache" bin were removed with cache_clear_all("*", "cache", TRUE).'));
234 break;
235 case 'remove_wildcard':
236 // We can also explicitly remove all cache items whose cid begins with
237 // 'cache_example' by using a wildcard. This again is brute-force
238 // removal, not expiration.
239 cache_clear_all('cache_example', 'cache', TRUE);
240 drupal_set_message(t('Cache entries whose cid began with "cache_example" in the "cache" bin were removed with cache_clear_all("cache_example", "cache", TRUE).'));
241 break;
242 }
243 }
244
file_scan_directory
file_scan_directory($dir, $mask, $options=array(), $depth=0)
Definition: file.inc:2058
cache_example_menu
cache_example_menu()
Definition: cache_example.module:33
cache_example_form_cache_clearing
cache_example_form_cache_clearing($form, &$form_state)
Definition: cache_example.module:222
request_uri
request_uri()
Definition: bootstrap.inc:1609
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
cache_example_page_form
cache_example_page_form($form, &$form_state)
Definition: cache_example.module:51
cache_example_form_create_expiring_item
cache_example_form_create_expiring_item($form, &$form_state)
Definition: cache_example.module:203
user_access
user_access($string, $account=NULL)
Definition: user.module:794
cache_example_form_expire_files
cache_example_form_expire_files($form, &$form_state)
Definition: cache_example.module:186
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
CACHE_PERMANENT
const CACHE_PERMANENT
Definition: bootstrap.inc:48
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/html.tpl.php Source File

  • modules
  • system
html.tpl.php
Go to the documentation of this file.
1 <?php
2
45 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
46 "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
47 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>"<?php print $rdf_namespaces; ?>>
48
49 <head profile="<?php print $grddl_profile; ?>">
50 <?php print $head; ?>
51 <title><?php print $head_title; ?></title>
52 <?php print $styles; ?>
53 <?php print $scripts; ?>
54 </head>
55 <body class="<?php print $classes; ?>" <?php print $attributes;?>>
56 <div id="skip-link">
57 <a href="#main-content" class="element-invisible element-focusable"><?php print t('Skip to main content'); ?></a>
58 </div>
59 <?php print $page_top; ?>
60 <?php print $page; ?>
61 <?php print $page_bottom; ?>
62 </body>
63 </html>
dir
print $language dir
Definition: html.tpl.php:47
$head
print $head
Definition: book-export-html.tpl.php:25
$page
print $page
Definition: overlay.tpl.php:37
$attributes
print $attributes
Definition: block.tpl.php:47
$rdf_namespaces
print $rdf_namespaces
Definition: html.tpl.php:47
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$scripts
print $scripts
Definition: html.tpl.php:53
$styles
print $styles
Definition: html.tpl.php:52
title
print $topic title
Definition: forum-topic-list.tpl.php:50
$page_top
print $page_top
Definition: html.tpl.php:59
$head_title
print $head_title
Definition: html.tpl.php:51
$page_bottom
print $page_bottom
Definition: html.tpl.php:61
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/update/update.compare.inc Source File

  • modules
  • update
update.compare.inc
Go to the documentation of this file.
1 <?php
2
56 function update_get_projects() {
57 $projects = &drupal_static(__FUNCTION__, array());
58 if (empty($projects)) {
59 // Retrieve the projects from cache, if present.
60 $projects = update_project_cache('update_project_projects');
61 if (empty($projects)) {
62 // Still empty, so we have to rebuild the cache.
63 $module_data = system_rebuild_module_data();
64 $theme_data = system_rebuild_theme_data();
65 _update_process_info_list($projects, $module_data, 'module', TRUE);
66 _update_process_info_list($projects, $theme_data, 'theme', TRUE);
67 if (variable_get('update_check_disabled', FALSE)) {
68 _update_process_info_list($projects, $module_data, 'module', FALSE);
69 _update_process_info_list($projects, $theme_data, 'theme', FALSE);
70 }
71 // Allow other modules to alter projects before fetching and comparing.
72 drupal_alter('update_projects', $projects);
73 // Cache the site's project data for at most 1 hour.
74 _update_cache_set('update_project_projects', $projects, REQUEST_TIME + 3600);
75 }
76 }
77 return $projects;
78 }
79
106 function _update_process_info_list(&$projects, $list, $project_type, $status) {
107 foreach ($list as $file) {
108 // A disabled base theme of an enabled sub-theme still has all of its code
109 // run by the sub-theme, so we include it in our "enabled" projects list.
110 if ($status && !$file->status && !empty($file->sub_themes)) {
111 foreach ($file->sub_themes as $key => $name) {
112 // Build a list of enabled sub-themes.
113 if ($list[$key]->status) {
114 $file->enabled_sub_themes[$key] = $name;
115 }
116 }
117 // If there are no enabled subthemes, we should ignore this base theme
118 // for the enabled case. If the site is trying to display disabled
119 // themes, we'll catch it then.
120 if (empty($file->enabled_sub_themes)) {
121 continue;
122 }
123 }
124 // Otherwise, just add projects of the proper status to our list.
125 elseif ($file->status != $status) {
126 continue;
127 }
128
129 // Skip if the .info file is broken.
130 if (empty($file->info)) {
131 continue;
132 }
133
134 // Skip if it's a hidden module or theme.
135 if (!empty($file->info['hidden'])) {
136 continue;
137 }
138
139 // If the .info doesn't define the 'project', try to figure it out.
140 if (!isset($file->info['project'])) {
141 $file->info['project'] = update_get_project_name($file);
142 }
143
144 // If we still don't know the 'project', give up.
145 if (empty($file->info['project'])) {
146 continue;
147 }
148
149 // If we don't already know it, grab the change time on the .info file
150 // itself. Note: we need to use the ctime, not the mtime (modification
151 // time) since many (all?) tar implementations will go out of their way to
152 // set the mtime on the files it creates to the timestamps recorded in the
153 // tarball. We want to see the last time the file was changed on disk,
154 // which is left alone by tar and correctly set to the time the .info file
155 // was unpacked.
156 if (!isset($file->info['_info_file_ctime'])) {
157 $info_filename = dirname($file->uri) . '/' . $file->name . '.info';
158 $file->info['_info_file_ctime'] = filectime($info_filename);
159 }
160
161 if (!isset($file->info['datestamp'])) {
162 $file->info['datestamp'] = 0;
163 }
164
165 $project_name = $file->info['project'];
166
167 // Figure out what project type we're going to use to display this module
168 // or theme. If the project name is 'drupal', we don't want it to show up
169 // under the usual "Modules" section, we put it at a special "Drupal Core"
170 // section at the top of the report.
171 if ($project_name == 'drupal') {
172 $project_display_type = 'core';
173 }
174 else {
175 $project_display_type = $project_type;
176 }
177 if (empty($status) && empty($file->enabled_sub_themes)) {
178 // If we're processing disabled modules or themes, append a suffix.
179 // However, we don't do this to a a base theme with enabled
180 // subthemes, since we treat that case as if it is enabled.
181 $project_display_type .= '-disabled';
182 }
183 // Add a list of sub-themes that "depend on" the project and a list of base
184 // themes that are "required by" the project.
185 if ($project_name == 'drupal') {
186 // Drupal core is always required, so this extra info would be noise.
187 $sub_themes = array();
188 $base_themes = array();
189 }
190 else {
191 // Add list of enabled sub-themes.
192 $sub_themes = !empty($file->enabled_sub_themes) ? $file->enabled_sub_themes : array();
193 // Add list of base themes.
194 $base_themes = !empty($file->base_themes) ? $file->base_themes : array();
195 }
196 if (!isset($projects[$project_name])) {
197 // Only process this if we haven't done this project, since a single
198 // project can have multiple modules or themes.
199 $projects[$project_name] = array(
200 'name' => $project_name,
201 // Only save attributes from the .info file we care about so we do not
202 // bloat our RAM usage needlessly.
203 'info' => update_filter_project_info($file->info),
204 'datestamp' => $file->info['datestamp'],
205 'includes' => array($file->name => $file->info['name']),
206 'project_type' => $project_display_type,
207 'project_status' => $status,
208 'sub_themes' => $sub_themes,
209 'base_themes' => $base_themes,
210 );
211 }
212 elseif ($projects[$project_name]['project_type'] == $project_display_type) {
213 // Only add the file we're processing to the 'includes' array for this
214 // project if it is of the same type and status (which is encoded in the
215 // $project_display_type). This prevents listing all the disabled
216 // modules included with an enabled project if we happen to be checking
217 // for disabled modules, too.
218 $projects[$project_name]['includes'][$file->name] = $file->info['name'];
219 $projects[$project_name]['info']['_info_file_ctime'] = max($projects[$project_name]['info']['_info_file_ctime'], $file->info['_info_file_ctime']);
220 $projects[$project_name]['datestamp'] = max($projects[$project_name]['datestamp'], $file->info['datestamp']);
221 if (!empty($sub_themes)) {
222 $projects[$project_name]['sub_themes'] += $sub_themes;
223 }
224 if (!empty($base_themes)) {
225 $projects[$project_name]['base_themes'] += $base_themes;
226 }
227 }
228 elseif (empty($status)) {
229 // If we have a project_name that matches, but the project_display_type
230 // does not, it means we're processing a disabled module or theme that
231 // belongs to a project that has some enabled code. In this case, we add
232 // the disabled thing into a separate array for separate display.
233 $projects[$project_name]['disabled'][$file->name] = $file->info['name'];
234 }
235 }
236 }
237
249 function update_get_project_name($file) {
250 $project_name = '';
251 if (isset($file->info['project'])) {
252 $project_name = $file->info['project'];
253 }
254 elseif (isset($file->info['package']) && (strpos($file->info['package'], 'Core') === 0)) {
255 $project_name = 'drupal';
256 }
257 return $project_name;
258 }
259
270 function update_process_project_info(&$projects) {
271 foreach ($projects as $key => $project) {
272 // Assume an official release until we see otherwise.
273 $install_type = 'official';
274
275 $info = $project['info'];
276
277 if (isset($info['version'])) {
278 // Check for development snapshots
279 if (preg_match('@(dev|HEAD)@', $info['version'])) {
280 $install_type = 'dev';
281 }
282
283 // Figure out what the currently installed major version is. We need
284 // to handle both contribution (e.g. "5.x-1.3", major = 1) and core
285 // (e.g. "5.1", major = 5) version strings.
286 $matches = array();
287 if (preg_match('/^(\d+\.x-)?(\d+)\..*$/', $info['version'], $matches)) {
288 $info['major'] = $matches[2];
289 }
290 elseif (!isset($info['major'])) {
291 // This would only happen for version strings that don't follow the
292 // drupal.org convention. We let contribs define "major" in their
293 // .info in this case, and only if that's missing would we hit this.
294 $info['major'] = -1;
295 }
296 }
297 else {
298 // No version info available at all.
299 $install_type = 'unknown';
300 $info['version'] = t('Unknown');
301 $info['major'] = -1;
302 }
303
304 // Finally, save the results we care about into the $projects array.
305 $projects[$key]['existing_version'] = $info['version'];
306 $projects[$key]['existing_major'] = $info['major'];
307 $projects[$key]['install_type'] = $install_type;
308 }
309 }
310
335 function update_calculate_project_data($available) {
336 // Retrieve the projects from cache, if present.
337 $projects = update_project_cache('update_project_data');
338 // If $projects is empty, then the cache must be rebuilt.
339 // Otherwise, return the cached data and skip the rest of the function.
340 if (!empty($projects)) {
341 return $projects;
342 }
343 $projects = update_get_projects();
344 update_process_project_info($projects);
345 foreach ($projects as $project => $project_info) {
346 if (isset($available[$project])) {
347 update_calculate_project_update_status($project, $projects[$project], $available[$project]);
348 }
349 else {
350 $projects[$project]['status'] = UPDATE_UNKNOWN;
351 $projects[$project]['reason'] = t('No available releases found');
352 }
353 }
354 // Give other modules a chance to alter the status (for example, to allow a
355 // contrib module to provide fine-grained settings to ignore specific
356 // projects or releases).
357 drupal_alter('update_status', $projects);
358
359 // Cache the site's update status for at most 1 hour.
360 _update_cache_set('update_project_data', $projects, REQUEST_TIME + 3600);
361 return $projects;
362 }
363
427 function update_calculate_project_update_status($project, &$project_data, $available) {
428 foreach (array('title', 'link') as $attribute) {
429 if (!isset($project_data[$attribute]) && isset($available[$attribute])) {
430 $project_data[$attribute] = $available[$attribute];
431 }
432 }
433
434 // If the project status is marked as something bad, there's nothing else
435 // to consider.
436 if (isset($available['project_status'])) {
437 switch ($available['project_status']) {
438 case 'insecure':
439 $project_data['status'] = UPDATE_NOT_SECURE;
440 if (empty($project_data['extra'])) {
441 $project_data['extra'] = array();
442 }
443 $project_data['extra'][] = array(
444 'class' => array('project-not-secure'),
445 'label' => t('Project not secure'),
446 'data' => t('This project has been labeled insecure by the Drupal security team, and is no longer available for download. Immediately disabling everything included by this project is strongly recommended!'),
447 );
448 break;
449 case 'unpublished':
450 case 'revoked':
451 $project_data['status'] = UPDATE_REVOKED;
452 if (empty($project_data['extra'])) {
453 $project_data['extra'] = array();
454 }
455 $project_data['extra'][] = array(
456 'class' => array('project-revoked'),
457 'label' => t('Project revoked'),
458 'data' => t('This project has been revoked, and is no longer available for download. Disabling everything included by this project is strongly recommended!'),
459 );
460 break;
461 case 'unsupported':
462 $project_data['status'] = UPDATE_NOT_SUPPORTED;
463 if (empty($project_data['extra'])) {
464 $project_data['extra'] = array();
465 }
466 $project_data['extra'][] = array(
467 'class' => array('project-not-supported'),
468 'label' => t('Project not supported'),
469 'data' => t('This project is no longer supported, and is no longer available for download. Disabling everything included by this project is strongly recommended!'),
470 );
471 break;
472 case 'not-fetched':
473 $project_data['status'] = UPDATE_NOT_FETCHED;
474 $project_data['reason'] = t('Failed to get available update data.');
475 break;
476
477 default:
478 // Assume anything else (e.g. 'published') is valid and we should
479 // perform the rest of the logic in this function.
480 break;
481 }
482 }
483
484 if (!empty($project_data['status'])) {
485 // We already know the status for this project, so there's nothing else to
486 // compute. Record the project status into $project_data and we're done.
487 $project_data['project_status'] = $available['project_status'];
488 return;
489 }
490
491 // Figure out the target major version.
492 $existing_major = $project_data['existing_major'];
493 $supported_majors = array();
494 if (isset($available['supported_majors'])) {
495 $supported_majors = explode(',', $available['supported_majors']);
496 }
497 elseif (isset($available['default_major'])) {
498 // Older release history XML file without supported or recommended.
499 $supported_majors[] = $available['default_major'];
500 }
501
502 if (in_array($existing_major, $supported_majors)) {
503 // Still supported, stay at the current major version.
504 $target_major = $existing_major;
505 }
506 elseif (isset($available['recommended_major'])) {
507 // Since 'recommended_major' is defined, we know this is the new XML
508 // format. Therefore, we know the current release is unsupported since
509 // its major version was not in the 'supported_majors' list. We should
510 // find the best release from the recommended major version.
511 $target_major = $available['recommended_major'];
512 $project_data['status'] = UPDATE_NOT_SUPPORTED;
513 }
514 elseif (isset($available['default_major'])) {
515 // Older release history XML file without recommended, so recommend
516 // the currently defined "default_major" version.
517 $target_major = $available['default_major'];
518 }
519 else {
520 // Malformed XML file? Stick with the current version.
521 $target_major = $existing_major;
522 }
523
524 // Make sure we never tell the admin to downgrade. If we recommended an
525 // earlier version than the one they're running, they'd face an
526 // impossible data migration problem, since Drupal never supports a DB
527 // downgrade path. In the unfortunate case that what they're running is
528 // unsupported, and there's nothing newer for them to upgrade to, we
529 // can't print out a "Recommended version", but just have to tell them
530 // what they have is unsupported and let them figure it out.
531 $target_major = max($existing_major, $target_major);
532
533 $release_patch_changed = '';
534 $patch = '';
535
536 // If the project is marked as UPDATE_FETCH_PENDING, it means that the
537 // data we currently have (if any) is stale, and we've got a task queued
538 // up to (re)fetch the data. In that case, we mark it as such, merge in
539 // whatever data we have (e.g. project title and link), and move on.
540 if (!empty($available['fetch_status']) && $available['fetch_status'] == UPDATE_FETCH_PENDING) {
541 $project_data['status'] = UPDATE_FETCH_PENDING;
542 $project_data['reason'] = t('No available update data');
543 $project_data['fetch_status'] = $available['fetch_status'];
544 return;
545 }
546
547 // Defend ourselves from XML history files that contain no releases.
548 if (empty($available['releases'])) {
549 $project_data['status'] = UPDATE_UNKNOWN;
550 $project_data['reason'] = t('No available releases found');
551 return;
552 }
553 foreach ($available['releases'] as $version => $release) {
554 // First, if this is the existing release, check a few conditions.
555 if ($project_data['existing_version'] === $version) {
556 if (isset($release['terms']['Release type']) &&
557 in_array('Insecure', $release['terms']['Release type'])) {
558 $project_data['status'] = UPDATE_NOT_SECURE;
559 }
560 elseif ($release['status'] == 'unpublished') {
561 $project_data['status'] = UPDATE_REVOKED;
562 if (empty($project_data['extra'])) {
563 $project_data['extra'] = array();
564 }
565 $project_data['extra'][] = array(
566 'class' => array('release-revoked'),
567 'label' => t('Release revoked'),
568 'data' => t('Your currently installed release has been revoked, and is no longer available for download. Disabling everything included in this release or upgrading is strongly recommended!'),
569 );
570 }
571 elseif (isset($release['terms']['Release type']) &&
572 in_array('Unsupported', $release['terms']['Release type'])) {
573 $project_data['status'] = UPDATE_NOT_SUPPORTED;
574 if (empty($project_data['extra'])) {
575 $project_data['extra'] = array();
576 }
577 $project_data['extra'][] = array(
578 'class' => array('release-not-supported'),
579 'label' => t('Release not supported'),
580 'data' => t('Your currently installed release is now unsupported, and is no longer available for download. Disabling everything included in this release or upgrading is strongly recommended!'),
581 );
582 }
583 }
584
585 // Otherwise, ignore unpublished, insecure, or unsupported releases.
586 if ($release['status'] == 'unpublished' ||
587 (isset($release['terms']['Release type']) &&
588 (in_array('Insecure', $release['terms']['Release type']) ||
589 in_array('Unsupported', $release['terms']['Release type'])))) {
590 continue;
591 }
592
593 // See if this is a higher major version than our target and yet still
594 // supported. If so, record it as an "Also available" release.
595 // Note: some projects have a HEAD release from CVS days, which could
596 // be one of those being compared. They would not have version_major
597 // set, so we must call isset first.
598 if (isset($release['version_major']) && $release['version_major'] > $target_major) {
599 if (in_array($release['version_major'], $supported_majors)) {
600 if (!isset($project_data['also'])) {
601 $project_data['also'] = array();
602 }
603 if (!isset($project_data['also'][$release['version_major']])) {
604 $project_data['also'][$release['version_major']] = $version;
605 $project_data['releases'][$version] = $release;
606 }
607 }
608 // Otherwise, this release can't matter to us, since it's neither
609 // from the release series we're currently using nor the recommended
610 // release. We don't even care about security updates for this
611 // branch, since if a project maintainer puts out a security release
612 // at a higher major version and not at the lower major version,
613 // they must remove the lower version from the supported major
614 // versions at the same time, in which case we won't hit this code.
615 continue;
616 }
617
618 // Look for the 'latest version' if we haven't found it yet. Latest is
619 // defined as the most recent version for the target major version.
620 if (!isset($project_data['latest_version'])
621 && $release['version_major'] == $target_major) {
622 $project_data['latest_version'] = $version;
623 $project_data['releases'][$version] = $release;
624 }
625
626 // Look for the development snapshot release for this branch.
627 if (!isset($project_data['dev_version'])
628 && $release['version_major'] == $target_major
629 && isset($release['version_extra'])
630 && $release['version_extra'] == 'dev') {
631 $project_data['dev_version'] = $version;
632 $project_data['releases'][$version] = $release;
633 }
634
635 // Look for the 'recommended' version if we haven't found it yet (see
636 // phpdoc at the top of this function for the definition).
637 if (!isset($project_data['recommended'])
638 && $release['version_major'] == $target_major
639 && isset($release['version_patch'])) {
640 if ($patch != $release['version_patch']) {
641 $patch = $release['version_patch'];
642 $release_patch_changed = $release;
643 }
644 if (empty($release['version_extra']) && $patch == $release['version_patch']) {
645 $project_data['recommended'] = $release_patch_changed['version'];
646 $project_data['releases'][$release_patch_changed['version']] = $release_patch_changed;
647 }
648 }
649
650 // Stop searching once we hit the currently installed version.
651 if ($project_data['existing_version'] === $version) {
652 break;
653 }
654
655 // If we're running a dev snapshot and have a timestamp, stop
656 // searching for security updates once we hit an official release
657 // older than what we've got. Allow 100 seconds of leeway to handle
658 // differences between the datestamp in the .info file and the
659 // timestamp of the tarball itself (which are usually off by 1 or 2
660 // seconds) so that we don't flag that as a new release.
661 if ($project_data['install_type'] == 'dev') {
662 if (empty($project_data['datestamp'])) {
663 // We don't have current timestamp info, so we can't know.
664 continue;
665 }
666 elseif (isset($release['date']) && ($project_data['datestamp'] + 100 > $release['date'])) {
667 // We're newer than this, so we can skip it.
668 continue;
669 }
670 }
671
672 // See if this release is a security update.
673 if (isset($release['terms']['Release type'])
674 && in_array('Security update', $release['terms']['Release type'])) {
675 $project_data['security updates'][] = $release;
676 }
677 }
678
679 // If we were unable to find a recommended version, then make the latest
680 // version the recommended version if possible.
681 if (!isset($project_data['recommended']) && isset($project_data['latest_version'])) {
682 $project_data['recommended'] = $project_data['latest_version'];
683 }
684
685 //
686 // Check to see if we need an update or not.
687 //
688
689 if (!empty($project_data['security updates'])) {
690 // If we found security updates, that always trumps any other status.
691 $project_data['status'] = UPDATE_NOT_SECURE;
692 }
693
694 if (isset($project_data['status'])) {
695 // If we already know the status, we're done.
696 return;
697 }
698
699 // If we don't know what to recommend, there's nothing we can report.
700 // Bail out early.
701 if (!isset($project_data['recommended'])) {
702 $project_data['status'] = UPDATE_UNKNOWN;
703 $project_data['reason'] = t('No available releases found');
704 return;
705 }
706
707 // If we're running a dev snapshot, compare the date of the dev snapshot
708 // with the latest official version, and record the absolute latest in
709 // 'latest_dev' so we can correctly decide if there's a newer release
710 // than our current snapshot.
711 if ($project_data['install_type'] == 'dev') {
712 if (isset($project_data['dev_version']) && $available['releases'][$project_data['dev_version']]['date'] > $available['releases'][$project_data['latest_version']]['date']) {
713 $project_data['latest_dev'] = $project_data['dev_version'];
714 }
715 else {
716 $project_data['latest_dev'] = $project_data['latest_version'];
717 }
718 }
719
720 // Figure out the status, based on what we've seen and the install type.
721 switch ($project_data['install_type']) {
722 case 'official':
723 if ($project_data['existing_version'] === $project_data['recommended'] || $project_data['existing_version'] === $project_data['latest_version']) {
724 $project_data['status'] = UPDATE_CURRENT;
725 }
726 else {
727 $project_data['status'] = UPDATE_NOT_CURRENT;
728 }
729 break;
730
731 case 'dev':
732 $latest = $available['releases'][$project_data['latest_dev']];
733 if (empty($project_data['datestamp'])) {
734 $project_data['status'] = UPDATE_NOT_CHECKED;
735 $project_data['reason'] = t('Unknown release date');
736 }
737 elseif (($project_data['datestamp'] + 100 > $latest['date'])) {
738 $project_data['status'] = UPDATE_CURRENT;
739 }
740 else {
741 $project_data['status'] = UPDATE_NOT_CURRENT;
742 }
743 break;
744
745 default:
746 $project_data['status'] = UPDATE_UNKNOWN;
747 $project_data['reason'] = t('Invalid info');
748 }
749 }
750
779 function update_project_cache($cid) {
780 $projects = array();
781
782 // On certain paths, we should clear the cache and recompute the projects for
783 // update status of the site to avoid presenting stale information.
784 $q = $_GET['q'];
785 $paths = array(
786 'admin/modules',
787 'admin/modules/update',
788 'admin/appearance',
789 'admin/appearance/update',
790 'admin/reports',
791 'admin/reports/updates',
792 'admin/reports/updates/update',
793 'admin/reports/status',
794 'admin/reports/updates/check',
795 );
796 if (in_array($q, $paths)) {
797 _update_cache_clear($cid);
798 }
799 else {
800 $cache = _update_cache_get($cid);
801 if (!empty($cache->data) && $cache->expire > REQUEST_TIME) {
802 $projects = $cache->data;
803 }
804 }
805 return $projects;
806 }
807
819 function update_filter_project_info($info) {
820 $whitelist = array(
821 '_info_file_ctime',
822 'datestamp',
823 'major',
824 'name',
825 'package',
826 'project',
827 'project status url',
828 'version',
829 );
830 return array_intersect_key($info, drupal_map_assoc($whitelist));
831 }
_update_cache_get
_update_cache_get($cid)
Definition: update.module:799
update_filter_project_info
update_filter_project_info($info)
Definition: update.compare.inc:819
UPDATE_NOT_CURRENT
const UPDATE_NOT_CURRENT
Definition: update.module:39
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
_update_cache_clear
_update_cache_clear($cid=NULL, $wildcard=FALSE)
Definition: update.module:846
update_calculate_project_data
update_calculate_project_data($available)
Definition: update.compare.inc:335
$name
print $name
Definition: profile-listing.tpl.php:43
UPDATE_UNKNOWN
const UPDATE_UNKNOWN
Definition: update.module:54
UPDATE_REVOKED
const UPDATE_REVOKED
Definition: update.module:29
system_rebuild_theme_data
system_rebuild_theme_data()
Definition: system.module:2609
system_rebuild_module_data
system_rebuild_module_data()
Definition: system.module:2444
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
update_get_project_name
update_get_project_name($file)
Definition: update.compare.inc:249
$info
$info
Definition: color.inc:6
_update_cache_set
_update_cache_set($cid, $data, $expire)
Definition: update.module:769
UPDATE_NOT_CHECKED
const UPDATE_NOT_CHECKED
Definition: update.module:49
_update_process_info_list
_update_process_info_list(&$projects, $list, $project_type, $status)
Definition: update.compare.inc:106
update_project_cache
update_project_cache($cid)
Definition: update.compare.inc:779
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
UPDATE_CURRENT
const UPDATE_CURRENT
Definition: update.module:44
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
update_get_projects
update_get_projects()
Definition: update.compare.inc:56
UPDATE_NOT_FETCHED
const UPDATE_NOT_FETCHED
Definition: update.module:59
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
UPDATE_NOT_SUPPORTED
const UPDATE_NOT_SUPPORTED
Definition: update.module:34
update_calculate_project_update_status
update_calculate_project_update_status($project, &$project_data, $available)
Definition: update.compare.inc:427
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
update_process_project_info
update_process_project_info(&$projects)
Definition: update.compare.inc:270
UPDATE_NOT_SECURE
const UPDATE_NOT_SECURE
Definition: update.module:24
UPDATE_FETCH_PENDING
const UPDATE_FETCH_PENDING
Definition: update.module:64
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.pages.inc Source File

  • modules
  • aggregator
aggregator.pages.inc
Go to the documentation of this file.
1 <?php
2
14 function aggregator_page_last() {
15 drupal_add_feed('aggregator/rss', variable_get('site_name', 'Drupal') . ' ' . t('aggregator'));
16
17 $items = aggregator_feed_items_load('sum');
18
19 return _aggregator_page_list($items, arg(1));
20 }
21
33 function aggregator_page_source($feed) {
34 drupal_set_title($feed->title);
35 $feed_source = theme('aggregator_feed_source', array('feed' => $feed));
36
37 // It is safe to include the fid in the query because it's loaded from the
38 // database by aggregator_feed_load.
39 $items = aggregator_feed_items_load('source', $feed);
40
41 return _aggregator_page_list($items, arg(3), $feed_source);
42 }
43
55 function aggregator_page_source_form($form, $form_state, $feed) {
56 return aggregator_page_source($feed);
57 }
58
68 function aggregator_page_category($category) {
69 drupal_add_feed('aggregator/rss/' . $category['cid'], variable_get('site_name', 'Drupal') . ' ' . t('aggregator - @title', array('@title' => $category['title'])));
70
71 // It is safe to include the cid in the query because it's loaded from the
72 // database by aggregator_category_load.
73 $items = aggregator_feed_items_load('category', $category);
74
75 return _aggregator_page_list($items, arg(3));
76 }
77
89 function aggregator_page_category_form($form, $form_state, $category) {
90 return aggregator_page_category($category);
91 }
92
114 function aggregator_feed_items_load($type, $data = NULL) {
115 $items = array();
116 switch ($type) {
117 case 'sum':
118 $query = db_select('aggregator_item', 'i');
119 $query->join('aggregator_feed', 'f', 'i.fid = f.fid');
120 $query->fields('i');
121 $query->addField('f', 'title', 'ftitle');
122 $query->addField('f', 'link', 'flink');
123 break;
124 case 'source':
125 $query = db_select('aggregator_item', 'i');
126 $query
127 ->fields('i')
128 ->condition('i.fid', $data->fid);
129 break;
130 case 'category':
131 $query = db_select('aggregator_category_item', 'c');
132 $query->leftJoin('aggregator_item', 'i', 'c.iid = i.iid');
133 $query->leftJoin('aggregator_feed', 'f', 'i.fid = f.fid');
134 $query
135 ->fields('i')
136 ->condition('cid', $data['cid']);
137 $query->addField('f', 'title', 'ftitle');
138 $query->addField('f', 'link', 'flink');
139 break;
140 }
141
142 $result = $query
143 ->extend('PagerDefault')
144 ->limit(20)
145 ->orderBy('i.timestamp', 'DESC')
146 ->orderBy('i.iid', 'DESC')
147 ->execute();
148
149 foreach ($result as $item) {
150 $item->categories = db_query('SELECT c.title, c.cid FROM {aggregator_category_item} ci LEFT JOIN {aggregator_category} c ON ci.cid = c.cid WHERE ci.iid = :iid ORDER BY c.title', array(':iid' => $item->iid))->fetchAll();
151 $items[] = $item;
152 }
153
154 return $items;
155 }
156
173 function _aggregator_page_list($items, $op, $feed_source = '') {
174 if (user_access('administer news feeds') && ($op == 'categorize')) {
175 // Get form data.
176 $output = aggregator_categorize_items($items, $feed_source);
177 }
178 else {
179 // Assemble themed output.
180 $output = $feed_source;
181 foreach ($items as $item) {
182 $output .= theme('aggregator_item', array('item' => $item));
183 }
184 $output = theme('aggregator_wrapper', array('content' => $output));
185 }
186
187 return $output;
188 }
189
205 function aggregator_categorize_items($items, $feed_source = '') {
206 $form['#submit'][] = 'aggregator_categorize_items_submit';
207 $form['#theme'] = 'aggregator_categorize_items';
208 $form['feed_source'] = array(
209 '#value' => $feed_source,
210 );
211 $categories = array();
212 $done = FALSE;
213 $form['items'] = array();
214 $form['categories'] = array(
215 '#tree' => TRUE,
216 );
217 foreach ($items as $item) {
218 $form['items'][$item->iid] = array('#markup' => theme('aggregator_item', array('item' => $item)));
219 $form['categories'][$item->iid] = array();
220 $categories_result = db_query('SELECT c.cid, c.title, ci.iid FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid AND ci.iid = :iid', array(':iid' => $item->iid));
221 $selected = array();
222 foreach ($categories_result as $category) {
223 if (!$done) {
224 $categories[$category->cid] = check_plain($category->title);
225 }
226 if ($category->iid) {
227 $selected[] = $category->cid;
228 }
229 }
230 $done = TRUE;
231 $form['categories'][$item->iid] = array(
232 '#type' => variable_get('aggregator_category_selector', 'checkboxes'),
233 '#default_value' => $selected,
234 '#options' => $categories,
235 '#size' => 10,
236 '#multiple' => TRUE
237 );
238 }
239 $form['actions'] = array('#type' => 'actions');
240 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save categories'));
241
242 return $form;
243 }
244
248 function aggregator_categorize_items_submit($form, &$form_state) {
249 if (!empty($form_state['values']['categories'])) {
250 foreach ($form_state['values']['categories'] as $iid => $selection) {
251 db_delete('aggregator_category_item')
252 ->condition('iid', $iid)
253 ->execute();
254 $insert = db_insert('aggregator_category_item')->fields(array('iid', 'cid'));
255 $has_values = FALSE;
256 foreach ($selection as $cid) {
257 if ($cid && $iid) {
258 $has_values = TRUE;
259 $insert->values(array(
260 'iid' => $iid,
261 'cid' => $cid,
262 ));
263 }
264 }
265 if ($has_values) {
266 $insert->execute();
267 }
268 }
269 }
270 drupal_set_message(t('The categories have been saved.'));
271 }
272
282 function theme_aggregator_categorize_items($variables) {
283 $form = $variables['form'];
284
285 $output = drupal_render($form['feed_source']);
286 $rows = array();
287 if (!empty($form['items'])) {
288 foreach (element_children($form['items']) as $key) {
289 $rows[] = array(
290 drupal_render($form['items'][$key]),
291 array('data' => drupal_render($form['categories'][$key]), 'class' => array('categorize-item')),
292 );
293 }
294 }
295 $output .= theme('table', array('header' => array('', t('Categorize')), 'rows' => $rows));
296 $output .= drupal_render($form['submit']);
297 $output .= drupal_render_children($form);
298
299 return theme('aggregator_wrapper', array('content' => $output));
300 }
301
307 function template_preprocess_aggregator_wrapper(&$variables) {
308 $variables['pager'] = theme('pager');
309 }
310
316 function template_preprocess_aggregator_item(&$variables) {
317 $item = $variables['item'];
318
319 $variables['feed_url'] = check_url($item->link);
320 $variables['feed_title'] = check_plain($item->title);
321 $variables['content'] = aggregator_filter_xss($item->description);
322
323 $variables['source_url'] = '';
324 $variables['source_title'] = '';
325 if (isset($item->ftitle) && isset($item->fid)) {
326 $variables['source_url'] = url("aggregator/sources/$item->fid");
327 $variables['source_title'] = check_plain($item->ftitle);
328 }
329 if (date('Ymd', $item->timestamp) == date('Ymd')) {
330 $variables['source_date'] = t('%ago ago', array('%ago' => format_interval(REQUEST_TIME - $item->timestamp)));
331 }
332 else {
333 $variables['source_date'] = format_date($item->timestamp, 'custom', variable_get('date_format_medium', 'D, m/d/Y - H:i'));
334 }
335
336 $variables['categories'] = array();
337 foreach ($item->categories as $category) {
338 $variables['categories'][$category->cid] = l($category->title, 'aggregator/categories/' . $category->cid);
339 }
340 }
341
350 function aggregator_page_sources() {
351 $result = db_query('SELECT f.fid, f.title, f.description, f.image, MAX(i.timestamp) AS last FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.description, f.image ORDER BY last DESC, f.title');
352
353 $output = '';
354 foreach ($result as $feed) {
355 // Most recent items:
356 $summary_items = array();
357 if (variable_get('aggregator_summary_items', 3)) {
358 $items = db_query_range('SELECT i.title, i.timestamp, i.link FROM {aggregator_item} i WHERE i.fid = :fid ORDER BY i.timestamp DESC', 0, variable_get('aggregator_summary_items', 3), array(':fid' => $feed->fid));
359 foreach ($items as $item) {
360 $summary_items[] = theme('aggregator_summary_item', array('item' => $item));
361 }
362 }
363 $feed->url = url('aggregator/sources/' . $feed->fid);
364 $output .= theme('aggregator_summary_items', array('summary_items' => $summary_items, 'source' => $feed));
365 }
366 $output .= theme('feed_icon', array('url' => 'aggregator/opml', 'title' => t('OPML feed')));
367
368 return theme('aggregator_wrapper', array('content' => $output));
369 }
370
379 function aggregator_page_categories() {
380 $result = db_query('SELECT c.cid, c.title, c.description FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid LEFT JOIN {aggregator_item} i ON ci.iid = i.iid GROUP BY c.cid, c.title, c.description');
381
382 $output = '';
383 foreach ($result as $category) {
384 if (variable_get('aggregator_summary_items', 3)) {
385 $summary_items = array();
386 $items = db_query_range('SELECT i.title, i.timestamp, i.link, f.title as feed_title, f.link as feed_link FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON i.iid = ci.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE ci.cid = :cid ORDER BY i.timestamp DESC', 0, variable_get('aggregator_summary_items', 3), array(':cid' => $category->cid));
387 foreach ($items as $item) {
388 $summary_items[] = theme('aggregator_summary_item', array('item' => $item));
389 }
390 }
391 $category->url = url('aggregator/categories/' . $category->cid);
392 $output .= theme('aggregator_summary_items', array('summary_items' => $summary_items, 'source' => $category));
393 }
394
395 return theme('aggregator_wrapper', array('content' => $output));
396 }
397
404 function aggregator_page_rss() {
405 $result = NULL;
406 // arg(2) is the passed cid, only select for that category.
407 if (arg(2)) {
408 $category = db_query('SELECT cid, title FROM {aggregator_category} WHERE cid = :cid', array(':cid' => arg(2)))->fetchObject();
409 $result = db_query_range('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = :cid ORDER BY timestamp DESC, i.iid DESC', 0, variable_get('feed_default_items', 10), array(':cid' => $category->cid));
410 }
411 // Or, get the default aggregator items.
412 else {
413 $category = NULL;
414 $result = db_query_range('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC', 0, variable_get('feed_default_items', 10));
415 }
416
417 $feeds = $result->fetchAll();
418 return theme('aggregator_page_rss', array('feeds' => $feeds, 'category' => $category));
419 }
420
433 function theme_aggregator_page_rss($variables) {
434 $feeds = $variables['feeds'];
435 $category = $variables['category'];
436
437 drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
438
439 $items = '';
440 $feed_length = variable_get('feed_item_length', 'fulltext');
441 foreach ($feeds as $feed) {
442 switch ($feed_length) {
443 case 'teaser':
444 $summary = text_summary($feed->description, NULL, variable_get('aggregator_teaser_length', 600));
445 if ($summary != $feed->description) {
446 $summary .= '<p><a href="' . check_url($feed->link) . '">' . t('read more') . "</a></p>\n";
447 }
448 $feed->description = $summary;
449 break;
450 case 'title':
451 $feed->description = '';
452 break;
453 }
454 $items .= format_rss_item($feed->ftitle . ': ' . $feed->title, $feed->link, $feed->description, array('pubDate' => date('r', $feed->timestamp)));
455 }
456
457 $site_name = variable_get('site_name', 'Drupal');
458 $url = url((isset($category) ? 'aggregator/categories/' . $category->cid : 'aggregator'), array('absolute' => TRUE));
459 $description = isset($category) ? t('@site_name - aggregated feeds in category @title', array('@site_name' => $site_name, '@title' => $category->title)) : t('@site_name - aggregated feeds', array('@site_name' => $site_name));
460
461 $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
462 $output .= "<rss version=\"2.0\">\n";
463 $output .= format_rss_channel(t('@site_name aggregator', array('@site_name' => $site_name)), $url, $description, $items);
464 $output .= "</rss>\n";
465
466 print $output;
467 }
468
479 function aggregator_page_opml($cid = NULL) {
480 if ($cid) {
481 $result = db_query('SELECT f.title, f.url FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} c on f.fid = c.fid WHERE c.cid = :cid ORDER BY title', array(':cid' => $cid));
482 }
483 else {
484 $result = db_query('SELECT * FROM {aggregator_feed} ORDER BY title');
485 }
486
487 $feeds = $result->fetchAll();
488 return theme('aggregator_page_opml', array('feeds' => $feeds));
489 }
490
500 function theme_aggregator_page_opml($variables) {
501 $feeds = $variables['feeds'];
502
503 drupal_add_http_header('Content-Type', 'text/xml; charset=utf-8');
504
505 $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
506 $output .= "<opml version=\"1.1\">\n";
507 $output .= "<head>\n";
508 $output .= '<title>' . check_plain(variable_get('site_name', 'Drupal')) . "</title>\n";
509 $output .= '<dateModified>' . gmdate(DATE_RFC2822, REQUEST_TIME) . "</dateModified>\n";
510 $output .= "</head>\n";
511 $output .= "<body>\n";
512 foreach ($feeds as $feed) {
513 $output .= '<outline text="' . check_plain($feed->title) . '" xmlUrl="' . check_url($feed->url) . "\" />\n";
514 }
515 $output .= "</body>\n";
516 $output .= "</opml>\n";
517
518 print $output;
519 }
520
526 function template_preprocess_aggregator_summary_items(&$variables) {
527 $variables['title'] = check_plain($variables['source']->title);
528 $variables['summary_list'] = theme('item_list', array('items' => $variables['summary_items']));
529 $variables['source_url'] = $variables['source']->url;
530 }
531
537 function template_preprocess_aggregator_summary_item(&$variables) {
538 $item = $variables['item'];
539
540 $variables['feed_url'] = check_url($item->link);
541 $variables['feed_title'] = check_plain($item->title);
542 $variables['feed_age'] = t('%age old', array('%age' => format_interval(REQUEST_TIME - $item->timestamp)));
543
544 $variables['source_url'] = '';
545 $variables['source_title'] = '';
546 if (!empty($item->feed_link)) {
547 $variables['source_url'] = check_url($item->feed_link);
548 $variables['source_title'] = check_plain($item->feed_title);
549 }
550 }
551
557 function template_preprocess_aggregator_feed_source(&$variables) {
558 $feed = $variables['feed'];
559
560 $variables['source_icon'] = theme('feed_icon', array('url' => $feed->url, 'title' => t('!title feed', array('!title' => $feed->title))));
561
562 if (!empty($feed->image) && !empty($feed->title) && !empty($feed->link)) {
563 $variables['source_image'] = l(theme('image', array('path' => $feed->image, 'alt' => $feed->title)), $feed->link, array('html' => TRUE, 'attributes' => array('class' => 'feed-image')));
564 }
565 else {
566 $variables['source_image'] = '';
567 }
568
569 $variables['source_description'] = aggregator_filter_xss($feed->description);
570 $variables['source_url'] = check_url(url($feed->link, array('absolute' => TRUE)));
571
572 if ($feed->checked) {
573 $variables['last_checked'] = t('@time ago', array('@time' => format_interval(REQUEST_TIME - $feed->checked)));
574 }
575 else {
576 $variables['last_checked'] = t('never');
577 }
578
579 if (user_access('administer news feeds')) {
580 $variables['last_checked'] = l($variables['last_checked'], 'admin/config/services/aggregator');
581 }
582 }
aggregator_page_source
aggregator_page_source($feed)
Definition: aggregator.pages.inc:33
$op
$op
Definition: update.php:404
template_preprocess_aggregator_wrapper
template_preprocess_aggregator_wrapper(&$variables)
Definition: aggregator.pages.inc:307
format_rss_channel
format_rss_channel($title, $link, $description, $items, $langcode=NULL, $args=array())
Definition: common.inc:1685
l
l($text, $path, array $options=array())
Definition: common.inc:2432
template_preprocess_aggregator_item
template_preprocess_aggregator_item(&$variables)
Definition: aggregator.pages.inc:316
check_url
check_url($uri)
Definition: common.inc:1387
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
format_rss_item
format_rss_item($title, $link, $description, $args=array())
Definition: common.inc:1710
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
aggregator_page_rss
aggregator_page_rss()
Definition: aggregator.pages.inc:404
print
print
Definition: php-2.php:2
theme_aggregator_page_opml
theme_aggregator_page_opml($variables)
Definition: aggregator.pages.inc:500
template_preprocess_aggregator_summary_items
template_preprocess_aggregator_summary_items(&$variables)
Definition: aggregator.pages.inc:526
aggregator_page_category_form
aggregator_page_category_form($form, $form_state, $category)
Definition: aggregator.pages.inc:89
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
aggregator_categorize_items
aggregator_categorize_items($items, $feed_source= '')
Definition: aggregator.pages.inc:205
theme_aggregator_categorize_items
theme_aggregator_categorize_items($variables)
Definition: aggregator.pages.inc:282
theme_aggregator_page_rss
theme_aggregator_page_rss($variables)
Definition: aggregator.pages.inc:433
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$url
print $url
Definition: search-result.tpl.php:70
aggregator_page_source_form
aggregator_page_source_form($form, $form_state, $feed)
Definition: aggregator.pages.inc:55
text_summary
text_summary($text, $format=NULL, $size=NULL)
Definition: text.module:347
drupal_add_http_header
drupal_add_http_header($name, $value, $append=FALSE)
Definition: bootstrap.inc:1129
aggregator_categorize_items_submit
aggregator_categorize_items_submit($form, &$form_state)
Definition: aggregator.pages.inc:248
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
aggregator_page_sources
aggregator_page_sources()
Definition: aggregator.pages.inc:350
drupal_add_feed
drupal_add_feed($url=NULL, $title= '')
Definition: common.inc:368
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
aggregator_page_category
aggregator_page_category($category)
Definition: aggregator.pages.inc:68
aggregator_filter_xss
aggregator_filter_xss($value)
Definition: aggregator.module:734
template_preprocess_aggregator_summary_item
template_preprocess_aggregator_summary_item(&$variables)
Definition: aggregator.pages.inc:537
template_preprocess_aggregator_feed_source
template_preprocess_aggregator_feed_source(&$variables)
Definition: aggregator.pages.inc:557
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
aggregator_feed_items_load
aggregator_feed_items_load($type, $data=NULL)
Definition: aggregator.pages.inc:114
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
aggregator_page_last
aggregator_page_last()
Definition: aggregator.pages.inc:14
title
print $topic title
Definition: forum-topic-list.tpl.php:50
aggregator_page_categories
aggregator_page_categories()
Definition: aggregator.pages.inc:379
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
aggregator_page_opml
aggregator_page_opml($cid=NULL)
Definition: aggregator.pages.inc:479
$site_name
print $site_name
Definition: maintenance-page.tpl.php:40
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
_aggregator_page_list
_aggregator_page_list($items, $op, $feed_source= '')
Definition: aggregator.pages.inc:173
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/file/file.install Source File

  • modules
  • file
file.install
Go to the documentation of this file.
1 <?php
2
11 function file_field_schema($field) {
12 return array(
13 'columns' => array(
14 'fid' => array(
15 'description' => 'The {file_managed}.fid being referenced in this field.',
16 'type' => 'int',
17 'not null' => FALSE,
18 'unsigned' => TRUE,
19 ),
20 'display' => array(
21 'description' => 'Flag to control whether this file should be displayed when viewing content.',
22 'type' => 'int',
23 'size' => 'tiny',
24 'unsigned' => TRUE,
25 'not null' => TRUE,
26 'default' => 1,
27 ),
28 'description' => array(
29 'description' => 'A description of the file.',
30 'type' => 'text',
31 'not null' => FALSE,
32 ),
33 ),
34 'indexes' => array(
35 'fid' => array('fid'),
36 ),
37 'foreign keys' => array(
38 'fid' => array(
39 'table' => 'file_managed',
40 'columns' => array('fid' => 'fid'),
41 ),
42 ),
43 );
44 }
45
51 function file_requirements($phase) {
52 $requirements = array();
53
54 // Check the server's ability to indicate upload progress.
55 if ($phase == 'runtime') {
56 $implementation = file_progress_implementation();
57 $apache = strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== FALSE;
58 $fastcgi = strpos($_SERVER['SERVER_SOFTWARE'], 'mod_fastcgi') !== FALSE || strpos($_SERVER["SERVER_SOFTWARE"], 'mod_fcgi') !== FALSE;
59 $description = NULL;
60 if (!$apache) {
61 $value = t('Not enabled');
62 $description = t('Your server is not capable of displaying file upload progress. File upload progress requires an Apache server running PHP with mod_php.');
63 $severity = REQUIREMENT_INFO;
64 }
65 elseif ($fastcgi) {
66 $value = t('Not enabled');
67 $description = t('Your server is not capable of displaying file upload progress. File upload progress requires PHP be run with mod_php and not as FastCGI.');
68 $severity = REQUIREMENT_INFO;
69 }
70 elseif (!$implementation && extension_loaded('apc')) {
71 $value = t('Not enabled');
72 $description = t('Your server is capable of displaying file upload progress through APC, but it is not enabled. Add <code>apc.rfc1867 = 1</code> to your php.ini configuration. Alternatively, it is recommended to use <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>, which supports more than one simultaneous upload.');
73 $severity = REQUIREMENT_INFO;
74 }
75 elseif (!$implementation) {
76 $value = t('Not enabled');
77 $description = t('Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> (preferred) or to install <a href="http://us2.php.net/apc">APC</a>.');
78 $severity = REQUIREMENT_INFO;
79 }
80 elseif ($implementation == 'apc') {
81 $value = t('Enabled (<a href="http://php.net/manual/en/apc.configuration.php#ini.apc.rfc1867">APC RFC1867</a>)');
82 $description = t('Your server is capable of displaying file upload progress using APC RFC1867. Note that only one upload at a time is supported. It is recommended to use the <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> if possible.');
83 $severity = REQUIREMENT_OK;
84 }
85 elseif ($implementation == 'uploadprogress') {
86 $value = t('Enabled (<a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>)');
87 $severity = REQUIREMENT_OK;
88 }
89 $requirements['file_progress'] = array(
90 'title' => t('Upload progress'),
91 'value' => $value,
92 'severity' => $severity,
93 'description' => $description,
94 );
95 }
96
97 return $requirements;
98 }
file_requirements
file_requirements($phase)
Definition: file.install:51
file_progress_implementation
file_progress_implementation()
Definition: file.module:330
REQUIREMENT_OK
const REQUIREMENT_OK
Definition: install.inc:26
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
file_field_schema
file_field_schema($field)
Definition: file.install:11
$value
print $value
Definition: user-profile-item.tpl.php:26
REQUIREMENT_INFO
const REQUIREMENT_INFO
Definition: install.inc:21
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/filter/filter.pages.inc Source File

  • modules
  • filter
filter.pages.inc
Go to the documentation of this file.
1 <?php
2
17 function filter_tips_long() {
18 $format_id = arg(2);
19 if ($format_id) {
20 $output = theme('filter_tips', array('tips' => _filter_tips($format_id, TRUE), 'long' => TRUE));
21 }
22 else {
23 $output = theme('filter_tips', array('tips' => _filter_tips(-1, TRUE), 'long' => TRUE));
24 }
25 return $output;
26 }
27
54 function theme_filter_tips($variables) {
55 $tips = $variables['tips'];
56 $long = $variables['long'];
57 $output = '';
58
59 $multiple = count($tips) > 1;
60 if ($multiple) {
61 $output = '<h2>' . t('Text Formats') . '</h2>';
62 }
63
64 if (count($tips)) {
65 if ($multiple) {
66 $output .= '<div class="compose-tips">';
67 }
68 foreach ($tips as $name => $tiplist) {
69 if ($multiple) {
70 $output .= '<div class="filter-type filter-' . drupal_html_class($name) . '">';
71 $output .= '<h3>' . $name . '</h3>';
72 }
73
74 if (count($tiplist) > 0) {
75 $output .= '<ul class="tips">';
76 foreach ($tiplist as $tip) {
77 $output .= '<li' . ($long ? ' id="filter-' . str_replace("/", "-", $tip['id']) . '">' : '>') . $tip['tip'] . '</li>';
78 }
79 $output .= '</ul>';
80 }
81
82 if ($multiple) {
83 $output .= '</div>';
84 }
85 }
86 if ($multiple) {
87 $output .= '</div>';
88 }
89 }
90
91 return $output;
92 }
_filter_tips
_filter_tips($format_id, $long=FALSE)
Definition: filter.module:1054
$name
print $name
Definition: profile-listing.tpl.php:43
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$output
$output
Definition: authorize.php:93
filter_tips_long
filter_tips_long()
Definition: filter.pages.inc:17
theme_filter_tips
theme_filter_tips($variables)
Definition: filter.pages.inc:54
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
drupal_html_class
drupal_html_class($class)
Definition: common.inc:3841
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/tabledrag_example/tabledrag_example_simple_form.inc Source File

  • examples
  • tabledrag_example
tabledrag_example_simple_form.inc
Go to the documentation of this file.
1 <?php
15 function tabledrag_example_simple_form($form_state) {
16 // Identify that the elements in 'example_items' are a collection, to
17 // prevent Form API from flattening the array when submitted.
18 $form['example_items']['#tree'] = TRUE;
19
20 // Fetch the example data from the database, ordered by weight ascending.
21 //
22 // This query excludes the last two tabledrag_example database rows, as
23 // they are intended only for the 'parent/child' tabledrag examples.
24 $result = db_query('SELECT id, name, description, weight FROM {tabledrag_example} WHERE id < 8 ORDER BY weight ASC');
25
26 // Iterate through each database result.
27 foreach ($result as $item) {
28
29 // Create a form entry for this item.
30 //
31 // Each entry will be an array using the the unique id for that item as
32 // the array key, and an array of table row data as the value.
33 $form['example_items'][$item->id] = array(
34
35 // We'll use a form element of type '#markup' to display the item name.
36 'name' => array(
37 '#markup' => check_plain($item->name),
38 ),
39
40 // We'll use a form element of type '#textfield' to display the item
41 // description, which will allow the value to be changed via the form.
42 // We limit the input to 255 characters, which is the limit we set on
43 // the database field.
44 'description' => array(
45 '#type' => 'textfield',
46 '#default_value' => check_plain($item->description),
47 '#size' => 20,
48 '#maxlength' => 255,
49 ),
50
51 // The 'weight' field will be manipulated as we move the items around in
52 // the table using the tabledrag activity. We use the 'weight' element
53 // defined in Drupal's Form API.
54 'weight' => array(
55 '#type' => 'weight',
56 '#title' => t('Weight'),
57 '#default_value' => $item->weight,
58 '#delta' => 10,
59 '#title_display' => 'invisible',
60 ),
61 );
62 }
63
64 // Now we add our submit button, for submitting the form results.
65 //
66 // The 'actions' wrapper used here isn't strictly necessary for tabledrag,
67 // but is included as a Form API recommended practice.
68 $form['actions'] = array('#type' => 'actions');
69 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save Changes'));
70 return $form;
71 }
72
87 function theme_tabledrag_example_simple_form($variables) {
88 $form = $variables['form'];
89
90 // Initialize the variable which will store our table rows.
91 $rows = array();
92
93 // Iterate over each element in our $form['example_items'] array.
94 foreach (element_children($form['example_items']) as $id) {
95
96 // Before we add our 'weight' column to the row, we need to give the
97 // element a custom class so that it can be identified in the
98 // drupal_add_tabledrag call.
99 //
100 // This could also have been done during the form declaration by adding
101 // '#attributes' => array('class' => 'example-item-weight'),
102 // directy to the 'weight' element in tabledrag_example_simple_form().
103 $form['example_items'][$id]['weight']['#attributes']['class'] = array('example-item-weight');
104
105 // We are now ready to add each element of our $form data to the $rows
106 // array, so that they end up as individual table cells when rendered
107 // in the final table. We run each element through the drupal_render()
108 // function to generate the final html markup for that element.
109 $rows[] = array(
110 'data' => array(
111 // Add our 'name' column.
112 drupal_render($form['example_items'][$id]['name']),
113 // Add our 'description' column.
114 drupal_render($form['example_items'][$id]['description']),
115 // Add our 'weight' column.
116 drupal_render($form['example_items'][$id]['weight']),
117 ),
118 // To support the tabledrag behaviour, we need to assign each row of the
119 // table a class attribute of 'draggable'. This will add the 'draggable'
120 // class to the <tr> element for that row when the final table is
121 // rendered.
122 'class' => array('draggable'),
123 );
124 }
125
126 // We now define the table header values. Ensure that the 'header' count
127 // matches the final column count for your table.
128 $header = array(t('Name'), t('Description'), t('Weight'));
129
130 // We also need to pass the drupal_add_tabledrag() function an id which will
131 // be used to identify the <table> element containing our tabledrag form.
132 // Because an element's 'id' should be unique on a page, make sure the value
133 // you select is NOT the same as the form ID used in your form declaration.
134 $table_id = 'example-items-table';
135
136 // We can render our tabledrag table for output.
137 $output = theme('table', array(
138 'header' => $header,
139 'rows' => $rows,
140 'attributes' => array('id' => $table_id),
141 ));
142
143 // And then render any remaining form elements (such as our submit button).
144 $output .= drupal_render_children($form);
145
146 // We now call the drupal_add_tabledrag() function in order to add the
147 // tabledrag.js goodness onto our page.
148 //
149 // For a basic sortable table, we need to pass it:
150 // - the $table_id of our <table> element,
151 // - the $action to be performed on our form items ('order'),
152 // - a string describing where $action should be applied ('siblings'),
153 // - and the class of the element containing our 'weight' element.
154 drupal_add_tabledrag($table_id, 'order', 'sibling', 'example-item-weight');
155
156 return $output;
157 }
158
168 function tabledrag_example_simple_form_submit($form, &$form_state) {
169 // Because the form elements were keyed with the item ids from the database,
170 // we can simply iterate through the submitted values.
171 foreach ($form_state['values']['example_items'] as $id => $item) {
172 db_query(
173 "UPDATE {tabledrag_example} SET weight = :weight WHERE id = :id",
174 array(':weight' => $item['weight'], ':id' => $id)
175 );
176 }
177 }
$header
print $header
Definition: forum-topic-list.tpl.php:42
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
tabledrag_example_simple_form_submit
tabledrag_example_simple_form_submit($form, &$form_state)
Definition: tabledrag_example_simple_form.inc:168
$output
$output
Definition: authorize.php:93
tabledrag_example_simple_form
tabledrag_example_simple_form($form_state)
Definition: tabledrag_example_simple_form.inc:15
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
theme_tabledrag_example_simple_form
theme_tabledrag_example_simple_form($variables)
Definition: tabledrag_example_simple_form.inc:87
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DatabaseTasks_pgsql Member List

This is the complete list of members for DatabaseTasks_pgsql, including all inherited members.

$pdoDriver | DatabaseTasks_pgsql | protected
$results | DatabaseTasks | protected
$tasks | DatabaseTasks | protected
__construct() | DatabaseTasks_pgsql |
checkBinaryOutput() | DatabaseTasks_pgsql |
checkBinaryOutputSuccess() | DatabaseTasks_pgsql | protected
checkEncoding() | DatabaseTasks_pgsql | protected
checkEngineVersion() | DatabaseTasks | protected
checkPHPVersion() | DatabaseTasks_pgsql |
connect() | DatabaseTasks | protected
fail($message) | DatabaseTasks | protected
getFormOptions($database) | DatabaseTasks |
hasPdoDriver() | DatabaseTasks | protected
initializeDatabase() | DatabaseTasks_pgsql |
installable() | DatabaseTasks |
minimumVersion() | DatabaseTasks_pgsql |
name() | DatabaseTasks_pgsql |
pass($message) | DatabaseTasks | protected
runTasks() | DatabaseTasks |
runTestQuery($query, $pass, $fail, $fatal=FALSE) | DatabaseTasks | protected
validateDatabaseSettings($database) | DatabaseTasks |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/errors.inc Source File

  • includes
errors.inc
Go to the documentation of this file.
1 <?php
2
16 function drupal_error_levels() {
17 $types = array(
18 E_ERROR => array('Error', WATCHDOG_ERROR),
19 E_WARNING => array('Warning', WATCHDOG_WARNING),
20 E_PARSE => array('Parse error', WATCHDOG_ERROR),
21 E_NOTICE => array('Notice', WATCHDOG_NOTICE),
22 E_CORE_ERROR => array('Core error', WATCHDOG_ERROR),
23 E_CORE_WARNING => array('Core warning', WATCHDOG_WARNING),
24 E_COMPILE_ERROR => array('Compile error', WATCHDOG_ERROR),
25 E_COMPILE_WARNING => array('Compile warning', WATCHDOG_WARNING),
26 E_USER_ERROR => array('User error', WATCHDOG_ERROR),
27 E_USER_WARNING => array('User warning', WATCHDOG_WARNING),
28 E_USER_NOTICE => array('User notice', WATCHDOG_NOTICE),
29 E_STRICT => array('Strict warning', WATCHDOG_DEBUG),
30 E_RECOVERABLE_ERROR => array('Recoverable fatal error', WATCHDOG_ERROR),
31 );
32 // E_DEPRECATED and E_USER_DEPRECATED were added in PHP 5.3.0.
33 if (defined('E_DEPRECATED')) {
34 $types[E_DEPRECATED] = array('Deprecated function', WATCHDOG_DEBUG);
35 $types[E_USER_DEPRECATED] = array('User deprecated function', WATCHDOG_DEBUG);
36 }
37 return $types;
38 }
39
55 function _drupal_error_handler_real($error_level, $message, $filename, $line, $context) {
56 if ($error_level & error_reporting()) {
57 $types = drupal_error_levels();
58 list($severity_msg, $severity_level) = $types[$error_level];
59 $caller = _drupal_get_last_caller(debug_backtrace());
60
61 if (!function_exists('filter_xss_admin')) {
62 require_once DRUPAL_ROOT . '/includes/common.inc';
63 }
64
65 // We treat recoverable errors as fatal.
66 _drupal_log_error(array(
67 '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error',
68 // The standard PHP error handler considers that the error messages
69 // are HTML. We mimick this behavior here.
70 '!message' => filter_xss_admin($message),
71 '%function' => $caller['function'],
72 '%file' => $caller['file'],
73 '%line' => $caller['line'],
74 'severity_level' => $severity_level,
75 ), $error_level == E_RECOVERABLE_ERROR);
76 }
77 }
78
88 function _drupal_decode_exception($exception) {
89 $message = $exception->getMessage();
90
91 $backtrace = $exception->getTrace();
92 // Add the line throwing the exception to the backtrace.
93 array_unshift($backtrace, array('line' => $exception->getLine(), 'file' => $exception->getFile()));
94
95 // For PDOException errors, we try to return the initial caller,
96 // skipping internal functions of the database layer.
97 if ($exception instanceof PDOException) {
98 // The first element in the stack is the call, the second element gives us the caller.
99 // We skip calls that occurred in one of the classes of the database layer
100 // or in one of its global functions.
101 $db_functions = array('db_query', 'db_query_range');
102 while (!empty($backtrace[1]) && ($caller = $backtrace[1]) &&
103 ((isset($caller['class']) && (strpos($caller['class'], 'Query') !== FALSE || strpos($caller['class'], 'Database') !== FALSE || strpos($caller['class'], 'PDO') !== FALSE)) ||
104 in_array($caller['function'], $db_functions))) {
105 // We remove that call.
106 array_shift($backtrace);
107 }
108 if (isset($exception->query_string, $exception->args)) {
109 $message .= ": " . $exception->query_string . "; " . print_r($exception->args, TRUE);
110 }
111 }
112 $caller = _drupal_get_last_caller($backtrace);
113
114 return array(
115 '%type' => get_class($exception),
116 // The standard PHP exception handler considers that the exception message
117 // is plain-text. We mimick this behavior here.
118 '!message' => check_plain($message),
119 '%function' => $caller['function'],
120 '%file' => $caller['file'],
121 '%line' => $caller['line'],
122 'severity_level' => WATCHDOG_ERROR,
123 );
124 }
125
134 function _drupal_render_exception_safe($exception) {
135 return check_plain(strtr('%type: !message in %function (line %line of %file).', _drupal_decode_exception($exception)));
136 }
137
151 function error_displayable($error = NULL) {
152 $error_level = variable_get('error_level', ERROR_REPORTING_DISPLAY_ALL);
153 $updating = (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update');
154 $all_errors_displayed = ($error_level == ERROR_REPORTING_DISPLAY_ALL);
155 $error_needs_display = ($error_level == ERROR_REPORTING_DISPLAY_SOME &&
156 isset($error) && $error['%type'] != 'Notice' && $error['%type'] != 'Strict warning');
157
158 return ($updating || $all_errors_displayed || $error_needs_display);
159 }
160
171 function _drupal_log_error($error, $fatal = FALSE) {
172 // Initialize a maintenance theme if the bootstrap was not complete.
173 // Do it early because drupal_set_message() triggers a drupal_theme_initialize().
174 if ($fatal && (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL)) {
175 unset($GLOBALS['theme']);
176 if (!defined('MAINTENANCE_MODE')) {
177 define('MAINTENANCE_MODE', 'error');
178 }
179 drupal_maintenance_theme();
180 }
181
182 // When running inside the testing framework, we relay the errors
183 // to the tested site by the way of HTTP headers.
184 $test_info = &$GLOBALS['drupal_test_info'];
185 if (!empty($test_info['in_child_site']) && !headers_sent() && (!defined('SIMPLETEST_COLLECT_ERRORS') || SIMPLETEST_COLLECT_ERRORS)) {
186 // $number does not use drupal_static as it should not be reset
187 // as it uniquely identifies each PHP error.
188 static $number = 0;
189 $assertion = array(
190 $error['!message'],
191 $error['%type'],
192 array(
193 'function' => $error['%function'],
194 'file' => $error['%file'],
195 'line' => $error['%line'],
196 ),
197 );
198 header('X-Drupal-Assertion-' . $number . ': ' . rawurlencode(serialize($assertion)));
199 $number++;
200 }
201
202 watchdog('php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);
203
204 if ($fatal) {
205 drupal_add_http_header('Status', '500 Service unavailable (with message)');
206 }
207
208 if (drupal_is_cli()) {
209 if ($fatal) {
210 // When called from CLI, simply output a plain text message.
211 print html_entity_decode(strip_tags(t('%type: !message in %function (line %line of %file).', $error))). "\n";
212 exit;
213 }
214 }
215
216 if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
217 if ($fatal) {
218 if (error_displayable($error)) {
219 // When called from JavaScript, simply output the error message.
220 print t('%type: !message in %function (line %line of %file).', $error);
221 }
222 exit;
223 }
224 }
225 else {
226 // Display the message if the current error reporting level allows this type
227 // of message to be displayed, and unconditionnaly in update.php.
228 if (error_displayable($error)) {
229 $class = 'error';
230
231 // If error type is 'User notice' then treat it as debug information
232 // instead of an error message, see dd().
233 if ($error['%type'] == 'User notice') {
234 $error['%type'] = 'Debug';
235 $class = 'status';
236 }
237
238 drupal_set_message(t('%type: !message in %function (line %line of %file).', $error), $class);
239 }
240
241 if ($fatal) {
242 drupal_set_title(t('Error'));
243 // We fallback to a maintenance page at this point, because the page generation
244 // itself can generate errors.
245 print theme('maintenance_page', array('content' => t('The website encountered an unexpected error. Please try again later.')));
246 exit;
247 }
248 }
249 }
250
260 function _drupal_get_last_caller($backtrace) {
261 // Errors that occur inside PHP internal functions do not generate
262 // information about file and line. Ignore black listed functions.
263 $blacklist = array('debug', '_drupal_error_handler', '_drupal_exception_handler');
264 while (($backtrace && !isset($backtrace[0]['line'])) ||
265 (isset($backtrace[1]['function']) && in_array($backtrace[1]['function'], $blacklist))) {
266 array_shift($backtrace);
267 }
268
269 // The first trace is the call itself.
270 // It gives us the line and the file of the last call.
271 $call = $backtrace[0];
272
273 // The second call give us the function where the call originated.
274 if (isset($backtrace[1])) {
275 if (isset($backtrace[1]['class'])) {
276 $call['function'] = $backtrace[1]['class'] . $backtrace[1]['type'] . $backtrace[1]['function'] . '()';
277 }
278 else {
279 $call['function'] = $backtrace[1]['function'] . '()';
280 }
281 }
282 else {
283 $call['function'] = 'main()';
284 }
285 return $call;
286 }
_drupal_log_error
_drupal_log_error($error, $fatal=FALSE)
Definition: errors.inc:171
drupal_get_bootstrap_phase
drupal_get_bootstrap_phase()
Definition: bootstrap.inc:2503
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
_drupal_render_exception_safe
_drupal_render_exception_safe($exception)
Definition: errors.inc:134
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
ERROR_REPORTING_DISPLAY_SOME
const ERROR_REPORTING_DISPLAY_SOME
Definition: bootstrap.inc:36
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
drupal_add_http_header
drupal_add_http_header($name, $value, $append=FALSE)
Definition: bootstrap.inc:1129
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
_drupal_error_handler_real
_drupal_error_handler_real($error_level, $message, $filename, $line, $context)
Definition: errors.inc:55
WATCHDOG_DEBUG
const WATCHDOG_DEBUG
Definition: bootstrap.inc:113
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
_drupal_decode_exception
_drupal_decode_exception($exception)
Definition: errors.inc:88
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
drupal_maintenance_theme
drupal_maintenance_theme()
Definition: bootstrap.inc:2569
error_displayable
error_displayable($error=NULL)
Definition: errors.inc:151
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
drupal_is_cli
drupal_is_cli()
Definition: bootstrap.inc:3381
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
_drupal_get_last_caller
_drupal_get_last_caller($backtrace)
Definition: errors.inc:260
ERROR_REPORTING_DISPLAY_ALL
const ERROR_REPORTING_DISPLAY_ALL
Definition: bootstrap.inc:41
drupal_error_levels
drupal_error_levels()
Definition: errors.inc:16
MAINTENANCE_MODE
const MAINTENANCE_MODE
Definition: authorize.php:36
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
DRUPAL_BOOTSTRAP_FULL
const DRUPAL_BOOTSTRAP_FULL
Definition: bootstrap.inc:157
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/openid/openid.api.php Source File

  • modules
  • openid
openid.api.php
Go to the documentation of this file.
1 <?php
2
26 function hook_openid($op, $request) {
27 if ($op == 'request') {
28 $request['openid.identity'] = 'http://myname.myopenid.com/';
29 }
30 return $request;
31 }
32
42 function hook_openid_response($response, $account) {
43 if (isset($response['openid.ns.ax'])) {
44 _mymodule_store_ax_fields($response, $account);
45 }
46 }
47
69 function hook_openid_discovery_method_info() {
70 return array(
71 'new_discovery_idea' => '_my_discovery_method',
72 );
73 }
74
78 function hook_openid_discovery_method_info_alter(&$methods) {
79 // Remove XRI discovery scheme.
80 unset($methods['xri']);
81 }
82
100 function hook_openid_normalization_method_info() {
101 return array(
102 'new_normalization_idea' => '_my_normalization_method',
103 );
104 }
105
109 function hook_openid_normalization_method_info_alter(&$methods) {
110 // Remove Google IDP normalization.
111 unset($methods['google_idp']);
112 }
113
$op
$op
Definition: update.php:404
hook_openid_response
hook_openid_response($response, $account)
Definition: openid.api.php:42
hook_openid_normalization_method_info_alter
hook_openid_normalization_method_info_alter(&$methods)
Definition: openid.api.php:109
hook_openid_discovery_method_info_alter
hook_openid_discovery_method_info_alter(&$methods)
Definition: openid.api.php:78
hook_openid_discovery_method_info
hook_openid_discovery_method_info()
Definition: openid.api.php:69
hook_openid
hook_openid($op, $request)
Definition: openid.api.php:26
hook_openid_normalization_method_info
hook_openid_normalization_method_info()
Definition: openid.api.php:100
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/number/number.install Source File

  • modules
  • field
  • modules
  • number
number.install
Go to the documentation of this file.
1 <?php
2
11 function number_field_schema($field) {
12 switch ($field['type']) {
13 case 'number_integer' :
14 $columns = array(
15 'value' => array(
16 'type' => 'int',
17 'not null' => FALSE
18 ),
19 );
20 break;
21
22 case 'number_float' :
23 $columns = array(
24 'value' => array(
25 'type' => 'float',
26 'not null' => FALSE
27 ),
28 );
29 break;
30
31 case 'number_decimal' :
32 $columns = array(
33 'value' => array(
34 'type' => 'numeric',
35 'precision' => $field['settings']['precision'],
36 'scale' => $field['settings']['scale'],
37 'not null' => FALSE
38 ),
39 );
40 break;
41 }
42 return array(
43 'columns' => $columns,
44 );
45 }
number_field_schema
number_field_schema($field)
Definition: number.install:11
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: sites/example.sites.php Source File

  • sites
example.sites.php
Go to the documentation of this file.
1 <?php
2
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/shortcut/shortcut.install Source File

  • modules
  • shortcut
shortcut.install
Go to the documentation of this file.
1 <?php
2
11 function shortcut_install() {
12 $t = get_t();
13 // Create an initial default shortcut set.
14 $shortcut_set = new stdClass();
15 $shortcut_set->title = $t('Default');
16 $shortcut_set->links = array(
17 array(
18 'link_path' => 'node/add',
19 'link_title' => $t('Add content'),
20 'weight' => -20,
21 ),
22 array(
23 'link_path' => 'admin/content',
24 'link_title' => $t('Find content'),
25 'weight' => -19,
26 ),
27 );
28 // If Drupal is being installed, rebuild the menu before saving the shortcut
29 // set, to make sure the links defined above can be correctly saved. (During
30 // installation, the menu might not have been built at all yet, or it might
31 // have been built but without the node module's links in it.)
32 if (drupal_installation_attempted()) {
33 menu_rebuild();
34 }
35 shortcut_set_save($shortcut_set);
36 }
37
41 function shortcut_uninstall() {
42 drupal_load('module', 'shortcut');
43 // Delete the menu links associated with each shortcut set.
44 foreach (shortcut_sets() as $shortcut_set) {
45 menu_delete_links($shortcut_set->set_name);
46 }
47 }
48
52 function shortcut_schema() {
53 $schema['shortcut_set'] = array(
54 'description' => 'Stores information about sets of shortcuts links.',
55 'fields' => array(
56 'set_name' => array(
57 'type' => 'varchar',
58 'length' => 32,
59 'not null' => TRUE,
60 'default' => '',
61 'description' => "Primary Key: The {menu_links}.menu_name under which the set's links are stored.",
62 ),
63 'title' => array(
64 'type' => 'varchar',
65 'length' => 255,
66 'not null' => TRUE,
67 'default' => '',
68 'description' => 'The title of the set.',
69 ),
70 ),
71 'primary key' => array('set_name'),
72 'foreign keys' => array(
73 'menu_name' => array(
74 'table' => 'menu_links',
75 'columns' => array('set_name' => 'menu_name'),
76 ),
77 ),
78 );
79
80 $schema['shortcut_set_users'] = array(
81 'description' => 'Maps users to shortcut sets.',
82 'fields' => array(
83 'uid' => array(
84 'type' => 'int',
85 'unsigned' => TRUE,
86 'not null' => TRUE,
87 'default' => 0,
88 'description' => 'The {users}.uid for this set.',
89 ),
90 'set_name' => array(
91 'type' => 'varchar',
92 'length' => 32,
93 'not null' => TRUE,
94 'default' => '',
95 'description' => "The {shortcut_set}.set_name that will be displayed for this user.",
96 ),
97 ),
98 'primary key' => array('uid'),
99 'indexes' => array(
100 'set_name' => array('set_name'),
101 ),
102 'foreign keys' => array(
103 'set_user' => array(
104 'table' => 'users',
105 'columns' => array('uid' => 'uid'),
106 ),
107 'set_name' => array(
108 'table' => 'shortcut_set',
109 'columns' => array('set_name' => 'set_name'),
110 ),
111 ),
112 );
113
114 return $schema;
115 }
shortcut_install
shortcut_install()
Definition: shortcut.install:11
menu_delete_links
menu_delete_links($menu_name)
Definition: menu.inc:2976
drupal_installation_attempted
drupal_installation_attempted()
Definition: bootstrap.inc:2605
menu_rebuild
menu_rebuild()
Definition: menu.inc:2709
get_t
get_t()
Definition: bootstrap.inc:2635
shortcut_schema
shortcut_schema()
Definition: shortcut.install:52
shortcut_sets
shortcut_sets()
Definition: shortcut.module:583
shortcut_set_save
shortcut_set_save(&$shortcut_set)
Definition: shortcut.module:351
drupal_load
drupal_load($type, $name)
Definition: bootstrap.inc:1093
shortcut_uninstall
shortcut_uninstall()
Definition: shortcut.install:41
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment.admin.inc Source File

  • modules
  • comment
comment.admin.inc
Go to the documentation of this file.
1 <?php
2
11 function comment_admin($type = 'new') {
12 $edit = $_POST;
13
14 if (isset($edit['operation']) && ($edit['operation'] == 'delete') && isset($edit['comments']) && $edit['comments']) {
15 return drupal_get_form('comment_multiple_delete_confirm');
16 }
17 else {
18 return drupal_get_form('comment_admin_overview', $type);
19 }
20 }
21
34 function comment_admin_overview($form, &$form_state, $arg) {
35 // Build an 'Update options' form.
36 $form['options'] = array(
37 '#type' => 'fieldset',
38 '#title' => t('Update options'),
39 '#attributes' => array('class' => array('container-inline')),
40 );
41
42 if ($arg == 'approval') {
43 $options['publish'] = t('Publish the selected comments');
44 }
45 else {
46 $options['unpublish'] = t('Unpublish the selected comments');
47 }
48 $options['delete'] = t('Delete the selected comments');
49
50 $form['options']['operation'] = array(
51 '#type' => 'select',
52 '#title' => t('Operation'),
53 '#title_display' => 'invisible',
54 '#options' => $options,
55 '#default_value' => 'publish',
56 );
57 $form['options']['submit'] = array(
58 '#type' => 'submit',
59 '#value' => t('Update'),
60 );
61
62 // Load the comments that need to be displayed.
63 $status = ($arg == 'approval') ? COMMENT_NOT_PUBLISHED : COMMENT_PUBLISHED;
64 $header = array(
65 'subject' => array('data' => t('Subject'), 'field' => 'subject'),
66 'author' => array('data' => t('Author'), 'field' => 'name'),
67 'posted_in' => array('data' => t('Posted in'), 'field' => 'node_title'),
68 'changed' => array('data' => t('Updated'), 'field' => 'c.changed', 'sort' => 'desc'),
69 'operations' => array('data' => t('Operations')),
70 );
71
72 $query = db_select('comment', 'c')->extend('PagerDefault')->extend('TableSort');
73 $query->join('node', 'n', 'n.nid = c.nid');
74 $query->addField('n', 'title', 'node_title');
75 $query->addTag('node_access');
76 $result = $query
77 ->fields('c', array('cid', 'subject', 'name', 'changed'))
78 ->condition('c.status', $status)
79 ->limit(50)
80 ->orderByHeader($header)
81 ->execute();
82
83 $cids = array();
84
85 // We collect a sorted list of node_titles during the query to attach to the
86 // comments later.
87 foreach ($result as $row) {
88 $cids[] = $row->cid;
89 $node_titles[] = $row->node_title;
90 }
91 $comments = comment_load_multiple($cids);
92
93 // Build a table listing the appropriate comments.
94 $options = array();
95 $destination = drupal_get_destination();
96
97 foreach ($comments as $comment) {
98 // Remove the first node title from the node_titles array and attach to
99 // the comment.
100 $comment->node_title = array_shift($node_titles);
101 $comment_body = field_get_items('comment', $comment, 'comment_body');
102 $options[$comment->cid] = array(
103 'subject' => array(
104 'data' => array(
105 '#type' => 'link',
106 '#title' => $comment->subject,
107 '#href' => 'comment/' . $comment->cid,
108 '#options' => array('attributes' => array('title' => truncate_utf8($comment_body[0]['value'], 128)), 'fragment' => 'comment-' . $comment->cid),
109 ),
110 ),
111 'author' => theme('username', array('account' => $comment)),
112 'posted_in' => array(
113 'data' => array(
114 '#type' => 'link',
115 '#title' => $comment->node_title,
116 '#href' => 'node/' . $comment->nid,
117 ),
118 ),
119 'changed' => format_date($comment->changed, 'short'),
120 'operations' => array(
121 'data' => array(
122 '#type' => 'link',
123 '#title' => t('edit'),
124 '#href' => 'comment/' . $comment->cid . '/edit',
125 '#options' => array('query' => $destination),
126 ),
127 ),
128 );
129 }
130
131 $form['comments'] = array(
132 '#type' => 'tableselect',
133 '#header' => $header,
134 '#options' => $options,
135 '#empty' => t('No comments available.'),
136 );
137
138 $form['pager'] = array('#theme' => 'pager');
139
140 return $form;
141 }
142
146 function comment_admin_overview_validate($form, &$form_state) {
147 $form_state['values']['comments'] = array_diff($form_state['values']['comments'], array(0));
148 // We can't execute any 'Update options' if no comments were selected.
149 if (count($form_state['values']['comments']) == 0) {
150 form_set_error('', t('Select one or more comments to perform the update on.'));
151 }
152 }
153
160 function comment_admin_overview_submit($form, &$form_state) {
161 $operation = $form_state['values']['operation'];
162 $cids = $form_state['values']['comments'];
163
164 if ($operation == 'delete') {
165 comment_delete_multiple($cids);
166 }
167 else {
168 foreach ($cids as $cid => $value) {
169 $comment = comment_load($value);
170
171 if ($operation == 'unpublish') {
172 $comment->status = COMMENT_NOT_PUBLISHED;
173 }
174 elseif ($operation == 'publish') {
175 $comment->status = COMMENT_PUBLISHED;
176 }
177 comment_save($comment);
178 }
179 }
180 drupal_set_message(t('The update has been performed.'));
181 $form_state['redirect'] = 'admin/content/comment';
182 cache_clear_all();
183 }
184
195 function comment_multiple_delete_confirm($form, &$form_state) {
196 $edit = $form_state['input'];
197
198 $form['comments'] = array(
199 '#prefix' => '<ul>',
200 '#suffix' => '</ul>',
201 '#tree' => TRUE,
202 );
203 // array_filter() returns only elements with actual values.
204 $comment_counter = 0;
205 foreach (array_filter($edit['comments']) as $cid => $value) {
206 $comment = comment_load($cid);
207 if (is_object($comment) && is_numeric($comment->cid)) {
208 $subject = db_query('SELECT subject FROM {comment} WHERE cid = :cid', array(':cid' => $cid))->fetchField();
209 $form['comments'][$cid] = array('#type' => 'hidden', '#value' => $cid, '#prefix' => '<li>', '#suffix' => check_plain($subject) . '</li>');
210 $comment_counter++;
211 }
212 }
213 $form['operation'] = array('#type' => 'hidden', '#value' => 'delete');
214
215 if (!$comment_counter) {
216 drupal_set_message(t('There do not appear to be any comments to delete, or your selected comment was deleted by another administrator.'));
217 drupal_goto('admin/content/comment');
218 }
219 else {
220 return confirm_form($form,
221 t('Are you sure you want to delete these comments and all their children?'),
222 'admin/content/comment', t('This action cannot be undone.'),
223 t('Delete comments'), t('Cancel'));
224 }
225 }
226
230 function comment_multiple_delete_confirm_submit($form, &$form_state) {
231 if ($form_state['values']['confirm']) {
232 comment_delete_multiple(array_keys($form_state['values']['comments']));
233 cache_clear_all();
234 $count = count($form_state['values']['comments']);
235 watchdog('content', 'Deleted @count comments.', array('@count' => $count));
236 drupal_set_message(format_plural($count, 'Deleted 1 comment.', 'Deleted @count comments.'));
237 }
238 $form_state['redirect'] = 'admin/content/comment';
239 }
240
244 function comment_confirm_delete_page($cid) {
245 if ($comment = comment_load($cid)) {
246 return drupal_get_form('comment_confirm_delete', $comment);
247 }
248 return MENU_NOT_FOUND;
249 }
250
257 function comment_confirm_delete($form, &$form_state, $comment) {
258 $form['#comment'] = $comment;
259 // Always provide entity id in the same form key as in the entity edit form.
260 $form['cid'] = array('#type' => 'value', '#value' => $comment->cid);
261 return confirm_form(
262 $form,
263 t('Are you sure you want to delete the comment %title?', array('%title' => $comment->subject)),
264 'node/' . $comment->nid,
265 t('Any replies to this comment will be lost. This action cannot be undone.'),
266 t('Delete'),
267 t('Cancel'),
268 'comment_confirm_delete');
269 }
270
274 function comment_confirm_delete_submit($form, &$form_state) {
275 $comment = $form['#comment'];
276 // Delete the comment and its replies.
277 comment_delete($comment->cid);
278 drupal_set_message(t('The comment and all its replies have been deleted.'));
279 watchdog('content', 'Deleted comment @cid and its replies.', array('@cid' => $comment->cid));
280 // Clear the cache so an anonymous user sees that his comment was deleted.
281 cache_clear_all();
282
283 $form_state['redirect'] = "node/$comment->nid";
284 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
comment_save
comment_save($comment)
Definition: comment.module:1453
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
comment_multiple_delete_confirm
comment_multiple_delete_confirm($form, &$form_state)
Definition: comment.admin.inc:195
comment_load_multiple
comment_load_multiple($cids=array(), $conditions=array(), $reset=FALSE)
Definition: comment.module:1667
COMMENT_NOT_PUBLISHED
const COMMENT_NOT_PUBLISHED
Definition: comment.module:15
field_get_items
field_get_items($entity_type, $entity, $field_name, $langcode=NULL)
Definition: field.module:935
$header
print $header
Definition: forum-topic-list.tpl.php:42
comment_admin_overview_validate
comment_admin_overview_validate($form, &$form_state)
Definition: comment.admin.inc:146
comment_admin
comment_admin($type= 'new')
Definition: comment.admin.inc:11
comment_multiple_delete_confirm_submit
comment_multiple_delete_confirm_submit($form, &$form_state)
Definition: comment.admin.inc:230
comment_confirm_delete_submit
comment_confirm_delete_submit($form, &$form_state)
Definition: comment.admin.inc:274
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
MENU_NOT_FOUND
const MENU_NOT_FOUND
Definition: menu.inc:234
comment_admin_overview_submit
comment_admin_overview_submit($form, &$form_state)
Definition: comment.admin.inc:160
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
comment_load
comment_load($cid, $reset=FALSE)
Definition: comment.module:1683
comment_admin_overview
comment_admin_overview($form, &$form_state, $arg)
Definition: comment.admin.inc:34
$value
print $value
Definition: user-profile-item.tpl.php:26
comment_delete_multiple
comment_delete_multiple($cids)
Definition: comment.module:1616
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
comment_confirm_delete
comment_confirm_delete($form, &$form_state, $comment)
Definition: comment.admin.inc:257
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$row
$row
Definition: block-admin-display-form.tpl.php:47
comment_delete
comment_delete($cid)
Definition: comment.module:1606
COMMENT_PUBLISHED
const COMMENT_PUBLISHED
Definition: comment.module:20
comment_confirm_delete_page
comment_confirm_delete_page($cid)
Definition: comment.admin.inc:244
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
truncate_utf8
truncate_utf8($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
Definition: unicode.inc:316
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user.pages.inc Source File

  • modules
  • user
user.pages.inc
Go to the documentation of this file.
1 <?php
2
11 function user_autocomplete($string = '') {
12 $matches = array();
13 if ($string) {
14 $result = db_select('users')->fields('users', array('name'))->condition('name', db_like($string) . '%', 'LIKE')->range(0, 10)->execute();
15 foreach ($result as $user) {
16 $matches[$user->name] = check_plain($user->name);
17 }
18 }
19
20 drupal_json_output($matches);
21 }
22
30 function user_pass() {
31 global $user;
32
33 $form['name'] = array(
34 '#type' => 'textfield',
35 '#title' => t('Username or e-mail address'),
36 '#size' => 60,
37 '#maxlength' => max(USERNAME_MAX_LENGTH, EMAIL_MAX_LENGTH),
38 '#required' => TRUE,
39 '#default_value' => isset($_GET['name']) ? $_GET['name'] : '',
40 );
41 // Allow logged in users to request this also.
42 if ($user->uid > 0) {
43 $form['name']['#type'] = 'value';
44 $form['name']['#value'] = $user->mail;
45 $form['mail'] = array(
46 '#prefix' => '<p>',
47 '#markup' => t('Password reset instructions will be mailed to %email. You must log out to use the password reset link in the e-mail.', array('%email' => $user->mail)),
48 '#suffix' => '</p>',
49 );
50 }
51 $form['actions'] = array('#type' => 'actions');
52 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('E-mail new password'));
53
54 return $form;
55 }
56
57 function user_pass_validate($form, &$form_state) {
58 $name = trim($form_state['values']['name']);
59 // Try to load by email.
60 $users = user_load_multiple(array(), array('mail' => $name, 'status' => '1'));
61 $account = reset($users);
62 if (!$account) {
63 // No success, try to load by name.
64 $users = user_load_multiple(array(), array('name' => $name, 'status' => '1'));
65 $account = reset($users);
66 }
67 if (isset($account->uid)) {
68 form_set_value(array('#parents' => array('account')), $account, $form_state);
69 }
70 else {
71 form_set_error('name', t('Sorry, %name is not recognized as a user name or an e-mail address.', array('%name' => $name)));
72 }
73 }
74
75 function user_pass_submit($form, &$form_state) {
76 global $language;
77
78 $account = $form_state['values']['account'];
79 // Mail one time login URL and instructions using current language.
80 $mail = _user_mail_notify('password_reset', $account, $language);
81 if (!empty($mail)) {
82 watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => $account->name, '%email' => $account->mail));
83 drupal_set_message(t('Further instructions have been sent to your e-mail address.'));
84 }
85
86 $form_state['redirect'] = 'user';
87 return;
88 }
89
93 function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $action = NULL) {
94 global $user;
95
96 // When processing the one-time login link, we have to make sure that a user
97 // isn't already logged in.
98 if ($user->uid) {
99 // The existing user is already logged in.
100 if ($user->uid == $uid) {
101 drupal_set_message(t('You are logged in as %user. <a href="!user_edit">Change your password.</a>', array('%user' => $user->name, '!user_edit' => url("user/$user->uid/edit"))));
102 }
103 // A different user is already logged in on the computer.
104 else {
105 $reset_link_account = user_load($uid);
106 if (!empty($reset_link_account)) {
107 drupal_set_message(t('Another user (%other_user) is already logged into the site on this computer, but you tried to use a one-time link for user %resetting_user. Please <a href="!logout">logout</a> and try using the link again.',
108 array('%other_user' => $user->name, '%resetting_user' => $reset_link_account->name, '!logout' => url('user/logout'))));
109 } else {
110 // Invalid one-time link specifies an unknown user.
111 drupal_set_message(t('The one-time login link you clicked is invalid.'));
112 }
113 }
114 drupal_goto();
115 }
116 else {
117 // Time out, in seconds, until login URL expires. Defaults to 24 hours =
118 // 86400 seconds.
119 $timeout = variable_get('user_password_reset_timeout', 86400);
120 $current = REQUEST_TIME;
121 // Some redundant checks for extra security ?
122 $users = user_load_multiple(array($uid), array('status' => '1'));
123 if ($timestamp <= $current && $account = reset($users)) {
124 // No time out for first time login.
125 if ($account->login && $current - $timestamp > $timeout) {
126 drupal_set_message(t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'));
127 drupal_goto('user/password');
128 }
129 elseif ($account->uid && $timestamp >= $account->login && $timestamp <= $current && $hashed_pass == user_pass_rehash($account->pass, $timestamp, $account->login)) {
130 // First stage is a confirmation form, then login
131 if ($action == 'login') {
132 // Set the new user.
133 $user = $account;
134 // user_login_finalize() also updates the login timestamp of the
135 // user, which invalidates further use of the one-time login link.
136 user_login_finalize();
137 watchdog('user', 'User %name used one-time login link at time %timestamp.', array('%name' => $account->name, '%timestamp' => $timestamp));
138 drupal_set_message(t('You have just used your one-time login link. It is no longer necessary to use this link to log in. Please change your password.'));
139 // Let the user's password be changed without the current password check.
140 $token = drupal_random_key();
141 $_SESSION['pass_reset_' . $user->uid] = $token;
142 drupal_goto('user/' . $user->uid . '/edit', array('query' => array('pass-reset-token' => $token)));
143 }
144 else {
145 $form['message'] = array('#markup' => t('<p>This is a one-time login for %user_name and will expire on %expiration_date.</p><p>Click on this button to log in to the site and change your password.</p>', array('%user_name' => $account->name, '%expiration_date' => format_date($timestamp + $timeout))));
146 $form['help'] = array('#markup' => '<p>' . t('This login can be used only once.') . '</p>');
147 $form['actions'] = array('#type' => 'actions');
148 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Log in'));
149 $form['#action'] = url("user/reset/$uid/$timestamp/$hashed_pass/login");
150 return $form;
151 }
152 }
153 else {
154 drupal_set_message(t('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'));
155 drupal_goto('user/password');
156 }
157 }
158 else {
159 // Deny access, no more clues.
160 // Everything will be in the watchdog's URL for the administrator to check.
161 drupal_access_denied();
162 drupal_exit();
163 }
164 }
165 }
166
170 function user_logout() {
171 global $user;
172
173 watchdog('user', 'Session closed for %name.', array('%name' => $user->name));
174
175 module_invoke_all('user_logout', $user);
176
177 // Destroy the current session, and reset $user to the anonymous user.
178 session_destroy();
179
180 drupal_goto();
181 }
182
191 function template_preprocess_user_profile(&$variables) {
192 $account = $variables['elements']['#account'];
193
194 // Helpful $user_profile variable for templates.
195 foreach (element_children($variables['elements']) as $key) {
196 $variables['user_profile'][$key] = $variables['elements'][$key];
197 }
198
199 // Preprocess fields.
200 field_attach_preprocess('user', $account, $variables['elements'], $variables);
201 }
202
211 function template_preprocess_user_profile_item(&$variables) {
212 $variables['title'] = $variables['element']['#title'];
213 $variables['value'] = $variables['element']['#markup'];
214 $variables['attributes'] = '';
215 if (isset($variables['element']['#attributes'])) {
216 $variables['attributes'] = drupal_attributes($variables['element']['#attributes']);
217 }
218 }
219
228 function template_preprocess_user_profile_category(&$variables) {
229 $variables['title'] = check_plain($variables['element']['#title']);
230 $variables['profile_items'] = $variables['element']['#children'];
231 $variables['attributes'] = '';
232 if (isset($variables['element']['#attributes'])) {
233 $variables['attributes'] = drupal_attributes($variables['element']['#attributes']);
234 }
235 }
236
247 function user_profile_form($form, &$form_state, $account, $category = 'account') {
248 global $user;
249
250 // During initial form build, add the entity to the form state for use during
251 // form building and processing. During a rebuild, use what is in the form
252 // state.
253 if (!isset($form_state['user'])) {
254 $form_state['user'] = $account;
255 }
256 else {
257 $account = $form_state['user'];
258 }
259
260 // @todo Legacy support. Modules are encouraged to access the entity using
261 // $form_state. Remove in Drupal 8.
262 $form['#user'] = $account;
263 $form['#user_category'] = $category;
264
265 if ($category == 'account') {
266 user_account_form($form, $form_state);
267 // Attach field widgets.
268 $langcode = entity_language('user', $account);
269 field_attach_form('user', $account, $form, $form_state, $langcode);
270 }
271
272 $form['actions'] = array('#type' => 'actions');
273 $form['actions']['submit'] = array(
274 '#type' => 'submit',
275 '#value' => t('Save'),
276 );
277 if ($category == 'account') {
278 $form['actions']['cancel'] = array(
279 '#type' => 'submit',
280 '#value' => t('Cancel account'),
281 '#submit' => array('user_edit_cancel_submit'),
282 '#access' => $account->uid > 1 && (($account->uid == $user->uid && user_access('cancel account')) || user_access('administer users')),
283 );
284 }
285
286 $form['#validate'][] = 'user_profile_form_validate';
287 // Add the final user profile form submit handler.
288 $form['#submit'][] = 'user_profile_form_submit';
289
290 return $form;
291 }
292
296 function user_profile_form_validate($form, &$form_state) {
297 entity_form_field_validate('user', $form, $form_state);
298 }
299
303 function user_profile_form_submit($form, &$form_state) {
304 $account = $form_state['user'];
305 $category = $form['#user_category'];
306 // Remove unneeded values.
307 form_state_values_clean($form_state);
308
309 // Before updating the account entity, keep an unchanged copy for use with
310 // user_save() later. This is necessary for modules implementing the user
311 // hooks to be able to react on changes by comparing the values of $account
312 // and $edit.
313 $account_unchanged = clone $account;
314
315 entity_form_submit_build_entity('user', $account, $form, $form_state);
316
317 // Populate $edit with the properties of $account, which have been edited on
318 // this form by taking over all values, which appear in the form values too.
319 $edit = array_intersect_key((array) $account, $form_state['values']);
320
321 user_save($account_unchanged, $edit, $category);
322 $form_state['values']['uid'] = $account->uid;
323
324 if ($category == 'account' && !empty($edit['pass'])) {
325 // Remove the password reset tag since a new password was saved.
326 unset($_SESSION['pass_reset_'. $account->uid]);
327 }
328 // Clear the page cache because pages can contain usernames and/or profile information:
329 cache_clear_all();
330
331 drupal_set_message(t('The changes have been saved.'));
332 }
333
337 function user_edit_cancel_submit($form, &$form_state) {
338 $destination = array();
339 if (isset($_GET['destination'])) {
340 $destination = drupal_get_destination();
341 unset($_GET['destination']);
342 }
343 // Note: We redirect from user/uid/edit to user/uid/cancel to make the tabs disappear.
344 $form_state['redirect'] = array("user/" . $form['#user']->uid . "/cancel", array('query' => $destination));
345 }
346
353 function user_cancel_confirm_form($form, &$form_state, $account) {
354 global $user;
355
356 $form['_account'] = array('#type' => 'value', '#value' => $account);
357
358 // Display account cancellation method selection, if allowed.
359 $default_method = variable_get('user_cancel_method', 'user_cancel_block');
360 $admin_access = user_access('administer users');
361 $can_select_method = $admin_access || user_access('select account cancellation method');
362 $form['user_cancel_method'] = array(
363 '#type' => 'item',
364 '#title' => ($account->uid == $user->uid ? t('When cancelling your account') : t('When cancelling the account')),
365 '#access' => $can_select_method,
366 );
367 $form['user_cancel_method'] += user_cancel_methods();
368
369 // Allow user administrators to skip the account cancellation confirmation
370 // mail (by default), as long as they do not attempt to cancel their own
371 // account.
372 $override_access = $admin_access && ($account->uid != $user->uid);
373 $form['user_cancel_confirm'] = array(
374 '#type' => 'checkbox',
375 '#title' => t('Require e-mail confirmation to cancel account.'),
376 '#default_value' => ($override_access ? FALSE : TRUE),
377 '#access' => $override_access,
378 '#description' => t('When enabled, the user must confirm the account cancellation via e-mail.'),
379 );
380 // Also allow to send account canceled notification mail, if enabled.
381 $default_notify = variable_get('user_mail_status_canceled_notify', FALSE);
382 $form['user_cancel_notify'] = array(
383 '#type' => 'checkbox',
384 '#title' => t('Notify user when account is canceled.'),
385 '#default_value' => ($override_access ? FALSE : $default_notify),
386 '#access' => $override_access && $default_notify,
387 '#description' => t('When enabled, the user will receive an e-mail notification after the account has been cancelled.'),
388 );
389
390 // Prepare confirmation form page title and description.
391 if ($account->uid == $user->uid) {
392 $question = t('Are you sure you want to cancel your account?');
393 }
394 else {
395 $question = t('Are you sure you want to cancel the account %name?', array('%name' => $account->name));
396 }
397 $description = '';
398 if ($can_select_method) {
399 $description = t('Select the method to cancel the account above.');
400 foreach (element_children($form['user_cancel_method']) as $element) {
401 unset($form['user_cancel_method'][$element]['#description']);
402 }
403 }
404 else {
405 // The radio button #description is used as description for the confirmation
406 // form.
407 foreach (element_children($form['user_cancel_method']) as $element) {
408 if ($form['user_cancel_method'][$element]['#default_value'] == $form['user_cancel_method'][$element]['#return_value']) {
409 $description = $form['user_cancel_method'][$element]['#description'];
410 }
411 unset($form['user_cancel_method'][$element]['#description']);
412 }
413 }
414
415 // Always provide entity id in the same form key as in the entity edit form.
416 $form['uid'] = array('#type' => 'value', '#value' => $account->uid);
417 return confirm_form($form,
418 $question,
419 'user/' . $account->uid,
420 $description . ' ' . t('This action cannot be undone.'),
421 t('Cancel account'), t('Cancel'));
422 }
423
430 function user_cancel_confirm_form_submit($form, &$form_state) {
431 global $user;
432 $account = $form_state['values']['_account'];
433
434 // Cancel account immediately, if the current user has administrative
435 // privileges, no confirmation mail shall be sent, and the user does not
436 // attempt to cancel the own account.
437 if (user_access('administer users') && empty($form_state['values']['user_cancel_confirm']) && $account->uid != $user->uid) {
438 user_cancel($form_state['values'], $account->uid, $form_state['values']['user_cancel_method']);
439
440 $form_state['redirect'] = 'admin/people';
441 }
442 else {
443 // Store cancelling method and whether to notify the user in $account for
444 // user_cancel_confirm().
445 $edit = array(
446 'user_cancel_method' => $form_state['values']['user_cancel_method'],
447 'user_cancel_notify' => $form_state['values']['user_cancel_notify'],
448 );
449 $account = user_save($account, $edit);
450 _user_mail_notify('cancel_confirm', $account);
451 drupal_set_message(t('A confirmation request to cancel your account has been sent to your e-mail address.'));
452 watchdog('user', 'Sent account cancellation request to %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
453
454 $form_state['redirect'] = "user/$account->uid";
455 }
456 }
457
471 function user_cancel_methods() {
472 $methods = array(
473 'user_cancel_block' => array(
474 'title' => t('Disable the account and keep its content.'),
475 'description' => t('Your account will be blocked and you will no longer be able to log in. All of your content will remain attributed to your user name.'),
476 ),
477 'user_cancel_block_unpublish' => array(
478 'title' => t('Disable the account and unpublish its content.'),
479 'description' => t('Your account will be blocked and you will no longer be able to log in. All of your content will be hidden from everyone but administrators.'),
480 ),
481 'user_cancel_reassign' => array(
482 'title' => t('Delete the account and make its content belong to the %anonymous-name user.', array('%anonymous-name' => variable_get('anonymous', t('Anonymous')))),
483 'description' => t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', array('%anonymous-name' => variable_get('anonymous', t('Anonymous')))),
484 ),
485 'user_cancel_delete' => array(
486 'title' => t('Delete the account and its content.'),
487 'description' => t('Your account will be removed and all account information deleted. All of your content will also be deleted.'),
488 'access' => user_access('administer users'),
489 ),
490 );
491 // Allow modules to customize account cancellation methods.
492 drupal_alter('user_cancel_methods', $methods);
493
494 // Turn all methods into real form elements.
495 $default_method = variable_get('user_cancel_method', 'user_cancel_block');
496 foreach ($methods as $name => $method) {
497 $form[$name] = array(
498 '#type' => 'radio',
499 '#title' => $method['title'],
500 '#description' => (isset($method['description']) ? $method['description'] : NULL),
501 '#return_value' => $name,
502 '#default_value' => $default_method,
503 '#parents' => array('user_cancel_method'),
504 );
505 }
506 return $form;
507 }
508
515 function user_cancel_confirm($account, $timestamp = 0, $hashed_pass = '') {
516 // Time out in seconds until cancel URL expires; 24 hours = 86400 seconds.
517 $timeout = 86400;
518 $current = REQUEST_TIME;
519
520 // Basic validation of arguments.
521 if (isset($account->data['user_cancel_method']) && !empty($timestamp) && !empty($hashed_pass)) {
522 // Validate expiration and hashed password/login.
523 if ($timestamp <= $current && $current - $timestamp < $timeout && $account->uid && $timestamp >= $account->login && $hashed_pass == user_pass_rehash($account->pass, $timestamp, $account->login)) {
524 $edit = array(
525 'user_cancel_notify' => isset($account->data['user_cancel_notify']) ? $account->data['user_cancel_notify'] : variable_get('user_mail_status_canceled_notify', FALSE),
526 );
527 user_cancel($edit, $account->uid, $account->data['user_cancel_method']);
528 // Since user_cancel() is not invoked via Form API, batch processing needs
529 // to be invoked manually and should redirect to the front page after
530 // completion.
531 batch_process('');
532 }
533 else {
534 drupal_set_message(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'));
535 drupal_goto("user/$account->uid/cancel");
536 }
537 }
538 return MENU_ACCESS_DENIED;
539 }
540
553 function user_page() {
554 global $user;
555 if ($user->uid) {
556 menu_set_active_item('user/' . $user->uid);
557 return menu_execute_active_handler(NULL, FALSE);
558 }
559 else {
560 return drupal_get_form('user_login');
561 }
562 }
EMAIL_MAX_LENGTH
const EMAIL_MAX_LENGTH
Definition: user.module:16
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
batch_process
batch_process($redirect=NULL, $url= 'batch', $redirect_callback= 'drupal_goto')
Definition: form.inc:4459
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
user_cancel_confirm_form
user_cancel_confirm_form($form, &$form_state, $account)
Definition: user.pages.inc:353
user_edit_cancel_submit
user_edit_cancel_submit($form, &$form_state)
Definition: user.pages.inc:337
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
user_page
user_page()
Definition: user.pages.inc:553
entity_form_field_validate
entity_form_field_validate($entity_type, $form, &$form_state)
Definition: common.inc:7997
field_attach_form
field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode=NULL, $options=array())
Definition: field.attach.inc:564
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
MENU_ACCESS_DENIED
const MENU_ACCESS_DENIED
Definition: menu.inc:239
form_state_values_clean
form_state_values_clean(&$form_state)
Definition: form.inc:2159
$name
print $name
Definition: profile-listing.tpl.php:43
drupal_json_output
drupal_json_output($var=NULL)
Definition: common.inc:5041
menu_set_active_item
menu_set_active_item($path)
Definition: menu.inc:2340
drupal_attributes
drupal_attributes(array $attributes=array())
Definition: common.inc:2377
USERNAME_MAX_LENGTH
const USERNAME_MAX_LENGTH
Definition: user.module:11
user_profile_form
user_profile_form($form, &$form_state, $account, $category= 'account')
Definition: user.pages.inc:247
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
_user_mail_notify
_user_mail_notify($op, $account, $language=NULL)
Definition: user.module:3564
user_save
user_save($account, $edit=array(), $category= 'account')
Definition: user.module:424
user_cancel
user_cancel($edit, $uid, $method)
Definition: user.module:2398
user_autocomplete
user_autocomplete($string= '')
Definition: user.pages.inc:11
user_pass_rehash
user_pass_rehash($password, $timestamp, $login)
Definition: user.module:2378
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
user_pass
user_pass()
Definition: user.pages.inc:30
user_pass_submit
user_pass_submit($form, &$form_state)
Definition: user.pages.inc:75
user_profile_form_submit
user_profile_form_submit($form, &$form_state)
Definition: user.pages.inc:303
menu_execute_active_handler
menu_execute_active_handler($path=NULL, $deliver=TRUE)
Definition: menu.inc:500
user_logout
user_logout()
Definition: user.pages.inc:170
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
drupal_random_key
drupal_random_key($byte_count=32)
Definition: bootstrap.inc:1945
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
entity_language
entity_language($entity_type, $entity)
Definition: common.inc:7967
user_load_multiple
user_load_multiple($uids=array(), $conditions=array(), $reset=FALSE)
Definition: user.module:290
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
db_like
db_like($string)
Definition: database.inc:2610
user_access
user_access($string, $account=NULL)
Definition: user.module:794
field_attach_preprocess
field_attach_preprocess($entity_type, $entity, $element, &$variables)
Definition: field.attach.inc:1272
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
template_preprocess_user_profile_item
template_preprocess_user_profile_item(&$variables)
Definition: user.pages.inc:211
user_cancel_confirm_form_submit
user_cancel_confirm_form_submit($form, &$form_state)
Definition: user.pages.inc:430
user_pass_reset
user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $action=NULL)
Definition: user.pages.inc:93
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
user_login_finalize
user_login_finalize(&$edit=array())
Definition: user.module:2255
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_access_denied
drupal_access_denied()
Definition: common.inc:744
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
drupal_exit
drupal_exit($destination=NULL)
Definition: common.inc:2721
template_preprocess_user_profile
template_preprocess_user_profile(&$variables)
Definition: user.pages.inc:191
user_pass_validate
user_pass_validate($form, &$form_state)
Definition: user.pages.inc:57
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
user_cancel_confirm
user_cancel_confirm($account, $timestamp=0, $hashed_pass= '')
Definition: user.pages.inc:515
user_account_form
user_account_form(&$form, &$form_state)
Definition: user.module:1019
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
user_profile_form_validate
user_profile_form_validate($form, &$form_state)
Definition: user.pages.inc:296
user_cancel_methods
user_cancel_methods()
Definition: user.pages.inc:471
entity_form_submit_build_entity
entity_form_submit_build_entity($entity_type, $entity, $form, &$form_state)
Definition: common.inc:8028
template_preprocess_user_profile_category
template_preprocess_user_profile_category(&$variables)
Definition: user.pages.inc:228
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/templates/maintenance-page.tpl.php Source File

  • themes
  • bartik
  • templates
maintenance-page.tpl.php
Go to the documentation of this file.
1 <?php
2
13 ?>
14 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
15 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
16 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>">
17 <head>
18 <?php print $head; ?>
19 <title><?php print $head_title; ?></title>
20 <?php print $styles; ?>
21 <?php print $scripts; ?>
22 </head>
23 <body class="<?php print $classes; ?>" <?php print $attributes;?>>
24
25 <div id="skip-link">
26 <a href="#main-content" class="element-invisible element-focusable"><?php print t('Skip to main content'); ?></a>
27 </div>
28
29 <div id="page-wrapper"><div id="page">
30
31 <div id="header"><div class="section clearfix">
32 <?php if ($site_name || $site_slogan): ?>
33 <div id="name-and-slogan"<?php if ($hide_site_name && $hide_site_slogan) { print ' class="element-invisible"'; } ?>>
34 <?php if ($site_name): ?>
35 <div id="site-name"<?php if ($hide_site_name) { print ' class="element-invisible"'; } ?>>
36 <strong>
37 <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
38 </strong>
39 </div>
40 <?php endif; ?>
41 <?php if ($site_slogan): ?>
42 <div id="site-slogan"<?php if ($hide_site_slogan) { print ' class="element-invisible"'; } ?>>
43 <?php print $site_slogan; ?>
44 </div>
45 <?php endif; ?>
46 </div> <!-- /#name-and-slogan -->
47 <?php endif; ?>
48 </div></div> <!-- /.section, /#header -->
49
50 <div id="main-wrapper"><div id="main" class="clearfix">
51 <div id="content" class="column"><div class="section">
52 <a id="main-content"></a>
53 <?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
54 <?php print $content; ?>
55 <?php if ($messages): ?>
56 <div id="messages"><div class="section clearfix">
57 <?php print $messages; ?>
58 </div></div> <!-- /.section, /#messages -->
59 <?php endif; ?>
60 </div></div> <!-- /.section, /#content -->
61 </div></div> <!-- /#main, /#main-wrapper -->
62
63 </div></div> <!-- /#page, /#page-wrapper -->
64
65 </body>
66 </html>
dir
print $language dir
Definition: html.tpl.php:47
$head
print $head
Definition: book-export-html.tpl.php:25
name
print $forum name
Definition: forum-list.tpl.php:57
$attributes
print $attributes
Definition: block.tpl.php:47
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$site_slogan
if($site_slogan)($hide_site_slogan) print $site_slogan
Definition: maintenance-page.tpl.php:41
$scripts
print $scripts
Definition: html.tpl.php:53
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
endif
endif
Definition: aggregator-item.tpl.php:31
$messages
print $messages
Definition: page.tpl.php:121
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
$styles
print $styles
Definition: html.tpl.php:52
title
print $topic title
Definition: forum-topic-list.tpl.php:50
$head_title
print $head_title
Definition: html.tpl.php:51
$site_name
print $site_name
Definition: maintenance-page.tpl.php:40
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/unicode.entities.inc Source File

  • includes
unicode.entities.inc
Go to the documentation of this file.
1 <?php
2
10 $html_entities = array(
11 '&Aacute;' => 'Á',
12 '&aacute;' => 'á',
13 '&Acirc;' => 'Â',
14 '&acirc;' => 'â',
15 '&acute;' => '´',
16 '&AElig;' => 'Æ',
17 '&aelig;' => 'æ',
18 '&Agrave;' => 'À',
19 '&agrave;' => 'à',
20 '&alefsym;' => 'ℵ',
21 '&Alpha;' => 'Α',
22 '&alpha;' => 'α',
23 '&amp;' => '&',
24 '&and;' => '∧',
25 '&ang;' => '∠',
26 '&Aring;' => 'Å',
27 '&aring;' => 'å',
28 '&asymp;' => '≈',
29 '&Atilde;' => 'Ã',
30 '&atilde;' => 'ã',
31 '&Auml;' => 'Ä',
32 '&auml;' => 'ä',
33 '&bdquo;' => '„',
34 '&Beta;' => 'Β',
35 '&beta;' => 'β',
36 '&brvbar;' => '¦',
37 '&bull;' => '•',
38 '&cap;' => '∩',
39 '&Ccedil;' => 'Ç',
40 '&ccedil;' => 'ç',
41 '&cedil;' => '¸',
42 '&cent;' => '¢',
43 '&Chi;' => 'Χ',
44 '&chi;' => 'χ',
45 '&circ;' => 'ˆ',
46 '&clubs;' => '♣',
47 '&cong;' => '≅',
48 '&copy;' => '©',
49 '&crarr;' => '↵',
50 '&cup;' => '∪',
51 '&curren;' => '¤',
52 '&dagger;' => '†',
53 '&Dagger;' => '‡',
54 '&darr;' => '↓',
55 '&dArr;' => '⇓',
56 '&deg;' => '°',
57 '&Delta;' => 'Δ',
58 '&delta;' => 'δ',
59 '&diams;' => '♦',
60 '&divide;' => '÷',
61 '&Eacute;' => 'É',
62 '&eacute;' => 'é',
63 '&Ecirc;' => 'Ê',
64 '&ecirc;' => 'ê',
65 '&Egrave;' => 'È',
66 '&egrave;' => 'è',
67 '&empty;' => '∅',
68 '&emsp;' => ' ',
69 '&ensp;' => ' ',
70 '&Epsilon;' => 'Ε',
71 '&epsilon;' => 'ε',
72 '&equiv;' => '≡',
73 '&Eta;' => 'Η',
74 '&eta;' => 'η',
75 '&ETH;' => 'Ð',
76 '&eth;' => 'ð',
77 '&Euml;' => 'Ë',
78 '&euml;' => 'ë',
79 '&euro;' => '€',
80 '&exist;' => '∃',
81 '&fnof;' => 'ƒ',
82 '&forall;' => '∀',
83 '&frac12;' => '½',
84 '&frac14;' => '¼',
85 '&frac34;' => '¾',
86 '&frasl;' => '⁄',
87 '&Gamma;' => 'Γ',
88 '&gamma;' => 'γ',
89 '&ge;' => '≥',
90 '&harr;' => '↔',
91 '&hArr;' => '⇔',
92 '&hearts;' => '♥',
93 '&hellip;' => '…',
94 '&Iacute;' => 'Í',
95 '&iacute;' => 'í',
96 '&Icirc;' => 'Î',
97 '&icirc;' => 'î',
98 '&iexcl;' => '¡',
99 '&Igrave;' => 'Ì',
100 '&igrave;' => 'ì',
101 '&image;' => 'ℑ',
102 '&infin;' => '∞',
103 '&int;' => '∫',
104 '&Iota;' => 'Ι',
105 '&iota;' => 'ι',
106 '&iquest;' => '¿',
107 '&isin;' => '∈',
108 '&Iuml;' => 'Ï',
109 '&iuml;' => 'ï',
110 '&Kappa;' => 'Κ',
111 '&kappa;' => 'κ',
112 '&Lambda;' => 'Λ',
113 '&lambda;' => 'λ',
114 '&lang;' => '〈',
115 '&laquo;' => '«',
116 '&larr;' => '←',
117 '&lArr;' => '⇐',
118 '&lceil;' => '⌈',
119 '&ldquo;' => '“',
120 '&le;' => '≤',
121 '&lfloor;' => '⌊',
122 '&lowast;' => '∗',
123 '&loz;' => '◊',
124 '&lrm;' => '‎',
125 '&lsaquo;' => '‹',
126 '&lsquo;' => '‘',
127 '&macr;' => '¯',
128 '&mdash;' => '—',
129 '&micro;' => 'µ',
130 '&middot;' => '·',
131 '&minus;' => '−',
132 '&Mu;' => 'Μ',
133 '&mu;' => 'μ',
134 '&nabla;' => '∇',
135 '&nbsp;' => ' ',
136 '&ndash;' => '–',
137 '&ne;' => '≠',
138 '&ni;' => '∋',
139 '&not;' => '¬',
140 '&notin;' => '∉',
141 '&nsub;' => '⊄',
142 '&Ntilde;' => 'Ñ',
143 '&ntilde;' => 'ñ',
144 '&Nu;' => 'Ν',
145 '&nu;' => 'ν',
146 '&Oacute;' => 'Ó',
147 '&oacute;' => 'ó',
148 '&Ocirc;' => 'Ô',
149 '&ocirc;' => 'ô',
150 '&OElig;' => 'Œ',
151 '&oelig;' => 'œ',
152 '&Ograve;' => 'Ò',
153 '&ograve;' => 'ò',
154 '&oline;' => '‾',
155 '&Omega;' => 'Ω',
156 '&omega;' => 'ω',
157 '&Omicron;' => 'Ο',
158 '&omicron;' => 'ο',
159 '&oplus;' => '⊕',
160 '&or;' => '∨',
161 '&ordf;' => 'ª',
162 '&ordm;' => 'º',
163 '&Oslash;' => 'Ø',
164 '&oslash;' => 'ø',
165 '&Otilde;' => 'Õ',
166 '&otilde;' => 'õ',
167 '&otimes;' => '⊗',
168 '&Ouml;' => 'Ö',
169 '&ouml;' => 'ö',
170 '&para;' => '¶',
171 '&part;' => '∂',
172 '&permil;' => '‰',
173 '&perp;' => '⊥',
174 '&Phi;' => 'Φ',
175 '&phi;' => 'φ',
176 '&Pi;' => 'Π',
177 '&pi;' => 'π',
178 '&piv;' => 'ϖ',
179 '&plusmn;' => '±',
180 '&pound;' => '£',
181 '&prime;' => '′',
182 '&Prime;' => '″',
183 '&prod;' => '∏',
184 '&prop;' => '∝',
185 '&Psi;' => 'Ψ',
186 '&psi;' => 'ψ',
187 '&radic;' => '√',
188 '&rang;' => '〉',
189 '&raquo;' => '»',
190 '&rarr;' => '→',
191 '&rArr;' => '⇒',
192 '&rceil;' => '⌉',
193 '&rdquo;' => '”',
194 '&real;' => 'ℜ',
195 '&reg;' => '®',
196 '&rfloor;' => '⌋',
197 '&Rho;' => 'Ρ',
198 '&rho;' => 'ρ',
199 '&rlm;' => '‏',
200 '&rsaquo;' => '›',
201 '&rsquo;' => '’',
202 '&sbquo;' => '‚',
203 '&Scaron;' => 'Š',
204 '&scaron;' => 'š',
205 '&sdot;' => '⋅',
206 '&sect;' => '§',
207 '&shy;' => '',
208 '&Sigma;' => 'Σ',
209 '&sigma;' => 'σ',
210 '&sigmaf;' => 'ς',
211 '&sim;' => '∼',
212 '&spades;' => '♠',
213 '&sub;' => '⊂',
214 '&sube;' => '⊆',
215 '&sum;' => '∑',
216 '&sup1;' => '¹',
217 '&sup2;' => '²',
218 '&sup3;' => '³',
219 '&sup;' => '⊃',
220 '&supe;' => '⊇',
221 '&szlig;' => 'ß',
222 '&Tau;' => 'Τ',
223 '&tau;' => 'τ',
224 '&there4;' => '∴',
225 '&Theta;' => 'Θ',
226 '&theta;' => 'θ',
227 '&thetasym;' => 'ϑ',
228 '&thinsp;' => ' ',
229 '&THORN;' => 'Þ',
230 '&thorn;' => 'þ',
231 '&tilde;' => '˜',
232 '&times;' => '×',
233 '&trade;' => '™',
234 '&Uacute;' => 'Ú',
235 '&uacute;' => 'ú',
236 '&uarr;' => '↑',
237 '&uArr;' => '⇑',
238 '&Ucirc;' => 'Û',
239 '&ucirc;' => 'û',
240 '&Ugrave;' => 'Ù',
241 '&ugrave;' => 'ù',
242 '&uml;' => '¨',
243 '&upsih;' => 'ϒ',
244 '&Upsilon;' => 'Υ',
245 '&upsilon;' => 'υ',
246 '&Uuml;' => 'Ü',
247 '&uuml;' => 'ü',
248 '&weierp;' => '℘',
249 '&Xi;' => 'Ξ',
250 '&xi;' => 'ξ',
251 '&Yacute;' => 'Ý',
252 '&yacute;' => 'ý',
253 '&yen;' => '¥',
254 '&yuml;' => 'ÿ',
255 '&Yuml;' => 'Ÿ',
256 '&Zeta;' => 'Ζ',
257 '&zeta;' => 'ζ',
258 '&zwj;' => '‍',
259 '&zwnj;' => '‌',
260 '&gt;' => '>',
261 '&lt;' => '<',
262 '&quot;' => '"',
263 // Add apostrophe (XML).
264 '&apos;' => "'",
265 );
$html_entities
$html_entities
Definition: unicode.entities.inc:10
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/form_example/form_example_tutorial.inc Source File

  • examples
  • form_example
form_example_tutorial.inc
Go to the documentation of this file.
1 <?php
2
31 function form_example_tutorial() {
32 return t('This is a set of 10 form tutorials tied to the <a href="http://drupal.org/node/262422">Drupal handbook</a>.');
33 }
34
36
48 function form_example_tutorial_1($form, &$form_state) {
49
50 $form['description'] = array(
51 '#type' => 'item',
52 '#title' => t('A form with nothing but a textfield'),
53 );
54 // This is the first form element. It's a textfield with a label, "Name"
55 $form['name'] = array(
56 '#type' => 'textfield',
57 '#title' => t('Name'),
58 );
59 return $form;
60 }
61
62
64
71 function form_example_tutorial_2($form, &$form_state) {
72 $form['description'] = array(
73 '#type' => 'item',
74 '#title' => t('A simple form with a submit button'),
75 );
76
77 $form['name'] = array(
78 '#type' => 'textfield',
79 '#title' => t('Name'),
80 );
81
82 // Adds a simple submit button that refreshes the form and clears its
83 // contents. This is the default behavior for forms.
84 $form['submit'] = array(
85 '#type' => 'submit',
86 '#value' => 'Submit',
87 );
88 return $form;
89 }
90
92
106 function form_example_tutorial_3($form, &$form_state) {
107 $form['description'] = array(
108 '#type' => 'item',
109 '#title' => t('A form with a fieldset'),
110 );
111
112 $form['name'] = array(
113 '#type' => 'fieldset',
114 '#title' => t('Name'),
115 );
116 $form['name']['first'] = array(
117 '#type' => 'textfield',
118 '#title' => t('First name'),
119 );
120 $form['name']['last'] = array(
121 '#type' => 'textfield',
122 '#title' => t('Last name'),
123 );
124
125
126 $form['submit'] = array(
127 '#type' => 'submit',
128 '#value' => 'Submit',
129 );
130 return $form;
131 }
132
133
135
141 function form_example_tutorial_4($form, &$form_state) {
142 $form['description'] = array(
143 '#type' => 'item',
144 '#title' => t('A form with required fields'),
145 );
146
147 $form['name'] = array(
148 '#type' => 'fieldset',
149 '#title' => t('Name'),
150 // Make the fieldset collapsible.
151 '#collapsible' => TRUE, // Added
152 '#collapsed' => FALSE, // Added
153 );
154
155 // Make these fields required.
156 $form['name']['first'] = array(
157 '#type' => 'textfield',
158 '#title' => t('First name'),
159 '#required' => TRUE, // Added
160 );
161 $form['name']['last'] = array(
162 '#type' => 'textfield',
163 '#title' => t('Last name'),
164 '#required' => TRUE, // Added
165 );
166
167 $form['submit'] = array(
168 '#type' => 'submit',
169 '#value' => 'Submit',
170 );
171 return $form;
172 }
173
174
176
189 function form_example_tutorial_5($form, &$form_state) {
190 $form['description'] = array(
191 '#type' => 'item',
192 '#title' => t('A form with additional attributes'),
193 '#description' => t('This one adds #default_value and #description'),
194 );
195 $form['name'] = array(
196 '#type' => 'fieldset',
197 '#title' => t('Name'),
198 '#collapsible' => TRUE,
199 '#collapsed' => FALSE,
200 );
201
202 $form['name']['first'] = array(
203 '#type' => 'textfield',
204 '#title' => t('First name'),
205 '#required' => TRUE,
206 '#default_value' => "First name", // added default value.
207 '#description' => "Please enter your first name.", // added description
208 '#size' => 20, // added
209 '#maxlength' => 20, // added
210 );
211 $form['name']['last'] = array(
212 '#type' => 'textfield',
213 '#title' => t('Last name'),
214 '#required' => TRUE,
215 );
216 $form['submit'] = array(
217 '#type' => 'submit',
218 '#value' => 'Submit',
219 );
220 return $form;
221 }
222
223
225
232 function form_example_tutorial_6($form, &$form_state) {
233 $form['description'] = array(
234 '#type' => 'item',
235 '#title' => t('A form with a validation handler'),
236 );
237
238 $form['name'] = array(
239 '#type' => 'fieldset',
240 '#title' => t('Name'),
241 '#collapsible' => TRUE,
242 '#collapsed' => FALSE,
243 );
244 $form['name']['first'] = array(
245 '#type' => 'textfield',
246 '#title' => t('First name'),
247 '#required' => TRUE,
248 '#default_value' => "First name",
249 '#description' => "Please enter your first name.",
250 '#size' => 20,
251 '#maxlength' => 20,
252 );
253 $form['name']['last'] = array(
254 '#type' => 'textfield',
255 '#title' => t('Last name'),
256 '#required' => TRUE,
257 );
258
259 // New form field added to permit entry of year of birth.
260 // The data entered into this field will be validated with
261 // the default validation function.
262 $form['year_of_birth'] = array(
263 '#type' => 'textfield',
264 '#title' => "Year of birth",
265 '#description' => 'Format is "YYYY"',
266 );
267
268 $form['submit'] = array(
269 '#type' => 'submit',
270 '#value' => 'Submit',
271 );
272 return $form;
273 }
274
275
276
290 function form_example_tutorial_6_validate($form, &$form_state) {
291 $year_of_birth = $form_state['values']['year_of_birth'];
292 if ($year_of_birth && ($year_of_birth < 1900 || $year_of_birth > 2000)) {
293 form_set_error('year_of_birth', t('Enter a year between 1900 and 2000.'));
294 }
295 }
296
297
299
310 function form_example_tutorial_7($form, &$form_state) {
311 $form['description'] = array(
312 '#type' => 'item',
313 '#title' => t('A form with a submit handler'),
314 );
315 $form['name'] = array(
316 '#type' => 'fieldset',
317 '#title' => t('Name'),
318 '#collapsible' => TRUE,
319 '#collapsed' => FALSE,
320 );
321 $form['name']['first'] = array(
322 '#type' => 'textfield',
323 '#title' => t('First name'),
324 '#required' => TRUE,
325 '#default_value' => "First name",
326 '#description' => "Please enter your first name.",
327 '#size' => 20,
328 '#maxlength' => 20,
329 );
330 $form['name']['last'] = array(
331 '#type' => 'textfield',
332 '#title' => t('Last name'),
333 '#required' => TRUE,
334 );
335 $form['year_of_birth'] = array(
336 '#type' => 'textfield',
337 '#title' => "Year of birth",
338 '#description' => 'Format is "YYYY"',
339 );
340 $form['submit'] = array(
341 '#type' => 'submit',
342 '#value' => 'Submit',
343 );
344 return $form;
345 }
346
347
351 function form_example_tutorial_7_validate($form, &$form_state) {
352 $year_of_birth = $form_state['values']['year_of_birth'];
353 if ($year_of_birth && ($year_of_birth < 1900 || $year_of_birth > 2000)) {
354 form_set_error('year_of_birth', t('Enter a year between 1900 and 2000.'));
355 }
356 }
357
364 function form_example_tutorial_7_submit($form, &$form_state) {
365 drupal_set_message(t('The form has been submitted. name="@first @last", year of birth=@year_of_birth',
366 array('@first' => $form_state['values']['first'], '@last' => $form_state['values']['last'], '@year_of_birth' => $form_state['values']['year_of_birth'])));
367 }
368
369
371
392 function form_example_tutorial_8($form, &$form_state) {
393
394 // Display page 2 if $form_state['page_num'] == 2
395 if (!empty($form_state['page_num']) && $form_state['page_num'] == 2) {
396 return form_example_tutorial_8_page_two($form, $form_state);
397 }
398
399 // Otherwise we build page 1.
400 $form_state['page_num'] = 1;
401
402 $form['description'] = array(
403 '#type' => 'item',
404 '#title' => t('A basic multistep form (page 1)'),
405 );
406
407 $form['first'] = array(
408 '#type' => 'textfield',
409 '#title' => t('First name'),
410 '#description' => "Please enter your first name.",
411 '#size' => 20,
412 '#maxlength' => 20,
413 '#required' => TRUE,
414 '#default_value' => !empty($form_state['values']['first']) ? $form_state['values']['first'] : '',
415 );
416 $form['last'] = array(
417 '#type' => 'textfield',
418 '#title' => t('Last name'),
419 '#default_value' => !empty($form_state['values']['last']) ? $form_state['values']['last'] : '',
420 );
421 $form['year_of_birth'] = array(
422 '#type' => 'textfield',
423 '#title' => "Year of birth",
424 '#description' => 'Format is "YYYY"',
425 '#default_value' => !empty($form_state['values']['year_of_birth']) ? $form_state['values']['year_of_birth'] : '',
426 );
427 $form['next'] = array(
428 '#type' => 'submit',
429 '#value' => 'Next >>',
430 '#submit' => array('form_example_tutorial_8_next_submit'),
431 '#validate' => array('form_example_tutorial_8_next_validate'),
432 );
433 return $form;
434 }
435
439 function form_example_tutorial_8_page_two($form, &$form_state) {
440 $form['description'] = array(
441 '#type' => 'item',
442 '#title' => t('A basic multistep form (page 2)'),
443 );
444
445 $form['color'] = array(
446 '#type' => 'textfield',
447 '#title' => t('Favorite color'),
448 '#required' => TRUE,
449 '#default_value' => !empty($form_state['values']['color']) ? $form_state['values']['color'] : '',
450 );
451 $form['submit'] = array(
452 '#type' => 'submit',
453 '#value' => t('Submit'),
454 '#submit' => array('form_example_tutorial_8_page_two_submit'),
455 );
456 $form['back'] = array(
457 '#type' => 'submit',
458 '#value' => t('<< Back'),
459 '#submit' => array('form_example_tutorial_8_page_two_back'),
460 // We won't bother validating the required 'color' field, since they
461 // have to come back to this page to submit anyway.
462 '#limit_validation_errors' => array(),
463 );
464 return $form;
465 }
466
467
471 function form_example_tutorial_8_next_validate($form, &$form_state) {
472 $year_of_birth = $form_state['values']['year_of_birth'];
473 if ($year_of_birth && ($year_of_birth < 1900 || $year_of_birth > 2000)) {
474 form_set_error('year_of_birth', t('Enter a year between 1900 and 2000.'));
475 }
476 }
477
484 function form_example_tutorial_8_next_submit($form, &$form_state) {
485
486 // Values are saved for each page.
487 // to carry forward to subsequent pages in the form.
488 // and we tell FAPI to rebuild the form.
489 $form_state['page_values'][1] = $form_state['values'];
490
491 if (!empty($form_state['page_values'][2])) {
492 $form_state['values'] = $form_state['page_values'][2];
493 }
494
495 // When form rebuilds, it will look at this to figure which page to build.
496 $form_state['page_num'] = 2;
497 $form_state['rebuild'] = TRUE;
498 }
499
506 function form_example_tutorial_8_page_two_back($form, &$form_state) {
507 $form_state['values'] = $form_state['page_values'][1];
508 $form_state['page_num'] = 1;
509 $form_state['rebuild'] = TRUE;
510 }
511
518 function form_example_tutorial_8_page_two_submit($form, &$form_state) {
519 // Normally, some code would go here to alter the database with the data
520 // collected from the form. Instead sets a message with drupal_set_message()
521 // to validate that the code worked.
522 $page_one_values = $form_state['page_values'][1];
523 drupal_set_message(t('The form has been submitted. name="@first @last", year of birth=@year_of_birth',
524 array('@first' => $page_one_values['first'], '@last' => $page_one_values['last'], '@year_of_birth' => $page_one_values['year_of_birth'])));
525
526 if (!empty($page_one_values['first2'])) {
527 drupal_set_message(t('Second name: name="@first @last", year of birth=@year_of_birth',
528 array('@first' => $page_one_values['first2'], '@last' => $page_one_values['last2'], '@year_of_birth' => $page_one_values['year_of_birth2'])));
529 }
530 drupal_set_message(t('And the favorite color is @color', array('@color' => $form_state['values']['color'])));
531
532 // If we wanted to redirect on submission, set $form_state['redirect']. For
533 // simple redirects, the value can be a string of the path to redirect to. For
534 // example, to redirect to /node, one would specify the following:
535 //
536 // $form_state['redirect'] = 'node';
537 //
538 // For more complex redirects, this value can be set to an array of options to
539 // pass to drupal_goto(). For example, to redirect to /foo?bar=1#baz, one
540 // would specify the following:
541 //
542 // $form_state['redirect'] = array(
543 // 'foo',
544 // array(
545 // 'query' => array('bar' => 1),
546 // 'fragment' => 'baz',
547 // ),
548 // );
549 //
550 // The first element in the array is the path to redirect to, and the second
551 // element in the array is the array of options. For more information on the
552 // available options, see http://api.drupal.org/url.
553 }
554
556
571 function form_example_tutorial_9($form, &$form_state) {
572
573 // We will have many fields with the same name, so we need to be able to
574 // access the form hierarchically.
575 $form['#tree'] = TRUE;
576
577 $form['description'] = array(
578 '#type' => 'item',
579 '#title' => t('A form with dynamically added new fields'),
580 );
581
582 if (empty($form_state['num_names'])) {
583 $form_state['num_names'] = 1;
584 }
585
586 // Build the number of name fieldsets indicated by $form_state['num_names']
587 for ($i = 1; $i <= $form_state['num_names']; $i++) {
588 $form['name'][$i] = array(
589 '#type' => 'fieldset',
590 '#title' => t('Name #@num', array('@num' => $i)),
591 '#collapsible' => TRUE,
592 '#collapsed' => FALSE,
593 );
594
595 $form['name'][$i]['first'] = array(
596 '#type' => 'textfield',
597 '#title' => t('First name'),
598 '#description' => t("Enter first name."),
599 '#size' => 20,
600 '#maxlength' => 20,
601 '#required' => TRUE,
602 );
603 $form['name'][$i]['last'] = array(
604 '#type' => 'textfield',
605 '#title' => t('Enter Last name'),
606 '#required' => TRUE,
607 );
608 $form['name'][$i]['year_of_birth'] = array(
609 '#type' => 'textfield',
610 '#title' => t("Year of birth"),
611 '#description' => t('Format is "YYYY"'),
612 );
613 }
614 $form['submit'] = array(
615 '#type' => 'submit',
616 '#value' => 'Submit',
617 );
618
619 // Adds "Add another name" button
620 $form['add_name'] = array(
621 '#type' => 'submit',
622 '#value' => t('Add another name'),
623 '#submit' => array('form_example_tutorial_9_add_name'),
624 );
625
626 // If we have more than one name, this button allows removal of the
627 // last name.
628 if ($form_state['num_names'] > 1) {
629 $form['remove_name'] = array(
630 '#type' => 'submit',
631 '#value' => t('Remove latest name'),
632 '#submit' => array('form_example_tutorial_9_remove_name'),
633 // Since we are removing a name, don't validate until later.
634 '#limit_validation_errors' => array(),
635 );
636 }
637
638 return $form;
639 }
640
651 function form_example_tutorial_9_add_name($form, &$form_state) {
652 // Everything in $form_state is persistent, so we'll just use
653 // $form_state['add_name']
654 $form_state['num_names']++;
655
656 // Setting $form_state['rebuild'] = TRUE causes the form to be rebuilt again.
657 $form_state['rebuild'] = TRUE;
658 }
659
660
661 function form_example_tutorial_9_remove_name($form, &$form_state) {
662 if ($form_state['num_names'] > 1) {
663 $form_state['num_names']--;
664 }
665
666 // Setting $form_state['rebuild'] = TRUE causes the form to be rebuilt again.
667 $form_state['rebuild'] = TRUE;
668 }
669
676 function form_example_tutorial_9_validate($form, &$form_state) {
677
678 for ($i = 1; $i <= $form_state['num_names']; $i++) {
679 $year_of_birth = $form_state['values']['name'][$i]['year_of_birth'];
680
681 if ($year_of_birth && ($year_of_birth < 1900 || $year_of_birth > 2000)) {
682 form_set_error("name][$i][year_of_birth", t('Enter a year between 1900 and 2000.'));
683 }
684 }
685 }
686
690 function form_example_tutorial_9_submit($form, &$form_state) {
691 $output = t("Form 9 has been submitted.");
692 for ($i = 1; $i <= $form_state['num_names']; $i++) {
693 $output .= t("@num: @first @last (@date)... ", array('@num' => $i, '@first' => $form_state['values']['name'][$i]['first'],
694 '@last' => $form_state['values']['name'][$i]['last'], '@date' => $form_state['values']['name'][$i]['year_of_birth']));
695 }
696 drupal_set_message($output);
697 }
698
700
711 function form_example_tutorial_10($form_state) {
712 // If you are familiar with how browsers handle files, you know that
713 // enctype="multipart/form-data" is required. Drupal takes care of that, so
714 // you don't need to include it yourself.
715
716 $form['file'] = array(
717 '#type' => 'file',
718 '#title' => t('Image'),
719 '#description' => t('Upload a file, allowed extensions: jpg, jpeg, png, gif'),
720 );
721
722 $form['submit'] = array(
723 '#type' => 'submit',
724 '#value' => t('Submit'),
725 );
726
727 return $form;
728 }
729
733 function form_example_tutorial_10_validate($form, &$form_state) {
734 $file = file_save_upload('file', array(
735 'file_validate_is_image' => array(), // Validates file is really an image.
736 'file_validate_extensions' => array('png gif jpg jpeg'), // Validate extensions.
737 ));
738 // If the file passed validation:
739 if ($file) {
740 // Move the file, into the Drupal file system
741 if ($file = file_move($file, 'public://')) {
742 // Save the file for use in the submit handler.
743 $form_state['storage']['file'] = $file;
744 }
745 else {
746 form_set_error('file', t('Failed to write the uploaded file to the site\'s file folder.'));
747 }
748 }
749 else {
750 form_set_error('file', t('No file was uploaded.'));
751 }
752 }
753
757 function form_example_tutorial_10_submit($form, &$form_state) {
758 $file = $form_state['storage']['file'];
759 // We are done with the file, remove it from storage.
760 unset($form_state['storage']['file']);
761 // Make the storage of the file permanent
762 $file->status = FILE_STATUS_PERMANENT;
763 // Save file status.
764 file_save($file);
765 // Set a response to the user.
766 drupal_set_message(t('The form has been submitted and the image has been saved, filename: @filename.', array('@filename' => $file->filename)));
767 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
form_example_tutorial_10
form_example_tutorial_10($form_state)
Definition: form_example_tutorial.inc:711
form_example_tutorial_8_page_two
form_example_tutorial_8_page_two($form, &$form_state)
Definition: form_example_tutorial.inc:439
form_example_tutorial_9_submit
form_example_tutorial_9_submit($form, &$form_state)
Definition: form_example_tutorial.inc:690
form_example_tutorial_7_submit
form_example_tutorial_7_submit($form, &$form_state)
Definition: form_example_tutorial.inc:364
form_example_tutorial_10_validate
form_example_tutorial_10_validate($form, &$form_state)
Definition: form_example_tutorial.inc:733
FILE_STATUS_PERMANENT
const FILE_STATUS_PERMANENT
Definition: file.inc:70
form_example_tutorial_3
form_example_tutorial_3($form, &$form_state)
Definition: form_example_tutorial.inc:106
form_example_tutorial_8
form_example_tutorial_8($form, &$form_state)
Definition: form_example_tutorial.inc:392
form_example_tutorial
form_example_tutorial()
Definition: form_example_tutorial.inc:31
form_example_tutorial_10_submit
form_example_tutorial_10_submit($form, &$form_state)
Definition: form_example_tutorial.inc:757
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
form_example_tutorial_9_remove_name
form_example_tutorial_9_remove_name($form, &$form_state)
Definition: form_example_tutorial.inc:661
form_example_tutorial_5
form_example_tutorial_5($form, &$form_state)
Definition: form_example_tutorial.inc:189
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
file_move
file_move(stdClass $source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1035
$output
$output
Definition: authorize.php:93
form_example_tutorial_9
form_example_tutorial_9($form, &$form_state)
Definition: form_example_tutorial.inc:571
form_example_tutorial_7_validate
form_example_tutorial_7_validate($form, &$form_state)
Definition: form_example_tutorial.inc:351
form_example_tutorial_7
form_example_tutorial_7($form, &$form_state)
Definition: form_example_tutorial.inc:310
form_example_tutorial_6_validate
form_example_tutorial_6_validate($form, &$form_state)
Definition: form_example_tutorial.inc:290
file_save_upload
file_save_upload($source, $validators=array(), $destination=FALSE, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1437
form_example_tutorial_9_add_name
form_example_tutorial_9_add_name($form, &$form_state)
Definition: form_example_tutorial.inc:651
form_example_tutorial_1
form_example_tutorial_1($form, &$form_state)
Definition: form_example_tutorial.inc:48
form_example_tutorial_8_next_validate
form_example_tutorial_8_next_validate($form, &$form_state)
Definition: form_example_tutorial.inc:471
form_example_tutorial_4
form_example_tutorial_4($form, &$form_state)
Definition: form_example_tutorial.inc:141
form_example_tutorial_9_validate
form_example_tutorial_9_validate($form, &$form_state)
Definition: form_example_tutorial.inc:676
form_example_tutorial_8_page_two_submit
form_example_tutorial_8_page_two_submit($form, &$form_state)
Definition: form_example_tutorial.inc:518
form_example_tutorial_6
form_example_tutorial_6($form, &$form_state)
Definition: form_example_tutorial.inc:232
file_save
file_save(stdClass $file)
Definition: file.inc:599
form_example_tutorial_8_next_submit
form_example_tutorial_8_next_submit($form, &$form_state)
Definition: form_example_tutorial.inc:484
form_example_tutorial_2
form_example_tutorial_2($form, &$form_state)
Definition: form_example_tutorial.inc:71
form_example_tutorial_8_page_two_back
form_example_tutorial_8_page_two_back($form, &$form_state)
Definition: form_example_tutorial.inc:506
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/sqlite/query.inc Source File

  • includes
  • database
  • sqlite
query.inc
Go to the documentation of this file.
1 <?php
2
20 class InsertQuery_sqlite extends InsertQuery {
21
22 public function execute() {
23 if (!$this->preExecute()) {
24 return NULL;
25 }
26 if (count($this->insertFields)) {
27 return parent::execute();
28 }
29 else {
30 return $this->connection->query('INSERT INTO {' . $this->table . '} DEFAULT VALUES', array(), $this->queryOptions);
31 }
32 }
33
34 public function __toString() {
35 // Create a sanitized comment string to prepend to the query.
36 $comments = $this->connection->makeComment($this->comments);
37
38 // Produce as many generic placeholders as necessary.
39 $placeholders = array_fill(0, count($this->insertFields), '?');
40
41 // If we're selecting from a SelectQuery, finish building the query and
42 // pass it back, as any remaining options are irrelevant.
43 if (!empty($this->fromQuery)) {
44 $insert_fields_string = $this->insertFields ? ' (' . implode(', ', $this->insertFields) . ') ' : ' ';
45 return $comments . 'INSERT INTO {' . $this->table . '}' . $insert_fields_string . $this->fromQuery;
46 }
47
48 return $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $this->insertFields) . ') VALUES (' . implode(', ', $placeholders) . ')';
49 }
50
51 }
52
65 class UpdateQuery_sqlite extends UpdateQuery {
66 public function execute() {
67 if (!empty($this->queryOptions['sqlite_return_matched_rows'])) {
68 return parent::execute();
69 }
70
71 // Get the fields used in the update query.
72 $fields = $this->expressionFields + $this->fields;
73
74 // Add the inverse of the fields to the condition.
75 $condition = new DatabaseCondition('OR');
76 foreach ($fields as $field => $data) {
77 if (is_array($data)) {
78 // The field is an expression.
79 $condition->where($field . ' <> ' . $data['expression']);
80 $condition->isNull($field);
81 }
82 elseif (!isset($data)) {
83 // The field will be set to NULL.
84 $condition->isNotNull($field);
85 }
86 else {
87 $condition->condition($field, $data, '<>');
88 $condition->isNull($field);
89 }
90 }
91 if (count($condition)) {
92 $condition->compile($this->connection, $this);
93 $this->condition->where((string) $condition, $condition->arguments());
94 }
95 return parent::execute();
96 }
97
98 }
99
110 class DeleteQuery_sqlite extends DeleteQuery {
111 public function execute() {
112 if (!count($this->condition)) {
113 $total_rows = $this->connection->query('SELECT COUNT(*) FROM {' . $this->connection->escapeTable($this->table) . '}')->fetchField();
114 parent::execute();
115 return $total_rows;
116 }
117 else {
118 return parent::execute();
119 }
120 }
121 }
122
129 class TruncateQuery_sqlite extends TruncateQuery {
130 public function __toString() {
131 // Create a sanitized comment string to prepend to the query.
132 $comments = $this->connection->makeComment($this->comments);
133
134 return $comments . 'DELETE FROM {' . $this->connection->escapeTable($this->table) . '} ';
135 }
136 }
137
InsertQuery\$fromQuery
$fromQuery
Definition: query.inc:486
UpdateQuery\$condition
$condition
Definition: query.inc:993
InsertQuery_sqlite\__toString
__toString()
Definition: query.inc:34
UpdateQuery\$fields
$fields
Definition: query.inc:977
InsertQuery\preExecute
preExecute()
Definition: query.inc:698
DeleteQuery_sqlite
Definition: query.inc:110
TruncateQuery_sqlite
Definition: query.inc:129
InsertQuery_sqlite
Definition: query.inc:20
UpdateQuery\condition
condition($field, $value=NULL, $operator=NULL)
Definition: query.inc:1031
Query\$comments
$comments
Definition: query.inc:320
DatabaseCondition
Definition: query.inc:1652
UpdateQuery_sqlite
Definition: query.inc:65
InsertQuery_sqlite\execute
execute()
Definition: query.inc:22
InsertQuery
Definition: query.inc:441
DeleteQuery
Definition: query.inc:733
TruncateQuery
Definition: query.inc:887
UpdateQuery
Definition: query.inc:963
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: themes/bartik/templates/page.tpl.php Source File

  • themes
  • bartik
  • templates
page.tpl.php
Go to the documentation of this file.
1 <?php
2
87 ?>
88 <div id="page-wrapper"><div id="page">
89
90 <div id="header" class="<?php print $secondary_menu ? 'with-secondary-menu': 'without-secondary-menu'; ?>"><div class="section clearfix">
91
92 <?php if ($logo): ?>
93 <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
94 <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
95 </a>
96 <?php endif; ?>
97
98 <?php if ($site_name || $site_slogan): ?>
99 <div id="name-and-slogan"<?php if ($hide_site_name && $hide_site_slogan) { print ' class="element-invisible"'; } ?>>
100
101 <?php if ($site_name): ?>
102 <?php if ($title): ?>
103 <div id="site-name"<?php if ($hide_site_name) { print ' class="element-invisible"'; } ?>>
104 <strong>
105 <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
106 </strong>
107 </div>
108 <?php else: /* Use h1 when the content title is empty */ ?>
109 <h1 id="site-name"<?php if ($hide_site_name) { print ' class="element-invisible"'; } ?>>
110 <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
111 </h1>
112 <?php endif; ?>
113 <?php endif; ?>
114
115 <?php if ($site_slogan): ?>
116 <div id="site-slogan"<?php if ($hide_site_slogan) { print ' class="element-invisible"'; } ?>>
117 <?php print $site_slogan; ?>
118 </div>
119 <?php endif; ?>
120
121 </div> <!-- /#name-and-slogan -->
122 <?php endif; ?>
123
124 <?php print render($page['header']); ?>
125
126 <?php if ($main_menu): ?>
127 <div id="main-menu" class="navigation">
128 <?php print theme('links__system_main_menu', array(
129 'links' => $main_menu,
130 'attributes' => array(
131 'id' => 'main-menu-links',
132 'class' => array('links', 'clearfix'),
133 ),
134 'heading' => array(
135 'text' => t('Main menu'),
136 'level' => 'h2',
137 'class' => array('element-invisible'),
138 ),
139 )); ?>
140 </div> <!-- /#main-menu -->
141 <?php endif; ?>
142
143 <?php if ($secondary_menu): ?>
144 <div id="secondary-menu" class="navigation">
145 <?php print theme('links__system_secondary_menu', array(
146 'links' => $secondary_menu,
147 'attributes' => array(
148 'id' => 'secondary-menu-links',
149 'class' => array('links', 'inline', 'clearfix'),
150 ),
151 'heading' => array(
152 'text' => t('Secondary menu'),
153 'level' => 'h2',
154 'class' => array('element-invisible'),
155 ),
156 )); ?>
157 </div> <!-- /#secondary-menu -->
158 <?php endif; ?>
159
160 </div></div> <!-- /.section, /#header -->
161
162 <?php if ($messages): ?>
163 <div id="messages"><div class="section clearfix">
164 <?php print $messages; ?>
165 </div></div> <!-- /.section, /#messages -->
166 <?php endif; ?>
167
168 <?php if ($page['featured']): ?>
169 <div id="featured"><div class="section clearfix">
170 <?php print render($page['featured']); ?>
171 </div></div> <!-- /.section, /#featured -->
172 <?php endif; ?>
173
174 <div id="main-wrapper" class="clearfix"><div id="main" class="clearfix">
175
176 <?php if ($breadcrumb): ?>
177 <div id="breadcrumb"><?php print $breadcrumb; ?></div>
178 <?php endif; ?>
179
180 <?php if ($page['sidebar_first']): ?>
181 <div id="sidebar-first" class="column sidebar"><div class="section">
182 <?php print render($page['sidebar_first']); ?>
183 </div></div> <!-- /.section, /#sidebar-first -->
184 <?php endif; ?>
185
186 <div id="content" class="column"><div class="section">
187 <?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?>
188 <a id="main-content"></a>
189 <?php print render($title_prefix); ?>
190 <?php if ($title): ?>
191 <h1 class="title" id="page-title">
192 <?php print $title; ?>
193 </h1>
194 <?php endif; ?>
195 <?php print render($title_suffix); ?>
196 <?php if ($tabs): ?>
197 <div class="tabs">
198 <?php print render($tabs); ?>
199 </div>
200 <?php endif; ?>
201 <?php print render($page['help']); ?>
202 <?php if ($action_links): ?>
203 <ul class="action-links">
204 <?php print render($action_links); ?>
205 </ul>
206 <?php endif; ?>
207 <?php print render($page['content']); ?>
208 <?php print $feed_icons; ?>
209
210 </div></div> <!-- /.section, /#content -->
211
212 <?php if ($page['sidebar_second']): ?>
213 <div id="sidebar-second" class="column sidebar"><div class="section">
214 <?php print render($page['sidebar_second']); ?>
215 </div></div> <!-- /.section, /#sidebar-second -->
216 <?php endif; ?>
217
218 </div></div> <!-- /#main, /#main-wrapper -->
219
220 <?php if ($page['triptych_first'] || $page['triptych_middle'] || $page['triptych_last']): ?>
221 <div id="triptych-wrapper"><div id="triptych" class="clearfix">
222 <?php print render($page['triptych_first']); ?>
223 <?php print render($page['triptych_middle']); ?>
224 <?php print render($page['triptych_last']); ?>
225 </div></div> <!-- /#triptych, /#triptych-wrapper -->
226 <?php endif; ?>
227
228 <div id="footer-wrapper"><div class="section">
229
230 <?php if ($page['footer_firstcolumn'] || $page['footer_secondcolumn'] || $page['footer_thirdcolumn'] || $page['footer_fourthcolumn']): ?>
231 <div id="footer-columns" class="clearfix">
232 <?php print render($page['footer_firstcolumn']); ?>
233 <?php print render($page['footer_secondcolumn']); ?>
234 <?php print render($page['footer_thirdcolumn']); ?>
235 <?php print render($page['footer_fourthcolumn']); ?>
236 </div> <!-- /#footer-columns -->
237 <?php endif; ?>
238
239 <?php if ($page['footer']): ?>
240 <div id="footer" class="clearfix">
241 <?php print render($page['footer']); ?>
242 </div> <!-- /#footer -->
243 <?php endif; ?>
244
245 </div></div> <!-- /.section, /#footer-wrapper -->
246
247 </div></div> <!-- /#page, /#page-wrapper -->
$page
print $page
Definition: overlay.tpl.php:37
$secondary_menu
print $secondary_menu
Definition: page.tpl.php:90
name
print $forum name
Definition: forum-list.tpl.php:57
print
print
Definition: php-2.php:2
$feed_icons
print $feed_icons
Definition: page.tpl.php:135
$logo
print $logo
Definition: maintenance-page.tpl.php:33
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$site_slogan
if($site_slogan)($hide_site_slogan) print $site_slogan
Definition: maintenance-page.tpl.php:41
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
endif
endif
Definition: aggregator-item.tpl.php:31
$messages
print $messages
Definition: page.tpl.php:121
render
render(&$element)
Definition: common.inc:5988
$breadcrumb
print $breadcrumb
Definition: page.tpl.php:40
title
print $topic title
Definition: forum-topic-list.tpl.php:50
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
$site_name
print $site_name
Definition: maintenance-page.tpl.php:40
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/pgsql/schema.inc Source File

  • includes
  • database
  • pgsql
schema.inc
Go to the documentation of this file.
1 <?php
2
13 class DatabaseSchema_pgsql extends DatabaseSchema {
14
24 protected $tableInformation = array();
25
39 public function queryTableInformation($table) {
40 // Generate a key to reference this table's information on.
41 $key = $this->connection->prefixTables('{' . $table . '}');
42 if (!strpos($key, '.')) {
43 $key = 'public.' . $key;
44 }
45
46 if (!isset($this->tableInformation[$key])) {
47 // Split the key into schema and table for querying.
48 list($schema, $table_name) = explode('.', $key);
49 $table_information = (object) array(
50 'blob_fields' => array(),
51 'sequences' => array(),
52 );
53 // Don't use {} around information_schema.columns table.
54 $result = $this->connection->query("SELECT column_name, data_type, column_default FROM information_schema.columns WHERE table_schema = :schema AND table_name = :table AND (data_type = 'bytea' OR (numeric_precision IS NOT NULL AND column_default LIKE :default))", array(
55 ':schema' => $schema,
56 ':table' => $table_name,
57 ':default' => '%nextval%',
58 ));
59 foreach ($result as $column) {
60 if ($column->data_type == 'bytea') {
61 $table_information->blob_fields[$column->column_name] = TRUE;
62 }
63 elseif (preg_match("/nextval\('([^']+)'/", $column->column_default, $matches)) {
64 // We must know of any sequences in the table structure to help us
65 // return the last insert id. If there is more than 1 sequences the
66 // first one (index 0 of the sequences array) will be used.
67 $table_information->sequences[] = $matches[1];
68 $table_information->serial_fields[] = $column->column_name;
69 }
70 }
71 $this->tableInformation[$key] = $table_information;
72 }
73 return $this->tableInformation[$key];
74 }
75
89 public function queryFieldInformation($table, $field) {
90 $prefixInfo = $this->getPrefixInfo($table, TRUE);
91
92 // Split the key into schema and table for querying.
93 $schema = $prefixInfo['schema'];
94 $table_name = $prefixInfo['table'];
95
96 $field_information = (object) array(
97 'checks' => array(),
98 );
99 $checks = $this->connection->query("SELECT conname FROM pg_class cl INNER JOIN pg_constraint co ON co.conrelid = cl.oid INNER JOIN pg_attribute attr ON attr.attrelid = cl.oid AND attr.attnum = ANY (co.conkey) INNER JOIN pg_namespace ns ON cl.relnamespace = ns.oid WHERE co.contype = 'c' AND ns.nspname = :schema AND cl.relname = :table AND attr.attname = :column", array(
100 ':schema' => $schema,
101 ':table' => $table_name,
102 ':column' => $field,
103 ));
104 $field_information = $checks->fetchCol();
105
106 return $field_information;
107 }
108
119 protected function createTableSql($name, $table) {
120 $sql_fields = array();
121 foreach ($table['fields'] as $field_name => $field) {
122 $sql_fields[] = $this->createFieldSql($field_name, $this->processField($field));
123 }
124
125 $sql_keys = array();
126 if (isset($table['primary key']) && is_array($table['primary key'])) {
127 $sql_keys[] = 'PRIMARY KEY (' . implode(', ', $table['primary key']) . ')';
128 }
129 if (isset($table['unique keys']) && is_array($table['unique keys'])) {
130 foreach ($table['unique keys'] as $key_name => $key) {
131 $sql_keys[] = 'CONSTRAINT ' . $this->prefixNonTable($name, $key_name, 'key') . ' UNIQUE (' . implode(', ', $key) . ')';
132 }
133 }
134
135 $sql = "CREATE TABLE {" . $name . "} (\n\t";
136 $sql .= implode(",\n\t", $sql_fields);
137 if (count($sql_keys) > 0) {
138 $sql .= ",\n\t";
139 }
140 $sql .= implode(",\n\t", $sql_keys);
141 $sql .= "\n)";
142 $statements[] = $sql;
143
144 if (isset($table['indexes']) && is_array($table['indexes'])) {
145 foreach ($table['indexes'] as $key_name => $key) {
146 $statements[] = $this->_createIndexSql($name, $key_name, $key);
147 }
148 }
149
150 // Add table comment.
151 if (!empty($table['description'])) {
152 $statements[] = 'COMMENT ON TABLE {' . $name . '} IS ' . $this->prepareComment($table['description']);
153 }
154
155 // Add column comments.
156 foreach ($table['fields'] as $field_name => $field) {
157 if (!empty($field['description'])) {
158 $statements[] = 'COMMENT ON COLUMN {' . $name . '}.' . $field_name . ' IS ' . $this->prepareComment($field['description']);
159 }
160 }
161
162 return $statements;
163 }
164
177 protected function createFieldSql($name, $spec) {
178 $sql = $name . ' ' . $spec['pgsql_type'];
179
180 if (isset($spec['type']) && $spec['type'] == 'serial') {
181 unset($spec['not null']);
182 }
183
184 if (in_array($spec['pgsql_type'], array('varchar', 'character', 'text')) && isset($spec['length'])) {
185 $sql .= '(' . $spec['length'] . ')';
186 }
187 elseif (isset($spec['precision']) && isset($spec['scale'])) {
188 $sql .= '(' . $spec['precision'] . ', ' . $spec['scale'] . ')';
189 }
190
191 if (!empty($spec['unsigned'])) {
192 $sql .= " CHECK ($name >= 0)";
193 }
194
195 if (isset($spec['not null'])) {
196 if ($spec['not null']) {
197 $sql .= ' NOT NULL';
198 }
199 else {
200 $sql .= ' NULL';
201 }
202 }
203 if (isset($spec['default'])) {
204 $default = is_string($spec['default']) ? "'" . $spec['default'] . "'" : $spec['default'];
205 $sql .= " default $default";
206 }
207
208 return $sql;
209 }
210
217 protected function processField($field) {
218 if (!isset($field['size'])) {
219 $field['size'] = 'normal';
220 }
221
222 // Set the correct database-engine specific datatype.
223 // In case one is already provided, force it to lowercase.
224 if (isset($field['pgsql_type'])) {
225 $field['pgsql_type'] = drupal_strtolower($field['pgsql_type']);
226 }
227 else {
228 $map = $this->getFieldTypeMap();
229 $field['pgsql_type'] = $map[$field['type'] . ':' . $field['size']];
230 }
231
232 if (!empty($field['unsigned'])) {
233 // Unsigned datatypes are not supported in PostgreSQL 8.3. In MySQL,
234 // they are used to ensure a positive number is inserted and it also
235 // doubles the maximum integer size that can be stored in a field.
236 // The PostgreSQL schema in Drupal creates a check constraint
237 // to ensure that a value inserted is >= 0. To provide the extra
238 // integer capacity, here, we bump up the column field size.
239 if (!isset($map)) {
240 $map = $this->getFieldTypeMap();
241 }
242 switch ($field['pgsql_type']) {
243 case 'smallint':
244 $field['pgsql_type'] = $map['int:medium'];
245 break;
246 case 'int' :
247 $field['pgsql_type'] = $map['int:big'];
248 break;
249 }
250 }
251 if (isset($field['type']) && $field['type'] == 'serial') {
252 unset($field['not null']);
253 }
254 return $field;
255 }
256
261 function getFieldTypeMap() {
262 // Put :normal last so it gets preserved by array_flip. This makes
263 // it much easier for modules (such as schema.module) to map
264 // database types back into schema types.
265 // $map does not use drupal_static as its value never changes.
266 static $map = array(
267 'varchar:normal' => 'varchar',
268 'char:normal' => 'character',
269
270 'text:tiny' => 'text',
271 'text:small' => 'text',
272 'text:medium' => 'text',
273 'text:big' => 'text',
274 'text:normal' => 'text',
275
276 'int:tiny' => 'smallint',
277 'int:small' => 'smallint',
278 'int:medium' => 'int',
279 'int:big' => 'bigint',
280 'int:normal' => 'int',
281
282 'float:tiny' => 'real',
283 'float:small' => 'real',
284 'float:medium' => 'real',
285 'float:big' => 'double precision',
286 'float:normal' => 'real',
287
288 'numeric:normal' => 'numeric',
289
290 'blob:big' => 'bytea',
291 'blob:normal' => 'bytea',
292
293 'serial:tiny' => 'serial',
294 'serial:small' => 'serial',
295 'serial:medium' => 'serial',
296 'serial:big' => 'bigserial',
297 'serial:normal' => 'serial',
298 );
299 return $map;
300 }
301
302 protected function _createKeySql($fields) {
303 $return = array();
304 foreach ($fields as $field) {
305 if (is_array($field)) {
306 $return[] = 'substr(' . $field[0] . ', 1, ' . $field[1] . ')';
307 }
308 else {
309 $return[] = '"' . $field . '"';
310 }
311 }
312 return implode(', ', $return);
313 }
314
315 function renameTable($table, $new_name) {
316 if (!$this->tableExists($table)) {
317 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot rename %table to %table_new: table %table doesn't exist.", array('%table' => $table, '%table_new' => $new_name)));
318 }
319 if ($this->tableExists($new_name)) {
320 throw new DatabaseSchemaObjectExistsException(t("Cannot rename %table to %table_new: table %table_new already exists.", array('%table' => $table, '%table_new' => $new_name)));
321 }
322
323 // Get the schema and tablename for the old table.
324 $old_full_name = $this->connection->prefixTables('{' . $table . '}');
325 list($old_schema, $old_table_name) = strpos($old_full_name, '.') ? explode('.', $old_full_name) : array('public', $old_full_name);
326
327 // Index names and constraint names are global in PostgreSQL, so we need to
328 // rename them when renaming the table.
329 $indexes = $this->connection->query('SELECT indexname FROM pg_indexes WHERE schemaname = :schema AND tablename = :table', array(':schema' => $old_schema, ':table' => $old_table_name));
330 foreach ($indexes as $index) {
331 if (preg_match('/^' . preg_quote($old_full_name) . '_(.*)$/', $index->indexname, $matches)) {
332 $index_name = $matches[1];
333 $this->connection->query('ALTER INDEX ' . $index->indexname . ' RENAME TO {' . $new_name . '}_' . $index_name);
334 }
335 }
336
337 // Now rename the table.
338 // Ensure the new table name does not include schema syntax.
339 $prefixInfo = $this->getPrefixInfo($new_name);
340 $this->connection->query('ALTER TABLE {' . $table . '} RENAME TO ' . $prefixInfo['table']);
341 }
342
343 public function dropTable($table) {
344 if (!$this->tableExists($table)) {
345 return FALSE;
346 }
347
348 $this->connection->query('DROP TABLE {' . $table . '}');
349 return TRUE;
350 }
351
352 public function addField($table, $field, $spec, $new_keys = array()) {
353 if (!$this->tableExists($table)) {
354 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add field %table.%field: table doesn't exist.", array('%field' => $field, '%table' => $table)));
355 }
356 if ($this->fieldExists($table, $field)) {
357 throw new DatabaseSchemaObjectExistsException(t("Cannot add field %table.%field: field already exists.", array('%field' => $field, '%table' => $table)));
358 }
359
360 $fixnull = FALSE;
361 if (!empty($spec['not null']) && !isset($spec['default'])) {
362 $fixnull = TRUE;
363 $spec['not null'] = FALSE;
364 }
365 $query = 'ALTER TABLE {' . $table . '} ADD COLUMN ';
366 $query .= $this->createFieldSql($field, $this->processField($spec));
367 $this->connection->query($query);
368 if (isset($spec['initial'])) {
369 $this->connection->update($table)
370 ->fields(array($field => $spec['initial']))
371 ->execute();
372 }
373 if ($fixnull) {
374 $this->connection->query("ALTER TABLE {" . $table . "} ALTER $field SET NOT NULL");
375 }
376 if (isset($new_keys)) {
377 $this->_createKeys($table, $new_keys);
378 }
379 // Add column comment.
380 if (!empty($spec['description'])) {
381 $this->connection->query('COMMENT ON COLUMN {' . $table . '}.' . $field . ' IS ' . $this->prepareComment($spec['description']));
382 }
383 }
384
385 public function dropField($table, $field) {
386 if (!$this->fieldExists($table, $field)) {
387 return FALSE;
388 }
389
390 $this->connection->query('ALTER TABLE {' . $table . '} DROP COLUMN "' . $field . '"');
391 return TRUE;
392 }
393
394 public function fieldSetDefault($table, $field, $default) {
395 if (!$this->fieldExists($table, $field)) {
396 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
397 }
398
399 if (!isset($default)) {
400 $default = 'NULL';
401 }
402 else {
403 $default = is_string($default) ? "'$default'" : $default;
404 }
405
406 $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN "' . $field . '" SET DEFAULT ' . $default);
407 }
408
409 public function fieldSetNoDefault($table, $field) {
410 if (!$this->fieldExists($table, $field)) {
411 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
412 }
413
414 $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN "' . $field . '" DROP DEFAULT');
415 }
416
417 public function indexExists($table, $name) {
418 // Details http://www.postgresql.org/docs/8.3/interactive/view-pg-indexes.html
419 $index_name = '{' . $table . '}_' . $name . '_idx';
420 return (bool) $this->connection->query("SELECT 1 FROM pg_indexes WHERE indexname = '$index_name'")->fetchField();
421 }
422
431 protected function constraintExists($table, $name) {
432 $constraint_name = '{' . $table . '}_' . $name;
433 return (bool) $this->connection->query("SELECT 1 FROM pg_constraint WHERE conname = '$constraint_name'")->fetchField();
434 }
435
436 public function addPrimaryKey($table, $fields) {
437 if (!$this->tableExists($table)) {
438 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add primary key to table %table: table doesn't exist.", array('%table' => $table)));
439 }
440 if ($this->constraintExists($table, 'pkey')) {
441 throw new DatabaseSchemaObjectExistsException(t("Cannot add primary key to table %table: primary key already exists.", array('%table' => $table)));
442 }
443
444 $this->connection->query('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . implode(',', $fields) . ')');
445 }
446
447 public function dropPrimaryKey($table) {
448 if (!$this->constraintExists($table, 'pkey')) {
449 return FALSE;
450 }
451
452 $this->connection->query('ALTER TABLE {' . $table . '} DROP CONSTRAINT ' . $this->prefixNonTable($table, 'pkey'));
453 return TRUE;
454 }
455
456 function addUniqueKey($table, $name, $fields) {
457 if (!$this->tableExists($table)) {
458 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add unique key %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
459 }
460 if ($this->constraintExists($table, $name . '_key')) {
461 throw new DatabaseSchemaObjectExistsException(t("Cannot add unique key %name to table %table: unique key already exists.", array('%table' => $table, '%name' => $name)));
462 }
463
464 $this->connection->query('ALTER TABLE {' . $table . '} ADD CONSTRAINT "' . $this->prefixNonTable($table, $name, 'key') . '" UNIQUE (' . implode(',', $fields) . ')');
465 }
466
467 public function dropUniqueKey($table, $name) {
468 if (!$this->constraintExists($table, $name . '_key')) {
469 return FALSE;
470 }
471
472 $this->connection->query('ALTER TABLE {' . $table . '} DROP CONSTRAINT "' . $this->prefixNonTable($table, $name, 'key') . '"');
473 return TRUE;
474 }
475
476 public function addIndex($table, $name, $fields) {
477 if (!$this->tableExists($table)) {
478 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add index %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
479 }
480 if ($this->indexExists($table, $name)) {
481 throw new DatabaseSchemaObjectExistsException(t("Cannot add index %name to table %table: index already exists.", array('%table' => $table, '%name' => $name)));
482 }
483
484 $this->connection->query($this->_createIndexSql($table, $name, $fields));
485 }
486
487 public function dropIndex($table, $name) {
488 if (!$this->indexExists($table, $name)) {
489 return FALSE;
490 }
491
492 $this->connection->query('DROP INDEX ' . $this->prefixNonTable($table, $name, 'idx'));
493 return TRUE;
494 }
495
496 public function changeField($table, $field, $field_new, $spec, $new_keys = array()) {
497 if (!$this->fieldExists($table, $field)) {
498 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.", array('%table' => $table, '%name' => $field)));
499 }
500 if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
501 throw new DatabaseSchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
502 }
503
504 $spec = $this->processField($spec);
505
506 // We need to typecast the new column to best be able to transfer the data
507 // Schema_pgsql::getFieldTypeMap() will return possibilities that are not
508 // 'cast-able' such as 'serial' - so they need to be casted int instead.
509 if (in_array($spec['pgsql_type'], array('serial', 'bigserial', 'numeric'))) {
510 $typecast = 'int';
511 }
512 else {
513 $typecast = $spec['pgsql_type'];
514 }
515
516 if (in_array($spec['pgsql_type'], array('varchar', 'character', 'text')) && isset($spec['length'])) {
517 $typecast .= '(' . $spec['length'] . ')';
518 }
519 elseif (isset($spec['precision']) && isset($spec['scale'])) {
520 $typecast .= '(' . $spec['precision'] . ', ' . $spec['scale'] . ')';
521 }
522
523 // Remove old check constraints.
524 $field_info = $this->queryFieldInformation($table, $field);
525
526 foreach ($field_info as $check) {
527 $this->connection->query('ALTER TABLE {' . $table . '} DROP CONSTRAINT "' . $check . '"');
528 }
529
530 // Remove old default.
531 $this->fieldSetNoDefault($table, $field);
532
533 $this->connection->query('ALTER TABLE {' . $table . '} ALTER "' . $field . '" TYPE ' . $typecast . ' USING "' . $field . '"::' . $typecast);
534
535 if (isset($spec['not null'])) {
536 if ($spec['not null']) {
537 $nullaction = 'SET NOT NULL';
538 }
539 else {
540 $nullaction = 'DROP NOT NULL';
541 }
542 $this->connection->query('ALTER TABLE {' . $table . '} ALTER "' . $field . '" ' . $nullaction);
543 }
544
545 if (in_array($spec['pgsql_type'], array('serial', 'bigserial'))) {
546 // Type "serial" is known to PostgreSQL, but *only* during table creation,
547 // not when altering. Because of that, the sequence needs to be created
548 // and initialized by hand.
549 $seq = "{" . $table . "}_" . $field_new . "_seq";
550 $this->connection->query("CREATE SEQUENCE " . $seq);
551 // Set sequence to maximal field value to not conflict with existing
552 // entries.
553 $this->connection->query("SELECT setval('" . $seq . "', MAX(\"" . $field . '")) FROM {' . $table . "}");
554 $this->connection->query('ALTER TABLE {' . $table . '} ALTER "' . $field . '" SET DEFAULT nextval(\'' . $seq . '\')');
555 }
556
557 // Rename the column if necessary.
558 if ($field != $field_new) {
559 $this->connection->query('ALTER TABLE {' . $table . '} RENAME "' . $field . '" TO "' . $field_new . '"');
560 }
561
562 // Add unsigned check if necessary.
563 if (!empty($spec['unsigned'])) {
564 $this->connection->query('ALTER TABLE {' . $table . '} ADD CHECK ("' . $field_new . '" >= 0)');
565 }
566
567 // Add default if necessary.
568 if (isset($spec['default'])) {
569 $this->fieldSetDefault($table, $field_new, $spec['default']);
570 }
571
572 // Change description if necessary.
573 if (!empty($spec['description'])) {
574 $this->connection->query('COMMENT ON COLUMN {' . $table . '}."' . $field_new . '" IS ' . $this->prepareComment($spec['description']));
575 }
576
577 if (isset($new_keys)) {
578 $this->_createKeys($table, $new_keys);
579 }
580 }
581
582 protected function _createIndexSql($table, $name, $fields) {
583 $query = 'CREATE INDEX "' . $this->prefixNonTable($table, $name, 'idx') . '" ON {' . $table . '} (';
584 $query .= $this->_createKeySql($fields) . ')';
585 return $query;
586 }
587
588 protected function _createKeys($table, $new_keys) {
589 if (isset($new_keys['primary key'])) {
590 $this->addPrimaryKey($table, $new_keys['primary key']);
591 }
592 if (isset($new_keys['unique keys'])) {
593 foreach ($new_keys['unique keys'] as $name => $fields) {
594 $this->addUniqueKey($table, $name, $fields);
595 }
596 }
597 if (isset($new_keys['indexes'])) {
598 foreach ($new_keys['indexes'] as $name => $fields) {
599 $this->addIndex($table, $name, $fields);
600 }
601 }
602 }
603
607 public function getComment($table, $column = NULL) {
608 $info = $this->getPrefixInfo($table);
609 // Don' t use {} around pg_class, pg_attribute tables.
610 if (isset($column)) {
611 return $this->connection->query('SELECT col_description(oid, attnum) FROM pg_class, pg_attribute WHERE attrelid = oid AND relname = ? AND attname = ?', array($info['table'], $column))->fetchField();
612 }
613 else {
614 return $this->connection->query('SELECT obj_description(oid, ?) FROM pg_class WHERE relname = ?', array('pg_class', $info['table']))->fetchField();
615 }
616 }
617 }
DatabaseSchema_pgsql\addPrimaryKey
addPrimaryKey($table, $fields)
Definition: schema.inc:436
DatabaseSchema_pgsql\fieldSetNoDefault
fieldSetNoDefault($table, $field)
Definition: schema.inc:409
drupal_strtolower
drupal_strtolower($text)
Definition: unicode.inc:521
DatabaseSchema_pgsql\fieldSetDefault
fieldSetDefault($table, $field, $default)
Definition: schema.inc:394
DatabaseSchema_pgsql\_createIndexSql
_createIndexSql($table, $name, $fields)
Definition: schema.inc:582
DatabaseSchema_pgsql\$tableInformation
$tableInformation
Definition: schema.inc:24
DatabaseSchemaObjectExistsException
Definition: schema.inc:713
DatabaseSchema\prefixNonTable
prefixNonTable($table)
Definition: schema.inc:256
$name
print $name
Definition: profile-listing.tpl.php:43
DatabaseSchema
Definition: schema.inc:164
DatabaseSchema_pgsql\indexExists
indexExists($table, $name)
Definition: schema.inc:417
DatabaseSchema_pgsql\addField
addField($table, $field, $spec, $new_keys=array())
Definition: schema.inc:352
DatabaseSchema_pgsql\dropUniqueKey
dropUniqueKey($table, $name)
Definition: schema.inc:467
DatabaseSchema_pgsql\processField
processField($field)
Definition: schema.inc:217
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$info
$info
Definition: color.inc:6
DatabaseSchemaObjectDoesNotExistException
Definition: schema.inc:722
DatabaseSchema_pgsql\addUniqueKey
addUniqueKey($table, $name, $fields)
Definition: schema.inc:456
DatabaseSchema_pgsql\changeField
changeField($table, $field, $field_new, $spec, $new_keys=array())
Definition: schema.inc:496
DatabaseSchema_pgsql\dropPrimaryKey
dropPrimaryKey($table)
Definition: schema.inc:447
DatabaseSchema_pgsql\createFieldSql
createFieldSql($name, $spec)
Definition: schema.inc:177
DatabaseSchema_pgsql\queryTableInformation
queryTableInformation($table)
Definition: schema.inc:39
DatabaseSchema_pgsql\dropField
dropField($table, $field)
Definition: schema.inc:385
DatabaseSchema_pgsql\_createKeys
_createKeys($table, $new_keys)
Definition: schema.inc:588
DatabaseSchema_pgsql\createTableSql
createTableSql($name, $table)
Definition: schema.inc:119
DatabaseSchema_pgsql\renameTable
renameTable($table, $new_name)
Definition: schema.inc:315
DatabaseSchema\getPrefixInfo
getPrefixInfo($table= 'default', $add_prefix=TRUE)
Definition: schema.inc:227
DatabaseSchema_pgsql\dropTable
dropTable($table)
Definition: schema.inc:343
DatabaseSchema_pgsql\addIndex
addIndex($table, $name, $fields)
Definition: schema.inc:476
DatabaseSchema_pgsql\_createKeySql
_createKeySql($fields)
Definition: schema.inc:302
DatabaseSchema\tableExists
tableExists($table)
Definition: schema.inc:310
DatabaseSchema\prepareComment
prepareComment($comment, $length=NULL)
Definition: schema.inc:701
DatabaseSchema_pgsql\dropIndex
dropIndex($table, $name)
Definition: schema.inc:487
DatabaseSchema\fieldExists
fieldExists($table, $column)
Definition: schema.inc:354
DatabaseSchema_pgsql\queryFieldInformation
queryFieldInformation($table, $field)
Definition: schema.inc:89
DatabaseSchema_pgsql
Definition: schema.inc:13
DatabaseSchema_pgsql\getFieldTypeMap
getFieldTypeMap()
Definition: schema.inc:261
DatabaseSchema_pgsql\constraintExists
constraintExists($table, $name)
Definition: schema.inc:431
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/batch.queue.inc Source File

  • includes
batch.queue.inc
Go to the documentation of this file.
1 <?php
2
19 class BatchQueue extends SystemQueue {
20
28 public function claimItem($lease_time = 0) {
29 $item = db_query_range('SELECT data, item_id FROM {queue} q WHERE name = :name ORDER BY item_id ASC', 0, 1, array(':name' => $this->name))->fetchObject();
30 if ($item) {
31 $item->data = unserialize($item->data);
32 return $item;
33 }
34 return FALSE;
35 }
36
42 public function getAllItems() {
43 $result = array();
44 $items = db_query('SELECT data FROM {queue} q WHERE name = :name ORDER BY item_id ASC', array(':name' => $this->name))->fetchAll();
45 foreach ($items as $item) {
46 $result[] = unserialize($item->data);
47 }
48 return $result;
49 }
50 }
51
55 class BatchMemoryQueue extends MemoryQueue {
56
64 public function claimItem($lease_time = 0) {
65 if (!empty($this->queue)) {
66 reset($this->queue);
67 return current($this->queue);
68 }
69 return FALSE;
70 }
71
77 public function getAllItems() {
78 $result = array();
79 foreach ($this->queue as $item) {
80 $result[] = $item->data;
81 }
82 return $result;
83 }
84 }
MemoryQueue
Definition: system.queue.inc:296
name
print $forum name
Definition: forum-list.tpl.php:57
BatchMemoryQueue\getAllItems
getAllItems()
Definition: batch.queue.inc:77
BatchMemoryQueue\claimItem
claimItem($lease_time=0)
Definition: batch.queue.inc:64
SystemQueue
Definition: system.queue.inc:198
BatchQueue\getAllItems
getAllItems()
Definition: batch.queue.inc:42
BatchQueue\claimItem
claimItem($lease_time=0)
Definition: batch.queue.inc:28
BatchQueue
Definition: batch.queue.inc:19
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
BatchMemoryQueue
Definition: batch.queue.inc:55
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/form.inc Source File

  • includes
form.inc
Go to the documentation of this file.
1 <?php
123 function drupal_get_form($form_id) {
124 $form_state = array();
125
126 $args = func_get_args();
127 // Remove $form_id from the arguments.
128 array_shift($args);
129 $form_state['build_info']['args'] = $args;
130
131 return drupal_build_form($form_id, $form_state);
132 }
133
308 function drupal_build_form($form_id, &$form_state) {
309 // Ensure some defaults; if already set they will not be overridden.
310 $form_state += form_state_defaults();
311
312 if (!isset($form_state['input'])) {
313 $form_state['input'] = $form_state['method'] == 'get' ? $_GET : $_POST;
314 }
315
316 if (isset($_SESSION['batch_form_state'])) {
317 // We've been redirected here after a batch processing. The form has
318 // already been processed, but needs to be rebuilt. See _batch_finished().
319 $form_state = $_SESSION['batch_form_state'];
320 unset($_SESSION['batch_form_state']);
321 return drupal_rebuild_form($form_id, $form_state);
322 }
323
324 // If the incoming input contains a form_build_id, we'll check the cache for a
325 // copy of the form in question. If it's there, we don't have to rebuild the
326 // form to proceed. In addition, if there is stored form_state data from a
327 // previous step, we'll retrieve it so it can be passed on to the form
328 // processing code.
329 $check_cache = isset($form_state['input']['form_id']) && $form_state['input']['form_id'] == $form_id && !empty($form_state['input']['form_build_id']);
330 if ($check_cache) {
331 $form = form_get_cache($form_state['input']['form_build_id'], $form_state);
332 }
333
334 // If the previous bit of code didn't result in a populated $form object, we
335 // are hitting the form for the first time and we need to build it from
336 // scratch.
337 if (!isset($form)) {
338 // If we attempted to serve the form from cache, uncacheable $form_state
339 // keys need to be removed after retrieving and preparing the form, except
340 // any that were already set prior to retrieving the form.
341 if ($check_cache) {
342 $form_state_before_retrieval = $form_state;
343 }
344
345 $form = drupal_retrieve_form($form_id, $form_state);
346 drupal_prepare_form($form_id, $form, $form_state);
347
348 // form_set_cache() removes uncacheable $form_state keys defined in
349 // form_state_keys_no_cache() in order for multi-step forms to work
350 // properly. This means that form processing logic for single-step forms
351 // using $form_state['cache'] may depend on data stored in those keys
352 // during drupal_retrieve_form()/drupal_prepare_form(), but form
353 // processing should not depend on whether the form is cached or not, so
354 // $form_state is adjusted to match what it would be after a
355 // form_set_cache()/form_get_cache() sequence. These exceptions are
356 // allowed to survive here:
357 // - always_process: Does not make sense in conjunction with form caching
358 // in the first place, since passing form_build_id as a GET parameter is
359 // not desired.
360 // - temporary: Any assigned data is expected to survives within the same
361 // page request.
362 if ($check_cache) {
363 $uncacheable_keys = array_flip(array_diff(form_state_keys_no_cache(), array('always_process', 'temporary')));
364 $form_state = array_diff_key($form_state, $uncacheable_keys);
365 $form_state += $form_state_before_retrieval;
366 }
367 }
368
369 // Now that we have a constructed form, process it. This is where:
370 // - Element #process functions get called to further refine $form.
371 // - User input, if any, gets incorporated in the #value property of the
372 // corresponding elements and into $form_state['values'].
373 // - Validation and submission handlers are called.
374 // - If this submission is part of a multistep workflow, the form is rebuilt
375 // to contain the information of the next step.
376 // - If necessary, the form and form state are cached or re-cached, so that
377 // appropriate information persists to the next page request.
378 // All of the handlers in the pipeline receive $form_state by reference and
379 // can use it to know or update information about the state of the form.
380 drupal_process_form($form_id, $form, $form_state);
381
382 // If this was a successful submission of a single-step form or the last step
383 // of a multi-step form, then drupal_process_form() issued a redirect to
384 // another page, or back to this page, but as a new request. Therefore, if
385 // we're here, it means that this is either a form being viewed initially
386 // before any user input, or there was a validation error requiring the form
387 // to be re-displayed, or we're in a multi-step workflow and need to display
388 // the form's next step. In any case, we have what we need in $form, and can
389 // return it for rendering.
390 return $form;
391 }
392
396 function form_state_defaults() {
397 return array(
398 'rebuild' => FALSE,
399 'rebuild_info' => array(),
400 'redirect' => NULL,
401 // @todo 'args' is usually set, so no other default 'build_info' keys are
402 // appended via += form_state_defaults().
403 'build_info' => array(
404 'args' => array(),
405 'files' => array(),
406 ),
407 'temporary' => array(),
408 'submitted' => FALSE,
409 'executed' => FALSE,
410 'programmed' => FALSE,
411 'programmed_bypass_access_check' => TRUE,
412 'cache'=> FALSE,
413 'method' => 'post',
414 'groups' => array(),
415 'buttons' => array(),
416 );
417 }
418
458 function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) {
459 $form = drupal_retrieve_form($form_id, $form_state);
460
461 // If only parts of the form will be returned to the browser (e.g., Ajax or
462 // RIA clients), re-use the old #build_id to not require client-side code to
463 // manually update the hidden 'build_id' input element.
464 // Otherwise, a new #build_id is generated, to not clobber the previous
465 // build's data in the form cache; also allowing the user to go back to an
466 // earlier build, make changes, and re-submit.
467 // @see drupal_prepare_form()
468 if (isset($old_form['#build_id']) && !empty($form_state['rebuild_info']['copy']['#build_id'])) {
469 $form['#build_id'] = $old_form['#build_id'];
470 }
471 else {
472 $form['#build_id'] = 'form-' . drupal_random_key();
473 }
474
475 // #action defaults to request_uri(), but in case of Ajax and other partial
476 // rebuilds, the form is submitted to an alternate URL, and the original
477 // #action needs to be retained.
478 if (isset($old_form['#action']) && !empty($form_state['rebuild_info']['copy']['#action'])) {
479 $form['#action'] = $old_form['#action'];
480 }
481
482 drupal_prepare_form($form_id, $form, $form_state);
483
484 // Caching is normally done in drupal_process_form(), but what needs to be
485 // cached is the $form structure before it passes through form_builder(),
486 // so we need to do it here.
487 // @todo For Drupal 8, find a way to avoid this code duplication.
488 if (empty($form_state['no_cache'])) {
489 form_set_cache($form['#build_id'], $form, $form_state);
490 }
491
492 // Clear out all group associations as these might be different when
493 // re-rendering the form.
494 $form_state['groups'] = array();
495
496 // Return a fully built form that is ready for rendering.
497 return form_builder($form_id, $form, $form_state);
498 }
499
503 function form_get_cache($form_build_id, &$form_state) {
504 if ($cached = cache_get('form_' . $form_build_id, 'cache_form')) {
505 $form = $cached->data;
506
507 global $user;
508 if ((isset($form['#cache_token']) && drupal_valid_token($form['#cache_token'])) || (!isset($form['#cache_token']) && !$user->uid)) {
509 if ($cached = cache_get('form_state_' . $form_build_id, 'cache_form')) {
510 // Re-populate $form_state for subsequent rebuilds.
511 $form_state = $cached->data + $form_state;
512
513 // If the original form is contained in include files, load the files.
514 // @see form_load_include()
515 $form_state['build_info'] += array('files' => array());
516 foreach ($form_state['build_info']['files'] as $file) {
517 if (is_array($file)) {
518 $file += array('type' => 'inc', 'name' => $file['module']);
519 module_load_include($file['type'], $file['module'], $file['name']);
520 }
521 elseif (file_exists($file)) {
522 require_once DRUPAL_ROOT . '/' . $file;
523 }
524 }
525 }
526 return $form;
527 }
528 }
529 }
530
534 function form_set_cache($form_build_id, $form, $form_state) {
535 // 6 hours cache life time for forms should be plenty.
536 $expire = 21600;
537
538 // Cache form structure.
539 if (isset($form)) {
540 if ($GLOBALS['user']->uid) {
541 $form['#cache_token'] = drupal_get_token();
542 }
543 cache_set('form_' . $form_build_id, $form, 'cache_form', REQUEST_TIME + $expire);
544 }
545
546 // Cache form state.
547 if ($data = array_diff_key($form_state, array_flip(form_state_keys_no_cache()))) {
548 cache_set('form_state_' . $form_build_id, $data, 'cache_form', REQUEST_TIME + $expire);
549 }
550 }
551
555 function form_state_keys_no_cache() {
556 return array(
557 // Public properties defined by form constructors and form handlers.
558 'always_process',
559 'must_validate',
560 'rebuild',
561 'rebuild_info',
562 'redirect',
563 'no_redirect',
564 'temporary',
565 // Internal properties defined by form processing.
566 'buttons',
567 'triggering_element',
568 'clicked_button',
569 'complete form',
570 'groups',
571 'input',
572 'method',
573 'submit_handlers',
574 'submitted',
575 'executed',
576 'validate_handlers',
577 'values',
578 );
579 }
580
612 function form_load_include(&$form_state, $type, $module, $name = NULL) {
613 if (!isset($name)) {
614 $name = $module;
615 }
616 if (!isset($form_state['build_info']['files']["$module:$name.$type"])) {
617 // Only add successfully included files to the form state.
618 if ($result = module_load_include($type, $module, $name)) {
619 $form_state['build_info']['files']["$module:$name.$type"] = array(
620 'type' => $type,
621 'module' => $module,
622 'name' => $name,
623 );
624 return $result;
625 }
626 }
627 return FALSE;
628 }
629
685 function drupal_form_submit($form_id, &$form_state) {
686 if (!isset($form_state['build_info']['args'])) {
687 $args = func_get_args();
688 array_shift($args);
689 array_shift($args);
690 $form_state['build_info']['args'] = $args;
691 }
692 // Merge in default values.
693 $form_state += form_state_defaults();
694
695 // Populate $form_state['input'] with the submitted values before retrieving
696 // the form, to be consistent with what drupal_build_form() does for
697 // non-programmatic submissions (form builder functions may expect it to be
698 // there).
699 $form_state['input'] = $form_state['values'];
700
701 $form_state['programmed'] = TRUE;
702 $form = drupal_retrieve_form($form_id, $form_state);
703 // Programmed forms are always submitted.
704 $form_state['submitted'] = TRUE;
705
706 // Reset form validation.
707 $form_state['must_validate'] = TRUE;
708 form_clear_error();
709
710 drupal_prepare_form($form_id, $form, $form_state);
711 drupal_process_form($form_id, $form, $form_state);
712 }
713
728 function drupal_retrieve_form($form_id, &$form_state) {
729 $forms = &drupal_static(__FUNCTION__);
730
731 // Record the $form_id.
732 $form_state['build_info']['form_id'] = $form_id;
733
734 // Record the filepath of the include file containing the original form, so
735 // the form builder callbacks can be loaded when the form is being rebuilt
736 // from cache on a different path (such as 'system/ajax'). See
737 // form_get_cache(). Don't do this in maintenance mode as Drupal may not be
738 // fully bootstrapped (i.e. during installation) in which case
739 // menu_get_item() is not available.
740 if (!isset($form_state['build_info']['files']['menu']) && !defined('MAINTENANCE_MODE')) {
741 $item = menu_get_item();
742 if (!empty($item['include_file'])) {
743 // Do not use form_load_include() here, as the file is already loaded.
744 // Anyway, form_get_cache() is able to handle filepaths too.
745 $form_state['build_info']['files']['menu'] = $item['include_file'];
746 }
747 }
748
749 // We save two copies of the incoming arguments: one for modules to use
750 // when mapping form ids to constructor functions, and another to pass to
751 // the constructor function itself.
752 $args = $form_state['build_info']['args'];
753
754 // We first check to see if there's a function named after the $form_id.
755 // If there is, we simply pass the arguments on to it to get the form.
756 if (!function_exists($form_id)) {
757 // In cases where many form_ids need to share a central constructor function,
758 // such as the node editing form, modules can implement hook_forms(). It
759 // maps one or more form_ids to the correct constructor functions.
760 //
761 // We cache the results of that hook to save time, but that only works
762 // for modules that know all their form_ids in advance. (A module that
763 // adds a small 'rate this comment' form to each comment in a list
764 // would need a unique form_id for each one, for example.)
765 //
766 // So, we call the hook if $forms isn't yet populated, OR if it doesn't
767 // yet have an entry for the requested form_id.
768 if (!isset($forms) || !isset($forms[$form_id])) {
769 $forms = module_invoke_all('forms', $form_id, $args);
770 }
771 $form_definition = $forms[$form_id];
772 if (isset($form_definition['callback arguments'])) {
773 $args = array_merge($form_definition['callback arguments'], $args);
774 }
775 if (isset($form_definition['callback'])) {
776 $callback = $form_definition['callback'];
777 $form_state['build_info']['base_form_id'] = $callback;
778 }
779 // In case $form_state['wrapper_callback'] is not defined already, we also
780 // allow hook_forms() to define one.
781 if (!isset($form_state['wrapper_callback']) && isset($form_definition['wrapper_callback'])) {
782 $form_state['wrapper_callback'] = $form_definition['wrapper_callback'];
783 }
784 }
785
786 $form = array();
787 // We need to pass $form_state by reference in order for forms to modify it,
788 // since call_user_func_array() requires that referenced variables are passed
789 // explicitly.
790 $args = array_merge(array($form, &$form_state), $args);
791
792 // When the passed $form_state (not using drupal_get_form()) defines a
793 // 'wrapper_callback', then it requests to invoke a separate (wrapping) form
794 // builder function to pre-populate the $form array with form elements, which
795 // the actual form builder function ($callback) expects. This allows for
796 // pre-populating a form with common elements for certain forms, such as
797 // back/next/save buttons in multi-step form wizards. See drupal_build_form().
798 if (isset($form_state['wrapper_callback']) && function_exists($form_state['wrapper_callback'])) {
799 $form = call_user_func_array($form_state['wrapper_callback'], $args);
800 // Put the prepopulated $form into $args.
801 $args[0] = $form;
802 }
803
804 // If $callback was returned by a hook_forms() implementation, call it.
805 // Otherwise, call the function named after the form id.
806 $form = call_user_func_array(isset($callback) ? $callback : $form_id, $args);
807 $form['#form_id'] = $form_id;
808
809 return $form;
810 }
811
829 function drupal_process_form($form_id, &$form, &$form_state) {
830 $form_state['values'] = array();
831
832 // With $_GET, these forms are always submitted if requested.
833 if ($form_state['method'] == 'get' && !empty($form_state['always_process'])) {
834 if (!isset($form_state['input']['form_build_id'])) {
835 $form_state['input']['form_build_id'] = $form['#build_id'];
836 }
837 if (!isset($form_state['input']['form_id'])) {
838 $form_state['input']['form_id'] = $form_id;
839 }
840 if (!isset($form_state['input']['form_token']) && isset($form['#token'])) {
841 $form_state['input']['form_token'] = drupal_get_token($form['#token']);
842 }
843 }
844
845 // form_builder() finishes building the form by calling element #process
846 // functions and mapping user input, if any, to #value properties, and also
847 // storing the values in $form_state['values']. We need to retain the
848 // unprocessed $form in case it needs to be cached.
849 $unprocessed_form = $form;
850 $form = form_builder($form_id, $form, $form_state);
851
852 // Only process the input if we have a correct form submission.
853 if ($form_state['process_input']) {
854 drupal_validate_form($form_id, $form, $form_state);
855
856 // drupal_html_id() maintains a cache of element IDs it has seen,
857 // so it can prevent duplicates. We want to be sure we reset that
858 // cache when a form is processed, so scenarios that result in
859 // the form being built behind the scenes and again for the
860 // browser don't increment all the element IDs needlessly.
861 if (!form_get_errors()) {
862 // In case of errors, do not break HTML IDs of other forms.
863 drupal_static_reset('drupal_html_id');
864 }
865
866 if ($form_state['submitted'] && !form_get_errors() && !$form_state['rebuild']) {
867 // Execute form submit handlers.
868 form_execute_handlers('submit', $form, $form_state);
869
870 // We'll clear out the cached copies of the form and its stored data
871 // here, as we've finished with them. The in-memory copies are still
872 // here, though.
873 if (!variable_get('cache', 0) && !empty($form_state['values']['form_build_id'])) {
874 cache_clear_all('form_' . $form_state['values']['form_build_id'], 'cache_form');
875 cache_clear_all('form_state_' . $form_state['values']['form_build_id'], 'cache_form');
876 }
877
878 // If batches were set in the submit handlers, we process them now,
879 // possibly ending execution. We make sure we do not react to the batch
880 // that is already being processed (if a batch operation performs a
881 // drupal_form_submit).
882 if ($batch =& batch_get() && !isset($batch['current_set'])) {
883 // Store $form_state information in the batch definition.
884 // We need the full $form_state when either:
885 // - Some submit handlers were saved to be called during batch
886 // processing. See form_execute_handlers().
887 // - The form is multistep.
888 // In other cases, we only need the information expected by
889 // drupal_redirect_form().
890 if ($batch['has_form_submits'] || !empty($form_state['rebuild'])) {
891 $batch['form_state'] = $form_state;
892 }
893 else {
894 $batch['form_state'] = array_intersect_key($form_state, array_flip(array('programmed', 'rebuild', 'storage', 'no_redirect', 'redirect')));
895 }
896
897 $batch['progressive'] = !$form_state['programmed'];
898 batch_process();
899
900 // Execution continues only for programmatic forms.
901 // For 'regular' forms, we get redirected to the batch processing
902 // page. Form redirection will be handled in _batch_finished(),
903 // after the batch is processed.
904 }
905
906 // Set a flag to indicate the the form has been processed and executed.
907 $form_state['executed'] = TRUE;
908
909 // Redirect the form based on values in $form_state.
910 drupal_redirect_form($form_state);
911 }
912
913 // Don't rebuild or cache form submissions invoked via drupal_form_submit().
914 if (!empty($form_state['programmed'])) {
915 return;
916 }
917
918 // If $form_state['rebuild'] has been set and input has been processed
919 // without validation errors, we are in a multi-step workflow that is not
920 // yet complete. A new $form needs to be constructed based on the changes
921 // made to $form_state during this request. Normally, a submit handler sets
922 // $form_state['rebuild'] if a fully executed form requires another step.
923 // However, for forms that have not been fully executed (e.g., Ajax
924 // submissions triggered by non-buttons), there is no submit handler to set
925 // $form_state['rebuild']. It would not make sense to redisplay the
926 // identical form without an error for the user to correct, so we also
927 // rebuild error-free non-executed forms, regardless of
928 // $form_state['rebuild'].
929 // @todo D8: Simplify this logic; considering Ajax and non-HTML front-ends,
930 // along with element-level #submit properties, it makes no sense to have
931 // divergent form execution based on whether the triggering element has
932 // #executes_submit_callback set to TRUE.
933 if (($form_state['rebuild'] || !$form_state['executed']) && !form_get_errors()) {
934 // Form building functions (e.g., _form_builder_handle_input_element())
935 // may use $form_state['rebuild'] to determine if they are running in the
936 // context of a rebuild, so ensure it is set.
937 $form_state['rebuild'] = TRUE;
938 $form = drupal_rebuild_form($form_id, $form_state, $form);
939 }
940 }
941
942 // After processing the form, the form builder or a #process callback may
943 // have set $form_state['cache'] to indicate that the form and form state
944 // shall be cached. But the form may only be cached if the 'no_cache' property
945 // is not set to TRUE. Only cache $form as it was prior to form_builder(),
946 // because form_builder() must run for each request to accommodate new user
947 // input. Rebuilt forms are not cached here, because drupal_rebuild_form()
948 // already takes care of that.
949 if (!$form_state['rebuild'] && $form_state['cache'] && empty($form_state['no_cache'])) {
950 form_set_cache($form['#build_id'], $unprocessed_form, $form_state);
951 }
952 }
953
969 function drupal_prepare_form($form_id, &$form, &$form_state) {
970 global $user;
971
972 $form['#type'] = 'form';
973 $form_state['programmed'] = isset($form_state['programmed']) ? $form_state['programmed'] : FALSE;
974
975 // Fix the form method, if it is 'get' in $form_state, but not in $form.
976 if ($form_state['method'] == 'get' && !isset($form['#method'])) {
977 $form['#method'] = 'get';
978 }
979
980 // Generate a new #build_id for this form, if none has been set already. The
981 // form_build_id is used as key to cache a particular build of the form. For
982 // multi-step forms, this allows the user to go back to an earlier build, make
983 // changes, and re-submit.
984 // @see drupal_build_form()
985 // @see drupal_rebuild_form()
986 if (!isset($form['#build_id'])) {
987 $form['#build_id'] = 'form-' . drupal_random_key();
988 }
989 $form['form_build_id'] = array(
990 '#type' => 'hidden',
991 '#value' => $form['#build_id'],
992 '#id' => $form['#build_id'],
993 '#name' => 'form_build_id',
994 // Form processing and validation requires this value, so ensure the
995 // submitted form value appears literally, regardless of custom #tree
996 // and #parents being set elsewhere.
997 '#parents' => array('form_build_id'),
998 );
999
1000 // Add a token, based on either #token or form_id, to any form displayed to
1001 // authenticated users. This ensures that any submitted form was actually
1002 // requested previously by the user and protects against cross site request
1003 // forgeries.
1004 // This does not apply to programmatically submitted forms. Furthermore, since
1005 // tokens are session-bound and forms displayed to anonymous users are very
1006 // likely cached, we cannot assign a token for them.
1007 // During installation, there is no $user yet.
1008 if (!empty($user->uid) && !$form_state['programmed']) {
1009 // Form constructors may explicitly set #token to FALSE when cross site
1010 // request forgery is irrelevant to the form, such as search forms.
1011 if (isset($form['#token']) && $form['#token'] === FALSE) {
1012 unset($form['#token']);
1013 }
1014 // Otherwise, generate a public token based on the form id.
1015 else {
1016 $form['#token'] = $form_id;
1017 $form['form_token'] = array(
1018 '#id' => drupal_html_id('edit-' . $form_id . '-form-token'),
1019 '#type' => 'token',
1020 '#default_value' => drupal_get_token($form['#token']),
1021 // Form processing and validation requires this value, so ensure the
1022 // submitted form value appears literally, regardless of custom #tree
1023 // and #parents being set elsewhere.
1024 '#parents' => array('form_token'),
1025 );
1026 }
1027 }
1028
1029 if (isset($form_id)) {
1030 $form['form_id'] = array(
1031 '#type' => 'hidden',
1032 '#value' => $form_id,
1033 '#id' => drupal_html_id("edit-$form_id"),
1034 // Form processing and validation requires this value, so ensure the
1035 // submitted form value appears literally, regardless of custom #tree
1036 // and #parents being set elsewhere.
1037 '#parents' => array('form_id'),
1038 );
1039 }
1040 if (!isset($form['#id'])) {
1041 $form['#id'] = drupal_html_id($form_id);
1042 }
1043
1044 $form += element_info('form');
1045 $form += array('#tree' => FALSE, '#parents' => array());
1046
1047 if (!isset($form['#validate'])) {
1048 // Ensure that modules can rely on #validate being set.
1049 $form['#validate'] = array();
1050 // Check for a handler specific to $form_id.
1051 if (function_exists($form_id . '_validate')) {
1052 $form['#validate'][] = $form_id . '_validate';
1053 }
1054 // Otherwise check whether this is a shared form and whether there is a
1055 // handler for the shared $form_id.
1056 elseif (isset($form_state['build_info']['base_form_id']) && function_exists($form_state['build_info']['base_form_id'] . '_validate')) {
1057 $form['#validate'][] = $form_state['build_info']['base_form_id'] . '_validate';
1058 }
1059 }
1060
1061 if (!isset($form['#submit'])) {
1062 // Ensure that modules can rely on #submit being set.
1063 $form['#submit'] = array();
1064 // Check for a handler specific to $form_id.
1065 if (function_exists($form_id . '_submit')) {
1066 $form['#submit'][] = $form_id . '_submit';
1067 }
1068 // Otherwise check whether this is a shared form and whether there is a
1069 // handler for the shared $form_id.
1070 elseif (isset($form_state['build_info']['base_form_id']) && function_exists($form_state['build_info']['base_form_id'] . '_submit')) {
1071 $form['#submit'][] = $form_state['build_info']['base_form_id'] . '_submit';
1072 }
1073 }
1074
1075 // If no #theme has been set, automatically apply theme suggestions.
1076 // theme_form() itself is in #theme_wrappers and not #theme. Therefore, the
1077 // #theme function only has to care for rendering the inner form elements,
1078 // not the form itself.
1079 if (!isset($form['#theme'])) {
1080 $form['#theme'] = array($form_id);
1081 if (isset($form_state['build_info']['base_form_id'])) {
1082 $form['#theme'][] = $form_state['build_info']['base_form_id'];
1083 }
1084 }
1085
1086 // Invoke hook_form_alter(), hook_form_BASE_FORM_ID_alter(), and
1087 // hook_form_FORM_ID_alter() implementations.
1088 $hooks = array('form');
1089 if (isset($form_state['build_info']['base_form_id'])) {
1090 $hooks[] = 'form_' . $form_state['build_info']['base_form_id'];
1091 }
1092 $hooks[] = 'form_' . $form_id;
1093 drupal_alter($hooks, $form, $form_state, $form_id);
1094 }
1095
1096
1122 function drupal_validate_form($form_id, &$form, &$form_state) {
1123 $validated_forms = &drupal_static(__FUNCTION__, array());
1124
1125 if (isset($validated_forms[$form_id]) && empty($form_state['must_validate'])) {
1126 return;
1127 }
1128
1129 // If the session token was set by drupal_prepare_form(), ensure that it
1130 // matches the current user's session.
1131 if (isset($form['#token'])) {
1132 if (!drupal_valid_token($form_state['values']['form_token'], $form['#token'])) {
1133 $path = current_path();
1134 $query = drupal_get_query_parameters();
1135 $url = url($path, array('query' => $query));
1136
1137 // Setting this error will cause the form to fail validation.
1138 form_set_error('form_token', t('The form has become outdated. Copy any unsaved work in the form below and then <a href="@link">reload this page</a>.', array('@link' => $url)));
1139
1140 // Stop here and don't run any further validation handlers, because they
1141 // could invoke non-safe operations which opens the door for CSRF
1142 // vulnerabilities.
1143 $validated_forms[$form_id] = TRUE;
1144 return;
1145 }
1146 }
1147
1148 _form_validate($form, $form_state, $form_id);
1149 $validated_forms[$form_id] = TRUE;
1150
1151 // If validation errors are limited then remove any non validated form values,
1152 // so that only values that passed validation are left for submit callbacks.
1153 if (isset($form_state['triggering_element']['#limit_validation_errors']) && $form_state['triggering_element']['#limit_validation_errors'] !== FALSE) {
1154 $values = array();
1155 foreach ($form_state['triggering_element']['#limit_validation_errors'] as $section) {
1156 // If the section exists within $form_state['values'], even if the value
1157 // is NULL, copy it to $values.
1158 $section_exists = NULL;
1159 $value = drupal_array_get_nested_value($form_state['values'], $section, $section_exists);
1160 if ($section_exists) {
1161 drupal_array_set_nested_value($values, $section, $value);
1162 }
1163 }
1164 // A button's #value does not require validation, so for convenience we
1165 // allow the value of the clicked button to be retained in its normal
1166 // $form_state['values'] locations, even if these locations are not included
1167 // in #limit_validation_errors.
1168 if (isset($form_state['triggering_element']['#button_type'])) {
1169 $button_value = $form_state['triggering_element']['#value'];
1170
1171 // Like all input controls, the button value may be in the location
1172 // dictated by #parents. If it is, copy it to $values, but do not override
1173 // what may already be in $values.
1174 $parents = $form_state['triggering_element']['#parents'];
1175 if (!drupal_array_nested_key_exists($values, $parents) && drupal_array_get_nested_value($form_state['values'], $parents) === $button_value) {
1176 drupal_array_set_nested_value($values, $parents, $button_value);
1177 }
1178
1179 // Additionally, form_builder() places the button value in
1180 // $form_state['values'][BUTTON_NAME]. If it's still there, after
1181 // validation handlers have run, copy it to $values, but do not override
1182 // what may already be in $values.
1183 $name = $form_state['triggering_element']['#name'];
1184 if (!isset($values[$name]) && isset($form_state['values'][$name]) && $form_state['values'][$name] === $button_value) {
1185 $values[$name] = $button_value;
1186 }
1187 }
1188 $form_state['values'] = $values;
1189 }
1190 }
1191
1249 function drupal_redirect_form($form_state) {
1250 // Skip redirection for form submissions invoked via drupal_form_submit().
1251 if (!empty($form_state['programmed'])) {
1252 return;
1253 }
1254 // Skip redirection if rebuild is activated.
1255 if (!empty($form_state['rebuild'])) {
1256 return;
1257 }
1258 // Skip redirection if it was explicitly disallowed.
1259 if (!empty($form_state['no_redirect'])) {
1260 return;
1261 }
1262 // Only invoke drupal_goto() if redirect value was not set to FALSE.
1263 if (!isset($form_state['redirect']) || $form_state['redirect'] !== FALSE) {
1264 if (isset($form_state['redirect'])) {
1265 if (is_array($form_state['redirect'])) {
1266 call_user_func_array('drupal_goto', $form_state['redirect']);
1267 }
1268 else {
1269 // This function can be called from the installer, which guarantees
1270 // that $redirect will always be a string, so catch that case here
1271 // and use the appropriate redirect function.
1272 $function = drupal_installation_attempted() ? 'install_goto' : 'drupal_goto';
1273 $function($form_state['redirect']);
1274 }
1275 }
1276 drupal_goto(current_path(), array('query' => drupal_get_query_parameters()));
1277 }
1278 }
1279
1303 function _form_validate(&$elements, &$form_state, $form_id = NULL) {
1304 // Also used in the installer, pre-database setup.
1305 $t = get_t();
1306
1307 // Recurse through all children.
1308 foreach (element_children($elements) as $key) {
1309 if (isset($elements[$key]) && $elements[$key]) {
1310 _form_validate($elements[$key], $form_state);
1311 }
1312 }
1313
1314 // Validate the current input.
1315 if (!isset($elements['#validated']) || !$elements['#validated']) {
1316 // The following errors are always shown.
1317 if (isset($elements['#needs_validation'])) {
1318 // Verify that the value is not longer than #maxlength.
1319 if (isset($elements['#maxlength']) && drupal_strlen($elements['#value']) > $elements['#maxlength']) {
1320 form_error($elements, $t('!name cannot be longer than %max characters but is currently %length characters long.', array('!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], '%max' => $elements['#maxlength'], '%length' => drupal_strlen($elements['#value']))));
1321 }
1322
1323 if (isset($elements['#options']) && isset($elements['#value'])) {
1324 if ($elements['#type'] == 'select') {
1325 $options = form_options_flatten($elements['#options']);
1326 }
1327 else {
1328 $options = $elements['#options'];
1329 }
1330 if (is_array($elements['#value'])) {
1331 $value = in_array($elements['#type'], array('checkboxes', 'tableselect')) ? array_keys($elements['#value']) : $elements['#value'];
1332 foreach ($value as $v) {
1333 if (!isset($options[$v])) {
1334 form_error($elements, $t('An illegal choice has been detected. Please contact the site administrator.'));
1335 watchdog('form', 'Illegal choice %choice in !name element.', array('%choice' => $v, '!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']), WATCHDOG_ERROR);
1336 }
1337 }
1338 }
1339 // Non-multiple select fields always have a value in HTML. If the user
1340 // does not change the form, it will be the value of the first option.
1341 // Because of this, form validation for the field will almost always
1342 // pass, even if the user did not select anything. To work around this
1343 // browser behavior, required select fields without a #default_value get
1344 // an additional, first empty option. In case the submitted value is
1345 // identical to the empty option's value, we reset the element's value
1346 // to NULL to trigger the regular #required handling below.
1347 // @see form_process_select()
1348 elseif ($elements['#type'] == 'select' && !$elements['#multiple'] && $elements['#required'] && !isset($elements['#default_value']) && $elements['#value'] === $elements['#empty_value']) {
1349 $elements['#value'] = NULL;
1350 form_set_value($elements, NULL, $form_state);
1351 }
1352 elseif (!isset($options[$elements['#value']])) {
1353 form_error($elements, $t('An illegal choice has been detected. Please contact the site administrator.'));
1354 watchdog('form', 'Illegal choice %choice in %name element.', array('%choice' => $elements['#value'], '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']), WATCHDOG_ERROR);
1355 }
1356 }
1357 }
1358
1359 // While this element is being validated, it may be desired that some calls
1360 // to form_set_error() be suppressed and not result in a form error, so
1361 // that a button that implements low-risk functionality (such as "Previous"
1362 // or "Add more") that doesn't require all user input to be valid can still
1363 // have its submit handlers triggered. The triggering element's
1364 // #limit_validation_errors property contains the information for which
1365 // errors are needed, and all other errors are to be suppressed. The
1366 // #limit_validation_errors property is ignored if submit handlers will run,
1367 // but the element doesn't have a #submit property, because it's too large a
1368 // security risk to have any invalid user input when executing form-level
1369 // submit handlers.
1370 if (isset($form_state['triggering_element']['#limit_validation_errors']) && ($form_state['triggering_element']['#limit_validation_errors'] !== FALSE) && !($form_state['submitted'] && !isset($form_state['triggering_element']['#submit']))) {
1371 form_set_error(NULL, '', $form_state['triggering_element']['#limit_validation_errors']);
1372 }
1373 // If submit handlers won't run (due to the submission having been triggered
1374 // by an element whose #executes_submit_callback property isn't TRUE), then
1375 // it's safe to suppress all validation errors, and we do so by default,
1376 // which is particularly useful during an Ajax submission triggered by a
1377 // non-button. An element can override this default by setting the
1378 // #limit_validation_errors property. For button element types,
1379 // #limit_validation_errors defaults to FALSE (via system_element_info()),
1380 // so that full validation is their default behavior.
1381 elseif (isset($form_state['triggering_element']) && !isset($form_state['triggering_element']['#limit_validation_errors']) && !$form_state['submitted']) {
1382 form_set_error(NULL, '', array());
1383 }
1384 // As an extra security measure, explicitly turn off error suppression if
1385 // one of the above conditions wasn't met. Since this is also done at the
1386 // end of this function, doing it here is only to handle the rare edge case
1387 // where a validate handler invokes form processing of another form.
1388 else {
1389 drupal_static_reset('form_set_error:limit_validation_errors');
1390 }
1391
1392 // Make sure a value is passed when the field is required.
1393 if (isset($elements['#needs_validation']) && $elements['#required']) {
1394 // A simple call to empty() will not cut it here as some fields, like
1395 // checkboxes, can return a valid value of '0'. Instead, check the
1396 // length if it's a string, and the item count if it's an array.
1397 // An unchecked checkbox has a #value of integer 0, different than string
1398 // '0', which could be a valid value.
1399 $is_empty_multiple = (!count($elements['#value']));
1400 $is_empty_string = (is_string($elements['#value']) && drupal_strlen(trim($elements['#value'])) == 0);
1401 $is_empty_value = ($elements['#value'] === 0);
1402 if ($is_empty_multiple || $is_empty_string || $is_empty_value) {
1403 // Although discouraged, a #title is not mandatory for form elements. In
1404 // case there is no #title, we cannot set a form error message.
1405 // Instead of setting no #title, form constructors are encouraged to set
1406 // #title_display to 'invisible' to improve accessibility.
1407 if (isset($elements['#title'])) {
1408 form_error($elements, $t('!name field is required.', array('!name' => $elements['#title'])));
1409 }
1410 else {
1411 form_error($elements);
1412 }
1413 }
1414 }
1415
1416 // Call user-defined form level validators.
1417 if (isset($form_id)) {
1418 form_execute_handlers('validate', $elements, $form_state);
1419 }
1420 // Call any element-specific validators. These must act on the element
1421 // #value data.
1422 elseif (isset($elements['#element_validate'])) {
1423 foreach ($elements['#element_validate'] as $function) {
1424 $function($elements, $form_state, $form_state['complete form']);
1425 }
1426 }
1427 $elements['#validated'] = TRUE;
1428 }
1429
1430 // Done validating this element, so turn off error suppression.
1431 // _form_validate() turns it on again when starting on the next element, if
1432 // it's still appropriate to do so.
1433 drupal_static_reset('form_set_error:limit_validation_errors');
1434 }
1435
1452 function form_execute_handlers($type, &$form, &$form_state) {
1453 $return = FALSE;
1454 // If there was a button pressed, use its handlers.
1455 if (isset($form_state[$type . '_handlers'])) {
1456 $handlers = $form_state[$type . '_handlers'];
1457 }
1458 // Otherwise, check for a form-level handler.
1459 elseif (isset($form['#' . $type])) {
1460 $handlers = $form['#' . $type];
1461 }
1462 else {
1463 $handlers = array();
1464 }
1465
1466 foreach ($handlers as $function) {
1467 // Check if a previous _submit handler has set a batch, but make sure we
1468 // do not react to a batch that is already being processed (for instance
1469 // if a batch operation performs a drupal_form_submit()).
1470 if ($type == 'submit' && ($batch =& batch_get()) && !isset($batch['id'])) {
1471 // Some previous submit handler has set a batch. To ensure correct
1472 // execution order, store the call in a special 'control' batch set.
1473 // See _batch_next_set().
1474 $batch['sets'][] = array('form_submit' => $function);
1475 $batch['has_form_submits'] = TRUE;
1476 }
1477 else {
1478 $function($form, $form_state);
1479 }
1480 $return = TRUE;
1481 }
1482 return $return;
1483 }
1484
1581 function form_set_error($name = NULL, $message = '', $limit_validation_errors = NULL) {
1582 $form = &drupal_static(__FUNCTION__, array());
1583 $sections = &drupal_static(__FUNCTION__ . ':limit_validation_errors');
1584 if (isset($limit_validation_errors)) {
1585 $sections = $limit_validation_errors;
1586 }
1587
1588 if (isset($name) && !isset($form[$name])) {
1589 $record = TRUE;
1590 if (isset($sections)) {
1591 // #limit_validation_errors is an array of "sections" within which user
1592 // input must be valid. If the element is within one of these sections,
1593 // the error must be recorded. Otherwise, it can be suppressed.
1594 // #limit_validation_errors can be an empty array, in which case all
1595 // errors are suppressed. For example, a "Previous" button might want its
1596 // submit action to be triggered even if none of the submitted values are
1597 // valid.
1598 $record = FALSE;
1599 foreach ($sections as $section) {
1600 // Exploding by '][' reconstructs the element's #parents. If the
1601 // reconstructed #parents begin with the same keys as the specified
1602 // section, then the element's values are within the part of
1603 // $form_state['values'] that the clicked button requires to be valid,
1604 // so errors for this element must be recorded. As the exploded array
1605 // will all be strings, we need to cast every value of the section
1606 // array to string.
1607 if (array_slice(explode('][', $name), 0, count($section)) === array_map('strval', $section)) {
1608 $record = TRUE;
1609 break;
1610 }
1611 }
1612 }
1613 if ($record) {
1614 $form[$name] = $message;
1615 if ($message) {
1616 drupal_set_message($message, 'error');
1617 }
1618 }
1619 }
1620
1621 return $form;
1622 }
1623
1627 function form_clear_error() {
1628 drupal_static_reset('form_set_error');
1629 }
1630
1634 function form_get_errors() {
1635 $form = form_set_error();
1636 if (!empty($form)) {
1637 return $form;
1638 }
1639 }
1640
1647 function form_get_error($element) {
1648 $form = form_set_error();
1649 $parents = array();
1650 foreach ($element['#parents'] as $parent) {
1651 $parents[] = $parent;
1652 $key = implode('][', $parents);
1653 if (isset($form[$key])) {
1654 return $form[$key];
1655 }
1656 }
1657 }
1658
1662 function form_error(&$element, $message = '') {
1663 form_set_error(implode('][', $element['#parents']), $message);
1664 }
1665
1758 function form_builder($form_id, &$element, &$form_state) {
1759 // Initialize as unprocessed.
1760 $element['#processed'] = FALSE;
1761
1762 // Use element defaults.
1763 if (isset($element['#type']) && empty($element['#defaults_loaded']) && ($info = element_info($element['#type']))) {
1764 // Overlay $info onto $element, retaining preexisting keys in $element.
1765 $element += $info;
1766 $element['#defaults_loaded'] = TRUE;
1767 }
1768 // Assign basic defaults common for all form elements.
1769 $element += array(
1770 '#required' => FALSE,
1771 '#attributes' => array(),
1772 '#title_display' => 'before',
1773 );
1774
1775 // Special handling if we're on the top level form element.
1776 if (isset($element['#type']) && $element['#type'] == 'form') {
1777 if (!empty($element['#https']) && variable_get('https', FALSE) &&
1778 !url_is_external($element['#action'])) {
1779 global $base_root;
1780
1781 // Not an external URL so ensure that it is secure.
1782 $element['#action'] = str_replace('http://', 'https://', $base_root) . $element['#action'];
1783 }
1784
1785 // Store a reference to the complete form in $form_state prior to building
1786 // the form. This allows advanced #process and #after_build callbacks to
1787 // perform changes elsewhere in the form.
1788 $form_state['complete form'] = &$element;
1789
1790 // Set a flag if we have a correct form submission. This is always TRUE for
1791 // programmed forms coming from drupal_form_submit(), or if the form_id coming
1792 // from the POST data is set and matches the current form_id.
1793 if ($form_state['programmed'] || (!empty($form_state['input']) && (isset($form_state['input']['form_id']) && ($form_state['input']['form_id'] == $form_id)))) {
1794 $form_state['process_input'] = TRUE;
1795 }
1796 else {
1797 $form_state['process_input'] = FALSE;
1798 }
1799
1800 // All form elements should have an #array_parents property.
1801 $element['#array_parents'] = array();
1802 }
1803
1804 if (!isset($element['#id'])) {
1805 $element['#id'] = drupal_html_id('edit-' . implode('-', $element['#parents']));
1806 }
1807 // Handle input elements.
1808 if (!empty($element['#input'])) {
1809 _form_builder_handle_input_element($form_id, $element, $form_state);
1810 }
1811 // Allow for elements to expand to multiple elements, e.g., radios,
1812 // checkboxes and files.
1813 if (isset($element['#process']) && !$element['#processed']) {
1814 foreach ($element['#process'] as $process) {
1815 $element = $process($element, $form_state, $form_state['complete form']);
1816 }
1817 $element['#processed'] = TRUE;
1818 }
1819
1820 // We start off assuming all form elements are in the correct order.
1821 $element['#sorted'] = TRUE;
1822
1823 // Recurse through all child elements.
1824 $count = 0;
1825 foreach (element_children($element) as $key) {
1826 // Prior to checking properties of child elements, their default properties
1827 // need to be loaded.
1828 if (isset($element[$key]['#type']) && empty($element[$key]['#defaults_loaded']) && ($info = element_info($element[$key]['#type']))) {
1829 $element[$key] += $info;
1830 $element[$key]['#defaults_loaded'] = TRUE;
1831 }
1832
1833 // Don't squash an existing tree value.
1834 if (!isset($element[$key]['#tree'])) {
1835 $element[$key]['#tree'] = $element['#tree'];
1836 }
1837
1838 // Deny access to child elements if parent is denied.
1839 if (isset($element['#access']) && !$element['#access']) {
1840 $element[$key]['#access'] = FALSE;
1841 }
1842
1843 // Make child elements inherit their parent's #disabled and #allow_focus
1844 // values unless they specify their own.
1845 foreach (array('#disabled', '#allow_focus') as $property) {
1846 if (isset($element[$property]) && !isset($element[$key][$property])) {
1847 $element[$key][$property] = $element[$property];
1848 }
1849 }
1850
1851 // Don't squash existing parents value.
1852 if (!isset($element[$key]['#parents'])) {
1853 // Check to see if a tree of child elements is present. If so,
1854 // continue down the tree if required.
1855 $element[$key]['#parents'] = $element[$key]['#tree'] && $element['#tree'] ? array_merge($element['#parents'], array($key)) : array($key);
1856 }
1857 // Ensure #array_parents follows the actual form structure.
1858 $array_parents = $element['#array_parents'];
1859 $array_parents[] = $key;
1860 $element[$key]['#array_parents'] = $array_parents;
1861
1862 // Assign a decimal placeholder weight to preserve original array order.
1863 if (!isset($element[$key]['#weight'])) {
1864 $element[$key]['#weight'] = $count/1000;
1865 }
1866 else {
1867 // If one of the child elements has a weight then we will need to sort
1868 // later.
1869 unset($element['#sorted']);
1870 }
1871 $element[$key] = form_builder($form_id, $element[$key], $form_state);
1872 $count++;
1873 }
1874
1875 // The #after_build flag allows any piece of a form to be altered
1876 // after normal input parsing has been completed.
1877 if (isset($element['#after_build']) && !isset($element['#after_build_done'])) {
1878 foreach ($element['#after_build'] as $function) {
1879 $element = $function($element, $form_state);
1880 }
1881 $element['#after_build_done'] = TRUE;
1882 }
1883
1884 // If there is a file element, we need to flip a flag so later the
1885 // form encoding can be set.
1886 if (isset($element['#type']) && $element['#type'] == 'file') {
1887 $form_state['has_file_element'] = TRUE;
1888 }
1889
1890 // Final tasks for the form element after form_builder() has run for all other
1891 // elements.
1892 if (isset($element['#type']) && $element['#type'] == 'form') {
1893 // If there is a file element, we set the form encoding.
1894 if (isset($form_state['has_file_element'])) {
1895 $element['#attributes']['enctype'] = 'multipart/form-data';
1896 }
1897
1898 // If a form contains a single textfield, and the ENTER key is pressed
1899 // within it, Internet Explorer submits the form with no POST data
1900 // identifying any submit button. Other browsers submit POST data as though
1901 // the user clicked the first button. Therefore, to be as consistent as we
1902 // can be across browsers, if no 'triggering_element' has been identified
1903 // yet, default it to the first button.
1904 if (!$form_state['programmed'] && !isset($form_state['triggering_element']) && !empty($form_state['buttons'])) {
1905 $form_state['triggering_element'] = $form_state['buttons'][0];
1906 }
1907
1908 // If the triggering element specifies "button-level" validation and submit
1909 // handlers to run instead of the default form-level ones, then add those to
1910 // the form state.
1911 foreach (array('validate', 'submit') as $type) {
1912 if (isset($form_state['triggering_element']['#' . $type])) {
1913 $form_state[$type . '_handlers'] = $form_state['triggering_element']['#' . $type];
1914 }
1915 }
1916
1917 // If the triggering element executes submit handlers, then set the form
1918 // state key that's needed for those handlers to run.
1919 if (!empty($form_state['triggering_element']['#executes_submit_callback'])) {
1920 $form_state['submitted'] = TRUE;
1921 }
1922
1923 // Special processing if the triggering element is a button.
1924 if (isset($form_state['triggering_element']['#button_type'])) {
1925 // Because there are several ways in which the triggering element could
1926 // have been determined (including from input variables set by JavaScript
1927 // or fallback behavior implemented for IE), and because buttons often
1928 // have their #name property not derived from their #parents property, we
1929 // can't assume that input processing that's happened up until here has
1930 // resulted in $form_state['values'][BUTTON_NAME] being set. But it's
1931 // common for forms to have several buttons named 'op' and switch on
1932 // $form_state['values']['op'] during submit handler execution.
1933 $form_state['values'][$form_state['triggering_element']['#name']] = $form_state['triggering_element']['#value'];
1934
1935 // @todo Legacy support. Remove in Drupal 8.
1936 $form_state['clicked_button'] = $form_state['triggering_element'];
1937 }
1938 }
1939 return $element;
1940 }
1941
1945 function _form_builder_handle_input_element($form_id, &$element, &$form_state) {
1946 if (!isset($element['#name'])) {
1947 $name = array_shift($element['#parents']);
1948 $element['#name'] = $name;
1949 if ($element['#type'] == 'file') {
1950 // To make it easier to handle $_FILES in file.inc, we place all
1951 // file fields in the 'files' array. Also, we do not support
1952 // nested file names.
1953 $element['#name'] = 'files[' . $element['#name'] . ']';
1954 }
1955 elseif (count($element['#parents'])) {
1956 $element['#name'] .= '[' . implode('][', $element['#parents']) . ']';
1957 }
1958 array_unshift($element['#parents'], $name);
1959 }
1960
1961 // Setting #disabled to TRUE results in user input being ignored, regardless
1962 // of how the element is themed or whether JavaScript is used to change the
1963 // control's attributes. However, it's good UI to let the user know that input
1964 // is not wanted for the control. HTML supports two attributes for this:
1965 // http://www.w3.org/TR/html401/interact/forms.html#h-17.12. If a form wants
1966 // to start a control off with one of these attributes for UI purposes only,
1967 // but still allow input to be processed if it's sumitted, it can set the
1968 // desired attribute in #attributes directly rather than using #disabled.
1969 // However, developers should think carefully about the accessibility
1970 // implications of doing so: if the form expects input to be enterable under
1971 // some condition triggered by JavaScript, how would someone who has
1972 // JavaScript disabled trigger that condition? Instead, developers should
1973 // consider whether a multi-step form would be more appropriate (#disabled can
1974 // be changed from step to step). If one still decides to use JavaScript to
1975 // affect when a control is enabled, then it is best for accessibility for the
1976 // control to be enabled in the HTML, and disabled by JavaScript on document
1977 // ready.
1978 if (!empty($element['#disabled'])) {
1979 if (!empty($element['#allow_focus'])) {
1980 $element['#attributes']['readonly'] = 'readonly';
1981 }
1982 else {
1983 $element['#attributes']['disabled'] = 'disabled';
1984 }
1985 }
1986
1987 // With JavaScript or other easy hacking, input can be submitted even for
1988 // elements with #access=FALSE or #disabled=TRUE. For security, these must
1989 // not be processed. Forms that set #disabled=TRUE on an element do not
1990 // expect input for the element, and even forms submitted with
1991 // drupal_form_submit() must not be able to get around this. Forms that set
1992 // #access=FALSE on an element usually allow access for some users, so forms
1993 // submitted with drupal_form_submit() may bypass access restriction and be
1994 // treated as high-privilege users instead.
1995 $process_input = empty($element['#disabled']) && (($form_state['programmed'] && $form_state['programmed_bypass_access_check']) || ($form_state['process_input'] && (!isset($element['#access']) || $element['#access'])));
1996
1997 // Set the element's #value property.
1998 if (!isset($element['#value']) && !array_key_exists('#value', $element)) {
1999 $value_callback = !empty($element['#value_callback']) ? $element['#value_callback'] : 'form_type_' . $element['#type'] . '_value';
2000 if ($process_input) {
2001 // Get the input for the current element. NULL values in the input need to
2002 // be explicitly distinguished from missing input. (see below)
2003 $input_exists = NULL;
2004 $input = drupal_array_get_nested_value($form_state['input'], $element['#parents'], $input_exists);
2005 // For browser-submitted forms, the submitted values do not contain values
2006 // for certain elements (empty multiple select, unchecked checkbox).
2007 // During initial form processing, we add explicit NULL values for such
2008 // elements in $form_state['input']. When rebuilding the form, we can
2009 // distinguish elements having NULL input from elements that were not part
2010 // of the initially submitted form and can therefore use default values
2011 // for the latter, if required. Programmatically submitted forms can
2012 // submit explicit NULL values when calling drupal_form_submit(), so we do
2013 // not modify $form_state['input'] for them.
2014 if (!$input_exists && !$form_state['rebuild'] && !$form_state['programmed']) {
2015 // Add the necessary parent keys to $form_state['input'] and sets the
2016 // element's input value to NULL.
2017 drupal_array_set_nested_value($form_state['input'], $element['#parents'], NULL);
2018 $input_exists = TRUE;
2019 }
2020 // If we have input for the current element, assign it to the #value
2021 // property, optionally filtered through $value_callback.
2022 if ($input_exists) {
2023 if (function_exists($value_callback)) {
2024 $element['#value'] = $value_callback($element, $input, $form_state);
2025 }
2026 if (!isset($element['#value']) && isset($input)) {
2027 $element['#value'] = $input;
2028 }
2029 }
2030 // Mark all posted values for validation.
2031 if (isset($element['#value']) || (!empty($element['#required']))) {
2032 $element['#needs_validation'] = TRUE;
2033 }
2034 }
2035 // Load defaults.
2036 if (!isset($element['#value'])) {
2037 // Call #type_value without a second argument to request default_value handling.
2038 if (function_exists($value_callback)) {
2039 $element['#value'] = $value_callback($element, FALSE, $form_state);
2040 }
2041 // Final catch. If we haven't set a value yet, use the explicit default value.
2042 // Avoid image buttons (which come with garbage value), so we only get value
2043 // for the button actually clicked.
2044 if (!isset($element['#value']) && empty($element['#has_garbage_value'])) {
2045 $element['#value'] = isset($element['#default_value']) ? $element['#default_value'] : '';
2046 }
2047 }
2048 }
2049
2050 // Determine which element (if any) triggered the submission of the form and
2051 // keep track of all the clickable buttons in the form for
2052 // form_state_values_clean(). Enforce the same input processing restrictions
2053 // as above.
2054 if ($process_input) {
2055 // Detect if the element triggered the submission via Ajax.
2056 if (_form_element_triggered_scripted_submission($element, $form_state)) {
2057 $form_state['triggering_element'] = $element;
2058 }
2059
2060 // If the form was submitted by the browser rather than via Ajax, then it
2061 // can only have been triggered by a button, and we need to determine which
2062 // button within the constraints of how browsers provide this information.
2063 if (isset($element['#button_type'])) {
2064 // All buttons in the form need to be tracked for
2065 // form_state_values_clean() and for the form_builder() code that handles
2066 // a form submission containing no button information in $_POST.
2067 $form_state['buttons'][] = $element;
2068 if (_form_button_was_clicked($element, $form_state)) {
2069 $form_state['triggering_element'] = $element;
2070 }
2071 }
2072 }
2073
2074 // Set the element's value in $form_state['values'], but only, if its key
2075 // does not exist yet (a #value_callback may have already populated it).
2076 if (!drupal_array_nested_key_exists($form_state['values'], $element['#parents'])) {
2077 form_set_value($element, $element['#value'], $form_state);
2078 }
2079 }
2080
2092 function _form_element_triggered_scripted_submission($element, &$form_state) {
2093 if (!empty($form_state['input']['_triggering_element_name']) && $element['#name'] == $form_state['input']['_triggering_element_name']) {
2094 if (empty($form_state['input']['_triggering_element_value']) || $form_state['input']['_triggering_element_value'] == $element['#value']) {
2095 return TRUE;
2096 }
2097 }
2098 return FALSE;
2099 }
2100
2121 function _form_button_was_clicked($element, &$form_state) {
2122 // First detect normal 'vanilla' button clicks. Traditionally, all
2123 // standard buttons on a form share the same name (usually 'op'),
2124 // and the specific return value is used to determine which was
2125 // clicked. This ONLY works as long as $form['#name'] puts the
2126 // value at the top level of the tree of $_POST data.
2127 if (isset($form_state['input'][$element['#name']]) && $form_state['input'][$element['#name']] == $element['#value']) {
2128 return TRUE;
2129 }
2130 // When image buttons are clicked, browsers do NOT pass the form element
2131 // value in $_POST. Instead they pass an integer representing the
2132 // coordinates of the click on the button image. This means that image
2133 // buttons MUST have unique $form['#name'] values, but the details of
2134 // their $_POST data should be ignored.
2135 elseif (!empty($element['#has_garbage_value']) && isset($element['#value']) && $element['#value'] !== '') {
2136 return TRUE;
2137 }
2138 return FALSE;
2139 }
2140
2159 function form_state_values_clean(&$form_state) {
2160 // Remove internal Form API values.
2161 unset($form_state['values']['form_id'], $form_state['values']['form_token'], $form_state['values']['form_build_id'], $form_state['values']['op']);
2162
2163 // Remove button values.
2164 // form_builder() collects all button elements in a form. We remove the button
2165 // value separately for each button element.
2166 foreach ($form_state['buttons'] as $button) {
2167 // Remove this button's value from the submitted form values by finding
2168 // the value corresponding to this button.
2169 // We iterate over the #parents of this button and move a reference to
2170 // each parent in $form_state['values']. For example, if #parents is:
2171 // array('foo', 'bar', 'baz')
2172 // then the corresponding $form_state['values'] part will look like this:
2173 // array(
2174 // 'foo' => array(
2175 // 'bar' => array(
2176 // 'baz' => 'button_value',
2177 // ),
2178 // ),
2179 // )
2180 // We start by (re)moving 'baz' to $last_parent, so we are able unset it
2181 // at the end of the iteration. Initially, $values will contain a
2182 // reference to $form_state['values'], but in the iteration we move the
2183 // reference to $form_state['values']['foo'], and finally to
2184 // $form_state['values']['foo']['bar'], which is the level where we can
2185 // unset 'baz' (that is stored in $last_parent).
2186 $parents = $button['#parents'];
2187 $last_parent = array_pop($parents);
2188 $key_exists = NULL;
2189 $values = &drupal_array_get_nested_value($form_state['values'], $parents, $key_exists);
2190 if ($key_exists && is_array($values)) {
2191 unset($values[$last_parent]);
2192 }
2193 }
2194 }
2195
2211 function form_type_image_button_value($form, $input, $form_state) {
2212 if ($input !== FALSE) {
2213 if (!empty($input)) {
2214 // If we're dealing with Mozilla or Opera, we're lucky. It will
2215 // return a proper value, and we can get on with things.
2216 return $form['#return_value'];
2217 }
2218 else {
2219 // Unfortunately, in IE we never get back a proper value for THIS
2220 // form element. Instead, we get back two split values: one for the
2221 // X and one for the Y coordinates on which the user clicked the
2222 // button. We'll find this element in the #post data, and search
2223 // in the same spot for its name, with '_x'.
2224 $input = $form_state['input'];
2225 foreach (explode('[', $form['#name']) as $element_name) {
2226 // chop off the ] that may exist.
2227 if (substr($element_name, -1) == ']') {
2228 $element_name = substr($element_name, 0, -1);
2229 }
2230
2231 if (!isset($input[$element_name])) {
2232 if (isset($input[$element_name . '_x'])) {
2233 return $form['#return_value'];
2234 }
2235 return NULL;
2236 }
2237 $input = $input[$element_name];
2238 }
2239 return $form['#return_value'];
2240 }
2241 }
2242 }
2243
2257 function form_type_checkbox_value($element, $input = FALSE) {
2258 if ($input === FALSE) {
2259 // Use #default_value as the default value of a checkbox, except change
2260 // NULL to 0, because _form_builder_handle_input_element() would otherwise
2261 // replace NULL with empty string, but an empty string is a potentially
2262 // valid value for a checked checkbox.
2263 return isset($element['#default_value']) ? $element['#default_value'] : 0;
2264 }
2265 else {
2266 // Checked checkboxes are submitted with a value (possibly '0' or ''):
2267 // http://www.w3.org/TR/html401/interact/forms.html#successful-controls.
2268 // For checked checkboxes, browsers submit the string version of
2269 // #return_value, but we return the original #return_value. For unchecked
2270 // checkboxes, browsers submit nothing at all, but
2271 // _form_builder_handle_input_element() detects this, and calls this
2272 // function with $input=NULL. Returning NULL from a value callback means to
2273 // use the default value, which is not what is wanted when an unchecked
2274 // checkbox is submitted, so we use integer 0 as the value indicating an
2275 // unchecked checkbox. Therefore, modules must not use integer 0 as a
2276 // #return_value, as doing so results in the checkbox always being treated
2277 // as unchecked. The string '0' is allowed for #return_value. The most
2278 // common use-case for setting #return_value to either 0 or '0' is for the
2279 // first option within a 0-indexed array of checkboxes, and for this,
2280 // form_process_checkboxes() uses the string rather than the integer.
2281 return isset($input) ? $element['#return_value'] : 0;
2282 }
2283 }
2284
2298 function form_type_checkboxes_value($element, $input = FALSE) {
2299 if ($input === FALSE) {
2300 $value = array();
2301 $element += array('#default_value' => array());
2302 foreach ($element['#default_value'] as $key) {
2303 $value[$key] = $key;
2304 }
2305 return $value;
2306 }
2307 elseif (is_array($input)) {
2308 // Programmatic form submissions use NULL to indicate that a checkbox
2309 // should be unchecked; see drupal_form_submit(). We therefore remove all
2310 // NULL elements from the array before constructing the return value, to
2311 // simulate the behavior of web browsers (which do not send unchecked
2312 // checkboxes to the server at all). This will not affect non-programmatic
2313 // form submissions, since all values in $_POST are strings.
2314 foreach ($input as $key => $value) {
2315 if (!isset($value)) {
2316 unset($input[$key]);
2317 }
2318 }
2319 return drupal_map_assoc($input);
2320 }
2321 else {
2322 return array();
2323 }
2324 }
2325
2339 function form_type_tableselect_value($element, $input = FALSE) {
2340 // If $element['#multiple'] == FALSE, then radio buttons are displayed and
2341 // the default value handling is used.
2342 if (isset($element['#multiple']) && $element['#multiple']) {
2343 // Checkboxes are being displayed with the default value coming from the
2344 // keys of the #default_value property. This differs from the checkboxes
2345 // element which uses the array values.
2346 if ($input === FALSE) {
2347 $value = array();
2348 $element += array('#default_value' => array());
2349 foreach ($element['#default_value'] as $key => $flag) {
2350 if ($flag) {
2351 $value[$key] = $key;
2352 }
2353 }
2354 return $value;
2355 }
2356 else {
2357 return is_array($input) ? drupal_map_assoc($input) : array();
2358 }
2359 }
2360 }
2361
2375 function form_type_radios_value(&$element, $input = FALSE) {
2376 if ($input !== FALSE) {
2377 // When there's user input (including NULL), return it as the value.
2378 // However, if NULL is submitted, _form_builder_handle_input_element() will
2379 // apply the default value, and we want that validated against #options
2380 // unless it's empty. (An empty #default_value, such as NULL or FALSE, can
2381 // be used to indicate that no radio button is selected by default.)
2382 if (!isset($input) && !empty($element['#default_value'])) {
2383 $element['#needs_validation'] = TRUE;
2384 }
2385 return $input;
2386 }
2387 else {
2388 // For default value handling, simply return #default_value. Additionally,
2389 // for a NULL default value, set #has_garbage_value to prevent
2390 // _form_builder_handle_input_element() converting the NULL to an empty
2391 // string, so that code can distinguish between nothing selected and the
2392 // selection of a radio button whose value is an empty string.
2393 $value = isset($element['#default_value']) ? $element['#default_value'] : NULL;
2394 if (!isset($value)) {
2395 $element['#has_garbage_value'] = TRUE;
2396 }
2397 return $value;
2398 }
2399 }
2400
2414 function form_type_password_confirm_value($element, $input = FALSE) {
2415 if ($input === FALSE) {
2416 $element += array('#default_value' => array());
2417 return $element['#default_value'] + array('pass1' => '', 'pass2' => '');
2418 }
2419 }
2420
2434 function form_type_select_value($element, $input = FALSE) {
2435 if ($input !== FALSE) {
2436 if (isset($element['#multiple']) && $element['#multiple']) {
2437 // If an enabled multi-select submits NULL, it means all items are
2438 // unselected. A disabled multi-select always submits NULL, and the
2439 // default value should be used.
2440 if (empty($element['#disabled'])) {
2441 return (is_array($input)) ? drupal_map_assoc($input) : array();
2442 }
2443 else {
2444 return (isset($element['#default_value']) && is_array($element['#default_value'])) ? $element['#default_value'] : array();
2445 }
2446 }
2447 // Non-multiple select elements may have an empty option preprended to them
2448 // (see form_process_select()). When this occurs, usually #empty_value is
2449 // an empty string, but some forms set #empty_value to integer 0 or some
2450 // other non-string constant. PHP receives all submitted form input as
2451 // strings, but if the empty option is selected, set the value to match the
2452 // empty value exactly.
2453 elseif (isset($element['#empty_value']) && $input === (string) $element['#empty_value']) {
2454 return $element['#empty_value'];
2455 }
2456 else {
2457 return $input;
2458 }
2459 }
2460 }
2461
2475 function form_type_textfield_value($element, $input = FALSE) {
2476 if ($input !== FALSE && $input !== NULL) {
2477 // Equate $input to the form value to ensure it's marked for
2478 // validation.
2479 return str_replace(array("\r", "\n"), '', $input);
2480 }
2481 }
2482
2496 function form_type_token_value($element, $input = FALSE) {
2497 if ($input !== FALSE) {
2498 return (string) $input;
2499 }
2500 }
2501
2531 function form_set_value($element, $value, &$form_state) {
2532 drupal_array_set_nested_value($form_state['values'], $element['#parents'], $value, TRUE);
2533 }
2534
2548 function form_options_flatten($array) {
2549 // Always reset static var when first entering the recursion.
2550 drupal_static_reset('_form_options_flatten');
2551 return _form_options_flatten($array);
2552 }
2553
2559 function _form_options_flatten($array) {
2560 $return = &drupal_static(__FUNCTION__);
2561
2562 foreach ($array as $key => $value) {
2563 if (is_object($value)) {
2564 _form_options_flatten($value->option);
2565 }
2566 elseif (is_array($value)) {
2567 _form_options_flatten($value);
2568 }
2569 else {
2570 $return[$key] = 1;
2571 }
2572 }
2573
2574 return $return;
2575 }
2576
2613 function form_process_select($element) {
2614 // #multiple select fields need a special #name.
2615 if ($element['#multiple']) {
2616 $element['#attributes']['multiple'] = 'multiple';
2617 $element['#attributes']['name'] = $element['#name'] . '[]';
2618 }
2619 // A non-#multiple select needs special handling to prevent user agents from
2620 // preselecting the first option without intention. #multiple select lists do
2621 // not get an empty option, as it would not make sense, user interface-wise.
2622 else {
2623 $required = $element['#required'];
2624 // If the element is required and there is no #default_value, then add an
2625 // empty option that will fail validation, so that the user is required to
2626 // make a choice. Also, if there's a value for #empty_value or
2627 // #empty_option, then add an option that represents emptiness.
2628 if (($required && !isset($element['#default_value'])) || isset($element['#empty_value']) || isset($element['#empty_option'])) {
2629 $element += array(
2630 '#empty_value' => '',
2631 '#empty_option' => $required ? t('- Select -') : t('- None -'),
2632 );
2633 // The empty option is prepended to #options and purposively not merged
2634 // to prevent another option in #options mistakenly using the same value
2635 // as #empty_value.
2636 $empty_option = array($element['#empty_value'] => $element['#empty_option']);
2637 $element['#options'] = $empty_option + $element['#options'];
2638 }
2639 }
2640 return $element;
2641 }
2642
2658 function theme_select($variables) {
2659 $element = $variables['element'];
2660 element_set_attributes($element, array('id', 'name', 'size'));
2661 _form_set_class($element, array('form-select'));
2662
2663 return '<select' . drupal_attributes($element['#attributes']) . '>' . form_select_options($element) . '</select>';
2664 }
2665
2679 function form_select_options($element, $choices = NULL) {
2680 if (!isset($choices)) {
2681 $choices = $element['#options'];
2682 }
2683 // array_key_exists() accommodates the rare event where $element['#value'] is NULL.
2684 // isset() fails in this situation.
2685 $value_valid = isset($element['#value']) || array_key_exists('#value', $element);
2686 $value_is_array = $value_valid && is_array($element['#value']);
2687 $options = '';
2688 foreach ($choices as $key => $choice) {
2689 if (is_array($choice)) {
2690 $options .= '<optgroup label="' . $key . '">';
2691 $options .= form_select_options($element, $choice);
2692 $options .= '</optgroup>';
2693 }
2694 elseif (is_object($choice)) {
2695 $options .= form_select_options($element, $choice->option);
2696 }
2697 else {
2698 $key = (string) $key;
2699 if ($value_valid && (!$value_is_array && (string) $element['#value'] === $key || ($value_is_array && in_array($key, $element['#value'])))) {
2700 $selected = ' selected="selected"';
2701 }
2702 else {
2703 $selected = '';
2704 }
2705 $options .= '<option value="' . check_plain($key) . '"' . $selected . '>' . check_plain($choice) . '</option>';
2706 }
2707 }
2708 return $options;
2709 }
2710
2743 function form_get_options($element, $key) {
2744 $keys = array();
2745 foreach ($element['#options'] as $index => $choice) {
2746 if (is_array($choice)) {
2747 return FALSE;
2748 }
2749 elseif (is_object($choice)) {
2750 if (isset($choice->option[$key])) {
2751 $keys[] = $index;
2752 }
2753 }
2754 elseif ($index == $key) {
2755 $keys[] = $index;
2756 }
2757 }
2758 return $keys;
2759 }
2760
2772 function theme_fieldset($variables) {
2773 $element = $variables['element'];
2774 element_set_attributes($element, array('id'));
2775 _form_set_class($element, array('form-wrapper'));
2776
2777 $output = '<fieldset' . drupal_attributes($element['#attributes']) . '>';
2778 if (!empty($element['#title'])) {
2779 // Always wrap fieldset legends in a SPAN for CSS positioning.
2780 $output .= '<legend><span class="fieldset-legend">' . $element['#title'] . '</span></legend>';
2781 }
2782 $output .= '<div class="fieldset-wrapper">';
2783 if (!empty($element['#description'])) {
2784 $output .= '<div class="fieldset-description">' . $element['#description'] . '</div>';
2785 }
2786 $output .= $element['#children'];
2787 if (isset($element['#value'])) {
2788 $output .= $element['#value'];
2789 }
2790 $output .= '</div>';
2791 $output .= "</fieldset>\n";
2792 return $output;
2793 }
2794
2809 function theme_radio($variables) {
2810 $element = $variables['element'];
2811 $element['#attributes']['type'] = 'radio';
2812 element_set_attributes($element, array('id', 'name', '#return_value' => 'value'));
2813
2814 if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
2815 $element['#attributes']['checked'] = 'checked';
2816 }
2817 _form_set_class($element, array('form-radio'));
2818
2819 return '<input' . drupal_attributes($element['#attributes']) . ' />';
2820 }
2821
2833 function theme_radios($variables) {
2834 $element = $variables['element'];
2835 $attributes = array();
2836 if (isset($element['#id'])) {
2837 $attributes['id'] = $element['#id'];
2838 }
2839 $attributes['class'] = 'form-radios';
2840 if (!empty($element['#attributes']['class'])) {
2841 $attributes['class'] .= ' ' . implode(' ', $element['#attributes']['class']);
2842 }
2843 if (isset($element['#attributes']['title'])) {
2844 $attributes['title'] = $element['#attributes']['title'];
2845 }
2846 return '<div' . drupal_attributes($attributes) . '>' . (!empty($element['#children']) ? $element['#children'] : '') . '</div>';
2847 }
2848
2852 function form_process_password_confirm($element) {
2853 $element['pass1'] = array(
2854 '#type' => 'password',
2855 '#title' => t('Password'),
2856 '#value' => empty($element['#value']) ? NULL : $element['#value']['pass1'],
2857 '#required' => $element['#required'],
2858 '#attributes' => array('class' => array('password-field')),
2859 );
2860 $element['pass2'] = array(
2861 '#type' => 'password',
2862 '#title' => t('Confirm password'),
2863 '#value' => empty($element['#value']) ? NULL : $element['#value']['pass2'],
2864 '#required' => $element['#required'],
2865 '#attributes' => array('class' => array('password-confirm')),
2866 );
2867 $element['#element_validate'] = array('password_confirm_validate');
2868 $element['#tree'] = TRUE;
2869
2870 if (isset($element['#size'])) {
2871 $element['pass1']['#size'] = $element['pass2']['#size'] = $element['#size'];
2872 }
2873
2874 return $element;
2875 }
2876
2880 function password_confirm_validate($element, &$element_state) {
2881 $pass1 = trim($element['pass1']['#value']);
2882 $pass2 = trim($element['pass2']['#value']);
2883 if (!empty($pass1) || !empty($pass2)) {
2884 if (strcmp($pass1, $pass2)) {
2885 form_error($element, t('The specified passwords do not match.'));
2886 }
2887 }
2888 elseif ($element['#required'] && !empty($element_state['input'])) {
2889 form_error($element, t('Password field is required.'));
2890 }
2891
2892 // Password field must be converted from a two-element array into a single
2893 // string regardless of validation results.
2894 form_set_value($element['pass1'], NULL, $element_state);
2895 form_set_value($element['pass2'], NULL, $element_state);
2896 form_set_value($element, $pass1, $element_state);
2897
2898 return $element;
2899
2900 }
2901
2913 function theme_date($variables) {
2914 $element = $variables['element'];
2915
2916 $attributes = array();
2917 if (isset($element['#id'])) {
2918 $attributes['id'] = $element['#id'];
2919 }
2920 if (!empty($element['#attributes']['class'])) {
2921 $attributes['class'] = (array) $element['#attributes']['class'];
2922 }
2923 $attributes['class'][] = 'container-inline';
2924
2925 return '<div' . drupal_attributes($attributes) . '>' . drupal_render_children($element) . '</div>';
2926 }
2927
2931 function form_process_date($element) {
2932 // Default to current date
2933 if (empty($element['#value'])) {
2934 $element['#value'] = array(
2935 'day' => format_date(REQUEST_TIME, 'custom', 'j'),
2936 'month' => format_date(REQUEST_TIME, 'custom', 'n'),
2937 'year' => format_date(REQUEST_TIME, 'custom', 'Y'),
2938 );
2939 }
2940
2941 $element['#tree'] = TRUE;
2942
2943 // Determine the order of day, month, year in the site's chosen date format.
2944 $format = variable_get('date_format_short', 'm/d/Y - H:i');
2945 $sort = array();
2946 $sort['day'] = max(strpos($format, 'd'), strpos($format, 'j'));
2947 $sort['month'] = max(strpos($format, 'm'), strpos($format, 'M'));
2948 $sort['year'] = strpos($format, 'Y');
2949 asort($sort);
2950 $order = array_keys($sort);
2951
2952 // Output multi-selector for date.
2953 foreach ($order as $type) {
2954 switch ($type) {
2955 case 'day':
2956 $options = drupal_map_assoc(range(1, 31));
2957 $title = t('Day');
2958 break;
2959
2960 case 'month':
2961 $options = drupal_map_assoc(range(1, 12), 'map_month');
2962 $title = t('Month');
2963 break;
2964
2965 case 'year':
2966 $options = drupal_map_assoc(range(1900, 2050));
2967 $title = t('Year');
2968 break;
2969 }
2970
2971 $element[$type] = array(
2972 '#type' => 'select',
2973 '#title' => $title,
2974 '#title_display' => 'invisible',
2975 '#value' => $element['#value'][$type],
2976 '#attributes' => $element['#attributes'],
2977 '#options' => $options,
2978 );
2979 }
2980
2981 return $element;
2982 }
2983
2987 function date_validate($element) {
2988 if (!checkdate($element['#value']['month'], $element['#value']['day'], $element['#value']['year'])) {
2989 form_error($element, t('The specified date is invalid.'));
2990 }
2991 }
2992
2996 function map_month($month) {
2997 $months = &drupal_static(__FUNCTION__, array(
2998 1 => 'Jan',
2999 2 => 'Feb',
3000 3 => 'Mar',
3001 4 => 'Apr',
3002 5 => 'May',
3003 6 => 'Jun',
3004 7 => 'Jul',
3005 8 => 'Aug',
3006 9 => 'Sep',
3007 10 => 'Oct',
3008 11 => 'Nov',
3009 12 => 'Dec',
3010 ));
3011 return t($months[$month]);
3012 }
3013
3017 function weight_value(&$form) {
3018 if (isset($form['#default_value'])) {
3019 $form['#value'] = $form['#default_value'];
3020 }
3021 else {
3022 $form['#value'] = 0;
3023 }
3024 }
3025
3029 function form_process_radios($element) {
3030 if (count($element['#options']) > 0) {
3031 $weight = 0;
3032 foreach ($element['#options'] as $key => $choice) {
3033 // Maintain order of options as defined in #options, in case the element
3034 // defines custom option sub-elements, but does not define all option
3035 // sub-elements.
3036 $weight += 0.001;
3037
3038 $element += array($key => array());
3039 // Generate the parents as the autogenerator does, so we will have a
3040 // unique id for each radio button.
3041 $parents_for_id = array_merge($element['#parents'], array($key));
3042 $element[$key] += array(
3043 '#type' => 'radio',
3044 '#title' => $choice,
3045 // The key is sanitized in drupal_attributes() during output from the
3046 // theme function.
3047 '#return_value' => $key,
3048 // Use default or FALSE. A value of FALSE means that the radio button is
3049 // not 'checked'.
3050 '#default_value' => isset($element['#default_value']) ? $element['#default_value'] : FALSE,
3051 '#attributes' => $element['#attributes'],
3052 '#parents' => $element['#parents'],
3053 '#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)),
3054 '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
3055 '#weight' => $weight,
3056 );
3057 }
3058 }
3059 return $element;
3060 }
3061
3073 function theme_checkbox($variables) {
3074 $element = $variables['element'];
3075 $element['#attributes']['type'] = 'checkbox';
3076 element_set_attributes($element, array('id', 'name', '#return_value' => 'value'));
3077
3078 // Unchecked checkbox has #value of integer 0.
3079 if (!empty($element['#checked'])) {
3080 $element['#attributes']['checked'] = 'checked';
3081 }
3082 _form_set_class($element, array('form-checkbox'));
3083
3084 return '<input' . drupal_attributes($element['#attributes']) . ' />';
3085 }
3086
3097 function theme_checkboxes($variables) {
3098 $element = $variables['element'];
3099 $attributes = array();
3100 if (isset($element['#id'])) {
3101 $attributes['id'] = $element['#id'];
3102 }
3103 $attributes['class'][] = 'form-checkboxes';
3104 if (!empty($element['#attributes']['class'])) {
3105 $attributes['class'] = array_merge($attributes['class'], $element['#attributes']['class']);
3106 }
3107 if (isset($element['#attributes']['title'])) {
3108 $attributes['title'] = $element['#attributes']['title'];
3109 }
3110 return '<div' . drupal_attributes($attributes) . '>' . (!empty($element['#children']) ? $element['#children'] : '') . '</div>';
3111 }
3112
3118 function form_pre_render_conditional_form_element($element) {
3119 $t = get_t();
3120 // Set the element's title attribute to show #title as a tooltip, if needed.
3121 if (isset($element['#title']) && $element['#title_display'] == 'attribute') {
3122 $element['#attributes']['title'] = $element['#title'];
3123 if (!empty($element['#required'])) {
3124 // Append an indication that this field is required.
3125 $element['#attributes']['title'] .= ' (' . $t('Required') . ')';
3126 }
3127 }
3128
3129 if (isset($element['#title']) || isset($element['#description'])) {
3130 $element['#theme_wrappers'][] = 'form_element';
3131 }
3132 return $element;
3133 }
3134
3138 function form_process_checkbox($element, $form_state) {
3139 $value = $element['#value'];
3140 $return_value = $element['#return_value'];
3141 // On form submission, the #value of an available and enabled checked
3142 // checkbox is #return_value, and the #value of an available and enabled
3143 // unchecked checkbox is integer 0. On not submitted forms, and for
3144 // checkboxes with #access=FALSE or #disabled=TRUE, the #value is
3145 // #default_value (integer 0 if #default_value is NULL). Most of the time,
3146 // a string comparison of #value and #return_value is sufficient for
3147 // determining the "checked" state, but a value of TRUE always means checked
3148 // (even if #return_value is 'foo'), and a value of FALSE or integer 0 always
3149 // means unchecked (even if #return_value is '' or '0').
3150 if ($value === TRUE || $value === FALSE || $value === 0) {
3151 $element['#checked'] = (bool) $value;
3152 }
3153 else {
3154 // Compare as strings, so that 15 is not considered equal to '15foo', but 1
3155 // is considered equal to '1'. This cast does not imply that either #value
3156 // or #return_value is expected to be a string.
3157 $element['#checked'] = ((string) $value === (string) $return_value);
3158 }
3159 return $element;
3160 }
3161
3165 function form_process_checkboxes($element) {
3166 $value = is_array($element['#value']) ? $element['#value'] : array();
3167 $element['#tree'] = TRUE;
3168 if (count($element['#options']) > 0) {
3169 if (!isset($element['#default_value']) || $element['#default_value'] == 0) {
3170 $element['#default_value'] = array();
3171 }
3172 $weight = 0;
3173 foreach ($element['#options'] as $key => $choice) {
3174 // Integer 0 is not a valid #return_value, so use '0' instead.
3175 // @see form_type_checkbox_value().
3176 // @todo For Drupal 8, cast all integer keys to strings for consistency
3177 // with form_process_radios().
3178 if ($key === 0) {
3179 $key = '0';
3180 }
3181 // Maintain order of options as defined in #options, in case the element
3182 // defines custom option sub-elements, but does not define all option
3183 // sub-elements.
3184 $weight += 0.001;
3185
3186 $element += array($key => array());
3187 $element[$key] += array(
3188 '#type' => 'checkbox',
3189 '#title' => $choice,
3190 '#return_value' => $key,
3191 '#default_value' => isset($value[$key]) ? $key : NULL,
3192 '#attributes' => $element['#attributes'],
3193 '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
3194 '#weight' => $weight,
3195 );
3196 }
3197 }
3198 return $element;
3199 }
3200
3213 function form_process_actions($element, &$form_state) {
3214 $element['#attributes']['class'][] = 'form-actions';
3215 return $element;
3216 }
3217
3230 function form_process_container($element, &$form_state) {
3231 // Generate the ID of the element if it's not explicitly given.
3232 if (!isset($element['#id'])) {
3233 $element['#id'] = drupal_html_id(implode('-', $element['#parents']) . '-wrapper');
3234 }
3235 return $element;
3236 }
3237
3252 function theme_container($variables) {
3253 $element = $variables['element'];
3254
3255 // Special handling for form elements.
3256 if (isset($element['#array_parents'])) {
3257 // Assign an html ID.
3258 if (!isset($element['#attributes']['id'])) {
3259 $element['#attributes']['id'] = $element['#id'];
3260 }
3261 // Add the 'form-wrapper' class.
3262 $element['#attributes']['class'][] = 'form-wrapper';
3263 }
3264
3265 return '<div' . drupal_attributes($element['#attributes']) . '>' . $element['#children'] . '</div>';
3266 }
3267
3310 function theme_tableselect($variables) {
3311 $element = $variables['element'];
3312 $rows = array();
3313 $header = $element['#header'];
3314 if (!empty($element['#options'])) {
3315 // Generate a table row for each selectable item in #options.
3316 foreach (element_children($element) as $key) {
3317 $row = array();
3318
3319 $row['data'] = array();
3320 if (isset($element['#options'][$key]['#attributes'])) {
3321 $row += $element['#options'][$key]['#attributes'];
3322 }
3323 // Render the checkbox / radio element.
3324 $row['data'][] = drupal_render($element[$key]);
3325
3326 // As theme_table only maps header and row columns by order, create the
3327 // correct order by iterating over the header fields.
3328 foreach ($element['#header'] as $fieldname => $title) {
3329 $row['data'][] = $element['#options'][$key][$fieldname];
3330 }
3331 $rows[] = $row;
3332 }
3333 // Add an empty header or a "Select all" checkbox to provide room for the
3334 // checkboxes/radios in the first table column.
3335 if ($element['#js_select']) {
3336 // Add a "Select all" checkbox.
3337 drupal_add_js('misc/tableselect.js');
3338 array_unshift($header, array('class' => array('select-all')));
3339 }
3340 else {
3341 // Add an empty header when radio buttons are displayed or a "Select all"
3342 // checkbox is not desired.
3343 array_unshift($header, '');
3344 }
3345 }
3346 return theme('table', array('header' => $header, 'rows' => $rows, 'empty' => $element['#empty'], 'attributes' => $element['#attributes']));
3347 }
3348
3359 function form_process_tableselect($element) {
3360
3361 if ($element['#multiple']) {
3362 $value = is_array($element['#value']) ? $element['#value'] : array();
3363 }
3364 else {
3365 // Advanced selection behavior makes no sense for radios.
3366 $element['#js_select'] = FALSE;
3367 }
3368
3369 $element['#tree'] = TRUE;
3370
3371 if (count($element['#options']) > 0) {
3372 if (!isset($element['#default_value']) || $element['#default_value'] === 0) {
3373 $element['#default_value'] = array();
3374 }
3375
3376 // Create a checkbox or radio for each item in #options in such a way that
3377 // the value of the tableselect element behaves as if it had been of type
3378 // checkboxes or radios.
3379 foreach ($element['#options'] as $key => $choice) {
3380 // Do not overwrite manually created children.
3381 if (!isset($element[$key])) {
3382 if ($element['#multiple']) {
3383 $title = '';
3384 if (!empty($element['#options'][$key]['title']['data']['#title'])) {
3385 $title = t('Update @title', array(
3386 '@title' => $element['#options'][$key]['title']['data']['#title'],
3387 ));
3388 }
3389 $element[$key] = array(
3390 '#type' => 'checkbox',
3391 '#title' => $title,
3392 '#title_display' => 'invisible',
3393 '#return_value' => $key,
3394 '#default_value' => isset($value[$key]) ? $key : NULL,
3395 '#attributes' => $element['#attributes'],
3396 );
3397 }
3398 else {
3399 // Generate the parents as the autogenerator does, so we will have a
3400 // unique id for each radio button.
3401 $parents_for_id = array_merge($element['#parents'], array($key));
3402 $element[$key] = array(
3403 '#type' => 'radio',
3404 '#title' => '',
3405 '#return_value' => $key,
3406 '#default_value' => ($element['#default_value'] == $key) ? $key : NULL,
3407 '#attributes' => $element['#attributes'],
3408 '#parents' => $element['#parents'],
3409 '#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)),
3410 '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
3411 );
3412 }
3413 if (isset($element['#options'][$key]['#weight'])) {
3414 $element[$key]['#weight'] = $element['#options'][$key]['#weight'];
3415 }
3416 }
3417 }
3418 }
3419 else {
3420 $element['#value'] = array();
3421 }
3422 return $element;
3423 }
3424
3457 function form_process_machine_name($element, &$form_state) {
3458 // Apply default form element properties.
3459 $element += array(
3460 '#title' => t('Machine-readable name'),
3461 '#description' => t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'),
3462 '#machine_name' => array(),
3463 '#field_prefix' => '',
3464 '#field_suffix' => '',
3465 '#suffix' => '',
3466 );
3467 // A form element that only wants to set one #machine_name property (usually
3468 // 'source' only) would leave all other properties undefined, if the defaults
3469 // were defined in hook_element_info(). Therefore, we apply the defaults here.
3470 $element['#machine_name'] += array(
3471 'source' => array('name'),
3472 'target' => '#' . $element['#id'],
3473 'label' => t('Machine name'),
3474 'replace_pattern' => '[^a-z0-9_]+',
3475 'replace' => '_',
3476 'standalone' => FALSE,
3477 'field_prefix' => $element['#field_prefix'],
3478 'field_suffix' => $element['#field_suffix'],
3479 );
3480
3481 // By default, machine names are restricted to Latin alphanumeric characters.
3482 // So, default to LTR directionality.
3483 if (!isset($element['#attributes'])) {
3484 $element['#attributes'] = array();
3485 }
3486 $element['#attributes'] += array('dir' => 'ltr');
3487
3488 // The source element defaults to array('name'), but may have been overidden.
3489 if (empty($element['#machine_name']['source'])) {
3490 return $element;
3491 }
3492
3493 // Retrieve the form element containing the human-readable name from the
3494 // complete form in $form_state. By reference, because we may need to append
3495 // a #field_suffix that will hold the live preview.
3496 $key_exists = NULL;
3497 $source = drupal_array_get_nested_value($form_state['complete form'], $element['#machine_name']['source'], $key_exists);
3498 if (!$key_exists) {
3499 return $element;
3500 }
3501
3502 $suffix_id = $source['#id'] . '-machine-name-suffix';
3503 $element['#machine_name']['suffix'] = '#' . $suffix_id;
3504
3505 if ($element['#machine_name']['standalone']) {
3506 $element['#suffix'] .= ' <small id="' . $suffix_id . '">&nbsp;</small>';
3507 }
3508 else {
3509 // Append a field suffix to the source form element, which will contain
3510 // the live preview of the machine name.
3511 $source += array('#field_suffix' => '');
3512 $source['#field_suffix'] .= ' <small id="' . $suffix_id . '">&nbsp;</small>';
3513
3514 $parents = array_merge($element['#machine_name']['source'], array('#field_suffix'));
3515 drupal_array_set_nested_value($form_state['complete form'], $parents, $source['#field_suffix']);
3516 }
3517
3518 $js_settings = array(
3519 'type' => 'setting',
3520 'data' => array(
3521 'machineName' => array(
3522 '#' . $source['#id'] => $element['#machine_name'],
3523 ),
3524 ),
3525 );
3526 $element['#attached']['js'][] = 'misc/machine-name.js';
3527 $element['#attached']['js'][] = $js_settings;
3528
3529 return $element;
3530 }
3531
3537 function form_validate_machine_name(&$element, &$form_state) {
3538 // Verify that the machine name not only consists of replacement tokens.
3539 if (preg_match('@^' . $element['#machine_name']['replace'] . '+$@', $element['#value'])) {
3540 form_error($element, t('The machine-readable name must contain unique characters.'));
3541 }
3542
3543 // Verify that the machine name contains no disallowed characters.
3544 if (preg_match('@' . $element['#machine_name']['replace_pattern'] . '@', $element['#value'])) {
3545 if (!isset($element['#machine_name']['error'])) {
3546 // Since a hyphen is the most common alternative replacement character,
3547 // a corresponding validation error message is supported here.
3548 if ($element['#machine_name']['replace'] == '-') {
3549 form_error($element, t('The machine-readable name must contain only lowercase letters, numbers, and hyphens.'));
3550 }
3551 // Otherwise, we assume the default (underscore).
3552 else {
3553 form_error($element, t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
3554 }
3555 }
3556 else {
3557 form_error($element, $element['#machine_name']['error']);
3558 }
3559 }
3560
3561 // Verify that the machine name is unique.
3562 if ($element['#default_value'] !== $element['#value']) {
3563 $function = $element['#machine_name']['exists'];
3564 if ($function($element['#value'], $element, $form_state)) {
3565 form_error($element, t('The machine-readable name is already in use. It must be unique.'));
3566 }
3567 }
3568 }
3569
3583 function form_process_fieldset(&$element, &$form_state) {
3584 $parents = implode('][', $element['#parents']);
3585
3586 // Each fieldset forms a new group. The #type 'vertical_tabs' basically only
3587 // injects a new fieldset.
3588 $form_state['groups'][$parents]['#group_exists'] = TRUE;
3589 $element['#groups'] = &$form_state['groups'];
3590
3591 // Process vertical tabs group member fieldsets.
3592 if (isset($element['#group'])) {
3593 // Add this fieldset to the defined group (by reference).
3594 $group = $element['#group'];
3595 $form_state['groups'][$group][] = &$element;
3596 }
3597
3598 // Contains form element summary functionalities.
3599 $element['#attached']['library'][] = array('system', 'drupal.form');
3600
3601 // The .form-wrapper class is required for #states to treat fieldsets like
3602 // containers.
3603 if (!isset($element['#attributes']['class'])) {
3604 $element['#attributes']['class'] = array();
3605 }
3606
3607 // Collapsible fieldsets
3608 if (!empty($element['#collapsible'])) {
3609 $element['#attached']['library'][] = array('system', 'drupal.collapse');
3610 $element['#attributes']['class'][] = 'collapsible';
3611 if (!empty($element['#collapsed'])) {
3612 $element['#attributes']['class'][] = 'collapsed';
3613 }
3614 }
3615
3616 return $element;
3617 }
3618
3629 function form_pre_render_fieldset($element) {
3630 // Fieldsets may be rendered outside of a Form API context.
3631 if (!isset($element['#parents']) || !isset($element['#groups'])) {
3632 return $element;
3633 }
3634 // Inject group member elements belonging to this group.
3635 $parents = implode('][', $element['#parents']);
3636 $children = element_children($element['#groups'][$parents]);
3637 if (!empty($children)) {
3638 foreach ($children as $key) {
3639 // Break references and indicate that the element should be rendered as
3640 // group member.
3641 $child = (array) $element['#groups'][$parents][$key];
3642 $child['#group_fieldset'] = TRUE;
3643 // Inject the element as new child element.
3644 $element[] = $child;
3645
3646 $sort = TRUE;
3647 }
3648 // Re-sort the element's children if we injected group member elements.
3649 if (isset($sort)) {
3650 $element['#sorted'] = FALSE;
3651 }
3652 }
3653
3654 if (isset($element['#group'])) {
3655 $group = $element['#group'];
3656 // If this element belongs to a group, but the group-holding element does
3657 // not exist, we need to render it (at its original location).
3658 if (!isset($element['#groups'][$group]['#group_exists'])) {
3659 // Intentionally empty to clarify the flow; we simply return $element.
3660 }
3661 // If we injected this element into the group, then we want to render it.
3662 elseif (!empty($element['#group_fieldset'])) {
3663 // Intentionally empty to clarify the flow; we simply return $element.
3664 }
3665 // Otherwise, this element belongs to a group and the group exists, so we do
3666 // not render it.
3667 elseif (element_children($element['#groups'][$group])) {
3668 $element['#printed'] = TRUE;
3669 }
3670 }
3671
3672 return $element;
3673 }
3674
3687 function form_process_vertical_tabs($element, &$form_state) {
3688 // Inject a new fieldset as child, so that form_process_fieldset() processes
3689 // this fieldset like any other fieldset.
3690 $element['group'] = array(
3691 '#type' => 'fieldset',
3692 '#theme_wrappers' => array(),
3693 '#parents' => $element['#parents'],
3694 );
3695
3696 // The JavaScript stores the currently selected tab in this hidden
3697 // field so that the active tab can be restored the next time the
3698 // form is rendered, e.g. on preview pages or when form validation
3699 // fails.
3700 $name = implode('__', $element['#parents']);
3701 if (isset($form_state['values'][$name . '__active_tab'])) {
3702 $element['#default_tab'] = $form_state['values'][$name . '__active_tab'];
3703 }
3704 $element[$name . '__active_tab'] = array(
3705 '#type' => 'hidden',
3706 '#default_value' => $element['#default_tab'],
3707 '#attributes' => array('class' => array('vertical-tabs-active-tab')),
3708 );
3709
3710 return $element;
3711 }
3712
3723 function theme_vertical_tabs($variables) {
3724 $element = $variables['element'];
3725 // Add required JavaScript and Stylesheet.
3726 drupal_add_library('system', 'drupal.vertical-tabs');
3727
3728 $output = '<h2 class="element-invisible">' . t('Vertical Tabs') . '</h2>';
3729 $output .= '<div class="vertical-tabs-panes">' . $element['#children'] . '</div>';
3730 return $output;
3731 }
3732
3743 function theme_submit($variables) {
3744 return theme('button', $variables['element']);
3745 }
3746
3757 function theme_button($variables) {
3758 $element = $variables['element'];
3759 $element['#attributes']['type'] = 'submit';
3760 element_set_attributes($element, array('id', 'name', 'value'));
3761
3762 $element['#attributes']['class'][] = 'form-' . $element['#button_type'];
3763 if (!empty($element['#attributes']['disabled'])) {
3764 $element['#attributes']['class'][] = 'form-button-disabled';
3765 }
3766
3767 return '<input' . drupal_attributes($element['#attributes']) . ' />';
3768 }
3769
3780 function theme_image_button($variables) {
3781 $element = $variables['element'];
3782 $element['#attributes']['type'] = 'image';
3783 element_set_attributes($element, array('id', 'name', 'value'));
3784
3785 $element['#attributes']['src'] = file_create_url($element['#src']);
3786 if (!empty($element['#title'])) {
3787 $element['#attributes']['alt'] = $element['#title'];
3788 $element['#attributes']['title'] = $element['#title'];
3789 }
3790
3791 $element['#attributes']['class'][] = 'form-' . $element['#button_type'];
3792 if (!empty($element['#attributes']['disabled'])) {
3793 $element['#attributes']['class'][] = 'form-button-disabled';
3794 }
3795
3796 return '<input' . drupal_attributes($element['#attributes']) . ' />';
3797 }
3798
3809 function theme_hidden($variables) {
3810 $element = $variables['element'];
3811 $element['#attributes']['type'] = 'hidden';
3812 element_set_attributes($element, array('name', 'value'));
3813 return '<input' . drupal_attributes($element['#attributes']) . " />\n";
3814 }
3815
3827 function theme_textfield($variables) {
3828 $element = $variables['element'];
3829 $element['#attributes']['type'] = 'text';
3830 element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength'));
3831 _form_set_class($element, array('form-text'));
3832
3833 $extra = '';
3834 if ($element['#autocomplete_path'] && drupal_valid_path($element['#autocomplete_path'])) {
3835 drupal_add_library('system', 'drupal.autocomplete');
3836 $element['#attributes']['class'][] = 'form-autocomplete';
3837
3838 $attributes = array();
3839 $attributes['type'] = 'hidden';
3840 $attributes['id'] = $element['#attributes']['id'] . '-autocomplete';
3841 $attributes['value'] = url($element['#autocomplete_path'], array('absolute' => TRUE));
3842 $attributes['disabled'] = 'disabled';
3843 $attributes['class'][] = 'autocomplete';
3844 $extra = '<input' . drupal_attributes($attributes) . ' />';
3845 }
3846
3847 $output = '<input' . drupal_attributes($element['#attributes']) . ' />';
3848
3849 return $output . $extra;
3850 }
3851
3862 function theme_form($variables) {
3863 $element = $variables['element'];
3864 if (isset($element['#action'])) {
3865 $element['#attributes']['action'] = drupal_strip_dangerous_protocols($element['#action']);
3866 }
3867 element_set_attributes($element, array('method', 'id'));
3868 if (empty($element['#attributes']['accept-charset'])) {
3869 $element['#attributes']['accept-charset'] = "UTF-8";
3870 }
3871 // Anonymous DIV to satisfy XHTML compliance.
3872 return '<form' . drupal_attributes($element['#attributes']) . '><div>' . $element['#children'] . '</div></form>';
3873 }
3874
3886 function theme_textarea($variables) {
3887 $element = $variables['element'];
3888 element_set_attributes($element, array('id', 'name', 'cols', 'rows'));
3889 _form_set_class($element, array('form-textarea'));
3890
3891 $wrapper_attributes = array(
3892 'class' => array('form-textarea-wrapper'),
3893 );
3894
3895 // Add resizable behavior.
3896 if (!empty($element['#resizable'])) {
3897 drupal_add_library('system', 'drupal.textarea');
3898 $wrapper_attributes['class'][] = 'resizable';
3899 }
3900
3901 $output = '<div' . drupal_attributes($wrapper_attributes) . '>';
3902 $output .= '<textarea' . drupal_attributes($element['#attributes']) . '>' . check_plain($element['#value']) . '</textarea>';
3903 $output .= '</div>';
3904 return $output;
3905 }
3906
3918 function theme_password($variables) {
3919 $element = $variables['element'];
3920 $element['#attributes']['type'] = 'password';
3921 element_set_attributes($element, array('id', 'name', 'size', 'maxlength'));
3922 _form_set_class($element, array('form-text'));
3923
3924 return '<input' . drupal_attributes($element['#attributes']) . ' />';
3925 }
3926
3930 function form_process_weight($element) {
3931 $element['#is_weight'] = TRUE;
3932
3933 // If the number of options is small enough, use a select field.
3934 $max_elements = variable_get('drupal_weight_select_max', DRUPAL_WEIGHT_SELECT_MAX);
3935 if ($element['#delta'] <= $max_elements) {
3936 $element['#type'] = 'select';
3937 for ($n = (-1 * $element['#delta']); $n <= $element['#delta']; $n++) {
3938 $weights[$n] = $n;
3939 }
3940 $element['#options'] = $weights;
3941 $element += element_info('select');
3942 }
3943 // Otherwise, use a text field.
3944 else {
3945 $element['#type'] = 'textfield';
3946 // Use a field big enough to fit most weights.
3947 $element['#size'] = 10;
3948 $element['#element_validate'] = array('element_validate_integer');
3949 $element += element_info('textfield');
3950 }
3951
3952 return $element;
3953 }
3954
3969 function theme_file($variables) {
3970 $element = $variables['element'];
3971 $element['#attributes']['type'] = 'file';
3972 element_set_attributes($element, array('id', 'name', 'size'));
3973 _form_set_class($element, array('form-file'));
3974
3975 return '<input' . drupal_attributes($element['#attributes']) . ' />';
3976 }
3977
4024 function theme_form_element($variables) {
4025 $element = &$variables['element'];
4026
4027 // This function is invoked as theme wrapper, but the rendered form element
4028 // may not necessarily have been processed by form_builder().
4029 $element += array(
4030 '#title_display' => 'before',
4031 );
4032
4033 // Add element #id for #type 'item'.
4034 if (isset($element['#markup']) && !empty($element['#id'])) {
4035 $attributes['id'] = $element['#id'];
4036 }
4037 // Add element's #type and #name as class to aid with JS/CSS selectors.
4038 $attributes['class'] = array('form-item');
4039 if (!empty($element['#type'])) {
4040 $attributes['class'][] = 'form-type-' . strtr($element['#type'], '_', '-');
4041 }
4042 if (!empty($element['#name'])) {
4043 $attributes['class'][] = 'form-item-' . strtr($element['#name'], array(' ' => '-', '_' => '-', '[' => '-', ']' => ''));
4044 }
4045 // Add a class for disabled elements to facilitate cross-browser styling.
4046 if (!empty($element['#attributes']['disabled'])) {
4047 $attributes['class'][] = 'form-disabled';
4048 }
4049 $output = '<div' . drupal_attributes($attributes) . '>' . "\n";
4050
4051 // If #title is not set, we don't display any label or required marker.
4052 if (!isset($element['#title'])) {
4053 $element['#title_display'] = 'none';
4054 }
4055 $prefix = isset($element['#field_prefix']) ? '<span class="field-prefix">' . $element['#field_prefix'] . '</span> ' : '';
4056 $suffix = isset($element['#field_suffix']) ? ' <span class="field-suffix">' . $element['#field_suffix'] . '</span>' : '';
4057
4058 switch ($element['#title_display']) {
4059 case 'before':
4060 case 'invisible':
4061 $output .= ' ' . theme('form_element_label', $variables);
4062 $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n";
4063 break;
4064
4065 case 'after':
4066 $output .= ' ' . $prefix . $element['#children'] . $suffix;
4067 $output .= ' ' . theme('form_element_label', $variables) . "\n";
4068 break;
4069
4070 case 'none':
4071 case 'attribute':
4072 // Output no label and no required marker, only the children.
4073 $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n";
4074 break;
4075 }
4076
4077 if (!empty($element['#description'])) {
4078 $output .= '<div class="description">' . $element['#description'] . "</div>\n";
4079 }
4080
4081 $output .= "</div>\n";
4082
4083 return $output;
4084 }
4085
4095 function theme_form_required_marker($variables) {
4096 // This is also used in the installer, pre-database setup.
4097 $t = get_t();
4098 $attributes = array(
4099 'class' => 'form-required',
4100 'title' => $t('This field is required.'),
4101 );
4102 return '<span' . drupal_attributes($attributes) . '>*</span>';
4103 }
4104
4128 function theme_form_element_label($variables) {
4129 $element = $variables['element'];
4130 // This is also used in the installer, pre-database setup.
4131 $t = get_t();
4132
4133 // If title and required marker are both empty, output no label.
4134 if ((!isset($element['#title']) || $element['#title'] === '') && empty($element['#required'])) {
4135 return '';
4136 }
4137
4138 // If the element is required, a required marker is appended to the label.
4139 $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : '';
4140
4141 $title = filter_xss_admin($element['#title']);
4142
4143 $attributes = array();
4144 // Style the label as class option to display inline with the element.
4145 if ($element['#title_display'] == 'after') {
4146 $attributes['class'] = 'option';
4147 }
4148 // Show label only to screen readers to avoid disruption in visual flows.
4149 elseif ($element['#title_display'] == 'invisible') {
4150 $attributes['class'] = 'element-invisible';
4151 }
4152
4153 if (!empty($element['#id'])) {
4154 $attributes['for'] = $element['#id'];
4155 }
4156
4157 // The leading whitespace helps visually separate fields from inline labels.
4158 return ' <label' . drupal_attributes($attributes) . '>' . $t('!title !required', array('!title' => $title, '!required' => $required)) . "</label>\n";
4159 }
4160
4171 function _form_set_class(&$element, $class = array()) {
4172 if (!empty($class)) {
4173 if (!isset($element['#attributes']['class'])) {
4174 $element['#attributes']['class'] = array();
4175 }
4176 $element['#attributes']['class'] = array_merge($element['#attributes']['class'], $class);
4177 }
4178 // This function is invoked from form element theme functions, but the
4179 // rendered form element may not necessarily have been processed by
4180 // form_builder().
4181 if (!empty($element['#required'])) {
4182 $element['#attributes']['class'][] = 'required';
4183 }
4184 if (isset($element['#parents']) && form_get_error($element) !== NULL && !empty($element['#validated'])) {
4185 $element['#attributes']['class'][] = 'error';
4186 }
4187 }
4188
4192 function element_validate_integer($element, &$form_state) {
4193 $value = $element['#value'];
4194 if ($value !== '' && (!is_numeric($value) || intval($value) != $value)) {
4195 form_error($element, t('%name must be an integer.', array('%name' => $element['#title'])));
4196 }
4197 }
4198
4202 function element_validate_integer_positive($element, &$form_state) {
4203 $value = $element['#value'];
4204 if ($value !== '' && (!is_numeric($value) || intval($value) != $value || $value <= 0)) {
4205 form_error($element, t('%name must be a positive integer.', array('%name' => $element['#title'])));
4206 }
4207 }
4208
4212 function element_validate_number($element, &$form_state) {
4213 $value = $element['#value'];
4214 if ($value != '' && !is_numeric($value)) {
4215 form_error($element, t('%name must be a number.', array('%name' => $element['#title'])));
4216 }
4217 }
4218
4381 function batch_set($batch_definition) {
4382 if ($batch_definition) {
4383 $batch =& batch_get();
4384
4385 // Initialize the batch if needed.
4386 if (empty($batch)) {
4387 $batch = array(
4388 'sets' => array(),
4389 'has_form_submits' => FALSE,
4390 );
4391 }
4392
4393 // Base and default properties for the batch set.
4394 // Use get_t() to allow batches during installation.
4395 $t = get_t();
4396 $init = array(
4397 'sandbox' => array(),
4398 'results' => array(),
4399 'success' => FALSE,
4400 'start' => 0,
4401 'elapsed' => 0,
4402 );
4403 $defaults = array(
4404 'title' => $t('Processing'),
4405 'init_message' => $t('Initializing.'),
4406 'progress_message' => $t('Completed @current of @total.'),
4407 'error_message' => $t('An error has occurred.'),
4408 'css' => array(),
4409 );
4410 $batch_set = $init + $batch_definition + $defaults;
4411
4412 // Tweak init_message to avoid the bottom of the page flickering down after
4413 // init phase.
4414 $batch_set['init_message'] .= '<br/>&nbsp;';
4415
4416 // The non-concurrent workflow of batch execution allows us to save
4417 // numberOfItems() queries by handling our own counter.
4418 $batch_set['total'] = count($batch_set['operations']);
4419 $batch_set['count'] = $batch_set['total'];
4420
4421 // Add the set to the batch.
4422 if (empty($batch['id'])) {
4423 // The batch is not running yet. Simply add the new set.
4424 $batch['sets'][] = $batch_set;
4425 }
4426 else {
4427 // The set is being added while the batch is running. Insert the new set
4428 // right after the current one to ensure execution order, and store its
4429 // operations in a queue.
4430 $index = $batch['current_set'] + 1;
4431 $slice1 = array_slice($batch['sets'], 0, $index);
4432 $slice2 = array_slice($batch['sets'], $index);
4433 $batch['sets'] = array_merge($slice1, array($batch_set), $slice2);
4434 _batch_populate_queue($batch, $index);
4435 }
4436 }
4437 }
4438
4459 function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'drupal_goto') {
4460 $batch =& batch_get();
4461
4462 drupal_theme_initialize();
4463
4464 if (isset($batch)) {
4465 // Add process information
4466 $process_info = array(
4467 'current_set' => 0,
4468 'progressive' => TRUE,
4469 'url' => $url,
4470 'url_options' => array(),
4471 'source_url' => $_GET['q'],
4472 'redirect' => $redirect,
4473 'theme' => $GLOBALS['theme_key'],
4474 'redirect_callback' => $redirect_callback,
4475 );
4476 $batch += $process_info;
4477
4478 // The batch is now completely built. Allow other modules to make changes
4479 // to the batch so that it is easier to reuse batch processes in other
4480 // environments.
4481 drupal_alter('batch', $batch);
4482
4483 // Assign an arbitrary id: don't rely on a serial column in the 'batch'
4484 // table, since non-progressive batches skip database storage completely.
4485 $batch['id'] = db_next_id();
4486
4487 // Move operations to a job queue. Non-progressive batches will use a
4488 // memory-based queue.
4489 foreach ($batch['sets'] as $key => $batch_set) {
4490 _batch_populate_queue($batch, $key);
4491 }
4492
4493 // Initiate processing.
4494 if ($batch['progressive']) {
4495 // Now that we have a batch id, we can generate the redirection link in
4496 // the generic error message.
4497 $t = get_t();
4498 $batch['error_message'] = $t('Please continue to <a href="@error_url">the error page</a>', array('@error_url' => url($url, array('query' => array('id' => $batch['id'], 'op' => 'finished')))));
4499
4500 // Clear the way for the drupal_goto() redirection to the batch processing
4501 // page, by saving and unsetting the 'destination', if there is any.
4502 if (isset($_GET['destination'])) {
4503 $batch['destination'] = $_GET['destination'];
4504 unset($_GET['destination']);
4505 }
4506
4507 // Store the batch.
4508 db_insert('batch')
4509 ->fields(array(
4510 'bid' => $batch['id'],
4511 'timestamp' => REQUEST_TIME,
4512 'token' => drupal_get_token($batch['id']),
4513 'batch' => serialize($batch),
4514 ))
4515 ->execute();
4516
4517 // Set the batch number in the session to guarantee that it will stay alive.
4518 $_SESSION['batches'][$batch['id']] = TRUE;
4519
4520 // Redirect for processing.
4521 $function = $batch['redirect_callback'];
4522 if (function_exists($function)) {
4523 $function($batch['url'], array('query' => array('op' => 'start', 'id' => $batch['id'])));
4524 }
4525 }
4526 else {
4527 // Non-progressive execution: bypass the whole progressbar workflow
4528 // and execute the batch in one pass.
4529 require_once DRUPAL_ROOT . '/includes/batch.inc';
4530 _batch_process();
4531 }
4532 }
4533 }
4534
4538 function &batch_get() {
4539 // Not drupal_static(), because Batch API operates at a lower level than most
4540 // use-cases for resetting static variables, and we specifically do not want a
4541 // global drupal_static_reset() resetting the batch information. Functions
4542 // that are part of the Batch API and need to reset the batch information may
4543 // call batch_get() and manipulate the result by reference. Functions that are
4544 // not part of the Batch API can also do this, but shouldn't.
4545 static $batch = array();
4546 return $batch;
4547 }
4548
4563 function _batch_populate_queue(&$batch, $set_id) {
4564 $batch_set = &$batch['sets'][$set_id];
4565
4566 if (isset($batch_set['operations'])) {
4567 $batch_set += array(
4568 'queue' => array(
4569 'name' => 'drupal_batch:' . $batch['id'] . ':' . $set_id,
4570 'class' => $batch['progressive'] ? 'BatchQueue' : 'BatchMemoryQueue',
4571 ),
4572 );
4573
4574 $queue = _batch_queue($batch_set);
4575 $queue->createQueue();
4576 foreach ($batch_set['operations'] as $operation) {
4577 $queue->createItem($operation);
4578 }
4579
4580 unset($batch_set['operations']);
4581 }
4582 }
4583
4593 function _batch_queue($batch_set) {
4594 static $queues;
4595
4596 // The class autoloader is not available when running update.php, so make
4597 // sure the files are manually included.
4598 if (!isset($queues)) {
4599 $queues = array();
4600 require_once DRUPAL_ROOT . '/modules/system/system.queue.inc';
4601 require_once DRUPAL_ROOT . '/includes/batch.queue.inc';
4602 }
4603
4604 if (isset($batch_set['queue'])) {
4605 $name = $batch_set['queue']['name'];
4606 $class = $batch_set['queue']['class'];
4607
4608 if (!isset($queues[$class][$name])) {
4609 $queues[$class][$name] = new $class($name);
4610 }
4611 return $queues[$class][$name];
4612 }
4613 }
4614
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
theme_password
theme_password($variables)
Definition: form.inc:3918
theme_checkboxes
theme_checkboxes($variables)
Definition: form.inc:3097
batch_process
batch_process($redirect=NULL, $url= 'batch', $redirect_callback= 'drupal_goto')
Definition: form.inc:4459
form_builder
form_builder($form_id, &$element, &$form_state)
Definition: form.inc:1758
form_select_options
form_select_options($element, $choices=NULL)
Definition: form.inc:2679
form_get_cache
form_get_cache($form_build_id, &$form_state)
Definition: form.inc:503
db_next_id
db_next_id($existing_id=0)
Definition: database.inc:2653
form_execute_handlers
form_execute_handlers($type, &$form, &$form_state)
Definition: form.inc:1452
url_is_external
url_is_external($path)
Definition: common.inc:2311
date_validate
date_validate($element)
Definition: form.inc:2987
_form_button_was_clicked
_form_button_was_clicked($element, &$form_state)
Definition: form.inc:2121
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
form_type_checkboxes_value
form_type_checkboxes_value($element, $input=FALSE)
Definition: form.inc:2298
theme_image_button
theme_image_button($variables)
Definition: form.inc:3780
menu_get_item
menu_get_item($path=NULL, $router_item=NULL)
Definition: menu.inc:447
form_process_tableselect
form_process_tableselect($element)
Definition: form.inc:3359
form_process_checkbox
form_process_checkbox($element, $form_state)
Definition: form.inc:3138
drupal_strlen
drupal_strlen($text)
Definition: unicode.inc:474
drupal_array_nested_key_exists
drupal_array_nested_key_exists(array $array, array $parents)
Definition: common.inc:6710
theme_submit
theme_submit($variables)
Definition: form.inc:3743
form_set_cache
form_set_cache($form_build_id, $form, $form_state)
Definition: form.inc:534
drupal_redirect_form
drupal_redirect_form($form_state)
Definition: form.inc:1249
form_process_select
form_process_select($element)
Definition: form.inc:2613
drupal_array_get_nested_value
& drupal_array_get_nested_value(array &$array, array $parents, &$key_exists=NULL)
Definition: common.inc:6666
form_process_machine_name
form_process_machine_name($element, &$form_state)
Definition: form.inc:3457
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
drupal_valid_path
drupal_valid_path($path, $dynamic_allowed=FALSE)
Definition: path.inc:553
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
form_type_tableselect_value
form_type_tableselect_value($element, $input=FALSE)
Definition: form.inc:2339
$module
print $module
Definition: search-results.tpl.php:28
form_state_values_clean
form_state_values_clean(&$form_state)
Definition: form.inc:2159
file_create_url
file_create_url($uri)
Definition: file.inc:372
form_get_options
form_get_options($element, $key)
Definition: form.inc:2743
$name
print $name
Definition: profile-listing.tpl.php:43
element_validate_number
element_validate_number($element, &$form_state)
Definition: form.inc:4212
theme_radios
theme_radios($variables)
Definition: form.inc:2833
drupal_get_query_parameters
drupal_get_query_parameters(array $query=NULL, array $exclude=array('q'), $parent= '')
Definition: common.inc:417
form_type_textfield_value
form_type_textfield_value($element, $input=FALSE)
Definition: form.inc:2475
form_type_select_value
form_type_select_value($element, $input=FALSE)
Definition: form.inc:2434
$header
print $header
Definition: forum-topic-list.tpl.php:42
theme_file
theme_file($variables)
Definition: form.inc:3969
drupal_attributes
drupal_attributes(array $attributes=array())
Definition: common.inc:2377
$attributes
print $attributes
Definition: block.tpl.php:47
drupal_strip_dangerous_protocols
drupal_strip_dangerous_protocols($uri)
Definition: common.inc:1340
_form_element_triggered_scripted_submission
_form_element_triggered_scripted_submission($element, &$form_state)
Definition: form.inc:2092
form_validate_machine_name
form_validate_machine_name(&$element, &$form_state)
Definition: form.inc:3537
form_pre_render_conditional_form_element
form_pre_render_conditional_form_element($element)
Definition: form.inc:3118
form_type_image_button_value
form_type_image_button_value($form, $input, $form_state)
Definition: form.inc:2211
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
theme_checkbox
theme_checkbox($variables)
Definition: form.inc:3073
theme_select
theme_select($variables)
Definition: form.inc:2658
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
element_info
element_info($type)
Definition: common.inc:6306
drupal_installation_attempted
drupal_installation_attempted()
Definition: bootstrap.inc:2605
theme_container
theme_container($variables)
Definition: form.inc:3252
drupal_prepare_form
drupal_prepare_form($form_id, &$form, &$form_state)
Definition: form.inc:969
theme_vertical_tabs
theme_vertical_tabs($variables)
Definition: form.inc:3723
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
element_validate_integer
element_validate_integer($element, &$form_state)
Definition: form.inc:4192
theme_date
theme_date($variables)
Definition: form.inc:2913
form_process_actions
form_process_actions($element, &$form_state)
Definition: form.inc:3213
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
element_validate_integer_positive
element_validate_integer_positive($element, &$form_state)
Definition: form.inc:4202
drupal_add_library
drupal_add_library($module, $name, $every_page=NULL)
Definition: common.inc:4694
_form_options_flatten
_form_options_flatten($array)
Definition: form.inc:2559
form_process_password_confirm
form_process_password_confirm($element)
Definition: form.inc:2852
theme_radio
theme_radio($variables)
Definition: form.inc:2809
drupal_valid_token
drupal_valid_token($token, $value= '', $skip_anonymous=FALSE)
Definition: common.inc:5095
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$url
print $url
Definition: search-result.tpl.php:70
batch_set
batch_set($batch_definition)
Definition: form.inc:4381
theme_textfield
theme_textfield($variables)
Definition: form.inc:3827
form_type_radios_value
form_type_radios_value(&$element, $input=FALSE)
Definition: form.inc:2375
form_process_radios
form_process_radios($element)
Definition: form.inc:3029
$info
$info
Definition: color.inc:6
form_process_date
form_process_date($element)
Definition: form.inc:2931
_batch_process
_batch_process()
Definition: batch.inc:241
drupal_rebuild_form
drupal_rebuild_form($form_id, &$form_state, $old_form=NULL)
Definition: form.inc:458
drupal_random_key
drupal_random_key($byte_count=32)
Definition: bootstrap.inc:1945
drupal_build_form
drupal_build_form($form_id, &$form_state)
Definition: form.inc:308
theme_form
theme_form($variables)
Definition: form.inc:3862
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
$value
print $value
Definition: user-profile-item.tpl.php:26
get_t
get_t()
Definition: bootstrap.inc:2635
_batch_populate_queue
_batch_populate_queue(&$batch, $set_id)
Definition: form.inc:4563
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
form_type_token_value
form_type_token_value($element, $input=FALSE)
Definition: form.inc:2496
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
map_month
map_month($month)
Definition: form.inc:2996
$output
$output
Definition: authorize.php:93
drupal_process_form
drupal_process_form($form_id, &$form, &$form_state)
Definition: form.inc:829
drupal_html_id
drupal_html_id($id)
Definition: common.inc:3879
form_load_include
form_load_include(&$form_state, $type, $module, $name=NULL)
Definition: form.inc:612
form_process_container
form_process_container($element, &$form_state)
Definition: form.inc:3230
theme_form_element_label
theme_form_element_label($variables)
Definition: form.inc:4128
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
theme_fieldset
theme_fieldset($variables)
Definition: form.inc:2772
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
form_get_errors
form_get_errors()
Definition: form.inc:1634
_form_set_class
_form_set_class(&$element, $class=array())
Definition: form.inc:4171
$choice
print $choice
Definition: poll-vote.tpl.php:25
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
element_set_attributes
element_set_attributes(array &$element, array $map)
Definition: common.inc:6487
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
drupal_theme_initialize
drupal_theme_initialize()
Definition: theme.inc:70
form_pre_render_fieldset
form_pre_render_fieldset($element)
Definition: form.inc:3629
form_state_defaults
form_state_defaults()
Definition: form.inc:396
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
theme_textarea
theme_textarea($variables)
Definition: form.inc:3886
_form_builder_handle_input_element
_form_builder_handle_input_element($form_id, &$element, &$form_state)
Definition: form.inc:1945
form_process_checkboxes
form_process_checkboxes($element)
Definition: form.inc:3165
drupal_form_submit
drupal_form_submit($form_id, &$form_state)
Definition: form.inc:685
drupal_retrieve_form
drupal_retrieve_form($form_id, &$form_state)
Definition: form.inc:728
_form_validate
_form_validate(&$elements, &$form_state, $form_id=NULL)
Definition: form.inc:1303
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
theme_tableselect
theme_tableselect($variables)
Definition: form.inc:3310
form_type_checkbox_value
form_type_checkbox_value($element, $input=FALSE)
Definition: form.inc:2257
drupal_validate_form
drupal_validate_form($form_id, &$form, &$form_state)
Definition: form.inc:1122
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
drupal_get_token
drupal_get_token($value= '')
Definition: common.inc:5077
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
weight_value
weight_value(&$form)
Definition: form.inc:3017
$children
print $children
Definition: book-node-export-html.tpl.php:24
$row
$row
Definition: block-admin-display-form.tpl.php:47
batch_get
& batch_get()
Definition: form.inc:4538
drupal_array_set_nested_value
drupal_array_set_nested_value(array &$array, array $parents, $value, $force=FALSE)
Definition: common.inc:6598
form_process_fieldset
form_process_fieldset(&$element, &$form_state)
Definition: form.inc:3583
theme_button
theme_button($variables)
Definition: form.inc:3757
form_clear_error
form_clear_error()
Definition: form.inc:1627
form_get_error
form_get_error($element)
Definition: form.inc:1647
_batch_queue
_batch_queue($batch_set)
Definition: form.inc:4593
current_path
current_path()
Definition: path.inc:354
form_type_password_confirm_value
form_type_password_confirm_value($element, $input=FALSE)
Definition: form.inc:2414
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
form_process_weight
form_process_weight($element)
Definition: form.inc:3930
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
form_options_flatten
form_options_flatten($array)
Definition: form.inc:2548
password_confirm_validate
password_confirm_validate($element, &$element_state)
Definition: form.inc:2880
form_process_vertical_tabs
form_process_vertical_tabs($element, &$form_state)
Definition: form.inc:3687
form_state_keys_no_cache
form_state_keys_no_cache()
Definition: form.inc:555
theme_form_element
theme_form_element($variables)
Definition: form.inc:4024
theme_form_required_marker
theme_form_required_marker($variables)
Definition: form.inc:4095
theme_hidden
theme_hidden($variables)
Definition: form.inc:3809
DRUPAL_WEIGHT_SELECT_MAX
const DRUPAL_WEIGHT_SELECT_MAX
Definition: system.module:53
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/book/book.admin.inc Source File

  • modules
  • book
book.admin.inc
Go to the documentation of this file.
1 <?php
2
16 function book_admin_overview() {
17 $rows = array();
18
19 $headers = array(t('Book'), t('Operations'));
20
21 // Add any recognized books to the table list.
22 foreach (book_get_books() as $book) {
23 $rows[] = array(l($book['title'], $book['href'], $book['options']), l(t('edit order and titles'), 'admin/content/book/' . $book['nid']));
24 }
25
26 return theme('table', array('header' => $headers, 'rows' => $rows, 'empty' => t('No books available.')));
27 }
28
36 function book_admin_settings() {
37 $types = node_type_get_names();
38 $form['book_allowed_types'] = array(
39 '#type' => 'checkboxes',
40 '#title' => t('Content types allowed in book outlines'),
41 '#default_value' => variable_get('book_allowed_types', array('book')),
42 '#options' => $types,
43 '#description' => t('Users with the %outline-perm permission can add all content types.', array('%outline-perm' => t('Administer book outlines'))),
44 '#required' => TRUE,
45 );
46 $form['book_child_type'] = array(
47 '#type' => 'radios',
48 '#title' => t('Content type for child pages'),
49 '#default_value' => variable_get('book_child_type', 'book'),
50 '#options' => $types,
51 '#required' => TRUE,
52 );
53 $form['array_filter'] = array('#type' => 'value', '#value' => TRUE);
54 $form['#validate'][] = 'book_admin_settings_validate';
55
56 return system_settings_form($form);
57 }
58
64 function book_admin_settings_validate($form, &$form_state) {
65 $child_type = $form_state['values']['book_child_type'];
66 if (empty($form_state['values']['book_allowed_types'][$child_type])) {
67 form_set_error('book_child_type', t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', array('%add-child' => t('Add child page'))));
68 }
69 }
70
83 function book_admin_edit($form, $form_state, $node) {
84 drupal_set_title($node->title);
85 $form['#node'] = $node;
86 _book_admin_table($node, $form);
87 $form['save'] = array(
88 '#type' => 'submit',
89 '#value' => t('Save book pages'),
90 );
91
92 return $form;
93 }
94
102 function book_admin_edit_validate($form, &$form_state) {
103 if ($form_state['values']['tree_hash'] != $form_state['values']['tree_current_hash']) {
104 form_set_error('', t('This book has been modified by another user, the changes could not be saved.'));
105 }
106 }
107
117 function book_admin_edit_submit($form, &$form_state) {
118 // Save elements in the same order as defined in post rather than the form.
119 // This ensures parents are updated before their children, preventing orphans.
120 $order = array_flip(array_keys($form_state['input']['table']));
121 $form['table'] = array_merge($order, $form['table']);
122
123 foreach (element_children($form['table']) as $key) {
124 if ($form['table'][$key]['#item']) {
125 $row = $form['table'][$key];
126 $values = $form_state['values']['table'][$key];
127
128 // Update menu item if moved.
129 if ($row['plid']['#default_value'] != $values['plid'] || $row['weight']['#default_value'] != $values['weight']) {
130 $row['#item']['plid'] = $values['plid'];
131 $row['#item']['weight'] = $values['weight'];
132 menu_link_save($row['#item']);
133 }
134
135 // Update the title if changed.
136 if ($row['title']['#default_value'] != $values['title']) {
137 $node = node_load($values['nid']);
138 $langcode = LANGUAGE_NONE;
139 $node->title = $values['title'];
140 $node->book['link_title'] = $values['title'];
141 $node->revision = 1;
142 $node->log = t('Title changed from %original to %current.', array('%original' => $node->title, '%current' => $values['title']));
143
144 node_save($node);
145 watchdog('content', 'book: updated %title.', array('%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid));
146 }
147 }
148 }
149
150 drupal_set_message(t('Updated book %title.', array('%title' => $form['#node']->title)));
151 }
152
163 function _book_admin_table($node, &$form) {
164 $form['table'] = array(
165 '#theme' => 'book_admin_table',
166 '#tree' => TRUE,
167 );
168
169 $tree = book_menu_subtree_data($node->book);
170 $tree = array_shift($tree); // Do not include the book item itself.
171 if ($tree['below']) {
172 $hash = drupal_hash_base64(serialize($tree['below']));
173 // Store the hash value as a hidden form element so that we can detect
174 // if another user changed the book hierarchy.
175 $form['tree_hash'] = array(
176 '#type' => 'hidden',
177 '#default_value' => $hash,
178 );
179 $form['tree_current_hash'] = array(
180 '#type' => 'value',
181 '#value' => $hash,
182 );
183 _book_admin_table_tree($tree['below'], $form['table']);
184 }
185
186 }
187
201 function _book_admin_table_tree($tree, &$form) {
202 // The delta must be big enough to give each node a distinct value.
203 $count = count($tree);
204 $delta = ($count < 30) ? 15 : intval($count / 2) + 1;
205
206 foreach ($tree as $data) {
207 $form['book-admin-' . $data['link']['nid']] = array(
208 '#item' => $data['link'],
209 'nid' => array('#type' => 'value', '#value' => $data['link']['nid']),
210 'depth' => array('#type' => 'value', '#value' => $data['link']['depth']),
211 'href' => array('#type' => 'value', '#value' => $data['link']['href']),
212 'title' => array(
213 '#type' => 'textfield',
214 '#default_value' => $data['link']['link_title'],
215 '#maxlength' => 255,
216 '#size' => 40,
217 ),
218 'weight' => array(
219 '#type' => 'weight',
220 '#default_value' => $data['link']['weight'],
221 '#delta' => max($delta, abs($data['link']['weight'])),
222 '#title' => t('Weight for @title', array('@title' => $data['link']['title'])),
223 '#title_display' => 'invisible',
224 ),
225 'plid' => array(
226 '#type' => 'hidden',
227 '#default_value' => $data['link']['plid'],
228 ),
229 'mlid' => array(
230 '#type' => 'hidden',
231 '#default_value' => $data['link']['mlid'],
232 ),
233 );
234 if ($data['below']) {
235 _book_admin_table_tree($data['below'], $form);
236 }
237 }
238
239 return $form;
240 }
241
252 function theme_book_admin_table($variables) {
253 $form = $variables['form'];
254
255 drupal_add_tabledrag('book-outline', 'match', 'parent', 'book-plid', 'book-plid', 'book-mlid', TRUE, MENU_MAX_DEPTH - 2);
256 drupal_add_tabledrag('book-outline', 'order', 'sibling', 'book-weight');
257
258 $header = array(t('Title'), t('Weight'), t('Parent'), array('data' => t('Operations'), 'colspan' => '3'));
259
260 $rows = array();
261 $destination = drupal_get_destination();
262 $access = user_access('administer nodes');
263 foreach (element_children($form) as $key) {
264 $nid = $form[$key]['nid']['#value'];
265 $href = $form[$key]['href']['#value'];
266
267 // Add special classes to be used with tabledrag.js.
268 $form[$key]['plid']['#attributes']['class'] = array('book-plid');
269 $form[$key]['mlid']['#attributes']['class'] = array('book-mlid');
270 $form[$key]['weight']['#attributes']['class'] = array('book-weight');
271
272 $data = array(
273 theme('indentation', array('size' => $form[$key]['depth']['#value'] - 2)) . drupal_render($form[$key]['title']),
274 drupal_render($form[$key]['weight']),
275 drupal_render($form[$key]['plid']) . drupal_render($form[$key]['mlid']),
276 l(t('view'), $href),
277 $access ? l(t('edit'), 'node/' . $nid . '/edit', array('query' => $destination)) : '&nbsp;',
278 $access ? l(t('delete'), 'node/' . $nid . '/delete', array('query' => $destination) ) : '&nbsp;',
279 );
280 $row = array('data' => $data);
281 if (isset($form[$key]['#attributes'])) {
282 $row = array_merge($row, $form[$key]['#attributes']);
283 }
284 $row['class'][] = 'draggable';
285 $rows[] = $row;
286 }
287
288 return theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'book-outline'), 'empty' => t('No book content available.')));
289 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
book_admin_settings
book_admin_settings()
Definition: book.admin.inc:36
menu_link_save
menu_link_save(&$item, $existing_item=array(), $parent_candidates=array())
Definition: menu.inc:3074
l
l($text, $path, array $options=array())
Definition: common.inc:2432
theme_book_admin_table
theme_book_admin_table($variables)
Definition: book.admin.inc:252
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
node_save
node_save($node)
Definition: node.module:1076
$header
print $header
Definition: forum-topic-list.tpl.php:42
_book_admin_table_tree
_book_admin_table_tree($tree, &$form)
Definition: book.admin.inc:201
book_admin_edit_submit
book_admin_edit_submit($form, &$form_state)
Definition: book.admin.inc:117
book_admin_overview
book_admin_overview()
Definition: book.admin.inc:16
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
book_admin_edit
book_admin_edit($form, $form_state, $node)
Definition: book.admin.inc:83
book_admin_edit_validate
book_admin_edit_validate($form, &$form_state)
Definition: book.admin.inc:102
_book_admin_table
_book_admin_table($node, &$form)
Definition: book.admin.inc:163
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
user_access
user_access($string, $account=NULL)
Definition: user.module:794
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
MENU_MAX_DEPTH
const MENU_MAX_DEPTH
Definition: menu.inc:270
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
node_type_get_names
node_type_get_names()
Definition: node.module:446
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
book_get_books
book_get_books()
Definition: book.module:380
$row
$row
Definition: block-admin-display-form.tpl.php:47
title
print $topic title
Definition: forum-topic-list.tpl.php:50
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
drupal_hash_base64
drupal_hash_base64($data)
Definition: bootstrap.inc:2067
$tree
if($tree||$has_links) print $tree
Definition: book-navigation.tpl.php:35
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
system_settings_form
system_settings_form($form)
Definition: system.module:2755
book_admin_settings_validate
book_admin_settings_validate($form, &$form_state)
Definition: book.admin.inc:64
book_menu_subtree_data
book_menu_subtree_data($link)
Definition: book.module:1380
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
EntityFieldQuery Member List

This is the complete list of members for EntityFieldQuery, including all inherited members.

$age | EntityFieldQuery |
$altered | EntityFieldQuery |
$count | EntityFieldQuery |
$deleted | EntityFieldQuery |
$entityConditions | EntityFieldQuery |
$executeCallback | EntityFieldQuery |
$fieldConditions | EntityFieldQuery |
$fieldMetaConditions | EntityFieldQuery |
$fields | EntityFieldQuery |
$metaData | EntityFieldQuery |
$order | EntityFieldQuery |
$orderedResults | EntityFieldQuery |
$pager | EntityFieldQuery |
$propertyConditions | EntityFieldQuery |
$range | EntityFieldQuery |
$tags | EntityFieldQuery |
addCondition(SelectQuery $select_query, $sql_field, $condition, $having=FALSE) | EntityFieldQuery |
addFieldCondition(&$conditions, $field, $column=NULL, $value=NULL, $operator=NULL, $delta_group=NULL, $language_group=NULL) | EntityFieldQuery | protected
addMetaData($key, $object) | EntityFieldQuery |
addTag($tag) | EntityFieldQuery |
age($age) | EntityFieldQuery |
count() | EntityFieldQuery |
deleted($deleted=TRUE) | EntityFieldQuery |
entityCondition($name, $value, $operator=NULL) | EntityFieldQuery |
entityOrderBy($name, $direction= 'ASC') | EntityFieldQuery |
execute() | EntityFieldQuery |
fieldCondition($field, $column=NULL, $value=NULL, $operator=NULL, $delta_group=NULL, $language_group=NULL) | EntityFieldQuery |
fieldDeltaCondition($field, $value=NULL, $operator=NULL, $delta_group=NULL, $language_group=NULL) | EntityFieldQuery |
fieldLanguageCondition($field, $value=NULL, $operator=NULL, $delta_group=NULL, $language_group=NULL) | EntityFieldQuery |
fieldOrderBy($field, $column, $direction= 'ASC') | EntityFieldQuery |
finishQuery($select_query, $id_key= 'entity_id') | EntityFieldQuery |
initializePager() | EntityFieldQuery |
pager($limit=10, $element=NULL) | EntityFieldQuery |
propertyCondition($column, $value, $operator=NULL) | EntityFieldQuery |
propertyOrderBy($column, $direction= 'ASC') | EntityFieldQuery |
propertyQuery() | EntityFieldQuery | protected
queryCallback() | EntityFieldQuery |
range($start=NULL, $length=NULL) | EntityFieldQuery |
RETURN_ALL | EntityFieldQuery |
tableSort(&$headers) | EntityFieldQuery |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalLocalStreamWrapper Member List

This is the complete list of members for DrupalLocalStreamWrapper, including all inherited members.

$context | DrupalLocalStreamWrapper |
$handle | DrupalLocalStreamWrapper |
$uri | DrupalLocalStreamWrapper | protected
chmod($mode) | DrupalLocalStreamWrapper |
dir_closedir() | DrupalLocalStreamWrapper |
dir_opendir($uri, $options) | DrupalLocalStreamWrapper |
dir_readdir() | DrupalLocalStreamWrapper |
dir_rewinddir() | DrupalLocalStreamWrapper |
dirname($uri=NULL) | DrupalLocalStreamWrapper |
getDirectoryPath() | DrupalLocalStreamWrapper |
getExternalUrl() | DrupalStreamWrapperInterface |
getLocalPath($uri=NULL) | DrupalLocalStreamWrapper | protected
getMimeType($uri, $mapping=NULL) | DrupalLocalStreamWrapper | static
getTarget($uri=NULL) | DrupalLocalStreamWrapper | protected
getUri() | DrupalLocalStreamWrapper |
mkdir($uri, $mode, $options) | DrupalLocalStreamWrapper |
realpath() | DrupalLocalStreamWrapper |
rename($from_uri, $to_uri) | DrupalLocalStreamWrapper |
rmdir($uri, $options) | DrupalLocalStreamWrapper |
setUri($uri) | DrupalLocalStreamWrapper |
stream_close() | DrupalLocalStreamWrapper |
stream_eof() | DrupalLocalStreamWrapper |
stream_flush() | DrupalLocalStreamWrapper |
stream_lock($operation) | DrupalLocalStreamWrapper |
stream_open($uri, $mode, $options, &$opened_path) | DrupalLocalStreamWrapper |
stream_read($count) | DrupalLocalStreamWrapper |
stream_seek($offset, $whence) | DrupalLocalStreamWrapper |
stream_stat() | DrupalLocalStreamWrapper |
stream_tell() | DrupalLocalStreamWrapper |
stream_write($data) | DrupalLocalStreamWrapper |
unlink($uri) | DrupalLocalStreamWrapper |
url_stat($uri, $flags) | DrupalLocalStreamWrapper |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: xmlrpc.php Source File

xmlrpc.php
Go to the documentation of this file.
1 <?php
2
11 define('DRUPAL_ROOT', getcwd());
12
13 include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
14 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
15 include_once DRUPAL_ROOT . '/includes/xmlrpc.inc';
16 include_once DRUPAL_ROOT . '/includes/xmlrpcs.inc';
17
18 xmlrpc_server(module_invoke_all('xmlrpc'));
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
xmlrpc_server
xmlrpc_server($callbacks)
Definition: xmlrpcs.inc:14
drupal_bootstrap
drupal_bootstrap($phase=NULL, $new_phase=TRUE)
Definition: bootstrap.inc:2192
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
DRUPAL_BOOTSTRAP_FULL
const DRUPAL_BOOTSTRAP_FULL
Definition: bootstrap.inc:157
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/render_example/render_example.module Source File

  • examples
  • render_example
render_example.module
Go to the documentation of this file.
1 <?php
2
19 // This allows drupal_var_export() to work.
20 require_once('includes/utility.inc');
21
25 function render_example_menu() {
26 $items['examples/render_example'] = array(
27 'title' => 'Render Example',
28 'page callback' => 'render_example_info',
29 'access callback' => TRUE,
30 );
31 $items['examples/render_example/altering'] = array(
32 'title' => 'Alter pages and blocks',
33 'page callback' => 'drupal_get_form',
34 'page arguments' => array('render_example_demo_form'),
35 'access arguments' => array('access devel information'),
36 );
37 $items['examples/render_example/arrays'] = array(
38 'title' => 'Render array examples',
39 'page callback' => 'render_example_arrays',
40 'access callback' => TRUE,
41 );
42
43 return $items;
44 }
45
46
50 function render_example_info() {
51 return t('The render example provides a <ul><li><a href="!arrays">demonstration of of render array usage</a></li><li><a href="!alter">using hook_page_alter()</a> to make various changes on a page.</li></ul>', array('!arrays' => url('examples/render_example/arrays'), '!alter' => url('examples/render_example/altering')));
52 }
53
54
64 function render_example_arrays() {
65
66 $interval = 60; // Interval in seconds for cache update with #cache.
67
68 $demos = array(
69 // Demonstrate the simplest markup, a #markup element.
70 t('Super simple #markup') => array(
71 '#markup' => t('Some basic text in a #markup (shows basic markup and how it is rendered)'),
72 ),
73
74 // Shows how #prefix and #suffix can add markup into an array.
75 t('Using #prefix and #suffix') => array(
76 '#markup' => t('This one adds a prefix and suffix, which put a div around the item'),
77 '#prefix' => '<div><br/>(prefix)<br/>',
78 '#suffix' => '<br/>(suffix)</div>',
79 ),
80
81 // When #theme is provided, it is the #theme function's job to figure out
82 // the meaning of the render array. The #theme function receives the entire
83 // element in $variables and must return it, where it will be the content
84 // of '#children'. When a #theme or other function is provided, custom
85 // properties can be invented and used as needed, as the #separator
86 // property provided here.
87 //
88 // If #theme is not provided, either explicitly or by the underlying
89 // element, then the children are rendered using their own properties and
90 // the results go into #children.
91 t('theme for an element') => array(
92 'child' => array(
93 t('This is some text that should be put together'),
94 t('This is some more text that we need'),
95 ),
96 '#separator' => ' | ', // Made up for this theme function.
97 '#theme' => 'render_example_aggregate',
98 ),
99
100 // #theme_wrappers provides an array of theme functions which theme the
101 // envelope or "wrapper" of a set of child elements. The theme function
102 // finds its element children (the sub-arrays) already rendered in
103 // '#children'.
104 t('theme_wrappers demonstration') => array(
105 'child1' => array('#markup' => t('Markup for child1')),
106 'child2' => array('#markup' => t('Markup for child2')),
107 '#theme_wrappers' => array('render_example_add_div', 'render_example_add_notes'),
108 ),
109
110 // Add '#pre_render' and '#post_render' handlers.
111 // - '#pre_render' functions get access to the array before it is rendered
112 // and can change it. This is similar to a theme function, but it is a
113 // specific fixed function and changes the array in place rather than
114 // rendering it..
115 // - '#post_render' functions get access to the rendered content, but also
116 // have the original array available.
117 t('pre_render and post_render') => array(
118 '#markup' => '<div style="color:green">' . t('markup for pre_render and post_render example') . '</div>',
119 '#pre_render' => array('render_example_add_suffix'),
120 '#post_render' => array('render_example_add_prefix'),
121 ),
122
123 // Cache an element for $interval seconds using #cache.
124 // The assumption here is that this is an expensive item to render, perhaps
125 // large or otherwise expensive. Of course here it's just a piece of markup,
126 // so we don't get the value.
127 //
128 // #cache allows us to set
129 // - 'keys', an array of strings that will create the string cache key.
130 // - 'bin', the cache bin
131 // - 'expire', the expire timestamp. Note that this is actually limited
132 // to the granularity of a cron run.
133 // - 'granularity', a bitmask determining at what level the caching is done
134 // (user, role, page).
135 t('cache demonstration') => array(
136 // If your expensive function were to be executed here it would happen
137 // on every page load regardless of the cache. The actual markup is
138 // added via the #pre_render function, so that drupal_render() will only
139 // execute the expensive function if this array has not been cached.
140 '#markup' => '',
141 '#pre_render' => array('render_example_cache_pre_render'),
142 '#cache' => array(
143 'keys' => array('render_example', 'cache', 'demonstration'),
144 'bin' => 'cache',
145 'expire' => time() + $interval,
146 'granularity' => DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE,
147 ),
148 ),
149 );
150
151
152 // The rest of this function just places the above arrays in a context where
153 // they can be rendered (hopefully attractively and usefully) on the page.
154 $page_array = array();
155 foreach ($demos as $key => $item) {
156 $page_array[$key]['#theme_wrappers'] = array('render_array');
157 $page_array[$key]['#description'] = $key;
158
159 $page_array[$key]['unrendered'] = array(
160 '#prefix' => '<div class="unrendered-label">' . t('Unrendered array (as plain text and with a krumo version)') . ':</div>',
161 '#type' => 'markup',
162 '#markup' => htmlentities(drupal_var_export($item)),
163 );
164 $page_array[$key]['kpr'] = array(
165 // The kpr() function is from devel module and is here only allow us
166 // to output the array in a way that's easy to explore.
167 '#markup' => kpr($item, TRUE),
168 );
169 $page_array[$key]['hr'] = array('#markup' => '<hr/>');
170 $page_array[$key]['rendered'] = array($item);
171 $page_array[$key]['rendered']['#prefix'] = '<p><em>Rendered version (light blue)</em>:</p>' . '<div class="rendered">';
172 $page_array[$key]['rendered']['#suffix'] = '</div>';
173 }
174
175 return $page_array;
176 }
177
187 function render_example_cache_pre_render($element) {
188 $element['#markup'] = render_example_cache_expensive();
189
190 // The following line is due to the bug described in
191 // http://drupal.org/node/914792. A #markup element's #pre_render must set
192 // #children because it replaces the default #markup pre_render, which is
193 // drupal_pre_render_markup().
194 $element['#children'] = $element['#markup'];
195 return $element;
196 }
197
204 function render_example_cache_expensive() {
205 $interval = 60;
206 $time_message = t('The current time was %time when this was cached. Updated every %interval seconds', array('%time' => date('r'), '%interval' => $interval));
207 // Uncomment the following line to demonstrate that this function is not
208 // being run when the rendered array is cached.
209 // drupal_set_message($time_message);
210 return $time_message;
211 }
212
222 function render_example_add_suffix($element) {
223 $element['#suffix'] = '<div style="color:red">' . t('This #suffix was added by a #pre_render') . '</div>';
224
225 // The following line is due to the bug described in
226 // http://drupal.org/node/914792. A #markup element's #pre_render must set
227 // #children because it replaces the default #markup pre_render, which is
228 // drupal_pre_render_markup().
229 $element['#children'] = $element['#markup'];
230 return $element;
231 }
232
244 function render_example_add_prefix($markup, $element) {
245 $markup = '<div style="color:blue">This markup was added after rendering by a #post_render</div>' . $markup;
246 return $markup;
247 }
248
256 function theme_render_example_aggregate($variables) {
257 $output = '';
258 foreach (element_children($variables['element']['child']) as $item) {
259 $output .= $variables['element']['child'][$item] . $variables['element']['#separator'];
260 }
261 return $output;
262 }
263
264 /*************** Altering Section **************************
265 * The following section of the example builds and arranges the altering
266 * example.
267 */
268
272 function render_example_demo_form($form, &$form_state) {
273 $form['description'] = array(
274 '#type' => 'markup',
275 '#markup' => t('This example shows what render arrays look like in the building of a page. It will not work unless the user running it has the "access devel information" privilege. It shows both the actual arrays used to build a page or block and also the capabilities of altering the page late in its lifecycle.'),
276 );
277
278 $form['show_arrays'] = array(
279 '#type' => 'fieldset',
280 '#title' => t('Show render arrays'),
281 );
282
283 foreach (array('block', 'page') as $type) {
284 $form['show_arrays']['render_example_show_' . $type] = array(
285 '#type' => 'checkbox',
286 '#title' => t('Show @type render arrays', array('@type' => $type)),
287 '#default_value' => variable_get('render_example_show_' . $type, FALSE),
288 );
289 }
290
291 $form['page_fiddling'] = array(
292 '#type' => 'fieldset',
293 '#title' => t('Make changes on page via hook_page_alter()'),
294 );
295 $form['page_fiddling']['render_example_note_about_render_arrays'] = array(
296 '#title' => t('Add a note about render arrays to top of sidebar_first (if it exists)'),
297 '#description' => t('Creates a simple render array that displays the use of #pre_render, #post_render, #theme, and #theme_wrappers.'),
298 '#type' => 'checkbox',
299 '#default_value' => variable_get('render_example_note_about_render_arrays', FALSE),
300 );
301 $form['page_fiddling']['render_example_move_navigation_menu'] = array(
302 '#title' => t('Move the navigation menu to the top of the content area'),
303 '#description' => t('Uses hook_page_alter() to move the navigation menu into another region.'),
304 '#type' => 'checkbox',
305 '#default_value' => variable_get('render_example_move_navigation_menu', FALSE),
306 );
307 $form['page_fiddling']['render_example_reverse_sidebar'] = array(
308 '#title' => t('Reverse ordering of sidebar_first elements (if it exists) - will affect the above'),
309 '#description' => t('Uses hook_page_alter() to reverse the ordering of items in sidebar_first'),
310 '#type' => 'checkbox',
311 '#default_value' => variable_get('render_example_reverse_sidebar', FALSE),
312 );
313 $form['page_fiddling']['render_example_prefix'] = array(
314 '#title' => t('Use #prefix and #suffix to wrap a div around every block'),
315 '#description' => t('Uses hook_page_alter to wrap all blocks with a div using #prefix and #suffix'),
316 '#type' => 'checkbox',
317 '#default_value' => variable_get('render_example_prefix'),
318 );
319
320 return system_settings_form($form);
321 }
322
329 function render_example_page_alter(&$page) {
330
331 $original_page = $page;
332
333 // Re-sort the sidebar in reverse order.
334 if (variable_get('render_example_reverse_sidebar', FALSE) && !empty($page['sidebar_first'])) {
335 $page['sidebar_first'] = array_reverse($page['sidebar_first']);
336 foreach (element_children($page['sidebar_first']) as $element) {
337 // Reverse the weights if they exist.
338 if (!empty($page['sidebar_first'][$element]['#weight'])) {
339 $page['sidebar_first'][$element]['#weight'] *= -1;
340 }
341 }
342 $page['sidebar_first']['#sorted'] = FALSE;
343 }
344
345 // Add a list of items to the top of sidebar_first.
346 // This shows how #theme and #theme_wrappers work.
347 if (variable_get('render_example_note_about_render_arrays', FALSE) && !empty($page['sidebar_first'])) {
348 $items = array(
349 t('Render arrays are everywhere in D7'),
350 t('Leave content unrendered as much as possible'),
351 t('This allows rearrangement and alteration very late in page cycle'),
352 );
353
354 $note = array(
355 '#title' => t('Render Array Example'),
356 '#items' => $items,
357
358 // The functions in #pre_render get to alter the actual data before it
359 // gets rendered by the various theme functions.
360 '#pre_render' => array('render_example_change_to_ol'),
361 // The functions in #post_render get both the element and the rendered
362 // data and can add to the rendered data.
363 '#post_render' => array('render_example_add_hr'),
364 // The #theme theme operation gets the first chance at rendering the
365 // element and its children.
366 '#theme' => 'item_list',
367 // Then the theme operations in #theme_wrappers can wrap more around
368 // what #theme left in #chilren.
369 '#theme_wrappers' => array('render_example_add_div', 'render_example_add_notes'),
370 '#weight' => -9999,
371 );
372 $page['sidebar_first']['render_array_note'] = $note;
373 $page['sidebar_first']['#sorted'] = FALSE;
374 }
375
376
377 // Move the navigation menu into the content area.
378 if (variable_get('render_example_move_navigation_menu', FALSE) && !empty($page['sidebar_first']['system_navigation']) && !empty($page['content'])) {
379 $page['content']['system_navigation'] = $page['sidebar_first']['system_navigation'];
380 $page['content']['system_navigation']['#weight'] = -99999;
381 unset($page['content']['#sorted']);
382 unset($page['sidebar_first']['system_navigation']);
383 }
384
385 // Show the render array used to build the page render array display.
386 if (variable_get('render_example_show_page', FALSE)) {
387 $form['render_example_page_fieldset'] = array(
388 '#type' => 'fieldset',
389 '#title' => t('Page render array'),
390 '#collapsible' => TRUE,
391 '#collapsed' => TRUE,
392 );
393 $form['render_example_page_fieldset']['markup'] = array(
394 // The kpr() function is from devel module and is here only allow us
395 // to output the array in a way that's easy to explore.
396 '#markup' => kpr($page, TRUE),
397 );
398 $page['content']['page_render_array'] = drupal_get_form('render_example_embedded_form', $form);
399 $page['content']['page_render_array']['#weight'] = -999999;
400 $page['content']['#sorted'] = FALSE;
401 }
402
403 // Add render array to the bottom of each block
404 if (variable_get('render_example_show_block', FALSE)) {
405 foreach (element_children($page) as $region_name) {
406 foreach (element_children($page[$region_name]) as $block_name) {
407
408 // Push the block down a level so we can add another block after it.
409 $old_block = $page[$region_name][$block_name];
410 $page[$region_name][$block_name] = array(
411 $block_name => $old_block,
412 );
413 $form = array();
414 $form['render_example_block_fieldset'] = array(
415 '#type' => 'fieldset',
416 '#title' => t('Block render array'),
417 '#collapsible' => TRUE,
418 '#collapsed' => TRUE,
419 );
420
421 $form['render_example_block_fieldset']['markup'] = array(
422 '#type' => 'item',
423 '#title' => t('%blockname block render array', array('%blockname' => $block_name)),
424 // The kpr() function is from devel module and is here only allow us
425 // to output the array in a way that's easy to explore.
426 '#markup' => kpr($old_block, TRUE),
427 );
428
429 // Add the new block that contains the render array.
430 $page[$region_name][$block_name]['render_example_block_render_array'] = drupal_get_form('render_example_embedded_form', $form);
431 $page[$region_name][$block_name]['render_example_block_render_array']['#weight'] = 999;
432 }
433 }
434 }
435
436 // Add #prefix and #suffix to a block to wrap a div around it.
437 if (variable_get('render_example_prefix', FALSE)) {
438 foreach (element_children($page) as $region_name) {
439 foreach (element_children($page[$region_name]) as $block_name) {
440 $block = &$page[$region_name][$block_name];
441 $block['#prefix'] = '<div class="block-prefix"><p>Prefixed</p>';
442 $block['#suffix'] = '<span class="block-suffix">Block suffix</span></div>';
443 }
444 }
445 }
446 $altered_page = $page;
447
448 }
449
463 function render_example_embedded_form($form, &$form_state, $form_items) {
464 return $form_items;
465 }
466
470 function render_example_theme() {
471 $items = array(
472 'render_example_add_div' => array(
473 'render element' => 'element',
474 ),
475 'render_example_add_notes' => array(
476 'render element' => 'element',
477 ),
478 'render_array' => array(
479 'render element' => 'element',
480 ),
481 'render_example_aggregate' => array(
482 'render element' => 'element',
483 ),
484 );
485 return $items;
486 }
487
491 function theme_render_example_add_div($variables) {
492 $element = $variables['element'];
493 $output = '<div class="render-example-wrapper-div">';
494 $output .= $element['#children'];
495 $output .= '</div>';
496 return $output;
497 }
498
502 function theme_render_example_add_notes($variables) {
503 $element = $variables['element'];
504 $output = '<div class="render-example-notes-wrapper-div">';
505 $output .= $element['#children'];
506 $output .= '<em>' . t('This is a note added by a #theme_wrapper') . '</em>';
507 $output .= '</div>';
508
509 return $output;
510 }
511
515 function theme_render_array($variables) {
516 $heading = '<div class="render-header">' . $variables['element']['#description'] . '</div>';
517
518 $rendered = '<div class="render-array">' . $heading . $variables['element']['#children'] . '</div>';
519 return $rendered;
520 }
521
532 function render_example_change_to_ol($element) {
533 $element['#type'] = 'ol';
534 return $element;
535 }
536
551 function render_example_add_hr($markup, $element) {
552 $output = $markup . '<hr />';
553 return $output;
554 }
render_example_embedded_form
render_example_embedded_form($form, &$form_state, $form_items)
Definition: render_example.module:463
render_example_theme
render_example_theme()
Definition: render_example.module:470
DRUPAL_CACHE_PER_PAGE
const DRUPAL_CACHE_PER_PAGE
Definition: common.inc:156
render_example_cache_pre_render
render_example_cache_pre_render($element)
Definition: render_example.module:187
render_example_cache_expensive
render_example_cache_expensive()
Definition: render_example.module:204
render_example_add_suffix
render_example_add_suffix($element)
Definition: render_example.module:222
render_example_add_hr
render_example_add_hr($markup, $element)
Definition: render_example.module:551
$page
print $page
Definition: overlay.tpl.php:37
theme_render_example_aggregate
theme_render_example_aggregate($variables)
Definition: render_example.module:256
drupal_var_export
drupal_var_export($var, $prefix= '')
Definition: utility.inc:19
render_example_arrays
render_example_arrays()
Definition: render_example.module:64
render_example_change_to_ol
render_example_change_to_ol($element)
Definition: render_example.module:532
render_example_info
render_example_info()
Definition: render_example.module:50
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
render_example_demo_form
render_example_demo_form($form, &$form_state)
Definition: render_example.module:272
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
render_example_add_prefix
render_example_add_prefix($markup, $element)
Definition: render_example.module:244
theme_render_example_add_notes
theme_render_example_add_notes($variables)
Definition: render_example.module:502
$output
$output
Definition: authorize.php:93
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
render_example_page_alter
render_example_page_alter(&$page)
Definition: render_example.module:329
render_example_menu
render_example_menu()
Definition: render_example.module:25
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
theme_render_array
theme_render_array($variables)
Definition: render_example.module:515
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
system_settings_form
system_settings_form($form)
Definition: system.module:2755
theme_render_example_add_div
theme_render_example_add_div($variables)
Definition: render_example.module:491
DRUPAL_CACHE_PER_ROLE
const DRUPAL_CACHE_PER_ROLE
Definition: common.inc:143
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/sqlite/schema.inc Source File

  • includes
  • database
  • sqlite
schema.inc
Go to the documentation of this file.
1 <?php
2
14 class DatabaseSchema_sqlite extends DatabaseSchema {
15
19 protected $defaultSchema = 'main';
20
21 public function tableExists($table) {
22 $info = $this->getPrefixInfo($table);
23
24 // Don't use {} around sqlite_master table.
25 return (bool) $this->connection->query('SELECT 1 FROM ' . $info['schema'] . '.sqlite_master WHERE type = :type AND name = :name', array(':type' => 'table', ':name' => $info['table']))->fetchField();
26 }
27
28 public function fieldExists($table, $column) {
29 $schema = $this->introspectSchema($table);
30 return !empty($schema['fields'][$column]);
31 }
32
43 public function createTableSql($name, $table) {
44 $sql = array();
45 $sql[] = "CREATE TABLE {" . $name . "} (\n" . $this->createColumsSql($name, $table) . "\n);\n";
46 return array_merge($sql, $this->createIndexSql($name, $table));
47 }
48
52 protected function createIndexSql($tablename, $schema) {
53 $sql = array();
54 $info = $this->getPrefixInfo($tablename);
55 if (!empty($schema['unique keys'])) {
56 foreach ($schema['unique keys'] as $key => $fields) {
57 $sql[] = 'CREATE UNIQUE INDEX ' . $info['schema'] . '.' . $info['table'] . '_' . $key . ' ON ' . $info['table'] . ' (' . $this->createKeySql($fields) . "); \n";
58 }
59 }
60 if (!empty($schema['indexes'])) {
61 foreach ($schema['indexes'] as $key => $fields) {
62 $sql[] = 'CREATE INDEX ' . $info['schema'] . '.' . $info['table'] . '_' . $key . ' ON ' . $info['table'] . ' (' . $this->createKeySql($fields) . "); \n";
63 }
64 }
65 return $sql;
66 }
67
71 protected function createColumsSql($tablename, $schema) {
72 $sql_array = array();
73
74 // Add the SQL statement for each field.
75 foreach ($schema['fields'] as $name => $field) {
76 if (isset($field['type']) && $field['type'] == 'serial') {
77 if (isset($schema['primary key']) && ($key = array_search($name, $schema['primary key'])) !== FALSE) {
78 unset($schema['primary key'][$key]);
79 }
80 }
81 $sql_array[] = $this->createFieldSql($name, $this->processField($field));
82 }
83
84 // Process keys.
85 if (!empty($schema['primary key'])) {
86 $sql_array[] = " PRIMARY KEY (" . $this->createKeySql($schema['primary key']) . ")";
87 }
88
89 return implode(", \n", $sql_array);
90 }
91
95 protected function createKeySql($fields) {
96 $return = array();
97 foreach ($fields as $field) {
98 if (is_array($field)) {
99 $return[] = $field[0];
100 }
101 else {
102 $return[] = $field;
103 }
104 }
105 return implode(', ', $return);
106 }
107
114 protected function processField($field) {
115 if (!isset($field['size'])) {
116 $field['size'] = 'normal';
117 }
118
119 // Set the correct database-engine specific datatype.
120 // In case one is already provided, force it to uppercase.
121 if (isset($field['sqlite_type'])) {
122 $field['sqlite_type'] = drupal_strtoupper($field['sqlite_type']);
123 }
124 else {
125 $map = $this->getFieldTypeMap();
126 $field['sqlite_type'] = $map[$field['type'] . ':' . $field['size']];
127 }
128
129 if (isset($field['type']) && $field['type'] == 'serial') {
130 $field['auto_increment'] = TRUE;
131 }
132
133 return $field;
134 }
135
147 protected function createFieldSql($name, $spec) {
148 if (!empty($spec['auto_increment'])) {
149 $sql = $name . " INTEGER PRIMARY KEY AUTOINCREMENT";
150 if (!empty($spec['unsigned'])) {
151 $sql .= ' CHECK (' . $name . '>= 0)';
152 }
153 }
154 else {
155 $sql = $name . ' ' . $spec['sqlite_type'];
156
157 if (in_array($spec['sqlite_type'], array('VARCHAR', 'TEXT')) && isset($spec['length'])) {
158 $sql .= '(' . $spec['length'] . ')';
159 }
160
161 if (isset($spec['not null'])) {
162 if ($spec['not null']) {
163 $sql .= ' NOT NULL';
164 }
165 else {
166 $sql .= ' NULL';
167 }
168 }
169
170 if (!empty($spec['unsigned'])) {
171 $sql .= ' CHECK (' . $name . '>= 0)';
172 }
173
174 if (isset($spec['default'])) {
175 if (is_string($spec['default'])) {
176 $spec['default'] = "'" . $spec['default'] . "'";
177 }
178 $sql .= ' DEFAULT ' . $spec['default'];
179 }
180
181 if (empty($spec['not null']) && !isset($spec['default'])) {
182 $sql .= ' DEFAULT NULL';
183 }
184 }
185 return $sql;
186 }
187
192 public function getFieldTypeMap() {
193 // Put :normal last so it gets preserved by array_flip. This makes
194 // it much easier for modules (such as schema.module) to map
195 // database types back into schema types.
196 // $map does not use drupal_static as its value never changes.
197 static $map = array(
198 'varchar:normal' => 'VARCHAR',
199 'char:normal' => 'CHAR',
200
201 'text:tiny' => 'TEXT',
202 'text:small' => 'TEXT',
203 'text:medium' => 'TEXT',
204 'text:big' => 'TEXT',
205 'text:normal' => 'TEXT',
206
207 'serial:tiny' => 'INTEGER',
208 'serial:small' => 'INTEGER',
209 'serial:medium' => 'INTEGER',
210 'serial:big' => 'INTEGER',
211 'serial:normal' => 'INTEGER',
212
213 'int:tiny' => 'INTEGER',
214 'int:small' => 'INTEGER',
215 'int:medium' => 'INTEGER',
216 'int:big' => 'INTEGER',
217 'int:normal' => 'INTEGER',
218
219 'float:tiny' => 'FLOAT',
220 'float:small' => 'FLOAT',
221 'float:medium' => 'FLOAT',
222 'float:big' => 'FLOAT',
223 'float:normal' => 'FLOAT',
224
225 'numeric:normal' => 'NUMERIC',
226
227 'blob:big' => 'BLOB',
228 'blob:normal' => 'BLOB',
229 );
230 return $map;
231 }
232
233 public function renameTable($table, $new_name) {
234 if (!$this->tableExists($table)) {
235 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot rename %table to %table_new: table %table doesn't exist.", array('%table' => $table, '%table_new' => $new_name)));
236 }
237 if ($this->tableExists($new_name)) {
238 throw new DatabaseSchemaObjectExistsException(t("Cannot rename %table to %table_new: table %table_new already exists.", array('%table' => $table, '%table_new' => $new_name)));
239 }
240
241 $schema = $this->introspectSchema($table);
242
243 // SQLite doesn't allow you to rename tables outside of the current
244 // database. So the syntax '...RENAME TO database.table' would fail.
245 // So we must determine the full table name here rather than surrounding
246 // the table with curly braces incase the db_prefix contains a reference
247 // to a database outside of our existsing database.
248 $info = $this->getPrefixInfo($new_name);
249 $this->connection->query('ALTER TABLE {' . $table . '} RENAME TO ' . $info['table']);
250
251 // Drop the indexes, there is no RENAME INDEX command in SQLite.
252 if (!empty($schema['unique keys'])) {
253 foreach ($schema['unique keys'] as $key => $fields) {
254 $this->dropIndex($table, $key);
255 }
256 }
257 if (!empty($schema['indexes'])) {
258 foreach ($schema['indexes'] as $index => $fields) {
259 $this->dropIndex($table, $index);
260 }
261 }
262
263 // Recreate the indexes.
264 $statements = $this->createIndexSql($new_name, $schema);
265 foreach ($statements as $statement) {
266 $this->connection->query($statement);
267 }
268 }
269
270 public function dropTable($table) {
271 if (!$this->tableExists($table)) {
272 return FALSE;
273 }
274 $this->connection->tableDropped = TRUE;
275 $this->connection->query('DROP TABLE {' . $table . '}');
276 return TRUE;
277 }
278
279 public function addField($table, $field, $specification, $keys_new = array()) {
280 if (!$this->tableExists($table)) {
281 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add field %table.%field: table doesn't exist.", array('%field' => $field, '%table' => $table)));
282 }
283 if ($this->fieldExists($table, $field)) {
284 throw new DatabaseSchemaObjectExistsException(t("Cannot add field %table.%field: field already exists.", array('%field' => $field, '%table' => $table)));
285 }
286
287 // SQLite doesn't have a full-featured ALTER TABLE statement. It only
288 // supports adding new fields to a table, in some simple cases. In most
289 // cases, we have to create a new table and copy the data over.
290 if (empty($keys_new) && (empty($specification['not null']) || isset($specification['default']))) {
291 // When we don't have to create new keys and we are not creating a
292 // NOT NULL column without a default value, we can use the quicker version.
293 $query = 'ALTER TABLE {' . $table . '} ADD ' . $this->createFieldSql($field, $this->processField($specification));
294 $this->connection->query($query);
295
296 // Apply the initial value if set.
297 if (isset($specification['initial'])) {
298 $this->connection->update($table)
299 ->fields(array($field => $specification['initial']))
300 ->execute();
301 }
302 }
303 else {
304 // We cannot add the field directly. Use the slower table alteration
305 // method, starting from the old schema.
306 $old_schema = $this->introspectSchema($table);
307 $new_schema = $old_schema;
308
309 // Add the new field.
310 $new_schema['fields'][$field] = $specification;
311
312 // Build the mapping between the old fields and the new fields.
313 $mapping = array();
314 if (isset($specification['initial'])) {
315 // If we have a initial value, copy it over.
316 $mapping[$field] = array(
317 'expression' => ':newfieldinitial',
318 'arguments' => array(':newfieldinitial' => $specification['initial']),
319 );
320 }
321 else {
322 // Else use the default of the field.
323 $mapping[$field] = NULL;
324 }
325
326 // Add the new indexes.
327 $new_schema += $keys_new;
328
329 $this->alterTable($table, $old_schema, $new_schema, $mapping);
330 }
331 }
332
354 protected function alterTable($table, $old_schema, $new_schema, array $mapping = array()) {
355 $i = 0;
356 do {
357 $new_table = $table . '_' . $i++;
358 } while ($this->tableExists($new_table));
359
360 $this->createTable($new_table, $new_schema);
361
362 // Build a SQL query to migrate the data from the old table to the new.
363 $select = $this->connection->select($table);
364
365 // Complete the mapping.
366 $possible_keys = array_keys($new_schema['fields']);
367 $mapping += array_combine($possible_keys, $possible_keys);
368
369 // Now add the fields.
370 foreach ($mapping as $field_alias => $field_source) {
371 // Just ignore this field (ie. use it's default value).
372 if (!isset($field_source)) {
373 continue;
374 }
375
376 if (is_array($field_source)) {
377 $select->addExpression($field_source['expression'], $field_alias, $field_source['arguments']);
378 }
379 else {
380 $select->addField($table, $field_source, $field_alias);
381 }
382 }
383
384 // Execute the data migration query.
385 $this->connection->insert($new_table)
386 ->from($select)
387 ->execute();
388
389 $old_count = $this->connection->query('SELECT COUNT(*) FROM {' . $table . '}')->fetchField();
390 $new_count = $this->connection->query('SELECT COUNT(*) FROM {' . $new_table . '}')->fetchField();
391 if ($old_count == $new_count) {
392 $this->dropTable($table);
393 $this->renameTable($new_table, $table);
394 }
395 }
396
410 protected function introspectSchema($table) {
411 $mapped_fields = array_flip($this->getFieldTypeMap());
412 $schema = array(
413 'fields' => array(),
414 'primary key' => array(),
415 'unique keys' => array(),
416 'indexes' => array(),
417 );
418
419 $info = $this->getPrefixInfo($table);
420 $result = $this->connection->query('PRAGMA ' . $info['schema'] . '.table_info(' . $info['table'] . ')');
421 foreach ($result as $row) {
422 if (preg_match('/^([^(]+)\((.*)\)$/', $row->type, $matches)) {
423 $type = $matches[1];
424 $length = $matches[2];
425 }
426 else {
427 $type = $row->type;
428 $length = NULL;
429 }
430 if (isset($mapped_fields[$type])) {
431 list($type, $size) = explode(':', $mapped_fields[$type]);
432 $schema['fields'][$row->name] = array(
433 'type' => $type,
434 'size' => $size,
435 'not null' => !empty($row->notnull),
436 'default' => trim($row->dflt_value, "'"),
437 );
438 if ($length) {
439 $schema['fields'][$row->name]['length'] = $length;
440 }
441 if ($row->pk) {
442 $schema['primary key'][] = $row->name;
443 }
444 }
445 else {
446 new Exception("Unable to parse the column type " . $row->type);
447 }
448 }
449 $indexes = array();
450 $result = $this->connection->query('PRAGMA ' . $info['schema'] . '.index_list(' . $info['table'] . ')');
451 foreach ($result as $row) {
452 if (strpos($row->name, 'sqlite_autoindex_') !== 0) {
453 $indexes[] = array(
454 'schema_key' => $row->unique ? 'unique keys' : 'indexes',
455 'name' => $row->name,
456 );
457 }
458 }
459 foreach ($indexes as $index) {
460 $name = $index['name'];
461 // Get index name without prefix.
462 $index_name = substr($name, strlen($info['table']) + 1);
463 $result = $this->connection->query('PRAGMA ' . $info['schema'] . '.index_info(' . $name . ')');
464 foreach ($result as $row) {
465 $schema[$index['schema_key']][$index_name][] = $row->name;
466 }
467 }
468 return $schema;
469 }
470
471 public function dropField($table, $field) {
472 if (!$this->fieldExists($table, $field)) {
473 return FALSE;
474 }
475
476 $old_schema = $this->introspectSchema($table);
477 $new_schema = $old_schema;
478
479 unset($new_schema['fields'][$field]);
480 foreach ($new_schema['indexes'] as $index => $fields) {
481 foreach ($fields as $key => $field_name) {
482 if ($field_name == $field) {
483 unset($new_schema['indexes'][$index][$key]);
484 }
485 }
486 // If this index has no more fields then remove it.
487 if (empty($new_schema['indexes'][$index])) {
488 unset($new_schema['indexes'][$index]);
489 }
490 }
491 $this->alterTable($table, $old_schema, $new_schema);
492 return TRUE;
493 }
494
495 public function changeField($table, $field, $field_new, $spec, $keys_new = array()) {
496 if (!$this->fieldExists($table, $field)) {
497 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.", array('%table' => $table, '%name' => $field)));
498 }
499 if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
500 throw new DatabaseSchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
501 }
502
503 $old_schema = $this->introspectSchema($table);
504 $new_schema = $old_schema;
505
506 // Map the old field to the new field.
507 if ($field != $field_new) {
508 $mapping[$field_new] = $field;
509 }
510 else {
511 $mapping = array();
512 }
513
514 // Remove the previous definition and swap in the new one.
515 unset($new_schema['fields'][$field]);
516 $new_schema['fields'][$field_new] = $spec;
517
518 // Map the former indexes to the new column name.
519 $new_schema['primary key'] = $this->mapKeyDefinition($new_schema['primary key'], $mapping);
520 foreach (array('unique keys', 'indexes') as $k) {
521 foreach ($new_schema[$k] as &$key_definition) {
522 $key_definition = $this->mapKeyDefinition($key_definition, $mapping);
523 }
524 }
525
526 // Add in the keys from $keys_new.
527 if (isset($keys_new['primary key'])) {
528 $new_schema['primary key'] = $keys_new['primary key'];
529 }
530 foreach (array('unique keys', 'indexes') as $k) {
531 if (!empty($keys_new[$k])) {
532 $new_schema[$k] = $keys_new[$k] + $new_schema[$k];
533 }
534 }
535
536 $this->alterTable($table, $old_schema, $new_schema, $mapping);
537 }
538
547 protected function mapKeyDefinition(array $key_definition, array $mapping) {
548 foreach ($key_definition as &$field) {
549 // The key definition can be an array($field, $length).
550 if (is_array($field)) {
551 $field = &$field[0];
552 }
553 if (isset($mapping[$field])) {
554 $field = $mapping[$field];
555 }
556 }
557 return $key_definition;
558 }
559
560 public function addIndex($table, $name, $fields) {
561 if (!$this->tableExists($table)) {
562 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add index %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
563 }
564 if ($this->indexExists($table, $name)) {
565 throw new DatabaseSchemaObjectExistsException(t("Cannot add index %name to table %table: index already exists.", array('%table' => $table, '%name' => $name)));
566 }
567
568 $schema['indexes'][$name] = $fields;
569 $statements = $this->createIndexSql($table, $schema);
570 foreach ($statements as $statement) {
571 $this->connection->query($statement);
572 }
573 }
574
575 public function indexExists($table, $name) {
576 $info = $this->getPrefixInfo($table);
577
578 return $this->connection->query('PRAGMA ' . $info['schema'] . '.index_info(' . $info['table'] . '_' . $name . ')')->fetchField() != '';
579 }
580
581 public function dropIndex($table, $name) {
582 if (!$this->indexExists($table, $name)) {
583 return FALSE;
584 }
585
586 $info = $this->getPrefixInfo($table);
587
588 $this->connection->query('DROP INDEX ' . $info['schema'] . '.' . $info['table'] . '_' . $name);
589 return TRUE;
590 }
591
592 public function addUniqueKey($table, $name, $fields) {
593 if (!$this->tableExists($table)) {
594 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add unique key %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
595 }
596 if ($this->indexExists($table, $name)) {
597 throw new DatabaseSchemaObjectExistsException(t("Cannot add unique key %name to table %table: unique key already exists.", array('%table' => $table, '%name' => $name)));
598 }
599
600 $schema['unique keys'][$name] = $fields;
601 $statements = $this->createIndexSql($table, $schema);
602 foreach ($statements as $statement) {
603 $this->connection->query($statement);
604 }
605 }
606
607 public function dropUniqueKey($table, $name) {
608 if (!$this->indexExists($table, $name)) {
609 return FALSE;
610 }
611
612 $info = $this->getPrefixInfo($table);
613
614 $this->connection->query('DROP INDEX ' . $info['schema'] . '.' . $info['table'] . '_' . $name);
615 return TRUE;
616 }
617
618 public function addPrimaryKey($table, $fields) {
619 if (!$this->tableExists($table)) {
620 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add primary key to table %table: table doesn't exist.", array('%table' => $table)));
621 }
622
623 $old_schema = $this->introspectSchema($table);
624 $new_schema = $old_schema;
625
626 if (!empty($new_schema['primary key'])) {
627 throw new DatabaseSchemaObjectExistsException(t("Cannot add primary key to table %table: primary key already exists.", array('%table' => $table)));
628 }
629
630 $new_schema['primary key'] = $fields;
631 $this->alterTable($table, $old_schema, $new_schema);
632 }
633
634 public function dropPrimaryKey($table) {
635 $old_schema = $this->introspectSchema($table);
636 $new_schema = $old_schema;
637
638 if (empty($new_schema['primary key'])) {
639 return FALSE;
640 }
641
642 unset($new_schema['primary key']);
643 $this->alterTable($table, $old_schema, $new_schema);
644 return TRUE;
645 }
646
647 public function fieldSetDefault($table, $field, $default) {
648 if (!$this->fieldExists($table, $field)) {
649 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
650 }
651
652 $old_schema = $this->introspectSchema($table);
653 $new_schema = $old_schema;
654
655 $new_schema['fields'][$field]['default'] = $default;
656 $this->alterTable($table, $old_schema, $new_schema);
657 }
658
659 public function fieldSetNoDefault($table, $field) {
660 if (!$this->fieldExists($table, $field)) {
661 throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
662 }
663
664 $old_schema = $this->introspectSchema($table);
665 $new_schema = $old_schema;
666
667 unset($new_schema['fields'][$field]['default']);
668 $this->alterTable($table, $old_schema, $new_schema);
669 }
670
671 public function findTables($table_expression) {
672 // Don't add the prefix, $table_expression already includes the prefix.
673 $info = $this->getPrefixInfo($table_expression, FALSE);
674
675 // Can't use query placeholders for the schema because the query would have
676 // to be :prefixsqlite_master, which does not work.
677 $result = db_query("SELECT name FROM " . $info['schema'] . ".sqlite_master WHERE type = :type AND name LIKE :table_name", array(
678 ':type' => 'table',
679 ':table_name' => $info['table'],
680 ));
681 return $result->fetchAllKeyed(0, 0);
682 }
683 }
DatabaseSchema_sqlite\addPrimaryKey
addPrimaryKey($table, $fields)
Definition: schema.inc:618
DatabaseSchema_sqlite\fieldSetNoDefault
fieldSetNoDefault($table, $field)
Definition: schema.inc:659
DatabaseSchema_sqlite\fieldSetDefault
fieldSetDefault($table, $field, $default)
Definition: schema.inc:647
DatabaseSchema_sqlite\introspectSchema
introspectSchema($table)
Definition: schema.inc:410
DatabaseSchemaObjectExistsException
Definition: schema.inc:713
$name
print $name
Definition: profile-listing.tpl.php:43
Exception
DatabaseSchema
Definition: schema.inc:164
DatabaseSchema_sqlite\indexExists
indexExists($table, $name)
Definition: schema.inc:575
DatabaseSchema_sqlite\dropUniqueKey
dropUniqueKey($table, $name)
Definition: schema.inc:607
DatabaseSchema_sqlite\processField
processField($field)
Definition: schema.inc:114
DatabaseSchema_sqlite\mapKeyDefinition
mapKeyDefinition(array $key_definition, array $mapping)
Definition: schema.inc:547
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$info
$info
Definition: color.inc:6
DatabaseSchemaObjectDoesNotExistException
Definition: schema.inc:722
drupal_strtoupper
drupal_strtoupper($text)
Definition: unicode.inc:496
DatabaseSchema_sqlite\addUniqueKey
addUniqueKey($table, $name, $fields)
Definition: schema.inc:592
DatabaseSchema_sqlite\dropPrimaryKey
dropPrimaryKey($table)
Definition: schema.inc:634
DatabaseSchema_sqlite\createFieldSql
createFieldSql($name, $spec)
Definition: schema.inc:147
DatabaseSchema_sqlite\findTables
findTables($table_expression)
Definition: schema.inc:671
DatabaseSchema_sqlite\dropField
dropField($table, $field)
Definition: schema.inc:471
DatabaseSchema_sqlite\createTableSql
createTableSql($name, $table)
Definition: schema.inc:43
DatabaseSchema_sqlite\renameTable
renameTable($table, $new_name)
Definition: schema.inc:233
DatabaseSchema\getPrefixInfo
getPrefixInfo($table= 'default', $add_prefix=TRUE)
Definition: schema.inc:227
DatabaseSchema_sqlite\dropTable
dropTable($table)
Definition: schema.inc:270
DatabaseSchema_sqlite\addIndex
addIndex($table, $name, $fields)
Definition: schema.inc:560
DatabaseSchema_sqlite\tableExists
tableExists($table)
Definition: schema.inc:21
DatabaseSchema_sqlite\addField
addField($table, $field, $specification, $keys_new=array())
Definition: schema.inc:279
DatabaseSchema_sqlite\alterTable
alterTable($table, $old_schema, $new_schema, array $mapping=array())
Definition: schema.inc:354
$row
$row
Definition: block-admin-display-form.tpl.php:47
DatabaseSchema_sqlite\changeField
changeField($table, $field, $field_new, $spec, $keys_new=array())
Definition: schema.inc:495
DatabaseSchema_sqlite\$defaultSchema
$defaultSchema
Definition: schema.inc:19
DatabaseSchema_sqlite\createColumsSql
createColumsSql($tablename, $schema)
Definition: schema.inc:71
DatabaseSchema_sqlite
Definition: schema.inc:14
DatabaseSchema_sqlite\dropIndex
dropIndex($table, $name)
Definition: schema.inc:581
DatabaseSchema\createTable
createTable($name, $table)
Definition: schema.inc:655
DatabaseSchema_sqlite\fieldExists
fieldExists($table, $column)
Definition: schema.inc:28
DatabaseSchema_sqlite\createIndexSql
createIndexSql($tablename, $schema)
Definition: schema.inc:52
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
DatabaseSchema_sqlite\getFieldTypeMap
getFieldTypeMap()
Definition: schema.inc:192
DatabaseSchema_sqlite\createKeySql
createKeySql($fields)
Definition: schema.inc:95
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user.install Source File

  • modules
  • user
user.install
Go to the documentation of this file.
1 <?php
2
11 function user_schema() {
12 $schema['authmap'] = array(
13 'description' => 'Stores distributed authentication mapping.',
14 'fields' => array(
15 'aid' => array(
16 'description' => 'Primary Key: Unique authmap ID.',
17 'type' => 'serial',
18 'unsigned' => TRUE,
19 'not null' => TRUE,
20 ),
21 'uid' => array(
22 'type' => 'int',
23 'not null' => TRUE,
24 'default' => 0,
25 'description' => "User's {users}.uid.",
26 ),
27 'authname' => array(
28 'type' => 'varchar',
29 'length' => 128,
30 'not null' => TRUE,
31 'default' => '',
32 'description' => 'Unique authentication name.',
33 ),
34 'module' => array(
35 'type' => 'varchar',
36 'length' => 128,
37 'not null' => TRUE,
38 'default' => '',
39 'description' => 'Module which is controlling the authentication.',
40 ),
41 ),
42 'unique keys' => array(
43 'authname' => array('authname'),
44 ),
45 'primary key' => array('aid'),
46 'foreign keys' => array(
47 'user' => array(
48 'table' => 'users',
49 'columns' => array('uid' => 'uid'),
50 ),
51 ),
52 );
53
54 $schema['role_permission'] = array(
55 'description' => 'Stores the permissions assigned to user roles.',
56 'fields' => array(
57 'rid' => array(
58 'type' => 'int',
59 'unsigned' => TRUE,
60 'not null' => TRUE,
61 'description' => 'Foreign Key: {role}.rid.',
62 ),
63 'permission' => array(
64 'type' => 'varchar',
65 'length' => 128,
66 'not null' => TRUE,
67 'default' => '',
68 'description' => 'A single permission granted to the role identified by rid.',
69 ),
70 'module' => array(
71 'type' => 'varchar',
72 'length' => 255,
73 'not null' => TRUE,
74 'default' => '',
75 'description' => "The module declaring the permission.",
76 ),
77 ),
78 'primary key' => array('rid', 'permission'),
79 'indexes' => array(
80 'permission' => array('permission'),
81 ),
82 'foreign keys' => array(
83 'role' => array(
84 'table' => 'roles',
85 'columns' => array('rid' => 'rid'),
86 ),
87 ),
88 );
89
90 $schema['role'] = array(
91 'description' => 'Stores user roles.',
92 'fields' => array(
93 'rid' => array(
94 'type' => 'serial',
95 'unsigned' => TRUE,
96 'not null' => TRUE,
97 'description' => 'Primary Key: Unique role ID.',
98 ),
99 'name' => array(
100 'type' => 'varchar',
101 'length' => 64,
102 'not null' => TRUE,
103 'default' => '',
104 'description' => 'Unique role name.',
105 'translatable' => TRUE,
106 ),
107 'weight' => array(
108 'type' => 'int',
109 'not null' => TRUE,
110 'default' => 0,
111 'description' => 'The weight of this role in listings and the user interface.',
112 ),
113 ),
114 'unique keys' => array(
115 'name' => array('name'),
116 ),
117 'primary key' => array('rid'),
118 'indexes' => array(
119 'name_weight' => array('name', 'weight'),
120 ),
121 );
122
123 // The table name here is plural, despite Drupal table naming standards,
124 // because "user" is a reserved word in many databases.
125 $schema['users'] = array(
126 'description' => 'Stores user data.',
127 'fields' => array(
128 'uid' => array(
129 'type' => 'int',
130 'unsigned' => TRUE,
131 'not null' => TRUE,
132 'description' => 'Primary Key: Unique user ID.',
133 'default' => 0,
134 ),
135 'name' => array(
136 'type' => 'varchar',
137 'length' => 60,
138 'not null' => TRUE,
139 'default' => '',
140 'description' => 'Unique user name.',
141 ),
142 'pass' => array(
143 'type' => 'varchar',
144 'length' => 128,
145 'not null' => TRUE,
146 'default' => '',
147 'description' => "User's password (hashed).",
148 ),
149 'mail' => array(
150 'type' => 'varchar',
151 'length' => 254,
152 'not null' => FALSE,
153 'default' => '',
154 'description' => "User's e-mail address.",
155 ),
156 'theme' => array(
157 'type' => 'varchar',
158 'length' => 255,
159 'not null' => TRUE,
160 'default' => '',
161 'description' => "User's default theme.",
162 ),
163 'signature' => array(
164 'type' => 'varchar',
165 'length' => 255,
166 'not null' => TRUE,
167 'default' => '',
168 'description' => "User's signature.",
169 ),
170 'signature_format' => array(
171 'type' => 'varchar',
172 'length' => 255,
173 'not null' => FALSE,
174 'description' => 'The {filter_format}.format of the signature.',
175 ),
176 'created' => array(
177 'type' => 'int',
178 'not null' => TRUE,
179 'default' => 0,
180 'description' => 'Timestamp for when user was created.',
181 ),
182 'access' => array(
183 'type' => 'int',
184 'not null' => TRUE,
185 'default' => 0,
186 'description' => 'Timestamp for previous time user accessed the site.',
187 ),
188 'login' => array(
189 'type' => 'int',
190 'not null' => TRUE,
191 'default' => 0,
192 'description' => "Timestamp for user's last login.",
193 ),
194 'status' => array(
195 'type' => 'int',
196 'not null' => TRUE,
197 'default' => 0,
198 'size' => 'tiny',
199 'description' => 'Whether the user is active(1) or blocked(0).',
200 ),
201 'timezone' => array(
202 'type' => 'varchar',
203 'length' => 32,
204 'not null' => FALSE,
205 'description' => "User's time zone.",
206 ),
207 'language' => array(
208 'type' => 'varchar',
209 'length' => 12,
210 'not null' => TRUE,
211 'default' => '',
212 'description' => "User's default language.",
213 ),
214 'picture' => array(
215 'type' => 'int',
216 'not null' => TRUE,
217 'default' => 0,
218 'description' => "Foreign key: {file_managed}.fid of user's picture.",
219 ),
220 'init' => array(
221 'type' => 'varchar',
222 'length' => 254,
223 'not null' => FALSE,
224 'default' => '',
225 'description' => 'E-mail address used for initial account creation.',
226 ),
227 'data' => array(
228 'type' => 'blob',
229 'not null' => FALSE,
230 'size' => 'big',
231 'serialize' => TRUE,
232 'description' => 'A serialized array of name value pairs that are related to the user. Any form values posted during user edit are stored and are loaded into the $user object during user_load(). Use of this field is discouraged and it will likely disappear in a future version of Drupal.',
233 ),
234 ),
235 'indexes' => array(
236 'access' => array('access'),
237 'created' => array('created'),
238 'mail' => array('mail'),
239 'picture' => array('picture'),
240 ),
241 'unique keys' => array(
242 'name' => array('name'),
243 ),
244 'primary key' => array('uid'),
245 'foreign keys' => array(
246 'signature_format' => array(
247 'table' => 'filter_format',
248 'columns' => array('signature_format' => 'format'),
249 ),
250 ),
251 );
252
253 $schema['users_roles'] = array(
254 'description' => 'Maps users to roles.',
255 'fields' => array(
256 'uid' => array(
257 'type' => 'int',
258 'unsigned' => TRUE,
259 'not null' => TRUE,
260 'default' => 0,
261 'description' => 'Primary Key: {users}.uid for user.',
262 ),
263 'rid' => array(
264 'type' => 'int',
265 'unsigned' => TRUE,
266 'not null' => TRUE,
267 'default' => 0,
268 'description' => 'Primary Key: {role}.rid for role.',
269 ),
270 ),
271 'primary key' => array('uid', 'rid'),
272 'indexes' => array(
273 'rid' => array('rid'),
274 ),
275 'foreign keys' => array(
276 'user' => array(
277 'table' => 'users',
278 'columns' => array('uid' => 'uid'),
279 ),
280 'role' => array(
281 'table' => 'roles',
282 'columns' => array('rid' => 'rid'),
283 ),
284 ),
285 );
286
287 return $schema;
288 }
289
293 function user_install() {
294 // Insert a row for the anonymous user.
295 db_insert('users')
296 ->fields(array(
297 'uid' => 0,
298 'name' => '',
299 'mail' => '',
300 ))
301 ->execute();
302
303 // We need some placeholders here as name and mail are uniques and data is
304 // presumed to be a serialized array. This will be changed by the settings
305 // form in the installer.
306 db_insert('users')
307 ->fields(array(
308 'uid' => 1,
309 'name' => 'placeholder-for-uid-1',
310 'mail' => 'placeholder-for-uid-1',
311 'created' => REQUEST_TIME,
312 'status' => 1,
313 'data' => NULL,
314 ))
315 ->execute();
316
317 // Built-in roles.
318 $rid_anonymous = db_insert('role')
319 ->fields(array('name' => 'anonymous user', 'weight' => 0))
320 ->execute();
321 $rid_authenticated = db_insert('role')
322 ->fields(array('name' => 'authenticated user', 'weight' => 1))
323 ->execute();
324
325 // Sanity check to ensure the anonymous and authenticated role IDs are the
326 // same as the drupal defined constants. In certain situations, this will
327 // not be true.
328 if ($rid_anonymous != DRUPAL_ANONYMOUS_RID) {
329 db_update('role')
330 ->fields(array('rid' => DRUPAL_ANONYMOUS_RID))
331 ->condition('rid', $rid_anonymous)
332 ->execute();
333 }
334 if ($rid_authenticated != DRUPAL_AUTHENTICATED_RID) {
335 db_update('role')
336 ->fields(array('rid' => DRUPAL_AUTHENTICATED_RID))
337 ->condition('rid', $rid_authenticated)
338 ->execute();
339 }
340 }
341
345 function user_update_dependencies() {
346 // user_update_7006() updates data in the {role_permission} table, so it must
347 // run after system_update_7007(), which populates that table.
348 $dependencies['user'][7006] = array(
349 'system' => 7007,
350 );
351
352 // user_update_7010() needs to query the {filter_format} table to get a list
353 // of existing text formats, so it must run after filter_update_7000(), which
354 // creates that table.
355 $dependencies['user'][7010] = array(
356 'filter' => 7000,
357 );
358
359 // user_update_7012() uses the file API, which relies on the {file_managed}
360 // table, so it must run after system_update_7034(), which creates that
361 // table.
362 $dependencies['user'][7012] = array(
363 'system' => 7034,
364 );
365
366 // user_update_7013() uses the file usage API, which relies on the
367 // {file_usage} table, so it must run after system_update_7059(), which
368 // creates that table.
369 $dependencies['user'][7013] = array(
370 'system' => 7059,
371 );
372
373 return $dependencies;
374 }
375
389 function _update_7000_user_role_grant_permissions($rid, array $permissions, $module) {
390 // Grant new permissions for the role.
391 foreach ($permissions as $name) {
392 db_merge('role_permission')
393 ->key(array(
394 'rid' => $rid,
395 'permission' => $name,
396 ))
397 ->fields(array(
398 'module' => $module,
399 ))
400 ->execute();
401 }
402 }
403
415 function user_update_7000(&$sandbox) {
416 $sandbox['#finished'] = 0;
417 // Lower than DRUPAL_HASH_COUNT to make the update run at a reasonable speed.
418 $hash_count_log2 = 11;
419 // Multi-part update.
420 if (!isset($sandbox['user_from'])) {
421 db_change_field('users', 'pass', 'pass', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''));
422 $sandbox['user_from'] = 0;
423 $sandbox['user_count'] = db_query("SELECT COUNT(uid) FROM {users}")->fetchField();
424 }
425 else {
426 require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
427 // Hash again all current hashed passwords.
428 $has_rows = FALSE;
429 // Update this many per page load.
430 $count = 1000;
431 $result = db_query_range("SELECT uid, pass FROM {users} WHERE uid > 0 ORDER BY uid", $sandbox['user_from'], $count);
432 foreach ($result as $account) {
433 $has_rows = TRUE;
434
435 // If the $account->pass value is not a MD5 hash (a 32 character
436 // hexadecimal string) then skip it.
437 if (!preg_match('/^[0-9a-f]{32}$/', $account->pass)) {
438 continue;
439 }
440
441 $new_hash = user_hash_password($account->pass, $hash_count_log2);
442 if ($new_hash) {
443 // Indicate an updated password.
444 $new_hash = 'U' . $new_hash;
445 db_update('users')
446 ->fields(array('pass' => $new_hash))
447 ->condition('uid', $account->uid)
448 ->execute();
449 }
450 }
451 $sandbox['#finished'] = $sandbox['user_from']/$sandbox['user_count'];
452 $sandbox['user_from'] += $count;
453 if (!$has_rows) {
454 $sandbox['#finished'] = 1;
455 return t('User passwords rehashed to improve security');
456 }
457 }
458 }
459
466 function user_update_7001() {
467 db_drop_field('users', 'threshold');
468 db_drop_field('users', 'mode');
469 db_drop_field('users', 'sort');
470 }
471
475 function user_update_7002(&$sandbox) {
476 $sandbox['#finished'] = 0;
477
478 // Multi-part update.
479 if (!isset($sandbox['user_from'])) {
480 db_change_field('users', 'timezone', 'timezone', array('type' => 'varchar', 'length' => 32, 'not null' => FALSE));
481 $sandbox['user_from'] = 0;
482 $sandbox['user_count'] = db_query("SELECT COUNT(uid) FROM {users}")->fetchField();
483 $sandbox['user_not_migrated'] = 0;
484 }
485 else {
486 $timezones = system_time_zones();
487 // Update this many per page load.
488 $count = 10000;
489 $contributed_date_module = db_field_exists('users', 'timezone_name');
490 $contributed_event_module = db_field_exists('users', 'timezone_id');
491
492 $results = db_query_range("SELECT uid FROM {users} ORDER BY uid", $sandbox['user_from'], $count);
493 foreach ($results as $account) {
494 $timezone = NULL;
495 // If the contributed Date module has created a users.timezone_name
496 // column, use this data to set each user's time zone.
497 if ($contributed_date_module) {
498 $date_timezone = db_query("SELECT timezone_name FROM {users} WHERE uid = :uid", array(':uid' => $account->uid))->fetchField();
499 if (isset($timezones[$date_timezone])) {
500 $timezone = $date_timezone;
501 }
502 }
503 // If the contributed Event module has stored user time zone information
504 // use that information to update the user accounts.
505 if (!$timezone && $contributed_event_module) {
506 try {
507 $event_timezone = db_query("SELECT t.name FROM {users} u LEFT JOIN {event_timezones} t ON u.timezone_id = t.timezone WHERE u.uid = :uid", array(':uid' => $account->uid))->fetchField();
508 $event_timezone = str_replace(' ', '_', $event_timezone);
509 if (isset($timezones[$event_timezone])) {
510 $timezone = $event_timezone;
511 }
512 }
513 catch (PDOException $e) {
514 // Ignore error if event_timezones table does not exist or unexpected
515 // schema found.
516 }
517 }
518 if ($timezone) {
519 db_update('users')
520 ->fields(array('timezone' => $timezone))
521 ->condition('uid', $account->uid)
522 ->execute();
523 }
524 else {
525 $sandbox['user_not_migrated']++;
526 db_update('users')
527 ->fields(array('timezone' => NULL))
528 ->condition('uid', $account->uid)
529 ->execute();
530 }
531 $sandbox['user_from']++;
532 }
533
534 $sandbox['#finished'] = $sandbox['user_from'] / $sandbox['user_count'];
535 if ($sandbox['user_from'] == $sandbox['user_count']) {
536 if ($sandbox['user_not_migrated'] > 0) {
537 variable_set('empty_timezone_message', 1);
538 drupal_set_message(format_string('Some user time zones have been emptied and need to be set to the correct values. Use the new <a href="@config-url">time zone options</a> to choose whether to remind users at login to set the correct time zone.', array('@config-url' => url('admin/config/regional/settings'))), 'warning');
539 }
540 return t('Migrated user time zones');
541 }
542 }
543 }
544
552 function user_update_7003() {
553 // Set the default account cancellation method.
554 variable_set('user_cancel_method', 'user_cancel_reassign');
555 // Re-assign notification setting.
556 if ($setting = variable_get('user_mail_status_deleted_notify', FALSE)) {
557 variable_set('user_mail_status_canceled_notify', $setting);
558 variable_del('user_mail_status_deleted_notify');
559 }
560 // Re-assign "Account deleted" mail strings to "Account canceled" mail.
561 if ($setting = variable_get('user_mail_status_deleted_subject', FALSE)) {
562 variable_set('user_mail_status_canceled_subject', $setting);
563 variable_del('user_mail_status_deleted_subject');
564 }
565 if ($setting = variable_get('user_mail_status_deleted_body', FALSE)) {
566 variable_set('user_mail_status_canceled_body', $setting);
567 variable_del('user_mail_status_deleted_body');
568 }
569 }
570
574 function user_update_7005(&$sandbox) {
575 $mail_field = array(
576 'type' => 'varchar',
577 'length' => 254,
578 'not null' => FALSE,
579 'default' => '',
580 'description' => "User's e-mail address.",
581 );
582 $init_field = array(
583 'type' => 'varchar',
584 'length' => 254,
585 'not null' => FALSE,
586 'default' => '',
587 'description' => 'E-mail address used for initial account creation.',
588 );
589 db_drop_index('users', 'mail');
590 db_change_field('users', 'mail', 'mail', $mail_field, array('indexes' => array('mail' => array('mail'))));
591 db_change_field('users', 'init', 'init', $init_field);
592 }
593
597 function user_update_7006(&$sandbox) {
598 $module_field = array(
599 'type' => 'varchar',
600 'length' => 255,
601 'not null' => TRUE,
602 'default' => '',
603 'description' => "The module declaring the permission.",
604 );
605 // Check that the field hasn't been updated in an aborted run of this
606 // update.
607 if (!db_field_exists('role_permission', 'module')) {
608 // Add a new field for the fid.
609 db_add_field('role_permission', 'module', $module_field);
610 }
611 }
612
616 function user_update_7007() {
617 db_add_field('role', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
618 db_add_index('role', 'name_weight', array('name', 'weight'));
619 }
620
625 function user_update_7008() {
626 if (!isset($GLOBALS['conf']['user_register'])) {
627 // Set to the Drupal 6 default, "visitors can create accounts".
628 variable_set('user_register', USER_REGISTER_VISITORS);
629 }
630 }
631
635 function user_update_7009() {
636 $spec = array(
637 'type' => 'blob',
638 'not null' => FALSE,
639 'size' => 'big',
640 'serialize' => TRUE,
641 'description' => 'A serialized array of name value pairs that are related to the user. Any form values posted during user edit are stored and are loaded into the $user object during user_load(). Use of this field is discouraged and it will likely disappear in a future version of Drupal.',
642 );
643 db_change_field('users', 'data', 'data', $spec);
644 }
645
649 function user_update_7010() {
650 // Update the database column to allow NULL values.
651 db_change_field('users', 'signature_format', 'signature_format', array(
652 'type' => 'int',
653 'unsigned' => TRUE,
654 'not null' => FALSE,
655 'description' => 'The {filter_format}.format of the signature.',
656 ));
657
658 // Replace the signature format with NULL if the signature is empty and does
659 // not already have a stored text format.
660 //
661 // In Drupal 6, "0" (the former FILTER_FORMAT_DEFAULT constant) could be used
662 // to indicate this situation, but in Drupal 7, only NULL is supported. This
663 // update therefore preserves the ability of user accounts which were never
664 // given a signature (for example, if the site did not have user signatures
665 // enabled, or if the user never edited their account information) to not
666 // have a particular text format assumed for them the first time the
667 // signature is edited.
668 db_update('users')
669 ->fields(array('signature_format' => NULL))
670 ->condition('signature', '')
671 ->condition('signature_format', 0)
672 ->execute();
673
674 // There are a number of situations in which a Drupal 6 site could store
675 // content with a nonexistent text format. This includes text formats that
676 // had later been deleted, or non-empty content stored with a value of "0"
677 // (the former FILTER_FORMAT_DEFAULT constant). Drupal 6 would filter this
678 // content using whatever the site-wide default text format was at the moment
679 // the text was being displayed.
680 //
681 // In Drupal 7, this behavior is no longer supported, and all content must be
682 // stored with an explicit text format (or it will not be displayed when it
683 // is filtered). Therefore, to preserve the behavior of the site after the
684 // upgrade, we must replace all instances described above with the current
685 // value of the (old) site-wide default format at the moment of the upgrade.
686 $existing_formats = db_query("SELECT format FROM {filter_format}")->fetchCol();
687 $default_format = variable_get('filter_default_format', 1);
688 db_update('users')
689 ->fields(array('signature_format' => $default_format))
690 ->isNotNull('signature_format')
691 ->condition('signature_format', $existing_formats, 'NOT IN')
692 ->execute();
693 }
694
702 function user_update_7011() {
703 }
704
709 function user_update_7012(&$sandbox) {
710
711 $picture_field = array(
712 'type' => 'int',
713 'not null' => TRUE,
714 'default' => 0,
715 'description' => "Foreign key: {file_managed}.fid of user's picture.",
716 );
717
718 if (!isset($sandbox['progress'])) {
719 // Check that the field hasn't been updated in an aborted run of this
720 // update.
721 if (!db_field_exists('users', 'picture_fid')) {
722 // Add a new field for the fid.
723 db_add_field('users', 'picture_fid', $picture_field);
724 }
725
726 // Initialize batch update information.
727 $sandbox['progress'] = 0;
728 $sandbox['last_user_processed'] = -1;
729 $sandbox['max'] = db_query("SELECT COUNT(*) FROM {users} WHERE picture <> ''")->fetchField();
730 }
731
732 // As a batch operation move the photos into the {file_managed} table and
733 // update the {users} records.
734 $limit = 500;
735 $result = db_query_range("SELECT uid, picture FROM {users} WHERE picture <> '' AND uid > :uid ORDER BY uid", 0, $limit, array(':uid' => $sandbox['last_user_processed']));
736 foreach ($result as $user) {
737 // Don't bother adding files that don't exist.
738 if (file_exists($user->picture)) {
739
740 // Check if the file already exists.
741 $files = file_load_multiple(array(), array('uri' => $user->picture));
742 if (count($files)) {
743 $file = reset($files);
744 }
745 else {
746 // Create a file object.
747 $file = new stdClass();
748 $file->uri = $user->picture;
749 $file->filename = drupal_basename($file->uri);
750 $file->filemime = file_get_mimetype($file->uri);
751 $file->uid = $user->uid;
752 $file->status = FILE_STATUS_PERMANENT;
753 $file = file_save($file);
754 }
755
756 db_update('users')
757 ->fields(array('picture_fid' => $file->fid))
758 ->condition('uid', $user->uid)
759 ->execute();
760 }
761
762 // Update our progress information for the batch update.
763 $sandbox['progress']++;
764 $sandbox['last_user_processed'] = $user->uid;
765 }
766
767 // Indicate our current progress to the batch update system. If there's no
768 // max value then there's nothing to update and we're finished.
769 $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
770
771 // When we're finished, drop the old picture field and rename the new one to
772 // replace it.
773 if (isset($sandbox['#finished']) && $sandbox['#finished'] == 1) {
774 db_drop_field('users', 'picture');
775 db_change_field('users', 'picture_fid', 'picture', $picture_field);
776 }
777 }
778
782 function user_update_7013(&$sandbox) {
783 if (!isset($sandbox['progress'])) {
784 // Initialize batch update information.
785 $sandbox['progress'] = 0;
786 $sandbox['last_uid_processed'] = -1;
787 $sandbox['max'] = db_query("SELECT COUNT(*) FROM {users} u WHERE u.picture <> 0")->fetchField();
788 }
789
790 // Add usage entries for the user picture files.
791 $limit = 500;
792 $result = db_query_range('SELECT f.*, u.uid as user_uid FROM {users} u INNER JOIN {file_managed} f ON u.picture = f.fid WHERE u.picture <> 0 AND u.uid > :uid ORDER BY u.uid', 0, $limit, array(':uid' => $sandbox['last_uid_processed']))->fetchAllAssoc('fid', PDO::FETCH_ASSOC);
793 foreach ($result as $row) {
794 $uid = $row['user_uid'];
795 $file = (object) $row;
796 file_usage_add($file, 'user', 'user', $uid);
797
798 // Update our progress information for the batch update.
799 $sandbox['progress']++;
800 $sandbox['last_uid_processed'] = $uid;
801 }
802
803 // Indicate our current progress to the batch update system.
804 $sandbox['#finished'] = empty($sandbox['max']) || ($sandbox['progress'] / $sandbox['max']);
805 }
806
812 function user_update_7014() {
813 db_update('role_permission')
814 ->fields(array('permission' => 'skip comment approval'))
815 ->condition('permission', 'post comments without approval')
816 ->execute();
817
818 return t("Renamed the 'post comments without approval' permission to 'skip comment approval'.");
819 }
820
824 function user_update_7015() {
825 db_change_field('users', 'signature_format', 'signature_format', array(
826 'type' => 'varchar',
827 'length' => 255,
828 'not null' => FALSE,
829 'description' => 'The {filter_format}.format of the signature.',
830 ));
831 }
832
845 function user_update_7016() {
846 // Add field default.
847 db_change_field('users', 'uid', 'uid', array(
848 'type' => 'int',
849 'unsigned' => TRUE,
850 'not null' => TRUE,
851 'default' => 0,
852 ));
853 }
854
866 function user_update_7017() {
867 $message = '';
868
869 $tokens = array(
870 '!site' => '[site:name]',
871 '!username' => '[user:name]',
872 '!mailto' => '[user:mail]',
873 '!login_uri' => '[site:login-url]',
874 '!uri_brief' => '[site:url-brief]',
875 '!edit_uri' => '[user:edit-url]',
876 '!login_url' => '[user:one-time-login-url]',
877 '!uri' => '[site:url]',
878 '!date' => '[date:medium]',
879 '!password' => '',
880 );
881
882 $result = db_select('variable', 'v')
883 ->fields('v', array('name'))
884 ->condition('name', db_like('user_mail_') . '%', 'LIKE')
885 ->execute();
886
887 foreach ($result as $row) {
888 // Use variable_get() to get the unserialized value for free.
889 if ($value = variable_get($row->name, FALSE)) {
890
891 if (empty($message) && (strpos($value, '!password') !== FALSE)) {
892 $message = t('The ability to send users their passwords in plain text has been removed in Drupal 7. Your existing email templates have been modified to remove it. You should <a href="@template-url">review these templates</a> to make sure they read properly.', array('@template-url' => url('admin/config/people/accounts')));
893 }
894
895 variable_set($row->name, str_replace(array_keys($tokens), $tokens, $value));
896 }
897 }
898
899 return $message;
900 }
901
905 function user_update_7018() {
906 if (!db_index_exists('users', 'picture')) {
907 db_add_index('users', 'picture', array('picture'));
908 }
909 }
910
db_add_index
db_add_index($table, $name, $fields)
Definition: database.inc:2940
user_update_7001
user_update_7001()
Definition: user.install:466
file_usage_add
file_usage_add(stdClass $file, $module, $type, $id, $count=1)
Definition: file.inc:682
system_time_zones
system_time_zones($blank=NULL)
Definition: system.module:3335
_update_7000_user_role_grant_permissions
_update_7000_user_role_grant_permissions($rid, array $permissions, $module)
Definition: user.install:389
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
$module
print $module
Definition: search-results.tpl.php:28
user_update_7000
user_update_7000(&$sandbox)
Definition: user.install:415
user_update_7017
user_update_7017()
Definition: user.install:866
user_update_7013
user_update_7013(&$sandbox)
Definition: user.install:782
user_update_7015
user_update_7015()
Definition: user.install:824
user_update_dependencies
user_update_dependencies()
Definition: user.install:345
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_drop_index
db_drop_index($table, $name)
Definition: database.inc:2952
$name
print $name
Definition: profile-listing.tpl.php:43
$results
print $results
Definition: poll-results.tpl.php:23
db_field_exists
db_field_exists($table, $field)
Definition: database.inc:2775
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
user_update_7002
user_update_7002(&$sandbox)
Definition: user.install:475
user_update_7009
user_update_7009()
Definition: user.install:635
db_add_field
db_add_field($table, $field, $spec, $keys_new=array())
Definition: database.inc:2840
FILE_STATUS_PERMANENT
const FILE_STATUS_PERMANENT
Definition: file.inc:70
user_hash_password
user_hash_password($password, $count_log2=0)
Definition: password.inc:207
user_update_7018
user_update_7018()
Definition: user.install:905
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
user_update_7010
user_update_7010()
Definition: user.install:649
db_drop_field
db_drop_field($table, $field)
Definition: database.inc:2852
DRUPAL_ANONYMOUS_RID
const DRUPAL_ANONYMOUS_RID
Definition: bootstrap.inc:162
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
user_update_7005
user_update_7005(&$sandbox)
Definition: user.install:574
file_load_multiple
file_load_multiple($fids=array(), $conditions=array())
Definition: file.inc:564
user_update_7006
user_update_7006(&$sandbox)
Definition: user.install:597
$value
print $value
Definition: user-profile-item.tpl.php:26
user_schema
user_schema()
Definition: user.install:11
DRUPAL_AUTHENTICATED_RID
const DRUPAL_AUTHENTICATED_RID
Definition: bootstrap.inc:167
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
db_like
db_like($string)
Definition: database.inc:2610
user_update_7014
user_update_7014()
Definition: user.install:812
user_update_7012
user_update_7012(&$sandbox)
Definition: user.install:709
db_index_exists
db_index_exists($table, $name)
Definition: database.inc:2747
user_update_7011
user_update_7011()
Definition: user.install:702
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
format_string
format_string($string, array $args=array())
Definition: bootstrap.inc:1527
USER_REGISTER_VISITORS
const USER_REGISTER_VISITORS
Definition: user.module:26
$row
$row
Definition: block-admin-display-form.tpl.php:47
drupal_basename
drupal_basename($uri, $suffix=NULL)
Definition: file.inc:2317
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
user_update_7003
user_update_7003()
Definition: user.install:552
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
user_update_7016
user_update_7016()
Definition: user.install:845
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
file_save
file_save(stdClass $file)
Definition: file.inc:599
user_update_7007
user_update_7007()
Definition: user.install:616
user_update_7008
user_update_7008()
Definition: user.install:625
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
user_install
user_install()
Definition: user.install:293
file_get_mimetype
file_get_mimetype($uri, $mapping=NULL)
Definition: file.inc:2143
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
SearchQuery Member List

This is the complete list of members for SearchQuery, including all inherited members.

$conditions | SearchQuery | protected
$connection | SelectQueryExtender | protected
$executedFirstPass | SearchQuery | protected
$expressionsIgnored | SearchQuery | protected
$keys | SearchQuery | protected
$matches | SearchQuery | protected
$multiply | SearchQuery | protected
$normalize | SearchQuery | protected
$placeholder | SelectQueryExtender | protected
$query | SelectQueryExtender | protected
$scores | SearchQuery | protected
$scoresArguments | SearchQuery | protected
$searchExpression | SearchQuery | protected
$simple | SearchQuery | protected
$type | SearchQuery | protected
$uniqueIdentifier | SelectQueryExtender | protected
$words | SearchQuery | protected
__call($method, $args) | SelectQueryExtender |
__clone() | SelectQueryExtender |
__construct(SelectQueryInterface $query, DatabaseConnection $connection) | SelectQueryExtender |
__toString() | SelectQueryExtender |
addExpression($expression, $alias=NULL, $arguments=array()) | SelectQueryExtender |
addField($table_alias, $field, $alias=NULL) | SelectQueryExtender |
addJoin($type, $table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
addMetaData($key, $object) | SelectQueryExtender |
addScore($score, $arguments=array(), $multiply=FALSE) | SearchQuery |
addTag($tag) | SelectQueryExtender |
arguments() | SelectQueryExtender |
compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder) | SelectQueryExtender |
compiled() | SelectQueryExtender |
condition($field, $value=NULL, $operator=NULL) | SelectQueryExtender |
conditions() | SelectQueryExtender |
countQuery() | SearchQuery |
distinct($distinct=TRUE) | SelectQueryExtender |
execute() | SearchQuery |
executeFirstPass() | SearchQuery |
exists(SelectQueryInterface $select) | SelectQueryExtender |
extend($extender_name) | SelectQueryExtender |
fields($table_alias, array $fields=array()) | SelectQueryExtender |
forUpdate($set=TRUE) | SelectQueryExtender |
getArguments(QueryPlaceholderInterface $queryPlaceholder=NULL) | SelectQueryExtender |
getExpressions() | SelectQueryExtender |
getFields() | SelectQueryExtender |
getGroupBy() | SelectQueryExtender |
getMetaData($key) | SelectQueryExtender |
getOrderBy() | SelectQueryExtender |
getTables() | SelectQueryExtender |
getUnion() | SelectQueryExtender |
groupBy($field) | SelectQueryExtender |
hasAllTags() | SelectQueryExtender |
hasAnyTag() | SelectQueryExtender |
hasTag($tag) | SelectQueryExtender |
having($snippet, $args=array()) | SelectQueryExtender |
havingArguments() | SelectQueryExtender |
havingCompile(DatabaseConnection $connection) | SelectQueryExtender |
havingCondition($field, $value=NULL, $operator= '=') | SelectQueryExtender |
havingConditions() | SelectQueryExtender |
innerJoin($table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
isNotNull($field) | SelectQueryExtender |
isNull($field) | SelectQueryExtender |
isPrepared() | SelectQueryExtender |
join($table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
leftJoin($table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
nextPlaceholder() | SelectQueryExtender |
notExists(SelectQueryInterface $select) | SelectQueryExtender |
orderBy($field, $direction= 'ASC') | SelectQueryExtender |
orderRandom() | SelectQueryExtender |
parseSearchExpression() | SearchQuery | protected
parseWord($word) | SearchQuery | protected
preExecute(SelectQueryInterface $query=NULL) | SelectQueryExtender |
range($start=NULL, $length=NULL) | SelectQueryExtender |
rightJoin($table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
searchExpression($expression, $module) | SearchQuery |
setOption($option, $column) | SearchQuery |
union(SelectQueryInterface $query, $type= '') | SelectQueryExtender |
uniqueIdentifier() | SelectQueryExtender |
where($snippet, $args=array()) | SelectQueryExtender |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/schema.inc Source File

  • includes
  • database
schema.inc
Go to the documentation of this file.
1 <?php
2
8 require_once dirname(__FILE__) . '/query.inc';
9
164 abstract class DatabaseSchema implements QueryPlaceholderInterface {
165
166 protected $connection;
167
171 protected $placeholder = 0;
172
182 protected $defaultSchema = 'public';
183
187 protected $uniqueIdentifier;
188
189 public function __construct($connection) {
190 $this->uniqueIdentifier = uniqid('', TRUE);
191 $this->connection = $connection;
192 }
193
197 public function __clone() {
198 $this->uniqueIdentifier = uniqid('', TRUE);
199 }
200
204 public function uniqueIdentifier() {
205 return $this->uniqueIdentifier;
206 }
207
211 public function nextPlaceholder() {
212 return $this->placeholder++;
213 }
214
227 protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) {
228 $info = array(
229 'schema' => $this->defaultSchema,
230 'prefix' => $this->connection->tablePrefix($table),
231 );
232 if ($add_prefix) {
233 $table = $info['prefix'] . $table;
234 }
235 // If the prefix contains a period in it, then that means the prefix also
236 // contains a schema reference in which case we will change the schema key
237 // to the value before the period in the prefix. Everything after the dot
238 // will be prefixed onto the front of the table.
239 if (($pos = strpos($table, '.')) !== FALSE) {
240 // Grab everything before the period.
241 $info['schema'] = substr($table, 0, $pos);
242 // Grab everything after the dot.
243 $info['table'] = substr($table, ++$pos);
244 }
245 else {
246 $info['table'] = $table;
247 }
248 return $info;
249 }
250
256 function prefixNonTable($table) {
257 $args = func_get_args();
258 $info = $this->getPrefixInfo($table);
259 $args[0] = $info['table'];
260 return implode('_', $args);
261 }
262
288 protected function buildTableNameCondition($table_name, $operator = '=', $add_prefix = TRUE) {
289 $info = $this->connection->getConnectionOptions();
290
291 // Retrive the table name and schema
292 $table_info = $this->getPrefixInfo($table_name, $add_prefix);
293
294 $condition = new DatabaseCondition('AND');
295 $condition->condition('table_catalog', $info['database']);
296 $condition->condition('table_schema', $table_info['schema']);
297 $condition->condition('table_name', $table_info['table'], $operator);
298 return $condition;
299 }
300
310 public function tableExists($table) {
311 $condition = $this->buildTableNameCondition($table);
312 $condition->compile($this->connection, $this);
313 // Normally, we would heartily discourage the use of string
314 // concatenation for conditionals like this however, we
315 // couldn't use db_select() here because it would prefix
316 // information_schema.tables and the query would fail.
317 // Don't use {} around information_schema.tables table.
318 return (bool) $this->connection->query("SELECT 1 FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments())->fetchField();
319 }
320
331 public function findTables($table_expression) {
332 $condition = $this->buildTableNameCondition($table_expression, 'LIKE', FALSE);
333
334 $condition->compile($this->connection, $this);
335 // Normally, we would heartily discourage the use of string
336 // concatenation for conditionals like this however, we
337 // couldn't use db_select() here because it would prefix
338 // information_schema.tables and the query would fail.
339 // Don't use {} around information_schema.tables table.
340 return $this->connection->query("SELECT table_name FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments())->fetchAllKeyed(0, 0);
341 }
342
354 public function fieldExists($table, $column) {
355 $condition = $this->buildTableNameCondition($table);
356 $condition->condition('column_name', $column);
357 $condition->compile($this->connection, $this);
358 // Normally, we would heartily discourage the use of string
359 // concatenation for conditionals like this however, we
360 // couldn't use db_select() here because it would prefix
361 // information_schema.tables and the query would fail.
362 // Don't use {} around information_schema.columns table.
363 return (bool) $this->connection->query("SELECT 1 FROM information_schema.columns WHERE " . (string) $condition, $condition->arguments())->fetchField();
364 }
365
376 abstract public function getFieldTypeMap();
377
391 abstract public function renameTable($table, $new_name);
392
403 abstract public function dropTable($table);
404
431 abstract public function addField($table, $field, $spec, $keys_new = array());
432
445 abstract public function dropField($table, $field);
446
460 abstract public function fieldSetDefault($table, $field, $default);
461
473 abstract public function fieldSetNoDefault($table, $field);
474
486 abstract public function indexExists($table, $name);
487
501 abstract public function addPrimaryKey($table, $fields);
502
513 abstract public function dropPrimaryKey($table);
514
530 abstract public function addUniqueKey($table, $name, $fields);
531
544 abstract public function dropUniqueKey($table, $name);
545
561 abstract public function addIndex($table, $name, $fields);
562
575 abstract public function dropIndex($table, $name);
576
642 abstract public function changeField($table, $field, $field_new, $spec, $keys_new = array());
643
655 public function createTable($name, $table) {
656 if ($this->tableExists($name)) {
657 throw new DatabaseSchemaObjectExistsException(t('Table %name already exists.', array('%name' => $name)));
658 }
659 $statements = $this->createTableSql($name, $table);
660 foreach ($statements as $statement) {
661 $this->connection->query($statement);
662 }
663 }
664
677 public function fieldNames($fields) {
678 $return = array();
679 foreach ($fields as $field) {
680 if (is_array($field)) {
681 $return[] = $field[0];
682 }
683 else {
684 $return[] = $field;
685 }
686 }
687 return $return;
688 }
689
701 public function prepareComment($comment, $length = NULL) {
702 return $this->connection->quote($comment);
703 }
704 }
705
713 class DatabaseSchemaObjectExistsException extends Exception {}
714
722 class DatabaseSchemaObjectDoesNotExistException extends Exception {}
723
DatabaseSchema\addPrimaryKey
addPrimaryKey($table, $fields)
DatabaseSchema\fieldSetNoDefault
fieldSetNoDefault($table, $field)
DatabaseSchema\__construct
__construct($connection)
Definition: schema.inc:189
DatabaseSchema\fieldNames
fieldNames($fields)
Definition: schema.inc:677
DatabaseSchema\fieldSetDefault
fieldSetDefault($table, $field, $default)
DatabaseSchema\__clone
__clone()
Definition: schema.inc:197
DatabaseSchema\$uniqueIdentifier
$uniqueIdentifier
Definition: schema.inc:187
DatabaseSchemaObjectExistsException
Definition: schema.inc:713
DatabaseSchema\prefixNonTable
prefixNonTable($table)
Definition: schema.inc:256
$name
print $name
Definition: profile-listing.tpl.php:43
Exception
DatabaseSchema
Definition: schema.inc:164
DatabaseSchema\addField
addField($table, $field, $spec, $keys_new=array())
DatabaseSchema\indexExists
indexExists($table, $name)
DatabaseSchema\dropUniqueKey
dropUniqueKey($table, $name)
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
DatabaseCondition
Definition: query.inc:1652
$info
$info
Definition: color.inc:6
DatabaseSchemaObjectDoesNotExistException
Definition: schema.inc:722
DatabaseSchema\addUniqueKey
addUniqueKey($table, $name, $fields)
QueryPlaceholderInterface
Definition: query.inc:253
DatabaseSchema\dropPrimaryKey
dropPrimaryKey($table)
DatabaseSchema\nextPlaceholder
nextPlaceholder()
Definition: schema.inc:211
DatabaseSchema\findTables
findTables($table_expression)
Definition: schema.inc:331
DatabaseSchema\dropField
dropField($table, $field)
DatabaseSchema\renameTable
renameTable($table, $new_name)
DatabaseSchema\getPrefixInfo
getPrefixInfo($table= 'default', $add_prefix=TRUE)
Definition: schema.inc:227
DatabaseSchema\buildTableNameCondition
buildTableNameCondition($table_name, $operator= '=', $add_prefix=TRUE)
Definition: schema.inc:288
DatabaseSchema\dropTable
dropTable($table)
DatabaseSchema\addIndex
addIndex($table, $name, $fields)
DatabaseSchema\tableExists
tableExists($table)
Definition: schema.inc:310
DatabaseSchema\$connection
$connection
Definition: schema.inc:166
DatabaseSchema\prepareComment
prepareComment($comment, $length=NULL)
Definition: schema.inc:701
DatabaseSchema\changeField
changeField($table, $field, $field_new, $spec, $keys_new=array())
DatabaseSchema\$defaultSchema
$defaultSchema
Definition: schema.inc:182
DatabaseSchema\dropIndex
dropIndex($table, $name)
DatabaseSchema\createTable
createTable($name, $table)
Definition: schema.inc:655
DatabaseSchema\fieldExists
fieldExists($table, $column)
Definition: schema.inc:354
DatabaseSchema\uniqueIdentifier
uniqueIdentifier()
Definition: schema.inc:204
DatabaseSchema\$placeholder
$placeholder
Definition: schema.inc:171
DatabaseSchema\getFieldTypeMap
getFieldTypeMap()
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/menu/menu.api.php Source File

  • modules
  • menu
menu.api.php
Go to the documentation of this file.
1 <?php
2
29 function hook_menu_insert($menu) {
30 // For example, we track available menus in a variable.
31 $my_menus = variable_get('my_module_menus', array());
32 $my_menus[$menu['menu_name']] = $menu['menu_name'];
33 variable_set('my_module_menus', $my_menus);
34 }
35
54 function hook_menu_update($menu) {
55 // For example, we track available menus in a variable.
56 $my_menus = variable_get('my_module_menus', array());
57 $my_menus[$menu['menu_name']] = $menu['menu_name'];
58 variable_set('my_module_menus', $my_menus);
59 }
60
78 function hook_menu_delete($menu) {
79 // Delete the record from our variable.
80 $my_menus = variable_get('my_module_menus', array());
81 unset($my_menus[$menu['menu_name']]);
82 variable_set('my_module_menus', $my_menus);
83 }
84
hook_menu_update
hook_menu_update($menu)
Definition: menu.api.php:54
hook_menu_insert
hook_menu_insert($menu)
Definition: menu.api.php:29
hook_menu_delete
hook_menu_delete($menu)
Definition: menu.api.php:78
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/language.api.php Source File

  • modules
  • system
language.api.php
Go to the documentation of this file.
1 <?php
2
26 function hook_language_init() {
27 global $language, $conf;
28
29 switch ($language->language) {
30 case 'it':
31 $conf['site_name'] = 'Il mio sito Drupal';
32 break;
33
34 case 'fr':
35 $conf['site_name'] = 'Mon site Drupal';
36 break;
37 }
38 }
39
54 function hook_language_switch_links_alter(array &$links, $type, $path) {
55 global $language;
56
57 if ($type == LANGUAGE_TYPE_CONTENT && isset($links[$language->language])) {
58 foreach ($links[$language->language] as $link) {
59 $link['attributes']['class'][] = 'active-language';
60 }
61 }
62 }
63
82 function hook_language_types_info() {
83 return array(
84 'custom_language_type' => array(
85 'name' => t('Custom language'),
86 'description' => t('A custom language type.'),
87 ),
88 'fixed_custom_language_type' => array(
89 'fixed' => array('custom_language_provider'),
90 ),
91 );
92 }
93
103 function hook_language_types_info_alter(array &$language_types) {
104 if (isset($language_types['custom_language_type'])) {
105 $language_types['custom_language_type_custom']['description'] = t('A far better description.');
106 }
107 }
108
140 function hook_language_negotiation_info() {
141 return array(
142 'custom_language_provider' => array(
143 'callbacks' => array(
144 'language' => 'custom_language_provider_callback',
145 'switcher' => 'custom_language_switcher_callback',
146 'url_rewrite' => 'custom_language_url_rewrite_callback',
147 ),
148 'file' => drupal_get_path('module', 'custom') . '/custom.module',
149 'weight' => -4,
150 'types' => array('custom_language_type'),
151 'name' => t('Custom language negotiation provider'),
152 'description' => t('This is a custom language negotiation provider.'),
153 'cache' => 0,
154 ),
155 );
156 }
157
167 function hook_language_negotiation_info_alter(array &$language_providers) {
168 if (isset($language_providers['custom_language_provider'])) {
169 $language_providers['custom_language_provider']['config'] = 'admin/config/regional/language/configure/custom-language-provider';
170 }
171 }
172
180 function hook_language_fallback_candidates_alter(array &$fallback_candidates) {
181 $fallback_candidates = array_reverse($fallback_candidates);
182 }
183
hook_language_init
hook_language_init()
Definition: language.api.php:26
hook_language_negotiation_info_alter
hook_language_negotiation_info_alter(array &$language_providers)
Definition: language.api.php:167
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
LANGUAGE_TYPE_CONTENT
const LANGUAGE_TYPE_CONTENT
Definition: bootstrap.inc:186
hook_language_switch_links_alter
hook_language_switch_links_alter(array &$links, $type, $path)
Definition: language.api.php:54
$conf
global $conf
Definition: authorize.php:74
hook_language_types_info_alter
hook_language_types_info_alter(array &$language_types)
Definition: language.api.php:103
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
hook_language_fallback_candidates_alter
hook_language_fallback_candidates_alter(array &$fallback_candidates)
Definition: language.api.php:180
hook_language_negotiation_info
hook_language_negotiation_info()
Definition: language.api.php:140
$links
print $links
Definition: poll-results--block.tpl.php:28
hook_language_types_info
hook_language_types_info()
Definition: language.api.php:82
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/file.mimetypes.inc Source File

  • includes
file.mimetypes.inc
Go to the documentation of this file.
1 <?php
2
18 function file_mimetype_mapping() {
19 $mapping = &drupal_static(__FUNCTION__);
20 if (!isset($mapping)) {
21 $mapping = file_default_mimetype_mapping();
22 // Allow modules to alter the default mapping.
23 drupal_alter('file_mimetype_mapping', $mapping);
24 }
25 return $mapping;
26 }
27
36 function file_default_mimetype_mapping() {
37 return array(
38 'mimetypes' => array(
39 0 => 'application/andrew-inset',
40 1 => 'application/atom',
41 2 => 'application/atomcat+xml',
42 3 => 'application/atomserv+xml',
43 4 => 'application/cap',
44 5 => 'application/cu-seeme',
45 6 => 'application/dsptype',
46 7 => 'application/hta',
47 8 => 'application/java-archive',
48 9 => 'application/java-serialized-object',
49 10 => 'application/java-vm',
50 11 => 'application/mac-binhex40',
51 12 => 'application/mathematica',
52 13 => 'application/msaccess',
53 14 => 'application/msword',
54 15 => 'application/octet-stream',
55 16 => 'application/oda',
56 17 => 'application/ogg',
57 18 => 'application/pdf',
58 19 => 'application/pgp-keys',
59 20 => 'application/pgp-signature',
60 21 => 'application/pics-rules',
61 22 => 'application/postscript',
62 23 => 'application/rar',
63 24 => 'application/rdf+xml',
64 25 => 'application/rss+xml',
65 26 => 'application/rtf',
66 27 => 'application/smil',
67 28 => 'application/vnd.cinderella',
68 29 => 'application/vnd.google-earth.kml+xml',
69 30 => 'application/vnd.google-earth.kmz',
70 31 => 'application/vnd.mozilla.xul+xml',
71 32 => 'application/vnd.ms-excel',
72 33 => 'application/vnd.ms-excel.addin.macroEnabled.12',
73 34 => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
74 35 => 'application/vnd.ms-excel.sheet.macroEnabled.12',
75 36 => 'application/vnd.ms-excel.template.macroEnabled.12',
76 37 => 'application/vnd.ms-pki.seccat',
77 38 => 'application/vnd.ms-pki.stl',
78 39 => 'application/vnd.ms-powerpoint',
79 40 => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',
80 41 => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
81 42 => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
82 43 => 'application/vnd.ms-powerpoint.template.macroEnabled.12',
83 44 => 'application/vnd.ms-word.document.macroEnabled.12',
84 45 => 'application/vnd.ms-word.template.macroEnabled.12',
85 46 => 'application/vnd.ms-xpsdocument',
86 47 => 'application/vnd.oasis.opendocument.chart',
87 48 => 'application/vnd.oasis.opendocument.database',
88 49 => 'application/vnd.oasis.opendocument.formula',
89 50 => 'application/vnd.oasis.opendocument.graphics',
90 51 => 'application/vnd.oasis.opendocument.graphics-template',
91 52 => 'application/vnd.oasis.opendocument.image',
92 53 => 'application/vnd.oasis.opendocument.presentation',
93 54 => 'application/vnd.oasis.opendocument.presentation-template',
94 55 => 'application/vnd.oasis.opendocument.spreadsheet',
95 56 => 'application/vnd.oasis.opendocument.spreadsheet-template',
96 57 => 'application/vnd.oasis.opendocument.text',
97 58 => 'application/vnd.oasis.opendocument.text-master',
98 59 => 'application/vnd.oasis.opendocument.text-template',
99 60 => 'application/vnd.oasis.opendocument.text-web',
100 61 => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
101 62 => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
102 63 => 'application/vnd.openxmlformats-officedocument.presentationml.template',
103 64 => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
104 65 => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
105 66 => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
106 67 => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
107 68 => 'application/vnd.rim.cod',
108 69 => 'application/vnd.smaf',
109 70 => 'application/vnd.stardivision.calc',
110 71 => 'application/vnd.stardivision.chart',
111 72 => 'application/vnd.stardivision.draw',
112 73 => 'application/vnd.stardivision.impress',
113 74 => 'application/vnd.stardivision.math',
114 75 => 'application/vnd.stardivision.writer',
115 76 => 'application/vnd.stardivision.writer-global',
116 77 => 'application/vnd.sun.xml.calc',
117 78 => 'application/vnd.sun.xml.calc.template',
118 79 => 'application/vnd.sun.xml.draw',
119 80 => 'application/vnd.sun.xml.draw.template',
120 81 => 'application/vnd.sun.xml.impress',
121 82 => 'application/vnd.sun.xml.impress.template',
122 83 => 'application/vnd.sun.xml.math',
123 84 => 'application/vnd.sun.xml.writer',
124 85 => 'application/vnd.sun.xml.writer.global',
125 86 => 'application/vnd.sun.xml.writer.template',
126 87 => 'application/vnd.symbian.install',
127 88 => 'application/vnd.visio',
128 89 => 'application/vnd.wap.wbxml',
129 90 => 'application/vnd.wap.wmlc',
130 91 => 'application/vnd.wap.wmlscriptc',
131 92 => 'application/wordperfect',
132 93 => 'application/wordperfect5.1',
133 94 => 'application/x-123',
134 95 => 'application/x-7z-compressed',
135 96 => 'application/x-abiword',
136 97 => 'application/x-apple-diskimage',
137 98 => 'application/x-bcpio',
138 99 => 'application/x-bittorrent',
139 100 => 'application/x-cab',
140 101 => 'application/x-cbr',
141 102 => 'application/x-cbz',
142 103 => 'application/x-cdf',
143 104 => 'application/x-cdlink',
144 105 => 'application/x-chess-pgn',
145 106 => 'application/x-cpio',
146 107 => 'application/x-debian-package',
147 108 => 'application/x-director',
148 109 => 'application/x-dms',
149 110 => 'application/x-doom',
150 111 => 'application/x-dvi',
151 112 => 'application/x-flac',
152 113 => 'application/x-font',
153 114 => 'application/x-freemind',
154 115 => 'application/x-futuresplash',
155 116 => 'application/x-gnumeric',
156 117 => 'application/x-go-sgf',
157 118 => 'application/x-graphing-calculator',
158 119 => 'application/x-gtar',
159 120 => 'application/x-hdf',
160 121 => 'application/x-httpd-eruby',
161 122 => 'application/x-httpd-php',
162 123 => 'application/x-httpd-php-source',
163 124 => 'application/x-httpd-php3',
164 125 => 'application/x-httpd-php3-preprocessed',
165 126 => 'application/x-httpd-php4',
166 127 => 'application/x-ica',
167 128 => 'application/x-internet-signup',
168 129 => 'application/x-iphone',
169 130 => 'application/x-iso9660-image',
170 131 => 'application/x-java-jnlp-file',
171 132 => 'application/x-javascript',
172 133 => 'application/x-jmol',
173 134 => 'application/x-kchart',
174 135 => 'application/x-killustrator',
175 136 => 'application/x-koan',
176 137 => 'application/x-kpresenter',
177 138 => 'application/x-kspread',
178 139 => 'application/x-kword',
179 140 => 'application/x-latex',
180 141 => 'application/x-lha',
181 142 => 'application/x-lyx',
182 143 => 'application/x-lzh',
183 144 => 'application/x-lzx',
184 145 => 'application/x-maker',
185 146 => 'application/x-mif',
186 147 => 'application/x-ms-wmd',
187 148 => 'application/x-ms-wmz',
188 149 => 'application/x-msdos-program',
189 150 => 'application/x-msi',
190 151 => 'application/x-netcdf',
191 152 => 'application/x-ns-proxy-autoconfig',
192 153 => 'application/x-nwc',
193 154 => 'application/x-object',
194 155 => 'application/x-oz-application',
195 156 => 'application/x-pkcs7-certreqresp',
196 157 => 'application/x-pkcs7-crl',
197 158 => 'application/x-python-code',
198 159 => 'application/x-quicktimeplayer',
199 160 => 'application/x-redhat-package-manager',
200 161 => 'application/x-shar',
201 162 => 'application/x-shockwave-flash',
202 163 => 'application/x-stuffit',
203 164 => 'application/x-sv4cpio',
204 165 => 'application/x-sv4crc',
205 166 => 'application/x-tar',
206 167 => 'application/x-tcl',
207 168 => 'application/x-tex-gf',
208 169 => 'application/x-tex-pk',
209 170 => 'application/x-texinfo',
210 171 => 'application/x-trash',
211 172 => 'application/x-troff',
212 173 => 'application/x-troff-man',
213 174 => 'application/x-troff-me',
214 175 => 'application/x-troff-ms',
215 176 => 'application/x-ustar',
216 177 => 'application/x-wais-source',
217 178 => 'application/x-wingz',
218 179 => 'application/x-x509-ca-cert',
219 180 => 'application/x-xcf',
220 181 => 'application/x-xfig',
221 182 => 'application/x-xpinstall',
222 183 => 'application/xhtml+xml',
223 184 => 'application/xml',
224 185 => 'application/zip',
225 186 => 'audio/basic',
226 187 => 'audio/midi',
227 346 => 'audio/mp4',
228 188 => 'audio/mpeg',
229 189 => 'audio/ogg',
230 190 => 'audio/prs.sid',
231 191 => 'audio/x-aiff',
232 192 => 'audio/x-gsm',
233 193 => 'audio/x-mpegurl',
234 194 => 'audio/x-ms-wax',
235 195 => 'audio/x-ms-wma',
236 196 => 'audio/x-pn-realaudio',
237 197 => 'audio/x-realaudio',
238 198 => 'audio/x-scpls',
239 199 => 'audio/x-sd2',
240 200 => 'audio/x-wav',
241 201 => 'chemical/x-alchemy',
242 202 => 'chemical/x-cache',
243 203 => 'chemical/x-cache-csf',
244 204 => 'chemical/x-cactvs-binary',
245 205 => 'chemical/x-cdx',
246 206 => 'chemical/x-cerius',
247 207 => 'chemical/x-chem3d',
248 208 => 'chemical/x-chemdraw',
249 209 => 'chemical/x-cif',
250 210 => 'chemical/x-cmdf',
251 211 => 'chemical/x-cml',
252 212 => 'chemical/x-compass',
253 213 => 'chemical/x-crossfire',
254 214 => 'chemical/x-csml',
255 215 => 'chemical/x-ctx',
256 216 => 'chemical/x-cxf',
257 217 => 'chemical/x-embl-dl-nucleotide',
258 218 => 'chemical/x-galactic-spc',
259 219 => 'chemical/x-gamess-input',
260 220 => 'chemical/x-gaussian-checkpoint',
261 221 => 'chemical/x-gaussian-cube',
262 222 => 'chemical/x-gaussian-input',
263 223 => 'chemical/x-gaussian-log',
264 224 => 'chemical/x-gcg8-sequence',
265 225 => 'chemical/x-genbank',
266 226 => 'chemical/x-hin',
267 227 => 'chemical/x-isostar',
268 228 => 'chemical/x-jcamp-dx',
269 229 => 'chemical/x-kinemage',
270 230 => 'chemical/x-macmolecule',
271 231 => 'chemical/x-macromodel-input',
272 232 => 'chemical/x-mdl-molfile',
273 233 => 'chemical/x-mdl-rdfile',
274 234 => 'chemical/x-mdl-rxnfile',
275 235 => 'chemical/x-mdl-sdfile',
276 236 => 'chemical/x-mdl-tgf',
277 237 => 'chemical/x-mmcif',
278 238 => 'chemical/x-mol2',
279 239 => 'chemical/x-molconn-Z',
280 240 => 'chemical/x-mopac-graph',
281 241 => 'chemical/x-mopac-input',
282 242 => 'chemical/x-mopac-out',
283 243 => 'chemical/x-mopac-vib',
284 244 => 'chemical/x-ncbi-asn1-ascii',
285 245 => 'chemical/x-ncbi-asn1-binary',
286 246 => 'chemical/x-ncbi-asn1-spec',
287 247 => 'chemical/x-pdb',
288 248 => 'chemical/x-rosdal',
289 249 => 'chemical/x-swissprot',
290 250 => 'chemical/x-vamas-iso14976',
291 251 => 'chemical/x-vmd',
292 252 => 'chemical/x-xtel',
293 253 => 'chemical/x-xyz',
294 254 => 'image/gif',
295 255 => 'image/ief',
296 256 => 'image/jpeg',
297 257 => 'image/pcx',
298 258 => 'image/png',
299 259 => 'image/svg+xml',
300 260 => 'image/tiff',
301 261 => 'image/vnd.djvu',
302 262 => 'image/vnd.microsoft.icon',
303 263 => 'image/vnd.wap.wbmp',
304 264 => 'image/x-cmu-raster',
305 265 => 'image/x-coreldraw',
306 266 => 'image/x-coreldrawpattern',
307 267 => 'image/x-coreldrawtemplate',
308 268 => 'image/x-corelphotopaint',
309 269 => 'image/x-jg',
310 270 => 'image/x-jng',
311 271 => 'image/x-ms-bmp',
312 272 => 'image/x-photoshop',
313 273 => 'image/x-portable-anymap',
314 274 => 'image/x-portable-bitmap',
315 275 => 'image/x-portable-graymap',
316 276 => 'image/x-portable-pixmap',
317 277 => 'image/x-rgb',
318 278 => 'image/x-xbitmap',
319 279 => 'image/x-xpixmap',
320 280 => 'image/x-xwindowdump',
321 281 => 'message/rfc822',
322 282 => 'model/iges',
323 283 => 'model/mesh',
324 284 => 'model/vrml',
325 285 => 'text/calendar',
326 286 => 'text/css',
327 287 => 'text/csv',
328 288 => 'text/h323',
329 289 => 'text/html',
330 290 => 'text/iuls',
331 291 => 'text/mathml',
332 292 => 'text/plain',
333 293 => 'text/richtext',
334 294 => 'text/scriptlet',
335 295 => 'text/tab-separated-values',
336 296 => 'text/texmacs',
337 297 => 'text/vnd.sun.j2me.app-descriptor',
338 298 => 'text/vnd.wap.wml',
339 299 => 'text/vnd.wap.wmlscript',
340 300 => 'text/x-bibtex',
341 301 => 'text/x-boo',
342 302 => 'text/x-c++hdr',
343 303 => 'text/x-c++src',
344 304 => 'text/x-chdr',
345 305 => 'text/x-component',
346 306 => 'text/x-csh',
347 307 => 'text/x-csrc',
348 308 => 'text/x-diff',
349 309 => 'text/x-dsrc',
350 310 => 'text/x-haskell',
351 311 => 'text/x-java',
352 312 => 'text/x-literate-haskell',
353 313 => 'text/x-moc',
354 314 => 'text/x-pascal',
355 315 => 'text/x-pcs-gcd',
356 316 => 'text/x-perl',
357 317 => 'text/x-python',
358 318 => 'text/x-setext',
359 319 => 'text/x-sh',
360 320 => 'text/x-tcl',
361 321 => 'text/x-tex',
362 322 => 'text/x-vcalendar',
363 323 => 'text/x-vcard',
364 324 => 'video/3gpp',
365 325 => 'video/dl',
366 326 => 'video/dv',
367 327 => 'video/fli',
368 328 => 'video/gl',
369 329 => 'video/mp4',
370 330 => 'video/mpeg',
371 331 => 'video/ogg',
372 332 => 'video/quicktime',
373 333 => 'video/vnd.mpegurl',
374 347 => 'video/x-flv',
375 334 => 'video/x-la-asf',
376 348 => 'video/x-m4v',
377 335 => 'video/x-mng',
378 336 => 'video/x-ms-asf',
379 337 => 'video/x-ms-wm',
380 338 => 'video/x-ms-wmv',
381 339 => 'video/x-ms-wmx',
382 340 => 'video/x-ms-wvx',
383 341 => 'video/x-msvideo',
384 342 => 'video/x-sgi-movie',
385 343 => 'x-conference/x-cooltalk',
386 344 => 'x-epoc/x-sisx-app',
387 345 => 'x-world/x-vrml',
388 ),
389
390 // Extensions added to this list MUST be lower-case.
391 'extensions' => array(
392 'ez' => 0,
393 'atom' => 1,
394 'atomcat' => 2,
395 'atomsrv' => 3,
396 'cap' => 4,
397 'pcap' => 4,
398 'cu' => 5,
399 'tsp' => 6,
400 'hta' => 7,
401 'jar' => 8,
402 'ser' => 9,
403 'class' => 10,
404 'hqx' => 11,
405 'nb' => 12,
406 'mdb' => 13,
407 'dot' => 14,
408 'doc' => 14,
409 'bin' => 15,
410 'oda' => 16,
411 'ogx' => 17,
412 'pdf' => 18,
413 'key' => 19,
414 'pgp' => 20,
415 'prf' => 21,
416 'eps' => 22,
417 'ai' => 22,
418 'ps' => 22,
419 'rar' => 23,
420 'rdf' => 24,
421 'rss' => 25,
422 'rtf' => 26,
423 'smi' => 27,
424 'smil' => 27,
425 'cdy' => 28,
426 'kml' => 29,
427 'kmz' => 30,
428 'xul' => 31,
429 'xlb' => 32,
430 'xlt' => 32,
431 'xls' => 32,
432 'xlam' => 33,
433 'xlsb' => 34,
434 'xlsm' => 35,
435 'xltm' => 36,
436 'cat' => 37,
437 'stl' => 38,
438 'pps' => 39,
439 'ppt' => 39,
440 'ppam' => 40,
441 'pptm' => 41,
442 'ppsm' => 42,
443 'potm' => 43,
444 'docm' => 44,
445 'dotm' => 45,
446 'xps' => 46,
447 'odc' => 47,
448 'odb' => 48,
449 'odf' => 49,
450 'odg' => 50,
451 'otg' => 51,
452 'odi' => 52,
453 'odp' => 53,
454 'otp' => 54,
455 'ods' => 55,
456 'ots' => 56,
457 'odt' => 57,
458 'odm' => 58,
459 'ott' => 59,
460 'oth' => 60,
461 'pptx' => 61,
462 'ppsx' => 62,
463 'potx' => 63,
464 'xlsx' => 64,
465 'xltx' => 65,
466 'docx' => 66,
467 'dotx' => 67,
468 'cod' => 68,
469 'mmf' => 69,
470 'sdc' => 70,
471 'sds' => 71,
472 'sda' => 72,
473 'sdd' => 73,
474 'sdw' => 75,
475 'sgl' => 76,
476 'sxc' => 77,
477 'stc' => 78,
478 'sxd' => 79,
479 'std' => 80,
480 'sxi' => 81,
481 'sti' => 82,
482 'sxm' => 83,
483 'sxw' => 84,
484 'sxg' => 85,
485 'stw' => 86,
486 'sis' => 87,
487 'vsd' => 88,
488 'wbxml' => 89,
489 'wmlc' => 90,
490 'wmlsc' => 91,
491 'wpd' => 92,
492 'wp5' => 93,
493 'wk' => 94,
494 '7z' => 95,
495 'abw' => 96,
496 'dmg' => 97,
497 'bcpio' => 98,
498 'torrent' => 99,
499 'cab' => 100,
500 'cbr' => 101,
501 'cbz' => 102,
502 'cdf' => 103,
503 'vcd' => 104,
504 'pgn' => 105,
505 'cpio' => 106,
506 'udeb' => 107,
507 'deb' => 107,
508 'dir' => 108,
509 'dxr' => 108,
510 'dcr' => 108,
511 'dms' => 109,
512 'wad' => 110,
513 'dvi' => 111,
514 'flac' => 112,
515 'pfa' => 113,
516 'pfb' => 113,
517 'pcf' => 113,
518 'gsf' => 113,
519 'pcf.z' => 113,
520 'mm' => 114,
521 'spl' => 115,
522 'gnumeric' => 116,
523 'sgf' => 117,
524 'gcf' => 118,
525 'taz' => 119,
526 'gtar' => 119,
527 'tgz' => 119,
528 'hdf' => 120,
529 'rhtml' => 121,
530 'phtml' => 122,
531 'pht' => 122,
532 'php' => 122,
533 'phps' => 123,
534 'php3' => 124,
535 'php3p' => 125,
536 'php4' => 126,
537 'ica' => 127,
538 'ins' => 128,
539 'isp' => 128,
540 'iii' => 129,
541 'iso' => 130,
542 'jnlp' => 131,
543 'js' => 132,
544 'jmz' => 133,
545 'chrt' => 134,
546 'kil' => 135,
547 'skp' => 136,
548 'skd' => 136,
549 'skm' => 136,
550 'skt' => 136,
551 'kpr' => 137,
552 'kpt' => 137,
553 'ksp' => 138,
554 'kwd' => 139,
555 'kwt' => 139,
556 'latex' => 140,
557 'lha' => 141,
558 'lyx' => 142,
559 'lzh' => 143,
560 'lzx' => 144,
561 'maker' => 145,
562 'frm' => 145,
563 'frame' => 145,
564 'fm' => 145,
565 'book' => 145,
566 'fb' => 145,
567 'fbdoc' => 145,
568 'mif' => 146,
569 'wmd' => 147,
570 'wmz' => 148,
571 'dll' => 149,
572 'bat' => 149,
573 'exe' => 149,
574 'com' => 149,
575 'msi' => 150,
576 'nc' => 151,
577 'pac' => 152,
578 'nwc' => 153,
579 'o' => 154,
580 'oza' => 155,
581 'p7r' => 156,
582 'crl' => 157,
583 'pyo' => 158,
584 'pyc' => 158,
585 'qtl' => 159,
586 'rpm' => 160,
587 'shar' => 161,
588 'swf' => 162,
589 'swfl' => 162,
590 'sitx' => 163,
591 'sit' => 163,
592 'sv4cpio' => 164,
593 'sv4crc' => 165,
594 'tar' => 166,
595 'gf' => 168,
596 'pk' => 169,
597 'texi' => 170,
598 'texinfo' => 170,
599 'sik' => 171,
600 '~' => 171,
601 'bak' => 171,
602 '%' => 171,
603 'old' => 171,
604 't' => 172,
605 'roff' => 172,
606 'tr' => 172,
607 'man' => 173,
608 'me' => 174,
609 'ms' => 175,
610 'ustar' => 176,
611 'src' => 177,
612 'wz' => 178,
613 'crt' => 179,
614 'xcf' => 180,
615 'fig' => 181,
616 'xpi' => 182,
617 'xht' => 183,
618 'xhtml' => 183,
619 'xml' => 184,
620 'xsl' => 184,
621 'zip' => 185,
622 'au' => 186,
623 'snd' => 186,
624 'mid' => 187,
625 'midi' => 187,
626 'kar' => 187,
627 'mpega' => 188,
628 'mpga' => 188,
629 'm4a' => 188,
630 'mp3' => 188,
631 'mp2' => 188,
632 'ogg' => 189,
633 'oga' => 189,
634 'spx' => 189,
635 'sid' => 190,
636 'aif' => 191,
637 'aiff' => 191,
638 'aifc' => 191,
639 'gsm' => 192,
640 'm3u' => 193,
641 'wax' => 194,
642 'wma' => 195,
643 'rm' => 196,
644 'ram' => 196,
645 'ra' => 197,
646 'pls' => 198,
647 'sd2' => 199,
648 'wav' => 200,
649 'alc' => 201,
650 'cac' => 202,
651 'cache' => 202,
652 'csf' => 203,
653 'cascii' => 204,
654 'cbin' => 204,
655 'ctab' => 204,
656 'cdx' => 205,
657 'cer' => 206,
658 'c3d' => 207,
659 'chm' => 208,
660 'cif' => 209,
661 'cmdf' => 210,
662 'cml' => 211,
663 'cpa' => 212,
664 'bsd' => 213,
665 'csml' => 214,
666 'csm' => 214,
667 'ctx' => 215,
668 'cxf' => 216,
669 'cef' => 216,
670 'emb' => 217,
671 'embl' => 217,
672 'spc' => 218,
673 'gam' => 219,
674 'inp' => 219,
675 'gamin' => 219,
676 'fchk' => 220,
677 'fch' => 220,
678 'cub' => 221,
679 'gau' => 222,
680 'gjf' => 222,
681 'gjc' => 222,
682 'gal' => 223,
683 'gcg' => 224,
684 'gen' => 225,
685 'hin' => 226,
686 'istr' => 227,
687 'ist' => 227,
688 'dx' => 228,
689 'jdx' => 228,
690 'kin' => 229,
691 'mcm' => 230,
692 'mmd' => 231,
693 'mmod' => 231,
694 'mol' => 232,
695 'rd' => 233,
696 'rxn' => 234,
697 'sdf' => 235,
698 'sd' => 235,
699 'tgf' => 236,
700 'mcif' => 237,
701 'mol2' => 238,
702 'b' => 239,
703 'gpt' => 240,
704 'mopcrt' => 241,
705 'zmt' => 241,
706 'mpc' => 241,
707 'dat' => 241,
708 'mop' => 241,
709 'moo' => 242,
710 'mvb' => 243,
711 'prt' => 244,
712 'aso' => 245,
713 'val' => 245,
714 'asn' => 246,
715 'ent' => 247,
716 'pdb' => 247,
717 'ros' => 248,
718 'sw' => 249,
719 'vms' => 250,
720 'vmd' => 251,
721 'xtel' => 252,
722 'xyz' => 253,
723 'gif' => 254,
724 'ief' => 255,
725 'jpeg' => 256,
726 'jpe' => 256,
727 'jpg' => 256,
728 'pcx' => 257,
729 'png' => 258,
730 'svgz' => 259,
731 'svg' => 259,
732 'tif' => 260,
733 'tiff' => 260,
734 'djvu' => 261,
735 'djv' => 261,
736 'ico' => 262,
737 'wbmp' => 263,
738 'ras' => 264,
739 'cdr' => 265,
740 'pat' => 266,
741 'cdt' => 267,
742 'cpt' => 268,
743 'art' => 269,
744 'jng' => 270,
745 'bmp' => 271,
746 'psd' => 272,
747 'pnm' => 273,
748 'pbm' => 274,
749 'pgm' => 275,
750 'ppm' => 276,
751 'rgb' => 277,
752 'xbm' => 278,
753 'xpm' => 279,
754 'xwd' => 280,
755 'eml' => 281,
756 'igs' => 282,
757 'iges' => 282,
758 'silo' => 283,
759 'msh' => 283,
760 'mesh' => 283,
761 'icz' => 285,
762 'ics' => 285,
763 'css' => 286,
764 'csv' => 287,
765 '323' => 288,
766 'html' => 289,
767 'htm' => 289,
768 'shtml' => 289,
769 'uls' => 290,
770 'mml' => 291,
771 'txt' => 292,
772 'pot' => 292,
773 'text' => 292,
774 'asc' => 292,
775 'rtx' => 293,
776 'wsc' => 294,
777 'sct' => 294,
778 'tsv' => 295,
779 'ts' => 296,
780 'tm' => 296,
781 'jad' => 297,
782 'wml' => 298,
783 'wmls' => 299,
784 'bib' => 300,
785 'boo' => 301,
786 'hpp' => 302,
787 'hh' => 302,
788 'h++' => 302,
789 'hxx' => 302,
790 'cxx' => 303,
791 'cc' => 303,
792 'cpp' => 303,
793 'c++' => 303,
794 'h' => 304,
795 'htc' => 305,
796 'csh' => 306,
797 'c' => 307,
798 'patch' => 308,
799 'diff' => 308,
800 'd' => 309,
801 'hs' => 310,
802 'java' => 311,
803 'lhs' => 312,
804 'moc' => 313,
805 'pas' => 314,
806 'p' => 314,
807 'gcd' => 315,
808 'pm' => 316,
809 'pl' => 316,
810 'py' => 317,
811 'etx' => 318,
812 'sh' => 319,
813 'tk' => 320,
814 'tcl' => 320,
815 'cls' => 321,
816 'ltx' => 321,
817 'sty' => 321,
818 'tex' => 321,
819 'vcs' => 322,
820 'vcf' => 323,
821 '3gp' => 324,
822 'dl' => 325,
823 'dif' => 326,
824 'dv' => 326,
825 'fli' => 327,
826 'gl' => 328,
827 'mp4' => 329,
828 'f4v' => 329,
829 'f4p' => 329,
830 'mpe' => 330,
831 'mpeg' => 330,
832 'mpg' => 330,
833 'ogv' => 331,
834 'qt' => 332,
835 'mov' => 332,
836 'mxu' => 333,
837 'lsf' => 334,
838 'lsx' => 334,
839 'mng' => 335,
840 'asx' => 336,
841 'asf' => 336,
842 'wm' => 337,
843 'wmv' => 338,
844 'wmx' => 339,
845 'wvx' => 340,
846 'avi' => 341,
847 'movie' => 342,
848 'ice' => 343,
849 'sisx' => 344,
850 'wrl' => 345,
851 'vrm' => 345,
852 'vrml' => 345,
853 'f4a' => 346,
854 'f4b' => 346,
855 'flv' => 347,
856 'm4v' => 348,
857 ),
858 );
859 }
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
file_mimetype_mapping
file_mimetype_mapping()
Definition: file.mimetypes.inc:18
file_default_mimetype_mapping
file_default_mimetype_mapping()
Definition: file.mimetypes.inc:36
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/simpletest/files/php-2.php Source File

  • modules
  • simpletest
  • files
php-2.php
Go to the documentation of this file.
1 <?php
2 print 'SimpleTest PHP was executed!';
print
print
Definition: php-2.php:2
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/openid/openid.module Source File

  • modules
  • openid
openid.module
Go to the documentation of this file.
1 <?php
2
11 function openid_menu() {
12 $items['openid/authenticate'] = array(
13 'title' => 'OpenID Login',
14 'page callback' => 'openid_authentication_page',
15 'access callback' => 'user_is_anonymous',
16 'type' => MENU_CALLBACK,
17 'file' => 'openid.pages.inc',
18 );
19 $items['user/%user/openid'] = array(
20 'title' => 'OpenID identities',
21 'page callback' => 'openid_user_identities',
22 'page arguments' => array(1),
23 'access callback' => 'user_edit_access',
24 'access arguments' => array(1),
25 'type' => MENU_LOCAL_TASK,
26 'file' => 'openid.pages.inc',
27 );
28 $items['user/%user/openid/delete'] = array(
29 'title' => 'Delete OpenID',
30 'page callback' => 'drupal_get_form',
31 'page arguments' => array('openid_user_delete_form', 1),
32 'access callback' => 'user_edit_access',
33 'access arguments' => array(1),
34 'file' => 'openid.pages.inc',
35 );
36 return $items;
37 }
38
42 function openid_menu_site_status_alter(&$menu_site_status, $path) {
43 // Allow access to openid/authenticate even if site is in offline mode.
44 if ($menu_site_status == MENU_SITE_OFFLINE && user_is_anonymous() && $path == 'openid/authenticate') {
45 $menu_site_status = MENU_SITE_ONLINE;
46 }
47 }
48
52 function openid_admin_paths() {
53 $paths = array(
54 'user/*/openid' => TRUE,
55 'user/*/openid/delete' => TRUE,
56 );
57 return $paths;
58 }
59
63 function openid_help($path, $arg) {
64 switch ($path) {
65 case 'user/%/openid':
66 $output = '<p>' . t('This site supports <a href="@openid-net">OpenID</a>, a secure way to log in to many websites using a single username and password. OpenID can reduce the necessity of managing many usernames and passwords for many websites.', array('@openid-net' => 'http://openid.net')) . '</p>';
67 $output .= '<p>' . t('To use OpenID you must first establish an identity on a public or private OpenID server. If you do not have an OpenID and would like one, look into one of the <a href="@openid-providers">free public providers</a>. You can find out more about OpenID at <a href="@openid-net">this website</a>.', array('@openid-providers' => 'http://openid.net/get/', '@openid-net' => 'http://openid.net')) . '</p>';
68 $output .= '<p>' . t('If you already have an OpenID, enter the URL to your OpenID server below (e.g. myusername.openidprovider.com). Next time you log in, you will be able to use this URL instead of a regular username and password. You can have multiple OpenID servers if you like; just keep adding them here.') . '</p>';
69 return $output;
70 case 'admin/help#openid':
71 $output = '';
72 $output .= '<h3>' . t('About') . '</h3>';
73 $output .= '<p>' . t('The OpenID module allows users to log in using the OpenID single sign on service. <a href="@openid-net">OpenID</a> is a secure method for logging into many websites with a single username and password. It does not require special software, and it does not share passwords with any site to which it is associated, including the site being logged into. The main benefit to users is that they can have a single password that they can use on many websites. This means they can easily update their single password from a centralized location, rather than having to change dozens of passwords individually. For more information, see the online handbook entry for <a href="@handbook">OpenID module</a>.', array('@openid-net' => 'http://openid.net', '@handbook' => 'http://drupal.org/documentation/modules/openid')) . '</p>';
74 $output .= '<h3>' . t('Uses') . '</h3>';
75 $output .= '<dl>';
76 $output .= '<dt>' . t('Logging in with OpenID') . '</dt>';
77 $output .= '<dd>' . t("To log in using OpenID, a user must already have an OpenID account. Users can then create site accounts using their OpenID, assign one or more OpenIDs to an existing account, and log in using an OpenID. This lowers the barrier to registration, which helps increase the user base, and offers convenience and security to the users. Because OpenID cannot guarantee a user is legitimate, email verification is still necessary. When logging in, users are presented with the option of entering their OpenID URL, which will look like <em>myusername.openidprovider.com</em>. The site then communicates with the OpenID server, asking it to verify the identity of the user. If the user is logged into their OpenID server, the server communicates back to your site, verifying the user. If they are not logged in, the OpenID server will ask the user for their password. At no point does the site being logged into record the user's OpenID password.") . '</dd>';
78 $output .= '</dl>';
79 return $output;
80 }
81 }
82
86 function openid_user_insert(&$edit, $account, $category) {
87 if (!empty($edit['openid_claimed_id'])) {
88 // The user has registered after trying to log in via OpenID.
89 if (variable_get('user_email_verification', TRUE)) {
90 drupal_set_message(t('Once you have verified your e-mail address, you may log in via OpenID.'));
91 }
92 user_set_authmaps($account, array('authname_openid' => $edit['openid_claimed_id']));
93 unset($_SESSION['openid']);
94 unset($edit['openid_claimed_id']);
95 }
96 }
97
103 function openid_user_login(&$edit, $account) {
104 if (isset($_SESSION['openid'])) {
105 // The user has logged in via OpenID.
106 user_cookie_save(array_intersect_key($_SESSION['openid']['user_login_values'], array_flip(array('openid_identifier'))));
107 unset($_SESSION['openid']);
108 }
109 }
110
116 function openid_user_logout($account) {
117 if (isset($_COOKIE['Drupal_visitor_openid_identifier'])) {
118 user_cookie_delete('openid_identifier');
119 }
120 }
121
125 function openid_form_user_login_block_alter(&$form, &$form_state) {
126 _openid_user_login_form_alter($form, $form_state);
127 }
128
132 function openid_form_user_login_alter(&$form, &$form_state) {
133 _openid_user_login_form_alter($form, $form_state);
134 }
135
136 function _openid_user_login_form_alter(&$form, &$form_state) {
137 $form['#attached']['css'][] = drupal_get_path('module', 'openid') . '/openid.css';
138 $form['#attached']['js'][] = drupal_get_path('module', 'openid') . '/openid.js';
139 $form['#attached']['library'][] = array('system', 'jquery.cookie');
140 if (!empty($form_state['input']['openid_identifier'])) {
141 $form['name']['#required'] = FALSE;
142 $form['pass']['#required'] = FALSE;
143 unset($form['#submit']);
144 $form['#validate'] = array('openid_login_validate');
145 }
146
147 $items = array();
148 $items[] = array(
149 'data' => l(t('Log in using OpenID'), '#openid-login', array('external' => TRUE)),
150 'class' => array('openid-link'),
151 );
152 $items[] = array(
153 'data' => l(t('Cancel OpenID login'), '#', array('external' => TRUE)),
154 'class' => array('user-link'),
155 );
156
157 $form['openid_links'] = array(
158 '#theme' => 'item_list',
159 '#items' => $items,
160 '#attributes' => array('class' => array('openid-links')),
161 '#weight' => 1,
162 );
163
164 $form['links']['#weight'] = 2;
165
166 $form['openid_identifier'] = array(
167 '#type' => 'textfield',
168 '#title' => t('Log in using OpenID'),
169 '#size' => $form['name']['#size'],
170 '#maxlength' => 255,
171 '#weight' => -1,
172 '#description' => l(t('What is OpenID?'), 'http://openid.net/', array('external' => TRUE)),
173 );
174 $form['openid.return_to'] = array('#type' => 'hidden', '#value' => url('openid/authenticate', array('absolute' => TRUE, 'query' => user_login_destination())));
175 }
176
182 function openid_form_user_register_form_alter(&$form, &$form_state) {
183 if (isset($_SESSION['openid']['response'])) {
184 module_load_include('inc', 'openid');
185
186 $response = $_SESSION['openid']['response'];
187
188 // Extract Simple Registration keys from the response. We only include
189 // signed keys as required by OpenID Simple Registration Extension 1.0,
190 // section 4.
191 $sreg_values = openid_extract_namespace($response, OPENID_NS_SREG, 'sreg', TRUE);
192 // Extract Attribute Exchanges keys from the response. We only include
193 // signed keys. This is not required by the specification, but it is
194 // recommended by Google, see
195 // http://googlecode.blogspot.com/2011/05/security-advisory-to-websites-using.html
196 $ax_values = openid_extract_namespace($response, OPENID_NS_AX, 'ax', TRUE);
197
198 if (!empty($sreg_values['nickname'])) {
199 // Use the nickname returned by Simple Registration if available.
200 $form['account']['name']['#default_value'] = $sreg_values['nickname'];
201 }
202 elseif ($ax_name_values = openid_extract_ax_values($ax_values, array('http://axschema.org/namePerson/friendly', 'http://schema.openid.net/namePerson/friendly'))) {
203 // Else, use the first nickname returned by AX if available.
204 $form['account']['name']['#default_value'] = current($ax_name_values);
205 }
206 else {
207 $form['account']['name']['#default_value'] = '';
208 }
209
210 if (!empty($sreg_values['email'])) {
211 // Use the email returned by Simple Registration if available.
212 $form['account']['mail']['#default_value'] = $sreg_values['email'];
213 }
214 elseif ($ax_mail_values = openid_extract_ax_values($ax_values, array('http://axschema.org/contact/email', 'http://schema.openid.net/contact/email'))) {
215 // Else, use the first nickname returned by AX if available.
216 $form['account']['mail']['#default_value'] = current($ax_mail_values);
217 }
218
219 // If user_email_verification is off, hide the password field and just fill
220 // with random password to avoid confusion.
221 if (!variable_get('user_email_verification', TRUE)) {
222 $form['account']['pass']['#type'] = 'hidden';
223 $form['account']['pass']['#value'] = user_password();
224 }
225
226 $form['openid_claimed_id'] = array(
227 '#type' => 'value',
228 '#default_value' => $response['openid.claimed_id'],
229 );
230 $form['openid_display'] = array(
231 '#type' => 'item',
232 '#title' => t('Your OpenID'),
233 '#description' => t('This OpenID will be attached to your account after registration.'),
234 '#markup' => check_plain($response['openid.claimed_id']),
235 );
236 }
237 }
238
242 function openid_login_validate($form, &$form_state) {
243 $return_to = $form_state['values']['openid.return_to'];
244 if (empty($return_to)) {
245 $return_to = url('', array('absolute' => TRUE));
246 }
247
248 openid_begin($form_state['values']['openid_identifier'], $return_to, $form_state['values']);
249 }
250
261 function openid_begin($claimed_id, $return_to = '', $form_values = array()) {
262 module_load_include('inc', 'openid');
263
264 $service = NULL;
265 $claimed_id = openid_normalize($claimed_id);
266 $discovery = openid_discovery($claimed_id);
267
268 if (!empty($discovery['services'])) {
269 $service = _openid_select_service($discovery['services']);
270 }
271
272 // Quit if the discovery result was empty or if we can't select any service.
273 if (!$discovery || !$service) {
274 form_set_error('openid_identifier', t('Sorry, that is not a valid OpenID. Ensure you have spelled your ID correctly.'));
275 return;
276 }
277
278 // Set claimed id from discovery.
279 if (!empty($discovery['claimed_id'])) {
280 $claimed_id = $discovery['claimed_id'];
281 }
282
283 // Store discovered information in the users' session so we don't have to rediscover.
284 $_SESSION['openid']['service'] = $service;
285 // Store the claimed id
286 $_SESSION['openid']['claimed_id'] = $claimed_id;
287 // Store the login form values so we can pass them to
288 // user_exteral_login later.
289 $_SESSION['openid']['user_login_values'] = $form_values;
290
291 // If a supported math library is present, then create an association.
292 $assoc_handle = '';
293 if (_openid_get_math_library()) {
294 $assoc_handle = openid_association($service['uri']);
295 }
296
297 if (in_array('http://specs.openid.net/auth/2.0/server', $service['types'])) {
298 // User entered an OP Identifier.
299 $claimed_id = $identity = 'http://specs.openid.net/auth/2.0/identifier_select';
300 }
301 else {
302 // Use Claimed ID and/or OP-Local Identifier from service description, if
303 // available.
304 if (!empty($service['claimed_id'])) {
305 $claimed_id = $service['claimed_id'];
306 }
307 $identity = !empty($service['identity']) ? $service['identity'] : $claimed_id;
308 }
309 $request = openid_authentication_request($claimed_id, $identity, $return_to, $assoc_handle, $service);
310
311 if ($service['version'] == 2) {
312 openid_redirect($service['uri'], $request);
313 }
314 else {
315 openid_redirect_http($service['uri'], $request);
316 }
317 }
318
328 function openid_complete($response = array()) {
329 module_load_include('inc', 'openid');
330
331 if (count($response) == 0) {
332 $response = _openid_response();
333 }
334
335 // Default to failed response
336 $response['status'] = 'failed';
337 if (isset($_SESSION['openid']['service']['uri']) && isset($_SESSION['openid']['claimed_id'])) {
338 $service = $_SESSION['openid']['service'];
339 $claimed_id = $_SESSION['openid']['claimed_id'];
340 unset($_SESSION['openid']['service']);
341 unset($_SESSION['openid']['claimed_id']);
342 if (isset($response['openid.mode'])) {
343 if ($response['openid.mode'] == 'cancel') {
344 $response['status'] = 'cancel';
345 }
346 else {
347 if (openid_verify_assertion($service, $response)) {
348 // OpenID Authentication, section 7.3.2.3 and Appendix A.5:
349 // The CanonicalID specified in the XRDS document must be used as the
350 // account key. We rely on the XRI proxy resolver to verify that the
351 // provider is authorized to respond on behalf of the specified
352 // identifer (required per Extensible Resource Identifier (XRI)
353 // (XRI) Resolution Version 2.0, section 14.3):
354 if (!empty($service['claimed_id'])) {
355 $response['openid.claimed_id'] = $service['claimed_id'];
356 }
357 elseif ($service['version'] == 2) {
358 // Returned Claimed Identifier could contain unique fragment
359 // identifier to allow identifier recycling so we need to preserve
360 // it in the response.
361 $response_claimed_id = openid_normalize($response['openid.claimed_id']);
362
363 // OpenID Authentication, section 11.2:
364 // If the returned Claimed Identifier is different from the one sent
365 // to the OpenID Provider, we need to do discovery on the returned
366 // identififer to make sure that the provider is authorized to
367 // respond on behalf of this.
368 if ($response_claimed_id != $claimed_id) {
369 $discovery = openid_discovery($response['openid.claimed_id']);
370 if ($discovery && !empty($discovery['services'])) {
371 $uris = array();
372 foreach ($discovery['services'] as $discovered_service) {
373 if (in_array('http://specs.openid.net/auth/2.0/server', $discovered_service['types']) || in_array('http://specs.openid.net/auth/2.0/signon', $discovered_service['types'])) {
374 $uris[] = $discovered_service['uri'];
375 }
376 }
377 }
378 if (!in_array($service['uri'], $uris)) {
379 return $response;
380 }
381 }
382 }
383 else {
384 $response['openid.claimed_id'] = $claimed_id;
385 }
386 $response['status'] = 'success';
387 }
388 }
389 }
390 }
391 return $response;
392 }
393
413 function openid_discovery($claimed_id) {
414 module_load_include('inc', 'openid');
415
416 $methods = module_invoke_all('openid_discovery_method_info');
417 drupal_alter('openid_discovery_method_info', $methods);
418
419 // Execute each method in turn and return first successful discovery.
420 foreach ($methods as $method) {
421 $discovery = $method($claimed_id);
422 if (!empty($discovery)) {
423 return $discovery;
424 }
425 }
426
427 return FALSE;
428 }
429
435 function openid_openid_discovery_method_info() {
436 // The discovery process will stop as soon as one discovery method succeed.
437 // We first attempt to discover XRI-based identifiers, then standard XRDS
438 // identifiers via Yadis and HTML-based discovery, conforming to the OpenID 2.0
439 // specification.
440 return array(
441 'xri' => '_openid_xri_discovery',
442 'xrds' => '_openid_xrds_discovery',
443 );
444 }
445
457 function _openid_xri_discovery($claimed_id) {
458 if (_openid_is_xri($claimed_id)) {
459 // Resolve XRI using a proxy resolver (Extensible Resource Identifier (XRI)
460 // Resolution Version 2.0, section 11.2 and 14.3).
461 $xrds_url = variable_get('xri_proxy_resolver', 'http://xri.net/') . rawurlencode($claimed_id) . '?_xrd_r=application/xrds+xml';
462 $discovery = _openid_xrds_discovery($xrds_url);
463 if (!empty($discovery['services']) && is_array($discovery['services'])) {
464 foreach ($discovery['services'] as $i => &$service) {
465 $status = $service['xrd']->children(OPENID_NS_XRD)->Status;
466 if ($status && $status->attributes()->cid == 'verified') {
467 $service['claimed_id'] = openid_normalize((string)$service['xrd']->children(OPENID_NS_XRD)->CanonicalID);
468 }
469 else {
470 // Ignore service if the Canonical ID could not be verified.
471 unset($discovery['services'][$i]);
472 }
473 }
474 if (!empty($discovery['services'])) {
475 return $discovery;
476 }
477 }
478 }
479 }
480
492 function _openid_xrds_discovery($claimed_id) {
493 $services = array();
494
495 $xrds_url = $claimed_id;
496 $scheme = @parse_url($xrds_url, PHP_URL_SCHEME);
497 if ($scheme == 'http' || $scheme == 'https') {
498 // For regular URLs, try Yadis resolution first, then HTML-based discovery
499 $headers = array('Accept' => 'application/xrds+xml');
500 $result = drupal_http_request($xrds_url, array('headers' => $headers));
501
502 // Check for HTTP error and make sure, that we reach the target. If the
503 // maximum allowed redirects are exhausted, final destination URL isn't
504 // reached, but drupal_http_request() doesn't return any error.
505 // @todo Remove the check for 200 HTTP result code after the following issue
506 // will be fixed: http://drupal.org/node/1096890.
507 if (!isset($result->error) && $result->code == 200) {
508
509 // Replace the user-entered claimed_id if we received a redirect.
510 if (!empty($result->redirect_url)) {
511 $claimed_id = openid_normalize($result->redirect_url);
512 }
513
514 if (isset($result->headers['content-type']) && preg_match("/application\/xrds\+xml/", $result->headers['content-type'])) {
515 // Parse XML document to find URL
516 $services = _openid_xrds_parse($result->data);
517 }
518 else {
519 $xrds_url = NULL;
520 if (isset($result->headers['x-xrds-location'])) {
521 $xrds_url = $result->headers['x-xrds-location'];
522 }
523 else {
524 // Look for meta http-equiv link in HTML head
525 $xrds_url = _openid_meta_httpequiv('X-XRDS-Location', $result->data);
526 }
527 if (!empty($xrds_url)) {
528 $headers = array('Accept' => 'application/xrds+xml');
529 $xrds_result = drupal_http_request($xrds_url, array('headers' => $headers));
530 if (!isset($xrds_result->error)) {
531 $services = _openid_xrds_parse($xrds_result->data);
532 }
533 }
534 }
535
536 // Check for HTML delegation
537 if (count($services) == 0) {
538 // Look for 2.0 links
539 $uri = _openid_link_href('openid2.provider', $result->data);
540 $identity = _openid_link_href('openid2.local_id', $result->data);
541 $type = 'http://specs.openid.net/auth/2.0/signon';
542
543 // 1.x links
544 if (empty($uri)) {
545 $uri = _openid_link_href('openid.server', $result->data);
546 $identity = _openid_link_href('openid.delegate', $result->data);
547 $type = 'http://openid.net/signon/1.1';
548 }
549 if (!empty($uri)) {
550 $services[] = array(
551 'uri' => $uri,
552 'identity' => $identity,
553 'types' => array($type),
554 );
555 }
556 }
557 }
558 }
559
560 if (!empty($services)) {
561 return array(
562 'services' => $services,
563 'claimed_id' => $claimed_id,
564 );
565 }
566 }
567
573 function openid_openid_normalization_method_info() {
574 // OpenID Authentication 2.0, section 7.2:
575 // If the User-supplied Identifier looks like an XRI, treat it as such;
576 // otherwise treat it as an HTTP URL.
577 return array(
578 'xri' => '_openid_xri_normalize',
579 'url' => '_openid_url_normalize',
580 );
581 }
582
590 function openid_association($op_endpoint) {
591 module_load_include('inc', 'openid');
592
593 // Remove Old Associations:
594 db_delete('openid_association')
595 ->where('created + expires_in < :request_time', array(':request_time' => REQUEST_TIME))
596 ->execute();
597
598 // Check to see if we have an association for this IdP already
599 $assoc_handle = db_query("SELECT assoc_handle FROM {openid_association} WHERE idp_endpoint_uri = :endpoint", array(':endpoint' => $op_endpoint))->fetchField();
600 if (empty($assoc_handle)) {
601 $mod = OPENID_DH_DEFAULT_MOD;
602 $gen = OPENID_DH_DEFAULT_GEN;
603 $r = _openid_dh_rand($mod);
604 $private = _openid_math_add($r, 1);
605 $public = _openid_math_powmod($gen, $private, $mod);
606
607 // If there is no existing association, then request one
608 $assoc_request = openid_association_request($public);
609 $assoc_message = _openid_encode_message(_openid_create_message($assoc_request));
610 $assoc_options = array(
611 'headers' => array('Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8'),
612 'method' => 'POST',
613 'data' => $assoc_message,
614 );
615 $assoc_result = drupal_http_request($op_endpoint, $assoc_options);
616 if (isset($assoc_result->error)) {
617 return FALSE;
618 }
619
620 $assoc_response = _openid_parse_message($assoc_result->data);
621 if (isset($assoc_response['mode']) && $assoc_response['mode'] == 'error') {
622 return FALSE;
623 }
624
625 if ($assoc_response['session_type'] == 'DH-SHA1') {
626 $spub = _openid_dh_base64_to_long($assoc_response['dh_server_public']);
627 $enc_mac_key = base64_decode($assoc_response['enc_mac_key']);
628 $shared = _openid_math_powmod($spub, $private, $mod);
629 $assoc_response['mac_key'] = base64_encode(_openid_dh_xorsecret($shared, $enc_mac_key));
630 }
631 db_insert('openid_association')
632 ->fields(array(
633 'idp_endpoint_uri' => $op_endpoint,
634 'session_type' => $assoc_response['session_type'],
635 'assoc_handle' => $assoc_response['assoc_handle'],
636 'assoc_type' => $assoc_response['assoc_type'],
637 'expires_in' => $assoc_response['expires_in'],
638 'mac_key' => $assoc_response['mac_key'],
639 'created' => REQUEST_TIME,
640 ))
641 ->execute();
642 $assoc_handle = $assoc_response['assoc_handle'];
643 }
644 return $assoc_handle;
645 }
646
652 function openid_authentication($response) {
653 $identity = $response['openid.claimed_id'];
654 $account = user_external_load($identity);
655
656 // Tries to load user account if user_external_load fails due to possibly
657 // incompletely stored OpenID identifier in the authmap.
658 if (!isset($account->uid) && variable_get('openid_less_obtrusive_transition', FALSE)) {
659 module_load_include('inc', 'openid');
660 $account = _openid_invalid_openid_transition($identity, $response);
661 }
662
663 if (isset($account->uid)) {
664 if (!variable_get('user_email_verification', TRUE) || $account->login) {
665 // Check if user is blocked.
666 $state['values']['name'] = $account->name;
667 user_login_name_validate(array(), $state);
668 if (!form_get_errors()) {
669 // Load global $user and perform final login tasks.
670 $form_state['uid'] = $account->uid;
671 user_login_submit(array(), $form_state);
672 // Let other modules act on OpenID login
673 module_invoke_all('openid_response', $response, $account);
674 }
675 }
676 else {
677 drupal_set_message(t('You must validate your email address for this account before logging in via OpenID.'));
678 }
679 }
680 elseif (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
681 // Register new user.
682
683 // Save response for use in openid_form_user_register_form_alter().
684 $_SESSION['openid']['response'] = $response;
685
686 $form_state['values'] = array();
687 $form_state['values']['op'] = t('Create new account');
688 drupal_form_submit('user_register_form', $form_state);
689
690 if (!empty($form_state['user'])) {
691 module_invoke_all('openid_response', $response, $form_state['user']);
692 drupal_goto();
693 }
694
695 $messages = drupal_get_messages('error');
696 if (empty($form_state['values']['name']) || empty($form_state['values']['mail'])) {
697 // If the OpenID provider did not provide both a user name and an email
698 // address, ask the user to complete the registration manually instead of
699 // showing the error messages about the missing values generated by FAPI.
700 drupal_set_message(t('Complete the registration by filling out the form below. If you already have an account, you can <a href="@login">log in</a> now and add your OpenID under "My account".', array('@login' => url('user/login'))), 'warning');
701 }
702 else {
703 drupal_set_message(t('Account registration using the information provided by your OpenID provider failed due to the reasons listed below. Complete the registration by filling out the form below. If you already have an account, you can <a href="@login">log in</a> now and add your OpenID under "My account".', array('@login' => url('user/login'))), 'warning');
704 // Append form validation errors below the above warning.
705 foreach ($messages['error'] as $message) {
706 drupal_set_message($message, 'error');
707 }
708 }
709
710 // We were unable to register a valid new user. Redirect to the normal
711 // registration page and prefill with the values we received.
712 $destination = drupal_get_destination();
713 unset($_GET['destination']);
714 drupal_goto('user/register', array('query' => $destination));
715 }
716 else {
717 drupal_set_message(t('Only site administrators can create new user accounts.'), 'error');
718 }
719 drupal_goto();
720 }
721
722 function openid_association_request($public) {
723 module_load_include('inc', 'openid');
724
725 $request = array(
726 'openid.ns' => OPENID_NS_2_0,
727 'openid.mode' => 'associate',
728 'openid.session_type' => 'DH-SHA1',
729 'openid.assoc_type' => 'HMAC-SHA1'
730 );
731
732 if ($request['openid.session_type'] == 'DH-SHA1' || $request['openid.session_type'] == 'DH-SHA256') {
733 $cpub = _openid_dh_long_to_base64($public);
734 $request['openid.dh_consumer_public'] = $cpub;
735 }
736
737 return $request;
738 }
739
740 function openid_authentication_request($claimed_id, $identity, $return_to = '', $assoc_handle = '', $service) {
741 global $base_url;
742
743 module_load_include('inc', 'openid');
744
745 $request = array(
746 'openid.mode' => 'checkid_setup',
747 'openid.identity' => $identity,
748 'openid.assoc_handle' => $assoc_handle,
749 'openid.return_to' => $return_to,
750 );
751
752 if ($service['version'] == 2) {
753 $request['openid.ns'] = OPENID_NS_2_0;
754 $request['openid.claimed_id'] = $claimed_id;
755 $request['openid.realm'] = $base_url .'/';
756 }
757 else {
758 $request['openid.trust_root'] = $base_url .'/';
759 }
760
761 // Always request Simple Registration. The specification doesn't mandate
762 // that the Endpoint advertise OPENID_NS_SREG in the service description.
763 $request['openid.ns.sreg'] = OPENID_NS_SREG;
764 $request['openid.sreg.required'] = 'nickname,email';
765
766 // Request Attribute Exchange, if available.
767 // We only request the minimum attributes we need here, contributed modules
768 // can alter the request to add more attribute, and map them to profile fields.
769 if (in_array(OPENID_NS_AX, $service['types'])) {
770 $request['openid.ns.ax'] = OPENID_NS_AX;
771 $request['openid.ax.mode'] = 'fetch_request';
772 $request['openid.ax.required'] = 'mail_ao,name_ao,mail_son,name_son';
773
774 // Implementors disagree on which URIs to use, even for simple
775 // attributes like name and email (*sigh*). We ask for both axschema.org
776 // attributes (which are supposed to be newer), and schema.openid.net ones
777 // (which are supposed to be legacy).
778
779 // Attributes as defined by axschema.org.
780 $request['openid.ax.type.mail_ao'] = 'http://axschema.org/contact/email';
781 $request['openid.ax.type.name_ao'] = 'http://axschema.org/namePerson/friendly';
782
783 // Attributes as defined by schema.openid.net.
784 $request['openid.ax.type.mail_son'] = 'http://schema.openid.net/contact/email';
785 $request['openid.ax.type.name_son'] = 'http://schema.openid.net/namePerson/friendly';
786 }
787
788 $request = array_merge($request, module_invoke_all('openid', 'request', $request));
789
790 // module_invoke_all() uses array_merge_recursive() which might return nested
791 // arrays if two or more modules alter a given parameter, resulting in an
792 // invalid request format. To ensure this doesn't happen, we flatten the returned
793 // value by taking the last entry in the array if an array is returned.
794 $flattened_request = array();
795 foreach ($request as $key => $value) {
796 if (is_array($value)) {
797 $flattened_request[$key] = end($value);
798 }
799 else {
800 $flattened_request[$key] = $value;
801 }
802 }
803
804 return $flattened_request;
805 }
806
818 function openid_verify_assertion($service, $response) {
819 module_load_include('inc', 'openid');
820
821 // http://openid.net/specs/openid-authentication-2_0.html#rfc.section.11.3
822 // Check the Nonce to protect against replay attacks.
823 if (!openid_verify_assertion_nonce($service, $response)) {
824 return FALSE;
825 }
826
827 // http://openid.net/specs/openid-authentication-2_0.html#rfc.section.11.1
828 // Verifying the return URL.
829 if (!openid_verify_assertion_return_url($service, $response)) {
830 return FALSE;
831 }
832
833 // http://openid.net/specs/openid-authentication-2_0.html#rfc.section.11.4
834 // Verify the signatures.
835 $valid = FALSE;
836 $association = FALSE;
837
838 // If the OP returned a openid.invalidate_handle, we have to proceed with
839 // direct verification: ignore the openid.assoc_handle, even if present.
840 // See http://openid.net/specs/openid-authentication-2_0.html#rfc.section.11.4.1
841 if (!empty($response['openid.assoc_handle']) && empty($response['openid.invalidate_handle'])) {
842 $association = db_query("SELECT * FROM {openid_association} WHERE idp_endpoint_uri = :endpoint AND assoc_handle = :assoc_handle", array(':endpoint' => $service['uri'], ':assoc_handle' => $response['openid.assoc_handle']))->fetchObject();
843 }
844
845 if ($association && isset($association->session_type)) {
846 // http://openid.net/specs/openid-authentication-2_0.html#rfc.section.11.4.2
847 // Verification using an association.
848 $valid = openid_verify_assertion_signature($service, $association, $response);
849 }
850 else {
851 // http://openid.net/specs/openid-authentication-2_0.html#rfc.section.11.4.2
852 // Direct verification.
853 // The verification requests contain all the fields from the response,
854 // except openid.mode.
855 $request = $response;
856 $request['openid.mode'] = 'check_authentication';
857 $message = _openid_create_message($request);
858 $options = array(
859 'headers' => array('Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8'),
860 'method' => 'POST',
861 'data' => _openid_encode_message($message),
862 );
863 $result = drupal_http_request($service['uri'], $options);
864 if (!isset($result->error)) {
865 $response = _openid_parse_message($result->data);
866
867 if (strtolower(trim($response['is_valid'])) == 'true') {
868 $valid = TRUE;
869 if (!empty($response['invalidate_handle'])) {
870 // This association handle has expired on the OP side, remove it from the
871 // database to avoid reusing it again on a subsequent authentication request.
872 // See http://openid.net/specs/openid-authentication-2_0.html#rfc.section.11.4.2.2
873 db_delete('openid_association')
874 ->condition('idp_endpoint_uri', $service['uri'])
875 ->condition('assoc_handle', $response['invalidate_handle'])
876 ->execute();
877 }
878 }
879 else {
880 $valid = FALSE;
881 }
882 }
883 }
884 return $valid;
885 }
886
887
902 function openid_verify_assertion_signature($service, $association, $response) {
903 if ($service['version'] == 2) {
904 // OpenID Authentication 2.0, section 10.1:
905 // These keys must always be signed.
906 $mandatory_keys = array('op_endpoint', 'return_to', 'response_nonce', 'assoc_handle');
907 if (isset($response['openid.claimed_id'])) {
908 // If present, these two keys must also be signed. According to the spec,
909 // they are either both present or both absent.
910 $mandatory_keys[] = 'claimed_id';
911 $mandatory_keys[] = 'identity';
912 }
913 }
914 else {
915 // OpenID Authentication 1.1. section 4.3.3.
916 $mandatory_keys = array('identity', 'return_to');
917 }
918
919 $keys_to_sign = explode(',', $response['openid.signed']);
920
921 if (count(array_diff($mandatory_keys, $keys_to_sign)) > 0) {
922 return FALSE;
923 }
924
925 return _openid_signature($association, $response, $keys_to_sign) === $response['openid.sig'];
926 }
927
939 function openid_verify_assertion_nonce($service, $response) {
940 if ($service['version'] != 2) {
941 return TRUE;
942 }
943
944 if (preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z/', $response['openid.response_nonce'], $matches)) {
945 list(, $year, $month, $day, $hour, $minutes, $seconds) = $matches;
946 $nonce_timestamp = gmmktime($hour, $minutes, $seconds, $month, $day, $year);
947 }
948 else {
949 watchdog('openid', 'Nonce from @endpoint rejected because it is not correctly formatted, nonce: @nonce.', array('@endpoint' => $service['uri'], '@nonce' => $response['openid.response_nonce']), WATCHDOG_WARNING);
950 return FALSE;
951 }
952
953 // A nonce with a timestamp to far in the past or future will already have
954 // been removed and cannot be checked for single use anymore.
955 $time = time();
956 $expiry = 900;
957 if ($nonce_timestamp <= $time - $expiry || $nonce_timestamp >= $time + $expiry) {
958 watchdog('openid', 'Nonce received from @endpoint is out of range (time difference: @intervals). Check possible clock skew.', array('@endpoint' => $service['uri'], '@interval' => $time - $nonce_timestamp), WATCHDOG_WARNING);
959 return FALSE;
960 }
961
962 // Record that this nonce was used.
963 db_insert('openid_nonce')
964 ->fields(array(
965 'idp_endpoint_uri' => $service['uri'],
966 'nonce' => $response['openid.response_nonce'],
967 'expires' => $nonce_timestamp + $expiry,
968 ))
969 ->execute();
970
971 // Count the number of times this nonce was used.
972 $count_used = db_query("SELECT COUNT(*) FROM {openid_nonce} WHERE nonce = :nonce AND idp_endpoint_uri = :idp_endpoint_uri", array(
973 ':nonce' => $response['openid.response_nonce'],
974 ':idp_endpoint_uri' => $service['uri'],
975 ))->fetchField();
976
977 if ($count_used == 1) {
978 return TRUE;
979 }
980 else {
981 watchdog('openid', 'Nonce replay attempt blocked from @ip, nonce: @nonce.', array('@ip' => ip_address(), '@nonce' => $response['openid.response_nonce']), WATCHDOG_CRITICAL);
982 return FALSE;
983 }
984 }
985
986
1002 function openid_verify_assertion_return_url($service, $response) {
1003 global $base_url;
1004
1005 $return_to_parts = parse_url($response['openid.return_to']);
1006
1007 $base_url_parts = parse_url($base_url);
1008 $current_parts = parse_url($base_url_parts['scheme'] .'://'. $base_url_parts['host'] . request_uri());
1009
1010 if ($return_to_parts['scheme'] != $current_parts['scheme'] || $return_to_parts['host'] != $current_parts['host'] || $return_to_parts['path'] != $current_parts['path']) {
1011 return FALSE;
1012 }
1013 // Verify that all query parameters in the openid.return_to URL have
1014 // the same value in the current URL. In addition, the current URL
1015 // contains a number of other parameters added by the OpenID Provider.
1016 parse_str(isset($return_to_parts['query']) ? $return_to_parts['query'] : '', $return_to_query_parameters);
1017 foreach ($return_to_query_parameters as $name => $value) {
1018 if (!isset($_GET[$name]) || $_GET[$name] != $value) {
1019 return FALSE;
1020 }
1021 }
1022 return TRUE;
1023 }
1024
1030 function openid_cron() {
1031 db_delete('openid_nonce')
1032 ->condition('expires', REQUEST_TIME, '<')
1033 ->execute();
1034 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
_openid_invalid_openid_transition
_openid_invalid_openid_transition($identity, $response)
Definition: openid.inc:837
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
MENU_SITE_ONLINE
const MENU_SITE_ONLINE
Definition: menu.inc:249
openid_form_user_login_block_alter
openid_form_user_login_block_alter(&$form, &$form_state)
Definition: openid.module:125
user_set_authmaps
user_set_authmaps($account, $authmaps)
Definition: user.module:2044
_openid_xri_discovery
_openid_xri_discovery($claimed_id)
Definition: openid.module:457
openid_user_login
openid_user_login(&$edit, $account)
Definition: openid.module:103
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
_openid_dh_long_to_base64
_openid_dh_long_to_base64($str)
Definition: openid.inc:468
l
l($text, $path, array $options=array())
Definition: common.inc:2432
_openid_dh_base64_to_long
_openid_dh_base64_to_long($str)
Definition: openid.inc:462
_openid_is_xri
_openid_is_xri($identifier)
Definition: openid.inc:257
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
OPENID_NS_XRD
const OPENID_NS_XRD
Definition: openid.inc:70
openid_user_logout
openid_user_logout($account)
Definition: openid.module:116
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
_openid_link_href
_openid_link_href($rel, $html)
Definition: openid.inc:399
openid_form_user_login_alter
openid_form_user_login_alter(&$form, &$form_state)
Definition: openid.module:132
openid_verify_assertion_return_url
openid_verify_assertion_return_url($service, $response)
Definition: openid.module:1002
_openid_user_login_form_alter
_openid_user_login_form_alter(&$form, &$form_state)
Definition: openid.module:136
openid_association_request
openid_association_request($public)
Definition: openid.module:722
openid_menu
openid_menu()
Definition: openid.module:11
OPENID_NS_SREG
const OPENID_NS_SREG
Definition: openid.inc:60
openid_discovery
openid_discovery($claimed_id)
Definition: openid.module:413
MENU_SITE_OFFLINE
const MENU_SITE_OFFLINE
Definition: menu.inc:244
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
openid_admin_paths
openid_admin_paths()
Definition: openid.module:52
_openid_math_powmod
_openid_math_powmod($x, $y, $z)
Definition: openid.inc:812
openid_user_insert
openid_user_insert(&$edit, $account, $category)
Definition: openid.module:86
openid_verify_assertion_nonce
openid_verify_assertion_nonce($service, $response)
Definition: openid.module:939
user_cookie_save
user_cookie_save(array $values)
Definition: user.module:3958
drupal_http_request
drupal_http_request($url, array $options=array())
Definition: common.inc:787
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
ip_address
ip_address()
Definition: bootstrap.inc:2890
openid_normalize
openid_normalize($identifier)
Definition: openid.inc:277
request_uri
request_uri()
Definition: bootstrap.inc:1609
_openid_parse_message
_openid_parse_message($message)
Definition: openid.inc:366
user_login_destination
user_login_destination()
Definition: user.module:3944
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
openid_login_validate
openid_login_validate($form, &$form_state)
Definition: openid.module:242
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
drupal_get_messages
drupal_get_messages($type=NULL, $clear_queue=TRUE)
Definition: bootstrap.inc:1820
openid_extract_namespace
openid_extract_namespace($response, $extension_namespace, $fallback_prefix=NULL, $only_signed=FALSE)
Definition: openid.inc:642
OPENID_DH_DEFAULT_GEN
const OPENID_DH_DEFAULT_GEN
Definition: openid.inc:25
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
_openid_xrds_discovery
_openid_xrds_discovery($claimed_id)
Definition: openid.module:492
openid_association
openid_association($op_endpoint)
Definition: openid.module:590
user_login_submit
user_login_submit($form, &$form_state)
Definition: user.module:2279
_openid_dh_xorsecret
_openid_dh_xorsecret($shared, $secret)
Definition: openid.inc:513
openid_openid_normalization_method_info
openid_openid_normalization_method_info()
Definition: openid.module:573
openid_extract_ax_values
openid_extract_ax_values($values, $uris)
Definition: openid.inc:692
_openid_get_math_library
_openid_get_math_library()
Definition: openid.inc:714
$value
print $value
Definition: user-profile-item.tpl.php:26
_openid_select_service
_openid_select_service(array $services)
Definition: openid.inc:210
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$messages
print $messages
Definition: page.tpl.php:121
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
OPENID_DH_DEFAULT_MOD
const OPENID_DH_DEFAULT_MOD
Definition: openid.inc:16
$output
$output
Definition: authorize.php:93
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
_openid_encode_message
_openid_encode_message($message)
Definition: openid.inc:344
_openid_meta_httpequiv
_openid_meta_httpequiv($equiv, $html)
Definition: openid.inc:412
user_password
user_password($length=10)
Definition: user.module:705
form_get_errors
form_get_errors()
Definition: form.inc:1634
WATCHDOG_CRITICAL
const WATCHDOG_CRITICAL
Definition: bootstrap.inc:88
openid_verify_assertion_signature
openid_verify_assertion_signature($service, $association, $response)
Definition: openid.module:902
openid_begin
openid_begin($claimed_id, $return_to= '', $form_values=array())
Definition: openid.module:261
openid_authentication
openid_authentication($response)
Definition: openid.module:652
openid_openid_discovery_method_info
openid_openid_discovery_method_info()
Definition: openid.module:435
_openid_create_message
_openid_create_message($data)
Definition: openid.inc:329
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
openid_menu_site_status_alter
openid_menu_site_status_alter(&$menu_site_status, $path)
Definition: openid.module:42
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
drupal_form_submit
drupal_form_submit($form_id, &$form_state)
Definition: form.inc:685
openid_redirect
openid_redirect($url, $message)
Definition: openid.inc:90
user_external_load
user_external_load($authname)
Definition: user.module:249
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
_openid_response
_openid_response($str=NULL)
Definition: openid.inc:567
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
user_login_name_validate
user_login_name_validate($form, &$form_state)
Definition: user.module:2124
openid_cron
openid_cron()
Definition: openid.module:1030
openid_redirect_http
openid_redirect_http($url, $message)
Definition: openid.inc:75
openid_help
openid_help($path, $arg)
Definition: openid.module:63
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
openid_authentication_request
openid_authentication_request($claimed_id, $identity, $return_to= '', $assoc_handle= '', $service)
Definition: openid.module:740
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
OPENID_NS_2_0
const OPENID_NS_2_0
Definition: openid.inc:40
_openid_signature
_openid_signature($association, $message_array, $keys_to_sign)
Definition: openid.inc:431
OPENID_NS_AX
const OPENID_NS_AX
Definition: openid.inc:65
user_cookie_delete
user_cookie_delete($cookie_name)
Definition: user.module:3971
_openid_dh_rand
_openid_dh_rand($stop)
Definition: openid.inc:524
USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL
const USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL
Definition: user.module:32
openid_complete
openid_complete($response=array())
Definition: openid.module:328
openid_form_user_register_form_alter
openid_form_user_register_form_alter(&$form, &$form_state)
Definition: openid.module:182
_openid_xrds_parse
_openid_xrds_parse($raw_xml)
Definition: openid.inc:139
user_is_anonymous
user_is_anonymous()
Definition: user.module:1533
openid_verify_assertion
openid_verify_assertion($service, $response)
Definition: openid.module:818
_openid_math_add
_openid_math_add($x, $y)
Definition: openid.inc:734
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator-feed-source.tpl.php Source File

  • modules
  • aggregator
aggregator-feed-source.tpl.php
Go to the documentation of this file.
1 <?php
2
23 ?>
24 <div class="feed-source">
25 <?php print $source_icon; ?>
26 <?php print $source_image; ?>
27 <div class="feed-description">
28 <?php print $source_description; ?>
29 </div>
30 <div class="feed-url">
31 <em><?php print t('URL:'); ?></em> <a href="<?php print $source_url; ?>"><?php print $source_url; ?></a>
32 </div>
33 <div class="feed-updated">
34 <em><?php print t('Updated:'); ?></em> <?php print $last_checked; ?>
35 </div>
36 </div>
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$source_url
print $source_url
Definition: aggregator-feed-source.tpl.php:31
$source_description
print $source_description
Definition: aggregator-feed-source.tpl.php:28
$source_image
print $source_image
Definition: aggregator-feed-source.tpl.php:26
$last_checked
print $last_checked
Definition: aggregator-feed-source.tpl.php:34
$source_icon
print $source_icon
Definition: aggregator-feed-source.tpl.php:25
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalPublicStreamWrapper Member List

This is the complete list of members for DrupalPublicStreamWrapper, including all inherited members.

$context | DrupalLocalStreamWrapper |
$handle | DrupalLocalStreamWrapper |
$uri | DrupalLocalStreamWrapper | protected
chmod($mode) | DrupalLocalStreamWrapper |
dir_closedir() | DrupalLocalStreamWrapper |
dir_opendir($uri, $options) | DrupalLocalStreamWrapper |
dir_readdir() | DrupalLocalStreamWrapper |
dir_rewinddir() | DrupalLocalStreamWrapper |
dirname($uri=NULL) | DrupalLocalStreamWrapper |
getDirectoryPath() | DrupalPublicStreamWrapper |
getExternalUrl() | DrupalPublicStreamWrapper |
getLocalPath($uri=NULL) | DrupalLocalStreamWrapper | protected
getMimeType($uri, $mapping=NULL) | DrupalLocalStreamWrapper | static
getTarget($uri=NULL) | DrupalLocalStreamWrapper | protected
getUri() | DrupalLocalStreamWrapper |
mkdir($uri, $mode, $options) | DrupalLocalStreamWrapper |
realpath() | DrupalLocalStreamWrapper |
rename($from_uri, $to_uri) | DrupalLocalStreamWrapper |
rmdir($uri, $options) | DrupalLocalStreamWrapper |
setUri($uri) | DrupalLocalStreamWrapper |
stream_close() | DrupalLocalStreamWrapper |
stream_eof() | DrupalLocalStreamWrapper |
stream_flush() | DrupalLocalStreamWrapper |
stream_lock($operation) | DrupalLocalStreamWrapper |
stream_open($uri, $mode, $options, &$opened_path) | DrupalLocalStreamWrapper |
stream_read($count) | DrupalLocalStreamWrapper |
stream_seek($offset, $whence) | DrupalLocalStreamWrapper |
stream_stat() | DrupalLocalStreamWrapper |
stream_tell() | DrupalLocalStreamWrapper |
stream_write($data) | DrupalLocalStreamWrapper |
unlink($uri) | DrupalLocalStreamWrapper |
url_stat($uri, $flags) | DrupalLocalStreamWrapper |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum-list.tpl.php Source File

  • modules
  • forum
forum-list.tpl.php
Go to the documentation of this file.
1 <?php
2
35 ?>
36 <table id="forum-<?php print $forum_id; ?>">
37 <thead>
38 <tr>
39 <th><?php print t('Forum'); ?></th>
40 <th><?php print t('Topics');?></th>
41 <th><?php print t('Posts'); ?></th>
42 <th><?php print t('Last post'); ?></th>
43 </tr>
44 </thead>
45 <tbody>
46 <?php foreach ($forums as $child_id => $forum): ?>
47 <tr id="forum-list-<?php print $child_id; ?>" class="<?php print $forum->zebra; ?>">
48 <td <?php print $forum->is_container ? 'colspan="4" class="container"' : 'class="forum"'; ?>>
49 <?php /* Enclose the contents of this cell with X divs, where X is the
50 * depth this forum resides at. This will allow us to use CSS
51 * left-margin for indenting.
52 */ ?>
53 <?php print str_repeat('<div class="indent">', $forum->depth); ?>
54 <div class="icon forum-status-<?php print $forum->icon_class; ?>" title="<?php print $forum->icon_title; ?>">
55 <span class="element-invisible"><?php print $forum->icon_title; ?></span>
56 </div>
57 <div class="name"><a href="<?php print $forum->link; ?>"><?php print $forum->name; ?></a></div>
58 <?php if ($forum->description): ?>
59 <div class="description"><?php print $forum->description; ?></div>
60 <?php endif; ?>
61 <?php print str_repeat('</div>', $forum->depth); ?>
62 </td>
63 <?php if (!$forum->is_container): ?>
64 <td class="topics">
65 <?php print $forum->num_topics ?>
66 <?php if ($forum->new_topics): ?>
67 <br />
68 <a href="<?php print $forum->new_url; ?>"><?php print $forum->new_text; ?></a>
69 <?php endif; ?>
70 </td>
71 <td class="posts"><?php print $forum->num_posts ?></td>
72 <td class="last-reply"><?php print $forum->last_reply ?></td>
73 <?php endif; ?>
74 </tr>
75 <?php endforeach; ?>
76 </tbody>
77 </table>
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
endforeach
endforeach
Definition: block-admin-display-form.tpl.php:64
endif
endif
Definition: aggregator-item.tpl.php:31
title
print $topic title
Definition: forum-topic-list.tpl.php:50
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/modules/options/options.module Source File

  • modules
  • field
  • modules
  • options
options.module
Go to the documentation of this file.
1 <?php
2
11 function options_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#options':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t('The Options module defines checkbox, selection, and other input widgets for the Field module. See the <a href="@field-help">Field module help page</a> for more information about fields.', array('@field-help' => url('admin/help/field'))) . '</p>';
17 return $output;
18 }
19 }
20
24 function options_theme() {
25 return array(
26 'options_none' => array(
27 'variables' => array('instance' => NULL, 'option' => NULL),
28 ),
29 );
30 }
31
41 function options_field_widget_info() {
42 return array(
43 'options_select' => array(
44 'label' => t('Select list'),
45 'field types' => array(),
46 'behaviors' => array(
47 'multiple values' => FIELD_BEHAVIOR_CUSTOM,
48 ),
49 ),
50 'options_buttons' => array(
51 'label' => t('Check boxes/radio buttons'),
52 'field types' => array(),
53 'behaviors' => array(
54 'multiple values' => FIELD_BEHAVIOR_CUSTOM,
55 ),
56 ),
57 'options_onoff' => array(
58 'label' => t('Single on/off checkbox'),
59 'field types' => array(),
60 'behaviors' => array(
61 'multiple values' => FIELD_BEHAVIOR_CUSTOM,
62 ),
63 'settings' => array('display_label' => 0),
64 ),
65 );
66 }
67
71 function options_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
72 // Abstract over the actual field columns, to allow different field types to
73 // reuse those widgets.
74 $value_key = key($field['columns']);
75
76 $type = str_replace('options_', '', $instance['widget']['type']);
77 $multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED;
78 $required = $element['#required'];
79 $has_value = isset($items[0][$value_key]);
80 $properties = _options_properties($type, $multiple, $required, $has_value);
81
82 $entity_type = $element['#entity_type'];
83 $entity = $element['#entity'];
84
85 // Prepare the list of options.
86 $options = _options_get_options($field, $instance, $properties, $entity_type, $entity);
87
88 // Put current field values in shape.
89 $default_value = _options_storage_to_form($items, $options, $value_key, $properties);
90
91 switch ($type) {
92 case 'select':
93 $element += array(
94 '#type' => 'select',
95 '#default_value' => $default_value,
96 // Do not display a 'multiple' select box if there is only one option.
97 '#multiple' => $multiple && count($options) > 1,
98 '#options' => $options,
99 );
100 break;
101
102 case 'buttons':
103 // If required and there is one single option, preselect it.
104 if ($required && count($options) == 1) {
105 reset($options);
106 $default_value = array(key($options));
107 }
108
109 // If this is a single-value field, take the first default value, or
110 // default to NULL so that the form element is properly recognized as
111 // not having a default value.
112 if (!$multiple) {
113 $default_value = $default_value ? reset($default_value) : NULL;
114 }
115
116 $element += array(
117 '#type' => $multiple ? 'checkboxes' : 'radios',
118 // Radio buttons need a scalar value.
119 '#default_value' => $default_value,
120 '#options' => $options,
121 );
122 break;
123
124 case 'onoff':
125 $keys = array_keys($options);
126 $off_value = array_shift($keys);
127 $on_value = array_shift($keys);
128 $element += array(
129 '#type' => 'checkbox',
130 '#default_value' => (isset($default_value[0]) && $default_value[0] == $on_value) ? 1 : 0,
131 '#on_value' => $on_value,
132 '#off_value' => $off_value,
133 );
134 // Override the title from the incoming $element.
135 $element['#title'] = isset($options[$on_value]) ? $options[$on_value] : '';
136
137 if ($instance['widget']['settings']['display_label']) {
138 $element['#title'] = $instance['label'];
139 }
140 break;
141 }
142
143 $element += array(
144 '#value_key' => $value_key,
145 '#element_validate' => array('options_field_widget_validate'),
146 '#properties' => $properties,
147 );
148
149 return $element;
150 }
151
155 function options_field_widget_settings_form($field, $instance) {
156 $form = array();
157 if ($instance['widget']['type'] == 'options_onoff') {
158 $form['display_label'] = array(
159 '#type' => 'checkbox',
160 '#title' => t('Use field label instead of the "On value" as label'),
161 '#default_value' => $instance['widget']['settings']['display_label'],
162 '#weight' => -1,
163 );
164 }
165 return $form;
166 }
167
171 function options_field_widget_validate($element, &$form_state) {
172 if ($element['#required'] && $element['#value'] == '_none') {
173 form_error($element, t('!name field is required.', array('!name' => $element['#title'])));
174 }
175 // Transpose selections from field => delta to delta => field, turning
176 // multiple selected options into multiple parent elements.
177 $items = _options_form_to_storage($element);
178 form_set_value($element, $items, $form_state);
179 }
180
184 function _options_properties($type, $multiple, $required, $has_value) {
185 $base = array(
186 'filter_xss' => FALSE,
187 'strip_tags' => FALSE,
188 'empty_option' => FALSE,
189 'optgroups' => FALSE,
190 );
191
192 $properties = array();
193
194 switch ($type) {
195 case 'select':
196 $properties = array(
197 // Select boxes do not support any HTML tag.
198 'strip_tags' => TRUE,
199 'optgroups' => TRUE,
200 );
201 if ($multiple) {
202 // Multiple select: add a 'none' option for non-required fields.
203 if (!$required) {
204 $properties['empty_option'] = 'option_none';
205 }
206 }
207 else {
208 // Single select: add a 'none' option for non-required fields,
209 // and a 'select a value' option for required fields that do not come
210 // with a value selected.
211 if (!$required) {
212 $properties['empty_option'] = 'option_none';
213 }
214 elseif (!$has_value) {
215 $properties['empty_option'] = 'option_select';
216 }
217 }
218 break;
219
220 case 'buttons':
221 $properties = array(
222 'filter_xss' => TRUE,
223 );
224 // Add a 'none' option for non-required radio buttons.
225 if (!$required && !$multiple) {
226 $properties['empty_option'] = 'option_none';
227 }
228 break;
229
230 case 'onoff':
231 $properties = array(
232 'filter_xss' => TRUE,
233 );
234 break;
235 }
236
237 return $properties + $base;
238 }
239
243 function _options_get_options($field, $instance, $properties, $entity_type, $entity) {
244 // Get the list of options.
245 $options = (array) module_invoke($field['module'], 'options_list', $field, $instance, $entity_type, $entity);
246
247 // Sanitize the options.
248 _options_prepare_options($options, $properties);
249
250 if (!$properties['optgroups']) {
251 $options = options_array_flatten($options);
252 }
253
254 if ($properties['empty_option']) {
255 $label = theme('options_none', array('instance' => $instance, 'option' => $properties['empty_option']));
256 $options = array('_none' => $label) + $options;
257 }
258
259 return $options;
260 }
261
267 function _options_prepare_options(&$options, $properties) {
268 foreach ($options as $value => $label) {
269 // Recurse for optgroups.
270 if (is_array($label)) {
271 _options_prepare_options($options[$value], $properties);
272 }
273 else {
274 if ($properties['strip_tags']) {
275 $options[$value] = strip_tags($label);
276 }
277 if ($properties['filter_xss']) {
278 $options[$value] = field_filter_xss($label);
279 }
280 }
281 }
282 }
283
287 function _options_storage_to_form($items, $options, $column, $properties) {
288 $items_transposed = options_array_transpose($items);
289 $values = (isset($items_transposed[$column]) && is_array($items_transposed[$column])) ? $items_transposed[$column] : array();
290
291 // Discard values that are not in the current list of options. Flatten the
292 // array if needed.
293 if ($properties['optgroups']) {
294 $options = options_array_flatten($options);
295 }
296 $values = array_values(array_intersect($values, array_keys($options)));
297 return $values;
298 }
299
303 function _options_form_to_storage($element) {
304 $values = array_values((array) $element['#value']);
305 $properties = $element['#properties'];
306
307 // On/off checkbox: transform '0 / 1' into the 'on / off' values.
308 if ($element['#type'] == 'checkbox') {
309 $values = array($values[0] ? $element['#on_value'] : $element['#off_value']);
310 }
311
312 // Filter out the 'none' option. Use a strict comparison, because
313 // 0 == 'any string'.
314 if ($properties['empty_option']) {
315 $index = array_search('_none', $values, TRUE);
316 if ($index !== FALSE) {
317 unset($values[$index]);
318 }
319 }
320
321 // Make sure we populate at least an empty value.
322 if (empty($values)) {
323 $values = array(NULL);
324 }
325
326 $result = options_array_transpose(array($element['#value_key'] => $values));
327 return $result;
328 }
329
343 function options_array_transpose($array) {
344 $result = array();
345 if (is_array($array)) {
346 foreach ($array as $key1 => $value1) {
347 if (is_array($value1)) {
348 foreach ($value1 as $key2 => $value2) {
349 if (!isset($result[$key2])) {
350 $result[$key2] = array();
351 }
352 $result[$key2][$key1] = $value2;
353 }
354 }
355 }
356 }
357 return $result;
358 }
359
368 function options_array_flatten($array) {
369 $result = array();
370 if (is_array($array)) {
371 foreach ($array as $key => $value) {
372 if (is_array($value)) {
373 $result += options_array_flatten($value);
374 }
375 else {
376 $result[$key] = $value;
377 }
378 }
379 }
380 return $result;
381 }
382
386 function options_field_widget_error($element, $error, $form, &$form_state) {
387 form_error($element, $error['message']);
388 }
389
401 function theme_options_none($variables) {
402 $instance = $variables['instance'];
403 $option = $variables['option'];
404
405 $output = '';
406 switch ($instance['widget']['type']) {
407 case 'options_buttons':
408 $output = t('N/A');
409 break;
410
411 case 'options_select':
412 $output = ($option == 'option_none' ? t('- None -') : t('- Select a value -'));
413 break;
414 }
415
416 return $output;
417 }
field_filter_xss
field_filter_xss($string)
Definition: field.module:752
theme_options_none
theme_options_none($variables)
Definition: options.module:401
options_field_widget_form
options_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
Definition: options.module:71
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
options_help
options_help($path, $arg)
Definition: options.module:11
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
options_field_widget_error
options_field_widget_error($element, $error, $form, &$form_state)
Definition: options.module:386
options_field_widget_info
options_field_widget_info()
Definition: options.module:41
$value
print $value
Definition: user-profile-item.tpl.php:26
$output
$output
Definition: authorize.php:93
FIELD_BEHAVIOR_CUSTOM
const FIELD_BEHAVIOR_CUSTOM
Definition: field.module:262
FIELD_CARDINALITY_UNLIMITED
const FIELD_CARDINALITY_UNLIMITED
Definition: field.module:236
options_field_widget_settings_form
options_field_widget_settings_form($field, $instance)
Definition: options.module:155
_options_prepare_options
_options_prepare_options(&$options, $properties)
Definition: options.module:267
_options_properties
_options_properties($type, $multiple, $required, $has_value)
Definition: options.module:184
_options_form_to_storage
_options_form_to_storage($element)
Definition: options.module:303
options_array_flatten
options_array_flatten($array)
Definition: options.module:368
options_field_widget_validate
options_field_widget_validate($element, &$form_state)
Definition: options.module:171
_options_storage_to_form
_options_storage_to_form($items, $options, $column, $properties)
Definition: options.module:287
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
options_array_transpose
options_array_transpose($array)
Definition: options.module:343
options_theme
options_theme()
Definition: options.module:24
_options_get_options
_options_get_options($field, $instance, $properties, $entity_type, $entity)
Definition: options.module:243
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/theme.maintenance.inc Source File

  • includes
theme.maintenance.inc
Go to the documentation of this file.
1 <?php
2
17 function _drupal_maintenance_theme() {
18 global $theme, $theme_key, $conf;
19
20 // If $theme is already set, assume the others are set too, and do nothing.
21 if (isset($theme)) {
22 return;
23 }
24
25 require_once DRUPAL_ROOT . '/' . variable_get('path_inc', 'includes/path.inc');
26 require_once DRUPAL_ROOT . '/includes/theme.inc';
27 require_once DRUPAL_ROOT . '/includes/common.inc';
28 require_once DRUPAL_ROOT . '/includes/unicode.inc';
29 require_once DRUPAL_ROOT . '/includes/file.inc';
30 require_once DRUPAL_ROOT . '/includes/module.inc';
31 unicode_check();
32
33 // Install and update pages are treated differently to prevent theming overrides.
34 if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) {
35 $custom_theme = (isset($conf['maintenance_theme']) ? $conf['maintenance_theme'] : 'seven');
36 }
37 else {
38 // The bootstrap was not complete. So we are operating in a crippled
39 // environment, we need to bootstrap just enough to allow hook invocations
40 // to work. See _drupal_log_error().
41 if (!class_exists('Database', FALSE)) {
42 require_once DRUPAL_ROOT . '/includes/database/database.inc';
43 }
44
45 // We use the default theme as the maintenance theme. If a default theme
46 // isn't specified in the database or in settings.php, we use Bartik.
47 $custom_theme = variable_get('maintenance_theme', variable_get('theme_default', 'bartik'));
48 }
49
50 // Ensure that system.module is loaded.
51 if (!function_exists('_system_rebuild_theme_data')) {
52 $module_list['system']['filename'] = 'modules/system/system.module';
53 module_list(TRUE, FALSE, FALSE, $module_list);
54 drupal_load('module', 'system');
55 }
56
57 $themes = list_themes();
58
59 // list_themes() triggers a drupal_alter() in maintenance mode, but we can't
60 // let themes alter the .info data until we know a theme's base themes. So
61 // don't set global $theme until after list_themes() builds its cache.
62 $theme = $custom_theme;
63
64 // Store the identifier for retrieving theme settings with.
65 $theme_key = $theme;
66
67 // Find all our ancestor themes and put them in an array.
68 $base_theme = array();
69 $ancestor = $theme;
70 while ($ancestor && isset($themes[$ancestor]->base_theme)) {
71 $base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme];
72 $ancestor = $themes[$ancestor]->base_theme;
73 }
74 _drupal_theme_initialize($themes[$theme], array_reverse($base_theme), '_theme_load_offline_registry');
75
76 // These are usually added from system_init() -except maintenance.css.
77 // When the database is inactive it's not called so we add it here.
78 $path = drupal_get_path('module', 'system');
79 drupal_add_css($path . '/system.base.css');
80 drupal_add_css($path . '/system.admin.css');
81 drupal_add_css($path . '/system.menus.css');
82 drupal_add_css($path . '/system.messages.css');
83 drupal_add_css($path . '/system.theme.css');
84 drupal_add_css($path . '/system.maintenance.css');
85 }
86
90 function _theme_load_offline_registry($theme, $base_theme = NULL, $theme_engine = NULL) {
91 return _theme_build_registry($theme, $base_theme, $theme_engine);
92 }
93
104 function theme_task_list($variables) {
105 $items = $variables['items'];
106 $active = $variables['active'];
107
108 $done = isset($items[$active]) || $active == NULL;
109 $output = '<h2 class="element-invisible">Installation tasks</h2>';
110 $output .= '<ol class="task-list">';
111
112 foreach ($items as $k => $item) {
113 if ($active == $k) {
114 $class = 'active';
115 $status = '(' . t('active') . ')';
116 $done = FALSE;
117 }
118 else {
119 $class = $done ? 'done' : '';
120 $status = $done ? '(' . t('done') . ')' : '';
121 }
122 $output .= '<li';
123 $output .= ($class ? ' class="' . $class . '"' : '') . '>';
124 $output .= $item;
125 $output .= ($status ? '<span class="element-invisible">' . $status . '</span>' : '');
126 $output .= '</li>';
127 }
128 $output .= '</ol>';
129 return $output;
130 }
131
141 function theme_install_page($variables) {
142 drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
143 return theme('maintenance_page', $variables);
144 }
145
157 function theme_update_page($variables) {
158 drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
159 return theme('maintenance_page', $variables);
160 }
161
171 function theme_authorize_report($variables) {
172 $messages = $variables['messages'];
173 $output = '';
174 if (!empty($messages)) {
175 $output .= '<div id="authorize-results">';
176 foreach ($messages as $heading => $logs) {
177 $items = array();
178 foreach ($logs as $number => $log_message) {
179 if ($number === '#abort') {
180 continue;
181 }
182 $items[] = theme('authorize_message', array('message' => $log_message['message'], 'success' => $log_message['success']));
183 }
184 $output .= theme('item_list', array('items' => $items, 'title' => $heading));
185 }
186 $output .= '</div>';
187 }
188 return $output;
189 }
190
201 function theme_authorize_message($variables) {
202 $message = $variables['message'];
203 $success = $variables['success'];
204 if ($success) {
205 $item = array('data' => $message, 'class' => array('success'));
206 }
207 else {
208 $item = array('data' => '<strong>' . $message . '</strong>', 'class' => array('failure'));
209 }
210 return $item;
211 }
_theme_load_offline_registry
_theme_load_offline_registry($theme, $base_theme=NULL, $theme_engine=NULL)
Definition: theme.maintenance.inc:90
module_list
module_list($refresh=FALSE, $bootstrap_refresh=FALSE, $sort=FALSE, $fixed_list=NULL)
Definition: module.inc:66
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
_drupal_theme_initialize
_drupal_theme_initialize($theme, $base_theme=array(), $registry_callback= '_theme_load_registry')
Definition: theme.inc:141
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
$conf
global $conf
Definition: authorize.php:74
$module_list
$module_list['system']['filename']
Definition: authorize.php:78
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
drupal_add_http_header
drupal_add_http_header($name, $value, $append=FALSE)
Definition: bootstrap.inc:1129
$messages
print $messages
Definition: page.tpl.php:121
theme_authorize_message
theme_authorize_message($variables)
Definition: theme.maintenance.inc:201
$output
$output
Definition: authorize.php:93
theme_authorize_report
theme_authorize_report($variables)
Definition: theme.maintenance.inc:171
_theme_build_registry
_theme_build_registry($theme, $base_theme, $theme_engine)
Definition: theme.inc:678
theme_task_list
theme_task_list($variables)
Definition: theme.maintenance.inc:104
theme_install_page
theme_install_page($variables)
Definition: theme.maintenance.inc:141
MAINTENANCE_MODE
const MAINTENANCE_MODE
Definition: authorize.php:36
list_themes
list_themes($refresh=FALSE)
Definition: theme.inc:774
_drupal_maintenance_theme
_drupal_maintenance_theme()
Definition: theme.maintenance.inc:17
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
drupal_load
drupal_load($type, $name)
Definition: bootstrap.inc:1093
unicode_check
unicode_check()
Definition: unicode.inc:87
theme_update_page
theme_update_page($variables)
Definition: theme.maintenance.inc:157
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/node.tokens.inc Source File

  • modules
  • node
node.tokens.inc
Go to the documentation of this file.
1 <?php
2
13 function node_token_info() {
14 $type = array(
15 'name' => t('Nodes'),
16 'description' => t('Tokens related to individual content items, or "nodes".'),
17 'needs-data' => 'node',
18 );
19
20 // Core tokens for nodes.
21 $node['nid'] = array(
22 'name' => t("Content ID"),
23 'description' => t('The unique ID of the content item, or "node".'),
24 );
25 $node['vid'] = array(
26 'name' => t("Revision ID"),
27 'description' => t("The unique ID of the node's latest revision."),
28 );
29 $node['tnid'] = array(
30 'name' => t("Translation set ID"),
31 'description' => t("The unique ID of the original-language version of this node, if one exists."),
32 );
33 $node['type'] = array(
34 'name' => t("Content type"),
35 'description' => t("The type of the node."),
36 );
37 $node['type-name'] = array(
38 'name' => t("Content type name"),
39 'description' => t("The human-readable name of the node type."),
40 );
41 $node['title'] = array(
42 'name' => t("Title"),
43 'description' => t("The title of the node."),
44 );
45 $node['body'] = array(
46 'name' => t("Body"),
47 'description' => t("The main body text of the node."),
48 );
49 $node['summary'] = array(
50 'name' => t("Summary"),
51 'description' => t("The summary of the node's main body text."),
52 );
53 $node['language'] = array(
54 'name' => t("Language"),
55 'description' => t("The language the node is written in."),
56 );
57 $node['url'] = array(
58 'name' => t("URL"),
59 'description' => t("The URL of the node."),
60 );
61 $node['edit-url'] = array(
62 'name' => t("Edit URL"),
63 'description' => t("The URL of the node's edit page."),
64 );
65
66 // Chained tokens for nodes.
67 $node['created'] = array(
68 'name' => t("Date created"),
69 'description' => t("The date the node was posted."),
70 'type' => 'date',
71 );
72 $node['changed'] = array(
73 'name' => t("Date changed"),
74 'description' => t("The date the node was most recently updated."),
75 'type' => 'date',
76 );
77 $node['author'] = array(
78 'name' => t("Author"),
79 'description' => t("The author of the node."),
80 'type' => 'user',
81 );
82
83 return array(
84 'types' => array('node' => $type),
85 'tokens' => array('node' => $node),
86 );
87 }
88
92 function node_tokens($type, $tokens, array $data = array(), array $options = array()) {
93 $url_options = array('absolute' => TRUE);
94 if (isset($options['language'])) {
95 $url_options['language'] = $options['language'];
96 $language_code = $options['language']->language;
97 }
98 else {
99 $language_code = NULL;
100 }
101 $sanitize = !empty($options['sanitize']);
102
103 $replacements = array();
104
105 if ($type == 'node' && !empty($data['node'])) {
106 $node = $data['node'];
107
108 foreach ($tokens as $name => $original) {
109 switch ($name) {
110 // Simple key values on the node.
111 case 'nid':
112 $replacements[$original] = $node->nid;
113 break;
114
115 case 'vid':
116 $replacements[$original] = $node->vid;
117 break;
118
119 case 'tnid':
120 $replacements[$original] = $node->tnid;
121 break;
122
123 case 'type':
124 $replacements[$original] = $sanitize ? check_plain($node->type) : $node->type;
125 break;
126
127 case 'type-name':
128 $type_name = node_type_get_name($node);
129 $replacements[$original] = $sanitize ? check_plain($type_name) : $type_name;
130 break;
131
132 case 'title':
133 $replacements[$original] = $sanitize ? check_plain($node->title) : $node->title;
134 break;
135
136 case 'body':
137 case 'summary':
138 if ($items = field_get_items('node', $node, 'body', $language_code)) {
139 $column = ($name == 'body') ? 'value' : 'summary';
140 $instance = field_info_instance('node', 'body', $node->type);
141 $field_langcode = field_language('node', $node, 'body', $language_code);
142 $replacements[$original] = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], $column) : $items[0][$column];
143 }
144 break;
145
146 case 'language':
147 $langcode = entity_language('node', $node);
148 $replacements[$original] = $sanitize ? check_plain($langcode) : $langcode;
149 break;
150
151 case 'url':
152 $replacements[$original] = url('node/' . $node->nid, $url_options);
153 break;
154
155 case 'edit-url':
156 $replacements[$original] = url('node/' . $node->nid . '/edit', $url_options);
157 break;
158
159 // Default values for the chained tokens handled below.
160 case 'author':
161 $account = user_load($node->uid);
162 $name = format_username($account);
163 $replacements[$original] = $sanitize ? check_plain($name) : $name;
164 break;
165
166 case 'created':
167 $replacements[$original] = format_date($node->created, 'medium', '', NULL, $language_code);
168 break;
169
170 case 'changed':
171 $replacements[$original] = format_date($node->changed, 'medium', '', NULL, $language_code);
172 break;
173 }
174 }
175
176 if ($author_tokens = token_find_with_prefix($tokens, 'author')) {
177 $author = user_load($node->uid);
178 $replacements += token_generate('user', $author_tokens, array('user' => $author), $options);
179 }
180
181 if ($created_tokens = token_find_with_prefix($tokens, 'created')) {
182 $replacements += token_generate('date', $created_tokens, array('date' => $node->created), $options);
183 }
184
185 if ($changed_tokens = token_find_with_prefix($tokens, 'changed')) {
186 $replacements += token_generate('date', $changed_tokens, array('date' => $node->changed), $options);
187 }
188 }
189
190 return $replacements;
191 }
token_generate
token_generate($type, array $tokens, array $data=array(), array $options=array())
Definition: token.inc:176
format_username
format_username($account)
Definition: common.inc:2106
field_get_items
field_get_items($entity_type, $entity, $field_name, $langcode=NULL)
Definition: field.module:935
$name
print $name
Definition: profile-listing.tpl.php:43
node_type_get_name
node_type_get_name($node)
Definition: node.module:459
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
node_tokens
node_tokens($type, $tokens, array $data=array(), array $options=array())
Definition: node.tokens.inc:92
field_language
field_language($entity_type, $entity, $field_name=NULL, $langcode=NULL)
Definition: field.multilingual.inc:266
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
_text_sanitize
_text_sanitize($instance, $langcode, $item, $column)
Definition: text.module:313
entity_language
entity_language($entity_type, $entity)
Definition: common.inc:7967
$author
print $author
Definition: comment.tpl.php:68
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
node_token_info
node_token_info()
Definition: node.tokens.inc:13
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
token_find_with_prefix
token_find_with_prefix(array $tokens, $prefix, $delimiter= ':')
Definition: token.inc:219
field_info_instance
field_info_instance($entity_type, $field_name, $bundle_name)
Definition: field.info.inc:623
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/rdf_example/rdf_example.install Source File

  • examples
  • rdf_example
rdf_example.install
Go to the documentation of this file.
1 <?php
24 function rdf_example_install() {
25 // use get_t() to get the name of our localization function for translation
26 // during install, when t() is not available.
27 $t = get_t();
28
29 // Define the node type.
30 $rdf_example = array(
31 'type' => 'recipe',
32 'name' => $t('Recipe'),
33 'base' => 'node_content',
34 'description' => $t('The recipe node is defined to demonstrate RDF mapping.'),
35 );
36
37 // Set additional defaults and save the content type.
38 $content_type = node_type_set_defaults($rdf_example);
39 node_type_save($content_type);
40
41 // Create all the fields we are adding to our content type.
42 // http://api.drupal.org/api/function/field_create_field/7
43 foreach (_rdf_example_installed_fields() as $field) {
44 field_create_field($field);
45 }
46
47 // Create all the instances for our fields.
48 // http://api.drupal.org/api/function/field_create_instance/7
49 foreach (_rdf_example_installed_instances() as $instance) {
50 $instance['entity_type'] = 'node';
51 $instance['bundle'] = $rdf_example['type'];
52 field_create_instance($instance);
53 }
54 }
55
61 function _rdf_example_installed_fields() {
62 $t = get_t();
63 return array(
64 'recipe_photo' => array(
65 'field_name' => 'recipe_photo',
66 'cardinality' => 1,
67 'type' => 'image',
68 ),
69 'recipe_summary' => array(
70 'field_name' => 'recipe_summary',
71 'cardinality' => 1,
72 'type' => 'text',
73 'settings' => array(
74 'max_length' => 500,
75 ),
76 ),
77 );
78 }
79
85 function _rdf_example_installed_instances() {
86 $t = get_t();
87 return array(
88 'recipe_photo' => array(
89 'field_name' => 'recipe_photo',
90 'label' => $t('Photo of the prepared dish'),
91 ),
92 'recipe_summary' => array(
93 'field_name' => 'recipe_summary',
94 'label' => $t('Short summary describing the dish'),
95 'widget' => array(
96 'type' => 'text_textarea',
97 ),
98 ),
99 );
100 }
101
102
108 function rdf_example_uninstall() {
109 // Delete recipe content.
110 $sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
111 $result = db_query($sql, array(':type' => 'recipe'));
112 $nids = array();
113 foreach ($result as $row) {
114 $nids[] = $row->nid;
115 }
116 node_delete_multiple($nids);
117
118 // Delete field instances for now.
119 // Check status of http://drupal.org/node/1015846
120 $instances = field_info_instances('node', 'recipe');
121 foreach ($instances as $instance_name => $instance) {
122 field_delete_instance($instance);
123 }
124
125 // Delete node type.
126 node_type_delete('recipe');
127
128 field_purge_batch(1000);
129 }
node_type_save
node_type_save($info)
Definition: node.module:525
field_create_instance
field_create_instance($instance)
Definition: field.crud.inc:473
rdf_example_uninstall
rdf_example_uninstall()
Definition: rdf_example.install:108
node_type_delete
node_type_delete($type)
Definition: node.module:651
field_info_instances
field_info_instances($entity_type=NULL, $bundle_name=NULL)
Definition: field.info.inc:592
rdf_example_install
rdf_example_install()
Definition: rdf_example.install:24
field_create_field
field_create_field($field)
Definition: field.crud.inc:56
node_type_set_defaults
node_type_set_defaults($info=array())
Definition: node.module:805
_rdf_example_installed_fields
_rdf_example_installed_fields()
Definition: rdf_example.install:61
get_t
get_t()
Definition: bootstrap.inc:2635
field_purge_batch
field_purge_batch($batch_size)
Definition: field.crud.inc:880
_rdf_example_installed_instances
_rdf_example_installed_instances()
Definition: rdf_example.install:85
field_delete_instance
field_delete_instance($instance, $field_cleanup=TRUE)
Definition: field.crud.inc:768
$row
$row
Definition: block-admin-display-form.tpl.php:47
node_delete_multiple
node_delete_multiple($nids)
Definition: node.module:1243
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/field.info.inc Source File

  • modules
  • field
field.info.inc
Go to the documentation of this file.
1 <?php
2
14 function _field_info_field_cache() {
15 // Use the advanced drupal_static() pattern, since this is called very often.
16 static $drupal_static_fast;
17
18 if (!isset($drupal_static_fast)) {
19 $drupal_static_fast['field_info_field_cache'] = &drupal_static(__FUNCTION__);
20 }
21 $field_info = &$drupal_static_fast['field_info_field_cache'];
22
23 if (!isset($field_info)) {
24 // @todo The registry should save the need for an explicit include, but not
25 // a couple upgrade tests (DisabledNodeTypeTestCase,
26 // FilterFormatUpgradePathTestCase...) break in a strange way without it.
27 include_once dirname(__FILE__) . '/field.info.class.inc';
28 $field_info = new FieldInfo();
29 }
30
31 return $field_info;
32 }
33
54 function field_info_cache_clear() {
55 drupal_static_reset('field_view_mode_settings');
56 drupal_static_reset('field_available_languages');
57
58 // @todo: Remove this when field_attach_*_bundle() bundle management
59 // functions are moved to the entity API.
60 entity_info_cache_clear();
61
62 _field_info_collate_types(TRUE);
63 _field_info_field_cache()->flush();
64 }
65
76 function _field_info_collate_fields($reset = FALSE) {
77 if ($reset) {
78 _field_info_field_cache()->flush();
79 return;
80 }
81
82 $cache = _field_info_field_cache();
83
84 // Collect fields, and build the array of IDs keyed by field_name.
85 $fields = $cache->getFields();
86 $field_ids = array();
87 foreach ($fields as $id => $field) {
88 if (!$field['deleted']) {
89 $field_ids[$field['field_name']] = $id;
90 }
91 }
92
93 // Collect extra fields for all entity types.
94 $extra_fields = array();
95 foreach (field_info_bundles() as $entity_type => $bundles) {
96 foreach ($bundles as $bundle => $info) {
97 $extra_fields[$entity_type][$bundle] = $cache->getBundleExtraFields($entity_type, $bundle);
98 }
99 }
100
101 return array(
102 'fields' => $fields,
103 'field_ids' => $field_ids,
104 'instances' => $cache->getInstances(),
105 'extra_fields' => $extra_fields,
106 );
107 }
108
141 function _field_info_collate_types($reset = FALSE) {
142 global $language;
143 static $info;
144
145 // The _info() hooks invoked below include translated strings, so each
146 // language is cached separately.
147 $langcode = $language->language;
148
149 if ($reset) {
150 $info = NULL;
151 // Clear all languages.
152 cache_clear_all('field_info_types:', 'cache_field', TRUE);
153 return;
154 }
155
156 if (!isset($info)) {
157 if ($cached = cache_get("field_info_types:$langcode", 'cache_field')) {
158 $info = $cached->data;
159 }
160 else {
161 $info = array(
162 'field types' => array(),
163 'widget types' => array(),
164 'formatter types' => array(),
165 'storage types' => array(),
166 );
167
168 // Populate field types.
169 foreach (module_implements('field_info') as $module) {
170 $field_types = (array) module_invoke($module, 'field_info');
171 foreach ($field_types as $name => $field_info) {
172 // Provide defaults.
173 $field_info += array(
174 'settings' => array(),
175 'instance_settings' => array(),
176 );
177 $info['field types'][$name] = $field_info;
178 $info['field types'][$name]['module'] = $module;
179 }
180 }
181 drupal_alter('field_info', $info['field types']);
182
183 // Populate widget types.
184 foreach (module_implements('field_widget_info') as $module) {
185 $widget_types = (array) module_invoke($module, 'field_widget_info');
186 foreach ($widget_types as $name => $widget_info) {
187 // Provide defaults.
188 $widget_info += array(
189 'settings' => array(),
190 );
191 $info['widget types'][$name] = $widget_info;
192 $info['widget types'][$name]['module'] = $module;
193 }
194 }
195 drupal_alter('field_widget_info', $info['widget types']);
196 uasort($info['widget types'], 'drupal_sort_weight');
197
198 // Populate formatter types.
199 foreach (module_implements('field_formatter_info') as $module) {
200 $formatter_types = (array) module_invoke($module, 'field_formatter_info');
201 foreach ($formatter_types as $name => $formatter_info) {
202 // Provide defaults.
203 $formatter_info += array(
204 'settings' => array(),
205 );
206 $info['formatter types'][$name] = $formatter_info;
207 $info['formatter types'][$name]['module'] = $module;
208 }
209 }
210 drupal_alter('field_formatter_info', $info['formatter types']);
211
212 // Populate storage types.
213 foreach (module_implements('field_storage_info') as $module) {
214 $storage_types = (array) module_invoke($module, 'field_storage_info');
215 foreach ($storage_types as $name => $storage_info) {
216 // Provide defaults.
217 $storage_info += array(
218 'settings' => array(),
219 );
220 $info['storage types'][$name] = $storage_info;
221 $info['storage types'][$name]['module'] = $module;
222 }
223 }
224 drupal_alter('field_storage_info', $info['storage types']);
225
226 cache_set("field_info_types:$langcode", $info, 'cache_field');
227 }
228 }
229
230 return $info;
231 }
232
241 function _field_info_prepare_field($field) {
242 $cache = _field_info_field_cache();
243 return $cache->prepareField($field);
244 }
245
254 function _field_info_prepare_instance($instance, $field) {
255 $cache = _field_info_field_cache();
256 return $cache->prepareInstance($instance, $field['type']);
257 }
258
267 function _field_info_prepare_instance_display($field, $display) {
268 $cache = _field_info_field_cache();
269 return $cache->prepareInstanceDisplay($display, $field['type']);
270 }
271
280 function _field_info_prepare_instance_widget($field, $widget) {
281 $cache = _field_info_field_cache();
282 return $cache->prepareInstanceWidget($widget, $field['type']);
283 }
284
293 function _field_info_prepare_extra_fields($extra_fields, $entity_type, $bundle) {
294 $cache = _field_info_field_cache();
295 return $cache->prepareExtraFields($extra_fields, $entity_type, $bundle);
296 }
297
313 function field_behaviors_widget($op, $instance) {
314 $info = field_info_widget_types($instance['widget']['type']);
315 return isset($info['behaviors'][$op]) ? $info['behaviors'][$op] : FIELD_BEHAVIOR_DEFAULT;
316 }
317
329 function field_info_field_types($field_type = NULL) {
330 $info = _field_info_collate_types();
331 $field_types = $info['field types'];
332 if ($field_type) {
333 if (isset($field_types[$field_type])) {
334 return $field_types[$field_type];
335 }
336 }
337 else {
338 return $field_types;
339 }
340 }
341
354 function field_info_widget_types($widget_type = NULL) {
355 $info = _field_info_collate_types();
356 $widget_types = $info['widget types'];
357 if ($widget_type) {
358 if (isset($widget_types[$widget_type])) {
359 return $widget_types[$widget_type];
360 }
361 }
362 else {
363 return $widget_types;
364 }
365 }
366
379 function field_info_formatter_types($formatter_type = NULL) {
380 $info = _field_info_collate_types();
381 $formatter_types = $info['formatter types'];
382 if ($formatter_type) {
383 if (isset($formatter_types[$formatter_type])) {
384 return $formatter_types[$formatter_type];
385 }
386 }
387 else {
388 return $formatter_types;
389 }
390 }
391
404 function field_info_storage_types($storage_type = NULL) {
405 $info = _field_info_collate_types();
406 $storage_types = $info['storage types'];
407 if ($storage_type) {
408 if (isset($storage_types[$storage_type])) {
409 return $storage_types[$storage_type];
410 }
411 }
412 else {
413 return $storage_types;
414 }
415 }
416
428 function field_info_bundles($entity_type = NULL) {
429 $info = entity_get_info();
430
431 if ($entity_type) {
432 return isset($info[$entity_type]['bundles']) ? $info[$entity_type]['bundles'] : array();
433 }
434
435 $bundles = array();
436 foreach ($info as $type => $entity_info) {
437 $bundles[$type] = $entity_info['bundles'];
438 }
439 return $bundles;
440 }
441
464 function field_info_field_map() {
465 $cache = _field_info_field_cache();
466 return $cache->getFieldMap();
467 }
468
487 function field_info_fields() {
488 $cache = _field_info_field_cache();
489 $info = $cache->getFields();
490
491 $fields = array();
492 foreach ($info as $key => $field) {
493 if (!$field['deleted']) {
494 $fields[$field['field_name']] = $field;
495 }
496 }
497
498 return $fields;
499 }
500
518 function field_info_field($field_name) {
519 $cache = _field_info_field_cache();
520 return $cache->getField($field_name);
521 }
522
537 function field_info_field_by_id($field_id) {
538 $cache = _field_info_field_cache();
539 return $cache->getFieldById($field_id);
540 }
541
560 function field_info_field_by_ids() {
561 $cache = _field_info_field_cache();
562 return $cache->getFields();
563 }
564
592 function field_info_instances($entity_type = NULL, $bundle_name = NULL) {
593 $cache = _field_info_field_cache();
594
595 if (!isset($entity_type)) {
596 return $cache->getInstances();
597 }
598 if (!isset($bundle_name)) {
599 return $cache->getInstances($entity_type);
600 }
601
602 return $cache->getBundleInstances($entity_type, $bundle_name);
603 }
604
623 function field_info_instance($entity_type, $field_name, $bundle_name) {
624 $cache = _field_info_field_cache();
625 $info = $cache->getBundleInstances($entity_type, $bundle_name);
626 if (isset($info[$field_name])) {
627 return $info[$field_name];
628 }
629 }
630
684 function field_info_extra_fields($entity_type, $bundle, $context) {
685 $cache = _field_info_field_cache();
686 $info = $cache->getBundleExtraFields($entity_type, $bundle);
687
688 return isset($info[$context]) ? $info[$context] : array();
689 }
690
708 function field_info_max_weight($entity_type, $bundle, $context) {
709 $weights = array();
710
711 // Collect weights for fields.
712 foreach (field_info_instances($entity_type, $bundle) as $instance) {
713 if ($context == 'form') {
714 $weights[] = $instance['widget']['weight'];
715 }
716 elseif (isset($instance['display'][$context]['weight'])) {
717 $weights[] = $instance['display'][$context]['weight'];
718 }
719 }
720 // Collect weights for extra fields.
721 foreach (field_info_extra_fields($entity_type, $bundle, $context) as $extra) {
722 $weights[] = $extra['weight'];
723 }
724
725 // Let other modules feedback about their own additions.
726 $weights = array_merge($weights, module_invoke_all('field_info_max_weight', $entity_type, $bundle, $context));
727 $max_weight = $weights ? max($weights) : NULL;
728
729 return $max_weight;
730 }
731
742 function field_info_field_settings($type) {
743 $info = field_info_field_types($type);
744 return isset($info['settings']) ? $info['settings'] : array();
745 }
746
757 function field_info_instance_settings($type) {
758 $info = field_info_field_types($type);
759 return isset($info['instance_settings']) ? $info['instance_settings'] : array();
760 }
761
773 function field_info_widget_settings($type) {
774 $info = field_info_widget_types($type);
775 return isset($info['settings']) ? $info['settings'] : array();
776 }
777
789 function field_info_formatter_settings($type) {
790 $info = field_info_formatter_types($type);
791 return isset($info['settings']) ? $info['settings'] : array();
792 }
793
805 function field_info_storage_settings($type) {
806 $info = field_info_storage_types($type);
807 return isset($info['settings']) ? $info['settings'] : array();
808 }
809
field_info_storage_types
field_info_storage_types($storage_type=NULL)
Definition: field.info.inc:404
field_info_field_by_id
field_info_field_by_id($field_id)
Definition: field.info.inc:537
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
_field_info_prepare_field
_field_info_prepare_field($field)
Definition: field.info.inc:241
$op
$op
Definition: update.php:404
field_info_formatter_types
field_info_formatter_types($formatter_type=NULL)
Definition: field.info.inc:379
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
_field_info_field_cache
_field_info_field_cache()
Definition: field.info.inc:14
field_info_instances
field_info_instances($entity_type=NULL, $bundle_name=NULL)
Definition: field.info.inc:592
$module
print $module
Definition: search-results.tpl.php:28
field_info_field_map
field_info_field_map()
Definition: field.info.inc:464
$name
print $name
Definition: profile-listing.tpl.php:43
_field_info_collate_types
_field_info_collate_types($reset=FALSE)
Definition: field.info.inc:141
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
_field_info_collate_fields
_field_info_collate_fields($reset=FALSE)
Definition: field.info.inc:76
field_info_field_by_ids
field_info_field_by_ids()
Definition: field.info.inc:560
FIELD_BEHAVIOR_DEFAULT
const FIELD_BEHAVIOR_DEFAULT
Definition: field.module:255
entity_info_cache_clear
entity_info_cache_clear()
Definition: common.inc:7690
field_info_field_types
field_info_field_types($field_type=NULL)
Definition: field.info.inc:329
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
field_behaviors_widget
field_behaviors_widget($op, $instance)
Definition: field.info.inc:313
$info
$info
Definition: color.inc:6
_field_info_prepare_instance_display
_field_info_prepare_instance_display($field, $display)
Definition: field.info.inc:267
_field_info_prepare_instance
_field_info_prepare_instance($instance, $field)
Definition: field.info.inc:254
field_info_field_settings
field_info_field_settings($type)
Definition: field.info.inc:742
field_info_cache_clear
field_info_cache_clear()
Definition: field.info.inc:54
field_info_instance_settings
field_info_instance_settings($type)
Definition: field.info.inc:757
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
field_info_extra_fields
field_info_extra_fields($entity_type, $bundle, $context)
Definition: field.info.inc:684
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
_field_info_prepare_extra_fields
_field_info_prepare_extra_fields($extra_fields, $entity_type, $bundle)
Definition: field.info.inc:293
field_info_widget_settings
field_info_widget_settings($type)
Definition: field.info.inc:773
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
field_info_storage_settings
field_info_storage_settings($type)
Definition: field.info.inc:805
field_info_bundles
field_info_bundles($entity_type=NULL)
Definition: field.info.inc:428
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
field_info_max_weight
field_info_max_weight($entity_type, $bundle, $context)
Definition: field.info.inc:708
field_info_widget_types
field_info_widget_types($widget_type=NULL)
Definition: field.info.inc:354
field_info_formatter_settings
field_info_formatter_settings($type)
Definition: field.info.inc:789
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
_field_info_prepare_instance_widget
_field_info_prepare_instance_widget($field, $widget)
Definition: field.info.inc:280
field_info_fields
field_info_fields()
Definition: field.info.inc:487
field_info_instance
field_info_instance($entity_type, $field_name, $bundle_name)
Definition: field.info.inc:623
FieldInfo
Definition: field.info.class.inc:29
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/path/path.admin.inc Source File

  • modules
  • path
path.admin.inc
Go to the documentation of this file.
1 <?php
2
14 function path_admin_overview($keys = NULL) {
15 // Add the filter form above the overview table.
16 $build['path_admin_filter_form'] = drupal_get_form('path_admin_filter_form', $keys);
17 // Enable language column if locale is enabled or if we have any alias with language
18 $alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE language <> :language', 0, 1, array(':language' => LANGUAGE_NONE))->fetchField();
19 $multilanguage = (module_exists('locale') || $alias_exists);
20
21 $header = array();
22 $header[] = array('data' => t('Alias'), 'field' => 'alias', 'sort' => 'asc');
23 $header[] = array('data' => t('System'), 'field' => 'source');
24 if ($multilanguage) {
25 $header[] = array('data' => t('Language'), 'field' => 'language');
26 }
27 $header[] = array('data' => t('Operations'));
28
29 $query = db_select('url_alias')->extend('PagerDefault')->extend('TableSort');
30 if ($keys) {
31 // Replace wildcards with PDO wildcards.
32 $query->condition('alias', '%' . preg_replace('!\*+!', '%', $keys) . '%', 'LIKE');
33 }
34 $result = $query
35 ->fields('url_alias')
36 ->orderByHeader($header)
37 ->limit(50)
38 ->execute();
39
40 $rows = array();
41 $destination = drupal_get_destination();
42 foreach ($result as $data) {
43 $row = array();
44 $row['data']['alias'] = l($data->alias, $data->source);
45 $row['data']['source'] = l($data->source, $data->source, array('alias' => TRUE));
46 if ($multilanguage) {
47 $row['data']['language'] = module_invoke('locale', 'language_name', $data->language);
48 }
49
50 $operations = array();
51 $operations['edit'] = array(
52 'title' => t('edit'),
53 'href' => "admin/config/search/path/edit/$data->pid",
54 'query' => $destination,
55 );
56 $operations['delete'] = array(
57 'title' => t('delete'),
58 'href' => "admin/config/search/path/delete/$data->pid",
59 'query' => $destination,
60 );
61 $row['data']['operations'] = array(
62 'data' => array(
63 '#theme' => 'links',
64 '#links' => $operations,
65 '#attributes' => array('class' => array('links', 'inline', 'nowrap')),
66 ),
67 );
68
69 // If the system path maps to a different URL alias, highlight this table
70 // row to let the user know of old aliases.
71 if ($data->alias != drupal_get_path_alias($data->source, $data->language)) {
72 $row['class'] = array('warning');
73 }
74
75 $rows[] = $row;
76 }
77
78 $build['path_table'] = array(
79 '#theme' => 'table',
80 '#header' => $header,
81 '#rows' => $rows,
82 '#empty' => t('No URL aliases available. <a href="@link">Add URL alias</a>.', array('@link' => url('admin/config/search/path/add'))),
83 );
84 $build['path_pager'] = array('#theme' => 'pager');
85
86 return $build;
87 }
88
100 function path_admin_edit($path = array()) {
101 if ($path) {
102 drupal_set_title($path['alias']);
103 $output = drupal_get_form('path_admin_form', $path);
104 }
105 else {
106 $output = drupal_get_form('path_admin_form');
107 }
108
109 return $output;
110 }
111
123 function path_admin_form($form, &$form_state, $path = array('source' => '', 'alias' => '', 'language' => LANGUAGE_NONE, 'pid' => NULL)) {
124 $form['source'] = array(
125 '#type' => 'textfield',
126 '#title' => t('Existing system path'),
127 '#default_value' => $path['source'],
128 '#maxlength' => 255,
129 '#size' => 45,
130 '#description' => t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1.'),
131 '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
132 '#required' => TRUE,
133 );
134 $form['alias'] = array(
135 '#type' => 'textfield',
136 '#title' => t('Path alias'),
137 '#default_value' => $path['alias'],
138 '#maxlength' => 255,
139 '#size' => 45,
140 '#description' => t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
141 '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
142 '#required' => TRUE,
143 );
144
145 // This will be a hidden value unless locale module is enabled.
146 $form['language'] = array(
147 '#type' => 'value',
148 '#value' => $path['language']
149 );
150
151 $form['actions'] = array('#type' => 'actions');
152 $form['actions']['submit'] = array(
153 '#type' => 'submit',
154 '#value' => t('Save'),
155 );
156 if ($path['pid']) {
157 $form['pid'] = array(
158 '#type' => 'hidden',
159 '#value' => $path['pid'],
160 );
161 $form['actions']['delete'] = array(
162 '#type' => 'submit',
163 '#value' => t('Delete'),
164 '#submit' => array('path_admin_form_delete_submit'),
165 );
166 }
167
168 return $form;
169 }
170
177 function path_admin_form_delete_submit($form, &$form_state) {
178 $destination = array();
179 if (isset($_GET['destination'])) {
180 $destination = drupal_get_destination();
181 unset($_GET['destination']);
182 }
183 $form_state['redirect'] = array('admin/config/search/path/delete/' . $form_state['values']['pid'], array('query' => $destination));
184 }
185
192 function path_admin_form_validate($form, &$form_state) {
193 $source = &$form_state['values']['source'];
194 $source = drupal_get_normal_path($source);
195 $alias = $form_state['values']['alias'];
196 $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
197 // Language is only set if locale module is enabled, otherwise save for all languages.
198 $language = isset($form_state['values']['language']) ? $form_state['values']['language'] : LANGUAGE_NONE;
199
200 $has_alias = db_query("SELECT COUNT(alias) FROM {url_alias} WHERE pid <> :pid AND alias = :alias AND language = :language", array(
201 ':pid' => $pid,
202 ':alias' => $alias,
203 ':language' => $language,
204 ))
205 ->fetchField();
206
207 if ($has_alias) {
208 form_set_error('alias', t('The alias %alias is already in use in this language.', array('%alias' => $alias)));
209 }
210 if (!drupal_valid_path($source)) {
211 form_set_error('source', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $source)));
212 }
213 }
214
221 function path_admin_form_submit($form, &$form_state) {
222 // Remove unnecessary values.
223 form_state_values_clean($form_state);
224
225 path_save($form_state['values']);
226
227 drupal_set_message(t('The alias has been saved.'));
228 $form_state['redirect'] = 'admin/config/search/path';
229 }
230
239 function path_admin_delete_confirm($form, &$form_state, $path) {
240 if (user_access('administer url aliases')) {
241 $form_state['path'] = $path;
242 return confirm_form(
243 $form,
244 t('Are you sure you want to delete path alias %title?',
245 array('%title' => $path['alias'])),
246 'admin/config/search/path'
247 );
248 }
249 return array();
250 }
251
255 function path_admin_delete_confirm_submit($form, &$form_state) {
256 if ($form_state['values']['confirm']) {
257 path_delete($form_state['path']['pid']);
258 $form_state['redirect'] = 'admin/config/search/path';
259 }
260 }
261
269 function path_admin_filter_form($form, &$form_state, $keys = '') {
270 $form['#attributes'] = array('class' => array('search-form'));
271 $form['basic'] = array('#type' => 'fieldset',
272 '#title' => t('Filter aliases'),
273 '#attributes' => array('class' => array('container-inline')),
274 );
275 $form['basic']['filter'] = array(
276 '#type' => 'textfield',
277 '#title' => 'Path alias',
278 '#title_display' => 'invisible',
279 '#default_value' => $keys,
280 '#maxlength' => 128,
281 '#size' => 25,
282 );
283 $form['basic']['submit'] = array(
284 '#type' => 'submit',
285 '#value' => t('Filter'),
286 '#submit' => array('path_admin_filter_form_submit_filter'),
287 );
288 if ($keys) {
289 $form['basic']['reset'] = array(
290 '#type' => 'submit',
291 '#value' => t('Reset'),
292 '#submit' => array('path_admin_filter_form_submit_reset'),
293 );
294 }
295 return $form;
296 }
297
303 function path_admin_filter_form_submit_filter($form, &$form_state) {
304 $form_state['redirect'] = 'admin/config/search/path/list/' . trim($form_state['values']['filter']);
305 }
306
312 function path_admin_filter_form_submit_reset($form, &$form_state) {
313 $form_state['redirect'] = 'admin/config/search/path/list';
314 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
path_admin_filter_form
path_admin_filter_form($form, &$form_state, $keys= '')
Definition: path.admin.inc:269
path_admin_filter_form_submit_reset
path_admin_filter_form_submit_reset($form, &$form_state)
Definition: path.admin.inc:312
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_valid_path
drupal_valid_path($path, $dynamic_allowed=FALSE)
Definition: path.inc:553
form_state_values_clean
form_state_values_clean(&$form_state)
Definition: form.inc:2159
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
path_admin_form_delete_submit
path_admin_form_delete_submit($form, &$form_state)
Definition: path.admin.inc:177
path_admin_delete_confirm
path_admin_delete_confirm($form, &$form_state, $path)
Definition: path.admin.inc:239
$header
print $header
Definition: forum-topic-list.tpl.php:42
path_admin_form
path_admin_form($form, &$form_state, $path=array('source'=> '', 'alias'=> '', 'language'=> LANGUAGE_NONE, 'pid'=> NULL))
Definition: path.admin.inc:123
module_exists
module_exists($module)
Definition: module.inc:274
path_admin_overview
path_admin_overview($keys=NULL)
Definition: path.admin.inc:14
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
drupal_get_path_alias
drupal_get_path_alias($path=NULL, $path_language=NULL)
Definition: path.inc:235
path_admin_edit
path_admin_edit($path=array())
Definition: path.admin.inc:100
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
path_admin_form_validate
path_admin_form_validate($form, &$form_state)
Definition: path.admin.inc:192
path_delete
path_delete($criteria)
Definition: path.inc:463
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
drupal_get_normal_path
drupal_get_normal_path($path, $path_language=NULL)
Definition: path.inc:259
$output
$output
Definition: authorize.php:93
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
path_save
path_save(&$path)
Definition: path.inc:433
path_admin_delete_confirm_submit
path_admin_delete_confirm_submit($form, &$form_state)
Definition: path.admin.inc:255
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
$row
$row
Definition: block-admin-display-form.tpl.php:47
path_admin_filter_form_submit_filter
path_admin_filter_form_submit_filter($form, &$form_state)
Definition: path.admin.inc:303
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
path_admin_form_submit
path_admin_form_submit($form, &$form_state)
Definition: path.admin.inc:221
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/cache.inc Source File

  • includes
cache.inc
Go to the documentation of this file.
1 <?php
2
22 function _cache_get_object($bin) {
23 // We do not use drupal_static() here because we do not want to change the
24 // storage of a cache bin mid-request.
25 static $cache_objects;
26 if (!isset($cache_objects[$bin])) {
27 $class = variable_get('cache_class_' . $bin);
28 if (!isset($class)) {
29 $class = variable_get('cache_default_class', 'DrupalDatabaseCache');
30 }
31 $cache_objects[$bin] = new $class($bin);
32 }
33 return $cache_objects[$bin];
34 }
35
55 function cache_get($cid, $bin = 'cache') {
56 return _cache_get_object($bin)->get($cid);
57 }
58
71 function cache_get_multiple(array &$cids, $bin = 'cache') {
72 return _cache_get_object($bin)->getMultiple($cids);
73 }
74
133 function cache_set($cid, $data, $bin = 'cache', $expire = CACHE_PERMANENT) {
134 return _cache_get_object($bin)->set($cid, $data, $expire);
135 }
136
155 function cache_clear_all($cid = NULL, $bin = NULL, $wildcard = FALSE) {
156 if (!isset($cid) && !isset($bin)) {
157 // Clear the block cache first, so stale data will
158 // not end up in the page cache.
159 if (module_exists('block')) {
160 cache_clear_all(NULL, 'cache_block');
161 }
162 cache_clear_all(NULL, 'cache_page');
163 return;
164 }
165 return _cache_get_object($bin)->clear($cid, $wildcard);
166 }
167
180 function cache_is_empty($bin) {
181 return _cache_get_object($bin)->isEmpty();
182 }
183
221 interface DrupalCacheInterface {
222
235 function get($cid);
236
248 function getMultiple(&$cids);
249
268 function set($cid, $data, $expire = CACHE_PERMANENT);
269
270
287 function clear($cid = NULL, $wildcard = FALSE);
288
298 function isEmpty();
299 }
300
307 class DrupalDatabaseCache implements DrupalCacheInterface {
308 protected $bin;
309
316 function __construct($bin) {
317 $this->bin = $bin;
318 }
319
323 function get($cid) {
324 $cids = array($cid);
325 $cache = $this->getMultiple($cids);
326 return reset($cache);
327 }
328
332 function getMultiple(&$cids) {
333 try {
334 // Garbage collection necessary when enforcing a minimum cache lifetime.
335 $this->garbageCollection($this->bin);
336
337 // When serving cached pages, the overhead of using db_select() was found
338 // to add around 30% overhead to the request. Since $this->bin is a
339 // variable, this means the call to db_query() here uses a concatenated
340 // string. This is highly discouraged under any other circumstances, and
341 // is used here only due to the performance overhead we would incur
342 // otherwise. When serving an uncached page, the overhead of using
343 // db_select() is a much smaller proportion of the request.
344 $result = db_query('SELECT cid, data, created, expire, serialized FROM {' . db_escape_table($this->bin) . '} WHERE cid IN (:cids)', array(':cids' => $cids));
345 $cache = array();
346 foreach ($result as $item) {
347 $item = $this->prepareItem($item);
348 if ($item) {
349 $cache[$item->cid] = $item;
350 }
351 }
352 $cids = array_diff($cids, array_keys($cache));
353 return $cache;
354 }
355 catch (Exception $e) {
356 // If the database is never going to be available, cache requests should
357 // return FALSE in order to allow exception handling to occur.
358 return array();
359 }
360 }
361
368 protected function garbageCollection() {
369 $cache_lifetime = variable_get('cache_lifetime', 0);
370
371 // Clean-up the per-user cache expiration session data, so that the session
372 // handler can properly clean-up the session data for anonymous users.
373 if (isset($_SESSION['cache_expiration'])) {
374 $expire = REQUEST_TIME - $cache_lifetime;
375 foreach ($_SESSION['cache_expiration'] as $bin => $timestamp) {
376 if ($timestamp < $expire) {
377 unset($_SESSION['cache_expiration'][$bin]);
378 }
379 }
380 if (!$_SESSION['cache_expiration']) {
381 unset($_SESSION['cache_expiration']);
382 }
383 }
384
385 // Garbage collection of temporary items is only necessary when enforcing
386 // a minimum cache lifetime.
387 if (!$cache_lifetime) {
388 return;
389 }
390 // When cache lifetime is in force, avoid running garbage collection too
391 // often since this will remove temporary cache items indiscriminately.
392 $cache_flush = variable_get('cache_flush_' . $this->bin, 0);
393 if ($cache_flush && ($cache_flush + $cache_lifetime <= REQUEST_TIME)) {
394 // Reset the variable immediately to prevent a meltdown in heavy load situations.
395 variable_set('cache_flush_' . $this->bin, 0);
396 // Time to flush old cache data
397 db_delete($this->bin)
398 ->condition('expire', CACHE_PERMANENT, '<>')
399 ->condition('expire', $cache_flush, '<=')
400 ->execute();
401 }
402 }
403
417 protected function prepareItem($cache) {
418 global $user;
419
420 if (!isset($cache->data)) {
421 return FALSE;
422 }
423 // If the cached data is temporary and subject to a per-user minimum
424 // lifetime, compare the cache entry timestamp with the user session
425 // cache_expiration timestamp. If the cache entry is too old, ignore it.
426 if ($cache->expire != CACHE_PERMANENT && variable_get('cache_lifetime', 0) && isset($_SESSION['cache_expiration'][$this->bin]) && $_SESSION['cache_expiration'][$this->bin] > $cache->created) {
427 // Ignore cache data that is too old and thus not valid for this user.
428 return FALSE;
429 }
430
431 // If the data is permanent or not subject to a minimum cache lifetime,
432 // unserialize and return the cached data.
433 if ($cache->serialized) {
434 $cache->data = unserialize($cache->data);
435 }
436
437 return $cache;
438 }
439
443 function set($cid, $data, $expire = CACHE_PERMANENT) {
444 $fields = array(
445 'serialized' => 0,
446 'created' => REQUEST_TIME,
447 'expire' => $expire,
448 );
449 if (!is_string($data)) {
450 $fields['data'] = serialize($data);
451 $fields['serialized'] = 1;
452 }
453 else {
454 $fields['data'] = $data;
455 $fields['serialized'] = 0;
456 }
457
458 try {
459 db_merge($this->bin)
460 ->key(array('cid' => $cid))
461 ->fields($fields)
462 ->execute();
463 }
464 catch (Exception $e) {
465 // The database may not be available, so we'll ignore cache_set requests.
466 }
467 }
468
472 function clear($cid = NULL, $wildcard = FALSE) {
473 global $user;
474
475 if (empty($cid)) {
476 if (variable_get('cache_lifetime', 0)) {
477 // We store the time in the current user's session. We then simulate
478 // that the cache was flushed for this user by not returning cached
479 // data that was cached before the timestamp.
480 $_SESSION['cache_expiration'][$this->bin] = REQUEST_TIME;
481
482 $cache_flush = variable_get('cache_flush_' . $this->bin, 0);
483 if ($cache_flush == 0) {
484 // This is the first request to clear the cache, start a timer.
485 variable_set('cache_flush_' . $this->bin, REQUEST_TIME);
486 }
487 elseif (REQUEST_TIME > ($cache_flush + variable_get('cache_lifetime', 0))) {
488 // Clear the cache for everyone, cache_lifetime seconds have
489 // passed since the first request to clear the cache.
490 db_delete($this->bin)
491 ->condition('expire', CACHE_PERMANENT, '<>')
492 ->condition('expire', REQUEST_TIME, '<')
493 ->execute();
494 variable_set('cache_flush_' . $this->bin, 0);
495 }
496 }
497 else {
498 // No minimum cache lifetime, flush all temporary cache entries now.
499 db_delete($this->bin)
500 ->condition('expire', CACHE_PERMANENT, '<>')
501 ->condition('expire', REQUEST_TIME, '<')
502 ->execute();
503 }
504 }
505 else {
506 if ($wildcard) {
507 if ($cid == '*') {
508 // Check if $this->bin is a cache table before truncating. Other
509 // cache_clear_all() operations throw a PDO error in this situation,
510 // so we don't need to verify them first. This ensures that non-cache
511 // tables cannot be truncated accidentally.
512 if ($this->isValidBin()) {
513 db_truncate($this->bin)->execute();
514 }
515 else {
516 throw new Exception(t('Invalid or missing cache bin specified: %bin', array('%bin' => $this->bin)));
517 }
518 }
519 else {
520 db_delete($this->bin)
521 ->condition('cid', db_like($cid) . '%', 'LIKE')
522 ->execute();
523 }
524 }
525 elseif (is_array($cid)) {
526 // Delete in chunks when a large array is passed.
527 do {
528 db_delete($this->bin)
529 ->condition('cid', array_splice($cid, 0, 1000), 'IN')
530 ->execute();
531 }
532 while (count($cid));
533 }
534 else {
535 db_delete($this->bin)
536 ->condition('cid', $cid)
537 ->execute();
538 }
539 }
540 }
541
545 function isEmpty() {
546 $this->garbageCollection();
547 $query = db_select($this->bin);
548 $query->addExpression('1');
549 $result = $query->range(0, 1)
550 ->execute()
551 ->fetchField();
552 return empty($result);
553 }
554
563 function isValidBin() {
564 if ($this->bin == 'cache' || substr($this->bin, 0, 6) == 'cache_') {
565 // Skip schema check for bins with standard table names.
566 return TRUE;
567 }
568 // These fields are required for any cache table.
569 $fields = array('cid', 'data', 'expire', 'created', 'serialized');
570 // Load the table schema.
571 $schema = drupal_get_schema($this->bin);
572 // Confirm that all fields are present.
573 return isset($schema['fields']) && !array_diff($fields, array_keys($schema['fields']));
574 }
575 }
DrupalDatabaseCache\prepareItem
prepareItem($cache)
Definition: cache.inc:417
DrupalDatabaseCache\isValidBin
isValidBin()
Definition: cache.inc:563
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
DrupalCacheInterface\set
set($cid, $data, $expire=CACHE_PERMANENT)
Exception
DrupalDatabaseCache\$bin
$bin
Definition: cache.inc:308
DrupalDatabaseCache\clear
clear($cid=NULL, $wildcard=FALSE)
Definition: cache.inc:472
module_exists
module_exists($module)
Definition: module.inc:274
_cache_get_object
_cache_get_object($bin)
Definition: cache.inc:22
cache_get_multiple
cache_get_multiple(array &$cids, $bin= 'cache')
Definition: cache.inc:71
DrupalDatabaseCache\getMultiple
getMultiple(&$cids)
Definition: cache.inc:332
DrupalCacheInterface
Definition: cache.inc:221
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
drupal_get_schema
drupal_get_schema($table=NULL, $rebuild=FALSE)
Definition: bootstrap.inc:2940
DrupalDatabaseCache\__construct
__construct($bin)
Definition: cache.inc:316
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
DrupalCacheInterface\clear
clear($cid=NULL, $wildcard=FALSE)
DrupalDatabaseCache\isEmpty
isEmpty()
Definition: cache.inc:545
db_like
db_like($string)
Definition: database.inc:2610
DrupalCacheInterface\getMultiple
getMultiple(&$cids)
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
DrupalCacheInterface\isEmpty
isEmpty()
db_escape_table
db_escape_table($table)
Definition: database.inc:2566
CACHE_PERMANENT
const CACHE_PERMANENT
Definition: bootstrap.inc:48
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
DrupalDatabaseCache\set
set($cid, $data, $expire=CACHE_PERMANENT)
Definition: cache.inc:443
db_truncate
db_truncate($table, array $options=array())
Definition: database.inc:2495
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
DrupalDatabaseCache\garbageCollection
garbageCollection()
Definition: cache.inc:368
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
DrupalDatabaseCache
Definition: cache.inc:307
cache_is_empty
cache_is_empty($bin)
Definition: cache.inc:180
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/aggregator/aggregator.fetcher.inc Source File

  • modules
  • aggregator
aggregator.fetcher.inc
Go to the documentation of this file.
1 <?php
2
11 function aggregator_aggregator_fetch_info() {
12 return array(
13 'title' => t('Default fetcher'),
14 'description' => t('Downloads data from a URL using Drupal\'s HTTP request handler.'),
15 );
16 }
17
21 function aggregator_aggregator_fetch($feed) {
22 $feed->source_string = FALSE;
23
24 // Generate conditional GET headers.
25 $headers = array();
26 if ($feed->etag) {
27 $headers['If-None-Match'] = $feed->etag;
28 }
29 if ($feed->modified) {
30 $headers['If-Modified-Since'] = gmdate(DATE_RFC1123, $feed->modified);
31 }
32
33 // Request feed.
34 $result = drupal_http_request($feed->url, array('headers' => $headers));
35
36 // Process HTTP response code.
37 switch ($result->code) {
38 case 304:
39 break;
40 case 301:
41 $feed->url = $result->redirect_url;
42 // Do not break here.
43 case 200:
44 case 302:
45 case 307:
46 if (!isset($result->data)) {
47 $result->data = '';
48 }
49 if (!isset($result->headers)) {
50 $result->headers = array();
51 }
52 $feed->source_string = $result->data;
53 $feed->http_headers = $result->headers;
54 break;
55 default:
56 watchdog('aggregator', 'The feed from %site seems to be broken, due to "%error".', array('%site' => $feed->title, '%error' => $result->code . ' ' . $result->error), WATCHDOG_WARNING);
57 drupal_set_message(t('The feed from %site seems to be broken, because of error "%error".', array('%site' => $feed->title, '%error' => $result->code . ' ' . $result->error)));
58 }
59
60 return $feed->source_string === FALSE ? FALSE : TRUE;
61 }
drupal_http_request
drupal_http_request($url, array $options=array())
Definition: common.inc:787
aggregator_aggregator_fetch_info
aggregator_aggregator_fetch_info()
Definition: aggregator.fetcher.inc:11
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
WATCHDOG_WARNING
const WATCHDOG_WARNING
Definition: bootstrap.inc:98
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
aggregator_aggregator_fetch
aggregator_aggregator_fetch($feed)
Definition: aggregator.fetcher.inc:21
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/session.inc Source File

  • includes
session.inc
Go to the documentation of this file.
1 <?php
2
31 function _drupal_session_open() {
32 return TRUE;
33 }
34
47 function _drupal_session_close() {
48 return TRUE;
49 }
50
70 function _drupal_session_read($sid) {
71 global $user, $is_https;
72
73 // Write and Close handlers are called after destructing objects
74 // since PHP 5.0.5.
75 // Thus destructors can use sessions but session handler can't use objects.
76 // So we are moving session closure before destructing objects.
77 drupal_register_shutdown_function('session_write_close');
78
79 // Handle the case of first time visitors and clients that don't store
80 // cookies (eg. web crawlers).
81 $insecure_session_name = substr(session_name(), 1);
82 if (!isset($_COOKIE[session_name()]) && !isset($_COOKIE[$insecure_session_name])) {
83 $user = drupal_anonymous_user();
84 return '';
85 }
86
87 // Otherwise, if the session is still active, we have a record of the
88 // client's session in the database. If it's HTTPS then we are either have
89 // a HTTPS session or we are about to log in so we check the sessions table
90 // for an anonymous session with the non-HTTPS-only cookie.
91 if ($is_https) {
92 $user = db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.ssid = :ssid", array(':ssid' => $sid))->fetchObject();
93 if (!$user) {
94 if (isset($_COOKIE[$insecure_session_name])) {
95 $user = db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid AND s.uid = 0", array(
96 ':sid' => $_COOKIE[$insecure_session_name]))
97 ->fetchObject();
98 }
99 }
100 }
101 else {
102 $user = db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid", array(':sid' => $sid))->fetchObject();
103 }
104
105 // We found the client's session record and they are an authenticated,
106 // active user.
107 if ($user && $user->uid > 0 && $user->status == 1) {
108 // This is done to unserialize the data member of $user.
109 $user->data = unserialize($user->data);
110
111 // Add roles element to $user.
112 $user->roles = array();
113 $user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
114 $user->roles += db_query("SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = :uid", array(':uid' => $user->uid))->fetchAllKeyed(0, 1);
115 }
116 elseif ($user) {
117 // The user is anonymous or blocked. Only preserve two fields from the
118 // {sessions} table.
119 $account = drupal_anonymous_user();
120 $account->session = $user->session;
121 $account->timestamp = $user->timestamp;
122 $user = $account;
123 }
124 else {
125 // The session has expired.
126 $user = drupal_anonymous_user();
127 $user->session = '';
128 }
129
130 // Store the session that was read for comparison in _drupal_session_write().
131 $last_read = &drupal_static('drupal_session_last_read');
132 $last_read = array(
133 'sid' => $sid,
134 'value' => $user->session,
135 );
136
137 return $user->session;
138 }
139
158 function _drupal_session_write($sid, $value) {
159 global $user, $is_https;
160
161 // The exception handler is not active at this point, so we need to do it
162 // manually.
163 try {
164 if (!drupal_save_session()) {
165 // We don't have anything to do if we are not allowed to save the session.
166 return;
167 }
168
169 // Check whether $_SESSION has been changed in this request.
170 $last_read = &drupal_static('drupal_session_last_read');
171 $is_changed = !isset($last_read) || $last_read['sid'] != $sid || $last_read['value'] !== $value;
172
173 // For performance reasons, do not update the sessions table, unless
174 // $_SESSION has changed or more than 180 has passed since the last update.
175 if ($is_changed || !isset($user->timestamp) || REQUEST_TIME - $user->timestamp > variable_get('session_write_interval', 180)) {
176 // Either ssid or sid or both will be added from $key below.
177 $fields = array(
178 'uid' => $user->uid,
179 'cache' => isset($user->cache) ? $user->cache : 0,
180 'hostname' => ip_address(),
181 'session' => $value,
182 'timestamp' => REQUEST_TIME,
183 );
184
185 // Use the session ID as 'sid' and an empty string as 'ssid' by default.
186 // _drupal_session_read() does not allow empty strings so that's a safe
187 // default.
188 $key = array('sid' => $sid, 'ssid' => '');
189 // On HTTPS connections, use the session ID as both 'sid' and 'ssid'.
190 if ($is_https) {
191 $key['ssid'] = $sid;
192 // The "secure pages" setting allows a site to simultaneously use both
193 // secure and insecure session cookies. If enabled and both cookies are
194 // presented then use both keys.
195 if (variable_get('https', FALSE)) {
196 $insecure_session_name = substr(session_name(), 1);
197 if (isset($_COOKIE[$insecure_session_name])) {
198 $key['sid'] = $_COOKIE[$insecure_session_name];
199 }
200 }
201 }
202 elseif (variable_get('https', FALSE)) {
203 unset($key['ssid']);
204 }
205
206 db_merge('sessions')
207 ->key($key)
208 ->fields($fields)
209 ->execute();
210 }
211
212 // Likewise, do not update access time more than once per 180 seconds.
213 if ($user->uid && REQUEST_TIME - $user->access > variable_get('session_write_interval', 180)) {
214 db_update('users')
215 ->fields(array(
216 'access' => REQUEST_TIME
217 ))
218 ->condition('uid', $user->uid)
219 ->execute();
220 }
221
222 return TRUE;
223 }
224 catch (Exception $exception) {
225 require_once DRUPAL_ROOT . '/includes/errors.inc';
226 // If we are displaying errors, then do so with no possibility of a further
227 // uncaught exception being thrown.
228 if (error_displayable()) {
229 print '<h1>Uncaught exception thrown in session handler.</h1>';
230 print '<p>' . _drupal_render_exception_safe($exception) . '</p><hr />';
231 }
232 return FALSE;
233 }
234 }
235
239 function drupal_session_initialize() {
240 global $user, $is_https;
241
242 session_set_save_handler('_drupal_session_open', '_drupal_session_close', '_drupal_session_read', '_drupal_session_write', '_drupal_session_destroy', '_drupal_session_garbage_collection');
243
244 // We use !empty() in the following check to ensure that blank session IDs
245 // are not valid.
246 if (!empty($_COOKIE[session_name()]) || ($is_https && variable_get('https', FALSE) && !empty($_COOKIE[substr(session_name(), 1)]))) {
247 // If a session cookie exists, initialize the session. Otherwise the
248 // session is only started on demand in drupal_session_commit(), making
249 // anonymous users not use a session cookie unless something is stored in
250 // $_SESSION. This allows HTTP proxies to cache anonymous pageviews.
251 drupal_session_start();
252 if (!empty($user->uid) || !empty($_SESSION)) {
253 drupal_page_is_cacheable(FALSE);
254 }
255 }
256 else {
257 // Set a session identifier for this request. This is necessary because
258 // we lazily start sessions at the end of this request, and some
259 // processes (like drupal_get_token()) needs to know the future
260 // session ID in advance.
261 $GLOBALS['lazy_session'] = TRUE;
262 $user = drupal_anonymous_user();
263 // Less random sessions (which are much faster to generate) are used for
264 // anonymous users than are generated in drupal_session_regenerate() when
265 // a user becomes authenticated.
266 session_id(drupal_random_key());
267 if ($is_https && variable_get('https', FALSE)) {
268 $insecure_session_name = substr(session_name(), 1);
269 $session_id = drupal_random_key();
270 $_COOKIE[$insecure_session_name] = $session_id;
271 }
272 }
273 date_default_timezone_set(drupal_get_user_timezone());
274 }
275
281 function drupal_session_start() {
282 // Command line clients do not support cookies nor sessions.
283 if (!drupal_session_started() && !drupal_is_cli()) {
284 // Save current session data before starting it, as PHP will destroy it.
285 $session_data = isset($_SESSION) ? $_SESSION : NULL;
286
287 session_start();
288 drupal_session_started(TRUE);
289
290 // Restore session data.
291 if (!empty($session_data)) {
292 $_SESSION += $session_data;
293 }
294 }
295 }
296
302 function drupal_session_commit() {
303 global $user, $is_https;
304
305 if (!drupal_save_session()) {
306 // We don't have anything to do if we are not allowed to save the session.
307 return;
308 }
309
310 if (empty($user->uid) && empty($_SESSION)) {
311 // There is no session data to store, destroy the session if it was
312 // previously started.
313 if (drupal_session_started()) {
314 session_destroy();
315 }
316 }
317 else {
318 // There is session data to store. Start the session if it is not already
319 // started.
320 if (!drupal_session_started()) {
321 drupal_session_start();
322 if ($is_https && variable_get('https', FALSE)) {
323 $insecure_session_name = substr(session_name(), 1);
324 $params = session_get_cookie_params();
325 $expire = $params['lifetime'] ? REQUEST_TIME + $params['lifetime'] : 0;
326 setcookie($insecure_session_name, $_COOKIE[$insecure_session_name], $expire, $params['path'], $params['domain'], FALSE, $params['httponly']);
327 }
328 }
329 // Write the session data.
330 session_write_close();
331 }
332 }
333
337 function drupal_session_started($set = NULL) {
338 static $session_started = FALSE;
339 if (isset($set)) {
340 $session_started = $set;
341 }
342 return $session_started && session_id();
343 }
344
350 function drupal_session_regenerate() {
351 global $user, $is_https;
352 // Nothing to do if we are not allowed to change the session.
353 if (!drupal_save_session()) {
354 return;
355 }
356
357 if ($is_https && variable_get('https', FALSE)) {
358 $insecure_session_name = substr(session_name(), 1);
359 if (!isset($GLOBALS['lazy_session']) && isset($_COOKIE[$insecure_session_name])) {
360 $old_insecure_session_id = $_COOKIE[$insecure_session_name];
361 }
362 $params = session_get_cookie_params();
363 $session_id = drupal_random_key();
364 // If a session cookie lifetime is set, the session will expire
365 // $params['lifetime'] seconds from the current request. If it is not set,
366 // it will expire when the browser is closed.
367 $expire = $params['lifetime'] ? REQUEST_TIME + $params['lifetime'] : 0;
368 setcookie($insecure_session_name, $session_id, $expire, $params['path'], $params['domain'], FALSE, $params['httponly']);
369 $_COOKIE[$insecure_session_name] = $session_id;
370 }
371
372 if (drupal_session_started()) {
373 $old_session_id = session_id();
374 }
375 session_id(drupal_random_key());
376
377 if (isset($old_session_id)) {
378 $params = session_get_cookie_params();
379 $expire = $params['lifetime'] ? REQUEST_TIME + $params['lifetime'] : 0;
380 setcookie(session_name(), session_id(), $expire, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
381 $fields = array('sid' => session_id());
382 if ($is_https) {
383 $fields['ssid'] = session_id();
384 // If the "secure pages" setting is enabled, use the newly-created
385 // insecure session identifier as the regenerated sid.
386 if (variable_get('https', FALSE)) {
387 $fields['sid'] = $session_id;
388 }
389 }
390 db_update('sessions')
391 ->fields($fields)
392 ->condition($is_https ? 'ssid' : 'sid', $old_session_id)
393 ->execute();
394 }
395 elseif (isset($old_insecure_session_id)) {
396 // If logging in to the secure site, and there was no active session on the
397 // secure site but a session was active on the insecure site, update the
398 // insecure session with the new session identifiers.
399 db_update('sessions')
400 ->fields(array('sid' => $session_id, 'ssid' => session_id()))
401 ->condition('sid', $old_insecure_session_id)
402 ->execute();
403 }
404 else {
405 // Start the session when it doesn't exist yet.
406 // Preserve the logged in user, as it will be reset to anonymous
407 // by _drupal_session_read.
408 $account = $user;
409 drupal_session_start();
410 $user = $account;
411 }
412 date_default_timezone_set(drupal_get_user_timezone());
413 }
414
423 function _drupal_session_destroy($sid) {
424 global $user, $is_https;
425
426 // Nothing to do if we are not allowed to change the session.
427 if (!drupal_save_session()) {
428 return;
429 }
430
431 // Delete session data.
432 db_delete('sessions')
433 ->condition($is_https ? 'ssid' : 'sid', $sid)
434 ->execute();
435
436 // Reset $_SESSION and $user to prevent a new session from being started
437 // in drupal_session_commit().
438 $_SESSION = array();
439 $user = drupal_anonymous_user();
440
441 // Unset the session cookies.
442 _drupal_session_delete_cookie(session_name());
443 if ($is_https) {
444 _drupal_session_delete_cookie(substr(session_name(), 1), FALSE);
445 }
446 elseif (variable_get('https', FALSE)) {
447 _drupal_session_delete_cookie('S' . session_name(), TRUE);
448 }
449 }
450
459 function _drupal_session_delete_cookie($name, $secure = NULL) {
460 global $is_https;
461 if (isset($_COOKIE[$name]) || (!$is_https && $secure === TRUE)) {
462 $params = session_get_cookie_params();
463 if ($secure !== NULL) {
464 $params['secure'] = $secure;
465 }
466 setcookie($name, '', REQUEST_TIME - 3600, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
467 unset($_COOKIE[$name]);
468 }
469 }
470
477 function drupal_session_destroy_uid($uid) {
478 // Nothing to do if we are not allowed to change the session.
479 if (!drupal_save_session()) {
480 return;
481 }
482
483 db_delete('sessions')
484 ->condition('uid', $uid)
485 ->execute();
486 }
487
497 function _drupal_session_garbage_collection($lifetime) {
498 // Be sure to adjust 'php_value session.gc_maxlifetime' to a large enough
499 // value. For example, if you want user sessions to stay in your database
500 // for three weeks before deleting them, you need to set gc_maxlifetime
501 // to '1814400'. At that value, only after a user doesn't log in after
502 // three weeks (1814400 seconds) will his/her session be removed.
503 db_delete('sessions')
504 ->condition('timestamp', REQUEST_TIME - $lifetime, '<')
505 ->execute();
506 return TRUE;
507 }
508
524 function drupal_save_session($status = NULL) {
525 // PHP session ID, session, and cookie handling happens in the global scope.
526 // This value has to persist across calls to drupal_static_reset(), since a
527 // potentially wrong or disallowed session would be written otherwise.
528 static $save_session = TRUE;
529 if (isset($status)) {
530 $save_session = $status;
531 }
532 return $save_session;
533 }
drupal_session_destroy_uid
drupal_session_destroy_uid($uid)
Definition: session.inc:477
_drupal_session_delete_cookie
_drupal_session_delete_cookie($name, $secure=NULL)
Definition: session.inc:459
drupal_session_started
drupal_session_started($set=NULL)
Definition: session.inc:337
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
drupal_page_is_cacheable
drupal_page_is_cacheable($allow_caching=NULL)
Definition: bootstrap.inc:1048
drupal_get_user_timezone
drupal_get_user_timezone()
Definition: bootstrap.inc:2271
drupal_anonymous_user
drupal_anonymous_user()
Definition: bootstrap.inc:2152
_drupal_render_exception_safe
_drupal_render_exception_safe($exception)
Definition: errors.inc:134
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
drupal_save_session
drupal_save_session($status=NULL)
Definition: session.inc:524
$name
print $name
Definition: profile-listing.tpl.php:43
drupal_session_start
drupal_session_start()
Definition: session.inc:281
Exception
_drupal_session_open
_drupal_session_open()
Definition: session.inc:31
_drupal_session_close
_drupal_session_close()
Definition: session.inc:47
ip_address
ip_address()
Definition: bootstrap.inc:2890
print
print
Definition: php-2.php:2
drupal_session_commit
drupal_session_commit()
Definition: session.inc:302
drupal_random_key
drupal_random_key($byte_count=32)
Definition: bootstrap.inc:1945
drupal_session_initialize
drupal_session_initialize()
Definition: session.inc:239
$value
print $value
Definition: user-profile-item.tpl.php:26
DRUPAL_AUTHENTICATED_RID
const DRUPAL_AUTHENTICATED_RID
Definition: bootstrap.inc:167
error_displayable
error_displayable($error=NULL)
Definition: errors.inc:151
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
drupal_is_cli
drupal_is_cli()
Definition: bootstrap.inc:3381
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
_drupal_session_garbage_collection
_drupal_session_garbage_collection($lifetime)
Definition: session.inc:497
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
_drupal_session_read
_drupal_session_read($sid)
Definition: session.inc:70
_drupal_session_write
_drupal_session_write($sid, $value)
Definition: session.inc:158
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
drupal_register_shutdown_function
& drupal_register_shutdown_function($callback=NULL)
Definition: bootstrap.inc:3417
_drupal_session_destroy
_drupal_session_destroy($sid)
Definition: session.inc:423
drupal_session_regenerate
drupal_session_regenerate()
Definition: session.inc:350
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/standard/standard.install Source File

  • profiles
  • standard
standard.install
Go to the documentation of this file.
1 <?php
14 function standard_install() {
15 // Add text formats.
16 $filtered_html_format = array(
17 'format' => 'filtered_html',
18 'name' => 'Filtered HTML',
19 'weight' => 0,
20 'filters' => array(
21 // URL filter.
22 'filter_url' => array(
23 'weight' => 0,
24 'status' => 1,
25 ),
26 // HTML filter.
27 'filter_html' => array(
28 'weight' => 1,
29 'status' => 1,
30 ),
31 // Line break filter.
32 'filter_autop' => array(
33 'weight' => 2,
34 'status' => 1,
35 ),
36 // HTML corrector filter.
37 'filter_htmlcorrector' => array(
38 'weight' => 10,
39 'status' => 1,
40 ),
41 ),
42 );
43 $filtered_html_format = (object) $filtered_html_format;
44 filter_format_save($filtered_html_format);
45
46 $full_html_format = array(
47 'format' => 'full_html',
48 'name' => 'Full HTML',
49 'weight' => 1,
50 'filters' => array(
51 // URL filter.
52 'filter_url' => array(
53 'weight' => 0,
54 'status' => 1,
55 ),
56 // Line break filter.
57 'filter_autop' => array(
58 'weight' => 1,
59 'status' => 1,
60 ),
61 // HTML corrector filter.
62 'filter_htmlcorrector' => array(
63 'weight' => 10,
64 'status' => 1,
65 ),
66 ),
67 );
68 $full_html_format = (object) $full_html_format;
69 filter_format_save($full_html_format);
70
71 // Enable some standard blocks.
72 $default_theme = variable_get('theme_default', 'bartik');
73 $admin_theme = 'seven';
74 $blocks = array(
75 array(
76 'module' => 'system',
77 'delta' => 'main',
78 'theme' => $default_theme,
79 'status' => 1,
80 'weight' => 0,
81 'region' => 'content',
82 'pages' => '',
83 'cache' => -1,
84 ),
85 array(
86 'module' => 'search',
87 'delta' => 'form',
88 'theme' => $default_theme,
89 'status' => 1,
90 'weight' => -1,
91 'region' => 'sidebar_first',
92 'pages' => '',
93 'cache' => -1,
94 ),
95 array(
96 'module' => 'node',
97 'delta' => 'recent',
98 'theme' => $admin_theme,
99 'status' => 1,
100 'weight' => 10,
101 'region' => 'dashboard_main',
102 'pages' => '',
103 'cache' => -1,
104 ),
105 array(
106 'module' => 'user',
107 'delta' => 'login',
108 'theme' => $default_theme,
109 'status' => 1,
110 'weight' => 0,
111 'region' => 'sidebar_first',
112 'pages' => '',
113 'cache' => -1,
114 ),
115 array(
116 'module' => 'system',
117 'delta' => 'navigation',
118 'theme' => $default_theme,
119 'status' => 1,
120 'weight' => 0,
121 'region' => 'sidebar_first',
122 'pages' => '',
123 'cache' => -1,
124 ),
125 array(
126 'module' => 'system',
127 'delta' => 'powered-by',
128 'theme' => $default_theme,
129 'status' => 1,
130 'weight' => 10,
131 'region' => 'footer',
132 'pages' => '',
133 'cache' => -1,
134 ),
135 array(
136 'module' => 'system',
137 'delta' => 'help',
138 'theme' => $default_theme,
139 'status' => 1,
140 'weight' => 0,
141 'region' => 'help',
142 'pages' => '',
143 'cache' => -1,
144 ),
145 array(
146 'module' => 'system',
147 'delta' => 'main',
148 'theme' => $admin_theme,
149 'status' => 1,
150 'weight' => 0,
151 'region' => 'content',
152 'pages' => '',
153 'cache' => -1,
154 ),
155 array(
156 'module' => 'system',
157 'delta' => 'help',
158 'theme' => $admin_theme,
159 'status' => 1,
160 'weight' => 0,
161 'region' => 'help',
162 'pages' => '',
163 'cache' => -1,
164 ),
165 array(
166 'module' => 'user',
167 'delta' => 'login',
168 'theme' => $admin_theme,
169 'status' => 1,
170 'weight' => 10,
171 'region' => 'content',
172 'pages' => '',
173 'cache' => -1,
174 ),
175 array(
176 'module' => 'user',
177 'delta' => 'new',
178 'theme' => $admin_theme,
179 'status' => 1,
180 'weight' => 0,
181 'region' => 'dashboard_sidebar',
182 'pages' => '',
183 'cache' => -1,
184 ),
185 array(
186 'module' => 'search',
187 'delta' => 'form',
188 'theme' => $admin_theme,
189 'status' => 1,
190 'weight' => -10,
191 'region' => 'dashboard_sidebar',
192 'pages' => '',
193 'cache' => -1,
194 ),
195 );
196 $query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
197 foreach ($blocks as $block) {
198 $query->values($block);
199 }
200 $query->execute();
201
202 // Insert default pre-defined node types into the database. For a complete
203 // list of available node type attributes, refer to the node type API
204 // documentation at: http://api.drupal.org/api/HEAD/function/hook_node_info.
205 $types = array(
206 array(
207 'type' => 'page',
208 'name' => st('Basic page'),
209 'base' => 'node_content',
210 'description' => st("Use <em>basic pages</em> for your static content, such as an 'About us' page."),
211 'custom' => 1,
212 'modified' => 1,
213 'locked' => 0,
214 ),
215 array(
216 'type' => 'article',
217 'name' => st('Article'),
218 'base' => 'node_content',
219 'description' => st('Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.'),
220 'custom' => 1,
221 'modified' => 1,
222 'locked' => 0,
223 ),
224 );
225
226 foreach ($types as $type) {
227 $type = node_type_set_defaults($type);
228 node_type_save($type);
229 node_add_body_field($type);
230 }
231
232 // Insert default pre-defined RDF mapping into the database.
233 $rdf_mappings = array(
234 array(
235 'type' => 'node',
236 'bundle' => 'page',
237 'mapping' => array(
238 'rdftype' => array('foaf:Document'),
239 ),
240 ),
241 array(
242 'type' => 'node',
243 'bundle' => 'article',
244 'mapping' => array(
245 'field_image' => array(
246 'predicates' => array('og:image', 'rdfs:seeAlso'),
247 'type' => 'rel',
248 ),
249 'field_tags' => array(
250 'predicates' => array('dc:subject'),
251 'type' => 'rel',
252 ),
253 ),
254 ),
255 );
256 foreach ($rdf_mappings as $rdf_mapping) {
257 rdf_mapping_save($rdf_mapping);
258 }
259
260 // Default "Basic page" to not be promoted and have comments disabled.
261 variable_set('node_options_page', array('status'));
262 variable_set('comment_page', COMMENT_NODE_HIDDEN);
263
264 // Don't display date and author information for "Basic page" nodes by default.
265 variable_set('node_submitted_page', FALSE);
266
267 // Enable user picture support and set the default to a square thumbnail option.
268 variable_set('user_pictures', '1');
269 variable_set('user_picture_dimensions', '1024x1024');
270 variable_set('user_picture_file_size', '800');
271 variable_set('user_picture_style', 'thumbnail');
272
273 // Allow visitor account creation with administrative approval.
274 variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
275
276 // Create a default vocabulary named "Tags", enabled for the 'article' content type.
277 $description = st('Use tags to group articles on similar topics into categories.');
278 $vocabulary = (object) array(
279 'name' => st('Tags'),
280 'description' => $description,
281 'machine_name' => 'tags',
282 );
283 taxonomy_vocabulary_save($vocabulary);
284
285 $field = array(
286 'field_name' => 'field_' . $vocabulary->machine_name,
287 'type' => 'taxonomy_term_reference',
288 // Set cardinality to unlimited for tagging.
289 'cardinality' => FIELD_CARDINALITY_UNLIMITED,
290 'settings' => array(
291 'allowed_values' => array(
292 array(
293 'vocabulary' => $vocabulary->machine_name,
294 'parent' => 0,
295 ),
296 ),
297 ),
298 );
299 field_create_field($field);
300
301 $help = st('Enter a comma-separated list of words to describe your content.');
302 $instance = array(
303 'field_name' => 'field_' . $vocabulary->machine_name,
304 'entity_type' => 'node',
305 'label' => 'Tags',
306 'bundle' => 'article',
307 'description' => $help,
308 'widget' => array(
309 'type' => 'taxonomy_autocomplete',
310 'weight' => -4,
311 ),
312 'display' => array(
313 'default' => array(
314 'type' => 'taxonomy_term_reference_link',
315 'weight' => 10,
316 ),
317 'teaser' => array(
318 'type' => 'taxonomy_term_reference_link',
319 'weight' => 10,
320 ),
321 ),
322 );
323 field_create_instance($instance);
324
325
326 // Create an image field named "Image", enabled for the 'article' content type.
327 // Many of the following values will be defaulted, they're included here as an illustrative examples.
328 // See http://api.drupal.org/api/function/field_create_field/7
329
330 $field = array(
331 'field_name' => 'field_image',
332 'type' => 'image',
333 'cardinality' => 1,
334 'locked' => FALSE,
335 'indexes' => array('fid' => array('fid')),
336 'settings' => array(
337 'uri_scheme' => 'public',
338 'default_image' => FALSE,
339 ),
340 'storage' => array(
341 'type' => 'field_sql_storage',
342 'settings' => array(),
343 ),
344 );
345 field_create_field($field);
346
347
348 // Many of the following values will be defaulted, they're included here as an illustrative examples.
349 // See http://api.drupal.org/api/function/field_create_instance/7
350 $instance = array(
351 'field_name' => 'field_image',
352 'entity_type' => 'node',
353 'label' => 'Image',
354 'bundle' => 'article',
355 'description' => st('Upload an image to go with this article.'),
356 'required' => FALSE,
357
358 'settings' => array(
359 'file_directory' => 'field/image',
360 'file_extensions' => 'png gif jpg jpeg',
361 'max_filesize' => '',
362 'max_resolution' => '',
363 'min_resolution' => '',
364 'alt_field' => TRUE,
365 'title_field' => '',
366 ),
367
368 'widget' => array(
369 'type' => 'image_image',
370 'settings' => array(
371 'progress_indicator' => 'throbber',
372 'preview_image_style' => 'thumbnail',
373 ),
374 'weight' => -1,
375 ),
376
377 'display' => array(
378 'default' => array(
379 'label' => 'hidden',
380 'type' => 'image',
381 'settings' => array('image_style' => 'large', 'image_link' => ''),
382 'weight' => -1,
383 ),
384 'teaser' => array(
385 'label' => 'hidden',
386 'type' => 'image',
387 'settings' => array('image_style' => 'medium', 'image_link' => 'content'),
388 'weight' => -1,
389 ),
390 ),
391 );
392 field_create_instance($instance);
393
394 // Enable default permissions for system roles.
395 $filtered_html_permission = filter_permission_name($filtered_html_format);
396 user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content', 'access comments', $filtered_html_permission));
397 user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content', 'access comments', 'post comments', 'skip comment approval', $filtered_html_permission));
398
399 // Create a default role for site administrators, with all available permissions assigned.
400 $admin_role = new stdClass();
401 $admin_role->name = 'administrator';
402 $admin_role->weight = 2;
403 user_role_save($admin_role);
404 user_role_grant_permissions($admin_role->rid, array_keys(module_invoke_all('permission')));
405 // Set this as the administrator role.
406 variable_set('user_admin_role', $admin_role->rid);
407
408 // Assign user 1 the "administrator" role.
409 db_insert('users_roles')
410 ->fields(array('uid' => 1, 'rid' => $admin_role->rid))
411 ->execute();
412
413 // Create a Home link in the main menu.
414 $item = array(
415 'link_title' => st('Home'),
416 'link_path' => '<front>',
417 'menu_name' => 'main-menu',
418 );
419 menu_link_save($item);
420
421 // Update the menu router information.
422 menu_rebuild();
423
424 // Enable the admin theme.
425 db_update('system')
426 ->fields(array('status' => 1))
427 ->condition('type', 'theme')
428 ->condition('name', 'seven')
429 ->execute();
430 variable_set('admin_theme', 'seven');
431 variable_set('node_admin_theme', '1');
432 }
node_type_save
node_type_save($info)
Definition: node.module:525
field_create_instance
field_create_instance($instance)
Definition: field.crud.inc:473
menu_link_save
menu_link_save(&$item, $existing_item=array(), $parent_candidates=array())
Definition: menu.inc:3074
taxonomy_vocabulary_save
taxonomy_vocabulary_save($vocabulary)
Definition: taxonomy.module:413
filter_permission_name
filter_permission_name($format)
Definition: filter.module:373
standard_install
standard_install()
Definition: standard.install:14
COMMENT_NODE_HIDDEN
const COMMENT_NODE_HIDDEN
Definition: comment.module:60
user_role_grant_permissions
user_role_grant_permissions($rid, array $permissions=array())
Definition: user.module:3100
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
field_create_field
field_create_field($field)
Definition: field.crud.inc:56
DRUPAL_ANONYMOUS_RID
const DRUPAL_ANONYMOUS_RID
Definition: bootstrap.inc:162
node_type_set_defaults
node_type_set_defaults($info=array())
Definition: node.module:805
filter_format_save
filter_format_save($format)
Definition: filter.module:198
menu_rebuild
menu_rebuild()
Definition: menu.inc:2709
node_add_body_field
node_add_body_field($type, $label= 'Body')
Definition: node.module:586
DRUPAL_AUTHENTICATED_RID
const DRUPAL_AUTHENTICATED_RID
Definition: bootstrap.inc:167
FIELD_CARDINALITY_UNLIMITED
const FIELD_CARDINALITY_UNLIMITED
Definition: field.module:236
st
st($string, array $args=array(), array $options=array())
Definition: install.inc:1111
user_role_save
user_role_save($role)
Definition: user.module:2955
$help
print $help
Definition: maintenance-page.tpl.php:69
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
rdf_mapping_save
rdf_mapping_save($mapping)
Definition: rdf.module:225
USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL
const USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL
Definition: user.module:32
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/image/image.field.inc Source File

  • modules
  • image
image.field.inc
Go to the documentation of this file.
1 <?php
2
11 function image_field_info() {
12 return array(
13 'image' => array(
14 'label' => t('Image'),
15 'description' => t('This field stores the ID of an image file as an integer value.'),
16 'settings' => array(
17 'uri_scheme' => variable_get('file_default_scheme', 'public'),
18 'default_image' => 0,
19 ),
20 'instance_settings' => array(
21 'file_extensions' => 'png gif jpg jpeg',
22 'file_directory' => '',
23 'max_filesize' => '',
24 'alt_field' => 0,
25 'title_field' => 0,
26 'max_resolution' => '',
27 'min_resolution' => '',
28 'default_image' => 0,
29 ),
30 'default_widget' => 'image_image',
31 'default_formatter' => 'image',
32 ),
33 );
34 }
35
39 function image_field_settings_form($field, $instance) {
40 $defaults = field_info_field_settings($field['type']);
41 $settings = array_merge($defaults, $field['settings']);
42
43 $scheme_options = array();
44 foreach (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $stream_wrapper) {
45 $scheme_options[$scheme] = $stream_wrapper['name'];
46 }
47 $form['uri_scheme'] = array(
48 '#type' => 'radios',
49 '#title' => t('Upload destination'),
50 '#options' => $scheme_options,
51 '#default_value' => $settings['uri_scheme'],
52 '#description' => t('Select where the final files should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'),
53 );
54
55 // When the user sets the scheme on the UI, even for the first time, it's
56 // updating a field because fields are created on the "Manage fields"
57 // page. So image_field_update_field() can handle this change.
58 $form['default_image'] = array(
59 '#title' => t('Default image'),
60 '#type' => 'managed_file',
61 '#description' => t('If no image is uploaded, this image will be shown on display.'),
62 '#default_value' => $field['settings']['default_image'],
63 '#upload_location' => $settings['uri_scheme'] . '://default_images/',
64 );
65
66 return $form;
67 }
68
72 function image_field_instance_settings_form($field, $instance) {
73 $settings = $instance['settings'];
74
75 // Use the file field instance settings form as a basis.
76 $form = file_field_instance_settings_form($field, $instance);
77
78 // Add maximum and minimum resolution settings.
79 $max_resolution = explode('x', $settings['max_resolution']) + array('', '');
80 $form['max_resolution'] = array(
81 '#type' => 'item',
82 '#title' => t('Maximum image resolution'),
83 '#element_validate' => array('_image_field_resolution_validate'),
84 '#weight' => 4.1,
85 '#field_prefix' => '<div class="container-inline">',
86 '#field_suffix' => '</div>',
87 '#description' => t('The maximum allowed image size expressed as WIDTHxHEIGHT (e.g. 640x480). Leave blank for no restriction. If a larger image is uploaded, it will be resized to reflect the given width and height. Resizing images on upload will cause the loss of <a href="http://en.wikipedia.org/wiki/Exchangeable_image_file_format">EXIF data</a> in the image.'),
88 );
89 $form['max_resolution']['x'] = array(
90 '#type' => 'textfield',
91 '#title' => t('Maximum width'),
92 '#title_display' => 'invisible',
93 '#default_value' => $max_resolution[0],
94 '#size' => 5,
95 '#maxlength' => 5,
96 '#field_suffix' => ' x ',
97 );
98 $form['max_resolution']['y'] = array(
99 '#type' => 'textfield',
100 '#title' => t('Maximum height'),
101 '#title_display' => 'invisible',
102 '#default_value' => $max_resolution[1],
103 '#size' => 5,
104 '#maxlength' => 5,
105 '#field_suffix' => ' ' . t('pixels'),
106 );
107
108 $min_resolution = explode('x', $settings['min_resolution']) + array('', '');
109 $form['min_resolution'] = array(
110 '#type' => 'item',
111 '#title' => t('Minimum image resolution'),
112 '#element_validate' => array('_image_field_resolution_validate'),
113 '#weight' => 4.2,
114 '#field_prefix' => '<div class="container-inline">',
115 '#field_suffix' => '</div>',
116 '#description' => t('The minimum allowed image size expressed as WIDTHxHEIGHT (e.g. 640x480). Leave blank for no restriction. If a smaller image is uploaded, it will be rejected.'),
117 );
118 $form['min_resolution']['x'] = array(
119 '#type' => 'textfield',
120 '#title' => t('Minimum width'),
121 '#title_display' => 'invisible',
122 '#default_value' => $min_resolution[0],
123 '#size' => 5,
124 '#maxlength' => 5,
125 '#field_suffix' => ' x ',
126 );
127 $form['min_resolution']['y'] = array(
128 '#type' => 'textfield',
129 '#title' => t('Minimum height'),
130 '#title_display' => 'invisible',
131 '#default_value' => $min_resolution[1],
132 '#size' => 5,
133 '#maxlength' => 5,
134 '#field_suffix' => ' ' . t('pixels'),
135 );
136
137 // Remove the description option.
138 unset($form['description_field']);
139
140 // Add title and alt configuration options.
141 $form['alt_field'] = array(
142 '#type' => 'checkbox',
143 '#title' => t('Enable <em>Alt</em> field'),
144 '#default_value' => $settings['alt_field'],
145 '#description' => t('The alt attribute may be used by search engines, screen readers, and when the image cannot be loaded.'),
146 '#weight' => 10,
147 );
148 $form['title_field'] = array(
149 '#type' => 'checkbox',
150 '#title' => t('Enable <em>Title</em> field'),
151 '#default_value' => $settings['title_field'],
152 '#description' => t('The title attribute is used as a tooltip when the mouse hovers over the image.'),
153 '#weight' => 11,
154 );
155
156 // Add the default image to the instance.
157 $form['default_image'] = array(
158 '#title' => t('Default image'),
159 '#type' => 'managed_file',
160 '#description' => t("If no image is uploaded, this image will be shown on display and will override the field's default image."),
161 '#default_value' => $settings['default_image'],
162 '#upload_location' => $field['settings']['uri_scheme'] . '://default_images/',
163 );
164
165 return $form;
166 }
167
171 function _image_field_resolution_validate($element, &$form_state) {
172 if (!empty($element['x']['#value']) || !empty($element['y']['#value'])) {
173 foreach (array('x', 'y') as $dimension) {
174 $value = $element[$dimension]['#value'];
175 if (!is_numeric($value)) {
176 form_error($element[$dimension], t('Height and width values must be numeric.'));
177 return;
178 }
179 if (intval($value) == 0) {
180 form_error($element[$dimension], t('Both a height and width value must be specified in the !name field.', array('!name' => $element['#title'])));
181 return;
182 }
183 }
184 form_set_value($element, intval($element['x']['#value']) . 'x' . intval($element['y']['#value']), $form_state);
185 }
186 else {
187 form_set_value($element, '', $form_state);
188 }
189 }
190
194 function image_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
195 file_field_load($entity_type, $entities, $field, $instances, $langcode, $items, $age);
196 }
197
201 function image_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) {
202 // If there are no files specified at all, use the default.
203 foreach ($entities as $id => $entity) {
204 if (empty($items[$id])) {
205 $fid = 0;
206 // Use the default for the instance if one is available.
207 if (!empty($instances[$id]['settings']['default_image'])) {
208 $fid = $instances[$id]['settings']['default_image'];
209 }
210 // Otherwise, use the default for the field.
211 elseif (!empty($field['settings']['default_image'])) {
212 $fid = $field['settings']['default_image'];
213 }
214
215 // Add the default image if one is found.
216 if ($fid && ($file = file_load($fid))) {
217 $items[$id][0] = (array) $file + array(
218 'is_default' => TRUE,
219 'alt' => '',
220 'title' => '',
221 );
222 }
223 }
224 }
225 }
226
230 function image_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
231 file_field_presave($entity_type, $entity, $field, $instance, $langcode, $items);
232
233 // Determine the dimensions if necessary.
234 foreach ($items as &$item) {
235 if (!isset($item['width']) || !isset($item['height'])) {
236 $info = image_get_info(file_load($item['fid'])->uri);
237
238 if (is_array($info)) {
239 $item['width'] = $info['width'];
240 $item['height'] = $info['height'];
241 }
242 }
243 }
244 }
245
249 function image_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
250 file_field_insert($entity_type, $entity, $field, $instance, $langcode, $items);
251 }
252
256 function image_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
257 file_field_update($entity_type, $entity, $field, $instance, $langcode, $items);
258 }
259
263 function image_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
264 file_field_delete($entity_type, $entity, $field, $instance, $langcode, $items);
265 }
266
270 function image_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) {
271 file_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, $items);
272 }
273
277 function image_field_is_empty($item, $field) {
278 return file_field_is_empty($item, $field);
279 }
280
284 function image_field_widget_info() {
285 return array(
286 'image_image' => array(
287 'label' => t('Image'),
288 'field types' => array('image'),
289 'settings' => array(
290 'progress_indicator' => 'throbber',
291 'preview_image_style' => 'thumbnail',
292 ),
293 'behaviors' => array(
294 'multiple values' => FIELD_BEHAVIOR_CUSTOM,
295 'default value' => FIELD_BEHAVIOR_NONE,
296 ),
297 ),
298 );
299 }
300
304 function image_field_widget_settings_form($field, $instance) {
305 $widget = $instance['widget'];
306 $settings = $widget['settings'];
307
308 // Use the file widget settings form.
309 $form = file_field_widget_settings_form($field, $instance);
310
311 $form['preview_image_style'] = array(
312 '#title' => t('Preview image style'),
313 '#type' => 'select',
314 '#options' => image_style_options(FALSE, PASS_THROUGH),
315 '#empty_option' => '<' . t('no preview') . '>',
316 '#default_value' => $settings['preview_image_style'],
317 '#description' => t('The preview image will be shown while editing the content.'),
318 '#weight' => 15,
319 );
320
321 return $form;
322 }
323
327 function image_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
328
329 // Add display_field setting to field because file_field_widget_form() assumes it is set.
330 $field['settings']['display_field'] = 0;
331
332 $elements = file_field_widget_form($form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
333 $settings = $instance['settings'];
334
335 foreach (element_children($elements) as $delta) {
336 // Add upload resolution validation.
337 if ($settings['max_resolution'] || $settings['min_resolution']) {
338 $elements[$delta]['#upload_validators']['file_validate_image_resolution'] = array($settings['max_resolution'], $settings['min_resolution']);
339 }
340
341 // If not using custom extension validation, ensure this is an image.
342 $supported_extensions = array('png', 'gif', 'jpg', 'jpeg');
343 $extensions = isset($elements[$delta]['#upload_validators']['file_validate_extensions'][0]) ? $elements[$delta]['#upload_validators']['file_validate_extensions'][0] : implode(' ', $supported_extensions);
344 $extensions = array_intersect(explode(' ', $extensions), $supported_extensions);
345 $elements[$delta]['#upload_validators']['file_validate_extensions'][0] = implode(' ', $extensions);
346
347 // Add all extra functionality provided by the image widget.
348 $elements[$delta]['#process'][] = 'image_field_widget_process';
349 }
350
351 if ($field['cardinality'] == 1) {
352 // If there's only one field, return it as delta 0.
353 if (empty($elements[0]['#default_value']['fid'])) {
354 $elements[0]['#description'] = theme('file_upload_help', array('description' => field_filter_xss($instance['description']), 'upload_validators' => $elements[0]['#upload_validators']));
355 }
356 }
357 else {
358 $elements['#file_upload_description'] = theme('file_upload_help', array('upload_validators' => $elements[0]['#upload_validators']));
359 }
360 return $elements;
361 }
362
368 function image_field_widget_process($element, &$form_state, $form) {
369 $item = $element['#value'];
370 $item['fid'] = $element['fid']['#value'];
371
372 $instance = field_widget_instance($element, $form_state);
373
374 $settings = $instance['settings'];
375 $widget_settings = $instance['widget']['settings'];
376
377 $element['#theme'] = 'image_widget';
378 $element['#attached']['css'][] = drupal_get_path('module', 'image') . '/image.css';
379
380 // Add the image preview.
381 if ($element['#file'] && $widget_settings['preview_image_style']) {
382 $variables = array(
383 'style_name' => $widget_settings['preview_image_style'],
384 'path' => $element['#file']->uri,
385 );
386
387 // Determine image dimensions.
388 if (isset($element['#value']['width']) && isset($element['#value']['height'])) {
389 $variables['width'] = $element['#value']['width'];
390 $variables['height'] = $element['#value']['height'];
391 }
392 else {
393 $info = image_get_info($element['#file']->uri);
394
395 if (is_array($info)) {
396 $variables['width'] = $info['width'];
397 $variables['height'] = $info['height'];
398 }
399 else {
400 $variables['width'] = $variables['height'] = NULL;
401 }
402 }
403
404 $element['preview'] = array(
405 '#type' => 'markup',
406 '#markup' => theme('image_style', $variables),
407 );
408
409 // Store the dimensions in the form so the file doesn't have to be accessed
410 // again. This is important for remote files.
411 $element['width'] = array(
412 '#type' => 'hidden',
413 '#value' => $variables['width'],
414 );
415 $element['height'] = array(
416 '#type' => 'hidden',
417 '#value' => $variables['height'],
418 );
419 }
420
421 // Add the additional alt and title fields.
422 $element['alt'] = array(
423 '#title' => t('Alternate text'),
424 '#type' => 'textfield',
425 '#default_value' => isset($item['alt']) ? $item['alt'] : '',
426 '#description' => t('This text will be used by screen readers, search engines, or when the image cannot be loaded.'),
427 // @see http://www.gawds.org/show.php?contentid=28
428 '#maxlength' => 512,
429 '#weight' => -2,
430 '#access' => (bool) $item['fid'] && $settings['alt_field'],
431 );
432 $element['title'] = array(
433 '#type' => 'textfield',
434 '#title' => t('Title'),
435 '#default_value' => isset($item['title']) ? $item['title'] : '',
436 '#description' => t('The title is used as a tool tip when the user hovers the mouse over the image.'),
437 '#maxlength' => 1024,
438 '#weight' => -1,
439 '#access' => (bool) $item['fid'] && $settings['title_field'],
440 );
441
442 return $element;
443 }
444
454 function theme_image_widget($variables) {
455 $element = $variables['element'];
456 $output = '';
457 $output .= '<div class="image-widget form-managed-file clearfix">';
458
459 if (isset($element['preview'])) {
460 $output .= '<div class="image-preview">';
461 $output .= drupal_render($element['preview']);
462 $output .= '</div>';
463 }
464
465 $output .= '<div class="image-widget-data">';
466 if ($element['fid']['#value'] != 0) {
467 $element['filename']['#markup'] .= ' <span class="file-size">(' . format_size($element['#file']->filesize) . ')</span> ';
468 }
469 $output .= drupal_render_children($element);
470 $output .= '</div>';
471 $output .= '</div>';
472
473 return $output;
474 }
475
479 function image_field_formatter_info() {
480 $formatters = array(
481 'image' => array(
482 'label' => t('Image'),
483 'field types' => array('image'),
484 'settings' => array('image_style' => '', 'image_link' => ''),
485 ),
486 );
487
488 return $formatters;
489 }
490
494 function image_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
495 $display = $instance['display'][$view_mode];
496 $settings = $display['settings'];
497
498 $image_styles = image_style_options(FALSE, PASS_THROUGH);
499 $element['image_style'] = array(
500 '#title' => t('Image style'),
501 '#type' => 'select',
502 '#default_value' => $settings['image_style'],
503 '#empty_option' => t('None (original image)'),
504 '#options' => $image_styles,
505 );
506
507 $link_types = array(
508 'content' => t('Content'),
509 'file' => t('File'),
510 );
511 $element['image_link'] = array(
512 '#title' => t('Link image to'),
513 '#type' => 'select',
514 '#default_value' => $settings['image_link'],
515 '#empty_option' => t('Nothing'),
516 '#options' => $link_types,
517 );
518
519 return $element;
520 }
521
525 function image_field_formatter_settings_summary($field, $instance, $view_mode) {
526 $display = $instance['display'][$view_mode];
527 $settings = $display['settings'];
528
529 $summary = array();
530
531 $image_styles = image_style_options(FALSE, PASS_THROUGH);
532 // Unset possible 'No defined styles' option.
533 unset($image_styles['']);
534 // Styles could be lost because of enabled/disabled modules that defines
535 // their styles in code.
536 if (isset($image_styles[$settings['image_style']])) {
537 $summary[] = t('Image style: @style', array('@style' => $image_styles[$settings['image_style']]));
538 }
539 else {
540 $summary[] = t('Original image');
541 }
542
543 $link_types = array(
544 'content' => t('Linked to content'),
545 'file' => t('Linked to file'),
546 );
547 // Display this setting only if image is linked.
548 if (isset($link_types[$settings['image_link']])) {
549 $summary[] = $link_types[$settings['image_link']];
550 }
551
552 return implode('<br />', $summary);
553 }
554
558 function image_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
559 $element = array();
560
561 // Check if the formatter involves a link.
562 if ($display['settings']['image_link'] == 'content') {
563 $uri = entity_uri($entity_type, $entity);
564 }
565 elseif ($display['settings']['image_link'] == 'file') {
566 $link_file = TRUE;
567 }
568
569 foreach ($items as $delta => $item) {
570 if (isset($link_file)) {
571 $uri = array(
572 'path' => file_create_url($item['uri']),
573 'options' => array(),
574 );
575 }
576 $element[$delta] = array(
577 '#theme' => 'image_formatter',
578 '#item' => $item,
579 '#image_style' => $display['settings']['image_style'],
580 '#path' => isset($uri) ? $uri : '',
581 );
582 }
583
584 return $element;
585 }
586
599 function theme_image_formatter($variables) {
600 $item = $variables['item'];
601 $image = array(
602 'path' => $item['uri'],
603 );
604
605 if (array_key_exists('alt', $item)) {
606 $image['alt'] = $item['alt'];
607 }
608
609 if (isset($item['attributes'])) {
610 $image['attributes'] = $item['attributes'];
611 }
612
613 if (isset($item['width']) && isset($item['height'])) {
614 $image['width'] = $item['width'];
615 $image['height'] = $item['height'];
616 }
617
618 // Do not output an empty 'title' attribute.
619 if (isset($item['title']) && drupal_strlen($item['title']) > 0) {
620 $image['title'] = $item['title'];
621 }
622
623 if ($variables['image_style']) {
624 $image['style_name'] = $variables['image_style'];
625 $output = theme('image_style', $image);
626 }
627 else {
628 $output = theme('image', $image);
629 }
630
631 // The link path and link options are both optional, but for the options to be
632 // processed, the link path must at least be an empty string.
633 if (isset($variables['path']['path'])) {
634 $path = $variables['path']['path'];
635 $options = isset($variables['path']['options']) ? $variables['path']['options'] : array();
636 // When displaying an image inside a link, the html option must be TRUE.
637 $options['html'] = TRUE;
638 $output = l($output, $path, $options);
639 }
640
641 return $output;
642 }
file_field_widget_settings_form
file_field_widget_settings_form($field, $instance)
Definition: file.field.inc:433
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
image_field_formatter_settings_summary
image_field_formatter_settings_summary($field, $instance, $view_mode)
Definition: image.field.inc:525
file_field_insert
file_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: file.field.inc:238
theme_image_formatter
theme_image_formatter($variables)
Definition: image.field.inc:599
drupal_strlen
drupal_strlen($text)
Definition: unicode.inc:474
field_filter_xss
field_filter_xss($string)
Definition: field.module:752
file_field_presave
file_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: file.field.inc:214
image_field_delete_revision
image_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: image.field.inc:270
file_create_url
file_create_url($uri)
Definition: file.inc:372
file_field_update
file_field_update($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: file.field.inc:253
image_field_widget_form
image_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
Definition: image.field.inc:327
image_field_presave
image_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: image.field.inc:230
image_field_delete
image_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: image.field.inc:263
image_field_is_empty
image_field_is_empty($item, $field)
Definition: image.field.inc:277
image_field_formatter_info
image_field_formatter_info()
Definition: image.field.inc:479
image_field_update
image_field_update($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: image.field.inc:256
file_field_load
file_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age)
Definition: file.field.inc:169
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
entity_uri
entity_uri($entity_type, $entity)
Definition: common.inc:7902
image_field_widget_info
image_field_widget_info()
Definition: image.field.inc:284
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
field_widget_instance
field_widget_instance($element, $form_state)
Definition: field.form.inc:601
file_field_instance_settings_form
file_field_instance_settings_form($field, $instance)
Definition: file.field.inc:74
file_get_stream_wrappers
file_get_stream_wrappers($filter=STREAM_WRAPPERS_ALL)
Definition: file.inc:123
file_field_delete_revision
file_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: file.field.inc:317
image_field_insert
image_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: image.field.inc:249
image_get_info
image_get_info($filepath, $toolkit=FALSE)
Definition: image.inc:124
$info
$info
Definition: color.inc:6
file_field_widget_form
file_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
Definition: file.field.inc:456
image_field_info
image_field_info()
Definition: image.field.inc:11
field_info_field_settings
field_info_field_settings($type)
Definition: field.info.inc:742
image_field_settings_form
image_field_settings_form($field, $instance)
Definition: image.field.inc:39
$value
print $value
Definition: user-profile-item.tpl.php:26
file_load
file_load($fid)
Definition: file.inc:580
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
$output
$output
Definition: authorize.php:93
FIELD_BEHAVIOR_CUSTOM
const FIELD_BEHAVIOR_CUSTOM
Definition: field.module:262
image_style_options
image_style_options($include_empty=TRUE, $output=CHECK_PLAIN)
Definition: image.module:781
image_field_instance_settings_form
image_field_instance_settings_form($field, $instance)
Definition: image.field.inc:72
STREAM_WRAPPERS_WRITE_VISIBLE
const STREAM_WRAPPERS_WRITE_VISIBLE
Definition: stream_wrappers.inc:72
theme_image_widget
theme_image_widget($variables)
Definition: image.field.inc:454
image_field_formatter_view
image_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
Definition: image.field.inc:558
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
image_field_load
image_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age)
Definition: image.field.inc:194
file_field_delete
file_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: file.field.inc:305
image_field_formatter_settings_form
image_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state)
Definition: image.field.inc:494
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
_image_field_resolution_validate
_image_field_resolution_validate($element, &$form_state)
Definition: image.field.inc:171
FIELD_BEHAVIOR_NONE
const FIELD_BEHAVIOR_NONE
Definition: field.module:243
image_field_widget_process
image_field_widget_process($element, &$form_state, $form)
Definition: image.field.inc:368
format_size
format_size($size, $langcode=NULL)
Definition: common.inc:1866
file_field_is_empty
file_field_is_empty($item, $field)
Definition: file.field.inc:369
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
image_field_widget_settings_form
image_field_widget_settings_form($field, $instance)
Definition: image.field.inc:304
image_field_prepare_view
image_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items)
Definition: image.field.inc:201
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/field/theme/field.tpl.php Source File

  • modules
  • field
  • theme
field.tpl.php
Go to the documentation of this file.
1 <?php
2
46 ?>
47 <!--
48 THIS FILE IS NOT USED AND IS HERE AS A STARTING POINT FOR CUSTOMIZATION ONLY.
49 See http://api.drupal.org/api/function/theme_field/7 for details.
50 After copying this file to your theme 's folder and customizing it, remove this
51 HTML comment.
52 -->
53 <div class="<?php print $classes; ?>"<?php print $attributes; ?>>
54 <?php if (!$label_hidden): ?>
55 <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
56 <?php endif; ?>
57 <div class="field-items"<?php print $content_attributes; ?>>
58 <?php foreach ($items as $delta => $item): ?>
59 <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?></div>
60 <?php endforeach; ?>
61 </div>
62 </div>
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/json-encode.inc Source File

  • includes
json-encode.inc
Go to the documentation of this file.
1 <?php
2
13 function drupal_json_encode_helper($var) {
14 switch (gettype($var)) {
15 case 'boolean':
16 return $var ? 'true' : 'false'; // Lowercase necessary!
17
18 case 'integer':
19 case 'double':
20 return $var;
21
22 case 'resource':
23 case 'string':
24 // Always use Unicode escape sequences (\u0022) over JSON escape
25 // sequences (\") to prevent browsers interpreting these as
26 // special characters.
27 $replace_pairs = array(
28 // ", \ and U+0000 - U+001F must be escaped according to RFC 4627.
29 '\\' => '\u005C',
30 '"' => '\u0022',
31 "\x00" => '\u0000',
32 "\x01" => '\u0001',
33 "\x02" => '\u0002',
34 "\x03" => '\u0003',
35 "\x04" => '\u0004',
36 "\x05" => '\u0005',
37 "\x06" => '\u0006',
38 "\x07" => '\u0007',
39 "\x08" => '\u0008',
40 "\x09" => '\u0009',
41 "\x0a" => '\u000A',
42 "\x0b" => '\u000B',
43 "\x0c" => '\u000C',
44 "\x0d" => '\u000D',
45 "\x0e" => '\u000E',
46 "\x0f" => '\u000F',
47 "\x10" => '\u0010',
48 "\x11" => '\u0011',
49 "\x12" => '\u0012',
50 "\x13" => '\u0013',
51 "\x14" => '\u0014',
52 "\x15" => '\u0015',
53 "\x16" => '\u0016',
54 "\x17" => '\u0017',
55 "\x18" => '\u0018',
56 "\x19" => '\u0019',
57 "\x1a" => '\u001A',
58 "\x1b" => '\u001B',
59 "\x1c" => '\u001C',
60 "\x1d" => '\u001D',
61 "\x1e" => '\u001E',
62 "\x1f" => '\u001F',
63 // Prevent browsers from interpreting these as as special.
64 "'" => '\u0027',
65 '<' => '\u003C',
66 '>' => '\u003E',
67 '&' => '\u0026',
68 // Prevent browsers from interpreting the solidus as special and
69 // non-compliant JSON parsers from interpreting // as a comment.
70 '/' => '\u002F',
71 // While these are allowed unescaped according to ECMA-262, section
72 // 15.12.2, they cause problems in some JSON parsers.
73 "\xe2\x80\xa8" => '\u2028', // U+2028, Line Separator.
74 "\xe2\x80\xa9" => '\u2029', // U+2029, Paragraph Separator.
75 );
76
77 return '"' . strtr($var, $replace_pairs) . '"';
78
79 case 'array':
80 // Arrays in JSON can't be associative. If the array is empty or if it
81 // has sequential whole number keys starting with 0, it's not associative
82 // so we can go ahead and convert it as an array.
83 if (empty($var) || array_keys($var) === range(0, sizeof($var) - 1)) {
84 $output = array();
85 foreach ($var as $v) {
86 $output[] = drupal_json_encode_helper($v);
87 }
88 return '[ ' . implode(', ', $output) . ' ]';
89 }
90 // Otherwise, fall through to convert the array as an object.
91
92 case 'object':
93 $output = array();
94 foreach ($var as $k => $v) {
95 $output[] = drupal_json_encode_helper(strval($k)) . ':' . drupal_json_encode_helper($v);
96 }
97 return '{' . implode(', ', $output) . '}';
98
99 default:
100 return 'null';
101 }
102 }
drupal_json_encode_helper
drupal_json_encode_helper($var)
Definition: json-encode.inc:13
$output
$output
Definition: authorize.php:93
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment.tpl.php Source File

  • modules
  • comment
comment.tpl.php
Go to the documentation of this file.
1 <?php
2
61 ?>
62 <div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
63 <?php print $picture ?>
64
65 <?php if ($new): ?>
66 <span class="new"><?php print $new ?></span>
67 <?php endif; ?>
68
69 <?php print render($title_prefix); ?>
70 <h3<?php print $title_attributes; ?>><?php print $title ?></h3>
71 <?php print render($title_suffix); ?>
72
73 <div class="submitted">
74 <?php print $permalink; ?>
75 <?php print $submitted; ?>
76 </div>
77
78 <div class="content"<?php print $content_attributes; ?>>
79 <?php
80 // We hide the comments and links now so that we can render them later.
81 hide($content['links']);
82 print render($content);
83 ?>
84 <?php if ($signature): ?>
85 <div class="user-signature clearfix">
86 <?php print $signature ?>
87 </div>
88 <?php endif; ?>
89 </div>
90
91 <?php print render($content['links']) ?>
92 </div>
$attributes
print $attributes
Definition: block.tpl.php:47
print
print
Definition: php-2.php:2
$content_attributes
print $content_attributes
Definition: block.tpl.php:55
$picture
print $picture
Definition: comment.tpl.php:64
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
hide
hide(&$element)
Definition: common.inc:6021
endif
endif
Definition: aggregator-item.tpl.php:31
$submitted
print $submitted
Definition: comment.tpl.php:75
render
render(&$element)
Definition: common.inc:5988
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
$permalink
print $permalink
Definition: comment.tpl.php:74
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum.install Source File

  • modules
  • forum
forum.install
Go to the documentation of this file.
1 <?php
2
11 function forum_install() {
12 // Set the weight of the forum.module to 1 so it is loaded after the taxonomy.module.
13 db_update('system')
14 ->fields(array('weight' => 1))
15 ->condition('name', 'forum')
16 ->execute();
17 // Forum topics are published by default, but do not have any other default
18 // options set (for example, they are not promoted to the front page).
19 variable_set('node_options_forum', array('status'));
20 }
21
25 function forum_enable() {
26 // If we enable forum at the same time as taxonomy we need to call
27 // field_associate_fields() as otherwise the field won't be enabled until
28 // hook modules_enabled is called which takes place after hook_enable events.
29 field_associate_fields('taxonomy');
30 // Create the forum vocabulary if it does not exist.
31 $vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0));
32 if (!$vocabulary) {
33 $edit = array(
34 'name' => t('Forums'),
35 'machine_name' => 'forums',
36 'description' => t('Forum navigation vocabulary'),
37 'hierarchy' => 1,
38 'module' => 'forum',
39 'weight' => -10,
40 );
41 $vocabulary = (object) $edit;
42 taxonomy_vocabulary_save($vocabulary);
43 variable_set('forum_nav_vocabulary', $vocabulary->vid);
44 }
45
46 // Create the 'taxonomy_forums' field if it doesn't already exist.
47 if (!field_info_field('taxonomy_forums')) {
48 $field = array(
49 'field_name' => 'taxonomy_forums',
50 'type' => 'taxonomy_term_reference',
51 'settings' => array(
52 'allowed_values' => array(
53 array(
54 'vocabulary' => $vocabulary->machine_name,
55 'parent' => 0,
56 ),
57 ),
58 ),
59 );
60 field_create_field($field);
61
62 // Create a default forum so forum posts can be created.
63 $edit = array(
64 'name' => t('General discussion'),
65 'description' => '',
66 'parent' => array(0),
67 'vid' => $vocabulary->vid,
68 );
69 $term = (object) $edit;
70 taxonomy_term_save($term);
71
72 // Create the instance on the bundle.
73 $instance = array(
74 'field_name' => 'taxonomy_forums',
75 'entity_type' => 'node',
76 'label' => $vocabulary->name,
77 'bundle' => 'forum',
78 'required' => TRUE,
79 'widget' => array(
80 'type' => 'options_select',
81 ),
82 'display' => array(
83 'default' => array(
84 'type' => 'taxonomy_term_reference_link',
85 'weight' => 10,
86 ),
87 'teaser' => array(
88 'type' => 'taxonomy_term_reference_link',
89 'weight' => 10,
90 ),
91 ),
92 );
93 field_create_instance($instance);
94 }
95
96 // Ensure the forum node type is available.
97 node_types_rebuild();
98 $types = node_type_get_types();
99 node_add_body_field($types['forum']);
100 }
101
105 function forum_uninstall() {
106 // Load the dependent Taxonomy module, in case it has been disabled.
107 drupal_load('module', 'taxonomy');
108
109 variable_del('forum_containers');
110 variable_del('forum_hot_topic');
111 variable_del('forum_per_page');
112 variable_del('forum_order');
113 variable_del('forum_block_num_active');
114 variable_del('forum_block_num_new');
115 variable_del('node_options_forum');
116
117 field_delete_field('taxonomy_forums');
118 // Purge field data now to allow taxonomy module to be uninstalled
119 // if this is the only field remaining.
120 field_purge_batch(10);
121 }
122
126 function forum_schema() {
127 $schema['forum'] = array(
128 'description' => 'Stores the relationship of nodes to forum terms.',
129 'fields' => array(
130 'nid' => array(
131 'type' => 'int',
132 'unsigned' => TRUE,
133 'not null' => TRUE,
134 'default' => 0,
135 'description' => 'The {node}.nid of the node.',
136 ),
137 'vid' => array(
138 'type' => 'int',
139 'unsigned' => TRUE,
140 'not null' => TRUE,
141 'default' => 0,
142 'description' => 'Primary Key: The {node}.vid of the node.',
143 ),
144 'tid' => array(
145 'type' => 'int',
146 'unsigned' => TRUE,
147 'not null' => TRUE,
148 'default' => 0,
149 'description' => 'The {taxonomy_term_data}.tid of the forum term assigned to the node.',
150 ),
151 ),
152 'indexes' => array(
153 'forum_topic' => array('nid', 'tid'),
154 'tid' => array('tid'),
155 ),
156 'primary key' => array('vid'),
157 'foreign keys' => array(
158 'forum_node' => array(
159 'table' => 'node',
160 'columns' => array(
161 'nid' => 'nid',
162 'vid' => 'vid',
163 ),
164 ),
165 ),
166 );
167
168 $schema['forum_index'] = array(
169 'description' => 'Maintains denormalized information about node/term relationships.',
170 'fields' => array(
171 'nid' => array(
172 'description' => 'The {node}.nid this record tracks.',
173 'type' => 'int',
174 'unsigned' => TRUE,
175 'not null' => TRUE,
176 'default' => 0,
177 ),
178 'title' => array(
179 'description' => 'The title of this node, always treated as non-markup plain text.',
180 'type' => 'varchar',
181 'length' => 255,
182 'not null' => TRUE,
183 'default' => '',
184 ),
185 'tid' => array(
186 'description' => 'The term ID.',
187 'type' => 'int',
188 'unsigned' => TRUE,
189 'not null' => TRUE,
190 'default' => 0,
191 ),
192 'sticky' => array(
193 'description' => 'Boolean indicating whether the node is sticky.',
194 'type' => 'int',
195 'not null' => FALSE,
196 'default' => 0,
197 'size' => 'tiny',
198 ),
199 'created' => array(
200 'description' => 'The Unix timestamp when the node was created.',
201 'type' => 'int',
202 'unsigned' => TRUE,
203 'not null' => TRUE,
204 'default'=> 0,
205 ),
206 'last_comment_timestamp' => array(
207 'type' => 'int',
208 'not null' => TRUE,
209 'default' => 0,
210 'description' => 'The Unix timestamp of the last comment that was posted within this node, from {comment}.timestamp.',
211 ),
212 'comment_count' => array(
213 'type' => 'int',
214 'unsigned' => TRUE,
215 'not null' => TRUE,
216 'default' => 0,
217 'description' => 'The total number of comments on this node.',
218 ),
219 ),
220 'indexes' => array(
221 'forum_topics' => array('nid', 'tid', 'sticky', 'last_comment_timestamp'),
222 'created' => array('created'),
223 'last_comment_timestamp' => array('last_comment_timestamp'),
224 ),
225 'foreign keys' => array(
226 'tracked_node' => array(
227 'table' => 'node',
228 'columns' => array('nid' => 'nid'),
229 ),
230 'term' => array(
231 'table' => 'taxonomy_term_data',
232 'columns' => array(
233 'tid' => 'tid',
234 ),
235 ),
236 ),
237 );
238
239
240 return $schema;
241 }
242
246 function forum_update_dependencies() {
247 $dependencies['forum'][7003] = array(
248 // Forum update 7003 uses field API update functions, so must run after
249 // Field API has been enabled.
250 'system' => 7020,
251 // Forum update 7003 relies on updated taxonomy module schema. Ensure it
252 // runs after all taxonomy updates.
253 'taxonomy' => 7010,
254 );
255 return $dependencies;
256 }
257
261 function forum_update_7000() {
262 db_drop_index('forum', 'nid');
263 db_add_index('forum', 'forum_topic', array('nid', 'tid'));
264 }
265
269 function forum_update_7001() {
270 $forum_index = array(
271 'description' => 'Maintains denormalized information about node/term relationships.',
272 'fields' => array(
273 'nid' => array(
274 'description' => 'The {node}.nid this record tracks.',
275 'type' => 'int',
276 'unsigned' => TRUE,
277 'not null' => TRUE,
278 'default' => 0,
279 ),
280 'title' => array(
281 'description' => 'The title of this node, always treated as non-markup plain text.',
282 'type' => 'varchar',
283 'length' => 255,
284 'not null' => TRUE,
285 'default' => '',
286 ),
287 'tid' => array(
288 'description' => 'The term ID.',
289 'type' => 'int',
290 'unsigned' => TRUE,
291 'not null' => TRUE,
292 'default' => 0,
293 ),
294 'sticky' => array(
295 'description' => 'Boolean indicating whether the node is sticky.',
296 'type' => 'int',
297 'not null' => FALSE,
298 'default' => 0,
299 'size' => 'tiny',
300 ),
301 'created' => array(
302 'description' => 'The Unix timestamp when the node was created.',
303 'type' => 'int',
304 'unsigned' => TRUE,
305 'not null' => TRUE,
306 'default'=> 0,
307 ),
308 'last_comment_timestamp' => array(
309 'type' => 'int',
310 'not null' => TRUE,
311 'default' => 0,
312 'description' => 'The Unix timestamp of the last comment that was posted within this node, from {comment}.timestamp.',
313 ),
314 'comment_count' => array(
315 'type' => 'int',
316 'unsigned' => TRUE,
317 'not null' => TRUE,
318 'default' => 0,
319 'description' => 'The total number of comments on this node.',
320 ),
321 ),
322 'indexes' => array(
323 'forum_topics' => array('tid', 'sticky', 'last_comment_timestamp'),
324 ),
325 'foreign keys' => array(
326 'tracked_node' => array(
327 'table' => 'node',
328 'columns' => array('nid' => 'nid'),
329 ),
330 'term' => array(
331 'table' => 'taxonomy_term_data',
332 'columns' => array(
333 'tid' => 'tid',
334 ),
335 ),
336 ),
337 );
338 db_create_table('forum_index', $forum_index);
339
340 $select = db_select('node', 'n');
341 $forum_alias = $select->join('forum', 'f', 'n.vid = f.vid');
342 $ncs_alias = $select->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid');
343 $select
344 ->fields('n', array('nid', 'title', 'sticky', 'created'))
345 ->fields($forum_alias, array('tid'))
346 ->fields($ncs_alias, array('last_comment_timestamp', 'comment_count'));
347
348 db_insert('forum_index')
349 ->fields(array('nid', 'title', 'sticky', 'created', 'tid', 'last_comment_timestamp', 'comment_count'))
350 ->from($select)
351 ->execute();
352 }
353
362 function forum_update_7002() {
363 db_drop_index('forum_index', 'forum_topics');
364 db_add_index('forum_index', 'forum_topics', array('nid', 'tid', 'sticky', 'last_comment_timestamp'));
365 }
366
370 function forum_update_7003() {
371 $messages = array();
372
373 $new_field_name = 'taxonomy_forums';
374
375 // Test to see if the taxonomy_forums field exists.
376 $fields = _update_7000_field_read_fields(array('field_name' => $new_field_name));
377 if ($fields) {
378 // Since the field exists, we're done.
379 return;
380 }
381
382 // Calculate the old field name.
383 $vid = variable_get('forum_nav_vocabulary', 0);
384 $vocabulary_machine_name = db_select('taxonomy_vocabulary', 'tv')
385 ->fields('tv', array('machine_name'))
386 ->condition('vid', $vid)
387 ->execute()
388 ->fetchField();
389 $old_field_name = 'taxonomy_' . $vocabulary_machine_name;
390
391 // Read the old fields.
392 $old_fields = _update_7000_field_read_fields(array('field_name' => $old_field_name));
393 foreach ($old_fields as $old_field) {
394 if ($old_field['storage']['type'] != 'field_sql_storage') {
395 $messages[] = t('Cannot rename field %id (%old_field_name) to %new_field_name because it does not use the field_sql_storage storage type.', array(
396 '%id' => $old_field['id'],
397 '%old_field_name' => $old_field_name,
398 '%new_field_name' => $new_field_name,
399 ));
400 continue;
401 }
402
403 // Update {field_config}.
404 db_update('field_config')
405 ->fields(array('field_name' => $new_field_name))
406 ->condition('id', $old_field['id'])
407 ->execute();
408
409 // Update {field_config_instance}.
410 db_update('field_config_instance')
411 ->fields(array('field_name' => $new_field_name))
412 ->condition('field_id', $old_field['id'])
413 ->execute();
414
415 // The tables that need updating in the form 'old_name' => 'new_name'.
416 $tables = array(
417 'field_data_' . $old_field_name => 'field_data_' . $new_field_name,
418 'field_revision_' . $old_field_name => 'field_revision_' . $new_field_name,
419 );
420 foreach ($tables as $old_table => $new_table) {
421 $old_column_name = $old_field_name . '_tid';
422 $new_column_name = $new_field_name . '_tid';
423
424 // Rename the column.
425 db_drop_index($old_table, $old_column_name);
426 db_change_field($old_table, $old_column_name, $new_column_name, array(
427 'type' => 'int',
428 'unsigned' => TRUE,
429 'not null' => FALSE,
430 ));
431 db_drop_index($old_table, $new_column_name);
432 db_add_index($old_table, $new_column_name, array($new_column_name));
433
434 // Rename the table.
435 db_rename_table($old_table, $new_table);
436 }
437 }
438
439 cache_clear_all('*', 'cache_field', TRUE);
440
441 return $messages;
442 }
443
447 function forum_update_7011() {
448 $select = db_select('node', 'n')
449 ->fields('n', array('nid'))
450 ->condition('status', 0 );
451
452 db_delete('forum_index')
453 ->condition('nid', $select, 'IN')
454 ->execute();
455 }
456
460 function forum_update_7012() {
461 db_add_index('forum_index', 'created', array('created'));
462 db_add_index('forum_index', 'last_comment_timestamp', array('last_comment_timestamp'));
463 }
464
forum_update_7011
forum_update_7011()
Definition: forum.install:447
field_create_instance
field_create_instance($instance)
Definition: field.crud.inc:473
forum_enable
forum_enable()
Definition: forum.install:25
forum_update_7001
forum_update_7001()
Definition: forum.install:269
db_add_index
db_add_index($table, $name, $fields)
Definition: database.inc:2940
forum_update_7003
forum_update_7003()
Definition: forum.install:370
taxonomy_vocabulary_save
taxonomy_vocabulary_save($vocabulary)
Definition: taxonomy.module:413
field_info_field
field_info_field($field_name)
Definition: field.info.inc:518
field_associate_fields
field_associate_fields($module)
Definition: field.module:446
forum_schema
forum_schema()
Definition: forum.install:126
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
db_drop_index
db_drop_index($table, $name)
Definition: database.inc:2952
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
_update_7000_field_read_fields
_update_7000_field_read_fields(array $conditions=array(), $key= 'id')
Definition: field.install:328
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
forum_update_dependencies
forum_update_dependencies()
Definition: forum.install:246
taxonomy_vocabulary_load
taxonomy_vocabulary_load($vid)
Definition: taxonomy.module:1351
field_create_field
field_create_field($field)
Definition: field.crud.inc:56
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
node_type_get_types
node_type_get_types()
Definition: node.module:393
forum_install
forum_install()
Definition: forum.install:11
node_add_body_field
node_add_body_field($type, $label= 'Body')
Definition: node.module:586
node_types_rebuild
node_types_rebuild()
Definition: node.module:475
$messages
print $messages
Definition: page.tpl.php:121
field_purge_batch
field_purge_batch($batch_size)
Definition: field.crud.inc:880
forum_uninstall
forum_uninstall()
Definition: forum.install:105
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
field_delete_field
field_delete_field($field_name)
Definition: field.crud.inc:411
forum_update_7000
forum_update_7000()
Definition: forum.install:261
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
forum_update_7002
forum_update_7002()
Definition: forum.install:362
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
taxonomy_term_save
taxonomy_term_save($term)
Definition: taxonomy.module:621
forum_update_7012
forum_update_7012()
Definition: forum.install:460
drupal_load
drupal_load($type, $name)
Definition: bootstrap.inc:1093
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
db_rename_table
db_rename_table($table, $new_name)
Definition: database.inc:2805
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user.tokens.inc Source File

  • modules
  • user
user.tokens.inc
Go to the documentation of this file.
1 <?php
2
11 function user_token_info() {
12 $types['user'] = array(
13 'name' => t('Users'),
14 'description' => t('Tokens related to individual user accounts.'),
15 'needs-data' => 'user',
16 );
17 $types['current-user'] = array(
18 'name' => t('Current user'),
19 'description' => t('Tokens related to the currently logged in user.'),
20 'type' => 'user',
21 );
22
23 $user['uid'] = array(
24 'name' => t('User ID'),
25 'description' => t("The unique ID of the user account."),
26 );
27 $user['name'] = array(
28 'name' => t("Name"),
29 'description' => t("The login name of the user account."),
30 );
31 $user['mail'] = array(
32 'name' => t("Email"),
33 'description' => t("The email address of the user account."),
34 );
35 $user['url'] = array(
36 'name' => t("URL"),
37 'description' => t("The URL of the account profile page."),
38 );
39 $user['edit-url'] = array(
40 'name' => t("Edit URL"),
41 'description' => t("The URL of the account edit page."),
42 );
43
44 $user['last-login'] = array(
45 'name' => t("Last login"),
46 'description' => t("The date the user last logged in to the site."),
47 'type' => 'date',
48 );
49 $user['created'] = array(
50 'name' => t("Created"),
51 'description' => t("The date the user account was created."),
52 'type' => 'date',
53 );
54
55 return array(
56 'types' => $types,
57 'tokens' => array('user' => $user),
58 );
59 }
60
64 function user_tokens($type, $tokens, array $data = array(), array $options = array()) {
65 $url_options = array('absolute' => TRUE);
66 if (isset($options['language'])) {
67 $url_options['language'] = $options['language'];
68 $language_code = $options['language']->language;
69 }
70 else {
71 $language_code = NULL;
72 }
73 $sanitize = !empty($options['sanitize']);
74
75 $replacements = array();
76
77 if ($type == 'user' && !empty($data['user'])) {
78 $account = $data['user'];
79 foreach ($tokens as $name => $original) {
80 switch ($name) {
81 // Basic user account information.
82 case 'uid':
83 // In the case of hook user_presave uid is not set yet.
84 $replacements[$original] = !empty($account->uid) ? $account->uid : t('not yet assigned');
85 break;
86
87 case 'name':
88 $name = format_username($account);
89 $replacements[$original] = $sanitize ? check_plain($name) : $name;
90 break;
91
92 case 'mail':
93 $replacements[$original] = $sanitize ? check_plain($account->mail) : $account->mail;
94 break;
95
96 case 'url':
97 $replacements[$original] = !empty($account->uid) ? url("user/$account->uid", $url_options) : t('not yet assigned');
98 break;
99
100 case 'edit-url':
101 $replacements[$original] = !empty($account->uid) ? url("user/$account->uid/edit", $url_options) : t('not yet assigned');
102 break;
103
104 // These tokens are default variations on the chained tokens handled below.
105 case 'last-login':
106 $replacements[$original] = !empty($account->login) ? format_date($account->login, 'medium', '', NULL, $language_code) : t('never');
107 break;
108
109 case 'created':
110 // In the case of user_presave the created date may not yet be set.
111 $replacements[$original] = !empty($account->created) ? format_date($account->created, 'medium', '', NULL, $language_code) : t('not yet created');
112 break;
113 }
114 }
115
116 if ($login_tokens = token_find_with_prefix($tokens, 'last-login')) {
117 $replacements += token_generate('date', $login_tokens, array('date' => $account->login), $options);
118 }
119
120 if ($registered_tokens = token_find_with_prefix($tokens, 'created')) {
121 $replacements += token_generate('date', $registered_tokens, array('date' => $account->created), $options);
122 }
123 }
124
125 if ($type == 'current-user') {
126 $account = user_load($GLOBALS['user']->uid);
127 $replacements += token_generate('user', $tokens, array('user' => $account), $options);
128 }
129
130 return $replacements;
131 }
token_generate
token_generate($type, array $tokens, array $data=array(), array $options=array())
Definition: token.inc:176
format_username
format_username($account)
Definition: common.inc:2106
$name
print $name
Definition: profile-listing.tpl.php:43
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
user_token_info
user_token_info()
Definition: user.tokens.inc:11
user_tokens
user_tokens($type, $tokens, array $data=array(), array $options=array())
Definition: user.tokens.inc:64
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
token_find_with_prefix
token_find_with_prefix(array $tokens, $prefix, $delimiter= ':')
Definition: token.inc:219
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalPrivateStreamWrapper Member List

This is the complete list of members for DrupalPrivateStreamWrapper, including all inherited members.

$context | DrupalLocalStreamWrapper |
$handle | DrupalLocalStreamWrapper |
$uri | DrupalLocalStreamWrapper | protected
chmod($mode) | DrupalLocalStreamWrapper |
dir_closedir() | DrupalLocalStreamWrapper |
dir_opendir($uri, $options) | DrupalLocalStreamWrapper |
dir_readdir() | DrupalLocalStreamWrapper |
dir_rewinddir() | DrupalLocalStreamWrapper |
dirname($uri=NULL) | DrupalLocalStreamWrapper |
getDirectoryPath() | DrupalPrivateStreamWrapper |
getExternalUrl() | DrupalPrivateStreamWrapper |
getLocalPath($uri=NULL) | DrupalLocalStreamWrapper | protected
getMimeType($uri, $mapping=NULL) | DrupalLocalStreamWrapper | static
getTarget($uri=NULL) | DrupalLocalStreamWrapper | protected
getUri() | DrupalLocalStreamWrapper |
mkdir($uri, $mode, $options) | DrupalLocalStreamWrapper |
realpath() | DrupalLocalStreamWrapper |
rename($from_uri, $to_uri) | DrupalLocalStreamWrapper |
rmdir($uri, $options) | DrupalLocalStreamWrapper |
setUri($uri) | DrupalLocalStreamWrapper |
stream_close() | DrupalLocalStreamWrapper |
stream_eof() | DrupalLocalStreamWrapper |
stream_flush() | DrupalLocalStreamWrapper |
stream_lock($operation) | DrupalLocalStreamWrapper |
stream_open($uri, $mode, $options, &$opened_path) | DrupalLocalStreamWrapper |
stream_read($count) | DrupalLocalStreamWrapper |
stream_seek($offset, $whence) | DrupalLocalStreamWrapper |
stream_stat() | DrupalLocalStreamWrapper |
stream_tell() | DrupalLocalStreamWrapper |
stream_write($data) | DrupalLocalStreamWrapper |
unlink($uri) | DrupalLocalStreamWrapper |
url_stat($uri, $flags) | DrupalLocalStreamWrapper |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/tablesort_example/tablesort_example.install Source File

  • examples
  • tablesort_example
tablesort_example.install
Go to the documentation of this file.
1 <?php
2
17 function tablesort_example_install() {
18 // let's fill the database with some values for sorting
19 $rows = array(
20 array('numbers' => 1, 'alpha' => 'e', 'random' => '912cv21'),
21 array('numbers' => 2, 'alpha' => 'a', 'random' => '0kuykuh'),
22 array('numbers' => 3, 'alpha' => 'm', 'random' => 'fuye8734h'),
23 array('numbers' => 4, 'alpha' => 'w', 'random' => '80jsv772'),
24 array('numbers' => 5, 'alpha' => 'o', 'random' => 'd82sf-csj'),
25 array('numbers' => 6, 'alpha' => 's', 'random' => 'au832'),
26 array('numbers' => 7, 'alpha' => 'e', 'random' => 't982hkv'),
27 );
28
29 if (db_table_exists('tablesort_example')) {
30 foreach ($rows as $row) {
31 db_insert('tablesort_example')->fields($row)->execute();
32 }
33 }
34 }
35
43 function tablesort_example_uninstall() {
44 db_drop_table('tablesort_example');
45 }
46
52 function tablesort_example_schema() {
53 $schema['tablesort_example'] = array(
54 'description' => 'Stores some values for sorting fun.',
55 'fields' => array(
56 'numbers' => array(
57 'description' => 'This column simply holds numbers values',
58 'type' => 'varchar',
59 'length' => 2,
60 'not null' => TRUE,
61 ),
62 'alpha' => array(
63 'description' => 'This column simply holds alpha values',
64 'type' => 'varchar',
65 'length' => 2,
66 'not null' => TRUE,
67 ),
68 'random' => array(
69 'description' => 'This column simply holds random values',
70 'type' => 'varchar',
71 'length' => 12,
72 'not null' => TRUE,
73 ),
74 ),
75 'primary key' => array('numbers'),
76 );
77
78 return $schema;
79 }
tablesort_example_install
tablesort_example_install()
Definition: tablesort_example.install:17
tablesort_example_uninstall
tablesort_example_uninstall()
Definition: tablesort_example.install:43
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
$row
$row
Definition: block-admin-display-form.tpl.php:47
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
tablesort_example_schema
tablesort_example_schema()
Definition: tablesort_example.install:52
db_table_exists
db_table_exists($table)
Definition: database.inc:2760
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/shortcut/shortcut.api.php Source File

  • modules
  • shortcut
shortcut.api.php
Go to the documentation of this file.
1 <?php
2
33 function hook_shortcut_default_set($account) {
34 // Use a special set of default shortcuts for administrators only.
35 if (in_array(variable_get('user_admin_role', 0), $account->roles)) {
36 return variable_get('mymodule_shortcut_admin_default_set');
37 }
38 }
39
hook_shortcut_default_set
hook_shortcut_default_set($account)
Definition: shortcut.api.php:33
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module Source File

  • profiles
  • testing
  • modules
  • drupal_system_listing_compatible_test
drupal_system_listing_compatible_test.module
Go to the documentation of this file.
1 <?php
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/node.pages.inc Source File

  • modules
  • node
node.pages.inc
Go to the documentation of this file.
1 <?php
2
11 function node_page_edit($node) {
12 $type_name = node_type_get_name($node);
13 drupal_set_title(t('<em>Edit @type</em> @title', array('@type' => $type_name, '@title' => $node->title)), PASS_THROUGH);
14 return drupal_get_form($node->type . '_node_form', $node);
15 }
16
24 function node_add_page() {
25 $item = menu_get_item();
26 $content = system_admin_menu_block($item);
27 // Bypass the node/add listing if only one content type is available.
28 if (count($content) == 1) {
29 $item = array_shift($content);
30 drupal_goto($item['href']);
31 }
32 return theme('node_add_list', array('content' => $content));
33 }
34
44 function theme_node_add_list($variables) {
45 $content = $variables['content'];
46 $output = '';
47
48 if ($content) {
49 $output = '<dl class="node-type-list">';
50 foreach ($content as $item) {
51 $output .= '<dt>' . l($item['title'], $item['href'], $item['localized_options']) . '</dt>';
52 $output .= '<dd>' . filter_xss_admin($item['description']) . '</dd>';
53 }
54 $output .= '</dl>';
55 }
56 else {
57 $output = '<p>' . t('You have not created any content types yet. Go to the <a href="@create-content">content type creation page</a> to add a new content type.', array('@create-content' => url('admin/structure/types/add'))) . '</p>';
58 }
59 return $output;
60 }
61
62
72 function node_add($type) {
73 global $user;
74
75 $types = node_type_get_types();
76 $node = (object) array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => LANGUAGE_NONE);
77 drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)), PASS_THROUGH);
78 $output = drupal_get_form($type . '_node_form', $node);
79
80 return $output;
81 }
82
89 function node_form_validate($form, &$form_state) {
90 // $form_state['node'] contains the actual entity being edited, but we must
91 // not update it with form values that have not yet been validated, so we
92 // create a pseudo-entity to use during validation.
93 $node = (object) $form_state['values'];
94 node_validate($node, $form, $form_state);
95 entity_form_field_validate('node', $form, $form_state);
96 }
97
107 function node_form($form, &$form_state, $node) {
108 global $user;
109
110 // During initial form build, add the node entity to the form state for use
111 // during form building and processing. During a rebuild, use what is in the
112 // form state.
113 if (!isset($form_state['node'])) {
114 if (!isset($node->title)) {
115 $node->title = NULL;
116 }
117 node_object_prepare($node);
118 $form_state['node'] = $node;
119 }
120 else {
121 $node = $form_state['node'];
122 }
123
124 // Some special stuff when previewing a node.
125 if (isset($form_state['node_preview'])) {
126 $form['#prefix'] = $form_state['node_preview'];
127 $node->in_preview = TRUE;
128 }
129 else {
130 unset($node->in_preview);
131 }
132
133 // Identify this as a node edit form.
134 // @todo D8: Remove. Modules can implement hook_form_BASE_FORM_ID_alter() now.
135 $form['#node_edit_form'] = TRUE;
136
137 $form['#attributes']['class'][] = 'node-form';
138 if (!empty($node->type)) {
139 $form['#attributes']['class'][] = 'node-' . $node->type . '-form';
140 }
141
142 // Basic node information.
143 // These elements are just values so they are not even sent to the client.
144 foreach (array('nid', 'vid', 'uid', 'created', 'type', 'language') as $key) {
145 $form[$key] = array(
146 '#type' => 'value',
147 '#value' => isset($node->$key) ? $node->$key : NULL,
148 );
149 }
150
151 // Changed must be sent to the client, for later overwrite error checking.
152 $form['changed'] = array(
153 '#type' => 'hidden',
154 '#default_value' => isset($node->changed) ? $node->changed : NULL,
155 );
156 // Invoke hook_form() to get the node-specific bits. Can't use node_invoke(),
157 // because hook_form() needs to be able to receive $form_state by reference.
158 // @todo hook_form() implementations are unable to add #validate or #submit
159 // handlers to the form buttons below. Remove hook_form() entirely.
160 $function = node_type_get_base($node) . '_form';
161 if (function_exists($function) && ($extra = $function($node, $form_state))) {
162 $form = array_merge_recursive($form, $extra);
163 }
164 // If the node type has a title, and the node type form defined no special
165 // weight for it, we default to a weight of -5 for consistency.
166 if (isset($form['title']) && !isset($form['title']['#weight'])) {
167 $form['title']['#weight'] = -5;
168 }
169 // @todo D8: Remove. Modules should access the node using $form_state['node'].
170 $form['#node'] = $node;
171
172 $form['additional_settings'] = array(
173 '#type' => 'vertical_tabs',
174 '#weight' => 99,
175 );
176
177 // Add a log field if the "Create new revision" option is checked, or if the
178 // current user has the ability to check that option.
179 $form['revision_information'] = array(
180 '#type' => 'fieldset',
181 '#title' => t('Revision information'),
182 '#collapsible' => TRUE,
183 // Collapsed by default when "Create new revision" is unchecked
184 '#collapsed' => !$node->revision,
185 '#group' => 'additional_settings',
186 '#attributes' => array(
187 'class' => array('node-form-revision-information'),
188 ),
189 '#attached' => array(
190 'js' => array(drupal_get_path('module', 'node') . '/node.js'),
191 ),
192 '#weight' => 20,
193 '#access' => $node->revision || user_access('administer nodes'),
194 );
195 $form['revision_information']['revision'] = array(
196 '#type' => 'checkbox',
197 '#title' => t('Create new revision'),
198 '#default_value' => $node->revision,
199 '#access' => user_access('administer nodes'),
200 );
201 // Check the revision log checkbox when the log textarea is filled in.
202 // This must not happen if "Create new revision" is enabled by default, since
203 // the state would auto-disable the checkbox otherwise.
204 if (!$node->revision) {
205 $form['revision_information']['revision']['#states'] = array(
206 'checked' => array(
207 'textarea[name="log"]' => array('empty' => FALSE),
208 ),
209 );
210 }
211 $form['revision_information']['log'] = array(
212 '#type' => 'textarea',
213 '#title' => t('Revision log message'),
214 '#rows' => 4,
215 '#default_value' => !empty($node->log) ? $node->log : '',
216 '#description' => t('Provide an explanation of the changes you are making. This will help other authors understand your motivations.'),
217 );
218
219 // Node author information for administrators
220 $form['author'] = array(
221 '#type' => 'fieldset',
222 '#access' => user_access('administer nodes'),
223 '#title' => t('Authoring information'),
224 '#collapsible' => TRUE,
225 '#collapsed' => TRUE,
226 '#group' => 'additional_settings',
227 '#attributes' => array(
228 'class' => array('node-form-author'),
229 ),
230 '#attached' => array(
231 'js' => array(
232 drupal_get_path('module', 'node') . '/node.js',
233 array(
234 'type' => 'setting',
235 'data' => array('anonymous' => variable_get('anonymous', t('Anonymous'))),
236 ),
237 ),
238 ),
239 '#weight' => 90,
240 );
241 $form['author']['name'] = array(
242 '#type' => 'textfield',
243 '#title' => t('Authored by'),
244 '#maxlength' => 60,
245 '#autocomplete_path' => 'user/autocomplete',
246 '#default_value' => !empty($node->name) ? $node->name : '',
247 '#weight' => -1,
248 '#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))),
249 );
250 $form['author']['date'] = array(
251 '#type' => 'textfield',
252 '#title' => t('Authored on'),
253 '#maxlength' => 25,
254 '#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the time zone offset from UTC. Leave blank to use the time of form submission.', array('%time' => !empty($node->date) ? date_format(date_create($node->date), 'Y-m-d H:i:s O') : format_date($node->created, 'custom', 'Y-m-d H:i:s O'), '%timezone' => !empty($node->date) ? date_format(date_create($node->date), 'O') : format_date($node->created, 'custom', 'O'))),
255 '#default_value' => !empty($node->date) ? $node->date : '',
256 );
257
258 // Node options for administrators
259 $form['options'] = array(
260 '#type' => 'fieldset',
261 '#access' => user_access('administer nodes'),
262 '#title' => t('Publishing options'),
263 '#collapsible' => TRUE,
264 '#collapsed' => TRUE,
265 '#group' => 'additional_settings',
266 '#attributes' => array(
267 'class' => array('node-form-options'),
268 ),
269 '#attached' => array(
270 'js' => array(drupal_get_path('module', 'node') . '/node.js'),
271 ),
272 '#weight' => 95,
273 );
274 $form['options']['status'] = array(
275 '#type' => 'checkbox',
276 '#title' => t('Published'),
277 '#default_value' => $node->status,
278 );
279 $form['options']['promote'] = array(
280 '#type' => 'checkbox',
281 '#title' => t('Promoted to front page'),
282 '#default_value' => $node->promote,
283 );
284 $form['options']['sticky'] = array(
285 '#type' => 'checkbox',
286 '#title' => t('Sticky at top of lists'),
287 '#default_value' => $node->sticky,
288 );
289
290 // Add the buttons.
291 $form['actions'] = array('#type' => 'actions');
292 $form['actions']['submit'] = array(
293 '#type' => 'submit',
294 '#access' => variable_get('node_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_REQUIRED || (!form_get_errors() && isset($form_state['node_preview'])),
295 '#value' => t('Save'),
296 '#weight' => 5,
297 '#submit' => array('node_form_submit'),
298 );
299 $form['actions']['preview'] = array(
300 '#access' => variable_get('node_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_DISABLED,
301 '#type' => 'submit',
302 '#value' => t('Preview'),
303 '#weight' => 10,
304 '#submit' => array('node_form_build_preview'),
305 );
306 if (!empty($node->nid) && node_access('delete', $node)) {
307 $form['actions']['delete'] = array(
308 '#type' => 'submit',
309 '#value' => t('Delete'),
310 '#weight' => 15,
311 '#submit' => array('node_form_delete_submit'),
312 );
313 }
314 // This form uses a button-level #submit handler for the form's main submit
315 // action. node_form_submit() manually invokes all form-level #submit handlers
316 // of the form. Without explicitly setting #submit, Form API would auto-detect
317 // node_form_submit() as submit handler, but that is the button-level #submit
318 // handler for the 'Save' action. To maintain backwards compatibility, a
319 // #submit handler is auto-suggested for custom node type modules.
320 $form['#validate'][] = 'node_form_validate';
321 if (!isset($form['#submit']) && function_exists($node->type . '_node_form_submit')) {
322 $form['#submit'][] = $node->type . '_node_form_submit';
323 }
324 $form += array('#submit' => array());
325
326 field_attach_form('node', $node, $form, $form_state, entity_language('node', $node));
327 return $form;
328 }
329
338 function node_form_delete_submit($form, &$form_state) {
339 $destination = array();
340 if (isset($_GET['destination'])) {
341 $destination = drupal_get_destination();
342 unset($_GET['destination']);
343 }
344 $node = $form['#node'];
345 $form_state['redirect'] = array('node/' . $node->nid . '/delete', array('query' => $destination));
346 }
347
356 function node_form_build_preview($form, &$form_state) {
357 $node = node_form_submit_build_node($form, $form_state);
358 $form_state['node_preview'] = node_preview($node);
359 $form_state['rebuild'] = TRUE;
360 }
361
373 function node_preview($node) {
374 if (node_access('create', $node) || node_access('update', $node)) {
375 _field_invoke_multiple('load', 'node', array($node->nid => $node));
376 // Load the user's name when needed.
377 if (isset($node->name)) {
378 // The use of isset() is mandatory in the context of user IDs, because
379 // user ID 0 denotes the anonymous user.
380 if ($user = user_load_by_name($node->name)) {
381 $node->uid = $user->uid;
382 $node->picture = $user->picture;
383 }
384 else {
385 $node->uid = 0; // anonymous user
386 }
387 }
388 elseif ($node->uid) {
389 $user = user_load($node->uid);
390 $node->name = $user->name;
391 $node->picture = $user->picture;
392 }
393
394 $node->changed = REQUEST_TIME;
395 $nodes = array($node->nid => $node);
396 field_attach_prepare_view('node', $nodes, 'full');
397
398 // Display a preview of the node.
399 if (!form_get_errors()) {
400 $node->in_preview = TRUE;
401 $output = theme('node_preview', array('node' => $node));
402 unset($node->in_preview);
403 }
404 drupal_set_title(t('Preview'), PASS_THROUGH);
405
406 return $output;
407 }
408 }
409
420 function theme_node_preview($variables) {
421 $node = $variables['node'];
422
423 $output = '<div class="preview">';
424
425 $preview_trimmed_version = FALSE;
426
427 $elements = node_view(clone $node, 'teaser');
428 $trimmed = drupal_render($elements);
429 $elements = node_view($node, 'full');
430 $full = drupal_render($elements);
431
432 // Do we need to preview trimmed version of post as well as full version?
433 if ($trimmed != $full) {
434 drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication.<span class="no-js"> You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.</span>'));
435 $output .= '<h3>' . t('Preview trimmed version') . '</h3>';
436 $output .= $trimmed;
437 $output .= '<h3>' . t('Preview full version') . '</h3>';
438 $output .= $full;
439 }
440 else {
441 $output .= $full;
442 }
443 $output .= "</div>\n";
444
445 return $output;
446 }
447
454 function node_form_submit($form, &$form_state) {
455 $node = node_form_submit_build_node($form, $form_state);
456 $insert = empty($node->nid);
457 node_save($node);
458 $node_link = l(t('view'), 'node/' . $node->nid);
459 $watchdog_args = array('@type' => $node->type, '%title' => $node->title);
460 $t_args = array('@type' => node_type_get_name($node), '%title' => $node->title);
461
462 if ($insert) {
463 watchdog('content', '@type: added %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
464 drupal_set_message(t('@type %title has been created.', $t_args));
465 }
466 else {
467 watchdog('content', '@type: updated %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
468 drupal_set_message(t('@type %title has been updated.', $t_args));
469 }
470 if ($node->nid) {
471 $form_state['values']['nid'] = $node->nid;
472 $form_state['nid'] = $node->nid;
473 $form_state['redirect'] = node_access('view', $node) ? 'node/' . $node->nid : '<front>';
474 }
475 else {
476 // In the unlikely case something went wrong on save, the node will be
477 // rebuilt and node form redisplayed the same way as in preview.
478 drupal_set_message(t('The post could not be saved.'), 'error');
479 $form_state['rebuild'] = TRUE;
480 }
481 // Clear the page and block caches.
482 cache_clear_all();
483 }
484
496 function node_form_submit_build_node($form, &$form_state) {
497 // @todo Legacy support for modules that extend the node form with form-level
498 // submit handlers that adjust $form_state['values'] prior to those values
499 // being used to update the entity. Module authors are encouraged to instead
500 // adjust the node directly within a hook_node_submit() implementation. For
501 // Drupal 8, evaluate whether the pattern of triggering form-level submit
502 // handlers during button-level submit processing is worth supporting
503 // properly, and if so, add a Form API function for doing so.
504 unset($form_state['submit_handlers']);
505 form_execute_handlers('submit', $form, $form_state);
506
507 $node = $form_state['node'];
508 entity_form_submit_build_entity('node', $node, $form, $form_state);
509
510 node_submit($node);
511 foreach (module_implements('node_submit') as $module) {
512 $function = $module . '_node_submit';
513 $function($node, $form, $form_state);
514 }
515 return $node;
516 }
517
523 function node_delete_confirm($form, &$form_state, $node) {
524 $form['#node'] = $node;
525 // Always provide entity id in the same form key as in the entity edit form.
526 $form['nid'] = array('#type' => 'value', '#value' => $node->nid);
527 return confirm_form($form,
528 t('Are you sure you want to delete %title?', array('%title' => $node->title)),
529 'node/' . $node->nid,
530 t('This action cannot be undone.'),
531 t('Delete'),
532 t('Cancel')
533 );
534 }
535
541 function node_delete_confirm_submit($form, &$form_state) {
542 if ($form_state['values']['confirm']) {
543 $node = node_load($form_state['values']['nid']);
544 node_delete($form_state['values']['nid']);
545 cache_clear_all();
546 watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
547 drupal_set_message(t('@type %title has been deleted.', array('@type' => node_type_get_name($node), '%title' => $node->title)));
548 }
549
550 $form_state['redirect'] = '<front>';
551 }
552
564 function node_revision_overview($node) {
565 drupal_set_title(t('Revisions for %title', array('%title' => $node->title)), PASS_THROUGH);
566
567 $header = array(t('Revision'), array('data' => t('Operations'), 'colspan' => 2));
568
569 $revisions = node_revision_list($node);
570
571 $rows = array();
572 $revert_permission = FALSE;
573 if ((user_access('revert revisions') || user_access('administer nodes')) && node_access('update', $node)) {
574 $revert_permission = TRUE;
575 }
576 $delete_permission = FALSE;
577 if ((user_access('delete revisions') || user_access('administer nodes')) && node_access('delete', $node)) {
578 $delete_permission = TRUE;
579 }
580 foreach ($revisions as $revision) {
581 $row = array();
582 $operations = array();
583
584 if ($revision->current_vid > 0) {
585 $row[] = array('data' => t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'short'), "node/$node->nid"), '!username' => theme('username', array('account' => $revision))))
586 . (($revision->log != '') ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : ''),
587 'class' => array('revision-current'));
588 $operations[] = array('data' => drupal_placeholder(t('current revision')), 'class' => array('revision-current'), 'colspan' => 2);
589 }
590 else {
591 $row[] = t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'short'), "node/$node->nid/revisions/$revision->vid/view"), '!username' => theme('username', array('account' => $revision))))
592 . (($revision->log != '') ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : '');
593 if ($revert_permission) {
594 $operations[] = l(t('revert'), "node/$node->nid/revisions/$revision->vid/revert");
595 }
596 if ($delete_permission) {
597 $operations[] = l(t('delete'), "node/$node->nid/revisions/$revision->vid/delete");
598 }
599 }
600 $rows[] = array_merge($row, $operations);
601 }
602
603 $build['node_revisions_table'] = array(
604 '#theme' => 'table',
605 '#rows' => $rows,
606 '#header' => $header,
607 );
608
609 return $build;
610 }
611
625 function node_revision_revert_confirm($form, $form_state, $node_revision) {
626 $form['#node_revision'] = $node_revision;
627 return confirm_form($form, t('Are you sure you want to revert to the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revision->nid . '/revisions', '', t('Revert'), t('Cancel'));
628 }
629
633 function node_revision_revert_confirm_submit($form, &$form_state) {
634 $node_revision = $form['#node_revision'];
635 $node_revision->revision = 1;
636 $node_revision->log = t('Copy of the revision from %date.', array('%date' => format_date($node_revision->revision_timestamp)));
637
638 node_save($node_revision);
639
640 watchdog('content', '@type: reverted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title, '%revision' => $node_revision->vid));
641 drupal_set_message(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => node_type_get_name($node_revision), '%title' => $node_revision->title, '%revision-date' => format_date($node_revision->revision_timestamp))));
642 $form_state['redirect'] = 'node/' . $node_revision->nid . '/revisions';
643 }
644
660 function node_revision_delete_confirm($form, $form_state, $node_revision) {
661 $form['#node_revision'] = $node_revision;
662 return confirm_form($form, t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revision->nid . '/revisions', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
663 }
664
668 function node_revision_delete_confirm_submit($form, &$form_state) {
669 $node_revision = $form['#node_revision'];
670 node_revision_delete($node_revision->vid);
671
672 watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title, '%revision' => $node_revision->vid));
673 drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($node_revision->revision_timestamp), '@type' => node_type_get_name($node_revision), '%title' => $node_revision->title)));
674 $form_state['redirect'] = 'node/' . $node_revision->nid;
675 if (db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid', array(':nid' => $node_revision->nid))->fetchField() > 1) {
676 $form_state['redirect'] .= '/revisions';
677 }
678 }
node_revision_delete
node_revision_delete($revision_id)
Definition: node.module:1296
form_execute_handlers
form_execute_handlers($type, &$form, &$form_state)
Definition: form.inc:1452
node_add_page
node_add_page()
Definition: node.pages.inc:24
node_validate
node_validate($node, $form, &$form_state)
Definition: node.module:1010
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
menu_get_item
menu_get_item($path=NULL, $router_item=NULL)
Definition: menu.inc:447
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
entity_form_field_validate
entity_form_field_validate($entity_type, $form, &$form_state)
Definition: common.inc:7997
field_attach_form
field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode=NULL, $options=array())
Definition: field.attach.inc:564
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
node_revision_list
node_revision_list($node)
Definition: node.module:2231
$module
print $module
Definition: search-results.tpl.php:28
node_add
node_add($type)
Definition: node.pages.inc:72
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
system_admin_menu_block
system_admin_menu_block($item)
Definition: system.module:2117
node_save
node_save($node)
Definition: node.module:1076
name
print $forum name
Definition: forum-list.tpl.php:57
DRUPAL_OPTIONAL
const DRUPAL_OPTIONAL
Definition: system.module:41
$header
print $header
Definition: forum-topic-list.tpl.php:42
field_attach_prepare_view
field_attach_prepare_view($entity_type, $entities, $view_mode, $langcode=NULL, $options=array())
Definition: field.attach.inc:1133
node_submit
node_submit($node)
Definition: node.module:1051
node_type_get_base
node_type_get_base($node)
Definition: node.module:431
node_delete_confirm_submit
node_delete_confirm_submit($form, &$form_state)
Definition: node.pages.inc:541
node_type_get_name
node_type_get_name($node)
Definition: node.module:459
theme_node_preview
theme_node_preview($variables)
Definition: node.pages.inc:420
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
node_type_get_types
node_type_get_types()
Definition: node.module:393
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
node_delete_confirm
node_delete_confirm($form, &$form_state, $node)
Definition: node.pages.inc:523
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
entity_language
entity_language($entity_type, $entity)
Definition: common.inc:7967
node_delete
node_delete($nid)
Definition: node.module:1233
$output
$output
Definition: authorize.php:93
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
user_access
user_access($string, $account=NULL)
Definition: user.module:794
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
DRUPAL_REQUIRED
const DRUPAL_REQUIRED
Definition: system.module:46
node_form_submit_build_node
node_form_submit_build_node($form, &$form_state)
Definition: node.pages.inc:496
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
node_revision_delete_confirm
node_revision_delete_confirm($form, $form_state, $node_revision)
Definition: node.pages.inc:660
filter_xss_admin
filter_xss_admin($string)
Definition: common.inc:1401
form_get_errors
form_get_errors()
Definition: form.inc:1634
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
node_page_edit
node_page_edit($node)
Definition: node.pages.inc:11
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
node_object_prepare
node_object_prepare($node)
Definition: node.module:978
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
node_access
node_access($op, $node, $account=NULL)
Definition: node.module:2981
node_preview
node_preview($node)
Definition: node.pages.inc:373
node_form_validate
node_form_validate($form, &$form_state)
Definition: node.pages.inc:89
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
drupal_placeholder
drupal_placeholder($text)
Definition: bootstrap.inc:3396
node_revision_overview
node_revision_overview($node)
Definition: node.pages.inc:564
$row
$row
Definition: block-admin-display-form.tpl.php:47
user_load_by_name
user_load_by_name($name)
Definition: user.module:397
node_revision_revert_confirm_submit
node_revision_revert_confirm_submit($form, &$form_state)
Definition: node.pages.inc:633
DRUPAL_DISABLED
const DRUPAL_DISABLED
Definition: system.module:36
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
theme_node_add_list
theme_node_add_list($variables)
Definition: node.pages.inc:44
node_revision_delete_confirm_submit
node_revision_delete_confirm_submit($form, &$form_state)
Definition: node.pages.inc:668
node_form_build_preview
node_form_build_preview($form, &$form_state)
Definition: node.pages.inc:356
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
node_form_submit
node_form_submit($form, &$form_state)
Definition: node.pages.inc:454
node_form
node_form($form, &$form_state, $node)
Definition: node.pages.inc:107
node_form_delete_submit
node_form_delete_submit($form, &$form_state)
Definition: node.pages.inc:338
entity_form_submit_build_entity
entity_form_submit_build_entity($entity_type, $entity, $form, &$form_state)
Definition: common.inc:8028
node_view
node_view($node, $view_mode= 'full', $langcode=NULL)
Definition: node.module:1329
_field_invoke_multiple
_field_invoke_multiple($op, $entity_type, $entities, &$a=NULL, &$b=NULL, $options=array())
Definition: field.attach.inc:278
node_revision_revert_confirm
node_revision_revert_confirm($form, $form_state, $node_revision)
Definition: node.pages.inc:625
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/field_example/field_example.module Source File

  • examples
  • field_example
field_example.module
Go to the documentation of this file.
1 <?php
49 /***************************************************************
50 * Field Type API hooks
51 ***************************************************************/
52
58 function field_example_field_info() {
59 return array(
60 // We name our field as the associative name of the array.
61 'field_example_rgb' => array(
62 'label' => t('Example Color RGB'),
63 'description' => t('Demonstrates a field composed of an RGB color.'),
64 'default_widget' => 'field_example_3text',
65 'default_formatter' => 'field_example_simple_text',
66 ),
67 );
68 }
69
82 function field_example_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
83 foreach ($items as $delta => $item) {
84 if (!empty($item['rgb'])) {
85 if (! preg_match('@^#[0-9a-f]{6}$@', $item['rgb'])) {
86 $errors[$field['field_name']][$langcode][$delta][] = array(
87 'error' => 'field_example_invalid',
88 'message' => t('Color must be in the HTML format #abcdef.'),
89 );
90 }
91 }
92 }
93 }
94
95
103 function field_example_field_is_empty($item, $field) {
104 return empty($item['rgb']);
105 }
106
116 function field_example_field_formatter_info() {
117 return array(
118 // This formatter just displays the hex value in the color indicated.
119 'field_example_simple_text' => array(
120 'label' => t('Simple text-based formatter'),
121 'field types' => array('field_example_rgb'),
122 ),
123 // This formatter changes the background color of the content region.
124 'field_example_color_background' => array(
125 'label' => t('Change the background of the output text'),
126 'field types' => array('field_example_rgb'),
127 ),
128 );
129 }
130
142 function field_example_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
143 $element = array();
144
145 switch ($display['type']) {
146 // This formatter simply outputs the field as text and with a color.
147 case 'field_example_simple_text':
148 foreach ($items as $delta => $item) {
149 $element[$delta] = array(
150 // We create a render array to produce the desired markup,
151 // "<p style="color: #hexcolor">The color code ... #hexcolor</p>".
152 // See theme_html_tag().
153 '#type' => 'html_tag',
154 '#tag' => 'p',
155 '#attributes' => array(
156 'style' => 'color: ' . $item['rgb'],
157 ),
158 '#value' => t('The color code in this field is @code', array('@code' => $item['rgb'])),
159 );
160 }
161 break;
162
163 // This formatter adds css to the page changing the '.region-content' area's
164 // background color. If there are many fields, the last one will win.
165 case 'field_example_color_background':
166 foreach ($items as $delta => $item) {
167 $element[$delta] = array(
168 '#type' => 'html_tag',
169 '#tag' => 'p',
170 '#value' => t('The content area color has been changed to @code', array('@code' => $item['rgb'])),
171 '#attached' => array(
172 'css' => array(
173 array(
174 'data' => 'div.region-content { background-color:' . $item['rgb'] . ';}',
175 'type' => 'inline',
176 ),
177 ),
178 ),
179 );
180 }
181 break;
182 }
183
184 return $element;
185 }
186
201 function field_example_field_widget_info() {
202 return array(
203 'field_example_text' => array(
204 'label' => t('RGB value as #ffffff'),
205 'field types' => array('field_example_rgb'),
206 ),
207 'field_example_3text' => array(
208 'label' => t('RGB text field'),
209 'field types' => array('field_example_rgb'),
210 ),
211 'field_example_colorpicker' => array(
212 'label' => t('Color Picker'),
213 'field types' => array('field_example_rgb'),
214 ),
215 );
216 }
217
237 function field_example_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
238 $value = isset($items[$delta]['rgb']) ? $items[$delta]['rgb'] : '';
239
240 $widget = $element;
241 $widget['#delta'] = $delta;
242
243 switch ($instance['widget']['type']) {
244
245 case 'field_example_colorpicker':
246 $widget += array(
247 '#suffix' => '<div class="field-example-colorpicker"></div>',
248 '#attributes' => array('class' => array('edit-field-example-colorpicker')),
249 '#attached' => array(
250 // Add Farbtastic color picker.
251 'library' => array(
252 array('system', 'farbtastic'),
253 ),
254 // Add javascript to trigger the colorpicker.
255 'js' => array(drupal_get_path('module', 'field_example') . '/field_example.js'),
256 ),
257 );
258
259 // DELIBERATE fall-through: From here on the field_example_text and
260 // field_example_colorpicker are exactly the same.
261 case 'field_example_text':
262 $widget += array(
263 '#type' => 'textfield',
264 '#default_value' => $value,
265 // Allow a slightly larger size that the field length to allow for some
266 // configurations where all characters won't fit in input field.
267 '#size' => 7,
268 '#maxlength' => 7,
269 );
270 break;
271
272 case 'field_example_3text':
273 // Convert rgb value into r, g, and b for #default_value.
274 if (!empty($value)) {
275 preg_match_all('@..@', substr($value, 1), $match);
276 }
277 else {
278 $match = array(array());
279 }
280
281 // Make this a fieldset with the three text fields.
282 $widget += array(
283 '#type' => 'fieldset',
284 '#element_validate' => array('field_example_3text_validate'),
285
286 // #delta is set so that the validation function will be able
287 // to access external value information which otherwise would be
288 // unavailable.
289 '#delta' => $delta,
290
291 '#attached' => array(
292 'css' => array(drupal_get_path('module', 'field_example') . '/field_example.css'),
293 ),
294 );
295
296 // Create a textfield for saturation values for Red, Green, and Blue.
297 foreach (array('r' => t('Red'), 'g' => t('Green'), 'b' => t('Blue')) as $key => $title) {
298 $widget[$key] = array(
299 '#type' => 'textfield',
300 '#title' => $title,
301 '#size' => 2,
302 '#default_value' => array_shift($match[0]),
303 '#attributes' => array('class' => array('rgb-entry')),
304 '#description' => t('The 2-digit hexadecimal representation of @color saturation, like "a1" or "ff"', array('@color' => $title)),
305 );
306 // Since Form API doesn't allow a fieldset to be required, we
307 // have to require each field element individually.
308 if ($instance['required'] == 1) $widget[$key]['#required'] = 1;
309 }
310 break;
311
312 }
313
314 $element['rgb'] = $widget;
315 return $element;
316 }
317
318
323 function field_example_3text_validate($element, &$form_state) {
324 $delta = $element['#delta']; // TODO: Isn't there a better way to find out which element?
325 $field = $form_state['field'][$element['#field_name']][$element['#language']]['field'];
326 $field_name = $field['field_name'];
327 if (isset($form_state['values'][$field_name][$element['#language']][$delta]['rgb'])) {
328 $values = $form_state['values'][$field_name][$element['#language']][$delta]['rgb'];
329 foreach (array('r', 'g', 'b') as $colorfield) {
330 $colorfield_value = hexdec($values[$colorfield]);
331 // If they left any empty, we'll set the value empty and quit.
332 if (strlen($values[$colorfield]) == 0) {
333 form_set_value($element, '', $form_state);
334 return;
335 }
336 // If they gave us anything that's not hex, reject it.
337 if ( (strlen($values[$colorfield]) != 2) || $colorfield_value < 0 || $colorfield_value > 255) {
338 form_error($element[$colorfield], t("Saturation value must be a 2-digit hexadecimal value between 00 and ff."));
339 }
340 }
341
342 $value = sprintf('#%02s%02s%02s', $values['r'], $values['g'], $values['b']);
343 form_set_value($element, $value, $form_state);
344 }
345 }
346
357 function field_example_field_widget_error($element, $error, $form, &$form_state) {
358 switch ($error['error']) {
359 case 'field_example_invalid':
360 form_error($element, $error['message']);
361 break;
362 }
363 }
364
365
371 function field_example_menu() {
372 $items['examples/field_example'] = array(
373 'title' => 'Field Example',
374 'page callback' => '_field_example_page',
375 'access callback' => TRUE,
376 );
377 return $items;
378 }
379
383 function _field_example_page() {
384 return t("The Field Example provides a field composed of an HTML RGB value, like #ff00ff. To use it, add the field to a content type.");
385 }
field_example_field_widget_error
field_example_field_widget_error($element, $error, $form, &$form_state)
Definition: field_example.module:357
field_example_field_widget_form
field_example_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
Definition: field_example.module:237
field_example_field_validate
field_example_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
Definition: field_example.module:82
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
field_example_field_widget_info
field_example_field_widget_info()
Definition: field_example.module:201
_field_example_page
_field_example_page()
Definition: field_example.module:383
field_example_menu
field_example_menu()
Definition: field_example.module:371
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
field_example_field_formatter_info
field_example_field_formatter_info()
Definition: field_example.module:116
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
field_example_field_info
field_example_field_info()
Definition: field_example.module:58
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
field_example_field_is_empty
field_example_field_is_empty($item, $field)
Definition: field_example.module:103
$value
print $value
Definition: user-profile-item.tpl.php:26
field_example_3text_validate
field_example_3text_validate($element, &$form_state)
Definition: field_example.module:323
field_example_field_formatter_view
field_example_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
Definition: field_example.module:142
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/log.inc Source File

  • includes
  • database
log.inc
Go to the documentation of this file.
1 <?php
2
19 class DatabaseLog {
20
35 protected $queryLog = array();
36
42 protected $connectionKey = 'default';
43
50 public function __construct($key = 'default') {
51 $this->connectionKey = $key;
52 }
53
64 public function start($logging_key) {
65 if (empty($this->queryLog[$logging_key])) {
66 $this->clear($logging_key);
67 }
68 }
69
78 public function get($logging_key) {
79 return $this->queryLog[$logging_key];
80 }
81
91 public function clear($logging_key) {
92 $this->queryLog[$logging_key] = array();
93 }
94
101 public function end($logging_key) {
102 unset($this->queryLog[$logging_key]);
103 }
104
115 public function log(DatabaseStatementInterface $statement, $args, $time) {
116 foreach (array_keys($this->queryLog) as $key) {
117 $this->queryLog[$key][] = array(
118 'query' => $statement->getQueryString(),
119 'args' => $args,
120 'target' => $statement->dbh->getTarget(),
121 'caller' => $this->findCaller(),
122 'time' => $time,
123 );
124 }
125 }
126
144 public function findCaller() {
145 $stack = debug_backtrace();
146 $stack_count = count($stack);
147 for ($i = 0; $i < $stack_count; ++$i) {
148 if (!empty($stack[$i]['file']) && strpos($stack[$i]['file'], 'includes' . DIRECTORY_SEPARATOR . 'database') === FALSE) {
149 $stack[$i] += array('args' => array());
150 return array(
151 'file' => $stack[$i]['file'],
152 'line' => $stack[$i]['line'],
153 'function' => $stack[$i + 1]['function'],
154 'class' => isset($stack[$i + 1]['class']) ? $stack[$i + 1]['class'] : NULL,
155 'type' => isset($stack[$i + 1]['type']) ? $stack[$i + 1]['type'] : NULL,
156 'args' => $stack[$i + 1]['args'],
157 );
158 }
159 }
160 }
161 }
DatabaseStatementInterface\getQueryString
getQueryString()
DatabaseLog\clear
clear($logging_key)
Definition: log.inc:91
DatabaseLog\$connectionKey
$connectionKey
Definition: log.inc:42
DatabaseLog\$queryLog
$queryLog
Definition: log.inc:35
DatabaseLog\start
start($logging_key)
Definition: log.inc:64
DatabaseStatementInterface
Definition: database.inc:1953
DatabaseLog\log
log(DatabaseStatementInterface $statement, $args, $time)
Definition: log.inc:115
DatabaseLog
Definition: log.inc:19
DatabaseLog\findCaller
findCaller()
Definition: log.inc:144
DatabaseLog\end
end($logging_key)
Definition: log.inc:101
DatabaseLog\__construct
__construct($key= 'default')
Definition: log.inc:50
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/trigger/trigger.api.php Source File

  • modules
  • trigger
trigger.api.php
Go to the documentation of this file.
1 <?php
2
42 function hook_trigger_info() {
43 return array(
44 'node' => array(
45 'node_presave' => array(
46 'label' => t('When either saving new content or updating existing content'),
47 ),
48 'node_insert' => array(
49 'label' => t('After saving new content'),
50 ),
51 'node_update' => array(
52 'label' => t('After saving updated content'),
53 ),
54 'node_delete' => array(
55 'label' => t('After deleting content'),
56 ),
57 'node_view' => array(
58 'label' => t('When content is viewed by an authenticated user'),
59 ),
60 ),
61 );
62 }
63
72 function hook_trigger_info_alter(&$triggers) {
73 $triggers['node']['node_insert']['label'] = t('When content is saved');
74 }
75
hook_trigger_info
hook_trigger_info()
Definition: trigger.api.php:42
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
hook_trigger_info_alter
hook_trigger_info_alter(&$triggers)
Definition: trigger.api.php:72
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example/ajax_example_autocomplete.inc Source File

  • examples
  • ajax_example
ajax_example_autocomplete.inc
Go to the documentation of this file.
1 <?php
22 function ajax_example_simple_autocomplete($form, &$form_state) {
23
24 $form['info'] = array(
25 '#markup' => '<div>' . t("This example does a simplest possible autocomplete by username. You'll need a few users on your system for it to make sense.") . '</div>',
26 );
27
28 $form['user'] = array(
29 '#type' => 'textfield',
30 '#title' => t('Choose a user (or a people, depending on your usage preference)'),
31 // The autocomplete path is provided in hook_menu in ajax_example.module.
32 '#autocomplete_path' => 'examples/ajax_example/simple_user_autocomplete_callback',
33 );
34
35 return $form;
36 }
37
58 function ajax_example_simple_user_autocomplete_callback($string = "") {
59 $matches = array();
60 if ($string) {
61 $result = db_select('users')
62 ->fields('users', array('name', 'uid'))
63 ->condition('name', db_like($string) . '%', 'LIKE')
64 ->range(0, 10)
65 ->execute();
66 foreach ($result as $user) {
67 // In the simplest case (see user_autocomplete), the key and the value are the same. Here we'll display the
68 // uid along with the username in the dropdown.
69 $matches[$user->name] = check_plain($user->name) . " (uid=$user->uid)";
70 }
71 }
72
73 drupal_json_output($matches);
74 }
75
76
77
78
87 function ajax_example_unique_autocomplete($form, &$form_state) {
88
89 $form['info'] = array(
90 '#markup' => '<div>' . t("This example does a node autocomplete by title. The difference between this and a username autocomplete is that the node title may not be unique, so we have to use the nid for uniqueness, placing it in a parseable location in the textfield.") . '</div>',
91 );
92
93 $form['node'] = array(
94 '#type' => 'textfield',
95 '#title' => t('Choose a node by title'),
96 // The autocomplete path is provided in hook_menu in ajax_example.module.
97 '#autocomplete_path' => 'examples/ajax_example/unique_node_autocomplete_callback',
98 );
99
100 $form['actions'] = array(
101 '#type' => 'actions'
102 );
103
104 $form['actions']['submit'] = array(
105 '#type' => 'submit',
106 '#value' => t('Submit'),
107 );
108
109 return $form;
110 }
111
124 function ajax_example_unique_autocomplete_validate($form, &$form_state) {
125 $title = $form_state['values']['node'];
126 $matches = array();
127 $nid = 0;
128
129 // This preg_match() looks for the last pattern like [33334] and if found extracts the numeric portion.
130 $result = preg_match('/\[([0-9]+)\]$/', $title, $matches);
131 if ($result > 0) {
132 // If $result is nonzero, we found a match and can use it as the index into $matches.
133 $nid = $matches[$result];
134 // Verify that it's a valid nid.
135 $node = node_load($nid);
136 if (empty($node)) {
137 form_error($form['node'], t('Sorry, no node with nid %nid can be found', array('%nid' => $nid)));
138 return;
139 }
140 }
141 // BUT: Not everybody will have javascript turned on, or they might hit ESC and not use the autocomplete values
142 // offered. In that case, we can attempt to come up with a useful value. This is not absolutely necessary,
143 // and we *could* just emit a form_error() as below.
144 else {
145 $nid = db_select('node')
146 ->fields('node', array('nid'))
147 ->condition('title', db_like($title) . '%', 'LIKE')
148 ->range(0, 1)
149 ->execute()
150 ->fetchField();
151 }
152
153 // Now, if we somehow found a nid, assign it to the node. If we failed, emit an error.
154 if (!empty($nid)) {
155 $form_state['values']['node'] = $nid;
156 }
157 else {
158 form_error($form['node'], t('Sorry, no node starting with %title can be found', array('%title' => $title)));
159 }
160 }
161
170 function ajax_example_unique_autocomplete_submit($form, &$form_state) {
171 $node = node_load($form_state['values']['node']);
172 drupal_set_message(t('You found node %nid with title %title', array('%nid' => $node->nid, '%title' => $node->title)));
173 }
174
191 function ajax_example_unique_node_autocomplete_callback($string = "") {
192 $matches = array();
193 if ($string) {
194 $result = db_select('node')
195 ->fields('node', array('nid', 'title'))
196 ->condition('title', db_like($string) . '%', 'LIKE')
197 ->range(0, 10)
198 ->execute();
199 foreach ($result as $node) {
200 $matches[$node->title . " [$node->nid]"] = check_plain($node->title);
201 }
202 }
203
204 drupal_json_output($matches);
205 }
206
207
208
209
224 function ajax_example_node_by_author_autocomplete($form, &$form_state) {
225
226 $form['intro'] = array(
227 '#markup' => '<div>' . t("This example uses a user autocomplete to dynamically change a node title autocomplete using #ajax.
228 This is a way to get past the fact that we have no other way to provide context to the autocomplete function.
229 It won't work very well unless you have a few users who have created some content that you can search for.") . '</div>',
230 );
231
232 $form['author'] = array(
233 '#type' => 'textfield',
234 '#title' => t('Choose the username that authored nodes you are interested in'),
235 // Since we just need simple user lookup, we can use the simplest function of them all, user_autocomplete().
236 '#autocomplete_path' => 'user/autocomplete',
237 '#ajax' => array(
238 'callback' => 'ajax_example_node_by_author_ajax_callback',
239 'wrapper' => 'autocomplete-by-node-ajax-replace',
240 ),
241 );
242
243 // This form element with autocomplete will be replaced by #ajax whenever the author changes, allowing the search
244 // to be limited by user.
245 $form['node'] = array(
246 '#type' => 'textfield',
247 '#title' => t('Choose a node by title'),
248 '#prefix' => '<div id="autocomplete-by-node-ajax-replace">',
249 '#suffix' => '</div>',
250 '#disabled' => TRUE,
251 );
252
253 // When the author changes in the author field, we'll change the autocomplete_path to match.
254 if (!empty($form_state['values']['author'])) {
255 $author = user_load_by_name($form_state['values']['author']);
256 if (!empty($author)) {
257 $autocomplete_path = 'examples/ajax_example/node_by_author_autocomplete/' . $author->uid;
258 $form['node']['#autocomplete_path'] = $autocomplete_path;
259 $form['node']['#title'] = t('Choose a node title authored by %author', array('%author' => $author->name));
260 $form['node']['#disabled'] = FALSE;
261 }
262 }
263
264 $form['actions'] = array(
265 '#type' => 'actions'
266 );
267
268 $form['actions']['submit'] = array(
269 '#type' => 'submit',
270 '#value' => t('Submit'),
271 );
272
273 return $form;
274 }
275
284 function ajax_example_node_by_author_ajax_callback($form, $form_state) {
285 return $form['node'];
286 }
287
304 function ajax_example_node_by_author_autocomplete_validate($form, &$form_state) {
305 $title = $form_state['values']['node'];
306 $author = $form_state['values']['author'];
307 $matches = array();
308 $nid = 0;
309
310 $account = user_load_by_name($author); // We must have a valid user.
311 if (empty($account)) {
312 form_error($form['author'], t('You must choose a valid author username'));
313 return;
314 }
315 // This preg_match() looks for the last pattern like [33334] and if found extracts the numeric portion.
316 $result = preg_match('/\[([0-9]+)\]$/', $title, $matches);
317 if ($result > 0) {
318 // If $result is nonzero, we found a match and can use it as the index into $matches.
319 $nid = $matches[$result];
320 // Verify that it's a valid nid.
321 $node = node_load($nid);
322 if (empty($node)) {
323 form_error($form['node'], t('Sorry, no node with nid %nid can be found', array('%nid' => $nid)));
324 return;
325 }
326 }
327 // BUT: Not everybody will have javascript turned on, or they might hit ESC and not use the autocomplete values
328 // offered. In that case, we can attempt to come up with a useful value. This is not absolutely necessary,
329 // and we *could* just emit a form_error() as below. Here we'll find the *first* matching title and assume
330 // that is adequate.
331 else {
332 $nid = db_select('node')
333 ->fields('node', array('nid'))
334 ->condition('uid', $account->uid)
335 ->condition('title', db_like($title) . '%', 'LIKE')
336 ->range(0, 1)
337 ->execute()
338 ->fetchField();
339 }
340
341 // Now, if we somehow found a nid, assign it to the node. If we failed, emit an error.
342 if (!empty($nid)) {
343 $form_state['values']['node'] = $nid;
344 }
345 else {
346 form_error($form['node'], t('Sorry, no node starting with %title can be found', array('%title' => $title)));
347 }
348 }
349
358 function ajax_example_node_by_author_autocomplete_submit($form, &$form_state) {
359 $node = node_load($form_state['values']['node']);
360 $account = user_load($node->uid);
361 drupal_set_message(t('You found node %nid with title !title_link, authored by !user_link',
362 array('%nid' => $node->nid, '!title_link' => l($node->title, 'node/' . $node->nid), '!user_link' => theme('username', array('account' => $account)))));
363 }
364
382 function ajax_example_node_by_author_node_autocomplete_callback($author_uid, $string = "") {
383 $matches = array();
384 if ($author_uid > 0 && trim($string)) {
385 $result = db_select('node')
386 ->fields('node', array('nid', 'title'))
387 ->condition('uid', $author_uid)
388 ->condition('title', db_like($string) . '%', 'LIKE')
389 ->range(0, 10)
390 ->execute();
391 foreach ($result as $node) {
392 $matches[$node->title . " [$node->nid]"] = check_plain($node->title);
393 }
394 }
395
396 drupal_json_output($matches);
397 }
ajax_example_simple_user_autocomplete_callback
ajax_example_simple_user_autocomplete_callback($string="")
Definition: ajax_example_autocomplete.inc:58
ajax_example_node_by_author_autocomplete
ajax_example_node_by_author_autocomplete($form, &$form_state)
Definition: ajax_example_autocomplete.inc:224
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_json_output
drupal_json_output($var=NULL)
Definition: common.inc:5041
ajax_example_node_by_author_node_autocomplete_callback
ajax_example_node_by_author_node_autocomplete_callback($author_uid, $string="")
Definition: ajax_example_autocomplete.inc:382
ajax_example_unique_autocomplete_validate
ajax_example_unique_autocomplete_validate($form, &$form_state)
Definition: ajax_example_autocomplete.inc:124
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
ajax_example_unique_autocomplete_submit
ajax_example_unique_autocomplete_submit($form, &$form_state)
Definition: ajax_example_autocomplete.inc:170
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
ajax_example_simple_autocomplete
ajax_example_simple_autocomplete($form, &$form_state)
Definition: ajax_example_autocomplete.inc:22
ajax_example_unique_node_autocomplete_callback
ajax_example_unique_node_autocomplete_callback($string="")
Definition: ajax_example_autocomplete.inc:191
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$author
print $author
Definition: comment.tpl.php:68
db_like
db_like($string)
Definition: database.inc:2610
node_load
node_load($nid=NULL, $vid=NULL, $reset=FALSE)
Definition: node.module:962
ajax_example_unique_autocomplete
ajax_example_unique_autocomplete($form, &$form_state)
Definition: ajax_example_autocomplete.inc:87
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
user_load_by_name
user_load_by_name($name)
Definition: user.module:397
user_load
user_load($uid, $reset=FALSE)
Definition: user.module:365
ajax_example_node_by_author_autocomplete_validate
ajax_example_node_by_author_autocomplete_validate($form, &$form_state)
Definition: ajax_example_autocomplete.inc:304
ajax_example_node_by_author_autocomplete_submit
ajax_example_node_by_author_autocomplete_submit($form, &$form_state)
Definition: ajax_example_autocomplete.inc:358
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
ajax_example_node_by_author_ajax_callback
ajax_example_node_by_author_ajax_callback($form, $form_state)
Definition: ajax_example_autocomplete.inc:284
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/bootstrap.inc Source File

  • includes
bootstrap.inc
Go to the documentation of this file.
1 <?php
2
11 define('VERSION', '7.26');
12
16 define('DRUPAL_CORE_COMPATIBILITY', '7.x');
17
21 define('DRUPAL_MINIMUM_PHP', '5.2.4');
22
26 define('DRUPAL_MINIMUM_PHP_MEMORY_LIMIT', '32M');
27
31 define('ERROR_REPORTING_HIDE', 0);
32
36 define('ERROR_REPORTING_DISPLAY_SOME', 1);
37
41 define('ERROR_REPORTING_DISPLAY_ALL', 2);
42
48 define('CACHE_PERMANENT', 0);
49
53 define('CACHE_TEMPORARY', -1);
54
78 define('WATCHDOG_EMERGENCY', 0);
79
83 define('WATCHDOG_ALERT', 1);
84
88 define('WATCHDOG_CRITICAL', 2);
89
93 define('WATCHDOG_ERROR', 3);
94
98 define('WATCHDOG_WARNING', 4);
99
103 define('WATCHDOG_NOTICE', 5);
104
108 define('WATCHDOG_INFO', 6);
109
113 define('WATCHDOG_DEBUG', 7);
114
122 define('DRUPAL_BOOTSTRAP_CONFIGURATION', 0);
123
127 define('DRUPAL_BOOTSTRAP_PAGE_CACHE', 1);
128
132 define('DRUPAL_BOOTSTRAP_DATABASE', 2);
133
137 define('DRUPAL_BOOTSTRAP_VARIABLES', 3);
138
142 define('DRUPAL_BOOTSTRAP_SESSION', 4);
143
147 define('DRUPAL_BOOTSTRAP_PAGE_HEADER', 5);
148
152 define('DRUPAL_BOOTSTRAP_LANGUAGE', 6);
153
157 define('DRUPAL_BOOTSTRAP_FULL', 7);
158
162 define('DRUPAL_ANONYMOUS_RID', 1);
163
167 define('DRUPAL_AUTHENTICATED_RID', 2);
168
174 define('DRUPAL_KILOBYTE', 1024);
175
181 define('LANGUAGE_NONE', 'und');
182
186 define('LANGUAGE_TYPE_CONTENT', 'language_content');
187
191 define('LANGUAGE_TYPE_INTERFACE', 'language');
192
196 define('LANGUAGE_TYPE_URL', 'language_url');
197
201 define('LANGUAGE_LTR', 0);
202
206 define('LANGUAGE_RTL', 1);
207
218 define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']);
219
225 define('CHECK_PLAIN', 0);
226
232 define('PASS_THROUGH', -1);
233
237 define('REGISTRY_RESET_LOOKUP_CACHE', 1);
238
242 define('REGISTRY_WRITE_LOOKUP_CACHE', 2);
243
249 define('DRUPAL_PHP_FUNCTION_PATTERN', '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*');
250
306 abstract class DrupalCacheArray implements ArrayAccess {
307
311 protected $cid;
312
316 protected $bin;
317
321 protected $keysToPersist = array();
322
326 protected $storage = array();
327
336 public function __construct($cid, $bin) {
337 $this->cid = $cid;
338 $this->bin = $bin;
339
340 if ($cached = cache_get($this->cid, $this->bin)) {
341 $this->storage = $cached->data;
342 }
343 }
344
348 public function offsetExists($offset) {
349 return $this->offsetGet($offset) !== NULL;
350 }
351
355 public function offsetGet($offset) {
356 if (isset($this->storage[$offset]) || array_key_exists($offset, $this->storage)) {
357 return $this->storage[$offset];
358 }
359 else {
360 return $this->resolveCacheMiss($offset);
361 }
362 }
363
367 public function offsetSet($offset, $value) {
368 $this->storage[$offset] = $value;
369 }
370
374 public function offsetUnset($offset) {
375 unset($this->storage[$offset]);
376 }
377
393 protected function persist($offset, $persist = TRUE) {
394 $this->keysToPersist[$offset] = $persist;
395 }
396
410 abstract protected function resolveCacheMiss($offset);
411
420 protected function set($data, $lock = TRUE) {
421 // Lock cache writes to help avoid stampedes.
422 // To implement locking for cache misses, override __construct().
423 $lock_name = $this->cid . ':' . $this->bin;
424 if (!$lock || lock_acquire($lock_name)) {
425 if ($cached = cache_get($this->cid, $this->bin)) {
426 $data = $cached->data + $data;
427 }
428 cache_set($this->cid, $data, $this->bin);
429 if ($lock) {
430 lock_release($lock_name);
431 }
432 }
433 }
434
438 public function __destruct() {
439 $data = array();
440 foreach ($this->keysToPersist as $offset => $persist) {
441 if ($persist) {
442 $data[$offset] = $this->storage[$offset];
443 }
444 }
445 if (!empty($data)) {
446 $this->set($data);
447 }
448 }
449 }
450
460 function timer_start($name) {
461 global $timers;
462
463 $timers[$name]['start'] = microtime(TRUE);
464 $timers[$name]['count'] = isset($timers[$name]['count']) ? ++$timers[$name]['count'] : 1;
465 }
466
476 function timer_read($name) {
477 global $timers;
478
479 if (isset($timers[$name]['start'])) {
480 $stop = microtime(TRUE);
481 $diff = round(($stop - $timers[$name]['start']) * 1000, 2);
482
483 if (isset($timers[$name]['time'])) {
484 $diff += $timers[$name]['time'];
485 }
486 return $diff;
487 }
488 return $timers[$name]['time'];
489 }
490
501 function timer_stop($name) {
502 global $timers;
503
504 if (isset($timers[$name]['start'])) {
505 $stop = microtime(TRUE);
506 $diff = round(($stop - $timers[$name]['start']) * 1000, 2);
507 if (isset($timers[$name]['time'])) {
508 $timers[$name]['time'] += $diff;
509 }
510 else {
511 $timers[$name]['time'] = $diff;
512 }
513 unset($timers[$name]['start']);
514 }
515
516 return $timers[$name];
517 }
518
541 function conf_path($require_settings = TRUE, $reset = FALSE) {
542 $conf = &drupal_static(__FUNCTION__, '');
543
544 if ($conf && !$reset) {
545 return $conf;
546 }
547
548 $confdir = 'sites';
549
550 $sites = array();
551 if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/sites.php')) {
552 // This will overwrite $sites with the desired mappings.
553 include(DRUPAL_ROOT . '/' . $confdir . '/sites.php');
554 }
555
556 $uri = explode('/', $_SERVER['SCRIPT_NAME'] ? $_SERVER['SCRIPT_NAME'] : $_SERVER['SCRIPT_FILENAME']);
557 $server = explode('.', implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));
558 for ($i = count($uri) - 1; $i > 0; $i--) {
559 for ($j = count($server); $j > 0; $j--) {
560 $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
561 if (isset($sites[$dir]) && file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $sites[$dir])) {
562 $dir = $sites[$dir];
563 }
564 if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $dir . '/settings.php') || (!$require_settings && file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $dir))) {
565 $conf = "$confdir/$dir";
566 return $conf;
567 }
568 }
569 }
570 $conf = "$confdir/default";
571 return $conf;
572 }
573
608 function drupal_override_server_variables($variables = array()) {
609 // Allow the provided URL to override any existing values in $_SERVER.
610 if (isset($variables['url'])) {
611 $url = parse_url($variables['url']);
612 if (isset($url['host'])) {
613 $_SERVER['HTTP_HOST'] = $url['host'];
614 }
615 if (isset($url['path'])) {
616 $_SERVER['SCRIPT_NAME'] = $url['path'];
617 }
618 unset($variables['url']);
619 }
620 // Define default values for $_SERVER keys. These will be used if $_SERVER
621 // does not already define them and no other values are passed in to this
622 // function.
623 $defaults = array(
624 'HTTP_HOST' => 'localhost',
625 'SCRIPT_NAME' => NULL,
626 'REMOTE_ADDR' => '127.0.0.1',
627 'REQUEST_METHOD' => 'GET',
628 'SERVER_NAME' => NULL,
629 'SERVER_SOFTWARE' => NULL,
630 'HTTP_USER_AGENT' => NULL,
631 );
632 // Replace elements of the $_SERVER array, as appropriate.
633 $_SERVER = $variables + $_SERVER + $defaults;
634 }
635
639 function drupal_environment_initialize() {
640 if (!isset($_SERVER['HTTP_REFERER'])) {
641 $_SERVER['HTTP_REFERER'] = '';
642 }
643 if (!isset($_SERVER['SERVER_PROTOCOL']) || ($_SERVER['SERVER_PROTOCOL'] != 'HTTP/1.0' && $_SERVER['SERVER_PROTOCOL'] != 'HTTP/1.1')) {
644 $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.0';
645 }
646
647 if (isset($_SERVER['HTTP_HOST'])) {
648 // As HTTP_HOST is user input, ensure it only contains characters allowed
649 // in hostnames. See RFC 952 (and RFC 2181).
650 // $_SERVER['HTTP_HOST'] is lowercased here per specifications.
651 $_SERVER['HTTP_HOST'] = strtolower($_SERVER['HTTP_HOST']);
652 if (!drupal_valid_http_host($_SERVER['HTTP_HOST'])) {
653 // HTTP_HOST is invalid, e.g. if containing slashes it may be an attack.
654 header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
655 exit;
656 }
657 }
658 else {
659 // Some pre-HTTP/1.1 clients will not send a Host header. Ensure the key is
660 // defined for E_ALL compliance.
661 $_SERVER['HTTP_HOST'] = '';
662 }
663
664 // When clean URLs are enabled, emulate ?q=foo/bar using REQUEST_URI. It is
665 // not possible to append the query string using mod_rewrite without the B
666 // flag (this was added in Apache 2.2.8), because mod_rewrite unescapes the
667 // path before passing it on to PHP. This is a problem when the path contains
668 // e.g. "&" or "%" that have special meanings in URLs and must be encoded.
669 $_GET['q'] = request_path();
670
671 // Enforce E_ALL, but allow users to set levels not part of E_ALL.
672 error_reporting(E_ALL | error_reporting());
673
674 // Override PHP settings required for Drupal to work properly.
675 // sites/default/default.settings.php contains more runtime settings.
676 // The .htaccess file contains settings that cannot be changed at runtime.
677
678 // Don't escape quotes when reading files from the database, disk, etc.
679 ini_set('magic_quotes_runtime', '0');
680 // Use session cookies, not transparent sessions that puts the session id in
681 // the query string.
682 ini_set('session.use_cookies', '1');
683 ini_set('session.use_only_cookies', '1');
684 ini_set('session.use_trans_sid', '0');
685 // Don't send HTTP headers using PHP's session handler.
686 // An empty string is used here to disable the cache limiter.
687 ini_set('session.cache_limiter', '');
688 // Use httponly session cookies.
689 ini_set('session.cookie_httponly', '1');
690
691 // Set sane locale settings, to ensure consistent string, dates, times and
692 // numbers handling.
693 setlocale(LC_ALL, 'C');
694 }
695
702 function drupal_valid_http_host($host) {
703 return preg_match('/^\[?(?:[a-zA-Z0-9-:\]_]+\.?)+$/', $host);
704 }
705
709 function drupal_settings_initialize() {
710 global $base_url, $base_path, $base_root;
711
712 // Export these settings.php variables to the global namespace.
713 global $databases, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $db_prefix, $drupal_hash_salt, $is_https, $base_secure_url, $base_insecure_url;
714 $conf = array();
715
716 if (file_exists(DRUPAL_ROOT . '/' . conf_path() . '/settings.php')) {
717 include_once DRUPAL_ROOT . '/' . conf_path() . '/settings.php';
718 }
719 $is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
720
721 if (isset($base_url)) {
722 // Parse fixed base URL from settings.php.
723 $parts = parse_url($base_url);
724 if (!isset($parts['path'])) {
725 $parts['path'] = '';
726 }
727 $base_path = $parts['path'] . '/';
728 // Build $base_root (everything until first slash after "scheme://").
729 $base_root = substr($base_url, 0, strlen($base_url) - strlen($parts['path']));
730 }
731 else {
732 // Create base URL.
733 $http_protocol = $is_https ? 'https' : 'http';
734 $base_root = $http_protocol . '://' . $_SERVER['HTTP_HOST'];
735
736 $base_url = $base_root;
737
738 // $_SERVER['SCRIPT_NAME'] can, in contrast to $_SERVER['PHP_SELF'], not
739 // be modified by a visitor.
740 if ($dir = rtrim(dirname($_SERVER['SCRIPT_NAME']), '\/')) {
741 $base_path = $dir;
742 $base_url .= $base_path;
743 $base_path .= '/';
744 }
745 else {
746 $base_path = '/';
747 }
748 }
749 $base_secure_url = str_replace('http://', 'https://', $base_url);
750 $base_insecure_url = str_replace('https://', 'http://', $base_url);
751
752 if ($cookie_domain) {
753 // If the user specifies the cookie domain, also use it for session name.
754 $session_name = $cookie_domain;
755 }
756 else {
757 // Otherwise use $base_url as session name, without the protocol
758 // to use the same session identifiers across HTTP and HTTPS.
759 list( , $session_name) = explode('://', $base_url, 2);
760 // HTTP_HOST can be modified by a visitor, but we already sanitized it
761 // in drupal_settings_initialize().
762 if (!empty($_SERVER['HTTP_HOST'])) {
763 $cookie_domain = $_SERVER['HTTP_HOST'];
764 // Strip leading periods, www., and port numbers from cookie domain.
765 $cookie_domain = ltrim($cookie_domain, '.');
766 if (strpos($cookie_domain, 'www.') === 0) {
767 $cookie_domain = substr($cookie_domain, 4);
768 }
769 $cookie_domain = explode(':', $cookie_domain);
770 $cookie_domain = '.' . $cookie_domain[0];
771 }
772 }
773 // Per RFC 2109, cookie domains must contain at least one dot other than the
774 // first. For hosts such as 'localhost' or IP Addresses we don't set a cookie domain.
775 if (count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
776 ini_set('session.cookie_domain', $cookie_domain);
777 }
778 // To prevent session cookies from being hijacked, a user can configure the
779 // SSL version of their website to only transfer session cookies via SSL by
780 // using PHP's session.cookie_secure setting. The browser will then use two
781 // separate session cookies for the HTTPS and HTTP versions of the site. So we
782 // must use different session identifiers for HTTPS and HTTP to prevent a
783 // cookie collision.
784 if ($is_https) {
785 ini_set('session.cookie_secure', TRUE);
786 }
787 $prefix = ini_get('session.cookie_secure') ? 'SSESS' : 'SESS';
788 session_name($prefix . substr(hash('sha256', $session_name), 0, 32));
789 }
790
820 function drupal_get_filename($type, $name, $filename = NULL) {
821 // The location of files will not change during the request, so do not use
822 // drupal_static().
823 static $files = array(), $dirs = array();
824
825 // Profiles are a special case: they have a fixed location and naming.
826 if ($type == 'profile') {
827 $profile_filename = "profiles/$name/$name.profile";
828 $files[$type][$name] = file_exists($profile_filename) ? $profile_filename : FALSE;
829 }
830 if (!isset($files[$type])) {
831 $files[$type] = array();
832 }
833
834 if (!empty($filename) && file_exists($filename)) {
835 $files[$type][$name] = $filename;
836 }
837 elseif (isset($files[$type][$name])) {
838 // nothing
839 }
840 // Verify that we have an active database connection, before querying
841 // the database. This is required because this function is called both
842 // before we have a database connection (i.e. during installation) and
843 // when a database connection fails.
844 else {
845 try {
846 if (function_exists('db_query')) {
847 $file = db_query("SELECT filename FROM {system} WHERE name = :name AND type = :type", array(':name' => $name, ':type' => $type))->fetchField();
848 if (file_exists(DRUPAL_ROOT . '/' . $file)) {
849 $files[$type][$name] = $file;
850 }
851 }
852 }
853 catch (Exception $e) {
854 // The database table may not exist because Drupal is not yet installed,
855 // or the database might be down. We have a fallback for this case so we
856 // hide the error completely.
857 }
858 // Fallback to searching the filesystem if the database could not find the
859 // file or the file returned by the database is not found.
860 if (!isset($files[$type][$name])) {
861 // We have a consistent directory naming: modules, themes...
862 $dir = $type . 's';
863 if ($type == 'theme_engine') {
864 $dir = 'themes/engines';
865 $extension = 'engine';
866 }
867 elseif ($type == 'theme') {
868 $extension = 'info';
869 }
870 else {
871 $extension = $type;
872 }
873
874 if (!isset($dirs[$dir][$extension])) {
875 $dirs[$dir][$extension] = TRUE;
876 if (!function_exists('drupal_system_listing')) {
877 require_once DRUPAL_ROOT . '/includes/common.inc';
878 }
879 // Scan the appropriate directories for all files with the requested
880 // extension, not just the file we are currently looking for. This
881 // prevents unnecessary scans from being repeated when this function is
882 // called more than once in the same page request.
883 $matches = drupal_system_listing("/^" . DRUPAL_PHP_FUNCTION_PATTERN . "\.$extension$/", $dir, 'name', 0);
884 foreach ($matches as $matched_name => $file) {
885 $files[$type][$matched_name] = $file->uri;
886 }
887 }
888 }
889 }
890
891 if (isset($files[$type][$name])) {
892 return $files[$type][$name];
893 }
894 }
895
903 function variable_initialize($conf = array()) {
904 // NOTE: caching the variables improves performance by 20% when serving
905 // cached pages.
906 if ($cached = cache_get('variables', 'cache_bootstrap')) {
907 $variables = $cached->data;
908 }
909 else {
910 // Cache miss. Avoid a stampede.
911 $name = 'variable_init';
912 if (!lock_acquire($name, 1)) {
913 // Another request is building the variable cache.
914 // Wait, then re-run this function.
915 lock_wait($name);
916 return variable_initialize($conf);
917 }
918 else {
919 // Proceed with variable rebuild.
920 $variables = array_map('unserialize', db_query('SELECT name, value FROM {variable}')->fetchAllKeyed());
921 cache_set('variables', $variables, 'cache_bootstrap');
922 lock_release($name);
923 }
924 }
925
926 foreach ($conf as $name => $value) {
927 $variables[$name] = $value;
928 }
929
930 return $variables;
931 }
932
951 function variable_get($name, $default = NULL) {
952 global $conf;
953
954 return isset($conf[$name]) ? $conf[$name] : $default;
955 }
956
973 function variable_set($name, $value) {
974 global $conf;
975
976 db_merge('variable')->key(array('name' => $name))->fields(array('value' => serialize($value)))->execute();
977
978 cache_clear_all('variables', 'cache_bootstrap');
979
980 $conf[$name] = $value;
981 }
982
996 function variable_del($name) {
997 global $conf;
998
999 db_delete('variable')
1000 ->condition('name', $name)
1001 ->execute();
1002 cache_clear_all('variables', 'cache_bootstrap');
1003
1004 unset($conf[$name]);
1005 }
1006
1022 function drupal_page_get_cache($check_only = FALSE) {
1023 global $base_root;
1024 static $cache_hit = FALSE;
1025
1026 if ($check_only) {
1027 return $cache_hit;
1028 }
1029
1030 if (drupal_page_is_cacheable()) {
1031 $cache = cache_get($base_root . request_uri(), 'cache_page');
1032 if ($cache !== FALSE) {
1033 $cache_hit = TRUE;
1034 }
1035 return $cache;
1036 }
1037 }
1038
1048 function drupal_page_is_cacheable($allow_caching = NULL) {
1049 $allow_caching_static = &drupal_static(__FUNCTION__, TRUE);
1050 if (isset($allow_caching)) {
1051 $allow_caching_static = $allow_caching;
1052 }
1053
1054 return $allow_caching_static && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD')
1055 && !drupal_is_cli();
1056 }
1057
1066 function bootstrap_invoke_all($hook) {
1067 // Bootstrap modules should have been loaded when this function is called, so
1068 // we don't need to tell module_list() to reset its internal list (and we
1069 // therefore leave the first parameter at its default value of FALSE). We
1070 // still pass in TRUE for the second parameter, though; in case this is the
1071 // first time during the bootstrap that module_list() is called, we want to
1072 // make sure that its internal cache is primed with the bootstrap modules
1073 // only.
1074 foreach (module_list(FALSE, TRUE) as $module) {
1075 drupal_load('module', $module);
1076 module_invoke($module, $hook);
1077 }
1078 }
1079
1093 function drupal_load($type, $name) {
1094 // Once a file is included this can't be reversed during a request so do not
1095 // use drupal_static() here.
1096 static $files = array();
1097
1098 if (isset($files[$type][$name])) {
1099 return TRUE;
1100 }
1101
1102 $filename = drupal_get_filename($type, $name);
1103
1104 if ($filename) {
1105 include_once DRUPAL_ROOT . '/' . $filename;
1106 $files[$type][$name] = TRUE;
1107
1108 return TRUE;
1109 }
1110
1111 return FALSE;
1112 }
1113
1129 function drupal_add_http_header($name, $value, $append = FALSE) {
1130 // The headers as name/value pairs.
1131 $headers = &drupal_static('drupal_http_headers', array());
1132
1133 $name_lower = strtolower($name);
1134 _drupal_set_preferred_header_name($name);
1135
1136 if ($value === FALSE) {
1137 $headers[$name_lower] = FALSE;
1138 }
1139 elseif (isset($headers[$name_lower]) && $append) {
1140 // Multiple headers with identical names may be combined using comma (RFC
1141 // 2616, section 4.2).
1142 $headers[$name_lower] .= ',' . $value;
1143 }
1144 else {
1145 $headers[$name_lower] = $value;
1146 }
1147 drupal_send_headers(array($name => $headers[$name_lower]), TRUE);
1148 }
1149
1161 function drupal_get_http_header($name = NULL) {
1162 $headers = &drupal_static('drupal_http_headers', array());
1163 if (isset($name)) {
1164 $name = strtolower($name);
1165 return isset($headers[$name]) ? $headers[$name] : NULL;
1166 }
1167 else {
1168 return $headers;
1169 }
1170 }
1171
1178 function _drupal_set_preferred_header_name($name = NULL) {
1179 static $header_names = array();
1180
1181 if (!isset($name)) {
1182 return $header_names;
1183 }
1184 $header_names[strtolower($name)] = $name;
1185 }
1186
1199 function drupal_send_headers($default_headers = array(), $only_default = FALSE) {
1200 $headers_sent = &drupal_static(__FUNCTION__, FALSE);
1201 $headers = drupal_get_http_header();
1202 if ($only_default && $headers_sent) {
1203 $headers = array();
1204 }
1205 $headers_sent = TRUE;
1206
1207 $header_names = _drupal_set_preferred_header_name();
1208 foreach ($default_headers as $name => $value) {
1209 $name_lower = strtolower($name);
1210 if (!isset($headers[$name_lower])) {
1211 $headers[$name_lower] = $value;
1212 $header_names[$name_lower] = $name;
1213 }
1214 }
1215 foreach ($headers as $name_lower => $value) {
1216 if ($name_lower == 'status') {
1217 header($_SERVER['SERVER_PROTOCOL'] . ' ' . $value);
1218 }
1219 // Skip headers that have been unset.
1220 elseif ($value !== FALSE) {
1221 header($header_names[$name_lower] . ': ' . $value);
1222 }
1223 }
1224 }
1225
1253 function drupal_page_header() {
1254 $headers_sent = &drupal_static(__FUNCTION__, FALSE);
1255 if ($headers_sent) {
1256 return TRUE;
1257 }
1258 $headers_sent = TRUE;
1259
1260 $default_headers = array(
1261 'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT',
1262 'Last-Modified' => gmdate(DATE_RFC1123, REQUEST_TIME),
1263 'Cache-Control' => 'no-cache, must-revalidate, post-check=0, pre-check=0',
1264 'ETag' => '"' . REQUEST_TIME . '"',
1265 );
1266 drupal_send_headers($default_headers);
1267 }
1268
1280 function drupal_serve_page_from_cache(stdClass $cache) {
1281 // Negotiate whether to use compression.
1282 $page_compression = !empty($cache->data['page_compressed']);
1283 $return_compressed = $page_compression && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE;
1284
1285 // Get headers set in hook_boot(). Keys are lower-case.
1286 $hook_boot_headers = drupal_get_http_header();
1287
1288 // Headers generated in this function, that may be replaced or unset using
1289 // drupal_add_http_headers(). Keys are mixed-case.
1290 $default_headers = array();
1291
1292 foreach ($cache->data['headers'] as $name => $value) {
1293 // In the case of a 304 response, certain headers must be sent, and the
1294 // remaining may not (see RFC 2616, section 10.3.5). Do not override
1295 // headers set in hook_boot().
1296 $name_lower = strtolower($name);
1297 if (in_array($name_lower, array('content-location', 'expires', 'cache-control', 'vary')) && !isset($hook_boot_headers[$name_lower])) {
1298 drupal_add_http_header($name, $value);
1299 unset($cache->data['headers'][$name]);
1300 }
1301 }
1302
1303 // If the client sent a session cookie, a cached copy will only be served
1304 // to that one particular client due to Vary: Cookie. Thus, do not set
1305 // max-age > 0, allowing the page to be cached by external proxies, when a
1306 // session cookie is present unless the Vary header has been replaced or
1307 // unset in hook_boot().
1308 $max_age = !isset($_COOKIE[session_name()]) || isset($hook_boot_headers['vary']) ? variable_get('page_cache_maximum_age', 0) : 0;
1309 $default_headers['Cache-Control'] = 'public, max-age=' . $max_age;
1310
1311 // Entity tag should change if the output changes.
1312 $etag = '"' . $cache->created . '-' . intval($return_compressed) . '"';
1313 header('Etag: ' . $etag);
1314
1315 // See if the client has provided the required HTTP headers.
1316 $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE;
1317 $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE;
1318
1319 if ($if_modified_since && $if_none_match
1320 && $if_none_match == $etag // etag must match
1321 && $if_modified_since == $cache->created) { // if-modified-since must match
1322 header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
1323 drupal_send_headers($default_headers);
1324 return;
1325 }
1326
1327 // Send the remaining headers.
1328 foreach ($cache->data['headers'] as $name => $value) {
1329 drupal_add_http_header($name, $value);
1330 }
1331
1332 $default_headers['Last-Modified'] = gmdate(DATE_RFC1123, $cache->created);
1333
1334 // HTTP/1.0 proxies does not support the Vary header, so prevent any caching
1335 // by sending an Expires date in the past. HTTP/1.1 clients ignores the
1336 // Expires header if a Cache-Control: max-age= directive is specified (see RFC
1337 // 2616, section 14.9.3).
1338 $default_headers['Expires'] = 'Sun, 19 Nov 1978 05:00:00 GMT';
1339
1340 drupal_send_headers($default_headers);
1341
1342 // Allow HTTP proxies to cache pages for anonymous users without a session
1343 // cookie. The Vary header is used to indicates the set of request-header
1344 // fields that fully determines whether a cache is permitted to use the
1345 // response to reply to a subsequent request for a given URL without
1346 // revalidation. If a Vary header has been set in hook_boot(), it is assumed
1347 // that the module knows how to cache the page.
1348 if (!isset($hook_boot_headers['vary']) && !variable_get('omit_vary_cookie')) {
1349 header('Vary: Cookie');
1350 }
1351
1352 if ($page_compression) {
1353 header('Vary: Accept-Encoding', FALSE);
1354 // If page_compression is enabled, the cache contains gzipped data.
1355 if ($return_compressed) {
1356 // $cache->data['body'] is already gzip'ed, so make sure
1357 // zlib.output_compression does not compress it once more.
1358 ini_set('zlib.output_compression', '0');
1359 header('Content-Encoding: gzip');
1360 }
1361 else {
1362 // The client does not support compression, so unzip the data in the
1363 // cache. Strip the gzip header and run uncompress.
1364 $cache->data['body'] = gzinflate(substr(substr($cache->data['body'], 10), 0, -8));
1365 }
1366 }
1367
1368 // Print the page.
1369 print $cache->data['body'];
1370 }
1371
1375 function bootstrap_hooks() {
1376 return array('boot', 'exit', 'watchdog', 'language_init');
1377 }
1378
1387 function drupal_unpack($obj, $field = 'data') {
1388 if ($obj->$field && $data = unserialize($obj->$field)) {
1389 foreach ($data as $key => $value) {
1390 if (!empty($key) && !isset($obj->$key)) {
1391 $obj->$key = $value;
1392 }
1393 }
1394 }
1395 return $obj;
1396 }
1397
1459 function t($string, array $args = array(), array $options = array()) {
1460 global $language;
1461 static $custom_strings;
1462
1463 // Merge in default.
1464 if (empty($options['langcode'])) {
1465 $options['langcode'] = isset($language->language) ? $language->language : 'en';
1466 }
1467 if (empty($options['context'])) {
1468 $options['context'] = '';
1469 }
1470
1471 // First, check for an array of customized strings. If present, use the array
1472 // *instead of* database lookups. This is a high performance way to provide a
1473 // handful of string replacements. See settings.php for examples.
1474 // Cache the $custom_strings variable to improve performance.
1475 if (!isset($custom_strings[$options['langcode']])) {
1476 $custom_strings[$options['langcode']] = variable_get('locale_custom_strings_' . $options['langcode'], array());
1477 }
1478 // Custom strings work for English too, even if locale module is disabled.
1479 if (isset($custom_strings[$options['langcode']][$options['context']][$string])) {
1480 $string = $custom_strings[$options['langcode']][$options['context']][$string];
1481 }
1482 // Translate with locale module if enabled.
1483 elseif ($options['langcode'] != 'en' && function_exists('locale')) {
1484 $string = locale($string, $options['context'], $options['langcode']);
1485 }
1486 if (empty($args)) {
1487 return $string;
1488 }
1489 else {
1490 return format_string($string, $args);
1491 }
1492 }
1493
1527 function format_string($string, array $args = array()) {
1528 // Transform arguments before inserting them.
1529 foreach ($args as $key => $value) {
1530 switch ($key[0]) {
1531 case '@':
1532 // Escaped only.
1533 $args[$key] = check_plain($value);
1534 break;
1535
1536 case '%':
1537 default:
1538 // Escaped and placeholder.
1539 $args[$key] = drupal_placeholder($value);
1540 break;
1541
1542 case '!':
1543 // Pass-through.
1544 }
1545 }
1546 return strtr($string, $args);
1547 }
1548
1565 function check_plain($text) {
1566 return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
1567 }
1568
1593 function drupal_validate_utf8($text) {
1594 if (strlen($text) == 0) {
1595 return TRUE;
1596 }
1597 // With the PCRE_UTF8 modifier 'u', preg_match() fails silently on strings
1598 // containing invalid UTF-8 byte sequences. It does not reject character
1599 // codes above U+10FFFF (represented by 4 or more octets), though.
1600 return (preg_match('/^./us', $text) == 1);
1601 }
1602
1609 function request_uri() {
1610 if (isset($_SERVER['REQUEST_URI'])) {
1611 $uri = $_SERVER['REQUEST_URI'];
1612 }
1613 else {
1614 if (isset($_SERVER['argv'])) {
1615 $uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['argv'][0];
1616 }
1617 elseif (isset($_SERVER['QUERY_STRING'])) {
1618 $uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'];
1619 }
1620 else {
1621 $uri = $_SERVER['SCRIPT_NAME'];
1622 }
1623 }
1624 // Prevent multiple slashes to avoid cross site requests via the Form API.
1625 $uri = '/' . ltrim($uri, '/');
1626
1627 return $uri;
1628 }
1629
1654 function watchdog_exception($type, Exception $exception, $message = NULL, $variables = array(), $severity = WATCHDOG_ERROR, $link = NULL) {
1655
1656 // Use a default value if $message is not set.
1657 if (empty($message)) {
1658 // The exception message is run through check_plain() by _drupal_decode_exception().
1659 $message = '%type: !message in %function (line %line of %file).';
1660 }
1661 // $variables must be an array so that we can add the exception information.
1662 if (!is_array($variables)) {
1663 $variables = array();
1664 }
1665
1666 require_once DRUPAL_ROOT . '/includes/errors.inc';
1667 $variables += _drupal_decode_exception($exception);
1668 watchdog($type, $message, $variables, $severity, $link);
1669 }
1670
1704 function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) {
1705 global $user, $base_root;
1706
1707 static $in_error_state = FALSE;
1708
1709 // It is possible that the error handling will itself trigger an error. In that case, we could
1710 // end up in an infinite loop. To avoid that, we implement a simple static semaphore.
1711 if (!$in_error_state && function_exists('module_implements')) {
1712 $in_error_state = TRUE;
1713
1714 // The user object may not exist in all conditions, so 0 is substituted if needed.
1715 $user_uid = isset($user->uid) ? $user->uid : 0;
1716
1717 // Prepare the fields to be logged
1718 $log_entry = array(
1719 'type' => $type,
1720 'message' => $message,
1721 'variables' => $variables,
1722 'severity' => $severity,
1723 'link' => $link,
1724 'user' => $user,
1725 'uid' => $user_uid,
1726 'request_uri' => $base_root . request_uri(),
1727 'referer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
1728 'ip' => ip_address(),
1729 // Request time isn't accurate for long processes, use time() instead.
1730 'timestamp' => time(),
1731 );
1732
1733 // Call the logging hooks to log/process the message
1734 foreach (module_implements('watchdog') as $module) {
1735 module_invoke($module, 'watchdog', $log_entry);
1736 }
1737
1738 // It is critical that the semaphore is only cleared here, in the parent
1739 // watchdog() call (not outside the loop), to prevent recursive execution.
1740 $in_error_state = FALSE;
1741 }
1742 }
1743
1777 function drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE) {
1778 if ($message) {
1779 if (!isset($_SESSION['messages'][$type])) {
1780 $_SESSION['messages'][$type] = array();
1781 }
1782
1783 if ($repeat || !in_array($message, $_SESSION['messages'][$type])) {
1784 $_SESSION['messages'][$type][] = $message;
1785 }
1786
1787 // Mark this page as being uncacheable.
1788 drupal_page_is_cacheable(FALSE);
1789 }
1790
1791 // Messages not set when DB connection fails.
1792 return isset($_SESSION['messages']) ? $_SESSION['messages'] : NULL;
1793 }
1794
1820 function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
1821 if ($messages = drupal_set_message()) {
1822 if ($type) {
1823 if ($clear_queue) {
1824 unset($_SESSION['messages'][$type]);
1825 }
1826 if (isset($messages[$type])) {
1827 return array($type => $messages[$type]);
1828 }
1829 }
1830 else {
1831 if ($clear_queue) {
1832 unset($_SESSION['messages']);
1833 }
1834 return $messages;
1835 }
1836 }
1837 return array();
1838 }
1839
1848 function drupal_get_title() {
1849 $title = drupal_set_title();
1850
1851 // During a bootstrap, menu.inc is not included and thus we cannot provide a title.
1852 if (!isset($title) && function_exists('menu_get_active_title')) {
1853 $title = check_plain(menu_get_active_title());
1854 }
1855
1856 return $title;
1857 }
1858
1876 function drupal_set_title($title = NULL, $output = CHECK_PLAIN) {
1877 $stored_title = &drupal_static(__FUNCTION__);
1878
1879 if (isset($title)) {
1880 $stored_title = ($output == PASS_THROUGH) ? $title : check_plain($title);
1881 }
1882
1883 return $stored_title;
1884 }
1885
1900 function drupal_is_denied($ip) {
1901 // Because this function is called on every page request, we first check
1902 // for an array of IP addresses in settings.php before querying the
1903 // database.
1904 $blocked_ips = variable_get('blocked_ips');
1905 $denied = FALSE;
1906 if (isset($blocked_ips) && is_array($blocked_ips)) {
1907 $denied = in_array($ip, $blocked_ips);
1908 }
1909 // Only check if database.inc is loaded already. If
1910 // $conf['page_cache_without_database'] = TRUE; is set in settings.php,
1911 // then the database won't be loaded here so the IPs in the database
1912 // won't be denied. However the user asked explicitly not to use the
1913 // database and also in this case it's quite likely that the user relies
1914 // on higher performance solutions like a firewall.
1915 elseif (class_exists('Database', FALSE)) {
1916 $denied = (bool)db_query("SELECT 1 FROM {blocked_ips} WHERE ip = :ip", array(':ip' => $ip))->fetchField();
1917 }
1918 return $denied;
1919 }
1920
1927 function drupal_block_denied($ip) {
1928 // Deny access to blocked IP addresses - t() is not yet available.
1929 if (drupal_is_denied($ip)) {
1930 header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
1931 print 'Sorry, ' . check_plain(ip_address()) . ' has been banned.';
1932 exit();
1933 }
1934 }
1935
1945 function drupal_random_key($byte_count = 32) {
1946 return drupal_base64_encode(drupal_random_bytes($byte_count));
1947 }
1948
1957 function drupal_base64_encode($string) {
1958 $data = base64_encode($string);
1959 // Modify the output so it's safe to use in URLs.
1960 return strtr($data, array('+' => '-', '/' => '_', '=' => ''));
1961 }
1962
1974 function drupal_random_bytes($count) {
1975 // $random_state does not use drupal_static as it stores random bytes.
1976 static $random_state, $bytes, $has_openssl;
1977
1978 $missing_bytes = $count - strlen($bytes);
1979
1980 if ($missing_bytes > 0) {
1981 // PHP versions prior 5.3.4 experienced openssl_random_pseudo_bytes()
1982 // locking on Windows and rendered it unusable.
1983 if (!isset($has_openssl)) {
1984 $has_openssl = version_compare(PHP_VERSION, '5.3.4', '>=') && function_exists('openssl_random_pseudo_bytes');
1985 }
1986
1987 // openssl_random_pseudo_bytes() will find entropy in a system-dependent
1988 // way.
1989 if ($has_openssl) {
1990 $bytes .= openssl_random_pseudo_bytes($missing_bytes);
1991 }
1992
1993 // Else, read directly from /dev/urandom, which is available on many *nix
1994 // systems and is considered cryptographically secure.
1995 elseif ($fh = @fopen('/dev/urandom', 'rb')) {
1996 // PHP only performs buffered reads, so in reality it will always read
1997 // at least 4096 bytes. Thus, it costs nothing extra to read and store
1998 // that much so as to speed any additional invocations.
1999 $bytes .= fread($fh, max(4096, $missing_bytes));
2000 fclose($fh);
2001 }
2002
2003 // If we couldn't get enough entropy, this simple hash-based PRNG will
2004 // generate a good set of pseudo-random bytes on any system.
2005 // Note that it may be important that our $random_state is passed
2006 // through hash() prior to being rolled into $output, that the two hash()
2007 // invocations are different, and that the extra input into the first one -
2008 // the microtime() - is prepended rather than appended. This is to avoid
2009 // directly leaking $random_state via the $output stream, which could
2010 // allow for trivial prediction of further "random" numbers.
2011 if (strlen($bytes) < $count) {
2012 // Initialize on the first call. The contents of $_SERVER includes a mix of
2013 // user-specific and system information that varies a little with each page.
2014 if (!isset($random_state)) {
2015 $random_state = print_r($_SERVER, TRUE);
2016 if (function_exists('getmypid')) {
2017 // Further initialize with the somewhat random PHP process ID.
2018 $random_state .= getmypid();
2019 }
2020 $bytes = '';
2021 }
2022
2023 do {
2024 $random_state = hash('sha256', microtime() . mt_rand() . $random_state);
2025 $bytes .= hash('sha256', mt_rand() . $random_state, TRUE);
2026 }
2027 while (strlen($bytes) < $count);
2028 }
2029 }
2030 $output = substr($bytes, 0, $count);
2031 $bytes = substr($bytes, $count);
2032 return $output;
2033 }
2034
2047 function drupal_hmac_base64($data, $key) {
2048 // Casting $data and $key to strings here is necessary to avoid empty string
2049 // results of the hash function if they are not scalar values. As this
2050 // function is used in security-critical contexts like token validation it is
2051 // important that it never returns an empty string.
2052 $hmac = base64_encode(hash_hmac('sha256', (string) $data, (string) $key, TRUE));
2053 // Modify the hmac so it's safe to use in URLs.
2054 return strtr($hmac, array('+' => '-', '/' => '_', '=' => ''));
2055 }
2056
2067 function drupal_hash_base64($data) {
2068 $hash = base64_encode(hash('sha256', $data, TRUE));
2069 // Modify the hash so it's safe to use in URLs.
2070 return strtr($hash, array('+' => '-', '/' => '_', '=' => ''));
2071 }
2072
2100 function drupal_array_merge_deep() {
2101 $args = func_get_args();
2102 return drupal_array_merge_deep_array($args);
2103 }
2104
2122 function drupal_array_merge_deep_array($arrays) {
2123 $result = array();
2124
2125 foreach ($arrays as $array) {
2126 foreach ($array as $key => $value) {
2127 // Renumber integer keys as array_merge_recursive() does. Note that PHP
2128 // automatically converts array keys that are integer strings (e.g., '1')
2129 // to integers.
2130 if (is_integer($key)) {
2131 $result[] = $value;
2132 }
2133 // Recurse when both values are arrays.
2134 elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value)) {
2135 $result[$key] = drupal_array_merge_deep_array(array($result[$key], $value));
2136 }
2137 // Otherwise, use the latter value, overriding any previous value.
2138 else {
2139 $result[$key] = $value;
2140 }
2141 }
2142 }
2143
2144 return $result;
2145 }
2146
2152 function drupal_anonymous_user() {
2153 $user = variable_get('drupal_anonymous_user_object', new stdClass);
2154 $user->uid = 0;
2155 $user->hostname = ip_address();
2156 $user->roles = array();
2157 $user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
2158 $user->cache = 0;
2159 return $user;
2160 }
2161
2192 function drupal_bootstrap($phase = NULL, $new_phase = TRUE) {
2193 // Not drupal_static(), because does not depend on any run-time information.
2194 static $phases = array(
2195 DRUPAL_BOOTSTRAP_CONFIGURATION,
2196 DRUPAL_BOOTSTRAP_PAGE_CACHE,
2197 DRUPAL_BOOTSTRAP_DATABASE,
2198 DRUPAL_BOOTSTRAP_VARIABLES,
2199 DRUPAL_BOOTSTRAP_SESSION,
2200 DRUPAL_BOOTSTRAP_PAGE_HEADER,
2201 DRUPAL_BOOTSTRAP_LANGUAGE,
2202 DRUPAL_BOOTSTRAP_FULL,
2203 );
2204 // Not drupal_static(), because the only legitimate API to control this is to
2205 // call drupal_bootstrap() with a new phase parameter.
2206 static $final_phase;
2207 // Not drupal_static(), because it's impossible to roll back to an earlier
2208 // bootstrap state.
2209 static $stored_phase = -1;
2210
2211 // When not recursing, store the phase name so it's not forgotten while
2212 // recursing.
2213 if ($new_phase) {
2214 $final_phase = $phase;
2215 }
2216 if (isset($phase)) {
2217 // Call a phase if it has not been called before and is below the requested
2218 // phase.
2219 while ($phases && $phase > $stored_phase && $final_phase > $stored_phase) {
2220 $current_phase = array_shift($phases);
2221
2222 // This function is re-entrant. Only update the completed phase when the
2223 // current call actually resulted in a progress in the bootstrap process.
2224 if ($current_phase > $stored_phase) {
2225 $stored_phase = $current_phase;
2226 }
2227
2228 switch ($current_phase) {
2229 case DRUPAL_BOOTSTRAP_CONFIGURATION:
2230 _drupal_bootstrap_configuration();
2231 break;
2232
2233 case DRUPAL_BOOTSTRAP_PAGE_CACHE:
2234 _drupal_bootstrap_page_cache();
2235 break;
2236
2237 case DRUPAL_BOOTSTRAP_DATABASE:
2238 _drupal_bootstrap_database();
2239 break;
2240
2241 case DRUPAL_BOOTSTRAP_VARIABLES:
2242 _drupal_bootstrap_variables();
2243 break;
2244
2245 case DRUPAL_BOOTSTRAP_SESSION:
2246 require_once DRUPAL_ROOT . '/' . variable_get('session_inc', 'includes/session.inc');
2247 drupal_session_initialize();
2248 break;
2249
2250 case DRUPAL_BOOTSTRAP_PAGE_HEADER:
2251 _drupal_bootstrap_page_header();
2252 break;
2253
2254 case DRUPAL_BOOTSTRAP_LANGUAGE:
2255 drupal_language_initialize();
2256 break;
2257
2258 case DRUPAL_BOOTSTRAP_FULL:
2259 require_once DRUPAL_ROOT . '/includes/common.inc';
2260 _drupal_bootstrap_full();
2261 break;
2262 }
2263 }
2264 }
2265 return $stored_phase;
2266 }
2267
2271 function drupal_get_user_timezone() {
2272 global $user;
2273 if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) {
2274 return $user->timezone;
2275 }
2276 else {
2277 // Ignore PHP strict notice if time zone has not yet been set in the php.ini
2278 // configuration.
2279 return variable_get('date_default_timezone', @date_default_timezone_get());
2280 }
2281 }
2282
2289 function drupal_get_hash_salt() {
2290 global $drupal_hash_salt, $databases;
2291 // If the $drupal_hash_salt variable is empty, a hash of the serialized
2292 // database credentials is used as a fallback salt.
2293 return empty($drupal_hash_salt) ? hash('sha256', serialize($databases)) : $drupal_hash_salt;
2294 }
2295
2311 function _drupal_error_handler($error_level, $message, $filename, $line, $context) {
2312 require_once DRUPAL_ROOT . '/includes/errors.inc';
2313 _drupal_error_handler_real($error_level, $message, $filename, $line, $context);
2314 }
2315
2326 function _drupal_exception_handler($exception) {
2327 require_once DRUPAL_ROOT . '/includes/errors.inc';
2328
2329 try {
2330 // Log the message to the watchdog and return an error page to the user.
2331 _drupal_log_error(_drupal_decode_exception($exception), TRUE);
2332 }
2333 catch (Exception $exception2) {
2334 // Another uncaught exception was thrown while handling the first one.
2335 // If we are displaying errors, then do so with no possibility of a further uncaught exception being thrown.
2336 if (error_displayable()) {
2337 print '<h1>Additional uncaught exception thrown while handling exception.</h1>';
2338 print '<h2>Original</h2><p>' . _drupal_render_exception_safe($exception) . '</p>';
2339 print '<h2>Additional</h2><p>' . _drupal_render_exception_safe($exception2) . '</p><hr />';
2340 }
2341 }
2342 }
2343
2347 function _drupal_bootstrap_configuration() {
2348 // Set the Drupal custom error handler.
2349 set_error_handler('_drupal_error_handler');
2350 set_exception_handler('_drupal_exception_handler');
2351
2352 drupal_environment_initialize();
2353 // Start a page timer:
2354 timer_start('page');
2355 // Initialize the configuration, including variables from settings.php.
2356 drupal_settings_initialize();
2357 }
2358
2362 function _drupal_bootstrap_page_cache() {
2363 global $user;
2364
2365 // Allow specifying special cache handlers in settings.php, like
2366 // using memcached or files for storing cache information.
2367 require_once DRUPAL_ROOT . '/includes/cache.inc';
2368 foreach (variable_get('cache_backends', array()) as $include) {
2369 require_once DRUPAL_ROOT . '/' . $include;
2370 }
2371 // Check for a cache mode force from settings.php.
2372 if (variable_get('page_cache_without_database')) {
2373 $cache_enabled = TRUE;
2374 }
2375 else {
2376 drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES, FALSE);
2377 $cache_enabled = variable_get('cache');
2378 }
2379 drupal_block_denied(ip_address());
2380 // If there is no session cookie and cache is enabled (or forced), try
2381 // to serve a cached page.
2382 if (!isset($_COOKIE[session_name()]) && $cache_enabled) {
2383 // Make sure there is a user object because its timestamp will be
2384 // checked, hook_boot might check for anonymous user etc.
2385 $user = drupal_anonymous_user();
2386 // Get the page from the cache.
2387 $cache = drupal_page_get_cache();
2388 // If there is a cached page, display it.
2389 if (is_object($cache)) {
2390 header('X-Drupal-Cache: HIT');
2391 // Restore the metadata cached with the page.
2392 $_GET['q'] = $cache->data['path'];
2393 drupal_set_title($cache->data['title'], PASS_THROUGH);
2394 date_default_timezone_set(drupal_get_user_timezone());
2395 // If the skipping of the bootstrap hooks is not enforced, call
2396 // hook_boot.
2397 if (variable_get('page_cache_invoke_hooks', TRUE)) {
2398 bootstrap_invoke_all('boot');
2399 }
2400 drupal_serve_page_from_cache($cache);
2401 // If the skipping of the bootstrap hooks is not enforced, call
2402 // hook_exit.
2403 if (variable_get('page_cache_invoke_hooks', TRUE)) {
2404 bootstrap_invoke_all('exit');
2405 }
2406 // We are done.
2407 exit;
2408 }
2409 else {
2410 header('X-Drupal-Cache: MISS');
2411 }
2412 }
2413 }
2414
2418 function _drupal_bootstrap_database() {
2419 // Redirect the user to the installation script if Drupal has not been
2420 // installed yet (i.e., if no $databases array has been defined in the
2421 // settings.php file) and we are not already installing.
2422 if (empty($GLOBALS['databases']) && !drupal_installation_attempted()) {
2423 include_once DRUPAL_ROOT . '/includes/install.inc';
2424 install_goto('install.php');
2425 }
2426
2427 // The user agent header is used to pass a database prefix in the request when
2428 // running tests. However, for security reasons, it is imperative that we
2429 // validate we ourselves made the request.
2430 if ($test_prefix = drupal_valid_test_ua()) {
2431 // Set the test run id for use in other parts of Drupal.
2432 $test_info = &$GLOBALS['drupal_test_info'];
2433 $test_info['test_run_id'] = $test_prefix;
2434 $test_info['in_child_site'] = TRUE;
2435
2436 foreach ($GLOBALS['databases']['default'] as &$value) {
2437 // Extract the current default database prefix.
2438 if (!isset($value['prefix'])) {
2439 $current_prefix = '';
2440 }
2441 elseif (is_array($value['prefix'])) {
2442 $current_prefix = $value['prefix']['default'];
2443 }
2444 else {
2445 $current_prefix = $value['prefix'];
2446 }
2447
2448 // Remove the current database prefix and replace it by our own.
2449 $value['prefix'] = array(
2450 'default' => $current_prefix . $test_prefix,
2451 );
2452 }
2453 }
2454
2455 // Initialize the database system. Note that the connection
2456 // won't be initialized until it is actually requested.
2457 require_once DRUPAL_ROOT . '/includes/database/database.inc';
2458
2459 // Register autoload functions so that we can access classes and interfaces.
2460 // The database autoload routine comes first so that we can load the database
2461 // system without hitting the database. That is especially important during
2462 // the install or upgrade process.
2463 spl_autoload_register('drupal_autoload_class');
2464 spl_autoload_register('drupal_autoload_interface');
2465 }
2466
2470 function _drupal_bootstrap_variables() {
2471 global $conf;
2472
2473 // Initialize the lock system.
2474 require_once DRUPAL_ROOT . '/' . variable_get('lock_inc', 'includes/lock.inc');
2475 lock_initialize();
2476
2477 // Load variables from the database, but do not overwrite variables set in settings.php.
2478 $conf = variable_initialize(isset($conf) ? $conf : array());
2479 // Load bootstrap modules.
2480 require_once DRUPAL_ROOT . '/includes/module.inc';
2481 module_load_all(TRUE);
2482 }
2483
2487 function _drupal_bootstrap_page_header() {
2488 bootstrap_invoke_all('boot');
2489
2490 if (!drupal_is_cli()) {
2491 ob_start();
2492 drupal_page_header();
2493 }
2494 }
2495
2503 function drupal_get_bootstrap_phase() {
2504 return drupal_bootstrap();
2505 }
2506
2515 function drupal_valid_test_ua() {
2516 // No reason to reset this.
2517 static $test_prefix;
2518
2519 if (isset($test_prefix)) {
2520 return $test_prefix;
2521 }
2522
2523 if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/^(simpletest\d+);(.+);(.+);(.+)$/", $_SERVER['HTTP_USER_AGENT'], $matches)) {
2524 list(, $prefix, $time, $salt, $hmac) = $matches;
2525 $check_string = $prefix . ';' . $time . ';' . $salt;
2526 // We use the salt from settings.php to make the HMAC key, since
2527 // the database is not yet initialized and we can't access any Drupal variables.
2528 // The file properties add more entropy not easily accessible to others.
2529 $key = drupal_get_hash_salt() . filectime(__FILE__) . fileinode(__FILE__);
2530 $time_diff = REQUEST_TIME - $time;
2531 // Since we are making a local request a 5 second time window is allowed,
2532 // and the HMAC must match.
2533 if ($time_diff >= 0 && $time_diff <= 5 && $hmac == drupal_hmac_base64($check_string, $key)) {
2534 $test_prefix = $prefix;
2535 return $test_prefix;
2536 }
2537 }
2538
2539 $test_prefix = FALSE;
2540 return $test_prefix;
2541 }
2542
2546 function drupal_generate_test_ua($prefix) {
2547 static $key;
2548
2549 if (!isset($key)) {
2550 // We use the salt from settings.php to make the HMAC key, since
2551 // the database is not yet initialized and we can't access any Drupal variables.
2552 // The file properties add more entropy not easily accessible to others.
2553 $key = drupal_get_hash_salt() . filectime(__FILE__) . fileinode(__FILE__);
2554 }
2555 // Generate a moderately secure HMAC based on the database credentials.
2556 $salt = uniqid('', TRUE);
2557 $check_string = $prefix . ';' . time() . ';' . $salt;
2558 return $check_string . ';' . drupal_hmac_base64($check_string, $key);
2559 }
2560
2569 function drupal_maintenance_theme() {
2570 require_once DRUPAL_ROOT . '/includes/theme.maintenance.inc';
2571 _drupal_maintenance_theme();
2572 }
2573
2588 function drupal_fast_404() {
2589 $exclude_paths = variable_get('404_fast_paths_exclude', FALSE);
2590 if ($exclude_paths && !preg_match($exclude_paths, $_GET['q'])) {
2591 $fast_paths = variable_get('404_fast_paths', FALSE);
2592 if ($fast_paths && preg_match($fast_paths, $_GET['q'])) {
2593 drupal_add_http_header('Status', '404 Not Found');
2594 $fast_404_html = variable_get('404_fast_html', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>');
2595 // Replace @path in the variable with the page path.
2596 print strtr($fast_404_html, array('@path' => check_plain(request_uri())));
2597 exit;
2598 }
2599 }
2600 }
2601
2605 function drupal_installation_attempted() {
2606 return defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install';
2607 }
2608
2635 function get_t() {
2636 static $t;
2637 // This is not converted to drupal_static because there is no point in
2638 // resetting this as it can not change in the course of a request.
2639 if (!isset($t)) {
2640 $t = drupal_installation_attempted() ? 'st' : 't';
2641 }
2642 return $t;
2643 }
2644
2648 function drupal_language_initialize() {
2649 $types = language_types();
2650
2651 // Ensure the language is correctly returned, even without multilanguage
2652 // support. Also make sure we have a $language fallback, in case a language
2653 // negotiation callback needs to do a full bootstrap.
2654 // Useful for eg. XML/HTML 'lang' attributes.
2655 $default = language_default();
2656 foreach ($types as $type) {
2657 $GLOBALS[$type] = $default;
2658 }
2659 if (drupal_multilingual()) {
2660 include_once DRUPAL_ROOT . '/includes/language.inc';
2661 foreach ($types as $type) {
2662 $GLOBALS[$type] = language_initialize($type);
2663 }
2664 // Allow modules to react on language system initialization in multilingual
2665 // environments.
2666 bootstrap_invoke_all('language_init');
2667 }
2668 }
2669
2677 function drupal_language_types() {
2678 return array(
2679 LANGUAGE_TYPE_INTERFACE => TRUE,
2680 LANGUAGE_TYPE_CONTENT => FALSE,
2681 LANGUAGE_TYPE_URL => FALSE,
2682 );
2683 }
2684
2691 function drupal_multilingual() {
2692 // The "language_count" variable stores the number of enabled languages to
2693 // avoid unnecessarily querying the database when building the list of
2694 // enabled languages on monolingual sites.
2695 return variable_get('language_count', 1) > 1;
2696 }
2697
2705 function language_types() {
2706 return array_keys(variable_get('language_types', drupal_language_types()));
2707 }
2708
2723 function language_list($field = 'language') {
2724 $languages = &drupal_static(__FUNCTION__);
2725 // Init language list
2726 if (!isset($languages)) {
2727 if (drupal_multilingual() || module_exists('locale')) {
2728 $languages['language'] = db_query('SELECT * FROM {languages} ORDER BY weight ASC, name ASC')->fetchAllAssoc('language');
2729 // Users cannot uninstall the native English language. However, we allow
2730 // it to be hidden from the installed languages. Therefore, at least one
2731 // other language must be enabled then.
2732 if (!$languages['language']['en']->enabled && !variable_get('language_native_enabled', TRUE)) {
2733 unset($languages['language']['en']);
2734 }
2735 }
2736 else {
2737 // No locale module, so use the default language only.
2738 $default = language_default();
2739 $languages['language'][$default->language] = $default;
2740 }
2741 }
2742
2743 // Return the array indexed by the right field
2744 if (!isset($languages[$field])) {
2745 $languages[$field] = array();
2746 foreach ($languages['language'] as $lang) {
2747 // Some values should be collected into an array
2748 if (in_array($field, array('enabled', 'weight'))) {
2749 $languages[$field][$lang->$field][$lang->language] = $lang;
2750 }
2751 else {
2752 $languages[$field][$lang->$field] = $lang;
2753 }
2754 }
2755 }
2756 return $languages[$field];
2757 }
2758
2765 function language_default($property = NULL) {
2766 $language = variable_get('language_default', (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => ''));
2767 return $property ? $language->$property : $language;
2768 }
2769
2787 function request_path() {
2788 static $path;
2789
2790 if (isset($path)) {
2791 return $path;
2792 }
2793
2794 if (isset($_GET['q']) && is_string($_GET['q'])) {
2795 // This is a request with a ?q=foo/bar query string. $_GET['q'] is
2796 // overwritten in drupal_path_initialize(), but request_path() is called
2797 // very early in the bootstrap process, so the original value is saved in
2798 // $path and returned in later calls.
2799 $path = $_GET['q'];
2800 }
2801 elseif (isset($_SERVER['REQUEST_URI'])) {
2802 // This request is either a clean URL, or 'index.php', or nonsense.
2803 // Extract the path from REQUEST_URI.
2804 $request_path = strtok($_SERVER['REQUEST_URI'], '?');
2805 $base_path_len = strlen(rtrim(dirname($_SERVER['SCRIPT_NAME']), '\/'));
2806 // Unescape and strip $base_path prefix, leaving q without a leading slash.
2807 $path = substr(urldecode($request_path), $base_path_len + 1);
2808 // If the path equals the script filename, either because 'index.php' was
2809 // explicitly provided in the URL, or because the server added it to
2810 // $_SERVER['REQUEST_URI'] even when it wasn't provided in the URL (some
2811 // versions of Microsoft IIS do this), the front page should be served.
2812 if ($path == basename($_SERVER['PHP_SELF'])) {
2813 $path = '';
2814 }
2815 }
2816 else {
2817 // This is the front page.
2818 $path = '';
2819 }
2820
2821 // Under certain conditions Apache's RewriteRule directive prepends the value
2822 // assigned to $_GET['q'] with a slash. Moreover we can always have a trailing
2823 // slash in place, hence we need to normalize $_GET['q'].
2824 $path = trim($path, '/');
2825
2826 return $path;
2827 }
2828
2852 function arg($index = NULL, $path = NULL) {
2853 // Even though $arguments doesn't need to be resettable for any functional
2854 // reasons (the result of explode() does not depend on any run-time
2855 // information), it should be resettable anyway in case a module needs to
2856 // free up the memory used by it.
2857 // Use the advanced drupal_static() pattern, since this is called very often.
2858 static $drupal_static_fast;
2859 if (!isset($drupal_static_fast)) {
2860 $drupal_static_fast['arguments'] = &drupal_static(__FUNCTION__);
2861 }
2862 $arguments = &$drupal_static_fast['arguments'];
2863
2864 if (!isset($path)) {
2865 $path = $_GET['q'];
2866 }
2867 if (!isset($arguments[$path])) {
2868 $arguments[$path] = explode('/', $path);
2869 }
2870 if (!isset($index)) {
2871 return $arguments[$path];
2872 }
2873 if (isset($arguments[$path][$index])) {
2874 return $arguments[$path][$index];
2875 }
2876 }
2877
2890 function ip_address() {
2891 $ip_address = &drupal_static(__FUNCTION__);
2892
2893 if (!isset($ip_address)) {
2894 $ip_address = $_SERVER['REMOTE_ADDR'];
2895
2896 if (variable_get('reverse_proxy', 0)) {
2897 $reverse_proxy_header = variable_get('reverse_proxy_header', 'HTTP_X_FORWARDED_FOR');
2898 if (!empty($_SERVER[$reverse_proxy_header])) {
2899 // If an array of known reverse proxy IPs is provided, then trust
2900 // the XFF header if request really comes from one of them.
2901 $reverse_proxy_addresses = variable_get('reverse_proxy_addresses', array());
2902
2903 // Turn XFF header into an array.
2904 $forwarded = explode(',', $_SERVER[$reverse_proxy_header]);
2905
2906 // Trim the forwarded IPs; they may have been delimited by commas and spaces.
2907 $forwarded = array_map('trim', $forwarded);
2908
2909 // Tack direct client IP onto end of forwarded array.
2910 $forwarded[] = $ip_address;
2911
2912 // Eliminate all trusted IPs.
2913 $untrusted = array_diff($forwarded, $reverse_proxy_addresses);
2914
2915 // The right-most IP is the most specific we can trust.
2916 $ip_address = array_pop($untrusted);
2917 }
2918 }
2919 }
2920
2921 return $ip_address;
2922 }
2923
2940 function drupal_get_schema($table = NULL, $rebuild = FALSE) {
2941 static $schema;
2942
2943 if ($rebuild || !isset($table)) {
2944 $schema = drupal_get_complete_schema($rebuild);
2945 }
2946 elseif (!isset($schema)) {
2947 $schema = new SchemaCache();
2948 }
2949
2950 if (!isset($table)) {
2951 return $schema;
2952 }
2953 if (isset($schema[$table])) {
2954 return $schema[$table];
2955 }
2956 else {
2957 return FALSE;
2958 }
2959 }
2960
2964 class SchemaCache extends DrupalCacheArray {
2965
2969 public function __construct() {
2970 // Cache by request method.
2971 parent::__construct('schema:runtime:' . ($_SERVER['REQUEST_METHOD'] == 'GET'), 'cache');
2972 }
2973
2977 protected function resolveCacheMiss($offset) {
2978 $complete_schema = drupal_get_complete_schema();
2979 $value = isset($complete_schema[$offset]) ? $complete_schema[$offset] : NULL;
2980 $this->storage[$offset] = $value;
2981 $this->persist($offset);
2982 return $value;
2983 }
2984 }
2985
2995 function drupal_get_complete_schema($rebuild = FALSE) {
2996 static $schema = array();
2997
2998 if (empty($schema) || $rebuild) {
2999 // Try to load the schema from cache.
3000 if (!$rebuild && $cached = cache_get('schema')) {
3001 $schema = $cached->data;
3002 }
3003 // Otherwise, rebuild the schema cache.
3004 else {
3005 $schema = array();
3006 // Load the .install files to get hook_schema.
3007 // On some databases this function may be called before bootstrap has
3008 // been completed, so we force the functions we need to load just in case.
3009 if (function_exists('module_load_all_includes')) {
3010 // This function can be called very early in the bootstrap process, so
3011 // we force the module_list() cache to be refreshed to ensure that it
3012 // contains the complete list of modules before we go on to call
3013 // module_load_all_includes().
3014 module_list(TRUE);
3015 module_load_all_includes('install');
3016 }
3017
3018 require_once DRUPAL_ROOT . '/includes/common.inc';
3019 // Invoke hook_schema for all modules.
3020 foreach (module_implements('schema') as $module) {
3021 // Cast the result of hook_schema() to an array, as a NULL return value
3022 // would cause array_merge() to set the $schema variable to NULL as well.
3023 // That would break modules which use $schema further down the line.
3024 $current = (array) module_invoke($module, 'schema');
3025 // Set 'module' and 'name' keys for each table, and remove descriptions,
3026 // as they needlessly slow down cache_get() for every single request.
3027 _drupal_schema_initialize($current, $module);
3028 $schema = array_merge($schema, $current);
3029 }
3030
3031 drupal_alter('schema', $schema);
3032 // If the schema is empty, avoid saving it: some database engines require
3033 // the schema to perform queries, and this could lead to infinite loops.
3034 if (!empty($schema) && (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL)) {
3035 cache_set('schema', $schema);
3036 }
3037 if ($rebuild) {
3038 cache_clear_all('schema:', 'cache', TRUE);
3039 }
3040 }
3041 }
3042
3043 return $schema;
3044 }
3045
3068 function drupal_autoload_interface($interface) {
3069 return _registry_check_code('interface', $interface);
3070 }
3071
3084 function drupal_autoload_class($class) {
3085 return _registry_check_code('class', $class);
3086 }
3087
3103 function _registry_check_code($type, $name = NULL) {
3104 static $lookup_cache, $cache_update_needed;
3105
3106 if ($type == 'class' && class_exists($name) || $type == 'interface' && interface_exists($name)) {
3107 return TRUE;
3108 }
3109
3110 if (!isset($lookup_cache)) {
3111 $lookup_cache = array();
3112 if ($cache = cache_get('lookup_cache', 'cache_bootstrap')) {
3113 $lookup_cache = $cache->data;
3114 }
3115 }
3116
3117 // When we rebuild the registry, we need to reset this cache so
3118 // we don't keep lookups for resources that changed during the rebuild.
3119 if ($type == REGISTRY_RESET_LOOKUP_CACHE) {
3120 $cache_update_needed = TRUE;
3121 $lookup_cache = NULL;
3122 return;
3123 }
3124
3125 // Called from drupal_page_footer, we write to permanent storage if there
3126 // changes to the lookup cache for this request.
3127 if ($type == REGISTRY_WRITE_LOOKUP_CACHE) {
3128 if ($cache_update_needed) {
3129 cache_set('lookup_cache', $lookup_cache, 'cache_bootstrap');
3130 }
3131 return;
3132 }
3133
3134 // $type is either 'interface' or 'class', so we only need the first letter to
3135 // keep the cache key unique.
3136 $cache_key = $type[0] . $name;
3137 if (isset($lookup_cache[$cache_key])) {
3138 if ($lookup_cache[$cache_key]) {
3139 require_once DRUPAL_ROOT . '/' . $lookup_cache[$cache_key];
3140 }
3141 return (bool) $lookup_cache[$cache_key];
3142 }
3143
3144 // This function may get called when the default database is not active, but
3145 // there is no reason we'd ever want to not use the default database for
3146 // this query.
3147 $file = Database::getConnection('default', 'default')->query("SELECT filename FROM {registry} WHERE name = :name AND type = :type", array(
3148 ':name' => $name,
3149 ':type' => $type,
3150 ))
3151 ->fetchField();
3152
3153 // Flag that we've run a lookup query and need to update the cache.
3154 $cache_update_needed = TRUE;
3155
3156 // Misses are valuable information worth caching, so cache even if
3157 // $file is FALSE.
3158 $lookup_cache[$cache_key] = $file;
3159
3160 if ($file) {
3161 require_once DRUPAL_ROOT . '/' . $file;
3162 return TRUE;
3163 }
3164 else {
3165 return FALSE;
3166 }
3167 }
3168
3175 function registry_rebuild() {
3176 system_rebuild_module_data();
3177 registry_update();
3178 }
3179
3193 function registry_update() {
3194 // install_system_module() calls module_enable() which calls into this
3195 // function during initial system installation, so the lock system is neither
3196 // loaded nor does its storage exist yet.
3197 $in_installer = drupal_installation_attempted();
3198 if (!$in_installer && !lock_acquire(__FUNCTION__)) {
3199 // Another request got the lock, wait for it to finish.
3200 lock_wait(__FUNCTION__);
3201 return FALSE;
3202 }
3203
3204 require_once DRUPAL_ROOT . '/includes/registry.inc';
3205 _registry_update();
3206
3207 if (!$in_installer) {
3208 lock_release(__FUNCTION__);
3209 }
3210 return TRUE;
3211 }
3212
3335 function &drupal_static($name, $default_value = NULL, $reset = FALSE) {
3336 static $data = array(), $default = array();
3337 // First check if dealing with a previously defined static variable.
3338 if (isset($data[$name]) || array_key_exists($name, $data)) {
3339 // Non-NULL $name and both $data[$name] and $default[$name] statics exist.
3340 if ($reset) {
3341 // Reset pre-existing static variable to its default value.
3342 $data[$name] = $default[$name];
3343 }
3344 return $data[$name];
3345 }
3346 // Neither $data[$name] nor $default[$name] static variables exist.
3347 if (isset($name)) {
3348 if ($reset) {
3349 // Reset was called before a default is set and yet a variable must be
3350 // returned.
3351 return $data;
3352 }
3353 // First call with new non-NULL $name. Initialize a new static variable.
3354 $default[$name] = $data[$name] = $default_value;
3355 return $data[$name];
3356 }
3357 // Reset all: ($name == NULL). This needs to be done one at a time so that
3358 // references returned by earlier invocations of drupal_static() also get
3359 // reset.
3360 foreach ($default as $name => $value) {
3361 $data[$name] = $value;
3362 }
3363 // As the function returns a reference, the return should always be a
3364 // variable.
3365 return $data;
3366 }
3367
3374 function drupal_static_reset($name = NULL) {
3375 drupal_static($name, NULL, TRUE);
3376 }
3377
3381 function drupal_is_cli() {
3382 return (!isset($_SERVER['SERVER_SOFTWARE']) && (php_sapi_name() == 'cli' || (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0)));
3383 }
3384
3396 function drupal_placeholder($text) {
3397 return '<em class="placeholder">' . check_plain($text) . '</em>';
3398 }
3399
3417 function &drupal_register_shutdown_function($callback = NULL) {
3418 // We cannot use drupal_static() here because the static cache is reset during
3419 // batch processing, which breaks batch handling.
3420 static $callbacks = array();
3421
3422 if (isset($callback)) {
3423 // Only register the internal shutdown function once.
3424 if (empty($callbacks)) {
3425 register_shutdown_function('_drupal_shutdown_function');
3426 }
3427 $args = func_get_args();
3428 array_shift($args);
3429 // Save callback and arguments
3430 $callbacks[] = array('callback' => $callback, 'arguments' => $args);
3431 }
3432 return $callbacks;
3433 }
3434
3438 function _drupal_shutdown_function() {
3439 $callbacks = &drupal_register_shutdown_function();
3440
3441 // Set the CWD to DRUPAL_ROOT as it is not guaranteed to be the same as it
3442 // was in the normal context of execution.
3443 chdir(DRUPAL_ROOT);
3444
3445 try {
3446 while (list($key, $callback) = each($callbacks)) {
3447 call_user_func_array($callback['callback'], $callback['arguments']);
3448 }
3449 }
3450 catch (Exception $exception) {
3451 // If we are displaying errors, then do so with no possibility of a further uncaught exception being thrown.
3452 require_once DRUPAL_ROOT . '/includes/errors.inc';
3453 if (error_displayable()) {
3454 print '<h1>Uncaught exception thrown in shutdown function.</h1>';
3455 print '<p>' . _drupal_render_exception_safe($exception) . '</p><hr />';
3456 }
3457 }
3458 }
3459
3477 function drupal_check_memory_limit($required, $memory_limit = NULL) {
3478 if (!isset($memory_limit)) {
3479 $memory_limit = ini_get('memory_limit');
3480 }
3481
3482 // There is sufficient memory if:
3483 // - No memory limit is set.
3484 // - The memory limit is set to unlimited (-1).
3485 // - The memory limit is greater than the memory required for the operation.
3486 return ((!$memory_limit) || ($memory_limit == -1) || (parse_size($memory_limit) >= parse_size($required)));
3487 }
_drupal_log_error
_drupal_log_error($error, $fatal=FALSE)
Definition: errors.inc:171
_drupal_exception_handler
_drupal_exception_handler($exception)
Definition: bootstrap.inc:2326
drupal_base64_encode
drupal_base64_encode($string)
Definition: bootstrap.inc:1957
registry_rebuild
registry_rebuild()
Definition: bootstrap.inc:3175
module_list
module_list($refresh=FALSE, $bootstrap_refresh=FALSE, $sort=FALSE, $fixed_list=NULL)
Definition: module.inc:66
_drupal_bootstrap_configuration
_drupal_bootstrap_configuration()
Definition: bootstrap.inc:2347
drupal_unpack
drupal_unpack($obj, $field= 'data')
Definition: bootstrap.inc:1387
drupal_check_memory_limit
drupal_check_memory_limit($required, $memory_limit=NULL)
Definition: bootstrap.inc:3477
drupal_get_http_header
drupal_get_http_header($name=NULL)
Definition: bootstrap.inc:1161
watchdog_exception
watchdog_exception($type, Exception $exception, $message=NULL, $variables=array(), $severity=WATCHDOG_ERROR, $link=NULL)
Definition: bootstrap.inc:1654
DrupalCacheArray\$storage
$storage
Definition: bootstrap.inc:326
language_initialize
language_initialize($type)
Definition: language.inc:484
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
drupal_valid_test_ua
drupal_valid_test_ua()
Definition: bootstrap.inc:2515
drupal_block_denied
drupal_block_denied($ip)
Definition: bootstrap.inc:1927
drupal_get_bootstrap_phase
drupal_get_bootstrap_phase()
Definition: bootstrap.inc:2503
$databases
$databases
Definition: default.settings.php:213
DrupalCacheArray\offsetExists
offsetExists($offset)
Definition: bootstrap.inc:348
DrupalCacheArray\$keysToPersist
$keysToPersist
Definition: bootstrap.inc:321
Database\getConnection
static getConnection($target= 'default', $key=NULL)
Definition: database.inc:1460
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
$module
print $module
Definition: search-results.tpl.php:28
drupal_page_is_cacheable
drupal_page_is_cacheable($allow_caching=NULL)
Definition: bootstrap.inc:1048
menu_get_active_title
menu_get_active_title()
Definition: menu.inc:2611
locale
locale($string=NULL, $context=NULL, $langcode=NULL)
Definition: locale.module:668
registry_update
registry_update()
Definition: bootstrap.inc:3193
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
drupal_get_user_timezone
drupal_get_user_timezone()
Definition: bootstrap.inc:2271
drupal_language_types
drupal_language_types()
Definition: bootstrap.inc:2677
drupal_anonymous_user
drupal_anonymous_user()
Definition: bootstrap.inc:2152
_drupal_render_exception_safe
_drupal_render_exception_safe($exception)
Definition: errors.inc:134
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
SchemaCache\__construct
__construct()
Definition: bootstrap.inc:2969
DrupalCacheArray\set
set($data, $lock=TRUE)
Definition: bootstrap.inc:420
Exception
_drupal_schema_initialize
_drupal_schema_initialize(&$schema, $module, $remove_descriptions=TRUE)
Definition: common.inc:7025
LANGUAGE_TYPE_CONTENT
const LANGUAGE_TYPE_CONTENT
Definition: bootstrap.inc:186
DRUPAL_BOOTSTRAP_PAGE_CACHE
const DRUPAL_BOOTSTRAP_PAGE_CACHE
Definition: bootstrap.inc:127
SchemaCache
Definition: bootstrap.inc:2964
drupal_send_headers
drupal_send_headers($default_headers=array(), $only_default=FALSE)
Definition: bootstrap.inc:1199
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
DrupalCacheArray\__destruct
__destruct()
Definition: bootstrap.inc:438
module_exists
module_exists($module)
Definition: module.inc:274
ip_address
ip_address()
Definition: bootstrap.inc:2890
DRUPAL_BOOTSTRAP_PAGE_HEADER
const DRUPAL_BOOTSTRAP_PAGE_HEADER
Definition: bootstrap.inc:147
print
print
Definition: php-2.php:2
drupal_bootstrap
drupal_bootstrap($phase=NULL, $new_phase=TRUE)
Definition: bootstrap.inc:2192
drupal_array_merge_deep
drupal_array_merge_deep()
Definition: bootstrap.inc:2100
drupal_generate_test_ua
drupal_generate_test_ua($prefix)
Definition: bootstrap.inc:2546
drupal_hmac_base64
drupal_hmac_base64($data, $key)
Definition: bootstrap.inc:2047
$conf
global $conf
Definition: authorize.php:74
drupal_installation_attempted
drupal_installation_attempted()
Definition: bootstrap.inc:2605
drupal_fast_404
drupal_fast_404()
Definition: bootstrap.inc:2588
DrupalCacheArray\resolveCacheMiss
resolveCacheMiss($offset)
request_uri
request_uri()
Definition: bootstrap.inc:1609
drupal_page_header
drupal_page_header()
Definition: bootstrap.inc:1253
drupal_validate_utf8
drupal_validate_utf8($text)
Definition: bootstrap.inc:1593
_drupal_bootstrap_page_header
_drupal_bootstrap_page_header()
Definition: bootstrap.inc:2487
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
module_load_all
module_load_all($bootstrap=FALSE)
Definition: module.inc:19
DrupalCacheArray\offsetGet
offsetGet($offset)
Definition: bootstrap.inc:355
DrupalCacheArray\$cid
$cid
Definition: bootstrap.inc:311
system_rebuild_module_data
system_rebuild_module_data()
Definition: system.module:2444
DRUPAL_BOOTSTRAP_SESSION
const DRUPAL_BOOTSTRAP_SESSION
Definition: bootstrap.inc:142
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
REGISTRY_RESET_LOOKUP_CACHE
const REGISTRY_RESET_LOOKUP_CACHE
Definition: bootstrap.inc:237
drupal_get_messages
drupal_get_messages($type=NULL, $clear_queue=TRUE)
Definition: bootstrap.inc:1820
drupal_get_schema
drupal_get_schema($table=NULL, $rebuild=FALSE)
Definition: bootstrap.inc:2940
DRUPAL_ANONYMOUS_RID
const DRUPAL_ANONYMOUS_RID
Definition: bootstrap.inc:162
drupal_get_complete_schema
drupal_get_complete_schema($rebuild=FALSE)
Definition: bootstrap.inc:2995
drupal_valid_http_host
drupal_valid_http_host($host)
Definition: bootstrap.inc:702
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
_drupal_error_handler
_drupal_error_handler($error_level, $message, $filename, $line, $context)
Definition: bootstrap.inc:2311
$url
print $url
Definition: search-result.tpl.php:70
drupal_environment_initialize
drupal_environment_initialize()
Definition: bootstrap.inc:639
$update_free_access
$update_free_access
Definition: default.settings.php:226
drupal_serve_page_from_cache
drupal_serve_page_from_cache(stdClass $cache)
Definition: bootstrap.inc:1280
drupal_random_key
drupal_random_key($byte_count=32)
Definition: bootstrap.inc:1945
DRUPAL_BOOTSTRAP_VARIABLES
const DRUPAL_BOOTSTRAP_VARIABLES
Definition: bootstrap.inc:137
language_list
language_list($field= 'language')
Definition: bootstrap.inc:2723
timer_start
timer_start($name)
Definition: bootstrap.inc:460
drupal_session_initialize
drupal_session_initialize()
Definition: session.inc:239
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
drupal_override_server_variables
drupal_override_server_variables($variables=array())
Definition: bootstrap.inc:608
drupal_add_http_header
drupal_add_http_header($name, $value, $append=FALSE)
Definition: bootstrap.inc:1129
$value
print $value
Definition: user-profile-item.tpl.php:26
get_t
get_t()
Definition: bootstrap.inc:2635
timer_stop
timer_stop($name)
Definition: bootstrap.inc:501
bootstrap_hooks
bootstrap_hooks()
Definition: bootstrap.inc:1375
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$messages
print $messages
Definition: page.tpl.php:121
$output
$output
Definition: authorize.php:93
_drupal_error_handler_real
_drupal_error_handler_real($error_level, $message, $filename, $line, $context)
Definition: errors.inc:55
CHECK_PLAIN
const CHECK_PLAIN
Definition: bootstrap.inc:225
lock_initialize
lock_initialize()
Definition: lock.inc:67
REGISTRY_WRITE_LOOKUP_CACHE
const REGISTRY_WRITE_LOOKUP_CACHE
Definition: bootstrap.inc:242
DrupalCacheArray\offsetUnset
offsetUnset($offset)
Definition: bootstrap.inc:374
_drupal_bootstrap_database
_drupal_bootstrap_database()
Definition: bootstrap.inc:2418
parse_size
parse_size($size)
Definition: common.inc:1842
drupal_random_bytes
drupal_random_bytes($count)
Definition: bootstrap.inc:1974
drupal_array_merge_deep_array
drupal_array_merge_deep_array($arrays)
Definition: bootstrap.inc:2122
LANGUAGE_TYPE_URL
const LANGUAGE_TYPE_URL
Definition: bootstrap.inc:196
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
_registry_update
_registry_update()
Definition: registry.inc:21
_drupal_decode_exception
_drupal_decode_exception($exception)
Definition: errors.inc:88
drupal_static_reset
drupal_static_reset($name=NULL)
Definition: bootstrap.inc:3374
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
DrupalCacheArray\offsetSet
offsetSet($offset, $value)
Definition: bootstrap.inc:367
drupal_maintenance_theme
drupal_maintenance_theme()
Definition: bootstrap.inc:2569
error_displayable
error_displayable($error=NULL)
Definition: errors.inc:151
request_path
request_path()
Definition: bootstrap.inc:2787
cache_clear_all
cache_clear_all($cid=NULL, $bin=NULL, $wildcard=FALSE)
Definition: cache.inc:155
_drupal_shutdown_function
_drupal_shutdown_function()
Definition: bootstrap.inc:3438
conf_path
conf_path($require_settings=TRUE, $reset=FALSE)
Definition: bootstrap.inc:541
DrupalCacheArray
Definition: bootstrap.inc:306
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
_drupal_set_preferred_header_name
_drupal_set_preferred_header_name($name=NULL)
Definition: bootstrap.inc:1178
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
drupal_is_cli
drupal_is_cli()
Definition: bootstrap.inc:3381
drupal_language_initialize
drupal_language_initialize()
Definition: bootstrap.inc:2648
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
drupal_autoload_class
drupal_autoload_class($class)
Definition: bootstrap.inc:3084
timer_read
timer_read($name)
Definition: bootstrap.inc:476
lock_acquire
lock_acquire($name, $timeout=30.0)
Definition: lock.inc:102
drupal_autoload_interface
drupal_autoload_interface($interface)
Definition: bootstrap.inc:3068
DrupalCacheArray\persist
persist($offset, $persist=TRUE)
Definition: bootstrap.inc:393
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
lock_wait
lock_wait($name, $delay=30)
Definition: lock.inc:203
drupal_is_denied
drupal_is_denied($ip)
Definition: bootstrap.inc:1900
format_string
format_string($string, array $args=array())
Definition: bootstrap.inc:1527
_drupal_bootstrap_page_cache
_drupal_bootstrap_page_cache()
Definition: bootstrap.inc:2362
drupal_placeholder
drupal_placeholder($text)
Definition: bootstrap.inc:3396
$drupal_hash_salt
$drupal_hash_salt
Definition: default.settings.php:245
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
module_load_all_includes
module_load_all_includes($type, $name=NULL)
Definition: module.inc:340
language_default
language_default($property=NULL)
Definition: bootstrap.inc:2765
_drupal_bootstrap_variables
_drupal_bootstrap_variables()
Definition: bootstrap.inc:2470
DRUPAL_BOOTSTRAP_DATABASE
const DRUPAL_BOOTSTRAP_DATABASE
Definition: bootstrap.inc:132
DrupalCacheArray\$bin
$bin
Definition: bootstrap.inc:316
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
DRUPAL_BOOTSTRAP_LANGUAGE
const DRUPAL_BOOTSTRAP_LANGUAGE
Definition: bootstrap.inc:152
DRUPAL_PHP_FUNCTION_PATTERN
const DRUPAL_PHP_FUNCTION_PATTERN
Definition: bootstrap.inc:249
bootstrap_invoke_all
bootstrap_invoke_all($hook)
Definition: bootstrap.inc:1066
drupal_get_title
drupal_get_title()
Definition: bootstrap.inc:1848
$dir
print $dir
Definition: book-export-html.tpl.php:22
install_goto
install_goto($path)
Definition: install.inc:1027
drupal_system_listing
drupal_system_listing($mask, $directory, $key= 'name', $min_depth=1)
Definition: common.inc:5368
MAINTENANCE_MODE
const MAINTENANCE_MODE
Definition: authorize.php:36
DrupalCacheArray\__construct
__construct($cid, $bin)
Definition: bootstrap.inc:336
LANGUAGE_TYPE_INTERFACE
const LANGUAGE_TYPE_INTERFACE
Definition: bootstrap.inc:191
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
drupal_hash_base64
drupal_hash_base64($data)
Definition: bootstrap.inc:2067
_drupal_bootstrap_full
_drupal_bootstrap_full()
Definition: common.inc:5100
_drupal_maintenance_theme
_drupal_maintenance_theme()
Definition: theme.maintenance.inc:17
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
module_invoke
module_invoke($module, $hook)
Definition: module.inc:861
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
drupal_load
drupal_load($type, $name)
Definition: bootstrap.inc:1093
_registry_check_code
_registry_check_code($type, $name=NULL)
Definition: bootstrap.inc:3103
drupal_settings_initialize
drupal_settings_initialize()
Definition: bootstrap.inc:709
variable_initialize
variable_initialize($conf=array())
Definition: bootstrap.inc:903
lock_release
lock_release($name)
Definition: lock.inc:247
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
drupal_get_hash_salt
drupal_get_hash_salt()
Definition: bootstrap.inc:2289
drupal_page_get_cache
drupal_page_get_cache($check_only=FALSE)
Definition: bootstrap.inc:1022
language_types
language_types()
Definition: bootstrap.inc:2705
drupal_multilingual
drupal_multilingual()
Definition: bootstrap.inc:2691
drupal_get_filename
drupal_get_filename($type, $name, $filename=NULL)
Definition: bootstrap.inc:820
DRUPAL_BOOTSTRAP_FULL
const DRUPAL_BOOTSTRAP_FULL
Definition: bootstrap.inc:157
drupal_register_shutdown_function
& drupal_register_shutdown_function($callback=NULL)
Definition: bootstrap.inc:3417
DRUPAL_BOOTSTRAP_CONFIGURATION
const DRUPAL_BOOTSTRAP_CONFIGURATION
Definition: bootstrap.inc:122
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/render_example/render_example.install Source File

  • examples
  • render_example
render_example.install
Go to the documentation of this file.
1 <?php
2
11 function render_example_uninstall() {
12 variable_del('render_example_show_page');
13 variable_del('render_example_show_block');
14 variable_del('render_example_reverse_sidebar');
15 variable_del('render_example_note_about_render_arrays');
16 variable_del('render_example_move_navigation_menu');
17 }
variable_del
variable_del($name)
Definition: bootstrap.inc:996
render_example_uninstall
render_example_uninstall()
Definition: render_example.install:11
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
PagerDefault Member List

This is the complete list of members for PagerDefault, including all inherited members.

$connection | SelectQueryExtender | protected
$customCountQuery | PagerDefault | protected
$element | PagerDefault | protected
$limit | PagerDefault | protected
$maxElement | PagerDefault | static
$placeholder | SelectQueryExtender | protected
$query | SelectQueryExtender | protected
$uniqueIdentifier | SelectQueryExtender | protected
__call($method, $args) | SelectQueryExtender |
__clone() | SelectQueryExtender |
__construct(SelectQueryInterface $query, DatabaseConnection $connection) | PagerDefault |
__toString() | SelectQueryExtender |
addExpression($expression, $alias=NULL, $arguments=array()) | SelectQueryExtender |
addField($table_alias, $field, $alias=NULL) | SelectQueryExtender |
addJoin($type, $table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
addMetaData($key, $object) | SelectQueryExtender |
addTag($tag) | SelectQueryExtender |
arguments() | SelectQueryExtender |
compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder) | SelectQueryExtender |
compiled() | SelectQueryExtender |
condition($field, $value=NULL, $operator=NULL) | SelectQueryExtender |
conditions() | SelectQueryExtender |
countQuery() | SelectQueryExtender |
distinct($distinct=TRUE) | SelectQueryExtender |
element($element) | PagerDefault |
ensureElement() | PagerDefault | protected
execute() | PagerDefault |
exists(SelectQueryInterface $select) | SelectQueryExtender |
extend($extender_name) | SelectQueryExtender |
fields($table_alias, array $fields=array()) | SelectQueryExtender |
forUpdate($set=TRUE) | SelectQueryExtender |
getArguments(QueryPlaceholderInterface $queryPlaceholder=NULL) | SelectQueryExtender |
getCountQuery() | PagerDefault |
getExpressions() | SelectQueryExtender |
getFields() | SelectQueryExtender |
getGroupBy() | SelectQueryExtender |
getMetaData($key) | SelectQueryExtender |
getOrderBy() | SelectQueryExtender |
getTables() | SelectQueryExtender |
getUnion() | SelectQueryExtender |
groupBy($field) | SelectQueryExtender |
hasAllTags() | SelectQueryExtender |
hasAnyTag() | SelectQueryExtender |
hasTag($tag) | SelectQueryExtender |
having($snippet, $args=array()) | SelectQueryExtender |
havingArguments() | SelectQueryExtender |
havingCompile(DatabaseConnection $connection) | SelectQueryExtender |
havingCondition($field, $value=NULL, $operator= '=') | SelectQueryExtender |
havingConditions() | SelectQueryExtender |
innerJoin($table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
isNotNull($field) | SelectQueryExtender |
isNull($field) | SelectQueryExtender |
isPrepared() | SelectQueryExtender |
join($table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
leftJoin($table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
limit($limit=10) | PagerDefault |
nextPlaceholder() | SelectQueryExtender |
notExists(SelectQueryInterface $select) | SelectQueryExtender |
orderBy($field, $direction= 'ASC') | SelectQueryExtender |
orderRandom() | SelectQueryExtender |
preExecute(SelectQueryInterface $query=NULL) | SelectQueryExtender |
range($start=NULL, $length=NULL) | SelectQueryExtender |
rightJoin($table, $alias=NULL, $condition=NULL, $arguments=array()) | SelectQueryExtender |
setCountQuery(SelectQueryInterface $query) | PagerDefault |
union(SelectQueryInterface $query, $type= '') | SelectQueryExtender |
uniqueIdentifier() | SelectQueryExtender |
where($snippet, $args=array()) | SelectQueryExtender |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalFakeCache Member List

This is the complete list of members for DrupalFakeCache, including all inherited members.

$bin | DrupalDatabaseCache | protected
__construct($bin) | DrupalDatabaseCache |
clear($cid=NULL, $wildcard=FALSE) | DrupalFakeCache |
garbageCollection() | DrupalDatabaseCache | protected
get($cid) | DrupalFakeCache |
getMultiple(&$cids) | DrupalFakeCache |
isEmpty() | DrupalFakeCache |
isValidBin() | DrupalDatabaseCache |
prepareItem($cache) | DrupalDatabaseCache | protected
set($cid, $data, $expire=CACHE_PERMANENT) | DrupalFakeCache |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll-vote.tpl.php Source File

  • modules
  • poll
poll-vote.tpl.php
Go to the documentation of this file.
1 <?php
2
18 ?>
19 <div class="poll">
20 <div class="vote-form">
21 <div class="choices">
22 <?php if ($block): ?>
23 <div class="title"><?php print $title; ?></div>
24 <?php endif; ?>
25 <?php print $choice; ?>
26 </div>
27 <?php print $vote; ?>
28 </div>
29 <?php // This is the 'rest' of the form, in case items have been added. ?>
30 <?php print $rest ?>
31 </div>
print
print
Definition: php-2.php:2
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
endif
endif
Definition: aggregator-item.tpl.php:31
$choice
print $choice
Definition: poll-vote.tpl.php:25
$vote
print $vote
Definition: poll-vote.tpl.php:27
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: index.php Source File

index.php
Go to the documentation of this file.
1 <?php
2
17 define('DRUPAL_ROOT', getcwd());
18
19 require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
20 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
21 menu_execute_active_handler();
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
drupal_bootstrap
drupal_bootstrap($phase=NULL, $new_phase=TRUE)
Definition: bootstrap.inc:2192
menu_execute_active_handler
menu_execute_active_handler($path=NULL, $deliver=TRUE)
Definition: menu.inc:500
DRUPAL_BOOTSTRAP_FULL
const DRUPAL_BOOTSTRAP_FULL
Definition: bootstrap.inc:157
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/token_example/token_example.module Source File

  • examples
  • token_example
token_example.module
Go to the documentation of this file.
1 <?php
2
35 function token_example_menu() {
36 $items['examples/token'] = array(
37 'title' => 'Token example',
38 'description' => 'Test replacement tokens in real time.',
39 'page callback' => 'drupal_get_form',
40 'page arguments' => array('token_example_example_form'),
41 'access callback' => TRUE,
42 );
43 return $items;
44 }
45
52 function token_example_entity_info_alter(&$info) {
53 if (isset($info['taxonomy_term'])) {
54 $info['taxonomy_term']['token type'] = 'term';
55 }
56 if (isset($info['taxonomy_vocabulary'])) {
57 $info['taxonomy_vocabulary']['token type'] = 'vocabulary';
58 }
59 }
60
64 function token_example_example_form($form, &$form_state) {
65 $entities = entity_get_info();
66 $token_types = array();
67
68 // Scan through the list of entities for supported token entities.
69 foreach ($entities as $entity => $info) {
70 $object_callback = "_token_example_get_{$entity}";
71 if (function_exists($object_callback) && $objects = $object_callback()) {
72 $form[$entity] = array(
73 '#type' => 'select',
74 '#title' => $info['label'],
75 '#options' => array(0 => t('Not selected')) + $objects,
76 '#default_value' => isset($form_state['storage'][$entity]) ? $form_state['storage'][$entity] : 0,
77 '#access' => !empty($objects),
78 );
79
80 // Build a list of supported token types based on the available entites.
81 if ($form[$entity]['#access']) {
82 $token_types[$entity] = !empty($info['token type']) ? $info['token type'] : $entity;
83 }
84 }
85 }
86
87 $form['text'] = array(
88 '#type' => 'textarea',
89 '#title' => t('Enter your text here'),
90 '#default_value' => 'Hello [current-user:name]!'
91 );
92
93 // Display the results of tokenized text.
94 if (!empty($form_state['storage']['text'])) {
95 $form['text']['#default_value'] = $form_state['storage']['text'];
96
97 $data = array();
98 foreach ($entities as $entity => $info) {
99 if (!empty($form_state['storage'][$entity])) {
100 $objects = entity_load($entity, array($form_state['storage'][$entity]));
101 if ($objects) {
102 $data[$token_types[$entity]] = reset($objects);
103 }
104 }
105 }
106
107 // Display the tokenized text.
108 $form['text_tokenized'] = array(
109 '#type' => 'item',
110 '#title' => t('Result'),
111 '#markup' => token_replace($form_state['storage']['text'], $data),
112 );
113 }
114
115 $form['submit'] = array(
116 '#type' => 'submit',
117 '#value' => t('Submit'),
118 );
119
120 if (module_exists('token')) {
121 $form['token_tree'] = array(
122 '#theme' => 'token_tree',
123 '#token_types' => $token_types,
124 );
125 }
126 else {
127 $form['token_tree'] = array(
128 '#markup' => '<p>' . t('Enable the <a href="@drupal-token">Token module</a> to view the available token browser.', array('@drupal-token' => 'http://drupal.org/project/token')) . '</p>',
129 );
130 }
131
132 return $form;
133 }
134
138 function token_example_example_form_submit($form, &$form_state) {
139 $form_state['storage'] = $form_state['values'];
140 $form_state['rebuild'] = TRUE;
141 }
142
146 function _token_example_get_node() {
147 if (!user_access('access content') && !user_access('bypass node access')) {
148 return array();
149 }
150
151 $node_query = db_select('node', 'n');
152 $node_query->fields('n', array('nid', 'title'));
153 $node_query->condition('n.status', NODE_PUBLISHED);
154 $node_query->orderBy('n.created', 'DESC');
155 $node_query->range(0, 10);
156 $node_query->addTag('node_access');
157 $nodes = $node_query->execute()->fetchAllKeyed();
158 $nodes = array_map('check_plain', $nodes);
159 return $nodes;
160 }
161
165 function _token_example_get_comment() {
166 if (!module_exists('comment') || (!user_access('access comments') && !user_access('administer comments'))) {
167 return array();
168 }
169
170 $comment_query = db_select('comment', 'c');
171 $comment_query->innerJoin('node', 'n', 'n.nid = c.nid');
172 $comment_query->fields('c', array('cid', 'subject'));
173 $comment_query->condition('n.status', NODE_PUBLISHED);
174 $comment_query->condition('c.status', COMMENT_PUBLISHED);
175 $comment_query->orderBy('c.created', 'DESC');
176 $comment_query->range(0, 10);
177 $comment_query->addTag('node_access');
178 $comments = $comment_query->execute()->fetchAllKeyed();
179 $comments = array_map('check_plain', $comments);
180 return $comments;
181 }
182
186 function _token_example_get_user() {
187 if (!user_access('access user profiles') &&
188 !user_access('administer users')) {
189 return array();
190 }
191
192 $account_query = db_select('users', 'u');
193 $account_query->fields('u', array('uid', 'name'));
194 $account_query->condition('u.uid', 0, '>');
195 $account_query->condition('u.status', 1);
196 $account_query->range(0, 10);
197 $accounts = $account_query->execute()->fetchAllKeyed();
198 $accounts = array_map('check_plain', $accounts);
199 return $accounts;
200 }
201
205 function _token_example_get_taxonomy_term() {
206 $term_query = db_select('taxonomy_term_data', 'ttd');
207 $term_query->fields('ttd', array('tid', 'name'));
208 $term_query->range(0, 10);
209 $term_query->addTag('term_access');
210 $terms = $term_query->execute()->fetchAllKeyed();
211 $terms = array_map('check_plain', $terms);
212 return $terms;
213 }
214
218 function _token_example_get_file() {
219 $file_query = db_select('file_managed', 'f');
220 $file_query->fields('f', array('fid', 'filename'));
221 $file_query->range(0, 10);
222 $files = $file_query->execute()->fetchAllKeyed();
223 $files = array_map('check_plain', $files);
224 return $files;
225 }
token_example_entity_info_alter
token_example_entity_info_alter(&$info)
Definition: token_example.module:52
entity_load
entity_load($entity_type, $ids=FALSE, $conditions=array(), $reset=FALSE)
Definition: common.inc:7800
_token_example_get_taxonomy_term
_token_example_get_taxonomy_term()
Definition: token_example.module:205
token_example_example_form
token_example_example_form($form, &$form_state)
Definition: token_example.module:64
_token_example_get_user
_token_example_get_user()
Definition: token_example.module:186
entity_get_info
entity_get_info($entity_type=NULL)
Definition: common.inc:7617
module_exists
module_exists($module)
Definition: module.inc:274
token_replace
token_replace($text, array $data=array(), array $options=array())
Definition: token.inc:79
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
_token_example_get_comment
_token_example_get_comment()
Definition: token_example.module:165
NODE_PUBLISHED
const NODE_PUBLISHED
Definition: node.module:17
$info
$info
Definition: color.inc:6
token_example_menu
token_example_menu()
Definition: token_example.module:35
token_example_example_form_submit
token_example_example_form_submit($form, &$form_state)
Definition: token_example.module:138
user_access
user_access($string, $account=NULL)
Definition: user.module:794
COMMENT_PUBLISHED
const COMMENT_PUBLISHED
Definition: comment.module:20
_token_example_get_node
_token_example_get_node()
Definition: token_example.module:146
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
_token_example_get_file
_token_example_get_file()
Definition: token_example.module:218
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/form_example/form_example_elements.inc Source File

  • examples
  • form_example
form_example_elements.inc
Go to the documentation of this file.
1 <?php
2
77 function _form_example_element_info() {
78 // form_example_textfield is a trivial element based on textfield that
79 // requires only a definition and a theme function. In this case we provide
80 // the theme function using the parent "textfield" theme function, but it
81 // would by default be provided in hook_theme(), by a "form_example_textfield"
82 // theme implementation, provided by default by the function
83 // theme_form_example_textfield(). Note that the 'form_example_textfield'
84 // element type is completely defined here. There is no further code required
85 // for it.
86 $types['form_example_textfield'] = array(
87 // #input = TRUE means that the incoming value will be used to figure out
88 // what #value will be.
89 '#input' => TRUE,
90
91 // Use theme('textfield') to format this element on output.
92 '#theme' => array('textfield'),
93
94 // Do not provide autocomplete.
95 '#autocomplete_path' => FALSE,
96
97 // Allow theme('form_element') to control the markup surrounding this
98 // value on output.
99 '#theme_wrappers' => array('form_element'),
100 );
101
102 // form_example_checkbox is mostly a copy of the system-defined checkbox
103 // element.
104 $types['form_example_checkbox'] = array(
105 '#input' => TRUE, // This is an HTML <input>.
106
107 // @todo: Explain #return_value.
108 '#return_value' => TRUE,
109
110 // Our #process array will use the standard process functions used for a
111 // regular checkbox.
112 '#process' => array('form_process_checkbox', 'ajax_process_form'),
113
114 // Use theme('form_example_checkbox') to render this element on output.
115 '#theme' => 'form_example_checkbox',
116
117 // Use theme('form_element') to provide HTML wrappers for this element.
118 '#theme_wrappers' => array('form_element'),
119
120 // Place the title after the element (to the right of the checkbox).
121 // This attribute affects the behavior of theme_form_element().
122 '#title_display' => 'after',
123
124 // We use the default function name for the value callback, so it does not
125 // have to be listed explicitly. The pattern for the default function name
126 // is form_type_TYPENAME_value().
127 // '#value_callback' => 'form_type_form_example_checkbox_value',
128 );
129
130 // This discrete phonenumber element keeps its values as the separate elements
131 // area code, prefix, extension.
132 $types['form_example_phonenumber_discrete'] = array(
133 // #input == TRUE means that the form value here will be used to determine
134 // what #value will be.
135 '#input' => TRUE,
136
137 // #process is an array of callback functions executed when this element is
138 // processed. Here it provides the child form elements which define
139 // areacode, prefix, and extension.
140 '#process' => array('form_example_phonenumber_discrete_process'),
141
142 // validation handlers for this element. These are in addition to any
143 // validation handlers that might
144 '#element_validate' => array('form_example_phonenumber_discrete_validate'),
145 '#autocomplete_path' => FALSE,
146 '#theme_wrappers' => array('form_example_inline_form_element'),
147 );
148
149 // Define form_example_phonenumber_combined, which combines the phone
150 // number into a single validated text string.
151 $types['form_example_phonenumber_combined'] = array(
152 '#input' => TRUE ,
153 '#process' => array('form_example_phonenumber_combined_process'),
154 '#element_validate' => array('form_example_phonenumber_combined_validate'),
155 '#autocomplete_path' => FALSE,
156 '#value_callback' => 'form_example_phonenumber_combined_value',
157 '#default_value' => array(
158 'areacode' => '',
159 'prefix' => '',
160 'extension' => '',
161 ),
162 '#theme_wrappers' => array('form_example_inline_form_element'),
163 );
164 return $types;
165 }
166
167
178 function form_example_phonenumber_combined_value(&$element, $input = FALSE, $form_state = NULL) {
179 if (!$form_state['process_input']) {
180 $matches = array();
181 $match = preg_match('/^(\d{3})(\d{3})(\d{4})$/', $element['#default_value'], $matches);
182 if ($match) {
183 array_shift($matches); // get rid of the "all match" element
184 list($element['areacode'], $element['prefix'], $element['extension']) = $matches;
185 }
186 }
187 return $element;
188 }
189
200 function form_type_form_example_checkbox_value($element, $input = FALSE) {
201 if ($input === FALSE) {
202 return isset($element['#default_value']) ? $element['#default_value'] : 0;
203 }
204 else {
205 return isset($input) ? $element['#return_value'] : 0;
206 }
207 }
208
212 function form_example_phonenumber_discrete_process($element, &$form_state, $complete_form) {
213 // #tree = TRUE means that the values in $form_state['values'] will be stored
214 // hierarchically. In this case, the parts of the element will appear in
215 // $form_state['values'] as
216 // $form_state['values']['<element_name>']['areacode'],
217 // $form_state['values']['<element_name>']['prefix'],
218 // etc. This technique is preferred when an element has member form
219 // elements.
220 $element['#tree'] = TRUE;
221
222 // Normal FAPI field definitions, except that #value is defined.
223 $element['areacode'] = array(
224 '#type' => 'textfield',
225 '#size' => 3,
226 '#maxlength' => 3,
227 '#value' => $element['#value']['areacode'],
228 '#required' => TRUE,
229 '#prefix' => '(',
230 '#suffix' => ')',
231 );
232 $element['prefix'] = array(
233 '#type' => 'textfield',
234 '#size' => 3,
235 '#maxlength' => 3,
236 '#required' => TRUE,
237 '#value' => $element['#value']['prefix'],
238 );
239 $element['extension'] = array(
240 '#type' => 'textfield',
241 '#size' => 4,
242 '#maxlength' => 4,
243 '#value' => $element['#value']['extension'],
244 );
245
246 return $element;
247 }
248
259 function form_example_phonenumber_discrete_validate($element, &$form_state) {
260 if (isset($element['#value']['areacode'])) {
261 if (0 == preg_match('/^\d{3}$/', $element['#value']['areacode'])) {
262 form_error($element['areacode'], t('The area code is invalid.'));
263 }
264 }
265 if (isset($element['#value']['prefix'])) {
266 if (0 == preg_match('/^\d{3}$/', $element['#value']['prefix'])) {
267 form_error($element['prefix'], t('The prefix is invalid.'));
268 }
269 }
270 if (isset($element['#value']['extension'])) {
271 if (0 == preg_match('/^\d{4}$/', $element['#value']['extension'])) {
272 form_error($element['extension'], t('The extension is invalid.'));
273 }
274 }
275 return $element;
276 }
277
281 function form_example_phonenumber_combined_process($element, &$form_state, $complete_form) {
282 // #tree = TRUE means that the values in $form_state['values'] will be stored
283 // hierarchically. In this case, the parts of the element will appear in
284 // $form_state['values'] as
285 // $form_state['values']['<element_name>']['areacode'],
286 // $form_state['values']['<element_name>']['prefix'],
287 // etc. This technique is preferred when an element has member form
288 // elements.
289
290 $element['#tree'] = TRUE;
291
292 // Normal FAPI field definitions, except that #value is defined.
293 $element['areacode'] = array(
294 '#type' => 'textfield',
295 '#size' => 3,
296 '#maxlength' => 3,
297 '#required' => TRUE,
298 '#prefix' => '(',
299 '#suffix' => ')',
300 );
301 $element['prefix'] = array(
302 '#type' => 'textfield',
303 '#size' => 3,
304 '#maxlength' => 3,
305 '#required' => TRUE,
306 );
307 $element['extension'] = array(
308 '#type' => 'textfield',
309 '#size' => 4,
310 '#maxlength' => 4,
311 '#required' => TRUE,
312 );
313
314 $matches = array();
315 $match = preg_match('/^(\d{3})(\d{3})(\d{4})$/', $element['#default_value'], $matches);
316 if ($match) {
317 array_shift($matches); // get rid of the "all match" element
318 list($element['areacode']['#default_value'], $element['prefix']['#default_value'], $element['extension']['#default_value']) = $matches;
319 }
320
321 return $element;
322 }
323
336 function form_example_phonenumber_combined_validate($element, &$form_state) {
337 $lengths = array(
338 'areacode' => 3,
339 'prefix' => 3,
340 'extension' => 4,
341 );
342 foreach ($lengths as $member => $length) {
343 $regex = '/^\d{' . $length . '}$/';
344 if (!empty($element['#value'][$member]) && 0 == preg_match($regex, $element['#value'][$member])) {
345 form_error($element[$member], t('@member is invalid', array('@member' => $member)));
346 }
347 }
348
349 // Consolidate into the three parts into one combined value.
350 $value = $element['areacode']['#value'] . $element['prefix']['#value'] . $element['extension']['#value'];
351 form_set_value($element, $value, $form_state);
352 return $element;
353 }
354
361 function _form_example_element_theme() {
362 return array(
363 'form_example_inline_form_element' => array(
364 'render element' => 'element',
365 'file' => 'form_example_elements.inc',
366 ),
367 'form_example_checkbox' => array(
368 'render element' => 'element',
369 'file' => 'form_example_elements.inc',
370 ),
371 );
372 }
373
380 function theme_form_example_checkbox($variables) {
381 $element = $variables['element'];
382 return theme('checkbox', $element);
383 }
384
388 function theme_form_example_inline_form_element($variables) {
389 $element = $variables['element'];
390
391 // Add element #id for #type 'item'.
392 if (isset($element['#markup']) && !empty($element['#id'])) {
393 $attributes['id'] = $element['#id'];
394 }
395 // Add element's #type and #name as class to aid with JS/CSS selectors.
396 $attributes['class'] = array('form-item');
397 if (!empty($element['#type'])) {
398 $attributes['class'][] = 'form-type-' . strtr($element['#type'], '_', '-');
399 }
400 if (!empty($element['#name'])) {
401 $attributes['class'][] = 'form-item-' . strtr($element['#name'], array(' ' => '-', '_' => '-', '[' => '-', ']' => ''));
402 }
403 // Add a class for disabled elements to facilitate cross-browser styling.
404 if (!empty($element['#attributes']['disabled'])) {
405 $attributes['class'][] = 'form-disabled';
406 }
407 $output = '<div' . drupal_attributes($attributes) . '>' . "\n";
408
409 // If #title is not set, we don't display any label or required marker.
410 if (!isset($element['#title'])) {
411 $element['#title_display'] = 'none';
412 }
413 $prefix = isset($element['#field_prefix']) ? '<span class="field-prefix">' . $element['#field_prefix'] . '</span> ' : '';
414 $suffix = isset($element['#field_suffix']) ? ' <span class="field-suffix">' . $element['#field_suffix'] . '</span>' : '';
415
416 switch ($element['#title_display']) {
417 case 'before':
418 $output .= ' ' . theme('form_element_label', $variables);
419 $output .= ' ' . '<div class="container-inline">' . $prefix . $element['#children'] . $suffix . "</div>\n";
420 break;
421
422 case 'invisible':
423 case 'after':
424 $output .= ' ' . $prefix . $element['#children'] . $suffix;
425 $output .= ' ' . theme('form_element_label', $variables) . "\n";
426 break;
427
428 case 'none':
429 case 'attribute':
430 // Output no label and no required marker, only the children.
431 $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n";
432 break;
433 }
434
435 if (!empty($element['#description'])) {
436 $output .= ' <div class="description">' . $element['#description'] . "</div>\n";
437 }
438
439 $output .= "</div>\n";
440
441 return $output;
442 }
443
448 function form_example_element_demo_form($form, &$form_state) {
449 $form['a_form_example_textfield'] = array(
450 '#type' => 'form_example_textfield',
451 '#title' => t('Form Example textfield'),
452 '#default_value' => variable_get('form_example_textfield', ''),
453 '#description' => t('form_example_textfield is a new type, but it is actually uses the system-provided functions of textfield'),
454 );
455
456 $form['a_form_example_checkbox'] = array(
457 '#type' => 'form_example_checkbox',
458 '#title' => t('Form Example checkbox'),
459 '#default_value' => variable_get('form_example_checkbox', FALSE),
460 '#description' => t('Nothing more than a regular checkbox but with a theme provided by this module.')
461 );
462
463 $form['a_form_example_element_discrete'] = array(
464 '#type' => 'form_example_phonenumber_discrete',
465 '#title' => t('Discrete phone number'),
466 '#default_value' => variable_get('form_example_element_discrete', array('areacode' => '999', 'prefix' => '999', 'extension' => '9999')),
467 '#description' => t('A phone number : areacode (XXX), prefix (XXX) and extension (XXXX). This one uses a "discrete" element type, one which stores the three parts of the telephone number separately.'),
468 );
469
470 $form['a_form_example_element_combined'] = array(
471 '#type' => 'form_example_phonenumber_combined',
472 '#title' => t('Combined phone number'),
473 '#default_value' => variable_get('form_example_element_combined', '0000000000'),
474 '#description' => t('form_example_element_combined one uses a "combined" element type, one with a single 10-digit value which is broken apart when needed.'),
475 );
476
477 $form['submit'] = array(
478 '#type' => 'submit',
479 '#value' => t('Submit'),
480 );
481
482 return $form;
483 }
484
488 function form_example_element_demo_form_submit($form, &$form_state) {
489 // Exclude unnecessary elements.
490 unset($form_state['values']['submit'], $form_state['values']['form_id'], $form_state['values']['op'], $form_state['values']['form_token'], $form_state['values']['form_build_id']);
491
492 foreach ($form_state['values'] as $key => $value) {
493 variable_set($key, $value);
494 drupal_set_message(t('%name has value %value', array('%name' => $key, '%value' => print_r($value, TRUE))));
495 }
496 }
_form_example_element_info
_form_example_element_info()
Definition: form_example_elements.inc:77
form_type_form_example_checkbox_value
form_type_form_example_checkbox_value($element, $input=FALSE)
Definition: form_example_elements.inc:200
form_example_phonenumber_discrete_validate
form_example_phonenumber_discrete_validate($element, &$form_state)
Definition: form_example_elements.inc:259
drupal_attributes
drupal_attributes(array $attributes=array())
Definition: common.inc:2377
$attributes
print $attributes
Definition: block.tpl.php:47
form_example_phonenumber_combined_process
form_example_phonenumber_combined_process($element, &$form_state, $complete_form)
Definition: form_example_elements.inc:281
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
form_example_phonenumber_combined_validate
form_example_phonenumber_combined_validate($element, &$form_state)
Definition: form_example_elements.inc:336
theme_form_example_inline_form_element
theme_form_example_inline_form_element($variables)
Definition: form_example_elements.inc:388
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$output
$output
Definition: authorize.php:93
form_example_element_demo_form
form_example_element_demo_form($form, &$form_state)
Definition: form_example_elements.inc:448
form_example_phonenumber_discrete_process
form_example_phonenumber_discrete_process($element, &$form_state, $complete_form)
Definition: form_example_elements.inc:212
_form_example_element_theme
_form_example_element_theme()
Definition: form_example_elements.inc:361
form_example_phonenumber_combined_value
form_example_phonenumber_combined_value(&$element, $input=FALSE, $form_state=NULL)
Definition: form_example_elements.inc:178
form_example_element_demo_form_submit
form_example_element_demo_form_submit($form, &$form_state)
Definition: form_example_elements.inc:488
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
theme_form_example_checkbox
theme_form_example_checkbox($variables)
Definition: form_example_elements.inc:380
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalTestCase Member List

This is the complete list of members for DrupalTestCase, including all inherited members.

$assertions | DrupalTestCase | protected
$databasePrefix | DrupalTestCase | protected
$originalFileDirectory | DrupalTestCase | protected
$results | DrupalTestCase |
$setup | DrupalTestCase | protected
$setupDatabasePrefix | DrupalTestCase | protected
$setupEnvironment | DrupalTestCase | protected
$skipClasses | DrupalTestCase | protected
$testId | DrupalTestCase | protected
$timeLimit | DrupalTestCase | protected
__construct($test_id=NULL) | DrupalTestCase |
assert($status, $message= '', $group= 'Other', array $caller=NULL) | DrupalTestCase | protected
assertEqual($first, $second, $message= '', $group= 'Other') | DrupalTestCase | protected
assertFalse($value, $message= '', $group= 'Other') | DrupalTestCase | protected
assertIdentical($first, $second, $message= '', $group= 'Other') | DrupalTestCase | protected
assertNotEqual($first, $second, $message= '', $group= 'Other') | DrupalTestCase | protected
assertNotIdentical($first, $second, $message= '', $group= 'Other') | DrupalTestCase | protected
assertNotNull($value, $message= '', $group= 'Other') | DrupalTestCase | protected
assertNull($value, $message= '', $group= 'Other') | DrupalTestCase | protected
assertTrue($value, $message= '', $group= 'Other') | DrupalTestCase | protected
deleteAssert($message_id) | DrupalTestCase | static
error($message= '', $group= 'Other', array $caller=NULL) | DrupalTestCase | protected
errorHandler($severity, $message, $file=NULL, $line=NULL) | DrupalTestCase |
exceptionHandler($exception) | DrupalTestCase | protected
fail($message=NULL, $group= 'Other') | DrupalTestCase | protected
generatePermutations($parameters) | DrupalTestCase | static
getAssertionCall() | DrupalTestCase | protected
insertAssert($test_id, $test_class, $status, $message= '', $group= 'Other', array $caller=array()) | DrupalTestCase | static
pass($message=NULL, $group= 'Other') | DrupalTestCase | protected
randomName($length=8) | DrupalTestCase | static
randomString($length=8) | DrupalTestCase | static
run(array $methods=array()) | DrupalTestCase |
verbose($message) | DrupalTestCase | protected
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/nodeapi_example/nodeapi_example.module Source File

  • examples
  • nodeapi_example
nodeapi_example.module
Go to the documentation of this file.
1 <?php
2
45 function nodeapi_example_form_alter(&$form, $form_state, $form_id) {
46 // First, check for the node type configuration form.
47 if ($form_id == 'node_type_form') {
48 // Alter the node type's configuration form to add our setting. We don't
49 // need to worry about saving this value back to the variable, the form
50 // we're altering will do it for us.
51 $form['rating'] = array(
52 '#type' => 'fieldset',
53 '#title' => t('Rating settings'),
54 '#collapsible' => TRUE,
55 '#collapsed' => TRUE,
56 '#group' => 'additional_settings',
57 '#weight' => -1,
58 );
59
60 $form['rating']['nodeapi_example_node_type'] = array(
61 '#type' => 'radios',
62 '#title' => t('NodeAPI Example Rating'),
63 '#default_value' => variable_get('nodeapi_example_node_type_' . $form['#node_type']->type, FALSE),
64 '#options' => array(
65 FALSE => t('Disabled'),
66 TRUE => t('Enabled')
67 ),
68 '#description' => t('Should this node have a rating attached to it?'),
69 );
70 }
71 // Here we check to see if the type and node field are set. If so, it could
72 // be a node edit form.
73 elseif (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
74 // If the rating is enabled for this node type, we insert our control
75 // into the form.
76 $node = $form['#node'];
77 if (variable_get('nodeapi_example_node_type_' . $form['type']['#value'], FALSE)) {
78 $form['nodeapi_example_rating'] = array(
79 '#type' => 'select',
80 '#title' => t('Rating'),
81 '#default_value' => isset($node->nodeapi_example_rating) ? $node->nodeapi_example_rating : '',
82 '#options' => array(0 => t('Unrated'), 1, 2, 3, 4, 5),
83 '#required' => TRUE,
84 '#weight' => 0,
85 );
86 }
87 }
88 }
89
96 function nodeapi_example_node_validate($node, $form) {
97 if (variable_get('nodeapi_example_node_type_' . $node->type, FALSE)) {
98 if (isset($node->nodeapi_example_rating) && !$node->nodeapi_example_rating) {
99 form_set_error('nodeapi_example_rating', t('You must rate this content.'));
100 }
101 }
102 }
103
110 function nodeapi_example_node_load($nodes, $types) {
111 // We can use $types to figure out if we need to process any of these nodes.
112 $our_types = array();
113 foreach ($types as $type) {
114 if (variable_get('nodeapi_example_node_type_' . $type, FALSE)) {
115 $our_types[] = $type;
116 }
117 }
118
119 // Now $our_types contains all the types from $types that we want
120 // to deal with. If it's empty, we can safely return.
121 if (!count($our_types)) {
122 return;
123 }
124
125 // Now we need to make a list of revisions based on $our_types
126 foreach ($nodes as $node) {
127 // We are using the revision id instead of node id.
128 if (variable_get('nodeapi_example_node_type_' . $node->type, FALSE)) {
129 $vids[] = $node->vid;
130 }
131 }
132 // Check if we should load rating for any of the nodes.
133 if (!isset($vids) || !count($vids)) {
134 return;
135 }
136
137 // When we read, we don't care about the node->nid; we look for the right
138 // revision ID (node->vid).
139 $result = db_select('nodeapi_example', 'e')
140 ->fields('e', array('nid', 'vid', 'rating'))
141 ->where('e.vid IN (:vids)', array(':vids' => $vids))
142 ->execute();
143
144 foreach ($result as $record) {
145 $nodes[$record->nid]->nodeapi_example_rating = $record->rating;
146 }
147 }
148
155 function nodeapi_example_node_insert($node) {
156 if (variable_get('nodeapi_example_node_type_' . $node->type, FALSE)) {
157 // Notice that we are ignoring any revision information using $node->nid
158 db_insert('nodeapi_example')
159 ->fields(array(
160 'nid' => $node->nid,
161 'vid' => $node->vid,
162 'rating' => $node->nodeapi_example_rating,
163 ))
164 ->execute();
165 }
166 }
167
174 function nodeapi_example_node_delete($node) {
175 // Notice that we're deleting even if the content type has no rating enabled.
176 db_delete('nodeapi_example')
177 ->condition('nid', $node->nid)
178 ->execute();
179 }
180
192 function nodeapi_example_node_update($node) {
193 if (variable_get('nodeapi_example_node_type_' . $node->type, FALSE)) {
194 // Check first if this node has a saved rating.
195 $rating = db_select('nodeapi_example', 'e')
196 ->fields('e', array(
197 'rating',
198 ))
199 ->where('e.vid = (:vid)', array(':vid' => $node->vid))
200 ->execute()->fetchField();
201
202 if ($rating) {
203 // Node has been rated before.
204 db_update('nodeapi_example')
205 ->fields(array('rating' => $node->nodeapi_example_rating))
206 ->condition('vid', $node->vid)
207 ->execute();
208 }
209 else {
210 // Node was not previously rated, so insert a new rating in database.
211 nodeapi_example_node_insert($node);
212 }
213 }
214 }
215
232 function nodeapi_example_node_view($node, $build_mode = 'full') {
233 if (variable_get('nodeapi_example_node_type_' . $node->type, FALSE)) {
234 // Make sure to set a rating, also for nodes saved previously and not yet rated.
235 $rating = isset($node->nodeapi_example_rating) ? $node->nodeapi_example_rating : 0;
236 $node->content['nodeapi_example'] = array(
237 '#markup' => theme('nodeapi_example_rating', array('rating' => $rating)),
238 '#weight' => -1,
239 );
240 }
241 }
242
248 function nodeapi_example_theme() {
249 return array(
250 'nodeapi_example_rating' => array(
251 'variables' => array('rating' => NULL),
252 ),
253 );
254 }
255
265 function theme_nodeapi_example_rating($variables) {
266 $options = array(
267 0 => t('Unrated'),
268 1 => t('Poor'),
269 2 => t('Needs improvement'),
270 3 => t('Acceptable'),
271 4 => t('Good'),
272 5 => t('Excellent'),
273 );
274 $output = '<div class="nodeapi_example_rating">';
275 $output .= t('Rating: %rating', array('%rating' => $options[(int) $variables['rating']]));
276 $output .= '</div>';
277 return $output;
278 }
279
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
theme_nodeapi_example_rating
theme_nodeapi_example_rating($variables)
Definition: nodeapi_example.module:265
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
nodeapi_example_form_alter
nodeapi_example_form_alter(&$form, $form_state, $form_id)
Definition: nodeapi_example.module:45
nodeapi_example_node_insert
nodeapi_example_node_insert($node)
Definition: nodeapi_example.module:155
nodeapi_example_node_validate
nodeapi_example_node_validate($node, $form)
Definition: nodeapi_example.module:96
$output
$output
Definition: authorize.php:93
nodeapi_example_node_delete
nodeapi_example_node_delete($node)
Definition: nodeapi_example.module:174
nodeapi_example_node_load
nodeapi_example_node_load($nodes, $types)
Definition: nodeapi_example.module:110
nodeapi_example_theme
nodeapi_example_theme()
Definition: nodeapi_example.module:248
nodeapi_example_node_view
nodeapi_example_node_view($node, $build_mode= 'full')
Definition: nodeapi_example.module:232
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
nodeapi_example_node_update
nodeapi_example_node_update($node)
Definition: nodeapi_example.module:192
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
BatchMemoryQueue Member List

This is the complete list of members for BatchMemoryQueue, including all inherited members.

$id_sequence | MemoryQueue | protected
$queue | MemoryQueue | protected
__construct($name) | MemoryQueue |
claimItem($lease_time=0) | BatchMemoryQueue |
createItem($data) | MemoryQueue |
createQueue() | MemoryQueue |
deleteItem($item) | MemoryQueue |
deleteQueue() | MemoryQueue |
getAllItems() | BatchMemoryQueue |
numberOfItems() | MemoryQueue |
releaseItem($item) | MemoryQueue |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DrupalWebTestCase Member List

This is the complete list of members for DrupalWebTestCase, including all inherited members.

$additionalCurlOptions | DrupalWebTestCase | protected
$assertions | DrupalTestCase | protected
$content | DrupalWebTestCase | protected
$cookieFile | DrupalWebTestCase | protected
$curlHandle | DrupalWebTestCase | protected
$databasePrefix | DrupalTestCase | protected
$drupalSettings | DrupalWebTestCase | protected
$elements | DrupalWebTestCase | protected
$generatedTestFiles | DrupalWebTestCase | protected
$headers | DrupalWebTestCase | protected
$httpauth_credentials | DrupalWebTestCase | protected
$httpauth_method | DrupalWebTestCase | protected
$loggedInUser | DrupalWebTestCase | protected
$originalFileDirectory | DrupalTestCase | protected
$originalShutdownCallbacks | DrupalWebTestCase | protected
$originalUser | DrupalWebTestCase | protected
$plainTextContent | DrupalWebTestCase | protected
$profile | DrupalWebTestCase | protected
$redirect_count | DrupalWebTestCase | protected
$results | DrupalTestCase |
$session_id | DrupalWebTestCase | protected
$session_name | DrupalWebTestCase | protected
$setup | DrupalTestCase | protected
$setupDatabasePrefix | DrupalTestCase | protected
$setupEnvironment | DrupalTestCase | protected
$skipClasses | DrupalTestCase | protected
$testId | DrupalTestCase | protected
$timeLimit | DrupalTestCase | protected
$url | DrupalWebTestCase | protected
__construct($test_id=NULL) | DrupalWebTestCase |
assert($status, $message= '', $group= 'Other', array $caller=NULL) | DrupalTestCase | protected
assertEqual($first, $second, $message= '', $group= 'Other') | DrupalTestCase | protected
assertFalse($value, $message= '', $group= 'Other') | DrupalTestCase | protected
assertField($field, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertFieldById($id, $value= '', $message= '') | DrupalWebTestCase | protected
assertFieldByName($name, $value=NULL, $message=NULL) | DrupalWebTestCase | protected
assertFieldByXPath($xpath, $value=NULL, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertFieldChecked($id, $message= '') | DrupalWebTestCase | protected
assertIdentical($first, $second, $message= '', $group= 'Other') | DrupalTestCase | protected
assertLink($label, $index=0, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertLinkByHref($href, $index=0, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertMail($name, $value= '', $message= '') | DrupalWebTestCase | protected
assertMailPattern($field_name, $regex, $message) | DrupalWebTestCase | protected
assertMailString($field_name, $string, $email_depth) | DrupalWebTestCase | protected
assertNoDuplicateIds($message= '', $group= 'Other', $ids_to_skip=array()) | DrupalWebTestCase | protected
assertNoField($field, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertNoFieldById($id, $value= '', $message= '') | DrupalWebTestCase | protected
assertNoFieldByName($name, $value= '', $message= '') | DrupalWebTestCase | protected
assertNoFieldByXPath($xpath, $value=NULL, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertNoFieldChecked($id, $message= '') | DrupalWebTestCase | protected
assertNoLink($label, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertNoLinkByHref($href, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertNoOptionSelected($id, $option, $message= '') | DrupalWebTestCase | protected
assertNoPattern($pattern, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertNoRaw($raw, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertNoResponse($code, $message= '') | DrupalWebTestCase | protected
assertNotEqual($first, $second, $message= '', $group= 'Other') | DrupalTestCase | protected
assertNoText($text, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertNotIdentical($first, $second, $message= '', $group= 'Other') | DrupalTestCase | protected
assertNoTitle($title, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertNotNull($value, $message= '', $group= 'Other') | DrupalTestCase | protected
assertNoUniqueText($text, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertNull($value, $message= '', $group= 'Other') | DrupalTestCase | protected
assertOptionSelected($id, $option, $message= '') | DrupalWebTestCase | protected
assertPattern($pattern, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertRaw($raw, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertResponse($code, $message= '') | DrupalWebTestCase | protected
assertText($text, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertTextHelper($text, $message= '', $group, $not_exists) | DrupalWebTestCase | protected
assertThemeOutput($callback, array $variables=array(), $expected, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertTitle($title, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertTrue($value, $message= '', $group= 'Other') | DrupalTestCase | protected
assertUniqueText($text, $message= '', $group= 'Other') | DrupalWebTestCase | protected
assertUniqueTextHelper($text, $message= '', $group, $be_unique) | DrupalWebTestCase | protected
assertUrl($path, array $options=array(), $message= '', $group= 'Other') | DrupalWebTestCase | protected
buildXPathQuery($xpath, array $args=array()) | DrupalWebTestCase | protected
changeDatabasePrefix() | DrupalWebTestCase | protected
checkForMetaRefresh() | DrupalWebTestCase | protected
checkPermissions(array $permissions, $reset=FALSE) | DrupalWebTestCase | protected
clickLink($label, $index=0) | DrupalWebTestCase | protected
constructFieldXpath($attribute, $value) | DrupalWebTestCase | protected
cronRun() | DrupalWebTestCase | protected
curlClose() | DrupalWebTestCase | protected
curlExec($curl_options, $redirect=FALSE) | DrupalWebTestCase | protected
curlHeaderCallback($curlHandler, $header) | DrupalWebTestCase | protected
curlInitialize() | DrupalWebTestCase | protected
deleteAssert($message_id) | DrupalTestCase | static
drupalCompareFiles($file1, $file2) | DrupalWebTestCase | protected
drupalCreateContentType($settings=array()) | DrupalWebTestCase | protected
drupalCreateNode($settings=array()) | DrupalWebTestCase | protected
drupalCreateRole(array $permissions, $name=NULL) | DrupalWebTestCase | protected
drupalCreateUser(array $permissions=array()) | DrupalWebTestCase | protected
drupalGet($path, array $options=array(), array $headers=array()) | DrupalWebTestCase | protected
drupalGetAJAX($path, array $options=array(), array $headers=array()) | DrupalWebTestCase | protected
drupalGetContent() | DrupalWebTestCase | protected
drupalGetHeader($name, $all_requests=FALSE) | DrupalWebTestCase | protected
drupalGetHeaders($all_requests=FALSE) | DrupalWebTestCase | protected
drupalGetMails($filter=array()) | DrupalWebTestCase | protected
drupalGetNodeByTitle($title, $reset=FALSE) | DrupalWebTestCase |
drupalGetSettings() | DrupalWebTestCase | protected
drupalGetTestFiles($type, $size=NULL) | DrupalWebTestCase | protected
drupalGetToken($value= '') | DrupalWebTestCase | protected
drupalHead($path, array $options=array(), array $headers=array()) | DrupalWebTestCase | protected
drupalLogin(stdClass $account) | DrupalWebTestCase | protected
drupalLogout() | DrupalWebTestCase | protected
drupalPost($path, $edit, $submit, array $options=array(), array $headers=array(), $form_html_id=NULL, $extra_post=NULL) | DrupalWebTestCase | protected
drupalPostAJAX($path, $edit, $triggering_element, $ajax_path=NULL, array $options=array(), array $headers=array(), $form_html_id=NULL, $ajax_settings=NULL) | DrupalWebTestCase | protected
drupalSetContent($content, $url= 'internal:') | DrupalWebTestCase | protected
drupalSetSettings($settings) | DrupalWebTestCase | protected
error($message= '', $group= 'Other', array $caller=NULL) | DrupalTestCase | protected
errorHandler($severity, $message, $file=NULL, $line=NULL) | DrupalTestCase |
exceptionHandler($exception) | DrupalTestCase | protected
fail($message=NULL, $group= 'Other') | DrupalTestCase | protected
generatePermutations($parameters) | DrupalTestCase | static
getAbsoluteUrl($path) | DrupalWebTestCase | protected
getAllOptions(SimpleXMLElement $element) | DrupalWebTestCase | protected
getAssertionCall() | DrupalTestCase | protected
getSelectedItem(SimpleXMLElement $element) | DrupalWebTestCase | protected
getUrl() | DrupalWebTestCase | protected
handleForm(&$post, &$edit, &$upload, $submit, $form) | DrupalWebTestCase | protected
insertAssert($test_id, $test_class, $status, $message= '', $group= 'Other', array $caller=array()) | DrupalTestCase | static
parse() | DrupalWebTestCase | protected
pass($message=NULL, $group= 'Other') | DrupalTestCase | protected
preloadRegistry() | DrupalWebTestCase | protected
prepareDatabasePrefix() | DrupalWebTestCase | protected
prepareEnvironment() | DrupalWebTestCase | protected
randomName($length=8) | DrupalTestCase | static
randomString($length=8) | DrupalTestCase | static
refreshVariables() | DrupalWebTestCase | protected
resetAll() | DrupalWebTestCase | protected
run(array $methods=array()) | DrupalTestCase |
setUp() | DrupalWebTestCase | protected
tearDown() | DrupalWebTestCase | protected
verbose($message) | DrupalTestCase | protected
verboseEmail($count=1) | DrupalWebTestCase | protected
xpath($xpath, array $arguments=array()) | DrupalWebTestCase | protected
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/queue_example/queue_example.module Source File

  • examples
  • queue_example
queue_example.module
Go to the documentation of this file.
1 <?php
2
38 function queue_example_menu() {
39 $items = array();
40 $items['queue_example/insert_remove'] = array(
41 'title' => 'Queue Example: Insert and remove',
42 'page callback' => 'drupal_get_form',
43 'page arguments' => array('queue_example_add_remove_form'),
44 'access callback' => TRUE,
45 );
46
47 return $items;
48 }
49
56 function queue_example_add_remove_form($form, &$form_state) {
57 // Simple counter that makes it possible to put auto-incrementing default
58 // string into the string to insert.
59 if (empty($form_state['storage']['insert_counter'])) {
60 $form_state['storage']['insert_counter'] = 1;
61 }
62
63 $queue_name = !empty($form_state['values']['queue_name']) ? $form_state['values']['queue_name'] : 'queue_example_first_queue';
64 $items = queue_example_retrieve_queue($queue_name);
65
66 // Add CSS to make the form a bit denser.
67 $form['#attached']['css'] = array(drupal_get_path('module', 'queue_example') . '/queue_example.css');
68
69 $form['help'] = array(
70 '#type' => 'markup',
71 '#markup' => '<div>' . t('This page is an interface on the Drupal queue API. You can add new items to the queue, "claim" one (retrieve the next item and keep a lock on it), and delete one (remove it from the queue). Note that claims are not expired until cron runs, so there is a special button to run cron to perform any necessary expirations.') . '</div>',
72 );
73
74 $form['queue_name'] = array(
75 '#type' => 'select',
76 '#title' => t('Choose queue to examine'),
77 '#options' => drupal_map_assoc(array('queue_example_first_queue', 'queue_example_second_queue')),
78 '#default_value' => $queue_name,
79 );
80 $form['queue_show'] = array(
81 '#type' => 'submit',
82 '#value' => t('Show queue'),
83 '#submit' => array('queue_example_show_queue'),
84 );
85 $form['status_fieldset'] = array(
86 '#type' => 'fieldset',
87 '#title' => t('Queue status for @name', array('@name' => $queue_name)),
88 '#collapsible' => TRUE,
89 );
90 $form['status_fieldset']['status'] = array(
91 '#type' => 'markup',
92 '#markup' => theme('queue_items', array('items' => $items)),
93 );
94 $form['insert_fieldset'] = array(
95 '#type' => 'fieldset',
96 '#title' => t('Insert into @name', array('@name' => $queue_name)),
97 );
98 $form['insert_fieldset']['string_to_add'] = array(
99 '#type' => 'textfield',
100 '#size' => 10,
101 '#default_value' => t('item @counter', array('@counter' => $form_state['storage']['insert_counter'])),
102 );
103 $form['insert_fieldset']['add_item'] = array(
104 '#type' => 'submit',
105 '#value' => t('Insert into queue'),
106 '#submit' => array('queue_example_add_remove_form_insert'),
107 );
108 $form['claim_fieldset'] = array(
109 '#type' => 'fieldset',
110 '#title' => t('Claim from queue'),
111 '#collapsible' => TRUE,
112 );
113
114 $form['claim_fieldset']['claim_time'] = array(
115 '#type' => 'radios',
116 '#title' => t('Claim time, in seconds'),
117 '#options' => array(0 => t('none'), 5 => t('5 seconds'), 60 => t('60 seconds')),
118 '#description' => t('This time is only valid if cron runs during this time period. You can run cron manually below.'),
119 '#default_value' => !empty($form_state['values']['claim_time']) ? $form_state['values']['claim_time'] : 5,
120 );
121 $form['claim_fieldset']['claim_item'] = array(
122 '#type' => 'submit',
123 '#value' => t('Claim the next item from the queue'),
124 '#submit' => array('queue_example_add_remove_form_claim'),
125 );
126 $form['claim_fieldset']['claim_and_delete_item'] = array(
127 '#type' => 'submit',
128 '#value' => t('Claim the next item and delete it'),
129 '#submit' => array('queue_example_add_remove_form_delete'),
130 );
131 $form['claim_fieldset']['run_cron'] = array(
132 '#type' => 'submit',
133 '#value' => t('Run cron manually to expire claims'),
134 '#submit' => array('queue_example_add_remove_form_run_cron'),
135 );
136 $form['delete_queue'] = array(
137 '#type' => 'submit',
138 '#value' => t('Delete the queue and items in it'),
139 '#submit' => array('queue_example_add_remove_form_clear_queue'),
140 );
141 return $form;
142 }
143
147 function queue_example_add_remove_form_insert($form, &$form_state) {
148 // Get a queue (of the default type) called 'queue_example_queue'.
149 // If the default queue class is SystemQueue this creates a queue that stores
150 // its items in the database.
151 $queue = DrupalQueue::get($form_state['values']['queue_name']);
152 $queue->createQueue(); // There is no harm in trying to recreate existing.
153
154 // Queue the string.
155 $queue->createItem($form_state['values']['string_to_add']);
156 $count = $queue->numberOfItems();
157 drupal_set_message(t('Queued your string (@string_to_add). There are now @count items in the queue.', array('@count' => $count, '@string_to_add' => $form_state['values']['string_to_add'])));
158 $form_state['rebuild'] = TRUE; // Allows us to keep information in $form_state.
159 // Unsetting the string_to_add allows us to set the incremented default value
160 // for the user so they don't have to type anything.
161 unset($form_state['input']['string_to_add']);
162 $form_state['storage']['insert_counter']++;
163 }
164
168 function queue_example_show_queue($form, &$form_state) {
169 $queue = DrupalQueue::get($form_state['values']['queue_name']);
170 $queue->createQueue(); // There is no harm in trying to recreate existing.
171
172 // Get the number of items.
173 $count = $queue->numberOfItems();
174
175 // Update the form item counter.
176 $form_state['storage']['insert_counter'] = $count +1;
177
178 // Unset the string_to_add textbox.
179 unset($form_state['input']['string_to_add']);
180
181 $form_state['rebuild'] = TRUE;
182 }
183
188 function queue_example_add_remove_form_claim($form, &$form_state) {
189 $queue = DrupalQueue::get($form_state['values']['queue_name']);
190 $queue->createQueue(); // There is no harm in trying to recreate existing.
191 $item = $queue->claimItem($form_state['values']['claim_time']);
192 $count = $queue->numberOfItems();
193 if (!empty($item)) {
194 drupal_set_message(t('Claimed item id=@item_id string=@string for @seconds seconds. There are @count items in the queue.', array('@count' => $count, '@item_id' => $item->item_id, '@string' => $item->data, '@seconds' => $form_state['values']['claim_time'])));
195 }
196 else {
197 drupal_set_message(t('There were no items in the queue available to claim. There are @count items in the queue.', array('@count' => $count)));
198 }
199 $form_state['rebuild'] = TRUE;
200 }
201
205 function queue_example_add_remove_form_delete($form, &$form_state) {
206 $queue = DrupalQueue::get($form_state['values']['queue_name']);
207 $queue->createQueue(); // There is no harm in trying to recreate existing.
208 $count = $queue->numberOfItems();
209 $item = $queue->claimItem(60);
210 if (!empty($item)) {
211 drupal_set_message(t('Claimed and deleted item id=@item_id string=@string for @seconds seconds. There are @count items in the queue.', array('@count' => $count, '@item_id' => $item->item_id, '@string' => $item->data, '@seconds' => $form_state['values']['claim_time'])));
212 $queue->deleteItem($item);
213 $count = $queue->numberOfItems();
214 drupal_set_message(t('There are now @count items in the queue.', array('@count' => $count)));
215 }
216 else {
217 $count = $queue->numberOfItems();
218 drupal_set_message(t('There were no items in the queue available to claim/delete. There are currently @count items in the queue.', array('@count' => $count)));
219 }
220 $form_state['rebuild'] = TRUE;
221 }
222
228 function queue_example_add_remove_form_run_cron($form, &$form_state) {
229 drupal_cron_run();
230 $queue = DrupalQueue::get($form_state['values']['queue_name']);
231 $queue->createQueue(); // There is no harm in trying to recreate existing.
232 $count = $queue->numberOfItems();
233 drupal_set_message(t('Ran cron. If claimed items expired, they should be expired now. There are now @count items in the queue', array('@count' => $count)));
234 $form_state['rebuild'] = TRUE;
235 }
236
240 function queue_example_add_remove_form_clear_queue($form, &$form_state) {
241 $queue = DrupalQueue::get($form_state['values']['queue_name']);
242 $queue->deleteQueue();
243 drupal_set_message(t('Deleted the @queue_name queue and all items in it', array('@queue_name' => $form_state['values']['queue_name'])));
244 }
245
256 function queue_example_retrieve_queue($queue_name) {
257 $items = array();
258 $result = db_query("SELECT item_id, data, expire, created FROM {queue} WHERE name = :name ORDER BY item_id",
259 array(':name' => $queue_name),
260 array('fetch' => PDO::FETCH_ASSOC));
261 foreach ($result as $item) {
262 $items[] = $item;
263 }
264 return $items;
265 }
266
275 function theme_queue_items($variables) {
276 $items = $variables['items'];
277 $rows = array();
278 foreach ($items as &$item) {
279 if ($item['expire'] > 0) {
280 $item['expire'] = t("Claimed: expires %expire", array('%expire' => date('r', $item['expire'])));
281 }
282 else {
283 $item['expire'] = t('Unclaimed');
284 }
285 $item['created'] = date('r', $item['created']);
286 $item['content'] = check_plain(unserialize($item['data']));
287 unset($item['data']);
288 $rows[] = $item;
289 }
290 if (!empty($rows)) {
291 $header = array(t('Item ID'), t('Claimed/Expiration'), t('Created'), t('Content/Data'));
292 $output = theme('table', array('header' => $header, 'rows' => $rows));
293 return $output;
294 }
295 else {
296 return t('There are no items in the queue.');
297 }
298 }
299
303 function queue_example_theme() {
304 return array(
305 'queue_items' => array(
306 'variables' => array('items' => NULL),
307 ),
308 );
309 }
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
DrupalQueue\get
static get($name, $reliable=FALSE)
Definition: system.queue.inc:81
queue_example_add_remove_form_delete
queue_example_add_remove_form_delete($form, &$form_state)
Definition: queue_example.module:205
$header
print $header
Definition: forum-topic-list.tpl.php:42
queue_example_add_remove_form_clear_queue
queue_example_add_remove_form_clear_queue($form, &$form_state)
Definition: queue_example.module:240
queue_example_add_remove_form
queue_example_add_remove_form($form, &$form_state)
Definition: queue_example.module:56
queue_example_theme
queue_example_theme()
Definition: queue_example.module:303
queue_example_retrieve_queue
queue_example_retrieve_queue($queue_name)
Definition: queue_example.module:256
queue_example_add_remove_form_run_cron
queue_example_add_remove_form_run_cron($form, &$form_state)
Definition: queue_example.module:228
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
queue_example_menu
queue_example_menu()
Definition: queue_example.module:38
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
queue_example_add_remove_form_insert
queue_example_add_remove_form_insert($form, &$form_state)
Definition: queue_example.module:147
$output
$output
Definition: authorize.php:93
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
queue_example_show_queue
queue_example_show_queue($form, &$form_state)
Definition: queue_example.module:168
theme_queue_items
theme_queue_items($variables)
Definition: queue_example.module:275
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
queue_example_add_remove_form_claim
queue_example_add_remove_form_claim($form, &$form_state)
Definition: queue_example.module:188
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
drupal_cron_run
drupal_cron_run()
Definition: common.inc:5227
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
FileTransferChmodInterface Member List

This is the complete list of members for FileTransferChmodInterface, including all inherited members.

chmodJailed($path, $mode, $recursive) FileTransferChmodInterface
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/image/image.install Source File

  • modules
  • image
image.install
Go to the documentation of this file.
1 <?php
2
11 function image_install() {
12 // Create the styles directory and ensure it's writable.
13 $directory = file_default_scheme() . '://styles';
14 file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
15 }
16
20 function image_uninstall() {
21 // Remove the styles directory and generated images.
22 file_unmanaged_delete_recursive(file_default_scheme() . '://styles');
23 }
24
28 function image_schema() {
29 $schema = array();
30
31 $schema['cache_image'] = drupal_get_schema_unprocessed('system', 'cache');
32 $schema['cache_image']['description'] = 'Cache table used to store information about image manipulations that are in-progress.';
33
34 $schema['image_styles'] = array(
35 'description' => 'Stores configuration options for image styles.',
36 'fields' => array(
37 'isid' => array(
38 'description' => 'The primary identifier for an image style.',
39 'type' => 'serial',
40 'unsigned' => TRUE,
41 'not null' => TRUE,
42 ),
43 'name' => array(
44 'description' => 'The style machine name.',
45 'type' => 'varchar',
46 'length' => 255,
47 'not null' => TRUE,
48 ),
49 'label' => array(
50 'description' => 'The style administrative name.',
51 'type' => 'varchar',
52 'length' => 255,
53 'not null' => TRUE,
54 'default' => '',
55 ),
56 ),
57 'primary key' => array('isid'),
58 'unique keys' => array(
59 'name' => array('name'),
60 ),
61 );
62
63 $schema['image_effects'] = array(
64 'description' => 'Stores configuration options for image effects.',
65 'fields' => array(
66 'ieid' => array(
67 'description' => 'The primary identifier for an image effect.',
68 'type' => 'serial',
69 'unsigned' => TRUE,
70 'not null' => TRUE,
71 ),
72 'isid' => array(
73 'description' => 'The {image_styles}.isid for an image style.',
74 'type' => 'int',
75 'unsigned' => TRUE,
76 'not null' => TRUE,
77 'default' => 0,
78 ),
79 'weight' => array(
80 'description' => 'The weight of the effect in the style.',
81 'type' => 'int',
82 'unsigned' => FALSE,
83 'not null' => TRUE,
84 'default' => 0,
85 ),
86 'name' => array(
87 'description' => 'The unique name of the effect to be executed.',
88 'type' => 'varchar',
89 'length' => 255,
90 'not null' => TRUE,
91 ),
92 'data' => array(
93 'description' => 'The configuration data for the effect.',
94 'type' => 'blob',
95 'not null' => TRUE,
96 'size' => 'big',
97 'serialize' => TRUE,
98 ),
99 ),
100 'primary key' => array('ieid'),
101 'indexes' => array(
102 'isid' => array('isid'),
103 'weight' => array('weight'),
104 ),
105 'foreign keys' => array(
106 'image_style' => array(
107 'table' => 'image_styles',
108 'columns' => array('isid' => 'isid'),
109 ),
110 ),
111 );
112
113 return $schema;
114 }
115
119 function image_field_schema($field) {
120 return array(
121 'columns' => array(
122 'fid' => array(
123 'description' => 'The {file_managed}.fid being referenced in this field.',
124 'type' => 'int',
125 'not null' => FALSE,
126 'unsigned' => TRUE,
127 ),
128 'alt' => array(
129 'description' => "Alternative image text, for the image's 'alt' attribute.",
130 'type' => 'varchar',
131 'length' => 512,
132 'not null' => FALSE,
133 ),
134 'title' => array(
135 'description' => "Image title text, for the image's 'title' attribute.",
136 'type' => 'varchar',
137 'length' => 1024,
138 'not null' => FALSE,
139 ),
140 'width' => array(
141 'description' => 'The width of the image in pixels.',
142 'type' => 'int',
143 'unsigned' => TRUE,
144 ),
145 'height' => array(
146 'description' => 'The height of the image in pixels.',
147 'type' => 'int',
148 'unsigned' => TRUE,
149 ),
150 ),
151 'indexes' => array(
152 'fid' => array('fid'),
153 ),
154 'foreign keys' => array(
155 'fid' => array(
156 'table' => 'file_managed',
157 'columns' => array('fid' => 'fid'),
158 ),
159 ),
160 );
161 }
162
166 function image_update_dependencies() {
167 $dependencies['image'][7002] = array(
168 // Image update 7002 uses field API functions, so must run after
169 // Field API has been enabled.
170 'system' => 7020,
171 );
172 return $dependencies;
173 }
174
178 function image_update_7000() {
179 if (!db_table_exists('image_styles')) {
180 $schema = array();
181
182 $schema['cache_image'] = system_schema_cache_7054();
183 $schema['cache_image']['description'] = 'Cache table used to store information about image manipulations that are in-progress.';
184
185 $schema['image_styles'] = array(
186 'description' => 'Stores configuration options for image styles.',
187 'fields' => array(
188 'isid' => array(
189 'description' => 'The primary identifier for an image style.',
190 'type' => 'serial',
191 'unsigned' => TRUE,
192 'not null' => TRUE,
193 ),
194 'name' => array(
195 'description' => 'The style name.',
196 'type' => 'varchar',
197 'length' => 255,
198 'not null' => TRUE,
199 ),
200 ),
201 'primary key' => array('isid'),
202 'unique keys' => array(
203 'name' => array('name'),
204 ),
205 );
206
207 $schema['image_effects'] = array(
208 'description' => 'Stores configuration options for image effects.',
209 'fields' => array(
210 'ieid' => array(
211 'description' => 'The primary identifier for an image effect.',
212 'type' => 'serial',
213 'unsigned' => TRUE,
214 'not null' => TRUE,
215 ),
216 'isid' => array(
217 'description' => 'The {image_styles}.isid for an image style.',
218 'type' => 'int',
219 'unsigned' => TRUE,
220 'not null' => TRUE,
221 'default' => 0,
222 ),
223 'weight' => array(
224 'description' => 'The weight of the effect in the style.',
225 'type' => 'int',
226 'unsigned' => FALSE,
227 'not null' => TRUE,
228 'default' => 0,
229 ),
230 'name' => array(
231 'description' => 'The unique name of the effect to be executed.',
232 'type' => 'varchar',
233 'length' => 255,
234 'not null' => TRUE,
235 ),
236 'data' => array(
237 'description' => 'The configuration data for the effect.',
238 'type' => 'blob',
239 'not null' => TRUE,
240 'size' => 'big',
241 'serialize' => TRUE,
242 ),
243 ),
244 'primary key' => array('ieid'),
245 'indexes' => array(
246 'isid' => array('isid'),
247 'weight' => array('weight'),
248 ),
249 'foreign keys' => array(
250 'image_style' => array(
251 'table' => 'image_styles',
252 'columns' => array('isid' => 'isid'),
253 ),
254 ),
255 );
256
257 db_create_table('cache_image', $schema['cache_image']);
258 db_create_table('image_styles', $schema['image_styles']);
259 db_create_table('image_effects', $schema['image_effects']);
260 }
261 }
262
271 function image_update_7001() {
272 // Due to a bug in earlier versions of image_update_7000() it is possible
273 // to end up with an {image_effect} table where there should be an
274 // {image_effects} table.
275 if (!db_table_exists('image_effects') && db_table_exists('image_effect')) {
276 db_rename_table('image_effect', 'image_effects');
277 }
278 }
279
288 function _image_update_7002_add_columns($table, $field_name) {
289 $spec = array(
290 'type' => 'int',
291 'unsigned' => TRUE,
292 );
293
294 $spec['description'] = 'The width of the image in pixels.';
295 db_add_field($table, $field_name . '_width', $spec);
296
297 $spec['description'] = 'The height of the image in pixels.';
298 db_add_field($table, $field_name . '_height', $spec);
299 }
300
314 function _image_update_7002_populate_dimensions($table, $field_name, &$last_fid) {
315 // Define how many images to process per pass.
316 $images_per_pass = 100;
317
318 // Query the database for fid / URI pairs.
319 $query = db_select($table, NULL, array('fetch' => PDO::FETCH_ASSOC));
320 $query->join('file_managed', NULL, $table . '.' . $field_name . '_fid = file_managed.fid');
321
322 if ($last_fid) {
323 $query->condition('file_managed.fid', $last_fid, '>');
324 }
325
326 $result = $query->fields('file_managed', array('fid', 'uri'))
327 ->orderBy('file_managed.fid')
328 ->range(0, $images_per_pass)
329 ->execute();
330
331 $count = 0;
332 foreach ($result as $file) {
333 $count++;
334 $info = image_get_info($file['uri']);
335
336 if (is_array($info)) {
337 db_update($table)
338 ->fields(array(
339 $field_name . '_width' => $info['width'],
340 $field_name . '_height' => $info['height'],
341 ))
342 ->condition($field_name . '_fid', $file['fid'])
343 ->execute();
344 }
345 }
346
347 // If less than the requested number of rows were returned then this table
348 // has been fully processed.
349 $last_fid = ($count < $images_per_pass) ? NULL : $file['fid'];
350 return $count;
351 }
352
356 function image_update_7002(array &$sandbox) {
357 if (empty($sandbox)) {
358 // Setup the sandbox.
359 $sandbox = array(
360 'tables' => array(),
361 'total' => 0,
362 'processed' => 0,
363 'last_fid' => NULL,
364 );
365
366 $fields = _update_7000_field_read_fields(array(
367 'module' => 'image',
368 'storage_type' => 'field_sql_storage',
369 'deleted' => 0,
370 ));
371
372 foreach ($fields as $field) {
373 $tables = array(
374 _field_sql_storage_tablename($field),
375 _field_sql_storage_revision_tablename($field),
376 );
377 foreach ($tables as $table) {
378 // Add the width and height columns to the table.
379 _image_update_7002_add_columns($table, $field['field_name']);
380
381 // How many rows need dimensions populated?
382 $count = db_select($table)->countQuery()->execute()->fetchField();
383
384 if (!$count) {
385 continue;
386 }
387
388 $sandbox['total'] += $count;
389 $sandbox['tables'][$table] = $field['field_name'];
390 }
391 }
392
393 // If no tables need rows populated with dimensions then we are done.
394 if (empty($sandbox['tables'])) {
395 $sandbox = array();
396 return;
397 }
398 }
399
400 // Process the table at the top of the list.
401 $keys = array_keys($sandbox['tables']);
402 $table = reset($keys);
403 $sandbox['processed'] += _image_update_7002_populate_dimensions($table, $sandbox['tables'][$table], $sandbox['last_fid']);
404
405 // Has the table been fully processed?
406 if (!$sandbox['last_fid']) {
407 unset($sandbox['tables'][$table]);
408 }
409
410 $sandbox['#finished'] = count($sandbox['tables']) ? ($sandbox['processed'] / $sandbox['total']) : 1;
411 }
412
417 function image_update_7003() {
418 variable_del('image_alt_length');
419 variable_del('image_title_length');
420 }
421
426 function image_update_7004() {
427 $alt_spec = array(
428 'type' => 'varchar',
429 'length' => 512,
430 'not null' => FALSE,
431 );
432
433 $title_spec = array(
434 'type' => 'varchar',
435 'length' => 1024,
436 'not null' => FALSE,
437 );
438
439 $fields = _update_7000_field_read_fields(array(
440 'module' => 'image',
441 'storage_type' => 'field_sql_storage',
442 ));
443
444 foreach ($fields as $field_name => $field) {
445 $tables = array(
446 _field_sql_storage_tablename($field),
447 _field_sql_storage_revision_tablename($field),
448 );
449 $alt_column = $field['field_name'] . '_alt';
450 $title_column = $field['field_name'] . '_title';
451 foreach ($tables as $table) {
452 db_change_field($table, $alt_column, $alt_column, $alt_spec);
453 db_change_field($table, $title_column, $title_column, $title_spec);
454 }
455 }
456 }
457
461 function image_update_7005() {
462 $field = array(
463 'type' => 'varchar',
464 'length' => 255,
465 'not null' => TRUE,
466 'default' => '',
467 'description' => 'The style administrative name.',
468 );
469 db_add_field('image_styles', 'label', $field);
470
471 // Do a direct query here, rather than calling image_styles(),
472 // in case Image module is disabled.
473 $styles = db_query('SELECT name FROM {image_styles}')->fetchCol();
474 foreach ($styles as $style) {
475 db_update('image_styles')
476 ->fields(array('label' => $style))
477 ->condition('name', $style)
478 ->execute();
479 }
480 }
481
491 function image_requirements($phase) {
492 $requirements = array();
493
494 if ($phase == 'runtime') {
495 // Check for the PHP GD library.
496 if (function_exists('imagegd2')) {
497 $info = gd_info();
498 $requirements['image_gd'] = array(
499 'value' => $info['GD Version'],
500 );
501
502 // Check for filter and rotate support.
503 if (function_exists('imagefilter') && function_exists('imagerotate')) {
504 $requirements['image_gd']['severity'] = REQUIREMENT_OK;
505 }
506 else {
507 $requirements['image_gd']['severity'] = REQUIREMENT_WARNING;
508 $requirements['image_gd']['description'] = t('The GD Library for PHP is enabled, but was compiled without support for functions used by the rotate and desaturate effects. It was probably compiled using the official GD libraries from http://www.libgd.org instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See <a href="http://www.php.net/manual/book.image.php">the PHP manual</a>.');
509 }
510 }
511 else {
512 $requirements['image_gd'] = array(
513 'value' => t('Not installed'),
514 'severity' => REQUIREMENT_ERROR,
515 'description' => t('The GD library for PHP is missing or outdated. Check the <a href="@url">PHP image documentation</a> for information on how to correct this.', array('@url' => 'http://www.php.net/manual/book.image.php')),
516 );
517 }
518 $requirements['image_gd']['title'] = t('GD library rotate and desaturate effects');
519 }
520
521 return $requirements;
522 }
file_default_scheme
file_default_scheme()
Definition: file.inc:256
FILE_CREATE_DIRECTORY
const FILE_CREATE_DIRECTORY
Definition: file.inc:41
image_update_dependencies
image_update_dependencies()
Definition: image.install:166
_image_update_7002_populate_dimensions
_image_update_7002_populate_dimensions($table, $field_name, &$last_fid)
Definition: image.install:314
FILE_MODIFY_PERMISSIONS
const FILE_MODIFY_PERMISSIONS
Definition: file.inc:46
file_unmanaged_delete_recursive
file_unmanaged_delete_recursive($path)
Definition: file.inc:1358
variable_del
variable_del($name)
Definition: bootstrap.inc:996
image_install
image_install()
Definition: image.install:11
image_requirements
image_requirements($phase)
Definition: image.install:491
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
image_update_7000
image_update_7000()
Definition: image.install:178
_update_7000_field_read_fields
_update_7000_field_read_fields(array $conditions=array(), $key= 'id')
Definition: field.install:328
image_update_7001
image_update_7001()
Definition: image.install:271
db_add_field
db_add_field($table, $field, $spec, $keys_new=array())
Definition: database.inc:2840
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
REQUIREMENT_WARNING
const REQUIREMENT_WARNING
Definition: install.inc:31
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
REQUIREMENT_OK
const REQUIREMENT_OK
Definition: install.inc:26
drupal_get_schema_unprocessed
drupal_get_schema_unprocessed($module, $table=NULL)
Definition: common.inc:6998
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
image_update_7004
image_update_7004()
Definition: image.install:426
image_get_info
image_get_info($filepath, $toolkit=FALSE)
Definition: image.inc:124
$info
$info
Definition: color.inc:6
image_update_7002
image_update_7002(array &$sandbox)
Definition: image.install:356
_field_sql_storage_tablename
_field_sql_storage_tablename($field)
Definition: field_sql_storage.module:41
_image_update_7002_add_columns
_image_update_7002_add_columns($table, $field_name)
Definition: image.install:288
_field_sql_storage_revision_tablename
_field_sql_storage_revision_tablename($field)
Definition: field_sql_storage.module:58
$styles
print $styles
Definition: html.tpl.php:52
image_field_schema
image_field_schema($field)
Definition: image.install:119
file_prepare_directory
file_prepare_directory(&$directory, $options=FILE_MODIFY_PERMISSIONS)
Definition: file.inc:430
image_update_7005
image_update_7005()
Definition: image.install:461
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
system_schema_cache_7054
system_schema_cache_7054()
Definition: system.install:1660
image_update_7003
image_update_7003()
Definition: image.install:417
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
image_schema
image_schema()
Definition: image.install:28
db_table_exists
db_table_exists($table)
Definition: database.inc:2760
image_uninstall
image_uninstall()
Definition: image.install:20
db_rename_table
db_rename_table($table, $new_name)
Definition: database.inc:2805
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile/profile-listing.tpl.php Source File

  • modules
  • profile
profile-listing.tpl.php
Go to the documentation of this file.
1 <?php
2
38 ?>
39 <div class="profile clearfix">
40 <?php print $user_picture; ?>
41
42 <div class="name">
43 <?php print $name; ?>
44 </div>
45
46 <?php foreach ($profile as $field): ?>
47 <div class="field">
48 <?php print $field->value; ?>
49 </div>
50 <?php endforeach; ?>
51
52 </div>
$name
print $name
Definition: profile-listing.tpl.php:43
$user_picture
print $user_picture
Definition: node.tpl.php:85
print
print
Definition: php-2.php:2
endforeach
endforeach
Definition: block-admin-display-form.tpl.php:64
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
UpdateQuery_pgsql Member List

This is the complete list of members for UpdateQuery_pgsql, including all inherited members.

$arguments | UpdateQuery | protected
$comments | Query | protected
$condition | UpdateQuery | protected
$connection | Query | protected
$connectionKey | Query | protected
$connectionTarget | Query | protected
$expressionFields | UpdateQuery | protected
$fields | UpdateQuery | protected
$nextPlaceholder | Query | protected
$queryOptions | Query | protected
$table | UpdateQuery | protected
$uniqueIdentifier | Query | protected
__clone() | Query |
__construct(DatabaseConnection $connection, $table, array $options=array()) | UpdateQuery |
Query::__construct(DatabaseConnection $connection, $options) | Query |
__sleep() | Query |
__toString() | UpdateQuery |
__wakeup() | Query |
arguments() | UpdateQuery |
comment($comment) | Query |
compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder) | UpdateQuery |
compiled() | UpdateQuery |
condition($field, $value=NULL, $operator=NULL) | UpdateQuery |
conditions() | UpdateQuery |
execute() | UpdateQuery_pgsql |
exists(SelectQueryInterface $select) | UpdateQuery |
expression($field, $expression, array $arguments=NULL) | UpdateQuery |
fields(array $fields) | UpdateQuery |
getComments() | Query |
isNotNull($field) | UpdateQuery |
isNull($field) | UpdateQuery |
nextPlaceholder() | Query |
notExists(SelectQueryInterface $select) | UpdateQuery |
uniqueIdentifier() | Query |
where($snippet, $args=array()) | UpdateQuery |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/toolbar/toolbar.module Source File

  • modules
  • toolbar
toolbar.module
Go to the documentation of this file.
1 <?php
2
11 function toolbar_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#toolbar':
14 $output = '<h3>' . t('About') . '</h3>';
15 $output .= '<p>' . t('The Toolbar module displays links to top-level administration menu items and links from other modules at the top of the screen. For more information, see the online handbook entry for <a href="@toolbar">Toolbar module</a>.', array('@toolbar' => 'http://drupal.org/documentation/modules/toolbar/')) . '</p>';
16 $output .= '<h3>' . t('Uses') . '</h3>';
17 $output .= '<dl>';
18 $output .= '<dt>' . t('Displaying administrative links') . '</dt>';
19 $output .= '<dd>' . t('The Toolbar module displays a bar containing top-level administrative links across the top of the screen. Below that, the Toolbar module has a <em>drawer</em> section where it displays links provided by other modules, such as the core <a href="@shortcuts-help">Shortcut module</a>. The drawer can be hidden/shown by using the show/hide shortcuts link at the end of the toolbar.', array('@shortcuts-help' => url('admin/help/shortcut'))) . '</dd>';
20 $output .= '</dl>';
21 return $output;
22 }
23 }
24
28 function toolbar_permission() {
29 return array(
30 'access toolbar' => array(
31 'title' => t('Use the administration toolbar'),
32 ),
33 );
34 }
35
39 function toolbar_theme($existing, $type, $theme, $path) {
40 $items['toolbar'] = array(
41 'render element' => 'toolbar',
42 'template' => 'toolbar',
43 'path' => drupal_get_path('module', 'toolbar'),
44 );
45 $items['toolbar_toggle'] = array(
46 'variables' => array(
47 'collapsed' => NULL,
48 'attributes' => array(),
49 ),
50 );
51 return $items;
52 }
53
57 function toolbar_menu() {
58 $items['toolbar/toggle'] = array(
59 'title' => 'Toggle drawer visibility',
60 'type' => MENU_CALLBACK,
61 'page callback' => 'toolbar_toggle_page',
62 'access arguments' => array('access toolbar'),
63 );
64 return $items;
65 }
66
70 function toolbar_toggle_page() {
71 global $base_path;
72 // Toggle the value in the cookie.
73 setcookie('Drupal.toolbar.collapsed', !_toolbar_is_collapsed(), NULL, $base_path);
74 // Redirect the user from where he used the toggle element.
75 drupal_goto();
76 }
77
91 function theme_toolbar_toggle($variables) {
92 if ($variables['collapsed']) {
93 $toggle_text = t('Show shortcuts');
94 }
95 else {
96 $toggle_text = t('Hide shortcuts');
97 $variables['attributes']['class'][] = 'toggle-active';
98 }
99 return l($toggle_text, 'toolbar/toggle', array('query' => drupal_get_destination(), 'attributes' => array('title' => $toggle_text) + $variables['attributes']));
100 }
101
108 function _toolbar_is_collapsed() {
109 // PHP converts dots into underscores in cookie names to avoid problems with
110 // its parser, so we use a converted cookie name.
111 return isset($_COOKIE['Drupal_toolbar_collapsed']) ? $_COOKIE['Drupal_toolbar_collapsed'] : 0;
112 }
113
119 function toolbar_page_build(&$page) {
120 $page['page_top']['toolbar'] = array(
121 '#pre_render' => array('toolbar_pre_render'),
122 '#access' => user_access('access toolbar'),
123 'toolbar_drawer' => array(),
124 );
125 }
126
133 function toolbar_pre_render($toolbar) {
134 $toolbar = array_merge($toolbar, toolbar_view());
135 return $toolbar;
136 }
137
143 function toolbar_preprocess_html(&$vars) {
144 if (isset($vars['page']['page_top']['toolbar']) && user_access('access toolbar')) {
145 $vars['classes_array'][] = 'toolbar';
146 if (!_toolbar_is_collapsed()) {
147 $vars['classes_array'][] = 'toolbar-drawer';
148 }
149 }
150 }
151
158 function toolbar_preprocess_toolbar(&$variables) {
159 $variables['classes_array'][] = "overlay-displace-top";
160 }
161
172 function toolbar_system_info_alter(&$info, $file, $type) {
173 if ($type == 'theme') {
174 $info['overlay_supplemental_regions'][] = 'page_top';
175 }
176 }
177
184 function toolbar_view() {
185 global $user;
186
187 $module_path = drupal_get_path('module', 'toolbar');
188 $build = array(
189 '#theme' => 'toolbar',
190 '#attached'=> array(
191 'js' => array(
192 $module_path . '/toolbar.js',
193 array(
194 'data' => array('tableHeaderOffset' => 'Drupal.toolbar.height'),
195 'type' => 'setting'
196 ),
197 ),
198 'css' => array(
199 $module_path . '/toolbar.css',
200 ),
201 'library' => array(array('system', 'jquery.cookie')),
202 ),
203 );
204
205 // Retrieve the admin menu from the database.
206 $links = toolbar_menu_navigation_links(toolbar_get_menu_tree());
207 $build['toolbar_menu'] = array(
208 '#theme' => 'links__toolbar_menu',
209 '#links' => $links,
210 '#attributes' => array('id' => 'toolbar-menu'),
211 '#heading' => array('text' => t('Administrative toolbar'), 'level' => 'h2', 'class' => 'element-invisible'),
212 );
213
214 // Add logout & user account links or login link.
215 if ($user->uid) {
216 $links = array(
217 'account' => array(
218 'title' => t('Hello <strong>@username</strong>', array('@username' => format_username($user))),
219 'href' => 'user',
220 'html' => TRUE,
221 'attributes' => array('title' => t('User account')),
222 ),
223 'logout' => array(
224 'title' => t('Log out'),
225 'href' => 'user/logout',
226 ),
227 );
228 }
229 else {
230 $links = array(
231 'login' => array(
232 'title' => t('Log in'),
233 'href' => 'user',
234 ),
235 );
236 }
237 $build['toolbar_user'] = array(
238 '#theme' => 'links__toolbar_user',
239 '#links' => $links,
240 '#attributes' => array('id' => 'toolbar-user'),
241 );
242
243 // Add a "home" link.
244 $link = array(
245 'home' => array(
246 'title' => '<span class="home-link">Home</span>',
247 'href' => '<front>',
248 'html' => TRUE,
249 'attributes' => array('title' => t('Home')),
250 ),
251 );
252 $build['toolbar_home'] = array(
253 '#theme' => 'links',
254 '#links' => $link,
255 '#attributes' => array('id' => 'toolbar-home'),
256 );
257
258 // Add an anchor to be able to toggle the visibility of the drawer.
259 $build['toolbar_toggle'] = array(
260 '#theme' => 'toolbar_toggle',
261 '#collapsed' => _toolbar_is_collapsed(),
262 '#attributes' => array('class' => array('toggle')),
263 );
264
265 // Prepare the drawer links CSS classes.
266 $toolbar_drawer_classes = array(
267 'toolbar-drawer',
268 'clearfix',
269 );
270 if(_toolbar_is_collapsed()) {
271 $toolbar_drawer_classes[] = 'collapsed';
272 }
273 $build['toolbar_drawer_classes'] = implode(' ', $toolbar_drawer_classes);
274
275 return $build;
276 }
277
284 function toolbar_get_menu_tree() {
285 $tree = array();
286 $admin_link = db_query('SELECT * FROM {menu_links} WHERE menu_name = :menu_name AND module = :module AND link_path = :path', array(':menu_name' => 'management', ':module' => 'system', ':path' => 'admin'))->fetchAssoc();
287 if ($admin_link) {
288 $tree = menu_build_tree('management', array(
289 'expanded' => array($admin_link['mlid']),
290 'min_depth' => $admin_link['depth'] + 1,
291 'max_depth' => $admin_link['depth'] + 1,
292 ));
293 }
294
295 return $tree;
296 }
297
307 function toolbar_menu_navigation_links($tree) {
308 $links = array();
309 foreach ($tree as $item) {
310 if (!$item['link']['hidden'] && $item['link']['access']) {
311 // Make sure we have a path specific ID in place, so we can attach icons
312 // and behaviors to the items.
313 $id = str_replace(array('/', '<', '>'), array('-', '', ''), $item['link']['href']);
314
315 $link = $item['link']['localized_options'];
316 $link['href'] = $item['link']['href'];
317 // Add icon placeholder.
318 $link['title'] = '<span class="icon"></span>' . check_plain($item['link']['title']);
319 // Add admin link ID.
320 $link['attributes'] = array('id' => 'toolbar-link-' . $id);
321 if (!empty($item['link']['description'])) {
322 $link['title'] .= ' <span class="element-invisible">(' . $item['link']['description'] . ')</span>';
323 $link['attributes']['title'] = $item['link']['description'];
324 }
325 $link['html'] = TRUE;
326
327 $class = ' path-' . $id;
328 if (toolbar_in_active_trail($item['link']['href'])) {
329 $class .= ' active-trail';
330 }
331 $links['menu-' . $item['link']['mlid'] . $class] = $link;
332 }
333 }
334 return $links;
335 }
336
349 function toolbar_in_active_trail($path) {
350 $active_paths = &drupal_static(__FUNCTION__);
351
352 // Gather active paths.
353 if (!isset($active_paths)) {
354 $active_paths = array();
355 $trail = menu_get_active_trail();
356 foreach ($trail as $item) {
357 if (!empty($item['href'])) {
358 $active_paths[] = $item['href'];
359 }
360 }
361 }
362 return in_array($path, $active_paths);
363 }
toolbar_permission
toolbar_permission()
Definition: toolbar.module:28
toolbar_system_info_alter
toolbar_system_info_alter(&$info, $file, $type)
Definition: toolbar.module:172
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
toolbar_page_build
toolbar_page_build(&$page)
Definition: toolbar.module:119
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
format_username
format_username($account)
Definition: common.inc:2106
$page
print $page
Definition: overlay.tpl.php:37
toolbar_view
toolbar_view()
Definition: toolbar.module:184
toolbar_preprocess_toolbar
toolbar_preprocess_toolbar(&$variables)
Definition: toolbar.module:158
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
toolbar_preprocess_html
toolbar_preprocess_html(&$vars)
Definition: toolbar.module:143
toolbar_pre_render
toolbar_pre_render($toolbar)
Definition: toolbar.module:133
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
toolbar_menu_navigation_links
toolbar_menu_navigation_links($tree)
Definition: toolbar.module:307
$info
$info
Definition: color.inc:6
toolbar_in_active_trail
toolbar_in_active_trail($path)
Definition: toolbar.module:349
toolbar_toggle_page
toolbar_toggle_page()
Definition: toolbar.module:70
menu_get_active_trail
menu_get_active_trail()
Definition: menu.inc:2553
$output
$output
Definition: authorize.php:93
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
user_access
user_access($string, $account=NULL)
Definition: user.module:794
toolbar_menu
toolbar_menu()
Definition: toolbar.module:57
toolbar_theme
toolbar_theme($existing, $type, $theme, $path)
Definition: toolbar.module:39
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
toolbar_get_menu_tree
toolbar_get_menu_tree()
Definition: toolbar.module:284
_toolbar_is_collapsed
_toolbar_is_collapsed()
Definition: toolbar.module:108
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
toolbar_help
toolbar_help($path, $arg)
Definition: toolbar.module:11
theme_toolbar_toggle
theme_toolbar_toggle($variables)
Definition: toolbar.module:91
$tree
if($tree||$has_links) print $tree
Definition: book-navigation.tpl.php:35
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
menu_build_tree
menu_build_tree($menu_name, array $parameters=array())
Definition: menu.inc:1351
$links
print $links
Definition: poll-results--block.tpl.php:28
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/prefetch.inc Source File

  • includes
  • database
prefetch.inc
Go to the documentation of this file.
1 <?php
2
22 class DatabaseStatementPrefetch implements Iterator, DatabaseStatementInterface {
23
29 protected $queryString;
30
36 protected $driverOptions;
37
45 public $dbh;
46
52 protected $data = array();
53
59 protected $currentRow = NULL;
60
66 protected $currentKey = NULL;
67
73 protected $columnNames = NULL;
74
80 protected $rowCount = NULL;
81
87 protected $resultRowCount = 0;
88
95 protected $fetchStyle = PDO::FETCH_OBJ;
96
102 protected $fetchOptions = array(
103 'class' => 'stdClass',
104 'constructor_args' => array(),
105 'object' => NULL,
106 'column' => 0,
107 );
108
114 protected $defaultFetchStyle = PDO::FETCH_OBJ;
115
121 protected $defaultFetchOptions = array(
122 'class' => 'stdClass',
123 'constructor_args' => array(),
124 'object' => NULL,
125 'column' => 0,
126 );
127
128 public function __construct(DatabaseConnection $connection, $query, array $driver_options = array()) {
129 $this->dbh = $connection;
130 $this->queryString = $query;
131 $this->driverOptions = $driver_options;
132 }
133
144 public function execute($args = array(), $options = array()) {
145 if (isset($options['fetch'])) {
146 if (is_string($options['fetch'])) {
147 // Default to an object. Note: db fields will be added to the object
148 // before the constructor is run. If you need to assign fields after
149 // the constructor is run, see http://drupal.org/node/315092.
150 $this->setFetchMode(PDO::FETCH_CLASS, $options['fetch']);
151 }
152 else {
153 $this->setFetchMode($options['fetch']);
154 }
155 }
156
157 $logger = $this->dbh->getLogger();
158 if (!empty($logger)) {
159 $query_start = microtime(TRUE);
160 }
161
162 // Prepare the query.
163 $statement = $this->getStatement($this->queryString, $args);
164 if (!$statement) {
165 $this->throwPDOException();
166 }
167
168 $return = $statement->execute($args);
169 if (!$return) {
170 $this->throwPDOException();
171 }
172
173 // Fetch all the data from the reply, in order to release any lock
174 // as soon as possible.
175 $this->rowCount = $statement->rowCount();
176 $this->data = $statement->fetchAll(PDO::FETCH_ASSOC);
177 // Destroy the statement as soon as possible. See
178 // DatabaseConnection_sqlite::PDOPrepare() for explanation.
179 unset($statement);
180
181 $this->resultRowCount = count($this->data);
182
183 if ($this->resultRowCount) {
184 $this->columnNames = array_keys($this->data[0]);
185 }
186 else {
187 $this->columnNames = array();
188 }
189
190 if (!empty($logger)) {
191 $query_end = microtime(TRUE);
192 $logger->log($this, $args, $query_end - $query_start);
193 }
194
195 // Initialize the first row in $this->currentRow.
196 $this->next();
197
198 return $return;
199 }
200
204 protected function throwPDOException() {
205 $error_info = $this->dbh->errorInfo();
206 // We rebuild a message formatted in the same way as PDO.
207 $exception = new PDOException("SQLSTATE[" . $error_info[0] . "]: General error " . $error_info[1] . ": " . $error_info[2]);
208 $exception->errorInfo = $error_info;
209 throw $exception;
210 }
211
225 protected function getStatement($query, &$args = array()) {
226 return $this->dbh->prepare($query);
227 }
228
232 public function getQueryString() {
233 return $this->queryString;
234 }
235
239 public function setFetchMode($fetchStyle, $a2 = NULL, $a3 = NULL) {
240 $this->defaultFetchStyle = $fetchStyle;
241 switch ($fetchStyle) {
242 case PDO::FETCH_CLASS:
243 $this->defaultFetchOptions['class'] = $a2;
244 if ($a3) {
245 $this->defaultFetchOptions['constructor_args'] = $a3;
246 }
247 break;
248 case PDO::FETCH_COLUMN:
249 $this->defaultFetchOptions['column'] = $a2;
250 break;
251 case PDO::FETCH_INTO:
252 $this->defaultFetchOptions['object'] = $a2;
253 break;
254 }
255
256 // Set the values for the next fetch.
257 $this->fetchStyle = $this->defaultFetchStyle;
258 $this->fetchOptions = $this->defaultFetchOptions;
259 }
260
271 public function current() {
272 if (isset($this->currentRow)) {
273 switch ($this->fetchStyle) {
274 case PDO::FETCH_ASSOC:
275 return $this->currentRow;
276 case PDO::FETCH_BOTH:
277 // PDO::FETCH_BOTH returns an array indexed by both the column name
278 // and the column number.
279 return $this->currentRow + array_values($this->currentRow);
280 case PDO::FETCH_NUM:
281 return array_values($this->currentRow);
282 case PDO::FETCH_LAZY:
283 // We do not do lazy as everything is fetched already. Fallback to
284 // PDO::FETCH_OBJ.
285 case PDO::FETCH_OBJ:
286 return (object) $this->currentRow;
287 case PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE:
288 $class_name = array_unshift($this->currentRow);
289 // Deliberate no break.
290 case PDO::FETCH_CLASS:
291 if (!isset($class_name)) {
292 $class_name = $this->fetchOptions['class'];
293 }
294 if (count($this->fetchOptions['constructor_args'])) {
295 $reflector = new ReflectionClass($class_name);
296 $result = $reflector->newInstanceArgs($this->fetchOptions['constructor_args']);
297 }
298 else {
299 $result = new $class_name();
300 }
301 foreach ($this->currentRow as $k => $v) {
302 $result->$k = $v;
303 }
304 return $result;
305 case PDO::FETCH_INTO:
306 foreach ($this->currentRow as $k => $v) {
307 $this->fetchOptions['object']->$k = $v;
308 }
309 return $this->fetchOptions['object'];
310 case PDO::FETCH_COLUMN:
311 if (isset($this->columnNames[$this->fetchOptions['column']])) {
312 return $this->currentRow[$k][$this->columnNames[$this->fetchOptions['column']]];
313 }
314 else {
315 return;
316 }
317 }
318 }
319 }
320
321 /* Implementations of Iterator. */
322
323 public function key() {
324 return $this->currentKey;
325 }
326
327 public function rewind() {
328 // Nothing to do: our DatabaseStatement can't be rewound.
329 }
330
331 public function next() {
332 if (!empty($this->data)) {
333 $this->currentRow = reset($this->data);
334 $this->currentKey = key($this->data);
335 unset($this->data[$this->currentKey]);
336 }
337 else {
338 $this->currentRow = NULL;
339 }
340 }
341
342 public function valid() {
343 return isset($this->currentRow);
344 }
345
346 /* Implementations of DatabaseStatementInterface. */
347
348 public function rowCount() {
349 return $this->rowCount;
350 }
351
352 public function fetch($fetch_style = NULL, $cursor_orientation = PDO::FETCH_ORI_NEXT, $cursor_offset = NULL) {
353 if (isset($this->currentRow)) {
354 // Set the fetch parameter.
355 $this->fetchStyle = isset($fetch_style) ? $fetch_style : $this->defaultFetchStyle;
356 $this->fetchOptions = $this->defaultFetchOptions;
357
358 // Grab the row in the format specified above.
359 $return = $this->current();
360 // Advance the cursor.
361 $this->next();
362
363 // Reset the fetch parameters to the value stored using setFetchMode().
364 $this->fetchStyle = $this->defaultFetchStyle;
365 $this->fetchOptions = $this->defaultFetchOptions;
366 return $return;
367 }
368 else {
369 return FALSE;
370 }
371 }
372
373 public function fetchColumn($index = 0) {
374 if (isset($this->currentRow) && isset($this->columnNames[$index])) {
375 // We grab the value directly from $this->data, and format it.
376 $return = $this->currentRow[$this->columnNames[$index]];
377 $this->next();
378 return $return;
379 }
380 else {
381 return FALSE;
382 }
383 }
384
385 public function fetchField($index = 0) {
386 return $this->fetchColumn($index);
387 }
388
389 public function fetchObject($class_name = NULL, $constructor_args = array()) {
390 if (isset($this->currentRow)) {
391 if (!isset($class_name)) {
392 // Directly cast to an object to avoid a function call.
393 $result = (object) $this->currentRow;
394 }
395 else {
396 $this->fetchStyle = PDO::FETCH_CLASS;
397 $this->fetchOptions = array('constructor_args' => $constructor_args);
398 // Grab the row in the format specified above.
399 $result = $this->current();
400 // Reset the fetch parameters to the value stored using setFetchMode().
401 $this->fetchStyle = $this->defaultFetchStyle;
402 $this->fetchOptions = $this->defaultFetchOptions;
403 }
404
405 $this->next();
406
407 return $result;
408 }
409 else {
410 return FALSE;
411 }
412 }
413
414 public function fetchAssoc() {
415 if (isset($this->currentRow)) {
416 $result = $this->currentRow;
417 $this->next();
418 return $result;
419 }
420 else {
421 return FALSE;
422 }
423 }
424
425 public function fetchAll($fetch_style = NULL, $fetch_column = NULL, $constructor_args = NULL) {
426 $this->fetchStyle = isset($fetch_style) ? $fetch_style : $this->defaultFetchStyle;
427 $this->fetchOptions = $this->defaultFetchOptions;
428 if (isset($fetch_column)) {
429 $this->fetchOptions['column'] = $fetch_column;
430 }
431 if (isset($constructor_args)) {
432 $this->fetchOptions['constructor_args'] = $constructor_args;
433 }
434
435 $result = array();
436 // Traverse the array as PHP would have done.
437 while (isset($this->currentRow)) {
438 // Grab the row in the format specified above.
439 $result[] = $this->current();
440 $this->next();
441 }
442
443 // Reset the fetch parameters to the value stored using setFetchMode().
444 $this->fetchStyle = $this->defaultFetchStyle;
445 $this->fetchOptions = $this->defaultFetchOptions;
446 return $result;
447 }
448
449 public function fetchCol($index = 0) {
450 if (isset($this->columnNames[$index])) {
451 $column = $this->columnNames[$index];
452 $result = array();
453 // Traverse the array as PHP would have done.
454 while (isset($this->currentRow)) {
455 $result[] = $this->currentRow[$this->columnNames[$index]];
456 $this->next();
457 }
458 return $result;
459 }
460 else {
461 return array();
462 }
463 }
464
465 public function fetchAllKeyed($key_index = 0, $value_index = 1) {
466 if (!isset($this->columnNames[$key_index]) || !isset($this->columnNames[$value_index]))
467 return array();
468
469 $key = $this->columnNames[$key_index];
470 $value = $this->columnNames[$value_index];
471
472 $result = array();
473 // Traverse the array as PHP would have done.
474 while (isset($this->currentRow)) {
475 $result[$this->currentRow[$key]] = $this->currentRow[$value];
476 $this->next();
477 }
478 return $result;
479 }
480
481 public function fetchAllAssoc($key, $fetch_style = NULL) {
482 $this->fetchStyle = isset($fetch_style) ? $fetch_style : $this->defaultFetchStyle;
483 $this->fetchOptions = $this->defaultFetchOptions;
484
485 $result = array();
486 // Traverse the array as PHP would have done.
487 while (isset($this->currentRow)) {
488 // Grab the row in its raw PDO::FETCH_ASSOC format.
489 $row = $this->currentRow;
490 // Grab the row in the format specified above.
491 $result_row = $this->current();
492 $result[$this->currentRow[$key]] = $result_row;
493 $this->next();
494 }
495
496 // Reset the fetch parameters to the value stored using setFetchMode().
497 $this->fetchStyle = $this->defaultFetchStyle;
498 $this->fetchOptions = $this->defaultFetchOptions;
499 return $result;
500 }
501
502 }
503
DatabaseStatementPrefetch\valid
valid()
Definition: prefetch.inc:342
DatabaseStatementPrefetch\getQueryString
getQueryString()
Definition: prefetch.inc:232
DatabaseStatementPrefetch\fetchColumn
fetchColumn($index=0)
Definition: prefetch.inc:373
DatabaseStatementPrefetch\$data
$data
Definition: prefetch.inc:52
DatabaseStatementPrefetch\fetch
fetch($fetch_style=NULL, $cursor_orientation=PDO::FETCH_ORI_NEXT, $cursor_offset=NULL)
Definition: prefetch.inc:352
DatabaseStatementPrefetch\$resultRowCount
$resultRowCount
Definition: prefetch.inc:87
DatabaseStatementPrefetch\rowCount
rowCount()
Definition: prefetch.inc:348
DatabaseStatementPrefetch\fetchCol
fetchCol($index=0)
Definition: prefetch.inc:449
DatabaseStatementPrefetch\$defaultFetchOptions
$defaultFetchOptions
Definition: prefetch.inc:121
DatabaseStatementPrefetch\fetchObject
fetchObject($class_name=NULL, $constructor_args=array())
Definition: prefetch.inc:389
DatabaseStatementPrefetch\$dbh
$dbh
Definition: prefetch.inc:45
DatabaseStatementPrefetch\fetchField
fetchField($index=0)
Definition: prefetch.inc:385
DatabaseStatementPrefetch\fetchAll
fetchAll($fetch_style=NULL, $fetch_column=NULL, $constructor_args=NULL)
Definition: prefetch.inc:425
DatabaseStatementPrefetch\$currentRow
$currentRow
Definition: prefetch.inc:59
DatabaseStatementPrefetch\$columnNames
$columnNames
Definition: prefetch.inc:73
DatabaseStatementPrefetch\setFetchMode
setFetchMode($fetchStyle, $a2=NULL, $a3=NULL)
Definition: prefetch.inc:239
DatabaseStatementPrefetch\$fetchOptions
$fetchOptions
Definition: prefetch.inc:102
DatabaseStatementPrefetch\$fetchStyle
$fetchStyle
Definition: prefetch.inc:95
$value
print $value
Definition: user-profile-item.tpl.php:26
DatabaseStatementPrefetch\$rowCount
$rowCount
Definition: prefetch.inc:80
DatabaseStatementPrefetch\$queryString
$queryString
Definition: prefetch.inc:29
DatabaseStatementPrefetch\fetchAllKeyed
fetchAllKeyed($key_index=0, $value_index=1)
Definition: prefetch.inc:465
DatabaseStatementInterface
Definition: database.inc:1953
DatabaseStatementPrefetch\next
next()
Definition: prefetch.inc:331
DatabaseStatementPrefetch\current
current()
Definition: prefetch.inc:271
DatabaseStatementPrefetch
Definition: prefetch.inc:22
DatabaseStatementPrefetch\key
key()
Definition: prefetch.inc:323
DatabaseConnection
Definition: database.inc:184
DatabaseStatementPrefetch\getStatement
getStatement($query, &$args=array())
Definition: prefetch.inc:225
DatabaseStatementPrefetch\fetchAllAssoc
fetchAllAssoc($key, $fetch_style=NULL)
Definition: prefetch.inc:481
DatabaseStatementPrefetch\$driverOptions
$driverOptions
Definition: prefetch.inc:36
DatabaseStatementPrefetch\rewind
rewind()
Definition: prefetch.inc:327
$row
$row
Definition: block-admin-display-form.tpl.php:47
DatabaseStatementPrefetch\$currentKey
$currentKey
Definition: prefetch.inc:66
DatabaseStatementPrefetch\fetchAssoc
fetchAssoc()
Definition: prefetch.inc:414
DatabaseStatementPrefetch\__construct
__construct(DatabaseConnection $connection, $query, array $driver_options=array())
Definition: prefetch.inc:128
DatabaseStatementPrefetch\execute
execute($args=array(), $options=array())
Definition: prefetch.inc:144
DatabaseStatementPrefetch\$defaultFetchStyle
$defaultFetchStyle
Definition: prefetch.inc:114
DatabaseStatementPrefetch\throwPDOException
throwPDOException()
Definition: prefetch.inc:204
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/statistics/statistics.module Source File

  • modules
  • statistics
statistics.module
Go to the documentation of this file.
1 <?php
2
11 function statistics_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#statistics':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t('The Statistics module shows you how often a given page is viewed, who viewed it, the previous page the user visited (referrer URL), and when it was viewed. These statistics are useful in determining how users are visiting and navigating your site. For more information, see the online handbook entry for the <a href="@statistics">Statistics module</a>.', array('@statistics' => url('http://drupal.org/documentation/modules/statistics/'))) . '</p>';
17 $output .= '<h3>' . t('Uses') . '</h3>';
18 $output .= '<dl>';
19 $output .= '<dt>' . t('Managing logs') . '</dt>';
20 $output .= '<dd>' . t('To enable collection of statistics, the <em>Enable access log</em> checkbox on the <a href="@statistics-settings">Statistics settings page</a> must be checked. The <em>Discard access logs older than</em> setting on the settings page specifies the length of time entries are kept in the log before they are deleted. This setting requires a correctly configured <a href="@cron">cron maintenance task</a> to run.', array('@statistics-settings' => url('admin/config/system/statistics'), '@cron' => 'http://drupal.org/cron')) . '</dd>';
21 $output .= '<dt>' . t('Viewing site usage') . '</dt>';
22 $output .= '<dd>' . t('The Statistics module can help you break down details about your users and how they are using the site. The module offers four reports:');
23 $output .= '<ul><li>' . t('<a href="@recent-hits">Recent hits</a> displays information about the latest activity on your site, including the URL and title of the page that was accessed, the user name (if available) and the IP address of the viewer.', array('@recent-hits' => url('admin/reports/hits'))) . '</li>';
24 $output .= '<li>' . t('<a href="@top-referrers">Top referrers</a> displays where visitors came from (referrer URL).', array('@top-referrers' => url('admin/reports/referrers'))) . '</li>';
25 $output .= '<li>' . t('<a href="@top-pages">Top pages</a> displays a list of pages ordered by how often they were viewed.', array('@top-pages' => url('admin/reports/pages'))) . '</li>';
26 $output .= '<li>' . t('<a href="@top-visitors">Top visitors</a> shows you the most active visitors for your site and allows you to ban abusive visitors.', array('@top-visitors' => url('admin/reports/visitors'))) . '</li></ul>';
27 $output .= '<dt>' . t('Displaying popular content') . '</dt>';
28 $output .= '<dd>' . t('The module includes a <em>Popular content</em> block that displays the most viewed pages today and for all time, and the last content viewed. To use the block, enable <em>Count content views</em> on the <a href="@statistics-settings">statistics settings page</a>, and then you can enable and configure the block on the <a href="@blocks">blocks administration page</a>.', array('@statistics-settings' => url('admin/config/system/statistics'), '@blocks' => url('admin/structure/block'))) . '</dd>';
29 $output .= '<dt>' . t('Page view counter') . '</dt>';
30 $output .= '<dd>' . t('The Statistics module includes a counter for each page that increases whenever the page is viewed. To use the counter, enable <em>Count content views</em> on the <a href="@statistics-settings">statistics settings page</a>, and set the necessary <a href="@permissions">permissions</a> (<em>View content hits</em>) so that the counter is visible to the users.', array('@statistics-settings' => url('admin/config/system/statistics'), '@permissions' => url('admin/people/permissions', array('fragment' => 'module-statistics')))) . '</dd>';
31 $output .= '</dl>';
32 return $output;
33 case 'admin/config/system/statistics':
34 return '<p>' . t('Settings for the statistical information that Drupal will keep about the site. See <a href="@statistics">site statistics</a> for the actual information.', array('@statistics' => url('admin/reports/hits'))) . '</p>';
35 case 'admin/reports/hits':
36 return '<p>' . t("This page displays the site's most recent hits.") . '</p>';
37 case 'admin/reports/referrers':
38 return '<p>' . t('This page displays all external referrers, or external references to your website.') . '</p>';
39 case 'admin/reports/visitors':
40 return '<p>' . t("When you ban a visitor, you prevent the visitor's IP address from accessing your site. Unlike blocking a user, banning a visitor works even for anonymous users. This is most commonly used to block resource-intensive bots or web crawlers.") . '</p>';
41 }
42 }
43
44
50 function statistics_exit() {
51 global $user;
52
53 // When serving cached pages with the 'page_cache_without_database'
54 // configuration, system variables need to be loaded. This is a major
55 // performance decrease for non-database page caches, but with Statistics
56 // module, it is likely to also have 'statistics_enable_access_log' enabled,
57 // in which case we need to bootstrap to the session phase anyway.
58 drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
59
60 if (variable_get('statistics_count_content_views', 0) && !variable_get('statistics_count_content_views_ajax', 0)) {
61 // We are counting content views.
62 if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == NULL) {
63 // A node has been viewed, so update the node's counters.
64 db_merge('node_counter')
65 ->key(array('nid' => arg(1)))
66 ->fields(array(
67 'daycount' => 1,
68 'totalcount' => 1,
69 'timestamp' => REQUEST_TIME,
70 ))
71 ->expression('daycount', 'daycount + 1')
72 ->expression('totalcount', 'totalcount + 1')
73 ->execute();
74 }
75 }
76 if (variable_get('statistics_enable_access_log', 0)) {
77 drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
78
79 // For anonymous users unicode.inc will not have been loaded.
80 include_once DRUPAL_ROOT . '/includes/unicode.inc';
81 // Log this page access.
82 db_insert('accesslog')
83 ->fields(array(
84 'title' => truncate_utf8(strip_tags(drupal_get_title()), 255),
85 'path' => truncate_utf8($_GET['q'], 255),
86 'url' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
87 'hostname' => ip_address(),
88 'uid' => $user->uid,
89 'sid' => session_id(),
90 'timer' => (int) timer_read('page'),
91 'timestamp' => REQUEST_TIME,
92 ))
93 ->execute();
94 }
95 }
96
100 function statistics_permission() {
101 return array(
102 'administer statistics' => array(
103 'title' => t('Administer statistics'),
104 ),
105 'access statistics' => array(
106 'title' => t('View content access statistics'),
107 ),
108 'view post access counter' => array(
109 'title' => t('View content hits'),
110 ),
111 );
112 }
113
117 function statistics_node_view($node, $view_mode) {
118 // Attach Ajax node count statistics if configured.
119 if (variable_get('statistics_count_content_views', 0) && variable_get('statistics_count_content_views_ajax', 0)) {
120 if (!empty($node->nid) && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
121 $node->content['#attached']['js'] = array(
122 drupal_get_path('module', 'statistics') . '/statistics.js' => array(
123 'scope' => 'footer'
124 ),
125 );
126 $settings = array('data' => array('nid' => $node->nid), 'url' => url(drupal_get_path('module', 'statistics') . '/statistics.php'));
127 $node->content['#attached']['js'][] = array(
128 'data' => array('statistics' => $settings),
129 'type' => 'setting',
130 );
131 }
132 }
133
134 if ($view_mode != 'rss') {
135 if (user_access('view post access counter')) {
136 $statistics = statistics_get($node->nid);
137 if ($statistics) {
138 $links['statistics_counter']['title'] = format_plural($statistics['totalcount'], '1 read', '@count reads');
139 $node->content['links']['statistics'] = array(
140 '#theme' => 'links__node__statistics',
141 '#links' => $links,
142 '#attributes' => array('class' => array('links', 'inline')),
143 );
144 }
145 }
146 }
147 }
148
152 function statistics_menu() {
153 $items['admin/reports/hits'] = array(
154 'title' => 'Recent hits',
155 'description' => 'View pages that have recently been visited.',
156 'page callback' => 'statistics_recent_hits',
157 'access arguments' => array('access statistics'),
158 'file' => 'statistics.admin.inc',
159 );
160 $items['admin/reports/pages'] = array(
161 'title' => 'Top pages',
162 'description' => 'View pages that have been hit frequently.',
163 'page callback' => 'statistics_top_pages',
164 'access arguments' => array('access statistics'),
165 'weight' => 1,
166 'file' => 'statistics.admin.inc',
167 );
168 $items['admin/reports/visitors'] = array(
169 'title' => 'Top visitors',
170 'description' => 'View visitors that hit many pages.',
171 'page callback' => 'statistics_top_visitors',
172 'access arguments' => array('access statistics'),
173 'weight' => 2,
174 'file' => 'statistics.admin.inc',
175 );
176 $items['admin/reports/referrers'] = array(
177 'title' => 'Top referrers',
178 'description' => 'View top referrers.',
179 'page callback' => 'statistics_top_referrers',
180 'access arguments' => array('access statistics'),
181 'file' => 'statistics.admin.inc',
182 );
183 $items['admin/reports/access/%'] = array(
184 'title' => 'Details',
185 'description' => 'View access log.',
186 'page callback' => 'statistics_access_log',
187 'page arguments' => array(3),
188 'access arguments' => array('access statistics'),
189 'file' => 'statistics.admin.inc',
190 );
191 $items['admin/config/system/statistics'] = array(
192 'title' => 'Statistics',
193 'description' => 'Control details about what and how your site logs access statistics.',
194 'page callback' => 'drupal_get_form',
195 'page arguments' => array('statistics_settings_form'),
196 'access arguments' => array('administer statistics'),
197 'file' => 'statistics.admin.inc',
198 'weight' => -15,
199 );
200 $items['user/%user/track/navigation'] = array(
201 'title' => 'Track page visits',
202 'page callback' => 'statistics_user_tracker',
203 'access callback' => 'user_access',
204 'access arguments' => array('access statistics'),
205 'type' => MENU_LOCAL_TASK,
206 'weight' => 2,
207 'file' => 'statistics.pages.inc',
208 );
209 $items['node/%node/track'] = array(
210 'title' => 'Track',
211 'page callback' => 'statistics_node_tracker',
212 'access callback' => 'user_access',
213 'access arguments' => array('access statistics'),
214 'type' => MENU_LOCAL_TASK,
215 'weight' => 2,
216 'file' => 'statistics.pages.inc',
217 );
218
219 return $items;
220 }
221
225 function statistics_user_cancel($edit, $account, $method) {
226 switch ($method) {
227 case 'user_cancel_reassign':
228 db_update('accesslog')
229 ->fields(array('uid' => 0))
230 ->condition('uid', $account->uid)
231 ->execute();
232 break;
233 }
234 }
235
239 function statistics_user_delete($account) {
240 db_delete('accesslog')
241 ->condition('uid', $account->uid)
242 ->execute();
243 }
244
248 function statistics_cron() {
249 $statistics_timestamp = variable_get('statistics_day_timestamp', '');
250
251 if ((REQUEST_TIME - $statistics_timestamp) >= 86400) {
252 // Reset day counts.
253 db_update('node_counter')
254 ->fields(array('daycount' => 0))
255 ->execute();
256 variable_set('statistics_day_timestamp', REQUEST_TIME);
257 }
258
259 // Clean up expired access logs (if applicable).
260 if (variable_get('statistics_flush_accesslog_timer', 259200) > 0) {
261 db_delete('accesslog')
262 ->condition('timestamp', REQUEST_TIME - variable_get('statistics_flush_accesslog_timer', 259200), '<')
263 ->execute();
264 }
265 }
266
283 function statistics_title_list($dbfield, $dbrows) {
284 if (in_array($dbfield, array('totalcount', 'daycount', 'timestamp'))) {
285 $query = db_select('node', 'n');
286 $query->addTag('node_access');
287 $query->join('node_counter', 's', 'n.nid = s.nid');
288 $query->join('users', 'u', 'n.uid = u.uid');
289
290 return $query
291 ->fields('n', array('nid', 'title'))
292 ->fields('u', array('uid', 'name'))
293 ->condition($dbfield, 0, '<>')
294 ->condition('n.status', 1)
295 ->orderBy($dbfield, 'DESC')
296 ->range(0, $dbrows)
297 ->execute();
298 }
299 return FALSE;
300 }
301
302
317 function statistics_get($nid) {
318
319 if ($nid > 0) {
320 // Retrieve an array with both totalcount and daycount.
321 return db_query('SELECT totalcount, daycount, timestamp FROM {node_counter} WHERE nid = :nid', array(':nid' => $nid), array('target' => 'slave'))->fetchAssoc();
322 }
323 }
324
328 function statistics_block_info() {
329 $blocks = array();
330
331 if (variable_get('statistics_count_content_views', 0)) {
332 $blocks['popular']['info'] = t('Popular content');
333 // Too dynamic to cache.
334 $blocks['popular']['cache'] = DRUPAL_NO_CACHE;
335 }
336 return $blocks;
337 }
338
342 function statistics_block_configure($delta = '') {
343 // Popular content block settings
344 $numbers = array('0' => t('Disabled')) + drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40));
345 $form['statistics_block_top_day_num'] = array('#type' => 'select', '#title' => t("Number of day's top views to display"), '#default_value' => variable_get('statistics_block_top_day_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "day" list.'));
346 $form['statistics_block_top_all_num'] = array('#type' => 'select', '#title' => t('Number of all time views to display'), '#default_value' => variable_get('statistics_block_top_all_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "all time" list.'));
347 $form['statistics_block_top_last_num'] = array('#type' => 'select', '#title' => t('Number of most recent views to display'), '#default_value' => variable_get('statistics_block_top_last_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "recently viewed" list.'));
348 return $form;
349 }
350
354 function statistics_block_save($delta = '', $edit = array()) {
355 variable_set('statistics_block_top_day_num', $edit['statistics_block_top_day_num']);
356 variable_set('statistics_block_top_all_num', $edit['statistics_block_top_all_num']);
357 variable_set('statistics_block_top_last_num', $edit['statistics_block_top_last_num']);
358 }
359
363 function statistics_block_view($delta = '') {
364 if (user_access('access content')) {
365 $content = array();
366
367 $daytop = variable_get('statistics_block_top_day_num', 0);
368 if ($daytop && ($result = statistics_title_list('daycount', $daytop)) && ($node_title_list = node_title_list($result, t("Today's:")))) {
369 $content['top_day'] = $node_title_list;
370 $content['top_day']['#suffix'] = '<br />';
371 }
372
373 $alltimetop = variable_get('statistics_block_top_all_num', 0);
374 if ($alltimetop && ($result = statistics_title_list('totalcount', $alltimetop)) && ($node_title_list = node_title_list($result, t('All time:')))) {
375 $content['top_all'] = $node_title_list;
376 $content['top_all']['#suffix'] = '<br />';
377 }
378
379 $lasttop = variable_get('statistics_block_top_last_num', 0);
380 if ($lasttop && ($result = statistics_title_list('timestamp', $lasttop)) && ($node_title_list = node_title_list($result, t('Last viewed:')))) {
381 $content['top_last'] = $node_title_list;
382 $content['top_last']['#suffix'] = '<br />';
383 }
384
385 if (count($content)) {
386 $block['content'] = $content;
387 $block['subject'] = t('Popular content');
388 return $block;
389 }
390 }
391 }
392
404 function _statistics_link($path, $width = 35) {
405 $title = drupal_get_path_alias($path);
406 $title = truncate_utf8($title, $width, FALSE, TRUE);
407 return l($title, $path);
408 }
409
421 function _statistics_format_item($title, $path) {
422 $path = ($path ? $path : '/');
423 $output = ($title ? "$title<br />" : '');
424 $output .= _statistics_link($path);
425 return $output;
426 }
427
431 function statistics_node_delete($node) {
432 // clean up statistics table when node is deleted
433 db_delete('node_counter')
434 ->condition('nid', $node->nid)
435 ->execute();
436 }
437
441 function statistics_ranking() {
442 if (variable_get('statistics_count_content_views', 0)) {
443 return array(
444 'views' => array(
445 'title' => t('Number of views'),
446 'join' => array(
447 'type' => 'LEFT',
448 'table' => 'node_counter',
449 'alias' => 'node_counter',
450 'on' => 'node_counter.nid = i.sid',
451 ),
452 // Inverse law that maps the highest view count on the site to 1 and 0 to 0.
453 'score' => '2.0 - 2.0 / (1.0 + node_counter.totalcount * CAST(:scale AS DECIMAL))',
454 'arguments' => array(':scale' => variable_get('node_cron_views_scale', 0)),
455 ),
456 );
457 }
458 }
459
463 function statistics_update_index() {
464 variable_set('node_cron_views_scale', 1.0 / max(1, db_query('SELECT MAX(totalcount) FROM {node_counter}')->fetchField()));
465 }
statistics_permission
statistics_permission()
Definition: statistics.module:100
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
l
l($text, $path, array $options=array())
Definition: common.inc:2432
statistics_node_delete
statistics_node_delete($node)
Definition: statistics.module:431
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
_statistics_link
_statistics_link($path, $width=35)
Definition: statistics.module:404
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
statistics_block_info
statistics_block_info()
Definition: statistics.module:328
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
ip_address
ip_address()
Definition: bootstrap.inc:2890
node_is_page
node_is_page($node)
Definition: node.module:1487
drupal_bootstrap
drupal_bootstrap($phase=NULL, $new_phase=TRUE)
Definition: bootstrap.inc:2192
statistics_menu
statistics_menu()
Definition: statistics.module:152
statistics_update_index
statistics_update_index()
Definition: statistics.module:463
DRUPAL_BOOTSTRAP_SESSION
const DRUPAL_BOOTSTRAP_SESSION
Definition: bootstrap.inc:142
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
drupal_get_path_alias
drupal_get_path_alias($path=NULL, $path_language=NULL)
Definition: path.inc:235
format_plural
format_plural($count, $singular, $plural, array $args=array(), array $options=array())
Definition: common.inc:1805
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
statistics_block_view
statistics_block_view($delta= '')
Definition: statistics.module:363
statistics_get
statistics_get($nid)
Definition: statistics.module:317
DRUPAL_BOOTSTRAP_VARIABLES
const DRUPAL_BOOTSTRAP_VARIABLES
Definition: bootstrap.inc:137
statistics_user_delete
statistics_user_delete($account)
Definition: statistics.module:239
statistics_exit
statistics_exit()
Definition: statistics.module:50
$output
$output
Definition: authorize.php:93
statistics_cron
statistics_cron()
Definition: statistics.module:248
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
timer_read
timer_read($name)
Definition: bootstrap.inc:476
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
DRUPAL_NO_CACHE
const DRUPAL_NO_CACHE
Definition: common.inc:127
_statistics_format_item
_statistics_format_item($title, $path)
Definition: statistics.module:421
drupal_get_title
drupal_get_title()
Definition: bootstrap.inc:1848
statistics_title_list
statistics_title_list($dbfield, $dbrows)
Definition: statistics.module:283
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
statistics_block_configure
statistics_block_configure($delta= '')
Definition: statistics.module:342
statistics_ranking
statistics_ranking()
Definition: statistics.module:441
statistics_node_view
statistics_node_view($node, $view_mode)
Definition: statistics.module:117
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
statistics_help
statistics_help($path, $arg)
Definition: statistics.module:11
statistics_user_cancel
statistics_user_cancel($edit, $account, $method)
Definition: statistics.module:225
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
truncate_utf8
truncate_utf8($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
Definition: unicode.inc:316
statistics_block_save
statistics_block_save($delta= '', $edit=array())
Definition: statistics.module:354
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
$links
print $links
Definition: poll-results--block.tpl.php:28
node_title_list
node_title_list($result, $title=NULL)
Definition: node.module:288
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/profile/profile.pages.inc Source File

  • modules
  • profile
profile.pages.inc
Go to the documentation of this file.
1 <?php
2
11 function profile_browse() {
12 // Ensure that the path is converted to 3 levels always.
13 list(, $name, $value) = array_pad(explode('/', $_GET['q'], 3), 3, '');
14
15 $field = db_query("SELECT DISTINCT(fid), type, title, page, visibility FROM {profile_field} WHERE name = :name", array(':name' => $name))->fetchObject();
16
17 if ($name && $field->fid) {
18 // Only allow browsing of fields that have a page title set.
19 if (empty($field->page)) {
20 return MENU_NOT_FOUND;
21 }
22 // Do not allow browsing of private and hidden fields by non-admins.
23 if (!user_access('administer users') && ($field->visibility == PROFILE_PRIVATE || $field->visibility == PROFILE_HIDDEN)) {
24 return MENU_ACCESS_DENIED;
25 }
26
27 // Compile a list of fields to show.
28 $fields = db_query('SELECT name, title, type, weight, page, visibility FROM {profile_field} WHERE fid <> :fid AND visibility = :visibility ORDER BY weight', array(
29 ':fid' => $field->fid,
30 ':visibility' => PROFILE_PUBLIC_LISTINGS,
31 ))->fetchAll();
32
33 $query = db_select('users', 'u')->extend('PagerDefault');
34 $query->join('profile_value', 'v', 'u.uid = v.uid');
35 $query
36 ->fields('u', array('uid', 'access'))
37 ->condition('v.fid', $field->fid)
38 ->condition('u.status', 0, '<>')
39 ->orderBy('u.access', 'DESC');
40
41 // Determine what query to use:
42 $arguments = array($field->fid);
43 switch ($field->type) {
44 case 'checkbox':
45 $query->condition('v.value', 1);
46 break;
47 case 'textfield':
48 case 'selection':
49 $query->condition('v.value', $value);
50 break;
51 case 'list':
52 $query->condition('v.value', '%' . db_like($value) . '%', 'LIKE');
53 break;
54 default:
55 return MENU_NOT_FOUND;
56 }
57
58 $uids = $query
59 ->limit(20)
60 ->execute()
61 ->fetchCol();
62
63 // Load the users.
64 $users = user_load_multiple($uids);
65
66 $content = '';
67 foreach ($users as $account) {
68 $profile = _profile_update_user_fields($fields, $account);
69 $content .= theme('profile_listing', array('account' => $account, 'fields' => $profile));
70 }
71 $output = theme('profile_wrapper', array('content' => $content));
72 $output .= theme('pager');
73
74 if ($field->type == 'selection' || $field->type == 'list' || $field->type == 'textfield') {
75 $title = strtr(check_plain($field->page), array('%value' => drupal_placeholder($value)));
76 }
77 else {
78 $title = check_plain($field->page);
79 }
80
81 drupal_set_title($title, PASS_THROUGH);
82 return $output;
83 }
84 elseif ($name && !$field->fid) {
85 return MENU_NOT_FOUND;
86 }
87 else {
88 // Compile a list of fields to show.
89 $fields = db_query('SELECT name, title, type, weight, page, visibility FROM {profile_field} WHERE visibility = :visibility ORDER BY category, weight', array(':visibility' => PROFILE_PUBLIC_LISTINGS))->fetchAll();
90
91 // Extract the affected users:
92 $query = db_select('users', 'u')->extend('PagerDefault');
93 $uids = $query
94 ->fields('u', array('uid', 'access'))
95 ->condition('u.uid', 0, '>')
96 ->condition('u.status', 0, '>')
97 ->orderBy('u.access', 'DESC')
98 ->limit(20)
99 ->execute()
100 ->fetchCol();
101 $users = user_load_multiple($uids);
102 $content = '';
103 foreach ($users as $account) {
104 $profile = _profile_update_user_fields($fields, $account);
105 $content .= theme('profile_listing', array('account' => $account, 'fields' => $profile));
106 }
107 $output = theme('profile_wrapper', array('content' => $content));
108 $output .= theme('pager');
109
110 drupal_set_title(t('User list'));
111 return $output;
112 }
113 }
114
118 function profile_autocomplete($field, $string) {
119 $matches = array();
120 $autocomplete_field = (bool) db_query_range("SELECT 1 FROM {profile_field} WHERE fid = :fid AND autocomplete = 1", 0, 1, array(':fid' => $field))->fetchField();
121 if ($autocomplete_field) {
122 $values = db_select('profile_value')
123 ->fields('profile_value', array('value'))
124 ->condition('fid', $field)
125 ->condition('value', db_like($string) . '%', 'LIKE')
126 ->groupBy('value')
127 ->orderBy('value')
128 ->range(0, 10)
129 ->execute()->fetchCol();
130 foreach ($values as $value) {
131 $matches[$value] = check_plain($value);
132 }
133 }
134
135 drupal_json_output($matches);
136 }
PROFILE_PUBLIC_LISTINGS
const PROFILE_PUBLIC_LISTINGS
Definition: profile.module:21
MENU_ACCESS_DENIED
const MENU_ACCESS_DENIED
Definition: menu.inc:239
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
$name
print $name
Definition: profile-listing.tpl.php:43
drupal_json_output
drupal_json_output($var=NULL)
Definition: common.inc:5041
_profile_update_user_fields
_profile_update_user_fields($fields, $account)
Definition: profile.module:472
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
MENU_NOT_FOUND
const MENU_NOT_FOUND
Definition: menu.inc:234
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
$value
print $value
Definition: user-profile-item.tpl.php:26
$output
$output
Definition: authorize.php:93
user_load_multiple
user_load_multiple($uids=array(), $conditions=array(), $reset=FALSE)
Definition: user.module:290
db_like
db_like($string)
Definition: database.inc:2610
user_access
user_access($string, $account=NULL)
Definition: user.module:794
PROFILE_HIDDEN
const PROFILE_HIDDEN
Definition: profile.module:26
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
drupal_placeholder
drupal_placeholder($text)
Definition: bootstrap.inc:3396
profile_autocomplete
profile_autocomplete($field, $string)
Definition: profile.pages.inc:118
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
profile_browse
profile_browse()
Definition: profile.pages.inc:11
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
PROFILE_PRIVATE
const PROFILE_PRIVATE
Definition: profile.module:11
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/file/file.field.inc Source File

  • modules
  • file
file.field.inc
Go to the documentation of this file.
1 <?php
2
11 function file_field_info() {
12 return array(
13 'file' => array(
14 'label' => t('File'),
15 'description' => t('This field stores the ID of a file as an integer value.'),
16 'settings' => array(
17 'display_field' => 0,
18 'display_default' => 0,
19 'uri_scheme' => variable_get('file_default_scheme', 'public'),
20 ),
21 'instance_settings' => array(
22 'file_extensions' => 'txt',
23 'file_directory' => '',
24 'max_filesize' => '',
25 'description_field' => 0,
26 ),
27 'default_widget' => 'file_generic',
28 'default_formatter' => 'file_default',
29 ),
30 );
31 }
32
36 function file_field_settings_form($field, $instance, $has_data) {
37 $defaults = field_info_field_settings($field['type']);
38 $settings = array_merge($defaults, $field['settings']);
39
40 $form['#attached']['js'][] = drupal_get_path('module', 'file') . '/file.js';
41
42 $form['display_field'] = array(
43 '#type' => 'checkbox',
44 '#title' => t('Enable <em>Display</em> field'),
45 '#default_value' => $settings['display_field'],
46 '#description' => t('The display option allows users to choose if a file should be shown when viewing the content.'),
47 );
48 $form['display_default'] = array(
49 '#type' => 'checkbox',
50 '#title' => t('Files displayed by default'),
51 '#default_value' => $settings['display_default'],
52 '#description' => t('This setting only has an effect if the display option is enabled.'),
53 );
54
55 $scheme_options = array();
56 foreach (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $stream_wrapper) {
57 $scheme_options[$scheme] = $stream_wrapper['name'];
58 }
59 $form['uri_scheme'] = array(
60 '#type' => 'radios',
61 '#title' => t('Upload destination'),
62 '#options' => $scheme_options,
63 '#default_value' => $settings['uri_scheme'],
64 '#description' => t('Select where the final files should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'),
65 '#disabled' => $has_data,
66 );
67
68 return $form;
69 }
70
74 function file_field_instance_settings_form($field, $instance) {
75 $settings = $instance['settings'];
76
77 $form['file_directory'] = array(
78 '#type' => 'textfield',
79 '#title' => t('File directory'),
80 '#default_value' => $settings['file_directory'],
81 '#description' => t('Optional subdirectory within the upload destination where files will be stored. Do not include preceding or trailing slashes.'),
82 '#element_validate' => array('_file_generic_settings_file_directory_validate'),
83 '#weight' => 3,
84 );
85
86 // Make the extension list a little more human-friendly by comma-separation.
87 $extensions = str_replace(' ', ', ', $settings['file_extensions']);
88 $form['file_extensions'] = array(
89 '#type' => 'textfield',
90 '#title' => t('Allowed file extensions'),
91 '#default_value' => $extensions,
92 '#description' => t('Separate extensions with a space or comma and do not include the leading dot.'),
93 '#element_validate' => array('_file_generic_settings_extensions'),
94 '#weight' => 1,
95 // By making this field required, we prevent a potential security issue
96 // that would allow files of any type to be uploaded.
97 '#required' => TRUE,
98 );
99
100 $form['max_filesize'] = array(
101 '#type' => 'textfield',
102 '#title' => t('Maximum upload size'),
103 '#default_value' => $settings['max_filesize'],
104 '#description' => t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current limit <strong>%limit</strong>).', array('%limit' => format_size(file_upload_max_size()))),
105 '#size' => 10,
106 '#element_validate' => array('_file_generic_settings_max_filesize'),
107 '#weight' => 5,
108 );
109
110 $form['description_field'] = array(
111 '#type' => 'checkbox',
112 '#title' => t('Enable <em>Description</em> field'),
113 '#default_value' => isset($settings['description_field']) ? $settings['description_field'] : '',
114 '#description' => t('The description field allows users to enter a description about the uploaded file.'),
115 '#parents' => array('instance', 'settings', 'description_field'),
116 '#weight' => 11,
117 );
118
119 return $form;
120 }
121
127 function _file_generic_settings_max_filesize($element, &$form_state) {
128 if (!empty($element['#value']) && !is_numeric(parse_size($element['#value']))) {
129 form_error($element, t('The "!name" option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).', array('!name' => t($element['title']))));
130 }
131 }
132
140 function _file_generic_settings_extensions($element, &$form_state) {
141 if (!empty($element['#value'])) {
142 $extensions = preg_replace('/([, ]+\.?)/', ' ', trim(strtolower($element['#value'])));
143 $extensions = array_filter(explode(' ', $extensions));
144 $extensions = implode(' ', array_unique($extensions));
145 if (!preg_match('/^([a-z0-9]+([.][a-z0-9])* ?)+$/', $extensions)) {
146 form_error($element, t('The list of allowed extensions is not valid, be sure to exclude leading dots and to separate extensions with a comma or space.'));
147 }
148 else {
149 form_set_value($element, $extensions, $form_state);
150 }
151 }
152 }
153
160 function _file_generic_settings_file_directory_validate($element, &$form_state) {
161 // Strip slashes from the beginning and end of $widget['file_directory'].
162 $value = trim($element['#value'], '\\/');
163 form_set_value($element, $value, $form_state);
164 }
165
169 function file_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
170
171 $fids = array();
172 foreach ($entities as $id => $entity) {
173 // Load the files from the files table.
174 foreach ($items[$id] as $delta => $item) {
175 if (!empty($item['fid'])) {
176 $fids[] = $item['fid'];
177 }
178 }
179 }
180 $files = file_load_multiple($fids);
181
182 foreach ($entities as $id => $entity) {
183 foreach ($items[$id] as $delta => $item) {
184 // If the file does not exist, mark the entire item as empty.
185 if (empty($item['fid']) || !isset($files[$item['fid']])) {
186 $items[$id][$delta] = NULL;
187 }
188 else {
189 $items[$id][$delta] = array_merge((array) $files[$item['fid']], $item);
190 }
191 }
192 }
193 }
194
198 function file_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) {
199 // Remove files specified to not be displayed.
200 foreach ($entities as $id => $entity) {
201 foreach ($items[$id] as $delta => $item) {
202 if (!file_field_displayed($item, $field)) {
203 unset($items[$id][$delta]);
204 }
205 }
206 // Ensure consecutive deltas.
207 $items[$id] = array_values($items[$id]);
208 }
209 }
210
214 function file_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
215 // Make sure that each file which will be saved with this object has a
216 // permanent status, so that it will not be removed when temporary files are
217 // cleaned up.
218 foreach ($items as $delta => $item) {
219 if (empty($item['fid'])) {
220 unset($items[$delta]);
221 continue;
222 }
223 $file = file_load($item['fid']);
224 if (empty($file)) {
225 unset($items[$delta]);
226 continue;
227 }
228 if (!$file->status) {
229 $file->status = FILE_STATUS_PERMANENT;
230 file_save($file);
231 }
232 }
233 }
234
238 function file_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
239 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
240
241 // Add a new usage of each uploaded file.
242 foreach ($items as $item) {
243 $file = (object) $item;
244 file_usage_add($file, 'file', $entity_type, $id);
245 }
246 }
247
253 function file_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
254 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
255
256 // On new revisions, all files are considered to be a new usage and no
257 // deletion of previous file usages are necessary.
258 if (!empty($entity->revision)) {
259 foreach ($items as $item) {
260 $file = (object) $item;
261 file_usage_add($file, 'file', $entity_type, $id);
262 }
263 return;
264 }
265
266 // Build a display of the current FIDs.
267 $current_fids = array();
268 foreach ($items as $item) {
269 $current_fids[] = $item['fid'];
270 }
271
272 // Compare the original field values with the ones that are being saved. Use
273 // $entity->original to check this when possible, but if it isn't available,
274 // create a bare-bones entity and load its previous values instead.
275 if (isset($entity->original)) {
276 $original = $entity->original;
277 }
278 else {
279 $original = entity_create_stub_entity($entity_type, array($id, $vid, $bundle));
280 field_attach_load($entity_type, array($id => $original), FIELD_LOAD_CURRENT, array('field_id' => $field['id']));
281 }
282 $original_fids = array();
283 if (!empty($original->{$field['field_name']}[$langcode])) {
284 foreach ($original->{$field['field_name']}[$langcode] as $original_item) {
285 $original_fids[] = $original_item['fid'];
286 if (isset($original_item['fid']) && !in_array($original_item['fid'], $current_fids)) {
287 // Decrement the file usage count by 1 and delete the file if possible.
288 file_field_delete_file($original_item, $field, $entity_type, $id);
289 }
290 }
291 }
292
293 // Add new usage entries for newly added files.
294 foreach ($items as $item) {
295 if (!in_array($item['fid'], $original_fids)) {
296 $file = (object) $item;
297 file_usage_add($file, 'file', $entity_type, $id);
298 }
299 }
300 }
301
305 function file_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
306 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
307
308 // Delete all file usages within this entity.
309 foreach ($items as $delta => $item) {
310 file_field_delete_file($item, $field, $entity_type, $id, 0);
311 }
312 }
313
317 function file_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) {
318 list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
319 foreach ($items as $delta => $item) {
320 // Decrement the file usage count by 1 and delete the file if possible.
321 if (file_field_delete_file($item, $field, $entity_type, $id)) {
322 $items[$delta] = NULL;
323 }
324 }
325 }
326
350 function file_field_delete_file($item, $field, $entity_type, $id, $count = 1) {
351 // To prevent the file field from deleting files it doesn't know about, check
352 // the file reference count. Temporary files can be deleted because they
353 // are not yet associated with any content at all.
354 $file = (object) $item;
355 $file_usage = file_usage_list($file);
356 if ($file->status == 0 || !empty($file_usage['file'])) {
357 file_usage_delete($file, 'file', $entity_type, $id, $count);
358 return file_delete($file);
359 }
360
361 // Even if the file is not deleted, return TRUE to indicate the file field
362 // record can be removed from the field database tables.
363 return TRUE;
364 }
365
369 function file_field_is_empty($item, $field) {
370 return empty($item['fid']);
371 }
372
384 function file_field_displayed($item, $field) {
385 if (!empty($field['settings']['display_field'])) {
386 return (bool) $item['display'];
387 }
388 return TRUE;
389 }
390
394 function file_field_formatter_info() {
395 return array(
396 'file_default' => array(
397 'label' => t('Generic file'),
398 'field types' => array('file'),
399 ),
400 'file_table' => array(
401 'label' => t('Table of files'),
402 'field types' => array('file'),
403 ),
404 'file_url_plain' => array(
405 'label' => t('URL to file'),
406 'field types' => array('file'),
407 ),
408 );
409 }
410
414 function file_field_widget_info() {
415 return array(
416 'file_generic' => array(
417 'label' => t('File'),
418 'field types' => array('file'),
419 'settings' => array(
420 'progress_indicator' => 'throbber',
421 ),
422 'behaviors' => array(
423 'multiple values' => FIELD_BEHAVIOR_CUSTOM,
424 'default value' => FIELD_BEHAVIOR_NONE,
425 ),
426 ),
427 );
428 }
429
433 function file_field_widget_settings_form($field, $instance) {
434 $widget = $instance['widget'];
435 $settings = $widget['settings'];
436
437 $form['progress_indicator'] = array(
438 '#type' => 'radios',
439 '#title' => t('Progress indicator'),
440 '#options' => array(
441 'throbber' => t('Throbber'),
442 'bar' => t('Bar with progress meter'),
443 ),
444 '#default_value' => $settings['progress_indicator'],
445 '#description' => t('The throbber display does not show the status of uploads but takes up less space. The progress bar is helpful for monitoring progress on large uploads.'),
446 '#weight' => 16,
447 '#access' => file_progress_implementation(),
448 );
449
450 return $form;
451 }
452
456 function file_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
457
458 $defaults = array(
459 'fid' => 0,
460 'display' => !empty($field['settings']['display_default']),
461 'description' => '',
462 );
463
464 // Load the items for form rebuilds from the field state as they might not be
465 // in $form_state['values'] because of validation limitations. Also, they are
466 // only passed in as $items when editing existing entities.
467 $field_state = field_form_get_state($element['#field_parents'], $field['field_name'], $langcode, $form_state);
468 if (isset($field_state['items'])) {
469 $items = $field_state['items'];
470 }
471
472 // Essentially we use the managed_file type, extended with some enhancements.
473 $element_info = element_info('managed_file');
474 $element += array(
475 '#type' => 'managed_file',
476 '#upload_location' => file_field_widget_uri($field, $instance),
477 '#upload_validators' => file_field_widget_upload_validators($field, $instance),
478 '#value_callback' => 'file_field_widget_value',
479 '#process' => array_merge($element_info['#process'], array('file_field_widget_process')),
480 '#progress_indicator' => $instance['widget']['settings']['progress_indicator'],
481 // Allows this field to return an array instead of a single value.
482 '#extended' => TRUE,
483 );
484
485 if ($field['cardinality'] == 1) {
486 // Set the default value.
487 $element['#default_value'] = !empty($items) ? $items[0] : $defaults;
488 // If there's only one field, return it as delta 0.
489 if (empty($element['#default_value']['fid'])) {
490 $element['#description'] = theme('file_upload_help', array('description' => $element['#description'], 'upload_validators' => $element['#upload_validators']));
491 }
492 $elements = array($element);
493 }
494 else {
495 // If there are multiple values, add an element for each existing one.
496 foreach ($items as $item) {
497 $elements[$delta] = $element;
498 $elements[$delta]['#default_value'] = $item;
499 $elements[$delta]['#weight'] = $delta;
500 $delta++;
501 }
502 // And then add one more empty row for new uploads except when this is a
503 // programmed form as it is not necessary.
504 if (($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta < $field['cardinality']) && empty($form_state['programmed'])) {
505 $elements[$delta] = $element;
506 $elements[$delta]['#default_value'] = $defaults;
507 $elements[$delta]['#weight'] = $delta;
508 $elements[$delta]['#required'] = ($element['#required'] && $delta == 0);
509 }
510 // The group of elements all-together need some extra functionality
511 // after building up the full list (like draggable table rows).
512 $elements['#file_upload_delta'] = $delta;
513 $elements['#theme'] = 'file_widget_multiple';
514 $elements['#theme_wrappers'] = array('fieldset');
515 $elements['#process'] = array('file_field_widget_process_multiple');
516 $elements['#title'] = $element['#title'];
517 $elements['#description'] = $element['#description'];
518 $elements['#field_name'] = $element['#field_name'];
519 $elements['#language'] = $element['#language'];
520 $elements['#display_field'] = $field['settings']['display_field'];
521
522 // Add some properties that will eventually be added to the file upload
523 // field. These are added here so that they may be referenced easily through
524 // a hook_form_alter().
525 $elements['#file_upload_title'] = t('Add a new file');
526 $elements['#file_upload_description'] = theme('file_upload_help', array('description' => '', 'upload_validators' => $elements[0]['#upload_validators']));
527 }
528
529 return $elements;
530 }
531
542 function file_field_widget_upload_validators($field, $instance) {
543 // Cap the upload size according to the PHP limit.
544 $max_filesize = parse_size(file_upload_max_size());
545 if (!empty($instance['settings']['max_filesize']) && parse_size($instance['settings']['max_filesize']) < $max_filesize) {
546 $max_filesize = parse_size($instance['settings']['max_filesize']);
547 }
548
549 $validators = array();
550
551 // There is always a file size limit due to the PHP server limit.
552 $validators['file_validate_size'] = array($max_filesize);
553
554 // Add the extension check if necessary.
555 if (!empty($instance['settings']['file_extensions'])) {
556 $validators['file_validate_extensions'] = array($instance['settings']['file_extensions']);
557 }
558
559 return $validators;
560 }
561
577 function file_field_widget_uri($field, $instance, $data = array()) {
578 $destination = trim($instance['settings']['file_directory'], '/');
579
580 // Replace tokens.
581 $destination = token_replace($destination, $data);
582
583 return $field['settings']['uri_scheme'] . '://' . $destination;
584 }
585
589 function file_field_widget_value($element, $input = FALSE, $form_state) {
590 if ($input) {
591 // Checkboxes lose their value when empty.
592 // If the display field is present make sure its unchecked value is saved.
593 $field = field_widget_field($element, $form_state);
594 if (empty($input['display'])) {
595 $input['display'] = $field['settings']['display_field'] ? 0 : 1;
596 }
597 }
598
599 // We depend on the managed file element to handle uploads.
600 $return = file_managed_file_value($element, $input, $form_state);
601
602 // Ensure that all the required properties are returned even if empty.
603 $return += array(
604 'fid' => 0,
605 'display' => 1,
606 'description' => '',
607 );
608
609 return $return;
610 }
611
617 function file_field_widget_process($element, &$form_state, $form) {
618 $item = $element['#value'];
619 $item['fid'] = $element['fid']['#value'];
620
621 $field = field_widget_field($element, $form_state);
622 $instance = field_widget_instance($element, $form_state);
623 $settings = $instance['widget']['settings'];
624
625 $element['#theme'] = 'file_widget';
626
627 // Add the display field if enabled.
628 if (!empty($field['settings']['display_field']) && $item['fid']) {
629 $element['display'] = array(
630 '#type' => empty($item['fid']) ? 'hidden' : 'checkbox',
631 '#title' => t('Include file in display'),
632 '#value' => isset($item['display']) ? $item['display'] : $field['settings']['display_default'],
633 '#attributes' => array('class' => array('file-display')),
634 );
635 }
636 else {
637 $element['display'] = array(
638 '#type' => 'hidden',
639 '#value' => '1',
640 );
641 }
642
643 // Add the description field if enabled.
644 if (!empty($instance['settings']['description_field']) && $item['fid']) {
645 $element['description'] = array(
646 '#type' => variable_get('file_description_type', 'textfield'),
647 '#title' => t('Description'),
648 '#value' => isset($item['description']) ? $item['description'] : '',
649 '#maxlength' => variable_get('file_description_length', 128),
650 '#description' => t('The description may be used as the label of the link to the file.'),
651 );
652 }
653
654 // Adjust the Ajax settings so that on upload and remove of any individual
655 // file, the entire group of file fields is updated together.
656 if ($field['cardinality'] != 1) {
657 $parents = array_slice($element['#array_parents'], 0, -1);
658 $new_path = 'file/ajax/' . implode('/', $parents) . '/' . $form['form_build_id']['#value'];
659 $field_element = drupal_array_get_nested_value($form, $parents);
660 $new_wrapper = $field_element['#id'] . '-ajax-wrapper';
661 foreach (element_children($element) as $key) {
662 if (isset($element[$key]['#ajax'])) {
663 $element[$key]['#ajax']['path'] = $new_path;
664 $element[$key]['#ajax']['wrapper'] = $new_wrapper;
665 }
666 }
667 unset($element['#prefix'], $element['#suffix']);
668 }
669
670 // Add another submit handler to the upload and remove buttons, to implement
671 // functionality needed by the field widget. This submit handler, along with
672 // the rebuild logic in file_field_widget_form() requires the entire field,
673 // not just the individual item, to be valid.
674 foreach (array('upload_button', 'remove_button') as $key) {
675 $element[$key]['#submit'][] = 'file_field_widget_submit';
676 $element[$key]['#limit_validation_errors'] = array(array_slice($element['#parents'], 0, -1));
677 }
678
679 return $element;
680 }
681
688 function file_field_widget_process_multiple($element, &$form_state, $form) {
689 $element_children = element_children($element, TRUE);
690 $count = count($element_children);
691
692 foreach ($element_children as $delta => $key) {
693 if ($key != $element['#file_upload_delta']) {
694 $description = _file_field_get_description_from_element($element[$key]);
695 $element[$key]['_weight'] = array(
696 '#type' => 'weight',
697 '#title' => $description ? t('Weight for @title', array('@title' => $description)) : t('Weight for new file'),
698 '#title_display' => 'invisible',
699 '#delta' => $count,
700 '#default_value' => $delta,
701 );
702 }
703 else {
704 // The title needs to be assigned to the upload field so that validation
705 // errors include the correct widget label.
706 $element[$key]['#title'] = $element['#title'];
707 $element[$key]['_weight'] = array(
708 '#type' => 'hidden',
709 '#default_value' => $delta,
710 );
711 }
712 }
713
714 // Add a new wrapper around all the elements for Ajax replacement.
715 $element['#prefix'] = '<div id="' . $element['#id'] . '-ajax-wrapper">';
716 $element['#suffix'] = '</div>';
717
718 return $element;
719 }
720
732 function _file_field_get_description_from_element($element) {
733 // Use the actual file description, if it's available.
734 if (!empty($element['#default_value']['description'])) {
735 return $element['#default_value']['description'];
736 }
737 // Otherwise, fall back to the filename.
738 if (!empty($element['#default_value']['filename'])) {
739 return $element['#default_value']['filename'];
740 }
741 // This is probably a newly uploaded file; no description is available.
742 return FALSE;
743 }
744
754 function file_field_widget_submit($form, &$form_state) {
755 // During the form rebuild, file_field_widget_form() will create field item
756 // widget elements using re-indexed deltas, so clear out $form_state['input']
757 // to avoid a mismatch between old and new deltas. The rebuilt elements will
758 // have #default_value set appropriately for the current state of the field,
759 // so nothing is lost in doing this.
760 $parents = array_slice($form_state['triggering_element']['#parents'], 0, -2);
761 drupal_array_set_nested_value($form_state['input'], $parents, NULL);
762
763 $button = $form_state['triggering_element'];
764
765 // Go one level up in the form, to the widgets container.
766 $element = drupal_array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1));
767 $field_name = $element['#field_name'];
768 $langcode = $element['#language'];
769 $parents = $element['#field_parents'];
770
771 $submitted_values = drupal_array_get_nested_value($form_state['values'], array_slice($button['#array_parents'], 0, -2));
772 foreach ($submitted_values as $delta => $submitted_value) {
773 if (!$submitted_value['fid']) {
774 unset($submitted_values[$delta]);
775 }
776 }
777
778 // Re-index deltas after removing empty items.
779 $submitted_values = array_values($submitted_values);
780
781 // Update form_state values.
782 drupal_array_set_nested_value($form_state['values'], array_slice($button['#array_parents'], 0, -2), $submitted_values);
783
784 // Update items.
785 $field_state = field_form_get_state($parents, $field_name, $langcode, $form_state);
786 $field_state['items'] = $submitted_values;
787 field_form_set_state($parents, $field_name, $langcode, $form_state, $field_state);
788 }
789
799 function theme_file_widget($variables) {
800 $element = $variables['element'];
801 $output = '';
802
803 // The "form-managed-file" class is required for proper Ajax functionality.
804 $output .= '<div class="file-widget form-managed-file clearfix">';
805 if ($element['fid']['#value'] != 0) {
806 // Add the file size after the file name.
807 $element['filename']['#markup'] .= ' <span class="file-size">(' . format_size($element['#file']->filesize) . ')</span> ';
808 }
809 $output .= drupal_render_children($element);
810 $output .= '</div>';
811
812 return $output;
813 }
814
824 function theme_file_widget_multiple($variables) {
825 $element = $variables['element'];
826
827 // Special ID and classes for draggable tables.
828 $weight_class = $element['#id'] . '-weight';
829 $table_id = $element['#id'] . '-table';
830
831 // Build up a table of applicable fields.
832 $headers = array();
833 $headers[] = t('File information');
834 if ($element['#display_field']) {
835 $headers[] = array(
836 'data' => t('Display'),
837 'class' => array('checkbox'),
838 );
839 }
840 $headers[] = t('Weight');
841 $headers[] = t('Operations');
842
843 // Get our list of widgets in order (needed when the form comes back after
844 // preview or failed validation).
845 $widgets = array();
846 foreach (element_children($element) as $key) {
847 $widgets[] = &$element[$key];
848 }
849 usort($widgets, '_field_sort_items_value_helper');
850
851 $rows = array();
852 foreach ($widgets as $key => &$widget) {
853 // Save the uploading row for last.
854 if ($widget['#file'] == FALSE) {
855 $widget['#title'] = $element['#file_upload_title'];
856 $widget['#description'] = $element['#file_upload_description'];
857 continue;
858 }
859
860 // Delay rendering of the buttons, so that they can be rendered later in the
861 // "operations" column.
862 $operations_elements = array();
863 foreach (element_children($widget) as $sub_key) {
864 if (isset($widget[$sub_key]['#type']) && $widget[$sub_key]['#type'] == 'submit') {
865 hide($widget[$sub_key]);
866 $operations_elements[] = &$widget[$sub_key];
867 }
868 }
869
870 // Delay rendering of the "Display" option and the weight selector, so that
871 // each can be rendered later in its own column.
872 if ($element['#display_field']) {
873 hide($widget['display']);
874 }
875 hide($widget['_weight']);
876
877 // Render everything else together in a column, without the normal wrappers.
878 $widget['#theme_wrappers'] = array();
879 $information = drupal_render($widget);
880
881 // Render the previously hidden elements, using render() instead of
882 // drupal_render(), to undo the earlier hide().
883 $operations = '';
884 foreach ($operations_elements as $operation_element) {
885 $operations .= render($operation_element);
886 }
887 $display = '';
888 if ($element['#display_field']) {
889 unset($widget['display']['#title']);
890 $display = array(
891 'data' => render($widget['display']),
892 'class' => array('checkbox'),
893 );
894 }
895 $widget['_weight']['#attributes']['class'] = array($weight_class);
896 $weight = render($widget['_weight']);
897
898 // Arrange the row with all of the rendered columns.
899 $row = array();
900 $row[] = $information;
901 if ($element['#display_field']) {
902 $row[] = $display;
903 }
904 $row[] = $weight;
905 $row[] = $operations;
906 $rows[] = array(
907 'data' => $row,
908 'class' => isset($widget['#attributes']['class']) ? array_merge($widget['#attributes']['class'], array('draggable')) : array('draggable'),
909 );
910 }
911
912 drupal_add_tabledrag($table_id, 'order', 'sibling', $weight_class);
913
914 $output = '';
915 $output = empty($rows) ? '' : theme('table', array('header' => $headers, 'rows' => $rows, 'attributes' => array('id' => $table_id)));
916 $output .= drupal_render_children($element);
917 return $output;
918 }
919
920
933 function theme_file_upload_help($variables) {
934 $description = $variables['description'];
935 $upload_validators = $variables['upload_validators'];
936
937 $descriptions = array();
938
939 if (strlen($description)) {
940 $descriptions[] = $description;
941 }
942 if (isset($upload_validators['file_validate_size'])) {
943 $descriptions[] = t('Files must be less than !size.', array('!size' => '<strong>' . format_size($upload_validators['file_validate_size'][0]) . '</strong>'));
944 }
945 if (isset($upload_validators['file_validate_extensions'])) {
946 $descriptions[] = t('Allowed file types: !extensions.', array('!extensions' => '<strong>' . check_plain($upload_validators['file_validate_extensions'][0]) . '</strong>'));
947 }
948 if (isset($upload_validators['file_validate_image_resolution'])) {
949 $max = $upload_validators['file_validate_image_resolution'][0];
950 $min = $upload_validators['file_validate_image_resolution'][1];
951 if ($min && $max && $min == $max) {
952 $descriptions[] = t('Images must be exactly !size pixels.', array('!size' => '<strong>' . $max . '</strong>'));
953 }
954 elseif ($min && $max) {
955 $descriptions[] = t('Images must be between !min and !max pixels.', array('!min' => '<strong>' . $min . '</strong>', '!max' => '<strong>' . $max . '</strong>'));
956 }
957 elseif ($min) {
958 $descriptions[] = t('Images must be larger than !min pixels.', array('!min' => '<strong>' . $min . '</strong>'));
959 }
960 elseif ($max) {
961 $descriptions[] = t('Images must be smaller than !max pixels.', array('!max' => '<strong>' . $max . '</strong>'));
962 }
963 }
964
965 return implode('<br />', $descriptions);
966 }
967
971 function file_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
972 $element = array();
973
974 switch ($display['type']) {
975 case 'file_default':
976 foreach ($items as $delta => $item) {
977 $element[$delta] = array(
978 '#theme' => 'file_link',
979 '#file' => (object) $item,
980 );
981 }
982 break;
983
984 case 'file_url_plain':
985 foreach ($items as $delta => $item) {
986 $element[$delta] = array('#markup' => empty($item['uri']) ? '' : file_create_url($item['uri']));
987 }
988 break;
989
990 case 'file_table':
991 if (!empty($items)) {
992 // Display all values in a single element..
993 $element[0] = array(
994 '#theme' => 'file_formatter_table',
995 '#items' => $items,
996 );
997 }
998 break;
999 }
1000
1001 return $element;
1002 }
1003
1013 function theme_file_formatter_table($variables) {
1014 $header = array(t('Attachment'), t('Size'));
1015 $rows = array();
1016 foreach ($variables['items'] as $delta => $item) {
1017 $rows[] = array(
1018 theme('file_link', array('file' => (object) $item)),
1019 format_size($item['filesize']),
1020 );
1021 }
1022
1023 return empty($rows) ? '' : theme('table', array('header' => $header, 'rows' => $rows));
1024 }
file_field_widget_settings_form
file_field_widget_settings_form($field, $instance)
Definition: file.field.inc:433
file_field_widget_info
file_field_widget_info()
Definition: file.field.inc:414
file_field_settings_form
file_field_settings_form($field, $instance, $has_data)
Definition: file.field.inc:36
file_upload_max_size
file_upload_max_size()
Definition: file.inc:2108
file_field_info
file_field_info()
Definition: file.field.inc:11
file_managed_file_value
file_managed_file_value(&$element, $input=FALSE, $form_state=NULL)
Definition: file.module:480
file_usage_add
file_usage_add(stdClass $file, $module, $type, $id, $count=1)
Definition: file.inc:682
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
file_field_insert
file_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: file.field.inc:238
file_field_presave
file_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: file.field.inc:214
drupal_array_get_nested_value
& drupal_array_get_nested_value(array &$array, array $parents, &$key_exists=NULL)
Definition: common.inc:6666
file_create_url
file_create_url($uri)
Definition: file.inc:372
file_field_update
file_field_update($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: file.field.inc:253
_file_field_get_description_from_element
_file_field_get_description_from_element($element)
Definition: file.field.inc:732
file_field_delete_file
file_field_delete_file($item, $field, $entity_type, $id, $count=1)
Definition: file.field.inc:350
$header
print $header
Definition: forum-topic-list.tpl.php:42
file_field_widget_upload_validators
file_field_widget_upload_validators($field, $instance)
Definition: file.field.inc:542
file_field_load
file_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age)
Definition: file.field.inc:169
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
file_progress_implementation
file_progress_implementation()
Definition: file.module:330
FILE_STATUS_PERMANENT
const FILE_STATUS_PERMANENT
Definition: file.inc:70
form_error
form_error(&$element, $message= '')
Definition: form.inc:1662
element_info
element_info($type)
Definition: common.inc:6306
_file_generic_settings_file_directory_validate
_file_generic_settings_file_directory_validate($element, &$form_state)
Definition: file.field.inc:160
file_field_displayed
file_field_displayed($item, $field)
Definition: file.field.inc:384
file_field_widget_process
file_field_widget_process($element, &$form_state, $form)
Definition: file.field.inc:617
file_field_widget_process_multiple
file_field_widget_process_multiple($element, &$form_state, $form)
Definition: file.field.inc:688
file_field_widget_submit
file_field_widget_submit($form, &$form_state)
Definition: file.field.inc:754
token_replace
token_replace($text, array $data=array(), array $options=array())
Definition: token.inc:79
file_delete
file_delete(stdClass $file, $force=FALSE)
Definition: file.inc:1268
theme_file_formatter_table
theme_file_formatter_table($variables)
Definition: file.field.inc:1013
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
field_widget_instance
field_widget_instance($element, $form_state)
Definition: field.form.inc:601
file_field_instance_settings_form
file_field_instance_settings_form($field, $instance)
Definition: file.field.inc:74
file_get_stream_wrappers
file_get_stream_wrappers($filter=STREAM_WRAPPERS_ALL)
Definition: file.inc:123
file_field_formatter_view
file_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
Definition: file.field.inc:971
file_field_delete_revision
file_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: file.field.inc:317
file_field_widget_form
file_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
Definition: file.field.inc:456
file_load_multiple
file_load_multiple($fids=array(), $conditions=array())
Definition: file.inc:564
field_info_field_settings
field_info_field_settings($type)
Definition: field.info.inc:742
hide
hide(&$element)
Definition: common.inc:6021
$value
print $value
Definition: user-profile-item.tpl.php:26
file_load
file_load($fid)
Definition: file.inc:580
field_form_set_state
field_form_set_state($parents, $field_name, $langcode, &$form_state, $field_state)
Definition: field.form.inc:527
field_attach_load
field_attach_load($entity_type, $entities, $age=FIELD_LOAD_CURRENT, $options=array())
Definition: field.attach.inc:622
drupal_render_children
drupal_render_children(&$element, $children_keys=NULL)
Definition: common.inc:5958
$output
$output
Definition: authorize.php:93
FIELD_BEHAVIOR_CUSTOM
const FIELD_BEHAVIOR_CUSTOM
Definition: field.module:262
theme_file_widget_multiple
theme_file_widget_multiple($variables)
Definition: file.field.inc:824
render
render(&$element)
Definition: common.inc:5988
FIELD_CARDINALITY_UNLIMITED
const FIELD_CARDINALITY_UNLIMITED
Definition: field.module:236
file_usage_delete
file_usage_delete(stdClass $file, $module, $type=NULL, $id=NULL, $count=1)
Definition: file.inc:720
parse_size
parse_size($size)
Definition: common.inc:1842
file_field_widget_uri
file_field_widget_uri($field, $instance, $data=array())
Definition: file.field.inc:577
STREAM_WRAPPERS_WRITE_VISIBLE
const STREAM_WRAPPERS_WRITE_VISIBLE
Definition: stream_wrappers.inc:72
field_form_get_state
field_form_get_state($parents, $field_name, $langcode, &$form_state)
Definition: field.form.inc:505
file_field_widget_value
file_field_widget_value($element, $input=FALSE, $form_state)
Definition: file.field.inc:589
drupal_render
drupal_render(&$elements)
Definition: common.inc:5834
file_field_delete
file_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items)
Definition: file.field.inc:305
_file_generic_settings_max_filesize
_file_generic_settings_max_filesize($element, &$form_state)
Definition: file.field.inc:127
theme_file_widget
theme_file_widget($variables)
Definition: file.field.inc:799
_file_generic_settings_extensions
_file_generic_settings_extensions($element, &$form_state)
Definition: file.field.inc:140
element_children
element_children(&$elements, $sort=FALSE)
Definition: common.inc:6413
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
$row
$row
Definition: block-admin-display-form.tpl.php:47
FIELD_BEHAVIOR_NONE
const FIELD_BEHAVIOR_NONE
Definition: field.module:243
entity_create_stub_entity
entity_create_stub_entity($entity_type, $ids)
Definition: common.inc:7749
drupal_array_set_nested_value
drupal_array_set_nested_value(array &$array, array $parents, $value, $force=FALSE)
Definition: common.inc:6598
file_usage_list
file_usage_list(stdClass $file)
Definition: file.inc:642
field_widget_field
field_widget_field($element, $form_state)
Definition: field.form.inc:576
drupal_add_tabledrag
drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
Definition: common.inc:4887
file_field_formatter_info
file_field_formatter_info()
Definition: file.field.inc:394
format_size
format_size($size, $langcode=NULL)
Definition: common.inc:1866
file_field_is_empty
file_field_is_empty($item, $field)
Definition: file.field.inc:369
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
entity_extract_ids
entity_extract_ids($entity_type, $entity)
Definition: common.inc:7711
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
theme_file_upload_help
theme_file_upload_help($variables)
Definition: file.field.inc:933
file_save
file_save(stdClass $file)
Definition: file.inc:599
file_field_prepare_view
file_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items)
Definition: file.field.inc:198
FIELD_LOAD_CURRENT
const FIELD_LOAD_CURRENT
Definition: field.module:268
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/menu/menu.module Source File

  • modules
  • menu
menu.module
Go to the documentation of this file.
1 <?php
2
18 define('MENU_MAX_MENU_NAME_LENGTH_UI', 27);
19
23 function menu_help($path, $arg) {
24 switch ($path) {
25 case 'admin/help#menu':
26 $output = '';
27 $output .= '<h3>' . t('About') . '</h3>';
28 $output .= '<p>' . t('The Menu module provides an interface for managing menus. A menu is a hierarchical collection of links, which can be within or external to the site, generally used for navigation. Each menu is rendered in a block that can be enabled and positioned through the <a href="@blocks">Blocks administration page</a>. You can view and manage menus on the <a href="@menus">Menus administration page</a>. For more information, see the online handbook entry for the <a href="@menu">Menu module</a>.', array('@blocks' => url('admin/structure/block'), '@menus' => url('admin/structure/menu'), '@menu' => 'http://drupal.org/documentation/modules/menu/')) . '</p>';
29 $output .= '<h3>' . t('Uses') . '</h3>';
30 $output .= '<dl>';
31 $output .= '<dt>' . t('Managing menus') . '</dt>';
32 $output .= '<dd>' . t('Users with the <em>Administer menus and menu items</em> permission can add, edit and delete custom menus on the <a href="@menu">Menus administration page</a>. Custom menus can be special site menus, menus of external links, or any combination of internal and external links. You may create an unlimited number of additional menus, each of which will automatically have an associated block. By selecting <em>list links</em>, you can add, edit, or delete links for a given menu. The links listing page provides a drag-and-drop interface for controlling the order of links, and creating a hierarchy within the menu.', array('@menu' => url('admin/structure/menu'), '@add-menu' => url('admin/structure/menu/add'))) . '</dd>';
33 $output .= '<dt>' . t('Displaying menus') . '</dt>';
34 $output .= '<dd>' . t('After you have created a menu, you must enable and position the associated block on the <a href="@blocks">Blocks administration page</a>.', array('@blocks' => url('admin/structure/block'))) . '</dd>';
35 $output .= '</dl>';
36 return $output;
37 case 'admin/structure/menu/add':
38 return '<p>' . t('You can enable the newly-created block for this menu on the <a href="@blocks">Blocks administration page</a>.', array('@blocks' => url('admin/structure/block'))) . '</p>';
39 }
40 if ($path == 'admin/structure/menu' && module_exists('block')) {
41 return '<p>' . t('Each menu has a corresponding block that is managed on the <a href="@blocks">Blocks administration page</a>.', array('@blocks' => url('admin/structure/block'))) . '</p>';
42 }
43 }
44
48 function menu_permission() {
49 return array(
50 'administer menu' => array(
51 'title' => t('Administer menus and menu items'),
52 ),
53 );
54 }
55
59 function menu_menu() {
60 $items['admin/structure/menu'] = array(
61 'title' => 'Menus',
62 'description' => 'Add new menus to your site, edit existing menus, and rename and reorganize menu links.',
63 'page callback' => 'menu_overview_page',
64 'access callback' => 'user_access',
65 'access arguments' => array('administer menu'),
66 'file' => 'menu.admin.inc',
67 );
68 $items['admin/structure/menu/parents'] = array(
69 'title' => 'Parent menu items',
70 'page callback' => 'menu_parent_options_js',
71 'type' => MENU_CALLBACK,
72 'access arguments' => array(TRUE),
73 );
74 $items['admin/structure/menu/list'] = array(
75 'title' => 'List menus',
76 'type' => MENU_DEFAULT_LOCAL_TASK,
77 'weight' => -10,
78 );
79 $items['admin/structure/menu/add'] = array(
80 'title' => 'Add menu',
81 'page callback' => 'drupal_get_form',
82 'page arguments' => array('menu_edit_menu', 'add'),
83 'access arguments' => array('administer menu'),
84 'type' => MENU_LOCAL_ACTION,
85 'file' => 'menu.admin.inc',
86 );
87 $items['admin/structure/menu/settings'] = array(
88 'title' => 'Settings',
89 'page callback' => 'drupal_get_form',
90 'page arguments' => array('menu_configure'),
91 'access arguments' => array('administer menu'),
92 'type' => MENU_LOCAL_TASK,
93 'weight' => 5,
94 'file' => 'menu.admin.inc',
95 );
96 $items['admin/structure/menu/manage/%menu'] = array(
97 'title' => 'Customize menu',
98 'page callback' => 'drupal_get_form',
99 'page arguments' => array('menu_overview_form', 4),
100 'title callback' => 'menu_overview_title',
101 'title arguments' => array(4),
102 'access arguments' => array('administer menu'),
103 'file' => 'menu.admin.inc',
104 );
105 $items['admin/structure/menu/manage/%menu/list'] = array(
106 'title' => 'List links',
107 'weight' => -10,
108 'type' => MENU_DEFAULT_LOCAL_TASK,
109 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
110 );
111 $items['admin/structure/menu/manage/%menu/add'] = array(
112 'title' => 'Add link',
113 'page callback' => 'drupal_get_form',
114 'page arguments' => array('menu_edit_item', 'add', NULL, 4),
115 'access arguments' => array('administer menu'),
116 'type' => MENU_LOCAL_ACTION,
117 'file' => 'menu.admin.inc',
118 );
119 $items['admin/structure/menu/manage/%menu/edit'] = array(
120 'title' => 'Edit menu',
121 'page callback' => 'drupal_get_form',
122 'page arguments' => array('menu_edit_menu', 'edit', 4),
123 'access arguments' => array('administer menu'),
124 'type' => MENU_LOCAL_TASK,
125 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
126 'file' => 'menu.admin.inc',
127 );
128 $items['admin/structure/menu/manage/%menu/delete'] = array(
129 'title' => 'Delete menu',
130 'page callback' => 'menu_delete_menu_page',
131 'page arguments' => array(4),
132 'access arguments' => array('administer menu'),
133 'file' => 'menu.admin.inc',
134 );
135 $items['admin/structure/menu/item/%menu_link/edit'] = array(
136 'title' => 'Edit menu link',
137 'page callback' => 'drupal_get_form',
138 'page arguments' => array('menu_edit_item', 'edit', 4, NULL),
139 'access arguments' => array('administer menu'),
140 'file' => 'menu.admin.inc',
141 );
142 $items['admin/structure/menu/item/%menu_link/reset'] = array(
143 'title' => 'Reset menu link',
144 'page callback' => 'drupal_get_form',
145 'page arguments' => array('menu_reset_item_confirm', 4),
146 'access arguments' => array('administer menu'),
147 'file' => 'menu.admin.inc',
148 );
149 $items['admin/structure/menu/item/%menu_link/delete'] = array(
150 'title' => 'Delete menu link',
151 'page callback' => 'menu_item_delete_page',
152 'page arguments' => array(4),
153 'access arguments' => array('administer menu'),
154 'file' => 'menu.admin.inc',
155 );
156 return $items;
157 }
158
162 function menu_theme() {
163 return array(
164 'menu_overview_form' => array(
165 'file' => 'menu.admin.inc',
166 'render element' => 'form',
167 ),
168 'menu_admin_overview' => array(
169 'file' => 'menu.admin.inc',
170 'variables' => array('title' => NULL, 'name' => NULL, 'description' => NULL),
171 ),
172 );
173 }
174
180 function menu_enable() {
181 menu_rebuild();
182 $base_link = db_query("SELECT mlid AS plid, menu_name FROM {menu_links} WHERE link_path = 'admin/structure/menu' AND module = 'system'")->fetchAssoc();
183 $base_link['router_path'] = 'admin/structure/menu/manage/%';
184 $base_link['module'] = 'menu';
185 $result = db_query("SELECT * FROM {menu_custom}", array(), array('fetch' => PDO::FETCH_ASSOC));
186 foreach ($result as $menu) {
187 // $link is passed by reference to menu_link_save(), so we make a copy of $base_link.
188 $link = $base_link;
189 $link['mlid'] = 0;
190 $link['link_title'] = $menu['title'];
191 $link['link_path'] = 'admin/structure/menu/manage/' . $menu['menu_name'];
192 $menu_link = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :path AND plid = :plid", array(
193 ':path' => $link['link_path'],
194 ':plid' => $link['plid']
195 ))
196 ->fetchField();
197 if (!$menu_link) {
198 menu_link_save($link);
199 }
200 }
201 menu_cache_clear_all();
202 }
203
207 function menu_overview_title($menu) {
208 return $menu['title'];
209 }
210
219 function menu_load($menu_name) {
220 $all_menus = menu_load_all();
221 return isset($all_menus[$menu_name]) ? $all_menus[$menu_name] : FALSE;
222 }
223
230 function menu_load_all() {
231 $custom_menus = &drupal_static(__FUNCTION__);
232 if (!isset($custom_menus)) {
233 if ($cached = cache_get('menu_custom', 'cache_menu')) {
234 $custom_menus = $cached->data;
235 }
236 else {
237 $custom_menus = db_query('SELECT * FROM {menu_custom}')->fetchAllAssoc('menu_name', PDO::FETCH_ASSOC);
238 cache_set('menu_custom', $custom_menus, 'cache_menu');
239 }
240 }
241 return $custom_menus;
242 }
243
259 function menu_save($menu) {
260 $status = db_merge('menu_custom')
261 ->key(array('menu_name' => $menu['menu_name']))
262 ->fields(array(
263 'title' => $menu['title'],
264 'description' => $menu['description'],
265 ))
266 ->execute();
267 menu_cache_clear_all();
268
269 switch ($status) {
270 case SAVED_NEW:
271 // Make sure the menu is present in the active menus variable so that its
272 // items may appear in the menu active trail.
273 // @see menu_set_active_menu_names()
274 $active_menus = variable_get('menu_default_active_menus', array_keys(menu_get_menus()));
275 if (!in_array($menu['menu_name'], $active_menus)) {
276 $active_menus[] = $menu['menu_name'];
277 variable_set('menu_default_active_menus', $active_menus);
278 }
279
280 module_invoke_all('menu_insert', $menu);
281 break;
282
283 case SAVED_UPDATED:
284 module_invoke_all('menu_update', $menu);
285 break;
286 }
287 }
288
313 function menu_delete($menu) {
314 // Delete all links from the menu.
315 menu_delete_links($menu['menu_name']);
316
317 // Remove menu from active menus variable.
318 $active_menus = variable_get('menu_default_active_menus', array_keys(menu_get_menus()));
319 foreach ($active_menus as $i => $menu_name) {
320 if ($menu['menu_name'] == $menu_name) {
321 unset($active_menus[$i]);
322 variable_set('menu_default_active_menus', $active_menus);
323 }
324 }
325
326 // Delete the custom menu.
327 db_delete('menu_custom')
328 ->condition('menu_name', $menu['menu_name'])
329 ->execute();
330
331 menu_cache_clear_all();
332 module_invoke_all('menu_delete', $menu);
333 }
334
353 function menu_parent_options($menus, $item, $type = '') {
354 // The menu_links table can be practically any size and we need a way to
355 // allow contrib modules to provide more scalable pattern choosers.
356 // hook_form_alter is too late in itself because all the possible parents are
357 // retrieved here, unless menu_override_parent_selector is set to TRUE.
358 if (variable_get('menu_override_parent_selector', FALSE)) {
359 return array();
360 }
361
362 $available_menus = array();
363 if (!is_array($item)) {
364 // If $item is not an array then it is a node type.
365 // Use it as $type and prepare a dummy menu item for _menu_get_options().
366 $type = $item;
367 $item = array('mlid' => 0);
368 }
369 if (empty($type)) {
370 // If no node type is set, use all menus given to this function.
371 $available_menus = $menus;
372 }
373 else {
374 // If a node type is set, use all available menus for this type.
375 $type_menus = variable_get('menu_options_' . $type, array('main-menu' => 'main-menu'));
376 foreach ($type_menus as $menu) {
377 $available_menus[$menu] = $menu;
378 }
379 }
380
381 return _menu_get_options($menus, $available_menus, $item);
382 }
383
388 function menu_parent_options_js() {
389 $available_menus = array();
390 if (isset($_POST['menus']) && count($_POST['menus'])) {
391 foreach ($_POST['menus'] as $menu) {
392 $available_menus[$menu] = $menu;
393 }
394 }
395 $options = _menu_get_options(menu_get_menus(), $available_menus, array('mlid' => 0));
396
397 drupal_json_output($options);
398 }
399
403 function _menu_get_options($menus, $available_menus, $item) {
404 // If the item has children, there is an added limit to the depth of valid parents.
405 if (isset($item['parent_depth_limit'])) {
406 $limit = $item['parent_depth_limit'];
407 }
408 else {
409 $limit = _menu_parent_depth_limit($item);
410 }
411
412 $options = array();
413 foreach ($menus as $menu_name => $title) {
414 if (isset($available_menus[$menu_name])) {
415 $tree = menu_tree_all_data($menu_name, NULL);
416 $options[$menu_name . ':0'] = '<' . $title . '>';
417 _menu_parents_recurse($tree, $menu_name, '--', $options, $item['mlid'], $limit);
418 }
419 }
420 return $options;
421 }
422
426 function _menu_parents_recurse($tree, $menu_name, $indent, &$options, $exclude, $depth_limit) {
427 foreach ($tree as $data) {
428 if ($data['link']['depth'] > $depth_limit) {
429 // Don't iterate through any links on this level.
430 break;
431 }
432 if ($data['link']['mlid'] != $exclude && $data['link']['hidden'] >= 0) {
433 $title = $indent . ' ' . truncate_utf8($data['link']['title'], 30, TRUE, FALSE);
434 if ($data['link']['hidden']) {
435 $title .= ' (' . t('disabled') . ')';
436 }
437 $options[$menu_name . ':' . $data['link']['mlid']] = $title;
438 if ($data['below']) {
439 _menu_parents_recurse($data['below'], $menu_name, $indent . '--', $options, $exclude, $depth_limit);
440 }
441 }
442 }
443 }
444
448 function menu_reset_item($link) {
449 // To reset the link to its original values, we need to retrieve its
450 // definition from hook_menu(). Otherwise, for example, the link's menu would
451 // not be reset, because properties like the original 'menu_name' are not
452 // stored anywhere else. Since resetting a link happens rarely and this is a
453 // one-time operation, retrieving the full menu router does no harm.
454 $menu = menu_get_router();
455 $router_item = $menu[$link['router_path']];
456 $new_link = _menu_link_build($router_item);
457 // Merge existing menu link's ID and 'has_children' property.
458 foreach (array('mlid', 'has_children') as $key) {
459 $new_link[$key] = $link[$key];
460 }
461 menu_link_save($new_link);
462 return $new_link;
463 }
464
468 function menu_block_info() {
469 $menus = menu_get_menus(FALSE);
470
471 $blocks = array();
472 foreach ($menus as $name => $title) {
473 $blocks[$name]['info'] = check_plain($title);
474 // Menu blocks can't be cached because each menu item can have
475 // a custom access callback. menu.inc manages its own caching.
476 $blocks[$name]['cache'] = DRUPAL_NO_CACHE;
477 }
478 return $blocks;
479 }
480
484 function menu_block_view($delta = '') {
485 $menus = menu_get_menus(FALSE);
486 $data['subject'] = check_plain($menus[$delta]);
487 $data['content'] = menu_tree($delta);
488 // Add contextual links for this block.
489 if (!empty($data['content'])) {
490 $data['content']['#contextual_links']['menu'] = array('admin/structure/menu/manage', array($delta));
491 }
492 return $data;
493 }
494
498 function menu_block_view_alter(&$data, $block) {
499 // Add contextual links for system menu blocks.
500 if ($block->module == 'system' && !empty($data['content'])) {
501 $system_menus = menu_list_system_menus();
502 if (isset($system_menus[$block->delta])) {
503 $data['content']['#contextual_links']['menu'] = array('admin/structure/menu/manage', array($block->delta));
504 }
505 }
506 }
507
511 function menu_node_insert($node) {
512 menu_node_save($node);
513 }
514
518 function menu_node_update($node) {
519 menu_node_save($node);
520 }
521
525 function menu_node_save($node) {
526 if (isset($node->menu)) {
527 $link = &$node->menu;
528 if (empty($link['enabled'])) {
529 if (!empty($link['mlid'])) {
530 menu_link_delete($link['mlid']);
531 }
532 }
533 elseif (trim($link['link_title'])) {
534 $link['link_title'] = trim($link['link_title']);
535 $link['link_path'] = "node/$node->nid";
536 if (trim($link['description'])) {
537 $link['options']['attributes']['title'] = trim($link['description']);
538 }
539 else {
540 // If the description field was left empty, remove the title attribute
541 // from the menu link.
542 unset($link['options']['attributes']['title']);
543 }
544 if (!menu_link_save($link)) {
545 drupal_set_message(t('There was an error saving the menu link.'), 'error');
546 }
547 }
548 }
549 }
550
554 function menu_node_delete($node) {
555 // Delete all menu module links that point to this node.
556 $result = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :path AND module = 'menu'", array(':path' => 'node/' . $node->nid), array('fetch' => PDO::FETCH_ASSOC));
557 foreach ($result as $m) {
558 menu_link_delete($m['mlid']);
559 }
560 }
561
565 function menu_node_prepare($node) {
566 if (empty($node->menu)) {
567 // Prepare the node for the edit form so that $node->menu always exists.
568 $menu_name = strtok(variable_get('menu_parent_' . $node->type, 'main-menu:0'), ':');
569 $item = array();
570 if (isset($node->nid)) {
571 $mlid = FALSE;
572 // Give priority to the default menu
573 $type_menus = variable_get('menu_options_' . $node->type, array('main-menu' => 'main-menu'));
574 if (in_array($menu_name, $type_menus)) {
575 $mlid = db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND menu_name = :menu_name AND module = 'menu' ORDER BY mlid ASC", 0, 1, array(
576 ':path' => 'node/' . $node->nid,
577 ':menu_name' => $menu_name,
578 ))->fetchField();
579 }
580 // Check all allowed menus if a link does not exist in the default menu.
581 if (!$mlid && !empty($type_menus)) {
582 $mlid = db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND module = 'menu' AND menu_name IN (:type_menus) ORDER BY mlid ASC", 0, 1, array(
583 ':path' => 'node/' . $node->nid,
584 ':type_menus' => array_values($type_menus),
585 ))->fetchField();
586 }
587 if ($mlid) {
588 $item = menu_link_load($mlid);
589 }
590 }
591 // Set default values.
592 $node->menu = $item + array(
593 'link_title' => '',
594 'mlid' => 0,
595 'plid' => 0,
596 'menu_name' => $menu_name,
597 'weight' => 0,
598 'options' => array(),
599 'module' => 'menu',
600 'expanded' => 0,
601 'hidden' => 0,
602 'has_children' => 0,
603 'customized' => 0,
604 );
605 }
606 // Find the depth limit for the parent select.
607 if (!isset($node->menu['parent_depth_limit'])) {
608 $node->menu['parent_depth_limit'] = _menu_parent_depth_limit($node->menu);
609 }
610 }
611
615 function _menu_parent_depth_limit($item) {
616 return MENU_MAX_DEPTH - 1 - (($item['mlid'] && $item['has_children']) ? menu_link_children_relative_depth($item) : 0);
617 }
618
626 function menu_form_node_form_alter(&$form, $form_state) {
627 // Generate a list of possible parents (not including this link or descendants).
628 // @todo This must be handled in a #process handler.
629 $link = $form['#node']->menu;
630 $type = $form['#node']->type;
631 // menu_parent_options() is goofy and can actually handle either a menu link
632 // or a node type both as second argument. Pick based on whether there is
633 // a link already (menu_node_prepare() sets mlid default to 0).
634 $options = menu_parent_options(menu_get_menus(), $link['mlid'] ? $link : $type, $type);
635 // If no possible parent menu items were found, there is nothing to display.
636 if (empty($options)) {
637 return;
638 }
639
640 $form['menu'] = array(
641 '#type' => 'fieldset',
642 '#title' => t('Menu settings'),
643 '#access' => user_access('administer menu'),
644 '#collapsible' => TRUE,
645 '#collapsed' => !$link['link_title'],
646 '#group' => 'additional_settings',
647 '#attached' => array(
648 'js' => array(drupal_get_path('module', 'menu') . '/menu.js'),
649 ),
650 '#tree' => TRUE,
651 '#weight' => -2,
652 '#attributes' => array('class' => array('menu-link-form')),
653 );
654 $form['menu']['enabled'] = array(
655 '#type' => 'checkbox',
656 '#title' => t('Provide a menu link'),
657 '#default_value' => (int) (bool) $link['mlid'],
658 );
659 $form['menu']['link'] = array(
660 '#type' => 'container',
661 '#parents' => array('menu'),
662 '#states' => array(
663 'invisible' => array(
664 'input[name="menu[enabled]"]' => array('checked' => FALSE),
665 ),
666 ),
667 );
668
669 // Populate the element with the link data.
670 foreach (array('mlid', 'module', 'hidden', 'has_children', 'customized', 'options', 'expanded', 'hidden', 'parent_depth_limit') as $key) {
671 $form['menu']['link'][$key] = array('#type' => 'value', '#value' => $link[$key]);
672 }
673
674 $form['menu']['link']['link_title'] = array(
675 '#type' => 'textfield',
676 '#title' => t('Menu link title'),
677 '#default_value' => $link['link_title'],
678 );
679
680 $form['menu']['link']['description'] = array(
681 '#type' => 'textarea',
682 '#title' => t('Description'),
683 '#default_value' => isset($link['options']['attributes']['title']) ? $link['options']['attributes']['title'] : '',
684 '#rows' => 1,
685 '#description' => t('Shown when hovering over the menu link.'),
686 );
687
688 $default = ($link['mlid'] ? $link['menu_name'] . ':' . $link['plid'] : variable_get('menu_parent_' . $type, 'main-menu:0'));
689 // If the current parent menu item is not present in options, use the first
690 // available option as default value.
691 // @todo User should not be allowed to access menu link settings in such a
692 // case.
693 if (!isset($options[$default])) {
694 $array = array_keys($options);
695 $default = reset($array);
696 }
697 $form['menu']['link']['parent'] = array(
698 '#type' => 'select',
699 '#title' => t('Parent item'),
700 '#default_value' => $default,
701 '#options' => $options,
702 '#attributes' => array('class' => array('menu-parent-select')),
703 );
704 $form['menu']['link']['weight'] = array(
705 '#type' => 'weight',
706 '#title' => t('Weight'),
707 '#delta' => 50,
708 '#default_value' => $link['weight'],
709 '#description' => t('Menu links with smaller weights are displayed before links with larger weights.'),
710 );
711 }
712
718 function menu_node_submit($node, $form, $form_state) {
719 // Decompose the selected menu parent option into 'menu_name' and 'plid', if
720 // the form used the default parent selection widget.
721 if (!empty($form_state['values']['menu']['parent'])) {
722 list($node->menu['menu_name'], $node->menu['plid']) = explode(':', $form_state['values']['menu']['parent']);
723 }
724 }
725
731 function menu_form_node_type_form_alter(&$form, $form_state) {
732 $menu_options = menu_get_menus();
733 $type = $form['#node_type'];
734 $form['menu'] = array(
735 '#type' => 'fieldset',
736 '#title' => t('Menu settings'),
737 '#collapsible' => TRUE,
738 '#collapsed' => TRUE,
739 '#attached' => array(
740 'js' => array(drupal_get_path('module', 'menu') . '/menu.admin.js'),
741 ),
742 '#group' => 'additional_settings',
743 );
744 $form['menu']['menu_options'] = array(
745 '#type' => 'checkboxes',
746 '#title' => t('Available menus'),
747 '#default_value' => variable_get('menu_options_' . $type->type, array('main-menu')),
748 '#options' => $menu_options,
749 '#description' => t('The menus available to place links in for this content type.'),
750 );
751 // To avoid an 'illegal option' error after saving the form we have to load
752 // all available menu items.
753 // Otherwise it is not possible to dynamically add options to the list.
754 // @todo Convert menu_parent_options() into a #process callback.
755 $options = menu_parent_options(menu_get_menus(), array('mlid' => 0));
756 $form['menu']['menu_parent'] = array(
757 '#type' => 'select',
758 '#title' => t('Default parent item'),
759 '#default_value' => variable_get('menu_parent_' . $type->type, 'main-menu:0'),
760 '#options' => $options,
761 '#description' => t('Choose the menu item to be the default parent for a new link in the content authoring form.'),
762 '#attributes' => array('class' => array('menu-title-select')),
763 );
764
765 // Call Drupal.menu_update_parent_list() to filter the list of
766 // available default parent menu items based on the selected menus.
767 drupal_add_js(
768 '(function ($) { Drupal.menu_update_parent_list(); })(jQuery);',
769 array('scope' => 'footer', 'type' => 'inline')
770 );
771 }
772
783 function menu_get_menus($all = TRUE) {
784 if ($custom_menus = menu_load_all()) {
785 if (!$all) {
786 $custom_menus = array_diff_key($custom_menus, menu_list_system_menus());
787 }
788 foreach ($custom_menus as $menu_name => $menu) {
789 $custom_menus[$menu_name] = t($menu['title']);
790 }
791 asort($custom_menus);
792 }
793 return $custom_menus;
794 }
menu_enable
menu_enable()
Definition: menu.module:180
menu_parent_options_js
menu_parent_options_js()
Definition: menu.module:388
menu_get_router
menu_get_router()
Definition: menu.inc:2783
menu_link_save
menu_link_save(&$item, $existing_item=array(), $parent_candidates=array())
Definition: menu.inc:3074
menu_delete_links
menu_delete_links($menu_name)
Definition: menu.inc:2976
MENU_LOCAL_TASK
const MENU_LOCAL_TASK
Definition: menu.inc:170
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
menu_delete
menu_delete($menu)
Definition: menu.module:313
SAVED_UPDATED
const SAVED_UPDATED
Definition: common.inc:50
menu_save
menu_save($menu)
Definition: menu.module:259
menu_permission
menu_permission()
Definition: menu.module:48
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
drupal_json_output
drupal_json_output($var=NULL)
Definition: common.inc:5041
menu_link_delete
menu_link_delete($mlid, $path=NULL)
Definition: menu.inc:2996
_menu_link_build
_menu_link_build($item)
Definition: menu.inc:2795
MENU_LOCAL_ACTION
const MENU_LOCAL_ACTION
Definition: menu.inc:186
menu_reset_item
menu_reset_item($link)
Definition: menu.module:448
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
module_exists
module_exists($module)
Definition: module.inc:274
menu_node_update
menu_node_update($node)
Definition: menu.module:518
menu_node_insert
menu_node_insert($node)
Definition: menu.module:511
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
menu_block_info
menu_block_info()
Definition: menu.module:468
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
menu_rebuild
menu_rebuild()
Definition: menu.inc:2709
menu_theme
menu_theme()
Definition: menu.module:162
MENU_DEFAULT_LOCAL_TASK
const MENU_DEFAULT_LOCAL_TASK
Definition: menu.inc:178
menu_link_children_relative_depth
menu_link_children_relative_depth($item)
Definition: menu.inc:3432
cache_get
cache_get($cid, $bin= 'cache')
Definition: cache.inc:55
menu_link_load
menu_link_load($mlid)
Definition: menu.inc:2635
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
menu_form_node_type_form_alter
menu_form_node_type_form_alter(&$form, $form_state)
Definition: menu.module:731
$output
$output
Definition: authorize.php:93
user_access
user_access($string, $account=NULL)
Definition: user.module:794
menu_cache_clear_all
menu_cache_clear_all()
Definition: menu.inc:2678
menu_get_menus
menu_get_menus($all=TRUE)
Definition: menu.module:783
MENU_MAX_DEPTH
const MENU_MAX_DEPTH
Definition: menu.inc:270
menu_list_system_menus
menu_list_system_menus()
Definition: menu.inc:1792
menu_node_delete
menu_node_delete($node)
Definition: menu.module:554
menu_tree_all_data
menu_tree_all_data($menu_name, $link=NULL, $max_depth=NULL)
Definition: menu.inc:1105
SAVED_NEW
const SAVED_NEW
Definition: common.inc:45
menu_load_all
menu_load_all()
Definition: menu.module:230
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
_menu_get_options
_menu_get_options($menus, $available_menus, $item)
Definition: menu.module:403
menu_form_node_form_alter
menu_form_node_form_alter(&$form, $form_state)
Definition: menu.module:626
drupal_add_js
drupal_add_js($data=NULL, $options=NULL)
Definition: common.inc:4128
DRUPAL_NO_CACHE
const DRUPAL_NO_CACHE
Definition: common.inc:127
menu_parent_options
menu_parent_options($menus, $item, $type= '')
Definition: menu.module:353
cache_set
cache_set($cid, $data, $bin= 'cache', $expire=CACHE_PERMANENT)
Definition: cache.inc:133
MENU_CONTEXT_INLINE
const MENU_CONTEXT_INLINE
Definition: menu.inc:214
menu_help
menu_help($path, $arg)
Definition: menu.module:23
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
menu_menu
menu_menu()
Definition: menu.module:59
menu_node_prepare
menu_node_prepare($node)
Definition: menu.module:565
menu_block_view
menu_block_view($delta= '')
Definition: menu.module:484
menu_load
menu_load($menu_name)
Definition: menu.module:219
menu_tree
menu_tree($menu_name)
Definition: menu.inc:992
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
$tree
if($tree||$has_links) print $tree
Definition: book-navigation.tpl.php:35
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
menu_overview_title
menu_overview_title($menu)
Definition: menu.module:207
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
truncate_utf8
truncate_utf8($string, $max_length, $wordsafe=FALSE, $add_ellipsis=FALSE, $min_wordsafe_length=1)
Definition: unicode.inc:316
menu_block_view_alter
menu_block_view_alter(&$data, $block)
Definition: menu.module:498
menu_node_save
menu_node_save($node)
Definition: menu.module:525
_menu_parents_recurse
_menu_parents_recurse($tree, $menu_name, $indent, &$options, $exclude, $depth_limit)
Definition: menu.module:426
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
menu_node_submit
menu_node_submit($node, $form, $form_state)
Definition: menu.module:718
MENU_CONTEXT_PAGE
const MENU_CONTEXT_PAGE
Definition: menu.inc:209
_menu_parent_depth_limit
_menu_parent_depth_limit($item)
Definition: menu.module:615
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy/taxonomy.install Source File

  • modules
  • taxonomy
taxonomy.install
Go to the documentation of this file.
1 <?php
2
11 function taxonomy_uninstall() {
12 // Remove variables.
13 variable_del('taxonomy_override_selector');
14 variable_del('taxonomy_terms_per_page_admin');
15 // Remove taxonomy_term bundles.
16 $vocabularies = db_query("SELECT machine_name FROM {taxonomy_vocabulary}")->fetchCol();
17 foreach ($vocabularies as $vocabulary) {
18 field_attach_delete_bundle('taxonomy_term', $vocabulary);
19 }
20 }
21
25 function taxonomy_schema() {
26 $schema['taxonomy_term_data'] = array(
27 'description' => 'Stores term information.',
28 'fields' => array(
29 'tid' => array(
30 'type' => 'serial',
31 'unsigned' => TRUE,
32 'not null' => TRUE,
33 'description' => 'Primary Key: Unique term ID.',
34 ),
35 'vid' => array(
36 'type' => 'int',
37 'unsigned' => TRUE,
38 'not null' => TRUE,
39 'default' => 0,
40 'description' => 'The {taxonomy_vocabulary}.vid of the vocabulary to which the term is assigned.',
41 ),
42 'name' => array(
43 'type' => 'varchar',
44 'length' => 255,
45 'not null' => TRUE,
46 'default' => '',
47 'description' => 'The term name.',
48 'translatable' => TRUE,
49 ),
50 'description' => array(
51 'type' => 'text',
52 'not null' => FALSE,
53 'size' => 'big',
54 'description' => 'A description of the term.',
55 'translatable' => TRUE,
56 ),
57 'format' => array(
58 'type' => 'varchar',
59 'length' => 255,
60 'not null' => FALSE,
61 'description' => 'The {filter_format}.format of the description.',
62 ),
63 'weight' => array(
64 'type' => 'int',
65 'not null' => TRUE,
66 'default' => 0,
67 'description' => 'The weight of this term in relation to other terms.',
68 ),
69 ),
70 'primary key' => array('tid'),
71 'foreign keys' => array(
72 'vocabulary' => array(
73 'table' => 'taxonomy_vocabulary',
74 'columns' => array('vid' => 'vid'),
75 ),
76 ),
77 'indexes' => array(
78 'taxonomy_tree' => array('vid', 'weight', 'name'),
79 'vid_name' => array('vid', 'name'),
80 'name' => array('name'),
81 ),
82 );
83
84 $schema['taxonomy_term_hierarchy'] = array(
85 'description' => 'Stores the hierarchical relationship between terms.',
86 'fields' => array(
87 'tid' => array(
88 'type' => 'int',
89 'unsigned' => TRUE,
90 'not null' => TRUE,
91 'default' => 0,
92 'description' => 'Primary Key: The {taxonomy_term_data}.tid of the term.',
93 ),
94 'parent' => array(
95 'type' => 'int',
96 'unsigned' => TRUE,
97 'not null' => TRUE,
98 'default' => 0,
99 'description' => "Primary Key: The {taxonomy_term_data}.tid of the term's parent. 0 indicates no parent.",
100 ),
101 ),
102 'indexes' => array(
103 'parent' => array('parent'),
104 ),
105 'foreign keys' => array(
106 'taxonomy_term_data' => array(
107 'table' => 'taxonomy_term_data',
108 'columns' => array('tid' => 'tid'),
109 ),
110 ),
111 'primary key' => array('tid', 'parent'),
112 );
113
114 $schema['taxonomy_vocabulary'] = array(
115 'description' => 'Stores vocabulary information.',
116 'fields' => array(
117 'vid' => array(
118 'type' => 'serial',
119 'unsigned' => TRUE,
120 'not null' => TRUE,
121 'description' => 'Primary Key: Unique vocabulary ID.',
122 ),
123 'name' => array(
124 'type' => 'varchar',
125 'length' => 255,
126 'not null' => TRUE,
127 'default' => '',
128 'description' => 'Name of the vocabulary.',
129 'translatable' => TRUE,
130 ),
131 'machine_name' => array(
132 'type' => 'varchar',
133 'length' => 255,
134 'not null' => TRUE,
135 'default' => '',
136 'description' => 'The vocabulary machine name.',
137 ),
138 'description' => array(
139 'type' => 'text',
140 'not null' => FALSE,
141 'size' => 'big',
142 'description' => 'Description of the vocabulary.',
143 'translatable' => TRUE,
144 ),
145 'hierarchy' => array(
146 'type' => 'int',
147 'unsigned' => TRUE,
148 'not null' => TRUE,
149 'default' => 0,
150 'size' => 'tiny',
151 'description' => 'The type of hierarchy allowed within the vocabulary. (0 = disabled, 1 = single, 2 = multiple)',
152 ),
153 'module' => array(
154 'type' => 'varchar',
155 'length' => 255,
156 'not null' => TRUE,
157 'default' => '',
158 'description' => 'The module which created the vocabulary.',
159 ),
160 'weight' => array(
161 'type' => 'int',
162 'not null' => TRUE,
163 'default' => 0,
164 'description' => 'The weight of this vocabulary in relation to other vocabularies.',
165 ),
166 ),
167 'primary key' => array('vid'),
168 'indexes' => array(
169 'list' => array('weight', 'name'),
170 ),
171 'unique keys' => array(
172 'machine_name' => array('machine_name'),
173 ),
174 );
175
176 $schema['taxonomy_index'] = array(
177 'description' => 'Maintains denormalized information about node/term relationships.',
178 'fields' => array(
179 'nid' => array(
180 'description' => 'The {node}.nid this record tracks.',
181 'type' => 'int',
182 'unsigned' => TRUE,
183 'not null' => TRUE,
184 'default' => 0,
185 ),
186 'tid' => array(
187 'description' => 'The term ID.',
188 'type' => 'int',
189 'unsigned' => TRUE,
190 'not null' => TRUE,
191 'default' => 0,
192 ),
193 'sticky' => array(
194 'description' => 'Boolean indicating whether the node is sticky.',
195 'type' => 'int',
196 'not null' => FALSE,
197 'default' => 0,
198 'size' => 'tiny',
199 ),
200 'created' => array(
201 'description' => 'The Unix timestamp when the node was created.',
202 'type' => 'int',
203 'not null' => TRUE,
204 'default'=> 0,
205 ),
206 ),
207 'indexes' => array(
208 'term_node' => array('tid', 'sticky', 'created'),
209 'nid' => array('nid'),
210 ),
211 'foreign keys' => array(
212 'tracked_node' => array(
213 'table' => 'node',
214 'columns' => array('nid' => 'nid'),
215 ),
216 'term' => array(
217 'table' => 'taxonomy_term_data',
218 'columns' => array('tid' => 'tid'),
219 ),
220 ),
221 );
222
223 return $schema;
224 }
225
229 function taxonomy_field_schema($field) {
230 return array(
231 'columns' => array(
232 'tid' => array(
233 'type' => 'int',
234 'unsigned' => TRUE,
235 'not null' => FALSE,
236 ),
237 ),
238 'indexes' => array(
239 'tid' => array('tid'),
240 ),
241 'foreign keys' => array(
242 'tid' => array(
243 'table' => 'taxonomy_term_data',
244 'columns' => array('tid' => 'tid'),
245 ),
246 ),
247 );
248 }
249
253 function taxonomy_update_dependencies() {
254 // taxonomy_update_7004() migrates taxonomy term data to fields and therefore
255 // must run after all Field modules have been enabled, which happens in
256 // system_update_7027().
257 $dependencies['taxonomy'][7004] = array(
258 'system' => 7027,
259 );
260
261 return $dependencies;
262 }
263
271 function _update_7002_taxonomy_get_vocabularies() {
272 return db_query('SELECT v.* FROM {taxonomy_vocabulary} v ORDER BY v.weight, v.name')->fetchAllAssoc('vid', PDO::FETCH_OBJ);
273 }
274
278 function taxonomy_update_7001() {
279 db_rename_table('term_data', 'taxonomy_term_data');
280 db_rename_table('term_hierarchy', 'taxonomy_term_hierarchy');
281 db_rename_table('term_node', 'taxonomy_term_node');
282 db_rename_table('term_relation', 'taxonomy_term_relation');
283 db_rename_table('term_synonym', 'taxonomy_term_synonym');
284 db_rename_table('vocabulary', 'taxonomy_vocabulary');
285 db_rename_table('vocabulary_node_types', 'taxonomy_vocabulary_node_type');
286 }
287
291 function taxonomy_update_7002() {
292 $field = array(
293 'type' => 'varchar',
294 'length' => 255,
295 'not null' => TRUE,
296 'default' => '',
297 'description' => 'The vocabulary machine name.',
298 );
299
300 db_add_field('taxonomy_vocabulary', 'machine_name', $field);
301
302 // Do a direct query here, rather than calling taxonomy_get_vocabularies(),
303 // in case Taxonomy module is disabled.
304 $vids = db_query('SELECT vid FROM {taxonomy_vocabulary}')->fetchCol();
305 foreach ($vids as $vid) {
306 $machine_name = 'vocabulary_' . $vid;
307 db_update('taxonomy_vocabulary')
308 ->fields(array('machine_name' => $machine_name))
309 ->condition('vid', $vid)
310 ->execute();
311 }
312
313 // The machine_name unique key can only be added after we ensure the
314 // machine_name column contains unique values.
315 db_add_unique_key('taxonomy_vocabulary', 'machine_name', array('machine_name'));
316 }
317
324 function taxonomy_update_7003() {
325 db_drop_field('taxonomy_vocabulary', 'relations');
326 }
327
331 function taxonomy_update_7004() {
332 $taxonomy_index = array(
333 'description' => 'Maintains denormalized information about node/term relationships.',
334 'fields' => array(
335 'nid' => array(
336 'description' => 'The {node}.nid this record tracks.',
337 'type' => 'int',
338 'unsigned' => TRUE,
339 'not null' => TRUE,
340 'default' => 0,
341 ),
342 'tid' => array(
343 'description' => 'The term ID.',
344 'type' => 'int',
345 'unsigned' => TRUE,
346 'not null' => TRUE,
347 'default' => 0,
348 ),
349 'sticky' => array(
350 'description' => 'Boolean indicating whether the node is sticky.',
351 'type' => 'int',
352 'not null' => FALSE,
353 'default' => 0,
354 'size' => 'tiny',
355 ),
356 'created' => array(
357 'description' => 'The Unix timestamp when the node was created.',
358 'type' => 'int',
359 'unsigned' => TRUE,
360 'not null' => TRUE,
361 'default'=> 0,
362 ),
363 ),
364 'indexes' => array(
365 'term_node' => array('tid', 'sticky', 'created'),
366 'nid' => array('nid'),
367 ),
368 'foreign keys' => array(
369 'tracked_node' => array(
370 'table' => 'node',
371 'columns' => array('nid' => 'nid'),
372 ),
373 'term' => array(
374 'table' => 'taxonomy_term_data',
375 'columns' => array('tid' => 'tid'),
376 ),
377 ),
378 );
379 db_create_table('taxonomy_index', $taxonomy_index);
380
381 // Use an inline version of Drupal 6 taxonomy_get_vocabularies() here since
382 // we can no longer rely on $vocabulary->nodes from the API function.
383 $result = db_query('SELECT v.*, n.type FROM {taxonomy_vocabulary} v LEFT JOIN {taxonomy_vocabulary_node_type} n ON v.vid = n.vid ORDER BY v.weight, v.name');
384 $vocabularies = array();
385 foreach ($result as $record) {
386 // If no node types are associated with a vocabulary, the LEFT JOIN will
387 // return a NULL value for type.
388 if (isset($record->type)) {
389 $node_types[$record->vid][$record->type] = $record->type;
390 unset($record->type);
391 $record->nodes = $node_types[$record->vid];
392 }
393 elseif (!isset($record->nodes)) {
394 $record->nodes = array();
395 }
396 $vocabularies[$record->vid] = $record;
397 }
398
399 foreach ($vocabularies as $vocabulary) {
400 $field_name = 'taxonomy_' . $vocabulary->machine_name;
401 $field = array(
402 'field_name' => $field_name,
403 'module' => 'taxonomy',
404 'type' => 'taxonomy_term_reference',
405 'cardinality' => $vocabulary->multiple || $vocabulary->tags ? FIELD_CARDINALITY_UNLIMITED : 1,
406 'settings' => array(
407 'required' => $vocabulary->required ? TRUE : FALSE,
408 'allowed_values' => array(
409 array(
410 'vocabulary' => $vocabulary->machine_name,
411 'parent' => 0,
412 ),
413 ),
414 ),
415 );
416 _update_7000_field_create_field($field);
417
418 foreach ($vocabulary->nodes as $bundle) {
419 $instance = array(
420 'label' => $vocabulary->name,
421 'field_name' => $field_name,
422 'bundle' => $bundle,
423 'entity_type' => 'node',
424 'settings' => array(),
425 'description' => $vocabulary->help,
426 'required' => $vocabulary->required,
427 'widget' => array(),
428 'display' => array(
429 'default' => array(
430 'type' => 'taxonomy_term_reference_link',
431 'weight' => 10,
432 ),
433 'teaser' => array(
434 'type' => 'taxonomy_term_reference_link',
435 'weight' => 10,
436 ),
437 ),
438 );
439 if ($vocabulary->tags) {
440 $instance['widget'] = array(
441 'type' => 'taxonomy_autocomplete',
442 'module' => 'taxonomy',
443 'settings' => array(
444 'size' => 60,
445 'autocomplete_path' => 'taxonomy/autocomplete',
446 ),
447 );
448 }
449 else {
450 $instance['widget'] = array(
451 'type' => 'select',
452 'module' => 'options',
453 'settings' => array(),
454 );
455 }
456 _update_7000_field_create_instance($field, $instance);
457 }
458 }
459
460 // Some contrib projects stored term node associations without regard for the
461 // selections in the taxonomy_vocabulary_node_types table, or have more terms
462 // for a single node than the vocabulary allowed. We construct the
463 // taxonomyextra field to store all the extra stuff.
464
465 // Allowed values for this extra vocabs field is every vocabulary.
466 $allowed_values = array();
467 foreach (_update_7002_taxonomy_get_vocabularies() as $vocabulary) {
468 $allowed_values[] = array(
469 'vocabulary' => $vocabulary->machine_name,
470 'parent' => 0,
471 );
472 }
473
474 $field_name = 'taxonomyextra';
475 $field = array(
476 'field_name' => $field_name,
477 'module' => 'taxonomy',
478 'type' => 'taxonomy_term_reference',
479 'cardinality' => FIELD_CARDINALITY_UNLIMITED,
480 'settings' => array(
481 'required' => FALSE,
482 'allowed_values' => $allowed_values,
483 ),
484 );
485 _update_7000_field_create_field($field);
486
487 foreach (_update_7000_node_get_types() as $bundle) {
488 $instance = array(
489 'label' => 'Taxonomy upgrade extras',
490 'field_name' => $field_name,
491 'entity_type' => 'node',
492 'bundle' => $bundle->type,
493 'settings' => array(),
494 'description' => 'Debris left over after upgrade from Drupal 6',
495 'widget' => array(
496 'type' => 'taxonomy_autocomplete',
497 'module' => 'taxonomy',
498 'settings' => array(),
499 ),
500 'display' => array(
501 'default' => array(
502 'type' => 'taxonomy_term_reference_link',
503 'weight' => 10,
504 ),
505 'teaser' => array(
506 'type' => 'taxonomy_term_reference_link',
507 'weight' => 10,
508 ),
509 ),
510 );
511 _update_7000_field_create_instance($field, $instance);
512 }
513
514 $fields = array('help', 'multiple', 'required', 'tags');
515 foreach ($fields as $field) {
516 db_drop_field('taxonomy_vocabulary', $field);
517 }
518 }
519
526 function taxonomy_update_7005(&$sandbox) {
527 // $sandbox contents:
528 // - total: The total number of term_node relationships to migrate.
529 // - count: The number of term_node relationships that have been
530 // migrated so far.
531 // - last: The db_query_range() offset to use when querying
532 // term_node; this field is incremented in quantities of $batch
533 // (1000) but at the end of each call to this function, last and
534 // count are the same.
535 // - vocabularies: An associative array mapping vocabulary id and node
536 // type to field name. If a voc id/node type pair does not appear
537 // in this array but a term_node relationship exists mapping a
538 // term in voc id to node of that type, the relationship is
539 // assigned to the taxonomymyextra field which allows terms of all
540 // vocabularies.
541 // - cursor[values], cursor[deltas]: The contents of $values and
542 // $deltas at the end of the previous call to this function. These
543 // need to be preserved across calls because a single batch of
544 // 1000 rows from term_node may end in the middle of the terms for
545 // a single node revision.
546 //
547 // $values is the array of values about to be/most recently inserted
548 // into the SQL data table for the taxonomy_term_reference
549 // field. Before $values is constructed for each record, the
550 // $values from the previous insert is checked to see if the two
551 // records are for the same node revision id; this enables knowing
552 // when to reset the delta counters which are incremented across all
553 // terms for a single field on a single revision, but reset for each
554 // new field and revision.
555 //
556 // $deltas is an associative array mapping field name to the number
557 // of term references stored so far for the current revision, which
558 // provides the delta value for each term reference data insert. The
559 // deltas are reset for each new revision.
560
561 $conditions = array(
562 'type' => 'taxonomy_term_reference',
563 'deleted' => 0,
564 );
565 $field_info = _update_7000_field_read_fields($conditions, 'field_name');
566
567 // This is a multi-pass update. On the first call we need to initialize some
568 // variables.
569 if (!isset($sandbox['total'])) {
570 $sandbox['last'] = 0;
571 $sandbox['count'] = 0;
572
573 // Run the same joins as the query that is used later to retrieve the
574 // term_node data, this ensures that bad records in that table - for
575 // tids which aren't in taxonomy_term_data or nids which aren't in {node}
576 // are not included in the count.
577 $sandbox['total'] = db_query('SELECT COUNT(*) FROM {taxonomy_term_data} td INNER JOIN {taxonomy_term_node} tn ON td.tid = tn.tid INNER JOIN {node} n ON tn.nid = n.nid LEFT JOIN {node} n2 ON tn.vid = n2.vid')->fetchField();
578
579 // Use an inline version of Drupal 6 taxonomy_get_vocabularies() here since
580 // we can no longer rely on $vocabulary->nodes from the API function.
581 $result = db_query('SELECT v.vid, v.machine_name, n.type FROM {taxonomy_vocabulary} v INNER JOIN {taxonomy_vocabulary_node_type} n ON v.vid = n.vid');
582 $vocabularies = array();
583 foreach ($result as $record) {
584
585 // If no node types are associated with a vocabulary, the LEFT JOIN will
586 // return a NULL value for type.
587 if (isset($record->type)) {
588 $vocabularies[$record->vid][$record->type] = 'taxonomy_'. $record->machine_name;
589 }
590 }
591
592 if (!empty($vocabularies)) {
593 $sandbox['vocabularies'] = $vocabularies;
594 }
595
596 db_create_table('taxonomy_update_7005', array(
597 'description' => 'Stores temporary data for taxonomy_update_7005.',
598 'fields' => array(
599 'n' => array(
600 'description' => 'Preserve order.',
601 'type' => 'serial',
602 'unsigned' => TRUE,
603 'not null' => TRUE,
604 ),
605 'vocab_id' => array(
606 'type' => 'int',
607 'unsigned' => TRUE,
608 'not null' => TRUE,
609 'default' => 0,
610 ),
611 'tid' => array(
612 'type' => 'int',
613 'unsigned' => TRUE,
614 'not null' => TRUE,
615 ),
616 'nid' => array(
617 'type' => 'int',
618 'unsigned' => TRUE,
619 'not null' => TRUE,
620 ),
621 'vid' => array(
622 'type' => 'int',
623 'unsigned' => TRUE,
624 'not null' => FALSE,
625 'default' => NULL,
626 ),
627 'type' => array(
628 'type' => 'varchar',
629 'length' => 32,
630 'not null' => TRUE,
631 'default' => '',
632 ),
633 'created' => array(
634 'type' => 'int',
635 'not null' => FALSE,
636 ),
637 'sticky' => array(
638 'type' => 'int',
639 'not null' => FALSE,
640 ),
641 'status' => array(
642 'type' => 'int',
643 'not null' => FALSE,
644 ),
645 'is_current' => array(
646 'type' => 'int',
647 'unsigned' => TRUE,
648 'not null' => FALSE,
649 ),
650 ),
651 'primary key' => array('n'),
652 ));
653
654 // Query selects all revisions at once and processes them in revision and
655 // term weight order.
656 $query = db_select('taxonomy_term_data', 'td');
657 // We are migrating term-node relationships. If there are none for a
658 // term, we do not need the term_data row.
659 $query->join('taxonomy_term_node', 'tn', 'td.tid = tn.tid');
660 // If a term-node relationship exists for a nid that does not exist, we
661 // cannot migrate it as we have no node to relate it to; thus we do not
662 // need that row from term_node.
663 $query->join('node', 'n', 'tn.nid = n.nid');
664 // If the current term-node relationship is for the current revision of
665 // the node, this left join will match and is_current will be non-NULL
666 // (we also get the current sticky and created in this case). This
667 // tells us whether to insert into the current data tables in addition
668 // to the revision data tables.
669 $query->leftJoin('node', 'n2', 'tn.vid = n2.vid');
670 $query->addField('td', 'vid', 'vocab_id');
671 $query->addField('td', 'tid');
672 $query->addField('tn', 'nid');
673 $query->addField('tn', 'vid');
674 $query->addField('n', 'type');
675 $query->addField('n2', 'created');
676 $query->addField('n2', 'sticky');
677 $query->addField('n2', 'status');
678 $query->addField('n2', 'nid', 'is_current');
679 // This query must return a consistent ordering across multiple calls.
680 // We need them ordered by node vid (since we use that to decide when
681 // to reset the delta counters) and by term weight so they appear
682 // within each node in weight order. However, tn.vid,td.weight is not
683 // guaranteed to be unique, so we add tn.tid as an additional sort key
684 // because tn.tid,tn.vid is the primary key of the D6 term_node table
685 // and so is guaranteed unique. Unfortunately it also happens to be in
686 // the wrong order which is less efficient, but c'est la vie.
687 $query->orderBy('tn.vid');
688 $query->orderBy('td.weight');
689 $query->orderBy('tn.tid');
690
691 // Work around a bug in the PostgreSQL driver that would result in fatal
692 // errors when this subquery is used in the insert query below. See
693 // https://drupal.org/node/2057693.
694 $fields = &$query->getFields();
695 unset($fields['td.weight']);
696 unset($fields['tn.tid']);
697
698 db_insert('taxonomy_update_7005')
699 ->from($query)
700 ->execute();
701 }
702 else {
703 // We do each pass in batches of 1000.
704 $batch = 1000;
705
706 $result = db_query_range('SELECT vocab_id, tid, nid, vid, type, created, sticky, status, is_current FROM {taxonomy_update_7005} ORDER BY n', $sandbox['last'], $batch);
707 if (isset($sandbox['cursor'])) {
708 $values = $sandbox['cursor']['values'];
709 $deltas = $sandbox['cursor']['deltas'];
710 }
711 else {
712 $deltas = array();
713 }
714 foreach ($result as $record) {
715 $sandbox['count'] += 1;
716
717 // Use the valid field for this vocabulary and node type or use the
718 // overflow vocabulary if there is no valid field.
719 $field_name = isset($sandbox['vocabularies'][$record->vocab_id][$record->type]) ? $sandbox['vocabularies'][$record->vocab_id][$record->type] : 'taxonomyextra';
720 $field = $field_info[$field_name];
721
722 // Start deltas from 0, and increment by one for each term attached to a
723 // node.
724 if (!isset($deltas[$field_name])) {
725 $deltas[$field_name] = 0;
726 }
727
728 if (isset($values)) {
729
730 // If the last inserted revision_id is the same as the current record,
731 // use the previous deltas to calculate the next delta.
732 if ($record->vid == $values[2]) {
733
734 // For limited cardinality fields, the delta must not be allowed to
735 // exceed the cardinality during the update. So ensure that the
736 // delta about to be inserted is within this limit.
737 // @see field_default_validate().
738 if ($field['cardinality'] != FIELD_CARDINALITY_UNLIMITED && ($deltas[$field_name] + 1) > $field['cardinality']) {
739
740 // For excess values of a single-term vocabulary, switch over to
741 // the overflow field.
742 $field_name = 'taxonomyextra';
743 $field = $field_info[$field_name];
744 if (!isset($deltas[$field_name])) {
745 $deltas[$field_name] = 0;
746 }
747 }
748 }
749 else {
750
751 // When the record is a new revision, empty the deltas array.
752 $deltas = array($field_name => 0);
753 }
754 }
755
756 // Table and column found in the field's storage details. During upgrades,
757 // it's always SQL.
758 $table_name = "field_data_{$field_name}";
759 $revision_name = "field_revision_{$field_name}";
760 $value_column = $field_name . '_tid';
761
762 // Column names and values in field storage are the same for current and
763 // revision.
764 $columns = array('entity_type', 'entity_id', 'revision_id', 'bundle', 'language', 'delta', $value_column);
765 $values = array('node', $record->nid, $record->vid, $record->type, LANGUAGE_NONE, $deltas[$field_name]++, $record->tid);
766
767 // Insert rows into the revision table.
768 db_insert($revision_name)->fields($columns)->values($values)->execute();
769
770 // is_current column is a node ID if this revision is also current.
771 if ($record->is_current) {
772 db_insert($table_name)->fields($columns)->values($values)->execute();
773 // Only insert a record in the taxonomy index if the node is published.
774 if ($record->status) {
775 // Update the {taxonomy_index} table.
776 db_insert('taxonomy_index')
777 ->fields(array('nid', 'tid', 'sticky', 'created',))
778 ->values(array($record->nid, $record->tid, $record->sticky, $record->created))
779 ->execute();
780 }
781 }
782 }
783
784 // Store the set of inserted values and the current revision's deltas in the
785 // sandbox.
786 $sandbox['cursor'] = array(
787 'values' => $values,
788 'deltas' => $deltas,
789 );
790 $sandbox['last'] += $batch;
791 }
792
793 if ($sandbox['count'] < $sandbox['total']) {
794 $sandbox['#finished'] = FALSE;
795 }
796 else {
797 db_drop_table('taxonomy_vocabulary_node_type');
798 db_drop_table('taxonomy_term_node');
799
800 // If there are no vocabs, we're done.
801 db_drop_table('taxonomy_update_7005');
802 $sandbox['#finished'] = TRUE;
803
804 // Determine necessity of taxonomyextras field.
805 $field = $field_info['taxonomyextra'];
806 $revision_name = 'field_revision_' . $field['field_name'];
807 $node_types = db_select($revision_name)->distinct()->fields($revision_name, array('bundle'))
808 ->execute()->fetchCol();
809
810 if (empty($node_types)) {
811 // Delete the overflow field if there are no rows in the revision table.
812 _update_7000_field_delete_field('taxonomyextra');
813 }
814 else {
815 // Remove instances which are not actually used.
816 $bundles = db_query('SELECT bundle FROM {field_config_instance} WHERE field_name = :field_name', array(':field_name' => 'taxonomyextra'))->fetchCol();
817 $bundles = array_diff($bundles, $node_types);
818 foreach ($bundles as $bundle) {
819 _update_7000_field_delete_instance('taxonomyextra', 'node', $bundle);
820 }
821 }
822 }
823 }
824
828 function taxonomy_update_7006() {
829 db_add_field('taxonomy_term_data', 'format', array(
830 'type' => 'int',
831 'unsigned' => TRUE,
832 'not null' => FALSE,
833 'description' => 'The {filter_format}.format of the description.',
834 ));
835 }
836
840 function taxonomy_update_7007() {
841 db_add_index('taxonomy_term_data', 'name', array('name'));
842 }
843
847 function taxonomy_update_7008() {
848 db_drop_index('taxonomy_term_data', 'taxonomy_tree');
849 db_change_field('taxonomy_term_data', 'weight', 'weight', array(
850 'type' => 'int',
851 'not null' => TRUE,
852 'default' => 0,
853 'description' => 'The weight of this term in relation to other terms.',
854 ), array(
855 'indexes' => array(
856 'taxonomy_tree' => array('vid', 'weight', 'name'),
857 ),
858 ));
859
860 db_drop_index('taxonomy_vocabulary', 'list');
861 db_change_field('taxonomy_vocabulary', 'weight', 'weight', array(
862 'type' => 'int',
863 'not null' => TRUE,
864 'default' => 0,
865 'description' => 'The weight of this vocabulary in relation to other vocabularies.',
866 ), array(
867 'indexes' => array(
868 'list' => array('weight', 'name'),
869 ),
870 ));
871 }
872
876 function taxonomy_update_7009() {
877 db_change_field('taxonomy_term_data', 'format', 'format', array(
878 'type' => 'varchar',
879 'length' => 255,
880 'not null' => FALSE,
881 'description' => 'The {filter_format}.format of the description.',
882 ));
883 }
884
888 function taxonomy_update_7010() {
889 db_change_field('taxonomy_index', 'created', 'created', array(
890 'description' => 'The Unix timestamp when the node was created.',
891 'type' => 'int',
892 'unsigned' => FALSE,
893 'not null' => TRUE,
894 'default'=> 0,
895 ));
896 }
897
906 function taxonomy_update_7011() {
907 $nids = db_query('SELECT nid from {node} WHERE status = :status', array(':status' => NODE_NOT_PUBLISHED))->fetchCol();
908 if (!empty($nids)) {
909 db_delete('taxonomy_index')
910 ->condition('nid', $nids)
911 ->execute();
912 }
913 }
914
taxonomy_update_7004
taxonomy_update_7004()
Definition: taxonomy.install:331
taxonomy_field_schema
taxonomy_field_schema($field)
Definition: taxonomy.install:229
db_add_index
db_add_index($table, $name, $fields)
Definition: database.inc:2940
taxonomy_update_7005
taxonomy_update_7005(&$sandbox)
Definition: taxonomy.install:526
taxonomy_update_7003
taxonomy_update_7003()
Definition: taxonomy.install:324
taxonomy_update_7007
taxonomy_update_7007()
Definition: taxonomy.install:840
_update_7000_field_delete_field
_update_7000_field_delete_field($field_name)
Definition: field.install:258
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
db_drop_index
db_drop_index($table, $name)
Definition: database.inc:2952
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
_update_7000_field_read_fields
_update_7000_field_read_fields(array $conditions=array(), $key= 'id')
Definition: field.install:328
db_add_field
db_add_field($table, $field, $spec, $keys_new=array())
Definition: database.inc:2840
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
db_add_unique_key
db_add_unique_key($table, $name, $fields)
Definition: database.inc:2914
db_drop_field
db_drop_field($table, $field)
Definition: database.inc:2852
taxonomy_update_7008
taxonomy_update_7008()
Definition: taxonomy.install:847
NODE_NOT_PUBLISHED
const NODE_NOT_PUBLISHED
Definition: node.module:12
taxonomy_update_dependencies
taxonomy_update_dependencies()
Definition: taxonomy.install:253
taxonomy_uninstall
taxonomy_uninstall()
Definition: taxonomy.install:11
taxonomy_update_7010
taxonomy_update_7010()
Definition: taxonomy.install:888
taxonomy_update_7002
taxonomy_update_7002()
Definition: taxonomy.install:291
_update_7000_field_create_instance
_update_7000_field_create_instance($field, &$instance)
Definition: field.install:363
taxonomy_schema
taxonomy_schema()
Definition: taxonomy.install:25
FIELD_CARDINALITY_UNLIMITED
const FIELD_CARDINALITY_UNLIMITED
Definition: field.module:236
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
_update_7000_node_get_types
_update_7000_node_get_types()
Definition: node.install:480
field_attach_delete_bundle
field_attach_delete_bundle($entity_type, $bundle)
Definition: field.attach.inc:1394
_update_7002_taxonomy_get_vocabularies
_update_7002_taxonomy_get_vocabularies()
Definition: taxonomy.install:271
_update_7000_field_delete_instance
_update_7000_field_delete_instance($field_name, $entity_type, $bundle)
Definition: field.install:289
taxonomy_update_7009
taxonomy_update_7009()
Definition: taxonomy.install:876
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
taxonomy_update_7006
taxonomy_update_7006()
Definition: taxonomy.install:828
_update_7000_field_create_field
_update_7000_field_create_field(&$field)
Definition: field.install:177
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
taxonomy_update_7001
taxonomy_update_7001()
Definition: taxonomy.install:278
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
taxonomy_update_7011
taxonomy_update_7011()
Definition: taxonomy.install:906
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
db_rename_table
db_rename_table($table, $new_name)
Definition: database.inc:2805
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum.pages.inc Source File

  • modules
  • forum
forum.pages.inc
Go to the documentation of this file.
1 <?php
2
20 function forum_page($forum_term = NULL) {
21 if (!isset($forum_term)) {
22 // On the main page, display all the top-level forums.
23 $forum_term = forum_forum_load(0);
24 }
25
26 $forum_per_page = variable_get('forum_per_page', 25);
27 $sortby = variable_get('forum_order', 1);
28
29 if (empty($forum_term->container)) {
30 $topics = forum_get_topics($forum_term->tid, $sortby, $forum_per_page);
31 }
32 else {
33 $topics = '';
34 }
35
36 return theme('forums', array('forums' => $forum_term->forums, 'topics' => $topics, 'parents' => $forum_term->parents, 'tid' => $forum_term->tid, 'sortby' => $sortby, 'forums_per_page' => $forum_per_page));
37 }
forum_get_topics
forum_get_topics($tid, $sortby, $forum_per_page)
Definition: forum.module:914
$topics
if($forums_defined) print $topics
Definition: forums.tpl.php:19
forum_page
forum_page($forum_term=NULL)
Definition: forum.pages.inc:20
forum_forum_load
forum_forum_load($tid=NULL)
Definition: forum.module:765
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/statistics/statistics.admin.inc Source File

  • modules
  • statistics
statistics.admin.inc
Go to the documentation of this file.
1 <?php
2
18 function statistics_recent_hits() {
19 $header = array(
20 array('data' => t('Timestamp'), 'field' => 'a.timestamp', 'sort' => 'desc'),
21 array('data' => t('Page'), 'field' => 'a.path'),
22 array('data' => t('User'), 'field' => 'u.name'),
23 array('data' => t('Operations'))
24 );
25
26 $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
27 $query->join('users', 'u', 'a.uid = u.uid');
28 $query
29 ->fields('a', array('aid', 'timestamp', 'path', 'title', 'uid'))
30 ->fields('u', array('name'))
31 ->limit(30)
32 ->orderByHeader($header);
33
34 $result = $query->execute();
35 $rows = array();
36 foreach ($result as $log) {
37 $rows[] = array(
38 array('data' => format_date($log->timestamp, 'short'), 'class' => array('nowrap')),
39 _statistics_format_item($log->title, $log->path),
40 theme('username', array('account' => $log)),
41 l(t('details'), "admin/reports/access/$log->aid"));
42 }
43
44 $build['statistics_table'] = array(
45 '#theme' => 'table',
46 '#header' => $header,
47 '#rows' => $rows,
48 '#empty' => t('No statistics available.'),
49 );
50 $build['statistics_pager'] = array('#theme' => 'pager');
51 return $build;
52 }
53
64 function statistics_top_pages() {
65 $header = array(
66 array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
67 array('data' => t('Page'), 'field' => 'path'),
68 array('data' => t('Average page generation time'), 'field' => 'average_time'),
69 array('data' => t('Total page generation time'), 'field' => 'total_time')
70 );
71
72 $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
73 $query->addExpression('COUNT(path)', 'hits');
74 // MAX(title) avoids having empty node titles which otherwise causes
75 // duplicates in the top pages list.
76 $query->addExpression('MAX(title)', 'title');
77 $query->addExpression('AVG(timer)', 'average_time');
78 $query->addExpression('SUM(timer)', 'total_time');
79
80 $query
81 ->fields('a', array('path'))
82 ->groupBy('path')
83 ->limit(30)
84 ->orderByHeader($header);
85
86 $count_query = db_select('accesslog', 'a', array('target' => 'slave'));
87 $count_query->addExpression('COUNT(DISTINCT path)');
88 $query->setCountQuery($count_query);
89
90 $result = $query->execute();
91 $rows = array();
92 foreach ($result as $page) {
93 $rows[] = array($page->hits, _statistics_format_item($page->title, $page->path), t('%time ms', array('%time' => round($page->average_time))), format_interval(round($page->total_time / 1000)));
94 }
95
96 drupal_set_title(t('Top pages in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))), PASS_THROUGH);
97 $build['statistics_top_pages_table'] = array(
98 '#theme' => 'table',
99 '#header' => $header,
100 '#rows' => $rows,
101 '#empty' => t('No statistics available.'),
102 );
103 $build['statistics_top_pages_pager'] = array('#theme' => 'pager');
104 return $build;
105 }
106
117 function statistics_top_visitors() {
118
119 $header = array(
120 array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
121 array('data' => t('Visitor'), 'field' => 'u.name'),
122 array('data' => t('Total page generation time'), 'field' => 'total'),
123 array('data' => user_access('block IP addresses') ? t('Operations') : '', 'colspan' => 2),
124 );
125 $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
126 $query->leftJoin('blocked_ips', 'bl', 'a.hostname = bl.ip');
127 $query->leftJoin('users', 'u', 'a.uid = u.uid');
128
129 $query->addExpression('COUNT(a.uid)', 'hits');
130 $query->addExpression('SUM(a.timer)', 'total');
131 $query
132 ->fields('a', array('uid', 'hostname'))
133 ->fields('u', array('name'))
134 ->fields('bl', array('iid'))
135 ->groupBy('a.hostname')
136 ->groupBy('a.uid')
137 ->groupBy('u.name')
138 ->groupBy('bl.iid')
139 ->limit(30)
140 ->orderByHeader($header);
141
142 $uniques_query = db_select('accesslog')->distinct();
143 $uniques_query->fields('accesslog', array('uid', 'hostname'));
144 $count_query = db_select($uniques_query);
145 $count_query->addExpression('COUNT(*)');
146 $query->setCountQuery($count_query);
147
148 $result = $query->execute();
149 $rows = array();
150 $destination = drupal_get_destination();
151 foreach ($result as $account) {
152 $ban_link = $account->iid ? l(t('unblock IP address'), "admin/config/people/ip-blocking/delete/$account->iid", array('query' => $destination)) : l(t('block IP address'), "admin/config/people/ip-blocking/$account->hostname", array('query' => $destination));
153 $rows[] = array($account->hits, ($account->uid ? theme('username', array('account' => $account)) : $account->hostname), format_interval(round($account->total / 1000)), (user_access('block IP addresses') && !$account->uid) ? $ban_link : '');
154 }
155
156 drupal_set_title(t('Top visitors in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))), PASS_THROUGH);
157 $build['statistics_top_visitors_table'] = array(
158 '#theme' => 'table',
159 '#header' => $header,
160 '#rows' => $rows,
161 '#empty' => t('No statistics available.'),
162 );
163 $build['statistics_top_visitors_pager'] = array('#theme' => 'pager');
164 return $build;
165 }
166
177 function statistics_top_referrers() {
178 drupal_set_title(t('Top referrers in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))), PASS_THROUGH);
179
180 $header = array(
181 array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
182 array('data' => t('Url'), 'field' => 'url'),
183 array('data' => t('Last visit'), 'field' => 'last'),
184 );
185 $query = db_select('accesslog', 'a')->extend('PagerDefault')->extend('TableSort');
186
187 $query->addExpression('COUNT(url)', 'hits');
188 $query->addExpression('MAX(timestamp)', 'last');
189 $query
190 ->fields('a', array('url'))
191 ->condition('url', '%' . $_SERVER['HTTP_HOST'] . '%', 'NOT LIKE')
192 ->condition('url', '', '<>')
193 ->groupBy('url')
194 ->limit(30)
195 ->orderByHeader($header);
196
197 $count_query = db_select('accesslog', 'a', array('target' => 'slave'));
198 $count_query->addExpression('COUNT(DISTINCT url)');
199 $count_query
200 ->condition('url', '%' . $_SERVER['HTTP_HOST'] . '%', 'NOT LIKE')
201 ->condition('url', '', '<>');
202 $query->setCountQuery($count_query);
203
204 $result = $query->execute();
205 $rows = array();
206 foreach ($result as $referrer) {
207 $rows[] = array($referrer->hits, _statistics_link($referrer->url), t('@time ago', array('@time' => format_interval(REQUEST_TIME - $referrer->last))));
208 }
209
210 $build['statistics_top_referrers_table'] = array(
211 '#theme' => 'table',
212 '#header' => $header,
213 '#rows' => $rows,
214 '#empty' => t('No statistics available.'),
215 );
216 $build['statistics_top_referrers_pager'] = array('#theme' => 'pager');
217 return $build;
218 }
219
230 function statistics_access_log($aid) {
231 $access = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE aid = :aid', array(':aid' => $aid))->fetch();
232 if ($access) {
233 $rows[] = array(
234 array('data' => t('URL'), 'header' => TRUE),
235 l(url($access->path, array('absolute' => TRUE)), $access->path)
236 );
237 // It is safe to avoid filtering $access->title through check_plain because
238 // it comes from drupal_get_title().
239 $rows[] = array(
240 array('data' => t('Title'), 'header' => TRUE),
241 $access->title
242 );
243 $rows[] = array(
244 array('data' => t('Referrer'), 'header' => TRUE),
245 ($access->url ? l($access->url, $access->url) : '')
246 );
247 $rows[] = array(
248 array('data' => t('Date'), 'header' => TRUE),
249 format_date($access->timestamp, 'long')
250 );
251 $rows[] = array(
252 array('data' => t('User'), 'header' => TRUE),
253 theme('username', array('account' => $access))
254 );
255 $rows[] = array(
256 array('data' => t('Hostname'), 'header' => TRUE),
257 check_plain($access->hostname)
258 );
259
260 $build['statistics_table'] = array(
261 '#theme' => 'table',
262 '#rows' => $rows,
263 );
264 return $build;
265 }
266 return MENU_NOT_FOUND;
267 }
268
275 function statistics_settings_form() {
276 // Access log settings.
277 $form['access'] = array(
278 '#type' => 'fieldset',
279 '#title' => t('Access log settings'),
280 );
281 $form['access']['statistics_enable_access_log'] = array(
282 '#type' => 'checkbox',
283 '#title' => t('Enable access log'),
284 '#default_value' => variable_get('statistics_enable_access_log', 0),
285 '#description' => t('Log each page access. Required for referrer statistics.'),
286 );
287 $form['access']['statistics_flush_accesslog_timer'] = array(
288 '#type' => 'select',
289 '#title' => t('Discard access logs older than'),
290 '#default_value' => variable_get('statistics_flush_accesslog_timer', 259200),
291 '#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval'),
292 '#description' => t('Older access log entries (including referrer statistics) will be automatically discarded. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array('@cron' => url('admin/reports/status'))),
293 );
294
295 // Content counter settings.
296 $form['content'] = array(
297 '#type' => 'fieldset',
298 '#title' => t('Content viewing counter settings'),
299 );
300 $form['content']['statistics_count_content_views'] = array(
301 '#type' => 'checkbox',
302 '#title' => t('Count content views'),
303 '#default_value' => variable_get('statistics_count_content_views', 0),
304 '#description' => t('Increment a counter each time content is viewed.'),
305 );
306 $form['content']['statistics_count_content_views_ajax'] = array(
307 '#type' => 'checkbox',
308 '#title' => t('Use Ajax to increment the counter'),
309 '#default_value' => variable_get('statistics_count_content_views_ajax', 0),
310 '#description' => t('Perform the count asynchronously after page load rather than during page generation.'),
311 '#states' => array(
312 'disabled' => array(
313 ':input[name="statistics_count_content_views"]' => array('checked' => FALSE),
314 ),
315 ),
316 );
317
318 return system_settings_form($form);
319 }
l
l($text, $path, array $options=array())
Definition: common.inc:2432
statistics_top_referrers
statistics_top_referrers()
Definition: statistics.admin.inc:177
$page
print $page
Definition: overlay.tpl.php:37
_statistics_link
_statistics_link($path, $width=35)
Definition: statistics.module:404
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
$header
print $header
Definition: forum-topic-list.tpl.php:42
format_interval
format_interval($interval, $granularity=2, $langcode=NULL)
Definition: common.inc:1908
statistics_top_visitors
statistics_top_visitors()
Definition: statistics.admin.inc:117
PASS_THROUGH
const PASS_THROUGH
Definition: bootstrap.inc:232
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
MENU_NOT_FOUND
const MENU_NOT_FOUND
Definition: menu.inc:234
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
statistics_access_log
statistics_access_log($aid)
Definition: statistics.admin.inc:230
statistics_top_pages
statistics_top_pages()
Definition: statistics.admin.inc:64
statistics_recent_hits
statistics_recent_hits()
Definition: statistics.admin.inc:18
drupal_get_destination
drupal_get_destination()
Definition: common.inc:525
user_access
user_access($string, $account=NULL)
Definition: user.module:794
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
_statistics_format_item
_statistics_format_item($title, $path)
Definition: statistics.module:421
statistics_settings_form
statistics_settings_form()
Definition: statistics.admin.inc:275
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
system_settings_form
system_settings_form($form)
Definition: system.module:2755
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/forum/forum-icon.tpl.php Source File

  • modules
  • forum
forum-icon.tpl.php
Go to the documentation of this file.
1 <?php
2
18 ?>
19 <div class="topic-status-<?php print $icon_class ?>" title="<?php print $icon_title ?>">
20 <?php if ($first_new): ?>
21 <a id="new"></a>
22 <?php endif; ?>
23
24 <span class="element-invisible"><?php print $icon_title ?></span>
25
26 </div>
print
print
Definition: php-2.php:2
endif
endif
Definition: aggregator-item.tpl.php:31
title
print $topic title
Definition: forum-topic-list.tpl.php:50
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/search/search.pages.inc Source File

  • modules
  • search
search.pages.inc
Go to the documentation of this file.
1 <?php
2
16 function search_view($module = NULL, $keys = '') {
17 $info = FALSE;
18 $keys = trim($keys);
19 // Also try to pull search keywords out of the $_REQUEST variable to
20 // support old GET format of searches for existing links.
21 if (!$keys && !empty($_REQUEST['keys'])) {
22 $keys = trim($_REQUEST['keys']);
23 }
24
25 if (!empty($module)) {
26 $active_module_info = search_get_info();
27 if (isset($active_module_info[$module])) {
28 $info = $active_module_info[$module];
29 }
30 }
31
32 if (empty($info)) {
33 // No path or invalid path: find the default module. Note that if there
34 // are no enabled search modules, this function should never be called,
35 // since hook_menu() would not have defined any search paths.
36 $info = search_get_default_module_info();
37 // Redirect from bare /search or an invalid path to the default search path.
38 $path = 'search/' . $info['path'];
39 if ($keys) {
40 $path .= '/' . $keys;
41 }
42 drupal_goto($path);
43 }
44
45 // Default results output is an empty string.
46 $results = array('#markup' => '');
47 // Process the search form. Note that if there is $_POST data,
48 // search_form_submit() will cause a redirect to search/[module path]/[keys],
49 // which will get us back to this page callback. In other words, the search
50 // form submits with POST but redirects to GET. This way we can keep
51 // the search query URL clean as a whistle.
52 if (empty($_POST['form_id']) || $_POST['form_id'] != 'search_form') {
53 $conditions = NULL;
54 if (isset($info['conditions_callback']) && function_exists($info['conditions_callback'])) {
55 // Build an optional array of more search conditions.
56 $conditions = call_user_func($info['conditions_callback'], $keys);
57 }
58 // Only search if there are keywords or non-empty conditions.
59 if ($keys || !empty($conditions)) {
60 // Log the search keys.
61 watchdog('search', 'Searched %type for %keys.', array('%keys' => $keys, '%type' => $info['title']), WATCHDOG_NOTICE, l(t('results'), 'search/' . $info['path'] . '/' . $keys));
62
63 // Collect the search results.
64 $results = search_data($keys, $info['module'], $conditions);
65 }
66 }
67 // The form may be altered based on whether the search was run.
68 $build['search_form'] = drupal_get_form('search_form', NULL, $keys, $info['module']);
69 $build['search_results'] = $results;
70
71 return $build;
72 }
73
84 function template_preprocess_search_results(&$variables) {
85 $variables['search_results'] = '';
86 if (!empty($variables['module'])) {
87 $variables['module'] = check_plain($variables['module']);
88 }
89 foreach ($variables['results'] as $result) {
90 $variables['search_results'] .= theme('search_result', array('result' => $result, 'module' => $variables['module']));
91 }
92 $variables['pager'] = theme('pager', array('tags' => NULL));
93 $variables['theme_hook_suggestions'][] = 'search_results__' . $variables['module'];
94 }
95
105 function template_preprocess_search_result(&$variables) {
106 global $language;
107
108 $result = $variables['result'];
109 $variables['url'] = check_url($result['link']);
110 $variables['title'] = check_plain($result['title']);
111 if (isset($result['language']) && $result['language'] != $language->language && $result['language'] != LANGUAGE_NONE) {
112 $variables['title_attributes_array']['xml:lang'] = $result['language'];
113 $variables['content_attributes_array']['xml:lang'] = $result['language'];
114 }
115
116 $info = array();
117 if (!empty($result['module'])) {
118 $info['module'] = check_plain($result['module']);
119 }
120 if (!empty($result['user'])) {
121 $info['user'] = $result['user'];
122 }
123 if (!empty($result['date'])) {
124 $info['date'] = format_date($result['date'], 'short');
125 }
126 if (isset($result['extra']) && is_array($result['extra'])) {
127 $info = array_merge($info, $result['extra']);
128 }
129 // Check for existence. User search does not include snippets.
130 $variables['snippet'] = isset($result['snippet']) ? $result['snippet'] : '';
131 // Provide separated and grouped meta information..
132 $variables['info_split'] = $info;
133 $variables['info'] = implode(' - ', $info);
134 $variables['theme_hook_suggestions'][] = 'search_result__' . $variables['module'];
135 }
136
143 function search_form_validate($form, &$form_state) {
144 form_set_value($form['basic']['processed_keys'], trim($form_state['values']['keys']), $form_state);
145 }
146
150 function search_form_submit($form, &$form_state) {
151 $keys = $form_state['values']['processed_keys'];
152 if ($keys == '') {
153 form_set_error('keys', t('Please enter some keywords.'));
154 // Fall through to the form redirect.
155 }
156
157 $form_state['redirect'] = $form_state['action'] . '/' . $keys;
158 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
l
l($text, $path, array $options=array())
Definition: common.inc:2432
search_view
search_view($module=NULL, $keys= '')
Definition: search.pages.inc:16
search_get_info
search_get_info($all=FALSE)
Definition: search.module:252
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
$module
print $module
Definition: search-results.tpl.php:28
check_url
check_url($uri)
Definition: common.inc:1387
$results
print $results
Definition: poll-results.tpl.php:23
search_form_validate
search_form_validate($form, &$form_state)
Definition: search.pages.inc:143
search_form_submit
search_form_submit($form, &$form_state)
Definition: search.pages.inc:150
form_set_value
form_set_value($element, $value, &$form_state)
Definition: form.inc:2531
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
$info
$info
Definition: color.inc:6
search_get_default_module_info
search_get_default_module_info()
Definition: search.module:279
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
format_date
format_date($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
Definition: common.inc:1962
LANGUAGE_NONE
const LANGUAGE_NONE
Definition: bootstrap.inc:181
template_preprocess_search_results
template_preprocess_search_results(&$variables)
Definition: search.pages.inc:84
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
search_data
search_data($keys, $module, $conditions=NULL)
Definition: search.module:1096
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
template_preprocess_search_result
template_preprocess_search_result(&$variables)
Definition: search.pages.inc:105
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
DatabaseTasks_sqlite Member List

This is the complete list of members for DatabaseTasks_sqlite, including all inherited members.

$pdoDriver | DatabaseTasks_sqlite | protected
$results | DatabaseTasks | protected
$tasks | DatabaseTasks | protected
checkEngineVersion() | DatabaseTasks | protected
connect() | DatabaseTasks | protected
fail($message) | DatabaseTasks | protected
getFormOptions($database) | DatabaseTasks_sqlite |
hasPdoDriver() | DatabaseTasks | protected
installable() | DatabaseTasks |
minimumVersion() | DatabaseTasks_sqlite |
name() | DatabaseTasks_sqlite |
pass($message) | DatabaseTasks | protected
runTasks() | DatabaseTasks |
runTestQuery($query, $pass, $fail, $fatal=FALSE) | DatabaseTasks | protected
validateDatabaseSettings($database) | DatabaseTasks_sqlite |
Generated on Mon Feb 3 2014 12:40:51 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/taxonomy/taxonomy.api.php Source File

  • modules
  • taxonomy
taxonomy.api.php
Go to the documentation of this file.
1 <?php
2
22 function hook_taxonomy_vocabulary_load($vocabularies) {
23 $result = db_select('mytable', 'm')
24 ->fields('m', array('vid', 'foo'))
25 ->condition('m.vid', array_keys($vocabularies), 'IN')
26 ->execute();
27 foreach ($result as $record) {
28 $vocabularies[$record->vid]->foo = $record->foo;
29 }
30 }
31
41 function hook_taxonomy_vocabulary_presave($vocabulary) {
42 $vocabulary->foo = 'bar';
43 }
44
54 function hook_taxonomy_vocabulary_insert($vocabulary) {
55 if ($vocabulary->machine_name == 'my_vocabulary') {
56 $vocabulary->weight = 100;
57 }
58 }
59
68 function hook_taxonomy_vocabulary_update($vocabulary) {
69 db_update('mytable')
70 ->fields(array('foo' => $vocabulary->foo))
71 ->condition('vid', $vocabulary->vid)
72 ->execute();
73 }
74
84 function hook_taxonomy_vocabulary_delete($vocabulary) {
85 db_delete('mytable')
86 ->condition('vid', $vocabulary->vid)
87 ->execute();
88 }
89
106 function hook_taxonomy_term_load($terms) {
107 $result = db_select('mytable', 'm')
108 ->fields('m', array('tid', 'foo'))
109 ->condition('m.tid', array_keys($terms), 'IN')
110 ->execute();
111 foreach ($result as $record) {
112 $terms[$record->tid]->foo = $record->foo;
113 }
114 }
115
125 function hook_taxonomy_term_presave($term) {
126 $term->foo = 'bar';
127 }
128
138 function hook_taxonomy_term_insert($term) {
139 db_insert('mytable')
140 ->fields(array(
141 'tid' => $term->tid,
142 'foo' => $term->foo,
143 ))
144 ->execute();
145 }
146
155 function hook_taxonomy_term_update($term) {
156 db_update('mytable')
157 ->fields(array('foo' => $term->foo))
158 ->condition('tid', $term->tid)
159 ->execute();
160 }
161
171 function hook_taxonomy_term_delete($term) {
172 db_delete('mytable')
173 ->condition('tid', $term->tid)
174 ->execute();
175 }
176
193 function hook_taxonomy_term_view($term, $view_mode, $langcode) {
194 $term->content['my_additional_field'] = array(
195 '#markup' => $additional_field,
196 '#weight' => 10,
197 '#theme' => 'mymodule_my_additional_field',
198 );
199 }
200
219 function hook_taxonomy_term_view_alter(&$build) {
220 if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
221 // Change its weight.
222 $build['an_additional_field']['#weight'] = -10;
223 }
224
225 // Add a #post_render callback to act on the rendered HTML of the term.
226 $build['#post_render'][] = 'my_module_node_post_render';
227 }
228
hook_taxonomy_term_update
hook_taxonomy_term_update($term)
Definition: taxonomy.api.php:155
hook_taxonomy_term_view_alter
hook_taxonomy_term_view_alter(&$build)
Definition: taxonomy.api.php:219
hook_taxonomy_term_presave
hook_taxonomy_term_presave($term)
Definition: taxonomy.api.php:125
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
hook_taxonomy_term_load
hook_taxonomy_term_load($terms)
Definition: taxonomy.api.php:106
hook_taxonomy_term_view
hook_taxonomy_term_view($term, $view_mode, $langcode)
Definition: taxonomy.api.php:193
hook_taxonomy_vocabulary_delete
hook_taxonomy_vocabulary_delete($vocabulary)
Definition: taxonomy.api.php:84
hook_taxonomy_term_delete
hook_taxonomy_term_delete($term)
Definition: taxonomy.api.php:171
hook_taxonomy_vocabulary_presave
hook_taxonomy_vocabulary_presave($vocabulary)
Definition: taxonomy.api.php:41
hook_taxonomy_vocabulary_load
hook_taxonomy_vocabulary_load($vocabularies)
Definition: taxonomy.api.php:22
hook_taxonomy_vocabulary_insert
hook_taxonomy_vocabulary_insert($vocabulary)
Definition: taxonomy.api.php:54
hook_taxonomy_term_insert
hook_taxonomy_term_insert($term)
Definition: taxonomy.api.php:138
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
hook_taxonomy_vocabulary_update
hook_taxonomy_vocabulary_update($vocabulary)
Definition: taxonomy.api.php:68
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/file/file.api.php Source File

  • modules
  • file
file.api.php
Go to the documentation of this file.
1 <?php
2
29 function hook_file_download_access($file_item, $entity_type, $entity) {
30 if ($entity_type == 'node') {
31 return node_access('view', $entity);
32 }
33 }
34
55 function hook_file_download_access_alter(&$grants, $file_item, $entity_type, $entity) {
56 // For our example module, we always enforce the rules set by node module.
57 if (isset($grants['node'])) {
58 $grants = array('node' => $grants['node']);
59 }
60 }
hook_file_download_access
hook_file_download_access($file_item, $entity_type, $entity)
Definition: file.api.php:29
node_access
node_access($op, $node, $account=NULL)
Definition: node.module:2981
hook_file_download_access_alter
hook_file_download_access_alter(&$grants, $file_item, $entity_type, $entity)
Definition: file.api.php:55
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/php/php.module Source File

  • modules
  • php
php.module
Go to the documentation of this file.
1 <?php
2
11 function php_help($path, $arg) {
12 switch ($path) {
13 case 'admin/help#php':
14 $output = '';
15 $output .= '<h3>' . t('About') . '</h3>';
16 $output .= '<p>' . t('The PHP filter module adds a PHP filter to your site, for use with <a href="@filter">text formats</a>. This filter adds the ability to execute PHP code in any text field that uses a text format (such as the body of a content item or the text of a comment). <a href="@php-net">PHP</a> is a general-purpose scripting language widely-used for web development, and is the language with which Drupal has been developed. For more information, see the online handbook entry for the <a href="@php">PHP filter module</a>.', array('@filter' => url('admin/help/filter'), '@php-net' => 'http://www.php.net', '@php' => 'http://drupal.org/documentation/modules/php/')) . '</p>';
17 $output .= '<h3>' . t('Uses') . '</h3>';
18 $output .= '<dl>';
19 $output .= '<dt>' . t('Enabling execution of PHP in text fields') . '</dt>';
20 $output .= '<dd>' . t('The PHP filter module allows users with the proper permissions to include custom PHP code that will get executed when pages of your site are processed. While this is a powerful and flexible feature if used by a trusted user with PHP experience, it is a significant and dangerous security risk in the hands of a malicious or inexperienced user. Even a trusted user may accidentally compromise the site by entering malformed or incorrect PHP code. Only the most trusted users should be granted permission to use the PHP filter, and all PHP code added through the PHP filter should be carefully examined before use. <a href="@php-snippets">Example PHP snippets</a> can be found on Drupal.org.', array('@php-snippets' => url('http://drupal.org/documentation/customization/php-snippets'))) . '</dd>';
21 $output .= '</dl>';
22 return $output;
23 }
24 }
25
29 function php_permission() {
30 return array(
31 'use PHP for settings' => array(
32 'title' => t('Use PHP for settings'),
33 'restrict access' => TRUE,
34 ),
35 );
36 }
37
63 function php_eval($code) {
64 global $theme_path, $theme_info, $conf;
65
66 // Store current theme path.
67 $old_theme_path = $theme_path;
68
69 // Restore theme_path to the theme, as long as php_eval() executes,
70 // so code evaluated will not see the caller module as the current theme.
71 // If theme info is not initialized get the path from theme_default.
72 if (!isset($theme_info)) {
73 $theme_path = drupal_get_path('theme', $conf['theme_default']);
74 }
75 else {
76 $theme_path = dirname($theme_info->filename);
77 }
78
79 ob_start();
80 print eval('?>' . $code);
81 $output = ob_get_contents();
82 ob_end_clean();
83
84 // Recover original theme path.
85 $theme_path = $old_theme_path;
86
87 return $output;
88 }
89
95 function _php_filter_tips($filter, $format, $long = FALSE) {
96 global $base_url;
97 if ($long) {
98 $output = '<h4>' . t('Using custom PHP code') . '</h4>';
99 $output .= '<p>' . t('Custom PHP code may be embedded in some types of site content, including posts and blocks. While embedding PHP code inside a post or block is a powerful and flexible feature when used by a trusted user with PHP experience, it is a significant and dangerous security risk when used improperly. Even a small mistake when posting PHP code may accidentally compromise your site.') . '</p>';
100 $output .= '<p>' . t('If you are unfamiliar with PHP, SQL, or Drupal, avoid using custom PHP code within posts. Experimenting with PHP may corrupt your database, render your site inoperable, or significantly compromise security.') . '</p>';
101 $output .= '<p>' . t('Notes:') . '</p>';
102 $output .= '<ul><li>' . t('Remember to double-check each line for syntax and logic errors <strong>before</strong> saving.') . '</li>';
103 $output .= '<li>' . t('Statements must be correctly terminated with semicolons.') . '</li>';
104 $output .= '<li>' . t('Global variables used within your PHP code retain their values after your script executes.') . '</li>';
105 $output .= '<li>' . t('<code>register_globals</code> is <strong>turned off</strong>. If you need to use forms, understand and use the functions in <a href="@formapi">the Drupal Form API</a>.', array('@formapi' => url('http://api.drupal.org/api/group/form_api/7'))) . '</li>';
106 $output .= '<li>' . t('Use a <code>print</code> or <code>return</code> statement in your code to output content.') . '</li>';
107 $output .= '<li>' . t('Develop and test your PHP code using a separate test script and sample database before deploying on a production site.') . '</li>';
108 $output .= '<li>' . t('Consider including your custom PHP code within a site-specific module or <code>template.php</code> file rather than embedding it directly into a post or block.') . '</li>';
109 $output .= '<li>' . t('Be aware that the ability to embed PHP code within content is provided by the PHP Filter module. If this module is disabled or deleted, then blocks and posts with embedded PHP may display, rather than execute, the PHP code.') . '</li></ul>';
110 $output .= '<p>' . t('A basic example: <em>Creating a "Welcome" block that greets visitors with a simple message.</em>') . '</p>';
111 $output .= '<ul><li>' . t('<p>Add a custom block to your site, named "Welcome" . With its text format set to "PHP code" (or another format supporting PHP input), add the following in the Block body:</p>
112 <pre>
113 print t(\'Welcome visitor! Thank you for visiting.\');
114 </pre>') . '</li>';
115 $output .= '<li>' . t('<p>To display the name of a registered user, use this instead:</p>
116 <pre>
117 global $user;
118 if ($user->uid) {
119 print t(\'Welcome @name! Thank you for visiting.\', array(\'@name\' => format_username($user)));
120 }
121 else {
122 print t(\'Welcome visitor! Thank you for visiting.\');
123 }
124 </pre>') . '</li></ul>';
125 $output .= '<p>' . t('<a href="@drupal">Drupal.org</a> offers <a href="@php-snippets">some example PHP snippets</a>, or you can create your own with some PHP experience and knowledge of the Drupal system.', array('@drupal' => url('http://drupal.org'), '@php-snippets' => url('http://drupal.org/documentation/customization/php-snippets'))) . '</p>';
126 return $output;
127 }
128 else {
129 return t('You may post PHP code. You should include &lt;?php ?&gt; tags.');
130 }
131 }
132
138 function php_filter_info() {
139 $filters['php_code'] = array(
140 'title' => t('PHP evaluator'),
141 'description' => t('Executes a piece of PHP code. The usage of this filter should be restricted to administrators only!'),
142 'process callback' => 'php_eval',
143 'tips callback' => '_php_filter_tips',
144 'cache' => FALSE,
145 );
146 return $filters;
147 }
_php_filter_tips
_php_filter_tips($filter, $format, $long=FALSE)
Definition: php.module:95
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
php_permission
php_permission()
Definition: php.module:29
print
print
Definition: php-2.php:2
$conf
global $conf
Definition: authorize.php:74
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
php_help
php_help($path, $arg)
Definition: php.module:11
php_eval
php_eval($code)
Definition: php.module:63
$output
$output
Definition: authorize.php:93
php_filter_info
php_filter_info()
Definition: php.module:138
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
MailSystemInterface Member List

This is the complete list of members for MailSystemInterface, including all inherited members.

format(array $message) | MailSystemInterface
mail(array $message) | MailSystemInterface
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/node/node.tpl.php Source File

  • modules
  • node
node.tpl.php
Go to the documentation of this file.
1 <?php
2
82 ?>
83 <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
84
85 <?php print $user_picture; ?>
86
87 <?php print render($title_prefix); ?>
88 <?php if (!$page): ?>
89 <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
90 <?php endif; ?>
91 <?php print render($title_suffix); ?>
92
93 <?php if ($display_submitted): ?>
94 <div class="submitted">
95 <?php print $submitted; ?>
96 </div>
97 <?php endif; ?>
98
99 <div class="content"<?php print $content_attributes; ?>>
100 <?php
101 // We hide the comments and links now so that we can render them later.
102 hide($content['comments']);
103 hide($content['links']);
104 print render($content);
105 ?>
106 </div>
107
108 <?php print render($content['links']); ?>
109
110 <?php print render($content['comments']); ?>
111
112 </div>
$page
print $page
Definition: overlay.tpl.php:37
$attributes
print $attributes
Definition: block.tpl.php:47
$user_picture
print $user_picture
Definition: node.tpl.php:85
print
print
Definition: php-2.php:2
$content_attributes
print $content_attributes
Definition: block.tpl.php:55
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
hide
hide(&$element)
Definition: common.inc:6021
endif
endif
Definition: aggregator-item.tpl.php:31
$submitted
print $submitted
Definition: comment.tpl.php:75
render
render(&$element)
Definition: common.inc:5988
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
ModuleUpdater Member List

This is the complete list of members for ModuleUpdater, including all inherited members.

$source | Updater |
__construct($source) | Updater |
canUpdate($project_name) | ModuleUpdater | static
canUpdateDirectory($directory) | ModuleUpdater | static
factory($source) | Updater | static
findInfoFile($directory) | Updater | static
getBackupDir() | Updater |
getInstallArgs($overrides=array()) | Updater | protected
getInstallDirectory() | ModuleUpdater |
Updater::getProjectName($directory) | Updater | static
DrupalUpdaterInterface::getProjectName($directory) | DrupalUpdaterInterface | static
getProjectTitle($directory) | Updater | static
getSchemaUpdates() | ModuleUpdater |
getUpdaterFromDirectory($directory) | Updater | static
install(&$filetransfer, $overrides=array()) | Updater |
isInstalled() | ModuleUpdater |
makeBackup(&$filetransfer, $from, $to) | Updater |
makeWorldReadable(&$filetransfer, $path, $recursive=TRUE) | Updater |
Updater::postInstall() | Updater |
DrupalUpdaterInterface::postInstall() | DrupalUpdaterInterface |
postInstallTasks() | ModuleUpdater |
Updater::postUpdate() | Updater |
DrupalUpdaterInterface::postUpdate() | DrupalUpdaterInterface |
postUpdateTasks() | ModuleUpdater |
prepareInstallDirectory(&$filetransfer, $directory) | Updater |
update(&$filetransfer, $overrides=array()) | Updater |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/page_example/page_example.module Source File

  • examples
  • page_example
page_example.module
Go to the documentation of this file.
1 <?php
2
37 function page_example_help($path, $arg) {
38 switch ($path) {
39 case 'examples/page_example/simple':
40 // Help text for the simple page registered for this path.
41 return t('This is help text for the simple page.');
42
43 case 'admin/help#page_example':
44 // Help text for the admin section, using the module name in the path.
45 return t('This is help text created in the page example\'s second case.');
46 }
47 }
48
57 function page_example_permission() {
58 return array(
59 'access simple page' => array(
60 'title' => t('Access simple page'),
61 'description' => t('Allow users to access simple page'),
62 ),
63 'access arguments page' => array(
64 'title' => t('Access page with arguments'),
65 'description' => t('Allow users to access page with arguments'),
66 ),
67 );
68 }
69
102 function page_example_menu() {
103
104 // This is the minimum information you can provide for a menu item. This menu
105 // item will be created in the default menu, usually Navigation.
106 $items['examples/page_example'] = array(
107 'title' => 'Page Example',
108 'page callback' => 'page_example_description',
109 'access callback' => TRUE,
110 'expanded' => TRUE,
111 );
112
113 $items['examples/page_example/simple'] = array(
114 'title' => 'Simple - no arguments',
115 'page callback' => 'page_example_simple',
116 'access arguments' => array('access simple page'),
117 );
118
119 // By using the MENU_CALLBACK type, we can register the callback for this
120 // path without the item appearing in the menu; the admin cannot enable the
121 // item in the menu, either.
122 //
123 // Notice that 'page arguments' is an array of numbers. These will be
124 // replaced with the corresponding parts of the menu path. In this case a 0
125 // would be replaced by 'example', a 1 by 'page_example', and a 2 by
126 // 'arguments.' 3 and 4 will be replaced by whatever the user provides.
127 // These will be passed as arguments to the page_example_arguments() function.
128 $items['examples/page_example/arguments/%/%'] = array(
129 'page callback' => 'page_example_arguments',
130 'page arguments' => array(3, 4),
131 'access arguments' => array('access arguments page'),
132 'type' => MENU_CALLBACK,
133 );
134
135 return $items;
136 }
137
144 function page_example_description() {
145 return array('#markup' => t('<p>The page_example provides two pages, "simple" and "arguments".</p><p>The <a href="@simple_link">simple page</a> just returns a renderable array for display.</p><p>The <a href="@arguments_link">arguments page</a> takes two arguments and displays them, as in @arguments_link</p>', array('@simple_link' => url('examples/page_example/simple', array('absolute' => TRUE)), '@arguments_link' => url('examples/page_example/arguments/23/56', array('absolute' => TRUE)))));
146 }
147
160 function page_example_simple() {
161 return array('#markup' => '<p>' . t('Simple page: The quick brown fox jumps over the lazy dog.') . '</p>');
162 }
163
182 function page_example_arguments($first, $second) {
183 // Make sure you don't trust the URL to be safe! Always check for exploits.
184 if (!is_numeric($first) || !is_numeric($second)) {
185 // We will just show a standard "access denied" page in this case.
186 drupal_access_denied();
187 return; // We actually don't get here.
188 }
189
190 $list[] = t("First number was @number.", array('@number' => $first));
191 $list[] = t("Second number was @number.", array('@number' => $second));
192 $list[] = t('The total was @number.', array('@number' => $first + $second));
193
194 $render_array['page_example_arguments'] = array(
195 '#theme' => 'item_list', // The theme function to apply to the #items
196 '#items' => $list, // The list itself.
197 '#title' => t('Argument Information'),
198 );
199 return $render_array;
200 }
page_example_description
page_example_description()
Definition: page_example.module:144
page_example_menu
page_example_menu()
Definition: page_example.module:102
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
page_example_simple
page_example_simple()
Definition: page_example.module:160
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
page_example_help
page_example_help($path, $arg)
Definition: page_example.module:37
drupal_access_denied
drupal_access_denied()
Definition: common.inc:744
page_example_permission
page_example_permission()
Definition: page_example.module:57
page_example_arguments
page_example_arguments($first, $second)
Definition: page_example.module:182
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/user/user-profile-item.tpl.php Source File

  • modules
  • user
user-profile-item.tpl.php
Go to the documentation of this file.
1 <?php
2
24 ?>
25 <dt<?php print $attributes; ?>><?php print $title; ?></dt>
26 <dd<?php print $attributes; ?>><?php print $value; ?></dd>
print
print
Definition: php-2.php:2
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
$value
print $value
Definition: user-profile-item.tpl.php:26
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/openid/openid.pages.inc Source File

  • modules
  • openid
openid.pages.inc
Go to the documentation of this file.
1 <?php
2
11 function openid_authentication_page() {
12 $result = openid_complete();
13 switch ($result['status']) {
14 case 'success':
15 return openid_authentication($result);
16 case 'failed':
17 drupal_set_message(t('OpenID login failed.'), 'error');
18 break;
19 case 'cancel':
20 drupal_set_message(t('OpenID login cancelled.'));
21 break;
22 }
23 drupal_goto();
24 }
25
29 function openid_user_identities($account) {
30 drupal_set_title(format_username($account));
31 drupal_add_css(drupal_get_path('module', 'openid') . '/openid.css');
32
33 // Check to see if we got a response
34 $result = openid_complete();
35 if ($result['status'] == 'success') {
36 $identity = $result['openid.claimed_id'];
37 $query = db_insert('authmap')
38 ->fields(array(
39 'uid' => $account->uid,
40 'authname' => $identity,
41 'module' => 'openid',
42 ))
43 ->execute();
44 drupal_set_message(t('Successfully added %identity', array('%identity' => $identity)));
45 }
46
47 $header = array(t('OpenID'), t('Operations'));
48 $rows = array();
49
50 $result = db_query("SELECT * FROM {authmap} WHERE module='openid' AND uid=:uid", array(':uid' => $account->uid));
51 foreach ($result as $identity) {
52 $rows[] = array(check_plain($identity->authname), l(t('Delete'), 'user/' . $account->uid . '/openid/delete/' . $identity->aid));
53 }
54
55 $build['openid_table'] = array(
56 '#theme' => 'table',
57 '#header' => $header,
58 '#rows' => $rows,
59 '#empty' => t('No OpenID identities available for this account.'),
60 );
61 $build['openid_user_add'] = drupal_get_form('openid_user_add');
62 return $build;
63 }
64
71 function openid_user_add() {
72 $form['openid_identifier'] = array(
73 '#type' => 'textfield',
74 '#title' => t('OpenID'),
75 );
76 $form['actions'] = array('#type' => 'actions');
77 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Add an OpenID'));
78 return $form;
79 }
80
81 function openid_user_add_validate($form, &$form_state) {
82 // Check for existing entries.
83 $claimed_id = openid_normalize($form_state['values']['openid_identifier']);
84 if (db_query("SELECT authname FROM {authmap} WHERE authname = :authname", (array(':authname' => $claimed_id)))->fetchField()) {
85 form_set_error('openid_identifier', t('That OpenID is already in use on this site.'));
86 }
87 }
88
89 function openid_user_add_submit($form, &$form_state) {
90 $return_to = url('user/' . arg(1) . '/openid', array('absolute' => TRUE));
91 openid_begin($form_state['values']['openid_identifier'], $return_to);
92 }
93
97 function openid_user_delete_form($form, $form_state, $account, $aid = 0) {
98 $authname = db_query("SELECT authname FROM {authmap} WHERE uid = :uid AND aid = :aid AND module = 'openid'", array(
99 ':uid' => $account->uid,
100 ':aid' => $aid,
101 ))
102 ->fetchField();
103 return confirm_form(array(), t('Are you sure you want to delete the OpenID %authname for %user?', array('%authname' => $authname, '%user' => $account->name)), 'user/' . $account->uid . '/openid');
104 }
105
106 function openid_user_delete_form_submit($form, &$form_state) {
107 $query = db_delete('authmap')
108 ->condition('uid', $form_state['build_info']['args'][0]->uid)
109 ->condition('aid', $form_state['build_info']['args'][1])
110 ->condition('module', 'openid')
111 ->execute();
112 if ($query) {
113 drupal_set_message(t('OpenID deleted.'));
114 }
115 $form_state['redirect'] = 'user/' . $form_state['build_info']['args'][0]->uid . '/openid';
116 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
confirm_form
confirm_form($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
Definition: system.module:2847
l
l($text, $path, array $options=array())
Definition: common.inc:2432
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
drupal_goto
drupal_goto($path= '', array $options=array(), $http_response_code=302)
Definition: common.inc:686
format_username
format_username($account)
Definition: common.inc:2106
drupal_set_title
drupal_set_title($title=NULL, $output=CHECK_PLAIN)
Definition: bootstrap.inc:1876
drupal_add_css
drupal_add_css($data=NULL, $options=NULL)
Definition: common.inc:2967
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$header
print $header
Definition: forum-topic-list.tpl.php:42
arg
arg($index=NULL, $path=NULL)
Definition: bootstrap.inc:2852
openid_normalize
openid_normalize($identifier)
Definition: openid.inc:277
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
openid_user_delete_form
openid_user_delete_form($form, $form_state, $account, $aid=0)
Definition: openid.pages.inc:97
openid_user_add
openid_user_add()
Definition: openid.pages.inc:71
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
openid_user_identities
openid_user_identities($account)
Definition: openid.pages.inc:29
drupal_get_form
drupal_get_form($form_id)
Definition: form.inc:123
openid_begin
openid_begin($claimed_id, $return_to= '', $form_values=array())
Definition: openid.module:261
openid_authentication
openid_authentication($response)
Definition: openid.module:652
openid_user_add_validate
openid_user_add_validate($form, &$form_state)
Definition: openid.pages.inc:81
openid_user_delete_form_submit
openid_user_delete_form_submit($form, &$form_state)
Definition: openid.pages.inc:106
openid_user_add_submit
openid_user_add_submit($form, &$form_state)
Definition: openid.pages.inc:89
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
openid_complete
openid_complete($response=array())
Definition: openid.module:328
openid_authentication_page
openid_authentication_page()
Definition: openid.pages.inc:11
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/poll/poll-bar--block.tpl.php Source File

  • modules
  • poll
poll-bar--block.tpl.php
Go to the documentation of this file.
1 <?php
2
18 ?>
19
20 <div class="text"><?php print $title; ?></div>
21 <div class="bar">
22 <div style="width: <?php print $percentage; ?>%;" class="foreground"></div>
23 </div>
24 <div class="percent">
25 <?php print $percentage; ?>%
26 </div>
$percentage
print $percentage
Definition: poll-bar--block.tpl.php:22
print
print
Definition: php-2.php:2
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/openid/openid.install Source File

  • modules
  • openid
openid.install
Go to the documentation of this file.
1 <?php
2
11 function openid_schema() {
12 $schema['openid_association'] = array(
13 'description' => 'Stores temporary shared key association information for OpenID authentication.',
14 'fields' => array(
15 'idp_endpoint_uri' => array(
16 'type' => 'varchar',
17 'length' => 255,
18 'not null' => TRUE,
19 'description' => 'Primary Key: URI of the OpenID Provider endpoint.',
20 ),
21 'assoc_handle' => array(
22 'type' => 'varchar',
23 'length' => 255,
24 'not null' => TRUE,
25 'description' => 'Used to refer to this association in subsequent messages.',
26 ),
27 'assoc_type' => array(
28 'type' => 'varchar',
29 'length' => 32,
30 'description' => 'The signature algorithm used: one of HMAC-SHA1 or HMAC-SHA256.',
31 ),
32 'session_type' => array(
33 'type' => 'varchar',
34 'length' => 32,
35 'description' => 'Valid association session types: "no-encryption", "DH-SHA1", and "DH-SHA256".',
36 ),
37 'mac_key' => array(
38 'type' => 'varchar',
39 'length' => 255,
40 'description' => 'The MAC key (shared secret) for this association.',
41 ),
42 'created' => array(
43 'type' => 'int',
44 'not null' => TRUE,
45 'default' => 0,
46 'description' => 'UNIX timestamp for when the association was created.',
47 ),
48 'expires_in' => array(
49 'type' => 'int',
50 'not null' => TRUE,
51 'default' => 0,
52 'description' => 'The lifetime, in seconds, of this association.',
53 ),
54 ),
55 'primary key' => array('idp_endpoint_uri'),
56 'unique keys' => array(
57 'assoc_handle' => array('assoc_handle'),
58 ),
59 );
60
61 $schema['openid_nonce'] = array(
62 'description' => 'Stores received openid.response_nonce per OpenID endpoint URL to prevent replay attacks.',
63 'fields' => array(
64 'idp_endpoint_uri' => array(
65 'type' => 'varchar',
66 'length' => 255,
67 'description' => 'URI of the OpenID Provider endpoint.',
68 ),
69 'nonce' => array(
70 'type' => 'varchar',
71 'length' => 255,
72 'description' => 'The value of openid.response_nonce.',
73 ),
74 'expires' => array(
75 'type' => 'int',
76 'not null' => TRUE,
77 'default' => 0,
78 'description' => 'A Unix timestamp indicating when the entry should expire.',
79 ),
80 ),
81 'indexes' => array(
82 'nonce' => array('nonce'),
83 'expires' => array('expires'),
84 ),
85 );
86
87 return $schema;
88 }
89
93 function openid_requirements($phase) {
94 $requirements = array();
95
96 if ($phase == 'runtime') {
97 // Check for the PHP BC Math library.
98 if (!function_exists('bcadd') && !function_exists('gmp_add')) {
99 $requirements['openid_math'] = array(
100 'value' => t('Not installed'),
101 'severity' => REQUIREMENT_ERROR,
102 'description' => t('OpenID suggests the use of either the <a href="@gmp">GMP Math</a> (recommended for performance) or <a href="@bc">BC Math</a> libraries to enable OpenID associations.', array('@gmp' => 'http://php.net/manual/en/book.gmp.php', '@bc' => 'http://www.php.net/manual/en/book.bc.php')),
103 );
104 }
105 elseif (!function_exists('gmp_add')) {
106 $requirements['openid_math'] = array(
107 'value' => t('Not optimized'),
108 'severity' => REQUIREMENT_WARNING,
109 'description' => t('OpenID suggests the use of the GMP Math library for PHP for optimal performance. Check the <a href="@url">GMP Math Library documentation</a> for installation instructions.', array('@url' => 'http://www.php.net/manual/en/book.gmp.php')),
110 );
111 }
112 else {
113 $requirements['openid_math'] = array(
114 'value' => t('Installed'),
115 'severity' => REQUIREMENT_OK,
116 );
117 }
118 $requirements['openid_math']['title'] = t('OpenID Math library');
119 }
120
121 return $requirements;
122 }
123
132 function openid_update_6000() {
133 $schema['openid_nonce'] = array(
134 'description' => 'Stores received openid.response_nonce per OpenID endpoint URL to prevent replay attacks.',
135 'fields' => array(
136 'idp_endpoint_uri' => array(
137 'type' => 'varchar',
138 'length' => 255,
139 'description' => 'URI of the OpenID Provider endpoint.',
140 ),
141 'nonce' => array(
142 'type' => 'varchar',
143 'length' => 255,
144 'description' => 'The value of openid.response_nonce'
145 ),
146 'expires' => array(
147 'type' => 'int',
148 'not null' => TRUE,
149 'default' => 0,
150 'description' => 'A Unix timestamp indicating when the entry should expire.',
151 ),
152 ),
153 'indexes' => array(
154 'nonce' => array('nonce'),
155 'expires' => array('expires'),
156 ),
157 );
158
159 db_create_table('openid_nonce', $schema['openid_nonce']);
160 }
161
174 function openid_update_7000() {
175 db_drop_table('openid_association');
176
177 $schema = array(
178 'description' => 'Stores temporary shared key association information for OpenID authentication.',
179 'fields' => array(
180 'idp_endpoint_uri' => array(
181 'type' => 'varchar',
182 'length' => 255,
183 'not null' => TRUE,
184 'description' => 'Primary Key: URI of the OpenID Provider endpoint.',
185 ),
186 'assoc_handle' => array(
187 'type' => 'varchar',
188 'length' => 255,
189 'not null' => TRUE,
190 'description' => 'Used to refer to this association in subsequent messages.',
191 ),
192 'assoc_type' => array(
193 'type' => 'varchar',
194 'length' => 32,
195 'description' => 'The signature algorithm used: one of HMAC-SHA1 or HMAC-SHA256.',
196 ),
197 'session_type' => array(
198 'type' => 'varchar',
199 'length' => 32,
200 'description' => 'Valid association session types: "no-encryption", "DH-SHA1", and "DH-SHA256".',
201 ),
202 'mac_key' => array(
203 'type' => 'varchar',
204 'length' => 255,
205 'description' => 'The MAC key (shared secret) for this association.',
206 ),
207 'created' => array(
208 'type' => 'int',
209 'not null' => TRUE,
210 'default' => 0,
211 'description' => 'UNIX timestamp for when the association was created.',
212 ),
213 'expires_in' => array(
214 'type' => 'int',
215 'not null' => TRUE,
216 'default' => 0,
217 'description' => 'The lifetime, in seconds, of this association.',
218 ),
219 ),
220 'primary key' => array('idp_endpoint_uri'),
221 'unique keys' => array(
222 'assoc_handle' => array('assoc_handle'),
223 ),
224 );
225 db_create_table('openid_association', $schema);
226 }
227
openid_schema
openid_schema()
Definition: openid.install:11
db_create_table
db_create_table($name, $table)
Definition: database.inc:2716
openid_update_6000
openid_update_6000()
Definition: openid.install:132
REQUIREMENT_WARNING
const REQUIREMENT_WARNING
Definition: install.inc:31
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
openid_update_7000
openid_update_7000()
Definition: openid.install:174
REQUIREMENT_OK
const REQUIREMENT_OK
Definition: install.inc:26
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
openid_requirements
openid_requirements($phase)
Definition: openid.install:93
db_drop_table
db_drop_table($table)
Definition: database.inc:2815
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/theme.api.php Source File

  • modules
  • system
theme.api.php
Go to the documentation of this file.
1 <?php
2
87 function hook_form_system_theme_settings_alter(&$form, &$form_state) {
88 // Add a checkbox to toggle the breadcrumb trail.
89 $form['toggle_breadcrumb'] = array(
90 '#type' => 'checkbox',
91 '#title' => t('Display the breadcrumb'),
92 '#default_value' => theme_get_setting('toggle_breadcrumb'),
93 '#description' => t('Show a trail of links from the homepage to the current page.'),
94 );
95 }
96
113 function hook_preprocess(&$variables, $hook) {
114 static $hooks;
115
116 // Add contextual links to the variables, if the user has permission.
117
118 if (!user_access('access contextual links')) {
119 return;
120 }
121
122 if (!isset($hooks)) {
123 $hooks = theme_get_registry();
124 }
125
126 // Determine the primary theme function argument.
127 if (isset($hooks[$hook]['variables'])) {
128 $keys = array_keys($hooks[$hook]['variables']);
129 $key = $keys[0];
130 }
131 else {
132 $key = $hooks[$hook]['render element'];
133 }
134
135 if (isset($variables[$key])) {
136 $element = $variables[$key];
137 }
138
139 if (isset($element) && is_array($element) && !empty($element['#contextual_links'])) {
140 $variables['title_suffix']['contextual_links'] = contextual_links_view($element);
141 if (!empty($variables['title_suffix']['contextual_links'])) {
142 $variables['classes_array'][] = 'contextual-links-region';
143 }
144 }
145 }
146
159 function hook_preprocess_HOOK(&$variables) {
160 // This example is from rdf_preprocess_image(). It adds an RDF attribute
161 // to the image hook's variables.
162 $variables['attributes']['typeof'] = array('foaf:Image');
163 }
164
181 function hook_process(&$variables, $hook) {
182 // Wraps variables in RDF wrappers.
183 if (!empty($variables['rdf_template_variable_attributes_array'])) {
184 foreach ($variables['rdf_template_variable_attributes_array'] as $variable_name => $attributes) {
185 $context = array(
186 'hook' => $hook,
187 'variable_name' => $variable_name,
188 'variables' => $variables,
189 );
190 $variables[$variable_name] = theme('rdf_template_variable_wrapper', array('content' => $variables[$variable_name], 'attributes' => $attributes, 'context' => $context));
191 }
192 }
193 }
194
207 function hook_process_HOOK(&$variables) {
208 // @todo There are no use-cases in Drupal core for this hook. Find one from a
209 // contributed module, or come up with a good example. Coming up with a good
210 // example might be tough, since the intent is for nearly everything to be
211 // achievable via preprocess functions, and for process functions to only be
212 // used when requiring the later execution time.
213 }
214
223 function hook_themes_enabled($theme_list) {
224 foreach ($theme_list as $theme) {
225 block_theme_initialize($theme);
226 }
227 }
228
237 function hook_themes_disabled($theme_list) {
238 // Clear all update module caches.
239 _update_cache_clear();
240 }
block_theme_initialize
block_theme_initialize($theme)
Definition: block.module:638
_update_cache_clear
_update_cache_clear($cid=NULL, $wildcard=FALSE)
Definition: update.module:846
$attributes
print $attributes
Definition: block.tpl.php:47
hook_preprocess_HOOK
hook_preprocess_HOOK(&$variables)
Definition: theme.api.php:159
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
theme_get_registry
theme_get_registry($complete=TRUE)
Definition: theme.inc:255
user_access
user_access($string, $account=NULL)
Definition: user.module:794
theme_get_setting
theme_get_setting($setting_name, $theme=NULL)
Definition: theme.inc:1401
hook_process_HOOK
hook_process_HOOK(&$variables)
Definition: theme.api.php:207
hook_themes_enabled
hook_themes_enabled($theme_list)
Definition: theme.api.php:223
hook_themes_disabled
hook_themes_disabled($theme_list)
Definition: theme.api.php:237
hook_process
hook_process(&$variables, $hook)
Definition: theme.api.php:181
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
hook_form_system_theme_settings_alter
hook_form_system_theme_settings_alter(&$form, &$form_state)
Definition: theme.api.php:87
hook_preprocess
hook_preprocess(&$variables, $hook)
Definition: theme.api.php:113
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/select.inc Source File

  • includes
  • database
select.inc
Go to the documentation of this file.
1 <?php
2
8 require_once dirname(__FILE__) . '/query.inc';
9
20 interface QueryExtendableInterface {
21
33 public function extend($extender_name);
34 }
35
39 interface SelectQueryInterface extends QueryConditionInterface, QueryAlterableInterface, QueryExtendableInterface, QueryPlaceholderInterface {
40
41 /* Alter accessors to expose the query data to alter hooks. */
42
59 public function &getFields();
60
77 public function &getExpressions();
78
95 public function &getOrderBy();
96
113 public function &getGroupBy();
114
131 public function &getTables();
132
150 public function &getUnion();
151
162 public function getArguments(QueryPlaceholderInterface $queryPlaceholder = NULL);
163
164 /* Query building operations */
165
174 public function distinct($distinct = TRUE);
175
193 public function addField($table_alias, $field, $alias = NULL);
194
216 public function fields($table_alias, array $fields = array());
217
237 public function addExpression($expression, $alias = NULL, $arguments = array());
238
262 public function join($table, $alias = NULL, $condition = NULL, $arguments = array());
263
285 public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = array());
286
308 public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = array());
309
331 public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = array());
332
362 public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = array());
363
384 public function orderBy($field, $direction = 'ASC');
385
406 public function orderRandom();
407
422 public function range($start = NULL, $length = NULL);
423
447 public function union(SelectQueryInterface $query, $type = '');
448
457 public function groupBy($field);
458
465 public function countQuery();
466
473 public function isPrepared();
474
481 public function preExecute(SelectQueryInterface $query = NULL);
482
504 public function havingCondition($field, $value = NULL, $operator = NULL);
505
513 public function __clone();
514
529 public function forUpdate($set = TRUE);
530 }
531
535 class SelectQueryExtender implements SelectQueryInterface {
536
542 protected $query;
543
549 protected $connection;
550
554 protected $uniqueIdentifier;
555
559 protected $placeholder = 0;
560
561 public function __construct(SelectQueryInterface $query, DatabaseConnection $connection) {
562 $this->uniqueIdentifier = uniqid('', TRUE);
563 $this->query = $query;
564 $this->connection = $connection;
565 }
566
570 public function uniqueIdentifier() {
571 return $this->uniqueIdentifier;
572 }
573
577 public function nextPlaceholder() {
578 return $this->placeholder++;
579 }
580
581 /* Implementations of QueryAlterableInterface. */
582
583 public function addTag($tag) {
584 $this->query->addTag($tag);
585 return $this;
586 }
587
588 public function hasTag($tag) {
589 return $this->query->hasTag($tag);
590 }
591
592 public function hasAllTags() {
593 $args = func_get_args();
594 return call_user_func_array(array($this->query, 'hasAllTags'), $args);
595 }
596
597 public function hasAnyTag() {
598 $args = func_get_args();
599 return call_user_func_array(array($this->query, 'hasAnyTags'), $args);
600 }
601
602 public function addMetaData($key, $object) {
603 $this->query->addMetaData($key, $object);
604 return $this;
605 }
606
607 public function getMetaData($key) {
608 return $this->query->getMetaData($key);
609 }
610
611 /* Implementations of QueryConditionInterface for the WHERE clause. */
612
613 public function condition($field, $value = NULL, $operator = NULL) {
614 $this->query->condition($field, $value, $operator);
615 return $this;
616 }
617
618 public function &conditions() {
619 return $this->query->conditions();
620 }
621
622 public function arguments() {
623 return $this->query->arguments();
624 }
625
626 public function where($snippet, $args = array()) {
627 $this->query->where($snippet, $args);
628 return $this;
629 }
630
631 public function compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder) {
632 return $this->query->compile($connection, $queryPlaceholder);
633 }
634
635 public function compiled() {
636 return $this->query->compiled();
637 }
638
639 /* Implementations of QueryConditionInterface for the HAVING clause. */
640
641 public function havingCondition($field, $value = NULL, $operator = '=') {
642 $this->query->havingCondition($field, $value, $operator);
643 return $this;
644 }
645
646 public function &havingConditions() {
647 return $this->query->havingConditions();
648 }
649
650 public function havingArguments() {
651 return $this->query->havingArguments();
652 }
653
654 public function having($snippet, $args = array()) {
655 $this->query->having($snippet, $args);
656 return $this;
657 }
658
659 public function havingCompile(DatabaseConnection $connection) {
660 return $this->query->havingCompile($connection);
661 }
662
663 /* Implementations of QueryExtendableInterface. */
664
665 public function extend($extender_name) {
666 // The extender can be anywhere so this needs to go to the registry, which
667 // is surely loaded by now.
668 $class = $this->connection->getDriverClass($extender_name, array(), TRUE);
669 return new $class($this, $this->connection);
670 }
671
672 /* Alter accessors to expose the query data to alter hooks. */
673
674 public function &getFields() {
675 return $this->query->getFields();
676 }
677
678 public function &getExpressions() {
679 return $this->query->getExpressions();
680 }
681
682 public function &getOrderBy() {
683 return $this->query->getOrderBy();
684 }
685
686 public function &getGroupBy() {
687 return $this->query->getGroupBy();
688 }
689
690 public function &getTables() {
691 return $this->query->getTables();
692 }
693
694 public function &getUnion() {
695 return $this->query->getUnion();
696 }
697
698 public function getArguments(QueryPlaceholderInterface $queryPlaceholder = NULL) {
699 return $this->query->getArguments($queryPlaceholder);
700 }
701
702 public function isPrepared() {
703 return $this->query->isPrepared();
704 }
705
706 public function preExecute(SelectQueryInterface $query = NULL) {
707 // If no query object is passed in, use $this.
708 if (!isset($query)) {
709 $query = $this;
710 }
711
712 return $this->query->preExecute($query);
713 }
714
715 public function execute() {
716 // By calling preExecute() here, we force it to preprocess the extender
717 // object rather than just the base query object. That means
718 // hook_query_alter() gets access to the extended object.
719 if (!$this->preExecute($this)) {
720 return NULL;
721 }
722
723 return $this->query->execute();
724 }
725
726 public function distinct($distinct = TRUE) {
727 $this->query->distinct($distinct);
728 return $this;
729 }
730
731 public function addField($table_alias, $field, $alias = NULL) {
732 return $this->query->addField($table_alias, $field, $alias);
733 }
734
735 public function fields($table_alias, array $fields = array()) {
736 $this->query->fields($table_alias, $fields);
737 return $this;
738 }
739
740 public function addExpression($expression, $alias = NULL, $arguments = array()) {
741 return $this->query->addExpression($expression, $alias, $arguments);
742 }
743
744 public function join($table, $alias = NULL, $condition = NULL, $arguments = array()) {
745 return $this->query->join($table, $alias, $condition, $arguments);
746 }
747
748 public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
749 return $this->query->innerJoin($table, $alias, $condition, $arguments);
750 }
751
752 public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
753 return $this->query->leftJoin($table, $alias, $condition, $arguments);
754 }
755
756 public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
757 return $this->query->rightJoin($table, $alias, $condition, $arguments);
758 }
759
760 public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = array()) {
761 return $this->query->addJoin($type, $table, $alias, $condition, $arguments);
762 }
763
764 public function orderBy($field, $direction = 'ASC') {
765 $this->query->orderBy($field, $direction);
766 return $this;
767 }
768
769 public function orderRandom() {
770 $this->query->orderRandom();
771 return $this;
772 }
773
774 public function range($start = NULL, $length = NULL) {
775 $this->query->range($start, $length);
776 return $this;
777 }
778
779 public function union(SelectQueryInterface $query, $type = '') {
780 $this->query->union($query, $type);
781 return $this;
782 }
783
784 public function groupBy($field) {
785 $this->query->groupBy($field);
786 return $this;
787 }
788
789 public function forUpdate($set = TRUE) {
790 $this->query->forUpdate($set);
791 return $this;
792 }
793
794 public function countQuery() {
795 return $this->query->countQuery();
796 }
797
798 function isNull($field) {
799 $this->query->isNull($field);
800 return $this;
801 }
802
803 function isNotNull($field) {
804 $this->query->isNotNull($field);
805 return $this;
806 }
807
808 public function exists(SelectQueryInterface $select) {
809 $this->query->exists($select);
810 return $this;
811 }
812
813 public function notExists(SelectQueryInterface $select) {
814 $this->query->notExists($select);
815 return $this;
816 }
817
818 public function __toString() {
819 return (string) $this->query;
820 }
821
822 public function __clone() {
823 $this->uniqueIdentifier = uniqid('', TRUE);
824
825 // We need to deep-clone the query we're wrapping, which in turn may
826 // deep-clone other objects. Exciting!
827 $this->query = clone($this->query);
828 }
829
839 public function __call($method, $args) {
840 $return = call_user_func_array(array($this->query, $method), $args);
841
842 // Some methods will return the called object as part of a fluent interface.
843 // Others will return some useful value. If it's a value, then the caller
844 // probably wants that value. If it's the called object, then we instead
845 // return this object. That way we don't "lose" an extender layer when
846 // chaining methods together.
847 if ($return instanceof SelectQueryInterface) {
848 return $this;
849 }
850 else {
851 return $return;
852 }
853 }
854 }
855
859 class SelectQuery extends Query implements SelectQueryInterface {
860
866 protected $fields = array();
867
873 protected $expressions = array();
874
895 protected $tables = array();
896
905 protected $order = array();
906
912 protected $group = array();
913
919 protected $where;
920
926 protected $having;
927
933 protected $distinct = FALSE;
934
940 protected $range;
941
953 protected $union = array();
954
959 protected $prepared = FALSE;
960
964 protected $forUpdate = FALSE;
965
966 public function __construct($table, $alias = NULL, DatabaseConnection $connection, $options = array()) {
967 $options['return'] = Database::RETURN_STATEMENT;
968 parent::__construct($connection, $options);
969 $this->where = new DatabaseCondition('AND');
970 $this->having = new DatabaseCondition('AND');
971 $this->addJoin(NULL, $table, $alias);
972 }
973
974 /* Implementations of QueryAlterableInterface. */
975
976 public function addTag($tag) {
977 $this->alterTags[$tag] = 1;
978 return $this;
979 }
980
981 public function hasTag($tag) {
982 return isset($this->alterTags[$tag]);
983 }
984
985 public function hasAllTags() {
986 $args = func_get_args();
987 return !(boolean)array_diff($args, array_keys($this->alterTags));
988 }
989
990 public function hasAnyTag() {
991 $args = func_get_args();
992 return (boolean)array_intersect($args, array_keys($this->alterTags));
993 }
994
995 public function addMetaData($key, $object) {
996 $this->alterMetaData[$key] = $object;
997 return $this;
998 }
999
1000 public function getMetaData($key) {
1001 return isset($this->alterMetaData[$key]) ? $this->alterMetaData[$key] : NULL;
1002 }
1003
1004 /* Implementations of QueryConditionInterface for the WHERE clause. */
1005
1006 public function condition($field, $value = NULL, $operator = NULL) {
1007 $this->where->condition($field, $value, $operator);
1008 return $this;
1009 }
1010
1011 public function &conditions() {
1012 return $this->where->conditions();
1013 }
1014
1015 public function arguments() {
1016 if (!$this->compiled()) {
1017 return NULL;
1018 }
1019
1020 $args = $this->where->arguments() + $this->having->arguments();
1021
1022 foreach ($this->tables as $table) {
1023 if ($table['arguments']) {
1024 $args += $table['arguments'];
1025 }
1026 // If this table is a subquery, grab its arguments recursively.
1027 if ($table['table'] instanceof SelectQueryInterface) {
1028 $args += $table['table']->arguments();
1029 }
1030 }
1031
1032 foreach ($this->expressions as $expression) {
1033 if ($expression['arguments']) {
1034 $args += $expression['arguments'];
1035 }
1036 }
1037
1038 // If there are any dependent queries to UNION,
1039 // incorporate their arguments recursively.
1040 foreach ($this->union as $union) {
1041 $args += $union['query']->arguments();
1042 }
1043
1044 return $args;
1045 }
1046
1047 public function where($snippet, $args = array()) {
1048 $this->where->where($snippet, $args);
1049 return $this;
1050 }
1051
1052 public function isNull($field) {
1053 $this->where->isNull($field);
1054 return $this;
1055 }
1056
1057 public function isNotNull($field) {
1058 $this->where->isNotNull($field);
1059 return $this;
1060 }
1061
1062 public function exists(SelectQueryInterface $select) {
1063 $this->where->exists($select);
1064 return $this;
1065 }
1066
1067 public function notExists(SelectQueryInterface $select) {
1068 $this->where->notExists($select);
1069 return $this;
1070 }
1071
1072 public function compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder) {
1073 $this->where->compile($connection, $queryPlaceholder);
1074 $this->having->compile($connection, $queryPlaceholder);
1075
1076 foreach ($this->tables as $table) {
1077 // If this table is a subquery, compile it recursively.
1078 if ($table['table'] instanceof SelectQueryInterface) {
1079 $table['table']->compile($connection, $queryPlaceholder);
1080 }
1081 }
1082
1083 // If there are any dependent queries to UNION, compile it recursively.
1084 foreach ($this->union as $union) {
1085 $union['query']->compile($connection, $queryPlaceholder);
1086 }
1087 }
1088
1089 public function compiled() {
1090 if (!$this->where->compiled() || !$this->having->compiled()) {
1091 return FALSE;
1092 }
1093
1094 foreach ($this->tables as $table) {
1095 // If this table is a subquery, check its status recursively.
1096 if ($table['table'] instanceof SelectQueryInterface) {
1097 if (!$table['table']->compiled()) {
1098 return FALSE;
1099 }
1100 }
1101 }
1102
1103 foreach ($this->union as $union) {
1104 if (!$union['query']->compiled()) {
1105 return FALSE;
1106 }
1107 }
1108
1109 return TRUE;
1110 }
1111
1112 /* Implementations of QueryConditionInterface for the HAVING clause. */
1113
1114 public function havingCondition($field, $value = NULL, $operator = NULL) {
1115 $this->having->condition($field, $value, $operator);
1116 return $this;
1117 }
1118
1119 public function &havingConditions() {
1120 return $this->having->conditions();
1121 }
1122
1123 public function havingArguments() {
1124 return $this->having->arguments();
1125 }
1126
1127 public function having($snippet, $args = array()) {
1128 $this->having->where($snippet, $args);
1129 return $this;
1130 }
1131
1132 public function havingCompile(DatabaseConnection $connection) {
1133 return $this->having->compile($connection, $this);
1134 }
1135
1136 /* Implementations of QueryExtendableInterface. */
1137
1138 public function extend($extender_name) {
1139 $override_class = $extender_name . '_' . $this->connection->driver();
1140 if (class_exists($override_class)) {
1141 $extender_name = $override_class;
1142 }
1143 return new $extender_name($this, $this->connection);
1144 }
1145
1146 public function havingIsNull($field) {
1147 $this->having->isNull($field);
1148 return $this;
1149 }
1150
1151 public function havingIsNotNull($field) {
1152 $this->having->isNotNull($field);
1153 return $this;
1154 }
1155
1156 public function havingExists(SelectQueryInterface $select) {
1157 $this->having->exists($select);
1158 return $this;
1159 }
1160
1161 public function havingNotExists(SelectQueryInterface $select) {
1162 $this->having->notExists($select);
1163 return $this;
1164 }
1165
1166 public function forUpdate($set = TRUE) {
1167 if (isset($set)) {
1168 $this->forUpdate = $set;
1169 }
1170 return $this;
1171 }
1172
1173 /* Alter accessors to expose the query data to alter hooks. */
1174
1175 public function &getFields() {
1176 return $this->fields;
1177 }
1178
1179 public function &getExpressions() {
1180 return $this->expressions;
1181 }
1182
1183 public function &getOrderBy() {
1184 return $this->order;
1185 }
1186
1187 public function &getGroupBy() {
1188 return $this->group;
1189 }
1190
1191 public function &getTables() {
1192 return $this->tables;
1193 }
1194
1195 public function &getUnion() {
1196 return $this->union;
1197 }
1198
1199 public function getArguments(QueryPlaceholderInterface $queryPlaceholder = NULL) {
1200 if (!isset($queryPlaceholder)) {
1201 $queryPlaceholder = $this;
1202 }
1203 $this->compile($this->connection, $queryPlaceholder);
1204 return $this->arguments();
1205 }
1206
1210 public function isPrepared() {
1211 return $this->prepared;
1212 }
1213
1220 public function preExecute(SelectQueryInterface $query = NULL) {
1221 // If no query object is passed in, use $this.
1222 if (!isset($query)) {
1223 $query = $this;
1224 }
1225
1226 // Only execute this once.
1227 if ($query->isPrepared()) {
1228 return TRUE;
1229 }
1230
1231 // Modules may alter all queries or only those having a particular tag.
1232 if (isset($this->alterTags)) {
1233 $hooks = array('query');
1234 foreach ($this->alterTags as $tag => $value) {
1235 $hooks[] = 'query_' . $tag;
1236 }
1237 drupal_alter($hooks, $query);
1238 }
1239
1240 $this->prepared = TRUE;
1241
1242 // Now also prepare any sub-queries.
1243 foreach ($this->tables as $table) {
1244 if ($table['table'] instanceof SelectQueryInterface) {
1245 $table['table']->preExecute();
1246 }
1247 }
1248
1249 foreach ($this->union as $union) {
1250 $union['query']->preExecute();
1251 }
1252
1253 return $this->prepared;
1254 }
1255
1256 public function execute() {
1257 // If validation fails, simply return NULL.
1258 // Note that validation routines in preExecute() may throw exceptions instead.
1259 if (!$this->preExecute()) {
1260 return NULL;
1261 }
1262
1263 $args = $this->getArguments();
1264 return $this->connection->query((string) $this, $args, $this->queryOptions);
1265 }
1266
1267 public function distinct($distinct = TRUE) {
1268 $this->distinct = $distinct;
1269 return $this;
1270 }
1271
1272 public function addField($table_alias, $field, $alias = NULL) {
1273 // If no alias is specified, first try the field name itself.
1274 if (empty($alias)) {
1275 $alias = $field;
1276 }
1277
1278 // If that's already in use, try the table name and field name.
1279 if (!empty($this->fields[$alias])) {
1280 $alias = $table_alias . '_' . $field;
1281 }
1282
1283 // If that is already used, just add a counter until we find an unused alias.
1284 $alias_candidate = $alias;
1285 $count = 2;
1286 while (!empty($this->fields[$alias_candidate])) {
1287 $alias_candidate = $alias . '_' . $count++;
1288 }
1289 $alias = $alias_candidate;
1290
1291 $this->fields[$alias] = array(
1292 'field' => $field,
1293 'table' => $table_alias,
1294 'alias' => $alias,
1295 );
1296
1297 return $alias;
1298 }
1299
1300 public function fields($table_alias, array $fields = array()) {
1301
1302 if ($fields) {
1303 foreach ($fields as $field) {
1304 // We don't care what alias was assigned.
1305 $this->addField($table_alias, $field);
1306 }
1307 }
1308 else {
1309 // We want all fields from this table.
1310 $this->tables[$table_alias]['all_fields'] = TRUE;
1311 }
1312
1313 return $this;
1314 }
1315
1316 public function addExpression($expression, $alias = NULL, $arguments = array()) {
1317 if (empty($alias)) {
1318 $alias = 'expression';
1319 }
1320
1321 $alias_candidate = $alias;
1322 $count = 2;
1323 while (!empty($this->expressions[$alias_candidate])) {
1324 $alias_candidate = $alias . '_' . $count++;
1325 }
1326 $alias = $alias_candidate;
1327
1328 $this->expressions[$alias] = array(
1329 'expression' => $expression,
1330 'alias' => $alias,
1331 'arguments' => $arguments,
1332 );
1333
1334 return $alias;
1335 }
1336
1337 public function join($table, $alias = NULL, $condition = NULL, $arguments = array()) {
1338 return $this->addJoin('INNER', $table, $alias, $condition, $arguments);
1339 }
1340
1341 public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
1342 return $this->addJoin('INNER', $table, $alias, $condition, $arguments);
1343 }
1344
1345 public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
1346 return $this->addJoin('LEFT OUTER', $table, $alias, $condition, $arguments);
1347 }
1348
1349 public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
1350 return $this->addJoin('RIGHT OUTER', $table, $alias, $condition, $arguments);
1351 }
1352
1353 public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = array()) {
1354
1355 if (empty($alias)) {
1356 if ($table instanceof SelectQueryInterface) {
1357 $alias = 'subquery';
1358 }
1359 else {
1360 $alias = $table;
1361 }
1362 }
1363
1364 $alias_candidate = $alias;
1365 $count = 2;
1366 while (!empty($this->tables[$alias_candidate])) {
1367 $alias_candidate = $alias . '_' . $count++;
1368 }
1369 $alias = $alias_candidate;
1370
1371 if (is_string($condition)) {
1372 $condition = str_replace('%alias', $alias, $condition);
1373 }
1374
1375 $this->tables[$alias] = array(
1376 'join type' => $type,
1377 'table' => $table,
1378 'alias' => $alias,
1379 'condition' => $condition,
1380 'arguments' => $arguments,
1381 );
1382
1383 return $alias;
1384 }
1385
1386 public function orderBy($field, $direction = 'ASC') {
1387 $this->order[$field] = $direction;
1388 return $this;
1389 }
1390
1391 public function orderRandom() {
1392 $alias = $this->addExpression('RAND()', 'random_field');
1393 $this->orderBy($alias);
1394 return $this;
1395 }
1396
1397 public function range($start = NULL, $length = NULL) {
1398 $this->range = func_num_args() ? array('start' => $start, 'length' => $length) : array();
1399 return $this;
1400 }
1401
1402 public function union(SelectQueryInterface $query, $type = '') {
1403 // Handle UNION aliasing.
1404 switch ($type) {
1405 // Fold UNION DISTINCT to UNION for better cross database support.
1406 case 'DISTINCT':
1407 case '':
1408 $type = 'UNION';
1409 break;
1410
1411 case 'ALL':
1412 $type = 'UNION ALL';
1413 default:
1414 }
1415
1416 $this->union[] = array(
1417 'type' => $type,
1418 'query' => $query,
1419 );
1420
1421 return $this;
1422 }
1423
1424 public function groupBy($field) {
1425 $this->group[$field] = $field;
1426 return $this;
1427 }
1428
1429 public function countQuery() {
1430 // Create our new query object that we will mutate into a count query.
1431 $count = clone($this);
1432
1433 $group_by = $count->getGroupBy();
1434 $having = $count->havingConditions();
1435
1436 if (!$count->distinct && !isset($having[0])) {
1437 // When not executing a distinct query, we can zero-out existing fields
1438 // and expressions that are not used by a GROUP BY or HAVING. Fields
1439 // listed in a GROUP BY or HAVING clause need to be present in the
1440 // query.
1441 $fields =& $count->getFields();
1442 foreach (array_keys($fields) as $field) {
1443 if (empty($group_by[$field])) {
1444 unset($fields[$field]);
1445 }
1446 }
1447
1448 $expressions =& $count->getExpressions();
1449 foreach (array_keys($expressions) as $field) {
1450 if (empty($group_by[$field])) {
1451 unset($expressions[$field]);
1452 }
1453 }
1454
1455 // Also remove 'all_fields' statements, which are expanded into tablename.*
1456 // when the query is executed.
1457 foreach ($count->tables as $alias => &$table) {
1458 unset($table['all_fields']);
1459 }
1460 }
1461
1462 // If we've just removed all fields from the query, make sure there is at
1463 // least one so that the query still runs.
1464 $count->addExpression('1');
1465
1466 // Ordering a count query is a waste of cycles, and breaks on some
1467 // databases anyway.
1468 $orders = &$count->getOrderBy();
1469 $orders = array();
1470
1471 if ($count->distinct && !empty($group_by)) {
1472 // If the query is distinct and contains a GROUP BY, we need to remove the
1473 // distinct because SQL99 does not support counting on distinct multiple fields.
1474 $count->distinct = FALSE;
1475 }
1476
1477 $query = $this->connection->select($count);
1478 $query->addExpression('COUNT(*)');
1479
1480 return $query;
1481 }
1482
1483 public function __toString() {
1484 // For convenience, we compile the query ourselves if the caller forgot
1485 // to do it. This allows constructs like "(string) $query" to work. When
1486 // the query will be executed, it will be recompiled using the proper
1487 // placeholder generator anyway.
1488 if (!$this->compiled()) {
1489 $this->compile($this->connection, $this);
1490 }
1491
1492 // Create a sanitized comment string to prepend to the query.
1493 $comments = $this->connection->makeComment($this->comments);
1494
1495 // SELECT
1496 $query = $comments . 'SELECT ';
1497 if ($this->distinct) {
1498 $query .= 'DISTINCT ';
1499 }
1500
1501 // FIELDS and EXPRESSIONS
1502 $fields = array();
1503 foreach ($this->tables as $alias => $table) {
1504 if (!empty($table['all_fields'])) {
1505 $fields[] = $this->connection->escapeTable($alias) . '.*';
1506 }
1507 }
1508 foreach ($this->fields as $alias => $field) {
1509 // Always use the AS keyword for field aliases, as some
1510 // databases require it (e.g., PostgreSQL).
1511 $fields[] = (isset($field['table']) ? $this->connection->escapeTable($field['table']) . '.' : '') . $this->connection->escapeField($field['field']) . ' AS ' . $this->connection->escapeAlias($field['alias']);
1512 }
1513 foreach ($this->expressions as $alias => $expression) {
1514 $fields[] = $expression['expression'] . ' AS ' . $this->connection->escapeAlias($expression['alias']);
1515 }
1516 $query .= implode(', ', $fields);
1517
1518
1519 // FROM - We presume all queries have a FROM, as any query that doesn't won't need the query builder anyway.
1520 $query .= "\nFROM ";
1521 foreach ($this->tables as $alias => $table) {
1522 $query .= "\n";
1523 if (isset($table['join type'])) {
1524 $query .= $table['join type'] . ' JOIN ';
1525 }
1526
1527 // If the table is a subquery, compile it and integrate it into this query.
1528 if ($table['table'] instanceof SelectQueryInterface) {
1529 // Run preparation steps on this sub-query before converting to string.
1530 $subquery = $table['table'];
1531 $subquery->preExecute();
1532 $table_string = '(' . (string) $subquery . ')';
1533 }
1534 else {
1535 $table_string = '{' . $this->connection->escapeTable($table['table']) . '}';
1536 }
1537
1538 // Don't use the AS keyword for table aliases, as some
1539 // databases don't support it (e.g., Oracle).
1540 $query .= $table_string . ' ' . $this->connection->escapeTable($table['alias']);
1541
1542 if (!empty($table['condition'])) {
1543 $query .= ' ON ' . $table['condition'];
1544 }
1545 }
1546
1547 // WHERE
1548 if (count($this->where)) {
1549 // There is an implicit string cast on $this->condition.
1550 $query .= "\nWHERE " . $this->where;
1551 }
1552
1553 // GROUP BY
1554 if ($this->group) {
1555 $query .= "\nGROUP BY " . implode(', ', $this->group);
1556 }
1557
1558 // HAVING
1559 if (count($this->having)) {
1560 // There is an implicit string cast on $this->having.
1561 $query .= "\nHAVING " . $this->having;
1562 }
1563
1564 // ORDER BY
1565 if ($this->order) {
1566 $query .= "\nORDER BY ";
1567 $fields = array();
1568 foreach ($this->order as $field => $direction) {
1569 $fields[] = $field . ' ' . $direction;
1570 }
1571 $query .= implode(', ', $fields);
1572 }
1573
1574 // RANGE
1575 // There is no universal SQL standard for handling range or limit clauses.
1576 // Fortunately, all core-supported databases use the same range syntax.
1577 // Databases that need a different syntax can override this method and
1578 // do whatever alternate logic they need to.
1579 if (!empty($this->range)) {
1580 $query .= "\nLIMIT " . (int) $this->range['length'] . " OFFSET " . (int) $this->range['start'];
1581 }
1582
1583 // UNION is a little odd, as the select queries to combine are passed into
1584 // this query, but syntactically they all end up on the same level.
1585 if ($this->union) {
1586 foreach ($this->union as $union) {
1587 $query .= ' ' . $union['type'] . ' ' . (string) $union['query'];
1588 }
1589 }
1590
1591 if ($this->forUpdate) {
1592 $query .= ' FOR UPDATE';
1593 }
1594
1595 return $query;
1596 }
1597
1598 public function __clone() {
1599 // On cloning, also clone the dependent objects. However, we do not
1600 // want to clone the database connection object as that would duplicate the
1601 // connection itself.
1602
1603 $this->where = clone($this->where);
1604 $this->having = clone($this->having);
1605 foreach ($this->union as $key => $aggregate) {
1606 $this->union[$key]['query'] = clone($aggregate['query']);
1607 }
1608 }
1609 }
1610
SelectQuery\__construct
__construct($table, $alias=NULL, DatabaseConnection $connection, $options=array())
Definition: select.inc:966
SelectQueryInterface\__clone
__clone()
SelectQueryExtender\havingCompile
havingCompile(DatabaseConnection $connection)
Definition: select.inc:659
SelectQueryExtender\nextPlaceholder
nextPlaceholder()
Definition: select.inc:577
SelectQuery\havingExists
havingExists(SelectQueryInterface $select)
Definition: select.inc:1156
SelectQueryExtender\havingConditions
& havingConditions()
Definition: select.inc:646
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
QueryAlterableInterface
Definition: query.inc:166
SelectQuery\$having
$having
Definition: select.inc:926
SelectQueryExtender\arguments
arguments()
Definition: select.inc:622
SelectQueryExtender\addMetaData
addMetaData($key, $object)
Definition: select.inc:602
SelectQueryInterface\fields
fields($table_alias, array $fields=array())
SelectQueryInterface\orderBy
orderBy($field, $direction= 'ASC')
SelectQueryExtender\hasTag
hasTag($tag)
Definition: select.inc:588
SelectQuery
Definition: select.inc:859
SelectQueryExtender\__construct
__construct(SelectQueryInterface $query, DatabaseConnection $connection)
Definition: select.inc:561
SelectQueryInterface\rightJoin
rightJoin($table, $alias=NULL, $condition=NULL, $arguments=array())
SelectQueryExtender\__toString
__toString()
Definition: select.inc:818
$snippet
if($snippet) print $snippet
Definition: search-result.tpl.php:74
SelectQueryExtender\isNull
isNull($field)
Definition: select.inc:798
SelectQueryInterface\getArguments
getArguments(QueryPlaceholderInterface $queryPlaceholder=NULL)
SelectQueryInterface\getGroupBy
& getGroupBy()
SelectQuery\$union
$union
Definition: select.inc:953
SelectQueryExtender\havingCondition
havingCondition($field, $value=NULL, $operator= '=')
Definition: select.inc:641
SelectQueryInterface\addExpression
addExpression($expression, $alias=NULL, $arguments=array())
SelectQuery\$fields
$fields
Definition: select.inc:866
SelectQueryExtender
Definition: select.inc:535
SelectQueryExtender\having
having($snippet, $args=array())
Definition: select.inc:654
SelectQuery\$group
$group
Definition: select.inc:912
QueryExtendableInterface
Definition: select.inc:20
SelectQueryExtender\condition
condition($field, $value=NULL, $operator=NULL)
Definition: select.inc:613
SelectQueryExtender\compile
compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder)
Definition: select.inc:631
SelectQueryExtender\__call
__call($method, $args)
Definition: select.inc:839
SelectQueryExtender\$placeholder
$placeholder
Definition: select.inc:559
SelectQueryInterface\distinct
distinct($distinct=TRUE)
SelectQuery\$order
$order
Definition: select.inc:905
Database\RETURN_STATEMENT
const RETURN_STATEMENT
Definition: database.inc:1335
Query\$comments
$comments
Definition: query.inc:320
SelectQueryInterface\join
join($table, $alias=NULL, $condition=NULL, $arguments=array())
DatabaseCondition
Definition: query.inc:1652
SelectQueryExtender\hasAnyTag
hasAnyTag()
Definition: select.inc:597
SelectQueryExtender\where
where($snippet, $args=array())
Definition: select.inc:626
SelectQuery\havingIsNotNull
havingIsNotNull($field)
Definition: select.inc:1151
SelectQueryExtender\execute
execute()
Definition: select.inc:715
QueryConditionInterface
Definition: query.inc:16
SelectQueryExtender\$query
$query
Definition: select.inc:542
SelectQueryInterface\isPrepared
isPrepared()
SelectQueryInterface\countQuery
countQuery()
SelectQueryExtender\addTag
addTag($tag)
Definition: select.inc:583
SelectQuery\$expressions
$expressions
Definition: select.inc:873
SelectQueryInterface\forUpdate
forUpdate($set=TRUE)
SelectQuery\havingNotExists
havingNotExists(SelectQueryInterface $select)
Definition: select.inc:1161
$value
print $value
Definition: user-profile-item.tpl.php:26
SelectQueryInterface
Definition: select.inc:39
SelectQueryExtender\getMetaData
getMetaData($key)
Definition: select.inc:607
SelectQueryInterface\getTables
& getTables()
SelectQueryExtender\uniqueIdentifier
uniqueIdentifier()
Definition: select.inc:570
QueryPlaceholderInterface
Definition: query.inc:253
SelectQueryExtender\notExists
notExists(SelectQueryInterface $select)
Definition: select.inc:813
QueryExtendableInterface\extend
extend($extender_name)
DatabaseConnection
Definition: database.inc:184
SelectQueryExtender\hasAllTags
hasAllTags()
Definition: select.inc:592
SelectQueryInterface\range
range($start=NULL, $length=NULL)
SelectQuery\$tables
$tables
Definition: select.inc:895
SelectQuery\havingIsNull
havingIsNull($field)
Definition: select.inc:1146
SelectQueryInterface\addField
addField($table_alias, $field, $alias=NULL)
SelectQuery\$where
$where
Definition: select.inc:919
SelectQueryExtender\havingArguments
havingArguments()
Definition: select.inc:650
SelectQueryExtender\isNotNull
isNotNull($field)
Definition: select.inc:803
SelectQueryInterface\innerJoin
innerJoin($table, $alias=NULL, $condition=NULL, $arguments=array())
SelectQueryExtender\exists
exists(SelectQueryInterface $select)
Definition: select.inc:808
SelectQueryInterface\leftJoin
leftJoin($table, $alias=NULL, $condition=NULL, $arguments=array())
SelectQueryInterface\getOrderBy
& getOrderBy()
SelectQueryExtender\$uniqueIdentifier
$uniqueIdentifier
Definition: select.inc:554
SelectQueryInterface\getFields
& getFields()
Query
Definition: query.inc:275
SelectQueryExtender\conditions
& conditions()
Definition: select.inc:618
SelectQueryInterface\preExecute
preExecute(SelectQueryInterface $query=NULL)
SelectQuery\$prepared
$prepared
Definition: select.inc:959
SelectQuery\$distinct
$distinct
Definition: select.inc:933
SelectQueryInterface\havingCondition
havingCondition($field, $value=NULL, $operator=NULL)
SelectQueryExtender\$connection
$connection
Definition: select.inc:549
SelectQuery\$range
$range
Definition: select.inc:940
SelectQuery\$forUpdate
$forUpdate
Definition: select.inc:964
SelectQueryInterface\addJoin
addJoin($type, $table, $alias=NULL, $condition=NULL, $arguments=array())
SelectQueryInterface\getExpressions
& getExpressions()
SelectQueryInterface\getUnion
& getUnion()
SelectQueryInterface\orderRandom
orderRandom()
SelectQueryExtender\compiled
compiled()
Definition: select.inc:635
SelectQueryInterface\groupBy
groupBy($field)
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/database/mysql/install.inc Source File

  • includes
  • database
  • mysql
install.inc
Go to the documentation of this file.
1 <?php
2
11 class DatabaseTasks_mysql extends DatabaseTasks {
17 protected $pdoDriver = 'mysql';
18
22 public function name() {
23 return st('MySQL, MariaDB, or equivalent');
24 }
25
29 public function minimumVersion() {
30 return '5.0.15';
31 }
32 }
33
DatabaseTasks_mysql\$pdoDriver
$pdoDriver
Definition: install.inc:17
DatabaseTasks
Definition: install.inc:290
DatabaseTasks_mysql
Definition: install.inc:11
st
st($string, array $args=array(), array $options=array())
Definition: install.inc:1111
DatabaseTasks_mysql\minimumVersion
minimumVersion()
Definition: install.inc:29
DatabaseTasks_mysql\name
name()
Definition: install.inc:22
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/field_permission_example/field_permission_example.install Source File

  • examples
  • field_permission_example
field_permission_example.install
Go to the documentation of this file.
1 <?php
25 function field_permission_example_field_schema($field) {
26 $columns = array(
27 'notes' => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE),
28 );
29 return array(
30 'columns' => $columns,
31 );
32 }
field_permission_example_field_schema
field_permission_example_field_schema($field)
Definition: field_permission_example.install:25
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example/ajax_example_graceful_degradation.inc Source File

  • examples
  • ajax_example
ajax_example_graceful_degradation.inc
Go to the documentation of this file.
1 <?php
2
38 function ajax_example_dependent_dropdown_degrades($form, &$form_state, $no_js_use = FALSE) {
39 // Get the list of options to populate the first dropdown.
40 $options_first = _ajax_example_get_first_dropdown_options();
41
42 // If we have a value for the first dropdown from $form_state['values'] we use
43 // this both as the default value for the first dropdown and also as a
44 // parameter to pass to the function that retrieves the options for the
45 // second dropdown.
46 $selected = isset($form_state['values']['dropdown_first']) ? $form_state['values']['dropdown_first'] : key($options_first);
47
48 // Attach the CSS and JS we need to show this with and without javascript.
49 // Without javascript we need an extra "Choose" button, and this is
50 // hidden when we have javascript enabled.
51 $form['#attached']['css'] = array(
52 drupal_get_path('module', 'ajax_example') . '/ajax_example.css',
53 );
54 $form['#attached']['js'] = array(
55 drupal_get_path('module', 'ajax_example') . '/ajax_example.js',
56 );
57
58 $form['dropdown_first_fieldset'] = array(
59 '#type' => 'fieldset',
60 );
61 $form['dropdown_first_fieldset']['dropdown_first'] = array(
62 '#type' => 'select',
63 '#title' => 'Instrument Type',
64 '#options' => $options_first,
65 '#attributes' => array('class' => array('enabled-for-ajax')),
66
67 // The '#ajax' property allows us to bind a callback to the server whenever this
68 // form element changes. See ajax_example_autocheckboxes and
69 // ajax_example_dependent_dropdown in ajax_example.module for more details.
70 '#ajax' => array(
71 'callback' => 'ajax_example_dependent_dropdown_degrades_first_callback',
72 'wrapper' => 'dropdown-second-replace',
73 ),
74 );
75
76 // This simply allows us to demonstrate no-javascript use without
77 // actually turning off javascript in the browser. Removing the #ajax
78 // element turns off AJAX behaviors on that element and as a result
79 // ajax.js doesn't get loaded. This is for demonstration purposes only.
80 if ($no_js_use) {
81 unset($form['dropdown_first_fieldset']['dropdown_first']['#ajax']);
82 }
83
84 // Since we don't know if the user has js or not, we always need to output
85 // this element, then hide it with with css if javascript is enabled.
86 $form['dropdown_first_fieldset']['continue_to_second'] = array(
87 '#type' => 'submit',
88 '#value' => t('Choose'),
89 '#attributes' => array('class' => array('next-button')),
90 );
91
92 $form['dropdown_second_fieldset'] = array(
93 '#type' => 'fieldset',
94 );
95 $form['dropdown_second_fieldset']['dropdown_second'] = array(
96 '#type' => 'select',
97 '#title' => $options_first[$selected] . ' ' . t('Instruments'),
98 '#prefix' => '<div id="dropdown-second-replace">',
99 '#suffix' => '</div>',
100 '#attributes' => array('class' => array('enabled-for-ajax')),
101 // When the form is rebuilt during processing (either AJAX or multistep),
102 // the $selected variable will now have the new value and so the options
103 // will change.
104 '#options' => _ajax_example_get_second_dropdown_options($selected),
105 );
106 $form['dropdown_second_fieldset']['submit'] = array(
107 '#type' => 'submit',
108 '#value' => t('OK'),
109 // This class allows attached js file to override the disabled attribute,
110 // since it's not necessary in ajax-enabled form.
111 '#attributes' => array('class' => array('enabled-for-ajax')),
112 );
113
114 // Disable dropdown_second if a selection has not been made on dropdown_first.
115 if (empty($form_state['values']['dropdown_first'])) {
116 $form['dropdown_second_fieldset']['dropdown_second']['#disabled'] = TRUE;
117 $form['dropdown_second_fieldset']['dropdown_second']['#description'] = t('You must make your choice on the first dropdown before changing this second one.');
118 $form['dropdown_second_fieldset']['submit']['#disabled'] = TRUE;
119 }
120
121 return $form;
122 }
123
127 function ajax_example_dependent_dropdown_degrades_submit($form, &$form_state) {
128
129 // Now handle the case of the next, previous, and submit buttons.
130 // only submit will result in actual submission, all others rebuild.
131 switch ($form_state['triggering_element']['#value']) {
132 case t('OK'): // Submit: We're done.
133 drupal_set_message(t('Your values have been submitted. dropdown_first=@first, dropdown_second=@second', array('@first' => $form_state['values']['dropdown_first'], '@second' => $form_state['values']['dropdown_second'])));
134 return;
135 }
136 // 'Choose' or anything else will cause rebuild of the form and present
137 // it again.
138 $form_state['rebuild'] = TRUE;
139 }
140
147 function ajax_example_dependent_dropdown_degrades_first_callback($form, $form_state) {
148 return $form['dropdown_second_fieldset']['dropdown_second'];
149 }
150
151
163 function ajax_example_dynamic_sections($form, &$form_state, $no_js_use = FALSE) {
164
165 // Attach the CSS and JS we need to show this with and without javascript.
166 // Without javascript we need an extra "Choose" button, and this is
167 // hidden when we have javascript enabled.
168 $form['#attached']['css'] = array(
169 drupal_get_path('module', 'ajax_example') . '/ajax_example.css',
170 );
171 $form['#attached']['js'] = array(
172 drupal_get_path('module', 'ajax_example') . '/ajax_example.js',
173 );
174 $form['description'] = array(
175 '#type' => 'markup',
176 '#markup' => '<div>' . t('This example demonstrates a form which dynamically creates various sections based on the configuration in the form.
177 It deliberately allows graceful degradation to a non-javascript environment.
178 In a non-javascript environment, the "Choose" button next to the select control
179 is displayed; in a javascript environment it is hidden by the module CSS.
180 <br/><br/>The basic idea here is that the form is built up based on
181 the selection in the question_type_select field, and it is built the same
182 whether we are in a javascript/AJAX environment or not.
183 <br/><br/>
184 Try the <a href="!ajax_link">AJAX version</a> and the <a href="!non_ajax_link">simulated-non-AJAX version</a>.
185 ', array('!ajax_link' => url('examples/ajax_example/dynamic_sections'), '!non_ajax_link' => url('examples/ajax_example/dynamic_sections_no_js') )) . '</div>',
186 );
187 $form['question_type_select'] = array(
188 '#type' => 'select',
189 '#title' => t('Question style'),
190 '#options' => drupal_map_assoc(array(t('Choose question style'), t('Multiple Choice'), t('True/False'), t('Fill-in-the-blanks'))),
191 '#ajax' => array(
192 'wrapper' => 'questions-fieldset-wrapper',
193 'callback' => 'ajax_example_dynamic_sections_select_callback',
194 ),
195 );
196 // The CSS for this module hides this next button if JS is enabled.
197 $form['question_type_submit'] = array(
198 '#type' => 'submit',
199 '#value' => t('Choose'),
200 '#attributes' => array('class' => array('next-button')),
201 '#limit_validation_errors' => array(), // No need to validate when submitting this.
202 '#validate' => array(),
203 );
204
205 // This simply allows us to demonstrate no-javascript use without
206 // actually turning off javascript in the browser. Removing the #ajax
207 // element turns off AJAX behaviors on that element and as a result
208 // ajax.js doesn't get loaded.
209 if ($no_js_use) {
210 // Remove the #ajax from the above, so ajax.js won't be loaded.
211 unset($form['question_type_select']['#ajax']);
212 }
213
214 // This fieldset just serves as a container for the part of the form
215 // that gets rebuilt.
216 $form['questions_fieldset'] = array(
217 '#type' => 'fieldset',
218 // These provide the wrapper referred to in #ajax['wrapper'] above.
219 '#prefix' => '<div id="questions-fieldset-wrapper">',
220 '#suffix' => '</div>',
221 );
222 if (!empty($form_state['values']['question_type_select'])) {
223
224 $form['questions_fieldset']['question'] = array(
225 '#markup' => t('Who was the first president of the U.S.?'),
226 );
227 $question_type = $form_state['values']['question_type_select'];
228
229 switch ($question_type) {
230 case t('Multiple Choice'):
231 $form['questions_fieldset']['question'] = array(
232 '#type' => 'radios',
233 '#title' => t('Who was the first president of the United States'),
234 '#options' => drupal_map_assoc(array(t('George Bush'), t('Adam McGuire'), t('Abraham Lincoln'), t('George Washington'))),
235 );
236 break;
237
238 case t('True/False'):
239 $form['questions_fieldset']['question'] = array(
240 '#type' => 'radios',
241 '#title' => t('Was George Washington the first president of the United States?'),
242 '#options' => array(t('George Washington') => t("True"), 0 => t("False")),
243 '#description' => t('Click "True" if you think George Washington was the first president of the United States.'),
244 );
245 break;
246
247 case t('Fill-in-the-blanks'):
248 $form['questions_fieldset']['question'] = array(
249 '#type' => 'textfield',
250 '#title' => t('Who was the first president of the United States'),
251 '#description' => t('Please type the correct answer to the question.'),
252 );
253 break;
254 }
255
256 $form['questions_fieldset']['submit'] = array(
257 '#type' => 'submit',
258 '#value' => t('Submit your answer'),
259 );
260 }
261 return $form;
262 }
263
267 function ajax_example_dynamic_sections_validate($form, &$form_state) {
268 $answer = $form_state['values']['question'];
269 if ($answer !== t('George Washington')) {
270 form_set_error('question', t('Wrong answer. Try again. (Hint: The right answer is "George Washington".)'));
271 }
272 }
273
277 function ajax_example_dynamic_sections_submit($form, &$form_state) {
278 // This is only executed when a button is pressed, not when the AJAXified
279 // select is changed.
280 // Now handle the case of the next, previous, and submit buttons.
281 // Only submit will result in actual submission, all others rebuild.
282 switch ($form_state['triggering_element']['#value']) {
283 case t('Submit your answer'): // Submit: We're done.
284 $form_state['rebuild'] = FALSE;
285 $answer = $form_state['values']['question'];
286
287 // Special handling for the checkbox.
288 if ($answer == 1 && $form['questions_fieldset']['question']['#type'] == 'checkbox') {
289 $answer = $form['questions_fieldset']['question']['#title'];
290 }
291 if ($answer === t('George Washington')) {
292 drupal_set_message(t('You got the right answer: @answer', array('@answer' => $answer)));
293 }
294 else {
295 drupal_set_message(t('Sorry, your answer (@answer) is wrong', array('@answer' => $answer)));
296 }
297 $form_state['rebuild'] = FALSE;
298 return;
299 // Any other form element will cause rebuild of the form and present
300 // it again.
301 case t('Choose'):
302 $form_state['values']['question_type_select'] =
303 $form_state['input']['question_type_select'];
304 // Fall through.
305 default:
306 $form_state['rebuild'] = TRUE;
307 }
308 }
309
315 function ajax_example_dynamic_sections_select_callback($form, $form_state) {
316 return $form['questions_fieldset'];
317 }
318
319
334 function ajax_example_wizard($form, &$form_state, $no_js_use = FALSE) {
335
336 // Provide a wrapper around the entire form, since we'll replace the whole
337 // thing with each submit.
338 $form['#prefix'] = '<div id="wizard-form-wrapper">';
339 $form['#suffix'] = '</div>';
340 $form['#tree'] = TRUE; // We want to deal with hierarchical form values.
341
342 $form['description'] = array(
343 '#markup' => '<div>' . t('This example is a step-by-step wizard. The <a href="!ajax">AJAX version</a> does it without page reloads; the <a href="!multistep">multistep version</a> is the same code but simulates a non-javascript environment, showing it with page reloads.',
344 array('!ajax' => url('examples/ajax_example/wizard'), '!multistep' => url('examples/ajax_example/wizard_no_js')))
345 . '</div>',
346 );
347
348 // $form_state['storage'] has no specific drupal meaning, but it is
349 // traditional to keep variables for multistep forms there.
350 $step = empty($form_state['storage']['step']) ? 1 : $form_state['storage']['step'];
351 $form_state['storage']['step'] = $step;
352
353 switch ($step) {
354 case 1:
355 $form['step1'] = array(
356 '#type' => 'fieldset',
357 '#title' => t('Step 1: Personal details'),
358 );
359 $form['step1']['name'] = array(
360 '#type' => 'textfield',
361 '#title' => t('Your name'),
362 '#default_value' => empty($form_state['values']['step1']['name']) ? '' : $form_state['values']['step1']['name'],
363 '#required' => TRUE,
364 );
365 break;
366
367 case 2:
368 $form['step2'] = array(
369 '#type' => 'fieldset',
370 '#title' => t('Step 2: Street address info'),
371 );
372 $form['step2']['address'] = array(
373 '#type' => 'textfield',
374 '#title' => t('Your street address'),
375 '#default_value' => empty($form_state['values']['step2']['address']) ? '' : $form_state['values']['step2']['address'],
376 '#required' => TRUE,
377 );
378 break;
379
380 case 3:
381 $form['step3'] = array(
382 '#type' => 'fieldset',
383 '#title' => t('Step 3: City info'),
384 );
385 $form['step3']['city'] = array(
386 '#type' => 'textfield',
387 '#title' => t('Your city'),
388 '#default_value' => empty($form_state['values']['step3']['city']) ? '' : $form_state['values']['step3']['city'],
389 '#required' => TRUE,
390 );
391 break;
392 }
393 if ($step == 3) {
394 $form['submit'] = array(
395 '#type' => 'submit',
396 '#value' => t("Submit your information"),
397 );
398 }
399 if ($step < 3) {
400 $form['next'] = array(
401 '#type' => 'submit',
402 '#value' => t('Next step'),
403 '#ajax' => array(
404 'wrapper' => 'wizard-form-wrapper',
405 'callback' => 'ajax_example_wizard_callback',
406 ),
407 );
408 }
409 if ($step > 1) {
410 $form['prev'] = array(
411 '#type' => 'submit',
412 '#value' => t("Previous step"),
413
414 // Since all info will be discarded, don't validate on 'prev'.
415 '#limit_validation_errors' => array(),
416 // #submit is required to use #limit_validation_errors
417 '#submit' => array('ajax_example_wizard_submit'),
418 '#ajax' => array(
419 'wrapper' => 'wizard-form-wrapper',
420 'callback' => 'ajax_example_wizard_callback',
421 ),
422 );
423 }
424
425 // This simply allows us to demonstrate no-javascript use without
426 // actually turning off javascript in the browser. Removing the #ajax
427 // element turns off AJAX behaviors on that element and as a result
428 // ajax.js doesn't get loaded.
429 // For demonstration only! You don't need this.
430 if ($no_js_use) {
431 // Remove the #ajax from the above, so ajax.js won't be loaded.
432 // For demonstration only.
433 unset($form['next']['#ajax']);
434 unset($form['prev']['#ajax']);
435 }
436
437 return $form;
438 }
439
440 function ajax_example_wizard_callback($form, $form_state) {
441 return $form;
442 }
443
451 function ajax_example_wizard_submit($form, &$form_state) {
452
453 // Save away the current information.
454 $current_step = 'step' . $form_state['storage']['step'];
455 if (!empty($form_state['values'][$current_step])) {
456 $form_state['storage']['values'][$current_step] = $form_state['values'][$current_step];
457 }
458
459 // Increment or decrement the step as needed. Recover values if they exist.
460 if ($form_state['triggering_element']['#value'] == t('Next step')) {
461 $form_state['storage']['step']++;
462 // If values have already been entered for this step, recover them from
463 // $form_state['storage'] to pre-populate them.
464 $step_name = 'step' . $form_state['storage']['step'];
465 if (!empty($form_state['storage']['values'][$step_name])) {
466 $form_state['values'][$step_name] = $form_state['storage']['values'][$step_name];
467 }
468 }
469 if ($form_state['triggering_element']['#value'] == t('Previous step')) {
470 $form_state['storage']['step']--;
471 // Recover our values from $form_state['storage'] to pre-populate them.
472 $step_name = 'step' . $form_state['storage']['step'];
473 $form_state['values'][$step_name] = $form_state['storage']['values'][$step_name];
474 }
475
476 // If they're done, submit.
477 if ($form_state['triggering_element']['#value'] == t('Submit your information')) {
478 $value_message = t('Your information has been submitted:') . ' ';
479 foreach ($form_state['storage']['values'] as $step => $values) {
480 $value_message .= "$step: ";
481 foreach ($values as $key => $value) {
482 $value_message .= "$key=$value, ";
483 }
484 }
485 drupal_set_message($value_message);
486 $form_state['rebuild'] = FALSE;
487 return;
488 }
489
490 // Otherwise, we still have work to do.
491 $form_state['rebuild'] = TRUE;
492 }
493
494
511 function ajax_example_add_more($form, &$form_state, $no_js_use = FALSE) {
512 $form['description'] = array(
513 '#markup' => '<div>' . t('This example shows an add-more and a remove-last button. The <a href="!ajax">AJAX version</a> does it without page reloads; the <a href="!multistep">non-js version</a> is the same code but simulates a non-javascript environment, showing it with page reloads.',
514 array('!ajax' => url('examples/ajax_example/add_more'), '!multistep' => url('examples/ajax_example/add_more_no_js')))
515 . '</div>',
516 );
517
518 // Because we have many fields with the same values, we have to set
519 // #tree to be able to access them.
520 $form['#tree'] = TRUE;
521 $form['names_fieldset'] = array(
522 '#type' => 'fieldset',
523 '#title' => t('People coming to the picnic'),
524 // Set up the wrapper so that AJAX will be able to replace the fieldset.
525 '#prefix' => '<div id="names-fieldset-wrapper">',
526 '#suffix' => '</div>',
527 );
528
529 // Build the fieldset with the proper number of names. We'll use
530 // $form_state['num_names'] to determine the number of textfields to build.
531 if (empty($form_state['num_names'])) {
532 $form_state['num_names'] = 1;
533 }
534 for ($i = 0; $i < $form_state['num_names']; $i++) {
535 $form['names_fieldset']['name'][$i] = array(
536 '#type' => 'textfield',
537 '#title' => t('Name'),
538 );
539 }
540 $form['names_fieldset']['add_name'] = array(
541 '#type' => 'submit',
542 '#value' => t('Add one more'),
543 '#submit' => array('ajax_example_add_more_add_one'),
544 // See the examples in ajax_example.module for more details on the
545 // properties of #ajax.
546 '#ajax' => array(
547 'callback' => 'ajax_example_add_more_callback',
548 'wrapper' => 'names-fieldset-wrapper',
549 ),
550 );
551 if ($form_state['num_names'] > 1) {
552 $form['names_fieldset']['remove_name'] = array(
553 '#type' => 'submit',
554 '#value' => t('Remove one'),
555 '#submit' => array('ajax_example_add_more_remove_one'),
556 '#ajax' => array(
557 'callback' => 'ajax_example_add_more_callback',
558 'wrapper' => 'names-fieldset-wrapper',
559 ),
560 );
561 }
562 $form['submit'] = array(
563 '#type' => 'submit',
564 '#value' => t('Submit'),
565 );
566
567 // This simply allows us to demonstrate no-javascript use without
568 // actually turning off javascript in the browser. Removing the #ajax
569 // element turns off AJAX behaviors on that element and as a result
570 // ajax.js doesn't get loaded.
571 // For demonstration only! You don't need this.
572 if ($no_js_use) {
573 // Remove the #ajax from the above, so ajax.js won't be loaded.
574 if (!empty($form['names_fieldset']['remove_name']['#ajax'])) {
575 unset($form['names_fieldset']['remove_name']['#ajax']);
576 }
577 unset($form['names_fieldset']['add_name']['#ajax']);
578 }
579
580 return $form;
581 }
582
588 function ajax_example_add_more_callback($form, $form_state) {
589 return $form['names_fieldset'];
590 }
591
597 function ajax_example_add_more_add_one($form, &$form_state) {
598 $form_state['num_names']++;
599 $form_state['rebuild'] = TRUE;
600 }
601
607 function ajax_example_add_more_remove_one($form, &$form_state) {
608 if ($form_state['num_names'] > 1) {
609 $form_state['num_names']--;
610 }
611 $form_state['rebuild'] = TRUE;
612 }
613
619 function ajax_example_add_more_submit($form, &$form_state) {
620 $output = t('These people are coming to the picnic: @names',
621 array('@names' => implode(', ', $form_state['values']['names_fieldset']['name'])) );
622 drupal_set_message($output);
623 }
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
ajax_example_add_more_remove_one
ajax_example_add_more_remove_one($form, &$form_state)
Definition: ajax_example_graceful_degradation.inc:607
drupal_get_path
drupal_get_path($type, $name)
Definition: common.inc:2803
_ajax_example_get_second_dropdown_options
_ajax_example_get_second_dropdown_options($key= '')
Definition: ajax_example.module:600
ajax_example_add_more
ajax_example_add_more($form, &$form_state, $no_js_use=FALSE)
Definition: ajax_example_graceful_degradation.inc:511
ajax_example_wizard
ajax_example_wizard($form, &$form_state, $no_js_use=FALSE)
Definition: ajax_example_graceful_degradation.inc:334
ajax_example_dynamic_sections_select_callback
ajax_example_dynamic_sections_select_callback($form, $form_state)
Definition: ajax_example_graceful_degradation.inc:315
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
ajax_example_dependent_dropdown_degrades_submit
ajax_example_dependent_dropdown_degrades_submit($form, &$form_state)
Definition: ajax_example_graceful_degradation.inc:127
ajax_example_dynamic_sections
ajax_example_dynamic_sections($form, &$form_state, $no_js_use=FALSE)
Definition: ajax_example_graceful_degradation.inc:163
_ajax_example_get_first_dropdown_options
_ajax_example_get_first_dropdown_options()
Definition: ajax_example.module:586
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
ajax_example_wizard_callback
ajax_example_wizard_callback($form, $form_state)
Definition: ajax_example_graceful_degradation.inc:440
$output
$output
Definition: authorize.php:93
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
ajax_example_dynamic_sections_submit
ajax_example_dynamic_sections_submit($form, &$form_state)
Definition: ajax_example_graceful_degradation.inc:277
ajax_example_wizard_submit
ajax_example_wizard_submit($form, &$form_state)
Definition: ajax_example_graceful_degradation.inc:451
ajax_example_add_more_submit
ajax_example_add_more_submit($form, &$form_state)
Definition: ajax_example_graceful_degradation.inc:619
ajax_example_add_more_add_one
ajax_example_add_more_add_one($form, &$form_state)
Definition: ajax_example_graceful_degradation.inc:597
ajax_example_add_more_callback
ajax_example_add_more_callback($form, $form_state)
Definition: ajax_example_graceful_degradation.inc:588
ajax_example_dependent_dropdown_degrades_first_callback
ajax_example_dependent_dropdown_degrades_first_callback($form, $form_state)
Definition: ajax_example_graceful_degradation.inc:147
ajax_example_dependent_dropdown_degrades
ajax_example_dependent_dropdown_degrades($form, &$form_state, $no_js_use=FALSE)
Definition: ajax_example_graceful_degradation.inc:38
ajax_example_dynamic_sections_validate
ajax_example_dynamic_sections_validate($form, &$form_state)
Definition: ajax_example_graceful_degradation.inc:267
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/color/color.install Source File

  • modules
  • color
color.install
Go to the documentation of this file.
1 <?php
2
11 function color_requirements($phase) {
12 $requirements = array();
13
14 if ($phase == 'runtime') {
15 // Check for the PHP GD library.
16 if (function_exists('imagegd2')) {
17 $info = gd_info();
18 $requirements['color_gd'] = array(
19 'value' => $info['GD Version'],
20 );
21
22 // Check for PNG support.
23 if (function_exists('imagecreatefrompng')) {
24 $requirements['color_gd']['severity'] = REQUIREMENT_OK;
25 }
26 else {
27 $requirements['color_gd']['severity'] = REQUIREMENT_WARNING;
28 $requirements['color_gd']['description'] = t('The GD library for PHP is enabled, but was compiled without PNG support. Check the <a href="@url">PHP image documentation</a> for information on how to correct this.', array('@url' => 'http://www.php.net/manual/ref.image.php'));
29 }
30 }
31 else {
32 $requirements['color_gd'] = array(
33 'value' => t('Not installed'),
34 'severity' => REQUIREMENT_ERROR,
35 'description' => t('The GD library for PHP is missing or outdated. Check the <a href="@url">PHP image documentation</a> for information on how to correct this.', array('@url' => 'http://www.php.net/manual/book.image.php')),
36 );
37 }
38 $requirements['color_gd']['title'] = t('GD library PNG support');
39 }
40
41 return $requirements;
42 }
43
52 function color_update_7001() {
53 $theme_palettes = db_query("SELECT name FROM {variable} WHERE name LIKE 'color_%_palette'")->fetchCol();
54 foreach ($theme_palettes as $name) {
55 $palette = variable_get($name, array());
56 foreach ($palette as $key => $color) {
57 if (!preg_match('/^#([a-f0-9]{3}){1,2}$/iD', $color)) {
58 drupal_set_message('Some of the custom CSS color codes specified via the color module are invalid. Please examine the themes which are making use of the color module at the <a href="'. url('admin/appearance/settings') .'">Appearance settings</a> page to verify their CSS color values.', 'warning');
59 }
60 }
61 }
62 }
63
$name
print $name
Definition: profile-listing.tpl.php:43
REQUIREMENT_WARNING
const REQUIREMENT_WARNING
Definition: install.inc:31
REQUIREMENT_ERROR
const REQUIREMENT_ERROR
Definition: install.inc:36
REQUIREMENT_OK
const REQUIREMENT_OK
Definition: install.inc:26
color_update_7001
color_update_7001()
Definition: color.install:52
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
url
url($path=NULL, array $options=array())
Definition: common.inc:2181
$info
$info
Definition: color.inc:6
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
color_requirements
color_requirements($phase)
Definition: color.install:11
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/comment/comment-wrapper.tpl.php Source File

  • modules
  • comment
comment-wrapper.tpl.php
Go to the documentation of this file.
1 <?php
2
38 ?>
39 <div id="comments" class="<?php print $classes; ?>"<?php print $attributes; ?>>
40 <?php if ($content['comments'] && $node->type != 'forum'): ?>
41 <?php print render($title_prefix); ?>
42 <h2 class="title"><?php print t('Comments'); ?></h2>
43 <?php print render($title_suffix); ?>
44 <?php endif; ?>
45
46 <?php print render($content['comments']); ?>
47
48 <?php if ($content['comment_form']): ?>
49 <h2 class="title comment-form"><?php print t('Add new comment'); ?></h2>
50 <?php print render($content['comment_form']); ?>
51 <?php endif; ?>
52 </div>
$attributes
print $attributes
Definition: block.tpl.php:47
print
print
Definition: php-2.php:2
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
endif
endif
Definition: aggregator-item.tpl.php:31
render
render(&$element)
Definition: common.inc:5988
$content
print $content
Definition: contextual-links-example-object.tpl.php:35
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/file.inc Source File

  • includes
file.inc
Go to the documentation of this file.
1 <?php
2
15 require_once DRUPAL_ROOT . '/includes/stream_wrappers.inc';
16
41 define('FILE_CREATE_DIRECTORY', 1);
42
46 define('FILE_MODIFY_PERMISSIONS', 2);
47
51 define('FILE_EXISTS_RENAME', 0);
52
56 define('FILE_EXISTS_REPLACE', 1);
57
61 define('FILE_EXISTS_ERROR', 2);
62
70 define('FILE_STATUS_PERMANENT', 1);
71
123 function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) {
124 $wrappers_storage = &drupal_static(__FUNCTION__);
125
126 if (!isset($wrappers_storage)) {
127 $wrappers = module_invoke_all('stream_wrappers');
128 foreach ($wrappers as $scheme => $info) {
129 // Add defaults.
130 $wrappers[$scheme] += array('type' => STREAM_WRAPPERS_NORMAL);
131 }
132 drupal_alter('stream_wrappers', $wrappers);
133 $existing = stream_get_wrappers();
134 foreach ($wrappers as $scheme => $info) {
135 // We only register classes that implement our interface.
136 if (in_array('DrupalStreamWrapperInterface', class_implements($info['class']), TRUE)) {
137 // Record whether we are overriding an existing scheme.
138 if (in_array($scheme, $existing, TRUE)) {
139 $wrappers[$scheme]['override'] = TRUE;
140 stream_wrapper_unregister($scheme);
141 }
142 else {
143 $wrappers[$scheme]['override'] = FALSE;
144 }
145 if (($info['type'] & STREAM_WRAPPERS_LOCAL) == STREAM_WRAPPERS_LOCAL) {
146 stream_wrapper_register($scheme, $info['class']);
147 }
148 else {
149 stream_wrapper_register($scheme, $info['class'], STREAM_IS_URL);
150 }
151 }
152 // Pre-populate the static cache with the filters most typically used.
153 $wrappers_storage[STREAM_WRAPPERS_ALL][$scheme] = $wrappers[$scheme];
154 if (($info['type'] & STREAM_WRAPPERS_WRITE_VISIBLE) == STREAM_WRAPPERS_WRITE_VISIBLE) {
155 $wrappers_storage[STREAM_WRAPPERS_WRITE_VISIBLE][$scheme] = $wrappers[$scheme];
156 }
157 }
158 }
159
160 if (!isset($wrappers_storage[$filter])) {
161 $wrappers_storage[$filter] = array();
162 foreach ($wrappers_storage[STREAM_WRAPPERS_ALL] as $scheme => $info) {
163 // Bit-wise filter.
164 if (($info['type'] & $filter) == $filter) {
165 $wrappers_storage[$filter][$scheme] = $info;
166 }
167 }
168 }
169
170 return $wrappers_storage[$filter];
171 }
172
182 function file_stream_wrapper_get_class($scheme) {
183 $wrappers = file_get_stream_wrappers();
184 return empty($wrappers[$scheme]) ? FALSE : $wrappers[$scheme]['class'];
185 }
186
199 function file_uri_scheme($uri) {
200 $position = strpos($uri, '://');
201 return $position ? substr($uri, 0, $position) : FALSE;
202 }
203
218 function file_stream_wrapper_valid_scheme($scheme) {
219 // Does the scheme have a registered handler that is callable?
220 $class = file_stream_wrapper_get_class($scheme);
221 if (class_exists($class)) {
222 return TRUE;
223 }
224 else {
225 return FALSE;
226 }
227 }
228
229
243 function file_uri_target($uri) {
244 $data = explode('://', $uri, 2);
245
246 // Remove erroneous leading or trailing, forward-slashes and backslashes.
247 return count($data) == 2 ? trim($data[1], '\/') : FALSE;
248 }
249
256 function file_default_scheme() {
257 return variable_get('file_default_scheme', 'public');
258 }
259
275 function file_stream_wrapper_uri_normalize($uri) {
276 $scheme = file_uri_scheme($uri);
277
278 if ($scheme && file_stream_wrapper_valid_scheme($scheme)) {
279 $target = file_uri_target($uri);
280
281 if ($target !== FALSE) {
282 $uri = $scheme . '://' . $target;
283 }
284 }
285 return $uri;
286 }
287
303 function file_stream_wrapper_get_instance_by_uri($uri) {
304 $scheme = file_uri_scheme($uri);
305 $class = file_stream_wrapper_get_class($scheme);
306 if (class_exists($class)) {
307 $instance = new $class();
308 $instance->setUri($uri);
309 return $instance;
310 }
311 else {
312 return FALSE;
313 }
314 }
315
336 function file_stream_wrapper_get_instance_by_scheme($scheme) {
337 $class = file_stream_wrapper_get_class($scheme);
338 if (class_exists($class)) {
339 $instance = new $class();
340 $instance->setUri($scheme . '://');
341 return $instance;
342 }
343 else {
344 return FALSE;
345 }
346 }
347
372 function file_create_url($uri) {
373 // Allow the URI to be altered, e.g. to serve a file from a CDN or static
374 // file server.
375 drupal_alter('file_url', $uri);
376
377 $scheme = file_uri_scheme($uri);
378
379 if (!$scheme) {
380 // Allow for:
381 // - root-relative URIs (e.g. /foo.jpg in http://example.com/foo.jpg)
382 // - protocol-relative URIs (e.g. //bar.jpg, which is expanded to
383 // http://example.com/bar.jpg by the browser when viewing a page over
384 // HTTP and to https://example.com/bar.jpg when viewing a HTTPS page)
385 // Both types of relative URIs are characterized by a leading slash, hence
386 // we can use a single check.
387 if (drupal_substr($uri, 0, 1) == '/') {
388 return $uri;
389 }
390 else {
391 // If this is not a properly formatted stream, then it is a shipped file.
392 // Therefore, return the urlencoded URI with the base URL prepended.
393 return $GLOBALS['base_url'] . '/' . drupal_encode_path($uri);
394 }
395 }
396 elseif ($scheme == 'http' || $scheme == 'https') {
397 // Check for HTTP so that we don't have to implement getExternalUrl() for
398 // the HTTP wrapper.
399 return $uri;
400 }
401 else {
402 // Attempt to return an external URL using the appropriate wrapper.
403 if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
404 return $wrapper->getExternalUrl();
405 }
406 else {
407 return FALSE;
408 }
409 }
410 }
411
430 function file_prepare_directory(&$directory, $options = FILE_MODIFY_PERMISSIONS) {
431 if (!file_stream_wrapper_valid_scheme(file_uri_scheme($directory))) {
432 // Only trim if we're not dealing with a stream.
433 $directory = rtrim($directory, '/\\');
434 }
435
436 // Check if directory exists.
437 if (!is_dir($directory)) {
438 // Let mkdir() recursively create directories and use the default directory
439 // permissions.
440 if (($options & FILE_CREATE_DIRECTORY) && @drupal_mkdir($directory, NULL, TRUE)) {
441 return drupal_chmod($directory);
442 }
443 return FALSE;
444 }
445 // The directory exists, so check to see if it is writable.
446 $writable = is_writable($directory);
447 if (!$writable && ($options & FILE_MODIFY_PERMISSIONS)) {
448 return drupal_chmod($directory);
449 }
450
451 return $writable;
452 }
453
457 function file_ensure_htaccess() {
458 file_create_htaccess('public://', FALSE);
459 if (variable_get('file_private_path', FALSE)) {
460 file_create_htaccess('private://', TRUE);
461 }
462 file_create_htaccess('temporary://', TRUE);
463 }
464
477 function file_create_htaccess($directory, $private = TRUE, $force_overwrite = FALSE) {
478 if (file_uri_scheme($directory)) {
479 $directory = file_stream_wrapper_uri_normalize($directory);
480 }
481 else {
482 $directory = rtrim($directory, '/\\');
483 }
484 $htaccess_path = $directory . '/.htaccess';
485
486 if (file_exists($htaccess_path) && !$force_overwrite) {
487 // Short circuit if the .htaccess file already exists.
488 return;
489 }
490
491 $htaccess_lines = file_htaccess_lines($private);
492
493 // Write the .htaccess file.
494 if (file_put_contents($htaccess_path, $htaccess_lines)) {
495 drupal_chmod($htaccess_path, 0444);
496 }
497 else {
498 $variables = array('%directory' => $directory, '!htaccess' => '<br />' . nl2br(check_plain($htaccess_lines)));
499 watchdog('security', "Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines: <code>!htaccess</code>", $variables, WATCHDOG_ERROR);
500 }
501 }
502
516 function file_htaccess_lines($private = TRUE) {
517 $lines = <<<EOF
518 # Turn off all options we don't need.
519 Options None
520 Options +FollowSymLinks
521
522 # Set the catch-all handler to prevent scripts from being executed.
523 SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
524 <Files *>
525 # Override the handler again if we're run later in the evaluation list.
526 SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
527 </Files>
528
529 # If we know how to do it safely, disable the PHP engine entirely.
530 <IfModule mod_php5.c>
531 php_flag engine off
532 </IfModule>
533 EOF;
534
535 if ($private) {
536 $lines = "Deny from all\n\n" . $lines;
537 }
538
539 return $lines;
540 }
541
564 function file_load_multiple($fids = array(), $conditions = array()) {
565 return entity_load('file', $fids, $conditions);
566 }
567
580 function file_load($fid) {
581 $files = file_load_multiple(array($fid), array());
582 return reset($files);
583 }
584
599 function file_save(stdClass $file) {
600 $file->timestamp = REQUEST_TIME;
601 $file->filesize = filesize($file->uri);
602
603 // Load the stored entity, if any.
604 if (!empty($file->fid) && !isset($file->original)) {
605 $file->original = entity_load_unchanged('file', $file->fid);
606 }
607
608 module_invoke_all('file_presave', $file);
609 module_invoke_all('entity_presave', $file, 'file');
610
611 if (empty($file->fid)) {
612 drupal_write_record('file_managed', $file);
613 // Inform modules about the newly added file.
614 module_invoke_all('file_insert', $file);
615 module_invoke_all('entity_insert', $file, 'file');
616 }
617 else {
618 drupal_write_record('file_managed', $file, 'fid');
619 // Inform modules that the file has been updated.
620 module_invoke_all('file_update', $file);
621 module_invoke_all('entity_update', $file, 'file');
622 }
623
624 unset($file->original);
625 return $file;
626 }
627
642 function file_usage_list(stdClass $file) {
643 $result = db_select('file_usage', 'f')
644 ->fields('f', array('module', 'type', 'id', 'count'))
645 ->condition('fid', $file->fid)
646 ->condition('count', 0, '>')
647 ->execute();
648 $references = array();
649 foreach ($result as $usage) {
650 $references[$usage->module][$usage->type][$usage->id] = $usage->count;
651 }
652 return $references;
653 }
654
682 function file_usage_add(stdClass $file, $module, $type, $id, $count = 1) {
683 db_merge('file_usage')
684 ->key(array(
685 'fid' => $file->fid,
686 'module' => $module,
687 'type' => $type,
688 'id' => $id,
689 ))
690 ->fields(array('count' => $count))
691 ->expression('count', 'count + :count', array(':count' => $count))
692 ->execute();
693 }
694
720 function file_usage_delete(stdClass $file, $module, $type = NULL, $id = NULL, $count = 1) {
721 // Delete rows that have a exact or less value to prevent empty rows.
722 $query = db_delete('file_usage')
723 ->condition('module', $module)
724 ->condition('fid', $file->fid);
725 if ($type && $id) {
726 $query
727 ->condition('type', $type)
728 ->condition('id', $id);
729 }
730 if ($count) {
731 $query->condition('count', $count, '<=');
732 }
733 $result = $query->execute();
734
735 // If the row has more than the specified count decrement it by that number.
736 if (!$result && $count > 0) {
737 $query = db_update('file_usage')
738 ->condition('module', $module)
739 ->condition('fid', $file->fid);
740 if ($type && $id) {
741 $query
742 ->condition('type', $type)
743 ->condition('id', $id);
744 }
745 $query->expression('count', 'count - :count', array(':count' => $count));
746 $query->execute();
747 }
748 }
749
786 function file_copy(stdClass $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
787 if (!file_valid_uri($destination)) {
788 if (($realpath = drupal_realpath($source->uri)) !== FALSE) {
789 watchdog('file', 'File %file (%realpath) could not be copied, because the destination %destination is invalid. This is often caused by improper use of file_copy() or a missing stream wrapper.', array('%file' => $source->uri, '%realpath' => $realpath, '%destination' => $destination));
790 }
791 else {
792 watchdog('file', 'File %file could not be copied, because the destination %destination is invalid. This is often caused by improper use of file_copy() or a missing stream wrapper.', array('%file' => $source->uri, '%destination' => $destination));
793 }
794 drupal_set_message(t('The specified file %file could not be copied, because the destination is invalid. More information is available in the system log.', array('%file' => $source->uri)), 'error');
795 return FALSE;
796 }
797
798 if ($uri = file_unmanaged_copy($source->uri, $destination, $replace)) {
799 $file = clone $source;
800 $file->fid = NULL;
801 $file->uri = $uri;
802 $file->filename = drupal_basename($uri);
803 // If we are replacing an existing file re-use its database record.
804 if ($replace == FILE_EXISTS_REPLACE) {
805 $existing_files = file_load_multiple(array(), array('uri' => $uri));
806 if (count($existing_files)) {
807 $existing = reset($existing_files);
808 $file->fid = $existing->fid;
809 $file->filename = $existing->filename;
810 }
811 }
812 // If we are renaming around an existing file (rather than a directory),
813 // use its basename for the filename.
814 elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) {
815 $file->filename = drupal_basename($destination);
816 }
817
818 $file = file_save($file);
819
820 // Inform modules that the file has been copied.
821 module_invoke_all('file_copy', $file, $source);
822
823 return $file;
824 }
825 return FALSE;
826 }
827
841 function file_valid_uri($uri) {
842 // Assert that the URI has an allowed scheme. Barepaths are not allowed.
843 $uri_scheme = file_uri_scheme($uri);
844 if (empty($uri_scheme) || !file_stream_wrapper_valid_scheme($uri_scheme)) {
845 return FALSE;
846 }
847 return TRUE;
848 }
849
884 function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
885 $original_source = $source;
886 $original_destination = $destination;
887
888 // Assert that the source file actually exists.
889 if (!file_exists($source)) {
890 // @todo Replace drupal_set_message() calls with exceptions instead.
891 drupal_set_message(t('The specified file %file could not be copied, because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $original_source)), 'error');
892 if (($realpath = drupal_realpath($original_source)) !== FALSE) {
893 watchdog('file', 'File %file (%realpath) could not be copied because it does not exist.', array('%file' => $original_source, '%realpath' => $realpath));
894 }
895 else {
896 watchdog('file', 'File %file could not be copied because it does not exist.', array('%file' => $original_source));
897 }
898 return FALSE;
899 }
900
901 // Build a destination URI if necessary.
902 if (!isset($destination)) {
903 $destination = file_build_uri(drupal_basename($source));
904 }
905
906
907 // Prepare the destination directory.
908 if (file_prepare_directory($destination)) {
909 // The destination is already a directory, so append the source basename.
910 $destination = file_stream_wrapper_uri_normalize($destination . '/' . drupal_basename($source));
911 }
912 else {
913 // Perhaps $destination is a dir/file?
914 $dirname = drupal_dirname($destination);
915 if (!file_prepare_directory($dirname)) {
916 // The destination is not valid.
917 watchdog('file', 'File %file could not be copied, because the destination directory %destination is not configured correctly.', array('%file' => $original_source, '%destination' => $dirname));
918 drupal_set_message(t('The specified file %file could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.', array('%file' => $original_source)), 'error');
919 return FALSE;
920 }
921 }
922
923 // Determine whether we can perform this operation based on overwrite rules.
924 $destination = file_destination($destination, $replace);
925 if ($destination === FALSE) {
926 drupal_set_message(t('The file %file could not be copied because a file by that name already exists in the destination directory.', array('%file' => $original_source)), 'error');
927 watchdog('file', 'File %file could not be copied because a file by that name already exists in the destination directory (%directory)', array('%file' => $original_source, '%directory' => $destination));
928 return FALSE;
929 }
930
931 // Assert that the source and destination filenames are not the same.
932 $real_source = drupal_realpath($source);
933 $real_destination = drupal_realpath($destination);
934 if ($source == $destination || ($real_source !== FALSE) && ($real_source == $real_destination)) {
935 drupal_set_message(t('The specified file %file was not copied because it would overwrite itself.', array('%file' => $source)), 'error');
936 watchdog('file', 'File %file could not be copied because it would overwrite itself.', array('%file' => $source));
937 return FALSE;
938 }
939 // Make sure the .htaccess files are present.
940 file_ensure_htaccess();
941 // Perform the copy operation.
942 if (!@copy($source, $destination)) {
943 // If the copy failed and realpaths exist, retry the operation using them
944 // instead.
945 if ($real_source === FALSE || $real_destination === FALSE || !@copy($real_source, $real_destination)) {
946 watchdog('file', 'The specified file %file could not be copied to %destination.', array('%file' => $source, '%destination' => $destination), WATCHDOG_ERROR);
947 return FALSE;
948 }
949 }
950
951 // Set the permissions on the new file.
952 drupal_chmod($destination);
953
954 return $destination;
955 }
956
960 function file_build_uri($path) {
961 $uri = file_default_scheme() . '://' . $path;
962 return file_stream_wrapper_uri_normalize($uri);
963 }
964
981 function file_destination($destination, $replace) {
982 if (file_exists($destination)) {
983 switch ($replace) {
984 case FILE_EXISTS_REPLACE:
985 // Do nothing here, we want to overwrite the existing file.
986 break;
987
988 case FILE_EXISTS_RENAME:
989 $basename = drupal_basename($destination);
990 $directory = drupal_dirname($destination);
991 $destination = file_create_filename($basename, $directory);
992 break;
993
994 case FILE_EXISTS_ERROR:
995 // Error reporting handled by calling function.
996 return FALSE;
997 }
998 }
999 return $destination;
1000 }
1001
1035 function file_move(stdClass $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
1036 if (!file_valid_uri($destination)) {
1037 if (($realpath = drupal_realpath($source->uri)) !== FALSE) {
1038 watchdog('file', 'File %file (%realpath) could not be moved, because the destination %destination is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.', array('%file' => $source->uri, '%realpath' => $realpath, '%destination' => $destination));
1039 }
1040 else {
1041 watchdog('file', 'File %file could not be moved, because the destination %destination is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.', array('%file' => $source->uri, '%destination' => $destination));
1042 }
1043 drupal_set_message(t('The specified file %file could not be moved, because the destination is invalid. More information is available in the system log.', array('%file' => $source->uri)), 'error');
1044 return FALSE;
1045 }
1046
1047 if ($uri = file_unmanaged_move($source->uri, $destination, $replace)) {
1048 $delete_source = FALSE;
1049
1050 $file = clone $source;
1051 $file->uri = $uri;
1052 // If we are replacing an existing file re-use its database record.
1053 if ($replace == FILE_EXISTS_REPLACE) {
1054 $existing_files = file_load_multiple(array(), array('uri' => $uri));
1055 if (count($existing_files)) {
1056 $existing = reset($existing_files);
1057 $delete_source = TRUE;
1058 $file->fid = $existing->fid;
1059 }
1060 }
1061 // If we are renaming around an existing file (rather than a directory),
1062 // use its basename for the filename.
1063 elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) {
1064 $file->filename = drupal_basename($destination);
1065 }
1066
1067 $file = file_save($file);
1068
1069 // Inform modules that the file has been moved.
1070 module_invoke_all('file_move', $file, $source);
1071
1072 if ($delete_source) {
1073 // Try a soft delete to remove original if it's not in use elsewhere.
1074 file_delete($source);
1075 }
1076
1077 return $file;
1078 }
1079 return FALSE;
1080 }
1081
1103 function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
1104 $filepath = file_unmanaged_copy($source, $destination, $replace);
1105 if ($filepath == FALSE || file_unmanaged_delete($source) == FALSE) {
1106 return FALSE;
1107 }
1108 return $filepath;
1109 }
1110
1143 function file_munge_filename($filename, $extensions, $alerts = TRUE) {
1144 $original = $filename;
1145
1146 // Allow potentially insecure uploads for very savvy users and admin
1147 if (!variable_get('allow_insecure_uploads', 0)) {
1148 // Remove any null bytes. See http://php.net/manual/security.filesystem.nullbytes.php
1149 $filename = str_replace(chr(0), '', $filename);
1150
1151 $whitelist = array_unique(explode(' ', trim($extensions)));
1152
1153 // Split the filename up by periods. The first part becomes the basename
1154 // the last part the final extension.
1155 $filename_parts = explode('.', $filename);
1156 $new_filename = array_shift($filename_parts); // Remove file basename.
1157 $final_extension = array_pop($filename_parts); // Remove final extension.
1158
1159 // Loop through the middle parts of the name and add an underscore to the
1160 // end of each section that could be a file extension but isn't in the list
1161 // of allowed extensions.
1162 foreach ($filename_parts as $filename_part) {
1163 $new_filename .= '.' . $filename_part;
1164 if (!in_array($filename_part, $whitelist) && preg_match("/^[a-zA-Z]{2,5}\d?$/", $filename_part)) {
1165 $new_filename .= '_';
1166 }
1167 }
1168 $filename = $new_filename . '.' . $final_extension;
1169
1170 if ($alerts && $original != $filename) {
1171 drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $filename)));
1172 }
1173 }
1174
1175 return $filename;
1176 }
1177
1187 function file_unmunge_filename($filename) {
1188 return str_replace('_.', '.', $filename);
1189 }
1190
1206 function file_create_filename($basename, $directory) {
1207 // Strip control characters (ASCII value < 32). Though these are allowed in
1208 // some filesystems, not many applications handle them well.
1209 $basename = preg_replace('/[\x00-\x1F]/u', '_', $basename);
1210 if (substr(PHP_OS, 0, 3) == 'WIN') {
1211 // These characters are not allowed in Windows filenames
1212 $basename = str_replace(array(':', '*', '?', '"', '<', '>', '|'), '_', $basename);
1213 }
1214
1215 // A URI or path may already have a trailing slash or look like "public://".
1216 if (substr($directory, -1) == '/') {
1217 $separator = '';
1218 }
1219 else {
1220 $separator = '/';
1221 }
1222
1223 $destination = $directory . $separator . $basename;
1224
1225 if (file_exists($destination)) {
1226 // Destination file already exists, generate an alternative.
1227 $pos = strrpos($basename, '.');
1228 if ($pos !== FALSE) {
1229 $name = substr($basename, 0, $pos);
1230 $ext = substr($basename, $pos);
1231 }
1232 else {
1233 $name = $basename;
1234 $ext = '';
1235 }
1236
1237 $counter = 0;
1238 do {
1239 $destination = $directory . $separator . $name . '_' . $counter++ . $ext;
1240 } while (file_exists($destination));
1241 }
1242
1243 return $destination;
1244 }
1245
1268 function file_delete(stdClass $file, $force = FALSE) {
1269 if (!file_valid_uri($file->uri)) {
1270 if (($realpath = drupal_realpath($file->uri)) !== FALSE) {
1271 watchdog('file', 'File %file (%realpath) could not be deleted because it is not a valid URI. This may be caused by improper use of file_delete() or a missing stream wrapper.', array('%file' => $file->uri, '%realpath' => $realpath));
1272 }
1273 else {
1274 watchdog('file', 'File %file could not be deleted because it is not a valid URI. This may be caused by improper use of file_delete() or a missing stream wrapper.', array('%file' => $file->uri));
1275 }
1276 drupal_set_message(t('The specified file %file could not be deleted, because it is not a valid URI. More information is available in the system log.', array('%file' => $file->uri)), 'error');
1277 return FALSE;
1278 }
1279
1280 // If any module still has a usage entry in the file_usage table, the file
1281 // will not be deleted, but file_delete() will return a populated array
1282 // that tests as TRUE.
1283 if (!$force && ($references = file_usage_list($file))) {
1284 return $references;
1285 }
1286
1287 // Let other modules clean up any references to the deleted file.
1288 module_invoke_all('file_delete', $file);
1289 module_invoke_all('entity_delete', $file, 'file');
1290
1291 // Make sure the file is deleted before removing its row from the
1292 // database, so UIs can still find the file in the database.
1293 if (file_unmanaged_delete($file->uri)) {
1294 db_delete('file_managed')->condition('fid', $file->fid)->execute();
1295 db_delete('file_usage')->condition('fid', $file->fid)->execute();
1296 return TRUE;
1297 }
1298 return FALSE;
1299 }
1300
1317 function file_unmanaged_delete($path) {
1318 if (is_dir($path)) {
1319 watchdog('file', '%path is a directory and cannot be removed using file_unmanaged_delete().', array('%path' => $path), WATCHDOG_ERROR);
1320 return FALSE;
1321 }
1322 if (is_file($path)) {
1323 return drupal_unlink($path);
1324 }
1325 // Return TRUE for non-existent file, but log that nothing was actually
1326 // deleted, as the current state is the intended result.
1327 if (!file_exists($path)) {
1328 watchdog('file', 'The file %path was not deleted, because it does not exist.', array('%path' => $path), WATCHDOG_NOTICE);
1329 return TRUE;
1330 }
1331 // We cannot handle anything other than files and directories. Log an error
1332 // for everything else (sockets, symbolic links, etc).
1333 watchdog('file', 'The file %path is not of a recognized type so it was not deleted.', array('%path' => $path), WATCHDOG_ERROR);
1334 return FALSE;
1335 }
1336
1358 function file_unmanaged_delete_recursive($path) {
1359 if (is_dir($path)) {
1360 $dir = dir($path);
1361 while (($entry = $dir->read()) !== FALSE) {
1362 if ($entry == '.' || $entry == '..') {
1363 continue;
1364 }
1365 $entry_path = $path . '/' . $entry;
1366 file_unmanaged_delete_recursive($entry_path);
1367 }
1368 $dir->close();
1369
1370 return drupal_rmdir($path);
1371 }
1372 return file_unmanaged_delete($path);
1373 }
1374
1388 function file_space_used($uid = NULL, $status = FILE_STATUS_PERMANENT) {
1389 $query = db_select('file_managed', 'f');
1390 $query->condition('f.status', $status);
1391 $query->addExpression('SUM(f.filesize)', 'filesize');
1392 if (isset($uid)) {
1393 $query->condition('f.uid', $uid);
1394 }
1395 return $query->execute()->fetchField();
1396 }
1397
1437 function file_save_upload($source, $validators = array(), $destination = FALSE, $replace = FILE_EXISTS_RENAME) {
1438 global $user;
1439 static $upload_cache;
1440
1441 // Return cached objects without processing since the file will have
1442 // already been processed and the paths in _FILES will be invalid.
1443 if (isset($upload_cache[$source])) {
1444 return $upload_cache[$source];
1445 }
1446
1447 // Make sure there's an upload to process.
1448 if (empty($_FILES['files']['name'][$source])) {
1449 return NULL;
1450 }
1451
1452 // Check for file upload errors and return FALSE if a lower level system
1453 // error occurred. For a complete list of errors:
1454 // See http://php.net/manual/features.file-upload.errors.php.
1455 switch ($_FILES['files']['error'][$source]) {
1456 case UPLOAD_ERR_INI_SIZE:
1457 case UPLOAD_ERR_FORM_SIZE:
1458 drupal_set_message(t('The file %file could not be saved, because it exceeds %maxsize, the maximum allowed size for uploads.', array('%file' => $_FILES['files']['name'][$source], '%maxsize' => format_size(file_upload_max_size()))), 'error');
1459 return FALSE;
1460
1461 case UPLOAD_ERR_PARTIAL:
1462 case UPLOAD_ERR_NO_FILE:
1463 drupal_set_message(t('The file %file could not be saved, because the upload did not complete.', array('%file' => $_FILES['files']['name'][$source])), 'error');
1464 return FALSE;
1465
1466 case UPLOAD_ERR_OK:
1467 // Final check that this is a valid upload, if it isn't, use the
1468 // default error handler.
1469 if (is_uploaded_file($_FILES['files']['tmp_name'][$source])) {
1470 break;
1471 }
1472
1473 // Unknown error
1474 default:
1475 drupal_set_message(t('The file %file could not be saved. An unknown error has occurred.', array('%file' => $_FILES['files']['name'][$source])), 'error');
1476 return FALSE;
1477 }
1478
1479 // Begin building file object.
1480 $file = new stdClass();
1481 $file->uid = $user->uid;
1482 $file->status = 0;
1483 $file->filename = trim(drupal_basename($_FILES['files']['name'][$source]), '.');
1484 $file->uri = $_FILES['files']['tmp_name'][$source];
1485 $file->filemime = file_get_mimetype($file->filename);
1486 $file->filesize = $_FILES['files']['size'][$source];
1487
1488 $extensions = '';
1489 if (isset($validators['file_validate_extensions'])) {
1490 if (isset($validators['file_validate_extensions'][0])) {
1491 // Build the list of non-munged extensions if the caller provided them.
1492 $extensions = $validators['file_validate_extensions'][0];
1493 }
1494 else {
1495 // If 'file_validate_extensions' is set and the list is empty then the
1496 // caller wants to allow any extension. In this case we have to remove the
1497 // validator or else it will reject all extensions.
1498 unset($validators['file_validate_extensions']);
1499 }
1500 }
1501 else {
1502 // No validator was provided, so add one using the default list.
1503 // Build a default non-munged safe list for file_munge_filename().
1504 $extensions = 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp';
1505 $validators['file_validate_extensions'] = array();
1506 $validators['file_validate_extensions'][0] = $extensions;
1507 }
1508
1509 if (!empty($extensions)) {
1510 // Munge the filename to protect against possible malicious extension hiding
1511 // within an unknown file type (ie: filename.html.foo).
1512 $file->filename = file_munge_filename($file->filename, $extensions);
1513 }
1514
1515 // Rename potentially executable files, to help prevent exploits (i.e. will
1516 // rename filename.php.foo and filename.php to filename.php.foo.txt and
1517 // filename.php.txt, respectively). Don't rename if 'allow_insecure_uploads'
1518 // evaluates to TRUE.
1519 if (!variable_get('allow_insecure_uploads', 0) && preg_match('/\.(php|pl|py|cgi|asp|js)(\.|$)/i', $file->filename) && (substr($file->filename, -4) != '.txt')) {
1520 $file->filemime = 'text/plain';
1521 $file->uri .= '.txt';
1522 $file->filename .= '.txt';
1523 // The .txt extension may not be in the allowed list of extensions. We have
1524 // to add it here or else the file upload will fail.
1525 if (!empty($extensions)) {
1526 $validators['file_validate_extensions'][0] .= ' txt';
1527 drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $file->filename)));
1528 }
1529 }
1530
1531 // If the destination is not provided, use the temporary directory.
1532 if (empty($destination)) {
1533 $destination = 'temporary://';
1534 }
1535
1536 // Assert that the destination contains a valid stream.
1537 $destination_scheme = file_uri_scheme($destination);
1538 if (!$destination_scheme || !file_stream_wrapper_valid_scheme($destination_scheme)) {
1539 drupal_set_message(t('The file could not be uploaded, because the destination %destination is invalid.', array('%destination' => $destination)), 'error');
1540 return FALSE;
1541 }
1542
1543 $file->source = $source;
1544 // A URI may already have a trailing slash or look like "public://".
1545 if (substr($destination, -1) != '/') {
1546 $destination .= '/';
1547 }
1548 $file->destination = file_destination($destination . $file->filename, $replace);
1549 // If file_destination() returns FALSE then $replace == FILE_EXISTS_ERROR and
1550 // there's an existing file so we need to bail.
1551 if ($file->destination === FALSE) {
1552 drupal_set_message(t('The file %source could not be uploaded because a file by that name already exists in the destination %directory.', array('%source' => $source, '%directory' => $destination)), 'error');
1553 return FALSE;
1554 }
1555
1556 // Add in our check of the the file name length.
1557 $validators['file_validate_name_length'] = array();
1558
1559 // Call the validation functions specified by this function's caller.
1560 $errors = file_validate($file, $validators);
1561
1562 // Check for errors.
1563 if (!empty($errors)) {
1564 $message = t('The specified file %name could not be uploaded.', array('%name' => $file->filename));
1565 if (count($errors) > 1) {
1566 $message .= theme('item_list', array('items' => $errors));
1567 }
1568 else {
1569 $message .= ' ' . array_pop($errors);
1570 }
1571 form_set_error($source, $message);
1572 return FALSE;
1573 }
1574
1575 // Move uploaded files from PHP's upload_tmp_dir to Drupal's temporary
1576 // directory. This overcomes open_basedir restrictions for future file
1577 // operations.
1578 $file->uri = $file->destination;
1579 if (!drupal_move_uploaded_file($_FILES['files']['tmp_name'][$source], $file->uri)) {
1580 form_set_error($source, t('File upload error. Could not move uploaded file.'));
1581 watchdog('file', 'Upload error. Could not move uploaded file %file to destination %destination.', array('%file' => $file->filename, '%destination' => $file->uri));
1582 return FALSE;
1583 }
1584
1585 // Set the permissions on the new file.
1586 drupal_chmod($file->uri);
1587
1588 // If we are replacing an existing file re-use its database record.
1589 if ($replace == FILE_EXISTS_REPLACE) {
1590 $existing_files = file_load_multiple(array(), array('uri' => $file->uri));
1591 if (count($existing_files)) {
1592 $existing = reset($existing_files);
1593 $file->fid = $existing->fid;
1594 }
1595 }
1596
1597 // If we made it this far it's safe to record this file in the database.
1598 if ($file = file_save($file)) {
1599 // Add file to the cache.
1600 $upload_cache[$source] = $file;
1601 return $file;
1602 }
1603 return FALSE;
1604 }
1605
1626 function drupal_move_uploaded_file($filename, $uri) {
1627 $result = @move_uploaded_file($filename, $uri);
1628 // PHP's move_uploaded_file() does not properly support streams if safe_mode
1629 // or open_basedir are enabled so if the move failed, try finding a real path
1630 // and retry the move operation.
1631 if (!$result) {
1632 if ($realpath = drupal_realpath($uri)) {
1633 $result = move_uploaded_file($filename, $realpath);
1634 }
1635 else {
1636 $result = move_uploaded_file($filename, $uri);
1637 }
1638 }
1639
1640 return $result;
1641 }
1642
1664 function file_validate(stdClass &$file, $validators = array()) {
1665 // Call the validation functions specified by this function's caller.
1666 $errors = array();
1667 foreach ($validators as $function => $args) {
1668 if (function_exists($function)) {
1669 array_unshift($args, $file);
1670 $errors = array_merge($errors, call_user_func_array($function, $args));
1671 }
1672 }
1673
1674 // Let other modules perform validation on the new file.
1675 return array_merge($errors, module_invoke_all('file_validate', $file));
1676 }
1677
1687 function file_validate_name_length(stdClass $file) {
1688 $errors = array();
1689
1690 if (empty($file->filename)) {
1691 $errors[] = t("The file's name is empty. Please give a name to the file.");
1692 }
1693 if (strlen($file->filename) > 240) {
1694 $errors[] = t("The file's name exceeds the 240 characters limit. Please rename the file and try again.");
1695 }
1696 return $errors;
1697 }
1698
1713 function file_validate_extensions(stdClass $file, $extensions) {
1714 $errors = array();
1715
1716 $regex = '/\.(' . preg_replace('/ +/', '|', preg_quote($extensions)) . ')$/i';
1717 if (!preg_match($regex, $file->filename)) {
1718 $errors[] = t('Only files with the following extensions are allowed: %files-allowed.', array('%files-allowed' => $extensions));
1719 }
1720 return $errors;
1721 }
1722
1743 function file_validate_size(stdClass $file, $file_limit = 0, $user_limit = 0) {
1744 global $user;
1745
1746 $errors = array();
1747
1748 // Bypass validation for uid = 1.
1749 if ($user->uid != 1) {
1750 if ($file_limit && $file->filesize > $file_limit) {
1751 $errors[] = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($file->filesize), '%maxsize' => format_size($file_limit)));
1752 }
1753
1754 // Save a query by only calling file_space_used() when a limit is provided.
1755 if ($user_limit && (file_space_used($user->uid) + $file->filesize) > $user_limit) {
1756 $errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' => format_size($file->filesize), '%quota' => format_size($user_limit)));
1757 }
1758 }
1759 return $errors;
1760 }
1761
1773 function file_validate_is_image(stdClass $file) {
1774 $errors = array();
1775
1776 $info = image_get_info($file->uri);
1777 if (!$info || empty($info['extension'])) {
1778 $errors[] = t('Only JPEG, PNG and GIF images are allowed.');
1779 }
1780
1781 return $errors;
1782 }
1783
1808 function file_validate_image_resolution(stdClass $file, $maximum_dimensions = 0, $minimum_dimensions = 0) {
1809 $errors = array();
1810
1811 // Check first that the file is an image.
1812 if ($info = image_get_info($file->uri)) {
1813 if ($maximum_dimensions) {
1814 // Check that it is smaller than the given dimensions.
1815 list($width, $height) = explode('x', $maximum_dimensions);
1816 if ($info['width'] > $width || $info['height'] > $height) {
1817 // Try to resize the image to fit the dimensions.
1818 if ($image = image_load($file->uri)) {
1819 image_scale($image, $width, $height);
1820 image_save($image);
1821 $file->filesize = $image->info['file_size'];
1822 drupal_set_message(t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', array('%dimensions' => $maximum_dimensions)));
1823 }
1824 else {
1825 $errors[] = t('The image is too large; the maximum dimensions are %dimensions pixels.', array('%dimensions' => $maximum_dimensions));
1826 }
1827 }
1828 }
1829
1830 if ($minimum_dimensions) {
1831 // Check that it is larger than the given dimensions.
1832 list($width, $height) = explode('x', $minimum_dimensions);
1833 if ($info['width'] < $width || $info['height'] < $height) {
1834 $errors[] = t('The image is too small; the minimum dimensions are %dimensions pixels.', array('%dimensions' => $minimum_dimensions));
1835 }
1836 }
1837 }
1838
1839 return $errors;
1840 }
1841
1865 function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
1866 global $user;
1867
1868 if (empty($destination)) {
1869 $destination = file_default_scheme() . '://';
1870 }
1871 if (!file_valid_uri($destination)) {
1872 watchdog('file', 'The data could not be saved because the destination %destination is invalid. This may be caused by improper use of file_save_data() or a missing stream wrapper.', array('%destination' => $destination));
1873 drupal_set_message(t('The data could not be saved, because the destination is invalid. More information is available in the system log.'), 'error');
1874 return FALSE;
1875 }
1876
1877 if ($uri = file_unmanaged_save_data($data, $destination, $replace)) {
1878 // Create a file object.
1879 $file = new stdClass();
1880 $file->fid = NULL;
1881 $file->uri = $uri;
1882 $file->filename = drupal_basename($uri);
1883 $file->filemime = file_get_mimetype($file->uri);
1884 $file->uid = $user->uid;
1885 $file->status = FILE_STATUS_PERMANENT;
1886 // If we are replacing an existing file re-use its database record.
1887 if ($replace == FILE_EXISTS_REPLACE) {
1888 $existing_files = file_load_multiple(array(), array('uri' => $uri));
1889 if (count($existing_files)) {
1890 $existing = reset($existing_files);
1891 $file->fid = $existing->fid;
1892 $file->filename = $existing->filename;
1893 }
1894 }
1895 // If we are renaming around an existing file (rather than a directory),
1896 // use its basename for the filename.
1897 elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) {
1898 $file->filename = drupal_basename($destination);
1899 }
1900
1901 return file_save($file);
1902 }
1903 return FALSE;
1904 }
1905
1932 function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
1933 // Write the data to a temporary file.
1934 $temp_name = drupal_tempnam('temporary://', 'file');
1935 if (file_put_contents($temp_name, $data) === FALSE) {
1936 drupal_set_message(t('The file could not be created.'), 'error');
1937 return FALSE;
1938 }
1939
1940 // Move the file to its final destination.
1941 return file_unmanaged_move($temp_name, $destination, $replace);
1942 }
1943
1954 function file_transfer($uri, $headers) {
1955 if (ob_get_level()) {
1956 ob_end_clean();
1957 }
1958
1959 foreach ($headers as $name => $value) {
1960 drupal_add_http_header($name, $value);
1961 }
1962 drupal_send_headers();
1963 $scheme = file_uri_scheme($uri);
1964 // Transfer file in 1024 byte chunks to save memory usage.
1965 if ($scheme && file_stream_wrapper_valid_scheme($scheme) && $fd = fopen($uri, 'rb')) {
1966 while (!feof($fd)) {
1967 print fread($fd, 1024);
1968 }
1969 fclose($fd);
1970 }
1971 else {
1972 drupal_not_found();
1973 }
1974 drupal_exit();
1975 }
1976
1989 function file_download() {
1990 // Merge remainder of arguments from GET['q'], into relative file path.
1991 $args = func_get_args();
1992 $scheme = array_shift($args);
1993 $target = implode('/', $args);
1994 $uri = $scheme . '://' . $target;
1995 if (file_stream_wrapper_valid_scheme($scheme) && file_exists($uri)) {
1996 // Let other modules provide headers and controls access to the file.
1997 // module_invoke_all() uses array_merge_recursive() which merges header
1998 // values into a new array. To avoid that and allow modules to override
1999 // headers instead, use array_merge() to merge the returned arrays.
2000 $headers = array();
2001 foreach (module_implements('file_download') as $module) {
2002 $function = $module . '_file_download';
2003 $result = $function($uri);
2004 if ($result == -1) {
2005 // Throw away the headers received so far.
2006 $headers = array();
2007 break;
2008 }
2009 if (isset($result) && is_array($result)) {
2010 $headers = array_merge($headers, $result);
2011 }
2012 }
2013 if (count($headers)) {
2014 file_transfer($uri, $headers);
2015 }
2016 drupal_access_denied();
2017 }
2018 else {
2019 drupal_not_found();
2020 }
2021 drupal_exit();
2022 }
2023
2024
2058 function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
2059 // Merge in defaults.
2060 $options += array(
2061 'nomask' => '/(\.\.?|CVS)$/',
2062 'callback' => 0,
2063 'recurse' => TRUE,
2064 'key' => 'uri',
2065 'min_depth' => 0,
2066 );
2067
2068 $options['key'] = in_array($options['key'], array('uri', 'filename', 'name')) ? $options['key'] : 'uri';
2069 $files = array();
2070 if (is_dir($dir) && $handle = opendir($dir)) {
2071 while (FALSE !== ($filename = readdir($handle))) {
2072 if (!preg_match($options['nomask'], $filename) && $filename[0] != '.') {
2073 $uri = "$dir/$filename";
2074 $uri = file_stream_wrapper_uri_normalize($uri);
2075 if (is_dir($uri) && $options['recurse']) {
2076 // Give priority to files in this folder by merging them in after any subdirectory files.
2077 $files = array_merge(file_scan_directory($uri, $mask, $options, $depth + 1), $files);
2078 }
2079 elseif ($depth >= $options['min_depth'] && preg_match($mask, $filename)) {
2080 // Always use this match over anything already set in $files with the
2081 // same $$options['key'].
2082 $file = new stdClass();
2083 $file->uri = $uri;
2084 $file->filename = $filename;
2085 $file->name = pathinfo($filename, PATHINFO_FILENAME);
2086 $key = $options['key'];
2087 $files[$file->$key] = $file;
2088 if ($options['callback']) {
2089 $options['callback']($uri);
2090 }
2091 }
2092 }
2093 }
2094
2095 closedir($handle);
2096 }
2097
2098 return $files;
2099 }
2100
2108 function file_upload_max_size() {
2109 static $max_size = -1;
2110
2111 if ($max_size < 0) {
2112 // Start with post_max_size.
2113 $max_size = parse_size(ini_get('post_max_size'));
2114
2115 // If upload_max_size is less, then reduce. Except if upload_max_size is
2116 // zero, which indicates no limit.
2117 $upload_max = parse_size(ini_get('upload_max_filesize'));
2118 if ($upload_max > 0 && $upload_max < $max_size) {
2119 $max_size = $upload_max;
2120 }
2121 }
2122 return $max_size;
2123 }
2124
2143 function file_get_mimetype($uri, $mapping = NULL) {
2144 if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
2145 return $wrapper->getMimeType($uri, $mapping);
2146 }
2147 else {
2148 // getMimeType() is not implementation specific, so we can directly
2149 // call it without an instance.
2150 return DrupalLocalStreamWrapper::getMimeType($uri, $mapping);
2151 }
2152 }
2153
2180 function drupal_chmod($uri, $mode = NULL) {
2181 if (!isset($mode)) {
2182 if (is_dir($uri)) {
2183 $mode = variable_get('file_chmod_directory', 0775);
2184 }
2185 else {
2186 $mode = variable_get('file_chmod_file', 0664);
2187 }
2188 }
2189
2190 // If this URI is a stream, pass it off to the appropriate stream wrapper.
2191 // Otherwise, attempt PHP's chmod. This allows use of drupal_chmod even
2192 // for unmanaged files outside of the stream wrapper interface.
2193 if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
2194 if ($wrapper->chmod($mode)) {
2195 return TRUE;
2196 }
2197 }
2198 else {
2199 if (@chmod($uri, $mode)) {
2200 return TRUE;
2201 }
2202 }
2203
2204 watchdog('file', 'The file permissions could not be set on %uri.', array('%uri' => $uri), WATCHDOG_ERROR);
2205 return FALSE;
2206 }
2207
2225 function drupal_unlink($uri, $context = NULL) {
2226 $scheme = file_uri_scheme($uri);
2227 if ((!$scheme || !file_stream_wrapper_valid_scheme($scheme)) && (substr(PHP_OS, 0, 3) == 'WIN')) {
2228 chmod($uri, 0600);
2229 }
2230 if ($context) {
2231 return unlink($uri, $context);
2232 }
2233 else {
2234 return unlink($uri);
2235 }
2236 }
2237
2259 function drupal_realpath($uri) {
2260 // If this URI is a stream, pass it off to the appropriate stream wrapper.
2261 // Otherwise, attempt PHP's realpath. This allows use of drupal_realpath even
2262 // for unmanaged files outside of the stream wrapper interface.
2263 if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
2264 return $wrapper->realpath();
2265 }
2266 // Check that the URI has a value. There is a bug in PHP 5.2 on *BSD systems
2267 // that makes realpath not return FALSE as expected when passing an empty
2268 // variable.
2269 // @todo Remove when Drupal drops support for PHP 5.2.
2270 elseif (!empty($uri)) {
2271 return realpath($uri);
2272 }
2273 return FALSE;
2274 }
2275
2295 function drupal_dirname($uri) {
2296 $scheme = file_uri_scheme($uri);
2297
2298 if ($scheme && file_stream_wrapper_valid_scheme($scheme)) {
2299 return file_stream_wrapper_get_instance_by_scheme($scheme)->dirname($uri);
2300 }
2301 else {
2302 return dirname($uri);
2303 }
2304 }
2305
2317 function drupal_basename($uri, $suffix = NULL) {
2318 $separators = '/';
2319 if (DIRECTORY_SEPARATOR != '/') {
2320 // For Windows OS add special separator.
2321 $separators .= DIRECTORY_SEPARATOR;
2322 }
2323 // Remove right-most slashes when $uri points to directory.
2324 $uri = rtrim($uri, $separators);
2325 // Returns the trailing part of the $uri starting after one of the directory
2326 // separators.
2327 $filename = preg_match('@[^' . preg_quote($separators, '@') . ']+$@', $uri, $matches) ? $matches[0] : '';
2328 // Cuts off a suffix from the filename.
2329 if ($suffix) {
2330 $filename = preg_replace('@' . preg_quote($suffix, '@') . '$@', '', $filename);
2331 }
2332 return $filename;
2333 }
2334
2359 function drupal_mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL) {
2360 if (!isset($mode)) {
2361 $mode = variable_get('file_chmod_directory', 0775);
2362 }
2363
2364 if (!isset($context)) {
2365 return mkdir($uri, $mode, $recursive);
2366 }
2367 else {
2368 return mkdir($uri, $mode, $recursive, $context);
2369 }
2370 }
2371
2389 function drupal_rmdir($uri, $context = NULL) {
2390 $scheme = file_uri_scheme($uri);
2391 if ((!$scheme || !file_stream_wrapper_valid_scheme($scheme)) && (substr(PHP_OS, 0, 3) == 'WIN')) {
2392 chmod($uri, 0700);
2393 }
2394 if ($context) {
2395 return rmdir($uri, $context);
2396 }
2397 else {
2398 return rmdir($uri);
2399 }
2400 }
2401
2424 function drupal_tempnam($directory, $prefix) {
2425 $scheme = file_uri_scheme($directory);
2426
2427 if ($scheme && file_stream_wrapper_valid_scheme($scheme)) {
2428 $wrapper = file_stream_wrapper_get_instance_by_scheme($scheme);
2429
2430 if ($filename = tempnam($wrapper->getDirectoryPath(), $prefix)) {
2431 return $scheme . '://' . drupal_basename($filename);
2432 }
2433 else {
2434 return FALSE;
2435 }
2436 }
2437 else {
2438 // Handle as a normal tempnam() call.
2439 return tempnam($directory, $prefix);
2440 }
2441 }
2442
2446 function file_directory_temp() {
2447 $temporary_directory = variable_get('file_temporary_path', NULL);
2448
2449 if (empty($temporary_directory)) {
2450 $directories = array();
2451
2452 // Has PHP been set with an upload_tmp_dir?
2453 if (ini_get('upload_tmp_dir')) {
2454 $directories[] = ini_get('upload_tmp_dir');
2455 }
2456
2457 // Operating system specific dirs.
2458 if (substr(PHP_OS, 0, 3) == 'WIN') {
2459 $directories[] = 'c:\\windows\\temp';
2460 $directories[] = 'c:\\winnt\\temp';
2461 }
2462 else {
2463 $directories[] = '/tmp';
2464 }
2465 // PHP may be able to find an alternative tmp directory.
2466 // This function exists in PHP 5 >= 5.2.1, but Drupal
2467 // requires PHP 5 >= 5.2.0, so we check for it.
2468 if (function_exists('sys_get_temp_dir')) {
2469 $directories[] = sys_get_temp_dir();
2470 }
2471
2472 foreach ($directories as $directory) {
2473 if (is_dir($directory) && is_writable($directory)) {
2474 $temporary_directory = $directory;
2475 break;
2476 }
2477 }
2478
2479 if (empty($temporary_directory)) {
2480 // If no directory has been found default to 'files/tmp'.
2481 $temporary_directory = variable_get('file_public_path', conf_path() . '/files') . '/tmp';
2482
2483 // Windows accepts paths with either slash (/) or backslash (\), but will
2484 // not accept a path which contains both a slash and a backslash. Since
2485 // the 'file_public_path' variable may have either format, we sanitize
2486 // everything to use slash which is supported on all platforms.
2487 $temporary_directory = str_replace('\\', '/', $temporary_directory);
2488 }
2489 // Save the path of the discovered directory.
2490 variable_set('file_temporary_path', $temporary_directory);
2491 }
2492
2493 return $temporary_directory;
2494 }
2495
2505 function file_get_content_headers($file) {
2506 $name = mime_header_encode($file->filename);
2507 $type = mime_header_encode($file->filemime);
2508
2509 return array(
2510 'Content-Type' => $type,
2511 'Content-Length' => $file->filesize,
2512 'Cache-Control' => 'private',
2513 );
2514 }
2515
image_scale
image_scale(stdClass $image, $width=NULL, $height=NULL, $upscale=FALSE)
Definition: image.inc:252
form_set_error
form_set_error($name=NULL, $message= '', $limit_validation_errors=NULL)
Definition: form.inc:1581
file_upload_max_size
file_upload_max_size()
Definition: file.inc:2108
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
file_default_scheme
file_default_scheme()
Definition: file.inc:256
STREAM_WRAPPERS_ALL
const STREAM_WRAPPERS_ALL
Definition: stream_wrappers.inc:32
file_validate_image_resolution
file_validate_image_resolution(stdClass $file, $maximum_dimensions=0, $minimum_dimensions=0)
Definition: file.inc:1808
drupal_write_record
drupal_write_record($table, &$record, $primary_keys=array())
Definition: common.inc:7097
file_usage_add
file_usage_add(stdClass $file, $module, $type, $id, $count=1)
Definition: file.inc:682
FILE_CREATE_DIRECTORY
const FILE_CREATE_DIRECTORY
Definition: file.inc:41
entity_load
entity_load($entity_type, $ids=FALSE, $conditions=array(), $reset=FALSE)
Definition: common.inc:7800
FILE_MODIFY_PERMISSIONS
const FILE_MODIFY_PERMISSIONS
Definition: file.inc:46
drupal_unlink
drupal_unlink($uri, $context=NULL)
Definition: file.inc:2225
file_scan_directory
file_scan_directory($dir, $mask, $options=array(), $depth=0)
Definition: file.inc:2058
file_build_uri
file_build_uri($path)
Definition: file.inc:960
dir
print $language dir
Definition: html.tpl.php:47
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
$module
print $module
Definition: search-results.tpl.php:28
file_unmanaged_delete_recursive
file_unmanaged_delete_recursive($path)
Definition: file.inc:1358
file_create_url
file_create_url($uri)
Definition: file.inc:372
file_get_content_headers
file_get_content_headers($file)
Definition: file.inc:2505
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
file_validate_name_length
file_validate_name_length(stdClass $file)
Definition: file.inc:1687
file_copy
file_copy(stdClass $source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:786
drupal_tempnam
drupal_tempnam($directory, $prefix)
Definition: file.inc:2424
drupal_realpath
drupal_realpath($uri)
Definition: file.inc:2259
drupal_send_headers
drupal_send_headers($default_headers=array(), $only_default=FALSE)
Definition: bootstrap.inc:1199
file_stream_wrapper_get_class
file_stream_wrapper_get_class($scheme)
Definition: file.inc:182
file_valid_uri
file_valid_uri($uri)
Definition: file.inc:841
drupal_substr
drupal_substr($text, $start, $length=NULL)
Definition: unicode.inc:585
drupal_move_uploaded_file
drupal_move_uploaded_file($filename, $uri)
Definition: file.inc:1626
file_stream_wrapper_get_instance_by_scheme
file_stream_wrapper_get_instance_by_scheme($scheme)
Definition: file.inc:336
drupal_dirname
drupal_dirname($uri)
Definition: file.inc:2295
file_validate_extensions
file_validate_extensions(stdClass $file, $extensions)
Definition: file.inc:1713
print
print
Definition: php-2.php:2
FILE_STATUS_PERMANENT
const FILE_STATUS_PERMANENT
Definition: file.inc:70
file_unmanaged_move
file_unmanaged_move($source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1103
FILE_EXISTS_ERROR
const FILE_EXISTS_ERROR
Definition: file.inc:61
file_delete
file_delete(stdClass $file, $force=FALSE)
Definition: file.inc:1268
module_invoke_all
module_invoke_all($hook)
Definition: module.inc:887
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
file_download
file_download()
Definition: file.inc:1989
file_get_stream_wrappers
file_get_stream_wrappers($filter=STREAM_WRAPPERS_ALL)
Definition: file.inc:123
WATCHDOG_NOTICE
const WATCHDOG_NOTICE
Definition: bootstrap.inc:103
file_unmanaged_copy
file_unmanaged_copy($source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:884
file_stream_wrapper_valid_scheme
file_stream_wrapper_valid_scheme($scheme)
Definition: file.inc:218
image_get_info
image_get_info($filepath, $toolkit=FALSE)
Definition: image.inc:124
$info
$info
Definition: color.inc:6
FILE_EXISTS_REPLACE
const FILE_EXISTS_REPLACE
Definition: file.inc:56
file_load_multiple
file_load_multiple($fids=array(), $conditions=array())
Definition: file.inc:564
file_munge_filename
file_munge_filename($filename, $extensions, $alerts=TRUE)
Definition: file.inc:1143
drupal_mkdir
drupal_mkdir($uri, $mode=NULL, $recursive=FALSE, $context=NULL)
Definition: file.inc:2359
entity_load_unchanged
entity_load_unchanged($entity_type, $id)
Definition: common.inc:7823
drupal_rmdir
drupal_rmdir($uri, $context=NULL)
Definition: file.inc:2389
image_load
image_load($file, $toolkit=FALSE)
Definition: image.inc:383
file_space_used
file_space_used($uid=NULL, $status=FILE_STATUS_PERMANENT)
Definition: file.inc:1388
drupal_add_http_header
drupal_add_http_header($name, $value, $append=FALSE)
Definition: bootstrap.inc:1129
$value
print $value
Definition: user-profile-item.tpl.php:26
file_load
file_load($fid)
Definition: file.inc:580
file_destination
file_destination($destination, $replace)
Definition: file.inc:981
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
file_move
file_move(stdClass $source, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1035
file_directory_temp
file_directory_temp()
Definition: file.inc:2446
$depth
print $depth
Definition: book-node-export-html.tpl.php:21
file_unmanaged_delete
file_unmanaged_delete($path)
Definition: file.inc:1317
file_create_htaccess
file_create_htaccess($directory, $private=TRUE, $force_overwrite=FALSE)
Definition: file.inc:477
file_usage_delete
file_usage_delete(stdClass $file, $module, $type=NULL, $id=NULL, $count=1)
Definition: file.inc:720
parse_size
parse_size($size)
Definition: common.inc:1842
file_save_upload
file_save_upload($source, $validators=array(), $destination=FALSE, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1437
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
file_uri_target
file_uri_target($uri)
Definition: file.inc:243
module_implements
module_implements($hook, $sort=FALSE, $reset=FALSE)
Definition: module.inc:694
STREAM_WRAPPERS_WRITE_VISIBLE
const STREAM_WRAPPERS_WRITE_VISIBLE
Definition: stream_wrappers.inc:72
file_stream_wrapper_uri_normalize
file_stream_wrapper_uri_normalize($uri)
Definition: file.inc:275
drupal_access_denied
drupal_access_denied()
Definition: common.inc:744
conf_path
conf_path($require_settings=TRUE, $reset=FALSE)
Definition: bootstrap.inc:541
mime_header_encode
mime_header_encode($string)
Definition: unicode.inc:384
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
file_unmanaged_save_data
file_unmanaged_save_data($data, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1932
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
drupal_chmod
drupal_chmod($uri, $mode=NULL)
Definition: file.inc:2180
drupal_encode_path
drupal_encode_path($path)
Definition: common.inc:639
REQUEST_TIME
const REQUEST_TIME
Definition: bootstrap.inc:218
drupal_exit
drupal_exit($destination=NULL)
Definition: common.inc:2721
file_stream_wrapper_get_instance_by_uri
file_stream_wrapper_get_instance_by_uri($uri)
Definition: file.inc:303
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
file_unmunge_filename
file_unmunge_filename($filename)
Definition: file.inc:1187
file_create_filename
file_create_filename($basename, $directory)
Definition: file.inc:1206
file_validate_is_image
file_validate_is_image(stdClass $file)
Definition: file.inc:1773
$dir
print $dir
Definition: book-export-html.tpl.php:22
FILE_EXISTS_RENAME
const FILE_EXISTS_RENAME
Definition: file.inc:51
file_usage_list
file_usage_list(stdClass $file)
Definition: file.inc:642
file_prepare_directory
file_prepare_directory(&$directory, $options=FILE_MODIFY_PERMISSIONS)
Definition: file.inc:430
drupal_basename
drupal_basename($uri, $suffix=NULL)
Definition: file.inc:2317
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
file_uri_scheme
file_uri_scheme($uri)
Definition: file.inc:199
drupal_not_found
drupal_not_found()
Definition: common.inc:731
file_save_data
file_save_data($data, $destination=NULL, $replace=FILE_EXISTS_RENAME)
Definition: file.inc:1865
format_size
format_size($size, $langcode=NULL)
Definition: common.inc:1866
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
image_save
image_save(stdClass $image, $destination=NULL)
Definition: image.inc:417
file_htaccess_lines
file_htaccess_lines($private=TRUE)
Definition: file.inc:516
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
STREAM_WRAPPERS_NORMAL
const STREAM_WRAPPERS_NORMAL
Definition: stream_wrappers.inc:86
file_ensure_htaccess
file_ensure_htaccess()
Definition: file.inc:457
STREAM_WRAPPERS_LOCAL
const STREAM_WRAPPERS_LOCAL
Definition: stream_wrappers.inc:37
file_validate_size
file_validate_size(stdClass $file, $file_limit=0, $user_limit=0)
Definition: file.inc:1743
db_select
db_select($table, $alias=NULL, array $options=array())
Definition: database.inc:2516
file_save
file_save(stdClass $file)
Definition: file.inc:599
file_validate
file_validate(stdClass &$file, $validators=array())
Definition: file.inc:1664
db_merge
db_merge($table, array $options=array())
Definition: database.inc:2441
file_transfer
file_transfer($uri, $headers)
Definition: file.inc:1954
file_get_mimetype
file_get_mimetype($uri, $mapping=NULL)
Definition: file.inc:2143
DrupalLocalStreamWrapper\getMimeType
static getMimeType($uri, $mapping=NULL)
Definition: stream_wrappers.inc:311
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/simpletest_example/simpletest_example.module Source File

  • examples
  • simpletest_example
simpletest_example.module
Go to the documentation of this file.
1 <?php
2
22 function simpletest_example_node_info() {
23 return array(
24 'simpletest_example' => array(
25 'name' => t('SimpleTest Example Node Type'),
26 'base' => 'simpletest_example',
27 'description' => t('simpletest_example page node type.'),
28 )
29 );
30 }
31
38 function simpletest_example_permission() {
39 $perms = array();
40 $perms['extra special edit any simpletest_example'] = array('title' => t('Extra special edit any SimpleTest Example'), 'description' => t('Extra special edit any SimpleTest Example'));
41 return $perms;
42 }
43
52 function simpletest_example_node_access($node, $op, $account) {
53 // Don't get involved if this isn't a simpletest_example node, etc.
54 $type = is_string($node) ? $node : $node->type;
55 if ($type != 'simpletest_example' || ($op != 'update' && $op != 'delete')) {
56 return NODE_ACCESS_IGNORE;
57 }
58
59 // This code has a BUG that we'll find in testing.
60
61 // This is the incorrect version we'll use to demonstrate test failure.
62 // The correct version should have ($op == 'update' || $op == 'delete').
63 // The author had mistakenly always tested with User 1 so it always
64 // allowed access and the bug wasn't noticed!
65 if ( ($op == 'delete') && (user_access('extra special edit any simpletest_example', $account) && ($account->uid == $node->uid))) {
66 return NODE_ACCESS_ALLOW;
67 }
68
69 return NODE_ACCESS_DENY;
70 }
71
77 function simpletest_example_form($node, $form_state) {
78 $type = node_type_get_type($node);
79 $form = array();
80 if ($type->has_title) {
81 $form['title'] = array(
82 '#type' => 'textfield',
83 '#title' => check_plain($type->title_label),
84 '#required' => TRUE,
85 '#default_value' => $node->title,
86 '#maxlength' => 255,
87 '#weight' => -5,
88 );
89 }
90 return $form;
91 }
92
98 function simpletest_example_menu() {
99 $items['examples/simpletest_example'] = array(
100 'title' => 'Simpletest Example',
101 'description' => 'Explain the simpletest example and allow the error logic to be executed.',
102 'page callback' => '_simpletest_example_explanation',
103 'access callback' => TRUE,
104 );
105 return $items;
106 }
107
111 function _simpletest_example_explanation() {
112
113 $explanation = t("This Simpletest Example is designed to give an introductory tutorial to writing
114 a simpletest test. Please see the <a href='http://drupal.org/node/890654'>associated tutorial</a>.");
115 return $explanation;
116 }
117
123 function simpletest_example_empty_mysql_date($date_string) {
124 if (empty($date_string) || $date_string == '0000-00-00' || $date_string == '0000-00-00 00:00:00') {
125 return true;
126 }
127 return false;
128 }
129
$op
$op
Definition: update.php:404
NODE_ACCESS_ALLOW
const NODE_ACCESS_ALLOW
Definition: node.module:50
NODE_ACCESS_DENY
const NODE_ACCESS_DENY
Definition: node.module:55
node_type_get_type
node_type_get_type($node)
Definition: node.module:410
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
_simpletest_example_explanation
_simpletest_example_explanation()
Definition: simpletest_example.module:111
simpletest_example_empty_mysql_date
simpletest_example_empty_mysql_date($date_string)
Definition: simpletest_example.module:123
user_access
user_access($string, $account=NULL)
Definition: user.module:794
simpletest_example_form
simpletest_example_form($node, $form_state)
Definition: simpletest_example.module:77
check_plain
check_plain($text)
Definition: bootstrap.inc:1565
simpletest_example_permission
simpletest_example_permission()
Definition: simpletest_example.module:38
NODE_ACCESS_IGNORE
const NODE_ACCESS_IGNORE
Definition: node.module:60
simpletest_example_node_access
simpletest_example_node_access($node, $op, $account)
Definition: simpletest_example.module:52
simpletest_example_menu
simpletest_example_menu()
Definition: simpletest_example.module:98
simpletest_example_node_info
simpletest_example_node_info()
Definition: simpletest_example.module:22
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
ThemeUpdater Member List

This is the complete list of members for ThemeUpdater, including all inherited members.

$source | Updater |
__construct($source) | Updater |
canUpdate($project_name) | ThemeUpdater | static
canUpdateDirectory($directory) | ThemeUpdater | static
factory($source) | Updater | static
findInfoFile($directory) | Updater | static
getBackupDir() | Updater |
getInstallArgs($overrides=array()) | Updater | protected
getInstallDirectory() | ThemeUpdater |
Updater::getProjectName($directory) | Updater | static
DrupalUpdaterInterface::getProjectName($directory) | DrupalUpdaterInterface | static
getProjectTitle($directory) | Updater | static
getUpdaterFromDirectory($directory) | Updater | static
install(&$filetransfer, $overrides=array()) | Updater |
isInstalled() | ThemeUpdater |
makeBackup(&$filetransfer, $from, $to) | Updater |
makeWorldReadable(&$filetransfer, $path, $recursive=TRUE) | Updater |
postInstall() | ThemeUpdater |
postInstallTasks() | ThemeUpdater |
Updater::postUpdate() | Updater |
DrupalUpdaterInterface::postUpdate() | DrupalUpdaterInterface |
postUpdateTasks() | Updater |
prepareInstallDirectory(&$filetransfer, $directory) | Updater |
update(&$filetransfer, $overrides=array()) | Updater |
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: Member List

  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
TestingMailSystem Member List

This is the complete list of members for TestingMailSystem, including all inherited members.

format(array $message) | DefaultMailSystem
mail(array $message) | TestingMailSystem
Generated on Mon Feb 3 2014 12:40:52 for Drupal 7 by doxygen 1.8.5


Drupal 7: examples/ajax_example/ajax_example.module Source File

  • examples
  • ajax_example
ajax_example.module
Go to the documentation of this file.
1 <?php
2
21 // The Node Form Alter example needs to be in another file.
22 module_load_include('inc', 'ajax_example', 'ajax_example_node_form_alter');
23
32 function ajax_example_menu() {
33 $items = array();
34
35 $items['examples/ajax_example'] = array(
36 'title' => 'AJAX Example',
37 'page callback' => 'ajax_example_intro',
38 'access callback' => TRUE,
39 'expanded' => TRUE,
40 );
41
42 // Change the description of a form element.
43 $items['examples/ajax_example/simplest'] = array(
44 'title' => 'Simplest AJAX Example',
45 'page callback' => 'drupal_get_form',
46 'page arguments' => array('ajax_example_simplest'),
47 'access callback' => TRUE,
48 'weight' => 0,
49 );
50 // Generate a changing number of checkboxes.
51 $items['examples/ajax_example/autocheckboxes'] = array(
52 'title' => 'Generate checkboxes',
53 'page callback' => 'drupal_get_form',
54 'page arguments' => array('ajax_example_autocheckboxes'),
55 'access callback' => TRUE,
56 'weight' => 1,
57 );
58 // Generate different textfields based on form state.
59 $items['examples/ajax_example/autotextfields'] = array(
60 'title' => 'Generate textfields',
61 'page callback' => 'drupal_get_form',
62 'page arguments' => array('ajax_example_autotextfields'),
63 'access callback' => TRUE,
64 'weight' => 2,
65 );
66
67 // Submit a form without a page reload.
68 $items['examples/ajax_example/submit_driven_ajax'] = array(
69 'title' => 'Submit-driven AJAX',
70 'page callback' => 'drupal_get_form',
71 'page arguments' => array('ajax_example_submit_driven_ajax'),
72 'access callback' => TRUE,
73 'weight' => 3,
74 );
75
76 // Repopulate a dropdown based on form state.
77 $items['examples/ajax_example/dependent_dropdown'] = array(
78 'title' => 'Dependent dropdown',
79 'page callback' => 'drupal_get_form',
80 'page arguments' => array('ajax_example_dependent_dropdown'),
81 'access callback' => TRUE,
82 'weight' => 4,
83 );
84 // Repopulate a dropdown, but this time with graceful degredation.
85 // See ajax_example_graceful_degradation.inc.
86 $items['examples/ajax_example/dependent_dropdown_degrades'] = array(
87 'title' => 'Dependent dropdown (with graceful degradation)',
88 'page callback' => 'drupal_get_form',
89 'page arguments' => array('ajax_example_dependent_dropdown_degrades'),
90 'access callback' => TRUE,
91 'weight' => 5,
92 'file' => 'ajax_example_graceful_degradation.inc',
93 );
94 // The above example as it appears to users with no javascript.
95 $items['examples/ajax_example/dependent_dropdown_degrades_no_js'] = array(
96 'title' => 'Dependent dropdown with javascript off',
97 'page callback' => 'drupal_get_form',
98 'page arguments' => array('ajax_example_dependent_dropdown_degrades', TRUE),
99 'access callback' => TRUE,
100 'file' => 'ajax_example_graceful_degradation.inc',
101 'weight' => 5,
102 );
103
104 // Populate a form section based on input in another element.
105 $items['examples/ajax_example/dynamic_sections'] = array(
106 'title' => 'Dynamic Sections (with graceful degradation)',
107 'page callback' => 'drupal_get_form',
108 'page arguments' => array('ajax_example_dynamic_sections'),
109 'access callback' => TRUE,
110 'weight' => 6,
111 'file' => 'ajax_example_graceful_degradation.inc',
112 );
113 // The above example as it appears to users with no javascript.
114 $items['examples/ajax_example/dynamic_sections_no_js'] = array(
115 'title' => 'Dynamic Sections w/JS turned off',
116 'page callback' => 'drupal_get_form',
117 'page arguments' => array('ajax_example_dynamic_sections', TRUE),
118 'access callback' => TRUE,
119 'weight' => 6,
120 'file' => 'ajax_example_graceful_degradation.inc',
121 );
122
123 // A classic multi-step wizard, but with no page reloads.
124 // See ajax_example_graceful_degradation.inc.
125 $items['examples/ajax_example/wizard'] = array(
126 'title' => 'Wizard (with graceful degradation)',
127 'page callback' => 'drupal_get_form',
128 'page arguments' => array('ajax_example_wizard'),
129 'access callback' => TRUE,
130 'file' => 'ajax_example_graceful_degradation.inc',
131 'weight' => 7,
132 );
133 // The above example as it appears to users with no javascript.
134 $items['examples/ajax_example/wizard_no_js'] = array(
135 'title' => 'Wizard w/JS turned off',
136 'page callback' => 'drupal_get_form',
137 'page arguments' => array('ajax_example_wizard', TRUE),
138 'access callback' => TRUE,
139 'file' => 'ajax_example_graceful_degradation.inc',
140 'weight' => 7,
141 );
142
143 // Add-more button that creates additional form elements.
144 // See ajax_example_graceful_degradation.inc.
145 $items['examples/ajax_example/add_more'] = array(
146 'title' => 'Add-more button (with graceful degradation)',
147 'page callback' => 'drupal_get_form',
148 'page arguments' => array('ajax_example_add_more'),
149 'access callback' => TRUE,
150 'file' => 'ajax_example_graceful_degradation.inc',
151 'weight' => 8,
152 );
153 // The above example as it appears to users with no javascript.
154 $items['examples/ajax_example/add_more_no_js'] = array(
155 'title' => 'Add-more button w/JS turned off',
156 'page callback' => 'drupal_get_form',
157 'page arguments' => array('ajax_example_add_more', TRUE),
158 'access callback' => TRUE,
159 'file' => 'ajax_example_graceful_degradation.inc',
160 'weight' => 8,
161 );
162
163 // Use the AJAX framework outside the context of a form using the use-ajax
164 // class. See ajax_example_misc.inc.
165 $items['examples/ajax_example/ajax_link'] = array(
166 'title' => 'Ajax Link ("use-ajax" class)',
167 'page callback' => 'ajax_example_render_link',
168 'access callback' => TRUE,
169 'file' => 'ajax_example_misc.inc',
170 'weight' => 9,
171 );
172 // Use the AJAX framework outside the context of a form using a renderable
173 // array of type link with the #ajax property. See ajax_example_misc.inc.
174 $items['examples/ajax_example/ajax_link_renderable'] = array(
175 'title' => 'Ajax Link (Renderable Array)',
176 'page callback' => 'ajax_example_render_link_ra',
177 'access callback' => TRUE,
178 'file' => 'ajax_example_misc.inc',
179 'weight' => 9,
180 );
181 // A menu callback is required when using ajax outside of the Form API.
182 $items['ajax_link_callback'] = array(
183 'page callback' => 'ajax_link_response',
184 'access callback' => 'user_access',
185 'access arguments' => array('access content'),
186 'type' => MENU_CALLBACK,
187 'file' => 'ajax_example_misc.inc',
188 );
189
190 // Use AJAX framework commands outside of the #ajax form property.
191 // See ajax_example_advanced.inc.
192 $items['examples/ajax_example/advanced_commands'] = array(
193 'title' => 'AJAX framework commands',
194 'page callback' => 'drupal_get_form',
195 'page arguments' => array('ajax_example_advanced_commands'),
196 'access callback' => TRUE,
197 'file' => 'ajax_example_advanced.inc',
198 'weight' => 100,
199 );
200
201 // Autocomplete examples.
202 $items['examples/ajax_example/simple_autocomplete'] = array(
203 'title' => 'Autocomplete (simple)',
204 'page callback' => 'drupal_get_form',
205 'page arguments' => array('ajax_example_simple_autocomplete'),
206 'access arguments' => array('access user profiles'),
207 'file' => 'ajax_example_autocomplete.inc',
208 'weight' => 10,
209 );
210 $items['examples/ajax_example/simple_user_autocomplete_callback'] = array(
211 'page callback' => 'ajax_example_simple_user_autocomplete_callback',
212 'file' => 'ajax_example_autocomplete.inc',
213 'type' => MENU_CALLBACK,
214 'access arguments' => array('access user profiles'),
215 );
216 $items['examples/ajax_example/node_autocomplete'] = array(
217 'title' => 'Autocomplete (node with nid)',
218 'page callback' => 'drupal_get_form',
219 'page arguments' => array('ajax_example_unique_autocomplete'),
220 'access arguments' => array('access content'),
221 'file' => 'ajax_example_autocomplete.inc',
222 'weight' => 11,
223 );
224 $items['examples/ajax_example/unique_node_autocomplete_callback'] = array(
225 'page callback' => 'ajax_example_unique_node_autocomplete_callback',
226 'file' => 'ajax_example_autocomplete.inc',
227 'type' => MENU_CALLBACK,
228 'access arguments' => array('access content'),
229 );
230 $items['examples/ajax_example/node_by_author'] = array(
231 'title' => 'Autocomplete (node limited by author)',
232 'page callback' => 'drupal_get_form',
233 'page arguments' => array('ajax_example_node_by_author_autocomplete'),
234 'access callback' => TRUE,
235 'file' => 'ajax_example_autocomplete.inc',
236 'weight' => 12,
237 );
238 $items['examples/ajax_example/node_by_author_autocomplete'] = array(
239 'page callback' => 'ajax_example_node_by_author_node_autocomplete_callback',
240 'file' => 'ajax_example_autocomplete.inc',
241 'type' => MENU_CALLBACK,
242 'access arguments' => array('access content'),
243 );
244
245 return $items;
246 }
247
248 function ajax_example_intro() {
249 $markup = t('The AJAX example module provides many examples of AJAX including forms, links, and AJAX commands.');
250
251 $list[] = l(t('Simplest AJAX Example'), 'examples/ajax_example/simplest');
252 $list[] = l(t('Generate checkboxes'), 'examples/ajax_example/autocheckboxes');
253 $list[] = l(t('Generate textfields'), 'examples/ajax_example/autotextfields');
254 $list[] = l(t('Submit-driven AJAX'), 'examples/ajax_example/submit_driven_ajax');
255 $list[] = l(t('Dependent dropdown'), 'examples/ajax_example/dependent_dropdown');
256 $list[] = l(t('Dependent dropdown (with graceful degradation)'), 'examples/ajax_example/dependent_dropdown_degrades');
257 $list[] = l(t('Dynamic Sections w/JS turned off'), 'examples/ajax_example/dependent_dropdown_degrades_no_js');
258 $list[] = l(t('Wizard (with graceful degradation)'), 'examples/ajax_example/wizard');
259 $list[] = l(t('Wizard w/JS turned off'), 'examples/ajax_example/wizard_no_js');
260 $list[] = l(t('Add-more button (with graceful degradation)'), 'examples/ajax_example/add_more');
261 $list[] = l(t('Add-more button w/JS turned off'), 'examples/ajax_example/add_more_no_js');
262 $list[] = l(t('Ajax Link ("use-ajax" class)'), 'examples/ajax_example/ajax_link');
263 $list[] = l(t('Ajax Link (Renderable Array)'), 'examples/ajax_example/ajax_link_renderable');
264 $list[] = l(t('AJAX framework commands'), 'examples/ajax_example/advanced_commands');
265 $list[] = l(t('Autocomplete (simple)'), 'examples/ajax_example/simple_autocomplete');
266 $list[] = l(t('Autocomplete (node with nid)'), 'examples/ajax_example/node_autocomplete');
267 $list[] = l(t('Autocomplete (node limited by author)'), 'examples/ajax_example/node_by_author');
268
269 $variables['items'] = $list;
270 $variables['type'] = 'ul';
271 $markup .= theme('item_list', $variables);
272
273 return $markup;
274 }
275
281 function ajax_example_simplest($form, &$form_state) {
282 $form = array();
283 $form['changethis'] = array(
284 '#title' => t("Choose something and explain why"),
285 '#type' => 'select',
286 '#options' => array(
287 'one' => 'one',
288 'two' => 'two',
289 'three' => 'three',
290 ),
291 '#ajax' => array(
292 // #ajax has two required keys: callback and wrapper.
293 // 'callback' is a function that will be called when this element changes.
294 'callback' => 'ajax_example_simplest_callback',
295 // 'wrapper' is the HTML id of the page element that will be replaced.
296 'wrapper' => 'replace_textfield_div',
297 // There are also several optional keys - see ajax_example_autocheckboxes
298 // below for details on 'method', 'effect' and 'speed' and
299 // ajax_example_dependent_dropdown for 'event'.
300 ),
301 );
302
303 // This entire form element will be replaced whenever 'changethis' is updated.
304 $form['replace_textfield'] = array(
305 '#type' => 'textfield',
306 '#title' => t("Why"),
307 // The prefix/suffix provide the div that we're replacing, named by
308 // #ajax['wrapper'] above.
309 '#prefix' => '<div id="replace_textfield_div">',
310 '#suffix' => '</div>',
311 );
312
313 // An AJAX request calls the form builder function for every change.
314 // We can change how we build the form based on $form_state.
315 if (!empty($form_state['values']['changethis'])) {
316 $form['replace_textfield']['#description'] = t("Say why you chose '@value'", array('@value' => $form_state['values']['changethis']));
317 }
318 return $form;
319 }
320
330 function ajax_example_simplest_callback($form, $form_state) {
331 // The form has already been submitted and updated. We can return the replaced
332 // item as it is.
333 return $form['replace_textfield'];
334 }
335
340 function ajax_example_autocheckboxes($form, &$form_state) {
341 // Since the form builder is called after every AJAX request, we rebuild
342 // the form based on $form_state.
343 $num_checkboxes = !empty($form_state['values']['howmany_select']) ? $form_state['values']['howmany_select'] : 1;
344
345 $form['howmany_select'] = array(
346 '#title' => t('How many checkboxes do you want?'),
347 '#type' => 'select',
348 '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4),
349 '#default_value' => $num_checkboxes,
350 '#ajax' => array(
351 'callback' => 'ajax_example_autocheckboxes_callback',
352 'wrapper' => 'checkboxes-div',
353 //'method' defaults to replaceWith, but valid values also include
354 // append, prepend, before and after.
355 // 'method' => 'replaceWith',
356 // 'effect' defaults to none. Other valid values are 'fade' and 'slide'.
357 // See ajax_example_autotextfields for an example of 'fade'.
358 'effect' => 'slide',
359 // 'speed' defaults to 'slow'. You can also use 'fast'
360 // or a number of milliseconds for the animation to last.
361 // 'speed' => 'slow',
362 // Don't show any throbber...
363 'progress' => array('type' => 'none'),
364 ),
365 );
366
367
368 $form['checkboxes_fieldset'] = array(
369 '#title' => t("Generated Checkboxes"),
370 // The prefix/suffix provide the div that we're replacing, named by
371 // #ajax['wrapper'] above.
372 '#prefix' => '<div id="checkboxes-div">',
373 '#suffix' => '</div>',
374 '#type' => 'fieldset',
375 '#description' => t('This is where we get automatically generated checkboxes'),
376 );
377
378 for ($i = 1; $i <= $num_checkboxes; $i++) {
379 $form['checkboxes_fieldset']["checkbox$i"] = array(
380 '#type' => 'checkbox',
381 '#title' => "Checkbox $i",
382 );
383 }
384
385 $form['submit'] = array(
386 '#type' => 'submit',
387 '#value' => t('Submit'),
388 );
389
390 return $form;
391 }
392
402 function ajax_example_autocheckboxes_callback($form, $form_state) {
403 return $form['checkboxes_fieldset'];
404 }
405
406
410 function ajax_example_autotextfields($form, &$form_state) {
411
412 $form['ask_first_name'] = array(
413 '#type' => 'checkbox',
414 '#title' => t('Ask me my first name'),
415 '#ajax' => array(
416 'callback' => 'ajax_example_autotextfields_callback',
417 'wrapper' => 'textfields',
418 'effect' => 'fade',
419 )
420 );
421 $form['ask_last_name'] = array(
422 '#type' => 'checkbox',
423 '#title' => t('Ask me my last name'),
424 '#ajax' => array(
425 'callback' => 'ajax_example_autotextfields_callback',
426 'wrapper' => 'textfields',
427 'effect' => 'fade',
428 ),
429 );
430
431 $form['textfields'] = array(
432 '#title' => t("Generated text fields for first and last name"),
433 '#prefix' => '<div id="textfields">',
434 '#suffix' => '</div>',
435 '#type' => 'fieldset',
436 '#description' => t('This is where we put automatically generated textfields'),
437 );
438
439 // Since checkboxes return TRUE or FALSE, we have to check that
440 // $form_state has been filled as well as what it contains.
441 if (!empty($form_state['values']['ask_first_name']) && $form_state['values']['ask_first_name']) {
442 $form['textfields']['first_name'] = array(
443 '#type' => 'textfield',
444 '#title' => t('First Name'),
445 );
446 }
447 if (!empty($form_state['values']['ask_last_name']) && $form_state['values']['ask_last_name']) {
448 $form['textfields']['last_name'] = array(
449 '#type' => 'textfield',
450 '#title' => t('Last Name'),
451 );
452 }
453
454 $form['submit'] = array(
455 '#type' => 'submit',
456 '#value' => t('Click Me'),
457 );
458
459 return $form;
460 }
461
468 function ajax_example_autotextfields_callback($form, $form_state) {
469 return $form['textfields'];
470 }
471
472
478 function ajax_example_submit_driven_ajax($form, &$form_state) {
479 $form['box'] = array(
480 '#type' => 'markup',
481 '#prefix' => '<div id="box">',
482 '#suffix' => '</div>',
483 '#markup' => '<h1>Initial markup for box</h1>',
484 );
485
486 $form['submit'] = array(
487 '#type' => 'submit',
488 '#ajax' => array(
489 'callback' => 'ajax_example_submit_driven_callback',
490 'wrapper' => 'box',
491 ),
492 '#value' => t('Submit'),
493 );
494
495 return $form;
496 }
497
504 function ajax_example_submit_driven_callback($form, $form_state) {
505 // In most cases, it is recomended that you put this logic in form generation
506 // rather than the callback. Submit driven forms are an exception, because
507 // you may not want to return the form at all.
508 $element = $form['box'];
509 $element['#markup'] = "Clicked submit ({$form_state['values']['op']}): " . date('c');
510 return $element;
511 }
512
513
521 function ajax_example_dependent_dropdown($form, &$form_state) {
522 // Get the list of options to populate the first dropdown.
523 $options_first = _ajax_example_get_first_dropdown_options();
524 // If we have a value for the first dropdown from $form_state['values'] we use
525 // this both as the default value for the first dropdown and also as a
526 // parameter to pass to the function that retrieves the options for the
527 // second dropdown.
528 $selected = isset($form_state['values']['dropdown_first']) ? $form_state['values']['dropdown_first'] : key($options_first);
529
530 $form['dropdown_first'] = array(
531 '#type' => 'select',
532 '#title' => 'Instrument Type',
533 '#options' => $options_first,
534 '#default_value' => $selected,
535 // Bind an ajax callback to the change event (which is the default for the
536 // select form type) of the first dropdown. It will replace the second
537 // dropdown when rebuilt
538 '#ajax' => array(
539 // When 'event' occurs, Drupal will perform an ajax request in the
540 // background. Usually the default value is sufficient (eg. change for
541 // select elements), but valid values include any jQuery event,
542 // most notably 'mousedown', 'blur', and 'submit'.
543 // 'event' => 'change',
544 'callback' => 'ajax_example_dependent_dropdown_callback',
545 'wrapper' => 'dropdown-second-replace',
546 ),
547 );
548
549 $form['dropdown_second'] = array(
550 '#type' => 'select',
551 '#title' => $options_first[$selected] . ' ' . t('Instruments'),
552 // The entire enclosing div created here gets replaced when dropdown_first
553 // is changed.
554 '#prefix' => '<div id="dropdown-second-replace">',
555 '#suffix' => '</div>',
556 // when the form is rebuilt during ajax processing, the $selected variable
557 // will now have the new value and so the options will change
558 '#options' => _ajax_example_get_second_dropdown_options($selected),
559 '#default_value' => isset($form_state['values']['dropdown_second']) ? $form_state['values']['dropdown_second'] : '',
560 );
561 $form['submit'] = array(
562 '#type' => 'submit',
563 '#value' => t('Submit'),
564 );
565 return $form;
566 }
567
576 function ajax_example_dependent_dropdown_callback($form, $form_state) {
577 return $form['dropdown_second'];
578 }
579
586 function _ajax_example_get_first_dropdown_options() {
587 // drupal_map_assoc() just makes an array('String' => 'String'...).
588 return drupal_map_assoc(array(t('String'), t('Woodwind'), t('Brass'), t('Percussion')));
589 }
590
600 function _ajax_example_get_second_dropdown_options($key = '') {
601 $options = array(
602 t('String') => drupal_map_assoc(array(t('Violin'), t('Viola'), t('Cello'), t('Double Bass'))),
603 t('Woodwind') => drupal_map_assoc(array(t('Flute'), t('Clarinet'), t('Oboe'), t('Bassoon'))),
604 t('Brass') => drupal_map_assoc(array(t('Trumpet'), t('Trombone'), t('French Horn'), t('Euphonium'))),
605 t('Percussion') => drupal_map_assoc(array(t('Bass Drum'), t('Timpani'), t('Snare Drum'), t('Tambourine'))),
606 );
607 if (isset($options[$key])) {
608 return $options[$key];
609 }
610 else {
611 return array();
612 }
613 }
l
l($text, $path, array $options=array())
Definition: common.inc:2432
_ajax_example_get_second_dropdown_options
_ajax_example_get_second_dropdown_options($key= '')
Definition: ajax_example.module:600
ajax_example_intro
ajax_example_intro()
Definition: ajax_example.module:248
ajax_example_autotextfields_callback
ajax_example_autotextfields_callback($form, $form_state)
Definition: ajax_example.module:468
ajax_example_submit_driven_ajax
ajax_example_submit_driven_ajax($form, &$form_state)
Definition: ajax_example.module:478
MENU_CALLBACK
const MENU_CALLBACK
Definition: menu.inc:151
ajax_example_simplest_callback
ajax_example_simplest_callback($form, $form_state)
Definition: ajax_example.module:330
ajax_example_simplest
ajax_example_simplest($form, &$form_state)
Definition: ajax_example.module:281
ajax_example_autocheckboxes
ajax_example_autocheckboxes($form, &$form_state)
Definition: ajax_example.module:340
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
ajax_example_autocheckboxes_callback
ajax_example_autocheckboxes_callback($form, $form_state)
Definition: ajax_example.module:402
ajax_example_autotextfields
ajax_example_autotextfields($form, &$form_state)
Definition: ajax_example.module:410
ajax_example_dependent_dropdown
ajax_example_dependent_dropdown($form, &$form_state)
Definition: ajax_example.module:521
_ajax_example_get_first_dropdown_options
_ajax_example_get_first_dropdown_options()
Definition: ajax_example.module:586
ajax_example_dependent_dropdown_callback
ajax_example_dependent_dropdown_callback($form, $form_state)
Definition: ajax_example.module:576
ajax_example_menu
ajax_example_menu()
Definition: ajax_example.module:32
module_load_include
module_load_include($type, $module, $name=NULL)
Definition: module.inc:322
drupal_map_assoc
drupal_map_assoc($array, $function=NULL)
Definition: common.inc:2748
ajax_example_submit_driven_callback
ajax_example_submit_driven_callback($form, $form_state)
Definition: ajax_example.module:504
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
Generated on Mon Feb 3 2014 12:40:41 for Drupal 7 by doxygen 1.8.5


Drupal 7: includes/mail.inc Source File

  • includes
mail.inc
Go to the documentation of this file.
1 <?php
2
13 define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER_SOFTWARE'], 'Win32') !== FALSE ? "\r\n" : "\n");
14
122 function drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE) {
123 $default_from = variable_get('site_mail', ini_get('sendmail_from'));
124
125 // Bundle up the variables into a structured array for altering.
126 $message = array(
127 'id' => $module . '_' . $key,
128 'module' => $module,
129 'key' => $key,
130 'to' => $to,
131 'from' => isset($from) ? $from : $default_from,
132 'language' => $language,
133 'params' => $params,
134 'send' => TRUE,
135 'subject' => '',
136 'body' => array()
137 );
138
139 // Build the default headers
140 $headers = array(
141 'MIME-Version' => '1.0',
142 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
143 'Content-Transfer-Encoding' => '8Bit',
144 'X-Mailer' => 'Drupal'
145 );
146 if ($default_from) {
147 // To prevent e-mail from looking like spam, the addresses in the Sender and
148 // Return-Path headers should have a domain authorized to use the originating
149 // SMTP server.
150 $headers['From'] = $headers['Sender'] = $headers['Return-Path'] = $default_from;
151 }
152 if ($from) {
153 $headers['From'] = $from;
154 }
155 $message['headers'] = $headers;
156
157 // Build the e-mail (get subject and body, allow additional headers) by
158 // invoking hook_mail() on this module. We cannot use module_invoke() as
159 // we need to have $message by reference in hook_mail().
160 if (function_exists($function = $module . '_mail')) {
161 $function($key, $message, $params);
162 }
163
164 // Invoke hook_mail_alter() to allow all modules to alter the resulting e-mail.
165 drupal_alter('mail', $message);
166
167 // Retrieve the responsible implementation for this message.
168 $system = drupal_mail_system($module, $key);
169
170 // Format the message body.
171 $message = $system->format($message);
172
173 // Optionally send e-mail.
174 if ($send) {
175 // The original caller requested sending. Sending was canceled by one or
176 // more hook_mail_alter() implementations. We set 'result' to NULL, because
177 // FALSE indicates an error in sending.
178 if (empty($message['send'])) {
179 $message['result'] = NULL;
180 }
181 // Sending was originally requested and was not canceled.
182 else {
183 $message['result'] = $system->mail($message);
184 // Log errors.
185 if (!$message['result']) {
186 watchdog('mail', 'Error sending e-mail (from %from to %to).', array('%from' => $message['from'], '%to' => $message['to']), WATCHDOG_ERROR);
187 drupal_set_message(t('Unable to send e-mail. Contact the site administrator if the problem persists.'), 'error');
188 }
189 }
190 }
191
192 return $message;
193 }
194
258 function drupal_mail_system($module, $key) {
259 $instances = &drupal_static(__FUNCTION__, array());
260
261 $id = $module . '_' . $key;
262
263 $configuration = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
264
265 // Look for overrides for the default class, starting from the most specific
266 // id, and falling back to the module name.
267 if (isset($configuration[$id])) {
268 $class = $configuration[$id];
269 }
270 elseif (isset($configuration[$module])) {
271 $class = $configuration[$module];
272 }
273 else {
274 $class = $configuration['default-system'];
275 }
276
277 if (empty($instances[$class])) {
278 $interfaces = class_implements($class);
279 if (isset($interfaces['MailSystemInterface'])) {
280 $instances[$class] = new $class();
281 }
282 else {
283 throw new Exception(t('Class %class does not implement interface %interface', array('%class' => $class, '%interface' => 'MailSystemInterface')));
284 }
285 }
286 return $instances[$class];
287 }
288
292 interface MailSystemInterface {
302 public function format(array $message);
303
331 public function mail(array $message);
332 }
333
351 function drupal_wrap_mail($text, $indent = '') {
352 // Convert CRLF into LF.
353 $text = str_replace("\r", '', $text);
354 // See if soft-wrapping is allowed.
355 $clean_indent = _drupal_html_to_text_clean($indent);
356 $soft = strpos($clean_indent, ' ') === FALSE;
357 // Check if the string has line breaks.
358 if (strpos($text, "\n") !== FALSE) {
359 // Remove trailing spaces to make existing breaks hard, but leave signature
360 // marker untouched (RFC 3676, Section 4.3).
361 $text = preg_replace('/(?(?<!^--) +\n| +\n)/m', "\n", $text);
362 // Wrap each line at the needed width.
363 $lines = explode("\n", $text);
364 array_walk($lines, '_drupal_wrap_mail_line', array('soft' => $soft, 'length' => strlen($indent)));
365 $text = implode("\n", $lines);
366 }
367 else {
368 // Wrap this line.
369 _drupal_wrap_mail_line($text, 0, array('soft' => $soft, 'length' => strlen($indent)));
370 }
371 // Empty lines with nothing but spaces.
372 $text = preg_replace('/^ +\n/m', "\n", $text);
373 // Space-stuff special lines.
374 $text = preg_replace('/^(>| |From)/m', ' $1', $text);
375 // Apply indentation. We only include non-'>' indentation on the first line.
376 $text = $indent . substr(preg_replace('/^/m', $clean_indent, $text), strlen($indent));
377
378 return $text;
379 }
380
402 function drupal_html_to_text($string, $allowed_tags = NULL) {
403 // Cache list of supported tags.
404 static $supported_tags;
405 if (empty($supported_tags)) {
406 $supported_tags = array('a', 'em', 'i', 'strong', 'b', 'br', 'p', 'blockquote', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr');
407 }
408
409 // Make sure only supported tags are kept.
410 $allowed_tags = isset($allowed_tags) ? array_intersect($supported_tags, $allowed_tags) : $supported_tags;
411
412 // Make sure tags, entities and attributes are well-formed and properly nested.
413 $string = _filter_htmlcorrector(filter_xss($string, $allowed_tags));
414
415 // Apply inline styles.
416 $string = preg_replace('!</?(em|i)((?> +)[^>]*)?>!i', '/', $string);
417 $string = preg_replace('!</?(strong|b)((?> +)[^>]*)?>!i', '*', $string);
418
419 // Replace inline <a> tags with the text of link and a footnote.
420 // 'See <a href="http://drupal.org">the Drupal site</a>' becomes
421 // 'See the Drupal site [1]' with the URL included as a footnote.
422 _drupal_html_to_mail_urls(NULL, TRUE);
423 $pattern = '@(<a[^>]+?href="([^"]*)"[^>]*?>(.+?)</a>)@i';
424 $string = preg_replace_callback($pattern, '_drupal_html_to_mail_urls', $string);
425 $urls = _drupal_html_to_mail_urls();
426 $footnotes = '';
427 if (count($urls)) {
428 $footnotes .= "\n";
429 for ($i = 0, $max = count($urls); $i < $max; $i++) {
430 $footnotes .= '[' . ($i + 1) . '] ' . $urls[$i] . "\n";
431 }
432 }
433
434 // Split tags from text.
435 $split = preg_split('/<([^>]+?)>/', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
436 // Note: PHP ensures the array consists of alternating delimiters and literals
437 // and begins and ends with a literal (inserting $null as required).
438
439 $tag = FALSE; // Odd/even counter (tag or no tag)
440 $casing = NULL; // Case conversion function
441 $output = '';
442 $indent = array(); // All current indentation string chunks
443 $lists = array(); // Array of counters for opened lists
444 foreach ($split as $value) {
445 $chunk = NULL; // Holds a string ready to be formatted and output.
446
447 // Process HTML tags (but don't output any literally).
448 if ($tag) {
449 list($tagname) = explode(' ', strtolower($value), 2);
450 switch ($tagname) {
451 // List counters
452 case 'ul':
453 array_unshift($lists, '*');
454 break;
455 case 'ol':
456 array_unshift($lists, 1);
457 break;
458 case '/ul':
459 case '/ol':
460 array_shift($lists);
461 $chunk = ''; // Ensure blank new-line.
462 break;
463
464 // Quotation/list markers, non-fancy headers
465 case 'blockquote':
466 // Format=flowed indentation cannot be mixed with lists.
467 $indent[] = count($lists) ? ' "' : '>';
468 break;
469 case 'li':
470 $indent[] = isset($lists[0]) && is_numeric($lists[0]) ? ' ' . $lists[0]++ . ') ' : ' * ';
471 break;
472 case 'dd':
473 $indent[] = ' ';
474 break;
475 case 'h3':
476 $indent[] = '.... ';
477 break;
478 case 'h4':
479 $indent[] = '.. ';
480 break;
481 case '/blockquote':
482 if (count($lists)) {
483 // Append closing quote for inline quotes (immediately).
484 $output = rtrim($output, "> \n") . "\"\n";
485 $chunk = ''; // Ensure blank new-line.
486 }
487 // Fall-through
488 case '/li':
489 case '/dd':
490 array_pop($indent);
491 break;
492 case '/h3':
493 case '/h4':
494 array_pop($indent);
495 case '/h5':
496 case '/h6':
497 $chunk = ''; // Ensure blank new-line.
498 break;
499
500 // Fancy headers
501 case 'h1':
502 $indent[] = '======== ';
503 $casing = 'drupal_strtoupper';
504 break;
505 case 'h2':
506 $indent[] = '-------- ';
507 $casing = 'drupal_strtoupper';
508 break;
509 case '/h1':
510 case '/h2':
511 $casing = NULL;
512 // Pad the line with dashes.
513 $output = _drupal_html_to_text_pad($output, ($tagname == '/h1') ? '=' : '-', ' ');
514 array_pop($indent);
515 $chunk = ''; // Ensure blank new-line.
516 break;
517
518 // Horizontal rulers
519 case 'hr':
520 // Insert immediately.
521 $output .= drupal_wrap_mail('', implode('', $indent)) . "\n";
522 $output = _drupal_html_to_text_pad($output, '-');
523 break;
524
525 // Paragraphs and definition lists
526 case '/p':
527 case '/dl':
528 $chunk = ''; // Ensure blank new-line.
529 break;
530 }
531 }
532 // Process blocks of text.
533 else {
534 // Convert inline HTML text to plain text; not removing line-breaks or
535 // white-space, since that breaks newlines when sanitizing plain-text.
536 $value = trim(decode_entities($value));
537 if (drupal_strlen($value)) {
538 $chunk = $value;
539 }
540 }
541
542 // See if there is something waiting to be output.
543 if (isset($chunk)) {
544 // Apply any necessary case conversion.
545 if (isset($casing)) {
546 $chunk = $casing($chunk);
547 }
548 // Format it and apply the current indentation.
549 $output .= drupal_wrap_mail($chunk, implode('', $indent)) . MAIL_LINE_ENDINGS;
550 // Remove non-quotation markers from indentation.
551 $indent = array_map('_drupal_html_to_text_clean', $indent);
552 }
553
554 $tag = !$tag;
555 }
556
557 return $output . $footnotes;
558 }
559
565 function _drupal_wrap_mail_line(&$line, $key, $values) {
566 // Use soft-breaks only for purely quoted or unindented text.
567 $line = wordwrap($line, 77 - $values['length'], $values['soft'] ? " \n" : "\n");
568 // Break really long words at the maximum width allowed.
569 $line = wordwrap($line, 996 - $values['length'], $values['soft'] ? " \n" : "\n");
570 }
571
577 function _drupal_html_to_mail_urls($match = NULL, $reset = FALSE) {
578 global $base_url, $base_path;
579 static $urls = array(), $regexp;
580
581 if ($reset) {
582 // Reset internal URL list.
583 $urls = array();
584 }
585 else {
586 if (empty($regexp)) {
587 $regexp = '@^' . preg_quote($base_path, '@') . '@';
588 }
589 if ($match) {
590 list(, , $url, $label) = $match;
591 // Ensure all URLs are absolute.
592 $urls[] = strpos($url, '://') ? $url : preg_replace($regexp, $base_url . '/', $url);
593 return $label . ' [' . count($urls) . ']';
594 }
595 }
596 return $urls;
597 }
598
604 function _drupal_html_to_text_clean($indent) {
605 return preg_replace('/[^>]/', ' ', $indent);
606 }
607
613 function _drupal_html_to_text_pad($text, $pad, $prefix = '') {
614 // Remove last line break.
615 $text = substr($text, 0, -1);
616 // Calculate needed padding space and add it.
617 if (($p = strrpos($text, "\n")) === FALSE) {
618 $p = -1;
619 }
620 $n = max(0, 79 - (strlen($text) - $p) - strlen($prefix));
621 // Add prefix and padding, and restore linebreak.
622 return $text . $prefix . str_repeat($pad, $n) . "\n";
623 }
_drupal_html_to_text_clean
_drupal_html_to_text_clean($indent)
Definition: mail.inc:604
drupal_alter
drupal_alter($type, &$data, &$context1=NULL, &$context2=NULL, &$context3=NULL)
Definition: module.inc:988
decode_entities
decode_entities($text)
Definition: unicode.inc:457
drupal_strlen
drupal_strlen($text)
Definition: unicode.inc:474
MailSystemInterface\format
format(array $message)
$module
print $module
Definition: search-results.tpl.php:28
drupal_mail
drupal_mail($module, $key, $to, $language, $params=array(), $from=NULL, $send=TRUE)
Definition: mail.inc:122
Exception
drupal_mail_system
drupal_mail_system($module, $key)
Definition: mail.inc:258
MailSystemInterface
Definition: mail.inc:292
MAIL_LINE_ENDINGS
const MAIL_LINE_ENDINGS
Definition: mail.inc:13
_drupal_html_to_text_pad
_drupal_html_to_text_pad($text, $pad, $prefix= '')
Definition: mail.inc:613
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
MailSystemInterface\mail
mail(array $message)
$url
print $url
Definition: search-result.tpl.php:70
drupal_html_to_text
drupal_html_to_text($string, $allowed_tags=NULL)
Definition: mail.inc:402
filter_xss
filter_xss($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
Definition: common.inc:1431
$value
print $value
Definition: user-profile-item.tpl.php:26
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
$output
$output
Definition: authorize.php:93
_drupal_wrap_mail_line
_drupal_wrap_mail_line(&$line, $key, $values)
Definition: mail.inc:565
WATCHDOG_ERROR
const WATCHDOG_ERROR
Definition: bootstrap.inc:93
drupal_static
& drupal_static($name, $default_value=NULL, $reset=FALSE)
Definition: bootstrap.inc:3335
watchdog
watchdog($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
Definition: bootstrap.inc:1704
$base_url
print $base_url
Definition: book-export-html.tpl.php:26
drupal_wrap_mail
drupal_wrap_mail($text, $indent= '')
Definition: mail.inc:351
_filter_htmlcorrector
_filter_htmlcorrector($text)
Definition: filter.module:1675
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
_drupal_html_to_mail_urls
_drupal_html_to_mail_urls($match=NULL, $reset=FALSE)
Definition: mail.inc:577
Generated on Mon Feb 3 2014 12:40:42 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/system.queue.inc Source File

  • modules
  • system
system.queue.inc
Go to the documentation of this file.
1 <?php
2
60 class DrupalQueue {
81 public static function get($name, $reliable = FALSE) {
82 static $queues;
83 if (!isset($queues[$name])) {
84 $class = variable_get('queue_class_' . $name, NULL);
85 if (!$class) {
86 $class = variable_get('queue_default_class', 'SystemQueue');
87 }
88 $object = new $class($name);
89 if ($reliable && !$object instanceof DrupalReliableQueueInterface) {
90 $class = variable_get('queue_default_reliable_class', 'SystemQueue');
91 $object = new $class($name);
92 }
93 $queues[$name] = $object;
94 }
95 return $queues[$name];
96 }
97 }
98
99 interface DrupalQueueInterface {
100
112 public function createItem($data);
113
128 public function numberOfItems();
129
148 public function claimItem($lease_time = 3600);
149
156 public function deleteItem($item);
157
165 public function releaseItem($item);
166
178 public function createQueue();
179
183 public function deleteQueue();
184 }
185
192 interface DrupalReliableQueueInterface extends DrupalQueueInterface {
193 }
194
198 class SystemQueue implements DrupalReliableQueueInterface {
204 protected $name;
205
206 public function __construct($name) {
207 $this->name = $name;
208 }
209
210 public function createItem($data) {
211 // During a Drupal 6.x to 7.x update, drupal_get_schema() does not contain
212 // the queue table yet, so we cannot rely on drupal_write_record().
213 $query = db_insert('queue')
214 ->fields(array(
215 'name' => $this->name,
216 'data' => serialize($data),
217 // We cannot rely on REQUEST_TIME because many items might be created
218 // by a single request which takes longer than 1 second.
219 'created' => time(),
220 ));
221 return (bool) $query->execute();
222 }
223
224 public function numberOfItems() {
225 return db_query('SELECT COUNT(item_id) FROM {queue} WHERE name = :name', array(':name' => $this->name))->fetchField();
226 }
227
228 public function claimItem($lease_time = 30) {
229 // Claim an item by updating its expire fields. If claim is not successful
230 // another thread may have claimed the item in the meantime. Therefore loop
231 // until an item is successfully claimed or we are reasonably sure there
232 // are no unclaimed items left.
233 while (TRUE) {
234 $item = db_query_range('SELECT data, item_id FROM {queue} q WHERE expire = 0 AND name = :name ORDER BY created ASC', 0, 1, array(':name' => $this->name))->fetchObject();
235 if ($item) {
236 // Try to update the item. Only one thread can succeed in UPDATEing the
237 // same row. We cannot rely on REQUEST_TIME because items might be
238 // claimed by a single consumer which runs longer than 1 second. If we
239 // continue to use REQUEST_TIME instead of the current time(), we steal
240 // time from the lease, and will tend to reset items before the lease
241 // should really expire.
242 $update = db_update('queue')
243 ->fields(array(
244 'expire' => time() + $lease_time,
245 ))
246 ->condition('item_id', $item->item_id)
247 ->condition('expire', 0);
248 // If there are affected rows, this update succeeded.
249 if ($update->execute()) {
250 $item->data = unserialize($item->data);
251 return $item;
252 }
253 }
254 else {
255 // No items currently available to claim.
256 return FALSE;
257 }
258 }
259 }
260
261 public function releaseItem($item) {
262 $update = db_update('queue')
263 ->fields(array(
264 'expire' => 0,
265 ))
266 ->condition('item_id', $item->item_id);
267 return $update->execute();
268 }
269
270 public function deleteItem($item) {
271 db_delete('queue')
272 ->condition('item_id', $item->item_id)
273 ->execute();
274 }
275
276 public function createQueue() {
277 // All tasks are stored in a single database table (which is created when
278 // Drupal is first installed) so there is nothing we need to do to create
279 // a new queue.
280 }
281
282 public function deleteQueue() {
283 db_delete('queue')
284 ->condition('name', $this->name)
285 ->execute();
286 }
287 }
288
296 class MemoryQueue implements DrupalQueueInterface {
302 protected $queue;
303
309 protected $id_sequence;
310
317 public function __construct($name) {
318 $this->queue = array();
319 $this->id_sequence = 0;
320 }
321
322 public function createItem($data) {
323 $item = new stdClass();
324 $item->item_id = $this->id_sequence++;
325 $item->data = $data;
326 $item->created = time();
327 $item->expire = 0;
328 $this->queue[$item->item_id] = $item;
329 }
330
331 public function numberOfItems() {
332 return count($this->queue);
333 }
334
335 public function claimItem($lease_time = 30) {
336 foreach ($this->queue as $key => $item) {
337 if ($item->expire == 0) {
338 $item->expire = time() + $lease_time;
339 $this->queue[$key] = $item;
340 return $item;
341 }
342 }
343 return FALSE;
344 }
345
346 public function deleteItem($item) {
347 unset($this->queue[$item->item_id]);
348 }
349
350 public function releaseItem($item) {
351 if (isset($this->queue[$item->item_id]) && $this->queue[$item->item_id]->expire != 0) {
352 $this->queue[$item->item_id]->expire = 0;
353 return TRUE;
354 }
355 return FALSE;
356 }
357
358 public function createQueue() {
359 // Nothing needed here.
360 }
361
362 public function deleteQueue() {
363 $this->queue = array();
364 $this->id_sequence = 0;
365 }
366 }
367
SystemQueue\__construct
__construct($name)
Definition: system.queue.inc:206
DrupalQueueInterface\claimItem
claimItem($lease_time=3600)
MemoryQueue
Definition: system.queue.inc:296
DrupalQueueInterface\deleteQueue
deleteQueue()
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
$name
print $name
Definition: profile-listing.tpl.php:43
name
print $forum name
Definition: forum-list.tpl.php:57
DrupalQueueInterface\releaseItem
releaseItem($item)
DrupalReliableQueueInterface
Definition: system.queue.inc:192
DrupalQueue
Definition: system.queue.inc:60
SystemQueue\$name
$name
Definition: system.queue.inc:204
SystemQueue
Definition: system.queue.inc:198
DrupalQueueInterface
Definition: system.queue.inc:99
MemoryQueue\$id_sequence
$id_sequence
Definition: system.queue.inc:309
DrupalQueueInterface\createItem
createItem($data)
DrupalQueueInterface\deleteItem
deleteItem($item)
MemoryQueue\$queue
$queue
Definition: system.queue.inc:302
DrupalQueueInterface\createQueue
createQueue()
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
db_query_range
db_query_range($query, $from, $count, array $args=array(), array $options=array())
Definition: database.inc:2374
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
DrupalQueueInterface\numberOfItems
numberOfItems()
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
SystemQueue\claimItem
claimItem($lease_time=30)
Definition: system.queue.inc:228
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
Generated on Mon Feb 3 2014 12:40:45 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/locale/locale.install Source File

  • modules
  • locale
locale.install
Go to the documentation of this file.
1 <?php
2
11 function locale_install() {
12 // locales_source.source and locales_target.target are not used as binary
13 // fields; non-MySQL database servers need to ensure the field type is text
14 // and that LIKE produces a case-sensitive comparison.
15
16 db_insert('languages')
17 ->fields(array(
18 'language' => 'en',
19 'name' => 'English',
20 'native' => 'English',
21 'direction' => 0,
22 'enabled' => 1,
23 'weight' => 0,
24 'javascript' => '',
25 ))
26 ->execute();
27 }
28
37 function locale_update_7000() {
38 db_drop_index('locales_source', 'source');
39 db_add_index('locales_source', 'source_context', array(array('source', 30), 'context'));
40
41 // Also drop the 'textgroup_location' index added by the i18nstrings module
42 // of the i18n project, which prevents the below schema update from running.
43 if (db_index_exists('locales_source', 'textgroup_location')) {
44 db_drop_index('locales_source', 'textgroup_location');
45 }
46
47 db_change_field('locales_source', 'location', 'location', array(
48 'type' => 'text',
49 'not null' => FALSE,
50 'size' => 'big',
51 'description' => 'Drupal path in case of online discovered translations or file path in case of imported strings.',
52 ));
53 }
54
58 function locale_update_7001() {
59 require_once DRUPAL_ROOT . '/includes/language.inc';
60 require_once DRUPAL_ROOT . '/includes/locale.inc';
61 require_once DRUPAL_ROOT . '/modules/locale/locale.module';
62
63 switch (variable_get('language_negotiation', 0)) {
64 // LANGUAGE_NEGOTIATION_NONE.
65 case 0:
66 $negotiation = array();
67 break;
68
69 // LANGUAGE_NEGOTIATION_PATH_DEFAULT.
70 case 1:
71 $negotiation = array(LOCALE_LANGUAGE_NEGOTIATION_URL);
72 // In Drupal 6 path prefixes are shown for the default language only when
73 // language negotiation is set to LANGUAGE_NEGOTIATION_PATH, while in
74 // Drupal 7 path prefixes are always shown if not empty. Hence we need to
75 // ensure that the default language has an empty prefix to avoid breaking
76 // the site URLs with a prefix that previously was missing.
77 $default = language_default();
78 $default->prefix = '';
79 variable_set('language_default', $default);
80 db_update('languages')
81 ->fields(array('prefix' => $default->prefix))
82 ->condition('language', $default->language)
83 ->execute();
84 break;
85
86 // LANGUAGE_NEGOTIATION_PATH.
87 case 2:
88 $negotiation = array(LOCALE_LANGUAGE_NEGOTIATION_URL, LOCALE_LANGUAGE_NEGOTIATION_USER, LOCALE_LANGUAGE_NEGOTIATION_BROWSER);
89 break;
90
91 // LANGUAGE_NEGOTIATION_DOMAIN.
92 case 3:
93 variable_set('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN);
94 $negotiation = array(LOCALE_LANGUAGE_NEGOTIATION_URL);
95 break;
96 }
97
98 // Save the new language negotiation options.
99 language_negotiation_set(LANGUAGE_TYPE_INTERFACE, array_flip($negotiation));
100 language_negotiation_set(LANGUAGE_TYPE_CONTENT, array(LOCALE_LANGUAGE_NEGOTIATION_INTERFACE => 0));
101 language_negotiation_set(LANGUAGE_TYPE_URL, array(LOCALE_LANGUAGE_NEGOTIATION_URL => 0));
102
103 // Save admininstration UI settings.
104 $type = LANGUAGE_TYPE_INTERFACE;
105 $provider_weights = array_flip(array_keys(locale_language_negotiation_info()));
106 variable_set("locale_language_providers_weight_$type", $provider_weights);
107
108 // Unset the old language negotiation system variable.
109 variable_del('language_negotiation');
110
111 return array();
112 }
113
117 function locale_update_7002() {
118 // language.inc may not have been included during bootstrap if there is not
119 // more than one language currently enabled.
120 require_once DRUPAL_ROOT . '/includes/language.inc';
121 $language_types_info = language_types_info();
122 $info = $language_types_info[LANGUAGE_TYPE_URL];
123 if (isset($info['fixed'])) {
124 language_negotiation_set(LANGUAGE_TYPE_URL, array_flip($info['fixed']));
125 }
126 }
127
140 function locale_update_7003() {
141 $languages = language_list('enabled');
142 variable_set('language_count', count($languages[1]));
143 }
144
148 function locale_update_7004() {
149 // Look up all duplicates. For each set of duplicates, we select the row
150 // with the lowest lid as the "master" that will be preserved.
151 $result_source = db_query("SELECT MIN(lid) AS lid, source, context FROM {locales_source} WHERE textgroup = 'default' GROUP BY source, context HAVING COUNT(*) > 1");
152
153 $conflict = FALSE;
154 foreach ($result_source as $source) {
155 // Find all rows in {locales_target} that are translations of the same
156 // string (incl. context).
157 $result_target = db_query("SELECT t.lid, t.language, t.plural, t.translation FROM {locales_source} s JOIN {locales_target} t ON s.lid = t.lid WHERE s.source = :source AND s.context = :context AND s.textgroup = 'default' ORDER BY lid", array(
158 ':source' => $source->source,
159 ':context' => $source->context,
160 ));
161
162 $translations = array();
163 $keep_lids = array($source->lid);
164 foreach ($result_target as $target) {
165 if (!isset($translations[$target->language])) {
166 $translations[$target->language] = $target->translation;
167 if ($target->lid != $source->lid) {
168 // Move translation to the master lid.
169 db_query('UPDATE {locales_target} SET lid = :new_lid WHERE lid = :old_lid', array(
170 ':new_lid' => $source->lid,
171 ':old_lid' => $target->lid));
172 }
173 }
174 elseif ($translations[$target->language] == $target->translation) {
175 // Delete duplicate translation.
176 db_query('DELETE FROM {locales_target} WHERE lid = :lid AND language = :language', array(
177 ':lid' => $target->lid,
178 ':language' => $target->language));
179 }
180 else {
181 // The same string is translated into several different strings in one
182 // language. We do not know which is the preferred, so we keep them all.
183 $keep_lids[] = $target->lid;
184 $conflict = TRUE;
185 }
186 }
187
188 // Delete rows in {locales_source} that are no longer referenced from
189 // {locales_target}.
190 db_delete('locales_source')
191 ->condition('source', $source->source)
192 ->condition('context', $source->context)
193 ->condition('textgroup', 'default')
194 ->condition('lid', $keep_lids, 'NOT IN')
195 ->execute();
196 }
197
198 if ($conflict) {
199 $url = 'http://drupal.org/node/746240';
200 drupal_set_message('Your {locales_source} table contains duplicates that could not be removed automatically. See <a href="' . $url .'" target="_blank">' . $url . '</a> for more information.', 'warning');
201 }
202 }
203
207 function locale_update_7005() {
208 db_change_field('languages', 'formula', 'formula', array(
209 'type' => 'varchar',
210 'length' => 255,
211 'not null' => TRUE,
212 'default' => '',
213 'description' => 'Plural formula in PHP code to evaluate to get plural indexes.',
214 ));
215 }
216
224 function locale_uninstall() {
225 // Delete all JavaScript translation files.
226 $locale_js_directory = 'public://' . variable_get('locale_js_directory', 'languages');
227
228 if (is_dir($locale_js_directory)) {
229 $files = db_query('SELECT language, javascript FROM {languages}');
230 foreach ($files as $file) {
231 if (!empty($file->javascript)) {
232 file_unmanaged_delete($locale_js_directory . '/' . $file->language . '_' . $file->javascript . '.js');
233 }
234 }
235 // Delete the JavaScript translations directory if empty.
236 if (!file_scan_directory($locale_js_directory, '/.*/')) {
237 drupal_rmdir($locale_js_directory);
238 }
239 }
240
241 // Clear variables.
242 variable_del('language_default');
243 variable_del('language_count');
244 variable_del('language_types');
245 variable_del('locale_language_negotiation_url_part');
246 variable_del('locale_language_negotiation_session_param');
247 variable_del('language_content_type_default');
248 variable_del('language_content_type_negotiation');
249 variable_del('locale_cache_strings');
250 variable_del('locale_js_directory');
251 variable_del('javascript_parsed');
252 variable_del('locale_field_language_fallback');
253 variable_del('locale_cache_length');
254
255 foreach (language_types() as $type) {
256 variable_del("language_negotiation_$type");
257 variable_del("locale_language_providers_weight_$type");
258 }
259
260 foreach (node_type_get_types() as $type => $content_type) {
261 $setting = variable_del("language_content_type_$type");
262 }
263
264 // Switch back to English: with a $language->language value different from 'en'
265 // successive calls of t() might result in calling locale(), which in turn might
266 // try to query the unexisting {locales_source} and {locales_target} tables.
267 drupal_language_initialize();
268
269 }
270
274 function locale_schema() {
275 $schema['languages'] = array(
276 'description' => 'List of all available languages in the system.',
277 'fields' => array(
278 'language' => array(
279 'type' => 'varchar',
280 'length' => 12,
281 'not null' => TRUE,
282 'default' => '',
283 'description' => "Language code, e.g. 'de' or 'en-US'.",
284 ),
285 'name' => array(
286 'type' => 'varchar',
287 'length' => 64,
288 'not null' => TRUE,
289 'default' => '',
290 'description' => 'Language name in English.',
291 ),
292 'native' => array(
293 'type' => 'varchar',
294 'length' => 64,
295 'not null' => TRUE,
296 'default' => '',
297 'description' => 'Native language name.',
298 ),
299 'direction' => array(
300 'type' => 'int',
301 'not null' => TRUE,
302 'default' => 0,
303 'description' => 'Direction of language (Left-to-Right = 0, Right-to-Left = 1).',
304 ),
305 'enabled' => array(
306 'type' => 'int',
307 'not null' => TRUE,
308 'default' => 0,
309 'description' => 'Enabled flag (1 = Enabled, 0 = Disabled).',
310 ),
311 'plurals' => array(
312 'type' => 'int',
313 'not null' => TRUE,
314 'default' => 0,
315 'description' => 'Number of plural indexes in this language.',
316 ),
317 'formula' => array(
318 'type' => 'varchar',
319 'length' => 255,
320 'not null' => TRUE,
321 'default' => '',
322 'description' => 'Plural formula in PHP code to evaluate to get plural indexes.',
323 ),
324 'domain' => array(
325 'type' => 'varchar',
326 'length' => 128,
327 'not null' => TRUE,
328 'default' => '',
329 'description' => 'Domain to use for this language.',
330 ),
331 'prefix' => array(
332 'type' => 'varchar',
333 'length' => 128,
334 'not null' => TRUE,
335 'default' => '',
336 'description' => 'Path prefix to use for this language.',
337 ),
338 'weight' => array(
339 'type' => 'int',
340 'not null' => TRUE,
341 'default' => 0,
342 'description' => 'Weight, used in lists of languages.',
343 ),
344 'javascript' => array(
345 'type' => 'varchar',
346 'length' => 64,
347 'not null' => TRUE,
348 'default' => '',
349 'description' => 'Location of JavaScript translation file.',
350 ),
351 ),
352 'primary key' => array('language'),
353 'indexes' => array(
354 'list' => array('weight', 'name'),
355 ),
356 );
357
358 $schema['locales_source'] = array(
359 'description' => 'List of English source strings.',
360 'fields' => array(
361 'lid' => array(
362 'type' => 'serial',
363 'not null' => TRUE,
364 'description' => 'Unique identifier of this string.',
365 ),
366 'location' => array(
367 'type' => 'text',
368 'not null' => FALSE,
369 'size' => 'big',
370 'description' => 'Drupal path in case of online discovered translations or file path in case of imported strings.',
371 ),
372 'textgroup' => array(
373 'type' => 'varchar',
374 'length' => 255,
375 'not null' => TRUE,
376 'default' => 'default',
377 'description' => 'A module defined group of translations, see hook_locale().',
378 ),
379 'source' => array(
380 'type' => 'text',
381 'mysql_type' => 'blob',
382 'not null' => TRUE,
383 'description' => 'The original string in English.',
384 ),
385 'context' => array(
386 'type' => 'varchar',
387 'length' => 255,
388 'not null' => TRUE,
389 'default' => '',
390 'description' => 'The context this string applies to.',
391 ),
392 'version' => array(
393 'type' => 'varchar',
394 'length' => 20,
395 'not null' => TRUE,
396 'default' => 'none',
397 'description' => 'Version of Drupal, where the string was last used (for locales optimization).',
398 ),
399 ),
400 'primary key' => array('lid'),
401 'indexes' => array(
402 'source_context' => array(array('source', 30), 'context'),
403 ),
404 );
405
406 $schema['locales_target'] = array(
407 'description' => 'Stores translated versions of strings.',
408 'fields' => array(
409 'lid' => array(
410 'type' => 'int',
411 'not null' => TRUE,
412 'default' => 0,
413 'description' => 'Source string ID. References {locales_source}.lid.',
414 ),
415 'translation' => array(
416 'type' => 'text',
417 'mysql_type' => 'blob',
418 'not null' => TRUE,
419 'description' => 'Translation string value in this language.',
420 ),
421 'language' => array(
422 'type' => 'varchar',
423 'length' => 12,
424 'not null' => TRUE,
425 'default' => '',
426 'description' => 'Language code. References {languages}.language.',
427 ),
428 'plid' => array(
429 'type' => 'int',
430 'not null' => TRUE, // This should be NULL for no referenced string, not zero.
431 'default' => 0,
432 'description' => 'Parent lid (lid of the previous string in the plural chain) in case of plural strings. References {locales_source}.lid.',
433 ),
434 'plural' => array(
435 'type' => 'int',
436 'not null' => TRUE,
437 'default' => 0,
438 'description' => 'Plural index number in case of plural strings.',
439 ),
440 ),
441 'primary key' => array('language', 'lid', 'plural'),
442 'foreign keys' => array(
443 'locales_source' => array(
444 'table' => 'locales_source',
445 'columns' => array('lid' => 'lid'),
446 ),
447 ),
448 'indexes' => array(
449 'lid' => array('lid'),
450 'plid' => array('plid'),
451 'plural' => array('plural'),
452 ),
453 );
454
455 return $schema;
456 }
457
db_add_index
db_add_index($table, $name, $fields)
Definition: database.inc:2940
LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN
const LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN
Definition: locale.inc:97
LOCALE_LANGUAGE_NEGOTIATION_BROWSER
const LOCALE_LANGUAGE_NEGOTIATION_BROWSER
Definition: locale.inc:17
file_scan_directory
file_scan_directory($dir, $mask, $options=array(), $depth=0)
Definition: file.inc:2058
DRUPAL_ROOT
const DRUPAL_ROOT
Definition: authorize.php:26
locale_update_7002
locale_update_7002()
Definition: locale.install:117
LOCALE_LANGUAGE_NEGOTIATION_INTERFACE
const LOCALE_LANGUAGE_NEGOTIATION_INTERFACE
Definition: locale.inc:22
variable_del
variable_del($name)
Definition: bootstrap.inc:996
db_delete
db_delete($table, array $options=array())
Definition: database.inc:2477
db_drop_index
db_drop_index($table, $name)
Definition: database.inc:2952
LANGUAGE_TYPE_CONTENT
const LANGUAGE_TYPE_CONTENT
Definition: bootstrap.inc:186
db_change_field
db_change_field($table, $field, $field_new, $spec, $keys_new=array())
Definition: database.inc:3016
language_negotiation_set
language_negotiation_set($type, $language_providers)
Definition: language.inc:347
locale_uninstall
locale_uninstall()
Definition: locale.install:224
locale_update_7001
locale_update_7001()
Definition: locale.install:58
locale_update_7000
locale_update_7000()
Definition: locale.install:37
LOCALE_LANGUAGE_NEGOTIATION_URL
const LOCALE_LANGUAGE_NEGOTIATION_URL
Definition: locale.inc:12
LOCALE_LANGUAGE_NEGOTIATION_USER
const LOCALE_LANGUAGE_NEGOTIATION_USER
Definition: locale.inc:33
node_type_get_types
node_type_get_types()
Definition: node.module:393
$url
print $url
Definition: search-result.tpl.php:70
$info
$info
Definition: color.inc:6
locale_update_7004
locale_update_7004()
Definition: locale.install:148
drupal_rmdir
drupal_rmdir($uri, $context=NULL)
Definition: file.inc:2389
language_list
language_list($field= 'language')
Definition: bootstrap.inc:2723
locale_update_7005
locale_update_7005()
Definition: locale.install:207
locale_schema
locale_schema()
Definition: locale.install:274
drupal_set_message
drupal_set_message($message=NULL, $type= 'status', $repeat=TRUE)
Definition: bootstrap.inc:1777
locale_language_negotiation_info
locale_language_negotiation_info()
Definition: locale.module:566
file_unmanaged_delete
file_unmanaged_delete($path)
Definition: file.inc:1317
LANGUAGE_TYPE_URL
const LANGUAGE_TYPE_URL
Definition: bootstrap.inc:196
language_types_info
language_types_info()
Definition: language.inc:110
db_index_exists
db_index_exists($table, $name)
Definition: database.inc:2747
locale_install
locale_install()
Definition: locale.install:11
drupal_language_initialize
drupal_language_initialize()
Definition: bootstrap.inc:2648
language_default
language_default($property=NULL)
Definition: bootstrap.inc:2765
LANGUAGE_TYPE_INTERFACE
const LANGUAGE_TYPE_INTERFACE
Definition: bootstrap.inc:191
variable_set
variable_set($name, $value)
Definition: bootstrap.inc:973
db_insert
db_insert($table, array $options=array())
Definition: database.inc:2423
locale_update_7003
locale_update_7003()
Definition: locale.install:140
variable_get
variable_get($name, $default=NULL)
Definition: bootstrap.inc:951
db_query
db_query($query, array $args=array(), array $options=array())
Definition: database.inc:2342
db_update
db_update($table, array $options=array())
Definition: database.inc:2459
language_types
language_types()
Definition: bootstrap.inc:2705
Generated on Mon Feb 3 2014 12:40:43 for Drupal 7 by doxygen 1.8.5


Drupal 7: modules/system/page.tpl.php Source File

  • modules
  • system
page.tpl.php
Go to the documentation of this file.
1 <?php
2
74 ?>
75
76 <div id="page-wrapper"><div id="page">
77
78 <div id="header"><div class="section clearfix">
79
80 <?php if ($logo): ?>
81 <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
82 <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
83 </a>
84 <?php endif; ?>
85
86 <?php if ($site_name || $site_slogan): ?>
87 <div id="name-and-slogan">
88 <?php if ($site_name): ?>
89 <?php if ($title): ?>
90 <div id="site-name"><strong>
91 <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
92 </strong></div>
93 <?php else: /* Use h1 when the content title is empty */ ?>
94 <h1 id="site-name">
95 <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
96 </h1>
97 <?php endif; ?>
98 <?php endif; ?>
99
100 <?php if ($site_slogan): ?>
101 <div id="site-slogan"><?php print $site_slogan; ?></div>
102 <?php endif; ?>
103 </div> <!-- /#name-and-slogan -->
104 <?php endif; ?>
105
106 <?php print render($page['header']); ?>
107
108 </div></div> <!-- /.section, /#header -->
109
110 <?php if ($main_menu || $secondary_menu): ?>
111 <div id="navigation"><div class="section">
112 <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'inline', 'clearfix')), 'heading' => t('Main menu'))); ?>
113 <?php print theme('links__system_secondary_menu', array('links' => $secondary_menu, 'attributes' => array('id' => 'secondary-menu', 'class' => array('links', 'inline', 'clearfix')), 'heading' => t('Secondary menu'))); ?>
114 </div></div> <!-- /.section, /#navigation -->
115 <?php endif; ?>
116
117 <?php if ($breadcrumb): ?>
118 <div id="breadcrumb"><?php print $breadcrumb; ?></div>
119 <?php endif; ?>
120
121 <?php print $messages; ?>
122
123 <div id="main-wrapper"><div id="main" class="clearfix">
124
125 <div id="content" class="column"><div class="section">
126 <?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?>
127 <a id="main-content"></a>
128 <?php print render($title_prefix); ?>
129 <?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
130 <?php print render($title_suffix); ?>
131 <?php if ($tabs): ?><div class="tabs"><?php print render($tabs); ?></div><?php endif; ?>
132 <?php print render($page['help']); ?>
133 <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?>
134 <?php print render($page['content']); ?>
135 <?php print $feed_icons; ?>
136 </div></div> <!-- /.section, /#content -->
137
138 <?php if ($page['sidebar_first']): ?>
139 <div id="sidebar-first" class="column sidebar"><div class="section">
140 <?php print render($page['sidebar_first']); ?>
141 </div></div> <!-- /.section, /#sidebar-first -->
142 <?php endif; ?>
143
144 <?php if ($page['sidebar_second']): ?>
145 <div id="sidebar-second" class="column sidebar"><div class="section">
146 <?php print render($page['sidebar_second']); ?>
147 </div></div> <!-- /.section, /#sidebar-second -->
148 <?php endif; ?>
149
150 </div></div> <!-- /#main, /#main-wrapper -->
151
152 <div id="footer"><div class="section">
153 <?php print render($page['footer']); ?>
154 </div></div> <!-- /.section, /#footer -->
155
156 </div></div> <!-- /#page, /#page-wrapper -->
$page
print $page
Definition: overlay.tpl.php:37
$secondary_menu
print $secondary_menu
Definition: page.tpl.php:90
name
print $forum name
Definition: forum-list.tpl.php:57
print
print
Definition: php-2.php:2
$feed_icons
print $feed_icons
Definition: page.tpl.php:135
$logo
print $logo
Definition: maintenance-page.tpl.php:33
t
t($string, array $args=array(), array $options=array())
Definition: bootstrap.inc:1459
$site_slogan
if($site_slogan)($hide_site_slogan) print $site_slogan
Definition: maintenance-page.tpl.php:41
$title
print $title
Definition: contextual-links-example-object.tpl.php:33
endif
endif
Definition: aggregator-item.tpl.php:31
$messages
print $messages
Definition: page.tpl.php:121
render
render(&$element)
Definition: common.inc:5988
$breadcrumb
print $breadcrumb
Definition: page.tpl.php:40
title
print $topic title
Definition: forum-topic-list.tpl.php:50
theme
theme($hook, $variables=array())
Definition: theme.inc:1012
$site_name
print $site_name
Definition: maintenance-page.tpl.php:40
Generated on Mon Feb 3 2014 12:40:44 for Drupal 7 by doxygen 1.8.5